1 line
5.9 KiB
JavaScript
1 line
5.9 KiB
JavaScript
!function(b,p,v,h){b.site=b.fn.site=function(e){var a,i=(new Date).getTime(),t=[],n=e,o="string"==typeof n,c=[].slice.call(arguments,1),l=b.isPlainObject(e)?b.extend(!0,{},b.site.settings,e):b.extend({},b.site.settings),s=l.namespace,u=l.error,r="module-"+s,m=b(v),d=this,g=m.data(r),f={initialize:function(){f.instantiate()},instantiate:function(){f.verbose("Storing instance of site",f),g=f,m.data(r,f)},normalize:function(){f.fix.console(),f.fix.requestAnimationFrame()},fix:{console:function(){f.debug("Normalizing window.console"),console!==h&&console.log!==h||(f.verbose("Console not available, normalizing events"),f.disable.console()),void 0!==console.group&&void 0!==console.groupEnd&&void 0!==console.groupCollapsed||(f.verbose("Console group not available, normalizing events"),p.console.group=function(){},p.console.groupEnd=function(){},p.console.groupCollapsed=function(){}),void 0===console.markTimeline&&(f.verbose("Mark timeline not available, normalizing events"),p.console.markTimeline=function(){})},consoleClear:function(){f.debug("Disabling programmatic console clearing"),p.console.clear=function(){}},requestAnimationFrame:function(){f.debug("Normalizing requestAnimationFrame"),p.requestAnimationFrame===h&&(f.debug("RequestAnimationFrame not available, normalizing event"),p.requestAnimationFrame=p.requestAnimationFrame||p.mozRequestAnimationFrame||p.webkitRequestAnimationFrame||p.msRequestAnimationFrame||function(e){setTimeout(e,0)})}},moduleExists:function(e){return b.fn[e]!==h&&b.fn[e].settings!==h},enabled:{modules:function(e){var o=[];return e=e||l.modules,b.each(e,function(e,n){f.moduleExists(n)&&o.push(n)}),o}},disabled:{modules:function(e){var o=[];return e=e||l.modules,b.each(e,function(e,n){f.moduleExists(n)||o.push(n)}),o}},change:{setting:function(t,s,e,r){e="string"==typeof e?"all"===e?l.modules:[e]:e||l.modules,r=r===h||r,b.each(e,function(e,n){var o,i=!f.moduleExists(n)||(b.fn[n].settings.namespace||!1);f.moduleExists(n)&&(f.verbose("Changing default setting",t,s,n),b.fn[n].settings[t]=s,r&&i&&0<(o=b(":data(module-"+i+")")).length&&(f.verbose("Modifying existing settings",o),o[n]("setting",t,s)))})},settings:function(i,e,t){e="string"==typeof e?[e]:e||l.modules,t=t===h||t,b.each(e,function(e,n){var o;f.moduleExists(n)&&(f.verbose("Changing default setting",i,n),b.extend(!0,b.fn[n].settings,i),t&&s&&0<(o=b(":data(module-"+s+")")).length&&(f.verbose("Modifying existing settings",o),o[n]("setting",i)))})}},enable:{console:function(){f.console(!0)},debug:function(e,n){e=e||l.modules,f.debug("Enabling debug for modules",e),f.change.setting("debug",!0,e,n)},verbose:function(e,n){e=e||l.modules,f.debug("Enabling verbose debug for modules",e),f.change.setting("verbose",!0,e,n)}},disable:{console:function(){f.console(!1)},debug:function(e,n){e=e||l.modules,f.debug("Disabling debug for modules",e),f.change.setting("debug",!1,e,n)},verbose:function(e,n){e=e||l.modules,f.debug("Disabling verbose debug for modules",e),f.change.setting("verbose",!1,e,n)}},console:function(e){if(e){if(g.cache.console===h)return void f.error(u.console);f.debug("Restoring console function"),p.console=g.cache.console}else f.debug("Disabling console function"),g.cache.console=p.console,p.console={clear:function(){},error:function(){},group:function(){},groupCollapsed:function(){},groupEnd:function(){},info:function(){},log:function(){},markTimeline:function(){},warn:function(){}}},destroy:function(){f.verbose("Destroying previous site for",m),m.removeData(r)},cache:{},setting:function(e,n){if(b.isPlainObject(e))b.extend(!0,l,e);else{if(n===h)return l[e];l[e]=n}},internal:function(e,n){if(b.isPlainObject(e))b.extend(!0,f,e);else{if(n===h)return f[e];f[e]=n}},debug:function(){l.debug&&(l.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,l.name+":"),f.debug.apply(console,arguments)))},verbose:function(){l.verbose&&l.debug&&(l.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,l.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,l.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var n,o;l.performance&&(o=(n=(new Date).getTime())-(i||n),i=n,t.push({Element:d,Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":o})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,500)},display:function(){var e=l.name+":",o=0;i=!1,clearTimeout(f.performance.timer),b.each(t,function(e,n){o+=n["Execution Time"]}),e+=" "+o+"ms",(console.group!==h||console.table!==h)&&0<t.length&&(console.groupCollapsed(e),console.table?console.table(t):b.each(t,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),t=[]}},invoke:function(i,e,n){var t,s,o,r=g;return e=e||c,n=d||n,"string"==typeof i&&r!==h&&(i=i.split(/[\. ]/),t=i.length-1,b.each(i,function(e,n){var o=e!=t?n+i[e+1].charAt(0).toUpperCase()+i[e+1].slice(1):i;if(b.isPlainObject(r[o])&&e!=t)r=r[o];else{if(r[o]!==h)return s=r[o],!1;if(!b.isPlainObject(r[n])||e==t)return r[n]!==h?s=r[n]:f.error(u.method,i),!1;r=r[n]}})),b.isFunction(s)?o=s.apply(n,e):s!==h&&(o=s),b.isArray(a)?a.push(o):a!==h?a=[a,o]:o!==h&&(a=o),s}};return o?(g===h&&f.initialize(),f.invoke(n)):(g!==h&&f.destroy(),f.initialize()),a!==h?a:this},b.site.settings={name:"Site",namespace:"site",error:{console:"Console cannot be restored, most likely it was overwritten outside of module",method:"The method you called is not defined."},debug:!1,verbose:!1,performance:!0,modules:["accordion","api","checkbox","dimmer","dropdown","embed","form","modal","nag","popup","rating","shape","sidebar","state","sticky","tab","transition","visit","visibility"],siteNamespace:"site",namespaceStub:{cache:{},config:{},sections:{},section:{},utilities:{}}},b.extend(b.expr[":"],{data:b.expr.createPseudo?b.expr.createPseudo(function(n){return function(e){return!!b.data(e,n)}}):function(e,n,o){return!!b.data(e,o[3])}})}(jQuery,window,document); |