]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Update and re-add missing triggers dependency
authorKevin Ball <kmball11@gmail.com>
Wed, 31 May 2017 21:08:18 +0000 (14:08 -0700)
committerKevin Ball <kmball11@gmail.com>
Wed, 31 May 2017 21:08:18 +0000 (14:08 -0700)
js/entries/foundation.js
js/entries/plugins/foundation.util.triggers.js
js/foundation.dropdown.js
js/foundation.offcanvas.js
js/foundation.slider.js
js/foundation.smoothScroll.js
js/foundation.sticky.js
js/foundation.toggler.js
js/foundation.tooltip.js
js/foundation.util.triggers.js

index d6260115dce6cae340ad1d9a11e80aafb2af533b..71c6622241169df36658de5a4cf55625a8deb07c 100644 (file)
@@ -35,7 +35,7 @@ import { Touch } from '../foundation.util.touch';
 Touch.init($);
 
 import { Triggers } from '../foundation.util.triggers';
-Triggers.init(Foundation, $);
+Triggers.init($, Foundation);
 
 import { Abide } from '../foundation.abide';
 Foundation.plugin(Abide, 'Abide');
index b2f641f2d8f92dc52c6ee730122a47ddd5b661ca..30689f4b0d5e2cd96cec7effac27acebb52fbad8 100644 (file)
@@ -2,4 +2,4 @@ import { Foundation } from './foundation.core';
 import $ from 'jquery';
 
 import { Triggers } from '../../foundation.util.triggers';
-Triggers.init(Foundation, $);
+Triggers.init($, Foundation);
index b3b6e18e9b70a77824cd807a064672b5590bac82..08ea429eca0f25ff5ca394225de3a9b632f52951 100644 (file)
@@ -6,8 +6,7 @@ import { Box } from './foundation.util.box';
 import { GetYoDigits } from './foundation.util.core';
 import { Plugin } from './foundation.plugin';
 
