diff --git a/.eslintrc b/.eslintrc index a388f57560c..0493181083f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -227,7 +227,7 @@ }, // We're using babel transpiling so use their parser // for linting. - parser: 'babel-eslint', + parser: '@babel/eslint-parser', // Check AMD with some slightly stricter rules. rules: { 'no-unused-vars': 'error', @@ -300,7 +300,8 @@ }, parserOptions: { 'ecmaVersion': 9, - 'sourceType': 'module' + 'sourceType': 'module', + 'requireConfigFile': false, } } ] diff --git a/.gitignore b/.gitignore index 0a44a94ce68..780bcc878fe 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ moodle-plugin-ci.phar /jsdoc /admin/tool/componentlibrary/docs /admin/tool/componentlibrary/hugo/site/data/my-index.json +.hugo_build.lock diff --git a/.grunt/tasks/javascript.js b/.grunt/tasks/javascript.js index 5761f9206fd..9533f18db64 100644 --- a/.grunt/tasks/javascript.js +++ b/.grunt/tasks/javascript.js @@ -30,6 +30,7 @@ * @param {String} srcPath the matched src path * @return {String} The rewritten destination path. */ + const babelRename = function(destPath, srcPath) { destPath = srcPath.replace('src', 'build'); destPath = destPath.replace('.js', '.min.js'); @@ -53,65 +54,139 @@ module.exports = grunt => { // Register JS tasks. grunt.registerTask('yui', ['eslint:yui', 'shifter']); - grunt.registerTask('amd', ['ignorefiles', 'eslint:amd', 'babel']); + grunt.registerTask('amd', ['ignorefiles', 'eslint:amd', 'rollup']); grunt.registerTask('js', ['amd', 'yui']); // Register NPM tasks. grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-rollup'); - // Load the Babel tasks and config. - grunt.loadNpmTasks('grunt-babel'); + const babelTransform = require('@babel/core').transform; + const babel = (options = {}) => { + return { + name: 'babel', + + transform: (code, id) => { + grunt.log.debug(`Transforming ${id}`); + options.filename = id; + const transformed = babelTransform(code, options); + + return { + code: transformed.code, + map: transformed.map + }; + } + }; + }; + + // Note: We have to use a rate limit plugin here because rollup runs all tasks asynchronously and in parallel. + // When we kick off a full run, if we kick off a rollup of every file this will fork-bomb the machine. + // To work around this we use a concurrent Promise queue based on the number of available processors. + const rateLimit = () => { + const queue = []; + let queueRunner; + + const startQueue = () => { + if (queueRunner) { + return; + } + + queueRunner = setTimeout(() => { + const limit = Math.max(1, require('os').cpus().length / 2); + grunt.log.debug(`Starting rollup with queue size of ${limit}`); + runQueue(limit); + }, 100); + }; + + // The queue runner will run the next `size` items in the queue. + const runQueue = (size = 1) => { + queue.splice(0, size).forEach(resolve => { + resolve(); + }); + }; + + return { + name: 'ratelimit', + + // The options hook is run in parallel. + // We can return an unresolved Promise which is queued for later resolution. + options: async() => { + return new Promise(resolve => { + queue.push(resolve); + startQueue(); + }); + }, + + // When an item in the queue completes, start the next item in the queue. + buildEnd: () => { + runQueue(); + }, + }; + }; + + const terser = require('rollup-plugin-terser').terser; grunt.config.merge({ - babel: { + rollup: { options: { - sourceMaps: true, - comments: false, + format: 'esm', + dir: 'output', + sourcemap: true, + treeshake: false, + context: 'window', plugins: [ - 'transform-es2015-modules-amd-lazy', - 'system-import-transformer', - // This plugin modifies the Babel transpiling for "export default" - // so that if it's used then only the exported value is returned - // by the generated AMD module. - // - // It also adds the Moodle plugin name to the AMD module definition - // so that it can be imported as expected in other modules. - path.resolve('.grunt/babel-plugin-add-module-to-define.js'), - '@babel/plugin-syntax-dynamic-import', - '@babel/plugin-syntax-import-meta', - ['@babel/plugin-proposal-class-properties', {'loose': false}], - '@babel/plugin-proposal-json-strings' + rateLimit(), + babel({ + sourceMaps: true, + comments: false, + compact: false, + plugins: [ + 'transform-es2015-modules-amd-lazy', + 'system-import-transformer', + // This plugin modifies the Babel transpiling for "export default" + // so that if it's used then only the exported value is returned + // by the generated AMD module. + // + // It also adds the Moodle plugin name to the AMD module definition + // so that it can be imported as expected in other modules. + path.resolve('.grunt/babel-plugin-add-module-to-define.js'), + '@babel/plugin-syntax-dynamic-import', + '@babel/plugin-syntax-import-meta', + ['@babel/plugin-proposal-class-properties', {'loose': false}], + '@babel/plugin-proposal-json-strings' + ], + presets: [ + ['@babel/preset-env', { + targets: { + browsers: [ + ">0.3%", + "last 2 versions", + "not ie >= 0", + "not op_mini all", + "not Opera > 0", + "not dead" + ] + }, + modules: false, + useBuiltIns: false + }] + ] + }), + + terser({ + // Do not mangle variables. + // Makes debugging easier. + mangle: false, + }), ], - presets: [ - ['minify', { - // This minification plugin needs to be disabled because it breaks the - // source map generation and causes invalid source maps to be output. - simplify: false, - builtIns: false - }], - ['@babel/preset-env', { - targets: { - browsers: [ - ">0.25%", - "last 2 versions", - "not ie <= 10", - "not op_mini all", - "not Opera > 0", - "not dead" - ] - }, - modules: false, - useBuiltIns: false - }] - ] }, dist: { files: [{ expand: true, src: grunt.moodleEnv.files ? grunt.moodleEnv.files : grunt.moodleEnv.amdSrc, rename: babelRename - }] - } + }], + }, }, }); @@ -135,7 +210,7 @@ module.exports = grunt => { let changedFiles = Object.create(null); const onChange = grunt.util._.debounce(function() { const files = Object.keys(changedFiles); - grunt.config('babel.dist.files', [{expand: true, src: files, rename: babelRename}]); + grunt.config('rollup.dist.files', [{expand: true, src: files, rename: babelRename}]); changedFiles = Object.create(null); }, 200); diff --git a/.nvmrc b/.nvmrc index b2d264b67df..53d838af215 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v14.18.0 +lts/gallium diff --git a/admin/tool/analytics/amd/build/log_info.min.js b/admin/tool/analytics/amd/build/log_info.min.js index 9b48cc9f4e7..71c8acc96cf 100644 --- a/admin/tool/analytics/amd/build/log_info.min.js +++ b/admin/tool/analytics/amd/build/log_info.min.js @@ -1,2 +1,10 @@ -define ("tool_analytics/log_info",["jquery","core/str","core/modal_factory","core/notification"],function(a,b,c,d){return{loadInfo:function loadInfo(e,f){var g=a("[data-model-log-id=\""+e+"\"]");b.get_string("loginfo","tool_analytics").then(function(b){var d=a("");return c.create({title:b,body:d.html(),large:!0},g)}).catch(d.exception)}}}); -//# sourceMappingURL=log_info.min.js.map +/** + * Shows a dialogue with info about this logs. + * + * @module tool_analytics/log_info + * @copyright 2017 David Monllao {@link http://www.davidmonllao.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_analytics/log_info",["jquery","core/str","core/modal_factory","core/notification"],(function($,str,ModalFactory,Notification){return{loadInfo:function(id,info){var link=$('[data-model-log-id="'+id+'"]');str.get_string("loginfo","tool_analytics").then((function(langString){var bodyInfo=$(""),ModalFactory.create({title:langString,body:bodyInfo.html(),large:!0},link)})).catch(Notification.exception)}}})); + +//# sourceMappingURL=log_info.min.js.map \ No newline at end of file diff --git a/admin/tool/analytics/amd/build/log_info.min.js.map b/admin/tool/analytics/amd/build/log_info.min.js.map index c3243b8a2f8..38c60d0eedc 100644 --- a/admin/tool/analytics/amd/build/log_info.min.js.map +++ b/admin/tool/analytics/amd/build/log_info.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/log_info.js"],"names":["define","$","str","ModalFactory","Notification","loadInfo","id","info","link","get_string","then","langString","bodyInfo","forEach","item","append","create","title","body","html","large","catch","exception"],"mappings":"AAsBAA,OAAM,2BAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,oBAAvB,CAA6C,mBAA7C,CAAD,CAAoE,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAA+BC,CAA/B,CAA6C,CAEnH,MAAoD,CAShDC,QAAQ,CAAE,kBAASC,CAAT,CAAaC,CAAb,CAAmB,CAEzB,GAAIC,CAAAA,CAAI,CAAGP,CAAC,CAAC,wBAAyBK,CAAzB,CAA8B,KAA/B,CAAZ,CACAJ,CAAG,CAACO,UAAJ,CAAe,SAAf,CAA0B,gBAA1B,EAA4CC,IAA5C,CAAiD,SAASC,CAAT,CAAqB,CAElE,GAAIC,CAAAA,CAAQ,CAAGX,CAAC,CAAC,MAAD,CAAhB,CACAM,CAAI,CAACM,OAAL,CAAa,SAASC,CAAT,CAAe,CACxBF,CAAQ,CAACG,MAAT,CAAgB,OAASD,CAAT,CAAgB,OAAhC,CACH,CAFD,EAGAF,CAAQ,CAACG,MAAT,CAAgB,OAAhB,EAEA,MAAOZ,CAAAA,CAAY,CAACa,MAAb,CAAoB,CACvBC,KAAK,CAAEN,CADgB,CAEvBO,IAAI,CAAEN,CAAQ,CAACO,IAAT,EAFiB,CAGvBC,KAAK,GAHkB,CAApB,CAIJZ,CAJI,CAMV,CAdD,EAcGa,KAdH,CAcSjB,CAAY,CAACkB,SAdtB,CAeH,CA3B+C,CA6BvD,CA/BK,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 * Shows a dialogue with info about this logs.\n *\n * @module tool_analytics/log_info\n * @copyright 2017 David Monllao {@link http://www.davidmonllao.com}\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], function($, str, ModalFactory, Notification) {\n\n return /** @alias module:tool_analytics/log_info */ {\n\n /**\n * Prepares a modal info for a log's results.\n *\n * @method loadInfo\n * @param {int} id\n * @param {string[]} info\n */\n loadInfo: function(id, info) {\n\n var link = $('[data-model-log-id=\"' + id + '\"]');\n str.get_string('loginfo', 'tool_analytics').then(function(langString) {\n\n var bodyInfo = $(\"\");\n\n return ModalFactory.create({\n title: langString,\n body: bodyInfo.html(),\n large: true,\n }, link);\n\n }).catch(Notification.exception);\n }\n };\n});\n"],"file":"log_info.min.js"} \ No newline at end of file +{"version":3,"file":"log_info.min.js","sources":["../src/log_info.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 * Shows a dialogue with info about this logs.\n *\n * @module tool_analytics/log_info\n * @copyright 2017 David Monllao {@link http://www.davidmonllao.com}\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], function($, str, ModalFactory, Notification) {\n\n return /** @alias module:tool_analytics/log_info */ {\n\n /**\n * Prepares a modal info for a log's results.\n *\n * @method loadInfo\n * @param {int} id\n * @param {string[]} info\n */\n loadInfo: function(id, info) {\n\n var link = $('[data-model-log-id=\"' + id + '\"]');\n str.get_string('loginfo', 'tool_analytics').then(function(langString) {\n\n var bodyInfo = $(\"\");\n\n return ModalFactory.create({\n title: langString,\n body: bodyInfo.html(),\n large: true,\n }, link);\n\n }).catch(Notification.exception);\n }\n };\n});\n"],"names":["define","$","str","ModalFactory","Notification","loadInfo","id","info","link","get_string","then","langString","bodyInfo","forEach","item","append","create","title","body","html","large","catch","exception"],"mappings":";;;;;;;AAsBAA,iCAAO,CAAC,SAAU,WAAY,qBAAsB,sBAAsB,SAASC,EAAGC,IAAKC,aAAcC,oBAEjD,CAShDC,SAAU,SAASC,GAAIC,UAEfC,KAAOP,EAAE,uBAAyBK,GAAK,MAC3CJ,IAAIO,WAAW,UAAW,kBAAkBC,MAAK,SAASC,gBAElDC,SAAWX,EAAE,eACjBM,KAAKM,SAAQ,SAASC,MAClBF,SAASG,OAAO,OAASD,KAAO,YAEpCF,SAASG,OAAO,SAETZ,aAAaa,OAAO,CACvBC,MAAON,WACPO,KAAMN,SAASO,OACfC,OAAO,GACRZ,SAEJa,MAAMjB,aAAakB"} \ No newline at end of file diff --git a/admin/tool/analytics/amd/build/model.min.js b/admin/tool/analytics/amd/build/model.min.js index 05c30735ae0..6c8812c6022 100644 --- a/admin/tool/analytics/amd/build/model.min.js +++ b/admin/tool/analytics/amd/build/model.min.js @@ -1,2 +1,10 @@ -define ("tool_analytics/model",["jquery","core/str","core/log","core/notification","core/modal_factory","core/modal_events","core/templates"],function(b,c,d,e,f,g,h){var i={clear:{title:{key:"clearpredictions",component:"tool_analytics"},body:{key:"clearmodelpredictions",component:"tool_analytics"}},delete:{title:{key:"delete",component:"tool_analytics"},body:{key:"deletemodelconfirmation",component:"tool_analytics"}}},j=function(a){var c=b(a).closest("[data-model-name]");if(c.length){return c.attr("data-model-name")}else{d.error("Unexpected DOM error - unable to obtain the model name");return""}};return{confirmAction:function confirmAction(a,h){b("[data-action-id=\""+a+"\"]").on("click",function(k){k.preventDefault();var l=b(k.currentTarget);if("undefined"==typeof i[h]){d.error("Action \""+h+"\" is not allowed.");return}var a=[i[h].title,i[h].body];a[1].param=j(l);var m=c.get_strings(a),n=f.create({type:f.types.SAVE_CANCEL});b.when(m,n).then(function(a,b){b.setTitle(a[0]);b.setBody(a[1]);b.setSaveButtonText(a[0]);b.getRoot().on(g.save,function(){window.location.href=l.attr("href")});b.show();return b}).fail(e.exception)})},selectEvaluationOptions:function selectEvaluationOptions(a,d){b("[data-action-id=\""+a+"\"]").on("click",function(i){i.preventDefault();var j=b(i.currentTarget),a=b(this).attr("data-timesplitting-methods"),k=c.get_strings([{key:"evaluatemodel",component:"tool_analytics"},{key:"evaluate",component:"tool_analytics"}]),l=f.create({type:f.types.SAVE_CANCEL}),m=h.render("tool_analytics/evaluation_options",{trainedexternally:d,timesplittingmethods:JSON.parse(a)});b.when(k,l).then(function(a,c){c.getRoot().on(g.hidden,c.destroy.bind(c));c.setTitle(a[0]);c.setSaveButtonText(a[1]);c.setBody(m);c.getRoot().on(g.save,function(){var a=b("input[name='evaluationmode']:checked").val();if("trainedmodel"==a){j.attr("href",j.attr("href")+"&mode=trainedmodel")}var c=b("#id-evaluation-timesplitting").val();j.attr("href",j.attr("href")+"×plitting="+c);window.location.href=j.attr("href")});c.show();return c}).fail(e.exception)})},selectExportOptions:function selectExportOptions(a,d){b("[data-action-id=\""+a+"\"]").on("click",function(i){i.preventDefault();var j=b(i.currentTarget);if(!d){j.attr("href",j.attr("href")+"&action=exportmodel&includeweights=0");window.location.href=j.attr("href");return}var a=c.get_strings([{key:"export",component:"tool_analytics"}]),k=f.create({type:f.types.SAVE_CANCEL}),l=h.render("tool_analytics/export_options",{});b.when(a,k).then(function(a,c){c.getRoot().on(g.hidden,c.destroy.bind(c));c.setTitle(a[0]);c.setSaveButtonText(a[0]);c.setBody(l);c.getRoot().on(g.save,function(){var a=b("input[name='exportoption']:checked").val();if("exportdata"==a){j.attr("href",j.attr("href")+"&action=exportdata")}else{j.attr("href",j.attr("href")+"&action=exportmodel");if(b("#id-includeweights").is(":checked")){j.attr("href",j.attr("href")+"&includeweights=1")}else{j.attr("href",j.attr("href")+"&includeweights=0")}}window.location.href=j.attr("href")});c.show();return c}).fail(e.exception)})}}}); -//# sourceMappingURL=model.min.js.map +/** + * AMD module for model actions confirmation. + * + * @module tool_analytics/model + * @copyright 2017 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_analytics/model",["jquery","core/str","core/log","core/notification","core/modal_factory","core/modal_events","core/templates"],(function($,Str,log,Notification,ModalFactory,ModalEvents,Templates){var actionsList={clear:{title:{key:"clearpredictions",component:"tool_analytics"},body:{key:"clearmodelpredictions",component:"tool_analytics"}},delete:{title:{key:"delete",component:"tool_analytics"},body:{key:"deletemodelconfirmation",component:"tool_analytics"}}};return{confirmAction:function(actionId,actionType){$('[data-action-id="'+actionId+'"]').on("click",(function(ev){ev.preventDefault();var a=$(ev.currentTarget);if(void 0!==actionsList[actionType]){var wrap,reqStrings=[actionsList[actionType].title,actionsList[actionType].body];reqStrings[1].param=(wrap=$(a).closest("[data-model-name]")).length?wrap.attr("data-model-name"):(log.error("Unexpected DOM error - unable to obtain the model name"),"");var stringsPromise=Str.get_strings(reqStrings),modalPromise=ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL});$.when(stringsPromise,modalPromise).then((function(strings,modal){return modal.setTitle(strings[0]),modal.setBody(strings[1]),modal.setSaveButtonText(strings[0]),modal.getRoot().on(ModalEvents.save,(function(){window.location.href=a.attr("href")})),modal.show(),modal})).fail(Notification.exception)}else log.error('Action "'+actionType+'" is not allowed.')}))},selectEvaluationOptions:function(actionId,trainedOnlyExternally){$('[data-action-id="'+actionId+'"]').on("click",(function(ev){ev.preventDefault();var a=$(ev.currentTarget),timeSplittingMethods=$(this).attr("data-timesplitting-methods"),stringsPromise=Str.get_strings([{key:"evaluatemodel",component:"tool_analytics"},{key:"evaluate",component:"tool_analytics"}]),modalPromise=ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL}),bodyPromise=Templates.render("tool_analytics/evaluation_options",{trainedexternally:trainedOnlyExternally,timesplittingmethods:JSON.parse(timeSplittingMethods)});$.when(stringsPromise,modalPromise).then((function(strings,modal){return modal.getRoot().on(ModalEvents.hidden,modal.destroy.bind(modal)),modal.setTitle(strings[0]),modal.setSaveButtonText(strings[1]),modal.setBody(bodyPromise),modal.getRoot().on(ModalEvents.save,(function(){"trainedmodel"==$("input[name='evaluationmode']:checked").val()&&a.attr("href",a.attr("href")+"&mode=trainedmodel");var timeSplittingMethod=$("#id-evaluation-timesplitting").val();a.attr("href",a.attr("href")+"×plitting="+timeSplittingMethod),window.location.href=a.attr("href")})),modal.show(),modal})).fail(Notification.exception)}))},selectExportOptions:function(actionId,isTrained){$('[data-action-id="'+actionId+'"]').on("click",(function(ev){ev.preventDefault();var a=$(ev.currentTarget);if(!isTrained)return a.attr("href",a.attr("href")+"&action=exportmodel&includeweights=0"),void(window.location.href=a.attr("href"));var stringsPromise=Str.get_strings([{key:"export",component:"tool_analytics"}]),modalPromise=ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL}),bodyPromise=Templates.render("tool_analytics/export_options",{});$.when(stringsPromise,modalPromise).then((function(strings,modal){return modal.getRoot().on(ModalEvents.hidden,modal.destroy.bind(modal)),modal.setTitle(strings[0]),modal.setSaveButtonText(strings[0]),modal.setBody(bodyPromise),modal.getRoot().on(ModalEvents.save,(function(){"exportdata"==$("input[name='exportoption']:checked").val()?a.attr("href",a.attr("href")+"&action=exportdata"):(a.attr("href",a.attr("href")+"&action=exportmodel"),$("#id-includeweights").is(":checked")?a.attr("href",a.attr("href")+"&includeweights=1"):a.attr("href",a.attr("href")+"&includeweights=0")),window.location.href=a.attr("href")})),modal.show(),modal})).fail(Notification.exception)}))}}})); + +//# sourceMappingURL=model.min.js.map \ No newline at end of file diff --git a/admin/tool/analytics/amd/build/model.min.js.map b/admin/tool/analytics/amd/build/model.min.js.map index 1ea039bdf3b..f50f1c0f05a 100644 --- a/admin/tool/analytics/amd/build/model.min.js.map +++ b/admin/tool/analytics/amd/build/model.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/model.js"],"names":["define","$","Str","log","Notification","ModalFactory","ModalEvents","Templates","actionsList","clear","title","key","component","body","getModelName","actionItem","wrap","closest","length","attr","error","confirmAction","actionId","actionType","on","ev","preventDefault","a","currentTarget","reqStrings","param","stringsPromise","get_strings","modalPromise","create","type","types","SAVE_CANCEL","when","then","strings","modal","setTitle","setBody","setSaveButtonText","getRoot","save","window","location","href","show","fail","exception","selectEvaluationOptions","trainedOnlyExternally","timeSplittingMethods","bodyPromise","render","trainedexternally","timesplittingmethods","JSON","parse","hidden","destroy","bind","evaluationMode","val","timeSplittingMethod","selectExportOptions","isTrained","exportOption","is"],"mappings":"AAsBAA,OAAM,wBAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,UAAvB,CAAmC,mBAAnC,CAAwD,oBAAxD,CAA8E,mBAA9E,CAAmG,gBAAnG,CAAD,CACF,SAASC,CAAT,CAAYC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mBAAhC,CACH,CACJ,CAED4B,MAAM,CAACC,QAAP,CAAgBC,IAAhB,CAAuBtB,CAAC,CAACR,IAAF,CAAO,MAAP,CAE1B,CAlBD,EAoBAsB,CAAK,CAACS,IAAN,GACA,MAAOT,CAAAA,CACV,CA9BD,EA8BGU,IA9BH,CA8BQ/C,CAAY,CAACgD,SA9BrB,CA+BH,CApDD,CAqDH,CApKE,CAsKV,CArNK,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 for model actions confirmation.\n *\n * @module tool_analytics/model\n * @copyright 2017 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/templates'],\n function($, Str, log, Notification, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of actions that require confirmation and confirmation message.\n */\n var actionsList = {\n clear: {\n title: {\n key: 'clearpredictions',\n component: 'tool_analytics'\n }, body: {\n key: 'clearmodelpredictions',\n component: 'tool_analytics'\n }\n\n },\n 'delete': {\n title: {\n key: 'delete',\n component: 'tool_analytics'\n }, body: {\n key: 'deletemodelconfirmation',\n component: 'tool_analytics'\n }\n }\n };\n\n /**\n * Returns the model name.\n *\n * @param {Object} actionItem The action item DOM node.\n * @return {String}\n */\n var getModelName = function(actionItem) {\n var wrap = $(actionItem).closest('[data-model-name]');\n\n if (wrap.length) {\n return wrap.attr('data-model-name');\n\n } else {\n log.error('Unexpected DOM error - unable to obtain the model name');\n return '';\n }\n };\n\n /** @alias module:tool_analytics/model */\n return {\n\n /**\n * Displays a confirm modal window before executing the action.\n *\n * @param {String} actionId\n * @param {String} actionType\n */\n confirmAction: function(actionId, actionType) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (typeof actionsList[actionType] === \"undefined\") {\n log.error('Action \"' + actionType + '\" is not allowed.');\n return;\n }\n\n var reqStrings = [\n actionsList[actionType].title,\n actionsList[actionType].body\n ];\n reqStrings[1].param = getModelName(a);\n\n var stringsPromise = Str.get_strings(reqStrings);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n modal.setTitle(strings[0]);\n modal.setBody(strings[1]);\n modal.setSaveButtonText(strings[0]);\n modal.getRoot().on(ModalEvents.save, function() {\n window.location.href = a.attr('href');\n });\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays evaluation mode and time-splitting method choices.\n *\n * @param {String} actionId\n * @param {Boolean} trainedOnlyExternally\n */\n selectEvaluationOptions: function(actionId, trainedOnlyExternally) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n var timeSplittingMethods = $(this).attr('data-timesplitting-methods');\n\n var stringsPromise = Str.get_strings([\n {\n key: 'evaluatemodel',\n component: 'tool_analytics'\n }, {\n key: 'evaluate',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/evaluation_options', {\n trainedexternally: trainedOnlyExternally,\n timesplittingmethods: JSON.parse(timeSplittingMethods)\n });\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[1]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n // Evaluation mode.\n var evaluationMode = $(\"input[name='evaluationmode']:checked\").val();\n if (evaluationMode == 'trainedmodel') {\n a.attr('href', a.attr('href') + '&mode=trainedmodel');\n }\n\n // Selected time-splitting id.\n var timeSplittingMethod = $(\"#id-evaluation-timesplitting\").val();\n a.attr('href', a.attr('href') + '×plitting=' + timeSplittingMethod);\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays export options.\n *\n * We have two main options: export training data and export configuration.\n * The 2nd option has an extra option: include the trained algorithm weights.\n *\n * @param {String} actionId\n * @param {Boolean} isTrained\n */\n selectExportOptions: function(actionId, isTrained) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (!isTrained) {\n // Export the model configuration if the model is not trained. We can't export anything else.\n a.attr('href', a.attr('href') + '&action=exportmodel&includeweights=0');\n window.location.href = a.attr('href');\n return;\n }\n\n var stringsPromise = Str.get_strings([\n {\n key: 'export',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/export_options', {});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[0]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n var exportOption = $(\"input[name='exportoption']:checked\").val();\n\n if (exportOption == 'exportdata') {\n a.attr('href', a.attr('href') + '&action=exportdata');\n\n } else {\n a.attr('href', a.attr('href') + '&action=exportmodel');\n if ($(\"#id-includeweights\").is(':checked')) {\n a.attr('href', a.attr('href') + '&includeweights=1');\n } else {\n a.attr('href', a.attr('href') + '&includeweights=0');\n }\n }\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n }\n };\n});\n"],"file":"model.min.js"} \ No newline at end of file +{"version":3,"file":"model.min.js","sources":["../src/model.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 * AMD module for model actions confirmation.\n *\n * @module tool_analytics/model\n * @copyright 2017 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/templates'],\n function($, Str, log, Notification, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of actions that require confirmation and confirmation message.\n */\n var actionsList = {\n clear: {\n title: {\n key: 'clearpredictions',\n component: 'tool_analytics'\n }, body: {\n key: 'clearmodelpredictions',\n component: 'tool_analytics'\n }\n\n },\n 'delete': {\n title: {\n key: 'delete',\n component: 'tool_analytics'\n }, body: {\n key: 'deletemodelconfirmation',\n component: 'tool_analytics'\n }\n }\n };\n\n /**\n * Returns the model name.\n *\n * @param {Object} actionItem The action item DOM node.\n * @return {String}\n */\n var getModelName = function(actionItem) {\n var wrap = $(actionItem).closest('[data-model-name]');\n\n if (wrap.length) {\n return wrap.attr('data-model-name');\n\n } else {\n log.error('Unexpected DOM error - unable to obtain the model name');\n return '';\n }\n };\n\n /** @alias module:tool_analytics/model */\n return {\n\n /**\n * Displays a confirm modal window before executing the action.\n *\n * @param {String} actionId\n * @param {String} actionType\n */\n confirmAction: function(actionId, actionType) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (typeof actionsList[actionType] === \"undefined\") {\n log.error('Action \"' + actionType + '\" is not allowed.');\n return;\n }\n\n var reqStrings = [\n actionsList[actionType].title,\n actionsList[actionType].body\n ];\n reqStrings[1].param = getModelName(a);\n\n var stringsPromise = Str.get_strings(reqStrings);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n modal.setTitle(strings[0]);\n modal.setBody(strings[1]);\n modal.setSaveButtonText(strings[0]);\n modal.getRoot().on(ModalEvents.save, function() {\n window.location.href = a.attr('href');\n });\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays evaluation mode and time-splitting method choices.\n *\n * @param {String} actionId\n * @param {Boolean} trainedOnlyExternally\n */\n selectEvaluationOptions: function(actionId, trainedOnlyExternally) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n var timeSplittingMethods = $(this).attr('data-timesplitting-methods');\n\n var stringsPromise = Str.get_strings([\n {\n key: 'evaluatemodel',\n component: 'tool_analytics'\n }, {\n key: 'evaluate',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/evaluation_options', {\n trainedexternally: trainedOnlyExternally,\n timesplittingmethods: JSON.parse(timeSplittingMethods)\n });\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[1]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n // Evaluation mode.\n var evaluationMode = $(\"input[name='evaluationmode']:checked\").val();\n if (evaluationMode == 'trainedmodel') {\n a.attr('href', a.attr('href') + '&mode=trainedmodel');\n }\n\n // Selected time-splitting id.\n var timeSplittingMethod = $(\"#id-evaluation-timesplitting\").val();\n a.attr('href', a.attr('href') + '×plitting=' + timeSplittingMethod);\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays export options.\n *\n * We have two main options: export training data and export configuration.\n * The 2nd option has an extra option: include the trained algorithm weights.\n *\n * @param {String} actionId\n * @param {Boolean} isTrained\n */\n selectExportOptions: function(actionId, isTrained) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (!isTrained) {\n // Export the model configuration if the model is not trained. We can't export anything else.\n a.attr('href', a.attr('href') + '&action=exportmodel&includeweights=0');\n window.location.href = a.attr('href');\n return;\n }\n\n var stringsPromise = Str.get_strings([\n {\n key: 'export',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/export_options', {});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[0]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n var exportOption = $(\"input[name='exportoption']:checked\").val();\n\n if (exportOption == 'exportdata') {\n a.attr('href', a.attr('href') + '&action=exportdata');\n\n } else {\n a.attr('href', a.attr('href') + '&action=exportmodel');\n if ($(\"#id-includeweights\").is(':checked')) {\n a.attr('href', a.attr('href') + '&includeweights=1');\n } else {\n a.attr('href', a.attr('href') + '&includeweights=0');\n }\n }\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n }\n };\n});\n"],"names":["define","$","Str","log","Notification","ModalFactory","ModalEvents","Templates","actionsList","clear","title","key","component","body","confirmAction","actionId","actionType","on","ev","preventDefault","a","currentTarget","wrap","reqStrings","param","closest","length","attr","error","stringsPromise","get_strings","modalPromise","create","type","types","SAVE_CANCEL","when","then","strings","modal","setTitle","setBody","setSaveButtonText","getRoot","save","window","location","href","show","fail","exception","selectEvaluationOptions","trainedOnlyExternally","timeSplittingMethods","this","bodyPromise","render","trainedexternally","timesplittingmethods","JSON","parse","hidden","destroy","bind","val","timeSplittingMethod","selectExportOptions","isTrained","is"],"mappings":";;;;;;;AAsBAA,8BAAO,CAAC,SAAU,WAAY,WAAY,oBAAqB,qBAAsB,oBAAqB,mBACtG,SAASC,EAAGC,IAAKC,IAAKC,aAAcC,aAAcC,YAAaC,eAK3DC,YAAc,CACdC,MAAO,CACHC,MAAO,CACHC,IAAK,mBACLC,UAAW,kBACZC,KAAM,CACLF,IAAK,wBACLC,UAAW,0BAIT,CACNF,MAAO,CACHC,IAAK,SACLC,UAAW,kBACZC,KAAM,CACLF,IAAK,0BACLC,UAAW,0BAwBhB,CAQHE,cAAe,SAASC,SAAUC,YAC9Bf,EAAE,oBAAsBc,SAAW,MAAME,GAAG,SAAS,SAASC,IAC1DA,GAAGC,qBAECC,EAAInB,EAAEiB,GAAGG,uBAE0B,IAA5Bb,YAAYQ,iBA1B3BM,KA+BQC,WAAa,CACbf,YAAYQ,YAAYN,MACxBF,YAAYQ,YAAYH,MAE5BU,WAAW,GAAGC,OAnClBF,KAAOrB,EAmCgCmB,GAnClBK,QAAQ,sBAExBC,OACEJ,KAAKK,KAAK,oBAGjBxB,IAAIyB,MAAM,0DACH,QA8BCC,eAAiB3B,IAAI4B,YAAYP,YACjCQ,aAAe1B,aAAa2B,OAAO,CAACC,KAAM5B,aAAa6B,MAAMC,cAEjElC,EAAEmC,KAAKP,eAAgBE,cAAcM,MAAK,SAASC,QAASC,cACxDA,MAAMC,SAASF,QAAQ,IACvBC,MAAME,QAAQH,QAAQ,IACtBC,MAAMG,kBAAkBJ,QAAQ,IAChCC,MAAMI,UAAU1B,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G,mBAER8C,iBAED/C,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,6CAChCkB,OAAOC,SAASC,KAAO3B,EAAEO,KAAK,aAI9BE,eAAiB3B,IAAI4B,YAAY,CACjC,CACInB,IAAK,SACLC,UAAW,oBAGfmB,aAAe1B,aAAa2B,OAAO,CAACC,KAAM5B,aAAa6B,MAAMC,cAC7DoB,YAAchD,UAAUiD,OAAO,gCAAiC,IAEpEvD,EAAEmC,KAAKP,eAAgBE,cAAcM,MAAK,SAASC,QAASC,cAExDA,MAAMI,UAAU1B,GAAGX,YAAYuD,OAAQtB,MAAMuB,QAAQC,KAAKxB,QAE1DA,MAAMC,SAASF,QAAQ,IACvBC,MAAMG,kBAAkBJ,QAAQ,IAChCC,MAAME,QAAQc,aAEdhB,MAAMI,UAAU1B,GAAGX,YAAYsC,MAAM,WAIb,cAFD3C,EAAE,sCAAsC+D,MAGvD5C,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,uBAGhCP,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,uBAC5B1B,EAAE,sBAAsBmE,GAAG,YAC3BhD,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,qBAEhCP,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,sBAIxCkB,OAAOC,SAASC,KAAO3B,EAAEO,KAAK,WAIlCY,MAAMS,OACCT,SACRU,KAAK7C,aAAa8C"} \ No newline at end of file diff --git a/admin/tool/analytics/amd/build/potential-contexts.min.js b/admin/tool/analytics/amd/build/potential-contexts.min.js index c93ee47896f..a6c87044eb6 100644 --- a/admin/tool/analytics/amd/build/potential-contexts.min.js +++ b/admin/tool/analytics/amd/build/potential-contexts.min.js @@ -1,2 +1,10 @@ -define ("tool_analytics/potential-contexts",["jquery","core/ajax"],function(a,b){return{processResults:function processResults(b,c){var d=[];if(a.isArray(c)){a.each(c,function(a,b){d.push({value:b.id,label:b.name})});return d}else{return c}},transport:function transport(c,d,e,f){var g,h=a(c).attr("modelid")||null;g=b.call([{methodname:"tool_analytics_potential_contexts",args:{query:d,modelid:h}}]);g[0].then(e).fail(f)}}}); -//# sourceMappingURL=potential-contexts.min.js.map +/** + * Potential contexts selector module. + * + * @module tool_analytics/potential-contexts + * @copyright 2019 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_analytics/potential-contexts",["jquery","core/ajax"],(function($,Ajax){return{processResults:function(selector,results){var contexts=[];return $.isArray(results)?($.each(results,(function(index,context){contexts.push({value:context.id,label:context.name})})),contexts):results},transport:function(selector,query,success,failure){let modelid=$(selector).attr("modelid")||null;Ajax.call([{methodname:"tool_analytics_potential_contexts",args:{query:query,modelid:modelid}}])[0].then(success).fail(failure)}}})); + +//# sourceMappingURL=potential-contexts.min.js.map \ No newline at end of file diff --git a/admin/tool/analytics/amd/build/potential-contexts.min.js.map b/admin/tool/analytics/amd/build/potential-contexts.min.js.map index c4ca6a9fec5..82ec224e954 100644 --- a/admin/tool/analytics/amd/build/potential-contexts.min.js.map +++ b/admin/tool/analytics/amd/build/potential-contexts.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/potential-contexts.js"],"names":["define","$","Ajax","processResults","selector","results","contexts","isArray","each","index","context","push","value","id","label","name","transport","query","success","failure","promise","modelid","attr","call","methodname","args","then","fail"],"mappings":"AAuBAA,OAAM,qCAAC,CAAC,QAAD,CAAW,WAAX,CAAD,CAA0B,SAASC,CAAT,CAAYC,CAAZ,CAAkB,CAE9C,MAA8D,CAE1DC,cAAc,CAAE,wBAASC,CAAT,CAAmBC,CAAnB,CAA4B,CACxC,GAAIC,CAAAA,CAAQ,CAAG,EAAf,CACA,GAAIL,CAAC,CAACM,OAAF,CAAUF,CAAV,CAAJ,CAAwB,CACpBJ,CAAC,CAACO,IAAF,CAAOH,CAAP,CAAgB,SAASI,CAAT,CAAgBC,CAAhB,CAAyB,CACrCJ,CAAQ,CAACK,IAAT,CAAc,CACVC,KAAK,CAAEF,CAAO,CAACG,EADL,CAEVC,KAAK,CAAEJ,CAAO,CAACK,IAFL,CAAd,CAIH,CALD,EAMA,MAAOT,CAAAA,CAEV,CATD,IASO,CACH,MAAOD,CAAAA,CACV,CACJ,CAhByD,CAkB1DW,SAAS,CAAE,mBAASZ,CAAT,CAAmBa,CAAnB,CAA0BC,CAA1B,CAAmCC,CAAnC,CAA4C,IAC/CC,CAAAA,CAD+C,CAG/CC,CAAO,CAAGpB,CAAC,CAACG,CAAD,CAAD,CAAYkB,IAAZ,CAAiB,SAAjB,GAA+B,IAHM,CAInDF,CAAO,CAAGlB,CAAI,CAACqB,IAAL,CAAU,CAAC,CACjBC,UAAU,CAAE,mCADK,CAEjBC,IAAI,CAAE,CACFR,KAAK,CAAEA,CADL,CAEFI,OAAO,CAAEA,CAFP,CAFW,CAAD,CAAV,CAAV,CAQAD,CAAO,CAAC,CAAD,CAAP,CAAWM,IAAX,CAAgBR,CAAhB,EAAyBS,IAAzB,CAA8BR,CAA9B,CACH,CA/ByD,CAmCjE,CArCK,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 * Potential contexts selector module.\n *\n * @module tool_analytics/potential-contexts\n * @copyright 2019 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax'], function($, Ajax) {\n\n return /** @alias module:tool_analytics/potential-contexts */ {\n\n processResults: function(selector, results) {\n var contexts = [];\n if ($.isArray(results)) {\n $.each(results, function(index, context) {\n contexts.push({\n value: context.id,\n label: context.name\n });\n });\n return contexts;\n\n } else {\n return results;\n }\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n let modelid = $(selector).attr('modelid') || null;\n promise = Ajax.call([{\n methodname: 'tool_analytics_potential_contexts',\n args: {\n query: query,\n modelid: modelid\n }\n }]);\n\n promise[0].then(success).fail(failure);\n }\n\n };\n\n});\n"],"file":"potential-contexts.min.js"} \ No newline at end of file +{"version":3,"file":"potential-contexts.min.js","sources":["../src/potential-contexts.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 * Potential contexts selector module.\n *\n * @module tool_analytics/potential-contexts\n * @copyright 2019 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax'], function($, Ajax) {\n\n return /** @alias module:tool_analytics/potential-contexts */ {\n\n processResults: function(selector, results) {\n var contexts = [];\n if ($.isArray(results)) {\n $.each(results, function(index, context) {\n contexts.push({\n value: context.id,\n label: context.name\n });\n });\n return contexts;\n\n } else {\n return results;\n }\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n let modelid = $(selector).attr('modelid') || null;\n promise = Ajax.call([{\n methodname: 'tool_analytics_potential_contexts',\n args: {\n query: query,\n modelid: modelid\n }\n }]);\n\n promise[0].then(success).fail(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","processResults","selector","results","contexts","isArray","each","index","context","push","value","id","label","name","transport","query","success","failure","modelid","attr","call","methodname","args","then","fail"],"mappings":";;;;;;;AAuBAA,2CAAO,CAAC,SAAU,cAAc,SAASC,EAAGC,YAEsB,CAE1DC,eAAgB,SAASC,SAAUC,aAC3BC,SAAW,UACXL,EAAEM,QAAQF,UACVJ,EAAEO,KAAKH,SAAS,SAASI,MAAOC,SAC5BJ,SAASK,KAAK,CACVC,MAAOF,QAAQG,GACfC,MAAOJ,QAAQK,UAGhBT,UAGAD,SAIfW,UAAW,SAASZ,SAAUa,MAAOC,QAASC,aAGtCC,QAAUnB,EAAEG,UAAUiB,KAAK,YAAc,KACnCnB,KAAKoB,KAAK,CAAC,CACjBC,WAAY,oCACZC,KAAM,CACFP,MAAOA,MACPG,QAASA,YAIT,GAAGK,KAAKP,SAASQ,KAAKP"} \ No newline at end of file diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js index 30e97fccc72..fee3a858e71 100644 --- a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js +++ b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js @@ -1 +1 @@ -YUI.add("moodle-tool_capability-search",function(s,t){var e=function(){e.superclass.constructor.apply(this,arguments)};e.prototype={form:null,select:null,selectoptions:{},input:null,button:null,cancel:null,lastsearch:null,initializer:function(){this.form=s.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(t){var e=t.get("value");this.selectoptions[e]=t},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=s.Node.create('
'),e=s.Node.create('");this.cancel=s.Node.create(''),this.input=s.Node.create(''),t.append(e).append(this.input).append(this.cancel),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.cancel.on("click",function(){this.input.set("value",""),this.typed()},this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",""===this.select.get("value"))},typed:function(){var t,e=this.input.get("value"),s=0,i=null;for(t in this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove(),this.selectoptions)0<=t.indexOf(e)&&(s++,i=this.selectoptions[t],this.select.append(this.selectoptions[t]));0===s?this.input.addClass("error"):(this.input.removeClass("error"),1===s&&i.set("selected",!0)),""!==e?this.cancel.removeClass("d-none"):this.cancel.addClass("d-none"),this.validate()}},s.extend(e,s.Base,e.prototype,{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(t){new e(t)}},"@VERSION@",{requires:["base","node"]}); \ No newline at end of file +YUI.add("moodle-tool_capability-search",function(s,t){var e=function(){e.superclass.constructor.apply(this,arguments)};s.extend(e,s.Base,e.prototype={form:null,select:null,selectoptions:{},input:null,button:null,cancel:null,lastsearch:null,initializer:function(){this.form=s.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(t){var e=t.get("value");this.selectoptions[e]=t},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=s.Node.create('
'),e=s.Node.create('");this.cancel=s.Node.create(''),this.input=s.Node.create(''),t.append(e).append(this.input).append(this.cancel),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.cancel.on("click",function(){this.input.set("value",""),this.typed()},this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",""===this.select.get("value"))},typed:function(){var t,e=this.input.get("value"),s=0,i=null;for(t in this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove(),this.selectoptions)0<=t.indexOf(e)&&(s++,i=this.selectoptions[t],this.select.append(this.selectoptions[t]));0===s?this.input.addClass("error"):(this.input.removeClass("error"),1===s&&i.set("selected",!0)),""!==e?this.cancel.removeClass("d-none"):this.cancel.addClass("d-none"),this.validate()}},{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(t){new e(t)}},"@VERSION@",{requires:["base","node"]}); \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js b/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js index 37db2479ca3..a8faa5acf56 100644 --- a/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js +++ b/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js @@ -1,2 +1,10 @@ -define ("tool_componentlibrary/clipboardwrapper",["exports","core/copy_to_clipboard","tool_componentlibrary/selectors","core/templates"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.clipboardWrapper=void 0;c=e(c);d=e(d);function e(a){return a&&a.__esModule?a:{default:a}}function f(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function g(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var i=a.apply(b,c);function g(a){f(i,d,e,g,h,"next",a)}function h(a){f(i,d,e,g,h,"throw",a)}g(void 0)})}}var h=0,i=function(){var a=g(regeneratorRuntime.mark(function a(){return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:document.querySelectorAll(c.default.clipboardcontent).forEach(function(a){if(!a.id){a.id="tool_componentlibrary_content-".concat(h++)}d.default.renderForPromise("tool_componentlibrary/clipboardbutton",{clipboardtarget:"#".concat(a.id," code")}).then(function(b){var c=b.html,e=b.js;d.default.prependNodeContents(a,c,e);return}).catch()});case 1:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.clipboardWrapper=i}); -//# sourceMappingURL=clipboardwrapper.min.js.map +define("tool_componentlibrary/clipboardwrapper",["exports","core/copy_to_clipboard","tool_componentlibrary/selectors","core/templates"],(function(_exports,_copy_to_clipboard,_selectors,_templates){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} +/** + * Wrapper to ensure that all Hugo example snippets have a "Copy to clipboard" button. + * + * @module tool_componentlibrary/clipboardwrapper + * @copyright 2021 Bas Brands + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.clipboardWrapper=void 0,_selectors=_interopRequireDefault(_selectors),_templates=_interopRequireDefault(_templates);let idCounter=0;_exports.clipboardWrapper=async()=>{document.querySelectorAll(_selectors.default.clipboardcontent).forEach((element=>{element.id||(element.id="tool_componentlibrary_content-".concat(idCounter++)),_templates.default.renderForPromise("tool_componentlibrary/clipboardbutton",{clipboardtarget:"#".concat(element.id," code")}).then((_ref=>{let{html:html,js:js}=_ref;_templates.default.prependNodeContents(element,html,js)})).catch()}))}})); + +//# sourceMappingURL=clipboardwrapper.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map b/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map index 080df4a7164..0c6e79f2a59 100644 --- a/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map +++ b/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/clipboardwrapper.js"],"names":["idCounter","clipboardWrapper","document","querySelectorAll","selectors","clipboardcontent","forEach","element","id","Templates","renderForPromise","clipboardtarget","then","html","js","prependNodeContents","catch"],"mappings":"mPAuBA,OACA,O,qXAEIA,CAAAA,CAAS,CAAG,C,CAOHC,CAAgB,4CAAG,8FAC5BC,QAAQ,CAACC,gBAAT,CAA0BC,UAAUC,gBAApC,EAAsDC,OAAtD,CAA8D,SAAAC,CAAO,CAAI,CACrE,GAAI,CAACA,CAAO,CAACC,EAAb,CAAiB,CACbD,CAAO,CAACC,EAAR,yCAA8CR,CAAS,EAAvD,CACH,CACDS,UAAUC,gBAAV,CAA2B,uCAA3B,CAAoE,CAACC,eAAe,YAAMJ,CAAO,CAACC,EAAd,SAAhB,CAApE,EACCI,IADD,CACM,WAAgB,IAAdC,CAAAA,CAAc,GAAdA,IAAc,CAARC,CAAQ,GAARA,EAAQ,CAClBL,UAAUM,mBAAV,CAA8BR,CAA9B,CAAuCM,CAAvC,CAA6CC,CAA7C,EACA,MACH,CAJD,EAKCE,KALD,EAMH,CAVD,EAD4B,wCAAH,uD","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 to ensure that all Hugo example snippets have a \"Copy to clipboard\" button.\n *\n * @module tool_componentlibrary/clipboardwrapper\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport 'core/copy_to_clipboard';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Templates from 'core/templates';\n\nlet idCounter = 0;\n\n/**\n * Initialise the clipboard button on all reusable code.\n *\n * @method\n */\nexport const clipboardWrapper = async() => {\n document.querySelectorAll(selectors.clipboardcontent).forEach(element => {\n if (!element.id) {\n element.id = `tool_componentlibrary_content-${idCounter++}`;\n }\n Templates.renderForPromise('tool_componentlibrary/clipboardbutton', {clipboardtarget: `#${element.id} code`})\n .then(({html, js}) => {\n Templates.prependNodeContents(element, html, js);\n return;\n })\n .catch();\n });\n};\n"],"file":"clipboardwrapper.min.js"} \ No newline at end of file +{"version":3,"file":"clipboardwrapper.min.js","sources":["../src/clipboardwrapper.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 * Wrapper to ensure that all Hugo example snippets have a \"Copy to clipboard\" button.\n *\n * @module tool_componentlibrary/clipboardwrapper\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport 'core/copy_to_clipboard';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Templates from 'core/templates';\n\nlet idCounter = 0;\n\n/**\n * Initialise the clipboard button on all reusable code.\n *\n * @method\n */\nexport const clipboardWrapper = async() => {\n document.querySelectorAll(selectors.clipboardcontent).forEach(element => {\n if (!element.id) {\n element.id = `tool_componentlibrary_content-${idCounter++}`;\n }\n Templates.renderForPromise('tool_componentlibrary/clipboardbutton', {clipboardtarget: `#${element.id} code`})\n .then(({html, js}) => {\n Templates.prependNodeContents(element, html, js);\n return;\n })\n .catch();\n });\n};\n"],"names":["idCounter","async","document","querySelectorAll","selectors","clipboardcontent","forEach","element","id","renderForPromise","clipboardtarget","then","_ref","html","js","prependNodeContents","catch"],"mappings":";;;;;;;8LA0BIA,UAAY,4BAOgBC,UAC5BC,SAASC,iBAAiBC,mBAAUC,kBAAkBC,SAAQC,UACrDA,QAAQC,KACTD,QAAQC,2CAAsCR,iCAExCS,iBAAiB,wCAAyC,CAACC,2BAAqBH,QAAQC,cACjGG,MAAKC,WAACC,KAACA,KAADC,GAAOA,4BACAC,oBAAoBR,QAASM,KAAMC,OAGhDE"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/jsrunner.min.js b/admin/tool/componentlibrary/amd/build/jsrunner.min.js index 727d94d0ff2..df5fb710e61 100644 --- a/admin/tool/componentlibrary/amd/build/jsrunner.min.js +++ b/admin/tool/componentlibrary/amd/build/jsrunner.min.js @@ -1,2 +1,10 @@ -define ("tool_componentlibrary/jsrunner",["exports","tool_componentlibrary/selectors"],function(_exports,_selectors){"use strict";Object.defineProperty(_exports,"__esModule",{value:!0});_exports.jsRunner=void 0;_selectors=_interopRequireDefault(_selectors);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var jsRunner=function(){var compLib=document.querySelector(_selectors.default.componentlibrary);compLib.querySelectorAll(_selectors.default.jscode).forEach(function(runjs){eval(runjs.innerText)})};_exports.jsRunner=jsRunner}); -//# sourceMappingURL=jsrunner.min.js.map +define("tool_componentlibrary/jsrunner",["exports","tool_componentlibrary/selectors"],(function(_exports,_selectors){var obj; +/** + * Run the JS required for example code to work in the library. + * + * @module tool_componentlibrary/jsrunner + * @copyright 2021 Bas Brands + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.jsRunner=void 0,_selectors=(obj=_selectors)&&obj.__esModule?obj:{default:obj};_exports.jsRunner=()=>{document.querySelector(_selectors.default.componentlibrary).querySelectorAll(_selectors.default.jscode).forEach((runjs=>{const script=document.createElement("script");script.type="text/javascript",script.innerHTML=runjs.textContent,document.head.appendChild(script)}))}})); + +//# sourceMappingURL=jsrunner.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map b/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map index fbad8f1fe76..cba5b132059 100644 --- a/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map +++ b/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/jsrunner.js"],"names":["jsRunner","compLib","document","querySelector","selectors","componentlibrary","querySelectorAll","jscode","forEach","runjs","eval","innerText"],"mappings":"mNAuBA,8C,wEAUO,GAAMA,CAAAA,QAAQ,CAAG,UAAM,CAC1B,GAAMC,CAAAA,OAAO,CAAGC,QAAQ,CAACC,aAAT,CAAuBC,mBAAUC,gBAAjC,CAAhB,CACAJ,OAAO,CAACK,gBAAR,CAAyBF,mBAAUG,MAAnC,EAA2CC,OAA3C,CAAmD,SAAAC,KAAK,CAAI,CACxDC,IAAI,CAACD,KAAK,CAACE,SAAP,CACP,CAFD,CAGH,CALM,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 .\n\n/**\n * Run the JS required for example code to work in the library.\n *\n * @module tool_componentlibrary/jsrunner\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\n\n/**\n * The Hugo shortcodes changes the JavaScript in markdownfiles from\n * the Moodle mustache {{js}} code... {{/js}} syntax into a div with\n * attribute data-action='runjs'. See hugo/site/layouts/shortcodes/example.html.\n * This code fetches and runs the JavaScript content.\n *\n * @method\n */\nexport const jsRunner = () => {\n const compLib = document.querySelector(selectors.componentlibrary);\n compLib.querySelectorAll(selectors.jscode).forEach(runjs => {\n eval(runjs.innerText); // eslint-disable-line no-eval\n });\n};\n"],"file":"jsrunner.min.js"} \ No newline at end of file +{"version":3,"file":"jsrunner.min.js","sources":["../src/jsrunner.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 * Run the JS required for example code to work in the library.\n *\n * @module tool_componentlibrary/jsrunner\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\n\n/**\n * The Hugo shortcodes changes the JavaScript in markdownfiles from\n * the Moodle mustache {{js}} code... {{/js}} syntax into a div with\n * attribute data-action='runjs'. See hugo/site/layouts/shortcodes/example.html.\n * This code fetches and runs the JavaScript content.\n *\n * @method\n */\nexport const jsRunner = () => {\n const compLib = document.querySelector(selectors.componentlibrary);\n compLib.querySelectorAll(selectors.jscode).forEach(runjs => {\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.innerHTML = runjs.textContent;\n document.head.appendChild(script);\n });\n};\n"],"names":["document","querySelector","selectors","componentlibrary","querySelectorAll","jscode","forEach","runjs","script","createElement","type","innerHTML","textContent","head","appendChild"],"mappings":";;;;;;;sKAiCwB,KACJA,SAASC,cAAcC,mBAAUC,kBACzCC,iBAAiBF,mBAAUG,QAAQC,SAAQC,cACzCC,OAASR,SAASS,cAAc,UACtCD,OAAOE,KAAO,kBACdF,OAAOG,UAAYJ,MAAMK,YACzBZ,SAASa,KAAKC,YAAYN"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/loader.min.js b/admin/tool/componentlibrary/amd/build/loader.min.js index 84f31de304b..e921903b5f5 100644 --- a/admin/tool/componentlibrary/amd/build/loader.min.js +++ b/admin/tool/componentlibrary/amd/build/loader.min.js @@ -1,2 +1,3 @@ -define ("tool_componentlibrary/loader",["exports","./mustache","./jsrunner","./clipboardwrapper","./search"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;a.init=function init(a){(0,b.mustache)();(0,c.jsRunner)();(0,d.clipboardWrapper)();(0,e.search)(a)}}); -//# sourceMappingURL=loader.min.js.map +define("tool_componentlibrary/loader",["exports","./mustache","./jsrunner","./clipboardwrapper","./search"],(function(_exports,_mustache,_jsrunner,_clipboardwrapper,_search){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0;_exports.init=jsonFile=>{(0,_mustache.mustache)(),(0,_jsrunner.jsRunner)(),(0,_clipboardwrapper.clipboardWrapper)(),(0,_search.search)(jsonFile)}})); + +//# sourceMappingURL=loader.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/loader.min.js.map b/admin/tool/componentlibrary/amd/build/loader.min.js.map index 44286dee310..cd8e5c606e5 100644 --- a/admin/tool/componentlibrary/amd/build/loader.min.js.map +++ b/admin/tool/componentlibrary/amd/build/loader.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/loader.js"],"names":["init","jsonFile"],"mappings":"oNAiCoB,QAAPA,CAAAA,IAAO,CAAAC,CAAQ,CAAI,CAC5B,iBACA,iBACA,yBACA,aAAOA,CAAP,CACH,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 .\n\n/**\n * This initialises the component library JS\n *\n * @module tool_componentlibrary/loader\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {mustache} from './mustache';\nimport {jsRunner} from './jsrunner';\nimport {clipboardWrapper} from './clipboardwrapper';\nimport {search} from './search';\n\n/**\n * Load all the component library JavaScript.\n *\n * @param {string} jsonFile Full path to the JSON file with the search DB.\n */\nexport const init = jsonFile => {\n mustache();\n jsRunner();\n clipboardWrapper();\n search(jsonFile);\n};\n"],"file":"loader.min.js"} \ No newline at end of file +{"version":3,"file":"loader.min.js","sources":["../src/loader.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 * This initialises the component library JS\n *\n * @module tool_componentlibrary/loader\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {mustache} from './mustache';\nimport {jsRunner} from './jsrunner';\nimport {clipboardWrapper} from './clipboardwrapper';\nimport {search} from './search';\n\n/**\n * Load all the component library JavaScript.\n *\n * @param {string} jsonFile Full path to the JSON file with the search DB.\n */\nexport const init = jsonFile => {\n mustache();\n jsRunner();\n clipboardWrapper();\n search(jsonFile);\n};\n"],"names":["jsonFile"],"mappings":"yQAiCoBA,yHAITA"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/lunr.min.js b/admin/tool/componentlibrary/amd/build/lunr.min.js index ae085755e7e..9273bde7c14 100644 --- a/admin/tool/componentlibrary/amd/build/lunr.min.js +++ b/admin/tool/componentlibrary/amd/build/lunr.min.js @@ -1,2 +1,8 @@ -function _typeof(e){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(e){return typeof e}}else{_typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}(function(){var e=function(t){var r=new e.Builder;r.pipeline.add(e.trimmer,e.stopWordFilter,e.stemmer);r.searchPipeline.add(e.stemmer);t.call(r,r);return r.build()};e.version="2.3.9";e.utils={};e.utils.warn=function(e){return function(t){if(e.console&&console.warn){console.warn(t)}}}(this);e.utils.asString=function(e){if(void 0===e||null===e){return""}else{return e.toString()}};e.utils.clone=function(e){if(null===e||e===void 0){return e}for(var t=Object.create(null),r=Object.keys(e),n=0;ne){r=n}if(s==e){break}i=r-t;n=t+Math.floor(i/2);s=this.elements[2*n]}if(s==e){return 2*n}if(s>e){return 2*n}if(sa){u+=2}else if(o==a){t+=r[l+1]*n[u+1];l+=2;u+=2}}return t};e.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0};e.Vector.prototype.toArray=function(){for(var e=Array(this.elements.length/2),t=1,r=0;ts.length){return s}a=s.substr(0,1);if("y"==a){s=a.toUpperCase()+s.substr(1)}l=/^(.+?)(ss|i)es$/;u=/^(.+?)([^s])s$/;if(l.test(s)){s=s.replace(l,"$1$2")}else if(u.test(s)){s=s.replace(u,"$1$2")}l=/^(.+?)eed$/;u=/^(.+?)(ed|ing)$/;if(l.test(s)){var m=l.exec(s);l=r;if(l.test(m[1])){l=n;s=s.replace(l,"")}}else if(u.test(s)){var m=u.exec(s);d=m[1];u=/^([^aeiou][^aeiouy]*)?[aeiouy]/;if(u.test(d)){s=d;u=/(at|bl|iz)$/;p=/([^aeiouylsz])\1$/;c=/^[^aeiou][^aeiouy]*[aeiouy][^aeiouwxy]$/;if(u.test(s)){s=s+"e"}else if(p.test(s)){l=n;s=s.replace(l,"")}else if(c.test(s)){s=s+"e"}}}l=/^(.+?[^aeiou])y$/;if(l.test(s)){var m=l.exec(s);d=m[1];s=d+"i"}l=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;if(l.test(s)){var m=l.exec(s);d=m[1];o=m[2];l=r;if(l.test(d)){s=d+e[o]}}l=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;if(l.test(s)){var m=l.exec(s);d=m[1];o=m[2];l=r;if(l.test(d)){s=d+t[o]}}l=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;u=/^(.+?)(s|t)(ion)$/;if(l.test(s)){var m=l.exec(s);d=m[1];l=i;if(l.test(d)){s=d}}else if(u.test(s)){var m=u.exec(s);d=m[1]+m[2];u=i;if(u.test(d)){s=d}}l=/^(.+?)e$/;if(l.test(s)){var m=l.exec(s);d=m[1];l=i;u=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$/;p=/^[^aeiou][^aeiouy]*[aeiouy][^aeiouwxy]$/;if(l.test(d)||u.test(d)&&!p.test(d)){s=d}}l=/ll$/;u=i;if(l.test(s)&&u.test(s)){l=n;s=s.replace(l,"")}if("y"==a){s=a.toLowerCase()+s.substr(1)}return s};return function(e){return e.update(s)}}();e.Pipeline.registerFunction(e.stemmer,"stemmer");e.generateStopWordFilter=function(e){var t=e.reduce(function(e,t){e[t]=t;return e},{});return function(e){if(e&&t[e.toString()]!==e.toString())return e}};e.stopWordFilter=e.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]);e.Pipeline.registerFunction(e.stopWordFilter,"stopWordFilter");e.trimmer=function(e){return e.update(function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")})};e.Pipeline.registerFunction(e.trimmer,"trimmer");e.TokenSet=function(){this.final=!1;this.edges={};this.id=e.TokenSet._nextId;e.TokenSet._nextId+=1};e.TokenSet._nextId=1;e.TokenSet.fromArray=function(t){for(var r=new e.TokenSet.Builder,n=0,s=t.length;n=e;t--){var r=this.uncheckedNodes[t],n=r.child.toString();if(n in this.minimizedNodes){r.parent.edges[r.char]=this.minimizedNodes[n]}else{r.child._str=n;this.minimizedNodes[n]=r.child}this.uncheckedNodes.pop()}};e.Index=function(e){this.invertedIndex=e.invertedIndex;this.fieldVectors=e.fieldVectors;this.tokenSet=e.tokenSet;this.fields=e.fields;this.pipeline=e.pipeline};e.Index.prototype.search=function(t){return this.query(function(r){var i=new e.QueryParser(t,r);i.parse()})};e.Index.prototype.query=function(t){for(var r=new e.Query(this.fields),n=Object.create(null),s=Object.create(null),d=Object.create(null),o=Object.create(null),a=Object.create(null),u=0;ue){this._b=0}else if(1=this.length){return e.QueryLexer.EOS}var t=this.str.charAt(this.pos);this.pos+=1;return t};e.QueryLexer.prototype.width=function(){return this.pos-this.start};e.QueryLexer.prototype.ignore=function(){if(this.start==this.pos){this.pos+=1}this.start=this.pos};e.QueryLexer.prototype.backup=function(){this.pos-=1};e.QueryLexer.prototype.acceptDigitRun=function(){var t,r;do{t=this.next();r=t.charCodeAt(0)}while(47r);if(t!=e.QueryLexer.EOS){this.backup()}};e.QueryLexer.prototype.more=function(){return this.pos0){var tokenMetadata=lunr.utils.clone(metadata)||{};tokenMetadata.position=[sliceStart,sliceLength],tokenMetadata.index=tokens.length,tokens.push(new lunr.Token(str.slice(sliceStart,sliceEnd),tokenMetadata))}sliceStart=sliceEnd+1}}return tokens},lunr.tokenizer.separator=/[\s\-]+/,lunr.Pipeline=function(){this._stack=[]},lunr.Pipeline.registeredFunctions=Object.create(null),lunr.Pipeline.registerFunction=function(fn,label){label in this.registeredFunctions&&lunr.utils.warn("Overwriting existing registered function: "+label),fn.label=label,lunr.Pipeline.registeredFunctions[fn.label]=fn},lunr.Pipeline.warnIfFunctionNotRegistered=function(fn){fn.label&&fn.label in this.registeredFunctions||lunr.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",fn)},lunr.Pipeline.load=function(serialised){var pipeline=new lunr.Pipeline;return serialised.forEach((function(fnName){var fn=lunr.Pipeline.registeredFunctions[fnName];if(!fn)throw new Error("Cannot load unregistered function: "+fnName);pipeline.add(fn)})),pipeline},lunr.Pipeline.prototype.add=function(){var fns=Array.prototype.slice.call(arguments);fns.forEach((function(fn){lunr.Pipeline.warnIfFunctionNotRegistered(fn),this._stack.push(fn)}),this)},lunr.Pipeline.prototype.after=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(-1==pos)throw new Error("Cannot find existingFn");pos+=1,this._stack.splice(pos,0,newFn)},lunr.Pipeline.prototype.before=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(-1==pos)throw new Error("Cannot find existingFn");this._stack.splice(pos,0,newFn)},lunr.Pipeline.prototype.remove=function(fn){var pos=this._stack.indexOf(fn);-1!=pos&&this._stack.splice(pos,1)},lunr.Pipeline.prototype.run=function(tokens){for(var stackLength=this._stack.length,i=0;i1&&(pivotIndexindex&&(end=pivotPoint),pivotIndex!=index);)sliceLength=end-start,pivotPoint=start+Math.floor(sliceLength/2),pivotIndex=this.elements[2*pivotPoint];return pivotIndex==index||pivotIndex>index?2*pivotPoint:pivotIndexbVal?j+=2:aVal==bVal&&(dotProduct+=a[i+1]*b[j+1],i+=2,j+=2);return dotProduct},lunr.Vector.prototype.similarity=function(otherVector){return this.dot(otherVector)/this.magnitude()||0},lunr.Vector.prototype.toArray=function(){for(var output=new Array(this.elements.length/2),i=1,j=0;i0){var noEditNode,char=frame.str.charAt(0);char in frame.node.edges?noEditNode=frame.node.edges[char]:(noEditNode=new lunr.TokenSet,frame.node.edges[char]=noEditNode),1==frame.str.length&&(noEditNode.final=!0),stack.push({node:noEditNode,editsRemaining:frame.editsRemaining,str:frame.str.slice(1)})}if(0!=frame.editsRemaining){if("*"in frame.node.edges)var insertionNode=frame.node.edges["*"];else{insertionNode=new lunr.TokenSet;frame.node.edges["*"]=insertionNode}if(0==frame.str.length&&(insertionNode.final=!0),stack.push({node:insertionNode,editsRemaining:frame.editsRemaining-1,str:frame.str}),frame.str.length>1&&stack.push({node:frame.node,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(1)}),1==frame.str.length&&(frame.node.final=!0),frame.str.length>=1){if("*"in frame.node.edges)var substitutionNode=frame.node.edges["*"];else{substitutionNode=new lunr.TokenSet;frame.node.edges["*"]=substitutionNode}1==frame.str.length&&(substitutionNode.final=!0),stack.push({node:substitutionNode,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(1)})}if(frame.str.length>1){var transposeNode,charA=frame.str.charAt(0),charB=frame.str.charAt(1);charB in frame.node.edges?transposeNode=frame.node.edges[charB]:(transposeNode=new lunr.TokenSet,frame.node.edges[charB]=transposeNode),1==frame.str.length&&(transposeNode.final=!0),stack.push({node:transposeNode,editsRemaining:frame.editsRemaining-1,str:charA+frame.str.slice(2)})}}}return root},lunr.TokenSet.fromString=function(str){for(var node=new lunr.TokenSet,root=node,i=0,len=str.length;i=downTo;i--){var node=this.uncheckedNodes[i],childKey=node.child.toString();childKey in this.minimizedNodes?node.parent.edges[node.char]=this.minimizedNodes[childKey]:(node.child._str=childKey,this.minimizedNodes[childKey]=node.child),this.uncheckedNodes.pop()}},lunr.Index=function(attrs){this.invertedIndex=attrs.invertedIndex,this.fieldVectors=attrs.fieldVectors,this.tokenSet=attrs.tokenSet,this.fields=attrs.fields,this.pipeline=attrs.pipeline},lunr.Index.prototype.search=function(queryString){return this.query((function(query){new lunr.QueryParser(queryString,query).parse()}))},lunr.Index.prototype.query=function(fn){for(var query=new lunr.Query(this.fields),matchingFields=Object.create(null),queryVectors=Object.create(null),termFieldCache=Object.create(null),requiredMatches=Object.create(null),prohibitedMatches=Object.create(null),i=0;i1?1:number},lunr.Builder.prototype.k1=function(number){this._k1=number},lunr.Builder.prototype.add=function(doc,attributes){var docRef=doc[this._ref],fields=Object.keys(this._fields);this._documents[docRef]=attributes||{},this.documentCount+=1;for(var i=0;i=this.length)return lunr.QueryLexer.EOS;var char=this.str.charAt(this.pos);return this.pos+=1,char},lunr.QueryLexer.prototype.width=function(){return this.pos-this.start},lunr.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},lunr.QueryLexer.prototype.backup=function(){this.pos-=1},lunr.QueryLexer.prototype.acceptDigitRun=function(){var char,charCode;do{charCode=(char=this.next()).charCodeAt(0)}while(charCode>47&&charCode<58);char!=lunr.QueryLexer.EOS&&this.backup()},lunr.QueryLexer.prototype.more=function(){return this.pos1&&(lexer.backup(),lexer.emit(lunr.QueryLexer.TERM)),lexer.ignore(),lexer.more())return lunr.QueryLexer.lexText},lunr.QueryLexer.lexEditDistance=function(lexer){return lexer.ignore(),lexer.acceptDigitRun(),lexer.emit(lunr.QueryLexer.EDIT_DISTANCE),lunr.QueryLexer.lexText},lunr.QueryLexer.lexBoost=function(lexer){return lexer.ignore(),lexer.acceptDigitRun(),lexer.emit(lunr.QueryLexer.BOOST),lunr.QueryLexer.lexText},lunr.QueryLexer.lexEOS=function(lexer){lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM)},lunr.QueryLexer.termSeparator=lunr.tokenizer.separator,lunr.QueryLexer.lexText=function(lexer){for(;;){var char=lexer.next();if(char==lunr.QueryLexer.EOS)return lunr.QueryLexer.lexEOS;if(92!=char.charCodeAt(0)){if(":"==char)return lunr.QueryLexer.lexField;if("~"==char)return lexer.backup(),lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM),lunr.QueryLexer.lexEditDistance;if("^"==char)return lexer.backup(),lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM),lunr.QueryLexer.lexBoost;if("+"==char&&1===lexer.width())return lexer.emit(lunr.QueryLexer.PRESENCE),lunr.QueryLexer.lexText;if("-"==char&&1===lexer.width())return lexer.emit(lunr.QueryLexer.PRESENCE),lunr.QueryLexer.lexText;if(char.match(lunr.QueryLexer.termSeparator))return lunr.QueryLexer.lexTerm}else lexer.escapeCharacter()}},lunr.QueryParser=function(str,query){this.lexer=new lunr.QueryLexer(str),this.query=query,this.currentClause={},this.lexemeIdx=0},lunr.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var state=lunr.QueryParser.parseClause;state;)state=state(this);return this.query},lunr.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},lunr.QueryParser.prototype.consumeLexeme=function(){var lexeme=this.peekLexeme();return this.lexemeIdx+=1,lexeme},lunr.QueryParser.prototype.nextClause=function(){var completedClause=this.currentClause;this.query.clause(completedClause),this.currentClause={}},lunr.QueryParser.parseClause=function(parser){var lexeme=parser.peekLexeme();if(null!=lexeme)switch(lexeme.type){case lunr.QueryLexer.PRESENCE:return lunr.QueryParser.parsePresence;case lunr.QueryLexer.FIELD:return lunr.QueryParser.parseField;case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:var errorMessage="expected either a field or a term, found "+lexeme.type;throw lexeme.str.length>=1&&(errorMessage+=" with value '"+lexeme.str+"'"),new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}},lunr.QueryParser.parsePresence=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){switch(lexeme.str){case"-":parser.currentClause.presence=lunr.Query.presence.PROHIBITED;break;case"+":parser.currentClause.presence=lunr.Query.presence.REQUIRED;break;default:var errorMessage="unrecognised presence operator'"+lexeme.str+"'";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}var nextLexeme=parser.peekLexeme();if(null==nextLexeme){errorMessage="expecting term or field, found nothing";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}switch(nextLexeme.type){case lunr.QueryLexer.FIELD:return lunr.QueryParser.parseField;case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:errorMessage="expecting term or field, found '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}}},lunr.QueryParser.parseField=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){if(-1==parser.query.allFields.indexOf(lexeme.str)){var possibleFields=parser.query.allFields.map((function(f){return"'"+f+"'"})).join(", "),errorMessage="unrecognised field '"+lexeme.str+"', possible fields: "+possibleFields;throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.fields=[lexeme.str];var nextLexeme=parser.peekLexeme();if(null==nextLexeme){errorMessage="expecting term, found nothing";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}if(nextLexeme.type===lunr.QueryLexer.TERM)return lunr.QueryParser.parseTerm;errorMessage="expecting term, found '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}},lunr.QueryParser.parseTerm=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){parser.currentClause.term=lexeme.str.toLowerCase(),-1!=lexeme.str.indexOf("*")&&(parser.currentClause.usePipeline=!1);var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:var errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},lunr.QueryParser.parseEditDistance=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){var editDistance=parseInt(lexeme.str,10);if(isNaN(editDistance)){var errorMessage="edit distance must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.editDistance=editDistance;var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},lunr.QueryParser.parseBoost=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){var boost=parseInt(lexeme.str,10);if(isNaN(boost)){var errorMessage="boost must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.boost=boost;var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},root=this,factory=function(){return lunr},"function"==typeof define&&define.amd?define("tool_componentlibrary/lunr",factory):"object"==typeof exports?module.exports=factory():root.lunr=factory()}(); + +//# sourceMappingURL=lunr.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/lunr.min.js.map b/admin/tool/componentlibrary/amd/build/lunr.min.js.map index 5b8ba3e9cef..fb888b2a655 100644 --- a/admin/tool/componentlibrary/amd/build/lunr.min.js.map +++ b/admin/tool/componentlibrary/amd/build/lunr.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/lunr.js"],"names":["lunr","config","builder","Builder","pipeline","add","trimmer","stopWordFilter","stemmer","searchPipeline","call","build","version","utils","warn","global","message","console","asString","obj","toString","clone","Object","create","keys","i","length","key","val","Array","isArray","slice","TypeError","FieldRef","docRef","fieldName","stringValue","_stringValue","joiner","fromString","s","n","indexOf","fieldRef","prototype","Set","elements","complete","intersect","other","union","contains","empty","object","a","b","intersection","element","push","concat","idf","posting","documentCount","documentsWithTerm","x","Math","log","abs","Token","str","metadata","update","fn","tokenizer","map","t","toLowerCase","len","tokens","sliceEnd","sliceStart","char","charAt","sliceLength","match","separator","tokenMetadata","Pipeline","_stack","registeredFunctions","registerFunction","label","warnIfFunctionNotRegistered","isRegistered","load","serialised","forEach","fnName","Error","fns","arguments","after","existingFn","newFn","pos","splice","before","remove","run","stackLength","memo","j","result","k","runString","token","reset","toJSON","Vector","_magnitude","positionForIndex","index","start","end","pivotPoint","floor","pivotIndex","insert","insertIdx","upsert","position","magnitude","sumOfSquares","elementsLength","sqrt","dot","otherVector","dotProduct","aLen","bLen","aVal","bVal","similarity","toArray","output","step2list","step3list","re_mgr0","re_mgr1","re_1b_2","porterStemmer","w","stem","suffix","firstch","re","re2","re3","re4","substr","toUpperCase","test","replace","fp","exec","generateStopWordFilter","stopWords","words","reduce","stopWord","TokenSet","final","edges","id","_nextId","fromArray","arr","finish","root","fromClause","clause","fromFuzzyString","term","editDistance","stack","node","editsRemaining","frame","pop","noEditNode","insertionNode","substitutionNode","charA","charB","transposeNode","next","prefix","edge","_str","labels","sort","qNode","qEdges","qLen","nEdges","nLen","q","qEdge","nEdge","previousWord","uncheckedNodes","minimizedNodes","word","commonPrefix","minimize","child","nextNode","parent","downTo","childKey","Index","attrs","invertedIndex","fieldVectors","tokenSet","fields","search","queryString","query","parser","QueryParser","parse","Query","matchingFields","queryVectors","termFieldCache","requiredMatches","prohibitedMatches","clauses","terms","clauseMatches","usePipeline","m","termTokenSet","expandedTerms","presence","REQUIRED","field","expandedTerm","termIndex","_index","fieldPosting","matchingDocumentRefs","termField","matchingDocumentsSet","PROHIBITED","boost","l","matchingDocumentRef","matchingFieldRef","fieldMatch","MatchData","allRequiredMatches","allProhibitedMatches","matchingFieldRefs","results","matches","isNegated","fieldVector","score","docMatch","matchData","combine","ref","serializedIndex","serializedVectors","serializedInvertedIndex","tokenSetBuilder","tuple","_ref","_fields","_documents","fieldTermFrequencies","fieldLengths","_b","_k1","metadataWhitelist","attributes","RangeError","number","k1","doc","extractor","fieldTerms","metadataKey","calculateAverageFieldLengths","fieldRefs","numberOfFields","accumulator","documentsWithField","averageFieldLength","createFieldVectors","fieldRefsLength","termIdfCache","fieldLength","termFrequencies","termsLength","fieldBoost","docBoost","tf","scoreWithPrecision","round","createTokenSet","use","args","unshift","apply","clonedMetadata","metadataKeys","otherMatchData","allFields","wildcard","String","NONE","LEADING","TRAILING","OPTIONAL","options","QueryParseError","name","QueryLexer","lexemes","escapeCharPositions","state","lexText","sliceString","subSlices","join","emit","type","escapeCharacter","EOS","width","ignore","backup","acceptDigitRun","charCode","charCodeAt","more","FIELD","TERM","EDIT_DISTANCE","BOOST","PRESENCE","lexField","lexer","lexTerm","lexEditDistance","lexBoost","lexEOS","termSeparator","currentClause","lexemeIdx","parseClause","peekLexeme","consumeLexeme","lexeme","nextClause","completedClause","parsePresence","parseField","parseTerm","errorMessage","nextLexeme","possibleFields","f","parseEditDistance","parseBoost","parseInt","isNaN","factory","define","amd","exports","module"],"mappings":"mSAaC,CAAC,UAAU,CAiCZ,GAAIA,CAAAA,CAAI,CAAG,SAAUC,CAAV,CAAkB,CAC3B,GAAIC,CAAAA,CAAO,CAAG,GAAIF,CAAAA,CAAI,CAACG,OAAvB,CAEAD,CAAO,CAACE,QAAR,CAAiBC,GAAjB,CACEL,CAAI,CAACM,OADP,CAEEN,CAAI,CAACO,cAFP,CAGE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AC3P,KAAnD,CAA0D2P,CAAU,CAAC1P,GAArE,CAAN,CAhBJ,CAkBD,CAzCD,CA+CI,UAAUuD,CAAV,CAAgB0M,CAAhB,CAAyB,CACzB,GAAsB,UAAlB,QAAOC,CAAAA,MAAP,EAAgCA,MAAM,CAACC,GAA3C,CAAgD,CAE9CD,OAAM,8BAACD,CAAD,CACP,CAHD,IAGO,IAAuB,QAAnB,uBAAOG,CAAAA,OAAP,qBAAOA,OAAP,EAAJ,CAAiC,CAMtCC,MAAM,CAACD,OAAP,CAAiBH,CAAO,EACzB,CAPM,IAOA,CAEL1M,CAAI,CAAClL,IAAL,CAAY4X,CAAO,EACpB,CACF,CAfC,EAeA,IAfA,CAeM,UAAY,CAMlB,MAAO5X,CAAAA,CACR,CAtBC,CAuBH,CA54GA","sourcesContent":["/**\n * moodle readme\n *\n * Lunrjs can be downloaded from https://github.com/olivernn/lunr.js. To update this library get the lunr.js file\n * from this project and replace the content below with the new content.\n */\n\n/**\n * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9\n * Copyright (C) 2020 Oliver Nightingale\n * @license MIT\n */\n\n;(function(){\n\n/**\n * A convenience function for configuring and constructing\n * a new lunr Index.\n *\n * A lunr.Builder instance is created and the pipeline setup\n * with a trimmer, stop word filter and stemmer.\n *\n * This builder object is yielded to the configuration function\n * that is passed as a parameter, allowing the list of fields\n * and other builder parameters to be customised.\n *\n * All documents _must_ be added within the passed config function.\n *\n * @example\n * var idx = lunr(function () {\n * this.field('title')\n * this.field('body')\n * this.ref('id')\n *\n * documents.forEach(function (doc) {\n * this.add(doc)\n * }, this)\n * })\n *\n * @see {@link lunr.Builder}\n * @see {@link lunr.Pipeline}\n * @see {@link lunr.trimmer}\n * @see {@link lunr.stopWordFilter}\n * @see {@link lunr.stemmer}\n * @namespace {function} lunr\n */\nvar lunr = function (config) {\n var builder = new lunr.Builder\n\n builder.pipeline.add(\n lunr.trimmer,\n lunr.stopWordFilter,\n lunr.stemmer\n )\n\n builder.searchPipeline.add(\n lunr.stemmer\n )\n\n config.call(builder, builder)\n return builder.build()\n}\n\nlunr.version = \"2.3.9\"\n/*!\n * lunr.utils\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A namespace containing utils for the rest of the lunr library\n * @namespace lunr.utils\n */\nlunr.utils = {}\n\n/**\n * Print a warning message to the console.\n *\n * @param {String} message The message to be printed.\n * @memberOf lunr.utils\n * @function\n */\nlunr.utils.warn = (function (global) {\n /* eslint-disable no-console */\n return function (message) {\n if (global.console && console.warn) {\n console.warn(message)\n }\n }\n /* eslint-enable no-console */\n})(this)\n\n/**\n * Convert an object to a string.\n *\n * In the case of `null` and `undefined` the function returns\n * the empty string, in all other cases the result of calling\n * `toString` on the passed object is returned.\n *\n * @param {Any} obj The object to convert to a string.\n * @return {String} string representation of the passed object.\n * @memberOf lunr.utils\n */\nlunr.utils.asString = function (obj) {\n if (obj === void 0 || obj === null) {\n return \"\"\n } else {\n return obj.toString()\n }\n}\n\n/**\n * Clones an object.\n *\n * Will create a copy of an existing object such that any mutations\n * on the copy cannot affect the original.\n *\n * Only shallow objects are supported, passing a nested object to this\n * function will cause a TypeError.\n *\n * Objects with primitives, and arrays of primitives are supported.\n *\n * @param {Object} obj The object to clone.\n * @return {Object} a clone of the passed object.\n * @throws {TypeError} when a nested object is passed.\n * @memberOf Utils\n */\nlunr.utils.clone = function (obj) {\n if (obj === null || obj === undefined) {\n return obj\n }\n\n var clone = Object.create(null),\n keys = Object.keys(obj)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i],\n val = obj[key]\n\n if (Array.isArray(val)) {\n clone[key] = val.slice()\n continue\n }\n\n if (typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean') {\n clone[key] = val\n continue\n }\n\n throw new TypeError(\"clone is not deep and does not support nested objects\")\n }\n\n return clone\n}\nlunr.FieldRef = function (docRef, fieldName, stringValue) {\n this.docRef = docRef\n this.fieldName = fieldName\n this._stringValue = stringValue\n}\n\nlunr.FieldRef.joiner = \"/\"\n\nlunr.FieldRef.fromString = function (s) {\n var n = s.indexOf(lunr.FieldRef.joiner)\n\n if (n === -1) {\n throw \"malformed field ref string\"\n }\n\n var fieldRef = s.slice(0, n),\n docRef = s.slice(n + 1)\n\n return new lunr.FieldRef (docRef, fieldRef, s)\n}\n\nlunr.FieldRef.prototype.toString = function () {\n if (this._stringValue == undefined) {\n this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef\n }\n\n return this._stringValue\n}\n/*!\n * lunr.Set\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A lunr set.\n *\n * @constructor\n */\nlunr.Set = function (elements) {\n this.elements = Object.create(null)\n\n if (elements) {\n this.length = elements.length\n\n for (var i = 0; i < this.length; i++) {\n this.elements[elements[i]] = true\n }\n } else {\n this.length = 0\n }\n}\n\n/**\n * A complete set that contains all elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.complete = {\n intersect: function (other) {\n return other\n },\n\n union: function () {\n return this\n },\n\n contains: function () {\n return true\n }\n}\n\n/**\n * An empty set that contains no elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.empty = {\n intersect: function () {\n return this\n },\n\n union: function (other) {\n return other\n },\n\n contains: function () {\n return false\n }\n}\n\n/**\n * Returns true if this set contains the specified object.\n *\n * @param {object} object - Object whose presence in this set is to be tested.\n * @returns {boolean} - True if this set contains the specified object.\n */\nlunr.Set.prototype.contains = function (object) {\n return !!this.elements[object]\n}\n\n/**\n * Returns a new set containing only the elements that are present in both\n * this set and the specified set.\n *\n * @param {lunr.Set} other - set to intersect with this set.\n * @returns {lunr.Set} a new set that is the intersection of this and the specified set.\n */\n\nlunr.Set.prototype.intersect = function (other) {\n var a, b, elements, intersection = []\n\n if (other === lunr.Set.complete) {\n return this\n }\n\n if (other === lunr.Set.empty) {\n return other\n }\n\n if (this.length < other.length) {\n a = this\n b = other\n } else {\n a = other\n b = this\n }\n\n elements = Object.keys(a.elements)\n\n for (var i = 0; i < elements.length; i++) {\n var element = elements[i]\n if (element in b.elements) {\n intersection.push(element)\n }\n }\n\n return new lunr.Set (intersection)\n}\n\n/**\n * Returns a new set combining the elements of this and the specified set.\n *\n * @param {lunr.Set} other - set to union with this set.\n * @return {lunr.Set} a new set that is the union of this and the specified set.\n */\n\nlunr.Set.prototype.union = function (other) {\n if (other === lunr.Set.complete) {\n return lunr.Set.complete\n }\n\n if (other === lunr.Set.empty) {\n return this\n }\n\n return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements)))\n}\n/**\n * A function to calculate the inverse document frequency for\n * a posting. This is shared between the builder and the index\n *\n * @private\n * @param {object} posting - The posting for a given term\n * @param {number} documentCount - The total number of documents.\n */\nlunr.idf = function (posting, documentCount) {\n var documentsWithTerm = 0\n\n for (var fieldName in posting) {\n if (fieldName == '_index') continue // Ignore the term index, its not a field\n documentsWithTerm += Object.keys(posting[fieldName]).length\n }\n\n var x = (documentCount - documentsWithTerm + 0.5) / (documentsWithTerm + 0.5)\n\n return Math.log(1 + Math.abs(x))\n}\n\n/**\n * A token wraps a string representation of a token\n * as it is passed through the text processing pipeline.\n *\n * @constructor\n * @param {string} [str=''] - The string token being wrapped.\n * @param {object} [metadata={}] - Metadata associated with this token.\n */\nlunr.Token = function (str, metadata) {\n this.str = str || \"\"\n this.metadata = metadata || {}\n}\n\n/**\n * Returns the token string that is being wrapped by this object.\n *\n * @returns {string}\n */\nlunr.Token.prototype.toString = function () {\n return this.str\n}\n\n/**\n * A token update function is used when updating or optionally\n * when cloning a token.\n *\n * @callback lunr.Token~updateFunction\n * @param {string} str - The string representation of the token.\n * @param {Object} metadata - All metadata associated with this token.\n */\n\n/**\n * Applies the given function to the wrapped string token.\n *\n * @example\n * token.update(function (str, metadata) {\n * return str.toUpperCase()\n * })\n *\n * @param {lunr.Token~updateFunction} fn - A function to apply to the token string.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.update = function (fn) {\n this.str = fn(this.str, this.metadata)\n return this\n}\n\n/**\n * Creates a clone of this token. Optionally a function can be\n * applied to the cloned token.\n *\n * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.clone = function (fn) {\n fn = fn || function (s) { return s }\n return new lunr.Token (fn(this.str, this.metadata), this.metadata)\n}\n/*!\n * lunr.tokenizer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A function for splitting a string into tokens ready to be inserted into\n * the search index. Uses `lunr.tokenizer.separator` to split strings, change\n * the value of this property to change how strings are split into tokens.\n *\n * This tokenizer will convert its parameter to a string by calling `toString` and\n * then will split this string on the character in `lunr.tokenizer.separator`.\n * Arrays will have their elements converted to strings and wrapped in a lunr.Token.\n *\n * Optional metadata can be passed to the tokenizer, this metadata will be cloned and\n * added as metadata to every token that is created from the object to be tokenized.\n *\n * @static\n * @param {?(string|object|object[])} obj - The object to convert into tokens\n * @param {?object} metadata - Optional metadata to associate with every token\n * @returns {lunr.Token[]}\n * @see {@link lunr.Pipeline}\n */\nlunr.tokenizer = function (obj, metadata) {\n if (obj == null || obj == undefined) {\n return []\n }\n\n if (Array.isArray(obj)) {\n return obj.map(function (t) {\n return new lunr.Token(\n lunr.utils.asString(t).toLowerCase(),\n lunr.utils.clone(metadata)\n )\n })\n }\n\n var str = obj.toString().toLowerCase(),\n len = str.length,\n tokens = []\n\n for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) {\n var char = str.charAt(sliceEnd),\n sliceLength = sliceEnd - sliceStart\n\n if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) {\n\n if (sliceLength > 0) {\n var tokenMetadata = lunr.utils.clone(metadata) || {}\n tokenMetadata[\"position\"] = [sliceStart, sliceLength]\n tokenMetadata[\"index\"] = tokens.length\n\n tokens.push(\n new lunr.Token (\n str.slice(sliceStart, sliceEnd),\n tokenMetadata\n )\n )\n }\n\n sliceStart = sliceEnd + 1\n }\n\n }\n\n return tokens\n}\n\n/**\n * The separator used to split a string into tokens. Override this property to change the behaviour of\n * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens.\n *\n * @static\n * @see lunr.tokenizer\n */\nlunr.tokenizer.separator = /[\\s\\-]+/\n/*!\n * lunr.Pipeline\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Pipelines maintain an ordered list of functions to be applied to all\n * tokens in documents entering the search index and queries being ran against\n * the index.\n *\n * An instance of lunr.Index created with the lunr shortcut will contain a\n * pipeline with a stop word filter and an English language stemmer. Extra\n * functions can be added before or after either of these functions or these\n * default functions can be removed.\n *\n * When run the pipeline will call each function in turn, passing a token, the\n * index of that token in the original list of all tokens and finally a list of\n * all the original tokens.\n *\n * The output of functions in the pipeline will be passed to the next function\n * in the pipeline. To exclude a token from entering the index the function\n * should return undefined, the rest of the pipeline will not be called with\n * this token.\n *\n * For serialisation of pipelines to work, all functions used in an instance of\n * a pipeline should be registered with lunr.Pipeline. Registered functions can\n * then be loaded. If trying to load a serialised pipeline that uses functions\n * that are not registered an error will be thrown.\n *\n * If not planning on serialising the pipeline then registering pipeline functions\n * is not necessary.\n *\n * @constructor\n */\nlunr.Pipeline = function () {\n this._stack = []\n}\n\nlunr.Pipeline.registeredFunctions = Object.create(null)\n\n/**\n * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token\n * string as well as all known metadata. A pipeline function can mutate the token string\n * or mutate (or add) metadata for a given token.\n *\n * A pipeline function can indicate that the passed token should be discarded by returning\n * null, undefined or an empty string. This token will not be passed to any downstream pipeline\n * functions and will not be added to the index.\n *\n * Multiple tokens can be returned by returning an array of tokens. Each token will be passed\n * to any downstream pipeline functions and all will returned tokens will be added to the index.\n *\n * Any number of pipeline functions may be chained together using a lunr.Pipeline.\n *\n * @interface lunr.PipelineFunction\n * @param {lunr.Token} token - A token from the document being processed.\n * @param {number} i - The index of this token in the complete list of tokens for this document/field.\n * @param {lunr.Token[]} tokens - All tokens for this document/field.\n * @returns {(?lunr.Token|lunr.Token[])}\n */\n\n/**\n * Register a function with the pipeline.\n *\n * Functions that are used in the pipeline should be registered if the pipeline\n * needs to be serialised, or a serialised pipeline needs to be loaded.\n *\n * Registering a function does not add it to a pipeline, functions must still be\n * added to instances of the pipeline for them to be used when running a pipeline.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @param {String} label - The label to register this function with\n */\nlunr.Pipeline.registerFunction = function (fn, label) {\n if (label in this.registeredFunctions) {\n lunr.utils.warn('Overwriting existing registered function: ' + label)\n }\n\n fn.label = label\n lunr.Pipeline.registeredFunctions[fn.label] = fn\n}\n\n/**\n * Warns if the function is not registered as a Pipeline function.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @private\n */\nlunr.Pipeline.warnIfFunctionNotRegistered = function (fn) {\n var isRegistered = fn.label && (fn.label in this.registeredFunctions)\n\n if (!isRegistered) {\n lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\\n', fn)\n }\n}\n\n/**\n * Loads a previously serialised pipeline.\n *\n * All functions to be loaded must already be registered with lunr.Pipeline.\n * If any function from the serialised data has not been registered then an\n * error will be thrown.\n *\n * @param {Object} serialised - The serialised pipeline to load.\n * @returns {lunr.Pipeline}\n */\nlunr.Pipeline.load = function (serialised) {\n var pipeline = new lunr.Pipeline\n\n serialised.forEach(function (fnName) {\n var fn = lunr.Pipeline.registeredFunctions[fnName]\n\n if (fn) {\n pipeline.add(fn)\n } else {\n throw new Error('Cannot load unregistered function: ' + fnName)\n }\n })\n\n return pipeline\n}\n\n/**\n * Adds new functions to the end of the pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline.\n */\nlunr.Pipeline.prototype.add = function () {\n var fns = Array.prototype.slice.call(arguments)\n\n fns.forEach(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n this._stack.push(fn)\n }, this)\n}\n\n/**\n * Adds a single function after a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.after = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n pos = pos + 1\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Adds a single function before a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.before = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Removes a function from the pipeline.\n *\n * @param {lunr.PipelineFunction} fn The function to remove from the pipeline.\n */\nlunr.Pipeline.prototype.remove = function (fn) {\n var pos = this._stack.indexOf(fn)\n if (pos == -1) {\n return\n }\n\n this._stack.splice(pos, 1)\n}\n\n/**\n * Runs the current list of functions that make up the pipeline against the\n * passed tokens.\n *\n * @param {Array} tokens The tokens to run through the pipeline.\n * @returns {Array}\n */\nlunr.Pipeline.prototype.run = function (tokens) {\n var stackLength = this._stack.length\n\n for (var i = 0; i < stackLength; i++) {\n var fn = this._stack[i]\n var memo = []\n\n for (var j = 0; j < tokens.length; j++) {\n var result = fn(tokens[j], j, tokens)\n\n if (result === null || result === void 0 || result === '') continue\n\n if (Array.isArray(result)) {\n for (var k = 0; k < result.length; k++) {\n memo.push(result[k])\n }\n } else {\n memo.push(result)\n }\n }\n\n tokens = memo\n }\n\n return tokens\n}\n\n/**\n * Convenience method for passing a string through a pipeline and getting\n * strings out. This method takes care of wrapping the passed string in a\n * token and mapping the resulting tokens back to strings.\n *\n * @param {string} str - The string to pass through the pipeline.\n * @param {?object} metadata - Optional metadata to associate with the token\n * passed to the pipeline.\n * @returns {string[]}\n */\nlunr.Pipeline.prototype.runString = function (str, metadata) {\n var token = new lunr.Token (str, metadata)\n\n return this.run([token]).map(function (t) {\n return t.toString()\n })\n}\n\n/**\n * Resets the pipeline by removing any existing processors.\n *\n */\nlunr.Pipeline.prototype.reset = function () {\n this._stack = []\n}\n\n/**\n * Returns a representation of the pipeline ready for serialisation.\n *\n * Logs a warning if the function has not been registered.\n *\n * @returns {Array}\n */\nlunr.Pipeline.prototype.toJSON = function () {\n return this._stack.map(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n\n return fn.label\n })\n}\n/*!\n * lunr.Vector\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A vector is used to construct the vector space of documents and queries. These\n * vectors support operations to determine the similarity between two documents or\n * a document and a query.\n *\n * Normally no parameters are required for initializing a vector, but in the case of\n * loading a previously dumped vector the raw elements can be provided to the constructor.\n *\n * For performance reasons vectors are implemented with a flat array, where an elements\n * index is immediately followed by its value. E.g. [index, value, index, value]. This\n * allows the underlying array to be as sparse as possible and still offer decent\n * performance when being used for vector calculations.\n *\n * @constructor\n * @param {Number[]} [elements] - The flat list of element index and element value pairs.\n */\nlunr.Vector = function (elements) {\n this._magnitude = 0\n this.elements = elements || []\n}\n\n\n/**\n * Calculates the position within the vector to insert a given index.\n *\n * This is used internally by insert and upsert. If there are duplicate indexes then\n * the position is returned as if the value for that index were to be updated, but it\n * is the callers responsibility to check whether there is a duplicate at that index\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @returns {Number}\n */\nlunr.Vector.prototype.positionForIndex = function (index) {\n // For an empty vector the tuple can be inserted at the beginning\n if (this.elements.length == 0) {\n return 0\n }\n\n var start = 0,\n end = this.elements.length / 2,\n sliceLength = end - start,\n pivotPoint = Math.floor(sliceLength / 2),\n pivotIndex = this.elements[pivotPoint * 2]\n\n while (sliceLength > 1) {\n if (pivotIndex < index) {\n start = pivotPoint\n }\n\n if (pivotIndex > index) {\n end = pivotPoint\n }\n\n if (pivotIndex == index) {\n break\n }\n\n sliceLength = end - start\n pivotPoint = start + Math.floor(sliceLength / 2)\n pivotIndex = this.elements[pivotPoint * 2]\n }\n\n if (pivotIndex == index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex > index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex < index) {\n return (pivotPoint + 1) * 2\n }\n}\n\n/**\n * Inserts an element at an index within the vector.\n *\n * Does not allow duplicates, will throw an error if there is already an entry\n * for this index.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n */\nlunr.Vector.prototype.insert = function (insertIdx, val) {\n this.upsert(insertIdx, val, function () {\n throw \"duplicate index\"\n })\n}\n\n/**\n * Inserts or updates an existing index within the vector.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n * @param {function} fn - A function that is called for updates, the existing value and the\n * requested value are passed as arguments\n */\nlunr.Vector.prototype.upsert = function (insertIdx, val, fn) {\n this._magnitude = 0\n var position = this.positionForIndex(insertIdx)\n\n if (this.elements[position] == insertIdx) {\n this.elements[position + 1] = fn(this.elements[position + 1], val)\n } else {\n this.elements.splice(position, 0, insertIdx, val)\n }\n}\n\n/**\n * Calculates the magnitude of this vector.\n *\n * @returns {Number}\n */\nlunr.Vector.prototype.magnitude = function () {\n if (this._magnitude) return this._magnitude\n\n var sumOfSquares = 0,\n elementsLength = this.elements.length\n\n for (var i = 1; i < elementsLength; i += 2) {\n var val = this.elements[i]\n sumOfSquares += val * val\n }\n\n return this._magnitude = Math.sqrt(sumOfSquares)\n}\n\n/**\n * Calculates the dot product of this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The vector to compute the dot product with.\n * @returns {Number}\n */\nlunr.Vector.prototype.dot = function (otherVector) {\n var dotProduct = 0,\n a = this.elements, b = otherVector.elements,\n aLen = a.length, bLen = b.length,\n aVal = 0, bVal = 0,\n i = 0, j = 0\n\n while (i < aLen && j < bLen) {\n aVal = a[i], bVal = b[j]\n if (aVal < bVal) {\n i += 2\n } else if (aVal > bVal) {\n j += 2\n } else if (aVal == bVal) {\n dotProduct += a[i + 1] * b[j + 1]\n i += 2\n j += 2\n }\n }\n\n return dotProduct\n}\n\n/**\n * Calculates the similarity between this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The other vector to calculate the\n * similarity with.\n * @returns {Number}\n */\nlunr.Vector.prototype.similarity = function (otherVector) {\n return this.dot(otherVector) / this.magnitude() || 0\n}\n\n/**\n * Converts the vector to an array of the elements within the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toArray = function () {\n var output = new Array (this.elements.length / 2)\n\n for (var i = 1, j = 0; i < this.elements.length; i += 2, j++) {\n output[j] = this.elements[i]\n }\n\n return output\n}\n\n/**\n * A JSON serializable representation of the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toJSON = function () {\n return this.elements\n}\n/* eslint-disable */\n/*!\n * lunr.stemmer\n * Copyright (C) 2020 Oliver Nightingale\n * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt\n */\n\n/**\n * lunr.stemmer is an english language stemmer, this is a JavaScript\n * implementation of the PorterStemmer taken from http://tartarus.org/~martin\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token - The string to stem\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n * @function\n */\nlunr.stemmer = (function(){\n var step2list = {\n \"ational\" : \"ate\",\n \"tional\" : \"tion\",\n \"enci\" : \"ence\",\n \"anci\" : \"ance\",\n \"izer\" : \"ize\",\n \"bli\" : \"ble\",\n \"alli\" : \"al\",\n \"entli\" : \"ent\",\n \"eli\" : \"e\",\n \"ousli\" : \"ous\",\n \"ization\" : \"ize\",\n \"ation\" : \"ate\",\n \"ator\" : \"ate\",\n \"alism\" : \"al\",\n \"iveness\" : \"ive\",\n \"fulness\" : \"ful\",\n \"ousness\" : \"ous\",\n \"aliti\" : \"al\",\n \"iviti\" : \"ive\",\n \"biliti\" : \"ble\",\n \"logi\" : \"log\"\n },\n\n step3list = {\n \"icate\" : \"ic\",\n \"ative\" : \"\",\n \"alize\" : \"al\",\n \"iciti\" : \"ic\",\n \"ical\" : \"ic\",\n \"ful\" : \"\",\n \"ness\" : \"\"\n },\n\n c = \"[^aeiou]\", // consonant\n v = \"[aeiouy]\", // vowel\n C = c + \"[^aeiouy]*\", // consonant sequence\n V = v + \"[aeiou]*\", // vowel sequence\n\n mgr0 = \"^(\" + C + \")?\" + V + C, // [C]VC... is m>0\n meq1 = \"^(\" + C + \")?\" + V + C + \"(\" + V + \")?$\", // [C]VC[V] is m=1\n mgr1 = \"^(\" + C + \")?\" + V + C + V + C, // [C]VCVC... is m>1\n s_v = \"^(\" + C + \")?\" + v; // vowel in stem\n\n var re_mgr0 = new RegExp(mgr0);\n var re_mgr1 = new RegExp(mgr1);\n var re_meq1 = new RegExp(meq1);\n var re_s_v = new RegExp(s_v);\n\n var re_1a = /^(.+?)(ss|i)es$/;\n var re2_1a = /^(.+?)([^s])s$/;\n var re_1b = /^(.+?)eed$/;\n var re2_1b = /^(.+?)(ed|ing)$/;\n var re_1b_2 = /.$/;\n var re2_1b_2 = /(at|bl|iz)$/;\n var re3_1b_2 = new RegExp(\"([^aeiouylsz])\\\\1$\");\n var re4_1b_2 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var re_1c = /^(.+?[^aeiou])y$/;\n var re_2 = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;\n\n var re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;\n\n var re_4 = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;\n var re2_4 = /^(.+?)(s|t)(ion)$/;\n\n var re_5 = /^(.+?)e$/;\n var re_5_1 = /ll$/;\n var re3_5 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var porterStemmer = function porterStemmer(w) {\n var stem,\n suffix,\n firstch,\n re,\n re2,\n re3,\n re4;\n\n if (w.length < 3) { return w; }\n\n firstch = w.substr(0,1);\n if (firstch == \"y\") {\n w = firstch.toUpperCase() + w.substr(1);\n }\n\n // Step 1a\n re = re_1a\n re2 = re2_1a;\n\n if (re.test(w)) { w = w.replace(re,\"$1$2\"); }\n else if (re2.test(w)) { w = w.replace(re2,\"$1$2\"); }\n\n // Step 1b\n re = re_1b;\n re2 = re2_1b;\n if (re.test(w)) {\n var fp = re.exec(w);\n re = re_mgr0;\n if (re.test(fp[1])) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1];\n re2 = re_s_v;\n if (re2.test(stem)) {\n w = stem;\n re2 = re2_1b_2;\n re3 = re3_1b_2;\n re4 = re4_1b_2;\n if (re2.test(w)) { w = w + \"e\"; }\n else if (re3.test(w)) { re = re_1b_2; w = w.replace(re,\"\"); }\n else if (re4.test(w)) { w = w + \"e\"; }\n }\n }\n\n // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)\n re = re_1c;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n w = stem + \"i\";\n }\n\n // Step 2\n re = re_2;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step2list[suffix];\n }\n }\n\n // Step 3\n re = re_3;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step3list[suffix];\n }\n }\n\n // Step 4\n re = re_4;\n re2 = re2_4;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n if (re.test(stem)) {\n w = stem;\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1] + fp[2];\n re2 = re_mgr1;\n if (re2.test(stem)) {\n w = stem;\n }\n }\n\n // Step 5\n re = re_5;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n re2 = re_meq1;\n re3 = re3_5;\n if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) {\n w = stem;\n }\n }\n\n re = re_5_1;\n re2 = re_mgr1;\n if (re.test(w) && re2.test(w)) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n\n // and turn initial Y back to y\n\n if (firstch == \"y\") {\n w = firstch.toLowerCase() + w.substr(1);\n }\n\n return w;\n };\n\n return function (token) {\n return token.update(porterStemmer);\n }\n})();\n\nlunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')\n/*!\n * lunr.stopWordFilter\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.generateStopWordFilter builds a stopWordFilter function from the provided\n * list of stop words.\n *\n * The built in lunr.stopWordFilter is built using this generator and can be used\n * to generate custom stopWordFilters for applications or non English languages.\n *\n * @function\n * @param {Array} token The token to pass through the filter\n * @returns {lunr.PipelineFunction}\n * @see lunr.Pipeline\n * @see lunr.stopWordFilter\n */\nlunr.generateStopWordFilter = function (stopWords) {\n var words = stopWords.reduce(function (memo, stopWord) {\n memo[stopWord] = stopWord\n return memo\n }, {})\n\n return function (token) {\n if (token && words[token.toString()] !== token.toString()) return token\n }\n}\n\n/**\n * lunr.stopWordFilter is an English language stop word list filter, any words\n * contained in the list will not be passed through the filter.\n *\n * This is intended to be used in the Pipeline. If the token does not pass the\n * filter then undefined will be returned.\n *\n * @function\n * @implements {lunr.PipelineFunction}\n * @params {lunr.Token} token - A token to check for being a stop word.\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n */\nlunr.stopWordFilter = lunr.generateStopWordFilter([\n 'a',\n 'able',\n 'about',\n 'across',\n 'after',\n 'all',\n 'almost',\n 'also',\n 'am',\n 'among',\n 'an',\n 'and',\n 'any',\n 'are',\n 'as',\n 'at',\n 'be',\n 'because',\n 'been',\n 'but',\n 'by',\n 'can',\n 'cannot',\n 'could',\n 'dear',\n 'did',\n 'do',\n 'does',\n 'either',\n 'else',\n 'ever',\n 'every',\n 'for',\n 'from',\n 'get',\n 'got',\n 'had',\n 'has',\n 'have',\n 'he',\n 'her',\n 'hers',\n 'him',\n 'his',\n 'how',\n 'however',\n 'i',\n 'if',\n 'in',\n 'into',\n 'is',\n 'it',\n 'its',\n 'just',\n 'least',\n 'let',\n 'like',\n 'likely',\n 'may',\n 'me',\n 'might',\n 'most',\n 'must',\n 'my',\n 'neither',\n 'no',\n 'nor',\n 'not',\n 'of',\n 'off',\n 'often',\n 'on',\n 'only',\n 'or',\n 'other',\n 'our',\n 'own',\n 'rather',\n 'said',\n 'say',\n 'says',\n 'she',\n 'should',\n 'since',\n 'so',\n 'some',\n 'than',\n 'that',\n 'the',\n 'their',\n 'them',\n 'then',\n 'there',\n 'these',\n 'they',\n 'this',\n 'tis',\n 'to',\n 'too',\n 'twas',\n 'us',\n 'wants',\n 'was',\n 'we',\n 'were',\n 'what',\n 'when',\n 'where',\n 'which',\n 'while',\n 'who',\n 'whom',\n 'why',\n 'will',\n 'with',\n 'would',\n 'yet',\n 'you',\n 'your'\n])\n\nlunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')\n/*!\n * lunr.trimmer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.trimmer is a pipeline function for trimming non word\n * characters from the beginning and end of tokens before they\n * enter the index.\n *\n * This implementation may not work correctly for non latin\n * characters and should either be removed or adapted for use\n * with languages with non-latin characters.\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token The token to pass through the filter\n * @returns {lunr.Token}\n * @see lunr.Pipeline\n */\nlunr.trimmer = function (token) {\n return token.update(function (s) {\n return s.replace(/^\\W+/, '').replace(/\\W+$/, '')\n })\n}\n\nlunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')\n/*!\n * lunr.TokenSet\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A token set is used to store the unique list of all tokens\n * within an index. Token sets are also used to represent an\n * incoming query to the index, this query token set and index\n * token set are then intersected to find which tokens to look\n * up in the inverted index.\n *\n * A token set can hold multiple tokens, as in the case of the\n * index token set, or it can hold a single token as in the\n * case of a simple query token set.\n *\n * Additionally token sets are used to perform wildcard matching.\n * Leading, contained and trailing wildcards are supported, and\n * from this edit distance matching can also be provided.\n *\n * Token sets are implemented as a minimal finite state automata,\n * where both common prefixes and suffixes are shared between tokens.\n * This helps to reduce the space used for storing the token set.\n *\n * @constructor\n */\nlunr.TokenSet = function () {\n this.final = false\n this.edges = {}\n this.id = lunr.TokenSet._nextId\n lunr.TokenSet._nextId += 1\n}\n\n/**\n * Keeps track of the next, auto increment, identifier to assign\n * to a new tokenSet.\n *\n * TokenSets require a unique identifier to be correctly minimised.\n *\n * @private\n */\nlunr.TokenSet._nextId = 1\n\n/**\n * Creates a TokenSet instance from the given sorted array of words.\n *\n * @param {String[]} arr - A sorted array of strings to create the set from.\n * @returns {lunr.TokenSet}\n * @throws Will throw an error if the input array is not sorted.\n */\nlunr.TokenSet.fromArray = function (arr) {\n var builder = new lunr.TokenSet.Builder\n\n for (var i = 0, len = arr.length; i < len; i++) {\n builder.insert(arr[i])\n }\n\n builder.finish()\n return builder.root\n}\n\n/**\n * Creates a token set from a query clause.\n *\n * @private\n * @param {Object} clause - A single clause from lunr.Query.\n * @param {string} clause.term - The query clause term.\n * @param {number} [clause.editDistance] - The optional edit distance for the term.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromClause = function (clause) {\n if ('editDistance' in clause) {\n return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance)\n } else {\n return lunr.TokenSet.fromString(clause.term)\n }\n}\n\n/**\n * Creates a token set representing a single string with a specified\n * edit distance.\n *\n * Insertions, deletions, substitutions and transpositions are each\n * treated as an edit distance of 1.\n *\n * Increasing the allowed edit distance will have a dramatic impact\n * on the performance of both creating and intersecting these TokenSets.\n * It is advised to keep the edit distance less than 3.\n *\n * @param {string} str - The string to create the token set from.\n * @param {number} editDistance - The allowed edit distance to match.\n * @returns {lunr.Vector}\n */\nlunr.TokenSet.fromFuzzyString = function (str, editDistance) {\n var root = new lunr.TokenSet\n\n var stack = [{\n node: root,\n editsRemaining: editDistance,\n str: str\n }]\n\n while (stack.length) {\n var frame = stack.pop()\n\n // no edit\n if (frame.str.length > 0) {\n var char = frame.str.charAt(0),\n noEditNode\n\n if (char in frame.node.edges) {\n noEditNode = frame.node.edges[char]\n } else {\n noEditNode = new lunr.TokenSet\n frame.node.edges[char] = noEditNode\n }\n\n if (frame.str.length == 1) {\n noEditNode.final = true\n }\n\n stack.push({\n node: noEditNode,\n editsRemaining: frame.editsRemaining,\n str: frame.str.slice(1)\n })\n }\n\n if (frame.editsRemaining == 0) {\n continue\n }\n\n // insertion\n if (\"*\" in frame.node.edges) {\n var insertionNode = frame.node.edges[\"*\"]\n } else {\n var insertionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = insertionNode\n }\n\n if (frame.str.length == 0) {\n insertionNode.final = true\n }\n\n stack.push({\n node: insertionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str\n })\n\n // deletion\n // can only do a deletion if we have enough edits remaining\n // and if there are characters left to delete in the string\n if (frame.str.length > 1) {\n stack.push({\n node: frame.node,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // deletion\n // just removing the last character from the str\n if (frame.str.length == 1) {\n frame.node.final = true\n }\n\n // substitution\n // can only do a substitution if we have enough edits remaining\n // and if there are characters left to substitute\n if (frame.str.length >= 1) {\n if (\"*\" in frame.node.edges) {\n var substitutionNode = frame.node.edges[\"*\"]\n } else {\n var substitutionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = substitutionNode\n }\n\n if (frame.str.length == 1) {\n substitutionNode.final = true\n }\n\n stack.push({\n node: substitutionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // transposition\n // can only do a transposition if there are edits remaining\n // and there are enough characters to transpose\n if (frame.str.length > 1) {\n var charA = frame.str.charAt(0),\n charB = frame.str.charAt(1),\n transposeNode\n\n if (charB in frame.node.edges) {\n transposeNode = frame.node.edges[charB]\n } else {\n transposeNode = new lunr.TokenSet\n frame.node.edges[charB] = transposeNode\n }\n\n if (frame.str.length == 1) {\n transposeNode.final = true\n }\n\n stack.push({\n node: transposeNode,\n editsRemaining: frame.editsRemaining - 1,\n str: charA + frame.str.slice(2)\n })\n }\n }\n\n return root\n}\n\n/**\n * Creates a TokenSet from a string.\n *\n * The string may contain one or more wildcard characters (*)\n * that will allow wildcard matching when intersecting with\n * another TokenSet.\n *\n * @param {string} str - The string to create a TokenSet from.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromString = function (str) {\n var node = new lunr.TokenSet,\n root = node\n\n /*\n * Iterates through all characters within the passed string\n * appending a node for each character.\n *\n * When a wildcard character is found then a self\n * referencing edge is introduced to continually match\n * any number of any characters.\n */\n for (var i = 0, len = str.length; i < len; i++) {\n var char = str[i],\n final = (i == len - 1)\n\n if (char == \"*\") {\n node.edges[char] = node\n node.final = final\n\n } else {\n var next = new lunr.TokenSet\n next.final = final\n\n node.edges[char] = next\n node = next\n }\n }\n\n return root\n}\n\n/**\n * Converts this TokenSet into an array of strings\n * contained within the TokenSet.\n *\n * This is not intended to be used on a TokenSet that\n * contains wildcards, in these cases the results are\n * undefined and are likely to cause an infinite loop.\n *\n * @returns {string[]}\n */\nlunr.TokenSet.prototype.toArray = function () {\n var words = []\n\n var stack = [{\n prefix: \"\",\n node: this\n }]\n\n while (stack.length) {\n var frame = stack.pop(),\n edges = Object.keys(frame.node.edges),\n len = edges.length\n\n if (frame.node.final) {\n /* In Safari, at this point the prefix is sometimes corrupted, see:\n * https://github.com/olivernn/lunr.js/issues/279 Calling any\n * String.prototype method forces Safari to \"cast\" this string to what\n * it's supposed to be, fixing the bug. */\n frame.prefix.charAt(0)\n words.push(frame.prefix)\n }\n\n for (var i = 0; i < len; i++) {\n var edge = edges[i]\n\n stack.push({\n prefix: frame.prefix.concat(edge),\n node: frame.node.edges[edge]\n })\n }\n }\n\n return words\n}\n\n/**\n * Generates a string representation of a TokenSet.\n *\n * This is intended to allow TokenSets to be used as keys\n * in objects, largely to aid the construction and minimisation\n * of a TokenSet. As such it is not designed to be a human\n * friendly representation of the TokenSet.\n *\n * @returns {string}\n */\nlunr.TokenSet.prototype.toString = function () {\n // NOTE: Using Object.keys here as this.edges is very likely\n // to enter 'hash-mode' with many keys being added\n //\n // avoiding a for-in loop here as it leads to the function\n // being de-optimised (at least in V8). From some simple\n // benchmarks the performance is comparable, but allowing\n // V8 to optimize may mean easy performance wins in the future.\n\n if (this._str) {\n return this._str\n }\n\n var str = this.final ? '1' : '0',\n labels = Object.keys(this.edges).sort(),\n len = labels.length\n\n for (var i = 0; i < len; i++) {\n var label = labels[i],\n node = this.edges[label]\n\n str = str + label + node.id\n }\n\n return str\n}\n\n/**\n * Returns a new TokenSet that is the intersection of\n * this TokenSet and the passed TokenSet.\n *\n * This intersection will take into account any wildcards\n * contained within the TokenSet.\n *\n * @param {lunr.TokenSet} b - An other TokenSet to intersect with.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.prototype.intersect = function (b) {\n var output = new lunr.TokenSet,\n frame = undefined\n\n var stack = [{\n qNode: b,\n output: output,\n node: this\n }]\n\n while (stack.length) {\n frame = stack.pop()\n\n // NOTE: As with the #toString method, we are using\n // Object.keys and a for loop instead of a for-in loop\n // as both of these objects enter 'hash' mode, causing\n // the function to be de-optimised in V8\n var qEdges = Object.keys(frame.qNode.edges),\n qLen = qEdges.length,\n nEdges = Object.keys(frame.node.edges),\n nLen = nEdges.length\n\n for (var q = 0; q < qLen; q++) {\n var qEdge = qEdges[q]\n\n for (var n = 0; n < nLen; n++) {\n var nEdge = nEdges[n]\n\n if (nEdge == qEdge || qEdge == '*') {\n var node = frame.node.edges[nEdge],\n qNode = frame.qNode.edges[qEdge],\n final = node.final && qNode.final,\n next = undefined\n\n if (nEdge in frame.output.edges) {\n // an edge already exists for this character\n // no need to create a new node, just set the finality\n // bit unless this node is already final\n next = frame.output.edges[nEdge]\n next.final = next.final || final\n\n } else {\n // no edge exists yet, must create one\n // set the finality bit and insert it\n // into the output\n next = new lunr.TokenSet\n next.final = final\n frame.output.edges[nEdge] = next\n }\n\n stack.push({\n qNode: qNode,\n output: next,\n node: node\n })\n }\n }\n }\n }\n\n return output\n}\nlunr.TokenSet.Builder = function () {\n this.previousWord = \"\"\n this.root = new lunr.TokenSet\n this.uncheckedNodes = []\n this.minimizedNodes = {}\n}\n\nlunr.TokenSet.Builder.prototype.insert = function (word) {\n var node,\n commonPrefix = 0\n\n if (word < this.previousWord) {\n throw new Error (\"Out of order word insertion\")\n }\n\n for (var i = 0; i < word.length && i < this.previousWord.length; i++) {\n if (word[i] != this.previousWord[i]) break\n commonPrefix++\n }\n\n this.minimize(commonPrefix)\n\n if (this.uncheckedNodes.length == 0) {\n node = this.root\n } else {\n node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child\n }\n\n for (var i = commonPrefix; i < word.length; i++) {\n var nextNode = new lunr.TokenSet,\n char = word[i]\n\n node.edges[char] = nextNode\n\n this.uncheckedNodes.push({\n parent: node,\n char: char,\n child: nextNode\n })\n\n node = nextNode\n }\n\n node.final = true\n this.previousWord = word\n}\n\nlunr.TokenSet.Builder.prototype.finish = function () {\n this.minimize(0)\n}\n\nlunr.TokenSet.Builder.prototype.minimize = function (downTo) {\n for (var i = this.uncheckedNodes.length - 1; i >= downTo; i--) {\n var node = this.uncheckedNodes[i],\n childKey = node.child.toString()\n\n if (childKey in this.minimizedNodes) {\n node.parent.edges[node.char] = this.minimizedNodes[childKey]\n } else {\n // Cache the key for this node since\n // we know it can't change anymore\n node.child._str = childKey\n\n this.minimizedNodes[childKey] = node.child\n }\n\n this.uncheckedNodes.pop()\n }\n}\n/*!\n * lunr.Index\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * An index contains the built index of all documents and provides a query interface\n * to the index.\n *\n * Usually instances of lunr.Index will not be created using this constructor, instead\n * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be\n * used to load previously built and serialized indexes.\n *\n * @constructor\n * @param {Object} attrs - The attributes of the built search index.\n * @param {Object} attrs.invertedIndex - An index of term/field to document reference.\n * @param {Object} attrs.fieldVectors - Field vectors\n * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens.\n * @param {string[]} attrs.fields - The names of indexed document fields.\n * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms.\n */\nlunr.Index = function (attrs) {\n this.invertedIndex = attrs.invertedIndex\n this.fieldVectors = attrs.fieldVectors\n this.tokenSet = attrs.tokenSet\n this.fields = attrs.fields\n this.pipeline = attrs.pipeline\n}\n\n/**\n * A result contains details of a document matching a search query.\n * @typedef {Object} lunr.Index~Result\n * @property {string} ref - The reference of the document this result represents.\n * @property {number} score - A number between 0 and 1 representing how similar this document is to the query.\n * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match.\n */\n\n/**\n * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple\n * query language which itself is parsed into an instance of lunr.Query.\n *\n * For programmatically building queries it is advised to directly use lunr.Query, the query language\n * is best used for human entered text rather than program generated text.\n *\n * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported\n * and will be combined with OR, e.g `hello world` will match documents that contain either 'hello'\n * or 'world', though those that contain both will rank higher in the results.\n *\n * Wildcards can be included in terms to match one or more unspecified characters, these wildcards can\n * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding\n * wildcards will increase the number of documents that will be found but can also have a negative\n * impact on query performance, especially with wildcards at the beginning of a term.\n *\n * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term\n * hello in the title field will match this query. Using a field not present in the index will lead\n * to an error being thrown.\n *\n * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term\n * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported\n * to provide fuzzy matching, e.g. 'hello~2' will match documents with hello with an edit distance of 2.\n * Avoid large values for edit distance to improve query performance.\n *\n * Each term also supports a presence modifier. By default a term's presence in document is optional, however\n * this can be changed to either required or prohibited. For a term's presence to be required in a document the\n * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and\n * optionally contain 'bar'. Conversely a leading '-' sets the terms presence to prohibited, i.e. it must not\n * appear in a document, e.g. `-foo bar` is a search for documents that do not contain 'foo' but may contain 'bar'.\n *\n * To escape special characters the backslash character '\\' can be used, this allows searches to include\n * characters that would normally be considered modifiers, e.g. `foo\\~2` will search for a term \"foo~2\" instead\n * of attempting to apply a boost of 2 to the search term \"foo\".\n *\n * @typedef {string} lunr.Index~QueryString\n * @example Simple single term query\n * hello\n * @example Multiple term query\n * hello world\n * @example term scoped to a field\n * title:hello\n * @example term with a boost of 10\n * hello^10\n * @example term with an edit distance of 2\n * hello~2\n * @example terms with presence modifiers\n * -foo +bar baz\n */\n\n/**\n * Performs a search against the index using lunr query syntax.\n *\n * Results will be returned sorted by their score, the most relevant results\n * will be returned first. For details on how the score is calculated, please see\n * the {@link https://lunrjs.com/guides/searching.html#scoring|guide}.\n *\n * For more programmatic querying use lunr.Index#query.\n *\n * @param {lunr.Index~QueryString} queryString - A string containing a lunr query.\n * @throws {lunr.QueryParseError} If the passed query string cannot be parsed.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.search = function (queryString) {\n return this.query(function (query) {\n var parser = new lunr.QueryParser(queryString, query)\n parser.parse()\n })\n}\n\n/**\n * A query builder callback provides a query object to be used to express\n * the query to perform on the index.\n *\n * @callback lunr.Index~queryBuilder\n * @param {lunr.Query} query - The query object to build up.\n * @this lunr.Query\n */\n\n/**\n * Performs a query against the index using the yielded lunr.Query object.\n *\n * If performing programmatic queries against the index, this method is preferred\n * over lunr.Index#search so as to avoid the additional query parsing overhead.\n *\n * A query object is yielded to the supplied function which should be used to\n * express the query to be run against the index.\n *\n * Note that although this function takes a callback parameter it is _not_ an\n * asynchronous operation, the callback is just yielded a query object to be\n * customized.\n *\n * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.query = function (fn) {\n // for each query clause\n // * process terms\n // * expand terms from token set\n // * find matching documents and metadata\n // * get document vectors\n // * score documents\n\n var query = new lunr.Query(this.fields),\n matchingFields = Object.create(null),\n queryVectors = Object.create(null),\n termFieldCache = Object.create(null),\n requiredMatches = Object.create(null),\n prohibitedMatches = Object.create(null)\n\n /*\n * To support field level boosts a query vector is created per\n * field. An empty vector is eagerly created to support negated\n * queries.\n */\n for (var i = 0; i < this.fields.length; i++) {\n queryVectors[this.fields[i]] = new lunr.Vector\n }\n\n fn.call(query, query)\n\n for (var i = 0; i < query.clauses.length; i++) {\n /*\n * Unless the pipeline has been disabled for this term, which is\n * the case for terms with wildcards, we need to pass the clause\n * term through the search pipeline. A pipeline returns an array\n * of processed terms. Pipeline functions may expand the passed\n * term, which means we may end up performing multiple index lookups\n * for a single query term.\n */\n var clause = query.clauses[i],\n terms = null,\n clauseMatches = lunr.Set.empty\n\n if (clause.usePipeline) {\n terms = this.pipeline.runString(clause.term, {\n fields: clause.fields\n })\n } else {\n terms = [clause.term]\n }\n\n for (var m = 0; m < terms.length; m++) {\n var term = terms[m]\n\n /*\n * Each term returned from the pipeline needs to use the same query\n * clause object, e.g. the same boost and or edit distance. The\n * simplest way to do this is to re-use the clause object but mutate\n * its term property.\n */\n clause.term = term\n\n /*\n * From the term in the clause we create a token set which will then\n * be used to intersect the indexes token set to get a list of terms\n * to lookup in the inverted index\n */\n var termTokenSet = lunr.TokenSet.fromClause(clause),\n expandedTerms = this.tokenSet.intersect(termTokenSet).toArray()\n\n /*\n * If a term marked as required does not exist in the tokenSet it is\n * impossible for the search to return any matches. We set all the field\n * scoped required matches set to empty and stop examining any further\n * clauses.\n */\n if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = lunr.Set.empty\n }\n\n break\n }\n\n for (var j = 0; j < expandedTerms.length; j++) {\n /*\n * For each term get the posting and termIndex, this is required for\n * building the query vector.\n */\n var expandedTerm = expandedTerms[j],\n posting = this.invertedIndex[expandedTerm],\n termIndex = posting._index\n\n for (var k = 0; k < clause.fields.length; k++) {\n /*\n * For each field that this query term is scoped by (by default\n * all fields are in scope) we need to get all the document refs\n * that have this term in that field.\n *\n * The posting is the entry in the invertedIndex for the matching\n * term from above.\n */\n var field = clause.fields[k],\n fieldPosting = posting[field],\n matchingDocumentRefs = Object.keys(fieldPosting),\n termField = expandedTerm + \"/\" + field,\n matchingDocumentsSet = new lunr.Set(matchingDocumentRefs)\n\n /*\n * if the presence of this term is required ensure that the matching\n * documents are added to the set of required matches for this clause.\n *\n */\n if (clause.presence == lunr.Query.presence.REQUIRED) {\n clauseMatches = clauseMatches.union(matchingDocumentsSet)\n\n if (requiredMatches[field] === undefined) {\n requiredMatches[field] = lunr.Set.complete\n }\n }\n\n /*\n * if the presence of this term is prohibited ensure that the matching\n * documents are added to the set of prohibited matches for this field,\n * creating that set if it does not yet exist.\n */\n if (clause.presence == lunr.Query.presence.PROHIBITED) {\n if (prohibitedMatches[field] === undefined) {\n prohibitedMatches[field] = lunr.Set.empty\n }\n\n prohibitedMatches[field] = prohibitedMatches[field].union(matchingDocumentsSet)\n\n /*\n * Prohibited matches should not be part of the query vector used for\n * similarity scoring and no metadata should be extracted so we continue\n * to the next field\n */\n continue\n }\n\n /*\n * The query field vector is populated using the termIndex found for\n * the term and a unit value with the appropriate boost applied.\n * Using upsert because there could already be an entry in the vector\n * for the term we are working with. In that case we just add the scores\n * together.\n */\n queryVectors[field].upsert(termIndex, clause.boost, function (a, b) { return a + b })\n\n /**\n * If we've already seen this term, field combo then we've already collected\n * the matching documents and metadata, no need to go through all that again\n */\n if (termFieldCache[termField]) {\n continue\n }\n\n for (var l = 0; l < matchingDocumentRefs.length; l++) {\n /*\n * All metadata for this term/field/document triple\n * are then extracted and collected into an instance\n * of lunr.MatchData ready to be returned in the query\n * results\n */\n var matchingDocumentRef = matchingDocumentRefs[l],\n matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field),\n metadata = fieldPosting[matchingDocumentRef],\n fieldMatch\n\n if ((fieldMatch = matchingFields[matchingFieldRef]) === undefined) {\n matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata)\n } else {\n fieldMatch.add(expandedTerm, field, metadata)\n }\n\n }\n\n termFieldCache[termField] = true\n }\n }\n }\n\n /**\n * If the presence was required we need to update the requiredMatches field sets.\n * We do this after all fields for the term have collected their matches because\n * the clause terms presence is required in _any_ of the fields not _all_ of the\n * fields.\n */\n if (clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = requiredMatches[field].intersect(clauseMatches)\n }\n }\n }\n\n /**\n * Need to combine the field scoped required and prohibited\n * matching documents into a global set of required and prohibited\n * matches\n */\n var allRequiredMatches = lunr.Set.complete,\n allProhibitedMatches = lunr.Set.empty\n\n for (var i = 0; i < this.fields.length; i++) {\n var field = this.fields[i]\n\n if (requiredMatches[field]) {\n allRequiredMatches = allRequiredMatches.intersect(requiredMatches[field])\n }\n\n if (prohibitedMatches[field]) {\n allProhibitedMatches = allProhibitedMatches.union(prohibitedMatches[field])\n }\n }\n\n var matchingFieldRefs = Object.keys(matchingFields),\n results = [],\n matches = Object.create(null)\n\n /*\n * If the query is negated (contains only prohibited terms)\n * we need to get _all_ fieldRefs currently existing in the\n * index. This is only done when we know that the query is\n * entirely prohibited terms to avoid any cost of getting all\n * fieldRefs unnecessarily.\n *\n * Additionally, blank MatchData must be created to correctly\n * populate the results.\n */\n if (query.isNegated()) {\n matchingFieldRefs = Object.keys(this.fieldVectors)\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n var matchingFieldRef = matchingFieldRefs[i]\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRef)\n matchingFields[matchingFieldRef] = new lunr.MatchData\n }\n }\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n /*\n * Currently we have document fields that match the query, but we\n * need to return documents. The matchData and scores are combined\n * from multiple fields belonging to the same document.\n *\n * Scores are calculated by field, using the query vectors created\n * above, and combined into a final document score using addition.\n */\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]),\n docRef = fieldRef.docRef\n\n if (!allRequiredMatches.contains(docRef)) {\n continue\n }\n\n if (allProhibitedMatches.contains(docRef)) {\n continue\n }\n\n var fieldVector = this.fieldVectors[fieldRef],\n score = queryVectors[fieldRef.fieldName].similarity(fieldVector),\n docMatch\n\n if ((docMatch = matches[docRef]) !== undefined) {\n docMatch.score += score\n docMatch.matchData.combine(matchingFields[fieldRef])\n } else {\n var match = {\n ref: docRef,\n score: score,\n matchData: matchingFields[fieldRef]\n }\n matches[docRef] = match\n results.push(match)\n }\n }\n\n /*\n * Sort the results objects by score, highest first.\n */\n return results.sort(function (a, b) {\n return b.score - a.score\n })\n}\n\n/**\n * Prepares the index for JSON serialization.\n *\n * The schema for this JSON blob will be described in a\n * separate JSON schema file.\n *\n * @returns {Object}\n */\nlunr.Index.prototype.toJSON = function () {\n var invertedIndex = Object.keys(this.invertedIndex)\n .sort()\n .map(function (term) {\n return [term, this.invertedIndex[term]]\n }, this)\n\n var fieldVectors = Object.keys(this.fieldVectors)\n .map(function (ref) {\n return [ref, this.fieldVectors[ref].toJSON()]\n }, this)\n\n return {\n version: lunr.version,\n fields: this.fields,\n fieldVectors: fieldVectors,\n invertedIndex: invertedIndex,\n pipeline: this.pipeline.toJSON()\n }\n}\n\n/**\n * Loads a previously serialized lunr.Index\n *\n * @param {Object} serializedIndex - A previously serialized lunr.Index\n * @returns {lunr.Index}\n */\nlunr.Index.load = function (serializedIndex) {\n var attrs = {},\n fieldVectors = {},\n serializedVectors = serializedIndex.fieldVectors,\n invertedIndex = Object.create(null),\n serializedInvertedIndex = serializedIndex.invertedIndex,\n tokenSetBuilder = new lunr.TokenSet.Builder,\n pipeline = lunr.Pipeline.load(serializedIndex.pipeline)\n\n if (serializedIndex.version != lunr.version) {\n lunr.utils.warn(\"Version mismatch when loading serialised index. Current version of lunr '\" + lunr.version + \"' does not match serialized index '\" + serializedIndex.version + \"'\")\n }\n\n for (var i = 0; i < serializedVectors.length; i++) {\n var tuple = serializedVectors[i],\n ref = tuple[0],\n elements = tuple[1]\n\n fieldVectors[ref] = new lunr.Vector(elements)\n }\n\n for (var i = 0; i < serializedInvertedIndex.length; i++) {\n var tuple = serializedInvertedIndex[i],\n term = tuple[0],\n posting = tuple[1]\n\n tokenSetBuilder.insert(term)\n invertedIndex[term] = posting\n }\n\n tokenSetBuilder.finish()\n\n attrs.fields = serializedIndex.fields\n\n attrs.fieldVectors = fieldVectors\n attrs.invertedIndex = invertedIndex\n attrs.tokenSet = tokenSetBuilder.root\n attrs.pipeline = pipeline\n\n return new lunr.Index(attrs)\n}\n/*!\n * lunr.Builder\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Builder performs indexing on a set of documents and\n * returns instances of lunr.Index ready for querying.\n *\n * All configuration of the index is done via the builder, the\n * fields to index, the document reference, the text processing\n * pipeline and document scoring parameters are all set on the\n * builder before indexing.\n *\n * @constructor\n * @property {string} _ref - Internal reference to the document reference field.\n * @property {string[]} _fields - Internal reference to the document fields to index.\n * @property {object} invertedIndex - The inverted index maps terms to document fields.\n * @property {object} documentTermFrequencies - Keeps track of document term frequencies.\n * @property {object} documentLengths - Keeps track of the length of documents added to the index.\n * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing.\n * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing.\n * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index.\n * @property {number} documentCount - Keeps track of the total number of documents indexed.\n * @property {number} _b - A parameter to control field length normalization, setting this to 0 disabled normalization, 1 fully normalizes field lengths, the default value is 0.75.\n * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2.\n * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space.\n * @property {array} metadataWhitelist - A list of metadata keys that have been whitelisted for entry in the index.\n */\nlunr.Builder = function () {\n this._ref = \"id\"\n this._fields = Object.create(null)\n this._documents = Object.create(null)\n this.invertedIndex = Object.create(null)\n this.fieldTermFrequencies = {}\n this.fieldLengths = {}\n this.tokenizer = lunr.tokenizer\n this.pipeline = new lunr.Pipeline\n this.searchPipeline = new lunr.Pipeline\n this.documentCount = 0\n this._b = 0.75\n this._k1 = 1.2\n this.termIndex = 0\n this.metadataWhitelist = []\n}\n\n/**\n * Sets the document field used as the document reference. Every document must have this field.\n * The type of this field in the document should be a string, if it is not a string it will be\n * coerced into a string by calling toString.\n *\n * The default ref is 'id'.\n *\n * The ref should _not_ be changed during indexing, it should be set before any documents are\n * added to the index. Changing it during indexing can lead to inconsistent results.\n *\n * @param {string} ref - The name of the reference field in the document.\n */\nlunr.Builder.prototype.ref = function (ref) {\n this._ref = ref\n}\n\n/**\n * A function that is used to extract a field from a document.\n *\n * Lunr expects a field to be at the top level of a document, if however the field\n * is deeply nested within a document an extractor function can be used to extract\n * the right field for indexing.\n *\n * @callback fieldExtractor\n * @param {object} doc - The document being added to the index.\n * @returns {?(string|object|object[])} obj - The object that will be indexed for this field.\n * @example Extracting a nested field\n * function (doc) { return doc.nested.field }\n */\n\n/**\n * Adds a field to the list of document fields that will be indexed. Every document being\n * indexed should have this field. Null values for this field in indexed documents will\n * not cause errors but will limit the chance of that document being retrieved by searches.\n *\n * All fields should be added before adding documents to the index. Adding fields after\n * a document has been indexed will have no effect on already indexed documents.\n *\n * Fields can be boosted at build time. This allows terms within that field to have more\n * importance when ranking search results. Use a field boost to specify that matches within\n * one field are more important than other fields.\n *\n * @param {string} fieldName - The name of a field to index in all documents.\n * @param {object} attributes - Optional attributes associated with this field.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this field.\n * @param {fieldExtractor} [attributes.extractor] - Function to extract a field from a document.\n * @throws {RangeError} fieldName cannot contain unsupported characters '/'\n */\nlunr.Builder.prototype.field = function (fieldName, attributes) {\n if (/\\//.test(fieldName)) {\n throw new RangeError (\"Field '\" + fieldName + \"' contains illegal character '/'\")\n }\n\n this._fields[fieldName] = attributes || {}\n}\n\n/**\n * A parameter to tune the amount of field length normalisation that is applied when\n * calculating relevance scores. A value of 0 will completely disable any normalisation\n * and a value of 1 will fully normalise field lengths. The default is 0.75. Values of b\n * will be clamped to the range 0 - 1.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.b = function (number) {\n if (number < 0) {\n this._b = 0\n } else if (number > 1) {\n this._b = 1\n } else {\n this._b = number\n }\n}\n\n/**\n * A parameter that controls the speed at which a rise in term frequency results in term\n * frequency saturation. The default value is 1.2. Setting this to a higher value will give\n * slower saturation levels, a lower value will result in quicker saturation.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.k1 = function (number) {\n this._k1 = number\n}\n\n/**\n * Adds a document to the index.\n *\n * Before adding fields to the index the index should have been fully setup, with the document\n * ref and all fields to index already having been specified.\n *\n * The document must have a field name as specified by the ref (by default this is 'id') and\n * it should have all fields defined for indexing, though null or undefined values will not\n * cause errors.\n *\n * Entire documents can be boosted at build time. Applying a boost to a document indicates that\n * this document should rank higher in search results than other documents.\n *\n * @param {object} doc - The document to add to the index.\n * @param {object} attributes - Optional attributes associated with this document.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this document.\n */\nlunr.Builder.prototype.add = function (doc, attributes) {\n var docRef = doc[this._ref],\n fields = Object.keys(this._fields)\n\n this._documents[docRef] = attributes || {}\n this.documentCount += 1\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i],\n extractor = this._fields[fieldName].extractor,\n field = extractor ? extractor(doc) : doc[fieldName],\n tokens = this.tokenizer(field, {\n fields: [fieldName]\n }),\n terms = this.pipeline.run(tokens),\n fieldRef = new lunr.FieldRef (docRef, fieldName),\n fieldTerms = Object.create(null)\n\n this.fieldTermFrequencies[fieldRef] = fieldTerms\n this.fieldLengths[fieldRef] = 0\n\n // store the length of this field for this document\n this.fieldLengths[fieldRef] += terms.length\n\n // calculate term frequencies for this field\n for (var j = 0; j < terms.length; j++) {\n var term = terms[j]\n\n if (fieldTerms[term] == undefined) {\n fieldTerms[term] = 0\n }\n\n fieldTerms[term] += 1\n\n // add to inverted index\n // create an initial posting if one doesn't exist\n if (this.invertedIndex[term] == undefined) {\n var posting = Object.create(null)\n posting[\"_index\"] = this.termIndex\n this.termIndex += 1\n\n for (var k = 0; k < fields.length; k++) {\n posting[fields[k]] = Object.create(null)\n }\n\n this.invertedIndex[term] = posting\n }\n\n // add an entry for this term/fieldName/docRef to the invertedIndex\n if (this.invertedIndex[term][fieldName][docRef] == undefined) {\n this.invertedIndex[term][fieldName][docRef] = Object.create(null)\n }\n\n // store all whitelisted metadata about this token in the\n // inverted index\n for (var l = 0; l < this.metadataWhitelist.length; l++) {\n var metadataKey = this.metadataWhitelist[l],\n metadata = term.metadata[metadataKey]\n\n if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) {\n this.invertedIndex[term][fieldName][docRef][metadataKey] = []\n }\n\n this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata)\n }\n }\n\n }\n}\n\n/**\n * Calculates the average document length for this index\n *\n * @private\n */\nlunr.Builder.prototype.calculateAverageFieldLengths = function () {\n\n var fieldRefs = Object.keys(this.fieldLengths),\n numberOfFields = fieldRefs.length,\n accumulator = {},\n documentsWithField = {}\n\n for (var i = 0; i < numberOfFields; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n field = fieldRef.fieldName\n\n documentsWithField[field] || (documentsWithField[field] = 0)\n documentsWithField[field] += 1\n\n accumulator[field] || (accumulator[field] = 0)\n accumulator[field] += this.fieldLengths[fieldRef]\n }\n\n var fields = Object.keys(this._fields)\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i]\n accumulator[fieldName] = accumulator[fieldName] / documentsWithField[fieldName]\n }\n\n this.averageFieldLength = accumulator\n}\n\n/**\n * Builds a vector space model of every document using lunr.Vector\n *\n * @private\n */\nlunr.Builder.prototype.createFieldVectors = function () {\n var fieldVectors = {},\n fieldRefs = Object.keys(this.fieldTermFrequencies),\n fieldRefsLength = fieldRefs.length,\n termIdfCache = Object.create(null)\n\n for (var i = 0; i < fieldRefsLength; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n fieldName = fieldRef.fieldName,\n fieldLength = this.fieldLengths[fieldRef],\n fieldVector = new lunr.Vector,\n termFrequencies = this.fieldTermFrequencies[fieldRef],\n terms = Object.keys(termFrequencies),\n termsLength = terms.length\n\n\n var fieldBoost = this._fields[fieldName].boost || 1,\n docBoost = this._documents[fieldRef.docRef].boost || 1\n\n for (var j = 0; j < termsLength; j++) {\n var term = terms[j],\n tf = termFrequencies[term],\n termIndex = this.invertedIndex[term]._index,\n idf, score, scoreWithPrecision\n\n if (termIdfCache[term] === undefined) {\n idf = lunr.idf(this.invertedIndex[term], this.documentCount)\n termIdfCache[term] = idf\n } else {\n idf = termIdfCache[term]\n }\n\n score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (fieldLength / this.averageFieldLength[fieldName])) + tf)\n score *= fieldBoost\n score *= docBoost\n scoreWithPrecision = Math.round(score * 1000) / 1000\n // Converts 1.23456789 to 1.234.\n // Reducing the precision so that the vectors take up less\n // space when serialised. Doing it now so that they behave\n // the same before and after serialisation. Also, this is\n // the fastest approach to reducing a number's precision in\n // JavaScript.\n\n fieldVector.insert(termIndex, scoreWithPrecision)\n }\n\n fieldVectors[fieldRef] = fieldVector\n }\n\n this.fieldVectors = fieldVectors\n}\n\n/**\n * Creates a token set of all tokens in the index using lunr.TokenSet\n *\n * @private\n */\nlunr.Builder.prototype.createTokenSet = function () {\n this.tokenSet = lunr.TokenSet.fromArray(\n Object.keys(this.invertedIndex).sort()\n )\n}\n\n/**\n * Builds the index, creating an instance of lunr.Index.\n *\n * This completes the indexing process and should only be called\n * once all documents have been added to the index.\n *\n * @returns {lunr.Index}\n */\nlunr.Builder.prototype.build = function () {\n this.calculateAverageFieldLengths()\n this.createFieldVectors()\n this.createTokenSet()\n\n return new lunr.Index({\n invertedIndex: this.invertedIndex,\n fieldVectors: this.fieldVectors,\n tokenSet: this.tokenSet,\n fields: Object.keys(this._fields),\n pipeline: this.searchPipeline\n })\n}\n\n/**\n * Applies a plugin to the index builder.\n *\n * A plugin is a function that is called with the index builder as its context.\n * Plugins can be used to customise or extend the behaviour of the index\n * in some way. A plugin is just a function, that encapsulated the custom\n * behaviour that should be applied when building the index.\n *\n * The plugin function will be called with the index builder as its argument, additional\n * arguments can also be passed when calling use. The function will be called\n * with the index builder as its context.\n *\n * @param {Function} plugin The plugin to apply.\n */\nlunr.Builder.prototype.use = function (fn) {\n var args = Array.prototype.slice.call(arguments, 1)\n args.unshift(this)\n fn.apply(this, args)\n}\n/**\n * Contains and collects metadata about a matching document.\n * A single instance of lunr.MatchData is returned as part of every\n * lunr.Index~Result.\n *\n * @constructor\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n * @property {object} metadata - A cloned collection of metadata associated with this document.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData = function (term, field, metadata) {\n var clonedMetadata = Object.create(null),\n metadataKeys = Object.keys(metadata || {})\n\n // Cloning the metadata to prevent the original\n // being mutated during match data combination.\n // Metadata is kept in an array within the inverted\n // index so cloning the data can be done with\n // Array#slice\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n clonedMetadata[key] = metadata[key].slice()\n }\n\n this.metadata = Object.create(null)\n\n if (term !== undefined) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = clonedMetadata\n }\n}\n\n/**\n * An instance of lunr.MatchData will be created for every term that matches a\n * document. However only one instance is required in a lunr.Index~Result. This\n * method combines metadata from another instance of lunr.MatchData with this\n * objects metadata.\n *\n * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData.prototype.combine = function (otherMatchData) {\n var terms = Object.keys(otherMatchData.metadata)\n\n for (var i = 0; i < terms.length; i++) {\n var term = terms[i],\n fields = Object.keys(otherMatchData.metadata[term])\n\n if (this.metadata[term] == undefined) {\n this.metadata[term] = Object.create(null)\n }\n\n for (var j = 0; j < fields.length; j++) {\n var field = fields[j],\n keys = Object.keys(otherMatchData.metadata[term][field])\n\n if (this.metadata[term][field] == undefined) {\n this.metadata[term][field] = Object.create(null)\n }\n\n for (var k = 0; k < keys.length; k++) {\n var key = keys[k]\n\n if (this.metadata[term][field][key] == undefined) {\n this.metadata[term][field][key] = otherMatchData.metadata[term][field][key]\n } else {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key])\n }\n\n }\n }\n }\n}\n\n/**\n * Add metadata for a term/field pair to this instance of match data.\n *\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n */\nlunr.MatchData.prototype.add = function (term, field, metadata) {\n if (!(term in this.metadata)) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = metadata\n return\n }\n\n if (!(field in this.metadata[term])) {\n this.metadata[term][field] = metadata\n return\n }\n\n var metadataKeys = Object.keys(metadata)\n\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n\n if (key in this.metadata[term][field]) {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key])\n } else {\n this.metadata[term][field][key] = metadata[key]\n }\n }\n}\n/**\n * A lunr.Query provides a programmatic way of defining queries to be performed\n * against a {@link lunr.Index}.\n *\n * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method\n * so the query object is pre-initialized with the right index fields.\n *\n * @constructor\n * @property {lunr.Query~Clause[]} clauses - An array of query clauses.\n * @property {string[]} allFields - An array of all available fields in a lunr.Index.\n */\nlunr.Query = function (allFields) {\n this.clauses = []\n this.allFields = allFields\n}\n\n/**\n * Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause.\n *\n * This allows wildcards to be added to the beginning and end of a term without having to manually do any string\n * concatenation.\n *\n * The wildcard constants can be bitwise combined to select both leading and trailing wildcards.\n *\n * @constant\n * @default\n * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour\n * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists\n * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with trailing wildcard\n * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })\n * @example query term with leading and trailing wildcard\n * query.term('foo', {\n * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING\n * })\n */\n\nlunr.Query.wildcard = new String (\"*\")\nlunr.Query.wildcard.NONE = 0\nlunr.Query.wildcard.LEADING = 1\nlunr.Query.wildcard.TRAILING = 2\n\n/**\n * Constants for indicating what kind of presence a term must have in matching documents.\n *\n * @constant\n * @enum {number}\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with required presence\n * query.term('foo', { presence: lunr.Query.presence.REQUIRED })\n */\nlunr.Query.presence = {\n /**\n * Term's presence in a document is optional, this is the default value.\n */\n OPTIONAL: 1,\n\n /**\n * Term's presence in a document is required, documents that do not contain\n * this term will not be returned.\n */\n REQUIRED: 2,\n\n /**\n * Term's presence in a document is prohibited, documents that do contain\n * this term will not be returned.\n */\n PROHIBITED: 3\n}\n\n/**\n * A single clause in a {@link lunr.Query} contains a term and details on how to\n * match that term against a {@link lunr.Index}.\n *\n * @typedef {Object} lunr.Query~Clause\n * @property {string[]} fields - The fields in an index this clause should be matched against.\n * @property {number} [boost=1] - Any boost that should be applied when matching this clause.\n * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be.\n * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline.\n * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended.\n * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents.\n */\n\n/**\n * Adds a {@link lunr.Query~Clause} to this query.\n *\n * Unless the clause contains the fields to be matched all fields will be matched. In addition\n * a default boost of 1 is applied to the clause.\n *\n * @param {lunr.Query~Clause} clause - The clause to add to this query.\n * @see lunr.Query~Clause\n * @returns {lunr.Query}\n */\nlunr.Query.prototype.clause = function (clause) {\n if (!('fields' in clause)) {\n clause.fields = this.allFields\n }\n\n if (!('boost' in clause)) {\n clause.boost = 1\n }\n\n if (!('usePipeline' in clause)) {\n clause.usePipeline = true\n }\n\n if (!('wildcard' in clause)) {\n clause.wildcard = lunr.Query.wildcard.NONE\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) {\n clause.term = \"*\" + clause.term\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) {\n clause.term = \"\" + clause.term + \"*\"\n }\n\n if (!('presence' in clause)) {\n clause.presence = lunr.Query.presence.OPTIONAL\n }\n\n this.clauses.push(clause)\n\n return this\n}\n\n/**\n * A negated query is one in which every clause has a presence of\n * prohibited. These queries require some special processing to return\n * the expected results.\n *\n * @returns boolean\n */\nlunr.Query.prototype.isNegated = function () {\n for (var i = 0; i < this.clauses.length; i++) {\n if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause}\n * to the list of clauses that make up this query.\n *\n * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion\n * to a token or token-like string should be done before calling this method.\n *\n * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an\n * array, each term in the array will share the same options.\n *\n * @param {object|object[]} term - The term(s) to add to the query.\n * @param {object} [options] - Any additional properties to add to the query clause.\n * @returns {lunr.Query}\n * @see lunr.Query#clause\n * @see lunr.Query~Clause\n * @example adding a single term to a query\n * query.term(\"foo\")\n * @example adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard\n * query.term(\"foo\", {\n * fields: [\"title\"],\n * boost: 10,\n * wildcard: lunr.Query.wildcard.TRAILING\n * })\n * @example using lunr.tokenizer to convert a string to tokens before using them as terms\n * query.term(lunr.tokenizer(\"foo bar\"))\n */\nlunr.Query.prototype.term = function (term, options) {\n if (Array.isArray(term)) {\n term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)\n return this\n }\n\n var clause = options || {}\n clause.term = term.toString()\n\n this.clause(clause)\n\n return this\n}\nlunr.QueryParseError = function (message, start, end) {\n this.name = \"QueryParseError\"\n this.message = message\n this.start = start\n this.end = end\n}\n\nlunr.QueryParseError.prototype = new Error\nlunr.QueryLexer = function (str) {\n this.lexemes = []\n this.str = str\n this.length = str.length\n this.pos = 0\n this.start = 0\n this.escapeCharPositions = []\n}\n\nlunr.QueryLexer.prototype.run = function () {\n var state = lunr.QueryLexer.lexText\n\n while (state) {\n state = state(this)\n }\n}\n\nlunr.QueryLexer.prototype.sliceString = function () {\n var subSlices = [],\n sliceStart = this.start,\n sliceEnd = this.pos\n\n for (var i = 0; i < this.escapeCharPositions.length; i++) {\n sliceEnd = this.escapeCharPositions[i]\n subSlices.push(this.str.slice(sliceStart, sliceEnd))\n sliceStart = sliceEnd + 1\n }\n\n subSlices.push(this.str.slice(sliceStart, this.pos))\n this.escapeCharPositions.length = 0\n\n return subSlices.join('')\n}\n\nlunr.QueryLexer.prototype.emit = function (type) {\n this.lexemes.push({\n type: type,\n str: this.sliceString(),\n start: this.start,\n end: this.pos\n })\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.escapeCharacter = function () {\n this.escapeCharPositions.push(this.pos - 1)\n this.pos += 1\n}\n\nlunr.QueryLexer.prototype.next = function () {\n if (this.pos >= this.length) {\n return lunr.QueryLexer.EOS\n }\n\n var char = this.str.charAt(this.pos)\n this.pos += 1\n return char\n}\n\nlunr.QueryLexer.prototype.width = function () {\n return this.pos - this.start\n}\n\nlunr.QueryLexer.prototype.ignore = function () {\n if (this.start == this.pos) {\n this.pos += 1\n }\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.backup = function () {\n this.pos -= 1\n}\n\nlunr.QueryLexer.prototype.acceptDigitRun = function () {\n var char, charCode\n\n do {\n char = this.next()\n charCode = char.charCodeAt(0)\n } while (charCode > 47 && charCode < 58)\n\n if (char != lunr.QueryLexer.EOS) {\n this.backup()\n }\n}\n\nlunr.QueryLexer.prototype.more = function () {\n return this.pos < this.length\n}\n\nlunr.QueryLexer.EOS = 'EOS'\nlunr.QueryLexer.FIELD = 'FIELD'\nlunr.QueryLexer.TERM = 'TERM'\nlunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE'\nlunr.QueryLexer.BOOST = 'BOOST'\nlunr.QueryLexer.PRESENCE = 'PRESENCE'\n\nlunr.QueryLexer.lexField = function (lexer) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.FIELD)\n lexer.ignore()\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexTerm = function (lexer) {\n if (lexer.width() > 1) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.TERM)\n }\n\n lexer.ignore()\n\n if (lexer.more()) {\n return lunr.QueryLexer.lexText\n }\n}\n\nlunr.QueryLexer.lexEditDistance = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.EDIT_DISTANCE)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexBoost = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.BOOST)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexEOS = function (lexer) {\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n}\n\n// This matches the separator used when tokenising fields\n// within a document. These should match otherwise it is\n// not possible to search for some tokens within a document.\n//\n// It is possible for the user to change the separator on the\n// tokenizer so it _might_ clash with any other of the special\n// characters already used within the search string, e.g. :.\n//\n// This means that it is possible to change the separator in\n// such a way that makes some words unsearchable using a search\n// string.\nlunr.QueryLexer.termSeparator = lunr.tokenizer.separator\n\nlunr.QueryLexer.lexText = function (lexer) {\n while (true) {\n var char = lexer.next()\n\n if (char == lunr.QueryLexer.EOS) {\n return lunr.QueryLexer.lexEOS\n }\n\n // Escape character is '\\'\n if (char.charCodeAt(0) == 92) {\n lexer.escapeCharacter()\n continue\n }\n\n if (char == \":\") {\n return lunr.QueryLexer.lexField\n }\n\n if (char == \"~\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexEditDistance\n }\n\n if (char == \"^\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexBoost\n }\n\n // \"+\" indicates term presence is required\n // checking for length to ensure that only\n // leading \"+\" are considered\n if (char == \"+\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n // \"-\" indicates term presence is prohibited\n // checking for length to ensure that only\n // leading \"-\" are considered\n if (char == \"-\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n if (char.match(lunr.QueryLexer.termSeparator)) {\n return lunr.QueryLexer.lexTerm\n }\n }\n}\n\nlunr.QueryParser = function (str, query) {\n this.lexer = new lunr.QueryLexer (str)\n this.query = query\n this.currentClause = {}\n this.lexemeIdx = 0\n}\n\nlunr.QueryParser.prototype.parse = function () {\n this.lexer.run()\n this.lexemes = this.lexer.lexemes\n\n var state = lunr.QueryParser.parseClause\n\n while (state) {\n state = state(this)\n }\n\n return this.query\n}\n\nlunr.QueryParser.prototype.peekLexeme = function () {\n return this.lexemes[this.lexemeIdx]\n}\n\nlunr.QueryParser.prototype.consumeLexeme = function () {\n var lexeme = this.peekLexeme()\n this.lexemeIdx += 1\n return lexeme\n}\n\nlunr.QueryParser.prototype.nextClause = function () {\n var completedClause = this.currentClause\n this.query.clause(completedClause)\n this.currentClause = {}\n}\n\nlunr.QueryParser.parseClause = function (parser) {\n var lexeme = parser.peekLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.type) {\n case lunr.QueryLexer.PRESENCE:\n return lunr.QueryParser.parsePresence\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expected either a field or a term, found \" + lexeme.type\n\n if (lexeme.str.length >= 1) {\n errorMessage += \" with value '\" + lexeme.str + \"'\"\n }\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n}\n\nlunr.QueryParser.parsePresence = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.str) {\n case \"-\":\n parser.currentClause.presence = lunr.Query.presence.PROHIBITED\n break\n case \"+\":\n parser.currentClause.presence = lunr.Query.presence.REQUIRED\n break\n default:\n var errorMessage = \"unrecognised presence operator'\" + lexeme.str + \"'\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term or field, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term or field, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseField = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n if (parser.query.allFields.indexOf(lexeme.str) == -1) {\n var possibleFields = parser.query.allFields.map(function (f) { return \"'\" + f + \"'\" }).join(', '),\n errorMessage = \"unrecognised field '\" + lexeme.str + \"', possible fields: \" + possibleFields\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.fields = [lexeme.str]\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseTerm = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n parser.currentClause.term = lexeme.str.toLowerCase()\n\n if (lexeme.str.indexOf(\"*\") != -1) {\n parser.currentClause.usePipeline = false\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseEditDistance = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var editDistance = parseInt(lexeme.str, 10)\n\n if (isNaN(editDistance)) {\n var errorMessage = \"edit distance must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.editDistance = editDistance\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseBoost = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var boost = parseInt(lexeme.str, 10)\n\n if (isNaN(boost)) {\n var errorMessage = \"boost must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.boost = boost\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\n /**\n * export the module via AMD, CommonJS or as a browser global\n * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js\n */\n ;(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(factory)\n } else if (typeof exports === 'object') {\n /**\n * Node. Does not work with strict CommonJS, but\n * only CommonJS-like enviroments that support module.exports,\n * like Node.\n */\n module.exports = factory()\n } else {\n // Browser globals (root is window)\n root.lunr = factory()\n }\n }(this, function () {\n /**\n * Just return a value to define the module export.\n * This example returns an object, but the module\n * can return a function as the exported value.\n */\n return lunr\n }))\n})();\n"],"file":"lunr.min.js"} \ No newline at end of file +{"version":3,"file":"lunr.min.js","sources":["../src/lunr.js"],"sourcesContent":["/**\n * moodle readme\n *\n * Lunrjs can be downloaded from https://github.com/olivernn/lunr.js. To update this library get the lunr.js file\n * from this project and replace the content below with the new content.\n */\n\n/**\n * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9\n * Copyright (C) 2020 Oliver Nightingale\n * @license MIT\n */\n\n;(function(){\n\n/**\n * A convenience function for configuring and constructing\n * a new lunr Index.\n *\n * A lunr.Builder instance is created and the pipeline setup\n * with a trimmer, stop word filter and stemmer.\n *\n * This builder object is yielded to the configuration function\n * that is passed as a parameter, allowing the list of fields\n * and other builder parameters to be customised.\n *\n * All documents _must_ be added within the passed config function.\n *\n * @example\n * var idx = lunr(function () {\n * this.field('title')\n * this.field('body')\n * this.ref('id')\n *\n * documents.forEach(function (doc) {\n * this.add(doc)\n * }, this)\n * })\n *\n * @see {@link lunr.Builder}\n * @see {@link lunr.Pipeline}\n * @see {@link lunr.trimmer}\n * @see {@link lunr.stopWordFilter}\n * @see {@link lunr.stemmer}\n * @namespace {function} lunr\n */\nvar lunr = function (config) {\n var builder = new lunr.Builder\n\n builder.pipeline.add(\n lunr.trimmer,\n lunr.stopWordFilter,\n lunr.stemmer\n )\n\n builder.searchPipeline.add(\n lunr.stemmer\n )\n\n config.call(builder, builder)\n return builder.build()\n}\n\nlunr.version = \"2.3.9\"\n/*!\n * lunr.utils\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A namespace containing utils for the rest of the lunr library\n * @namespace lunr.utils\n */\nlunr.utils = {}\n\n/**\n * Print a warning message to the console.\n *\n * @param {String} message The message to be printed.\n * @memberOf lunr.utils\n * @function\n */\nlunr.utils.warn = (function (global) {\n /* eslint-disable no-console */\n return function (message) {\n if (global.console && console.warn) {\n console.warn(message)\n }\n }\n /* eslint-enable no-console */\n})(this)\n\n/**\n * Convert an object to a string.\n *\n * In the case of `null` and `undefined` the function returns\n * the empty string, in all other cases the result of calling\n * `toString` on the passed object is returned.\n *\n * @param {Any} obj The object to convert to a string.\n * @return {String} string representation of the passed object.\n * @memberOf lunr.utils\n */\nlunr.utils.asString = function (obj) {\n if (obj === void 0 || obj === null) {\n return \"\"\n } else {\n return obj.toString()\n }\n}\n\n/**\n * Clones an object.\n *\n * Will create a copy of an existing object such that any mutations\n * on the copy cannot affect the original.\n *\n * Only shallow objects are supported, passing a nested object to this\n * function will cause a TypeError.\n *\n * Objects with primitives, and arrays of primitives are supported.\n *\n * @param {Object} obj The object to clone.\n * @return {Object} a clone of the passed object.\n * @throws {TypeError} when a nested object is passed.\n * @memberOf Utils\n */\nlunr.utils.clone = function (obj) {\n if (obj === null || obj === undefined) {\n return obj\n }\n\n var clone = Object.create(null),\n keys = Object.keys(obj)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i],\n val = obj[key]\n\n if (Array.isArray(val)) {\n clone[key] = val.slice()\n continue\n }\n\n if (typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean') {\n clone[key] = val\n continue\n }\n\n throw new TypeError(\"clone is not deep and does not support nested objects\")\n }\n\n return clone\n}\nlunr.FieldRef = function (docRef, fieldName, stringValue) {\n this.docRef = docRef\n this.fieldName = fieldName\n this._stringValue = stringValue\n}\n\nlunr.FieldRef.joiner = \"/\"\n\nlunr.FieldRef.fromString = function (s) {\n var n = s.indexOf(lunr.FieldRef.joiner)\n\n if (n === -1) {\n throw \"malformed field ref string\"\n }\n\n var fieldRef = s.slice(0, n),\n docRef = s.slice(n + 1)\n\n return new lunr.FieldRef (docRef, fieldRef, s)\n}\n\nlunr.FieldRef.prototype.toString = function () {\n if (this._stringValue == undefined) {\n this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef\n }\n\n return this._stringValue\n}\n/*!\n * lunr.Set\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A lunr set.\n *\n * @constructor\n */\nlunr.Set = function (elements) {\n this.elements = Object.create(null)\n\n if (elements) {\n this.length = elements.length\n\n for (var i = 0; i < this.length; i++) {\n this.elements[elements[i]] = true\n }\n } else {\n this.length = 0\n }\n}\n\n/**\n * A complete set that contains all elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.complete = {\n intersect: function (other) {\n return other\n },\n\n union: function () {\n return this\n },\n\n contains: function () {\n return true\n }\n}\n\n/**\n * An empty set that contains no elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.empty = {\n intersect: function () {\n return this\n },\n\n union: function (other) {\n return other\n },\n\n contains: function () {\n return false\n }\n}\n\n/**\n * Returns true if this set contains the specified object.\n *\n * @param {object} object - Object whose presence in this set is to be tested.\n * @returns {boolean} - True if this set contains the specified object.\n */\nlunr.Set.prototype.contains = function (object) {\n return !!this.elements[object]\n}\n\n/**\n * Returns a new set containing only the elements that are present in both\n * this set and the specified set.\n *\n * @param {lunr.Set} other - set to intersect with this set.\n * @returns {lunr.Set} a new set that is the intersection of this and the specified set.\n */\n\nlunr.Set.prototype.intersect = function (other) {\n var a, b, elements, intersection = []\n\n if (other === lunr.Set.complete) {\n return this\n }\n\n if (other === lunr.Set.empty) {\n return other\n }\n\n if (this.length < other.length) {\n a = this\n b = other\n } else {\n a = other\n b = this\n }\n\n elements = Object.keys(a.elements)\n\n for (var i = 0; i < elements.length; i++) {\n var element = elements[i]\n if (element in b.elements) {\n intersection.push(element)\n }\n }\n\n return new lunr.Set (intersection)\n}\n\n/**\n * Returns a new set combining the elements of this and the specified set.\n *\n * @param {lunr.Set} other - set to union with this set.\n * @return {lunr.Set} a new set that is the union of this and the specified set.\n */\n\nlunr.Set.prototype.union = function (other) {\n if (other === lunr.Set.complete) {\n return lunr.Set.complete\n }\n\n if (other === lunr.Set.empty) {\n return this\n }\n\n return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements)))\n}\n/**\n * A function to calculate the inverse document frequency for\n * a posting. This is shared between the builder and the index\n *\n * @private\n * @param {object} posting - The posting for a given term\n * @param {number} documentCount - The total number of documents.\n */\nlunr.idf = function (posting, documentCount) {\n var documentsWithTerm = 0\n\n for (var fieldName in posting) {\n if (fieldName == '_index') continue // Ignore the term index, its not a field\n documentsWithTerm += Object.keys(posting[fieldName]).length\n }\n\n var x = (documentCount - documentsWithTerm + 0.5) / (documentsWithTerm + 0.5)\n\n return Math.log(1 + Math.abs(x))\n}\n\n/**\n * A token wraps a string representation of a token\n * as it is passed through the text processing pipeline.\n *\n * @constructor\n * @param {string} [str=''] - The string token being wrapped.\n * @param {object} [metadata={}] - Metadata associated with this token.\n */\nlunr.Token = function (str, metadata) {\n this.str = str || \"\"\n this.metadata = metadata || {}\n}\n\n/**\n * Returns the token string that is being wrapped by this object.\n *\n * @returns {string}\n */\nlunr.Token.prototype.toString = function () {\n return this.str\n}\n\n/**\n * A token update function is used when updating or optionally\n * when cloning a token.\n *\n * @callback lunr.Token~updateFunction\n * @param {string} str - The string representation of the token.\n * @param {Object} metadata - All metadata associated with this token.\n */\n\n/**\n * Applies the given function to the wrapped string token.\n *\n * @example\n * token.update(function (str, metadata) {\n * return str.toUpperCase()\n * })\n *\n * @param {lunr.Token~updateFunction} fn - A function to apply to the token string.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.update = function (fn) {\n this.str = fn(this.str, this.metadata)\n return this\n}\n\n/**\n * Creates a clone of this token. Optionally a function can be\n * applied to the cloned token.\n *\n * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.clone = function (fn) {\n fn = fn || function (s) { return s }\n return new lunr.Token (fn(this.str, this.metadata), this.metadata)\n}\n/*!\n * lunr.tokenizer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A function for splitting a string into tokens ready to be inserted into\n * the search index. Uses `lunr.tokenizer.separator` to split strings, change\n * the value of this property to change how strings are split into tokens.\n *\n * This tokenizer will convert its parameter to a string by calling `toString` and\n * then will split this string on the character in `lunr.tokenizer.separator`.\n * Arrays will have their elements converted to strings and wrapped in a lunr.Token.\n *\n * Optional metadata can be passed to the tokenizer, this metadata will be cloned and\n * added as metadata to every token that is created from the object to be tokenized.\n *\n * @static\n * @param {?(string|object|object[])} obj - The object to convert into tokens\n * @param {?object} metadata - Optional metadata to associate with every token\n * @returns {lunr.Token[]}\n * @see {@link lunr.Pipeline}\n */\nlunr.tokenizer = function (obj, metadata) {\n if (obj == null || obj == undefined) {\n return []\n }\n\n if (Array.isArray(obj)) {\n return obj.map(function (t) {\n return new lunr.Token(\n lunr.utils.asString(t).toLowerCase(),\n lunr.utils.clone(metadata)\n )\n })\n }\n\n var str = obj.toString().toLowerCase(),\n len = str.length,\n tokens = []\n\n for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) {\n var char = str.charAt(sliceEnd),\n sliceLength = sliceEnd - sliceStart\n\n if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) {\n\n if (sliceLength > 0) {\n var tokenMetadata = lunr.utils.clone(metadata) || {}\n tokenMetadata[\"position\"] = [sliceStart, sliceLength]\n tokenMetadata[\"index\"] = tokens.length\n\n tokens.push(\n new lunr.Token (\n str.slice(sliceStart, sliceEnd),\n tokenMetadata\n )\n )\n }\n\n sliceStart = sliceEnd + 1\n }\n\n }\n\n return tokens\n}\n\n/**\n * The separator used to split a string into tokens. Override this property to change the behaviour of\n * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens.\n *\n * @static\n * @see lunr.tokenizer\n */\nlunr.tokenizer.separator = /[\\s\\-]+/\n/*!\n * lunr.Pipeline\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Pipelines maintain an ordered list of functions to be applied to all\n * tokens in documents entering the search index and queries being ran against\n * the index.\n *\n * An instance of lunr.Index created with the lunr shortcut will contain a\n * pipeline with a stop word filter and an English language stemmer. Extra\n * functions can be added before or after either of these functions or these\n * default functions can be removed.\n *\n * When run the pipeline will call each function in turn, passing a token, the\n * index of that token in the original list of all tokens and finally a list of\n * all the original tokens.\n *\n * The output of functions in the pipeline will be passed to the next function\n * in the pipeline. To exclude a token from entering the index the function\n * should return undefined, the rest of the pipeline will not be called with\n * this token.\n *\n * For serialisation of pipelines to work, all functions used in an instance of\n * a pipeline should be registered with lunr.Pipeline. Registered functions can\n * then be loaded. If trying to load a serialised pipeline that uses functions\n * that are not registered an error will be thrown.\n *\n * If not planning on serialising the pipeline then registering pipeline functions\n * is not necessary.\n *\n * @constructor\n */\nlunr.Pipeline = function () {\n this._stack = []\n}\n\nlunr.Pipeline.registeredFunctions = Object.create(null)\n\n/**\n * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token\n * string as well as all known metadata. A pipeline function can mutate the token string\n * or mutate (or add) metadata for a given token.\n *\n * A pipeline function can indicate that the passed token should be discarded by returning\n * null, undefined or an empty string. This token will not be passed to any downstream pipeline\n * functions and will not be added to the index.\n *\n * Multiple tokens can be returned by returning an array of tokens. Each token will be passed\n * to any downstream pipeline functions and all will returned tokens will be added to the index.\n *\n * Any number of pipeline functions may be chained together using a lunr.Pipeline.\n *\n * @interface lunr.PipelineFunction\n * @param {lunr.Token} token - A token from the document being processed.\n * @param {number} i - The index of this token in the complete list of tokens for this document/field.\n * @param {lunr.Token[]} tokens - All tokens for this document/field.\n * @returns {(?lunr.Token|lunr.Token[])}\n */\n\n/**\n * Register a function with the pipeline.\n *\n * Functions that are used in the pipeline should be registered if the pipeline\n * needs to be serialised, or a serialised pipeline needs to be loaded.\n *\n * Registering a function does not add it to a pipeline, functions must still be\n * added to instances of the pipeline for them to be used when running a pipeline.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @param {String} label - The label to register this function with\n */\nlunr.Pipeline.registerFunction = function (fn, label) {\n if (label in this.registeredFunctions) {\n lunr.utils.warn('Overwriting existing registered function: ' + label)\n }\n\n fn.label = label\n lunr.Pipeline.registeredFunctions[fn.label] = fn\n}\n\n/**\n * Warns if the function is not registered as a Pipeline function.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @private\n */\nlunr.Pipeline.warnIfFunctionNotRegistered = function (fn) {\n var isRegistered = fn.label && (fn.label in this.registeredFunctions)\n\n if (!isRegistered) {\n lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\\n', fn)\n }\n}\n\n/**\n * Loads a previously serialised pipeline.\n *\n * All functions to be loaded must already be registered with lunr.Pipeline.\n * If any function from the serialised data has not been registered then an\n * error will be thrown.\n *\n * @param {Object} serialised - The serialised pipeline to load.\n * @returns {lunr.Pipeline}\n */\nlunr.Pipeline.load = function (serialised) {\n var pipeline = new lunr.Pipeline\n\n serialised.forEach(function (fnName) {\n var fn = lunr.Pipeline.registeredFunctions[fnName]\n\n if (fn) {\n pipeline.add(fn)\n } else {\n throw new Error('Cannot load unregistered function: ' + fnName)\n }\n })\n\n return pipeline\n}\n\n/**\n * Adds new functions to the end of the pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline.\n */\nlunr.Pipeline.prototype.add = function () {\n var fns = Array.prototype.slice.call(arguments)\n\n fns.forEach(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n this._stack.push(fn)\n }, this)\n}\n\n/**\n * Adds a single function after a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.after = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n pos = pos + 1\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Adds a single function before a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.before = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Removes a function from the pipeline.\n *\n * @param {lunr.PipelineFunction} fn The function to remove from the pipeline.\n */\nlunr.Pipeline.prototype.remove = function (fn) {\n var pos = this._stack.indexOf(fn)\n if (pos == -1) {\n return\n }\n\n this._stack.splice(pos, 1)\n}\n\n/**\n * Runs the current list of functions that make up the pipeline against the\n * passed tokens.\n *\n * @param {Array} tokens The tokens to run through the pipeline.\n * @returns {Array}\n */\nlunr.Pipeline.prototype.run = function (tokens) {\n var stackLength = this._stack.length\n\n for (var i = 0; i < stackLength; i++) {\n var fn = this._stack[i]\n var memo = []\n\n for (var j = 0; j < tokens.length; j++) {\n var result = fn(tokens[j], j, tokens)\n\n if (result === null || result === void 0 || result === '') continue\n\n if (Array.isArray(result)) {\n for (var k = 0; k < result.length; k++) {\n memo.push(result[k])\n }\n } else {\n memo.push(result)\n }\n }\n\n tokens = memo\n }\n\n return tokens\n}\n\n/**\n * Convenience method for passing a string through a pipeline and getting\n * strings out. This method takes care of wrapping the passed string in a\n * token and mapping the resulting tokens back to strings.\n *\n * @param {string} str - The string to pass through the pipeline.\n * @param {?object} metadata - Optional metadata to associate with the token\n * passed to the pipeline.\n * @returns {string[]}\n */\nlunr.Pipeline.prototype.runString = function (str, metadata) {\n var token = new lunr.Token (str, metadata)\n\n return this.run([token]).map(function (t) {\n return t.toString()\n })\n}\n\n/**\n * Resets the pipeline by removing any existing processors.\n *\n */\nlunr.Pipeline.prototype.reset = function () {\n this._stack = []\n}\n\n/**\n * Returns a representation of the pipeline ready for serialisation.\n *\n * Logs a warning if the function has not been registered.\n *\n * @returns {Array}\n */\nlunr.Pipeline.prototype.toJSON = function () {\n return this._stack.map(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n\n return fn.label\n })\n}\n/*!\n * lunr.Vector\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A vector is used to construct the vector space of documents and queries. These\n * vectors support operations to determine the similarity between two documents or\n * a document and a query.\n *\n * Normally no parameters are required for initializing a vector, but in the case of\n * loading a previously dumped vector the raw elements can be provided to the constructor.\n *\n * For performance reasons vectors are implemented with a flat array, where an elements\n * index is immediately followed by its value. E.g. [index, value, index, value]. This\n * allows the underlying array to be as sparse as possible and still offer decent\n * performance when being used for vector calculations.\n *\n * @constructor\n * @param {Number[]} [elements] - The flat list of element index and element value pairs.\n */\nlunr.Vector = function (elements) {\n this._magnitude = 0\n this.elements = elements || []\n}\n\n\n/**\n * Calculates the position within the vector to insert a given index.\n *\n * This is used internally by insert and upsert. If there are duplicate indexes then\n * the position is returned as if the value for that index were to be updated, but it\n * is the callers responsibility to check whether there is a duplicate at that index\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @returns {Number}\n */\nlunr.Vector.prototype.positionForIndex = function (index) {\n // For an empty vector the tuple can be inserted at the beginning\n if (this.elements.length == 0) {\n return 0\n }\n\n var start = 0,\n end = this.elements.length / 2,\n sliceLength = end - start,\n pivotPoint = Math.floor(sliceLength / 2),\n pivotIndex = this.elements[pivotPoint * 2]\n\n while (sliceLength > 1) {\n if (pivotIndex < index) {\n start = pivotPoint\n }\n\n if (pivotIndex > index) {\n end = pivotPoint\n }\n\n if (pivotIndex == index) {\n break\n }\n\n sliceLength = end - start\n pivotPoint = start + Math.floor(sliceLength / 2)\n pivotIndex = this.elements[pivotPoint * 2]\n }\n\n if (pivotIndex == index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex > index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex < index) {\n return (pivotPoint + 1) * 2\n }\n}\n\n/**\n * Inserts an element at an index within the vector.\n *\n * Does not allow duplicates, will throw an error if there is already an entry\n * for this index.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n */\nlunr.Vector.prototype.insert = function (insertIdx, val) {\n this.upsert(insertIdx, val, function () {\n throw \"duplicate index\"\n })\n}\n\n/**\n * Inserts or updates an existing index within the vector.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n * @param {function} fn - A function that is called for updates, the existing value and the\n * requested value are passed as arguments\n */\nlunr.Vector.prototype.upsert = function (insertIdx, val, fn) {\n this._magnitude = 0\n var position = this.positionForIndex(insertIdx)\n\n if (this.elements[position] == insertIdx) {\n this.elements[position + 1] = fn(this.elements[position + 1], val)\n } else {\n this.elements.splice(position, 0, insertIdx, val)\n }\n}\n\n/**\n * Calculates the magnitude of this vector.\n *\n * @returns {Number}\n */\nlunr.Vector.prototype.magnitude = function () {\n if (this._magnitude) return this._magnitude\n\n var sumOfSquares = 0,\n elementsLength = this.elements.length\n\n for (var i = 1; i < elementsLength; i += 2) {\n var val = this.elements[i]\n sumOfSquares += val * val\n }\n\n return this._magnitude = Math.sqrt(sumOfSquares)\n}\n\n/**\n * Calculates the dot product of this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The vector to compute the dot product with.\n * @returns {Number}\n */\nlunr.Vector.prototype.dot = function (otherVector) {\n var dotProduct = 0,\n a = this.elements, b = otherVector.elements,\n aLen = a.length, bLen = b.length,\n aVal = 0, bVal = 0,\n i = 0, j = 0\n\n while (i < aLen && j < bLen) {\n aVal = a[i], bVal = b[j]\n if (aVal < bVal) {\n i += 2\n } else if (aVal > bVal) {\n j += 2\n } else if (aVal == bVal) {\n dotProduct += a[i + 1] * b[j + 1]\n i += 2\n j += 2\n }\n }\n\n return dotProduct\n}\n\n/**\n * Calculates the similarity between this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The other vector to calculate the\n * similarity with.\n * @returns {Number}\n */\nlunr.Vector.prototype.similarity = function (otherVector) {\n return this.dot(otherVector) / this.magnitude() || 0\n}\n\n/**\n * Converts the vector to an array of the elements within the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toArray = function () {\n var output = new Array (this.elements.length / 2)\n\n for (var i = 1, j = 0; i < this.elements.length; i += 2, j++) {\n output[j] = this.elements[i]\n }\n\n return output\n}\n\n/**\n * A JSON serializable representation of the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toJSON = function () {\n return this.elements\n}\n/* eslint-disable */\n/*!\n * lunr.stemmer\n * Copyright (C) 2020 Oliver Nightingale\n * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt\n */\n\n/**\n * lunr.stemmer is an english language stemmer, this is a JavaScript\n * implementation of the PorterStemmer taken from http://tartarus.org/~martin\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token - The string to stem\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n * @function\n */\nlunr.stemmer = (function(){\n var step2list = {\n \"ational\" : \"ate\",\n \"tional\" : \"tion\",\n \"enci\" : \"ence\",\n \"anci\" : \"ance\",\n \"izer\" : \"ize\",\n \"bli\" : \"ble\",\n \"alli\" : \"al\",\n \"entli\" : \"ent\",\n \"eli\" : \"e\",\n \"ousli\" : \"ous\",\n \"ization\" : \"ize\",\n \"ation\" : \"ate\",\n \"ator\" : \"ate\",\n \"alism\" : \"al\",\n \"iveness\" : \"ive\",\n \"fulness\" : \"ful\",\n \"ousness\" : \"ous\",\n \"aliti\" : \"al\",\n \"iviti\" : \"ive\",\n \"biliti\" : \"ble\",\n \"logi\" : \"log\"\n },\n\n step3list = {\n \"icate\" : \"ic\",\n \"ative\" : \"\",\n \"alize\" : \"al\",\n \"iciti\" : \"ic\",\n \"ical\" : \"ic\",\n \"ful\" : \"\",\n \"ness\" : \"\"\n },\n\n c = \"[^aeiou]\", // consonant\n v = \"[aeiouy]\", // vowel\n C = c + \"[^aeiouy]*\", // consonant sequence\n V = v + \"[aeiou]*\", // vowel sequence\n\n mgr0 = \"^(\" + C + \")?\" + V + C, // [C]VC... is m>0\n meq1 = \"^(\" + C + \")?\" + V + C + \"(\" + V + \")?$\", // [C]VC[V] is m=1\n mgr1 = \"^(\" + C + \")?\" + V + C + V + C, // [C]VCVC... is m>1\n s_v = \"^(\" + C + \")?\" + v; // vowel in stem\n\n var re_mgr0 = new RegExp(mgr0);\n var re_mgr1 = new RegExp(mgr1);\n var re_meq1 = new RegExp(meq1);\n var re_s_v = new RegExp(s_v);\n\n var re_1a = /^(.+?)(ss|i)es$/;\n var re2_1a = /^(.+?)([^s])s$/;\n var re_1b = /^(.+?)eed$/;\n var re2_1b = /^(.+?)(ed|ing)$/;\n var re_1b_2 = /.$/;\n var re2_1b_2 = /(at|bl|iz)$/;\n var re3_1b_2 = new RegExp(\"([^aeiouylsz])\\\\1$\");\n var re4_1b_2 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var re_1c = /^(.+?[^aeiou])y$/;\n var re_2 = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;\n\n var re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;\n\n var re_4 = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;\n var re2_4 = /^(.+?)(s|t)(ion)$/;\n\n var re_5 = /^(.+?)e$/;\n var re_5_1 = /ll$/;\n var re3_5 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var porterStemmer = function porterStemmer(w) {\n var stem,\n suffix,\n firstch,\n re,\n re2,\n re3,\n re4;\n\n if (w.length < 3) { return w; }\n\n firstch = w.substr(0,1);\n if (firstch == \"y\") {\n w = firstch.toUpperCase() + w.substr(1);\n }\n\n // Step 1a\n re = re_1a\n re2 = re2_1a;\n\n if (re.test(w)) { w = w.replace(re,\"$1$2\"); }\n else if (re2.test(w)) { w = w.replace(re2,\"$1$2\"); }\n\n // Step 1b\n re = re_1b;\n re2 = re2_1b;\n if (re.test(w)) {\n var fp = re.exec(w);\n re = re_mgr0;\n if (re.test(fp[1])) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1];\n re2 = re_s_v;\n if (re2.test(stem)) {\n w = stem;\n re2 = re2_1b_2;\n re3 = re3_1b_2;\n re4 = re4_1b_2;\n if (re2.test(w)) { w = w + \"e\"; }\n else if (re3.test(w)) { re = re_1b_2; w = w.replace(re,\"\"); }\n else if (re4.test(w)) { w = w + \"e\"; }\n }\n }\n\n // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)\n re = re_1c;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n w = stem + \"i\";\n }\n\n // Step 2\n re = re_2;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step2list[suffix];\n }\n }\n\n // Step 3\n re = re_3;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step3list[suffix];\n }\n }\n\n // Step 4\n re = re_4;\n re2 = re2_4;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n if (re.test(stem)) {\n w = stem;\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1] + fp[2];\n re2 = re_mgr1;\n if (re2.test(stem)) {\n w = stem;\n }\n }\n\n // Step 5\n re = re_5;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n re2 = re_meq1;\n re3 = re3_5;\n if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) {\n w = stem;\n }\n }\n\n re = re_5_1;\n re2 = re_mgr1;\n if (re.test(w) && re2.test(w)) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n\n // and turn initial Y back to y\n\n if (firstch == \"y\") {\n w = firstch.toLowerCase() + w.substr(1);\n }\n\n return w;\n };\n\n return function (token) {\n return token.update(porterStemmer);\n }\n})();\n\nlunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')\n/*!\n * lunr.stopWordFilter\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.generateStopWordFilter builds a stopWordFilter function from the provided\n * list of stop words.\n *\n * The built in lunr.stopWordFilter is built using this generator and can be used\n * to generate custom stopWordFilters for applications or non English languages.\n *\n * @function\n * @param {Array} token The token to pass through the filter\n * @returns {lunr.PipelineFunction}\n * @see lunr.Pipeline\n * @see lunr.stopWordFilter\n */\nlunr.generateStopWordFilter = function (stopWords) {\n var words = stopWords.reduce(function (memo, stopWord) {\n memo[stopWord] = stopWord\n return memo\n }, {})\n\n return function (token) {\n if (token && words[token.toString()] !== token.toString()) return token\n }\n}\n\n/**\n * lunr.stopWordFilter is an English language stop word list filter, any words\n * contained in the list will not be passed through the filter.\n *\n * This is intended to be used in the Pipeline. If the token does not pass the\n * filter then undefined will be returned.\n *\n * @function\n * @implements {lunr.PipelineFunction}\n * @params {lunr.Token} token - A token to check for being a stop word.\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n */\nlunr.stopWordFilter = lunr.generateStopWordFilter([\n 'a',\n 'able',\n 'about',\n 'across',\n 'after',\n 'all',\n 'almost',\n 'also',\n 'am',\n 'among',\n 'an',\n 'and',\n 'any',\n 'are',\n 'as',\n 'at',\n 'be',\n 'because',\n 'been',\n 'but',\n 'by',\n 'can',\n 'cannot',\n 'could',\n 'dear',\n 'did',\n 'do',\n 'does',\n 'either',\n 'else',\n 'ever',\n 'every',\n 'for',\n 'from',\n 'get',\n 'got',\n 'had',\n 'has',\n 'have',\n 'he',\n 'her',\n 'hers',\n 'him',\n 'his',\n 'how',\n 'however',\n 'i',\n 'if',\n 'in',\n 'into',\n 'is',\n 'it',\n 'its',\n 'just',\n 'least',\n 'let',\n 'like',\n 'likely',\n 'may',\n 'me',\n 'might',\n 'most',\n 'must',\n 'my',\n 'neither',\n 'no',\n 'nor',\n 'not',\n 'of',\n 'off',\n 'often',\n 'on',\n 'only',\n 'or',\n 'other',\n 'our',\n 'own',\n 'rather',\n 'said',\n 'say',\n 'says',\n 'she',\n 'should',\n 'since',\n 'so',\n 'some',\n 'than',\n 'that',\n 'the',\n 'their',\n 'them',\n 'then',\n 'there',\n 'these',\n 'they',\n 'this',\n 'tis',\n 'to',\n 'too',\n 'twas',\n 'us',\n 'wants',\n 'was',\n 'we',\n 'were',\n 'what',\n 'when',\n 'where',\n 'which',\n 'while',\n 'who',\n 'whom',\n 'why',\n 'will',\n 'with',\n 'would',\n 'yet',\n 'you',\n 'your'\n])\n\nlunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')\n/*!\n * lunr.trimmer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.trimmer is a pipeline function for trimming non word\n * characters from the beginning and end of tokens before they\n * enter the index.\n *\n * This implementation may not work correctly for non latin\n * characters and should either be removed or adapted for use\n * with languages with non-latin characters.\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token The token to pass through the filter\n * @returns {lunr.Token}\n * @see lunr.Pipeline\n */\nlunr.trimmer = function (token) {\n return token.update(function (s) {\n return s.replace(/^\\W+/, '').replace(/\\W+$/, '')\n })\n}\n\nlunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')\n/*!\n * lunr.TokenSet\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A token set is used to store the unique list of all tokens\n * within an index. Token sets are also used to represent an\n * incoming query to the index, this query token set and index\n * token set are then intersected to find which tokens to look\n * up in the inverted index.\n *\n * A token set can hold multiple tokens, as in the case of the\n * index token set, or it can hold a single token as in the\n * case of a simple query token set.\n *\n * Additionally token sets are used to perform wildcard matching.\n * Leading, contained and trailing wildcards are supported, and\n * from this edit distance matching can also be provided.\n *\n * Token sets are implemented as a minimal finite state automata,\n * where both common prefixes and suffixes are shared between tokens.\n * This helps to reduce the space used for storing the token set.\n *\n * @constructor\n */\nlunr.TokenSet = function () {\n this.final = false\n this.edges = {}\n this.id = lunr.TokenSet._nextId\n lunr.TokenSet._nextId += 1\n}\n\n/**\n * Keeps track of the next, auto increment, identifier to assign\n * to a new tokenSet.\n *\n * TokenSets require a unique identifier to be correctly minimised.\n *\n * @private\n */\nlunr.TokenSet._nextId = 1\n\n/**\n * Creates a TokenSet instance from the given sorted array of words.\n *\n * @param {String[]} arr - A sorted array of strings to create the set from.\n * @returns {lunr.TokenSet}\n * @throws Will throw an error if the input array is not sorted.\n */\nlunr.TokenSet.fromArray = function (arr) {\n var builder = new lunr.TokenSet.Builder\n\n for (var i = 0, len = arr.length; i < len; i++) {\n builder.insert(arr[i])\n }\n\n builder.finish()\n return builder.root\n}\n\n/**\n * Creates a token set from a query clause.\n *\n * @private\n * @param {Object} clause - A single clause from lunr.Query.\n * @param {string} clause.term - The query clause term.\n * @param {number} [clause.editDistance] - The optional edit distance for the term.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromClause = function (clause) {\n if ('editDistance' in clause) {\n return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance)\n } else {\n return lunr.TokenSet.fromString(clause.term)\n }\n}\n\n/**\n * Creates a token set representing a single string with a specified\n * edit distance.\n *\n * Insertions, deletions, substitutions and transpositions are each\n * treated as an edit distance of 1.\n *\n * Increasing the allowed edit distance will have a dramatic impact\n * on the performance of both creating and intersecting these TokenSets.\n * It is advised to keep the edit distance less than 3.\n *\n * @param {string} str - The string to create the token set from.\n * @param {number} editDistance - The allowed edit distance to match.\n * @returns {lunr.Vector}\n */\nlunr.TokenSet.fromFuzzyString = function (str, editDistance) {\n var root = new lunr.TokenSet\n\n var stack = [{\n node: root,\n editsRemaining: editDistance,\n str: str\n }]\n\n while (stack.length) {\n var frame = stack.pop()\n\n // no edit\n if (frame.str.length > 0) {\n var char = frame.str.charAt(0),\n noEditNode\n\n if (char in frame.node.edges) {\n noEditNode = frame.node.edges[char]\n } else {\n noEditNode = new lunr.TokenSet\n frame.node.edges[char] = noEditNode\n }\n\n if (frame.str.length == 1) {\n noEditNode.final = true\n }\n\n stack.push({\n node: noEditNode,\n editsRemaining: frame.editsRemaining,\n str: frame.str.slice(1)\n })\n }\n\n if (frame.editsRemaining == 0) {\n continue\n }\n\n // insertion\n if (\"*\" in frame.node.edges) {\n var insertionNode = frame.node.edges[\"*\"]\n } else {\n var insertionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = insertionNode\n }\n\n if (frame.str.length == 0) {\n insertionNode.final = true\n }\n\n stack.push({\n node: insertionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str\n })\n\n // deletion\n // can only do a deletion if we have enough edits remaining\n // and if there are characters left to delete in the string\n if (frame.str.length > 1) {\n stack.push({\n node: frame.node,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // deletion\n // just removing the last character from the str\n if (frame.str.length == 1) {\n frame.node.final = true\n }\n\n // substitution\n // can only do a substitution if we have enough edits remaining\n // and if there are characters left to substitute\n if (frame.str.length >= 1) {\n if (\"*\" in frame.node.edges) {\n var substitutionNode = frame.node.edges[\"*\"]\n } else {\n var substitutionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = substitutionNode\n }\n\n if (frame.str.length == 1) {\n substitutionNode.final = true\n }\n\n stack.push({\n node: substitutionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // transposition\n // can only do a transposition if there are edits remaining\n // and there are enough characters to transpose\n if (frame.str.length > 1) {\n var charA = frame.str.charAt(0),\n charB = frame.str.charAt(1),\n transposeNode\n\n if (charB in frame.node.edges) {\n transposeNode = frame.node.edges[charB]\n } else {\n transposeNode = new lunr.TokenSet\n frame.node.edges[charB] = transposeNode\n }\n\n if (frame.str.length == 1) {\n transposeNode.final = true\n }\n\n stack.push({\n node: transposeNode,\n editsRemaining: frame.editsRemaining - 1,\n str: charA + frame.str.slice(2)\n })\n }\n }\n\n return root\n}\n\n/**\n * Creates a TokenSet from a string.\n *\n * The string may contain one or more wildcard characters (*)\n * that will allow wildcard matching when intersecting with\n * another TokenSet.\n *\n * @param {string} str - The string to create a TokenSet from.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromString = function (str) {\n var node = new lunr.TokenSet,\n root = node\n\n /*\n * Iterates through all characters within the passed string\n * appending a node for each character.\n *\n * When a wildcard character is found then a self\n * referencing edge is introduced to continually match\n * any number of any characters.\n */\n for (var i = 0, len = str.length; i < len; i++) {\n var char = str[i],\n final = (i == len - 1)\n\n if (char == \"*\") {\n node.edges[char] = node\n node.final = final\n\n } else {\n var next = new lunr.TokenSet\n next.final = final\n\n node.edges[char] = next\n node = next\n }\n }\n\n return root\n}\n\n/**\n * Converts this TokenSet into an array of strings\n * contained within the TokenSet.\n *\n * This is not intended to be used on a TokenSet that\n * contains wildcards, in these cases the results are\n * undefined and are likely to cause an infinite loop.\n *\n * @returns {string[]}\n */\nlunr.TokenSet.prototype.toArray = function () {\n var words = []\n\n var stack = [{\n prefix: \"\",\n node: this\n }]\n\n while (stack.length) {\n var frame = stack.pop(),\n edges = Object.keys(frame.node.edges),\n len = edges.length\n\n if (frame.node.final) {\n /* In Safari, at this point the prefix is sometimes corrupted, see:\n * https://github.com/olivernn/lunr.js/issues/279 Calling any\n * String.prototype method forces Safari to \"cast\" this string to what\n * it's supposed to be, fixing the bug. */\n frame.prefix.charAt(0)\n words.push(frame.prefix)\n }\n\n for (var i = 0; i < len; i++) {\n var edge = edges[i]\n\n stack.push({\n prefix: frame.prefix.concat(edge),\n node: frame.node.edges[edge]\n })\n }\n }\n\n return words\n}\n\n/**\n * Generates a string representation of a TokenSet.\n *\n * This is intended to allow TokenSets to be used as keys\n * in objects, largely to aid the construction and minimisation\n * of a TokenSet. As such it is not designed to be a human\n * friendly representation of the TokenSet.\n *\n * @returns {string}\n */\nlunr.TokenSet.prototype.toString = function () {\n // NOTE: Using Object.keys here as this.edges is very likely\n // to enter 'hash-mode' with many keys being added\n //\n // avoiding a for-in loop here as it leads to the function\n // being de-optimised (at least in V8). From some simple\n // benchmarks the performance is comparable, but allowing\n // V8 to optimize may mean easy performance wins in the future.\n\n if (this._str) {\n return this._str\n }\n\n var str = this.final ? '1' : '0',\n labels = Object.keys(this.edges).sort(),\n len = labels.length\n\n for (var i = 0; i < len; i++) {\n var label = labels[i],\n node = this.edges[label]\n\n str = str + label + node.id\n }\n\n return str\n}\n\n/**\n * Returns a new TokenSet that is the intersection of\n * this TokenSet and the passed TokenSet.\n *\n * This intersection will take into account any wildcards\n * contained within the TokenSet.\n *\n * @param {lunr.TokenSet} b - An other TokenSet to intersect with.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.prototype.intersect = function (b) {\n var output = new lunr.TokenSet,\n frame = undefined\n\n var stack = [{\n qNode: b,\n output: output,\n node: this\n }]\n\n while (stack.length) {\n frame = stack.pop()\n\n // NOTE: As with the #toString method, we are using\n // Object.keys and a for loop instead of a for-in loop\n // as both of these objects enter 'hash' mode, causing\n // the function to be de-optimised in V8\n var qEdges = Object.keys(frame.qNode.edges),\n qLen = qEdges.length,\n nEdges = Object.keys(frame.node.edges),\n nLen = nEdges.length\n\n for (var q = 0; q < qLen; q++) {\n var qEdge = qEdges[q]\n\n for (var n = 0; n < nLen; n++) {\n var nEdge = nEdges[n]\n\n if (nEdge == qEdge || qEdge == '*') {\n var node = frame.node.edges[nEdge],\n qNode = frame.qNode.edges[qEdge],\n final = node.final && qNode.final,\n next = undefined\n\n if (nEdge in frame.output.edges) {\n // an edge already exists for this character\n // no need to create a new node, just set the finality\n // bit unless this node is already final\n next = frame.output.edges[nEdge]\n next.final = next.final || final\n\n } else {\n // no edge exists yet, must create one\n // set the finality bit and insert it\n // into the output\n next = new lunr.TokenSet\n next.final = final\n frame.output.edges[nEdge] = next\n }\n\n stack.push({\n qNode: qNode,\n output: next,\n node: node\n })\n }\n }\n }\n }\n\n return output\n}\nlunr.TokenSet.Builder = function () {\n this.previousWord = \"\"\n this.root = new lunr.TokenSet\n this.uncheckedNodes = []\n this.minimizedNodes = {}\n}\n\nlunr.TokenSet.Builder.prototype.insert = function (word) {\n var node,\n commonPrefix = 0\n\n if (word < this.previousWord) {\n throw new Error (\"Out of order word insertion\")\n }\n\n for (var i = 0; i < word.length && i < this.previousWord.length; i++) {\n if (word[i] != this.previousWord[i]) break\n commonPrefix++\n }\n\n this.minimize(commonPrefix)\n\n if (this.uncheckedNodes.length == 0) {\n node = this.root\n } else {\n node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child\n }\n\n for (var i = commonPrefix; i < word.length; i++) {\n var nextNode = new lunr.TokenSet,\n char = word[i]\n\n node.edges[char] = nextNode\n\n this.uncheckedNodes.push({\n parent: node,\n char: char,\n child: nextNode\n })\n\n node = nextNode\n }\n\n node.final = true\n this.previousWord = word\n}\n\nlunr.TokenSet.Builder.prototype.finish = function () {\n this.minimize(0)\n}\n\nlunr.TokenSet.Builder.prototype.minimize = function (downTo) {\n for (var i = this.uncheckedNodes.length - 1; i >= downTo; i--) {\n var node = this.uncheckedNodes[i],\n childKey = node.child.toString()\n\n if (childKey in this.minimizedNodes) {\n node.parent.edges[node.char] = this.minimizedNodes[childKey]\n } else {\n // Cache the key for this node since\n // we know it can't change anymore\n node.child._str = childKey\n\n this.minimizedNodes[childKey] = node.child\n }\n\n this.uncheckedNodes.pop()\n }\n}\n/*!\n * lunr.Index\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * An index contains the built index of all documents and provides a query interface\n * to the index.\n *\n * Usually instances of lunr.Index will not be created using this constructor, instead\n * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be\n * used to load previously built and serialized indexes.\n *\n * @constructor\n * @param {Object} attrs - The attributes of the built search index.\n * @param {Object} attrs.invertedIndex - An index of term/field to document reference.\n * @param {Object} attrs.fieldVectors - Field vectors\n * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens.\n * @param {string[]} attrs.fields - The names of indexed document fields.\n * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms.\n */\nlunr.Index = function (attrs) {\n this.invertedIndex = attrs.invertedIndex\n this.fieldVectors = attrs.fieldVectors\n this.tokenSet = attrs.tokenSet\n this.fields = attrs.fields\n this.pipeline = attrs.pipeline\n}\n\n/**\n * A result contains details of a document matching a search query.\n * @typedef {Object} lunr.Index~Result\n * @property {string} ref - The reference of the document this result represents.\n * @property {number} score - A number between 0 and 1 representing how similar this document is to the query.\n * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match.\n */\n\n/**\n * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple\n * query language which itself is parsed into an instance of lunr.Query.\n *\n * For programmatically building queries it is advised to directly use lunr.Query, the query language\n * is best used for human entered text rather than program generated text.\n *\n * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported\n * and will be combined with OR, e.g `hello world` will match documents that contain either 'hello'\n * or 'world', though those that contain both will rank higher in the results.\n *\n * Wildcards can be included in terms to match one or more unspecified characters, these wildcards can\n * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding\n * wildcards will increase the number of documents that will be found but can also have a negative\n * impact on query performance, especially with wildcards at the beginning of a term.\n *\n * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term\n * hello in the title field will match this query. Using a field not present in the index will lead\n * to an error being thrown.\n *\n * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term\n * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported\n * to provide fuzzy matching, e.g. 'hello~2' will match documents with hello with an edit distance of 2.\n * Avoid large values for edit distance to improve query performance.\n *\n * Each term also supports a presence modifier. By default a term's presence in document is optional, however\n * this can be changed to either required or prohibited. For a term's presence to be required in a document the\n * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and\n * optionally contain 'bar'. Conversely a leading '-' sets the terms presence to prohibited, i.e. it must not\n * appear in a document, e.g. `-foo bar` is a search for documents that do not contain 'foo' but may contain 'bar'.\n *\n * To escape special characters the backslash character '\\' can be used, this allows searches to include\n * characters that would normally be considered modifiers, e.g. `foo\\~2` will search for a term \"foo~2\" instead\n * of attempting to apply a boost of 2 to the search term \"foo\".\n *\n * @typedef {string} lunr.Index~QueryString\n * @example Simple single term query\n * hello\n * @example Multiple term query\n * hello world\n * @example term scoped to a field\n * title:hello\n * @example term with a boost of 10\n * hello^10\n * @example term with an edit distance of 2\n * hello~2\n * @example terms with presence modifiers\n * -foo +bar baz\n */\n\n/**\n * Performs a search against the index using lunr query syntax.\n *\n * Results will be returned sorted by their score, the most relevant results\n * will be returned first. For details on how the score is calculated, please see\n * the {@link https://lunrjs.com/guides/searching.html#scoring|guide}.\n *\n * For more programmatic querying use lunr.Index#query.\n *\n * @param {lunr.Index~QueryString} queryString - A string containing a lunr query.\n * @throws {lunr.QueryParseError} If the passed query string cannot be parsed.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.search = function (queryString) {\n return this.query(function (query) {\n var parser = new lunr.QueryParser(queryString, query)\n parser.parse()\n })\n}\n\n/**\n * A query builder callback provides a query object to be used to express\n * the query to perform on the index.\n *\n * @callback lunr.Index~queryBuilder\n * @param {lunr.Query} query - The query object to build up.\n * @this lunr.Query\n */\n\n/**\n * Performs a query against the index using the yielded lunr.Query object.\n *\n * If performing programmatic queries against the index, this method is preferred\n * over lunr.Index#search so as to avoid the additional query parsing overhead.\n *\n * A query object is yielded to the supplied function which should be used to\n * express the query to be run against the index.\n *\n * Note that although this function takes a callback parameter it is _not_ an\n * asynchronous operation, the callback is just yielded a query object to be\n * customized.\n *\n * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.query = function (fn) {\n // for each query clause\n // * process terms\n // * expand terms from token set\n // * find matching documents and metadata\n // * get document vectors\n // * score documents\n\n var query = new lunr.Query(this.fields),\n matchingFields = Object.create(null),\n queryVectors = Object.create(null),\n termFieldCache = Object.create(null),\n requiredMatches = Object.create(null),\n prohibitedMatches = Object.create(null)\n\n /*\n * To support field level boosts a query vector is created per\n * field. An empty vector is eagerly created to support negated\n * queries.\n */\n for (var i = 0; i < this.fields.length; i++) {\n queryVectors[this.fields[i]] = new lunr.Vector\n }\n\n fn.call(query, query)\n\n for (var i = 0; i < query.clauses.length; i++) {\n /*\n * Unless the pipeline has been disabled for this term, which is\n * the case for terms with wildcards, we need to pass the clause\n * term through the search pipeline. A pipeline returns an array\n * of processed terms. Pipeline functions may expand the passed\n * term, which means we may end up performing multiple index lookups\n * for a single query term.\n */\n var clause = query.clauses[i],\n terms = null,\n clauseMatches = lunr.Set.empty\n\n if (clause.usePipeline) {\n terms = this.pipeline.runString(clause.term, {\n fields: clause.fields\n })\n } else {\n terms = [clause.term]\n }\n\n for (var m = 0; m < terms.length; m++) {\n var term = terms[m]\n\n /*\n * Each term returned from the pipeline needs to use the same query\n * clause object, e.g. the same boost and or edit distance. The\n * simplest way to do this is to re-use the clause object but mutate\n * its term property.\n */\n clause.term = term\n\n /*\n * From the term in the clause we create a token set which will then\n * be used to intersect the indexes token set to get a list of terms\n * to lookup in the inverted index\n */\n var termTokenSet = lunr.TokenSet.fromClause(clause),\n expandedTerms = this.tokenSet.intersect(termTokenSet).toArray()\n\n /*\n * If a term marked as required does not exist in the tokenSet it is\n * impossible for the search to return any matches. We set all the field\n * scoped required matches set to empty and stop examining any further\n * clauses.\n */\n if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = lunr.Set.empty\n }\n\n break\n }\n\n for (var j = 0; j < expandedTerms.length; j++) {\n /*\n * For each term get the posting and termIndex, this is required for\n * building the query vector.\n */\n var expandedTerm = expandedTerms[j],\n posting = this.invertedIndex[expandedTerm],\n termIndex = posting._index\n\n for (var k = 0; k < clause.fields.length; k++) {\n /*\n * For each field that this query term is scoped by (by default\n * all fields are in scope) we need to get all the document refs\n * that have this term in that field.\n *\n * The posting is the entry in the invertedIndex for the matching\n * term from above.\n */\n var field = clause.fields[k],\n fieldPosting = posting[field],\n matchingDocumentRefs = Object.keys(fieldPosting),\n termField = expandedTerm + \"/\" + field,\n matchingDocumentsSet = new lunr.Set(matchingDocumentRefs)\n\n /*\n * if the presence of this term is required ensure that the matching\n * documents are added to the set of required matches for this clause.\n *\n */\n if (clause.presence == lunr.Query.presence.REQUIRED) {\n clauseMatches = clauseMatches.union(matchingDocumentsSet)\n\n if (requiredMatches[field] === undefined) {\n requiredMatches[field] = lunr.Set.complete\n }\n }\n\n /*\n * if the presence of this term is prohibited ensure that the matching\n * documents are added to the set of prohibited matches for this field,\n * creating that set if it does not yet exist.\n */\n if (clause.presence == lunr.Query.presence.PROHIBITED) {\n if (prohibitedMatches[field] === undefined) {\n prohibitedMatches[field] = lunr.Set.empty\n }\n\n prohibitedMatches[field] = prohibitedMatches[field].union(matchingDocumentsSet)\n\n /*\n * Prohibited matches should not be part of the query vector used for\n * similarity scoring and no metadata should be extracted so we continue\n * to the next field\n */\n continue\n }\n\n /*\n * The query field vector is populated using the termIndex found for\n * the term and a unit value with the appropriate boost applied.\n * Using upsert because there could already be an entry in the vector\n * for the term we are working with. In that case we just add the scores\n * together.\n */\n queryVectors[field].upsert(termIndex, clause.boost, function (a, b) { return a + b })\n\n /**\n * If we've already seen this term, field combo then we've already collected\n * the matching documents and metadata, no need to go through all that again\n */\n if (termFieldCache[termField]) {\n continue\n }\n\n for (var l = 0; l < matchingDocumentRefs.length; l++) {\n /*\n * All metadata for this term/field/document triple\n * are then extracted and collected into an instance\n * of lunr.MatchData ready to be returned in the query\n * results\n */\n var matchingDocumentRef = matchingDocumentRefs[l],\n matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field),\n metadata = fieldPosting[matchingDocumentRef],\n fieldMatch\n\n if ((fieldMatch = matchingFields[matchingFieldRef]) === undefined) {\n matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata)\n } else {\n fieldMatch.add(expandedTerm, field, metadata)\n }\n\n }\n\n termFieldCache[termField] = true\n }\n }\n }\n\n /**\n * If the presence was required we need to update the requiredMatches field sets.\n * We do this after all fields for the term have collected their matches because\n * the clause terms presence is required in _any_ of the fields not _all_ of the\n * fields.\n */\n if (clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = requiredMatches[field].intersect(clauseMatches)\n }\n }\n }\n\n /**\n * Need to combine the field scoped required and prohibited\n * matching documents into a global set of required and prohibited\n * matches\n */\n var allRequiredMatches = lunr.Set.complete,\n allProhibitedMatches = lunr.Set.empty\n\n for (var i = 0; i < this.fields.length; i++) {\n var field = this.fields[i]\n\n if (requiredMatches[field]) {\n allRequiredMatches = allRequiredMatches.intersect(requiredMatches[field])\n }\n\n if (prohibitedMatches[field]) {\n allProhibitedMatches = allProhibitedMatches.union(prohibitedMatches[field])\n }\n }\n\n var matchingFieldRefs = Object.keys(matchingFields),\n results = [],\n matches = Object.create(null)\n\n /*\n * If the query is negated (contains only prohibited terms)\n * we need to get _all_ fieldRefs currently existing in the\n * index. This is only done when we know that the query is\n * entirely prohibited terms to avoid any cost of getting all\n * fieldRefs unnecessarily.\n *\n * Additionally, blank MatchData must be created to correctly\n * populate the results.\n */\n if (query.isNegated()) {\n matchingFieldRefs = Object.keys(this.fieldVectors)\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n var matchingFieldRef = matchingFieldRefs[i]\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRef)\n matchingFields[matchingFieldRef] = new lunr.MatchData\n }\n }\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n /*\n * Currently we have document fields that match the query, but we\n * need to return documents. The matchData and scores are combined\n * from multiple fields belonging to the same document.\n *\n * Scores are calculated by field, using the query vectors created\n * above, and combined into a final document score using addition.\n */\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]),\n docRef = fieldRef.docRef\n\n if (!allRequiredMatches.contains(docRef)) {\n continue\n }\n\n if (allProhibitedMatches.contains(docRef)) {\n continue\n }\n\n var fieldVector = this.fieldVectors[fieldRef],\n score = queryVectors[fieldRef.fieldName].similarity(fieldVector),\n docMatch\n\n if ((docMatch = matches[docRef]) !== undefined) {\n docMatch.score += score\n docMatch.matchData.combine(matchingFields[fieldRef])\n } else {\n var match = {\n ref: docRef,\n score: score,\n matchData: matchingFields[fieldRef]\n }\n matches[docRef] = match\n results.push(match)\n }\n }\n\n /*\n * Sort the results objects by score, highest first.\n */\n return results.sort(function (a, b) {\n return b.score - a.score\n })\n}\n\n/**\n * Prepares the index for JSON serialization.\n *\n * The schema for this JSON blob will be described in a\n * separate JSON schema file.\n *\n * @returns {Object}\n */\nlunr.Index.prototype.toJSON = function () {\n var invertedIndex = Object.keys(this.invertedIndex)\n .sort()\n .map(function (term) {\n return [term, this.invertedIndex[term]]\n }, this)\n\n var fieldVectors = Object.keys(this.fieldVectors)\n .map(function (ref) {\n return [ref, this.fieldVectors[ref].toJSON()]\n }, this)\n\n return {\n version: lunr.version,\n fields: this.fields,\n fieldVectors: fieldVectors,\n invertedIndex: invertedIndex,\n pipeline: this.pipeline.toJSON()\n }\n}\n\n/**\n * Loads a previously serialized lunr.Index\n *\n * @param {Object} serializedIndex - A previously serialized lunr.Index\n * @returns {lunr.Index}\n */\nlunr.Index.load = function (serializedIndex) {\n var attrs = {},\n fieldVectors = {},\n serializedVectors = serializedIndex.fieldVectors,\n invertedIndex = Object.create(null),\n serializedInvertedIndex = serializedIndex.invertedIndex,\n tokenSetBuilder = new lunr.TokenSet.Builder,\n pipeline = lunr.Pipeline.load(serializedIndex.pipeline)\n\n if (serializedIndex.version != lunr.version) {\n lunr.utils.warn(\"Version mismatch when loading serialised index. Current version of lunr '\" + lunr.version + \"' does not match serialized index '\" + serializedIndex.version + \"'\")\n }\n\n for (var i = 0; i < serializedVectors.length; i++) {\n var tuple = serializedVectors[i],\n ref = tuple[0],\n elements = tuple[1]\n\n fieldVectors[ref] = new lunr.Vector(elements)\n }\n\n for (var i = 0; i < serializedInvertedIndex.length; i++) {\n var tuple = serializedInvertedIndex[i],\n term = tuple[0],\n posting = tuple[1]\n\n tokenSetBuilder.insert(term)\n invertedIndex[term] = posting\n }\n\n tokenSetBuilder.finish()\n\n attrs.fields = serializedIndex.fields\n\n attrs.fieldVectors = fieldVectors\n attrs.invertedIndex = invertedIndex\n attrs.tokenSet = tokenSetBuilder.root\n attrs.pipeline = pipeline\n\n return new lunr.Index(attrs)\n}\n/*!\n * lunr.Builder\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Builder performs indexing on a set of documents and\n * returns instances of lunr.Index ready for querying.\n *\n * All configuration of the index is done via the builder, the\n * fields to index, the document reference, the text processing\n * pipeline and document scoring parameters are all set on the\n * builder before indexing.\n *\n * @constructor\n * @property {string} _ref - Internal reference to the document reference field.\n * @property {string[]} _fields - Internal reference to the document fields to index.\n * @property {object} invertedIndex - The inverted index maps terms to document fields.\n * @property {object} documentTermFrequencies - Keeps track of document term frequencies.\n * @property {object} documentLengths - Keeps track of the length of documents added to the index.\n * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing.\n * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing.\n * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index.\n * @property {number} documentCount - Keeps track of the total number of documents indexed.\n * @property {number} _b - A parameter to control field length normalization, setting this to 0 disabled normalization, 1 fully normalizes field lengths, the default value is 0.75.\n * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2.\n * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space.\n * @property {array} metadataWhitelist - A list of metadata keys that have been whitelisted for entry in the index.\n */\nlunr.Builder = function () {\n this._ref = \"id\"\n this._fields = Object.create(null)\n this._documents = Object.create(null)\n this.invertedIndex = Object.create(null)\n this.fieldTermFrequencies = {}\n this.fieldLengths = {}\n this.tokenizer = lunr.tokenizer\n this.pipeline = new lunr.Pipeline\n this.searchPipeline = new lunr.Pipeline\n this.documentCount = 0\n this._b = 0.75\n this._k1 = 1.2\n this.termIndex = 0\n this.metadataWhitelist = []\n}\n\n/**\n * Sets the document field used as the document reference. Every document must have this field.\n * The type of this field in the document should be a string, if it is not a string it will be\n * coerced into a string by calling toString.\n *\n * The default ref is 'id'.\n *\n * The ref should _not_ be changed during indexing, it should be set before any documents are\n * added to the index. Changing it during indexing can lead to inconsistent results.\n *\n * @param {string} ref - The name of the reference field in the document.\n */\nlunr.Builder.prototype.ref = function (ref) {\n this._ref = ref\n}\n\n/**\n * A function that is used to extract a field from a document.\n *\n * Lunr expects a field to be at the top level of a document, if however the field\n * is deeply nested within a document an extractor function can be used to extract\n * the right field for indexing.\n *\n * @callback fieldExtractor\n * @param {object} doc - The document being added to the index.\n * @returns {?(string|object|object[])} obj - The object that will be indexed for this field.\n * @example Extracting a nested field\n * function (doc) { return doc.nested.field }\n */\n\n/**\n * Adds a field to the list of document fields that will be indexed. Every document being\n * indexed should have this field. Null values for this field in indexed documents will\n * not cause errors but will limit the chance of that document being retrieved by searches.\n *\n * All fields should be added before adding documents to the index. Adding fields after\n * a document has been indexed will have no effect on already indexed documents.\n *\n * Fields can be boosted at build time. This allows terms within that field to have more\n * importance when ranking search results. Use a field boost to specify that matches within\n * one field are more important than other fields.\n *\n * @param {string} fieldName - The name of a field to index in all documents.\n * @param {object} attributes - Optional attributes associated with this field.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this field.\n * @param {fieldExtractor} [attributes.extractor] - Function to extract a field from a document.\n * @throws {RangeError} fieldName cannot contain unsupported characters '/'\n */\nlunr.Builder.prototype.field = function (fieldName, attributes) {\n if (/\\//.test(fieldName)) {\n throw new RangeError (\"Field '\" + fieldName + \"' contains illegal character '/'\")\n }\n\n this._fields[fieldName] = attributes || {}\n}\n\n/**\n * A parameter to tune the amount of field length normalisation that is applied when\n * calculating relevance scores. A value of 0 will completely disable any normalisation\n * and a value of 1 will fully normalise field lengths. The default is 0.75. Values of b\n * will be clamped to the range 0 - 1.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.b = function (number) {\n if (number < 0) {\n this._b = 0\n } else if (number > 1) {\n this._b = 1\n } else {\n this._b = number\n }\n}\n\n/**\n * A parameter that controls the speed at which a rise in term frequency results in term\n * frequency saturation. The default value is 1.2. Setting this to a higher value will give\n * slower saturation levels, a lower value will result in quicker saturation.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.k1 = function (number) {\n this._k1 = number\n}\n\n/**\n * Adds a document to the index.\n *\n * Before adding fields to the index the index should have been fully setup, with the document\n * ref and all fields to index already having been specified.\n *\n * The document must have a field name as specified by the ref (by default this is 'id') and\n * it should have all fields defined for indexing, though null or undefined values will not\n * cause errors.\n *\n * Entire documents can be boosted at build time. Applying a boost to a document indicates that\n * this document should rank higher in search results than other documents.\n *\n * @param {object} doc - The document to add to the index.\n * @param {object} attributes - Optional attributes associated with this document.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this document.\n */\nlunr.Builder.prototype.add = function (doc, attributes) {\n var docRef = doc[this._ref],\n fields = Object.keys(this._fields)\n\n this._documents[docRef] = attributes || {}\n this.documentCount += 1\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i],\n extractor = this._fields[fieldName].extractor,\n field = extractor ? extractor(doc) : doc[fieldName],\n tokens = this.tokenizer(field, {\n fields: [fieldName]\n }),\n terms = this.pipeline.run(tokens),\n fieldRef = new lunr.FieldRef (docRef, fieldName),\n fieldTerms = Object.create(null)\n\n this.fieldTermFrequencies[fieldRef] = fieldTerms\n this.fieldLengths[fieldRef] = 0\n\n // store the length of this field for this document\n this.fieldLengths[fieldRef] += terms.length\n\n // calculate term frequencies for this field\n for (var j = 0; j < terms.length; j++) {\n var term = terms[j]\n\n if (fieldTerms[term] == undefined) {\n fieldTerms[term] = 0\n }\n\n fieldTerms[term] += 1\n\n // add to inverted index\n // create an initial posting if one doesn't exist\n if (this.invertedIndex[term] == undefined) {\n var posting = Object.create(null)\n posting[\"_index\"] = this.termIndex\n this.termIndex += 1\n\n for (var k = 0; k < fields.length; k++) {\n posting[fields[k]] = Object.create(null)\n }\n\n this.invertedIndex[term] = posting\n }\n\n // add an entry for this term/fieldName/docRef to the invertedIndex\n if (this.invertedIndex[term][fieldName][docRef] == undefined) {\n this.invertedIndex[term][fieldName][docRef] = Object.create(null)\n }\n\n // store all whitelisted metadata about this token in the\n // inverted index\n for (var l = 0; l < this.metadataWhitelist.length; l++) {\n var metadataKey = this.metadataWhitelist[l],\n metadata = term.metadata[metadataKey]\n\n if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) {\n this.invertedIndex[term][fieldName][docRef][metadataKey] = []\n }\n\n this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata)\n }\n }\n\n }\n}\n\n/**\n * Calculates the average document length for this index\n *\n * @private\n */\nlunr.Builder.prototype.calculateAverageFieldLengths = function () {\n\n var fieldRefs = Object.keys(this.fieldLengths),\n numberOfFields = fieldRefs.length,\n accumulator = {},\n documentsWithField = {}\n\n for (var i = 0; i < numberOfFields; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n field = fieldRef.fieldName\n\n documentsWithField[field] || (documentsWithField[field] = 0)\n documentsWithField[field] += 1\n\n accumulator[field] || (accumulator[field] = 0)\n accumulator[field] += this.fieldLengths[fieldRef]\n }\n\n var fields = Object.keys(this._fields)\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i]\n accumulator[fieldName] = accumulator[fieldName] / documentsWithField[fieldName]\n }\n\n this.averageFieldLength = accumulator\n}\n\n/**\n * Builds a vector space model of every document using lunr.Vector\n *\n * @private\n */\nlunr.Builder.prototype.createFieldVectors = function () {\n var fieldVectors = {},\n fieldRefs = Object.keys(this.fieldTermFrequencies),\n fieldRefsLength = fieldRefs.length,\n termIdfCache = Object.create(null)\n\n for (var i = 0; i < fieldRefsLength; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n fieldName = fieldRef.fieldName,\n fieldLength = this.fieldLengths[fieldRef],\n fieldVector = new lunr.Vector,\n termFrequencies = this.fieldTermFrequencies[fieldRef],\n terms = Object.keys(termFrequencies),\n termsLength = terms.length\n\n\n var fieldBoost = this._fields[fieldName].boost || 1,\n docBoost = this._documents[fieldRef.docRef].boost || 1\n\n for (var j = 0; j < termsLength; j++) {\n var term = terms[j],\n tf = termFrequencies[term],\n termIndex = this.invertedIndex[term]._index,\n idf, score, scoreWithPrecision\n\n if (termIdfCache[term] === undefined) {\n idf = lunr.idf(this.invertedIndex[term], this.documentCount)\n termIdfCache[term] = idf\n } else {\n idf = termIdfCache[term]\n }\n\n score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (fieldLength / this.averageFieldLength[fieldName])) + tf)\n score *= fieldBoost\n score *= docBoost\n scoreWithPrecision = Math.round(score * 1000) / 1000\n // Converts 1.23456789 to 1.234.\n // Reducing the precision so that the vectors take up less\n // space when serialised. Doing it now so that they behave\n // the same before and after serialisation. Also, this is\n // the fastest approach to reducing a number's precision in\n // JavaScript.\n\n fieldVector.insert(termIndex, scoreWithPrecision)\n }\n\n fieldVectors[fieldRef] = fieldVector\n }\n\n this.fieldVectors = fieldVectors\n}\n\n/**\n * Creates a token set of all tokens in the index using lunr.TokenSet\n *\n * @private\n */\nlunr.Builder.prototype.createTokenSet = function () {\n this.tokenSet = lunr.TokenSet.fromArray(\n Object.keys(this.invertedIndex).sort()\n )\n}\n\n/**\n * Builds the index, creating an instance of lunr.Index.\n *\n * This completes the indexing process and should only be called\n * once all documents have been added to the index.\n *\n * @returns {lunr.Index}\n */\nlunr.Builder.prototype.build = function () {\n this.calculateAverageFieldLengths()\n this.createFieldVectors()\n this.createTokenSet()\n\n return new lunr.Index({\n invertedIndex: this.invertedIndex,\n fieldVectors: this.fieldVectors,\n tokenSet: this.tokenSet,\n fields: Object.keys(this._fields),\n pipeline: this.searchPipeline\n })\n}\n\n/**\n * Applies a plugin to the index builder.\n *\n * A plugin is a function that is called with the index builder as its context.\n * Plugins can be used to customise or extend the behaviour of the index\n * in some way. A plugin is just a function, that encapsulated the custom\n * behaviour that should be applied when building the index.\n *\n * The plugin function will be called with the index builder as its argument, additional\n * arguments can also be passed when calling use. The function will be called\n * with the index builder as its context.\n *\n * @param {Function} plugin The plugin to apply.\n */\nlunr.Builder.prototype.use = function (fn) {\n var args = Array.prototype.slice.call(arguments, 1)\n args.unshift(this)\n fn.apply(this, args)\n}\n/**\n * Contains and collects metadata about a matching document.\n * A single instance of lunr.MatchData is returned as part of every\n * lunr.Index~Result.\n *\n * @constructor\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n * @property {object} metadata - A cloned collection of metadata associated with this document.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData = function (term, field, metadata) {\n var clonedMetadata = Object.create(null),\n metadataKeys = Object.keys(metadata || {})\n\n // Cloning the metadata to prevent the original\n // being mutated during match data combination.\n // Metadata is kept in an array within the inverted\n // index so cloning the data can be done with\n // Array#slice\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n clonedMetadata[key] = metadata[key].slice()\n }\n\n this.metadata = Object.create(null)\n\n if (term !== undefined) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = clonedMetadata\n }\n}\n\n/**\n * An instance of lunr.MatchData will be created for every term that matches a\n * document. However only one instance is required in a lunr.Index~Result. This\n * method combines metadata from another instance of lunr.MatchData with this\n * objects metadata.\n *\n * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData.prototype.combine = function (otherMatchData) {\n var terms = Object.keys(otherMatchData.metadata)\n\n for (var i = 0; i < terms.length; i++) {\n var term = terms[i],\n fields = Object.keys(otherMatchData.metadata[term])\n\n if (this.metadata[term] == undefined) {\n this.metadata[term] = Object.create(null)\n }\n\n for (var j = 0; j < fields.length; j++) {\n var field = fields[j],\n keys = Object.keys(otherMatchData.metadata[term][field])\n\n if (this.metadata[term][field] == undefined) {\n this.metadata[term][field] = Object.create(null)\n }\n\n for (var k = 0; k < keys.length; k++) {\n var key = keys[k]\n\n if (this.metadata[term][field][key] == undefined) {\n this.metadata[term][field][key] = otherMatchData.metadata[term][field][key]\n } else {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key])\n }\n\n }\n }\n }\n}\n\n/**\n * Add metadata for a term/field pair to this instance of match data.\n *\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n */\nlunr.MatchData.prototype.add = function (term, field, metadata) {\n if (!(term in this.metadata)) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = metadata\n return\n }\n\n if (!(field in this.metadata[term])) {\n this.metadata[term][field] = metadata\n return\n }\n\n var metadataKeys = Object.keys(metadata)\n\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n\n if (key in this.metadata[term][field]) {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key])\n } else {\n this.metadata[term][field][key] = metadata[key]\n }\n }\n}\n/**\n * A lunr.Query provides a programmatic way of defining queries to be performed\n * against a {@link lunr.Index}.\n *\n * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method\n * so the query object is pre-initialized with the right index fields.\n *\n * @constructor\n * @property {lunr.Query~Clause[]} clauses - An array of query clauses.\n * @property {string[]} allFields - An array of all available fields in a lunr.Index.\n */\nlunr.Query = function (allFields) {\n this.clauses = []\n this.allFields = allFields\n}\n\n/**\n * Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause.\n *\n * This allows wildcards to be added to the beginning and end of a term without having to manually do any string\n * concatenation.\n *\n * The wildcard constants can be bitwise combined to select both leading and trailing wildcards.\n *\n * @constant\n * @default\n * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour\n * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists\n * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with trailing wildcard\n * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })\n * @example query term with leading and trailing wildcard\n * query.term('foo', {\n * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING\n * })\n */\n\nlunr.Query.wildcard = new String (\"*\")\nlunr.Query.wildcard.NONE = 0\nlunr.Query.wildcard.LEADING = 1\nlunr.Query.wildcard.TRAILING = 2\n\n/**\n * Constants for indicating what kind of presence a term must have in matching documents.\n *\n * @constant\n * @enum {number}\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with required presence\n * query.term('foo', { presence: lunr.Query.presence.REQUIRED })\n */\nlunr.Query.presence = {\n /**\n * Term's presence in a document is optional, this is the default value.\n */\n OPTIONAL: 1,\n\n /**\n * Term's presence in a document is required, documents that do not contain\n * this term will not be returned.\n */\n REQUIRED: 2,\n\n /**\n * Term's presence in a document is prohibited, documents that do contain\n * this term will not be returned.\n */\n PROHIBITED: 3\n}\n\n/**\n * A single clause in a {@link lunr.Query} contains a term and details on how to\n * match that term against a {@link lunr.Index}.\n *\n * @typedef {Object} lunr.Query~Clause\n * @property {string[]} fields - The fields in an index this clause should be matched against.\n * @property {number} [boost=1] - Any boost that should be applied when matching this clause.\n * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be.\n * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline.\n * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended.\n * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents.\n */\n\n/**\n * Adds a {@link lunr.Query~Clause} to this query.\n *\n * Unless the clause contains the fields to be matched all fields will be matched. In addition\n * a default boost of 1 is applied to the clause.\n *\n * @param {lunr.Query~Clause} clause - The clause to add to this query.\n * @see lunr.Query~Clause\n * @returns {lunr.Query}\n */\nlunr.Query.prototype.clause = function (clause) {\n if (!('fields' in clause)) {\n clause.fields = this.allFields\n }\n\n if (!('boost' in clause)) {\n clause.boost = 1\n }\n\n if (!('usePipeline' in clause)) {\n clause.usePipeline = true\n }\n\n if (!('wildcard' in clause)) {\n clause.wildcard = lunr.Query.wildcard.NONE\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) {\n clause.term = \"*\" + clause.term\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) {\n clause.term = \"\" + clause.term + \"*\"\n }\n\n if (!('presence' in clause)) {\n clause.presence = lunr.Query.presence.OPTIONAL\n }\n\n this.clauses.push(clause)\n\n return this\n}\n\n/**\n * A negated query is one in which every clause has a presence of\n * prohibited. These queries require some special processing to return\n * the expected results.\n *\n * @returns boolean\n */\nlunr.Query.prototype.isNegated = function () {\n for (var i = 0; i < this.clauses.length; i++) {\n if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause}\n * to the list of clauses that make up this query.\n *\n * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion\n * to a token or token-like string should be done before calling this method.\n *\n * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an\n * array, each term in the array will share the same options.\n *\n * @param {object|object[]} term - The term(s) to add to the query.\n * @param {object} [options] - Any additional properties to add to the query clause.\n * @returns {lunr.Query}\n * @see lunr.Query#clause\n * @see lunr.Query~Clause\n * @example adding a single term to a query\n * query.term(\"foo\")\n * @example adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard\n * query.term(\"foo\", {\n * fields: [\"title\"],\n * boost: 10,\n * wildcard: lunr.Query.wildcard.TRAILING\n * })\n * @example using lunr.tokenizer to convert a string to tokens before using them as terms\n * query.term(lunr.tokenizer(\"foo bar\"))\n */\nlunr.Query.prototype.term = function (term, options) {\n if (Array.isArray(term)) {\n term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)\n return this\n }\n\n var clause = options || {}\n clause.term = term.toString()\n\n this.clause(clause)\n\n return this\n}\nlunr.QueryParseError = function (message, start, end) {\n this.name = \"QueryParseError\"\n this.message = message\n this.start = start\n this.end = end\n}\n\nlunr.QueryParseError.prototype = new Error\nlunr.QueryLexer = function (str) {\n this.lexemes = []\n this.str = str\n this.length = str.length\n this.pos = 0\n this.start = 0\n this.escapeCharPositions = []\n}\n\nlunr.QueryLexer.prototype.run = function () {\n var state = lunr.QueryLexer.lexText\n\n while (state) {\n state = state(this)\n }\n}\n\nlunr.QueryLexer.prototype.sliceString = function () {\n var subSlices = [],\n sliceStart = this.start,\n sliceEnd = this.pos\n\n for (var i = 0; i < this.escapeCharPositions.length; i++) {\n sliceEnd = this.escapeCharPositions[i]\n subSlices.push(this.str.slice(sliceStart, sliceEnd))\n sliceStart = sliceEnd + 1\n }\n\n subSlices.push(this.str.slice(sliceStart, this.pos))\n this.escapeCharPositions.length = 0\n\n return subSlices.join('')\n}\n\nlunr.QueryLexer.prototype.emit = function (type) {\n this.lexemes.push({\n type: type,\n str: this.sliceString(),\n start: this.start,\n end: this.pos\n })\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.escapeCharacter = function () {\n this.escapeCharPositions.push(this.pos - 1)\n this.pos += 1\n}\n\nlunr.QueryLexer.prototype.next = function () {\n if (this.pos >= this.length) {\n return lunr.QueryLexer.EOS\n }\n\n var char = this.str.charAt(this.pos)\n this.pos += 1\n return char\n}\n\nlunr.QueryLexer.prototype.width = function () {\n return this.pos - this.start\n}\n\nlunr.QueryLexer.prototype.ignore = function () {\n if (this.start == this.pos) {\n this.pos += 1\n }\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.backup = function () {\n this.pos -= 1\n}\n\nlunr.QueryLexer.prototype.acceptDigitRun = function () {\n var char, charCode\n\n do {\n char = this.next()\n charCode = char.charCodeAt(0)\n } while (charCode > 47 && charCode < 58)\n\n if (char != lunr.QueryLexer.EOS) {\n this.backup()\n }\n}\n\nlunr.QueryLexer.prototype.more = function () {\n return this.pos < this.length\n}\n\nlunr.QueryLexer.EOS = 'EOS'\nlunr.QueryLexer.FIELD = 'FIELD'\nlunr.QueryLexer.TERM = 'TERM'\nlunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE'\nlunr.QueryLexer.BOOST = 'BOOST'\nlunr.QueryLexer.PRESENCE = 'PRESENCE'\n\nlunr.QueryLexer.lexField = function (lexer) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.FIELD)\n lexer.ignore()\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexTerm = function (lexer) {\n if (lexer.width() > 1) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.TERM)\n }\n\n lexer.ignore()\n\n if (lexer.more()) {\n return lunr.QueryLexer.lexText\n }\n}\n\nlunr.QueryLexer.lexEditDistance = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.EDIT_DISTANCE)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexBoost = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.BOOST)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexEOS = function (lexer) {\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n}\n\n// This matches the separator used when tokenising fields\n// within a document. These should match otherwise it is\n// not possible to search for some tokens within a document.\n//\n// It is possible for the user to change the separator on the\n// tokenizer so it _might_ clash with any other of the special\n// characters already used within the search string, e.g. :.\n//\n// This means that it is possible to change the separator in\n// such a way that makes some words unsearchable using a search\n// string.\nlunr.QueryLexer.termSeparator = lunr.tokenizer.separator\n\nlunr.QueryLexer.lexText = function (lexer) {\n while (true) {\n var char = lexer.next()\n\n if (char == lunr.QueryLexer.EOS) {\n return lunr.QueryLexer.lexEOS\n }\n\n // Escape character is '\\'\n if (char.charCodeAt(0) == 92) {\n lexer.escapeCharacter()\n continue\n }\n\n if (char == \":\") {\n return lunr.QueryLexer.lexField\n }\n\n if (char == \"~\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexEditDistance\n }\n\n if (char == \"^\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexBoost\n }\n\n // \"+\" indicates term presence is required\n // checking for length to ensure that only\n // leading \"+\" are considered\n if (char == \"+\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n // \"-\" indicates term presence is prohibited\n // checking for length to ensure that only\n // leading \"-\" are considered\n if (char == \"-\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n if (char.match(lunr.QueryLexer.termSeparator)) {\n return lunr.QueryLexer.lexTerm\n }\n }\n}\n\nlunr.QueryParser = function (str, query) {\n this.lexer = new lunr.QueryLexer (str)\n this.query = query\n this.currentClause = {}\n this.lexemeIdx = 0\n}\n\nlunr.QueryParser.prototype.parse = function () {\n this.lexer.run()\n this.lexemes = this.lexer.lexemes\n\n var state = lunr.QueryParser.parseClause\n\n while (state) {\n state = state(this)\n }\n\n return this.query\n}\n\nlunr.QueryParser.prototype.peekLexeme = function () {\n return this.lexemes[this.lexemeIdx]\n}\n\nlunr.QueryParser.prototype.consumeLexeme = function () {\n var lexeme = this.peekLexeme()\n this.lexemeIdx += 1\n return lexeme\n}\n\nlunr.QueryParser.prototype.nextClause = function () {\n var completedClause = this.currentClause\n this.query.clause(completedClause)\n this.currentClause = {}\n}\n\nlunr.QueryParser.parseClause = function (parser) {\n var lexeme = parser.peekLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.type) {\n case lunr.QueryLexer.PRESENCE:\n return lunr.QueryParser.parsePresence\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expected either a field or a term, found \" + lexeme.type\n\n if (lexeme.str.length >= 1) {\n errorMessage += \" with value '\" + lexeme.str + \"'\"\n }\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n}\n\nlunr.QueryParser.parsePresence = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.str) {\n case \"-\":\n parser.currentClause.presence = lunr.Query.presence.PROHIBITED\n break\n case \"+\":\n parser.currentClause.presence = lunr.Query.presence.REQUIRED\n break\n default:\n var errorMessage = \"unrecognised presence operator'\" + lexeme.str + \"'\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term or field, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term or field, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseField = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n if (parser.query.allFields.indexOf(lexeme.str) == -1) {\n var possibleFields = parser.query.allFields.map(function (f) { return \"'\" + f + \"'\" }).join(', '),\n errorMessage = \"unrecognised field '\" + lexeme.str + \"', possible fields: \" + possibleFields\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.fields = [lexeme.str]\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseTerm = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n parser.currentClause.term = lexeme.str.toLowerCase()\n\n if (lexeme.str.indexOf(\"*\") != -1) {\n parser.currentClause.usePipeline = false\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseEditDistance = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var editDistance = parseInt(lexeme.str, 10)\n\n if (isNaN(editDistance)) {\n var errorMessage = \"edit distance must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.editDistance = editDistance\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseBoost = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var boost = parseInt(lexeme.str, 10)\n\n if (isNaN(boost)) {\n var errorMessage = \"boost must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.boost = boost\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\n /**\n * export the module via AMD, CommonJS or as a browser global\n * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js\n */\n ;(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(factory)\n } else if (typeof exports === 'object') {\n /**\n * Node. Does not work with strict CommonJS, but\n * only CommonJS-like enviroments that support module.exports,\n * like Node.\n */\n module.exports = factory()\n } else {\n // Browser globals (root is window)\n root.lunr = factory()\n }\n }(this, function () {\n /**\n * Just return a value to define the module export.\n * This example returns an object, but the module\n * can return a function as the exported value.\n */\n return lunr\n }))\n})();\n"],"names":["global","step2list","step3list","v","C","re_mgr0","re_mgr1","re_meq1","re_s_v","re_1a","re2_1a","re_1b","re2_1b","re_1b_2","re2_1b_2","re3_1b_2","re4_1b_2","re_1c","re_2","re_3","re_4","re2_4","re_5","re_5_1","re3_5","porterStemmer","root","factory","lunr","config","builder","Builder","pipeline","add","trimmer","stopWordFilter","stemmer","searchPipeline","call","build","version","utils","warn","this","message","console","asString","obj","toString","clone","Object","create","keys","i","length","key","val","Array","isArray","slice","TypeError","FieldRef","docRef","fieldName","stringValue","_stringValue","joiner","fromString","s","n","indexOf","fieldRef","prototype","undefined","Set","elements","complete","intersect","other","union","contains","empty","object","a","b","intersection","element","push","concat","idf","posting","documentCount","documentsWithTerm","x","Math","log","abs","Token","str","metadata","update","fn","tokenizer","map","t","toLowerCase","len","tokens","sliceEnd","sliceStart","sliceLength","charAt","match","separator","tokenMetadata","Pipeline","_stack","registeredFunctions","registerFunction","label","warnIfFunctionNotRegistered","load","serialised","forEach","fnName","Error","fns","arguments","after","existingFn","newFn","pos","splice","before","remove","run","stackLength","memo","j","result","k","runString","token","reset","toJSON","Vector","_magnitude","positionForIndex","index","start","end","pivotPoint","floor","pivotIndex","insert","insertIdx","upsert","position","magnitude","sumOfSquares","elementsLength","sqrt","dot","otherVector","dotProduct","aLen","bLen","aVal","bVal","similarity","toArray","output","c","RegExp","w","stem","suffix","firstch","re","re2","re3","re4","substr","toUpperCase","test","replace","fp","exec","generateStopWordFilter","stopWords","words","reduce","stopWord","TokenSet","final","edges","id","_nextId","fromArray","arr","finish","fromClause","clause","fromFuzzyString","term","editDistance","stack","node","editsRemaining","frame","pop","noEditNode","char","insertionNode","substitutionNode","transposeNode","charA","charB","next","prefix","edge","_str","labels","sort","qNode","qEdges","qLen","nEdges","nLen","q","qEdge","nEdge","previousWord","uncheckedNodes","minimizedNodes","word","commonPrefix","minimize","child","nextNode","parent","downTo","childKey","Index","attrs","invertedIndex","fieldVectors","tokenSet","fields","search","queryString","query","QueryParser","parse","Query","matchingFields","queryVectors","termFieldCache","requiredMatches","prohibitedMatches","clauses","terms","clauseMatches","usePipeline","m","termTokenSet","expandedTerms","presence","REQUIRED","field","expandedTerm","termIndex","_index","fieldPosting","matchingDocumentRefs","termField","matchingDocumentsSet","PROHIBITED","boost","l","fieldMatch","matchingDocumentRef","matchingFieldRef","MatchData","allRequiredMatches","allProhibitedMatches","matchingFieldRefs","results","matches","isNegated","docMatch","fieldVector","score","matchData","combine","ref","serializedIndex","serializedVectors","serializedInvertedIndex","tokenSetBuilder","tuple","_ref","_fields","_documents","fieldTermFrequencies","fieldLengths","_b","_k1","metadataWhitelist","attributes","RangeError","number","k1","doc","extractor","fieldTerms","metadataKey","calculateAverageFieldLengths","fieldRefs","numberOfFields","accumulator","documentsWithField","averageFieldLength","createFieldVectors","fieldRefsLength","termIdfCache","fieldLength","termFrequencies","termsLength","fieldBoost","docBoost","scoreWithPrecision","tf","round","createTokenSet","use","args","unshift","apply","clonedMetadata","metadataKeys","otherMatchData","allFields","wildcard","String","NONE","LEADING","TRAILING","OPTIONAL","options","QueryParseError","name","QueryLexer","lexemes","escapeCharPositions","state","lexText","sliceString","subSlices","join","emit","type","escapeCharacter","EOS","width","ignore","backup","acceptDigitRun","charCode","charCodeAt","more","FIELD","TERM","EDIT_DISTANCE","BOOST","PRESENCE","lexField","lexer","lexTerm","lexEditDistance","lexBoost","lexEOS","termSeparator","currentClause","lexemeIdx","parseClause","peekLexeme","consumeLexeme","lexeme","nextClause","completedClause","parser","parsePresence","parseField","parseTerm","errorMessage","nextLexeme","possibleFields","f","parseEditDistance","parseBoost","parseInt","isNaN","define","amd","exports","module"],"mappings":";;;;;CAaC,eAqE4BA,OAw2BvBC,UAwBFC,UAWAC,EACAC,EAQEC,QACAC,QACAC,QACAC,OAEAC,MACAC,OACAC,MACAC,OACAC,QACAC,SACAC,SACAC,SAEAC,MACAC,KAEAC,KAEAC,KACAC,MAEAC,KACAC,OACAC,MAEAC,cAk4EQC,KAAMC,QAp1GhBC,KAAO,SAAUC,YACfC,QAAU,IAAIF,KAAKG,eAEv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AG,IAClBP,IAAM7K,SACEkL,KAAKT,QACXD,EAAIC,QAKRG,GAAK5J,MACEkK,KAAKV,KAEVC,MADIW,GAAKR,GAAGS,KAAKb,IACP,GAEVK,IAAM5K,QACN6K,IAAM5J,QAFN0J,GAAK5K,SAGEkL,KAAKT,OAAUI,IAAIK,KAAKT,QAAWK,IAAII,KAAKT,SACjDD,EAAIC,OAKRI,IAAM7K,SADN4K,GAAK3J,QAEEiK,KAAKV,IAAMK,IAAIK,KAAKV,KACzBI,GAAKrK,QACLiK,EAAIA,EAAEW,QAAQP,GAAG,KAKJ,KAAXD,UACFH,EAAIG,QAAQxE,cAAgBqE,EAAEQ,OAAO,IAGhCR,GAGF,SAAUhC,cACRA,MAAM1C,OAAO3E,iBAIxBG,KAAKuF,SAASG,iBAAiB1F,KAAKQ,QAAS,WAmB7CR,KAAKgK,uBAAyB,SAAUC,eAClCC,MAAQD,UAAUE,QAAO,SAAUtD,KAAMuD,iBAC3CvD,KAAKuD,UAAYA,SACVvD,OACN,WAEI,SAAUK,UACXA,OAASgD,MAAMhD,MAAM9F,cAAgB8F,MAAM9F,WAAY,OAAO8F,QAiBtElH,KAAKO,eAAiBP,KAAKgK,uBAAuB,CAChD,IACA,OACA,QACA,SACA,QACA,MACA,SACA,OACA,KACA,QACA,KACA,MACA,MACA,MACA,KACA,KACA,KACA,UACA,OACA,MACA,KACA,MACA,SACA,QACA,OACA,MACA,KACA,OACA,SACA,OACA,OACA,QACA,MACA,OACA,MACA,MACA,MACA,MACA,OACA,KACA,MACA,OACA,MACA,MACA,MACA,UACA,IACA,KACA,KACA,OACA,KACA,KACA,MACA,OACA,QACA,MACA,OACA,SACA,MACA,KACA,QACA,OACA,OACA,KACA,UACA,KACA,MACA,MACA,KACA,MACA,QACA,KACA,OACA,KACA,QACA,MACA,MACA,SACA,OACA,MACA,OACA,MACA,SACA,QACA,KACA,OACA,OACA,OACA,MACA,QACA,OACA,OACA,QACA,QACA,OACA,OACA,MACA,KACA,MACA,OACA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lS,IAAK,OAE7BgT,MAAM5H,OAAQ,KACZqH,aAAe,8BACb,IAAI/W,KAAKkU,gBAAiB6C,aAAcP,OAAO/O,MAAO+O,OAAO9O,KAGrEiP,OAAOR,cAAczG,MAAQA,UAEzBsH,WAAaL,OAAOL,gBAENzT,MAAdmU,kBAKIA,WAAWnC,WACZ7U,KAAKoU,WAAWoB,YACnBmB,OAAOF,aACAzW,KAAKgO,YAAY8I,eACrB9W,KAAKoU,WAAWmB,aACnBoB,OAAOF,aACAzW,KAAKgO,YAAY6I,gBACrB7W,KAAKoU,WAAWqB,qBACZzV,KAAKgO,YAAYmJ,uBACrBnX,KAAKoU,WAAWsB,aACZ1V,KAAKgO,YAAYoJ,gBACrBpX,KAAKoU,WAAWuB,gBACnBgB,OAAOF,aACAzW,KAAKgO,YAAY4I,sBAEpBG,aAAe,2BAA6BC,WAAWnC,KAAO,UAC5D,IAAI7U,KAAKkU,gBAAiB6C,aAAcC,WAAWvP,MAAOuP,WAAWtP,UApB7EiP,OAAOF,eA4BG3W,KAeViB,KAfgBhB,QAeV,kBAMCC,MApBe,mBAAXuX,QAAyBA,OAAOC,IAEzCD,oCAAOxX,SACqB,iBAAZ0X,QAMhBC,OAAOD,QAAU1X,UAGjBD,KAAKE,KAAOD,UAl4GjB"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/mustache.min.js b/admin/tool/componentlibrary/amd/build/mustache.min.js index 88e2e53d339..571732f1afc 100644 --- a/admin/tool/componentlibrary/amd/build/mustache.min.js +++ b/admin/tool/componentlibrary/amd/build/mustache.min.js @@ -1,2 +1,10 @@ -define ("tool_componentlibrary/mustache",["exports","tool_componentlibrary/selectors","core/ajax","core/config","core/templates","core/log","core/notification"],function(a,b,c,d,e,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.mustache=void 0;b=h(b);c=h(c);d=h(d);e=h(e);f=h(f);g=h(g);function h(a){return a&&a.__esModule?a:{default:a}}function i(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function j(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){i(h,d,e,f,g,"next",a)}function g(a){i(h,d,e,f,g,"throw",a)}f(void 0)})}}var k=function(){var a=j(regeneratorRuntime.mark(function a(c,d,g){var h,i,j,k;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:try{g=JSON.parse(g)}catch(a){f.default.debug("Could not parse json example context for template.");f.default.debug(a)}a.next=3;return e.default.renderForPromise(d,g);case 3:h=a.sent;i=h.html;j=h.js;k=c.querySelector(b.default.mustacherendered);a.next=9;return e.default.replaceNodeContents(k,i,j);case 9:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),l=function(a){var e=a.querySelector(b.default.mustachesource),f=a.querySelector(b.default.mustachecontext),h=a.dataset.template,i=a.querySelector(b.default.mustacherawcontext).textContent,j=h.split("/"),l=j.shift(),m=j.join("/"),n={methodname:"core_output_load_template",args:{component:l,template:m,themename:d.default.theme,includecomments:!0}};c.default.call([n])[0].done(function(b){e.textContent=b;if(!i){var c=b.match(/Example context \(json\):([\s\S]+?)(}})/);i=c[1];var d=document.createElement("pre");d.innerHTML=JSON.stringify(JSON.parse(i),null,4);f.parentNode.appendChild(d);f.classList.add("d-none")}k(a,h,i)}).fail(g.default.exception)},m=function(){document.querySelectorAll(b.default.mustachecode).forEach(function(a){l(a)})};a.mustache=m}); -//# sourceMappingURL=mustache.min.js.map +define("tool_componentlibrary/mustache",["exports","tool_componentlibrary/selectors","core/ajax","core/config","core/templates","core/log","core/notification"],(function(_exports,_selectors,_ajax,_config,_templates,_log,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} +/** + * Render mustache template examples within the component library. + * + * @module tool_componentlibrary/mustache + * @copyright 2021 Bas Brands + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.mustache=void 0,_selectors=_interopRequireDefault(_selectors),_ajax=_interopRequireDefault(_ajax),_config=_interopRequireDefault(_config),_templates=_interopRequireDefault(_templates),_log=_interopRequireDefault(_log),_notification=_interopRequireDefault(_notification);const loadTemplate=container=>{const sourcecontainer=container.querySelector(_selectors.default.mustachesource),contextcontainer=container.querySelector(_selectors.default.mustachecontext),templateName=container.dataset.template;let context=container.querySelector(_selectors.default.mustacherawcontext).textContent;const parts=templateName.split("/"),request={methodname:"core_output_load_template",args:{component:parts.shift(),template:parts.join("/"),themename:_config.default.theme,includecomments:!0}};_ajax.default.call([request])[0].done((source=>{if(sourcecontainer.textContent=source,!context){const example=source.match(/Example context \(json\):([\s\S]+?)(}})/);context=example[1];const precontainer=document.createElement("pre");precontainer.innerHTML=JSON.stringify(JSON.parse(context),null,4),contextcontainer.parentNode.appendChild(precontainer),contextcontainer.classList.add("d-none")}(async(container,templateName,context)=>{try{context=JSON.parse(context)}catch(e){_log.default.debug("Could not parse json example context for template."),_log.default.debug(e)}const{html:html,js:js}=await _templates.default.renderForPromise(templateName,context),rendercontainer=container.querySelector(_selectors.default.mustacherendered);await _templates.default.replaceNodeContents(rendercontainer,html,js)})(container,templateName,context)})).fail(_notification.default.exception)};_exports.mustache=()=>{document.querySelectorAll(_selectors.default.mustachecode).forEach((container=>{loadTemplate(container)}))}})); + +//# sourceMappingURL=mustache.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/mustache.min.js.map b/admin/tool/componentlibrary/amd/build/mustache.min.js.map index a7b69afaf6c..3e3fa85e215 100644 --- a/admin/tool/componentlibrary/amd/build/mustache.min.js.map +++ b/admin/tool/componentlibrary/amd/build/mustache.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/mustache.js"],"names":["renderTemplate","container","templateName","context","JSON","parse","e","Log","debug","Templates","renderForPromise","html","js","rendercontainer","querySelector","selectors","mustacherendered","replaceNodeContents","loadTemplate","sourcecontainer","mustachesource","contextcontainer","mustachecontext","dataset","template","mustacherawcontext","textContent","parts","split","component","shift","name","join","request","methodname","args","themename","Config","theme","includecomments","Ajax","call","done","source","example","match","precontainer","document","createElement","innerHTML","stringify","parentNode","appendChild","classList","add","fail","Notification","exception","mustache","querySelectorAll","mustachecode","forEach"],"mappings":"yQAuBA,OACA,OACA,OACA,OACA,OACA,O,qXAWMA,CAAAA,CAAc,4CAAG,WAAMC,CAAN,CAAiBC,CAAjB,CAA+BC,CAA/B,+FACnB,GAAI,CACAA,CAAO,CAAGC,IAAI,CAACC,KAAL,CAAWF,CAAX,CACb,CAAC,MAAOG,CAAP,CAAU,CACRC,UAAIC,KAAJ,CAAU,oDAAV,EACAD,UAAIC,KAAJ,CAAUF,CAAV,CACH,CANkB,eAQMG,WAAUC,gBAAV,CAA2BR,CAA3B,CAAyCC,CAAzC,CARN,iBAQZQ,CARY,GAQZA,IARY,CAQNC,CARM,GAQNA,EARM,CAUbC,CAVa,CAUKZ,CAAS,CAACa,aAAV,CAAwBC,UAAUC,gBAAlC,CAVL,gBAabP,WAAUQ,mBAAV,CAA8BJ,CAA9B,CAA+CF,CAA/C,CAAqDC,CAArD,CAba,yCAAH,uD,CAuBdM,CAAY,CAAG,SAAAjB,CAAS,CAAI,IACpBkB,CAAAA,CAAe,CAAGlB,CAAS,CAACa,aAAV,CAAwBC,UAAUK,cAAlC,CADE,CAEpBC,CAAgB,CAAGpB,CAAS,CAACa,aAAV,CAAwBC,UAAUO,eAAlC,CAFC,CAGpBpB,CAAY,CAAGD,CAAS,CAACsB,OAAV,CAAkBC,QAHb,CAItBrB,CAAO,CAAGF,CAAS,CAACa,aAAV,CAAwBC,UAAUU,kBAAlC,EAAsDC,WAJ1C,CAMpBC,CAAK,CAAGzB,CAAY,CAAC0B,KAAb,CAAmB,GAAnB,CANY,CAOpBC,CAAS,CAAGF,CAAK,CAACG,KAAN,EAPQ,CAQpBC,CAAI,CAAGJ,CAAK,CAACK,IAAN,CAAW,GAAX,CARa,CAUpBC,CAAO,CAAG,CACZC,UAAU,CAAE,2BADA,CAEZC,IAAI,CAAE,CACFN,SAAS,CAAEA,CADT,CAEFL,QAAQ,CAAEO,CAFR,CAGFK,SAAS,CAAEC,UAAOC,KAHhB,CAIFC,eAAe,GAJb,CAFM,CAVU,CAoB1BC,UAAKC,IAAL,CAAU,CAACR,CAAD,CAAV,EAAqB,CAArB,EACKS,IADL,CACU,SAACC,CAAD,CAAY,CAEdxB,CAAe,CAACO,WAAhB,CAA8BiB,CAA9B,CACA,GAAI,CAACxC,CAAL,CAAc,CACV,GAAMyC,CAAAA,CAAO,CAAGD,CAAM,CAACE,KAAP,CAAa,yCAAb,CAAhB,CACA1C,CAAO,CAAGyC,CAAO,CAAC,CAAD,CAAjB,CAEA,GAAME,CAAAA,CAAY,CAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAArB,CACAF,CAAY,CAACG,SAAb,CAAyB7C,IAAI,CAAC8C,SAAL,CAAe9C,IAAI,CAACC,KAAL,CAAWF,CAAX,CAAf,CAAoC,IAApC,CAA0C,CAA1C,CAAzB,CACAkB,CAAgB,CAAC8B,UAAjB,CAA4BC,WAA5B,CAAwCN,CAAxC,EACAzB,CAAgB,CAACgC,SAAjB,CAA2BC,GAA3B,CAA+B,QAA/B,CACH,CACDtD,CAAc,CAACC,CAAD,CAAYC,CAAZ,CAA0BC,CAA1B,CACjB,CAdL,EAeKoD,IAfL,CAeUC,UAAaC,SAfvB,CAgBP,C,CAOYC,CAAQ,CAAG,UAAM,CAC1BX,QAAQ,CAACY,gBAAT,CAA0B5C,UAAU6C,YAApC,EAAkDC,OAAlD,CAA0D,SAAC5D,CAAD,CAAe,CACrEiB,CAAY,CAACjB,CAAD,CACf,CAFD,CAGH,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 .\n\n/**\n * Render mustache template examples within the component library.\n *\n * @module tool_componentlibrary/mustache\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\nimport Ajax from 'core/ajax';\nimport Config from 'core/config';\nimport Templates from 'core/templates';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\n\n/**\n * Handle a template loaded response.\n *\n * @method\n * @private\n * @param {String} container The template container\n * @param {String} templateName The template name\n * @param {String} context Data for the template.\n */\nconst renderTemplate = async(container, templateName, context) => {\n try {\n context = JSON.parse(context);\n } catch (e) {\n Log.debug('Could not parse json example context for template.');\n Log.debug(e);\n }\n\n const {html, js} = await Templates.renderForPromise(templateName, context);\n\n const rendercontainer = container.querySelector(selectors.mustacherendered);\n\n // Load the rendered content in the renderer tab.\n await Templates.replaceNodeContents(rendercontainer, html, js);\n};\n\n/**\n * Load the a template source from Moodle.\n *\n * @method\n * @private\n * @param {String} container The template container\n */\nconst loadTemplate = container => {\n const sourcecontainer = container.querySelector(selectors.mustachesource);\n const contextcontainer = container.querySelector(selectors.mustachecontext);\n const templateName = container.dataset.template;\n let context = container.querySelector(selectors.mustacherawcontext).textContent;\n\n const parts = templateName.split('/');\n const component = parts.shift();\n const name = parts.join('/');\n\n const request = {\n methodname: 'core_output_load_template',\n args: {\n component: component,\n template: name,\n themename: Config.theme,\n includecomments: true\n }\n };\n\n Ajax.call([request])[0]\n .done((source) => {\n // Load the source template in Template tab.\n sourcecontainer.textContent = source;\n if (!context) {\n const example = source.match(/Example context \\(json\\):([\\s\\S]+?)(}})/);\n context = example[1];\n // Load the variables in the Variables tab.\n const precontainer = document.createElement(\"pre\");\n precontainer.innerHTML = JSON.stringify(JSON.parse(context), null, 4);\n contextcontainer.parentNode.appendChild(precontainer);\n contextcontainer.classList.add('d-none');\n }\n renderTemplate(container, templateName, context);\n })\n .fail(Notification.exception);\n};\n\n/**\n * Initialize the module.\n *\n * @method\n */\nexport const mustache = () => {\n document.querySelectorAll(selectors.mustachecode).forEach((container) => {\n loadTemplate(container);\n });\n};\n"],"file":"mustache.min.js"} \ No newline at end of file +{"version":3,"file":"mustache.min.js","sources":["../src/mustache.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 * Render mustache template examples within the component library.\n *\n * @module tool_componentlibrary/mustache\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\nimport Ajax from 'core/ajax';\nimport Config from 'core/config';\nimport Templates from 'core/templates';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\n\n/**\n * Handle a template loaded response.\n *\n * @method\n * @private\n * @param {String} container The template container\n * @param {String} templateName The template name\n * @param {String} context Data for the template.\n */\nconst renderTemplate = async(container, templateName, context) => {\n try {\n context = JSON.parse(context);\n } catch (e) {\n Log.debug('Could not parse json example context for template.');\n Log.debug(e);\n }\n\n const {html, js} = await Templates.renderForPromise(templateName, context);\n\n const rendercontainer = container.querySelector(selectors.mustacherendered);\n\n // Load the rendered content in the renderer tab.\n await Templates.replaceNodeContents(rendercontainer, html, js);\n};\n\n/**\n * Load the a template source from Moodle.\n *\n * @method\n * @private\n * @param {String} container The template container\n */\nconst loadTemplate = container => {\n const sourcecontainer = container.querySelector(selectors.mustachesource);\n const contextcontainer = container.querySelector(selectors.mustachecontext);\n const templateName = container.dataset.template;\n let context = container.querySelector(selectors.mustacherawcontext).textContent;\n\n const parts = templateName.split('/');\n const component = parts.shift();\n const name = parts.join('/');\n\n const request = {\n methodname: 'core_output_load_template',\n args: {\n component: component,\n template: name,\n themename: Config.theme,\n includecomments: true\n }\n };\n\n Ajax.call([request])[0]\n .done((source) => {\n // Load the source template in Template tab.\n sourcecontainer.textContent = source;\n if (!context) {\n const example = source.match(/Example context \\(json\\):([\\s\\S]+?)(}})/);\n context = example[1];\n // Load the variables in the Variables tab.\n const precontainer = document.createElement(\"pre\");\n precontainer.innerHTML = JSON.stringify(JSON.parse(context), null, 4);\n contextcontainer.parentNode.appendChild(precontainer);\n contextcontainer.classList.add('d-none');\n }\n renderTemplate(container, templateName, context);\n })\n .fail(Notification.exception);\n};\n\n/**\n * Initialize the module.\n *\n * @method\n */\nexport const mustache = () => {\n document.querySelectorAll(selectors.mustachecode).forEach((container) => {\n loadTemplate(container);\n });\n};\n"],"names":["loadTemplate","container","sourcecontainer","querySelector","selectors","mustachesource","contextcontainer","mustachecontext","templateName","dataset","template","context","mustacherawcontext","textContent","parts","split","request","methodname","args","component","shift","join","themename","Config","theme","includecomments","call","done","source","example","match","precontainer","document","createElement","innerHTML","JSON","stringify","parse","parentNode","appendChild","classList","add","async","e","debug","html","js","Templates","renderForPromise","rendercontainer","mustacherendered","replaceNodeContents","renderTemplate","fail","Notification","exception","querySelectorAll","mustachecode","forEach"],"mappings":";;;;;;;0VA8DMA,aAAeC,kBACPC,gBAAkBD,UAAUE,cAAcC,mBAAUC,gBACpDC,iBAAmBL,UAAUE,cAAcC,mBAAUG,iBACrDC,aAAeP,UAAUQ,QAAQC,aACnCC,QAAUV,UAAUE,cAAcC,mBAAUQ,oBAAoBC,kBAE9DC,MAAQN,aAAaO,MAAM,KAI3BC,QAAU,CACZC,WAAY,4BACZC,KAAM,CACFC,UANUL,MAAMM,QAOhBV,SANKI,MAAMO,KAAK,KAOhBC,UAAWC,gBAAOC,MAClBC,iBAAiB,kBAIpBC,KAAK,CAACV,UAAU,GAChBW,MAAMC,YAEH1B,gBAAgBW,YAAce,QACzBjB,QAAS,OACJkB,QAAUD,OAAOE,MAAM,2CAC7BnB,QAAUkB,QAAQ,SAEZE,aAAeC,SAASC,cAAc,OAC5CF,aAAaG,UAAYC,KAAKC,UAAUD,KAAKE,MAAM1B,SAAU,KAAM,GACnEL,iBAAiBgC,WAAWC,YAAYR,cACxCzB,iBAAiBkC,UAAUC,IAAI,UAtD5BC,OAAMzC,UAAWO,aAAcG,eAE9CA,QAAUwB,KAAKE,MAAM1B,SACvB,MAAOgC,gBACDC,MAAM,mEACNA,MAAMD,SAGRE,KAACA,KAADC,GAAOA,UAAYC,mBAAUC,iBAAiBxC,aAAcG,SAE5DsC,gBAAkBhD,UAAUE,cAAcC,mBAAU8C,wBAGpDH,mBAAUI,oBAAoBF,gBAAiBJ,KAAMC,KA2C/CM,CAAenD,UAAWO,aAAcG,YAE3C0C,KAAKC,sBAAaC,8BAQP,KACpBvB,SAASwB,iBAAiBpD,mBAAUqD,cAAcC,SAASzD,YACvDD,aAAaC"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/search.min.js b/admin/tool/componentlibrary/amd/build/search.min.js index 19b9ac47361..94280efb0d9 100644 --- a/admin/tool/componentlibrary/amd/build/search.min.js +++ b/admin/tool/componentlibrary/amd/build/search.min.js @@ -1,2 +1,10 @@ -define ("tool_componentlibrary/search",["exports","tool_componentlibrary/lunr","tool_componentlibrary/selectors","core/log","core/notification","core/key_codes"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.search=void 0;b=g(b);c=g(c);d=g(d);e=g(e);function g(a){return a&&a.__esModule?a:{default:a}}function h(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function i(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var i=a.apply(b,c);function f(a){h(i,d,e,f,g,"next",a)}function g(a){h(i,d,e,f,g,"throw",a)}f(void 0)})}}var j=null,k=null,l=function(){var a=i(regeneratorRuntime.mark(function a(b){var c;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return fetch(b);case 2:c=a.sent;if(!c.ok){d.default.debug("Error getting Hugo index file: ".concat(c.status))}a.next=6;return c.json();case 6:return a.abrupt("return",a.sent);case 7:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),m=function(a){l(a).then(function(a){k=a;j=(0,b.default)(function(){var b=this;this.ref("uri");this.field("title",{boost:10});this.field("content");this.field("tags",{boost:5});a.forEach(function(a){b.add(a)})});return null}).catch(e.default.exception)},n=function(){var a=document.querySelector(c.default.searchinput);a.addEventListener("keyup",function(a){var b=a.currentTarget.value;if(2>b.length){document.querySelector(c.default.dropdownmenu).classList.remove("show");return}p(o(b))});a.addEventListener("keydown",function(b){if(b.keyCode===f.enter){b.preventDefault()}if(b.keyCode===f.escape){a.value=""}})},o=function(a){return j.search(a+" "+a+"*").map(function(a){return k.filter(function(b){return b.uri===a.ref})[0]})},p=function(a){var b=document.querySelector(c.default.dropdownmenu);if(!a.length){b.classList.remove("show");return}b.innerHTML="";var d=M.cfg.wwwroot+"/admin/tool/componentlibrary/docspage.php";a.slice(0,10).forEach(function(a){var c=document.createElement("a"),e=a.uri.split("/")[1];c.appendChild(document.createTextNode("".concat(e," > ").concat(a.title)));c.classList.add("dropdown-item");c.href=d+a.uri;b.appendChild(c)});b.classList.add("show")};a.search=function search(a){m(a);n()}}); -//# sourceMappingURL=search.min.js.map +define("tool_componentlibrary/search",["exports","tool_componentlibrary/lunr","tool_componentlibrary/selectors","core/log","core/notification","core/key_codes"],(function(_exports,_lunr,_selectors,_log,_notification,_key_codes){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} +/** + * Interface to the Lunr search engines. + * + * @module tool_componentlibrary/search + * @copyright 2021 Bas Brands + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.search=void 0,_lunr=_interopRequireDefault(_lunr),_selectors=_interopRequireDefault(_selectors),_log=_interopRequireDefault(_log),_notification=_interopRequireDefault(_notification);let lunrIndex=null,pagesIndex=null;const initLunr=jsonFile=>{(async jsonFile=>{const response=await fetch(jsonFile);return response.ok||_log.default.debug("Error getting Hugo index file: ".concat(response.status)),await response.json()})(jsonFile).then((jsondata=>(pagesIndex=jsondata,lunrIndex=(0,_lunr.default)((function(){this.ref("uri"),this.field("title",{boost:10}),this.field("content"),this.field("tags",{boost:5}),jsondata.forEach((p=>{this.add(p)}))})),null))).catch(_notification.default.exception)},searchIndex=query=>lunrIndex.search(query+" "+query+"*").map((result=>pagesIndex.filter((page=>page.uri===result.ref))[0])),renderResults=results=>{const dropdownMenu=document.querySelector(_selectors.default.dropdownmenu);if(!results.length)return void dropdownMenu.classList.remove("show");dropdownMenu.innerHTML="";const baseUrl=M.cfg.wwwroot+"/admin/tool/componentlibrary/docspage.php";results.slice(0,10).forEach((function(result){const link=document.createElement("a"),chapter=result.uri.split("/")[1];link.appendChild(document.createTextNode("".concat(chapter," > ").concat(result.title))),link.classList.add("dropdown-item"),link.href=baseUrl+result.uri,dropdownMenu.appendChild(link)})),dropdownMenu.classList.add("show")};_exports.search=jsonFile=>{initLunr(jsonFile),(()=>{const searchInput=document.querySelector(_selectors.default.searchinput);searchInput.addEventListener("keyup",(e=>{const query=e.currentTarget.value;query.length<2?document.querySelector(_selectors.default.dropdownmenu).classList.remove("show"):renderResults(searchIndex(query))})),searchInput.addEventListener("keydown",(e=>{e.keyCode===_key_codes.enter&&e.preventDefault(),e.keyCode===_key_codes.escape&&(searchInput.value="")}))})()}})); + +//# sourceMappingURL=search.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/search.min.js.map b/admin/tool/componentlibrary/amd/build/search.min.js.map index b3ff1293d90..82b9e5a4a44 100644 --- a/admin/tool/componentlibrary/amd/build/search.min.js.map +++ b/admin/tool/componentlibrary/amd/build/search.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/search.js"],"names":["lunrIndex","pagesIndex","fetchJson","jsonFile","fetch","response","ok","Log","debug","status","json","initLunr","then","jsondata","ref","field","boost","forEach","p","add","catch","Notification","exception","initUI","searchInput","document","querySelector","selectors","searchinput","addEventListener","e","query","currentTarget","value","length","dropdownmenu","classList","remove","renderResults","searchIndex","keyCode","enter","preventDefault","escape","search","map","result","filter","page","uri","results","dropdownMenu","innerHTML","baseUrl","M","cfg","wwwroot","slice","link","createElement","chapter","split","appendChild","createTextNode","title","href"],"mappings":"sQAuBA,OACA,OACA,OACA,O,qXAGIA,CAAAA,CAAS,CAAG,I,CACZC,CAAU,CAAG,I,CAUXC,CAAS,4CAAG,WAAMC,CAAN,wGACSC,CAAAA,KAAK,CAACD,CAAD,CADd,QACRE,CADQ,QAGd,GAAI,CAACA,CAAQ,CAACC,EAAd,CAAkB,CACdC,UAAIC,KAAJ,0CAA4CH,CAAQ,CAACI,MAArD,EACH,CALa,eAODJ,CAAAA,CAAQ,CAACK,IAAT,EAPC,iFAAH,uD,CAiBTC,CAAQ,CAAG,SAAAR,CAAQ,CAAI,CACzBD,CAAS,CAACC,CAAD,CAAT,CAAoBS,IAApB,CAAyB,SAAAC,CAAQ,CAAI,CACjCZ,CAAU,CAAGY,CAAb,CAEAb,CAAS,CAAG,cAAO,UAAW,YAC1B,KAAKc,GAAL,CAAS,KAAT,EACA,KAAKC,KAAL,CAAW,OAAX,CAAoB,CAACC,KAAK,CAAE,EAAR,CAApB,EACA,KAAKD,KAAL,CAAW,SAAX,EACA,KAAKA,KAAL,CAAW,MAAX,CAAmB,CAACC,KAAK,CAAE,CAAR,CAAnB,EACAH,CAAQ,CAACI,OAAT,CAAiB,SAAAC,CAAC,CAAI,CAClB,CAAI,CAACC,GAAL,CAASD,CAAT,CACH,CAF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G1B,QAAQ,CAACC,aAAT,CAAuBC,UAAUQ,YAAjC,CAArB,CACA,GAAI,CAACe,CAAO,CAAChB,MAAb,CAAqB,CACjBiB,CAAY,CAACf,SAAb,CAAuBC,MAAvB,CAA8B,MAA9B,EACA,MACH,CAGDc,CAAY,CAACC,SAAb,CAAyB,EAAzB,CAEA,GAAMC,CAAAA,CAAO,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,2CAAhC,CAGAN,CAAO,CAACO,KAAR,CAAc,CAAd,CAAiB,EAAjB,EAAqBxC,OAArB,CAA6B,SAAS6B,CAAT,CAAiB,IACpCY,CAAAA,CAAI,CAAGjC,QAAQ,CAACkC,aAAT,CAAuB,GAAvB,CAD6B,CAEpCC,CAAO,CAAGd,CAAM,CAACG,GAAP,CAAWY,KAAX,CAAiB,GAAjB,EAAsB,CAAtB,CAF0B,CAG1CH,CAAI,CAACI,WAAL,CAAiBrC,QAAQ,CAACsC,cAAT,WAA2BH,CAA3B,eAAwCd,CAAM,CAACkB,KAA/C,EAAjB,EACAN,CAAI,CAACtB,SAAL,CAAejB,GAAf,CAAmB,eAAnB,EACAuC,CAAI,CAACO,IAAL,CAAYZ,CAAO,CAAGP,CAAM,CAACG,GAA7B,CAEAE,CAAY,CAACW,WAAb,CAAyBJ,CAAzB,CACH,CARD,EAUAP,CAAY,CAACf,SAAb,CAAuBjB,GAAvB,CAA2B,MAA3B,CACH,C,UAQqB,QAATyB,CAAAA,MAAS,CAAAzC,CAAQ,CAAI,CAC9BQ,CAAQ,CAACR,CAAD,CAAR,CACAoB,CAAM,EACT,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 .\n\n/**\n * Interface to the Lunr search engines.\n *\n * @module tool_componentlibrary/search\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport lunrJs from 'tool_componentlibrary/lunr';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\nimport {enter, escape} from 'core/key_codes';\n\nlet lunrIndex = null;\nlet pagesIndex = null;\n\n/**\n * Get the jsonFile that is generated when the component library is build.\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n * @return {Object}\n */\nconst fetchJson = async(jsonFile) => {\n const response = await fetch(jsonFile);\n\n if (!response.ok) {\n Log.debug(`Error getting Hugo index file: ${response.status}`);\n }\n\n return await response.json();\n};\n\n/**\n * Initiate lunr on the data in the jsonFile and add the jsondata to the pagesIndex\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n */\nconst initLunr = jsonFile => {\n fetchJson(jsonFile).then(jsondata => {\n pagesIndex = jsondata;\n // Using an arrow function here will break lunr on compile.\n lunrIndex = lunrJs(function() {\n this.ref('uri');\n this.field('title', {boost: 10});\n this.field('content');\n this.field('tags', {boost: 5});\n jsondata.forEach(p => {\n this.add(p);\n });\n });\n return null;\n }).catch(Notification.exception);\n};\n\n/**\n * Setup the eventlistener to listen on user input on the search field.\n *\n * @method\n * @private\n */\nconst initUI = () => {\n const searchInput = document.querySelector(selectors.searchinput);\n searchInput.addEventListener('keyup', e => {\n const query = e.currentTarget.value;\n if (query.length < 2) {\n document.querySelector(selectors.dropdownmenu).classList.remove('show');\n return;\n }\n renderResults(searchIndex(query));\n });\n searchInput.addEventListener('keydown', e => {\n if (e.keyCode === enter) {\n e.preventDefault();\n }\n if (e.keyCode === escape) {\n searchInput.value = '';\n }\n });\n};\n\n/**\n * Trigger a search in lunr and transform the result.\n *\n * @method\n * @private\n * @param {String} query\n * @return {Array} results\n */\nconst searchIndex = query => {\n // Find the item in our index corresponding to the lunr one to have more info\n // Lunr result:\n // {ref: \"/section/page1\", score: 0.2725657778206127}\n // Our result:\n // {title:\"Page1\", href:\"/section/page1\", ...}\n\n return lunrIndex.search(query + ' ' + query + '*').map(result => {\n return pagesIndex.filter(page => {\n return page.uri === result.ref;\n })[0];\n });\n};\n\n/**\n * Display the 10 first results\n *\n * @method\n * @private\n * @param {Array} results to display\n */\nconst renderResults = results => {\n const dropdownMenu = document.querySelector(selectors.dropdownmenu);\n if (!results.length) {\n dropdownMenu.classList.remove('show');\n return;\n }\n\n // Clear out the results.\n dropdownMenu.innerHTML = '';\n\n const baseUrl = M.cfg.wwwroot + '/admin/tool/componentlibrary/docspage.php';\n\n // Only show the ten first results\n results.slice(0, 10).forEach(function(result) {\n const link = document.createElement(\"a\");\n const chapter = result.uri.split('/')[1];\n link.appendChild(document.createTextNode(`${chapter} > ${result.title}`));\n link.classList.add('dropdown-item');\n link.href = baseUrl + result.uri;\n\n dropdownMenu.appendChild(link);\n });\n\n dropdownMenu.classList.add('show');\n};\n\n/**\n * Initialize module.\n *\n * @method\n * @param {String} jsonFile Full path to the search DB json file.\n */\nexport const search = jsonFile => {\n initLunr(jsonFile);\n initUI();\n};\n"],"file":"search.min.js"} \ No newline at end of file +{"version":3,"file":"search.min.js","sources":["../src/search.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 * Interface to the Lunr search engines.\n *\n * @module tool_componentlibrary/search\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport lunrJs from 'tool_componentlibrary/lunr';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\nimport {enter, escape} from 'core/key_codes';\n\nlet lunrIndex = null;\nlet pagesIndex = null;\n\n/**\n * Get the jsonFile that is generated when the component library is build.\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n * @return {Object}\n */\nconst fetchJson = async(jsonFile) => {\n const response = await fetch(jsonFile);\n\n if (!response.ok) {\n Log.debug(`Error getting Hugo index file: ${response.status}`);\n }\n\n return await response.json();\n};\n\n/**\n * Initiate lunr on the data in the jsonFile and add the jsondata to the pagesIndex\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n */\nconst initLunr = jsonFile => {\n fetchJson(jsonFile).then(jsondata => {\n pagesIndex = jsondata;\n // Using an arrow function here will break lunr on compile.\n lunrIndex = lunrJs(function() {\n this.ref('uri');\n this.field('title', {boost: 10});\n this.field('content');\n this.field('tags', {boost: 5});\n jsondata.forEach(p => {\n this.add(p);\n });\n });\n return null;\n }).catch(Notification.exception);\n};\n\n/**\n * Setup the eventlistener to listen on user input on the search field.\n *\n * @method\n * @private\n */\nconst initUI = () => {\n const searchInput = document.querySelector(selectors.searchinput);\n searchInput.addEventListener('keyup', e => {\n const query = e.currentTarget.value;\n if (query.length < 2) {\n document.querySelector(selectors.dropdownmenu).classList.remove('show');\n return;\n }\n renderResults(searchIndex(query));\n });\n searchInput.addEventListener('keydown', e => {\n if (e.keyCode === enter) {\n e.preventDefault();\n }\n if (e.keyCode === escape) {\n searchInput.value = '';\n }\n });\n};\n\n/**\n * Trigger a search in lunr and transform the result.\n *\n * @method\n * @private\n * @param {String} query\n * @return {Array} results\n */\nconst searchIndex = query => {\n // Find the item in our index corresponding to the lunr one to have more info\n // Lunr result:\n // {ref: \"/section/page1\", score: 0.2725657778206127}\n // Our result:\n // {title:\"Page1\", href:\"/section/page1\", ...}\n\n return lunrIndex.search(query + ' ' + query + '*').map(result => {\n return pagesIndex.filter(page => {\n return page.uri === result.ref;\n })[0];\n });\n};\n\n/**\n * Display the 10 first results\n *\n * @method\n * @private\n * @param {Array} results to display\n */\nconst renderResults = results => {\n const dropdownMenu = document.querySelector(selectors.dropdownmenu);\n if (!results.length) {\n dropdownMenu.classList.remove('show');\n return;\n }\n\n // Clear out the results.\n dropdownMenu.innerHTML = '';\n\n const baseUrl = M.cfg.wwwroot + '/admin/tool/componentlibrary/docspage.php';\n\n // Only show the ten first results\n results.slice(0, 10).forEach(function(result) {\n const link = document.createElement(\"a\");\n const chapter = result.uri.split('/')[1];\n link.appendChild(document.createTextNode(`${chapter} > ${result.title}`));\n link.classList.add('dropdown-item');\n link.href = baseUrl + result.uri;\n\n dropdownMenu.appendChild(link);\n });\n\n dropdownMenu.classList.add('show');\n};\n\n/**\n * Initialize module.\n *\n * @method\n * @param {String} jsonFile Full path to the search DB json file.\n */\nexport const search = jsonFile => {\n initLunr(jsonFile);\n initUI();\n};\n"],"names":["lunrIndex","pagesIndex","initLunr","jsonFile","async","response","fetch","ok","debug","status","json","fetchJson","then","jsondata","ref","field","boost","forEach","p","add","catch","Notification","exception","searchIndex","query","search","map","result","filter","page","uri","renderResults","results","dropdownMenu","document","querySelector","selectors","dropdownmenu","length","classList","remove","innerHTML","baseUrl","M","cfg","wwwroot","slice","link","createElement","chapter","split","appendChild","createTextNode","title","href","searchInput","searchinput","addEventListener","e","currentTarget","value","keyCode","enter","preventDefault","escape","initUI"],"mappings":";;;;;;;gQA6BIA,UAAY,KACZC,WAAa,WA2BXC,SAAWC,WAjBCC,OAAAA,iBACRC,eAAiBC,MAAMH,iBAExBE,SAASE,iBACNC,+CAAwCH,SAASI,eAG5CJ,SAASK,QAWtBC,CAAUR,UAAUS,MAAKC,WACrBZ,WAAaY,SAEbb,WAAY,kBAAO,gBACVc,IAAI,YACJC,MAAM,QAAS,CAACC,MAAO,UACvBD,MAAM,gBACNA,MAAM,OAAQ,CAACC,MAAO,IAC3BH,SAASI,SAAQC,SACRC,IAAID,SAGV,QACRE,MAAMC,sBAAaC,YAqCpBC,YAAcC,OAOTxB,UAAUyB,OAAOD,MAAQ,IAAMA,MAAQ,KAAKE,KAAIC,QAC5C1B,WAAW2B,QAAOC,MACdA,KAAKC,MAAQH,OAAOb,MAC5B,KAWLiB,cAAgBC,gBACZC,aAAeC,SAASC,cAAcC,mBAAUC,kBACjDL,QAAQM,mBACTL,aAAaM,UAAUC,OAAO,QAKlCP,aAAaQ,UAAY,SAEnBC,QAAUC,EAAEC,IAAIC,QAAU,4CAGhCb,QAAQc,MAAM,EAAG,IAAI7B,SAAQ,SAASU,cAC5BoB,KAAOb,SAASc,cAAc,KAC9BC,QAAUtB,OAAOG,IAAIoB,MAAM,KAAK,GACtCH,KAAKI,YAAYjB,SAASkB,yBAAkBH,sBAAatB,OAAO0B,SAChEN,KAAKR,UAAUpB,IAAI,iBACnB4B,KAAKO,KAAOZ,QAAUf,OAAOG,IAE7BG,aAAakB,YAAYJ,SAG7Bd,aAAaM,UAAUpB,IAAI,yBASThB,WAClBD,SAASC,UAlFE,YACLoD,YAAcrB,SAASC,cAAcC,mBAAUoB,aACrDD,YAAYE,iBAAiB,SAASC,UAC5BlC,MAAQkC,EAAEC,cAAcC,MAC1BpC,MAAMc,OAAS,EACfJ,SAASC,cAAcC,mBAAUC,cAAcE,UAAUC,OAAO,QAGpET,cAAcR,YAAYC,WAE9B+B,YAAYE,iBAAiB,WAAWC,IAChCA,EAAEG,UAAYC,kBACdJ,EAAEK,iBAEFL,EAAEG,UAAYG,oBACdT,YAAYK,MAAQ,QAoE5BK"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/selectors.min.js b/admin/tool/componentlibrary/amd/build/selectors.min.js index b7ad97c31ba..1f57da39fcb 100644 --- a/admin/tool/componentlibrary/amd/build/selectors.min.js +++ b/admin/tool/componentlibrary/amd/build/selectors.min.js @@ -1,2 +1,3 @@ -define ("tool_componentlibrary/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;a.default={clipboardbutton:".btn-clipboard",clipboardcontent:"figure.highlight, div.highlight",searchinput:"[data-region=\"docsearch\"] input",searchsubmit:"[data-region=\"docsearch\"] .btn-submit",dropdownmenu:"[data-region=\"docsearch\"] .dropdown-menu",componentlibrary:"[data-region=\"componentlibrary\"]",jscode:"[data-action=\"runjs\"]",mustachecode:"[data-region=\"mustachecode\"]",mustacherawcontext:"[data-region=\"rawcontext\"]",mustacherendered:"[data-region=\"mustacherendered\"]",mustachesource:"[data-region=\"mustachesource\"]",mustachecontext:"[data-region=\"mustachecontext\"]"};return a.default}); -//# sourceMappingURL=selectors.min.js.map +define("tool_componentlibrary/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={clipboardbutton:".btn-clipboard",clipboardcontent:"figure.highlight, div.highlight",searchinput:'[data-region="docsearch"] input',searchsubmit:'[data-region="docsearch"] .btn-submit',dropdownmenu:'[data-region="docsearch"] .dropdown-menu',componentlibrary:'[data-region="componentlibrary"]',jscode:'[data-action="runjs"]',mustachecode:'[data-region="mustachecode"]',mustacherawcontext:'[data-region="rawcontext"]',mustacherendered:'[data-region="mustacherendered"]',mustachesource:'[data-region="mustachesource"]',mustachecontext:'[data-region="mustachecontext"]'},_exports.default})); + +//# sourceMappingURL=selectors.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/selectors.min.js.map b/admin/tool/componentlibrary/amd/build/selectors.min.js.map index 55c47bad35a..3f14335b2e2 100644 --- a/admin/tool/componentlibrary/amd/build/selectors.min.js.map +++ b/admin/tool/componentlibrary/amd/build/selectors.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/selectors.js"],"names":["clipboardbutton","clipboardcontent","searchinput","searchsubmit","dropdownmenu","componentlibrary","jscode","mustachecode","mustacherawcontext","mustacherendered","mustachesource","mustachecontext"],"mappings":"2JAsBe,CAMXA,eAAe,CAAE,gBANN,CAaXC,gBAAgB,CAAE,iCAbP,CAoBXC,WAAW,CAAE,mCApBF,CA2BXC,YAAY,CAAE,yCA3BH,CAkCXC,YAAY,CAAE,4CAlCH,CAyCXC,gBAAgB,CAAE,oCAzCP,CAgDXC,MAAM,CAAE,yBAhDG,CAuDXC,YAAY,CAAE,gCAvDH,CA8DXC,kBAAkB,CAAE,8BA9DT,CAqEXC,gBAAgB,CAAE,oCArEP,CA4EXC,cAAc,CAAE,kCA5EL,CAmFXC,eAAe,CAAE,mCAnFN,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 .\n\n/**\n * Selectors for the component library\n *\n * @module tool_componentlibrary/selectors\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n /**\n * A selector relating to the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardbutton: '.btn-clipboard',\n\n /**\n * A selector relating to the content copied by the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardcontent: 'figure.highlight, div.highlight',\n\n /**\n * A selector relating to the 'Search' text input.\n *\n * @type {string}\n */\n searchinput: '[data-region=\"docsearch\"] input',\n\n /**\n * A selector relating to the 'Search' submit btton.\n *\n * @type {string}\n */\n searchsubmit: '[data-region=\"docsearch\"] .btn-submit',\n\n /**\n * A selector relating to the search dropdown menu.\n *\n * @type {string}\n */\n dropdownmenu: '[data-region=\"docsearch\"] .dropdown-menu',\n\n /**\n * A selector relating to the entire Component Library content region.\n *\n * @type {string}\n */\n componentlibrary: '[data-region=\"componentlibrary\"]',\n\n /**\n * A selector relating to JS Code which is to be run for examples to function.\n *\n * @type {string}\n */\n jscode: '[data-action=\"runjs\"]',\n\n /**\n * A selector relating to Mustache Template code regions.\n *\n * @type {string}\n */\n mustachecode: '[data-region=\"mustachecode\"]',\n\n /**\n * A selector relating to raw Mustache content regions.\n *\n * @type {string}\n */\n mustacherawcontext: '[data-region=\"rawcontext\"]',\n\n /**\n * A selector relating to rendered Mustache content regions.\n *\n * @type {string}\n */\n mustacherendered: '[data-region=\"mustacherendered\"]',\n\n /**\n * A selector relating to Mustache source code regions.\n *\n * @type {string}\n */\n mustachesource: '[data-region=\"mustachesource\"]',\n\n /**\n * A selector relating to Mustache context regions.\n *\n * @type {string}\n */\n mustachecontext: '[data-region=\"mustachecontext\"]',\n};\n"],"file":"selectors.min.js"} \ No newline at end of file +{"version":3,"file":"selectors.min.js","sources":["../src/selectors.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 * Selectors for the component library\n *\n * @module tool_componentlibrary/selectors\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n /**\n * A selector relating to the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardbutton: '.btn-clipboard',\n\n /**\n * A selector relating to the content copied by the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardcontent: 'figure.highlight, div.highlight',\n\n /**\n * A selector relating to the 'Search' text input.\n *\n * @type {string}\n */\n searchinput: '[data-region=\"docsearch\"] input',\n\n /**\n * A selector relating to the 'Search' submit btton.\n *\n * @type {string}\n */\n searchsubmit: '[data-region=\"docsearch\"] .btn-submit',\n\n /**\n * A selector relating to the search dropdown menu.\n *\n * @type {string}\n */\n dropdownmenu: '[data-region=\"docsearch\"] .dropdown-menu',\n\n /**\n * A selector relating to the entire Component Library content region.\n *\n * @type {string}\n */\n componentlibrary: '[data-region=\"componentlibrary\"]',\n\n /**\n * A selector relating to JS Code which is to be run for examples to function.\n *\n * @type {string}\n */\n jscode: '[data-action=\"runjs\"]',\n\n /**\n * A selector relating to Mustache Template code regions.\n *\n * @type {string}\n */\n mustachecode: '[data-region=\"mustachecode\"]',\n\n /**\n * A selector relating to raw Mustache content regions.\n *\n * @type {string}\n */\n mustacherawcontext: '[data-region=\"rawcontext\"]',\n\n /**\n * A selector relating to rendered Mustache content regions.\n *\n * @type {string}\n */\n mustacherendered: '[data-region=\"mustacherendered\"]',\n\n /**\n * A selector relating to Mustache source code regions.\n *\n * @type {string}\n */\n mustachesource: '[data-region=\"mustachesource\"]',\n\n /**\n * A selector relating to Mustache context regions.\n *\n * @type {string}\n */\n mustachecontext: '[data-region=\"mustachecontext\"]',\n};\n"],"names":["clipboardbutton","clipboardcontent","searchinput","searchsubmit","dropdownmenu","componentlibrary","jscode","mustachecode","mustacherawcontext","mustacherendered","mustachesource","mustachecontext"],"mappings":"iLAsBe,CAMXA,gBAAiB,iBAOjBC,iBAAkB,kCAOlBC,YAAa,kCAObC,aAAc,wCAOdC,aAAc,2CAOdC,iBAAkB,mCAOlBC,OAAQ,wBAORC,aAAc,+BAOdC,mBAAoB,6BAOpBC,iBAAkB,mCAOlBC,eAAgB,iCAOhBC,gBAAiB"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/src/jsrunner.js b/admin/tool/componentlibrary/amd/src/jsrunner.js index f36c7188414..dfe2678ef85 100644 --- a/admin/tool/componentlibrary/amd/src/jsrunner.js +++ b/admin/tool/componentlibrary/amd/src/jsrunner.js @@ -34,6 +34,9 @@ import selectors from 'tool_componentlibrary/selectors'; export const jsRunner = () => { const compLib = document.querySelector(selectors.componentlibrary); compLib.querySelectorAll(selectors.jscode).forEach(runjs => { - eval(runjs.innerText); // eslint-disable-line no-eval + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.innerHTML = runjs.textContent; + document.head.appendChild(script); }); }; diff --git a/admin/tool/dataprivacy/amd/build/add_category.min.js b/admin/tool/dataprivacy/amd/build/add_category.min.js index 987f86b93c9..63a1d972b27 100644 --- a/admin/tool/dataprivacy/amd/build/add_category.min.js +++ b/admin/tool/dataprivacy/amd/build/add_category.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/add_category",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core_form/changechecker"],function(a,b,c,d,e,f,g,h){var i={CATEGORY_LINK:"[data-add-element=\"category\"]"},j=function(a){this.contextId=a;this.strings=b.get_strings([{key:"addcategory",component:"tool_dataprivacy"},{key:"save",component:"admin"}]);this.registerEventListeners()};j.prototype.contextId=0;j.prototype.strings=0;j.prototype.registerEventListeners=function(){var b=a(i.CATEGORY_LINK);b.on("click",function(){return this.strings.then(function(a){e.create({type:e.types.SAVE_CANCEL,title:a[0],body:""},b).done(function(b){this.setupFormModal(b,a[1])}.bind(this))}.bind(this)).fail(d.exception)}.bind(this))};j.prototype.getBody=function(a){var b=null;if("undefined"!=typeof a){b={jsonformdata:JSON.stringify(a)}}return g.loadFragment("tool_dataprivacy","addcategory_form",this.contextId,b)};j.prototype.setupFormModal=function(a,b){a.setLarge();a.setSaveButtonText(b);a.getRoot().on(f.hidden,this.destroy.bind(this));a.setBody(this.getBody());a.getRoot().on(f.save,this.submitForm.bind(this));a.getRoot().on("submit","form",this.submitFormAjax.bind(this));this.modal=a;a.show()};j.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};j.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize();c.call([{methodname:"tool_dataprivacy_create_category_form",args:{jsonformdata:JSON.stringify(b)},done:function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this),fail:d.exception}])};j.prototype.close=function(){this.destroy();document.location.reload()};j.prototype.destroy=function(){h.resetAllFormDirtyStates();this.modal.destroy()};j.prototype.removeListeners=function(){a(i.CATEGORY_LINK).off("click")};return{getInstance:function getInstance(a){return new j(a)}}}); -//# sourceMappingURL=add_category.min.js.map +/** + * Module to add categories. + * + * @module tool_dataprivacy/add_category + * @copyright 2018 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/add_category",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core_form/changechecker"],(function($,Str,Ajax,Notification,ModalFactory,ModalEvents,Fragment,FormChangeChecker){var SELECTORS_CATEGORY_LINK='[data-add-element="category"]',AddCategory=function(contextId){this.contextId=contextId;this.strings=Str.get_strings([{key:"addcategory",component:"tool_dataprivacy"},{key:"save",component:"admin"}]),this.registerEventListeners()};return AddCategory.prototype.contextId=0,AddCategory.prototype.strings=0,AddCategory.prototype.registerEventListeners=function(){var trigger=$(SELECTORS_CATEGORY_LINK);trigger.on("click",function(){return this.strings.then(function(strings){ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL,title:strings[0],body:""},trigger).done(function(modal){this.setupFormModal(modal,strings[1])}.bind(this))}.bind(this)).fail(Notification.exception)}.bind(this))},AddCategory.prototype.getBody=function(formdata){var params=null;return void 0!==formdata&&(params={jsonformdata:JSON.stringify(formdata)}),Fragment.loadFragment("tool_dataprivacy","addcategory_form",this.contextId,params)},AddCategory.prototype.setupFormModal=function(modal,saveText){modal.setLarge(),modal.setSaveButtonText(saveText),modal.getRoot().on(ModalEvents.hidden,this.destroy.bind(this)),modal.setBody(this.getBody()),modal.getRoot().on(ModalEvents.save,this.submitForm.bind(this)),modal.getRoot().on("submit","form",this.submitFormAjax.bind(this)),this.modal=modal,modal.show()},AddCategory.prototype.submitForm=function(e){e.preventDefault(),this.modal.getRoot().find("form").submit()},AddCategory.prototype.submitFormAjax=function(e){e.preventDefault();var formData=this.modal.getRoot().find("form").serialize();Ajax.call([{methodname:"tool_dataprivacy_create_category_form",args:{jsonformdata:JSON.stringify(formData)},done:function(data){data.validationerrors?this.modal.setBody(this.getBody(formData)):this.close()}.bind(this),fail:Notification.exception}])},AddCategory.prototype.close=function(){this.destroy(),document.location.reload()},AddCategory.prototype.destroy=function(){FormChangeChecker.resetAllFormDirtyStates(),this.modal.destroy()},AddCategory.prototype.removeListeners=function(){$(SELECTORS_CATEGORY_LINK).off("click")},{getInstance:function(contextId){return new AddCategory(contextId)}}})); + +//# sourceMappingURL=add_category.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/add_category.min.js.map b/admin/tool/dataprivacy/amd/build/add_category.min.js.map index f97e7286498..2ee9d89dc99 100644 --- a/admin/tool/dataprivacy/amd/build/add_category.min.js.map +++ b/admin/tool/dataprivacy/amd/build/add_category.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/add_category.js"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","CATEGORY_LINK","AddCategory","contextId","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":"AAsBAA,OAAM,iCAAC,CACH,QADG,CAEH,UAFG,CAGH,WAHG,CAIH,mBAJG,CAKH,oBALG,CAMH,mBANG,CAOH,eAPG,CAQH,yBARG,CAAD,CASH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKC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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 to add categories.\n *\n * @module tool_dataprivacy/add_category\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n CATEGORY_LINK: '[data-add-element=\"category\"]',\n };\n\n var AddCategory = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addcategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddCategory.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddCategory.prototype.strings = 0;\n\n AddCategory.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.CATEGORY_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddCategory.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addcategory_form', this.contextId, params);\n };\n\n AddCategory.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddCategory.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddCategory.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_category_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n AddCategory.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddCategory.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddCategory.prototype.removeListeners = function() {\n $(SELECTORS.CATEGORY_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_category */ {\n getInstance: function(contextId) {\n return new AddCategory(contextId);\n }\n };\n }\n);\n\n"],"file":"add_category.min.js"} \ No newline at end of file +{"version":3,"file":"add_category.min.js","sources":["../src/add_category.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 to add categories.\n *\n * @module tool_dataprivacy/add_category\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n CATEGORY_LINK: '[data-add-element=\"category\"]',\n };\n\n var AddCategory = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addcategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddCategory.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddCategory.prototype.strings = 0;\n\n AddCategory.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.CATEGORY_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddCategory.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addcategory_form', this.contextId, params);\n };\n\n AddCategory.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddCategory.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddCategory.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_category_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n AddCategory.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddCategory.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddCategory.prototype.removeListeners = function() {\n $(SELECTORS.CATEGORY_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_category */ {\n getInstance: function(contextId) {\n return new AddCategory(contextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","AddCategory","contextId","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","this","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":";;;;;;;AAsBAA,uCAAO,CACH,SACA,WACA,YACA,oBACA,qBACA,oBACA,gBACA,4BACD,SACCC,EACAC,IACAC,KACAC,aACAC,aACAC,YACAC,SACAC,uBAGQC,wBACe,gCAGfC,YAAc,SAASC,gBAClBA,UAAYA,eAYZC,QAAUV,IAAIW,YAVF,CACb,CACIC,IAAK,cACLC,UAAW,oBAEf,CACID,IAAK,OACLC,UAAW,gBAKdC,iCAOTN,YAAYO,UAAUN,UAAY,EAMlCD,YAAYO,UAAUL,QAAU,EAEhCF,YAAYO,UAAUD,uBAAyB,eAEvCE,QAAUjB,EAAEQ,yBAChBS,QAAQC,GAAG,QAAS,kBACTC,KAAKR,QAAQS,KAAK,SAAST,SAC9BP,aAAaiB,OAAO,CAChBC,KAAMlB,aAAamB,MAAMC,YACzBC,MAAOd,QAAQ,GACfe,KAAM,IACPT,SAASU,KAAK,SAASC,YACjBC,eAAeD,MAAOjB,QAAQ,KACrCmB,KAAKX,QACTW,KAAKX,OACNY,KAAK5B,aAAa6B,YACrBF,KAAKX,QAUXV,YAAYO,UAAUiB,QAAU,SAASC,cAEjCC,OAAS,iBACW,IAAbD,WACPC,OAAS,CAACC,aAAcC,KAAKC,UAAUJ,YAGpC5B,SAASiC,aAAa,mBAAoB,mBAAoBpB,KAAKT,UAAWyB,SAGzF1B,YAAYO,UAAUa,eAAiB,SAASD,MAAOY,UACnDZ,MAAMa,WAENb,MAAMc,kBAAkBF,UAGxBZ,MAAMe,UAAUzB,GAAGb,YAAYuC,OAAQzB,KAAK0B,QAAQf,KAAKX,OAEzDS,MAAMkB,QAAQ3B,KAAKc,WAInBL,MAAMe,UAAUzB,GAAGb,YAAY0C,KAAM5B,KAAK6B,WAAWlB,KAAKX,OAE1DS,MAAMe,UAAUzB,GAAG,SAAU,OAAQC,KAAK8B,eAAenB,KAAKX,YAEzDS,MAAQA,MAEbA,MAAMsB,QAUVzC,YAAYO,UAAUgC,WAAa,SAASG,GACxCA,EAAEC,sBACGxB,MAAMe,UAAUU,KAAK,QAAQC,UAGtC7C,YAAYO,UAAUiC,eAAiB,SAASE,GAE5CA,EAAEC,qBAGEG,SAAWpC,KAAKS,MAAMe,UAAUU,KAAK,QAAQG,YAEjDtD,KAAKuD,KAAK,CAAC,CACPC,WAAY,wCACZC,KAAM,CAACvB,aAAcC,KAAKC,UAAUiB,WACpC5B,KAAM,SAASiC,MACPA,KAAKC,sBACAjC,MAAMkB,QAAQ3B,KAAKc,QAAQsB,gBAE3BO,SAEXhC,KAAKX,MACPY,KAAM5B,aAAa6B,cAI3BvB,YAAYO,UAAU8C,MAAQ,gBACrBjB,UACLkB,SAASC,SAASC,UAGtBxD,YAAYO,UAAU6B,QAAU,WAC5BtC,kBAAkB2D,+BACbtC,MAAMiB,WAGfpC,YAAYO,UAAUmD,gBAAkB,WACpCnE,EAAEQ,yBAAyB4D,IAAI,UAGuB,CACtDC,YAAa,SAAS3D,kBACX,IAAID,YAAYC"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/add_purpose.min.js b/admin/tool/dataprivacy/amd/build/add_purpose.min.js index 9e71843cdb6..1a949a9f722 100644 --- a/admin/tool/dataprivacy/amd/build/add_purpose.min.js +++ b/admin/tool/dataprivacy/amd/build/add_purpose.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/add_purpose",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core_form/changechecker"],function(a,b,c,d,e,f,g,h){var i={PURPOSE_LINK:"[data-add-element=\"purpose\"]"},j=function(a){this.contextId=a;this.strings=b.get_strings([{key:"addpurpose",component:"tool_dataprivacy"},{key:"save",component:"admin"}]);this.registerEventListeners()};j.prototype.contextId=0;j.prototype.strings=0;j.prototype.registerEventListeners=function(){var b=a(i.PURPOSE_LINK);b.on("click",function(){return this.strings.then(function(a){e.create({type:e.types.SAVE_CANCEL,title:a[0],body:""},b).done(function(b){this.setupFormModal(b,a[1])}.bind(this))}.bind(this)).fail(d.exception)}.bind(this))};j.prototype.getBody=function(a){var b=null;if("undefined"!=typeof a){b={jsonformdata:JSON.stringify(a)}}return g.loadFragment("tool_dataprivacy","addpurpose_form",this.contextId,b)};j.prototype.setupFormModal=function(a,b){a.setLarge();a.setSaveButtonText(b);a.getRoot().on(f.hidden,this.destroy.bind(this));a.setBody(this.getBody());a.getRoot().on(f.save,this.submitForm.bind(this));a.getRoot().on("submit","form",this.submitFormAjax.bind(this));this.modal=a;a.show()};j.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};j.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize();c.call([{methodname:"tool_dataprivacy_create_purpose_form",args:{jsonformdata:JSON.stringify(b)},done:function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this),fail:d.exception}])};j.prototype.close=function(){this.destroy();document.location.reload()};j.prototype.destroy=function(){h.resetAllFormDirtyStates();this.modal.destroy()};j.prototype.removeListeners=function(){a(i.PURPOSE_LINK).off("click")};return{getInstance:function getInstance(a){return new j(a)}}}); -//# sourceMappingURL=add_purpose.min.js.map +/** + * Module to add purposes. + * + * @module tool_dataprivacy/add_purpose + * @copyright 2018 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/add_purpose",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core_form/changechecker"],(function($,Str,Ajax,Notification,ModalFactory,ModalEvents,Fragment,FormChangeChecker){var SELECTORS_PURPOSE_LINK='[data-add-element="purpose"]',AddPurpose=function(contextId){this.contextId=contextId;this.strings=Str.get_strings([{key:"addpurpose",component:"tool_dataprivacy"},{key:"save",component:"admin"}]),this.registerEventListeners()};return AddPurpose.prototype.contextId=0,AddPurpose.prototype.strings=0,AddPurpose.prototype.registerEventListeners=function(){var trigger=$(SELECTORS_PURPOSE_LINK);trigger.on("click",function(){return this.strings.then(function(strings){ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL,title:strings[0],body:""},trigger).done(function(modal){this.setupFormModal(modal,strings[1])}.bind(this))}.bind(this)).fail(Notification.exception)}.bind(this))},AddPurpose.prototype.getBody=function(formdata){var params=null;return void 0!==formdata&&(params={jsonformdata:JSON.stringify(formdata)}),Fragment.loadFragment("tool_dataprivacy","addpurpose_form",this.contextId,params)},AddPurpose.prototype.setupFormModal=function(modal,saveText){modal.setLarge(),modal.setSaveButtonText(saveText),modal.getRoot().on(ModalEvents.hidden,this.destroy.bind(this)),modal.setBody(this.getBody()),modal.getRoot().on(ModalEvents.save,this.submitForm.bind(this)),modal.getRoot().on("submit","form",this.submitFormAjax.bind(this)),this.modal=modal,modal.show()},AddPurpose.prototype.submitForm=function(e){e.preventDefault(),this.modal.getRoot().find("form").submit()},AddPurpose.prototype.submitFormAjax=function(e){e.preventDefault();var formData=this.modal.getRoot().find("form").serialize();Ajax.call([{methodname:"tool_dataprivacy_create_purpose_form",args:{jsonformdata:JSON.stringify(formData)},done:function(data){data.validationerrors?this.modal.setBody(this.getBody(formData)):this.close()}.bind(this),fail:Notification.exception}])},AddPurpose.prototype.close=function(){this.destroy(),document.location.reload()},AddPurpose.prototype.destroy=function(){FormChangeChecker.resetAllFormDirtyStates(),this.modal.destroy()},AddPurpose.prototype.removeListeners=function(){$(SELECTORS_PURPOSE_LINK).off("click")},{getInstance:function(contextId){return new AddPurpose(contextId)}}})); + +//# sourceMappingURL=add_purpose.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map b/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map index 81d703e1eca..6b9b9f5b460 100644 --- a/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map +++ b/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/add_purpose.js"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","PURPOSE_LINK","AddPurpose","contextId","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":"AAsBAA,OAAM,gCAAC,CACH,QADG,CAEH,UAFG,CAGH,WAHG,CAIH,mBAJG,CAKH,oBALG,CAMH,mBANG,CAOH,eAPG,CAQH,yBARG,CAAD,CASH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMCC,CAND,CAOCC,CAPD,CAQCC,CARD,CASD,IAEUC,CAAAA,CAAS,CAAG,CACZC,YAAY,CAAE,gCADF,CAFtB,CAMUC,CAAU,CAAG,SAASC,CAAT,CAAoB,CACjC,KAAKA,SAAL,CAAiBA,CAAjB,CAYA,KAAKC,OAAL,CAAeX,CAAG,CAACY,WAAJ,CAVE,CACb,CACIC,GAAG,CAAE,YADT,CAEIC,SAAS,CAAE,kBAFf,CADa,CAKb,CACID,GAAG,CAAE,MADT,CAEIC,SAAS,CAAE,OAFf,CALa,CAUF,CAAf,CAE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AAIA,CAAI,CAACC,gBAAT,CAA2B,CACvB,KAAKjC,KAAL,CAAWkB,OAAX,CAAmB,KAAKb,OAAL,CAAasB,CAAb,CAAnB,CACH,CAFD,IAEO,CACH,KAAKO,KAAL,EACH,CACJ,CANK,CAMJhC,IANI,CAMC,IAND,CAHC,CAWPC,IAAI,CAAE5B,CAAY,CAAC6B,SAXZ,CAAD,CAAV,CAaH,CApBD,CAsBAtB,CAAU,CAACO,SAAX,CAAqB6C,KAArB,CAA6B,UAAW,CACpC,KAAKjB,OAAL,GACAkB,QAAQ,CAACC,QAAT,CAAkBC,MAAlB,EACH,CAHD,CAKAvD,CAAU,CAACO,SAAX,CAAqB4B,OAArB,CAA+B,UAAW,CACtCtC,CAAiB,CAAC2D,uBAAlB,GACA,KAAKtC,KAAL,CAAWiB,OAAX,EACH,CAHD,CAKAnC,CAAU,CAACO,SAAX,CAAqBkD,eAArB,CAAuC,UAAW,CAC9CnE,CAAC,CAACQ,CAAS,CAACC,YAAX,CAAD,CAA0B2D,GAA1B,CAA8B,OAA9B,CACH,CAFD,CAIA,MAAyD,CACrDC,WAAW,CAAE,qBAAS1D,CAAT,CAAoB,CAC7B,MAAO,IAAID,CAAAA,CAAJ,CAAeC,CAAf,CACV,CAHoD,CAK5D,CAlKC,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 * Module to add purposes.\n *\n * @module tool_dataprivacy/add_purpose\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n PURPOSE_LINK: '[data-add-element=\"purpose\"]',\n };\n\n var AddPurpose = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addpurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddPurpose.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddPurpose.prototype.strings = 0;\n\n AddPurpose.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.PURPOSE_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddPurpose.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addpurpose_form', this.contextId, params);\n };\n\n AddPurpose.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddPurpose.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddPurpose.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_purpose_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n\n fail: Notification.exception\n }]);\n };\n\n AddPurpose.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddPurpose.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddPurpose.prototype.removeListeners = function() {\n $(SELECTORS.PURPOSE_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_purpose */ {\n getInstance: function(contextId) {\n return new AddPurpose(contextId);\n }\n };\n }\n);\n\n"],"file":"add_purpose.min.js"} \ No newline at end of file +{"version":3,"file":"add_purpose.min.js","sources":["../src/add_purpose.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 to add purposes.\n *\n * @module tool_dataprivacy/add_purpose\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n PURPOSE_LINK: '[data-add-element=\"purpose\"]',\n };\n\n var AddPurpose = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addpurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddPurpose.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddPurpose.prototype.strings = 0;\n\n AddPurpose.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.PURPOSE_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddPurpose.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addpurpose_form', this.contextId, params);\n };\n\n AddPurpose.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddPurpose.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddPurpose.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_purpose_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n\n fail: Notification.exception\n }]);\n };\n\n AddPurpose.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddPurpose.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddPurpose.prototype.removeListeners = function() {\n $(SELECTORS.PURPOSE_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_purpose */ {\n getInstance: function(contextId) {\n return new AddPurpose(contextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","AddPurpose","contextId","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","this","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":";;;;;;;AAsBAA,sCAAO,CACH,SACA,WACA,YACA,oBACA,qBACA,oBACA,gBACA,4BACD,SACCC,EACAC,IACAC,KACAC,aACAC,aACAC,YACAC,SACAC,uBAGQC,uBACc,+BAGdC,WAAa,SAASC,gBACjBA,UAAYA,eAYZC,QAAUV,IAAIW,YAVF,CACb,CACIC,IAAK,aACLC,UAAW,oBAEf,CACID,IAAK,OACLC,UAAW,gBAKdC,iCAOTN,WAAWO,UAAUN,UAAY,EAMjCD,WAAWO,UAAUL,QAAU,EAE/BF,WAAWO,UAAUD,uBAAyB,eAEtCE,QAAUjB,EAAEQ,wBAChBS,QAAQC,GAAG,QAAS,kBACTC,KAAKR,QAAQS,KAAK,SAAST,SAC9BP,aAAaiB,OAAO,CAChBC,KAAMlB,aAAamB,MAAMC,YACzBC,MAAOd,QAAQ,GACfe,KAAM,IACPT,SAASU,KAAK,SAASC,YACjBC,eAAeD,MAAOjB,QAAQ,KACrCmB,KAAKX,QACTW,KAAKX,OACNY,KAAK5B,aAAa6B,YACrBF,KAAKX,QAUXV,WAAWO,UAAUiB,QAAU,SAASC,cAEhCC,OAAS,iBACW,IAAbD,WACPC,OAAS,CAACC,aAAcC,KAAKC,UAAUJ,YAGpC5B,SAASiC,aAAa,mBAAoB,kBAAmBpB,KAAKT,UAAWyB,SAGxF1B,WAAWO,UAAUa,eAAiB,SAASD,MAAOY,UAClDZ,MAAMa,WAENb,MAAMc,kBAAkBF,UAGxBZ,MAAMe,UAAUzB,GAAGb,YAAYuC,OAAQzB,KAAK0B,QAAQf,KAAKX,OAEzDS,MAAMkB,QAAQ3B,KAAKc,WAInBL,MAAMe,UAAUzB,GAAGb,YAAY0C,KAAM5B,KAAK6B,WAAWlB,KAAKX,OAE1DS,MAAMe,UAAUzB,GAAG,SAAU,OAAQC,KAAK8B,eAAenB,KAAKX,YAEzDS,MAAQA,MAEbA,MAAMsB,QAUVzC,WAAWO,UAAUgC,WAAa,SAASG,GACvCA,EAAEC,sBACGxB,MAAMe,UAAUU,KAAK,QAAQC,UAGtC7C,WAAWO,UAAUiC,eAAiB,SAASE,GAE3CA,EAAEC,qBAGEG,SAAWpC,KAAKS,MAAMe,UAAUU,KAAK,QAAQG,YAEjDtD,KAAKuD,KAAK,CAAC,CACPC,WAAY,uCACZC,KAAM,CAACvB,aAAcC,KAAKC,UAAUiB,WACpC5B,KAAM,SAASiC,MACPA,KAAKC,sBACAjC,MAAMkB,QAAQ3B,KAAKc,QAAQsB,gBAE3BO,SAEXhC,KAAKX,MAEPY,KAAM5B,aAAa6B,cAI3BvB,WAAWO,UAAU8C,MAAQ,gBACpBjB,UACLkB,SAASC,SAASC,UAGtBxD,WAAWO,UAAU6B,QAAU,WAC3BtC,kBAAkB2D,+BACbtC,MAAMiB,WAGfpC,WAAWO,UAAUmD,gBAAkB,WACnCnE,EAAEQ,wBAAwB4D,IAAI,UAGuB,CACrDC,YAAa,SAAS3D,kBACX,IAAID,WAAWC"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/categoriesactions.min.js b/admin/tool/dataprivacy/amd/build/categoriesactions.min.js index 0b47fca7d37..4fe615bab59 100644 --- a/admin/tool/dataprivacy/amd/build/categoriesactions.min.js +++ b/admin/tool/dataprivacy/amd/build/categoriesactions.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/categoriesactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var g={DELETE:"[data-action=\"deletecategory\"]"},h=function(){this.registerEvents()};h.prototype.registerEvents=function(){a(g.DELETE).click(function(g){g.preventDefault();var h=a(this).data("id"),i=a(this).data("name");d.get_strings([{key:"deletecategory",component:"tool_dataprivacy"},{key:"deletecategorytext",component:"tool_dataprivacy",param:i},{key:"delete"}]).then(function(d){var g=d[0],i=d[1],j=d[2];return e.create({title:g,body:i,type:e.types.SAVE_CANCEL}).then(function(d){d.setSaveButtonText(j);d.getRoot().on(f.save,function(){b.call([{methodname:"tool_dataprivacy_delete_category",args:{id:h}}])[0].done(function(b){if(b.result){a("tr[data-categoryid=\""+h+"\"]").remove()}else{c.addNotification({message:b.warnings[0].message,type:"error"})}}).fail(c.exception)});d.getRoot().on(f.hidden,function(){d.destroy()});return d})}).done(function(a){a.show()}).fail(c.exception)})};return{init:function init(){return new h}}}); -//# sourceMappingURL=categoriesactions.min.js.map +/** + * AMD module for categories actions. + * + * @module tool_dataprivacy/categoriesactions + * @copyright 2018 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/categoriesactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],(function($,Ajax,Notification,Str,ModalFactory,ModalEvents){var ACTIONS_DELETE='[data-action="deletecategory"]',CategoriesActions=function(){this.registerEvents()};return CategoriesActions.prototype.registerEvents=function(){$(ACTIONS_DELETE).click((function(e){e.preventDefault();var id=$(this).data("id"),stringkeys=[{key:"deletecategory",component:"tool_dataprivacy"},{key:"deletecategorytext",component:"tool_dataprivacy",param:$(this).data("name")},{key:"delete"}];Str.get_strings(stringkeys).then((function(langStrings){var title=langStrings[0],confirmMessage=langStrings[1],buttonText=langStrings[2];return ModalFactory.create({title:title,body:confirmMessage,type:ModalFactory.types.SAVE_CANCEL}).then((function(modal){return modal.setSaveButtonText(buttonText),modal.getRoot().on(ModalEvents.save,(function(){var request={methodname:"tool_dataprivacy_delete_category",args:{id:id}};Ajax.call([request])[0].done((function(data){data.result?$('tr[data-categoryid="'+id+'"]').remove():Notification.addNotification({message:data.warnings[0].message,type:"error"})})).fail(Notification.exception)})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal}))})).done((function(modal){modal.show()})).fail(Notification.exception)}))},{init:function(){return new CategoriesActions}}})); + +//# sourceMappingURL=categoriesactions.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map b/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map index cb8801921da..683666ec3bb 100644 --- a/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/categoriesactions.js"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","DELETE","CategoriesActions","registerEvents","prototype","click","e","preventDefault","id","data","categoryname","get_strings","key","component","param","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","call","methodname","args","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show"],"mappings":"AAsBAA,OAAM,sCAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,oBALG,CAMH,mBANG,CAAD,CAON,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAAqCC,CAArC,CAAmDC,CAAnD,CAAgE,IAOxDC,CAAAA,CAAO,CAAG,CACVC,MAAM,CAAE,kCADE,CAP8C,CAcxDC,CAAiB,CAAG,UAAW,CAC/B,KAAKC,cAAL,EACH,CAhB2D,CAqB5DD,CAAiB,CAACE,SAAlB,CAA4BD,cAA5B,CAA6C,UAAW,CACpDT,CAAC,CAACM,CAAO,CAACC,MAAT,CAAD,CAAkBI,KAAlB,CAAwB,SAASC,CAAT,CAAY,CAChCA,CAAC,CAACC,cAAF,GADgC,GAG5BC,CAAAA,CAAE,CAAGd,CAAC,CAAC,IAAD,CAAD,CAAQe,IAAR,CAAa,IAAb,CAHuB,CAI5BC,CAAY,CAAGhB,CAAC,CAAC,IAAD,CAAD,CAAQe,IAAR,CAAa,MAAb,CAJa,CAoBhCZ,CAAG,CAACc,WAAJ,CAfiB,CACb,CACIC,GAAG,CAAE,gBADT,CAEIC,SAAS,CAAE,kBAFf,CADa,CAKb,CACID,GAAG,CAAE,oB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ChB,CAAK,CAACiB,OAAN,EACH,CAHD,EAKA,MAAOjB,CAAAA,CACV,CAlCM,CAmCV,CAvCD,EAuCGQ,IAvCH,CAuCQ,SAASR,CAAT,CAAgB,CACpBA,CAAK,CAACkB,IAAN,EAEH,CA1CD,EA0CGJ,IA1CH,CA0CQ3C,CAAY,CAAC4C,SA1CrB,CA2CH,CA/DD,CAgEH,CAjED,CAmEA,MAA+D,CAS3D,KAAQ,eAAW,CACf,MAAO,IAAItC,CAAAA,CACd,CAX0D,CAalE,CA5GK,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 for categories actions.\n *\n * @module tool_dataprivacy/categoriesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletecategory\"]',\n };\n\n /**\n * CategoriesActions class.\n */\n var CategoriesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n CategoriesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var categoryname = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletecategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletecategorytext',\n component: 'tool_dataprivacy',\n param: categoryname\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_category',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-categoryid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/categoriesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {CategoriesActions}\n */\n 'init': function() {\n return new CategoriesActions();\n }\n };\n});\n"],"file":"categoriesactions.min.js"} \ No newline at end of file +{"version":3,"file":"categoriesactions.min.js","sources":["../src/categoriesactions.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 * AMD module for categories actions.\n *\n * @module tool_dataprivacy/categoriesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletecategory\"]',\n };\n\n /**\n * CategoriesActions class.\n */\n var CategoriesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n CategoriesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var categoryname = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletecategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletecategorytext',\n component: 'tool_dataprivacy',\n param: categoryname\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_category',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-categoryid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/categoriesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {CategoriesActions}\n */\n 'init': function() {\n return new CategoriesActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","CategoriesActions","registerEvents","prototype","click","e","preventDefault","id","this","data","stringkeys","key","component","param","get_strings","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show"],"mappings":";;;;;;;AAsBAA,4CAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,iBAO3CC,eACQ,iCAMRC,kBAAoB,gBACfC,yBAMTD,kBAAkBE,UAAUD,eAAiB,WACzCR,EAAEM,gBAAgBI,OAAM,SAASC,GAC7BA,EAAEC,qBAEEC,GAAKb,EAAEc,MAAMC,KAAK,MAElBC,WAAa,CACb,CACIC,IAAK,iBACLC,UAAW,oBAEf,CACID,IAAK,qBACLC,UAAW,mBACXC,MATWnB,EAAEc,MAAMC,KAAK,SAW5B,CACIE,IAAK,WAIbd,IAAIiB,YAAYJ,YAAYK,MAAK,SAASC,iBAClCC,MAAQD,YAAY,GACpBE,eAAiBF,YAAY,GAC7BG,WAAaH,YAAY,UACtBlB,aAAasB,OAAO,CACvBH,MAAOA,MACPI,KAAMH,eACNI,KAAMxB,aAAayB,MAAMC,cAC1BT,MAAK,SAASU,cACbA,MAAMC,kBAAkBP,YAGxBM,MAAME,UAAUC,GAAG7B,YAAY8B,MAAM,eAE7BC,QAAU,CACVC,WAAY,mCACZC,KAAM,IAAOzB,KAGjBZ,KAAKsC,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASzB,MAC9BA,KAAK0B,OACLzC,EAAE,uBAAyBa,GAAK,MAAM6B,SAEtCxC,aAAayC,gBAAgB,CACzBC,QAAS7B,KAAK8B,SAAS,GAAGD,QAC1BhB,KAAM,aAGfkB,KAAK5C,aAAa6C,cAIzBhB,MAAME,UAAUC,GAAG7B,YAAY2C,QAAQ,WAEnCjB,MAAMkB,aAGHlB,YAEZS,MAAK,SAAST,OACbA,MAAMmB,UAEPJ,KAAK5C,aAAa6C,eAIkC,MASnD,kBACG,IAAIxC"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/contactdpo.min.js b/admin/tool/dataprivacy/amd/build/contactdpo.min.js index 73514788d05..c13d9806449 100644 --- a/admin/tool/dataprivacy/amd/build/contactdpo.min.js +++ b/admin/tool/dataprivacy/amd/build/contactdpo.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/contactdpo",["exports","core_form/modalform","core/notification","core/str","core/toast"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=f(b);c=f(c);function f(a){return a&&a.__esModule?a:{default:a}}var g={CONTACT_DPO:"[data-action=\"contactdpo\"]"};a.init=function init(){var a=document.querySelector(g.CONTACT_DPO);a.addEventListener("click",function(f){f.preventDefault();var g=new b.default({modalConfig:{title:(0,d.get_string)("contactdataprotectionofficer","tool_dataprivacy")},formClass:"tool_dataprivacy\\form\\contactdpo",saveButtonText:(0,d.get_string)("send","tool_dataprivacy"),returnFocus:a});g.addEventListener(g.events.FORM_SUBMITTED,function(a){if(a.detail.result){(0,d.get_string)("requestsubmitted","tool_dataprivacy").then(e.add).catch()}else{var b=a.detail.warnings.map(function(a){return a.message});c.default.addNotification({type:"error",message:b.join("
")})}});g.show()})}}); -//# sourceMappingURL=contactdpo.min.js.map +define("tool_dataprivacy/contactdpo",["exports","core_form/modalform","core/notification","core/str","core/toast"],(function(_exports,_modalform,_notification,_str,_toast){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} +/** + * Javascript module for contacting the site DPO + * + * @module tool_dataprivacy/contactdpo + * @copyright 2021 Paul Holden + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_modalform=_interopRequireDefault(_modalform),_notification=_interopRequireDefault(_notification);const SELECTORS_CONTACT_DPO='[data-action="contactdpo"]';_exports.init=()=>{const triggerElement=document.querySelector(SELECTORS_CONTACT_DPO);triggerElement.addEventListener("click",(event=>{event.preventDefault();const modalForm=new _modalform.default({modalConfig:{title:(0,_str.get_string)("contactdataprotectionofficer","tool_dataprivacy")},formClass:"tool_dataprivacy\\form\\contactdpo",saveButtonText:(0,_str.get_string)("send","tool_dataprivacy"),returnFocus:triggerElement});modalForm.addEventListener(modalForm.events.FORM_SUBMITTED,(event=>{if(event.detail.result)(0,_str.get_string)("requestsubmitted","tool_dataprivacy").then(_toast.add).catch();else{const warningMessages=event.detail.warnings.map((warning=>warning.message));_notification.default.addNotification({type:"error",message:warningMessages.join("
")})}})),modalForm.show()}))}})); + +//# sourceMappingURL=contactdpo.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map b/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map index efbac474315..680d7bb355d 100644 --- a/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map +++ b/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/contactdpo.js"],"names":["SELECTORS","CONTACT_DPO","init","triggerElement","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","then","addToast","catch","warningMessages","warnings","map","warning","message","Notification","addNotification","type","join","show"],"mappings":"oNAuBA,OACA,O,sDAIMA,CAAAA,CAAS,CAAG,CACdC,WAAW,CAAE,8BADC,C,QAOE,QAAPC,CAAAA,IAAO,EAAM,CACtB,GAAMC,CAAAA,CAAc,CAAGC,QAAQ,CAACC,aAAT,CAAuBL,CAAS,CAACC,WAAjC,CAAvB,CAEAE,CAAc,CAACG,gBAAf,CAAgC,OAAhC,CAAyC,SAAAC,CAAK,CAAI,CAC9CA,CAAK,CAACC,cAAN,GAEA,GAAMC,CAAAA,CAAS,CAAG,GAAIC,UAAJ,CAAc,CAC5BC,WAAW,CAAE,CACTC,KAAK,CAAE,iBAAU,8BAAV,CAA0C,kBAA1C,CADE,CADe,CAI5BC,SAAS,CAAE,oCAJiB,CAK5BC,cAAc,CAAE,iBAAU,MAAV,CAAkB,kBAAlB,CALY,CAM5BC,WAAW,CAAEZ,CANe,CAAd,CAAlB,CAUAM,CAAS,CAACH,gBAAV,CAA2BG,CAAS,CAACO,MAAV,CAAiBC,cAA5C,CAA4D,SAAAV,CAAK,CAAI,CACjE,GAAIA,CAAK,CAACW,MAAN,CAAaC,MAAjB,CAAyB,CACrB,iBAAU,kBAAV,CAA8B,kBAA9B,EAAkDC,IAAlD,CAAuDC,KAAvD,EAAiEC,KAAjE,EACH,CAFD,IAEO,CACH,GAAMC,CAAAA,CAAe,CAAGhB,CAAK,CAACW,MAAN,CAAaM,QAAb,CAAsBC,GAAtB,CAA0B,SAAAC,CAAO,QAAIA,CAAAA,CAAO,CAACC,OAAZ,CAAjC,CAAxB,CACAC,UAAaC,eAAb,CAA6B,CACzBC,IAAI,CAAE,OADmB,CAEzBH,OAAO,CAAEJ,CAAe,CAACQ,IAAhB,CAAqB,MAArB,CAFgB,CAA7B,CAIH,CACJ,CAVD,EAYAtB,CAAS,CAACuB,IAAV,EACH,CA1BD,CA2BH,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 .\n\n/**\n * Javascript module for contacting the site DPO\n *\n * @module tool_dataprivacy/contactdpo\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\nimport {add as addToast} from 'core/toast';\n\nconst SELECTORS = {\n CONTACT_DPO: '[data-action=\"contactdpo\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const triggerElement = document.querySelector(SELECTORS.CONTACT_DPO);\n\n triggerElement.addEventListener('click', event => {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('contactdataprotectionofficer', 'tool_dataprivacy'),\n },\n formClass: 'tool_dataprivacy\\\\form\\\\contactdpo',\n saveButtonText: getString('send', 'tool_dataprivacy'),\n returnFocus: triggerElement,\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n getString('requestsubmitted', 'tool_dataprivacy').then(addToast).catch();\n } else {\n const warningMessages = event.detail.warnings.map(warning => warning.message);\n Notification.addNotification({\n type: 'error',\n message: warningMessages.join('
')\n });\n }\n });\n\n modalForm.show();\n });\n};\n"],"file":"contactdpo.min.js"} \ No newline at end of file +{"version":3,"file":"contactdpo.min.js","sources":["../src/contactdpo.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 * Javascript module for contacting the site DPO\n *\n * @module tool_dataprivacy/contactdpo\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\nimport {add as addToast} from 'core/toast';\n\nconst SELECTORS = {\n CONTACT_DPO: '[data-action=\"contactdpo\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const triggerElement = document.querySelector(SELECTORS.CONTACT_DPO);\n\n triggerElement.addEventListener('click', event => {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('contactdataprotectionofficer', 'tool_dataprivacy'),\n },\n formClass: 'tool_dataprivacy\\\\form\\\\contactdpo',\n saveButtonText: getString('send', 'tool_dataprivacy'),\n returnFocus: triggerElement,\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n getString('requestsubmitted', 'tool_dataprivacy').then(addToast).catch();\n } else {\n const warningMessages = event.detail.warnings.map(warning => warning.message);\n Notification.addNotification({\n type: 'error',\n message: warningMessages.join('
')\n });\n }\n });\n\n modalForm.show();\n });\n};\n"],"names":["SELECTORS","triggerElement","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","then","addToast","catch","warningMessages","warnings","map","warning","message","addNotification","type","join","show"],"mappings":";;;;;;;0LA4BMA,sBACW,2CAMG,WACVC,eAAiBC,SAASC,cAAcH,uBAE9CC,eAAeG,iBAAiB,SAASC,QACrCA,MAAMC,uBAEAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,mBAAU,+BAAgC,qBAErDC,UAAW,qCACXC,gBAAgB,mBAAU,OAAQ,oBAClCC,YAAaZ,iBAIjBM,UAAUH,iBAAiBG,UAAUO,OAAOC,gBAAgBV,WACpDA,MAAMW,OAAOC,2BACH,mBAAoB,oBAAoBC,KAAKC,YAAUC,YAC9D,OACGC,gBAAkBhB,MAAMW,OAAOM,SAASC,KAAIC,SAAWA,QAAQC,gCACxDC,gBAAgB,CACzBC,KAAM,QACNF,QAASJ,gBAAgBO,KAAK,cAK1CrB,UAAUsB"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_deletion.min.js b/admin/tool/dataprivacy/amd/build/data_deletion.min.js index 88f9f42ce41..212a020c29a 100644 --- a/admin/tool/dataprivacy/amd/build/data_deletion.min.js +++ b/admin/tool/dataprivacy/amd/build/data_deletion.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/data_deletion",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var h={MARK_FOR_DELETION:"[data-action=\"markfordeletion\"]",SELECT_ALL:"[data-action=\"selectall\"]"},i={SELECTCONTEXT:".selectcontext"},j=function(){this.registerEvents()};j.prototype.registerEvents=function(){a(h.MARK_FOR_DELETION).click(function(b){b.preventDefault();var c=[];a(i.SELECTCONTEXT).each(function(){var b=a(this);if(b.is(":checked")){c.push(b.val())}});g(c)});a(h.SELECT_ALL).change(function(b){b.preventDefault();var c=a(this);if(c.is(":checked")){a(i.SELECTCONTEXT).attr("checked","checked")}else{a(i.SELECTCONTEXT).removeAttr("checked")}})};function g(a){var g="";d.get_strings([{key:"confirm",component:"moodle"},{key:"confirmcontextdeletion",component:"tool_dataprivacy"}]).then(function(a){g=a[0];var b=a[1];return e.create({title:g,body:b,type:e.types.SAVE_CANCEL})}).then(function(d){d.setSaveButtonText(g);d.getRoot().on(f.save,function(){b.call([{methodname:"tool_dataprivacy_confirm_contexts_for_deletion",args:{ids:a}}])[0].done(function(a){if(a.result){window.location.reload()}else{c.addNotification({message:a.warnings[0].message,type:"error"})}}).fail(c.exception)});d.getRoot().on(f.hidden,function(){d.destroy()});return d}).done(function(a){a.show()}).fail(c.exception)}return j}); -//# sourceMappingURL=data_deletion.min.js.map +/** + * Request actions. + * + * @module tool_dataprivacy/data_deletion + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/data_deletion",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],(function($,Ajax,Notification,Str,ModalFactory,ModalEvents){var ACTIONS_MARK_FOR_DELETION='[data-action="markfordeletion"]',ACTIONS_SELECT_ALL='[data-action="selectall"]',SELECTORS_SELECTCONTEXT=".selectcontext",DataDeletionActions=function(){this.registerEvents()};return DataDeletionActions.prototype.registerEvents=function(){$(ACTIONS_MARK_FOR_DELETION).click((function(e){e.preventDefault();var ids,keys,wsfunction,modalTitle,selectedIds=[];$(SELECTORS_SELECTCONTEXT).each((function(){var checkbox=$(this);checkbox.is(":checked")&&selectedIds.push(checkbox.val())})),ids=selectedIds,keys=[{key:"confirm",component:"moodle"},{key:"confirmcontextdeletion",component:"tool_dataprivacy"}],wsfunction="tool_dataprivacy_confirm_contexts_for_deletion",modalTitle="",Str.get_strings(keys).then((function(langStrings){modalTitle=langStrings[0];var confirmMessage=langStrings[1];return ModalFactory.create({title:modalTitle,body:confirmMessage,type:ModalFactory.types.SAVE_CANCEL})})).then((function(modal){return modal.setSaveButtonText(modalTitle),modal.getRoot().on(ModalEvents.save,(function(){var request={methodname:wsfunction,args:{ids:ids}};Ajax.call([request])[0].done((function(data){data.result?window.location.reload():Notification.addNotification({message:data.warnings[0].message,type:"error"})})).fail(Notification.exception)})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal})).done((function(modal){modal.show()})).fail(Notification.exception)})),$(ACTIONS_SELECT_ALL).change((function(e){e.preventDefault(),$(this).is(":checked")?$(SELECTORS_SELECTCONTEXT).attr("checked","checked"):$(SELECTORS_SELECTCONTEXT).removeAttr("checked")}))},DataDeletionActions})); + +//# sourceMappingURL=data_deletion.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map b/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map index 70995ebd33a..79fec21d7e6 100644 --- a/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map +++ b/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/data_deletion.js"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","MARK_FOR_DELETION","SELECT_ALL","SELECTORS","SELECTCONTEXT","DataDeletionActions","registerEvents","prototype","click","e","preventDefault","selectedIds","each","checkbox","is","push","val","showConfirmation","change","selectallnone","attr","removeAttr","ids","modalTitle","get_strings","key","component","then","langStrings","confirmMessage","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","call","methodname","args","done","data","result","window","location","reload","addNotification","message","warnings","fail","exception","hidden","destroy","show"],"mappings":"AAsBAA,OAAM,kCAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,oBALG,CAMH,mBANG,CAAD,CAON,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAAqCC,CAArC,CAAmDC,CAAnD,CAAgE,IAQxDC,CAAAA,CAAO,CAAG,CACVC,iBAAiB,CAAE,mCADT,CAEVC,UAAU,CAAE,6BAFF,CAR8C,CAkBxDC,CAAS,CAAG,CACZC,aAAa,CAAE,gBADH,CAlB4C,CAyBxDC,CAAmB,CAAG,UAAW,CACjC,KAAKC,cAAL,EACH,CA3B2D,CAgC5DD,CAAmB,CAACE,SAApB,CAA8BD,cAA9B,CAA+C,UAAW,CACtDZ,CAAC,CAACM,CAAO,CAACC,iBAAT,CAAD,CAA6BO,KAA7B,CAAmC,SAASC,CAAT,CAAY,CAC3CA,CAAC,CAACC,cAAF,GAEA,GAAIC,CAAAA,CAAW,CAAG,EAAlB,CACAjB,CAAC,CAACS,CAAS,CAACC,aAAX,CAAD,CAA2BQ,IAA3B,CAAgC,UAAW,CACvC,GAAIC,CAAAA,CAAQ,CAAGnB,CAAC,CAAC,IAAD,CAAhB,CACA,GAAImB,CAAQ,CAACC,EAAT,CAAY,UAAZ,CAAJ,CAA6B,CACzBH,CAAW,CAACI,IAAZ,CAAiBF,CAAQ,CAACG,GAAT,EAAjB,CACH,CACJ,CALD,EAMAC,CAA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AAU,CALI,CACVC,UAAU,CAtBL,gDAqBK,CAEVC,IAAI,CANK,CACT,IAAOrB,CADE,CAIC,CAKJ,CAAV,EAAqB,CAArB,EAAwBsB,IAAxB,CAA6B,SAASC,CAAT,CAAe,CACxC,GAAIA,CAAI,CAACC,MAAT,CAAiB,CACbC,MAAM,CAACC,QAAP,CAAgBC,MAAhB,EACH,CAFD,IAEO,CACHrD,CAAY,CAACsD,eAAb,CAA6B,CACzBC,OAAO,CAAEN,CAAI,CAACO,QAAL,CAAc,CAAd,EAAiBD,OADD,CAEzBlB,IAAI,CAAE,OAFmB,CAA7B,CAIH,CACJ,CATD,EASGoB,IATH,CASQzD,CAAY,CAAC0D,SATrB,CAUH,CArBD,EAwBAlB,CAAK,CAACE,OAAN,GAAgBC,EAAhB,CAAmBxC,CAAW,CAACwD,MAA/B,CAAuC,UAAW,CAE9CnB,CAAK,CAACoB,OAAN,EACH,CAHD,EAKA,MAAOpB,CAAAA,CACV,CA1CD,EA0CGQ,IA1CH,CA0CQ,SAASR,CAAT,CAAgB,CACpBA,CAAK,CAACqB,IAAN,EACH,CA5CD,EA4CGJ,IA5CH,CA4CQzD,CAAY,CAAC0D,SA5CrB,CA6CH,CAED,MAAOjD,CAAAA,CACV,CApIK,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 * Request actions.\n *\n * @module tool_dataprivacy/data_deletion\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{MARK_FOR_DELETION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n MARK_FOR_DELETION: '[data-action=\"markfordeletion\"]',\n SELECT_ALL: '[data-action=\"selectall\"]',\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECTCONTEXT: string}}\n */\n var SELECTORS = {\n SELECTCONTEXT: '.selectcontext',\n };\n\n /**\n * DataDeletionActions class.\n */\n var DataDeletionActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DataDeletionActions.prototype.registerEvents = function() {\n $(ACTIONS.MARK_FOR_DELETION).click(function(e) {\n e.preventDefault();\n\n var selectedIds = [];\n $(SELECTORS.SELECTCONTEXT).each(function() {\n var checkbox = $(this);\n if (checkbox.is(':checked')) {\n selectedIds.push(checkbox.val());\n }\n });\n showConfirmation(selectedIds);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectallnone = $(this);\n if (selectallnone.is(':checked')) {\n $(SELECTORS.SELECTCONTEXT).attr('checked', 'checked');\n } else {\n $(SELECTORS.SELECTCONTEXT).removeAttr('checked');\n }\n });\n };\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {Array} ids The array of expired context record IDs.\n */\n function showConfirmation(ids) {\n var keys = [\n {\n key: 'confirm',\n component: 'moodle'\n },\n {\n key: 'confirmcontextdeletion',\n component: 'tool_dataprivacy'\n }\n ];\n var wsfunction = 'tool_dataprivacy_confirm_contexts_for_deletion';\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n // Confirm the request.\n var params = {\n 'ids': ids\n };\n\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n }).done(function(modal) {\n modal.show();\n }).fail(Notification.exception);\n }\n\n return DataDeletionActions;\n});\n"],"file":"data_deletion.min.js"} \ No newline at end of file +{"version":3,"file":"data_deletion.min.js","sources":["../src/data_deletion.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 * Request actions.\n *\n * @module tool_dataprivacy/data_deletion\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{MARK_FOR_DELETION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n MARK_FOR_DELETION: '[data-action=\"markfordeletion\"]',\n SELECT_ALL: '[data-action=\"selectall\"]',\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECTCONTEXT: string}}\n */\n var SELECTORS = {\n SELECTCONTEXT: '.selectcontext',\n };\n\n /**\n * DataDeletionActions class.\n */\n var DataDeletionActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DataDeletionActions.prototype.registerEvents = function() {\n $(ACTIONS.MARK_FOR_DELETION).click(function(e) {\n e.preventDefault();\n\n var selectedIds = [];\n $(SELECTORS.SELECTCONTEXT).each(function() {\n var checkbox = $(this);\n if (checkbox.is(':checked')) {\n selectedIds.push(checkbox.val());\n }\n });\n showConfirmation(selectedIds);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectallnone = $(this);\n if (selectallnone.is(':checked')) {\n $(SELECTORS.SELECTCONTEXT).attr('checked', 'checked');\n } else {\n $(SELECTORS.SELECTCONTEXT).removeAttr('checked');\n }\n });\n };\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {Array} ids The array of expired context record IDs.\n */\n function showConfirmation(ids) {\n var keys = [\n {\n key: 'confirm',\n component: 'moodle'\n },\n {\n key: 'confirmcontextdeletion',\n component: 'tool_dataprivacy'\n }\n ];\n var wsfunction = 'tool_dataprivacy_confirm_contexts_for_deletion';\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n // Confirm the request.\n var params = {\n 'ids': ids\n };\n\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n }).done(function(modal) {\n modal.show();\n }).fail(Notification.exception);\n }\n\n return DataDeletionActions;\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","SELECTORS","DataDeletionActions","registerEvents","prototype","click","e","preventDefault","ids","keys","wsfunction","modalTitle","selectedIds","each","checkbox","this","is","push","val","key","component","get_strings","then","langStrings","confirmMessage","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","data","result","window","location","reload","addNotification","message","warnings","fail","exception","hidden","destroy","show","change","attr","removeAttr"],"mappings":";;;;;;;AAsBAA,wCAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,iBAQ3CC,0BACmB,kCADnBA,mBAEY,4BAQZC,wBACe,iBAMfC,oBAAsB,gBACjBC,yBAMTD,oBAAoBE,UAAUD,eAAiB,WAC3CT,EAAEM,2BAA2BK,OAAM,SAASC,GACxCA,EAAEC,qBA6BgBC,IAClBC,KAUAC,WAEAC,WAxCIC,YAAc,GAClBlB,EAAEO,yBAAyBY,MAAK,eACxBC,SAAWpB,EAAEqB,MACbD,SAASE,GAAG,aACZJ,YAAYK,KAAKH,SAASI,UAuBhBV,IApBDI,YAqBjBH,KAAO,CACP,CACIU,IAAK,UACLC,UAAW,UAEf,CACID,IAAK,yBACLC,UAAW,qBAGfV,WAAa,iDAEbC,WAAa,GACjBd,IAAIwB,YAAYZ,MAAMa,MAAK,SAASC,aAChCZ,WAAaY,YAAY,OACrBC,eAAiBD,YAAY,UAC1BzB,aAAa2B,OAAO,CACvBC,MAAOf,WACPgB,KAAMH,eACNI,KAAM9B,aAAa+B,MAAMC,iBAE9BR,MAAK,SAASS,cACbA,MAAMC,kBAAkBrB,YAGxBoB,MAAME,UAAUC,GAAGnC,YAAYoC,MAAM,eAM7BC,QAAU,CACVC,WAAY3B,WACZ4B,KANS,KACF9B,MAQXb,KAAK4C,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASC,MAC9BA,KAAKC,OACLC,OAAOC,SAASC,SAEhBjD,aAAakD,gBAAgB,CACzBC,QAASN,KAAKO,SAAS,GAAGD,QAC1BnB,KAAM,aAGfqB,KAAKrD,aAAasD,cAIzBnB,MAAME,UAAUC,GAAGnC,YAAYoD,QAAQ,WAEnCpB,MAAMqB,aAGHrB,SACRS,MAAK,SAAST,OACbA,MAAMsB,UACPJ,KAAKrD,aAAasD,cA3ErBxD,EAAEM,oBAAoBsD,QAAO,SAAShD,GAClCA,EAAEC,iBAEkBb,EAAEqB,MACJC,GAAG,YACjBtB,EAAEO,yBAAyBsD,KAAK,UAAW,WAE3C7D,EAAEO,yBAAyBuD,WAAW,eAuE3CtD"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_registry.min.js b/admin/tool/dataprivacy/amd/build/data_registry.min.js index 44c2310075f..5dd4d5ed6eb 100644 --- a/admin/tool/dataprivacy/amd/build/data_registry.min.js +++ b/admin/tool/dataprivacy/amd/build/data_registry.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/data_registry",["jquery","core/str","core/ajax","core/notification","core/templates","core/modal_factory","core/modal_events","core/fragment","tool_dataprivacy/add_purpose","tool_dataprivacy/add_category"],function(a,b,c,d,e,f,g,h,i,j){var k={TREE_NODES:"[data-context-tree-node=1]",FORM_CONTAINER:"#context-form-container"},l=function(a,b,c){this.systemContextId=a;this.currentContextLevel=b;this.currentContextId=c;this.init()};l.prototype.systemContextId=0;l.prototype.currentContextLevel=0;l.prototype.currentContextId=0;l.prototype.addpurpose=null;l.prototype.addcategory=null;l.prototype.init=function(){this.addpurpose=i.getInstance(this.systemContextId);this.addcategory=j.getInstance(this.systemContextId);this.strings=b.get_strings([{key:"changessaved",component:"moodle"},{key:"contextpurposecategorysaved",component:"tool_dataprivacy"},{key:"noblockstoload",component:"tool_dataprivacy"},{key:"noactivitiestoload",component:"tool_dataprivacy"},{key:"nocoursestoload",component:"tool_dataprivacy"}]);this.registerEventListeners();if(this.currentContextId){this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this))}else{this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this))}};l.prototype.registerEventListeners=function(){a(k.TREE_NODES).on("click",function(b){b.preventDefault();var c=a(b.currentTarget);a(k.TREE_NODES).removeClass("active");c.addClass("active");var d=c.data("contextlevel"),e=c.data("contextid");if(d){window.history.pushState({},null,"?contextlevel="+d);this.addpurpose.removeListeners();this.addcategory.removeListeners();this.currentContextLevel=d;this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this))}else if(e){window.history.pushState({},null,"?contextid="+e);this.addpurpose.removeListeners();this.addcategory.removeListeners();this.currentContextId=e;this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this))}else{var f=c.data("expandcontextid"),g=c.data("expandelement"),h=c.data("expanded");if(g){if(!h){if(c.data("loaded")||!f||!g){this.expand(c)}else{c.find("> i").removeClass("fa-plus");c.find("> i").addClass("fa-circle-o-notch fa-spin");this.loadExtra(c,f,g)}}else{this.collapse(c)}}}}.bind(this))};l.prototype.removeListeners=function(){a(k.TREE_NODES).off("click")};l.prototype.loadForm=function(b,c,f){this.clearForm();var g=h.loadFragment("tool_dataprivacy",b,this.systemContextId,c);g.done(function(b,c){a(k.FORM_CONTAINER).html(b);e.runTemplateJS(c);this.addpurpose.registerEventListeners();this.addcategory.registerEventListeners();a(k.FORM_CONTAINER).on("submit","form",f)}.bind(this)).fail(d.exception)};l.prototype.clearForm=function(){a(k.FORM_CONTAINER).off("submit","form")};l.prototype.submitForm=function(b){b.preventDefault();a(k.FORM_CONTAINER).find("form").submit()};l.prototype.submitContextLevelFormAjax=function(a){this.submitFormAjax(a,"tool_dataprivacy_set_contextlevel_form")};l.prototype.submitContextFormAjax=function(a){this.submitFormAjax(a,"tool_dataprivacy_set_context_form")};l.prototype.submitFormAjax=function(b,e){b.preventDefault();var f=a(k.FORM_CONTAINER).find("form").serialize();return this.strings.then(function(a){c.call([{methodname:e,args:{jsonformdata:JSON.stringify(f)},done:function done(){d.alert(a[0],a[1])},fail:d.exception}])}).catch(d.exception)};l.prototype.loadExtra=function(a,b,f){c.call([{methodname:"tool_dataprivacy_tree_extra_branches",args:{contextid:b,element:f},done:function(b){if(0==b.branches.length){this.noElements(a,f);return}e.render("tool_dataprivacy/context_tree_branches",b).then(function(b){a.after(b);this.removeListeners();this.registerEventListeners();this.expand(a);a.data("loaded",1)}.bind(this)).fail(d.exception)}.bind(this),fail:d.exception}])};l.prototype.noElements=function(a,b){a.data("expandcontextid","");a.data("expandelement","");this.strings.then(function(c){var d=2;if("module"==b){d=3}else if("course"==b){d=4}a.text(c[d])}).fail(d.exception)};l.prototype.collapse=function(a){a.data("expanded",0);a.siblings("nav").addClass("hidden");a.find("> i").removeClass("fa-minus");a.find("> i").addClass("fa-plus")};l.prototype.expand=function(a){a.data("expanded",1);a.siblings("nav").removeClass("hidden");a.find("> i").removeClass("fa-plus");a.find("> i").removeClass("fa-circle-o-notch fa-spin");a.find("> i").addClass("fa-minus")};return{init:function init(a,b,c){return new l(a,b,c)}}}); -//# sourceMappingURL=data_registry.min.js.map +/** + * Request actions. + * + * @module tool_dataprivacy/data_registry + * @copyright 2018 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/data_registry",["jquery","core/str","core/ajax","core/notification","core/templates","core/modal_factory","core/modal_events","core/fragment","tool_dataprivacy/add_purpose","tool_dataprivacy/add_category"],(function($,Str,Ajax,Notification,Templates,ModalFactory,ModalEvents,Fragment,AddPurpose,AddCategory){var SELECTORS_TREE_NODES="[data-context-tree-node=1]",SELECTORS_FORM_CONTAINER="#context-form-container",DataRegistry=function(systemContextId,initContextLevel,initContextId){this.systemContextId=systemContextId,this.currentContextLevel=initContextLevel,this.currentContextId=initContextId,this.init()};return DataRegistry.prototype.systemContextId=0,DataRegistry.prototype.currentContextLevel=0,DataRegistry.prototype.currentContextId=0,DataRegistry.prototype.addpurpose=null,DataRegistry.prototype.addcategory=null,DataRegistry.prototype.init=function(){this.addpurpose=AddPurpose.getInstance(this.systemContextId),this.addcategory=AddCategory.getInstance(this.systemContextId);this.strings=Str.get_strings([{key:"changessaved",component:"moodle"},{key:"contextpurposecategorysaved",component:"tool_dataprivacy"},{key:"noblockstoload",component:"tool_dataprivacy"},{key:"noactivitiestoload",component:"tool_dataprivacy"},{key:"nocoursestoload",component:"tool_dataprivacy"}]),this.registerEventListeners(),this.currentContextId?this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this)):this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this))},DataRegistry.prototype.registerEventListeners=function(){$(SELECTORS_TREE_NODES).on("click",function(ev){ev.preventDefault();var trigger=$(ev.currentTarget);$(SELECTORS_TREE_NODES).removeClass("active"),trigger.addClass("active");var contextLevel=trigger.data("contextlevel"),contextId=trigger.data("contextid");if(contextLevel)window.history.pushState({},null,"?contextlevel="+contextLevel),this.addpurpose.removeListeners(),this.addcategory.removeListeners(),this.currentContextLevel=contextLevel,this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this));else if(contextId)window.history.pushState({},null,"?contextid="+contextId),this.addpurpose.removeListeners(),this.addcategory.removeListeners(),this.currentContextId=contextId,this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this));else{var expandContextId=trigger.data("expandcontextid"),expandElement=trigger.data("expandelement"),expanded=trigger.data("expanded");expandElement&&(expanded?this.collapse(trigger):!trigger.data("loaded")&&expandContextId&&expandElement?(trigger.find("> i").removeClass("fa-plus"),trigger.find("> i").addClass("fa-circle-o-notch fa-spin"),this.loadExtra(trigger,expandContextId,expandElement)):this.expand(trigger))}}.bind(this))},DataRegistry.prototype.removeListeners=function(){$(SELECTORS_TREE_NODES).off("click")},DataRegistry.prototype.loadForm=function(fragmentName,fragmentArgs,formSubmitCallback){this.clearForm(),Fragment.loadFragment("tool_dataprivacy",fragmentName,this.systemContextId,fragmentArgs).done(function(html,js){$(SELECTORS_FORM_CONTAINER).html(html),Templates.runTemplateJS(js),this.addpurpose.registerEventListeners(),this.addcategory.registerEventListeners(),$(SELECTORS_FORM_CONTAINER).on("submit","form",formSubmitCallback)}.bind(this)).fail(Notification.exception)},DataRegistry.prototype.clearForm=function(){$(SELECTORS_FORM_CONTAINER).off("submit","form")},DataRegistry.prototype.submitForm=function(e){e.preventDefault(),$(SELECTORS_FORM_CONTAINER).find("form").submit()},DataRegistry.prototype.submitContextLevelFormAjax=function(e){this.submitFormAjax(e,"tool_dataprivacy_set_contextlevel_form")},DataRegistry.prototype.submitContextFormAjax=function(e){this.submitFormAjax(e,"tool_dataprivacy_set_context_form")},DataRegistry.prototype.submitFormAjax=function(e,saveMethodName){e.preventDefault();var formData=$(SELECTORS_FORM_CONTAINER).find("form").serialize();return this.strings.then((function(strings){Ajax.call([{methodname:saveMethodName,args:{jsonformdata:JSON.stringify(formData)},done:function(){Notification.alert(strings[0],strings[1])},fail:Notification.exception}])})).catch(Notification.exception)},DataRegistry.prototype.loadExtra=function(parentNode,expandContextId,expandElement){Ajax.call([{methodname:"tool_dataprivacy_tree_extra_branches",args:{contextid:expandContextId,element:expandElement},done:function(data){0!=data.branches.length?Templates.render("tool_dataprivacy/context_tree_branches",data).then(function(html){parentNode.after(html),this.removeListeners(),this.registerEventListeners(),this.expand(parentNode),parentNode.data("loaded",1)}.bind(this)).fail(Notification.exception):this.noElements(parentNode,expandElement)}.bind(this),fail:Notification.exception}])},DataRegistry.prototype.noElements=function(node,expandElement){node.data("expandcontextid",""),node.data("expandelement",""),this.strings.then((function(strings){var key=2;"module"==expandElement?key=3:"course"==expandElement&&(key=4),node.text(strings[key])})).fail(Notification.exception)},DataRegistry.prototype.collapse=function(node){node.data("expanded",0),node.siblings("nav").addClass("hidden"),node.find("> i").removeClass("fa-minus"),node.find("> i").addClass("fa-plus")},DataRegistry.prototype.expand=function(node){node.data("expanded",1),node.siblings("nav").removeClass("hidden"),node.find("> i").removeClass("fa-plus"),node.find("> i").removeClass("fa-circle-o-notch fa-spin"),node.find("> i").addClass("fa-minus")},{init:function(systemContextId,initContextLevel,initContextId){return new DataRegistry(systemContextId,initContextLevel,initContextId)}}})); + +//# sourceMappingURL=data_registry.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_registry.min.js.map b/admin/tool/dataprivacy/amd/build/data_registry.min.js.map index 02e3bb008c7..235aef226ce 100644 --- a/admin/tool/dataprivacy/amd/build/data_registry.min.js.map +++ b/admin/tool/dataprivacy/amd/build/data_registry.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/data_registry.js"],"names":["define","$","Str","Ajax","Notification","Templates","ModalFactory","ModalEvents","Fragment","AddPurpose","AddCategory","SELECTORS","TREE_NODES","FORM_CONTAINER","DataRegistry","systemContextId","initContextLevel","initContextId","currentContextLevel","currentContextId","init","prototype","addpurpose","addcategory","getInstance","strings","get_strings","key","component","registerEventListeners","loadForm","submitContextFormAjax","bind","submitContextLevelFormAjax","on","ev","preventDefault","trigger","currentTarget","removeClass","addClass","contextLevel","data","contextId","window","history","pushState","removeListeners","expandContextId","expandElement","expanded","expand","find","loadExtra","collapse","off","fragmentName","fragmentArgs","formSubmitCallback","clearForm","fragment","loadFragment","done","html","js","runTemplateJS","fail","exception","submitForm","e","submit","submitFormAjax","saveMethodName","formData","serialize","then","call","methodname","args","jsonformdata","JSON","stringify","alert","catch","parentNode","contextid","element","branches","length","noElements","render","after","node","text","siblings"],"mappings":"AAsBAA,OAAM,kCAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,WAAvB,CAAoC,mBAApC,CAAyD,gBAAzD,CAA2E,oBAA3E,CACH,mBADG,CACkB,eADlB,CACmC,8BADnC,CACmE,+BADnE,CAAD,CAEF,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAAuBC,CAAvB,CAAqCC,CAArC,CAAgDC,CAAhD,CAA8DC,CAA9D,CAA2EC,CAA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B,EACAqD,CAAI,CAACxC,IAAL,CAAU,KAAV,EAAiBZ,QAAjB,CAA0B,SAA1B,CACH,CALD,CAOA1B,CAAY,CAACO,SAAb,CAAuB8B,MAAvB,CAAgC,SAASyC,CAAT,CAAe,CAC3CA,CAAI,CAAClD,IAAL,CAAU,UAAV,CAAsB,CAAtB,EACAkD,CAAI,CAACE,QAAL,CAAc,KAAd,EAAqBvD,WAArB,CAAiC,QAAjC,EACAqD,CAAI,CAACxC,IAAL,CAAU,KAAV,EAAiBb,WAAjB,CAA6B,SAA7B,EAEAqD,CAAI,CAACxC,IAAL,CAAU,KAAV,EAAiBb,WAAjB,CAA6B,2BAA7B,EACAqD,CAAI,CAACxC,IAAL,CAAU,KAAV,EAAiBZ,QAAjB,CAA0B,UAA1B,CACH,CAPD,CAQA,MAA2D,CAUvDpB,IAAI,CAAE,cAASL,CAAT,CAA0BC,CAA1B,CAA4CC,CAA5C,CAA2D,CAC7D,MAAO,IAAIH,CAAAA,CAAJ,CAAiBC,CAAjB,CAAkCC,CAAlC,CAAoDC,CAApD,CACV,CAZsD,CAc9D,CA/RC,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 * Request actions.\n *\n * @module tool_dataprivacy/data_registry\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/templates', 'core/modal_factory',\n 'core/modal_events', 'core/fragment', 'tool_dataprivacy/add_purpose', 'tool_dataprivacy/add_category'],\n function($, Str, Ajax, Notification, Templates, ModalFactory, ModalEvents, Fragment, AddPurpose, AddCategory) {\n\n var SELECTORS = {\n TREE_NODES: '[data-context-tree-node=1]',\n FORM_CONTAINER: '#context-form-container',\n };\n\n var DataRegistry = function(systemContextId, initContextLevel, initContextId) {\n this.systemContextId = systemContextId;\n this.currentContextLevel = initContextLevel;\n this.currentContextId = initContextId;\n this.init();\n };\n\n /**\n * @var {int} systemContextId\n * @private\n */\n DataRegistry.prototype.systemContextId = 0;\n\n /**\n * @var {int} currentContextLevel\n * @private\n */\n DataRegistry.prototype.currentContextLevel = 0;\n\n /**\n * @var {int} currentContextId\n * @private\n */\n DataRegistry.prototype.currentContextId = 0;\n\n /**\n * @var {AddPurpose} addpurpose\n * @private\n */\n DataRegistry.prototype.addpurpose = null;\n\n /**\n * @var {AddCategory} addcategory\n * @private\n */\n DataRegistry.prototype.addcategory = null;\n\n DataRegistry.prototype.init = function() {\n // Add purpose and category modals always at system context.\n this.addpurpose = AddPurpose.getInstance(this.systemContextId);\n this.addcategory = AddCategory.getInstance(this.systemContextId);\n\n var stringKeys = [\n {\n key: 'changessaved',\n component: 'moodle'\n }, {\n key: 'contextpurposecategorysaved',\n component: 'tool_dataprivacy'\n }, {\n key: 'noblockstoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'noactivitiestoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'nocoursestoload',\n component: 'tool_dataprivacy'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n\n // Load the default context level form.\n if (this.currentContextId) {\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n }\n };\n\n DataRegistry.prototype.registerEventListeners = function() {\n $(SELECTORS.TREE_NODES).on('click', function(ev) {\n ev.preventDefault();\n\n var trigger = $(ev.currentTarget);\n\n // Active node.\n $(SELECTORS.TREE_NODES).removeClass('active');\n trigger.addClass('active');\n\n var contextLevel = trigger.data('contextlevel');\n var contextId = trigger.data('contextid');\n if (contextLevel) {\n // Context level level.\n\n window.history.pushState({}, null, '?contextlevel=' + contextLevel);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextLevel = contextLevel;\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n } else if (contextId) {\n // Context instance level.\n\n window.history.pushState({}, null, '?contextid=' + contextId);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextId = contextId;\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n // Expandable nodes.\n\n var expandContextId = trigger.data('expandcontextid');\n var expandElement = trigger.data('expandelement');\n var expanded = trigger.data('expanded');\n\n // Extra checking that there is an expandElement because we remove it after loading 0 branches.\n if (expandElement) {\n\n if (!expanded) {\n if (trigger.data('loaded') || !expandContextId || !expandElement) {\n this.expand(trigger);\n } else {\n\n trigger.find('> i').removeClass('fa-plus');\n trigger.find('> i').addClass('fa-circle-o-notch fa-spin');\n this.loadExtra(trigger, expandContextId, expandElement);\n }\n } else {\n this.collapse(trigger);\n }\n }\n }\n\n }.bind(this));\n };\n\n DataRegistry.prototype.removeListeners = function() {\n $(SELECTORS.TREE_NODES).off('click');\n };\n\n DataRegistry.prototype.loadForm = function(fragmentName, fragmentArgs, formSubmitCallback) {\n\n this.clearForm();\n\n var fragment = Fragment.loadFragment('tool_dataprivacy', fragmentName, this.systemContextId, fragmentArgs);\n fragment.done(function(html, js) {\n\n $(SELECTORS.FORM_CONTAINER).html(html);\n Templates.runTemplateJS(js);\n\n this.addpurpose.registerEventListeners();\n this.addcategory.registerEventListeners();\n\n // We also catch the form submit event and use it to submit the form with ajax.\n $(SELECTORS.FORM_CONTAINER).on('submit', 'form', formSubmitCallback);\n\n }.bind(this)).fail(Notification.exception);\n };\n\n DataRegistry.prototype.clearForm = function() {\n // Remove previous listeners.\n $(SELECTORS.FORM_CONTAINER).off('submit', 'form');\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n DataRegistry.prototype.submitForm = function(e) {\n e.preventDefault();\n $(SELECTORS.FORM_CONTAINER).find('form').submit();\n };\n\n DataRegistry.prototype.submitContextLevelFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_contextlevel_form');\n };\n\n DataRegistry.prototype.submitContextFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_context_form');\n };\n\n DataRegistry.prototype.submitFormAjax = function(e, saveMethodName) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = $(SELECTORS.FORM_CONTAINER).find('form').serialize();\n return this.strings.then(function(strings) {\n Ajax.call([{\n methodname: saveMethodName,\n args: {jsonformdata: JSON.stringify(formData)},\n done: function() {\n Notification.alert(strings[0], strings[1]);\n },\n fail: Notification.exception\n }]);\n return;\n }).catch(Notification.exception);\n\n };\n\n DataRegistry.prototype.loadExtra = function(parentNode, expandContextId, expandElement) {\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_tree_extra_branches',\n args: {\n contextid: expandContextId,\n element: expandElement,\n },\n done: function(data) {\n if (data.branches.length == 0) {\n this.noElements(parentNode, expandElement);\n return;\n }\n Templates.render('tool_dataprivacy/context_tree_branches', data)\n .then(function(html) {\n parentNode.after(html);\n this.removeListeners();\n this.registerEventListeners();\n this.expand(parentNode);\n parentNode.data('loaded', 1);\n return;\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n DataRegistry.prototype.noElements = function(node, expandElement) {\n node.data('expandcontextid', '');\n node.data('expandelement', '');\n this.strings.then(function(strings) {\n\n // 2 = blocks, 3 = activities, 4 = courses (although courses is not likely really).\n var key = 2;\n if (expandElement == 'module') {\n key = 3;\n } else if (expandElement == 'course') {\n key = 4;\n }\n node.text(strings[key]);\n return;\n }).fail(Notification.exception);\n };\n\n DataRegistry.prototype.collapse = function(node) {\n node.data('expanded', 0);\n node.siblings('nav').addClass('hidden');\n node.find('> i').removeClass('fa-minus');\n node.find('> i').addClass('fa-plus');\n };\n\n DataRegistry.prototype.expand = function(node) {\n node.data('expanded', 1);\n node.siblings('nav').removeClass('hidden');\n node.find('> i').removeClass('fa-plus');\n // Also remove the spinning one if data was just loaded.\n node.find('> i').removeClass('fa-circle-o-notch fa-spin');\n node.find('> i').addClass('fa-minus');\n };\n return /** @alias module:tool_dataprivacy/data_registry */ {\n\n /**\n * Initialise the page.\n *\n * @param {Number} systemContextId\n * @param {Number} initContextLevel\n * @param {Number} initContextId\n * @return {DataRegistry}\n */\n init: function(systemContextId, initContextLevel, initContextId) {\n return new DataRegistry(systemContextId, initContextLevel, initContextId);\n }\n };\n }\n);\n\n"],"file":"data_registry.min.js"} \ No newline at end of file +{"version":3,"file":"data_registry.min.js","sources":["../src/data_registry.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 * Request actions.\n *\n * @module tool_dataprivacy/data_registry\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/templates', 'core/modal_factory',\n 'core/modal_events', 'core/fragment', 'tool_dataprivacy/add_purpose', 'tool_dataprivacy/add_category'],\n function($, Str, Ajax, Notification, Templates, ModalFactory, ModalEvents, Fragment, AddPurpose, AddCategory) {\n\n var SELECTORS = {\n TREE_NODES: '[data-context-tree-node=1]',\n FORM_CONTAINER: '#context-form-container',\n };\n\n var DataRegistry = function(systemContextId, initContextLevel, initContextId) {\n this.systemContextId = systemContextId;\n this.currentContextLevel = initContextLevel;\n this.currentContextId = initContextId;\n this.init();\n };\n\n /**\n * @var {int} systemContextId\n * @private\n */\n DataRegistry.prototype.systemContextId = 0;\n\n /**\n * @var {int} currentContextLevel\n * @private\n */\n DataRegistry.prototype.currentContextLevel = 0;\n\n /**\n * @var {int} currentContextId\n * @private\n */\n DataRegistry.prototype.currentContextId = 0;\n\n /**\n * @var {AddPurpose} addpurpose\n * @private\n */\n DataRegistry.prototype.addpurpose = null;\n\n /**\n * @var {AddCategory} addcategory\n * @private\n */\n DataRegistry.prototype.addcategory = null;\n\n DataRegistry.prototype.init = function() {\n // Add purpose and category modals always at system context.\n this.addpurpose = AddPurpose.getInstance(this.systemContextId);\n this.addcategory = AddCategory.getInstance(this.systemContextId);\n\n var stringKeys = [\n {\n key: 'changessaved',\n component: 'moodle'\n }, {\n key: 'contextpurposecategorysaved',\n component: 'tool_dataprivacy'\n }, {\n key: 'noblockstoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'noactivitiestoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'nocoursestoload',\n component: 'tool_dataprivacy'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n\n // Load the default context level form.\n if (this.currentContextId) {\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n }\n };\n\n DataRegistry.prototype.registerEventListeners = function() {\n $(SELECTORS.TREE_NODES).on('click', function(ev) {\n ev.preventDefault();\n\n var trigger = $(ev.currentTarget);\n\n // Active node.\n $(SELECTORS.TREE_NODES).removeClass('active');\n trigger.addClass('active');\n\n var contextLevel = trigger.data('contextlevel');\n var contextId = trigger.data('contextid');\n if (contextLevel) {\n // Context level level.\n\n window.history.pushState({}, null, '?contextlevel=' + contextLevel);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextLevel = contextLevel;\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n } else if (contextId) {\n // Context instance level.\n\n window.history.pushState({}, null, '?contextid=' + contextId);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextId = contextId;\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n // Expandable nodes.\n\n var expandContextId = trigger.data('expandcontextid');\n var expandElement = trigger.data('expandelement');\n var expanded = trigger.data('expanded');\n\n // Extra checking that there is an expandElement because we remove it after loading 0 branches.\n if (expandElement) {\n\n if (!expanded) {\n if (trigger.data('loaded') || !expandContextId || !expandElement) {\n this.expand(trigger);\n } else {\n\n trigger.find('> i').removeClass('fa-plus');\n trigger.find('> i').addClass('fa-circle-o-notch fa-spin');\n this.loadExtra(trigger, expandContextId, expandElement);\n }\n } else {\n this.collapse(trigger);\n }\n }\n }\n\n }.bind(this));\n };\n\n DataRegistry.prototype.removeListeners = function() {\n $(SELECTORS.TREE_NODES).off('click');\n };\n\n DataRegistry.prototype.loadForm = function(fragmentName, fragmentArgs, formSubmitCallback) {\n\n this.clearForm();\n\n var fragment = Fragment.loadFragment('tool_dataprivacy', fragmentName, this.systemContextId, fragmentArgs);\n fragment.done(function(html, js) {\n\n $(SELECTORS.FORM_CONTAINER).html(html);\n Templates.runTemplateJS(js);\n\n this.addpurpose.registerEventListeners();\n this.addcategory.registerEventListeners();\n\n // We also catch the form submit event and use it to submit the form with ajax.\n $(SELECTORS.FORM_CONTAINER).on('submit', 'form', formSubmitCallback);\n\n }.bind(this)).fail(Notification.exception);\n };\n\n DataRegistry.prototype.clearForm = function() {\n // Remove previous listeners.\n $(SELECTORS.FORM_CONTAINER).off('submit', 'form');\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n DataRegistry.prototype.submitForm = function(e) {\n e.preventDefault();\n $(SELECTORS.FORM_CONTAINER).find('form').submit();\n };\n\n DataRegistry.prototype.submitContextLevelFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_contextlevel_form');\n };\n\n DataRegistry.prototype.submitContextFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_context_form');\n };\n\n DataRegistry.prototype.submitFormAjax = function(e, saveMethodName) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = $(SELECTORS.FORM_CONTAINER).find('form').serialize();\n return this.strings.then(function(strings) {\n Ajax.call([{\n methodname: saveMethodName,\n args: {jsonformdata: JSON.stringify(formData)},\n done: function() {\n Notification.alert(strings[0], strings[1]);\n },\n fail: Notification.exception\n }]);\n return;\n }).catch(Notification.exception);\n\n };\n\n DataRegistry.prototype.loadExtra = function(parentNode, expandContextId, expandElement) {\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_tree_extra_branches',\n args: {\n contextid: expandContextId,\n element: expandElement,\n },\n done: function(data) {\n if (data.branches.length == 0) {\n this.noElements(parentNode, expandElement);\n return;\n }\n Templates.render('tool_dataprivacy/context_tree_branches', data)\n .then(function(html) {\n parentNode.after(html);\n this.removeListeners();\n this.registerEventListeners();\n this.expand(parentNode);\n parentNode.data('loaded', 1);\n return;\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n DataRegistry.prototype.noElements = function(node, expandElement) {\n node.data('expandcontextid', '');\n node.data('expandelement', '');\n this.strings.then(function(strings) {\n\n // 2 = blocks, 3 = activities, 4 = courses (although courses is not likely really).\n var key = 2;\n if (expandElement == 'module') {\n key = 3;\n } else if (expandElement == 'course') {\n key = 4;\n }\n node.text(strings[key]);\n return;\n }).fail(Notification.exception);\n };\n\n DataRegistry.prototype.collapse = function(node) {\n node.data('expanded', 0);\n node.siblings('nav').addClass('hidden');\n node.find('> i').removeClass('fa-minus');\n node.find('> i').addClass('fa-plus');\n };\n\n DataRegistry.prototype.expand = function(node) {\n node.data('expanded', 1);\n node.siblings('nav').removeClass('hidden');\n node.find('> i').removeClass('fa-plus');\n // Also remove the spinning one if data was just loaded.\n node.find('> i').removeClass('fa-circle-o-notch fa-spin');\n node.find('> i').addClass('fa-minus');\n };\n return /** @alias module:tool_dataprivacy/data_registry */ {\n\n /**\n * Initialise the page.\n *\n * @param {Number} systemContextId\n * @param {Number} initContextLevel\n * @param {Number} initContextId\n * @return {DataRegistry}\n */\n init: function(systemContextId, initContextLevel, initContextId) {\n return new DataRegistry(systemContextId, initContextLevel, initContextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","Templates","ModalFactory","ModalEvents","Fragment","AddPurpose","AddCategory","SELECTORS","DataRegistry","systemContextId","initContextLevel","initContextId","currentContextLevel","currentContextId","init","prototype","addpurpose","addcategory","getInstance","this","strings","get_strings","key","component","registerEventListeners","loadForm","submitContextFormAjax","bind","submitContextLevelFormAjax","on","ev","preventDefault","trigger","currentTarget","removeClass","addClass","contextLevel","data","contextId","window","history","pushState","removeListeners","expandContextId","expandElement","expanded","collapse","find","loadExtra","expand","off","fragmentName","fragmentArgs","formSubmitCallback","clearForm","loadFragment","done","html","js","runTemplateJS","fail","exception","submitForm","e","submit","submitFormAjax","saveMethodName","formData","serialize","then","call","methodname","args","jsonformdata","JSON","stringify","alert","catch","parentNode","contextid","element","branches","length","render","after","noElements","node","text","siblings"],"mappings":";;;;;;;AAsBAA,wCAAO,CAAC,SAAU,WAAY,YAAa,oBAAqB,iBAAkB,qBAC9E,o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AAS,SAASqC,MACrCA,KAAKjD,KAAK,WAAY,GACtBiD,KAAKE,SAAS,OAAOtD,YAAY,UACjCoD,KAAKvC,KAAK,OAAOb,YAAY,WAE7BoD,KAAKvC,KAAK,OAAOb,YAAY,6BAC7BoD,KAAKvC,KAAK,OAAOZ,SAAS,aAE6B,CAUvDrB,KAAM,SAASL,gBAAiBC,iBAAkBC,sBACvC,IAAIH,aAAaC,gBAAiBC,iBAAkBC"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js index 2027d4408fd..bb9b4c44ef3 100644 --- a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js +++ b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/data_request_modal",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","tool_dataprivacy/events"],function(a,b,c,d,e,f){var g=!1,h={APPROVE_BUTTON:"[data-action=\"approve\"]",DENY_BUTTON:"[data-action=\"deny\"]",COMPLETE_BUTTON:"[data-action=\"complete\"]"},i=function(a){d.call(this,a)};i.TYPE="tool_dataprivacy-data_request";i.prototype=Object.create(d.prototype);i.prototype.constructor=i;i.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this);this.getModal().on(c.events.activate,h.APPROVE_BUTTON,function(b,c){var d=a.Event(f.approve);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this));this.getModal().on(c.events.activate,h.DENY_BUTTON,function(b,c){var d=a.Event(f.deny);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this));this.getModal().on(c.events.activate,h.COMPLETE_BUTTON,function(b,c){var d=a.Event(f.complete);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this))};if(!g){e.register(i.TYPE,i,"tool_dataprivacy/data_request_modal");g=!0}return i}); -//# sourceMappingURL=data_request_modal.min.js.map +/** + * Request actions. + * + * @module tool_dataprivacy/data_request_modal + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/data_request_modal",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","tool_dataprivacy/events"],(function($,Notification,CustomEvents,Modal,ModalRegistry,DataPrivacyEvents){var registered=!1,SELECTORS_APPROVE_BUTTON='[data-action="approve"]',SELECTORS_DENY_BUTTON='[data-action="deny"]',SELECTORS_COMPLETE_BUTTON='[data-action="complete"]',ModalDataRequest=function(root){Modal.call(this,root)};return ModalDataRequest.TYPE="tool_dataprivacy-data_request",(ModalDataRequest.prototype=Object.create(Modal.prototype)).constructor=ModalDataRequest,ModalDataRequest.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_APPROVE_BUTTON,function(e,data){var approveEvent=$.Event(DataPrivacyEvents.approve);this.getRoot().trigger(approveEvent,this),approveEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_DENY_BUTTON,function(e,data){var denyEvent=$.Event(DataPrivacyEvents.deny);this.getRoot().trigger(denyEvent,this),denyEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_COMPLETE_BUTTON,function(e,data){var completeEvent=$.Event(DataPrivacyEvents.complete);this.getRoot().trigger(completeEvent,this),completeEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this))},registered||(ModalRegistry.register(ModalDataRequest.TYPE,ModalDataRequest,"tool_dataprivacy/data_request_modal"),registered=!0),ModalDataRequest})); + +//# sourceMappingURL=data_request_modal.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map index b8e2c8bb9d9..ef4fbb7deda 100644 --- a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map +++ b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/data_request_modal.js"],"names":["define","$","Notification","CustomEvents","Modal","ModalRegistry","DataPrivacyEvents","registered","SELECTORS","APPROVE_BUTTON","DENY_BUTTON","COMPLETE_BUTTON","ModalDataRequest","root","call","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","approveEvent","Event","approve","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","denyEvent","deny","completeEvent","complete","register"],"mappings":"AAsBAA,OAAM,uCAAC,CAAC,QAAD,CAAW,mBAAX,CAAgC,gCAAhC,CAAkE,YAAlE,CAAgF,qBAAhF,CACC,yBADD,CAAD,CAEF,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAwCC,CAAxC,CAA+CC,CAA/C,CAA8DC,CAA9D,CAAiF,IAEzEC,CAAAA,CAAU,GAF+D,CAGzEC,CAAS,CAAG,CACZC,cAAc,CAAE,2BADJ,CAEZC,WAAW,CAAE,wBAFD,CAGZC,eAAe,CAAE,4BAHL,CAH6D,CAczEC,CAAgB,CAAG,SAASC,CAAT,CAAe,CAClCT,CAAK,CAACU,IAAN,CAAW,IAAX,CAAiBD,CAAjB,CACH,CAhB4E,CAkB7ED,CAAgB,CAACG,IAAjB,CAAwB,+BAAxB,CACAH,CAAgB,CAACI,SAAjB,CAA6BC,MAAM,CAACC,MAAP,CAAcd,CAAK,CAACY,SAApB,CAA7B,CACAJ,CAAgB,CAACI,SAAjB,CAA2BG,WAA3B,CAAyCP,CAAzC,CAOAA,CAAgB,CAACI,SAAjB,CAA2BI,sBAA3B,CAAoD,UAAW,CAE3DhB,CAAK,CAACY,SAAN,CAAgBI,sBAAhB,CAAuCN,IAAvC,CAA4C,IAA5C,EAEA,KAAKO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GAAI,CAACA,CAAa,CAACP,kBAAd,EAAL,CAAyC,CACrC,KAAKC,IAAL,GACAP,CAAI,CAACQ,aAAL,CAAmBC,cAAnB,EACH,CACJ,CAR2E,CAQ1EC,IAR0E,CAQrE,IARqE,CAA5E,CASH,CAjCD,CAqCA,GAAI,CAAC7B,CAAL,CAAiB,CACbF,CAAa,CAACoC,QAAd,CAAuB7B,CAAgB,CAACG,IAAxC,CAA8CH,CAA9C,CAAgE,qCAAhE,EACAL,CAAU,GACb,CAED,MAAOK,CAAAA,CACV,CAxEC,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 * Request actions.\n *\n * @module tool_dataprivacy/data_request_modal\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/modal', 'core/modal_registry',\n 'tool_dataprivacy/events'],\n function($, Notification, CustomEvents, Modal, ModalRegistry, DataPrivacyEvents) {\n\n var registered = false;\n var SELECTORS = {\n APPROVE_BUTTON: '[data-action=\"approve\"]',\n DENY_BUTTON: '[data-action=\"deny\"]',\n COMPLETE_BUTTON: '[data-action=\"complete\"]'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDataRequest = function(root) {\n Modal.call(this, root);\n };\n\n ModalDataRequest.TYPE = 'tool_dataprivacy-data_request';\n ModalDataRequest.prototype = Object.create(Modal.prototype);\n ModalDataRequest.prototype.constructor = ModalDataRequest;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDataRequest.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, function(e, data) {\n var approveEvent = $.Event(DataPrivacyEvents.approve);\n this.getRoot().trigger(approveEvent, this);\n\n if (!approveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, function(e, data) {\n var denyEvent = $.Event(DataPrivacyEvents.deny);\n this.getRoot().trigger(denyEvent, this);\n\n if (!denyEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, function(e, data) {\n var completeEvent = $.Event(DataPrivacyEvents.complete);\n this.getRoot().trigger(completeEvent, this);\n\n if (!completeEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDataRequest.TYPE, ModalDataRequest, 'tool_dataprivacy/data_request_modal');\n registered = true;\n }\n\n return ModalDataRequest;\n });"],"file":"data_request_modal.min.js"} \ No newline at end of file +{"version":3,"file":"data_request_modal.min.js","sources":["../src/data_request_modal.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 * Request actions.\n *\n * @module tool_dataprivacy/data_request_modal\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/modal', 'core/modal_registry',\n 'tool_dataprivacy/events'],\n function($, Notification, CustomEvents, Modal, ModalRegistry, DataPrivacyEvents) {\n\n var registered = false;\n var SELECTORS = {\n APPROVE_BUTTON: '[data-action=\"approve\"]',\n DENY_BUTTON: '[data-action=\"deny\"]',\n COMPLETE_BUTTON: '[data-action=\"complete\"]'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDataRequest = function(root) {\n Modal.call(this, root);\n };\n\n ModalDataRequest.TYPE = 'tool_dataprivacy-data_request';\n ModalDataRequest.prototype = Object.create(Modal.prototype);\n ModalDataRequest.prototype.constructor = ModalDataRequest;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDataRequest.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, function(e, data) {\n var approveEvent = $.Event(DataPrivacyEvents.approve);\n this.getRoot().trigger(approveEvent, this);\n\n if (!approveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, function(e, data) {\n var denyEvent = $.Event(DataPrivacyEvents.deny);\n this.getRoot().trigger(denyEvent, this);\n\n if (!denyEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, function(e, data) {\n var completeEvent = $.Event(DataPrivacyEvents.complete);\n this.getRoot().trigger(completeEvent, this);\n\n if (!completeEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDataRequest.TYPE, ModalDataRequest, 'tool_dataprivacy/data_request_modal');\n registered = true;\n }\n\n return ModalDataRequest;\n });"],"names":["define","$","Notification","CustomEvents","Modal","ModalRegistry","DataPrivacyEvents","registered","SELECTORS","ModalDataRequest","root","call","this","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","approveEvent","Event","approve","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","denyEvent","deny","completeEvent","complete","register"],"mappings":";;;;;;;AAsBAA,6CAAO,CAAC,SAAU,oBAAqB,iCAAkC,aAAc,sBAC/E,4BACJ,SAASC,EAAGC,aAAcC,aAAcC,MAAOC,cAAeC,uBAEtDC,YAAa,EACbC,yBACgB,0BADhBA,sBAEa,uBAFbA,0BAGiB,2BAQjBC,iBAAmB,SAASC,MAC5BN,MAAMO,KAAKC,KAAMF,cAGrBD,iBAAiBI,KAAO,iCACxBJ,iBAAiBK,UAAYC,OAAOC,OAAOZ,MAAMU,YACtBG,YAAcR,iBAOzCA,iBAAiBK,UAAUI,uBAAyB,WAEhDd,MAAMU,UAAUI,uBAAuBP,KAAKC,WAEvCO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,yBAA0B,SAASe,EAAGC,UAC/EC,aAAexB,EAAEyB,MAAMpB,kBAAkBqB,cACxCC,UAAUC,QAAQJ,aAAcb,MAEhCa,aAAaK,4BACTC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,YAEFO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,sBAAuB,SAASe,EAAGC,UAC5EW,UAAYlC,EAAEyB,MAAMpB,kBAAkB8B,WACrCR,UAAUC,QAAQM,UAAWvB,MAE7BuB,UAAUL,4BACNC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,YAEFO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,0BAA2B,SAASe,EAAGC,UAChFa,cAAgBpC,EAAEyB,MAAMpB,kBAAkBgC,eACzCV,UAAUC,QAAQQ,cAAezB,MAEjCyB,cAAcP,4BACVC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,QAKNL,aACDF,cAAckC,SAAS9B,iBAAiBI,KAAMJ,iBAAkB,uCAChEF,YAAa,GAGVE"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/defaultsactions.min.js b/admin/tool/dataprivacy/amd/build/defaultsactions.min.js index fa8e7fcac27..765cd98cf54 100644 --- a/admin/tool/dataprivacy/amd/build/defaultsactions.min.js +++ b/admin/tool/dataprivacy/amd/build/defaultsactions.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/defaultsactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates"],function(a,b,c,d,f,g,h){var k={EDIT_LEVEL_DEFAULTS:"[data-action=\"edit-level-defaults\"]",NEW_ACTIVITY_DEFAULTS:"[data-action=\"new-activity-defaults\"]",EDIT_ACTIVITY_DEFAULTS:"[data-action=\"edit-activity-defaults\"]",DELETE_ACTIVITY_DEFAULTS:"[data-action=\"delete-activity-defaults\"]"},l=-1,m=function(){this.registerEvents()};m.prototype.registerEvents=function(){a(k.EDIT_LEVEL_DEFAULTS).click(function(f){f.preventDefault();var e=a(this),g=e.data("contextlevel"),h=e.data("category"),j=e.data("purpose"),k=b.call([{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}}]),l=d.get_string("editdefaults","tool_dataprivacy",a("#defaults-header").text());a.when(k[0],k[1],l).then(function(a,b,c){var d=a.options,e=b.options;i(c,g,h,j,null,d,e,null);return!0}).catch(c.exception)});a(k.NEW_ACTIVITY_DEFAULTS).click(function(f){f.preventDefault();var e=a(this),g=e.data("contextlevel"),h=b.call([{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}},{methodname:"tool_dataprivacy_get_activity_options",args:{nodefaults:!0}}]),j=d.get_string("addnewdefaults","tool_dataprivacy");a.when(h[0],h[1],h[2],j).then(function(a,b,c,d){var e=a.options,f=b.options,h=c.options;i(d,g,null,null,null,e,f,h);return!0}).catch(c.exception)});a(k.EDIT_ACTIVITY_DEFAULTS).click(function(f){f.preventDefault();var e=a(this),g=e.data("contextlevel"),h=e.data("category"),j=e.data("purpose"),k=e.data("activityname"),l=b.call([{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}},{methodname:"tool_dataprivacy_get_activity_options",args:{}}]),m=d.get_string("editmoduledefaults","tool_dataprivacy");a.when(l[0],l[1],l[2],m).then(function(a,b,c,d){var e=a.options,f=b.options,l=c.options;i(d,g,h,j,k,e,f,l);return!0}).catch(c.exception)});a(k.DELETE_ACTIVITY_DEFAULTS).click(function(b){b.preventDefault();var e=a(this),i=e.data("contextlevel"),k=e.data("activityname"),m=e.data("activitydisplayname");f.create({title:d.get_string("deletedefaults","tool_dataprivacy",m),body:h.render("tool_dataprivacy/delete_activity_defaults",{activityname:m}),type:f.types.SAVE_CANCEL,large:!0}).then(function(a){a.setSaveButtonText(d.get_string("delete"));a.getRoot().on(g.save,function(){j(i,l,l,k,!1)});a.getRoot().on(g.hidden,function(){a.destroy()});a.show();return!0}).catch(c.exception)})};function i(b,d,e,i,k,l,m,n){if(null!==e){l.forEach(function(a){if(a.id===e){a.selected=!0}})}if(null!==i){m.forEach(function(a){if(a.id===i){a.selected=!0}})}var o={contextlevel:d,categoryoptions:l,purposeoptions:m};if(null!==n&&n.length){if(null===k){o.newactivitydefaults=!0}else{n.forEach(function(a){if(k===a.name){a.selected=!0}})}o.modemodule=!0;o.activityoptions=n}f.create({title:b,body:h.render("tool_dataprivacy/category_purpose_form",o),type:f.types.SAVE_CANCEL,large:!0}).then(function(b){b.getRoot().on(g.save,function(){var b=a("#activity"),c="undefined"!=typeof b?b.val():null,d=a("#override"),e="undefined"!=typeof d?d.is(":checked"):!1;j(a("#contextlevel").val(),a("#category").val(),a("#purpose").val(),c,e)});b.getRoot().on(g.hidden,function(){b.destroy()});b.show();return b}).catch(c.exception)}function j(a,c,d,e,f){b.call([{methodname:"tool_dataprivacy_set_context_defaults",args:{contextlevel:a,category:c,purpose:d,override:f,activity:e}}])[0].done(function(a){if(a.result){window.location.reload()}})}return{init:function init(){return new m}}}); -//# sourceMappingURL=defaultsactions.min.js.map +/** + * AMD module for data registry defaults actions. + * + * @module tool_dataprivacy/defaultsactions + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/defaultsactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates"],(function($,Ajax,Notification,Str,ModalFactory,ModalEvents,Templates){var ACTIONS_EDIT_LEVEL_DEFAULTS='[data-action="edit-level-defaults"]',ACTIONS_NEW_ACTIVITY_DEFAULTS='[data-action="new-activity-defaults"]',ACTIONS_EDIT_ACTIVITY_DEFAULTS='[data-action="edit-activity-defaults"]',ACTIONS_DELETE_ACTIVITY_DEFAULTS='[data-action="delete-activity-defaults"]',DefaultsActions=function(){this.registerEvents()};function showDefaultsFormModal(title,contextLevel,category,purpose,activity,categoryOptions,purposeOptions,activityOptions){null!==category&&categoryOptions.forEach((function(currentValue){currentValue.id===category&&(currentValue.selected=!0)})),null!==purpose&&purposeOptions.forEach((function(currentValue){currentValue.id===purpose&&(currentValue.selected=!0)}));var templateContext={contextlevel:contextLevel,categoryoptions:categoryOptions,purposeoptions:purposeOptions};null!==activityOptions&&activityOptions.length&&(null===activity?templateContext.newactivitydefaults=!0:activityOptions.forEach((function(currentValue){activity===currentValue.name&&(currentValue.selected=!0)})),templateContext.modemodule=!0,templateContext.activityoptions=activityOptions),ModalFactory.create({title:title,body:Templates.render("tool_dataprivacy/category_purpose_form",templateContext),type:ModalFactory.types.SAVE_CANCEL,large:!0}).then((function(modal){return modal.getRoot().on(ModalEvents.save,(function(){var activity=$("#activity"),activityVal=void 0!==activity?activity.val():null,override=$("#override"),overrideVal=void 0!==override&&override.is(":checked");setContextDefaults($("#contextlevel").val(),$("#category").val(),$("#purpose").val(),activityVal,overrideVal)})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal.show(),modal})).catch(Notification.exception)}function setContextDefaults(contextLevel,category,purpose,activity,override){var request={methodname:"tool_dataprivacy_set_context_defaults",args:{contextlevel:contextLevel,category:category,purpose:purpose,override:override,activity:activity}};Ajax.call([request])[0].done((function(data){data.result&&window.location.reload()}))}return DefaultsActions.prototype.registerEvents=function(){$(ACTIONS_EDIT_LEVEL_DEFAULTS).click((function(e){e.preventDefault();var button=$(this),contextLevel=button.data("contextlevel"),category=button.data("category"),purpose=button.data("purpose"),promises=Ajax.call([{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}}]),titlePromise=Str.get_string("editdefaults","tool_dataprivacy",$("#defaults-header").text());$.when(promises[0],promises[1],titlePromise).then((function(categoryResponse,purposeResponse,title){var categories=categoryResponse.options,purposes=purposeResponse.options;return showDefaultsFormModal(title,contextLevel,category,purpose,null,categories,purposes,null),!0})).catch(Notification.exception)})),$(ACTIONS_NEW_ACTIVITY_DEFAULTS).click((function(e){e.preventDefault();var contextLevel=$(this).data("contextlevel"),promises=Ajax.call([{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}},{methodname:"tool_dataprivacy_get_activity_options",args:{nodefaults:!0}}]),titlePromise=Str.get_string("addnewdefaults","tool_dataprivacy");$.when(promises[0],promises[1],promises[2],titlePromise).then((function(categoryResponse,purposeResponse,activityResponse,title){var categories=categoryResponse.options,purposes=purposeResponse.options,activities=activityResponse.options;return showDefaultsFormModal(title,contextLevel,null,null,null,categories,purposes,activities),!0})).catch(Notification.exception)})),$(ACTIONS_EDIT_ACTIVITY_DEFAULTS).click((function(e){e.preventDefault();var button=$(this),contextLevel=button.data("contextlevel"),category=button.data("category"),purpose=button.data("purpose"),activity=button.data("activityname"),promises=Ajax.call([{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}},{methodname:"tool_dataprivacy_get_activity_options",args:{}}]),titlePromise=Str.get_string("editmoduledefaults","tool_dataprivacy");$.when(promises[0],promises[1],promises[2],titlePromise).then((function(categoryResponse,purposeResponse,activityResponse,title){var categories=categoryResponse.options,purposes=purposeResponse.options,activities=activityResponse.options;return showDefaultsFormModal(title,contextLevel,category,purpose,activity,categories,purposes,activities),!0})).catch(Notification.exception)})),$(ACTIONS_DELETE_ACTIVITY_DEFAULTS).click((function(e){e.preventDefault();var button=$(this),contextLevel=button.data("contextlevel"),activity=button.data("activityname"),activityDisplayName=button.data("activitydisplayname");ModalFactory.create({title:Str.get_string("deletedefaults","tool_dataprivacy",activityDisplayName),body:Templates.render("tool_dataprivacy/delete_activity_defaults",{activityname:activityDisplayName}),type:ModalFactory.types.SAVE_CANCEL,large:!0}).then((function(modal){return modal.setSaveButtonText(Str.get_string("delete")),modal.getRoot().on(ModalEvents.save,(function(){setContextDefaults(contextLevel,-1,-1,activity,!1)})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal.show(),!0})).catch(Notification.exception)}))},{init:function(){return new DefaultsActions}}})); + +//# sourceMappingURL=defaultsactions.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map b/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map index 0b988052be1..50b7d083a24 100644 --- a/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/defaultsactions.js"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ACTIONS","EDIT_LEVEL_DEFAULTS","NEW_ACTIVITY_DEFAULTS","EDIT_ACTIVITY_DEFAULTS","DELETE_ACTIVITY_DEFAULTS","INHERIT","DefaultsActions","registerEvents","prototype","click","e","preventDefault","button","contextLevel","data","category","purpose","promises","call","methodname","args","titlePromise","get_string","text","when","then","categoryResponse","purposeResponse","title","categories","options","purposes","showDefaultsFormModal","catch","exception","activityResponse","activities","activity","activityDisplayName","create","body","render","type","types","SAVE_CANCEL","large","modal","setSaveButtonText","getRoot","on","save","setContextDefaults","hidden","destroy","show","categoryOptions","purposeOptions","activityOptions","forEach","currentValue","id","selected","templateContext","length","newactivitydefaults","name","modemodule","activityoptions","activityVal","val","override","overrideVal","is","done","result","window","location","reload"],"mappings":"AAsBAA,OAAM,oCAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,oBALG,CAMH,mBANG,CAOH,gBAPG,CAAD,CAQN,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAAqCC,CAArC,CAAmDC,CAAnD,CAAgEC,CAAhE,CAA2E,IAUnEC,CAAAA,CAAO,CAAG,CACVC,mBAAmB,CAAE,uCADX,CAEVC,qBAAqB,CAAE,yCAFb,CAGVC,sBAAsB,CAAE,0CAHd,CAIVC,wBAAwB,CAAE,4CAJhB,CAVyD,CAkBnEC,CAAO,CAAG,CAAC,CAlBwD,CAuBnEC,CAAe,CAAG,UAAW,CAC7B,KAAKC,cAAL,EACH,CAzBsE,CA8BvED,CAAe,CAACE,SAAhB,CAA0BD,cAA1B,CAA2C,UAAW,CAClDd,CAAC,CAACO,CAAO,CAACC,mBAAT,CAAD,CAA+BQ,KAA/B,CAAqC,SAASC,CAAT,CAAY,CAC7CA,CAAC,CAACC,cAAF,GAD6C,GAGzCC,CAAAA,CAAM,CAAGnB,CAAC,CAAC,IAAD,CAH+B,CAIzCoB,CAAY,CAAGD,CAAM,CAACE,IAAP,CAAY,cAAZ,CAJ0B,CAKzCC,CAAQ,CAAGH,CAAM,CAAC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//\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 for data registry defaults actions.\n *\n * @module tool_dataprivacy/defaultsactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of action selectors.\n *\n * @type {{EDIT_LEVEL_DEFAULTS: string}}\n * @type {{NEW_ACTIVITY_DEFAULTS: string}}\n * @type {{EDIT_ACTIVITY_DEFAULTS: string}}\n * @type {{DELETE_ACTIVITY_DEFAULTS: string}}\n */\n var ACTIONS = {\n EDIT_LEVEL_DEFAULTS: '[data-action=\"edit-level-defaults\"]',\n NEW_ACTIVITY_DEFAULTS: '[data-action=\"new-activity-defaults\"]',\n EDIT_ACTIVITY_DEFAULTS: '[data-action=\"edit-activity-defaults\"]',\n DELETE_ACTIVITY_DEFAULTS: '[data-action=\"delete-activity-defaults\"]'\n };\n\n /** @type {{INHERIT: Number}} **/\n var INHERIT = -1;\n\n /**\n * DefaultsActions class.\n */\n var DefaultsActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DefaultsActions.prototype.registerEvents = function() {\n $(ACTIONS.EDIT_LEVEL_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editdefaults', 'tool_dataprivacy', $('#defaults-header').text());\n $.when(promises[0], promises[1], titlePromise).then(function(categoryResponse, purposeResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n showDefaultsFormModal(title, contextLevel, category, purpose, null, categories, purposes, null);\n\n return true;\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.NEW_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {'nodefaults': true}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('addnewdefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, null, null, null, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.EDIT_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n var activity = button.data('activityname');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editmoduledefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, category, purpose, activity, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.DELETE_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var activity = button.data('activityname');\n var activityDisplayName = button.data('activitydisplayname');\n // Set category and purpose to inherit (-1).\n var category = INHERIT;\n var purpose = INHERIT;\n\n ModalFactory.create({\n title: Str.get_string('deletedefaults', 'tool_dataprivacy', activityDisplayName),\n body: Templates.render('tool_dataprivacy/delete_activity_defaults', {\"activityname\": activityDisplayName}),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n modal.setSaveButtonText(Str.get_string('delete'));\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n setContextDefaults(contextLevel, category, purpose, activity, false);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return true;\n }).catch(Notification.exception);\n });\n };\n\n /**\n * Prepares and renders the modal for setting the defaults for the given context level/plugin.\n *\n * @param {String} title The modal's title.\n * @param {Number} contextLevel The context level to set defaults for.\n * @param {Number} category The current category ID.\n * @param {Number} purpose The current purpose ID.\n * @param {String} activity The plugin name of the activity. Optional.\n * @param {Array} categoryOptions The list of category options.\n * @param {Array} purposeOptions The list of purpose options.\n * @param {Array} activityOptions The list of activity options. Optional.\n */\n function showDefaultsFormModal(title, contextLevel, category, purpose, activity,\n categoryOptions, purposeOptions, activityOptions) {\n\n if (category !== null) {\n categoryOptions.forEach(function(currentValue) {\n if (currentValue.id === category) {\n currentValue.selected = true;\n }\n });\n }\n\n if (purpose !== null) {\n purposeOptions.forEach(function(currentValue) {\n if (currentValue.id === purpose) {\n currentValue.selected = true;\n }\n });\n }\n\n var templateContext = {\n \"contextlevel\": contextLevel,\n \"categoryoptions\": categoryOptions,\n \"purposeoptions\": purposeOptions\n };\n\n // Check the activityOptions parameter that was passed.\n if (activityOptions !== null && activityOptions.length) {\n // Check the activity parameter that was passed.\n if (activity === null) {\n // We're setting a new defaults for a module.\n templateContext.newactivitydefaults = true;\n\n } else {\n // Edit mode. Set selection.\n activityOptions.forEach(function(currentValue) {\n if (activity === currentValue.name) {\n currentValue.selected = true;\n }\n });\n }\n\n templateContext.modemodule = true;\n templateContext.activityoptions = activityOptions;\n }\n\n ModalFactory.create({\n title: title,\n body: Templates.render('tool_dataprivacy/category_purpose_form', templateContext),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n var activity = $('#activity');\n var activityVal = typeof activity !== 'undefined' ? activity.val() : null;\n var override = $('#override');\n var overrideVal = typeof override !== 'undefined' ? override.is(':checked') : false;\n\n setContextDefaults($('#contextlevel').val(), $('#category').val(), $('#purpose').val(), activityVal, overrideVal);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return modal;\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a the tool_dataprivacy_set_context_defaults WS function.\n *\n * @param {Number} contextLevel The context level.\n * @param {Number} category The category ID.\n * @param {Number} purpose The purpose ID.\n * @param {String} activity The plugin name of the activity module.\n * @param {Boolean} override Whether to override custom instances.\n */\n function setContextDefaults(contextLevel, category, purpose, activity, override) {\n var request = {\n methodname: 'tool_dataprivacy_set_context_defaults',\n args: {\n 'contextlevel': contextLevel,\n 'category': category,\n 'purpose': purpose,\n 'override': override,\n 'activity': activity\n }\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n }\n });\n }\n\n return /** @alias module:tool_dataprivacy/defaultsactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {DefaultsActions}\n */\n 'init': function() {\n return new DefaultsActions();\n }\n };\n});\n"],"file":"defaultsactions.min.js"} \ No newline at end of file +{"version":3,"file":"defaultsactions.min.js","sources":["../src/defaultsactions.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 * AMD module for data registry defaults actions.\n *\n * @module tool_dataprivacy/defaultsactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of action selectors.\n *\n * @type {{EDIT_LEVEL_DEFAULTS: string}}\n * @type {{NEW_ACTIVITY_DEFAULTS: string}}\n * @type {{EDIT_ACTIVITY_DEFAULTS: string}}\n * @type {{DELETE_ACTIVITY_DEFAULTS: string}}\n */\n var ACTIONS = {\n EDIT_LEVEL_DEFAULTS: '[data-action=\"edit-level-defaults\"]',\n NEW_ACTIVITY_DEFAULTS: '[data-action=\"new-activity-defaults\"]',\n EDIT_ACTIVITY_DEFAULTS: '[data-action=\"edit-activity-defaults\"]',\n DELETE_ACTIVITY_DEFAULTS: '[data-action=\"delete-activity-defaults\"]'\n };\n\n /** @type {{INHERIT: Number}} **/\n var INHERIT = -1;\n\n /**\n * DefaultsActions class.\n */\n var DefaultsActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DefaultsActions.prototype.registerEvents = function() {\n $(ACTIONS.EDIT_LEVEL_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editdefaults', 'tool_dataprivacy', $('#defaults-header').text());\n $.when(promises[0], promises[1], titlePromise).then(function(categoryResponse, purposeResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n showDefaultsFormModal(title, contextLevel, category, purpose, null, categories, purposes, null);\n\n return true;\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.NEW_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {'nodefaults': true}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('addnewdefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, null, null, null, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.EDIT_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n var activity = button.data('activityname');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editmoduledefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, category, purpose, activity, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.DELETE_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var activity = button.data('activityname');\n var activityDisplayName = button.data('activitydisplayname');\n // Set category and purpose to inherit (-1).\n var category = INHERIT;\n var purpose = INHERIT;\n\n ModalFactory.create({\n title: Str.get_string('deletedefaults', 'tool_dataprivacy', activityDisplayName),\n body: Templates.render('tool_dataprivacy/delete_activity_defaults', {\"activityname\": activityDisplayName}),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n modal.setSaveButtonText(Str.get_string('delete'));\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n setContextDefaults(contextLevel, category, purpose, activity, false);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return true;\n }).catch(Notification.exception);\n });\n };\n\n /**\n * Prepares and renders the modal for setting the defaults for the given context level/plugin.\n *\n * @param {String} title The modal's title.\n * @param {Number} contextLevel The context level to set defaults for.\n * @param {Number} category The current category ID.\n * @param {Number} purpose The current purpose ID.\n * @param {String} activity The plugin name of the activity. Optional.\n * @param {Array} categoryOptions The list of category options.\n * @param {Array} purposeOptions The list of purpose options.\n * @param {Array} activityOptions The list of activity options. Optional.\n */\n function showDefaultsFormModal(title, contextLevel, category, purpose, activity,\n categoryOptions, purposeOptions, activityOptions) {\n\n if (category !== null) {\n categoryOptions.forEach(function(currentValue) {\n if (currentValue.id === category) {\n currentValue.selected = true;\n }\n });\n }\n\n if (purpose !== null) {\n purposeOptions.forEach(function(currentValue) {\n if (currentValue.id === purpose) {\n currentValue.selected = true;\n }\n });\n }\n\n var templateContext = {\n \"contextlevel\": contextLevel,\n \"categoryoptions\": categoryOptions,\n \"purposeoptions\": purposeOptions\n };\n\n // Check the activityOptions parameter that was passed.\n if (activityOptions !== null && activityOptions.length) {\n // Check the activity parameter that was passed.\n if (activity === null) {\n // We're setting a new defaults for a module.\n templateContext.newactivitydefaults = true;\n\n } else {\n // Edit mode. Set selection.\n activityOptions.forEach(function(currentValue) {\n if (activity === currentValue.name) {\n currentValue.selected = true;\n }\n });\n }\n\n templateContext.modemodule = true;\n templateContext.activityoptions = activityOptions;\n }\n\n ModalFactory.create({\n title: title,\n body: Templates.render('tool_dataprivacy/category_purpose_form', templateContext),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n var activity = $('#activity');\n var activityVal = typeof activity !== 'undefined' ? activity.val() : null;\n var override = $('#override');\n var overrideVal = typeof override !== 'undefined' ? override.is(':checked') : false;\n\n setContextDefaults($('#contextlevel').val(), $('#category').val(), $('#purpose').val(), activityVal, overrideVal);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return modal;\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a the tool_dataprivacy_set_context_defaults WS function.\n *\n * @param {Number} contextLevel The context level.\n * @param {Number} category The category ID.\n * @param {Number} purpose The purpose ID.\n * @param {String} activity The plugin name of the activity module.\n * @param {Boolean} override Whether to override custom instances.\n */\n function setContextDefaults(contextLevel, category, purpose, activity, override) {\n var request = {\n methodname: 'tool_dataprivacy_set_context_defaults',\n args: {\n 'contextlevel': contextLevel,\n 'category': category,\n 'purpose': purpose,\n 'override': override,\n 'activity': activity\n }\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n }\n });\n }\n\n return /** @alias module:tool_dataprivacy/defaultsactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {DefaultsActions}\n */\n 'init': function() {\n return new DefaultsActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ACTIONS","DefaultsActions","registerEvents","showDefaultsFormModal","title","contextLevel","category","purpose","activity","categoryOptions","purposeOptions","activityOptions","forEach","currentValue","id","selected","templateContext","length","newactivitydefaults","name","modemodule","activityoptions","create","body","render","type","types","SAVE_CANCEL","large","then","modal","getRoot","on","save","activityVal","val","override","overrideVal","is","setContextDefaults","hidden","destroy","show","catch","exception","request","methodname","args","call","done","data","result","window","location","reload","prototype","click","e","preventDefault","button","this","promises","titlePromise","get_string","text","when","categoryResponse","purposeResponse","categories","options","purposes","activityResponse","activities","activityDisplayName","setSaveButtonText"],"mappings":";;;;;;;AAsBAA,0CAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,oBACA,mBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,YAAaC,eAUxDC,4BACqB,sCADrBA,8BAEuB,wCAFvBA,+BAGwB,yCAHxBA,iCAI0B,2CAS1BC,gBAAkB,gBACbC,2BAgJAC,sBAAsBC,MAAOC,aAAcC,SAAUC,QAASC,SACxCC,gBAAiBC,eAAgBC,iBAE3C,OAAbL,UACAG,gBAAgBG,SAAQ,SAASC,cACzBA,aAAaC,KAAOR,WACpBO,aAAaE,UAAW,MAKpB,OAAZR,SACAG,eAAeE,SAAQ,SAASC,cACxBA,aAAaC,KAAOP,UACpBM,aAAaE,UAAW,UAKhCC,gBAAkB,cACFX,6BACGI,+BACDC,gBAIE,OAApBC,iBAA4BA,gBAAgBM,SAE3B,OAAbT,SAEAQ,gBAAgBE,qBAAsB,EAItCP,gBAAgBC,SAAQ,SAASC,cACzBL,WA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C,gBAAiBI,iBAAkBnE,WACtDgE,WAAaF,iBAAiBG,QAC9BC,SAAWH,gBAAgBE,QAC3BG,WAAaD,iBAAiBF,eAElClE,sBAAsBC,MAAOC,aAAcC,SAAUC,QAASC,SAAU4D,WAAYE,SAAUE,aAEvF,KAER7B,MAAMhD,aAAaiD,cAI9BnD,EAAEO,kCAAkCwD,OAAM,SAASC,GAC/CA,EAAEC,qBAEEC,OAASlE,EAAEmE,MACXvD,aAAesD,OAAOT,KAAK,gBAC3B1C,SAAWmD,OAAOT,KAAK,gBACvBuB,oBAAsBd,OAAOT,KAAK,uBAKtCrD,aAAayB,OAAO,CAChBlB,MAAOR,IAAImE,WAAW,iBAAkB,mBAAoBU,qBAC5DlD,KAAMxB,UAAUyB,OAAO,4CAA6C,cAAiBiD,sBACrFhD,KAAM5B,aAAa6B,MAAMC,YACzBC,OAAO,IACRC,MAAK,SAASC,cACbA,MAAM4C,kBAAkB9E,IAAImE,WAAW,WAGvCjC,MAAMC,UAAUC,GAAGlC,YAAYmC,MAAM,WACjCM,mBAAmBlC,cA1HrB,GAAA,EA0HsDG,UAAU,MAIlEsB,MAAMC,UAAUC,GAAGlC,YAAY0C,QAAQ,WAEnCV,MAAMW,aAGVX,MAAMY,QAEC,KACRC,MAAMhD,aAAaiD,eAsH+B,MASjD,kBACG,IAAI3C"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js b/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js index b7bd5b769fc..7079d003fc0 100644 --- a/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js +++ b/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/effective_retention_period",["jquery"],function(a){var b={PURPOSE_SELECT:"#id_purposeid",RETENTION_FIELD:"#fitem_id_retention_current [data-fieldtype=static]"},c=function(a){this.purposeRetentionPeriods=a;this.registerEventListeners()},d=function(){a(b.PURPOSE_SELECT).off("change")};c.prototype.purposeRetentionPeriods=[];c.prototype.registerEventListeners=function(){a(b.PURPOSE_SELECT).on("change",function(c){var d=a(c.currentTarget).val(),e=this.purposeRetentionPeriods[d];a(b.RETENTION_FIELD).text(e)}.bind(this))};return{init:function init(a){d();return new c(a)}}}); -//# sourceMappingURL=effective_retention_period.min.js.map +/** + * Module to update the displayed retention period. + * + * @module tool_dataprivacy/effective_retention_period + * @copyright 2018 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/effective_retention_period",["jquery"],(function($){var SELECTORS_PURPOSE_SELECT="#id_purposeid",SELECTORS_RETENTION_FIELD="#fitem_id_retention_current [data-fieldtype=static]",EffectiveRetentionPeriod=function(purposeRetentionPeriods){this.purposeRetentionPeriods=purposeRetentionPeriods,this.registerEventListeners()};return EffectiveRetentionPeriod.prototype.purposeRetentionPeriods=[],EffectiveRetentionPeriod.prototype.registerEventListeners=function(){$(SELECTORS_PURPOSE_SELECT).on("change",function(ev){var selected=$(ev.currentTarget).val(),selectedPurpose=this.purposeRetentionPeriods[selected];$(SELECTORS_RETENTION_FIELD).text(selectedPurpose)}.bind(this))},{init:function(purposeRetentionPeriods){return $(SELECTORS_PURPOSE_SELECT).off("change"),new EffectiveRetentionPeriod(purposeRetentionPeriods)}}})); + +//# sourceMappingURL=effective_retention_period.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js.map b/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js.map index e8e3d14390e..ac590ba9ea6 100644 --- a/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js.map +++ b/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/effective_retention_period.js"],"names":["define","$","SELECTORS","PURPOSE_SELECT","RETENTION_FIELD","EffectiveRetentionPeriod","purposeRetentionPeriods","registerEventListeners","removeListeners","off","prototype","on","ev","selected","currentTarget","val","selectedPurpose","text","bind","init"],"mappings":"AAsBAA,OAAM,+CAAC,CAAC,QAAD,CAAD,CACF,SAASC,CAAT,CAAY,IAEJC,CAAAA,CAAS,CAAG,CACZC,cAAc,CAAE,eADJ,CAEZC,eAAe,CAAE,qDAFL,CAFR,CAYJC,CAAwB,CAAG,SAASC,CAAT,CAAkC,CAC7D,KAAKA,uBAAL,CAA+BA,CAA/B,CACA,KAAKC,sBAAL,EACH,CAfO,CAsBJC,CAAe,CAAG,UAAW,CAC7BP,CAAC,CAACC,CAAS,CAACC,cAAX,CAAD,CAA4BM,GAA5B,CAAgC,QAAhC,CACH,CAxBO,CA8BRJ,CAAwB,CAACK,SAAzB,CAAmCJ,uBAAnC,CAA6D,EAA7D,CAOAD,CAAwB,CAACK,SAAzB,CAAmCH,sBAAnC,CAA4D,UAAW,CAEnEN,CAAC,CAACC,CAAS,CAACC,cAAX,CAAD,CAA4BQ,EAA5B,CAA+B,QAA/B,CAAyC,SAASC,CAAT,CAAa,IAC9CC,CAAAA,CAAQ,CAAGZ,CAAC,CAACW,CAAE,CAACE,aAAJ,CAAD,CAAoBC,GAApB,EADmC,CAE9CC,CAAe,CAAG,KAAKV,uBAAL,CAA6BO,CAA7B,CAF4B,CAGlDZ,CAAC,CAACC,CAAS,CAACE,eAAX,CAAD,CAA6Ba,IAA7B,CAAkCD,CAAlC,CACH,CAJwC,CAIvCE,IAJuC,CAIlC,IAJkC,CAAzC,CAKH,CAPD,CASA,MAAwE,CACpEC,IAAI,CAAE,cAASb,CAAT,CAAkC,CAEpCE,CAAe,GACf,MAAO,IAAIH,CAAAA,CAAJ,CAA6BC,CAA7B,CACV,CALmE,CAO3E,CAtDC,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 * Module to update the displayed retention period.\n *\n * @module tool_dataprivacy/effective_retention_period\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'],\n function($) {\n\n var SELECTORS = {\n PURPOSE_SELECT: '#id_purposeid',\n RETENTION_FIELD: '#fitem_id_retention_current [data-fieldtype=static]',\n };\n\n /**\n * Constructor for the retention period display.\n *\n * @param {Array} purposeRetentionPeriods Associative array of purposeids with effective retention period at this context\n */\n var EffectiveRetentionPeriod = function(purposeRetentionPeriods) {\n this.purposeRetentionPeriods = purposeRetentionPeriods;\n this.registerEventListeners();\n };\n\n /**\n * Removes the current 'change' listeners.\n *\n * Useful when a new form is loaded.\n */\n var removeListeners = function() {\n $(SELECTORS.PURPOSE_SELECT).off('change');\n };\n\n /**\n * @var {Array} purposeRetentionPeriods\n * @private\n */\n EffectiveRetentionPeriod.prototype.purposeRetentionPeriods = [];\n\n /**\n * Add purpose change listeners.\n *\n * @method registerEventListeners\n */\n EffectiveRetentionPeriod.prototype.registerEventListeners = function() {\n\n $(SELECTORS.PURPOSE_SELECT).on('change', function(ev) {\n var selected = $(ev.currentTarget).val();\n var selectedPurpose = this.purposeRetentionPeriods[selected];\n $(SELECTORS.RETENTION_FIELD).text(selectedPurpose);\n }.bind(this));\n };\n\n return /** @alias module:tool_dataprivacy/effective_retention_period */ {\n init: function(purposeRetentionPeriods) {\n // Remove previously attached listeners.\n removeListeners();\n return new EffectiveRetentionPeriod(purposeRetentionPeriods);\n }\n };\n }\n);\n\n"],"file":"effective_retention_period.min.js"} \ No newline at end of file +{"version":3,"file":"effective_retention_period.min.js","sources":["../src/effective_retention_period.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 to update the displayed retention period.\n *\n * @module tool_dataprivacy/effective_retention_period\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'],\n function($) {\n\n var SELECTORS = {\n PURPOSE_SELECT: '#id_purposeid',\n RETENTION_FIELD: '#fitem_id_retention_current [data-fieldtype=static]',\n };\n\n /**\n * Constructor for the retention period display.\n *\n * @param {Array} purposeRetentionPeriods Associative array of purposeids with effective retention period at this context\n */\n var EffectiveRetentionPeriod = function(purposeRetentionPeriods) {\n this.purposeRetentionPeriods = purposeRetentionPeriods;\n this.registerEventListeners();\n };\n\n /**\n * Removes the current 'change' listeners.\n *\n * Useful when a new form is loaded.\n */\n var removeListeners = function() {\n $(SELECTORS.PURPOSE_SELECT).off('change');\n };\n\n /**\n * @var {Array} purposeRetentionPeriods\n * @private\n */\n EffectiveRetentionPeriod.prototype.purposeRetentionPeriods = [];\n\n /**\n * Add purpose change listeners.\n *\n * @method registerEventListeners\n */\n EffectiveRetentionPeriod.prototype.registerEventListeners = function() {\n\n $(SELECTORS.PURPOSE_SELECT).on('change', function(ev) {\n var selected = $(ev.currentTarget).val();\n var selectedPurpose = this.purposeRetentionPeriods[selected];\n $(SELECTORS.RETENTION_FIELD).text(selectedPurpose);\n }.bind(this));\n };\n\n return /** @alias module:tool_dataprivacy/effective_retention_period */ {\n init: function(purposeRetentionPeriods) {\n // Remove previously attached listeners.\n removeListeners();\n return new EffectiveRetentionPeriod(purposeRetentionPeriods);\n }\n };\n }\n);\n\n"],"names":["define","$","SELECTORS","EffectiveRetentionPeriod","purposeRetentionPeriods","registerEventListeners","prototype","on","ev","selected","currentTarget","val","selectedPurpose","this","text","bind","init","off"],"mappings":";;;;;;;AAsBAA,qDAAO,CAAC,WACJ,SAASC,OAEDC,yBACgB,gBADhBA,0BAEiB,sDAQjBC,yBAA2B,SAASC,8BAC/BA,wBAA0BA,6BAC1BC,iCAgBTF,yBAAyBG,UAAUF,wBAA0B,GAO7DD,yBAAyBG,UAAUD,uBAAyB,WAExDJ,EAAEC,0BAA0BK,GAAG,SAAU,SAASC,QAC1CC,SAAWR,EAAEO,GAAGE,eAAeC,MAC/BC,gBAAkBC,KAAKT,wBAAwBK,UACnDR,EAAEC,2BAA2BY,KAAKF,kBACpCG,KAAKF,QAG6D,CACpEG,KAAM,SAASZ,gCAxBfH,EAAEC,0BAA0Be,IAAI,UA2BrB,IAAId,yBAAyBC"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/events.min.js b/admin/tool/dataprivacy/amd/build/events.min.js index acae406b7dc..f5ee42396d0 100644 --- a/admin/tool/dataprivacy/amd/build/events.min.js +++ b/admin/tool/dataprivacy/amd/build/events.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/events",[],function(){return{approve:"tool_dataprivacy-data_request:approve",bulkApprove:"tool_dataprivacy-data_request:bulk_approve",deny:"tool_dataprivacy-data_request:deny",bulkDeny:"tool_dataprivacy-data_request:bulk_deny",complete:"tool_dataprivacy-data_request:complete"}}); -//# sourceMappingURL=events.min.js.map +/** + * Contain the events the data privacy tool can fire. + * + * @module tool_dataprivacy/events + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/events",[],(function(){return{approve:"tool_dataprivacy-data_request:approve",bulkApprove:"tool_dataprivacy-data_request:bulk_approve",deny:"tool_dataprivacy-data_request:deny",bulkDeny:"tool_dataprivacy-data_request:bulk_deny",complete:"tool_dataprivacy-data_request:complete"}})); + +//# sourceMappingURL=events.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/events.min.js.map b/admin/tool/dataprivacy/amd/build/events.min.js.map index 60293f3a3d7..287e52800b6 100644 --- a/admin/tool/dataprivacy/amd/build/events.min.js.map +++ b/admin/tool/dataprivacy/amd/build/events.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/events.js"],"names":["define","approve","bulkApprove","deny","bulkDeny","complete"],"mappings":"AAsBAA,OAAM,2BAAC,EAAD,CAAK,UAAW,CAClB,MAAO,CACHC,OAAO,CAAE,uCADN,CAEHC,WAAW,CAAE,4CAFV,CAGHC,IAAI,CAAE,oCAHH,CAIHC,QAAQ,CAAE,yCAJP,CAKHC,QAAQ,CAAE,wCALP,CAOV,CARK,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 * Contain the events the data privacy tool can fire.\n *\n * @module tool_dataprivacy/events\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n approve: 'tool_dataprivacy-data_request:approve',\n bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',\n deny: 'tool_dataprivacy-data_request:deny',\n bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',\n complete: 'tool_dataprivacy-data_request:complete'\n };\n});\n"],"file":"events.min.js"} \ No newline at end of file +{"version":3,"file":"events.min.js","sources":["../src/events.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 * Contain the events the data privacy tool can fire.\n *\n * @module tool_dataprivacy/events\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n approve: 'tool_dataprivacy-data_request:approve',\n bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',\n deny: 'tool_dataprivacy-data_request:deny',\n bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',\n complete: 'tool_dataprivacy-data_request:complete'\n };\n});\n"],"names":["define","approve","bulkApprove","deny","bulkDeny","complete"],"mappings":";;;;;;;AAsBAA,iCAAO,IAAI,iBACA,CACHC,QAAS,wCACTC,YAAa,6CACbC,KAAM,qCACNC,SAAU,0CACVC,SAAU"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/expand_contract.min.js b/admin/tool/dataprivacy/amd/build/expand_contract.min.js index 7f73e4c65dd..4e4c3e93fa0 100644 --- a/admin/tool/dataprivacy/amd/build/expand_contract.min.js +++ b/admin/tool/dataprivacy/amd/build/expand_contract.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/expand_contract",["jquery","core/url","core/str"],function(a,b,c){var d=a("\"\""),e=a("\"\""),f={EXPAND:"fa-caret-right",COLLAPSE:"fa-caret-down"};return{expandCollapse:function expandCollapse(a,b){if(a.hasClass("hide")){a.removeClass("hide");a.addClass("visible");a.attr("aria-expanded",!0);b.find(":header i.fa").removeClass(f.EXPAND);b.find(":header i.fa").addClass(f.COLLAPSE);b.find(":header img.icon").attr("src",d.attr("src"))}else{a.removeClass("visible");a.addClass("hide");a.attr("aria-expanded",!1);b.find(":header i.fa").removeClass(f.COLLAPSE);b.find(":header i.fa").addClass(f.EXPAND);b.find(":header img.icon").attr("src",e.attr("src"))}},expandCollapseAll:function expandCollapseAll(b){var g="visible"==b?"hide":"visible",h="visible"==b?!0:!1,i="visible"==b?f.EXPAND:f.COLLAPSE,j="visible"==b?f.COLLAPSE:f.EXPAND,k="visible"==b?d.attr("src"):e.attr("src");a("."+g).each(function(){a(this).removeClass(g);a(this).addClass(b);a(this).attr("aria-expanded",h)});a(".tool_dataprivacy-expand-all").data("visibilityState",g);c.get_string(g,"tool_dataprivacy").then(function(b){a(".tool_dataprivacy-expand-all").html(b)}).catch(Notification.exception);a(":header i.fa").each(function(){a(this).removeClass(i);a(this).addClass(j)});a(":header img.icon").each(function(){a(this).attr("src",k)})}}}); -//# sourceMappingURL=expand_contract.min.js.map +/** + * Potential user selector module. + * + * @module tool_dataprivacy/expand_contract + * @copyright 2018 Adrian Greeve + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/expand_contract",["jquery","core/url","core/str"],(function($,url,str){var expandedImage=$(''),collapsedImage=$(''),CLASSES_EXPAND="fa-caret-right",CLASSES_COLLAPSE="fa-caret-down";return{expandCollapse:function(targetnode,thisnode){targetnode.hasClass("hide")?(targetnode.removeClass("hide"),targetnode.addClass("visible"),targetnode.attr("aria-expanded",!0),thisnode.find(":header i.fa").removeClass(CLASSES_EXPAND),thisnode.find(":header i.fa").addClass(CLASSES_COLLAPSE),thisnode.find(":header img.icon").attr("src",expandedImage.attr("src"))):(targetnode.removeClass("visible"),targetnode.addClass("hide"),targetnode.attr("aria-expanded",!1),thisnode.find(":header i.fa").removeClass(CLASSES_COLLAPSE),thisnode.find(":header i.fa").addClass(CLASSES_EXPAND),thisnode.find(":header img.icon").attr("src",collapsedImage.attr("src")))},expandCollapseAll:function(nextstate){var currentstate="visible"==nextstate?"hide":"visible",ariaexpandedstate="visible"==nextstate,iconclassnow="visible"==nextstate?CLASSES_EXPAND:CLASSES_COLLAPSE,iconclassnext="visible"==nextstate?CLASSES_COLLAPSE:CLASSES_EXPAND,imagenow="visible"==nextstate?expandedImage.attr("src"):collapsedImage.attr("src");$("."+currentstate).each((function(){$(this).removeClass(currentstate),$(this).addClass(nextstate),$(this).attr("aria-expanded",ariaexpandedstate)})),$(".tool_dataprivacy-expand-all").data("visibilityState",currentstate),str.get_string(currentstate,"tool_dataprivacy").then((function(langString){$(".tool_dataprivacy-expand-all").html(langString)})).catch(Notification.exception),$(":header i.fa").each((function(){$(this).removeClass(iconclassnow),$(this).addClass(iconclassnext)})),$(":header img.icon").each((function(){$(this).attr("src",imagenow)}))}}})); + +//# sourceMappingURL=expand_contract.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map b/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map index cd1ba61d3fd..f14dcd9e805 100644 --- a/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map +++ b/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/expand_contract.js"],"names":["define","$","url","str","expandedImage","imageUrl","collapsedImage","CLASSES","EXPAND","COLLAPSE","expandCollapse","targetnode","thisnode","hasClass","removeClass","addClass","attr","find","expandCollapseAll","nextstate","currentstate","ariaexpandedstate","iconclassnow","iconclassnext","imagenow","each","data","get_string","then","langString","html","catch","Notification","exception"],"mappings":"AAuBAA,OAAM,oCAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,UAAvB,CAAD,CAAqC,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAAsB,IAEzDC,CAAAA,CAAa,CAAGH,CAAC,CAAC,uBAAsBC,CAAG,CAACG,QAAJ,CAAa,YAAb,CAAtB,CAAmD,MAApD,CAFwC,CAGzDC,CAAc,CAAGL,CAAC,CAAC,uBAAsBC,CAAG,CAACG,QAAJ,CAAa,aAAb,CAAtB,CAAoD,MAArD,CAHuC,CAQzDE,CAAO,CAAG,CACVC,MAAM,CAAE,gBADE,CAEVC,QAAQ,CAAE,eAFA,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le 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 * Potential user selector module.\n *\n * @module tool_dataprivacy/expand_contract\n * @copyright 2018 Adrian Greeve\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/url', 'core/str'], function($, url, str) {\n\n var expandedImage = $('\"\"');\n var collapsedImage = $('\"\"');\n\n /*\n * Class names to apply when expanding/collapsing nodes.\n */\n var CLASSES = {\n EXPAND: 'fa-caret-right',\n COLLAPSE: 'fa-caret-down'\n };\n\n return /** @alias module:tool_dataprivacy/expand-collapse */ {\n /**\n * Expand or collapse a selected node.\n *\n * @param {object} targetnode The node that we want to expand / collapse\n * @param {object} thisnode The node that was clicked.\n */\n expandCollapse: function(targetnode, thisnode) {\n if (targetnode.hasClass('hide')) {\n targetnode.removeClass('hide');\n targetnode.addClass('visible');\n targetnode.attr('aria-expanded', true);\n thisnode.find(':header i.fa').removeClass(CLASSES.EXPAND);\n thisnode.find(':header i.fa').addClass(CLASSES.COLLAPSE);\n thisnode.find(':header img.icon').attr('src', expandedImage.attr('src'));\n } else {\n targetnode.removeClass('visible');\n targetnode.addClass('hide');\n targetnode.attr('aria-expanded', false);\n thisnode.find(':header i.fa').removeClass(CLASSES.COLLAPSE);\n thisnode.find(':header i.fa').addClass(CLASSES.EXPAND);\n thisnode.find(':header img.icon').attr('src', collapsedImage.attr('src'));\n }\n },\n\n /**\n * Expand or collapse all nodes on this page.\n *\n * @param {string} nextstate The next state to change to.\n */\n expandCollapseAll: function(nextstate) {\n var currentstate = (nextstate == 'visible') ? 'hide' : 'visible';\n var ariaexpandedstate = (nextstate == 'visible') ? true : false;\n var iconclassnow = (nextstate == 'visible') ? CLASSES.EXPAND : CLASSES.COLLAPSE;\n var iconclassnext = (nextstate == 'visible') ? CLASSES.COLLAPSE : CLASSES.EXPAND;\n var imagenow = (nextstate == 'visible') ? expandedImage.attr('src') : collapsedImage.attr('src');\n $('.' + currentstate).each(function() {\n $(this).removeClass(currentstate);\n $(this).addClass(nextstate);\n $(this).attr('aria-expanded', ariaexpandedstate);\n });\n $('.tool_dataprivacy-expand-all').data('visibilityState', currentstate);\n\n str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) {\n $('.tool_dataprivacy-expand-all').html(langString);\n return;\n }).catch(Notification.exception);\n\n $(':header i.fa').each(function() {\n $(this).removeClass(iconclassnow);\n $(this).addClass(iconclassnext);\n });\n $(':header img.icon').each(function() {\n $(this).attr('src', imagenow);\n });\n }\n };\n});\n"],"file":"expand_contract.min.js"} \ No newline at end of file +{"version":3,"file":"expand_contract.min.js","sources":["../src/expand_contract.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 * Potential user selector module.\n *\n * @module tool_dataprivacy/expand_contract\n * @copyright 2018 Adrian Greeve\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/url', 'core/str'], function($, url, str) {\n\n var expandedImage = $('\"\"');\n var collapsedImage = $('\"\"');\n\n /*\n * Class names to apply when expanding/collapsing nodes.\n */\n var CLASSES = {\n EXPAND: 'fa-caret-right',\n COLLAPSE: 'fa-caret-down'\n };\n\n return /** @alias module:tool_dataprivacy/expand-collapse */ {\n /**\n * Expand or collapse a selected node.\n *\n * @param {object} targetnode The node that we want to expand / collapse\n * @param {object} thisnode The node that was clicked.\n */\n expandCollapse: function(targetnode, thisnode) {\n if (targetnode.hasClass('hide')) {\n targetnode.removeClass('hide');\n targetnode.addClass('visible');\n targetnode.attr('aria-expanded', true);\n thisnode.find(':header i.fa').removeClass(CLASSES.EXPAND);\n thisnode.find(':header i.fa').addClass(CLASSES.COLLAPSE);\n thisnode.find(':header img.icon').attr('src', expandedImage.attr('src'));\n } else {\n targetnode.removeClass('visible');\n targetnode.addClass('hide');\n targetnode.attr('aria-expanded', false);\n thisnode.find(':header i.fa').removeClass(CLASSES.COLLAPSE);\n thisnode.find(':header i.fa').addClass(CLASSES.EXPAND);\n thisnode.find(':header img.icon').attr('src', collapsedImage.attr('src'));\n }\n },\n\n /**\n * Expand or collapse all nodes on this page.\n *\n * @param {string} nextstate The next state to change to.\n */\n expandCollapseAll: function(nextstate) {\n var currentstate = (nextstate == 'visible') ? 'hide' : 'visible';\n var ariaexpandedstate = (nextstate == 'visible') ? true : false;\n var iconclassnow = (nextstate == 'visible') ? CLASSES.EXPAND : CLASSES.COLLAPSE;\n var iconclassnext = (nextstate == 'visible') ? CLASSES.COLLAPSE : CLASSES.EXPAND;\n var imagenow = (nextstate == 'visible') ? expandedImage.attr('src') : collapsedImage.attr('src');\n $('.' + currentstate).each(function() {\n $(this).removeClass(currentstate);\n $(this).addClass(nextstate);\n $(this).attr('aria-expanded', ariaexpandedstate);\n });\n $('.tool_dataprivacy-expand-all').data('visibilityState', currentstate);\n\n str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) {\n $('.tool_dataprivacy-expand-all').html(langString);\n return;\n }).catch(Notification.exception);\n\n $(':header i.fa').each(function() {\n $(this).removeClass(iconclassnow);\n $(this).addClass(iconclassnext);\n });\n $(':header img.icon').each(function() {\n $(this).attr('src', imagenow);\n });\n }\n };\n});\n"],"names":["define","$","url","str","expandedImage","imageUrl","collapsedImage","CLASSES","expandCollapse","targetnode","thisnode","hasClass","removeClass","addClass","attr","find","expandCollapseAll","nextstate","currentstate","ariaexpandedstate","iconclassnow","iconclassnext","imagenow","each","this","data","get_string","then","langString","html","catch","Notification","exception"],"mappings":";;;;;;;AAuBAA,0CAAO,CAAC,SAAU,WAAY,aAAa,SAASC,EAAGC,IAAKC,SAEpDC,cAAgBH,EAAE,oBAAsBC,IAAIG,SAAS,cAAgB,OACrEC,eAAiBL,EAAE,oBAAsBC,IAAIG,SAAS,eAAiB,OAKvEE,eACQ,iBADRA,iBAEU,sBAG+C,CAOzDC,eAAgB,SAASC,WAAYC,UAC7BD,WAAWE,SAAS,SACpBF,WAAWG,YAAY,QACvBH,WAAWI,SAAS,WACpBJ,WAAWK,KAAK,iBAAiB,GACjCJ,SAASK,KAAK,gBAAgBH,YAAYL,gBAC1CG,SAASK,KAAK,gBAAgBF,SAASN,kBACvCG,SAASK,KAAK,oBAAoBD,KAAK,MAAOV,cAAcU,KAAK,UAEjEL,WAAWG,YAAY,WACvBH,WAAWI,SAAS,QACpBJ,WAAWK,KAAK,iBAAiB,GACjCJ,SAASK,KAAK,gBAAgBH,YAAYL,kBAC1CG,SAASK,KAAK,gBAAgBF,SAASN,gBACvCG,SAASK,KAAK,oBAAoBD,KAAK,MAAOR,eAAeQ,KAAK,UAS1EE,kBAAmB,SAASC,eACpBC,aAA6B,WAAbD,UAA0B,OAAS,UACnDE,kBAAkC,WAAbF,UACrBG,aAA6B,WAAbH,UAA0BV,eAAiBA,iBAC3Dc,cAA8B,WAAbJ,UAA0BV,iBAAmBA,eAC9De,SAAyB,WAAbL,UAA0Bb,cAAcU,KAAK,OAASR,eAAeQ,KAAK,OAC1Fb,EAAE,IAAMiB,cAAcK,MAAK,WACvBtB,EAAEuB,MAAMZ,YAAYM,cACpBjB,EAAEuB,MAAMX,SAASI,WACjBhB,EAAEuB,MAAMV,KAAK,gBAAiBK,sBAElClB,EAAE,gCAAgCwB,KAAK,kBAAmBP,cAE1Df,IAAIuB,WAAWR,aAAc,oBAAoBS,MAAK,SAASC,YAC3D3B,EAAE,gCAAgC4B,KAAKD,eAExCE,MAAMC,aAAaC,WAEtB/B,EAAE,gBAAgBsB,MAAK,WACnBtB,EAAEuB,MAAMZ,YAAYQ,cACpBnB,EAAEuB,MAAMX,SAASQ,kBAErBpB,EAAE,oBAAoBsB,MAAK,WACvBtB,EAAEuB,MAAMV,KAAK,MAAOQ"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/form-user-selector.min.js b/admin/tool/dataprivacy/amd/build/form-user-selector.min.js index 72a0c40be9a..e0b5040af02 100644 --- a/admin/tool/dataprivacy/amd/build/form-user-selector.min.js +++ b/admin/tool/dataprivacy/amd/build/form-user-selector.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/form-user-selector",["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function processResults(b,c){var d=[];a.each(c,function(a,b){d.push({value:b.id,label:b._label})});return d},transport:function transport(d,e,f,g){var h=b.call([{methodname:"tool_dataprivacy_get_users",args:{query:e}}]);h[0].then(function(b){var d=[],e=0;a.each(b,function(a,b){d.push(c.render("tool_dataprivacy/form-user-selector-suggestion",b))});return a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b,function(a,b){b._label=c[e];e++});f(b)})}).fail(g)}}}); -//# sourceMappingURL=form-user-selector.min.js.map +/** + * Potential user selector module. + * + * @module tool_dataprivacy/form-user-selector + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/form-user-selector",["jquery","core/ajax","core/templates"],(function($,Ajax,Templates){return{processResults:function(selector,results){var users=[];return $.each(results,(function(index,user){users.push({value:user.id,label:user._label})})),users},transport:function(selector,query,success,failure){Ajax.call([{methodname:"tool_dataprivacy_get_users",args:{query:query}}])[0].then((function(results){var promises=[],i=0;return $.each(results,(function(index,user){promises.push(Templates.render("tool_dataprivacy/form-user-selector-suggestion",user))})),$.when.apply($.when,promises).then((function(){var args=arguments;$.each(results,(function(index,user){user._label=args[i],i++})),success(results)}))})).fail(failure)}}})); + +//# sourceMappingURL=form-user-selector.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map b/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map index 1b0b75a5037..5d218425475 100644 --- a/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map +++ b/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/form-user-selector.js"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","promise","call","methodname","args","then","promises","i","render","when","apply","arguments","fail"],"mappings":"AAuBAA,OAAM,uCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,gBAAxB,CAAD,CAA4C,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAA6B,CAE3E,MAAgE,CAE5DC,cAAc,CAAE,wBAASC,CAAT,CAAmBC,CAAnB,CAA4B,CACxC,GAAIC,CAAAA,CAAK,CAAG,EAAZ,CACAN,CAAC,CAACO,IAAF,CAAOF,CAAP,CAAgB,SAASG,CAAT,CAAgBC,CAAhB,CAAsB,CAClCH,CAAK,CAACI,IAAN,CAAW,CACPC,KAAK,CAAEF,CAAI,CAACG,EADL,CAEPC,KAAK,CAAEJ,CAAI,CAACK,MAFL,CAAX,CAIH,CALD,EAMA,MAAOR,CAAAA,CACV,CAX2D,CAa5DS,SAAS,CAAE,mBAASX,CAAT,CAAmBY,CAAnB,CAA0BC,CAA1B,CAAmCC,CAAnC,CAA4C,CACnD,GAAIC,CAAAA,CAAO,CAEDlB,CAAI,CAACmB,IAAL,CAAU,CAAC,CACjBC,UAAU,CAAE,4BADK,CAEjBC,IAAI,CAAE,CACFN,KAAK,CAAEA,CADL,CAFW,CAAD,CAAV,CAFV,CASAG,CAAO,CAAC,CAAD,CAAP,CAAWI,IAAX,CAAgB,SAASlB,CAAT,CAAkB,CAC9B,GAAImB,CAAAA,CAAQ,CAAG,EAAf,CACIC,CAAC,CAAG,CADR,CAIAzB,CAAC,CAACO,IAAF,CAAOF,CAAP,CAAgB,SAASG,CAAT,CAAgBC,CAAhB,CAAsB,CAClCe,CAAQ,CAACd,IAAT,CAAcR,CAAS,CAACwB,MAAV,CAAiB,gDAAjB,CAAmEjB,CAAnE,CAAd,CACH,CAFD,EAKA,MAAOT,CAAAA,CAAC,CAAC2B,IAAF,CAAOC,KAAP,CAAa5B,CAAC,CAAC2B,IAAf,CAAqBH,CAArB,EAA+BD,IAA/B,CAAoC,UAAW,CAClD,GAAID,CAAAA,CAAI,CAAGO,SAAX,CACA7B,CAAC,CAACO,IAAF,CAAOF,CAAP,CAAgB,SAASG,CAAT,CAAgBC,CAAhB,CAAsB,CAClCA,CAAI,CAACK,MAAL,CAAcQ,CAAI,CAACG,CAAD,CAAlB,CACAA,CAAC,EACJ,CAHD,EAIAR,CAAO,CAACZ,CAAD,CAEV,CARM,CAUV,CApBD,EAoBGyB,IApBH,CAoBQZ,CApBR,CAqBH,CA5C2D,CAgDnE,CAlDK,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 * Potential user selector module.\n *\n * @module tool_dataprivacy/form-user-selector\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_dataprivacy/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n promise = Ajax.call([{\n methodname: 'tool_dataprivacy_get_users',\n args: {\n query: query\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results, function(index, user) {\n promises.push(Templates.render('tool_dataprivacy/form-user-selector-suggestion', user));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results);\n return;\n });\n\n }).fail(failure);\n }\n\n };\n\n});\n"],"file":"form-user-selector.min.js"} \ No newline at end of file +{"version":3,"file":"form-user-selector.min.js","sources":["../src/form-user-selector.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 * Potential user selector module.\n *\n * @module tool_dataprivacy/form-user-selector\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_dataprivacy/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n promise = Ajax.call([{\n methodname: 'tool_dataprivacy_get_users',\n args: {\n query: query\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results, function(index, user) {\n promises.push(Templates.render('tool_dataprivacy/form-user-selector-suggestion', user));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results);\n return;\n });\n\n }).fail(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","call","methodname","args","then","promises","i","render","when","apply","arguments","fail"],"mappings":";;;;;;;AAuBAA,6CAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBAEA,CAE5DC,eAAgB,SAASC,SAAUC,aAC3BC,MAAQ,UACZN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,YAGbR,OAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,SAGhCjB,KAAKkB,KAAK,CAAC,CACjBC,WAAY,6BACZC,KAAM,CACFL,MAAOA,UAIP,GAAGM,MAAK,SAASjB,aACjBkB,SAAW,GACXC,EAAI,SAGRxB,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5Bc,SAASb,KAAKR,UAAUuB,OAAO,iDAAkDhB,UAI9ET,EAAE0B,KAAKC,MAAM3B,EAAE0B,KAAMH,UAAUD,MAAK,eACnCD,KAAOO,UACX5B,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BA,KAAKK,OAASO,KAAKG,GACnBA,OAEJP,QAAQZ,eAIbwB,KAAKX"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/myrequestactions.min.js b/admin/tool/dataprivacy/amd/build/myrequestactions.min.js index b1b7317c48a..ebad9a83240 100644 --- a/admin/tool/dataprivacy/amd/build/myrequestactions.min.js +++ b/admin/tool/dataprivacy/amd/build/myrequestactions.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/myrequestactions",["exports","core/ajax","core/notification","core/pending","core/str"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=f(b);c=f(c);d=f(d);function f(a){return a&&a.__esModule?a:{default:a}}function g(a,b){return m(a)||l(a,b)||j(a,b)||h()}function h(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function j(a,b){if(!a)return;if("string"==typeof a)return k(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return k(a,b)}function k(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c{document.addEventListener("click",(event=>{const triggerElement=event.target.closest(SELECTORS_CANCEL_REQUEST);if(null===triggerElement)return;event.preventDefault();(0,_str.get_strings)([{key:"cancelrequest",component:"tool_dataprivacy"},{key:"cancelrequestconfirmation",component:"tool_dataprivacy"}]).then((_ref=>{let[cancelRequest,cancelConfirm]=_ref;return _notification.default.confirm(cancelRequest,cancelConfirm,cancelRequest,null,(()=>{const pendingPromise=new _pending.default("tool/dataprivacy:cancelRequest"),request={methodname:"tool_dataprivacy_cancel_data_request",args:{requestid:triggerElement.dataset.requestid}};_ajax.default.call([request])[0].then((response=>(response.result?window.location.reload():_notification.default.addNotification({type:"error",message:response.warnings[0].message}),pendingPromise.resolve()))).catch(_notification.default.exception)}))})).catch()}))}})); + +//# sourceMappingURL=myrequestactions.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map b/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map index a0ee7a25871..ac1d3817f17 100644 --- a/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/myrequestactions.js"],"names":["SELECTORS","CANCEL_REQUEST","init","document","addEventListener","event","triggerElement","target","closest","preventDefault","key","component","then","cancelRequest","cancelConfirm","Notification","confirm","pendingPromise","Pending","request","methodname","args","requestid","dataset","Ajax","call","response","result","window","location","reload","addNotification","type","message","warnings","resolve","catch","exception"],"mappings":"kNAuBA,OACA,OACA,O,khCAGMA,CAAAA,CAAS,CAAG,CACdC,cAAc,CAAE,0CADF,C,QAOE,QAAPC,CAAAA,IAAO,EAAM,CACtBC,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,CAAmC,SAAAC,CAAK,CAAI,CACxC,GAAMC,CAAAA,CAAc,CAAGD,CAAK,CAACE,MAAN,CAAaC,OAAb,CAAqBR,CAAS,CAACC,cAA/B,CAAvB,CACA,GAAuB,IAAnB,GAAAK,CAAJ,CAA6B,CACzB,MACH,CAEDD,CAAK,CAACI,cAAN,GAOA,kBALwB,CACpB,CAACC,GAAG,CAAE,eAAN,CAAuBC,SAAS,CAAE,kBAAlC,CADoB,CAEpB,CAACD,GAAG,CAAE,2BAAN,CAAmCC,SAAS,CAAE,kBAA9C,CAFoB,CAKxB,EAA4BC,IAA5B,CAAiC,WAAoC,cAAlCC,CAAkC,MAAnBC,CAAmB,MACjE,MAAOC,WAAaC,OAAb,CAAqBH,CAArB,CAAoCC,CAApC,CAAmDD,CAAnD,CAAkE,IAAlE,CAAwE,UAAM,IAC3EI,CAAAA,CAAc,CAAG,GAAIC,UAAJ,CAAY,gCAAZ,CAD0D,CAE3EC,CAAO,CAAG,CACZC,UAAU,CAAE,sCADA,CAEZC,IAAI,CAAE,CAACC,SAAS,CAAEhB,CAAc,CAACiB,OAAf,CAAuBD,SAAnC,CAFM,CAFiE,CAOjFE,UAAKC,IAAL,CAAU,CAACN,CAAD,CAAV,EAAqB,CAArB,EAAwBP,IAAxB,CAA6B,SAAAc,CAAQ,CAAI,CACrC,GAAIA,CAAQ,CAACC,MAAb,CAAqB,CACjBC,MAAM,CAACC,QAAP,CAAgBC,MAAhB,EACH,CAFD,IAEO,CACHf,UAAagB,eAAb,CAA6B,CACzBC,IAAI,CAAE,OADmB,CAEzBC,OAAO,CAAEP,CAAQ,CAACQ,QAAT,CAAkB,CAAlB,EAAqBD,OAFL,CAA7B,CAIH,CACD,MAAOhB,CAAAA,CAAc,CAACkB,OAAf,EACV,CAVD,EAUGC,KAVH,CAUSrB,UAAasB,SAVtB,CAWH,CAlBM,CAmBV,CApBD,EAoBGD,KApBH,EAqBH,CAlCD,CAmCH,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 .\n\n/**\n * AMD module to enable users to manage their own data requests.\n *\n * @module tool_dataprivacy/myrequestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport {get_strings as getStrings} from 'core/str';\n\nconst SELECTORS = {\n CANCEL_REQUEST: '[data-action=\"cancel\"][data-requestid]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n document.addEventListener('click', event => {\n const triggerElement = event.target.closest(SELECTORS.CANCEL_REQUEST);\n if (triggerElement === null) {\n return;\n }\n\n event.preventDefault();\n\n const requiredStrings = [\n {key: 'cancelrequest', component: 'tool_dataprivacy'},\n {key: 'cancelrequestconfirmation', component: 'tool_dataprivacy'},\n ];\n\n getStrings(requiredStrings).then(([cancelRequest, cancelConfirm]) => {\n return Notification.confirm(cancelRequest, cancelConfirm, cancelRequest, null, () => {\n const pendingPromise = new Pending('tool/dataprivacy:cancelRequest');\n const request = {\n methodname: 'tool_dataprivacy_cancel_data_request',\n args: {requestid: triggerElement.dataset.requestid}\n };\n\n Ajax.call([request])[0].then(response => {\n if (response.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n type: 'error',\n message: response.warnings[0].message\n });\n }\n return pendingPromise.resolve();\n }).catch(Notification.exception);\n });\n }).catch();\n });\n};\n"],"file":"myrequestactions.min.js"} \ No newline at end of file +{"version":3,"file":"myrequestactions.min.js","sources":["../src/myrequestactions.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 * AMD module to enable users to manage their own data requests.\n *\n * @module tool_dataprivacy/myrequestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport {get_strings as getStrings} from 'core/str';\n\nconst SELECTORS = {\n CANCEL_REQUEST: '[data-action=\"cancel\"][data-requestid]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n document.addEventListener('click', event => {\n const triggerElement = event.target.closest(SELECTORS.CANCEL_REQUEST);\n if (triggerElement === null) {\n return;\n }\n\n event.preventDefault();\n\n const requiredStrings = [\n {key: 'cancelrequest', component: 'tool_dataprivacy'},\n {key: 'cancelrequestconfirmation', component: 'tool_dataprivacy'},\n ];\n\n getStrings(requiredStrings).then(([cancelRequest, cancelConfirm]) => {\n return Notification.confirm(cancelRequest, cancelConfirm, cancelRequest, null, () => {\n const pendingPromise = new Pending('tool/dataprivacy:cancelRequest');\n const request = {\n methodname: 'tool_dataprivacy_cancel_data_request',\n args: {requestid: triggerElement.dataset.requestid}\n };\n\n Ajax.call([request])[0].then(response => {\n if (response.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n type: 'error',\n message: response.warnings[0].message\n });\n }\n return pendingPromise.resolve();\n }).catch(Notification.exception);\n });\n }).catch();\n });\n};\n"],"names":["SELECTORS","document","addEventListener","event","triggerElement","target","closest","preventDefault","key","component","then","_ref","cancelRequest","cancelConfirm","Notification","confirm","pendingPromise","Pending","request","methodname","args","requestid","dataset","call","response","result","window","location","reload","addNotification","type","message","warnings","resolve","catch","exception"],"mappings":";;;;;;;0NA4BMA,yBACc,uDAMA,KAChBC,SAASC,iBAAiB,SAASC,cACzBC,eAAiBD,MAAME,OAAOC,QAAQN,6BACrB,OAAnBI,sBAIJD,MAAMI,sCAEkB,CACpB,CAACC,IAAK,gBAAiBC,UAAW,oBAClC,CAACD,IAAK,4BAA6BC,UAAW,sBAGtBC,MAAKC,WAAEC,cAAeC,2BACvCC,sBAAaC,QAAQH,cAAeC,cAAeD,cAAe,MAAM,WACrEI,eAAiB,IAAIC,iBAAQ,kCAC7BC,QAAU,CACZC,WAAY,uCACZC,KAAM,CAACC,UAAWjB,eAAekB,QAAQD,0BAGxCE,KAAK,CAACL,UAAU,GAAGR,MAAKc,WACrBA,SAASC,OACTC,OAAOC,SAASC,+BAEHC,gBAAgB,CACzBC,KAAM,QACNC,QAASP,SAASQ,SAAS,GAAGD,UAG/Bf,eAAeiB,aACvBC,MAAMpB,sBAAaqB,iBAE3BD"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/purposesactions.min.js b/admin/tool/dataprivacy/amd/build/purposesactions.min.js index 765e5ef4102..edcabcf6e51 100644 --- a/admin/tool/dataprivacy/amd/build/purposesactions.min.js +++ b/admin/tool/dataprivacy/amd/build/purposesactions.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/purposesactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var g={DELETE:"[data-action=\"deletepurpose\"]"},h=function(){this.registerEvents()};h.prototype.registerEvents=function(){a(g.DELETE).click(function(g){g.preventDefault();var h=a(this).data("id"),i=a(this).data("name");d.get_strings([{key:"deletepurpose",component:"tool_dataprivacy"},{key:"deletepurposetext",component:"tool_dataprivacy",param:i},{key:"delete"}]).then(function(d){var g=d[0],i=d[1],j=d[2];return e.create({title:g,body:i,type:e.types.SAVE_CANCEL}).then(function(d){d.setSaveButtonText(j);d.getRoot().on(f.save,function(){b.call([{methodname:"tool_dataprivacy_delete_purpose",args:{id:h}}])[0].done(function(b){if(b.result){a("tr[data-purposeid=\""+h+"\"]").remove()}else{c.addNotification({message:b.warnings[0].message,type:"error"})}}).fail(c.exception)});d.getRoot().on(f.hidden,function(){d.destroy()});return d})}).done(function(a){a.show()}).fail(c.exception)})};return{init:function init(){return new h}}}); -//# sourceMappingURL=purposesactions.min.js.map +/** + * AMD module for purposes actions. + * + * @module tool_dataprivacy/purposesactions + * @copyright 2018 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/purposesactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],(function($,Ajax,Notification,Str,ModalFactory,ModalEvents){var ACTIONS_DELETE='[data-action="deletepurpose"]',PurposesActions=function(){this.registerEvents()};return PurposesActions.prototype.registerEvents=function(){$(ACTIONS_DELETE).click((function(e){e.preventDefault();var id=$(this).data("id"),stringkeys=[{key:"deletepurpose",component:"tool_dataprivacy"},{key:"deletepurposetext",component:"tool_dataprivacy",param:$(this).data("name")},{key:"delete"}];Str.get_strings(stringkeys).then((function(langStrings){var title=langStrings[0],confirmMessage=langStrings[1],buttonText=langStrings[2];return ModalFactory.create({title:title,body:confirmMessage,type:ModalFactory.types.SAVE_CANCEL}).then((function(modal){return modal.setSaveButtonText(buttonText),modal.getRoot().on(ModalEvents.save,(function(){var request={methodname:"tool_dataprivacy_delete_purpose",args:{id:id}};Ajax.call([request])[0].done((function(data){data.result?$('tr[data-purposeid="'+id+'"]').remove():Notification.addNotification({message:data.warnings[0].message,type:"error"})})).fail(Notification.exception)})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal}))})).done((function(modal){modal.show()})).fail(Notification.exception)}))},{init:function(){return new PurposesActions}}})); + +//# sourceMappingURL=purposesactions.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map b/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map index 6ac9001c7a5..6e7f8f4da8f 100644 --- a/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/purposesactions.js"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","DELETE","PurposesActions","registerEvents","prototype","click","e","preventDefault","id","data","purposename","get_strings","key","component","param","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","call","methodname","args","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show"],"mappings":"AAsBAA,OAAM,oCAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,oBALG,CAMH,mBANG,CAAD,CAON,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAAqCC,CAArC,CAAmDC,CAAnD,CAAgE,IAOxDC,CAAAA,CAAO,CAAG,CACVC,MAAM,CAAE,iCADE,CAP8C,CAcxDC,CAAe,CAAG,UAAW,CAC7B,KAAKC,cAAL,EACH,CAhB2D,CAqB5DD,CAAe,CAACE,SAAhB,CAA0BD,cAA1B,CAA2C,UAAW,CAClDT,CAAC,CAACM,CAAO,CAACC,MAAT,CAAD,CAAkBI,KAA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AA9B,CAAD,CAAqC2B,MAArC,EACH,CAFD,IAEO,CACHvC,CAAY,CAACwC,eAAb,CAA6B,CACzBC,OAAO,CAAE5B,CAAI,CAAC6B,QAAL,CAAc,CAAd,EAAiBD,OADD,CAEzBf,IAAI,CAAE,OAFmB,CAA7B,CAIH,CACJ,CATD,EASGiB,IATH,CASQ3C,CAAY,CAAC4C,SATrB,CAUH,CAjBD,EAoBAf,CAAK,CAACE,OAAN,GAAgBC,EAAhB,CAAmB7B,CAAW,CAAC0C,MAA/B,CAAuC,UAAW,CAE9ChB,CAAK,CAACiB,OAAN,EACH,CAHD,EAKA,MAAOjB,CAAAA,CACV,CAlCM,CAmCV,CAvCD,EAuCGQ,IAvCH,CAuCQ,SAASR,CAAT,CAAgB,CACpBA,CAAK,CAACkB,IAAN,EAEH,CA1CD,EA0CGJ,IA1CH,CA0CQ3C,CAAY,CAAC4C,SA1CrB,CA2CH,CA/DD,CAgEH,CAjED,CAmEA,MAA6D,CASzD,KAAQ,eAAW,CACf,MAAO,IAAItC,CAAAA,CACd,CAXwD,CAahE,CA5GK,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 for purposes actions.\n *\n * @module tool_dataprivacy/purposesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletepurpose\"]',\n };\n\n /**\n * PurposesActions class.\n */\n var PurposesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n PurposesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var purposename = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletepurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletepurposetext',\n component: 'tool_dataprivacy',\n param: purposename\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_purpose',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-purposeid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/purposesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {PurposesActions}\n */\n 'init': function() {\n return new PurposesActions();\n }\n };\n});\n"],"file":"purposesactions.min.js"} \ No newline at end of file +{"version":3,"file":"purposesactions.min.js","sources":["../src/purposesactions.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 * AMD module for purposes actions.\n *\n * @module tool_dataprivacy/purposesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletepurpose\"]',\n };\n\n /**\n * PurposesActions class.\n */\n var PurposesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n PurposesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var purposename = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletepurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletepurposetext',\n component: 'tool_dataprivacy',\n param: purposename\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_purpose',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-purposeid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/purposesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {PurposesActions}\n */\n 'init': function() {\n return new PurposesActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","PurposesActions","registerEvents","prototype","click","e","preventDefault","id","this","data","stringkeys","key","component","param","get_strings","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show"],"mappings":";;;;;;;AAsBAA,0CAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,iBAO3CC,eACQ,gCAMRC,gBAAkB,gBACbC,yBAMTD,gBAAgBE,UAAUD,eAAiB,WACvCR,EAAEM,gBAAgBI,OAAM,SAASC,GAC7BA,EAAEC,qBAEEC,GAAKb,EAAEc,MAAMC,KAAK,MAElBC,WAAa,CACb,CACIC,IAAK,gBACLC,UAAW,oBAEf,CACID,IAAK,oBACLC,UAAW,mBACXC,MATUnB,EAAEc,MAAMC,KAAK,SAW3B,CACIE,IAAK,WAIbd,IAAIiB,YAAYJ,YAAYK,MAAK,SAASC,iBAClCC,MAAQD,YAAY,GACpBE,eAAiBF,YAAY,GAC7BG,WAAaH,YAAY,UACtBlB,aAAasB,OAAO,CACvBH,MAAOA,MACPI,KAAMH,eACNI,KAAMxB,aAAayB,MAAMC,cAC1BT,MAAK,SAASU,cACbA,MAAMC,kBAAkBP,YAGxBM,MAAME,UAAUC,GAAG7B,YAAY8B,MAAM,eAE7BC,QAAU,CACVC,WAAY,kCACZC,KAAM,IAAOzB,KAGjBZ,KAAKsC,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASzB,MAC9BA,KAAK0B,OACLzC,EAAE,sBAAwBa,GAAK,MAAM6B,SAErCxC,aAAayC,gBAAgB,CACzBC,QAAS7B,KAAK8B,SAAS,GAAGD,QAC1BhB,KAAM,aAGfkB,KAAK5C,aAAa6C,cAIzBhB,MAAME,UAAUC,GAAG7B,YAAY2C,QAAQ,WAEnCjB,MAAMkB,aAGHlB,YAEZS,MAAK,SAAST,OACbA,MAAMmB,UAEPJ,KAAK5C,aAAa6C,eAIgC,MASjD,kBACG,IAAIxC"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/request_filter.min.js b/admin/tool/dataprivacy/amd/build/request_filter.min.js index ed608348291..048c7629f17 100644 --- a/admin/tool/dataprivacy/amd/build/request_filter.min.js +++ b/admin/tool/dataprivacy/amd/build/request_filter.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/request_filter",["jquery","core/form-autocomplete","core/str","core/notification"],function(a,b,c,d){var e={REQUEST_FILTERS:"#request-filters"},f=function init(){c.get_strings([{key:"filter",component:"moodle"},{key:"nofiltersapplied",component:"moodle"}]).then(function(a){var c=a[0],d=a[1];return b.enhance(e.REQUEST_FILTERS,!1,"",c,!1,!0,d,!0)}).fail(d.exception);var f=a(e.REQUEST_FILTERS).val();a(e.REQUEST_FILTERS).on("change",function(){var b=a(this).val();if(f.join(",")!==b.join(",")){if(0===b.length){a("#filters-cleared").val(1)}a(this.form).submit()}})};return{init:function init(){f()}}}); -//# sourceMappingURL=request_filter.min.js.map +/** + * JS module for the data requests filter. + * + * @module tool_dataprivacy/request_filter + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/request_filter",["jquery","core/form-autocomplete","core/str","core/notification"],(function($,Autocomplete,Str,Notification){var SELECTORS_REQUEST_FILTERS="#request-filters";return{init:function(){!function(){Str.get_strings([{key:"filter",component:"moodle"},{key:"nofiltersapplied",component:"moodle"}]).then((function(langstrings){var placeholder=langstrings[0],noSelectionString=langstrings[1];return Autocomplete.enhance(SELECTORS_REQUEST_FILTERS,!1,"",placeholder,!1,!0,noSelectionString,!0)})).fail(Notification.exception);var last=$(SELECTORS_REQUEST_FILTERS).val();$(SELECTORS_REQUEST_FILTERS).on("change",(function(){var current=$(this).val();last.join(",")!==current.join(",")&&(0===current.length&&$("#filters-cleared").val(1),$(this.form).submit())}))}()}}})); + +//# sourceMappingURL=request_filter.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/request_filter.min.js.map b/admin/tool/dataprivacy/amd/build/request_filter.min.js.map index 15634cd24d4..2bc86c5ab28 100644 --- a/admin/tool/dataprivacy/amd/build/request_filter.min.js.map +++ b/admin/tool/dataprivacy/amd/build/request_filter.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/request_filter.js"],"names":["define","$","Autocomplete","Str","Notification","SELECTORS","REQUEST_FILTERS","init","get_strings","key","component","then","langstrings","placeholder","noSelectionString","enhance","fail","exception","last","val","on","current","join","length","form","submit"],"mappings":"AAsBAA,OAAM,mCAAC,CAAC,QAAD,CAAW,wBAAX,CAAqC,UAArC,CAAiD,mBAAjD,CAAD,CAAwE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAA+BC,CAA/B,CAA6C,IAQnHC,CAAAA,CAAS,CAAG,CACZC,eAAe,CAAE,kBADL,CARuG,CAkBnHC,CAAI,CAAG,QAAPA,CAAAA,IAAO,EAAW,CAYlBJ,CAAG,CAACK,WAAJ,CAXiB,CACb,CACIC,GAAG,CAAE,QADT,CAEIC,SAAS,CAAE,QAFf,CADa,CAKb,CACID,GAAG,CAAE,kBADT,CAEIC,SAAS,CAAE,QAFf,CALa,CAWjB,EAA4BC,IAA5B,CAAiC,SAASC,CAAT,CAAsB,IAC/CC,CAAAA,CAAW,CAAGD,CAAW,CAAC,CAAD,CADsB,CAE/CE,CAAiB,CAAGF,CAAW,CAAC,CAAD,CAFgB,CAGnD,MAAOV,CAAAA,CAAY,CAACa,OAAb,CAAqBV,CAAS,CAACC,eAA/B,IAAuD,EAAvD,CAA2DO,CAA3D,OAAqFC,CAArF,IACV,CAJD,EAIGE,IAJH,CAIQZ,CAAY,CAACa,SAJrB,EAMA,GAAIC,CAAAA,CAAI,CAAGjB,CAAC,CAACI,CAAS,CAACC,eAAX,CAAD,CAA6Ba,GAA7B,EAAX,CACAlB,CAAC,CAACI,CAAS,CAACC,eAAX,CAAD,CAA6Bc,EAA7B,CAAgC,QAAhC,CAA0C,UAAW,CACjD,GAAIC,CAAAA,CAAO,CAAGpB,CAAC,CAAC,IAAD,CAAD,CAAQkB,GAAR,EAAd,CAEA,GAAID,CAAI,CAACI,IAAL,CAAU,GAAV,IAAmBD,CAAO,CAACC,IAAR,CAAa,GAAb,CAAvB,CAA0C,CAEtC,GAAuB,CAAnB,GAAAD,CAAO,CAACE,MAAZ,CAA0B,CACtBtB,CAAC,CAAC,kBAAD,CAAD,CAAsBkB,GAAtB,CAA0B,CAA1B,CACH,CACDlB,CAAC,CAAC,KAAKuB,IAAN,CAAD,CAAaC,MAAb,EACH,CACJ,CAVD,CAWH,CAhDsH,CAkDvH,MAAmD,CAM/ClB,IAAI,CAAE,eAAW,CACbA,CAAI,EACP,CAR8C,CAUtD,CA5DK,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 * JS module for the data requests filter.\n *\n * @module tool_dataprivacy/request_filter\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'], function($, Autocomplete, Str, Notification) {\n\n /**\n * Selectors.\n *\n * @access private\n * @type {{REQUEST_FILTERS: string}}\n */\n var SELECTORS = {\n REQUEST_FILTERS: '#request-filters'\n };\n\n /**\n * Init function.\n *\n * @method init\n * @private\n */\n var init = function() {\n var stringkeys = [\n {\n key: 'filter',\n component: 'moodle'\n },\n {\n key: 'nofiltersapplied',\n component: 'moodle'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langstrings) {\n var placeholder = langstrings[0];\n var noSelectionString = langstrings[1];\n return Autocomplete.enhance(SELECTORS.REQUEST_FILTERS, false, '', placeholder, false, true, noSelectionString, true);\n }).fail(Notification.exception);\n\n var last = $(SELECTORS.REQUEST_FILTERS).val();\n $(SELECTORS.REQUEST_FILTERS).on('change', function() {\n var current = $(this).val();\n // Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.\n if (last.join(',') !== current.join(',')) {\n // If we're submitting without filters, set the hidden input 'filters-cleared' to 1.\n if (current.length === 0) {\n $('#filters-cleared').val(1);\n }\n $(this.form).submit();\n }\n });\n };\n\n return /** @alias module:core/form-autocomplete */ {\n /**\n * Initialise the unified user filter.\n *\n * @method init\n */\n init: function() {\n init();\n }\n };\n});\n"],"file":"request_filter.min.js"} \ No newline at end of file +{"version":3,"file":"request_filter.min.js","sources":["../src/request_filter.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 * JS module for the data requests filter.\n *\n * @module tool_dataprivacy/request_filter\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'], function($, Autocomplete, Str, Notification) {\n\n /**\n * Selectors.\n *\n * @access private\n * @type {{REQUEST_FILTERS: string}}\n */\n var SELECTORS = {\n REQUEST_FILTERS: '#request-filters'\n };\n\n /**\n * Init function.\n *\n * @method init\n * @private\n */\n var init = function() {\n var stringkeys = [\n {\n key: 'filter',\n component: 'moodle'\n },\n {\n key: 'nofiltersapplied',\n component: 'moodle'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langstrings) {\n var placeholder = langstrings[0];\n var noSelectionString = langstrings[1];\n return Autocomplete.enhance(SELECTORS.REQUEST_FILTERS, false, '', placeholder, false, true, noSelectionString, true);\n }).fail(Notification.exception);\n\n var last = $(SELECTORS.REQUEST_FILTERS).val();\n $(SELECTORS.REQUEST_FILTERS).on('change', function() {\n var current = $(this).val();\n // Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.\n if (last.join(',') !== current.join(',')) {\n // If we're submitting without filters, set the hidden input 'filters-cleared' to 1.\n if (current.length === 0) {\n $('#filters-cleared').val(1);\n }\n $(this.form).submit();\n }\n });\n };\n\n return /** @alias module:core/form-autocomplete */ {\n /**\n * Initialise the unified user filter.\n *\n * @method init\n */\n init: function() {\n init();\n }\n };\n});\n"],"names":["define","$","Autocomplete","Str","Notification","SELECTORS","init","get_strings","key","component","then","langstrings","placeholder","noSelectionString","enhance","fail","exception","last","val","on","current","this","join","length","form","submit"],"mappings":";;;;;;;AAsBAA,yCAAO,CAAC,SAAU,yBAA0B,WAAY,sBAAsB,SAASC,EAAGC,aAAcC,IAAKC,kBAQrGC,0BACiB,yBAyC8B,CAM/CC,KAAM,YAtCC,WAYPH,IAAII,YAXa,CACb,CACIC,IAAK,SACLC,UAAW,UAEf,CACID,IAAK,mBACLC,UAAW,YAISC,MAAK,SAASC,iBAClCC,YAAcD,YAAY,GAC1BE,kBAAoBF,YAAY,UAC7BT,aAAaY,QAAQT,2BAA2B,EAAO,GAAIO,aAAa,GAAO,EAAMC,mBAAmB,MAChHE,KAAKX,aAAaY,eAEjBC,KAAOhB,EAAEI,2BAA2Ba,MACxCjB,EAAEI,2BAA2Bc,GAAG,UAAU,eAClCC,QAAUnB,EAAEoB,MAAMH,MAElBD,KAAKK,KAAK,OAASF,QAAQE,KAAK,OAET,IAAnBF,QAAQG,QACRtB,EAAE,oBAAoBiB,IAAI,GAE9BjB,EAAEoB,KAAKG,MAAMC,aAYjBnB"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/requestactions.min.js b/admin/tool/dataprivacy/amd/build/requestactions.min.js index 3c081e89dda..e77bb08fd2d 100644 --- a/admin/tool/dataprivacy/amd/build/requestactions.min.js +++ b/admin/tool/dataprivacy/amd/build/requestactions.min.js @@ -1,2 +1,10 @@ -define ("tool_dataprivacy/requestactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates","tool_dataprivacy/data_request_modal","tool_dataprivacy/events"],function(a,b,c,d,e,f,g,h,i){var q={APPROVE_REQUEST:"[data-action=\"approve\"]",DENY_REQUEST:"[data-action=\"deny\"]",VIEW_REQUEST:"[data-action=\"view\"]",MARK_COMPLETE:"[data-action=\"complete\"]",CHANGE_BULK_ACTION:"[id=\"bulk-action\"]",CONFIRM_BULK_ACTION:"[id=\"confirm-bulk-action\"]",SELECT_ALL:"[data-action=\"selectall\"]"},r={APPROVE:1,DENY:2},s={SELECT_REQUEST:".selectrequests"},t=function(){this.registerEvents()};t.prototype.registerEvents=function(){a(q.VIEW_REQUEST).click(function(d){d.preventDefault();var k=a(this).data("requestid"),m=b.call([{methodname:"tool_dataprivacy_get_data_request",args:{requestid:k}}]);a.when(m[0]).then(function(a){if(a.result){return a.result}c.addNotification({message:a.warnings[0].message,type:"error"});return!1}).then(function(a){var b=g.render("tool_dataprivacy/request_details",a),c={approvedeny:a.approvedeny,canmarkcomplete:a.canmarkcomplete};return e.create({title:a.typename,body:b,type:h.TYPE,large:!0,templateContext:c})}).then(function(a){a.getRoot().on(i.approve,function(){o(i.approve,j(k))});a.getRoot().on(i.deny,function(){o(i.deny,l(k))});a.getRoot().on(i.complete,function(){p("tool_dataprivacy_mark_complete",{requestid:k})});a.getRoot().on(f.hidden,function(){a.destroy()});a.show()}).catch(c.exception)});a(q.APPROVE_REQUEST).click(function(b){b.preventDefault();var c=a(this).data("requestid");o(i.approve,j(c))});a(q.DENY_REQUEST).click(function(b){b.preventDefault();var c=a(this).data("requestid");o(i.deny,l(c))});a(q.MARK_COMPLETE).click(function(b){b.preventDefault();var c=a(this).data("requestid");o(i.complete,n(c))});a(q.CONFIRM_BULK_ACTION).click(function(){var b=[],e="",f={},g=[{key:"selectbulkaction",component:"tool_dataprivacy"},{key:"selectdatarequests",component:"tool_dataprivacy"},{key:"ok"}],h=parseInt(a("#bulk-action").val());if(h!=r.APPROVE&&h!=r.DENY){d.get_strings(g).done(function(a){c.alert("",a[0],a[2])}).fail(c.exception);return}a(".selectrequests:checked").each(function(){b.push(a(this).val())});if(1>b.length){d.get_strings(g).done(function(a){c.alert("",a[1],a[2])}).fail(c.exception);return}switch(h){case r.APPROVE:e=i.bulkApprove;f=k(b);break;case r.DENY:e=i.bulkDeny;f=m(b);}o(e,f)});a(q.SELECT_ALL).change(function(b){b.preventDefault();var c=a(this).is(":checked");a(s.SELECT_REQUEST).prop("checked",c)})};function j(a){return{wsfunction:"tool_dataprivacy_approve_data_request",wsparams:{requestid:a}}}function k(a){return{wsfunction:"tool_dataprivacy_bulk_approve_data_requests",wsparams:{requestids:a}}}function l(a){return{wsfunction:"tool_dataprivacy_deny_data_request",wsparams:{requestid:a}}}function m(a){return{wsfunction:"tool_dataprivacy_bulk_deny_data_requests",wsparams:{requestids:a}}}function n(a){return{wsfunction:"tool_dataprivacy_mark_complete",wsparams:{requestid:a}}}function o(a,b){var g=[];switch(a){case i.approve:g=[{key:"approverequest",component:"tool_dataprivacy"},{key:"confirmapproval",component:"tool_dataprivacy"}];break;case i.bulkApprove:g=[{key:"bulkapproverequests",component:"tool_dataprivacy"},{key:"confirmbulkapproval",component:"tool_dataprivacy"}];break;case i.deny:g=[{key:"denyrequest",component:"tool_dataprivacy"},{key:"confirmdenial",component:"tool_dataprivacy"}];break;case i.bulkDeny:g=[{key:"bulkdenyrequests",component:"tool_dataprivacy"},{key:"confirmbulkdenial",component:"tool_dataprivacy"}];break;case i.complete:g=[{key:"markcomplete",component:"tool_dataprivacy"},{key:"confirmcompletion",component:"tool_dataprivacy"}];break;}var h="";d.get_strings(g).then(function(a){h=a[0];var b=a[1];return e.create({title:h,body:b,type:e.types.SAVE_CANCEL})}).then(function(a){a.setSaveButtonText(h);a.getRoot().on(f.save,function(){p(b.wsfunction,b.wsparams)});a.getRoot().on(f.hidden,function(){a.destroy()});a.show()}).catch(c.exception)}function p(a,d){b.call([{methodname:a,args:d}])[0].done(function(a){if(a.result){window.location.reload()}else{c.addNotification({message:a.warnings[0].message,type:"error"})}}).fail(c.exception)}return t}); -//# sourceMappingURL=requestactions.min.js.map +/** + * Request actions. + * + * @module tool_dataprivacy/requestactions + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_dataprivacy/requestactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates","tool_dataprivacy/data_request_modal","tool_dataprivacy/events"],(function($,Ajax,Notification,Str,ModalFactory,ModalEvents,Templates,ModalDataRequest,DataPrivacyEvents){var ACTIONS_APPROVE_REQUEST='[data-action="approve"]',ACTIONS_DENY_REQUEST='[data-action="deny"]',ACTIONS_VIEW_REQUEST='[data-action="view"]',ACTIONS_MARK_COMPLETE='[data-action="complete"]',ACTIONS_CONFIRM_BULK_ACTION='[id="confirm-bulk-action"]',ACTIONS_SELECT_ALL='[data-action="selectall"]',BULK_ACTIONS_APPROVE=1,BULK_ACTIONS_DENY=2,SELECTORS_SELECT_REQUEST=".selectrequests",RequestActions=function(){this.registerEvents()};function approveEventWsData(requestId){return{wsfunction:"tool_dataprivacy_approve_data_request",wsparams:{requestid:requestId}}}function denyEventWsData(requestId){return{wsfunction:"tool_dataprivacy_deny_data_request",wsparams:{requestid:requestId}}}function showConfirmation(action,wsdata){var keys=[];switch(action){case DataPrivacyEvents.approve:keys=[{key:"approverequest",component:"tool_dataprivacy"},{key:"confirmapproval",component:"tool_dataprivacy"}];break;case DataPrivacyEvents.bulkApprove:keys=[{key:"bulkapproverequests",component:"tool_dataprivacy"},{key:"confirmbulkapproval",component:"tool_dataprivacy"}];break;case DataPrivacyEvents.deny:keys=[{key:"denyrequest",component:"tool_dataprivacy"},{key:"confirmdenial",component:"tool_dataprivacy"}];break;case DataPrivacyEvents.bulkDeny:keys=[{key:"bulkdenyrequests",component:"tool_dataprivacy"},{key:"confirmbulkdenial",component:"tool_dataprivacy"}];break;case DataPrivacyEvents.complete:keys=[{key:"markcomplete",component:"tool_dataprivacy"},{key:"confirmcompletion",component:"tool_dataprivacy"}]}var modalTitle="";Str.get_strings(keys).then((function(langStrings){modalTitle=langStrings[0];var confirmMessage=langStrings[1];return ModalFactory.create({title:modalTitle,body:confirmMessage,type:ModalFactory.types.SAVE_CANCEL})})).then((function(modal){modal.setSaveButtonText(modalTitle),modal.getRoot().on(ModalEvents.save,(function(){handleSave(wsdata.wsfunction,wsdata.wsparams)})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal.show()})).catch(Notification.exception)}function handleSave(wsfunction,params){var request={methodname:wsfunction,args:params};Ajax.call([request])[0].done((function(data){data.result?window.location.reload():Notification.addNotification({message:data.warnings[0].message,type:"error"})})).fail(Notification.exception)}return RequestActions.prototype.registerEvents=function(){$(ACTIONS_VIEW_REQUEST).click((function(e){e.preventDefault();var requestId=$(this).data("requestid"),request={methodname:"tool_dataprivacy_get_data_request",args:{requestid:requestId}},promises=Ajax.call([request]);$.when(promises[0]).then((function(data){return data.result?data.result:(Notification.addNotification({message:data.warnings[0].message,type:"error"}),!1)})).then((function(data){var body=Templates.render("tool_dataprivacy/request_details",data),templateContext={approvedeny:data.approvedeny,canmarkcomplete:data.canmarkcomplete};return ModalFactory.create({title:data.typename,body:body,type:ModalDataRequest.TYPE,large:!0,templateContext:templateContext})})).then((function(modal){modal.getRoot().on(DataPrivacyEvents.approve,(function(){showConfirmation(DataPrivacyEvents.approve,approveEventWsData(requestId))})),modal.getRoot().on(DataPrivacyEvents.deny,(function(){showConfirmation(DataPrivacyEvents.deny,denyEventWsData(requestId))})),modal.getRoot().on(DataPrivacyEvents.complete,(function(){handleSave("tool_dataprivacy_mark_complete",{requestid:requestId})})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal.show()})).catch(Notification.exception)})),$(ACTIONS_APPROVE_REQUEST).click((function(e){e.preventDefault();var requestId=$(this).data("requestid");showConfirmation(DataPrivacyEvents.approve,approveEventWsData(requestId))})),$(ACTIONS_DENY_REQUEST).click((function(e){e.preventDefault();var requestId=$(this).data("requestid");showConfirmation(DataPrivacyEvents.deny,denyEventWsData(requestId))})),$(ACTIONS_MARK_COMPLETE).click((function(e){e.preventDefault();var requestId=$(this).data("requestid");showConfirmation(DataPrivacyEvents.complete,function(requestId){return{wsfunction:"tool_dataprivacy_mark_complete",wsparams:{requestid:requestId}}}(requestId))})),$(ACTIONS_CONFIRM_BULK_ACTION).click((function(){var requestIds=[],actionEvent="",wsdata={},bulkActionKeys=[{key:"selectbulkaction",component:"tool_dataprivacy"},{key:"selectdatarequests",component:"tool_dataprivacy"},{key:"ok"}],bulkaction=parseInt($("#bulk-action").val());if(bulkaction==BULK_ACTIONS_APPROVE||bulkaction==BULK_ACTIONS_DENY)if($(".selectrequests:checked").each((function(){requestIds.push($(this).val())})),requestIds.length<1)Str.get_strings(bulkActionKeys).done((function(langStrings){Notification.alert("",langStrings[1],langStrings[2])})).fail(Notification.exception);else{switch(bulkaction){case BULK_ACTIONS_APPROVE:actionEvent=DataPrivacyEvents.bulkApprove,wsdata=function(requestIds){return{wsfunction:"tool_dataprivacy_bulk_approve_data_requests",wsparams:{requestids:requestIds}}}(requestIds);break;case BULK_ACTIONS_DENY:actionEvent=DataPrivacyEvents.bulkDeny,wsdata=function(requestIds){return{wsfunction:"tool_dataprivacy_bulk_deny_data_requests",wsparams:{requestids:requestIds}}}(requestIds)}showConfirmation(actionEvent,wsdata)}else Str.get_strings(bulkActionKeys).done((function(langStrings){Notification.alert("",langStrings[0],langStrings[2])})).fail(Notification.exception)})),$(ACTIONS_SELECT_ALL).change((function(e){e.preventDefault();var selectAll=$(this).is(":checked");$(SELECTORS_SELECT_REQUEST).prop("checked",selectAll)}))},RequestActions})); + +//# sourceMappingURL=requestactions.min.js.map \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/requestactions.min.js.map b/admin/tool/dataprivacy/amd/build/requestactions.min.js.map index f88c1fdcd2c..4d822b3e809 100644 --- a/admin/tool/dataprivacy/amd/build/requestactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/requestactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/requestactions.js"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ModalDataRequest","DataPrivacyEvents","ACTIONS","APPROVE_REQUEST","DENY_REQUEST","VIEW_REQUEST","MARK_COMPLETE","CHANGE_BULK_ACTION","CONFIRM_BULK_ACTION","SELECT_ALL","BULK_ACTIONS","APPROVE","DENY","SELECTORS","SELECT_REQUEST","RequestActions","registerEvents","prototype","click","e","preventDefault","requestId","data","promises","call","methodname","args","when","then","result","addNotification","message","warnings","type","body","render","templateContext","approvedeny","canmarkcomplete","create","title","typename","TYPE","large","modal","getRoot","on","approve","showConfirmation","approveEventWsData","deny","denyEventWsData","complete","handleSave","hidden","destroy","show","catch","exception","completeEventWsData","requestIds","actionEvent","wsdata","bulkActionKeys","key","component","bulkaction","parseInt","val","get_strings","done","langStrings","alert","fail","each","push","length","bulkApprove","bulkApproveEventWsData","bulkDeny","bulkDenyEventWsData","change","selectAll","is","prop","action","keys","modalTitle","confirmMessage","types","SAVE_CANCEL","setSaveButtonText","save","wsfunction","wsparams","params","window","location","reload"],"mappings":"AAsBAA,OAAM,mCAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,oBALG,CAMH,mBANG,CAOH,gBAPG,CAQH,qCARG,CASH,yBATG,CAAD,CAUN,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAAqCC,CAArC,CAAmDC,CAAnD,CAAgEC,CAAhE,CAA2EC,CAA3E,CAA6FC,CAA7F,CAAgH,IAaxGC,CAAAA,CAAO,CAAG,CACVC,eAAe,CAAE,2BADP,CAEVC,YAAY,CAAE,wBAFJ,CAGVC,YAAY,CAAE,wBAHJ,CAIVC,aAAa,CAAE,4BAJL,CAKVC,kBAAkB,CAAE,sBALV,CAMVC,mBAAmB,CAAE,8BANX,CAOVC,UAAU,CAAE,6BAPF,CAb8F,CA6BxGC,CAAY,CAAG,CACfC,OAAO,CAAE,CADM,CAEfC,IAAI,CAAE,CAFS,CA7ByF,CAuCxGC,CAAS,CAAG,CACZC,cAAc,CAAE,iBADJ,CAvC4F,CA8CxGC,CAAc,CAAG,UAAW,CAC5B,KAAKC,cAAL,EACH,CAhD2G,CAqD5GD,CAAc,CAACE,SAAf,CAAyBD,cAAzB,CAA0C,UAAW,CACjDvB,CAAC,CAACS,CAAO,CAACG,YAAT,CAAD,CAAwBa,KAAxB,CAA8B,SAASC,CAAT,CAAY,CACtCA,CAAC,CAACC,cAAF,GADsC,GAGlCC,CAAAA,CAAS,CAAG5B,CAAC,CAAC,IAAD,CAAD,CAAQ6B,IAAR,CAAa,WAAb,CAHsB,CAelCC,CAAQ,CAAG7B,CAAI,CAAC8B,IAAL,CAAU,CALX,CACVC,UAAU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AAgBC,MAAhB,EACH,CAJD,IAIO,CAEHvG,CAAY,CAACmC,eAAb,CAA6B,CACzBC,OAAO,CAAET,CAAI,CAACU,QAAL,CAAc,CAAd,EAAiBD,OADD,CAEzBE,IAAI,CAAE,OAFmB,CAA7B,CAIH,CACJ,CAZD,EAYGwC,IAZH,CAYQ9E,CAAY,CAAC+D,SAZrB,CAaH,CAED,MAAO3C,CAAAA,CACV,CAjaK,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 * Request actions.\n *\n * @module tool_dataprivacy/requestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates',\n 'tool_dataprivacy/data_request_modal',\n 'tool_dataprivacy/events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, ModalDataRequest, DataPrivacyEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{APPROVE_REQUEST: string}}\n * @type {{DENY_REQUEST: string}}\n * @type {{VIEW_REQUEST: string}}\n * @type {{MARK_COMPLETE: string}}\n * @type {{CHANGE_BULK_ACTION: string}}\n * @type {{CONFIRM_BULK_ACTION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n APPROVE_REQUEST: '[data-action=\"approve\"]',\n DENY_REQUEST: '[data-action=\"deny\"]',\n VIEW_REQUEST: '[data-action=\"view\"]',\n MARK_COMPLETE: '[data-action=\"complete\"]',\n CHANGE_BULK_ACTION: '[id=\"bulk-action\"]',\n CONFIRM_BULK_ACTION: '[id=\"confirm-bulk-action\"]',\n SELECT_ALL: '[data-action=\"selectall\"]'\n };\n\n /**\n * List of available bulk actions.\n *\n * @type {{APPROVE: number}}\n * @type {{DENY: number}}\n */\n var BULK_ACTIONS = {\n APPROVE: 1,\n DENY: 2\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECT_REQUEST: string}}\n */\n var SELECTORS = {\n SELECT_REQUEST: '.selectrequests'\n };\n\n /**\n * RequestActions class.\n */\n var RequestActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n RequestActions.prototype.registerEvents = function() {\n $(ACTIONS.VIEW_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n\n // Cancel the request.\n var params = {\n 'requestid': requestId\n };\n\n var request = {\n methodname: 'tool_dataprivacy_get_data_request',\n args: params\n };\n\n var promises = Ajax.call([request]);\n $.when(promises[0]).then(function(data) {\n if (data.result) {\n return data.result;\n }\n // Fail.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n return false;\n\n }).then(function(data) {\n var body = Templates.render('tool_dataprivacy/request_details', data);\n var templateContext = {\n approvedeny: data.approvedeny,\n canmarkcomplete: data.canmarkcomplete\n };\n return ModalFactory.create({\n title: data.typename,\n body: body,\n type: ModalDataRequest.TYPE,\n large: true,\n templateContext: templateContext\n });\n\n }).then(function(modal) {\n // Handle approve event.\n modal.getRoot().on(DataPrivacyEvents.approve, function() {\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n // Handle deny event.\n modal.getRoot().on(DataPrivacyEvents.deny, function() {\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n // Handle send event.\n modal.getRoot().on(DataPrivacyEvents.complete, function() {\n var params = {\n 'requestid': requestId\n };\n handleSave('tool_dataprivacy_mark_complete', params);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n // Show the modal!\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.APPROVE_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n $(ACTIONS.DENY_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n $(ACTIONS.MARK_COMPLETE).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.complete, completeEventWsData(requestId));\n });\n\n $(ACTIONS.CONFIRM_BULK_ACTION).click(function() {\n var requestIds = [];\n var actionEvent = '';\n var wsdata = {};\n var bulkActionKeys = [\n {\n key: 'selectbulkaction',\n component: 'tool_dataprivacy'\n },\n {\n key: 'selectdatarequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'ok'\n }\n ];\n\n var bulkaction = parseInt($('#bulk-action').val());\n\n if (bulkaction != BULK_ACTIONS.APPROVE && bulkaction != BULK_ACTIONS.DENY) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[0], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n $(\".selectrequests:checked\").each(function() {\n requestIds.push($(this).val());\n });\n\n if (requestIds.length < 1) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[1], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n switch (bulkaction) {\n case BULK_ACTIONS.APPROVE:\n actionEvent = DataPrivacyEvents.bulkApprove;\n wsdata = bulkApproveEventWsData(requestIds);\n break;\n case BULK_ACTIONS.DENY:\n actionEvent = DataPrivacyEvents.bulkDeny;\n wsdata = bulkDenyEventWsData(requestIds);\n }\n\n showConfirmation(actionEvent, wsdata);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectAll = $(this).is(':checked');\n $(SELECTORS.SELECT_REQUEST).prop('checked', selectAll);\n });\n };\n\n /**\n * Return the webservice data for the approve request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function approveEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_approve_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk approve request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkApproveEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_approve_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the deny request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function denyEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_deny_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk deny request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkDenyEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_deny_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the complete request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function completeEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_mark_complete',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {String} action The action name.\n * @param {Object} wsdata Object containing ws data.\n */\n function showConfirmation(action, wsdata) {\n var keys = [];\n\n switch (action) {\n case DataPrivacyEvents.approve:\n keys = [\n {\n key: 'approverequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkApprove:\n keys = [\n {\n key: 'bulkapproverequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.deny:\n keys = [\n {\n key: 'denyrequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkDeny:\n keys = [\n {\n key: 'bulkdenyrequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.complete:\n keys = [\n {\n key: 'markcomplete',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmcompletion',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n }\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n handleSave(wsdata.wsfunction, wsdata.wsparams);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a web service function and reloads the page on success and shows a notification.\n * Displays an error notification, otherwise.\n *\n * @param {String} wsfunction The web service function to call.\n * @param {Object} params The parameters for the web service functoon.\n */\n function handleSave(wsfunction, params) {\n // Confirm the request.\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n // On success, reload the page so that the data request table will be updated.\n // TODO: Probably in the future, better to reload the table or the target data request via AJAX.\n window.location.reload();\n } else {\n // Add the notification.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n }\n\n return RequestActions;\n});\n"],"file":"requestactions.min.js"} \ No newline at end of file +{"version":3,"file":"requestactions.min.js","sources":["../src/requestactions.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 * Request actions.\n *\n * @module tool_dataprivacy/requestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates',\n 'tool_dataprivacy/data_request_modal',\n 'tool_dataprivacy/events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, ModalDataRequest, DataPrivacyEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{APPROVE_REQUEST: string}}\n * @type {{DENY_REQUEST: string}}\n * @type {{VIEW_REQUEST: string}}\n * @type {{MARK_COMPLETE: string}}\n * @type {{CHANGE_BULK_ACTION: string}}\n * @type {{CONFIRM_BULK_ACTION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n APPROVE_REQUEST: '[data-action=\"approve\"]',\n DENY_REQUEST: '[data-action=\"deny\"]',\n VIEW_REQUEST: '[data-action=\"view\"]',\n MARK_COMPLETE: '[data-action=\"complete\"]',\n CHANGE_BULK_ACTION: '[id=\"bulk-action\"]',\n CONFIRM_BULK_ACTION: '[id=\"confirm-bulk-action\"]',\n SELECT_ALL: '[data-action=\"selectall\"]'\n };\n\n /**\n * List of available bulk actions.\n *\n * @type {{APPROVE: number}}\n * @type {{DENY: number}}\n */\n var BULK_ACTIONS = {\n APPROVE: 1,\n DENY: 2\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECT_REQUEST: string}}\n */\n var SELECTORS = {\n SELECT_REQUEST: '.selectrequests'\n };\n\n /**\n * RequestActions class.\n */\n var RequestActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n RequestActions.prototype.registerEvents = function() {\n $(ACTIONS.VIEW_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n\n // Cancel the request.\n var params = {\n 'requestid': requestId\n };\n\n var request = {\n methodname: 'tool_dataprivacy_get_data_request',\n args: params\n };\n\n var promises = Ajax.call([request]);\n $.when(promises[0]).then(function(data) {\n if (data.result) {\n return data.result;\n }\n // Fail.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n return false;\n\n }).then(function(data) {\n var body = Templates.render('tool_dataprivacy/request_details', data);\n var templateContext = {\n approvedeny: data.approvedeny,\n canmarkcomplete: data.canmarkcomplete\n };\n return ModalFactory.create({\n title: data.typename,\n body: body,\n type: ModalDataRequest.TYPE,\n large: true,\n templateContext: templateContext\n });\n\n }).then(function(modal) {\n // Handle approve event.\n modal.getRoot().on(DataPrivacyEvents.approve, function() {\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n // Handle deny event.\n modal.getRoot().on(DataPrivacyEvents.deny, function() {\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n // Handle send event.\n modal.getRoot().on(DataPrivacyEvents.complete, function() {\n var params = {\n 'requestid': requestId\n };\n handleSave('tool_dataprivacy_mark_complete', params);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n // Show the modal!\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.APPROVE_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n $(ACTIONS.DENY_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n $(ACTIONS.MARK_COMPLETE).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.complete, completeEventWsData(requestId));\n });\n\n $(ACTIONS.CONFIRM_BULK_ACTION).click(function() {\n var requestIds = [];\n var actionEvent = '';\n var wsdata = {};\n var bulkActionKeys = [\n {\n key: 'selectbulkaction',\n component: 'tool_dataprivacy'\n },\n {\n key: 'selectdatarequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'ok'\n }\n ];\n\n var bulkaction = parseInt($('#bulk-action').val());\n\n if (bulkaction != BULK_ACTIONS.APPROVE && bulkaction != BULK_ACTIONS.DENY) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[0], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n $(\".selectrequests:checked\").each(function() {\n requestIds.push($(this).val());\n });\n\n if (requestIds.length < 1) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[1], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n switch (bulkaction) {\n case BULK_ACTIONS.APPROVE:\n actionEvent = DataPrivacyEvents.bulkApprove;\n wsdata = bulkApproveEventWsData(requestIds);\n break;\n case BULK_ACTIONS.DENY:\n actionEvent = DataPrivacyEvents.bulkDeny;\n wsdata = bulkDenyEventWsData(requestIds);\n }\n\n showConfirmation(actionEvent, wsdata);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectAll = $(this).is(':checked');\n $(SELECTORS.SELECT_REQUEST).prop('checked', selectAll);\n });\n };\n\n /**\n * Return the webservice data for the approve request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function approveEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_approve_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk approve request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkApproveEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_approve_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the deny request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function denyEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_deny_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk deny request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkDenyEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_deny_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the complete request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function completeEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_mark_complete',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {String} action The action name.\n * @param {Object} wsdata Object containing ws data.\n */\n function showConfirmation(action, wsdata) {\n var keys = [];\n\n switch (action) {\n case DataPrivacyEvents.approve:\n keys = [\n {\n key: 'approverequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkApprove:\n keys = [\n {\n key: 'bulkapproverequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.deny:\n keys = [\n {\n key: 'denyrequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkDeny:\n keys = [\n {\n key: 'bulkdenyrequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.complete:\n keys = [\n {\n key: 'markcomplete',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmcompletion',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n }\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n handleSave(wsdata.wsfunction, wsdata.wsparams);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a web service function and reloads the page on success and shows a notification.\n * Displays an error notification, otherwise.\n *\n * @param {String} wsfunction The web service function to call.\n * @param {Object} params The parameters for the web service functoon.\n */\n function handleSave(wsfunction, params) {\n // Confirm the request.\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n // On success, reload the page so that the data request table will be updated.\n // TODO: Probably in the future, better to reload the table or the target data request via AJAX.\n window.location.reload();\n } else {\n // Add the notification.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n }\n\n return RequestActions;\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ModalDataRequest","DataPrivacyEvents","ACTIONS","BULK_ACTIONS","SELECTORS","RequestActions","registerEvents","approveEventWsData","requestId","denyEventWsData","showConfirmation","action","wsdata","keys","approve","key","component","bulkApprove","deny","bulkDeny","complete","modalTitle","get_strings","then","langStrings","confirmMessage","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","handleSave","wsfunction","wsparams","hidden","destroy","show","catch","exception","params","request","methodname","args","call","done","data","result","window","location","reload","addNotification","message","warnings","fail","prototype","click","e","preventDefault","this","promises","when","render","templateContext","approvedeny","canmarkcomplete","typename","TYPE","large","completeEventWsData","requestIds","actionEvent","bulkActionKeys","bulkaction","parseInt","val","each","push","length","alert","bulkApproveEventWsData","bulkDenyEventWsData","change","selectAll","is","prop"],"mappings":";;;;;;;AAsBAA,yCAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,oBACA,iBACA,sCACA,4BACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,YAAaC,UAAWC,iBAAkBC,uBAarFC,wBACiB,0BADjBA,qBAEc,uBAFdA,qBAGc,uBAHdA,sBAIe,2BAJfA,4BAMqB,6BANrBA,mBAOY,4BASZC,qBACS,EADTA,kBAEM,EAQNC,yBACgB,kBAMhBC,eAAiB,gBACZC,2BAyKAC,mBAAmBC,iBACjB,YACW,iDACF,WAAcA,qBAuBzBC,gBAAgBD,iBACd,YACW,8CACF,WAAcA,qBAoCzBE,iBAAiBC,OAAQC,YAC1BC,KAAO,UAEHF,aACCV,kBAAkBa,QACnBD,KAAO,CACH,CACIE,IAAK,iBACLC,UAAW,oBAEf,CACID,IAAK,kBACLC,UAAW,gCAIlBf,kBAAkBgB,YACnBJ,KAAO,CACH,CACIE,IAAK,sBACLC,UAAW,oBAEf,CACID,IAAK,sBACLC,UAAW,gCAIlBf,kBAAkBiB,KACnBL,KAAO,CACH,CACIE,IAAK,cACLC,UAAW,oBAEf,CACID,IAAK,gBACLC,UAAW,gCAIlBf,kBAAkBkB,SACnBN,KAAO,CACH,CACIE,IAAK,mBACLC,UAAW,oBAEf,CACID,IAAK,oBACLC,UAAW,gCAIlBf,kBAAkBmB,SACnBP,KAAO,CACH,CACIE,IAAK,eACLC,UAAW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gB,UAGxBL,WAAWQ,OAAS,EACpBvF,IAAI0B,YAAYuD,gBAAgB3B,MAAK,SAAS1B,aAC1C7B,aAAayF,MAAM,GAAI5D,YAAY,GAAIA,YAAY,OACpDmC,KAAKhE,aAAaiD,uBAKjBkC,iBACC3E,qBACDyE,YAAc3E,kBAAkBgB,YAChCL,gBAqCgB+D,kBACrB,YACW,uDACF,YAAeA,aAxCVU,CAAuBV,uBAE/BxE,kBACDyE,YAAc3E,kBAAkBkB,SAChCP,gBA2Da+D,kBAClB,YACW,oDACF,YAAeA,aA9DVW,CAAoBX,YAGrCjE,iBAAiBkE,YAAahE,aA7B1BhB,IAAI0B,YAAYuD,gBAAgB3B,MAAK,SAAS1B,aAC1C7B,aAAayF,MAAM,GAAI5D,YAAY,GAAIA,YAAY,OACpDmC,KAAKhE,aAAaiD,cA8B7BnD,EAAES,oBAAoBqF,QAAO,SAASzB,GAClCA,EAAEC,qBAEEyB,UAAY/F,EAAEuE,MAAMyB,GAAG,YAC3BhG,EAAEW,0BAA0BsF,KAAK,UAAWF,eAwM7CnF"} \ No newline at end of file diff --git a/admin/tool/langimport/amd/build/search.min.js b/admin/tool/langimport/amd/build/search.min.js index 9f2b1aacce2..d3313c3c3bd 100644 --- a/admin/tool/langimport/amd/build/search.min.js +++ b/admin/tool/langimport/amd/build/search.min.js @@ -1,2 +1,10 @@ -define ("tool_langimport/search",["exports","core/pending","core/utils"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);function d(a,b){return j(a)||h(a,b)||f(a,b)||e()}function e(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(a,b){if(!a)return;if("string"==typeof a)return g(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return g(a,b)}function g(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_pending=(obj=_pending)&&obj.__esModule?obj:{default:obj};const SELECTORS_AVAILABLE_LANG_SELECT="select",SELECTORS_AVAILABLE_LANG_SEARCH='[data-action="search"]';var _default={init:form=>{const availableLangsElement=form.querySelector(SELECTORS_AVAILABLE_LANG_SELECT),availableLangsFilter=event=>{const pendingPromise=new _pending.default("tool_langimport/search:filter");availableLangsElement.querySelectorAll("option").forEach((option=>{option.remove()}));const searchTerm=event.target.value.toLowerCase(),availableLanguages=JSON.parse(availableLangsElement.dataset.availableLanguages),filteredLanguages=Object.keys(availableLanguages).reduce(((matches,langcode)=>(availableLanguages[langcode].toLowerCase().includes(searchTerm)&&(matches[langcode]=availableLanguages[langcode]),matches)),[]);Object.entries(filteredLanguages).forEach((_ref=>{let[langcode,langname]=_ref;const option=document.createElement("option");option.value=langcode,option.innerText=langname,availableLangsElement.append(option)})),pendingPromise.resolve()},availableLanguages={};availableLangsElement.querySelectorAll("option").forEach((option=>{availableLanguages[option.value]=option.text})),availableLangsElement.dataset.availableLanguages=JSON.stringify(availableLanguages);const availableLangsSearch=form.querySelector(SELECTORS_AVAILABLE_LANG_SEARCH);availableLangsSearch.addEventListener("keydown",(event=>{"Enter"===event.key&&event.preventDefault()})),availableLangsSearch.addEventListener("keyup",(event=>{const pendingPromise=new _pending.default("tool_langimport/search:keyup");(0,_utils.debounce)(availableLangsFilter,250)(event),setTimeout((()=>{pendingPromise.resolve()}),250)}))}};return _exports.default=_default,_exports.default})); + +//# sourceMappingURL=search.min.js.map \ No newline at end of file diff --git a/admin/tool/langimport/amd/build/search.min.js.map b/admin/tool/langimport/amd/build/search.min.js.map index 638ecd66d01..04116ba2df7 100644 --- a/admin/tool/langimport/amd/build/search.min.js.map +++ b/admin/tool/langimport/amd/build/search.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/search.js"],"names":["SELECTORS","AVAILABLE_LANG_SELECT","AVAILABLE_LANG_SEARCH","DEBOUNCE_TIMER","init","form","availableLangsElement","querySelector","availableLangsFilter","event","pendingPromise","Pending","querySelectorAll","forEach","option","remove","searchTerm","target","value","toLowerCase","availableLanguages","JSON","parse","dataset","filteredLanguages","Object","keys","reduce","matches","langcode","includes","entries","langname","document","createElement","innerText","append","resolve","text","stringify","availableLangsSearch","addEventListener","key","preventDefault","setTimeout"],"mappings":"wKAuBA,uD,+9BAGMA,CAAAA,CAAS,CAAG,CACdC,qBAAqB,CAAE,QADT,CAEdC,qBAAqB,CAAE,0BAFT,C,CAKZC,CAAc,CAAG,G,WAiER,CACXC,IAAI,CA3DK,QAAPA,CAAAA,IAAO,CAACC,CAAD,CAAU,IACbC,CAAAA,CAAqB,CAAGD,CAAI,CAACE,aAAL,CAAmBP,CAAS,CAACC,qBAA7B,CADX,CAGbO,CAAoB,CAAG,SAACC,CAAD,CAAW,CACpC,GAAMC,CAAAA,CAAc,CAAG,GAAIC,UAAJ,CAAY,+BAAZ,CAAvB,CAGAL,CAAqB,CAACM,gBAAtB,CAAuC,QAAvC,EAAiDC,OAAjD,CAAyD,SAACC,CAAD,CAAY,CACjEA,CAAM,CAACC,MAAP,EACH,CAFD,EAJoC,GAS9BC,CAAAA,CAAU,CAAGP,CAAK,CAACQ,MAAN,CAAaC,KAAb,CAAmBC,WAAnB,EATiB,CAU9BC,CAAkB,CAAGC,IAAI,CAACC,KAAL,CAAWhB,CAAqB,CAACiB,OAAtB,CAA8BH,kBAAzC,CAVS,CAW9BI,CAAiB,CAAGC,MAAM,CAACC,IAAP,CAAYN,CAAZ,EAAgCO,MAAhC,CAAuC,SAACC,CAAD,CAAUC,CAAV,CAAuB,CACpF,GAAIT,CAAkB,CAACS,CAAD,CAAlB,CAA6BV,WAA7B,GAA2CW,QAA3C,CAAoDd,CAApD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UAAM,CACblC,CAAc,CAAC2B,OAAf,EACH,CAFS,CAEPlC,CAFO,CAGb,CAPD,CAQH,CAEc,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 .\n\n/**\n * Add search filtering of available language packs\n *\n * @module tool_langimport/search\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\nimport {debounce} from 'core/utils';\n\nconst SELECTORS = {\n AVAILABLE_LANG_SELECT: 'select',\n AVAILABLE_LANG_SEARCH: '[data-action=\"search\"]',\n};\n\nconst DEBOUNCE_TIMER = 250;\n\n/**\n * Initialize module\n *\n * @param {Element} form\n */\nconst init = (form) => {\n const availableLangsElement = form.querySelector(SELECTORS.AVAILABLE_LANG_SELECT);\n\n const availableLangsFilter = (event) => {\n const pendingPromise = new Pending('tool_langimport/search:filter');\n\n // Remove existing options.\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n option.remove();\n });\n\n // Filter for matching languages.\n const searchTerm = event.target.value.toLowerCase();\n const availableLanguages = JSON.parse(availableLangsElement.dataset.availableLanguages);\n const filteredLanguages = Object.keys(availableLanguages).reduce((matches, langcode) => {\n if (availableLanguages[langcode].toLowerCase().includes(searchTerm)) {\n matches[langcode] = availableLanguages[langcode];\n }\n return matches;\n }, []);\n\n // Re-create filtered options.\n Object.entries(filteredLanguages).forEach(([langcode, langname]) => {\n const option = document.createElement('option');\n option.value = langcode;\n option.innerText = langname;\n availableLangsElement.append(option);\n });\n\n pendingPromise.resolve();\n };\n\n // Cache initial available language options.\n const availableLanguages = {};\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n availableLanguages[option.value] = option.text;\n });\n availableLangsElement.dataset.availableLanguages = JSON.stringify(availableLanguages);\n\n // Register event listeners on the search element.\n const availableLangsSearch = form.querySelector(SELECTORS.AVAILABLE_LANG_SEARCH);\n availableLangsSearch.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n }\n });\n\n // Debounce the event listener to allow the user to finish typing.\n availableLangsSearch.addEventListener('keyup', (event) => {\n const pendingPromise = new Pending('tool_langimport/search:keyup');\n\n debounce(availableLangsFilter, DEBOUNCE_TIMER)(event);\n setTimeout(() => {\n pendingPromise.resolve();\n }, DEBOUNCE_TIMER);\n });\n};\n\nexport default {\n init: init,\n};\n"],"file":"search.min.js"} \ No newline at end of file +{"version":3,"file":"search.min.js","sources":["../src/search.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 * Add search filtering of available language packs\n *\n * @module tool_langimport/search\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\nimport {debounce} from 'core/utils';\n\nconst SELECTORS = {\n AVAILABLE_LANG_SELECT: 'select',\n AVAILABLE_LANG_SEARCH: '[data-action=\"search\"]',\n};\n\nconst DEBOUNCE_TIMER = 250;\n\n/**\n * Initialize module\n *\n * @param {Element} form\n */\nconst init = (form) => {\n const availableLangsElement = form.querySelector(SELECTORS.AVAILABLE_LANG_SELECT);\n\n const availableLangsFilter = (event) => {\n const pendingPromise = new Pending('tool_langimport/search:filter');\n\n // Remove existing options.\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n option.remove();\n });\n\n // Filter for matching languages.\n const searchTerm = event.target.value.toLowerCase();\n const availableLanguages = JSON.parse(availableLangsElement.dataset.availableLanguages);\n const filteredLanguages = Object.keys(availableLanguages).reduce((matches, langcode) => {\n if (availableLanguages[langcode].toLowerCase().includes(searchTerm)) {\n matches[langcode] = availableLanguages[langcode];\n }\n return matches;\n }, []);\n\n // Re-create filtered options.\n Object.entries(filteredLanguages).forEach(([langcode, langname]) => {\n const option = document.createElement('option');\n option.value = langcode;\n option.innerText = langname;\n availableLangsElement.append(option);\n });\n\n pendingPromise.resolve();\n };\n\n // Cache initial available language options.\n const availableLanguages = {};\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n availableLanguages[option.value] = option.text;\n });\n availableLangsElement.dataset.availableLanguages = JSON.stringify(availableLanguages);\n\n // Register event listeners on the search element.\n const availableLangsSearch = form.querySelector(SELECTORS.AVAILABLE_LANG_SEARCH);\n availableLangsSearch.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n }\n });\n\n // Debounce the event listener to allow the user to finish typing.\n availableLangsSearch.addEventListener('keyup', (event) => {\n const pendingPromise = new Pending('tool_langimport/search:keyup');\n\n debounce(availableLangsFilter, DEBOUNCE_TIMER)(event);\n setTimeout(() => {\n pendingPromise.resolve();\n }, DEBOUNCE_TIMER);\n });\n};\n\nexport default {\n init: init,\n};\n"],"names":["SELECTORS","init","form","availableLangsElement","querySelector","availableLangsFilter","event","pendingPromise","Pending","querySelectorAll","forEach","option","remove","searchTerm","target","value","toLowerCase","availableLanguages","JSON","parse","dataset","filteredLanguages","Object","keys","reduce","matches","langcode","includes","entries","_ref","langname","document","createElement","innerText","append","resolve","text","stringify","availableLangsSearch","addEventListener","key","preventDefault","setTimeout"],"mappings":";;;;;;;qJA0BMA,gCACqB,SADrBA,gCAEqB,sCAoEZ,CACXC,KA3DUC,aACJC,sBAAwBD,KAAKE,cAAcJ,iCAE3CK,qBAAwBC,cACpBC,eAAiB,IAAIC,iBAAQ,iCAGnCL,sBAAsBM,iBAAiB,UAAUC,SAASC,SACtDA,OAAOC,kBAILC,WAAaP,MAAMQ,OAAOC,MAAMC,cAChCC,mBAAqBC,KAAKC,MAAMhB,sBAAsBiB,QAAQH,oBAC9DI,kBAAoBC,OAAOC,KAAKN,oBAAoBO,QAAO,CAACC,QAASC,YACnET,mBAAmBS,UAAUV,cAAcW,SAASd,cACpDY,QAAQC,UAAYT,mBAAmBS,WAEpCD,UACR,IAGHH,OAAOM,QAAQP,mBAAmBX,SAAQmB,WAAEH,SAAUI,qBAC5CnB,OAASoB,SAASC,cAAc,UACtCrB,OAAOI,MAAQW,SACff,OAAOsB,UAAYH,SACnB3B,sBAAsB+B,OAAOvB,WAGjCJ,eAAe4B,WAIblB,mBAAqB,GAC3Bd,sBAAsBM,iBAAiB,UAAUC,SAASC,SACtDM,mBAAmBN,OAAOI,OAASJ,OAAOyB,QAE9CjC,sBAAsBiB,QAAQH,mBAAqBC,KAAKmB,UAAUpB,0BAG5DqB,qBAAuBpC,KAAKE,cAAcJ,iCAChDsC,qBAAqBC,iBAAiB,WAAYjC,QAC5B,UAAdA,MAAMkC,KACNlC,MAAMmC,oBAKdH,qBAAqBC,iBAAiB,SAAUjC,cACtCC,eAAiB,IAAIC,iBAAQ,oDAE1BH,qBA1DM,KA0DgCC,OAC/CoC,YAAW,KACPnC,eAAe4B,YA5DJ"} \ No newline at end of file diff --git a/admin/tool/licensemanager/amd/build/delete_license.min.js b/admin/tool/licensemanager/amd/build/delete_license.min.js index 17dd2af256b..d9177e477f4 100644 --- a/admin/tool/licensemanager/amd/build/delete_license.min.js +++ b/admin/tool/licensemanager/amd/build/delete_license.min.js @@ -1,2 +1,10 @@ -define ("tool_licensemanager/delete_license",["jquery","core/modal_factory","core/modal_events","core/url","core/str"],function(a,b,c,d,e){var f=a(".delete-license");b.create({type:b.types.SAVE_CANCEL,title:e.get_string("deletelicense","tool_licensemanager"),body:e.get_string("deletelicenseconfirmmessage","tool_licensemanager"),preShowCallback:function preShowCallback(b,c){b=a(b);var e={action:"delete",license:b.data("license")};c.deleteURL=d.relativeUrl("/admin/tool/licensemanager/index.php",e,!0)},large:!0},f).done(function(a){a.getRoot().on(c.save,function(b){b.preventDefault();window.location.href=a.deleteURL})})}); -//# sourceMappingURL=delete_license.min.js.map +/** + * Modal for confirming deletion of a custom license. + * + * @module tool_licensemanager/delete_license + * @copyright 2019 Tom Dickman + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_licensemanager/delete_license",["jquery","core/modal_factory","core/modal_events","core/url","core/str"],(function($,ModalFactory,ModalEvents,Url,String){var trigger=$(".delete-license");ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL,title:String.get_string("deletelicense","tool_licensemanager"),body:String.get_string("deletelicenseconfirmmessage","tool_licensemanager"),preShowCallback:function(triggerElement,modal){let params={action:"delete",license:(triggerElement=$(triggerElement)).data("license")};modal.deleteURL=Url.relativeUrl("/admin/tool/licensemanager/index.php",params,!0)},large:!0},trigger).done((function(modal){modal.getRoot().on(ModalEvents.save,(function(e){e.preventDefault(),window.location.href=modal.deleteURL}))}))})); + +//# sourceMappingURL=delete_license.min.js.map \ No newline at end of file diff --git a/admin/tool/licensemanager/amd/build/delete_license.min.js.map b/admin/tool/licensemanager/amd/build/delete_license.min.js.map index ca10f407e80..71785b2bf5c 100644 --- a/admin/tool/licensemanager/amd/build/delete_license.min.js.map +++ b/admin/tool/licensemanager/amd/build/delete_license.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/delete_license.js"],"names":["define","$","ModalFactory","ModalEvents","Url","String","trigger","create","type","types","SAVE_CANCEL","title","get_string","body","preShowCallback","triggerElement","modal","params","data","deleteURL","relativeUrl","large","done","getRoot","on","save","e","preventDefault","window","location","href"],"mappings":"AAsBAA,OAAM,sCAAC,CAAC,QAAD,CAAW,oBAAX,CAAiC,mBAAjC,CAAsD,UAAtD,CAAkE,UAAlE,CAAD,CACF,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAuCC,CAAvC,CAA4CC,CAA5C,CAAoD,CAEhD,GAAIC,CAAAA,CAAO,CAAGL,CAAC,CAAC,iBAAD,CAAf,CACAC,CAAY,CAACK,MAAb,CAAoB,CAChBC,IAAI,CAAEN,CAAY,CAACO,KAAb,CAAmBC,WADT,CAEhBC,KAAK,CAAEN,CAAM,CAACO,UAAP,CAAkB,eAAlB,CAAmC,qBAAnC,CAFS,CAGhBC,IAAI,CAAER,CAAM,CAACO,UAAP,CAAkB,6BAAlB,CAAiD,qBAAjD,CAHU,CAIhBE,eAAe,CAAE,yBAASC,CAAT,CAAyBC,CAAzB,CAAgC,CAC7CD,CAAc,CAAGd,CAAC,CAACc,CAAD,CAAlB,CACA,GAAIE,CAAAA,CAAM,CAAG,CACT,OAAU,QADD,CAET,QAAWF,CAAc,CAACG,IAAf,CAAoB,SAApB,CAFF,CAAb,CAIAF,CAAK,CAACG,SAAN,CAAkBf,CAAG,CAACgB,WAAJ,CAAgB,sCAAhB,CAAwDH,CAAxD,IACrB,CAXe,CAYhBI,KAAK,GAZW,CAApB,CAaGf,CAbH,EAcKgB,IAdL,CAcU,SAASN,CAAT,CAAgB,CAClBA,CAAK,CAACO,OAAN,GAAgBC,EAAhB,CAAmBrB,CAAW,CAACsB,IAA/B,CAAqC,SAASC,CAAT,CAAY,CAE7CA,CAAC,CAACC,cAAF,GAEAC,MAAM,CAACC,QAAP,CAAgBC,IAAhB,CAAuBd,CAAK,CAACG,SAChC,CALD,CAMH,CArBL,CAsBH,CA1BC,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 * Modal for confirming deletion of a custom license.\n *\n * @module tool_licensemanager/delete_license\n * @copyright 2019 Tom Dickman \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/modal_factory', 'core/modal_events', 'core/url', 'core/str'],\n function($, ModalFactory, ModalEvents, Url, String) {\n\n var trigger = $('.delete-license');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: String.get_string('deletelicense', 'tool_licensemanager'),\n body: String.get_string('deletelicenseconfirmmessage', 'tool_licensemanager'),\n preShowCallback: function(triggerElement, modal) {\n triggerElement = $(triggerElement);\n let params = {\n 'action': 'delete',\n 'license': triggerElement.data('license')\n };\n modal.deleteURL = Url.relativeUrl('/admin/tool/licensemanager/index.php', params, true);\n },\n large: true,\n }, trigger)\n .done(function(modal) {\n modal.getRoot().on(ModalEvents.save, function(e) {\n // Stop the default save button behaviour which is to close the modal.\n e.preventDefault();\n // Redirect to delete url.\n window.location.href = modal.deleteURL;\n });\n });\n });\n"],"file":"delete_license.min.js"} \ No newline at end of file +{"version":3,"file":"delete_license.min.js","sources":["../src/delete_license.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 * Modal for confirming deletion of a custom license.\n *\n * @module tool_licensemanager/delete_license\n * @copyright 2019 Tom Dickman \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/modal_factory', 'core/modal_events', 'core/url', 'core/str'],\n function($, ModalFactory, ModalEvents, Url, String) {\n\n var trigger = $('.delete-license');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: String.get_string('deletelicense', 'tool_licensemanager'),\n body: String.get_string('deletelicenseconfirmmessage', 'tool_licensemanager'),\n preShowCallback: function(triggerElement, modal) {\n triggerElement = $(triggerElement);\n let params = {\n 'action': 'delete',\n 'license': triggerElement.data('license')\n };\n modal.deleteURL = Url.relativeUrl('/admin/tool/licensemanager/index.php', params, true);\n },\n large: true,\n }, trigger)\n .done(function(modal) {\n modal.getRoot().on(ModalEvents.save, function(e) {\n // Stop the default save button behaviour which is to close the modal.\n e.preventDefault();\n // Redirect to delete url.\n window.location.href = modal.deleteURL;\n });\n });\n });\n"],"names":["define","$","ModalFactory","ModalEvents","Url","String","trigger","create","type","types","SAVE_CANCEL","title","get_string","body","preShowCallback","triggerElement","modal","params","data","deleteURL","relativeUrl","large","done","getRoot","on","save","e","preventDefault","window","location","href"],"mappings":";;;;;;;AAsBAA,4CAAO,CAAC,SAAU,qBAAsB,oBAAqB,WAAY,aACrE,SAASC,EAAGC,aAAcC,YAAaC,IAAKC,YAEpCC,QAAUL,EAAE,mBAChBC,aAAaK,OAAO,CAChBC,KAAMN,aAAaO,MAAMC,YACzBC,MAAON,OAAOO,WAAW,gBAAiB,uBAC1CC,KAAMR,OAAOO,WAAW,8BAA+B,uBACvDE,gBAAiB,SAASC,eAAgBC,WAElCC,OAAS,QACC,kBAFdF,eAAiBd,EAAEc,iBAGWG,KAAK,YAEnCF,MAAMG,UAAYf,IAAIgB,YAAY,uCAAwCH,QAAQ,IAEtFI,OAAO,GACRf,SACEgB,MAAK,SAASN,OACXA,MAAMO,UAAUC,GAAGrB,YAAYsB,MAAM,SAASC,GAE1CA,EAAEC,iBAEFC,OAAOC,SAASC,KAAOd,MAAMG"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/actionselector.min.js b/admin/tool/lp/amd/build/actionselector.min.js index b082d803853..86d4019f3a8 100644 --- a/admin/tool/lp/amd/build/actionselector.min.js +++ b/admin/tool/lp/amd/build/actionselector.min.js @@ -1,2 +1,14 @@ -define ("tool_lp/actionselector",["jquery","core/notification","core/ajax","core/templates","tool_lp/dialogue","tool_lp/event_base"],function(a,b,c,d,e,f){var g=function(a,b,c,d,e){var g=this;f.prototype.constructor.apply(this,[]);g._title=a;g._message=b;g._actions=c;g._confirm=d;g._cancel=e;g._selectedValue=null;g._reset()};g.prototype=Object.create(f.prototype);g.prototype._selectedValue=null;g.prototype._popup=null;g.prototype._title=null;g.prototype._message=null;g.prototype._actions=null;g.prototype._confirm=null;g.prototype._cancel=null;g.prototype._afterRender=function(){var b=this;b._find("[data-action=\"action-selector-confirm\"]").attr("disabled","disabled");b._find("[data-region=\"action-selector-radio-buttons\"]").change(function(){b._selectedValue=a("input[type='radio']:checked").val();b._find("[data-action=\"action-selector-confirm\"]").removeAttr("disabled");b._refresh.bind(b)});b._find("[data-action=\"action-selector-cancel\"]").click(function(a){a.preventDefault();b.close()});b._find("[data-action=\"action-selector-confirm\"]").click(function(a){a.preventDefault();if(!b._selectedValue.length){return}b._trigger("save",{action:b._selectedValue});b.close()})};g.prototype.close=function(){var a=this;a._popup.close();a._reset()};g.prototype.display=function(){var a=this;return a._render().then(function(b){a._popup=new e(a._title,b,a._afterRender.bind(a))}).fail(b.exception)};g.prototype._find=function(b){return a(this._popup.getContent()).find(b)};g.prototype._refresh=function(){var a=this;return a._render().then(function(b){a._find("[data-region=\"action-selector\"]").replaceWith(b);a._afterRender()})};g.prototype._render=function(){var a=this,b=[];for(var c in a._actions){b.push(a._actions[c])}var e={message:a._message,choices:b,confirm:a._confirm,cancel:a._cancel};return d.render("tool_lp/action_selector",e)};g.prototype._reset=function(){this._popup=null;this._selectedValue=""};return g}); -//# sourceMappingURL=actionselector.min.js.map +/** + * Action selector. + * + * To handle 'save' events use: actionselector.on('save') + * This will receive the information to display in popup. + * The actions have the format [{'text': sometext, 'value' : somevalue}]. + * + * @module tool_lp/actionselector + * @copyright 2016 Serge Gauthier - + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/actionselector",["jquery","core/notification","core/ajax","core/templates","tool_lp/dialogue","tool_lp/event_base"],(function($,Notification,Ajax,Templates,Dialogue,EventBase){var ActionSelector=function(title,message,actions,confirm,cancel){EventBase.prototype.constructor.apply(this,[]),this._title=title,this._message=message,this._actions=actions,this._confirm=confirm,this._cancel=cancel,this._selectedValue=null,this._reset()};return(ActionSelector.prototype=Object.create(EventBase.prototype))._selectedValue=null,ActionSelector.prototype._popup=null,ActionSelector.prototype._title=null,ActionSelector.prototype._message=null,ActionSelector.prototype._actions=null,ActionSelector.prototype._confirm=null,ActionSelector.prototype._cancel=null,ActionSelector.prototype._afterRender=function(){var self=this;self._find('[data-action="action-selector-confirm"]').attr("disabled","disabled"),self._find('[data-region="action-selector-radio-buttons"]').change((function(){self._selectedValue=$("input[type='radio']:checked").val(),self._find('[data-action="action-selector-confirm"]').removeAttr("disabled"),self._refresh.bind(self)})),self._find('[data-action="action-selector-cancel"]').click((function(e){e.preventDefault(),self.close()})),self._find('[data-action="action-selector-confirm"]').click((function(e){e.preventDefault(),self._selectedValue.length&&(self._trigger("save",{action:self._selectedValue}),self.close())}))},ActionSelector.prototype.close=function(){this._popup.close(),this._reset()},ActionSelector.prototype.display=function(){var self=this;return self._render().then((function(html){self._popup=new Dialogue(self._title,html,self._afterRender.bind(self))})).fail(Notification.exception)},ActionSelector.prototype._find=function(selector){return $(this._popup.getContent()).find(selector)},ActionSelector.prototype._refresh=function(){var self=this;return self._render().then((function(html){self._find('[data-region="action-selector"]').replaceWith(html),self._afterRender()}))},ActionSelector.prototype._render=function(){var choices=[];for(var i in this._actions)choices.push(this._actions[i]);var content={message:this._message,choices:choices,confirm:this._confirm,cancel:this._cancel};return Templates.render("tool_lp/action_selector",content)},ActionSelector.prototype._reset=function(){this._popup=null,this._selectedValue=""},ActionSelector})); + +//# sourceMappingURL=actionselector.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/actionselector.min.js.map b/admin/tool/lp/amd/build/actionselector.min.js.map index f114d9ad751..1061e04a7e2 100644 --- a/admin/tool/lp/amd/build/actionselector.min.js.map +++ b/admin/tool/lp/amd/build/actionselector.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/actionselector.js"],"names":["define","$","Notification","Ajax","Templates","Dialogue","EventBase","ActionSelector","title","message","actions","confirm","cancel","self","prototype","constructor","apply","_title","_message","_actions","_confirm","_cancel","_selectedValue","_reset","Object","create","_popup","_afterRender","_find","attr","change","val","removeAttr","_refresh","bind","click","e","preventDefault","close","length","_trigger","action","display","_render","then","html","fail","exception","selector","getContent","find","replaceWith","choices","i","push","content","render"],"mappings":"AA2BAA,OAAM,0BAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,kBAJD,CAKC,oBALD,CAAD,CAME,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAqDC,CAArD,CAAgE,CAYpE,GAAIC,CAAAA,CAAc,CAAG,SAASC,CAAT,CAAgBC,CAAhB,CAAyBC,CAAzB,CAAkCC,CAAlC,CAA2CC,CAA3C,CAAmD,CACpE,GAAIC,CAAAA,CAAI,CAAG,IAAX,CAEAP,CAAS,CAACQ,SAAV,CAAoBC,WAApB,CAAgCC,KAAhC,CAAsC,IAAtC,CAA4C,EAA5C,EACAH,CAAI,CAACI,MAAL,CAAcT,CAAd,CACAK,CAAI,CAACK,QAAL,CAAgBT,CAAhB,CACAI,CAAI,CAACM,QAAL,CAAgBT,CAAhB,CACAG,CAAI,CAACO,QAAL,CAAgBT,CAAhB,CACAE,CAAI,CAACQ,OAAL,CAAeT,CAAf,CACAC,CAAI,CAACS,cAAL,CAAsB,IAAtB,CACAT,CAAI,CAACU,MA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,CAKV,CAPD,CAeApB,CAAc,CAACO,SAAf,CAAyB6B,OAAzB,CAAmC,UAAW,IACtC9B,CAAAA,CAAI,CAAG,IAD+B,CAEtCuC,CAAO,CAAG,EAF4B,CAG1C,IAAK,GAAIC,CAAAA,CAAT,GAAcxC,CAAAA,CAAI,CAACM,QAAnB,CAA6B,CACzBiC,CAAO,CAACE,IAAR,CAAazC,CAAI,CAACM,QAAL,CAAckC,CAAd,CAAb,CACH,CACD,GAAIE,CAAAA,CAAO,CAAG,CAAC,QAAW1C,CAAI,CAACK,QAAjB,CAA2B,QAAWkC,CAAtC,CACV,QAAWvC,CAAI,CAACO,QADN,CACgB,OAAUP,CAAI,CAACQ,OAD/B,CAAd,CAGA,MAAOjB,CAAAA,CAAS,CAACoD,MAAV,CAAiB,yBAAjB,CAA4CD,CAA5C,CACV,CAVD,CAmBAhD,CAAc,CAACO,SAAf,CAAyBS,MAAzB,CAAkC,UAAW,CACzC,KAAKG,MAAL,CAAc,IAAd,CACA,KAAKJ,cAAL,CAAsB,EACzB,CAHD,CAKA,MAAOf,CAAAA,CAEV,CA1KK,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 * Action selector.\n *\n * To handle 'save' events use: actionselector.on('save')\n * This will receive the information to display in popup.\n * The actions have the format [{'text': sometext, 'value' : somevalue}].\n *\n * @module tool_lp/actionselector\n * @copyright 2016 Serge Gauthier - \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base'],\n function($, Notification, Ajax, Templates, Dialogue, EventBase) {\n\n /**\n * Action selector class.\n *\n * @class tool_lp/actionselector\n * @param {String} title The title of popup.\n * @param {String} message The message to display.\n * @param {object} actions The actions that can be selected.\n * @param {String} confirm Text for confirm button.\n * @param {String} cancel Text for cancel button.\n */\n var ActionSelector = function(title, message, actions, confirm, cancel) {\n var self = this;\n\n EventBase.prototype.constructor.apply(this, []);\n self._title = title;\n self._message = message;\n self._actions = actions;\n self._confirm = confirm;\n self._cancel = cancel;\n self._selectedValue = null;\n self._reset();\n };\n\n ActionSelector.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The value that was selected. */\n ActionSelector.prototype._selectedValue = null;\n /** @property {Dialogue} The reference to the dialogue. */\n ActionSelector.prototype._popup = null;\n /** @property {String} The title of popup. */\n ActionSelector.prototype._title = null;\n /** @property {String} The message in popup. */\n ActionSelector.prototype._message = null;\n /** @property {object} The information for radion buttons. */\n ActionSelector.prototype._actions = null;\n /** @property {String} The text for confirm button. */\n ActionSelector.prototype._confirm = null;\n /** @property {String} The text for cancel button. */\n ActionSelector.prototype._cancel = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n ActionSelector.prototype._afterRender = function() {\n var self = this;\n\n // Confirm button is disabled until a choice is done.\n self._find('[data-action=\"action-selector-confirm\"]').attr('disabled', 'disabled');\n\n // Add listener for radio buttons change.\n self._find('[data-region=\"action-selector-radio-buttons\"]').change(function() {\n self._selectedValue = $(\"input[type='radio']:checked\").val();\n self._find('[data-action=\"action-selector-confirm\"]').removeAttr('disabled');\n self._refresh.bind(self);\n });\n\n // Add listener for cancel.\n self._find('[data-action=\"action-selector-cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for confirm.\n self._find('[data-action=\"action-selector-confirm\"]').click(function(e) {\n e.preventDefault();\n if (!self._selectedValue.length) {\n return;\n }\n self._trigger('save', {action: self._selectedValue});\n self.close();\n });\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n ActionSelector.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the action selector.\n *\n * @method display\n * @return {Promise}\n */\n ActionSelector.prototype.display = function() {\n var self = this;\n return self._render().then(function(html) {\n self._popup = new Dialogue(\n self._title,\n html,\n self._afterRender.bind(self)\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery} The node\n * @method _find\n */\n ActionSelector.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n ActionSelector.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"action-selector\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n ActionSelector.prototype._render = function() {\n var self = this;\n var choices = [];\n for (var i in self._actions) {\n choices.push(self._actions[i]);\n }\n var content = {'message': self._message, 'choices': choices,\n 'confirm': self._confirm, 'cancel': self._cancel};\n\n return Templates.render('tool_lp/action_selector', content);\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n ActionSelector.prototype._reset = function() {\n this._popup = null;\n this._selectedValue = '';\n };\n\n return ActionSelector;\n\n});\n"],"file":"actionselector.min.js"} \ No newline at end of file +{"version":3,"file":"actionselector.min.js","sources":["../src/actionselector.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 * Action selector.\n *\n * To handle 'save' events use: actionselector.on('save')\n * This will receive the information to display in popup.\n * The actions have the format [{'text': sometext, 'value' : somevalue}].\n *\n * @module tool_lp/actionselector\n * @copyright 2016 Serge Gauthier - \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base'],\n function($, Notification, Ajax, Templates, Dialogue, EventBase) {\n\n /**\n * Action selector class.\n *\n * @class tool_lp/actionselector\n * @param {String} title The title of popup.\n * @param {String} message The message to display.\n * @param {object} actions The actions that can be selected.\n * @param {String} confirm Text for confirm button.\n * @param {String} cancel Text for cancel button.\n */\n var ActionSelector = function(title, message, actions, confirm, cancel) {\n var self = this;\n\n EventBase.prototype.constructor.apply(this, []);\n self._title = title;\n self._message = message;\n self._actions = actions;\n self._confirm = confirm;\n self._cancel = cancel;\n self._selectedValue = null;\n self._reset();\n };\n\n ActionSelector.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The value that was selected. */\n ActionSelector.prototype._selectedValue = null;\n /** @property {Dialogue} The reference to the dialogue. */\n ActionSelector.prototype._popup = null;\n /** @property {String} The title of popup. */\n ActionSelector.prototype._title = null;\n /** @property {String} The message in popup. */\n ActionSelector.prototype._message = null;\n /** @property {object} The information for radion buttons. */\n ActionSelector.prototype._actions = null;\n /** @property {String} The text for confirm button. */\n ActionSelector.prototype._confirm = null;\n /** @property {String} The text for cancel button. */\n ActionSelector.prototype._cancel = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n ActionSelector.prototype._afterRender = function() {\n var self = this;\n\n // Confirm button is disabled until a choice is done.\n self._find('[data-action=\"action-selector-confirm\"]').attr('disabled', 'disabled');\n\n // Add listener for radio buttons change.\n self._find('[data-region=\"action-selector-radio-buttons\"]').change(function() {\n self._selectedValue = $(\"input[type='radio']:checked\").val();\n self._find('[data-action=\"action-selector-confirm\"]').removeAttr('disabled');\n self._refresh.bind(self);\n });\n\n // Add listener for cancel.\n self._find('[data-action=\"action-selector-cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for confirm.\n self._find('[data-action=\"action-selector-confirm\"]').click(function(e) {\n e.preventDefault();\n if (!self._selectedValue.length) {\n return;\n }\n self._trigger('save', {action: self._selectedValue});\n self.close();\n });\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n ActionSelector.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the action selector.\n *\n * @method display\n * @return {Promise}\n */\n ActionSelector.prototype.display = function() {\n var self = this;\n return self._render().then(function(html) {\n self._popup = new Dialogue(\n self._title,\n html,\n self._afterRender.bind(self)\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery} The node\n * @method _find\n */\n ActionSelector.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n ActionSelector.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"action-selector\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n ActionSelector.prototype._render = function() {\n var self = this;\n var choices = [];\n for (var i in self._actions) {\n choices.push(self._actions[i]);\n }\n var content = {'message': self._message, 'choices': choices,\n 'confirm': self._confirm, 'cancel': self._cancel};\n\n return Templates.render('tool_lp/action_selector', content);\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n ActionSelector.prototype._reset = function() {\n this._popup = null;\n this._selectedValue = '';\n };\n\n return ActionSelector;\n\n});\n"],"names":["define","$","Notification","Ajax","Templates","Dialogue","EventBase","ActionSelector","title","message","actions","confirm","cancel","prototype","constructor","apply","this","_title","_message","_actions","_confirm","_cancel","_selectedValue","_reset","Object","create","_popup","_afterRender","self","_find","attr","change","val","removeAttr","_refresh","bind","click","e","preventDefault","close","length","_trigger","action","display","_render","then","html","fail","exception","selector","getContent","find","replaceWith","choices","i","push","content","render"],"mappings":";;;;;;;;;;;AA2BAA,gCAAO,CAAC,SACA,oBACA,YACA,iBACA,mBACA,uBACA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,SAAUC,eAYrDC,eAAiB,SAASC,MAAOC,QAASC,QAASC,QAASC,QAG5DN,UAAUO,UAAUC,YAAYC,MAAMC,KAAM,IAFjCA,KAGNC,OAAST,MAHHQ,KAINE,SAAWT,QAJLO,KAKNG,SAAWT,QALLM,KAMNI,SAAWT,QANLK,KAONK,QAAUT,OAPJI,KAQNM,eAAiB,KARXN,KASNO,iBAGThB,eAAeM,UAAYW,OAAOC,OAAOnB,UAAUO,YAG1BS,eAAiB,KAE1Cf,eAAeM,UAAUa,OAAS,KAElCnB,eAAeM,UAAUI,OAAS,KAElCV,eAAeM,UAAUK,SAAW,KAEpCX,eAAeM,UAAUM,SAAW,KAEpCZ,eAAeM,UAAUO,SAAW,KAEpCb,eAAeM,UAAUQ,QAAU,KAOnCd,eAAeM,UAAUc,aAAe,eAChCC,KAAOZ,KAGXY,KAAKC,MAAM,2CAA2CC,KAAK,WAAY,YAGvEF,KAAKC,MAAM,iDAAiDE,QAAO,WAC/DH,KAAKN,eAAiBrB,EAAE,+BAA+B+B,MACvDJ,KAAKC,MAAM,2CAA2CI,WAAW,YACjEL,KAAKM,SAASC,KAAKP,SAIvBA,KAAKC,MAAM,0CAA0CO,OAAM,SAASC,GAChEA,EAAEC,iBACFV,KAAKW,WAITX,KAAKC,MAAM,2CAA2CO,OAAM,SAASC,GACjEA,EAAEC,iBACGV,KAAKN,eAAekB,SAGzBZ,KAAKa,SAAS,OAAQ,CAACC,OAAQd,KAAKN,iBACpCM,KAAKW,aASbhC,eAAeM,UAAU0B,MAAQ,WAClBvB,KACNU,OAAOa,QADDvB,KAENO,UASThB,eAAeM,UAAU8B,QAAU,eAC3Bf,KAAOZ,YACJY,KAAKgB,UAAUC,MAAK,SAASC,MAChClB,KAAKF,OAAS,IAAIrB,SACduB,KAAKX,OACL6B,KACAlB,KAAKD,aAAaQ,KAAKP,UAG5BmB,KAAK7C,aAAa8C,YAUzBzC,eAAeM,UAAUgB,MAAQ,SAASoB,iBAC/BhD,EAAEe,KAAKU,OAAOwB,cAAcC,KAAKF,WAS5C1C,eAAeM,UAAUqB,SAAW,eAC5BN,KAAOZ,YACJY,KAAKgB,UAAUC,MAAK,SAASC,MAChClB,KAAKC,MAAM,mCAAmCuB,YAAYN,MAC1DlB,KAAKD,mBAWbpB,eAAeM,UAAU+B,QAAU,eAE3BS,QAAU,OACT,IAAIC,KAFEtC,KAEQG,SACfkC,QAAQE,KAHDvC,KAGWG,SAASmC,QAE3BE,QAAU,SALHxC,KAKoBE,iBAAqBmC,gBALzCrC,KAMSI,gBANTJ,KAMkCK,gBAEtCjB,UAAUqD,OAAO,0BAA2BD,UAUvDjD,eAAeM,UAAUU,OAAS,gBACzBG,OAAS,UACTJ,eAAiB,IAGnBf"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencies.min.js b/admin/tool/lp/amd/build/competencies.min.js index 867ec94c464..a80300bd855 100644 --- a/admin/tool/lp/amd/build/competencies.min.js +++ b/admin/tool/lp/amd/build/competencies.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competencies",["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/competencypicker","tool_lp/dragdrop-reorder","core/pending"],function(a,b,c,d,e,f,g,h){var i=function(b,c,d){this.itemid=b;this.itemtype=c;this.pageContextId=d;this.pickerInstance=null;a("[data-region=\"actions\"] button").prop("disabled",!1);this.registerEvents();this.registerDragDrop()};i.prototype.registerDragDrop=function(){var a=this;e.get_string("movecompetency","tool_lp").done(function(b){g.dragdrop("movecompetency",b,{identifier:"movecompetency",component:"tool_lp"},{identifier:"movecompetencyafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",function(b,c){a.handleDrop(b,c)})}).fail(b.exception)};i.prototype.handleDrop=function(d,e){var f=a(d).data("id"),g=a(e).data("id"),h=this,i=[];if("course"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_course_competency",args:{courseid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else if("template"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_template_competency",args:{templateid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else if("plan"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_plan_competency",args:{planid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else{return}i[0].fail(b.exception)};i.prototype.pickCompetency=function(){var g=this,i,j,k,l;if(!g.pickerInstance){if("template"===g.itemtype||"course"===g.itemtype){l="parents"}g.pickerInstance=new f(g.pageContextId,!1,l);g.pickerInstance.on("save",function(f,e){var l=e.competencyIds,m=new h;if("course"===g.itemtype){i=[];a.each(l,function(a,b){i.push({methodname:"core_competency_add_competency_to_course",args:{courseid:g.itemid,competencyid:b}})});i.push({methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:g.itemid,moduleid:0}});j="tool_lp/course_competencies_page";k="coursecompetenciespage"}else if("template"===g.itemtype){i=[];a.each(l,function(a,b){i.push({methodname:"core_competency_add_competency_to_template",args:{templateid:g.itemid,competencyid:b}})});i.push({methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:g.itemid,pagecontext:{contextid:g.pageContextId}}});j="tool_lp/template_competencies_page";k="templatecompetenciespage"}else if("plan"===g.itemtype){i=[];a.each(l,function(a,b){i.push({methodname:"core_competency_add_competency_to_plan",args:{planid:g.itemid,competencyid:b}})});i.push({methodname:"tool_lp_data_for_plan_page",args:{planid:g.itemid}});j="tool_lp/plan_page";k="plan-page"}c.call(i)[i.length-1].then(function(a){return d.render(j,a)}).then(function(b,c){d.replaceNode(a("[data-region=\""+k+"\"]"),b,c)}).then(m.resolve).catch(b.exception)})}return g.pickerInstance.display()};i.prototype.doDelete=function(e){var f=this,g=[],h="",i="";if("course"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_course",args:{courseid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid,moduleid:0}}]);h="tool_lp/course_competencies_page";i="coursecompetenciespage"}else if("template"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_template",args:{templateid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:f.itemid,pagecontext:{contextid:f.pageContextId}}}]);h="tool_lp/template_competencies_page";i="templatecompetenciespage"}else if("plan"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_plan",args:{planid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_plan_page",args:{planid:f.itemid}}]);h="tool_lp/plan_page";i="plan-page"}g[1].done(function(c){d.render(h,c).done(function(b,c){a("[data-region=\""+i+"\"]").replaceWith(b);d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)};i.prototype.deleteHandler=function(a){var d=this,f=[],g;if("course"==d.itemtype){g="unlinkcompetencycourse"}else if("template"==d.itemtype){g="unlinkcompetencytemplate"}else if("plan"==d.itemtype){g="unlinkcompetencyplan"}else{return}f=c.call([{methodname:"core_competency_read_competency",args:{id:a}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:g,component:"tool_lp",param:c.shortname},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){b.confirm(c[0],c[1],c[2],c[3],function(){d.doDelete(a)})}).fail(b.exception)}).fail(b.exception)};i.prototype.registerEvents=function(){var f=this;if("course"==f.itemtype){a("[data-region=\"coursecompetenciespage\"]").on("change","select[data-field=\"ruleoutcome\"]",function(g){var e=new h,i=[],j=a(g.target).data("id"),k=a(g.target).val();i=c.call([{methodname:"core_competency_set_course_competency_ruleoutcome",args:{coursecompetencyid:j,ruleoutcome:k}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid,moduleid:0}}]);i[1].then(function(a){return d.render("tool_lp/course_competencies_page",a)}).then(function(b,c){return d.replaceNode(a("[data-region=\""+"coursecompetenciespage"+"\"]"),b,c)}).then(e.resolve).catch(b.exception)})}a("[data-region=\"actions\"] button").click(function(a){var b=new h;a.preventDefault();f.pickCompetency().then(b.resolve).catch()});a("[data-action=\"delete-competency-link\"]").click(function(b){b.preventDefault();var c=a(b.target).closest("[data-id]").data("id");f.deleteHandler(c)})};return i}); -//# sourceMappingURL=competencies.min.js.map +/** + * Handle add/remove competency links. + * + * @module tool_lp/competencies + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competencies",["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/competencypicker","tool_lp/dragdrop-reorder","core/pending"],(function($,notification,ajax,templates,str,Picker,dragdrop,Pending){var competencies=function(itemid,itemtype,pagectxid){this.itemid=itemid,this.itemtype=itemtype,this.pageContextId=pagectxid,this.pickerInstance=null,$('[data-region="actions"] button').prop("disabled",!1),this.registerEvents(),this.registerDragDrop()};return competencies.prototype.registerDragDrop=function(){var localthis=this;str.get_string("movecompetency","tool_lp").done((function(movestring){dragdrop.dragdrop("movecompetency",movestring,{identifier:"movecompetency",component:"tool_lp"},{identifier:"movecompetencyafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",(function(drag,drop){localthis.handleDrop(drag,drop)}))})).fail(notification.exception)},competencies.prototype.handleDrop=function(drag,drop){var fromid=$(drag).data("id"),toid=$(drop).data("id"),requests=[];if("course"==this.itemtype)requests=ajax.call([{methodname:"core_competency_reorder_course_competency",args:{courseid:this.itemid,competencyidfrom:fromid,competencyidto:toid}}]);else if("template"==this.itemtype)requests=ajax.call([{methodname:"core_competency_reorder_template_competency",args:{templateid:this.itemid,competencyidfrom:fromid,competencyidto:toid}}]);else{if("plan"!=this.itemtype)return;requests=ajax.call([{methodname:"core_competency_reorder_plan_competency",args:{planid:this.itemid,competencyidfrom:fromid,competencyidto:toid}}])}requests[0].fail(notification.exception)},competencies.prototype.pickCompetency=function(){var requests,pagerender,pageregion,pageContextIncludes,self=this;return self.pickerInstance||("template"!==self.itemtype&&"course"!==self.itemtype||(pageContextIncludes="parents"),self.pickerInstance=new Picker(self.pageContextId,!1,pageContextIncludes),self.pickerInstance.on("save",(function(e,data){var compIds=data.competencyIds,pendingPromise=new Pending;"course"===self.itemtype?(requests=[],$.each(compIds,(function(index,compId){requests.push({methodname:"core_competency_add_competency_to_course",args:{courseid:self.itemid,competencyid:compId}})})),requests.push({methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:self.itemid,moduleid:0}}),pagerender="tool_lp/course_competencies_page",pageregion="coursecompetenciespage"):"template"===self.itemtype?(requests=[],$.each(compIds,(function(index,compId){requests.push({methodname:"core_competency_add_competency_to_template",args:{templateid:self.itemid,competencyid:compId}})})),requests.push({methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:self.itemid,pagecontext:{contextid:self.pageContextId}}}),pagerender="tool_lp/template_competencies_page",pageregion="templatecompetenciespage"):"plan"===self.itemtype&&(requests=[],$.each(compIds,(function(index,compId){requests.push({methodname:"core_competency_add_competency_to_plan",args:{planid:self.itemid,competencyid:compId}})})),requests.push({methodname:"tool_lp_data_for_plan_page",args:{planid:self.itemid}}),pagerender="tool_lp/plan_page",pageregion="plan-page"),ajax.call(requests)[requests.length-1].then((function(context){return templates.render(pagerender,context)})).then((function(html,js){templates.replaceNode($('[data-region="'+pageregion+'"]'),html,js)})).then(pendingPromise.resolve).catch(notification.exception)}))),self.pickerInstance.display()},competencies.prototype.doDelete=function(deleteid){var requests=[],pagerender="",pageregion="";"course"==this.itemtype?(requests=ajax.call([{methodname:"core_competency_remove_competency_from_course",args:{courseid:this.itemid,competencyid:deleteid}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:this.itemid,moduleid:0}}]),pagerender="tool_lp/course_competencies_page",pageregion="coursecompetenciespage"):"template"==this.itemtype?(requests=ajax.call([{methodname:"core_competency_remove_competency_from_template",args:{templateid:this.itemid,competencyid:deleteid}},{methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:this.itemid,pagecontext:{contextid:this.pageContextId}}}]),pagerender="tool_lp/template_competencies_page",pageregion="templatecompetenciespage"):"plan"==this.itemtype&&(requests=ajax.call([{methodname:"core_competency_remove_competency_from_plan",args:{planid:this.itemid,competencyid:deleteid}},{methodname:"tool_lp_data_for_plan_page",args:{planid:this.itemid}}]),pagerender="tool_lp/plan_page",pageregion="plan-page"),requests[1].done((function(context){templates.render(pagerender,context).done((function(html,js){$('[data-region="'+pageregion+'"]').replaceWith(html),templates.runTemplateJS(js)})).fail(notification.exception)})).fail(notification.exception)},competencies.prototype.deleteHandler=function(deleteid){var message,localthis=this;if("course"==localthis.itemtype)message="unlinkcompetencycourse";else if("template"==localthis.itemtype)message="unlinkcompetencytemplate";else{if("plan"!=localthis.itemtype)return;message="unlinkcompetencyplan"}ajax.call([{methodname:"core_competency_read_competency",args:{id:deleteid}}])[0].done((function(competency){str.get_strings([{key:"confirm",component:"moodle"},{key:message,component:"tool_lp",param:competency.shortname},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){localthis.doDelete(deleteid)}))})).fail(notification.exception)})).fail(notification.exception)},competencies.prototype.registerEvents=function(){var localthis=this;"course"==localthis.itemtype&&$('[data-region="coursecompetenciespage"]').on("change",'select[data-field="ruleoutcome"]',(function(e){var pendingPromise=new Pending,coursecompetencyid=$(e.target).data("id"),ruleoutcome=$(e.target).val();ajax.call([{methodname:"core_competency_set_course_competency_ruleoutcome",args:{coursecompetencyid:coursecompetencyid,ruleoutcome:ruleoutcome}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:localthis.itemid,moduleid:0}}])[1].then((function(context){return templates.render("tool_lp/course_competencies_page",context)})).then((function(html,js){return templates.replaceNode($('[data-region="coursecompetenciespage"]'),html,js)})).then(pendingPromise.resolve).catch(notification.exception)})),$('[data-region="actions"] button').click((function(e){var pendingPromise=new Pending;e.preventDefault(),localthis.pickCompetency().then(pendingPromise.resolve).catch()})),$('[data-action="delete-competency-link"]').click((function(e){e.preventDefault();var deleteid=$(e.target).closest("[data-id]").data("id");localthis.deleteHandler(deleteid)}))},competencies})); + +//# sourceMappingURL=competencies.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencies.min.js.map b/admin/tool/lp/amd/build/competencies.min.js.map index fe7e6ed9854..38cbcbe25d1 100644 --- a/admin/tool/lp/amd/build/competencies.min.js.map +++ b/admin/tool/lp/amd/build/competencies.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencies.js"],"names":["define","$","notification","ajax","templates","str","Picker","dragdrop","Pending","competencies","itemid","itemtype","pagectxid","pageContextId","pickerInstance","prop","registerEvents","registerDragDrop","prototype","localthis","get_string","done","movestring","identifier","component","drag","drop","handleDrop","fail","exception","fromid","data","toid","requests","call","methodname","args","courseid","competencyidfrom","competencyidto","templateid","planid","pickCompetency","self","pagerender","pageregion","pageContextIncludes","on","e","compIds","competencyIds","pendingPromise","each","index","compId","push","competencyid","moduleid","pagecontext","contextid","length","then","context","render","html","js","replaceNode","resolve","catch","display","doDelete","deleteid","replaceWith","runTemplateJS","deleteHandler","message","id","competency","get_strings","key","param","shortname","strings","confirm","coursecompetencyid","target","ruleoutcome","val","click","preventDefault","closest"],"mappings":"AAsBAA,OAAM,wBAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,UAJD,CAKC,0BALD,CAMC,0BAND,CAOC,cAPD,CAAD,CAQC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAwDC,CAAxD,CAAkEC,CAAlE,CAA2E,CAU9E,GAAIC,CAAAA,C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CACUV,CAAc,CAACgB,OADzB,EAEKC,KAFL,EAGH,CAPD,EAQAnE,CAAC,CAAC,0CAAD,CAAD,CAA4CuF,KAA5C,CAAkD,SAASxC,CAAT,CAAY,CAC1DA,CAAC,CAACyC,cAAF,GAEA,GAAIlB,CAAAA,CAAQ,CAAGtE,CAAC,CAAC+C,CAAC,CAACqC,MAAH,CAAD,CAAYK,OAAZ,CAAoB,WAApB,EAAiC3D,IAAjC,CAAsC,IAAtC,CAAf,CACAZ,CAAS,CAACuD,aAAV,CAAwBH,CAAxB,CACH,CALD,CAMH,CA5CD,CA8CA,MAAiD9D,CAAAA,CACpD,CAzUK,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 * Handle add/remove competency links.\n *\n * @module tool_lp/competencies\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/competencypicker',\n 'tool_lp/dragdrop-reorder',\n 'core/pending'],\n function($, notification, ajax, templates, str, Picker, dragdrop, Pending) {\n\n /**\n * Constructor\n *\n * @class tool_lp/competencies\n * @param {Number} itemid\n * @param {String} itemtype\n * @param {Number} pagectxid\n */\n var competencies = function(itemid, itemtype, pagectxid) {\n this.itemid = itemid;\n this.itemtype = itemtype;\n this.pageContextId = pagectxid;\n this.pickerInstance = null;\n\n $('[data-region=\"actions\"] button').prop('disabled', false);\n this.registerEvents();\n this.registerDragDrop();\n };\n\n /**\n * Initialise the drag/drop code.\n * @method registerDragDrop\n */\n competencies.prototype.registerDragDrop = function() {\n var localthis = this;\n // Init this module.\n str.get_string('movecompetency', 'tool_lp').done(\n function(movestring) {\n dragdrop.dragdrop('movecompetency',\n movestring,\n {identifier: 'movecompetency', component: 'tool_lp'},\n {identifier: 'movecompetencyafter', component: 'tool_lp'},\n 'drag-samenode',\n 'drag-parentnode',\n 'drag-handlecontainer',\n function(drag, drop) {\n localthis.handleDrop(drag, drop);\n });\n }\n ).fail(notification.exception);\n\n };\n\n /**\n * Handle a drop from a drag/drop operation.\n *\n * @method handleDrop\n * @param {DOMNode} drag The dragged node.\n * @param {DOMNode} drop The dropped on node.\n */\n competencies.prototype.handleDrop = function(drag, drop) {\n var fromid = $(drag).data('id');\n var toid = $(drop).data('id');\n var localthis = this;\n var requests = [];\n\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_course_competency',\n args: {courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_template_competency',\n args: {templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_plan_competency',\n args: {planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else {\n return;\n }\n\n requests[0].fail(notification.exception);\n };\n\n /**\n * Pick a competency\n *\n * @method pickCompetency\n * @return {Promise}\n */\n competencies.prototype.pickCompetency = function() {\n var self = this;\n var requests;\n var pagerender;\n var pageregion;\n var pageContextIncludes;\n\n if (!self.pickerInstance) {\n if (self.itemtype === 'template' || self.itemtype === 'course') {\n pageContextIncludes = 'parents';\n }\n self.pickerInstance = new Picker(self.pageContextId, false, pageContextIncludes);\n self.pickerInstance.on('save', function(e, data) {\n var compIds = data.competencyIds;\n var pendingPromise = new Pending();\n\n if (self.itemtype === \"course\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_course',\n args: {courseid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: self.itemid, moduleid: 0}\n });\n\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n\n } else if (self.itemtype === \"template\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_template',\n args: {templateid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: self.itemid, pagecontext: {contextid: self.pageContextId}}\n });\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (self.itemtype === \"plan\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_plan',\n args: {planid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: self.itemid}\n });\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n ajax.call(requests)[requests.length - 1]\n .then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n return self.pickerInstance.display();\n };\n\n /**\n * Delete the link between competency and course, template or plan. Reload the page.\n *\n * @method doDelete\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.doDelete = function(deleteid) {\n var localthis = this;\n var requests = [],\n pagerender = '',\n pageregion = '';\n\n // Delete the link and reload the page template.\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_course',\n args: {courseid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_template',\n args: {templateid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: localthis.itemid, pagecontext: {contextid: localthis.pageContextId}}}\n ]);\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_plan',\n args: {planid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_plan_page',\n args: {planid: localthis.itemid}}\n ]);\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n\n requests[1].done(function(context) {\n templates.render(pagerender, context).done(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n *\n * @method deleteHandler\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.deleteHandler = function(deleteid) {\n var localthis = this;\n var requests = [];\n var message;\n\n if (localthis.itemtype == 'course') {\n message = 'unlinkcompetencycourse';\n } else if (localthis.itemtype == 'template') {\n message = 'unlinkcompetencytemplate';\n } else if (localthis.itemtype == 'plan') {\n message = 'unlinkcompetencyplan';\n } else {\n return;\n }\n\n requests = ajax.call([{\n methodname: 'core_competency_read_competency',\n args: {id: deleteid}\n }]);\n\n requests[0].done(function(competency) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: message, component: 'tool_lp', param: competency.shortname},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink the competency X from the course?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n localthis.doDelete(deleteid);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Register the javascript event handlers for this page.\n *\n * @method registerEvents\n */\n competencies.prototype.registerEvents = function() {\n var localthis = this;\n\n if (localthis.itemtype == 'course') {\n // Course completion rule handling.\n $('[data-region=\"coursecompetenciespage\"]').on('change', 'select[data-field=\"ruleoutcome\"]', function(e) {\n var pendingPromise = new Pending();\n var requests = [];\n var pagerender = 'tool_lp/course_competencies_page';\n var pageregion = 'coursecompetenciespage';\n var coursecompetencyid = $(e.target).data('id');\n var ruleoutcome = $(e.target).val();\n requests = ajax.call([\n {methodname: 'core_competency_set_course_competency_ruleoutcome',\n args: {coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n\n requests[1].then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n return templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n $('[data-region=\"actions\"] button').click(function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n localthis.pickCompetency()\n .then(pendingPromise.resolve)\n .catch();\n });\n $('[data-action=\"delete-competency-link\"]').click(function(e) {\n e.preventDefault();\n\n var deleteid = $(e.target).closest('[data-id]').data('id');\n localthis.deleteHandler(deleteid);\n });\n };\n\n return /** @alias module:tool_lp/competencies */ competencies;\n});\n"],"file":"competencies.min.js"} \ No newline at end of file +{"version":3,"file":"competencies.min.js","sources":["../src/competencies.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 * Handle add/remove competency links.\n *\n * @module tool_lp/competencies\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/competencypicker',\n 'tool_lp/dragdrop-reorder',\n 'core/pending'],\n function($, notification, ajax, templates, str, Picker, dragdrop, Pending) {\n\n /**\n * Constructor\n *\n * @class tool_lp/competencies\n * @param {Number} itemid\n * @param {String} itemtype\n * @param {Number} pagectxid\n */\n var competencies = function(itemid, itemtype, pagectxid) {\n this.itemid = itemid;\n this.itemtype = itemtype;\n this.pageContextId = pagectxid;\n this.pickerInstance = null;\n\n $('[data-region=\"actions\"] button').prop('disabled', false);\n this.registerEvents();\n this.registerDragDrop();\n };\n\n /**\n * Initialise the drag/drop code.\n * @method registerDragDrop\n */\n competencies.prototype.registerDragDrop = function() {\n var localthis = this;\n // Init this module.\n str.get_string('movecompetency', 'tool_lp').done(\n function(movestring) {\n dragdrop.dragdrop('movecompetency',\n movestring,\n {identifier: 'movecompetency', component: 'tool_lp'},\n {identifier: 'movecompetencyafter', component: 'tool_lp'},\n 'drag-samenode',\n 'drag-parentnode',\n 'drag-handlecontainer',\n function(drag, drop) {\n localthis.handleDrop(drag, drop);\n });\n }\n ).fail(notification.exception);\n\n };\n\n /**\n * Handle a drop from a drag/drop operation.\n *\n * @method handleDrop\n * @param {DOMNode} drag The dragged node.\n * @param {DOMNode} drop The dropped on node.\n */\n competencies.prototype.handleDrop = function(drag, drop) {\n var fromid = $(drag).data('id');\n var toid = $(drop).data('id');\n var localthis = this;\n var requests = [];\n\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_course_competency',\n args: {courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_template_competency',\n args: {templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_plan_competency',\n args: {planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else {\n return;\n }\n\n requests[0].fail(notification.exception);\n };\n\n /**\n * Pick a competency\n *\n * @method pickCompetency\n * @return {Promise}\n */\n competencies.prototype.pickCompetency = function() {\n var self = this;\n var requests;\n var pagerender;\n var pageregion;\n var pageContextIncludes;\n\n if (!self.pickerInstance) {\n if (self.itemtype === 'template' || self.itemtype === 'course') {\n pageContextIncludes = 'parents';\n }\n self.pickerInstance = new Picker(self.pageContextId, false, pageContextIncludes);\n self.pickerInstance.on('save', function(e, data) {\n var compIds = data.competencyIds;\n var pendingPromise = new Pending();\n\n if (self.itemtype === \"course\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_course',\n args: {courseid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: self.itemid, moduleid: 0}\n });\n\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n\n } else if (self.itemtype === \"template\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_template',\n args: {templateid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: self.itemid, pagecontext: {contextid: self.pageContextId}}\n });\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (self.itemtype === \"plan\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_plan',\n args: {planid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: self.itemid}\n });\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n ajax.call(requests)[requests.length - 1]\n .then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n return self.pickerInstance.display();\n };\n\n /**\n * Delete the link between competency and course, template or plan. Reload the page.\n *\n * @method doDelete\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.doDelete = function(deleteid) {\n var localthis = this;\n var requests = [],\n pagerender = '',\n pageregion = '';\n\n // Delete the link and reload the page template.\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_course',\n args: {courseid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_template',\n args: {templateid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: localthis.itemid, pagecontext: {contextid: localthis.pageContextId}}}\n ]);\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_plan',\n args: {planid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_plan_page',\n args: {planid: localthis.itemid}}\n ]);\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n\n requests[1].done(function(context) {\n templates.render(pagerender, context).done(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n *\n * @method deleteHandler\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.deleteHandler = function(deleteid) {\n var localthis = this;\n var requests = [];\n var message;\n\n if (localthis.itemtype == 'course') {\n message = 'unlinkcompetencycourse';\n } else if (localthis.itemtype == 'template') {\n message = 'unlinkcompetencytemplate';\n } else if (localthis.itemtype == 'plan') {\n message = 'unlinkcompetencyplan';\n } else {\n return;\n }\n\n requests = ajax.call([{\n methodname: 'core_competency_read_competency',\n args: {id: deleteid}\n }]);\n\n requests[0].done(function(competency) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: message, component: 'tool_lp', param: competency.shortname},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink the competency X from the course?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n localthis.doDelete(deleteid);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Register the javascript event handlers for this page.\n *\n * @method registerEvents\n */\n competencies.prototype.registerEvents = function() {\n var localthis = this;\n\n if (localthis.itemtype == 'course') {\n // Course completion rule handling.\n $('[data-region=\"coursecompetenciespage\"]').on('change', 'select[data-field=\"ruleoutcome\"]', function(e) {\n var pendingPromise = new Pending();\n var requests = [];\n var pagerender = 'tool_lp/course_competencies_page';\n var pageregion = 'coursecompetenciespage';\n var coursecompetencyid = $(e.target).data('id');\n var ruleoutcome = $(e.target).val();\n requests = ajax.call([\n {methodname: 'core_competency_set_course_competency_ruleoutcome',\n args: {coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n\n requests[1].then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n return templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n $('[data-region=\"actions\"] button').click(function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n localthis.pickCompetency()\n .then(pendingPromise.resolve)\n .catch();\n });\n $('[data-action=\"delete-competency-link\"]').click(function(e) {\n e.preventDefault();\n\n var deleteid = $(e.target).closest('[data-id]').data('id');\n localthis.deleteHandler(deleteid);\n });\n };\n\n return /** @alias module:tool_lp/competencies */ competencies;\n});\n"],"names":["define","$","notification","ajax","templates","str","Picker","dragdrop","Pending","competencies","itemid","itemtype","pagectxid","pageContextId","pickerInstance","prop","registerEvents","registerDragDrop","prototype","localthis","this","get_string","done","movestring","identifier","component","drag","drop","handleDrop","fail","exception","fromid","data","toid","requests","call","methodname","args","courseid","competencyidfrom","competencyidto","templateid","planid","pickCompetency","pagerender","pageregion","pageContextIncludes","self","on","e","compIds","competencyIds","pendingPromise","each","index","compId","push","competencyid","moduleid","pagecontext","contextid","length","then","context","render","html","js","replaceNode","resolve","catch","display","doDelete","deleteid","replaceWith","runTemplateJS","deleteHandler","message","id","competency","get_strings","key","param","shortname","strings","confirm","coursecompetencyid","target","ruleoutcome","val","click","preventDefault","closest"],"mappings":";;;;;;;AAsBAA,8BAAO,CAAC,SACA,oBACA,YACA,iBACA,WACA,2BACA,2BACA,iBACD,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,OAAQC,SAAUC,aAUjEC,aAAe,SAASC,OAAQC,SAAUC,gBACrCF,OAASA,YACTC,SAAWA,cACXE,cAAgBD,eAChBE,eAAiB,KAEtBb,EAAE,kCAAkCc,KAAK,YAAY,QAChDC,sBACAC,2BAOTR,aAAaS,UAAUD,iBAAmB,eAClCE,UAAYC,KAEhBf,IAAIgB,WAAW,iBAAkB,WAAWC,MACxC,SAASC,YACLhB,SAASA,SAAS,iBACAgB,WACA,CAACC,WAAY,iBAAkBC,UAAW,WAC1C,CAACD,WAAY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AQ,GACRA,QAAQ,IACR,WACIhE,UAAUoD,SAASC,gBAG5B3C,KAAK3B,aAAa4B,cACtBD,KAAK3B,aAAa4B,YAQzBrB,aAAaS,UAAUF,eAAiB,eAChCG,UAAYC,KAEU,UAAtBD,UAAUR,UAEVV,EAAE,0CAA0C+C,GAAG,SAAU,oCAAoC,SAASC,OAC9FG,eAAiB,IAAI5C,QAIrB6E,mBAAqBpF,EAAEgD,EAAEqC,QAAQtD,KAAK,MACtCuD,YAActF,EAAEgD,EAAEqC,QAAQE,MACnBrF,KAAKgC,KAAK,CACjB,CAACC,WAAY,oDACXC,KAAM,CAACgD,mBAAoBA,mBAAoBE,YAAaA,cAC9D,CAACnD,WAAY,4CACXC,KAAM,CAACC,SAAUnB,UAAUT,OAAQgD,SAAU,MAG1C,GAAGI,MAAK,SAASC,gBACf3D,UAAU4D,OAZJ,mCAYuBD,YAEvCD,MAAK,SAASG,KAAMC,WACV9D,UAAU+D,YAAYlE,EAAE,0CAAuCgE,KAAMC,OAE/EJ,KAAKV,eAAegB,SACpBC,MAAMnE,aAAa4B,cAI5B7B,EAAE,kCAAkCwF,OAAM,SAASxC,OAC3CG,eAAiB,IAAI5C,QACzByC,EAAEyC,iBAEFvE,UAAUwB,iBACLmB,KAAKV,eAAegB,SACpBC,WAETpE,EAAE,0CAA0CwF,OAAM,SAASxC,GACvDA,EAAEyC,qBAEElB,SAAWvE,EAAEgD,EAAEqC,QAAQK,QAAQ,aAAa3D,KAAK,MACrDb,UAAUwD,cAAcH,cAIiB/D"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_outcomes.min.js b/admin/tool/lp/amd/build/competency_outcomes.min.js index ae3938f0be3..a1e39dd4f5d 100644 --- a/admin/tool/lp/amd/build/competency_outcomes.min.js +++ b/admin/tool/lp/amd/build/competency_outcomes.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competency_outcomes",["jquery","core/str"],function(a,b){return{NONE:0,EVIDENCE:1,COMPLETE:2,RECOMMEND:3,getAll:function getAll(){var a=this;return b.get_strings([{key:"competencyoutcome_none",component:"tool_lp"},{key:"competencyoutcome_evidence",component:"tool_lp"},{key:"competencyoutcome_recommend",component:"tool_lp"},{key:"competencyoutcome_complete",component:"tool_lp"}]).then(function(b){var c={};c[a.NONE]={code:a.NONE,name:b[0]};c[a.EVIDENCE]={code:a.EVIDENCE,name:b[1]};c[a.RECOMMEND]={code:a.RECOMMEND,name:b[2]};c[a.COMPLETE]={code:a.COMPLETE,name:b[3]};return c})},getString:function getString(b){var c=this,d=c.getAll();return d.then(function(c){if("undefined"==typeof c[b]){return a.Deferred().reject().promise()}return c[b].name})}}}); -//# sourceMappingURL=competency_outcomes.min.js.map +/** + * Competency rule config. + * + * @module tool_lp/competency_outcomes + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competency_outcomes",["jquery","core/str"],(function($,Str){return{NONE:0,EVIDENCE:1,COMPLETE:2,RECOMMEND:3,getAll:function(){var self=this;return Str.get_strings([{key:"competencyoutcome_none",component:"tool_lp"},{key:"competencyoutcome_evidence",component:"tool_lp"},{key:"competencyoutcome_recommend",component:"tool_lp"},{key:"competencyoutcome_complete",component:"tool_lp"}]).then((function(strings){var outcomes={};return outcomes[self.NONE]={code:self.NONE,name:strings[0]},outcomes[self.EVIDENCE]={code:self.EVIDENCE,name:strings[1]},outcomes[self.RECOMMEND]={code:self.RECOMMEND,name:strings[2]},outcomes[self.COMPLETE]={code:self.COMPLETE,name:strings[3]},outcomes}))},getString:function(id){return this.getAll().then((function(outcomes){return void 0===outcomes[id]?$.Deferred().reject().promise():outcomes[id].name}))}}})); + +//# sourceMappingURL=competency_outcomes.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_outcomes.min.js.map b/admin/tool/lp/amd/build/competency_outcomes.min.js.map index 3a38fcdc31a..e3bf7de9983 100644 --- a/admin/tool/lp/amd/build/competency_outcomes.min.js.map +++ b/admin/tool/lp/amd/build/competency_outcomes.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competency_outcomes.js"],"names":["define","$","Str","NONE","EVIDENCE","COMPLETE","RECOMMEND","getAll","self","get_strings","key","component","then","strings","outcomes","code","name","getString","id","all","Deferred","reject","promise"],"mappings":"AAuBAA,OAAM,+BAAC,CAAC,QAAD,CACC,UADD,CAAD,CAEE,SAASC,CAAT,CAAYC,CAAZ,CAAiB,CAOrB,MAAO,CAEHC,IAAI,EAFD,CAGHC,QAAQ,EAHL,CAIHC,QAAQ,EAJL,CAKHC,SAAS,EALN,CAaHC,MAAM,CAAE,iBAAW,CACf,GAAIC,CAAAA,CAAI,CAAG,IAAX,CACA,MAAON,CAAAA,CAAG,CAACO,WAAJ,CAAgB,CACnB,CAACC,GAAG,CAAE,wBAAN,CAAgCC,SAAS,CAAE,SAA3C,CADmB,CAEnB,CAACD,GAAG,CAAE,4BAAN,CAAoCC,SAAS,CAAE,SAA/C,CAFmB,CAGnB,CAACD,GAAG,CAAE,6BAAN,CAAqCC,SAAS,CAAE,SAAhD,CAHmB,CAInB,CAACD,GAAG,CAAE,4BAAN,CAAoCC,SAAS,CAAE,SAA/C,CAJmB,CAAhB,EAKJC,IALI,CAKC,SAASC,CAAT,CAAkB,CACtB,GAAIC,CAAAA,CAAQ,CAAG,EAAf,CACAA,CAAQ,CAACN,CAAI,CAACL,IAAN,CAAR,CAAsB,CAACY,IAAI,CAAEP,CAAI,CAACL,IAAZ,CAAkBa,IAAI,CAAEH,CAAO,CAAC,CAAD,CAA/B,CAAtB,CACAC,CAAQ,CAACN,CAAI,CAACJ,QAAN,CAAR,CAA0B,CAACW,IAAI,CAAEP,CAAI,CAACJ,QAAZ,CAAsBY,IAAI,CAAEH,CAAO,CAAC,CAAD,CAAnC,CAA1B,CACAC,CAAQ,CAACN,CAAI,CAACF,SAAN,CAAR,CAA2B,CAACS,IAAI,CAAEP,CAAI,CAACF,SAAZ,CAAuBU,IAAI,CAAEH,CAAO,CAAC,CAAD,CAApC,CAA3B,CACAC,CAAQ,CAACN,CAAI,CAACH,QAAN,CAAR,CAA0B,CAACU,IAAI,CAAEP,CAAI,CAACH,QAAZ,CAAsBW,IAAI,CAAEH,CAAO,CAAC,CAAD,CAAnC,CAA1B,CACA,MAAOC,CAAAA,CACV,CAZM,CAaV,CA5BE,CAqCHG,SAAS,CAAE,mBAASC,CAAT,CAAa,CACpB,GAAIV,CAAAA,CAAI,CAAG,IAAX,CACIW,CAAG,CAAGX,CAAI,CAACD,MAAL,EADV,CAGA,MAAOY,CAAAA,CAAG,CAACP,IAAJ,CAAS,SAASE,CAAT,CAAmB,CAC/B,GAA4B,WAAxB,QAAOA,CAAAA,CAAQ,CAACI,CAAD,CAAnB,CAAyC,CACrC,MAAOjB,CAAAA,CAAC,CAACmB,QAAF,GAAaC,MAAb,GAAsBC,OAAtB,EACV,CACD,MAAOR,CAAAA,CAAQ,CAACI,CAAD,CAAR,CAAaF,IACvB,CALM,CAMV,CA/CE,CAiDV,CA1DK,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 * Competency rule config.\n *\n * @module tool_lp/competency_outcomes\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str'],\n function($, Str) {\n\n var OUTCOME_NONE = 0,\n OUTCOME_EVIDENCE = 1,\n OUTCOME_COMPLETE = 2,\n OUTCOME_RECOMMEND = 3;\n\n return {\n\n NONE: OUTCOME_NONE,\n EVIDENCE: OUTCOME_EVIDENCE,\n COMPLETE: OUTCOME_COMPLETE,\n RECOMMEND: OUTCOME_RECOMMEND,\n\n /**\n * Get all the outcomes.\n *\n * @return {Object} Indexed by outcome code, contains code and name.\n * @method getAll\n */\n getAll: function() {\n var self = this;\n return Str.get_strings([\n {key: 'competencyoutcome_none', component: 'tool_lp'},\n {key: 'competencyoutcome_evidence', component: 'tool_lp'},\n {key: 'competencyoutcome_recommend', component: 'tool_lp'},\n {key: 'competencyoutcome_complete', component: 'tool_lp'},\n ]).then(function(strings) {\n var outcomes = {};\n outcomes[self.NONE] = {code: self.NONE, name: strings[0]};\n outcomes[self.EVIDENCE] = {code: self.EVIDENCE, name: strings[1]};\n outcomes[self.RECOMMEND] = {code: self.RECOMMEND, name: strings[2]};\n outcomes[self.COMPLETE] = {code: self.COMPLETE, name: strings[3]};\n return outcomes;\n });\n },\n\n /**\n * Get the string for an outcome.\n *\n * @param {Number} id The outcome code.\n * @return {Promise} Resolved with the string.\n * @method getString\n */\n getString: function(id) {\n var self = this,\n all = self.getAll();\n\n return all.then(function(outcomes) {\n if (typeof outcomes[id] === 'undefined') {\n return $.Deferred().reject().promise();\n }\n return outcomes[id].name;\n });\n }\n };\n});\n"],"file":"competency_outcomes.min.js"} \ No newline at end of file +{"version":3,"file":"competency_outcomes.min.js","sources":["../src/competency_outcomes.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 * Competency rule config.\n *\n * @module tool_lp/competency_outcomes\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str'],\n function($, Str) {\n\n var OUTCOME_NONE = 0,\n OUTCOME_EVIDENCE = 1,\n OUTCOME_COMPLETE = 2,\n OUTCOME_RECOMMEND = 3;\n\n return {\n\n NONE: OUTCOME_NONE,\n EVIDENCE: OUTCOME_EVIDENCE,\n COMPLETE: OUTCOME_COMPLETE,\n RECOMMEND: OUTCOME_RECOMMEND,\n\n /**\n * Get all the outcomes.\n *\n * @return {Object} Indexed by outcome code, contains code and name.\n * @method getAll\n */\n getAll: function() {\n var self = this;\n return Str.get_strings([\n {key: 'competencyoutcome_none', component: 'tool_lp'},\n {key: 'competencyoutcome_evidence', component: 'tool_lp'},\n {key: 'competencyoutcome_recommend', component: 'tool_lp'},\n {key: 'competencyoutcome_complete', component: 'tool_lp'},\n ]).then(function(strings) {\n var outcomes = {};\n outcomes[self.NONE] = {code: self.NONE, name: strings[0]};\n outcomes[self.EVIDENCE] = {code: self.EVIDENCE, name: strings[1]};\n outcomes[self.RECOMMEND] = {code: self.RECOMMEND, name: strings[2]};\n outcomes[self.COMPLETE] = {code: self.COMPLETE, name: strings[3]};\n return outcomes;\n });\n },\n\n /**\n * Get the string for an outcome.\n *\n * @param {Number} id The outcome code.\n * @return {Promise} Resolved with the string.\n * @method getString\n */\n getString: function(id) {\n var self = this,\n all = self.getAll();\n\n return all.then(function(outcomes) {\n if (typeof outcomes[id] === 'undefined') {\n return $.Deferred().reject().promise();\n }\n return outcomes[id].name;\n });\n }\n };\n});\n"],"names":["define","$","Str","NONE","EVIDENCE","COMPLETE","RECOMMEND","getAll","self","this","get_strings","key","component","then","strings","outcomes","code","name","getString","id","Deferred","reject","promise"],"mappings":";;;;;;;AAuBAA,qCAAO,CAAC,SACA,aACA,SAASC,EAAGC,WAOT,CAEHC,KAPe,EAQfC,SAPmB,EAQnBC,SAPmB,EAQnBC,UAPoB,EAepBC,OAAQ,eACAC,KAAOC,YACJP,IAAIQ,YAAY,CACnB,CAACC,IAAK,yBAA0BC,UAAW,WAC3C,CAACD,IAAK,6BAA8BC,UAAW,WAC/C,CAACD,IAAK,8BAA+BC,UAAW,WAChD,CAACD,IAAK,6BAA8BC,UAAW,aAChDC,MAAK,SAASC,aACTC,SAAW,UACfA,SAASP,KAAKL,MAAQ,CAACa,KAAMR,KAAKL,KAAMc,KAAMH,QAAQ,IACtDC,SAASP,KAAKJ,UAAY,CAACY,KAAMR,KAAKJ,SAAUa,KAAMH,QAAQ,IAC9DC,SAASP,KAAKF,WAAa,CAACU,KAAMR,KAAKF,UAAWW,KAAMH,QAAQ,IAChEC,SAASP,KAAKH,UAAY,CAACW,KAAMR,KAAKH,SAAUY,KAAMH,QAAQ,IACvDC,aAWfG,UAAW,SAASC,WACLV,KACIF,SAEJM,MAAK,SAASE,sBACO,IAAjBA,SAASI,IACTlB,EAAEmB,WAAWC,SAASC,UAE1BP,SAASI,IAAIF"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_plan_navigation.min.js b/admin/tool/lp/amd/build/competency_plan_navigation.min.js index fbf44da2b37..de5ef7683a9 100644 --- a/admin/tool/lp/amd/build/competency_plan_navigation.min.js +++ b/admin/tool/lp/amd/build/competency_plan_navigation.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competency_plan_navigation",["jquery"],function(a){var b=function(b,c,d,e,f){this._baseUrl=c;this._userId=d+"";this._competencyId=e+"";this._planId=f;this._ignoreFirstCompetency=!0;a(b).on("change",this._competencyChanged.bind(this))};b.prototype._competencyChanged=function(b){if(this._ignoreFirstCompetency){this._ignoreFirstCompetency=!1;return}var c=a(b.target).val(),d="?userid="+this._userId+"&planid="+this._planId+"&competencyid="+c;document.location=this._baseUrl+d};b.prototype._competencyId=null;b.prototype._userId=null;b.prototype._planId=null;b.prototype._baseUrl=null;b.prototype._ignoreFirstCompetency=null;return b}); -//# sourceMappingURL=competency_plan_navigation.min.js.map +/** + * Event click on selecting competency in the competency autocomplete. + * + * @module tool_lp/competency_plan_navigation + * @copyright 2016 Issam Taboubi + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competency_plan_navigation",["jquery"],(function($){var CompetencyPlanNavigation=function(competencySelector,baseUrl,userId,competencyId,planId){this._baseUrl=baseUrl,this._userId=userId+"",this._competencyId=competencyId+"",this._planId=planId,this._ignoreFirstCompetency=!0,$(competencySelector).on("change",this._competencyChanged.bind(this))};return CompetencyPlanNavigation.prototype._competencyChanged=function(e){if(this._ignoreFirstCompetency)this._ignoreFirstCompetency=!1;else{var newCompetencyId=$(e.target).val(),queryStr="?userid="+this._userId+"&planid="+this._planId+"&competencyid="+newCompetencyId;document.location=this._baseUrl+queryStr}},CompetencyPlanNavigation.prototype._competencyId=null,CompetencyPlanNavigation.prototype._userId=null,CompetencyPlanNavigation.prototype._planId=null,CompetencyPlanNavigation.prototype._baseUrl=null,CompetencyPlanNavigation.prototype._ignoreFirstCompetency=null,CompetencyPlanNavigation})); + +//# sourceMappingURL=competency_plan_navigation.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map b/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map index 8b9c63dd49f..613139fd6e8 100644 --- a/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map +++ b/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competency_plan_navigation.js"],"names":["define","$","CompetencyPlanNavigation","competencySelector","baseUrl","userId","competencyId","planId","_baseUrl","_userId","_competencyId","_planId","_ignoreFirstCompetency","on","_competencyChanged","bind","prototype","e","newCompetencyId","target","val","queryStr","document","location"],"mappings":"AAuBAA,OAAM,sCAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAY3B,GAAIC,CAAAA,CAAwB,CAAG,SAASC,CAAT,CAA6BC,CAA7B,CAAsCC,CAAtC,CAA8CC,CAA9C,CAA4DC,CAA5D,CAAoE,CAC/F,KAAKC,QAAL,CAAgBJ,CAAhB,CACA,KAAKK,OAAL,CAAeJ,CAAM,CAAG,EAAxB,CACA,KAAKK,aAAL,CAAqBJ,CAAY,CAAG,EAApC,CACA,KAAKK,OAAL,CAAeJ,CAAf,CACA,KAAKK,sBAAL,IAEAX,CAAC,CAACE,CAAD,CAAD,CAAsBU,EAAtB,CAAyB,QAAzB,CAAmC,KAAKC,kBAAL,CAAwBC,IAAxB,CAA6B,IAA7B,CAAnC,CACH,CARD,CAgBAb,CAAwB,CAACc,SAAzB,CAAmCF,kBAAnC,CAAwD,SAASG,CAAT,CAAY,CAChE,GAAI,KAAKL,sBAAT,CAAiC,CAC7B,KAAKA,sBAAL,IACA,MACH,CAJ+D,GAK5DM,CAAAA,CAAe,CAAGjB,CAAC,CAACgB,CAAC,CAACE,MAAH,CAAD,CAAYC,GAAZ,EAL0C,CAM5DC,CAAQ,CAAG,WAAa,KAAKZ,OAAlB,CAA4B,UAA5B,CAAyC,KAAKE,OAA9C,CAAwD,gBAAxD,CAA2EO,CAN1B,CAOhEI,QAAQ,CAACC,QAAT,CAAoB,KAAKf,QAAL,CAAgBa,CACvC,CARD,CAWAnB,CAAwB,CAACc,SAAzB,CAAmCN,aAAnC,CAAmD,IAAnD,CAEAR,CAAwB,CAACc,SAAzB,CAAmCP,OAAnC,CAA6C,IAA7C,CAEAP,CAAwB,CAACc,SAAzB,CAAmCL,OAAnC,CAA6C,IAA7C,CAEAT,CAAwB,CAACc,SAAzB,CAAmCR,QAAnC,CAA8C,IAA9C,CAEAN,CAAwB,CAACc,SAAzB,CAAmCJ,sBAAnC,CAA4D,IAA5D,CAEA,MAAOV,CAAAA,CACV,CAlDK,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 * Event click on selecting competency in the competency autocomplete.\n *\n * @module tool_lp/competency_plan_navigation\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * CompetencyPlanNavigation\n *\n * @class\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} planId The plan id\n */\n var CompetencyPlanNavigation = function(competencySelector, baseUrl, userId, competencyId, planId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._planId = planId;\n this._ignoreFirstCompetency = true;\n\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n CompetencyPlanNavigation.prototype._competencyChanged = function(e) {\n if (this._ignoreFirstCompetency) {\n this._ignoreFirstCompetency = false;\n return;\n }\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&planid=' + this._planId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n CompetencyPlanNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n CompetencyPlanNavigation.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n CompetencyPlanNavigation.prototype._planId = null;\n /** @property {String} Plugin base url. */\n CompetencyPlanNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n CompetencyPlanNavigation.prototype._ignoreFirstCompetency = null;\n\n return CompetencyPlanNavigation;\n});\n"],"file":"competency_plan_navigation.min.js"} \ No newline at end of file +{"version":3,"file":"competency_plan_navigation.min.js","sources":["../src/competency_plan_navigation.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 * Event click on selecting competency in the competency autocomplete.\n *\n * @module tool_lp/competency_plan_navigation\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * CompetencyPlanNavigation\n *\n * @class\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} planId The plan id\n */\n var CompetencyPlanNavigation = function(competencySelector, baseUrl, userId, competencyId, planId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._planId = planId;\n this._ignoreFirstCompetency = true;\n\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n CompetencyPlanNavigation.prototype._competencyChanged = function(e) {\n if (this._ignoreFirstCompetency) {\n this._ignoreFirstCompetency = false;\n return;\n }\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&planid=' + this._planId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n CompetencyPlanNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n CompetencyPlanNavigation.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n CompetencyPlanNavigation.prototype._planId = null;\n /** @property {String} Plugin base url. */\n CompetencyPlanNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n CompetencyPlanNavigation.prototype._ignoreFirstCompetency = null;\n\n return CompetencyPlanNavigation;\n});\n"],"names":["define","$","CompetencyPlanNavigation","competencySelector","baseUrl","userId","competencyId","planId","_baseUrl","_userId","_competencyId","_planId","_ignoreFirstCompetency","on","this","_competencyChanged","bind","prototype","e","newCompetencyId","target","val","queryStr","document","location"],"mappings":";;;;;;;AAuBAA,4CAAO,CAAC,WAAW,SAASC,OAYpBC,yBAA2B,SAASC,mBAAoBC,QAASC,OAAQC,aAAcC,aAClFC,SAAWJ,aACXK,QAAUJ,OAAS,QACnBK,cAAgBJ,aAAe,QAC/BK,QAAUJ,YACVK,wBAAyB,EAE9BX,EAAEE,oBAAoBU,GAAG,SAAUC,KAAKC,mBAAmBC,KAAKF,eASpEZ,yBAAyBe,UAAUF,mBAAqB,SAASG,MACzDJ,KAAKF,4BACAA,wBAAyB,WAG9BO,gBAAkBlB,EAAEiB,EAAEE,QAAQC,MAC9BC,SAAW,WAAaR,KAAKL,QAAU,WAAaK,KAAKH,QAAU,iBAAmBQ,gBAC1FI,SAASC,SAAWV,KAAKN,SAAWc,WAIxCpB,yBAAyBe,UAAUP,cAAgB,KAEnDR,yBAAyBe,UAAUR,QAAU,KAE7CP,yBAAyBe,UAAUN,QAAU,KAE7CT,yBAAyBe,UAAUT,SAAW,KAE9CN,yBAAyBe,UAAUL,uBAAyB,KAErDV"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule.min.js b/admin/tool/lp/amd/build/competency_rule.min.js index 1315e57b049..032876db145 100644 --- a/admin/tool/lp/amd/build/competency_rule.min.js +++ b/admin/tool/lp/amd/build/competency_rule.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competency_rule",["jquery"],function(a){var b=function(b){this._eventNode=a("
");this._ready=a.Deferred();this._tree=b};b.prototype._competency=null;b.prototype._eventNode=null;b.prototype._ready=null;b.prototype._tree=null;b.prototype.canConfig=function(){return this._tree.hasChildren(this._competency.id)};b.prototype.getConfig=function(){return null};b.prototype.getType=function(){throw new Error("Not implemented")};b.prototype.init=function(){return this._load()};b.prototype.injectTemplate=function(){return a.Deferred().reject().promise()};b.prototype.isValid=function(){return!1};b.prototype._load=function(){return a.when()};b.prototype.on=function(a,b){this._eventNode.on(a,b)};b.prototype.setTargetCompetency=function(a){this._competency=a};b.prototype._trigger=function(a,b){this._eventNode.trigger(a,[b])};b.prototype._triggerChange=function(){this._trigger("change",this)};return b}); -//# sourceMappingURL=competency_rule.min.js.map +/** + * Competency rule base module. + * + * @module tool_lp/competencyrule + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competency_rule",["jquery"],(function($){var Rule=function(tree){this._eventNode=$("
"),this._ready=$.Deferred(),this._tree=tree};return Rule.prototype._competency=null,Rule.prototype._eventNode=null,Rule.prototype._ready=null,Rule.prototype._tree=null,Rule.prototype.canConfig=function(){return this._tree.hasChildren(this._competency.id)},Rule.prototype.getConfig=function(){return null},Rule.prototype.getType=function(){throw new Error("Not implemented")},Rule.prototype.init=function(){return this._load()},Rule.prototype.injectTemplate=function(){return $.Deferred().reject().promise()},Rule.prototype.isValid=function(){return!1},Rule.prototype._load=function(){return $.when()},Rule.prototype.on=function(type,handler){this._eventNode.on(type,handler)},Rule.prototype.setTargetCompetency=function(competency){this._competency=competency},Rule.prototype._trigger=function(type,data){this._eventNode.trigger(type,[data])},Rule.prototype._triggerChange=function(){this._trigger("change",this)},Rule})); + +//# sourceMappingURL=competency_rule.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule.min.js.map b/admin/tool/lp/amd/build/competency_rule.min.js.map index 1ca5191e836..a0fe9913190 100644 --- a/admin/tool/lp/amd/build/competency_rule.min.js.map +++ b/admin/tool/lp/amd/build/competency_rule.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competency_rule.js"],"names":["define","$","Rule","tree","_eventNode","_ready","Deferred","_tree","prototype","_competency","canConfig","hasChildren","id","getConfig","getType","Error","init","_load","injectTemplate","reject","promise","isValid","when","on","type","handler","setTargetCompetency","competency","_trigger","data","trigger","_triggerChange"],"mappings":"AAuBAA,OAAM,2BAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAa3B,GAAIC,CAAAA,CAAI,CAAG,SAASC,CAAT,CAAe,CACtB,KAAKC,UAAL,CAAkBH,CAAC,CAAC,OAAD,CAAnB,CACA,KAAKI,MAAL,CAAcJ,CAAC,CAACK,QAAF,EAAd,CACA,KAAKC,KAAL,CAAaJ,CAChB,CAJD,CAOAD,CAAI,CAACM,SAAL,CAAeC,WAAf,CAA6B,IAA7B,CAEAP,CAAI,CAACM,SAAL,CAAeJ,UAAf,CAA4B,IAA5B,CAEAF,CAAI,CAACM,SAAL,CAAeH,MAAf,CAAwB,IAAxB,CAEAH,CAAI,CAACM,SAAL,CAAeD,KAAf,CAAuB,IAAvB,CAQAL,CAAI,CAACM,SAAL,CAAeE,SAAf,CAA2B,UAAW,CAClC,MAAO,MAAKH,KAAL,CAAWI,WAAX,CAAuB,KAAKF,WAAL,CAAiBG,EAAxC,CACV,CAFD,CAYAV,CAAI,CAACM,SAAL,CAAeK,SAAf,CAA2B,UAAW,CAClC,MAAO,KACV,CAFD,CAYAX,CAAI,CAACM,SAAL,CAAeM,OAAf,CAAyB,UAAW,CAChC,KAAM,IAAIC,CAAAA,KAAJ,CAAU,iBAAV,CACT,CAFD,CAYAb,CAAI,CAACM,SAAL,CAAeQ,IAAf,CAAsB,UAAW,CAC7B,MAAO,MAAKC,KAAL,EACV,CAFD,CAUAf,CAAI,CAACM,SAAL,CAAeU,cAAf,CAAgC,UAAW,CACvC,MAAOjB,CAAAA,CAAC,CAACK,QAAF,GAAaa,MAAb,GAAsBC,OAAtB,EACV,CAFD,CAYAlB,CAAI,CAACM,SAAL,CAAea,OAAf,CAAyB,UAAW,CAChC,QACH,CAFD,CAWAnB,CAAI,CAACM,SAAL,CAAeS,KAAf,CAAuB,UAAW,CAC9B,MAAOhB,CAAAA,CAAC,CAACqB,IAAF,EACV,CAFD,CAWApB,CAAI,CAACM,SAAL,CAAee,EAAf,CAAoB,SAASC,CAAT,CAAeC,CAAf,CAAwB,CACxC,KAAKrB,UAAL,CAAgBmB,EAAhB,CAAmBC,CAAnB,CAAyBC,CAAzB,CACH,CAFD,CAUAvB,CAAI,CAACM,SAAL,CAAekB,mBAAf,CAAqC,SAASC,CAAT,CAAqB,CACtD,KAAKlB,WAAL,CAAmBkB,CACtB,CAFD,CAYAzB,CAAI,CAACM,SAAL,CAAeoB,QAAf,CAA0B,SAASJ,CAAT,CAAeK,CAAf,CAAqB,CAC3C,KAAKzB,UAAL,CAAgB0B,OAAhB,CAAwBN,CAAxB,CAA8B,CAACK,CAAD,CAA9B,CACH,CAFD,CAUA3B,CAAI,CAACM,SAAL,CAAeuB,cAAf,CAAgC,UAAW,CACvC,KAAKH,QAAL,CAAc,QAAd,CAAwB,IAAxB,CACH,CAFD,CAIA,MAAoD1B,CAAAA,CAEvD,CAxJK,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 * Competency rule base module.\n *\n * @module tool_lp/competencyrule\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * Competency rule abstract class.\n *\n * Any competency rule should extend this object. The event 'change' should be\n * triggered on the instance when the configuration has changed. This will allow\n * the components using the rule to gather the config, or check its validity.\n *\n * this._triggerChange();\n *\n * @param {Tree} tree The competency tree.\n */\n var Rule = function(tree) {\n this._eventNode = $('
');\n this._ready = $.Deferred();\n this._tree = tree;\n };\n\n /** @property {Object} The current competency. */\n Rule.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n Rule.prototype._eventNode = null;\n /** @property {Promise} Resolved when the object is ready. */\n Rule.prototype._ready = null;\n /** @property {Tree} The competency tree. */\n Rule.prototype._tree = null;\n\n /**\n * Whether or not the current competency can be configured using this rule.\n *\n * @return {Boolean}\n * @method canConfig\n */\n Rule.prototype.canConfig = function() {\n return this._tree.hasChildren(this._competency.id);\n };\n\n /**\n * The config established by this rule.\n *\n * To override in subclasses when relevant.\n *\n * @return {String|null}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return null;\n };\n\n // eslint-disable-line valid-jsdoc\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n // eslint-enable-line valid-jsdoc\n Rule.prototype.getType = function() {\n throw new Error('Not implemented');\n };\n\n /**\n * The init process.\n *\n * Do not override this, instead override _load.\n *\n * @return {Promise} Revoled when the plugin is initialised.\n * @method init\n */\n Rule.prototype.init = function() {\n return this._load();\n };\n\n /**\n * Callback to inject the template.\n *\n * @returns {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function() {\n return $.Deferred().reject().promise();\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * Plugins should override this.\n *\n * @return {Boolean}\n * @method _isValid\n */\n Rule.prototype.isValid = function() {\n return false;\n };\n\n /**\n * Load the class.\n *\n * @return {Promise}\n * @method _load\n * @protected\n */\n Rule.prototype._load = function() {\n return $.when();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Rule.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Sets the current competency.\n *\n * @param {Competency} competency\n * @method setTargetCompetency\n */\n Rule.prototype.setTargetCompetency = function(competency) {\n this._competency = competency;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n Rule.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n /**\n * Trigger the change event.\n *\n * @method _triggerChange\n * @protected\n */\n Rule.prototype._triggerChange = function() {\n this._trigger('change', this);\n };\n\n return /** @alias module:tool_lp/competency_rule */ Rule;\n\n});\n"],"file":"competency_rule.min.js"} \ No newline at end of file +{"version":3,"file":"competency_rule.min.js","sources":["../src/competency_rule.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 * Competency rule base module.\n *\n * @module tool_lp/competencyrule\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * Competency rule abstract class.\n *\n * Any competency rule should extend this object. The event 'change' should be\n * triggered on the instance when the configuration has changed. This will allow\n * the components using the rule to gather the config, or check its validity.\n *\n * this._triggerChange();\n *\n * @param {Tree} tree The competency tree.\n */\n var Rule = function(tree) {\n this._eventNode = $('
');\n this._ready = $.Deferred();\n this._tree = tree;\n };\n\n /** @property {Object} The current competency. */\n Rule.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n Rule.prototype._eventNode = null;\n /** @property {Promise} Resolved when the object is ready. */\n Rule.prototype._ready = null;\n /** @property {Tree} The competency tree. */\n Rule.prototype._tree = null;\n\n /**\n * Whether or not the current competency can be configured using this rule.\n *\n * @return {Boolean}\n * @method canConfig\n */\n Rule.prototype.canConfig = function() {\n return this._tree.hasChildren(this._competency.id);\n };\n\n /**\n * The config established by this rule.\n *\n * To override in subclasses when relevant.\n *\n * @return {String|null}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return null;\n };\n\n // eslint-disable-line valid-jsdoc\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n // eslint-enable-line valid-jsdoc\n Rule.prototype.getType = function() {\n throw new Error('Not implemented');\n };\n\n /**\n * The init process.\n *\n * Do not override this, instead override _load.\n *\n * @return {Promise} Revoled when the plugin is initialised.\n * @method init\n */\n Rule.prototype.init = function() {\n return this._load();\n };\n\n /**\n * Callback to inject the template.\n *\n * @returns {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function() {\n return $.Deferred().reject().promise();\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * Plugins should override this.\n *\n * @return {Boolean}\n * @method _isValid\n */\n Rule.prototype.isValid = function() {\n return false;\n };\n\n /**\n * Load the class.\n *\n * @return {Promise}\n * @method _load\n * @protected\n */\n Rule.prototype._load = function() {\n return $.when();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Rule.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Sets the current competency.\n *\n * @param {Competency} competency\n * @method setTargetCompetency\n */\n Rule.prototype.setTargetCompetency = function(competency) {\n this._competency = competency;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n Rule.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n /**\n * Trigger the change event.\n *\n * @method _triggerChange\n * @protected\n */\n Rule.prototype._triggerChange = function() {\n this._trigger('change', this);\n };\n\n return /** @alias module:tool_lp/competency_rule */ Rule;\n\n});\n"],"names":["define","$","Rule","tree","_eventNode","_ready","Deferred","_tree","prototype","_competency","canConfig","this","hasChildren","id","getConfig","getType","Error","init","_load","injectTemplate","reject","promise","isValid","when","on","type","handler","setTargetCompetency","competency","_trigger","data","trigger","_triggerChange"],"mappings":";;;;;;;AAuBAA,iCAAO,CAAC,WAAW,SAASC,OAapBC,KAAO,SAASC,WACXC,WAAaH,EAAE,cACfI,OAASJ,EAAEK,gBACXC,MAAQJ,aAIjBD,KAAKM,UAAUC,YAAc,KAE7BP,KAAKM,UAAUJ,WAAa,KAE5BF,KAAKM,UAAUH,OAAS,KAExBH,KAAKM,UAAUD,MAAQ,KAQvBL,KAAKM,UAAUE,UAAY,kBAChBC,KAAKJ,MAAMK,YAAYD,KAAKF,YAAYI,KAWnDX,KAAKM,UAAUM,UAAY,kBAChB,MAWXZ,KAAKM,UAAUO,QAAU,iBACf,IAAIC,MAAM,oBAWpBd,KAAKM,UAAUS,KAAO,kBACXN,KAAKO,SAShBhB,KAAKM,UAAUW,eAAiB,kBACrBlB,EAAEK,WAAWc,SAASC,WAWjCnB,KAAKM,UAAUc,QAAU,kBACd,GAUXpB,KAAKM,UAAUU,MAAQ,kBACZjB,EAAEsB,QAUbrB,KAAKM,UAAUgB,GAAK,SAASC,KAAMC,cAC1BtB,WAAWoB,GAAGC,KAAMC,UAS7BxB,KAAKM,UAAUmB,oBAAsB,SAASC,iBACrCnB,YAAcmB,YAWvB1B,KAAKM,UAAUqB,SAAW,SAASJ,KAAMK,WAChC1B,WAAW2B,QAAQN,KAAM,CAACK,QASnC5B,KAAKM,UAAUwB,eAAiB,gBACvBH,SAAS,SAAUlB,OAGwBT"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule_all.min.js b/admin/tool/lp/amd/build/competency_rule_all.min.js index c396c7fcfc9..812d645ebed 100644 --- a/admin/tool/lp/amd/build/competency_rule_all.min.js +++ b/admin/tool/lp/amd/build/competency_rule_all.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competency_rule_all",["jquery","core/str","tool_lp/competency_rule"],function(a,b,c){var d=function(){c.apply(this,arguments)};d.prototype=Object.create(c.prototype);d.prototype.getType=function(){return"core_competency\\competency_rule_all"};d.prototype.isValid=function(){return!0};return d}); -//# sourceMappingURL=competency_rule_all.min.js.map +/** + * Competency rule all module. + * + * @module tool_lp/competency_rule_all + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competency_rule_all",["jquery","core/str","tool_lp/competency_rule"],(function($,Str,RuleBase){var Rule=function(){RuleBase.apply(this,arguments)};return(Rule.prototype=Object.create(RuleBase.prototype)).getType=function(){return"core_competency\\competency_rule_all"},Rule.prototype.isValid=function(){return!0},Rule})); + +//# sourceMappingURL=competency_rule_all.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule_all.min.js.map b/admin/tool/lp/amd/build/competency_rule_all.min.js.map index 9e6113d704c..cb5f90d05f7 100644 --- a/admin/tool/lp/amd/build/competency_rule_all.min.js.map +++ b/admin/tool/lp/amd/build/competency_rule_all.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competency_rule_all.js"],"names":["define","$","Str","RuleBase","Rule","apply","arguments","prototype","Object","create","getType","isValid"],"mappings":"AAuBAA,OAAM,+BAAC,CAAC,QAAD,CACC,UADD,CAEC,yBAFD,CAAD,CAIE,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAA2B,CAO/B,GAAIC,CAAAA,CAAI,CAAG,UAAW,CAClBD,CAAQ,CAACE,KAAT,CAAe,IAAf,CAAqBC,SAArB,CACH,CAFD,CAGAF,CAAI,CAACG,SAAL,CAAiBC,MAAM,CAACC,MAAP,CAAcN,CAAQ,CAACI,SAAvB,CAAjB,CAQAH,CAAI,CAACG,SAAL,CAAeG,OAAf,CAAyB,UAAW,CAChC,MAAO,sCACV,CAFD,CAUAN,CAAI,CAACG,SAAL,CAAeI,OAAf,CAAyB,UAAW,CAChC,QACH,CAFD,CAIA,MAAOP,CAAAA,CACV,CArCK,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 * Competency rule all module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'tool_lp/competency_rule',\n ],\n function($, Str, RuleBase) {\n\n /**\n * Competency rule all class.\n *\n * @class tool_lp/competency_rule_all\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_all';\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n return true;\n };\n\n return Rule;\n});\n"],"file":"competency_rule_all.min.js"} \ No newline at end of file +{"version":3,"file":"competency_rule_all.min.js","sources":["../src/competency_rule_all.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 * Competency rule all module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'tool_lp/competency_rule',\n ],\n function($, Str, RuleBase) {\n\n /**\n * Competency rule all class.\n *\n * @class tool_lp/competency_rule_all\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_all';\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n return true;\n };\n\n return Rule;\n});\n"],"names":["define","$","Str","RuleBase","Rule","apply","this","arguments","prototype","Object","create","getType","isValid"],"mappings":";;;;;;;AAuBAA,qCAAO,CAAC,SACA,WACA,4BAEA,SAASC,EAAGC,IAAKC,cAOjBC,KAAO,WACPD,SAASE,MAAMC,KAAMC,mBAEzBH,KAAKI,UAAYC,OAAOC,OAAOP,SAASK,YAQzBG,QAAU,iBACd,wCASXP,KAAKI,UAAUI,QAAU,kBACd,GAGJR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule_points.min.js b/admin/tool/lp/amd/build/competency_rule_points.min.js index 1a034201667..fb104b99183 100644 --- a/admin/tool/lp/amd/build/competency_rule_points.min.js +++ b/admin/tool/lp/amd/build/competency_rule_points.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competency_rule_points",["jquery","core/str","core/templates","tool_lp/competency_rule"],function(a,b,c,d){var e=function(){d.apply(this,arguments)};e.prototype=Object.create(d.prototype);e.prototype._container=null;e.prototype._templateLoaded=!1;e.prototype.getConfig=function(){return JSON.stringify({base:{points:this._getRequiredPoints()},competencies:this._getCompetenciesConfig()})};e.prototype._getCompetenciesConfig=function(){var b=[];this._container.find("[data-competency]").each(function(){var c=a(this),d=c.data("competency"),e=parseInt(c.find("[name=\"points\"]").val(),10),f=c.find("[name=\"required\"]").prop("checked");b.push({id:d,points:e,required:f?1:0})});return b};e.prototype._getRequiredPoints=function(){return parseInt(this._container.find("[name=\"requiredpoints\"]").val()||1,10)};e.prototype.getType=function(){return"core_competency\\competency_rule_points"};e.prototype.injectTemplate=function(b){var d=this,e=this._tree.getChildren(this._competency.id),f,g={base:{points:2},competencies:[]};this._templateLoaded=!1;if(d._competency.ruletype==d.getType()){try{g=JSON.parse(d._competency.ruleconfig)}catch(a){}}f={requiredpoints:g&&g.base?g.base.points:2,competency:d._competency,children:[]};a.each(e,function(b,c){var d={id:c.id,shortname:c.shortname,required:!1,points:0};if(g){a.each(g.competencies,function(a,b){if(b.id==d.id){d.required=b.required?!0:!1;d.points=b.points}})}f.children.push(d)});return c.render("tool_lp/competency_rule_points",f).then(function(a){d._container=b;b.html(a);b.find("input").change(function(){d._triggerChange()});d._templateLoaded=!0;d._triggerChange()})};e.prototype.isValid=function(){if(!this._templateLoaded){return!1}var b=this._getRequiredPoints(),c=0,d=!0;a.each(this._getCompetenciesConfig(),function(a,b){if(0>b.points){d=!1}c+=b.points});d=d&&c>=b;return d};return e}); -//# sourceMappingURL=competency_rule_points.min.js.map +/** + * Competency rule points module. + * + * @module tool_lp/competency_rule_all + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competency_rule_points",["jquery","core/str","core/templates","tool_lp/competency_rule"],(function($,Str,Templates,RuleBase){var Rule=function(){RuleBase.apply(this,arguments)};return(Rule.prototype=Object.create(RuleBase.prototype))._container=null,Rule.prototype._templateLoaded=!1,Rule.prototype.getConfig=function(){return JSON.stringify({base:{points:this._getRequiredPoints()},competencies:this._getCompetenciesConfig()})},Rule.prototype._getCompetenciesConfig=function(){var competencies=[];return this._container.find("[data-competency]").each((function(){var node=$(this),id=node.data("competency"),points=parseInt(node.find('[name="points"]').val(),10),required=node.find('[name="required"]').prop("checked");competencies.push({id:id,points:points,required:required?1:0})})),competencies},Rule.prototype._getRequiredPoints=function(){return parseInt(this._container.find('[name="requiredpoints"]').val()||1,10)},Rule.prototype.getType=function(){return"core_competency\\competency_rule_points"},Rule.prototype.injectTemplate=function(container){var context,self=this,children=this._tree.getChildren(this._competency.id),config={base:{points:2},competencies:[]};if(this._templateLoaded=!1,self._competency.ruletype==self.getType())try{config=JSON.parse(self._competency.ruleconfig)}catch(e){}return context={requiredpoints:config&&config.base?config.base.points:2,competency:self._competency,children:[]},$.each(children,(function(index,child){var competency={id:child.id,shortname:child.shortname,required:!1,points:0};config&&$.each(config.competencies,(function(index,comp){comp.id==competency.id&&(competency.required=!!comp.required,competency.points=comp.points)})),context.children.push(competency)})),Templates.render("tool_lp/competency_rule_points",context).then((function(html){self._container=container,container.html(html),container.find("input").change((function(){self._triggerChange()})),self._templateLoaded=!0,self._triggerChange()}))},Rule.prototype.isValid=function(){if(!this._templateLoaded)return!1;var required=this._getRequiredPoints(),max=0,valid=!0;return $.each(this._getCompetenciesConfig(),(function(index,competency){competency.points<0&&(valid=!1),max+=competency.points})),valid=valid&&max>=required},Rule})); + +//# sourceMappingURL=competency_rule_points.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule_points.min.js.map b/admin/tool/lp/amd/build/competency_rule_points.min.js.map index 0402a73f950..d3583f13916 100644 --- a/admin/tool/lp/amd/build/competency_rule_points.min.js.map +++ b/admin/tool/lp/amd/build/competency_rule_points.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competency_rule_points.js"],"names":["define","$","Str","Templates","RuleBase","Rule","apply","arguments","prototype","Object","create","_container","_templateLoaded","getConfig","JSON","stringify","base","points","_getRequiredPoints","competencies","_getCompetenciesConfig","find","each","node","id","data","parseInt","val","required","prop","push","getType","injectTemplate","container","self","children","_tree","getChildren","_competency","context","config","ruletype","parse","ruleconfig","e","requiredpoints","competency","index","child","shortname","comp","render","then","html","change","_triggerChange","isValid","max","valid"],"mappings":"AAuBAA,OAAM,kCAAC,CAAC,QAAD,CACC,UADD,CAEC,gBAFD,CAGC,yBAHD,CAAD,CAKE,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAA4BC,CAA5B,CAAsC,CAK1C,GAAIC,CAAAA,CAAI,CAAG,UAAW,CAClBD,CAAQ,CAACE,KAAT,CAAe,IAAf,CAAqBC,SAArB,CACH,CAFD,CAGAF,CAAI,CAACG,SAAL,CAAiBC,MAAM,CAACC,MAAP,CAAcN,CAAQ,CAACI,SAAvB,CAAjB,CAGAH,CAAI,CAACG,SAAL,CAAeG,UAAf,CAA4B,IAA5B,CAEAN,CAAI,CAACG,SAAL,CAAeI,eAAf,IAQAP,CAAI,CAACG,SAAL,CAAeK,SAAf,CAA2B,UAAW,CAClC,MAAOC,CAAAA,IAAI,CAACC,SAAL,CAAe,CAClBC,IAAI,CAAE,CACFC,MAAM,CAAE,KAAKC,kBAAL,EADN,CADY,CAIlBC,YAAY,CAAE,KAAKC,sBAAL,EAJI,CAAf,CAMV,CAPD,CAgBAf,CAAI,CAACG,SAAL,CAAeY,sBAAf,CAAwC,UAAW,CAC/C,GAAID,CAAAA,CAAY,CAAG,EAAnB,CAEA,KAAKR,UAAL,CAAgBU,IAAhB,CAAqB,mBAArB,EAA0CC,IAA1C,CAA+C,UAAW,CACtD,GAAIC,CAAAA,CAAI,CAAGtB,CAAC,CAAC,IAAD,CAAZ,CACIuB,CAAE,CAAGD,CAAI,CAACE,IAAL,CAAU,YAAV,CADT,CAEIR,CAAM,CAAGS,QAAQ,CAACH,CAAI,CAACF,IAAL,CAAU,mBAAV,EAA6BM,GAA7B,EAAD,CAAqC,EAArC,CAFrB,CAGIC,CAAQ,CAAGL,CAAI,CAACF,IAAL,CAAU,qBAAV,EAA+BQ,IAA/B,CAAoC,SAApC,CAHf,CAKAV,CAAY,CAACW,IAAb,CAAkB,CACdN,EA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,CAAsC,SAAS2B,CAAT,CAAgBD,CAAhB,CAA4B,CAC9D,GAAwB,CAApB,CAAAA,CAAU,CAAC7B,MAAf,CAA2B,CACvByC,CAAK,GACR,CACDD,CAAG,EAAIX,CAAU,CAAC7B,MACrB,CALD,EAOAyC,CAAK,CAAGA,CAAK,EAAID,CAAG,EAAI7B,CAAxB,CACA,MAAO8B,CAAAA,CACV,CAlBD,CAoBA,MAAOrD,CAAAA,CACV,CAhLK,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 * Competency rule points module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'core/templates',\n 'tool_lp/competency_rule',\n ],\n function($, Str, Templates, RuleBase) {\n\n /**\n * Competency rule points class.\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /** @property {Node} Reference to the container in which the template was included. */\n Rule.prototype._container = null;\n /** @property {Boolean} Whether or not the template was included. */\n Rule.prototype._templateLoaded = false;\n\n /**\n * The config established by this rule.\n *\n * @return {String}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return JSON.stringify({\n base: {\n points: this._getRequiredPoints(),\n },\n competencies: this._getCompetenciesConfig()\n });\n };\n\n /**\n * Gathers the input provided by the user for competencies.\n *\n * @return {Array} Containing id, points and required.\n * @method _getCompetenciesConfig\n * @protected\n */\n Rule.prototype._getCompetenciesConfig = function() {\n var competencies = [];\n\n this._container.find('[data-competency]').each(function() {\n var node = $(this),\n id = node.data('competency'),\n points = parseInt(node.find('[name=\"points\"]').val(), 10),\n required = node.find('[name=\"required\"]').prop('checked');\n\n competencies.push({\n id: id,\n points: points,\n required: required ? 1 : 0\n });\n });\n\n return competencies;\n };\n\n /**\n * Fetches the required points set by the user.\n *\n * @return {Number}\n * @method _getRequiredPoints\n * @protected\n */\n Rule.prototype._getRequiredPoints = function() {\n return parseInt(this._container.find('[name=\"requiredpoints\"]').val() || 1, 10);\n };\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_points';\n };\n\n /**\n * Callback to inject the template.\n *\n * @param {Node} container Node to inject in.\n * @return {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function(container) {\n var self = this,\n children = this._tree.getChildren(this._competency.id),\n context,\n config = {\n base: {points: 2},\n competencies: []\n };\n\n this._templateLoaded = false;\n\n // Only pre-load the configuration when the competency is using this rule.\n if (self._competency.ruletype == self.getType()) {\n try {\n config = JSON.parse(self._competency.ruleconfig);\n } catch (e) {\n // eslint-disable-line no-empty\n }\n }\n\n context = {\n requiredpoints: (config && config.base) ? config.base.points : 2,\n competency: self._competency,\n children: []\n };\n\n $.each(children, function(index, child) {\n var competency = {\n id: child.id,\n shortname: child.shortname,\n required: false,\n points: 0\n };\n\n if (config) {\n $.each(config.competencies, function(index, comp) {\n if (comp.id == competency.id) {\n competency.required = comp.required ? true : false;\n competency.points = comp.points;\n }\n });\n }\n\n context.children.push(competency);\n });\n\n return Templates.render('tool_lp/competency_rule_points', context).then(function(html) {\n self._container = container;\n container.html(html);\n container.find('input').change(function() {\n self._triggerChange();\n });\n\n // We're done, let's trigger a change.\n self._templateLoaded = true;\n self._triggerChange();\n return;\n });\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n if (!this._templateLoaded) {\n return false;\n }\n\n var required = this._getRequiredPoints(),\n max = 0,\n valid = true;\n\n $.each(this._getCompetenciesConfig(), function(index, competency) {\n if (competency.points < 0) {\n valid = false;\n }\n max += competency.points;\n });\n\n valid = valid && max >= required;\n return valid;\n };\n\n return Rule;\n});\n"],"file":"competency_rule_points.min.js"} \ No newline at end of file +{"version":3,"file":"competency_rule_points.min.js","sources":["../src/competency_rule_points.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 * Competency rule points module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'core/templates',\n 'tool_lp/competency_rule',\n ],\n function($, Str, Templates, RuleBase) {\n\n /**\n * Competency rule points class.\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /** @property {Node} Reference to the container in which the template was included. */\n Rule.prototype._container = null;\n /** @property {Boolean} Whether or not the template was included. */\n Rule.prototype._templateLoaded = false;\n\n /**\n * The config established by this rule.\n *\n * @return {String}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return JSON.stringify({\n base: {\n points: this._getRequiredPoints(),\n },\n competencies: this._getCompetenciesConfig()\n });\n };\n\n /**\n * Gathers the input provided by the user for competencies.\n *\n * @return {Array} Containing id, points and required.\n * @method _getCompetenciesConfig\n * @protected\n */\n Rule.prototype._getCompetenciesConfig = function() {\n var competencies = [];\n\n this._container.find('[data-competency]').each(function() {\n var node = $(this),\n id = node.data('competency'),\n points = parseInt(node.find('[name=\"points\"]').val(), 10),\n required = node.find('[name=\"required\"]').prop('checked');\n\n competencies.push({\n id: id,\n points: points,\n required: required ? 1 : 0\n });\n });\n\n return competencies;\n };\n\n /**\n * Fetches the required points set by the user.\n *\n * @return {Number}\n * @method _getRequiredPoints\n * @protected\n */\n Rule.prototype._getRequiredPoints = function() {\n return parseInt(this._container.find('[name=\"requiredpoints\"]').val() || 1, 10);\n };\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_points';\n };\n\n /**\n * Callback to inject the template.\n *\n * @param {Node} container Node to inject in.\n * @return {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function(container) {\n var self = this,\n children = this._tree.getChildren(this._competency.id),\n context,\n config = {\n base: {points: 2},\n competencies: []\n };\n\n this._templateLoaded = false;\n\n // Only pre-load the configuration when the competency is using this rule.\n if (self._competency.ruletype == self.getType()) {\n try {\n config = JSON.parse(self._competency.ruleconfig);\n } catch (e) {\n // eslint-disable-line no-empty\n }\n }\n\n context = {\n requiredpoints: (config && config.base) ? config.base.points : 2,\n competency: self._competency,\n children: []\n };\n\n $.each(children, function(index, child) {\n var competency = {\n id: child.id,\n shortname: child.shortname,\n required: false,\n points: 0\n };\n\n if (config) {\n $.each(config.competencies, function(index, comp) {\n if (comp.id == competency.id) {\n competency.required = comp.required ? true : false;\n competency.points = comp.points;\n }\n });\n }\n\n context.children.push(competency);\n });\n\n return Templates.render('tool_lp/competency_rule_points', context).then(function(html) {\n self._container = container;\n container.html(html);\n container.find('input').change(function() {\n self._triggerChange();\n });\n\n // We're done, let's trigger a change.\n self._templateLoaded = true;\n self._triggerChange();\n return;\n });\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n if (!this._templateLoaded) {\n return false;\n }\n\n var required = this._getRequiredPoints(),\n max = 0,\n valid = true;\n\n $.each(this._getCompetenciesConfig(), function(index, competency) {\n if (competency.points < 0) {\n valid = false;\n }\n max += competency.points;\n });\n\n valid = valid && max >= required;\n return valid;\n };\n\n return Rule;\n});\n"],"names":["define","$","Str","Templates","RuleBase","Rule","apply","this","arguments","prototype","Object","create","_container","_templateLoaded","getConfig","JSON","stringify","base","points","_getRequiredPoints","competencies","_getCompetenciesConfig","find","each","node","id","data","parseInt","val","required","prop","push","getType","injectTemplate","container","context","self","children","_tree","getChildren","_competency","config","ruletype","parse","ruleconfig","e","requiredpoints","competency","index","child","shortname","comp","render","then","html","change","_triggerChange","isValid","max","valid"],"mappings":";;;;;;;AAuBAA,wCAAO,CAAC,SACA,WACA,iBACA,4BAEA,SAASC,EAAGC,IAAKC,UAAWC,cAK5BC,KAAO,WACPD,SAASE,MAAMC,KAAMC,mBAEzBH,KAAKI,UAAYC,OAAOC,OAAOP,SAASK,YAGzBG,WAAa,KAE5BP,KAAKI,UAAUI,iBAAkB,EAQjCR,KAAKI,UAAUK,UAAY,kBAChBC,KAAKC,UAAU,CAClBC,KAAM,CACFC,OAAQX,KAAKY,sBAEjBC,aAAcb,KAAKc,4BAW3BhB,KAAKI,UAAUY,uBAAyB,eAChCD,aAAe,eAEdR,WAAWU,KAAK,qBAAqBC,MAAK,eACvCC,KAAOvB,EAAEM,MACTkB,GAAKD,KAAKE,KAAK,cACfR,OAASS,SAASH,KAAKF,KAAK,mBAAmBM,MAAO,IACtDC,SAAWL,KAAKF,KAAK,qBAAqBQ,KAAK,WAEnDV,aAAaW,KAAK,CACdN,GAAIA,GACJP,OAAQA,OACRW,SAAUA,SAAW,EAAI,OAI1BT,cAUXf,KAAKI,UAAUU,mBAAqB,kBACzBQ,SAASpB,KAAKK,WAAWU,KAAK,2BAA2BM,OAAS,EAAG,KAShFvB,KAAKI,UAAUuB,QAAU,iBACd,2CAUX3B,KAAK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/build/competencyactions.min.js index 838c6249d6a..030afdb723b 100644 --- a/admin/tool/lp/amd/build/competencyactions.min.js +++ b/admin/tool/lp/amd/build/competencyactions.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competencyactions",["jquery","core/url","core/templates","core/notification","core/str","core/ajax","tool_lp/dragdrop-reorder","tool_lp/tree","tool_lp/dialogue","tool_lp/menubar","tool_lp/competencypicker","tool_lp/competency_outcomes","tool_lp/competencyruleconfig","core/pending"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=null,p=null,q=null,r,s,t,u,v,w,x=null,y=function(){var c=a("[data-region=\"competencyactions\"]").data("competency"),f={competencyframeworkid:o.getCompetencyFrameworkId(),pagecontextid:r};if(null!==c){f.parentid=c.id}var g=function(){var c=a.param(f);window.location=b.relativeUrl("/admin/tool/lp/editcompetency.php?"+c)};if(null!==c&&o.hasRule(c.id)){e.get_strings([{key:"confirm",component:"moodle"},{key:"addingcompetencywillresetparentrule",component:"tool_lp",param:c.shortname},{key:"yes",component:"core"},{key:"no",component:"core"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],g)}).fail(d.exception)}else{g()}},z=function(){var b=a("[data-region=\"filtercompetencies\"]").data("frameworkid"),c=f.call([{methodname:"core_competency_set_parent_competency",args:{competencyid:p,parentid:q}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);c[1].done(F).fail(d.exception)},A=function(){q="undefined"==typeof q?0:q;if(q==p){return}var a=o.getCompetency(q)||{},b=o.getCompetency(p)||{},c="movecompetencywillresetrules",f=!1;if(b.parentid==q){return}if(a.path&&0<=a.path.indexOf("/"+b.id+"/")){c="movecompetencytochildofselfwillresetrules";f=f||o.hasRule(b.id)}f=f||o.hasRule(a.id)||o.hasRule(b.parentid);if(f){e.get_strings([{key:"confirm",component:"moodle"},{key:c,component:"tool_lp"},{key:"yes",component:"moodle"},{key:"no",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],z)}).fail(d.exception)}else{z()}},B=function(b){var c=a(b.getContent()),d=c.find("[data-enhance=movetree]"),e=new h(d,!1);e.on("selectionchanged",function(b,c){var d=c.selected;q=a(d).data("id")});d.show();c.on("click","[data-action=\"move\"]",function(){b.close();A()});c.on("click","[data-action=\"cancel\"]",function(){b.close()})},C=function(a,b){var c;for(c=0;cspan",P).on("dragover","li>span",Q).on("dragenter","li>span",R).on("dragleave","li>span",S).on("drop","li>span",T);b.on("selectionchanged",_);t=new m(o,w);t.on("save",M.bind(this))}}}); -//# sourceMappingURL=competencyactions.min.js.map +/** + * Handle selection changes and actions on the competency tree. + * + * @module tool_lp/competencyactions + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competencyactions",["jquery","core/url","core/templates","core/notification","core/str","core/ajax","tool_lp/dragdrop-reorder","tool_lp/tree","tool_lp/dialogue","tool_lp/menubar","tool_lp/competencypicker","tool_lp/competency_outcomes","tool_lp/competencyruleconfig","core/pending"],(function($,url,templates,notification,str,ajax,dragdrop,Ariatree,Dialogue,menubar,Picker,Outcomes,RuleConfig,Pending){var pageContextId,pickerInstance,ruleConfigInstance,relatedTarget,taxonomiesConstants,rulesModules,treeModel=null,moveSource=null,moveTarget=null,selectedCompetencyId=null,addHandler=function(){var parent=$('[data-region="competencyactions"]').data("competency"),params={competencyframeworkid:treeModel.getCompetencyFrameworkId(),pagecontextid:pageContextId};null!==parent&&(params.parentid=parent.id);var relocate=function(){var queryparams=$.param(params);window.location=url.relativeUrl("/admin/tool/lp/editcompetency.php?"+queryparams)};null!==parent&&treeModel.hasRule(parent.id)?str.get_strings([{key:"confirm",component:"moodle"},{key:"addingcompetencywillresetparentrule",component:"tool_lp",param:parent.shortname},{key:"yes",component:"core"},{key:"no",component:"core"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],relocate)})).fail(notification.exception):relocate()},doMove=function(){var frameworkid=$('[data-region="filtercompetencies"]').data("frameworkid");ajax.call([{methodname:"core_competency_set_parent_competency",args:{competencyid:moveSource,parentid:moveTarget}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:frameworkid,search:$('[data-region="filtercompetencies"] input').val()}}])[1].done(reloadPage).fail(notification.exception)},confirmMove=function(){if((moveTarget=void 0===moveTarget?0:moveTarget)!=moveSource){var targetComp=treeModel.getCompetency(moveTarget)||{},sourceComp=treeModel.getCompetency(moveSource)||{},confirmMessage="movecompetencywillresetrules",showConfirm=!1;sourceComp.parentid!=moveTarget&&(targetComp.path&&targetComp.path.indexOf("/"+sourceComp.id+"/")>=0&&(confirmMessage="movecompetencytochildofselfwillresetrules",showConfirm=showConfirm||treeModel.hasRule(sourceComp.id)),(showConfirm=showConfirm||treeModel.hasRule(targetComp.id)||treeModel.hasRule(sourceComp.parentid))?str.get_strings([{key:"confirm",component:"moodle"},{key:confirmMessage,component:"tool_lp"},{key:"yes",component:"moodle"},{key:"no",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],doMove)})).fail(notification.exception):doMove())}},initMovePopup=function(popup){var body=$(popup.getContent()),treeRoot=body.find("[data-enhance=movetree]");new Ariatree(treeRoot,!1).on("selectionchanged",(function(evt,params){var target=params.selected;moveTarget=$(target).data("id")})),treeRoot.show(),body.on("click",'[data-action="move"]',(function(){popup.close(),confirmMove()})),body.on("click",'[data-action="cancel"]',(function(){popup.close()}))},addCompetencyChildren=function(parent,competencies){var i;for(i=0;ispan",dragStart).on("dragover","li>span",allowDrop).on("dragenter","li>span",dragEnter).on("dragleave","li>span",dragLeave).on("drop","li>span",dropOver),model.on("selectionchanged",selectionChanged),(ruleConfigInstance=new RuleConfig(treeModel,rulesModules)).on("save",ruleConfigSaveHandler.bind(this))}}})); + +//# sourceMappingURL=competencyactions.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencyactions.min.js.map b/admin/tool/lp/amd/build/competencyactions.min.js.map index 34dffce4b06..aeac60ed8e9 100644 --- a/admin/tool/lp/amd/build/competencyactions.min.js.map +++ b/admin/tool/lp/amd/build/competencyactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencyactions.js"],"names":["define","$","url","templates","notification","str","ajax","dragdrop","Ariatree","Dialogue","menubar","Picker","Outcomes","RuleConfig","Pending","treeModel","moveSource","moveTarget","pageContextId","pickerInstance","ruleConfigInstance","relatedTarget","taxonomiesConstants","rulesModules","selectedCompetencyId","addHandler","parent","data","params","competencyframeworkid","getCompetencyFrameworkId","pagecontextid","parentid","id","relocate","queryparams","param","window","location","relativeUrl","hasRule","get_strings","key","component","shortname","done","strings","confirm","fail","exception","doMove","frameworkid","requests","call","methodname","args","competencyid","search","val","reloadPage","confirmMove","targetComp","getCompetency","sourceComp","confirmMessage","showConfirm","path","indexOf","initMovePopup","popup","body","getContent","treeRoot","find","tree","on","evt","target","selected","show","close","addCompetencyChildren","competencies","i","length","haschildren","children","moveHandler","e","preventDefault","competency","searchtext","when","apply","framework","competenciestree","onecompetency","render","editHandler","context","newhtml","newjs","replaceWith","runTemplateJS","updateSearchHandler","moveUpHandler","moveDownHandler","seeCoursesHandler","courses","html","get_string","linkedcourses","relateCompetenciesHandler","pendingPromise","compIds","competencyIds","calls","each","index","value","push","relatedcompetencyid","promises","then","js","updatedRelatedCompetencies","resolve","catch","setDisallowedCompetencyIDs","display","ruleConfigHandler","setTargetCompetencyId","ruleConfigSaveHandler","config","update","idnumber","description","descriptionformat","ruletype","ruleoutcome","ruleconfig","promise","result","renderCompetencySummary","doDelete","success","alert","deleteCompetencyHandler","dragStart","originalEvent","dataTransfer","setData","allowDrop","dropEffect","dragEnter","addClass","dragLeave","removeClass","dropOver","getData","deleteRelatedHandler","relatedid","substr","removeRelated","triggerCompetencyViewedEvent","getTaxonomyAtLevel","level","constant","Deferred","showdeleterelatedaction","showrelatedcompetencies","showrule","pluginbaseurl","NONE","getString","name","modInfo","type","strs","rule","outcome","replaceNodeContents","strAddTaxonomy","strSelectedTaxonomy","selectionChanged","node","btn","actionMenu","selectedTitle","sublevel","closeAll","clone","remove","end","text","hide","getCompetencyLevel","parseTaxonomies","taxonomiesstr","all","split","unshift","init","model","pagectxid","taxonomies","rulesMods","enhance","bind","top"],"mappings":"AAsBAA,OAAM,6BAAC,CAAC,QAAD,CACC,UADD,CAEC,gBAFD,CAGC,mBAHD,CAIC,UAJD,CAKC,WALD,CAMC,0BAND,CAOC,cAPD,CAQC,kBARD,CASC,iBATD,CAUC,0BAVD,CAWC,6BAXD,CAYC,8BAZD,CAaC,cAbD,CAAD,CAeC,SACKC,CADL,CACQC,CADR,CACaC,CADb,CACwBC,CADxB,CACsCC,CADtC,CAC2CC,CAD3C,CACiDC,CADjD,CAC2DC,CAD3D,CACqEC,CADrE,CAC+EC,CAD/E,CACwFC,CADxF,CACgGC,CADhG,CAC0GC,CAD1G,CACsHC,CADtH,CAEG,IAIFC,CAAAA,CAAS,CAAG,IAJV,CAMFC,CAAU,CAAG,IANX,CAQFC,CAAU,CAAG,IARX,CAUFC,CAVE,CAYFC,CAZE,CAcFC,CAdE,CAgBFC,CAhBE,CAkBFC,CAlBE,CAoBFC,CApBE,CAsBFC,CAAoB,CAAG,IAtBrB,CA4BFC,CAAU,CAAG,UAAW,IACpBC,CAAAA,CAAM,CAAGzB,CAAC,CAAC,qCAAD,CAAD,CAAuC0B,IAAvC,CAA4C,YAA5C,CADW,CAGpBC,CAAM,CAAG,CACTC,qBAAqB,CAAEd,CAAS,CAACe,wBAAV,EADd,CAETC,aAAa,CAAEb,CAFN,CAHW,CAQxB,GAAe,IAAX,GAAAQ,CAAJ,CAAqB,CAEjBE,CAAM,CAACI,QAAP,CAAkBN,CAAM,CAACO,EAC5B,CAED,GAAIC,CAAAA,CAAQ,CAAG,UAAW,CACtB,GAAIC,CAAAA,CAAW,CAAGlC,CAAC,CAACmC,KAAF,CAAQR,CAAR,CAAlB,CACAS,MAAM,CAACC,QAAP,CAAkBpC,CAAG,CAACqC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AT,CAA6B6G,CAA7B,EAGApK,CAAkB,CAAG,GAAIP,CAAAA,CAAJ,CAAeE,CAAf,CAA0BQ,CAA1B,CAArB,CACAH,CAAkB,CAACuD,EAAnB,CAAsB,MAAtB,CAA8ByD,CAAqB,CAAC4E,IAAtB,CAA2B,IAA3B,CAA9B,CACH,CA7CE,CA+CV,CA50BK,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 * Handle selection changes and actions on the competency tree.\n *\n * @module tool_lp/competencyactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/url',\n 'core/templates',\n 'core/notification',\n 'core/str',\n 'core/ajax',\n 'tool_lp/dragdrop-reorder',\n 'tool_lp/tree',\n 'tool_lp/dialogue',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker',\n 'tool_lp/competency_outcomes',\n 'tool_lp/competencyruleconfig',\n 'core/pending',\n ],\n function(\n $, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig, Pending\n ) {\n\n // Private variables and functions.\n /** @var {Object} treeModel - This is an object representing the nodes in the tree. */\n var treeModel = null;\n /** @var {Node} moveSource - The start of a drag operation */\n var moveSource = null;\n /** @var {Node} moveTarget - The end of a drag operation */\n var moveTarget = null;\n /** @var {Number} pageContextId The page context ID. */\n var pageContextId;\n /** @var {Object} Picker instance. */\n var pickerInstance;\n /** @var {Object} Rule config instance. */\n var ruleConfigInstance;\n /** @var {Object} The competency we're picking a relation to. */\n var relatedTarget;\n /** @var {Object} Taxonomy constants indexed per level. */\n var taxonomiesConstants;\n /** @var {Array} The rules modules. Values are object containing type, namd and amd. */\n var rulesModules;\n /** @var {Number} the selected competency ID. */\n var selectedCompetencyId = null;\n\n /**\n * Respond to choosing the \"Add\" menu item for the selected node in the tree.\n * @method addHandler\n */\n var addHandler = function() {\n var parent = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n pagecontextid: pageContextId\n };\n\n if (parent !== null) {\n // We are adding at a sub node.\n params.parentid = parent.id;\n }\n\n var relocate = function() {\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n if (parent !== null && treeModel.hasRule(parent.id)) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname},\n {key: 'yes', component: 'core'},\n {key: 'no', component: 'core'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0],\n strings[1],\n strings[2],\n strings[3],\n relocate\n );\n }).fail(notification.exception);\n } else {\n relocate();\n }\n };\n\n /**\n * A source and destination has been chosen - so time to complete a move.\n * @method doMove\n */\n var doMove = function() {\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n var requests = ajax.call([{\n methodname: 'core_competency_set_parent_competency',\n args: {competencyid: moveSource, parentid: moveTarget}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Confirms a competency move.\n *\n * @method confirmMove\n */\n var confirmMove = function() {\n moveTarget = typeof moveTarget === \"undefined\" ? 0 : moveTarget;\n if (moveTarget == moveSource) {\n // No move to do.\n return;\n }\n\n var targetComp = treeModel.getCompetency(moveTarget) || {},\n sourceComp = treeModel.getCompetency(moveSource) || {},\n confirmMessage = 'movecompetencywillresetrules',\n showConfirm = false;\n\n // We shouldn't be moving the competency to the same parent.\n if (sourceComp.parentid == moveTarget) {\n return;\n }\n\n // If we are moving to a child of self.\n if (targetComp.path && targetComp.path.indexOf('/' + sourceComp.id + '/') >= 0) {\n confirmMessage = 'movecompetencytochildofselfwillresetrules';\n\n // Show a confirmation if self has rules, as they'll disappear.\n showConfirm = showConfirm || treeModel.hasRule(sourceComp.id);\n }\n\n // Show a confirmation if the current parent, or the destination have rules.\n showConfirm = showConfirm || (treeModel.hasRule(targetComp.id) || treeModel.hasRule(sourceComp.parentid));\n\n // Show confirm, and/or do the things.\n if (showConfirm) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp'},\n {key: 'yes', component: 'moodle'},\n {key: 'no', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doMove\n );\n }).fail(notification.exception);\n\n } else {\n doMove();\n }\n };\n\n /**\n * A move competency popup was opened - initialise the aria tree in it.\n * @method initMovePopup\n * @param {dialogue} popup The tool_lp/dialogue that was created.\n */\n var initMovePopup = function(popup) {\n var body = $(popup.getContent());\n var treeRoot = body.find('[data-enhance=movetree]');\n var tree = new Ariatree(treeRoot, false);\n tree.on('selectionchanged', function(evt, params) {\n var target = params.selected;\n moveTarget = $(target).data('id');\n });\n treeRoot.show();\n\n body.on('click', '[data-action=\"move\"]', function() {\n popup.close();\n confirmMove();\n });\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Turn a flat list of competencies into a tree structure (recursive).\n * @method addCompetencyChildren\n * @param {Object} parent The current parent node in the tree\n * @param {Object[]} competencies The flat list of competencies\n */\n var addCompetencyChildren = function(parent, competencies) {\n var i;\n\n for (i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n };\n\n /**\n * A node was chosen and \"Move\" was selected from the menu. Open a popup to select the target.\n * @param {Event} e\n * @method moveHandler\n */\n var moveHandler = function(e) {\n e.preventDefault();\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n // Remember what we are moving.\n moveSource = competency.id;\n\n // Load data for the template.\n var requests = ajax.call([\n {\n methodname: 'core_competency_search_competencies',\n args: {\n competencyframeworkid: competency.competencyframeworkid,\n searchtext: ''\n }\n }, {\n methodname: 'core_competency_read_competency_framework',\n args: {\n id: competency.competencyframeworkid\n }\n }\n ]);\n\n // When all data has arrived, continue.\n $.when.apply(null, requests).done(function(competencies, framework) {\n\n // Expand the list of competencies into a tree.\n var i;\n var competenciestree = [];\n for (i = 0; i < competencies.length; i++) {\n var onecompetency = competencies[i];\n if (onecompetency.parentid == \"0\") {\n onecompetency.children = [];\n onecompetency.haschildren = 0;\n competenciestree[competenciestree.length] = onecompetency;\n addCompetencyChildren(onecompetency, competencies);\n }\n }\n\n str.get_strings([\n {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},\n {key: 'move', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n\n var context = {\n framework: framework,\n competencies: competenciestree\n };\n\n templates.render('tool_lp/competencies_move_tree', context)\n .done(function(tree) {\n new Dialogue(\n strings[0], // Move competency x.\n tree, // The move tree.\n initMovePopup\n );\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n };\n\n /**\n * Edit the selected competency.\n * @method editHandler\n */\n var editHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n id: competency.id,\n parentid: competency.parentid,\n pagecontextid: pageContextId\n };\n\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n /**\n * Re-render the page with the latest data.\n * @param {Object} context\n * @method reloadPage\n */\n var reloadPage = function(context) {\n templates.render('tool_lp/manage_competencies_page', context)\n .done(function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n })\n .fail(notification.exception);\n };\n\n /**\n * Perform a search and render the page with the new search results.\n * @param {Event} e\n * @method updateSearchHandler\n */\n var updateSearchHandler = function(e) {\n e.preventDefault();\n\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"up\". This only affects the sort order within the same branch of the tree.\n * @method moveUpHandler\n */\n var moveUpHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_up_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"down\". This only affects the sort order within the same branch of the tree.\n * @method moveDownHandler\n */\n var moveDownHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_down_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Open a dialogue to show all the courses using the selected competency.\n * @method seeCoursesHandler\n */\n var seeCoursesHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competency.id}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html, // The linked courses.\n initMovePopup\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method relateCompetenciesHandler\n */\n var relateCompetenciesHandler = function() {\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, relatedTarget.competencyframeworkid);\n pickerInstance.on('save', function(e, data) {\n var pendingPromise = new Pending();\n var compIds = data.competencyIds;\n\n var calls = [];\n $.each(compIds, function(index, value) {\n calls.push({\n methodname: 'core_competency_add_related_competency',\n args: {competencyid: value, relatedcompetencyid: relatedTarget.id}\n });\n });\n\n calls.push({\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: relatedTarget.id}\n });\n\n var promises = ajax.call(calls);\n\n promises[calls.length - 1].then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs([relatedTarget.id]);\n pickerInstance.display();\n };\n\n var ruleConfigHandler = function(e) {\n e.preventDefault();\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n ruleConfigInstance.setTargetCompetencyId(relatedTarget.id);\n ruleConfigInstance.display();\n };\n\n var ruleConfigSaveHandler = function(e, config) {\n var update = {\n id: relatedTarget.id,\n shortname: relatedTarget.shortname,\n idnumber: relatedTarget.idnumber,\n description: relatedTarget.description,\n descriptionformat: relatedTarget.descriptionformat,\n ruletype: config.ruletype,\n ruleoutcome: config.ruleoutcome,\n ruleconfig: config.ruleconfig\n };\n var promise = ajax.call([{\n methodname: 'core_competency_update_competency',\n args: {competency: update}\n }]);\n promise[0].then(function(result) {\n if (result) {\n relatedTarget.ruletype = config.ruletype;\n relatedTarget.ruleoutcome = config.ruleoutcome;\n relatedTarget.ruleconfig = config.ruleconfig;\n renderCompetencySummary(relatedTarget);\n }\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Delete a competency.\n * @method doDelete\n */\n var doDelete = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n str.get_strings([\n {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n * @method deleteCompetencyHandler\n */\n var deleteCompetencyHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency'),\n confirmMessage = 'deletecompetency';\n\n if (treeModel.hasRule(competency.parentid)) {\n confirmMessage = 'deletecompetencyparenthasrule';\n }\n\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp', param: competency.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragStart\n * @param {Event} e\n */\n var dragStart = function(e) {\n e.originalEvent.dataTransfer.setData('text', $(e.target).parent().data('id'));\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method allowDrop\n * @param {Event} e\n */\n var allowDrop = function(e) {\n e.originalEvent.dataTransfer.dropEffect = 'move';\n e.preventDefault();\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragEnter\n * @param {Event} e\n */\n var dragEnter = function(e) {\n e.preventDefault();\n $(this).addClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragLeave\n * @param {Event} e\n */\n var dragLeave = function(e) {\n e.preventDefault();\n $(this).removeClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dropOver\n * @param {Event} e\n */\n var dropOver = function(e) {\n e.preventDefault();\n moveSource = e.originalEvent.dataTransfer.getData('text');\n moveTarget = $(e.target).parent().data('id');\n $(this).removeClass('currentdragtarget');\n\n confirmMove();\n };\n\n /**\n * Deletes a related competency without confirmation.\n *\n * @param {Event} e The event that triggered the action.\n * @method deleteRelatedHandler\n */\n var deleteRelatedHandler = function(e) {\n e.preventDefault();\n\n var relatedid = this.id.substr(11);\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var removeRelated = ajax.call([\n {methodname: 'core_competency_remove_related_competency',\n args: {relatedcompetencyid: relatedid, competencyid: competency.id}},\n {methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}}\n ]);\n\n removeRelated[1].done(function(context) {\n templates.render('tool_lp/related_competencies', context).done(function(html) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n updatedRelatedCompetencies();\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Updates the competencies list (with relations) and add listeners.\n *\n * @method updatedRelatedCompetencies\n */\n var updatedRelatedCompetencies = function() {\n\n // Listeners to newly loaded related competencies.\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Object} competency The competency.\n * @method triggerCompetencyViewedEvent\n */\n var triggerCompetencyViewedEvent = function(competency) {\n if (competency.id !== selectedCompetencyId) {\n // Set the selected competency id.\n selectedCompetencyId = competency.id;\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competency.id}\n }]);\n }\n };\n\n /**\n * Return the taxonomy constant for a level.\n *\n * @param {Number} level The level.\n * @return {String}\n * @function getTaxonomyAtLevel\n */\n var getTaxonomyAtLevel = function(level) {\n var constant = taxonomiesConstants[level];\n if (!constant) {\n constant = 'competency';\n }\n return constant;\n };\n\n /**\n * Render the competency summary.\n *\n * @param {Object} competency The competency.\n */\n var renderCompetencySummary = function(competency) {\n var promise = $.Deferred().resolve().promise(),\n context = {};\n\n context.competency = competency;\n context.showdeleterelatedaction = true;\n context.showrelatedcompetencies = true;\n context.showrule = false;\n context.pluginbaseurl = url.relativeUrl('/admin/tool/lp');\n\n if (competency.ruleoutcome != Outcomes.NONE) {\n // Get the outcome and rule name.\n promise = Outcomes.getString(competency.ruleoutcome).then(function(str) {\n var name;\n $.each(rulesModules, function(index, modInfo) {\n if (modInfo.type == competency.ruletype) {\n name = modInfo.name;\n }\n });\n return [str, name];\n });\n }\n\n promise.then(function(strs) {\n if (typeof strs !== 'undefined') {\n context.showrule = true;\n context.rule = {\n outcome: strs[0],\n type: strs[1]\n };\n }\n return context;\n }).then(function(context) {\n return templates.render('tool_lp/competency_summary', context);\n }).then(function(html) {\n $('[data-region=\"competencyinfo\"]').html(html);\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n return templates.render('tool_lp/loading', {});\n }).then(function(html, js) {\n templates.replaceNodeContents('[data-region=\"relatedcompetencies\"]', html, js);\n return ajax.call([{\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}\n }])[0];\n }).then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Return the string \"Add \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strAddTaxonomy\n */\n var strAddTaxonomy = function(level) {\n return str.get_string('taxonomy_add_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strSelectedTaxonomy\n */\n var strSelectedTaxonomy = function(level) {\n return str.get_string('taxonomy_selected_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Handler when a node in the aria tree is selected.\n * @method selectionChanged\n * @param {Event} evt The event that triggered the selection change.\n * @param {Object} params The parameters for the event. Contains a list of selected nodes.\n * @return {Boolean}\n */\n var selectionChanged = function(evt, params) {\n var node = params.selected,\n id = $(node).data('id'),\n btn = $('[data-region=\"competencyactions\"] [data-action=\"add\"]'),\n actionMenu = $('[data-region=\"competencyactionsmenu\"]'),\n selectedTitle = $('[data-region=\"selected-competency\"]'),\n level = 0,\n sublevel = 1;\n\n menubar.closeAll();\n\n if (typeof id === \"undefined\") {\n // Assume this is the root of the tree.\n // Here we are only getting the text from the top of the tree, to do it we clone the tree,\n // remove all children and then call text on the result.\n $('[data-region=\"competencyinfo\"]').html(node.clone().children().remove().end().text());\n $('[data-region=\"competencyactions\"]').data('competency', null);\n actionMenu.hide();\n\n } else {\n var competency = treeModel.getCompetency(id);\n\n level = treeModel.getCompetencyLevel(id);\n sublevel = level + 1;\n\n actionMenu.show();\n $('[data-region=\"competencyactions\"]').data('competency', competency);\n renderCompetencySummary(competency);\n // Log Competency viewed event.\n triggerCompetencyViewedEvent(competency);\n }\n strSelectedTaxonomy(level).then(function(str) {\n selectedTitle.text(str);\n return;\n }).catch(notification.exception);\n\n strAddTaxonomy(sublevel).then(function(str) {\n btn.show()\n .find('[data-region=\"term\"]')\n .text(str);\n return;\n }).catch(notification.exception);\n\n // We handled this event so consume it.\n evt.preventDefault();\n return false;\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @function parseTaxonomies\n * @param {String} taxonomiesstr Comma separated list of taxonomies.\n * @return {Array} of level => taxonomystr\n */\n var parseTaxonomies = function(taxonomiesstr) {\n var all = taxonomiesstr.split(',');\n all.unshift(\"\");\n delete all[0];\n\n // Note we don't need to fill holes, because other functions check for empty anyway.\n return all;\n };\n\n return {\n /**\n * Initialise this page (attach event handlers etc).\n *\n * @method init\n * @param {Object} model The tree model provides some useful functions for loading and searching competencies.\n * @param {Number} pagectxid The page context ID.\n * @param {Object} taxonomies Constants indexed by level.\n * @param {Object} rulesMods The modules of the rules.\n */\n init: function(model, pagectxid, taxonomies, rulesMods) {\n treeModel = model;\n pageContextId = pagectxid;\n taxonomiesConstants = parseTaxonomies(taxonomies);\n rulesModules = rulesMods;\n\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').on('click', addHandler);\n\n menubar.enhance('.competencyactionsmenu', {\n '[data-action=\"edit\"]': editHandler,\n '[data-action=\"delete\"]': deleteCompetencyHandler,\n '[data-action=\"move\"]': moveHandler,\n '[data-action=\"moveup\"]': moveUpHandler,\n '[data-action=\"movedown\"]': moveDownHandler,\n '[data-action=\"linkedcourses\"]': seeCoursesHandler,\n '[data-action=\"relatedcompetencies\"]': relateCompetenciesHandler.bind(this),\n '[data-action=\"competencyrules\"]': ruleConfigHandler.bind(this)\n });\n $('[data-region=\"competencyactionsmenu\"]').hide();\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').hide();\n\n $('[data-region=\"filtercompetencies\"]').on('submit', updateSearchHandler);\n // Simple html5 drag drop because we already added an accessible alternative.\n var top = $('[data-region=\"managecompetencies\"] [data-enhance=\"tree\"]');\n top.on('dragstart', 'li>span', dragStart)\n .on('dragover', 'li>span', allowDrop)\n .on('dragenter', 'li>span', dragEnter)\n .on('dragleave', 'li>span', dragLeave)\n .on('drop', 'li>span', dropOver);\n\n model.on('selectionchanged', selectionChanged);\n\n // Prepare the configuration tool.\n ruleConfigInstance = new RuleConfig(treeModel, rulesModules);\n ruleConfigInstance.on('save', ruleConfigSaveHandler.bind(this));\n }\n };\n});\n"],"file":"competencyactions.min.js"} \ No newline at end of file +{"version":3,"file":"competencyactions.min.js","sources":["../src/competencyactions.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 * Handle selection changes and actions on the competency tree.\n *\n * @module tool_lp/competencyactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/url',\n 'core/templates',\n 'core/notification',\n 'core/str',\n 'core/ajax',\n 'tool_lp/dragdrop-reorder',\n 'tool_lp/tree',\n 'tool_lp/dialogue',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker',\n 'tool_lp/competency_outcomes',\n 'tool_lp/competencyruleconfig',\n 'core/pending',\n ],\n function(\n $, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig, Pending\n ) {\n\n // Private variables and functions.\n /** @var {Object} treeModel - This is an object representing the nodes in the tree. */\n var treeModel = null;\n /** @var {Node} moveSource - The start of a drag operation */\n var moveSource = null;\n /** @var {Node} moveTarget - The end of a drag operation */\n var moveTarget = null;\n /** @var {Number} pageContextId The page context ID. */\n var pageContextId;\n /** @var {Object} Picker instance. */\n var pickerInstance;\n /** @var {Object} Rule config instance. */\n var ruleConfigInstance;\n /** @var {Object} The competency we're picking a relation to. */\n var relatedTarget;\n /** @var {Object} Taxonomy constants indexed per level. */\n var taxonomiesConstants;\n /** @var {Array} The rules modules. Values are object containing type, namd and amd. */\n var rulesModules;\n /** @var {Number} the selected competency ID. */\n var selectedCompetencyId = null;\n\n /**\n * Respond to choosing the \"Add\" menu item for the selected node in the tree.\n * @method addHandler\n */\n var addHandler = function() {\n var parent = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n pagecontextid: pageContextId\n };\n\n if (parent !== null) {\n // We are adding at a sub node.\n params.parentid = parent.id;\n }\n\n var relocate = function() {\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n if (parent !== null && treeModel.hasRule(parent.id)) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname},\n {key: 'yes', component: 'core'},\n {key: 'no', component: 'core'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0],\n strings[1],\n strings[2],\n strings[3],\n relocate\n );\n }).fail(notification.exception);\n } else {\n relocate();\n }\n };\n\n /**\n * A source and destination has been chosen - so time to complete a move.\n * @method doMove\n */\n var doMove = function() {\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n var requests = ajax.call([{\n methodname: 'core_competency_set_parent_competency',\n args: {competencyid: moveSource, parentid: moveTarget}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Confirms a competency move.\n *\n * @method confirmMove\n */\n var confirmMove = function() {\n moveTarget = typeof moveTarget === \"undefined\" ? 0 : moveTarget;\n if (moveTarget == moveSource) {\n // No move to do.\n return;\n }\n\n var targetComp = treeModel.getCompetency(moveTarget) || {},\n sourceComp = treeModel.getCompetency(moveSource) || {},\n confirmMessage = 'movecompetencywillresetrules',\n showConfirm = false;\n\n // We shouldn't be moving the competency to the same parent.\n if (sourceComp.parentid == moveTarget) {\n return;\n }\n\n // If we are moving to a child of self.\n if (targetComp.path && targetComp.path.indexOf('/' + sourceComp.id + '/') >= 0) {\n confirmMessage = 'movecompetencytochildofselfwillresetrules';\n\n // Show a confirmation if self has rules, as they'll disappear.\n showConfirm = showConfirm || treeModel.hasRule(sourceComp.id);\n }\n\n // Show a confirmation if the current parent, or the destination have rules.\n showConfirm = showConfirm || (treeModel.hasRule(targetComp.id) || treeModel.hasRule(sourceComp.parentid));\n\n // Show confirm, and/or do the things.\n if (showConfirm) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp'},\n {key: 'yes', component: 'moodle'},\n {key: 'no', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doMove\n );\n }).fail(notification.exception);\n\n } else {\n doMove();\n }\n };\n\n /**\n * A move competency popup was opened - initialise the aria tree in it.\n * @method initMovePopup\n * @param {dialogue} popup The tool_lp/dialogue that was created.\n */\n var initMovePopup = function(popup) {\n var body = $(popup.getContent());\n var treeRoot = body.find('[data-enhance=movetree]');\n var tree = new Ariatree(treeRoot, false);\n tree.on('selectionchanged', function(evt, params) {\n var target = params.selected;\n moveTarget = $(target).data('id');\n });\n treeRoot.show();\n\n body.on('click', '[data-action=\"move\"]', function() {\n popup.close();\n confirmMove();\n });\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Turn a flat list of competencies into a tree structure (recursive).\n * @method addCompetencyChildren\n * @param {Object} parent The current parent node in the tree\n * @param {Object[]} competencies The flat list of competencies\n */\n var addCompetencyChildren = function(parent, competencies) {\n var i;\n\n for (i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n };\n\n /**\n * A node was chosen and \"Move\" was selected from the menu. Open a popup to select the target.\n * @param {Event} e\n * @method moveHandler\n */\n var moveHandler = function(e) {\n e.preventDefault();\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n // Remember what we are moving.\n moveSource = competency.id;\n\n // Load data for the template.\n var requests = ajax.call([\n {\n methodname: 'core_competency_search_competencies',\n args: {\n competencyframeworkid: competency.competencyframeworkid,\n searchtext: ''\n }\n }, {\n methodname: 'core_competency_read_competency_framework',\n args: {\n id: competency.competencyframeworkid\n }\n }\n ]);\n\n // When all data has arrived, continue.\n $.when.apply(null, requests).done(function(competencies, framework) {\n\n // Expand the list of competencies into a tree.\n var i;\n var competenciestree = [];\n for (i = 0; i < competencies.length; i++) {\n var onecompetency = competencies[i];\n if (onecompetency.parentid == \"0\") {\n onecompetency.children = [];\n onecompetency.haschildren = 0;\n competenciestree[competenciestree.length] = onecompetency;\n addCompetencyChildren(onecompetency, competencies);\n }\n }\n\n str.get_strings([\n {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},\n {key: 'move', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n\n var context = {\n framework: framework,\n competencies: competenciestree\n };\n\n templates.render('tool_lp/competencies_move_tree', context)\n .done(function(tree) {\n new Dialogue(\n strings[0], // Move competency x.\n tree, // The move tree.\n initMovePopup\n );\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n };\n\n /**\n * Edit the selected competency.\n * @method editHandler\n */\n var editHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n id: competency.id,\n parentid: competency.parentid,\n pagecontextid: pageContextId\n };\n\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n /**\n * Re-render the page with the latest data.\n * @param {Object} context\n * @method reloadPage\n */\n var reloadPage = function(context) {\n templates.render('tool_lp/manage_competencies_page', context)\n .done(function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n })\n .fail(notification.exception);\n };\n\n /**\n * Perform a search and render the page with the new search results.\n * @param {Event} e\n * @method updateSearchHandler\n */\n var updateSearchHandler = function(e) {\n e.preventDefault();\n\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"up\". This only affects the sort order within the same branch of the tree.\n * @method moveUpHandler\n */\n var moveUpHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_up_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"down\". This only affects the sort order within the same branch of the tree.\n * @method moveDownHandler\n */\n var moveDownHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_down_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Open a dialogue to show all the courses using the selected competency.\n * @method seeCoursesHandler\n */\n var seeCoursesHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competency.id}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html, // The linked courses.\n initMovePopup\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method relateCompetenciesHandler\n */\n var relateCompetenciesHandler = function() {\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, relatedTarget.competencyframeworkid);\n pickerInstance.on('save', function(e, data) {\n var pendingPromise = new Pending();\n var compIds = data.competencyIds;\n\n var calls = [];\n $.each(compIds, function(index, value) {\n calls.push({\n methodname: 'core_competency_add_related_competency',\n args: {competencyid: value, relatedcompetencyid: relatedTarget.id}\n });\n });\n\n calls.push({\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: relatedTarget.id}\n });\n\n var promises = ajax.call(calls);\n\n promises[calls.length - 1].then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs([relatedTarget.id]);\n pickerInstance.display();\n };\n\n var ruleConfigHandler = function(e) {\n e.preventDefault();\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n ruleConfigInstance.setTargetCompetencyId(relatedTarget.id);\n ruleConfigInstance.display();\n };\n\n var ruleConfigSaveHandler = function(e, config) {\n var update = {\n id: relatedTarget.id,\n shortname: relatedTarget.shortname,\n idnumber: relatedTarget.idnumber,\n description: relatedTarget.description,\n descriptionformat: relatedTarget.descriptionformat,\n ruletype: config.ruletype,\n ruleoutcome: config.ruleoutcome,\n ruleconfig: config.ruleconfig\n };\n var promise = ajax.call([{\n methodname: 'core_competency_update_competency',\n args: {competency: update}\n }]);\n promise[0].then(function(result) {\n if (result) {\n relatedTarget.ruletype = config.ruletype;\n relatedTarget.ruleoutcome = config.ruleoutcome;\n relatedTarget.ruleconfig = config.ruleconfig;\n renderCompetencySummary(relatedTarget);\n }\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Delete a competency.\n * @method doDelete\n */\n var doDelete = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n str.get_strings([\n {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n * @method deleteCompetencyHandler\n */\n var deleteCompetencyHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency'),\n confirmMessage = 'deletecompetency';\n\n if (treeModel.hasRule(competency.parentid)) {\n confirmMessage = 'deletecompetencyparenthasrule';\n }\n\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp', param: competency.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragStart\n * @param {Event} e\n */\n var dragStart = function(e) {\n e.originalEvent.dataTransfer.setData('text', $(e.target).parent().data('id'));\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method allowDrop\n * @param {Event} e\n */\n var allowDrop = function(e) {\n e.originalEvent.dataTransfer.dropEffect = 'move';\n e.preventDefault();\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragEnter\n * @param {Event} e\n */\n var dragEnter = function(e) {\n e.preventDefault();\n $(this).addClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragLeave\n * @param {Event} e\n */\n var dragLeave = function(e) {\n e.preventDefault();\n $(this).removeClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dropOver\n * @param {Event} e\n */\n var dropOver = function(e) {\n e.preventDefault();\n moveSource = e.originalEvent.dataTransfer.getData('text');\n moveTarget = $(e.target).parent().data('id');\n $(this).removeClass('currentdragtarget');\n\n confirmMove();\n };\n\n /**\n * Deletes a related competency without confirmation.\n *\n * @param {Event} e The event that triggered the action.\n * @method deleteRelatedHandler\n */\n var deleteRelatedHandler = function(e) {\n e.preventDefault();\n\n var relatedid = this.id.substr(11);\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var removeRelated = ajax.call([\n {methodname: 'core_competency_remove_related_competency',\n args: {relatedcompetencyid: relatedid, competencyid: competency.id}},\n {methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}}\n ]);\n\n removeRelated[1].done(function(context) {\n templates.render('tool_lp/related_competencies', context).done(function(html) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n updatedRelatedCompetencies();\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Updates the competencies list (with relations) and add listeners.\n *\n * @method updatedRelatedCompetencies\n */\n var updatedRelatedCompetencies = function() {\n\n // Listeners to newly loaded related competencies.\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Object} competency The competency.\n * @method triggerCompetencyViewedEvent\n */\n var triggerCompetencyViewedEvent = function(competency) {\n if (competency.id !== selectedCompetencyId) {\n // Set the selected competency id.\n selectedCompetencyId = competency.id;\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competency.id}\n }]);\n }\n };\n\n /**\n * Return the taxonomy constant for a level.\n *\n * @param {Number} level The level.\n * @return {String}\n * @function getTaxonomyAtLevel\n */\n var getTaxonomyAtLevel = function(level) {\n var constant = taxonomiesConstants[level];\n if (!constant) {\n constant = 'competency';\n }\n return constant;\n };\n\n /**\n * Render the competency summary.\n *\n * @param {Object} competency The competency.\n */\n var renderCompetencySummary = function(competency) {\n var promise = $.Deferred().resolve().promise(),\n context = {};\n\n context.competency = competency;\n context.showdeleterelatedaction = true;\n context.showrelatedcompetencies = true;\n context.showrule = false;\n context.pluginbaseurl = url.relativeUrl('/admin/tool/lp');\n\n if (competency.ruleoutcome != Outcomes.NONE) {\n // Get the outcome and rule name.\n promise = Outcomes.getString(competency.ruleoutcome).then(function(str) {\n var name;\n $.each(rulesModules, function(index, modInfo) {\n if (modInfo.type == competency.ruletype) {\n name = modInfo.name;\n }\n });\n return [str, name];\n });\n }\n\n promise.then(function(strs) {\n if (typeof strs !== 'undefined') {\n context.showrule = true;\n context.rule = {\n outcome: strs[0],\n type: strs[1]\n };\n }\n return context;\n }).then(function(context) {\n return templates.render('tool_lp/competency_summary', context);\n }).then(function(html) {\n $('[data-region=\"competencyinfo\"]').html(html);\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n return templates.render('tool_lp/loading', {});\n }).then(function(html, js) {\n templates.replaceNodeContents('[data-region=\"relatedcompetencies\"]', html, js);\n return ajax.call([{\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}\n }])[0];\n }).then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Return the string \"Add \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strAddTaxonomy\n */\n var strAddTaxonomy = function(level) {\n return str.get_string('taxonomy_add_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strSelectedTaxonomy\n */\n var strSelectedTaxonomy = function(level) {\n return str.get_string('taxonomy_selected_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Handler when a node in the aria tree is selected.\n * @method selectionChanged\n * @param {Event} evt The event that triggered the selection change.\n * @param {Object} params The parameters for the event. Contains a list of selected nodes.\n * @return {Boolean}\n */\n var selectionChanged = function(evt, params) {\n var node = params.selected,\n id = $(node).data('id'),\n btn = $('[data-region=\"competencyactions\"] [data-action=\"add\"]'),\n actionMenu = $('[data-region=\"competencyactionsmenu\"]'),\n selectedTitle = $('[data-region=\"selected-competency\"]'),\n level = 0,\n sublevel = 1;\n\n menubar.closeAll();\n\n if (typeof id === \"undefined\") {\n // Assume this is the root of the tree.\n // Here we are only getting the text from the top of the tree, to do it we clone the tree,\n // remove all children and then call text on the result.\n $('[data-region=\"competencyinfo\"]').html(node.clone().children().remove().end().text());\n $('[data-region=\"competencyactions\"]').data('competency', null);\n actionMenu.hide();\n\n } else {\n var competency = treeModel.getCompetency(id);\n\n level = treeModel.getCompetencyLevel(id);\n sublevel = level + 1;\n\n actionMenu.show();\n $('[data-region=\"competencyactions\"]').data('competency', competency);\n renderCompetencySummary(competency);\n // Log Competency viewed event.\n triggerCompetencyViewedEvent(competency);\n }\n strSelectedTaxonomy(level).then(function(str) {\n selectedTitle.text(str);\n return;\n }).catch(notification.exception);\n\n strAddTaxonomy(sublevel).then(function(str) {\n btn.show()\n .find('[data-region=\"term\"]')\n .text(str);\n return;\n }).catch(notification.exception);\n\n // We handled this event so consume it.\n evt.preventDefault();\n return false;\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @function parseTaxonomies\n * @param {String} taxonomiesstr Comma separated list of taxonomies.\n * @return {Array} of level => taxonomystr\n */\n var parseTaxonomies = function(taxonomiesstr) {\n var all = taxonomiesstr.split(',');\n all.unshift(\"\");\n delete all[0];\n\n // Note we don't need to fill holes, because other functions check for empty anyway.\n return all;\n };\n\n return {\n /**\n * Initialise this page (attach event handlers etc).\n *\n * @method init\n * @param {Object} model The tree model provides some useful functions for loading and searching competencies.\n * @param {Number} pagectxid The page context ID.\n * @param {Object} taxonomies Constants indexed by level.\n * @param {Object} rulesMods The modules of the rules.\n */\n init: function(model, pagectxid, taxonomies, rulesMods) {\n treeModel = model;\n pageContextId = pagectxid;\n taxonomiesConstants = parseTaxonomies(taxonomies);\n rulesModules = rulesMods;\n\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').on('click', addHandler);\n\n menubar.enhance('.competencyactionsmenu', {\n '[data-action=\"edit\"]': editHandler,\n '[data-action=\"delete\"]': deleteCompetencyHandler,\n '[data-action=\"move\"]': moveHandler,\n '[data-action=\"moveup\"]': moveUpHandler,\n '[data-action=\"movedown\"]': moveDownHandler,\n '[data-action=\"linkedcourses\"]': seeCoursesHandler,\n '[data-action=\"relatedcompetencies\"]': relateCompetenciesHandler.bind(this),\n '[data-action=\"competencyrules\"]': ruleConfigHandler.bind(this)\n });\n $('[data-region=\"competencyactionsmenu\"]').hide();\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').hide();\n\n $('[data-region=\"filtercompetencies\"]').on('submit', updateSearchHandler);\n // Simple html5 drag drop because we already added an accessible alternative.\n var top = $('[data-region=\"managecompetencies\"] [data-enhance=\"tree\"]');\n top.on('dragstart', 'li>span', dragStart)\n .on('dragover', 'li>span', allowDrop)\n .on('dragenter', 'li>span', dragEnter)\n .on('dragleave', 'li>span', dragLeave)\n .on('drop', 'li>span', dropOver);\n\n model.on('selectionchanged', selectionChanged);\n\n // Prepare the configuration tool.\n ruleConfigInstance = new RuleConfig(treeModel, rulesModules);\n ruleConfigInstance.on('save', ruleConfigSaveHandler.bind(this));\n }\n };\n});\n"],"names":["define","$","url","templates","notification","str","ajax","dragdrop","Ariatree","Dialogue","menubar","Picker","Outcomes","RuleConfig","Pending","pageContextId","pickerInstance","ruleConfigInstance","relatedTarget","taxonomiesConstants","rulesModules","treeModel","moveSource","moveTarget","selectedCompetencyId","addHandler","parent","data","params","competencyframeworkid","getCompetencyFrameworkId","pagecontextid","parentid","id","relocate","queryparams","param","window","location","relativeUrl","hasRule","get_strings","key","component","shortname","done","strings","confirm","fail","exception","doMove","frameworkid","call","methodname","args","competencyid","search","val","reloadPage","confirmMove","targetComp","getCompetency","sourceComp","confirmMessage","showConfirm","path","indexOf","initMovePopup","popup","body","getContent","treeRoot","find","on","evt","target","selected","show","close","addCompetencyChildren","competencies","i","length","haschildren","children","moveHandler","e","preventDefault","competency","requests","searchtext","when","apply","framework","competenciestree","onecompetency","context","render","tree","editHandler","newhtml","newjs","replaceWith","runTemplateJS","updateSearchHandler","moveUpHandler","moveDownHandler","seeCoursesHandler","courses","html","get_string","linkedcourses","relateCompetenciesHandler","pendingPromise","compIds","competencyIds","calls","each","index","value","push","relatedcompetencyid","then","js","updatedRelatedCompetencies","resolve","catch","setDisallowedCompetencyIDs","display","ruleConfigHandler","setTargetCompetencyId","ruleConfigSaveHandler","config","update","idnumber","description","descriptionformat","ruletype","ruleoutcome","ruleconfig","result","renderCompetencySummary","doDelete","success","alert","deleteCompetencyHandler","dragStart","originalEvent","dataTransfer","setData","allowDrop","dropEffect","dragEnter","this","addClass","dragLeave","removeClass","dropOver","getData","deleteRelatedHandler","relatedid","substr","getTaxonomyAtLevel","level","constant","promise","Deferred","showdeleterelatedaction","showrelatedcompetencies","showrule","pluginbaseurl","NONE","getString","name","modInfo","type","strs","rule","outcome","replaceNodeContents","selectionChanged","node","btn","actionMenu","selectedTitle","sublevel","closeAll","clone","remove","end","text","hide","getCompetencyLevel","triggerCompetencyViewedEvent","strSelectedTaxonomy","strAddTaxonomy","init","model","pagectxid","taxonomies","rulesMods","all","split","unshift","enhance","bind"],"mappings":";;;;;;;AAsBAA,mCAAO,CAAC,SACA,WACA,iBACA,oBACA,WACA,YACA,2BACA,eACA,mBACA,kBACA,2BACA,8BACA,+BACA,iBAED,SACKC,EAAGC,IAAKC,UAAWC,aAAcC,IAAKC,KAAMC,SAAUC,SAAUC,SAAUC,QAASC,OAAQC,SAAUC,WAAYC,aAWrHC,cAEAC,eAEAC,mBAEAC,cAEAC,oBAEAC,aAhBAC,UAAY,KAEZC,WAAa,KAEbC,WAAa,KAcbC,qBAAuB,KAMvBC,WAAa,eACTC,OAASzB,EAAE,qCAAqC0B,KAAK,cAErDC,OAAS,CACTC,sBAAuBR,UAAUS,2BACjCC,cAAehB,eAGJ,OAAXW,SAEAE,OAAOI,SAAWN,OAAOO,QAGzBC,SAAW,eACPC,YAAclC,EAAEmC,MAAMR,QAC1BS,OAAOC,SAAWpC,IAAIqC,YAAY,qCAAuCJ,cAG9D,OAAXT,QAAmBL,UAAUmB,QAAQd,OAAOO,IAC5C5B,IAAIoC,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,sCAAuCC,UAAW,UAAWP,MAAOV,OAAOkB,WACjF,CAACF,IAAK,MAAOC,UAAW,QACxB,CAACD,IAAK,KAAMC,UAAW,UACxBE,MAAK,SAASC,SACb1C,aAAa2C,QACTD,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRZ,aAELc,KAAK5C,aAAa6C,WAErBf,YAQJgB,OAAS,eACLC,YAAclD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G,qCACE8C,+CACF5D,qCACEoB,yCACEC,gDACKC,wDACMK,0BAA0B6F,KAAKpD,wCACnCxB,kBAAkB4E,KAAKpD,QAE9DxJ,EAAE,yCAAyC8L,OAC3C9L,EAAE,yDAAyD8L,OAE3D9L,EAAE,sCAAsCwE,GAAG,SAAU+B,qBAE3CvG,EAAE,4DACRwE,GAAG,YAAa,UAAWyE,WAC1BzE,GAAG,WAAY,UAAW6E,WAC1B7E,GAAG,YAAa,UAAW+E,WAC3B/E,GAAG,YAAa,UAAWkF,WAC3BlF,GAAG,OAAQ,UAAWoF,UAE3BwC,MAAM5H,GAAG,mBAAoB2G,mBAG7BnK,mBAAqB,IAAIJ,WAAWQ,UAAWD,eAC5BqD,GAAG,OAAQ0D,sBAAsB0E,KAAKpD"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencydialogue.min.js b/admin/tool/lp/amd/build/competencydialogue.min.js index 53a0e337f32..c06ba3594da 100644 --- a/admin/tool/lp/amd/build/competencydialogue.min.js +++ b/admin/tool/lp/amd/build/competencydialogue.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competencydialogue",["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/dialogue"],function(a,b,c,d,e,f){var g,h=function(){};h.prototype.triggerCompetencyViewedEvent=function(a){c.call([{methodname:"core_competency_competency_viewed",args:{id:a}}])};h.prototype.showDialogue=function(a,c){var e=this.getCompetencyDataPromise(a,c),g=this;e.done(function(c){d.render("tool_lp/competency_summary",c).done(function(b){g.triggerCompetencyViewedEvent(a);new f(c.competency.shortname,b)}).fail(b.exception)}).fail(b.exception)};h.prototype.showDialogueFromData=function(a){var c=this;d.render("tool_lp/competency_summary",a).done(function(b){c.triggerCompetencyViewedEvent(a.id);new f(a.shortname,b,c.enhanceDialogue)}).fail(b.exception)};h.prototype.clickEventHandler=function(b){var c=b.data.compdialogue,d=a(b.currentTarget),e=d.data("id"),f=!d.data("excluderelated"),g=d.data("includecourses");c.showDialogue(e,{includerelated:f,includecourses:g});b.preventDefault()};h.prototype.getCompetencyDataPromise=function(a,d){var e=c.call([{methodname:"tool_lp_data_for_competency_summary",args:{competencyid:a,includerelated:d.includerelated||!1,includecourses:d.includecourses||!1}}]);return e[0].then(function(a){return a}).fail(b.exception)};return{init:function init(){if("undefined"!=typeof g){return}g=new h;a("body").delegate("[data-action=\"competency-dialogue\"]","click",{compdialogue:g},g.clickEventHandler.bind(g))}}}); -//# sourceMappingURL=competencydialogue.min.js.map +/** + * Display Competency in dialogue box. + * + * @module tool_lp/Competencydialogue + * @copyright 2015 Issam Taboubi + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competencydialogue",["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/dialogue"],(function($,notification,ajax,templates,str,Dialogue){var instance,Competencydialogue=function(){};return Competencydialogue.prototype.triggerCompetencyViewedEvent=function(competencyId){ajax.call([{methodname:"core_competency_competency_viewed",args:{id:competencyId}}])},Competencydialogue.prototype.showDialogue=function(competencyid,options){var datapromise=this.getCompetencyDataPromise(competencyid,options),localthis=this;datapromise.done((function(data){templates.render("tool_lp/competency_summary",data).done((function(html){localthis.triggerCompetencyViewedEvent(competencyid),new Dialogue(data.competency.shortname,html)})).fail(notification.exception)})).fail(notification.exception)},Competencydialogue.prototype.showDialogueFromData=function(dataSource){var localthis=this;templates.render("tool_lp/competency_summary",dataSource).done((function(html){localthis.triggerCompetencyViewedEvent(dataSource.id),new Dialogue(dataSource.shortname,html,localthis.enhanceDialogue)})).fail(notification.exception)},Competencydialogue.prototype.clickEventHandler=function(e){var compdialogue=e.data.compdialogue,currentTarget=$(e.currentTarget),competencyid=currentTarget.data("id"),includerelated=!currentTarget.data("excluderelated"),includecourses=currentTarget.data("includecourses");compdialogue.showDialogue(competencyid,{includerelated:includerelated,includecourses:includecourses}),e.preventDefault()},Competencydialogue.prototype.getCompetencyDataPromise=function(competencyid,options){return ajax.call([{methodname:"tool_lp_data_for_competency_summary",args:{competencyid:competencyid,includerelated:options.includerelated||!1,includecourses:options.includecourses||!1}}])[0].then((function(context){return context})).fail(notification.exception)},{init:function(){void 0===instance&&(instance=new Competencydialogue,$("body").delegate('[data-action="competency-dialogue"]',"click",{compdialogue:instance},instance.clickEventHandler.bind(instance)))}}})); + +//# sourceMappingURL=competencydialogue.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencydialogue.min.js.map b/admin/tool/lp/amd/build/competencydialogue.min.js.map index 9ed99d48920..3a66a43e0e3 100644 --- a/admin/tool/lp/amd/build/competencydialogue.min.js.map +++ b/admin/tool/lp/amd/build/competencydialogue.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencydialogue.js"],"names":["define","$","notification","ajax","templates","str","Dialogue","instance","Competencydialogue","prototype","triggerCompetencyViewedEvent","competencyId","call","methodname","args","id","showDialogue","competencyid","options","datapromise","getCompetencyDataPromise","localthis","done","data","render","html","competency","shortname","fail","exception","showDialogueFromData","dataSource","enhanceDialogue","clickEventHandler","e","compdialogue","currentTarget","includerelated","includecourses","preventDefault","requests","then","context","init","delegate","bind"],"mappings":"AAsBAA,OAAM,8BAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,UAJD,CAKC,kBALD,CAAD,CAMC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAgDC,CAAhD,CAA0D,IAOzDC,CAAAA,CAPyD,CAYzDC,CAAkB,CAAG,UAAW,CAEnC,CAd4D,CAsB7DA,CAAkB,CAACC,SAAnB,CAA6BC,4BAA7B,CAA4D,SAASC,CAAT,CAAuB,CAC/ER,CAAI,CAACS,IAAL,CAAU,CAAC,CACHC,UAAU,CAAE,mCADT,CAEHC,IAAI,CAAE,CAACC,EAAE,CAAEJ,CAAL,CAFH,CAAD,CAAV,CAIH,CALD,CAcAH,CAAkB,CAACC,SAAnB,CAA6BO,YAA7B,CAA4C,SAASC,CAAT,CAAuBC,CAA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Aa,CAACb,IAAd,CAAmB,gBAAnB,CALkC,CAMrDe,CAAc,CAAGF,CAAa,CAACb,IAAd,CAAmB,gBAAnB,CANoC,CASzDY,CAAY,CAACnB,YAAb,CAA0BC,CAA1B,CAAwC,CACpCoB,cAAc,CAAEA,CADoB,CAEpCC,cAAc,CAAEA,CAFoB,CAAxC,EAIAJ,CAAC,CAACK,cAAF,EACH,CAdD,CAwBA/B,CAAkB,CAACC,SAAnB,CAA6BW,wBAA7B,CAAwD,SAASH,CAAT,CAAuBC,CAAvB,CAAgC,CAEpF,GAAIsB,CAAAA,CAAQ,CAAGrC,CAAI,CAACS,IAAL,CAAU,CACrB,CAACC,UAAU,CAAE,qCAAb,CACEC,IAAI,CAAE,CAACG,YAAY,CAAEA,CAAf,CACEoB,cAAc,CAAEnB,CAAO,CAACmB,cAAR,IADlB,CAEEC,cAAc,CAAEpB,CAAO,CAACoB,cAAR,IAFlB,CADR,CADqB,CAAV,CAAf,CASA,MAAOE,CAAAA,CAAQ,CAAC,CAAD,CAAR,CAAYC,IAAZ,CAAiB,SAASC,CAAT,CAAkB,CACvC,MAAOA,CAAAA,CACT,CAFM,EAEJd,IAFI,CAEC1B,CAAY,CAAC2B,SAFd,CAGV,CAdD,CAgBA,MAAuD,CAOnDc,IAAI,CAAE,eAAW,CACb,GAAwB,WAApB,QAAOpC,CAAAA,CAAX,CAAqC,CACjC,MACH,CAGDA,CAAQ,CAAG,GAAIC,CAAAA,CAAf,CACAP,CAAC,CAAC,MAAD,CAAD,CAAU2C,QAAV,CAAmB,uCAAnB,CAA0D,OAA1D,CAAmE,CAACT,YAAY,CAAE5B,CAAf,CAAnE,CACIA,CAAQ,CAAC0B,iBAAT,CAA2BY,IAA3B,CAAgCtC,CAAhC,CADJ,CAEH,CAhBkD,CAkB1D,CAtJK,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 * Display Competency in dialogue box.\n *\n * @module tool_lp/Competencydialogue\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/dialogue'],\n function($, notification, ajax, templates, str, Dialogue) {\n\n /**\n * The main instance we'll be working with.\n *\n * @type {Competencydialogue}\n */\n var instance;\n\n /**\n * Constructor for CompetencyDialogue.\n */\n var Competencydialogue = function() {\n // Intentionally left empty.\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Number} competencyId The competency ID.\n * @method triggerCompetencyViewedEvent\n */\n Competencydialogue.prototype.triggerCompetencyViewedEvent = function(competencyId) {\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competencyId}\n }]);\n };\n\n /**\n * Display a dialogue box by competencyid.\n *\n * @param {Number} competencyid The competency ID.\n * @param {Object} options The options.\n * @method showDialogue\n */\n Competencydialogue.prototype.showDialogue = function(competencyid, options) {\n\n var datapromise = this.getCompetencyDataPromise(competencyid, options);\n var localthis = this;\n datapromise.done(function(data) {\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', data)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(competencyid);\n\n // Show the dialogue.\n new Dialogue(\n data.competency.shortname,\n html\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Display a dialogue box from data.\n *\n * @param {Object} dataSource data to be used to display dialogue box\n * @method showDialogueFromData\n */\n Competencydialogue.prototype.showDialogueFromData = function(dataSource) {\n\n var localthis = this;\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', dataSource)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(dataSource.id);\n\n // Show the dialogue.\n new Dialogue(\n dataSource.shortname,\n html,\n localthis.enhanceDialogue\n );\n }).fail(notification.exception);\n };\n\n /**\n * The action on the click event.\n *\n * @param {Event} e event click\n * @method clickEventHandler\n */\n Competencydialogue.prototype.clickEventHandler = function(e) {\n\n var compdialogue = e.data.compdialogue;\n var currentTarget = $(e.currentTarget);\n var competencyid = currentTarget.data('id');\n var includerelated = !(currentTarget.data('excluderelated'));\n var includecourses = currentTarget.data('includecourses');\n\n // Show the dialogue box.\n compdialogue.showDialogue(competencyid, {\n includerelated: includerelated,\n includecourses: includecourses\n });\n e.preventDefault();\n };\n\n /**\n * Get a promise on data competency.\n *\n * @param {Number} competencyid\n * @param {Object} options\n * @return {Promise} return promise on data request\n * @method getCompetencyDataPromise\n */\n Competencydialogue.prototype.getCompetencyDataPromise = function(competencyid, options) {\n\n var requests = ajax.call([\n {methodname: 'tool_lp_data_for_competency_summary',\n args: {competencyid: competencyid,\n includerelated: options.includerelated || false,\n includecourses: options.includecourses || false\n }\n }\n ]);\n\n return requests[0].then(function(context) {\n return context;\n }).fail(notification.exception);\n };\n\n return /** @alias module:tool_lp/competencydialogue */ {\n\n /**\n * Initialise the competency dialogue module.\n *\n * Only the first call matters.\n */\n init: function() {\n if (typeof instance !== 'undefined') {\n return;\n }\n\n // Instantiate the one instance and delegate event on the body.\n instance = new Competencydialogue();\n $('body').delegate('[data-action=\"competency-dialogue\"]', 'click', {compdialogue: instance},\n instance.clickEventHandler.bind(instance));\n }\n };\n});\n"],"file":"competencydialogue.min.js"} \ No newline at end of file +{"version":3,"file":"competencydialogue.min.js","sources":["../src/competencydialogue.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 * Display Competency in dialogue box.\n *\n * @module tool_lp/Competencydialogue\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/dialogue'],\n function($, notification, ajax, templates, str, Dialogue) {\n\n /**\n * The main instance we'll be working with.\n *\n * @type {Competencydialogue}\n */\n var instance;\n\n /**\n * Constructor for CompetencyDialogue.\n */\n var Competencydialogue = function() {\n // Intentionally left empty.\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Number} competencyId The competency ID.\n * @method triggerCompetencyViewedEvent\n */\n Competencydialogue.prototype.triggerCompetencyViewedEvent = function(competencyId) {\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competencyId}\n }]);\n };\n\n /**\n * Display a dialogue box by competencyid.\n *\n * @param {Number} competencyid The competency ID.\n * @param {Object} options The options.\n * @method showDialogue\n */\n Competencydialogue.prototype.showDialogue = function(competencyid, options) {\n\n var datapromise = this.getCompetencyDataPromise(competencyid, options);\n var localthis = this;\n datapromise.done(function(data) {\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', data)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(competencyid);\n\n // Show the dialogue.\n new Dialogue(\n data.competency.shortname,\n html\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Display a dialogue box from data.\n *\n * @param {Object} dataSource data to be used to display dialogue box\n * @method showDialogueFromData\n */\n Competencydialogue.prototype.showDialogueFromData = function(dataSource) {\n\n var localthis = this;\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', dataSource)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(dataSource.id);\n\n // Show the dialogue.\n new Dialogue(\n dataSource.shortname,\n html,\n localthis.enhanceDialogue\n );\n }).fail(notification.exception);\n };\n\n /**\n * The action on the click event.\n *\n * @param {Event} e event click\n * @method clickEventHandler\n */\n Competencydialogue.prototype.clickEventHandler = function(e) {\n\n var compdialogue = e.data.compdialogue;\n var currentTarget = $(e.currentTarget);\n var competencyid = currentTarget.data('id');\n var includerelated = !(currentTarget.data('excluderelated'));\n var includecourses = currentTarget.data('includecourses');\n\n // Show the dialogue box.\n compdialogue.showDialogue(competencyid, {\n includerelated: includerelated,\n includecourses: includecourses\n });\n e.preventDefault();\n };\n\n /**\n * Get a promise on data competency.\n *\n * @param {Number} competencyid\n * @param {Object} options\n * @return {Promise} return promise on data request\n * @method getCompetencyDataPromise\n */\n Competencydialogue.prototype.getCompetencyDataPromise = function(competencyid, options) {\n\n var requests = ajax.call([\n {methodname: 'tool_lp_data_for_competency_summary',\n args: {competencyid: competencyid,\n includerelated: options.includerelated || false,\n includecourses: options.includecourses || false\n }\n }\n ]);\n\n return requests[0].then(function(context) {\n return context;\n }).fail(notification.exception);\n };\n\n return /** @alias module:tool_lp/competencydialogue */ {\n\n /**\n * Initialise the competency dialogue module.\n *\n * Only the first call matters.\n */\n init: function() {\n if (typeof instance !== 'undefined') {\n return;\n }\n\n // Instantiate the one instance and delegate event on the body.\n instance = new Competencydialogue();\n $('body').delegate('[data-action=\"competency-dialogue\"]', 'click', {compdialogue: instance},\n instance.clickEventHandler.bind(instance));\n }\n };\n});\n"],"names":["define","$","notification","ajax","templates","str","Dialogue","instance","Competencydialogue","prototype","triggerCompetencyViewedEvent","competencyId","call","methodname","args","id","showDialogue","competencyid","options","datapromise","this","getCompetencyDataPromise","localthis","done","data","render","html","competency","shortname","fail","exception","showDialogueFromData","dataSource","enhanceDialogue","clickEventHandler","e","compdialogue","currentTarget","includerelated","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qB,iBAAkB,MAKxC,GAAGE,MAAK,SAASC,gBACvBA,WACPb,KAAK3B,aAAa4B,YAG8B,CAOnDa,KAAM,gBACsB,IAAbpC,WAKXA,SAAW,IAAIC,mBACfP,EAAE,QAAQ2C,SAAS,sCAAuC,QAAS,CAACR,aAAc7B,UAC9EA,SAAS2B,kBAAkBW,KAAKtC"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencypicker.min.js b/admin/tool/lp/amd/build/competencypicker.min.js index ec38fee95eb..37c9d3e8d79 100644 --- a/admin/tool/lp/amd/build/competencypicker.min.js +++ b/admin/tool/lp/amd/build/competencypicker.min.js @@ -1,2 +1,14 @@ -define ("tool_lp/competencypicker",["jquery","core/notification","core/ajax","core/templates","tool_lp/dialogue","core/str","tool_lp/tree","core/pending"],function(a,b,c,d,e,f,g,h){var i=function(b,c,d,e){var f=this;f._eventNode=a("
");f._frameworks=[];f._reset();f._pageContextId=b;f._pageContextIncludes=d||"children";f._multiSelect="undefined"==typeof e||!0===e;if(c){f._frameworkId=c;f._singleFramework=!0}};i.prototype._competencies=null;i.prototype._disallowedCompetencyIDs=null;i.prototype._eventNode=null;i.prototype._frameworks=null;i.prototype._frameworkId=null;i.prototype._pageContextId=null;i.prototype._pageContextIncludes=null;i.prototype._popup=null;i.prototype._searchText="";i.prototype._selectedCompetencies=null;i.prototype._singleFramework=!1;i.prototype._multiSelect=!0;i.prototype._onlyVisible=!0;i.prototype._afterRender=function(){var c=this,d=new g(c._find("[data-enhance=linktree]"),c._multiSelect);c._find("[data-enhance=linktree]").show();d.on("selectionchanged",function(b,d){var e=d.selected;b.preventDefault();var f=[];a.each(e,function(b,d){var e=a(d).data("id"),g=!0;if("undefined"==typeof e){g=!1}else{a.each(c._disallowedCompetencyIDs,function(a,b){if(b==e){g=!1}})}if(g){f.push(e)}});c._selectedCompetencies=f;if(!c._selectedCompetencies.length){c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").attr("disabled","disabled")}else{c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").removeAttr("disabled")}});if(!c._singleFramework){c._find("[data-action=\"chooseframework\"]").change(function(d){c._frameworkId=a(d.target).val();c._loadCompetencies().then(c._refresh.bind(c)).catch(b.exception)})}c._find("[data-region=\"filtercompetencies\"] button").click(function(b){b.preventDefault();a(b.target).attr("disabled","disabled");c._searchText=c._find("[data-region=\"filtercompetencies\"] input").val()||"";return c._refresh().always(function(){a(b.target).removeAttr("disabled")})});c._find("[data-region=\"competencylinktree\"] [data-action=\"cancel\"]").click(function(a){a.preventDefault();c.close()});c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").click(function(a){a.preventDefault();var b=new h;if(!c._selectedCompetencies.length){return}if(c._multiSelect){c._trigger("save",{competencyIds:c._selectedCompetencies})}else{c._trigger("save",{competencyId:c._selectedCompetencies[0]})}c.close();b.resolve()});var e=c._selectedCompetencies.slice(0);a.each(e,function(a,b){var e=c._find("[data-id="+b+"]");if(e.length){d.toggleItem(e);d.updateFocus(e)}})};i.prototype.close=function(){var a=this;a._popup.close();a._reset()};i.prototype.display=function(){var c=this;return a.when(f.get_string("competencypicker","tool_lp"),c._render()).then(function(a,b){c._popup=new e(a,b[0],c._afterRender.bind(c))}).catch(b.exception)};i.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"core_competency_search_competencies",args:{searchtext:d,competencyframeworkid:a}}])[0].done(function(a){function b(a,c){for(var d=0;d
"),this._frameworks=[],this._reset(),this._pageContextId=pageContextId,this._pageContextIncludes=pageContextIncludes||"children",this._multiSelect=void 0===multiSelect||!0===multiSelect,singleFramework&&(this._frameworkId=singleFramework,this._singleFramework=!0)};return Picker.prototype._competencies=null,Picker.prototype._disallowedCompetencyIDs=null,Picker.prototype._eventNode=null,Picker.prototype._frameworks=null,Picker.prototype._frameworkId=null,Picker.prototype._pageContextId=null,Picker.prototype._pageContextIncludes=null,Picker.prototype._popup=null,Picker.prototype._searchText="",Picker.prototype._selectedCompetencies=null,Picker.prototype._singleFramework=!1,Picker.prototype._multiSelect=!0,Picker.prototype._onlyVisible=!0,Picker.prototype._afterRender=function(){var self=this,tree=new Tree(self._find("[data-enhance=linktree]"),self._multiSelect);self._find("[data-enhance=linktree]").show(),tree.on("selectionchanged",(function(evt,params){var selected=params.selected;evt.preventDefault();var validIds=[];$.each(selected,(function(index,item){var compId=$(item).data("id"),valid=!0;void 0===compId?valid=!1:$.each(self._disallowedCompetencyIDs,(function(i,id){id==compId&&(valid=!1)})),valid&&validIds.push(compId)})),self._selectedCompetencies=validIds,self._selectedCompetencies.length?self._find('[data-region="competencylinktree"] [data-action="add"]').removeAttr("disabled"):self._find('[data-region="competencylinktree"] [data-action="add"]').attr("disabled","disabled")})),self._singleFramework||self._find('[data-action="chooseframework"]').change((function(e){self._frameworkId=$(e.target).val(),self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception)})),self._find('[data-region="filtercompetencies"] button').click((function(e){return e.preventDefault(),$(e.target).attr("disabled","disabled"),self._searchText=self._find('[data-region="filtercompetencies"] input').val()||"",self._refresh().always((function(){$(e.target).removeAttr("disabled")}))})),self._find('[data-region="competencylinktree"] [data-action="cancel"]').click((function(e){e.preventDefault(),self.close()})),self._find('[data-region="competencylinktree"] [data-action="add"]').click((function(e){e.preventDefault();var pendingPromise=new Pending;self._selectedCompetencies.length&&(self._multiSelect?self._trigger("save",{competencyIds:self._selectedCompetencies}):self._trigger("save",{competencyId:self._selectedCompetencies[0]}),self.close(),pendingPromise.resolve())}));var currentItems=self._selectedCompetencies.slice(0);$.each(currentItems,(function(index,id){var node=self._find("[data-id="+id+"]");node.length&&(tree.toggleItem(node),tree.updateFocus(node))}))},Picker.prototype.close=function(){this._popup.close(),this._reset()},Picker.prototype.display=function(){var self=this;return $.when(Str.get_string("competencypicker","tool_lp"),self._render()).then((function(title,render){self._popup=new Dialogue(title,render[0],self._afterRender.bind(self))})).catch(Notification.exception)},Picker.prototype._fetchCompetencies=function(frameworkId,searchText){var self=this;return Ajax.call([{methodname:"core_competency_search_competencies",args:{searchtext:searchText,competencyframeworkid:frameworkId}}])[0].done((function(competencies){function addCompetencyChildren(parent,competencies){for(var i=0;i0?$.when():(self._singleFramework?Ajax.call([{methodname:"core_competency_read_competency_framework",args:{id:this._frameworkId}}])[0].then((function(framework){return[framework]})):Ajax.call([{methodname:"core_competency_list_competency_frameworks",args:{sort:"shortname",context:{contextid:self._pageContextId},includes:self._pageContextIncludes,onlyvisible:self._onlyVisible}}])[0]).done((function(frameworks){self._frameworks=frameworks})).fail(Notification.exception)},Picker.prototype.on=function(type,handler){this._eventNode.on(type,handler)},Picker.prototype._preRender=function(){var self=this;return self._loadFrameworks().then((function(){return!self._frameworkId&&self._frameworks.length>0&&(self._frameworkId=self._frameworks[0].id),self._frameworkId?self._loadCompetencies():(self._frameworks=[],$.when())}))},Picker.prototype._refresh=function(){var self=this;return self._render().then((function(html){self._find('[data-region="competencylinktree"]').replaceWith(html),self._afterRender()}))},Picker.prototype._render=function(){var self=this;return self._preRender().then((function(){self._singleFramework||$.each(self._frameworks,(function(i,framework){framework.id==self._frameworkId?framework.selected=!0:framework.selected=!1}));var context={competencies:self._competencies,framework:self._getFramework(self._frameworkId),frameworks:self._frameworks,search:self._searchText,singleFramework:self._singleFramework};return Templates.render("tool_lp/competency_picker",context)}))},Picker.prototype._reset=function(){this._competencies=[],this._disallowedCompetencyIDs=[],this._popup=null,this._searchText="",this._selectedCompetencies=[]},Picker.prototype.setDisallowedCompetencyIDs=function(ids){this._disallowedCompetencyIDs=ids},Picker.prototype._trigger=function(type,data){this._eventNode.trigger(type,[data])},Picker})); + +//# sourceMappingURL=competencypicker.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencypicker.min.js.map b/admin/tool/lp/amd/build/competencypicker.min.js.map index 24af47b4232..6fca0dc076b 100644 --- a/admin/tool/lp/amd/build/competencypicker.min.js.map +++ b/admin/tool/lp/amd/build/competencypicker.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencypicker.js"],"names":["define","$","Notification","Ajax","Templates","Dialogue","Str","Tree","Pending","Picker","pageContextId","singleFramework","pageContextIncludes","multiSelect","self","_eventNode","_frameworks","_reset","_pageContextId","_pageContextIncludes","_multiSelect","_frameworkId","_singleFramework","prototype","_competencies","_disallowedCompetencyIDs","_popup","_searchText","_selectedCompetencies","_onlyVisible","_afterRender","tree","_find","show","on","evt","params","selected","preventDefault","validIds","each","index","item","compId","data","valid","i","id","push","length","attr","removeAttr","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","click","always","close","pendingPromise","_trigger","competencyIds","competencyId","resolve","currentItems","slice","node","toggleItem","updateFocus","display","when","get_string","_render","title","render","_fetchCompetencies","frameworkId","searchText","call","methodname","args","searchtext","competencyframeworkid","done","competencies","addCompetencyChildren","parent","parentid","haschildren","children","comp","fail","selector","getContent","find","_getFramework","fid","frm","f","_loadFrameworks","promise","framework","sort","context","contextid","includes","onlyvisible","frameworks","type","handler","_preRender","html","replaceWith","search","setDisallowedCompetencyIDs","ids","trigger"],"mappings":"AA2BAA,OAAM,4BAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,kBAJD,CAKC,UALD,CAMC,cAND,CAOC,cAPD,CAAD,CASE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAqDC,CAArD,CAA0DC,CAA1D,CAAgEC,CAAhE,CAAyE,CAS7E,GAAIC,CAAAA,CAAM,CAAG,SAASC,CAAT,CAAwBC,CAAxB,CAAyCC,CAAzC,CAA8DC,CAA9D,CAA2E,CACpF,GAAIC,CAAAA,CAAI,CAAG,IAAX,CACAA,CAAI,CAACC,UAAL,CAAkBd,CAAC,CAAC,aAAD,CAAnB,CACAa,CAAI,CAACE,WAAL,CAAmB,EAAnB,CACAF,CAAI,CAACG,MAAL,GAEAH,CAAI,CAACI,cAAL,CAAsBR,CAAtB,CACAI,CAAI,CAACK,oBAAL,CAA4BP,CAAmB,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AAS,CAAC4E,MAAV,CAAiB,2BAAjB,CAA8C6B,CAA9C,CACV,CArBM,CAsBV,CAxBD,CAiCApG,CAAM,CAACc,SAAP,CAAiBN,MAAjB,CAA0B,UAAW,CACjC,KAAKO,aAAL,CAAqB,EAArB,CACA,KAAKC,wBAAL,CAAgC,EAAhC,CACA,KAAKC,MAAL,CAAc,IAAd,CACA,KAAKC,WAAL,CAAmB,EAAnB,CACA,KAAKC,qBAAL,CAA6B,EAChC,CAND,CAgBAnB,CAAM,CAACc,SAAP,CAAiBiG,0BAAjB,CAA8C,SAASC,CAAT,CAAc,CACxD,KAAKhG,wBAAL,CAAgCgG,CACnC,CAFD,CAWAhH,CAAM,CAACc,SAAP,CAAiB2C,QAAjB,CAA4B,SAASgD,CAAT,CAAetE,CAAf,CAAqB,CAC7C,KAAK7B,UAAL,CAAgB2G,OAAhB,CAAwBR,CAAxB,CAA8B,CAACtE,CAAD,CAA9B,CACH,CAFD,CAIA,MAAOnC,CAAAA,CAEV,CA7bK,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 * Competency picker.\n *\n * To handle 'save' events use: picker.on('save')\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'core/str',\n 'tool_lp/tree',\n 'core/pending'\n ],\n function($, Notification, Ajax, Templates, Dialogue, Str, Tree, Pending) {\n\n /**\n * Competency picker class.\n * @param {Number} pageContextId The page context ID.\n * @param {Number|false} singleFramework The ID of the framework when limited to one.\n * @param {String} pageContextIncludes One of 'children', 'parents', 'self'.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(pageContextId, singleFramework, pageContextIncludes, multiSelect) {\n var self = this;\n self._eventNode = $('
');\n self._frameworks = [];\n self._reset();\n\n self._pageContextId = pageContextId;\n self._pageContextIncludes = pageContextIncludes || 'children';\n self._multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n if (singleFramework) {\n self._frameworkId = singleFramework;\n self._singleFramework = true;\n }\n };\n\n /** @property {Array} The competencies fetched. */\n Picker.prototype._competencies = null;\n /** @property {Array} The competencies that cannot be picked. */\n Picker.prototype._disallowedCompetencyIDs = null;\n /** @property {Node} The node we attach the events to. */\n Picker.prototype._eventNode = null;\n /** @property {Array} The list of frameworks fetched. */\n Picker.prototype._frameworks = null;\n /** @property {Number} The current framework ID. */\n Picker.prototype._frameworkId = null;\n /** @property {Number} The page context ID. */\n Picker.prototype._pageContextId = null;\n /** @property {Number} Relevant contexts inclusion. */\n Picker.prototype._pageContextIncludes = null;\n /** @property {Dialogue} The reference to the dialogue. */\n Picker.prototype._popup = null;\n /** @property {String} The string we filter the competencies with. */\n Picker.prototype._searchText = '';\n /** @property {Object} The competency that was selected. */\n Picker.prototype._selectedCompetencies = null;\n /** @property {Boolean} Whether we can browse frameworks or not. */\n Picker.prototype._singleFramework = false;\n /** @property {Boolean} Do we allow multi select? */\n Picker.prototype._multiSelect = true;\n /** @property {Boolean} Do we allow to display hidden framework? */\n Picker.prototype._onlyVisible = true;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n\n // Initialise the tree.\n var tree = new Tree(self._find('[data-enhance=linktree]'), self._multiSelect);\n\n // To prevent jiggling we only show the tree after it is enhanced.\n self._find('[data-enhance=linktree]').show();\n\n tree.on('selectionchanged', function(evt, params) {\n var selected = params.selected;\n evt.preventDefault();\n var validIds = [];\n $.each(selected, function(index, item) {\n var compId = $(item).data('id'),\n valid = true;\n\n if (typeof compId === 'undefined') {\n // Do not allow picking nodes with no id.\n valid = false;\n } else {\n $.each(self._disallowedCompetencyIDs, function(i, id) {\n if (id == compId) {\n valid = false;\n }\n });\n }\n if (valid) {\n validIds.push(compId);\n }\n });\n\n self._selectedCompetencies = validIds;\n\n // TODO Implement disabling of nodes in the tree module somehow.\n if (!self._selectedCompetencies.length) {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').attr('disabled', 'disabled');\n } else {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').removeAttr('disabled');\n }\n });\n\n // Add listener for framework change.\n if (!self._singleFramework) {\n self._find('[data-action=\"chooseframework\"]').change(function(e) {\n self._frameworkId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);\n });\n }\n\n // Add listener for search.\n self._find('[data-region=\"filtercompetencies\"] button').click(function(e) {\n e.preventDefault();\n $(e.target).attr('disabled', 'disabled');\n self._searchText = self._find('[data-region=\"filtercompetencies\"] input').val() || '';\n return self._refresh().always(function() {\n $(e.target).removeAttr('disabled');\n });\n });\n\n // Add listener for cancel.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for add.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').click(function(e) {\n e.preventDefault();\n var pendingPromise = new Pending();\n if (!self._selectedCompetencies.length) {\n return;\n }\n\n if (self._multiSelect) {\n self._trigger('save', {competencyIds: self._selectedCompetencies});\n } else {\n // We checked above that the array has at least one value.\n self._trigger('save', {competencyId: self._selectedCompetencies[0]});\n }\n\n // The dialogue here is a YUI dialogue and doesn't support Promises at all.\n // However, it is typically synchronous so this shoudl suffice.\n self.close();\n pendingPromise.resolve();\n });\n\n // The list of selected competencies will be modified while looping (because of the listeners above).\n var currentItems = self._selectedCompetencies.slice(0);\n\n $.each(currentItems, function(index, id) {\n var node = self._find('[data-id=' + id + ']');\n if (node.length) {\n tree.toggleItem(node);\n tree.updateFocus(node);\n }\n });\n\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Picker.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Picker.prototype.display = function() {\n var self = this;\n return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} frameworkId The frameworkId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise}\n */\n Picker.prototype._fetchCompetencies = function(frameworkId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_search_competencies', args: {\n searchtext: searchText,\n competencyframeworkid: frameworkId\n }}\n ])[0].done(function(competencies) {\n /**\n * @param {Object} parent\n * @param {Array} competencies\n */\n function addCompetencyChildren(parent, competencies) {\n for (var i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n }\n\n // Expand the list of competencies into a tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i];\n if (comp.parentid == \"0\") { // Loose check for now, because WS returns a string.\n comp.children = [];\n comp.haschildren = 0;\n tree[tree.length] = comp;\n addCompetencyChildren(comp, competencies);\n }\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n */\n Picker.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Convenience method to get a framework object.\n *\n * @param {Number} fid The framework ID.\n * @return {Object}\n * @method _getFramework\n */\n Picker.prototype._getFramework = function(fid) {\n var frm;\n $.each(this._frameworks, function(i, f) {\n if (f.id == fid) {\n frm = f;\n return;\n }\n });\n return frm;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._frameworkId, this._searchText);\n };\n\n /**\n * Load the frameworks.\n *\n * @method _loadFrameworks\n * @return {Promise}\n */\n Picker.prototype._loadFrameworks = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._frameworks.length > 0) {\n return $.when();\n }\n\n if (self._singleFramework) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_competency_framework', args: {\n id: this._frameworkId\n }}\n ])[0].then(function(framework) {\n return [framework];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_competency_frameworks', args: {\n sort: 'shortname',\n context: {contextid: self._pageContextId},\n includes: self._pageContextIncludes,\n onlyvisible: self._onlyVisible\n }}\n ])[0];\n }\n\n return promise.done(function(frameworks) {\n self._frameworks = frameworks;\n }).fail(Notification.exception);\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Picker.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadFrameworks().then(function() {\n if (!self._frameworkId && self._frameworks.length > 0) {\n self._frameworkId = self._frameworks[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._frameworkId) {\n self._frameworks = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n Picker.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"competencylinktree\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singleFramework) {\n $.each(self._frameworks, function(i, framework) {\n if (framework.id == self._frameworkId) {\n framework.selected = true;\n } else {\n framework.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker', context);\n });\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n Picker.prototype._reset = function() {\n this._competencies = [];\n this._disallowedCompetencyIDs = [];\n this._popup = null;\n this._searchText = '';\n this._selectedCompetencies = [];\n };\n\n /**\n * Set what competencies cannot be picked.\n *\n * This needs to be set after reset/close.\n *\n * @param {Number[]} ids The IDs.\n * @method _setDisallowedCompetencyIDs\n */\n Picker.prototype.setDisallowedCompetencyIDs = function(ids) {\n this._disallowedCompetencyIDs = ids;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _reset\n */\n Picker.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return Picker;\n\n});\n"],"file":"competencypicker.min.js"} \ No newline at end of file +{"version":3,"file":"competencypicker.min.js","sources":["../src/competencypicker.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 * Competency picker.\n *\n * To handle 'save' events use: picker.on('save')\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'core/str',\n 'tool_lp/tree',\n 'core/pending'\n ],\n function($, Notification, Ajax, Templates, Dialogue, Str, Tree, Pending) {\n\n /**\n * Competency picker class.\n * @param {Number} pageContextId The page context ID.\n * @param {Number|false} singleFramework The ID of the framework when limited to one.\n * @param {String} pageContextIncludes One of 'children', 'parents', 'self'.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(pageContextId, singleFramework, pageContextIncludes, multiSelect) {\n var self = this;\n self._eventNode = $('
');\n self._frameworks = [];\n self._reset();\n\n self._pageContextId = pageContextId;\n self._pageContextIncludes = pageContextIncludes || 'children';\n self._multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n if (singleFramework) {\n self._frameworkId = singleFramework;\n self._singleFramework = true;\n }\n };\n\n /** @property {Array} The competencies fetched. */\n Picker.prototype._competencies = null;\n /** @property {Array} The competencies that cannot be picked. */\n Picker.prototype._disallowedCompetencyIDs = null;\n /** @property {Node} The node we attach the events to. */\n Picker.prototype._eventNode = null;\n /** @property {Array} The list of frameworks fetched. */\n Picker.prototype._frameworks = null;\n /** @property {Number} The current framework ID. */\n Picker.prototype._frameworkId = null;\n /** @property {Number} The page context ID. */\n Picker.prototype._pageContextId = null;\n /** @property {Number} Relevant contexts inclusion. */\n Picker.prototype._pageContextIncludes = null;\n /** @property {Dialogue} The reference to the dialogue. */\n Picker.prototype._popup = null;\n /** @property {String} The string we filter the competencies with. */\n Picker.prototype._searchText = '';\n /** @property {Object} The competency that was selected. */\n Picker.prototype._selectedCompetencies = null;\n /** @property {Boolean} Whether we can browse frameworks or not. */\n Picker.prototype._singleFramework = false;\n /** @property {Boolean} Do we allow multi select? */\n Picker.prototype._multiSelect = true;\n /** @property {Boolean} Do we allow to display hidden framework? */\n Picker.prototype._onlyVisible = true;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n\n // Initialise the tree.\n var tree = new Tree(self._find('[data-enhance=linktree]'), self._multiSelect);\n\n // To prevent jiggling we only show the tree after it is enhanced.\n self._find('[data-enhance=linktree]').show();\n\n tree.on('selectionchanged', function(evt, params) {\n var selected = params.selected;\n evt.preventDefault();\n var validIds = [];\n $.each(selected, function(index, item) {\n var compId = $(item).data('id'),\n valid = true;\n\n if (typeof compId === 'undefined') {\n // Do not allow picking nodes with no id.\n valid = false;\n } else {\n $.each(self._disallowedCompetencyIDs, function(i, id) {\n if (id == compId) {\n valid = false;\n }\n });\n }\n if (valid) {\n validIds.push(compId);\n }\n });\n\n self._selectedCompetencies = validIds;\n\n // TODO Implement disabling of nodes in the tree module somehow.\n if (!self._selectedCompetencies.length) {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').attr('disabled', 'disabled');\n } else {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').removeAttr('disabled');\n }\n });\n\n // Add listener for framework change.\n if (!self._singleFramework) {\n self._find('[data-action=\"chooseframework\"]').change(function(e) {\n self._frameworkId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);\n });\n }\n\n // Add listener for search.\n self._find('[data-region=\"filtercompetencies\"] button').click(function(e) {\n e.preventDefault();\n $(e.target).attr('disabled', 'disabled');\n self._searchText = self._find('[data-region=\"filtercompetencies\"] input').val() || '';\n return self._refresh().always(function() {\n $(e.target).removeAttr('disabled');\n });\n });\n\n // Add listener for cancel.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for add.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').click(function(e) {\n e.preventDefault();\n var pendingPromise = new Pending();\n if (!self._selectedCompetencies.length) {\n return;\n }\n\n if (self._multiSelect) {\n self._trigger('save', {competencyIds: self._selectedCompetencies});\n } else {\n // We checked above that the array has at least one value.\n self._trigger('save', {competencyId: self._selectedCompetencies[0]});\n }\n\n // The dialogue here is a YUI dialogue and doesn't support Promises at all.\n // However, it is typically synchronous so this shoudl suffice.\n self.close();\n pendingPromise.resolve();\n });\n\n // The list of selected competencies will be modified while looping (because of the listeners above).\n var currentItems = self._selectedCompetencies.slice(0);\n\n $.each(currentItems, function(index, id) {\n var node = self._find('[data-id=' + id + ']');\n if (node.length) {\n tree.toggleItem(node);\n tree.updateFocus(node);\n }\n });\n\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Picker.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Picker.prototype.display = function() {\n var self = this;\n return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} frameworkId The frameworkId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise}\n */\n Picker.prototype._fetchCompetencies = function(frameworkId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_search_competencies', args: {\n searchtext: searchText,\n competencyframeworkid: frameworkId\n }}\n ])[0].done(function(competencies) {\n /**\n * @param {Object} parent\n * @param {Array} competencies\n */\n function addCompetencyChildren(parent, competencies) {\n for (var i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n }\n\n // Expand the list of competencies into a tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i];\n if (comp.parentid == \"0\") { // Loose check for now, because WS returns a string.\n comp.children = [];\n comp.haschildren = 0;\n tree[tree.length] = comp;\n addCompetencyChildren(comp, competencies);\n }\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n */\n Picker.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Convenience method to get a framework object.\n *\n * @param {Number} fid The framework ID.\n * @return {Object}\n * @method _getFramework\n */\n Picker.prototype._getFramework = function(fid) {\n var frm;\n $.each(this._frameworks, function(i, f) {\n if (f.id == fid) {\n frm = f;\n return;\n }\n });\n return frm;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._frameworkId, this._searchText);\n };\n\n /**\n * Load the frameworks.\n *\n * @method _loadFrameworks\n * @return {Promise}\n */\n Picker.prototype._loadFrameworks = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._frameworks.length > 0) {\n return $.when();\n }\n\n if (self._singleFramework) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_competency_framework', args: {\n id: this._frameworkId\n }}\n ])[0].then(function(framework) {\n return [framework];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_competency_frameworks', args: {\n sort: 'shortname',\n context: {contextid: self._pageContextId},\n includes: self._pageContextIncludes,\n onlyvisible: self._onlyVisible\n }}\n ])[0];\n }\n\n return promise.done(function(frameworks) {\n self._frameworks = frameworks;\n }).fail(Notification.exception);\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Picker.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadFrameworks().then(function() {\n if (!self._frameworkId && self._frameworks.length > 0) {\n self._frameworkId = self._frameworks[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._frameworkId) {\n self._frameworks = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n Picker.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"competencylinktree\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singleFramework) {\n $.each(self._frameworks, function(i, framework) {\n if (framework.id == self._frameworkId) {\n framework.selected = true;\n } else {\n framework.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker', context);\n });\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n Picker.prototype._reset = function() {\n this._competencies = [];\n this._disallowedCompetencyIDs = [];\n this._popup = null;\n this._searchText = '';\n this._selectedCompetencies = [];\n };\n\n /**\n * Set what competencies cannot be picked.\n *\n * This needs to be set after reset/close.\n *\n * @param {Number[]} ids The IDs.\n * @method _setDisallowedCompetencyIDs\n */\n Picker.prototype.setDisallowedCompetencyIDs = function(ids) {\n this._disallowedCompetencyIDs = ids;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _reset\n */\n Picker.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return Picker;\n\n});\n"],"names":["define","$","Notification","Ajax","Templates","Dialogue","Str","Tree","Pending","Picker","pageContextId","singleFramework","pageContextIncludes","multiSelect","this","_eventNode","_frameworks","_reset","_pageContextId","_pageContextIncludes","_multiSelect","_frameworkId","_singleFramework","prototype","_competencies","_disallowedCompetencyIDs","_popup","_searchText","_selectedCompetencies","_onlyVisible","_afterRender","self","tree","_find","show","on","evt","params","selected","preventDefault","validIds","each","index","item","compId","data","valid","i","id","push","length","removeAttr","attr","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","click","always","close","pendingPromise","_trigger","competencyIds","competencyId","resolve","currentItems","slice","node","toggleItem","updateFocus","display","when","get_string","_render","title","render","_fetchCompetencies","frameworkId","searchText","call","methodname","args","searchtext","competencyframeworkid","done","competencies","addCompetencyChildren","parent","parentid","haschildren","children","comp","fail","selector","getContent","find","_getFramework","fid","frm","f","_loadFrameworks","framework","sort","context","contextid","includes","onlyvisible","frameworks","type","handler","_preRender","html","replaceWith","search","setDisallowedCompetencyIDs","ids","trigger"],"mappings":";;;;;;;;;;;AA2BAA,kCAAO,CAAC,SACA,oBACA,YACA,iBACA,mBACA,WACA,eACA,iBAEA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,SAAUC,IAAKC,KAAMC,aAShEC,OAAS,SAASC,cAAeC,gBAAiBC,oBAAqBC,aAC5DC,KACNC,WAAad,EAAE,eADTa,KAENE,YAAc,GAFRF,KAGNG,SAHMH,KAKNI,eAAiBR,cALXI,KAMNK,qBAAuBP,qBAAuB,WANxCE,KAONM,kBAAuC,IAAhBP,cAA+C,IAAhBA,YACvDF,kBAROG,KASFO,aAAeV,gBATbG,KAUFQ,kBAAmB,WAKhCb,OAAOc,UAAUC,cAAgB,KAEjCf,OAAOc,UAAUE,yBAA2B,KAE5ChB,OAAOc,UAAUR,WAAa,KAE9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Y,GAAK,SAAS+E,KAAMC,cAC5BpG,WAAWoB,GAAG+E,KAAMC,UAS7B1G,OAAOc,UAAU6F,WAAa,eACtBrF,KAAOjB,YACJiB,KAAK2E,kBAAkBhD,MAAK,kBAC1B3B,KAAKV,cAAgBU,KAAKf,YAAYkC,OAAS,IAChDnB,KAAKV,aAAeU,KAAKf,YAAY,GAAGgC,IAIvCjB,KAAKV,aAKHU,KAAK0B,qBAJR1B,KAAKf,YAAc,GACZf,EAAE4E,YAarBpE,OAAOc,UAAUoC,SAAW,eACpB5B,KAAOjB,YACJiB,KAAKgD,UAAUrB,MAAK,SAAS2D,MAChCtF,KAAKE,MAAM,sCAAsCqF,YAAYD,MAC7DtF,KAAKD,mBAWbrB,OAAOc,UAAUwD,QAAU,eACnBhD,KAAOjB,YACJiB,KAAKqF,aAAa1D,MAAK,WAErB3B,KAAKT,kBACNrB,EAAEwC,KAAKV,KAAKf,aAAa,SAAS+B,EAAG4D,WAC7BA,UAAU3D,IAAMjB,KAAKV,aACrBsF,UAAUrE,UAAW,EAErBqE,UAAUrE,UAAW,SAK7BuE,QAAU,CACVlB,aAAc5D,KAAKP,cACnBmF,UAAW5E,KAAKuE,cAAcvE,KAAKV,cACnC4F,WAAYlF,KAAKf,YACjBuG,OAAQxF,KAAKJ,YACbhB,gBAAiBoB,KAAKT,yBAGnBlB,UAAU6E,OAAO,4BAA6B4B,aAW7DpG,OAAOc,UAAUN,OAAS,gBACjBO,cAAgB,QAChBC,yBAA2B,QAC3BC,OAAS,UACTC,YAAc,QACdC,sBAAwB,IAWjCnB,OAAOc,UAAUiG,2BAA6B,SAASC,UAC9ChG,yBAA2BgG,KAUpChH,OAAOc,UAAU4C,SAAW,SAAS+C,KAAMrE,WAClC9B,WAAW2G,QAAQR,KAAM,CAACrE,QAG5BpC"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencypicker_user_plans.min.js b/admin/tool/lp/amd/build/competencypicker_user_plans.min.js index 460dd5cb7ad..77da9c7c7b7 100644 --- a/admin/tool/lp/amd/build/competencypicker_user_plans.min.js +++ b/admin/tool/lp/amd/build/competencypicker_user_plans.min.js @@ -1,2 +1,15 @@ -define ("tool_lp/competencypicker_user_plans",["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/tree","tool_lp/competencypicker"],function(a,b,c,d,e,f,g){var h=function(a,b,c){g.prototype.constructor.apply(this,[1,!1,"self",c]);this._userId=a;this._plans=[];if(b){this._planId=b;this._singlePlan=!0}};h.prototype=Object.create(g.prototype);h.prototype._plans=null;h.prototype._planId=null;h.prototype._singlePlan=!1;h.prototype._userId=null;h.prototype._afterRender=function(){var c=this;g.prototype._afterRender.apply(c,arguments);if(!c._singlePlan){c._find("[data-action=\"chooseplan\"]").change(function(d){c._planId=a(d.target).val();c._loadCompetencies().then(c._refresh.bind(c)).catch(b.exception)})}};h.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"core_competency_list_plan_competencies",args:{id:a}}])[0].done(function(a){var b,c,f=[];for(b=0;bc.shortname.toLowerCase().indexOf(d.toLowerCase())){continue}c.children=[];c.haschildren=0;f.push(c)}e._competencies=f}).fail(b.exception)};h.prototype._getPlan=function(b){var c;a.each(this._plans,function(a,d){if(d.id==b){c=d}});return c};h.prototype._loadCompetencies=function(){return this._fetchCompetencies(this._planId,this._searchText)};h.prototype._loadPlans=function(){var d,e=this;if(00?$.when():(self._singlePlan?Ajax.call([{methodname:"core_competency_read_plan",args:{id:this._planId}}])[0].then((function(plan){return[plan]})):Ajax.call([{methodname:"core_competency_list_user_plans",args:{userid:self._userId}}])[0]).done((function(plans){self._plans=plans})).fail(Notification.exception)},Picker.prototype._preRender=function(){var self=this;return self._loadPlans().then((function(){return!self._planId&&self._plans.length>0&&(self._planId=self._plans[0].id),self._planId?self._loadCompetencies():(self._plans=[],$.when())}))},Picker.prototype._render=function(){var self=this;return self._preRender().then((function(){self._singlePlan||$.each(self._plans,(function(i,plan){plan.id==self._planId?plan.selected=!0:plan.selected=!1}));var context={competencies:self._competencies,plan:self._getPlan(self._planId),plans:self._plans,search:self._searchText,singlePlan:self._singlePlan};return Templates.render("tool_lp/competency_picker_user_plans",context)}))},Picker})); + +//# sourceMappingURL=competencypicker_user_plans.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map b/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map index c84dcf7a316..26cd77c5717 100644 --- a/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map +++ b/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencypicker_user_plans.js"],"names":["define","$","Notification","Ajax","Templates","Str","Tree","PickerBase","Picker","userId","singlePlan","multiSelect","prototype","constructor","apply","_userId","_plans","_planId","_singlePlan","Object","create","_afterRender","self","arguments","_find","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","_fetchCompetencies","planId","searchText","call","methodname","args","id","done","competencies","i","comp","tree","length","competency","shortname","toLowerCase","indexOf","children","haschildren","push","_competencies","fail","_getPlan","plan","each","f","_searchText","_loadPlans","promise","when","userid","plans","_preRender","_render","selected","context","search","render"],"mappings":"AA4BAA,OAAM,uCAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,UAJD,CAKC,cALD,CAMC,0BAND,CAAD,CAQE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAsDC,CAAtD,CAAkE,CAUtE,GAAIC,CAAAA,CAAM,CAAG,SAASC,CAAT,CAAiBC,CAAjB,CAA6BC,CAA7B,CAA0C,CACnDJ,CAAU,CAACK,SAAX,CAAqBC,WAArB,CAAiCC,KAAjC,CAAuC,IAAvC,CAA6C,CAAC,CAAD,IAAW,MAAX,CAAmBH,CAAnB,CAA7C,EACA,KAAKI,OAAL,CAAeN,CAAf,CACA,KAAKO,MAAL,CAAc,EAAd,CAEA,GAAIN,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AuBArB,CAAM,CAACI,SAAP,CAAiBwD,OAAjB,CAA2B,UAAW,CAClC,GAAI9C,CAAAA,CAAI,CAAG,IAAX,CACA,MAAOA,CAAAA,CAAI,CAAC6C,UAAL,GAAkBrC,IAAlB,CAAuB,UAAW,CAErC,GAAI,CAACR,CAAI,CAACJ,WAAV,CAAuB,CACnBjB,CAAC,CAAC0D,IAAF,CAAOrC,CAAI,CAACN,MAAZ,CAAoB,SAAS4B,CAAT,CAAYc,CAAZ,CAAkB,CAClC,GAAIA,CAAI,CAACjB,EAAL,EAAWnB,CAAI,CAACL,OAApB,CAA6B,CACzByC,CAAI,CAACW,QAAL,GACH,CAFD,IAEO,CACHX,CAAI,CAACW,QAAL,GACH,CACJ,CAND,CAOH,CAED,GAAIC,CAAAA,CAAO,CAAG,CACV3B,YAAY,CAAErB,CAAI,CAACiC,aADT,CAEVG,IAAI,CAAEpC,CAAI,CAACmC,QAAL,CAAcnC,CAAI,CAACL,OAAnB,CAFI,CAGViD,KAAK,CAAE5C,CAAI,CAACN,MAHF,CAIVuD,MAAM,CAAEjD,CAAI,CAACuC,WAJH,CAKVnD,UAAU,CAAEY,CAAI,CAACJ,WALP,CAAd,CAQA,MAAOd,CAAAA,CAAS,CAACoE,MAAV,CAAiB,sCAAjB,CAAyDF,CAAzD,CACV,CArBM,CAsBV,CAxBD,CA0BA,MAAO9D,CAAAA,CACV,CArNK,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 * Competency picker from user plans.\n *\n * To handle 'save' events use: picker.on('save').\n *\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker_user_plans\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/tree',\n 'tool_lp/competencypicker'\n ],\n function($, Notification, Ajax, Templates, Str, Tree, PickerBase) {\n\n /**\n * Competency picker in plan class.\n *\n * @class tool_lp/competencypicker_user_plans\n * @param {Number} userId\n * @param {Number|false} singlePlan The ID of the plan when limited to one.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(userId, singlePlan, multiSelect) {\n PickerBase.prototype.constructor.apply(this, [1, false, 'self', multiSelect]);\n this._userId = userId;\n this._plans = [];\n\n if (singlePlan) {\n this._planId = singlePlan;\n this._singlePlan = true;\n }\n };\n Picker.prototype = Object.create(PickerBase.prototype);\n\n /** @property {Array} The list of plans fetched. */\n Picker.prototype._plans = null;\n /** @property {Number} The current plan ID. */\n Picker.prototype._planId = null;\n /** @property {Boolean} Whether we can browse plans or not. */\n Picker.prototype._singlePlan = false;\n /** @property {Number} The user the plans belongs to. */\n Picker.prototype._userId = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n PickerBase.prototype._afterRender.apply(self, arguments);\n\n // Add listener for framework change.\n if (!self._singlePlan) {\n self._find('[data-action=\"chooseplan\"]').change(function(e) {\n self._planId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self))\n .catch(Notification.exception);\n });\n }\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} planId The planId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise} The promise object.\n */\n Picker.prototype._fetchCompetencies = function(planId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_list_plan_competencies', args: {\n id: planId\n }}\n ])[0].done(function(competencies) {\n\n // Expand the list of competencies into a fake tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i].competency;\n if (comp.shortname.toLowerCase().indexOf(searchText.toLowerCase()) < 0) {\n continue;\n }\n comp.children = [];\n comp.haschildren = 0;\n tree.push(comp);\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Convenience method to get a plan object.\n *\n * @param {Number} id The plan ID.\n * @return {Object|undefined} The plan.\n * @method _getPlan\n */\n Picker.prototype._getPlan = function(id) {\n var plan;\n $.each(this._plans, function(i, f) {\n if (f.id == id) {\n plan = f;\n return;\n }\n });\n return plan;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._planId, this._searchText);\n };\n\n /**\n * Load the plans.\n *\n * @method _loadPlans\n * @return {Promise}\n */\n Picker.prototype._loadPlans = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._plans.length > 0) {\n return $.when();\n }\n\n if (self._singlePlan) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_plan', args: {\n id: this._planId\n }}\n ])[0].then(function(plan) {\n return [plan];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_user_plans', args: {\n userid: self._userId\n }}\n ])[0];\n }\n\n return promise.done(function(plans) {\n self._plans = plans;\n }).fail(Notification.exception);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadPlans().then(function() {\n if (!self._planId && self._plans.length > 0) {\n self._planId = self._plans[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._planId) {\n self._plans = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singlePlan) {\n $.each(self._plans, function(i, plan) {\n if (plan.id == self._planId) {\n plan.selected = true;\n } else {\n plan.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n plan: self._getPlan(self._planId),\n plans: self._plans,\n search: self._searchText,\n singlePlan: self._singlePlan,\n };\n\n return Templates.render('tool_lp/competency_picker_user_plans', context);\n });\n };\n\n return Picker;\n});\n"],"file":"competencypicker_user_plans.min.js"} \ No newline at end of file +{"version":3,"file":"competencypicker_user_plans.min.js","sources":["../src/competencypicker_user_plans.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 * Competency picker from user plans.\n *\n * To handle 'save' events use: picker.on('save').\n *\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker_user_plans\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/tree',\n 'tool_lp/competencypicker'\n ],\n function($, Notification, Ajax, Templates, Str, Tree, PickerBase) {\n\n /**\n * Competency picker in plan class.\n *\n * @class tool_lp/competencypicker_user_plans\n * @param {Number} userId\n * @param {Number|false} singlePlan The ID of the plan when limited to one.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(userId, singlePlan, multiSelect) {\n PickerBase.prototype.constructor.apply(this, [1, false, 'self', multiSelect]);\n this._userId = userId;\n this._plans = [];\n\n if (singlePlan) {\n this._planId = singlePlan;\n this._singlePlan = true;\n }\n };\n Picker.prototype = Object.create(PickerBase.prototype);\n\n /** @property {Array} The list of plans fetched. */\n Picker.prototype._plans = null;\n /** @property {Number} The current plan ID. */\n Picker.prototype._planId = null;\n /** @property {Boolean} Whether we can browse plans or not. */\n Picker.prototype._singlePlan = false;\n /** @property {Number} The user the plans belongs to. */\n Picker.prototype._userId = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n PickerBase.prototype._afterRender.apply(self, arguments);\n\n // Add listener for framework change.\n if (!self._singlePlan) {\n self._find('[data-action=\"chooseplan\"]').change(function(e) {\n self._planId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self))\n .catch(Notification.exception);\n });\n }\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} planId The planId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise} The promise object.\n */\n Picker.prototype._fetchCompetencies = function(planId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_list_plan_competencies', args: {\n id: planId\n }}\n ])[0].done(function(competencies) {\n\n // Expand the list of competencies into a fake tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i].competency;\n if (comp.shortname.toLowerCase().indexOf(searchText.toLowerCase()) < 0) {\n continue;\n }\n comp.children = [];\n comp.haschildren = 0;\n tree.push(comp);\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Convenience method to get a plan object.\n *\n * @param {Number} id The plan ID.\n * @return {Object|undefined} The plan.\n * @method _getPlan\n */\n Picker.prototype._getPlan = function(id) {\n var plan;\n $.each(this._plans, function(i, f) {\n if (f.id == id) {\n plan = f;\n return;\n }\n });\n return plan;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._planId, this._searchText);\n };\n\n /**\n * Load the plans.\n *\n * @method _loadPlans\n * @return {Promise}\n */\n Picker.prototype._loadPlans = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._plans.length > 0) {\n return $.when();\n }\n\n if (self._singlePlan) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_plan', args: {\n id: this._planId\n }}\n ])[0].then(function(plan) {\n return [plan];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_user_plans', args: {\n userid: self._userId\n }}\n ])[0];\n }\n\n return promise.done(function(plans) {\n self._plans = plans;\n }).fail(Notification.exception);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadPlans().then(function() {\n if (!self._planId && self._plans.length > 0) {\n self._planId = self._plans[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._planId) {\n self._plans = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singlePlan) {\n $.each(self._plans, function(i, plan) {\n if (plan.id == self._planId) {\n plan.selected = true;\n } else {\n plan.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n plan: self._getPlan(self._planId),\n plans: self._plans,\n search: self._searchText,\n singlePlan: self._singlePlan,\n };\n\n return Templates.render('tool_lp/competency_picker_user_plans', context);\n });\n };\n\n return Picker;\n});\n"],"names":["define","$","Notification","Ajax","Templates","Str","Tree","PickerBase","Picker","userId","singlePlan","multiSelect","prototype","constructor","apply","this","_userId","_plans","_planId","_singlePlan","Object","create","_afterRender","self","arguments","_find","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","_fetchCompetencies","planId","searchText","call","methodname","args","id","done","competencies","i","comp","tree","length","competency","shortname","toLowerCase","indexOf","children","haschildren","push","_competencies","fail","_getPlan","plan","each","f","_searchText","_loadPlans","when","userid","plans","_preRender","_render","selected","context","search","render"],"mappings":";;;;;;;;;;;;AA4BAA,6CAAO,CAAC,SACA,oBACA,YACA,iBACA,WACA,eACA,6BAEA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,KAAMC,gBAUtDC,OAAS,SAASC,OAAQC,WAAYC,aACtCJ,WAAWK,UAAUC,YAAYC,MAAMC,KAAM,CAAC,GAAG,EAAO,OAAQJ,mBAC3DK,QAAUP,YACVQ,OAAS,GAEVP,kBACKQ,QAAUR,gBACVS,aAAc,WAG3BX,OAAOI,UAAYQ,OAAOC,OAAOd,WAAWK,YAG3BK,OAAS,KAE1BT,OAAOI,UAAUM,QAAU,KAE3BV,OAAOI,UAAUO,aAAc,EAE/BX,OAAOI,UAAUI,QAAU,KAO3BR,OAAOI,UAAUU,aAAe,eACxBC,KAAOR,KACXR,WAAWK,UAAUU,aAAaR,MAAMS,KAAMC,WAGzCD,KAAKJ,aACNI,KAAKE,MAAM,8BAA8BC,QAAO,SAASC,GACrDJ,KAAKL,QAAUjB,EAAE0B,EAAEC,QAAQC,MAC3BN,KAAKO,oBAAoBC,KAAKR,KAAKS,SAASC,KAAKV,OAChDW,MAAMhC,aAAaiC,eAahC3B,OAAOI,UAAUwB,mBAAqB,SAASC,OAAQC,gBAC/Cf,KAAOR,YAEJZ,KAAKoC,KAAK,CACb,CAACC,WAAY,yCAA0CC,KAAM,CACzDC,GAAIL,WAET,GAAGM,MAAK,SAASC,kBAGZC,EAAGC,KACHC,KAAO,OACNF,EAAI,EAAGA,EAAID,aAAaI,OAAQH,KACjCC,KAAOF,aAAaC,GAAGI,YACdC,UAAUC,cAAcC,QAAQd,WAAWa,eAAiB,IAGrEL,KAAKO,SAAW,GAChBP,KAAKQ,YAAc,EACnBP,KAAKQ,KAAKT,OAGdvB,KAAKiC,cAA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Ya,KAAKJ,oBAGdf,UAAUoE,OAAO,uCAAwCF,aAIjE9D"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencyruleconfig.min.js b/admin/tool/lp/amd/build/competencyruleconfig.min.js index d52ffcb4aec..11b49530409 100644 --- a/admin/tool/lp/amd/build/competencyruleconfig.min.js +++ b/admin/tool/lp/amd/build/competencyruleconfig.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competencyruleconfig",["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/competency_outcomes","core/str"],function(a,b,c,d,e,f){var g=function(b,c){this._eventNode=a("
");this._tree=b;this._rulesModules=c;this._setUp()};g.prototype._competency=null;g.prototype._eventNode=null;g.prototype._outcomesOption=null;g.prototype._popup=null;g.prototype._ready=null;g.prototype._rules=null;g.prototype._rulesModules=null;g.prototype._tree=null;g.prototype._afterChange=function(){if(!this._isValid()){this._find("[data-action=\"save\"]").prop("disabled",!0)}else{this._find("[data-action=\"save\"]").prop("disabled",!1)}};g.prototype._afterRuleConfigChange=function(a,b){if(b!=this._getRule()){return}this._afterChange()};g.prototype._afterRender=function(){var a=this;a._find("[name=\"outcome\"]").on("change",function(){a._switchedOutcome()}).trigger("change");a._find("[name=\"rule\"]").on("change",function(){a._switchedRule()}).trigger("change");a._find("[data-action=\"save\"]").on("click",function(){a._trigger("save",a._getConfig());a.close()});a._find("[data-action=\"cancel\"]").on("click",function(){a.close()})};g.prototype.canBeConfigured=function(){var b=!1;a.each(this._rules,function(a,c){if(c.canConfig()){b=!0}});return b};g.prototype.close=function(){this._popup.close();this._popup=null};g.prototype.display=function(){var c=this;if(!c._competency){return!1}return a.when(f.get_string("competencyrule","tool_lp"),c._render()).then(function(a,b){c._popup=new d(a,b[0],c._afterRender.bind(c))}).fail(b.exception)};g.prototype._find=function(b){return a(this._popup.getContent()).find(b)};g.prototype._getApplicableOutcomesOptions=function(){var b=this,c=[];a.each(b._outcomesOption,function(a,d){c.push({code:d.code,name:d.name,selected:d.code==b._competency.ruleoutcome?!0:!1})});return c};g.prototype._getApplicableRulesOptions=function(){var b=this,c=[];a.each(b._rules,function(a,d){if(!d.canConfig()){return}c.push({name:b._getRuleName(d.getType()),type:d.getType(),selected:d.getType()==b._competency.ruletype?!0:!1})});return c};g.prototype._getConfig=function(){var a=this._getRule();return{ruletype:a?a.getType():null,ruleconfig:a?a.getConfig():null,ruleoutcome:this._getOutcome()}};g.prototype._getOutcome=function(){return this._find("[name=\"outcome\"]").val()};g.prototype._getRule=function(){var b,c=this._find("[name=\"rule\"]").val();a.each(this._rules,function(a,d){if(d.getType()==c){b=d}});return b};g.prototype._getRuleName=function(b){var c=this,d;a.each(c._rulesModules,function(a,c){if(c.type==b){d=c.name}});return d};g.prototype._initOutcomes=function(){var a=this;return e.getAll().then(function(b){a._outcomesOption=b})};g.prototype._initRules=function(){var b=this,c=[];a.each(b._rules,function(d,e){var f=e.init().then(function(){e.setTargetCompetency(b._competency);e.on("change",b._afterRuleConfigChange.bind(b))},function(){b._rules.splice(d,1);return a.when()});c.push(f)});return a.when.apply(a.when,c)};g.prototype._isValid=function(){var a=this._getOutcome(),b=this._getRule();if(a==e.NONE){return!0}else if(!b){return!1}return b.isValid()};g.prototype.on=function(a,b){this._eventNode.on(a,b)};g.prototype._preRender=function(){return this.ready()};g.prototype.ready=function(){return this._ready.promise()};g.prototype._render=function(){var a=this;return this._preRender().then(function(){var b;if(!a.canBeConfigured()){b=!1}else{b={};b.outcomes=a._getApplicableOutcomesOptions();b.rules=a._getApplicableRulesOptions()}var d={competencyshortname:a._competency.shortname,config:b};return c.render("tool_lp/competency_rule_config",d)})};g.prototype.setTargetCompetencyId=function(b){var c=this;c._competency=c._tree.getCompetency(b);a.each(c._rules,function(a,b){b.setTargetCompetency(c._competency)})};g.prototype._setUp=function(){var b=this,c=[],d=[];b._ready=a.Deferred();b._rules=[];a.each(b._rulesModules,function(a,b){d.push(b.amd)});require(d,function(){a.each(arguments,function(a,c){var d=new c(b._tree);b._rules.push(d)});c.push(b._initRules());c.push(b._initOutcomes());a.when.apply(a.when,c).always(function(){b._ready.resolve()})})};g.prototype._switchedOutcome=function(){var a=this,b=a._getOutcome();if(b==e.NONE){a._find("[data-region=\"rule-type\"]").hide().find("[name=\"rule\"]").val(-1);a._find("[data-region=\"rule-config\"]").empty().hide();a._afterChange();return}a._find("[data-region=\"rule-type\"]").show();a._find("[data-region=\"rule-config\"]").show();a._afterChange()};g.prototype._switchedRule=function(){var a=this,b=a._find("[data-region=\"rule-config\"]"),c=a._getRule();if(!c){b.empty().hide();a._afterChange();return}c.injectTemplate(b).then(function(){b.show()}).always(function(){a._afterChange()}).catch(function(){b.empty().hide()})};g.prototype._trigger=function(a,b){this._eventNode.trigger(a,[b])};return g}); -//# sourceMappingURL=competencyruleconfig.min.js.map +/** + * Competency rule config. + * + * @module tool_lp/competencyruleconfig + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competencyruleconfig",["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/competency_outcomes","core/str"],(function($,Notification,Templates,Dialogue,Outcomes,Str){var RuleConfig=function(tree,rulesModules){this._eventNode=$("
"),this._tree=tree,this._rulesModules=rulesModules,this._setUp()};return RuleConfig.prototype._competency=null,RuleConfig.prototype._eventNode=null,RuleConfig.prototype._outcomesOption=null,RuleConfig.prototype._popup=null,RuleConfig.prototype._ready=null,RuleConfig.prototype._rules=null,RuleConfig.prototype._rulesModules=null,RuleConfig.prototype._tree=null,RuleConfig.prototype._afterChange=function(){this._isValid()?this._find('[data-action="save"]').prop("disabled",!1):this._find('[data-action="save"]').prop("disabled",!0)},RuleConfig.prototype._afterRuleConfigChange=function(e,rule){rule==this._getRule()&&this._afterChange()},RuleConfig.prototype._afterRender=function(){var self=this;self._find('[name="outcome"]').on("change",(function(){self._switchedOutcome()})).trigger("change"),self._find('[name="rule"]').on("change",(function(){self._switchedRule()})).trigger("change"),self._find('[data-action="save"]').on("click",(function(){self._trigger("save",self._getConfig()),self.close()})),self._find('[data-action="cancel"]').on("click",(function(){self.close()}))},RuleConfig.prototype.canBeConfigured=function(){var can=!1;return $.each(this._rules,(function(index,rule){rule.canConfig()&&(can=!0)})),can},RuleConfig.prototype.close=function(){this._popup.close(),this._popup=null},RuleConfig.prototype.display=function(){var self=this;return!!self._competency&&$.when(Str.get_string("competencyrule","tool_lp"),self._render()).then((function(title,render){self._popup=new Dialogue(title,render[0],self._afterRender.bind(self))})).fail(Notification.exception)},RuleConfig.prototype._find=function(selector){return $(this._popup.getContent()).find(selector)},RuleConfig.prototype._getApplicableOutcomesOptions=function(){var self=this,options=[];return $.each(self._outcomesOption,(function(index,outcome){options.push({code:outcome.code,name:outcome.name,selected:outcome.code==self._competency.ruleoutcome})})),options},RuleConfig.prototype._getApplicableRulesOptions=function(){var self=this,options=[];return $.each(self._rules,(function(index,rule){rule.canConfig()&&options.push({name:self._getRuleName(rule.getType()),type:rule.getType(),selected:rule.getType()==self._competency.ruletype})})),options},RuleConfig.prototype._getConfig=function(){var rule=this._getRule();return{ruletype:rule?rule.getType():null,ruleconfig:rule?rule.getConfig():null,ruleoutcome:this._getOutcome()}},RuleConfig.prototype._getOutcome=function(){return this._find('[name="outcome"]').val()},RuleConfig.prototype._getRule=function(){var result,type=this._find('[name="rule"]').val();return $.each(this._rules,(function(index,rule){rule.getType()!=type||(result=rule)})),result},RuleConfig.prototype._getRuleName=function(type){var name;return $.each(this._rulesModules,(function(index,modInfo){modInfo.type!=type||(name=modInfo.name)})),name},RuleConfig.prototype._initOutcomes=function(){var self=this;return Outcomes.getAll().then((function(outcomes){self._outcomesOption=outcomes}))},RuleConfig.prototype._initRules=function(){var self=this,promises=[];return $.each(self._rules,(function(index,rule){var promise=rule.init().then((function(){rule.setTargetCompetency(self._competency),rule.on("change",self._afterRuleConfigChange.bind(self))}),(function(){return self._rules.splice(index,1),$.when()}));promises.push(promise)})),$.when.apply($.when,promises)},RuleConfig.prototype._isValid=function(){var outcome=this._getOutcome(),rule=this._getRule();return outcome==Outcomes.NONE||!!rule&&rule.isValid()},RuleConfig.prototype.on=function(type,handler){this._eventNode.on(type,handler)},RuleConfig.prototype._preRender=function(){return this.ready()},RuleConfig.prototype.ready=function(){return this._ready.promise()},RuleConfig.prototype._render=function(){var self=this;return this._preRender().then((function(){var config;self.canBeConfigured()?((config={}).outcomes=self._getApplicableOutcomesOptions(),config.rules=self._getApplicableRulesOptions()):config=!1;var context={competencyshortname:self._competency.shortname,config:config};return Templates.render("tool_lp/competency_rule_config",context)}))},RuleConfig.prototype.setTargetCompetencyId=function(competencyId){var self=this;self._competency=self._tree.getCompetency(competencyId),$.each(self._rules,(function(index,rule){rule.setTargetCompetency(self._competency)}))},RuleConfig.prototype._setUp=function(){var self=this,promises=[],modules=[];self._ready=$.Deferred(),self._rules=[],$.each(self._rulesModules,(function(index,rule){modules.push(rule.amd)})),require(modules,(function(){$.each(arguments,(function(index,Module){var rule=new Module(self._tree);self._rules.push(rule)})),promises.push(self._initRules()),promises.push(self._initOutcomes()),$.when.apply($.when,promises).always((function(){self._ready.resolve()}))}))},RuleConfig.prototype._switchedOutcome=function(){if(this._getOutcome()==Outcomes.NONE)return this._find('[data-region="rule-type"]').hide().find('[name="rule"]').val(-1),this._find('[data-region="rule-config"]').empty().hide(),void this._afterChange();this._find('[data-region="rule-type"]').show(),this._find('[data-region="rule-config"]').show(),this._afterChange()},RuleConfig.prototype._switchedRule=function(){var self=this,container=self._find('[data-region="rule-config"]'),rule=self._getRule();if(!rule)return container.empty().hide(),void self._afterChange();rule.injectTemplate(container).then((function(){container.show()})).always((function(){self._afterChange()})).catch((function(){container.empty().hide()}))},RuleConfig.prototype._trigger=function(type,data){this._eventNode.trigger(type,[data])},RuleConfig})); + +//# sourceMappingURL=competencyruleconfig.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencyruleconfig.min.js.map b/admin/tool/lp/amd/build/competencyruleconfig.min.js.map index 27dcc816d18..abb941a1722 100644 --- a/admin/tool/lp/amd/build/competencyruleconfig.min.js.map +++ b/admin/tool/lp/amd/build/competencyruleconfig.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencyruleconfig.js"],"names":["define","$","Notification","Templates","Dialogue","Outcomes","Str","RuleConfig","tree","rulesModules","_eventNode","_tree","_rulesModules","_setUp","prototype","_competency","_outcomesOption","_popup","_ready","_rules","_afterChange","_isValid","_find","prop","_afterRuleConfigChange","e","rule","_getRule","_afterRender","self","on","_switchedOutcome","trigger","_switchedRule","_trigger","_getConfig","close","canBeConfigured","can","each","index","canConfig","display","when","get_string","_render","then","title","render","bind","fail","exception","selector","getContent","find","_getApplicableOutcomesOptions","options","outcome","push","code","name","selected","ruleoutcome","_getApplicableRulesOptions","_getRuleName","getType","type","ruletype","ruleconfig","getConfig","_getOutcome","val","result","modInfo","_initOutcomes","getAll","outcomes","_initRules","promises","promise","init","setTargetCompetency","splice","apply","NONE","isValid","handler","_preRender","ready","config","rules","context","competencyshortname","shortname","setTargetCompetencyId","competencyId","getCompetency","modules","Deferred","amd","require","arguments","Module","always","resolve","hide","empty","show","container","injectTemplate","catch","data"],"mappings":"AAuBAA,OAAM,gCAAC,CAAC,QAAD,CACC,mBADD,CAEC,gBAFD,CAGC,kBAHD,CAIC,6BAJD,CAKC,UALD,CAAD,CAME,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAqCC,CAArC,CAA+CC,CAA/C,CAAyDC,CAAzD,CAA8D,CAclE,GAAIC,CAAAA,CAAU,CAAG,SAASC,CAAT,CAAeC,CAAf,CAA6B,CAC1C,KAAKC,UAAL,CAAkBT,CAAC,CAAC,aAAD,CAAnB,CACA,KAAKU,KAAL,CAAaH,CAAb,CACA,KAAKI,aAAL,CAAqBH,CAArB,CACA,KAAKI,MAAL,EACH,CALD,CAQAN,CAAU,CAACO,SAAX,CAAqBC,WAArB,CAAmC,IAAnC,CAEAR,CAAU,CAACO,SAAX,CAAqBJ,UAArB,CAAkC,IAAlC,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B,CAAC6C,CAAD,CAA9B,CACH,CAFD,CAIA,MAAyDxG,CAAAA,CAE5D,CAxgBK,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 * Competency rule config.\n *\n * @module tool_lp/competencyruleconfig\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/competency_outcomes',\n 'core/str'],\n function($, Notification, Templates, Dialogue, Outcomes, Str) {\n\n /**\n * Competency rule class.\n *\n * When implementing this you should attach a listener to the event 'save'\n * on the instance. E.g.\n *\n * var config = new RuleConfig(tree, modules);\n * config.on('save', function(e, config) { ... });\n *\n * @param {competencytree} tree The competency tree.\n * @param {Array} rulesModules The modules containing the rules: [{ typeName: { amd: amdModule, name: ruleName }}].\n */\n var RuleConfig = function(tree, rulesModules) {\n this._eventNode = $('
');\n this._tree = tree;\n this._rulesModules = rulesModules;\n this._setUp();\n };\n\n /** @property {Object} The current competency. */\n RuleConfig.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n RuleConfig.prototype._eventNode = null;\n /** @property {Array} Outcomes options. */\n RuleConfig.prototype._outcomesOption = null;\n /** @property {Dialogue} The dialogue. */\n RuleConfig.prototype._popup = null;\n /** @property {Promise} Resolved when the module is ready. */\n RuleConfig.prototype._ready = null;\n /** @property {Array} The rules. */\n RuleConfig.prototype._rules = null;\n /** @property {Array} The rules modules. */\n RuleConfig.prototype._rulesModules = null;\n /** @property {competencytree} The competency tree. */\n RuleConfig.prototype._tree = null;\n\n /**\n * After change.\n *\n * Triggered when a change occured.\n *\n * @method _afterChange\n * @protected\n */\n RuleConfig.prototype._afterChange = function() {\n if (!this._isValid()) {\n this._find('[data-action=\"save\"]').prop('disabled', true);\n } else {\n this._find('[data-action=\"save\"]').prop('disabled', false);\n }\n };\n\n /**\n * After change in rule's config.\n *\n * Triggered when a change occured in a specific rule config.\n *\n * @method _afterRuleConfigChange\n * @protected\n * @param {Event} e\n * @param {Rule} rule\n */\n RuleConfig.prototype._afterRuleConfigChange = function(e, rule) {\n if (rule != this._getRule()) {\n // This rule is not the current one any more, we can ignore.\n return;\n }\n this._afterChange();\n };\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n RuleConfig.prototype._afterRender = function() {\n var self = this;\n\n self._find('[name=\"outcome\"]').on('change', function() {\n self._switchedOutcome();\n }).trigger('change');\n\n self._find('[name=\"rule\"]').on('change', function() {\n self._switchedRule();\n }).trigger('change');\n\n self._find('[data-action=\"save\"]').on('click', function() {\n self._trigger('save', self._getConfig());\n self.close();\n });\n\n self._find('[data-action=\"cancel\"]').on('click', function() {\n self.close();\n });\n };\n\n /**\n * Whether the current competency can be configured.\n *\n * @return {Boolean}\n * @method canBeConfigured\n */\n RuleConfig.prototype.canBeConfigured = function() {\n var can = false;\n $.each(this._rules, function(index, rule) {\n if (rule.canConfig()) {\n can = true;\n return;\n }\n });\n return can;\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n RuleConfig.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @returns {Promise}\n */\n RuleConfig.prototype.display = function() {\n var self = this;\n if (!self._competency) {\n return false;\n }\n return $.when(Str.get_string('competencyrule', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n * @protected\n */\n RuleConfig.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Get the applicable outcome options.\n *\n * @return {Array}\n * @method _getApplicableOutcomesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableOutcomesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._outcomesOption, function(index, outcome) {\n options.push({\n code: outcome.code,\n name: outcome.name,\n selected: (outcome.code == self._competency.ruleoutcome) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the applicable rules options.\n *\n * @return {Array}\n * @method _getApplicableRulesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableRulesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._rules, function(index, rule) {\n if (!rule.canConfig()) {\n return;\n }\n options.push({\n name: self._getRuleName(rule.getType()),\n type: rule.getType(),\n selected: (rule.getType() == self._competency.ruletype) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the full config for the competency.\n *\n * @return {Object} Contains rule, ruleoutcome and ruleconfig.\n * @method _getConfig\n * @protected\n */\n RuleConfig.prototype._getConfig = function() {\n var rule = this._getRule();\n return {\n ruletype: rule ? rule.getType() : null,\n ruleconfig: rule ? rule.getConfig() : null,\n ruleoutcome: this._getOutcome()\n };\n };\n\n /**\n * Get the selected outcome code.\n *\n * @return {String}\n * @method _getOutcome\n * @protected\n */\n RuleConfig.prototype._getOutcome = function() {\n return this._find('[name=\"outcome\"]').val();\n };\n\n /**\n * Get the selected rule.\n *\n * @return {null|Rule}\n * @method _getRule\n * @protected\n */\n RuleConfig.prototype._getRule = function() {\n var result,\n type = this._find('[name=\"rule\"]').val();\n\n $.each(this._rules, function(index, rule) {\n if (rule.getType() == type) {\n result = rule;\n return;\n }\n });\n\n return result;\n };\n\n /**\n * Return the name of a rule.\n *\n * @param {String} type The type of a rule.\n * @return {String}\n * @method _getRuleName\n * @protected\n */\n RuleConfig.prototype._getRuleName = function(type) {\n var self = this,\n name;\n $.each(self._rulesModules, function(index, modInfo) {\n if (modInfo.type == type) {\n name = modInfo.name;\n return;\n }\n });\n return name;\n };\n\n /**\n * Initialise the outcomes.\n *\n * @return {Promise}\n * @method _initOutcomes\n * @protected\n */\n RuleConfig.prototype._initOutcomes = function() {\n var self = this;\n return Outcomes.getAll().then(function(outcomes) {\n self._outcomesOption = outcomes;\n return;\n });\n };\n\n /**\n * Initialise the rules.\n *\n * @return {Promise}\n * @method _initRules\n * @protected\n */\n RuleConfig.prototype._initRules = function() {\n var self = this,\n promises = [];\n $.each(self._rules, function(index, rule) {\n var promise = rule.init().then(function() {\n rule.setTargetCompetency(self._competency);\n rule.on('change', self._afterRuleConfigChange.bind(self));\n return;\n }, function() {\n // Upon failure remove the rule, and resolve the promise.\n self._rules.splice(index, 1);\n return $.when();\n });\n promises.push(promise);\n });\n\n return $.when.apply($.when, promises);\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method _isValid\n * @protected\n */\n RuleConfig.prototype._isValid = function() {\n var outcome = this._getOutcome(),\n rule = this._getRule();\n\n if (outcome == Outcomes.NONE) {\n return true;\n } else if (!rule) {\n return false;\n }\n\n return rule.isValid();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n RuleConfig.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._preRender = function() {\n // We need to have all the information about the rule plugins first.\n return this.ready();\n };\n\n /**\n * Returns a promise that is resolved when the module is ready.\n *\n * @return {Promise}\n * @method ready\n * @protected\n */\n RuleConfig.prototype.ready = function() {\n return this._ready.promise();\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._render = function() {\n var self = this;\n return this._preRender().then(function() {\n var config;\n\n if (!self.canBeConfigured()) {\n config = false;\n } else {\n config = {};\n config.outcomes = self._getApplicableOutcomesOptions();\n config.rules = self._getApplicableRulesOptions();\n }\n\n var context = {\n competencyshortname: self._competency.shortname,\n config: config\n };\n\n return Templates.render('tool_lp/competency_rule_config', context);\n });\n };\n\n /**\n * Set the target competency.\n *\n * @param {Number} competencyId The target competency Id.\n * @method setTargetCompetencyId\n */\n RuleConfig.prototype.setTargetCompetencyId = function(competencyId) {\n var self = this;\n self._competency = self._tree.getCompetency(competencyId);\n $.each(self._rules, function(index, rule) {\n rule.setTargetCompetency(self._competency);\n });\n };\n\n /**\n * Set up the instance.\n *\n * @method _setUp\n * @protected\n */\n RuleConfig.prototype._setUp = function() {\n var self = this,\n promises = [],\n modules = [];\n\n self._ready = $.Deferred();\n self._rules = [];\n\n $.each(self._rulesModules, function(index, rule) {\n modules.push(rule.amd);\n });\n\n // Load all the modules.\n require(modules, function() {\n $.each(arguments, function(index, Module) {\n // Instantiate the rule and listen to it.\n var rule = new Module(self._tree);\n self._rules.push(rule);\n });\n\n // Load all the option values.\n promises.push(self._initRules());\n promises.push(self._initOutcomes());\n\n // Ready when everything is done.\n $.when.apply($.when, promises).always(function() {\n self._ready.resolve();\n });\n });\n };\n\n /**\n * Called when the user switches outcome.\n *\n * @method _switchedOutcome\n * @protected\n */\n RuleConfig.prototype._switchedOutcome = function() {\n var self = this,\n type = self._getOutcome();\n\n if (type == Outcomes.NONE) {\n // Reset to defaults.\n self._find('[data-region=\"rule-type\"]').hide()\n .find('[name=\"rule\"]').val(-1);\n self._find('[data-region=\"rule-config\"]').empty().hide();\n self._afterChange();\n return;\n }\n\n self._find('[data-region=\"rule-type\"]').show();\n self._find('[data-region=\"rule-config\"]').show();\n self._afterChange();\n };\n\n /**\n * Called when the user switches rule.\n *\n * @method _switchedRule\n * @protected\n */\n RuleConfig.prototype._switchedRule = function() {\n var self = this,\n container = self._find('[data-region=\"rule-config\"]'),\n rule = self._getRule();\n\n if (!rule) {\n container.empty().hide();\n self._afterChange();\n return;\n }\n rule.injectTemplate(container).then(function() {\n container.show();\n return;\n }).always(function() {\n self._afterChange();\n }).catch(function() {\n container.empty().hide();\n });\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n RuleConfig.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/competencyruleconfig */ RuleConfig;\n\n});\n"],"file":"competencyruleconfig.min.js"} \ No newline at end of file +{"version":3,"file":"competencyruleconfig.min.js","sources":["../src/competencyruleconfig.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 * Competency rule config.\n *\n * @module tool_lp/competencyruleconfig\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/competency_outcomes',\n 'core/str'],\n function($, Notification, Templates, Dialogue, Outcomes, Str) {\n\n /**\n * Competency rule class.\n *\n * When implementing this you should attach a listener to the event 'save'\n * on the instance. E.g.\n *\n * var config = new RuleConfig(tree, modules);\n * config.on('save', function(e, config) { ... });\n *\n * @param {competencytree} tree The competency tree.\n * @param {Array} rulesModules The modules containing the rules: [{ typeName: { amd: amdModule, name: ruleName }}].\n */\n var RuleConfig = function(tree, rulesModules) {\n this._eventNode = $('
');\n this._tree = tree;\n this._rulesModules = rulesModules;\n this._setUp();\n };\n\n /** @property {Object} The current competency. */\n RuleConfig.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n RuleConfig.prototype._eventNode = null;\n /** @property {Array} Outcomes options. */\n RuleConfig.prototype._outcomesOption = null;\n /** @property {Dialogue} The dialogue. */\n RuleConfig.prototype._popup = null;\n /** @property {Promise} Resolved when the module is ready. */\n RuleConfig.prototype._ready = null;\n /** @property {Array} The rules. */\n RuleConfig.prototype._rules = null;\n /** @property {Array} The rules modules. */\n RuleConfig.prototype._rulesModules = null;\n /** @property {competencytree} The competency tree. */\n RuleConfig.prototype._tree = null;\n\n /**\n * After change.\n *\n * Triggered when a change occured.\n *\n * @method _afterChange\n * @protected\n */\n RuleConfig.prototype._afterChange = function() {\n if (!this._isValid()) {\n this._find('[data-action=\"save\"]').prop('disabled', true);\n } else {\n this._find('[data-action=\"save\"]').prop('disabled', false);\n }\n };\n\n /**\n * After change in rule's config.\n *\n * Triggered when a change occured in a specific rule config.\n *\n * @method _afterRuleConfigChange\n * @protected\n * @param {Event} e\n * @param {Rule} rule\n */\n RuleConfig.prototype._afterRuleConfigChange = function(e, rule) {\n if (rule != this._getRule()) {\n // This rule is not the current one any more, we can ignore.\n return;\n }\n this._afterChange();\n };\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n RuleConfig.prototype._afterRender = function() {\n var self = this;\n\n self._find('[name=\"outcome\"]').on('change', function() {\n self._switchedOutcome();\n }).trigger('change');\n\n self._find('[name=\"rule\"]').on('change', function() {\n self._switchedRule();\n }).trigger('change');\n\n self._find('[data-action=\"save\"]').on('click', function() {\n self._trigger('save', self._getConfig());\n self.close();\n });\n\n self._find('[data-action=\"cancel\"]').on('click', function() {\n self.close();\n });\n };\n\n /**\n * Whether the current competency can be configured.\n *\n * @return {Boolean}\n * @method canBeConfigured\n */\n RuleConfig.prototype.canBeConfigured = function() {\n var can = false;\n $.each(this._rules, function(index, rule) {\n if (rule.canConfig()) {\n can = true;\n return;\n }\n });\n return can;\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n RuleConfig.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @returns {Promise}\n */\n RuleConfig.prototype.display = function() {\n var self = this;\n if (!self._competency) {\n return false;\n }\n return $.when(Str.get_string('competencyrule', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n * @protected\n */\n RuleConfig.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Get the applicable outcome options.\n *\n * @return {Array}\n * @method _getApplicableOutcomesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableOutcomesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._outcomesOption, function(index, outcome) {\n options.push({\n code: outcome.code,\n name: outcome.name,\n selected: (outcome.code == self._competency.ruleoutcome) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the applicable rules options.\n *\n * @return {Array}\n * @method _getApplicableRulesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableRulesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._rules, function(index, rule) {\n if (!rule.canConfig()) {\n return;\n }\n options.push({\n name: self._getRuleName(rule.getType()),\n type: rule.getType(),\n selected: (rule.getType() == self._competency.ruletype) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the full config for the competency.\n *\n * @return {Object} Contains rule, ruleoutcome and ruleconfig.\n * @method _getConfig\n * @protected\n */\n RuleConfig.prototype._getConfig = function() {\n var rule = this._getRule();\n return {\n ruletype: rule ? rule.getType() : null,\n ruleconfig: rule ? rule.getConfig() : null,\n ruleoutcome: this._getOutcome()\n };\n };\n\n /**\n * Get the selected outcome code.\n *\n * @return {String}\n * @method _getOutcome\n * @protected\n */\n RuleConfig.prototype._getOutcome = function() {\n return this._find('[name=\"outcome\"]').val();\n };\n\n /**\n * Get the selected rule.\n *\n * @return {null|Rule}\n * @method _getRule\n * @protected\n */\n RuleConfig.prototype._getRule = function() {\n var result,\n type = this._find('[name=\"rule\"]').val();\n\n $.each(this._rules, function(index, rule) {\n if (rule.getType() == type) {\n result = rule;\n return;\n }\n });\n\n return result;\n };\n\n /**\n * Return the name of a rule.\n *\n * @param {String} type The type of a rule.\n * @return {String}\n * @method _getRuleName\n * @protected\n */\n RuleConfig.prototype._getRuleName = function(type) {\n var self = this,\n name;\n $.each(self._rulesModules, function(index, modInfo) {\n if (modInfo.type == type) {\n name = modInfo.name;\n return;\n }\n });\n return name;\n };\n\n /**\n * Initialise the outcomes.\n *\n * @return {Promise}\n * @method _initOutcomes\n * @protected\n */\n RuleConfig.prototype._initOutcomes = function() {\n var self = this;\n return Outcomes.getAll().then(function(outcomes) {\n self._outcomesOption = outcomes;\n return;\n });\n };\n\n /**\n * Initialise the rules.\n *\n * @return {Promise}\n * @method _initRules\n * @protected\n */\n RuleConfig.prototype._initRules = function() {\n var self = this,\n promises = [];\n $.each(self._rules, function(index, rule) {\n var promise = rule.init().then(function() {\n rule.setTargetCompetency(self._competency);\n rule.on('change', self._afterRuleConfigChange.bind(self));\n return;\n }, function() {\n // Upon failure remove the rule, and resolve the promise.\n self._rules.splice(index, 1);\n return $.when();\n });\n promises.push(promise);\n });\n\n return $.when.apply($.when, promises);\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method _isValid\n * @protected\n */\n RuleConfig.prototype._isValid = function() {\n var outcome = this._getOutcome(),\n rule = this._getRule();\n\n if (outcome == Outcomes.NONE) {\n return true;\n } else if (!rule) {\n return false;\n }\n\n return rule.isValid();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n RuleConfig.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._preRender = function() {\n // We need to have all the information about the rule plugins first.\n return this.ready();\n };\n\n /**\n * Returns a promise that is resolved when the module is ready.\n *\n * @return {Promise}\n * @method ready\n * @protected\n */\n RuleConfig.prototype.ready = function() {\n return this._ready.promise();\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._render = function() {\n var self = this;\n return this._preRender().then(function() {\n var config;\n\n if (!self.canBeConfigured()) {\n config = false;\n } else {\n config = {};\n config.outcomes = self._getApplicableOutcomesOptions();\n config.rules = self._getApplicableRulesOptions();\n }\n\n var context = {\n competencyshortname: self._competency.shortname,\n config: config\n };\n\n return Templates.render('tool_lp/competency_rule_config', context);\n });\n };\n\n /**\n * Set the target competency.\n *\n * @param {Number} competencyId The target competency Id.\n * @method setTargetCompetencyId\n */\n RuleConfig.prototype.setTargetCompetencyId = function(competencyId) {\n var self = this;\n self._competency = self._tree.getCompetency(competencyId);\n $.each(self._rules, function(index, rule) {\n rule.setTargetCompetency(self._competency);\n });\n };\n\n /**\n * Set up the instance.\n *\n * @method _setUp\n * @protected\n */\n RuleConfig.prototype._setUp = function() {\n var self = this,\n promises = [],\n modules = [];\n\n self._ready = $.Deferred();\n self._rules = [];\n\n $.each(self._rulesModules, function(index, rule) {\n modules.push(rule.amd);\n });\n\n // Load all the modules.\n require(modules, function() {\n $.each(arguments, function(index, Module) {\n // Instantiate the rule and listen to it.\n var rule = new Module(self._tree);\n self._rules.push(rule);\n });\n\n // Load all the option values.\n promises.push(self._initRules());\n promises.push(self._initOutcomes());\n\n // Ready when everything is done.\n $.when.apply($.when, promises).always(function() {\n self._ready.resolve();\n });\n });\n };\n\n /**\n * Called when the user switches outcome.\n *\n * @method _switchedOutcome\n * @protected\n */\n RuleConfig.prototype._switchedOutcome = function() {\n var self = this,\n type = self._getOutcome();\n\n if (type == Outcomes.NONE) {\n // Reset to defaults.\n self._find('[data-region=\"rule-type\"]').hide()\n .find('[name=\"rule\"]').val(-1);\n self._find('[data-region=\"rule-config\"]').empty().hide();\n self._afterChange();\n return;\n }\n\n self._find('[data-region=\"rule-type\"]').show();\n self._find('[data-region=\"rule-config\"]').show();\n self._afterChange();\n };\n\n /**\n * Called when the user switches rule.\n *\n * @method _switchedRule\n * @protected\n */\n RuleConfig.prototype._switchedRule = function() {\n var self = this,\n container = self._find('[data-region=\"rule-config\"]'),\n rule = self._getRule();\n\n if (!rule) {\n container.empty().hide();\n self._afterChange();\n return;\n }\n rule.injectTemplate(container).then(function() {\n container.show();\n return;\n }).always(function() {\n self._afterChange();\n }).catch(function() {\n container.empty().hide();\n });\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n RuleConfig.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/competencyruleconfig */ RuleConfig;\n\n});\n"],"names":["define","$","Notification","Templates","Dialogue","Outcomes","Str","RuleConfig","tree","rulesModules","_eventNode","_tree","_rulesModules","_setUp","prototype","_competency","_outcomesOption","_popup","_ready","_rules","_afterChange","this","_isValid","_find","prop","_afterRuleConfigChange","e","rule","_getRule","_afterRender","self","on","_switchedOutcome","trigger","_switchedRule","_trigger","_getConfig","close","canBeConfigured","can","each","index","canConfig","display","when","get_string","_render","then","title","render","bind","fail","exception","selector","getContent","find","_getApplicableOutcomesOptions","options","outcome","push","code","name","selected","ruleoutcome","_getApplicableRulesOptions","_getRuleName","getType","type","ruletype","ruleconfig","getConfig","_getOutcome","val","result","modInfo","_initOutcomes","getAll","outcomes","_initRules","promises","promise","init","setTargetCompetency","splice","apply","NONE","isValid","handler","_preRender","ready","config","rules","context","competencyshortname","shortname","setTargetCompetencyId","competencyId","getCompetency","modules","Deferred","amd","require","arguments","Module","always","resolve","hide","empty","show","container","injectTemplate","catch","data"],"mappings":";;;;;;;AAuBAA,sCAAO,CA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AAM,CAAC6C,QAGsBzG"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencytree.min.js b/admin/tool/lp/amd/build/competencytree.min.js index 305c88a3c7f..6f3ab53f3da 100644 --- a/admin/tool/lp/amd/build/competencytree.min.js +++ b/admin/tool/lp/amd/build/competencytree.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/competencytree",["core/ajax","core/notification","core/templates","tool_lp/tree","tool_lp/competency_outcomes","jquery"],function(a,b,c,d,e,f){var g={},h=0,j="",k="",l="",m=!1,n=function(a,b){var c=0,d=!1;a.haschildren=!1;a.children=[];for(c=0;c + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/competencytree",["core/ajax","core/notification","core/templates","tool_lp/tree","tool_lp/competency_outcomes","jquery"],(function(ajax,notification,templates,Ariatree,CompOutcomes,$){var competencies={},competencyFrameworkId=0,competencyFrameworkShortName="",treeSelector="",currentNodeId="",competencyFramworkCanManage=!1,addChildren=function(parent,all){var i=0,current=!1;for(parent.haschildren=!1,parent.children=[],i=0;i0&&(currentNodeId=competencyid),this.on("selectionchanged",rememberCurrent)},on:function(eventname,handler){$(treeSelector).on(eventname,handler)},getChildren:function(id){var children=[];return $.each(competencies,(function(index,competency){competency.parentid==id&&children.push(competency)})),children},getCompetencyFrameworkId:function(){return competencyFrameworkId},getCompetency:function(id){return competencies[id]},getCompetencyLevel:function(id){return this.getCompetency(id).path.replace(/^\/|\/$/g,"").split("/").length},hasChildren:function(id){return this.getChildren(id).length>0},hasRule:function(id){var comp=this.getCompetency(id);return!!comp&&(comp.ruleoutcome!=CompOutcomes.OUTCOME_NONE&&comp.ruletype)},reloadCompetencies:function(){return loadCompetencies("").fail(notification.exception)},listCompetencies:function(){return competencies}}})); + +//# sourceMappingURL=competencytree.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencytree.min.js.map b/admin/tool/lp/amd/build/competencytree.min.js.map index 5d07f95700c..30b8cbf7e8e 100644 --- a/admin/tool/lp/amd/build/competencytree.min.js.map +++ b/admin/tool/lp/amd/build/competencytree.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencytree.js"],"names":["define","ajax","notification","templates","Ariatree","CompOutcomes","$","competencies","competencyFrameworkId","competencyFrameworkShortName","treeSelector","currentNodeId","competencyFramworkCanManage","addChildren","parent","all","i","current","haschildren","children","length","parentid","id","push","loadCompetencies","searchtext","deferred","Deferred","render","done","loadinghtml","loadingjs","replaceNodeContents","promises","call","methodname","args","competencyframeworkid","result","competency","parseInt","context","shortname","canmanage","html","js","tree","node","find","selectItem","updateFocus","resolve","fail","reject","promise","rememberCurrent","evt","params","selected","attr","init","search","selector","competencyid","exception","on","eventname","handler","getChildren","each","index","getCompetencyFrameworkId","getCompetency","getCompetencyLevel","level","path","replace","split","hasChildren","hasRule","comp","ruleoutcome","OUTCOME_NONE","ruletype","reloadCompetencies","listCompetencies"],"mappings":"AAsBAA,OAAM,0BAAC,CAAC,WAAD,CAAc,mBAAd,CAAmC,gBAAnC,CAAqD,cAArD,CAAqE,6BAArE,CAAoG,QAApG,CAAD,CACC,SAASC,CAAT,CAAeC,CAAf,CAA6BC,CAA7B,CAAwCC,CAAxC,CAAkDC,CAAlD,CAAgEC,CAAhE,CAAmE,IAIlEC,CAAAA,CAAY,CAAG,EAJmD,CAOlEC,CAAqB,CAAG,CAP0C,CAUlEC,CAA4B,CAAG,EAVmC,CAalEC,CAAY,CAAG,EAbmD,CAgBlEC,CAAa,CAAG,EAhBkD,CAmBlEC,CAA2B,GAnBuC,CA0BlEC,CAAW,CAAG,SAASC,CAAT,CAAiBC,CAAjB,CAAsB,IAChCC,CAAAA,CAAC,CAAG,CAD4B,CAEhCC,CAAO,GAFyB,CAGpCH,CAAM,CAACI,WAAP,IACAJ,CAAM,CAACK,QAAP,CAAkB,EAAlB,CACA,IAAKH,CAAC,CAAG,CAAT,CAAYA,CAAC,CAAGD,CAAG,CAACK,MAApB,CAA4BJ,CAAC,EAA7B,CAAiC,CAC7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Of,CAAAA,CAAY,CAACe,CAAD,CACtB,CAzE8C,CAiF/CmD,kBAAkB,CAAE,4BAASnD,CAAT,CAAa,CAC7B,GAAIiB,CAAAA,CAAU,CAAG,KAAKiC,aAAL,CAAmBlD,CAAnB,CAAjB,CACIoD,CAAK,CAAGnC,CAAU,CAACoC,IAAX,CAAgBC,OAAhB,CAAwB,UAAxB,CAAoC,EAApC,EAAwCC,KAAxC,CAA8C,GAA9C,EAAmDzD,MAD/D,CAEA,MAAOsD,CAAAA,CACV,CArF8C,CA8F/CI,WAAW,CAAE,qBAASxD,CAAT,CAAa,CACtB,MAAqC,EAA9B,MAAK8C,WAAL,CAAiB9C,CAAjB,EAAqBF,MAC/B,CAhG8C,CAwG/C2D,OAAO,CAAE,iBAASzD,CAAT,CAAa,CAClB,GAAI0D,CAAAA,CAAI,CAAG,KAAKR,aAAL,CAAmBlD,CAAnB,CAAX,CACA,GAAI0D,CAAJ,CAAU,CACN,MAAOA,CAAAA,CAAI,CAACC,WAAL,EAAoB5E,CAAY,CAAC6E,YAAjC,EACAF,CAAI,CAACG,QACf,CACD,QACH,CA/G8C,CAsH/CC,kBAAkB,CAAE,6BAAW,CAC3B,MAAO5D,CAAAA,CAAgB,CAAC,EAAD,CAAhB,CAAqB4B,IAArB,CAA0BlD,CAAY,CAAC8D,SAAvC,CACV,CAxH8C,CA+H/CqB,gBAAgB,CAAE,2BAAW,CACzB,MAAO9E,CAAAA,CACV,CAjI8C,CAoIrD,CAlPI,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 * Handle selection changes on the competency tree.\n *\n * @module tool_lp/competencyselect\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/ajax', 'core/notification', 'core/templates', 'tool_lp/tree', 'tool_lp/competency_outcomes', 'jquery'],\n function(ajax, notification, templates, Ariatree, CompOutcomes, $) {\n\n // Private variables and functions.\n /** @var {Object[]} competencies - Cached list of competencies */\n var competencies = {};\n\n /** @var {Number} competencyFrameworkId - The current framework id */\n var competencyFrameworkId = 0;\n\n /** @var {String} competencyFrameworkShortName - The current framework short name */\n var competencyFrameworkShortName = '';\n\n /** @var {String} treeSelector - The selector for the root of the tree. */\n var treeSelector = '';\n\n /** @var {String} currentNodeId - The data-id of the current node in the tree. */\n var currentNodeId = '';\n\n /** @var {Boolean} competencyFramworkCanManage - Can manage the competencies framework */\n var competencyFramworkCanManage = false;\n\n /**\n * Build a tree from the flat list of competencies.\n * @param {Object} parent The parent competency.\n * @param {Array} all The list of all competencies.\n */\n var addChildren = function(parent, all) {\n var i = 0;\n var current = false;\n parent.haschildren = false;\n parent.children = [];\n for (i = 0; i < all.length; i++) {\n current = all[i];\n if (current.parentid == parent.id) {\n parent.haschildren = true;\n parent.children.push(current);\n addChildren(current, all);\n }\n }\n };\n\n /**\n * Load the list of competencies via ajax. Competencies are filtered by the searchtext.\n * @param {String} searchtext The text to filter on.\n * @return {promise}\n */\n var loadCompetencies = function(searchtext) {\n var deferred = $.Deferred();\n\n templates.render('tool_lp/loading', {}).done(function(loadinghtml, loadingjs) {\n templates.replaceNodeContents($(treeSelector), loadinghtml, loadingjs);\n\n var promises = ajax.call([{\n methodname: 'core_competency_search_competencies',\n args: {\n searchtext: searchtext,\n competencyframeworkid: competencyFrameworkId\n }\n }]);\n promises[0].done(function(result) {\n competencies = {};\n var i = 0;\n for (i = 0; i < result.length; i++) {\n competencies[result[i].id] = result[i];\n }\n\n var children = [];\n var competency = false;\n for (i = 0; i < result.length; i++) {\n competency = result[i];\n if (parseInt(competency.parentid, 10) === 0) {\n children.push(competency);\n addChildren(competency, result);\n }\n }\n var context = {\n shortname: competencyFrameworkShortName,\n canmanage: competencyFramworkCanManage,\n competencies: children\n };\n templates.render('tool_lp/competencies_tree_root', context).done(function(html, js) {\n templates.replaceNodeContents($(treeSelector), $(html).html(), js);\n var tree = new Ariatree(treeSelector, false);\n\n if (currentNodeId) {\n var node = $(treeSelector).find('[data-id=' + currentNodeId + ']');\n if (node.length) {\n tree.selectItem(node);\n tree.updateFocus(node);\n }\n }\n deferred.resolve(competencies);\n }).fail(deferred.reject);\n }).fail(deferred.reject);\n });\n\n return deferred.promise();\n };\n\n /**\n * Whenever the current item in the tree is changed - remember the \"id\".\n * @param {Event} evt\n * @param {Object} params The parameters for the event (This is the selected node).\n */\n var rememberCurrent = function(evt, params) {\n var node = params.selected;\n currentNodeId = node.attr('data-id');\n };\n\n return /** @alias module:tool_lp/competencytree */ {\n // Public variables and functions.\n /**\n * Initialise the tree.\n *\n * @param {Number} id The competency framework id.\n * @param {String} shortname The framework shortname\n * @param {String} search The current search string\n * @param {String} selector The selector for the tree div\n * @param {Boolean} canmanage Can manage the competencies\n * @param {Number} competencyid The id of the competency to show first\n */\n init: function(id, shortname, search, selector, canmanage, competencyid) {\n competencyFrameworkId = id;\n competencyFrameworkShortName = shortname;\n competencyFramworkCanManage = canmanage;\n treeSelector = selector;\n loadCompetencies(search).fail(notification.exception);\n if (competencyid > 0) {\n currentNodeId = competencyid;\n }\n\n this.on('selectionchanged', rememberCurrent);\n },\n\n /**\n * Add an event handler for custom events emitted by the tree.\n *\n * @param {String} eventname The name of the event - only \"selectionchanged\" for now\n * @param {Function} handler The handler for the event.\n */\n on: function(eventname, handler) {\n // We can't use the tree on function directly\n // because the tree gets rebuilt whenever the search string changes,\n // instead we attach the listner to the root node of the tree which never\n // gets destroyed (same as \"on()\" code in the tree.js).\n $(treeSelector).on(eventname, handler);\n },\n\n /**\n * Get the children of a competency.\n *\n * @param {Number} id The competency ID.\n * @return {Array}\n * @method getChildren\n */\n getChildren: function(id) {\n var children = [];\n $.each(competencies, function(index, competency) {\n if (competency.parentid == id) {\n children.push(competency);\n }\n });\n return children;\n },\n\n /**\n * Get the competency framework id this model was initiliased with.\n *\n * @return {Number}\n */\n getCompetencyFrameworkId: function() {\n return competencyFrameworkId;\n },\n\n /**\n * Get a competency by id\n *\n * @param {Number} id The competency id\n * @return {Object}\n */\n getCompetency: function(id) {\n return competencies[id];\n },\n\n /**\n * Get the competency level.\n *\n * @param {Number} id The competency ID.\n * @return {Number}\n */\n getCompetencyLevel: function(id) {\n var competency = this.getCompetency(id),\n level = competency.path.replace(/^\\/|\\/$/g, '').split('/').length;\n return level;\n },\n\n /**\n * Whether a competency has children.\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n * @method hasChildren\n */\n hasChildren: function(id) {\n return this.getChildren(id).length > 0;\n },\n\n /**\n * Does the competency have a rule?\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n */\n hasRule: function(id) {\n var comp = this.getCompetency(id);\n if (comp) {\n return comp.ruleoutcome != CompOutcomes.OUTCOME_NONE\n && comp.ruletype;\n }\n return false;\n },\n\n /**\n * Reload all the page competencies framework competencies.\n * @method reloadCompetencies\n * @return {Promise}\n */\n reloadCompetencies: function() {\n return loadCompetencies('').fail(notification.exception);\n },\n\n /**\n * Get all competencies for this framework.\n *\n * @return {Object[]}\n */\n listCompetencies: function() {\n return competencies;\n },\n\n };\n });\n"],"file":"competencytree.min.js"} \ No newline at end of file +{"version":3,"file":"competencytree.min.js","sources":["../src/competencytree.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 * Handle selection changes on the competency tree.\n *\n * @module tool_lp/competencyselect\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/ajax', 'core/notification', 'core/templates', 'tool_lp/tree', 'tool_lp/competency_outcomes', 'jquery'],\n function(ajax, notification, templates, Ariatree, CompOutcomes, $) {\n\n // Private variables and functions.\n /** @var {Object[]} competencies - Cached list of competencies */\n var competencies = {};\n\n /** @var {Number} competencyFrameworkId - The current framework id */\n var competencyFrameworkId = 0;\n\n /** @var {String} competencyFrameworkShortName - The current framework short name */\n var competencyFrameworkShortName = '';\n\n /** @var {String} treeSelector - The selector for the root of the tree. */\n var treeSelector = '';\n\n /** @var {String} currentNodeId - The data-id of the current node in the tree. */\n var currentNodeId = '';\n\n /** @var {Boolean} competencyFramworkCanManage - Can manage the competencies framework */\n var competencyFramworkCanManage = false;\n\n /**\n * Build a tree from the flat list of competencies.\n * @param {Object} parent The parent competency.\n * @param {Array} all The list of all competencies.\n */\n var addChildren = function(parent, all) {\n var i = 0;\n var current = false;\n parent.haschildren = false;\n parent.children = [];\n for (i = 0; i < all.length; i++) {\n current = all[i];\n if (current.parentid == parent.id) {\n parent.haschildren = true;\n parent.children.push(current);\n addChildren(current, all);\n }\n }\n };\n\n /**\n * Load the list of competencies via ajax. Competencies are filtered by the searchtext.\n * @param {String} searchtext The text to filter on.\n * @return {promise}\n */\n var loadCompetencies = function(searchtext) {\n var deferred = $.Deferred();\n\n templates.render('tool_lp/loading', {}).done(function(loadinghtml, loadingjs) {\n templates.replaceNodeContents($(treeSelector), loadinghtml, loadingjs);\n\n var promises = ajax.call([{\n methodname: 'core_competency_search_competencies',\n args: {\n searchtext: searchtext,\n competencyframeworkid: competencyFrameworkId\n }\n }]);\n promises[0].done(function(result) {\n competencies = {};\n var i = 0;\n for (i = 0; i < result.length; i++) {\n competencies[result[i].id] = result[i];\n }\n\n var children = [];\n var competency = false;\n for (i = 0; i < result.length; i++) {\n competency = result[i];\n if (parseInt(competency.parentid, 10) === 0) {\n children.push(competency);\n addChildren(competency, result);\n }\n }\n var context = {\n shortname: competencyFrameworkShortName,\n canmanage: competencyFramworkCanManage,\n competencies: children\n };\n templates.render('tool_lp/competencies_tree_root', context).done(function(html, js) {\n templates.replaceNodeContents($(treeSelector), $(html).html(), js);\n var tree = new Ariatree(treeSelector, false);\n\n if (currentNodeId) {\n var node = $(treeSelector).find('[data-id=' + currentNodeId + ']');\n if (node.length) {\n tree.selectItem(node);\n tree.updateFocus(node);\n }\n }\n deferred.resolve(competencies);\n }).fail(deferred.reject);\n }).fail(deferred.reject);\n });\n\n return deferred.promise();\n };\n\n /**\n * Whenever the current item in the tree is changed - remember the \"id\".\n * @param {Event} evt\n * @param {Object} params The parameters for the event (This is the selected node).\n */\n var rememberCurrent = function(evt, params) {\n var node = params.selected;\n currentNodeId = node.attr('data-id');\n };\n\n return /** @alias module:tool_lp/competencytree */ {\n // Public variables and functions.\n /**\n * Initialise the tree.\n *\n * @param {Number} id The competency framework id.\n * @param {String} shortname The framework shortname\n * @param {String} search The current search string\n * @param {String} selector The selector for the tree div\n * @param {Boolean} canmanage Can manage the competencies\n * @param {Number} competencyid The id of the competency to show first\n */\n init: function(id, shortname, search, selector, canmanage, competencyid) {\n competencyFrameworkId = id;\n competencyFrameworkShortName = shortname;\n competencyFramworkCanManage = canmanage;\n treeSelector = selector;\n loadCompetencies(search).fail(notification.exception);\n if (competencyid > 0) {\n currentNodeId = competencyid;\n }\n\n this.on('selectionchanged', rememberCurrent);\n },\n\n /**\n * Add an event handler for custom events emitted by the tree.\n *\n * @param {String} eventname The name of the event - only \"selectionchanged\" for now\n * @param {Function} handler The handler for the event.\n */\n on: function(eventname, handler) {\n // We can't use the tree on function directly\n // because the tree gets rebuilt whenever the search string changes,\n // instead we attach the listner to the root node of the tree which never\n // gets destroyed (same as \"on()\" code in the tree.js).\n $(treeSelector).on(eventname, handler);\n },\n\n /**\n * Get the children of a competency.\n *\n * @param {Number} id The competency ID.\n * @return {Array}\n * @method getChildren\n */\n getChildren: function(id) {\n var children = [];\n $.each(competencies, function(index, competency) {\n if (competency.parentid == id) {\n children.push(competency);\n }\n });\n return children;\n },\n\n /**\n * Get the competency framework id this model was initiliased with.\n *\n * @return {Number}\n */\n getCompetencyFrameworkId: function() {\n return competencyFrameworkId;\n },\n\n /**\n * Get a competency by id\n *\n * @param {Number} id The competency id\n * @return {Object}\n */\n getCompetency: function(id) {\n return competencies[id];\n },\n\n /**\n * Get the competency level.\n *\n * @param {Number} id The competency ID.\n * @return {Number}\n */\n getCompetencyLevel: function(id) {\n var competency = this.getCompetency(id),\n level = competency.path.replace(/^\\/|\\/$/g, '').split('/').length;\n return level;\n },\n\n /**\n * Whether a competency has children.\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n * @method hasChildren\n */\n hasChildren: function(id) {\n return this.getChildren(id).length > 0;\n },\n\n /**\n * Does the competency have a rule?\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n */\n hasRule: function(id) {\n var comp = this.getCompetency(id);\n if (comp) {\n return comp.ruleoutcome != CompOutcomes.OUTCOME_NONE\n && comp.ruletype;\n }\n return false;\n },\n\n /**\n * Reload all the page competencies framework competencies.\n * @method reloadCompetencies\n * @return {Promise}\n */\n reloadCompetencies: function() {\n return loadCompetencies('').fail(notification.exception);\n },\n\n /**\n * Get all competencies for this framework.\n *\n * @return {Object[]}\n */\n listCompetencies: function() {\n return competencies;\n },\n\n };\n });\n"],"names":["define","ajax","notification","templates","Ariatree","CompOutcomes","$","competencies","competencyFrameworkId","competencyFrameworkShortName","treeSelector","currentNodeId","competencyFramworkCanManage","addChildren","parent","all","i","current","haschildren","children","length","parentid","id","push","loadCompetencies","searchtext","deferred","Deferred","render","done","loadinghtml","loadingjs","replaceNodeContents","call","methodname","args","competencyframeworkid","result","competency","parseInt","context","shortname","canmanage","html","js","tree","node","find","selectItem","updateFocus","resolve","fail","reject","promise","rememberCurrent","evt","params","selected","attr","init","search","selector","competencyid","exception","on","eventname","handler","getChildren","each","index","getCompetencyFrameworkId","getCompetency","getCompetencyLevel","this","path","replace","split","hasChildren","hasRule","comp","ruleoutcome","OUTCOME_NONE","ruletype","reloadCompetencies","listCompetencies"],"mappings":";;;;;;;AAsBAA,gCAAO,CAAC,YAAa,oBAAqB,iBAAkB,eAAgB,8BAA+B,WACpG,SAASC,KAAMC,aAAcC,UAAWC,SAAUC,aAAcC,OAI/DC,aAAe,GAGfC,sBAAwB,EAGxBC,6BAA+B,GAG/BC,aAAe,GAGfC,cAAgB,GAGhBC,6BAA8B,EAO9BC,YAAc,SAASC,OAAQC,SAC3BC,EAAI,EACJC,SAAU,MACdH,OAAOI,aAAc,EACrBJ,OAAOK,SAAW,GACbH,EAAI,EAAGA,EAAID,IAAIK,OAAQJ,KACxBC,QAAUF,IAAIC,IACFK,UAAYP,OAAOQ,KAC3BR,OAAOI,aAAc,EACrBJ,OAAOK,SAASI,KAAKN,SACrBJ,YAAYI,QAASF,OAU7BS,iBAAmB,SAASC,gBACxBC,SAAWpB,EAAEqB,kBAEjBxB,UAAUyB,OAAO,kBAAmB,IAAIC,MAAK,SAASC,YAAaC,WAC/D5B,UAAU6B,oBAAoB1B,EAAEI,cAAeoB,YAAaC,WAE7C9B,KAAKgC,KAAK,CAAC,CACtBC,WAAY,sCACZC,KAAM,CACFV,WAAYA,WACZW,sBAAuB5B,0BAGtB,GAAGqB,MAAK,SAASQ,QACtB9B,aAAe,OACXS,EAAI,MACHA,EAAI,EAAGA,EAAIqB,OAAOjB,OAAQJ,IAC3BT,aAAa8B,OAAOrB,GAAGM,IAAMe,OAAOrB,OAGpCG,SAAW,GACXmB,YAAa,MACZtB,EAAI,EAAGA,EAAIqB,OAAOjB,OAAQJ,IAC3BsB,WAAaD,OAAOrB,GACsB,IAAtCuB,SAASD,WAAWjB,SAAU,MAC9BF,SAASI,KAAK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,KAAON,KAAKF,cAAcjD,YAC1ByD,OACOA,KAAKC,aAAe3E,aAAa4E,cACjCF,KAAKG,WAUpBC,mBAAoB,kBACT3D,iBAAiB,IAAI2B,KAAKjD,aAAa6D,YAQlDqB,iBAAkB,kBACP7E"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/course_competency_settings.min.js b/admin/tool/lp/amd/build/course_competency_settings.min.js index 496c31ddee0..71086022821 100644 --- a/admin/tool/lp/amd/build/course_competency_settings.min.js +++ b/admin/tool/lp/amd/build/course_competency_settings.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/course_competency_settings",["jquery","core/notification","tool_lp/dialogue","core/str","core/ajax","core/templates","core/pending"],function(a,b,c,d,f,g,h){var i=function(b){a(b).on("click",this.configureSettings.bind(this))};i.prototype._dialogue=null;i.prototype.configureSettings=function(f){var e=new h,i=a(f.target).closest("a").data("courseid"),j=a(f.target).closest("a").data("pushratingstouserplans");f.preventDefault();a.when(d.get_string("configurecoursecompetencysettings","tool_lp"),g.render("tool_lp/course_competency_settings",{courseid:i,settings:{pushratingstouserplans:j}})).then(function(a,b){this._dialogue=new c(a,b[0],this.addListeners.bind(this));return this._dialogue}.bind(this)).then(e.resolve).catch(b.exception)};i.prototype.addListeners=function(){var a=this._find("[data-action=\"save\"]");a.on("click",this.saveSettings.bind(this));var b=this._find("[data-action=\"cancel\"]");b.on("click",this.cancelChanges.bind(this))};i.prototype.cancelChanges=function(a){a.preventDefault();this._dialogue.close()};i.prototype._find=function(b){return a("[data-region=\"coursecompetencysettings\"]").find(b)};i.prototype.saveSettings=function(a){var c=new h;a.preventDefault();var d=this._find("input[name=\"pushratingstouserplans\"]:checked").val(),e=this._find("input[name=\"courseid\"]").val();f.call([{methodname:"core_competency_update_course_competency_settings",args:{courseid:e,settings:{pushratingstouserplans:d}}}])[0].then(function(){return this.refreshCourseCompetenciesPage()}.bind(this)).then(c.resolve).catch(b.exception)};i.prototype.refreshCourseCompetenciesPage=function(){var c=this._find("input[name=\"courseid\"]").val(),d=new h;f.call([{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:c,moduleid:0}}])[0].then(function(a){return g.render("tool_lp/course_competencies_page",a)}).then(function(b,c){g.replaceNode(a("[data-region=\"coursecompetenciespage\"]"),b,c);this._dialogue.close()}.bind(this)).then(d.resolve).catch(b.exception)};return i}); -//# sourceMappingURL=course_competency_settings.min.js.map +/** + * Change the course competency settings in a popup. + * + * @module tool_lp/configurecoursecompetencysettings + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/course_competency_settings",["jquery","core/notification","tool_lp/dialogue","core/str","core/ajax","core/templates","core/pending"],(function($,notification,Dialogue,str,ajax,templates,Pending){var settingsMod=function(selector){$(selector).on("click",this.configureSettings.bind(this))};return settingsMod.prototype._dialogue=null,settingsMod.prototype.configureSettings=function(e){var pendingPromise=new Pending,context={courseid:$(e.target).closest("a").data("courseid"),settings:{pushratingstouserplans:$(e.target).closest("a").data("pushratingstouserplans")}};e.preventDefault(),$.when(str.get_string("configurecoursecompetencysettings","tool_lp"),templates.render("tool_lp/course_competency_settings",context)).then(function(title,templateResult){return this._dialogue=new Dialogue(title,templateResult[0],this.addListeners.bind(this)),this._dialogue}.bind(this)).then(pendingPromise.resolve).catch(notification.exception)},settingsMod.prototype.addListeners=function(){this._find('[data-action="save"]').on("click",this.saveSettings.bind(this)),this._find('[data-action="cancel"]').on("click",this.cancelChanges.bind(this))},settingsMod.prototype.cancelChanges=function(e){e.preventDefault(),this._dialogue.close()},settingsMod.prototype._find=function(selector){return $('[data-region="coursecompetencysettings"]').find(selector)},settingsMod.prototype.saveSettings=function(e){var pendingPromise=new Pending;e.preventDefault();var newValue=this._find('input[name="pushratingstouserplans"]:checked').val(),courseId=this._find('input[name="courseid"]').val(),settings={pushratingstouserplans:newValue};ajax.call([{methodname:"core_competency_update_course_competency_settings",args:{courseid:courseId,settings:settings}}])[0].then(function(){return this.refreshCourseCompetenciesPage()}.bind(this)).then(pendingPromise.resolve).catch(notification.exception)},settingsMod.prototype.refreshCourseCompetenciesPage=function(){var courseId=this._find('input[name="courseid"]').val(),pendingPromise=new Pending;ajax.call([{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:courseId,moduleid:0}}])[0].then((function(context){return templates.render("tool_lp/course_competencies_page",context)})).then(function(html,js){templates.replaceNode($('[data-region="coursecompetenciespage"]'),html,js),this._dialogue.close()}.bind(this)).then(pendingPromise.resolve).catch(notification.exception)},settingsMod})); + +//# sourceMappingURL=course_competency_settings.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/course_competency_settings.min.js.map b/admin/tool/lp/amd/build/course_competency_settings.min.js.map index 2011dcea9e3..f473cf570da 100644 --- a/admin/tool/lp/amd/build/course_competency_settings.min.js.map +++ b/admin/tool/lp/amd/build/course_competency_settings.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/course_competency_settings.js"],"names":["define","$","notification","Dialogue","str","ajax","templates","Pending","settingsMod","selector","on","configureSettings","bind","prototype","_dialogue","e","pendingPromise","courseid","target","closest","data","currentValue","preventDefault","when","get_string","render","settings","pushratingstouserplans","then","title","templateResult","addListeners","resolve","catch","exception","save","_find","saveSettings","cancel","cancelChanges","close","find","newValue","val","courseId","call","methodname","args","refreshCourseCompetenciesPage","moduleid","context","html","js","replaceNode"],"mappings":"AAsBAA,OAAM,sCAAC,CAAC,QAAD,CACC,mBADD,CAEC,kBAFD,CAGC,UAHD,CAIC,WAJD,CAKC,gBALD,CAMC,cAND,CAAD,CAQC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAoCC,CAApC,CAAyCC,CAAzC,CAA+CC,CAA/C,CAA0DC,CAA1D,CAAmE,CAOtE,GAAIC,CAAAA,CAAW,CAAG,SAASC,CAAT,CAAmB,CACjCR,CAAC,CAACQ,CAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,KAAKC,iBAAL,CAAuBC,IAAvB,CAA4B,IAA5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D,CAyBA1B,CAAW,CAACK,SAAZ,CAAsBmC,6BAAtB,CAAsD,UAAW,IACzDJ,CAAAA,CAAQ,CAAG,KAAKR,KAAL,CAAW,0BAAX,EAAqCO,GAArC,EAD8C,CAEzD3B,CAAc,CAAG,GAAIT,CAAAA,CAFoC,CAI7DF,CAAI,CAACwC,IAAL,CAAU,CACN,CAACC,UAAU,CAAE,2CAAb,CACEC,IAAI,CAAE,CAAC9B,QAAQ,CAAE2B,CAAX,CAAqBK,QAAQ,CAAE,CAA/B,CADR,CADM,CAAV,EAGG,CAHH,EAICrB,IAJD,CAIM,SAASsB,CAAT,CAAkB,CACpB,MAAO5C,CAAAA,CAAS,CAACmB,MAAV,CAAiB,kCAAjB,CAAqDyB,CAArD,CACV,CAND,EAOCtB,IAPD,CAOM,SAASuB,CAAT,CAAeC,CAAf,CAAmB,CACrB9C,CAAS,CAAC+C,WAAV,CAAsBpD,CAAC,CAAC,0CAAD,CAAvB,CAAmEkD,CAAnE,CAAyEC,CAAzE,EACA,KAAKtC,SAAL,CAAe0B,KAAf,EAGH,CALK,CAKJ5B,IALI,CAKC,IALD,CAPN,EAaCgB,IAbD,CAaMZ,CAAc,CAACgB,OAbrB,EAcCC,KAdD,CAcO/B,CAAY,CAACgC,SAdpB,CAeH,CAnBD,CAqBA,MAAsE1B,CAAAA,CACzE,CA7IK,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 * Change the course competency settings in a popup.\n *\n * @module tool_lp/configurecoursecompetencysettings\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'tool_lp/dialogue',\n 'core/str',\n 'core/ajax',\n 'core/templates',\n 'core/pending'\n ],\n function($, notification, Dialogue, str, ajax, templates, Pending) {\n\n /**\n * Constructor\n *\n * @param {String} selector - selector for the links to open the dialogue.\n */\n var settingsMod = function(selector) {\n $(selector).on('click', this.configureSettings.bind(this));\n };\n\n /** @property {Dialogue} Reference to the dialogue that we opened. */\n settingsMod.prototype._dialogue = null;\n\n /**\n * Open the configure settings dialogue.\n *\n * @param {Event} e\n * @method configureSettings\n */\n settingsMod.prototype.configureSettings = function(e) {\n var pendingPromise = new Pending();\n var courseid = $(e.target).closest('a').data('courseid');\n var currentValue = $(e.target).closest('a').data('pushratingstouserplans');\n var context = {\n courseid: courseid,\n settings: {pushratingstouserplans: currentValue}\n };\n e.preventDefault();\n\n $.when(\n str.get_string('configurecoursecompetencysettings', 'tool_lp'),\n templates.render('tool_lp/course_competency_settings', context),\n )\n .then(function(title, templateResult) {\n this._dialogue = new Dialogue(\n title,\n templateResult[0],\n this.addListeners.bind(this)\n );\n\n return this._dialogue;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n /**\n * Add the save listener to the form.\n *\n * @method addSaveListener\n */\n settingsMod.prototype.addListeners = function() {\n var save = this._find('[data-action=\"save\"]');\n save.on('click', this.saveSettings.bind(this));\n var cancel = this._find('[data-action=\"cancel\"]');\n cancel.on('click', this.cancelChanges.bind(this));\n };\n\n /**\n * Cancel the changes.\n *\n * @param {Event} e\n * @method cancelChanges\n */\n settingsMod.prototype.cancelChanges = function(e) {\n e.preventDefault();\n this._dialogue.close();\n };\n\n /**\n * Cancel the changes.\n *\n * @param {String} selector\n * @return {JQuery}\n */\n settingsMod.prototype._find = function(selector) {\n return $('[data-region=\"coursecompetencysettings\"]').find(selector);\n };\n\n /**\n * Save the settings.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.saveSettings = function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n var newValue = this._find('input[name=\"pushratingstouserplans\"]:checked').val();\n var courseId = this._find('input[name=\"courseid\"]').val();\n var settings = {pushratingstouserplans: newValue};\n\n ajax.call([\n {methodname: 'core_competency_update_course_competency_settings',\n args: {courseid: courseId, settings: settings}}\n ])[0]\n .then(function() {\n return this.refreshCourseCompetenciesPage();\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n\n };\n\n /**\n * Refresh the course competencies page.\n *\n * @method saveSettings\n */\n settingsMod.prototype.refreshCourseCompetenciesPage = function() {\n var courseId = this._find('input[name=\"courseid\"]').val();\n var pendingPromise = new Pending();\n\n ajax.call([\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: courseId, moduleid: 0}}\n ])[0]\n .then(function(context) {\n return templates.render('tool_lp/course_competencies_page', context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"coursecompetenciespage\"]'), html, js);\n this._dialogue.close();\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod;\n});\n"],"file":"course_competency_settings.min.js"} \ No newline at end of file +{"version":3,"file":"course_competency_settings.min.js","sources":["../src/course_competency_settings.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 * Change the course competency settings in a popup.\n *\n * @module tool_lp/configurecoursecompetencysettings\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'tool_lp/dialogue',\n 'core/str',\n 'core/ajax',\n 'core/templates',\n 'core/pending'\n ],\n function($, notification, Dialogue, str, ajax, templates, Pending) {\n\n /**\n * Constructor\n *\n * @param {String} selector - selector for the links to open the dialogue.\n */\n var settingsMod = function(selector) {\n $(selector).on('click', this.configureSettings.bind(this));\n };\n\n /** @property {Dialogue} Reference to the dialogue that we opened. */\n settingsMod.prototype._dialogue = null;\n\n /**\n * Open the configure settings dialogue.\n *\n * @param {Event} e\n * @method configureSettings\n */\n settingsMod.prototype.configureSettings = function(e) {\n var pendingPromise = new Pending();\n var courseid = $(e.target).closest('a').data('courseid');\n var currentValue = $(e.target).closest('a').data('pushratingstouserplans');\n var context = {\n courseid: courseid,\n settings: {pushratingstouserplans: currentValue}\n };\n e.preventDefault();\n\n $.when(\n str.get_string('configurecoursecompetencysettings', 'tool_lp'),\n templates.render('tool_lp/course_competency_settings', context),\n )\n .then(function(title, templateResult) {\n this._dialogue = new Dialogue(\n title,\n templateResult[0],\n this.addListeners.bind(this)\n );\n\n return this._dialogue;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n /**\n * Add the save listener to the form.\n *\n * @method addSaveListener\n */\n settingsMod.prototype.addListeners = function() {\n var save = this._find('[data-action=\"save\"]');\n save.on('click', this.saveSettings.bind(this));\n var cancel = this._find('[data-action=\"cancel\"]');\n cancel.on('click', this.cancelChanges.bind(this));\n };\n\n /**\n * Cancel the changes.\n *\n * @param {Event} e\n * @method cancelChanges\n */\n settingsMod.prototype.cancelChanges = function(e) {\n e.preventDefault();\n this._dialogue.close();\n };\n\n /**\n * Cancel the changes.\n *\n * @param {String} selector\n * @return {JQuery}\n */\n settingsMod.prototype._find = function(selector) {\n return $('[data-region=\"coursecompetencysettings\"]').find(selector);\n };\n\n /**\n * Save the settings.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.saveSettings = function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n var newValue = this._find('input[name=\"pushratingstouserplans\"]:checked').val();\n var courseId = this._find('input[name=\"courseid\"]').val();\n var settings = {pushratingstouserplans: newValue};\n\n ajax.call([\n {methodname: 'core_competency_update_course_competency_settings',\n args: {courseid: courseId, settings: settings}}\n ])[0]\n .then(function() {\n return this.refreshCourseCompetenciesPage();\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n\n };\n\n /**\n * Refresh the course competencies page.\n *\n * @method saveSettings\n */\n settingsMod.prototype.refreshCourseCompetenciesPage = function() {\n var courseId = this._find('input[name=\"courseid\"]').val();\n var pendingPromise = new Pending();\n\n ajax.call([\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: courseId, moduleid: 0}}\n ])[0]\n .then(function(context) {\n return templates.render('tool_lp/course_competencies_page', context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"coursecompetenciespage\"]'), html, js);\n this._dialogue.close();\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod;\n});\n"],"names":["define","$","notification","Dialogue","str","ajax","templates","Pending","settingsMod","selector","on","this","configureSettings","bind","prototype","_dialogue","e","pendingPromise","context","courseid","target","closest","data","settings","pushratingstouserplans","preventDefault","when","get_string","render","then","title","templateResult","addListeners","resolve","catch","exception","_find","saveSettings","cancelChanges","close","find","newValue","val","courseId","call","methodname","args","refreshCourseCompetenciesPage","moduleid","html","js","replaceNode"],"mappings":";;;;;;;AAsBAA,4CAAO,CAAC,SACA,oBACA,mBACA,WACA,YACA,iBACA,iBAED,SAASC,EAAGC,aAAcC,SAAUC,IAAKC,KAAMC,UAAWC,aAOzDC,YAAc,SAASC,UACvBR,EAAEQ,UAAUC,GAAG,QAASC,KAAKC,kBAAkBC,KAAKF,eAIxDH,YAAYM,UAAUC,UAAY,KAQlCP,YAAYM,UAAUF,kBAA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,KAAKuC,KAAK,CACN,CAACC,WAAY,4CACXC,KAAM,CAAC3B,SAAUwB,SAAUK,SAAU,MACxC,GACFnB,MAAK,SAASX,gBACJZ,UAAUsB,OAAO,mCAAoCV,YAE/DW,KAAK,SAASoB,KAAMC,IACjB5C,UAAU6C,YAAYlD,EAAE,0CAA2CgD,KAAMC,SACpEnC,UAAUwB,SAGjB1B,KAAKF,OACNkB,KAAKZ,eAAegB,SACpBC,MAAMhC,aAAaiC,YAG8C3B"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/dialogue.min.js b/admin/tool/lp/amd/build/dialogue.min.js index 6e0c86cdfbd..21d72a304b2 100644 --- a/admin/tool/lp/amd/build/dialogue.min.js +++ b/admin/tool/lp/amd/build/dialogue.min.js @@ -1,2 +1,11 @@ -define ("tool_lp/dialogue",["core/yui"],function(a){var b=function(b,c,d,e,f){M.util.js_pending("tool_lp/dialogue:dialogue");this.yuiDialogue=null;var g=this;if("undefined"==typeof f){f=!1}a.use("moodle-core-notification","timers",function(){var h="480px";if(f){h="800px"}g.yuiDialogue=new M.core.dialogue({headerContent:b,bodyContent:c,draggable:!0,visible:!1,center:!0,modal:!0,width:h});g.yuiDialogue.before("visibleChange",function(){M.util.js_pending("tool_lp/dialogue:before:visibleChange")});g.yuiDialogue.after("visibleChange",function(b){if(b.newVal){if("undefined"!=typeof d){a.soon(function(){d(g);g.yuiDialogue.centerDialogue();M.util.js_complete("tool_lp/dialogue:before:visibleChange")})}else{M.util.js_complete("tool_lp/dialogue:before:visibleChange")}}else{if("undefined"!=typeof e){a.soon(function(){e(g);M.util.js_complete("tool_lp/dialogue:before:visibleChange")})}else{M.util.js_complete("tool_lp/dialogue:before:visibleChange")}}});g.yuiDialogue.show();M.util.js_complete("tool_lp/dialogue:dialogue")})};b.prototype.close=function(){this.yuiDialogue.hide();this.yuiDialogue.destroy()};b.prototype.getContent=function(){return this.yuiDialogue.bodyNode.getDOMNode()};return b}); -//# sourceMappingURL=dialogue.min.js.map +/** + * Wrapper for the YUI M.core.notification class. Allows us to + * use the YUI version in AMD code until it is replaced. + * + * @module tool_lp/dialogue + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/dialogue",["core/yui"],(function(Y){var dialogue=function(title,content,afterShow,afterHide,wide){M.util.js_pending("tool_lp/dialogue:dialogue"),this.yuiDialogue=null;var parent=this;void 0===wide&&(wide=!1),Y.use("moodle-core-notification","timers",(function(){var width="480px";wide&&(width="800px"),parent.yuiDialogue=new M.core.dialogue({headerContent:title,bodyContent:content,draggable:!0,visible:!1,center:!0,modal:!0,width:width}),parent.yuiDialogue.before("visibleChange",(function(){M.util.js_pending("tool_lp/dialogue:before:visibleChange")})),parent.yuiDialogue.after("visibleChange",(function(e){e.newVal?void 0!==afterShow?Y.soon((function(){afterShow(parent),parent.yuiDialogue.centerDialogue(),M.util.js_complete("tool_lp/dialogue:before:visibleChange")})):M.util.js_complete("tool_lp/dialogue:before:visibleChange"):void 0!==afterHide?Y.soon((function(){afterHide(parent),M.util.js_complete("tool_lp/dialogue:before:visibleChange")})):M.util.js_complete("tool_lp/dialogue:before:visibleChange")})),parent.yuiDialogue.show(),M.util.js_complete("tool_lp/dialogue:dialogue")}))};return dialogue.prototype.close=function(){this.yuiDialogue.hide(),this.yuiDialogue.destroy()},dialogue.prototype.getContent=function(){return this.yuiDialogue.bodyNode.getDOMNode()},dialogue})); + +//# sourceMappingURL=dialogue.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/dialogue.min.js.map b/admin/tool/lp/amd/build/dialogue.min.js.map index 410139a4b1d..97577b8780a 100644 --- a/admin/tool/lp/amd/build/dialogue.min.js.map +++ b/admin/tool/lp/amd/build/dialogue.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/dialogue.js"],"names":["define","Y","dialogue","title","content","afterShow","afterHide","wide","M","util","js_pending","yuiDialogue","parent","use","width","core","headerContent","bodyContent","draggable","visible","center","modal","before","after","e","newVal","soon","centerDialogue","js_complete","show","prototype","close","hide","destroy","getContent","bodyNode","getDOMNode"],"mappings":"AAuBAA,OAAM,oBAAC,CAAC,UAAD,CAAD,CAAe,SAASC,CAAT,CAAY,CAY7B,GAAIC,CAAAA,CAAQ,CAAG,SAASC,CAAT,CAAgBC,CAAhB,CAAyBC,CAAzB,CAAoCC,CAApC,CAA+CC,CAA/C,CAAqD,CAChEC,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,2BAAlB,EAEA,KAAKC,WAAL,CAAmB,IAAnB,CACA,GAAIC,CAAAA,CAAM,CAAG,IAAb,CAGA,GAAmB,WAAf,QAAOL,CAAAA,CAAX,CAAgC,CAC5BA,CAAI,GACP,CAEDN,CAAC,CAACY,GAAF,CAAM,0BAAN,CAAkC,QAAlC,CAA4C,UAAW,CACnD,GAAIC,CAAAA,CAAK,CAAG,OAAZ,CACA,GAAIP,CAAJ,CAAU,CACNO,CAAK,CAAG,OACX,CAEDF,CAAM,CAACD,WAAP,CAAqB,GAAIH,CAAAA,CAAC,CAACO,IAAF,CAAOb,QAAX,CAAoB,CACrCc,aAAa,CAAEb,CADsB,CAErCc,WAAW,CAAEb,CAFwB,CAGrCc,SAAS,GAH4B,CAIrCC,OAAO,GAJ8B,CAKrCC,MAAM,GAL+B,CAMrCC,KAAK,GANgC,CAOrCP,KAAK,CAAEA,CAP8B,CAApB,CAArB,CAUAF,CAAM,CAACD,WAAP,CAAmBW,MAAnB,CAA0B,eAA1B,CAA2C,UAAW,CAClDd,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,uCAAlB,CACH,CAFD,EAIAE,CAAM,CAACD,WAAP,CAAmBY,KAAnB,CAAyB,eAAzB,CAA0C,SAASC,CAAT,CAAY,CAClD,GAAIA,CAAC,CAACC,MAAN,CAAc,CAGV,GAA0B,WAArB,QAAOpB,CAAAA,CAAZ,CAAwC,CACpCJ,CAAC,CAACyB,IAAF,CAAO,UAAW,CACdrB,CAAS,CAACO,CAAD,CAAT,CACAA,CAAM,CAACD,WAAP,CAAmBgB,cAAnB,GACAnB,CAAC,CAACC,IAAF,CAAOmB,WAAP,CAAmB,uCAAnB,CACH,CAJD,CAKH,CAND,IAMO,CACHpB,CAAC,CAACC,IAAF,CAAOmB,WAAP,CAAmB,uCAAnB,CACH,CACJ,CAZD,IAYO,CACH,GAA0B,WAArB,QAAOtB,CAAAA,CAAZ,CAAwC,CACpCL,CAAC,CAACyB,IAAF,CAAO,UAAW,CACdpB,CAAS,CAACM,CAAD,CAAT,CACAJ,CAAC,CAACC,IAAF,CAAOmB,WAAP,CAAmB,uCAAnB,CACH,CAHD,CAIH,CALD,IAKO,CACHpB,CAAC,CAACC,IAAF,CAAOmB,WAAP,CAAmB,uCAAnB,CACH,CACJ,CACJ,CAvBD,EAyBAhB,CAAM,CAACD,WAAP,CAAmBkB,IAAnB,GACArB,CAAC,CAACC,IAAF,CAAOmB,WAAP,CAAmB,2BAAnB,CACH,CA/CD,CAgDH,CA3DD,CAgEA1B,CAAQ,CAAC4B,SAAT,CAAmBC,KAAnB,CAA2B,UAAW,CAClC,KAAKpB,WAAL,CAAiBqB,IAAjB,GACA,KAAKrB,WAAL,CAAiBsB,OAAjB,EACH,CAHD,CASA/B,CAAQ,CAAC4B,SAAT,CAAmBI,UAAnB,CAAgC,UAAW,CACvC,MAAO,MAAKvB,WAAL,CAAiBwB,QAAjB,CAA0BC,UAA1B,EACV,CAFD,CAIA,MAA6ClC,CAAAA,CAChD,CA1FK,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 tool_lp/dialogue\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/yui'], function(Y) {\n\n // Private variables and functions.\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 M.util.js_pending('tool_lp/dialogue:dialogue');\n\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.before('visibleChange', function() {\n M.util.js_pending('tool_lp/dialogue:before:visibleChange');\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 M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n } else {\n if ((typeof afterHide !== 'undefined')) {\n Y.soon(function() {\n afterHide(parent);\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n }\n });\n\n parent.yuiDialogue.show();\n M.util.js_complete('tool_lp/dialogue:dialogue');\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 * @return {node}\n */\n dialogue.prototype.getContent = function() {\n return this.yuiDialogue.bodyNode.getDOMNode();\n };\n\n return /** @alias module:tool_lp/dialogue */ dialogue;\n});\n"],"file":"dialogue.min.js"} \ No newline at end of file +{"version":3,"file":"dialogue.min.js","sources":["../src/dialogue.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 * 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 tool_lp/dialogue\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/yui'], function(Y) {\n\n // Private variables and functions.\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 M.util.js_pending('tool_lp/dialogue:dialogue');\n\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.before('visibleChange', function() {\n M.util.js_pending('tool_lp/dialogue:before:visibleChange');\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 M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n } else {\n if ((typeof afterHide !== 'undefined')) {\n Y.soon(function() {\n afterHide(parent);\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n }\n });\n\n parent.yuiDialogue.show();\n M.util.js_complete('tool_lp/dialogue:dialogue');\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 * @return {node}\n */\n dialogue.prototype.getContent = function() {\n return this.yuiDialogue.bodyNode.getDOMNode();\n };\n\n return /** @alias module:tool_lp/dialogue */ dialogue;\n});\n"],"names":["define","Y","dialogue","title","content","afterShow","afterHide","wide","M","util","js_pending","yuiDialogue","parent","this","use","width","core","headerContent","bodyContent","draggable","visible","center","modal","before","after","e","newVal","soon","centerDialogue","js_complete","show","prototype","close","hide","destroy","getContent","bodyNode","getDOMNode"],"mappings":";;;;;;;;AAuBAA,0BAAO,CAAC,aAAa,SAASC,OAYtBC,SAAW,SAASC,MAAOC,QAASC,UAAWC,UAAWC,MAC1DC,EAAEC,KAAKC,WAAW,kCAEbC,YAAc,SACfC,OAASC,UAGM,IAARN,OACPA,MAAO,GAGXN,EAAEa,IAAI,2BAA4B,UAAU,eACpCC,MAAQ,QACRR,OACAQ,MAAQ,SAGZH,OAAOD,YAAc,IAAIH,EAAEQ,KAAKd,SAAS,CACrCe,cAAed,MACfe,YAAad,QACbe,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPP,MAAOA,QAGXH,OAAOD,YAAYY,OAAO,iBAAiB,WACvCf,EAAEC,KAAKC,WAAW,4CAGtBE,OAAOD,YAAYa,MAAM,iBAAiB,SAASC,GAC3CA,EAAEC,YAGwB,IAAdrB,UACRJ,EAAE0B,MAAK,WACHtB,UAAUO,QACVA,OAAOD,YAAYiB,iBACnBpB,EAAEC,KAAKoB,YAAY,4CAGvBrB,EAAEC,KAAKoB,YAAY,8CAGG,IAAdvB,UACRL,EAAE0B,MAAK,WACHrB,UAAUM,QACVJ,EAAEC,KAAKoB,YAAY,4CAGvBrB,EAAEC,KAAKoB,YAAY,4CAK/BjB,OAAOD,YAAYmB,OACnBtB,EAAEC,KAAKoB,YAAY,wCAO3B3B,SAAS6B,UAAUC,MAAQ,gBAClBrB,YAAYsB,YACZtB,YAAYuB,WAOrBhC,SAAS6B,UAAUI,WAAa,kBACrBtB,KAAKF,YAAYyB,SAASC,cAGQnC"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/dragdrop-reorder.min.js b/admin/tool/lp/amd/build/dragdrop-reorder.min.js index d83b1c62107..d5a282411ff 100644 --- a/admin/tool/lp/amd/build/dragdrop-reorder.min.js +++ b/admin/tool/lp/amd/build/dragdrop-reorder.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/dragdrop-reorder",["core/str","core/yui"],function(a,b){var c=null,d=function(a){var b=a.drag.get("node"),c=a.drop.get("node");this.callback(b.getDOMNode(),c.getDOMNode())};return{dragdrop:function dragdrop(e,f,g,h,i,j,k,l){a.get_strings([{key:"emptydragdropregion",component:"moodle"},{key:"movecontent",component:"moodle"},{key:"tocontent",component:"moodle"}]).done(function(){b.use("moodle-tool_lp-dragdrop-reorder",function(){if(c){c.destroy()}c=M.tool_lp.dragdrop_reorder({group:e,dragHandleText:f,sameNodeText:g,parentNodeText:h,sameNodeClass:i,parentNodeClass:j,dragHandleInsertClass:k,callback:b.bind(d,{callback:l})})})})}}}); -//# sourceMappingURL=dragdrop-reorder.min.js.map +/** + * Drag and drop reorder via HTML5. + * + * @module tool_lp/dragdrop-reorder + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/dragdrop-reorder",["core/str","core/yui"],(function(str,Y){var dragDropInstance=null,proxyCallback=function(e){var dragNode=e.drag.get("node"),dropNode=e.drop.get("node");this.callback(dragNode.getDOMNode(),dropNode.getDOMNode())};return{dragdrop:function(group,dragHandleText,sameNodeText,parentNodeText,sameNodeClass,parentNodeClass,dragHandleInsertClass,callback){str.get_strings([{key:"emptydragdropregion",component:"moodle"},{key:"movecontent",component:"moodle"},{key:"tocontent",component:"moodle"}]).done((function(){Y.use("moodle-tool_lp-dragdrop-reorder",(function(){var context={callback:callback};dragDropInstance&&dragDropInstance.destroy(),dragDropInstance=M.tool_lp.dragdrop_reorder({group:group,dragHandleText:dragHandleText,sameNodeText:sameNodeText,parentNodeText:parentNodeText,sameNodeClass:sameNodeClass,parentNodeClass:parentNodeClass,dragHandleInsertClass:dragHandleInsertClass,callback:Y.bind(proxyCallback,context)})}))}))}}})); + +//# sourceMappingURL=dragdrop-reorder.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map b/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map index fb8b59038a3..ed41f5b52a8 100644 --- a/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map +++ b/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/dragdrop-reorder.js"],"names":["define","str","Y","dragDropInstance","proxyCallback","e","dragNode","drag","get","dropNode","drop","callback","getDOMNode","dragdrop","group","dragHandleText","sameNodeText","parentNodeText","sameNodeClass","parentNodeClass","dragHandleInsertClass","get_strings","key","component","done","use","destroy","M","tool_lp","dragdrop_reorder","bind"],"mappings":"AAsBAA,OAAM,4BAAC,CAAC,UAAD,CAAa,UAAb,CA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AAEA,CADA,CAcA,CARgC,CAA3B,CAUtB,CAlBD,CAmBH,CAxBD,CAyBH,CAjDgD,CAoDxD,CAzEK,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 * Drag and drop reorder via HTML5.\n *\n * @module tool_lp/dragdrop-reorder\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/str', 'core/yui'], function(str, Y) {\n // Private variables and functions.\n\n /**\n * Store the current instance of the core drag drop.\n *\n * @property {object} dragDropInstance M.tool_lp.dragdrop_reorder\n */\n var dragDropInstance = null;\n\n /**\n * Translate the drophit event from YUI\n * into simple drag and drop nodes.\n * @param {Y.Event} e The yui drop event.\n */\n var proxyCallback = function(e) {\n var dragNode = e.drag.get('node');\n var dropNode = e.drop.get('node');\n this.callback(dragNode.getDOMNode(), dropNode.getDOMNode());\n };\n\n return /** @alias module:tool_lp/dragdrop-reorder */ {\n // Public variables and functions.\n /**\n * Create an instance of M.tool_lp.dragdrop\n *\n * @param {String} group Unique string to identify this interaction.\n * @param {String} dragHandleText Alt text for the drag handle.\n * @param {String} sameNodeText Used in keyboard drag drop for the list of items target.\n * @param {String} parentNodeText Used in keyboard drag drop for the parent target.\n * @param {String} sameNodeClass class used to find the each of the list of items.\n * @param {String} parentNodeClass class used to find the container for the list of items.\n * @param {String} dragHandleInsertClass class used to find the location to insert the drag handles.\n * @param {function} callback Drop hit handler.\n */\n dragdrop: function(group,\n dragHandleText,\n sameNodeText,\n parentNodeText,\n sameNodeClass,\n parentNodeClass,\n dragHandleInsertClass,\n callback) {\n // Here we are wrapping YUI. This allows us to start transitioning, but\n // wait for a good alternative without having inconsistent UIs.\n str.get_strings([\n {key: 'emptydragdropregion', component: 'moodle'},\n {key: 'movecontent', component: 'moodle'},\n {key: 'tocontent', component: 'moodle'},\n ]).done(function() {\n Y.use('moodle-tool_lp-dragdrop-reorder', function() {\n\n var context = {\n callback: callback\n };\n if (dragDropInstance) {\n dragDropInstance.destroy();\n }\n dragDropInstance = M.tool_lp.dragdrop_reorder({\n group: group,\n dragHandleText: dragHandleText,\n sameNodeText: sameNodeText,\n parentNodeText: parentNodeText,\n sameNodeClass: sameNodeClass,\n parentNodeClass: parentNodeClass,\n dragHandleInsertClass: dragHandleInsertClass,\n callback: Y.bind(proxyCallback, context)\n });\n });\n });\n }\n\n };\n});\n"],"file":"dragdrop-reorder.min.js"} \ No newline at end of file +{"version":3,"file":"dragdrop-reorder.min.js","sources":["../src/dragdrop-reorder.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 * Drag and drop reorder via HTML5.\n *\n * @module tool_lp/dragdrop-reorder\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/str', 'core/yui'], function(str, Y) {\n // Private variables and functions.\n\n /**\n * Store the current instance of the core drag drop.\n *\n * @property {object} dragDropInstance M.tool_lp.dragdrop_reorder\n */\n var dragDropInstance = null;\n\n /**\n * Translate the drophit event from YUI\n * into simple drag and drop nodes.\n * @param {Y.Event} e The yui drop event.\n */\n var proxyCallback = function(e) {\n var dragNode = e.drag.get('node');\n var dropNode = e.drop.get('node');\n this.callback(dragNode.getDOMNode(), dropNode.getDOMNode());\n };\n\n return /** @alias module:tool_lp/dragdrop-reorder */ {\n // Public variables and functions.\n /**\n * Create an instance of M.tool_lp.dragdrop\n *\n * @param {String} group Unique string to identify this interaction.\n * @param {String} dragHandleText Alt text for the drag handle.\n * @param {String} sameNodeText Used in keyboard drag drop for the list of items target.\n * @param {String} parentNodeText Used in keyboard drag drop for the parent target.\n * @param {String} sameNodeClass class used to find the each of the list of items.\n * @param {String} parentNodeClass class used to find the container for the list of items.\n * @param {String} dragHandleInsertClass class used to find the location to insert the drag handles.\n * @param {function} callback Drop hit handler.\n */\n dragdrop: function(group,\n dragHandleText,\n sameNodeText,\n parentNodeText,\n sameNodeClass,\n parentNodeClass,\n dragHandleInsertClass,\n callback) {\n // Here we are wrapping YUI. This allows us to start transitioning, but\n // wait for a good alternative without having inconsistent UIs.\n str.get_strings([\n {key: 'emptydragdropregion', component: 'moodle'},\n {key: 'movecontent', component: 'moodle'},\n {key: 'tocontent', component: 'moodle'},\n ]).done(function() {\n Y.use('moodle-tool_lp-dragdrop-reorder', function() {\n\n var context = {\n callback: callback\n };\n if (dragDropInstance) {\n dragDropInstance.destroy();\n }\n dragDropInstance = M.tool_lp.dragdrop_reorder({\n group: group,\n dragHandleText: dragHandleText,\n sameNodeText: sameNodeText,\n parentNodeText: parentNodeText,\n sameNodeClass: sameNodeClass,\n parentNodeClass: parentNodeClass,\n dragHandleInsertClass: dragHandleInsertClass,\n callback: Y.bind(proxyCallback, context)\n });\n });\n });\n }\n\n };\n});\n"],"names":["define","str","Y","dragDropInstance","proxyCallback","e","dragNode","drag","get","dropNode","drop","callback","getDOMNode","dragdrop","group","dragHandleText","sameNodeText","parentNodeText","sameNodeClass","parentNodeClass","dragHandleInsertClass","get_strings","key","component","done","use","context","destroy","M","tool_lp","dragdrop_reorder","bind"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,WAAY,aAAa,SAASC,IAAKC,OAQvCC,iBAAmB,KAOnBC,cAAgB,SAASC,OACrBC,SAAWD,EAAEE,KAAKC,IAAI,QACtBC,SAAWJ,EAAEK,KAAKF,IAAI,aACrBG,SAASL,SAASM,aAAcH,SAASG,qBAGG,CAcjDC,SAAU,SAASC,MACAC,eACAC,aACAC,eACAC,cACAC,gBACAC,sBACAT,UAGfV,IAAIoB,YAAY,CACZ,CAACC,IAAK,sBAAuBC,UAAW,UACxC,CAACD,IAAK,cAAeC,UAAW,UAChC,CAACD,IAAK,YAAaC,UAAW,YAC/BC,MAAK,WACJtB,EAAEuB,IAAI,mCAAmC,eAEjCC,QAAU,CACVf,SAAUA,UAEVR,kBACAA,iBAAiBwB,UAErBxB,iBAAmByB,EAAEC,QAAQC,iBAAiB,CAC1ChB,MAAOA,MACPC,eAAgBA,eAChBC,aAAcA,aACdC,eAAgBA,eAChBC,cAAeA,cACfC,gBAAiBA,gBACjBC,sBAAuBA,sBACvBT,SAAUT,EAAE6B,KAAK3B,cAAesB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/event_base.min.js b/admin/tool/lp/amd/build/event_base.min.js index bd20aa13ce0..ab189053f91 100644 --- a/admin/tool/lp/amd/build/event_base.min.js +++ b/admin/tool/lp/amd/build/event_base.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/event_base",["jquery"],function(a){var b=function(){this._eventNode=a("
")};b.prototype._eventNode=null;b.prototype.on=function(a,b){this._eventNode.on(a,b)};b.prototype._trigger=function(a,b){this._eventNode.trigger(a,[b])};return b}); -//# sourceMappingURL=event_base.min.js.map +/** + * Event base javascript module. + * + * @module tool_lp/event_base + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/event_base",["jquery"],(function($){var Base=function(){this._eventNode=$("
")};return Base.prototype._eventNode=null,Base.prototype.on=function(type,handler){this._eventNode.on(type,handler)},Base.prototype._trigger=function(type,data){this._eventNode.trigger(type,[data])},Base})); + +//# sourceMappingURL=event_base.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/event_base.min.js.map b/admin/tool/lp/amd/build/event_base.min.js.map index d587f301884..5acbe6740c4 100644 --- a/admin/tool/lp/amd/build/event_base.min.js.map +++ b/admin/tool/lp/amd/build/event_base.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/event_base.js"],"names":["define","$","Base","_eventNode","prototype","on","type","handler","_trigger","data","trigger"],"mappings":"AAsBAA,OAAM,sBAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAK3B,GAAIC,CAAAA,CAAI,CAAG,UAAW,CAClB,KAAKC,UAAL,CAAkBF,CAAC,CAAC,aAAD,CACtB,CAFD,CAKAC,CAAI,CAACE,SAAL,CAAeD,UAAf,CAA4B,IAA5B,CASAD,CAAI,CAACE,SAAL,CAAeC,EAAf,CAAoB,SAASC,CAAT,CAAeC,CAAf,CAAwB,CACxC,KAAKJ,UAAL,CAAgBE,EAAhB,CAAmBC,CAAnB,CAAyBC,CAAzB,CACH,CAFD,CAWAL,CAAI,CAACE,SAAL,CAAeI,QAAf,CAA0B,SAASF,CAAT,CAAeG,CAAf,CAAqB,CAC3C,KAAKN,UAAL,CAAgBO,OAAhB,CAAwBJ,CAAxB,CAA8B,CAACG,CAAD,CAA9B,CACH,CAFD,CAIA,MAA+CP,CAAAA,CAClD,CAnCK,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 * Event base javascript module.\n *\n * @module tool_lp/event_base\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /**\n * Base class.\n */\n var Base = function() {\n this._eventNode = $('
');\n };\n\n /** @property {Node} The node we attach the events to. */\n Base.prototype._eventNode = null;\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Base.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n */\n Base.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/event_base */ Base;\n});\n"],"file":"event_base.min.js"} \ No newline at end of file +{"version":3,"file":"event_base.min.js","sources":["../src/event_base.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 * Event base javascript module.\n *\n * @module tool_lp/event_base\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /**\n * Base class.\n */\n var Base = function() {\n this._eventNode = $('
');\n };\n\n /** @property {Node} The node we attach the events to. */\n Base.prototype._eventNode = null;\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Base.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n */\n Base.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/event_base */ Base;\n});\n"],"names":["define","$","Base","_eventNode","prototype","on","type","handler","_trigger","data","trigger"],"mappings":";;;;;;;AAsBAA,4BAAO,CAAC,WAAW,SAASC,OAKpBC,KAAO,gBACFC,WAAaF,EAAE,uBAIxBC,KAAKE,UAAUD,WAAa,KAS5BD,KAAKE,UAAUC,GAAK,SAASC,KAAMC,cAC1BJ,WAAWE,GAAGC,KAAMC,UAU7BL,KAAKE,UAAUI,SAAW,SAASF,KAAMG,WAChCN,WAAWO,QAAQJ,KAAM,CAACG,QAGYP"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/evidence_delete.min.js b/admin/tool/lp/amd/build/evidence_delete.min.js index d74b0d9f06b..dc56c219b5e 100644 --- a/admin/tool/lp/amd/build/evidence_delete.min.js +++ b/admin/tool/lp/amd/build/evidence_delete.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/evidence_delete",["jquery","core/notification","core/ajax","core/str","core/log"],function(a,b,c,d,e){var f={};return{register:function register(g,h){if("undefined"!=typeof f[g]){return}f[g]=a("body").delegate(g,"click",function(f){var g=a(f.currentTarget).parents(h);if(!g.length||11)Log.error("None or too many evidence container were found.");else{var evidenceId=parent.data("id");evidenceId?(e.preventDefault(),e.stopPropagation(),Str.get_strings([{key:"confirm",component:"moodle"},{key:"areyousure",component:"moodle"},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){Notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){Ajax.call([{methodname:"core_competency_delete_evidence",args:{id:evidenceId}}])[0].then((function(){parent.remove()})).fail(Notification.exception)}))})).fail(Notification.exception)):Log.error("Evidence ID was not found.")}})))}}})); + +//# sourceMappingURL=evidence_delete.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/evidence_delete.min.js.map b/admin/tool/lp/amd/build/evidence_delete.min.js.map index 285ff964b1d..f16b333f0b6 100644 --- a/admin/tool/lp/amd/build/evidence_delete.min.js.map +++ b/admin/tool/lp/amd/build/evidence_delete.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/evidence_delete.js"],"names":["define","$","Notification","Ajax","Str","Log","selectors","register","triggerSelector","containerSelector","delegate","e","parent","currentTarget","parents","length","error","evidenceId","data","preventDefault","stopPropagation","get_strings","key","component","done","strings","confirm","promise","call","methodname","args","id","then","remove","fail","exception"],"mappings":"AAuBAA,OAAM,2BAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,UAHD,CAIC,UAJD,CAAD,CAKE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAAqCC,CAArC,CAA0C,IAE1CC,CAAAA,CAAS,CAAG,EAF8B,CA4D9C,MAAoD,CAShDC,QAAQ,CA3DG,QAAXA,CAAAA,QAAW,CAASC,CAAT,CAA0BC,CAA1B,CAA6C,CACxD,GAA0C,WAAtC,QAAOH,CAAAA,CAAS,CAACE,CAAD,CAApB,CAAuD,CACnD,MACH,CAEDF,CAAS,CAACE,CAAD,CAAT,CAA6BP,CAAC,CAAC,MAAD,CAAD,CAAUS,QAAV,CAAmBF,CAAnB,CAAoC,OAApC,CAA6C,SAASG,CAAT,CAAY,CAClF,GAAIC,CAAAA,CAAM,CAAGX,CAAC,CAACU,CAAC,CAACE,aAAH,CAAD,CAAmBC,OAAnB,CAA2BL,CAA3B,CAAb,CACA,GAAI,CAACG,CAAM,CAACG,MAAR,EAAkC,CAAhB,CAAAH,CAAM,CAACG,MAA7B,CAAyC,CACrCV,CAAG,CAACW,KAAJ,CAAU,iDAAV,EACA,MACH,CACD,GAAIC,CAAAA,CAAU,CAAGL,CAAM,CAACM,IAAP,CAAY,IAAZ,CAAjB,CACA,GAAI,CAACD,CAAL,CAAiB,CACbZ,CAAG,CAACW,KAAJ,CAAU,4BAAV,EACA,MACH,CAEDL,CAAC,CAACQ,cAAF,GACAR,CAAC,CAACS,eAAF,GAEAhB,CAAG,CAACiB,WAAJ,CAAgB,CACZ,CAACC,GAAG,CAAE,SAAN,CAAiBC,SAAS,CAAE,QAA5B,CADY,CAEZ,CAACD,GAAG,CAAE,YAAN,CAAoBC,SAAS,CAAE,QAA/B,CAFY,CAGZ,CAACD,GAAG,CAAE,QAAN,CAAgBC,SAAS,CAAE,QAA3B,CAHY,CAIZ,CAACD,GAAG,CAAE,QAAN,CAAgBC,SAAS,CAAE,QAA3B,CAJY,CAAhB,EAKGC,IALH,CAKQ,SAASC,CAAT,CAAkB,CACtBvB,CAAY,CAACwB,OAAb,CACID,CAAO,CAAC,CAAD,CADX,CAEIA,CAAO,CAAC,CAAD,CAFX,CAGIA,CAAO,CAAC,CAAD,CAHX,CAIIA,CAAO,CAAC,CAAD,CAJX,CAKI,UAAW,CACP,GAAIE,CAAAA,CAAO,CAAGxB,CAAI,CAACyB,IAAL,CAAU,CAAC,CACrBC,UAAU,CAAE,iCADS,CAErBC,IAAI,CAAE,CACFC,EAAE,CAAEd,CADF,CAFe,CAAD,CAAV,CAAd,CAMAU,CAAO,CAAC,CAAD,CAAP,CAAWK,IAAX,CAAgB,UAAW,CACvBpB,CAAM,CAACqB,MAAP,EAEH,CAHD,EAGGC,IAHH,CAGQhC,CAAY,CAACiC,SAHrB,CAIH,CAhBL,CAkBH,CAxBD,EAwBGD,IAxBH,CAwBQhC,CAAY,CAACiC,SAxBrB,CA2BH,CA1C4B,CA2ChC,CAEmD,CAYvD,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 * Evidence delete.\n *\n * @module tool_lp/evidence_delete\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/log'],\n function($, Notification, Ajax, Str, Log) {\n\n var selectors = {};\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n */\n var register = function(triggerSelector, containerSelector) {\n if (typeof selectors[triggerSelector] !== 'undefined') {\n return;\n }\n\n selectors[triggerSelector] = $('body').delegate(triggerSelector, 'click', function(e) {\n var parent = $(e.currentTarget).parents(containerSelector);\n if (!parent.length || parent.length > 1) {\n Log.error('None or too many evidence container were found.');\n return;\n }\n var evidenceId = parent.data('id');\n if (!evidenceId) {\n Log.error('Evidence ID was not found.');\n return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n\n Str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'areyousure', component: 'moodle'},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n Notification.confirm(\n strings[0], // Confirm.\n strings[1], // Are you sure?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n var promise = Ajax.call([{\n methodname: 'core_competency_delete_evidence',\n args: {\n id: evidenceId\n }\n }]);\n promise[0].then(function() {\n parent.remove();\n return;\n }).fail(Notification.exception);\n }\n );\n }).fail(Notification.exception);\n\n\n });\n };\n\n return /** @alias module:tool_lp/evidence_delete */ {\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n * @return {Void}\n */\n register: register\n };\n\n});\n"],"file":"evidence_delete.min.js"} \ No newline at end of file +{"version":3,"file":"evidence_delete.min.js","sources":["../src/evidence_delete.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 * Evidence delete.\n *\n * @module tool_lp/evidence_delete\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/log'],\n function($, Notification, Ajax, Str, Log) {\n\n var selectors = {};\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n */\n var register = function(triggerSelector, containerSelector) {\n if (typeof selectors[triggerSelector] !== 'undefined') {\n return;\n }\n\n selectors[triggerSelector] = $('body').delegate(triggerSelector, 'click', function(e) {\n var parent = $(e.currentTarget).parents(containerSelector);\n if (!parent.length || parent.length > 1) {\n Log.error('None or too many evidence container were found.');\n return;\n }\n var evidenceId = parent.data('id');\n if (!evidenceId) {\n Log.error('Evidence ID was not found.');\n return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n\n Str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'areyousure', component: 'moodle'},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n Notification.confirm(\n strings[0], // Confirm.\n strings[1], // Are you sure?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n var promise = Ajax.call([{\n methodname: 'core_competency_delete_evidence',\n args: {\n id: evidenceId\n }\n }]);\n promise[0].then(function() {\n parent.remove();\n return;\n }).fail(Notification.exception);\n }\n );\n }).fail(Notification.exception);\n\n\n });\n };\n\n return /** @alias module:tool_lp/evidence_delete */ {\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n * @return {Void}\n */\n register: register\n };\n\n});\n"],"names":["define","$","Notification","Ajax","Str","Log","selectors","register","triggerSelector","containerSelector","delegate","e","parent","currentTarget","parents","length","error","evidenceId","data","preventDefault","stopPropagation","get_strings","key","component","done","strings","confirm","call","methodname","args","id","then","remove","fail","exception"],"mappings":";;;;;;;AAuBAA,iCAAO,CAAC,SACA,oBACA,YACA,WACA,aACA,SAASC,EAAGC,aAAcC,KAAMC,IAAKC,SAErCC,UAAY,SA0DoC,CAShDC,SA3DW,SAASC,gBAAiBC,wBACK,IAA/BH,UAAUE,mBAIrBF,UAAUE,iBAAmBP,EAAE,QAAQS,SAASF,gBAAiB,SAAS,SAASG,OAC3EC,OAASX,EAAEU,EAAEE,eAAeC,QAAQL,uBACnCG,OAAOG,QAAUH,OAAOG,OAAS,EAClCV,IAAIW,MAAM,4DAGVC,WAAaL,OAAOM,KAAK,MACxBD,YAKLN,EAAEQ,iBACFR,EAAES,kBAEFhB,IAAIiB,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,aAAcC,UAAW,UAC/B,CAACD,IAAK,SAAUC,UAAW,UAC3B,CAACD,IAAK,SAAUC,UAAW,YAC5BC,MAAK,SAASC,SACbvB,aAAawB,QACTD,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,IACR,WACkBtB,KAAKwB,KAAK,CAAC,CACrBC,WAAY,kCACZC,KAAM,CACFC,GAAIb,eAGJ,GAAGc,MAAK,WACZnB,OAAOoB,YAERC,KAAK/B,aAAagC,iBAG9BD,KAAK/B,aAAagC,YA/BjB7B,IAAIW,MAAM"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form-cohort-selector.min.js b/admin/tool/lp/amd/build/form-cohort-selector.min.js index 5a7a0144e19..bfa8a6bebbf 100644 --- a/admin/tool/lp/amd/build/form-cohort-selector.min.js +++ b/admin/tool/lp/amd/build/form-cohort-selector.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/form-cohort-selector",["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function processResults(b,c){var d=[];a.each(c,function(a,b){d.push({value:b.id,label:b._label})});return d},transport:function transport(d,e,f,g){var h,i=parseInt(a(d).data("contextid"),10),j=a(d).data("includes");h=b.call([{methodname:"tool_lp_search_cohorts",args:{query:e,context:{contextid:i},includes:j}}]);h[0].then(function(b){var d=[],e=0;a.each(b.cohorts,function(a,b){d.push(c.render("tool_lp/form-cohort-selector-suggestion",b))});return a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b.cohorts,function(a,b){b._label=c[e];e++});f(b.cohorts)})}).catch(g)}}}); -//# sourceMappingURL=form-cohort-selector.min.js.map +/** + * Cohort selector module. + * + * @module tool_lp/form-cohort-selector + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/form-cohort-selector",["jquery","core/ajax","core/templates"],(function($,Ajax,Templates){return{processResults:function(selector,results){var cohorts=[];return $.each(results,(function(index,cohort){cohorts.push({value:cohort.id,label:cohort._label})})),cohorts},transport:function(selector,query,success,failure){var contextid=parseInt($(selector).data("contextid"),10),includes=$(selector).data("includes");Ajax.call([{methodname:"tool_lp_search_cohorts",args:{query:query,context:{contextid:contextid},includes:includes}}])[0].then((function(results){var promises=[],i=0;return $.each(results.cohorts,(function(index,cohort){promises.push(Templates.render("tool_lp/form-cohort-selector-suggestion",cohort))})),$.when.apply($.when,promises).then((function(){var args=arguments;$.each(results.cohorts,(function(index,cohort){cohort._label=args[i],i++})),success(results.cohorts)}))})).catch(failure)}}})); + +//# sourceMappingURL=form-cohort-selector.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form-cohort-selector.min.js.map b/admin/tool/lp/amd/build/form-cohort-selector.min.js.map index df2182978b6..aa365af512a 100644 --- a/admin/tool/lp/amd/build/form-cohort-selector.min.js.map +++ b/admin/tool/lp/amd/build/form-cohort-selector.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/form-cohort-selector.js"],"names":["define","$","Ajax","Templates","processResults","selector","results","cohorts","each","index","cohort","push","value","id","label","_label","transport","query","success","failure","promise","contextid","parseInt","data","includes","call","methodname","args","context","then","promises","i","render","when","apply","arguments","catch"],"mappings":"AAuBAA,OAAM,gCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,gBAAxB,CAAD,CAA4C,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAA6B,CAE3E,MAAyD,CAErDC,cAAc,CAAE,wBAASC,CAAT,CAAmBC,CAAnB,CAA4B,CACxC,GAAIC,CAAAA,CAAO,CAAG,EAAd,CACAN,CAAC,CAACO,IAAF,CAAOF,CAAP,CAAgB,SAASG,CAAT,CAAgBC,CAAhB,CAAwB,CACpCH,CAAO,CAACI,IAAR,CAAa,CACTC,KAAK,CAAEF,CAAM,CAACG,EADL,CAETC,KAAK,CAAEJ,CAAM,CAACK,MAFL,CAAb,CAIH,CALD,EAMA,MAAOR,CAAAA,CACV,CAXoD,CAarDS,SAAS,CAAE,mBAASX,CAAT,CAAmBY,CAAnB,CAA0BC,CAA1B,CAAmCC,CAAnC,CAA4C,CACnD,GAAIC,CAAAA,CAAJ,CACIC,CAAS,CAAGC,QAAQ,CAACrB,CAAC,CAACI,CAAD,CAAD,CAAYkB,IAAZ,CAAiB,WAAjB,CAAD,CAAgC,EAAhC,CADxB,CAEIC,CAAQ,CAAGvB,CAAC,CAACI,CAAD,CAAD,CAAYkB,IAAZ,CAAiB,UAAjB,CAFf,CAIAH,CAAO,CAAGlB,CAAI,CAACuB,IAAL,CAAU,CAAC,CACjBC,UAAU,CAAE,wBADK,CAEjBC,IAAI,CAAE,CACFV,KAAK,CAAEA,CADL,CAEFW,OAAO,CAAE,CAACP,SAAS,CAAEA,CAAZ,CAFP,CAGFG,QAAQ,CAAEA,CAHR,CAFW,CAAD,CAAV,CAAV,CAQAJ,CAAO,CAAC,CAAD,CAAP,CAAWS,IAAX,CAAgB,SAASvB,CAAT,CAAkB,CAC9B,GAAIwB,CAAAA,CAAQ,CAAG,EAAf,CACIC,CAAC,CAAG,CADR,CAIA9B,CAAC,CAACO,IAAF,CAAOF,CAAO,CAACC,OAAf,CAAwB,SAASE,CAAT,CAAgBC,CAAhB,CAAwB,CAC5CoB,CAAQ,CAACnB,IAAT,CAAcR,CAAS,CAAC6B,MAAV,CAAiB,yCAAjB,CAA4DtB,CAA5D,CAAd,CACH,CAFD,EAKA,MAAOT,CAAAA,CAAC,CAACgC,IAAF,CAAOC,KAAP,CAAajC,CAAC,CAACgC,IAAf,CAAqBH,CAArB,EAA+BD,IAA/B,CAAoC,UAAW,CAClD,GAAIF,CAAAA,CAAI,CAAGQ,SAAX,CACAlC,CAAC,CAACO,IAAF,CAAOF,CAAO,CAACC,OAAf,CAAwB,SAASE,CAAT,CAAgBC,CAAhB,CAAwB,CAC5CA,CAAM,CAACK,MAAP,CAAgBY,CAAI,CAACI,CAAD,CAApB,CACAA,CAAC,EACJ,CAHD,EAIAb,CAAO,CAACZ,CAAO,CAACC,OAAT,CAEV,CARM,CAUV,CApBD,EAoBG6B,KApBH,CAoBSjB,CApBT,CAqBH,CA/CoD,CAmD5D,CArDK,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 * Cohort selector module.\n *\n * @module tool_lp/form-cohort-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-cohort-selector */ {\n\n processResults: function(selector, results) {\n var cohorts = [];\n $.each(results, function(index, cohort) {\n cohorts.push({\n value: cohort.id,\n label: cohort._label\n });\n });\n return cohorts;\n },\n\n transport: function(selector, query, success, failure) {\n var promise,\n contextid = parseInt($(selector).data('contextid'), 10),\n includes = $(selector).data('includes');\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_cohorts',\n args: {\n query: query,\n context: {contextid: contextid},\n includes: includes\n }\n }]);\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.cohorts, function(index, cohort) {\n promises.push(Templates.render('tool_lp/form-cohort-selector-suggestion', cohort));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.cohorts, function(index, cohort) {\n cohort._label = args[i];\n i++;\n });\n success(results.cohorts);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"file":"form-cohort-selector.min.js"} \ No newline at end of file +{"version":3,"file":"form-cohort-selector.min.js","sources":["../src/form-cohort-selector.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 * Cohort selector module.\n *\n * @module tool_lp/form-cohort-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-cohort-selector */ {\n\n processResults: function(selector, results) {\n var cohorts = [];\n $.each(results, function(index, cohort) {\n cohorts.push({\n value: cohort.id,\n label: cohort._label\n });\n });\n return cohorts;\n },\n\n transport: function(selector, query, success, failure) {\n var promise,\n contextid = parseInt($(selector).data('contextid'), 10),\n includes = $(selector).data('includes');\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_cohorts',\n args: {\n query: query,\n context: {contextid: contextid},\n includes: includes\n }\n }]);\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.cohorts, function(index, cohort) {\n promises.push(Templates.render('tool_lp/form-cohort-selector-suggestion', cohort));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.cohorts, function(index, cohort) {\n cohort._label = args[i];\n i++;\n });\n success(results.cohorts);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","cohorts","each","index","cohort","push","value","id","label","_label","transport","query","success","failure","contextid","parseInt","data","includes","call","methodname","args","context","then","promises","i","render","when","apply","arguments","catch"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBAEP,CAErDC,eAAgB,SAASC,SAAUC,aAC3BC,QAAU,UACdN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,QAC5BH,QAAQI,KAAK,CACTC,MAAOF,OAAOG,GACdC,MAAOJ,OAAOK,YAGfR,SAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,aAEtCC,UAAYC,SAASpB,EAAEI,UAAUiB,KAAK,aAAc,IACpDC,SAAWtB,EAAEI,UAAUiB,KAAK,YAEtBpB,KAAKsB,KAAK,CAAC,CACjBC,WAAY,yBACZC,KAAM,CACFT,MAAOA,MACPU,QAAS,CAACP,UAAWA,WACrBG,SAAUA,aAGV,GAAGK,MAAK,SAAStB,aACjBuB,SAAW,GACXC,EAAI,SAGR7B,EAAEO,KAAKF,QAAQC,SAAS,SAASE,MAAOC,QACpCmB,SAASlB,KAAKR,UAAU4B,OAAO,0CAA2CrB,YAIvET,EAAE+B,KAAKC,MAAMhC,EAAE+B,KAAMH,UAAUD,MAAK,eACnCF,KAAOQ,UACXjC,EAAEO,KAAKF,QAAQC,SAAS,SAASE,MAAOC,QACpCA,OAAOK,OAASW,KAAKI,GACrBA,OAEJZ,QAAQZ,QAAQC,eAIrB4B,MAAMhB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form-user-selector.min.js b/admin/tool/lp/amd/build/form-user-selector.min.js index 0870d75389c..c22f5559c66 100644 --- a/admin/tool/lp/amd/build/form-user-selector.min.js +++ b/admin/tool/lp/amd/build/form-user-selector.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/form-user-selector",["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function processResults(b,c){var d=[];a.each(c,function(a,b){d.push({value:b.id,label:b._label})});return d},transport:function transport(d,e,f,g){var h,i=a(d).data("capability");if("undefined"==typeof i){i=""}h=b.call([{methodname:"tool_lp_search_users",args:{query:e,capability:i}}]);h[0].then(function(b){var d=[],e=0;a.each(b.users,function(b,e){var f=e,g=[];a.each(["idnumber","email","phone1","phone2","department","institution"],function(a,b){if("undefined"!=typeof e[b]&&""!==e[b]){f.hasidentity=!0;g.push(e[b])}});f.identity=g.join(", ");d.push(c.render("tool_lp/form-user-selector-suggestion",f))});return a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b.users,function(a,b){b._label=c[e];e++});f(b.users)})}).catch(g)}}}); -//# sourceMappingURL=form-user-selector.min.js.map +/** + * User selector module. + * + * @module tool_lp/form-user-selector + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/form-user-selector",["jquery","core/ajax","core/templates"],(function($,Ajax,Templates){return{processResults:function(selector,results){var users=[];return $.each(results,(function(index,user){users.push({value:user.id,label:user._label})})),users},transport:function(selector,query,success,failure){var capability=$(selector).data("capability");void 0===capability&&(capability=""),Ajax.call([{methodname:"tool_lp_search_users",args:{query:query,capability:capability}}])[0].then((function(results){var promises=[],i=0;return $.each(results.users,(function(index,user){var ctx=user,identity=[];$.each(["idnumber","email","phone1","phone2","department","institution"],(function(i,k){void 0!==user[k]&&""!==user[k]&&(ctx.hasidentity=!0,identity.push(user[k]))})),ctx.identity=identity.join(", "),promises.push(Templates.render("tool_lp/form-user-selector-suggestion",ctx))})),$.when.apply($.when,promises).then((function(){var args=arguments;$.each(results.users,(function(index,user){user._label=args[i],i++})),success(results.users)}))})).catch(failure)}}})); + +//# sourceMappingURL=form-user-selector.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form-user-selector.min.js.map b/admin/tool/lp/amd/build/form-user-selector.min.js.map index 2a6ef1014dd..795c5d36195 100644 --- a/admin/tool/lp/amd/build/form-user-selector.min.js.map +++ b/admin/tool/lp/amd/build/form-user-selector.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/form-user-selector.js"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","promise","capability","data","call","methodname","args","then","promises","i","ctx","identity","k","hasidentity","join","render","when","apply","arguments","catch"],"mappings":"AAuBAA,OAAM,8BAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,gBAAxB,CAAD,CAA4C,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAA6B,CAE3E,MAAuD,CAEnDC,cAAc,CAAE,wBAASC,CAAT,CAAmBC,CAAnB,CAA4B,CACxC,GAAIC,CAAAA,CAAK,CAAG,EAAZ,CACAN,CAAC,CAACO,IAAF,CAAOF,CAAP,CAAgB,SAASG,CAAT,CAAgBC,CAAhB,CAAsB,CAClCH,CAAK,C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,CAAD,CAAlB,CACH,CACJ,CALD,EAMAF,CAAG,CAACC,QAAJ,CAAeA,CAAQ,CAACG,IAAT,CAAc,IAAd,CAAf,CACAN,CAAQ,CAAChB,IAAT,CAAcR,CAAS,CAAC+B,MAAV,CAAiB,uCAAjB,CAA0DL,CAA1D,CAAd,CACH,CAXD,EAcA,MAAO5B,CAAAA,CAAC,CAACkC,IAAF,CAAOC,KAAP,CAAanC,CAAC,CAACkC,IAAf,CAAqBR,CAArB,EAA+BD,IAA/B,CAAoC,UAAW,CAClD,GAAID,CAAAA,CAAI,CAAGY,SAAX,CACApC,CAAC,CAACO,IAAF,CAAOF,CAAO,CAACC,KAAf,CAAsB,SAASE,CAAT,CAAgBC,CAAhB,CAAsB,CACxCA,CAAI,CAACK,MAAL,CAAcU,CAAI,CAACG,CAAD,CAAlB,CACAA,CAAC,EACJ,CAHD,EAIAV,CAAO,CAACZ,CAAO,CAACC,KAAT,CAEV,CARM,CAUV,CA7BD,EA6BG+B,KA7BH,CA6BSnB,CA7BT,CA8BH,CA1DkD,CA8D1D,CAhEK,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 * User selector module.\n *\n * @module tool_lp/form-user-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n var capability = $(selector).data('capability');\n if (typeof capability === \"undefined\") {\n capability = '';\n }\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_users',\n args: {\n query: query,\n capability: capability\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.users, function(index, user) {\n var ctx = user,\n identity = [];\n $.each(['idnumber', 'email', 'phone1', 'phone2', 'department', 'institution'], function(i, k) {\n if (typeof user[k] !== 'undefined' && user[k] !== '') {\n ctx.hasidentity = true;\n identity.push(user[k]);\n }\n });\n ctx.identity = identity.join(', ');\n promises.push(Templates.render('tool_lp/form-user-selector-suggestion', ctx));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.users, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results.users);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"file":"form-user-selector.min.js"} \ No newline at end of file +{"version":3,"file":"form-user-selector.min.js","sources":["../src/form-user-selector.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 * User selector module.\n *\n * @module tool_lp/form-user-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n var capability = $(selector).data('capability');\n if (typeof capability === \"undefined\") {\n capability = '';\n }\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_users',\n args: {\n query: query,\n capability: capability\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.users, function(index, user) {\n var ctx = user,\n identity = [];\n $.each(['idnumber', 'email', 'phone1', 'phone2', 'department', 'institution'], function(i, k) {\n if (typeof user[k] !== 'undefined' && user[k] !== '') {\n ctx.hasidentity = true;\n identity.push(user[k]);\n }\n });\n ctx.identity = identity.join(', ');\n promises.push(Templates.render('tool_lp/form-user-selector-suggestion', ctx));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.users, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results.users);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","capability","data","call","methodname","args","then","promises","i","ctx","identity","k","hasidentity","join","render","when","apply","arguments","catch"],"mappings":";;;;;;;AAuBAA,oCAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBAET,CAEnDC,eAAgB,SAASC,SAAUC,aAC3BC,MAAQ,UACZN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,YAGbR,OAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,aAEtCC,WAAanB,EAAEI,UAAUgB,KAAK,mBACR,IAAfD,aACPA,WAAa,IAGPlB,KAAKoB,KAAK,CAAC,CACjBC,WAAY,uBACZC,KAAM,CACFP,MAAOA,MACPG,WAAYA,eAIZ,GAAGK,MAAK,SAASnB,aACjBoB,SAAW,GACXC,EAAI,SAGR1B,EAAEO,KAAKF,QAAQC,OAAO,SAASE,MAAOC,UAC9BkB,IAAMlB,KACNmB,SAAW,GACf5B,EAAEO,KAAK,CAAC,WAAY,QAAS,SAAU,SAAU,aAAc,gBAAgB,SAASmB,EAAGG,QAChE,IAAZpB,KAAKoB,IAAkC,KAAZpB,KAAKoB,KACvCF,IAAIG,aAAc,EAClBF,SAASlB,KAAKD,KAAKoB,QAG3BF,IAAIC,SAAWA,SAASG,KAAK,MAC7BN,SAASf,KAAKR,UAAU8B,OAAO,wCAAyCL,SAIrE3B,EAAEiC,KAAKC,MAAMlC,EAAEiC,KAAMR,UAAUD,MAAK,eACnCD,KAAOY,UACXnC,EAAEO,KAAKF,QAAQC,OAAO,SAASE,MAAOC,MAClCA,KAAKK,OAASS,KAAKG,GACnBA,OAEJT,QAAQZ,QAAQC,aAIrB8B,MAAMlB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form_competency_element.min.js b/admin/tool/lp/amd/build/form_competency_element.min.js index c3937f2f8ac..5fbf4040bd3 100644 --- a/admin/tool/lp/amd/build/form_competency_element.min.js +++ b/admin/tool/lp/amd/build/form_competency_element.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/form_competency_element",["jquery","tool_lp/competencypicker","core/ajax","core/notification","core/templates"],function(a,b,c,d,e){var f=null,g=1,h=function(){var b=a("[data-action=\"competencies\"]").val(),f=[],g=0;if(""!=b){b=b.split(",");for(g=0;g + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/form_competency_element",["jquery","tool_lp/competencypicker","core/ajax","core/notification","core/templates"],(function($,Picker,Ajax,Notification,Templates){var pickerInstance=null,pageContextId=1,renderCompetencies=function(){var currentCompetencies=$('[data-action="competencies"]').val(),requests=[],i=0;if(""!=currentCompetencies)for(currentCompetencies=currentCompetencies.split(","),i=0;i.\n\n/**\n * Badge select competency actions\n *\n * @module tool_lp/form_competency_element\n * @copyright 2019 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'tool_lp/competencypicker', 'core/ajax', 'core/notification', 'core/templates'],\n function($, Picker, Ajax, Notification, Templates) {\n\n var pickerInstance = null;\n\n var pageContextId = 1;\n\n /**\n * Re-render the list of selected competencies.\n *\n * @method renderCompetencies\n * @return {boolean}\n */\n var renderCompetencies = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val();\n var requests = [];\n var i = 0;\n\n if (currentCompetencies != '') {\n currentCompetencies = currentCompetencies.split(',');\n for (i = 0; i < currentCompetencies.length; i++) {\n requests[requests.length] = {\n methodname: 'core_competency_read_competency',\n args: {id: currentCompetencies[i]}\n };\n }\n }\n\n $.when.apply($, Ajax.call(requests, false)).then(function() {\n var i = 0,\n competencies = [];\n\n for (i = 0; i < arguments.length; i++) {\n competencies[i] = arguments[i];\n }\n var context = {\n competencies: competencies\n };\n\n return Templates.render('tool_lp/form_competency_list', context);\n }).then(function(html, js) {\n Templates.replaceNode($('[data-region=\"competencies\"]'), html, js);\n return true;\n }).fail(Notification.exception);\n\n return true;\n };\n\n /**\n * Deselect a competency\n *\n * @method unpickCompetenciesHandler\n * @param {Event} e\n * @return {boolean}\n */\n var unpickCompetenciesHandler = function(e) {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(','),\n newCompetencies = [],\n i,\n toRemove = $(e.currentTarget).data('id');\n\n for (i = 0; i < currentCompetencies.length; i++) {\n if (currentCompetencies[i] != toRemove) {\n newCompetencies[newCompetencies.length] = currentCompetencies[i];\n }\n }\n\n $('[data-action=\"competencies\"]').val(newCompetencies.join(','));\n\n return renderCompetencies();\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method pickCompetenciesHandler\n */\n var pickCompetenciesHandler = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(',');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, false, 'parents', true);\n pickerInstance.on('save', function(e, data) {\n var before = $('[data-action=\"competencies\"]').val();\n var compIds = data.competencyIds;\n if (before != '') {\n compIds = compIds.concat(before.split(','));\n }\n var value = compIds.join(',');\n\n $('[data-action=\"competencies\"]').val(value);\n\n return renderCompetencies();\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs(currentCompetencies);\n pickerInstance.display();\n };\n\n return /** @alias module:tool_lp/form_competency_element */ {\n /**\n * Listen for clicks on the competency picker and push the changes to the form element.\n *\n * @method init\n * @param {Integer} contextId\n */\n init: function(contextId) {\n pageContextId = contextId;\n renderCompetencies();\n $('[data-action=\"select-competencies\"]').on('click', pickCompetenciesHandler);\n $('body').on('click', '[data-action=\"deselect-competency\"]', unpickCompetenciesHandler);\n }\n };\n});\n"],"file":"form_competency_element.min.js"} \ No newline at end of file +{"version":3,"file":"form_competency_element.min.js","sources":["../src/form_competency_element.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 * Badge select competency actions\n *\n * @module tool_lp/form_competency_element\n * @copyright 2019 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'tool_lp/competencypicker', 'core/ajax', 'core/notification', 'core/templates'],\n function($, Picker, Ajax, Notification, Templates) {\n\n var pickerInstance = null;\n\n var pageContextId = 1;\n\n /**\n * Re-render the list of selected competencies.\n *\n * @method renderCompetencies\n * @return {boolean}\n */\n var renderCompetencies = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val();\n var requests = [];\n var i = 0;\n\n if (currentCompetencies != '') {\n currentCompetencies = currentCompetencies.split(',');\n for (i = 0; i < currentCompetencies.length; i++) {\n requests[requests.length] = {\n methodname: 'core_competency_read_competency',\n args: {id: currentCompetencies[i]}\n };\n }\n }\n\n $.when.apply($, Ajax.call(requests, false)).then(function() {\n var i = 0,\n competencies = [];\n\n for (i = 0; i < arguments.length; i++) {\n competencies[i] = arguments[i];\n }\n var context = {\n competencies: competencies\n };\n\n return Templates.render('tool_lp/form_competency_list', context);\n }).then(function(html, js) {\n Templates.replaceNode($('[data-region=\"competencies\"]'), html, js);\n return true;\n }).fail(Notification.exception);\n\n return true;\n };\n\n /**\n * Deselect a competency\n *\n * @method unpickCompetenciesHandler\n * @param {Event} e\n * @return {boolean}\n */\n var unpickCompetenciesHandler = function(e) {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(','),\n newCompetencies = [],\n i,\n toRemove = $(e.currentTarget).data('id');\n\n for (i = 0; i < currentCompetencies.length; i++) {\n if (currentCompetencies[i] != toRemove) {\n newCompetencies[newCompetencies.length] = currentCompetencies[i];\n }\n }\n\n $('[data-action=\"competencies\"]').val(newCompetencies.join(','));\n\n return renderCompetencies();\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method pickCompetenciesHandler\n */\n var pickCompetenciesHandler = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(',');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, false, 'parents', true);\n pickerInstance.on('save', function(e, data) {\n var before = $('[data-action=\"competencies\"]').val();\n var compIds = data.competencyIds;\n if (before != '') {\n compIds = compIds.concat(before.split(','));\n }\n var value = compIds.join(',');\n\n $('[data-action=\"competencies\"]').val(value);\n\n return renderCompetencies();\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs(currentCompetencies);\n pickerInstance.display();\n };\n\n return /** @alias module:tool_lp/form_competency_element */ {\n /**\n * Listen for clicks on the competency picker and push the changes to the form element.\n *\n * @method init\n * @param {Integer} contextId\n */\n init: function(contextId) {\n pageContextId = contextId;\n renderCompetencies();\n $('[data-action=\"select-competencies\"]').on('click', pickCompetenciesHandler);\n $('body').on('click', '[data-action=\"deselect-competency\"]', unpickCompetenciesHandler);\n }\n };\n});\n"],"names":["define","$","Picker","Ajax","Notification","Templates","pickerInstance","pageContextId","renderCompetencies","currentCompetencies","val","requests","i","split","length","methodname","args","id","when","apply","call","then","competencies","arguments","context","render","html","js","replaceNode","fail","exception","unpickCompetenciesHandler","e","newCompetencies","toRemove","currentTarget","data","join","pickCompetenciesHandler","on","before","compIds","competencyIds","concat","value","setDisallowedCompetencyIDs","display","init","contextId"],"mappings":";;;;;;;AAsBAA,yCAAO,CAAC,SAAU,2BAA4B,YAAa,oBAAqB,mBACxE,SAASC,EAAGC,OAAQC,KAAMC,aAAcC,eAExCC,eAAiB,KAEjBC,cAAgB,EAQhBC,mBAAqB,eACjBC,oBAAsBR,EAAE,gCAAgCS,MACxDC,SAAW,GACXC,EAAI,KAEmB,IAAvBH,wBACAA,oBAAsBA,oBAAoBI,MAAM,KAC3CD,EAAI,EAAGA,EAAIH,oBAAoBK,OAAQF,IACxCD,SAASA,SAASG,QAAU,CACxBC,WAAY,kCACZC,KAAM,CAACC,GAAIR,oBAAoBG,YAK3CX,EAAEiB,KAAKC,MAAMlB,EAAGE,KAAKiB,KAAKT,UAAU,IAAQU,MAAK,eACzCT,EAAI,EACJU,aAAe,OAEdV,EAAI,EAAGA,EAAIW,UAAUT,OAAQF,IAC9BU,aAAaV,GAAKW,UAAUX,OAE5BY,QAAU,CACVF,aAAcA,qBAGXjB,UAAUoB,OAAO,+BAAgCD,YACzDH,MAAK,SAASK,KAAMC,WACnBtB,UAAUuB,YAAY3B,EAAE,gCAAiCyB,KAAMC,KACxD,KACRE,KAAKzB,aAAa0B,YAEd,GAUPC,0BAA4B,SAASC,OAGjCpB,EAFAH,oBAAsBR,EAAE,gCAAgCS,MAAMG,MAAM,KACpEoB,gBAAkB,GAElBC,SAAWjC,EAAE+B,EAAEG,eAAeC,KAAK,UAElCxB,EAAI,EAAGA,EAAIH,oBAAoBK,OAAQF,IACpCH,oBAAoBG,IAAMsB,WAC1BD,gBAAgBA,gBAAgBnB,QAAUL,oBAAoBG,WAItEX,EAAE,gCAAgCS,IAAIuB,gBAAgBI,KAAK,MAEpD7B,sBAQP8B,wBAA0B,eACtB7B,oBAAsBR,EAAE,gCAAgCS,MAAMG,MAAM,KAEnEP,iBACDA,eAAiB,IAAIJ,OAAOK,eAAe,EAAO,WAAW,IAC9CgC,GAAG,QAAQ,SAASP,EAAGI,UAC9BI,OAASvC,EAAE,gCAAgCS,MAC3C+B,QAAUL,KAAKM,cACL,IAAVF,SACAC,QAAUA,QAAQE,OAAOH,OAAO3B,MAAM,WAEtC+B,MAAQH,QAAQJ,KAAK,YAEzBpC,EAAE,gCAAgCS,IAAIkC,OAE/BpC,wBAIfF,eAAeuC,2BAA2BpC,qBAC1CH,eAAewC,iBAGyC,CAOxDC,KAAM,SAASC,WACXzC,cAAgByC,UAChBxC,qBACAP,EAAE,uCAAuCsC,GAAG,QAASD,yBACrDrC,EAAE,QAAQsC,GAAG,QAAS,sCAAuCR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/frameworkactions.min.js b/admin/tool/lp/amd/build/frameworkactions.min.js index 523461f0c27..c192d3a573d 100644 --- a/admin/tool/lp/amd/build/frameworkactions.min.js +++ b/admin/tool/lp/amd/build/frameworkactions.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/frameworkactions",["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=0,h=function(c,d){a("[data-region=\"managecompetencies\"]").replaceWith(c);b.runTemplateJS(d)},i=function(a){b.render("tool_lp/manage_competency_frameworks_page",a).done(h).fail(d.exception)},j=function(b){b.preventDefault();g=a(this).attr("data-frameworkid");var e=c.call([{methodname:"core_competency_duplicate_competency_framework",args:{id:g}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:{pagecontext:{contextid:f}}}]);e[1].done(i).fail(d.exception)},k=function(){var a=c.call([{methodname:"core_competency_delete_competency_framework",args:{id:g}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:{pagecontext:{contextid:f}}}]);a[0].done(function(a){if(!1===a){var b=c.call([{methodname:"core_competency_read_competency_framework",args:{id:g}}]);b[0].done(function(a){e.get_strings([{key:"frameworkcannotbedeleted",component:"tool_lp",param:a.shortname},{key:"cancel",component:"moodle"}]).done(function(a){d.alert(null,a[0])}).fail(d.exception)})}}).fail(d.exception);a[1].done(i).fail(d.exception)},l=function(b){b.preventDefault();var f=a(this).attr("data-frameworkid");g=f;var h=c.call([{methodname:"core_competency_read_competency_framework",args:{id:g}}]);h[0].done(function(a){e.get_strings([{key:"confirm",component:"moodle"},{key:"deletecompetencyframework",component:"tool_lp",param:a.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],k)}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:l,duplicateHandler:j,init:function init(a){f=a}}}); -//# sourceMappingURL=frameworkactions.min.js.map +/** + * Competency frameworks actions via ajax. + * + * @module tool_lp/frameworkactions + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/frameworkactions",["jquery","core/templates","core/ajax","core/notification","core/str"],(function($,templates,ajax,notification,str){var pagecontextid=0,frameworkid=0,updatePage=function(newhtml,newjs){$('[data-region="managecompetencies"]').replaceWith(newhtml),templates.runTemplateJS(newjs)},reloadList=function(context){templates.render("tool_lp/manage_competency_frameworks_page",context).done(updatePage).fail(notification.exception)},doDelete=function(){var requests=ajax.call([{methodname:"core_competency_delete_competency_framework",args:{id:frameworkid}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:{pagecontext:{contextid:pagecontextid}}}]);requests[0].done((function(success){!1===success&&ajax.call([{methodname:"core_competency_read_competency_framework",args:{id:frameworkid}}])[0].done((function(framework){str.get_strings([{key:"frameworkcannotbedeleted",component:"tool_lp",param:framework.shortname},{key:"cancel",component:"moodle"}]).done((function(strings){notification.alert(null,strings[0])})).fail(notification.exception)}))})).fail(notification.exception),requests[1].done(reloadList).fail(notification.exception)};return{deleteHandler:function(e){e.preventDefault();var id=$(this).attr("data-frameworkid");frameworkid=id,ajax.call([{methodname:"core_competency_read_competency_framework",args:{id:frameworkid}}])[0].done((function(framework){str.get_strings([{key:"confirm",component:"moodle"},{key:"deletecompetencyframework",component:"tool_lp",param:framework.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],doDelete)})).fail(notification.exception)})).fail(notification.exception)},duplicateHandler:function(e){e.preventDefault(),frameworkid=$(this).attr("data-frameworkid"),ajax.call([{methodname:"core_competency_duplicate_competency_framework",args:{id:frameworkid}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:{pagecontext:{contextid:pagecontextid}}}])[1].done(reloadList).fail(notification.exception)},init:function(contextid){pagecontextid=contextid}}})); + +//# sourceMappingURL=frameworkactions.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/frameworkactions.min.js.map b/admin/tool/lp/amd/build/frameworkactions.min.js.map index a661f254c5a..96e2bbfc0ee 100644 --- a/admin/tool/lp/amd/build/frameworkactions.min.js.map +++ b/admin/tool/lp/amd/build/frameworkactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/frameworkactions.js"],"names":["define","$","templates","ajax","notification","str","pagecontextid","frameworkid","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDuplicate","e","preventDefault","attr","requests","call","methodname","args","id","pagecontext","contextid","doDelete","success","req","framework","get_strings","key","component","param","shortname","strings","alert","confirmDelete","confirm","deleteHandler","duplicateHandler","init"],"mappings":"AAsBAA,OAAM,4BAAC,CAAC,QAAD,CAAW,gBAAX,CAA6B,WAA7B,CAA0C,mBAA1C,CAA+D,UAA/D,CAAD,CAA6E,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,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,CAAU,CAAC,CACtBC,UAAU,CAAE,2CADU,CAEtBC,IAAI,CAAE,CAACC,EAAE,CAAEpB,CAAL,CAFgB,CAAD,CAAV,CAAf,CAKAgB,CAAQ,CAAC,CAAD,CAAR,CAAYP,IAAZ,CAAiB,SAASiB,CAAT,CAAoB,CACjC5B,CAAG,CAAC6B,WAAJ,CAAgB,CACZ,CAACC,GAAG,CAAE,SAAN,CAAiBC,SAAS,CAAE,QAA5B,CADY,CAEZ,CAACD,GAAG,CAAE,2BAAN,CAAmCC,SAAS,CAAE,SAA9C,CAAyDC,KAAK,CAAEJ,CAAS,CAACK,SAA1E,CAFY,CAGZ,CAACH,GAAG,CAAE,QAAN,CAAgBC,SAAS,CAAE,QAA3B,CAHY,CAIZ,CAACD,GAAG,CAAE,QAAN,CAAgBC,SAAS,CAAE,QAA3B,CAJY,CAAhB,EAKGpB,IALH,CAKQ,SAASuB,CAAT,CAAkB,CACtBnC,CAAY,CAACsC,OAAb,CACIH,CAAO,CAAC,CAAD,CADX,CAEIA,CAAO,CAAC,CAAD,CAFX,CAGIA,CAAO,CAAC,CAAD,CAHX,CAIIA,CAAO,CAAC,CAAD,CAJX,CAKIT,CALJ,CAOH,CAbD,EAaGb,IAbH,CAaQb,CAAY,CAACc,SAbrB,CAcH,CAfD,EAeGD,IAfH,CAeQb,CAAY,CAACc,SAfrB,CAiBH,CA9H8H,CAiI/H,MAAqD,CAQjDyB,aAAa,CAAEF,CARkC,CAejDG,gBAAgB,CAAEzB,CAf+B,CAsBjD0B,IAAI,CAAE,cAAShB,CAAT,CAAoB,CACtBvB,CAAa,CAAGuB,CACnB,CAxBgD,CA0BxD,CA3JK,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 * Competency frameworks actions via ajax.\n *\n * @module tool_lp/frameworkactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} frameworkid The id of the framework */\n var frameworkid = 0;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_competency_frameworks_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Duplicate a framework and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n frameworkid = $(this).attr('data-frameworkid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n /**\n * Delete a framework and reload the page.\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n var req = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n req[0].done(function(framework) {\n str.get_strings([\n {key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n });\n }\n }).fail(notification.exception);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete competency framework\" actions.\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-frameworkid');\n frameworkid = id;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n\n requests[0].done(function(framework) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency framework X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n\n return /** @alias module:tool_lp/frameworkactions */ {\n // Public variables and functions.\n\n /**\n * Expose the event handler for delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"file":"frameworkactions.min.js"} \ No newline at end of file +{"version":3,"file":"frameworkactions.min.js","sources":["../src/frameworkactions.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 * Competency frameworks actions via ajax.\n *\n * @module tool_lp/frameworkactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} frameworkid The id of the framework */\n var frameworkid = 0;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_competency_frameworks_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Duplicate a framework and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n frameworkid = $(this).attr('data-frameworkid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n /**\n * Delete a framework and reload the page.\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n var req = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n req[0].done(function(framework) {\n str.get_strings([\n {key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n });\n }\n }).fail(notification.exception);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete competency framework\" actions.\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-frameworkid');\n frameworkid = id;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n\n requests[0].done(function(framework) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency framework X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n\n return /** @alias module:tool_lp/frameworkactions */ {\n // Public variables and functions.\n\n /**\n * Expose the event handler for delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"names":["define","$","templates","ajax","notification","str","pagecontextid","frameworkid","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDelete","requests","call","methodname","args","id","pagecontext","contextid","success","framework","get_strings","key","component","param","shortname","strings","alert","deleteHandler","e","preventDefault","this","attr","confirm","duplicateHandler","init"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,SAAU,iBAAkB,YAAa,oBAAqB,aAAa,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,SAItHC,cAAgB,EAGhBC,YAAc,EAQdC,WAAa,SAASC,QAASC,OAC/BT,EAAE,sCAAsCU,YAAYF,SACpDP,UAAUU,cAAcF,QAQxBG,WAAa,SAASC,SACtBZ,UAAUa,OAAO,4CAA6CD,SACzDE,KAAKR,YACLS,KAAKb,aAAac,YA8BvBC,SAAW,eAGPC,SAAWjB,KAAKkB,KAAK,CAAC,CACtBC,WAAY,8CACZC,KAAM,CAACC,GAAIjB,cACZ,CACCe,WAAY,qDACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAIvBc,SAAS,GAAGJ,MAAK,SAASW,UACN,IAAZA,SACUxB,KAAKkB,KAAK,CAAC,CACjBC,WAAY,4CACZC,KAAM,CAACC,GAAIjB,gBAEX,GAAGS,MAAK,SAASY,WACjBvB,IAAIwB,YAAY,CACZ,CAACC,IAAK,2BAA4BC,UAAW,UAAWC,MAAOJ,UAAUK,WACzE,CAACH,IAAK,SAAUC,UAAW,YAC5Bf,MAAK,SAASkB,SACb9B,aAAa+B,MACT,KACAD,QAAQ,OAEbjB,KAAKb,aAAac,iBAG9BD,KAAKb,aAAac,WACrBE,SAAS,GAAGJ,KAAKH,YAAYI,KAAKb,aAAac,kBAsCE,CAQjDkB,cAvCgB,SAASC,GACzBA,EAAEC,qBAEEd,GAAKvB,EAAEsC,MAAMC,KAAK,oBACtBjC,YAAciB,GAECrB,KAAKkB,KAAK,CAAC,CACtBC,WAAY,4CACZC,KAAM,CAACC,GAAIjB,gBAGN,GAAGS,MAAK,SAASY,WACtBvB,IAAIwB,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,4BAA6BC,UAAW,UAAWC,MAAOJ,UAAUK,WAC1E,CAACH,IAAK,SAAUC,UAAW,UAC3B,CAACD,IAAK,SAAUC,UAAW,YAC5Bf,MAAK,SAASkB,SACb9B,aAAaqC,QACTP,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRf,aAELF,KAAKb,aAAac,cACtBD,KAAKb,aAAac,YAoBrBwB,iBA5Gc,SAASL,GACvBA,EAAEC,iBAEF/B,YAAcN,EAAEsC,MAAMC,KAAK,oBAGZrC,KAAKkB,KAAK,CAAC,CACtBC,WAAY,iDACZC,KAAM,CAACC,GAAIjB,cACZ,CACCe,WAAY,qDACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAId,GAAGU,KAAKH,YAAYI,KAAKb,aAAac,YAkG/CyB,KAAM,SAASjB,WACXpB,cAAgBoB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/frameworks_datasource.min.js b/admin/tool/lp/amd/build/frameworks_datasource.min.js index 7e4abb6a966..e0ad0ad1808 100644 --- a/admin/tool/lp/amd/build/frameworks_datasource.min.js +++ b/admin/tool/lp/amd/build/frameworks_datasource.min.js @@ -1,2 +1,12 @@ -define ("tool_lp/frameworks_datasource",["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function list(c,d){var e={context:{contextid:c}};a.extend(e,"undefined"==typeof d?{}:d);return b.call([{methodname:"core_competency_list_competency_frameworks",args:e}])[0]},processResults:function processResults(b,c){var d=[];a.each(c,function(a,b){d.push({value:b.id,label:b.shortname+" "+b.idnumber})});return d},transport:function transport(b,d,e){var f=a(b),g=f.data("contextid"),h=f.data("onlyvisible");if(!g){throw new Error("The attribute data-contextid is required on "+b)}this.list(g,{query:d,onlyvisible:h}).then(e).catch(c.exception)}}}); -//# sourceMappingURL=frameworks_datasource.min.js.map +/** + * Frameworks datasource. + * + * This module is compatible with core/form-autocomplete. + * + * @module tool_lp/frameworks_datasource + * @copyright 2016 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/frameworks_datasource",["jquery","core/ajax","core/notification"],(function($,Ajax,Notification){return{list:function(contextId,options){var args={context:{contextid:contextId}};return $.extend(args,void 0===options?{}:options),Ajax.call([{methodname:"core_competency_list_competency_frameworks",args:args}])[0]},processResults:function(selector,results){var options=[];return $.each(results,(function(index,data){options.push({value:data.id,label:data.shortname+" "+data.idnumber})})),options},transport:function(selector,query,callback){var el=$(selector),contextId=el.data("contextid"),onlyVisible=el.data("onlyvisible");if(!contextId)throw new Error("The attribute data-contextid is required on "+selector);this.list(contextId,{query:query,onlyvisible:onlyVisible}).then(callback).catch(Notification.exception)}}})); + +//# sourceMappingURL=frameworks_datasource.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/frameworks_datasource.min.js.map b/admin/tool/lp/amd/build/frameworks_datasource.min.js.map index 1cfb8eecc1b..26a6873f93f 100644 --- a/admin/tool/lp/amd/build/frameworks_datasource.min.js.map +++ b/admin/tool/lp/amd/build/frameworks_datasource.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/frameworks_datasource.js"],"names":["define","$","Ajax","Notification","list","contextId","options","args","context","contextid","extend","call","methodname","processResults","selector","results","each","index","data","push","value","id","label","shortname","idnumber","transport","query","callback","el","onlyVisible","Error","onlyvisible","then","catch","exception"],"mappings":"AAyBAA,OAAM,iCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,mBAAxB,CAAD,CAA+C,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgC,CAEjF,MAAiE,CAS7DC,IAAI,CAAE,cAASC,CAAT,CAAoBC,CAApB,CAA6B,CAC/B,GAAIC,CAAAA,CAAI,CAAG,CACHC,OAAO,CAAE,CACLC,SAAS,CAAEJ,CADN,CADN,CAAX,CAMAJ,CAAC,CAACS,MAAF,CAASH,CAAT,CAAkC,WAAnB,QAAOD,CAAAA,CAAP,CAAiC,EAAjC,CAAsCA,CAArD,EACA,MAAOJ,CAAAA,CAAI,CAACS,IAAL,CAAU,CAAC,CACdC,UAAU,CAAE,4CADE,CAEdL,IAAI,CAAEA,CAFQ,CAAD,CAAV,EAGH,CAHG,CAIV,CArB4D,CA8B7DM,cAAc,CAAE,wBAASC,CAAT,CAAmBC,CAAnB,CAA4B,CACxC,GAAIT,CAAAA,CAAO,CAAG,EAAd,CACAL,CAAC,CAACe,IAAF,CAAOD,CAAP,CAAgB,SAASE,CAAT,CAAgBC,CAAhB,CAAsB,CAClCZ,CAAO,CAACa,IAAR,CAAa,CACTC,KAAK,CAAEF,CAAI,CAACG,EADH,CAETC,KAAK,CAAEJ,CAAI,CAACK,SAAL,CAAiB,GAAjB,CAAuBL,CAAI,CAACM,QAF1B,CAAb,CAIH,CALD,EAMA,MAAOlB,CAAAA,CACV,CAvC4D,CAiD7DmB,SAAS,CAAE,mBAASX,CAAT,CAAmBY,CAAnB,CAA0BC,CAA1B,CAAoC,CAC3C,GAAIC,CAAAA,CAAE,CAAG3B,CAAC,CAACa,CAAD,CAAV,CACIT,CAAS,CAAGuB,CAAE,CAACV,IAAH,CAAQ,WAAR,CADhB,CAEIW,CAAW,CAAGD,CAAE,CAACV,IAAH,CAAQ,aAAR,CAFlB,CAIA,GAAI,CAACb,CAAL,CAAgB,CACZ,KAAM,IAAIyB,CAAAA,KAAJ,CAAU,+CAAiDhB,CAA3D,CACT,CACD,KAAKV,IAAL,CAAUC,CAAV,CAAqB,CACjBqB,KAAK,CAAEA,CADU,CAEjBK,WAAW,CAAEF,CAFI,CAArB,EAGGG,IAHH,CAGQL,CAHR,EAGkBM,KAHlB,CAGwB9B,CAAY,CAAC+B,SAHrC,CAIH,CA7D4D,CAgEpE,CAlEK,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 * Frameworks datasource.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @module tool_lp/frameworks_datasource\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:tool_lpmigrate/frameworks_datasource */ {\n\n /**\n * List frameworks.\n *\n * @param {Number} contextId The context ID.\n * @param {Object} options Additional parameters to pass to the external function.\n * @return {Promise}\n */\n list: function(contextId, options) {\n var args = {\n context: {\n contextid: contextId\n }\n };\n\n $.extend(args, typeof options === 'undefined' ? {} : options);\n return Ajax.call([{\n methodname: 'core_competency_list_competency_frameworks',\n args: args\n }])[0];\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.id,\n label: data.shortname + ' ' + data.idnumber\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n var el = $(selector),\n contextId = el.data('contextid'),\n onlyVisible = el.data('onlyvisible');\n\n if (!contextId) {\n throw new Error('The attribute data-contextid is required on ' + selector);\n }\n this.list(contextId, {\n query: query,\n onlyvisible: onlyVisible,\n }).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"file":"frameworks_datasource.min.js"} \ No newline at end of file +{"version":3,"file":"frameworks_datasource.min.js","sources":["../src/frameworks_datasource.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 * Frameworks datasource.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @module tool_lp/frameworks_datasource\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:tool_lpmigrate/frameworks_datasource */ {\n\n /**\n * List frameworks.\n *\n * @param {Number} contextId The context ID.\n * @param {Object} options Additional parameters to pass to the external function.\n * @return {Promise}\n */\n list: function(contextId, options) {\n var args = {\n context: {\n contextid: contextId\n }\n };\n\n $.extend(args, typeof options === 'undefined' ? {} : options);\n return Ajax.call([{\n methodname: 'core_competency_list_competency_frameworks',\n args: args\n }])[0];\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.id,\n label: data.shortname + ' ' + data.idnumber\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n var el = $(selector),\n contextId = el.data('contextid'),\n onlyVisible = el.data('onlyvisible');\n\n if (!contextId) {\n throw new Error('The attribute data-contextid is required on ' + selector);\n }\n this.list(contextId, {\n query: query,\n onlyvisible: onlyVisible,\n }).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","list","contextId","options","args","context","contextid","extend","call","methodname","processResults","selector","results","each","index","data","push","value","id","label","shortname","idnumber","transport","query","callback","el","onlyVisible","Error","onlyvisible","then","catch","exception"],"mappings":";;;;;;;;;AAyBAA,uCAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBAEF,CAS7DC,KAAM,SAASC,UAAWC,aAClBC,KAAO,CACHC,QAAS,CACLC,UAAWJ,mBAIvBJ,EAAES,OAAOH,UAAyB,IAAZD,QAA0B,GAAKA,SAC9CJ,KAAKS,KAAK,CAAC,CACdC,WAAY,6CACZL,KAAMA,QACN,IAURM,eAAgB,SAASC,SAAUC,aAC3BT,QAAU,UACdL,EAAEe,KAAKD,SAAS,SAASE,MAAOC,MAC5BZ,QAAQa,KAAK,CACTC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,UAAY,IAAML,KAAKM,cAGpClB,SAWXmB,UAAW,SAASX,SAAUY,MAAOC,cAC7BC,GAAK3B,EAAEa,UACPT,UAAYuB,GAAGV,KAAK,aACpBW,YAAcD,GAAGV,KAAK,mBAErBb,gBACK,IAAIyB,MAAM,+CAAiDhB,eAEhEV,KAAKC,UAAW,CACjBqB,MAAOA,MACPK,YAAaF,cACdG,KAAKL,UAAUM,MAAM9B,aAAa+B"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/grade_dialogue.min.js b/admin/tool/lp/amd/build/grade_dialogue.min.js index 9637bc9003a..a9c9c8d053b 100644 --- a/admin/tool/lp/amd/build/grade_dialogue.min.js +++ b/admin/tool/lp/amd/build/grade_dialogue.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/grade_dialogue",["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/event_base","core/str"],function(a,b,c,d,e,f){var g=function(a){e.prototype.constructor.apply(this,[]);this._ratingOptions=a};g.prototype=Object.create(e.prototype);g.prototype._popup=null;g.prototype._ratingOptions=null;g.prototype._afterRender=function(){var b=this._find("[data-action=\"rate\"]"),c=this._find("[name=\"rating\"]"),d=this._find("[name=\"comment\"]");this._find("[data-action=\"cancel\"]").click(function(a){a.preventDefault();this._trigger("cancelled");this.close()}.bind(this));c.change(function(){var c=a(this);if(!c.val()){b.prop("disabled",!0)}else{b.prop("disabled",!1)}}).change();b.click(function(a){a.preventDefault();var b=c.val();if(!b){return}this._trigger("rated",{rating:b,note:d.val()});this.close()}.bind(this))};g.prototype.close=function(){this._popup.close();this._popup=null};g.prototype.display=function(){M.util.js_pending("tool_lp/grade_dialogue:display");return a.when(f.get_string("rate","tool_lp"),this._render()).then(function(a,b){this._popup=new d(a,b[0],function(){this._afterRender();M.util.js_complete("tool_lp/grade_dialogue:display")}.bind(this));return this._popup}.bind(this)).catch(b.exception)};g.prototype._find=function(b){return a(this._popup.getContent()).find(b)};g.prototype._render=function(){var a={cangrade:this._canGrade,ratings:this._ratingOptions};return c.render("tool_lp/competency_grader",a)};return g}); -//# sourceMappingURL=grade_dialogue.min.js.map +/** + * Grade dialogue. + * + * @module tool_lp/grade_dialogue + * @copyright 2016 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/grade_dialogue",["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/event_base","core/str"],(function($,Notification,Templates,Dialogue,EventBase,Str){var Grade=function(ratingOptions){EventBase.prototype.constructor.apply(this,[]),this._ratingOptions=ratingOptions};return(Grade.prototype=Object.create(EventBase.prototype))._popup=null,Grade.prototype._ratingOptions=null,Grade.prototype._afterRender=function(){var btnRate=this._find('[data-action="rate"]'),lstRating=this._find('[name="rating"]'),txtComment=this._find('[name="comment"]');this._find('[data-action="cancel"]').click(function(e){e.preventDefault(),this._trigger("cancelled"),this.close()}.bind(this)),lstRating.change((function(){$(this).val()?btnRate.prop("disabled",!1):btnRate.prop("disabled",!0)})).change(),btnRate.click(function(e){e.preventDefault();var val=lstRating.val();val&&(this._trigger("rated",{rating:val,note:txtComment.val()}),this.close())}.bind(this))},Grade.prototype.close=function(){this._popup.close(),this._popup=null},Grade.prototype.display=function(){return M.util.js_pending("tool_lp/grade_dialogue:display"),$.when(Str.get_string("rate","tool_lp"),this._render()).then(function(title,templateResult){return this._popup=new Dialogue(title,templateResult[0],function(){this._afterRender(),M.util.js_complete("tool_lp/grade_dialogue:display")}.bind(this)),this._popup}.bind(this)).catch(Notification.exception)},Grade.prototype._find=function(selector){return $(this._popup.getContent()).find(selector)},Grade.prototype._render=function(){var context={cangrade:this._canGrade,ratings:this._ratingOptions};return Templates.render("tool_lp/competency_grader",context)},Grade})); + +//# sourceMappingURL=grade_dialogue.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/grade_dialogue.min.js.map b/admin/tool/lp/amd/build/grade_dialogue.min.js.map index 333e741fe4e..52764f4e8fe 100644 --- a/admin/tool/lp/amd/build/grade_dialogue.min.js.map +++ b/admin/tool/lp/amd/build/grade_dialogue.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/grade_dialogue.js"],"names":["define","$","Notification","Templates","Dialogue","EventBase","Str","Grade","ratingOptions","prototype","constructor","apply","_ratingOptions","Object","create","_popup","_afterRender","btnRate","_find","lstRating","txtComment","click","e","preventDefault","_trigger","close","bind","change","node","val","prop","display","M","util","js_pending","when","get_string","_render","then","title","templateResult","js_complete","catch","exception","selector","getContent","find","context","cangrade","_canGrade","ratings","render"],"mappings":"AAuBAA,OAAM,0BAAC,CAAC,QAAD,CACC,mBADD,CAEC,gBAFD,CAGC,kBAHD,CAIC,oBAJD,CAKC,UALD,CAAD,CAME,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAqCC,CAArC,CAA+CC,CAA/C,CAA0DC,CAA1D,CAA+D,CAQnE,GAAIC,CAAAA,CAAK,CAAG,SAASC,CAAT,CAAwB,CAChCH,CAAS,CAACI,SAAV,CAAoBC,WAApB,CAAgCC,KAAhC,C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,CAA8CJ,CAA9C,CACV,CAND,CAQA,MAAOxC,CAAAA,CACV,CAlIK,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 * Grade dialogue.\n *\n * @module tool_lp/grade_dialogue\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base',\n 'core/str'],\n function($, Notification, Templates, Dialogue, EventBase, Str) {\n\n /**\n * Grade dialogue class.\n *\n * @class tool_lp/grade_dialogue\n * @param {Array} ratingOptions\n */\n var Grade = function(ratingOptions) {\n EventBase.prototype.constructor.apply(this, []);\n this._ratingOptions = ratingOptions;\n };\n Grade.prototype = Object.create(EventBase.prototype);\n\n /** @property {Dialogue} The dialogue. */\n Grade.prototype._popup = null;\n /** @property {Array} Array of objects containing, 'value', 'name' and optionally 'selected'. */\n Grade.prototype._ratingOptions = null;\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n Grade.prototype._afterRender = function() {\n var btnRate = this._find('[data-action=\"rate\"]'),\n lstRating = this._find('[name=\"rating\"]'),\n txtComment = this._find('[name=\"comment\"]');\n\n this._find('[data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n this._trigger('cancelled');\n this.close();\n }.bind(this));\n\n lstRating.change(function() {\n var node = $(this);\n if (!node.val()) {\n btnRate.prop('disabled', true);\n } else {\n btnRate.prop('disabled', false);\n }\n }).change();\n\n btnRate.click(function(e) {\n e.preventDefault();\n var val = lstRating.val();\n if (!val) {\n return;\n }\n this._trigger('rated', {\n 'rating': val,\n 'note': txtComment.val()\n });\n this.close();\n }.bind(this));\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Grade.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Grade.prototype.display = function() {\n M.util.js_pending('tool_lp/grade_dialogue:display');\n return $.when(\n Str.get_string('rate', 'tool_lp'),\n this._render()\n )\n .then(function(title, templateResult) {\n this._popup = new Dialogue(\n title,\n templateResult[0],\n function() {\n this._afterRender();\n M.util.js_complete('tool_lp/grade_dialogue:display');\n }.bind(this)\n );\n\n return this._popup;\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @method _find\n * @returns {node} The node\n * @protected\n */\n Grade.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n Grade.prototype._render = function() {\n var context = {\n cangrade: this._canGrade,\n ratings: this._ratingOptions\n };\n return Templates.render('tool_lp/competency_grader', context);\n };\n\n return Grade;\n});\n"],"file":"grade_dialogue.min.js"} \ No newline at end of file +{"version":3,"file":"grade_dialogue.min.js","sources":["../src/grade_dialogue.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 * Grade dialogue.\n *\n * @module tool_lp/grade_dialogue\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base',\n 'core/str'],\n function($, Notification, Templates, Dialogue, EventBase, Str) {\n\n /**\n * Grade dialogue class.\n *\n * @class tool_lp/grade_dialogue\n * @param {Array} ratingOptions\n */\n var Grade = function(ratingOptions) {\n EventBase.prototype.constructor.apply(this, []);\n this._ratingOptions = ratingOptions;\n };\n Grade.prototype = Object.create(EventBase.prototype);\n\n /** @property {Dialogue} The dialogue. */\n Grade.prototype._popup = null;\n /** @property {Array} Array of objects containing, 'value', 'name' and optionally 'selected'. */\n Grade.prototype._ratingOptions = null;\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n Grade.prototype._afterRender = function() {\n var btnRate = this._find('[data-action=\"rate\"]'),\n lstRating = this._find('[name=\"rating\"]'),\n txtComment = this._find('[name=\"comment\"]');\n\n this._find('[data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n this._trigger('cancelled');\n this.close();\n }.bind(this));\n\n lstRating.change(function() {\n var node = $(this);\n if (!node.val()) {\n btnRate.prop('disabled', true);\n } else {\n btnRate.prop('disabled', false);\n }\n }).change();\n\n btnRate.click(function(e) {\n e.preventDefault();\n var val = lstRating.val();\n if (!val) {\n return;\n }\n this._trigger('rated', {\n 'rating': val,\n 'note': txtComment.val()\n });\n this.close();\n }.bind(this));\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Grade.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Grade.prototype.display = function() {\n M.util.js_pending('tool_lp/grade_dialogue:display');\n return $.when(\n Str.get_string('rate', 'tool_lp'),\n this._render()\n )\n .then(function(title, templateResult) {\n this._popup = new Dialogue(\n title,\n templateResult[0],\n function() {\n this._afterRender();\n M.util.js_complete('tool_lp/grade_dialogue:display');\n }.bind(this)\n );\n\n return this._popup;\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @method _find\n * @returns {node} The node\n * @protected\n */\n Grade.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n Grade.prototype._render = function() {\n var context = {\n cangrade: this._canGrade,\n ratings: this._ratingOptions\n };\n return Templates.render('tool_lp/competency_grader', context);\n };\n\n return Grade;\n});\n"],"names":["define","$","Notification","Templates","Dialogue","EventBase","Str","Grade","ratingOptions","prototype","constructor","apply","this","_ratingOptions","Object","create","_popup","_afterRender","btnRate","_find","lstRating","txtComment","click","e","preventDefault","_trigger","close","bind","change","val","prop","display","M","util","js_pending","when","get_string","_render","then","title","templateResult","js_complete","catch","exception","selector","getContent","find","context","cangrade","_canGrade","ratings","render"],"mappings":";;;;;;;AAuBAA,gCAAO,CAAC,SACA,oBACA,iBACA,mBACA,qBACA,aACA,SAASC,EAAGC,aAAcC,UAAWC,SAAUC,UAAWC,SAQ1DC,MAAQ,SAASC,eACjBH,UAAUI,UAAUC,YAAYC,MAAMC,KAAM,SACvCC,eAAiBL,sBAE1BD,MAAME,UAAYK,OAAOC,OAAOV,UAAUI,YAG1BO,OAAS,KAEzBT,MAAME,UAAUI,eAAiB,KAQjCN,MAAME,UAAUQ,aAAe,eACvBC,QAAUN,KAAKO,MAAM,wBACrBC,UAAYR,KAAKO,MAAM,mBACvBE,WAAaT,KAAKO,MAAM,yBAEvBA,MAAM,0BAA0BG,MAAM,SAASC,GAChDA,EAAEC,sBACGC,SAAS,kBACTC,SACPC,KAAKf,OAEPQ,UAAUQ,QAAO,WACF3B,EAAEW,MACHiB,MAGNX,QAAQY,KAAK,YAAY,GAFzBZ,QAAQY,KAAK,YAAY,MAI9BF,SAEHV,QAAQI,MAAM,SAASC,GACnBA,EAAEC,qBACEK,IAAMT,UAAUS,MACfA,WAGAJ,SAAS,QAAS,QACTI,SACFR,WAAWQ,aAElBH,UACPC,KAAKf,QAQXL,MAAME,UAAUiB,MAAQ,gBACfV,OAAOU,aACPV,OAAS,MASlBT,MAAME,UAAUsB,QAAU,kBACtBC,EAAEC,KAAKC,WAAW,kCACXjC,EAAEkC,KACL7B,IAAI8B,WAAW,OAAQ,WACvBxB,KAAKyB,WAERC,KAAK,SAASC,MAAOC,4BACbxB,OAAS,IAAIZ,SACdmC,MACAC,eAAe,GACf,gBACSvB,eACLe,EAAEC,KAAKQ,YAAY,mCACrBd,KAAKf,OAGJA,KAAKI,QACdW,KAAKf,OACN8B,MAAMxC,aAAayC,YAWxBpC,MAAME,UAAUU,MAAQ,SAASyB,iBACtB3C,EAAEW,KAAKI,OAAO6B,cAAcC,KAAKF,WAU5CrC,MAAME,UAAU4B,QAAU,eAClBU,QAAU,CACVC,SAAUpC,KAAKqC,UACfC,QAAStC,KAAKC,uBAEXV,UAAUgD,OAAO,4BAA6BJ,UAGlDxC"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js index 45c08008cf2..8f267cb2658 100644 --- a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js +++ b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/grade_user_competency_inline",["jquery","core/notification","core/ajax","core/log","tool_lp/grade_dialogue","tool_lp/event_base","tool_lp/scalevalues"],function(a,b,c,d,e,f,g){var h=function(b,c,d,e,g,h,i){f.prototype.constructor.apply(this,[]);var j=a(b);if(!j.length){throw new Error("Could not find the trigger")}this._scaleId=c;this._competencyId=d;this._userId=e;this._planId=g;this._courseId=h;this._chooseStr=i;this._setUp();j.click(function(a){a.preventDefault();this._dialogue.display()}.bind(this));if(this._planId){this._methodName="core_competency_grade_competency_in_plan";this._args={competencyid:this._competencyId,planid:this._planId}}else if(this._courseId){this._methodName="core_competency_grade_competency_in_course";this._args={competencyid:this._competencyId,courseid:this._courseId,userid:this._userId}}else{this._methodName="core_competency_grade_competency";this._args={userid:this._userId,competencyid:this._competencyId}}};h.prototype=Object.create(f.prototype);h.prototype._setUp=function(){var a=[],d=this;M.util.js_pending("tool_lp/grade_user_competency_inline:_setUp");var f=g.get_values(d._scaleId);f.then(function(b){a.push({value:"",name:d._chooseStr});for(var c=0,e;c.\n\n/**\n * Module to enable inline editing of a comptency grade.\n *\n * @module tool_lp/grade_user_competency_inline\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/log',\n 'tool_lp/grade_dialogue',\n 'tool_lp/event_base',\n 'tool_lp/scalevalues',\n ], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {\n\n /**\n * InlineEditor\n *\n * @class tool_lp/grade_user_competency_inline\n * @param {String} selector The selector to trigger the grading.\n * @param {Number} scaleId The id of the scale for this competency.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {String} chooseStr Language string for choose a rating.\n */\n var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {\n EventBase.prototype.constructor.apply(this, []);\n\n var trigger = $(selector);\n if (!trigger.length) {\n throw new Error('Could not find the trigger');\n }\n\n this._scaleId = scaleId;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._chooseStr = chooseStr;\n this._setUp();\n\n trigger.click(function(e) {\n e.preventDefault();\n this._dialogue.display();\n }.bind(this));\n\n if (this._planId) {\n this._methodName = 'core_competency_grade_competency_in_plan';\n this._args = {\n competencyid: this._competencyId,\n planid: this._planId\n };\n } else if (this._courseId) {\n this._methodName = 'core_competency_grade_competency_in_course';\n this._args = {\n competencyid: this._competencyId,\n courseid: this._courseId,\n userid: this._userId\n };\n } else {\n this._methodName = 'core_competency_grade_competency';\n this._args = {\n userid: this._userId,\n competencyid: this._competencyId\n };\n }\n };\n InlineEditor.prototype = Object.create(EventBase.prototype);\n\n /**\n * Setup.\n *\n * @method _setUp\n */\n InlineEditor.prototype._setUp = function() {\n var options = [],\n self = this;\n\n M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');\n var promise = ScaleValues.get_values(self._scaleId);\n promise.then(function(scalevalues) {\n options.push({\n value: '',\n name: self._chooseStr\n });\n\n for (var i = 0; i < scalevalues.length; i++) {\n var optionConfig = scalevalues[i];\n options.push({\n value: optionConfig.id,\n name: optionConfig.name\n });\n }\n\n return options;\n })\n .then(function(options) {\n return new GradeDialogue(options);\n })\n .then(function(dialogue) {\n dialogue.on('rated', function(e, data) {\n var args = self._args;\n args.grade = data.rating;\n args.note = data.note;\n ajax.call([{\n methodname: self._methodName,\n args: args,\n done: function(evidence) {\n self._trigger('competencyupdated', {args: args, evidence: evidence});\n },\n fail: notification.exception\n }]);\n });\n\n return dialogue;\n })\n .then(function(dialogue) {\n self._dialogue = dialogue;\n\n M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');\n return;\n })\n .fail(notification.exception);\n };\n\n /** @property {Number} The scale id for this competency. */\n InlineEditor.prototype._scaleId = null;\n /** @property {Number} The id of the competency. */\n InlineEditor.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n InlineEditor.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n InlineEditor.prototype._planId = null;\n /** @property {Number} The id of the course. */\n InlineEditor.prototype._courseId = null;\n /** @property {String} The text for Choose rating. */\n InlineEditor.prototype._chooseStr = null;\n /** @property {GradeDialogue} The grading dialogue. */\n InlineEditor.prototype._dialogue = null;\n\n return InlineEditor;\n});\n"],"file":"grade_user_competency_inline.min.js"} \ No newline at end of file +{"version":3,"file":"grade_user_competency_inline.min.js","sources":["../src/grade_user_competency_inline.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 to enable inline editing of a comptency grade.\n *\n * @module tool_lp/grade_user_competency_inline\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/log',\n 'tool_lp/grade_dialogue',\n 'tool_lp/event_base',\n 'tool_lp/scalevalues',\n ], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {\n\n /**\n * InlineEditor\n *\n * @class tool_lp/grade_user_competency_inline\n * @param {String} selector The selector to trigger the grading.\n * @param {Number} scaleId The id of the scale for this competency.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {String} chooseStr Language string for choose a rating.\n */\n var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {\n EventBase.prototype.constructor.apply(this, []);\n\n var trigger = $(selector);\n if (!trigger.length) {\n throw new Error('Could not find the trigger');\n }\n\n this._scaleId = scaleId;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._chooseStr = chooseStr;\n this._setUp();\n\n trigger.click(function(e) {\n e.preventDefault();\n this._dialogue.display();\n }.bind(this));\n\n if (this._planId) {\n this._methodName = 'core_competency_grade_competency_in_plan';\n this._args = {\n competencyid: this._competencyId,\n planid: this._planId\n };\n } else if (this._courseId) {\n this._methodName = 'core_competency_grade_competency_in_course';\n this._args = {\n competencyid: this._competencyId,\n courseid: this._courseId,\n userid: this._userId\n };\n } else {\n this._methodName = 'core_competency_grade_competency';\n this._args = {\n userid: this._userId,\n competencyid: this._competencyId\n };\n }\n };\n InlineEditor.prototype = Object.create(EventBase.prototype);\n\n /**\n * Setup.\n *\n * @method _setUp\n */\n InlineEditor.prototype._setUp = function() {\n var options = [],\n self = this;\n\n M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');\n var promise = ScaleValues.get_values(self._scaleId);\n promise.then(function(scalevalues) {\n options.push({\n value: '',\n name: self._chooseStr\n });\n\n for (var i = 0; i < scalevalues.length; i++) {\n var optionConfig = scalevalues[i];\n options.push({\n value: optionConfig.id,\n name: optionConfig.name\n });\n }\n\n return options;\n })\n .then(function(options) {\n return new GradeDialogue(options);\n })\n .then(function(dialogue) {\n dialogue.on('rated', function(e, data) {\n var args = self._args;\n args.grade = data.rating;\n args.note = data.note;\n ajax.call([{\n methodname: self._methodName,\n args: args,\n done: function(evidence) {\n self._trigger('competencyupdated', {args: args, evidence: evidence});\n },\n fail: notification.exception\n }]);\n });\n\n return dialogue;\n })\n .then(function(dialogue) {\n self._dialogue = dialogue;\n\n M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');\n return;\n })\n .fail(notification.exception);\n };\n\n /** @property {Number} The scale id for this competency. */\n InlineEditor.prototype._scaleId = null;\n /** @property {Number} The id of the competency. */\n InlineEditor.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n InlineEditor.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n InlineEditor.prototype._planId = null;\n /** @property {Number} The id of the course. */\n InlineEditor.prototype._courseId = null;\n /** @property {String} The text for Choose rating. */\n InlineEditor.prototype._chooseStr = null;\n /** @property {GradeDialogue} The grading dialogue. */\n InlineEditor.prototype._dialogue = null;\n\n return InlineEditor;\n});\n"],"names":["define","$","notification","ajax","log","GradeDialogue","EventBase","ScaleValues","InlineEditor","selector","scaleId","competencyId","userId","planId","courseId","chooseStr","prototype","constructor","apply","this","trigger","length","Error","_scaleId","_competencyId","_userId","_planId","_courseId","_chooseStr","_setUp","click","e","preventDefault","_dialogue","display","bind","_methodName","_args","competencyid","planid","courseid","userid","Object","create","options","self","M","util","js_pending","get_values","then","scalevalues","push","value","name","i","optionConfig","id","dialogue","on","data","args","grade","rating","note","call","methodname","done","evidence","_trigger","fail","exception","js_complete"],"mappings":";;;;;;;AAuBAA,8CAAO,CAAC,SACA,oBACA,YACA,WACA,yBACA,qBACA,wBACD,SAASC,EAAGC,aAAcC,KAAMC,IAAKC,cAAeC,UAAWC,iBAc9DC,aAAe,SAASC,SAAUC,QAASC,aAAcC,OAAQC,OAAQC,SAAUC,WACnFT,UAAUU,UAAUC,YAAYC,MAAMC,KAAM,QAExCC,QAAUnB,EAAEQ,cACXW,QAAQC,aACH,IAAIC,MAAM,mCAGfC,SAAWb,aACXc,cAAgBb,kBAChBc,QAAUb,YACVc,QAAUb,YACVc,UAAYb,cACZc,WAAab,eACbc,SAELT,QAAQU,MAAM,SAASC,GACnBA,EAAEC,sBACGC,UAAUC,WACjBC,KAAKhB,OAEHA,KAAKO,cACAU,YAAc,gDACdC,MAAQ,CACTC,aAAcnB,KAAKK,cACnBe,OAAQpB,KAAKO,UAEVP,KAAKQ,gBACPS,YAAc,kDACdC,MAAQ,CACTC,aAAcnB,KAAKK,cACnBgB,SAAUrB,KAAKQ,UACfc,OAAQtB,KAAKM,gBAGZW,YAAc,wCACdC,MAAQ,CACTI,OAAQtB,KAAKM,QACba,aAAcnB,KAAKK,wBAI/BhB,aAAaQ,UAAY0B,OAAOC,OAAOrC,UAAUU,YAO1Ba,OAAS,eACxBe,QAAU,GACVC,KAAO1B,KAEX2B,EAAEC,KAAKC,WAAW,+CACJzC,YAAY0C,WAAWJ,KAAKtB,UAClC2B,MAAK,SAASC,aAClBP,QAAQQ,KAAK,CACTC,MAAO,GACPC,KAAMT,KAAKjB,iBAGV,IAAI2B,EAAI,EAAGA,EAAIJ,YAAY9B,OAAQkC,IAAK,KACrCC,aAAeL,YAAYI,GAC/BX,QAAQQ,KAAK,CACTC,MAAOG,aAAaC,GACpBH,KAAME,aAAaF,cAIpBV,WAEVM,MAAK,SAASN,gBACJ,IAAIvC,cAAcuC,YAE5BM,MAAK,SAASQ,iBACXA,SAASC,GAAG,SAAS,SAAS5B,EAAG6B,UACzBC,KAAOhB,KAAKR,MAChBwB,KAAKC,MAAQF,KAAKG,OAClBF,KAAKG,KAAOJ,KAAKI,KACjB7D,KAAK8D,KAAK,CAAC,CACPC,WAAYrB,KAAKT,YACjByB,KAAMA,KACNM,KAAM,SAASC,UACXvB,KAAKwB,SAAS,oBAAqB,CAACR,KAAMA,KAAMO,SAAUA,YAE9DE,KAAMpE,aAAaqE,gBAIpBb,YAEVR,MAAK,SAASQ,UACXb,KAAKZ,UAAYyB,SAEjBZ,EAAEC,KAAKyB,YAAY,kDAGtBF,KAAKpE,aAAaqE,YAIvB/D,aAAaQ,UAAUO,SAAW,KAElCf,aAAaQ,UAAUQ,cAAgB,KAEvChB,aAAaQ,UAAUS,QAAU,KAEjCjB,aAAaQ,UAAUU,QAAU,KAEjClB,aAAaQ,UAAUW,UAAY,KAEnCnB,aAAaQ,UAAUY,WAAa,KAEpCpB,aAAaQ,UAAUiB,UAAY,KAE5BzB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/menubar.min.js b/admin/tool/lp/amd/build/menubar.min.js index e71b3c84eb6..4f47be5ceac 100644 --- a/admin/tool/lp/amd/build/menubar.min.js +++ b/admin/tool/lp/amd/build/menubar.min.js @@ -1,2 +1,11 @@ -define ("tool_lp/menubar",["jquery"],function(a){var b=!1,c=!1,d=function(){a(".tool-lp-menu .tool-lp-sub-menu").attr("aria-hidden","true");c=!1},e=function(a,b){this.menuRoot=a;this.handlers=b;this.rootMenus=this.menuRoot.children("li");this.subMenus=this.rootMenus.children("ul");this.subMenuItems=this.subMenus.children("li");this.allItems=this.rootMenus.add(this.subMenuItems);this.activeItem=null;this.isChildOpen=!1;this.keys={tab:9,enter:13,esc:27,space:32,left:37,up:38,right:39,down:40};this.addAriaAttributes();this.addEventListeners()};e.prototype.openSubMenu=function(a){this.setOpenDirection();d();a.attr("aria-hidden","false");c=!0};e.prototype.addEventListeners=function(){var f=this;if(!1===b){a(document).click(function(){if(c){d()}});b=!0}this.subMenuItems.mouseenter(function(){a(this).addClass("menu-hover");return!0});this.subMenuItems.mouseout(function(){a(this).removeClass("menu-hover");return!0});this.allItems.click(function(b){return f.handleClick(a(this),b)});this.allItems.keydown(function(b){return f.handleKeyDown(a(this),b)});this.allItems.focus(function(){return f.handleFocus(a(this))});this.allItems.blur(function(){return f.handleBlur(a(this))})};e.prototype.handleClick=function(b,c){c.stopPropagation();var d=b.parent();if(d.is(".tool-lp-menu")){if("true"==b.children("ul").first().attr("aria-hidden")){this.openSubMenu(b.children("ul").first())}else{b.children("ul").first().attr("aria-hidden","true")}}else{this.allItems.removeClass("menu-hover menu-focus");this.activeItem=null;this.menuRoot.find("ul").not(".root-level").attr("aria-hidden","true");var e=b.find("a").first(),f=new a.Event("click");f.target=e;var g=!1;if(this.handlers){a.each(this.handlers,function(c,d){if(g){return}if(0a(window).height()){i=h+d;f.css("margin-top","-"+i+"px")}if(c){if(0>b.left-g){j=g-e;f.css("margin-right","-"+j+"px")}}else{if(b.left+g>a(window).width()){k=g-e;f.css("margin-left","-"+k+"px")}}if(!0){this.menuRoot.addClass("tool-lp-menu-open-left")}else{this.menuRoot.removeClass("tool-lp-menu-open-left")}};e.prototype.handleKeyDown=function(a,b){if(b.altKey||b.ctrlKey){return!0}switch(b.keyCode){case this.keys.tab:{this.menuRoot.find("ul").attr("aria-hidden","true");this.allItems.removeClass("menu-focus");this.activeItem=null;this.isChildOpen=!1;break}case this.keys.esc:{var c=a.parent();if(c.is(".tool-lp-menu")){a.children("ul").first().attr("aria-hidden","true")}else{this.activeItem=c.parent();this.isChildOpen=!1;this.activeItem.focus();c.attr("aria-hidden","true")}b.stopPropagation();return!1}case this.keys.enter:case this.keys.space:{return this.handleClick(a,b)}case this.keys.left:{this.activeItem=this.moveToPrevious(a);this.activeItem.focus();b.stopPropagation();return!1}case this.keys.right:{this.activeItem=this.moveToNext(a);this.activeItem.focus();b.stopPropagation();return!1}case this.keys.up:{this.activeItem=this.moveUp(a);this.activeItem.focus();b.stopPropagation();return!1}case this.keys.down:{this.activeItem=this.moveDown(a);this.activeItem.focus();b.stopPropagation();return!1}}return!0};e.prototype.moveToNext=function(a){var b=a.parent(),c=b.children("li"),d=c.length,e=c.index(a),f=null,g=null;if(b.is(".tool-lp-menu")){if(e + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/menubar",["jquery"],(function($){var documentClickHandlerRegistered=!1,menuActive=!1,closeAllSubMenus=function(){$(".tool-lp-menu .tool-lp-sub-menu").attr("aria-hidden","true"),menuActive=!1},Menubar=function(menuRoot,handlers){this.menuRoot=menuRoot,this.handlers=handlers,this.rootMenus=this.menuRoot.children("li"),this.subMenus=this.rootMenus.children("ul"),this.subMenuItems=this.subMenus.children("li"),this.allItems=this.rootMenus.add(this.subMenuItems),this.activeItem=null,this.isChildOpen=!1,this.keys={tab:9,enter:13,esc:27,space:32,left:37,up:38,right:39,down:40},this.addAriaAttributes(),this.addEventListeners()};return Menubar.prototype.openSubMenu=function(menu){this.setOpenDirection(),closeAllSubMenus(),menu.attr("aria-hidden","false"),menuActive=!0},Menubar.prototype.addEventListeners=function(){var currentThis=this;!1===documentClickHandlerRegistered&&($(document).click((function(){menuActive&&closeAllSubMenus()})),documentClickHandlerRegistered=!0),this.subMenuItems.mouseenter((function(){return $(this).addClass("menu-hover"),!0})),this.subMenuItems.mouseout((function(){return $(this).removeClass("menu-hover"),!0})),this.allItems.click((function(e){return currentThis.handleClick($(this),e)})),this.allItems.keydown((function(e){return currentThis.handleKeyDown($(this),e)})),this.allItems.focus((function(){return currentThis.handleFocus($(this))})),this.allItems.blur((function(){return currentThis.handleBlur($(this))}))},Menubar.prototype.handleClick=function(item,e){if(e.stopPropagation(),item.parent().is(".tool-lp-menu"))"true"==item.children("ul").first().attr("aria-hidden")?this.openSubMenu(item.children("ul").first()):item.children("ul").first().attr("aria-hidden","true");else{this.allItems.removeClass("menu-hover menu-focus"),this.activeItem=null,this.menuRoot.find("ul").not(".root-level").attr("aria-hidden","true");var anchor=item.find("a").first(),clickEvent=new $.Event("click");clickEvent.target=anchor;var eventHandled=!1;this.handlers&&$.each(this.handlers,(function(selector,handler){if(!eventHandled&&item.find(selector).length>0){var callable=$.proxy(handler,anchor);eventHandled=!1===callable(clickEvent)||clickEvent.isDefaultPrevented()}})),eventHandled||"#"===anchor.attr("href")||(window.location.href=anchor.attr("href"))}return!1},Menubar.prototype.handleFocus=function(item){if(null===this.activeItem)this.activeItem=item;else if(item[0]!=this.activeItem[0])return!0;var parentItems=this.activeItem.parentsUntil("ul.tool-lp-menu").filter("li");(this.allItems.removeClass("menu-focus"),this.activeItem.addClass("menu-focus"),parentItems.addClass("menu-focus"),!0===this.isChildOpen)&&(item.parent().is(".tool-lp-menu")&&"true"==item.attr("aria-haspopup")&&this.openSubMenu(item.children("ul").first()));return!0},Menubar.prototype.handleBlur=function(item){return item.removeClass("menu-focus"),!0},Menubar.prototype.setOpenDirection=function(){var pos=this.menuRoot.offset(),isRTL=$(document.body).hasClass("dir-rtl"),heightmenuRoot=this.rootMenus.outerHeight(),widthmenuRoot=this.rootMenus.outerWidth(),subMenuContainer=this.rootMenus.find("ul.tool-lp-sub-menu");subMenuContainer.css("margin-right",""),subMenuContainer.css("margin-left",""),subMenuContainer.css("margin-top",""),subMenuContainer.attr("aria-hidden",!1);var menuRealWidth=subMenuContainer.outerWidth(),menuRealHeight=subMenuContainer.outerHeight(),margintop=null,marginright=null,marginleft=null;pos.top-$(window).scrollTop()+menuRealHeight>$(window).height()&&(margintop=menuRealHeight+heightmenuRoot,subMenuContainer.css("margin-top","-"+margintop+"px")),isRTL?pos.left-menuRealWidth<0&&(marginright=menuRealWidth-widthmenuRoot,subMenuContainer.css("margin-right","-"+marginright+"px")):pos.left+menuRealWidth>$(window).width()&&(marginleft=menuRealWidth-widthmenuRoot,subMenuContainer.css("margin-left","-"+marginleft+"px")),this.menuRoot.addClass("tool-lp-menu-open-left")},Menubar.prototype.handleKeyDown=function(item,e){if(e.altKey||e.ctrlKey)return!0;switch(e.keyCode){case this.keys.tab:this.menuRoot.find("ul").attr("aria-hidden","true"),this.allItems.removeClass("menu-focus"),this.activeItem=null,this.isChildOpen=!1;break;case this.keys.esc:var itemUL=item.parent();return itemUL.is(".tool-lp-menu")?item.children("ul").first().attr("aria-hidden","true"):(this.activeItem=itemUL.parent(),this.isChildOpen=!1,this.activeItem.focus(),itemUL.attr("aria-hidden","true")),e.stopPropagation(),!1;case this.keys.enter:case this.keys.space:return this.handleClick(item,e);case this.keys.left:return this.activeItem=this.moveToPrevious(item),this.activeItem.focus(),e.stopPropagation(),!1;case this.keys.right:return this.activeItem=this.moveToNext(item),this.activeItem.focus(),e.stopPropagation(),!1;case this.keys.up:return this.activeItem=this.moveUp(item),this.activeItem.focus(),e.stopPropagation(),!1;case this.keys.down:return this.activeItem=this.moveDown(item),this.activeItem.focus(),e.stopPropagation(),!1}return!0},Menubar.prototype.moveToNext=function(item){var itemUL=item.parent(),menuItems=itemUL.children("li"),menuNum=menuItems.length,menuIndex=menuItems.index(item),newItem=null,childMenu=null;if(itemUL.is(".tool-lp-menu"))newItem=menuIndex0?item.prev():menuItems.last(),"true"==item.attr("aria-haspopup")&&"false"==(childMenu=item.children("ul").first()).attr("aria-hidden")&&(childMenu.attr("aria-hidden","true"),this.isChildOpen=!0),item.removeClass("menu-focus"),"true"===newItem.attr("aria-haspopup")&&!0===this.isChildOpen&&(childMenu=newItem.children("ul").first(),this.openSubMenu(childMenu));else{var parentLI=itemUL.parent();parentLI.parent().is(".tool-lp-menu")?(itemUL.attr("aria-hidden","true"),item.removeClass("menu-focus"),parentLI.removeClass("menu-focus"),(newItem=(menuIndex=this.rootMenus.index(parentLI))>0?parentLI.prev():this.rootMenus.last()).addClass("menu-focus"),"true"==newItem.attr("aria-haspopup")&&(childMenu=newItem.children("ul").first(),this.openSubMenu(childMenu),this.isChildOpen=!0,newItem=childMenu.children("li").first())):(newItem=itemUL.parent(),itemUL.attr("aria-hidden","true"),item.removeClass("menu-focus"))}return newItem},Menubar.prototype.moveDown=function(item,startChr){var itemUL=item.parent(),menuItems=itemUL.children("li").not(".separator"),menuNum=menuItems.length,menuIndex=menuItems.index(item),newItem=null,newItemUL=null;if(itemUL.is(".tool-lp-menu"))return"true"!=item.attr("aria-haspopup")?item:(newItem=(newItemUL=item.children("ul").first()).children("li").first(),this.openSubMenu(newItemUL),newItem);if(startChr){var match=!1,curNdx=menuIndex+1;for(curNdx==menuNum&&(curNdx=0);curNdx!=menuIndex;){if(menuItems.eq(curNdx).html().charAt(0).toLowerCase()==startChr){match=!0;break}(curNdx+=1)==menuNum&&(curNdx=0)}return!0===match?(newItem=menuItems.eq(curNdx),item.removeClass("menu-focus"),newItem):item}return newItem=menuIndex0?menuItems.eq(menuIndex-1):menuItems.last(),item.removeClass("menu-focus"),newItem)},Menubar.prototype.addAriaAttributes=function(){this.menuRoot.attr("role","menubar"),this.rootMenus.attr("role","menuitem"),this.rootMenus.attr("tabindex","0"),this.rootMenus.attr("aria-haspopup","true"),this.subMenus.attr("role","menu"),this.subMenus.attr("aria-hidden","true"),this.subMenuItems.attr("role","menuitem"),this.subMenuItems.attr("tabindex","-1"),this.menuRoot.addClass("tool-lp-menu"),this.allItems.addClass("tool-lp-menu-item"),this.rootMenus.addClass("tool-lp-root-menu"),this.subMenus.addClass("tool-lp-sub-menu"),this.subMenuItems.addClass("dropdown-item")},{enhance:function(selector,handler){$(selector).each((function(index,element){var menuRoot=$(element);!0!==menuRoot.data("menubarEnhanced")&&(new Menubar(menuRoot,handler),menuRoot.data("menubarEnhanced",!0))}))},closeAll:closeAllSubMenus}})); + +//# sourceMappingURL=menubar.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/menubar.min.js.map b/admin/tool/lp/amd/build/menubar.min.js.map index 8da85b41543..01dbfe4212f 100644 --- a/admin/tool/lp/amd/build/menubar.min.js.map +++ b/admin/tool/lp/amd/build/menubar.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/menubar.js"],"names":["define","$","documentClickHandlerRegistered","menuActive","closeAllSubMenus","attr","Menubar","menuRoot","handlers","rootMenus","children","subMenus","subMenuItems","allItems","add","activeItem","isChildOpen","keys","tab","enter","esc","space","left","up","right","down","addAriaAttributes","addEventListeners","prototype","openSubMenu","menu","setOpenDirection","currentThis","document","click","mouseenter","addClass","mouseout","removeClass","e","handleClick","keydown","handleKeyDown","focus","handleFocus","blur","handleBlur","item","stopPropagation","parentUL","parent","is","first","find","not","anchor","clickEvent","Event","target","eventHandled","each","selector","handler","length","callable","proxy","isDefaultPrevented","window","location","href","parentItems","parentsUntil","filter","itemUL","pos","offset","isRTL","body","hasClass","heightmenuRoot","outerHeight","widthmenuRoot","outerWidth","subMenuContainer","css","menuRealWidth","menuRealHeight","margintop","marginright","marginleft","top","scrollTop","height","width","altKey","ctrlKey","keyCode","moveToPrevious","moveToNext","moveUp","moveDown","menuItems","menuNum","menuIndex","index","newItem","childMenu","next","parentMenus","rootItem","last","prev","parentLI","startChr","newItemUL","match","curNdx","titleChr","eq","html","charAt","toLowerCase","enhance","element","data","closeAll"],"mappings":"AAuBAA,OAAM,mBAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,IAGvBC,CAAAA,CAA8B,GAHP,CAMvBC,CAAU,GANa,CAavBC,CAAgB,CAAG,UAAW,CAC9BH,CAAC,CAAC,iCAAD,CAAD,CAAqCI,IAArC,CAA0C,aAA1C,CAAyD,MAAzD,EAEAF,CAAU,GACb,CAjB0B,CAyBvBG,CAAO,CAAG,SAASC,CAAT,CAAmBC,CAAnB,CAA6B,CAEvC,KAAKD,QAAL,CAAgBA,CAAhB,CACA,KAAKC,QAAL,CAAgBA,CAAhB,CACA,KAAKC,SAAL,CAAiB,KAAKF,QAAL,CAAcG,QAAd,C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AAuB,kBAAvB,EACA,KAAKxB,YAAL,CAAkBwB,QAAlB,CAA2B,eAA3B,CACH,CAhBD,CAkBA,MAA4C,CA0BxCsF,OAAO,CAAE,iBAAS7D,CAAT,CAAmBC,CAAnB,CAA4B,CACjC7D,CAAC,CAAC4D,CAAD,CAAD,CAAYD,IAAZ,CAAiB,SAAS4C,CAAT,CAAgBmB,CAAhB,CAAyB,CACtC,GAAIpH,CAAAA,CAAQ,CAAGN,CAAC,CAAC0H,CAAD,CAAhB,CAEA,GAAI,KAAApH,CAAQ,CAACqH,IAAT,CAAc,iBAAd,CAAJ,CAA+C,CAC1C,GAAItH,CAAAA,CAAJ,CAAYC,CAAZ,CAAsBuD,CAAtB,CAAD,CACAvD,CAAQ,CAACqH,IAAT,CAAc,iBAAd,IACH,CACJ,CAPD,CAQH,CAnCuC,CAyCxCC,QAAQ,CAAEzH,CAzC8B,CA2C/C,CAlzBK,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 * Aria menubar functionality. Enhances a simple nested list structure into a full aria widget.\n * Based on the open ajax example: http://oaa-accessibility.org/example/26/\n *\n * @module tool_lp/menubar\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /** @property {boolean} Flag to indicate if we have already registered a click event handler for the document. */\n var documentClickHandlerRegistered = false;\n\n /** @property {boolean} Flag to indicate whether there's an active, open menu. */\n var menuActive = false;\n\n /**\n * Close all open submenus anywhere in the page (there should only ever be one open at a time).\n *\n * @method closeAllSubMenus\n */\n var closeAllSubMenus = function() {\n $('.tool-lp-menu .tool-lp-sub-menu').attr('aria-hidden', 'true');\n // Every menu's closed at this point, so set the menu active flag to false.\n menuActive = false;\n };\n\n /**\n * Constructor\n *\n * @param {jQuery} menuRoot Jquery collection matching the root of the menu.\n * @param {Function[]} handlers called when a menu item is chosen.\n */\n var Menubar = function(menuRoot, handlers) {\n // Setup private class variables.\n this.menuRoot = menuRoot;\n this.handlers = handlers;\n this.rootMenus = this.menuRoot.children('li');\n this.subMenus = this.rootMenus.children('ul');\n this.subMenuItems = this.subMenus.children('li');\n this.allItems = this.rootMenus.add(this.subMenuItems);\n this.activeItem = null;\n this.isChildOpen = false;\n\n this.keys = {\n tab: 9,\n enter: 13,\n esc: 27,\n space: 32,\n left: 37,\n up: 38,\n right: 39,\n down: 40\n };\n\n this.addAriaAttributes();\n // Add the event listeners.\n this.addEventListeners();\n };\n\n /**\n * Open a submenu, first it closes all other sub-menus and sets the open direction.\n * @method openSubMenu\n * @param {Node} menu\n */\n Menubar.prototype.openSubMenu = function(menu) {\n this.setOpenDirection();\n closeAllSubMenus();\n menu.attr('aria-hidden', 'false');\n // Set menu active flag to true when a menu is opened.\n menuActive = true;\n };\n\n\n /**\n * Bind the event listeners to the DOM\n * @method addEventListeners\n */\n Menubar.prototype.addEventListeners = function() {\n var currentThis = this;\n\n // When clicking outside the menubar.\n if (documentClickHandlerRegistered === false) {\n $(document).click(function() {\n // Check if a menu is opened.\n if (menuActive) {\n // Close menu.\n closeAllSubMenus();\n }\n });\n // Set this flag to true so that we won't need to add a document click handler for the other Menubar instances.\n documentClickHandlerRegistered = true;\n }\n\n // Hovers.\n this.subMenuItems.mouseenter(function() {\n $(this).addClass('menu-hover');\n return true;\n });\n\n this.subMenuItems.mouseout(function() {\n $(this).removeClass('menu-hover');\n return true;\n });\n\n // Mouse listeners.\n this.allItems.click(function(e) {\n return currentThis.handleClick($(this), e);\n });\n\n // Key listeners.\n this.allItems.keydown(function(e) {\n return currentThis.handleKeyDown($(this), e);\n });\n\n this.allItems.focus(function() {\n return currentThis.handleFocus($(this));\n });\n\n this.allItems.blur(function() {\n return currentThis.handleBlur($(this));\n });\n };\n\n /**\n * Process click events for the top menus.\n *\n * @method handleClick\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return {boolean} Returns false\n */\n Menubar.prototype.handleClick = function(item, e) {\n e.stopPropagation();\n\n var parentUL = item.parent();\n\n if (parentUL.is('.tool-lp-menu')) {\n // Toggle the child menu open/closed.\n if (item.children('ul').first().attr('aria-hidden') == 'true') {\n this.openSubMenu(item.children('ul').first());\n } else {\n item.children('ul').first().attr('aria-hidden', 'true');\n }\n } else {\n // Remove hover and focus styling.\n this.allItems.removeClass('menu-hover menu-focus');\n\n // Clear the active item.\n this.activeItem = null;\n\n // Close the menu.\n this.menuRoot.find('ul').not('.root-level').attr('aria-hidden', 'true');\n // Follow any link, or call the click handlers.\n var anchor = item.find('a').first();\n var clickEvent = new $.Event('click');\n clickEvent.target = anchor;\n var eventHandled = false;\n if (this.handlers) {\n $.each(this.handlers, function(selector, handler) {\n if (eventHandled) {\n return;\n }\n if (item.find(selector).length > 0) {\n var callable = $.proxy(handler, anchor);\n // False means stop propogatting events.\n eventHandled = (callable(clickEvent) === false) || clickEvent.isDefaultPrevented();\n }\n });\n }\n // If we didn't find a handler, and the HREF is # that probably means that\n // we are handling it from somewhere else. Let's just do nothing in that case.\n if (!eventHandled && anchor.attr('href') !== '#') {\n window.location.href = anchor.attr('href');\n }\n }\n return false;\n };\n\n /*\n * Process focus events for the menu.\n *\n * @method handleFocus\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleFocus = function(item) {\n\n // If activeItem is null, we are getting focus from outside the menu. Store\n // the item that triggered the event.\n if (this.activeItem === null) {\n this.activeItem = item;\n } else if (item[0] != this.activeItem[0]) {\n return true;\n }\n\n // Get the set of jquery objects for all the parent items of the active item.\n var parentItems = this.activeItem.parentsUntil('ul.tool-lp-menu').filter('li');\n\n // Remove focus styling from all other menu items.\n this.allItems.removeClass('menu-focus');\n\n // Add focus styling to the active item.\n this.activeItem.addClass('menu-focus');\n\n // Add focus styling to all parent items.\n parentItems.addClass('menu-focus');\n\n // If the bChildOpen flag has been set, open the active item's child menu (if applicable).\n if (this.isChildOpen === true) {\n\n var itemUL = item.parent();\n\n // If the itemUL is a root-level menu and item is a parent item,\n // show the child menu.\n if (itemUL.is('.tool-lp-menu') && (item.attr('aria-haspopup') == 'true')) {\n this.openSubMenu(item.children('ul').first());\n }\n }\n\n return true;\n };\n\n /*\n * Process blur events for the menu.\n *\n * @method handleBlur\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleBlur = function(item) {\n item.removeClass('menu-focus');\n\n return true;\n };\n\n /*\n * Determine if the menu should open to the left, or the right,\n * based on the screen size and menu position.\n * @method setOpenDirection\n */\n Menubar.prototype.setOpenDirection = function() {\n var pos = this.menuRoot.offset();\n var isRTL = $(document.body).hasClass('dir-rtl');\n var openLeft = true;\n var heightmenuRoot = this.rootMenus.outerHeight();\n var widthmenuRoot = this.rootMenus.outerWidth();\n // Sometimes the menuMinWidth is not enough to figure out if menu exceeds the window width.\n // So we have to calculate the real menu width.\n var subMenuContainer = this.rootMenus.find('ul.tool-lp-sub-menu');\n\n // Reset margins.\n subMenuContainer.css('margin-right', '');\n subMenuContainer.css('margin-left', '');\n subMenuContainer.css('margin-top', '');\n\n subMenuContainer.attr('aria-hidden', false);\n var menuRealWidth = subMenuContainer.outerWidth(),\n menuRealHeight = subMenuContainer.outerHeight();\n\n var margintop = null,\n marginright = null,\n marginleft = null;\n var top = pos.top - $(window).scrollTop();\n // Top is the same for RTL and LTR.\n if (top + menuRealHeight > $(window).height()) {\n margintop = menuRealHeight + heightmenuRoot;\n subMenuContainer.css('margin-top', '-' + margintop + 'px');\n }\n\n if (isRTL) {\n if (pos.left - menuRealWidth < 0) {\n marginright = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-right', '-' + marginright + 'px');\n }\n } else {\n if (pos.left + menuRealWidth > $(window).width()) {\n marginleft = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-left', '-' + marginleft + 'px');\n }\n }\n\n if (openLeft) {\n this.menuRoot.addClass('tool-lp-menu-open-left');\n } else {\n this.menuRoot.removeClass('tool-lp-menu-open-left');\n }\n\n };\n\n /*\n * Process keyDown events for the menu.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return boolean Returns false if consuming the event\n */\n Menubar.prototype.handleKeyDown = function(item, e) {\n\n if (e.altKey || e.ctrlKey) {\n // Modifier key pressed: Do not process.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n\n // Hide all menu items and update their aria attributes.\n this.menuRoot.find('ul').attr('aria-hidden', 'true');\n\n // Remove focus styling from all menu items.\n this.allItems.removeClass('menu-focus');\n\n this.activeItem = null;\n\n this.isChildOpen = false;\n\n break;\n }\n case this.keys.esc: {\n var itemUL = item.parent();\n\n if (itemUL.is('.tool-lp-menu')) {\n // Hide the child menu and update the aria attributes.\n item.children('ul').first().attr('aria-hidden', 'true');\n } else {\n\n // Move up one level.\n this.activeItem = itemUL.parent();\n\n // Reset the isChildOpen flag.\n this.isChildOpen = false;\n\n // Set focus on the new item.\n this.activeItem.focus();\n\n // Hide the active menu and update the aria attributes.\n itemUL.attr('aria-hidden', 'true');\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n // Trigger click handler.\n return this.handleClick(item, e);\n }\n\n case this.keys.left: {\n\n this.activeItem = this.moveToPrevious(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n\n this.activeItem = this.moveToNext(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n this.activeItem = this.moveUp(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n this.activeItem = this.moveDown(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n }\n\n return true;\n\n };\n\n\n /**\n * Move to the next menu level.\n * This will be either the next root-level menu or the child of a menu parent. If\n * at the root level and the active item is the last in the menu, this function will loop\n * to the first menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToNext\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToNext = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to next sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex < menuNum - 1) {\n // Not the last root menu.\n newItem = item.next();\n } else { // Wrap to first item.\n newItem = menuItems.first();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n }\n } else {\n // This is not the root level. If there is a child menu to be moved into, do that;\n // otherwise, move to the next root-level menu if there is one.\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update its aria attributes.\n this.openSubMenu(childMenu);\n } else {\n // At deepest level, move to the next root-level menu.\n\n var parentMenus = null;\n var rootItem = null;\n\n // Get list of all parent menus for item, up to the root level.\n parentMenus = item.parentsUntil('ul.tool-lp-menu').filter('ul').not('.tool-lp-menu');\n\n // Hide the current menu and update its aria attributes accordingly.\n parentMenus.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n parentMenus.find('li').removeClass('menu-focus');\n parentMenus.last().parent().removeClass('menu-focus');\n\n // The containing root for the menu.\n rootItem = parentMenus.last().parent();\n\n menuIndex = this.rootMenus.index(rootItem);\n\n // If this is not the last root menu item, move to the next one.\n if (menuIndex < this.rootMenus.length - 1) {\n newItem = rootItem.next();\n } else {\n // Loop.\n newItem = this.rootMenus.first();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to move to the previous menu level.\n * This will be either the previous root-level menu or the child of a menu parent. If\n * at the root level and the active item is the first in the menu, this function will loop\n * to the last menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToPrevious\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToPrevious = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to previous sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex > 0) {\n // Not the first root menu.\n newItem = item.prev();\n } else {\n // Wrap to last item.\n newItem = menuItems.last();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n\n }\n } else {\n // This is not the root level. If there is a parent menu that is not the\n // root menu, move up one level; otherwise, move to first item of the previous\n // root menu.\n\n var parentLI = itemUL.parent();\n var parentUL = parentLI.parent();\n\n // If this is a vertical menu or is not the first child menu\n // of the root-level menu, move up one level.\n if (!parentUL.is('.tool-lp-menu')) {\n\n newItem = itemUL.parent();\n\n // Hide the active menu and update aria-hidden.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus highlight from the item.\n item.removeClass('menu-focus');\n\n } else {\n // Move to previous root-level menu.\n\n // Hide the current menu and update the aria attributes accordingly.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n item.removeClass('menu-focus');\n parentLI.removeClass('menu-focus');\n\n menuIndex = this.rootMenus.index(parentLI);\n\n if (menuIndex > 0) {\n // Move to the previous root-level menu.\n newItem = parentLI.prev();\n } else {\n // Loop to last root-level menu.\n newItem = this.rootMenus.last();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n\n newItem = childMenu.children('li').first();\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to select the next item in a menu.\n * If the active item is the last in the menu, this function will loop to the\n * first menu item.\n *\n * @method moveDown\n * @param {Object} item is the active menu item\n * @param {String} startChr is the character to attempt to match against the beginning of the\n * menu item titles. If found, focus moves to the next menu item beginning with that character.\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveDown = function(item, startChr) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var newItemUL = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n\n if (item.attr('aria-haspopup') != 'true') {\n // No child menu to move to.\n return item;\n }\n\n // Move to the first item in the child menu.\n newItemUL = item.children('ul').first();\n newItem = newItemUL.children('li').first();\n\n // Make sure the child menu is visible.\n this.openSubMenu(newItemUL);\n\n return newItem;\n }\n\n // If $item is not the last item in its menu, move to the next item. If startChr is specified, move\n // to the next item with a title that begins with that character.\n if (startChr) {\n var match = false;\n var curNdx = menuIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (curNdx == menuNum) {\n curNdx = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (curNdx != menuIndex) {\n\n var titleChr = menuItems.eq(curNdx).html().charAt(0);\n\n if (titleChr.toLowerCase() == startChr) {\n match = true;\n break;\n }\n\n curNdx = curNdx + 1;\n\n if (curNdx == menuNum) {\n // Reached the end of the list, start again at the beginning.\n curNdx = 0;\n }\n }\n\n if (match === true) {\n newItem = menuItems.eq(curNdx);\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n } else {\n return item;\n }\n } else {\n if (menuIndex < menuNum - 1) {\n newItem = menuItems.eq(menuIndex + 1);\n } else {\n newItem = menuItems.first();\n }\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Function moveUp() is a member function to select the previous item in a menu.\n * If the active item is the first in the menu, this function will loop to the\n * last menu item.\n *\n * @method moveUp\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveUp = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n // Nothing to do.\n return item;\n }\n\n // If item is not the first item in its menu, move to the previous item.\n if (menuIndex > 0) {\n newItem = menuItems.eq(menuIndex - 1);\n } else {\n // Loop to top of menu.\n newItem = menuItems.last();\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Enhance the dom with aria attributes.\n * @method addAriaAttributes\n */\n Menubar.prototype.addAriaAttributes = function() {\n this.menuRoot.attr('role', 'menubar');\n this.rootMenus.attr('role', 'menuitem');\n this.rootMenus.attr('tabindex', '0');\n this.rootMenus.attr('aria-haspopup', 'true');\n this.subMenus.attr('role', 'menu');\n this.subMenus.attr('aria-hidden', 'true');\n this.subMenuItems.attr('role', 'menuitem');\n this.subMenuItems.attr('tabindex', '-1');\n\n // For CSS styling and effects.\n this.menuRoot.addClass('tool-lp-menu');\n this.allItems.addClass('tool-lp-menu-item');\n this.rootMenus.addClass('tool-lp-root-menu');\n this.subMenus.addClass('tool-lp-sub-menu');\n this.subMenuItems.addClass('dropdown-item');\n };\n\n return /** @alias module:tool_lp/menubar */ {\n /**\n * Create a menu bar object for every node matching the selector.\n *\n * The expected DOM structure is shown below.\n *
    <- This is the target of the selector parameter.\n *
  • <- This is repeated for each top level menu.\n * Text <- This is the text for the top level menu.\n *
      <- This is a list of the entries in this top level menu.\n *
    • <- This is repeated for each menu entry.\n * Choice 1 <- The anchor for the menu.\n *
    • \n *
    \n *
  • \n *
\n *\n * @method enhance\n * @param {String} selector - The selector for the outer most menu node.\n * @param {Function} handler - Javascript handler for when a menu item was chosen. If the\n * handler returns true (or does not exist), the\n * menu will look for an anchor with a link to follow.\n * For example, if the menu entry has a \"data-action\" attribute\n * and we want to call a javascript function when that entry is chosen,\n * we could pass a list of handlers like this:\n * { \"[data-action='add']\" : callAddFunction }\n */\n enhance: function(selector, handler) {\n $(selector).each(function(index, element) {\n var menuRoot = $(element);\n // Don't enhance the same menu twice.\n if (menuRoot.data(\"menubarEnhanced\") !== true) {\n (new Menubar(menuRoot, handler));\n menuRoot.data(\"menubarEnhanced\", true);\n }\n });\n },\n\n /**\n * Handy function to close all open menus anywhere on the page.\n * @method closeAll\n */\n closeAll: closeAllSubMenus\n };\n});\n"],"file":"menubar.min.js"} \ No newline at end of file +{"version":3,"file":"menubar.min.js","sources":["../src/menubar.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 * Aria menubar functionality. Enhances a simple nested list structure into a full aria widget.\n * Based on the open ajax example: http://oaa-accessibility.org/example/26/\n *\n * @module tool_lp/menubar\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /** @property {boolean} Flag to indicate if we have already registered a click event handler for the document. */\n var documentClickHandlerRegistered = false;\n\n /** @property {boolean} Flag to indicate whether there's an active, open menu. */\n var menuActive = false;\n\n /**\n * Close all open submenus anywhere in the page (there should only ever be one open at a time).\n *\n * @method closeAllSubMenus\n */\n var closeAllSubMenus = function() {\n $('.tool-lp-menu .tool-lp-sub-menu').attr('aria-hidden', 'true');\n // Every menu's closed at this point, so set the menu active flag to false.\n menuActive = false;\n };\n\n /**\n * Constructor\n *\n * @param {jQuery} menuRoot Jquery collection matching the root of the menu.\n * @param {Function[]} handlers called when a menu item is chosen.\n */\n var Menubar = function(menuRoot, handlers) {\n // Setup private class variables.\n this.menuRoot = menuRoot;\n this.handlers = handlers;\n this.rootMenus = this.menuRoot.children('li');\n this.subMenus = this.rootMenus.children('ul');\n this.subMenuItems = this.subMenus.children('li');\n this.allItems = this.rootMenus.add(this.subMenuItems);\n this.activeItem = null;\n this.isChildOpen = false;\n\n this.keys = {\n tab: 9,\n enter: 13,\n esc: 27,\n space: 32,\n left: 37,\n up: 38,\n right: 39,\n down: 40\n };\n\n this.addAriaAttributes();\n // Add the event listeners.\n this.addEventListeners();\n };\n\n /**\n * Open a submenu, first it closes all other sub-menus and sets the open direction.\n * @method openSubMenu\n * @param {Node} menu\n */\n Menubar.prototype.openSubMenu = function(menu) {\n this.setOpenDirection();\n closeAllSubMenus();\n menu.attr('aria-hidden', 'false');\n // Set menu active flag to true when a menu is opened.\n menuActive = true;\n };\n\n\n /**\n * Bind the event listeners to the DOM\n * @method addEventListeners\n */\n Menubar.prototype.addEventListeners = function() {\n var currentThis = this;\n\n // When clicking outside the menubar.\n if (documentClickHandlerRegistered === false) {\n $(document).click(function() {\n // Check if a menu is opened.\n if (menuActive) {\n // Close menu.\n closeAllSubMenus();\n }\n });\n // Set this flag to true so that we won't need to add a document click handler for the other Menubar instances.\n documentClickHandlerRegistered = true;\n }\n\n // Hovers.\n this.subMenuItems.mouseenter(function() {\n $(this).addClass('menu-hover');\n return true;\n });\n\n this.subMenuItems.mouseout(function() {\n $(this).removeClass('menu-hover');\n return true;\n });\n\n // Mouse listeners.\n this.allItems.click(function(e) {\n return currentThis.handleClick($(this), e);\n });\n\n // Key listeners.\n this.allItems.keydown(function(e) {\n return currentThis.handleKeyDown($(this), e);\n });\n\n this.allItems.focus(function() {\n return currentThis.handleFocus($(this));\n });\n\n this.allItems.blur(function() {\n return currentThis.handleBlur($(this));\n });\n };\n\n /**\n * Process click events for the top menus.\n *\n * @method handleClick\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return {boolean} Returns false\n */\n Menubar.prototype.handleClick = function(item, e) {\n e.stopPropagation();\n\n var parentUL = item.parent();\n\n if (parentUL.is('.tool-lp-menu')) {\n // Toggle the child menu open/closed.\n if (item.children('ul').first().attr('aria-hidden') == 'true') {\n this.openSubMenu(item.children('ul').first());\n } else {\n item.children('ul').first().attr('aria-hidden', 'true');\n }\n } else {\n // Remove hover and focus styling.\n this.allItems.removeClass('menu-hover menu-focus');\n\n // Clear the active item.\n this.activeItem = null;\n\n // Close the menu.\n this.menuRoot.find('ul').not('.root-level').attr('aria-hidden', 'true');\n // Follow any link, or call the click handlers.\n var anchor = item.find('a').first();\n var clickEvent = new $.Event('click');\n clickEvent.target = anchor;\n var eventHandled = false;\n if (this.handlers) {\n $.each(this.handlers, function(selector, handler) {\n if (eventHandled) {\n return;\n }\n if (item.find(selector).length > 0) {\n var callable = $.proxy(handler, anchor);\n // False means stop propogatting events.\n eventHandled = (callable(clickEvent) === false) || clickEvent.isDefaultPrevented();\n }\n });\n }\n // If we didn't find a handler, and the HREF is # that probably means that\n // we are handling it from somewhere else. Let's just do nothing in that case.\n if (!eventHandled && anchor.attr('href') !== '#') {\n window.location.href = anchor.attr('href');\n }\n }\n return false;\n };\n\n /*\n * Process focus events for the menu.\n *\n * @method handleFocus\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleFocus = function(item) {\n\n // If activeItem is null, we are getting focus from outside the menu. Store\n // the item that triggered the event.\n if (this.activeItem === null) {\n this.activeItem = item;\n } else if (item[0] != this.activeItem[0]) {\n return true;\n }\n\n // Get the set of jquery objects for all the parent items of the active item.\n var parentItems = this.activeItem.parentsUntil('ul.tool-lp-menu').filter('li');\n\n // Remove focus styling from all other menu items.\n this.allItems.removeClass('menu-focus');\n\n // Add focus styling to the active item.\n this.activeItem.addClass('menu-focus');\n\n // Add focus styling to all parent items.\n parentItems.addClass('menu-focus');\n\n // If the bChildOpen flag has been set, open the active item's child menu (if applicable).\n if (this.isChildOpen === true) {\n\n var itemUL = item.parent();\n\n // If the itemUL is a root-level menu and item is a parent item,\n // show the child menu.\n if (itemUL.is('.tool-lp-menu') && (item.attr('aria-haspopup') == 'true')) {\n this.openSubMenu(item.children('ul').first());\n }\n }\n\n return true;\n };\n\n /*\n * Process blur events for the menu.\n *\n * @method handleBlur\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleBlur = function(item) {\n item.removeClass('menu-focus');\n\n return true;\n };\n\n /*\n * Determine if the menu should open to the left, or the right,\n * based on the screen size and menu position.\n * @method setOpenDirection\n */\n Menubar.prototype.setOpenDirection = function() {\n var pos = this.menuRoot.offset();\n var isRTL = $(document.body).hasClass('dir-rtl');\n var openLeft = true;\n var heightmenuRoot = this.rootMenus.outerHeight();\n var widthmenuRoot = this.rootMenus.outerWidth();\n // Sometimes the menuMinWidth is not enough to figure out if menu exceeds the window width.\n // So we have to calculate the real menu width.\n var subMenuContainer = this.rootMenus.find('ul.tool-lp-sub-menu');\n\n // Reset margins.\n subMenuContainer.css('margin-right', '');\n subMenuContainer.css('margin-left', '');\n subMenuContainer.css('margin-top', '');\n\n subMenuContainer.attr('aria-hidden', false);\n var menuRealWidth = subMenuContainer.outerWidth(),\n menuRealHeight = subMenuContainer.outerHeight();\n\n var margintop = null,\n marginright = null,\n marginleft = null;\n var top = pos.top - $(window).scrollTop();\n // Top is the same for RTL and LTR.\n if (top + menuRealHeight > $(window).height()) {\n margintop = menuRealHeight + heightmenuRoot;\n subMenuContainer.css('margin-top', '-' + margintop + 'px');\n }\n\n if (isRTL) {\n if (pos.left - menuRealWidth < 0) {\n marginright = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-right', '-' + marginright + 'px');\n }\n } else {\n if (pos.left + menuRealWidth > $(window).width()) {\n marginleft = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-left', '-' + marginleft + 'px');\n }\n }\n\n if (openLeft) {\n this.menuRoot.addClass('tool-lp-menu-open-left');\n } else {\n this.menuRoot.removeClass('tool-lp-menu-open-left');\n }\n\n };\n\n /*\n * Process keyDown events for the menu.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return boolean Returns false if consuming the event\n */\n Menubar.prototype.handleKeyDown = function(item, e) {\n\n if (e.altKey || e.ctrlKey) {\n // Modifier key pressed: Do not process.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n\n // Hide all menu items and update their aria attributes.\n this.menuRoot.find('ul').attr('aria-hidden', 'true');\n\n // Remove focus styling from all menu items.\n this.allItems.removeClass('menu-focus');\n\n this.activeItem = null;\n\n this.isChildOpen = false;\n\n break;\n }\n case this.keys.esc: {\n var itemUL = item.parent();\n\n if (itemUL.is('.tool-lp-menu')) {\n // Hide the child menu and update the aria attributes.\n item.children('ul').first().attr('aria-hidden', 'true');\n } else {\n\n // Move up one level.\n this.activeItem = itemUL.parent();\n\n // Reset the isChildOpen flag.\n this.isChildOpen = false;\n\n // Set focus on the new item.\n this.activeItem.focus();\n\n // Hide the active menu and update the aria attributes.\n itemUL.attr('aria-hidden', 'true');\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n // Trigger click handler.\n return this.handleClick(item, e);\n }\n\n case this.keys.left: {\n\n this.activeItem = this.moveToPrevious(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n\n this.activeItem = this.moveToNext(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n this.activeItem = this.moveUp(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n this.activeItem = this.moveDown(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n }\n\n return true;\n\n };\n\n\n /**\n * Move to the next menu level.\n * This will be either the next root-level menu or the child of a menu parent. If\n * at the root level and the active item is the last in the menu, this function will loop\n * to the first menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToNext\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToNext = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to next sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex < menuNum - 1) {\n // Not the last root menu.\n newItem = item.next();\n } else { // Wrap to first item.\n newItem = menuItems.first();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n }\n } else {\n // This is not the root level. If there is a child menu to be moved into, do that;\n // otherwise, move to the next root-level menu if there is one.\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update its aria attributes.\n this.openSubMenu(childMenu);\n } else {\n // At deepest level, move to the next root-level menu.\n\n var parentMenus = null;\n var rootItem = null;\n\n // Get list of all parent menus for item, up to the root level.\n parentMenus = item.parentsUntil('ul.tool-lp-menu').filter('ul').not('.tool-lp-menu');\n\n // Hide the current menu and update its aria attributes accordingly.\n parentMenus.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n parentMenus.find('li').removeClass('menu-focus');\n parentMenus.last().parent().removeClass('menu-focus');\n\n // The containing root for the menu.\n rootItem = parentMenus.last().parent();\n\n menuIndex = this.rootMenus.index(rootItem);\n\n // If this is not the last root menu item, move to the next one.\n if (menuIndex < this.rootMenus.length - 1) {\n newItem = rootItem.next();\n } else {\n // Loop.\n newItem = this.rootMenus.first();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to move to the previous menu level.\n * This will be either the previous root-level menu or the child of a menu parent. If\n * at the root level and the active item is the first in the menu, this function will loop\n * to the last menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToPrevious\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToPrevious = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to previous sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex > 0) {\n // Not the first root menu.\n newItem = item.prev();\n } else {\n // Wrap to last item.\n newItem = menuItems.last();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n\n }\n } else {\n // This is not the root level. If there is a parent menu that is not the\n // root menu, move up one level; otherwise, move to first item of the previous\n // root menu.\n\n var parentLI = itemUL.parent();\n var parentUL = parentLI.parent();\n\n // If this is a vertical menu or is not the first child menu\n // of the root-level menu, move up one level.\n if (!parentUL.is('.tool-lp-menu')) {\n\n newItem = itemUL.parent();\n\n // Hide the active menu and update aria-hidden.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus highlight from the item.\n item.removeClass('menu-focus');\n\n } else {\n // Move to previous root-level menu.\n\n // Hide the current menu and update the aria attributes accordingly.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n item.removeClass('menu-focus');\n parentLI.removeClass('menu-focus');\n\n menuIndex = this.rootMenus.index(parentLI);\n\n if (menuIndex > 0) {\n // Move to the previous root-level menu.\n newItem = parentLI.prev();\n } else {\n // Loop to last root-level menu.\n newItem = this.rootMenus.last();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n\n newItem = childMenu.children('li').first();\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to select the next item in a menu.\n * If the active item is the last in the menu, this function will loop to the\n * first menu item.\n *\n * @method moveDown\n * @param {Object} item is the active menu item\n * @param {String} startChr is the character to attempt to match against the beginning of the\n * menu item titles. If found, focus moves to the next menu item beginning with that character.\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveDown = function(item, startChr) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var newItemUL = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n\n if (item.attr('aria-haspopup') != 'true') {\n // No child menu to move to.\n return item;\n }\n\n // Move to the first item in the child menu.\n newItemUL = item.children('ul').first();\n newItem = newItemUL.children('li').first();\n\n // Make sure the child menu is visible.\n this.openSubMenu(newItemUL);\n\n return newItem;\n }\n\n // If $item is not the last item in its menu, move to the next item. If startChr is specified, move\n // to the next item with a title that begins with that character.\n if (startChr) {\n var match = false;\n var curNdx = menuIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (curNdx == menuNum) {\n curNdx = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (curNdx != menuIndex) {\n\n var titleChr = menuItems.eq(curNdx).html().charAt(0);\n\n if (titleChr.toLowerCase() == startChr) {\n match = true;\n break;\n }\n\n curNdx = curNdx + 1;\n\n if (curNdx == menuNum) {\n // Reached the end of the list, start again at the beginning.\n curNdx = 0;\n }\n }\n\n if (match === true) {\n newItem = menuItems.eq(curNdx);\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n } else {\n return item;\n }\n } else {\n if (menuIndex < menuNum - 1) {\n newItem = menuItems.eq(menuIndex + 1);\n } else {\n newItem = menuItems.first();\n }\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Function moveUp() is a member function to select the previous item in a menu.\n * If the active item is the first in the menu, this function will loop to the\n * last menu item.\n *\n * @method moveUp\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveUp = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n // Nothing to do.\n return item;\n }\n\n // If item is not the first item in its menu, move to the previous item.\n if (menuIndex > 0) {\n newItem = menuItems.eq(menuIndex - 1);\n } else {\n // Loop to top of menu.\n newItem = menuItems.last();\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Enhance the dom with aria attributes.\n * @method addAriaAttributes\n */\n Menubar.prototype.addAriaAttributes = function() {\n this.menuRoot.attr('role', 'menubar');\n this.rootMenus.attr('role', 'menuitem');\n this.rootMenus.attr('tabindex', '0');\n this.rootMenus.attr('aria-haspopup', 'true');\n this.subMenus.attr('role', 'menu');\n this.subMenus.attr('aria-hidden', 'true');\n this.subMenuItems.attr('role', 'menuitem');\n this.subMenuItems.attr('tabindex', '-1');\n\n // For CSS styling and effects.\n this.menuRoot.addClass('tool-lp-menu');\n this.allItems.addClass('tool-lp-menu-item');\n this.rootMenus.addClass('tool-lp-root-menu');\n this.subMenus.addClass('tool-lp-sub-menu');\n this.subMenuItems.addClass('dropdown-item');\n };\n\n return /** @alias module:tool_lp/menubar */ {\n /**\n * Create a menu bar object for every node matching the selector.\n *\n * The expected DOM structure is shown below.\n *
    <- This is the target of the selector parameter.\n *
  • <- This is repeated for each top level menu.\n * Text <- This is the text for the top level menu.\n *
      <- This is a list of the entries in this top level menu.\n *
    • <- This is repeated for each menu entry.\n * Choice 1 <- The anchor for the menu.\n *
    • \n *
    \n *
  • \n *
\n *\n * @method enhance\n * @param {String} selector - The selector for the outer most menu node.\n * @param {Function} handler - Javascript handler for when a menu item was chosen. If the\n * handler returns true (or does not exist), the\n * menu will look for an anchor with a link to follow.\n * For example, if the menu entry has a \"data-action\" attribute\n * and we want to call a javascript function when that entry is chosen,\n * we could pass a list of handlers like this:\n * { \"[data-action='add']\" : callAddFunction }\n */\n enhance: function(selector, handler) {\n $(selector).each(function(index, element) {\n var menuRoot = $(element);\n // Don't enhance the same menu twice.\n if (menuRoot.data(\"menubarEnhanced\") !== true) {\n (new Menubar(menuRoot, handler));\n menuRoot.data(\"menubarEnhanced\", true);\n }\n });\n },\n\n /**\n * Handy function to close all open menus anywhere on the page.\n * @method closeAll\n */\n closeAll: closeAllSubMenus\n };\n});\n"],"names":["define","$","documentClickHandlerRegistered","menuActive","closeAllSubMenus","attr","Menubar","menuRoot","handlers","rootMenus","this","children","subMenus","subMenuItems","allItems","add","activeItem","isChildOpen","keys","tab","enter","esc","space","left","up","right","down","addAriaAttributes","addEventListeners","prototype","openSubMenu","menu","setOpenDirection","currentThis","document","click","mouseenter","addClass","mouseout","removeClass","e","handleClick","keydown","handleKeyDown","focus","handleFocus","blur","handleBlur","item","stopPropagation","parent","is","first","find","not","anchor","clickEvent","Event","target","eventHandled","each","selector","handler","length","callable","proxy","isDefaultPrevented","window","location","href","parentItems","parentsUntil","filter","pos","offset","isRTL","body","hasClass","heightmenuRoot","outerHeight","widthmenuRoot","outerWidth","subMenuContainer","css","menuRealWidth","menuRealHeight","margintop","marginright","marginleft","top","scrollTop","height","width","altKey","ctrlKey","keyCode","itemUL","moveToPrevious","moveToNext","moveUp","moveDown","menuItems","menuNum","menuIndex","index","newItem","childMenu","next","parentMenus","rootItem","last","prev","parentLI","startChr","newItemUL","match","curNdx","eq","html","charAt","toLowerCase","enhance","element","data","closeAll"],"mappings":";;;;;;;;AAuBAA,yBAAO,CAAC,WAAW,SAASC,OAGpBC,gCAAiC,EAGjCC,YAAa,EAObC,iBAAmB,WACnBH,EAAE,mCAAmCI,KAAK,cAAe,QAEzDF,YAAa,GASbG,QAAU,SAASC,SAAUC,eAExBD,SAAWA,cACXC,SAAWA,cACXC,UAAYC,KAAKH,SAASI,SAAS,WACnCC,SAAWF,KAAKD,UAAUE,SAAS,WACnCE,aAAeH,KAAKE,SAASD,SAAS,WACtCG,SAAWJ,KAAKD,UAAUM,IAAIL,KAAKG,mBACnCG,WAAa,UACbC,aAAc,OAEdC,KAAO,CACRC,IAAQ,EACRC,MAAQ,GACRC,IAAQ,GACRC,MAAQ,GACRC,KA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,OAAOC,OAAO,GAErCC,eAAiBP,SAAU,CACpCE,OAAQ,SAIZC,QAAkB,IAEJd,UAEVc,OAAS,UAIH,IAAVD,OACAV,QAAUJ,UAAUgB,GAAGD,QAGvBpE,KAAKT,YAAY,cAEVkE,SAEAzD,YAIPyD,QADAF,UAAYD,QAAU,EACZD,UAAUgB,GAAGd,UAAY,GAEzBF,UAAUjD,QAK5BJ,KAAKT,YAAY,cAEVkE,SAYXnG,QAAQuB,UAAUsE,OAAS,SAASnD,UAE5BgD,OAAShD,KAAKE,SAEdmD,UAAYL,OAAOrF,SAAS,MAAM2C,IAAI,cAEtCiD,UAAYF,UAAUG,MAAMxD,MAC5ByD,QAAU,YAEVT,OAAO7C,GAAG,iBAGHH,MAKPyD,QADAF,UAAY,EACFF,UAAUgB,GAAGd,UAAY,GAGzBF,UAAUS,OAIxB9D,KAAKT,YAAY,cAEVkE,UAOXnG,QAAQuB,UAAUF,kBAAoB,gBAC7BpB,SAASF,KAAK,OAAQ,gBACtBI,UAAUJ,KAAK,OAAQ,iBACvBI,UAAUJ,KAAK,WAAY,UAC3BI,UAAUJ,KAAK,gBAAiB,aAChCO,SAASP,KAAK,OAAQ,aACtBO,SAASP,KAAK,cAAe,aAC7BQ,aAAaR,KAAK,OAAQ,iBAC1BQ,aAAaR,KAAK,WAAY,WAG9BE,SAAS8B,SAAS,qBAClBvB,SAASuB,SAAS,0BAClB5B,UAAU4B,SAAS,0BACnBzB,SAASyB,SAAS,yBAClBxB,aAAawB,SAAS,kBAGa,CA0BxCoF,QAAS,SAAS5D,SAAUC,SACxB7D,EAAE4D,UAAUD,MAAK,SAAS4C,MAAOkB,aACzBnH,SAAWN,EAAEyH,UAEwB,IAArCnH,SAASoH,KAAK,yBACTrH,QAAQC,SAAUuD,SACvBvD,SAASoH,KAAK,mBAAmB,QAS7CC,SAAUxH"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/module_navigation.min.js b/admin/tool/lp/amd/build/module_navigation.min.js index 917da94c8a0..e88d34c6c6f 100644 --- a/admin/tool/lp/amd/build/module_navigation.min.js +++ b/admin/tool/lp/amd/build/module_navigation.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/module_navigation",["jquery"],function(a){var b=function(b,c,d,e){this._baseUrl=c;this._moduleId=e;this._courseId=d;a(b).on("change",this._moduleChanged.bind(this))};b.prototype._moduleChanged=function(b){var c=a(b.target).val(),d="?mod="+c+"&courseid="+this._courseId;document.location=this._baseUrl+d};b.prototype._courseId=null;b.prototype._moduleId=null;b.prototype._baseUrl=null;return b}); -//# sourceMappingURL=module_navigation.min.js.map +/** + * Module to navigation between users in a course. + * + * @module tool_lp/module_navigation + * @copyright 2019 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/module_navigation",["jquery"],(function($){var ModuleNavigation=function(moduleSelector,baseUrl,courseId,moduleId){this._baseUrl=baseUrl,this._moduleId=moduleId,this._courseId=courseId,$(moduleSelector).on("change",this._moduleChanged.bind(this))};return ModuleNavigation.prototype._moduleChanged=function(e){var queryStr="?mod="+$(e.target).val()+"&courseid="+this._courseId;document.location=this._baseUrl+queryStr},ModuleNavigation.prototype._courseId=null,ModuleNavigation.prototype._moduleId=null,ModuleNavigation.prototype._baseUrl=null,ModuleNavigation})); + +//# sourceMappingURL=module_navigation.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/module_navigation.min.js.map b/admin/tool/lp/amd/build/module_navigation.min.js.map index 6b1405383eb..adddb1a552d 100644 --- a/admin/tool/lp/amd/build/module_navigation.min.js.map +++ b/admin/tool/lp/amd/build/module_navigation.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/module_navigation.js"],"names":["define","$","ModuleNavigation","moduleSelector","baseUrl","courseId","moduleId","_baseUrl","_moduleId","_courseId","on","_moduleChanged","bind","prototype","e","newModuleId","target","val","queryStr","document","location"],"mappings":"AAuBAA,OAAM,6BAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAW3B,GAAIC,CAAAA,CAAgB,CAAG,SAASC,CAAT,CAAyBC,CAAzB,CAAkCC,CAAlC,CAA4CC,CAA5C,CAAsD,CACzE,KAAKC,QAAL,CAAgBH,CAAhB,CACA,KAAKI,SAAL,CAAiBF,CAAjB,CACA,KAAKG,SAAL,CAAiBJ,CAAjB,CAEAJ,CAAC,CAACE,CAAD,CAAD,CAAkBO,EAAlB,CAAqB,QAArB,CAA+B,KAAKC,cAAL,CAAoBC,IAApB,CAAyB,IAAzB,CAA/B,CACH,CAND,CAcAV,CAAgB,CAACW,SAAjB,CAA2BF,cAA3B,CAA4C,SAASG,CAAT,CAAY,IAChDC,CAAAA,CAAW,CAAGd,CAAC,CAACa,CAAC,CAACE,MAAH,CAAD,CAAYC,GAAZ,EADkC,CAEhDC,CAAQ,CAAG,QAAUH,CAAV,CAAwB,YAAxB,CAAuC,KAAKN,SAFP,CAGpDU,QAAQ,CAACC,QAAT,CAAoB,KAAKb,QAAL,CAAgBW,CACvC,CAJD,CAOAhB,CAAgB,CAACW,SAAjB,CAA2BJ,SAA3B,CAAuC,IAAvC,CAEAP,CAAgB,CAACW,SAAjB,CAA2BL,SAA3B,CAAuC,IAAvC,CAEAN,CAAgB,CAACW,SAAjB,CAA2BN,QAA3B,CAAsC,IAAtC,CAEA,MAAOL,CAAAA,CACV,CAvCK,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 * Module to navigation between users in a course.\n *\n * @module tool_lp/module_navigation\n * @copyright 2019 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * ModuleNavigation\n *\n * @class tool_lp/module_navigation\n * @param {String} moduleSelector The selector of the module element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} courseId The course id\n * @param {Number} moduleId The activity module (filter)\n */\n var ModuleNavigation = function(moduleSelector, baseUrl, courseId, moduleId) {\n this._baseUrl = baseUrl;\n this._moduleId = moduleId;\n this._courseId = courseId;\n\n $(moduleSelector).on('change', this._moduleChanged.bind(this));\n };\n\n /**\n * The module was changed in the select list.\n *\n * @method _moduleChanged\n * @param {Event} e the event\n */\n ModuleNavigation.prototype._moduleChanged = function(e) {\n var newModuleId = $(e.target).val();\n var queryStr = '?mod=' + newModuleId + '&courseid=' + this._courseId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the course. */\n ModuleNavigation.prototype._courseId = null;\n /** @property {Number} The id of the module. */\n ModuleNavigation.prototype._moduleId = null;\n /** @property {String} Plugin base url. */\n ModuleNavigation.prototype._baseUrl = null;\n\n return ModuleNavigation;\n});\n"],"file":"module_navigation.min.js"} \ No newline at end of file +{"version":3,"file":"module_navigation.min.js","sources":["../src/module_navigation.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 to navigation between users in a course.\n *\n * @module tool_lp/module_navigation\n * @copyright 2019 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * ModuleNavigation\n *\n * @class tool_lp/module_navigation\n * @param {String} moduleSelector The selector of the module element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} courseId The course id\n * @param {Number} moduleId The activity module (filter)\n */\n var ModuleNavigation = function(moduleSelector, baseUrl, courseId, moduleId) {\n this._baseUrl = baseUrl;\n this._moduleId = moduleId;\n this._courseId = courseId;\n\n $(moduleSelector).on('change', this._moduleChanged.bind(this));\n };\n\n /**\n * The module was changed in the select list.\n *\n * @method _moduleChanged\n * @param {Event} e the event\n */\n ModuleNavigation.prototype._moduleChanged = function(e) {\n var newModuleId = $(e.target).val();\n var queryStr = '?mod=' + newModuleId + '&courseid=' + this._courseId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the course. */\n ModuleNavigation.prototype._courseId = null;\n /** @property {Number} The id of the module. */\n ModuleNavigation.prototype._moduleId = null;\n /** @property {String} Plugin base url. */\n ModuleNavigation.prototype._baseUrl = null;\n\n return ModuleNavigation;\n});\n"],"names":["define","$","ModuleNavigation","moduleSelector","baseUrl","courseId","moduleId","_baseUrl","_moduleId","_courseId","on","this","_moduleChanged","bind","prototype","e","queryStr","target","val","document","location"],"mappings":";;;;;;;AAuBAA,mCAAO,CAAC,WAAW,SAASC,OAWpBC,iBAAmB,SAASC,eAAgBC,QAASC,SAAUC,eAC1DC,SAAWH,aACXI,UAAYF,cACZG,UAAYJ,SAEjBJ,EAAEE,gBAAgBO,GAAG,SAAUC,KAAKC,eAAeC,KAAKF,eAS5DT,iBAAiBY,UAAUF,eAAiB,SAASG,OAE7CC,SAAW,QADGf,EAAEc,EAAEE,QAAQC,MACS,aAAeP,KAAKF,UAC3DU,SAASC,SAAWT,KAAKJ,SAAWS,UAIxCd,iBAAiBY,UAAUL,UAAY,KAEvCP,iBAAiBY,UAAUN,UAAY,KAEvCN,iBAAiBY,UAAUP,SAAW,KAE/BL"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/parentcompetency_form.min.js b/admin/tool/lp/amd/build/parentcompetency_form.min.js index 87e8535bdcf..916755eeab3 100644 --- a/admin/tool/lp/amd/build/parentcompetency_form.min.js +++ b/admin/tool/lp/amd/build/parentcompetency_form.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/parentcompetency_form",["jquery","core/ajax","core/str","tool_lp/competencypicker","core/templates","core/notification"],function(a,b,c,d,e,f){var g=function(a,b,c,d,e){this.buttonSelector=a;this.inputHiddenSelector=b;this.staticElementSelector=c;this.frameworkId=d;this.pageContextId=e;this.registerEvents()};g.prototype.buttonSelector=null;g.prototype.inputHiddenSelector=null;g.prototype.staticElementSelector=null;g.prototype.frameworkId=null;g.prototype.pageContextId=null;g.prototype.setParent=function(d){var e=this;if(0!==d.competencyId){b.call([{methodname:"core_competency_read_competency",args:{id:d.competencyId}}])[0].done(function(b){a(e.staticElementSelector).html(b.shortname);a(e.inputHiddenSelector).val(b.id)}).fail(f.exception)}else{c.get_string("competencyframeworkroot","tool_lp").then(function(b){a(e.staticElementSelector).html(b);a(e.inputHiddenSelector).val(d.competencyId)}).fail(f.exception)}};g.prototype.registerEvents=function(){var b=this;a(b.buttonSelector).on("click",function(a){a.preventDefault();var c=new d(b.pageContextId,b.frameworkId,"self",!1);c._render=function(){var a=this;return a._preRender().then(function(){var b={competencies:a._competencies,framework:a._getFramework(a._frameworkId),frameworks:a._frameworks,search:a._searchText,singleFramework:a._singleFramework};return e.render("tool_lp/competency_picker_competencyform",b)})};c.on("save",function(a,c){b.setParent(c)});c.display()})};return{init:function init(a,b,c,d,e){new g(a,b,c,d,e)}}}); -//# sourceMappingURL=parentcompetency_form.min.js.map +/** + * Handle selecting parent competency in competency form. + * + * @module tool_lp/parentcompetency_form + * @copyright 2015 Issam Taboubi + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/parentcompetency_form",["jquery","core/ajax","core/str","tool_lp/competencypicker","core/templates","core/notification"],(function($,ajax,Str,Picker,Templates,Notification){var ParentCompetencyForm=function(buttonSelector,inputHiddenSelector,staticElementSelector,frameworkId,pageContextId){this.buttonSelector=buttonSelector,this.inputHiddenSelector=inputHiddenSelector,this.staticElementSelector=staticElementSelector,this.frameworkId=frameworkId,this.pageContextId=pageContextId,this.registerEvents()};return ParentCompetencyForm.prototype.buttonSelector=null,ParentCompetencyForm.prototype.inputHiddenSelector=null,ParentCompetencyForm.prototype.staticElementSelector=null,ParentCompetencyForm.prototype.frameworkId=null,ParentCompetencyForm.prototype.pageContextId=null,ParentCompetencyForm.prototype.setParent=function(data){var self=this;0!==data.competencyId?ajax.call([{methodname:"core_competency_read_competency",args:{id:data.competencyId}}])[0].done((function(competency){$(self.staticElementSelector).html(competency.shortname),$(self.inputHiddenSelector).val(competency.id)})).fail(Notification.exception):Str.get_string("competencyframeworkroot","tool_lp").then((function(rootframework){$(self.staticElementSelector).html(rootframework),$(self.inputHiddenSelector).val(data.competencyId)})).fail(Notification.exception)},ParentCompetencyForm.prototype.registerEvents=function(){var self=this;$(self.buttonSelector).on("click",(function(e){e.preventDefault();var picker=new Picker(self.pageContextId,self.frameworkId,"self",!1);picker._render=function(){var self=this;return self._preRender().then((function(){var context={competencies:self._competencies,framework:self._getFramework(self._frameworkId),frameworks:self._frameworks,search:self._searchText,singleFramework:self._singleFramework};return Templates.render("tool_lp/competency_picker_competencyform",context)}))},picker.on("save",(function(e,data){self.setParent(data)})),picker.display()}))},{init:function(buttonSelector,inputSelector,staticElementSelector,frameworkId,pageContextId){new ParentCompetencyForm(buttonSelector,inputSelector,staticElementSelector,frameworkId,pageContextId)}}})); + +//# sourceMappingURL=parentcompetency_form.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/parentcompetency_form.min.js.map b/admin/tool/lp/amd/build/parentcompetency_form.min.js.map index df3600bea00..0b2c3238c2b 100644 --- a/admin/tool/lp/amd/build/parentcompetency_form.min.js.map +++ b/admin/tool/lp/amd/build/parentcompetency_form.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/parentcompetency_form.js"],"names":["define","$","ajax","Str","Picker","Templates","Notification","ParentCompetencyForm","buttonSelector","inputHiddenSelector","staticElementSelector","frameworkId","pageContextId","registerEvents","prototype","setParent","data","self","competencyId","call","methodname","args","id","done","competency","html","shortname","val","fail","exception","get_string","then","rootframework","on","e","preventDefault","picker","_render","_preRender","context","competencies","_competencies","framework","_getFramework","_frameworkId","frameworks","_frameworks","search","_searchText","singleFramework","_singleFramework","render","display","init","inputSelector"],"mappings":"AAsBAA,OAAM,iCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,UAAxB,CAAoC,0BAApC,CAAgE,gBAAhE,CAAkF,mBAAlF,CAAD,CACF,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAuBC,CAAvB,CAA+BC,CAA/B,CAA0CC,CAA1C,CAAwD,CAUxD,GAAIC,CAAAA,CAAoB,CAAG,SAASC,CAAT,CACSC,CADT,CAESC,CAFT,CAGSC,CAHT,CAISC,CAJT,CAIwB,CAC/C,KAAKJ,cAAL,CAAsBA,CAAtB,CACA,KAAKC,mBAAL,CAA2BA,CAA3B,CACA,KAAKC,qBAAL,CAA6BA,CAA7B,CACA,KAAKC,WAAL,CAAmBA,CAAnB,CACA,KAAKC,aAAL,CAAqBA,CAArB,CAGA,KAAKC,cAAL,EACH,CAbD,CAgBAN,CAAoB,CAACO,SAArB,CAA+BN,cAA/B,CAAgD,IAAhD,CAEAD,CAAoB,CAACO,SAArB,CAA+BL,mBAA/B,CAAqD,IAArD,CAEAF,CAAoB,CAACO,SAArB,CAA+BJ,qBAA/B,CAAuD,IAAvD,CAEAH,CAAoB,CAACO,SAArB,CAA+BH,WAA/B,CAA6C,IAA7C,CAEAJ,CAAoB,CAACO,SAArB,CAA+BF,aAA/B,CAA+C,IAA/C,CAQAL,CAAoB,CAACO,SAArB,CAA+BC,SAA/B,CAA2C,SAASC,CAAT,CAAe,CACtD,GAAIC,CAAAA,CAAI,CAAG,IAAX,CAEA,GAA0B,CAAtB,GAAAD,CAAI,CAACE,YAAT,CAA6B,CACzBhB,CAAI,C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L,GAAkBP,IAAlB,CAAuB,UAAW,CACrC,GAAIQ,CAAAA,CAAO,CAAG,CACVC,YAAY,CAAEvB,CAAI,CAACwB,aADT,CAEVC,SAAS,CAAEzB,CAAI,CAAC0B,aAAL,CAAmB1B,CAAI,CAAC2B,YAAxB,CAFD,CAGVC,UAAU,CAAE5B,CAAI,CAAC6B,WAHP,CAIVC,MAAM,CAAE9B,CAAI,CAAC+B,WAJH,CAKVC,eAAe,CAAEhC,CAAI,CAACiC,gBALZ,CAAd,CAQA,MAAO7C,CAAAA,CAAS,CAAC8C,MAAV,CAAiB,0CAAjB,CAA6DZ,CAA7D,CACV,CAVM,CAWV,CAbD,CAgBAH,CAAM,CAACH,EAAP,CAAU,MAAV,CAAkB,SAASC,CAAT,CAAYlB,CAAZ,CAAkB,CAChCC,CAAI,CAACF,SAAL,CAAeC,CAAf,CACH,CAFD,EAIAoB,CAAM,CAACgB,OAAP,EACH,CA3BD,CA4BH,CAhCD,CAkCA,MAAO,CAWHC,IAAI,CAAE,cAAS7C,CAAT,CACU8C,CADV,CAEU5C,CAFV,CAGUC,CAHV,CAIUC,CAJV,CAIyB,CAE3B,GAAIL,CAAAA,CAAJ,CAAyBC,CAAzB,CACwB8C,CADxB,CAEwB5C,CAFxB,CAGwBC,CAHxB,CAIwBC,CAJxB,CAKH,CAtBE,CAwBV,CAhIK,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 * Handle selecting parent competency in competency form.\n *\n * @module tool_lp/parentcompetency_form\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/templates', 'core/notification'],\n function($, ajax, Str, Picker, Templates, Notification) {\n\n /**\n * Parent Competency Form object.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputHiddenSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n */\n var ParentCompetencyForm = function(buttonSelector,\n inputHiddenSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n this.buttonSelector = buttonSelector;\n this.inputHiddenSelector = inputHiddenSelector;\n this.staticElementSelector = staticElementSelector;\n this.frameworkId = frameworkId;\n this.pageContextId = pageContextId;\n\n // Register the events.\n this.registerEvents();\n };\n\n /** @var {String} The parent competency button selector. */\n ParentCompetencyForm.prototype.buttonSelector = null;\n /** @var {String} The hidden input field selector. */\n ParentCompetencyForm.prototype.inputHiddenSelector = null;\n /** @var {String} The static element displaying the parent competency. */\n ParentCompetencyForm.prototype.staticElementSelector = null;\n /** @var {Number} The competency framework ID. */\n ParentCompetencyForm.prototype.frameworkId = null;\n /** @var {Number} The page context ID. */\n ParentCompetencyForm.prototype.pageContextId = null;\n\n /**\n * Set the parent competency in the competency form.\n *\n * @param {Object} data Data containing selected competency.\n * @method setParent\n */\n ParentCompetencyForm.prototype.setParent = function(data) {\n var self = this;\n\n if (data.competencyId !== 0) {\n ajax.call([\n {methodname: 'core_competency_read_competency', args: {\n id: data.competencyId\n }}\n ])[0].done(function(competency) {\n $(self.staticElementSelector).html(competency.shortname);\n $(self.inputHiddenSelector).val(competency.id);\n }).fail(Notification.exception);\n } else {\n // Root of competency framework selected.\n Str.get_string('competencyframeworkroot', 'tool_lp').then(function(rootframework) {\n $(self.staticElementSelector).html(rootframework);\n $(self.inputHiddenSelector).val(data.competencyId);\n return;\n }).fail(Notification.exception);\n }\n };\n\n /**\n * Register the events of parent competency button click.\n *\n * @method registerEvents\n */\n ParentCompetencyForm.prototype.registerEvents = function() {\n var self = this;\n\n // Event on edit parent button.\n $(self.buttonSelector).on('click', function(e) {\n e.preventDefault();\n\n var picker = new Picker(self.pageContextId, self.frameworkId, 'self', false);\n\n // Override the render method to make framework selectable.\n picker._render = function() {\n var self = this;\n return self._preRender().then(function() {\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker_competencyform', context);\n });\n };\n\n // On selected competency.\n picker.on('save', function(e, data) {\n self.setParent(data);\n });\n\n picker.display();\n });\n };\n\n return {\n\n /**\n * Main initialisation.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n * @method init\n */\n init: function(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n // Create instance.\n new ParentCompetencyForm(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId);\n }\n };\n});\n"],"file":"parentcompetency_form.min.js"} \ No newline at end of file +{"version":3,"file":"parentcompetency_form.min.js","sources":["../src/parentcompetency_form.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 * Handle selecting parent competency in competency form.\n *\n * @module tool_lp/parentcompetency_form\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/templates', 'core/notification'],\n function($, ajax, Str, Picker, Templates, Notification) {\n\n /**\n * Parent Competency Form object.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputHiddenSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n */\n var ParentCompetencyForm = function(buttonSelector,\n inputHiddenSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n this.buttonSelector = buttonSelector;\n this.inputHiddenSelector = inputHiddenSelector;\n this.staticElementSelector = staticElementSelector;\n this.frameworkId = frameworkId;\n this.pageContextId = pageContextId;\n\n // Register the events.\n this.registerEvents();\n };\n\n /** @var {String} The parent competency button selector. */\n ParentCompetencyForm.prototype.buttonSelector = null;\n /** @var {String} The hidden input field selector. */\n ParentCompetencyForm.prototype.inputHiddenSelector = null;\n /** @var {String} The static element displaying the parent competency. */\n ParentCompetencyForm.prototype.staticElementSelector = null;\n /** @var {Number} The competency framework ID. */\n ParentCompetencyForm.prototype.frameworkId = null;\n /** @var {Number} The page context ID. */\n ParentCompetencyForm.prototype.pageContextId = null;\n\n /**\n * Set the parent competency in the competency form.\n *\n * @param {Object} data Data containing selected competency.\n * @method setParent\n */\n ParentCompetencyForm.prototype.setParent = function(data) {\n var self = this;\n\n if (data.competencyId !== 0) {\n ajax.call([\n {methodname: 'core_competency_read_competency', args: {\n id: data.competencyId\n }}\n ])[0].done(function(competency) {\n $(self.staticElementSelector).html(competency.shortname);\n $(self.inputHiddenSelector).val(competency.id);\n }).fail(Notification.exception);\n } else {\n // Root of competency framework selected.\n Str.get_string('competencyframeworkroot', 'tool_lp').then(function(rootframework) {\n $(self.staticElementSelector).html(rootframework);\n $(self.inputHiddenSelector).val(data.competencyId);\n return;\n }).fail(Notification.exception);\n }\n };\n\n /**\n * Register the events of parent competency button click.\n *\n * @method registerEvents\n */\n ParentCompetencyForm.prototype.registerEvents = function() {\n var self = this;\n\n // Event on edit parent button.\n $(self.buttonSelector).on('click', function(e) {\n e.preventDefault();\n\n var picker = new Picker(self.pageContextId, self.frameworkId, 'self', false);\n\n // Override the render method to make framework selectable.\n picker._render = function() {\n var self = this;\n return self._preRender().then(function() {\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker_competencyform', context);\n });\n };\n\n // On selected competency.\n picker.on('save', function(e, data) {\n self.setParent(data);\n });\n\n picker.display();\n });\n };\n\n return {\n\n /**\n * Main initialisation.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n * @method init\n */\n init: function(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n // Create instance.\n new ParentCompetencyForm(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId);\n }\n };\n});\n"],"names":["define","$","ajax","Str","Picker","Templates","Notification","ParentCompetencyForm","buttonSelector","inputHiddenSelector","staticElementSelector","frameworkId","pageContextId","registerEvents","prototype","setParent","data","self","this","competencyId","call","methodname","args","id","done","competency","html","shortname","val","fail","exception","get_string","then","rootframework","on","e","preventDefault","picker","_render","_preRender","context","competencies","_competencies","framework","_getFramework","_frameworkId","frameworks","_frameworks","search","_searchText","singleFramework","_singleFramework","render","display","init","inputSelector"],"mappings":";;;;;;;AAsBAA,uCAAO,CAAC,SAAU,YAAa,WAAY,2BAA4B,iBAAkB,sBACrF,SAASC,EAAGC,KAAMC,IAAKC,OAAQC,UAAWC,kBAUtCC,qBAAuB,SAASC,eACAC,oBACAC,sBACAC,YACAC,oBAC3BJ,eAAiBA,oBACjBC,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HC,KAAM,SAAS9C,eACC+C,cACA7C,sBACAC,YACAC,mBAERL,qBAAqBC,eACD+C,cACA7C,sBACAC,YACAC"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/planactions.min.js b/admin/tool/lp/amd/build/planactions.min.js index 4edcfa09f06..009eb0dd64f 100644 --- a/admin/tool/lp/amd/build/planactions.min.js +++ b/admin/tool/lp/amd/build/planactions.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/planactions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/dialogue"],function(a,b,c,d,e,f,g){var h=function(a){this._type=a;if("plan"===a){this._region="[data-region=\"plan-page\"]";this._planNode="[data-region=\"plan-page\"]";this._template="tool_lp/plan_page";this._contextMethod="tool_lp_data_for_plan_page"}else if("plans"===a){this._region="[data-region=\"plans\"]";this._planNode="[data-region=\"plan-node\"]";this._template="tool_lp/plans_page";this._contextMethod="tool_lp_data_for_plans_page"}else{throw new TypeError("Unexpected type.")}};h.prototype._contextMethod=null;h.prototype._planNode=null;h.prototype._region=null;h.prototype._template=null;h.prototype._type=null;h.prototype._getContextArgs=function(a){var b=this,c={};if("plan"===b._type){c={planid:a.id}}else if("plans"===b._type){c={userid:a.userid}}return c};h.prototype.refresh=function(b){var c=this._findPlanData(a(b));this._callAndRefresh([],c)};h.prototype._renderView=function(c){var d=this;return b.render(d._template,c).then(function(c,e){a(d._region).replaceWith(c);b.runTemplateJS(e)})};h.prototype._callAndRefresh=function(b,e){var f="tool_lp/planactions:_callAndRefresh-"+Math.floor(Math.random()*Math.floor(1e3));M.util.js_pending(f);var g=this;b.push({methodname:g._contextMethod,args:g._getContextArgs(e)});return a.when.apply(a,c.call(b)).then(function(){return g._renderView(arguments[arguments.length-1])}).fail(d.exception).always(function(){return M.util.js_complete(f)})};h.prototype._doDelete=function(a){var b=this,c=[{methodname:"core_competency_delete_plan",args:{id:a.id}}];b._callAndRefresh(c,a)};h.prototype.deletePlan=function(a){var b=this,f;f=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"deleteplan",component:"tool_lp",param:c.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doDelete(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._doReopenPlan=function(a){var b=this,c=[{methodname:"core_competency_reopen_plan",args:{planid:a.id}}];b._callAndRefresh(c,a)};h.prototype.reopenPlan=function(a){var b=this,f=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"reopenplanconfirm",component:"tool_lp",param:c.name},{key:"reopenplan",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doReopenPlan(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._doCompletePlan=function(a){var b=this,c=[{methodname:"core_competency_complete_plan",args:{planid:a.id}}];b._callAndRefresh(c,a)};h.prototype.completePlan=function(a){var b=this,f=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"completeplanconfirm",component:"tool_lp",param:c.name},{key:"completeplan",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doCompletePlan(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._doUnlinkPlan=function(a){var b=this,c=[{methodname:"core_competency_unlink_plan_from_template",args:{planid:a.id}}];b._callAndRefresh(c,a)};h.prototype.unlinkPlan=function(a){var b=this,f=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"unlinkplantemplateconfirm",component:"tool_lp",param:c.name},{key:"unlinkplantemplate",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doUnlinkPlan(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._doRequestReview=function(a){var b=[{methodname:"core_competency_plan_request_review",args:{id:a.id}}];this._callAndRefresh(b,a)};h.prototype.requestReview=function(a){this._doRequestReview(a)};h.prototype._doCancelReviewRequest=function(a){var b=[{methodname:"core_competency_plan_cancel_review_request",args:{id:a.id}}];this._callAndRefresh(b,a)};h.prototype.cancelReviewRequest=function(a){this._doCancelReviewRequest(a)};h.prototype._doStartReview=function(a){var b=[{methodname:"core_competency_plan_start_review",args:{id:a.id}}];this._callAndRefresh(b,a)};h.prototype.startReview=function(a){this._doStartReview(a)};h.prototype._doStopReview=function(a){var b=[{methodname:"core_competency_plan_stop_review",args:{id:a.id}}];this._callAndRefresh(b,a)};h.prototype.stopReview=function(a){this._doStopReview(a)};h.prototype._doApprove=function(a){var b=[{methodname:"core_competency_approve_plan",args:{id:a.id}}];this._callAndRefresh(b,a)};h.prototype.approve=function(a){this._doApprove(a)};h.prototype._doUnapprove=function(a){var b=[{methodname:"core_competency_unapprove_plan",args:{id:a.id}}];this._callAndRefresh(b,a)};h.prototype.unapprove=function(a){this._doUnapprove(a)};h.prototype._showLinkedCoursesHandler=function(f){f.preventDefault();var h=a(f.target).data("id"),i=c.call([{methodname:"tool_lp_list_courses_using_competency",args:{id:h}}]);i[0].done(function(a){b.render("tool_lp/linked_courses_summary",{courses:a}).done(function(a){e.get_string("linkedcourses","tool_lp").done(function(b){new g(b,a)}).fail(d.exception)}).fail(d.exception)}).fail(d.exception)};h.prototype._eventHandler=function(b,c){c.preventDefault();var d=this._findPlanData(a(c.target));this[b](d)};h.prototype._findPlanData=function(b){var c=b.parentsUntil(a(this._region).parent(),this._planNode),d;if(1!=c.length){throw new Error("The plan node was not located.")}d=c.data();if("undefined"==typeof d||"undefined"==typeof d.id){throw new Error("Plan data could not be found.")}return d};h.prototype.enhanceMenubar=function(a){f.enhance(a,{'[data-action="plan-delete"]':this._eventHandler.bind(this,"deletePlan"),'[data-action="plan-complete"]':this._eventHandler.bind(this,"completePlan"),'[data-action="plan-reopen"]':this._eventHandler.bind(this,"reopenPlan"),'[data-action="plan-unlink"]':this._eventHandler.bind(this,"unlinkPlan"),'[data-action="plan-request-review"]':this._eventHandler.bind(this,"requestReview"),'[data-action="plan-cancel-review-request"]':this._eventHandler.bind(this,"cancelReviewRequest"),'[data-action="plan-start-review"]':this._eventHandler.bind(this,"startReview"),'[data-action="plan-stop-review"]':this._eventHandler.bind(this,"stopReview"),'[data-action="plan-approve"]':this._eventHandler.bind(this,"approve"),'[data-action="plan-unapprove"]':this._eventHandler.bind(this,"unapprove")})};h.prototype.registerEvents=function(){var b=a(this._region);b.find("[data-action=\"plan-delete\"]").click(this._eventHandler.bind(this,"deletePlan"));b.find("[data-action=\"plan-complete\"]").click(this._eventHandler.bind(this,"completePlan"));b.find("[data-action=\"plan-reopen\"]").click(this._eventHandler.bind(this,"reopenPlan"));b.find("[data-action=\"plan-unlink\"]").click(this._eventHandler.bind(this,"unlinkPlan"));b.find("[data-action=\"plan-request-review\"]").click(this._eventHandler.bind(this,"requestReview"));b.find("[data-action=\"plan-cancel-review-request\"]").click(this._eventHandler.bind(this,"cancelReviewRequest"));b.find("[data-action=\"plan-start-review\"]").click(this._eventHandler.bind(this,"startReview"));b.find("[data-action=\"plan-stop-review\"]").click(this._eventHandler.bind(this,"stopReview"));b.find("[data-action=\"plan-approve\"]").click(this._eventHandler.bind(this,"approve"));b.find("[data-action=\"plan-unapprove\"]").click(this._eventHandler.bind(this,"unapprove"));b.find("[data-action=\"find-courses-link\"]").click(this._showLinkedCoursesHandler.bind(this))};return h}); -//# sourceMappingURL=planactions.min.js.map +/** + * Plan actions via ajax. + * + * @module tool_lp/planactions + * @copyright 2015 David Monllao + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/planactions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/dialogue"],(function($,templates,ajax,notification,str,Menubar,Dialogue){var PlanActions=function(type){if(this._type=type,"plan"===type)this._region='[data-region="plan-page"]',this._planNode='[data-region="plan-page"]',this._template="tool_lp/plan_page",this._contextMethod="tool_lp_data_for_plan_page";else{if("plans"!==type)throw new TypeError("Unexpected type.");this._region='[data-region="plans"]',this._planNode='[data-region="plan-node"]',this._template="tool_lp/plans_page",this._contextMethod="tool_lp_data_for_plans_page"}};return PlanActions.prototype._contextMethod=null,PlanActions.prototype._planNode=null,PlanActions.prototype._region=null,PlanActions.prototype._template=null,PlanActions.prototype._type=null,PlanActions.prototype._getContextArgs=function(planData){var args={};return"plan"===this._type?args={planid:planData.id}:"plans"===this._type&&(args={userid:planData.userid}),args},PlanActions.prototype.refresh=function(selector){var planData=this._findPlanData($(selector));this._callAndRefresh([],planData)},PlanActions.prototype._renderView=function(context){var self=this;return templates.render(self._template,context).then((function(newhtml,newjs){$(self._region).replaceWith(newhtml),templates.runTemplateJS(newjs)}))},PlanActions.prototype._callAndRefresh=function(calls,planData){var callKey="tool_lp/planactions:_callAndRefresh-"+Math.floor(Math.random()*Math.floor(1e3));M.util.js_pending(callKey);var self=this;return calls.push({methodname:self._contextMethod,args:self._getContextArgs(planData)}),$.when.apply($,ajax.call(calls)).then((function(){return self._renderView(arguments[arguments.length-1])})).fail(notification.exception).always((function(){return M.util.js_complete(callKey)}))},PlanActions.prototype._doDelete=function(planData){var calls=[{methodname:"core_competency_delete_plan",args:{id:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.deletePlan=function(planData){var self=this;ajax.call([{methodname:"core_competency_read_plan",args:{id:planData.id}}])[0].done((function(plan){str.get_strings([{key:"confirm",component:"moodle"},{key:"deleteplan",component:"tool_lp",param:plan.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){self._doDelete(planData)}))})).fail(notification.exception)})).fail(notification.exception)},PlanActions.prototype._doReopenPlan=function(planData){var calls=[{methodname:"core_competency_reopen_plan",args:{planid:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.reopenPlan=function(planData){var self=this;ajax.call([{methodname:"core_competency_read_plan",args:{id:planData.id}}])[0].done((function(plan){str.get_strings([{key:"confirm",component:"moodle"},{key:"reopenplanconfirm",component:"tool_lp",param:plan.name},{key:"reopenplan",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){self._doReopenPlan(planData)}))})).fail(notification.exception)})).fail(notification.exception)},PlanActions.prototype._doCompletePlan=function(planData){var calls=[{methodname:"core_competency_complete_plan",args:{planid:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.completePlan=function(planData){var self=this;ajax.call([{methodname:"core_competency_read_plan",args:{id:planData.id}}])[0].done((function(plan){str.get_strings([{key:"confirm",component:"moodle"},{key:"completeplanconfirm",component:"tool_lp",param:plan.name},{key:"completeplan",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){self._doCompletePlan(planData)}))})).fail(notification.exception)})).fail(notification.exception)},PlanActions.prototype._doUnlinkPlan=function(planData){var calls=[{methodname:"core_competency_unlink_plan_from_template",args:{planid:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.unlinkPlan=function(planData){var self=this;ajax.call([{methodname:"core_competency_read_plan",args:{id:planData.id}}])[0].done((function(plan){str.get_strings([{key:"confirm",component:"moodle"},{key:"unlinkplantemplateconfirm",component:"tool_lp",param:plan.name},{key:"unlinkplantemplate",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){self._doUnlinkPlan(planData)}))})).fail(notification.exception)})).fail(notification.exception)},PlanActions.prototype._doRequestReview=function(planData){var calls=[{methodname:"core_competency_plan_request_review",args:{id:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.requestReview=function(planData){this._doRequestReview(planData)},PlanActions.prototype._doCancelReviewRequest=function(planData){var calls=[{methodname:"core_competency_plan_cancel_review_request",args:{id:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.cancelReviewRequest=function(planData){this._doCancelReviewRequest(planData)},PlanActions.prototype._doStartReview=function(planData){var calls=[{methodname:"core_competency_plan_start_review",args:{id:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.startReview=function(planData){this._doStartReview(planData)},PlanActions.prototype._doStopReview=function(planData){var calls=[{methodname:"core_competency_plan_stop_review",args:{id:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.stopReview=function(planData){this._doStopReview(planData)},PlanActions.prototype._doApprove=function(planData){var calls=[{methodname:"core_competency_approve_plan",args:{id:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.approve=function(planData){this._doApprove(planData)},PlanActions.prototype._doUnapprove=function(planData){var calls=[{methodname:"core_competency_unapprove_plan",args:{id:planData.id}}];this._callAndRefresh(calls,planData)},PlanActions.prototype.unapprove=function(planData){this._doUnapprove(planData)},PlanActions.prototype._showLinkedCoursesHandler=function(e){e.preventDefault();var competencyid=$(e.target).data("id");ajax.call([{methodname:"tool_lp_list_courses_using_competency",args:{id:competencyid}}])[0].done((function(courses){var context={courses:courses};templates.render("tool_lp/linked_courses_summary",context).done((function(html){str.get_string("linkedcourses","tool_lp").done((function(linkedcourses){new Dialogue(linkedcourses,html)})).fail(notification.exception)})).fail(notification.exception)})).fail(notification.exception)},PlanActions.prototype._eventHandler=function(method,e){e.preventDefault();var data=this._findPlanData($(e.target));this[method](data)},PlanActions.prototype._findPlanData=function(node){var data,parent=node.parentsUntil($(this._region).parent(),this._planNode);if(1!=parent.length)throw new Error("The plan node was not located.");if(void 0===(data=parent.data())||void 0===data.id)throw new Error("Plan data could not be found.");return data},PlanActions.prototype.enhanceMenubar=function(selector){Menubar.enhance(selector,{'[data-action="plan-delete"]':this._eventHandler.bind(this,"deletePlan"),'[data-action="plan-complete"]':this._eventHandler.bind(this,"completePlan"),'[data-action="plan-reopen"]':this._eventHandler.bind(this,"reopenPlan"),'[data-action="plan-unlink"]':this._eventHandler.bind(this,"unlinkPlan"),'[data-action="plan-request-review"]':this._eventHandler.bind(this,"requestReview"),'[data-action="plan-cancel-review-request"]':this._eventHandler.bind(this,"cancelReviewRequest"),'[data-action="plan-start-review"]':this._eventHandler.bind(this,"startReview"),'[data-action="plan-stop-review"]':this._eventHandler.bind(this,"stopReview"),'[data-action="plan-approve"]':this._eventHandler.bind(this,"approve"),'[data-action="plan-unapprove"]':this._eventHandler.bind(this,"unapprove")})},PlanActions.prototype.registerEvents=function(){var wrapper=$(this._region);wrapper.find('[data-action="plan-delete"]').click(this._eventHandler.bind(this,"deletePlan")),wrapper.find('[data-action="plan-complete"]').click(this._eventHandler.bind(this,"completePlan")),wrapper.find('[data-action="plan-reopen"]').click(this._eventHandler.bind(this,"reopenPlan")),wrapper.find('[data-action="plan-unlink"]').click(this._eventHandler.bind(this,"unlinkPlan")),wrapper.find('[data-action="plan-request-review"]').click(this._eventHandler.bind(this,"requestReview")),wrapper.find('[data-action="plan-cancel-review-request"]').click(this._eventHandler.bind(this,"cancelReviewRequest")),wrapper.find('[data-action="plan-start-review"]').click(this._eventHandler.bind(this,"startReview")),wrapper.find('[data-action="plan-stop-review"]').click(this._eventHandler.bind(this,"stopReview")),wrapper.find('[data-action="plan-approve"]').click(this._eventHandler.bind(this,"approve")),wrapper.find('[data-action="plan-unapprove"]').click(this._eventHandler.bind(this,"unapprove")),wrapper.find('[data-action="find-courses-link"]').click(this._showLinkedCoursesHandler.bind(this))},PlanActions})); + +//# sourceMappingURL=planactions.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/planactions.min.js.map b/admin/tool/lp/amd/build/planactions.min.js.map index 5d24458ce4f..9ef56027339 100644 --- a/admin/tool/lp/amd/build/planactions.min.js.map +++ b/admin/tool/lp/amd/build/planactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/planactions.js"],"names":["define","$","templates","ajax","notification","str","Menubar","Dialogue","PlanActions","type","_type","_region","_planNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","planData","self","args","planid","id","userid","refresh","selector","_findPlanData","_callAndRefresh","_renderView","context","render","then","newhtml","newjs","replaceWith","runTemplateJS","calls","callKey","Math","floor","random","M","util","js_pending","push","methodname","when","apply","call","arguments","length","fail","exception","always","js_complete","_doDelete","deletePlan","requests","done","plan","get_strings","key","component","param","name","strings","confirm","_doReopenPlan","reopenPlan","_doCompletePlan","completePlan","_doUnlinkPlan","unlinkPlan","_doRequestReview","requestReview","_doCancelReviewRequest","cancelReviewRequest","_doStartReview","startReview","_doStopReview","stopReview","_doApprove","approve","_doUnapprove","unapprove","_showLinkedCoursesHandler","e","preventDefault","competencyid","target","data","courses","html","get_string","linkedcourses","_eventHandler","method","node","parent","parentsUntil","Error","enhanceMenubar","enhance","bind","registerEvents","wrapper","find","click"],"mappings":"AAsBAA,OAAM,uBAAC,CAAC,QAAD,CACC,gBADD,CAEC,WAFD,CAGC,mBAHD,CAIC,UAJD,CAKC,iBALD,CAMC,kBAND,CAAD,CAOE,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAA6BC,CAA7B,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAyDC,CAAzD,CAAmE,CASvE,GAAIC,CAAAA,CAAW,CAAG,SAASC,CAAT,CAAe,CAC7B,KAAKC,KAAL,CAAaD,CAAb,CAEA,GAAa,MAAT,GAAAA,CAAJ,CAAqB,CAEjB,KAAKE,OAAL,CAAe,6BAAf,CACA,KAAKC,SAAL,CAAiB,6BAAjB,CACA,KAAKC,SAAL,CAAiB,mBAAjB,CACA,KAAKC,cAAL,CAAsB,4BAEzB,CAPD,IAOO,IAAa,OAAT,GAAAL,CAAJ,CAAsB,CAEzB,KAAKE,OAAL,CAAe,yBAAf,CACA,KAAKC,SAAL,CAAiB,6BAAjB,CACA,KAAKC,SAAL,CAAiB,oBAAjB,CACA,KAAKC,cAAL,CAAs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DC,KAApD,CAA0D,KAAKZ,aAAL,CAAmBQ,IAAnB,CAAwB,IAAxB,CAA8B,eAA9B,CAA1D,EACAE,CAAO,CAACC,IAAR,CAAa,8CAAb,EAA2DC,KAA3D,CAAiE,KAAKZ,aAAL,CAAmBQ,IAAnB,CAAwB,IAAxB,CAA8B,qBAA9B,CAAjE,EACAE,CAAO,CAACC,IAAR,CAAa,qCAAb,EAAkDC,KAAlD,CAAwD,KAAKZ,aAAL,CAAmBQ,IAAnB,CAAwB,IAAxB,CAA8B,aAA9B,CAAxD,EACAE,CAAO,CAACC,IAAR,CAAa,oCAAb,EAAiDC,KAAjD,CAAuD,KAAKZ,aAAL,CAAmBQ,IAAnB,CAAwB,IAAxB,CAA8B,YAA9B,CAAvD,EACAE,CAAO,CAACC,IAAR,CAAa,gCAAb,EAA6CC,KAA7C,CAAmD,KAAKZ,aAAL,CAAmBQ,IAAnB,CAAwB,IAAxB,CAA8B,SAA9B,CAAnD,EACAE,CAAO,CAACC,IAAR,CAAa,kCAAb,EAA+CC,KAA/C,CAAqD,KAAKZ,aAAL,CAAmBQ,IAAnB,CAAwB,IAAxB,CAA8B,WAA9B,CAArD,EAEAE,CAAO,CAACC,IAAR,CAAa,qCAAb,EAAkDC,KAAlD,CAAwD,KAAKtB,yBAAL,CAA+BkB,IAA/B,CAAoC,IAApC,CAAxD,CACH,CAhBD,CAkBA,MAAO/F,CAAAA,CACV,CAxkBK,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 * Plan actions via ajax.\n *\n * @module tool_lp/planactions\n * @copyright 2015 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/dialogue'],\n function($, templates, ajax, notification, str, Menubar, Dialogue) {\n\n /**\n * PlanActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var PlanActions = function(type) {\n this._type = type;\n\n if (type === 'plan') {\n // This is the page to view one plan.\n this._region = '[data-region=\"plan-page\"]';\n this._planNode = '[data-region=\"plan-page\"]';\n this._template = 'tool_lp/plan_page';\n this._contextMethod = 'tool_lp_data_for_plan_page';\n\n } else if (type === 'plans') {\n // This is the page to view a list of plans.\n this._region = '[data-region=\"plans\"]';\n this._planNode = '[data-region=\"plan-node\"]';\n this._template = 'tool_lp/plans_page';\n this._contextMethod = 'tool_lp_data_for_plans_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n PlanActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the plan. */\n PlanActions.prototype._planNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n PlanActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n PlanActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n PlanActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} planData Plan data from plan node.\n * @return {Object} List of arguments.\n */\n PlanActions.prototype._getContextArgs = function(planData) {\n var self = this,\n args = {};\n\n if (self._type === 'plan') {\n args = {\n planid: planData.id\n };\n\n } else if (self._type === 'plans') {\n args = {\n userid: planData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Refresh the plan view.\n *\n * This is useful when you only want to refresh the view.\n *\n * @param {String} selector The node to search the plan data from.\n */\n PlanActions.prototype.refresh = function(selector) {\n var planData = this._findPlanData($(selector));\n this._callAndRefresh([], planData);\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n PlanActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n $(self._region).replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} planData Plan data from plan node.\n * @return {Promise}\n */\n PlanActions.prototype._callAndRefresh = function(calls, planData) {\n // Because this function causes a refresh, we must track the JS completion from start to finish to prevent\n // stale reference issues in Behat.\n var callKey = 'tool_lp/planactions:_callAndRefresh-' + Math.floor(Math.random() * Math.floor(1000));\n M.util.js_pending(callKey);\n\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(planData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception)\n .always(function() {\n return M.util.js_complete(callKey);\n });\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doDelete = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_plan',\n args: {id: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.deletePlan = function(planData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteplan', component: 'tool_lp', param: plan.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete plan X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Reopen plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doReopenPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_reopen_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Reopen a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.reopenPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'reopenplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Reopen plan X?\n strings[2], // Reopen.\n strings[3], // Cancel.\n function() {\n self._doReopenPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Complete plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doCompletePlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_complete_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Complete a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.completePlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'completeplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'completeplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Complete plan X?\n strings[2], // Complete.\n strings[3], // Cancel.\n function() {\n self._doCompletePlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Unlink plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doUnlinkPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_unlink_plan_from_template',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Unlink a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.unlinkPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name},\n {key: 'unlinkplantemplate', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink plan X?\n strings[2], // Unlink.\n strings[3], // Cancel.\n function() {\n self._doUnlinkPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doRequestReview\n */\n PlanActions.prototype._doRequestReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_request_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method requestReview\n */\n PlanActions.prototype.requestReview = function(planData) {\n this._doRequestReview(planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doCancelReviewRequest\n */\n PlanActions.prototype._doCancelReviewRequest = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_cancel_review_request',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method cancelReviewRequest\n */\n PlanActions.prototype.cancelReviewRequest = function(planData) {\n this._doCancelReviewRequest(planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStartReview\n */\n PlanActions.prototype._doStartReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_start_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method startReview\n */\n PlanActions.prototype.startReview = function(planData) {\n this._doStartReview(planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStopReview\n */\n PlanActions.prototype._doStopReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_stop_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method stopReview\n */\n PlanActions.prototype.stopReview = function(planData) {\n this._doStopReview(planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doApprove\n */\n PlanActions.prototype._doApprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_approve_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method approve\n */\n PlanActions.prototype.approve = function(planData) {\n this._doApprove(planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doUnapprove\n */\n PlanActions.prototype._doUnapprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_unapprove_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method unapprove\n */\n PlanActions.prototype.unapprove = function(planData) {\n this._doUnapprove(planData);\n };\n\n /**\n * Display list of linked courses on a modal dialogue.\n *\n * @param {Event} e The event.\n */\n PlanActions.prototype._showLinkedCoursesHandler = function(e) {\n e.preventDefault();\n\n var competencyid = $(e.target).data('id');\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competencyid}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html // The linked courses.\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Plan event handler.\n *\n * @param {String} method The method to call.\n * @param {Event} e The event.\n * @method _eventHandler\n */\n PlanActions.prototype._eventHandler = function(method, e) {\n e.preventDefault();\n var data = this._findPlanData($(e.target));\n this[method](data);\n };\n\n /**\n * Find the plan data from the plan node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Plan data.\n */\n PlanActions.prototype._findPlanData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._planNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The plan node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Plan data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n PlanActions.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"plan-delete\"]': this._eventHandler.bind(this, 'deletePlan'),\n '[data-action=\"plan-complete\"]': this._eventHandler.bind(this, 'completePlan'),\n '[data-action=\"plan-reopen\"]': this._eventHandler.bind(this, 'reopenPlan'),\n '[data-action=\"plan-unlink\"]': this._eventHandler.bind(this, 'unlinkPlan'),\n '[data-action=\"plan-request-review\"]': this._eventHandler.bind(this, 'requestReview'),\n '[data-action=\"plan-cancel-review-request\"]': this._eventHandler.bind(this, 'cancelReviewRequest'),\n '[data-action=\"plan-start-review\"]': this._eventHandler.bind(this, 'startReview'),\n '[data-action=\"plan-stop-review\"]': this._eventHandler.bind(this, 'stopReview'),\n '[data-action=\"plan-approve\"]': this._eventHandler.bind(this, 'approve'),\n '[data-action=\"plan-unapprove\"]': this._eventHandler.bind(this, 'unapprove'),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n PlanActions.prototype.registerEvents = function() {\n var wrapper = $(this._region);\n\n wrapper.find('[data-action=\"plan-delete\"]').click(this._eventHandler.bind(this, 'deletePlan'));\n wrapper.find('[data-action=\"plan-complete\"]').click(this._eventHandler.bind(this, 'completePlan'));\n wrapper.find('[data-action=\"plan-reopen\"]').click(this._eventHandler.bind(this, 'reopenPlan'));\n wrapper.find('[data-action=\"plan-unlink\"]').click(this._eventHandler.bind(this, 'unlinkPlan'));\n\n wrapper.find('[data-action=\"plan-request-review\"]').click(this._eventHandler.bind(this, 'requestReview'));\n wrapper.find('[data-action=\"plan-cancel-review-request\"]').click(this._eventHandler.bind(this, 'cancelReviewRequest'));\n wrapper.find('[data-action=\"plan-start-review\"]').click(this._eventHandler.bind(this, 'startReview'));\n wrapper.find('[data-action=\"plan-stop-review\"]').click(this._eventHandler.bind(this, 'stopReview'));\n wrapper.find('[data-action=\"plan-approve\"]').click(this._eventHandler.bind(this, 'approve'));\n wrapper.find('[data-action=\"plan-unapprove\"]').click(this._eventHandler.bind(this, 'unapprove'));\n\n wrapper.find('[data-action=\"find-courses-link\"]').click(this._showLinkedCoursesHandler.bind(this));\n };\n\n return PlanActions;\n});\n"],"file":"planactions.min.js"} \ No newline at end of file +{"version":3,"file":"planactions.min.js","sources":["../src/planactions.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 * Plan actions via ajax.\n *\n * @module tool_lp/planactions\n * @copyright 2015 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/dialogue'],\n function($, templates, ajax, notification, str, Menubar, Dialogue) {\n\n /**\n * PlanActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var PlanActions = function(type) {\n this._type = type;\n\n if (type === 'plan') {\n // This is the page to view one plan.\n this._region = '[data-region=\"plan-page\"]';\n this._planNode = '[data-region=\"plan-page\"]';\n this._template = 'tool_lp/plan_page';\n this._contextMethod = 'tool_lp_data_for_plan_page';\n\n } else if (type === 'plans') {\n // This is the page to view a list of plans.\n this._region = '[data-region=\"plans\"]';\n this._planNode = '[data-region=\"plan-node\"]';\n this._template = 'tool_lp/plans_page';\n this._contextMethod = 'tool_lp_data_for_plans_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n PlanActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the plan. */\n PlanActions.prototype._planNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n PlanActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n PlanActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n PlanActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} planData Plan data from plan node.\n * @return {Object} List of arguments.\n */\n PlanActions.prototype._getContextArgs = function(planData) {\n var self = this,\n args = {};\n\n if (self._type === 'plan') {\n args = {\n planid: planData.id\n };\n\n } else if (self._type === 'plans') {\n args = {\n userid: planData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Refresh the plan view.\n *\n * This is useful when you only want to refresh the view.\n *\n * @param {String} selector The node to search the plan data from.\n */\n PlanActions.prototype.refresh = function(selector) {\n var planData = this._findPlanData($(selector));\n this._callAndRefresh([], planData);\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n PlanActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n $(self._region).replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} planData Plan data from plan node.\n * @return {Promise}\n */\n PlanActions.prototype._callAndRefresh = function(calls, planData) {\n // Because this function causes a refresh, we must track the JS completion from start to finish to prevent\n // stale reference issues in Behat.\n var callKey = 'tool_lp/planactions:_callAndRefresh-' + Math.floor(Math.random() * Math.floor(1000));\n M.util.js_pending(callKey);\n\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(planData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception)\n .always(function() {\n return M.util.js_complete(callKey);\n });\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doDelete = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_plan',\n args: {id: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.deletePlan = function(planData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteplan', component: 'tool_lp', param: plan.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete plan X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Reopen plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doReopenPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_reopen_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Reopen a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.reopenPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'reopenplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Reopen plan X?\n strings[2], // Reopen.\n strings[3], // Cancel.\n function() {\n self._doReopenPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Complete plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doCompletePlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_complete_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Complete a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.completePlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'completeplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'completeplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Complete plan X?\n strings[2], // Complete.\n strings[3], // Cancel.\n function() {\n self._doCompletePlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Unlink plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doUnlinkPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_unlink_plan_from_template',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Unlink a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.unlinkPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name},\n {key: 'unlinkplantemplate', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink plan X?\n strings[2], // Unlink.\n strings[3], // Cancel.\n function() {\n self._doUnlinkPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doRequestReview\n */\n PlanActions.prototype._doRequestReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_request_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method requestReview\n */\n PlanActions.prototype.requestReview = function(planData) {\n this._doRequestReview(planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doCancelReviewRequest\n */\n PlanActions.prototype._doCancelReviewRequest = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_cancel_review_request',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method cancelReviewRequest\n */\n PlanActions.prototype.cancelReviewRequest = function(planData) {\n this._doCancelReviewRequest(planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStartReview\n */\n PlanActions.prototype._doStartReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_start_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method startReview\n */\n PlanActions.prototype.startReview = function(planData) {\n this._doStartReview(planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStopReview\n */\n PlanActions.prototype._doStopReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_stop_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method stopReview\n */\n PlanActions.prototype.stopReview = function(planData) {\n this._doStopReview(planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doApprove\n */\n PlanActions.prototype._doApprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_approve_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method approve\n */\n PlanActions.prototype.approve = function(planData) {\n this._doApprove(planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doUnapprove\n */\n PlanActions.prototype._doUnapprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_unapprove_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method unapprove\n */\n PlanActions.prototype.unapprove = function(planData) {\n this._doUnapprove(planData);\n };\n\n /**\n * Display list of linked courses on a modal dialogue.\n *\n * @param {Event} e The event.\n */\n PlanActions.prototype._showLinkedCoursesHandler = function(e) {\n e.preventDefault();\n\n var competencyid = $(e.target).data('id');\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competencyid}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html // The linked courses.\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Plan event handler.\n *\n * @param {String} method The method to call.\n * @param {Event} e The event.\n * @method _eventHandler\n */\n PlanActions.prototype._eventHandler = function(method, e) {\n e.preventDefault();\n var data = this._findPlanData($(e.target));\n this[method](data);\n };\n\n /**\n * Find the plan data from the plan node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Plan data.\n */\n PlanActions.prototype._findPlanData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._planNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The plan node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Plan data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n PlanActions.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"plan-delete\"]': this._eventHandler.bind(this, 'deletePlan'),\n '[data-action=\"plan-complete\"]': this._eventHandler.bind(this, 'completePlan'),\n '[data-action=\"plan-reopen\"]': this._eventHandler.bind(this, 'reopenPlan'),\n '[data-action=\"plan-unlink\"]': this._eventHandler.bind(this, 'unlinkPlan'),\n '[data-action=\"plan-request-review\"]': this._eventHandler.bind(this, 'requestReview'),\n '[data-action=\"plan-cancel-review-request\"]': this._eventHandler.bind(this, 'cancelReviewRequest'),\n '[data-action=\"plan-start-review\"]': this._eventHandler.bind(this, 'startReview'),\n '[data-action=\"plan-stop-review\"]': this._eventHandler.bind(this, 'stopReview'),\n '[data-action=\"plan-approve\"]': this._eventHandler.bind(this, 'approve'),\n '[data-action=\"plan-unapprove\"]': this._eventHandler.bind(this, 'unapprove'),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n PlanActions.prototype.registerEvents = function() {\n var wrapper = $(this._region);\n\n wrapper.find('[data-action=\"plan-delete\"]').click(this._eventHandler.bind(this, 'deletePlan'));\n wrapper.find('[data-action=\"plan-complete\"]').click(this._eventHandler.bind(this, 'completePlan'));\n wrapper.find('[data-action=\"plan-reopen\"]').click(this._eventHandler.bind(this, 'reopenPlan'));\n wrapper.find('[data-action=\"plan-unlink\"]').click(this._eventHandler.bind(this, 'unlinkPlan'));\n\n wrapper.find('[data-action=\"plan-request-review\"]').click(this._eventHandler.bind(this, 'requestReview'));\n wrapper.find('[data-action=\"plan-cancel-review-request\"]').click(this._eventHandler.bind(this, 'cancelReviewRequest'));\n wrapper.find('[data-action=\"plan-start-review\"]').click(this._eventHandler.bind(this, 'startReview'));\n wrapper.find('[data-action=\"plan-stop-review\"]').click(this._eventHandler.bind(this, 'stopReview'));\n wrapper.find('[data-action=\"plan-approve\"]').click(this._eventHandler.bind(this, 'approve'));\n wrapper.find('[data-action=\"plan-unapprove\"]').click(this._eventHandler.bind(this, 'unapprove'));\n\n wrapper.find('[data-action=\"find-courses-link\"]').click(this._showLinkedCoursesHandler.bind(this));\n };\n\n return PlanActions;\n});\n"],"names":["define","$","templates","ajax","notification","str","Menubar","Dialogue","PlanActions","type","_type","_region","_planNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","planData","args","this","planid","id","userid","refresh","selector","_findPlanData","_callAndRefresh","_renderView","context","self","render","then","newhtml","newjs","replaceWith","runTemplateJS","calls","callKey","Math","floor","random","M","util","js_pending","push","methodname","when","apply","call","arguments","length","fail","exception","always","js_complete","_doDelete","deletePlan","done","plan","get_strings","key","component","param","name","strings","confirm","_doReopenPlan","reopenPlan","_doCompletePlan","completePlan","_doUnlinkPlan","unlinkPlan","_doRequestReview","requestReview","_doCancelReviewRequest","cancelReviewRequest","_doStartReview","startReview","_doStopReview","stopReview","_doApprove","approve","_doUnapprove","unapprove","_showLinkedCoursesHandler","e","preventDefault","competencyid","target","data","courses","html","get_string","linkedcourses","_eventHandler","method","node","parent","parentsUntil","Error","enhanceMenubar","enhance","bind","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SACA,iBACA,YACA,oBACA,WACA,kBACA,qBACA,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,QAASC,cASzDC,YAAc,SAASC,cAClBC,MAAQD,KAEA,SAATA,UAEKE,QAAU,iCACVC,UAAY,iCACZC,UAAY,yBACZC,eAAiB,iCAEnB,CAAA,GAAa,UAATL,WAQD,IAAIM,UAAU,yBANfJ,QAAU,6BACVC,UAAY,iCACZC,UAAY,0BACZC,eAAiB,uCAQ9BN,YAAYQ,UAAUF,eAAiB,KAEvCN,YAAYQ,UAAUJ,UAAY,KAElCJ,YAAYQ,UAAUL,QAAU,KAEhCH,YAAYQ,UAAUH,UAAY,KAElCL,YAAYQ,UAAUN,MAAQ,KAQ9BF,YAAYQ,UAAUC,gBAAkB,SAASC,cAEzCC,KAAO,SAEQ,SAHRC,KAGFV,MACLS,KAAO,CACHE,OAAQH,SAASI,IAGC,UARfF,KAQKV,QACZS,KAAO,CACHI,OAAQL,SAASK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KAAK,8CAA8CC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,wBAC/FqF,QAAQC,KAAK,qCAAqCC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,gBACtFqF,QAAQC,KAAK,oCAAoCC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,eACrFqF,QAAQC,KAAK,gCAAgCC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,YACjFqF,QAAQC,KAAK,kCAAkCC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,cAEnFqF,QAAQC,KAAK,qCAAqCC,MAAMvF,KAAKiE,0BAA0BkB,KAAKnF,QAGzFZ"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/scaleconfig.min.js b/admin/tool/lp/amd/build/scaleconfig.min.js index 3e275c29b91..12a49195596 100644 --- a/admin/tool/lp/amd/build/scaleconfig.min.js +++ b/admin/tool/lp/amd/build/scaleconfig.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/scaleconfig",["jquery","core/notification","core/templates","core/ajax","tool_lp/dialogue","tool_lp/scalevalues"],function(a,b,c,d,e,f){var g=function(b,c,d){this.selectSelector=b;this.inputSelector=c;this.triggerSelector=d;this.originalscaleid=a(b).val();a(b).on("change",this.scaleChangeHandler.bind(this)).change();a(d).click(this.showConfig.bind(this))};g.prototype.selectSelector=null;g.prototype.inputSelector=null;g.prototype.triggerSelector=null;g.prototype.scalevalues=null;g.prototype.originalscaleid=0;g.prototype.scaleid=0;g.prototype.popup=null;g.prototype.showConfig=function(){var d=this;this.scaleid=a(this.selectSelector).val();if(0>=this.scaleid){return}var f=a(this.selectSelector).find("option:selected").text();this.getScaleValues(this.scaleid).done(function(){var a={scalename:f,scales:d.scalevalues};c.render("tool_lp/scale_configuration_page",a).done(function(a){new e(f,a,d.initScaleConfig.bind(d))}).fail(b.exception)}).fail(b.exception)};g.prototype.retrieveOriginalScaleConfig=function(){var b=a(this.inputSelector).val();if(""!==b){var c=a.parseJSON(b),d=c.shift();if(d.scaleid===this.originalscaleid){return c}}return""};g.prototype.initScaleConfig=function(b){this.popup=b;var c=a(b.getContent());if(this.originalscaleid===this.scaleid){var d=this.retrieveOriginalScaleConfig();if(""!==d){d.forEach(function(a){if(1===a.scaledefault){c.find("[data-field=\"tool_lp_scale_default_"+a.id+"\"]").attr("checked",!0)}if(1===a.proficient){c.find("[data-field=\"tool_lp_scale_proficient_"+a.id+"\"]").attr("checked",!0)}})}}c.on("click","[data-action=\"close\"]",function(){this.setScaleConfig();b.close()}.bind(this));c.on("click","[data-action=\"cancel\"]",function(){b.close()})};g.prototype.setScaleConfig=function(){var b=a(this.popup.getContent()),c=[{scaleid:this.scaleid}];this.scalevalues.forEach(function(a){var d=0,e=0;if(b.find("[data-field=\"tool_lp_scale_default_"+a.id+"\"]").is(":checked")){d=1}if(b.find("[data-field=\"tool_lp_scale_proficient_"+a.id+"\"]").is(":checked")){e=1}if(!d&&!e){return}c.push({id:a.id,scaledefault:d,proficient:e})});var d=JSON.stringify(c);a(this.inputSelector).val(d);this.originalscaleid=this.scaleid};g.prototype.getScaleValues=function(a){return f.get_values(a).then(function(a){this.scalevalues=a;return a}.bind(this))};g.prototype.scaleChangeHandler=function(b){if(0>=a(b.target).val()){a(this.triggerSelector).prop("disabled",!0)}else{a(this.triggerSelector).prop("disabled",!1)}};return{init:function init(a,b,c){return new g(a,b,c)}}}); -//# sourceMappingURL=scaleconfig.min.js.map +/** + * Handle opening a dialogue to configure scale data. + * + * @module tool_lp/scaleconfig + * @copyright 2015 Adrian Greeve + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/scaleconfig",["jquery","core/notification","core/templates","core/ajax","tool_lp/dialogue","tool_lp/scalevalues"],(function($,notification,templates,ajax,Dialogue,ModScaleValues){var ScaleConfig=function(selectSelector,inputSelector,triggerSelector){this.selectSelector=selectSelector,this.inputSelector=inputSelector,this.triggerSelector=triggerSelector,this.originalscaleid=$(selectSelector).val(),$(selectSelector).on("change",this.scaleChangeHandler.bind(this)).change(),$(triggerSelector).click(this.showConfig.bind(this))};return ScaleConfig.prototype.selectSelector=null,ScaleConfig.prototype.inputSelector=null,ScaleConfig.prototype.triggerSelector=null,ScaleConfig.prototype.scalevalues=null,ScaleConfig.prototype.originalscaleid=0,ScaleConfig.prototype.scaleid=0,ScaleConfig.prototype.popup=null,ScaleConfig.prototype.showConfig=function(){var self=this;if(this.scaleid=$(this.selectSelector).val(),!(this.scaleid<=0)){var scalename=$(this.selectSelector).find("option:selected").text();this.getScaleValues(this.scaleid).done((function(){var context={scalename:scalename,scales:self.scalevalues};templates.render("tool_lp/scale_configuration_page",context).done((function(html){new Dialogue(scalename,html,self.initScaleConfig.bind(self))})).fail(notification.exception)})).fail(notification.exception)}},ScaleConfig.prototype.retrieveOriginalScaleConfig=function(){var jsonstring=$(this.inputSelector).val();if(""!==jsonstring){var scaleconfiguration=$.parseJSON(jsonstring);if(scaleconfiguration.shift().scaleid===this.originalscaleid)return scaleconfiguration}return""},ScaleConfig.prototype.initScaleConfig=function(popup){this.popup=popup;var body=$(popup.getContent());if(this.originalscaleid===this.scaleid){var currentconfig=this.retrieveOriginalScaleConfig();""!==currentconfig&¤tconfig.forEach((function(value){1===value.scaledefault&&body.find('[data-field="tool_lp_scale_default_'+value.id+'"]').attr("checked",!0),1===value.proficient&&body.find('[data-field="tool_lp_scale_proficient_'+value.id+'"]').attr("checked",!0)}))}body.on("click",'[data-action="close"]',function(){this.setScaleConfig(),popup.close()}.bind(this)),body.on("click",'[data-action="cancel"]',(function(){popup.close()}))},ScaleConfig.prototype.setScaleConfig=function(){var body=$(this.popup.getContent()),data=[{scaleid:this.scaleid}];this.scalevalues.forEach((function(value){var scaledefault=0,proficient=0;body.find('[data-field="tool_lp_scale_default_'+value.id+'"]').is(":checked")&&(scaledefault=1),body.find('[data-field="tool_lp_scale_proficient_'+value.id+'"]').is(":checked")&&(proficient=1),(scaledefault||proficient)&&data.push({id:value.id,scaledefault:scaledefault,proficient:proficient})}));var datastring=JSON.stringify(data);$(this.inputSelector).val(datastring),this.originalscaleid=this.scaleid},ScaleConfig.prototype.getScaleValues=function(scaleid){return ModScaleValues.get_values(scaleid).then(function(values){return this.scalevalues=values,values}.bind(this))},ScaleConfig.prototype.scaleChangeHandler=function(e){$(e.target).val()<=0?$(this.triggerSelector).prop("disabled",!0):$(this.triggerSelector).prop("disabled",!1)},{init:function(selectSelector,inputSelector,triggerSelector){return new ScaleConfig(selectSelector,inputSelector,triggerSelector)}}})); + +//# sourceMappingURL=scaleconfig.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/scaleconfig.min.js.map b/admin/tool/lp/amd/build/scaleconfig.min.js.map index 73df75a279d..3a709b50add 100644 --- a/admin/tool/lp/amd/build/scaleconfig.min.js.map +++ b/admin/tool/lp/amd/build/scaleconfig.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/scaleconfig.js"],"names":["define","$","notification","templates","ajax","Dialogue","ModScaleValues","ScaleConfig","selectSelector","inputSelector","triggerSelector","originalscaleid","val","on","scaleChangeHandler","bind","change","click","showConfig","prototype","scalevalues","scaleid","popup","self","scalename","find","text","getScaleValues","done","context","scales","render","html","initScaleConfig","fail","exception","retrieveOriginalScaleConfig","jsonstring","scaleconfiguration","parseJSON","scaledetail","shift","body","getContent","currentconfig","forEach","value","scaledefault","id","attr","proficient","setScaleConfig","close","data","is","push","datastring","JSON","stringify","get_values","then","values","e","target","prop","init"],"mappings":"AAsBAA,OAAM,uBAAC,CAAC,QAAD,CAAW,mBAAX,CAAgC,gBAAhC,CAAkD,WAAlD,CAA+D,kBAA/D,CAAmF,qBAAnF,CAAD,CACF,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAqCC,CAArC,CAA2CC,CAA3C,CAAqDC,CAArD,CAAqE,CAQrE,GAAIC,CAAAA,CAAW,CAAG,SAASC,CAAT,CAAyBC,CAAzB,CAAwCC,CAAxC,CAAyD,CACvE,KAAKF,cAAL,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hC,CAA+CC,CAA/C,CACV,CAbE,CAeV,CA3MK,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 * Handle opening a dialogue to configure scale data.\n *\n * @module tool_lp/scaleconfig\n * @copyright 2015 Adrian Greeve \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/templates', 'core/ajax', 'tool_lp/dialogue', 'tool_lp/scalevalues'],\n function($, notification, templates, ajax, Dialogue, ModScaleValues) {\n\n /**\n * Scale config object.\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n */\n var ScaleConfig = function(selectSelector, inputSelector, triggerSelector) {\n this.selectSelector = selectSelector;\n this.inputSelector = inputSelector;\n this.triggerSelector = triggerSelector;\n\n // Get the current scale ID.\n this.originalscaleid = $(selectSelector).val();\n $(selectSelector).on('change', this.scaleChangeHandler.bind(this)).change();\n $(triggerSelector).click(this.showConfig.bind(this));\n };\n\n /** @var {String} The select box selector. */\n ScaleConfig.prototype.selectSelector = null;\n /** @var {String} The hidden field selector. */\n ScaleConfig.prototype.inputSelector = null;\n /** @var {String} The trigger selector. */\n ScaleConfig.prototype.triggerSelector = null;\n /** @var {Array} scalevalues ID and name of the scales. */\n ScaleConfig.prototype.scalevalues = null;\n /** @var {Number) originalscaleid Original scale ID when the page loads. */\n ScaleConfig.prototype.originalscaleid = 0;\n /** @var {Number} scaleid Current scale ID. */\n ScaleConfig.prototype.scaleid = 0;\n /** @var {Dialogue} Reference to the popup. */\n ScaleConfig.prototype.popup = null;\n\n /**\n * Displays the scale configuration dialogue.\n *\n * @method showConfig\n */\n ScaleConfig.prototype.showConfig = function() {\n var self = this;\n\n this.scaleid = $(this.selectSelector).val();\n if (this.scaleid <= 0) {\n // This should not happen.\n return;\n }\n\n var scalename = $(this.selectSelector).find(\"option:selected\").text();\n this.getScaleValues(this.scaleid).done(function() {\n\n var context = {\n scalename: scalename,\n scales: self.scalevalues\n };\n\n // Dish up the form.\n templates.render('tool_lp/scale_configuration_page', context)\n .done(function(html) {\n new Dialogue(\n scalename,\n html,\n self.initScaleConfig.bind(self)\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Gets the original scale configuration if it was set.\n *\n * @method retrieveOriginalScaleConfig\n * @return {Object|String} scale configuration or empty string.\n */\n ScaleConfig.prototype.retrieveOriginalScaleConfig = function() {\n var jsonstring = $(this.inputSelector).val();\n if (jsonstring !== '') {\n var scaleconfiguration = $.parseJSON(jsonstring);\n // The first object should contain the scale ID for the configuration.\n var scaledetail = scaleconfiguration.shift();\n // Check that this scale id matches the one from the page before returning the configuration.\n if (scaledetail.scaleid === this.originalscaleid) {\n return scaleconfiguration;\n }\n }\n return '';\n };\n\n /**\n * Initialises the scale configuration dialogue.\n *\n * @method initScaleConfig\n * @param {Dialogue} popup Dialogue object to initialise.\n */\n ScaleConfig.prototype.initScaleConfig = function(popup) {\n this.popup = popup;\n var body = $(popup.getContent());\n if (this.originalscaleid === this.scaleid) {\n // Set up the popup to show the current configuration.\n var currentconfig = this.retrieveOriginalScaleConfig();\n // Set up the form only if there is configuration settings to set.\n if (currentconfig !== '') {\n currentconfig.forEach(function(value) {\n if (value.scaledefault === 1) {\n body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').attr('checked', true);\n }\n if (value.proficient === 1) {\n body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').attr('checked', true);\n }\n });\n }\n }\n body.on('click', '[data-action=\"close\"]', function() {\n this.setScaleConfig();\n popup.close();\n }.bind(this));\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Set the scale configuration back into a JSON string in the hidden element.\n *\n * @method setScaleConfig\n */\n ScaleConfig.prototype.setScaleConfig = function() {\n var body = $(this.popup.getContent());\n // Get the data.\n var data = [{scaleid: this.scaleid}];\n this.scalevalues.forEach(function(value) {\n var scaledefault = 0;\n var proficient = 0;\n if (body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').is(':checked')) {\n scaledefault = 1;\n }\n if (body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').is(':checked')) {\n proficient = 1;\n }\n\n if (!scaledefault && !proficient) {\n return;\n }\n\n data.push({\n id: value.id,\n scaledefault: scaledefault,\n proficient: proficient\n });\n });\n var datastring = JSON.stringify(data);\n // Send to the hidden field on the form.\n $(this.inputSelector).val(datastring);\n // Once the configuration has been saved then the original scale ID is set to the current scale ID.\n this.originalscaleid = this.scaleid;\n };\n\n /**\n * Get the scale values for the selected scale.\n *\n * @method getScaleValues\n * @param {Number} scaleid The scale ID of the selected scale.\n * @return {Promise} A deffered object with the scale values.\n */\n ScaleConfig.prototype.getScaleValues = function(scaleid) {\n return ModScaleValues.get_values(scaleid).then(function(values) {\n this.scalevalues = values;\n return values;\n }.bind(this));\n };\n\n /**\n * Triggered when a scale is selected.\n *\n * @name scaleChangeHandler\n * @param {Event} e\n * @function\n */\n ScaleConfig.prototype.scaleChangeHandler = function(e) {\n if ($(e.target).val() <= 0) {\n $(this.triggerSelector).prop('disabled', true);\n } else {\n $(this.triggerSelector).prop('disabled', false);\n }\n\n };\n\n return {\n\n /**\n * Main initialisation.\n *\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n * @return {ScaleConfig} A new instance of ScaleConfig.\n * @method init\n */\n init: function(selectSelector, inputSelector, triggerSelector) {\n return new ScaleConfig(selectSelector, inputSelector, triggerSelector);\n }\n };\n});\n"],"file":"scaleconfig.min.js"} \ No newline at end of file +{"version":3,"file":"scaleconfig.min.js","sources":["../src/scaleconfig.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 * Handle opening a dialogue to configure scale data.\n *\n * @module tool_lp/scaleconfig\n * @copyright 2015 Adrian Greeve \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/templates', 'core/ajax', 'tool_lp/dialogue', 'tool_lp/scalevalues'],\n function($, notification, templates, ajax, Dialogue, ModScaleValues) {\n\n /**\n * Scale config object.\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n */\n var ScaleConfig = function(selectSelector, inputSelector, triggerSelector) {\n this.selectSelector = selectSelector;\n this.inputSelector = inputSelector;\n this.triggerSelector = triggerSelector;\n\n // Get the current scale ID.\n this.originalscaleid = $(selectSelector).val();\n $(selectSelector).on('change', this.scaleChangeHandler.bind(this)).change();\n $(triggerSelector).click(this.showConfig.bind(this));\n };\n\n /** @var {String} The select box selector. */\n ScaleConfig.prototype.selectSelector = null;\n /** @var {String} The hidden field selector. */\n ScaleConfig.prototype.inputSelector = null;\n /** @var {String} The trigger selector. */\n ScaleConfig.prototype.triggerSelector = null;\n /** @var {Array} scalevalues ID and name of the scales. */\n ScaleConfig.prototype.scalevalues = null;\n /** @var {Number) originalscaleid Original scale ID when the page loads. */\n ScaleConfig.prototype.originalscaleid = 0;\n /** @var {Number} scaleid Current scale ID. */\n ScaleConfig.prototype.scaleid = 0;\n /** @var {Dialogue} Reference to the popup. */\n ScaleConfig.prototype.popup = null;\n\n /**\n * Displays the scale configuration dialogue.\n *\n * @method showConfig\n */\n ScaleConfig.prototype.showConfig = function() {\n var self = this;\n\n this.scaleid = $(this.selectSelector).val();\n if (this.scaleid <= 0) {\n // This should not happen.\n return;\n }\n\n var scalename = $(this.selectSelector).find(\"option:selected\").text();\n this.getScaleValues(this.scaleid).done(function() {\n\n var context = {\n scalename: scalename,\n scales: self.scalevalues\n };\n\n // Dish up the form.\n templates.render('tool_lp/scale_configuration_page', context)\n .done(function(html) {\n new Dialogue(\n scalename,\n html,\n self.initScaleConfig.bind(self)\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Gets the original scale configuration if it was set.\n *\n * @method retrieveOriginalScaleConfig\n * @return {Object|String} scale configuration or empty string.\n */\n ScaleConfig.prototype.retrieveOriginalScaleConfig = function() {\n var jsonstring = $(this.inputSelector).val();\n if (jsonstring !== '') {\n var scaleconfiguration = $.parseJSON(jsonstring);\n // The first object should contain the scale ID for the configuration.\n var scaledetail = scaleconfiguration.shift();\n // Check that this scale id matches the one from the page before returning the configuration.\n if (scaledetail.scaleid === this.originalscaleid) {\n return scaleconfiguration;\n }\n }\n return '';\n };\n\n /**\n * Initialises the scale configuration dialogue.\n *\n * @method initScaleConfig\n * @param {Dialogue} popup Dialogue object to initialise.\n */\n ScaleConfig.prototype.initScaleConfig = function(popup) {\n this.popup = popup;\n var body = $(popup.getContent());\n if (this.originalscaleid === this.scaleid) {\n // Set up the popup to show the current configuration.\n var currentconfig = this.retrieveOriginalScaleConfig();\n // Set up the form only if there is configuration settings to set.\n if (currentconfig !== '') {\n currentconfig.forEach(function(value) {\n if (value.scaledefault === 1) {\n body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').attr('checked', true);\n }\n if (value.proficient === 1) {\n body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').attr('checked', true);\n }\n });\n }\n }\n body.on('click', '[data-action=\"close\"]', function() {\n this.setScaleConfig();\n popup.close();\n }.bind(this));\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Set the scale configuration back into a JSON string in the hidden element.\n *\n * @method setScaleConfig\n */\n ScaleConfig.prototype.setScaleConfig = function() {\n var body = $(this.popup.getContent());\n // Get the data.\n var data = [{scaleid: this.scaleid}];\n this.scalevalues.forEach(function(value) {\n var scaledefault = 0;\n var proficient = 0;\n if (body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').is(':checked')) {\n scaledefault = 1;\n }\n if (body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').is(':checked')) {\n proficient = 1;\n }\n\n if (!scaledefault && !proficient) {\n return;\n }\n\n data.push({\n id: value.id,\n scaledefault: scaledefault,\n proficient: proficient\n });\n });\n var datastring = JSON.stringify(data);\n // Send to the hidden field on the form.\n $(this.inputSelector).val(datastring);\n // Once the configuration has been saved then the original scale ID is set to the current scale ID.\n this.originalscaleid = this.scaleid;\n };\n\n /**\n * Get the scale values for the selected scale.\n *\n * @method getScaleValues\n * @param {Number} scaleid The scale ID of the selected scale.\n * @return {Promise} A deffered object with the scale values.\n */\n ScaleConfig.prototype.getScaleValues = function(scaleid) {\n return ModScaleValues.get_values(scaleid).then(function(values) {\n this.scalevalues = values;\n return values;\n }.bind(this));\n };\n\n /**\n * Triggered when a scale is selected.\n *\n * @name scaleChangeHandler\n * @param {Event} e\n * @function\n */\n ScaleConfig.prototype.scaleChangeHandler = function(e) {\n if ($(e.target).val() <= 0) {\n $(this.triggerSelector).prop('disabled', true);\n } else {\n $(this.triggerSelector).prop('disabled', false);\n }\n\n };\n\n return {\n\n /**\n * Main initialisation.\n *\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n * @return {ScaleConfig} A new instance of ScaleConfig.\n * @method init\n */\n init: function(selectSelector, inputSelector, triggerSelector) {\n return new ScaleConfig(selectSelector, inputSelector, triggerSelector);\n }\n };\n});\n"],"names":["define","$","notification","templates","ajax","Dialogue","ModScaleValues","ScaleConfig","selectSelector","inputSelector","triggerSelector","originalscaleid","val","on","this","scaleChangeHandler","bind","change","click","showConfig","prototype","scalevalues","scaleid","popup","self","scalename","find","text","getScaleValues","done","context","scales","render","html","initScaleConfig","fail","exception","retrieveOriginalScaleConfig","jsonstring","scaleconfiguration","parseJSON","shift","body","getContent","currentconfig","forEach","value","scaledefault","id","attr","proficient","setScaleConfig","close","data","is","push","datastring","JSON","stringify","get_values","then","values","e","target","prop","init"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SAAU,oBAAqB,iBAAkB,YAAa,mBAAoB,wBACtF,SAASC,EAAGC,aAAcC,UAAWC,KAAMC,SAAUC,oBAQjDC,YAAc,SAASC,eAAgBC,cAAeC,sBACjDF,eAAiBA,oBACjBC,cAAgBA,mBAChBC,gBAAkBA,qBAGlBC,gBAAkBV,EAAEO,gBAAgBI,MACzCX,EAAEO,gBAAgBK,GAAG,SAAUC,KAAKC,mBAAmBC,KAAKF,OAAOG,SACnEhB,EAAES,iBAAiBQ,MAAMJ,KAAKK,WAAWH,KAAKF,eAIlDP,YAAYa,UAAUZ,eAAiB,KAEvCD,YAAYa,UAAUX,cAAgB,KAEtCF,YAAYa,UAAUV,gBAAkB,KAExCH,YAAYa,UAAUC,YAAc,KAEpCd,YAAYa,UAAUT,gBAAkB,EAExCJ,YAAYa,UAAUE,QAAU,EAEhCf,YAAYa,UAAUG,MAAQ,KAO9BhB,YAAYa,UAAUD,WAAa,eAC3BK,KAAOV,aAENQ,QAAUrB,EAAEa,KAAKN,gBAAgBI,QAClCE,KAAKQ,SAAW,QAKhBG,UAAYxB,EAAEa,KAAKN,gBAAgBkB,KAAK,mBAAmBC,YAC1DC,eAAed,KAAKQ,SAASO,MAAK,eAE/BC,QAAU,CACVL,UAAWA,UACXM,OAAQP,KAAKH,aAIjBlB,UA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AAUL,MAEhCpD,EAAEa,KAAKL,eAAeG,IAAI4C,iBAErB7C,gBAAkBG,KAAKQ,SAUhCf,YAAYa,UAAUQ,eAAiB,SAASN,gBACrChB,eAAeqD,WAAWrC,SAASsC,KAAK,SAASC,oBAC/CxC,YAAcwC,OACZA,QACT7C,KAAKF,QAUXP,YAAYa,UAAUL,mBAAqB,SAAS+C,GAC5C7D,EAAE6D,EAAEC,QAAQnD,OAAS,EACrBX,EAAEa,KAAKJ,iBAAiBsD,KAAK,YAAY,GAEzC/D,EAAEa,KAAKJ,iBAAiBsD,KAAK,YAAY,IAK1C,CAWHC,KAAM,SAASzD,eAAgBC,cAAeC,wBACnC,IAAIH,YAAYC,eAAgBC,cAAeC"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/scalevalues.min.js b/admin/tool/lp/amd/build/scalevalues.min.js index 637c17fb289..dd1d78ea291 100644 --- a/admin/tool/lp/amd/build/scalevalues.min.js +++ b/admin/tool/lp/amd/build/scalevalues.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/scalevalues",["jquery","core/ajax"],function(a,b){var c=[];return{get_values:function get_values(d){var e=a.Deferred();if("undefined"==typeof c[d]){b.call([{methodname:"core_competency_get_scale_values",args:{scaleid:d},done:function done(a){c[d]=a;e.resolve(a)},fail:e.reject}])}else{e.resolve(c[d])}return e.promise()}}}); -//# sourceMappingURL=scalevalues.min.js.map +/** + * Module to get the scale values. + * + * @module tool_lp/scalevalues + * @copyright 2016 Serge Gauthier + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/scalevalues",["jquery","core/ajax"],(function($,ajax){var localCache=[];return{get_values:function(scaleid){var deferred=$.Deferred();return void 0===localCache[scaleid]?ajax.call([{methodname:"core_competency_get_scale_values",args:{scaleid:scaleid},done:function(scaleinfo){localCache[scaleid]=scaleinfo,deferred.resolve(scaleinfo)},fail:deferred.reject}]):deferred.resolve(localCache[scaleid]),deferred.promise()}}})); + +//# sourceMappingURL=scalevalues.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/scalevalues.min.js.map b/admin/tool/lp/amd/build/scalevalues.min.js.map index d652b9fb38d..f15ca392296 100644 --- a/admin/tool/lp/amd/build/scalevalues.min.js.map +++ b/admin/tool/lp/amd/build/scalevalues.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/scalevalues.js"],"names":["define","$","ajax","localCache","get_values","scaleid","deferred","Deferred","call","methodname","args","done","scaleinfo","resolve","fail","reject","promise"],"mappings":"AAsBAA,OAAM,uBAAC,CAAC,QAAD,CAAW,WAAX,CAAD,CAA0B,SAASC,CAAT,CAAYC,CAAZ,CAAkB,CAC9C,GAAIC,CAAAA,CAAU,CAAG,EAAjB,CAEA,MAAO,CAUHC,UAAU,CAAE,oBAASC,CAAT,CAAkB,CAE1B,GAAIC,CAAAA,CAAQ,CAAGL,CAAC,CAACM,QAAF,EAAf,CAEA,GAAmC,WAA/B,QAAOJ,CAAAA,CAAU,CAACE,CAAD,CAArB,CAAgD,CAC5CH,CAAI,CAACM,IAAL,CAAU,CAAC,CACPC,UAAU,CAAE,kCADL,CAEPC,IAAI,CAAE,CAACL,OAAO,CAAEA,CAAV,CAFC,CAGPM,IAAI,CAAE,cAASC,CAAT,CAAoB,CACtBT,CAAU,CAACE,CAAD,CAAV,CAAsBO,CAAtB,CACAN,CAAQ,CAACO,OAAT,CAAiBD,CAAjB,CACH,CANM,CAOPE,IAAI,CAAGR,CAAQ,CAACS,MAPT,CAAD,CAAV,CASH,CAVD,IAUO,CACHT,CAAQ,CAACO,OAAT,CAAiBV,CAAU,CAACE,CAAD,CAA3B,CACH,CAED,MAAOC,CAAAA,CAAQ,CAACU,OAAT,EACV,CA7BE,CA+BV,CAlCK,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 * Module to get the scale values.\n *\n * @module tool_lp/scalevalues\n * @copyright 2016 Serge Gauthier\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax'], function($, ajax) {\n var localCache = [];\n\n return {\n\n /**\n * Return a promise object that will be resolved into a string eventually (maybe immediately).\n *\n * @method get_values\n * @param {Number} scaleid The scale id\n * @return [] {Promise}\n */\n // eslint-disable-next-line camelcase\n get_values: function(scaleid) {\n\n var deferred = $.Deferred();\n\n if (typeof localCache[scaleid] === 'undefined') {\n ajax.call([{\n methodname: 'core_competency_get_scale_values',\n args: {scaleid: scaleid},\n done: function(scaleinfo) {\n localCache[scaleid] = scaleinfo;\n deferred.resolve(scaleinfo);\n },\n fail: (deferred.reject)\n }]);\n } else {\n deferred.resolve(localCache[scaleid]);\n }\n\n return deferred.promise();\n }\n };\n});\n"],"file":"scalevalues.min.js"} \ No newline at end of file +{"version":3,"file":"scalevalues.min.js","sources":["../src/scalevalues.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 to get the scale values.\n *\n * @module tool_lp/scalevalues\n * @copyright 2016 Serge Gauthier\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax'], function($, ajax) {\n var localCache = [];\n\n return {\n\n /**\n * Return a promise object that will be resolved into a string eventually (maybe immediately).\n *\n * @method get_values\n * @param {Number} scaleid The scale id\n * @return [] {Promise}\n */\n // eslint-disable-next-line camelcase\n get_values: function(scaleid) {\n\n var deferred = $.Deferred();\n\n if (typeof localCache[scaleid] === 'undefined') {\n ajax.call([{\n methodname: 'core_competency_get_scale_values',\n args: {scaleid: scaleid},\n done: function(scaleinfo) {\n localCache[scaleid] = scaleinfo;\n deferred.resolve(scaleinfo);\n },\n fail: (deferred.reject)\n }]);\n } else {\n deferred.resolve(localCache[scaleid]);\n }\n\n return deferred.promise();\n }\n };\n});\n"],"names":["define","$","ajax","localCache","get_values","scaleid","deferred","Deferred","call","methodname","args","done","scaleinfo","resolve","fail","reject","promise"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SAAU,cAAc,SAASC,EAAGC,UACpCC,WAAa,SAEV,CAUHC,WAAY,SAASC,aAEbC,SAAWL,EAAEM,uBAEkB,IAAxBJ,WAAWE,SAClBH,KAAKM,KAAK,CAAC,CACPC,WAAY,mCACZC,KAAM,CAACL,QAASA,SAChBM,KAAM,SAASC,WACXT,WAAWE,SAAWO,UACtBN,SAASO,QAAQD,YAErBE,KAAOR,SAASS,UAGpBT,SAASO,QAAQV,WAAWE,UAGzBC,SAASU"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/templateactions.min.js b/admin/tool/lp/amd/build/templateactions.min.js index e57f9618e1c..1c72cff04d6 100644 --- a/admin/tool/lp/amd/build/templateactions.min.js +++ b/admin/tool/lp/amd/build/templateactions.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/templateactions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/actionselector"],function(a,b,c,d,e,f){var g=0,h=0,i=!0,j=function(c,d){a("[data-region=\"managetemplates\"]").replaceWith(c);b.runTemplateJS(d)},k=function(a){b.render("tool_lp/manage_templates_page",a).done(j).fail(d.exception)},l=function(){var a=c.call([{methodname:"core_competency_delete_template",args:{id:h,deleteplans:i}},{methodname:"tool_lp_data_for_templates_manage_page",args:{pagecontext:{contextid:g}}}]);a[1].done(k).fail(d.exception)},m=function(b){b.preventDefault();h=a(this).attr("data-templateid");var e=c.call([{methodname:"core_competency_duplicate_template",args:{id:h}},{methodname:"tool_lp_data_for_templates_manage_page",args:{pagecontext:{contextid:g}}}]);e[1].done(k).fail(d.exception)},n=function(b){b.preventDefault();var g=a(this).attr("data-templateid");h=g;i=!0;var j=c.call([{methodname:"core_competency_read_template",args:{id:h}},{methodname:"core_competency_template_has_related_data",args:{id:h}}]);j[0].done(function(a){j[1].done(function(b){if(b){e.get_strings([{key:"deletetemplate",component:"tool_lp",param:a.shortname},{key:"deletetemplatewithplans",component:"tool_lp"},{key:"deleteplans",component:"tool_lp"},{key:"unlinkplanstemplate",component:"tool_lp"},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){var b=[{text:a[2],value:"delete"},{text:a[3],value:"unlink"}],c=new f(a[0],a[1],b,a[4],a[5]);c.display();c.on("save",function(a,b){if("delete"!=b.action){i=!1}l()})}).fail(d.exception)}else{e.get_strings([{key:"confirm",component:"moodle"},{key:"deletetemplate",component:"tool_lp",param:a.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],l)}).fail(d.exception)}}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:n,duplicateHandler:m,init:function init(a){g=a}}}); -//# sourceMappingURL=templateactions.min.js.map +/** + * Handle actions on learning plan templates via ajax. + * + * @module tool_lp/templateactions + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/templateactions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/actionselector"],(function($,templates,ajax,notification,str,Actionselector){var pagecontextid=0,templateid=0,deleteplans=!0,updatePage=function(newhtml,newjs){$('[data-region="managetemplates"]').replaceWith(newhtml),templates.runTemplateJS(newjs)},reloadList=function(context){templates.render("tool_lp/manage_templates_page",context).done(updatePage).fail(notification.exception)},doDelete=function(){ajax.call([{methodname:"core_competency_delete_template",args:{id:templateid,deleteplans:deleteplans}},{methodname:"tool_lp_data_for_templates_manage_page",args:{pagecontext:{contextid:pagecontextid}}}])[1].done(reloadList).fail(notification.exception)};return{deleteHandler:function(e){e.preventDefault();var id=$(this).attr("data-templateid");templateid=id,deleteplans=!0;var requests=ajax.call([{methodname:"core_competency_read_template",args:{id:templateid}},{methodname:"core_competency_template_has_related_data",args:{id:templateid}}]);requests[0].done((function(template){requests[1].done((function(templatehasrelateddata){templatehasrelateddata?str.get_strings([{key:"deletetemplate",component:"tool_lp",param:template.shortname},{key:"deletetemplatewithplans",component:"tool_lp"},{key:"deleteplans",component:"tool_lp"},{key:"unlinkplanstemplate",component:"tool_lp"},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){var actions=[{text:strings[2],value:"delete"},{text:strings[3],value:"unlink"}],actionselector=new Actionselector(strings[0],strings[1],actions,strings[4],strings[5]);actionselector.display(),actionselector.on("save",(function(e,data){"delete"!=data.action&&(deleteplans=!1),doDelete()}))})).fail(notification.exception):str.get_strings([{key:"confirm",component:"moodle"},{key:"deletetemplate",component:"tool_lp",param:template.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],doDelete)})).fail(notification.exception)})).fail(notification.exception)})).fail(notification.exception)},duplicateHandler:function(e){e.preventDefault(),templateid=$(this).attr("data-templateid"),ajax.call([{methodname:"core_competency_duplicate_template",args:{id:templateid}},{methodname:"tool_lp_data_for_templates_manage_page",args:{pagecontext:{contextid:pagecontextid}}}])[1].done(reloadList).fail(notification.exception)},init:function(contextid){pagecontextid=contextid}}})); + +//# sourceMappingURL=templateactions.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/templateactions.min.js.map b/admin/tool/lp/amd/build/templateactions.min.js.map index cbcfd077d8d..6c72d2794ca 100644 --- a/admin/tool/lp/amd/build/templateactions.min.js.map +++ b/admin/tool/lp/amd/build/templateactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/templateactions.js"],"names":["define","$","templates","ajax","notification","str","Actionselector","pagecontextid","templateid","deleteplans","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDelete","requests","call","methodname","args","id","pagecontext","contextid","doDuplicate","e","preventDefault","attr","confirmDelete","template","templatehasrelateddata","get_strings","key","component","param","shortname","strings","actions","actionselector","display","on","data","action","confirm","deleteHandler","duplicateHandler","init"],"mappings":"AAsBAA,OAAM,2BAAC,CAAC,QAAD,CAAW,gBAAX,CAA6B,WAA7B,CAA0C,mBAA1C,CAA+D,UAA/D,CAA2E,wBAA3E,CAAD,CACC,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAA6BC,CAA7B,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAgE,IAI/DC,CAAAA,CAAa,CAAG,CAJ+C,CAO/DC,CAAU,CAAG,CAPkD,CAU/DC,CAAW,GAVoD,CAmB/DC,CAAU,CAAG,SAASC,CAAT,CAAkBC,CAAlB,CAAyB,CACtCX,CAAC,CAAC,mCAAD,CAAD,CAAqCY,WAArC,CAAiDF,CAAjD,EACAT,CAAS,CAACY,aAAV,CAAwBF,CAAxB,CACH,CAtBkE,CA8B/DG,CAAU,CAAG,SAASC,CAAT,CAAkB,CAC/Bd,CAAS,CAACe,MAAV,CAAiB,+BAAjB,CAAkDD,CAAlD,EACKE,IADL,CACUR,CADV,EAEKS,IAFL,CAEUf,CAAY,CAACgB,SAFvB,CAGH,CAlCkE,CAwC/DC,CAAQ,CAAG,UAAW,CAGtB,GAAIC,CAAAA,CAAQ,CAAGnB,CAAI,CAACoB,IAAL,CAAU,CAAC,CACtBC,UAAU,CAAE,iCADU,CAEtBC,IAAI,CAAE,CAACC,EAAE,CAAElB,CAAL,CACEC,WAAW,CAAEA,CADf,CAFgB,CA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zBtC,CAAW,GACd,CACDY,CAAQ,EACX,CALD,CAMH,CAvBD,EAuBGF,IAvBH,CAuBQf,CAAY,CAACgB,SAvBrB,CAwBH,CAzBD,IAyBO,CACHf,CAAG,CAAC+B,WAAJ,CAAgB,CACZ,CAACC,GAAG,CAAE,SAAN,CAAiBC,SAAS,CAAE,QAA5B,CADY,CAEZ,CAACD,GAAG,CAAE,gBAAN,CAAwBC,SAAS,CAAE,SAAnC,CAA8CC,KAAK,CAAEL,CAAQ,CAACM,SAA9D,CAFY,CAGZ,CAACH,GAAG,CAAE,QAAN,CAAgBC,SAAS,CAAE,QAA3B,CAHY,CAIZ,CAACD,GAAG,CAAE,QAAN,CAAgBC,SAAS,CAAE,QAA3B,CAJY,CAAhB,EAKGpB,IALH,CAKQ,SAASuB,CAAT,CAAkB,CACtBrC,CAAY,CAAC4C,OAAb,CACAP,CAAO,CAAC,CAAD,CADP,CAEAA,CAAO,CAAC,CAAD,CAFP,CAGAA,CAAO,CAAC,CAAD,CAHP,CAIAA,CAAO,CAAC,CAAD,CAJP,CAKApB,CALA,CAOH,CAbD,EAaGF,IAbH,CAaQf,CAAY,CAACgB,SAbrB,CAcH,CACJ,CA1CD,EA0CGD,IA1CH,CA0CQf,CAAY,CAACgB,SA1CrB,CA2CH,CA5CD,EA4CGD,IA5CH,CA4CQf,CAAY,CAACgB,SA5CrB,CA8CH,CArJkE,CAuJnE,MAAoD,CAOhD6B,aAAa,CAAEhB,CAPiC,CAchDiB,gBAAgB,CAAErB,CAd8B,CAqBhDsB,IAAI,CAAE,cAASvB,CAAT,CAAoB,CACtBrB,CAAa,CAAGqB,CACnB,CAvB+C,CAyBvD,CAjLK,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 * Handle actions on learning plan templates via ajax.\n *\n * @module tool_lp/templateactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str', 'tool_lp/actionselector'],\n function($, templates, ajax, notification, str, Actionselector) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} templateid The id of the template */\n var templateid = 0;\n\n /** @var {Boolean} Action to apply to plans when deleting a template */\n var deleteplans = true;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @method updatePage\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managetemplates\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @method reloadList\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_templates_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Delete a template and reload the page.\n * @method doDelete\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_template',\n args: {id: templateid,\n deleteplans: deleteplans}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Duplicate a template and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n templateid = $(this).attr('data-templateid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_template',\n args: {id: templateid}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete learning plan template\" actions.\n * @method confirmDelete\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-templateid');\n templateid = id;\n deleteplans = true;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_template',\n args: {id: templateid}\n }, {\n methodname: 'core_competency_template_has_related_data',\n args: {id: templateid}\n }]);\n\n requests[0].done(function(template) {\n requests[1].done(function(templatehasrelateddata) {\n if (templatehasrelateddata) {\n str.get_strings([\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'deletetemplatewithplans', component: 'tool_lp'},\n {key: 'deleteplans', component: 'tool_lp'},\n {key: 'unlinkplanstemplate', component: 'tool_lp'},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n var actions = [{'text': strings[2], 'value': 'delete'},\n {'text': strings[3], 'value': 'unlink'}];\n var actionselector = new Actionselector(\n strings[0], // Title.\n strings[1], // Message\n actions, // Radio button options.\n strings[4], // Confirm.\n strings[5]); // Cancel.\n actionselector.display();\n actionselector.on('save', function(e, data) {\n if (data.action != 'delete') {\n deleteplans = false;\n }\n doDelete();\n });\n }).fail(notification.exception);\n } else {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete learning plan template X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n return /** @alias module:tool_lp/templateactions */ {\n // Public variables and functions.\n /**\n * Expose the event handler for the delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for the duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"file":"templateactions.min.js"} \ No newline at end of file +{"version":3,"file":"templateactions.min.js","sources":["../src/templateactions.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 * Handle actions on learning plan templates via ajax.\n *\n * @module tool_lp/templateactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str', 'tool_lp/actionselector'],\n function($, templates, ajax, notification, str, Actionselector) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} templateid The id of the template */\n var templateid = 0;\n\n /** @var {Boolean} Action to apply to plans when deleting a template */\n var deleteplans = true;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @method updatePage\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managetemplates\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @method reloadList\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_templates_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Delete a template and reload the page.\n * @method doDelete\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_template',\n args: {id: templateid,\n deleteplans: deleteplans}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Duplicate a template and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n templateid = $(this).attr('data-templateid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_template',\n args: {id: templateid}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete learning plan template\" actions.\n * @method confirmDelete\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-templateid');\n templateid = id;\n deleteplans = true;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_template',\n args: {id: templateid}\n }, {\n methodname: 'core_competency_template_has_related_data',\n args: {id: templateid}\n }]);\n\n requests[0].done(function(template) {\n requests[1].done(function(templatehasrelateddata) {\n if (templatehasrelateddata) {\n str.get_strings([\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'deletetemplatewithplans', component: 'tool_lp'},\n {key: 'deleteplans', component: 'tool_lp'},\n {key: 'unlinkplanstemplate', component: 'tool_lp'},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n var actions = [{'text': strings[2], 'value': 'delete'},\n {'text': strings[3], 'value': 'unlink'}];\n var actionselector = new Actionselector(\n strings[0], // Title.\n strings[1], // Message\n actions, // Radio button options.\n strings[4], // Confirm.\n strings[5]); // Cancel.\n actionselector.display();\n actionselector.on('save', function(e, data) {\n if (data.action != 'delete') {\n deleteplans = false;\n }\n doDelete();\n });\n }).fail(notification.exception);\n } else {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete learning plan template X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n return /** @alias module:tool_lp/templateactions */ {\n // Public variables and functions.\n /**\n * Expose the event handler for the delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for the duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"names":["define","$","templates","ajax","notification","str","Actionselector","pagecontextid","templateid","deleteplans","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDelete","call","methodname","args","id","pagecontext","contextid","deleteHandler","e","preventDefault","this","attr","requests","template","templatehasrelateddata","get_strings","key","component","param","shortname","strings","actions","actionselector","display","on","data","action","confirm","duplicateHandler","init"],"mappings":";;;;;;;AAsBAA,iCAAO,CAAC,SAAU,iBAAkB,YAAa,oBAAqB,WAAY,2BAC3E,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,oBAI/CC,cAAgB,EAGhBC,WAAa,EAGbC,aAAc,EASdC,WAAa,SAASC,QAASC,OAC/BX,EAAE,mCAAmCY,YAAYF,SACjDT,UAAUY,cAAcF,QASxBG,WAAa,SAASC,SACtBd,UAAUe,OAAO,gCAAiCD,SAC7CE,KAAKR,YACLS,KA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AC5BpB,MAAK,SAASuB,SACbrC,aAAa4C,QACbP,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRpB,aAEDF,KAAKf,aAAagB,cAE1BD,KAAKf,aAAagB,cACtBD,KAAKf,aAAagB,YAkBrB6B,iBAtGc,SAASpB,GACvBA,EAAEC,iBAEFtB,WAAaP,EAAE8B,MAAMC,KAAK,mBAGX7B,KAAKmB,KAAK,CAAC,CACtBC,WAAY,qCACZC,KAAM,CAACC,GAAIjB,aACZ,CACCe,WAAY,yCACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAId,GAAGW,KAAKH,YAAYI,KAAKf,aAAagB,YA4F/C8B,KAAM,SAASvB,WACXpB,cAAgBoB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/tree.min.js b/admin/tool/lp/amd/build/tree.min.js index a5a4ecd4449..d6d373a1320 100644 --- a/admin/tool/lp/amd/build/tree.min.js +++ b/admin/tool/lp/amd/build/tree.min.js @@ -1,2 +1,15 @@ -define ("tool_lp/tree",["jquery","core/url","core/log"],function(a,b,c){var d=a("\"\""),e=a("\"\""),f=function(b,c){this.treeRoot=a(b);this.multiSelect="undefined"==typeof c||!0===c;this.items=this.treeRoot.find("li");this.expandAll=20>this.items.length;this.parents=this.treeRoot.find("li:has(ul)");if(c){this.treeRoot.attr("aria-multiselectable","true")}this.items.attr("aria-selected","false");this.visibleItems=null;this.activeItem=null;this.lastActiveItem=null;this.keys={tab:9,enter:13,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,eight:56,asterisk:106};this.init();this.bindEventHandlers()};f.prototype.init=function(){this.parents.attr("aria-expanded","true");this.parents.prepend(d.clone());this.items.attr("role","tree-item");this.items.attr("tabindex","-1");this.parents.attr("role","group");this.treeRoot.attr("role","tree");this.visibleItems=this.treeRoot.find("li");var b=this;if(!this.expandAll){this.parents.each(function(){b.collapseGroup(a(this))});this.expandGroup(this.parents.first())}};f.prototype.expandGroup=function(a){var b=a.children("ul");b.show().attr("aria-hidden","false");a.attr("aria-expanded","true");a.children("img").attr("src",d.attr("src"));this.visibleItems=this.treeRoot.find("li:visible")};f.prototype.collapseGroup=function(a){var b=a.children("ul");b.hide().attr("aria-hidden","true");a.attr("aria-expanded","false");a.children("img").attr("src",e.attr("src"));this.visibleItems=this.treeRoot.find("li:visible")};f.prototype.toggleGroup=function(a){if("true"==a.attr("aria-expanded")){this.collapseGroup(a)}else{this.expandGroup(a)}};f.prototype.triggerChange=function(){var a=this.items.filter("[aria-selected=true]");if(!this.multiSelect){a=a.first()}this.treeRoot.trigger("selectionchanged",{selected:a})};f.prototype.multiSelectItem=function(b){if(!this.multiSelect){this.items.attr("aria-selected","false")}else if(null!==this.lastActiveItem){var c=this.visibleItems.index(this.lastActiveItem),d=this.visibleItems.index(this.activeItem),e=null;while(cd){e=a(this.visibleItems.get(c));e.attr("aria-selected","true");c--}}b.attr("aria-selected","true");this.triggerChange()};f.prototype.selectItem=function(a){var b=a.parent();while("tree"!=b.attr("role")){b=b.parent();if("false"==b.attr("aria-expanded")){this.expandGroup(b)}b=b.parent()}this.items.attr("aria-selected","false");a.attr("aria-selected","true");this.triggerChange()};f.prototype.toggleItem=function(a){if(!this.multiSelect){this.selectItem(a);return}var b=a.attr("aria-selected");if("true"===b){b="false"}else{b="true"}a.attr("aria-selected",b);this.triggerChange()};f.prototype.updateFocus=function(a){this.lastActiveItem=this.activeItem;this.activeItem=a;var b=a.parent();while("tree"!=b.attr("role")){b=b.parent();if("false"==b.attr("aria-expanded")){this.expandGroup(b)}b=b.parent()}this.items.attr("tabindex","-1");a.attr("tabindex",0)};f.prototype.handleKeyDown=function(b,c){var d=this.visibleItems.index(b),e=null,f=c.shiftKey||c.ctrlKey||c.metaKey||c.altKey,g=this;switch(c.keyCode){case this.keys.home:{e=this.parents.first();e.focus();if(c.shiftKey){this.multiSelectItem(e)}else if(!f){this.selectItem(e)}c.stopPropagation();return!1}case this.keys.end:{e=this.visibleItems.last();e.focus();if(c.shiftKey){this.multiSelectItem(e)}else if(!f){this.selectItem(e)}c.stopPropagation();return!1}case this.keys.enter:case this.keys.space:{if(c.shiftKey){this.multiSelectItem(b)}else if(c.metaKey||c.ctrlKey){this.toggleItem(b)}else{this.selectItem(b)}c.stopPropagation();return!1}case this.keys.left:{if(b.has("ul")&&"true"==b.attr("aria-expanded")){this.collapseGroup(b)}else{var h=b.parent(),i=h.parent();if(i.is("li")){i.focus();if(c.shiftKey){this.multiSelectItem(i)}else if(!f){this.selectItem(i)}}}c.stopPropagation();return!1}case this.keys.right:{if(b.has("ul")&&"false"==b.attr("aria-expanded")){this.expandGroup(b)}else{e=b.children("ul").children("li").first();if(0 + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/tree",["jquery","core/url","core/log"],(function($,url,log){var expandedImage=$(''),collapsedImage=$(''),Tree=function(selector,multiSelect){this.treeRoot=$(selector),this.multiSelect=void 0===multiSelect||!0===multiSelect,this.items=this.treeRoot.find("li"),this.expandAll=this.items.length<20,this.parents=this.treeRoot.find("li:has(ul)"),multiSelect&&this.treeRoot.attr("aria-multiselectable","true"),this.items.attr("aria-selected","false"),this.visibleItems=null,this.activeItem=null,this.lastActiveItem=null,this.keys={tab:9,enter:13,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,eight:56,asterisk:106},this.init(),this.bindEventHandlers()};return Tree.prototype.init=function(){this.parents.attr("aria-expanded","true"),this.parents.prepend(expandedImage.clone()),this.items.attr("role","tree-item"),this.items.attr("tabindex","-1"),this.parents.attr("role","group"),this.treeRoot.attr("role","tree"),this.visibleItems=this.treeRoot.find("li");var thisObj=this;this.expandAll||(this.parents.each((function(){thisObj.collapseGroup($(this))})),this.expandGroup(this.parents.first()))},Tree.prototype.expandGroup=function(item){item.children("ul").show().attr("aria-hidden","false"),item.attr("aria-expanded","true"),item.children("img").attr("src",expandedImage.attr("src")),this.visibleItems=this.treeRoot.find("li:visible")},Tree.prototype.collapseGroup=function(item){item.children("ul").hide().attr("aria-hidden","true"),item.attr("aria-expanded","false"),item.children("img").attr("src",collapsedImage.attr("src")),this.visibleItems=this.treeRoot.find("li:visible")},Tree.prototype.toggleGroup=function(item){"true"==item.attr("aria-expanded")?this.collapseGroup(item):this.expandGroup(item)},Tree.prototype.triggerChange=function(){var allSelected=this.items.filter("[aria-selected=true]");this.multiSelect||(allSelected=allSelected.first()),this.treeRoot.trigger("selectionchanged",{selected:allSelected})},Tree.prototype.multiSelectItem=function(item){if(this.multiSelect){if(null!==this.lastActiveItem){for(var lastIndex=this.visibleItems.index(this.lastActiveItem),currentIndex=this.visibleItems.index(this.activeItem);lastIndexcurrentIndex;)$(this.visibleItems.get(lastIndex)).attr("aria-selected","true"),lastIndex--}}else this.items.attr("aria-selected","false");item.attr("aria-selected","true"),this.triggerChange()},Tree.prototype.selectItem=function(item){for(var walk=item.parent();"tree"!=walk.attr("role");)"false"==(walk=walk.parent()).attr("aria-expanded")&&this.expandGroup(walk),walk=walk.parent();this.items.attr("aria-selected","false"),item.attr("aria-selected","true"),this.triggerChange()},Tree.prototype.toggleItem=function(item){if(this.multiSelect){var current=item.attr("aria-selected");current="true"===current?"false":"true",item.attr("aria-selected",current),this.triggerChange()}else this.selectItem(item)},Tree.prototype.updateFocus=function(item){this.lastActiveItem=this.activeItem,this.activeItem=item;for(var walk=item.parent();"tree"!=walk.attr("role");)"false"==(walk=walk.parent()).attr("aria-expanded")&&this.expandGroup(walk),walk=walk.parent();this.items.attr("tabindex","-1"),item.attr("tabindex",0)},Tree.prototype.handleKeyDown=function(item,e){var currentIndex=this.visibleItems.index(item),newItem=null,hasKeyModifier=e.shiftKey||e.ctrlKey||e.metaKey||e.altKey,thisObj=this;switch(e.keyCode){case this.keys.home:return(newItem=this.parents.first()).focus(),e.shiftKey?this.multiSelectItem(newItem):hasKeyModifier||this.selectItem(newItem),e.stopPropagation(),!1;case this.keys.end:return(newItem=this.visibleItems.last()).focus(),e.shiftKey?this.multiSelectItem(newItem):hasKeyModifier||this.selectItem(newItem),e.stopPropagation(),!1;case this.keys.enter:case this.keys.space:return e.shiftKey?this.multiSelectItem(item):e.metaKey||e.ctrlKey?this.toggleItem(item):this.selectItem(item),e.stopPropagation(),!1;case this.keys.left:if(item.has("ul")&&"true"==item.attr("aria-expanded"))this.collapseGroup(item);else{var itemParent=item.parent().parent();itemParent.is("li")&&(itemParent.focus(),e.shiftKey?this.multiSelectItem(itemParent):hasKeyModifier||this.selectItem(itemParent))}return e.stopPropagation(),!1;case this.keys.right:return item.has("ul")&&"false"==item.attr("aria-expanded")?this.expandGroup(item):(newItem=item.children("ul").children("li").first()).length>0&&(newItem.focus(),e.shiftKey?this.multiSelectItem(newItem):hasKeyModifier||this.selectItem(newItem)),e.stopPropagation(),!1;case this.keys.up:if(currentIndex>0){var prev=this.visibleItems.eq(currentIndex-1);prev.focus(),e.shiftKey?this.multiSelectItem(prev):hasKeyModifier||this.selectItem(prev)}return e.stopPropagation(),!1;case this.keys.down:if(currentIndex.\n\n/**\n * Implement an accessible aria tree widget, from a nested unordered list.\n * Based on http://oaa-accessibility.org/example/41/\n *\n * To respond to selection changed events - use tree.on(\"selectionchanged\", handler).\n * The handler will receive an array of nodes, which are the list items that are currently\n * selected. (Or a single node if multiselect is disabled).\n *\n * @module tool_lp/tree\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/url', 'core/log'], function($, url, log) {\n // Private variables and functions.\n /** @var {String} expandedImage The html for an expanded tree node twistie. */\n var expandedImage = $('\"\"');\n /** @var {String} collapsedImage The html for a collapsed tree node twistie. */\n var collapsedImage = $('\"\"');\n\n /**\n * Constructor\n *\n * @param {String} selector\n * @param {Boolean} multiSelect\n */\n var Tree = function(selector, multiSelect) {\n this.treeRoot = $(selector);\n this.multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n\n this.items = this.treeRoot.find('li');\n this.expandAll = this.items.length < 20;\n this.parents = this.treeRoot.find('li:has(ul)');\n\n if (multiSelect) {\n this.treeRoot.attr('aria-multiselectable', 'true');\n }\n\n this.items.attr('aria-selected', 'false');\n\n this.visibleItems = null;\n this.activeItem = null;\n this.lastActiveItem = null;\n\n this.keys = {\n tab: 9,\n enter: 13,\n space: 32,\n pageup: 33,\n pagedown: 34,\n end: 35,\n home: 36,\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n eight: 56,\n asterisk: 106\n };\n\n this.init();\n\n this.bindEventHandlers();\n };\n // Public variables and functions.\n\n /**\n * Init this tree\n * @method init\n */\n Tree.prototype.init = function() {\n this.parents.attr('aria-expanded', 'true');\n this.parents.prepend(expandedImage.clone());\n\n this.items.attr('role', 'tree-item');\n this.items.attr('tabindex', '-1');\n this.parents.attr('role', 'group');\n this.treeRoot.attr('role', 'tree');\n\n this.visibleItems = this.treeRoot.find('li');\n\n var thisObj = this;\n if (!this.expandAll) {\n this.parents.each(function() {\n thisObj.collapseGroup($(this));\n });\n this.expandGroup(this.parents.first());\n }\n };\n\n /**\n * Expand a collapsed group.\n *\n * @method expandGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.expandGroup = function(item) {\n // Find the first child ul node.\n var group = item.children('ul');\n\n // Expand the group.\n group.show().attr('aria-hidden', 'false');\n\n item.attr('aria-expanded', 'true');\n\n item.children('img').attr('src', expandedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Collapse an expanded group.\n *\n * @method collapseGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.collapseGroup = function(item) {\n var group = item.children('ul');\n\n // Collapse the group.\n group.hide().attr('aria-hidden', 'true');\n\n item.attr('aria-expanded', 'false');\n\n item.children('img').attr('src', collapsedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Expand or collapse a group.\n *\n * @method toggleGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.toggleGroup = function(item) {\n if (item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n this.expandGroup(item);\n }\n };\n\n /**\n * Whenever the currently selected node has changed, trigger an event using this function.\n *\n * @method triggerChange\n */\n Tree.prototype.triggerChange = function() {\n var allSelected = this.items.filter('[aria-selected=true]');\n if (!this.multiSelect) {\n allSelected = allSelected.first();\n }\n this.treeRoot.trigger('selectionchanged', {selected: allSelected});\n };\n\n /**\n * Select all the items between the last focused item and this currently focused item.\n *\n * @method multiSelectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.multiSelectItem = function(item) {\n if (!this.multiSelect) {\n this.items.attr('aria-selected', 'false');\n } else if (this.lastActiveItem !== null) {\n var lastIndex = this.visibleItems.index(this.lastActiveItem);\n var currentIndex = this.visibleItems.index(this.activeItem);\n var oneItem = null;\n\n while (lastIndex < currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex++;\n }\n while (lastIndex > currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex--;\n }\n }\n\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Select a single item. Make sure all the parents are expanded. De-select all other items.\n *\n * @method selectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.selectItem = function(item) {\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('aria-selected', 'false');\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Toggle the selected state for an item back and forth.\n *\n * @method toggleItem\n * @param {Object} item is the jquery id of the item to toggle.\n */\n Tree.prototype.toggleItem = function(item) {\n if (!this.multiSelect) {\n this.selectItem(item);\n return;\n }\n\n var current = item.attr('aria-selected');\n if (current === 'true') {\n current = 'false';\n } else {\n current = 'true';\n }\n item.attr('aria-selected', current);\n this.triggerChange();\n };\n\n /**\n * Set the focus to this item.\n *\n * @method updateFocus\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.updateFocus = function(item) {\n this.lastActiveItem = this.activeItem;\n this.activeItem = item;\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('tabindex', '-1');\n item.attr('tabindex', 0);\n };\n\n /**\n * Handle a key down event - ie navigate the tree.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n // This function should be simplified. In the meantime..\n // eslint-disable-next-line complexity\n Tree.prototype.handleKeyDown = function(item, e) {\n var currentIndex = this.visibleItems.index(item);\n var newItem = null;\n var hasKeyModifier = e.shiftKey || e.ctrlKey || e.metaKey || e.altKey;\n var thisObj = this;\n\n switch (e.keyCode) {\n case this.keys.home: {\n // Jump to first item in tree.\n newItem = this.parents.first();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.end: {\n // Jump to last visible item.\n newItem = this.visibleItems.last();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.left: {\n if (item.has('ul') && item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n // Move up to the parent.\n var itemUL = item.parent();\n var itemParent = itemUL.parent();\n if (itemParent.is('li')) {\n itemParent.focus();\n if (e.shiftKey) {\n this.multiSelectItem(itemParent);\n } else if (!hasKeyModifier) {\n this.selectItem(itemParent);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n if (item.has('ul') && item.attr('aria-expanded') == 'false') {\n this.expandGroup(item);\n } else {\n // Move to the first item in the child group.\n newItem = item.children('ul').children('li').first();\n if (newItem.length > 0) {\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n if (currentIndex > 0) {\n var prev = this.visibleItems.eq(currentIndex - 1);\n prev.focus();\n if (e.shiftKey) {\n this.multiSelectItem(prev);\n } else if (!hasKeyModifier) {\n this.selectItem(prev);\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n if (currentIndex < this.visibleItems.length - 1) {\n var next = this.visibleItems.eq(currentIndex + 1);\n next.focus();\n if (e.shiftKey) {\n this.multiSelectItem(next);\n } else if (!hasKeyModifier) {\n this.selectItem(next);\n }\n }\n e.stopPropagation();\n return false;\n }\n case this.keys.asterisk: {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n return false;\n }\n case this.keys.eight: {\n if (e.shiftKey) {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n }\n\n return false;\n }\n }\n\n return true;\n };\n\n /**\n * Handle a key press event - ie navigate the tree.\n *\n * @method handleKeyPress\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleKeyPress = function(item, e) {\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n return true;\n }\n case this.keys.enter:\n case this.keys.home:\n case this.keys.end:\n case this.keys.left:\n case this.keys.right:\n case this.keys.up:\n case this.keys.down: {\n e.stopPropagation();\n return false;\n }\n default : {\n var chr = String.fromCharCode(e.which);\n var match = false;\n var itemIndex = this.visibleItems.index(item);\n var itemCount = this.visibleItems.length;\n var currentIndex = itemIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (currentIndex == itemCount) {\n currentIndex = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (currentIndex != itemIndex) {\n\n var currentItem = this.visibleItems.eq(currentIndex);\n var titleChr = currentItem.text().charAt(0);\n\n if (currentItem.has('ul')) {\n titleChr = currentItem.find('span').text().charAt(0);\n }\n\n if (titleChr.toLowerCase() == chr) {\n match = true;\n break;\n }\n\n currentIndex = currentIndex + 1;\n if (currentIndex == itemCount) {\n // Reached the end of the list, start again at the beginning.\n currentIndex = 0;\n }\n }\n\n if (match === true) {\n this.updateFocus(this.visibleItems.eq(currentIndex));\n }\n e.stopPropagation();\n return false;\n }\n }\n\n // eslint-disable-next-line no-unreachable\n return true;\n };\n\n /**\n * Attach an event listener to the tree.\n *\n * @method on\n * @param {String} eventname This is the name of the event to listen for. Only 'selectionchanged' is supported for now.\n * @param {Function} handler The function to call when the event is triggered.\n */\n Tree.prototype.on = function(eventname, handler) {\n if (eventname !== 'selectionchanged') {\n log.warning('Invalid custom event name for tree. Only \"selectionchanged\" is supported.');\n } else {\n this.treeRoot.on(eventname, handler);\n }\n };\n\n /**\n * Handle a double click (expand/collapse).\n *\n * @method handleDblClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleDblClick = function(item, e) {\n\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n // Apply the focus markup.\n this.updateFocus(item);\n\n // Expand or collapse the group.\n this.toggleGroup(item);\n\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a click (select).\n *\n * @method handleExpandCollapseClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleExpandCollapseClick = function(item, e) {\n\n // Do not shift the focus.\n this.toggleGroup(item);\n e.stopPropagation();\n return false;\n };\n\n\n /**\n * Handle a click (select).\n *\n * @method handleClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleClick = function(item, e) {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n this.updateFocus(item);\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a blur event\n *\n * @method handleBlur\n * @return {Boolean}\n */\n Tree.prototype.handleBlur = function() {\n return true;\n };\n\n /**\n * Handle a focus event\n *\n * @method handleFocus\n * @param {Object} item item is the jquery id of the parent item of the group\n * @return {Boolean}\n */\n Tree.prototype.handleFocus = function(item) {\n\n this.updateFocus(item);\n\n return true;\n };\n\n /**\n * Bind the event listeners we require.\n *\n * @method bindEventHandlers\n */\n Tree.prototype.bindEventHandlers = function() {\n var thisObj = this;\n\n // Bind a dblclick handler to the parent items.\n this.parents.dblclick(function(e) {\n return thisObj.handleDblClick($(this), e);\n });\n\n // Bind a click handler.\n this.items.click(function(e) {\n return thisObj.handleClick($(this), e);\n });\n\n // Bind a toggle handler to the expand/collapse icons.\n this.items.children('img').click(function(e) {\n return thisObj.handleExpandCollapseClick($(this).parent(), e);\n });\n\n // Bind a keydown handler.\n this.items.keydown(function(e) {\n return thisObj.handleKeyDown($(this), e);\n });\n\n // Bind a keypress handler.\n this.items.keypress(function(e) {\n return thisObj.handleKeyPress($(this), e);\n });\n\n // Bind a focus handler.\n this.items.focus(function(e) {\n return thisObj.handleFocus($(this), e);\n });\n\n // Bind a blur handler.\n this.items.blur(function(e) {\n return thisObj.handleBlur($(this), e);\n });\n\n };\n\n return /** @alias module:tool_lp/tree */ Tree;\n});\n"],"file":"tree.min.js"} \ No newline at end of file +{"version":3,"file":"tree.min.js","sources":["../src/tree.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 * Implement an accessible aria tree widget, from a nested unordered list.\n * Based on http://oaa-accessibility.org/example/41/\n *\n * To respond to selection changed events - use tree.on(\"selectionchanged\", handler).\n * The handler will receive an array of nodes, which are the list items that are currently\n * selected. (Or a single node if multiselect is disabled).\n *\n * @module tool_lp/tree\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/url', 'core/log'], function($, url, log) {\n // Private variables and functions.\n /** @var {String} expandedImage The html for an expanded tree node twistie. */\n var expandedImage = $('\"\"');\n /** @var {String} collapsedImage The html for a collapsed tree node twistie. */\n var collapsedImage = $('\"\"');\n\n /**\n * Constructor\n *\n * @param {String} selector\n * @param {Boolean} multiSelect\n */\n var Tree = function(selector, multiSelect) {\n this.treeRoot = $(selector);\n this.multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n\n this.items = this.treeRoot.find('li');\n this.expandAll = this.items.length < 20;\n this.parents = this.treeRoot.find('li:has(ul)');\n\n if (multiSelect) {\n this.treeRoot.attr('aria-multiselectable', 'true');\n }\n\n this.items.attr('aria-selected', 'false');\n\n this.visibleItems = null;\n this.activeItem = null;\n this.lastActiveItem = null;\n\n this.keys = {\n tab: 9,\n enter: 13,\n space: 32,\n pageup: 33,\n pagedown: 34,\n end: 35,\n home: 36,\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n eight: 56,\n asterisk: 106\n };\n\n this.init();\n\n this.bindEventHandlers();\n };\n // Public variables and functions.\n\n /**\n * Init this tree\n * @method init\n */\n Tree.prototype.init = function() {\n this.parents.attr('aria-expanded', 'true');\n this.parents.prepend(expandedImage.clone());\n\n this.items.attr('role', 'tree-item');\n this.items.attr('tabindex', '-1');\n this.parents.attr('role', 'group');\n this.treeRoot.attr('role', 'tree');\n\n this.visibleItems = this.treeRoot.find('li');\n\n var thisObj = this;\n if (!this.expandAll) {\n this.parents.each(function() {\n thisObj.collapseGroup($(this));\n });\n this.expandGroup(this.parents.first());\n }\n };\n\n /**\n * Expand a collapsed group.\n *\n * @method expandGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.expandGroup = function(item) {\n // Find the first child ul node.\n var group = item.children('ul');\n\n // Expand the group.\n group.show().attr('aria-hidden', 'false');\n\n item.attr('aria-expanded', 'true');\n\n item.children('img').attr('src', expandedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Collapse an expanded group.\n *\n * @method collapseGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.collapseGroup = function(item) {\n var group = item.children('ul');\n\n // Collapse the group.\n group.hide().attr('aria-hidden', 'true');\n\n item.attr('aria-expanded', 'false');\n\n item.children('img').attr('src', collapsedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Expand or collapse a group.\n *\n * @method toggleGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.toggleGroup = function(item) {\n if (item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n this.expandGroup(item);\n }\n };\n\n /**\n * Whenever the currently selected node has changed, trigger an event using this function.\n *\n * @method triggerChange\n */\n Tree.prototype.triggerChange = function() {\n var allSelected = this.items.filter('[aria-selected=true]');\n if (!this.multiSelect) {\n allSelected = allSelected.first();\n }\n this.treeRoot.trigger('selectionchanged', {selected: allSelected});\n };\n\n /**\n * Select all the items between the last focused item and this currently focused item.\n *\n * @method multiSelectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.multiSelectItem = function(item) {\n if (!this.multiSelect) {\n this.items.attr('aria-selected', 'false');\n } else if (this.lastActiveItem !== null) {\n var lastIndex = this.visibleItems.index(this.lastActiveItem);\n var currentIndex = this.visibleItems.index(this.activeItem);\n var oneItem = null;\n\n while (lastIndex < currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex++;\n }\n while (lastIndex > currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex--;\n }\n }\n\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Select a single item. Make sure all the parents are expanded. De-select all other items.\n *\n * @method selectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.selectItem = function(item) {\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('aria-selected', 'false');\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Toggle the selected state for an item back and forth.\n *\n * @method toggleItem\n * @param {Object} item is the jquery id of the item to toggle.\n */\n Tree.prototype.toggleItem = function(item) {\n if (!this.multiSelect) {\n this.selectItem(item);\n return;\n }\n\n var current = item.attr('aria-selected');\n if (current === 'true') {\n current = 'false';\n } else {\n current = 'true';\n }\n item.attr('aria-selected', current);\n this.triggerChange();\n };\n\n /**\n * Set the focus to this item.\n *\n * @method updateFocus\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.updateFocus = function(item) {\n this.lastActiveItem = this.activeItem;\n this.activeItem = item;\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('tabindex', '-1');\n item.attr('tabindex', 0);\n };\n\n /**\n * Handle a key down event - ie navigate the tree.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n // This function should be simplified. In the meantime..\n // eslint-disable-next-line complexity\n Tree.prototype.handleKeyDown = function(item, e) {\n var currentIndex = this.visibleItems.index(item);\n var newItem = null;\n var hasKeyModifier = e.shiftKey || e.ctrlKey || e.metaKey || e.altKey;\n var thisObj = this;\n\n switch (e.keyCode) {\n case this.keys.home: {\n // Jump to first item in tree.\n newItem = this.parents.first();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.end: {\n // Jump to last visible item.\n newItem = this.visibleItems.last();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.left: {\n if (item.has('ul') && item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n // Move up to the parent.\n var itemUL = item.parent();\n var itemParent = itemUL.parent();\n if (itemParent.is('li')) {\n itemParent.focus();\n if (e.shiftKey) {\n this.multiSelectItem(itemParent);\n } else if (!hasKeyModifier) {\n this.selectItem(itemParent);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n if (item.has('ul') && item.attr('aria-expanded') == 'false') {\n this.expandGroup(item);\n } else {\n // Move to the first item in the child group.\n newItem = item.children('ul').children('li').first();\n if (newItem.length > 0) {\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n if (currentIndex > 0) {\n var prev = this.visibleItems.eq(currentIndex - 1);\n prev.focus();\n if (e.shiftKey) {\n this.multiSelectItem(prev);\n } else if (!hasKeyModifier) {\n this.selectItem(prev);\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n if (currentIndex < this.visibleItems.length - 1) {\n var next = this.visibleItems.eq(currentIndex + 1);\n next.focus();\n if (e.shiftKey) {\n this.multiSelectItem(next);\n } else if (!hasKeyModifier) {\n this.selectItem(next);\n }\n }\n e.stopPropagation();\n return false;\n }\n case this.keys.asterisk: {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n return false;\n }\n case this.keys.eight: {\n if (e.shiftKey) {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n }\n\n return false;\n }\n }\n\n return true;\n };\n\n /**\n * Handle a key press event - ie navigate the tree.\n *\n * @method handleKeyPress\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleKeyPress = function(item, e) {\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n return true;\n }\n case this.keys.enter:\n case this.keys.home:\n case this.keys.end:\n case this.keys.left:\n case this.keys.right:\n case this.keys.up:\n case this.keys.down: {\n e.stopPropagation();\n return false;\n }\n default : {\n var chr = String.fromCharCode(e.which);\n var match = false;\n var itemIndex = this.visibleItems.index(item);\n var itemCount = this.visibleItems.length;\n var currentIndex = itemIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (currentIndex == itemCount) {\n currentIndex = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (currentIndex != itemIndex) {\n\n var currentItem = this.visibleItems.eq(currentIndex);\n var titleChr = currentItem.text().charAt(0);\n\n if (currentItem.has('ul')) {\n titleChr = currentItem.find('span').text().charAt(0);\n }\n\n if (titleChr.toLowerCase() == chr) {\n match = true;\n break;\n }\n\n currentIndex = currentIndex + 1;\n if (currentIndex == itemCount) {\n // Reached the end of the list, start again at the beginning.\n currentIndex = 0;\n }\n }\n\n if (match === true) {\n this.updateFocus(this.visibleItems.eq(currentIndex));\n }\n e.stopPropagation();\n return false;\n }\n }\n\n // eslint-disable-next-line no-unreachable\n return true;\n };\n\n /**\n * Attach an event listener to the tree.\n *\n * @method on\n * @param {String} eventname This is the name of the event to listen for. Only 'selectionchanged' is supported for now.\n * @param {Function} handler The function to call when the event is triggered.\n */\n Tree.prototype.on = function(eventname, handler) {\n if (eventname !== 'selectionchanged') {\n log.warning('Invalid custom event name for tree. Only \"selectionchanged\" is supported.');\n } else {\n this.treeRoot.on(eventname, handler);\n }\n };\n\n /**\n * Handle a double click (expand/collapse).\n *\n * @method handleDblClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleDblClick = function(item, e) {\n\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n // Apply the focus markup.\n this.updateFocus(item);\n\n // Expand or collapse the group.\n this.toggleGroup(item);\n\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a click (select).\n *\n * @method handleExpandCollapseClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleExpandCollapseClick = function(item, e) {\n\n // Do not shift the focus.\n this.toggleGroup(item);\n e.stopPropagation();\n return false;\n };\n\n\n /**\n * Handle a click (select).\n *\n * @method handleClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleClick = function(item, e) {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n this.updateFocus(item);\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a blur event\n *\n * @method handleBlur\n * @return {Boolean}\n */\n Tree.prototype.handleBlur = function() {\n return true;\n };\n\n /**\n * Handle a focus event\n *\n * @method handleFocus\n * @param {Object} item item is the jquery id of the parent item of the group\n * @return {Boolean}\n */\n Tree.prototype.handleFocus = function(item) {\n\n this.updateFocus(item);\n\n return true;\n };\n\n /**\n * Bind the event listeners we require.\n *\n * @method bindEventHandlers\n */\n Tree.prototype.bindEventHandlers = function() {\n var thisObj = this;\n\n // Bind a dblclick handler to the parent items.\n this.parents.dblclick(function(e) {\n return thisObj.handleDblClick($(this), e);\n });\n\n // Bind a click handler.\n this.items.click(function(e) {\n return thisObj.handleClick($(this), e);\n });\n\n // Bind a toggle handler to the expand/collapse icons.\n this.items.children('img').click(function(e) {\n return thisObj.handleExpandCollapseClick($(this).parent(), e);\n });\n\n // Bind a keydown handler.\n this.items.keydown(function(e) {\n return thisObj.handleKeyDown($(this), e);\n });\n\n // Bind a keypress handler.\n this.items.keypress(function(e) {\n return thisObj.handleKeyPress($(this), e);\n });\n\n // Bind a focus handler.\n this.items.focus(function(e) {\n return thisObj.handleFocus($(this), e);\n });\n\n // Bind a blur handler.\n this.items.blur(function(e) {\n return thisObj.handleBlur($(this), e);\n });\n\n };\n\n return /** @alias module:tool_lp/tree */ Tree;\n});\n"],"names":["define","$","url","log","expandedImage","imageUrl","collapsedImage","Tree","selector","multiSelect","treeRoot","items","this","find","expandAll","length","parents","attr","visibleItems","activeItem","lastActiveItem","keys","tab","enter","space","pageup","pagedown","end","home","left","up","right","down","eight","asterisk","init","bindEventHandlers","prototype","prepend","clone","thisObj","each","collapseGroup","expandGroup","first","item","children","show","hide","toggleGroup","triggerChange","allSelected","filter","trigger","selected","multiSelectItem","lastIndex","index","currentIndex","get","selectItem","walk","parent","toggleItem","current","updateFocus","handleKeyDown","e","newItem","hasKeyModifier","shiftKey","ctrlKey","metaKey","altKey","keyCode","focus","stopPropagation","last","has","itemParent","is","prev","eq","next","handleKeyPress","chr","String","fromCharCode","which","match","itemIndex","itemCount","currentItem","titleChr","text","charAt","toLowerCase","on","eventname","handler","warning","handleDblClick","handleExpandCollapseClick","handleClick","handleBlur","handleFocus","dblclick","click","keydown","keypress","blur"],"mappings":";;;;;;;;;;;;AA2BAA,sBAAO,CAAC,SAAU,WAAY,aAAa,SAASC,EAAGC,IAAKC,SAGpDC,cAAgBH,EAAE,oBAAsBC,IAAIG,SAAS,cAAgB,OAErEC,eAAiBL,EAAE,oBAAsBC,IAAIG,SAAS,eAAiB,OAQvEE,KAAO,SAASC,SAAUC,kBACrBC,SAAWT,EAAEO,eACbC,iBAAsC,IAAhBA,cAA+C,IAAhBA,iBAErDE,MAAQC,KAAKF,SAASG,KAAK,WAC3BC,UAAYF,KAAKD,MAAMI,OAAS,QAChCC,QAAUJ,KAAKF,SAASG,KAAK,cAE9BJ,kBACKC,SAASO,KAAK,uBAAwB,aAG1CN,MAAMM,KAAK,gBAAiB,cAE5BC,aAAe,UACfC,WAAa,UACbC,eAAiB,UAEjBC,KAAO,CACRC,IAAU,EACVC,MAAU,GACVC,MAAU,GACVC,OAAU,GACVC,SAAU,GACVC,IAAU,GACVC,KAAU,GACVC,KAAU,GACVC,GAAU,GACVC,MAAU,GACVC,KAAU,GACVC,MAAU,GACVC,SAAU,UAGTC,YAEAC,4BAQT7B,KAAK8B,UAAUF,KAAO,gBACbnB,QAAQC,KAAK,gBAAiB,aAC9BD,QAAQsB,QAAQlC,cAAcmC,cAE9B5B,MAAMM,KAAK,OAAQ,kBACnBN,MAAMM,KAAK,WAA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,SAAS1D,KAAMsB,UAEpCA,EAAEG,cACGf,gBAAgBV,MACdsB,EAAEK,SAAWL,EAAEI,aACjBR,WAAWlB,WAEXe,WAAWf,WAEfoB,YAAYpB,MACjBsB,EAAES,mBACK,GASXrE,KAAK8B,UAAUmE,WAAa,kBACjB,GAUXjG,KAAK8B,UAAUoE,YAAc,SAAS5D,kBAE7BoB,YAAYpB,OAEV,GAQXtC,KAAK8B,UAAUD,kBAAoB,eAC3BI,QAAU5B,UAGTI,QAAQ0F,UAAS,SAASvC,UACpB3B,QAAQ6D,eAAepG,EAAEW,MAAOuD,WAItCxD,MAAMgG,OAAM,SAASxC,UACf3B,QAAQ+D,YAAYtG,EAAEW,MAAOuD,WAInCxD,MAAMmC,SAAS,OAAO6D,OAAM,SAASxC,UAC/B3B,QAAQ8D,0BAA0BrG,EAAEW,MAAMkD,SAAUK,WAI1DxD,MAAMiG,SAAQ,SAASzC,UACjB3B,QAAQ0B,cAAcjE,EAAEW,MAAOuD,WAIrCxD,MAAMkG,UAAS,SAAS1C,UAClB3B,QAAQ4C,eAAenF,EAAEW,MAAOuD,WAItCxD,MAAMgE,OAAM,SAASR,UACf3B,QAAQiE,YAAYxG,EAAEW,MAAOuD,WAInCxD,MAAMmG,MAAK,SAAS3C,UACd3B,QAAQgE,WAAWvG,EAAEW,MAAOuD,OAKF5D"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_course_navigation.min.js b/admin/tool/lp/amd/build/user_competency_course_navigation.min.js index 6bf284959ce..928414d4e67 100644 --- a/admin/tool/lp/amd/build/user_competency_course_navigation.min.js +++ b/admin/tool/lp/amd/build/user_competency_course_navigation.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/user_competency_course_navigation",["jquery"],function(a){var b=function(b,c,d,e,f,g){this._baseUrl=d;this._userId=e+"";this._competencyId=f+"";this._courseId=g;a(b).on("change",this._userChanged.bind(this));a(c).on("change",this._competencyChanged.bind(this))};b.prototype._userChanged=function(b){var c=a(b.target).val(),d="?userid="+c+"&courseid="+this._courseId+"&competencyid="+this._competencyId;document.location=this._baseUrl+d};b.prototype._competencyChanged=function(b){var c=a(b.target).val(),d="?userid="+this._userId+"&courseid="+this._courseId+"&competencyid="+c;document.location=this._baseUrl+d};b.prototype._competencyId=null;b.prototype._userId=null;b.prototype._courseId=null;b.prototype._baseUrl=null;b.prototype._ignoreFirstCompetency=null;return b}); -//# sourceMappingURL=user_competency_course_navigation.min.js.map +/** + * Module to enable inline editing of a comptency grade. + * + * @module tool_lp/user_competency_course_navigation + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/user_competency_course_navigation",["jquery"],(function($){var UserCompetencyCourseNavigation=function(userSelector,competencySelector,baseUrl,userId,competencyId,courseId){this._baseUrl=baseUrl,this._userId=userId+"",this._competencyId=competencyId+"",this._courseId=courseId,$(userSelector).on("change",this._userChanged.bind(this)),$(competencySelector).on("change",this._competencyChanged.bind(this))};return UserCompetencyCourseNavigation.prototype._userChanged=function(e){var queryStr="?userid="+$(e.target).val()+"&courseid="+this._courseId+"&competencyid="+this._competencyId;document.location=this._baseUrl+queryStr},UserCompetencyCourseNavigation.prototype._competencyChanged=function(e){var newCompetencyId=$(e.target).val(),queryStr="?userid="+this._userId+"&courseid="+this._courseId+"&competencyid="+newCompetencyId;document.location=this._baseUrl+queryStr},UserCompetencyCourseNavigation.prototype._competencyId=null,UserCompetencyCourseNavigation.prototype._userId=null,UserCompetencyCourseNavigation.prototype._courseId=null,UserCompetencyCourseNavigation.prototype._baseUrl=null,UserCompetencyCourseNavigation.prototype._ignoreFirstCompetency=null,UserCompetencyCourseNavigation})); + +//# sourceMappingURL=user_competency_course_navigation.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map b/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map index 15007d6d46a..180e7138397 100644 --- a/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/user_competency_course_navigation.js"],"names":["define","$","UserCompetencyCourseNavigation","userSelector","competencySelector","baseUrl","userId","competencyId","courseId","_baseUrl","_userId","_competencyId","_courseId","on","_userChanged","bind","_competencyChanged","prototype","e","newUserId","target","val","queryStr","document","location","newCompetencyId","_ignoreFirstCompetency"],"mappings":"AAuBAA,OAAM,6CAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAa3B,GAAIC,CAAAA,CAA8B,CAAG,SAASC,CAAT,CAAuBC,CAAvB,CAA2CC,CAA3C,CAAoDC,CAApD,CAA4DC,CAA5D,CAA0EC,CAA1E,CAAoF,CACrH,KAAKC,QAAL,CAAgBJ,CAAhB,CACA,KAAKK,OAAL,CAAeJ,CAAM,CAAG,EAAxB,CACA,KAAKK,aAAL,CAAqBJ,CAAY,CAAG,EAApC,CACA,KAAKK,SAAL,CAAiBJ,CAAjB,CAEAP,CAAC,CAACE,CAAD,CAAD,CAAgBU,EAAhB,CAAmB,QAAnB,CAA6B,KAAKC,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAA7B,EACAd,CAAC,CAACG,CAAD,CAAD,CAAsBS,EAAtB,CAAyB,QAAzB,CAAmC,KAAKG,kBAAL,CAAwBD,IAAxB,CAA6B,IAA7B,CAAnC,CACH,CARD,CAgBAb,CAA8B,CAACe,SAA/B,CAAyCH,YAAzC,CAAwD,SAASI,CAAT,CAAY,IAC5DC,CAAAA,CAAS,CAAGlB,CAAC,CAACiB,CAAC,CAACE,MAAH,CAAD,CAAYC,GAAZ,EADgD,CAE5DC,CAAQ,CAAG,WAAaH,CAAb,CAAyB,YAAzB,CAAwC,KAAKP,SAA7C,CAAyD,gBAAzD,CAA4E,KAAKD,aAFhC,CAGhEY,QAAQ,CAACC,QAAT,CAAoB,KAAKf,QAAL,CAAgBa,CACvC,CAJD,CAYApB,CAA8B,CAACe,SAA/B,CAAyCD,kBAAzC,CAA8D,SAASE,CAAT,CAAY,IAClEO,CAAAA,CAAe,CAAGxB,CAAC,CAACiB,CAAC,CAACE,MAAH,CAAD,CAAYC,GAAZ,EADgD,CAElEC,CAAQ,CAAG,WAAa,KAAKZ,OAAlB,CAA4B,YAA5B,CAA2C,KAAKE,SAAhD,CAA4D,gBAA5D,CAA+Ea,CAFxB,CAGtEF,QAAQ,CAACC,QAAT,CAAoB,KAAKf,QAAL,CAAgBa,CACvC,CAJD,CAOApB,CAA8B,CAACe,SAA/B,CAAyCN,aAAzC,CAAyD,IAAzD,CAEAT,CAA8B,CAACe,SAA/B,CAAyCP,OAAzC,CAAmD,IAAnD,CAEAR,CAA8B,CAACe,SAA/B,CAAyCL,SAAzC,CAAqD,IAArD,CAEAV,CAA8B,CAACe,SAA/B,CAAyCR,QAAzC,CAAoD,IAApD,CAEAP,CAA8B,CAACe,SAA/B,CAAyCS,sBAAzC,CAAkE,IAAlE,CAEA,MAAOxB,CAAAA,CACV,CA3DK,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 * Module to enable inline editing of a comptency grade.\n *\n * @module tool_lp/user_competency_course_navigation\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * UserCompetencyCourseNavigation\n *\n * @class tool_lp/user_competency_course_navigation\n * @param {String} userSelector The selector of the user element.\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} courseId The course id\n */\n var UserCompetencyCourseNavigation = function(userSelector, competencySelector, baseUrl, userId, competencyId, courseId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._courseId = courseId;\n\n $(userSelector).on('change', this._userChanged.bind(this));\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The user was changed in the select list.\n *\n * @method _userChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._userChanged = function(e) {\n var newUserId = $(e.target).val();\n var queryStr = '?userid=' + newUserId + '&courseid=' + this._courseId + '&competencyid=' + this._competencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._competencyChanged = function(e) {\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&courseid=' + this._courseId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n UserCompetencyCourseNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n UserCompetencyCourseNavigation.prototype._userId = null;\n /** @property {Number} The id of the course. */\n UserCompetencyCourseNavigation.prototype._courseId = null;\n /** @property {String} Plugin base url. */\n UserCompetencyCourseNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n UserCompetencyCourseNavigation.prototype._ignoreFirstCompetency = null;\n\n return UserCompetencyCourseNavigation;\n});\n"],"file":"user_competency_course_navigation.min.js"} \ No newline at end of file +{"version":3,"file":"user_competency_course_navigation.min.js","sources":["../src/user_competency_course_navigation.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 to enable inline editing of a comptency grade.\n *\n * @module tool_lp/user_competency_course_navigation\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * UserCompetencyCourseNavigation\n *\n * @class tool_lp/user_competency_course_navigation\n * @param {String} userSelector The selector of the user element.\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} courseId The course id\n */\n var UserCompetencyCourseNavigation = function(userSelector, competencySelector, baseUrl, userId, competencyId, courseId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._courseId = courseId;\n\n $(userSelector).on('change', this._userChanged.bind(this));\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The user was changed in the select list.\n *\n * @method _userChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._userChanged = function(e) {\n var newUserId = $(e.target).val();\n var queryStr = '?userid=' + newUserId + '&courseid=' + this._courseId + '&competencyid=' + this._competencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._competencyChanged = function(e) {\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&courseid=' + this._courseId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n UserCompetencyCourseNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n UserCompetencyCourseNavigation.prototype._userId = null;\n /** @property {Number} The id of the course. */\n UserCompetencyCourseNavigation.prototype._courseId = null;\n /** @property {String} Plugin base url. */\n UserCompetencyCourseNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n UserCompetencyCourseNavigation.prototype._ignoreFirstCompetency = null;\n\n return UserCompetencyCourseNavigation;\n});\n"],"names":["define","$","UserCompetencyCourseNavigation","userSelector","competencySelector","baseUrl","userId","competencyId","courseId","_baseUrl","_userId","_competencyId","_courseId","on","this","_userChanged","bind","_competencyChanged","prototype","e","queryStr","target","val","document","location","newCompetencyId","_ignoreFirstCompetency"],"mappings":";;;;;;;AAuBAA,mDAAO,CAAC,WAAW,SAASC,OAapBC,+BAAiC,SAASC,aAAcC,mBAAoBC,QAASC,OAAQC,aAAcC,eACtGC,SAAWJ,aACXK,QAAUJ,OAAS,QACnBK,cAAgBJ,aAAe,QAC/BK,UAAYJ,SAEjBP,EAAEE,cAAcU,GAAG,SAAUC,KAAKC,aAAaC,KAAKF,OACpDb,EAAEG,oBAAoBS,GAAG,SAAUC,KAAKG,mBAAmBD,KAAKF,eASpEZ,+BAA+BgB,UAAUH,aAAe,SAASI,OAEzDC,SAAW,WADCnB,EAAEkB,EAAEE,QAAQC,MACY,aAAeR,KAAKF,UAAY,iBAAmBE,KAAKH,cAChGY,SAASC,SAAWV,KAAKL,SAAWW,UASxClB,+BAA+BgB,UAAUD,mBAAqB,SAASE,OAC/DM,gBAAkBxB,EAAEkB,EAAEE,QAAQC,MAC9BF,SAAW,WAAaN,KAAKJ,QAAU,aAAeI,KAAKF,UAAY,iBAAmBa,gBAC9FF,SAASC,SAAWV,KAAKL,SAAWW,UAIxClB,+BAA+BgB,UAAUP,cAAgB,KAEzDT,+BAA+BgB,UAAUR,QAAU,KAEnDR,+BAA+BgB,UAAUN,UAAY,KAErDV,+BAA+BgB,UAAUT,SAAW,KAEpDP,+BAA+BgB,UAAUQ,uBAAyB,KAE3DxB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_info.min.js b/admin/tool/lp/amd/build/user_competency_info.min.js index c4a3f727781..271a5f6e0e3 100644 --- a/admin/tool/lp/amd/build/user_competency_info.min.js +++ b/admin/tool/lp/amd/build/user_competency_info.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/user_competency_info",["jquery","core/notification","core/ajax","core/templates"],function(a,b,c,d){var e=function(a,b,c,d,e,f){this._rootElement=a;this._competencyId=b;this._userId=c;this._planId=d;this._courseId=e;this._valid=!0;this._displayuser="undefined"!=typeof f?f:!1;if(this._planId){this._methodName="tool_lp_data_for_user_competency_summary_in_plan";this._args={competencyid:this._competencyId,planid:this._planId};this._templateName="tool_lp/user_competency_summary_in_plan"}else if(this._courseId){this._methodName="tool_lp_data_for_user_competency_summary_in_course";this._args={userid:this._userId,competencyid:this._competencyId,courseid:this._courseId};this._templateName="tool_lp/user_competency_summary_in_course"}else{this._methodName="tool_lp_data_for_user_competency_summary";this._args={userid:this._userId,competencyid:this._competencyId};this._templateName="tool_lp/user_competency_summary"}};e.prototype.reload=function(){var a=this,e=[];if(!this._valid){return}e=c.call([{methodname:this._methodName,args:this._args}]);e[0].done(function(c){if(a._displayuser){c.displayuser=!0}d.render(a._templateName,c).done(function(b,c){d.replaceNode(a._rootElement,b,c)}).fail(b.exception)}).fail(b.exception)};e.prototype._rootElement=null;e.prototype._courseId=null;e.prototype._valid=null;e.prototype._planId=null;e.prototype._competencyId=null;e.prototype._userId=null;e.prototype._methodName=null;e.prototype._args=null;e.prototype._templateName=null;e.prototype._displayuser=!1;return e}); -//# sourceMappingURL=user_competency_info.min.js.map +/** + * Module to refresh a user competency summary in a page. + * + * @module tool_lp/user_competency_info + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/user_competency_info",["jquery","core/notification","core/ajax","core/templates"],(function($,notification,ajax,templates){var Info=function(rootElement,competencyId,userId,planId,courseId,displayuser){this._rootElement=rootElement,this._competencyId=competencyId,this._userId=userId,this._planId=planId,this._courseId=courseId,this._valid=!0,this._displayuser=void 0!==displayuser&&displayuser,this._planId?(this._methodName="tool_lp_data_for_user_competency_summary_in_plan",this._args={competencyid:this._competencyId,planid:this._planId},this._templateName="tool_lp/user_competency_summary_in_plan"):this._courseId?(this._methodName="tool_lp_data_for_user_competency_summary_in_course",this._args={userid:this._userId,competencyid:this._competencyId,courseid:this._courseId},this._templateName="tool_lp/user_competency_summary_in_course"):(this._methodName="tool_lp_data_for_user_competency_summary",this._args={userid:this._userId,competencyid:this._competencyId},this._templateName="tool_lp/user_competency_summary")};return Info.prototype.reload=function(){var self=this;this._valid&&ajax.call([{methodname:this._methodName,args:this._args}])[0].done((function(context){self._displayuser&&(context.displayuser=!0),templates.render(self._templateName,context).done((function(html,js){templates.replaceNode(self._rootElement,html,js)})).fail(notification.exception)})).fail(notification.exception)},Info.prototype._rootElement=null,Info.prototype._courseId=null,Info.prototype._valid=null,Info.prototype._planId=null,Info.prototype._competencyId=null,Info.prototype._userId=null,Info.prototype._methodName=null,Info.prototype._args=null,Info.prototype._templateName=null,Info.prototype._displayuser=!1,Info})); + +//# sourceMappingURL=user_competency_info.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_info.min.js.map b/admin/tool/lp/amd/build/user_competency_info.min.js.map index 2d7caa901c0..6a86054a7a4 100644 --- a/admin/tool/lp/amd/build/user_competency_info.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_info.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/user_competency_info.js"],"names":["define","$","notification","ajax","templates","Info","rootElement","competencyId","userId","planId","courseId","displayuser","_rootElement","_competencyId","_userId","_planId","_courseId","_valid","_displayuser","_methodName","_args","competencyid","planid","_templateName","userid","courseid","prototype","reload","self","promises","call","methodname","args","done","context","render","html","js","replaceNode","fail","exception"],"mappings":"AAuBAA,OAAM,gCAAC,CAAC,QAAD,CAAW,mBAAX,CAAgC,WAAhC,CAA6C,gBAA7C,CAAD,CAAiE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CA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CAAC2B,IAAL,CAAU,CAAC,CAClBC,UAAU,CAAE,KAAKZ,WADC,CAElBa,IAAI,CAAE,KAAKZ,KAFO,CAAD,CAAV,CAAX,CAKAS,CAAQ,CAAC,CAAD,CAAR,CAAYI,IAAZ,CAAiB,SAASC,CAAT,CAAkB,CAE/B,GAAIN,CAAI,CAACV,YAAT,CAAuB,CACnBgB,CAAO,CAACvB,WAAR,GACH,CACDP,CAAS,CAAC+B,MAAV,CAAiBP,CAAI,CAACL,aAAtB,CAAqCW,CAArC,EAA8CD,IAA9C,CAAmD,SAASG,CAAT,CAAeC,CAAf,CAAmB,CAClEjC,CAAS,CAACkC,WAAV,CAAsBV,CAAI,CAAChB,YAA3B,CAAyCwB,CAAzC,CAA+CC,CAA/C,CACH,CAFD,EAEGE,IAFH,CAEQrC,CAAY,CAACsC,SAFrB,CAGH,CARD,EAQGD,IARH,CAQQrC,CAAY,CAACsC,SARrB,CASH,CAtBD,CAyBAnC,CAAI,CAACqB,SAAL,CAAed,YAAf,CAA8B,IAA9B,CAEAP,CAAI,CAACqB,SAAL,CAAeV,SAAf,CAA2B,IAA3B,CAEAX,CAAI,CAACqB,SAAL,CAAeT,MAAf,CAAwB,IAAxB,CAEAZ,CAAI,CAACqB,SAAL,CAAeX,OAAf,CAAyB,IAAzB,CAEAV,CAAI,CAACqB,SAAL,CAAeb,aAAf,CAA+B,IAA/B,CAEAR,CAAI,CAACqB,SAAL,CAAeZ,OAAf,CAAyB,IAAzB,CAEAT,CAAI,CAACqB,SAAL,CAAeP,WAAf,CAA6B,IAA7B,CAEAd,CAAI,CAACqB,SAAL,CAAeN,KAAf,CAAuB,IAAvB,CAEAf,CAAI,CAACqB,SAAL,CAAeH,aAAf,CAA+B,IAA/B,CAEAlB,CAAI,CAACqB,SAAL,CAAeR,YAAf,IAEA,MAAyDb,CAAAA,CAE5D,CAxFK,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 * Module to refresh a user competency summary in a page.\n *\n * @module tool_lp/user_competency_info\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function($, notification, ajax, templates) {\n\n /**\n * Info\n *\n * @param {JQuery} rootElement Selector to replace when the information needs updating.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {Boolean} displayuser If we should display the user info.\n */\n var Info = function(rootElement, competencyId, userId, planId, courseId, displayuser) {\n this._rootElement = rootElement;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._valid = true;\n this._displayuser = (typeof displayuser !== 'undefined') ? displayuser : false;\n\n if (this._planId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_plan';\n this._args = {competencyid: this._competencyId, planid: this._planId};\n this._templateName = 'tool_lp/user_competency_summary_in_plan';\n } else if (this._courseId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_course';\n this._args = {userid: this._userId, competencyid: this._competencyId, courseid: this._courseId};\n this._templateName = 'tool_lp/user_competency_summary_in_course';\n } else {\n this._methodName = 'tool_lp_data_for_user_competency_summary';\n this._args = {userid: this._userId, competencyid: this._competencyId};\n this._templateName = 'tool_lp/user_competency_summary';\n }\n };\n\n /**\n * Reload the info for this user competency.\n *\n * @method reload\n */\n Info.prototype.reload = function() {\n var self = this,\n promises = [];\n\n if (!this._valid) {\n return;\n }\n\n promises = ajax.call([{\n methodname: this._methodName,\n args: this._args\n }]);\n\n promises[0].done(function(context) {\n // Check if we should also the user info.\n if (self._displayuser) {\n context.displayuser = true;\n }\n templates.render(self._templateName, context).done(function(html, js) {\n templates.replaceNode(self._rootElement, html, js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /** @property {JQuery} The root element to replace in the DOM. */\n Info.prototype._rootElement = null;\n /** @property {Number} The id of the course. */\n Info.prototype._courseId = null;\n /** @property {Boolean} Is this module valid? */\n Info.prototype._valid = null;\n /** @property {Number} The id of the plan. */\n Info.prototype._planId = null;\n /** @property {Number} The id of the competency. */\n Info.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n Info.prototype._userId = null;\n /** @property {String} The method name to load the data. */\n Info.prototype._methodName = null;\n /** @property {Object} The arguments to load the data. */\n Info.prototype._args = null;\n /** @property {String} The template to reload the fragment. */\n Info.prototype._templateName = null;\n /** @property {Boolean} If we should display the user info? */\n Info.prototype._displayuser = false;\n\n return /** @alias module:tool_lp/user_competency_info */ Info;\n\n});\n"],"file":"user_competency_info.min.js"} \ No newline at end of file +{"version":3,"file":"user_competency_info.min.js","sources":["../src/user_competency_info.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 to refresh a user competency summary in a page.\n *\n * @module tool_lp/user_competency_info\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function($, notification, ajax, templates) {\n\n /**\n * Info\n *\n * @param {JQuery} rootElement Selector to replace when the information needs updating.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {Boolean} displayuser If we should display the user info.\n */\n var Info = function(rootElement, competencyId, userId, planId, courseId, displayuser) {\n this._rootElement = rootElement;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._valid = true;\n this._displayuser = (typeof displayuser !== 'undefined') ? displayuser : false;\n\n if (this._planId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_plan';\n this._args = {competencyid: this._competencyId, planid: this._planId};\n this._templateName = 'tool_lp/user_competency_summary_in_plan';\n } else if (this._courseId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_course';\n this._args = {userid: this._userId, competencyid: this._competencyId, courseid: this._courseId};\n this._templateName = 'tool_lp/user_competency_summary_in_course';\n } else {\n this._methodName = 'tool_lp_data_for_user_competency_summary';\n this._args = {userid: this._userId, competencyid: this._competencyId};\n this._templateName = 'tool_lp/user_competency_summary';\n }\n };\n\n /**\n * Reload the info for this user competency.\n *\n * @method reload\n */\n Info.prototype.reload = function() {\n var self = this,\n promises = [];\n\n if (!this._valid) {\n return;\n }\n\n promises = ajax.call([{\n methodname: this._methodName,\n args: this._args\n }]);\n\n promises[0].done(function(context) {\n // Check if we should also the user info.\n if (self._displayuser) {\n context.displayuser = true;\n }\n templates.render(self._templateName, context).done(function(html, js) {\n templates.replaceNode(self._rootElement, html, js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /** @property {JQuery} The root element to replace in the DOM. */\n Info.prototype._rootElement = null;\n /** @property {Number} The id of the course. */\n Info.prototype._courseId = null;\n /** @property {Boolean} Is this module valid? */\n Info.prototype._valid = null;\n /** @property {Number} The id of the plan. */\n Info.prototype._planId = null;\n /** @property {Number} The id of the competency. */\n Info.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n Info.prototype._userId = null;\n /** @property {String} The method name to load the data. */\n Info.prototype._methodName = null;\n /** @property {Object} The arguments to load the data. */\n Info.prototype._args = null;\n /** @property {String} The template to reload the fragment. */\n Info.prototype._templateName = null;\n /** @property {Boolean} If we should display the user info? */\n Info.prototype._displayuser = false;\n\n return /** @alias module:tool_lp/user_competency_info */ Info;\n\n});\n"],"names":["define","$","notification","ajax","templates","Info","rootElement","competencyId","userId","planId","courseId","displayuser","_rootElement","_competencyId","_userId","_planId","_courseId","_valid","_displayuser","this","_methodName","_args","competencyid","planid","_templateName","userid","courseid","prototype","reload","self","call","methodname","args","done","context","render","html","js","replaceNode","fail","exception"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SAAU,oBAAqB,YAAa,mBAAmB,SAASC,EAAGC,aAAcC,KAAMC,eAY/FC,KAAO,SAASC,YAAaC,aAAcC,OAAQC,OAAQC,SAAUC,kBAChEC,aAAeN,iBACfO,cAAgBN,kBAChBO,QAAUN,YACVO,QAAUN,YACVO,UAAYN,cACZO,QAAS,OACTC,kBAAuC,IAAhBP,aAA+BA,YAEvDQ,KAAKJ,cACAK,YAAc,wDACdC,MAAQ,CAACC,aAAcH,KAAKN,cAAeU,OAAQJ,KAAKJ,cACxDS,cAAgB,2CACdL,KAAKH,gBACPI,YAAc,0DACdC,MAAQ,CAACI,OAAQN,KAAKL,QAASQ,aAAcH,KAAKN,cAAea,SAAUP,KAAKH,gBAChFQ,cAAgB,mDAEhBJ,YAAc,gDACdC,MAAQ,CAACI,OAAQN,KAAKL,QAASQ,aAAcH,KAAKN,oBAClDW,cAAgB,2CAS7BnB,KAAKsB,UAAUC,OAAS,eAChBC,KAAOV,KAGNA,KAAKF,QAICd,KAAK2B,KAAK,CAAC,CAClBC,WAAYZ,KAAKC,YACjBY,KAAMb,KAAKE,SAGN,GAAGY,MAAK,SAASC,SAElBL,KAAKX,eACLgB,QAAQvB,aAAc,GAE1BP,UAAU+B,OAAON,KAAKL,cAAeU,SAASD,MAAK,SAASG,KAAMC,IAC9DjC,UAAUkC,YAAYT,KAAKjB,aAAcwB,KAAMC,OAChDE,KAAKrC,aAAasC,cACtBD,KAAKrC,aAAasC,YAIzBnC,KAAKsB,UAAUf,aAAe,KAE9BP,KAAKsB,UAAUX,UAAY,KAE3BX,KAAKsB,UAAUV,OAAS,KAExBZ,KAAKsB,UAAUZ,QAAU,KAEzBV,KAAKsB,UAAUd,cAAgB,KAE/BR,KAAKsB,UAAUb,QAAU,KAEzBT,KAAKsB,UAAUP,YAAc,KAE7Bf,KAAKsB,UAAUN,MAAQ,KAEvBhB,KAAKsB,UAAUH,cAAgB,KAE/BnB,KAAKsB,UAAUT,cAAe,EAE2Bb"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_plan_popup.min.js b/admin/tool/lp/amd/build/user_competency_plan_popup.min.js index cda67b49907..f05a6e8b24d 100644 --- a/admin/tool/lp/amd/build/user_competency_plan_popup.min.js +++ b/admin/tool/lp/amd/build/user_competency_plan_popup.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/user_competency_plan_popup",["jquery","core/notification","core/str","core/ajax","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f){var g=function(b,c,d){this._regionSelector=b;this._userCompetencySelector=c;this._planId=d;a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};g.prototype._handleClick=function(c){c.preventDefault();var e=a(c.target).closest("tr"),f=a(e).data("competencyid"),g=a(e).data("userid"),h=this._planId,i=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_plan",args:{competencyid:f,planid:h},done:this._contextLoaded.bind(this),fail:b.exception}]);i[0].then(function(a){var b="core_competency_user_competency_viewed_in_plan";if(a.plan.iscompleted){b="core_competency_user_competency_plan_viewed"}return d.call([{methodname:b,args:{competencyid:f,userid:g,planid:h}}])[0]}).catch(b.exception)};g.prototype._contextLoaded=function(a){var d=this;e.render("tool_lp/user_competency_summary_in_plan",a).done(function(a,g){c.get_string("usercompetencysummary","report_competency").done(function(b){new f(b,a,e.runTemplateJS.bind(e,g),d._refresh.bind(d),!0)}).fail(b.exception)}).fail(b.exception)};g.prototype._refresh=function(){var a=this._planId;d.call([{methodname:"tool_lp_data_for_plan_page",args:{planid:a},done:this._pageContextLoaded.bind(this),fail:b.exception}])};g.prototype._pageContextLoaded=function(a){var c=this;e.render("tool_lp/plan_page",a).done(function(a,b){e.replaceNode(c._regionSelector,a,b)}).fail(b.exception)};g.prototype._regionSelector=null;g.prototype._userCompetencySelector=null;g.prototype._planId=null;return g}); -//# sourceMappingURL=user_competency_plan_popup.min.js.map +/** + * Module to open user competency plan in popup + * + * @module tool_lp/user_competency_plan_popup + * @copyright 2016 Issam Taboubi + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/user_competency_plan_popup",["jquery","core/notification","core/str","core/ajax","core/templates","tool_lp/dialogue"],(function($,notification,str,ajax,templates,Dialogue){var UserCompetencyPopup=function(regionSelector,userCompetencySelector,planId){this._regionSelector=regionSelector,this._userCompetencySelector=userCompetencySelector,this._planId=planId,$(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return UserCompetencyPopup.prototype._handleClick=function(e){e.preventDefault();var tr=$(e.target).closest("tr"),competencyId=$(tr).data("competencyid"),userId=$(tr).data("userid"),planId=this._planId;ajax.call([{methodname:"tool_lp_data_for_user_competency_summary_in_plan",args:{competencyid:competencyId,planid:planId},done:this._contextLoaded.bind(this),fail:notification.exception}])[0].then((function(result){var eventMethodName="core_competency_user_competency_viewed_in_plan";return result.plan.iscompleted&&(eventMethodName="core_competency_user_competency_plan_viewed"),ajax.call([{methodname:eventMethodName,args:{competencyid:competencyId,userid:userId,planid:planId}}])[0]})).catch(notification.exception)},UserCompetencyPopup.prototype._contextLoaded=function(context){var self=this;templates.render("tool_lp/user_competency_summary_in_plan",context).done((function(html,js){str.get_string("usercompetencysummary","report_competency").done((function(title){new Dialogue(title,html,templates.runTemplateJS.bind(templates,js),self._refresh.bind(self),!0)})).fail(notification.exception)})).fail(notification.exception)},UserCompetencyPopup.prototype._refresh=function(){var planId=this._planId;ajax.call([{methodname:"tool_lp_data_for_plan_page",args:{planid:planId},done:this._pageContextLoaded.bind(this),fail:notification.exception}])},UserCompetencyPopup.prototype._pageContextLoaded=function(context){var self=this;templates.render("tool_lp/plan_page",context).done((function(html,js){templates.replaceNode(self._regionSelector,html,js)})).fail(notification.exception)},UserCompetencyPopup.prototype._regionSelector=null,UserCompetencyPopup.prototype._userCompetencySelector=null,UserCompetencyPopup.prototype._planId=null,UserCompetencyPopup})); + +//# sourceMappingURL=user_competency_plan_popup.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map b/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map index ec205079c83..14958c5e65c 100644 --- a/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/user_competency_plan_popup.js"],"names":["define","$","notification","str","ajax","templates","Dialogue","UserCompetencyPopup","regionSelector","userCompetencySelector","planId","_regionSelector","_userCompetencySelector","_planId","on","_handleClick","bind","prototype","e","preventDefault","tr","target","closest","competencyId","data","userId","requests","call","methodname","args","competencyid","planid","done","_contextLoaded","fail","exception","then","result","eventMethodName","plan","iscompleted","userid","catch","context","self","render","html","js","get_string","title","runTemplateJS","_refresh","_pageContextLoaded","replaceNode"],"mappings":"AAuBAA,OAAM,sCAAC,CAAC,QAAD,CAAW,mBAAX,CAAgC,UAAhC,CAA4C,WAA5C,CAAyD,gBAAzD,CAA2E,kBAA3E,CAAD,CACC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAA+BC,CAA/B,CAAqCC,CAArC,CAAgDC,CAAhD,CAA0D,CAS7D,GAAIC,CAAAA,CAAmB,CAAG,SAASC,CAAT,CAAyBC,CAAzB,CAAiDC,CAAjD,CAAyD,CAC/E,KAAKC,eAAL,CAAuBH,CAAvB,CACA,KAAKI,uBAA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ACjE,GAAIC,CAAAA,CAAI,CAAG,IAAX,CACAvC,CAAS,CAACwC,MAAV,CAAiB,mBAAjB,CAAsCF,CAAtC,EAA+CX,IAA/C,CAAoD,SAASc,CAAT,CAAeC,CAAf,CAAmB,CACnE1C,CAAS,CAACgD,WAAV,CAAsBT,CAAI,CAACjC,eAA3B,CAA4CmC,CAA5C,CAAkDC,CAAlD,CACH,CAFD,EAEGb,IAFH,CAEQhC,CAAY,CAACiC,SAFrB,CAGH,CALD,CAQA5B,CAAmB,CAACU,SAApB,CAA8BN,eAA9B,CAAgD,IAAhD,CAEAJ,CAAmB,CAACU,SAApB,CAA8BL,uBAA9B,CAAwD,IAAxD,CAEAL,CAAmB,CAACU,SAApB,CAA8BJ,OAA9B,CAAwC,IAAxC,CAEA,MAA+DN,CAAAA,CAElE,CAxGK,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 * Module to open user competency plan in popup\n *\n * @module tool_lp/user_competency_plan_popup\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates', 'tool_lp/dialogue'],\n function($, notification, str, ajax, templates, Dialogue) {\n\n /**\n * UserCompetencyPopup\n *\n * @param {String} regionSelector The regionSelector\n * @param {String} userCompetencySelector The userCompetencySelector\n * @param {Number} planId The plan ID\n */\n var UserCompetencyPopup = function(regionSelector, userCompetencySelector, planId) {\n this._regionSelector = regionSelector;\n this._userCompetencySelector = userCompetencySelector;\n this._planId = planId;\n\n $(this._regionSelector).on('click', this._userCompetencySelector, this._handleClick.bind(this));\n };\n\n /**\n * Get the data from the closest TR and open the popup.\n *\n * @method _handleClick\n * @param {Event} e\n */\n UserCompetencyPopup.prototype._handleClick = function(e) {\n e.preventDefault();\n var tr = $(e.target).closest('tr');\n var competencyId = $(tr).data('competencyid');\n var userId = $(tr).data('userid');\n var planId = this._planId;\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_user_competency_summary_in_plan',\n args: {competencyid: competencyId, planid: planId},\n done: this._contextLoaded.bind(this),\n fail: notification.exception\n }]);\n // Log the user competency viewed in plan event.\n requests[0].then(function(result) {\n var eventMethodName = 'core_competency_user_competency_viewed_in_plan';\n // Trigger core_competency_user_competency_plan_viewed event instead if plan is already completed.\n if (result.plan.iscompleted) {\n eventMethodName = 'core_competency_user_competency_plan_viewed';\n }\n return ajax.call([{\n methodname: eventMethodName,\n args: {competencyid: competencyId, userid: userId, planid: planId}\n }])[0];\n }).catch(notification.exception);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _contextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._contextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/user_competency_summary_in_plan', context).done(function(html, js) {\n str.get_string('usercompetencysummary', 'report_competency').done(function(title) {\n (new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Refresh the page.\n *\n * @method _refresh\n */\n UserCompetencyPopup.prototype._refresh = function() {\n var planId = this._planId;\n\n ajax.call([{\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: planId},\n done: this._pageContextLoaded.bind(this),\n fail: notification.exception\n }]);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _pageContextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._pageContextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/plan_page', context).done(function(html, js) {\n templates.replaceNode(self._regionSelector, html, js);\n }).fail(notification.exception);\n };\n\n /** @property {String} The selector for the region with the user competencies */\n UserCompetencyPopup.prototype._regionSelector = null;\n /** @property {String} The selector for the region with a single user competencies */\n UserCompetencyPopup.prototype._userCompetencySelector = null;\n /** @property {Number} The plan Id */\n UserCompetencyPopup.prototype._planId = null;\n\n return /** @alias module:tool_lp/user_competency_plan_popup */ UserCompetencyPopup;\n\n});\n"],"file":"user_competency_plan_popup.min.js"} \ No newline at end of file +{"version":3,"file":"user_competency_plan_popup.min.js","sources":["../src/user_competency_plan_popup.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 to open user competency plan in popup\n *\n * @module tool_lp/user_competency_plan_popup\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates', 'tool_lp/dialogue'],\n function($, notification, str, ajax, templates, Dialogue) {\n\n /**\n * UserCompetencyPopup\n *\n * @param {String} regionSelector The regionSelector\n * @param {String} userCompetencySelector The userCompetencySelector\n * @param {Number} planId The plan ID\n */\n var UserCompetencyPopup = function(regionSelector, userCompetencySelector, planId) {\n this._regionSelector = regionSelector;\n this._userCompetencySelector = userCompetencySelector;\n this._planId = planId;\n\n $(this._regionSelector).on('click', this._userCompetencySelector, this._handleClick.bind(this));\n };\n\n /**\n * Get the data from the closest TR and open the popup.\n *\n * @method _handleClick\n * @param {Event} e\n */\n UserCompetencyPopup.prototype._handleClick = function(e) {\n e.preventDefault();\n var tr = $(e.target).closest('tr');\n var competencyId = $(tr).data('competencyid');\n var userId = $(tr).data('userid');\n var planId = this._planId;\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_user_competency_summary_in_plan',\n args: {competencyid: competencyId, planid: planId},\n done: this._contextLoaded.bind(this),\n fail: notification.exception\n }]);\n // Log the user competency viewed in plan event.\n requests[0].then(function(result) {\n var eventMethodName = 'core_competency_user_competency_viewed_in_plan';\n // Trigger core_competency_user_competency_plan_viewed event instead if plan is already completed.\n if (result.plan.iscompleted) {\n eventMethodName = 'core_competency_user_competency_plan_viewed';\n }\n return ajax.call([{\n methodname: eventMethodName,\n args: {competencyid: competencyId, userid: userId, planid: planId}\n }])[0];\n }).catch(notification.exception);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _contextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._contextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/user_competency_summary_in_plan', context).done(function(html, js) {\n str.get_string('usercompetencysummary', 'report_competency').done(function(title) {\n (new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Refresh the page.\n *\n * @method _refresh\n */\n UserCompetencyPopup.prototype._refresh = function() {\n var planId = this._planId;\n\n ajax.call([{\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: planId},\n done: this._pageContextLoaded.bind(this),\n fail: notification.exception\n }]);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _pageContextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._pageContextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/plan_page', context).done(function(html, js) {\n templates.replaceNode(self._regionSelector, html, js);\n }).fail(notification.exception);\n };\n\n /** @property {String} The selector for the region with the user competencies */\n UserCompetencyPopup.prototype._regionSelector = null;\n /** @property {String} The selector for the region with a single user competencies */\n UserCompetencyPopup.prototype._userCompetencySelector = null;\n /** @property {Number} The plan Id */\n UserCompetencyPopup.prototype._planId = null;\n\n return /** @alias module:tool_lp/user_competency_plan_popup */ UserCompetencyPopup;\n\n});\n"],"names":["define","$","notification","str","ajax","templates","Dialogue","UserCompetencyPopup","regionSelector","userCompetencySelector","planId","_regionSelector","_userCompetencySelector","_planId","this","on","_handleClick","bind","prototype","e","preventDefault","tr","target","closest","competencyId","data","userId","call","methodname","args","competencyid","planid","done","_contextLoaded","fail","exception","then","result","eventMethodName","plan","iscompleted","userid","catch","context","self","render","html","js","get_string","title","runTemplateJS","_refresh","_pageContextLoaded","replaceNode"],"mappings":";;;;;;;AAuBAA,4CAAO,CAAC,SAAU,oBAAqB,WAAY,YAAa,iBAAkB,qBAC3E,SAASC,EAAGC,aAAcC,IAAKC,KAAMC,UAAWC,cAS/CC,oBAAsB,SAASC,eAAgBC,uBAAwBC,aAClEC,gBAAkBH,oBAClBI,wBAA0BH,4BAC1BI,QAAUH,OAEfT,EAAEa,KAAKH,iBAAiBI,GAAG,QAASD,KAAKF,wBAAyBE,KAAKE,aAAaC,KAAKH,eAS7FP,oBAAoBW,UAAUF,aAAe,SAASG,GAClDA,EAAEC,qBACEC,GAAKpB,EAAEkB,EAAEG,QAAQC,QAAQ,MACzBC,aAAevB,EAAEoB,IAAII,KAAK,gBAC1BC,OAASzB,EAAEoB,IAAII,KAAK,UACpBf,OAASI,KAAKD,QAEHT,KAAKuB,KAAK,CAAC,CACtBC,WAAY,mDACZC,KAAM,CAACC,aAAcN,aAAcO,OAAQrB,QAC3CsB,KAAMlB,KAAKmB,eAAehB,KAAKH,MAC/BoB,KAAMhC,aAAaiC,aAGd,GAAGC,MAAK,SAASC,YAClBC,gBAAkB,wDAElBD,OAAOE,KAAKC,cACZF,gBAAkB,+CAEflC,KAAKuB,KAAK,CAAC,CACdC,WAAYU,gBACZT,KAAM,CAACC,aAAcN,aAAciB,OAAQf,OAAQK,OAAQrB,WAC3D,MACLgC,MAAMxC,aAAaiC,YAS1B5B,oBAAoBW,UAAUe,eAAiB,SAASU,aAChDC,KAAO9B,KACXT,UAAUwC,OAAO,0CAA2CF,SAASX,MAAK,SAASc,KAAMC,IACrF5C,IAAI6C,WAAW,wBAAyB,qBAAqBhB,MAAK,SAASiB,WAClE3C,SAAS2C,MAAOH,KAAMzC,UAAU6C,cAAcjC,KAAKZ,UAAW0C,IAAKH,KAAKO,SAASlC,KAAK2B,OAAO,MACnGV,KAAKhC,aAAaiC,cACtBD,KAAKhC,aAAaiC,YAQzB5B,oBAAoBW,UAAUiC,SAAW,eACjCzC,OAASI,KAAKD,QAElBT,KAAKuB,KAAK,CAAC,CACPC,WAAY,6BACZC,KAAM,CAACE,OAAQrB,QACfsB,KAAMlB,KAAKsC,mBAAmBnC,KAAKH,MACnCoB,KAAMhC,aAAaiC,cAU3B5B,oBAAoBW,UAAUkC,mBAAqB,SAAST,aACpDC,KAAO9B,KACXT,UAAUwC,OAAO,oBAAqBF,SAASX,MAAK,SAASc,KAAMC,IAC/D1C,UAAUgD,YAAYT,KAAKjC,gBAAiBmC,KAAMC,OACnDb,KAAKhC,aAAaiC,YAIzB5B,oBAAoBW,UAAUP,gBAAkB,KAEhDJ,oBAAoBW,UAAUN,wBAA0B,KAExDL,oBAAoBW,UAAUL,QAAU,KAEuBN"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_workflow.min.js b/admin/tool/lp/amd/build/user_competency_workflow.min.js index b975a287e3b..e65a435128b 100644 --- a/admin/tool/lp/amd/build/user_competency_workflow.min.js +++ b/admin/tool/lp/amd/build/user_competency_workflow.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/user_competency_workflow",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/event_base"],function(a,b,c,d,e,f,g){var h=function(){g.prototype.constructor.apply(this,[])};h.prototype=Object.create(g.prototype);h.prototype._nodeSelector="[data-node=\"user-competency\"]";h.prototype._cancelReviewRequest=function(a){var b={methodname:"core_competency_user_competency_cancel_review_request",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-request-cancelled",a);this._trigger("status-changed",a)}.bind(this)).catch(function(){this._trigger("error-occured",a)}.bind(this))};h.prototype.cancelReviewRequest=function(a){this._cancelReviewRequest(a)};h.prototype._cancelReviewRequestHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.cancelReviewRequest(c)};h.prototype._requestReview=function(a){var b={methodname:"core_competency_user_competency_request_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-requested",a);this._trigger("status-changed",a)}.bind(this)).catch(function(){this._trigger("error-occured",a)}.bind(this))};h.prototype.requestReview=function(a){this._requestReview(a)};h.prototype._requestReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.requestReview(c)};h.prototype._startReview=function(a){var b={methodname:"core_competency_user_competency_start_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-started",a);this._trigger("status-changed",a)}.bind(this)).catch(function(){this._trigger("error-occured",a)}.bind(this))};h.prototype.startReview=function(a){this._startReview(a)};h.prototype._startReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.startReview(c)};h.prototype._stopReview=function(a){var b={methodname:"core_competency_user_competency_stop_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-stopped",a);this._trigger("status-changed",a)}.bind(this)).catch(function(){this._trigger("error-occured",a)}.bind(this))};h.prototype.stopReview=function(a){this._stopReview(a)};h.prototype._stopReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.stopReview(c)};h.prototype.enhanceMenubar=function(a){f.enhance(a,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this)})};h.prototype._findUserCompetencyData=function(a){var b=a.parents(this._nodeSelector),c;if(1!=b.length){throw new Error("The evidence node was not located.")}c=b.data();if("undefined"==typeof c||"undefined"==typeof c.userid||"undefined"==typeof c.competencyid){throw new Error("User competency data could not be found.")}return c};h.prototype.enhanceMenubar=function(a){f.enhance(a,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this),'[data-action="start-review"]':this._startReviewHandler.bind(this),'[data-action="stop-review"]':this._stopReviewHandler.bind(this)})};h.prototype.registerEvents=function(b){var c=a(b);c.find("[data-action=\"request-review\"]").click(this._requestReviewHandler.bind(this));c.find("[data-action=\"cancel-review-request\"]").click(this._cancelReviewRequestHandler.bind(this));c.find("[data-action=\"start-review\"]").click(this._startReviewHandler.bind(this));c.find("[data-action=\"stop-review\"]").click(this._stopReviewHandler.bind(this))};return h}); -//# sourceMappingURL=user_competency_workflow.min.js.map +/** + * User competency workflow. + * + * @module tool_lp/user_competency_workflow + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/user_competency_workflow",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/event_base"],(function($,Templates,Ajax,Notification,Str,Menubar,EventBase){var UserCompetencyWorkflow=function(){EventBase.prototype.constructor.apply(this,[])};return(UserCompetencyWorkflow.prototype=Object.create(EventBase.prototype))._nodeSelector='[data-node="user-competency"]',UserCompetencyWorkflow.prototype._cancelReviewRequest=function(data){var call={methodname:"core_competency_user_competency_cancel_review_request",args:{userid:data.userid,competencyid:data.competencyid}};Ajax.call([call])[0].then(function(){this._trigger("review-request-cancelled",data),this._trigger("status-changed",data)}.bind(this)).catch(function(){this._trigger("error-occured",data)}.bind(this))},UserCompetencyWorkflow.prototype.cancelReviewRequest=function(data){this._cancelReviewRequest(data)},UserCompetencyWorkflow.prototype._cancelReviewRequestHandler=function(e){e.preventDefault();var data=this._findUserCompetencyData($(e.target));this.cancelReviewRequest(data)},UserCompetencyWorkflow.prototype._requestReview=function(data){var call={methodname:"core_competency_user_competency_request_review",args:{userid:data.userid,competencyid:data.competencyid}};Ajax.call([call])[0].then(function(){this._trigger("review-requested",data),this._trigger("status-changed",data)}.bind(this)).catch(function(){this._trigger("error-occured",data)}.bind(this))},UserCompetencyWorkflow.prototype.requestReview=function(data){this._requestReview(data)},UserCompetencyWorkflow.prototype._requestReviewHandler=function(e){e.preventDefault();var data=this._findUserCompetencyData($(e.target));this.requestReview(data)},UserCompetencyWorkflow.prototype._startReview=function(data){var call={methodname:"core_competency_user_competency_start_review",args:{userid:data.userid,competencyid:data.competencyid}};Ajax.call([call])[0].then(function(){this._trigger("review-started",data),this._trigger("status-changed",data)}.bind(this)).catch(function(){this._trigger("error-occured",data)}.bind(this))},UserCompetencyWorkflow.prototype.startReview=function(data){this._startReview(data)},UserCompetencyWorkflow.prototype._startReviewHandler=function(e){e.preventDefault();var data=this._findUserCompetencyData($(e.target));this.startReview(data)},UserCompetencyWorkflow.prototype._stopReview=function(data){var call={methodname:"core_competency_user_competency_stop_review",args:{userid:data.userid,competencyid:data.competencyid}};Ajax.call([call])[0].then(function(){this._trigger("review-stopped",data),this._trigger("status-changed",data)}.bind(this)).catch(function(){this._trigger("error-occured",data)}.bind(this))},UserCompetencyWorkflow.prototype.stopReview=function(data){this._stopReview(data)},UserCompetencyWorkflow.prototype._stopReviewHandler=function(e){e.preventDefault();var data=this._findUserCompetencyData($(e.target));this.stopReview(data)},UserCompetencyWorkflow.prototype.enhanceMenubar=function(selector){Menubar.enhance(selector,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this)})},UserCompetencyWorkflow.prototype._findUserCompetencyData=function(node){var data,parent=node.parents(this._nodeSelector);if(1!=parent.length)throw new Error("The evidence node was not located.");if(void 0===(data=parent.data())||void 0===data.userid||void 0===data.competencyid)throw new Error("User competency data could not be found.");return data},UserCompetencyWorkflow.prototype.enhanceMenubar=function(selector){Menubar.enhance(selector,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this),'[data-action="start-review"]':this._startReviewHandler.bind(this),'[data-action="stop-review"]':this._stopReviewHandler.bind(this)})},UserCompetencyWorkflow.prototype.registerEvents=function(selector){var wrapper=$(selector);wrapper.find('[data-action="request-review"]').click(this._requestReviewHandler.bind(this)),wrapper.find('[data-action="cancel-review-request"]').click(this._cancelReviewRequestHandler.bind(this)),wrapper.find('[data-action="start-review"]').click(this._startReviewHandler.bind(this)),wrapper.find('[data-action="stop-review"]').click(this._stopReviewHandler.bind(this))},UserCompetencyWorkflow})); + +//# sourceMappingURL=user_competency_workflow.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_workflow.min.js.map b/admin/tool/lp/amd/build/user_competency_workflow.min.js.map index f843d5ce9e6..6828088a678 100644 --- a/admin/tool/lp/amd/build/user_competency_workflow.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_workflow.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/user_competency_workflow.js"],"names":["define","$","Templates","Ajax","Notification","Str","Menubar","EventBase","UserCompetencyWorkflow","prototype","constructor","apply","Object","create","_nodeSelector","_cancelReviewRequest","data","call","methodname","args","userid","competencyid","then","_trigger","bind","catch","cancelReviewRequest","_cancelReviewRequestHandler","e","preventDefault","_findUserCompetencyData","target","_requestReview","requestReview","_requestReviewHandler","_startReview","startReview","_startReviewHandler","_stopReview","stopReview","_stopReviewHandler","enhanceMenubar","selector","enhance","node","parent","parents","length","Error","registerEvents","wrapper","find","click"],"mappings":"AAsBAA,OAAM,oCAAC,CAAC,QAAD,CACC,gBADD,CAEC,WAFD,CAGC,mBAHD,CAIC,UAJD,CAKC,iBALD,CAMC,oBAND,CAAD,CAOE,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAA6BC,CAA7B,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAyDC,CAAzD,CAAoE,CAKxE,GAAIC,CAAAA,CAAsB,CAAG,UAAW,CACp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AAOhC,CAAAA,CACV,CAdD,CAqBAR,CAAsB,CAACC,SAAvB,CAAiCgC,cAAjC,CAAkD,SAASC,CAAT,CAAmB,CACjEpC,CAAO,CAACqC,OAAR,CAAgBD,CAAhB,CAA0B,CACtB,iCAAkC,KAAKR,qBAAL,CAA2BV,IAA3B,CAAgC,IAAhC,CADZ,CAEtB,wCAAyC,KAAKG,2BAAL,CAAiCH,IAAjC,CAAsC,IAAtC,CAFnB,CAGtB,+BAAgC,KAAKa,mBAAL,CAAyBb,IAAzB,CAA8B,IAA9B,CAHV,CAItB,8BAA+B,KAAKgB,kBAAL,CAAwBhB,IAAxB,CAA6B,IAA7B,CAJT,CAA1B,CAMH,CAPD,CAcAhB,CAAsB,CAACC,SAAvB,CAAiCwC,cAAjC,CAAkD,SAASP,CAAT,CAAmB,CACjE,GAAIQ,CAAAA,CAAO,CAAGjD,CAAC,CAACyC,CAAD,CAAf,CAEAQ,CAAO,CAACC,IAAR,CAAa,kCAAb,EAA+CC,KAA/C,CAAqD,KAAKlB,qBAAL,CAA2BV,IAA3B,CAAgC,IAAhC,CAArD,EACA0B,CAAO,CAACC,IAAR,CAAa,yCAAb,EAAsDC,KAAtD,CAA4D,KAAKzB,2BAAL,CAAiCH,IAAjC,CAAsC,IAAtC,CAA5D,EACA0B,CAAO,CAACC,IAAR,CAAa,gCAAb,EAA6CC,KAA7C,CAAmD,KAAKf,mBAAL,CAAyBb,IAAzB,CAA8B,IAA9B,CAAnD,EACA0B,CAAO,CAACC,IAAR,CAAa,+BAAb,EAA4CC,KAA5C,CAAkD,KAAKZ,kBAAL,CAAwBhB,IAAxB,CAA6B,IAA7B,CAAlD,CACH,CAPD,CASA,MAA4DhB,CAAAA,CAC/D,CAtQK,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 * User competency workflow.\n *\n * @module tool_lp/user_competency_workflow\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/event_base'],\n function($, Templates, Ajax, Notification, Str, Menubar, EventBase) {\n\n /**\n * UserCompetencyWorkflow class.\n */\n var UserCompetencyWorkflow = function() {\n EventBase.prototype.constructor.apply(this, []);\n };\n UserCompetencyWorkflow.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The selector to find the user competency data. */\n UserCompetencyWorkflow.prototype._nodeSelector = '[data-node=\"user-competency\"]';\n\n /**\n * Cancel a review request and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequest = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_cancel_review_request',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-request-cancelled', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Cancel a review request an refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype.cancelReviewRequest = function(data) {\n this._cancelReviewRequest(data);\n };\n\n /**\n * Cancel a review request handler.\n *\n * @param {Event} e The event.\n * @method _cancelReviewRequestHandler\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequestHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.cancelReviewRequest(data);\n };\n\n /**\n * Request a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _requestReview\n */\n UserCompetencyWorkflow.prototype._requestReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_request_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-requested', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Request a review.\n *\n * @param {Object} data The user competency data.\n * @method requestReview\n */\n UserCompetencyWorkflow.prototype.requestReview = function(data) {\n this._requestReview(data);\n };\n\n /**\n * Request a review handler.\n *\n * @param {Event} e The event.\n * @method _requestReviewHandler\n */\n UserCompetencyWorkflow.prototype._requestReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.requestReview(data);\n };\n\n /**\n * Start a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _startReview\n */\n UserCompetencyWorkflow.prototype._startReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_start_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n Ajax.call([call])[0].then(function() {\n this._trigger('review-started', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Start a review.\n *\n * @param {Object} data The user competency data.\n * @method startReview\n */\n UserCompetencyWorkflow.prototype.startReview = function(data) {\n this._startReview(data);\n };\n\n /**\n * Start a review handler.\n *\n * @param {Event} e The event.\n * @method _startReviewHandler\n */\n UserCompetencyWorkflow.prototype._startReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.startReview(data);\n };\n\n /**\n * Stop a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _stopReview\n */\n UserCompetencyWorkflow.prototype._stopReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_stop_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-stopped', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Stop a review.\n *\n * @param {Object} data The user competency data.\n * @method stopReview\n */\n UserCompetencyWorkflow.prototype.stopReview = function(data) {\n this._stopReview(data);\n };\n\n /**\n * Stop a review handler.\n *\n * @param {Event} e The event.\n * @method _stopReviewHandler\n */\n UserCompetencyWorkflow.prototype._stopReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.stopReview(data);\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n });\n };\n\n /**\n * Find the user competency data from a node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} User competency data.\n */\n UserCompetencyWorkflow.prototype._findUserCompetencyData = function(node) {\n var parent = node.parents(this._nodeSelector),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.userid === 'undefined' || typeof data.competencyid === 'undefined') {\n throw new Error('User competency data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n '[data-action=\"start-review\"]': this._startReviewHandler.bind(this),\n '[data-action=\"stop-review\"]': this._stopReviewHandler.bind(this),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * @param {String} selector The base selector to search nodes in and attach events.\n */\n UserCompetencyWorkflow.prototype.registerEvents = function(selector) {\n var wrapper = $(selector);\n\n wrapper.find('[data-action=\"request-review\"]').click(this._requestReviewHandler.bind(this));\n wrapper.find('[data-action=\"cancel-review-request\"]').click(this._cancelReviewRequestHandler.bind(this));\n wrapper.find('[data-action=\"start-review\"]').click(this._startReviewHandler.bind(this));\n wrapper.find('[data-action=\"stop-review\"]').click(this._stopReviewHandler.bind(this));\n };\n\n return /** @alias module:tool_lp/user_competency_actions */ UserCompetencyWorkflow;\n});\n"],"file":"user_competency_workflow.min.js"} \ No newline at end of file +{"version":3,"file":"user_competency_workflow.min.js","sources":["../src/user_competency_workflow.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 * User competency workflow.\n *\n * @module tool_lp/user_competency_workflow\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/event_base'],\n function($, Templates, Ajax, Notification, Str, Menubar, EventBase) {\n\n /**\n * UserCompetencyWorkflow class.\n */\n var UserCompetencyWorkflow = function() {\n EventBase.prototype.constructor.apply(this, []);\n };\n UserCompetencyWorkflow.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The selector to find the user competency data. */\n UserCompetencyWorkflow.prototype._nodeSelector = '[data-node=\"user-competency\"]';\n\n /**\n * Cancel a review request and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequest = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_cancel_review_request',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-request-cancelled', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Cancel a review request an refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype.cancelReviewRequest = function(data) {\n this._cancelReviewRequest(data);\n };\n\n /**\n * Cancel a review request handler.\n *\n * @param {Event} e The event.\n * @method _cancelReviewRequestHandler\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequestHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.cancelReviewRequest(data);\n };\n\n /**\n * Request a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _requestReview\n */\n UserCompetencyWorkflow.prototype._requestReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_request_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-requested', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Request a review.\n *\n * @param {Object} data The user competency data.\n * @method requestReview\n */\n UserCompetencyWorkflow.prototype.requestReview = function(data) {\n this._requestReview(data);\n };\n\n /**\n * Request a review handler.\n *\n * @param {Event} e The event.\n * @method _requestReviewHandler\n */\n UserCompetencyWorkflow.prototype._requestReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.requestReview(data);\n };\n\n /**\n * Start a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _startReview\n */\n UserCompetencyWorkflow.prototype._startReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_start_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n Ajax.call([call])[0].then(function() {\n this._trigger('review-started', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Start a review.\n *\n * @param {Object} data The user competency data.\n * @method startReview\n */\n UserCompetencyWorkflow.prototype.startReview = function(data) {\n this._startReview(data);\n };\n\n /**\n * Start a review handler.\n *\n * @param {Event} e The event.\n * @method _startReviewHandler\n */\n UserCompetencyWorkflow.prototype._startReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.startReview(data);\n };\n\n /**\n * Stop a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _stopReview\n */\n UserCompetencyWorkflow.prototype._stopReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_stop_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-stopped', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Stop a review.\n *\n * @param {Object} data The user competency data.\n * @method stopReview\n */\n UserCompetencyWorkflow.prototype.stopReview = function(data) {\n this._stopReview(data);\n };\n\n /**\n * Stop a review handler.\n *\n * @param {Event} e The event.\n * @method _stopReviewHandler\n */\n UserCompetencyWorkflow.prototype._stopReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.stopReview(data);\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n });\n };\n\n /**\n * Find the user competency data from a node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} User competency data.\n */\n UserCompetencyWorkflow.prototype._findUserCompetencyData = function(node) {\n var parent = node.parents(this._nodeSelector),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.userid === 'undefined' || typeof data.competencyid === 'undefined') {\n throw new Error('User competency data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n '[data-action=\"start-review\"]': this._startReviewHandler.bind(this),\n '[data-action=\"stop-review\"]': this._stopReviewHandler.bind(this),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * @param {String} selector The base selector to search nodes in and attach events.\n */\n UserCompetencyWorkflow.prototype.registerEvents = function(selector) {\n var wrapper = $(selector);\n\n wrapper.find('[data-action=\"request-review\"]').click(this._requestReviewHandler.bind(this));\n wrapper.find('[data-action=\"cancel-review-request\"]').click(this._cancelReviewRequestHandler.bind(this));\n wrapper.find('[data-action=\"start-review\"]').click(this._startReviewHandler.bind(this));\n wrapper.find('[data-action=\"stop-review\"]').click(this._stopReviewHandler.bind(this));\n };\n\n return /** @alias module:tool_lp/user_competency_actions */ UserCompetencyWorkflow;\n});\n"],"names":["define","$","Templates","Ajax","Notification","Str","Menubar","EventBase","UserCompetencyWorkflow","prototype","constructor","apply","this","Object","create","_nodeSelector","_cancelReviewRequest","data","call","methodname","args","userid","competencyid","then","_trigger","bind","catch","cancelReviewRequest","_cancelReviewRequestHandler","e","preventDefault","_findUserCompetencyData","target","_requestReview","requestReview","_requestReviewHandler","_startReview","startReview","_startReviewHandler","_stopReview","stopReview","_stopReviewHandler","enhanceMenubar","selector","enhance","node","parent","parents","length","Error","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,0CAAO,CAAC,SACA,i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UACvDrC,QAAQsC,QAAQD,SAAU,kCACY/B,KAAKuB,sBAAsBV,KAAKb,8CACzBA,KAAKgB,4BAA4BH,KAAKb,qCAC/CA,KAAK0B,oBAAoBb,KAAKb,oCAC/BA,KAAK6B,mBAAmBhB,KAAKb,SASpEJ,uBAAuBC,UAAUyC,eAAiB,SAASP,cACnDQ,QAAUlD,EAAE0C,UAEhBQ,QAAQC,KAAK,kCAAkCC,MAAMzC,KAAKuB,sBAAsBV,KAAKb,OACrFuC,QAAQC,KAAK,yCAAyCC,MAAMzC,KAAKgB,4BAA4BH,KAAKb,OAClGuC,QAAQC,KAAK,gCAAgCC,MAAMzC,KAAK0B,oBAAoBb,KAAKb,OACjFuC,QAAQC,KAAK,+BAA+BC,MAAMzC,KAAK6B,mBAAmBhB,KAAKb,QAGvBJ"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_evidence_actions.min.js b/admin/tool/lp/amd/build/user_evidence_actions.min.js index d8c7b8efe08..9d0ec07c6da 100644 --- a/admin/tool/lp/amd/build/user_evidence_actions.min.js +++ b/admin/tool/lp/amd/build/user_evidence_actions.min.js @@ -1,2 +1,10 @@ -define ("tool_lp/user_evidence_actions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/competencypicker_user_plans"],function(a,b,c,d,e,f,g){var h=function(a){this._type=a;if("evidence"===a){this._region="[data-region=\"user-evidence-page\"]";this._evidenceNode="[data-region=\"user-evidence-page\"]";this._template="tool_lp/user_evidence_page";this._contextMethod="tool_lp_data_for_user_evidence_page"}else if("list"===a){this._region="[data-region=\"user-evidence-list\"]";this._evidenceNode="[data-region=\"user-evidence-node\"]";this._template="tool_lp/user_evidence_list_page";this._contextMethod="tool_lp_data_for_user_evidence_list_page"}else{throw new TypeError("Unexpected type.")}};h.prototype._contextMethod=null;h.prototype._evidenceNode=null;h.prototype._region=null;h.prototype._template=null;h.prototype._type=null;h.prototype._getContextArgs=function(a){var b=this,c={};if("evidence"===b._type){c={id:a.id}}else if("list"===b._type){c={userid:a.userid}}return c};h.prototype._renderView=function(c){var d=this;return b.render(d._template,c).then(function(c,e){b.replaceNode(a(d._region),c,e)})};h.prototype._callAndRefresh=function(b,e){var f=this;b.push({methodname:f._contextMethod,args:f._getContextArgs(e)});return a.when.apply(a.when,c.call(b)).then(function(){return f._renderView(arguments[arguments.length-1])}).fail(d.exception)};h.prototype._doDelete=function(a){var b=this,c=[{methodname:"core_competency_delete_user_evidence",args:{id:a.id}}];b._callAndRefresh(c,a)};h.prototype.deleteEvidence=function(a){var b=this,f;f=c.call([{methodname:"core_competency_read_user_evidence",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"deleteuserevidence",component:"tool_lp",param:c.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doDelete(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._deleteEvidenceHandler=function(b){b.preventDefault();var c=this._findEvidenceData(a(b.target));this.deleteEvidence(c)};h.prototype._doCreateUserEvidenceCompetency=function(b,c){var d=this,e=[];a.each(c,function(a,c){e.push({methodname:"core_competency_create_user_evidence_competency",args:{userevidenceid:b.id,competencyid:c}})});d._callAndRefresh(e,b)};h.prototype.createUserEvidenceCompetency=function(a){var b=this,c=new g(a.userid);c.on("save",function(c,d){var e=d.competencyIds;b._doCreateUserEvidenceCompetency(a,e,d.requestReview)});c.display()};h.prototype._createUserEvidenceCompetencyHandler=function(b){b.preventDefault();var c=this._findEvidenceData(a(b.target));this.createUserEvidenceCompetency(c)};h.prototype._doDeleteUserEvidenceCompetency=function(a,b){var c=this,d=[];d.push({methodname:"core_competency_delete_user_evidence_competency",args:{userevidenceid:a.id,competencyid:b}});c._callAndRefresh(d,a)};h.prototype.deleteUserEvidenceCompetency=function(a,b){this._doDeleteUserEvidenceCompetency(a,b)};h.prototype._deleteUserEvidenceCompetencyHandler=function(b){var c=this._findEvidenceData(a(b.currentTarget)),d=a(b.currentTarget).data("id");b.preventDefault();this.deleteUserEvidenceCompetency(c,d)};h.prototype._doReviewUserEvidenceCompetencies=function(a){var b=this,c=[{methodname:"core_competency_request_review_of_user_evidence_linked_competencies",args:{id:a.id}}];b._callAndRefresh(c,a)};h.prototype.reviewUserEvidenceCompetencies=function(a){var b=this,f;f=c.call([{methodname:"core_competency_read_user_evidence",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"sendallcompetenciestoreview",component:"tool_lp",param:c.name},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doReviewUserEvidenceCompetencies(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._reviewUserEvidenceCompetenciesHandler=function(b){b.preventDefault();var c=this._findEvidenceData(a(b.target));this.reviewUserEvidenceCompetencies(c)};h.prototype._findEvidenceData=function(b){var c=b.parentsUntil(a(this._region).parent(),this._evidenceNode),d;if(1!=c.length){throw new Error("The evidence node was not located.")}d=c.data();if("undefined"==typeof d||"undefined"==typeof d.id){throw new Error("Evidence data could not be found.")}return d};h.prototype.enhanceMenubar=function(a){var b=this;f.enhance(a,{'[data-action="user-evidence-delete"]':b._deleteEvidenceHandler.bind(b),'[data-action="link-competency"]':b._createUserEvidenceCompetencyHandler.bind(b),'[data-action="send-competencies-review"]':b._reviewUserEvidenceCompetenciesHandler.bind(b)})};h.prototype.registerEvents=function(){var b=a(this._region),c=this;b.find("[data-action=\"user-evidence-delete\"]").click(c._deleteEvidenceHandler.bind(c));b.find("[data-action=\"link-competency\"]").click(c._createUserEvidenceCompetencyHandler.bind(c));b.find("[data-action=\"delete-competency-link\"]").click(c._deleteUserEvidenceCompetencyHandler.bind(c));b.find("[data-action=\"send-competencies-review\"]").click(c._reviewUserEvidenceCompetenciesHandler.bind(c))};return h}); -//# sourceMappingURL=user_evidence_actions.min.js.map +/** + * User evidence actions. + * + * @module tool_lp/user_evidence_actions + * @copyright 2015 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_lp/user_evidence_actions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/competencypicker_user_plans"],(function($,templates,ajax,notification,str,Menubar,PickerUserPlans){var UserEvidenceActions=function(type){if(this._type=type,"evidence"===type)this._region='[data-region="user-evidence-page"]',this._evidenceNode='[data-region="user-evidence-page"]',this._template="tool_lp/user_evidence_page",this._contextMethod="tool_lp_data_for_user_evidence_page";else{if("list"!==type)throw new TypeError("Unexpected type.");this._region='[data-region="user-evidence-list"]',this._evidenceNode='[data-region="user-evidence-node"]',this._template="tool_lp/user_evidence_list_page",this._contextMethod="tool_lp_data_for_user_evidence_list_page"}};return UserEvidenceActions.prototype._contextMethod=null,UserEvidenceActions.prototype._evidenceNode=null,UserEvidenceActions.prototype._region=null,UserEvidenceActions.prototype._template=null,UserEvidenceActions.prototype._type=null,UserEvidenceActions.prototype._getContextArgs=function(evidenceData){var args={};return"evidence"===this._type?args={id:evidenceData.id}:"list"===this._type&&(args={userid:evidenceData.userid}),args},UserEvidenceActions.prototype._renderView=function(context){var self=this;return templates.render(self._template,context).then((function(newhtml,newjs){templates.replaceNode($(self._region),newhtml,newjs)}))},UserEvidenceActions.prototype._callAndRefresh=function(calls,evidenceData){var self=this;return calls.push({methodname:self._contextMethod,args:self._getContextArgs(evidenceData)}),$.when.apply($.when,ajax.call(calls)).then((function(){return self._renderView(arguments[arguments.length-1])})).fail(notification.exception)},UserEvidenceActions.prototype._doDelete=function(evidenceData){var calls=[{methodname:"core_competency_delete_user_evidence",args:{id:evidenceData.id}}];this._callAndRefresh(calls,evidenceData)},UserEvidenceActions.prototype.deleteEvidence=function(evidenceData){var self=this;ajax.call([{methodname:"core_competency_read_user_evidence",args:{id:evidenceData.id}}])[0].done((function(evidence){str.get_strings([{key:"confirm",component:"moodle"},{key:"deleteuserevidence",component:"tool_lp",param:evidence.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){self._doDelete(evidenceData)}))})).fail(notification.exception)})).fail(notification.exception)},UserEvidenceActions.prototype._deleteEvidenceHandler=function(e){e.preventDefault();var data=this._findEvidenceData($(e.target));this.deleteEvidence(data)},UserEvidenceActions.prototype._doCreateUserEvidenceCompetency=function(evidenceData,competencyIds){var calls=[];$.each(competencyIds,(function(index,competencyId){calls.push({methodname:"core_competency_create_user_evidence_competency",args:{userevidenceid:evidenceData.id,competencyid:competencyId}})})),this._callAndRefresh(calls,evidenceData)},UserEvidenceActions.prototype.createUserEvidenceCompetency=function(evidenceData){var self=this,picker=new PickerUserPlans(evidenceData.userid);picker.on("save",(function(e,data){var competencyIds=data.competencyIds;self._doCreateUserEvidenceCompetency(evidenceData,competencyIds,data.requestReview)})),picker.display()},UserEvidenceActions.prototype._createUserEvidenceCompetencyHandler=function(e){e.preventDefault();var data=this._findEvidenceData($(e.target));this.createUserEvidenceCompetency(data)},UserEvidenceActions.prototype._doDeleteUserEvidenceCompetency=function(evidenceData,competencyId){var calls=[];calls.push({methodname:"core_competency_delete_user_evidence_competency",args:{userevidenceid:evidenceData.id,competencyid:competencyId}}),this._callAndRefresh(calls,evidenceData)},UserEvidenceActions.prototype.deleteUserEvidenceCompetency=function(evidenceData,competencyId){this._doDeleteUserEvidenceCompetency(evidenceData,competencyId)},UserEvidenceActions.prototype._deleteUserEvidenceCompetencyHandler=function(e){var data=this._findEvidenceData($(e.currentTarget)),competencyId=$(e.currentTarget).data("id");e.preventDefault(),this.deleteUserEvidenceCompetency(data,competencyId)},UserEvidenceActions.prototype._doReviewUserEvidenceCompetencies=function(evidenceData){var calls=[{methodname:"core_competency_request_review_of_user_evidence_linked_competencies",args:{id:evidenceData.id}}];this._callAndRefresh(calls,evidenceData)},UserEvidenceActions.prototype.reviewUserEvidenceCompetencies=function(evidenceData){var self=this;ajax.call([{methodname:"core_competency_read_user_evidence",args:{id:evidenceData.id}}])[0].done((function(evidence){str.get_strings([{key:"confirm",component:"moodle"},{key:"sendallcompetenciestoreview",component:"tool_lp",param:evidence.name},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],(function(){self._doReviewUserEvidenceCompetencies(evidenceData)}))})).fail(notification.exception)})).fail(notification.exception)},UserEvidenceActions.prototype._reviewUserEvidenceCompetenciesHandler=function(e){e.preventDefault();var data=this._findEvidenceData($(e.target));this.reviewUserEvidenceCompetencies(data)},UserEvidenceActions.prototype._findEvidenceData=function(node){var data,parent=node.parentsUntil($(this._region).parent(),this._evidenceNode);if(1!=parent.length)throw new Error("The evidence node was not located.");if(void 0===(data=parent.data())||void 0===data.id)throw new Error("Evidence data could not be found.");return data},UserEvidenceActions.prototype.enhanceMenubar=function(selector){Menubar.enhance(selector,{'[data-action="user-evidence-delete"]':this._deleteEvidenceHandler.bind(this),'[data-action="link-competency"]':this._createUserEvidenceCompetencyHandler.bind(this),'[data-action="send-competencies-review"]':this._reviewUserEvidenceCompetenciesHandler.bind(this)})},UserEvidenceActions.prototype.registerEvents=function(){var wrapper=$(this._region);wrapper.find('[data-action="user-evidence-delete"]').click(this._deleteEvidenceHandler.bind(this)),wrapper.find('[data-action="link-competency"]').click(this._createUserEvidenceCompetencyHandler.bind(this)),wrapper.find('[data-action="delete-competency-link"]').click(this._deleteUserEvidenceCompetencyHandler.bind(this)),wrapper.find('[data-action="send-competencies-review"]').click(this._reviewUserEvidenceCompetenciesHandler.bind(this))},UserEvidenceActions})); + +//# sourceMappingURL=user_evidence_actions.min.js.map \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_evidence_actions.min.js.map b/admin/tool/lp/amd/build/user_evidence_actions.min.js.map index e4ce2adbb68..719e3f31120 100644 --- a/admin/tool/lp/amd/build/user_evidence_actions.min.js.map +++ b/admin/tool/lp/amd/build/user_evidence_actions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/user_evidence_actions.js"],"names":["define","$","templates","ajax","notification","str","Menubar","PickerUserPlans","UserEvidenceActions","type","_type","_region","_evidenceNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","evidenceData","self","args","id","userid","_renderView","context","render","then","newhtml","newjs","replaceNode","_callAndRefresh","calls","push","methodname","when","apply","call","arguments","length","fail","exception","_doDelete","deleteEvidence","requests","done","evidence","get_strings","key","component","param","name","strings","confirm","_deleteEvidenceHandler","e","preventDefault","data","_findEvidenceData","target","_doCreateUserEvidenceCompetency","competencyIds","each","index","competencyId","userevidenceid","competencyid","createUserEvidenceCompetency","picker","on","requestReview","display","_createUserEvidenceCompetencyHandler","_doDeleteUserEvidenceCompetency","deleteUserEvidenceCompetency","_deleteUserEvidenceCompetencyHandler","currentTarget","_doReviewUserEvidenceCompetencies","reviewUserEvidenceCompetencies","_reviewUserEvidenceCompetenciesHandler","node","parent","parentsUntil","Error","enhanceMenubar","selector","enhance","bind","registerEvents","wrapper","find","click"],"mappings":"AAsBAA,OAAM,iCAAC,CAAC,QAAD,CACC,gBADD,CAEC,WAFD,CAGC,mBAHD,CAIC,UAJD,CAKC,iBALD,CAMC,qCAND,CAAD,CAOE,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAA6BC,CAA7B,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAyDC,CAAzD,CAA0E,CAS9E,GAAIC,CAAAA,CAAmB,CAAG,SAASC,CAAT,CAAe,CACrC,KAAKC,KAAL,CAAaD,CAAb,CAEA,GAAa,UAAT,GAAAA,CAAJ,CAAyB,CAErB,KAAKE,OAAL,CAAe,sCAAf,CACA,KAAKC,aAAL,CAAqB,sCAArB,CACA,KAAKC,SAAL,CAAiB,4BAAjB,CACA,KAAKC,cAAL,CAAsB,qCAEzB,CAPD,IAOO,IAAa,MAAT,GAAAL,CAAJ,CAAqB,CAExB,KAAKE,OAAL,CAAe,sCAAf,CACA,KAAKC,aAAL,CAAqB,sCAArB,CACA,KAAKC,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CAA/C,CAA7D,EACAqE,CAAO,CAACC,IAAR,CAAa,4CAAb,EAAyDC,KAAzD,CAA+DvE,CAAI,CAAC2D,sCAAL,CAA4CQ,IAA5C,CAAiDnE,CAAjD,CAA/D,CACH,CARD,CAUA,MAA0DX,CAAAA,CAC7D,CAzXK,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 * User evidence actions.\n *\n * @module tool_lp/user_evidence_actions\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker_user_plans'],\n function($, templates, ajax, notification, str, Menubar, PickerUserPlans) {\n\n /**\n * UserEvidenceActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var UserEvidenceActions = function(type) {\n this._type = type;\n\n if (type === 'evidence') {\n // This is the page to view one evidence.\n this._region = '[data-region=\"user-evidence-page\"]';\n this._evidenceNode = '[data-region=\"user-evidence-page\"]';\n this._template = 'tool_lp/user_evidence_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_page';\n\n } else if (type === 'list') {\n // This is the page to view a list of evidence.\n this._region = '[data-region=\"user-evidence-list\"]';\n this._evidenceNode = '[data-region=\"user-evidence-node\"]';\n this._template = 'tool_lp/user_evidence_list_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_list_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n UserEvidenceActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the evidence. */\n UserEvidenceActions.prototype._evidenceNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n UserEvidenceActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n UserEvidenceActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n UserEvidenceActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Object} List of arguments.\n */\n UserEvidenceActions.prototype._getContextArgs = function(evidenceData) {\n var self = this,\n args = {};\n\n if (self._type === 'evidence') {\n args = {\n id: evidenceData.id\n };\n\n } else if (self._type === 'list') {\n args = {\n userid: evidenceData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n templates.replaceNode($(self._region), newhtml, newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._callAndRefresh = function(calls, evidenceData) {\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(evidenceData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($.when, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception);\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doDelete = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_user_evidence',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.deleteEvidence = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteuserevidence', component: 'tool_lp', param: evidence.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete evidence X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Delete evidence handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteEvidenceHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.deleteEvidence(data);\n };\n\n /**\n * Link a competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyIds The competency IDs.\n */\n UserEvidenceActions.prototype._doCreateUserEvidenceCompetency = function(evidenceData, competencyIds) {\n var self = this,\n calls = [];\n\n $.each(competencyIds, function(index, competencyId) {\n calls.push({\n methodname: 'core_competency_create_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Create a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.createUserEvidenceCompetency = function(evidenceData) {\n var self = this,\n picker = new PickerUserPlans(evidenceData.userid);\n\n picker.on('save', function(e, data) {\n var competencyIds = data.competencyIds;\n self._doCreateUserEvidenceCompetency(evidenceData, competencyIds, data.requestReview);\n });\n\n picker.display();\n };\n\n /**\n * Create user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._createUserEvidenceCompetencyHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.createUserEvidenceCompetency(data);\n };\n\n /**\n * Remove a linked competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype._doDeleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n var self = this,\n calls = [];\n\n calls.push({\n methodname: 'core_competency_delete_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype.deleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n this._doDeleteUserEvidenceCompetency(evidenceData, competencyId);\n };\n\n /**\n * Delete user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteUserEvidenceCompetencyHandler = function(e) {\n var data = this._findEvidenceData($(e.currentTarget)),\n competencyId = $(e.currentTarget).data('id');\n e.preventDefault();\n this.deleteUserEvidenceCompetency(data, competencyId);\n };\n\n /**\n * Send request review for user evidence competencies and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doReviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_request_review_of_user_evidence_linked_competencies',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Send request review for user evidence competencies.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.reviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'sendallcompetenciestoreview', component: 'tool_lp', param: evidence.name},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Send all competencies in review for X?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n self._doReviewUserEvidenceCompetencies(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Send request review for user evidence competencies handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._reviewUserEvidenceCompetenciesHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.reviewUserEvidenceCompetencies(data);\n };\n\n /**\n * Find the evidence data from the evidence node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Evidence data.\n */\n UserEvidenceActions.prototype._findEvidenceData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._evidenceNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Evidence data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserEvidenceActions.prototype.enhanceMenubar = function(selector) {\n var self = this;\n Menubar.enhance(selector, {\n '[data-action=\"user-evidence-delete\"]': self._deleteEvidenceHandler.bind(self),\n '[data-action=\"link-competency\"]': self._createUserEvidenceCompetencyHandler.bind(self),\n '[data-action=\"send-competencies-review\"]': self._reviewUserEvidenceCompetenciesHandler.bind(self),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n UserEvidenceActions.prototype.registerEvents = function() {\n var wrapper = $(this._region),\n self = this;\n\n wrapper.find('[data-action=\"user-evidence-delete\"]').click(self._deleteEvidenceHandler.bind(self));\n wrapper.find('[data-action=\"link-competency\"]').click(self._createUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"delete-competency-link\"]').click(self._deleteUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"send-competencies-review\"]').click(self._reviewUserEvidenceCompetenciesHandler.bind(self));\n };\n\n return /** @alias module:tool_lp/user_evidence_actions */ UserEvidenceActions;\n});\n"],"file":"user_evidence_actions.min.js"} \ No newline at end of file +{"version":3,"file":"user_evidence_actions.min.js","sources":["../src/user_evidence_actions.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 * User evidence actions.\n *\n * @module tool_lp/user_evidence_actions\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker_user_plans'],\n function($, templates, ajax, notification, str, Menubar, PickerUserPlans) {\n\n /**\n * UserEvidenceActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var UserEvidenceActions = function(type) {\n this._type = type;\n\n if (type === 'evidence') {\n // This is the page to view one evidence.\n this._region = '[data-region=\"user-evidence-page\"]';\n this._evidenceNode = '[data-region=\"user-evidence-page\"]';\n this._template = 'tool_lp/user_evidence_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_page';\n\n } else if (type === 'list') {\n // This is the page to view a list of evidence.\n this._region = '[data-region=\"user-evidence-list\"]';\n this._evidenceNode = '[data-region=\"user-evidence-node\"]';\n this._template = 'tool_lp/user_evidence_list_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_list_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n UserEvidenceActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the evidence. */\n UserEvidenceActions.prototype._evidenceNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n UserEvidenceActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n UserEvidenceActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n UserEvidenceActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Object} List of arguments.\n */\n UserEvidenceActions.prototype._getContextArgs = function(evidenceData) {\n var self = this,\n args = {};\n\n if (self._type === 'evidence') {\n args = {\n id: evidenceData.id\n };\n\n } else if (self._type === 'list') {\n args = {\n userid: evidenceData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n templates.replaceNode($(self._region), newhtml, newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._callAndRefresh = function(calls, evidenceData) {\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(evidenceData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($.when, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception);\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doDelete = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_user_evidence',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.deleteEvidence = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteuserevidence', component: 'tool_lp', param: evidence.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete evidence X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Delete evidence handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteEvidenceHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.deleteEvidence(data);\n };\n\n /**\n * Link a competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyIds The competency IDs.\n */\n UserEvidenceActions.prototype._doCreateUserEvidenceCompetency = function(evidenceData, competencyIds) {\n var self = this,\n calls = [];\n\n $.each(competencyIds, function(index, competencyId) {\n calls.push({\n methodname: 'core_competency_create_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Create a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.createUserEvidenceCompetency = function(evidenceData) {\n var self = this,\n picker = new PickerUserPlans(evidenceData.userid);\n\n picker.on('save', function(e, data) {\n var competencyIds = data.competencyIds;\n self._doCreateUserEvidenceCompetency(evidenceData, competencyIds, data.requestReview);\n });\n\n picker.display();\n };\n\n /**\n * Create user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._createUserEvidenceCompetencyHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.createUserEvidenceCompetency(data);\n };\n\n /**\n * Remove a linked competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype._doDeleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n var self = this,\n calls = [];\n\n calls.push({\n methodname: 'core_competency_delete_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype.deleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n this._doDeleteUserEvidenceCompetency(evidenceData, competencyId);\n };\n\n /**\n * Delete user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteUserEvidenceCompetencyHandler = function(e) {\n var data = this._findEvidenceData($(e.currentTarget)),\n competencyId = $(e.currentTarget).data('id');\n e.preventDefault();\n this.deleteUserEvidenceCompetency(data, competencyId);\n };\n\n /**\n * Send request review for user evidence competencies and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doReviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_request_review_of_user_evidence_linked_competencies',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Send request review for user evidence competencies.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.reviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'sendallcompetenciestoreview', component: 'tool_lp', param: evidence.name},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Send all competencies in review for X?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n self._doReviewUserEvidenceCompetencies(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Send request review for user evidence competencies handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._reviewUserEvidenceCompetenciesHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.reviewUserEvidenceCompetencies(data);\n };\n\n /**\n * Find the evidence data from the evidence node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Evidence data.\n */\n UserEvidenceActions.prototype._findEvidenceData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._evidenceNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Evidence data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserEvidenceActions.prototype.enhanceMenubar = function(selector) {\n var self = this;\n Menubar.enhance(selector, {\n '[data-action=\"user-evidence-delete\"]': self._deleteEvidenceHandler.bind(self),\n '[data-action=\"link-competency\"]': self._createUserEvidenceCompetencyHandler.bind(self),\n '[data-action=\"send-competencies-review\"]': self._reviewUserEvidenceCompetenciesHandler.bind(self),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n UserEvidenceActions.prototype.registerEvents = function() {\n var wrapper = $(this._region),\n self = this;\n\n wrapper.find('[data-action=\"user-evidence-delete\"]').click(self._deleteEvidenceHandler.bind(self));\n wrapper.find('[data-action=\"link-competency\"]').click(self._createUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"delete-competency-link\"]').click(self._deleteUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"send-competencies-review\"]').click(self._reviewUserEvidenceCompetenciesHandler.bind(self));\n };\n\n return /** @alias module:tool_lp/user_evidence_actions */ UserEvidenceActions;\n});\n"],"names":["define","$","templates","ajax","notification","str","Menubar","PickerUserPlans","UserEvidenceActions","type","_type","_region","_evidenceNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","evidenceData","args","this","id","userid","_renderView","context","self","render","then","newhtml","newjs","replaceNode","_callAndRefresh","calls","push","methodname","when","apply","call","arguments","length","fail","exception","_doDelete","deleteEvidence","done","evidence","get_strings","key","component","param","name","strings","confirm","_deleteEvidenceHandler","e","preventDefault","data","_findEvidenceData","target","_doCreateUserEvidenceCompetency","competencyIds","each","index","competencyId","userevidenceid","competencyid","createUserEvidenceCompetency","picker","on","requestReview","display","_createUserEvidenceCompetencyHandler","_doDeleteUserEvidenceCompetency","deleteUserEvidenceCompetency","_deleteUserEvidenceCompetencyHandler","currentTarget","_doReviewUserEvidenceCompetencies","reviewUserEvidenceCompetencies","_reviewUserEvidenceCompetenciesHandler","node","parent","parentsUntil","Error","enhanceMenubar","selector","enhance","bind","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,uCAAO,CAAC,SACA,iBACA,YACA,oBACA,WACA,kBACA,wCACA,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,QAASC,qBASzDC,oBAAsB,SAASC,cAC1BC,MAAQD,KAEA,aAATA,UAEKE,QAAU,0CACVC,cAAgB,0CAChBC,UAAY,kCACZC,eAAiB,0CAEnB,CAAA,GAAa,SAATL,WAQD,IAAIM,UAAU,yBANfJ,QAAU,0CACVC,cAAgB,0CACh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,UAAUmE,eAAiB,SAASC,UAEpD9E,QAAQ+E,QAAQD,SAAU,wCADfhE,KAEsCiC,uBAAuBiC,KAF7DlE,wCAAAA,KAGiCmD,qCAAqCe,KAHtElE,iDAAAA,KAI0C0D,uCAAuCQ,KAJjFlE,SAcfZ,oBAAoBQ,UAAUuE,eAAiB,eACvCC,QAAUvF,EAAEmB,KAAKT,SAGrB6E,QAAQC,KAAK,wCAAwCC,MAF1CtE,KAEqDiC,uBAAuBiC,KAF5ElE,OAGXoE,QAAQC,KAAK,mCAAmCC,MAHrCtE,KAGgDmD,qCAAqCe,KAHrFlE,OAIXoE,QAAQC,KAAK,0CAA0CC,MAJ5CtE,KAIuDsD,qCAAqCY,KAJ5FlE,OAKXoE,QAAQC,KAAK,4CAA4CC,MAL9CtE,KAKyD0D,uCAAuCQ,KALhGlE,QAQ2CZ"} \ No newline at end of file diff --git a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js index 2e8537e4ccb..d30bd3f47fd 100644 --- a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js +++ b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js @@ -1 +1 @@ -YUI.add("moodle-tool_monitor-dropdown",function(s,e){function t(){t.superclass.constructor.apply(this,arguments)}var n="#id_plugin",i="#id_eventname",a="option";s.extend(t,s.Base,{plugin:null,eventname:null,initializer:function(){this.plugin=s.one(n),this.eventname=s.one(i);var e=this.eventname.get("value");this.updateEventsList(),this.updateSelection(e),this.plugin.on("change",this.updateEventsList,this)},updateEventsList:function(){var n,e,t,i=this.plugin.get("value"),o="\\"+i+"\\";this.eventname.all(a).remove(!0),e=this.get("eventlist"),(t=s.Node.create('")).set("selected","selected"),this.eventname.appendChild(t),s.Object.each(e,function(e,t){t.substring(0,o.length)===o&&(n=s.Node.create('"),this.eventname.appendChild(n))},this)},updateSelection:function(t){this.eventname.get("options").each(function(e){e.get("value")===t&&e.set("selected","selected")},this)}},{NAME:"dropDown",ATTRS:{eventlist:null}}),s.namespace("M.tool_monitor.DropDown").init=function(e){return new t(e)}},"@VERSION@",{requires:["base","event","node"]}); \ No newline at end of file +YUI.add("moodle-tool_monitor-dropdown",function(o,e){function t(){t.superclass.constructor.apply(this,arguments)}var n="#id_plugin",i="#id_eventname",s="option";o.extend(t,o.Base,{plugin:null,eventname:null,initializer:function(){this.plugin=o.one(n),this.eventname=o.one(i);var e=this.eventname.get("value");this.updateEventsList(),this.updateSelection(e),this.plugin.on("change",this.updateEventsList,this)},updateEventsList:function(){var n,e,t=this.plugin.get("value"),i="\\"+t+"\\";this.eventname.all(s).remove(!0),t=this.get("eventlist"),(e=o.Node.create('")).set("selected","selected"),this.eventname.appendChild(e),o.Object.each(t,function(e,t){t.substring(0,i.length)===i&&(n=o.Node.create('"),this.eventname.appendChild(n))},this)},updateSelection:function(t){this.eventname.get("options").each(function(e){e.get("value")===t&&e.set("selected","selected")},this)}},{NAME:"dropDown",ATTRS:{eventlist:null}}),o.namespace("M.tool_monitor.DropDown").init=function(e){return new t(e)}},"@VERSION@",{requires:["base","event","node"]}); \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/instance_form.min.js b/admin/tool/moodlenet/amd/build/instance_form.min.js index 70d692bc592..6b6ebb2ff29 100644 --- a/admin/tool/moodlenet/amd/build/instance_form.min.js +++ b/admin/tool/moodlenet/amd/build/instance_form.min.js @@ -1,2 +1,17 @@ -define ("tool_moodlenet/instance_form",["tool_moodlenet/validator","tool_moodlenet/selectors","core/loadingicon","core/templates","core/notification","jquery"],function(a,b,c,d,e,f){var g=function(d){d.addEventListener("click",function(f){if(f.target.matches(b.action.submit)){var e=d.querySelector("[data-var=\"mnet-link\"]"),g=d.querySelector(b.region.spinner),h=document.querySelector(b.region.validationArea);g.classList.remove("d-none");var i=c.addIconToContainerWithPromise(g);a.validation(e).then(function(a){i.resolve();g.classList.add("d-none");if(a.result){e.classList.remove("is-invalid");e.classList.add("is-valid");h.innerText=a.message;h.classList.remove("text-danger");h.classList.add("text-success");setTimeout(function(){window.location=a.domain},1e3)}else{e.classList.add("is-invalid");h.innerText=a.message;h.classList.add("text-danger")}}).catch()}})},h=function(a,b,h,i){a.innerHTML="";var j=c.addIconToContainer(a),k=null,l=new Promise(function(a){k=a});f.when(j,l).then(function(){d.replaceNodeContents(a,b.customcarouseltemplate,"")}).catch(e.exception);g(a);h.one("slid.bs.carousel",function(){k()});h.carousel(2);i.setFooter(d.render("tool_moodlenet/chooser_footer_close_mnet",{}))},i=function(a,b,c){a.carousel(0);b.setFooter(c.customfootertemplate)};return{footerClickListener:function footerClickListener(a,c,d){if(a.target.matches(b.action.showMoodleNet)||a.target.closest(b.action.showMoodleNet)){a.preventDefault();var e=f(d.getBody()[0].querySelector(b.region.carousel)),g=e.find(b.region.moodleNet)[0];h(g,c,e,d)}if(a.target.matches(b.action.closeOption)){var j=f(d.getBody()[0].querySelector(b.region.carousel));i(j,d,c)}}}}); -//# sourceMappingURL=instance_form.min.js.map +/** + * Our basic form manager for when a user either enters + * their profile url or just wants to browse. + * + * This file is a mishmash of JS functions we need for both the standalone (M3.7, M3.8) + * plugin & Moodle 3.9 functions. The 3.9 Functions have a base understanding that certain + * things exist i.e. directory structures for templates. When this feature goes 3.9+ only + * The goal is that we can quickly gut all AMD modules into bare JS files and use ES6 guidelines. + * Till then this will have to do. + * + * @module tool_moodlenet/instance_form + * @copyright 2020 Mathew May + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_moodlenet/instance_form",["tool_moodlenet/validator","tool_moodlenet/selectors","core/loadingicon","core/templates","core/notification","jquery"],(function(Validator,Selectors,LoadingIcon,Templates,Notification,$){var chooserNavigateToMnet=function(showMoodleNet,footerData,carousel,modal){showMoodleNet.innerHTML="";var page,spinnerPromise=LoadingIcon.addIconToContainer(showMoodleNet),transitionPromiseResolver=null,transitionPromise=new Promise((resolve=>{transitionPromiseResolver=resolve}));$.when(spinnerPromise,transitionPromise).then((function(){Templates.replaceNodeContents(showMoodleNet,footerData.customcarouseltemplate,"")})).catch(Notification.exception),(page=showMoodleNet).addEventListener("click",(function(e){if(e.target.matches(Selectors.action.submit)){var input=page.querySelector('[data-var="mnet-link"]'),overlay=page.querySelector(Selectors.region.spinner),validationArea=document.querySelector(Selectors.region.validationArea);overlay.classList.remove("d-none");var spinner=LoadingIcon.addIconToContainerWithPromise(overlay);Validator.validation(input).then((function(result){spinner.resolve(),overlay.classList.add("d-none"),result.result?(input.classList.remove("is-invalid"),input.classList.add("is-valid"),validationArea.innerText=result.message,validationArea.classList.remove("text-danger"),validationArea.classList.add("text-success"),setTimeout((function(){window.location=result.domain}),1e3)):(input.classList.add("is-invalid"),validationArea.innerText=result.message,validationArea.classList.add("text-danger"))})).catch()}})),carousel.one("slid.bs.carousel",(function(){transitionPromiseResolver()})),carousel.carousel(2),modal.setFooter(Templates.render("tool_moodlenet/chooser_footer_close_mnet",{}))};return{footerClickListener:function(e,footerData,modal){if(e.target.matches(Selectors.action.showMoodleNet)||e.target.closest(Selectors.action.showMoodleNet)){e.preventDefault();const carousel=$(modal.getBody()[0].querySelector(Selectors.region.carousel)),showMoodleNet=carousel.find(Selectors.region.moodleNet)[0];chooserNavigateToMnet(showMoodleNet,footerData,carousel,modal)}if(e.target.matches(Selectors.action.closeOption)){!function(carousel,modal,footerData){carousel.carousel(0),modal.setFooter(footerData.customfootertemplate)}($(modal.getBody()[0].querySelector(Selectors.region.carousel)),modal,footerData)}}}})); + +//# sourceMappingURL=instance_form.min.js.map \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/instance_form.min.js.map b/admin/tool/moodlenet/amd/build/instance_form.min.js.map index 0faff890d64..4d3ccc56ff7 100644 --- a/admin/tool/moodlenet/amd/build/instance_form.min.js.map +++ b/admin/tool/moodlenet/amd/build/instance_form.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/instance_form.js"],"names":["define","Validator","Selectors","LoadingIcon","Templates","Notification","$","registerListenerEvents","page","addEventListener","e","target","matches","action","submit","input","querySelector","overlay","region","spinner","validationArea","document","classList","remove","addIconToContainerWithPromise","validation","then","result","resolve","add","innerText","message","setTimeout","window","location","domain","catch","chooserNavigateToMnet","showMoodleNet","footerData","carousel","modal","innerHTML","spinnerPromise","addIconToContainer","transitionPromiseResolver","transitionPromise","Promise","when","replaceNodeContents","customcarouseltemplate","exception","one","setFooter","render","chooserNavigateFromMnet","customfootertemplate","footerClickListener","closest","preventDefault","getBody","find","moodleNet","closeOption"],"mappings":"AA8BAA,OAAM,gCAAC,CAAC,0BAAD,CACC,0BADD,CAEC,kBAFD,CAGC,gBAHD,CAIC,mBAJD,CAKC,QALD,CAAD,CAMF,SAASC,CAAT,CACSC,CADT,CAESC,CAFT,CAGSC,CAHT,CAISC,CAJT,CAKSC,CALT,CAKY,IAQRC,CAAAA,CAAsB,CAAG,SAAgCC,CAAhC,CAAsC,CAC/DA,CAAI,CAACC,gBAAL,CAAsB,OAAtB,CAA+B,SAASC,CAAT,CAAY,CAGvC,GAAIA,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiBV,CAAS,CAACW,MAAV,CAAiBC,MAAlC,CAAJ,CAA+C,IACvCC,CAAAA,CAAK,CAAGP,CAAI,CAACQ,aAAL,CAAmB,0BAAnB,CAD+B,CAEvCC,CAAO,CAAGT,CAAI,CAACQ,aAAL,CAAmBd,CAAS,CAACgB,MAAV,CAAiBC,OAApC,CAF6B,CAGvCC,CAAc,CAAGC,QAAQ,CAACL,aAAT,CAAuBd,CAAS,CAACgB,MAAV,CAAiBE,cAAxC,CAHsB,CAK3CH,CAAO,CAACK,SAAR,CAAkBC,MAAlB,CAAyB,QAAzB,EACA,GAAIJ,CAAAA,CAAO,CAAGhB,CAAW,CAACqB,6BAAZ,CAA0CP,CAA1C,CAAd,CACAhB,CAAS,CAACwB,UAAV,CAAq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CAED,GAAI/B,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiBV,CAAS,CAACW,MAAV,CAAiBkD,WAAlC,CAAJ,CAAoD,CAChD,GAAMvB,CAAAA,CAAQ,CAAGlC,CAAC,CAACmC,CAAK,CAACmB,OAAN,GAAgB,CAAhB,EAAmB5C,aAAnB,CAAiCd,CAAS,CAACgB,MAAV,CAAiBsB,QAAlD,CAAD,CAAlB,CAEAe,CAAuB,CAACf,CAAD,CAAWC,CAAX,CAAkBF,CAAlB,CAC1B,CACJ,CAEM,CAGV,CAzIK,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 * Our basic form manager for when a user either enters\n * their profile url or just wants to browse.\n *\n * This file is a mishmash of JS functions we need for both the standalone (M3.7, M3.8)\n * plugin & Moodle 3.9 functions. The 3.9 Functions have a base understanding that certain\n * things exist i.e. directory structures for templates. When this feature goes 3.9+ only\n * The goal is that we can quickly gut all AMD modules into bare JS files and use ES6 guidelines.\n * Till then this will have to do.\n *\n * @module tool_moodlenet/instance_form\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['tool_moodlenet/validator',\n 'tool_moodlenet/selectors',\n 'core/loadingicon',\n 'core/templates',\n 'core/notification',\n 'jquery'],\n function(Validator,\n Selectors,\n LoadingIcon,\n Templates,\n Notification,\n $) {\n\n /**\n * Add the event listeners to our form.\n *\n * @method registerListenerEvents\n * @param {HTMLElement} page The whole page element for our form area\n */\n var registerListenerEvents = function registerListenerEvents(page) {\n page.addEventListener('click', function(e) {\n\n // Our fake submit button / browse button.\n if (e.target.matches(Selectors.action.submit)) {\n var input = page.querySelector('[data-var=\"mnet-link\"]');\n var overlay = page.querySelector(Selectors.region.spinner);\n var validationArea = document.querySelector(Selectors.region.validationArea);\n\n overlay.classList.remove('d-none');\n var spinner = LoadingIcon.addIconToContainerWithPromise(overlay);\n Validator.validation(input)\n .then(function(result) {\n spinner.resolve();\n overlay.classList.add('d-none');\n if (result.result) {\n input.classList.remove('is-invalid'); // Just in case the class has been applied already.\n input.classList.add('is-valid');\n validationArea.innerText = result.message;\n validationArea.classList.remove('text-danger');\n validationArea.classList.add('text-success');\n // Give the user some time to see their input is valid.\n setTimeout(function() {\n window.location = result.domain;\n }, 1000);\n } else {\n input.classList.add('is-invalid');\n validationArea.innerText = result.message;\n validationArea.classList.add('text-danger');\n }\n return;\n }).catch();\n }\n });\n };\n\n /**\n * Given a user wishes to see the MoodleNet profile url form transition them there.\n *\n * @method chooserNavigateToMnet\n * @param {HTMLElement} showMoodleNet The chooser's area for ment\n * @param {Object} footerData Our footer object to render out\n * @param {jQuery} carousel Our carousel instance to manage\n * @param {jQuery} modal Our modal instance to manage\n */\n var chooserNavigateToMnet = function(showMoodleNet, footerData, carousel, modal) {\n showMoodleNet.innerHTML = '';\n\n // Add a spinner.\n var spinnerPromise = LoadingIcon.addIconToContainer(showMoodleNet);\n\n // Used later...\n var transitionPromiseResolver = null;\n var transitionPromise = new Promise(resolve => {\n transitionPromiseResolver = resolve;\n });\n\n $.when(\n spinnerPromise,\n transitionPromise\n ).then(function() {\n Templates.replaceNodeContents(showMoodleNet, footerData.customcarouseltemplate, '');\n return;\n }).catch(Notification.exception);\n\n // We apply our handlers in here to minimise plugin dependency in the Chooser.\n registerListenerEvents(showMoodleNet);\n\n // Move to the next slide, and resolve the transition promise when it's done.\n carousel.one('slid.bs.carousel', function() {\n transitionPromiseResolver();\n });\n // Trigger the transition between 'pages'.\n carousel.carousel(2);\n // eslint-disable-next-line max-len\n modal.setFooter(Templates.render('tool_moodlenet/chooser_footer_close_mnet', {}));\n };\n\n /**\n * Given a user no longer wishes to see the MoodleNet profile url form transition them from there.\n *\n * @method chooserNavigateFromMnet\n * @param {jQuery} carousel Our carousel instance to manage\n * @param {jQuery} modal Our modal instance to manage\n * @param {Object} footerData Our footer object to render out\n */\n var chooserNavigateFromMnet = function(carousel, modal, footerData) {\n // Trigger the transition between 'pages'.\n carousel.carousel(0);\n modal.setFooter(footerData.customfootertemplate);\n };\n\n /**\n * Create the custom listener that would handle anything in the footer.\n *\n * @param {Event} e The event being triggered.\n * @param {Object} footerData The data generated from the exporter.\n * @param {Object} modal The chooser modal.\n */\n var footerClickListener = function(e, footerData, modal) {\n if (e.target.matches(Selectors.action.showMoodleNet) || e.target.closest(Selectors.action.showMoodleNet)) {\n e.preventDefault();\n const carousel = $(modal.getBody()[0].querySelector(Selectors.region.carousel));\n const showMoodleNet = carousel.find(Selectors.region.moodleNet)[0];\n\n chooserNavigateToMnet(showMoodleNet, footerData, carousel, modal);\n }\n // From the help screen go back to the module overview.\n if (e.target.matches(Selectors.action.closeOption)) {\n const carousel = $(modal.getBody()[0].querySelector(Selectors.region.carousel));\n\n chooserNavigateFromMnet(carousel, modal, footerData);\n }\n };\n\n return {\n footerClickListener: footerClickListener\n };\n});\n"],"file":"instance_form.min.js"} \ No newline at end of file +{"version":3,"file":"instance_form.min.js","sources":["../src/instance_form.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 * Our basic form manager for when a user either enters\n * their profile url or just wants to browse.\n *\n * This file is a mishmash of JS functions we need for both the standalone (M3.7, M3.8)\n * plugin & Moodle 3.9 functions. The 3.9 Functions have a base understanding that certain\n * things exist i.e. directory structures for templates. When this feature goes 3.9+ only\n * The goal is that we can quickly gut all AMD modules into bare JS files and use ES6 guidelines.\n * Till then this will have to do.\n *\n * @module tool_moodlenet/instance_form\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['tool_moodlenet/validator',\n 'tool_moodlenet/selectors',\n 'core/loadingicon',\n 'core/templates',\n 'core/notification',\n 'jquery'],\n function(Validator,\n Selectors,\n LoadingIcon,\n Templates,\n Notification,\n $) {\n\n /**\n * Add the event listeners to our form.\n *\n * @method registerListenerEvents\n * @param {HTMLElement} page The whole page element for our form area\n */\n var registerListenerEvents = function registerListenerEvents(page) {\n page.addEventListener('click', function(e) {\n\n // Our fake submit button / browse button.\n if (e.target.matches(Selectors.action.submit)) {\n var input = page.querySelector('[data-var=\"mnet-link\"]');\n var overlay = page.querySelector(Selectors.region.spinner);\n var validationArea = document.querySelector(Selectors.region.validationArea);\n\n overlay.classList.remove('d-none');\n var spinner = LoadingIcon.addIconToContainerWithPromise(overlay);\n Validator.validation(input)\n .then(function(result) {\n spinner.resolve();\n overlay.classList.add('d-none');\n if (result.result) {\n input.classList.remove('is-invalid'); // Just in case the class has been applied already.\n input.classList.add('is-valid');\n validationArea.innerText = result.message;\n validationArea.classList.remove('text-danger');\n validationArea.classList.add('text-success');\n // Give the user some time to see their input is valid.\n setTimeout(function() {\n window.location = result.domain;\n }, 1000);\n } else {\n input.classList.add('is-invalid');\n validationArea.innerText = result.message;\n validationArea.classList.add('text-danger');\n }\n return;\n }).catch();\n }\n });\n };\n\n /**\n * Given a user wishes to see the MoodleNet profile url form transition them there.\n *\n * @method chooserNavigateToMnet\n * @param {HTMLElement} showMoodleNet The chooser's area for ment\n * @param {Object} footerData Our footer object to render out\n * @param {jQuery} carousel Our carousel instance to manage\n * @param {jQuery} modal Our modal instance to manage\n */\n var chooserNavigateToMnet = function(showMoodleNet, footerData, carousel, modal) {\n showMoodleNet.innerHTML = '';\n\n // Add a spinner.\n var spinnerPromise = LoadingIcon.addIconToContainer(showMoodleNet);\n\n // Used later...\n var transitionPromiseResolver = null;\n var transitionPromise = new Promise(resolve => {\n transitionPromiseResolver = resolve;\n });\n\n $.when(\n spinnerPromise,\n transitionPromise\n ).then(function() {\n Templates.replaceNodeContents(showMoodleNet, footerData.customcarouseltemplate, '');\n return;\n }).catch(Notification.exception);\n\n // We apply our handlers in here to minimise plugin dependency in the Chooser.\n registerListenerEvents(showMoodleNet);\n\n // Move to the next slide, and resolve the transition promise when it's done.\n carousel.one('slid.bs.carousel', function() {\n transitionPromiseResolver();\n });\n // Trigger the transition between 'pages'.\n carousel.carousel(2);\n // eslint-disable-next-line max-len\n modal.setFooter(Templates.render('tool_moodlenet/chooser_footer_close_mnet', {}));\n };\n\n /**\n * Given a user no longer wishes to see the MoodleNet profile url form transition them from there.\n *\n * @method chooserNavigateFromMnet\n * @param {jQuery} carousel Our carousel instance to manage\n * @param {jQuery} modal Our modal instance to manage\n * @param {Object} footerData Our footer object to render out\n */\n var chooserNavigateFromMnet = function(carousel, modal, footerData) {\n // Trigger the transition between 'pages'.\n carousel.carousel(0);\n modal.setFooter(footerData.customfootertemplate);\n };\n\n /**\n * Create the custom listener that would handle anything in the footer.\n *\n * @param {Event} e The event being triggered.\n * @param {Object} footerData The data generated from the exporter.\n * @param {Object} modal The chooser modal.\n */\n var footerClickListener = function(e, footerData, modal) {\n if (e.target.matches(Selectors.action.showMoodleNet) || e.target.closest(Selectors.action.showMoodleNet)) {\n e.preventDefault();\n const carousel = $(modal.getBody()[0].querySelector(Selectors.region.carousel));\n const showMoodleNet = carousel.find(Selectors.region.moodleNet)[0];\n\n chooserNavigateToMnet(showMoodleNet, footerData, carousel, modal);\n }\n // From the help screen go back to the module overview.\n if (e.target.matches(Selectors.action.closeOption)) {\n const carousel = $(modal.getBody()[0].querySelector(Selectors.region.carousel));\n\n chooserNavigateFromMnet(carousel, modal, footerData);\n }\n };\n\n return {\n footerClickListener: footerClickListener\n };\n});\n"],"names":["define","Validator","Selectors","LoadingIcon","Templates","Notification","$","chooserNavigateToMnet","showMoodleNet","footerData","carousel","modal","innerHTML","page","spinnerPromise","addIconToContainer","transitionPromiseResolver","transitionPromise","Promise","resolve","when","then","replaceNodeContents","customcarouseltemplate","catch","exception","addEventListener","e","target","matches","action","submit","input","querySelector","overlay","region","spinner","validationArea","document","classList","remove","addIconToContainerWithPromise","validation","result","add","innerText","message","setTimeout","window","location","domain","one","setFooter","render","footerClickListener","closest","preventDefault","getBody","find","moodleNet","closeOption","customfootertemplate","chooserNavigateFromMnet"],"mappings":";;;;;;;;;;;;;;AA8BAA,sCAAO,CAAC,2BACA,2BACA,mBACA,iBACA,oBACA,WACJ,SAASC,UACAC,UACAC,YACAC,UACAC,aACAC,OAqDLC,sBAAwB,SAASC,cAAeC,WAAYC,SAAUC,OACtEH,cAAcI,UAAY,OA9C+BC,KAiDrDC,eAAiBX,YAAYY,mBAAmBP,eAGhDQ,0BAA4B,KAC5BC,kBAAoB,IAAIC,SAAQC,UAChCH,0BAA4BG,WAGhCb,EAAEc,KACEN,eACAG,mBACFI,MAAK,WACCjB,UAAUkB,oBAAoBd,cAAeC,WAAWc,uBAAwB,OAErFC,MAAMnB,aAAaoB,YA/DmCZ,KAkElCL,eAjElBkB,iBAAiB,SAAS,SAASC,MAGhCA,EAAEC,OAAOC,QAAQ3B,UAAU4B,OAAOC,QAAS,KACvCC,MAAQnB,KAAKoB,cAAc,0BAC3BC,QAAUrB,KAAKoB,cAAc/B,UAAUiC,OAAOC,SAC9CC,eAAiBC,SAASL,cAAc/B,UAAUiC,OAAOE,gBAE7DH,QAAQK,UAAUC,OAAO,cACrBJ,QAAUjC,YAAYsC,8BAA8BP,SACxDjC,UAAUyC,WAAWV,OAChBX,MAAK,SAASsB,QACXP,QAAQjB,UACRe,QAAQK,UAAUK,IAAI,UAClBD,OAAOA,QACPX,MAAMO,UAAUC,OAAO,cACvBR,MAAMO,UAAUK,IAAI,YACpBP,eAAeQ,UAAYF,OAAOG,QAClCT,eAAeE,UAAUC,OAAO,eAChCH,eAAeE,UAAUK,IAAI,gBAE7BG,YAAW,WACPC,OAAOC,SAAWN,OAAOO,SAC1B,OAEHlB,MAAMO,UAAUK,IAAI,cACpBP,eAAeQ,UAAYF,OAAOG,QAClCT,eAAeE,UAAUK,IAAI,mBAGtCpB,YAsCXd,SAASyC,IAAI,oBAAoB,WAC7BnC,+BAGJN,SAASA,SAAS,GAElBC,MAAMyC,UAAUhD,UAAUiD,OAAO,2CAA4C,YAwC1E,CACHC,oBAjBsB,SAAS3B,EAAGlB,WAAYE,UAC1CgB,EAAEC,OAAOC,QAAQ3B,UAAU4B,OAAOtB,gBAAkBmB,EAAEC,OAAO2B,QAAQrD,UAAU4B,OAAOtB,eAAgB,CACtGmB,EAAE6B,uBACI9C,SAAWJ,EAAEK,MAAM8C,UAAU,GAAGxB,cAAc/B,UAAUiC,OAAOzB,WAC/DF,cAAgBE,SAASgD,KAAKxD,UAAUiC,OAAOwB,WAAW,GAEhEpD,sBAAsBC,cAAeC,WAAYC,SAAUC,UAG3DgB,EAAEC,OAAOC,QAAQ3B,UAAU4B,OAAO8B,aAAc,EAtB1B,SAASlD,SAAUC,MAAOF,YAEpDC,SAASA,SAAS,GAClBC,MAAMyC,UAAU3C,WAAWoD,sBAsBvBC,CAFiBxD,EAAEK,MAAM8C,UAAU,GAAGxB,cAAc/B,UAAUiC,OAAOzB,WAEnCC,MAAOF"} \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/select_page.min.js b/admin/tool/moodlenet/amd/build/select_page.min.js index 558896069b9..a74d396a408 100644 --- a/admin/tool/moodlenet/amd/build/select_page.min.js +++ b/admin/tool/moodlenet/amd/build/select_page.min.js @@ -1,2 +1,10 @@ -define ("tool_moodlenet/select_page",["core/ajax","core/templates","tool_moodlenet/selectors","core/notification"],function(a,b,c,d){var e,f=function(a){return b.renderPix("courses","tool_moodlenet").then(function(a){return a}).then(function(a){var c=document.createElement("div");c.innerHTML=a.trim();return b.render("core_course/no-courses",{nocoursesimg:c.firstChild.src})}).then(function(c,d){b.replaceNodeContents(a,c,d);a.classList.add("mx-auto");a.classList.add("w-25")})},g=function(a,c){return b.render("tool_moodlenet/view-cards",{courses:c}).then(function(c,d){b.replaceNodeContents(a,c,d);a.classList.remove("mx-auto");a.classList.remove("w-25")})},h=function(b,h,i){var j=h.querySelector(c.region.searchIcon),k=h.querySelector(c.region.clearIcon);if(""!==b){j.classList.add("d-none");k.parentElement.classList.remove("d-none")}else{j.classList.remove("d-none");k.parentElement.classList.add("d-none")}a.call([{methodname:"tool_moodlenet_search_courses",args:{searchvalue:b}}])[0].then(function(a){if(0===a.courses.length){return f(i)}else{a.courses.forEach(function(a){a.viewurl+="&id="+e});return g(i,a.courses)}}).catch(d.exception)},i=function(a){var b=a.querySelector(c.region.searchInput),d=a.querySelector(c.region.courses),e=a.querySelector(c.region.clearIcon);e.addEventListener("click",function(){b.value="";h("",a,d)});b.addEventListener("input",k(function(){h(b.value,a,d)},300))},j=function(a){var b=a.querySelector(c.region.courses);h("",a,b)},k=function(a,b,c){var d;return function(){var e=this,f=arguments,g=c&&!d;clearTimeout(d);d=setTimeout(function later(){d=null;if(!c){a.apply(e,f)}},b);if(g){a.apply(e,f)}}};return{init:function init(a){e=a;var b=document.querySelector(c.region.selectPage);i(b);j(b)}}}); -//# sourceMappingURL=select_page.min.js.map +/** + * When returning to Moodle let the user select which course to add the resource to. + * + * @module tool_moodlenet/select_page + * @copyright 2020 Mathew May + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_moodlenet/select_page",["core/ajax","core/templates","tool_moodlenet/selectors","core/notification"],(function(Ajax,Templates,Selectors,Notification){var importId,searchCourses=function(inputValue,page,areaReplace){var searchIcon=page.querySelector(Selectors.region.searchIcon),clearIcon=page.querySelector(Selectors.region.clearIcon);""!==inputValue?(searchIcon.classList.add("d-none"),clearIcon.parentElement.classList.remove("d-none")):(searchIcon.classList.remove("d-none"),clearIcon.parentElement.classList.add("d-none"));var args={searchvalue:inputValue};Ajax.call([{methodname:"tool_moodlenet_search_courses",args:args}])[0].then((function(result){return 0===result.courses.length?function(areaReplace){return Templates.renderPix("courses","tool_moodlenet").then((function(img){return img})).then((function(img){var temp=document.createElement("div");return temp.innerHTML=img.trim(),Templates.render("core_course/no-courses",{nocoursesimg:temp.firstChild.src})})).then((function(html,js){Templates.replaceNodeContents(areaReplace,html,js),areaReplace.classList.add("mx-auto"),areaReplace.classList.add("w-25")}))}(areaReplace):(result.courses.forEach((function(course){course.viewurl+="&id="+importId})),function(areaReplace,courses){return Templates.render("tool_moodlenet/view-cards",{courses:courses}).then((function(html,js){Templates.replaceNodeContents(areaReplace,html,js),areaReplace.classList.remove("mx-auto"),areaReplace.classList.remove("w-25")}))}(areaReplace,result.courses))})).catch(Notification.exception)},registerListenerEvents=function(page){var input=page.querySelector(Selectors.region.searchInput),courseArea=page.querySelector(Selectors.region.courses);page.querySelector(Selectors.region.clearIcon).addEventListener("click",(function(){input.value="",searchCourses("",page,courseArea)})),input.addEventListener("input",debounce((function(){searchCourses(input.value,page,courseArea)}),300))},addCourses=function(page){var courseArea=page.querySelector(Selectors.region.courses);searchCourses("",page,courseArea)},debounce=function(func,wait,immediate){var timeout;return function(){var context=this,args=arguments,later=function(){timeout=null,immediate||func.apply(context,args)},callNow=immediate&&!timeout;clearTimeout(timeout),timeout=setTimeout(later,wait),callNow&&func.apply(context,args)}};return{init:function(importIdString){importId=importIdString;var page=document.querySelector(Selectors.region.selectPage);registerListenerEvents(page),addCourses(page)}}})); + +//# sourceMappingURL=select_page.min.js.map \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/select_page.min.js.map b/admin/tool/moodlenet/amd/build/select_page.min.js.map index a170f8b0a08..bc80e534253 100644 --- a/admin/tool/moodlenet/amd/build/select_page.min.js.map +++ b/admin/tool/moodlenet/amd/build/select_page.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/select_page.js"],"names":["define","Ajax","Templates","Selectors","Notification","importId","renderNoCourses","areaReplace","renderPix","then","img","temp","document","createElement","innerHTML","trim","render","nocoursesimg","firstChild","src","html","js","replaceNodeContents","classList","add","renderCourses","courses","remove","searchCourses","inputValue","page","searchIcon","querySelector","region","clearIcon","parentElement","call","methodname","args","searchvalue","result","length","forEach","course","viewurl","catch","exception","registerListenerEvents","input","searchInput","courseArea","addEventListener","value","debounce","addCourses","func","wait","immediate","timeout","context","arguments","callNow","clearTimeout","setTimeout","later","apply","init","importIdString","selectPage"],"mappings":"AAuBAA,OAAM,8BAAC,CACH,WADG,CAEH,gBAFG,CAGH,0BAHG,CAIH,mBAJG,CAAD,CAKH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKD,IAIMC,CAAAA,CAJN,CAyBMC,CAAe,CAAG,SAASC,CAAT,CAAsB,CACxC,MAAOL,CAAAA,CAAS,CAACM,SAAV,CAAoB,SAApB,CAA+B,gBAA/B,EAAiDC,IAAjD,CAAsD,SAASC,CAAT,CAAc,CACvE,MAAOA,CAAAA,CACV,CAFM,EAEJD,IAFI,CAEC,SAASC,CAAT,CAAc,CAClB,GAAIC,CAAAA,CAAI,CAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAX,CACAF,CAAI,CAACG,SAAL,CAAiBJ,CAAG,CAACK,IAAJ,EAAjB,CACA,MAAOb,CAAAA,CAAS,CAACc,MAAV,CAAiB,wBAAjB,CAA2C,CAC9CC,YAAY,CAAEN,CAAI,CAACO,UAAL,CAAgBC,GADgB,CAA3C,CAGV,CARM,EAQJV,IARI,CAQC,SAASW,CAAT,CAAeC,CAAf,CAAmB,CACvBnB,CAAS,CAACoB,mBAAV,CAA8Bf,CAA9B,CAA2Ca,CAA3C,CAAiDC,CAAjD,EACAd,CAAW,CAACgB,SAAZ,CA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MAAV,CAAiBP,OAApC,CAAjB,CACAE,CAAa,CAAC,EAAD,CAAKE,CAAL,CAAWoB,CAAX,CAChB,CA/HH,CA6IMG,CAAQ,CAAG,SAASE,CAAT,CAAeC,CAAf,CAAqBC,CAArB,CAAgC,CAC3C,GAAIC,CAAAA,CAAJ,CACA,MAAO,WAAW,IACVC,CAAAA,CAAO,CAAG,IADA,CAEVrB,CAAI,CAAGsB,SAFG,CASVC,CAAO,CAAGJ,CAAS,EAAI,CAACC,CATd,CAUdI,YAAY,CAACJ,CAAD,CAAZ,CACAA,CAAO,CAAGK,UAAU,CARR,QAARC,CAAAA,KAAQ,EAAW,CACnBN,CAAO,CAAG,IAAV,CACA,GAAI,CAACD,CAAL,CAAgB,CACZF,CAAI,CAACU,KAAL,CAAWN,CAAX,CAAoBrB,CAApB,CACH,CACJ,CAGmB,CAAQkB,CAAR,CAApB,CACA,GAAIK,CAAJ,CAAa,CACTN,CAAI,CAACU,KAAL,CAAWN,CAAX,CAAoBrB,CAApB,CACH,CACJ,CACJ,CA/JH,CAgKE,MAAO,CACH4B,IAAI,CArJG,QAAPA,CAAAA,IAAO,CAASC,CAAT,CAAyB,CAChC9D,CAAQ,CAAG8D,CAAX,CACA,GAAIrC,CAAAA,CAAI,CAAGlB,QAAQ,CAACoB,aAAT,CAAuB7B,CAAS,CAAC8B,MAAV,CAAiBmC,UAAxC,CAAX,CACArB,CAAsB,CAACjB,CAAD,CAAtB,CACAwB,CAAU,CAACxB,CAAD,CACb,CA+IM,CAGV,CA7KK,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 * When returning to Moodle let the user select which course to add the resource to.\n *\n * @module tool_moodlenet/select_page\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine([\n 'core/ajax',\n 'core/templates',\n 'tool_moodlenet/selectors',\n 'core/notification'\n], function(\n Ajax,\n Templates,\n Selectors,\n Notification\n) {\n /**\n * @var {string} The id corresponding to the import.\n */\n var importId;\n\n /**\n * Set up the page.\n *\n * @method init\n * @param {string} importIdString the string ID of the import.\n */\n var init = function(importIdString) {\n importId = importIdString;\n var page = document.querySelector(Selectors.region.selectPage);\n registerListenerEvents(page);\n addCourses(page);\n };\n\n /**\n * Renders the 'no-courses' template.\n *\n * @param {HTMLElement} areaReplace the DOM node to replace.\n * @returns {Promise}\n */\n var renderNoCourses = function(areaReplace) {\n return Templates.renderPix('courses', 'tool_moodlenet').then(function(img) {\n return img;\n }).then(function(img) {\n var temp = document.createElement('div');\n temp.innerHTML = img.trim();\n return Templates.render('core_course/no-courses', {\n nocoursesimg: temp.firstChild.src\n });\n }).then(function(html, js) {\n Templates.replaceNodeContents(areaReplace, html, js);\n areaReplace.classList.add('mx-auto');\n areaReplace.classList.add('w-25');\n return;\n });\n };\n\n /**\n * Render the course cards for those supplied courses.\n *\n * @param {HTMLElement} areaReplace the DOM node to replace.\n * @param {Array} courses the courses to render.\n * @returns {Promise}\n */\n var renderCourses = function(areaReplace, courses) {\n return Templates.render('tool_moodlenet/view-cards', {\n courses: courses\n }).then(function(html, js) {\n Templates.replaceNodeContents(areaReplace, html, js);\n areaReplace.classList.remove('mx-auto');\n areaReplace.classList.remove('w-25');\n return;\n });\n };\n\n /**\n * For a given input, the page & what to replace fetch courses and manage icons too.\n *\n * @method searchCourses\n * @param {string} inputValue What to search for\n * @param {HTMLElement} page The whole page element for our page\n * @param {HTMLElement} areaReplace The Element to replace the contents of\n */\n var searchCourses = function(inputValue, page, areaReplace) {\n var searchIcon = page.querySelector(Selectors.region.searchIcon);\n var clearIcon = page.querySelector(Selectors.region.clearIcon);\n\n if (inputValue !== '') {\n searchIcon.classList.add('d-none');\n clearIcon.parentElement.classList.remove('d-none');\n } else {\n searchIcon.classList.remove('d-none');\n clearIcon.parentElement.classList.add('d-none');\n }\n var args = {\n searchvalue: inputValue,\n };\n Ajax.call([{\n methodname: 'tool_moodlenet_search_courses',\n args: args\n }])[0].then(function(result) {\n if (result.courses.length === 0) {\n return renderNoCourses(areaReplace);\n } else {\n // Add the importId to the course link\n result.courses.forEach(function(course) {\n course.viewurl += '&id=' + importId;\n });\n return renderCourses(areaReplace, result.courses);\n }\n }).catch(Notification.exception);\n };\n\n /**\n * Add the event listeners to our page.\n *\n * @method registerListenerEvents\n * @param {HTMLElement} page The whole page element for our page\n */\n var registerListenerEvents = function(page) {\n var input = page.querySelector(Selectors.region.searchInput);\n var courseArea = page.querySelector(Selectors.region.courses);\n var clearIcon = page.querySelector(Selectors.region.clearIcon);\n clearIcon.addEventListener('click', function() {\n input.value = '';\n searchCourses('', page, courseArea);\n });\n\n input.addEventListener('input', debounce(function() {\n searchCourses(input.value, page, courseArea);\n }, 300));\n };\n\n /**\n * Fetch the courses to show the user. We use the same WS structure & template as the search for consistency.\n *\n * @method addCourses\n * @param {HTMLElement} page The whole page element for our course page\n */\n var addCourses = function(page) {\n var courseArea = page.querySelector(Selectors.region.courses);\n searchCourses('', page, courseArea);\n };\n\n /**\n * Define our own debounce function as Moodle 3.7 does not have it.\n *\n * @method debounce\n * @from underscore.js\n * @copyright 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * @licence MIT\n * @param {function} func The function we want to keep calling\n * @param {number} wait Our timeout\n * @param {boolean} immediate Do we want to apply the function immediately\n * @return {function}\n */\n var debounce = function(func, wait, immediate) {\n var timeout;\n return function() {\n var context = this;\n var args = arguments;\n var later = function() {\n timeout = null;\n if (!immediate) {\n func.apply(context, args);\n }\n };\n var callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) {\n func.apply(context, args);\n }\n };\n };\n return {\n init: init,\n };\n});\n"],"file":"select_page.min.js"} \ No newline at end of file +{"version":3,"file":"select_page.min.js","sources":["../src/select_page.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 * When returning to Moodle let the user select which course to add the resource to.\n *\n * @module tool_moodlenet/select_page\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine([\n 'core/ajax',\n 'core/templates',\n 'tool_moodlenet/selectors',\n 'core/notification'\n], function(\n Ajax,\n Templates,\n Selectors,\n Notification\n) {\n /**\n * @var {string} The id corresponding to the import.\n */\n var importId;\n\n /**\n * Set up the page.\n *\n * @method init\n * @param {string} importIdString the string ID of the import.\n */\n var init = function(importIdString) {\n importId = importIdString;\n var page = document.querySelector(Selectors.region.selectPage);\n registerListenerEvents(page);\n addCourses(page);\n };\n\n /**\n * Renders the 'no-courses' template.\n *\n * @param {HTMLElement} areaReplace the DOM node to replace.\n * @returns {Promise}\n */\n var renderNoCourses = function(areaReplace) {\n return Templates.renderPix('courses', 'tool_moodlenet').then(function(img) {\n return img;\n }).then(function(img) {\n var temp = document.createElement('div');\n temp.innerHTML = img.trim();\n return Templates.render('core_course/no-courses', {\n nocoursesimg: temp.firstChild.src\n });\n }).then(function(html, js) {\n Templates.replaceNodeContents(areaReplace, html, js);\n areaReplace.classList.add('mx-auto');\n areaReplace.classList.add('w-25');\n return;\n });\n };\n\n /**\n * Render the course cards for those supplied courses.\n *\n * @param {HTMLElement} areaReplace the DOM node to replace.\n * @param {Array} courses the courses to render.\n * @returns {Promise}\n */\n var renderCourses = function(areaReplace, courses) {\n return Templates.render('tool_moodlenet/view-cards', {\n courses: courses\n }).then(function(html, js) {\n Templates.replaceNodeContents(areaReplace, html, js);\n areaReplace.classList.remove('mx-auto');\n areaReplace.classList.remove('w-25');\n return;\n });\n };\n\n /**\n * For a given input, the page & what to replace fetch courses and manage icons too.\n *\n * @method searchCourses\n * @param {string} inputValue What to search for\n * @param {HTMLElement} page The whole page element for our page\n * @param {HTMLElement} areaReplace The Element to replace the contents of\n */\n var searchCourses = function(inputValue, page, areaReplace) {\n var searchIcon = page.querySelector(Selectors.region.searchIcon);\n var clearIcon = page.querySelector(Selectors.region.clearIcon);\n\n if (inputValue !== '') {\n searchIcon.classList.add('d-none');\n clearIcon.parentElement.classList.remove('d-none');\n } else {\n searchIcon.classList.remove('d-none');\n clearIcon.parentElement.classList.add('d-none');\n }\n var args = {\n searchvalue: inputValue,\n };\n Ajax.call([{\n methodname: 'tool_moodlenet_search_courses',\n args: args\n }])[0].then(function(result) {\n if (result.courses.length === 0) {\n return renderNoCourses(areaReplace);\n } else {\n // Add the importId to the course link\n result.courses.forEach(function(course) {\n course.viewurl += '&id=' + importId;\n });\n return renderCourses(areaReplace, result.courses);\n }\n }).catch(Notification.exception);\n };\n\n /**\n * Add the event listeners to our page.\n *\n * @method registerListenerEvents\n * @param {HTMLElement} page The whole page element for our page\n */\n var registerListenerEvents = function(page) {\n var input = page.querySelector(Selectors.region.searchInput);\n var courseArea = page.querySelector(Selectors.region.courses);\n var clearIcon = page.querySelector(Selectors.region.clearIcon);\n clearIcon.addEventListener('click', function() {\n input.value = '';\n searchCourses('', page, courseArea);\n });\n\n input.addEventListener('input', debounce(function() {\n searchCourses(input.value, page, courseArea);\n }, 300));\n };\n\n /**\n * Fetch the courses to show the user. We use the same WS structure & template as the search for consistency.\n *\n * @method addCourses\n * @param {HTMLElement} page The whole page element for our course page\n */\n var addCourses = function(page) {\n var courseArea = page.querySelector(Selectors.region.courses);\n searchCourses('', page, courseArea);\n };\n\n /**\n * Define our own debounce function as Moodle 3.7 does not have it.\n *\n * @method debounce\n * @from underscore.js\n * @copyright 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * @licence MIT\n * @param {function} func The function we want to keep calling\n * @param {number} wait Our timeout\n * @param {boolean} immediate Do we want to apply the function immediately\n * @return {function}\n */\n var debounce = function(func, wait, immediate) {\n var timeout;\n return function() {\n var context = this;\n var args = arguments;\n var later = function() {\n timeout = null;\n if (!immediate) {\n func.apply(context, args);\n }\n };\n var callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) {\n func.apply(context, args);\n }\n };\n };\n return {\n init: init,\n };\n});\n"],"names":["define","Ajax","Templates","Selectors","Notification","importId","searchCourses","inputValue","page","areaReplace","searchIcon","querySelector","region","clearIcon","classList","add","parentElement","remove","args","searchvalue","call","methodname","then","result","courses","length","renderPix","img","temp","document","createElement","innerHTML","trim","render","nocoursesimg","firstChild","src","html","js","replaceNodeContents","renderNoCourses","forEach","course","viewurl","renderCourses","catch","exception","registerListenerEvents","input","searchInput","courseArea","addEventListener","value","debounce","addCourses","func","wait","immediate","timeout","context","this","arguments","later","apply","callNow","clearTimeout","setTimeout","init","importIdString","selectPage"],"mappings":";;;;;;;AAuBAA,oCAAO,CACH,YACA,iBACA,2BACA,sBACD,SACCC,KACAC,UACAC,UACAC,kBAKIC,SAgEAC,cAAgB,SAASC,WAAYC,KAAMC,iBACvCC,WAAaF,KAAKG,cAAcR,UAAUS,OAAOF,YACjDG,UAAYL,KAAKG,cAAcR,UAAUS,OAAOC,WAEjC,KAAfN,YACAG,WAAWI,UAAUC,IAAI,UACzBF,UAAUG,cAAcF,UAAUG,OAAO,YAEzCP,WAAWI,UAAUG,OAAO,UAC5BJ,UAAUG,cAAcF,UAAUC,IAAI,eAEtCG,KAAO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AMC,eAC5BC,eACG,eACCC,QAAUC,KACV1C,KAAO2C,UACPC,MAAQ,WACRJ,QAAU,KACLD,WACDF,KAAKQ,MAAMJ,QAASzC,OAGxB8C,QAAUP,YAAcC,QAC5BO,aAAaP,SACbA,QAAUQ,WAAWJ,MAAON,MACxBQ,SACAT,KAAKQ,MAAMJ,QAASzC,cAIzB,CACHiD,KArJO,SAASC,gBAChB/D,SAAW+D,mBACP5D,KAAOqB,SAASlB,cAAcR,UAAUS,OAAOyD,YACnDtB,uBAAuBvC,MACvB8C,WAAW9C"} \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/selectors.min.js b/admin/tool/moodlenet/amd/build/selectors.min.js index b1db64f13e2..75de02c08db 100644 --- a/admin/tool/moodlenet/amd/build/selectors.min.js +++ b/admin/tool/moodlenet/amd/build/selectors.min.js @@ -1,2 +1,10 @@ -define ("tool_moodlenet/selectors",[],function(){return{action:{browse:"[data-action=\"browse\"]",submit:"[data-action=\"submit\"]",showMoodleNet:"[data-action=\"show-moodlenet\"]",closeOption:"[data-action=\"close-chooser-option-summary\"]"},region:{clearIcon:"[data-region=\"clear-icon\"]",courses:"[data-region=\"mnet-courses\"]",instancePage:"[data-region=\"moodle-net\"]",searchInput:"[data-region=\"search-input\"]",searchIcon:"[data-region=\"search-icon\"]",selectPage:"[data-region=\"moodle-net-select\"]",spinner:"[data-region=\"spinner\"]",validationArea:"[data-region=\"validation-area\"]",carousel:"[data-region=\"carousel\"]",moodleNet:"[data-region=\"pluginCarousel\"]"}}}); -//# sourceMappingURL=selectors.min.js.map +/** + * Define all of the selectors we will be using within MoodleNet plugin. + * + * @module tool_moodlenet/selectors + * @copyright 2020 Mathew May + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_moodlenet/selectors",[],(function(){return{action:{browse:'[data-action="browse"]',submit:'[data-action="submit"]',showMoodleNet:'[data-action="show-moodlenet"]',closeOption:'[data-action="close-chooser-option-summary"]'},region:{clearIcon:'[data-region="clear-icon"]',courses:'[data-region="mnet-courses"]',instancePage:'[data-region="moodle-net"]',searchInput:'[data-region="search-input"]',searchIcon:'[data-region="search-icon"]',selectPage:'[data-region="moodle-net-select"]',spinner:'[data-region="spinner"]',validationArea:'[data-region="validation-area"]',carousel:'[data-region="carousel"]',moodleNet:'[data-region="pluginCarousel"]'}}})); + +//# sourceMappingURL=selectors.min.js.map \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/selectors.min.js.map b/admin/tool/moodlenet/amd/build/selectors.min.js.map index 045ac3b471f..4adbf8d872f 100644 --- a/admin/tool/moodlenet/amd/build/selectors.min.js.map +++ b/admin/tool/moodlenet/amd/build/selectors.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/selectors.js"],"names":["define","action","browse","submit","showMoodleNet","closeOption","region","clearIcon","courses","instancePage","searchInput","searchIcon","selectPage","spinner","validationArea","carousel","moodleNet"],"mappings":"AAsBAA,OAAM,4BAAC,EAAD,CAAK,UAAW,CAClB,MAAO,CACHC,MAAM,CAAE,CACJC,MAAM,CAAE,0BADJ,CAEJC,MAAM,CAAE,0BAFJ,CAGJC,aAAa,CAAE,kCAHX,CAIJC,WAAW,CAAE,gDAJT,CADL,CAOHC,MAAM,CAAE,CACJC,SAAS,CAAE,8BADP,CAEJC,OAAO,CAAE,gCAFL,CAGJC,YAAY,CAAE,8BAHV,CAIJC,WAAW,CAAE,gCAJT,CAKJC,UAAU,CAAE,+BALR,CAMJC,UAAU,CAAE,qCANR,CAOJC,OAAO,CAAE,2BAPL,CAQJC,cAAc,CAAE,mCARZ,CASJC,QAAQ,CAAE,4BATN,CAUJC,SAAS,CAAE,kCAVP,CAPL,CAoBV,CArBK,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 * Define all of the selectors we will be using within MoodleNet plugin.\n *\n * @module tool_moodlenet/selectors\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n action: {\n browse: '[data-action=\"browse\"]',\n submit: '[data-action=\"submit\"]',\n showMoodleNet: '[data-action=\"show-moodlenet\"]',\n closeOption: '[data-action=\"close-chooser-option-summary\"]',\n },\n region: {\n clearIcon: '[data-region=\"clear-icon\"]',\n courses: '[data-region=\"mnet-courses\"]',\n instancePage: '[data-region=\"moodle-net\"]',\n searchInput: '[data-region=\"search-input\"]',\n searchIcon: '[data-region=\"search-icon\"]',\n selectPage: '[data-region=\"moodle-net-select\"]',\n spinner: '[data-region=\"spinner\"]',\n validationArea: '[data-region=\"validation-area\"]',\n carousel: '[data-region=\"carousel\"]',\n moodleNet: '[data-region=\"pluginCarousel\"]',\n },\n };\n});\n"],"file":"selectors.min.js"} \ No newline at end of file +{"version":3,"file":"selectors.min.js","sources":["../src/selectors.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 * Define all of the selectors we will be using within MoodleNet plugin.\n *\n * @module tool_moodlenet/selectors\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n action: {\n browse: '[data-action=\"browse\"]',\n submit: '[data-action=\"submit\"]',\n showMoodleNet: '[data-action=\"show-moodlenet\"]',\n closeOption: '[data-action=\"close-chooser-option-summary\"]',\n },\n region: {\n clearIcon: '[data-region=\"clear-icon\"]',\n courses: '[data-region=\"mnet-courses\"]',\n instancePage: '[data-region=\"moodle-net\"]',\n searchInput: '[data-region=\"search-input\"]',\n searchIcon: '[data-region=\"search-icon\"]',\n selectPage: '[data-region=\"moodle-net-select\"]',\n spinner: '[data-region=\"spinner\"]',\n validationArea: '[data-region=\"validation-area\"]',\n carousel: '[data-region=\"carousel\"]',\n moodleNet: '[data-region=\"pluginCarousel\"]',\n },\n };\n});\n"],"names":["define","action","browse","submit","showMoodleNet","closeOption","region","clearIcon","courses","instancePage","searchInput","searchIcon","selectPage","spinner","validationArea","carousel","moodleNet"],"mappings":";;;;;;;AAsBAA,kCAAO,IAAI,iBACA,CACHC,OAAQ,CACJC,OAAQ,yBACRC,OAAQ,yBACRC,cAAe,iCACfC,YAAa,gDAEjBC,OAAQ,CACJC,UAAW,6BACXC,QAAS,+BACTC,aAAc,6BACdC,YAAa,+BACbC,WAAY,8BACZC,WAAY,oCACZC,QAAS,0BACTC,eAAgB,kCAChBC,SAAU,2BACVC,UAAW"} \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/validator.min.js b/admin/tool/moodlenet/amd/build/validator.min.js index 1c4d02ae503..7cf1287e5cc 100644 --- a/admin/tool/moodlenet/amd/build/validator.min.js +++ b/admin/tool/moodlenet/amd/build/validator.min.js @@ -1,2 +1,10 @@ -define ("tool_moodlenet/validator",["jquery","core/ajax","core/str","core/notification"],function(a,b,c,d){return{validation:function(e){var f=e.value;if(""===f||!f.includes("@")){a.when(c.get_string("profilevalidationerror","tool_moodlenet")).then(function(a){return Promise.reject().catch(function(){return{result:!1,message:a[0]}})}).fail(d.exception)}return b.call([{methodname:"tool_moodlenet_verify_webfinger",args:{profileurl:f,course:e.dataset.courseid,section:e.dataset.sectionid}}])[0].then(function(a){return a}).catch()}}}); -//# sourceMappingURL=validator.min.js.map +/** + * Our validator that splits the user's input then fires off to a webservice + * + * @module tool_moodlenet/validator + * @copyright 2020 Mathew May + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_moodlenet/validator",["jquery","core/ajax","core/str","core/notification"],(function($,Ajax,Str,Notification){return{validation:function(inputElement){var inputValue=inputElement.value;return""!==inputValue&&inputValue.includes("@")||$.when(Str.get_string("profilevalidationerror","tool_moodlenet")).then((function(strings){return Promise.reject().catch((function(){return{result:!1,message:strings[0]}}))})).fail(Notification.exception),Ajax.call([{methodname:"tool_moodlenet_verify_webfinger",args:{profileurl:inputValue,course:inputElement.dataset.courseid,section:inputElement.dataset.sectionid}}])[0].then((function(result){return result})).catch()}}})); + +//# sourceMappingURL=validator.min.js.map \ No newline at end of file diff --git a/admin/tool/moodlenet/amd/build/validator.min.js.map b/admin/tool/moodlenet/amd/build/validator.min.js.map index e0ccd035c88..7d0a9ae7781 100644 --- a/admin/tool/moodlenet/amd/build/validator.min.js.map +++ b/admin/tool/moodlenet/amd/build/validator.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/validator.js"],"names":["define","$","Ajax","Str","Notification","validation","inputElement","inputValue","value","includes","when","get_string","then","strings","Promise","reject","catch","result","message","fail","exception","call","methodname","args","profileurl","course","dataset","courseid","section","sectionid"],"mappings":"AAsBAA,OAAM,4BAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,UAAxB,CAAoC,mBAApC,CAAD,CAA2D,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAuBC,CAAvB,CAAqC,CAgClG,MAAO,CACHC,UAAU,CAzBG,SAAoBC,CAApB,CAAkC,CAC/C,GAAIC,CAAAA,CAAU,CAAGD,CAAY,CAACE,KAA9B,CAGA,GAAmB,EAAf,GAAAD,CAAU,EAAW,CAACA,CAAU,CAACE,QAAX,CAAoB,GAApB,CAA1B,CAAoD,CAEhDR,CAAC,CAACS,IAAF,CAAOP,CAAG,CAACQ,UAAJ,CAAe,wBAAf,CAAyC,gBAAzC,CAAP,EAAmEC,IAAnE,CAAwE,SAASC,CAAT,CAAkB,CACtF,MAAOC,CAAAA,OAAO,CAACC,MAAR,GAAiBC,KAAjB,CAAuB,UAAW,CACrC,MAAO,CAACC,MAAM,GAAP,CAAgBC,OAAO,CAAEL,CAAO,CAAC,CAAD,CAAhC,CACV,CAFM,CAGV,CAJD,EAIGM,IAJH,CAIQf,CAAY,CAACgB,SAJrB,CAKH,CAED,MAAOlB,CAAAA,CAAI,CAACmB,IAAL,CAAU,CAAC,CACdC,UAAU,CAAE,iCADE,CAEdC,IAAI,CAAE,CACFC,UAAU,CAAEjB,CADV,CAEFkB,MAAM,CAAEnB,CAAY,CAACoB,OAAb,CAAqBC,QAF3B,CAGFC,OAAO,CAAEtB,CAAY,CAACoB,OAAb,CAAqBG,SAH5B,CAFQ,CAAD,CAAV,EAOH,CAPG,EAOAjB,IAPA,CAOK,SAASK,CAAT,CAAiB,CACzB,MAAOA,CAAAA,CACV,CATM,EASJD,KATI,EAUV,CACM,CAGV,CAnCK,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 * Our validator that splits the user's input then fires off to a webservice\n *\n * @module tool_moodlenet/validator\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification'], function($, Ajax, Str, Notification) {\n /**\n * Handle form validation\n *\n * @method validation\n * @param {HTMLElement} inputElement The element the user entered text into.\n * @return {Promise} Was the users' entry a valid profile URL?\n */\n var validation = function validation(inputElement) {\n var inputValue = inputElement.value;\n\n // They didn't submit anything or they gave us a simple string that we can't do anything with.\n if (inputValue === \"\" || !inputValue.includes(\"@\")) {\n // Create a promise and immediately reject it.\n $.when(Str.get_string('profilevalidationerror', 'tool_moodlenet')).then(function(strings) {\n return Promise.reject().catch(function() {\n return {result: false, message: strings[0]};\n });\n }).fail(Notification.exception);\n }\n\n return Ajax.call([{\n methodname: 'tool_moodlenet_verify_webfinger',\n args: {\n profileurl: inputValue,\n course: inputElement.dataset.courseid,\n section: inputElement.dataset.sectionid\n }\n }])[0].then(function(result) {\n return result;\n }).catch();\n };\n return {\n validation: validation,\n };\n});\n"],"file":"validator.min.js"} \ No newline at end of file +{"version":3,"file":"validator.min.js","sources":["../src/validator.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 * Our validator that splits the user's input then fires off to a webservice\n *\n * @module tool_moodlenet/validator\n * @copyright 2020 Mathew May \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification'], function($, Ajax, Str, Notification) {\n /**\n * Handle form validation\n *\n * @method validation\n * @param {HTMLElement} inputElement The element the user entered text into.\n * @return {Promise} Was the users' entry a valid profile URL?\n */\n var validation = function validation(inputElement) {\n var inputValue = inputElement.value;\n\n // They didn't submit anything or they gave us a simple string that we can't do anything with.\n if (inputValue === \"\" || !inputValue.includes(\"@\")) {\n // Create a promise and immediately reject it.\n $.when(Str.get_string('profilevalidationerror', 'tool_moodlenet')).then(function(strings) {\n return Promise.reject().catch(function() {\n return {result: false, message: strings[0]};\n });\n }).fail(Notification.exception);\n }\n\n return Ajax.call([{\n methodname: 'tool_moodlenet_verify_webfinger',\n args: {\n profileurl: inputValue,\n course: inputElement.dataset.courseid,\n section: inputElement.dataset.sectionid\n }\n }])[0].then(function(result) {\n return result;\n }).catch();\n };\n return {\n validation: validation,\n };\n});\n"],"names":["define","$","Ajax","Str","Notification","validation","inputElement","inputValue","value","includes","when","get_string","then","strings","Promise","reject","catch","result","message","fail","exception","call","methodname","args","profileurl","course","dataset","courseid","section","sectionid"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,SAAU,YAAa,WAAY,sBAAsB,SAASC,EAAGC,KAAMC,IAAKC,oBAgC7E,CACHC,WAzBa,SAAoBC,kBAC7BC,WAAaD,aAAaE,YAGX,KAAfD,YAAsBA,WAAWE,SAAS,MAE1CR,EAAES,KAAKP,IAAIQ,WAAW,yBAA0B,mBAAmBC,MAAK,SAASC,gBACtEC,QAAQC,SAASC,OAAM,iBACnB,CAACC,QAAQ,EAAOC,QAASL,QAAQ,UAE7CM,KAAKf,aAAagB,WAGlBlB,KAAKmB,KAAK,CAAC,CACdC,WAAY,kCACZC,KAAM,CACFC,WAAYjB,WACZkB,OAAQnB,aAAaoB,QAAQC,SAC7BC,QAAStB,aAAaoB,QAAQG,cAElC,GAAGjB,MAAK,SAASK,eACVA,UACRD"} \ No newline at end of file diff --git a/admin/tool/policy/amd/build/acceptances_filter.min.js b/admin/tool/policy/amd/build/acceptances_filter.min.js index 0cb2282aecf..9bd16c757bc 100644 --- a/admin/tool/policy/amd/build/acceptances_filter.min.js +++ b/admin/tool/policy/amd/build/acceptances_filter.min.js @@ -1,2 +1,10 @@ -define ("tool_policy/acceptances_filter",["jquery","core/form-autocomplete","core/str","core/notification"],function(a,b,c,d){var e={UNIFIED_FILTERS:"#unified-filters"},f=function init(){M.util.js_pending("acceptances_filter_datasource");c.get_strings([{key:"filterplaceholder",component:"tool_policy"},{key:"nofiltersapplied",component:"tool_policy"}]).done(function(a){var c=a[0],f=a[1];b.enhance(e.UNIFIED_FILTERS,!0,"tool_policy/acceptances_filter_datasource",c,!1,!0,f,!0).then(function(){M.util.js_complete("acceptances_filter_datasource")}).fail(d.exception)}).fail(d.exception);var f=a(e.UNIFIED_FILTERS).val();a(e.UNIFIED_FILTERS).on("change",function(){var b=a(this).val(),c=[],d=[],e=!1;a.each(b,function(a,b){var f=b.split(":",2);if(2!==f.length){d.push(b);return!0}var g=f[0],h=f[1];if("undefined"!=typeof c[g]){e=!0}c[g]=h;return!0});if(e){var g=[];for(var h in c){g.push(h+":"+c[h])}g=g.concat(d);a(this).val(g)}if(f.join(",")!=b.join(",")){this.form.submit()}})},g=function getForm(){return a(e.UNIFIED_FILTERS).closest("form")};return{init:function init(){f()},getForm:function getForm(){return g()}}}); -//# sourceMappingURL=acceptances_filter.min.js.map +/** + * Unified filter page JS module for the course participants page. + * + * @module tool_policy/acceptances_filter + * @copyright 2017 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_policy/acceptances_filter",["jquery","core/form-autocomplete","core/str","core/notification"],(function($,Autocomplete,Str,Notification){var SELECTORS_UNIFIED_FILTERS="#unified-filters";return{init:function(){!function(){M.util.js_pending("acceptances_filter_datasource"),Str.get_strings([{key:"filterplaceholder",component:"tool_policy"},{key:"nofiltersapplied",component:"tool_policy"}]).done((function(langstrings){var placeholder=langstrings[0],noSelectionString=langstrings[1];Autocomplete.enhance(SELECTORS_UNIFIED_FILTERS,!0,"tool_policy/acceptances_filter_datasource",placeholder,!1,!0,noSelectionString,!0).then((function(){M.util.js_complete("acceptances_filter_datasource")})).fail(Notification.exception)})).fail(Notification.exception);var last=$(SELECTORS_UNIFIED_FILTERS).val();$(SELECTORS_UNIFIED_FILTERS).on("change",(function(){var current=$(this).val(),listoffilters=[],textfilters=[],updatedselectedfilters=!1;if($.each(current,(function(index,catoption){var catandoption=catoption.split(":",2);if(2!==catandoption.length)return textfilters.push(catoption),!0;var category=catandoption[0],option=catandoption[1];return void 0!==listoffilters[category]&&(updatedselectedfilters=!0),listoffilters[category]=option,!0})),updatedselectedfilters){var updatefilters=[];for(var category in listoffilters)updatefilters.push(category+":"+listoffilters[category]);updatefilters=updatefilters.concat(textfilters),$(this).val(updatefilters)}last.join(",")!=current.join(",")&&this.form.submit()}))}()},getForm:function(){return $(SELECTORS_UNIFIED_FILTERS).closest("form")}}})); + +//# sourceMappingURL=acceptances_filter.min.js.map \ No newline at end of file diff --git a/admin/tool/policy/amd/build/acceptances_filter.min.js.map b/admin/tool/policy/amd/build/acceptances_filter.min.js.map index 9d3a54d842f..360aa9aa9b6 100644 --- a/admin/tool/policy/amd/build/acceptances_filter.min.js.map +++ b/admin/tool/policy/amd/build/acceptances_filter.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/acceptances_filter.js"],"names":["define","$","Autocomplete","Str","Notification","SELECTORS","UNIFIED_FILTERS","init","M","util","js_pending","get_strings","key","component","done","langstrings","placeholder","noSelectionString","enhance","then","js_complete","fail","exception","last","val","on","current","listoffilters","textfilters","updatedselectedfilters","each","index","catoption","catandoption","split","length","push","category","option","updatefilters","concat","join","form","submit","getForm","closest"],"mappings":"AAsBAA,OAAM,kCAAC,CAAC,QAAD,CAAW,wBAAX,CAAqC,UAArC,CAAiD,mBAAjD,CAAD,CACF,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAA+BC,CAA/B,CAA6C,IAQrCC,CAAAA,CAAS,CAAG,CACZC,eAAe,CAAE,kBADL,CARyB,CAkBrCC,CAAI,CAAG,QAAPA,CAAAA,IAAO,EAAW,CASlBC,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,+BAAlB,EACAP,CAAG,CAACQ,WAAJ,CATiB,CAAC,CACdC,GAAG,CAAE,mBADS,CAEdC,SAAS,CAAE,aAFG,CAAD,CAGd,CACCD,GAA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AA,CAAa,CAACU,CAAD,CAAxB,CAAoD,CAChDR,CAAsB,GACzB,CAEDF,CAAa,CAACU,CAAD,CAAb,CAA0BC,CAA1B,CACA,QACH,CArBD,EAwBA,GAAIT,CAAJ,CAA4B,CAExB,GAAIU,CAAAA,CAAa,CAAG,EAApB,CACA,IAAK,GAAIF,CAAAA,CAAT,GAAqBV,CAAAA,CAArB,CAAoC,CAChCY,CAAa,CAACH,IAAd,CAAmBC,CAAQ,CAAG,GAAX,CAAiBV,CAAa,CAACU,CAAD,CAAjD,CACH,CACDE,CAAa,CAAGA,CAAa,CAACC,MAAd,CAAqBZ,CAArB,CAAhB,CACA3B,CAAC,CAAC,IAAD,CAAD,CAAQuB,GAAR,CAAYe,CAAZ,CACH,CAGD,GAAIhB,CAAI,CAACkB,IAAL,CAAU,GAAV,GAAkBf,CAAO,CAACe,IAAR,CAAa,GAAb,CAAtB,CAAyC,CACrC,KAAKC,IAAL,CAAUC,MAAV,EACH,CACJ,CA5CD,CA6CH,CAvFwC,CA+FrCC,CAAO,CAAG,QAAVA,CAAAA,OAAU,EAAW,CACrB,MAAO3C,CAAAA,CAAC,CAACI,CAAS,CAACC,eAAX,CAAD,CAA6BuC,OAA7B,CAAqC,MAArC,CACV,CAjGwC,CAmGzC,MAAmD,CAM/CtC,IAAI,CAAE,eAAW,CACbA,CAAI,EACP,CAR8C,CAgB/CqC,OAAO,CAAE,kBAAW,CAChB,MAAOA,CAAAA,CAAO,EACjB,CAlB8C,CAoBtD,CAxHC,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 * Unified filter page JS module for the course participants page.\n *\n * @module tool_policy/acceptances_filter\n * @copyright 2017 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'],\n function($, Autocomplete, Str, Notification) {\n\n /**\n * Selectors.\n *\n * @access private\n * @type {{UNIFIED_FILTERS: string}}\n */\n var SELECTORS = {\n UNIFIED_FILTERS: '#unified-filters'\n };\n\n /**\n * Init function.\n *\n * @method init\n * @private\n */\n var init = function() {\n var stringkeys = [{\n key: 'filterplaceholder',\n component: 'tool_policy'\n }, {\n key: 'nofiltersapplied',\n component: 'tool_policy'\n }];\n\n M.util.js_pending('acceptances_filter_datasource');\n Str.get_strings(stringkeys).done(function(langstrings) {\n var placeholder = langstrings[0];\n var noSelectionString = langstrings[1];\n Autocomplete.enhance(SELECTORS.UNIFIED_FILTERS, true, 'tool_policy/acceptances_filter_datasource', placeholder,\n false, true, noSelectionString, true)\n .then(function() {\n M.util.js_complete('acceptances_filter_datasource');\n\n return;\n })\n .fail(Notification.exception);\n }).fail(Notification.exception);\n\n var last = $(SELECTORS.UNIFIED_FILTERS).val();\n $(SELECTORS.UNIFIED_FILTERS).on('change', function() {\n var current = $(this).val();\n var listoffilters = [];\n var textfilters = [];\n var updatedselectedfilters = false;\n\n $.each(current, function(index, catoption) {\n var catandoption = catoption.split(':', 2);\n if (catandoption.length !== 2) {\n textfilters.push(catoption);\n return true; // Text search filter.\n }\n\n var category = catandoption[0];\n var option = catandoption[1];\n\n // The last option (eg. 'Teacher') out of a category (eg. 'Role') in this loop is the one that was last\n // selected, so we want to use that if there are multiple options from the same category. Eg. The user\n // may have chosen to filter by the 'Student' role, then wanted to filter by the 'Teacher' role - the\n // last option in the category to be selected (in this case 'Teacher') will come last, so will overwrite\n // 'Student' (after this if). We want to let the JS know that the filters have been updated.\n if (typeof listoffilters[category] !== 'undefined') {\n updatedselectedfilters = true;\n }\n\n listoffilters[category] = option;\n return true;\n });\n\n // Check if we have something to remove from the list of filters.\n if (updatedselectedfilters) {\n // Go through and put the list into something we can use to update the list of filters.\n var updatefilters = [];\n for (var category in listoffilters) {\n updatefilters.push(category + \":\" + listoffilters[category]);\n }\n updatefilters = updatefilters.concat(textfilters);\n $(this).val(updatefilters);\n }\n\n // Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.\n if (last.join(',') != current.join(',')) {\n this.form.submit();\n }\n });\n };\n\n /**\n * Return the unified user filter form.\n *\n * @method getForm\n * @return {DOMElement}\n */\n var getForm = function() {\n return $(SELECTORS.UNIFIED_FILTERS).closest('form');\n };\n\n return /** @alias module:core/form-autocomplete */ {\n /**\n * Initialise the unified user filter.\n *\n * @method init\n */\n init: function() {\n init();\n },\n\n /**\n * Return the unified user filter form.\n *\n * @method getForm\n * @return {DOMElement}\n */\n getForm: function() {\n return getForm();\n }\n };\n });\n"],"file":"acceptances_filter.min.js"} \ No newline at end of file +{"version":3,"file":"acceptances_filter.min.js","sources":["../src/acceptances_filter.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 * Unified filter page JS module for the course participants page.\n *\n * @module tool_policy/acceptances_filter\n * @copyright 2017 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'],\n function($, Autocomplete, Str, Notification) {\n\n /**\n * Selectors.\n *\n * @access private\n * @type {{UNIFIED_FILTERS: string}}\n */\n var SELECTORS = {\n UNIFIED_FILTERS: '#unified-filters'\n };\n\n /**\n * Init function.\n *\n * @method init\n * @private\n */\n var init = function() {\n var stringkeys = [{\n key: 'filterplaceholder',\n component: 'tool_policy'\n }, {\n key: 'nofiltersapplied',\n component: 'tool_policy'\n }];\n\n M.util.js_pending('acceptances_filter_datasource');\n Str.get_strings(stringkeys).done(function(langstrings) {\n var placeholder = langstrings[0];\n var noSelectionString = langstrings[1];\n Autocomplete.enhance(SELECTORS.UNIFIED_FILTERS, true, 'tool_policy/acceptances_filter_datasource', placeholder,\n false, true, noSelectionString, true)\n .then(function() {\n M.util.js_complete('acceptances_filter_datasource');\n\n return;\n })\n .fail(Notification.exception);\n }).fail(Notification.exception);\n\n var last = $(SELECTORS.UNIFIED_FILTERS).val();\n $(SELECTORS.UNIFIED_FILTERS).on('change', function() {\n var current = $(this).val();\n var listoffilters = [];\n var textfilters = [];\n var updatedselectedfilters = false;\n\n $.each(current, function(index, catoption) {\n var catandoption = catoption.split(':', 2);\n if (catandoption.length !== 2) {\n textfilters.push(catoption);\n return true; // Text search filter.\n }\n\n var category = catandoption[0];\n var option = catandoption[1];\n\n // The last option (eg. 'Teacher') out of a category (eg. 'Role') in this loop is the one that was last\n // selected, so we want to use that if there are multiple options from the same category. Eg. The user\n // may have chosen to filter by the 'Student' role, then wanted to filter by the 'Teacher' role - the\n // last option in the category to be selected (in this case 'Teacher') will come last, so will overwrite\n // 'Student' (after this if). We want to let the JS know that the filters have been updated.\n if (typeof listoffilters[category] !== 'undefined') {\n updatedselectedfilters = true;\n }\n\n listoffilters[category] = option;\n return true;\n });\n\n // Check if we have something to remove from the list of filters.\n if (updatedselectedfilters) {\n // Go through and put the list into something we can use to update the list of filters.\n var updatefilters = [];\n for (var category in listoffilters) {\n updatefilters.push(category + \":\" + listoffilters[category]);\n }\n updatefilters = updatefilters.concat(textfilters);\n $(this).val(updatefilters);\n }\n\n // Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.\n if (last.join(',') != current.join(',')) {\n this.form.submit();\n }\n });\n };\n\n /**\n * Return the unified user filter form.\n *\n * @method getForm\n * @return {DOMElement}\n */\n var getForm = function() {\n return $(SELECTORS.UNIFIED_FILTERS).closest('form');\n };\n\n return /** @alias module:core/form-autocomplete */ {\n /**\n * Initialise the unified user filter.\n *\n * @method init\n */\n init: function() {\n init();\n },\n\n /**\n * Return the unified user filter form.\n *\n * @method getForm\n * @return {DOMElement}\n */\n getForm: function() {\n return getForm();\n }\n };\n });\n"],"names":["define","$","Autocomplete","Str","Notification","SELECTORS","init","M","util","js_pending","get_strings","key","component","done","langstrings","placeholder","noSelectionString","enhance","then","js_complete","fail","exception","last","val","on","current","this","listoffilters","textfilters","updatedselectedfilters","each","index","catoption","catandoption","split","length","push","category","option","updatefilters","concat","join","form","submit","getForm","closest"],"mappings":";;;;;;;AAsBAA,wCAAO,CAAC,SAAU,yBAA0B,WAAY,sBACpD,SAASC,EAAGC,aAAcC,IAAKC,kBAQvBC,0BACiB,yBA0F8B,CAM/CC,KAAM,YAvFC,WASPC,EAAEC,KAAKC,WAAW,iCAClBN,IAAIO,YATa,CAAC,CACdC,IAAK,oBACLC,UAAW,eACZ,CACCD,IAAK,mBACLC,UAAW,iBAIaC,MAAK,SAASC,iBAClCC,YAAcD,YAAY,GAC1BE,kBAAoBF,YAAY,GACpCZ,aAAae,QAAQZ,2BAA2B,EAAM,4CAA6CU,aAC/F,GAAO,EAAMC,mBAAmB,GAC/BE,MAAK,WACFX,EAAEC,KAAKW,YAAY,oCAItBC,KAAKhB,aAAaiB,cACxBD,KAAKhB,aAAaiB,eAEjBC,KAAOrB,EAAEI,2BAA2BkB,MACxCtB,EAAEI,2BAA2BmB,GAAG,UAAU,eAClCC,QAAUxB,EAAEyB,MAAMH,MAClBI,cAAgB,GAChBC,YAAc,GACdC,wBAAyB,KAE7B5B,EAAE6B,KAAKL,SAAS,SAASM,MAAOC,eACxBC,aAAeD,UAAUE,MAAM,IAAK,MACZ,IAAxBD,aAAaE,cACbP,YAAYQ,KAAKJ,YACV,MAGPK,SAAWJ,aAAa,GACxBK,OAASL,aAAa,eAOa,IAA5BN,cAAcU,YACrBR,wBAAyB,GAG7BF,cAAcU,UAAYC,QACnB,KAIPT,uBAAwB,KAEpBU,cAAgB,OACf,IAAIF,YAAYV,cACjBY,cAAcH,KAAKC,SAAW,IAAMV,cAAcU,WAEtDE,cAAgBA,cAAcC,OAAOZ,aACrC3B,EAAEyB,MAAMH,IAAIgB,eAIZjB,KAAKmB,KAAK,MAAQhB,QAAQgB,KAAK,WAC1BC,KAAKC,YAsBdrC,IASJsC,QAAS,kBAnBF3C,EAAEI,2BAA2BwC,QAAQ"} \ No newline at end of file diff --git a/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js b/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js index 0a642f0c6b4..b76e74e00b1 100644 --- a/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js +++ b/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js @@ -1,2 +1,11 @@ -define ("tool_policy/acceptances_filter_datasource",["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function list(b,c){var d=[],e=a(b),f=a(b).data("originaloptionsjson"),g=e.val();a.each(f,function(b,e){if(""!==c.trim()&&-1===e.label.toLocaleLowerCase().indexOf(c.toLocaleLowerCase())){return!0}if(-1-1||filteredOptions.push(option),!0}));var deferred=new $.Deferred;return deferred.resolve(filteredOptions),deferred.promise()},processResults:function(selector,results){var options=[];return $.each(results,(function(index,data){options.push({value:data.value,label:data.label})})),options},transport:function(selector,query,callback){this.list(selector,query).then(callback).catch(Notification.exception)}}})); + +//# sourceMappingURL=acceptances_filter_datasource.min.js.map \ No newline at end of file diff --git a/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js.map b/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js.map index 3132f75f920..2d37ce4cd38 100644 --- a/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js.map +++ b/admin/tool/policy/amd/build/acceptances_filter_datasource.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/acceptances_filter_datasource.js"],"names":["define","$","Ajax","Notification","list","selector","query","filteredOptions","el","originalOptions","data","selectedFilters","val","each","index","option","trim","label","toLocaleLowerCase","indexOf","inArray","value","push","deferred","Deferred","resolve","promise","processResults","results","options","transport","callback","then","catch","exception"],"mappings":"AAwBAA,OAAM,6CAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,mBAAxB,CAAD,CAA+C,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgC,CAEjF,MAAsE,CAQlEC,IAAI,CAAE,cAASC,CAAT,CAAmBC,CAAnB,CAA0B,IACxBC,CAAAA,CAAe,CAAG,EADM,CAGxBC,CAAE,CAAGP,CAAC,CAACI,CAAD,CAHkB,CAIxBI,CAAe,CAAGR,CAAC,CAACI,CAAD,CAAD,CAAYK,IAAZ,CAAiB,qBAAjB,CAJM,CAKxBC,CAAe,CAAGH,CAAE,CAACI,GAAH,EALM,CAM5BX,CAAC,CAACY,IAAF,CAAOJ,CAAP,CAAwB,SAASK,CAAT,CAAgBC,CAAhB,CAAwB,CAE5C,GAAqB,EAAjB,GAAAT,CAAK,CAACU,IAAN,IAA+F,CAAC,CAAzE,GAAAD,CAAM,CAACE,KAAP,CAAaC,iBAAb,GAAiCC,OAAjC,CAAyCb,CAAK,CAACY,iBAAN,EAAzC,CAA3B,CAAuG,CACnG,QACH,CAED,GAA+C,CAAC,CAA5C,CAAAjB,CAAC,CAACmB,OAAF,CAAUL,CAAM,CAACM,KAAjB,CAAwBV,CAAxB,CAAJ,CAAmD,CAC/C,QACH,CAEDJ,CAAe,CAACe,IAAhB,CAAqBP,CAArB,EACA,QACH,CAZD,EAcA,GAAIQ,CAAAA,CAAQ,CAAG,GAAItB,CAAAA,CAAC,CAACuB,QAArB,CACAD,CAAQ,CAACE,OAAT,CAAiBlB,CAAjB,EAEA,MAAOgB,CAAAA,CAAQ,CAACG,OAAT,EACV,CAhCiE,CAyClEC,cAAc,CAAE,wBAAStB,CAAT,CAAmBuB,CAAnB,CAA4B,CACxC,GAAIC,CAAAA,CAAO,CAAG,EAAd,CACA5B,CAAC,CAACY,IAAF,CAAOe,CAAP,CAAgB,SAASd,CAAT,CAAgBJ,CAAhB,CAAsB,CAClCmB,CAAO,CAACP,IAAR,CAAa,CACTD,KAAK,CAAEX,CAAI,CAACW,KADH,CAETJ,KAAK,CAAEP,CAAI,CAACO,KAFH,CAAb,CAIH,CALD,EAMA,MAAOY,CAAAA,CACV,CAlDiE,CA4DlEC,SAAS,CAAE,mBAASzB,CAAT,CAAmBC,CAAnB,CAA0ByB,CAA1B,CAAoC,CAC3C,KAAK3B,IAAL,CAAUC,CAAV,CAAoBC,CAApB,EAA2B0B,IAA3B,CAAgCD,CAAhC,EAA0CE,KAA1C,CAAgD9B,CAAY,CAAC+B,SAA7D,CACH,CA9DiE,CAiEzE,CAnEK,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 * Datasource for the tool_policy/acceptances_filter.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @copyright 2017 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:tool_policy/acceptances_filter_datasource */ {\n /**\n * List filter options.\n *\n * @param {String} selector The select element selector.\n * @param {String} query The query string.\n * @return {Promise}\n */\n list: function(selector, query) {\n var filteredOptions = [];\n\n var el = $(selector);\n var originalOptions = $(selector).data('originaloptionsjson');\n var selectedFilters = el.val();\n $.each(originalOptions, function(index, option) {\n // Skip option if it does not contain the query string.\n if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {\n return true;\n }\n // Skip filters that have already been selected.\n if ($.inArray(option.value, selectedFilters) > -1) {\n return true;\n }\n\n filteredOptions.push(option);\n return true;\n });\n\n var deferred = new $.Deferred();\n deferred.resolve(filteredOptions);\n\n return deferred.promise();\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.value,\n label: data.label\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n this.list(selector, query).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"file":"acceptances_filter_datasource.min.js"} \ No newline at end of file +{"version":3,"file":"acceptances_filter_datasource.min.js","sources":["../src/acceptances_filter_datasource.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 * Datasource for the tool_policy/acceptances_filter.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @copyright 2017 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:tool_policy/acceptances_filter_datasource */ {\n /**\n * List filter options.\n *\n * @param {String} selector The select element selector.\n * @param {String} query The query string.\n * @return {Promise}\n */\n list: function(selector, query) {\n var filteredOptions = [];\n\n var el = $(selector);\n var originalOptions = $(selector).data('originaloptionsjson');\n var selectedFilters = el.val();\n $.each(originalOptions, function(index, option) {\n // Skip option if it does not contain the query string.\n if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {\n return true;\n }\n // Skip filters that have already been selected.\n if ($.inArray(option.value, selectedFilters) > -1) {\n return true;\n }\n\n filteredOptions.push(option);\n return true;\n });\n\n var deferred = new $.Deferred();\n deferred.resolve(filteredOptions);\n\n return deferred.promise();\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.value,\n label: data.label\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n this.list(selector, query).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","list","selector","query","filteredOptions","el","originalOptions","data","selectedFilters","val","each","index","option","trim","label","toLocaleLowerCase","indexOf","inArray","value","push","deferred","Deferred","resolve","promise","processResults","results","options","transport","callback","then","catch","exception"],"mappings":";;;;;;;;AAwBAA,mDAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBAEG,CAQlEC,KAAM,SAASC,SAAUC,WACjBC,gBAAkB,GAElBC,GAAKP,EAAEI,UACPI,gBAAkBR,EAAEI,UAAUK,KAAK,uBACnCC,gBAAkBH,GAAGI,MACzBX,EAAEY,KAAKJ,iBAAiB,SAASK,MAAOC,cAEf,KAAjBT,MAAMU,SAA0F,IAAzED,OAAOE,MAAMC,oBAAoBC,QAAQb,MAAMY,sBAItEjB,EAAEmB,QAAQL,OAAOM,MAAOV,kBAAoB,GAIhDJ,gBAAgBe,KAAKP,SAPV,SAWXQ,SAAW,IAAItB,EAAEuB,gBACrBD,SAASE,QAAQlB,iBAEVgB,SAASG,WAUpBC,eAAgB,SAAStB,SAAUuB,aAC3BC,QAAU,UACd5B,EAAEY,KAAKe,SAAS,SAASd,MAAOJ,MAC5BmB,QAAQP,KAAK,CACTD,MAAOX,KAAKW,MACZJ,MAAOP,KAAKO,WAGbY,SAWXC,UAAW,SAASzB,SAAUC,MAAOyB,eAC5B3B,KAAKC,SAAUC,OAAO0B,KAAKD,UAAUE,MAAM9B,aAAa+B"} \ No newline at end of file diff --git a/admin/tool/policy/amd/build/acceptmodal.min.js b/admin/tool/policy/amd/build/acceptmodal.min.js index b1c6edfaeb7..2c1c4f907a9 100644 --- a/admin/tool/policy/amd/build/acceptmodal.min.js +++ b/admin/tool/policy/amd/build/acceptmodal.min.js @@ -1,2 +1,10 @@ -define ("tool_policy/acceptmodal",["jquery","core/str","core/modal_factory","core/modal_events","core/notification","core/fragment","core/ajax","core_form/changechecker"],function(a,b,c,d,f,g,h,i){"use strict";var j=function(a){this.contextid=a;this.init()};j.prototype.modal=null;j.prototype.contextid=-1;j.prototype.currentTrigger=null;j.prototype.triggers={SINGLE:"a[data-action=acceptmodal]",BULK:"input[data-action=acceptmodal]"};j.prototype.init=function(){a(this.triggers.SINGLE).on("click",function(b){b.preventDefault();this.currentTrigger=a(b.currentTarget);var c=a(b.currentTarget).attr("href"),d=c.slice(c.indexOf("?")+1);this.showFormModal(d)}.bind(this));a(this.triggers.BULK).on("click",function(c){c.preventDefault();this.currentTrigger=a(c.currentTarget);var d=a(c.currentTarget).closest("form");if(d.find("input[type=checkbox][name=\"userids[]\"]:checked").length){var e=d.serialize();this.showFormModal(e)}else{b.get_strings([{key:"notice"},{key:"selectusersforconsent",component:"tool_policy"},{key:"ok"}]).then(function(a){f.alert(a[0],a[1],a[2])}).fail(f.exception)}}.bind(this))};j.prototype.showFormModal=function(a){for(var d,e=a.split("&"),g=0,h;g.\n\n/**\n * Add policy consent modal to the page\n *\n * @module tool_policy/acceptmodal\n * @copyright 2018 Marina Glancy\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/notification',\n 'core/fragment',\n 'core/ajax',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n ModalFactory,\n ModalEvents,\n Notification,\n Fragment,\n Ajax,\n FormChangeChecker\n) {\n\n \"use strict\";\n\n /**\n * Constructor\n *\n * @param {int} contextid\n *\n * Each call to init gets it's own instance of this class.\n */\n var AcceptOnBehalf = function(contextid) {\n this.contextid = contextid;\n this.init();\n };\n\n /**\n * @var {Modal} modal\n * @private\n */\n AcceptOnBehalf.prototype.modal = null;\n\n /**\n * @var {int} contextid\n * @private\n */\n AcceptOnBehalf.prototype.contextid = -1;\n\n /**\n * @var {object} currentTrigger The triggered HTML jQuery object\n * @private\n */\n AcceptOnBehalf.prototype.currentTrigger = null;\n\n /**\n * @var {object} triggers The trigger selectors\n * @private\n */\n AcceptOnBehalf.prototype.triggers = {\n SINGLE: 'a[data-action=acceptmodal]',\n BULK: 'input[data-action=acceptmodal]'\n };\n\n /**\n * Initialise the class.\n *\n * @private\n */\n AcceptOnBehalf.prototype.init = function() {\n // Initialise for links accepting policies for individual users.\n $(this.triggers.SINGLE).on('click', function(e) {\n e.preventDefault();\n this.currentTrigger = $(e.currentTarget);\n var href = $(e.currentTarget).attr('href'),\n formData = href.slice(href.indexOf('?') + 1);\n this.showFormModal(formData);\n }.bind(this));\n\n // Initialise for multiple users acceptance form.\n $(this.triggers.BULK).on('click', function(e) {\n e.preventDefault();\n this.currentTrigger = $(e.currentTarget);\n var form = $(e.currentTarget).closest('form');\n if (form.find('input[type=checkbox][name=\"userids[]\"]:checked').length) {\n var formData = form.serialize();\n this.showFormModal(formData);\n } else {\n Str.get_strings([\n {key: 'notice'},\n {key: 'selectusersforconsent', component: 'tool_policy'},\n {key: 'ok'}\n ]).then(function(strings) {\n Notification.alert(strings[0], strings[1], strings[2]);\n return;\n }).fail(Notification.exception);\n }\n }.bind(this));\n };\n\n /**\n * Show modal with a form\n *\n * @param {String} formData\n */\n AcceptOnBehalf.prototype.showFormModal = function(formData) {\n var action;\n var params = formData.split('&');\n for (var i = 0; i < params.length; i++) {\n var pair = params[i].split('=');\n if (pair[0] == 'action') {\n action = pair[1];\n }\n }\n // Fetch the title string.\n Str.get_strings([\n {key: 'statusformtitleaccept', component: 'tool_policy'},\n {key: 'iagreetothepolicy', component: 'tool_policy'},\n {key: 'statusformtitlerevoke', component: 'tool_policy'},\n {key: 'irevokethepolicy', component: 'tool_policy'},\n {key: 'statusformtitledecline', component: 'tool_policy'},\n {key: 'declinethepolicy', component: 'tool_policy'}\n ]).then(function(strings) {\n var title;\n var saveText;\n if (action == 'accept') {\n title = strings[0];\n saveText = strings[1];\n } else if (action == 'revoke') {\n title = strings[2];\n saveText = strings[3];\n } else if (action == 'decline') {\n title = strings[4];\n saveText = strings[5];\n }\n // Create the modal.\n return ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: title,\n body: ''\n }).done(function(modal) {\n this.modal = modal;\n this.setupFormModal(formData, saveText);\n }.bind(this));\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Setup form inside a modal\n *\n * @param {String} formData\n * @param {String} saveText\n */\n AcceptOnBehalf.prototype.setupFormModal = function(formData, saveText) {\n var modal = this.modal;\n\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody(formData));\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n modal.show();\n };\n\n /**\n * Load the body of the modal (contains the form)\n *\n * @method getBody\n * @private\n * @param {String} formData\n * @return {Promise}\n */\n AcceptOnBehalf.prototype.getBody = function(formData) {\n if (typeof formData === \"undefined\") {\n formData = {};\n }\n // Get the content of the modal.\n var params = {jsonformdata: JSON.stringify(formData)};\n return Fragment.loadFragment('tool_policy', 'accept_on_behalf', this.contextid, params);\n };\n\n /**\n * Submit the form inside the modal via AJAX request\n *\n * @method submitFormAjax\n * @private\n * @param {Event} e Form submission event.\n */\n AcceptOnBehalf.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n var requests = Ajax.call([{\n methodname: 'tool_policy_submit_accept_on_behalf',\n args: {jsonformdata: JSON.stringify(formData)}\n }]);\n requests[0].done(function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this)).fail(Notification.exception);\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AcceptOnBehalf.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n /**\n * Close the modal\n */\n AcceptOnBehalf.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n /**\n * Destroy the modal\n */\n AcceptOnBehalf.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n this.currentTrigger.focus();\n };\n\n return /** @alias module:tool_policy/acceptmodal */ {\n // Public variables and functions.\n /**\n * Attach event listeners to initialise this module.\n *\n * @method init\n * @param {int} contextid The contextid for the course.\n * @return {AcceptOnBehalf}\n */\n getInstance: function(contextid) {\n return new AcceptOnBehalf(contextid);\n }\n };\n });\n"],"file":"acceptmodal.min.js"} \ No newline at end of file +{"version":3,"file":"acceptmodal.min.js","sources":["../src/acceptmodal.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 * Add policy consent modal to the page\n *\n * @module tool_policy/acceptmodal\n * @copyright 2018 Marina Glancy\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/notification',\n 'core/fragment',\n 'core/ajax',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n ModalFactory,\n ModalEvents,\n Notification,\n Fragment,\n Ajax,\n FormChangeChecker\n) {\n\n \"use strict\";\n\n /**\n * Constructor\n *\n * @param {int} contextid\n *\n * Each call to init gets it's own instance of this class.\n */\n var AcceptOnBehalf = function(contextid) {\n this.contextid = contextid;\n this.init();\n };\n\n /**\n * @var {Modal} modal\n * @private\n */\n AcceptOnBehalf.prototype.modal = null;\n\n /**\n * @var {int} contextid\n * @private\n */\n AcceptOnBehalf.prototype.contextid = -1;\n\n /**\n * @var {object} currentTrigger The triggered HTML jQuery object\n * @private\n */\n AcceptOnBehalf.prototype.currentTrigger = null;\n\n /**\n * @var {object} triggers The trigger selectors\n * @private\n */\n AcceptOnBehalf.prototype.triggers = {\n SINGLE: 'a[data-action=acceptmodal]',\n BULK: 'input[data-action=acceptmodal]'\n };\n\n /**\n * Initialise the class.\n *\n * @private\n */\n AcceptOnBehalf.prototype.init = function() {\n // Initialise for links accepting policies for individual users.\n $(this.triggers.SINGLE).on('click', function(e) {\n e.preventDefault();\n this.currentTrigger = $(e.currentTarget);\n var href = $(e.currentTarget).attr('href'),\n formData = href.slice(href.indexOf('?') + 1);\n this.showFormModal(formData);\n }.bind(this));\n\n // Initialise for multiple users acceptance form.\n $(this.triggers.BULK).on('click', function(e) {\n e.preventDefault();\n this.currentTrigger = $(e.currentTarget);\n var form = $(e.currentTarget).closest('form');\n if (form.find('input[type=checkbox][name=\"userids[]\"]:checked').length) {\n var formData = form.serialize();\n this.showFormModal(formData);\n } else {\n Str.get_strings([\n {key: 'notice'},\n {key: 'selectusersforconsent', component: 'tool_policy'},\n {key: 'ok'}\n ]).then(function(strings) {\n Notification.alert(strings[0], strings[1], strings[2]);\n return;\n }).fail(Notification.exception);\n }\n }.bind(this));\n };\n\n /**\n * Show modal with a form\n *\n * @param {String} formData\n */\n AcceptOnBehalf.prototype.showFormModal = function(formData) {\n var action;\n var params = formData.split('&');\n for (var i = 0; i < params.length; i++) {\n var pair = params[i].split('=');\n if (pair[0] == 'action') {\n action = pair[1];\n }\n }\n // Fetch the title string.\n Str.get_strings([\n {key: 'statusformtitleaccept', component: 'tool_policy'},\n {key: 'iagreetothepolicy', component: 'tool_policy'},\n {key: 'statusformtitlerevoke', component: 'tool_policy'},\n {key: 'irevokethepolicy', component: 'tool_policy'},\n {key: 'statusformtitledecline', component: 'tool_policy'},\n {key: 'declinethepolicy', component: 'tool_policy'}\n ]).then(function(strings) {\n var title;\n var saveText;\n if (action == 'accept') {\n title = strings[0];\n saveText = strings[1];\n } else if (action == 'revoke') {\n title = strings[2];\n saveText = strings[3];\n } else if (action == 'decline') {\n title = strings[4];\n saveText = strings[5];\n }\n // Create the modal.\n return ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: title,\n body: ''\n }).done(function(modal) {\n this.modal = modal;\n this.setupFormModal(formData, saveText);\n }.bind(this));\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Setup form inside a modal\n *\n * @param {String} formData\n * @param {String} saveText\n */\n AcceptOnBehalf.prototype.setupFormModal = function(formData, saveText) {\n var modal = this.modal;\n\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody(formData));\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n modal.show();\n };\n\n /**\n * Load the body of the modal (contains the form)\n *\n * @method getBody\n * @private\n * @param {String} formData\n * @return {Promise}\n */\n AcceptOnBehalf.prototype.getBody = function(formData) {\n if (typeof formData === \"undefined\") {\n formData = {};\n }\n // Get the content of the modal.\n var params = {jsonformdata: JSON.stringify(formData)};\n return Fragment.loadFragment('tool_policy', 'accept_on_behalf', this.contextid, params);\n };\n\n /**\n * Submit the form inside the modal via AJAX request\n *\n * @method submitFormAjax\n * @private\n * @param {Event} e Form submission event.\n */\n AcceptOnBehalf.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n var requests = Ajax.call([{\n methodname: 'tool_policy_submit_accept_on_behalf',\n args: {jsonformdata: JSON.stringify(formData)}\n }]);\n requests[0].done(function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this)).fail(Notification.exception);\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AcceptOnBehalf.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n /**\n * Close the modal\n */\n AcceptOnBehalf.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n /**\n * Destroy the modal\n */\n AcceptOnBehalf.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n this.currentTrigger.focus();\n };\n\n return /** @alias module:tool_policy/acceptmodal */ {\n // Public variables and functions.\n /**\n * Attach event listeners to initialise this module.\n *\n * @method init\n * @param {int} contextid The contextid for the course.\n * @return {AcceptOnBehalf}\n */\n getInstance: function(contextid) {\n return new AcceptOnBehalf(contextid);\n }\n };\n });\n"],"names":["define","$","Str","ModalFactory","ModalEvents","Notification","Fragment","Ajax","FormChangeChecker","AcceptOnBehalf","contextid","init","prototype","modal","currentTrigger","triggers","SINGLE","BULK","this","on","e","preventDefault","currentTarget","href","attr","formData","slice","indexOf","showFormModal","bind","form","closest","find","length","serialize","get_strings","key","component","then","strings","alert","fail","exception","action","params","split","i","pair","title","saveText","create","type","types","SAVE_CANCEL","body","done","setupFormModal","catch","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","getBody","save","submitForm","submitFormAjax","show","jsonformdata","JSON","stringify","loadFragment","call","methodname","args","data","validationerrors","close","submit","document","location","reload","resetAllFormDirtyStates","focus","getInstance"],"mappings":";;;;;;;AAsBAA,iCAAO,CACH,SACA,WACA,qBACA,oBACA,oBACA,gBACA,YACA,4BACD,SACCC,EACAC,IACAC,aACAC,YACAC,aACAC,SACAC,KACAC,uBAYQC,eAAiB,SAASC,gBACrBA,UAAYA,eACZC,eAOTF,eAAeG,UAAUC,MAAQ,KAMjCJ,eAAeG,UAAUF,WAAa,EAMtCD,eAAeG,UAAUE,eAAiB,KAM1CL,eAAeG,UAAUG,SAAW,CAChCC,OAAQ,6BACRC,KAAM,kCAQVR,eAAeG,UAAUD,KAAO,WAE5BV,EAAEiB,KAAKH,SAASC,QAAQG,GAAG,QAAS,SAASC,GACzCA,EAAEC,sBACGP,eAAiBb,EAAEmB,EAAEE,mBACtBC,KAAOtB,EAAEmB,EAAE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SAG4B,CAShDC,YAAa,SAAS3E,kBACX,IAAID,eAAeC"} \ No newline at end of file diff --git a/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js b/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js index 37744652a39..6dc7ef9edf3 100644 --- a/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js +++ b/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js @@ -1,2 +1,3 @@ -define ("tool_policy/jquery-eu-cookie-law-popup",["jquery"],function(a){if(!window.console)window.console={};if(!window.console.log)window.console.log=function(){};a.fn.euCookieLawPopup=function(){var b=this;b.params={cookiePolicyUrl:"/?cookie-policy",popupPosition:"top",colorStyle:"default",compactStyle:!1,popupTitle:"This website is using cookies",popupText:"We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on this website.",buttonContinueTitle:"Continue",buttonLearnmoreTitle:"Learn more",buttonLearnmoreOpenInNewWindow:!0,agreementExpiresInDays:30,autoAcceptCookiePolicy:!1,htmlMarkup:null};b.vars={INITIALISED:!1,HTML_MARKUP:null,COOKIE_NAME:"EU_COOKIE_LAW_CONSENT"};var c=function(c,d,e){if(c){var f=a(c).attr("class")?a(c).attr("class"):"";if(-1
"+b.params.popupTitle+"
"+b.params.popupText+"
x
";return a},e=function(c){var e=new Date,d=1e3*(60*(60*(24*b.params.agreementExpiresInDays)));e.setTime(e.getTime()+d);var f="expires="+e.toGMTString();document.cookie=b.vars.COOKIE_NAME+"="+c+"; "+f+";path=/";a(document).trigger("user_cookie_consent_changed",{consent:c})},f=function(){for(var a=!1,d=document.cookie.split(";"),e=0,f;e-1?_self.params.popupPosition="top":className.indexOf("eupopup-fixedtop")>-1?_self.params.popupPosition="fixedtop":className.indexOf("eupopup-bottomright")>-1?_self.params.popupPosition="bottomright":className.indexOf("eupopup-bottomleft")>-1?_self.params.popupPosition="bottomleft":className.indexOf("eupopup-bottom")>-1?_self.params.popupPosition="bottom":className.indexOf("eupopup-block")>-1&&(_self.params.popupPosition="block"),className.indexOf("eupopup-color-default")>-1?_self.params.colorStyle="default":className.indexOf("eupopup-color-inverse")>-1&&(_self.params.colorStyle="inverse"),className.indexOf("eupopup-style-compact")>-1&&(_self.params.compactStyle=!0)}markup&&(_self.params.htmlMarkup=markup),settings&&(void 0!==settings.cookiePolicyUrl&&(_self.params.cookiePolicyUrl=settings.cookiePolicyUrl),void 0!==settings.popupPosition&&(_self.params.popupPosition=settings.popupPosition),void 0!==settings.colorStyle&&(_self.params.colorStyle=settings.colorStyle),void 0!==settings.popupTitle&&(_self.params.popupTitle=settings.popupTitle),void 0!==settings.popupText&&(_self.params.popupText=settings.popupText),void 0!==settings.buttonContinueTitle&&(_self.params.buttonContinueTitle=settings.buttonContinueTitle),void 0!==settings.buttonLearnmoreTitle&&(_self.params.buttonLearnmoreTitle=settings.buttonLearnmoreTitle),void 0!==settings.buttonLearnmoreOpenInNewWindow&&(_self.params.buttonLearnmoreOpenInNewWindow=settings.buttonLearnmoreOpenInNewWindow),void 0!==settings.agreementExpiresInDays&&(_self.params.agreementExpiresInDays=settings.agreementExpiresInDays),void 0!==settings.autoAcceptCookiePolicy&&(_self.params.autoAcceptCookiePolicy=settings.autoAcceptCookiePolicy),void 0!==settings.htmlMarkup&&(_self.params.htmlMarkup=settings.htmlMarkup))}($(".eupopup").first(),$(".eupopup-markup").html(),settings),function(){for(var userAcceptedCookies=!1,cookies=document.cookie.split(";"),i=0;i
'+_self.params.popupTitle+'
'+_self.params.popupText+'
x
',$(".eupopup-block").length>0?$(".eupopup-block").append(_self.vars.HTML_MARKUP):$("BODY").append(_self.vars.HTML_MARKUP),$(".eupopup-button_1").click((function(){return setUserAcceptsCookies(!0),hideContainer(),!1})),$(".eupopup-closebutton").click((function(){return setUserAcceptsCookies(!0),hideContainer(),!1})),$(".eupopup-container").show(),_self.params.autoAcceptCookiePolicy&&setUserAcceptsCookies(!0))}}}})); + +//# sourceMappingURL=jquery-eu-cookie-law-popup.min.js.map \ No newline at end of file diff --git a/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js.map b/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js.map index 0fac0c498af..e9557426c2c 100644 --- a/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js.map +++ b/admin/tool/policy/amd/build/jquery-eu-cookie-law-popup.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/jquery-eu-cookie-law-popup.js"],"names":["define","$","window","console","log","fn","euCookieLawPopup","_self","params","cookiePolicyUrl","popupPosition","colorStyle","compactStyle","popupTitle","popupText","buttonContinueTitle","buttonLearnmoreTitle","buttonLearnmoreOpenInNewWindow","agreementExpiresInDays","autoAcceptCookiePolicy","htmlMarkup","vars","INITIALISED","HTML_MARKUP","COOKIE_NAME","parseParameters","object","markup","settings","className","attr","indexOf","createHtmlMarkup","html","setUserAcceptsCookies","consent","d","Date","expiresInDays","setTime","getTime","expires","toGMTString","document","cookie","trigger","userAlreadyAcceptedCookies","userAcceptedCookies","cookies","split","i","c","length","trim","substring","hideContainer","animate","opacity","height","hide","init","first","append","click","show"],"mappings":"AAgBAA,OAAM,0CAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAG/B,GAAI,CAACC,MAAM,CAACC,OAAZ,CAAqBD,MAAM,CAACC,OAAP,CAAiB,EAAjB,CACrB,GAAI,CAACD,MAAM,CAACC,OAAP,CAAeC,GAApB,CAAyBF,MAAM,CAACC,OAAP,CAAeC,GAAf,CAAqB,UAAY,CAAG,CAApC,CAGzBH,CAAC,CAACI,EAAF,CAAKC,gBAAL,CAAyB,UAAW,CAEnC,GAAIC,CAAAA,CAAK,CAAG,IAAZ,CAIAA,CAAK,CAACC,MAAN,CAAe,CACdC,eAAe,CAAG,iBADJ,CAEdC,aAAa,CAAG,KAFF,CAGdC,UAAU,CAAG,SAHC,CAIdC,YAAY,GAJE,CAKdC,UAAU,CAAG,+BALC,CAMdC,SAAS,CAAG,uMANE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AAtC,CACA,CAFD,IAEO,CACNtB,CAAC,CAAC,MAAD,CAAD,CAAU6D,MAAV,CAAiBvD,CAAK,CAACc,IAAN,CAAWE,WAA5B,CACA,CAEDtB,CAAC,CAAC,mBAAD,CAAD,CAAuB8D,KAAvB,CAA6B,UAAW,CACvC7B,CAAqB,IAArB,CACAqB,CAAa,GACb,QACA,CAJD,EAKAtD,CAAC,CAAC,sBAAD,CAAD,CAA0B8D,KAA1B,CAAgC,UAAW,CAC1C7B,CAAqB,IAArB,CACAqB,CAAa,GACb,QACA,CAJD,EAQAtD,CAAC,CAAC,oBAAD,CAAD,CAAwB+D,IAAxB,GAGA,GAAIzD,CAAK,CAACC,MAAN,CAAaW,sBAAjB,CAAyC,CACxCe,CAAqB,IACrB,CAED,CAnDe,CAwDjB,CACA,CA3OK,CAAN","sourcesContent":["/**\r\n *\r\n * JQUERY EU COOKIE LAW POPUPS\r\n * version 1.1.1\r\n *\r\n * Code on Github:\r\n * https://github.com/wimagguc/jquery-eu-cookie-law-popup\r\n *\r\n * To see a live demo, go to:\r\n * http://www.wimagguc.com/2018/05/gdpr-compliance-with-the-jquery-eu-cookie-law-plugin/\r\n *\r\n * by Richard Dancsi\r\n * http://www.wimagguc.com/\r\n *\r\n */\r\n\r\ndefine(['jquery'], function($) {\r\n\r\n// for ie9 doesn't support debug console >>>\r\nif (!window.console) window.console = {};\r\nif (!window.console.log) window.console.log = function () { };\r\n// ^^^\r\n\r\n$.fn.euCookieLawPopup = (function() {\r\n\r\n\tvar _self = this;\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// PARAMETERS (MODIFY THIS PART) //////////////////////////////////////////////////////////////\r\n\t_self.params = {\r\n\t\tcookiePolicyUrl : '/?cookie-policy',\r\n\t\tpopupPosition : 'top',\r\n\t\tcolorStyle : 'default',\r\n\t\tcompactStyle : false,\r\n\t\tpopupTitle : 'This website is using cookies',\r\n\t\tpopupText : 'We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we\\'ll assume that you are happy to receive all cookies on this website.',\r\n\t\tbuttonContinueTitle : 'Continue',\r\n\t\tbuttonLearnmoreTitle : 'Learn more',\r\n\t\tbuttonLearnmoreOpenInNewWindow : true,\r\n\t\tagreementExpiresInDays : 30,\r\n\t\tautoAcceptCookiePolicy : false,\r\n\t\thtmlMarkup : null\r\n\t};\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// VARIABLES USED BY THE FUNCTION (DON'T MODIFY THIS PART) ////////////////////////////////////\r\n\t_self.vars = {\r\n\t\tINITIALISED : false,\r\n\t\tHTML_MARKUP : null,\r\n\t\tCOOKIE_NAME : 'EU_COOKIE_LAW_CONSENT'\r\n\t};\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// PRIVATE FUNCTIONS FOR MANIPULATING DATA ////////////////////////////////////////////////////\r\n\r\n\t// Overwrite default parameters if any of those is present\r\n\tvar parseParameters = function(object, markup, settings) {\r\n\r\n\t\tif (object) {\r\n\t\t\tvar className = $(object).attr('class') ? $(object).attr('class') : '';\r\n\t\t\tif (className.indexOf('eupopup-top') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'top';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-fixedtop') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'fixedtop';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-bottomright') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'bottomright';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-bottomleft') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'bottomleft';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-bottom') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'bottom';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-block') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'block';\r\n\t\t\t}\r\n\t\t\tif (className.indexOf('eupopup-color-default') > -1) {\r\n\t\t\t\t_self.params.colorStyle = 'default';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-color-inverse') > -1) {\r\n\t\t\t\t_self.params.colorStyle = 'inverse';\r\n\t\t\t}\r\n\t\t\tif (className.indexOf('eupopup-style-compact') > -1) {\r\n\t\t\t\t_self.params.compactStyle = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (markup) {\r\n\t\t\t_self.params.htmlMarkup = markup;\r\n\t\t}\r\n\r\n\t\tif (settings) {\r\n\t\t\tif (typeof settings.cookiePolicyUrl !== 'undefined') {\r\n\t\t\t\t_self.params.cookiePolicyUrl = settings.cookiePolicyUrl;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.popupPosition !== 'undefined') {\r\n\t\t\t\t_self.params.popupPosition = settings.popupPosition;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.colorStyle !== 'undefined') {\r\n\t\t\t\t_self.params.colorStyle = settings.colorStyle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.popupTitle !== 'undefined') {\r\n\t\t\t\t_self.params.popupTitle = settings.popupTitle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.popupText !== 'undefined') {\r\n\t\t\t\t_self.params.popupText = settings.popupText;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.buttonContinueTitle !== 'undefined') {\r\n\t\t\t\t_self.params.buttonContinueTitle = settings.buttonContinueTitle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.buttonLearnmoreTitle !== 'undefined') {\r\n\t\t\t\t_self.params.buttonLearnmoreTitle = settings.buttonLearnmoreTitle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.buttonLearnmoreOpenInNewWindow !== 'undefined') {\r\n\t\t\t\t_self.params.buttonLearnmoreOpenInNewWindow = settings.buttonLearnmoreOpenInNewWindow;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.agreementExpiresInDays !== 'undefined') {\r\n\t\t\t\t_self.params.agreementExpiresInDays = settings.agreementExpiresInDays;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.autoAcceptCookiePolicy !== 'undefined') {\r\n\t\t\t\t_self.params.autoAcceptCookiePolicy = settings.autoAcceptCookiePolicy;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.htmlMarkup !== 'undefined') {\r\n\t\t\t\t_self.params.htmlMarkup = settings.htmlMarkup;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t};\r\n\r\n\tvar createHtmlMarkup = function() {\r\n\r\n\t\tif (_self.params.htmlMarkup) {\r\n\t\t\treturn _self.params.htmlMarkup;\r\n\t\t}\r\n\r\n\t\tvar html =\r\n\t\t\t'
' +\r\n\t\t\t\t'
' + _self.params.popupTitle + '
' +\r\n\t\t\t\t'
' + _self.params.popupText + '
' +\r\n\t\t\t\t'
' +\r\n\t\t\t\t '' + _self.params.buttonContinueTitle + '' +\r\n\t\t\t\t '' + _self.params.buttonLearnmoreTitle + '' +\r\n\t\t\t\t '
' +\r\n\t\t\t\t'
' +\r\n\t\t\t\t'x' +\r\n\t\t\t'
';\r\n\r\n\t\treturn html;\r\n\t};\r\n\r\n\t// Storing the consent in a cookie\r\n\tvar setUserAcceptsCookies = function(consent) {\r\n\t\tvar d = new Date();\r\n\t\tvar expiresInDays = _self.params.agreementExpiresInDays * 24 * 60 * 60 * 1000;\r\n\t\td.setTime( d.getTime() + expiresInDays );\r\n\t\tvar expires = \"expires=\" + d.toGMTString();\r\n\t\tdocument.cookie = _self.vars.COOKIE_NAME + '=' + consent + \"; \" + expires + \";path=/\";\r\n\r\n\t\t$(document).trigger(\"user_cookie_consent_changed\", {'consent' : consent});\r\n\t};\r\n\r\n\t// Let's see if we have a consent cookie already\r\n\tvar userAlreadyAcceptedCookies = function() {\r\n\t\tvar userAcceptedCookies = false;\r\n\t\tvar cookies = document.cookie.split(\";\");\r\n\t\tfor (var i = 0; i < cookies.length; i++) {\r\n\t\t\tvar c = cookies[i].trim();\r\n\t\t\tif (c.indexOf(_self.vars.COOKIE_NAME) !== -1) {\r\n\t\t\t\tuserAcceptedCookies = c.substring(_self.vars.COOKIE_NAME.length + 1, c.length);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn userAcceptedCookies;\r\n\t};\r\n\r\n\tvar hideContainer = function() {\r\n\t\t// $('.eupopup-container').slideUp(200);\r\n\t\t$('.eupopup-container').animate({\r\n\t\t\topacity: 0,\r\n\t\t\theight: 0\r\n\t\t}, 200, function() {\r\n\t\t\t$('.eupopup-container').hide(0);\r\n\t\t});\r\n\t};\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////\r\n\tvar publicfunc = {\r\n\r\n\t\t// INITIALIZE EU COOKIE LAW POPUP /////////////////////////////////////////////////////////\r\n\t\tinit : function(settings) {\r\n\r\n\t\t\tparseParameters(\r\n\t\t\t\t$(\".eupopup\").first(),\r\n\t\t\t\t$(\".eupopup-markup\").html(),\r\n\t\t\t\tsettings);\r\n\r\n\t\t\t// No need to display this if user already accepted the policy\r\n\t\t\tif (userAlreadyAcceptedCookies()) {\r\n $(document).trigger(\"user_cookie_already_accepted\", {'consent': true});\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// We should initialise only once\r\n\t\t\tif (_self.vars.INITIALISED) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t_self.vars.INITIALISED = true;\r\n\r\n\t\t\t// Markup and event listeners >>>\r\n\t\t\t_self.vars.HTML_MARKUP = createHtmlMarkup();\r\n\r\n\t\t\tif ($('.eupopup-block').length > 0) {\r\n\t\t\t\t$('.eupopup-block').append(_self.vars.HTML_MARKUP);\r\n\t\t\t} else {\r\n\t\t\t\t$('BODY').append(_self.vars.HTML_MARKUP);\r\n\t\t\t}\r\n\r\n\t\t\t$('.eupopup-button_1').click(function() {\r\n\t\t\t\tsetUserAcceptsCookies(true);\r\n\t\t\t\thideContainer();\r\n\t\t\t\treturn false;\r\n\t\t\t});\r\n\t\t\t$('.eupopup-closebutton').click(function() {\r\n\t\t\t\tsetUserAcceptsCookies(true);\r\n\t\t\t\thideContainer();\r\n\t\t\t\treturn false;\r\n\t\t\t});\r\n\t\t\t// ^^^ Markup and event listeners\r\n\r\n\t\t\t// Ready to start!\r\n\t\t\t$('.eupopup-container').show();\r\n\r\n\t\t\t// In case it's alright to just display the message once\r\n\t\t\tif (_self.params.autoAcceptCookiePolicy) {\r\n\t\t\t\tsetUserAcceptsCookies(true);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t};\r\n\r\n\treturn publicfunc;\r\n});\r\n});\r\n"],"file":"jquery-eu-cookie-law-popup.min.js"} \ No newline at end of file +{"version":3,"file":"jquery-eu-cookie-law-popup.min.js","sources":["../src/jquery-eu-cookie-law-popup.js"],"sourcesContent":["/**\r\n *\r\n * JQUERY EU COOKIE LAW POPUPS\r\n * version 1.1.1\r\n *\r\n * Code on Github:\r\n * https://github.com/wimagguc/jquery-eu-cookie-law-popup\r\n *\r\n * To see a live demo, go to:\r\n * http://www.wimagguc.com/2018/05/gdpr-compliance-with-the-jquery-eu-cookie-law-plugin/\r\n *\r\n * by Richard Dancsi\r\n * http://www.wimagguc.com/\r\n *\r\n */\r\n\r\ndefine(['jquery'], function($) {\r\n\r\n// for ie9 doesn't support debug console >>>\r\nif (!window.console) window.console = {};\r\nif (!window.console.log) window.console.log = function () { };\r\n// ^^^\r\n\r\n$.fn.euCookieLawPopup = (function() {\r\n\r\n\tvar _self = this;\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// PARAMETERS (MODIFY THIS PART) //////////////////////////////////////////////////////////////\r\n\t_self.params = {\r\n\t\tcookiePolicyUrl : '/?cookie-policy',\r\n\t\tpopupPosition : 'top',\r\n\t\tcolorStyle : 'default',\r\n\t\tcompactStyle : false,\r\n\t\tpopupTitle : 'This website is using cookies',\r\n\t\tpopupText : 'We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we\\'ll assume that you are happy to receive all cookies on this website.',\r\n\t\tbuttonContinueTitle : 'Continue',\r\n\t\tbuttonLearnmoreTitle : 'Learn more',\r\n\t\tbuttonLearnmoreOpenInNewWindow : true,\r\n\t\tagreementExpiresInDays : 30,\r\n\t\tautoAcceptCookiePolicy : false,\r\n\t\thtmlMarkup : null\r\n\t};\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// VARIABLES USED BY THE FUNCTION (DON'T MODIFY THIS PART) ////////////////////////////////////\r\n\t_self.vars = {\r\n\t\tINITIALISED : false,\r\n\t\tHTML_MARKUP : null,\r\n\t\tCOOKIE_NAME : 'EU_COOKIE_LAW_CONSENT'\r\n\t};\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// PRIVATE FUNCTIONS FOR MANIPULATING DATA ////////////////////////////////////////////////////\r\n\r\n\t// Overwrite default parameters if any of those is present\r\n\tvar parseParameters = function(object, markup, settings) {\r\n\r\n\t\tif (object) {\r\n\t\t\tvar className = $(object).attr('class') ? $(object).attr('class') : '';\r\n\t\t\tif (className.indexOf('eupopup-top') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'top';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-fixedtop') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'fixedtop';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-bottomright') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'bottomright';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-bottomleft') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'bottomleft';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-bottom') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'bottom';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-block') > -1) {\r\n\t\t\t\t_self.params.popupPosition = 'block';\r\n\t\t\t}\r\n\t\t\tif (className.indexOf('eupopup-color-default') > -1) {\r\n\t\t\t\t_self.params.colorStyle = 'default';\r\n\t\t\t}\r\n\t\t\telse if (className.indexOf('eupopup-color-inverse') > -1) {\r\n\t\t\t\t_self.params.colorStyle = 'inverse';\r\n\t\t\t}\r\n\t\t\tif (className.indexOf('eupopup-style-compact') > -1) {\r\n\t\t\t\t_self.params.compactStyle = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (markup) {\r\n\t\t\t_self.params.htmlMarkup = markup;\r\n\t\t}\r\n\r\n\t\tif (settings) {\r\n\t\t\tif (typeof settings.cookiePolicyUrl !== 'undefined') {\r\n\t\t\t\t_self.params.cookiePolicyUrl = settings.cookiePolicyUrl;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.popupPosition !== 'undefined') {\r\n\t\t\t\t_self.params.popupPosition = settings.popupPosition;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.colorStyle !== 'undefined') {\r\n\t\t\t\t_self.params.colorStyle = settings.colorStyle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.popupTitle !== 'undefined') {\r\n\t\t\t\t_self.params.popupTitle = settings.popupTitle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.popupText !== 'undefined') {\r\n\t\t\t\t_self.params.popupText = settings.popupText;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.buttonContinueTitle !== 'undefined') {\r\n\t\t\t\t_self.params.buttonContinueTitle = settings.buttonContinueTitle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.buttonLearnmoreTitle !== 'undefined') {\r\n\t\t\t\t_self.params.buttonLearnmoreTitle = settings.buttonLearnmoreTitle;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.buttonLearnmoreOpenInNewWindow !== 'undefined') {\r\n\t\t\t\t_self.params.buttonLearnmoreOpenInNewWindow = settings.buttonLearnmoreOpenInNewWindow;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.agreementExpiresInDays !== 'undefined') {\r\n\t\t\t\t_self.params.agreementExpiresInDays = settings.agreementExpiresInDays;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.autoAcceptCookiePolicy !== 'undefined') {\r\n\t\t\t\t_self.params.autoAcceptCookiePolicy = settings.autoAcceptCookiePolicy;\r\n\t\t\t}\r\n\t\t\tif (typeof settings.htmlMarkup !== 'undefined') {\r\n\t\t\t\t_self.params.htmlMarkup = settings.htmlMarkup;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t};\r\n\r\n\tvar createHtmlMarkup = function() {\r\n\r\n\t\tif (_self.params.htmlMarkup) {\r\n\t\t\treturn _self.params.htmlMarkup;\r\n\t\t}\r\n\r\n\t\tvar html =\r\n\t\t\t'
' +\r\n\t\t\t\t'
' + _self.params.popupTitle + '
' +\r\n\t\t\t\t'
' + _self.params.popupText + '
' +\r\n\t\t\t\t'
' +\r\n\t\t\t\t '' + _self.params.buttonContinueTitle + '' +\r\n\t\t\t\t '' + _self.params.buttonLearnmoreTitle + '' +\r\n\t\t\t\t '
' +\r\n\t\t\t\t'
' +\r\n\t\t\t\t'x' +\r\n\t\t\t'
';\r\n\r\n\t\treturn html;\r\n\t};\r\n\r\n\t// Storing the consent in a cookie\r\n\tvar setUserAcceptsCookies = function(consent) {\r\n\t\tvar d = new Date();\r\n\t\tvar expiresInDays = _self.params.agreementExpiresInDays * 24 * 60 * 60 * 1000;\r\n\t\td.setTime( d.getTime() + expiresInDays );\r\n\t\tvar expires = \"expires=\" + d.toGMTString();\r\n\t\tdocument.cookie = _self.vars.COOKIE_NAME + '=' + consent + \"; \" + expires + \";path=/\";\r\n\r\n\t\t$(document).trigger(\"user_cookie_consent_changed\", {'consent' : consent});\r\n\t};\r\n\r\n\t// Let's see if we have a consent cookie already\r\n\tvar userAlreadyAcceptedCookies = function() {\r\n\t\tvar userAcceptedCookies = false;\r\n\t\tvar cookies = document.cookie.split(\";\");\r\n\t\tfor (var i = 0; i < cookies.length; i++) {\r\n\t\t\tvar c = cookies[i].trim();\r\n\t\t\tif (c.indexOf(_self.vars.COOKIE_NAME) !== -1) {\r\n\t\t\t\tuserAcceptedCookies = c.substring(_self.vars.COOKIE_NAME.length + 1, c.length);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn userAcceptedCookies;\r\n\t};\r\n\r\n\tvar hideContainer = function() {\r\n\t\t// $('.eupopup-container').slideUp(200);\r\n\t\t$('.eupopup-container').animate({\r\n\t\t\topacity: 0,\r\n\t\t\theight: 0\r\n\t\t}, 200, function() {\r\n\t\t\t$('.eupopup-container').hide(0);\r\n\t\t});\r\n\t};\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////\r\n\t// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////\r\n\tvar publicfunc = {\r\n\r\n\t\t// INITIALIZE EU COOKIE LAW POPUP /////////////////////////////////////////////////////////\r\n\t\tinit : function(settings) {\r\n\r\n\t\t\tparseParameters(\r\n\t\t\t\t$(\".eupopup\").first(),\r\n\t\t\t\t$(\".eupopup-markup\").html(),\r\n\t\t\t\tsettings);\r\n\r\n\t\t\t// No need to display this if user already accepted the policy\r\n\t\t\tif (userAlreadyAcceptedCookies()) {\r\n $(document).trigger(\"user_cookie_already_accepted\", {'consent': true});\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// We should initialise only once\r\n\t\t\tif (_self.vars.INITIALISED) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t_self.vars.INITIALISED = true;\r\n\r\n\t\t\t// Markup and event listeners >>>\r\n\t\t\t_self.vars.HTML_MARKUP = createHtmlMarkup();\r\n\r\n\t\t\tif ($('.eupopup-block').length > 0) {\r\n\t\t\t\t$('.eupopup-block').append(_self.vars.HTML_MARKUP);\r\n\t\t\t} else {\r\n\t\t\t\t$('BODY').append(_self.vars.HTML_MARKUP);\r\n\t\t\t}\r\n\r\n\t\t\t$('.eupopup-button_1').click(function() {\r\n\t\t\t\tsetUserAcceptsCookies(true);\r\n\t\t\t\thideContainer();\r\n\t\t\t\treturn false;\r\n\t\t\t});\r\n\t\t\t$('.eupopup-closebutton').click(function() {\r\n\t\t\t\tsetUserAcceptsCookies(true);\r\n\t\t\t\thideContainer();\r\n\t\t\t\treturn false;\r\n\t\t\t});\r\n\t\t\t// ^^^ Markup and event listeners\r\n\r\n\t\t\t// Ready to start!\r\n\t\t\t$('.eupopup-container').show();\r\n\r\n\t\t\t// In case it's alright to just display the message once\r\n\t\t\tif (_self.params.autoAcceptCookiePolicy) {\r\n\t\t\t\tsetUserAcceptsCookies(true);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t};\r\n\r\n\treturn publicfunc;\r\n});\r\n});\r\n"],"names":["define","$","window","console","log","fn","euCookieLawPopup","_self","this","params","cookiePolicyUrl","popupPosition","colorStyle","compactStyle","popupTitle","popupText","buttonContinueTitle","buttonLearnmoreTitle","buttonLearnmoreOpenInNewWindow","agreementExpiresInDays","autoAcceptCookiePolicy","htmlMarkup","vars","INITIALISED","HTML_MARKUP","COOKIE_NAME","setUserAcceptsCookies","consent","d","Date","expiresInDays","setTime","getTime","expires","toGMTString","document","cookie","trigger","hideContainer","animate","opacity","height","hide","init","settings","object","markup","className","attr","indexOf","parseParameters","first","html","userAcceptedCookies","cookies","split","i","length","c","trim","substring","userAlreadyAcceptedCookies","append","click","show"],"mappings":"AAgBAA,gDAAO,CAAC,WAAW,SAASC,GAGvBC,OAAOC,UAASD,OAAOC,QAAU,IACjCD,OAAOC,QAAQC,MAAKF,OAAOC,QAAQC,IAAM,cAG9CH,EAAEI,GAAGC,iBAAoB,eAEpBC,MAAQC,KAIZD,MAAME,OAAS,CACdC,gBAAkB,kBAClBC,cAAgB,MAChBC,WAAa,UACbC,cAAe,EACfC,WAAa,gCACbC,UAAY,wMACZC,oBAAsB,WACtBC,qBAAuB,kBACvBC,gCAAiC,EACjCC,uBAAyB,GACzBC,wBAAyB,EACzBC,WAAa,MAKdd,MAAMe,KAAO,CACZC,aAAc,EACdC,YAAc,KACdC,YAAc,6BA6GXC,sBAAwB,SAASC,aAChCC,EAAI,IAAIC,KACRC,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oBAPzE,gBAQiBT,MAAME,OAAOC,gBAAkB,KAC5CH,MAAME,OAAOS,+BAAiC,kBAAoB,IACpE,4CAA8CX,MAAME,OAAOQ,qBAV7D,4FAiFIhB,EAAE,kBAAkBwD,OAAS,EAChCxD,EAAE,kBAAkB6D,OAAOvD,MAAMe,KAAKE,aAEtCvB,EAAE,QAAQ6D,OAAOvD,MAAMe,KAAKE,aAG7BvB,EAAE,qBAAqB8D,OAAM,kBAC5BrC,uBAAsB,GACtBY,iBACO,KAERrC,EAAE,wBAAwB8D,OAAM,kBAC/BrC,uBAAsB,GACtBY,iBACO,KAKRrC,EAAE,sBAAsB+D,OAGpBzD,MAAME,OAAOW,wBAChBM,uBAAsB"} \ No newline at end of file diff --git a/admin/tool/policy/amd/build/managedocsactions.min.js b/admin/tool/policy/amd/build/managedocsactions.min.js index e5a1692f384..fb447ea00ea 100644 --- a/admin/tool/policy/amd/build/managedocsactions.min.js +++ b/admin/tool/policy/amd/build/managedocsactions.min.js @@ -1,2 +1,10 @@ -define ("tool_policy/managedocsactions",["jquery","core/log","core/config","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){"use strict";var h={LINKS:"[data-action]",MAKE_CURRENT:"[data-action=\"makecurrent\"]",INACTIVATE:"[data-action=\"inactivate\"]",DELETE:"[data-action=\"delete\"]"};function g(a){this.base=a;this.initEvents()}g.prototype.initEvents=function(){var g=this;g.base.on("click",h.LINKS,function(g){g.stopPropagation();var i=a(g.currentTarget),j,k;if(i.is(h.MAKE_CURRENT)){j=d.get_strings([{key:"activating",component:"tool_policy"},{key:"activateconfirm",component:"tool_policy",param:{name:i.closest("[data-policy-name]").attr("data-policy-name"),revision:i.closest("[data-policy-revision]").attr("data-policy-revision")}},{key:"activateconfirmyes",component:"tool_policy"}])}else if(i.is(h.INACTIVATE)){j=d.get_strings([{key:"inactivating",component:"tool_policy"},{key:"inactivatingconfirm",component:"tool_policy",param:{name:i.closest("[data-policy-name]").attr("data-policy-name"),revision:i.closest("[data-policy-revision]").attr("data-policy-revision")}},{key:"inactivatingconfirmyes",component:"tool_policy"}])}else if(i.is(h.DELETE)){j=d.get_strings([{key:"deleting",component:"tool_policy"},{key:"deleteconfirm",component:"tool_policy",param:{name:i.closest("[data-policy-name]").attr("data-policy-name"),revision:i.closest("[data-policy-revision]").attr("data-policy-revision")}},{key:"delete",component:"core"}])}else{b.error("unknown action type detected","tool_policy/managedocsactions");return}g.preventDefault();j.then(function(a){k=a;return e.create({title:k[0],body:k[1],type:e.types.SAVE_CANCEL})}).then(function(a){a.setSaveButtonText(k[2]);a.getRoot().on(f.save,function(){window.location.href=i.attr("href")+"&sesskey="+c.sesskey+"&confirm=1"});a.getRoot().on(f.hidden,function(){a.destroy()});a.show();return!0}).catch(function(a){b.error(a);return!1})})};return{init:function init(b){var c=a(document.getElementById(b));if(c.length){return new g(c)}else{throw new Error("managedocsactions: Invalid base element identifier")}}}}); -//# sourceMappingURL=managedocsactions.min.js.map +/** + * Adds support for confirmation via JS modal for some management actions at the Manage policies page. + * + * @module tool_policy/managedocsactions + * @copyright 2018 David Mudrák + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_policy/managedocsactions",["jquery","core/log","core/config","core/str","core/modal_factory","core/modal_events"],(function($,Log,Config,Str,ModalFactory,ModalEvents){var ACTION_LINKS="[data-action]",ACTION_MAKE_CURRENT='[data-action="makecurrent"]',ACTION_INACTIVATE='[data-action="inactivate"]',ACTION_DELETE='[data-action="delete"]';function ManageDocsActions(base){this.base=base,this.initEvents()}return ManageDocsActions.prototype.initEvents=function(){this.base.on("click",ACTION_LINKS,(function(e){e.stopPropagation();var promise,strings,link=$(e.currentTarget);if(link.is(ACTION_MAKE_CURRENT))promise=Str.get_strings([{key:"activating",component:"tool_policy"},{key:"activateconfirm",component:"tool_policy",param:{name:link.closest("[data-policy-name]").attr("data-policy-name"),revision:link.closest("[data-policy-revision]").attr("data-policy-revision")}},{key:"activateconfirmyes",component:"tool_policy"}]);else if(link.is(ACTION_INACTIVATE))promise=Str.get_strings([{key:"inactivating",component:"tool_policy"},{key:"inactivatingconfirm",component:"tool_policy",param:{name:link.closest("[data-policy-name]").attr("data-policy-name"),revision:link.closest("[data-policy-revision]").attr("data-policy-revision")}},{key:"inactivatingconfirmyes",component:"tool_policy"}]);else{if(!link.is(ACTION_DELETE))return void Log.error("unknown action type detected","tool_policy/managedocsactions");promise=Str.get_strings([{key:"deleting",component:"tool_policy"},{key:"deleteconfirm",component:"tool_policy",param:{name:link.closest("[data-policy-name]").attr("data-policy-name"),revision:link.closest("[data-policy-revision]").attr("data-policy-revision")}},{key:"delete",component:"core"}])}e.preventDefault(),promise.then((function(strs){return strings=strs,ModalFactory.create({title:strings[0],body:strings[1],type:ModalFactory.types.SAVE_CANCEL})})).then((function(modal){return modal.setSaveButtonText(strings[2]),modal.getRoot().on(ModalEvents.save,(function(){window.location.href=link.attr("href")+"&sesskey="+Config.sesskey+"&confirm=1"})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal.show(),!0})).catch((function(e){return Log.error(e),!1}))}))},{init:function(baseid){var base=$(document.getElementById(baseid));if(base.length)return new ManageDocsActions(base);throw new Error("managedocsactions: Invalid base element identifier")}}})); + +//# sourceMappingURL=managedocsactions.min.js.map \ No newline at end of file diff --git a/admin/tool/policy/amd/build/managedocsactions.min.js.map b/admin/tool/policy/amd/build/managedocsactions.min.js.map index 0c08443570d..d2962520b4e 100644 --- a/admin/tool/policy/amd/build/managedocsactions.min.js.map +++ b/admin/tool/policy/amd/build/managedocsactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/managedocsactions.js"],"names":["define","$","Log","Config","Str","ModalFactory","ModalEvents","ACTION","LINKS","MAKE_CURRENT","INACTIVATE","DELETE","ManageDocsActions","base","initEvents","prototype","self","on","e","stopPropagation","link","currentTarget","promise","strings","is","get_strings","key","component","param","name","closest","attr","revision","error","preventDefault","then","strs","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","save","window","location","href","sesskey","hidden","destroy","show","catch","init","baseid","document","getElementById","length","Error"],"mappings":"AAsBAA,OAAM,iCAAC,CACH,QADG,CAEH,UAFG,CAGH,aAHG,CAIH,UAJG,CAKH,oBALG,CAMH,mBANG,CAAD,CAOH,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAAyBC,CAAzB,CAA8BC,CAA9B,CAA4CC,CAA5C,CAAyD,CAExD,aAQA,GAAIC,CAAAA,CAAM,CAAG,CACTC,KAAK,CAAE,eADE,CAETC,YAAY,CAAE,+BAFL,CAGTC,UAAU,CAAE,8BAHH,CAITC,MAAM,CAAE,0BAJC,CAAb,CAWA,QAASC,CAAAA,CAAT,CAA2BC,CAA3B,CAAiC,CAC7B,KAAKA,IAAL,CAAYA,CAAZ,CAEA,KAAKC,UAAL,EACH,CAKDF,CAAiB,CAACG,SAAlB,CAA4BD,UAA5B,CAAyC,UAAW,CAChD,GAAIE,CAAAA,CAAI,CAAG,IAAX,CAEAA,CAAI,CAACH,IAAL,CAAUI,EAAV,CAAa,OAAb,CAAsBV,CAAM,CAACC,KAA7B,CAAoC,SAASU,CAAT,CAAY,CAC5CA,CAAC,CAACC,eAAF,GAD4C,GAGxCC,CAAAA,CAAI,CAAGnB,CAAC,CAACiB,CAAC,CAACG,aAAH,CAHgC,CAIxCC,CAJwC,CAKxCC,CALwC,CAO5C,GAAIH,CAAI,CAACI,EAAL,CAAQjB,CAAM,CAACE,YAAf,CAAJ,CAAkC,CAC9Ba,CAAO,CAAGlB,CAAG,CAACqB,WAAJ,CAAgB,CACtB,CAACC,GAAG,CAAE,YAAN,CAAoBC,SAAS,CAAE,aAA/B,CADsB,CAEtB,CAACD,GAAG,CAAE,iBAAN,CAAyBC,SAAS,CAAE,aAApC,CAAmDC,KAAK,CAAE,CACtDC,IAAI,CAAET,CAAI,CAACU,OAAL,CAAa,oBAAb,EAAmCC,IAAnC,CAAwC,kBAAxC,CADgD,CAEtDC,QAAQ,CAAEZ,CA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,CACb,MAAO,IAAI/C,CAAAA,CAAJ,CAAsBC,CAAtB,CAEV,CAHD,IAGO,CACH,KAAM,IAAI+C,CAAAA,KAAJ,CAAU,oDAAV,CACT,CACJ,CAhBE,CAkBV,CAlIK,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 * Adds support for confirmation via JS modal for some management actions at the Manage policies page.\n *\n * @module tool_policy/managedocsactions\n * @copyright 2018 David Mudrák \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/log',\n 'core/config',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'\n], function($, Log, Config, Str, ModalFactory, ModalEvents) {\n\n \"use strict\";\n\n /**\n * List of action selectors.\n *\n * @property {string} LINKS - Selector for all action links\n * @property {string} MAKE_CURRENT\n */\n var ACTION = {\n LINKS: '[data-action]',\n MAKE_CURRENT: '[data-action=\"makecurrent\"]',\n INACTIVATE: '[data-action=\"inactivate\"]',\n DELETE: '[data-action=\"delete\"]'\n };\n\n /**\n * @constructor\n * @param {Element} base - Management area wrapping element\n */\n function ManageDocsActions(base) {\n this.base = base;\n\n this.initEvents();\n }\n\n /**\n * Register event listeners.\n */\n ManageDocsActions.prototype.initEvents = function() {\n var self = this;\n\n self.base.on('click', ACTION.LINKS, function(e) {\n e.stopPropagation();\n\n var link = $(e.currentTarget);\n var promise;\n var strings;\n\n if (link.is(ACTION.MAKE_CURRENT)) {\n promise = Str.get_strings([\n {key: 'activating', component: 'tool_policy'},\n {key: 'activateconfirm', component: 'tool_policy', param: {\n name: link.closest('[data-policy-name]').attr('data-policy-name'),\n revision: link.closest('[data-policy-revision]').attr('data-policy-revision')\n }},\n {key: 'activateconfirmyes', component: 'tool_policy'}\n ]);\n\n } else if (link.is(ACTION.INACTIVATE)) {\n promise = Str.get_strings([\n {key: 'inactivating', component: 'tool_policy'},\n {key: 'inactivatingconfirm', component: 'tool_policy', param: {\n name: link.closest('[data-policy-name]').attr('data-policy-name'),\n revision: link.closest('[data-policy-revision]').attr('data-policy-revision')\n }},\n {key: 'inactivatingconfirmyes', component: 'tool_policy'}\n ]);\n\n } else if (link.is(ACTION.DELETE)) {\n promise = Str.get_strings([\n {key: 'deleting', component: 'tool_policy'},\n {key: 'deleteconfirm', component: 'tool_policy', param: {\n name: link.closest('[data-policy-name]').attr('data-policy-name'),\n revision: link.closest('[data-policy-revision]').attr('data-policy-revision')\n }},\n {key: 'delete', component: 'core'}\n ]);\n\n } else {\n Log.error('unknown action type detected', 'tool_policy/managedocsactions');\n return;\n }\n\n e.preventDefault();\n\n promise.then(function(strs) {\n strings = strs;\n return ModalFactory.create({\n title: strings[0],\n body: strings[1],\n type: ModalFactory.types.SAVE_CANCEL\n });\n\n }).then(function(modal) {\n modal.setSaveButtonText(strings[2]);\n modal.getRoot().on(ModalEvents.save, function() {\n window.location.href = link.attr('href') + '&sesskey=' + Config.sesskey + '&confirm=1';\n });\n\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n modal.show();\n return true;\n\n }).catch(function(e) {\n Log.error(e);\n return false;\n });\n });\n };\n\n return {\n /**\n * Factory method returning instance of the ManageDocsActions\n *\n * @param {String} baseid - ID of the management area wrapping element\n * @return {ManageDocsActions}\n */\n init: function(baseid) {\n var base = $(document.getElementById(baseid));\n\n if (base.length) {\n return new ManageDocsActions(base);\n\n } else {\n throw new Error(\"managedocsactions: Invalid base element identifier\");\n }\n }\n };\n});\n"],"file":"managedocsactions.min.js"} \ No newline at end of file +{"version":3,"file":"managedocsactions.min.js","sources":["../src/managedocsactions.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 * Adds support for confirmation via JS modal for some management actions at the Manage policies page.\n *\n * @module tool_policy/managedocsactions\n * @copyright 2018 David Mudrák \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/log',\n 'core/config',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'\n], function($, Log, Config, Str, ModalFactory, ModalEvents) {\n\n \"use strict\";\n\n /**\n * List of action selectors.\n *\n * @property {string} LINKS - Selector for all action links\n * @property {string} MAKE_CURRENT\n */\n var ACTION = {\n LINKS: '[data-action]',\n MAKE_CURRENT: '[data-action=\"makecurrent\"]',\n INACTIVATE: '[data-action=\"inactivate\"]',\n DELETE: '[data-action=\"delete\"]'\n };\n\n /**\n * @constructor\n * @param {Element} base - Management area wrapping element\n */\n function ManageDocsActions(base) {\n this.base = base;\n\n this.initEvents();\n }\n\n /**\n * Register event listeners.\n */\n ManageDocsActions.prototype.initEvents = function() {\n var self = this;\n\n self.base.on('click', ACTION.LINKS, function(e) {\n e.stopPropagation();\n\n var link = $(e.currentTarget);\n var promise;\n var strings;\n\n if (link.is(ACTION.MAKE_CURRENT)) {\n promise = Str.get_strings([\n {key: 'activating', component: 'tool_policy'},\n {key: 'activateconfirm', component: 'tool_policy', param: {\n name: link.closest('[data-policy-name]').attr('data-policy-name'),\n revision: link.closest('[data-policy-revision]').attr('data-policy-revision')\n }},\n {key: 'activateconfirmyes', component: 'tool_policy'}\n ]);\n\n } else if (link.is(ACTION.INACTIVATE)) {\n promise = Str.get_strings([\n {key: 'inactivating', component: 'tool_policy'},\n {key: 'inactivatingconfirm', component: 'tool_policy', param: {\n name: link.closest('[data-policy-name]').attr('data-policy-name'),\n revision: link.closest('[data-policy-revision]').attr('data-policy-revision')\n }},\n {key: 'inactivatingconfirmyes', component: 'tool_policy'}\n ]);\n\n } else if (link.is(ACTION.DELETE)) {\n promise = Str.get_strings([\n {key: 'deleting', component: 'tool_policy'},\n {key: 'deleteconfirm', component: 'tool_policy', param: {\n name: link.closest('[data-policy-name]').attr('data-policy-name'),\n revision: link.closest('[data-policy-revision]').attr('data-policy-revision')\n }},\n {key: 'delete', component: 'core'}\n ]);\n\n } else {\n Log.error('unknown action type detected', 'tool_policy/managedocsactions');\n return;\n }\n\n e.preventDefault();\n\n promise.then(function(strs) {\n strings = strs;\n return ModalFactory.create({\n title: strings[0],\n body: strings[1],\n type: ModalFactory.types.SAVE_CANCEL\n });\n\n }).then(function(modal) {\n modal.setSaveButtonText(strings[2]);\n modal.getRoot().on(ModalEvents.save, function() {\n window.location.href = link.attr('href') + '&sesskey=' + Config.sesskey + '&confirm=1';\n });\n\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n\n modal.show();\n return true;\n\n }).catch(function(e) {\n Log.error(e);\n return false;\n });\n });\n };\n\n return {\n /**\n * Factory method returning instance of the ManageDocsActions\n *\n * @param {String} baseid - ID of the management area wrapping element\n * @return {ManageDocsActions}\n */\n init: function(baseid) {\n var base = $(document.getElementById(baseid));\n\n if (base.length) {\n return new ManageDocsActions(base);\n\n } else {\n throw new Error(\"managedocsactions: Invalid base element identifier\");\n }\n }\n };\n});\n"],"names":["define","$","Log","Config","Str","ModalFactory","ModalEvents","ACTION","ManageDocsActions","base","initEvents","prototype","this","on","e","stopPropagation","promise","strings","link","currentTarget","is","get_strings","key","component","param","name","closest","attr","revision","error","preventDefault","then","strs","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","save","window","location","href","sesskey","hidden","destroy","show","catch","init","baseid","document","getElementById","length","Error"],"mappings":";;;;;;;AAsBAA,uCAAO,CACH,SACA,WACA,cACA,WACA,qBACA,sBACD,SAASC,EAAGC,IAAKC,OAAQC,IAAKC,aAAcC,iBAUvCC,aACO,gBADPA,oBAEc,8BAFdA,kBAGY,6BAHZA,cAIQ,kCAOHC,kBAAkBC,WAClBA,KAAOA,UAEPC,oBAMTF,kBAAkBG,UAAUD,WAAa,WAC1BE,KAENH,KAAKI,GAAG,QAASN,cAAc,SAASO,GACzCA,EAAEC,sBAGEC,QACAC,QAFAC,KAAOjB,EAAEa,EAAEK,kBAIXD,KAAKE,GAAGb,qBACRS,QAAUZ,IAAIiB,YAAY,CACtB,CAACC,IAAK,aAAcC,UAAW,eAC/B,CAACD,IAAK,kBAAmBC,UAAW,cAAeC,MAAO,CACtDC,KAAMP,KAAKQ,QAAQ,sBAAsBC,KAAK,oBAC9CC,SAAUV,KAAKQ,QAAQ,0BAA0BC,KAAK,0BAE1D,CAACL,IAAK,qBAAsBC,UAAW,sBAGxC,GAAIL,KAAKE,GAAGb,mBACfS,QAAUZ,IAAIiB,YAAY,CACtB,CAACC,IAAK,eAAgBC,UAAW,eACjC,CAACD,IAAK,sBAAuBC,UAAW,cAAeC,MAAO,CAC1DC,KAAMP,KAAKQ,QAAQ,sBAAsBC,KAAK,oBAC9CC,SAAUV,KAAKQ,QAAQ,0BAA0BC,KAAK,0BAE1D,CAACL,IAAK,yBAA0BC,UAAW,qBAG5C,CAAA,IAAIL,KAAKE,GAAGb,2BAWfL,IAAI2B,MAAM,+BAAgC,iCAV1Cb,QAAUZ,IAAIiB,YAAY,CACtB,CAACC,IAAK,WAAYC,UAAW,eAC7B,CAACD,IAAK,gBAAiBC,UAAW,cAAeC,MAAO,CACpDC,KAAMP,KAAKQ,QAAQ,sBAAsBC,KAAK,oBAC9CC,SAAUV,KAAKQ,QAAQ,0BAA0BC,KAAK,0BAE1D,CAACL,IAAK,SAAUC,UAAW,UAQnCT,EAAEgB,iBAEFd,QAAQe,MAAK,SAASC,aAClBf,QAAUe,KACH3B,aAAa4B,OAAO,CACvBC,MAAOjB,QAAQ,GACfkB,KAAMlB,QAAQ,GACdmB,KAAM/B,aAAagC,MAAMC,iBAG9BP,MAAK,SAASQ,cACbA,MAAMC,kBAAkBvB,QAAQ,IAChCsB,MAAME,UAAU5B,GAAGP,YAAYoC,MAAM,WACjCC,OAAOC,SAASC,KAAO3B,KAAKS,KAAK,QAAU,YAAcxB,OAAO2C,QAAU,gBAG9EP,MAAME,UAAU5B,GAAGP,YAAYyC,QAAQ,WACnCR,MAAMS,aAGVT,MAAMU,QACC,KAERC,OAAM,SAASpC,UACdZ,IAAI2B,MAAMf,IACH,SAKZ,CAOHqC,KAAM,SAASC,YACP3C,KAAOR,EAAEoD,SAASC,eAAeF,YAEjC3C,KAAK8C,cACE,IAAI/C,kBAAkBC,YAGvB,IAAI+C,MAAM"} \ No newline at end of file diff --git a/admin/tool/policy/amd/build/policyactions.min.js b/admin/tool/policy/amd/build/policyactions.min.js index 80d26882b60..ec338571b8e 100644 --- a/admin/tool/policy/amd/build/policyactions.min.js +++ b/admin/tool/policy/amd/build/policyactions.min.js @@ -1,2 +1,10 @@ -define ("tool_policy/policyactions",["jquery","core/ajax","core/notification","core/modal_factory","core/modal_events"],function(a,b,c,d,e){var f=function(a){this.registerEvents(a)};f.prototype.registerEvents=function(f){f.on("click",function(f){f.preventDefault();var g=a(this).data("versionid"),h=a(this).data("behalfid"),i=a.Deferred(),j=a.Deferred(),k=d.create({title:i,body:j,large:!0}).then(function(a){a.getRoot().on(e.hidden,function(){a.destroy()});return a}).then(function(a){a.show();return a}).catch(c.exception),l=b.call([{methodname:"tool_policy_get_policy_version",args:{versionid:g,behalfid:h}}]);a.when(l[0]).then(function(a){if(a.result.policy){i.resolve(a.result.policy.name);j.resolve(a.result.policy.content);return a}else{throw new Error(a.warnings[0].message)}}).catch(function(a){k.then(function(a){a.hide();a.destroy();return a}).catch(c.exception);return c.addNotification({message:a,type:"error"})})})};return{init:function init(b){b=a(b);return new f(b)}}}); -//# sourceMappingURL=policyactions.min.js.map +/** + * Policy actions. + * + * @module tool_policy/policyactions + * @copyright 2018 Sara Arjona (sara@moodle.com) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_policy/policyactions",["jquery","core/ajax","core/notification","core/modal_factory","core/modal_events"],(function($,Ajax,Notification,ModalFactory,ModalEvents){var PolicyActions=function(root){this.registerEvents(root)};return PolicyActions.prototype.registerEvents=function(root){root.on("click",(function(e){e.preventDefault();var request={methodname:"tool_policy_get_policy_version",args:{versionid:$(this).data("versionid"),behalfid:$(this).data("behalfid")}},modalTitle=$.Deferred(),modalBody=$.Deferred(),modal=ModalFactory.create({title:modalTitle,body:modalBody,large:!0}).then((function(modal){return modal.getRoot().on(ModalEvents.hidden,(function(){modal.destroy()})),modal})).then((function(modal){return modal.show(),modal})).catch(Notification.exception),promises=Ajax.call([request]);$.when(promises[0]).then((function(data){if(data.result.policy)return modalTitle.resolve(data.result.policy.name),modalBody.resolve(data.result.policy.content),data;throw new Error(data.warnings[0].message)})).catch((function(message){return modal.then((function(modal){return modal.hide(),modal.destroy(),modal})).catch(Notification.exception),Notification.addNotification({message:message,type:"error"})}))}))},{init:function(root){return root=$(root),new PolicyActions(root)}}})); + +//# sourceMappingURL=policyactions.min.js.map \ No newline at end of file diff --git a/admin/tool/policy/amd/build/policyactions.min.js.map b/admin/tool/policy/amd/build/policyactions.min.js.map index 6cfd15e5e92..fb97f1b84ae 100644 --- a/admin/tool/policy/amd/build/policyactions.min.js.map +++ b/admin/tool/policy/amd/build/policyactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/policyactions.js"],"names":["define","$","Ajax","Notification","ModalFactory","ModalEvents","PolicyActions","root","registerEvents","prototype","on","e","preventDefault","versionid","data","behalfid","modalTitle","Deferred","modalBody","modal","create","title","body","large","then","getRoot","hidden","destroy","show","catch","exception","promises","call","methodname","args","when","result","policy","resolve","name","content","Error","warnings","message","hide","addNotification","type"],"mappings":"AAsBAA,OAAM,6BAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,oBAJG,CAKH,mBALG,CAAD,CAMN,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAA8CC,CAA9C,CAA2D,CAOvD,GAAIC,CAAAA,CAAa,CAAG,SAASC,CAAT,CAAe,CAC/B,KAAKC,cAAL,CAAoBD,CAApB,CACH,CAFD,CASAD,CAAa,CAACG,SAAd,CAAwBD,cAAxB,CAAyC,SAASD,CAAT,CAAe,CACpDA,CAAI,CAACG,EAAL,CAAQ,OAAR,CAAiB,SAASC,CAAT,CAAY,CACzBA,CAAC,CAACC,cAAF,GADyB,GAGrBC,CAAAA,CAAS,CAAGZ,CAAC,CAAC,IAAD,CAAD,CAAQa,IAAR,CAAa,WAAb,CAHS,CAIrBC,CAAQ,CAAGd,CAAC,CAAC,IAAD,CAAD,CAAQa,IAAR,CAAa,UAAb,CAJU,CAgBrBE,CAAU,CAAGf,CAAC,CAACgB,QAAF,EAhBQ,CAiBrBC,CAAS,CAAGjB,CAAC,CAACgB,QAAF,EAjBS,CAmBrBE,CAAK,CAAGf,CAAY,CAACgB,MAAb,CAAoB,CAC5BC,KAAK,CAAEL,CADqB,CAE5BM,IAAI,CAAEJ,CAFsB,CAG5BK,KAAK,GAHuB,CAApB,EAKXC,IALW,CAKN,SAASL,CAAT,CAAgB,CAElBA,CAAK,CAACM,OAAN,GAAgBf,EAAhB,CAAmBL,CAAW,CAACqB,MAA/B,CAAuC,UAAW,CAE9CP,CAAK,CAACQ,OAAN,EACH,CAHD,EAKA,MAAOR,CAAAA,CACV,CAbW,EAcXK,IAdW,CAcN,SAASL,CAAT,CAAgB,CAClBA,CAAK,CAACS,IAAN,GAEA,MAAOT,CAAAA,CACV,CAlBW,EAmBXU,KAnBW,CAmBL1B,CAAY,CAAC2B,SAnBR,CAnBa,CAyCrBC,CAAQ,CAAG7B,CAAI,CAAC8B,IAAL,CAAU,CA9BX,CACVC,UAAU,CAAE,gCADF,CAEVC,IAAI,CAPK,CACT,UAAarB,CADJ,CAET,SAAYE,CAFH,CAKC,CA8BW,CAAV,CAzCU,CA0CzBd,CAAC,CAACkC,IAAF,CAAOJ,CAAQ,CAAC,CAAD,CAAf,EAAoBP,IAApB,CAAyB,SAASV,CAAT,CAAe,CACpC,GAAIA,CAAI,CAACsB,MAAL,CAAYC,MAAhB,CAAwB,CACpBrB,CAAU,CAACsB,OAAX,CAAmBxB,CAAI,CAACsB,MAAL,CAAYC,MAAZ,CAAmBE,IAAtC,EACArB,CAAS,CAACoB,OAAV,CAAkBxB,CAAI,CAACsB,MAAL,CAAYC,MAAZ,CAAmBG,OAArC,EAEA,MAAO1B,CAAAA,CACV,CALD,IAKO,CACH,KAAM,IAAI2B,CAAAA,KAAJ,CAAU3B,CAAI,CAAC4B,QAAL,CAAc,CAAd,EAAiBC,OAA3B,CACT,CACJ,CATD,EASGd,KATH,CASS,SAASc,CAAT,CAAkB,CACvBxB,CAAK,CAACK,IAAN,CAAW,SAASL,CAAT,CAAgB,CACvBA,CAAK,CAACyB,IAAN,GACAzB,CAAK,CAACQ,OAAN,GAEA,MAAOR,CAAAA,CACV,CALD,EAMCU,KAND,CAMO1B,CAAY,CAAC2B,SANpB,EAQA,MAAO3B,CAAAA,CAAY,CAAC0C,eAAb,CAA6B,CAChCF,OAAO,CAAEA,CADuB,CAEhCG,IAAI,CAAE,OAF0B,CAA7B,CAIV,CAtBD,CAuBH,CAjED,CAmEH,CApED,CAsEA,MAAsD,CAUlD,KAAQ,cAASvC,CAAT,CAAe,CACnBA,CAAI,CAAGN,CAAC,CAACM,CAAD,CAAR,CACA,MAAO,IAAID,CAAAA,CAAJ,CAAkBC,CAAlB,CACV,CAbiD,CAezD,CA3GK,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 * Policy actions.\n *\n * @module tool_policy/policyactions\n * @copyright 2018 Sara Arjona (sara@moodle.com)\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, ModalFactory, ModalEvents) {\n\n /**\n * PolicyActions class.\n *\n * @param {jQuery} root\n */\n var PolicyActions = function(root) {\n this.registerEvents(root);\n };\n\n /**\n * Register event listeners.\n *\n * @param {jQuery} root\n */\n PolicyActions.prototype.registerEvents = function(root) {\n root.on(\"click\", function(e) {\n e.preventDefault();\n\n var versionid = $(this).data('versionid');\n var behalfid = $(this).data('behalfid');\n\n var params = {\n 'versionid': versionid,\n 'behalfid': behalfid\n };\n\n var request = {\n methodname: 'tool_policy_get_policy_version',\n args: params\n };\n\n var modalTitle = $.Deferred();\n var modalBody = $.Deferred();\n\n var modal = ModalFactory.create({\n title: modalTitle,\n body: modalBody,\n large: true\n })\n .then(function(modal) {\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n })\n .then(function(modal) {\n modal.show();\n\n return modal;\n })\n .catch(Notification.exception);\n\n // Make the request now that the modal is configured.\n var promises = Ajax.call([request]);\n $.when(promises[0]).then(function(data) {\n if (data.result.policy) {\n modalTitle.resolve(data.result.policy.name);\n modalBody.resolve(data.result.policy.content);\n\n return data;\n } else {\n throw new Error(data.warnings[0].message);\n }\n }).catch(function(message) {\n modal.then(function(modal) {\n modal.hide();\n modal.destroy();\n\n return modal;\n })\n .catch(Notification.exception);\n\n return Notification.addNotification({\n message: message,\n type: 'error'\n });\n });\n });\n\n };\n\n return /** @alias module:tool_policy/policyactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the actions helper.\n *\n * @method init\n * @param {object} root\n * @return {PolicyActions}\n */\n 'init': function(root) {\n root = $(root);\n return new PolicyActions(root);\n }\n };\n});\n"],"file":"policyactions.min.js"} \ No newline at end of file +{"version":3,"file":"policyactions.min.js","sources":["../src/policyactions.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 * Policy actions.\n *\n * @module tool_policy/policyactions\n * @copyright 2018 Sara Arjona (sara@moodle.com)\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, ModalFactory, ModalEvents) {\n\n /**\n * PolicyActions class.\n *\n * @param {jQuery} root\n */\n var PolicyActions = function(root) {\n this.registerEvents(root);\n };\n\n /**\n * Register event listeners.\n *\n * @param {jQuery} root\n */\n PolicyActions.prototype.registerEvents = function(root) {\n root.on(\"click\", function(e) {\n e.preventDefault();\n\n var versionid = $(this).data('versionid');\n var behalfid = $(this).data('behalfid');\n\n var params = {\n 'versionid': versionid,\n 'behalfid': behalfid\n };\n\n var request = {\n methodname: 'tool_policy_get_policy_version',\n args: params\n };\n\n var modalTitle = $.Deferred();\n var modalBody = $.Deferred();\n\n var modal = ModalFactory.create({\n title: modalTitle,\n body: modalBody,\n large: true\n })\n .then(function(modal) {\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n })\n .then(function(modal) {\n modal.show();\n\n return modal;\n })\n .catch(Notification.exception);\n\n // Make the request now that the modal is configured.\n var promises = Ajax.call([request]);\n $.when(promises[0]).then(function(data) {\n if (data.result.policy) {\n modalTitle.resolve(data.result.policy.name);\n modalBody.resolve(data.result.policy.content);\n\n return data;\n } else {\n throw new Error(data.warnings[0].message);\n }\n }).catch(function(message) {\n modal.then(function(modal) {\n modal.hide();\n modal.destroy();\n\n return modal;\n })\n .catch(Notification.exception);\n\n return Notification.addNotification({\n message: message,\n type: 'error'\n });\n });\n });\n\n };\n\n return /** @alias module:tool_policy/policyactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the actions helper.\n *\n * @method init\n * @param {object} root\n * @return {PolicyActions}\n */\n 'init': function(root) {\n root = $(root);\n return new PolicyActions(root);\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","ModalFactory","ModalEvents","PolicyActions","root","registerEvents","prototype","on","e","preventDefault","request","methodname","args","this","data","modalTitle","Deferred","modalBody","modal","create","title","body","large","then","getRoot","hidden","destroy","show","catch","exception","promises","call","when","result","policy","resolve","name","content","Error","warnings","message","hide","addNotification","type"],"mappings":";;;;;;;AAsBAA,mCAAO,CACH,SACA,YACA,oBACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,aAAcC,iBAOtCC,cAAgB,SAASC,WACpBC,eAAeD,cAQxBD,cAAcG,UAAUD,eAAiB,SAASD,MAC9CA,KAAKG,GAAG,SAAS,SAASC,GACtBA,EAAEC,qBAUEC,QAAU,CACVC,WAAY,iCACZC,KAPS,WAHGd,EAAEe,MAAMC,KAAK,sBACdhB,EAAEe,MAAMC,KAAK,cAYxBC,WAAajB,EAAEkB,WACfC,UAAYnB,EAAEkB,WAEdE,MAAQjB,aAAakB,OAAO,CAC5BC,MAAOL,WACPM,KAAMJ,UACNK,OAAO,IAEVC,MAAK,SAASL,cAEXA,MAAMM,UAAUjB,GAAGL,YAAYuB,QAAQ,WAEnCP,MAAMQ,aAGHR,SAEVK,MAAK,SAASL,cACXA,MAAMS,OAECT,SAEVU,MAAM5B,aAAa6B,WAGhBC,SAAW/B,KAAKgC,KAAK,CAACrB,UAC1BZ,EAAEkC,KAAKF,SAAS,IAAIP,MAAK,SAAST,SAC1BA,KAAKmB,OAAOC,cACZnB,WAAWoB,QAAQrB,KAAKmB,OAAOC,OAAOE,MACtCnB,UAAUkB,QAAQrB,KAAKmB,OAAOC,OAAOG,SAE9BvB,WAED,IAAIwB,MAAMxB,KAAKyB,SAAS,GAAGC,YAEtCZ,OAAM,SAASY,gBACdtB,MAAMK,MAAK,SAASL,cAChBA,MAAMuB,OACNvB,MAAMQ,UAECR,SAEVU,MAAM5B,aAAa6B,WAEb7B,aAAa0C,gBAAgB,CAChCF,QAASA,QACTG,KAAM,iBAOgC,MAU1C,SAASvC,aACbA,KAAON,EAAEM,MACF,IAAID,cAAcC"} \ No newline at end of file diff --git a/admin/tool/templatelibrary/amd/build/display.min.js b/admin/tool/templatelibrary/amd/build/display.min.js index 9ac8f6ba001..a256e671bc9 100644 --- a/admin/tool/templatelibrary/amd/build/display.min.js +++ b/admin/tool/templatelibrary/amd/build/display.min.js @@ -1,2 +1,10 @@ -define ("tool_templatelibrary/display",["jquery","core/ajax","core/log","core/notification","core/templates","core/config","core/str"],function(a,b,c,d,e,f,g){var h=function(a,b){if(!a){return!1}var c="@template "+b,d=0,e=[];e=a.match(/{{!([\s\S]*?)}}/g);if(null!==e){for(d=0;d + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_templatelibrary/display",["jquery","core/ajax","core/log","core/notification","core/templates","core/config","core/str"],(function($,ajax,log,notification,templates,config,str){var findDocsSection=function(templateSource,templateName){if(!templateSource)return!1;var sections,marker="@template "+templateName,i=0;if(null!==(sections=templateSource.match(/{{!([\s\S]*?)}}/g)))for(i=0;i.\n\n/**\n * This module adds ajax display functions to the template library page.\n *\n * @module tool_templatelibrary/display\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates', 'core/config', 'core/str'],\n function($, ajax, log, notification, templates, config, str) {\n\n /**\n * Search through a template for a template docs comment.\n *\n * @param {String} templateSource The raw template\n * @param {String} templateName The name of the template used to search for docs tag\n * @return {String|boolean} the correct comment or false\n */\n var findDocsSection = function(templateSource, templateName) {\n\n if (!templateSource) {\n return false;\n }\n // Find the comment section marked with @template component/template.\n var marker = \"@template \" + templateName,\n i = 0,\n sections = [];\n\n sections = templateSource.match(/{{!([\\s\\S]*?)}}/g);\n\n // If no sections match - show the entire file.\n if (sections !== null) {\n for (i = 0; i < sections.length; i++) {\n var section = sections[i];\n var start = section.indexOf(marker);\n if (start !== -1) {\n // Remove {{! and }} from start and end.\n var offset = start + marker.length + 1;\n section = section.substr(offset, section.length - 2 - offset);\n return section;\n }\n }\n }\n // No matching comment.\n return false;\n };\n\n /**\n * Handle a template loaded response.\n *\n * @param {String} templateName The template name\n * @param {String} source The template source\n * @param {String} originalSource The original template source (not theme overridden)\n */\n var templateLoaded = function(templateName, source, originalSource) {\n str.get_string('templateselected', 'tool_templatelibrary', templateName).done(function(s) {\n $('[data-region=\"displaytemplateheader\"]').text(s);\n }).fail(notification.exception);\n\n // Find the comment section marked with @template component/template.\n var docs = findDocsSection(source, templateName);\n\n if (docs === false) {\n // Docs was not in theme template, try original.\n docs = findDocsSection(originalSource, templateName);\n }\n\n // If we found a docs section, limit the template library to showing this section.\n if (docs) {\n source = docs;\n }\n\n $('[data-region=\"displaytemplatesource\"]').text(source);\n\n // Now search the text for a json example.\n\n var example = source.match(/Example context \\(json\\):([\\s\\S]*)/);\n var context = false;\n if (example) {\n var rawJSON = example[1].trim();\n try {\n context = $.parseJSON(rawJSON);\n } catch (e) {\n log.debug('Could not parse json example context for template.');\n log.debug(e);\n }\n }\n if (context) {\n templates.render(templateName, context).done(function(html, js) {\n templates.replaceNodeContents($('[data-region=\"displaytemplateexample\"]'), html, js);\n }).fail(notification.exception);\n } else {\n str.get_string('templatehasnoexample', 'tool_templatelibrary').done(function(s) {\n $('[data-region=\"displaytemplateexample\"]').text(s);\n }).fail(notification.exception);\n }\n };\n\n /**\n * Load the a template source from Moodle.\n *\n * @param {String} templateName\n */\n var loadTemplate = function(templateName) {\n var parts = templateName.split('/');\n var component = parts.shift();\n var name = parts.join('/');\n\n var promises = ajax.call([{\n methodname: 'core_output_load_template',\n args: {\n component: component,\n template: name,\n themename: config.theme,\n includecomments: true\n }\n }, {\n methodname: 'tool_templatelibrary_load_canonical_template',\n args: {\n component: component,\n template: name\n }\n }], true, false);\n\n // When returns a new promise that is resolved when all the passed in promises are resolved.\n // The arguments to the done become the values of each resolved promise.\n $.when.apply($, promises)\n .done(function(source, originalSource) {\n templateLoaded(templateName, source, originalSource);\n })\n .fail(notification.exception);\n };\n\n // Add the event listeners.\n $('[data-region=\"list-templates\"]').on('click', '[data-templatename]', function(e) {\n var templatename = $(this).data('templatename');\n e.preventDefault();\n loadTemplate(templatename);\n });\n\n // This module does not expose anything.\n return {};\n});\n"],"file":"display.min.js"} \ No newline at end of file +{"version":3,"file":"display.min.js","sources":["../src/display.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 * This module adds ajax display functions to the template library page.\n *\n * @module tool_templatelibrary/display\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates', 'core/config', 'core/str'],\n function($, ajax, log, notification, templates, config, str) {\n\n /**\n * Search through a template for a template docs comment.\n *\n * @param {String} templateSource The raw template\n * @param {String} templateName The name of the template used to search for docs tag\n * @return {String|boolean} the correct comment or false\n */\n var findDocsSection = function(templateSource, templateName) {\n\n if (!templateSource) {\n return false;\n }\n // Find the comment section marked with @template component/template.\n var marker = \"@template \" + templateName,\n i = 0,\n sections = [];\n\n sections = templateSource.match(/{{!([\\s\\S]*?)}}/g);\n\n // If no sections match - show the entire file.\n if (sections !== null) {\n for (i = 0; i < sections.length; i++) {\n var section = sections[i];\n var start = section.indexOf(marker);\n if (start !== -1) {\n // Remove {{! and }} from start and end.\n var offset = start + marker.length + 1;\n section = section.substr(offset, section.length - 2 - offset);\n return section;\n }\n }\n }\n // No matching comment.\n return false;\n };\n\n /**\n * Handle a template loaded response.\n *\n * @param {String} templateName The template name\n * @param {String} source The template source\n * @param {String} originalSource The original template source (not theme overridden)\n */\n var templateLoaded = function(templateName, source, originalSource) {\n str.get_string('templateselected', 'tool_templatelibrary', templateName).done(function(s) {\n $('[data-region=\"displaytemplateheader\"]').text(s);\n }).fail(notification.exception);\n\n // Find the comment section marked with @template component/template.\n var docs = findDocsSection(source, templateName);\n\n if (docs === false) {\n // Docs was not in theme template, try original.\n docs = findDocsSection(originalSource, templateName);\n }\n\n // If we found a docs section, limit the template library to showing this section.\n if (docs) {\n source = docs;\n }\n\n $('[data-region=\"displaytemplatesource\"]').text(source);\n\n // Now search the text for a json example.\n\n var example = source.match(/Example context \\(json\\):([\\s\\S]*)/);\n var context = false;\n if (example) {\n var rawJSON = example[1].trim();\n try {\n context = $.parseJSON(rawJSON);\n } catch (e) {\n log.debug('Could not parse json example context for template.');\n log.debug(e);\n }\n }\n if (context) {\n templates.render(templateName, context).done(function(html, js) {\n templates.replaceNodeContents($('[data-region=\"displaytemplateexample\"]'), html, js);\n }).fail(notification.exception);\n } else {\n str.get_string('templatehasnoexample', 'tool_templatelibrary').done(function(s) {\n $('[data-region=\"displaytemplateexample\"]').text(s);\n }).fail(notification.exception);\n }\n };\n\n /**\n * Load the a template source from Moodle.\n *\n * @param {String} templateName\n */\n var loadTemplate = function(templateName) {\n var parts = templateName.split('/');\n var component = parts.shift();\n var name = parts.join('/');\n\n var promises = ajax.call([{\n methodname: 'core_output_load_template',\n args: {\n component: component,\n template: name,\n themename: config.theme,\n includecomments: true\n }\n }, {\n methodname: 'tool_templatelibrary_load_canonical_template',\n args: {\n component: component,\n template: name\n }\n }], true, false);\n\n // When returns a new promise that is resolved when all the passed in promises are resolved.\n // The arguments to the done become the values of each resolved promise.\n $.when.apply($, promises)\n .done(function(source, originalSource) {\n templateLoaded(templateName, source, originalSource);\n })\n .fail(notification.exception);\n };\n\n // Add the event listeners.\n $('[data-region=\"list-templates\"]').on('click', '[data-templatename]', function(e) {\n var templatename = $(this).data('templatename');\n e.preventDefault();\n loadTemplate(templatename);\n });\n\n // This module does not expose anything.\n return {};\n});\n"],"names":["define","$","ajax","log","notification","templates","config","str","findDocsSection","templateSource","templateName","sections","marker","i","match","length","section","start","indexOf","offset","substr","loadTemplate","parts","split","component","shift","name","join","promises","call","methodname","args","template","themename","theme","includecomments","when","apply","done","source","originalSource","get_string","s","text","fail","exception","docs","example","context","rawJSON","trim","parseJSON","e","debug","render","html","js","replaceNodeContents","templateLoaded","on","templatename","this","data","preventDefault"],"mappings":";;;;;;;AAsBAA,sCAAO,CAAC,SAAU,YAAa,WAAY,oBAAqB,iBAAkB,cAAe,aAC1F,SAASC,EAAGC,KAAMC,IAAKC,aAAcC,UAAWC,OAAQC,SASvDC,gBAAkB,SAASC,eAAgBC,kBAEtCD,sBACM,MAKPE,SAFAC,OAAS,aAAeF,aACxBG,EAAI,KAMS,QAHjBF,SAAWF,eAAeK,MAAM,yBAIvBD,EAAI,EAAGA,E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EzC,EAAE,0CAA0C0C,KAAKD,MAClDE,KAAKxC,aAAayC,WAkCnBa,CAAehD,aAAc6B,OAAQC,mBAEtCI,KAAKxC,aAAayC,mBAI3B5C,EAAE,kCAAkC0D,GAAG,QAAS,uBAAuB,SAASP,OACxEQ,aAAe3D,EAAE4D,MAAMC,KAAK,gBAChCV,EAAEW,iBACF1C,aAAauC,iBAIV"} \ No newline at end of file diff --git a/admin/tool/templatelibrary/amd/build/search.min.js b/admin/tool/templatelibrary/amd/build/search.min.js index 9645fa6341e..74919611155 100644 --- a/admin/tool/templatelibrary/amd/build/search.min.js +++ b/admin/tool/templatelibrary/amd/build/search.min.js @@ -1,2 +1,10 @@ -define ("tool_templatelibrary/search",["jquery","core/ajax","core/log","core/notification","core/templates","core/config"],function(a,b,c,d,e,f){var g=function(b){e.render("tool_templatelibrary/search_results",{templates:b}).done(function(b,c){e.replaceNode(a("[data-region=\"searchresults\"]"),b,c)}).fail(d.exception)},h=function(c){var e=a("[data-field=\"component\"]").val(),f=a("[data-region=\"list-templates\"] [data-region=\"input\"]").val();if(""!==f){a("[data-region=\"list-templates\"] [data-action=\"clearsearch\"]").removeClass("d-none")}else{a("[data-region=\"list-templates\"] [data-action=\"clearsearch\"]").addClass("d-none")}b.call([{methodname:"tool_templatelibrary_list_templates",args:{component:e,search:f,themename:c},done:g,fail:d.exception}],!0,!1)},i=null,j=function(a,b){if(null!==i){window.clearTimeout(i)}i=window.setTimeout(function(){a();i=null},b)},k=function(){j(h.bind(this,f.theme),400)};a("[data-region=\"list-templates\"]").on("change","[data-field=\"component\"]",k);a("[data-region=\"list-templates\"]").on("input","[data-region=\"input\"]",k);a("[data-action=\"clearsearch\"]").on("click",function(){a("[data-region=\"input\"]").val("");h(f.theme);a(this).addClass("d-none")});h(f.theme);return{}}); -//# sourceMappingURL=search.min.js.map +/** + * This module adds ajax search functions to the template library page. + * + * @module tool_templatelibrary/search + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("tool_templatelibrary/search",["jquery","core/ajax","core/log","core/notification","core/templates","core/config"],(function($,ajax,log,notification,templates,config){var reloadListTemplate=function(templateList){templates.render("tool_templatelibrary/search_results",{templates:templateList}).done((function(result,js){templates.replaceNode($('[data-region="searchresults"]'),result,js)})).fail(notification.exception)},refreshSearch=function(themename){var componentStr=$('[data-field="component"]').val(),searchStr=$('[data-region="list-templates"] [data-region="input"]').val();""!==searchStr?$('[data-region="list-templates"] [data-action="clearsearch"]').removeClass("d-none"):$('[data-region="list-templates"] [data-action="clearsearch"]').addClass("d-none"),ajax.call([{methodname:"tool_templatelibrary_list_templates",args:{component:componentStr,search:searchStr,themename:themename},done:reloadListTemplate,fail:notification.exception}],!0,!1)},throttle=null,changeHandler=function(){var callback,delay;callback=refreshSearch.bind(this,config.theme),delay=400,null!==throttle&&window.clearTimeout(throttle),throttle=window.setTimeout((function(){callback(),throttle=null}),delay)};return $('[data-region="list-templates"]').on("change",'[data-field="component"]',changeHandler),$('[data-region="list-templates"]').on("input",'[data-region="input"]',changeHandler),$('[data-action="clearsearch"]').on("click",(function(){$('[data-region="input"]').val(""),refreshSearch(config.theme),$(this).addClass("d-none")})),refreshSearch(config.theme),{}})); + +//# sourceMappingURL=search.min.js.map \ No newline at end of file diff --git a/admin/tool/templatelibrary/amd/build/search.min.js.map b/admin/tool/templatelibrary/amd/build/search.min.js.map index 7d606eaf503..51ef5370a44 100644 --- a/admin/tool/templatelibrary/amd/build/search.min.js.map +++ b/admin/tool/templatelibrary/amd/build/search.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/search.js"],"names":["define","$","ajax","log","notification","templates","config","reloadListTemplate","templateList","render","done","result","js","replaceNode","fail","exception","refreshSearch","themename","componentStr","val","searchStr","removeClass","addClass","call","methodname","args","component","search","throttle","queueRefresh","callback","delay","window","clearTimeout","setTimeout","changeHandler","bind","theme","on"],"mappings":"AAsBAA,OAAM,+BAAC,CAAC,QAAD,CAAW,WAAX,CAAw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CACzC,GAAiB,IAAb,GAAAH,CAAJ,CAAuB,CACnBI,MAAM,CAACC,YAAP,CAAoBL,CAApB,CACH,CAEDA,CAAQ,CAAGI,MAAM,CAACE,UAAP,CAAkB,UAAW,CACpCJ,CAAQ,GACRF,CAAQ,CAAG,IACd,CAHU,CAGRG,CAHQ,CAId,CA3D0D,CA6DvDI,CAAa,CAAG,UAAW,CAC3BN,CAAY,CAACb,CAAa,CAACoB,IAAd,CAAmB,IAAnB,CAAyB9B,CAAM,CAAC+B,KAAhC,CAAD,CAAyC,GAAzC,CACf,CA/D0D,CAiE3DpC,CAAC,CAAC,kCAAD,CAAD,CAAoCqC,EAApC,CAAuC,QAAvC,CAAiD,4BAAjD,CAA6EH,CAA7E,EACAlC,CAAC,CAAC,kCAAD,CAAD,CAAoCqC,EAApC,CAAuC,OAAvC,CAAgD,yBAAhD,CAAyEH,CAAzE,EACAlC,CAAC,CAAC,+BAAD,CAAD,CAAiCqC,EAAjC,CAAoC,OAApC,CAA6C,UAAW,CACpDrC,CAAC,CAAC,yBAAD,CAAD,CAA2BkB,GAA3B,CAA+B,EAA/B,EACAH,CAAa,CAACV,CAAM,CAAC+B,KAAR,CAAb,CACApC,CAAC,CAAC,IAAD,CAAD,CAAQqB,QAAR,CAAiB,QAAjB,CACH,CAJD,EAMAN,CAAa,CAACV,CAAM,CAAC+B,KAAR,CAAb,CACA,MAAO,EACV,CA5EK,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 * This module adds ajax search functions to the template library page.\n *\n * @module tool_templatelibrary/search\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates', 'core/config'],\n function($, ajax, log, notification, templates, config) {\n\n /**\n * The ajax call has returned with a new list of templates.\n *\n * @method reloadListTemplate\n * @param {String[]} templateList List of template ids.\n */\n var reloadListTemplate = function(templateList) {\n templates.render('tool_templatelibrary/search_results', {templates: templateList})\n .done(function(result, js) {\n templates.replaceNode($('[data-region=\"searchresults\"]'), result, js);\n }).fail(notification.exception);\n };\n\n /**\n * Get the current values for the form inputs and refresh the list of matching templates.\n *\n * @method refreshSearch\n * @param {String} themename The naeme of the theme.\n */\n var refreshSearch = function(themename) {\n var componentStr = $('[data-field=\"component\"]').val();\n var searchStr = $('[data-region=\"list-templates\"] [data-region=\"input\"]').val();\n\n if (searchStr !== '') {\n $('[data-region=\"list-templates\"] [data-action=\"clearsearch\"]').removeClass('d-none');\n } else {\n $('[data-region=\"list-templates\"] [data-action=\"clearsearch\"]').addClass('d-none');\n }\n\n // Trigger the search.\n ajax.call([\n {methodname: 'tool_templatelibrary_list_templates',\n args: {component: componentStr, search: searchStr, themename: themename},\n done: reloadListTemplate,\n fail: notification.exception}\n ], true, false);\n };\n\n var throttle = null;\n\n /**\n * Call the specified function after a delay. If this function is called again before the function is executed,\n * the function will only be executed once.\n *\n * @method queueRefresh\n * @param {function} callback\n * @param {Number} delay The time in milliseconds to delay.\n */\n var queueRefresh = function(callback, delay) {\n if (throttle !== null) {\n window.clearTimeout(throttle);\n }\n\n throttle = window.setTimeout(function() {\n callback();\n throttle = null;\n }, delay);\n };\n\n var changeHandler = function() {\n queueRefresh(refreshSearch.bind(this, config.theme), 400);\n };\n // Add change handlers to refresh the list.\n $('[data-region=\"list-templates\"]').on('change', '[data-field=\"component\"]', changeHandler);\n $('[data-region=\"list-templates\"]').on('input', '[data-region=\"input\"]', changeHandler);\n $('[data-action=\"clearsearch\"]').on('click', function() {\n $('[data-region=\"input\"]').val('');\n refreshSearch(config.theme);\n $(this).addClass('d-none');\n });\n\n refreshSearch(config.theme);\n return {};\n});\n"],"file":"search.min.js"} \ No newline at end of file +{"version":3,"file":"search.min.js","sources":["../src/search.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 * This module adds ajax search functions to the template library page.\n *\n * @module tool_templatelibrary/search\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates', 'core/config'],\n function($, ajax, log, notification, templates, config) {\n\n /**\n * The ajax call has returned with a new list of templates.\n *\n * @method reloadListTemplate\n * @param {String[]} templateList List of template ids.\n */\n var reloadListTemplate = function(templateList) {\n templates.render('tool_templatelibrary/search_results', {templates: templateList})\n .done(function(result, js) {\n templates.replaceNode($('[data-region=\"searchresults\"]'), result, js);\n }).fail(notification.exception);\n };\n\n /**\n * Get the current values for the form inputs and refresh the list of matching templates.\n *\n * @method refreshSearch\n * @param {String} themename The naeme of the theme.\n */\n var refreshSearch = function(themename) {\n var componentStr = $('[data-field=\"component\"]').val();\n var searchStr = $('[data-region=\"list-templates\"] [data-region=\"input\"]').val();\n\n if (searchStr !== '') {\n $('[data-region=\"list-templates\"] [data-action=\"clearsearch\"]').removeClass('d-none');\n } else {\n $('[data-region=\"list-templates\"] [data-action=\"clearsearch\"]').addClass('d-none');\n }\n\n // Trigger the search.\n ajax.call([\n {methodname: 'tool_templatelibrary_list_templates',\n args: {component: componentStr, search: searchStr, themename: themename},\n done: reloadListTemplate,\n fail: notification.exception}\n ], true, false);\n };\n\n var throttle = null;\n\n /**\n * Call the specified function after a delay. If this function is called again before the function is executed,\n * the function will only be executed once.\n *\n * @method queueRefresh\n * @param {function} callback\n * @param {Number} delay The time in milliseconds to delay.\n */\n var queueRefresh = function(callback, delay) {\n if (throttle !== null) {\n window.clearTimeout(throttle);\n }\n\n throttle = window.setTimeout(function() {\n callback();\n throttle = null;\n }, delay);\n };\n\n var changeHandler = function() {\n queueRefresh(refreshSearch.bind(this, config.theme), 400);\n };\n // Add change handlers to refresh the list.\n $('[data-region=\"list-templates\"]').on('change', '[data-field=\"component\"]', changeHandler);\n $('[data-region=\"list-templates\"]').on('input', '[data-region=\"input\"]', changeHandler);\n $('[data-action=\"clearsearch\"]').on('click', function() {\n $('[data-region=\"input\"]').val('');\n refreshSearch(config.theme);\n $(this).addClass('d-none');\n });\n\n refreshSearch(config.theme);\n return {};\n});\n"],"names":["define","$","ajax","log","notification","templates","config","reloadListTemplate","templateList","render","done","result","js","replaceNode","fail","exception","refreshSearch","themename","componentStr","val","searchStr","removeClass","addClass","call","methodname","args","component","search","throttle","changeHandler","callback","delay","bind","this","theme","window","clearTimeout","setTimeout","on"],"mappings":";;;;;;;AAsBAA,qCAAO,CAAC,SAAU,YAAa,WAAY,oBAAqB,iBAAkB,gBAC3E,SAASC,EAAGC,KAAMC,IAAKC,aAAcC,UAAWC,YAQ/CC,mBAAqB,SAASC,cAC9BH,UAAUI,OAAO,sCAAuC,CAACJ,UAAWG,eAC/DE,MAAK,SAASC,OAAQC,IACnBP,UAAUQ,YAAYZ,EAAE,iCAAkCU,OAAQC,OACnEE,KAAKV,aAAaW,YASzBC,cAAgB,SAASC,eACrBC,aAAejB,EAAE,4BAA4BkB,MAC7CC,UAAYnB,EAAE,wDAAwDkB,MAExD,KAAdC,UACAnB,EAAE,8DAA8DoB,YAAY,UAE5EpB,EAAE,8DAA8DqB,SAAS,UAI7EpB,KAAKqB,KAAK,CACN,CAACC,WAAY,sCACXC,KAAM,CAACC,UAAWR,aAAcS,OAAQP,UAAWH,UAAWA,WAC9DP,KAAMH,mBACNO,KAAMV,aAAaW,aACtB,GAAM,IAGTa,SAAW,KAqBXC,cAAgB,WAXD,IAASC,SAAUC,MAAVD,SAYXd,cAAcgB,KAAKC,KAAM3B,OAAO4B,OAZXH,MAYmB,IAXpC,OAAbH,UACAO,OAAOC,aAAaR,UAGxBA,SAAWO,OAAOE,YAAW,WACzBP,WACAF,SAAW,OACZG,eAOP9B,EAAE,kCAAkCqC,GAAG,SAAU,2BAA4BT,eAC7E5B,EAAE,kCAAkCqC,GAAG,QAAS,wBAAyBT,eACzE5B,EAAE,+BAA+BqC,GAAG,SAAS,WACzCrC,EAAE,yBAAyBkB,IAAI,IAC/BH,cAAcV,OAAO4B,OACrBjC,EAAEgC,MAAMX,SAAS,aAGrBN,cAAcV,OAAO4B,OACd"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/events.min.js b/admin/tool/usertours/amd/build/events.min.js index c11e5f9b53f..9ca58ad87c0 100644 --- a/admin/tool/usertours/amd/build/events.min.js +++ b/admin/tool/usertours/amd/build/events.min.js @@ -1,2 +1,3 @@ -define ("tool_usertours/events",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.eventTypes=void 0;a.eventTypes={stepRender:"tool_usertours/stepRender",stepRendered:"tool_usertours/stepRendered",tourStart:"tool_usertours/tourStart",tourStarted:"tool_usertours/tourStarted",tourEnd:"tool_usertours/tourEnd",tourEnded:"tool_usertours/tourEnded",stepHide:"tool_usertours/stepHide",stepHidden:"tool_usertours/stepHidden"}}); -//# sourceMappingURL=events.min.js.map +define("tool_usertours/events",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.eventTypes=void 0;_exports.eventTypes={stepRender:"tool_usertours/stepRender",stepRendered:"tool_usertours/stepRendered",tourStart:"tool_usertours/tourStart",tourStarted:"tool_usertours/tourStarted",tourEnd:"tool_usertours/tourEnd",tourEnded:"tool_usertours/tourEnded",stepHide:"tool_usertours/stepHide",stepHidden:"tool_usertours/stepHidden"}})); + +//# sourceMappingURL=events.min.js.map \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/events.min.js.map b/admin/tool/usertours/amd/build/events.min.js.map index aa04927359e..33b8481c3fb 100644 --- a/admin/tool/usertours/amd/build/events.min.js.map +++ b/admin/tool/usertours/amd/build/events.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/events.js"],"names":["stepRender","stepRendered","tourStart","tourStarted","tourEnd","tourEnded","stepHide","stepHidden"],"mappings":"uJA6C0B,CAYtBA,UAAU,CAAE,2BAZU,CAuBtBC,YAAY,CAAE,6BAvBQ,CAoCtBC,SAAS,CAAE,0BApCW,CA8CtBC,WAAW,CAAE,4BA9CS,CA0DtBC,OAAO,CAAE,wBA1Da,CAoEtBC,SAAS,CAAE,0BApEW,CAgFtBC,QAAQ,CAAE,yBAhFY,CA0FtBC,UAAU,CAAE,2BA1FU,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 .\n\n/**\n * Javascript events for the `tool_usertours` subsystem.\n *\n * @module tool_usertours/events\n * @copyright 2021 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n *\n * @example Example of listening to a step rendering event and cancelling it.\n * import {eventTypes as userTourEvents} from 'tool_usertours/events';\n *\n * document.addEventListener(userTourEvents.stepRender, e => {\n * console.log(e.detail.tour); // The Tour instance\n * e.preventDefault();\n * });\n */\n\n/**\n * Events for the component.\n *\n * @constant\n * @property {object} eventTypes\n * @property {String} eventTypes.stepRender See {@link event:tool_usertours/stepRender}\n * @property {String} eventTypes.stepRendered See {@link event:tool_usertours/stepRendered}\n * @property {String} eventTypes.tourStart See {@link event:tool_usertours/tourStart}\n * @property {String} eventTypes.tourStarted See {@link event:tool_usertours/tourStarted}\n * @property {String} eventTypes.tourEnd See {@link event:tool_usertours/tourEnd}\n * @property {String} eventTypes.tourEnded See {@link event:tool_usertours/tourEnded}\n * @property {String} eventTypes.stepHide See {@link event:tool_usertours/stepHide}\n * @property {String} eventTypes.stepHidden See {@link event:tool_usertours/stepHidden}\n */\nexport const eventTypes = {\n /**\n * An event triggered before a user tour step is rendered.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/stepRender\n * @type {CustomEvent}\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @property {object} detail.stepConfig\n */\n stepRender: 'tool_usertours/stepRender',\n\n /**\n * An event triggered after a user tour step has been rendered.\n *\n * @event tool_usertours/stepRendered\n * @type {CustomEvent}\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @property {object} detail.stepConfig\n */\n stepRendered: 'tool_usertours/stepRendered',\n\n /**\n * An event triggered before a user tour starts.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/tourStart\n * @type {CustomEvent}\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @property {Number} detail.startAt\n */\n tourStart: 'tool_usertours/tourStart',\n\n /**\n * An event triggered after a user tour has started.\n *\n * @event tool_usertours/tourStarted\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n tourStarted: 'tool_usertours/tourStarted',\n\n /**\n * An event triggered before a tour ends.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/tourEnd\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n tourEnd: 'tool_usertours/tourEnd',\n\n /**\n * An event triggered after a tour has ended.\n *\n * @event tool_usertours/tourEnded\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n tourEnded: 'tool_usertours/tourEnded',\n\n /**\n * An event triggered before a step is hidden.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/stepHide\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n stepHide: 'tool_usertours/stepHide',\n\n /**\n * An event triggered after a step has been hidden.\n *\n * @event tool_usertours/stepHidden\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n stepHidden: 'tool_usertours/stepHidden',\n};\n"],"file":"events.min.js"} \ No newline at end of file +{"version":3,"file":"events.min.js","sources":["../src/events.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 * Javascript events for the `tool_usertours` subsystem.\n *\n * @module tool_usertours/events\n * @copyright 2021 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n *\n * @example Example of listening to a step rendering event and cancelling it.\n * import {eventTypes as userTourEvents} from 'tool_usertours/events';\n *\n * document.addEventListener(userTourEvents.stepRender, e => {\n * console.log(e.detail.tour); // The Tour instance\n * e.preventDefault();\n * });\n */\n\n/**\n * Events for the component.\n *\n * @constant\n * @property {object} eventTypes\n * @property {String} eventTypes.stepRender See {@link event:tool_usertours/stepRender}\n * @property {String} eventTypes.stepRendered See {@link event:tool_usertours/stepRendered}\n * @property {String} eventTypes.tourStart See {@link event:tool_usertours/tourStart}\n * @property {String} eventTypes.tourStarted See {@link event:tool_usertours/tourStarted}\n * @property {String} eventTypes.tourEnd See {@link event:tool_usertours/tourEnd}\n * @property {String} eventTypes.tourEnded See {@link event:tool_usertours/tourEnded}\n * @property {String} eventTypes.stepHide See {@link event:tool_usertours/stepHide}\n * @property {String} eventTypes.stepHidden See {@link event:tool_usertours/stepHidden}\n */\nexport const eventTypes = {\n /**\n * An event triggered before a user tour step is rendered.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/stepRender\n * @type {CustomEvent}\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @property {object} detail.stepConfig\n */\n stepRender: 'tool_usertours/stepRender',\n\n /**\n * An event triggered after a user tour step has been rendered.\n *\n * @event tool_usertours/stepRendered\n * @type {CustomEvent}\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @property {object} detail.stepConfig\n */\n stepRendered: 'tool_usertours/stepRendered',\n\n /**\n * An event triggered before a user tour starts.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/tourStart\n * @type {CustomEvent}\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @property {Number} detail.startAt\n */\n tourStart: 'tool_usertours/tourStart',\n\n /**\n * An event triggered after a user tour has started.\n *\n * @event tool_usertours/tourStarted\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n tourStarted: 'tool_usertours/tourStarted',\n\n /**\n * An event triggered before a tour ends.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/tourEnd\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n tourEnd: 'tool_usertours/tourEnd',\n\n /**\n * An event triggered after a tour has ended.\n *\n * @event tool_usertours/tourEnded\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n tourEnded: 'tool_usertours/tourEnded',\n\n /**\n * An event triggered before a step is hidden.\n *\n * This event is cancellable.\n *\n * @event tool_usertours/stepHide\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n stepHide: 'tool_usertours/stepHide',\n\n /**\n * An event triggered after a step has been hidden.\n *\n * @event tool_usertours/stepHidden\n * @property {object} detail\n * @property {tool_usertours/tour} detail.tour\n * @type {CustomEvent}\n */\n stepHidden: 'tool_usertours/stepHidden',\n};\n"],"names":["stepRender","stepRendered","tourStart","tourStarted","tourEnd","tourEnded","stepHide","stepHidden"],"mappings":"sKA6C0B,CAYtBA,WAAY,4BAWZC,aAAc,8BAadC,UAAW,2BAUXC,YAAa,6BAYbC,QAAS,yBAUTC,UAAW,2BAYXC,SAAU,0BAUVC,WAAY"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/filter_cssselector.min.js b/admin/tool/usertours/amd/build/filter_cssselector.min.js index 6dbb873f9c9..551b50be739 100644 --- a/admin/tool/usertours/amd/build/filter_cssselector.min.js +++ b/admin/tool/usertours/amd/build/filter_cssselector.min.js @@ -1,2 +1,3 @@ -define ("tool_usertours/filter_cssselector",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.filterMatches=void 0;a.filterMatches=function filterMatches(a){var b=a.filtervalues.cssselector;if(b[0]){return!!document.querySelector(b[0])}return!0}}); -//# sourceMappingURL=filter_cssselector.min.js.map +define("tool_usertours/filter_cssselector",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.filterMatches=void 0;_exports.filterMatches=function(tourConfig){let filterValues=tourConfig.filtervalues.cssselector;return!filterValues[0]||!!document.querySelector(filterValues[0])}})); + +//# sourceMappingURL=filter_cssselector.min.js.map \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/filter_cssselector.min.js.map b/admin/tool/usertours/amd/build/filter_cssselector.min.js.map index 969f574c204..e29a30215d8 100644 --- a/admin/tool/usertours/amd/build/filter_cssselector.min.js.map +++ b/admin/tool/usertours/amd/build/filter_cssselector.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/filter_cssselector.js"],"names":["filterMatches","tourConfig","filterValues","filtervalues","cssselector","document","querySelector"],"mappings":"yKA6B6B,QAAhBA,CAAAA,aAAgB,CAASC,CAAT,CAAqB,CAC9C,GAAIC,CAAAA,CAAY,CAAGD,CAAU,CAACE,YAAX,CAAwBC,WAA3C,CACA,GAAIF,CAAY,CAAC,CAAD,CAAhB,CAAqB,CACjB,MAAO,CAAC,CAACG,QAAQ,CAACC,aAAT,CAAuBJ,CAAY,CAAC,CAAD,CAAnC,CACZ,CAED,QACH,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 .\n\n/**\n * CSS selector client side filter.\n *\n * @module tool_usertours/filter_cssselector\n * @copyright 2020 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Checks whether the configured CSS selector exists on this page.\n *\n * @param {array} tourConfig The tour configuration.\n * @returns {boolean}\n */\nexport const filterMatches = function(tourConfig) {\n let filterValues = tourConfig.filtervalues.cssselector;\n if (filterValues[0]) {\n return !!document.querySelector(filterValues[0]);\n }\n // If there is no CSS selector configured, this page matches.\n return true;\n};\n"],"file":"filter_cssselector.min.js"} \ No newline at end of file +{"version":3,"file":"filter_cssselector.min.js","sources":["../src/filter_cssselector.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 * CSS selector client side filter.\n *\n * @module tool_usertours/filter_cssselector\n * @copyright 2020 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Checks whether the configured CSS selector exists on this page.\n *\n * @param {array} tourConfig The tour configuration.\n * @returns {boolean}\n */\nexport const filterMatches = function(tourConfig) {\n let filterValues = tourConfig.filtervalues.cssselector;\n if (filterValues[0]) {\n return !!document.querySelector(filterValues[0]);\n }\n // If there is no CSS selector configured, this page matches.\n return true;\n};\n"],"names":["tourConfig","filterValues","filtervalues","cssselector","document","querySelector"],"mappings":"wLA6B6B,SAASA,gBAC9BC,aAAeD,WAAWE,aAAaC,mBACvCF,aAAa,MACJG,SAASC,cAAcJ,aAAa"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/managesteps.min.js b/admin/tool/usertours/amd/build/managesteps.min.js index e566fba502f..4c8a4a1ebb4 100644 --- a/admin/tool/usertours/amd/build/managesteps.min.js +++ b/admin/tool/usertours/amd/build/managesteps.min.js @@ -1,2 +1,3 @@ -define ("tool_usertours/managesteps",["exports","core/prefetch","core/str","core/notification"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.setup=void 0;var e=function(a){var b=a.target.closest("[data-action=\"delete\"]");if(b){a.preventDefault();f(b.href)}},f=function(a){(0,d.confirm)((0,c.get_string)("confirmstepremovaltitle","tool_usertours"),(0,c.get_string)("confirmstepremovalquestion","tool_usertours"),(0,c.get_string)("yes","core"),(0,c.get_string)("no","core"),function(){window.location=a})};a.setup=function setup(){(0,b.prefetchStrings)("tool_usertours",["confirmstepremovaltitle","confirmstepremovalquestion"]);(0,b.prefetchStrings)("core",["yes","no"]);document.querySelector("body").addEventListener("click",e)}}); -//# sourceMappingURL=managesteps.min.js.map +define("tool_usertours/managesteps",["exports","core/prefetch","core/str","core/notification"],(function(_exports,_prefetch,_str,_notification){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setup=void 0;const removeStepHandler=e=>{const deleteButton=e.target.closest('[data-action="delete"]');deleteButton&&(e.preventDefault(),removeStepFromLink(deleteButton.href))},removeStepFromLink=targetUrl=>{(0,_notification.confirm)((0,_str.get_string)("confirmstepremovaltitle","tool_usertours"),(0,_str.get_string)("confirmstepremovalquestion","tool_usertours"),(0,_str.get_string)("yes","core"),(0,_str.get_string)("no","core"),(()=>{window.location=targetUrl}))};_exports.setup=()=>{(0,_prefetch.prefetchStrings)("tool_usertours",["confirmstepremovaltitle","confirmstepremovalquestion"]),(0,_prefetch.prefetchStrings)("core",["yes","no"]),document.querySelector("body").addEventListener("click",removeStepHandler)}})); + +//# sourceMappingURL=managesteps.min.js.map \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/managesteps.min.js.map b/admin/tool/usertours/amd/build/managesteps.min.js.map index 7c8052becff..e42c77cbf65 100644 --- a/admin/tool/usertours/amd/build/managesteps.min.js.map +++ b/admin/tool/usertours/amd/build/managesteps.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/managesteps.js"],"names":["removeStepHandler","e","deleteButton","target","closest","preventDefault","removeStepFromLink","href","targetUrl","window","location","setup","document","querySelector","addEventListener"],"mappings":"kMAgBMA,CAAAA,CAAiB,CAAG,SAAAC,CAAC,CAAI,CAC3B,GAAMC,CAAAA,CAAY,CAAGD,CAAC,CAACE,MAAF,CAASC,OAAT,CAAiB,0BAAjB,CAArB,CACA,GAAIF,CAAJ,CAAkB,CACdD,CAAC,CAACI,cAAF,GACAC,CAAkB,CAACJ,CAAY,CAACK,IAAd,CACrB,CACJ,C,CAQKD,CAAkB,CAAG,SAAAE,CAAS,CAAI,CACpC,cACI,iBAAU,yBAAV,CAAqC,gBAArC,CADJ,CAEI,iBAAU,4BAAV,CAAwC,gBAAxC,CAFJ,CAGI,iBAAU,KAAV,CAAiB,MAAjB,CAHJ,CAII,iBAAU,IAAV,CAAgB,MAAhB,CAJJ,CAKI,UAAM,CACFC,MAAM,CAACC,QAAP,CAAkBF,CACrB,CAPL,CASH,C,SAKoB,QAARG,CAAAA,KAAQ,EAAM,CACvB,sBAAgB,gBAAhB,CAAkC,CAC9B,yBAD8B,CAE9B,4BAF8B,CAAlC,EAKA,sBAAgB,MAAhB,CAAwB,CACpB,KADoB,CAEpB,IAFoB,CAAxB,EAKAC,QAAQ,CAACC,aAAT,CAAuB,MAAvB,EAA+BC,gBAA/B,CAAgD,OAAhD,CAAyDd,CAAzD,CACH,C","sourcesContent":["/**\n * Step management code.\n *\n * @module tool_usertours/managesteps\n * @copyright 2016 Andrew Nicols \n */\nimport {prefetchStrings} from 'core/prefetch';\nimport {get_string as getString} from 'core/str';\nimport {confirm as confirmModal} from 'core/notification';\n\n/**\n * Handle step management actions.\n *\n * @param {Event} e\n * @private\n */\nconst removeStepHandler = e => {\n const deleteButton = e.target.closest('[data-action=\"delete\"]');\n if (deleteButton) {\n e.preventDefault();\n removeStepFromLink(deleteButton.href);\n }\n};\n\n/**\n * Handle removal of a step with confirmation.\n *\n * @param {string} targetUrl\n * @private\n */\nconst removeStepFromLink = targetUrl => {\n confirmModal(\n getString('confirmstepremovaltitle', 'tool_usertours'),\n getString('confirmstepremovalquestion', 'tool_usertours'),\n getString('yes', 'core'),\n getString('no', 'core'),\n () => {\n window.location = targetUrl;\n }\n );\n};\n\n/**\n * Set up the step management handlers.\n */\nexport const setup = () => {\n prefetchStrings('tool_usertours', [\n 'confirmstepremovaltitle',\n 'confirmstepremovalquestion',\n ]);\n\n prefetchStrings('core', [\n 'yes',\n 'no',\n ]);\n\n document.querySelector('body').addEventListener('click', removeStepHandler);\n};\n"],"file":"managesteps.min.js"} \ No newline at end of file +{"version":3,"file":"managesteps.min.js","sources":["../src/managesteps.js"],"sourcesContent":["/**\n * Step management code.\n *\n * @module tool_usertours/managesteps\n * @copyright 2016 Andrew Nicols \n */\nimport {prefetchStrings} from 'core/prefetch';\nimport {get_string as getString} from 'core/str';\nimport {confirm as confirmModal} from 'core/notification';\n\n/**\n * Handle step management actions.\n *\n * @param {Event} e\n * @private\n */\nconst removeStepHandler = e => {\n const deleteButton = e.target.closest('[data-action=\"delete\"]');\n if (deleteButton) {\n e.preventDefault();\n removeStepFromLink(deleteButton.href);\n }\n};\n\n/**\n * Handle removal of a step with confirmation.\n *\n * @param {string} targetUrl\n * @private\n */\nconst removeStepFromLink = targetUrl => {\n confirmModal(\n getString('confirmstepremovaltitle', 'tool_usertours'),\n getString('confirmstepremovalquestion', 'tool_usertours'),\n getString('yes', 'core'),\n getString('no', 'core'),\n () => {\n window.location = targetUrl;\n }\n );\n};\n\n/**\n * Set up the step management handlers.\n */\nexport const setup = () => {\n prefetchStrings('tool_usertours', [\n 'confirmstepremovaltitle',\n 'confirmstepremovalquestion',\n ]);\n\n prefetchStrings('core', [\n 'yes',\n 'no',\n ]);\n\n document.querySelector('body').addEventListener('click', removeStepHandler);\n};\n"],"names":["removeStepHandler","e","deleteButton","target","closest","preventDefault","removeStepFromLink","href","targetUrl","window","location","document","querySelector","addEventListener"],"mappings":"oOAgBMA,kBAAoBC,UAChBC,aAAeD,EAAEE,OAAOC,QAAQ,0BAClCF,eACAD,EAAEI,iBACFC,mBAAmBJ,aAAaK,QAUlCD,mBAAqBE,uCAEnB,mBAAU,0BAA2B,mBACrC,mBAAU,6BAA8B,mBACxC,mBAAU,MAAO,SACjB,mBAAU,KAAM,SAChB,KACIC,OAAOC,SAAWF,6BAQT,mCACD,iBAAkB,CAC9B,0BACA,6DAGY,OAAQ,CACpB,MACA,OAGJG,SAASC,cAAc,QAAQC,iBAAiB,QAASb"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/managetours.min.js b/admin/tool/usertours/amd/build/managetours.min.js index 5d502854d90..301aca618e5 100644 --- a/admin/tool/usertours/amd/build/managetours.min.js +++ b/admin/tool/usertours/amd/build/managetours.min.js @@ -1,2 +1,3 @@ -define ("tool_usertours/managetours",["exports","core/prefetch","core/str","core/notification"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.setup=void 0;var e=function(a){var b=a.target.closest("[data-action=\"delete\"]");if(b){a.preventDefault();f(b.href)}},f=function(a){(0,d.confirm)((0,c.get_string)("confirmtourremovaltitle","tool_usertours"),(0,c.get_string)("confirmtourremovalquestion","tool_usertours"),(0,c.get_string)("yes","core"),(0,c.get_string)("no","core"),function(){window.location=a})};a.setup=function setup(){(0,b.prefetchStrings)("tool_usertours",["confirmtourremovaltitle","confirmtourremovalquestion"]);(0,b.prefetchStrings)("core",["yes","no"]);document.querySelector("body").addEventListener("click",e)}}); -//# sourceMappingURL=managetours.min.js.map +define("tool_usertours/managetours",["exports","core/prefetch","core/str","core/notification"],(function(_exports,_prefetch,_str,_notification){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setup=void 0;const removeTourHandler=e=>{const deleteButton=e.target.closest('[data-action="delete"]');deleteButton&&(e.preventDefault(),removeTourFromLink(deleteButton.href))},removeTourFromLink=targetUrl=>{(0,_notification.confirm)((0,_str.get_string)("confirmtourremovaltitle","tool_usertours"),(0,_str.get_string)("confirmtourremovalquestion","tool_usertours"),(0,_str.get_string)("yes","core"),(0,_str.get_string)("no","core"),(()=>{window.location=targetUrl}))};_exports.setup=()=>{(0,_prefetch.prefetchStrings)("tool_usertours",["confirmtourremovaltitle","confirmtourremovalquestion"]),(0,_prefetch.prefetchStrings)("core",["yes","no"]),document.querySelector("body").addEventListener("click",removeTourHandler)}})); + +//# sourceMappingURL=managetours.min.js.map \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/managetours.min.js.map b/admin/tool/usertours/amd/build/managetours.min.js.map index 35243deae2c..702cd1a661c 100644 --- a/admin/tool/usertours/amd/build/managetours.min.js.map +++ b/admin/tool/usertours/amd/build/managetours.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/managetours.js"],"names":["removeTourHandler","e","deleteButton","target","closest","preventDefault","removeTourFromLink","href","targetUrl","window","location","setup","document","querySelector","addEventListener"],"mappings":"kMAgBMA,CAAAA,CAAiB,CAAG,SAAAC,CAAC,CAAI,CAC3B,GAAMC,CAAAA,CAAY,CAAGD,CAAC,CAACE,MAAF,CAASC,OAAT,CAAiB,0BAAjB,CAArB,CACA,GAAIF,CAAJ,CAAkB,CACdD,CAAC,CAACI,cAAF,GACAC,CAAkB,CAACJ,CAAY,CAACK,IAAd,CACrB,CACJ,C,CAQKD,CAAkB,CAAG,SAAAE,CAAS,CAAI,CACpC,cACI,iBAAU,yBAAV,CAAqC,gBAArC,CADJ,CAEI,iBAAU,4BAAV,CAAwC,gBAAxC,CAFJ,CAGI,iBAAU,KAAV,CAAiB,MAAjB,CAHJ,CAII,iBAAU,IAAV,CAAgB,MAAhB,CAJJ,CAKI,UAAM,CACFC,MAAM,CAACC,QAAP,CAAkBF,CACrB,CAPL,CASH,C,SAKoB,QAARG,CAAAA,KAAQ,EAAM,CACvB,sBAAgB,gBAAhB,CAAkC,CAC9B,yBAD8B,CAE9B,4BAF8B,CAAlC,EAKA,sBAAgB,MAAhB,CAAwB,CACpB,KADoB,CAEpB,IAFoB,CAAxB,EAKAC,QAAQ,CAACC,aAAT,CAAuB,MAAvB,EAA+BC,gBAA/B,CAAgD,OAAhD,CAAyDd,CAAzD,CACH,C","sourcesContent":["/**\n * Tour management code.\n *\n * @module tool_usertours/managetours\n * @copyright 2016 Andrew Nicols \n */\nimport {prefetchStrings} from 'core/prefetch';\nimport {get_string as getString} from 'core/str';\nimport {confirm as confirmModal} from 'core/notification';\n\n/**\n * Handle tour management actions.\n *\n * @param {Event} e\n * @private\n */\nconst removeTourHandler = e => {\n const deleteButton = e.target.closest('[data-action=\"delete\"]');\n if (deleteButton) {\n e.preventDefault();\n removeTourFromLink(deleteButton.href);\n }\n};\n\n/**\n * Handle removal of a tour with confirmation.\n *\n * @param {string} targetUrl\n * @private\n */\nconst removeTourFromLink = targetUrl => {\n confirmModal(\n getString('confirmtourremovaltitle', 'tool_usertours'),\n getString('confirmtourremovalquestion', 'tool_usertours'),\n getString('yes', 'core'),\n getString('no', 'core'),\n () => {\n window.location = targetUrl;\n }\n );\n};\n\n/**\n * Set up the tour management handlers.\n */\nexport const setup = () => {\n prefetchStrings('tool_usertours', [\n 'confirmtourremovaltitle',\n 'confirmtourremovalquestion',\n ]);\n\n prefetchStrings('core', [\n 'yes',\n 'no',\n ]);\n\n document.querySelector('body').addEventListener('click', removeTourHandler);\n};\n"],"file":"managetours.min.js"} \ No newline at end of file +{"version":3,"file":"managetours.min.js","sources":["../src/managetours.js"],"sourcesContent":["/**\n * Tour management code.\n *\n * @module tool_usertours/managetours\n * @copyright 2016 Andrew Nicols \n */\nimport {prefetchStrings} from 'core/prefetch';\nimport {get_string as getString} from 'core/str';\nimport {confirm as confirmModal} from 'core/notification';\n\n/**\n * Handle tour management actions.\n *\n * @param {Event} e\n * @private\n */\nconst removeTourHandler = e => {\n const deleteButton = e.target.closest('[data-action=\"delete\"]');\n if (deleteButton) {\n e.preventDefault();\n removeTourFromLink(deleteButton.href);\n }\n};\n\n/**\n * Handle removal of a tour with confirmation.\n *\n * @param {string} targetUrl\n * @private\n */\nconst removeTourFromLink = targetUrl => {\n confirmModal(\n getString('confirmtourremovaltitle', 'tool_usertours'),\n getString('confirmtourremovalquestion', 'tool_usertours'),\n getString('yes', 'core'),\n getString('no', 'core'),\n () => {\n window.location = targetUrl;\n }\n );\n};\n\n/**\n * Set up the tour management handlers.\n */\nexport const setup = () => {\n prefetchStrings('tool_usertours', [\n 'confirmtourremovaltitle',\n 'confirmtourremovalquestion',\n ]);\n\n prefetchStrings('core', [\n 'yes',\n 'no',\n ]);\n\n document.querySelector('body').addEventListener('click', removeTourHandler);\n};\n"],"names":["removeTourHandler","e","deleteButton","target","closest","preventDefault","removeTourFromLink","href","targetUrl","window","location","document","querySelector","addEventListener"],"mappings":"oOAgBMA,kBAAoBC,UAChBC,aAAeD,EAAEE,OAAOC,QAAQ,0BAClCF,eACAD,EAAEI,iBACFC,mBAAmBJ,aAAaK,QAUlCD,mBAAqBE,uCAEnB,mBAAU,0BAA2B,mBACrC,mBAAU,6BAA8B,mBACxC,mBAAU,MAAO,SACjB,mBAAU,KAAM,SAChB,KACIC,OAAOC,SAAWF,6BAQT,mCACD,iBAAkB,CAC9B,0BACA,6DAGY,OAAQ,CACpB,MACA,OAGJG,SAASC,cAAc,QAAQC,iBAAiB,QAASb"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/repository.min.js b/admin/tool/usertours/amd/build/repository.min.js index 3f253d6e1c5..633fe176f16 100644 --- a/admin/tool/usertours/amd/build/repository.min.js +++ b/admin/tool/usertours/amd/build/repository.min.js @@ -1,2 +1,3 @@ -define ("tool_usertours/repository",["exports","core/ajax","core/config"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.markStepShown=a.fetchTour=a.markTourComplete=a.resetTourState=void 0;c=function(a){return a&&a.__esModule?a:{default:a}}(c);var d=function(a){return(0,b.call)([{methodname:"tool_usertours_reset_tour",args:{tourid:a,context:c.default.contextid,pageurl:window.location.href}}])[0]};a.resetTourState=d;var e=function(a,d,e){return(0,b.call)([{methodname:"tool_usertours_complete_tour",args:{stepid:a,stepindex:e,tourid:d,context:c.default.contextid,pageurl:window.location.href}}])[0]};a.markTourComplete=e;var f=function(a){return(0,b.call)([{methodname:"tool_usertours_fetch_and_start_tour",args:{tourid:a,context:c.default.contextid,pageurl:window.location.href}}])[0]};a.fetchTour=f;var g=function(a,d,e){return(0,b.call)([{methodname:"tool_usertours_step_shown",args:{tourid:d,stepid:a,stepindex:e,context:c.default.contextid,pageurl:window.location.href}}])[0]};a.markStepShown=g}); -//# sourceMappingURL=repository.min.js.map +define("tool_usertours/repository",["exports","core/ajax","core/config"],(function(_exports,_ajax,_config){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.resetTourState=_exports.markTourComplete=_exports.markStepShown=_exports.fetchTour=void 0,_config=(obj=_config)&&obj.__esModule?obj:{default:obj};_exports.resetTourState=tourid=>(0,_ajax.call)([{methodname:"tool_usertours_reset_tour",args:{tourid:tourid,context:_config.default.contextid,pageurl:window.location.href}}])[0];_exports.markTourComplete=(stepid,tourid,stepindex)=>(0,_ajax.call)([{methodname:"tool_usertours_complete_tour",args:{stepid:stepid,stepindex:stepindex,tourid:tourid,context:_config.default.contextid,pageurl:window.location.href}}])[0];_exports.fetchTour=tourid=>(0,_ajax.call)([{methodname:"tool_usertours_fetch_and_start_tour",args:{tourid:tourid,context:_config.default.contextid,pageurl:window.location.href}}])[0];_exports.markStepShown=(stepid,tourid,stepindex)=>(0,_ajax.call)([{methodname:"tool_usertours_step_shown",args:{tourid:tourid,stepid:stepid,stepindex:stepindex,context:_config.default.contextid,pageurl:window.location.href}}])[0]})); + +//# sourceMappingURL=repository.min.js.map \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/repository.min.js.map b/admin/tool/usertours/amd/build/repository.min.js.map index c2552d58fdc..8afcf933c7f 100644 --- a/admin/tool/usertours/amd/build/repository.min.js.map +++ b/admin/tool/usertours/amd/build/repository.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/repository.js"],"names":["resetTourState","tourid","methodname","args","context","moodleConfig","contextid","pageurl","window","location","href","markTourComplete","stepid","stepindex","fetchTour","markStepShown"],"mappings":"+NAOA,uDAQO,GAAMA,CAAAA,CAAc,CAAG,SAAAC,CAAM,QAAI,WAAU,CAAC,CAC/CC,UAAU,CAAE,2BADmC,CAE/CC,IAAI,CAAE,CACFF,MAAM,CAANA,CADE,CAEFG,OAAO,CAAEC,UAAaC,SAFpB,CAGFC,OAAO,CAAEC,MAAM,CAACC,QAAP,CAAgBC,IAHvB,CAFyC,CAAD,CAAV,EAOpC,CAPoC,CAAJ,CAA7B,C,mBAiBA,GAAMC,CAAAA,CAAgB,CAAG,SAACC,CAAD,CAASX,CAAT,CAAiBY,CAAjB,QAA+B,WAAU,CAAC,CACtEX,UAAU,CAAE,8BAD0D,CAEtEC,IAAI,CAAE,CACFS,MAAM,CAANA,CADE,CAEFC,SAAS,CAAEA,CAFT,CAGFZ,MAAM,CAANA,CAHE,CAIFG,OAAO,CAAEC,UAAaC,SAJpB,CAKFC,OAAO,CAAEC,MAAM,CAACC,QAAP,CAAgBC,IALvB,CAFgE,CAAD,CAAV,EAS3D,CAT2D,CAA/B,CAAzB,C,qBAiBA,GAAMI,CAAAA,CAAS,CAAG,SAAAb,CAAM,QAAI,WAAU,CAAC,CAC1CC,UAAU,CAAE,qCAD8B,CAE1CC,IAAI,CAAE,CACFF,MAAM,CAANA,CADE,CAEFG,OAAO,CAAEC,UAAaC,SAFpB,CAGFC,OAAO,CAAEC,MAAM,CAACC,QAAP,CAAgBC,IAHvB,CAFoC,CAAD,CAAV,EAO/B,CAP+B,CAAJ,CAAxB,C,cAiBA,GAAMK,CAAAA,CAAa,CAAG,SAACH,CAAD,CAASX,CAAT,CAAiBY,CAAjB,QAA+B,WAAU,CAAC,CACnEX,UAAU,CAAE,2BADuD,CAEnEC,IAAI,CAAE,CACFF,MAAM,CAANA,CADE,CAEFW,MAAM,CAANA,CAFE,CAGFC,SAAS,CAATA,CAHE,CAIFT,OAAO,CAAEC,UAAaC,SAJpB,CAKFC,OAAO,CAAEC,MAAM,CAACC,QAAP,CAAgBC,IALvB,CAF6D,CAAD,CAAV,EASxD,CATwD,CAA/B,CAAtB,C","sourcesContent":["/**\n * Step management code.\n *\n * @module tool_usertours/managesteps\n * @copyright 2016 Andrew Nicols \n */\nimport {call as fetchMany} from 'core/ajax';\nimport moodleConfig from 'core/config';\n\n/**\n * Reset the tour state of the specified tour.\n *\n * @param {number} tourid\n * @return {Promise}\n */\nexport const resetTourState = tourid => fetchMany([{\n methodname: 'tool_usertours_reset_tour',\n args: {\n tourid,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n\n/**\n * Mark the specified tour as complete.\n *\n * @param {number} stepid\n * @param {number} tourid\n * @param {number} stepindex\n * @return {Promise}\n */\nexport const markTourComplete = (stepid, tourid, stepindex) => fetchMany([{\n methodname: 'tool_usertours_complete_tour',\n args: {\n stepid,\n stepindex: stepindex,\n tourid,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n\n/**\n * Fetch the specified tour.\n *\n * @param {number} tourid\n * @return {Promise}\n */\nexport const fetchTour = tourid => fetchMany([{\n methodname: 'tool_usertours_fetch_and_start_tour',\n args: {\n tourid,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n\n/**\n * Mark the specified step as having been shown.\n *\n * @param {number} stepid\n * @param {number} tourid\n * @param {number} stepindex\n * @return {Promise}\n */\nexport const markStepShown = (stepid, tourid, stepindex) => fetchMany([{\n methodname: 'tool_usertours_step_shown',\n args: {\n tourid,\n stepid,\n stepindex,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n"],"file":"repository.min.js"} \ No newline at end of file +{"version":3,"file":"repository.min.js","sources":["../src/repository.js"],"sourcesContent":["/**\n * Step management code.\n *\n * @module tool_usertours/managesteps\n * @copyright 2016 Andrew Nicols \n */\nimport {call as fetchMany} from 'core/ajax';\nimport moodleConfig from 'core/config';\n\n/**\n * Reset the tour state of the specified tour.\n *\n * @param {number} tourid\n * @return {Promise}\n */\nexport const resetTourState = tourid => fetchMany([{\n methodname: 'tool_usertours_reset_tour',\n args: {\n tourid,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n\n/**\n * Mark the specified tour as complete.\n *\n * @param {number} stepid\n * @param {number} tourid\n * @param {number} stepindex\n * @return {Promise}\n */\nexport const markTourComplete = (stepid, tourid, stepindex) => fetchMany([{\n methodname: 'tool_usertours_complete_tour',\n args: {\n stepid,\n stepindex: stepindex,\n tourid,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n\n/**\n * Fetch the specified tour.\n *\n * @param {number} tourid\n * @return {Promise}\n */\nexport const fetchTour = tourid => fetchMany([{\n methodname: 'tool_usertours_fetch_and_start_tour',\n args: {\n tourid,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n\n/**\n * Mark the specified step as having been shown.\n *\n * @param {number} stepid\n * @param {number} tourid\n * @param {number} stepindex\n * @return {Promise}\n */\nexport const markStepShown = (stepid, tourid, stepindex) => fetchMany([{\n methodname: 'tool_usertours_step_shown',\n args: {\n tourid,\n stepid,\n stepindex,\n context: moodleConfig.contextid,\n pageurl: window.location.href,\n }\n}])[0];\n"],"names":["tourid","methodname","args","context","moodleConfig","contextid","pageurl","window","location","href","stepid","stepindex"],"mappings":"8VAe8BA,SAAU,cAAU,CAAC,CAC/CC,WAAY,4BACZC,KAAM,CACFF,OAAAA,OACAG,QAASC,gBAAaC,UACtBC,QAASC,OAAOC,SAASC,SAE7B,6BAU4B,CAACC,OAAQV,OAAQW,aAAc,cAAU,CAAC,CACtEV,WAAY,+BACZC,KAAM,CACFQ,OAAAA,OACAC,UAAWA,UACXX,OAAAA,OACAG,QAASC,gBAAaC,UACtBC,QAASC,OAAOC,SAASC,SAE7B,sBAQqBT,SAAU,cAAU,CAAC,CAC1CC,WAAY,sCACZC,KAAM,CACFF,OAAAA,OACAG,QAASC,gBAAaC,UACtBC,QAASC,OAAOC,SAASC,SAE7B,0BAUyB,CAACC,OAAQV,OAAQW,aAAc,cAAU,CAAC,CACnEV,WAAY,4BACZC,KAAM,CACFF,OAAAA,OACAU,OAAAA,OACAC,UAAAA,UACAR,QAASC,gBAAaC,UACtBC,QAASC,OAAOC,SAASC,SAE7B"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/tour.min.js b/admin/tool/usertours/amd/build/tour.min.js index 9aa89c46b95..031a72682b6 100644 --- a/admin/tool/usertours/amd/build/tour.min.js +++ b/admin/tool/usertours/amd/build/tour.min.js @@ -1,2 +1,3 @@ -define ("tool_usertours/tour",["exports","jquery","core/aria","core/popper","core/event_dispatcher","./events","core/str","core/prefetch"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=k(b);c=j(c);d=k(d);var s;function i(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;i=function(){return a};return a}function j(a){if(a&&a.__esModule){return a}if(null===a||"object"!==n(a)&&"function"!=typeof a){return{default:a}}var b=i();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function k(a){return a&&a.__esModule?a:{default:a}}function l(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function m(a){for(var b=1,c;ba){return this.endTour()}var c=this.getStepConfig(a);if(null===c){return this.endTour()}return this._gotoStep(c,b)}},{key:"_gotoStep",value:function _gotoStep(a,b){if(!a){return this.endTour()}if("undefined"!=typeof a.delay&&a.delay&&!a.delayed){a.delayed=!0;window.setTimeout(this._gotoStep.bind(this),a.delay,a,b);return this}else if(!a.orphan&&!this.isStepActuallyVisible(a)){var d=-1==b?"getPreviousStepNumber":"getNextStepNumber";return this.gotoStep(this[d](a.stepNumber),b)}this.hide();var c=this.dispatchEvent(f.eventTypes.stepRender,{stepConfig:a},!0);if(!c.defaultPrevented){this.renderStep(a);this.dispatchEvent(f.eventTypes.stepRendered,{stepConfig:a})}return this}},{key:"getStepConfig",value:function getStepConfig(a){if(null===a||0>a||a>=this.steps.length){return null}var c=this.normalizeStepConfig(this.steps[a]);c=b.default.extend(c,{stepNumber:a});return c}},{key:"normalizeStepConfig",value:function normalizeStepConfig(a){if("undefined"!=typeof a.reflex&&"undefined"==typeof a.moveAfterClick){a.moveAfterClick=a.reflex}if("undefined"!=typeof a.element&&"undefined"==typeof a.target){a.target=a.element}if("undefined"!=typeof a.content&&"undefined"==typeof a.body){a.body=a.content}a=b.default.extend({},this.stepDefaults,a);a=b.default.extend({},{attachTo:a.target,attachPoint:"after"},a);if(a.attachTo){a.attachTo=(0,b.default)(a.attachTo).first()}return a}},{key:"getStepTarget",value:function getStepTarget(a){if(a.target){return(0,b.default)(a.target)}return null}},{key:"dispatchEvent",value:function dispatchEvent(a){var b=1").html(a.template).hide(),e=(0,b.default)("body, html").stop(!0,!0);if(this.isStepActuallyVisible(a)){var f=this.getStepTarget(a);if(f.parents("[data-usertour=\"scroller\"]").length){e=f.parents("[data-usertour=\"scroller\"]")}f.data("flexitour","target");var g=this.calculateZIndex(f);if(g){a.zIndex=g+1}if(a.zIndex){c.css("zIndex",a.zIndex+1)}this.positionBackdrop(a);(0,b.default)(document.body).append(c);this.currentStepNode=c;this.currentStepNode.css({top:0,left:0});e.animate({scrollTop:this.calculateScrollTop(a)}).promise().then(function(){this.positionStep(a);this.revealStep(a)}.bind(this)).catch(function(){})}else if(a.orphan){a.isOrphan=!0;a.attachTo=(0,b.default)("body").first();a.attachPoint="append";this.positionBackdrop(a);c.addClass("orphan");(0,b.default)(document.body).append(c);this.currentStepNode=c;this.currentStepNode.offset(this.calculateStepPositionInPage());this.currentStepNode.css("position","fixed");this.currentStepPopper=new d.default((0,b.default)("body"),this.currentStepNode[0],{removeOnDestroy:!0,placement:a.placement+"-start",arrowElement:"[data-role=\"arrow\"]",modifiers:{hide:{enabled:!1},applyStyle:{onLoad:null,enabled:!1}}});this.revealStep(a)}return this}},{key:"revealStep",value:function revealStep(a){this.currentStepNode.fadeIn("",b.default.proxy(function(){this.announceStep(a);this.currentStepNode.focus();window.setTimeout(b.default.proxy(function(){if(this.currentStepNode){this.currentStepNode.focus()}},this),100)},this));return this}},{key:"announceStep",value:function announceStep(a){var b="tour-step-"+this.tourName+"-"+a.stepNumber;this.currentStepNode.attr("id",b);var c=this.currentStepNode.find("[data-placeholder=\"body\"]").first();c.attr("id",b+"-body");c.attr("role","document");var d=this.currentStepNode.find("[data-placeholder=\"title\"]").first();d.attr("id",b+"-title");d.attr("aria-labelledby",b+"-body");this.currentStepNode.attr("role","dialog");this.currentStepNode.attr("tabindex",0);this.currentStepNode.attr("aria-labelledby",b+"-title");this.currentStepNode.attr("aria-describedby",b+"-body");var e=this.getStepTarget(a);if(e){if(!e.attr("tabindex")){e.attr("tabindex",0)}e.data("original-describedby",e.attr("aria-describedby")).attr("aria-describedby",b+"-body")}this.accessibilityShow(a);return this}},{key:"handleKeyDown",value:function handleKeyDown(a){var c="a[href], link[href], [draggable=true], [contenteditable=true], ";c+=":input:enabled, [tabindex], button:enabled";switch(a.keyCode){case 27:this.endTour();break;case 9:(function(){if(!this.currentStepConfig.hasBackdrop){return}var d=(0,b.default)(document.activeElement),e=this.getStepTarget(this.currentStepConfig),f=(0,b.default)(c),g=(0,b.default)("span[data-flexitour=\"container\"]"),h;if(e){f=f.filter(function(a,b){return null!==e&&(e.has(b).length||g.has(b).length||e.is(b)||g.is(b))})}f.each(function(a,b){if(d.is(b)){h=a;return!1}return!0});var i,j,k;if(void 0!=h){var l=1;if(a.shiftKey){l=-1}i=h;do{i+=l;j=(0,b.default)(f[i])}while(j.length&&j.is(":disabled")||j.is(":hidden"));if(j.length){k=j.closest(e).length;k=k||j.closest(this.currentStepNode).length}else{k=!1}}if(k){j.focus()}else{if(a.shiftKey){this.currentStepNode.find(c).last().focus()}else{if(this.currentStepConfig.isOrphan){this.currentStepNode.focus()}else{e.focus()}}}a.preventDefault()}).call(this);break;}}},{key:"startTour",value:function startTour(a){if(this.storage&&"undefined"==typeof a){var c=this.storage.getItem(this.storageKey);if(c){var d=parseInt(c,10);if(d<=this.steps.length){a=d}}}if("undefined"==typeof a){a=this.getCurrentStepNumber()}var b=this.dispatchEvent(f.eventTypes.tourStart,{startAt:a},!0);if(!b.defaultPrevented){this.gotoStep(a);this.tourRunning=!0;this.dispatchEvent(f.eventTypes.tourStarted,{startAt:a})}return this}},{key:"restartTour",value:function restartTour(){return this.startTour(0)}},{key:"endTour",value:function endTour(){var a=this.dispatchEvent(f.eventTypes.tourEnd,{},!0);if(a.defaultPrevented){return this}if(this.currentStepConfig){var b=this.getStepTarget(this.currentStepConfig);if(b){if(!b.attr("tabindex")){b.attr("tabindex","-1")}b.focus()}}this.hide(!0);this.tourRunning=!1;this.dispatchEvent(f.eventTypes.tourEnded);return this}},{key:"hide",value:function hide(a){var c=this.dispatchEvent(f.eventTypes.stepHide,{},!0);if(c.defaultPrevented){return this}if(this.currentStepNode&&this.currentStepNode.length){this.currentStepNode.hide();if(this.currentStepPopper){this.currentStepPopper.destroy()}}if(this.currentStepConfig){var e=this.getStepTarget(this.currentStepConfig);if(e){if(e.data("original-labelledby")){e.attr("aria-labelledby",e.data("original-labelledby"))}if(e.data("original-describedby")){e.attr("aria-describedby",e.data("original-describedby"))}if(e.data("original-tabindex")){e.attr("tabindex",e.data("tabindex"))}}this.currentStepConfig=null}var d=0;if(a){d=400}(0,b.default)("[data-flexitour=\"step-background\"]").remove();(0,b.default)("[data-flexitour=\"step-backdrop\"]").removeAttr("data-flexitour");(0,b.default)("[data-flexitour=\"backdrop\"]").fadeOut(d,function(){(0,b.default)(this).remove()});if(this.currentStepNode&&this.currentStepNode.length){var g=this.currentStepNode.attr("id");if(g){var h="[aria-describedby=\""+g+"-body\"]";(0,b.default)(h).removeAttr("tabindex");(0,b.default)(h).removeAttr("aria-describedby")}}this.resetStepListeners();this.accessibilityHide();this.dispatchEvent(f.eventTypes.stepHidden);this.currentStepNode=null;this.currentStepPopper=null;return this}},{key:"show",value:function show(){var a=this.getCurrentStepNumber();return this.gotoStep(a)}},{key:"getStepContainer",value:function getStepContainer(){return(0,b.default)(this.currentStepNode)}},{key:"calculateScrollTop",value:function calculateScrollTop(a){var c=(0,b.default)(window).height(),d=this.getStepTarget(a),e=(0,b.default)(window);if(d.parents("[data-usertour=\"scroller\"]").length){e=d.parents("[data-usertour=\"scroller\"]")}var f=e.scrollTop();if("top"===a.placement){f=d.offset().top-c/2}else if("bottom"===a.placement){f=d.offset().top+d.height()+f-c/2}else if(d.height()<=.8*c){f=d.offset().top-(c-d.height())/2}else{f=d.offset().top-.2*c}f=Math.max(0,f);f=Math.min((0,b.default)(document).height()-c,f);return Math.ceil(f)}},{key:"calculateStepPositionInPage",value:function calculateStepPositionInPage(){var a=(0,b.default)(window).height(),c=this.currentStepNode.height(),d=(0,b.default)(window).width(),e=this.currentStepNode.width();return{top:Math.ceil((a-c)/2),left:Math.ceil((d-e)/2)}}},{key:"positionStep",value:function positionStep(a){var c=this.currentStepNode;if(!c||!c.length){return this}a.placement=this.recalculatePlacement(a);var e;switch(a.placement){case"left":e=["left","right","top","bottom"];break;case"right":e=["right","left","top","bottom"];break;case"top":e=["top","bottom","right","left"];break;case"bottom":e=["bottom","top","right","left"];break;default:e="flip";break;}var f=this.getStepTarget(a),g={placement:a.placement+"-start",removeOnDestroy:!0,modifiers:{flip:{behaviour:e},arrow:{element:"[data-role=\"arrow\"]"}},onCreate:function onCreate(a){h(a)},onUpdate:function onUpdate(a){h(a)}},h=function(a){var c=a.placement.split("-")[0],d=-1!==["left","right"].indexOf(c),e=a.instance.popper.querySelector("[data-role=\"arrow\"]"),f=(0,b.default)(a.instance.popper.querySelector("[data-role=\"flexitour-step\"]"));if(d){var g=parseFloat(window.getComputedStyle(e).height),h=parseFloat(window.getComputedStyle(e).top),i=parseFloat(window.getComputedStyle(a.instance.popper).height),j=parseFloat(window.getComputedStyle(a.instance.popper).top),k=parseFloat(f.css("borderTopWidth")),l=2*parseFloat(f.css("borderTopLeftRadius")),m=h+g/2,n=i+j-k-l,o=j+k+l;if(m>=n||m<=o){var y=0;if(m>i/2){y=n-g}else{y=o+g}(0,b.default)(e).css("top",y)}}else{var p=parseFloat(window.getComputedStyle(e).width),q=parseFloat(window.getComputedStyle(e).left),r=parseFloat(window.getComputedStyle(a.instance.popper).width),s=parseFloat(window.getComputedStyle(a.instance.popper).left),t=parseFloat(f.css("borderTopWidth")),u=2*parseFloat(f.css("borderTopLeftRadius")),v=q+p/2,w=r+s-t-u,x=s+t+u;if(v>=w||v<=x){var z=0;if(v>r/2){z=w-p}else{z=x+p}(0,b.default)(e).css("left",z)}}},i=(0,b.default)("[data-flexitour=\"step-background\"]");if(i.length){f=i}this.currentStepPopper=new d.default(f,c[0],g);return this}},{key:"recalculatePlacement",value:function recalculatePlacement(a){var b=this.getStepTarget(a),c=this.currentStepNode.width()+16,d=b.offset().left-10,e=b.offset().left+b.width()+10,f=a.placement;if(-1!==["left","right"].indexOf(f)){if(ddocument.documentElement.clientWidth){f="top"}}return f}},{key:"positionBackdrop",value:function positionBackdrop(a){if(a.backdrop){this.currentStepConfig.hasBackdrop=!0;var h=(0,b.default)("
");if(a.zIndex){if("append"===a.attachPoint){a.attachTo.append(h)}else{h.insertAfter(a.attachTo)}}else{(0,b.default)("body").append(h)}if(this.isStepActuallyVisible(a)){var i=(0,b.default)("[data-flexitour=\"step-background\"]");if(!i.length){i=(0,b.default)("
")}var c=this.getStepTarget(a),d=10,e=c;if(d){e=(0,b.default)("body")}var j=0;if(c.parents("[data-usertour=\"scroller\"]").length){var f=c.parents("[data-usertour=\"scroller\"]"),g=f.offset().top;if(f.scrollTop()>=g){j=f.scrollTop()-g;i.css({position:"fixed"})}}i.css({width:c.outerWidth()+d+d,height:c.outerHeight()+d+d,left:c.offset().left-d,top:c.offset().top+j-d,backgroundColor:this.calculateInherittedBackgroundColor(e)});if(c.offset().left").hide();(0,b.default)("body").append(c);var d=c.css("backgroundColor");c.remove();a=(0,b.default)(a);while(a.length&&a[0]!==document){var e=a.css("backgroundColor");if(e!==d){return e}a=a.parent()}return null}},{key:"calculatePosition",value:function calculatePosition(a){a=(0,b.default)(a);while(a.length&&a[0]!==document){var c=a.css("position");if("static"!==c){return c}a=a.parent()}return null}},{key:"accessibilityShow",value:function accessibilityShow(){var a=function(a){var b=a.data("flexitour");if(b){switch(b){case"container":case"target":return;}}var d=a.attr("aria-hidden");if(!d){a.attr("data-has-hidden",!0);c.hide(a)}};this.currentStepNode.siblings().each(function(c,d){a((0,b.default)(d))});this.currentStepNode.parentsUntil("body").siblings().each(function(c,d){a((0,b.default)(d))})}},{key:"accessibilityHide",value:function accessibilityHide(){var a=function(a){var b=a.attr("data-has-hidden");if("undefined"!=typeof b){a.removeAttr("data-has-hidden");c.unhide(a)}};(0,b.default)("[data-has-hidden]").each(function(c,d){a((0,b.default)(d))})}}]);return a}(),s);a.default=t;return a.default}); -//# sourceMappingURL=tour.min.js.map +define("tool_usertours/tour",["exports","jquery","core/aria","core/popper","core/event_dispatcher","./events","core/str","core/prefetch"],(function(_exports,_jquery,Aria,_popper,_event_dispatcher,_events,_str,_prefetch){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),Aria=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Aria),_popper=_interopRequireDefault(_popper);var _default=class{constructor(config){var obj,key,value;value=!1,(key="tourRunning")in(obj=this)?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,this.init(config)}init(config){this.eventHandlers={},this.reset(),this.originalConfiguration=config||{},this.configure.apply(this,arguments);try{this.storage=window.sessionStorage,this.storageKey="tourstate_"+this.tourName}catch(e){this.storage=!1,this.storageKey=""}return(0,_prefetch.prefetchStrings)("tool_usertours",["nextstep_sequence","skip_tour"]),this}reset(){return this.hide(),this.eventHandlers=[],this.resetStepListeners(),this.originalConfiguration={},this.steps=[],this.currentStepNumber=0,this}configure(config){if("object"==typeof config){if(void 0!==config.tourName&&(this.tourName=config.tourName),config.eventHandlers)for(let eventName in config.eventHandlers)config.eventHandlers[eventName].forEach((function(handler){this.addEventHandler(eventName,handler)}),this);this.resetStepDefaults(!0),"object"==typeof config.steps&&(this.steps=config.steps),void 0!==config.template&&(this.templateContent=config.template)}return this.checkMinimumRequirements(),this}checkMinimumRequirements(){if(!this.tourName)throw new Error("Tour Name required");if(!this.steps||!this.steps.length)throw new Error("Steps must be specified")}resetStepDefaults(loadOriginalConfiguration){return void 0===loadOriginalConfiguration&&(loadOriginalConfiguration=!0),this.stepDefaults={},loadOriginalConfiguration&&void 0!==this.originalConfiguration.stepDefaults?this.setStepDefaults(this.originalConfiguration.stepDefaults):this.setStepDefaults({}),this}setStepDefaults(stepDefaults){return this.stepDefaults||(this.stepDefaults={}),_jquery.default.extend(this.stepDefaults,{element:"",placement:"top",delay:0,moveOnClick:!1,moveAfterTime:0,orphan:!1,direction:1},stepDefaults),this}getCurrentStepNumber(){return parseInt(this.currentStepNumber,10)}setCurrentStepNumber(stepNumber){if(this.currentStepNumber=stepNumber,this.storage)try{this.storage.setItem(this.storageKey,stepNumber)}catch(e){e.code===DOMException.QUOTA_EXCEEDED_ERR&&this.storage.removeItem(this.storageKey)}}getNextStepNumber(stepNumber){void 0===stepNumber&&(stepNumber=this.getCurrentStepNumber());let nextStepNumber=stepNumber+1;for(;nextStepNumber<=this.steps.length;){if(this.isStepPotentiallyVisible(this.getStepConfig(nextStepNumber)))return nextStepNumber;nextStepNumber++}return null}getPreviousStepNumber(stepNumber){void 0===stepNumber&&(stepNumber=this.getCurrentStepNumber());let previousStepNumber=stepNumber-1;for(;previousStepNumber>=0;){if(this.isStepPotentiallyVisible(this.getStepConfig(previousStepNumber)))return previousStepNumber;previousStepNumber--}return null}isLastStep(stepNumber){return null===this.getNextStepNumber(stepNumber)}isStepPotentiallyVisible(stepConfig){return!!stepConfig&&(!!this.isStepActuallyVisible(stepConfig)||(!(void 0===stepConfig.orphan||!stepConfig.orphan)||!(void 0===stepConfig.delay||!stepConfig.delay)))}getPotentiallyVisibleSteps(){let position=1,result=[];for(let stepNumber=0;stepNumber=this.steps.length)return null;let stepConfig=this.normalizeStepConfig(this.steps[stepNumber]);return stepConfig=_jquery.default.extend(stepConfig,{stepNumber:stepNumber}),stepConfig}normalizeStepConfig(stepConfig){return void 0!==stepConfig.reflex&&void 0===stepConfig.moveAfterClick&&(stepConfig.moveAfterClick=stepConfig.reflex),void 0!==stepConfig.element&&void 0===stepConfig.target&&(stepConfig.target=stepConfig.element),void 0!==stepConfig.content&&void 0===stepConfig.body&&(stepConfig.body=stepConfig.content),stepConfig=_jquery.default.extend({},this.stepDefaults,stepConfig),(stepConfig=_jquery.default.extend({},{attachTo:stepConfig.target,attachPoint:"after"},stepConfig)).attachTo&&(stepConfig.attachTo=(0,_jquery.default)(stepConfig.attachTo).first()),stepConfig}getStepTarget(stepConfig){return stepConfig.target?(0,_jquery.default)(stepConfig.target):null}dispatchEvent(eventName){let detail=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},cancelable=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,_event_dispatcher.dispatchEvent)(eventName,{tour:this,...detail},document,{cancelable:cancelable})}addEventHandler(eventName,handler){return void 0===this.eventHandlers[eventName]&&(this.eventHandlers[eventName]=[]),this.eventHandlers[eventName].push(handler),this}processStepListeners(stepConfig){if(this.listeners.push({node:this.currentStepNode,args:["click",'[data-role="next"]',_jquery.default.proxy(this.next,this)]},{node:this.currentStepNode,args:["click",'[data-role="end"]',_jquery.default.proxy(this.endTour,this)]},{node:(0,_jquery.default)('[data-flexitour="backdrop"]'),args:["click",_jquery.default.proxy(this.hide,this)]},{node:(0,_jquery.default)("body"),args:["keydown",_jquery.default.proxy(this.handleKeyDown,this)]}),stepConfig.moveOnClick){var targetNode=this.getStepTarget(stepConfig);this.listeners.push({node:targetNode,args:["click",_jquery.default.proxy((function(e){0===(0,_jquery.default)(e.target).parents('[data-flexitour="container"]').length&&window.setTimeout(_jquery.default.proxy(this.next,this),500)}),this)]})}return this.listeners.forEach((function(listener){listener.node.on.apply(listener.node,listener.args)})),this}resetStepListeners(){return this.listeners&&this.listeners.forEach((function(listener){listener.node.off.apply(listener.node,listener.args)})),this.listeners=[],this}renderStep(stepConfig){this.currentStepConfig=stepConfig,this.setCurrentStepNumber(stepConfig.stepNumber);let template=(0,_jquery.default)(this.getTemplateContent());template.find('[data-placeholder="title"]').html(stepConfig.title),template.find('[data-placeholder="body"]').html(stepConfig.body);const nextBtn=template.find('[data-role="next"]'),endBtn=template.find('[data-role="end"]');if(this.isLastStep(stepConfig.stepNumber)?(nextBtn.hide(),endBtn.removeClass("btn-secondary").addClass("btn-primary")):(nextBtn.prop("disabled",!1),(0,_str.get_string)("skip_tour","tool_usertours").then((value=>{endBtn.html(value)})).catch()),nextBtn.attr("role","button"),endBtn.attr("role","button"),this.originalConfiguration.displaystepnumbers){const stepsPotentiallyVisible=this.getPotentiallyVisibleSteps(),totalStepsPotentiallyVisible=stepsPotentiallyVisible.length,position=stepsPotentiallyVisible[stepConfig.stepNumber].position;totalStepsPotentiallyVisible>1&&(0,_str.get_string)("nextstep_sequence","tool_usertours",{position:position,total:totalStepsPotentiallyVisible}).then((value=>{nextBtn.html(value)})).catch()}return stepConfig.template=template,this.addStepToPage(stepConfig),this.processStepListeners(stepConfig),this}getTemplateContent(){return(0,_jquery.default)(this.templateContent).clone()}addStepToPage(stepConfig){let currentStepNode=(0,_jquery.default)('').html(stepConfig.template).hide(),animationTarget=(0,_jquery.default)("body, html").stop(!0,!0);if(this.isStepActuallyVisible(stepConfig)){let targetNode=this.getStepTarget(stepConfig);targetNode.parents('[data-usertour="scroller"]').length&&(animationTarget=targetNode.parents('[data-usertour="scroller"]')),targetNode.data("flexitour","target");let zIndex=this.calculateZIndex(targetNode);zIndex&&(stepConfig.zIndex=zIndex+1),stepConfig.zIndex&¤tStepNode.css("zIndex",stepConfig.zIndex+1),this.positionBackdrop(stepConfig),(0,_jquery.default)(document.body).append(currentStepNode),this.currentStepNode=currentStepNode,this.currentStepNode.css({top:0,left:0}),animationTarget.animate({scrollTop:this.calculateScrollTop(stepConfig)}).promise().then(function(){this.positionStep(stepConfig),this.revealStep(stepConfig)}.bind(this)).catch((function(){}))}else stepConfig.orphan&&(stepConfig.isOrphan=!0,stepConfig.attachTo=(0,_jquery.default)("body").first(),stepConfig.attachPoint="append",this.positionBackdrop(stepConfig),currentStepNode.addClass("orphan"),(0,_jquery.default)(document.body).append(currentStepNode),this.currentStepNode=currentStepNode,this.currentStepNode.offset(this.calculateStepPositionInPage()),this.currentStepNode.css("position","fixed"),this.currentStepPopper=new _popper.default((0,_jquery.default)("body"),this.currentStepNode[0],{removeOnDestroy:!0,placement:stepConfig.placement+"-start",arrowElement:'[data-role="arrow"]',modifiers:{hide:{enabled:!1},applyStyle:{onLoad:null,enabled:!1}}}),this.revealStep(stepConfig));return this}revealStep(stepConfig){return this.currentStepNode.fadeIn("",_jquery.default.proxy((function(){this.announceStep(stepConfig),this.currentStepNode.focus(),window.setTimeout(_jquery.default.proxy((function(){this.currentStepNode&&this.currentStepNode.focus()}),this),100)}),this)),this}announceStep(stepConfig){let stepId="tour-step-"+this.tourName+"-"+stepConfig.stepNumber;this.currentStepNode.attr("id",stepId);let bodyRegion=this.currentStepNode.find('[data-placeholder="body"]').first();bodyRegion.attr("id",stepId+"-body"),bodyRegion.attr("role","document");let headerRegion=this.currentStepNode.find('[data-placeholder="title"]').first();headerRegion.attr("id",stepId+"-title"),headerRegion.attr("aria-labelledby",stepId+"-body"),this.currentStepNode.attr("role","dialog"),this.currentStepNode.attr("tabindex",0),this.currentStepNode.attr("aria-labelledby",stepId+"-title"),this.currentStepNode.attr("aria-describedby",stepId+"-body");let target=this.getStepTarget(stepConfig);return target&&(target.attr("tabindex")||target.attr("tabindex",0),target.data("original-describedby",target.attr("aria-describedby")).attr("aria-describedby",stepId+"-body")),this.accessibilityShow(stepConfig),this}handleKeyDown(e){let tabbableSelector="a[href], link[href], [draggable=true], [contenteditable=true], ";switch(tabbableSelector+=":input:enabled, [tabindex], button:enabled",e.keyCode){case 27:this.endTour();break;case 9:(function(){if(!this.currentStepConfig.hasBackdrop)return;let currentIndex,nextIndex,nextNode,focusRelevant,activeElement=(0,_jquery.default)(document.activeElement),stepTarget=this.getStepTarget(this.currentStepConfig),tabbableNodes=(0,_jquery.default)(tabbableSelector),dialogContainer=(0,_jquery.default)('span[data-flexitour="container"]');if(stepTarget&&(tabbableNodes=tabbableNodes.filter((function(index,element){return null!==stepTarget&&(stepTarget.has(element).length||dialogContainer.has(element).length||stepTarget.is(element)||dialogContainer.is(element))}))),tabbableNodes.each((function(index,element){return!activeElement.is(element)||(currentIndex=index,!1)})),null!=currentIndex){let direction=1;e.shiftKey&&(direction=-1),nextIndex=currentIndex;do{nextIndex+=direction,nextNode=(0,_jquery.default)(tabbableNodes[nextIndex])}while(nextNode.length&&nextNode.is(":disabled")||nextNode.is(":hidden"));nextNode.length?(focusRelevant=nextNode.closest(stepTarget).length,focusRelevant=focusRelevant||nextNode.closest(this.currentStepNode).length):focusRelevant=!1}focusRelevant?nextNode.focus():e.shiftKey?this.currentStepNode.find(tabbableSelector).last().focus():this.currentStepConfig.isOrphan?this.currentStepNode.focus():stepTarget.focus(),e.preventDefault()}).call(this)}}startTour(startAt){if(this.storage&&void 0===startAt){let storageStartValue=this.storage.getItem(this.storageKey);if(storageStartValue){let storageStartAt=parseInt(storageStartValue,10);storageStartAt<=this.steps.length&&(startAt=storageStartAt)}}void 0===startAt&&(startAt=this.getCurrentStepNumber());return this.dispatchEvent(_events.eventTypes.tourStart,{startAt:startAt},!0).defaultPrevented||(this.gotoStep(startAt),this.tourRunning=!0,this.dispatchEvent(_events.eventTypes.tourStarted,{startAt:startAt})),this}restartTour(){return this.startTour(0)}endTour(){if(this.dispatchEvent(_events.eventTypes.tourEnd,{},!0).defaultPrevented)return this;if(this.currentStepConfig){let previousTarget=this.getStepTarget(this.currentStepConfig);previousTarget&&(previousTarget.attr("tabindex")||previousTarget.attr("tabindex","-1"),previousTarget.focus())}return this.hide(!0),this.tourRunning=!1,this.dispatchEvent(_events.eventTypes.tourEnded),this}hide(transition){if(this.dispatchEvent(_events.eventTypes.stepHide,{},!0).defaultPrevented)return this;if(this.currentStepNode&&this.currentStepNode.length&&(this.currentStepNode.hide(),this.currentStepPopper&&this.currentStepPopper.destroy()),this.currentStepConfig){let target=this.getStepTarget(this.currentStepConfig);target&&(target.data("original-labelledby")&&target.attr("aria-labelledby",target.data("original-labelledby")),target.data("original-describedby")&&target.attr("aria-describedby",target.data("original-describedby")),target.data("original-tabindex")&&target.attr("tabindex",target.data("tabindex"))),this.currentStepConfig=null}let fadeTime=0;if(transition&&(fadeTime=400),(0,_jquery.default)('[data-flexitour="step-background"]').remove(),(0,_jquery.default)('[data-flexitour="step-backdrop"]').removeAttr("data-flexitour"),(0,_jquery.default)('[data-flexitour="backdrop"]').fadeOut(fadeTime,(function(){(0,_jquery.default)(this).remove()})),this.currentStepNode&&this.currentStepNode.length){let stepId=this.currentStepNode.attr("id");if(stepId){let currentStepElement='[aria-describedby="'+stepId+'-body"]';(0,_jquery.default)(currentStepElement).removeAttr("tabindex"),(0,_jquery.default)(currentStepElement).removeAttr("aria-describedby")}}return this.resetStepListeners(),this.accessibilityHide(),this.dispatchEvent(_events.eventTypes.stepHidden),this.currentStepNode=null,this.currentStepPopper=null,this}show(){let startAt=this.getCurrentStepNumber();return this.gotoStep(startAt)}getStepContainer(){return(0,_jquery.default)(this.currentStepNode)}calculateScrollTop(stepConfig){let viewportHeight=(0,_jquery.default)(window).height(),targetNode=this.getStepTarget(stepConfig),scrollParent=(0,_jquery.default)(window);targetNode.parents('[data-usertour="scroller"]').length&&(scrollParent=targetNode.parents('[data-usertour="scroller"]'));let scrollTop=scrollParent.scrollTop();return scrollTop="top"===stepConfig.placement?targetNode.offset().top-viewportHeight/2:"bottom"===stepConfig.placement?targetNode.offset().top+targetNode.height()+scrollTop-viewportHeight/2:targetNode.height()<=.8*viewportHeight?targetNode.offset().top-(viewportHeight-targetNode.height())/2:targetNode.offset().top-.2*viewportHeight,scrollTop=Math.max(0,scrollTop),scrollTop=Math.min((0,_jquery.default)(document).height()-viewportHeight,scrollTop),Math.ceil(scrollTop)}calculateStepPositionInPage(){let viewportHeight=(0,_jquery.default)(window).height(),stepHeight=this.currentStepNode.height(),viewportWidth=(0,_jquery.default)(window).width(),stepWidth=this.currentStepNode.width();return{top:Math.ceil((viewportHeight-stepHeight)/2),left:Math.ceil((viewportWidth-stepWidth)/2)}}positionStep(stepConfig){let flipBehavior,content=this.currentStepNode;if(!content||!content.length)return this;switch(stepConfig.placement=this.recalculatePlacement(stepConfig),stepConfig.placement){case"left":flipBehavior=["left","right","top","bottom"];break;case"right":flipBehavior=["right","left","top","bottom"];break;case"top":flipBehavior=["top","bottom","right","left"];break;case"bottom":flipBehavior=["bottom","top","right","left"];break;default:flipBehavior="flip"}let target=this.getStepTarget(stepConfig);var config={placement:stepConfig.placement+"-start",removeOnDestroy:!0,modifiers:{flip:{behaviour:flipBehavior},arrow:{element:'[data-role="arrow"]'}},onCreate:function(data){recalculateArrowPosition(data)},onUpdate:function(data){recalculateArrowPosition(data)}};let recalculateArrowPosition=function(data){let placement=data.placement.split("-")[0];const isVertical=-1!==["left","right"].indexOf(placement),arrowElement=data.instance.popper.querySelector('[data-role="arrow"]'),stepElement=(0,_jquery.default)(data.instance.popper.querySelector('[data-role="flexitour-step"]'));if(isVertical){let arrowHeight=parseFloat(window.getComputedStyle(arrowElement).height),arrowOffset=parseFloat(window.getComputedStyle(arrowElement).top),popperHeight=parseFloat(window.getComputedStyle(data.instance.popper).height),popperOffset=parseFloat(window.getComputedStyle(data.instance.popper).top),popperBorderWidth=parseFloat(stepElement.css("borderTopWidth")),popperBorderRadiusWidth=2*parseFloat(stepElement.css("borderTopLeftRadius")),arrowPos=arrowOffset+arrowHeight/2,maxPos=popperHeight+popperOffset-popperBorderWidth-popperBorderRadiusWidth,minPos=popperOffset+popperBorderWidth+popperBorderRadiusWidth;if(arrowPos>=maxPos||arrowPos<=minPos){let newArrowPos=0;newArrowPos=arrowPos>popperHeight/2?maxPos-arrowHeight:minPos+arrowHeight,(0,_jquery.default)(arrowElement).css("top",newArrowPos)}}else{let arrowWidth=parseFloat(window.getComputedStyle(arrowElement).width),arrowOffset=parseFloat(window.getComputedStyle(arrowElement).left),popperWidth=parseFloat(window.getComputedStyle(data.instance.popper).width),popperOffset=parseFloat(window.getComputedStyle(data.instance.popper).left),popperBorderWidth=parseFloat(stepElement.css("borderTopWidth")),popperBorderRadiusWidth=2*parseFloat(stepElement.css("borderTopLeftRadius")),arrowPos=arrowOffset+arrowWidth/2,maxPos=popperWidth+popperOffset-popperBorderWidth-popperBorderRadiusWidth,minPos=popperOffset+popperBorderWidth+popperBorderRadiusWidth;if(arrowPos>=maxPos||arrowPos<=minPos){let newArrowPos=0;newArrowPos=arrowPos>popperWidth/2?maxPos-arrowWidth:minPos+arrowWidth,(0,_jquery.default)(arrowElement).css("left",newArrowPos)}}},background=(0,_jquery.default)('[data-flexitour="step-background"]');return background.length&&(target=background),this.currentStepPopper=new _popper.default(target,content[0],config),this}recalculatePlacement(stepConfig){let target=this.getStepTarget(stepConfig),widthContent=this.currentStepNode.width()+16,targetOffsetLeft=target.offset().left-10,targetOffsetRight=target.offset().left+target.width()+10,placement=stepConfig.placement;return-1!==["left","right"].indexOf(placement)&&targetOffsetLeftdocument.documentElement.clientWidth&&(placement="top"),placement}positionBackdrop(stepConfig){if(stepConfig.backdrop){this.currentStepConfig.hasBackdrop=!0;let backdrop=(0,_jquery.default)('
');if(stepConfig.zIndex?"append"===stepConfig.attachPoint?stepConfig.attachTo.append(backdrop):backdrop.insertAfter(stepConfig.attachTo):(0,_jquery.default)("body").append(backdrop),this.isStepActuallyVisible(stepConfig)){let background=(0,_jquery.default)('[data-flexitour="step-background"]');background.length||(background=(0,_jquery.default)('
'));let targetNode=this.getStepTarget(stepConfig),buffer=10,colorNode=targetNode;buffer&&(colorNode=(0,_jquery.default)("body"));let drawertop=0;if(targetNode.parents('[data-usertour="scroller"]').length){const scrollerElement=targetNode.parents('[data-usertour="scroller"]'),navigationBuffer=scrollerElement.offset().top;scrollerElement.scrollTop()>=navigationBuffer&&(drawertop=scrollerElement.scrollTop()-navigationBuffer,background.css({position:"fixed"}))}background.css({width:targetNode.outerWidth()+buffer+buffer,height:targetNode.outerHeight()+buffer+buffer,left:targetNode.offset().left-buffer,top:targetNode.offset().top+drawertop-buffer,backgroundColor:this.calculateInherittedBackgroundColor(colorNode)}),targetNode.offset().left").hide();(0,_jquery.default)("body").append(fakeNode);let fakeElemColor=fakeNode.css("backgroundColor");for(fakeNode.remove(),elem=(0,_jquery.default)(elem);elem.length&&elem[0]!==document;){let color=elem.css("backgroundColor");if(color!==fakeElemColor)return color;elem=elem.parent()}return null}calculatePosition(elem){for(elem=(0,_jquery.default)(elem);elem.length&&elem[0]!==document;){let position=elem.css("position");if("static"!==position)return position;elem=elem.parent()}return null}accessibilityShow(){let hideFunction=function(child){let flexitourRole=child.data("flexitour");if(flexitourRole)switch(flexitourRole){case"container":case"target":return}child.attr("aria-hidden")||(child.attr("data-has-hidden",!0),Aria.hide(child))};this.currentStepNode.siblings().each((function(index,node){hideFunction((0,_jquery.default)(node))})),this.currentStepNode.parentsUntil("body").siblings().each((function(index,node){hideFunction((0,_jquery.default)(node))}))}accessibilityHide(){(0,_jquery.default)("[data-has-hidden]").each((function(index,node){var child;void 0!==(child=(0,_jquery.default)(node)).attr("data-has-hidden")&&(child.removeAttr("data-has-hidden"),Aria.unhide(child))}))}};return _exports.default=_default,_exports.default})); + +//# sourceMappingURL=tour.min.js.map \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/tour.min.js.map b/admin/tool/usertours/amd/build/tour.min.js.map index 266a79dba3d..1e58fd2b5ca 100644 --- a/admin/tool/usertours/amd/build/tour.min.js.map +++ b/admin/tool/usertours/amd/build/tour.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/tour.js"],"names":["Tour","config","init","eventHandlers","reset","originalConfiguration","configure","apply","arguments","storage","window","sessionStorage","storageKey","tourName","e","hide","resetStepListeners","steps","currentStepNumber","eventName","forEach","handler","addEventHandler","resetStepDefaults","template","templateContent","checkMinimumRequirements","Error","length","loadOriginalConfiguration","stepDefaults","setStepDefaults","$","extend","element","placement","delay","moveOnClick","moveAfterTime","orphan","direction","parseInt","stepNumber","setItem","code","DOMException","QUOTA_EXCEEDED_ERR","removeItem","getCurrentStepNumber","nextStepNumber","isStepPotentiallyVisible","getStepConfig","previousStepNumber","getNextStepNumber","stepConfig","isStepActuallyVisible","position","result","stepId","stepid","target","getStepTarget","is","gotoStep","getPreviousStepNumber","endTour","_gotoStep","delayed","setTimeout","bind","fn","stepRenderEvent","dispatchEvent","eventTypes","stepRender","defaultPrevented","renderStep","stepRendered","normalizeStepConfig","reflex","moveAfterClick","content","body","attachTo","attachPoint","first","detail","cancelable","tour","document","push","listeners","node","currentStepNode","args","proxy","next","handleKeyDown","targetNode","parents","listener","on","off","currentStepConfig","setCurrentStepNumber","getTemplateContent","find","html","title","nextBtn","endBtn","isLastStep","removeClass","addClass","prop","then","value","catch","attr","displaystepnumbers","stepsPotentiallyVisible","getPotentiallyVisibleSteps","totalStepsPotentiallyVisible","total","addStepToPage","processStepListeners","clone","animationTarget","stop","data","zIndex","calculateZIndex","css","positionBackdrop","append","top","left","animate","scrollTop","calculateScrollTop","promise","positionStep","revealStep","isOrphan","offset","calculateStepPositionInPage","currentStepPopper","Popper","removeOnDestroy","arrowElement","modifiers","enabled","applyStyle","onLoad","fadeIn","announceStep","focus","bodyRegion","headerRegion","accessibilityShow","tabbableSelector","keyCode","hasBackdrop","activeElement","stepTarget","tabbableNodes","dialogContainer","currentIndex","filter","index","has","each","nextIndex","nextNode","focusRelevant","shiftKey","closest","last","preventDefault","call","startAt","storageStartValue","getItem","storageStartAt","tourStartEvent","tourStart","tourRunning","tourStarted","startTour","tourEndEvent","tourEnd","previousTarget","tourEnded","transition","stepHideEvent","stepHide","destroy","fadeTime","remove","removeAttr","fadeOut","currentStepElement","accessibilityHide","stepHidden","viewportHeight","height","scrollParent","Math","max","min","ceil","stepHeight","viewportWidth","width","stepWidth","recalculatePlacement","flipBehavior","flip","behaviour","arrow","onCreate","recalculateArrowPosition","onUpdate","split","isVertical","indexOf","instance","popper","querySelector","stepElement","arrowHeight","parseFloat","getComputedStyle","arrowOffset","popperHeight","popperOffset","popperBorderWidth","popperBorderRadiusWidth","arrowPos","maxPos","minPos","newArrowPos","arrowWidth","popperWidth","background","widthContent","targetOffsetLeft","targetOffsetRight","documentElement","clientWidth","backdrop","insertAfter","buffer","colorNode","drawertop","scrollerElement","navigationBuffer","outerWidth","outerHeight","backgroundColor","calculateInherittedBackgroundColor","targetRadius","targetPosition","calculatePosition","fader","opacity","targetClone","elem","isNaN","parent","fakeNode","fakeElemColor","color","hideFunction","child","flexitourRole","hidden","Aria","siblings","parentsUntil","showFunction","unhide"],"mappings":"oPA+BA,OACA,OACA,O,m3DAYMA,CAAAA,CAAI,eAMN,WAAYC,CAAZ,CAAoB,oCAChB,KAAKC,IAAL,CAAUD,CAAV,CACH,CARK,qCAkBDA,CAlBC,CAkBO,CAET,KAAKE,aAAL,CAAqB,EAArB,CAGA,KAAKC,KAAL,GAGA,KAAKC,qBAAL,CAA6BJ,CAAM,EAAI,EAAvC,CAGA,KAAKK,SAAL,CAAeC,KAAf,CAAqB,IAArB,CAA2BC,SAA3B,EAEA,GAAI,CACA,KAAKC,OAAL,CAAeC,MAAM,CAACC,cA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,CAAI,CAACI,MAAL,CAAYP,CAAZ,CACH,CACJ,CARe,CAUhB,mCAA2BvG,IAA3B,CAAgC,SAASF,CAAT,CAAgB7E,CAAhB,CAAsB,CAClD4L,CAAY,CAAC,cAAE5L,CAAF,CAAD,CACf,CAFD,CAGH,CAzkDK,kB,WA4kDK5F,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 .\n\n/**\n * A user tour.\n *\n * @module tool_usertours/tour\n * @copyright 2018 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * A list of steps.\n *\n * @typedef {Object[]} StepList\n * @property {Number} stepId The id of the step in the database\n * @property {Number} position The position of the step within the tour (zero-indexed)\n */\n\nimport $ from 'jquery';\nimport * as Aria from 'core/aria';\nimport Popper from 'core/popper';\nimport {dispatchEvent} from 'core/event_dispatcher';\nimport {eventTypes} from './events';\nimport {get_string as getString} from 'core/str';\nimport {prefetchStrings} from 'core/prefetch';\n\n/**\n * A user tour.\n *\n * @class tool_usertours/tour\n * @property {boolean} tourRunning Whether the tour is currently running.\n */\nconst Tour = class {\n tourRunning = false;\n\n /**\n * @param {object} config The configuration object.\n */\n constructor(config) {\n this.init(config);\n }\n\n /**\n * Initialise the tour.\n *\n * @method init\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n init(config) {\n // Unset all handlers.\n this.eventHandlers = {};\n\n // Reset the current tour states.\n this.reset();\n\n // Store the initial configuration.\n this.originalConfiguration = config || {};\n\n // Apply configuration.\n this.configure.apply(this, arguments);\n\n try {\n this.storage = window.sessionStorage;\n this.storageKey = 'tourstate_' + this.tourName;\n } catch (e) {\n this.storage = false;\n this.storageKey = '';\n }\n\n prefetchStrings('tool_usertours', [\n 'nextstep_sequence',\n 'skip_tour'\n ]);\n\n return this;\n }\n\n /**\n * Reset the current tour state.\n *\n * @method reset\n * @chainable\n * @return {Object} this.\n */\n reset() {\n // Hide the current step.\n this.hide();\n\n // Unset all handlers.\n this.eventHandlers = [];\n\n // Unset all listeners.\n this.resetStepListeners();\n\n // Unset the original configuration.\n this.originalConfiguration = {};\n\n // Reset the current step number and list of steps.\n this.steps = [];\n\n // Reset the current step number.\n this.currentStepNumber = 0;\n\n return this;\n }\n\n /**\n * Prepare tour configuration.\n *\n * @method configure\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n configure(config) {\n if (typeof config === 'object') {\n // Tour name.\n if (typeof config.tourName !== 'undefined') {\n this.tourName = config.tourName;\n }\n\n // Set up eventHandlers.\n if (config.eventHandlers) {\n for (let eventName in config.eventHandlers) {\n config.eventHandlers[eventName].forEach(function(handler) {\n this.addEventHandler(eventName, handler);\n }, this);\n }\n }\n\n // Reset the step configuration.\n this.resetStepDefaults(true);\n\n // Configure the steps.\n if (typeof config.steps === 'object') {\n this.steps = config.steps;\n }\n\n if (typeof config.template !== 'undefined') {\n this.templateContent = config.template;\n }\n }\n\n // Check that we have enough to start the tour.\n this.checkMinimumRequirements();\n\n return this;\n }\n\n /**\n * Check that the configuration meets the minimum requirements.\n *\n * @method checkMinimumRequirements\n */\n checkMinimumRequirements() {\n // Need a tourName.\n if (!this.tourName) {\n throw new Error(\"Tour Name required\");\n }\n\n // Need a minimum of one step.\n if (!this.steps || !this.steps.length) {\n throw new Error(\"Steps must be specified\");\n }\n }\n\n /**\n * Reset step default configuration.\n *\n * @method resetStepDefaults\n * @param {Boolean} loadOriginalConfiguration Whether to load the original configuration supplied with the Tour.\n * @chainable\n * @return {Object} this.\n */\n resetStepDefaults(loadOriginalConfiguration) {\n if (typeof loadOriginalConfiguration === 'undefined') {\n loadOriginalConfiguration = true;\n }\n\n this.stepDefaults = {};\n if (!loadOriginalConfiguration || typeof this.originalConfiguration.stepDefaults === 'undefined') {\n this.setStepDefaults({});\n } else {\n this.setStepDefaults(this.originalConfiguration.stepDefaults);\n }\n\n return this;\n }\n\n /**\n * Set the step defaults.\n *\n * @method setStepDefaults\n * @param {Object} stepDefaults The step defaults to apply to all steps\n * @chainable\n * @return {Object} this.\n */\n setStepDefaults(stepDefaults) {\n if (!this.stepDefaults) {\n this.stepDefaults = {};\n }\n $.extend(\n this.stepDefaults,\n {\n element: '',\n placement: 'top',\n delay: 0,\n moveOnClick: false,\n moveAfterTime: 0,\n orphan: false,\n direction: 1,\n },\n stepDefaults\n );\n\n return this;\n }\n\n /**\n * Retrieve the current step number.\n *\n * @method getCurrentStepNumber\n * @return {Number} The current step number\n */\n getCurrentStepNumber() {\n return parseInt(this.currentStepNumber, 10);\n }\n\n /**\n * Store the current step number.\n *\n * @method setCurrentStepNumber\n * @param {Number} stepNumber The current step number\n * @chainable\n */\n setCurrentStepNumber(stepNumber) {\n this.currentStepNumber = stepNumber;\n if (this.storage) {\n try {\n this.storage.setItem(this.storageKey, stepNumber);\n } catch (e) {\n if (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n this.storage.removeItem(this.storageKey);\n }\n }\n }\n }\n\n /**\n * Get the next step number after the currently displayed step.\n *\n * @method getNextStepNumber\n * @param {Number} stepNumber The current step number\n * @return {Number} The next step number to display\n */\n getNextStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let nextStepNumber = stepNumber + 1;\n\n // Keep checking the remaining steps.\n while (nextStepNumber <= this.steps.length) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(nextStepNumber))) {\n return nextStepNumber;\n }\n nextStepNumber++;\n }\n\n return null;\n }\n\n /**\n * Get the previous step number before the currently displayed step.\n *\n * @method getPreviousStepNumber\n * @param {Number} stepNumber The current step number\n * @return {Number} The previous step number to display\n */\n getPreviousStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let previousStepNumber = stepNumber - 1;\n\n // Keep checking the remaining steps.\n while (previousStepNumber >= 0) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(previousStepNumber))) {\n return previousStepNumber;\n }\n previousStepNumber--;\n }\n\n return null;\n }\n\n /**\n * Is the step the final step number?\n *\n * @method isLastStep\n * @param {Number} stepNumber Step number to test\n * @return {Boolean} Whether the step is the final step\n */\n isLastStep(stepNumber) {\n let nextStepNumber = this.getNextStepNumber(stepNumber);\n\n return nextStepNumber === null;\n }\n\n /**\n * Is this step potentially visible?\n *\n * @method isStepPotentiallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is the potentially visible\n */\n isStepPotentiallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // If it is actually visible, it is already potentially visible.\n return true;\n }\n\n if (typeof stepConfig.orphan !== 'undefined' && stepConfig.orphan) {\n // Orphan steps have no target. They are always visible.\n return true;\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay) {\n // Only return true if the activated has not been used yet.\n return true;\n }\n\n // Not theoretically, or actually visible.\n return false;\n }\n\n /**\n * Get potentially visible steps in a tour.\n *\n * @returns {StepList} A list of ordered steps\n */\n getPotentiallyVisibleSteps() {\n let position = 1;\n let result = [];\n // Checking the total steps.\n for (let stepNumber = 0; stepNumber < this.steps.length; stepNumber++) {\n const stepConfig = this.getStepConfig(stepNumber);\n if (this.isStepPotentiallyVisible(stepConfig)) {\n result[stepNumber] = {stepId: stepConfig.stepid, position: position};\n position++;\n }\n }\n\n return result;\n }\n\n /**\n * Is this step actually visible?\n *\n * @method isStepActuallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is actually visible\n */\n isStepActuallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n let target = this.getStepTarget(stepConfig);\n if (target && target.length && target.is(':visible')) {\n // Without a target, there can be no step.\n return !!target.length;\n }\n\n return false;\n }\n\n /**\n * Go to the next step in the tour.\n *\n * @method next\n * @chainable\n * @return {Object} this.\n */\n next() {\n return this.gotoStep(this.getNextStepNumber());\n }\n\n /**\n * Go to the previous step in the tour.\n *\n * @method previous\n * @chainable\n * @return {Object} this.\n */\n previous() {\n return this.gotoStep(this.getPreviousStepNumber(), -1);\n }\n\n /**\n * Go to the specified step in the tour.\n *\n * @method gotoStep\n * @param {Number} stepNumber The step number to display\n * @param {Number} direction Next or previous step\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/stepRender\n * @fires tool_usertours/stepRendered\n * @fires tool_usertours/stepHide\n * @fires tool_usertours/stepHidden\n */\n gotoStep(stepNumber, direction) {\n if (stepNumber < 0) {\n return this.endTour();\n }\n\n let stepConfig = this.getStepConfig(stepNumber);\n if (stepConfig === null) {\n return this.endTour();\n }\n\n return this._gotoStep(stepConfig, direction);\n }\n\n _gotoStep(stepConfig, direction) {\n if (!stepConfig) {\n return this.endTour();\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay && !stepConfig.delayed) {\n stepConfig.delayed = true;\n window.setTimeout(this._gotoStep.bind(this), stepConfig.delay, stepConfig, direction);\n\n return this;\n } else if (!stepConfig.orphan && !this.isStepActuallyVisible(stepConfig)) {\n let fn = direction == -1 ? 'getPreviousStepNumber' : 'getNextStepNumber';\n return this.gotoStep(this[fn](stepConfig.stepNumber), direction);\n }\n\n this.hide();\n\n const stepRenderEvent = this.dispatchEvent(eventTypes.stepRender, {stepConfig}, true);\n if (!stepRenderEvent.defaultPrevented) {\n this.renderStep(stepConfig);\n this.dispatchEvent(eventTypes.stepRendered, {stepConfig});\n }\n\n return this;\n }\n\n /**\n * Fetch the normalised step configuration for the specified step number.\n *\n * @method getStepConfig\n * @param {Number} stepNumber The step number to fetch configuration for\n * @return {Object} The step configuration\n */\n getStepConfig(stepNumber) {\n if (stepNumber === null || stepNumber < 0 || stepNumber >= this.steps.length) {\n return null;\n }\n\n // Normalise the step configuration.\n let stepConfig = this.normalizeStepConfig(this.steps[stepNumber]);\n\n // Add the stepNumber to the stepConfig.\n stepConfig = $.extend(stepConfig, {stepNumber: stepNumber});\n\n return stepConfig;\n }\n\n /**\n * Normalise the supplied step configuration.\n *\n * @method normalizeStepConfig\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Object} The normalised step configuration\n */\n normalizeStepConfig(stepConfig) {\n\n if (typeof stepConfig.reflex !== 'undefined' && typeof stepConfig.moveAfterClick === 'undefined') {\n stepConfig.moveAfterClick = stepConfig.reflex;\n }\n\n if (typeof stepConfig.element !== 'undefined' && typeof stepConfig.target === 'undefined') {\n stepConfig.target = stepConfig.element;\n }\n\n if (typeof stepConfig.content !== 'undefined' && typeof stepConfig.body === 'undefined') {\n stepConfig.body = stepConfig.content;\n }\n\n stepConfig = $.extend({}, this.stepDefaults, stepConfig);\n\n stepConfig = $.extend({}, {\n attachTo: stepConfig.target,\n attachPoint: 'after',\n }, stepConfig);\n\n if (stepConfig.attachTo) {\n stepConfig.attachTo = $(stepConfig.attachTo).first();\n }\n\n return stepConfig;\n }\n\n /**\n * Fetch the actual step target from the selector.\n *\n * This should not be called until after any delay has completed.\n *\n * @method getStepTarget\n * @param {Object} stepConfig The step configuration\n * @return {$}\n */\n getStepTarget(stepConfig) {\n if (stepConfig.target) {\n return $(stepConfig.target);\n }\n\n return null;\n }\n\n /**\n * Fire any event handlers for the specified event.\n *\n * @param {String} eventName The name of the event\n * @param {Object} [detail={}] Any additional details to pass into the eveent\n * @param {Boolean} [cancelable=false] Whether preventDefault() can be called\n * @returns {CustomEvent}\n */\n dispatchEvent(\n eventName,\n detail = {},\n cancelable = false\n ) {\n return dispatchEvent(eventName, {\n // Add the tour to the detail.\n tour: this,\n ...detail,\n }, document, {\n cancelable,\n });\n }\n\n /**\n * @method addEventHandler\n * @param {string} eventName The name of the event to listen for\n * @param {function} handler The event handler to call\n * @return {Object} this.\n */\n addEventHandler(eventName, handler) {\n if (typeof this.eventHandlers[eventName] === 'undefined') {\n this.eventHandlers[eventName] = [];\n }\n\n this.eventHandlers[eventName].push(handler);\n\n return this;\n }\n\n /**\n * Process listeners for the step being shown.\n *\n * @method processStepListeners\n * @param {object} stepConfig The configuration for the step\n * @chainable\n * @return {Object} this.\n */\n processStepListeners(stepConfig) {\n this.listeners.push(\n // Next button.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"next\"]', $.proxy(this.next, this)]\n },\n\n // Close and end tour buttons.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"end\"]', $.proxy(this.endTour, this)]\n },\n\n // Click backdrop and hide tour.\n {\n node: $('[data-flexitour=\"backdrop\"]'),\n args: ['click', $.proxy(this.hide, this)]\n },\n\n // Keypresses.\n {\n node: $('body'),\n args: ['keydown', $.proxy(this.handleKeyDown, this)]\n });\n\n if (stepConfig.moveOnClick) {\n var targetNode = this.getStepTarget(stepConfig);\n this.listeners.push({\n node: targetNode,\n args: ['click', $.proxy(function(e) {\n if ($(e.target).parents('[data-flexitour=\"container\"]').length === 0) {\n // Ignore clicks when they are in the flexitour.\n window.setTimeout($.proxy(this.next, this), 500);\n }\n }, this)]\n });\n }\n\n this.listeners.forEach(function(listener) {\n listener.node.on.apply(listener.node, listener.args);\n });\n\n return this;\n }\n\n /**\n * Reset step listeners.\n *\n * @method resetStepListeners\n * @chainable\n * @return {Object} this.\n */\n resetStepListeners() {\n // Stop listening to all external handlers.\n if (this.listeners) {\n this.listeners.forEach(function(listener) {\n listener.node.off.apply(listener.node, listener.args);\n });\n }\n this.listeners = [];\n\n return this;\n }\n\n /**\n * The standard step renderer.\n *\n * @method renderStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n renderStep(stepConfig) {\n // Store the current step configuration for later.\n this.currentStepConfig = stepConfig;\n this.setCurrentStepNumber(stepConfig.stepNumber);\n\n // Fetch the template and convert it to a $ object.\n let template = $(this.getTemplateContent());\n\n // Title.\n template.find('[data-placeholder=\"title\"]')\n .html(stepConfig.title);\n\n // Body.\n template.find('[data-placeholder=\"body\"]')\n .html(stepConfig.body);\n\n // Buttons.\n const nextBtn = template.find('[data-role=\"next\"]');\n const endBtn = template.find('[data-role=\"end\"]');\n\n // Is this the final step?\n if (this.isLastStep(stepConfig.stepNumber)) {\n nextBtn.hide();\n endBtn.removeClass(\"btn-secondary\").addClass(\"btn-primary\");\n } else {\n nextBtn.prop('disabled', false);\n // Use Skip tour label for the End tour button.\n getString('skip_tour', 'tool_usertours').then(value => {\n endBtn.html(value);\n return;\n }).catch();\n }\n\n nextBtn.attr('role', 'button');\n endBtn.attr('role', 'button');\n\n if (this.originalConfiguration.displaystepnumbers) {\n const stepsPotentiallyVisible = this.getPotentiallyVisibleSteps();\n const totalStepsPotentiallyVisible = stepsPotentiallyVisible.length;\n const position = stepsPotentiallyVisible[stepConfig.stepNumber].position;\n if (totalStepsPotentiallyVisible > 1) {\n // Change the label of the Next button to include the sequence.\n getString('nextstep_sequence', 'tool_usertours',\n {position: position, total: totalStepsPotentiallyVisible}).then(value => {\n nextBtn.html(value);\n return;\n }).catch();\n }\n }\n\n // Replace the template with the updated version.\n stepConfig.template = template;\n\n // Add to the page.\n this.addStepToPage(stepConfig);\n\n // Process step listeners after adding to the page.\n // This uses the currentNode.\n this.processStepListeners(stepConfig);\n\n return this;\n }\n\n /**\n * Getter for the template content.\n *\n * @method getTemplateContent\n * @return {$}\n */\n getTemplateContent() {\n return $(this.templateContent).clone();\n }\n\n /**\n * Helper to add a step to the page.\n *\n * @method addStepToPage\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n addStepToPage(stepConfig) {\n // Create the stepNode from the template data.\n let currentStepNode = $('')\n .html(stepConfig.template)\n .hide();\n\n // The scroll animation occurs on the body or html.\n let animationTarget = $('body, html')\n .stop(true, true);\n\n if (this.isStepActuallyVisible(stepConfig)) {\n let targetNode = this.getStepTarget(stepConfig);\n\n if (targetNode.parents('[data-usertour=\"scroller\"]').length) {\n animationTarget = targetNode.parents('[data-usertour=\"scroller\"]');\n }\n\n targetNode.data('flexitour', 'target');\n\n let zIndex = this.calculateZIndex(targetNode);\n if (zIndex) {\n stepConfig.zIndex = zIndex + 1;\n }\n\n if (stepConfig.zIndex) {\n currentStepNode.css('zIndex', stepConfig.zIndex + 1);\n }\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n // Ensure that the step node is positioned.\n // Some situations mean that the value is not properly calculated without this step.\n this.currentStepNode.css({\n top: 0,\n left: 0,\n });\n\n animationTarget\n .animate({\n scrollTop: this.calculateScrollTop(stepConfig),\n }).promise().then(function() {\n this.positionStep(stepConfig);\n this.revealStep(stepConfig);\n return;\n }.bind(this))\n .catch(function() {\n // Silently fail.\n });\n\n } else if (stepConfig.orphan) {\n stepConfig.isOrphan = true;\n\n // This will be appended to the body instead.\n stepConfig.attachTo = $('body').first();\n stepConfig.attachPoint = 'append';\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n // This is an orphaned step.\n currentStepNode.addClass('orphan');\n\n // It lives in the body.\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n this.currentStepNode.offset(this.calculateStepPositionInPage());\n this.currentStepNode.css('position', 'fixed');\n\n this.currentStepPopper = new Popper(\n $('body'),\n this.currentStepNode[0], {\n removeOnDestroy: true,\n placement: stepConfig.placement + '-start',\n arrowElement: '[data-role=\"arrow\"]',\n // Empty the modifiers. We've already placed the step and don't want it moved.\n modifiers: {\n hide: {\n enabled: false,\n },\n applyStyle: {\n onLoad: null,\n enabled: false,\n },\n }\n }\n );\n\n this.revealStep(stepConfig);\n }\n\n return this;\n }\n\n /**\n * Make the given step visible.\n *\n * @method revealStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n revealStep(stepConfig) {\n // Fade the step in.\n this.currentStepNode.fadeIn('', $.proxy(function() {\n // Announce via ARIA.\n this.announceStep(stepConfig);\n\n // Focus on the current step Node.\n this.currentStepNode.focus();\n window.setTimeout($.proxy(function() {\n // After a brief delay, focus again.\n // There seems to be an issue with Jaws where it only reads the dialogue title initially.\n // This second focus helps it to read the full dialogue.\n if (this.currentStepNode) {\n this.currentStepNode.focus();\n }\n }, this), 100);\n\n }, this));\n\n return this;\n }\n\n /**\n * Helper to announce the step on the page.\n *\n * @method announceStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n announceStep(stepConfig) {\n // Setup the step Dialogue as per:\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_nonmodal\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_modal\n\n // Generate an ID for the current step node.\n let stepId = 'tour-step-' + this.tourName + '-' + stepConfig.stepNumber;\n this.currentStepNode.attr('id', stepId);\n\n let bodyRegion = this.currentStepNode.find('[data-placeholder=\"body\"]').first();\n bodyRegion.attr('id', stepId + '-body');\n bodyRegion.attr('role', 'document');\n\n let headerRegion = this.currentStepNode.find('[data-placeholder=\"title\"]').first();\n headerRegion.attr('id', stepId + '-title');\n headerRegion.attr('aria-labelledby', stepId + '-body');\n\n // Generally, a modal dialog has a role of dialog.\n this.currentStepNode.attr('role', 'dialog');\n this.currentStepNode.attr('tabindex', 0);\n this.currentStepNode.attr('aria-labelledby', stepId + '-title');\n this.currentStepNode.attr('aria-describedby', stepId + '-body');\n\n // Configure ARIA attributes on the target.\n let target = this.getStepTarget(stepConfig);\n if (target) {\n if (!target.attr('tabindex')) {\n target.attr('tabindex', 0);\n }\n\n target\n .data('original-describedby', target.attr('aria-describedby'))\n .attr('aria-describedby', stepId + '-body')\n ;\n }\n\n this.accessibilityShow(stepConfig);\n\n return this;\n }\n\n /**\n * Handle key down events.\n *\n * @method handleKeyDown\n * @param {EventFacade} e\n */\n handleKeyDown(e) {\n let tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], ';\n tabbableSelector += ':input:enabled, [tabindex], button:enabled';\n switch (e.keyCode) {\n case 27:\n this.endTour();\n break;\n\n // 9 == Tab - trap focus for items with a backdrop.\n case 9:\n // Tab must be handled on key up only in this instance.\n (function() {\n if (!this.currentStepConfig.hasBackdrop) {\n // Trapping tab focus is only handled for those steps with a backdrop.\n return;\n }\n\n // Find all tabbable locations.\n let activeElement = $(document.activeElement);\n let stepTarget = this.getStepTarget(this.currentStepConfig);\n let tabbableNodes = $(tabbableSelector);\n let dialogContainer = $('span[data-flexitour=\"container\"]');\n let currentIndex;\n // Filter out element which is not belong to target section or dialogue.\n if (stepTarget) {\n tabbableNodes = tabbableNodes.filter(function(index, element) {\n return stepTarget !== null\n && (stepTarget.has(element).length\n || dialogContainer.has(element).length\n || stepTarget.is(element)\n || dialogContainer.is(element));\n });\n }\n\n // Find index of focusing element.\n tabbableNodes.each(function(index, element) {\n if (activeElement.is(element)) {\n currentIndex = index;\n return false;\n }\n // Keep looping.\n return true;\n });\n\n let nextIndex;\n let nextNode;\n let focusRelevant;\n if (currentIndex != void 0) {\n let direction = 1;\n if (e.shiftKey) {\n direction = -1;\n }\n nextIndex = currentIndex;\n do {\n nextIndex += direction;\n nextNode = $(tabbableNodes[nextIndex]);\n } while (nextNode.length && nextNode.is(':disabled') || nextNode.is(':hidden'));\n if (nextNode.length) {\n // A new f\n focusRelevant = nextNode.closest(stepTarget).length;\n focusRelevant = focusRelevant || nextNode.closest(this.currentStepNode).length;\n } else {\n // Unable to find the target somehow.\n focusRelevant = false;\n }\n }\n\n if (focusRelevant) {\n nextNode.focus();\n } else {\n if (e.shiftKey) {\n // Focus on the last tabbable node in the step.\n this.currentStepNode.find(tabbableSelector).last().focus();\n } else {\n if (this.currentStepConfig.isOrphan) {\n // Focus on the step - there is no target.\n this.currentStepNode.focus();\n } else {\n // Focus on the step target.\n stepTarget.focus();\n }\n }\n }\n e.preventDefault();\n }).call(this);\n break;\n }\n }\n\n /**\n * Start the current tour.\n *\n * @method startTour\n * @param {Number} startAt Which step number to start at. If not specified, starts at the last point.\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/tourStart\n * @fires tool_usertours/tourStarted\n */\n startTour(startAt) {\n if (this.storage && typeof startAt === 'undefined') {\n let storageStartValue = this.storage.getItem(this.storageKey);\n if (storageStartValue) {\n let storageStartAt = parseInt(storageStartValue, 10);\n if (storageStartAt <= this.steps.length) {\n startAt = storageStartAt;\n }\n }\n }\n\n if (typeof startAt === 'undefined') {\n startAt = this.getCurrentStepNumber();\n }\n\n const tourStartEvent = this.dispatchEvent(eventTypes.tourStart, {startAt}, true);\n if (!tourStartEvent.defaultPrevented) {\n this.gotoStep(startAt);\n this.tourRunning = true;\n this.dispatchEvent(eventTypes.tourStarted, {startAt});\n }\n\n return this;\n }\n\n /**\n * Restart the tour from the beginning, resetting the completionlag.\n *\n * @method restartTour\n * @chainable\n * @return {Object} this.\n */\n restartTour() {\n return this.startTour(0);\n }\n\n /**\n * End the current tour.\n *\n * @method endTour\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/tourEnd\n * @fires tool_usertours/tourEnded\n */\n endTour() {\n const tourEndEvent = this.dispatchEvent(eventTypes.tourEnd, {}, true);\n if (tourEndEvent.defaultPrevented) {\n return this;\n }\n\n if (this.currentStepConfig) {\n let previousTarget = this.getStepTarget(this.currentStepConfig);\n if (previousTarget) {\n if (!previousTarget.attr('tabindex')) {\n previousTarget.attr('tabindex', '-1');\n }\n previousTarget.focus();\n }\n }\n\n this.hide(true);\n\n this.tourRunning = false;\n this.dispatchEvent(eventTypes.tourEnded);\n\n return this;\n }\n\n /**\n * Hide any currently visible steps.\n *\n * @method hide\n * @param {Bool} transition Animate the visibility change\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/stepHide\n * @fires tool_usertours/stepHidden\n */\n hide(transition) {\n const stepHideEvent = this.dispatchEvent(eventTypes.stepHide, {}, true);\n if (stepHideEvent.defaultPrevented) {\n return this;\n }\n\n if (this.currentStepNode && this.currentStepNode.length) {\n this.currentStepNode.hide();\n if (this.currentStepPopper) {\n this.currentStepPopper.destroy();\n }\n }\n\n // Restore original target configuration.\n if (this.currentStepConfig) {\n let target = this.getStepTarget(this.currentStepConfig);\n if (target) {\n if (target.data('original-labelledby')) {\n target.attr('aria-labelledby', target.data('original-labelledby'));\n }\n\n if (target.data('original-describedby')) {\n target.attr('aria-describedby', target.data('original-describedby'));\n }\n\n if (target.data('original-tabindex')) {\n target.attr('tabindex', target.data('tabindex'));\n }\n }\n\n // Clear the step configuration.\n this.currentStepConfig = null;\n }\n\n let fadeTime = 0;\n if (transition) {\n fadeTime = 400;\n }\n\n // Remove the backdrop features.\n $('[data-flexitour=\"step-background\"]').remove();\n $('[data-flexitour=\"step-backdrop\"]').removeAttr('data-flexitour');\n $('[data-flexitour=\"backdrop\"]').fadeOut(fadeTime, function() {\n $(this).remove();\n });\n\n // Remove aria-describedby and tabindex attributes.\n if (this.currentStepNode && this.currentStepNode.length) {\n let stepId = this.currentStepNode.attr('id');\n if (stepId) {\n let currentStepElement = '[aria-describedby=\"' + stepId + '-body\"]';\n $(currentStepElement).removeAttr('tabindex');\n $(currentStepElement).removeAttr('aria-describedby');\n }\n }\n\n // Reset the listeners.\n this.resetStepListeners();\n\n this.accessibilityHide();\n\n this.dispatchEvent(eventTypes.stepHidden);\n\n this.currentStepNode = null;\n this.currentStepPopper = null;\n return this;\n }\n\n /**\n * Show the current steps.\n *\n * @method show\n * @chainable\n * @return {Object} this.\n */\n show() {\n // Show the current step.\n let startAt = this.getCurrentStepNumber();\n\n return this.gotoStep(startAt);\n }\n\n /**\n * Return the current step node.\n *\n * @method getStepContainer\n * @return {jQuery}\n */\n getStepContainer() {\n return $(this.currentStepNode);\n }\n\n /**\n * Calculate scrollTop.\n *\n * @method calculateScrollTop\n * @param {Object} stepConfig The step configuration of the step\n * @return {Number}\n */\n calculateScrollTop(stepConfig) {\n let viewportHeight = $(window).height();\n let targetNode = this.getStepTarget(stepConfig);\n\n let scrollParent = $(window);\n if (targetNode.parents('[data-usertour=\"scroller\"]').length) {\n scrollParent = targetNode.parents('[data-usertour=\"scroller\"]');\n }\n let scrollTop = scrollParent.scrollTop();\n\n if (stepConfig.placement === 'top') {\n // If the placement is top, center scroll at the top of the target.\n scrollTop = targetNode.offset().top - (viewportHeight / 2);\n } else if (stepConfig.placement === 'bottom') {\n // If the placement is bottom, center scroll at the bottom of the target.\n scrollTop = targetNode.offset().top + targetNode.height() + scrollTop - (viewportHeight / 2);\n } else if (targetNode.height() <= (viewportHeight * 0.8)) {\n // If the placement is left/right, and the target fits in the viewport, centre screen on the target\n scrollTop = targetNode.offset().top - ((viewportHeight - targetNode.height()) / 2);\n } else {\n // If the placement is left/right, and the target is bigger than the viewport, set scrollTop to target.top + buffer\n // and change step attachmentTarget to top+.\n scrollTop = targetNode.offset().top - (viewportHeight * 0.2);\n }\n\n // Never scroll over the top.\n scrollTop = Math.max(0, scrollTop);\n\n // Never scroll beyond the bottom.\n scrollTop = Math.min($(document).height() - viewportHeight, scrollTop);\n\n return Math.ceil(scrollTop);\n }\n\n /**\n * Calculate dialogue position for page middle.\n *\n * @method calculateScrollTop\n * @return {Number}\n */\n calculateStepPositionInPage() {\n let viewportHeight = $(window).height();\n let stepHeight = this.currentStepNode.height();\n\n let viewportWidth = $(window).width();\n let stepWidth = this.currentStepNode.width();\n\n return {\n top: Math.ceil((viewportHeight - stepHeight) / 2),\n left: Math.ceil((viewportWidth - stepWidth) / 2)\n };\n }\n\n /**\n * Position the step on the page.\n *\n * @method positionStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionStep(stepConfig) {\n let content = this.currentStepNode;\n if (!content || !content.length) {\n // Unable to find the step node.\n return this;\n }\n\n stepConfig.placement = this.recalculatePlacement(stepConfig);\n let flipBehavior;\n switch (stepConfig.placement) {\n case 'left':\n flipBehavior = ['left', 'right', 'top', 'bottom'];\n break;\n case 'right':\n flipBehavior = ['right', 'left', 'top', 'bottom'];\n break;\n case 'top':\n flipBehavior = ['top', 'bottom', 'right', 'left'];\n break;\n case 'bottom':\n flipBehavior = ['bottom', 'top', 'right', 'left'];\n break;\n default:\n flipBehavior = 'flip';\n break;\n }\n\n let target = this.getStepTarget(stepConfig);\n var config = {\n placement: stepConfig.placement + '-start',\n removeOnDestroy: true,\n modifiers: {\n flip: {\n behaviour: flipBehavior,\n },\n arrow: {\n element: '[data-role=\"arrow\"]',\n },\n },\n onCreate: function(data) {\n recalculateArrowPosition(data);\n },\n onUpdate: function(data) {\n recalculateArrowPosition(data);\n },\n };\n\n let recalculateArrowPosition = function(data) {\n let placement = data.placement.split('-')[0];\n const isVertical = ['left', 'right'].indexOf(placement) !== -1;\n const arrowElement = data.instance.popper.querySelector('[data-role=\"arrow\"]');\n const stepElement = $(data.instance.popper.querySelector('[data-role=\"flexitour-step\"]'));\n if (isVertical) {\n let arrowHeight = parseFloat(window.getComputedStyle(arrowElement).height);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).top);\n let popperHeight = parseFloat(window.getComputedStyle(data.instance.popper).height);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).top);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowHeight / 2);\n let maxPos = popperHeight + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperHeight / 2)) {\n newArrowPos = maxPos - arrowHeight;\n } else {\n newArrowPos = minPos + arrowHeight;\n }\n $(arrowElement).css('top', newArrowPos);\n }\n } else {\n let arrowWidth = parseFloat(window.getComputedStyle(arrowElement).width);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).left);\n let popperWidth = parseFloat(window.getComputedStyle(data.instance.popper).width);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).left);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowWidth / 2);\n let maxPos = popperWidth + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperWidth / 2)) {\n newArrowPos = maxPos - arrowWidth;\n } else {\n newArrowPos = minPos + arrowWidth;\n }\n $(arrowElement).css('left', newArrowPos);\n }\n }\n };\n\n let background = $('[data-flexitour=\"step-background\"]');\n if (background.length) {\n target = background;\n }\n this.currentStepPopper = new Popper(target, content[0], config);\n\n return this;\n }\n\n /**\n * For left/right placement, checks that there is room for the step at current window size.\n *\n * If there is not enough room, changes placement to 'top'.\n *\n * @method recalculatePlacement\n * @param {Object} stepConfig The step configuration of the step\n * @return {String} The placement after recalculate\n */\n recalculatePlacement(stepConfig) {\n const buffer = 10;\n const arrowWidth = 16;\n let target = this.getStepTarget(stepConfig);\n let widthContent = this.currentStepNode.width() + arrowWidth;\n let targetOffsetLeft = target.offset().left - buffer;\n let targetOffsetRight = target.offset().left + target.width() + buffer;\n let placement = stepConfig.placement;\n\n if (['left', 'right'].indexOf(placement) !== -1) {\n if ((targetOffsetLeft < (widthContent + buffer)) &&\n ((targetOffsetRight + widthContent + buffer) > document.documentElement.clientWidth)) {\n placement = 'top';\n }\n }\n return placement;\n }\n\n /**\n * Add the backdrop.\n *\n * @method positionBackdrop\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionBackdrop(stepConfig) {\n if (stepConfig.backdrop) {\n this.currentStepConfig.hasBackdrop = true;\n let backdrop = $('
');\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(backdrop);\n } else {\n backdrop.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(backdrop);\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // The step has a visible target.\n // Punch a hole through the backdrop.\n let background = $('[data-flexitour=\"step-background\"]');\n if (!background.length) {\n background = $('
');\n }\n\n let targetNode = this.getStepTarget(stepConfig);\n\n let buffer = 10;\n\n let colorNode = targetNode;\n if (buffer) {\n colorNode = $('body');\n }\n\n let drawertop = 0;\n if (targetNode.parents('[data-usertour=\"scroller\"]').length) {\n const scrollerElement = targetNode.parents('[data-usertour=\"scroller\"]');\n const navigationBuffer = scrollerElement.offset().top;\n if (scrollerElement.scrollTop() >= navigationBuffer) {\n drawertop = scrollerElement.scrollTop() - navigationBuffer;\n background.css({\n position: 'fixed'\n });\n }\n }\n\n background.css({\n width: targetNode.outerWidth() + buffer + buffer,\n height: targetNode.outerHeight() + buffer + buffer,\n left: targetNode.offset().left - buffer,\n top: targetNode.offset().top + drawertop - buffer,\n backgroundColor: this.calculateInherittedBackgroundColor(colorNode),\n });\n\n if (targetNode.offset().left < buffer) {\n background.css({\n width: targetNode.outerWidth() + targetNode.offset().left + buffer,\n left: targetNode.offset().left,\n });\n }\n\n if ((targetNode.offset().top + drawertop) < buffer) {\n background.css({\n height: targetNode.outerHeight() + targetNode.offset().top + buffer,\n top: targetNode.offset().top,\n });\n }\n\n let targetRadius = targetNode.css('borderRadius');\n if (targetRadius && targetRadius !== $('body').css('borderRadius')) {\n background.css('borderRadius', targetRadius);\n }\n\n let targetPosition = this.calculatePosition(targetNode);\n if (targetPosition === 'fixed') {\n background.css('top', 0);\n } else if (targetPosition === 'absolute') {\n background.css('position', 'fixed');\n }\n\n let fader = background.clone();\n fader.css({\n backgroundColor: backdrop.css('backgroundColor'),\n opacity: backdrop.css('opacity'),\n });\n fader.attr('data-flexitour', 'step-background-fader');\n\n if (targetNode.parents('[data-region=\"fixed-drawer\"]').length) {\n let targetClone = targetNode.clone();\n background.append(targetClone);\n }\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(background);\n } else {\n fader.insertAfter(stepConfig.attachTo);\n background.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(fader);\n $('body').append(background);\n }\n\n // Add the backdrop data to the actual target.\n // This is the part which actually does the work.\n targetNode.attr('data-flexitour', 'step-backdrop');\n\n if (stepConfig.zIndex) {\n backdrop.css('zIndex', stepConfig.zIndex);\n background.css('zIndex', stepConfig.zIndex + 1);\n targetNode.css('zIndex', stepConfig.zIndex + 2);\n }\n\n fader.fadeOut('2000', function() {\n $(this).remove();\n });\n }\n }\n return this;\n }\n\n /**\n * Calculate the inheritted z-index.\n *\n * @method calculateZIndex\n * @param {jQuery} elem The element to calculate z-index for\n * @return {Number} Calculated z-index\n */\n calculateZIndex(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n // Ignore z-index if position is set to a value where z-index is ignored by the browser\n // This makes behavior of this function consistent across browsers\n // WebKit always returns auto if the element is positioned.\n let position = elem.css(\"position\");\n if (position === \"absolute\" || position === \"relative\" || position === \"fixed\") {\n // IE returns 0 when zIndex is not specified\n // other browsers return a string\n // we ignore the case of nested elements with an explicit value of 0\n //
\n let value = parseInt(elem.css(\"zIndex\"), 10);\n if (!isNaN(value) && value !== 0) {\n return value;\n }\n }\n elem = elem.parent();\n }\n\n return 0;\n }\n\n /**\n * Calculate the inheritted background colour.\n *\n * @method calculateInherittedBackgroundColor\n * @param {jQuery} elem The element to calculate colour for\n * @return {String} Calculated background colour\n */\n calculateInherittedBackgroundColor(elem) {\n // Use a fake node to compare each element against.\n let fakeNode = $('
').hide();\n $('body').append(fakeNode);\n let fakeElemColor = fakeNode.css('backgroundColor');\n fakeNode.remove();\n\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let color = elem.css('backgroundColor');\n if (color !== fakeElemColor) {\n return color;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Calculate the inheritted position.\n *\n * @method calculatePosition\n * @param {jQuery} elem The element to calculate position for\n * @return {String} Calculated position\n */\n calculatePosition(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let position = elem.css('position');\n if (position !== 'static') {\n return position;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Perform accessibility changes for step shown.\n *\n * This will add aria-hidden=\"true\" to all siblings and parent siblings.\n *\n * @method accessibilityShow\n */\n accessibilityShow() {\n let stateHolder = 'data-has-hidden';\n let attrName = 'aria-hidden';\n let hideFunction = function(child) {\n let flexitourRole = child.data('flexitour');\n if (flexitourRole) {\n switch (flexitourRole) {\n case 'container':\n case 'target':\n return;\n }\n }\n\n let hidden = child.attr(attrName);\n if (!hidden) {\n child.attr(stateHolder, true);\n Aria.hide(child);\n }\n };\n\n this.currentStepNode.siblings().each(function(index, node) {\n hideFunction($(node));\n });\n this.currentStepNode.parentsUntil('body').siblings().each(function(index, node) {\n hideFunction($(node));\n });\n }\n\n /**\n * Perform accessibility changes for step hidden.\n *\n * This will remove any newly added aria-hidden=\"true\".\n *\n * @method accessibilityHide\n */\n accessibilityHide() {\n let stateHolder = 'data-has-hidden';\n let showFunction = function(child) {\n let hidden = child.attr(stateHolder);\n if (typeof hidden !== 'undefined') {\n child.removeAttr(stateHolder);\n Aria.unhide(child);\n }\n };\n\n $('[' + stateHolder + ']').each(function(index, node) {\n showFunction($(node));\n });\n }\n};\n\nexport default Tour;\n"],"file":"tour.min.js"} \ No newline at end of file +{"version":3,"file":"tour.min.js","sources":["../src/tour.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 * A user tour.\n *\n * @module tool_usertours/tour\n * @copyright 2018 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * A list of steps.\n *\n * @typedef {Object[]} StepList\n * @property {Number} stepId The id of the step in the database\n * @property {Number} position The position of the step within the tour (zero-indexed)\n */\n\nimport $ from 'jquery';\nimport * as Aria from 'core/aria';\nimport Popper from 'core/popper';\nimport {dispatchEvent} from 'core/event_dispatcher';\nimport {eventTypes} from './events';\nimport {get_string as getString} from 'core/str';\nimport {prefetchStrings} from 'core/prefetch';\n\n/**\n * A user tour.\n *\n * @class tool_usertours/tour\n * @property {boolean} tourRunning Whether the tour is currently running.\n */\nconst Tour = class {\n tourRunning = false;\n\n /**\n * @param {object} config The configuration object.\n */\n constructor(config) {\n this.init(config);\n }\n\n /**\n * Initialise the tour.\n *\n * @method init\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n init(config) {\n // Unset all handlers.\n this.eventHandlers = {};\n\n // Reset the current tour states.\n this.reset();\n\n // Store the initial configuration.\n this.originalConfiguration = config || {};\n\n // Apply configuration.\n this.configure.apply(this, arguments);\n\n try {\n this.storage = window.sessionStorage;\n this.storageKey = 'tourstate_' + this.tourName;\n } catch (e) {\n this.storage = false;\n this.storageKey = '';\n }\n\n prefetchStrings('tool_usertours', [\n 'nextstep_sequence',\n 'skip_tour'\n ]);\n\n return this;\n }\n\n /**\n * Reset the current tour state.\n *\n * @method reset\n * @chainable\n * @return {Object} this.\n */\n reset() {\n // Hide the current step.\n this.hide();\n\n // Unset all handlers.\n this.eventHandlers = [];\n\n // Unset all listeners.\n this.resetStepListeners();\n\n // Unset the original configuration.\n this.originalConfiguration = {};\n\n // Reset the current step number and list of steps.\n this.steps = [];\n\n // Reset the current step number.\n this.currentStepNumber = 0;\n\n return this;\n }\n\n /**\n * Prepare tour configuration.\n *\n * @method configure\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n configure(config) {\n if (typeof config === 'object') {\n // Tour name.\n if (typeof config.tourName !== 'undefined') {\n this.tourName = config.tourName;\n }\n\n // Set up eventHandlers.\n if (config.eventHandlers) {\n for (let eventName in config.eventHandlers) {\n config.eventHandlers[eventName].forEach(function(handler) {\n this.addEventHandler(eventName, handler);\n }, this);\n }\n }\n\n // Reset the step configuration.\n this.resetStepDefaults(true);\n\n // Configure the steps.\n if (typeof config.steps === 'object') {\n this.steps = config.steps;\n }\n\n if (typeof config.template !== 'undefined') {\n this.templateContent = config.template;\n }\n }\n\n // Check that we have enough to start the tour.\n this.checkMinimumRequirements();\n\n return this;\n }\n\n /**\n * Check that the configuration meets the minimum requirements.\n *\n * @method checkMinimumRequirements\n */\n checkMinimumRequirements() {\n // Need a tourName.\n if (!this.tourName) {\n throw new Error(\"Tour Name required\");\n }\n\n // Need a minimum of one step.\n if (!this.steps || !this.steps.length) {\n throw new Error(\"Steps must be specified\");\n }\n }\n\n /**\n * Reset step default configuration.\n *\n * @method resetStepDefaults\n * @param {Boolean} loadOriginalConfiguration Whether to load the original configuration supplied with the Tour.\n * @chainable\n * @return {Object} this.\n */\n resetStepDefaults(loadOriginalConfiguration) {\n if (typeof loadOriginalConfiguration === 'undefined') {\n loadOriginalConfiguration = true;\n }\n\n this.stepDefaults = {};\n if (!loadOriginalConfiguration || typeof this.originalConfiguration.stepDefaults === 'undefined') {\n this.setStepDefaults({});\n } else {\n this.setStepDefaults(this.originalConfiguration.stepDefaults);\n }\n\n return this;\n }\n\n /**\n * Set the step defaults.\n *\n * @method setStepDefaults\n * @param {Object} stepDefaults The step defaults to apply to all steps\n * @chainable\n * @return {Object} this.\n */\n setStepDefaults(stepDefaults) {\n if (!this.stepDefaults) {\n this.stepDefaults = {};\n }\n $.extend(\n this.stepDefaults,\n {\n element: '',\n placement: 'top',\n delay: 0,\n moveOnClick: false,\n moveAfterTime: 0,\n orphan: false,\n direction: 1,\n },\n stepDefaults\n );\n\n return this;\n }\n\n /**\n * Retrieve the current step number.\n *\n * @method getCurrentStepNumber\n * @return {Number} The current step number\n */\n getCurrentStepNumber() {\n return parseInt(this.currentStepNumber, 10);\n }\n\n /**\n * Store the current step number.\n *\n * @method setCurrentStepNumber\n * @param {Number} stepNumber The current step number\n * @chainable\n */\n setCurrentStepNumber(stepNumber) {\n this.currentStepNumber = stepNumber;\n if (this.storage) {\n try {\n this.storage.setItem(this.storageKey, stepNumber);\n } catch (e) {\n if (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n this.storage.removeItem(this.storageKey);\n }\n }\n }\n }\n\n /**\n * Get the next step number after the currently displayed step.\n *\n * @method getNextStepNumber\n * @param {Number} stepNumber The current step number\n * @return {Number} The next step number to display\n */\n getNextStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let nextStepNumber = stepNumber + 1;\n\n // Keep checking the remaining steps.\n while (nextStepNumber <= this.steps.length) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(nextStepNumber))) {\n return nextStepNumber;\n }\n nextStepNumber++;\n }\n\n return null;\n }\n\n /**\n * Get the previous step number before the currently displayed step.\n *\n * @method getPreviousStepNumber\n * @param {Number} stepNumber The current step number\n * @return {Number} The previous step number to display\n */\n getPreviousStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let previousStepNumber = stepNumber - 1;\n\n // Keep checking the remaining steps.\n while (previousStepNumber >= 0) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(previousStepNumber))) {\n return previousStepNumber;\n }\n previousStepNumber--;\n }\n\n return null;\n }\n\n /**\n * Is the step the final step number?\n *\n * @method isLastStep\n * @param {Number} stepNumber Step number to test\n * @return {Boolean} Whether the step is the final step\n */\n isLastStep(stepNumber) {\n let nextStepNumber = this.getNextStepNumber(stepNumber);\n\n return nextStepNumber === null;\n }\n\n /**\n * Is this step potentially visible?\n *\n * @method isStepPotentiallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is the potentially visible\n */\n isStepPotentiallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // If it is actually visible, it is already potentially visible.\n return true;\n }\n\n if (typeof stepConfig.orphan !== 'undefined' && stepConfig.orphan) {\n // Orphan steps have no target. They are always visible.\n return true;\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay) {\n // Only return true if the activated has not been used yet.\n return true;\n }\n\n // Not theoretically, or actually visible.\n return false;\n }\n\n /**\n * Get potentially visible steps in a tour.\n *\n * @returns {StepList} A list of ordered steps\n */\n getPotentiallyVisibleSteps() {\n let position = 1;\n let result = [];\n // Checking the total steps.\n for (let stepNumber = 0; stepNumber < this.steps.length; stepNumber++) {\n const stepConfig = this.getStepConfig(stepNumber);\n if (this.isStepPotentiallyVisible(stepConfig)) {\n result[stepNumber] = {stepId: stepConfig.stepid, position: position};\n position++;\n }\n }\n\n return result;\n }\n\n /**\n * Is this step actually visible?\n *\n * @method isStepActuallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is actually visible\n */\n isStepActuallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n let target = this.getStepTarget(stepConfig);\n if (target && target.length && target.is(':visible')) {\n // Without a target, there can be no step.\n return !!target.length;\n }\n\n return false;\n }\n\n /**\n * Go to the next step in the tour.\n *\n * @method next\n * @chainable\n * @return {Object} this.\n */\n next() {\n return this.gotoStep(this.getNextStepNumber());\n }\n\n /**\n * Go to the previous step in the tour.\n *\n * @method previous\n * @chainable\n * @return {Object} this.\n */\n previous() {\n return this.gotoStep(this.getPreviousStepNumber(), -1);\n }\n\n /**\n * Go to the specified step in the tour.\n *\n * @method gotoStep\n * @param {Number} stepNumber The step number to display\n * @param {Number} direction Next or previous step\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/stepRender\n * @fires tool_usertours/stepRendered\n * @fires tool_usertours/stepHide\n * @fires tool_usertours/stepHidden\n */\n gotoStep(stepNumber, direction) {\n if (stepNumber < 0) {\n return this.endTour();\n }\n\n let stepConfig = this.getStepConfig(stepNumber);\n if (stepConfig === null) {\n return this.endTour();\n }\n\n return this._gotoStep(stepConfig, direction);\n }\n\n _gotoStep(stepConfig, direction) {\n if (!stepConfig) {\n return this.endTour();\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay && !stepConfig.delayed) {\n stepConfig.delayed = true;\n window.setTimeout(this._gotoStep.bind(this), stepConfig.delay, stepConfig, direction);\n\n return this;\n } else if (!stepConfig.orphan && !this.isStepActuallyVisible(stepConfig)) {\n let fn = direction == -1 ? 'getPreviousStepNumber' : 'getNextStepNumber';\n return this.gotoStep(this[fn](stepConfig.stepNumber), direction);\n }\n\n this.hide();\n\n const stepRenderEvent = this.dispatchEvent(eventTypes.stepRender, {stepConfig}, true);\n if (!stepRenderEvent.defaultPrevented) {\n this.renderStep(stepConfig);\n this.dispatchEvent(eventTypes.stepRendered, {stepConfig});\n }\n\n return this;\n }\n\n /**\n * Fetch the normalised step configuration for the specified step number.\n *\n * @method getStepConfig\n * @param {Number} stepNumber The step number to fetch configuration for\n * @return {Object} The step configuration\n */\n getStepConfig(stepNumber) {\n if (stepNumber === null || stepNumber < 0 || stepNumber >= this.steps.length) {\n return null;\n }\n\n // Normalise the step configuration.\n let stepConfig = this.normalizeStepConfig(this.steps[stepNumber]);\n\n // Add the stepNumber to the stepConfig.\n stepConfig = $.extend(stepConfig, {stepNumber: stepNumber});\n\n return stepConfig;\n }\n\n /**\n * Normalise the supplied step configuration.\n *\n * @method normalizeStepConfig\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Object} The normalised step configuration\n */\n normalizeStepConfig(stepConfig) {\n\n if (typeof stepConfig.reflex !== 'undefined' && typeof stepConfig.moveAfterClick === 'undefined') {\n stepConfig.moveAfterClick = stepConfig.reflex;\n }\n\n if (typeof stepConfig.element !== 'undefined' && typeof stepConfig.target === 'undefined') {\n stepConfig.target = stepConfig.element;\n }\n\n if (typeof stepConfig.content !== 'undefined' && typeof stepConfig.body === 'undefined') {\n stepConfig.body = stepConfig.content;\n }\n\n stepConfig = $.extend({}, this.stepDefaults, stepConfig);\n\n stepConfig = $.extend({}, {\n attachTo: stepConfig.target,\n attachPoint: 'after',\n }, stepConfig);\n\n if (stepConfig.attachTo) {\n stepConfig.attachTo = $(stepConfig.attachTo).first();\n }\n\n return stepConfig;\n }\n\n /**\n * Fetch the actual step target from the selector.\n *\n * This should not be called until after any delay has completed.\n *\n * @method getStepTarget\n * @param {Object} stepConfig The step configuration\n * @return {$}\n */\n getStepTarget(stepConfig) {\n if (stepConfig.target) {\n return $(stepConfig.target);\n }\n\n return null;\n }\n\n /**\n * Fire any event handlers for the specified event.\n *\n * @param {String} eventName The name of the event\n * @param {Object} [detail={}] Any additional details to pass into the eveent\n * @param {Boolean} [cancelable=false] Whether preventDefault() can be called\n * @returns {CustomEvent}\n */\n dispatchEvent(\n eventName,\n detail = {},\n cancelable = false\n ) {\n return dispatchEvent(eventName, {\n // Add the tour to the detail.\n tour: this,\n ...detail,\n }, document, {\n cancelable,\n });\n }\n\n /**\n * @method addEventHandler\n * @param {string} eventName The name of the event to listen for\n * @param {function} handler The event handler to call\n * @return {Object} this.\n */\n addEventHandler(eventName, handler) {\n if (typeof this.eventHandlers[eventName] === 'undefined') {\n this.eventHandlers[eventName] = [];\n }\n\n this.eventHandlers[eventName].push(handler);\n\n return this;\n }\n\n /**\n * Process listeners for the step being shown.\n *\n * @method processStepListeners\n * @param {object} stepConfig The configuration for the step\n * @chainable\n * @return {Object} this.\n */\n processStepListeners(stepConfig) {\n this.listeners.push(\n // Next button.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"next\"]', $.proxy(this.next, this)]\n },\n\n // Close and end tour buttons.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"end\"]', $.proxy(this.endTour, this)]\n },\n\n // Click backdrop and hide tour.\n {\n node: $('[data-flexitour=\"backdrop\"]'),\n args: ['click', $.proxy(this.hide, this)]\n },\n\n // Keypresses.\n {\n node: $('body'),\n args: ['keydown', $.proxy(this.handleKeyDown, this)]\n });\n\n if (stepConfig.moveOnClick) {\n var targetNode = this.getStepTarget(stepConfig);\n this.listeners.push({\n node: targetNode,\n args: ['click', $.proxy(function(e) {\n if ($(e.target).parents('[data-flexitour=\"container\"]').length === 0) {\n // Ignore clicks when they are in the flexitour.\n window.setTimeout($.proxy(this.next, this), 500);\n }\n }, this)]\n });\n }\n\n this.listeners.forEach(function(listener) {\n listener.node.on.apply(listener.node, listener.args);\n });\n\n return this;\n }\n\n /**\n * Reset step listeners.\n *\n * @method resetStepListeners\n * @chainable\n * @return {Object} this.\n */\n resetStepListeners() {\n // Stop listening to all external handlers.\n if (this.listeners) {\n this.listeners.forEach(function(listener) {\n listener.node.off.apply(listener.node, listener.args);\n });\n }\n this.listeners = [];\n\n return this;\n }\n\n /**\n * The standard step renderer.\n *\n * @method renderStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n renderStep(stepConfig) {\n // Store the current step configuration for later.\n this.currentStepConfig = stepConfig;\n this.setCurrentStepNumber(stepConfig.stepNumber);\n\n // Fetch the template and convert it to a $ object.\n let template = $(this.getTemplateContent());\n\n // Title.\n template.find('[data-placeholder=\"title\"]')\n .html(stepConfig.title);\n\n // Body.\n template.find('[data-placeholder=\"body\"]')\n .html(stepConfig.body);\n\n // Buttons.\n const nextBtn = template.find('[data-role=\"next\"]');\n const endBtn = template.find('[data-role=\"end\"]');\n\n // Is this the final step?\n if (this.isLastStep(stepConfig.stepNumber)) {\n nextBtn.hide();\n endBtn.removeClass(\"btn-secondary\").addClass(\"btn-primary\");\n } else {\n nextBtn.prop('disabled', false);\n // Use Skip tour label for the End tour button.\n getString('skip_tour', 'tool_usertours').then(value => {\n endBtn.html(value);\n return;\n }).catch();\n }\n\n nextBtn.attr('role', 'button');\n endBtn.attr('role', 'button');\n\n if (this.originalConfiguration.displaystepnumbers) {\n const stepsPotentiallyVisible = this.getPotentiallyVisibleSteps();\n const totalStepsPotentiallyVisible = stepsPotentiallyVisible.length;\n const position = stepsPotentiallyVisible[stepConfig.stepNumber].position;\n if (totalStepsPotentiallyVisible > 1) {\n // Change the label of the Next button to include the sequence.\n getString('nextstep_sequence', 'tool_usertours',\n {position: position, total: totalStepsPotentiallyVisible}).then(value => {\n nextBtn.html(value);\n return;\n }).catch();\n }\n }\n\n // Replace the template with the updated version.\n stepConfig.template = template;\n\n // Add to the page.\n this.addStepToPage(stepConfig);\n\n // Process step listeners after adding to the page.\n // This uses the currentNode.\n this.processStepListeners(stepConfig);\n\n return this;\n }\n\n /**\n * Getter for the template content.\n *\n * @method getTemplateContent\n * @return {$}\n */\n getTemplateContent() {\n return $(this.templateContent).clone();\n }\n\n /**\n * Helper to add a step to the page.\n *\n * @method addStepToPage\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n addStepToPage(stepConfig) {\n // Create the stepNode from the template data.\n let currentStepNode = $('')\n .html(stepConfig.template)\n .hide();\n\n // The scroll animation occurs on the body or html.\n let animationTarget = $('body, html')\n .stop(true, true);\n\n if (this.isStepActuallyVisible(stepConfig)) {\n let targetNode = this.getStepTarget(stepConfig);\n\n if (targetNode.parents('[data-usertour=\"scroller\"]').length) {\n animationTarget = targetNode.parents('[data-usertour=\"scroller\"]');\n }\n\n targetNode.data('flexitour', 'target');\n\n let zIndex = this.calculateZIndex(targetNode);\n if (zIndex) {\n stepConfig.zIndex = zIndex + 1;\n }\n\n if (stepConfig.zIndex) {\n currentStepNode.css('zIndex', stepConfig.zIndex + 1);\n }\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n // Ensure that the step node is positioned.\n // Some situations mean that the value is not properly calculated without this step.\n this.currentStepNode.css({\n top: 0,\n left: 0,\n });\n\n animationTarget\n .animate({\n scrollTop: this.calculateScrollTop(stepConfig),\n }).promise().then(function() {\n this.positionStep(stepConfig);\n this.revealStep(stepConfig);\n return;\n }.bind(this))\n .catch(function() {\n // Silently fail.\n });\n\n } else if (stepConfig.orphan) {\n stepConfig.isOrphan = true;\n\n // This will be appended to the body instead.\n stepConfig.attachTo = $('body').first();\n stepConfig.attachPoint = 'append';\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n // This is an orphaned step.\n currentStepNode.addClass('orphan');\n\n // It lives in the body.\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n this.currentStepNode.offset(this.calculateStepPositionInPage());\n this.currentStepNode.css('position', 'fixed');\n\n this.currentStepPopper = new Popper(\n $('body'),\n this.currentStepNode[0], {\n removeOnDestroy: true,\n placement: stepConfig.placement + '-start',\n arrowElement: '[data-role=\"arrow\"]',\n // Empty the modifiers. We've already placed the step and don't want it moved.\n modifiers: {\n hide: {\n enabled: false,\n },\n applyStyle: {\n onLoad: null,\n enabled: false,\n },\n }\n }\n );\n\n this.revealStep(stepConfig);\n }\n\n return this;\n }\n\n /**\n * Make the given step visible.\n *\n * @method revealStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n revealStep(stepConfig) {\n // Fade the step in.\n this.currentStepNode.fadeIn('', $.proxy(function() {\n // Announce via ARIA.\n this.announceStep(stepConfig);\n\n // Focus on the current step Node.\n this.currentStepNode.focus();\n window.setTimeout($.proxy(function() {\n // After a brief delay, focus again.\n // There seems to be an issue with Jaws where it only reads the dialogue title initially.\n // This second focus helps it to read the full dialogue.\n if (this.currentStepNode) {\n this.currentStepNode.focus();\n }\n }, this), 100);\n\n }, this));\n\n return this;\n }\n\n /**\n * Helper to announce the step on the page.\n *\n * @method announceStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n announceStep(stepConfig) {\n // Setup the step Dialogue as per:\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_nonmodal\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_modal\n\n // Generate an ID for the current step node.\n let stepId = 'tour-step-' + this.tourName + '-' + stepConfig.stepNumber;\n this.currentStepNode.attr('id', stepId);\n\n let bodyRegion = this.currentStepNode.find('[data-placeholder=\"body\"]').first();\n bodyRegion.attr('id', stepId + '-body');\n bodyRegion.attr('role', 'document');\n\n let headerRegion = this.currentStepNode.find('[data-placeholder=\"title\"]').first();\n headerRegion.attr('id', stepId + '-title');\n headerRegion.attr('aria-labelledby', stepId + '-body');\n\n // Generally, a modal dialog has a role of dialog.\n this.currentStepNode.attr('role', 'dialog');\n this.currentStepNode.attr('tabindex', 0);\n this.currentStepNode.attr('aria-labelledby', stepId + '-title');\n this.currentStepNode.attr('aria-describedby', stepId + '-body');\n\n // Configure ARIA attributes on the target.\n let target = this.getStepTarget(stepConfig);\n if (target) {\n if (!target.attr('tabindex')) {\n target.attr('tabindex', 0);\n }\n\n target\n .data('original-describedby', target.attr('aria-describedby'))\n .attr('aria-describedby', stepId + '-body')\n ;\n }\n\n this.accessibilityShow(stepConfig);\n\n return this;\n }\n\n /**\n * Handle key down events.\n *\n * @method handleKeyDown\n * @param {EventFacade} e\n */\n handleKeyDown(e) {\n let tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], ';\n tabbableSelector += ':input:enabled, [tabindex], button:enabled';\n switch (e.keyCode) {\n case 27:\n this.endTour();\n break;\n\n // 9 == Tab - trap focus for items with a backdrop.\n case 9:\n // Tab must be handled on key up only in this instance.\n (function() {\n if (!this.currentStepConfig.hasBackdrop) {\n // Trapping tab focus is only handled for those steps with a backdrop.\n return;\n }\n\n // Find all tabbable locations.\n let activeElement = $(document.activeElement);\n let stepTarget = this.getStepTarget(this.currentStepConfig);\n let tabbableNodes = $(tabbableSelector);\n let dialogContainer = $('span[data-flexitour=\"container\"]');\n let currentIndex;\n // Filter out element which is not belong to target section or dialogue.\n if (stepTarget) {\n tabbableNodes = tabbableNodes.filter(function(index, element) {\n return stepTarget !== null\n && (stepTarget.has(element).length\n || dialogContainer.has(element).length\n || stepTarget.is(element)\n || dialogContainer.is(element));\n });\n }\n\n // Find index of focusing element.\n tabbableNodes.each(function(index, element) {\n if (activeElement.is(element)) {\n currentIndex = index;\n return false;\n }\n // Keep looping.\n return true;\n });\n\n let nextIndex;\n let nextNode;\n let focusRelevant;\n if (currentIndex != void 0) {\n let direction = 1;\n if (e.shiftKey) {\n direction = -1;\n }\n nextIndex = currentIndex;\n do {\n nextIndex += direction;\n nextNode = $(tabbableNodes[nextIndex]);\n } while (nextNode.length && nextNode.is(':disabled') || nextNode.is(':hidden'));\n if (nextNode.length) {\n // A new f\n focusRelevant = nextNode.closest(stepTarget).length;\n focusRelevant = focusRelevant || nextNode.closest(this.currentStepNode).length;\n } else {\n // Unable to find the target somehow.\n focusRelevant = false;\n }\n }\n\n if (focusRelevant) {\n nextNode.focus();\n } else {\n if (e.shiftKey) {\n // Focus on the last tabbable node in the step.\n this.currentStepNode.find(tabbableSelector).last().focus();\n } else {\n if (this.currentStepConfig.isOrphan) {\n // Focus on the step - there is no target.\n this.currentStepNode.focus();\n } else {\n // Focus on the step target.\n stepTarget.focus();\n }\n }\n }\n e.preventDefault();\n }).call(this);\n break;\n }\n }\n\n /**\n * Start the current tour.\n *\n * @method startTour\n * @param {Number} startAt Which step number to start at. If not specified, starts at the last point.\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/tourStart\n * @fires tool_usertours/tourStarted\n */\n startTour(startAt) {\n if (this.storage && typeof startAt === 'undefined') {\n let storageStartValue = this.storage.getItem(this.storageKey);\n if (storageStartValue) {\n let storageStartAt = parseInt(storageStartValue, 10);\n if (storageStartAt <= this.steps.length) {\n startAt = storageStartAt;\n }\n }\n }\n\n if (typeof startAt === 'undefined') {\n startAt = this.getCurrentStepNumber();\n }\n\n const tourStartEvent = this.dispatchEvent(eventTypes.tourStart, {startAt}, true);\n if (!tourStartEvent.defaultPrevented) {\n this.gotoStep(startAt);\n this.tourRunning = true;\n this.dispatchEvent(eventTypes.tourStarted, {startAt});\n }\n\n return this;\n }\n\n /**\n * Restart the tour from the beginning, resetting the completionlag.\n *\n * @method restartTour\n * @chainable\n * @return {Object} this.\n */\n restartTour() {\n return this.startTour(0);\n }\n\n /**\n * End the current tour.\n *\n * @method endTour\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/tourEnd\n * @fires tool_usertours/tourEnded\n */\n endTour() {\n const tourEndEvent = this.dispatchEvent(eventTypes.tourEnd, {}, true);\n if (tourEndEvent.defaultPrevented) {\n return this;\n }\n\n if (this.currentStepConfig) {\n let previousTarget = this.getStepTarget(this.currentStepConfig);\n if (previousTarget) {\n if (!previousTarget.attr('tabindex')) {\n previousTarget.attr('tabindex', '-1');\n }\n previousTarget.focus();\n }\n }\n\n this.hide(true);\n\n this.tourRunning = false;\n this.dispatchEvent(eventTypes.tourEnded);\n\n return this;\n }\n\n /**\n * Hide any currently visible steps.\n *\n * @method hide\n * @param {Bool} transition Animate the visibility change\n * @chainable\n * @return {Object} this.\n * @fires tool_usertours/stepHide\n * @fires tool_usertours/stepHidden\n */\n hide(transition) {\n const stepHideEvent = this.dispatchEvent(eventTypes.stepHide, {}, true);\n if (stepHideEvent.defaultPrevented) {\n return this;\n }\n\n if (this.currentStepNode && this.currentStepNode.length) {\n this.currentStepNode.hide();\n if (this.currentStepPopper) {\n this.currentStepPopper.destroy();\n }\n }\n\n // Restore original target configuration.\n if (this.currentStepConfig) {\n let target = this.getStepTarget(this.currentStepConfig);\n if (target) {\n if (target.data('original-labelledby')) {\n target.attr('aria-labelledby', target.data('original-labelledby'));\n }\n\n if (target.data('original-describedby')) {\n target.attr('aria-describedby', target.data('original-describedby'));\n }\n\n if (target.data('original-tabindex')) {\n target.attr('tabindex', target.data('tabindex'));\n }\n }\n\n // Clear the step configuration.\n this.currentStepConfig = null;\n }\n\n let fadeTime = 0;\n if (transition) {\n fadeTime = 400;\n }\n\n // Remove the backdrop features.\n $('[data-flexitour=\"step-background\"]').remove();\n $('[data-flexitour=\"step-backdrop\"]').removeAttr('data-flexitour');\n $('[data-flexitour=\"backdrop\"]').fadeOut(fadeTime, function() {\n $(this).remove();\n });\n\n // Remove aria-describedby and tabindex attributes.\n if (this.currentStepNode && this.currentStepNode.length) {\n let stepId = this.currentStepNode.attr('id');\n if (stepId) {\n let currentStepElement = '[aria-describedby=\"' + stepId + '-body\"]';\n $(currentStepElement).removeAttr('tabindex');\n $(currentStepElement).removeAttr('aria-describedby');\n }\n }\n\n // Reset the listeners.\n this.resetStepListeners();\n\n this.accessibilityHide();\n\n this.dispatchEvent(eventTypes.stepHidden);\n\n this.currentStepNode = null;\n this.currentStepPopper = null;\n return this;\n }\n\n /**\n * Show the current steps.\n *\n * @method show\n * @chainable\n * @return {Object} this.\n */\n show() {\n // Show the current step.\n let startAt = this.getCurrentStepNumber();\n\n return this.gotoStep(startAt);\n }\n\n /**\n * Return the current step node.\n *\n * @method getStepContainer\n * @return {jQuery}\n */\n getStepContainer() {\n return $(this.currentStepNode);\n }\n\n /**\n * Calculate scrollTop.\n *\n * @method calculateScrollTop\n * @param {Object} stepConfig The step configuration of the step\n * @return {Number}\n */\n calculateScrollTop(stepConfig) {\n let viewportHeight = $(window).height();\n let targetNode = this.getStepTarget(stepConfig);\n\n let scrollParent = $(window);\n if (targetNode.parents('[data-usertour=\"scroller\"]').length) {\n scrollParent = targetNode.parents('[data-usertour=\"scroller\"]');\n }\n let scrollTop = scrollParent.scrollTop();\n\n if (stepConfig.placement === 'top') {\n // If the placement is top, center scroll at the top of the target.\n scrollTop = targetNode.offset().top - (viewportHeight / 2);\n } else if (stepConfig.placement === 'bottom') {\n // If the placement is bottom, center scroll at the bottom of the target.\n scrollTop = targetNode.offset().top + targetNode.height() + scrollTop - (viewportHeight / 2);\n } else if (targetNode.height() <= (viewportHeight * 0.8)) {\n // If the placement is left/right, and the target fits in the viewport, centre screen on the target\n scrollTop = targetNode.offset().top - ((viewportHeight - targetNode.height()) / 2);\n } else {\n // If the placement is left/right, and the target is bigger than the viewport, set scrollTop to target.top + buffer\n // and change step attachmentTarget to top+.\n scrollTop = targetNode.offset().top - (viewportHeight * 0.2);\n }\n\n // Never scroll over the top.\n scrollTop = Math.max(0, scrollTop);\n\n // Never scroll beyond the bottom.\n scrollTop = Math.min($(document).height() - viewportHeight, scrollTop);\n\n return Math.ceil(scrollTop);\n }\n\n /**\n * Calculate dialogue position for page middle.\n *\n * @method calculateScrollTop\n * @return {Number}\n */\n calculateStepPositionInPage() {\n let viewportHeight = $(window).height();\n let stepHeight = this.currentStepNode.height();\n\n let viewportWidth = $(window).width();\n let stepWidth = this.currentStepNode.width();\n\n return {\n top: Math.ceil((viewportHeight - stepHeight) / 2),\n left: Math.ceil((viewportWidth - stepWidth) / 2)\n };\n }\n\n /**\n * Position the step on the page.\n *\n * @method positionStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionStep(stepConfig) {\n let content = this.currentStepNode;\n if (!content || !content.length) {\n // Unable to find the step node.\n return this;\n }\n\n stepConfig.placement = this.recalculatePlacement(stepConfig);\n let flipBehavior;\n switch (stepConfig.placement) {\n case 'left':\n flipBehavior = ['left', 'right', 'top', 'bottom'];\n break;\n case 'right':\n flipBehavior = ['right', 'left', 'top', 'bottom'];\n break;\n case 'top':\n flipBehavior = ['top', 'bottom', 'right', 'left'];\n break;\n case 'bottom':\n flipBehavior = ['bottom', 'top', 'right', 'left'];\n break;\n default:\n flipBehavior = 'flip';\n break;\n }\n\n let target = this.getStepTarget(stepConfig);\n var config = {\n placement: stepConfig.placement + '-start',\n removeOnDestroy: true,\n modifiers: {\n flip: {\n behaviour: flipBehavior,\n },\n arrow: {\n element: '[data-role=\"arrow\"]',\n },\n },\n onCreate: function(data) {\n recalculateArrowPosition(data);\n },\n onUpdate: function(data) {\n recalculateArrowPosition(data);\n },\n };\n\n let recalculateArrowPosition = function(data) {\n let placement = data.placement.split('-')[0];\n const isVertical = ['left', 'right'].indexOf(placement) !== -1;\n const arrowElement = data.instance.popper.querySelector('[data-role=\"arrow\"]');\n const stepElement = $(data.instance.popper.querySelector('[data-role=\"flexitour-step\"]'));\n if (isVertical) {\n let arrowHeight = parseFloat(window.getComputedStyle(arrowElement).height);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).top);\n let popperHeight = parseFloat(window.getComputedStyle(data.instance.popper).height);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).top);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowHeight / 2);\n let maxPos = popperHeight + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperHeight / 2)) {\n newArrowPos = maxPos - arrowHeight;\n } else {\n newArrowPos = minPos + arrowHeight;\n }\n $(arrowElement).css('top', newArrowPos);\n }\n } else {\n let arrowWidth = parseFloat(window.getComputedStyle(arrowElement).width);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).left);\n let popperWidth = parseFloat(window.getComputedStyle(data.instance.popper).width);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).left);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowWidth / 2);\n let maxPos = popperWidth + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperWidth / 2)) {\n newArrowPos = maxPos - arrowWidth;\n } else {\n newArrowPos = minPos + arrowWidth;\n }\n $(arrowElement).css('left', newArrowPos);\n }\n }\n };\n\n let background = $('[data-flexitour=\"step-background\"]');\n if (background.length) {\n target = background;\n }\n this.currentStepPopper = new Popper(target, content[0], config);\n\n return this;\n }\n\n /**\n * For left/right placement, checks that there is room for the step at current window size.\n *\n * If there is not enough room, changes placement to 'top'.\n *\n * @method recalculatePlacement\n * @param {Object} stepConfig The step configuration of the step\n * @return {String} The placement after recalculate\n */\n recalculatePlacement(stepConfig) {\n const buffer = 10;\n const arrowWidth = 16;\n let target = this.getStepTarget(stepConfig);\n let widthContent = this.currentStepNode.width() + arrowWidth;\n let targetOffsetLeft = target.offset().left - buffer;\n let targetOffsetRight = target.offset().left + target.width() + buffer;\n let placement = stepConfig.placement;\n\n if (['left', 'right'].indexOf(placement) !== -1) {\n if ((targetOffsetLeft < (widthContent + buffer)) &&\n ((targetOffsetRight + widthContent + buffer) > document.documentElement.clientWidth)) {\n placement = 'top';\n }\n }\n return placement;\n }\n\n /**\n * Add the backdrop.\n *\n * @method positionBackdrop\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionBackdrop(stepConfig) {\n if (stepConfig.backdrop) {\n this.currentStepConfig.hasBackdrop = true;\n let backdrop = $('
');\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(backdrop);\n } else {\n backdrop.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(backdrop);\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // The step has a visible target.\n // Punch a hole through the backdrop.\n let background = $('[data-flexitour=\"step-background\"]');\n if (!background.length) {\n background = $('
');\n }\n\n let targetNode = this.getStepTarget(stepConfig);\n\n let buffer = 10;\n\n let colorNode = targetNode;\n if (buffer) {\n colorNode = $('body');\n }\n\n let drawertop = 0;\n if (targetNode.parents('[data-usertour=\"scroller\"]').length) {\n const scrollerElement = targetNode.parents('[data-usertour=\"scroller\"]');\n const navigationBuffer = scrollerElement.offset().top;\n if (scrollerElement.scrollTop() >= navigationBuffer) {\n drawertop = scrollerElement.scrollTop() - navigationBuffer;\n background.css({\n position: 'fixed'\n });\n }\n }\n\n background.css({\n width: targetNode.outerWidth() + buffer + buffer,\n height: targetNode.outerHeight() + buffer + buffer,\n left: targetNode.offset().left - buffer,\n top: targetNode.offset().top + drawertop - buffer,\n backgroundColor: this.calculateInherittedBackgroundColor(colorNode),\n });\n\n if (targetNode.offset().left < buffer) {\n background.css({\n width: targetNode.outerWidth() + targetNode.offset().left + buffer,\n left: targetNode.offset().left,\n });\n }\n\n if ((targetNode.offset().top + drawertop) < buffer) {\n background.css({\n height: targetNode.outerHeight() + targetNode.offset().top + buffer,\n top: targetNode.offset().top,\n });\n }\n\n let targetRadius = targetNode.css('borderRadius');\n if (targetRadius && targetRadius !== $('body').css('borderRadius')) {\n background.css('borderRadius', targetRadius);\n }\n\n let targetPosition = this.calculatePosition(targetNode);\n if (targetPosition === 'fixed') {\n background.css('top', 0);\n } else if (targetPosition === 'absolute') {\n background.css('position', 'fixed');\n }\n\n let fader = background.clone();\n fader.css({\n backgroundColor: backdrop.css('backgroundColor'),\n opacity: backdrop.css('opacity'),\n });\n fader.attr('data-flexitour', 'step-background-fader');\n\n if (targetNode.parents('[data-region=\"fixed-drawer\"]').length) {\n let targetClone = targetNode.clone();\n background.append(targetClone);\n }\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(background);\n } else {\n fader.insertAfter(stepConfig.attachTo);\n background.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(fader);\n $('body').append(background);\n }\n\n // Add the backdrop data to the actual target.\n // This is the part which actually does the work.\n targetNode.attr('data-flexitour', 'step-backdrop');\n\n if (stepConfig.zIndex) {\n backdrop.css('zIndex', stepConfig.zIndex);\n background.css('zIndex', stepConfig.zIndex + 1);\n targetNode.css('zIndex', stepConfig.zIndex + 2);\n }\n\n fader.fadeOut('2000', function() {\n $(this).remove();\n });\n }\n }\n return this;\n }\n\n /**\n * Calculate the inheritted z-index.\n *\n * @method calculateZIndex\n * @param {jQuery} elem The element to calculate z-index for\n * @return {Number} Calculated z-index\n */\n calculateZIndex(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n // Ignore z-index if position is set to a value where z-index is ignored by the browser\n // This makes behavior of this function consistent across browsers\n // WebKit always returns auto if the element is positioned.\n let position = elem.css(\"position\");\n if (position === \"absolute\" || position === \"relative\" || position === \"fixed\") {\n // IE returns 0 when zIndex is not specified\n // other browsers return a string\n // we ignore the case of nested elements with an explicit value of 0\n //
\n let value = parseInt(elem.css(\"zIndex\"), 10);\n if (!isNaN(value) && value !== 0) {\n return value;\n }\n }\n elem = elem.parent();\n }\n\n return 0;\n }\n\n /**\n * Calculate the inheritted background colour.\n *\n * @method calculateInherittedBackgroundColor\n * @param {jQuery} elem The element to calculate colour for\n * @return {String} Calculated background colour\n */\n calculateInherittedBackgroundColor(elem) {\n // Use a fake node to compare each element against.\n let fakeNode = $('
').hide();\n $('body').append(fakeNode);\n let fakeElemColor = fakeNode.css('backgroundColor');\n fakeNode.remove();\n\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let color = elem.css('backgroundColor');\n if (color !== fakeElemColor) {\n return color;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Calculate the inheritted position.\n *\n * @method calculatePosition\n * @param {jQuery} elem The element to calculate position for\n * @return {String} Calculated position\n */\n calculatePosition(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let position = elem.css('position');\n if (position !== 'static') {\n return position;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Perform accessibility changes for step shown.\n *\n * This will add aria-hidden=\"true\" to all siblings and parent siblings.\n *\n * @method accessibilityShow\n */\n accessibilityShow() {\n let stateHolder = 'data-has-hidden';\n let attrName = 'aria-hidden';\n let hideFunction = function(child) {\n let flexitourRole = child.data('flexitour');\n if (flexitourRole) {\n switch (flexitourRole) {\n case 'container':\n case 'target':\n return;\n }\n }\n\n let hidden = child.attr(attrName);\n if (!hidden) {\n child.attr(stateHolder, true);\n Aria.hide(child);\n }\n };\n\n this.currentStepNode.siblings().each(function(index, node) {\n hideFunction($(node));\n });\n this.currentStepNode.parentsUntil('body').siblings().each(function(index, node) {\n hideFunction($(node));\n });\n }\n\n /**\n * Perform accessibility changes for step hidden.\n *\n * This will remove any newly added aria-hidden=\"true\".\n *\n * @method accessibilityHide\n */\n accessibilityHide() {\n let stateHolder = 'data-has-hidden';\n let showFunction = function(child) {\n let hidden = child.attr(stateHolder);\n if (typeof hidden !== 'undefined') {\n child.removeAttr(stateHolder);\n Aria.unhide(child);\n }\n };\n\n $('[' + stateHolder + ']').each(function(index, node) {\n showFunction($(node));\n });\n }\n};\n\nexport default Tour;\n"],"names":["constructor","config","init","eventHandlers","reset","originalConfiguration","configure","apply","this","arguments","storage","window","sessionStorage","storageKey","tourName","e","hide","resetStepListeners","steps","currentStepNumber","eventName","forEach","handler","addEventHandler","resetStepDefaults","template","templateContent","checkMinimumRequirements","Error","length","loadOriginalConfiguration","stepDefaults","setStepDefaults","extend","element","placement","delay","moveOnClick","moveAfterTime","orphan","direction","getCurrentStepNumber","parseInt","setCurrentStepNumber","stepNumber","setItem","code","DOMException","QUOTA_EXCEEDED_ERR","removeItem","getNextStepNumber","nextStepNumber","isStepPotentiallyVisible","getStepConfig","getPreviousStepNumber","previousStepNumber","isLastStep","stepConfig","isStepActuallyVisible","getPotentiallyVisibleSteps","position","result","stepId","stepid","target","getStepTarget","is","next","gotoStep","previous","endTour","_gotoStep","delayed","setTimeout","bind","fn","dispatchEvent","eventTypes","stepRender","defaultPrevented","renderStep","stepRendered","normalizeStepConfig","$","reflex","moveAfterClick","content","body","attachTo","attachPoint","first","detail","cancelable","tour","document","push","processStepListeners","listeners","node","currentStepNode","args","proxy","handleKeyDown","targetNode","parents","listener","on","off","currentStepConfig","getTemplateContent","find","html","title","nextBtn","endBtn","removeClass","addClass","prop","then","value","catch","attr","displaystepnumbers","stepsPotentiallyVisible","totalStepsPotentiallyVisible","total","addStepToPage","clone","animationTarget","stop","data","zIndex","calculateZIndex","css","positionBackdrop","append","top","left","animate","scrollTop","calculateScrollTop","promise","positionStep","revealStep","isOrphan","offset","calculateStepPositionInPage","currentStepPopper","Popper","removeOnDestroy","arrowElement","modifiers","enabled","applyStyle","onLoad","fadeIn","announceStep","focus","bodyRegion","headerRegion","accessibilityShow","tabbableSelector","keyCode","hasBackdrop","currentIndex","nextIndex","nextNode","focusRelevant","activeElement","stepTarget","tabbableNodes","dialogContainer","filter","index","has","each","shiftKey","closest","last","preventDefault","call","startTour","startAt","storageStartValue","getItem","storageStartAt","tourStart","tourRunning","tourStarted","restartTour","tourEnd","previousTarget","tourEnded","transition","stepHide","destroy","fadeTime","remove","removeAttr","fadeOut","currentStepElement","accessibilityHide","stepHidden","show","getStepContainer","viewportHeight","height","scrollParent","Math","max","min","ceil","stepHeight","viewportWidth","width","stepWidth","flipBehavior","recalculatePlacement","flip","behaviour","arrow","onCreate","recalculateArrowPosition","onUpdate","split","isVertical","indexOf","instance","popper","querySelector","stepElement","arrowHeight","parseFloat","getComputedStyle","arrowOffset","popperHeight","popperOffset","popperBorderWidth","popperBorderRadiusWidth","arrowPos","maxPos","minPos","newArrowPos","arrowWidth","popperWidth","background","widthContent","targetOffsetLeft","targetOffsetRight","documentElement","clientWidth","backdrop","insertAfter","buffer","colorNode","drawertop","scrollerElement","navigationBuffer","outerWidth","outerHeight","backgroundColor","calculateInherittedBackgroundColor","targetRadius","targetPosition","calculatePosition","fader","opacity","targetClone","elem","isNaN","parent","fakeNode","fakeElemColor","color","hideFunction","child","flexitourRole","Aria","siblings","parentsUntil","unhide"],"mappings":"s4CA6Ca,MAMTA,YAAYC,iCALE,6IAMLC,KAAKD,QAWdC,KAAKD,aAEIE,cAAgB,QAGhBC,aAGAC,sBAAwBJ,QAAU,QAGlCK,UAAUC,MAA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,SAASkO,KAAKvI,IAAI,UAAW,QACpCwI,MAAMtJ,QAAoB,IAAVA,aACVA,MAGfqJ,KAAOA,KAAKE,gBAGT,EAUXT,mCAAmCO,UAE3BG,UAAW,mBAAE,SAAS/P,2BACxB,QAAQuH,OAAOwI,cACbC,cAAgBD,SAAS1I,IAAI,uBACjC0I,SAAS1E,SAETuE,MAAO,mBAAEA,MACFA,KAAK/O,QAAU+O,KAAK,KAAO9K,UAAU,KACpCmL,MAAQL,KAAKvI,IAAI,sBACjB4I,QAAUD,qBACHC,MAEXL,KAAOA,KAAKE,gBAGT,KAUXN,kBAAkBI,UACdA,MAAO,mBAAEA,MACFA,KAAK/O,QAAU+O,KAAK,KAAO9K,UAAU,KACpClC,SAAWgN,KAAKvI,IAAI,eACP,WAAbzE,gBACOA,SAEXgN,KAAOA,KAAKE,gBAGT,KAUX9G,wBAGQkH,aAAe,SAASC,WACpBC,cAAgBD,MAAMjJ,KAAK,gBAC3BkJ,qBACQA,mBACC,gBACA,gBAKAD,MAAM1J,KAXR,iBAaP0J,MAAM1J,KAdI,mBAcc,GACxB4J,KAAKrQ,KAAKmQ,cAIbhL,gBAAgBmL,WAAWvG,MAAK,SAASF,MAAO3E,MACjDgL,cAAa,mBAAEhL,eAEdC,gBAAgBoL,aAAa,QAAQD,WAAWvG,MAAK,SAASF,MAAO3E,MACtEgL,cAAa,mBAAEhL,UAWvBuG,wCAUM,qBAAyB1B,MAAK,SAASF,MAAO3E,MAR7B,IAASiL,WAEF,KAFEA,OASX,mBAAEjL,OARIuB,KAFL,qBAIV0J,MAAM7E,WAJI,mBAKV+E,KAAKG,OAAOL"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/usertours.min.js b/admin/tool/usertours/amd/build/usertours.min.js index 88121c93775..c0709030ff0 100644 --- a/admin/tool/usertours/amd/build/usertours.min.js +++ b/admin/tool/usertours/amd/build/usertours.min.js @@ -1,2 +1,3 @@ -function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("tool_usertours/usertours",["exports","./tour","core/templates","core/log","core/notification","./repository","core/pending","./events"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.resetTourState=a.init=void 0;b=k(b);c=k(c);d=k(d);e=k(e);f=j(f);g=k(g);var n="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function i(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;i=function(){return a};return a}function j(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=i();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function k(a){return a&&a.__esModule?a:{default:a}}function l(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function m(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){l(h,d,e,f,g,"next",a)}function g(a){l(h,d,e,f,g,"throw",a)}f(void 0)})}}var o=null,p=null,q=function(a,b){return a.find(function(a){return b.some(function(b){if(b&&b.filterMatches){return b.filterMatches(a)}return!0})})},r=function(){var a=m(regeneratorRuntime.mark(function a(b,c){var d,e,f,g;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=[];c.forEach(function(a){d.push("function"==typeof n.define&&n.define.amd?new Promise(function(b,c){n.require(["tool_usertours/filter_".concat(a)],b,c)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&n.require&&"component"===n.require.loader?Promise.resolve(require(("tool_usertours/filter_".concat(a)))):Promise.resolve(n["tool_usertours/filter_".concat(a)]))});a.next=4;return Promise.all(d);case 4:e=a.sent;f=q(b,e);if(f){a.next=8;break}return a.abrupt("return");case 8:p=f.tourId;g=f.startTour;if("undefined"==typeof g){g=!0}if(g){s(p)}u();document.querySelector("body").addEventListener("click",function(a){var b=a.target.closest("#resetpagetour");if(b){a.preventDefault();y(p)}});case 14:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.init=r;var s=function(){var a=m(regeneratorRuntime.mark(function a(b){var d,h,i,j;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=new g.default("admin_usertour_fetchTour:".concat(b));a.prev=1;a.next=4;return f.fetchTour(b);case 4:h=a.sent;if(!h.hasOwnProperty("tourconfig")){d.resolve()}a.next=8;return c.default.renderForPromise("tool_usertours/tourstep",h.tourconfig);case 8:i=a.sent;j=i.html;v(b,j,h.tourconfig);d.resolve();a.next=18;break;case 14:a.prev=14;a.t0=a["catch"](1);d.resolve();e.default.exception(a.t0);case 18:case"end":return a.stop();}}},a,null,[[1,14]])}));return function(){return a.apply(this,arguments)}}(),t=function(){var a=document.querySelector(".tool_usertours-resettourcontainer");if(a){return a}a=document.querySelector(".logininfo");if(a){return a}a=document.querySelector("footer");if(a){return a}return document.body},u=function(){var a=new g.default("admin_usertour_addResetLink");c.default.render("tool_usertours/resettour",{}).then(function(a,b){c.default.appendNodeContents(t(),a,b)}).catch().then(a.resolve).catch()},v=function(a,c,d){if(o&&o.tourRunning){o.endTour();o=null}document.addEventListener(h.eventTypes.tourEnded,x);document.addEventListener(h.eventTypes.stepRenderer,w);d.tourName=d.name;delete d.name;d.template=c;d.steps=d.steps.map(function(a){if("undefined"!=typeof a.element){a.target=a.element;delete a.element}if("undefined"!=typeof a.reflex){a.moveOnClick=!!a.reflex;delete a.reflex}if("undefined"!=typeof a.content){a.body=a.content;delete a.content}return a});o=new b.default(d);return o.startTour()},w=function(a){var b=a.detail.tour,c=b.getStepConfig(b.getCurrentStepNumber());f.markStepShown(c.stepid,p,b.getCurrentStepNumber()).catch(d.default.error)},x=function(a){document.removeEventListener(h.eventTypes.tourEnded,x);document.removeEventListener(h.eventTypes.stepRenderer,w);var b=a.detail.tour,c=b.getStepConfig(b.getCurrentStepNumber());f.markTourComplete(c.stepid,p,b.getCurrentStepNumber()).catch(d.default.error)},y=function(a){return f.resetTourState(a).then(function(a){if(a.startTour){s(a.startTour)}}).catch(e.default.exception)};a.resetTourState=y}); -//# sourceMappingURL=usertours.min.js.map +define("tool_usertours/usertours",["exports","./tour","core/templates","core/log","core/notification","./repository","core/pending","./events"],(function(_exports,_tour,_templates,_log,_notification,tourRepository,_pending,_events){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.resetTourState=_exports.init=void 0,_tour=_interopRequireDefault(_tour),_templates=_interopRequireDefault(_templates),_log=_interopRequireDefault(_log),_notification=_interopRequireDefault(_notification),tourRepository=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(tourRepository),_pending=_interopRequireDefault(_pending);var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}let currentTour=null,tourId=null;_exports.init=async(tourDetails,filters)=>{const requirements=[];filters.forEach((filter=>{requirements.push("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["tool_usertours/filter_".concat(filter)],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("tool_usertours/filter_".concat(filter))):Promise.resolve(_systemImportTransformerGlobalIdentifier["tool_usertours/filter_".concat(filter)]))}));const matchingTour=((tourDetails,filters)=>tourDetails.find((tour=>filters.some((filter=>!filter||!filter.filterMatches||filter.filterMatches(tour))))))(tourDetails,await Promise.all(requirements));if(!matchingTour)return;tourId=matchingTour.tourId;let startTour=matchingTour.startTour;void 0===startTour&&(startTour=!0),startTour&&fetchTour(tourId),addResetLink(),document.querySelector("body").addEventListener("click",(e=>{e.target.closest("#resetpagetour")&&(e.preventDefault(),resetTourState(tourId))}))};const fetchTour=async tourId=>{const pendingPromise=new _pending.default("admin_usertour_fetchTour:".concat(tourId));try{const response=await tourRepository.fetchTour(tourId);response.hasOwnProperty("tourconfig")||pendingPromise.resolve();const{html:html}=await _templates.default.renderForPromise("tool_usertours/tourstep",response.tourconfig);startBootstrapTour(tourId,html,response.tourconfig),pendingPromise.resolve()}catch(error){pendingPromise.resolve(),_notification.default.exception(error)}},addResetLink=()=>{const pendingPromise=new _pending.default("admin_usertour_addResetLink");_templates.default.render("tool_usertours/resettour",{}).then((function(html,js){_templates.default.appendNodeContents((()=>{let location=document.querySelector(".tool_usertours-resettourcontainer");return location||(location=document.querySelector(".logininfo"),location||(location=document.querySelector("footer"),location||document.body))})(),html,js)})).catch().then(pendingPromise.resolve).catch()},startBootstrapTour=(tourId,template,tourConfig)=>(currentTour&¤tTour.tourRunning&&(currentTour.endTour(),currentTour=null),document.addEventListener(_events.eventTypes.tourEnded,markTourComplete),document.addEventListener(_events.eventTypes.stepRenderer,markStepShown),tourConfig.tourName=tourConfig.name,delete tourConfig.name,tourConfig.template=template,tourConfig.steps=tourConfig.steps.map((function(step){return void 0!==step.element&&(step.target=step.element,delete step.element),void 0!==step.reflex&&(step.moveOnClick=!!step.reflex,delete step.reflex),void 0!==step.content&&(step.body=step.content,delete step.content),step})),currentTour=new _tour.default(tourConfig),currentTour.startTour()),markStepShown=e=>{const tour=e.detail.tour,stepConfig=tour.getStepConfig(tour.getCurrentStepNumber());tourRepository.markStepShown(stepConfig.stepid,tourId,tour.getCurrentStepNumber()).catch(_log.default.error)},markTourComplete=e=>{document.removeEventListener(_events.eventTypes.tourEnded,markTourComplete),document.removeEventListener(_events.eventTypes.stepRenderer,markStepShown);const tour=e.detail.tour,stepConfig=tour.getStepConfig(tour.getCurrentStepNumber());tourRepository.markTourComplete(stepConfig.stepid,tourId,tour.getCurrentStepNumber()).catch(_log.default.error)},resetTourState=tourId=>tourRepository.resetTourState(tourId).then((response=>{response.startTour&&fetchTour(response.startTour)})).catch(_notification.default.exception);_exports.resetTourState=resetTourState})); + +//# sourceMappingURL=usertours.min.js.map \ No newline at end of file diff --git a/admin/tool/usertours/amd/build/usertours.min.js.map b/admin/tool/usertours/amd/build/usertours.min.js.map index 3c2c3357031..b01bfe115b6 100644 --- a/admin/tool/usertours/amd/build/usertours.min.js.map +++ b/admin/tool/usertours/amd/build/usertours.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/usertours.js"],"names":["currentTour","tourId","findMatchingTour","tourDetails","filters","find","tour","some","filter","filterMatches","init","requirements","forEach","push","Promise","all","filterPlugins","matchingTour","startTour","fetchTour","addResetLink","document","querySelector","addEventListener","e","resetLink","target","closest","preventDefault","resetTourState","pendingPromise","Pending","tourRepository","response","hasOwnProperty","resolve","Templates","renderForPromise","tourconfig","html","startBootstrapTour","notification","exception","getPreferredResetLocation","location","body","render","then","js","appendNodeContents","catch","template","tourConfig","tourRunning","endTour","eventTypes","tourEnded","markTourComplete","stepRenderer","markStepShown","tourName","name","steps","map","step","element","reflex","moveOnClick","content","BootstrapTour","detail","stepConfig","getStepConfig","getCurrentStepNumber","stepid","log","error","removeEventListener"],"mappings":"2iBAMA,OACA,OACA,OACA,OACA,OACA,O,sgCAGIA,CAAAA,CAAW,CAAG,I,CACdC,CAAM,CAAG,I,CASPC,CAAgB,CAAG,SAACC,CAAD,CAAcC,CAAd,CAA0B,CAC/C,MAAOD,CAAAA,CAAW,CAACE,IAAZ,CAAiB,SAAAC,CAAI,QAAIF,CAAAA,CAAO,CAACG,IAAR,CAAa,SAAAC,CAAM,CAAI,CACnD,GAAIA,CAAM,EAAIA,CAAM,CAACC,aAArB,CAAoC,CAChC,MAAOD,CAAAA,CAAM,CAACC,aAAP,CAAqBH,CAArB,CACV,CAED,QACH,CAN+B,CAAJ,CAArB,CAOV,C,CASYI,CAAI,4CAAG,WAAMP,CAAN,CAAmBC,CAAnB,+FACVO,CADU,CACK,EADL,CAEhBP,CAAO,CAACQ,OAAR,CAAgB,SAAAJ,CAAM,CAAI,CACtBG,CAAY,CAACE,IAAb,gHAAkDL,CAAlD,oOAAkDA,CAAlD,uDAAkDA,CAAlD,IACH,CAFD,EAFgB,eAMYM,CAAAA,OAAO,CAACC,GAAR,CAAYJ,CAAZ,CANZ,QAMVK,CANU,QAQVC,CARU,CAQKf,CAAgB,CAACC,CAAD,CAAca,CAAd,CARrB,IASXC,CATW,kDAchBhB,CAAM,CAAGgB,CAAY,CAAChB,MAAtB,CAEIiB,CAhBY,CAgBAD,CAAY,CAACC,SAhBb,CAiBhB,GAAyB,WAArB,QAAOA,CAAAA,CAAX,CAAsC,CAClCA,CAAS,GACZ,CAED,GAAIA,CAAJ,CAAe,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ACH,cAAf,CAA8B5B,CAA9B,EACvC8C,IADuC,CAClC,SAAAd,CAAQ,CAAI,CACd,GAAIA,CAAQ,CAACf,SAAb,CAAwB,CACpBC,CAAS,CAACc,CAAQ,CAACf,SAAV,CACZ,CAEJ,CANuC,EAMrCgC,KANqC,CAM/BT,UAAaC,SANkB,CAAJ,C","sourcesContent":["/**\n * User tour control library.\n *\n * @module tool_usertours/usertours\n * @copyright 2016 Andrew Nicols \n */\nimport BootstrapTour from './tour';\nimport Templates from 'core/templates';\nimport log from 'core/log';\nimport notification from 'core/notification';\nimport * as tourRepository from './repository';\nimport Pending from 'core/pending';\nimport {eventTypes} from './events';\n\nlet currentTour = null;\nlet tourId = null;\n\n/**\n * Find the first matching tour.\n *\n * @param {object[]} tourDetails\n * @param {object[]} filters\n * @returns {null|object}\n */\nconst findMatchingTour = (tourDetails, filters) => {\n return tourDetails.find(tour => filters.some(filter => {\n if (filter && filter.filterMatches) {\n return filter.filterMatches(tour);\n }\n\n return true;\n }));\n};\n\n/**\n * Initialise the user tour for the current page.\n *\n * @method init\n * @param {Array} tourDetails The matching tours for this page.\n * @param {Array} filters The names of all client side filters.\n */\nexport const init = async(tourDetails, filters) => {\n const requirements = [];\n filters.forEach(filter => {\n requirements.push(import(`tool_usertours/filter_${filter}`));\n });\n\n const filterPlugins = await Promise.all(requirements);\n\n const matchingTour = findMatchingTour(tourDetails, filterPlugins);\n if (!matchingTour) {\n return;\n }\n\n // Only one tour per page is allowed.\n tourId = matchingTour.tourId;\n\n let startTour = matchingTour.startTour;\n if (typeof startTour === 'undefined') {\n startTour = true;\n }\n\n if (startTour) {\n // Fetch the tour configuration.\n fetchTour(tourId);\n }\n\n addResetLink();\n\n // Watch for the reset link.\n document.querySelector('body').addEventListener('click', e => {\n const resetLink = e.target.closest('#resetpagetour');\n if (resetLink) {\n e.preventDefault();\n resetTourState(tourId);\n }\n });\n};\n\n/**\n * Fetch the configuration specified tour, and start the tour when it has been fetched.\n *\n * @method fetchTour\n * @param {Number} tourId The ID of the tour to start.\n */\nconst fetchTour = async tourId => {\n const pendingPromise = new Pending(`admin_usertour_fetchTour:${tourId}`);\n\n try {\n const response = await tourRepository.fetchTour(tourId);\n if (!response.hasOwnProperty('tourconfig')) {\n pendingPromise.resolve();\n }\n\n const {html} = await Templates.renderForPromise('tool_usertours/tourstep', response.tourconfig);\n startBootstrapTour(tourId, html, response.tourconfig);\n\n pendingPromise.resolve();\n } catch (error) {\n pendingPromise.resolve();\n notification.exception(error);\n }\n};\n\nconst getPreferredResetLocation = () => {\n let location = document.querySelector('.tool_usertours-resettourcontainer');\n if (location) {\n return location;\n }\n\n location = document.querySelector('.logininfo');\n if (location) {\n return location;\n }\n\n location = document.querySelector('footer');\n if (location) {\n return location;\n }\n\n return document.body;\n};\n\n/**\n * Add a reset link to the page.\n *\n * @method addResetLink\n */\nconst addResetLink = () => {\n const pendingPromise = new Pending('admin_usertour_addResetLink');\n\n Templates.render('tool_usertours/resettour', {})\n .then(function(html, js) {\n // Append the link to the most suitable place on the page with fallback to legacy selectors and finally the body if\n // there is no better place.\n Templates.appendNodeContents(getPreferredResetLocation(), html, js);\n\n return;\n })\n .catch()\n .then(pendingPromise.resolve)\n .catch();\n};\n\n/**\n * Start the specified tour.\n *\n * @method startBootstrapTour\n * @param {Number} tourId The ID of the tour to start.\n * @param {String} template The template to use.\n * @param {Object} tourConfig The tour configuration.\n * @return {Object}\n */\nconst startBootstrapTour = (tourId, template, tourConfig) => {\n if (currentTour && currentTour.tourRunning) {\n // End the current tour.\n currentTour.endTour();\n currentTour = null;\n }\n\n document.addEventListener(eventTypes.tourEnded, markTourComplete);\n document.addEventListener(eventTypes.stepRenderer, markStepShown);\n\n // Sort out the tour name.\n tourConfig.tourName = tourConfig.name;\n delete tourConfig.name;\n\n // Add the template to the configuration.\n // This enables translations of the buttons.\n tourConfig.template = template;\n\n tourConfig.steps = tourConfig.steps.map(function(step) {\n if (typeof step.element !== 'undefined') {\n step.target = step.element;\n delete step.element;\n }\n\n if (typeof step.reflex !== 'undefined') {\n step.moveOnClick = !!step.reflex;\n delete step.reflex;\n }\n\n if (typeof step.content !== 'undefined') {\n step.body = step.content;\n delete step.content;\n }\n\n return step;\n });\n\n currentTour = new BootstrapTour(tourConfig);\n return currentTour.startTour();\n};\n\n/**\n * Mark the specified step as being shownd by the user.\n *\n * @method markStepShown\n * @param {Event} e\n */\nconst markStepShown = e => {\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markStepShown(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Mark the specified tour as being completed by the user.\n *\n * @method markTourComplete\n * @param {Event} e\n * @listens tool_usertours/stepRendered\n */\nconst markTourComplete = e => {\n document.removeEventListener(eventTypes.tourEnded, markTourComplete);\n document.removeEventListener(eventTypes.stepRenderer, markStepShown);\n\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markTourComplete(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Reset the state, and restart the the tour on the current page.\n *\n * @method resetTourState\n * @param {Number} tourId The ID of the tour to start.\n * @returns {Promise}\n */\nexport const resetTourState = tourId => tourRepository.resetTourState(tourId)\n.then(response => {\n if (response.startTour) {\n fetchTour(response.startTour);\n }\n return;\n}).catch(notification.exception);\n"],"file":"usertours.min.js"} \ No newline at end of file +{"version":3,"file":"usertours.min.js","sources":["../src/usertours.js"],"sourcesContent":["/**\n * User tour control library.\n *\n * @module tool_usertours/usertours\n * @copyright 2016 Andrew Nicols \n */\nimport BootstrapTour from './tour';\nimport Templates from 'core/templates';\nimport log from 'core/log';\nimport notification from 'core/notification';\nimport * as tourRepository from './repository';\nimport Pending from 'core/pending';\nimport {eventTypes} from './events';\n\nlet currentTour = null;\nlet tourId = null;\n\n/**\n * Find the first matching tour.\n *\n * @param {object[]} tourDetails\n * @param {object[]} filters\n * @returns {null|object}\n */\nconst findMatchingTour = (tourDetails, filters) => {\n return tourDetails.find(tour => filters.some(filter => {\n if (filter && filter.filterMatches) {\n return filter.filterMatches(tour);\n }\n\n return true;\n }));\n};\n\n/**\n * Initialise the user tour for the current page.\n *\n * @method init\n * @param {Array} tourDetails The matching tours for this page.\n * @param {Array} filters The names of all client side filters.\n */\nexport const init = async(tourDetails, filters) => {\n const requirements = [];\n filters.forEach(filter => {\n requirements.push(import(`tool_usertours/filter_${filter}`));\n });\n\n const filterPlugins = await Promise.all(requirements);\n\n const matchingTour = findMatchingTour(tourDetails, filterPlugins);\n if (!matchingTour) {\n return;\n }\n\n // Only one tour per page is allowed.\n tourId = matchingTour.tourId;\n\n let startTour = matchingTour.startTour;\n if (typeof startTour === 'undefined') {\n startTour = true;\n }\n\n if (startTour) {\n // Fetch the tour configuration.\n fetchTour(tourId);\n }\n\n addResetLink();\n\n // Watch for the reset link.\n document.querySelector('body').addEventListener('click', e => {\n const resetLink = e.target.closest('#resetpagetour');\n if (resetLink) {\n e.preventDefault();\n resetTourState(tourId);\n }\n });\n};\n\n/**\n * Fetch the configuration specified tour, and start the tour when it has been fetched.\n *\n * @method fetchTour\n * @param {Number} tourId The ID of the tour to start.\n */\nconst fetchTour = async tourId => {\n const pendingPromise = new Pending(`admin_usertour_fetchTour:${tourId}`);\n\n try {\n const response = await tourRepository.fetchTour(tourId);\n if (!response.hasOwnProperty('tourconfig')) {\n pendingPromise.resolve();\n }\n\n const {html} = await Templates.renderForPromise('tool_usertours/tourstep', response.tourconfig);\n startBootstrapTour(tourId, html, response.tourconfig);\n\n pendingPromise.resolve();\n } catch (error) {\n pendingPromise.resolve();\n notification.exception(error);\n }\n};\n\nconst getPreferredResetLocation = () => {\n let location = document.querySelector('.tool_usertours-resettourcontainer');\n if (location) {\n return location;\n }\n\n location = document.querySelector('.logininfo');\n if (location) {\n return location;\n }\n\n location = document.querySelector('footer');\n if (location) {\n return location;\n }\n\n return document.body;\n};\n\n/**\n * Add a reset link to the page.\n *\n * @method addResetLink\n */\nconst addResetLink = () => {\n const pendingPromise = new Pending('admin_usertour_addResetLink');\n\n Templates.render('tool_usertours/resettour', {})\n .then(function(html, js) {\n // Append the link to the most suitable place on the page with fallback to legacy selectors and finally the body if\n // there is no better place.\n Templates.appendNodeContents(getPreferredResetLocation(), html, js);\n\n return;\n })\n .catch()\n .then(pendingPromise.resolve)\n .catch();\n};\n\n/**\n * Start the specified tour.\n *\n * @method startBootstrapTour\n * @param {Number} tourId The ID of the tour to start.\n * @param {String} template The template to use.\n * @param {Object} tourConfig The tour configuration.\n * @return {Object}\n */\nconst startBootstrapTour = (tourId, template, tourConfig) => {\n if (currentTour && currentTour.tourRunning) {\n // End the current tour.\n currentTour.endTour();\n currentTour = null;\n }\n\n document.addEventListener(eventTypes.tourEnded, markTourComplete);\n document.addEventListener(eventTypes.stepRenderer, markStepShown);\n\n // Sort out the tour name.\n tourConfig.tourName = tourConfig.name;\n delete tourConfig.name;\n\n // Add the template to the configuration.\n // This enables translations of the buttons.\n tourConfig.template = template;\n\n tourConfig.steps = tourConfig.steps.map(function(step) {\n if (typeof step.element !== 'undefined') {\n step.target = step.element;\n delete step.element;\n }\n\n if (typeof step.reflex !== 'undefined') {\n step.moveOnClick = !!step.reflex;\n delete step.reflex;\n }\n\n if (typeof step.content !== 'undefined') {\n step.body = step.content;\n delete step.content;\n }\n\n return step;\n });\n\n currentTour = new BootstrapTour(tourConfig);\n return currentTour.startTour();\n};\n\n/**\n * Mark the specified step as being shownd by the user.\n *\n * @method markStepShown\n * @param {Event} e\n */\nconst markStepShown = e => {\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markStepShown(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Mark the specified tour as being completed by the user.\n *\n * @method markTourComplete\n * @param {Event} e\n * @listens tool_usertours/stepRendered\n */\nconst markTourComplete = e => {\n document.removeEventListener(eventTypes.tourEnded, markTourComplete);\n document.removeEventListener(eventTypes.stepRenderer, markStepShown);\n\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markTourComplete(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Reset the state, and restart the the tour on the current page.\n *\n * @method resetTourState\n * @param {Number} tourId The ID of the tour to start.\n * @returns {Promise}\n */\nexport const resetTourState = tourId => tourRepository.resetTourState(tourId)\n.then(response => {\n if (response.startTour) {\n fetchTour(response.startTour);\n }\n return;\n}).catch(notification.exception);\n"],"names":["currentTour","tourId","async","tourDetails","filters","requirements","forEach","filter","push","matchingTour","find","tour","some","filterMatches","findMatchingTour","Promise","all","startTour","fetchTour","addResetLink","document","querySelector","addEventListener","e","target","closest","preventDefault","resetTourState","pendingPromise","Pending","response","tourRepository","hasOwnProperty","resolve","html","Templates","renderForPromise","tourconfig","startBootstrapTour","error","exception","render","then","js","appendNodeContents","location","body","getPreferredResetLocation","catch","template","tourConfig","tourRunning","endTour","eventTypes","tourEnded","markTourComplete","stepRenderer","markStepShown","tourName","name","steps","map","step","element","reflex","moveOnClick","content","BootstrapTour","detail","stepConfig","getStepConfig","getCurrentStepNumber","stepid","log","removeEventListener","notification"],"mappings":"ssDAcIA,YAAc,KACdC,OAAS,mBA0BOC,MAAMC,YAAaC,iBAC7BC,aAAe,GACrBD,QAAQE,SAAQC,SACZF,aAAaG,qPAAqCD,mUAAAA,mGAAAA,oBAKhDE,aAzBe,EAACN,YAAaC,UAC5BD,YAAYO,MAAKC,MAAQP,QAAQQ,MAAKL,SACrCA,SAAUA,OAAOM,eACVN,OAAOM,cAAcF,UAsBfG,CAAiBX,kBAFVY,QAAQC,IAAIX,mBAGnCI,oBAKLR,OAASQ,aAAaR,WAElBgB,UAAYR,aAAaQ,eACJ,IAAdA,YACPA,WAAY,GAGZA,WAEAC,UAAUjB,QAGdkB,eAGAC,SA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jBwC,cAAgBlC,UACZZ,KAAOY,EAAE6C,OAAOzD,KAChB0D,WAAa1D,KAAK2D,cAAc3D,KAAK4D,wBAC3CxC,eAAe0B,cACXY,WAAWG,OACXvE,OACAU,KAAK4D,wBACPvB,MAAMyB,aAAIlC,QAUVgB,iBAAmBhC,IACrBH,SAASsD,oBAAoBrB,mBAAWC,UAAWC,kBACnDnC,SAASsD,oBAAoBrB,mBAAWG,aAAcC,qBAEhD9C,KAAOY,EAAE6C,OAAOzD,KAChB0D,WAAa1D,KAAK2D,cAAc3D,KAAK4D,wBAC3CxC,eAAewB,iBACXc,WAAWG,OACXvE,OACAU,KAAK4D,wBACPvB,MAAMyB,aAAIlC,QAUHZ,eAAiB1B,QAAU8B,eAAeJ,eAAe1B,QACrEyC,MAAKZ,WACEA,SAASb,WACTC,UAAUY,SAASb,cAGxB+B,MAAM2B,sBAAanC"} \ No newline at end of file diff --git a/admin/tool/xmldb/amd/build/move.min.js b/admin/tool/xmldb/amd/build/move.min.js index 3873d1b2234..2b481ebe806 100644 --- a/admin/tool/xmldb/amd/build/move.min.js +++ b/admin/tool/xmldb/amd/build/move.min.js @@ -1,2 +1,3 @@ -define ("tool_xmldb/move",["jquery","core/sortable_list","core/ajax","core/notification"],function(a,b,c,d){return{init:function init(e,f){var g=new b("#"+e+" tbody");g.getElementName=function(b){return a.Deferred().resolve(b.attr("data-name"))};var h;a("#"+e+" tbody tr").on(b.EVENTS.DRAGSTART,function(b,c){h=c.sourceList.children().index(c.element);setTimeout(function(){a(".sortable-list-is-dragged").width(c.element.width())},501)}).on(b.EVENTS.DROP,function(a,b){var e=b.targetList.children().index(b.element),g=b.element.find("[data-action="+f+"]");if(b.positionChanged&&g.length){var i={methodname:"tool_xmldb_invoke_move_action",args:{action:f,dir:g.attr("data-dir"),table:g.attr("data-table"),field:g.attr("data-field"),key:g.attr("data-key"),index:g.attr("data-index"),position:e-h}};c.call([i])[0].fail(d.exception)}})}}}); -//# sourceMappingURL=move.min.js.map +define("tool_xmldb/move",["jquery","core/sortable_list","core/ajax","core/notification"],(function($,SortableList,Ajax,Notification){return{init:function(tableid,moveaction){var origIndex;new SortableList("#"+tableid+" tbody").getElementName=function(element){return $.Deferred().resolve(element.attr("data-name"))},$("#"+tableid+" tbody tr").on(SortableList.EVENTS.DRAGSTART,(function(_,info){origIndex=info.sourceList.children().index(info.element),setTimeout((function(){$(".sortable-list-is-dragged").width(info.element.width())}),501)})).on(SortableList.EVENTS.DROP,(function(_,info){var newIndex=info.targetList.children().index(info.element),t=info.element.find("[data-action="+moveaction+"]");if(info.positionChanged&&t.length){var request={methodname:"tool_xmldb_invoke_move_action",args:{action:moveaction,dir:t.attr("data-dir"),table:t.attr("data-table"),field:t.attr("data-field"),key:t.attr("data-key"),index:t.attr("data-index"),position:newIndex-origIndex}};Ajax.call([request])[0].fail(Notification.exception)}}))}}})); + +//# sourceMappingURL=move.min.js.map \ No newline at end of file diff --git a/admin/tool/xmldb/amd/build/move.min.js.map b/admin/tool/xmldb/amd/build/move.min.js.map index 28f624fa5b9..9fb16fee00f 100644 --- a/admin/tool/xmldb/amd/build/move.min.js.map +++ b/admin/tool/xmldb/amd/build/move.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/move.js"],"names":["define","$","SortableList","Ajax","Notification","init","tableid","moveaction","sort","getElementName","element","Deferred","resolve","attr","origIndex","on","EVENTS","DRAGSTART","_","info","sourceList","children","index","setTimeout","width","DROP","newIndex","targetList","t","find","positionChanged","length","request","methodname","args","action","dir","table","field","key","position","call","fail","exception"],"mappings":"AAeAA,OAAM,mBAAC,CAAC,QAAD,CAAW,oBAAX,CAAiC,WAAjC,CAA8C,mBAA9C,CAAD,CAAqE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA8C,CACrH,MAAO,CACHC,IAAI,CAAE,cAASC,CAAT,CAAkBC,CAAlB,CAA8B,CAEhC,GAAIC,CAAAA,CAAI,CAAG,GAAIN,CAAAA,CAAJ,C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IFyB,KAAK,CAAEV,CAAC,CAACf,IAAF,CAAO,YAAP,CAJL,CAKF0B,GAAG,CAAEX,CAAC,CAACf,IAAF,CAAO,UAAP,CALH,CAMFS,KAAK,CAAEM,CAAC,CAACf,IAAF,CAAO,YAAP,CANL,CAOF2B,QAAQ,CAAEd,CAAQ,CAAGZ,CAPnB,CAFI,CAAd,CAYAX,CAAI,CAACsC,IAAL,CAAU,CAACT,CAAD,CAAV,EAAqB,CAArB,EAAwBU,IAAxB,CAA6BtC,CAAY,CAACuC,SAA1C,CACH,CACJ,CA1BD,CA2BH,CAnCE,CAqCV,CAtCK,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\ndefine(['jquery', 'core/sortable_list', 'core/ajax', 'core/notification'], function($, SortableList, Ajax, Notification) {\n return {\n init: function(tableid, moveaction) {\n // Initialise sortable for the given list.\n var sort = new SortableList('#' + tableid + ' tbody');\n sort.getElementName = function(element) {\n return $.Deferred().resolve(element.attr('data-name'));\n };\n var origIndex;\n $('#' + tableid + ' tbody tr').on(SortableList.EVENTS.DRAGSTART, function(_, info) {\n // Remember position of the element in the beginning of dragging.\n origIndex = info.sourceList.children().index(info.element);\n // Resize the \"proxy\" element to be the same width as the main element.\n setTimeout(function() {\n $('.sortable-list-is-dragged').width(info.element.width());\n }, 501);\n }).on(SortableList.EVENTS.DROP, function(_, info) {\n // When a list element was moved send AJAX request to the server.\n var newIndex = info.targetList.children().index(info.element);\n var t = info.element.find('[data-action=' + moveaction + ']');\n if (info.positionChanged && t.length) {\n var request = {\n methodname: 'tool_xmldb_invoke_move_action',\n args: {\n action: moveaction,\n dir: t.attr('data-dir'),\n table: t.attr('data-table'),\n field: t.attr('data-field'),\n key: t.attr('data-key'),\n index: t.attr('data-index'),\n position: newIndex - origIndex\n }\n };\n Ajax.call([request])[0].fail(Notification.exception);\n }\n });\n }\n };\n});\n"],"file":"move.min.js"} \ No newline at end of file +{"version":3,"file":"move.min.js","sources":["../src/move.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\ndefine(['jquery', 'core/sortable_list', 'core/ajax', 'core/notification'], function($, SortableList, Ajax, Notification) {\n return {\n init: function(tableid, moveaction) {\n // Initialise sortable for the given list.\n var sort = new SortableList('#' + tableid + ' tbody');\n sort.getElementName = function(element) {\n return $.Deferred().resolve(element.attr('data-name'));\n };\n var origIndex;\n $('#' + tableid + ' tbody tr').on(SortableList.EVENTS.DRAGSTART, function(_, info) {\n // Remember position of the element in the beginning of dragging.\n origIndex = info.sourceList.children().index(info.element);\n // Resize the \"proxy\" element to be the same width as the main element.\n setTimeout(function() {\n $('.sortable-list-is-dragged').width(info.element.width());\n }, 501);\n }).on(SortableList.EVENTS.DROP, function(_, info) {\n // When a list element was moved send AJAX request to the server.\n var newIndex = info.targetList.children().index(info.element);\n var t = info.element.find('[data-action=' + moveaction + ']');\n if (info.positionChanged && t.length) {\n var request = {\n methodname: 'tool_xmldb_invoke_move_action',\n args: {\n action: moveaction,\n dir: t.attr('data-dir'),\n table: t.attr('data-table'),\n field: t.attr('data-field'),\n key: t.attr('data-key'),\n index: t.attr('data-index'),\n position: newIndex - origIndex\n }\n };\n Ajax.call([request])[0].fail(Notification.exception);\n }\n });\n }\n };\n});\n"],"names":["define","$","SortableList","Ajax","Notification","init","tableid","moveaction","origIndex","getElementName","element","Deferred","resolve","attr","on","EVENTS","DRAGSTART","_","info","sourceList","children","index","setTimeout","width","DROP","newIndex","targetList","t","find","positionChanged","length","request","methodname","args","action","dir","table","field","key","position","call","fail","exception"],"mappings":"AAeAA,yBAAO,CAAC,SAAU,qBAAsB,YAAa,sBAAsB,SAASC,EAAGC,aAAcC,KAAMC,oBAChG,CACHC,KAAM,SAASC,QAASC,gBAMhBC,UAJO,IAAIN,aAAa,IAAMI,QAAU,UACvCG,eAAiB,SAASC,gBACpBT,EAAEU,WAAWC,QAAQF,QAAQG,KAAK,eAG7CZ,EAAE,IAAMK,QAAU,aAAaQ,GAAGZ,aAAaa,OAAOC,WAAW,SAASC,EAAGC,MAEzEV,UAAYU,KAAKC,WAAWC,WAAWC,MAAMH,KAAKR,SAElDY,YAAW,WACPrB,EAAE,6BAA6BsB,MAAML,KAAKR,QAAQa,WACnD,QACJT,GAAGZ,aAAaa,OAAOS,MAAM,SAASP,EAAGC,UAEpCO,SAAWP,KAAKQ,WAAWN,WAAWC,MAAMH,KAAKR,SACjDiB,EAAIT,KAAKR,QAAQkB,KAAK,gBAAkBrB,WAAa,QACrDW,KAAKW,iBAAmBF,EAAEG,OAAQ,KAC9BC,QAAU,CACVC,WAAY,gCACZC,KAAM,CACFC,OAAQ3B,WACR4B,IAAKR,EAAEd,KAAK,YACZuB,MAAOT,EAAEd,KAAK,cACdwB,MAAOV,EAAEd,KAAK,cACdyB,IAAKX,EAAEd,KAAK,YACZQ,MAAOM,EAAEd,KAAK,cACd0B,SAAUd,SAAWjB,YAG7BL,KAAKqC,KAAK,CAACT,UAAU,GAAGU,KAAKrC,aAAasC"} \ No newline at end of file diff --git a/availability/amd/build/availability_more.min.js b/availability/amd/build/availability_more.min.js index 9c4875851ea..22358c76610 100644 --- a/availability/amd/build/availability_more.min.js +++ b/availability/amd/build/availability_more.min.js @@ -1,2 +1,11 @@ -define ("core_availability/availability_more",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;var b={regions:{availability:"[data-region=\"availability-multiple\"]"},actions:{showmorelink:"[data-action=\"showmore\"]"},classes:{hidden:"d-none",visible:"d-block"}},c=function(a){var c=a.target.closest(b.actions.showmorelink);if(null===c){return}var d=c.closest(b.regions.availability);d.querySelectorAll("."+b.classes.hidden).forEach(function(a){a.classList.remove(b.classes.hidden)});d.querySelectorAll("."+b.classes.visible).forEach(function(a){a.classList.remove(b.classes.visible);a.classList.add(b.classes.hidden)});a.preventDefault()};a.init=function init(){var a=document.querySelector("body");if(!a.dataset.showmoreactive){document.addEventListener("click",c);a.dataset.showmoreactive=1}}}); -//# sourceMappingURL=availability_more.min.js.map +define("core_availability/availability_more",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0; +/** + * Show more action for availablity information. + * + * @module core_availability/availability_more + * @copyright 2021 Bas Brands + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +const Selectors_regions={availability:'[data-region="availability-multiple"]'},Selectors_actions={showmorelink:'[data-action="showmore"]'},Selectors_classes={hidden:"d-none",visible:"d-block"},showMoreHandler=event=>{const triggerElement=event.target.closest(Selectors_actions.showmorelink);if(null===triggerElement)return;const container=triggerElement.closest(Selectors_regions.availability);container.querySelectorAll("."+Selectors_classes.hidden).forEach((function(node){node.classList.remove(Selectors_classes.hidden)})),container.querySelectorAll("."+Selectors_classes.visible).forEach((function(node){node.classList.remove(Selectors_classes.visible),node.classList.add(Selectors_classes.hidden)})),event.preventDefault()};_exports.init=()=>{const body=document.querySelector("body");body.dataset.showmoreactive||(document.addEventListener("click",showMoreHandler),body.dataset.showmoreactive=1)}})); + +//# sourceMappingURL=availability_more.min.js.map \ No newline at end of file diff --git a/availability/amd/build/availability_more.min.js.map b/availability/amd/build/availability_more.min.js.map index 75f162e592f..35247475686 100644 --- a/availability/amd/build/availability_more.min.js.map +++ b/availability/amd/build/availability_more.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/availability_more.js"],"names":["Selectors","regions","availability","actions","showmorelink","classes","hidden","visible","showMoreHandler","event","triggerElement","target","closest","container","querySelectorAll","forEach","node","classList","remove","add","preventDefault","init","body","document","querySelector","dataset","showmoreactive","addEventListener"],"mappings":"qJA0BMA,CAAAA,CAAS,CAAG,CACdC,OAAO,CAAE,CACLC,YAAY,CAAE,yCADT,CADK,CAIdC,OAAO,CAAE,CACLC,YAAY,CAAE,4BADT,CAJK,CAOdC,OAAO,CAAE,CACLC,MAAM,CAAE,QADH,CAELC,OAAO,CAAE,SAFJ,CAPK,C,CAmBZC,CAAe,CAAG,SAACC,CAAD,CAAW,CAC/B,GAAMC,CAAAA,CAAc,CAAGD,CAAK,CAACE,MAAN,CAAaC,OAAb,CAAqBZ,CAAS,CAACG,OAAV,CAAkBC,YAAvC,CAAvB,CACA,GAAuB,IAAnB,GAAAM,CAAJ,CAA6B,CACzB,MACH,CACD,GAAMG,CAAAA,CAAS,CAAGH,CAAc,CAACE,OAAf,CAAuBZ,CAAS,CAACC,OAAV,CAAkBC,YAAzC,CAAlB,CACAW,CAAS,CAACC,gBAAV,CAA2B,IAAMd,CAAS,CAACK,OAAV,CAAkBC,MAAnD,EAA2DS,OAA3D,CAAmE,SAASC,CAAT,CAAe,CAC9EA,CAAI,CAACC,SAAL,CAAeC,MAAf,CAAsBlB,CAAS,CAACK,OAAV,CAAkBC,MAAxC,CACH,CAFD,EAGAO,CAAS,CAACC,gBAAV,CAA2B,IAAMd,CAAS,CAACK,OAAV,CAAkBE,OAAnD,EAA4DQ,OAA5D,CAAoE,SAASC,CAAT,CAAe,CAC/EA,CAAI,CAACC,SAAL,CAAeC,MAAf,CAAsBlB,CAAS,CAACK,OAAV,CAAkBE,OAAxC,EACAS,CAAI,CAACC,SAAL,CAAeE,GAAf,CAAmBnB,CAAS,CAACK,OAAV,CAAkBC,MAArC,CACH,CAHD,EAIAG,CAAK,CAACW,cAAN,EACH,C,QAOmB,QAAPC,CAAAA,IAAO,EAAM,CACtB,GAAMC,CAAAA,CAAI,CAAGC,QAAQ,CAACC,aAAT,CAAuB,MAAvB,CAAb,CACA,GAAI,CAACF,CAAI,CAACG,OAAL,CAAaC,cAAlB,CAAkC,CAC9BH,QAAQ,CAACI,gBAAT,CAA0B,OAA1B,CAAmCnB,CAAnC,EACAc,CAAI,CAACG,OAAL,CAAaC,cAAb,CAA8B,CACjC,CACJ,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 .\n\n/**\n * Show more action for availablity information.\n *\n * @module core_availability/availability_more\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Availability info selectors.\n */\nconst Selectors = {\n regions: {\n availability: '[data-region=\"availability-multiple\"]',\n },\n actions: {\n showmorelink: '[data-action=\"showmore\"]'\n },\n classes: {\n hidden: 'd-none',\n visible: 'd-block',\n\n }\n};\n\n/**\n * Displays all the availability information in case part of it is hidden.\n *\n * @param {Event} event the triggered event\n */\nconst showMoreHandler = (event) => {\n const triggerElement = event.target.closest(Selectors.actions.showmorelink);\n if (triggerElement === null) {\n return;\n }\n const container = triggerElement.closest(Selectors.regions.availability);\n container.querySelectorAll('.' + Selectors.classes.hidden).forEach(function(node) {\n node.classList.remove(Selectors.classes.hidden);\n });\n container.querySelectorAll('.' + Selectors.classes.visible).forEach(function(node) {\n node.classList.remove(Selectors.classes.visible);\n node.classList.add(Selectors.classes.hidden);\n });\n event.preventDefault();\n};\n\n/**\n * Initialise the eventlister for the showmore action on availability information.\n *\n * @method init\n */\nexport const init = () => {\n const body = document.querySelector('body');\n if (!body.dataset.showmoreactive) {\n document.addEventListener('click', showMoreHandler);\n body.dataset.showmoreactive = 1;\n }\n};\n"],"file":"availability_more.min.js"} \ No newline at end of file +{"version":3,"file":"availability_more.min.js","sources":["../src/availability_more.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 * Show more action for availablity information.\n *\n * @module core_availability/availability_more\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Availability info selectors.\n */\nconst Selectors = {\n regions: {\n availability: '[data-region=\"availability-multiple\"]',\n },\n actions: {\n showmorelink: '[data-action=\"showmore\"]'\n },\n classes: {\n hidden: 'd-none',\n visible: 'd-block',\n\n }\n};\n\n/**\n * Displays all the availability information in case part of it is hidden.\n *\n * @param {Event} event the triggered event\n */\nconst showMoreHandler = (event) => {\n const triggerElement = event.target.closest(Selectors.actions.showmorelink);\n if (triggerElement === null) {\n return;\n }\n const container = triggerElement.closest(Selectors.regions.availability);\n container.querySelectorAll('.' + Selectors.classes.hidden).forEach(function(node) {\n node.classList.remove(Selectors.classes.hidden);\n });\n container.querySelectorAll('.' + Selectors.classes.visible).forEach(function(node) {\n node.classList.remove(Selectors.classes.visible);\n node.classList.add(Selectors.classes.hidden);\n });\n event.preventDefault();\n};\n\n/**\n * Initialise the eventlister for the showmore action on availability information.\n *\n * @method init\n */\nexport const init = () => {\n const body = document.querySelector('body');\n if (!body.dataset.showmoreactive) {\n document.addEventListener('click', showMoreHandler);\n body.dataset.showmoreactive = 1;\n }\n};\n"],"names":["Selectors","availability","showmorelink","hidden","visible","showMoreHandler","event","triggerElement","target","closest","container","querySelectorAll","forEach","node","classList","remove","add","preventDefault","body","document","querySelector","dataset","showmoreactive","addEventListener"],"mappings":";;;;;;;;MA0BMA,kBACO,CACLC,aAAc,yCAFhBD,kBAIO,CACLE,aAAc,4BALhBF,kBAOO,CACLG,OAAQ,SACRC,QAAS,WAUXC,gBAAmBC,cACfC,eAAiBD,MAAME,OAAOC,QAAQT,kBAAkBE,iBACvC,OAAnBK,4BAGEG,UAAYH,eAAeE,QAAQT,kBAAkBC,cAC3DS,UAAUC,iBAAiB,IAAMX,kBAAkBG,QAAQS,SAAQ,SAASC,MACxEA,KAAKC,UAAUC,OAAOf,kBAAkBG,WAE5CO,UAAUC,iBAAiB,IAAMX,kBAAkBI,SAASQ,SAAQ,SAASC,MACzEA,KAAKC,UAAUC,OAAOf,kBAAkBI,SACxCS,KAAKC,UAAUE,IAAIhB,kBAAkBG,WAEzCG,MAAMW,gCAQU,WACVC,KAAOC,SAASC,cAAc,QAC/BF,KAAKG,QAAQC,iBACdH,SAASI,iBAAiB,QAASlB,iBACnCa,KAAKG,QAAQC,eAAiB"} \ No newline at end of file diff --git a/availability/condition/completion/yui/build/moodle-availability_completion-form/moodle-availability_completion-form-min.js b/availability/condition/completion/yui/build/moodle-availability_completion-form/moodle-availability_completion-form-min.js index 3c31ebec29f..06805c7054d 100644 --- a/availability/condition/completion/yui/build/moodle-availability_completion-form/moodle-availability_completion-form-min.js +++ b/availability/condition/completion/yui/build/moodle-availability_completion-form/moodle-availability_completion-form-min.js @@ -1 +1 @@ -YUI.add("moodle-availability_completion-form",function(o,e){M.availability_completion=M.availability_completion||{},M.availability_completion.form=o.Object(M.core_availability.plugin),M.availability_completion.form.initInner=function(e){this.cms=e},M.availability_completion.form.getNode=function(e){var i,l,t,a=' '+M.util.get_string("title","availability_completion")+' ",t=o.Node.create(''+a+""),e.cm!==undefined&&t.one("select[name=cm] > option[value="+e.cm+"]")&&t.one("select[name=cm]").set("value",""+e.cm),e.e!==undefined&&t.one("select[name=e]").set("value",""+e.e),M.availability_completion.form.addedEvents||(M.availability_completion.form.addedEvents=!0,o.one(".availability-field").delegate("change",function(){M.core_availability.form.update()},".availability_completion select")),t},M.availability_completion.form.fillValue=function(e,i){e.cm=parseInt(i.one("select[name=cm]").get("value"),10),e.e=parseInt(i.one("select[name=e]").get("value"),10)},M.availability_completion.form.fillErrors=function(i,e){var l,t=parseInt(e.one("select[name=cm]").get("value"),10);0===t&&i.push("availability_completion:error_selectcmid"),2!==(l=parseInt(e.one("select[name=e]").get("value"),10))&&3!==l||this.cms.forEach(function(e){e.id===t&&null===e.completiongradeitemnumber&&i.push("availability_completion:error_selectcmidpassfail")})}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file +YUI.add("moodle-availability_completion-form",function(o,e){M.availability_completion=M.availability_completion||{},M.availability_completion.form=o.Object(M.core_availability.plugin),M.availability_completion.form.initInner=function(e){this.cms=e},M.availability_completion.form.getNode=function(e){for(var i,l,t=' '+M.util.get_string("title","availability_completion")+' ",l=o.Node.create(''+t+""),e.cm!==undefined&&l.one("select[name=cm] > option[value="+e.cm+"]")&&l.one("select[name=cm]").set("value",""+e.cm),e.e!==undefined&&l.one("select[name=e]").set("value",""+e.e),M.availability_completion.form.addedEvents||(M.availability_completion.form.addedEvents=!0,o.one(".availability-field").delegate("change",function(){M.core_availability.form.update()},".availability_completion select")),l},M.availability_completion.form.fillValue=function(e,i){e.cm=parseInt(i.one("select[name=cm]").get("value"),10),e.e=parseInt(i.one("select[name=e]").get("value"),10)},M.availability_completion.form.fillErrors=function(i,e){var l=parseInt(e.one("select[name=cm]").get("value"),10);0===l&&i.push("availability_completion:error_selectcmid"),2!==(e=parseInt(e.one("select[name=e]").get("value"),10))&&3!==e||this.cms.forEach(function(e){e.id===l&&null===e.completiongradeitemnumber&&i.push("availability_completion:error_selectcmidpassfail")})}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file diff --git a/availability/condition/date/yui/build/moodle-availability_date-form/moodle-availability_date-form-min.js b/availability/condition/date/yui/build/moodle-availability_date-form/moodle-availability_date-form-min.js index 4235144f9b4..04b294fb600 100644 --- a/availability/condition/date/yui/build/moodle-availability_date-form/moodle-availability_date-form-min.js +++ b/availability/condition/date/yui/build/moodle-availability_date-form/moodle-availability_date-form-min.js @@ -1 +1 @@ -YUI.add("moodle-availability_date-form",function(s,e){M.availability_date=M.availability_date||{},M.availability_date.form=s.Object(M.core_availability.plugin),M.availability_date.form.initInner=function(e,a){this.html=e,this.defaultTime=a},M.availability_date.form.getNode=function(e){var a,t,i,l,n=''+M.util.get_string("direction_before","availability_date")+' "+this.html,o=s.Node.create(""+n+"");return e.t!==undefined?(o.setData("time",e.t),o.all("select:not([name=direction])").each(function(e){e.set("disabled",!0)}),a=M.cfg.wwwroot+"/availability/condition/date/ajax.php?action=fromtime&time="+e.t,s.io(a,{on:{success:function(e,a){var t,i,l=s.JSON.parse(a.responseText);for(t in l)(i=o.one("select[name=x\\["+t+"\\]]")).set("value",""+l[t]),i.set("disabled",!1)},failure:function(){window.alert(M.util.get_string("ajaxerror","availability_date"))}}})):o.setData("time",this.defaultTime),e.d!==undefined&&o.one("select[name=direction]").set("value",e.d),M.availability_date.form.addedEvents||(M.availability_date.form.addedEvents=!0,(t=s.one(".availability-field")).delegate("change",function(){M.core_availability.form.update()},".availability_date select[name=direction]"),t.delegate("change",function(){M.availability_date.form.updateTime(this.ancestor("span.availability_date"))},".availability_date select:not([name=direction])")),o.one("a[href=#]")&&(M.form.dateselector.init_single_date_selector(o),i=o.one("select[name=x\\[year\\]]"),l=i.set,i.set=function(e,a){l.call(i,e,a),"selectedIndex"===e&&setTimeout(function(){M.availability_date.form.updateTime(o)},0)}),o},M.availability_date.form.updateTime=function(t){var e=M.cfg.wwwroot+"/availability/condition/date/ajax.php?action=totime&year="+t.one("select[name=x\\[year\\]]").get("value")+"&month="+t.one("select[name=x\\[month\\]]").get("value")+"&day="+t.one("select[name=x\\[day\\]]").get("value")+"&hour="+t.one("select[name=x\\[hour\\]]").get("value")+"&minute="+t.one("select[name=x\\[minute\\]]").get("value");s.io(e,{on:{success:function(e,a){t.setData("time",a.responseText),M.core_availability.form.update()},failure:function(){window.alert(M.util.get_string("ajaxerror","availability_date"))}}})},M.availability_date.form.fillValue=function(e,a){e.d=a.one("select[name=direction]").get("value"),e.t=parseInt(a.getData("time"),10)}},"@VERSION@",{requires:["base","node","event","io","moodle-core_availability-form"]}); \ No newline at end of file +YUI.add("moodle-availability_date-form",function(o,e){M.availability_date=M.availability_date||{},M.availability_date.form=o.Object(M.core_availability.plugin),M.availability_date.form.initInner=function(e,a){this.html=e,this.defaultTime=a},M.availability_date.form.getNode=function(e){var t,i,a=''+M.util.get_string("direction_before","availability_date")+' "+this.html,n=o.Node.create(""+a+"");return e.t!==undefined?(n.setData("time",e.t),n.all("select:not([name=direction])").each(function(e){e.set("disabled",!0)}),a=M.cfg.wwwroot+"/availability/condition/date/ajax.php?action=fromtime&time="+e.t,o.io(a,{on:{success:function(e,a){var t,i,l=o.JSON.parse(a.responseText);for(t in l)(i=n.one("select[name=x\\["+t+"\\]]")).set("value",""+l[t]),i.set("disabled",!1)},failure:function(){window.alert(M.util.get_string("ajaxerror","availability_date"))}}})):n.setData("time",this.defaultTime),e.d!==undefined&&n.one("select[name=direction]").set("value",e.d),M.availability_date.form.addedEvents||(M.availability_date.form.addedEvents=!0,(a=o.one(".availability-field")).delegate("change",function(){M.core_availability.form.update()},".availability_date select[name=direction]"),a.delegate("change",function(){M.availability_date.form.updateTime(this.ancestor("span.availability_date"))},".availability_date select:not([name=direction])")),n.one("a[href=#]")&&(M.form.dateselector.init_single_date_selector(n),t=n.one("select[name=x\\[year\\]]"),i=t.set,t.set=function(e,a){i.call(t,e,a),"selectedIndex"===e&&setTimeout(function(){M.availability_date.form.updateTime(n)},0)}),n},M.availability_date.form.updateTime=function(t){var e=M.cfg.wwwroot+"/availability/condition/date/ajax.php?action=totime&year="+t.one("select[name=x\\[year\\]]").get("value")+"&month="+t.one("select[name=x\\[month\\]]").get("value")+"&day="+t.one("select[name=x\\[day\\]]").get("value")+"&hour="+t.one("select[name=x\\[hour\\]]").get("value")+"&minute="+t.one("select[name=x\\[minute\\]]").get("value");o.io(e,{on:{success:function(e,a){t.setData("time",a.responseText),M.core_availability.form.update()},failure:function(){window.alert(M.util.get_string("ajaxerror","availability_date"))}}})},M.availability_date.form.fillValue=function(e,a){e.d=a.one("select[name=direction]").get("value"),e.t=parseInt(a.getData("time"),10)}},"@VERSION@",{requires:["base","node","event","io","moodle-core_availability-form"]}); \ No newline at end of file diff --git a/availability/condition/grade/yui/build/moodle-availability_grade-form/moodle-availability_grade-form-min.js b/availability/condition/grade/yui/build/moodle-availability_grade-form/moodle-availability_grade-form-min.js index 0e71a081388..2e8fe8c5a40 100644 --- a/availability/condition/grade/yui/build/moodle-availability_grade-form/moodle-availability_grade-form-min.js +++ b/availability/condition/grade/yui/build/moodle-availability_grade-form/moodle-availability_grade-form-min.js @@ -1 +1 @@ -YUI.add("moodle-availability_grade-form",function(o,a){M.availability_grade=M.availability_grade||{},M.availability_grade.form=o.Object(M.core_availability.plugin),M.availability_grade.form.grades=null,M.availability_grade.form.initInner=function(a){this.grades=a,this.nodesSoFar=0},M.availability_grade.form.getNode=function(a){var e,i,l,t,n,r;for(this.nodesSoFar++,e='
%
%',t=o.Node.create('
'+e+"
"),a.id!==undefined&&t.one("select[name=id] > option[value="+a.id+"]")&&t.one("select[name=id]").set("value",""+a.id),a.min!==undefined&&(t.one("input[name=min]").set("checked",!0),t.one("input[name=minval]").set("value",a.min)),a.max!==undefined&&(t.one("input[name=max]").set("checked",!0),t.one("input[name=maxval]").set("value",a.max)),n=function(a,e){var i=a.ancestor("label").next("label").one("input"),l=a.get("checked");return i.set("disabled",!l),e&&l&&i.focus(),l},t.all("input[type=checkbox]").each(n),M.availability_grade.form.addedEvents||(M.availability_grade.form.addedEvents=!0,(r=o.one(".availability-field")).delegate("change",function(){M.core_availability.form.update()},".availability_grade select[name=id]"),r.delegate("click",function(){n(this,!0),M.core_availability.form.update()},".availability_grade input[type=checkbox]"),r.delegate("valuechange",function(){M.core_availability.form.update()},".availability_grade input[type=text]")),t},M.availability_grade.form.fillValue=function(a,e){a.id=parseInt(e.one("select[name=id]").get("value"),10),e.one("input[name=min]").get("checked")&&(a.min=this.getValue("minval",e)),e.one("input[name=max]").get("checked")&&(a.max=this.getValue("maxval",e))},M.availability_grade.form.getValue=function(a,e){var i,l=e.one("input[name="+a+"]").get("value");return!/^[0-9]+([.,][0-9]+)?$/.test(l)||(i=parseFloat(l.replace(",",".")))<0||100
%
%',t=r.Node.create('
'+e+"
"),a.id!==undefined&&t.one("select[name=id] > option[value="+a.id+"]")&&t.one("select[name=id]").set("value",""+a.id),a.min!==undefined&&(t.one("input[name=min]").set("checked",!0),t.one("input[name=minval]").set("value",a.min)),a.max!==undefined&&(t.one("input[name=max]").set("checked",!0),t.one("input[name=maxval]").set("value",a.max)),n=function(a,e){var i=a.ancestor("label").next("label").one("input"),a=a.get("checked");return i.set("disabled",!a),e&&a&&i.focus(),a},t.all("input[type=checkbox]").each(n),M.availability_grade.form.addedEvents||(M.availability_grade.form.addedEvents=!0,(a=r.one(".availability-field")).delegate("change",function(){M.core_availability.form.update()},".availability_grade select[name=id]"),a.delegate("click",function(){n(this,!0),M.core_availability.form.update()},".availability_grade input[type=checkbox]"),a.delegate("valuechange",function(){M.core_availability.form.update()},".availability_grade input[type=text]")),t},M.availability_grade.form.fillValue=function(a,e){a.id=parseInt(e.one("select[name=id]").get("value"),10),e.one("input[name=min]").get("checked")&&(a.min=this.getValue("minval",e)),e.one("input[name=max]").get("checked")&&(a.max=this.getValue("maxval",e))},M.availability_grade.form.getValue=function(a,e){a=e.one("input[name="+a+"]").get("value");return!/^[0-9]+([.,][0-9]+)?$/.test(a)||(e=parseFloat(a.replace(",",".")))<0||100 ",l=t.Node.create(''+o+""),i.creating===undefined&&(i.id!==undefined&&l.one("select[name=id] > option[value="+i.id+"]")?l.one("select[name=id]").set("value",""+i.id):i.id===undefined&&l.one("select[name=id]").set("value","any")),M.availability_group.form.addedEvents||(M.availability_group.form.addedEvents=!0,t.one(".availability-field").delegate("change",function(){M.core_availability.form.update()},".availability_group select")),l},M.availability_group.form.fillValue=function(i,a){var e=a.one("select[name=id]").get("value");"choose"===e?i.id="choose":"any"!==e&&(i.id=parseInt(e,10))},M.availability_group.form.fillErrors=function(i,a){var e={};this.fillValue(e,a),e.id&&"choose"===e.id&&i.push("availability_group:error_selectgroup")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file +YUI.add("moodle-availability_group-form",function(t,i){M.availability_group=M.availability_group||{},M.availability_group.form=t.Object(M.core_availability.plugin),M.availability_group.form.groups=null,M.availability_group.form.initInner=function(i){this.groups=i},M.availability_group.form.getNode=function(i){for(var a,e,l='")+""),i.creating===undefined&&(i.id!==undefined&&e.one("select[name=id] > option[value="+i.id+"]")?e.one("select[name=id]").set("value",""+i.id):i.id===undefined&&e.one("select[name=id]").set("value","any")),M.availability_group.form.addedEvents||(M.availability_group.form.addedEvents=!0,t.one(".availability-field").delegate("change",function(){M.core_availability.form.update()},".availability_group select")),e},M.availability_group.form.fillValue=function(i,a){a=a.one("select[name=id]").get("value");"choose"===a?i.id="choose":"any"!==a&&(i.id=parseInt(a,10))},M.availability_group.form.fillErrors=function(i,a){var e={};this.fillValue(e,a),e.id&&"choose"===e.id&&i.push("availability_group:error_selectgroup")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file diff --git a/availability/condition/grouping/yui/build/moodle-availability_grouping-form/moodle-availability_grouping-form-min.js b/availability/condition/grouping/yui/build/moodle-availability_grouping-form/moodle-availability_grouping-form-min.js index 19802037577..c07e5f1725e 100644 --- a/availability/condition/grouping/yui/build/moodle-availability_grouping-form/moodle-availability_grouping-form-min.js +++ b/availability/condition/grouping/yui/build/moodle-availability_grouping-form/moodle-availability_grouping-form-min.js @@ -1 +1 @@ -YUI.add("moodle-availability_grouping-form",function(n,i){M.availability_grouping=M.availability_grouping||{},M.availability_grouping.form=n.Object(M.core_availability.plugin),M.availability_grouping.form.groupings=null,M.availability_grouping.form.initInner=function(i){this.groupings=i},M.availability_grouping.form.getNode=function(i){var a,e,l,o='",l=n.Node.create(''+o+""),i.id!==undefined&&l.one("select[name=id] > option[value="+i.id+"]")&&l.one("select[name=id]").set("value",""+i.id),M.availability_grouping.form.addedEvents||(M.availability_grouping.form.addedEvents=!0,n.one(".availability-field").delegate("change",function(){M.core_availability.form.update()},".availability_grouping select")),l},M.availability_grouping.form.fillValue=function(i,a){var e=a.one("select[name=id]").get("value");i.id="choose"===e?"choose":parseInt(e,10)},M.availability_grouping.form.fillErrors=function(i,a){var e={};this.fillValue(e,a),"choose"===e.id&&i.push("availability_grouping:error_selectgrouping")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file +YUI.add("moodle-availability_grouping-form",function(n,i){M.availability_grouping=M.availability_grouping||{},M.availability_grouping.form=n.Object(M.core_availability.plugin),M.availability_grouping.form.groupings=null,M.availability_grouping.form.initInner=function(i){this.groupings=i},M.availability_grouping.form.getNode=function(i){for(var a,e,l='")+""),i.id!==undefined&&e.one("select[name=id] > option[value="+i.id+"]")&&e.one("select[name=id]").set("value",""+i.id),M.availability_grouping.form.addedEvents||(M.availability_grouping.form.addedEvents=!0,n.one(".availability-field").delegate("change",function(){M.core_availability.form.update()},".availability_grouping select")),e},M.availability_grouping.form.fillValue=function(i,a){a=a.one("select[name=id]").get("value");i.id="choose"===a?"choose":parseInt(a,10)},M.availability_grouping.form.fillErrors=function(i,a){var e={};this.fillValue(e,a),"choose"===e.id&&i.push("availability_grouping:error_selectgrouping")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file diff --git a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js index 38bb84f55eb..004d9f7f826 100644 --- a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js +++ b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js @@ -1 +1 @@ -YUI.add("moodle-availability_profile-form",function(f,e){M.availability_profile=M.availability_profile||{},M.availability_profile.form=f.Object(M.core_availability.plugin),M.availability_profile.form.profiles=null,M.availability_profile.form.initInner=function(e,i){this.standardFields=e,this.customFields=i},M.availability_profile.form.getNode=function(e){var i,l,a,t,o,s,n=' ',t=f.Node.create(''+n+""),e.sf!==undefined&&t.one("select[name=field] > option[value=sf_"+e.sf+"]")?t.one("select[name=field]").set("value","sf_"+e.sf):e.cf!==undefined&&t.one("select[name=field] > option[value=cf_"+e.cf+"]")&&t.one("select[name=field]").set("value","cf_"+e.cf),e.op!==undefined&&t.one("select[name=op] > option[value="+e.op+"]")&&(t.one("select[name=op]").set("value",e.op),"isempty"!==e.op&&"isnotempty"!==e.op||t.one("input[name=value]").set("disabled",!0)),e.v!==undefined&&t.one("input").set("value",e.v),M.availability_profile.form.addedEvents||(M.availability_profile.form.addedEvents=!0,o=function(e){var i=e.ancestor("span.availability_profile"),l=i.one("select[name=op]"),a="isempty"===l.get("value")||"isnotempty"===l.get("value");i.one("input[name=value]").set("disabled",a),M.core_availability.form.update()},(s=f.one(".availability-field")).delegate("change",function(){o(this)},".availability_profile select"),s.delegate("change",function(){o(this)},".availability_profile input[name=value]")),t},M.availability_profile.form.fillValue=function(e,i){var l,a=i.one("select[name=field]").get("value");"sf_"===a.substr(0,3)?e.sf=a.substr(3):"cf_"===a.substr(0,3)&&(e.cf=a.substr(3)),e.op=i.one("select[name=op]").get("value"),(l=i.one("input[name=value]")).get("disabled")||(e.v=l.get("value"))},M.availability_profile.form.fillErrors=function(e,i){var l={};this.fillValue(l,i),l.sf===undefined&&l.cf===undefined&&e.push("availability_profile:error_selectfield"),l.v!==undefined&&/^\s*$/.test(l.v)&&e.push("availability_profile:error_setvalue")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file +YUI.add("moodle-availability_profile-form",function(n,e){M.availability_profile=M.availability_profile||{},M.availability_profile.form=n.Object(M.core_availability.plugin),M.availability_profile.form.profiles=null,M.availability_profile.form.initInner=function(e,i){this.standardFields=e,this.customFields=i},M.availability_profile.form.getNode=function(e){for(var i,l,a,t,o=' ',a=n.Node.create(''+o+""),e.sf!==undefined&&a.one("select[name=field] > option[value=sf_"+e.sf+"]")?a.one("select[name=field]").set("value","sf_"+e.sf):e.cf!==undefined&&a.one("select[name=field] > option[value=cf_"+e.cf+"]")&&a.one("select[name=field]").set("value","cf_"+e.cf),e.op!==undefined&&a.one("select[name=op] > option[value="+e.op+"]")&&(a.one("select[name=op]").set("value",e.op),"isempty"!==e.op&&"isnotempty"!==e.op||a.one("input[name=value]").set("disabled",!0)),e.v!==undefined&&a.one("input").set("value",e.v),M.availability_profile.form.addedEvents||(M.availability_profile.form.addedEvents=!0,t=function(e){var e=e.ancestor("span.availability_profile"),i=e.one("select[name=op]"),i="isempty"===i.get("value")||"isnotempty"===i.get("value");e.one("input[name=value]").set("disabled",i),M.core_availability.form.update()},(e=n.one(".availability-field")).delegate("change",function(){t(this)},".availability_profile select"),e.delegate("change",function(){t(this)},".availability_profile input[name=value]")),a},M.availability_profile.form.fillValue=function(e,i){var l=i.one("select[name=field]").get("value");"sf_"===l.substr(0,3)?e.sf=l.substr(3):"cf_"===l.substr(0,3)&&(e.cf=l.substr(3)),e.op=i.one("select[name=op]").get("value"),(l=i.one("input[name=value]")).get("disabled")||(e.v=l.get("value"))},M.availability_profile.form.fillErrors=function(e,i){var l={};this.fillValue(l,i),l.sf===undefined&&l.cf===undefined&&e.push("availability_profile:error_selectfield"),l.v!==undefined&&/^\s*$/.test(l.v)&&e.push("availability_profile:error_setvalue")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); \ No newline at end of file diff --git a/availability/yui/build/moodle-core_availability-form/moodle-core_availability-form-min.js b/availability/yui/build/moodle-core_availability-form/moodle-core_availability-form-min.js index 88010289440..741ff3fac1d 100644 --- a/availability/yui/build/moodle-core_availability-form/moodle-core_availability-form-min.js +++ b/availability/yui/build/moodle-core_availability-form/moodle-core_availability-form-min.js @@ -1,3 +1,3 @@ -YUI.add("moodle-core_availability-form",function(c,i){M.core_availability=M.core_availability||{},M.core_availability.form={plugins:{},field:null,mainDiv:null,rootList:null,idCounter:0,restrictByGroup:null,init:function(i){var t,e,a,l,n,o,s;for(t in i)e=i[t],(a=M[e[0]].form).init.apply(a,e);if(this.field=c.one("#id_availabilityconditionsjson"),this.field.setAttribute("aria-hidden","true"),this.mainDiv=c.Node.create(''),this.field.insert(this.mainDiv,"after"),n=null,""!==(l=this.field.get("value")))try{n=c.JSON.parse(l)}catch(r){this.field.set("value","")}this.rootList=new M.core_availability.List(n,!0),this.mainDiv.appendChild(this.rootList.node),this.update(),this.rootList.renumber(),this.mainDiv.setAttribute("aria-live","polite"),this.field.ancestor("form").on("submit",function(){this.mainDiv.all("input,textarea,select").set("disabled",!0)},this),this.restrictByGroup=c.one("#restrictbygroup"),this.restrictByGroup&&(this.restrictByGroup.on("click",this.addRestrictByGroup,this),o=c.one("#id_groupmode"),s=c.one("#id_groupingid"),o&&o.on("change",this.updateRestrictByGroup,this),s&&s.on("change",this.updateRestrictByGroup,this),this.updateRestrictByGroup())},update:function(){var i=this.rootList.getValue(),t=[];this.rootList.fillErrors(t),0!==t.length&&(i.errors=t),this.field.set("value",c.JSON.stringify(i)),this.updateRestrictByGroup()},updateRestrictByGroup:function(){var i,t,e,a;this.restrictByGroup&&("&"!==this.rootList.getValue().op||(this.rootList.hasItemOfType("group")||this.rootList.hasItemOfType("grouping"))?this.restrictByGroup.set("disabled",!0):(i=c.one("#id_groupmode"),t=c.one("#id_groupingid"),e=1===Number(this.restrictByGroup.getData("groupavailability")),a=1===Number(this.restrictByGroup.getData("groupingavailability")),i&&0!==Number(i.get("value"))&&e||t&&0!==Number(t.get("value"))&&a?this.restrictByGroup.set("disabled",!1):this.restrictByGroup.set("disabled",!0)))},addRestrictByGroup:function(i){var t,e,a,l,n;i.preventDefault(),t=c.one("#id_groupmode"),e=c.one("#id_groupingid"),a=1===Number(this.restrictByGroup.getData("groupavailability")),l=1===Number(this.restrictByGroup.getData("groupingavailability")),e&&0!==Number(e.get("value"))&&l?n=new M.core_availability.Item({type:"grouping",id:Number(e.get("value"))},!0):t&&a&&(n=new M.core_availability.Item({type:"group"},!0)),null!==n&&(this.rootList.addChild(n),this.update(),this.rootList.renumber(),this.rootList.updateHtml())}},M.core_availability.plugin={allowAdd:!1,init:function(i,t,e){var a=i.replace(/^availability_/,"");this.allowAdd=t,(M.core_availability.form.plugins[a]=this).initInner.apply(this,e)},initInner:function(){},getNode:function(){throw"getNode not implemented"},fillValue:function(){throw"fillValue not implemented"},fillErrors:function(){},focusAfterAdd:function(i){i.one("input:not([disabled]),select:not([disabled])").focus()}},M.core_availability.List=function(i,t,e){var a,l,n,o,s,r,d;if(this.children=[],t!==undefined&&(this.root=t),this.node=c.Node.create('

'+M.util.get_string("listheader_sign_before","availability")+' '+M.util.get_string("listheader_single","availability")+''+M.util.get_string("listheader_multi_before","availability")+' "+M.util.get_string("listheader_multi_after","availability")+'
'+M.util.get_string("none","moodle")+'
'),t||this.node.addClass("availability-childlist d-sm-flex align-items-center"),this.inner=this.node.one("> .availability-inner"),a=!0,t?(i&&i.show!==undefined&&(a=i.show),this.eyeIcon=new M.core_availability.EyeIcon(!1,a),this.node.one(".availability-header").get("firstChild").insert(this.eyeIcon.span,"before")):e&&(i&&i.showc!==undefined&&(a=i.showc),this.eyeIcon=new M.core_availability.EyeIcon(!1,a),this.inner.insert(this.eyeIcon.span,"before")),t||(l=new M.core_availability.DeleteIcon(this),(n=this.node.one(".availability-none")).appendChild(document.createTextNode(" ")),n.appendChild(l.span),n.appendChild(c.Node.create(''+M.util.get_string("invalid","availability")+""))),(o=c.Node.create('")).on("click",function(){this.clickAdd()},this),this.node.one("div.availability-button").appendChild(o),i){switch(i.op){case"&":case"|":this.node.one(".availability-neg").set("value","");break;case"!&":case"!|":this.node.one(".availability-neg").set("value","!")}switch(i.op){case"&":case"!&":this.node.one(".availability-op").set("value","&");break;case"|":case"!|":this.node.one(".availability-op").set("value","|")}for(s=0;s
')),this.children.push(i),this.inner.one(".availability-children").appendChild(i.node)},M.core_availability.List.prototype.focusAfterAdd=function(){this.inner.one("button").focus()},M.core_availability.List.prototype.isIndividualShowIcons=function(){var i,t;if(!this.root)throw"Can only call this on root list";return i="!"===this.node.one(".availability-neg").get("value"),t="|"===this.node.one(".availability-op").get("value"),!i&&!t||i&&t},M.core_availability.List.prototype.renumber=function(i){var t,e,a,l={count:this.children.length};for(t=i===undefined?l.number="":(l.number=i+":",i+"."),e=M.util.get_string("setheading","availability",l),this.node.one("> h3").set("innerHTML",e),a=0;a .availability-children").removeAttribute("aria-hidden"),this.inner.one("> .availability-none").setAttribute("aria-hidden","true"),this.inner.one("> .availability-header").removeAttribute("aria-hidden"),1 .availability-children").setAttribute("aria-hidden","true"),this.inner.one("> .availability-none").removeAttribute("aria-hidden"),this.inner.one("> .availability-header").setAttribute("aria-hidden","true")),this.root){for(i=this.isIndividualShowIcons(),t=0;t .availability-children > .availability-connector span.label").each(function(i){i.set("innerHTML",a)})},M.core_availability.List.prototype.deleteDescendant=function(i){var t,e,a;for(t=0;t .availability-children").removeChild(a),M.core_availability.form.update(),this.updateHtml(),this.inner.one("> .availability-button").one("button").focus(),!0;if(e instanceof M.core_availability.List&&e.deleteDescendant(i))return!0}return!1},M.core_availability.List.prototype.clickAdd=function(){var i,t,e,a,l,n,o=c.Node.create('
    "),s=o.one("button"),r={dialog:null},d=o.one("ul");for(l in M.core_availability.form.plugins)M.core_availability.form.plugins[l].allowAdd&&(i=c.Node.create('
  • '),t="availability_addrestriction_"+l,(e=c.Node.create('
    ")).on("click",this.getAddHandler(l,r),this),i.appendChild(e),a=c.Node.create('
    "),i.appendChild(a),d.appendChild(i));i=c.Node.create('
  • '),t="availability_addrestriction_list_",(e=c.Node.create('
    ")).on("click",this.getAddHandler(null,r),this),i.appendChild(e),a=c.Node.create('
    "),i.appendChild(a),d.appendChild(i),n={headerContent:M.util.get_string("addrestriction","availability"),bodyContent:o,additionalBaseClass:"availability-dialogue",draggable:!0,modal:!0,closeButton:!1,width:"450px"},r.dialog=new M.core.dialogue(n),r.dialog.show(),s.on("click",function(){r.dialog.destroy(),this.inner.one("> .availability-button").one("button").focus()},this)},M.core_availability.List.prototype.getAddHandler=function(t,e){return function(){var i;i=t?new M.core_availability.Item({type:t,creating:!0},this.root):new M.core_availability.List({c:[],showc:!0},!1,this.root),this.addChild(i),M.core_availability.form.update(),M.core_availability.form.rootList.renumber(),this.updateHtml(),e.dialog.destroy(),i.focusAfterAdd()}},M.core_availability.List.prototype.getValue=function(){var i,t={};for(t.op=this.node.one(".availability-neg").get("value")+this.node.one(".availability-op").get("value"),t.c=[],i=0;i'+M.util.get_string("missingplugin","availability")+"
    ")):(this.plugin=M.core_availability.form.plugins[i.type],this.pluginNode=this.plugin.getNode(i),this.pluginNode.addClass("availability_"+i.type)),this.node=c.Node.create('

    '),t&&(e=!0,i.showc!==undefined&&(e=i.showc),this.eyeIcon=new M.core_availability.EyeIcon(!0,e),this.node.appendChild(this.eyeIcon.span)),this.pluginNode.addClass("availability-plugincontrols"),this.node.appendChild(this.pluginNode),a=new M.core_availability.DeleteIcon(this),this.node.appendChild(a.span),this.node.appendChild(document.createTextNode(" ")),this.node.appendChild(c.Node.create(''))},M.core_availability.Item.prototype.getValue=function(){var i={type:this.pluginType};return this.plugin&&this.plugin.fillValue(i,this.pluginNode),i},M.core_availability.Item.prototype.fillErrors=function(i){var t,e=i.length;this.plugin?this.plugin.fillErrors(i,this.pluginNode):i.push("core_availability:item_unknowntype"),t=this.node.one("> .badge-warning"),i.length===e||t.get("firstChild")?i.length===e&&t.get("firstChild")&&t.get("firstChild").remove():t.appendChild(document.createTextNode(M.util.get_string("invalid","availability")))},M.core_availability.Item.prototype.renumber=function(i){var t,e={number:i};this.plugin?e.type=M.util.get_string("title","availability_"+this.pluginType):e.type="["+this.pluginType+"]",e.number=i+":",t=M.util.get_string("itemheading","availability",e),this.node.one("> h3").set("innerHTML",t)},M.core_availability.Item.prototype.focusAfterAdd=function(){this.plugin.focusAfterAdd(this.pluginNode)},M.core_availability.Item.prototype.pluginType=null,M.core_availability.Item.prototype.plugin=null,M.core_availability.Item.prototype.eyeIcon=null,M.core_availability.Item.prototype.node=null,M.core_availability.Item.prototype.pluginNode=null,M.core_availability.EyeIcon=function(i,t){var e,a,l,n,o;this.individual=i,this.span=c.Node.create(''),e=c.Node.create(""),this.span.appendChild(e),a=i?"_individual":"_all",l=function(){var i=M.util.get_string("hidden"+a,"availability");e.set("src",M.util.image_url("i/show","core")),e.set("alt",i),this.span.set("title",i+" • "+M.util.get_string("show_verb","availability"))},n=function(){var i=M.util.get_string("shown"+a,"availability");e.set("src",M.util.image_url("i/hide","core")),e.set("alt",i),this.span.set("title",i+" • "+M.util.get_string("hide_verb","availability"))},t?n.call(this):l.call(this),o=function(i){i.preventDefault(),this.isHidden()?n.call(this):l.call(this),M.core_availability.form.update()},this.span.on("click",o,this),this.span.on("key",o,"up:32",this),this.span.on("key",function(i){i.preventDefault()},"down:32",this)},M.core_availability.EyeIcon.prototype.individual=!1,M.core_availability.EyeIcon.prototype.span=null,M.core_availability.EyeIcon.prototype.isHidden=function(){var i=this.individual?"_individual":"_all",t=M.util.get_string("hidden"+i,"availability");return this.span.one("img").get("alt")===t},M.core_availability.DeleteIcon=function(t){var i,e;this.span=c.Node.create(''),i=c.Node.create(''+M.util.get_string('),this.span.appendChild(i),e=function(i){i.preventDefault(),M.core_availability.form.rootList.deleteDescendant(t),M.core_availability.form.rootList.renumber()},this.span.on("click",e,this),this.span.on("key",e,"up:32",this),this.span.on("key",function(i){i.preventDefault()},"down:32",this)},M.core_availability.DeleteIcon.prototype.span=null},"@VERSION@",{requires:["base","node","event","event-delegate","panel","moodle-core-notification-dialogue","json"]}); \ No newline at end of file +YUI.add("moodle-core_availability-form",function(d,i){M.core_availability=M.core_availability||{},M.core_availability.form={plugins:{},field:null,mainDiv:null,rootList:null,idCounter:0,restrictByGroup:null,init:function(i){var t,e,a,l,n;for(t in i)e=i[t],(a=M[e[0]].form).init.apply(a,e);if(this.field=d.one("#id_availabilityconditionsjson"),this.field.setAttribute("aria-hidden","true"),this.mainDiv=d.Node.create(''),this.field.insert(this.mainDiv,"after"),n=null,""!==(l=this.field.get("value")))try{n=d.JSON.parse(l)}catch(o){this.field.set("value","")}this.rootList=new M.core_availability.List(n,!0),this.mainDiv.appendChild(this.rootList.node),this.update(),this.rootList.renumber(),this.mainDiv.setAttribute("aria-live","polite"),this.field.ancestor("form").on("submit",function(){this.mainDiv.all("input,textarea,select").set("disabled",!0)},this),this.restrictByGroup=d.one("#restrictbygroup"),this.restrictByGroup&&(this.restrictByGroup.on("click",this.addRestrictByGroup,this),l=d.one("#id_groupmode"),n=d.one("#id_groupingid"),l&&l.on("change",this.updateRestrictByGroup,this),n&&n.on("change",this.updateRestrictByGroup,this),this.updateRestrictByGroup())},update:function(){var i=this.rootList.getValue(),t=[];this.rootList.fillErrors(t),0!==t.length&&(i.errors=t),this.field.set("value",d.JSON.stringify(i)),this.updateRestrictByGroup()},updateRestrictByGroup:function(){var i,t,e,a;this.restrictByGroup&&("&"!==this.rootList.getValue().op||(this.rootList.hasItemOfType("group")||this.rootList.hasItemOfType("grouping"))?this.restrictByGroup.set("disabled",!0):(i=d.one("#id_groupmode"),t=d.one("#id_groupingid"),e=1===Number(this.restrictByGroup.getData("groupavailability")),a=1===Number(this.restrictByGroup.getData("groupingavailability")),i&&0!==Number(i.get("value"))&&e||t&&0!==Number(t.get("value"))&&a?this.restrictByGroup.set("disabled",!1):this.restrictByGroup.set("disabled",!0)))},addRestrictByGroup:function(i){var t,e,a,l;i.preventDefault(),i=d.one("#id_groupmode"),t=d.one("#id_groupingid"),e=1===Number(this.restrictByGroup.getData("groupavailability")),a=1===Number(this.restrictByGroup.getData("groupingavailability")),t&&0!==Number(t.get("value"))&&a?l=new M.core_availability.Item({type:"grouping",id:Number(t.get("value"))},!0):i&&e&&(l=new M.core_availability.Item({type:"group"},!0)),null!==l&&(this.rootList.addChild(l),this.update(),this.rootList.renumber(),this.rootList.updateHtml())}},M.core_availability.plugin={allowAdd:!1,init:function(i,t,e){i=i.replace(/^availability_/,"");this.allowAdd=t,(M.core_availability.form.plugins[i]=this).initInner.apply(this,e)},initInner:function(){},getNode:function(){throw"getNode not implemented"},fillValue:function(){throw"fillValue not implemented"},fillErrors:function(){},focusAfterAdd:function(i){i.one("input:not([disabled]),select:not([disabled])").focus()}},M.core_availability.List=function(i,t,e){var a,l,n;if(this.children=[],t!==undefined&&(this.root=t),this.node=d.Node.create('

    '+M.util.get_string("listheader_sign_before","availability")+' '+M.util.get_string("listheader_single","availability")+''+M.util.get_string("listheader_multi_before","availability")+' "+M.util.get_string("listheader_multi_after","availability")+'
    '+M.util.get_string("none","moodle")+'
    '),t||this.node.addClass("availability-childlist d-sm-flex align-items-center"),this.inner=this.node.one("> .availability-inner"),a=!0,t?(i&&i.show!==undefined&&(a=i.show),this.eyeIcon=new M.core_availability.EyeIcon(!1,a),this.node.one(".availability-header").get("firstChild").insert(this.eyeIcon.span,"before")):e&&(i&&i.showc!==undefined&&(a=i.showc),this.eyeIcon=new M.core_availability.EyeIcon(!1,a),this.inner.insert(this.eyeIcon.span,"before")),t||(e=new M.core_availability.DeleteIcon(this),(a=this.node.one(".availability-none")).appendChild(document.createTextNode(" ")),a.appendChild(e.span),a.appendChild(d.Node.create(''+M.util.get_string("invalid","availability")+""))),(t=d.Node.create('")).on("click",function(){this.clickAdd()},this),this.node.one("div.availability-button").appendChild(t),i){switch(i.op){case"&":case"|":this.node.one(".availability-neg").set("value","");break;case"!&":case"!|":this.node.one(".availability-neg").set("value","!")}switch(i.op){case"&":case"!&":this.node.one(".availability-op").set("value","&");break;case"|":case"!|":this.node.one(".availability-op").set("value","|")}for(l=0;l
    ')),this.children.push(i),this.inner.one(".availability-children").appendChild(i.node)},M.core_availability.List.prototype.focusAfterAdd=function(){this.inner.one("button").focus()},M.core_availability.List.prototype.isIndividualShowIcons=function(){var i,t;if(!this.root)throw"Can only call this on root list";return i="!"===this.node.one(".availability-neg").get("value"),t="|"===this.node.one(".availability-op").get("value"),!i&&!t||i&&t},M.core_availability.List.prototype.renumber=function(i){var t,e={count:this.children.length},a=i===undefined?e.number="":(e.number=i+":",i+"."),i=M.util.get_string("setheading","availability",e);for(this.node.one("> h3").set("innerHTML",i),t=0;t .availability-children").removeAttribute("aria-hidden"),this.inner.one("> .availability-none").setAttribute("aria-hidden","true"),this.inner.one("> .availability-header").removeAttribute("aria-hidden"),1 .availability-children").setAttribute("aria-hidden","true"),this.inner.one("> .availability-none").removeAttribute("aria-hidden"),this.inner.one("> .availability-header").setAttribute("aria-hidden","true")),this.root){for(i=this.isIndividualShowIcons(),t=0;t .availability-children > .availability-connector span.label").each(function(i){i.set("innerHTML",a)})},M.core_availability.List.prototype.deleteDescendant=function(i){for(var t,e,a=0;a .availability-children").removeChild(e),M.core_availability.form.update(),this.updateHtml(),this.inner.one("> .availability-button").one("button").focus(),!0;if(t instanceof M.core_availability.List&&t.deleteDescendant(i))return!0}return!1},M.core_availability.List.prototype.clickAdd=function(){var i,t,e,a,l,n=d.Node.create('
      "),o=n.one("button"),s={dialog:null},r=n.one("ul");for(l in M.core_availability.form.plugins)M.core_availability.form.plugins[l].allowAdd&&(i=d.Node.create('
    • '),(e=d.Node.create('
      ")).on("click",this.getAddHandler(l,s),this),i.appendChild(e),a=d.Node.create('
      "),i.appendChild(a),r.appendChild(i));i=d.Node.create('
    • '),(e=d.Node.create('
      ")).on("click",this.getAddHandler(null,s),this),i.appendChild(e),a=d.Node.create('
      "),i.appendChild(a),r.appendChild(i),n={headerContent:M.util.get_string("addrestriction","availability"),bodyContent:n,additionalBaseClass:"availability-dialogue",draggable:!0,modal:!0,closeButton:!1,width:"450px"},s.dialog=new M.core.dialogue(n),s.dialog.show(),o.on("click",function(){s.dialog.destroy(),this.inner.one("> .availability-button").one("button").focus()},this)},M.core_availability.List.prototype.getAddHandler=function(t,e){return function(){var i=t?new M.core_availability.Item({type:t,creating:!0},this.root):new M.core_availability.List({c:[],showc:!0},!1,this.root);this.addChild(i),M.core_availability.form.update(),M.core_availability.form.rootList.renumber(),this.updateHtml(),e.dialog.destroy(),i.focusAfterAdd()}},M.core_availability.List.prototype.getValue=function(){var i,t={};for(t.op=this.node.one(".availability-neg").get("value")+this.node.one(".availability-op").get("value"),t.c=[],i=0;i'+M.util.get_string("missingplugin","availability")+"")):(this.plugin=M.core_availability.form.plugins[i.type],this.pluginNode=this.plugin.getNode(i),this.pluginNode.addClass("availability_"+i.type)),this.node=d.Node.create('

      '),t&&(t=!0,i.showc!==undefined&&(t=i.showc),this.eyeIcon=new M.core_availability.EyeIcon(!0,t),this.node.appendChild(this.eyeIcon.span)),this.pluginNode.addClass("availability-plugincontrols"),this.node.appendChild(this.pluginNode),i=new M.core_availability.DeleteIcon(this),this.node.appendChild(i.span),this.node.appendChild(document.createTextNode(" ")),this.node.appendChild(d.Node.create(''))},M.core_availability.Item.prototype.getValue=function(){var i={type:this.pluginType};return this.plugin&&this.plugin.fillValue(i,this.pluginNode),i},M.core_availability.Item.prototype.fillErrors=function(i){var t,e=i.length;this.plugin?this.plugin.fillErrors(i,this.pluginNode):i.push("core_availability:item_unknowntype"),t=this.node.one("> .badge-warning"),i.length===e||t.get("firstChild")?i.length===e&&t.get("firstChild")&&t.get("firstChild").remove():t.appendChild(document.createTextNode(M.util.get_string("invalid","availability")))},M.core_availability.Item.prototype.renumber=function(i){var t={number:i};this.plugin?t.type=M.util.get_string("title","availability_"+this.pluginType):t.type="["+this.pluginType+"]",t.number=i+":",i=M.util.get_string("itemheading","availability",t),this.node.one("> h3").set("innerHTML",i)},M.core_availability.Item.prototype.focusAfterAdd=function(){this.plugin.focusAfterAdd(this.pluginNode)},M.core_availability.Item.prototype.pluginType=null,M.core_availability.Item.prototype.plugin=null,M.core_availability.Item.prototype.eyeIcon=null,M.core_availability.Item.prototype.node=null,M.core_availability.Item.prototype.pluginNode=null,M.core_availability.EyeIcon=function(i,t){var e,a,l,n;this.individual=i,this.span=d.Node.create('
      '),e=d.Node.create(""),this.span.appendChild(e),a=i?"_individual":"_all",l=function(){var i=M.util.get_string("hidden"+a,"availability");e.set("src",M.util.image_url("i/show","core")),e.set("alt",i),this.span.set("title",i+" • "+M.util.get_string("show_verb","availability"))},n=function(){var i=M.util.get_string("shown"+a,"availability");e.set("src",M.util.image_url("i/hide","core")),e.set("alt",i),this.span.set("title",i+" • "+M.util.get_string("hide_verb","availability"))},(t?n:l).call(this),this.span.on("click",i=function(i){i.preventDefault(),(this.isHidden()?n:l).call(this),M.core_availability.form.update()},this),this.span.on("key",i,"up:32",this),this.span.on("key",function(i){i.preventDefault()},"down:32",this)},M.core_availability.EyeIcon.prototype.individual=!1,M.core_availability.EyeIcon.prototype.span=null,M.core_availability.EyeIcon.prototype.isHidden=function(){var i=this.individual?"_individual":"_all",i=M.util.get_string("hidden"+i,"availability");return this.span.one("img").get("alt")===i},M.core_availability.DeleteIcon=function(t){var i;this.span=d.Node.create(''),i=d.Node.create(''+M.util.get_string('),this.span.appendChild(i),this.span.on("click",i=function(i){i.preventDefault(),M.core_availability.form.rootList.deleteDescendant(t),M.core_availability.form.rootList.renumber()},this),this.span.on("key",i,"up:32",this),this.span.on("key",function(i){i.preventDefault()},"down:32",this)},M.core_availability.DeleteIcon.prototype.span=null},"@VERSION@",{requires:["base","node","event","event-delegate","panel","moodle-core-notification-dialogue","json"]}); \ No newline at end of file diff --git a/backup/util/ui/amd/build/async_backup.min.js b/backup/util/ui/amd/build/async_backup.min.js index 1511c10a96d..09a59771743 100644 --- a/backup/util/ui/amd/build/async_backup.min.js +++ b/backup/util/ui/amd/build/async_backup.min.js @@ -1,2 +1,12 @@ -define ("core_backup/async_backup",["jquery","core/ajax","core/str","core/notification","core/templates"],function(a,b,c,d,e){var q=900,r=1e3,s={},t=15e3,u=15e3,v=1.5,w,x,y,z,A,B,C,D=2e3;function f(a,b,c){var d=Math.round(c)+"%",e=document.querySelectorAll("[data-"+b+"id="+CSS.escape(a)+"]")[0],f=c.toFixed(2)+"%";e.setAttribute("aria-valuenow",d);e.style.width=d;e.innerHTML=f}function g(a,b,c){clearInterval(a);return setInterval(b,c)}function h(c){var f=a("#"+c+"_bar").parent().parent(),g=f.parent(),h=f.siblings(),i=h[1],j=a(i).text(),k=h[0],l=a(k).text();b.call([{methodname:"core_backup_get_async_backup_links_backup",args:{filename:l,contextid:x}}])[0].done(function(a){var b={filename:l,time:j,size:a.filesize,fileurl:a.fileurl,restoreurl:a.restoreurl};e.render("core/async_backup_progress_row",b).then(function(a,b){e.replaceNodeContents(g,a,b)}).fail(function(){d.exception(new Error("Failed to load table row"))})})}function i(c){var f=a("#"+c+"_bar").parent().parent(),g=f.parent(),h=f.siblings(),i=h[0],j=h[1],k=a(j).text();b.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:c,contextid:x}}])[0].done(function(b){var c=a(i).text(),f={resourcename:c,restoreurl:b.restoreurl,time:k};e.render("core/async_restore_progress_row",f).then(function(a,b){e.replaceNodeContents(g,a,b)}).fail(function(){d.exception(new Error("Failed to load table row"))})})}function j(a){var f=document.querySelectorAll("[data-restoreid="+CSS.escape(a)+"]")[0],g=f.closest("tr").children[1],h=g.innerHTML,i=document.createElement("a"),j=f.closest("td"),k=j.previousElementSibling;c.get_string("complete").then(function(a){k.innerHTML=a}).catch(function(){d.exception(new Error("Failed to load string: complete"))});e.render("core/async_copy_complete_cell",{}).then(function(a,b){e.replaceNodeContents(j,a,b)}).fail(function(){d.exception(new Error("Failed to load table cell"))});b.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:a,contextid:0}}])[0].done(function(a){i.setAttribute("href",a.restoreurl);i.innerHTML=h;g.innerHTML=null;g.appendChild(i)}).fail(function(){d.exception(new Error("Failed to update table row"))})}function k(e){var g=100*e.progress,h="backup",i=document.querySelectorAll("[data-"+h+"id="+CSS.escape(w)+"]")[0],j=a("#"+w+"_status"),k=a("#"+w+"_detail"),l=a("#"+w+"_button"),m;if(e.status==800){i.classList.add("bg-success");f(w,h,g);var n="async"+z+"processing";c.get_string(n,"backup").then(function(a){j.text(a)}).catch(function(){d.exception(new Error("Failed to load string: backup "+n))})}else if(e.status==q){i.classList.add("bg-danger");i.classList.remove("bg-success");f(w,h,100);var o="async"+z+"error",p="async"+z+"errordetail";m=[{key:o,component:"backup"},{key:p,component:"backup"}];c.get_strings(m).then(function(a){j.text(a[0]);k.text(a[1])}).catch(function(){d.exception(new Error("Failed to load string"))});a(".backup_progress").children("span").removeClass("backup_stage_current");a(".backup_progress").children("span").last().addClass("backup_stage_current");clearInterval(A)}else if(e.status==r){i.classList.add("bg-success");f(w,h,100);var s="async"+z+"complete";c.get_string(s,"backup").then(function(a){j.text(a)}).catch(function(){d.exception(new Error("Failed to load string: backup "+s))});if("restore"==z){b.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:w,contextid:x}}])[0].done(function(a){var b="async"+z+"completedetail",e="async"+z+"completebutton",f=[{key:b,component:"backup",param:a.restoreurl},{key:e,component:"backup"}];c.get_strings(f).then(function(b){k.html(b[0]);l.text(b[1]);l.attr("href",a.restoreurl)}).catch(function(){d.exception(new Error("Failed to load string"))})})}else{var t="async"+z+"completedetail",u="async"+z+"completebutton";m=[{key:t,component:"backup",param:y},{key:u,component:"backup"}];c.get_strings(m).then(function(a){k.html(a[0]);l.text(a[1]);l.attr("href",y)}).catch(function(){d.exception(new Error("Failed to load string"))})}a(".backup_progress").children("span").removeClass("backup_stage_current");a(".backup_progress").children("span").last().addClass("backup_stage_current");clearInterval(A)}}function l(a){a.forEach(function(a){var b=100*a.progress,c=a.backupid,d=a.operation,e=document.querySelectorAll("[data-"+d+"id="+CSS.escape(c)+"]")[0];if(a.status==800){e.classList.add("bg-success");f(c,d,b)}else if(a.status==q){e.classList.add("bg-danger");e.classList.add("complete");e.classList.remove("bg-success");f(c,d,100)}else if(a.status==r){e.classList.add("bg-success");e.classList.add("complete");f(c,d,100);if("backup"==d){h(c)}else{i(c)}}})}function m(a){a.forEach(function(a){var b=100*a.progress,e=a.backupid,g=a.operation,h=document.querySelectorAll("[data-"+g+"id="+CSS.escape(e)+"]")[0];if("restore"==g){var i=h.closest("tr").children[3];c.get_string("restore").then(function(a){i.innerHTML=a}).catch(function(){d.exception(new Error("Failed to load string: restore"))})}if(a.status==800){h.classList.add("bg-success");f(e,g,b)}else if(a.status==q){h.classList.add("bg-danger");h.classList.add("complete");h.classList.remove("bg-success");f(e,g,100)}else if(a.status==r&&"restore"==g){h.classList.add("bg-success");h.classList.add("complete");f(e,g,100);j(e)}})}function n(){b.call([{methodname:"core_backup_get_async_backup_progress",args:{backupids:[w],contextid:x}}],!0,!0,!1,D)[0].done(function(a){k(a[0]);u=t;A=g(A,n,t)}).fail(function(){u=u*v;A=g(A,n,u)})}function o(){var c=[],d=a(".progress").find(".progress-bar").not(".complete");d.each(function(){c.push(this.id.substring(0,32))});if(0 + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @since 3.7 + */ +define("core_backup/async_backup",["jquery","core/ajax","core/str","core/notification","core/templates"],(function($,ajax,Str,notification,Templates){var backupid,contextid,restoreurl,typeid,backupintervalid,allbackupintervalid,allcopyintervalid,Asyncbackup={},checkdelay=15e3;function updateElement(backupid,type,percentage){var percentagewidth=Math.round(percentage)+"%",elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0],percentagetext=percentage.toFixed(2)+"%";elementbar.setAttribute("aria-valuenow",percentagewidth),elementbar.style.width=percentagewidth,elementbar.innerHTML=percentagetext}function updateInterval(intervalid,callback,value){return clearInterval(intervalid),setInterval(callback,value)}function updateProgressAll(progress){progress.forEach((function(element){var percentage=100*element.progress,backupid=element.backupid,type=element.operation,elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0];800==element.status?(elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage)):900==element.status?(elementbar.classList.add("bg-danger"),elementbar.classList.add("complete"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100)):1e3==element.status&&(elementbar.classList.add("bg-success"),elementbar.classList.add("complete"),updateElement(backupid,type,100),"backup"==type?function(backupid){var statuscell=$("#"+backupid+"_bar").parent().parent(),tablerow=statuscell.parent(),cellsiblings=statuscell.siblings(),timecell=cellsiblings[1],timevalue=$(timecell).text(),filenamecell=cellsiblings[0],filename=$(filenamecell).text();ajax.call([{methodname:"core_backup_get_async_backup_links_backup",args:{filename:filename,contextid:contextid}}])[0].done((function(response){var context={filename:filename,time:timevalue,size:response.filesize,fileurl:response.fileurl,restoreurl:response.restoreurl};Templates.render("core/async_backup_progress_row",context).then((function(html,js){Templates.replaceNodeContents(tablerow,html,js)})).fail((function(){notification.exception(new Error("Failed to load table row"))}))}))}(backupid):function(backupid){var statuscell=$("#"+backupid+"_bar").parent().parent(),tablerow=statuscell.parent(),cellsiblings=statuscell.siblings(),coursecell=cellsiblings[0],timecell=cellsiblings[1],timevalue=$(timecell).text();ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:contextid}}])[0].done((function(response){var context={resourcename:$(coursecell).text(),restoreurl:response.restoreurl,time:timevalue};Templates.render("core/async_restore_progress_row",context).then((function(html,js){Templates.replaceNodeContents(tablerow,html,js)})).fail((function(){notification.exception(new Error("Failed to load table row"))}))}))}(backupid))}))}function updateProgressCopy(progress){progress.forEach((function(element){var percentage=100*element.progress,backupid=element.backupid,type=element.operation,elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0];if("restore"==type){let restorecell=elementbar.closest("tr").children[3];Str.get_string("restore").then((function(content){restorecell.innerHTML=content})).catch((function(){notification.exception(new Error("Failed to load string: restore"))}))}800==element.status?(elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage)):900==element.status?(elementbar.classList.add("bg-danger"),elementbar.classList.add("complete"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100)):1e3==element.status&&"restore"==type&&(elementbar.classList.add("bg-success"),elementbar.classList.add("complete"),updateElement(backupid,type,100),function(backupid){var elementbar=document.querySelectorAll("[data-restoreid="+CSS.escape(backupid)+"]")[0],restorecourse=elementbar.closest("tr").children[1],coursename=restorecourse.innerHTML,courselink=document.createElement("a"),elementbarparent=elementbar.closest("td"),operation=elementbarparent.previousElementSibling;Str.get_string("complete").then((function(content){operation.innerHTML=content})).catch((function(){notification.exception(new Error("Failed to load string: complete"))})),Templates.render("core/async_copy_complete_cell",{}).then((function(html,js){Templates.replaceNodeContents(elementbarparent,html,js)})).fail((function(){notification.exception(new Error("Failed to load table cell"))})),ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:0}}])[0].done((function(response){courselink.setAttribute("href",response.restoreurl),courselink.innerHTML=coursename,restorecourse.innerHTML=null,restorecourse.appendChild(courselink)})).fail((function(){notification.exception(new Error("Failed to update table row"))}))}(backupid))}))}function getBackupProgress(){ajax.call([{methodname:"core_backup_get_async_backup_progress",args:{backupids:[backupid],contextid:contextid}}],!0,!0,!1,2e3)[0].done((function(response){!function(progress){var stringRequests,percentage=100*progress.progress,type="backup",elementbar=document.querySelectorAll("[data-backupid="+CSS.escape(backupid)+"]")[0],elementstatus=$("#"+backupid+"_status"),elementdetail=$("#"+backupid+"_detail"),elementbutton=$("#"+backupid+"_button");if(800==progress.status){elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage);var strProcessing="async"+typeid+"processing";Str.get_string(strProcessing,"backup").then((function(title){elementstatus.text(title)})).catch((function(){notification.exception(new Error("Failed to load string: backup "+strProcessing))}))}else if(900==progress.status)elementbar.classList.add("bg-danger"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100),stringRequests=[{key:"async"+typeid+"error",component:"backup"},{key:"async"+typeid+"errordetail",component:"backup"}],Str.get_strings(stringRequests).then((function(strings){elementstatus.text(strings[0]),elementdetail.text(strings[1])})).catch((function(){notification.exception(new Error("Failed to load string"))})),$(".backup_progress").children("span").removeClass("backup_stage_current"),$(".backup_progress").children("span").last().addClass("backup_stage_current"),clearInterval(backupintervalid);else if(1e3==progress.status){elementbar.classList.add("bg-success"),updateElement(backupid,type,100);var strComplete="async"+typeid+"complete";Str.get_string(strComplete,"backup").then((function(title){elementstatus.text(title)})).catch((function(){notification.exception(new Error("Failed to load string: backup "+strComplete))})),"restore"==typeid?ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:contextid}}])[0].done((function(response){var strButton="async"+typeid+"completebutton",stringRequests=[{key:"async"+typeid+"completedetail",component:"backup",param:response.restoreurl},{key:strButton,component:"backup"}];Str.get_strings(stringRequests).then((function(strings){elementdetail.html(strings[0]),elementbutton.text(strings[1]),elementbutton.attr("href",response.restoreurl)})).catch((function(){notification.exception(new Error("Failed to load string"))}))})):(stringRequests=[{key:"async"+typeid+"completedetail",component:"backup",param:restoreurl},{key:"async"+typeid+"completebutton",component:"backup"}],Str.get_strings(stringRequests).then((function(strings){elementdetail.html(strings[0]),elementbutton.text(strings[1]),elementbutton.attr("href",restoreurl)})).catch((function(){notification.exception(new Error("Failed to load string"))}))),$(".backup_progress").children("span").removeClass("backup_stage_current"),$(".backup_progress").children("span").last().addClass("backup_stage_current"),clearInterval(backupintervalid)}}(response[0]),checkdelay=15e3,backupintervalid=updateInterval(backupintervalid,getBackupProgress,15e3)})).fail((function(){backupintervalid=updateInterval(backupintervalid,getBackupProgress,checkdelay*=1.5)}))}function getAllBackupProgress(){var backupids=[];$(".progress").find(".progress-bar").not(".complete").each((function(){backupids.push(this.id.substring(0,32))})),backupids.length>0?ajax.call([{methodname:"core_backup_get_async_backup_progress",args:{backupids:backupids,contextid:contextid}}],!0,!0,!1,2e3)[0].done((function(response){updateProgressAll(response),checkdelay=15e3,allbackupintervalid=updateInterval(allbackupintervalid,getAllBackupProgress,15e3)})).fail((function(){allbackupintervalid=updateInterval(allbackupintervalid,getAllBackupProgress,checkdelay*=1.5)})):clearInterval(allbackupintervalid)}function getAllCopyProgress(){var copyids=[];$(".progress").find(".progress-bar[data-operation][data-backupid][data-restoreid]").not(".complete").each((function(){let progressvars={backupid:this.dataset.backupid,restoreid:this.dataset.restoreid,operation:this.dataset.operation};copyids.push(progressvars)})),copyids.length>0?ajax.call([{methodname:"core_backup_get_copy_progress",args:{copies:copyids}}],!0,!0,!1,2e3)[0].done((function(response){updateProgressCopy(response),checkdelay=15e3,allcopyintervalid=updateInterval(allcopyintervalid,getAllCopyProgress,15e3)})).fail((function(){allcopyintervalid=updateInterval(allcopyintervalid,getAllCopyProgress,checkdelay*=1.5)})):clearInterval(allcopyintervalid)}return Asyncbackup.asyncBackupAllStatus=function(context){contextid=context,allbackupintervalid=setInterval(getAllBackupProgress,checkdelay)},Asyncbackup.asyncCopyAllStatus=function(){allcopyintervalid=setInterval(getAllCopyProgress,checkdelay)},Asyncbackup.asyncBackupStatus=function(backup,context,restore,type){backupid=backup,contextid=context,restoreurl=restore,typeid="backup"==type?"backup":"restore",$(".backup_progress").children("a").removeAttr("href"),backupintervalid=setInterval(getBackupProgress,checkdelay)},Asyncbackup})); + +//# sourceMappingURL=async_backup.min.js.map \ No newline at end of file diff --git a/backup/util/ui/amd/build/async_backup.min.js.map b/backup/util/ui/amd/build/async_backup.min.js.map index 2e04c575e7e..72f084eec81 100644 --- a/backup/util/ui/amd/build/async_backup.min.js.map +++ b/backup/util/ui/amd/build/async_backup.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/async_backup.js"],"names":["define","$","ajax","Str","notification","Templates","STATUS_FINISHED_ERR","STATUS_FINISHED_OK","Asyncbackup","checkdelayoriginal","checkdelay","checkdelaymultipler","backupid","contextid","restoreurl","typeid","backupintervalid","allbackupintervalid","allcopyintervalid","timeout","updateElement","type","percentage","percentagewidth","Math","round","elementbar","document","querySelectorAll","CSS","escape","percentagetext","toFixed","setAttribute","style","width","innerHTML","updateInterval","intervalid","callback","value","clearInterval","setInterval","updateBackupTableRow","statuscell","parent","tablerow","cellsiblings","siblings","timecell","timevalue","text","filenamecell","filename","call","methodname","args","done","response","context","time","size","filesize","fileurl","render","then","html","js","replaceNodeContents","fail","exception","Error","updateRestoreTableRow","coursecell","resourcename","updateCopyTableRow","restorecourse","closest","children","coursename","courselink","createElement","elementbarparent","operation","previousElementSibling","get_string","content","catch","appendChild","updateProgress","progress","elementstatus","elementdetail","elementbutton","stringRequests","status","classList","add","strProcessing","title","remove","strStatus","strStatusDetail","key","component","get_strings","strings","removeClass","last","addClass","strComplete","strDetail","strButton","param","attr","updateProgressAll","forEach","element","updateProgressCopy","restorecell","getBackupProgress","getAllBackupProgress","backupids","progressbars","find","not","each","push","id","substring","length","getAllCopyProgress","copyids","progressvars","dataset","restoreid","asyncBackupAllStatus","asyncCopyAllStatus","asyncBackupStatus","backup","restore","removeAttr"],"mappings":"AAwBAA,OAAM,4BAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,UAAxB,CAAoC,mBAApC,CAAyD,gBAAzD,CAAD,CACE,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAuBC,CAAvB,CAAqCC,CAArC,CAAgD,IAQhDC,CAAAA,CAAmB,CAAG,GAR0B,CAShDC,CAAkB,CAAG,GAT2B,CAchDC,CAAW,CAAG,EAdkC,CAehDC,CAAkB,CAAG,IAf2B,CAgBhDC,CAAU,CAAG,IAhBmC,CAiBhDC,CAAmB,CAAG,GAjB0B,CAkBhDC,CAlBgD,CAmBhDC,CAnBgD,CAoBhDC,CApBgD,CAqBhDC,CArBgD,CA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CAAD,CAChB,CACJ,CAQDV,CAAW,CAACgI,oBAAZ,CAAmC,SAAS7E,CAAT,CAAkB,CACjD9C,CAAS,CAAG8C,CAAZ,CACA1C,CAAmB,CAAGyB,WAAW,CAAC+E,CAAD,CAAuB/G,CAAvB,CACpC,CAHD,CAUAF,CAAW,CAACiI,kBAAZ,CAAiC,UAAW,CACxCvH,CAAiB,CAAGwB,WAAW,CAACyF,CAAD,CAAqBzH,CAArB,CAClC,CAFD,CAaAF,CAAW,CAACkI,iBAAZ,CAAgC,SAASC,CAAT,CAAiBhF,CAAjB,CAA0BiF,CAA1B,CAAmCvH,CAAnC,CAAyC,CACrET,CAAQ,CAAG+H,CAAX,CACA9H,CAAS,CAAG8C,CAAZ,CACA7C,CAAU,CAAG8H,CAAb,CAEA,GAAY,QAAR,EAAAvH,CAAJ,CAAsB,CAClBN,CAAM,CAAG,QACZ,CAFD,IAEO,CACHA,CAAM,CAAG,SACZ,CAGDd,CAAC,CAAC,kBAAD,CAAD,CAAsB6E,QAAtB,CAA+B,GAA/B,EAAoC+D,UAApC,CAA+C,MAA/C,EAGA7H,CAAgB,CAAG0B,WAAW,CAAC8E,CAAD,CAAoB9G,CAApB,CAE/B,CAjBH,CAmBE,MAAOF,CAAAA,CACZ,CArkBK,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 * This module updates the UI during an asynchronous\n * backup or restore process.\n *\n * @module core_backup/async_backup\n * @copyright 2018 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.7\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification', 'core/templates'],\n function($, ajax, Str, notification, Templates) {\n\n /**\n * Module level constants.\n *\n * Using var instead of const as ES6 isn't fully supported yet.\n */\n var STATUS_EXECUTING = 800;\n var STATUS_FINISHED_ERR = 900;\n var STATUS_FINISHED_OK = 1000;\n\n /**\n * Module level variables.\n */\n var Asyncbackup = {};\n var checkdelayoriginal = 15000; // This is the default time to use.\n var checkdelay = 15000; // How often we should check for progress updates.\n var checkdelaymultipler = 1.5; // If a request fails this multiplier will be used to increase the checkdelay value\n var backupid; // The backup id to get the progress for.\n var contextid; // The course this backup progress is for.\n var restoreurl; // The URL to view course restores.\n var typeid; // The type of operation backup or restore.\n var backupintervalid; // The id of the setInterval function.\n var allbackupintervalid; // The id of the setInterval function.\n var allcopyintervalid; // The id of the setInterval function.\n var timeout = 2000; // Timeout for ajax requests.\n\n /**\n * Helper function to update UI components.\n *\n * @param {string} backupid The id to match elements on.\n * @param {string} type The type of operation, backup or restore.\n * @param {number} percentage The completion percentage to apply.\n */\n function updateElement(backupid, type, percentage) {\n var percentagewidth = Math.round(percentage) + '%';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var percentagetext = percentage.toFixed(2) + '%';\n\n // Set progress bar percentage indicators\n elementbar.setAttribute('aria-valuenow', percentagewidth);\n elementbar.style.width = percentagewidth;\n elementbar.innerHTML = percentagetext;\n }\n\n /**\n * Updates the interval we use to check for backup progress.\n *\n * @param {Number} intervalid The id of the interval\n * @param {Function} callback The function to use in setInterval\n * @param {Number} value The specified interval (in milliseconds)\n * @returns {Number}\n */\n function updateInterval(intervalid, callback, value) {\n clearInterval(intervalid);\n return setInterval(callback, value);\n }\n\n /**\n * Update backup table row when an async backup completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateBackupTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n var filenamecell = cellsiblings[0];\n var filename = $(filenamecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_backup',\n args: {\n 'filename': filename,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var context = {\n filename: filename,\n time: timevalue,\n size: response.filesize,\n fileurl: response.fileurl,\n restoreurl: response.restoreurl\n };\n\n Templates.render('core/async_backup_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update restore table row when an async restore completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateRestoreTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var coursecell = cellsiblings[0];\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var resourcename = $(coursecell).text();\n var context = {\n resourcename: resourcename,\n restoreurl: response.restoreurl,\n time: timevalue\n };\n\n Templates.render('core/async_restore_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update copy table row when an course copy completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateCopyTableRow(backupid) {\n var elementbar = document.querySelectorAll(\"[data-restoreid=\" + CSS.escape(backupid) + \"]\")[0];\n var restorecourse = elementbar.closest('tr').children[1];\n var coursename = restorecourse.innerHTML;\n var courselink = document.createElement('a');\n var elementbarparent = elementbar.closest('td');\n var operation = elementbarparent.previousElementSibling;\n\n // Replace the prgress bar.\n Str.get_string('complete').then(function(content) {\n operation.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: complete'));\n return;\n });\n\n Templates.render('core/async_copy_complete_cell', {}).then(function(html, js) {\n Templates.replaceNodeContents(elementbarparent, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table cell'));\n return;\n });\n\n // Update the destination course name to a link to that course.\n ajax.call([{\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': 0\n },\n }])[0].done(function(response) {\n courselink.setAttribute('href', response.restoreurl);\n courselink.innerHTML = coursename;\n restorecourse.innerHTML = null;\n restorecourse.appendChild(courselink);\n\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to update table row'));\n return;\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * the backup process.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgress(progress) {\n var percentage = progress.progress * 100;\n var type = 'backup';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var elementstatus = $('#' + backupid + '_status');\n var elementdetail = $('#' + backupid + '_detail');\n var elementbutton = $('#' + backupid + '_button');\n var stringRequests;\n\n if (progress.status == STATUS_EXECUTING) {\n // Process is in progress.\n // Add in progress class color to bar.\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n // Change heading.\n var strProcessing = 'async' + typeid + 'processing';\n Str.get_string(strProcessing, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strProcessing));\n });\n\n } else if (progress.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar.\n elementbar.classList.add('bg-danger');\n\n // Remove in progress class color to bar.\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text.\n var strStatus = 'async' + typeid + 'error';\n var strStatusDetail = 'async' + typeid + 'errordetail';\n stringRequests = [\n {key: strStatus, component: 'backup'},\n {key: strStatusDetail, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementstatus.text(strings[0]);\n elementdetail.text(strings[1]);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n\n } else if (progress.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in progress class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text\n var strComplete = 'async' + typeid + 'complete';\n Str.get_string(strComplete, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strComplete));\n });\n\n if (typeid == 'restore') {\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n var stringRequests = [\n {key: strDetail, component: 'backup', param: response.restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', response.restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n });\n } else {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n stringRequests = [\n {key: strDetail, component: 'backup', param: restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n }\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n }\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for backup and restore operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressAll(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if (element.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful backup. Update the UI with download and file details.\n if (type == 'backup') {\n updateBackupTableRow(backupid);\n } else {\n updateRestoreTableRow(backupid);\n }\n\n }\n\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for copy operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressCopy(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (type == 'restore') {\n let restorecell = elementbar.closest('tr').children[3];\n Str.get_string('restore').then(function(content) {\n restorecell.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: restore'));\n });\n }\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if ((element.status == STATUS_FINISHED_OK) && (type == 'restore')) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful copy. Update the UI link to copied course.\n updateCopyTableRow(backupid);\n }\n\n });\n }\n\n /**\n * Get the progress of the backup process via ajax.\n */\n function getBackupProgress() {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': [backupid],\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n // We have the progress now update the UI.\n updateProgress(response[0]);\n checkdelay = checkdelayoriginal;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelay);\n });\n }\n\n /**\n * Get the progress of all backup processes via ajax.\n */\n function getAllBackupProgress() {\n var backupids = [];\n var progressbars = $('.progress').find('.progress-bar').not('.complete');\n\n progressbars.each(function() {\n backupids.push((this.id).substring(0, 32));\n });\n\n if (backupids.length > 0) {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': backupids,\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressAll(response);\n checkdelay = checkdelayoriginal;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelay);\n });\n } else {\n clearInterval(allbackupintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get the progress of all copy processes via ajax.\n */\n function getAllCopyProgress() {\n var copyids = [];\n var progressbars = $('.progress').find('.progress-bar[data-operation][data-backupid][data-restoreid]').not('.complete');\n\n progressbars.each(function() {\n let progressvars = {\n 'backupid': this.dataset.backupid,\n 'restoreid': this.dataset.restoreid,\n 'operation': this.dataset.operation,\n };\n copyids.push(progressvars);\n });\n\n if (copyids.length > 0) {\n ajax.call([{\n // Get the copy progress via webservice.\n methodname: 'core_backup_get_copy_progress',\n args: {\n 'copies': copyids\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressCopy(response);\n checkdelay = checkdelayoriginal;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelay);\n });\n } else {\n clearInterval(allcopyintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get status updates for all backups.\n *\n * @public\n * @param {number} context The context id.\n */\n Asyncbackup.asyncBackupAllStatus = function(context) {\n contextid = context;\n allbackupintervalid = setInterval(getAllBackupProgress, checkdelay);\n };\n\n /**\n * Get status updates for all course copies.\n *\n * @public\n */\n Asyncbackup.asyncCopyAllStatus = function() {\n allcopyintervalid = setInterval(getAllCopyProgress, checkdelay);\n };\n\n /**\n * Get status updates for backup.\n *\n * @public\n * @param {string} backup The backup record id.\n * @param {number} context The context id.\n * @param {string} restore The restore link.\n * @param {string} type The operation type (backup or restore).\n */\n Asyncbackup.asyncBackupStatus = function(backup, context, restore, type) {\n backupid = backup;\n contextid = context;\n restoreurl = restore;\n\n if (type == 'backup') {\n typeid = 'backup';\n } else {\n typeid = 'restore';\n }\n\n // Remove the links from the progress bar, no going back now.\n $('.backup_progress').children('a').removeAttr('href');\n\n // Periodically check for progress updates and update the UI as required.\n backupintervalid = setInterval(getBackupProgress, checkdelay);\n\n };\n\n return Asyncbackup;\n});\n"],"file":"async_backup.min.js"} \ No newline at end of file +{"version":3,"file":"async_backup.min.js","sources":["../src/async_backup.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 * This module updates the UI during an asynchronous\n * backup or restore process.\n *\n * @module core_backup/async_backup\n * @copyright 2018 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.7\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification', 'core/templates'],\n function($, ajax, Str, notification, Templates) {\n\n /**\n * Module level constants.\n *\n * Using var instead of const as ES6 isn't fully supported yet.\n */\n var STATUS_EXECUTING = 800;\n var STATUS_FINISHED_ERR = 900;\n var STATUS_FINISHED_OK = 1000;\n\n /**\n * Module level variables.\n */\n var Asyncbackup = {};\n var checkdelayoriginal = 15000; // This is the default time to use.\n var checkdelay = 15000; // How often we should check for progress updates.\n var checkdelaymultipler = 1.5; // If a request fails this multiplier will be used to increase the checkdelay value\n var backupid; // The backup id to get the progress for.\n var contextid; // The course this backup progress is for.\n var restoreurl; // The URL to view course restores.\n var typeid; // The type of operation backup or restore.\n var backupintervalid; // The id of the setInterval function.\n var allbackupintervalid; // The id of the setInterval function.\n var allcopyintervalid; // The id of the setInterval function.\n var timeout = 2000; // Timeout for ajax requests.\n\n /**\n * Helper function to update UI components.\n *\n * @param {string} backupid The id to match elements on.\n * @param {string} type The type of operation, backup or restore.\n * @param {number} percentage The completion percentage to apply.\n */\n function updateElement(backupid, type, percentage) {\n var percentagewidth = Math.round(percentage) + '%';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var percentagetext = percentage.toFixed(2) + '%';\n\n // Set progress bar percentage indicators\n elementbar.setAttribute('aria-valuenow', percentagewidth);\n elementbar.style.width = percentagewidth;\n elementbar.innerHTML = percentagetext;\n }\n\n /**\n * Updates the interval we use to check for backup progress.\n *\n * @param {Number} intervalid The id of the interval\n * @param {Function} callback The function to use in setInterval\n * @param {Number} value The specified interval (in milliseconds)\n * @returns {Number}\n */\n function updateInterval(intervalid, callback, value) {\n clearInterval(intervalid);\n return setInterval(callback, value);\n }\n\n /**\n * Update backup table row when an async backup completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateBackupTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n var filenamecell = cellsiblings[0];\n var filename = $(filenamecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_backup',\n args: {\n 'filename': filename,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var context = {\n filename: filename,\n time: timevalue,\n size: response.filesize,\n fileurl: response.fileurl,\n restoreurl: response.restoreurl\n };\n\n Templates.render('core/async_backup_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update restore table row when an async restore completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateRestoreTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var coursecell = cellsiblings[0];\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var resourcename = $(coursecell).text();\n var context = {\n resourcename: resourcename,\n restoreurl: response.restoreurl,\n time: timevalue\n };\n\n Templates.render('core/async_restore_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update copy table row when an course copy completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateCopyTableRow(backupid) {\n var elementbar = document.querySelectorAll(\"[data-restoreid=\" + CSS.escape(backupid) + \"]\")[0];\n var restorecourse = elementbar.closest('tr').children[1];\n var coursename = restorecourse.innerHTML;\n var courselink = document.createElement('a');\n var elementbarparent = elementbar.closest('td');\n var operation = elementbarparent.previousElementSibling;\n\n // Replace the prgress bar.\n Str.get_string('complete').then(function(content) {\n operation.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: complete'));\n return;\n });\n\n Templates.render('core/async_copy_complete_cell', {}).then(function(html, js) {\n Templates.replaceNodeContents(elementbarparent, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table cell'));\n return;\n });\n\n // Update the destination course name to a link to that course.\n ajax.call([{\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': 0\n },\n }])[0].done(function(response) {\n courselink.setAttribute('href', response.restoreurl);\n courselink.innerHTML = coursename;\n restorecourse.innerHTML = null;\n restorecourse.appendChild(courselink);\n\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to update table row'));\n return;\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * the backup process.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgress(progress) {\n var percentage = progress.progress * 100;\n var type = 'backup';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var elementstatus = $('#' + backupid + '_status');\n var elementdetail = $('#' + backupid + '_detail');\n var elementbutton = $('#' + backupid + '_button');\n var stringRequests;\n\n if (progress.status == STATUS_EXECUTING) {\n // Process is in progress.\n // Add in progress class color to bar.\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n // Change heading.\n var strProcessing = 'async' + typeid + 'processing';\n Str.get_string(strProcessing, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strProcessing));\n });\n\n } else if (progress.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar.\n elementbar.classList.add('bg-danger');\n\n // Remove in progress class color to bar.\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text.\n var strStatus = 'async' + typeid + 'error';\n var strStatusDetail = 'async' + typeid + 'errordetail';\n stringRequests = [\n {key: strStatus, component: 'backup'},\n {key: strStatusDetail, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementstatus.text(strings[0]);\n elementdetail.text(strings[1]);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n\n } else if (progress.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in progress class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text\n var strComplete = 'async' + typeid + 'complete';\n Str.get_string(strComplete, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strComplete));\n });\n\n if (typeid == 'restore') {\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n var stringRequests = [\n {key: strDetail, component: 'backup', param: response.restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', response.restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n });\n } else {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n stringRequests = [\n {key: strDetail, component: 'backup', param: restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n }\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n }\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for backup and restore operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressAll(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if (element.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful backup. Update the UI with download and file details.\n if (type == 'backup') {\n updateBackupTableRow(backupid);\n } else {\n updateRestoreTableRow(backupid);\n }\n\n }\n\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for copy operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressCopy(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (type == 'restore') {\n let restorecell = elementbar.closest('tr').children[3];\n Str.get_string('restore').then(function(content) {\n restorecell.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: restore'));\n });\n }\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if ((element.status == STATUS_FINISHED_OK) && (type == 'restore')) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful copy. Update the UI link to copied course.\n updateCopyTableRow(backupid);\n }\n\n });\n }\n\n /**\n * Get the progress of the backup process via ajax.\n */\n function getBackupProgress() {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': [backupid],\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n // We have the progress now update the UI.\n updateProgress(response[0]);\n checkdelay = checkdelayoriginal;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelay);\n });\n }\n\n /**\n * Get the progress of all backup processes via ajax.\n */\n function getAllBackupProgress() {\n var backupids = [];\n var progressbars = $('.progress').find('.progress-bar').not('.complete');\n\n progressbars.each(function() {\n backupids.push((this.id).substring(0, 32));\n });\n\n if (backupids.length > 0) {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': backupids,\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressAll(response);\n checkdelay = checkdelayoriginal;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelay);\n });\n } else {\n clearInterval(allbackupintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get the progress of all copy processes via ajax.\n */\n function getAllCopyProgress() {\n var copyids = [];\n var progressbars = $('.progress').find('.progress-bar[data-operation][data-backupid][data-restoreid]').not('.complete');\n\n progressbars.each(function() {\n let progressvars = {\n 'backupid': this.dataset.backupid,\n 'restoreid': this.dataset.restoreid,\n 'operation': this.dataset.operation,\n };\n copyids.push(progressvars);\n });\n\n if (copyids.length > 0) {\n ajax.call([{\n // Get the copy progress via webservice.\n methodname: 'core_backup_get_copy_progress',\n args: {\n 'copies': copyids\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressCopy(response);\n checkdelay = checkdelayoriginal;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelay);\n });\n } else {\n clearInterval(allcopyintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get status updates for all backups.\n *\n * @public\n * @param {number} context The context id.\n */\n Asyncbackup.asyncBackupAllStatus = function(context) {\n contextid = context;\n allbackupintervalid = setInterval(getAllBackupProgress, checkdelay);\n };\n\n /**\n * Get status updates for all course copies.\n *\n * @public\n */\n Asyncbackup.asyncCopyAllStatus = function() {\n allcopyintervalid = setInterval(getAllCopyProgress, checkdelay);\n };\n\n /**\n * Get status updates for backup.\n *\n * @public\n * @param {string} backup The backup record id.\n * @param {number} context The context id.\n * @param {string} restore The restore link.\n * @param {string} type The operation type (backup or restore).\n */\n Asyncbackup.asyncBackupStatus = function(backup, context, restore, type) {\n backupid = backup;\n contextid = context;\n restoreurl = restore;\n\n if (type == 'backup') {\n typeid = 'backup';\n } else {\n typeid = 'restore';\n }\n\n // Remove the links from the progress bar, no going back now.\n $('.backup_progress').children('a').removeAttr('href');\n\n // Periodically check for progress updates and update the UI as required.\n backupintervalid = setInterval(getBackupProgress, checkdelay);\n\n };\n\n return Asyncbackup;\n});\n"],"names":["define","$","ajax","Str","notification","Templates","backupid","contextid","restoreurl","typeid","backupintervalid","allbackupintervalid","allcopyintervalid","Asyncbackup","checkdelay","updateElement","type","percentage","percentagewidth","Math","round","elementbar","document","querySelectorAll","CSS","escape","percentagetext","toFixed","setAttribute","style","width","innerHTML","updateInterval","intervalid","callback","value","clearInterval","setInterval","updateProgressAll","progress","forEach","element","operation","status","classList","add","remove","statuscell","parent","tablerow","cellsiblings","siblings","timecell","timevalue","text","filenamecell","filename","call","methodname","args","done","response","context","time","size","filesize","fileurl","render","then","html","js","replaceNodeContents","fail","exception","Error","updateBackupTableRow","coursecell","resourcename","updateRestoreTableRow","updateProgressCopy","restorecell","closest","children","get_string","content","catch","restorecourse","coursename","courselink","createElement","elementbarparent","previousElementSibling","appendChild","updateCopyTableRow","getBackupProgress","stringRequests","elementstatus","elementdetail","elementbutton","strProcessing","title","key","component","get_strings","strings","removeClass","last","addClass","strComplete","strButton","param","attr","updateProgress","getAllBackupProgress","backupids","find","not","each","push","this","id","substring","length","getAllCopyProgress","copyids","progressvars","dataset","restoreid","asyncBackupAllStatus","asyncCopyAllStatus","asyncBackupStatus","backup","restore","removeAttr"],"mappings":";;;;;;;;;AAwBAA,kCAAO,CAAC,SAAU,YAAa,WAAY,oBAAqB,mBACxD,SAASC,EAAGC,KAAMC,IAAKC,aAAcC,eAkBrCC,SACAC,UACAC,WACAC,OACAC,iBACAC,oBACAC,kBAVAC,YAAc,GAEdC,WAAa,cAkBRC,cAAcT,SAAUU,KAAMC,gBAC/BC,gBAAkBC,KAAKC,MAAMH,YAAc,IAC3CI,WAAaC,SAASC,iBAAiB,SAAWP,KAAO,MAAQQ,IAAIC,OAAOnB,UAAY,KAAK,GAC7FoB,eAAiBT,WAAWU,QAAQ,GAAK,IAG7CN,WAAWO,aAAa,gBAAiBV,iBACzCG,WAAWQ,MAAMC,MAAQZ,gBACzBG,WAAWU,UAAYL,wBAWlBM,eAAeC,WAAYC,SAAUC,cAC1CC,cAAcH,YACPI,YAAYH,SAAUC,gBAuRxBG,kBAAkBC,UACvBA,SAASC,SAAQ,SAASC,aAClBxB,WAAgC,IAAnBwB,QAAQF,SACrBjC,SAAWmC,QAAQnC,SACnBU,KAAOyB,QAAQC,UACfrB,WAAaC,SAASC,iBAAiB,SAAWP,KAAO,MAAQQ,IAAIC,OAAOnB,UAAY,KAAK,GA5UlF,KA8UXmC,QAAQE,QAIRtB,WAAWuB,UAAUC,IAAI,cAEzB9B,cAAcT,SAAUU,KAAMC,aAnVhB,KAqVPwB,QAAQE,QAIftB,WAAWuB,UAAUC,IAAI,aACzBxB,WAAWuB,UAAUC,IAAI,YAGzBxB,WAAWuB,UAAUE,OAAO,cAE5B/B,cAAcT,SAAUU,KAAM,MA9VjB,KAgWNyB,QAAQE,SAIftB,WAAWuB,UAAUC,IAAI,cACzBxB,WAAWuB,UAAUC,IAAI,YAEzB9B,cAAcT,SAAUU,K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,SACxCvD,UAAYuD,QACZnD,oBAAsB0B,YAAY4E,qBAAsBnG,aAQ5DD,YAAYoH,mBAAqB,WAC7BrH,kBAAoByB,YAAYsF,mBAAoB7G,aAYxDD,YAAYqH,kBAAoB,SAASC,OAAQrE,QAASsE,QAASpH,MAC/DV,SAAW6H,OACX5H,UAAYuD,QACZtD,WAAa4H,QAGT3H,OADQ,UAARO,KACS,SAEA,UAIbf,EAAE,oBAAoBiF,SAAS,KAAKmD,WAAW,QAG/C3H,iBAAmB2B,YAAYyD,kBAAmBhF,aAI7CD"} \ No newline at end of file diff --git a/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js b/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js index db4d0c0bd9a..f588356485e 100644 --- a/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js +++ b/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js @@ -1 +1 @@ -YUI.add("moodle-backup-backupselectall",function(g,e){M.core_backup=M.core_backup||{},M.core_backup.backupselectall=function(e){var t,n,i,c,o,l,a,u,s=null,d=function(e,t,i,n){var c,o;e.preventDefault(),c="",void 0!==n&&(c="setting_activity_"+n+"_"),o=i.length,g.all('input[type="checkbox"]').each(function(e){var n=e.get("name");c&&n.substring(0,c.length)!==c||n.substring(n.length-o)===i&&e.set("checked",t)}),s&&M.form&&M.form.updateFormState(s)},r=function(e,n,t,i){return void 0===i&&(i=""),'"},p=g.one("fieldset#id_coursesettings .fcontainer.clearfix .grouped_settings.section_level");if(p&&p.one('input[type="checkbox"]')){for(l in s=p.ancestor("form").getAttribute("id"),t=!1,g.all('input[type="checkbox"]').each(function(e){var n=e.get("name");"_userdata"===n.substring(n.length-9)?t="_userdata":"_userinfo"===n.substring(n.length-9)&&(t="_userinfo")}),n=r("include_setting section_level","included",M.util.get_string("select","moodle"),' ('+M.util.get_string("showtypes","backup")+")"),t&&(n+=r("normal_setting","userdata",M.util.get_string("select","moodle"))),i=g.Node.create('
      '+n+"
      "),p.insert(i,"before"),c=function(e,n){g.one("#backup-all-mod_"+n).on("click",function(e){d(e,!0,"_included",n)}),g.one("#backup-none-mod_"+n).on("click",function(e){d(e,!1,"_included",n)}),t&&(g.one("#backup-all-userdata-mod_"+n).on("click",function(e){d(e,!0,t,n)}),g.one("#backup-none-userdata-mod_"+n).on("click",function(e){d(e,!1,t,n)}))},(o=g.Node.create('