{"version":3,"file":"util.min.js","sources":["https:\/\/www.moodlemediterrani.com\/moodle\/theme\/snap\/amd\/src\/util.js"],"sourcesContent":["\/**\n * 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 * @package\n * @copyright Copyright (c) 2016 Open LMS (https:\/\/www.openlms.net)\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\ndefine(['jquery'], function($) {\n\n var staticSupportsSessionStorage = null;\n\n \/**\n * General utilities library.\n *\/\n return {\n \/**\n * On function evaluating true.\n *\n * @param {function} func\n * @param {function} callBack\n * @param {boolean} forceCallBack\n * @param {number} maxIterations\n * @param {number} i\n *\/\n whenTrue: function(func, callBack, forceCallBack, maxIterations, i) {\n maxIterations = !maxIterations ? 10 : maxIterations;\n i = !i ? 0 : i + 1;\n if (i > maxIterations) {\n \/\/ Error, too long waiting for function to evaluate true.\n if (forceCallBack) {\n callBack();\n }\n return;\n }\n if (func()) {\n callBack();\n } else {\n var self = this;\n window.setTimeout(function() {\n self.whenTrue(func, callBack, forceCallBack, maxIterations, i);\n }, 200);\n }\n },\n\n \/**\n * Scroll a specific dom element into the viewport.\n * @param {Object} el\n *\/\n scrollToElement: function(el) {\n var navheight = $('#mr-nav').outerHeight();\n\n if (!el.length) {\n \/\/ Element does not exist so exit.\n return;\n }\n if (el.length > 1) {\n \/\/ If collection has more than one element then exit - we can't scroll to more than one element!\n return;\n }\n var scrtop = el.offset().top - navheight;\n $('html, body').animate({\n scrollTop: scrtop\n }, 600);\n },\n\n \/**\n * Does the browser support session storage?\n * @returns {null|bool}\n *\/\n supportsSessionStorage: function() {\n if (staticSupportsSessionStorage !== null) {\n return staticSupportsSessionStorage;\n }\n if (typeof window.sessionStorage === 'object') {\n try {\n window.sessionStorage.setItem('sessionStorage', 1);\n window.sessionStorage.removeItem('sessionStorage');\n staticSupportsSessionStorage = true;\n } catch (e) {\n staticSupportsSessionStorage = false;\n }\n }\n return staticSupportsSessionStorage;\n }\n };\n});\n"],"names":["define","$","staticSupportsSessionStorage","whenTrue","func","callBack","forceCallBack","maxIterations","i","self","this","window","setTimeout","scrollToElement","el","navheight","outerHeight","length","scrtop","offset","top","animate","scrollTop","supportsSessionStorage","sessionStorage","setItem","removeItem","e"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBAA,yBAAO,CAAC,WAAW,SAASC,OAEpBC,6BAA+B,WAK5B,CAUHC,SAAU,SAASC,KAAMC,SAAUC,cAAeC,cAAeC,OAE7DA,EAAKA,EAAQA,EAAI,EAAR,IADTD,cAAiBA,eAAgB,IAIzBD,eACAD,mBAIJD,OACAC,eACG,KACCI,KAAOC,KACXC,OAAOC,YAAW,WACdH,KAAKN,SAASC,KAAMC,SAAUC,cAAeC,cAAeC,KAC7D,OAQXK,gBAAiB,SAASC,QAClBC,UAAYd,EAAE,WAAWe,iBAExBF,GAAGG,UAIJH,GAAGG,OAAS,QAIZC,OAASJ,GAAGK,SAASC,IAAML,UAC\/Bd,EAAE,cAAcoB,QAAQ,CACpBC,UAAWJ,QACZ,OAOPK,uBAAwB,cACiB,OAAjCrB,oCACOA,gCAE0B,iBAA1BS,OAAOa,mBAEVb,OAAOa,eAAeC,QAAQ,iBAAkB,GAChDd,OAAOa,eAAeE,WAAW,kBACjCxB,8BAA+B,EACjC,MAAOyB,GACLzB,8BAA+B,SAGhCA"}