Current Path : C:/xampp/htdocs/moodle/mod/lti/amd/build/ |
Current File : C:/xampp/htdocs/moodle/mod/lti/amd/build/cartridge_registration_form.min.js.map |
{"version":3,"sources":["../src/cartridge_registration_form.js"],"names":["define","$","ajax","notification","toolType","ltiEvents","KEYS","str","SELECTORS","CARTRIDGE_URL","CONSUMER_KEY","SHARED_SECRET","REGISTRATION_FORM","REGISTRATION_SUBMIT_BUTTON","REGISTRATION_CANCEL_BUTTON","getCartridgeURL","attr","getSubmitButton","getCancelButton","getConsumerKey","val","getSharedSecret","startLoading","addClass","stopLoading","removeClass","isLoading","hasClass","submitCartridgeURL","url","consumerKey","sharedSecret","promise","create","cartridgeurl","key","secret","done","get_string","s","document","trigger","NEW_TOOL_TYPE","STOP_CARTRIDGE_REGISTRATION","REGISTRATION_FEEDBACK","message","fail","exception","error","always","registerEventListeners","form","submit","e","preventDefault","cancelButton","click","keypress","metaKey","shiftKey","altKey","ctrlKey","keyCode","ENTER","SPACE","init"],"mappings":"AA4BAA,OAAM,uCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,mBAAxB,CAA6C,mBAA7C,CAAkE,gBAAlE,CAAoF,cAApF,CAAoG,UAApG,CAAD,CACE,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAA0CC,CAA1C,CAAqDC,CAArD,CAA2DC,CAA3D,CAAgE,IAEhEC,CAAAA,CAAS,CAAG,CACZC,aAAa,CAAE,gBADH,CAEZC,YAAY,CAAE,mBAFF,CAGZC,aAAa,CAAE,sBAHH,CAIZC,iBAAiB,CAAE,8BAJP,CAKZC,0BAA0B,CAAE,gCALhB,CAMZC,0BAA0B,CAAE,gCANhB,CAFoD,CAkBhEC,CAAe,CAAG,UAAW,CAC7B,MAAOd,CAAAA,CAAC,CAACO,CAAS,CAACI,iBAAX,CAAD,CAA+BI,IAA/B,CAAoC,oBAApC,CACV,CApBmE,CA6BhEC,CAAe,CAAG,UAAW,CAC7B,MAAOhB,CAAAA,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AAYC,OAAZ,CAAoBpC,CAAS,CAACsC,2BAA9B,CACH,CAHD,EAIAY,CAAY,CAACE,QAAb,CAAsB,SAASJ,CAAT,CAAY,CAC9B,GAAI,CAACA,CAAC,CAACK,OAAH,EAAc,CAACL,CAAC,CAACM,QAAjB,EAA6B,CAACN,CAAC,CAACO,MAAhC,EAA0C,CAACP,CAAC,CAACQ,OAAjD,CAA0D,CACtD,GAAIR,CAAC,CAACS,OAAF,EAAaxD,CAAI,CAACyD,KAAlB,EAA2BV,CAAC,CAACS,OAAF,EAAaxD,CAAI,CAAC0D,KAAjD,CAAwD,CACpDX,CAAC,CAACC,cAAF,GACAC,CAAY,CAACC,KAAb,EACH,CACJ,CACJ,CAPD,CAQH,CA/KmE,CAiLpE,MAAgE,CAK5DS,IAAI,CAAE,eAAW,CACbf,CAAsB,EACzB,CAP2D,CASnE,CA3LK,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 * Encapsules the behavior for creating a tool type from a cartridge URL\n * in Moodle. Manages the UI while operations are occuring.\n *\n * See template: mod_lti/cartridge_registration_form\n *\n * @module mod_lti/cartridge_registration_form\n * @class cartridge_registration_form\n * @package mod_lti\n * @copyright 2015 Ryan Wyllie <ryan@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', 'mod_lti/tool_type', 'mod_lti/events', 'mod_lti/keys', 'core/str'],\n function($, ajax, notification, toolType, ltiEvents, KEYS, str) {\n\n var SELECTORS = {\n CARTRIDGE_URL: '#cartridge-url',\n CONSUMER_KEY: '#registration-key',\n SHARED_SECRET: '#registration-secret',\n REGISTRATION_FORM: '#cartridge-registration-form',\n REGISTRATION_SUBMIT_BUTTON: '#cartridge-registration-submit',\n REGISTRATION_CANCEL_BUTTON: '#cartridge-registration-cancel',\n };\n\n /**\n * Return the URL the user entered for the cartridge.\n *\n * @method getCartridgeURL\n * @private\n * @return {String}\n */\n var getCartridgeURL = function() {\n return $(SELECTORS.REGISTRATION_FORM).attr('data-cartridge-url');\n };\n\n /**\n * Return the submit button element.\n *\n * @method getSubmitButton\n * @private\n * @return {JQuery} jQuery object\n */\n var getSubmitButton = function() {\n return $(SELECTORS.REGISTRATION_SUBMIT_BUTTON);\n };\n\n /**\n * Return the cancel button element.\n *\n * @method getCancelButton\n * @private\n * @return {JQuery} jQuery object\n */\n var getCancelButton = function() {\n return $(SELECTORS.REGISTRATION_CANCEL_BUTTON);\n };\n\n /**\n * Return the value that the user entered for the consumer key.\n *\n * @method getConsumerKey\n * @private\n * @return {String} the value entered for consumer key.\n */\n var getConsumerKey = function() {\n return $(SELECTORS.CONSUMER_KEY).val();\n };\n\n /**\n * Return the value that the user entered for the shared secret.\n *\n * @method getSharedSecret\n * @private\n * @return {String} the value entered for shared secret\n */\n var getSharedSecret = function() {\n return $(SELECTORS.SHARED_SECRET).val();\n };\n\n /**\n * Trigger a visual loading indicator.\n *\n * @method startLoading\n * @private\n */\n var startLoading = function() {\n getSubmitButton().addClass('loading');\n };\n\n /**\n * Stop the visual loading indicator.\n *\n * @method stopLoading\n * @private\n */\n var stopLoading = function() {\n getSubmitButton().removeClass('loading');\n };\n\n /**\n * Check if the page is currently loading.\n *\n * @method isLoading\n * @private\n * @return {Boolean}\n */\n var isLoading = function() {\n return getSubmitButton().hasClass('loading');\n };\n\n /**\n * Create a tool type from the cartridge URL that the user input. This will\n * send an ajax request to the Moodle server to create the Type. The request will\n * include the consumer key and secret, if any.\n *\n * On success the page will be re-rendered to take the user back to the original\n * page with the list of tools and an alert notifying them of success.\n *\n * @method submitCartridgeURL\n * @private\n * @return {Promise} jQuery Deferred object\n */\n var submitCartridgeURL = function() {\n if (isLoading()) {\n return false;\n }\n\n var url = getCartridgeURL();\n // No URL? Do nothing.\n if (url === \"\") {\n return false;\n }\n\n startLoading();\n var consumerKey = getConsumerKey();\n var sharedSecret = getSharedSecret();\n var promise = toolType.create({cartridgeurl: url, key: consumerKey, secret: sharedSecret});\n\n promise.done(function() {\n str.get_string('successfullycreatedtooltype', 'mod_lti').done(function(s) {\n $(document).trigger(ltiEvents.NEW_TOOL_TYPE);\n $(document).trigger(ltiEvents.STOP_CARTRIDGE_REGISTRATION);\n $(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, {\n message: s\n });\n }).fail(notification.exception);\n }).fail(function() {\n str.get_string('failedtocreatetooltype', 'mod_lti').done(function(s) {\n $(document).trigger(ltiEvents.NEW_TOOL_TYPE);\n $(document).trigger(ltiEvents.STOP_CARTRIDGE_REGISTRATION);\n $(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, {\n message: s,\n error: true\n });\n }).fail(notification.exception);\n }).always(function() {\n stopLoading();\n });\n\n return promise;\n };\n\n /**\n * Sets up the listeners for user interaction on the page.\n *\n * @method registerEventListeners\n * @private\n */\n var registerEventListeners = function() {\n var form = $(SELECTORS.REGISTRATION_FORM);\n form.submit(function(e) {\n e.preventDefault();\n submitCartridgeURL();\n });\n\n var cancelButton = getCancelButton();\n cancelButton.click(function(e) {\n e.preventDefault();\n $(document).trigger(ltiEvents.STOP_CARTRIDGE_REGISTRATION);\n });\n cancelButton.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 cancelButton.click();\n }\n }\n });\n };\n\n return /** @alias module:mod_lti/cartridge_registration_form */ {\n\n /**\n * Initialise this module.\n */\n init: function() {\n registerEventListeners();\n }\n };\n});\n"],"file":"cartridge_registration_form.min.js"}