Hide certain overlays on smartphones if editor is focused
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / 3rdParty / redactor2 / plugins / WoltLabEvent.js
index 323f0aab7f46c9060825b5fa3df3963b3dd9b35f..f2930f04a327239d307637611714cd70b783ec08 100644 (file)
@@ -1,6 +1,8 @@
 $.Redactor.prototype.WoltLabEvent = function() {
        "use strict";
        
+       var _activeInstances = 0;
+       
        return {
                init: function() {
                        this._callbacks = [];
@@ -13,6 +15,22 @@ $.Redactor.prototype.WoltLabEvent = function() {
                                        
                                }).bind(this))
                        }).bind(this));
+                       
+                       this.$editor[0].addEventListener('focus', function () {
+                               _activeInstances++;
+                               
+                               document.documentElement.classList.add('redactorActive');
+                       });
+                       this.$editor[0].addEventListener('blur', function () {
+                               _activeInstances--;
+                               
+                               // short delay to prevent flickering when switching focus between editors
+                               window.setTimeout(function () {
+                                       if (_activeInstances === 0) {
+                                               document.documentElement.classList.remove('redactorActive');
+                                       }
+                               }, 100);
+                       })
                },
                
                _setEvents: function(EventHandler) {