Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"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 <http://www.gnu.org/licenses/>.\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"}