-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathmarka.min.js
10 lines (10 loc) · 3.82 KB
/
marka.min.js
1
2
3
4
5
6
7
8
9
10
/*!
* Marka - v0.3.1
* http://fian.my.id/marka
*
* Copyright 2014 Alfiana E. Sibuea and other contributors
* Released under the MIT license
* https://github.com/fians/marka/blob/master/LICENSE
*/
!function(){"use strict";function a(a,b){return Array.prototype.forEach.call(a,b)}function b(a){return"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName}function c(a,b){a.setAttribute("data-color",b);var c=a.getAttribute("data-icon"),d=a.children.length,e=[];if(f[c].hasOwnProperty("invert"))switch(f[c].invert){case"last":e=[d-1];break;case"last-two":e=[d-2,d-1];break;default:e=f[c].invert}for(var g=0;d>g;g++){var h=b;-1!==e.indexOf(g)&&(h=a.getAttribute("data-bg")),a.children[g].setAttribute("style","background-color:"+h)}}function d(a){var b=a.parentNode,c="rgba(0, 0, 0, 0)";do if(c=window.getComputedStyle(b).backgroundColor,b=b.parentNode,"rgba(0, 0, 0, 0)"!==c)break;while("tagName"in b);("rgba(0, 0, 0, 0)"===c||"transparent"===c)&&(c="rgb(255, 255, 255)"),a.setAttribute("data-bg",c)}function e(c){if(this.elements=[],"string"==typeof c&&(this.elements=document.querySelectorAll(c)),b(c)&&this.elements.push(c),c instanceof Array)for(var e=0;e<c.length;e++)b(c[e])&&this.elements.push(c[e]);if(!this.elements.length)throw Error("No element is selected.");return a(this.elements,function(a){d(a),-1===a.className.indexOf("marka")&&(a.className+=" marka ")}),this}var f={circle:{block:2},"circle-o":{block:3,invert:[1]},"circle-o-filled":{block:3,invert:[1]},"circle-minus":{block:3,invert:"last"},"circle-plus":{block:3,invert:"last-two"},"circle-times":{block:3,invert:"last-two"},"circle-o-minus":{block:4,invert:[1]},"circle-o-plus":{block:4,invert:[1]},"circle-o-times":{block:4,invert:[1]},square:{block:2},"square-o":{block:3,invert:[1]},"square-o-filled":{block:3,invert:[1]},"square-minus":{block:3,invert:"last"},"square-plus":{block:3,invert:"last-two"},"square-times":{block:3,invert:"last-two"},"square-check":{block:3,invert:"last-two"},"square-o-minus":{block:4,invert:[1]},"square-o-plus":{block:4,invert:[1]},"square-o-times":{block:4,invert:[1]},"square-o-check":{block:4,invert:[1]},triangle:{block:3},asterisk:{block:3},minus:{block:1},plus:{block:2},times:{block:2},check:{block:2},sort:{block:6},"sort-half":{block:3},"signal-three-one":{block:3},"signal-three-two":{block:3},"signal-three":{block:3},"signal-five-one":{block:5},"signal-five-two":{block:5},"signal-five-three":{block:5},"signal-five-four":{block:5},"signal-five":{block:5},pause:{block:2},angle:{block:2},"angle-double":{block:4},arrow:{block:3},bars:{block:3},chevron:{block:2}};e.prototype.set=function(b){var e=this;return a(this.elements,function(a){a.setAttribute("data-icon",b);var g=a.getAttribute("data-color");g||(g="rgb(0, 0, 0)",a.setAttribute("data-color",g));var h=a.children.length;if(f[b].block>h)for(var i=0;i<f[b].block-h;i++){var j=document.createElement("i");a.appendChild(j)}d(a),c(a,g),setTimeout(function(){a.className=a.className.replace(" "," ").replace(/marka-icon-[\w-]+/,""),a.className+="marka-icon-"+b+" ","sizeValue"in e&&a.setAttribute("style","width:"+e.sizeValue+"px;height:"+e.sizeValue+"px;"),-1===a.className.indexOf("marka-set")&&setTimeout(function(){a.className+="marka-set "},200)},10)}),this},e.prototype.color=function(b){return a(this.elements,function(a){d(a),c(a,b)}),this},e.prototype.size=function(b){return this.sizeValue=b,a(this.elements,function(a){a.setAttribute("style","width:"+b+"px;height:"+b+"px;")}),this},e.prototype.rotate=function(b){return a(this.elements,function(a){a.className=a.className.replace(" "," ").replace(/marka-rotate-[\w]+/,""),a.className+="marka-rotate-"+b+" "}),this},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(e):window&&(window.Marka=e)}();
//# sourceMappingURL=marka.min.js.map