UNPKG

syntax-highlighting

Version:

Syntax Highlighting Colorschemes for many applications

2 lines (1 loc) 6.69 kB
var libFuncName=null;if(typeof jQuery==="undefined"&&typeof Zepto==="undefined"&&typeof $==="function")libFuncName=$;else if(typeof jQuery==="function")libFuncName=jQuery;else if(typeof Zepto==="function")libFuncName=Zepto;else throw new TypeError;(function($,window,document,undefined){window.matchMedia=window.matchMedia||function(doc,undefined){var bool,docElem=doc.documentElement,refNode=docElem.firstElementChild||docElem.firstChild,fakeBody=doc.createElement("body"),div=doc.createElement("div");div.id="mq-test-1";div.style.cssText="position:absolute;top:-100em";fakeBody.style.background="none";fakeBody.appendChild(div);return function(q){div.innerHTML='&shy;<style media="'+q+'"> #mq-test-1 { width: 42px; }</style>';docElem.insertBefore(fakeBody,refNode);bool=div.offsetWidth===42;docElem.removeChild(fakeBody);return{matches:bool,media:q}}}(document);if(!Array.prototype.filter)Array.prototype.filter=function(fun){if(this==null)throw new TypeError;var t=Object(this),len=t.length>>>0;if(typeof fun!=="function")return;var res=[],thisp=arguments[1];for(var i=0;i<len;i++)if(i in t){var val=t[i];if(fun&&fun.call(thisp,val,i,t))res.push(val)}return res};if(!Function.prototype.bind)Function.prototype.bind=function(oThis){if(typeof this!=="function")throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var aArgs=Array.prototype.slice.call(arguments,1),fToBind=this,fNOP=function(){},fBound=function(){return fToBind.apply(this instanceof fNOP&&oThis?this:oThis,aArgs.concat(Array.prototype.slice.call(arguments)))};fNOP.prototype=this.prototype;fBound.prototype=new fNOP;return fBound};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(searchElement){if(this==null)throw new TypeError;var t=Object(this);var len=t.length>>>0;if(len===0)return-1;var n=0;if(arguments.length>1){n=Number(arguments[1]);if(n!=n)n=0;else if(n!=0&&n!=Infinity&&n!=-Infinity)n=(n>0||-1)*Math.floor(Math.abs(n))}if(n>=len)return-1;var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k<len;k++)if(k in t&&t[k]===searchElement)return k;return-1};$.fn.stop=$.fn.stop||function(){return this};window.Foundation={name:"Foundation",version:"4.3.1",cache:{},init:function(scope,libraries,method,options,response,nc){var library_arr,args=[scope,method,options,response],responses=[],nc=nc||false;if(nc)this.nc=nc;this.rtl=/rtl/i.test($("html").attr("dir"));this.scope=scope||this.scope;if(libraries&&typeof libraries==="string"&&!/reflow/i.test(libraries)){if(/off/i.test(libraries))return this.off();library_arr=libraries.split(" ");if(library_arr.length>0)for(var i=library_arr.length-1;i>=0;i--)responses.push(this.init_lib(library_arr[i],args))}else{if(/reflow/i.test(libraries))args[1]="reflow";for(var lib in this.libs)responses.push(this.init_lib(lib,args))}if(typeof libraries==="function")args.unshift(libraries);return this.response_obj(responses,args)},response_obj:function(response_arr,args){for(var i=0,len=args.length;i<len;i++)if(typeof args[i]==="function")return args[i]({errors:response_arr.filter(function(s){if(typeof s==="string")return s})});return response_arr},init_lib:function(lib,args){return this.trap(function(){if(this.libs.hasOwnProperty(lib)){this.patch(this.libs[lib]);return this.libs[lib].init.apply(this.libs[lib],args)}else return function(){}}.bind(this),lib)},trap:function(fun,lib){if(!this.nc)try{return fun()}catch(e){return this.error({name:lib,message:"could not be initialized",more:e.name+" "+e.message})}return fun()},patch:function(lib){this.fix_outer(lib);lib.scope=this.scope;lib.rtl=this.rtl},inherit:function(scope,methods){var methods_arr=methods.split(" ");for(var i=methods_arr.length-1;i>=0;i--)if(this.lib_methods.hasOwnProperty(methods_arr[i]))this.libs[scope.name][methods_arr[i]]=this.lib_methods[methods_arr[i]]},random_str:function(length){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");if(!length)length=Math.floor(Math.random()*chars.length);var str="";for(var i=0;i<length;i++)str+=chars[Math.floor(Math.random()*chars.length)];return str},libs:{},lib_methods:{set_data:function(node,data){var id=[this.name,+new Date,Foundation.random_str(5)].join("-");Foundation.cache[id]=data;node.attr("data-"+this.name+"-id",id);return data},get_data:function(node){return Foundation.cache[node.attr("data-"+this.name+"-id")]},remove_data:function(node){if(node){delete Foundation.cache[node.attr("data-"+this.name+"-id")];node.attr("data-"+this.name+"-id","")}else $("[data-"+this.name+"-id]").each(function(){delete Foundation.cache[$(this).attr("data-"+this.name+"-id")];$(this).attr("data-"+this.name+"-id","")})},throttle:function(fun,delay){var timer=null;return function(){var context=this,args=arguments;clearTimeout(timer);timer=setTimeout(function(){fun.apply(context,args)},delay)}},data_options:function(el){var opts={},ii,p,opts_arr=(el.attr("data-options")||":").split(";"),opts_len=opts_arr.length;function isNumber(o){return!isNaN(o-0)&&o!==null&&o!==""&&o!==false&&o!==true}function trim(str){if(typeof str==="string")return $.trim(str);return str}for(ii=opts_len-1;ii>=0;ii--){p=opts_arr[ii].split(":");if(/true/i.test(p[1]))p[1]=true;if(/false/i.test(p[1]))p[1]=false;if(isNumber(p[1]))p[1]=parseInt(p[1],10);if(p.length===2&&p[0].length>0)opts[trim(p[0])]=trim(p[1])}return opts},delay:function(fun,delay){return setTimeout(fun,delay)},scrollTo:function(el,to,duration){if(duration<0)return;var difference=to-$(window).scrollTop();var perTick=difference/duration*10;this.scrollToTimerCache=setTimeout(function(){if(!isNaN(parseInt(perTick,10))){window.scrollTo(0,$(window).scrollTop()+perTick);this.scrollTo(el,to,duration-10)}}.bind(this),10)},scrollLeft:function(el){if(!el.length)return;return"scrollLeft"in el[0]?el[0].scrollLeft:el[0].pageXOffset},empty:function(obj){if(obj.length&&obj.length>0)return false;if(obj.length&&obj.length===0)return true;for(var key in obj)if(hasOwnProperty.call(obj,key))return false;return true}},fix_outer:function(lib){lib.outerHeight=function(el,bool){if(typeof Zepto==="function")return el.height();if(typeof bool!=="undefined")return el.outerHeight(bool);return el.outerHeight()};lib.outerWidth=function(el,bool){if(typeof Zepto==="function")return el.width();if(typeof bool!=="undefined")return el.outerWidth(bool);return el.outerWidth()}},error:function(error){return error.name+" "+error.message+"; "+error.more},off:function(){$(this.scope).off(".fndtn");$(window).off(".fndtn");return true},zj:$};$.fn.foundation=function(){var args=Array.prototype.slice.call(arguments,0);return this.each(function(){Foundation.init.apply(Foundation,[this].concat(args));return this})}})(libFuncName,this,this.document);