Sindbad~EG File Manager
{"version":3,"file":"comment.min.js","sources":["../src/comment.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 * Column selector js.\n *\n * @module qbank_comment/comment\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Safat Shahin <safatshahin@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Fragment from 'core/fragment';\nimport * as Str from 'core/str';\nimport ModalEvents from 'core/modal_events';\nimport ModalFactory from 'core/modal_factory';\nimport Notification from 'core/notification';\n\n/**\n * Event listeners for the module.\n *\n * @method clickEvent\n * @param {Number} questionId\n * @param {Number} courseID\n * @param {Number} contextId\n */\nconst commentEvent = (questionId, courseID, contextId) => {\n let args = {\n questionid: questionId,\n courseid: courseID\n };\n let commentFragment = Fragment.loadFragment('qbank_comment', 'question_comment', contextId, args);\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: Str.get_string('commentheader', 'qbank_comment'),\n body: commentFragment,\n large: true,\n }).then((modal) => {\n let root = modal.getRoot();\n\n // Don't display the default add comment link in the modal.\n root.on(ModalEvents.bodyRendered, function() {\n const submitlink = document.querySelectorAll(\"div.comment-area a\")[0];\n submitlink.style.display = 'none';\n });\n\n // Get the required strings and updated the modal button text labels.\n Str.get_strings([\n {key: 'addcomment', component: 'qbank_comment'},\n {key: 'close', component: 'qbank_comment'},\n ]).then((strings) => {\n modal.setButtonText('save', strings[0]);\n modal.setButtonText('cancel', strings[1]);\n return;\n }).fail(Notification.exception);\n\n root.on(ModalEvents.cancel, function() {\n location.reload();\n modal.hide();\n });\n\n // Handle adding the comment when the button in the modal is clicked.\n root.on(ModalEvents.save, function(e) {\n e.preventDefault();\n const submitlink = document.querySelectorAll(\"div.comment-area a\")[0];\n const textarea = document.querySelectorAll(\"div.comment-area textarea\")[0];\n\n // Check there is a valid comment to add, and trigger adding if there is.\n if (textarea.value != textarea.getAttribute('aria-label') && textarea.value != '') {\n submitlink.click();\n }\n\n });\n root.on('click', 'button[data-action=\"hide\"]', () => {\n location.reload();\n modal.hide();\n });\n modal.show();\n return modal;\n }).fail(Notification.exception);\n};\n\n/**\n * Entrypoint of the js.\n *\n * @method init\n * @param {string} questionSelector the question comment identifier.\n */\nexport const init = (questionSelector) => {\n const target = document.querySelector(questionSelector);\n target.addEventListener('click', () => {\n // Call for the event listener to listed for clicks in any comment count row.\n commentEvent(target.dataset.questionid, target.dataset.courseid, target.dataset.contextid);\n });\n};\n"],"names":["questionSelector","target","document","querySelector","addEventListener","questionId","courseID","contextId","args","questionid","courseid","commentFragment","Fragment","loadFragment","create","type","ModalFactory","types","SAVE_CANCEL","title","Str","get_string","body","large","then","modal","root","getRoot","on","ModalEvents","bodyRendered","querySelectorAll","style","display","get_strings","key","component","strings","setButtonText","fail","Notification","exception","cancel","location","reload","hide","save","e","preventDefault","submitlink","textarea","value","getAttribute","click","show","commentEvent","dataset","contextid"],"mappings":";;;;;;;;g8BAoGqBA,yBACXC,OAASC,SAASC,cAAcH,kBACtCC,OAAOG,iBAAiB,SAAS,KAhEhB,EAACC,WAAYC,SAAUC,iBACpCC,KAAO,CACPC,WAAYJ,WACZK,SAAUJ,UAEVK,gBAAkBC,kBAASC,aAAa,gBAAiB,mBAAoBN,UAAWC,6BAC/EM,OAAO,CAChBC,KAAMC,uBAAaC,MAAMC,YACzBC,MAAOC,IAAIC,WAAW,gBAAiB,iBACvCC,KAAMX,gBACNY,OAAO,IACRC,MAAMC,YACDC,KAAOD,MAAME,iBAGjBD,KAAKE,GAAGC,sBAAYC,cAAc,WACX5B,SAAS6B,iBAAiB,sBAAsB,GACxDC,MAAMC,QAAU,UAI/Bb,IAAIc,YAAY,CACZ,CAACC,IAAK,aAAcC,UAAW,iBAC/B,CAACD,IAAK,QAASC,UAAW,mBAC3BZ,MAAMa,UACLZ,MAAMa,cAAc,OAAQD,QAAQ,IACpCZ,MAAMa,cAAc,SAAUD,QAAQ,OAEvCE,KAAKC,sBAAaC,WAErBf,KAAKE,GAAGC,sBAAYa,QAAQ,WACxBC,SAASC,SACTnB,MAAMoB,UAIVnB,KAAKE,GAAGC,sBAAYiB,MAAM,SAASC,GAC/BA,EAAEC,uBACIC,WAAa/C,SAAS6B,iBAAiB,sBAAsB,GAC7DmB,SAAWhD,SAAS6B,iBAAiB,6BAA6B,GAGpEmB,SAASC,OAASD,SAASE,aAAa,eAAmC,IAAlBF,SAASC,OAClEF,WAAWI,WAInB3B,KAAKE,GAAG,QAAS,8BAA8B,KAC3Ce,SAASC,SACTnB,MAAMoB,UAEVpB,MAAM6B,OACC7B,SACRc,KAAKC,sBAAaC,YAajBc,CAAatD,OAAOuD,QAAQ/C,WAAYR,OAAOuD,QAAQ9C,SAAUT,OAAOuD,QAAQC"}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists