14 lines
12 KiB
JavaScript
14 lines
12 KiB
JavaScript
|
/**
|
||
|
* jQuery fontIconPicker - v2.0.0
|
||
|
*
|
||
|
* An icon picker built on top of font icons and jQuery
|
||
|
*
|
||
|
* http://codeb.it/fontIconPicker
|
||
|
*
|
||
|
* Made by Alessandro Benoit & Swashata
|
||
|
* Under MIT License
|
||
|
*
|
||
|
* {@link https://github.com/micc83/fontIconPicker}
|
||
|
*/
|
||
|
!function(a){"use strict";function c(c,d){this.element=a(c),this.settings=a.extend({},b,d),this.settings.emptyIcon&&this.settings.iconsPerPage--,this.iconPicker=a("<div/>",{"class":"icons-selector",style:"position: relative",html:'<div class="selector"><span class="selected-icon"><i class="fip-icon-block"></i></span><span class="selector-button"><i class="fip-icon-down-dir"></i></span></div><div class="selector-popup" style="display: none;">'+(this.settings.hasSearch?'<div class="selector-search"><input type="text" name="" value="" placeholder="Search icon" class="icons-search-input"/><i class="fip-icon-search"></i></div>':"")+'<div class="selector-category">'+'<select name="" class="icon-category-select" style="display: none">'+"</select>"+"</div>"+'<div class="fip-icons-container"></div>'+'<div class="selector-footer" style="display:none;">'+'<span class="selector-pages">1/2</span>'+'<span class="selector-arrows">'+'<span class="selector-arrow-left" style="display:none;">'+'<i class="fip-icon-left-dir"></i>'+"</span>"+'<span class="selector-arrow-right">'+'<i class="fip-icon-right-dir"></i>'+"</span>"+"</span>"+"</div>"+"</div>"}),this.iconContainer=this.iconPicker.find(".fip-icons-container"),this.searchIcon=this.iconPicker.find(".selector-search i"),this.iconsSearched=[],this.isSearch=!1,this.totalPage=1,this.currentPage=1,this.currentIcon=!1,this.iconsCount=0,this.open=!1,this.searchValues=[],this.availableCategoriesSearch=[],this.triggerEvent=null,this.backupSource=[],this.backupSearch=[],this.isCategorized=!1,this.selectCategory=this.iconPicker.find(".icon-category-select"),this.selectedCategory=!1,this.availableCategories=[],this.unCategorizedKey=null,this.init()}var b={theme:"fip-grey",source:!1,emptyIcon:!0,emptyIconValue:"",iconsPerPage:20,hasSearch:!0,searchSource:!1,useAttribute:!1,attributeName:"data-icon",convertToHex:!0,allCategoryText:"From all categories",unCategorizedText:"Uncategorized"};c.prototype={init:function(){this.iconPicker.addClass(this.settings.theme),this.iconPicker.css({left:-9999}).appendTo("body");var b=this.iconPicker.outerHeight(),c=this.iconPicker.outerWidth();if(this.iconPicker.css({left:""}),this.element.before(this.iconPicker),this.element.css({visibility:"hidden",top:0,position:"relative",zIndex:"-1",left:"-"+c+"px",display:"inline-block",height:b+"px",width:c+"px",padding:"0",margin:"0 -"+c+"px 0 0",border:"0 none",verticalAlign:"top"}),!this.element.is("select")){var d=function(){for(var a=3,b=document.createElement("div"),c=b.all||[];b.innerHTML="<!--[if gt IE "+ ++a+"]><br><![endif]-->",c[0];);return a>4?a:!a}(),e=document.createElement("div");this.triggerEvent=9!==d&&"oninput"in e?["input","keyup"]:["keyup"]}!this.settings.source&&this.element.is("select")?(this.settings.source=[],this.settings.searchSource=[],this.element.find("optgroup").length?(this.isCategorized=!0,this.element.find("optgroup").each(a.proxy(function(b,c){var d=this.availableCategories.length,e=a("<option />");e.attr("value",d),e.html(a(c).attr("label")),this.selectCategory.append(e),this.availableCategories[d]=[],this.availableCategoriesSearch[d]=[],a(c).find("option").each(a.proxy(function(b,c){var e=a(c).val(),f=a(c).html();e&&e!==this.settings.emptyIconValue&&(this.settings.source.push(e),this.availableCategories[d].push(e),this.searchValues.push(f),this.availableCategoriesSearch[d].push(f))},this))},this)),this.element.find("> option").length&&this.element.find("> option").each(a.proxy(function(b,c){var d=a(c).val(),e=a(c).html();return d&&""!==d&&d!=this.settings.emptyIconValue?(null===this.unCategorizedKey&&(this.unCategorizedKey=this.availableCategories.length,this.availableCategories[this.unCategorizedKey]=[],this.availableCategoriesSearch[this.unCategorizedKey]=[],a("<option />").attr("value",this.unCategorizedKey).html(this.settings.unCategorizedText).appendTo(this.selectCategory)),this.settings.source.push(d),this.availableCategories[this.unCategorizedKey].push(d),this.searchValues.push(e),this.availableCategoriesSearch[this.unCategorizedKey].push(e),void 0):!0},this))):this.element.find("opti
|