diff --git a/actions/notification/classes/notification.php b/actions/notification/classes/notification.php index 19d7d3d..1a5d9be 100644 --- a/actions/notification/classes/notification.php +++ b/actions/notification/classes/notification.php @@ -1086,6 +1086,7 @@ public static function get_modules_data($modules) { unset($newmod->cmid); foreach ($newmod as $name => $value) { $key = str_replace('local_metadata_field_', 'metadata', $name); + $key = strtolower($key); $mod->$key = $value; } } diff --git a/amd/build/module.min.js b/amd/build/module.min.js index 5bd06e9..9f30e2d 100644 --- a/amd/build/module.min.js +++ b/amd/build/module.min.js @@ -7,6 +7,6 @@ * @copyright 2021, bdecent gmbh bdecent.de * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("mod_pulse/module",["core_editor/events"],(function(){return{init:function(branch){for(var module=this,templatevars=document.getElementsByClassName("fitem_id_templatevars_editor"),l=0;l{elem.addEventListener("click",(function(e){var target=e.currentTarget,EditorInput=branch<="402"?target.querySelector('[id*="_editoreditable"]'):target.querySelector('textarea[id*="_content_editor"]');module.insertCaretActive(EditorInput)}))}));var headertargetNode=document.querySelector("#id_s_mod_pulse_notificationheader");if(null!==headertargetNode){new MutationObserver((function(){if("none"==headertargetNode.style.display){var headeriframe=document.querySelector("#admin-notificationheader iframe").contentDocument;null!==headeriframe&&headeriframe.addEventListener("click",(function(e){var headercontentBody=e.target.querySelector("body");null!==headercontentBody&&headercontentBody.classList.add("insertatcaretactive");var footerBody=document.querySelector("#admin-notificationfooter iframe").contentDocument.querySelector("body");footerBody.classList.contains("insertatcaretactive")&&footerBody.classList.remove("insertatcaretactive")}))}})).observe(headertargetNode,{attributes:!0,childList:!0})}var footertargetNode=document.querySelector("#id_s_mod_pulse_notificationfooter");if(null!==footertargetNode){new MutationObserver((function(){if("none"==footertargetNode.style.display){var footeriframe=document.querySelector("#admin-notificationfooter iframe").contentDocument;null!==footeriframe&&footeriframe.addEventListener("click",(function(e){var footercontentBody=e.target.querySelector("body");null!==footercontentBody&&footercontentBody.classList.add("insertatcaretactive");var headerBody=document.querySelector("#admin-notificationheader iframe").contentDocument.querySelector("body");headerBody.classList.contains("insertatcaretactive")&&headerBody.classList.remove("insertatcaretactive")}))}})).observe(footertargetNode,{attributes:!0,childList:!0})}var targetNode=document.querySelector("textarea[id$=_editor]");if(null!==targetNode){new MutationObserver((function(){"none"==targetNode.style.display&&setTimeout(initIframeListeners,100)})).observe(targetNode,{attributes:!0,childList:!0})}const initIframeListeners=()=>{let iframes=document.querySelectorAll('[data-fieldtype="editor"] iframe');return!(null===iframes||!iframes.length)&&(iframes.forEach((iframe=>{iframe.contentDocument.addEventListener("click",(function(){iframes.forEach((frame=>{var frameElem=frame.contentDocument.querySelector(".insertatcaretactive");null!==frameElem&&frameElem.classList.remove("insertatcaretactive")}));var contentBody=iframe.contentDocument.querySelector("body");null!==contentBody&&contentBody.classList.add("insertatcaretactive")}))})),!0)};for(var clickforword=document.getElementsByClassName("clickforword"),i=0;i{const span=document.createElement("span");span.classList="badge badge-info pulse-completion-roles",node.after(span),span.appendChild(node)}))}},insertCaretActive:function(EditorInput){if(null!==EditorInput){for(var caret=document.getElementsByClassName("insertatcaretactive"),j=0;j3===node.nodeType&&node.textContent.trim().length>1))},isSelectionInsideDiv:div=>{const selection=window.getSelection();if(0===selection.rangeCount)return!1;const startNode=selection.getRangeAt(0).startContainer,endNode=selection.getRangeAt(0).endContainer;return div.contains(startNode)&&div.contains(endNode)},insertAtCaret:function(myValue){for(var sel,range,caretelements=document.getElementsByClassName("insertatcaretactive"),n=0;n{elem.addEventListener("click",(function(e){var target=e.currentTarget,EditorInput=branch<="402"?target.querySelector('[id*="_editoreditable"]'):target.querySelector('textarea[id*="_content_editor"]');module.insertCaretActive(EditorInput)}))}));var headertargetNode=document.querySelector("#id_s_mod_pulse_notificationheader");if(null!==headertargetNode){new MutationObserver((function(){if("none"==headertargetNode.style.display&&null!==document.querySelector("#admin-notificationheader iframe")){var headercontent=document.querySelector("#admin-notificationheader iframe").contentDocument;headercontent.addEventListener("click",(function(){var headercontentBody=headercontent.querySelector("body");null!==headercontentBody&&headercontentBody.classList.add("insertatcaretactive");var footerBody=document.querySelector("#admin-notificationfooter iframe").contentDocument.querySelector("body");footerBody.classList.contains("insertatcaretactive")&&footerBody.classList.remove("insertatcaretactive")}))}})).observe(headertargetNode,{attributes:!0,childList:!0})}var footertargetNode=document.querySelector("#id_s_mod_pulse_notificationfooter");if(null!==footertargetNode){new MutationObserver((function(){if("none"==footertargetNode.style.display&&null!==document.querySelector("#admin-notificationfooter iframe")){var footercontent=document.querySelector("#admin-notificationfooter iframe").contentDocument;footercontent.addEventListener("click",(function(){var footercontentBody=footercontent.querySelector("body");null!==footercontentBody&&footercontentBody.classList.add("insertatcaretactive");var headerBody=document.querySelector("#admin-notificationheader iframe").contentDocument.querySelector("body");headerBody.classList.contains("insertatcaretactive")&&headerBody.classList.remove("insertatcaretactive")}))}})).observe(footertargetNode,{attributes:!0,childList:!0})}var targetNode=document.querySelector("textarea[id$=_editor]");if(null!==targetNode){new MutationObserver((function(){"none"==targetNode.style.display&&setTimeout(initIframeListeners,100)})).observe(targetNode,{attributes:!0,childList:!0})}const initIframeListeners=()=>{let iframes=document.querySelectorAll('[data-fieldtype="editor"] iframe');return!(null===iframes||!iframes.length)&&(iframes.forEach((iframe=>{iframe.contentDocument.addEventListener("click",(function(){iframes.forEach((frame=>{var frameElem=frame.contentDocument.querySelector(".insertatcaretactive");null!==frameElem&&frameElem.classList.remove("insertatcaretactive")}));var contentBody=iframe.contentDocument.querySelector("body");null!==contentBody&&contentBody.classList.add("insertatcaretactive")}))})),!0)};for(var clickforword=document.getElementsByClassName("clickforword"),i=0;i{const span=document.createElement("span");span.classList="badge badge-info pulse-completion-roles",node.after(span),span.appendChild(node)}))}},insertCaretActive:function(EditorInput){if(null!==EditorInput){for(var caret=document.getElementsByClassName("insertatcaretactive"),j=0;j3===node.nodeType&&node.textContent.trim().length>1))},isSelectionInsideDiv:div=>{const selection=window.getSelection();if(0===selection.rangeCount)return!1;const startNode=selection.getRangeAt(0).startContainer,endNode=selection.getRangeAt(0).endContainer;return div.contains(startNode)&&div.contains(endNode)},insertAtCaret:function(myValue){for(var sel,range,caretelements=document.getElementsByClassName("insertatcaretactive"),n=0;n.\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(['core_editor/events'], function() {\n\n return {\n /**\n * Setup the classes to editors works with placeholders.\n *\n * @param {integer} branch\n */\n init: function(branch) {\n var module = this;\n\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 if (EditorInput !== null) {\n module.insertCaretActive(EditorInput);\n }\n });\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_notificationheader_ifr');\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_notificationfooter_ifr');\n module.insertCaretActive(EditorInput);\n });\n }\n\n\n templatevars = document.getElementsByClassName(\"fitem_id_templatevars_editor\");\n if (templatevars) {\n templatevars.forEach((elem) => {\n elem.addEventListener('click', function(e) {\n var target = e.currentTarget;\n var EditorInput = (branch <= \"402\")\n ? target.querySelector('[id*=\"_editoreditable\"]')\n : target.querySelector('textarea[id*=\"_content_editor\"]');\n module.insertCaretActive(EditorInput);\n });\n });\n }\n\n\n var headertargetNode = document.querySelector('#id_s_mod_pulse_notificationheader');\n if (headertargetNode !== null) {\n let observer = new MutationObserver(function() {\n if (headertargetNode.style.display == 'none') {\n var headeriframe = document.querySelector('#admin-notificationheader iframe').contentDocument;\n if (headeriframe !== null) {\n headeriframe.addEventListener('click', function(e) {\n var currentFrame = e.target;\n var headercontentBody = currentFrame.querySelector('body');\n if (headercontentBody !== null) {\n headercontentBody.classList.add(\"insertatcaretactive\");\n }\n\n var footer = document.querySelector('#admin-notificationfooter iframe').contentDocument;\n var footerBody = footer.querySelector('body');\n if (footerBody.classList.contains('insertatcaretactive')) {\n footerBody.classList.remove(\"insertatcaretactive\");\n }\n\n });\n }\n }\n });\n observer.observe(headertargetNode, {attributes: true, childList: true});\n }\n\n var footertargetNode = document.querySelector('#id_s_mod_pulse_notificationfooter');\n if (footertargetNode !== null) {\n let observer = new MutationObserver(function() {\n if (footertargetNode.style.display == 'none') {\n var footeriframe = document.querySelector('#admin-notificationfooter iframe').contentDocument;\n if (footeriframe !== null) {\n footeriframe.addEventListener('click', function(e) {\n var currentFrame = e.target;\n var footercontentBody = currentFrame.querySelector('body');\n if (footercontentBody !== null) {\n footercontentBody.classList.add(\"insertatcaretactive\");\n }\n\n var header = document.querySelector('#admin-notificationheader iframe').contentDocument;\n var headerBody = header.querySelector('body');\n if (headerBody.classList.contains('insertatcaretactive')) {\n headerBody.classList.remove(\"insertatcaretactive\");\n }\n\n });\n }\n }\n });\n observer.observe(footertargetNode, {attributes: true, childList: true});\n }\n\n var targetNode = document.querySelector('textarea[id$=_editor]');\n\n if (targetNode !== null) {\n let observer = new MutationObserver(function() {\n if (targetNode.style.display == 'none') {\n setTimeout(initIframeListeners, 100);\n }\n });\n observer.observe(targetNode, {attributes: true, childList: true});\n }\n\n const initIframeListeners = () => {\n\n let iframes = document.querySelectorAll('[data-fieldtype=\"editor\"] iframe');\n if (iframes === null || !iframes.length) {\n return false;\n }\n iframes.forEach((iframe) => {\n iframe.contentDocument.addEventListener('click', function() {\n iframes.forEach((frame) => {\n var frameElem = frame.contentDocument.querySelector(\".insertatcaretactive\");\n if (frameElem !== null) {\n frameElem.classList.remove(\"insertatcaretactive\");\n }\n });\n\n var contentBody = iframe.contentDocument.querySelector('body');\n if (contentBody !== null) {\n contentBody.classList.add(\"insertatcaretactive\");\n }\n });\n });\n\n return true;\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\n var content = \"{\" + this.getAttribute('data-text') + \"}\";\n let iframes = document.querySelectorAll('[data-fieldtype=\"editor\"] iframe');\n\n // Copy the placeholder field.\n navigator.clipboard.writeText(content);\n\n if (iframes === null || !iframes.length) {\n if (branch <= '402') {\n module.insertAtCaret(content);\n return true;\n } else {\n // Header notification editor.\n var headerNode = document.querySelector('#admin-notificationheader iframe').contentDocument;\n if (headerNode !== null) {\n var headercontentBody = headerNode.querySelector(\"body\");\n if (headercontentBody.classList.contains(\"insertatcaretactive\")) {\n headercontentBody.classList.add(\"insertatcaretactive\");\n const id = headercontentBody.dataset.id;\n var headereditor = window.tinyMCE.get(id);\n headereditor.selection.setContent(content);\n return true;\n }\n }\n // Footer notification editor.\n var footerNode = document.querySelector('#admin-notificationfooter iframe').contentDocument;\n if (footerNode !== null) {\n var footercontentBody = footerNode.querySelector(\"body\");\n if (footercontentBody.classList.contains(\"insertatcaretactive\")) {\n footercontentBody.classList.add(\"insertatcaretactive\");\n const id = footercontentBody.dataset.id;\n var footereditor = window.tinyMCE.get(id);\n footereditor.selection.setContent(content);\n return true;\n }\n }\n }\n }\n\n var tinyEditor;\n iframes.forEach(function(frame) {\n var frameElem = frame.contentDocument.querySelector(\".insertatcaretactive\");\n if (frameElem !== null) {\n var contentBody = frame.contentDocument.querySelector('body');\n if (contentBody !== null) {\n contentBody.classList.add(\"insertatcaretactive\");\n const id = contentBody.dataset.id;\n var editor = window.tinyMCE.get(id);\n tinyEditor = editor;\n }\n }\n });\n\n if (tinyEditor) {\n tinyEditor.selection.setContent(content);\n } else {\n module.insertAtCaret(content);\n }\n\n return true;\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 if (EditorInput === null) {\n return;\n }\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 * Find the selection is inside the editor\n *\n * @param {string} div\n * @returns {bool}\n */\n isSelectionInsideDiv: (div) => {\n const selection = window.getSelection();\n if (selection.rangeCount === 0) {\n return false;\n }\n\n // Get the start and end nodes of the selection.\n const startNode = selection.getRangeAt(0).startContainer;\n const endNode = selection.getRangeAt(0).endContainer;\n\n // Check if the start and end nodes are both descendants of the editor div.\n return div.contains(startNode) && div.contains(endNode);\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 && this.isSelectionInsideDiv(thiselem)) {\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","branch","module","this","templatevars","document","getElementsByClassName","l","length","addEventListener","EditorInput","getElementById","insertCaretActive","notificationheader","notificationfooter","forEach","elem","e","target","currentTarget","querySelector","headertargetNode","MutationObserver","style","display","headeriframe","contentDocument","headercontentBody","classList","add","footerBody","contains","remove","observe","attributes","childList","footertargetNode","footeriframe","footercontentBody","headerBody","targetNode","setTimeout","initIframeListeners","iframes","querySelectorAll","iframe","frame","frameElem","contentBody","clickforword","i","preventDefault","content","getAttribute","navigator","clipboard","writeText","insertAtCaret","headerNode","id","dataset","window","tinyMCE","get","selection","setContent","footerNode","tinyEditor","editor","getAllTextNodes","node","span","createElement","after","appendChild","caret","j","element","Array","from","childNodes","filter","nodeType","textContent","trim","isSelectionInsideDiv","div","getSelection","rangeCount","startNode","getRangeAt","startContainer","endNode","endContainer","myValue","sel","range","caretelements","n","thiselem","value","deleteContents","insertNode","createTextNode","position","modify","createRange","text","focus","selectionStart","startPos","endPos","selectionEnd","substring"],"mappings":";;;;;;;;;AAyBAA,0BAAO,CAAC,uBAAuB,iBAEpB,CAMHC,KAAM,SAAS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hB,QAAQtF,OAC3C2F,SAASS,aAETT,SAASC,OAASN,QAClBK,SAASS"} \ No newline at end of file +{"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 .\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(['core_editor/events'], function() {\n\n return {\n /**\n * Setup the classes to editors works with placeholders.\n *\n * @param {integer} branch\n */\n init: function(branch) {\n var module = this;\n\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 if (EditorInput !== null) {\n module.insertCaretActive(EditorInput);\n }\n });\n }\n\n var notificationheader = document.getElementById('admin-notificationheader');\n if (notificationheader !== null) {\n notificationheader.addEventListener('click', function() {\n var EditorInput = (branch <= '402') ? document.getElementById('id_s_mod_pulse_notificationheadereditable')\n : document.getElementById('id_s_mod_pulse_notificationheader_ifr');\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 = (branch <= '402') ? document.getElementById('id_s_mod_pulse_notificationfootereditable')\n : document.getElementById('id_s_mod_pulse_notificationfooter_ifr');\n module.insertCaretActive(EditorInput);\n });\n }\n\n\n templatevars = document.getElementsByClassName(\"fitem_id_templatevars_editor\");\n if (templatevars) {\n templatevars.forEach((elem) => {\n elem.addEventListener('click', function(e) {\n var target = e.currentTarget;\n var EditorInput = (branch <= \"402\")\n ? target.querySelector('[id*=\"_editoreditable\"]')\n : target.querySelector('textarea[id*=\"_content_editor\"]');\n module.insertCaretActive(EditorInput);\n });\n });\n }\n\n\n var headertargetNode = document.querySelector('#id_s_mod_pulse_notificationheader');\n if (headertargetNode !== null) {\n let observer = new MutationObserver(function() {\n if (headertargetNode.style.display == 'none') {\n var headeriframe = document.querySelector('#admin-notificationheader iframe');\n if (headeriframe !== null) {\n var headercontent = document.querySelector('#admin-notificationheader iframe').contentDocument;\n headercontent.addEventListener('click', function() {\n var headercontentBody = headercontent.querySelector('body');\n if (headercontentBody !== null) {\n headercontentBody.classList.add(\"insertatcaretactive\");\n }\n\n var footer = document.querySelector('#admin-notificationfooter iframe').contentDocument;\n var footerBody = footer.querySelector('body');\n if (footerBody.classList.contains('insertatcaretactive')) {\n footerBody.classList.remove(\"insertatcaretactive\");\n }\n\n });\n }\n }\n });\n observer.observe(headertargetNode, {attributes: true, childList: true});\n }\n\n var footertargetNode = document.querySelector('#id_s_mod_pulse_notificationfooter');\n if (footertargetNode !== null) {\n let observer = new MutationObserver(function() {\n if (footertargetNode.style.display == 'none') {\n var footeriframe = document.querySelector('#admin-notificationfooter iframe');\n if (footeriframe !== null) {\n var footercontent = document.querySelector('#admin-notificationfooter iframe').contentDocument;\n footercontent.addEventListener('click', function() {\n var footercontentBody = footercontent.querySelector('body');\n if (footercontentBody !== null) {\n footercontentBody.classList.add(\"insertatcaretactive\");\n }\n\n var header = document.querySelector('#admin-notificationheader iframe').contentDocument;\n var headerBody = header.querySelector('body');\n if (headerBody.classList.contains('insertatcaretactive')) {\n headerBody.classList.remove(\"insertatcaretactive\");\n }\n\n });\n }\n }\n });\n observer.observe(footertargetNode, {attributes: true, childList: true});\n }\n\n var targetNode = document.querySelector('textarea[id$=_editor]');\n\n if (targetNode !== null) {\n let observer = new MutationObserver(function() {\n if (targetNode.style.display == 'none') {\n setTimeout(initIframeListeners, 100);\n }\n });\n observer.observe(targetNode, {attributes: true, childList: true});\n }\n\n const initIframeListeners = () => {\n\n let iframes = document.querySelectorAll('[data-fieldtype=\"editor\"] iframe');\n if (iframes === null || !iframes.length) {\n return false;\n }\n iframes.forEach((iframe) => {\n iframe.contentDocument.addEventListener('click', function() {\n iframes.forEach((frame) => {\n var frameElem = frame.contentDocument.querySelector(\".insertatcaretactive\");\n if (frameElem !== null) {\n frameElem.classList.remove(\"insertatcaretactive\");\n }\n });\n\n var contentBody = iframe.contentDocument.querySelector('body');\n if (contentBody !== null) {\n contentBody.classList.add(\"insertatcaretactive\");\n }\n });\n });\n\n return true;\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\n var content = \"{\" + this.getAttribute('data-text') + \"}\";\n let iframes = document.querySelectorAll('[data-fieldtype=\"editor\"] iframe');\n\n // Copy the placeholder field.\n navigator.clipboard.writeText(content);\n\n if (iframes === null || !iframes.length) {\n var headerNode = document.querySelector('#admin-notificationheader iframe');\n if (headerNode !== null) {\n // Header notification editor.\n var headerNodeiframe = headerNode.contentDocument;\n if (headerNodeiframe !== null) {\n var headercontentBody = headerNodeiframe.querySelector(\"body\");\n if (headercontentBody.classList.contains(\"insertatcaretactive\")) {\n headercontentBody.classList.add(\"insertatcaretactive\");\n const id = headercontentBody.dataset.id;\n var headereditor = window.tinyMCE.get(id);\n headereditor.selection.setContent(content);\n return true;\n }\n }\n }\n\n var footerNode = document.querySelector('#admin-notificationfooter iframe');\n if (footerNode !== null) {\n // Footer notification editor.\n var footerNodeiframe = footerNode.contentDocument;\n if (footerNodeiframe !== null) {\n var footercontentBody = footerNodeiframe.querySelector(\"body\");\n if (footercontentBody.classList.contains(\"insertatcaretactive\")) {\n footercontentBody.classList.add(\"insertatcaretactive\");\n const id = footercontentBody.dataset.id;\n var footereditor = window.tinyMCE.get(id);\n footereditor.selection.setContent(content);\n return true;\n }\n }\n }\n }\n\n var tinyEditor;\n iframes.forEach(function(frame) {\n var frameElem = frame.contentDocument.querySelector(\".insertatcaretactive\");\n if (frameElem !== null) {\n var contentBody = frame.contentDocument.querySelector('body');\n if (contentBody !== null) {\n contentBody.classList.add(\"insertatcaretactive\");\n const id = contentBody.dataset.id;\n var editor = window.tinyMCE.get(id);\n tinyEditor = editor;\n }\n }\n });\n\n if (tinyEditor) {\n tinyEditor.selection.setContent(content);\n } else {\n module.insertAtCaret(content);\n }\n\n return true;\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 if (EditorInput === null) {\n return;\n }\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 * Find the selection is inside the editor\n *\n * @param {string} div\n * @returns {bool}\n */\n isSelectionInsideDiv: (div) => {\n const selection = window.getSelection();\n if (selection.rangeCount === 0) {\n return false;\n }\n\n // Get the start and end nodes of the selection.\n const startNode = selection.getRangeAt(0).startContainer;\n const endNode = selection.getRangeAt(0).endContainer;\n\n // Check if the start and end nodes are both descendants of the editor div.\n return div.contains(startNode) && div.contains(endNode);\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 && this.isSelectionInsideDiv(thiselem)) {\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","branch","module","this","templatevars","document","getElementsByClassName","l","length","addEventListener","EditorInput","getElementById","insertCaretActive","notificationheader","notificationfooter","forEach","elem","e","target","currentTarget","querySelector","headertargetNode","MutationObserver","style","display","headercontent","contentDocument","headercontentBody","classList","add","footerBody","contains","remove","observe","attributes","childList","footertargetNode","footercontent","footercontentBody","headerBody","targetNode","setTimeout","initIframeListeners","iframes","querySelectorAll","iframe","frame","frameElem","contentBody","clickforword","i","preventDefault","content","getAttribute","navigator","clipboard","writeText","headerNode","headerNodeiframe","id","dataset","window","tinyMCE","get","selection","setContent","footerNode","footerNodeiframe","tinyEditor","editor","insertAtCaret","getAllTextNodes","node","span","createElement","after","appendChild","caret","j","element","Array","from","childNodes","filter","nodeType","textContent","trim","isSelectionInsideDiv","div","getSelection","rangeCount","startNode","getRangeAt","startContainer","endNode","endContainer","myValue","sel","range","caretelements","n","thiselem","value","deleteContents","insertNode","createTextNode","position","modify","createRange","text","focus","selectionStart","startPos","endPos","selectionEnd","substring"],"mappings":";;;;;;;;;AAyBAA,0BAAO,CAAC,uBAAuB,iBAEpB,CAMHC,KAAM,SAASC,gBACPC,OAASC,KAETC,aAAeC,SAASC,uBAAuB,gCAC1CC,EAAI,EAAGA,EAAIH,aAAaI,OAAQD,IACrCH,aAAaG,GAAGE,iBAAiB,SAAS,eAClCC,YAAcL,SAASM,eAAe,mCACtB,OAAhBD,aACAR,OAAOU,kBAAkBF,oBAKjCG,mBAAqBR,SAASM,eAAe,4BACtB,OAAvBE,oBACAA,mBAAmBJ,iBAAiB,SAAS,eACrCC,YAAeT,QAAU,MAASI,SAASM,eAAe,6CAC5DN,SAASM,eAAe,yCAC1BT,OAAOU,kBAAkBF,oBAI7BI,mBAAqBT,SAASM,eAAe,4BACtB,OAAvBG,oBACAA,mBAAmBL,iBAAiB,SAAS,eACrCC,YAAeT,QAAU,MAASI,SAASM,eAAe,6CAC5DN,SAASM,eAAe,yCAC1BT,OAAOU,kBAAkBF,iBAKjCN,aAAeC,SAASC,uBAAuB,kCAE3CF,aAAaW,SAASC,OAClBA,KAAKP,iBAAiB,SAAS,SAASQ,OAChCC,OAASD,EAAEE,cACXT,YAAeT,QAAU,MACvBiB,OAAOE,cAAc,2BACrBF,OAAOE,cAAc,mCAC3BlB,OAAOU,kBAAkBF,uBAMjCW,iBAAmBhB,SAAS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WAAWnG,SAASoG,eAAeT,cAEpC,IAAIU,SAAW,EAAGA,UAAaV,QAAQxF,OAAS,EAAIkG,WACrDT,IAAIU,OAAO,OAAQ,QAAS,wBAGH,IAAnBN,SAASC,OAAyBjG,SAAS2D,WAAa3D,SAAS2D,UAAU4C,eACzFV,MAAQ7F,SAAS2D,UAAU4C,eACrBC,KAAOb,iBAGa,IAAnBK,SAASC,SACZjG,SAAS2D,UAETqC,SAASS,SACTb,IAAM5F,SAAS2D,UAAU4C,eACrBC,KAAOb,QACXK,SAASS,aACN,GAAIT,SAASU,gBAA6C,KAA3BV,SAASU,eAAuB,KAE9DC,SAAWX,SAASU,eACpBE,OAASZ,SAASa,aACtBb,SAASC,MAAQD,SAASC,MAAMa,UAAU,EAAGH,UACvChB,QAAUK,SAASC,MAAMa,UAAUF,OAAQZ,SAASC,MAAM9F,QAChE6F,SAASS,QACTT,SAASU,eAAiBC,SAAWhB,QAAQxF,OAC7C6F,SAASa,aAAeF,SAAWhB,QAAQxF,OAC3C6F,SAASS,aAETT,SAASC,OAASN,QAClBK,SAASS"} \ No newline at end of file diff --git a/amd/src/module.js b/amd/src/module.js index b88b2a8..c58999f 100644 --- a/amd/src/module.js +++ b/amd/src/module.js @@ -47,7 +47,8 @@ define(['core_editor/events'], function() { var notificationheader = document.getElementById('admin-notificationheader'); if (notificationheader !== null) { notificationheader.addEventListener('click', function() { - var EditorInput = document.getElementById('id_s_mod_pulse_notificationheader_ifr'); + var EditorInput = (branch <= '402') ? document.getElementById('id_s_mod_pulse_notificationheadereditable') + : document.getElementById('id_s_mod_pulse_notificationheader_ifr'); module.insertCaretActive(EditorInput); }); } @@ -55,7 +56,8 @@ define(['core_editor/events'], function() { var notificationfooter = document.getElementById('admin-notificationfooter'); if (notificationfooter !== null) { notificationfooter.addEventListener('click', function() { - var EditorInput = document.getElementById('id_s_mod_pulse_notificationfooter_ifr'); + var EditorInput = (branch <= '402') ? document.getElementById('id_s_mod_pulse_notificationfootereditable') + : document.getElementById('id_s_mod_pulse_notificationfooter_ifr'); module.insertCaretActive(EditorInput); }); } @@ -79,11 +81,11 @@ define(['core_editor/events'], function() { if (headertargetNode !== null) { let observer = new MutationObserver(function() { if (headertargetNode.style.display == 'none') { - var headeriframe = document.querySelector('#admin-notificationheader iframe').contentDocument; + var headeriframe = document.querySelector('#admin-notificationheader iframe'); if (headeriframe !== null) { - headeriframe.addEventListener('click', function(e) { - var currentFrame = e.target; - var headercontentBody = currentFrame.querySelector('body'); + var headercontent = document.querySelector('#admin-notificationheader iframe').contentDocument; + headercontent.addEventListener('click', function() { + var headercontentBody = headercontent.querySelector('body'); if (headercontentBody !== null) { headercontentBody.classList.add("insertatcaretactive"); } @@ -105,11 +107,11 @@ define(['core_editor/events'], function() { if (footertargetNode !== null) { let observer = new MutationObserver(function() { if (footertargetNode.style.display == 'none') { - var footeriframe = document.querySelector('#admin-notificationfooter iframe').contentDocument; + var footeriframe = document.querySelector('#admin-notificationfooter iframe'); if (footeriframe !== null) { - footeriframe.addEventListener('click', function(e) { - var currentFrame = e.target; - var footercontentBody = currentFrame.querySelector('body'); + var footercontent = document.querySelector('#admin-notificationfooter iframe').contentDocument; + footercontent.addEventListener('click', function() { + var footercontentBody = footercontent.querySelector('body'); if (footercontentBody !== null) { footercontentBody.classList.add("insertatcaretactive"); } @@ -176,26 +178,28 @@ define(['core_editor/events'], function() { navigator.clipboard.writeText(content); if (iframes === null || !iframes.length) { - if (branch <= '402') { - module.insertAtCaret(content); - return true; - } else { - // Header notification editor. - var headerNode = document.querySelector('#admin-notificationheader iframe').contentDocument; - if (headerNode !== null) { - var headercontentBody = headerNode.querySelector("body"); - if (headercontentBody.classList.contains("insertatcaretactive")) { - headercontentBody.classList.add("insertatcaretactive"); - const id = headercontentBody.dataset.id; - var headereditor = window.tinyMCE.get(id); - headereditor.selection.setContent(content); - return true; + var headerNode = document.querySelector('#admin-notificationheader iframe'); + if (headerNode !== null) { + // Header notification editor. + var headerNodeiframe = headerNode.contentDocument; + if (headerNodeiframe !== null) { + var headercontentBody = headerNodeiframe.querySelector("body"); + if (headercontentBody.classList.contains("insertatcaretactive")) { + headercontentBody.classList.add("insertatcaretactive"); + const id = headercontentBody.dataset.id; + var headereditor = window.tinyMCE.get(id); + headereditor.selection.setContent(content); + return true; + } } - } + } + + var footerNode = document.querySelector('#admin-notificationfooter iframe'); + if (footerNode !== null) { // Footer notification editor. - var footerNode = document.querySelector('#admin-notificationfooter iframe').contentDocument; - if (footerNode !== null) { - var footercontentBody = footerNode.querySelector("body"); + var footerNodeiframe = footerNode.contentDocument; + if (footerNodeiframe !== null) { + var footercontentBody = footerNodeiframe.querySelector("body"); if (footercontentBody.classList.contains("insertatcaretactive")) { footercontentBody.classList.add("insertatcaretactive"); const id = footercontentBody.dataset.id; diff --git a/lib.php b/lib.php index e3e8b81..bd34f9b 100644 --- a/lib.php +++ b/lib.php @@ -734,6 +734,7 @@ function pulse_email_placeholders($editor, $automation=true) { 'vars' => $label, 'showmore' => (count($label) > 6) ? true : false, 'active' => $i, + 'pretext' => ($key == "Mod_Metadata") ? '' : $key."_", ]; $i++; } diff --git a/mod_form.php b/mod_form.php index 36ad1da..4e5fcb5 100644 --- a/mod_form.php +++ b/mod_form.php @@ -105,7 +105,7 @@ public function definition() { $mform->addHelpButton('pulse_content_editor', 'remindercontent', 'mod_pulse'); // Email tempalte placholders. - $PAGE->requires->js_call_amd('mod_pulse/module', 'init'); + $PAGE->requires->js_call_amd('mod_pulse/module', 'init', [$CFG->branch]); // Presets - JS. $section = optional_param('section', 0, PARAM_INT); @@ -257,8 +257,8 @@ public function data_preprocessing(&$defaultvalues) { if ($this->current->instance) { // Prepare draft item id to store the files. $draftitemid = file_get_submitted_draft_itemid('pulse_content'); - $pulsecontent = isset($defaultvalues['pulse_content']) ?? ''; - $pulsecontentformat = isset($defaultvalues['pulse_contentformat']) ?? 0; + $pulsecontent = $defaultvalues['pulse_content'] ?? ''; + $pulsecontentformat = $defaultvalues['pulse_contentformat'] ?? 0; $defaultvalues['pulse_content_editor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_pulse', 'pulse_content', false, diff --git a/templates/vars.mustache b/templates/vars.mustache index 680c99c..44d31ae 100644 --- a/templates/vars.mustache +++ b/templates/vars.mustache @@ -60,8 +60,8 @@
{{#vars}} - - {{.}} + + {{.}} {{/vars}}
diff --git a/version.php b/version.php index 6a219a7..3eeaa67 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_pulse'; -$plugin->version = 2024033001; +$plugin->version = 2024033002; $plugin->requires = 2022112800; // Requires Moodle 4.1. $plugin->release = 'v2.1'; $plugin->maturity = MATURITY_STABLE;