kute.js/dist/kute-css.min.js
2016-09-03 18:35:49 +03:00

2 lines
3.3 KiB
JavaScript

// CSS Plugin for KUTE.js | dnp_theme | MIT License
(function(h){if("function"===typeof define&&define.amd)define(["./kute.js"],function(a){h(a);return a});else if("object"==typeof module&&"function"==typeof require){var a=require("./kute.js");module.exports=h(a)}else if("undefined"!=typeof window.KUTE)h(a);else throw Error("CSS Plugin require KUTE.js.");})(function(h){var a=window.KUTE,c,g=a.dom,m=a.pp,t=a.property("borderRadius"),u=a.property("borderTopLeftRadius"),v=a.property("borderTopRightRadius"),w=a.property("borderBottomLeftRadius"),x=a.property("borderBottomRightRadius");h="borderColor borderTopColor borderRightColor borderBottomColor borderLeftColor outlineColor".split(" ");var p=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"];c="right bottom minWidth minHeight maxWidth maxHeight padding margin paddingTop paddingBottom paddingLeft paddingRight marginTop marginBottom marginLeft marginRight borderWidth borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth outlineWidth".split(" ");for(var b=["fontSize","lineHeight","letterSpacing","wordSpacing"],n=["backgroundPosition"],q=p.concat(c,b),r=h.concat(["clip"],p,c,b,n),y=r.length,k=a.Interpolate.unit,z=a.Interpolate.color,l=l||{},b=0;b<y;b++)c=r[b],-1!==h.indexOf(c)?l[c]="rgba(0,0,0,0)":-1!==q.indexOf(c)?l[c]=0:-1!==n.indexOf(c)?l[c]=[50,50]:"clip"===c&&(l[c]=[0,0,0,0]);b=0;for(n=h.length;b<n;b++)c=h[b],m[c]=function(f,a){f in g||(g[f]=function(e,a,f,d,c,b){e.style[a]=z(f,d,c,b.keepHex)});return m.cls(f,a)},a.prS[c]=function(f,d,e){return a.gCS(f,d)||l[d]};b=0;for(n=q.length;b<n;b++)c=q[b],m[c]=function(a,d){a in g||(g[a]=function(a,f,d,c,b){a.style[f]=k(d.value,c.value,c.unit,b)});return m.box(a,d)},a.prS[c]=function(f,d,e){return a.gCS(f,d)||l[d]};b=0;for(n=p.length;b<n;b++)c=p[b],m[c]=function(a,d){a in g||("borderRadius"===a?g[a]=function(a,d,f,c,b){a.style[t]=k(f.value,c.value,c.unit,b)}:"borderTopLeftRadius"===a?g[a]=function(a,d,c,f,b){a.style[u]=k(c.value,f.value,f.unit,b)}:"borderTopRightRadius"===a?g[a]=function(a,d,f,c,b){a.style[v]=k(f.value,c.value,c.unit,b)}:"borderBottomLeftRadius"===a?g[a]=function(a,d,c,f,b){a.style[w]=k(c.value,f.value,f.unit,b)}:"borderBottomRightRadius"===a&&(g[a]=function(a,d,f,c,b){a.style[x]=k(f.value,c.value,c.unit,b)}));return m.box(a,d)},a.prS[c]=function(c,d,b){return a.gCS(c,d)||l[d]};m.clip=function(c,d){c in g||(g[c]=function(a,c,b,d,f){var e=0,g=[];for(e;4>e;e++)g[e]=k(b[e].v,d[e].v,d[e].u||"px",f);a.style[c]="rect("+g+")"});if(d instanceof Array)return[a.truD(d[0]),a.truD(d[1]),a.truD(d[2]),a.truD(d[3])];var b=d.replace(/rect|\(|\)/g,""),b=/\,/g.test(b)?b.split(/\,/g):b.split(/\s/g);return[a.truD(b[0]),a.truD(b[1]),a.truD(b[2]),a.truD(b[3])]};a.prS.clip=function(c,b,e){b=a.gCS(c,b);e=a.gCS(c,"width");c=a.gCS(c,"height");return/rect/.test(b)?b:[0,e,c,0]};m.backgroundPosition=function(c,b){c in g||(g[c]=function(a,c,b,d,e){a.style[c]=k(b.x.v,d.x.v,"%",e)+" "+k(b.y.v,d.y.v,"%",e)});if(b instanceof Array)return{x:a.truD(b[0])||{v:50,u:"%"},y:a.truD(b[1])||{v:50,u:"%"}};var e=b.replace(/top|left/g,0).replace(/right|bottom/g,100).replace(/center|middle/g,50),h,e=/\,/g.test(e)?e.split(/\,/g):e.split(/\s/g),e=2===e.length?e:[e[0],50];h=a.truD(e[0]);e=a.truD(e[1]);return{x:h,y:e}};a.prS.backgroundPosition=function(c,b,e){return a.gCS(c,b)||l[b]};return this});