File: /var/www/html/demo.sumarbc.com.py/mod/hvp/amd/build/communicator.min.js.map
{"version":3,"file":"communicator.min.js","sources":["../src/communicator.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 <http://www.gnu.org/licenses/>.\n\ndefine([], function() {\n\n /**\n * When embedded the communicator helps talk to the parent page.\n * This is a copy of the H5P.communicator, which we need to communicate in this context\n */\n var H5PEmbedCommunicator = function() {\n this._actionHandlers = {};\n this.registerEventListeners();\n };\n\n /** @type {Object} Maps actions to functions. */\n H5PEmbedCommunicator.prototype._actionHandlers = {};\n\n /**\n * Register action listener.\n *\n * @param {string} action What you are waiting for\n * @param {function} handler What you want done\n */\n H5PEmbedCommunicator.prototype.on = function(action, handler) {\n this._actionHandlers[action] = handler;\n };\n\n /**\n * Send a message to the all mighty father.\n *\n * @param {string} action\n * @param {Object} [data] payload\n */\n H5PEmbedCommunicator.prototype.send = function(action, data) {\n if (data === undefined) {\n data = {};\n }\n data.context = 'h5p';\n data.action = action;\n\n // Parent origin can be anything.\n window.parent.postMessage(data, '*');\n };\n\n\n /**\n * Register event listeners for the communicator.\n *\n * @method registerEventListeners\n */\n H5PEmbedCommunicator.prototype.registerEventListeners = function() {\n var self = this;\n // Register message listener.\n window.addEventListener('message', function receiveMessage(event) {\n if (window.parent !== event.source || event.data.context !== 'h5p') {\n return; // Only handle messages from parent and in the correct context.\n }\n\n if (self._actionHandlers[event.data.action] !== undefined) {\n self._actionHandlers[event.data.action](event.data);\n }\n }, false);\n };\n\n return new H5PEmbedCommunicator();\n\n});\n"],"names":["define","H5PEmbedCommunicator","_actionHandlers","registerEventListeners","prototype","on","action","handler","send","data","undefined","context","window","parent","postMessage","self","this","addEventListener","event","source"],"mappings":"AAeAA,8BAAO,IAAI,eAMHC,qBAAuB,gBAClBC,gBAAkB,QAClBC,iCAITF,qBAAqBG,UAAUF,gBAAkB,GAQjDD,qBAAqBG,UAAUC,GAAK,SAASC,OAAQC,cAC5CL,gBAAgBI,QAAUC,SASnCN,qBAAqBG,UAAUI,KAAO,SAASF,OAAQG,WACtCC,IAATD,OACAA,KAAO,IAEXA,KAAKE,QAAU,MACfF,KAAKH,OAASA,OAGdM,OAAOC,OAAOC,YAAYL,KAAM,MASpCR,qBAAqBG,UAAUD,uBAAyB,eAChDY,KAAOC,KAEXJ,OAAOK,iBAAiB,WAAW,SAAwBC,OACnDN,OAAOC,SAAWK,MAAMC,QAAiC,QAAvBD,MAAMT,KAAKE,cAIDD,IAA5CK,KAAKb,gBAAgBgB,MAAMT,KAAKH,SAChCS,KAAKb,gBAAgBgB,MAAMT,KAAKH,QAAQY,MAAMT,SAEnD,IAGA,IAAIR"}