From 276c3eeefc4cc83856f733c959d927b159c678c4 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 13 Dec 2016 15:03:44 +0100 Subject: [PATCH] Restrict fullscreen mode to tablets and above It doesn't work out for smartphones: - The editor takes up the entire width / height anyway due to the small screen size - `position: fixed` is a glitch paradise, especially iOS completely snaps when used, but the effects are negligible on an iPad --- .../redactor2/plugins/WoltLabFullscreen.js | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFullscreen.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFullscreen.js index 2466e1c8df..7fe9aeaaec 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFullscreen.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFullscreen.js @@ -1,25 +1,49 @@ -$.Redactor.prototype.WoltLabCode = function() { +$.Redactor.prototype.WoltLabFullscreen = function() { "use strict"; + var _active = false; var _button; return { init: function() { - _button = this.button.add('woltlabFullscreen', ''); - this.button.addCallback(_button, this.WoltLabCode._toggle.bind(this)); + var button = this.button.add('woltlabFullscreen', ''); + this.button.addCallback(button, this.WoltLabFullscreen._toggle.bind(this)); + + _button = button[0]; + elHide(_button.parentNode); + + require(['Ui/Screen'], (function (UiScreen) { + UiScreen.on('screen-sm-up', { + match: function () { + elShow(_button.parentNode); + }, + unmatch: (function () { + elHide(_button.parentNode); + + if (_active) { + this.WoltLabFullscreen._toggle(); + } + }).bind(this), + setup: function () { + elShow(_button.parentNode); + } + }); + }).bind(this)); }, _toggle: function () { - _button[0].children[0].classList.toggle('fa-compress'); - _button[0].children[0].classList.toggle('fa-expand'); + _button.children[0].classList.toggle('fa-compress'); + _button.children[0].classList.toggle('fa-expand'); if (this.core.box()[0].classList.toggle('redactorBoxFullscreen')) { WCF.System.DisableScrolling.disable(); this.core.editor()[0].style.setProperty('height', 'calc(100% - ' + ~~this.core.toolbar()[0].clientHeight + 'px)', ''); + _active = true; } else { WCF.System.DisableScrolling.enable(); this.core.editor()[0].style.removeProperty('height'); + _active = false; } } }; -- 2.20.1