From: Alexander Ebert Date: Sat, 29 Nov 2014 00:18:37 +0000 (+0100) Subject: Disabling zoom if image viewer is open X-Git-Tag: 2.1.0_Beta_1~122 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9c31391d2f855e2904b50404923d3d54a7947b96;p=GitHub%2FWoltLab%2FWCF.git Disabling zoom if image viewer is open --- diff --git a/wcfsetup/install/files/js/WCF.ImageViewer.js b/wcfsetup/install/files/js/WCF.ImageViewer.js index 19a9b068e9..7b5150b4c4 100644 --- a/wcfsetup/install/files/js/WCF.ImageViewer.js +++ b/wcfsetup/install/files/js/WCF.ImageViewer.js @@ -317,6 +317,7 @@ $.widget('ui.wcfImageViewer', { this._isOpen = true; WCF.System.DisableScrolling.disable(); + WCF.System.DisableZoom.disable(); // switch to fullscreen mode on smartphones if ($.browser.touch) { @@ -341,6 +342,7 @@ $.widget('ui.wcfImageViewer', { this._isOpen = true; WCF.System.DisableScrolling.disable(); + WCF.System.DisableZoom.disable(); } } @@ -371,6 +373,7 @@ $.widget('ui.wcfImageViewer', { this._isOpen = false; WCF.System.DisableScrolling.enable(); + WCF.System.DisableZoom.enable(); return true; }, @@ -1198,6 +1201,7 @@ $.widget('ui.wcfImageViewer', { this._isOpen = true; WCF.System.DisableScrolling.disable(); + WCF.System.DisableZoom.disable(); } } }); diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index ed8e801ece..b1f60721c5 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -7420,6 +7420,50 @@ WCF.System.DisableScrolling = { } }; +/** + * Disables the ability to zoom the page. + */ +WCF.System.DisableZoom = { + /** + * number of times zoom was disabled (nested calls) + * @var integer + */ + _depth: 0, + + /** + * old viewport settings in meta[name=viewport] + * @var string + */ + _oldViewportSettings: null, + + /** + * Disables zooming. + */ + disable: function () { + if (this._depth === 0) { + var $meta = $('meta[name=viewport]'); + this._oldViewportSettings = $meta.attr('content'); + $meta.attr('content', this._oldViewportSettings + ',maximum-scale=1'); + } + + this._depth++; + }, + + /** + * Enables scrolling again. + * Must be called the same number of times disable() was called to enable scrolling. + */ + enable: function () { + if (this._depth === 0) return; + + this._depth--; + + if (this._depth === 0) { + $('meta[name=viewport]').attr('content', this._oldViewportSettings); + } + } +}; + /** * Puts an element into HTML 5 fullscreen mode. */