%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/ava/mod/forum/amd/build/grades/
Upload File :
Create Path :
Current File : /home/vacivi36/ava/mod/forum/amd/build/grades/expandconversation.min.js.map

{"version":3,"file":"expandconversation.min.js","sources":["../../src/grades/expandconversation.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * This module handles the creation of a Modal that shows the user's post in context of the entire discussion.\n *\n * @module     mod_forum/grades/expandconversation\n * @copyright  2019 Mathew May <mathew.solutions>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport * as ForumSelectors from './grader/selectors';\nimport Repository from 'mod_forum/repository';\nimport {exception as showException} from \"core/notification\";\nimport Templates from 'core/templates';\nimport * as Modal from 'core/modal_factory';\nimport * as ModalEvents from 'core/modal_events';\n\n/**\n * Find the Node containing the gradable details from the provided node by searching up the tree.\n *\n * @param {HTMLElement} node\n * @returns {HTMLElement}\n */\nconst findGradableNode = node => node.closest(ForumSelectors.expandConversation);\n\n/**\n * Show the post in context in a modal.\n *\n * @param {HTMLElement} rootNode The button that has been clicked\n * @param {object} param\n * @param {bool} [param.focusOnClose=null]\n */\nconst showPostInContext = async(rootNode, {\n    focusOnClose = null,\n} = {}) => {\n    const postId = rootNode.dataset.postid;\n    const discussionId = rootNode.dataset.discussionid;\n    const discussionName = rootNode.dataset.name;\n    const experimentalDisplayMode = rootNode.dataset.experimentalDisplayMode == \"1\";\n\n    const [\n        allPosts,\n        modal,\n    ] = await Promise.all([\n        Repository.getDiscussionPosts(parseInt(discussionId)),\n        Modal.create({\n            title: discussionName,\n            large: true,\n            type: Modal.types.CANCEL\n        }),\n    ]);\n\n    const postsById = new Map(allPosts.posts.map(post => {\n        post.readonly = true;\n        post.hasreplies = false;\n        post.replies = [];\n        return [post.id, post];\n    }));\n\n    let posts = [];\n    allPosts.posts.forEach(post => {\n        if (post.parentid) {\n            const parent = postsById.get(post.parentid);\n            if (parent) {\n                post.parentauthorname = parent.author.fullname;\n                parent.hasreplies = true;\n                parent.replies.push(post);\n            } else {\n                posts.push(post);\n            }\n        } else {\n            posts.push(post);\n        }\n    });\n\n    // Handle hidden event.\n    modal.getRoot().on(ModalEvents.hidden, function() {\n        // Destroy when hidden.\n        modal.destroy();\n        try {\n            focusOnClose.focus();\n        } catch (e) {\n            // eslint-disable-line\n        }\n    });\n\n    modal.getRoot().on(ModalEvents.bodyRendered, () => {\n        const relevantPost = modal.getRoot()[0].querySelector(`#p${postId}`);\n        if (relevantPost) {\n            relevantPost.scrollIntoView({behavior: \"smooth\"});\n        }\n    });\n\n    modal.show();\n\n    // Note: We do not use await here because it messes with the Modal transitions.\n    const templatePromise = Templates.render('mod_forum/grades/grader/discussion/post_modal', {\n        posts,\n        experimentaldisplaymode: experimentalDisplayMode\n    });\n    modal.setBody(templatePromise);\n};\n\n/**\n * Register event listeners for the expand conversations button.\n *\n * @param {HTMLElement} rootNode The root to listen to.\n */\nexport const registerEventListeners = (rootNode) => {\n    rootNode.addEventListener('click', (e) => {\n        const rootNode = findGradableNode(e.target);\n\n        if (rootNode) {\n            e.preventDefault();\n\n            try {\n                showPostInContext(rootNode, {\n                    focusOnClose: e.target,\n                });\n            } catch (err) {\n                showException(err);\n            }\n        }\n    });\n};\n"],"names":["rootNode","addEventListener","e","target","closest","ForumSelectors","expandConversation","preventDefault","async","focusOnClose","postId","dataset","postid","discussionId","discussionid","discussionName","name","experimentalDisplayMode","allPosts","modal","Promise","all","Repository","getDiscussionPosts","parseInt","Modal","create","title","large","type","types","CANCEL","postsById","Map","posts","map","post","readonly","hasreplies","replies","id","forEach","parentid","parent","get","parentauthorname","author","fullname","push","getRoot","on","ModalEvents","hidden","destroy","focus","bodyRendered","relevantPost","querySelector","scrollIntoView","behavior","show","templatePromise","Templates","render","experimentaldisplaymode","setBody","showPostInContext","err"],"mappings":";;;;;;;+WAwHuCA,WACnCA,SAASC,iBAAiB,SAAUC,UAC1BF,SAA4BE,EAAEC,OAvFNC,QAAQC,eAAeC,uBAyFjDN,SAAU,CACVE,EAAEK,sBAjFYC,eAAMR,cAAUS,aACtCA,aAAe,6DACf,SACMC,OAASV,SAASW,QAAQC,OAC1BC,aAAeb,SAASW,QAAQG,aAChCC,eAAiBf,SAASW,QAAQK,KAClCC,wBAAsE,KAA5CjB,SAASW,QAAQM,yBAG7CC,SACAC,aACMC,QAAQC,IAAI,CAClBC,oBAAWC,mBAAmBC,SAASX,eACvCY,MAAMC,OAAO,CACTC,MAAOZ,eACPa,OAAO,EACPC,KAAMJ,MAAMK,MAAMC,WAIpBC,UAAY,IAAIC,IAAIf,SAASgB,MAAMC,KAAIC,OACzCA,KAAKC,UAAW,EAChBD,KAAKE,YAAa,EAClBF,KAAKG,QAAU,GACR,CAACH,KAAKI,GAAIJ,cAGjBF,MAAQ,GACZhB,SAASgB,MAAMO,SAAQL,UACfA,KAAKM,SAAU,OACTC,OAASX,UAAUY,IAAIR,KAAKM,UAC9BC,QACAP,KAAKS,iBAAmBF,OAAOG,OAAOC,SACtCJ,OAAOL,YAAa,EACpBK,OAAOJ,QAAQS,KAAKZ,OAEpBF,MAAMc,KAAKZ,WAGfF,MAAMc,KAAKZ,SAKnBjB,MAAM8B,UAAUC,GAAGC,YAAYC,QAAQ,WAEnCjC,MAAMkC,cAEF5C,aAAa6C,QACf,MAAOpD,QAKbiB,MAAM8B,UAAUC,GAAGC,YAAYI,cAAc,WACnCC,aAAerC,MAAM8B,UAAU,GAAGQ,0BAAmB/C,SACvD8C,cACAA,aAAaE,eAAe,CAACC,SAAU,cAI/CxC,MAAMyC,aAGAC,gBAAkBC,mBAAUC,OAAO,gDAAiD,CACtF7B,MAAAA,MACA8B,wBAAyB/C,0BAE7BE,MAAM8C,QAAQJ,iBAgBFK,CAAkBlE,SAAU,CACxBS,aAAcP,EAAEC,SAEtB,MAAOgE,iCACSA"}

Zerion Mini Shell 1.0