Current Path : /var/www/ljmtc/cbt/mod/forum/amd/build/grades/ |
Current File : /var/www/ljmtc/cbt/mod/forum/amd/build/grades/expandconversation.min.js.map |
{"version":3,"sources":["../../src/grades/expandconversation.js"],"names":["findGradableNode","node","closest","ForumSelectors","expandConversation","showPostInContext","rootNode","focusOnClose","postId","dataset","postid","discussionId","discussionid","discussionName","name","experimentalDisplayMode","Promise","all","Repository","getDiscussionPosts","parseInt","Modal","create","title","large","type","types","CANCEL","allPosts","modal","postsById","Map","posts","map","post","readonly","hasreplies","replies","id","forEach","parentid","parent","get","parentauthorname","author","fullname","push","getRoot","on","ModalEvents","hidden","destroy","focus","e","bodyRendered","relevantPost","querySelector","scrollIntoView","behavior","show","templatePromise","Templates","render","experimentaldisplaymode","setBody","registerEventListeners","addEventListener","target","preventDefault","err"],"mappings":"6kBAuBA,OACA,OAEA,OACA,OACA,O,u3DAQMA,CAAAA,CAAgB,CAAG,SAAAC,CAAI,QAAIA,CAAAA,CAAI,CAACC,OAAL,CAAaC,CAAc,CAACC,kBAA5B,CAAJ,C,CAOvBC,CAAiB,4CAAG,WAAMC,CAAN,gKAEtB,EAFsB,KACtBC,YADsB,CACtBA,CADsB,YACP,IADO,GAGhBC,CAHgB,CAGPF,CAAQ,CAACG,OAAT,CAAiBC,MAHV,CAIhBC,CAJgB,CAIDL,CAAQ,CAACG,OAAT,CAAiBG,YAJhB,CAKhBC,CALgB,CAKCP,CAAQ,CAACG,OAAT,CAAiBK,IALlB,CAMhBC,CANgB,CAMsD,GAA5C,EAAAT,CAAQ,CAACG,OAAT,CAAiBM,uBAN3B,gBAWZC,CAAAA,OAAO,CAACC,GAAR,CAAY,CAClBC,UAAWC,kBAAX,CAA8BC,QAAQ,CAACT,CAAD,CAAtC,CADkB,CAElBU,CAAK,CAACC,MAAN,CAAa,CACTC,KAAK,CAAEV,CADE,CAETW,KAAK,GAFI,CAGTC,IAAI,CAAEJ,CAAK,CAACK,KAAN,CAAYC,MAHT,CAAb,CAFkB,CAAZ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AAI+C,CAAJ,CAAkB,CACdA,CAAY,CAACE,cAAb,CAA4B,CAACC,QAAQ,CAAE,QAAX,CAA5B,CACH,CACJ,CALD,EAOA7B,CAAK,CAAC8B,IAAN,GAGMC,CAhEgB,CAgEEC,UAAUC,MAAV,CAAiB,+CAAjB,CAAkE,CACtF9B,KAAK,CAALA,CADsF,CAEtF+B,uBAAuB,CAAEhD,CAF6D,CAAlE,CAhEF,CAoEtBc,CAAK,CAACmC,OAAN,CAAcJ,CAAd,EApEsB,yCAAH,uD,0BA4Ee,QAAzBK,CAAAA,sBAAyB,CAAC3D,CAAD,CAAc,CAChDA,CAAQ,CAAC4D,gBAAT,CAA0B,OAA1B,CAAmC,SAACb,CAAD,CAAO,CACtC,GAAM/C,CAAAA,CAAQ,CAAGN,CAAgB,CAACqD,CAAC,CAACc,MAAH,CAAjC,CAEA,GAAI7D,CAAJ,CAAc,CACV+C,CAAC,CAACe,cAAF,GAEA,GAAI,CACA/D,CAAiB,CAACC,CAAD,CAAW,CACxBC,YAAY,CAAE8C,CAAC,CAACc,MADQ,CAAX,CAGpB,CAAC,MAAOE,CAAP,CAAY,CACV,gBAAcA,CAAd,CACH,CACJ,CACJ,CAdD,CAeH,C","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 * @package mod_forum\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 */\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"],"file":"expandconversation.min.js"}