1!function(Foundation, $) { 2 'use strict'; 3 // Elements with [data-open] will reveal a plugin that supports it when clicked. 4 $(document).on('click.zf.trigger', '[data-open]', function() { 5 var id = $(this).data('open'); 6 $('#' + id).triggerHandler('open.zf.trigger', [$(this)]); 7 }); 8 9 // Elements with [data-close] will close a plugin that supports it when clicked. 10 // If used without a value on [data-close], the event will bubble, allowing it to close a parent component. 11 $(document).on('click.zf.trigger', '[data-close]', function() { 12 var id = $(this).data('close'); 13 if (id) { 14 $('#' + id).triggerHandler('close.zf.trigger', [$(this)]); 15 } 16 else { 17 $(this).trigger('close.zf.trigger'); 18 } 19 }); 20 21 // Elements with [data-toggle] will toggle a plugin that supports it when clicked. 22 $(document).on('click.zf.trigger', '[data-toggle]', function() { 23 var id = $(this).data('toggle'); 24 $('#' + id).triggerHandler('toggle.zf.trigger', [$(this)]); 25 }); 26 27 // Elements with [data-closable] will respond to close.zf.trigger events. 28 $(document).on('close.zf.trigger', '[data-closable]', function() { 29 var animation = $(this).data('closable') || 'fade-out'; 30 if(Foundation.Motion){ 31 Foundation.Motion.animateOut($(this), animation, function() { 32 $(this).trigger('closed.zf'); 33 }); 34 }else{ 35 $(this).fadeOut().trigger('closed.zf'); 36 } 37 }); 38 39 var MutationObserver = (function () { 40 var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']; 41 for (var i=0; i < prefixes.length; i++) { 42 if (prefixes[i] + 'MutationObserver' in window) { 43 return window[prefixes[i] + 'MutationObserver']; 44 } 45 } 46 return false; 47 }()); 48 49 50 var checkListeners = function(){ 51 eventsListener(); 52 resizeListener(); 53 scrollListener(); 54 closemeListener(); 55 }; 56 /** 57 * Fires once after all other scripts have loaded 58 * @function 59 * @private 60 */ 61 $(window).load(function(){ 62 checkListeners(); 63 }); 64 65 //******** only fires this function once on load, if there's something to watch ******** 66 var closemeListener = function(pluginName){ 67 var yetiBoxes = $('[data-yeti-box]'), 68 plugNames = ['dropdown', 'tooltip', 'reveal']; 69 70 if(pluginName){ 71 if(typeof pluginName === 'string'){ 72 plugNames.push(pluginName); 73 }else if(typeof pluginName === 'object' && typeof pluginName[0] === 'string'){ 74 plugNames.concat(pluginName); 75 }else{ 76 console.error('Plugin names must be strings'); 77 } 78 }
79 if(yetiBoxes.length){ 80 var listeners = plugNames.map(function(name){ 81 return 'closeme.zf.' + name; 82 }).join(' '); 83 84 $(window).off(listeners).on(listeners, function(e, pluginId){ 85 var plugin = e.namespace.split('.')[0]; 86 var plugins = $('[data-' + plugin + ']').not('[data-yeti-box="' + pluginId + '"]'); 87 88 plugins.each(function(){ 89 var _this = $(this); 90 91 _this.triggerHandler('close.zf.trigger', [_this]); 92 }); 93 }); 94 } 95 }; 96 var resizeListener = function(debounce){ 97 var timer, 98 $nodes = $('[data-resize]'); 99 if($nodes.length){ 100 $(window).off('resize.zf.trigger') 101 .on('resize.zf.trigger', function(e) { 102 if (timer) { clearTimeout(timer); } 103 104 timer = setTimeout(function(){ 105 106 if(!MutationObserver){//fallback for IE 9 107 $nodes.each(function(){ 108 $(this).triggerHandler('resizeme.zf.trigger'); 109 }); 110 } 111 //trigger all listening elements and signal a resize event 112 $nodes.attr('data-events', "resize"); 113 }, debounce || 10);//default time to emit resize event 114 }); 115 } 116 }; 117 var scrollListener = function(debounce){ 118 var timer, 119 $nodes = $('[data-scroll]'); 120 if($nodes.length){ 121 $(window).off('scroll.zf.trigger') 122 .on('scroll.zf.trigger', function(e){ 123 if(timer){ clearTimeout(timer); } 124 125 timer = setTimeout(function(){ 126 127 if(!MutationObserver){//fallback for IE 9 128 $nodes.each(function(){ 129 $(this).triggerHandler('scrollme.zf.trigger'); 130 }); 131 } 132 //trigger all listening elements and signal a scroll event 133 $nodes.attr('data-events', "scroll"); 134 }, debounce || 10);//default time to emit scroll event 135 }); 136 } 137 }; 138 // function domMutationObserver(debounce) { 139 // // !!! This is coming soon and needs more work; not active !!! // 140 // var timer, 141 // nodes = document.querySelectorAll('[data-mutate]'); 142 // // 143 // if (nodes.length) { 144 // // var MutationObserver = (function () { 145 // // var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']; 146 // // for (var i=0; i < prefixes.length; i++) { 147 // // if (prefixes[i] + 'MutationObserver' in window) { 148 // // return window[prefixes[i] + 'MutationObserver']; 149 // // } 150 // // } 151 // // return false; 152 // // }()); 153 // 154 // 155 // //for the body, we need to listen for all changes effecting the style and class attributes 156 // var bodyObserver = new MutationObserver(bodyMutation); 157 // bodyObserver.observe(document.body, { attributes: true, childList: true, characterData: false, subtree:true, attributeFilter:["style", "class"]}); 158 // 159 // 160 // //body callback 161 // function bodyMutation(mutate) { 162 // //trigger all listening elements and signal a mutation event 163 // if (timer) { clearTimeout(timer); } 164 // 165 // timer = setTimeout(function() { 166 // bodyObserver.disconnect(); 167 // $('[data-mutate]').attr('data-events',"mutate"); 168 // }, debounce || 150); 169 // } 170 // } 171 // } 172 var eventsListener = function() { 173 if(!MutationObserver){ return false; } 174 var nodes = document.querySelectorAll('[data-resize], [data-scroll], [data-mutate]'); 175 176 //element callback 177 var listeningElementsMutation = function(mutationRecordsList) { 178 var $target = $(mutationRecordsList[0].target); 179 //trigger the event handler for the element depending on type 180 switch ($target.attr("data-events")) { 181 182 case "resize" : 183 $target.triggerHandler('resizeme.zf.trigger', [$target]); 184 break; 185 186 case "scroll" : 187 $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]); 188 break; 189 190 // case "mutate" : 191 // console.log('mutate', $target); 192 // $target.triggerHandler('mutate.zf.trigger'); 193 // 194 // //make sure we don't get stuck in an infinite loop from sloppy codeing 195 // if ($target.index('[data-mutate]') == $("[data-mutate]").length-1) { 196 // domMutationObserver(); 197 // } 198 // break; 199 200 default : 201 return false;
202 //nothing 203 } 204 } 205 206 if(nodes.length){ 207 //for each element that needs to listen for resizing, scrolling, (or coming soon mutation) add a single observer 208 for (var i = 0; i <= nodes.length-1; i++) { 209 var elementObserver = new MutationObserver(listeningElementsMutation); 210 elementObserver.observe(nodes[i], { attributes: true, childList: false, characterData: false, subtree:false, attributeFilter:["data-events"]}); 211 } 212 } 213 }; 214 // ------------------------------------ 215 216 // [PH] 217 // Foundation.CheckWatchers = checkWatchers; 218 Foundation.IHearYou = checkListeners; 219 // Foundation.ISeeYou = scrollListener; 220 // Foundation.IFeelYou = closemeListener; 221 222}(window.Foundation, window.jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.