]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: use mobile "tap" for the "closeOnClick" option in Reveal
authorNicolas Coden <nicolas@ncoden.fr>
Wed, 1 Aug 2018 21:14:02 +0000 (23:14 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Wed, 1 Aug 2018 21:14:37 +0000 (23:14 +0200)
BREAKING CHANGE: `foundation.utils.touch.js` is now required for `foundation.reveal.js`. If you import the Foundation Dropdown plugin manually, make sure to import the "Touch" utility as well.

js/foundation.reveal.js

index b11fba388786861d8d421927ab4099bf0103e244..acc986ba540728409c92880ffab4e0dc03f4cc01 100644 (file)
@@ -31,7 +31,8 @@ class Reveal extends Plugin {
     this.className = 'Reveal'; // ie9 back compat
     this._init();
 
-    // Triggers init is idempotent, just need to make sure it is initialized
+    // Touch and Triggers init are idempotent, just need to make sure they are initialized
+    Touch.init($);
     Triggers.init($);
 
     Keyboard.register('Reveal', {
@@ -160,7 +161,7 @@ class Reveal extends Plugin {
     });
 
     if (this.options.closeOnClick && this.options.overlay) {
-      this.$overlay.off('.zf.reveal').on('click.zf.reveal', function(e) {
+      this.$overlay.off('.zf.reveal').on('click.zf.dropdown tap.zf.dropdown', function(e) {
         if (e.target === _this.$element[0] ||
           $.contains(_this.$element[0], e.target) ||
             !$.contains(document, e.target)) {
@@ -365,7 +366,7 @@ class Reveal extends Plugin {
     this.focusableElements = Keyboard.findFocusable(this.$element);
 
     if (!this.options.overlay && this.options.closeOnClick && !this.options.fullScreen) {
-      $('body').on('click.zf.reveal', function(e) {
+      $('body').on('click.zf.dropdown tap.zf.dropdown', function(e) {
         if (e.target === _this.$element[0] ||
           $.contains(_this.$element[0], e.target) ||
             !$.contains(document, e.target)) { return; }
@@ -423,7 +424,7 @@ class Reveal extends Plugin {
     }
 
     if (!this.options.overlay && this.options.closeOnClick) {
-      $('body').off('click.zf.reveal');
+      $('body').off('click.zf.dropdown tap.zf.dropdown');
     }
 
     this.$element.off('keydown.zf.reveal');