{"version":3,"file":"default/js/experience/assets/modalVideoWithContentAsset.js","mappings":";;;;;AAAa;;AAEb;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,SAAS;;AAET;AACA,KAAK;AACL;;AAEA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,CAAC","sources":["webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/experience/assets/modalVideoWithContentAsset.js"],"sourcesContent":["\"use strict\";\n\n/**\n* Handles the click event on the modal video button and shows the modal video\n* @param {Object} $modalButtons - jQuery object of the modal video buttons\n*/\nconst modalOpenBtnListener = () => {\n const $modalButtons = $(\".js-btn-open-modal-video\");\n\n $modalButtons.on(\"click\", function () {\n const $buttonClicked = $(this);\n const $componentContainer = $buttonClicked.parents(\".js-pd-modal-video\");\n const $modalContainer = $(\".js-video-modal-container\", $componentContainer);\n\n $modalContainer.modal(\"show\");\n\n $modalContainer.on(\"hidden.bs.modal\", function () {\n stopHiddenVideosFromPlaying($modalContainer);\n });\n\n autoStartPlayer($modalContainer);\n });\n};\n\n/**\n* Pauses the YouTube video in the modal\n* @param {Object} context - the context of the modal\n*/\nconst stopHiddenVideosFromPlaying = (context) => {\n const $youTubeContainer = $(\".js-modal-video\", context);\n const $videoIframe = $youTubeContainer.children().get(0);\n\n window.players.filter(player => {\n if (player && player.g === $videoIframe) {\n player.pauseVideo();\n }\n });\n};\n\n/**\n* Plays the video in the modal if auto play is enabled\n* @param {Object} context - DOM element containing the video\n*/\nconst autoStartPlayer = (context) => {\n const $youTubeContainer = $(\".js-modal-video\", context);\n const $videoIframe = $youTubeContainer.children().get(0);\n const autoPlay = $youTubeContainer.data(\"video-auto-play\");\n\n if (autoPlay) {\n window.players.filter(player => {\n //If the player is ready and the video is the one in the modal, play the video\n if (player && player.g === $videoIframe) {\n if (Object.prototype.hasOwnProperty.call(player, \"playVideo\")) {\n player.playVideo();\n }\n }\n });\n }\n};\n\n/**\n* Initializes the modal video with content asset component.\n* @param {Object} $container - jQuery object of the modal video with content asset component.\n*/\n$(document).ready(function () {\n const $container = $(\".js-pd-modal-video\");\n\n //If there's no modal video with content asset component, just abort the listener initializers calls.\n if ($container.length === 0) {\n return;\n }\n\n modalOpenBtnListener();\n});\n"],"names":[],"sourceRoot":""}