1{"version":3,"sources":["../src/loader.js"],"names":["define","$","Event","onload","notifyVideoJS","e","nodes","find","addBack","each","id","attr","config","data","modules","techOrder","indexOf","push","require","videojs","setUp","executeonload","getLegacyEvents","done","events","document","on","FILTER_CONTENT_UPDATED"],"mappings":"AAwBAA,OAAM,wBAAC,CAAC,QAAD,CAAW,YAAX,CAAD,CAA2B,SAASC,CAAT,CAAYC,CAAZ,CAAmB,IAK5CC,CAAAA,CAL4C,CA6B5CC,CAAa,CAAG,SAASC,CAAT,CAAYC,CAAZ,CAAmB,CAOnCA,CAAK,CAACC,IAAN,yBACKC,OADL,yBAEKD,IAFL,CAEU,cAFV,EAE0BE,IAF1B,CAE+B,UAAW,CAClC,GAAIC,CAAAA,CAAE,CAAGT,CAAC,CAAC,IAAD,CAAD,CAAQU,IAAR,CAAa,IAAb,CAAT,CACIC,CAAM,CAAGX,CAAC,CAAC,IAAD,CAAD,CAAQY,IAAR,CAAa,YAAb,CADb,CAEIC,CAAO,CAAG,CAAC,0BAAD,CAFd,CAIA,GAAIF,CAAM,CAACG,SAAP,EAA4D,CAAC,CAAzC,GAAAH,CAAM,CAACG,SAAP,CAAiBC,OAAjB,CAAyB,SAAzB,CAAxB,CAAoE,CAEhEF,CAAO,CAACG,IAAR,CAAa,4BAAb,CACH,CACD,GAAIL,CAAM,CAACG,SAAP,EAA0D,CAAC,CAAvC,GAAAH,CAAM,CAACG,SAAP,CAAiBC,OAAjB,CAAyB,OAAzB,CAAxB,CAAkE,CAE9DF,CAAO,CAACG,IAAR,CAAa,kCAAb,CACH,CACDC,OAAO,CAACJ,CAAD,CAAU,SAASK,CAAT,CAAkB,CAC/B,GAAIhB,CAAJ,CAAY,CACRA,CAAM,CAACgB,CAAD,CAAN,CACAhB,CAAM,CAAG,IACZ,CACDgB,CAAO,CAACT,CAAD,CAAKE,CAAL,CACV,CANM,CAOV,CAtBL,CAuBH,CA3D+C,CA6DhD,MAAO,CACHQ,KAAK,CAjDG,QAARA,CAAAA,KAAQ,CAASC,CAAT,CAAwB,CAChClB,CAAM,CAAGkB,CAAT,CAEAjB,CAAa,CAAC,IAAD,CAAOH,CAAC,CAAC,MAAD,CAAR,CAAb,CAEAC,CAAK,CAACoB,eAAN,GAAwBC,IAAxB,CAA6B,SAASC,CAAT,CAAiB,CAC1CvB,CAAC,CAACwB,QAAD,CAAD,CAAYC,EAAZ,CAAeF,CAAM,CAACG,sBAAtB,CAA8CvB,CAA9C,CACH,CAFD,CAGH,CAwCM,CAIV,CAjEK,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 * Video JS loader.\n *\n * This takes care of applying the filter on content which was dynamically loaded.\n *\n * @package    media_videojs\n * @copyright  2016 Frédéric Massart - FMCorz.net\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/event'], function($, Event) {\n\n    /**\n     * Stores the method we need to execute on the first load of videojs module.\n     */\n    var onload;\n\n    /**\n     * Set-up.\n     *\n     * Adds the listener for the event to then notify video.js.\n     * @param {Function} executeonload function to execute when media_videojs/video is loaded\n     */\n    var setUp = function(executeonload) {\n        onload = executeonload;\n        // Notify Video.js about the nodes already present on the page.\n        notifyVideoJS(null, $('body'));\n        // We need to call popover automatically if nodes are added to the page later.\n        Event.getLegacyEvents().done(function(events) {\n            $(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     */\n    var notifyVideoJS = function(e, nodes) {\n        var selector = '.mediaplugin_videojs';\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(function() {\n                var id = $(this).attr('id'),\n                    config = $(this).data('setup-lazy'),\n                    modules = ['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                    modules.push('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                    modules.push('media_videojs/videojs-flash-lazy');\n                }\n                require(modules, function(videojs) {\n                    if (onload) {\n                        onload(videojs);\n                        onload = null;\n                    }\n                    videojs(id, config);\n                });\n            });\n    };\n\n    return {\n        setUp: setUp\n    };\n\n});\n"],"file":"loader.min.js"}