{"version":3,"sources":["https:\/\/learningcentre.lawsociety.ab.ca\/media\/player\/videojs\/amd\/src\/loader.js"],"names":["firstLoad","language","langStringCache","setUp","lang","notifyVideoJS","Event","getLegacyEvents","done","events","document","on","FILTER_CONTENT_UPDATED","e","nodes","langStrings","getLanguageJson","find","addBack","each","index","element","id","attr","config","data","modulePromises","techOrder","indexOf","push","Promise","all","then","langJson","videojs","options","flash","swf","Config","wwwroot","playbackRates","userActions","hotkeys","addLanguage","catch","Notification","exception","resolve","cacheKey","rawCacheContent","LocalStorage","get","cacheContent","JSON","parse","request","methodname","args","Ajax","call","langStringData","set","result"],"mappings":"wOAyBA,OACA,OACA,OACA,OACA,OACA,O,6nCAGIA,CAAAA,C,CAGAC,C,CAGAC,C,CAQSC,CAAK,CAAG,SAACC,CAAD,CAAU,CAC3BH,CAAQ,CAAGG,CAAX,CACAJ,CAAS,GAAT,CAEAK,CAAa,CAAC,IAAD,CAAO,cAAO,MAAP,CAAP,CAAb,CAEAC,UAAMC,eAAN,GAAwBC,IAAxB,CAA6B,SAACC,CAAD,CAAY,CACrC,cAAOC,QAAP,EAAiBC,EAAjB,CAAoBF,CAAM,CAACG,sBAA3B,CAAmDP,CAAnD,CACH,CAFD,CAGH,C,cAQKA,CAAAA,CAAa,CAAG,SAACQ,CAAD,CAAIC,CAAJ,CAAc,IAE1BC,CAAAA,CAAW,CAAGC,CAAe,EAFH,CAQhCF,CAAK,CAACG,IAAN,yBACKC,OADL,yBAEKD,IAFL,CAEU,cAFV,EAE0BE,IAF1B,CAE+B,SAACC,CAAD,CAAQC,CAAR,CAAoB,IACrCC,CAAAA,CAAE,CAAG,cAAOD,CAAP,EAAgBE,IAAhB,CAAqB,IAArB,CADgC,CAErCC,CAAM,CAAG,cAAOH,CAAP,EAAgBI,IAAhB,CAAqB,YAArB,CAF4B,CAGrCC,CAAc,CAAG,6SAAQ,0BAAR,mDAHoB,CAK3C,GAAIF,CAAM,CAACG,SAAP,EAA4D,CAAC,CAAzC,GAAA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,CAArB,CAEA\/C,CAAe,CAAGkD,CAAlB,CAEA,MAAOtB,CAAAA,OAAO,CAACiB,OAAR,CAAgB7C,CAAhB,CACV,CAED,GAAMqD,CAAAA,CAAO,CAAG,CACZC,UAAU,CAAE,4BADA,CAEZC,IAAI,CAAE,CACFrD,IAAI,CAAEH,CADJ,CAFM,CAAhB,CAOA,MAAOyD,WAAKC,IAAL,CAAU,CAACJ,CAAD,CAAV,EAAqB,CAArB,EACFvB,IADE,CACG,SAAA4B,CAAc,CAAI,CACpBV,UAAaW,GAAb,CAAiBb,CAAjB,CAA2BY,CAA3B,EAEA,MAAOA,CAAAA,CACV,CALE,EAMF5B,IANE,CAMG,SAAA8B,CAAM,QAAIT,CAAAA,IAAI,CAACC,KAAL,CAAWQ,CAAX,CAAJ,CANT,EAOF9B,IAPE,CAOG,SAAAjB,CAAW,CAAI,CACjBb,CAAe,CAAGa,CAAlB,CAEA,MAAOA,CAAAA,CACV,CAXE,CAYV,C","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 * Video JS loader.\n *\n * This takes care of applying the filter on content which was dynamically loaded.\n *\n * @module media_videojs\/loader\n * @copyright 2016 Fr\u00e9d\u00e9ric Massart - FMCorz.net\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\nimport Config from 'core\/config';\nimport Event from 'core\/event';\nimport jQuery from 'jquery';\nimport Ajax from 'core\/ajax';\nimport LocalStorage from 'core\/localstorage';\nimport Notification from 'core\/notification';\n\n\/** @var {bool} Whether this is the first load of videojs module *\/\nlet firstLoad;\n\n\/** @var {string} The language that is used in the player *\/\nlet language;\n\n\/** @var {object} List of languages and translations for the current page *\/\nlet langStringCache;\n\n\/**\n * Set-up.\n *\n * Adds the listener for the event to then notify video.js.\n * @param {string} lang Language to be used in the player\n *\/\nexport const setUp = (lang) => {\n language = lang;\n firstLoad = true;\n \/\/ Notify Video.js about the nodes already present on the page.\n notifyVideoJS(null, jQuery('body'));\n \/\/ We need to call popover automatically if nodes are added to the page later.\n Event.getLegacyEvents().done((events) => {\n jQuery(document).on(events.FILTER_CONTENT_UPDATED, notifyVideoJS);\n });\n};\n\n\/**\n * Notify video.js of new nodes.\n *\n * @param {Event} e The event.\n * @param {NodeList} nodes List of new nodes.\n *\/\nconst notifyVideoJS = (e, nodes) => {\n const selector = '.mediaplugin_videojs';\n const langStrings = getLanguageJson();\n\n \/\/ Find the descendants matching the expected parent of the audio and video\n \/\/ tags. Then also addBack the nodes matching the same selector. Finally,\n \/\/ we find the audio and video tags contained in those parents. Kind thanks\n \/\/ to jQuery for the simplicity.\n nodes.find(selector)\n .addBack(selector)\n .find('audio, video').each((index, element) => {\n const id = jQuery(element).attr('id');\n const config = jQuery(element).data('setup-lazy');\n const modulePromises = [import('media_videojs\/video-lazy')];\n\n if (config.techOrder && config.techOrder.indexOf('youtube') !== -1) {\n \/\/ Add YouTube to the list of modules we require.\n modulePromises.push(import('media_videojs\/Youtube-lazy'));\n }\n if (config.techOrder && config.techOrder.indexOf('flash') !== -1) {\n \/\/ Add Flash to the list of modules we require.\n modulePromises.push(import('media_videojs\/videojs-flash-lazy'));\n }\n Promise.all([langStrings, ...modulePromises])\n .then(([langJson, videojs]) => {\n if (firstLoad) {\n videojs.options.flash.swf = `${Config.wwwroot}\/media\/player\/videojs\/videojs\/video-js.swf`;\n videojs.options.playbackRates = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];\n videojs.options.userActions = {\n hotkeys: true,\n };\n videojs.addLanguage(language, langJson);\n\n firstLoad = false;\n }\n videojs(id, config);\n return;\n })\n .catch(Notification.exception);\n });\n};\n\n\/**\n * Returns the json object of the language strings to be used in the player.\n *\n * @returns {Promise}\n *\/\nconst getLanguageJson = () => {\n if (langStringCache) {\n return Promise.resolve(langStringCache);\n }\n\n const cacheKey = `media_videojs\/${language}`;\n\n const rawCacheContent = LocalStorage.get(cacheKey);\n if (rawCacheContent) {\n const cacheContent = JSON.parse(rawCacheContent);\n\n langStringCache = cacheContent;\n\n return Promise.resolve(langStringCache);\n }\n\n const request = {\n methodname: 'media_videojs_get_language',\n args: {\n lang: language,\n },\n };\n\n return Ajax.call([request])[0]\n .then(langStringData => {\n LocalStorage.set(cacheKey, langStringData);\n\n return langStringData;\n })\n .then(result => JSON.parse(result))\n .then(langStrings => {\n langStringCache = langStrings;\n\n return langStrings;\n });\n};\n"],"file":"loader.min.js"}