You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mods-for-HESK-Netsyms/js/bootstrap-iconpicker.min.js

19 lines
9.3 KiB
JavaScript

/* ========================================================================
* Bootstrap: bootstrap-iconpicker.js v1.6.0 by @recktoner
* https://victor-valencia.github.com/bootstrap-iconpicker
* ========================================================================
* Copyright 2013-2014 Victor Valencia Rico.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ======================================================================== */
!function(t){"use strict";var e=function(o,s){this.$element=t(o),this.options=t.extend({},e.DEFAULTS,this.$element.data()),this.options=t.extend({},this.options,s)};e.ICONSET_EMPTY={iconClass:"",iconClassFix:"",icons:[]},e.ICONSET={_custom:null,elusiveicon:t.iconset_elusiveicon||e.ICONSET_EMPTY,fontawesome:t.iconset_fontawesome||e.ICONSET_EMPTY,ionicon:t.iconset_ionicon||e.ICONSET_EMPTY,glyphicon:t.iconset_glyphicon||e.ICONSET_EMPTY,mapicon:t.iconset_mapicon||e.ICONSET_EMPTY,octicon:t.iconset_octicon||e.ICONSET_EMPTY,typicon:t.iconset_typicon||e.ICONSET_EMPTY,weathericon:t.iconset_weathericon||e.ICONSET_EMPTY},e.DEFAULTS={arrowClass:"btn-primary",arrowNextIconClass:"glyphicon glyphicon-arrow-right",arrowPrevIconClass:"glyphicon glyphicon-arrow-left",cols:4,icon:"",iconset:"glyphicon",labelHeader:"{0} / {1}",labelFooter:"{0} - {1} of {2}",placement:"bottom",rows:4,search:!0,searchText:"Search icon",selectedClass:"btn-warning",unselectedClass:"btn-default"},e.prototype.bindEvents=function(){var e=this.options,o=this;e.table.find(".btn-previous, .btn-next").off("click").on("click",function(){var s=parseInt(t(this).val(),10);o.changeList(e.page+s)}),e.table.find(".btn-icon").off("click").on("click",function(){o.select(t(this).val()),o.$element.popover("destroy")}),e.table.find(".search-control").off("keyup").on("keyup",function(){o.changeList(1)})},e.prototype.changeList=function(t){this.filterIcons(),this.updateLabels(t),this.updateIcons(t),this.options.page=t,this.bindEvents()},e.prototype.filterIcons=function(){var o=this.options,s=o.table.find(".search-control").val();if(""===s)o.icons=e.ICONSET[o.iconset].icons;else{var n=[];t.each(e.ICONSET[o.iconset].icons,function(t,e){e.indexOf(s)>-1&&n.push(e)}),o.icons=n}},e.prototype.removeAddClass=function(t,e,o){return this.options.table.find(t).removeClass(e).addClass(o),o},e.prototype.reset=function(){this.updatePicker(),this.changeList(1)},e.prototype.select=function(e){var o=this.options,s=this.$element;o.selected=t.inArray(e.replace(o.iconClassFix,""),o.icons),-1===o.selected&&(o.selected=0,e=o.iconClassFix+o.icons[o.selected]),""!==e&&o.selected>=0&&(o.icon=e,s.find("input").val(e),s.find("i").attr("class","").addClass(o.iconClass).addClass(e),s.trigger({type:"change",icon:e}),o.table.find("button."+o.selectedClass).removeClass(o.selectedClass))},e.prototype.switchPage=function(e){var o=this.options;if(o.selected=t.inArray(e.replace(o.iconClassFix,""),o.icons),""!==e&&o.selected>=0){var s=Math.ceil((o.selected+1)/this.totalIconsPerPage());this.changeList(s)}o.table.find("i."+e).parent().addClass(o.selectedClass)},e.prototype.totalPages=function(){return Math.ceil(this.totalIcons()/this.totalIconsPerPage())},e.prototype.totalIcons=function(){return this.options.icons.length},e.prototype.totalIconsPerPage=function(){return this.options.cols*this.options.rows},e.prototype.updateArrows=function(t){var e=this.options,o=this.totalPages();1===t?e.table.find(".btn-previous").addClass("disabled"):e.table.find(".btn-previous").removeClass("disabled"),t===o||0===o?e.table.find(".btn-next").addClass("disabled"):e.table.find(".btn-next").removeClass("disabled")},e.prototype.updateIcons=function(e){for(var o=this.options,s=o.table.find("tbody").empty(),n=(e-1)*this.totalIconsPerPage(),i=0;i<o.rows;i++){for(var a=t("<tr></tr>"),c=0;c<o.cols;c++){var r=n+i*o.cols+c,p=t('<button class="btn '+o.unselectedClass+' btn-icon"></button>').hide();if(r<o.icons.length){var l=o.iconClassFix+o.icons[r];p.val(l).attr("title",l).append('<i class="'+o.iconClass+" "+l+'"></i>').show(),o.icon===l&&p.addClass(o.selectedClass).addClass("btn-icon-selected")}a.append(t("<td></td>").append(p))}s.append(a)}},e.prototype.updateIconsCount=function(){var t=this.options,e=["<tr>",' <td colspan="'+t.cols+'" class="text-center">',' <span class="icons-count"></span>'," </td>","</tr>"];t.table.find("tfoot").empty().append(e.join(""))},e.prototype.updateLabels=function(t){var e=this.options,o=this.totalIcons(),s=this.totalPages();e.table.find(".page-count").html(e.labelHeader.replace("{0}",0===s?0:t).replace