1/** 2 * Front-end Scripts. 3 * 4 * Scripts for Front-end pages. 5 * 6 * @since 1.0.0 7 * 8 * @package Fusion 9 */ 10 11//Button collapse text toggle 12jQuery(document).ready(function() { 13 var buttonCollapseToggles = jQuery('a[data-toggle="collapse"][data-label-show][data-label-hide]'); 14 buttonCollapseToggles.each(function() { 15 var button = jQuery(this); 16 if (button.children().length == 0) { 17 var target = button.attr('href'); 18 var targetObject = jQuery(target); 19 var labelShow = button.attr('data-label-show'); 20 var labelHide = button.attr('data-label-hide'); 21 targetObject.on('show.bs.collapse', function () { 22 button.text(labelHide); 23 }); 24 targetObject.on('hide.bs.collapse', function () { 25 button.text(labelShow); 26 }); 27 } 28 }); 29}); 30 31//set images 32jQuery(window).on('load.fusion', function() { 33 var size = jQuery('body').attr('data-view'); 34 ADimageSwap(size); 35}); 36 37 38/** 39 * Tabs 40 */ 41 42//set resize event on tab change 43jQuery(document).ready(function() { 44 var tabShowInterval; 45 jQuery('a[data-toggle="tab"]').on('show.bs.tab', function (e) { 46 tabShowInterval = setInterval(function(){ 47 jQuery(window).trigger('resize'); 48 },10); 49 }); 50 jQuery('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 51 setTimeout(function(){ 52 clearInterval(tabShowInterval); 53 }, 1000); 54 }); 55}); 56 57//deep linking 58jQuery(window).on('load.fusion', function() { 59 var targetID = window.location.hash 60 var targetTabTrigger = jQuery('a[data-toggle="tab"][href="'+ targetID +'"]'); 61 if (targetTabTrigger.length > 0) { 62 var offset = fsnTabsGetOffset(targetTabTrigger); 63 setTimeout(function() { 64 jQuery(window).scrollTop(offset); 65 }, 100); 66 targetTabTrigger.trigger('click'); 67 } 68}); 69 70//control tabs from WordPress menus 71jQuery(document).ready(function() { 72 jQuery('body').on('click.fusion', '.menu-item-type-custom > a', function(e) { 73 if (e.target.hash != '') { 74 var targetTabTrigger = jQuery('a[data-toggle="tab"][href="'+ e.target.hash +'"]'); 75 if (targetTabTrigger.length > 0) { 76 e.preventDefault(); 77 var offset = fsnTabsGetOffset(targetTabTrigger); 78 jQuery(window).scrollTop(offset); 79 targetTabTrigger.trigger('click'); 80 //update hash 81 if (Modernizr.history) { 82 history.replaceState(null, null, e.target.hash); 83 } 84 //collapse mobile nav menu 85 var mobileNavMenu = jQuery(e.target).closest('.navbar-collapse'); 86 if (mobileNavMenu.length > 0 && mobileNavMenu.is('.in')) { 87 mobileNavMenu.collapse('hide'); 88 } 89 } 90 } 91 }); 92}); 93 94function fsnTabsGetOffset(targetTabTrigger) { 95 if (jQuery('body').hasClass('admin-bar') && jQuery(window).width() >= 768) { 96 var offset = targetTabTrigger.offset().top - 132; 97 } else { 98 var offset = targetTabTrigger.offset().top - 100; 99 } 100 if (jQuery(window).width() >= 768 && jQuery('.locking-menu').length > 0) { 101 offset = offset - 80; 102 } 103 return offset; 104} 105 106 107/** 108* Modals 109*/ 110 111//Set focus on modal when shown 112jQuery(document).ready(function() { 113 var modals = jQuery('.modal'); 114 modals.each(function() { 115 var modal = jQuery(this); 116 modal.on('shown.bs.modal', function () { 117 jQuery(this).find('.modal-dialog .close').focus(); 118 }) 119 }); 120}); 121 122/** 123 * JavaScript Media Queries 124 */ 125 126//initialize enquire.js and necessary polyfills 127jQuery(document).ready(function() { 128 /* MediaMatch v.2.0.2 - Testing css media queries in Javascript. Authors & copyright (c) 2013: WebLinc, David Knight. */ 129 if (!Modernizr.matchmedia) { 130 window.matchMedia||(window.matchMedia=function(c){var a=c.document,w=a.documentElement,l=[],t=0,x="",h={},G=/\s*(only|not)?\s*(screen|print|[a-z\-]+)\s*(and)?\s*/i,H=/^\s*\(\s*(-[a-z]+-)?(min-|max-)?([a-z\-]+)\s*(:?\s*([0-9]+(\.[0-9]+)?|portrait|landscape)(px|em|dppx|dpcm|rem|%|in|cm|mm|ex|pt|pc|\/([0-9]+(\.[0-9]+)?))?)?\s*\)\s*$/,y=0,A=function(b){var z=-1!==b.indexOf(",")&&b.split(",")||[b],e=z.length-1,j=e,g=null,d=null,c="",a=0,l=!1,m="",f="",g=null,d=0,f=null,k="",p="",q="",n="",r="",k=!1;if(""=== 131 b)return!0;do{g=z[j-e];l=!1;if(d=g.match(G))c=d[0],a=d.index;if(!d||-1===g.substring(0,a).indexOf("(")&&(a||!d[3]&&c!==d.input))k=!1;else{f=g;l="not"===d[1];a||(m=d[2],f=g.substring(c.length));k=m===x||"all"===m||""===m;g=-1!==f.indexOf(" and ")&&f.split(" and ")||[f];d=g.length-1;if(k&&0<=d&&""!==f){do{f=g[d].match(H);if(!f||!h[f[3]]){k=!1;break}k=f[2];n=p=f[5];q=f[7];r=h[f[3]];q&&(n="px"===q?Number(p):"em"===q||"rem"===q?16*p:f[8]?(p/f[8]).toFixed(2):"dppx"===q?96*p:"dpcm"===q?0.3937*p:Number(p)); 132 k="min-"===k&&n?r>=n:"max-"===k&&n?r<=n:n?r===n:!!r;if(!k)break}while(d--)}if(k)break}}while(e--);return l?!k:k},B=function(){var b=c.innerWidth||w.clientWidth,a=c.innerHeight||w.clientHeight,e=c.screen.width,j=c.screen.height,g=c.screen.colorDepth,d=c.devicePixelRatio;h.width=b;h.height=a;h["aspect-ratio"]=(b/a).toFixed(2);h["device-width"]=e;h["device-height"]=j;h["device-aspect-ratio"]=(e/j).toFixed(2);h.color=g;h["color-index"]=Math.pow(2,g);h.orientation=a>=b?"portrait":"landscape";h.resolution= 133 d&&96*d||c.screen.deviceXDPI||96;h["device-pixel-ratio"]=d||1},C=function(){clearTimeout(y);y=setTimeout(function(){var b=null,a=t-1,e=a,j=!1;if(0<=a){B();do if(b=l[e-a])if((j=A(b.mql.media))&&!b.mql.matches||!j&&b.mql.matches)if(b.mql.matches=j,b.listeners)for(var j=0,g=b.listeners.length;j<g;j++)b.listeners[j]&&b.listeners[j].call(c,b.mql);while(a--)}},10)},D=a.getElementsByTagName("head")[0],a=a.createElement("style"),E=null,u="screen print speech projection handheld tv braille embossed tty".split(" "), 134 m=0,I=u.length,s="#mediamatchjs { position: relative; z-index: 0; }",v="",F=c.addEventListener||(v="on")&&c.attachEvent;a.type="text/css";a.id="mediamatchjs";D.appendChild(a);for(E=c.getComputedStyle&&c.getComputedStyle(a)||a.currentStyle;m<I;m++)s+="@media "+u[m]+" { #mediamatchjs { position: relative; z-index: "+m+" } }";a.styleSheet?a.styleSheet.cssText=s:a.textContent=s;
134x=u[1*E.zIndex||0];D.removeChild(a);B();F(v+"resize",C);F(v+"orientationchange",C);return function(a){var c=t,e={matches:!1, 135 media:a,addListener:function(a){l[c].listeners||(l[c].listeners=[]);a&&l[c].listeners.push(a)},removeListener:function(a){var b=l[c],d=0,e=0;if(b)for(e=b.listeners.length;d<e;d++)b.listeners[d]===a&&b.listeners.splice(d,1)}};if(""===a)return e.matches=!0,e;e.matches=A(a);t=l.push({mql:e,listeners:null});return e}}(window)); 136 } 137 fsnInitEnquireJS(); 138}); 139 140function fsnInitEnquireJS() { 141if (typeof enquire != 'function') { 142/*! 143 * enquire.js v2.1.0 - Awesome Media Queries in JavaScript 144 * Copyright (c) 2013 Nick Williams - http://wicky.nillia.ms/enquire.js 145 * License: MIT (http://www.opensource.org/licenses/mit-license.php) 146 */ 147 148(function(t,i,n){var e=i.matchMedia;"undefined"!=typeof module&&module.exports?module.exports=n(e):"function"==typeof define&&define.amd?define(function(){return i[t]=n(e)}):i[t]=n(e)})("enquire",this,function(t){"use strict";function i(t,i){var n,e=0,s=t.length;for(e;s>e&&(n=i(t[e],e),n!==!1);e++);}function n(t){return"[object Array]"===Object.prototype.toString.apply(t)}function e(t){return"function"==typeof t}function s(t){this.options=t,!t.deferSetup&&this.setup()}function o(i,n){this.query=i,this.isUnconditional=n,this.handlers=[],this.mql=t(i);var e=this;this.listener=function(t){e.mql=t,e.assess()},this.mql.addListener(this.listener)}
148function r(){if(!t)throw Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!t("only all").matches}return s.prototype={setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(t){return this.options===t||this.options.match===t}},o.prototype={addHandler:function(t){var i=new s(t);this.handlers.push(i),this.matches()&&i.on()},removeHandler:function(t){var n=this.handlers;i(n,function(i,e){return i.equals(t)?(i.destroy(),!n.splice(e,1)):void 0})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){i(this.handlers,function(t){t.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var t=this.matches()?"on":"off";i(this.handlers,function(i){i[t]()})}},r.prototype={register:function(t,s,r){var h=this.queries,u=r&&this.browserIsIncapable;return h[t]||(h[t]=new o(t,u)),e(s)&&(s={match:s}),n(s)||(s=[s]),i(s,function(i){h[t].addHandler(i)}),this},unregister:function(t,i){var n=this.queries[t];return n&&(i?n.removeHandler(i):(n.clear(),delete this.queries[t])),this}},new r}); 149 150} 151 152 //desktop version 153 enquire.register("screen and (min-width: 768px)", { 154 match : function() { 155 //desktop functions go here 156 setViewport('desktop'); 157 }, 158 unmatch : function() { 159 //mobile functions go here 160 setViewport('mobile'); 161 } 162 }); 163 164} 165 166//add body attribute hook 167function setViewport(size) { 168 jQuery('body').attr('data-view',size); 169 ADimageSwap(size); 170} 171 172//update images 173function ADimageSwap(size) { 174 //create json object 175 var $images = jQuery('.ad-dynamic-image'); 176 $images.each(function() { 177 var image = jQuery(this); 178 var imageData = image.data('image-json'); 179 switch(size) { 180 case 'mobile': 181 var imageSrc = imageData.mobile_src; 182 var imageWidth = imageData.mobile_width; 183 var imageHeight = imageData.mobile_height; 184 break; 185 case 'desktop': 186 var imageSrc = imageData.desktop_src; 187 var imageWidth = imageData.desktop_width; 188 var imageHeight = imageData.desktop_height; 189 break; 190 } 191 image.attr('src', imageSrc); 192 image.attr('width', imageWidth); 193 image.attr('height', imageHeight); 194 jQuery(window).imagesLoaded(function() { 195 jQuery('body').trigger('imagesSwapped.fsn'); 196 }); 197 }); 198}
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.