/** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ define([ 'jquery', 'jquery-ui-modules/widget', 'catalogGallery', 'loadPlayer' ], function ($) { 'use strict'; /** * @private */ var allowBase = true; //global var is needed because fotorama always fully reloads events in case of fullscreen /** * @private */ function parseHref(href) { var a = document.createElement('a'); a.href = href; return a; } /** * @private */ function parseURL(href, forceVideo) { var id, type, ampersandPosition, vimeoRegex, useYoutubeNocookie = false; /** * Get youtube ID * @param {String} srcid * @returns {{}} */ function _getYoutubeId(srcid) { if (srcid) { ampersandPosition = srcid.indexOf('&'); if (ampersandPosition === -1) { return srcid; } srcid = srcid.substring(0, ampersandPosition); } return srcid; } if (typeof href !== 'string') { return href; } href = parseHref(href); if (href.host.match(/youtube\.com/) && href.search) { id = href.search.split('v=')[1]; if (id) { id = _getYoutubeId(id); type = 'youtube'; } } else if (href.host.match(/youtube\.com|youtu\.be|youtube-nocookie.com/)) { id = href.pathname.replace(/^\/(embed\/|v\/)?/, '').replace(/\/.*/, ''); type = 'youtube'; if (href.host.match(/youtube-nocookie.com/)) { useYoutubeNocookie = true; } } else if (href.host.match(/vimeo\.com/)) { type = 'vimeo'; vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)', '?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|video\\/|)(\\d+)(?:$|\\/|\\?)' ].join('')); id = href.href.match(vimeoRegex)[3]; } if ((!id || !type) && forceVideo) { id = href.href; type = 'custom'; } return id ? { id: id, type: type, s: href.search.replace(/^\?/, ''), useYoutubeNocookie: useYoutubeNocookie } : false; } //create AddFotoramaVideoEvents widget $.widget('mage.AddFotoramaVideoEvents', { options: { videoData: '', videoSettings: '', optionsVideoData: '', dataMergeStrategy: 'replace' }, /** * @private */ onVimeoJSFramework: function () {}, defaultVideoData: [], PV: 'product-video', // [CONST] VU: 'video-unplayed', PVLOADED: 'fotorama__product-video--loaded', // [CONST] PVLOADING: 'fotorama__product-video--loading', // [CONST] VID: 'video', // [CONST] VI: 'vimeo', // [CONST] FTVC: 'fotorama__video-close', FTAR: 'fotorama__arr', fotoramaSpinner: 'fotorama__spinner', fotoramaSpinnerShow: 'fotorama__spinner--show', TI: 'video-thumb-icon', isFullscreen: false, FTCF: '[data-gallery-role="fotorama__fullscreen-icon"]', Base: 0, //on check for video is base this setting become true if there is any video with base role MobileMaxWidth: 768, GP: 'gallery-placeholder', //gallery placeholder class is needed to find and erase