File: /var/www/html/demo.sumar.com.py/mod/pulse/amd/build/module.min.js.map
{"version":3,"file":"module.min.js","sources":["../src/module.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 * Module javascript to place the placeholders.\n * Modified version of IOMAD Email template emailvars.\n *\n * @module mod_pulse/module\n * @category Classes - autoloading\n * @copyright 2021, bdecent gmbh bdecent.de\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine([], function() {\n\n return {\n\n /**\n * Setup the classes to editors works with placeholders.\n */\n init: function() {\n var module = this;\n var templatevars = document.getElementsByClassName(\"fitem_id_templatevars_editor\");\n for (var l = 0; l < templatevars.length; l++) {\n templatevars[l].addEventListener('click', function() {\n var EditorInput = document.getElementById('id_pulse_content_editoreditable');\n module.insertCaretActive(EditorInput);\n });\n }\n var notificationheader = document.getElementById('admin-notificationheader');\n if (notificationheader !== null) {\n notificationheader.addEventListener('click', function() {\n var EditorInput = document.getElementById('id_s_mod_pulse_notificationheadereditable');\n module.insertCaretActive(EditorInput);\n });\n }\n\n var notificationfooter = document.getElementById('admin-notificationfooter');\n if (notificationfooter !== null) {\n notificationfooter.addEventListener('click', function() {\n var EditorInput = document.getElementById('id_s_mod_pulse_notificationfootereditable');\n module.insertCaretActive(EditorInput);\n });\n }\n\n var clickforword = document.getElementsByClassName('clickforword');\n for (var i = 0; i < clickforword.length; i++) {\n clickforword[i].addEventListener('click', function(e) {\n e.preventDefault(); // To prevent the default behaviour of a tag.\n module.insertAtCaret(\"{\" + this.getAttribute('data-text') + \"}\");\n });\n }\n\n // Make selected roles as badges in module edit form page.\n if (document.getElementById('page-mod-pulse-mod') !== null && document.getElementById('page-mod-pulse-mod')\n .querySelector(\"#fgroup_id_completionrequireapproval [data-fieldtype='autocomplete']\") !== null) {\n const textNodes = this.getAllTextNodes(\n document.getElementById('page-mod-pulse-mod')\n .querySelector(\"#fgroup_id_completionrequireapproval [data-fieldtype='autocomplete']\")\n );\n textNodes.forEach(node => {\n const span = document.createElement('span');\n span.classList = 'badge badge-info pulse-completion-roles';\n node.after(span);\n span.appendChild(node);\n });\n }\n },\n\n insertCaretActive: function(EditorInput) {\n var caret = document.getElementsByClassName(\"insertatcaretactive\");\n for (var j = 0; j < caret.length; j++) {\n caret[j].classList.remove(\"insertatcaretactive\");\n }\n EditorInput.classList.add(\"insertatcaretactive\");\n },\n\n /**\n * Filter text from node.\n * @param {string} element\n * @returns {array} list of childNodes.\n */\n getAllTextNodes: function(element) {\n return Array.from(element.childNodes)\n .filter(node => node.nodeType === 3 && node.textContent.trim().length > 1);\n },\n\n /**\n * Insert the placeholder in selected caret place.\n * @param {string} myValue\n */\n insertAtCaret: function(myValue) {\n var caretelements = document.getElementsByClassName(\"insertatcaretactive\");\n var sel, range;\n for (var n = 0; n < caretelements.length; n++) {\n var thiselem = caretelements[n];\n\n if (typeof thiselem.value === 'undefined' && window.getSelection) {\n sel = window.getSelection();\n if (sel.getRangeAt && sel.rangeCount) {\n range = sel.getRangeAt(0);\n range.deleteContents();\n range.insertNode(document.createTextNode(myValue));\n\n for (let position = 0; position != (myValue.length + 1); position++) {\n sel.modify(\"move\", \"right\", \"character\");\n }\n }\n } else if (typeof thiselem.value === 'undefined' && document.selection && document.selection.createRange) {\n range = document.selection.createRange();\n range.text = myValue;\n }\n\n if (typeof thiselem.value !== 'undefined') {\n if (document.selection) {\n // For browsers like Internet Explorer.\n thiselem.focus();\n sel = document.selection.createRange();\n sel.text = myValue;\n thiselem.focus();\n } else if (thiselem.selectionStart || thiselem.selectionStart == '0') {\n // For browsers like Firefox and Webkit based.\n var startPos = thiselem.selectionStart;\n var endPos = thiselem.selectionEnd;\n thiselem.value = thiselem.value.substring(0, startPos)\n + myValue + thiselem.value.substring(endPos, thiselem.value.length);\n thiselem.focus();\n thiselem.selectionStart = startPos + myValue.length;\n thiselem.selectionEnd = startPos + myValue.length;\n thiselem.focus();\n } else {\n thiselem.value += myValue;\n thiselem.focus();\n }\n }\n }\n },\n };\n});\n"],"names":["define","init","module","this","templatevars","document","getElementsByClassName","l","length","addEventListener","EditorInput","getElementById","insertCaretActive","notificationheader","notificationfooter","clickforword","i","e","preventDefault","insertAtCaret","getAttribute","querySelector","getAllTextNodes","forEach","node","span","createElement","classList","after","appendChild","caret","j","remove","add","element","Array","from","childNodes","filter","nodeType","textContent","trim","myValue","sel","range","caretelements","n","thiselem","value","window","getSelection","getRangeAt","rangeCount","deleteContents","insertNode","createTextNode","position","modify","selection","createRange","text","focus","selectionStart","startPos","endPos","selectionEnd","substring"],"mappings":";;;;;;;;;AAyBAA,0BAAO,IAAI,iBAEA,CAKHC,KAAM,mBACEC,OAASC,KACTC,aAAeC,SAASC,uBAAuB,gCAC1CC,EAAI,EAAGA,EAAIH,aAAaI,OAAQD,IACrCH,aAAaG,GAAGE,iBAAiB,SAAS,eAClCC,YAAcL,SAASM,eAAe,mCAC1CT,OAAOU,kBAAkBF,oBAG7BG,mBAAqBR,SAASM,eAAe,4BACtB,OAAvBE,oBACAA,mBAAmBJ,iBAAiB,SAAS,eACrCC,YAAcL,SAASM,eAAe,6CAC1CT,OAAOU,kBAAkBF,oBAI7BI,mBAAqBT,SAASM,eAAe,4BACtB,OAAvBG,oBACAA,mBAAmBL,iBAAiB,SAAS,eACrCC,YAAcL,SAASM,eAAe,6CAC1CT,OAAOU,kBAAkBF,wBAI7BK,aAAeV,SAASC,uBAAuB,gBAC1CU,EAAI,EAAGA,EAAID,aAAaP,OAAQQ,IACrCD,aAAaC,GAAGP,iBAAiB,SAAS,SAAS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