Current Path : C:/xampp/htdocs/moodle/mod/lti/amd/build/ |
Current File : C:/xampp/htdocs/moodle/mod/lti/amd/build/tool_proxy_card_controller.min.js.map |
{"version":3,"sources":["../src/tool_proxy_card_controller.js"],"names":["define","$","ajax","notification","templates","toolProxy","ltiEvents","KEYS","str","SELECTORS","DELETE_BUTTON","CAPABILITIES_CONTAINER","ACTIVATE_BUTTON","ANNOUNCEMENT_TIMEOUT","getDeleteButton","element","find","getActivateButton","getTypeId","attr","clearAllAnnouncements","removeClass","startLoading","addClass","stopLoading","announceSuccess","promise","Deferred","setTimeout","resolve","announceFailure","deleteType","typeId","get_strings","key","component","done","strs","confirm","delete","remove","fail","exception","error","reject","activateToolType","data","proxyid","document","trigger","START_EXTERNAL_REGISTRATION","registerEventListeners","deleteButton","click","e","preventDefault","keypress","metaKey","shiftKey","altKey","ctrlKey","keyCode","ENTER","SPACE","activateButton","init"],"mappings":"AA4BAA,OAAM,sCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,mBAAxB,CAA6C,gBAA7C,CAA+D,oBAA/D,CAAqF,gBAArF,CAAuG,cAAvG,CACC,UADD,CAAD,CAEE,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAsDC,CAAtD,CAAiEC,CAAjE,CAAuEC,CAAvE,CAA4E,IAE5EC,CAAAA,CAAS,CAAG,CACZC,aAAa,CAAE,SADH,CAEZC,sBAAsB,CAAE,yBAFZ,CAGZC,eAAe,CAAE,8BAHL,CAFgE,CAS5EC,CAAoB,CAAG,GATqD,CAmB5EC,CAAe,CAAG,SAASC,CAAT,CAAkB,CACpC,MAAOA,CAAAA,CAAO,CAACC,IAAR,CAAaP,CAAS,CAACC,aAAvB,CACV,CArB+E,CA+B5EO,CAAiB,CAAG,SAASF,CAAT,CAAkB,CACtC,MAAOA,CAAAA,CAAO,CAACC,IAAR,CAAaP,CAAS,CAACG,eAAvB,CACV,CAjC+E,CA2C5EM,CAAS,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,EAA0C,CAACL,CAAC,CAACM,OAAjD,CAA0D,CACtD,GAAIN,CAAC,CAACO,OAAF,EAAatD,CAAI,CAACuD,KAAlB,EAA2BR,CAAC,CAACO,OAAF,EAAatD,CAAI,CAACwD,KAAjD,CAAwD,CACpDT,CAAC,CAACC,cAAF,GACAS,CAAc,CAACX,KAAf,EACH,CACJ,CACJ,CAPL,CAQH,CAhP+E,CAkPhF,MAAyD,CAOrDY,IAAI,CAAE,cAASlD,CAAT,CAAkB,CACpBoC,CAAsB,CAACpC,CAAD,CACzB,CAToD,CAW5D,CA/PK,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 <http://www.gnu.org/licenses/>.\n\n/**\n * Controls all of the behaviour and interaction with a tool type card. These are\n * listed on the LTI tool type management page.\n *\n * See template: mod_lti/tool_proxy_card\n *\n * @module mod_lti/tool_proxy_card_controller\n * @class tool_card_controller\n * @package mod_lti\n * @copyright 2016 John Okely <john@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.1\n */\ndefine(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/tool_proxy', 'mod_lti/events', 'mod_lti/keys',\n 'core/str'],\n function($, ajax, notification, templates, toolProxy, ltiEvents, KEYS, str) {\n\n var SELECTORS = {\n DELETE_BUTTON: '.delete',\n CAPABILITIES_CONTAINER: '.capabilities-container',\n ACTIVATE_BUTTON: '.tool-card-footer a.activate',\n };\n\n // Timeout in seconds.\n var ANNOUNCEMENT_TIMEOUT = 2000;\n\n /**\n * Return the delete button element.\n *\n * @method getDeleteButton\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n * @return {JQuery} jQuery object\n */\n var getDeleteButton = function(element) {\n return element.find(SELECTORS.DELETE_BUTTON);\n };\n\n /**\n * Return the activate button for the type.\n *\n * @method getActivateButton\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n * @return {JQuery} jQuery object\n */\n var getActivateButton = function(element) {\n return element.find(SELECTORS.ACTIVATE_BUTTON);\n };\n\n /**\n * Get the type id.\n *\n * @method getTypeId\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n * @return {String} Type ID\n */\n var getTypeId = function(element) {\n return element.attr('data-proxy-id');\n };\n\n /**\n * Stop any announcement currently visible on the card.\n *\n * @method clearAllAnnouncements\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n */\n var clearAllAnnouncements = function(element) {\n element.removeClass('announcement loading success fail capabilities');\n };\n\n /**\n * Show the loading announcement.\n *\n * @method startLoading\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n */\n var startLoading = function(element) {\n clearAllAnnouncements(element);\n element.addClass('announcement loading');\n };\n\n /**\n * Hide the loading announcement.\n *\n * @method stopLoading\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n */\n var stopLoading = function(element) {\n element.removeClass('announcement loading');\n };\n\n /**\n * Show the success announcement. The announcement is only\n * visible for 2 seconds.\n *\n * @method announceSuccess\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n * @return {Promise} jQuery Deferred object\n */\n var announceSuccess = function(element) {\n var promise = $.Deferred();\n\n clearAllAnnouncements(element);\n element.addClass('announcement success');\n setTimeout(function() {\n element.removeClass('announcement success');\n promise.resolve();\n }, ANNOUNCEMENT_TIMEOUT);\n\n return promise;\n };\n\n /**\n * Show the failure announcement. The announcement is only\n * visible for 2 seconds.\n *\n * @method announceFailure\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n * @return {Promise} jQuery Deferred object\n */\n var announceFailure = function(element) {\n var promise = $.Deferred();\n\n clearAllAnnouncements(element);\n element.addClass('announcement fail');\n setTimeout(function() {\n element.removeClass('announcement fail');\n promise.resolve();\n }, ANNOUNCEMENT_TIMEOUT);\n\n return promise;\n };\n\n /**\n * Delete the tool type from the Moodle server. Triggers a success\n * or failure announcement depending on the result.\n *\n * @method deleteType\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n * @return {Promise} jQuery Deferred object\n */\n var deleteType = function(element) {\n var promise = $.Deferred();\n var typeId = getTypeId(element);\n startLoading(element);\n\n if (typeId === \"\") {\n return $.Deferred().resolve();\n }\n\n str.get_strings([\n {\n key: 'delete',\n component: 'mod_lti'\n },\n {\n key: 'delete_confirmation',\n component: 'mod_lti'\n },\n {\n key: 'delete',\n component: 'mod_lti'\n },\n {\n key: 'cancel',\n component: 'core'\n },\n ])\n .done(function(strs) {\n notification.confirm(strs[0], strs[1], strs[2], strs[3], function() {\n toolProxy.delete(typeId)\n .done(function() {\n stopLoading(element);\n announceSuccess(element)\n .done(function() {\n element.remove();\n promise.resolve();\n })\n .fail(notification.exception);\n })\n .fail(function(error) {\n announceFailure(element);\n promise.reject(error);\n });\n }, function() {\n stopLoading(element);\n promise.resolve();\n });\n })\n .fail(function(error) {\n stopLoading(element);\n notification.exception(error);\n promise.reject(error);\n });\n\n return promise;\n };\n\n /**\n * The user wishes to activate this tool so show them the capabilities that\n * they need to agree to or if there are none then set the tool type's state\n * to active.\n *\n * @method activateToolType\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n */\n var activateToolType = function(element) {\n var data = {proxyid: getTypeId(element)};\n $(document).trigger(ltiEvents.START_EXTERNAL_REGISTRATION, data);\n };\n\n /**\n * Sets up the listeners for user interaction on this tool type card.\n *\n * @method registerEventListeners\n * @private\n * @param {JQuery} element jQuery object representing the tool card.\n */\n var registerEventListeners = function(element) {\n var deleteButton = getDeleteButton(element);\n deleteButton.click(function(e) {\n e.preventDefault();\n deleteType(element);\n });\n deleteButton.keypress(function(e) {\n if (!e.metaKey && !e.shiftKey && !e.altKey && !e.ctrlKey) {\n if (e.keyCode == KEYS.ENTER || e.keyCode == KEYS.SPACE) {\n e.preventDefault();\n deleteButton.click();\n }\n }\n });\n\n var activateButton = getActivateButton(element);\n activateButton.click(function(e) {\n e.preventDefault();\n activateToolType(element);\n });\n activateButton.keypress(function(e) {\n if (!e.metaKey && !e.shiftKey && !e.altKey && !e.ctrlKey) {\n if (e.keyCode == KEYS.ENTER || e.keyCode == KEYS.SPACE) {\n e.preventDefault();\n activateButton.click();\n }\n }\n });\n };\n\n return /** @alias module:mod_lti/tool_card_controller */ {\n\n /**\n * Initialise this module.\n *\n * @param {JQuery} element jQuery object representing the tool card.\n */\n init: function(element) {\n registerEventListeners(element);\n }\n };\n});\n"],"file":"tool_proxy_card_controller.min.js"}