dear-anon/wp-content/plugins/child-theme-configurator/js/ctcgrad.min.js

7 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*!
* CTC Gradient Functions
* Adapted from Iris
* Copyright (c) 20122014 Automattic.
* Licensed under the GPLv2 license.
*/
(function(i,f){var d,q,b,a,o,e,l,c,h;l=navigator.userAgent.toLowerCase();c=navigator.appName==="Microsoft Internet Explorer";h=c?parseFloat(l.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]):0;q=(c&&h<10);a=["-moz-","-webkit-","-o-","-ms-"];p();if(q&&h<=7){i.fn.ctcgrad=i.noop;i.support.ctcgrad=false;return}i.support.ctcgrad=true;function p(){var r,s;if(q){b="filter"}else{r=i('<div id="ctcgrad-gradtest" />');s="linear-gradient(top,#fff,#000)";i.each(a,function(t,u){r.css("backgroundImage",u+s);if(r.css("backgroundImage").match("gradient")){b=t;return false}});if(b===false){r.css("background","-webkit-gradient(linear,0% 0%,0% 100%,from(#fff),to(#000))");if(r.css("backgroundImage").match("gradient")){b="webkit"}}r.remove()}}function n(r,s){r=(r.match(/(\d+deg|top|left|bottom|right)( (top|left|bottom|right))?/)?r:"top");s=i.isArray(s)?s:Array.prototype.slice.call(arguments,1);if(b==="webkit"){return m(r,s)}else{return a[b]+"linear-gradient("+r+", "+s.join(", ")+")"}}function g(x,A){var w,C,u,r,v,B,z,y,t,s;x=(x==="left")?"left":"top";A=i.isArray(A)?A:Array.prototype.slice.call(arguments,1);w=(x==="top")?0:1;C=i(this);u=A.length-1;r="filter";v=(w===1)?"left":"top";B=(w===1)?"right":"bottom";z=(w===1)?"height":"width";if(C.css("position")==="static"){C.css({position:"relative"})}A=j(A);i.each(A,function(D,F){var E,G;if(D===u){return false}E=A[D+1];if(F.stop===E.stop){return}G=100-parseFloat(E.stop)+"%";F.octoHex=new Color(F.color).toIEOctoHex();E.octoHex=new Color(E.color).toIEOctoHex();s="progid:DXImageTransform.Microsoft.Gradient(GradientType="+w+", StartColorStr='"+F.octoHex+"', EndColorStr='"+E.octoHex+"')"});return s}function m(r,s){var t=[];r=(r==="top")?"0% 0%,0% 100%,":"0% 100%,100% 100%,";s=j(s);i.each(s,function(u,v){t.push("color-stop("+(parseFloat(v.stop)/100)+", "+v.color+")")});return"-webkit-gradient(linear,"+r+t.join(",")+")"}function j(t){var s=[],u=[],r=[],v=t.length-1;i.each(t,function(y,A){var w=A,z=false,x=A.match(/1?[0-9]{1,2}%$/);if(x){w=A.replace(/\s?1?[0-9]{1,2}%$/,"");z=x.shift()}s.push(w);u.push(z)});if(u[0]===false){u[0]="0%"}if(u[v]===false){u[v]="100%"}u=k(u);i.each(u,function(w){r[w]={color:s[w],stop:u[w]}});return r}function k(z){var u=0,y=z.length-1,t=0,w=false,r,x,s,v;if(z.length<=2||i.inArray(false,z)<0){return z}while(t<z.length-1){if(!w&&z[t]===false){u=t-1;w=true}else{if(w&&z[t]!==false){y=t;t=z.length}}t++}x=y-u;v=parseInt(z[u].replace("%"),10);r=(parseFloat(z[y].replace("%"))-v)/x;t=u+1;s=1;while(t<y){z[t]=(v+(s*r))+"%";s++;t++}return k(z)}i.fn.ctcgrad=function(r){var s=arguments;if(q){i(this).css("filter",g.apply(this,s))}else{i(this).css("backgroundImage",n.apply(this,s))}}}(jQuery));