@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines (2 loc) • 3.62 kB
JavaScript
!function(e){"function"==typeof define&&define.amd?define(["kendo.html.base.min"],e):e()}((function(){var e,n,s,i,t,r,o,a,l,c,p;e=window.kendo.jQuery,n=window.kendo,s=e.extend,i=n.html.HTMLBase,t="k-i-",r="k-svg-i-",o={svg:function(e,n){return new p(e,n)},font:function(e,n){return new c(e,n)}},a={default:"",horizontal:"k-flip-h",vertical:"k-flip-v",both:"k-flip-h k-flip-v"},l=i.extend({init:function(e,n){i.fn.init.call(this,e,n),this._wrapper()},options:{name:"HTMLIcon",size:"none",themeColor:"none",flip:"default",iconClass:"",stylingOptions:["size","themeColor","fill"]},_wrapper:function(){this._addClasses()},_addClasses:function(){var e=this,s=e.options,i=s.stylingOptions,t=e.wrapper.data("added-classes");i=i.map((function(e){return"themeColor"===e?n.cssProperties.getValidClass({widget:s.name,propName:e,value:s[e],prefix:"k-color-"}):"fill"===e?a[s.flip]:n.cssProperties.getValidClass({widget:s.name,propName:e,value:s[e],fill:s.fillMode})})),t&&e.wrapper.removeClass(t.filter((function(n){return n!==e._className})).join(" ")),e.wrapper.data("added-classes",i.concat([e._className])),e.wrapper.addClass(i.join(" "))}}),c=l.extend({init:function(e,n){l.fn.init.call(this,e,n)},options:s({},l.fn.options,{name:"HTMLFontIcon",icon:null}),_wrapper:function(){var e=this,n=e.element[0].className.split(" ").find((function(e){return e.includes(t)})),s=e.options.icon?""+(e.options.icon.startsWith(t)?"":t)+e.options.icon:"";e._className=s,e.wrapper=e.element.addClass("k-icon").removeClass(n).addClass(s).addClass(e.options.iconClass||""),l.fn._wrapper.call(this)}}),p=l.extend({init:function(e,n){e.empty(),l.fn.init.call(this,e,n)},options:s({},l.fn.options,{name:"HTMLSVGIcon",icon:null}),_wrapper:function(){var s,i=this,t=i.options.icon,o=i.options.iconClass,a=i.element[0].className.split(" ").find((function(e){return e.includes(r)})),c=e("<svg></svg>");if(!t&&o){var p=o.match(/k-i-(\w+(?:-\w+)*)/);p&&(t=p[1],o=o.replace(p[0],""))}n.isString(t)&&(t=t.replace("k-i-","").replace(/-./g,(function(e){return e[1].toUpperCase()})),t=n.ui.svgIcons[t]||n.ui.svgIcons[t+"Icon"]),s=t&&t.name?"k-svg-i-"+t.name:"",i._className=s,i.wrapper=i.element.addClass("k-svg-icon").removeClass(a).addClass(s).addClass(o||""),e.isPlainObject(t)&&(c.attr("viewBox",t.viewBox||"").attr({viewBox:t.viewBox||"","aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg"}).html(t.content||""),i.wrapper.append(c[0].outerHTML)),l.fn._wrapper.call(this)}}),e.extend(n.html,{renderIcon:function(s,i){return(!s||e.isPlainObject(s)||n.isString(s))&&(i=s,s=e("<span></span>")),n.isString(i)&&(i={icon:i}),n.isPresent(i.type)||(i.type=n.defaults.iconType?n.defaults.iconType:"svg"),n.isFunction(i.type)?i.type(s,i):n.isFunction(o[i.type])?o[i.type](s,i).html():null},HTMLFontIcon:c,HTMLSvgIcon:p,getIconRenderer:function(e){return o[e]}}),n.cssProperties.registerPrefix("HTMLFontIcon","k-icon-"),n.cssProperties.registerValues("HTMLFontIcon",[{prop:"size",values:n.cssProperties.sizeValues.concat([["xsmall","xs"],["xlarge","xl"],["xxlarge","xxl"],["xxxlarge","xxxl"]])},{prop:"themeColor",values:["primary","secondary","tertiary","inherit","info","success","warning","error","dark","light","inverse"]}]),n.cssProperties.registerPrefix("HTMLSVGIcon","k-icon-"),n.cssProperties.registerValues("HTMLSVGIcon",[{prop:"size",values:n.cssProperties.sizeValues.concat([["xsmall","xs"],["xlarge","xl"],["xxlarge","xxl"],["xxxlarge","xxxl"]])},{prop:"themeColor",values:["primary","secondary","tertiary","inherit","info","success","warning","error","dark","light","inverse"]}])}));
//# sourceMappingURL=kendo.html.icon.min.js.map