text: 
  (function(b){var c={theme:"fip-grey",source:false,emptyIcon:true,emptyIconValue:"",iconsPerPage:20,hasSearch:true,searchSource:false,useAttribute:false,attributeName:"data-icon",convertToHex:true,allCategoryText:"From all categories",unCategorizedText:"Uncategorized"};function a(e,d){this.element=b(e);this.settings=b.extend({},c,d);if(this.settings.emptyIcon){this.settings.iconsPerPage--}this.iconPicker=b("<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=false;this.totalPage=1;this.currentPage=1;this.currentIcon=false;this.iconsCount=0;this.open=false;this.searchValues=[];this.availableCategoriesSearch=[];this.triggerEvent=null;this.backupSource=[];this.backupSearch=[];this.isCategorized=false;this.selectCategory=this.iconPicker.find(".icon-category-select");this.selectedCategory=false;this.availableCategories=[];this.unCategorizedKey=null;this.init()}a.prototype={init:function(){this.iconPicker.addClass(this.settings.theme);this.iconPicker.css({left:-9999}).appendTo("body");var d=this.iconPicker.outerHeight(),f=this.iconPicker.outerWidth();this.iconPicker.css({left:""});this.element.before(this.iconPicker);this.element.css({visibility:"hidden",top:0,position:"relative",zIndex:"-1",left:"-"+f+"px",display:"inline-block",height:d+"px",width:f+"px",padding:"0",margin:"0 -"+f+"px 0 0",border:"0 none",verticalAlign:"top"});if(!this.element.is("select")){var g=(function(){var i=3,j=document.createElement("div"),h=j.all||[];while(j.innerHTML="<!--[if gt IE "+(++i)+"]><br><![endif]-->",h[0]){}return i>4?i:!i}());var e=document.createElement("div");this.triggerEvent=(g===9||!("oninput" in e))?["keyup"]:["input","keyup"]}if(!this.settings.source&&this.element.is("select")){this.settings.source=[];this.settings.searchSource=[];if(this.element.find("optgroup").length){this.isCategorized=true;this.element.find("optgroup").each(b.proxy(function(j,k){var l=this.availableCategories.length,h=b("<option />");h.attr("value",l);h.html(b(k).attr("label"));this.selectCategory.append(h);this.availableCategories[l]=[];this.availableCategoriesSearch[l]=[];b(k).find("option").each(b.proxy(function(n,o){var p=b(o).val(),m=b(o).html();if(p&&p!==this.settings.emptyIconValue){this.settings.source.push(p);this.availableCategories[l].push(p);this.searchValues.push(m);this.availableCategoriesSearch[l].push(m)}},this))},this));if(this.element.find("> option").length){this.element.find("> option").each(b.proxy(function(j,k){var l=b(k).val(),h=b(k).html();if(!l||l===""||l==this.settings.emptyIconValue){return true}if(this.unCategorizedKey===null){this.unCategorizedKey=this.availableCategories.length;this.availableCategories[this.unCategorizedKey]=[];this.availableCategoriesSearch[this.unCategorizedKey]=[];b("<option />").attr("value",this.unCategorizedKey).html(this.settings.unCategorizedText).appendTo(this.selectCategory)}this.settings.source.push(l);this.availableCategories[this.unCategorizedKey].push(l);this.searchValues.push(h);this.availableCategoriesSearch[this.unCategorizedKey].push(h)},this))}}else{this.element.find("option").each(b.proxy(function(j,k){var l=b(k).val(),h=b(k).html();if(l){this.settings.source.push(l);this.searchValues.push(h)}},this))}this.backupSource=this.settings.source.slice(0);this.backupSearch=this.searchValues.slice(0);this.loadCategories()}else{this.initSourceIndex()}this.loadIcons();this.selectCategory.on("change keyup",b.proxy(function(k){if(this.isCategorized===false){return false}var h=b(k.currentTarget),i=h.val();if(h.val()==="all"){this.settings.source=this.backupSource;this.searchValues=this.backupSearch}else{var j=parseInt(i,10);if(this.availableCategories[j]){this.settings.source=this.availableCategories[j];this.searchValues=this.availableCategoriesSearch[j]}}this.resetSearch();this.loadIcons()},this));this.iconPicker.find(".selector-button").click(b.proxy(function(){this.toggleIconSelector()},this));this.iconPicker.find(".selector-arrow-right").click(b.proxy(function(h){if(this.currentPage<this.totalPage){this.iconPicker.find(".selector-arrow-left").show();this.currentPage=this.currentPage+1;this.renderIconContainer()}if(this.currentPage===this.totalPage){b(h.currentTarget).hide()}},this));this.iconPicker.find(".selector-arrow-left").click(b.proxy(function(h){if(this.currentPage>1){this.iconPicker.find(".selector-arrow-right").show();this.currentPage=this.currentPage-1;this.renderIconContainer()}if(this.currentPage===1){b(h.currentTarget).hide()}},this));this.iconPicker.find(".icons-search-input").keyup(b.proxy(function(i){var h=b(i.currentTarget).val();if(h===""){this.resetSearch();return}this.searchIcon.removeClass("fip-icon-search");this.searchIcon.addClass("fip-icon-cancel");this.isSearch=true;this.currentPage=1;this.iconsSearched=[];b.grep(this.searchValues,b.proxy(function(k,j){if(k.toLowerCase().search(h.toLowerCase())>=0){this.iconsSearched[this.iconsSearched.length]=this.settings.source[j];return true}},this));this.renderIconContainer()},this));this.iconPicker.find(".selector-search").on("click",".fip-icon-cancel",b.proxy(function(){this.iconPicker.find(".icons-search-input").focus();this.resetSearch()},this));this.iconContainer.on("click",".fip-box",b.proxy(function(h){this.setSelectedIcon(b(h.currentTarget).find("i").attr("data-fip-value"));this.toggleIconSelector()},this));this.iconPicker.click(function(h){h.stopPropagation();return false});b("html").click(b.proxy(function(){if(this.open){this.toggleIconSelector()}},this))},initSourceIndex:function(){if(typeof(this.settings.source)!=="object"){return}if(b.isArray(this.settings.source)){this.isCategorized=false;this.selectCategory.html("").hide();this.settings.source=b.map(this.settings.source,function(l,k){if(typeof(l.toString)=="function"){return l.toString()}else{return l}});if(b.isArray(this.settings.searchSource)){this.searchValues=b.map(this.settings.searchSource,function(l,k){if(typeof(l.toString)=="function"){return l.toString()}else{return l}})}else{this.searchValues=this.settings.source.slice(0)}}else{var f=b.extend(true,{},this.settings.source);this.settings.source=[];this.searchValues=[];this.availableCategoriesSearch=[];this.selectedCategory=false;this.availableCategories=[];this.unCategorizedKey=null;this.isCategorized=true;this.selectCategory.html("");for(var j in f){var i=this.availableCategories.length,e=b("<option />");e.attr("value",i);e.html(j);this.selectCategory.append(e);this.availableCategories[i]=[];this.availableCategoriesSearch[i]=[];for(var g in f[j]){var h=f[j][g];var d=(this.settings.searchSource&&this.settings.searchSource[j]&&this.settings.searchSource[j][g])?this.settings.searchSource[j][g]:h;if(typeof(h.toString)=="function"){h=h.toString()}if(h&&h!==this.settings.emptyIconValue){this.settings.source.push(h);this.availableCategories[i].push(h);this.searchValues.push(d);this.availableCategoriesSearch[i].push(d)}}}}this.backupSource=this.settings.source.slice(0);this.backupSearch=this.searchValues.slice(0);this.loadCategories()},loadCategories:function(){if(this.isCategorized===false){return}b('<option value="all">'+this.settings.allCategoryText+"</option>").prependTo(this.selectCategory);this.selectCategory.show().val("all").trigger("change")},loadIcons:function(){this.iconContainer.html('<i class="fip-icon-spin3 animate-spin loading"></i>');if(this.settings.source instanceof Array){this.renderIconContainer()}},renderIconContainer:function(){var h,g=[];if(this.isSearch){g=this.iconsSearched}else{g=this.settings.source}this.iconsCount=g.length;this.totalPage=Math.ceil(this.iconsCount/this.settings.iconsPerPage);if(this.totalPage>1){this.iconPicker.find(".selector-footer").show()}else{this.iconPicker.find(".selector-footer").hide()}this.iconPicker.find(".selector-pages").html(this.currentPage+"/"+this.totalPage+" <em>("+this.iconsCount+")</em>");h=(this.currentPage-1)*this.settings.iconsPerPage;if(this.settings.emptyIcon){this.iconContainer.html('<span class="fip-box"><i class="fip-icon-block" data-fip-value="fip-icon-block"></i></span>')}else{if(g.length<1){this.iconContainer.html('<span class="icons-picker-error"><i class="fip-icon-block" data-fip-value="fip-icon-block"></i></span>');return}else{this.iconContainer.html("")}}g=g.slice(h,h+this.settings.iconsPerPage);for(var d=0,f;f=g[d++];){var e=f;b.grep(this.settings.source,b.proxy(function(k,j){if(k===f){e=this.searchValues[j];return true}return false},this));b("<span/>",{html:'<i data-fip-value="'+f+'" '+(this.settings.useAttribute?(this.settings.attributeName+'="'+(this.settings.convertToHex?"&#x"+parseInt(f,10).toString(16)+";":f)+'"'):'class="'+f+'"')+"></i>","class":"fip-box",title:e}).appendTo(this.iconContainer)}if(!this.settings.emptyIcon&&(!this.element.val()||b.inArray(this.element.val(),this.settings.source)===-1)){this.setSelectedIcon(g[0])}else{if(b.inArray(this.element.val(),this.settings.source)===-1){this.setSelectedIcon()}else{this.setSelectedIcon(this.element.val())}}},setHighlightedIcon:function(){this.iconContainer.find(".current-icon").removeClass("current-icon");if(this.currentIcon){this.iconContainer.find('[data-fip-value="'+this.currentIcon+'"]').parent("span").addClass("current-icon")}},setSelectedIcon:function(e){if(e==="fip-icon-block"){e=""}if(this.settings.useAttribute){if(e){this.iconPicker.find(".selected-icon").html("<i "+this.settings.attributeName+'="'+(this.settings.convertToHex?"&#x"+parseInt(e,10).toString(16)+";":e)+'"></i>')}else{this.iconPicker.find(".selected-icon").html('<i class="fip-icon-block"></i>')}}else{this.iconPicker.find(".selected-icon").html('<i class="'+(e||"fip-icon-block")+'"></i>')}this.element.val((e===""?this.settings.emptyIconValue:e)).trigger("change");if(this.triggerEvent!==null){for(var d in this.triggerEvent){this.element.trigger(this.triggerEvent[d])}}this.currentIcon=e;this.setHighlightedIcon()},toggleIconSelector:function(){this.open=(!this.open)?1:0;this.iconPicker.find(".selector-popup").slideToggle(300);this.iconPicker.find(".selector-button i").toggleClass("fip-icon-down-dir");this.iconPicker.find(".selector-button i").toggleClass("fip-icon-up-dir");if(this.open){this.iconPicker.find(".icons-search-input").focus().select()}},resetSearch:function(){this.iconPicker.find(".icons-search-input").val("");this.searchIcon.removeClass("fip-icon-cancel");this.searchIcon.addClass("fip-icon-search");this.iconPicker.find(".selector-arrow-left").hide();this.currentPage=1;this.isSearch=false;this.renderIconContainer();if(this.totalPage>1){this.iconPicker.find(".selector-arrow-right").show()}}};b.fn.fontIconPicker=function(d){this.each(function(){if(!b.data(this,"fontIconPicker")){b.data(this,"fontIconPicker",new a(this,d))}});this.setIcons=b.proxy(function(f,e){if(undefined===f){f=false}if(undefined===e){e=false}this.each(function(){b.data(this,"fontIconPicker").settings.source=f;b.data(this,"fontIconPicker").settings.searchSource=e;b.data(this,"fontIconPicker").initSourceIndex();b.data(this,"fontIconPicker").resetSearch();b.data(this,"fontIconPicker").loadIcons()})},this);this.destroyPicker=b.proxy(function(){this.each(function(){if(!b.data(this,"fontIconPicker")){return}b.data(this,"fontIconPicker").iconPicker.remove();b.data(this,"fontIconPicker").element.css({visibility:"",top:"",position:"",zIndex:"",left:"",display:"",height:"",width:"",padding:"",margin:"",border:"",verticalAlign:""});b.removeData(this,"fontIconPicker")})},this);this.refreshPicker=b.proxy(function(e){if(!e){e=d}this.destroyPicker();this.each(function(){if(!b.data(this,"fontIconPicker")){b.data(this,"fontIconPicker",new a(this,e))}})},this);return this}})(jQuery);