From ce3e172571d715a211f702690f11541a701d7a99 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 27 Oct 2021 13:32:54 +0800 Subject: [PATCH] Change JS to please GHA --- amd/build/dialogue.min.js.map | 2 +- amd/build/rearrange-area.min.js.map | 2 +- amd/src/dialogue.js | 1 - amd/src/rearrange-area.js | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/amd/build/dialogue.min.js.map b/amd/build/dialogue.min.js.map index c511427..8986766 100644 --- a/amd/build/dialogue.min.js.map +++ b/amd/build/dialogue.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/dialogue.js"],"names":["define","Y","dialogue","title","content","afterShow","afterHide","wide","yuiDialogue","parent","use","width","M","core","headerContent","bodyContent","draggable","visible","center","modal","after","e","newVal","soon","centerDialogue","show","prototype","close","hide","destroy","getContent","bodyNode","getDOMNode"],"mappings":"AAwBAA,OAAM,2BAAC,CAAC,UAAD,CAAD,CAAe,SAASC,CAAT,CAAY,CAW7B,GAAIC,CAAAA,CAAQ,CAAG,SAASC,CAAT,CAAgBC,CAAhB,CAAyBC,CAAzB,CAAoCC,CAApC,CAA+CC,CAA/C,CAAqD,CAChE,KAAKC,WAAL,CAAmB,IAAnB,CACA,GAAIC,CAAAA,CAAM,CAAG,IAAb,CAGA,GAAmB,WAAf,QAAOF,CAAAA,CAAX,CAAgC,CAC5BA,CAAI,GACP,CAEDN,CAAC,CAACS,GAAF,CAAM,0BAAN,CAAkC,QAAlC,CAA4C,UAAW,CACnD,GAAIC,CAAAA,CAAK,CAAG,OAAZ,CACA,GAAIJ,CAAJ,CAAU,CACNI,CAAK,CAAG,OACX,CAEDF,CAAM,CAACD,WAAP,CAAqB,GAAII,CAAAA,CAAC,CAACC,IAAF,CAAOX,QAAX,CAAoB,CACrCY,aAAa,CAAEX,CADsB,CAErCY,WAAW,CAAEX,CAFwB,CAGrCY,SAAS,GAH4B,CAIrCC,OAAO,GAJ8B,CAKrCC,MAAM,GAL+B,CAMrCC,KAAK,GANgC,CAOrCR,KAAK,CAAEA,CAP8B,CAApB,CAArB,CAUAF,CAAM,CAACD,WAAP,CAAmBY,KAAnB,CAAyB,eAAzB,CAA0C,SAASC,CAAT,CAAY,CAClD,GAAIA,CAAC,CAACC,MAAN,CAAc,CAGV,GAA0B,WAArB,QAAOjB,CAAAA,CAAZ,CAAwC,CACpCJ,CAAC,CAACsB,IAAF,CAAO,UAAW,CACdlB,CAAS,CAACI,CAAD,CAAT,CACAA,CAAM,CAACD,WAAP,CAAmBgB,cAAnB,EACH,CAHD,CAIH,CACJ,CATD,IASO,CACH,GAA0B,WAArB,QAAOlB,CAAAA,CAAZ,CAAwC,CACpCL,CAAC,CAACsB,IAAF,CAAO,UAAW,CACdjB,CAAS,CAACG,CAAD,CACZ,CAFD,CAGH,CACJ,CACJ,CAjBD,EAmBAA,CAAM,CAACD,WAAP,CAAmBiB,IAAnB,EACH,CApCD,CAqCH,CA9CD,CAmDAvB,CAAQ,CAACwB,SAAT,CAAmBC,KAAnB,CAA2B,UAAW,CAClC,KAAKnB,WAAL,CAAiBoB,IAAjB,GACA,KAAKpB,WAAL,CAAiBqB,OAAjB,EACH,CAHD,CAUA3B,CAAQ,CAACwB,SAAT,CAAmBI,UAAnB,CAAgC,UAAW,CACvC,MAAO,MAAKtB,WAAL,CAAiBuB,QAAjB,CAA0BC,UAA1B,EACV,CAFD,CAIA,MAAO9B,CAAAA,CACV,CA7EK,CAAN","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 * Wrapper for the YUI M.core.notification class. Allows us to\n * use the YUI version in AMD code until it is replaced.\n *\n * @module mod_customcert/dialogue\n * @package mod_customcert\n * @copyright 2016 Mark Nelson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/yui'], function(Y) {\n\n /**\n * Constructor\n *\n * @param {String} title Title for the window.\n * @param {String} content The content for the window.\n * @param {function} afterShow Callback executed after the window is opened.\n * @param {function} afterHide Callback executed after the window is closed.\n * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).\n */\n var dialogue = function(title, content, afterShow, afterHide, wide) {\n this.yuiDialogue = null;\n var parent = this;\n\n // Default for wide is false.\n if (typeof wide == 'undefined') {\n wide = false;\n }\n\n Y.use('moodle-core-notification', 'timers', function() {\n var width = '480px';\n if (wide) {\n width = '800px';\n }\n\n parent.yuiDialogue = new M.core.dialogue({\n headerContent: title,\n bodyContent: content,\n draggable: true,\n visible: false,\n center: true,\n modal: true,\n width: width\n });\n\n parent.yuiDialogue.after('visibleChange', function(e) {\n if (e.newVal) {\n // Delay the callback call to the next tick, otherwise it can happen that it is\n // executed before the dialogue constructor returns.\n if ((typeof afterShow !== 'undefined')) {\n Y.soon(function() {\n afterShow(parent);\n parent.yuiDialogue.centerDialogue();\n });\n }\n } else {\n if ((typeof afterHide !== 'undefined')) {\n Y.soon(function() {\n afterHide(parent);\n });\n }\n }\n });\n\n parent.yuiDialogue.show();\n });\n };\n\n /**\n * Close this window.\n */\n dialogue.prototype.close = function() {\n this.yuiDialogue.hide();\n this.yuiDialogue.destroy();\n };\n\n /**\n * Get content.\n *\n * @returns {HTMLElement}\n */\n dialogue.prototype.getContent = function() {\n return this.yuiDialogue.bodyNode.getDOMNode();\n };\n\n return dialogue;\n});\n"],"file":"dialogue.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/dialogue.js"],"names":["define","Y","dialogue","title","content","afterShow","afterHide","wide","yuiDialogue","parent","use","width","M","core","headerContent","bodyContent","draggable","visible","center","modal","after","e","newVal","soon","centerD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ACJ,CACJ,CAjBD,EAmBAA,CAAM,CAACD,WAAP,CAAmBiB,IAAnB,EACH,CApCD,CAqCH,CA9CD,CAmDAvB,CAAQ,CAACwB,SAAT,CAAmBC,KAAnB,CAA2B,UAAW,CAClC,KAAKnB,WAAL,CAAiBoB,IAAjB,GACA,KAAKpB,WAAL,CAAiBqB,OAAjB,EACH,CAHD,CAUA3B,CAAQ,CAACwB,SAAT,CAAmBI,UAAnB,CAAgC,UAAW,CACvC,MAAO,MAAKtB,WAAL,CAAiBuB,QAAjB,CAA0BC,UAA1B,EACV,CAFD,CAIA,MAAO9B,CAAAA,CACV,CA7EK,CAAN","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 * Wrapper for the YUI M.core.notification class. Allows us to\n * use the YUI version in AMD code until it is replaced.\n *\n * @module mod_customcert/dialogue\n * @copyright 2016 Mark Nelson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/yui'], function(Y) {\n\n /**\n * Constructor\n *\n * @param {String} title Title for the window.\n * @param {String} content The content for the window.\n * @param {function} afterShow Callback executed after the window is opened.\n * @param {function} afterHide Callback executed after the window is closed.\n * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).\n */\n var dialogue = function(title, content, afterShow, afterHide, wide) {\n this.yuiDialogue = null;\n var parent = this;\n\n // Default for wide is false.\n if (typeof wide == 'undefined') {\n wide = false;\n }\n\n Y.use('moodle-core-notification', 'timers', function() {\n var width = '480px';\n if (wide) {\n width = '800px';\n }\n\n parent.yuiDialogue = new M.core.dialogue({\n headerContent: title,\n bodyContent: content,\n draggable: true,\n visible: false,\n center: true,\n modal: true,\n width: width\n });\n\n parent.yuiDialogue.after('visibleChange', function(e) {\n if (e.newVal) {\n // Delay the callback call to the next tick, otherwise it can happen that it is\n // executed before the dialogue constructor returns.\n if ((typeof afterShow !== 'undefined')) {\n Y.soon(function() {\n afterShow(parent);\n parent.yuiDialogue.centerDialogue();\n });\n }\n } else {\n if ((typeof afterHide !== 'undefined')) {\n Y.soon(function() {\n afterHide(parent);\n });\n }\n }\n });\n\n parent.yuiDialogue.show();\n });\n };\n\n /**\n * Close this window.\n */\n dialogue.prototype.close = function() {\n this.yuiDialogue.hide();\n this.yuiDialogue.destroy();\n };\n\n /**\n * Get content.\n *\n * @returns {HTMLElement}\n */\n dialogue.prototype.getContent = function() {\n return this.yuiDialogue.bodyNode.getDOMNode();\n };\n\n return dialogue;\n});\n"],"file":"dialogue.min.js"} \ No newline at end of file diff --git a/amd/build/rearrange-area.min.js.map b/amd/build/rearrange-area.min.js.map index 45761be..90a5924 100644 --- a/amd/build/rearrange-area.min.js.map +++ b/amd/build/rearrange-area.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/rearrange-area.js"],"names":["define","$","Y","fragment","Dialogue","notification","str","template","ajax","RearrangeArea","selector","_node","_setEvents","prototype","CUSTOMCERT_REF_POINT_TOPLEFT","CUSTOMCERT_REF_POINT_TOPCENTER","CUSTOMCERT_REF_POINT_TOPRIGHT","PIXELSINMM","on","_editElement","bind","event","elementid","currentTarget","id","substr","contextid","attr","loadFragment","done","html","js","get_string","title","use","_editElementDialogueConfig","fail","exception","popup","replaceNode","_setPositionInForm","body","getContent","e","M","core_formchangechecker","reset_form_dirty_state","_saveElement","then","_getElementHTML","elementNode","find","refpoint","parseInt","val","refpointClass","empty","append","removeClass","addClass","posx","posy","_setPosition","close","preventDefault","element","one","getX","getY","nodewidth","parseFloat","getComputedStyle","maxwidth","width","setX","setY","posxelement","posyelement","length","getData","Math","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AxB,CAAuC,SAASzB,CAAT,CAAoB,IAEnD4D,CAAAA,CAAU,CAAG,KAAKvE,KAAL,CAAWgB,IAAX,CAAgB,iBAAhB,CAFsC,CAGnD4D,CAAM,CAAGtF,CAAC,CAAC,kBAAD,CAAD,CAAsBuF,cAAtB,EAH0C,CAMnDL,CAAQ,CAAG3E,CAAI,CAAC4E,IAAL,CAAU,CAAC,CACtBC,UAAU,CAAE,6BADU,CAEtBC,IAAI,CAAE,CACFJ,UAAU,CAAEA,CADV,CAEF5D,SAAS,CAAEA,CAFT,CAGFmE,MAAM,CAAEF,CAHN,CAFgB,CAAD,CAAV,CANwC,CAgBvD,MAAOJ,CAAAA,CAAQ,CAAC,CAAD,CAClB,CAjBD,CAmBA,MAAO,CACHO,IAAI,CAAE,cAAShF,CAAT,CAAmB,CACrB,GAAID,CAAAA,CAAJ,CAAkBC,CAAlB,CACH,CAHE,CAKV,CA5LH,CAAN","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 * AMD module used when rearranging a custom certificate.\n *\n * @module mod_customcert/rearrange-area\n * @package mod_customcert\n * @copyright 2016 Mark Nelson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/yui', 'core/fragment', 'mod_customcert/dialogue', 'core/notification',\n 'core/str', 'core/templates', 'core/ajax'],\n function($, Y, fragment, Dialogue, notification, str, template, ajax) {\n\n /**\n * RearrangeArea class.\n *\n * @param {String} selector The rearrange PDF selector\n */\n var RearrangeArea = function(selector) {\n this._node = $(selector);\n this._setEvents();\n };\n\n RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPLEFT = 0;\n RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPCENTER = 1;\n RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT = 2;\n RearrangeArea.prototype.PIXELSINMM = 3.779527559055;\n\n RearrangeArea.prototype._setEvents = function() {\n this._node.on('click', '.element', this._editElement.bind(this));\n };\n\n RearrangeArea.prototype._editElement = function(event) {\n var elementid = event.currentTarget.id.substr(8);\n var contextid = this._node.attr('data-contextid');\n var params = {\n 'elementid': elementid\n };\n\n fragment.loadFragment('mod_customcert', 'editelement', contextid, params).done(function(html, js) {\n str.get_string('editelement', 'mod_customcert').done(function(title) {\n Y.use('moodle-core-formchangechecker', function() {\n new Dialogue(\n title,\n '
',\n this._editElementDialogueConfig.bind(this, elementid, html, js),\n undefined,\n true\n );\n }.bind(this));\n }.bind(this));\n }.bind(this)).fail(notification.exception);\n };\n\n RearrangeArea.prototype._editElementDialogueConfig = function(elementid, html, js, popup) {\n // Place the content in the dialogue.\n template.replaceNode('#elementcontent', html, js);\n\n // We may have dragged the element changing it's position.\n // Ensure the form has the current up-to-date location.\n this._setPositionInForm(elementid);\n\n // Add events for when we save, close and cancel the page.\n var body = $(popup.getContent());\n body.on('click', '#id_submitbutton', function(e) {\n // Do not want to ask the user if they wish to stay on page after saving.\n M.core_formchangechecker.reset_form_dirty_state();\n // Save the data.\n this._saveElement(elementid).then(function() {\n // Update the DOM to reflect the adjusted value.\n this._getElementHTML(elementid).done(function(html) {\n var elementNode = this._node.find('#element-' + elementid);\n var refpoint = parseInt($('#id_refpoint').val());\n var refpointClass = '';\n if (refpoint == this.CUSTOMCERT_REF_POINT_TOPLEFT) {\n refpointClass = 'refpoint-left';\n } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPCENTER) {\n refpointClass = 'refpoint-center';\n } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPRIGHT) {\n refpointClass = 'refpoint-right';\n }\n elementNode.empty().append(html);\n // Update the ref point.\n elementNode.removeClass();\n elementNode.addClass('element ' + refpointClass);\n elementNode.attr('data-refpoint', refpoint);\n // Move the element.\n var posx = $('#editelementform #id_posx').val();\n var posy = $('#editelementform #id_posy').val();\n this._setPosition(elementid, refpoint, posx, posy);\n // All done.\n popup.close();\n }.bind(this));\n }.bind(this)).fail(notification.exception);\n e.preventDefault();\n }.bind(this));\n\n body.on('click', '#id_cancel', function(e) {\n popup.close();\n e.preventDefault();\n });\n };\n\n RearrangeArea.prototype._setPosition = function(elementid, refpoint, posx, posy) {\n var element = Y.one('#element-' + elementid);\n\n posx = Y.one('#pdf').getX() + posx * this.PIXELSINMM;\n posy = Y.one('#pdf').getY() + posy * this.PIXELSINMM;\n var nodewidth = parseFloat(element.getComputedStyle('width'));\n var maxwidth = element.width * this.PIXELSINMM;\n\n if (maxwidth && (nodewidth > maxwidth)) {\n nodewidth = maxwidth;\n }\n\n switch (refpoint) {\n case this.CUSTOMCERT_REF_POINT_TOPCENTER:\n posx -= nodewidth / 2;\n break;\n case this.CUSTOMCERT_REF_POINT_TOPRIGHT:\n posx = posx - nodewidth + 2;\n break;\n }\n\n element.setX(posx);\n element.setY(posy);\n };\n\n RearrangeArea.prototype._setPositionInForm = function(elementid) {\n var posxelement = $('#editelementform #id_posx');\n var posyelement = $('#editelementform #id_posy');\n\n if (posxelement.length && posyelement.length) {\n var element = Y.one('#element-' + elementid);\n var posx = element.getX() - Y.one('#pdf').getX();\n var posy = element.getY() - Y.one('#pdf').getY();\n var refpoint = parseInt(element.getData('refpoint'));\n var nodewidth = parseFloat(element.getComputedStyle('width'));\n\n switch (refpoint) {\n case this.CUSTOMCERT_REF_POINT_TOPCENTER:\n posx += nodewidth / 2;\n break;\n case this.CUSTOMCERT_REF_POINT_TOPRIGHT:\n posx += nodewidth;\n break;\n }\n\n posx = Math.round(parseFloat(posx / this.PIXELSINMM));\n posy = Math.round(parseFloat(posy / this.PIXELSINMM));\n\n posxelement.val(posx);\n posyelement.val(posy);\n }\n };\n\n RearrangeArea.prototype._getElementHTML = function(elementid) {\n // Get the variables we need.\n var templateid = this._node.attr('data-templateid');\n\n // Call the web service to get the updated element.\n var promises = ajax.call([{\n methodname: 'mod_customcert_get_element_html',\n args: {\n templateid: templateid,\n elementid: elementid\n }\n }]);\n\n // Return the promise.\n return promises[0];\n };\n\n RearrangeArea.prototype._saveElement = function(elementid) {\n // Get the variables we need.\n var templateid = this._node.attr('data-templateid');\n var inputs = $('#editelementform').serializeArray();\n\n // Call the web service to save the element.\n var promises = ajax.call([{\n methodname: 'mod_customcert_save_element',\n args: {\n templateid: templateid,\n elementid: elementid,\n values: inputs\n }\n }]);\n\n // Return the promise.\n return promises[0];\n };\n\n return {\n init: function(selector) {\n new RearrangeArea(selector);\n }\n };\n }\n );\n"],"file":"rearrange-area.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/rearrange-area.js"],"names":["define","$","Y","fragment","Dialogue","notification","str","template","ajax","RearrangeArea","selector","_node","_setEvents","prototype","CUSTOMCERT_REF_POINT_TOPLEFT","CUSTOMCERT_REF_POINT_TOPCENTER","CUSTOMCERT_REF_POINT_TOPRIGHT","PIXELSINMM","on","_editElement","bind","event","elementid","currentTarget","id","substr","contextid","attr","loadFragment","done","html","js","get_string","title","use","_editElementDialogueConfig","fail","exception","popup","replaceNode","_setPositionInForm","body","getContent","e","M","core_formchangechecker","reset_form_dirty_state","_saveElement","then","_getElementHTML","elementNode","find","refpoint","parseInt","val","refpointClass","empty","append","removeClass","addClass","posx","posy","_setPosition","close","preventDefault","element","one","getX","getY","nodewidth","parseFloat","getComputedStyle","maxwidth","width","setX","setY","posxelement","posyelement","length","getData","Math","round","templateid","promises","call","methodname","args","inputs","serializeArray","values","init"],"mappings":"AAsBAA,OAAM,iCAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,eAAvB,CAAwC,yBAAxC,CAAmE,mBAAnE,CACC,UADD,CACa,gBADb,CAC+B,WAD/B,CAAD,CAEE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0C,CAMnDL,CAAQ,CAAG3E,CAAI,CAAC4E,IAAL,CAAU,CAAC,CACtBC,UAAU,CAAE,6BADU,CAEtBC,IAAI,CAAE,CACFJ,UAAU,CAAEA,CADV,CAEF5D,SAAS,CAAEA,CAFT,CAGFmE,MAAM,CAAEF,CAHN,CAFgB,CAAD,CAAV,CANwC,CAgBvD,MAAOJ,CAAAA,CAAQ,CAAC,CAAD,CAClB,CAjBD,CAmBA,MAAO,CACHO,IAAI,CAAE,cAAShF,CAAT,CAAmB,CACrB,GAAID,CAAAA,CAAJ,CAAkBC,CAAlB,CACH,CAHE,CAKV,CA5LH,CAAN","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 * AMD module used when rearranging a custom certificate.\n *\n * @module mod_customcert/rearrange-area\n * @copyright 2016 Mark Nelson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/yui', 'core/fragment', 'mod_customcert/dialogue', 'core/notification',\n 'core/str', 'core/templates', 'core/ajax'],\n function($, Y, fragment, Dialogue, notification, str, template, ajax) {\n\n /**\n * RearrangeArea class.\n *\n * @param {String} selector The rearrange PDF selector\n */\n var RearrangeArea = function(selector) {\n this._node = $(selector);\n this._setEvents();\n };\n\n RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPLEFT = 0;\n RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPCENTER = 1;\n RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT = 2;\n RearrangeArea.prototype.PIXELSINMM = 3.779527559055;\n\n RearrangeArea.prototype._setEvents = function() {\n this._node.on('click', '.element', this._editElement.bind(this));\n };\n\n RearrangeArea.prototype._editElement = function(event) {\n var elementid = event.currentTarget.id.substr(8);\n var contextid = this._node.attr('data-contextid');\n var params = {\n 'elementid': elementid\n };\n\n fragment.loadFragment('mod_customcert', 'editelement', contextid, params).done(function(html, js) {\n str.get_string('editelement', 'mod_customcert').done(function(title) {\n Y.use('moodle-core-formchangechecker', function() {\n new Dialogue(\n title,\n '
',\n this._editElementDialogueConfig.bind(this, elementid, html, js),\n undefined,\n true\n );\n }.bind(this));\n }.bind(this));\n }.bind(this)).fail(notification.exception);\n };\n\n RearrangeArea.prototype._editElementDialogueConfig = function(elementid, html, js, popup) {\n // Place the content in the dialogue.\n template.replaceNode('#elementcontent', html, js);\n\n // We may have dragged the element changing it's position.\n // Ensure the form has the current up-to-date location.\n this._setPositionInForm(elementid);\n\n // Add events for when we save, close and cancel the page.\n var body = $(popup.getContent());\n body.on('click', '#id_submitbutton', function(e) {\n // Do not want to ask the user if they wish to stay on page after saving.\n M.core_formchangechecker.reset_form_dirty_state();\n // Save the data.\n this._saveElement(elementid).then(function() {\n // Update the DOM to reflect the adjusted value.\n this._getElementHTML(elementid).done(function(html) {\n var elementNode = this._node.find('#element-' + elementid);\n var refpoint = parseInt($('#id_refpoint').val());\n var refpointClass = '';\n if (refpoint == this.CUSTOMCERT_REF_POINT_TOPLEFT) {\n refpointClass = 'refpoint-left';\n } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPCENTER) {\n refpointClass = 'refpoint-center';\n } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPRIGHT) {\n refpointClass = 'refpoint-right';\n }\n elementNode.empty().append(html);\n // Update the ref point.\n elementNode.removeClass();\n elementNode.addClass('element ' + refpointClass);\n elementNode.attr('data-refpoint', refpoint);\n // Move the element.\n var posx = $('#editelementform #id_posx').val();\n var posy = $('#editelementform #id_posy').val();\n this._setPosition(elementid, refpoint, posx, posy);\n // All done.\n popup.close();\n }.bind(this));\n }.bind(this)).fail(notification.exception);\n e.preventDefault();\n }.bind(this));\n\n body.on('click', '#id_cancel', function(e) {\n popup.close();\n e.preventDefault();\n });\n };\n\n RearrangeArea.prototype._setPosition = function(elementid, refpoint, posx, posy) {\n var element = Y.one('#element-' + elementid);\n\n posx = Y.one('#pdf').getX() + posx * this.PIXELSINMM;\n posy = Y.one('#pdf').getY() + posy * this.PIXELSINMM;\n var nodewidth = parseFloat(element.getComputedStyle('width'));\n var maxwidth = element.width * this.PIXELSINMM;\n\n if (maxwidth && (nodewidth > maxwidth)) {\n nodewidth = maxwidth;\n }\n\n switch (refpoint) {\n case this.CUSTOMCERT_REF_POINT_TOPCENTER:\n posx -= nodewidth / 2;\n break;\n case this.CUSTOMCERT_REF_POINT_TOPRIGHT:\n posx = posx - nodewidth + 2;\n break;\n }\n\n element.setX(posx);\n element.setY(posy);\n };\n\n RearrangeArea.prototype._setPositionInForm = function(elementid) {\n var posxelement = $('#editelementform #id_posx');\n var posyelement = $('#editelementform #id_posy');\n\n if (posxelement.length && posyelement.length) {\n var element = Y.one('#element-' + elementid);\n var posx = element.getX() - Y.one('#pdf').getX();\n var posy = element.getY() - Y.one('#pdf').getY();\n var refpoint = parseInt(element.getData('refpoint'));\n var nodewidth = parseFloat(element.getComputedStyle('width'));\n\n switch (refpoint) {\n case this.CUSTOMCERT_REF_POINT_TOPCENTER:\n posx += nodewidth / 2;\n break;\n case this.CUSTOMCERT_REF_POINT_TOPRIGHT:\n posx += nodewidth;\n break;\n }\n\n posx = Math.round(parseFloat(posx / this.PIXELSINMM));\n posy = Math.round(parseFloat(posy / this.PIXELSINMM));\n\n posxelement.val(posx);\n posyelement.val(posy);\n }\n };\n\n RearrangeArea.prototype._getElementHTML = function(elementid) {\n // Get the variables we need.\n var templateid = this._node.attr('data-templateid');\n\n // Call the web service to get the updated element.\n var promises = ajax.call([{\n methodname: 'mod_customcert_get_element_html',\n args: {\n templateid: templateid,\n elementid: elementid\n }\n }]);\n\n // Return the promise.\n return promises[0];\n };\n\n RearrangeArea.prototype._saveElement = function(elementid) {\n // Get the variables we need.\n var templateid = this._node.attr('data-templateid');\n var inputs = $('#editelementform').serializeArray();\n\n // Call the web service to save the element.\n var promises = ajax.call([{\n methodname: 'mod_customcert_save_element',\n args: {\n templateid: templateid,\n elementid: elementid,\n values: inputs\n }\n }]);\n\n // Return the promise.\n return promises[0];\n };\n\n return {\n init: function(selector) {\n new RearrangeArea(selector);\n }\n };\n }\n );\n"],"file":"rearrange-area.min.js"} \ No newline at end of file diff --git a/amd/src/dialogue.js b/amd/src/dialogue.js index d27a064..6bb9347 100644 --- a/amd/src/dialogue.js +++ b/amd/src/dialogue.js @@ -18,7 +18,6 @@ * use the YUI version in AMD code until it is replaced. * * @module mod_customcert/dialogue - * @package mod_customcert * @copyright 2016 Mark Nelson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/amd/src/rearrange-area.js b/amd/src/rearrange-area.js index ea79051..1099d25 100644 --- a/amd/src/rearrange-area.js +++ b/amd/src/rearrange-area.js @@ -17,7 +17,6 @@ * AMD module used when rearranging a custom certificate. * * @module mod_customcert/rearrange-area - * @package mod_customcert * @copyright 2016 Mark Nelson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */