]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11041 from DanielRuf/fix/reveal-destroy-remove-open-classes-10626...
authorDaniel Ruf <daniel@daniel-ruf.de>
Sat, 16 Jun 2018 07:27:57 +0000 (09:27 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Sat, 16 Jun 2018 07:27:57 +0000 (09:27 +0200)
21976813a fix: remove the open classes if no visible reveal exists after destroying one
c3f0e101e fix: properly call removeRevealOpenClasses, add comments, remove a few empty lines
74006f466 fix: use right reference to the local context
7f30ef811 fix: make removeRevealOpenClasses and addRevealOpenClasses available for the whole component

Co-Authored-By: Daniel Ruf <daniel.ruf@ueberbit.de>
Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
js/foundation.reveal.js

index 50f4d69eee724c9d87f76a9ab2a69a06e7c7800e..f12966f60202dbdee90e7d10e958635914a95a7b 100644 (file)
@@ -273,11 +273,6 @@ class Reveal extends Plugin {
 
     var _this = this;
 
-    function addRevealOpenClasses() {
-
-      $('html').addClass('is-reveal-open');
-    }
-
     // Motion UI method of reveal
     if (this.options.animationIn) {
       function afterAnimation(){
@@ -287,7 +282,7 @@ class Reveal extends Plugin {
             'tabindex': -1
           })
           .focus();
-        addRevealOpenClasses();
+        _this.addRevealOpenClasses();
         Keyboard.trapFocus(_this.$element);
       }
       if (this.options.overlay) {
@@ -317,7 +312,7 @@ class Reveal extends Plugin {
       .focus();
     Keyboard.trapFocus(this.$element);
 
-    addRevealOpenClasses();
+    this._addRevealOpenClasses();
 
     this._extraHandlers();
 
@@ -328,6 +323,14 @@ class Reveal extends Plugin {
     this.$element.trigger('open.zf.reveal');
   }
 
+  _addRevealOpenClasses() {
+    $('html').addClass('is-reveal-open');
+  }
+
+  _removeRevealOpenClasses() {
+    $('html').removeClass('is-reveal-open');
+  }
+
   /**
    * Adds extra event handlers for the body and window if necessary.
    * @private
@@ -409,7 +412,7 @@ class Reveal extends Plugin {
       var scrollTop = parseInt($("html").css("top"));
 
       if ($('.reveal:visible').length  === 0) {
-        $('html').removeClass('is-reveal-open');
+        _this._removeRevealOpenClasses(); // also remove .is-reveal-open from the html element when there is no opened reveal
       }
 
       Keyboard.releaseFocus(_this.$element);
@@ -469,6 +472,10 @@ class Reveal extends Plugin {
     this.$element.hide().off();
     this.$anchor.off('.zf');
     $(window).off(`.zf.reveal:${this.id}`);
+
+    if ($('.reveal:visible').length  === 0) {
+      this._removeRevealOpenClasses(); // also remove .is-reveal-open from the html element when there is no opened reveal
+    }
   };
 }