{"version":3,"file":"loadingicon.min.js","sources":["https:\/\/www.alsg.org\/home\/lib\/amd\/src\/loadingicon.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 logic for the loading icon.\n *\n * @module core\/loading_icon\n * @class loading_icon\n * @copyright 2019 Andrew Nicols \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\ndefine(['jquery', 'core\/templates'], function($, Templates) {\n var TEMPLATES = {\n LOADING: 'core\/loading',\n };\n\n var getIcon = function() {\n return Templates.render(TEMPLATES.LOADING, {});\n };\n\n \/**\n * Add a loading icon to the end of the specified container and return an unresolved promise.\n *\n * Resolution of the returned promise causes the icon to be faded out and removed.\n *\n * @method addIconToContainer\n * @param {jQuery|HTMLElement} container The element to add the spinner to\n * @return {Promise} The Promise used to create the icon.\n *\/\n var addIconToContainer = function(container) {\n return getIcon()\n .then(function(html) {\n var loadingIcon = $(html).hide();\n $(container).append(loadingIcon);\n loadingIcon.fadeIn(150);\n\n return loadingIcon;\n });\n };\n\n \/**\n * Add a loading icon to the end of the specified container and return an unresolved promise.\n *\n * Resolution of the returned promise causes the icon to be faded out and removed.\n *\n * @method addIconToContainerWithPromise\n * @param {jQuery|HTMLElement} container The element to add the spinner to\n * @param {Promise} loadingIconPromise The jQuery Promise which determines the removal of the icon\n * @return {jQuery} The Promise used to create and then remove the icon.\n *\/\n var addIconToContainerRemoveOnCompletion = function(container, loadingIconPromise) {\n return getIcon()\n .then(function(html) {\n var loadingIcon = $(html).hide();\n $(container).append(loadingIcon);\n loadingIcon.fadeIn(150);\n\n return $.when(loadingIcon.promise(), loadingIconPromise);\n })\n .then(function(loadingIcon) {\n \/\/ Once the content has finished loading and\n \/\/ the loading icon has been shown then we can\n \/\/ fade the icon away to reveal the content.\n return loadingIcon.fadeOut(100).promise();\n })\n .then(function(loadingIcon) {\n loadingIcon.remove();\n\n return;\n });\n };\n\n \/**\n * Add a loading icon to the end of the specified container and return an unresolved promise.\n *\n * Resolution of the returned promise causes the icon to be faded out and removed.\n *\n * @method addIconToContainerWithPromise\n * @param {jQuery|HTMLElement} container The element to add the spinner to\n * @return {Promise} A jQuery Promise to resolve when ready\n *\/\n var addIconToContainerWithPromise = function(container) {\n var loadingIconPromise = $.Deferred();\n\n addIconToContainerRemoveOnCompletion(container, loadingIconPromise);\n\n return loadingIconPromise;\n };\n\n return {\n getIcon: getIcon,\n addIconToContainer: addIconToContainer,\n addIconToContainerWithPromise: addIconToContainerWithPromise,\n addIconToContainerRemoveOnCompletion: addIconToContainerRemoveOnCompletion,\n };\n\n});\n"],"names":["define","$","Templates","TEMPLATES","getIcon","render","addIconToContainerRemoveOnCompletion","container","loadingIconPromise","then","html","loadingIcon","hide","append","fadeIn","when","promise","fadeOut","remove","addIconToContainer","addIconToContainerWithPromise","Deferred"],"mappings":";;;;;;;;AAuBAA,0BAAO,CAAC,SAAU,mBAAmB,SAASC,EAAGC,eACzCC,kBACS,eAGTC,QAAU,kBACHF,UAAUG,OAAOF,kBAAmB,KAiC3CG,qCAAuC,SAASC,UAAWC,2BACpDJ,UACNK,MAAK,SAASC,UACPC,YAAcV,EAAES,MAAME,cAC1BX,EAAEM,WAAWM,OAAOF,aACpBA,YAAYG,OAAO,KAEZb,EAAEc,KAAKJ,YAAYK,UAAWR,uBAExCC,MAAK,SAASE,oBAIJA,YAAYM,QAAQ,KAAKD,aAEnCP,MAAK,SAASE,aACXA,YAAYO,mBAuBb,CACHd,QAASA,QACTe,mBA9DqB,SAASZ,kBACvBH,UACNK,MAAK,SAASC,UACPC,YAAcV,EAAES,MAAME,cAC1BX,EAAEM,WAAWM,OAAOF,aACpBA,YAAYG,OAAO,KAEZH,gBAwDXS,8BAXgC,SAASb,eACrCC,mBAAqBP,EAAEoB,kBAE3Bf,qCAAqCC,UAAWC,oBAEzCA,oBAOPF,qCAAsCA"}