From 360698b5ac909583f252dd89ba8fd6716c468ee9 Mon Sep 17 00:00:00 2001 From: Michael Kessler <michael.kessler@sgalinski.de> Date: Wed, 2 Jun 2021 16:23:10 +0200 Subject: [PATCH] [TASK] Remove javascript --- .../Public/JavaScript/youtubeLightbox.js | 92 ------------------- composer.json | 49 +++++----- ext_emconf.php | 1 + 3 files changed, 26 insertions(+), 116 deletions(-) delete mode 100644 Resources/Public/JavaScript/youtubeLightbox.js diff --git a/Resources/Public/JavaScript/youtubeLightbox.js b/Resources/Public/JavaScript/youtubeLightbox.js deleted file mode 100644 index 17749e5..0000000 --- a/Resources/Public/JavaScript/youtubeLightbox.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * JavaScript module for the sg-youtube plugin - * - */ -module.exports = function() { - 'use strict'; - - const $ = require('jquery'); - require('magnific-popup'); - - /** - * Initialize the whole Popup setup - */ - function init(section) { - $(`${section || ''} .sg-youtube-item`).each(function (index, item) { - let $youtubeItem = $(item), - viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); - if (($youtubeItem.data('disable-lightbox') && viewportWidth >= 680) || - ($youtubeItem.data('disable-lightbox-mobile') && viewportWidth < 680) - ) { - $youtubeItem.on('click', replaceThumbnailWithVideo); - } else { - $youtubeItem.magnificPopup({ - type: 'iframe', - iframe: { - patterns: { - youtube: { - index: 'youtube.com/', - id: function(url) { - return prepareVideoUrl(url); - }, - src: '//www.youtube-nocookie.com/embed/%id%' - } - } - } - }); - } - }); - } - - /** - * Replaces the given element behind the event with a youtube video. - * - * @param {Event} event - */ - function replaceThumbnailWithVideo(event) { - event.preventDefault(); - let $youtubeItem = $(event.currentTarget); - - // This needs to be done, because the height of inline elements is always 0, if on auto... - $youtubeItem.css('display', 'block'); - - let queryString = prepareVideoUrl($youtubeItem.attr('href')), - $thumbnailElement = $youtubeItem.find('.sg-youtube-image'), - width = $thumbnailElement.outerWidth() + 'px', - height = $thumbnailElement.outerHeight() + 'px'; - $thumbnailElement.replaceWith('<div class="sg-youtube-item sg-card-shadow" ' + - 'style="height: ' + height + '; width: ' + width + ';"><iframe ' + - 'width="' + width + '" height="' + height + '" ' + - 'src="https://www.youtube-nocookie.com/embed/' + queryString + '" frameborder="0" ' + - 'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" ' + - 'allowfullscreen></iframe></div>'); - } - - /** - * Prepares the given url, or returns null. - * - * @param {string} url - * @return {string|null} - */ - function prepareVideoUrl(url) { - let matches = url.match(/watch\?v=(.*)&list=(.*)/); - if (!matches) { - // check if the list parameter is missing - matches = url.match(/watch\?v=([^?&]*)/); - if (!matches) { - return null; - } - } - let [, videoString] = matches, - queryParameterSeparator = '?'; - if (matches[2]) { - videoString += '?list=' + matches[2]; - queryParameterSeparator = '&'; - - } - - return videoString + queryParameterSeparator + 'autoplay=1&rel=0'; - } - - init(); -}; diff --git a/composer.json b/composer.json index 6a3ffbf..49944c6 100644 --- a/composer.json +++ b/composer.json @@ -1,27 +1,28 @@ { - "name": "sgalinski/sg-youtube", - "type": "typo3-cms-extension", - "description": "Embed YouTube Videos of a Playlist or Channel", - "homepage": "https://www.sgalinski.de", - "license": "GPL-2.0-or-later", - "version": "4.3.1", - "require": { - "typo3/cms-core": "^9.5.4 || ^10.4.0" - }, - "require-dev": { - "roave/security-advisories": "dev-master" - }, - "replace": { - "sgalinski/sg_youtube": "self.version" - }, - "extra": { - "typo3/cms": { - "extension-key": "sg_youtube" + "name": "sgalinski/sg-youtube", + "type": "typo3-cms-extension", + "description": "Embed YouTube Videos of a Playlist or Channel", + "homepage": "https://www.sgalinski.de", + "license": "GPL-2.0-or-later", + "version": "4.3.1", + "require": { + "typo3/cms-core": "^9.5.4 || ^10.4.0", + "sgalinski/project-theme-lightbox": "^1.0.0" + }, + "require-dev": { + "roave/security-advisories": "dev-master" + }, + "replace": { + "sgalinski/sg_youtube": "self.version" + }, + "extra": { + "typo3/cms": { + "extension-key": "sg_youtube" + } + }, + "autoload": { + "psr-4": { + "SGalinski\\SgYoutube\\": "Classes/" + } } - }, - "autoload": { - "psr-4": { - "SGalinski\\SgYoutube\\": "Classes/" - } - } } diff --git a/ext_emconf.php b/ext_emconf.php index d250bcb..187e7eb 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -40,6 +40,7 @@ $EM_CONF['sg_youtube'] = [ 'constraints' => [ 'depends' => [ 'typo3' => '9.5.0-10.4.99', + 'project_theme_lightbox' => '^1.0.0', ], 'conflicts' => [], 'suggests' => [], -- GitLab