-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgradext.min.js
More file actions
6 lines (6 loc) · 6.45 KB
/
gradext.min.js
File metadata and controls
6 lines (6 loc) · 6.45 KB
1
2
3
4
5
6
/*
####### mrReiha is here !
####### @mrReiha
####### www.reiha.net
*/
!function(t){"use strict";var e,r,i={fi:function(){var t,i=~~(5*Math.random());return r=[],e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame,void 0===e&&(e=function(t){setTimeout(function(){t()},1e3/60)}),t={A:this.animation||0,SC:this.startColor||["#0b2b87","#0a6b51","#dbd952","#c31fc1","#f1676e"][i],EC:this.endColor||["#244ec5","#39daaf","#6c6b0f","#5d0c5c","#6f0e13"][i],EI:this.elemID||0,RG:this.rgb||0,SP:this.startPosition?this.startPosition-1:0,EP:this.endPosition?this.endPosition-1:0,R:this.radius||15,D:1e3*this.delay||0,Q:this.quality||20,M:this.mode||"horizontal",DI:this.direction||"rtl"}},fm:function(t,e){var i,n,o=this;if("object"!=typeof o&&(o="string"==typeof o?{elemID:o}:{}),o=t.fi.apply(o),r[1]=o.EI?0:1,r[1])throw new Error('You Have to Specify an "elemID" for Me :(');if(i=document.getElementById(o.EI),r[2]=i?0:1,r[2])throw new Error('I Think your "elemID" wasn\'t Right ; Gimme Another Please ... :(');if(r[9]="vertical"==o.M?0:"horizontal"==o.M?0:1,r[9])throw new Error('Your Provided "mode" Has to be horizontal or vertical :(');var s=t.fnc(t.fr.apply(o.SC)),a=t.fnc(t.fr.apply(o.EC)),l=i.textContent.trim(),h=l.split(""),f="vertical"==o.M?o.Q:h.length,c=document.createDocumentFragment(),d="center"==getComputedStyle(i).textAlign?1:0;if(r[3]=""==l,r[3])throw new Error("Your Element Must Contains a Text :(");if(r[4]=o.SP+1>=f?"vertical"==o.M?0:1:0,r[4])throw new Error('"startPosition" Has to be Less than the Length of Your String :(');if(r[5]=o.EP>o.SP?0:0==o.EP?0:1,r[5])throw new Error('"endPosition" Has to be Greater than "startPosition"');if(r[6]=s.length<6?s.length>3?1:3==s.length?0:1:0,r[6]||(r[6]=a.length<6?a.length>3?1:3==a.length?0:1:0),r[6])throw new Error("Please Gimme a Valid and Standard Hexadecimal Code for Your Color; I Can't Read This one :(");if(r[7]=s==a,r[7])throw new Error('"startColor" is equal to "endColor"');if(r[10]=~~o.Q!=o.Q,r[10])throw new Error('"quality" can\'t be a Float Number :(');switch(n={f:i,k:f,c:0,r:"ltr"==o.DI?1:0,a:o,rg:o.RG,rt:2*o.R,d:{r:parseInt(s.substring(0,2),16),g:parseInt(s.substring(2,4),16),b:parseInt(s.substring(4,6),16)},g:{r:parseInt(a.substring(0,2),16),g:parseInt(a.substring(2,4),16),b:parseInt(a.substring(4,6),16)},v:"vertical"==o.M,s:t,eh:i.offsetHeight,ce:d},i.innerHTML="",o.M){case"horizontal":for(var g=0;f>g;g++){var b=document.createElement("span");b.innerHTML=h[g],b.setAttribute("data-i",g),b.style.color=o.SC,c.appendChild(b)}break;case"vertical":i.style.position="relative";for(var g=0;f>g;g++){var b=document.createElement("span");b.setAttribute("data-i",g),b.innerHTML=l,b.style.color=o.SC,b.style.position="absolute",b.style.zIndex=f-g,b.style.overflow="hidden",e||(b.style.pointerEvents=b.style.mozPointerEvents=b.style.webkitPointerEvents=b.style.msPointerEvents="none"),g==f-1&&(b.style.pointerEvents=b.style.mozPointerEvents=b.style.webkitPointerEvents=b.style.msPointerEvents="initial"),c.appendChild(b)}}return i.appendChild(c),n},hoverable:function(t){for(var e=this.fm.apply(t,[this,1]),r=e.a,i=e.f.children.length;i--;)r.A&&(e.f.children[i].style.transition=e.f.children[i].style.msTransition=e.f.children[i].style.webkitTransition=e.f.children[i].style.mozTransition=e.f.children[i].style.oTransition="color .25s ease"),e.v&&(e.f.children[i].style.height=e.s.fgh(e.eh,i,r.Q),e.ce&&(e.f.children[i].style.marginLeft="-"+e.f.children[i].offsetWidth/2+"px"),i==e.k-1&&(e.f.style.minHeight=e.f.children[i].offsetHeight+"px")),e.f.children[i].onmouseover=function(){if(r.SP=this.getAttribute("data-i")-r.R,r.SP<0)var t=-r.SP;else var t=0;for(var i=0;i<e.k;i++)i>=r.SP?(e.f.children[i].style.color=e.s.fgc(e.d,t,e.g,e.rt,r.R,"r",r.RG),t++):e.f.children[i].style.color=e.s.fgc(e.d,0,e.g,e.rt,r.R,"r",r.RG)};e.f.onmouseout=function(){for(var t=0;t<e.k;t++)e.f.children[t].style.color=e.s.fgc(e.d,0,e.g,e.k,r.R,"l",r.RG)}},linear:function(t){for(var e=this.fm.apply(t,[this]),r=e.a,i=0,n=e.c;i<e.k;i++)(r.SP?r.EP?i>=r.SP&&i<r.EP:i>=r.SP:r.EP?i<r.EP:1)?(e.f.children[i].style.color=e.s.fgc(e.d,n,e.g,r.EP?r.EP-r.SP:e.k-r.SP,r.R,"l",r.RG),n++):e.f.children[i].style.color=(r.EP?i>=r.EP:0)?e.s.fgc(e.d,e.k,e.g,e.k,r.R,"l",r.RG):e.s.fgc(e.d,0,e.g,e.k,r.R,"l",r.RG),e.v&&(e.f.children[i].style.height=e.s.fgh(e.eh,i,r.Q),e.ce&&(e.f.children[i].style.marginLeft="-"+e.f.children[i].offsetWidth/2+"px"),i==e.k-1&&(e.f.style.minHeight=e.f.children[i].offsetHeight+"px"))},radial:function(t){var r=this.fm.apply(t,[this]),i=r.a;!function n(){var t=r.c;!i.A&&r.r&&(t=r.k),i.A&&(i.SP=0);for(var o=0;o<r.k;o++)o>=i.SP?(r.f.children[o].style.color=r.s.fgc(r.d,t,r.g,r.rt,i.R,"r",i.RG),r.r?t--:t++):r.f.children[o].style.color=r.s.fgc(r.d,0,r.g,r.rt,i.R,"r",i.RG),r.v&&(r.f.children[o].style.height=r.s.fgh(r.eh,o,i.Q),r.ce&&(r.f.children[o].style.marginLeft="-"+r.f.children[o].offsetWidth/2+"px"),o==r.k-1&&(r.f.style.minHeight=r.f.children[o].offsetHeight+"px"));if(r.c++,i.A)if(r.r?r.c<=r.k+r.rt:r.c<=r.rt)e(n);else{r.c=r.r?-i.R:-r.k;{setTimeout(function(){e(n)},i.D)}}}()},fr:function(){return"#"==this.charAt(0)?this.substring(1,this.length):this},fnc:function(t){if(3==t.length){for(var e=t.split(""),r=0;e[r];)e[r]=e[r]+e[r],r++;return e.join("")}return t},fgh:function(t,e,r){return(e+1)*(t/r)+"px"},fgc:function(t,e,i,n,o,s,a){var l,h=function(t){return t=parseInt(t,10),isNaN(t)?"00":(t=Math.max(0,Math.min(t,255)),"0123456789ABCDEF".charAt((t-t%16)/16)+"0123456789ABCDEF".charAt(t%16))},f={r:Math.abs(t.r-i.r),g:Math.abs(t.g-i.g),b:Math.abs(t.b-i.b)};if(r[8]=0==f.r?0==f.g?0==f.b?1:0:0:0,r[8])throw new Error('"startColor" is equal to "endColor"');var c={r:(f.r/o).toFixed(2),b:(f.b/o).toFixed(2),g:(f.g/o).toFixed(2)},d={r:(f.r/n).toFixed(2),b:(f.b/n).toFixed(2),g:(f.g/n).toFixed(2)},g=function(){if(0==e)var r=t.r,o=t.g,s=t.b;else if(e==n-1)var r=i.r,o=i.g,s=i.b;else var r=Math.abs(e*d.r+(t.r<i.r?t.r:-t.r)),o=Math.abs(e*d.g+(t.g<i.g?t.g:-t.g)),s=Math.abs(e*d.b+(t.b<i.b?t.b:-t.b));return l=h(r)+h(o)+h(s),a?"rgb("+~~r+","+~~o+","+~~s+")":"#"+l},b=function(){if(0>=e||e>=n)var r=t.r,s=t.b,f=t.g;else if(o>e)var r=Math.abs(e*c.r+(t.r<i.r?t.r:-t.r)),s=Math.abs(e*c.b+(t.b<i.b?t.b:-t.b)),f=Math.abs(e*c.g+(t.g<i.g?t.g:-t.g));else var r=Math.abs((n-e)*c.r+(t.r<i.r?t.r:-t.r)),s=Math.abs((n-e)*c.b+(t.b<i.b?t.b:-t.b)),f=Math.abs((n-e)*c.g+(t.g<i.g?t.g:-t.g));return l=h(r)+h(f)+h(s),a?"rgb("+~~r+","+~~f+","+~~s+")":"#"+l};switch(s){case"l":return g();case"r":return b()}}};t.gradext=t.Gradext=i}(this);