????
Current Path : /home2/morganrand/.trash/js_composer/assets/lib/bower/vcIconPicker/ |
Current File : /home2/morganrand/.trash/js_composer/assets/lib/bower/vcIconPicker/jquery.fonticonpicker.min.js |
!function($){"use strict";function Plugin(element,options){this.element=$(element),this.settings=$.extend({},defaults,options),this.settings.emptyIcon&&this.settings.iconsPerPage--,this.iconPicker=$("<div/>",{"class":this.settings.mainClass,style:"position: relative",html:'<div class="selector"><span class="selected-icon"><i class="fip-block-icon '+this.settings.iconBlockClass+'"></i></span><span class="selector-button"><i class="'+this.settings.iconDownClass+'"></i></span></div><div class="selector-popup" style="display: none;">'+(this.settings.hasSearch?'<div class="selector-search"><input type="text" name="" value="" placeholder="'+this.settings.searchPlaceholder+'" class="icons-search-input"/><i class="'+this.settings.iconSearchClass+'"></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="'+this.settings.iconLeftClass+'"></i></span><span class="selector-arrow-right"><i class="'+this.settings.iconRightClass+'"></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.initialized=!1,this.iconsPaged=!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 defaults={theme:"fip-vc-theme-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",iconDownClass:"fip-icon-down-dir",iconUpClass:"fip-icon-up-dir",iconLeftClass:"fip-icon-left-dir",iconRightClass:"fip-icon-right-dir",iconSearchClass:"fip-icon-search",iconCancelClass:"fip-icon-cancel",iconSpinClass:"fip-icon-spin3",iconBlockClass:"fip-icon-block",searchPlaceholder:"Search Icon",mainClass:"vc-icons-selector"};Plugin.prototype={init:function(){this.iconPicker.addClass(this.settings.theme),this.iconPicker.css({left:-9999}).appendTo("body");var iconPickerHeight=this.iconPicker.outerHeight(),iconPickerWidth=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:"-"+iconPickerWidth+"px",display:"none",height:iconPickerHeight+"px",width:iconPickerWidth+"px",padding:"0",margin:"0 -"+iconPickerWidth+"px 0 0",border:"0 none",verticalAlign:"top"}).hide(),!this.element.is("select")){var ieVersion=function(){for(var v=3,div=document.createElement("div"),a=div.all||[];div.innerHTML="<!--[if gt IE "+ ++v+"]><br><![endif]-->",a[0];);return v>4?v:!v}(),el=document.createElement("div");this.triggerEvent=9!==ieVersion&&"oninput"in el?["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($.proxy(function(i,el){var thisCategoryKey=this.availableCategories.length,categoryOption=$("<option />");categoryOption.attr("value",thisCategoryKey),categoryOption.html($(el).attr("label")),this.selectCategory.append(categoryOption),this.availableCategories[thisCategoryKey]=[],this.availableCategoriesSearch[thisCategoryKey]=[],$(el).find("option").each($.proxy(function(i,cel){var newIconValue=$(cel).val(),newIconLabel=$(cel).html();newIconValue&&newIconValue!==this.settings.emptyIconValue&&(this.settings.source.push(newIconValue),this.availableCategories[thisCategoryKey].push(newIconValue),this.searchValues.push(newIconLabel),this.availableCategoriesSearch[thisCategoryKey].push(newIconLabel))},this))},this)),this.element.find("> option").length&&this.element.find("> option").each($.proxy(function(i,el){var newIconValue=$(el).val(),newIconLabel=$(el).html();return newIconValue&&""!==newIconValue&&newIconValue!=this.settings.emptyIconValue?(null===this.unCategorizedKey&&(this.unCategorizedKey=this.availableCategories.length,this.availableCategories[this.unCategorizedKey]=[],this.availableCategoriesSearch[this.unCategorizedKey]=[],$("<option />").attr("value",this.unCategorizedKey).html(this.settings.unCategorizedText).appendTo(this.selectCategory)),this.settings.source.push(newIconValue),this.availableCategories[this.unCategorizedKey].push(newIconValue),this.searchValues.push(newIconLabel),void this.availableCategoriesSearch[this.unCategorizedKey].push(newIconLabel)):!0},this))):this.element.find("option").each($.proxy(function(i,el){var newIconValue=$(el).val(),newIconLabel=$(el).html();newIconValue&&(this.settings.source.push(newIconValue),this.searchValues.push(newIconLabel))},this)),this.backupSource=this.settings.source.slice(0),this.backupSearch=this.searchValues.slice(0),this.loadCategories()):this.initSourceIndex(),this.loadIcons(),this.selectCategory.on("change keyup",$.proxy(function(e){if(this.isCategorized===!1)return!1;var targetSelect=$(e.currentTarget),currentCategory=targetSelect.val();if("all"===targetSelect.val())this.settings.source=this.backupSource,this.searchValues=this.backupSearch;else{var key=parseInt(currentCategory,10);this.availableCategories[key]&&(this.settings.source=this.availableCategories[key],this.searchValues=this.availableCategoriesSearch[key])}this.resetSearch(),this.loadIcons()},this)),this.iconPicker.find(".selector-button").click($.proxy(function(){this.toggleIconSelector()},this)),this.iconPicker.find(".selector-arrow-right").click($.proxy(function(e){this.currentPage<this.totalPage&&(this.iconPicker.find(".selector-arrow-left").show(),this.currentPage=this.currentPage+1,this.renderIconContainer(),this.renderIcons()),this.currentPage===this.totalPage&&$(e.currentTarget).hide()},this)),this.iconPicker.find(".selector-arrow-left").click($.proxy(function(e){this.currentPage>1&&(this.iconPicker.find(".selector-arrow-right").show(),this.currentPage=this.currentPage-1,this.renderIconContainer(),this.renderIcons()),1===this.currentPage&&$(e.currentTarget).hide()},this)),this.iconPicker.find(".icons-search-input").keyup($.proxy(function(e){var searchString=$(e.currentTarget).val();return""===searchString?void this.resetSearch():(this.searchIcon.removeClass(this.settings.iconSearchClass),this.searchIcon.addClass(this.settings.iconCancelClass),this.isSearch=!0,this.currentPage=1,this.iconsSearched=[],$.grep(this.searchValues,$.proxy(function(n,i){return n.toLowerCase().search(searchString.toLowerCase())>=0?(this.iconsSearched[this.iconsSearched.length]=this.settings.source[i],!0):void 0},this)),this.iconsSearched=this.iconsSearched.filter(this.getOnlyUnique),this.renderIconContainer(),void this.renderIcons())},this)),this.iconPicker.find(".selector-search i").on("click",$.proxy(function(){this.iconPicker.find(".icons-search-input").focus(),this.resetSearch()},this)),this.iconContainer.on("click",".fip-box",$.proxy(function(e){this.setSelectedIcon($(e.currentTarget).find("i").attr("data-fip-value")),this.toggleIconSelector()},this)),this.iconPicker.click(function(event){return event.stopPropagation(),!1}),$("html").click($.proxy(function(){this.open&&this.toggleIconSelector()},this))},getOnlyUnique:function(value,index,self){return self.indexOf(value)===index},initSourceIndex:function(){if("object"==typeof this.settings.source){if($.isArray(this.settings.source))this.isCategorized=!1,this.selectCategory.html("").hide(),this.settings.source=$.map(this.settings.source,function(e){return"function"==typeof e.toString?e.toString():e}),this.searchValues=$.isArray(this.settings.searchSource)?$.map(this.settings.searchSource,function(e){return"function"==typeof e.toString?e.toString():e}):this.settings.source.slice(0);else{var originalSource=$.extend(!0,{},this.settings.source);this.settings.source=[],this.searchValues=[],this.availableCategoriesSearch=[],this.selectedCategory=!1,this.availableCategories=[],this.unCategorizedKey=null,this.isCategorized=!0,this.selectCategory.html("");for(var categoryLabel in originalSource){var thisCategoryKey=this.availableCategories.length,categoryOption=$("<option />");categoryOption.attr("value",thisCategoryKey),categoryOption.html(categoryLabel),this.selectCategory.append(categoryOption),this.availableCategories[thisCategoryKey]=[],this.availableCategoriesSearch[thisCategoryKey]=[];for(var newIconKey in originalSource[categoryLabel]){var newIconValue=originalSource[categoryLabel][newIconKey],newIconLabel=this.settings.searchSource&&this.settings.searchSource[categoryLabel]&&this.settings.searchSource[categoryLabel][newIconKey]?this.settings.searchSource[categoryLabel][newIconKey]:newIconValue;"function"==typeof newIconValue.toString&&(newIconValue=newIconValue.toString()),newIconValue&&newIconValue!==this.settings.emptyIconValue&&(this.settings.source.push(newIconValue),this.availableCategories[thisCategoryKey].push(newIconValue),this.searchValues.push(newIconLabel),this.availableCategoriesSearch[thisCategoryKey].push(newIconLabel))}}}this.backupSource=this.settings.source.slice(0),this.backupSearch=this.searchValues.slice(0),this.loadCategories()}},loadCategories:function(){this.isCategorized!==!1&&($('<option value="all">'+this.settings.allCategoryText+"</option>").prependTo(this.selectCategory),this.selectCategory.show().val("all").trigger("change"))},loadIcons:function(){this.iconContainer.html('<i class="'+this.settings.iconSpinClass+' animate-spin loading"></i>'),this.settings.source instanceof Array&&(this.renderIconContainer(),this.setContainerSelectedItems())},renderIconContainer:function(){var offset,iconsPaged=[];if(iconsPaged=this.isSearch?this.iconsSearched:this.settings.source,this.iconsCount=iconsPaged.length,this.totalPage=Math.ceil(this.iconsCount/this.settings.iconsPerPage),this.totalPage>1?this.iconPicker.find(".selector-footer").show():this.iconPicker.find(".selector-footer").hide(),this.iconPicker.find(".selector-pages").html(this.currentPage+"/"+this.totalPage+" <em>("+this.iconsCount+")</em>"),offset=(this.currentPage-1)*this.settings.iconsPerPage,this.settings.emptyIcon)this.iconContainer.html('<span class="fip-box"><i class="fip-block-icon '+this.settings.iconBlockClass+'" data-fip-value="'+this.settings.iconBlockClass+'"></i></span>');else{if(iconsPaged.length<1)return void this.iconContainer.html('<span class="icons-picker-error"><i class="fip-block-icon '+this.settings.iconBlockClass+'" data-fip-value="'+this.settings.iconBlockClass+'"></i></span>');this.iconContainer.html("")}iconsPaged=iconsPaged.slice(offset,offset+this.settings.iconsPerPage),this.iconsPaged=iconsPaged},setContainerSelectedItems:function(){this.settings.emptyIcon||this.element.val()&&-1!==$.inArray(this.element.val(),this.settings.source)?-1===$.inArray(this.element.val(),this.settings.source)?this.setSelectedIcon():this.setSelectedIcon(this.element.val()):this.setSelectedIcon(this.iconsPaged[0])},setHighlightedIcon:function(){this.iconContainer.find(".current-icon").removeClass("current-icon"),this.currentIcon&&this.iconContainer.find('[data-fip-value="'+this.currentIcon+'"]').parent("span").addClass("current-icon")},setSelectedIcon:function(theIcon){if(theIcon===this.settings.iconBlockClass&&(theIcon=""),this.iconPicker.find(".selected-icon").html(this.settings.useAttribute?theIcon?"<i "+this.settings.attributeName+'="'+(this.settings.convertToHex?"&#x"+parseInt(theIcon,10).toString(16)+";":theIcon)+'"></i>':'<i class="fip-block-icon '+this.settings.iconBlockClass+'"></i>':'<i class="'+(theIcon||"fip-block-icon "+this.settings.iconBlockClass)+'"></i>'),this.element.val(""===theIcon?this.settings.emptyIconValue:theIcon).trigger("change"),null!==this.triggerEvent)for(var eventKey in this.triggerEvent)this.element.trigger(this.triggerEvent[eventKey]);this.currentIcon=theIcon,this.setHighlightedIcon()},toggleIconSelector:function(){this.open=this.open?0:1,this.iconPicker.find(".selector-popup").slideToggle(300),this.iconPicker.find(".selector-button i").toggleClass(this.settings.iconDownClass),this.iconPicker.find(".selector-button i").toggleClass(this.settings.iconUpClass),this.open&&(this.iconPicker.find(".icons-search-input").focus().select(),this.initialized||(this.renderIcons(),this.initialized=!0))},renderIcons:function(){for(var item,i=0;item=this.iconsPaged[i++];){var flipBoxTitle=item;$.grep(this.settings.source,$.proxy(function(e,i){return e===item?(flipBoxTitle=this.searchValues[i],!0):!1},this)),$("<span/>",{html:'<i data-fip-value="'+item+'" '+(this.settings.useAttribute?this.settings.attributeName+'="'+(this.settings.convertToHex?"&#x"+parseInt(item,10).toString(16)+";":item)+'"':'class="'+item+'"')+"></i>","class":"fip-box",title:flipBoxTitle}).appendTo(this.iconContainer)}this.setContainerSelectedItems()},resetSearch:function(){this.iconPicker.find(".icons-search-input").val(""),this.searchIcon.removeClass(this.settings.iconCancelClass),this.searchIcon.addClass(this.settings.iconSearchClass),this.iconPicker.find(".selector-arrow-left").hide(),this.currentPage=1,this.isSearch=!1,this.renderIconContainer(),this.renderIcons(),this.totalPage>1&&this.iconPicker.find(".selector-arrow-right").show()}},$.fn.vcFontIconPicker=function(options){return this.each(function(){$.data(this,"vcFontIconPicker")||$.data(this,"vcFontIconPicker",new Plugin(this,options))}),this.setIcons=$.proxy(function(newIcons,iconSearch){void 0===newIcons&&(newIcons=!1),void 0===iconSearch&&(iconSearch=!1),this.each(function(){$.data(this,"vcFontIconPicker").settings.source=newIcons,$.data(this,"vcFontIconPicker").settings.searchSource=iconSearch,$.data(this,"vcFontIconPicker").initSourceIndex(),$.data(this,"vcFontIconPicker").resetSearch(),$.data(this,"vcFontIconPicker").loadIcons()})},this),this.destroyPicker=$.proxy(function(){this.each(function(){$.data(this,"vcFontIconPicker")&&($.data(this,"vcFontIconPicker").iconPicker.remove(),$.data(this,"vcFontIconPicker").element.css({visibility:"",top:"",position:"",zIndex:"",left:"",display:"block",height:"",width:"",padding:"",margin:"",border:"",verticalAlign:""}).show(),$.removeData(this,"vcFontIconPicker"))})},this),this.refreshPicker=$.proxy(function(newOptions){newOptions||(newOptions=options),this.destroyPicker(),this.each(function(){$.data(this,"vcFontIconPicker")||$.data(this,"vcFontIconPicker",new Plugin(this,newOptions))})},this),this}}(jQuery);