kute.js/dist/kute-attr.min.js
2018-07-19 08:39:09 +03:00

2 lines
1.6 KiB
JavaScript

// KUTE.js v1.6.6 | © dnp_theme | Attributes Plugin | MIT-License
!function(t,e){if("function"==typeof define&&define.amd)define(["./kute.js"],e);else if("object"==typeof module&&"function"==typeof require)module.exports=e(require("./kute.js"));else{if(void 0===t.KUTE)throw new Error("Attributes Plugin require KUTE.js.");e(t.KUTE)}}(this,function(t){"use strict";var e,r="undefined"!=typeof global?global:window,n=t,i=n.dom,o=n.prepareStart,u=n.parseProperty,a=n.truC,s=n.truD,f=(n.crossCheck,r.Interpolate.unit,r.Interpolate.number),l=r.Interpolate.color,c=function(t,e){return t.getAttribute(e)},p=["fill","stroke","stop-color"],d=function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()};return o.attr=function(t,e){var r={};for(var n in e){var i=d(n).replace(/_+[a-z]+/,""),o=c(this.element,i);r[i]=-1!==p.indexOf(i)?o||"rgba(0,0,0,0)":o||(/opacity/i.test(n)?1:0)}return r},u.attr=function(t,r){"attr"in i||(i.attr=function(t,e,r,n,o){for(var u in n)i.attributes[u](t,u,r[u],n[u],o)},e=i.attributes={});var n={};for(var o in r){var u=d(o),v=/(%|[a-z]+)$/,b=c(this.element,u.replace(/_+[a-z]+/,""));if(-1===p.indexOf(u))if(null!==b&&v.test(b)){var m=s(b).u||s(r[o]).u,y=/%/.test(m)?"_percent":"_"+m;u+y in e||(/%/.test(m),e[u+y]=function(t,e,r,n,i){var o=o||e.replace(y,"");t.setAttribute(o,(1e3*f(r.v,n.v,i)>>0)/1e3+n.u)}),n[u+y]=s(r[o])}else v.test(r[o])&&null!==b&&(null===b||v.test(b))||(u in e||(/opacity/i.test(o),e[u]=function(t,e,r,n,i){t.setAttribute(e,(1e3*f(r,n,i)>>0)/1e3)}),n[u]=parseFloat(r[o]));else u in e||(e[u]=function(t,e,n,i,o){t.setAttribute(e,l(n,i,o,r.keepHex))}),n[u]=a(r[o])}return n},this});