-  // import "foundation.util.triggers.js";
-  // TODO: Figure out what a triggers import "means", since triggers are always accessed indirectly.
+import { Triggers } from './foundation.util.triggers';
 
 
 /**
@@ -29,6 +28,10 @@ class Dropdown extends Plugin {
   _setup(element, options) {
     this.$element = element;
     this.options = $.extend({}, Dropdown.defaults, this.$element.data(), options);
+
+    // Triggers init is idempotent, just need to make sure it is initialized
+    Triggers.init($);
+
     this._init();
 
     Keyboard.register('Dropdown', {
index ba8773daa548d90469d6c0244f0e16418e64a697..6716daf2f475676fa97a99784e4999847163e2d4 100644 (file)
@@ -6,8 +6,7 @@ import { MediaQuery } from './foundation.util.mediaQuery';
 import { transitionend } from './foundation.util.core';
 import { Plugin } from './foundation.plugin';
 
-  // import "foundation.util.triggers.js";
-  // TODO: Figure out what triggers import should actually do, given how indirect their use is
+import { Triggers } from './foundation.util.triggers';
 
 /**
  * OffCanvas module.
@@ -31,6 +30,9 @@ class OffCanvas extends Plugin {
     this.$lastTrigger = $();
     this.$triggers = $();
 
+    //Triggers init is idempotent, just need to make sure it is initialized
+    Triggers.init($);
+
     this._init();
     this._events();
 
index d80ef018179fdce82bef7c1a08c2f2d43d553c57..f57d467784a2274349530a225d786f8ea412b10d 100644 (file)
@@ -8,6 +8,8 @@ import { GetYoDigits, rtl as Rtl } from './foundation.util.core';
 import { Plugin } from './foundation.plugin';
 
 import { Touch } from './foundation.util.touch';
+
+import { Triggers } from './foundation.util.triggers';
 /**
  * Slider module.
  * @module foundation.slider
@@ -28,7 +30,10 @@ class Slider extends Plugin {
     this.$element = element;
     this.options = $.extend({}, Slider.defaults, this.$element.data(), options);
 
-    Touch.init($); // Touch init is idempotent, we just need to make sure it's initialied.
+  // Touch and Triggers inits are idempotent, we just need to make sure it's initialied.
+    Touch.init($);
+    Triggers.init($);
+
     this._init();
 
     Keyboard.register('Slider', {
index b81e3d30188ff74408a717cd04cb52d9b1cc6114..77ad38a6b626d09d0bf068572d9fa5eeea414316 100644 (file)
@@ -43,15 +43,15 @@ class SmoothScroll extends Plugin {
             if(!$(this).is('a[href^="#"]'))  {
                 return false;
             }
-            
+
             var arrival = this.getAttribute('href');
-            
+
             _this._inTransition = true;
 
             SmoothScroll.scrollToLoc(arrival, _this.options, function() {
                 _this._inTransition = false;
             });
-            
+
             e.preventDefault();
         };
 
index 52fafee1c736d675c8a71428699a628a58be379d..1217e4fa04e051eac0ae39ecb3f8f19b6299fc17 100644 (file)
@@ -4,6 +4,8 @@ import $ from 'jquery';
 import { GetYoDigits } from './foundation.util.core';
 import { MediaQuery } from './foundation.util.mediaQuery';
 import { Plugin } from './foundation.plugin';
+import { Triggers } from './foundation.util.triggers';
+
 /**
  * Sticky module.
  * @module foundation.sticky
@@ -22,6 +24,9 @@ class Sticky extends Plugin {
     this.$element = element;
     this.options = $.extend({}, Sticky.defaults, this.$element.data(), options);
 
+    // Triggers init is idempotent, just need to make sure it is initialized
+    Triggers.init($);
+
     this._init();
   }
 
index b2ce3606201d6125c3c0d7f89f7801703852a9fd..f0ea76ae84049ca4bea77893e653778d42605bbe 100644 (file)
@@ -3,8 +3,7 @@
 import $ from 'jquery';
 import { Motion } from './foundation.util.motion';
 import { Plugin } from './foundation.plugin';
-
-  // import "foundation.util.triggersjs";
+import { Triggers } from './foundation.util.triggers';
 
 /**
  * Toggler module.
@@ -26,6 +25,9 @@ class Toggler extends Plugin {
     this.options = $.extend({}, Toggler.defaults, element.data(), options);
     this.className = '';
 
+    // Triggers init is idempotent, just need to make sure it is initialized
+    Triggers.init($);
+
     this._init();
     this._events();
   }
index 3cb6d6d43473f01041c7525436e3855236d0062e..a24c79d431ea442f7a35448fbb05587122d11b32 100644 (file)
@@ -5,10 +5,9 @@ import $ from 'jquery';
 import { Box } from './foundation.util.box';
 import { GetYoDigits } from './foundation.util.core';
 import { MediaQuery } from './foundation.util.mediaQuery';
+import { Triggers } from './foundation.util.triggers';
 import { Plugin } from './foundation.plugin';
 
-  // import "foundation.util.triggers";
-
 /**
  * Tooltip module.
  * @module foundation.tooltip
@@ -31,6 +30,10 @@ class Tooltip extends Plugin {
 
     this.isActive = false;
     this.isClick = false;
+
+    // Triggers init is idempotent, just need to make sure it is initialized
+    Triggers.init($);
+
     this._init();
   }
 
index 6950aca418ea77fa4a186d529c994f6cc0fb8781..8ce7dcb766373d697f108b61e0d18b89e819e736 100644 (file)
@@ -240,7 +240,7 @@ Triggers.Initializers.addGlobalListeners = function() {
 }
 
 
-Triggers.init = function(Foundation, $) {
+Triggers.init = function($, Foundation) {
   if (typeof($.triggersInitialized) === 'undefined') {
     let $document = $(document);
 
@@ -253,11 +253,15 @@ Triggers.init = function(Foundation, $) {
         Triggers.Initializers.addGlobalListeners();
       });
     }
-    Foundation.Triggers = Triggers;
 
+
+    $.triggersInitialized = true;
+  }
+
+  if(Foundation) {
+    Foundation.Triggers = Triggers;
     // Legacy included to be backwards compatible for now.
     Foundation.IHearYou = Triggers.Initializers.addGlobalListeners
-    $.triggersInitialized = true;
   }
 }