From 15d6b45a158e230a5dcd2b1c4d4515bfa10f4942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Mar 2021 19:50:46 -0300 Subject: [PATCH] Remove jQuery Fullscreen plugin dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uses the Fullscreen API instead. Signed-off-by: MaurĂ­cio Meneghini Fauth --- js/src/designer/move.js | 10 +- js/vendor/jquery/jquery.fullscreen.js | 191 ------------------ .../Database/DesignerController.php | 1 - package.json | 1 - scripts/sync-js-vendor-files.sh | 2 - yarn.lock | 9 +- 6 files changed, 7 insertions(+), 207 deletions(-) delete mode 100644 js/vendor/jquery/jquery.fullscreen.js diff --git a/js/src/designer/move.js b/js/src/designer/move.js index ea0f4c4fdc..096d2b5f7c 100644 --- a/js/src/designer/move.js +++ b/js/src/designer/move.js @@ -26,7 +26,7 @@ AJAX.registerOnload('designer/move.js', function () { $content.css({ 'margin-left': '3px' }); $(document).on('fullscreenchange', function () { - if (!$.fn.fullScreen() || !$content.fullScreen()) { + if (! document.fullscreenElement) { $content.removeClass('content_fullscreen') .css({ 'width': 'auto', 'height': 'auto' }); $('#osn_tab').css({ 'width': 'auto', 'height': 'auto' }); @@ -531,7 +531,9 @@ DesignerMove.toggleFullscreen = function () { var $img = $('#toggleFullscreen').find('img'); var $span = $img.siblings('span'); var $content = $('#page_content'); - if (! $content.fullScreen()) { + const pageContent = document.getElementById('page_content'); + + if (! document.fullscreenElement) { $img.attr('src', $img.data('exit')) .attr('title', $span.data('exit')); $span.text($span.data('exit')); @@ -541,7 +543,7 @@ DesignerMove.toggleFullscreen = function () { $('#osn_tab').css({ 'width': screen.width + 'px', 'height': screen.height }); valueSent = 'on'; - $content.fullScreen(true); + pageContent.requestFullscreen(); } else { $img.attr('src', $img.data('enter')) .attr('title', $span.data('enter')); @@ -549,7 +551,7 @@ DesignerMove.toggleFullscreen = function () { $content.removeClass('content_fullscreen') .css({ 'width': 'auto', 'height': 'auto' }); $('#osn_tab').css({ 'width': 'auto', 'height': 'auto' }); - $content.fullScreen(false); + document.exitFullscreen(); valueSent = 'off'; } DesignerMove.saveValueInConfig('full_screen', valueSent); diff --git a/js/vendor/jquery/jquery.fullscreen.js b/js/vendor/jquery/jquery.fullscreen.js deleted file mode 100644 index 088c74c483..0000000000 --- a/js/vendor/jquery/jquery.fullscreen.js +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @preserve jquery.fullscreen 1.1.5 - * https://github.com/code-lts/jquery-fullscreen-plugin - * Copyright (C) 2012-2013 Klaus Reimer - * Licensed under the MIT license - * (See http://www.opensource.org/licenses/mit-license) - */ - -(function(jQuery) { - -/** - * Sets or gets the fullscreen state. - * - * @param {boolean=} state - * True to enable fullscreen mode, false to disable it. If not - * specified then the current fullscreen state is returned. - * @return {boolean|Element|jQuery|null} - * When querying the fullscreen state then the current fullscreen - * element (or true if browser doesn't support it) is returned - * when browser is currently in full screen mode. False is returned - * if browser is not in full screen mode. Null is returned if - * browser doesn't support fullscreen mode at all. When setting - * the fullscreen state then the current jQuery selection is - * returned for chaining. - * @this {jQuery} - */ -function fullScreen(state) -{ - var e, func, doc; - - // Do nothing when nothing was selected - if (!this.length) return this; - - // We only use the first selected element because it doesn't make sense - // to fullscreen multiple elements. - e = (/** @type {Element} */ this[0]); - - // Find the real element and the document (Depends on whether the - // document itself or a HTML element was selected) - if (e.ownerDocument) - { - doc = e.ownerDocument; - } - else - { - doc = e; - e = doc.documentElement; - } - - // When no state was specified then return the current state. - if (state == null) - { - // When fullscreen mode is not supported then return null - if (!((/** @type {?Function} */ doc["exitFullscreen"]) - || (/** @type {?Function} */ doc["webkitExitFullscreen"]) - || (/** @type {?Function} */ doc["webkitCancelFullScreen"]) - || (/** @type {?Function} */ doc["msExitFullscreen"]) - || (/** @type {?Function} */ doc["mozCancelFullScreen"]))) - { - return null; - } - - // Check fullscreen state - state = fullScreenState(doc); - if (!state) return state; - - // Return current fullscreen element or "true" if browser doesn't - // support this - return (/** @type {?Element} */ doc["fullscreenElement"]) - || (/** @type {?Element} */ doc["webkitFullscreenElement"]) - || (/** @type {?Element} */ doc["webkitCurrentFullScreenElement"]) - || (/** @type {?Element} */ doc["msFullscreenElement"]) - || (/** @type {?Element} */ doc["mozFullScreenElement"]) - || state; - } - - // When state was specified then enter or exit fullscreen mode. - if (state) - { - // Enter fullscreen - func = (/** @type {?Function} */ e["requestFullscreen"]) - || (/** @type {?Function} */ e["webkitRequestFullscreen"]) - || (/** @type {?Function} */ e["webkitRequestFullScreen"]) - || (/** @type {?Function} */ e["msRequestFullscreen"]) - || (/** @type {?Function} */ e["mozRequestFullScreen"]); - if (func) - { - func.call(e); - } - return this; - } - else - { - // Exit fullscreen - func = (/** @type {?Function} */ doc["exitFullscreen"]) - || (/** @type {?Function} */ doc["webkitExitFullscreen"]) - || (/** @type {?Function} */ doc["webkitCancelFullScreen"]) - || (/** @type {?Function} */ doc["msExitFullscreen"]) - || (/** @type {?Function} */ doc["mozCancelFullScreen"]); - if (func && fullScreenState(doc)) func.call(doc); - return this; - } -} - -/** - * Check fullscreen state - * - * @param {Document} doc The content document - * @return {Boolean} - */ -function fullScreenState(doc) { - return !!(doc["fullscreenElement"] || doc["msFullscreenElement"] || doc["webkitIsFullScreen"] || doc["mozFullScreen"]); -} - -/** - * Toggles the fullscreen mode. - * - * @return {!jQuery} - * The jQuery selection for chaining. - * @this {jQuery} - */ -function toggleFullScreen() -{ - return (/** @type {!jQuery} */ fullScreen.call(this, - !fullScreen.call(this))); -} - -/** - * Handles the browser-specific fullscreenchange event and triggers - * a jquery event for it. - * - * @param {?Event} event - * The fullscreenchange event. - */ -function fullScreenChangeHandler(event) -{ - jQuery(document).trigger(new jQuery.Event("fullscreenchange")); -} - -/** - * Handles the browser-specific fullscreenerror event and triggers - * a jquery event for it. - * - * @param {?Event} event - * The fullscreenerror event. - */ -function fullScreenErrorHandler(event) -{ - jQuery(document).trigger(new jQuery.Event("fullscreenerror")); -} - -/** - * Installs the fullscreenchange event handler. - */ -function installFullScreenHandlers() -{ - var e, change, error; - - // Determine event name - e = document; - if (e["webkitCancelFullScreen"]) - { - change = "webkitfullscreenchange"; - error = "webkitfullscreenerror"; - } - else if (e["msExitFullscreen"]) - { - change = "MSFullscreenChange"; - error = "MSFullscreenError"; - } - else if (e["mozCancelFullScreen"]) - { - change = "mozfullscreenchange"; - error = "mozfullscreenerror"; - } - else - { - change = "fullscreenchange"; - error = "fullscreenerror"; - } - - // Install the event handlers - jQuery(document).bind(change, fullScreenChangeHandler); - jQuery(document).bind(error, fullScreenErrorHandler); -} - -jQuery.fn["fullScreen"] = fullScreen; -jQuery.fn["toggleFullScreen"] = toggleFullScreen; -installFullScreenHandlers(); - -})(jQuery); diff --git a/libraries/classes/Controllers/Database/DesignerController.php b/libraries/classes/Controllers/Database/DesignerController.php index 7fb5b97b5e..fcabb0c67a 100644 --- a/libraries/classes/Controllers/Database/DesignerController.php +++ b/libraries/classes/Controllers/Database/DesignerController.php @@ -218,7 +218,6 @@ class DesignerController extends AbstractController $header->setBodyId('designer_body'); $this->addScriptFiles([ - 'vendor/jquery/jquery.fullscreen.js', 'designer/database.js', 'designer/objects.js', 'designer/page.js', diff --git a/package.json b/package.json index 9ec3530b7a..b76994c304 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "codemirror": "5.59.2", "jquery": "3.5.1", "jquery-debounce-throttle": "^1.0.6-rc.0", - "jquery-fullscreen-plugin": "^1.1.5", "jquery-migrate": "3.3.2", "jquery-mousewheel": "3.1.13", "jquery-ui-dist": "1.12.1", diff --git a/scripts/sync-js-vendor-files.sh b/scripts/sync-js-vendor-files.sh index aaa68c6bdf..b87c103f6d 100755 --- a/scripts/sync-js-vendor-files.sh +++ b/scripts/sync-js-vendor-files.sh @@ -87,8 +87,6 @@ echo 'Updating jquery-uitablefilter' cp ./node_modules/jquery-uitablefilter/jquery.uitablefilter.js js/vendor/jquery/jquery.uitablefilter.js echo 'Updating jquery-tablesorter' cp ./node_modules/tablesorter/dist/js/jquery.tablesorter.js ./js/vendor/jquery/jquery.tablesorter.js -echo 'Updating jquery-fullscreen-plugin' -cp ./node_modules/jquery-fullscreen-plugin/jquery.fullscreen.js ./js/vendor/jquery/jquery.fullscreen.js echo 'Updating jquery-debounce' cp ./node_modules/jquery-debounce-throttle/index.js ./js/vendor/jquery/jquery.debounce-1.0.6.js echo 'Updating jquery-Timepicker-Addon' diff --git a/yarn.lock b/yarn.lock index f6b39b371c..8f4e236944 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4204,13 +4204,6 @@ jquery-debounce-throttle@^1.0.6-rc.0: dependencies: jquery ">=1.7" -jquery-fullscreen-plugin@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/jquery-fullscreen-plugin/-/jquery-fullscreen-plugin-1.1.5.tgz#4369394e78646d26908148df673056b09433044d" - integrity sha512-/kGQZmXlIRIgS6sHmFwHqYDSH46NvksuUGDN3o/o8z+IED23JFHj8rRv53Ee1zsN04SMnb3jQKyDS0RvXN52Xg== - dependencies: - jquery ">=1.5" - jquery-migrate@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/jquery-migrate/-/jquery-migrate-3.3.2.tgz#7829ee24de3054d0d2f42dd093390d8a7b7af01a" @@ -4251,7 +4244,7 @@ jquery@3.5.1: resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5" integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg== -jquery@>=1.2.6, jquery@>=1.5, jquery@>=1.7: +jquery@>=1.2.6, jquery@>=1.7: version "3.5.0" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.0.tgz#9980b97d9e4194611c36530e7dc46a58d7340fc9" integrity sha512-Xb7SVYMvygPxbFMpTFQiHh1J7HClEaThguL15N/Gg37Lri/qKyhRGZYzHRyLH8Stq3Aow0LsHO2O2ci86fCrNQ==