]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Rework media query init 10207/head
authorKevin Ball <kmball11@gmail.com>
Mon, 19 Jun 2017 18:16:51 +0000 (11:16 -0700)
committerKevin Ball <kmball11@gmail.com>
Mon, 19 Jun 2017 18:16:51 +0000 (11:16 -0700)
js/foundation.core.js
js/foundation.equalizer.js
js/foundation.interchange.js
js/foundation.offcanvas.js
js/foundation.responsiveAccordionTabs.js
js/foundation.responsiveMenu.js
js/foundation.responsiveToggle.js
js/foundation.reveal.js
js/foundation.sticky.js
js/foundation.tooltip.js
js/foundation.util.mediaQuery.js

index 6febe15c14f0a6f6de6fb035e4648b3072f1df92..939dd0479dbfd13efc41bd6d78e3cf7c12f1cb67 100644 (file)
@@ -186,12 +186,8 @@ var Foundation = {
      */
     var foundation = function(method) {
       var type = typeof method,
-          $meta = $('meta.foundation-mq'),
           $noJS = $('.no-js');
 
-      if(!$meta.length){
-        $('<meta class="foundation-mq">').appendTo(document.head);
-      }
       if($noJS.length){
         $noJS.removeClass('no-js');
       }
index 2e4a5c9e0a3dce3f8b0429cec4b0938a212b2b67..41f45b14dac655703e57524ca933064cc5e4e4fe 100644 (file)
@@ -36,9 +36,11 @@ class Equalizer extends Plugin {
     var eqId = this.$element.attr('data-equalizer') || '';
     var $watched = this.$element.find(`[data-equalizer-watch="${eqId}"]`);
 
+    MediaQuery._init();
+
     this.$watched = $watched.length ? $watched : this.$element.find('[data-equalizer-watch]');
     this.$element.attr('data-resize', (eqId || GetYoDigits(6, 'eq')));
-       this.$element.attr('data-mutate', (eqId || GetYoDigits(6, 'eq')));
+    this.$element.attr('data-mutate', (eqId || GetYoDigits(6, 'eq')));
 
     this.hasNested = this.$element.find('[data-equalizer]').length > 0;
     this.isNested = this.$element.parentsUntil(document.body, '[data-equalizer]').length > 0;
index 3013c74af5f19646f4ed33d7eebf9236c4ab9659..8db4f84bc937b822ef928fdbfbe1b02154ea7728 100644 (file)
@@ -35,6 +35,8 @@ class Interchange extends Plugin {
    * @private
    */
   _init() {
+    MediaQuery._init();
+
     var id = this.$element[0].id || Foundation.GetYoDigits(6, 'interchange');
     this.$element.attr({
       'data-resize': id,
index 6716daf2f475676fa97a99784e4999847163e2d4..924675efa49cb36351192fe922cb0988ce0d1add 100644 (file)
@@ -32,6 +32,7 @@ class OffCanvas extends Plugin {
 
     //Triggers init is idempotent, just need to make sure it is initialized
     Triggers.init($);
+    MediaQuery._init();
 
     this._init();
     this._events();
index e8e71c1fbf410c2c4ffa6d1915ad7f052cde1bd5..374c895fee3f7158118db73cecf0546c1a4aafdd 100644 (file)
@@ -57,6 +57,8 @@ class ResponsiveAccordionTabs extends Plugin{
    * @private
    */
   _init() {
+    MediaQuery._init();
+
     // The first time an Interchange plugin is initialized, this.rules is converted from a string of "classes" to an object of rules
     if (typeof this.rules === 'string') {
       let rulesTree = {};
index 4d02f81171845c5c638a886507be22142fa11b66..737a0fa77697eab0ee02cd731e3467a9593a9ae4 100644 (file)
@@ -59,6 +59,8 @@ class ResponsiveMenu extends Plugin {
    * @private
    */
   _init() {
+
+    MediaQuery._init();
     // The first time an Interchange plugin is initialized, this.rules is converted from a string of "classes" to an object of rules
     if (typeof this.rules === 'string') {
       let rulesTree = {};
index f77f54f84e39dc761bc436f482ceffa636174296..798b1dbbf9eac95a6a2649102bc631b81e295e14 100644 (file)
@@ -35,6 +35,7 @@ class ResponsiveToggle extends Plugin {
    * @private
    */
   _init() {
+    MediaQuery._init();
     var targetID = this.$element.data('responsive-toggle');
     if (!targetID) {
       console.error('Your tab bar needs an ID of a Menu as the value of data-tab-bar.');
index afaca2658a1c420d580c07c8352f9d919d45d64f..8af83dca98d7872dd5a6c281e4e73c11ae26f620 100644 (file)
@@ -41,6 +41,7 @@ class Reveal extends Plugin {
    * @private
    */
   _init() {
+    MediaQuery._init();
     this.id = this.$element.attr('id');
     this.isActive = false;
     this.cached = {mq: MediaQuery.current};
index 1217e4fa04e051eac0ae39ecb3f8f19b6299fc17..4b285815dcd2eac60370f2d3d454ee37d02b892f 100644 (file)
@@ -36,6 +36,8 @@ class Sticky extends Plugin {
    * @private
    */
   _init() {
+    MediaQuery._init();
+
     var $parent = this.$element.parent('[data-sticky-container]'),
         id = this.$element[0].id || GetYoDigits(6, 'sticky'),
         _this = this;
index 12fb8ec4afa36f9079129f42d1e24c0f755f77ba..5fa150e511e7e369685c0a305f3a746f27d975f8 100644 (file)
@@ -41,6 +41,7 @@ class Tooltip extends Positionable {
    * @private
    */
   _init() {
+    MediaQuery._init();
     var elemId = this.$element.attr('aria-describedby') || GetYoDigits(6, 'tooltip');
 
     this.options.tipText = this.options.tipText || this.$element.attr('title');
index 20c30bcc6004f9ea1ccbffe8e658fb22536fff0b..23e1eb74b8abbd86f4d33e99a0ada386b251ae66 100644 (file)
@@ -75,6 +75,11 @@ var MediaQuery = {
    */
   _init() {
     var self = this;
+    var $meta = $('meta.foundation-mq');
+    if(!$meta.length){
+      $('<meta class="foundation-mq">').appendTo(document.head);
+    }
+
     var extractedStyles = $('.foundation-mq').css('font-family');
     var namedQueries;
 
@@ -173,7 +178,7 @@ var MediaQuery = {
    * @private
    */
   _watcher() {
-    $(window).on('resize.zf.mediaquery', () => {
+    $(window).off('resize.zf.mediaquery').on('resize.zf.mediaquery', () => {
       var newSize = this._getCurrentSize(), currentSize = this.current;
 
       if (newSize !== currentSize) {