PHP Classes

File: public/assets/bootstrap-iconpicker/js/bootstrap-iconpicker.min.js

Recommend this page to a friend!
  Classes of Aby Dahana   Aksara   public/assets/bootstrap-iconpicker/js/bootstrap-iconpicker.min.js   Download  
File: public/assets/bootstrap-iconpicker/js/bootstrap-iconpicker.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Aksara
A CodeIgniter based API and CRUD generator
Author: By
Last change: Fixing iconpicker (BS5 related)

- Fixing iconpicker popover that popped out when clicked;
- Add "text" to set_field method to prevent the numeric value aligned to right
Initial commit for update 4.4.0

- Refine core modules and plugin;
- Removing unnecessary dependencies.
Update commit for the version 4.3.3

Updates for this commit:
- Updating the default dependency of Bootstrap, now using Bootstrap version 5;
- Updating the minimum CI version to ^4.2.0;
- Secrete the Bootstrap framework as the required dependency, now you can create your own theme without concern to conflict with Bootstrap;
- Refine the Aksara core including its components;
- Fixing the feature that previously broken.
Date: 1 year ago
Size: 10,477 bytes
 

Contents

Class file image Download
/*!======================================================================== * File: bootstrap-iconpicker.js v1.10.0 by @victor-valencia * https://victor-valencia.github.com/bootstrap-iconpicker * ======================================================================== * Copyright 2013-2018 Victor Valencia Rico. * Licensed under MIT license. * https://github.com/victor-valencia/bootstrap-iconpicker/blob/master/LICENSE * ======================================================================== */ !function(p){"use strict";var a=function(t,e){this.$element=p(t),this.options=p.extend({},a.DEFAULTS,this.$element.data()),this.options=p.extend({},this.options,e)};a.VERSION="1.10.0",a.ICONSET_EMPTY={iconClass:"",iconClassFix:"",icons:[]},a.ICONSET={_custom:null,elusiveicon:p.iconset_elusiveicon||a.ICONSET_EMPTY,flagicon:p.iconset_flagicon||a.ICONSET_EMPTY,fontawesome4:p.iconset_fontawesome_4||a.ICONSET_EMPTY,fontawesome5:p.iconset_fontawesome_5||a.ICONSET_EMPTY,glyphicon:p.iconset_glyphicon||a.ICONSET_EMPTY,ionicon:p.iconset_ionicon||a.ICONSET_EMPTY,mapicon:p.iconset_mapicon||a.ICONSET_EMPTY,materialdesign:p.iconset_materialdesign||a.ICONSET_EMPTY,octicon:p.iconset_octicon||a.ICONSET_EMPTY,typicon:p.iconset_typicon||a.ICONSET_EMPTY,weathericon:p.iconset_weathericon||a.ICONSET_EMPTY},a.DEFAULTS={align:"center",arrowClass:"btn-primary",arrowNextIconClass:"mdi mdi-arrow-right",arrowPrevIconClass:"mdi mdi-arrow-left",cols:4,icon:"",iconset:"materialdesign",iconsetVersion:"lastest",header:!0,labelHeader:"{0} / {1}",footer:!0,labelFooter:"{0} - {1} of {2}",placement:"bottom",rows:4,search:!0,searchText:"Search icon",selectedClass:"btn-warning",unselectedClass:"btn-secondary"},a.prototype.bindEvents=function(){var e=this.options,o=this;e.table.find(".btn-previous, .btn-next").off("click").on("click",function(t){t.preventDefault(),p(this).hasClass("disabled")||(t=parseInt(p(this).val(),10),o.changeList(e.page+t))}),e.table.find(".btn-icon").off("click").on("click",function(t){t.preventDefault(),o.select(p(this).val()),!1===e.inline?o.$element.popover("dispose"):e.table.find("i[class$='"+p(this).val()+"']").parent().addClass(e.selectedClass)}),e.table.find(".search-control").off("keyup").on("keyup",function(){o.changeList(1)})},a.prototype.changeList=function(t){this.filterIcons(),this.updateLabels(t),this.updateIcons(t),this.options.page=t,this.bindEvents()},a.prototype.filterIcons=function(){var o,s=this.options,n=s.table.find(".search-control").val(),i=[];"lastest"!=s.iconsetVersion&&void 0!==a.ICONSET[s.iconset].allVersions?p.each(a.ICONSET[s.iconset].allVersions,function(t,e){s.iconsetVersion==e.version&&(i=e.icons)}):i=a.ICONSET[s.iconset].icons,""===n?s.icons=i:(o=[],p.each(i,function(t,e){-1<e.toLowerCase().indexOf(n)&&o.push(e)}),s.icons=o)},a.prototype.removeAddClass=function(t,e,o){return this.options.table.find(t).removeClass(e).addClass(o),o},a.prototype.reset=function(){this.updatePicker(),this.changeList(1)},a.prototype.select=function(t){var e=this.options,o=this.$element;e.selected=p.inArray(t.replace(e.iconClassFix,""),e.icons),-1===e.selected&&(e.selected=0,t=e.iconClassFix+e.icons[e.selected]),""!==t&&0<=e.selected&&(e.icon=t,!1===e.inline&&(o.find("input").val(t),o.find("i").attr("class","").addClass(e.iconClass).addClass(t)),t===e.iconClassFix?o.trigger({type:"change",icon:"empty"}):(o.trigger({type:"change",icon:t}),o.find("input").val(t)),e.table.find("button."+e.selectedClass).removeClass(e.selectedClass))},a.prototype.switchPage=function(t){var e,o=this.options;o.selected=p.inArray(t.replace(o.iconClassFix,""),o.icons),0<=o.selected&&(e=Math.ceil((o.selected+1)/this.totalIconsPerPage()),this.changeList(e)),(""===t?o.table.find("i."+o.iconClassFix):o.table.find("i."+t)).parent().addClass(o.selectedClass)},a.prototype.totalPages=function(){return Math.ceil(this.totalIcons()/this.totalIconsPerPage())},a.prototype.totalIcons=function(){return this.options.icons.length},a.prototype.totalIconsPerPage=function(){return 0===this.options.rows?this.options.icons.length:this.options.cols*this.options.rows},a.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")},a.prototype.updateIcons=function(t){var e=this.options,o=e.table.find("tbody").empty(),s=(t-1)*this.totalIconsPerPage(),n=e.rows;0===e.rows&&(n=e.icons.length);for(var i=0;i<n;i++){for(var a=p("<tr></tr>"),c=0;c<e.cols;c++){var r=s+i*e.cols+c,l=p('<button class="btn '+e.unselectedClass+' btn-icon"></button>').hide();r<e.icons.length&&(r=e.iconClassFix+e.icons[r],l.val(r).attr("title",r).append('<i class="'+e.iconClass+" "+r+'"></i>').show(),e.icon===r&&l.addClass(e.selectedClass).addClass("btn-icon-selected")),a.append(p("<td></td>").append(l))}o.append(a)}},a.prototype.updateIconsCount=function(){var t,e=this.options;!0===e.footer&&(t=["<tr>",'<td colspan="'+e.cols+'" class="text-center">','<span class="icons-count"></span>'," </td>","</tr>"],e.table.find("tfoot").empty().append(t.join("")))},a.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("{1}",s));var n=(t-1)*this.totalIconsPerPage(),s=t*this.totalIconsPerPage();e.table.find(".icons-count").html(e.labelFooter.replace("{0}",o?1+n:0).replace("{1}",s<o?s:o).replace("{2}",o)),this.updateArrows(t)},a.prototype.updatePagesCount=function(){var t=this.options;if(!0===t.header){for(var e=p("<tr></tr>"),o=0;o<t.cols;o++){var s,n=p('<td class="text-center"></td>');0===o||o===t.cols-1?(s=['<button class="btn btn-arrow '+(0===o?"btn-previous":"btn-next")+" "+t.arrowClass+'" value="'+(0===o?-1:1)+'">','<span class="'+(0===o?t.arrowPrevIconClass:t.arrowNextIconClass)+'"></span>',"</button>"],n.append(s.join("")),e.append(n)):0===e.find(".page-count").length&&(n.attr("colspan",t.cols-2).append('<span class="page-count"></span>'),e.append(n))}t.table.find("thead").empty().append(e)}},a.prototype.updatePicker=function(){var t=this.options;if(t.cols<4)throw"Iconpicker => The number of columns must be greater than or equal to 4. [option.cols = "+t.cols+"]";if(t.rows<0)throw"Iconpicker => The number of rows must be greater than or equal to 0. [option.rows = "+t.rows+"]";this.updatePagesCount(),this.updateSearch(),this.updateIconsCount()},a.prototype.updateSearch=function(){var t=this.options,e=["<tr>",'<td colspan="'+t.cols+'">','<input type="text" class="form-control form-control-sm search-control" style="width: '+41*t.cols+'px;" placeholder="'+t.searchText+'">',"</td>","</tr>"],e=p(e.join(""));!0===t.search?e.show():e.hide(),t.table.find("thead").append(e)},a.prototype.setAlign=function(t){this.$element.removeClass(this.options.align).addClass(t),this.options.align=t},a.prototype.setArrowClass=function(t){this.options.arrowClass=this.removeAddClass(".btn-arrow",this.options.arrowClass,t)},a.prototype.setArrowNextIconClass=function(t){this.options.arrowNextIconClass=this.removeAddClass(".btn-next > span",this.options.arrowNextIconClass,t)},a.prototype.setArrowPrevIconClass=function(t){this.options.arrowPrevIconClass=this.removeAddClass(".btn-previous > span",this.options.arrowPrevIconClass,t)},a.prototype.setCols=function(t){this.options.cols=t,this.reset()},a.prototype.setFooter=function(t){var e=this.options.table.find("tfoot");!0===t?e.show():e.hide(),this.options.footer=t},a.prototype.setHeader=function(t){var e=this.options.table.find("thead");!0===t?e.show():e.hide(),this.options.header=t},a.prototype.setIcon=function(t){this.select(t)},a.prototype.setIconset=function(t){var e=this.options;p.isPlainObject(t)?(a.ICONSET._custom=p.extend(a.ICONSET_EMPTY,t),e.iconset="_custom"):a.ICONSET.hasOwnProperty(t)?e.iconset=t:e.iconset=a.DEFAULTS.iconset,e=p.extend(e,a.ICONSET[e.iconset]),this.reset(),this.select(e.icon)},a.prototype.setLabelHeader=function(t){this.options.labelHeader=t,this.updateLabels(this.options.page)},a.prototype.setLabelFooter=function(t){this.options.labelFooter=t,this.updateLabels(this.options.page)},a.prototype.setPlacement=function(t){this.options.placement=t},a.prototype.setRows=function(t){this.options.rows=t,this.reset()},a.prototype.setSearch=function(t){var e=this.options.table.find(".search-control");!0===t?e.show():e.hide(),e.val(""),this.changeList(1),this.options.search=t},a.prototype.setSearchText=function(t){this.options.table.find(".search-control").attr("placeholder",t).trigger("focus"),this.options.searchText=t},a.prototype.setSelectedClass=function(t){this.options.selectedClass=this.removeAddClass(".btn-icon-selected",this.options.selectedClass,t)},a.prototype.setUnselectedClass=function(t){this.options.unselectedClass=this.removeAddClass(".btn-icon",this.options.unselectedClass,t)};var t=p.fn.iconpicker;p.fn.iconpicker=function(n,i){return this.each(function(){var e=p(this),o=e.data("bs.iconpicker"),t="object"==typeof n&&n;if(o||e.data("bs.iconpicker",o=new a(this,t)),"string"==typeof n){if(void 0===o[n])throw'Iconpicker => The "'+n+'" method does not exists.';o[n](i)}else{var s=o.options,s=p.extend(s,{inline:!1,page:1,selected:-1,table:p('<table class="table-icons"><thead></thead><tbody></tbody><tfoot></tfoot></table>')}),t=void 0!==e.attr("name")?'name="'+e.attr("name")+'"':"";"BUTTON"===e.prop("tagName")?(e.empty().append("<i></i>").append('<input type="hidden" '+t+"></input>").append('<span class="caret"></span>').addClass("iconpicker dropdown-toggle"),o.setIconset(s.iconset),e.off("click").on("click",function(t){t.preventDefault(),e.popover({animation:!1,trigger:"manual",html:!0,content:s.table,container:e.closest("form"),placement:s.placement}).on("shown.bs.popover",function(){o.switchPage(s.icon),o.bindEvents()}),e.popover("hide"),e.popover("show")})):(s.inline=!0,o.setIconset(s.iconset),e.empty().append('<input type="hidden" '+t+"></input>").append(s.table).addClass("iconpicker").addClass(s.align),o.switchPage(s.icon),o.bindEvents())}})},p.fn.iconpicker.Constructor=a,p.fn.iconpicker.noConflict=function(){return p.fn.iconpicker=t,this},p(document).on("click","body",function(t){p(".iconpicker").each(function(){p(this).is(t.target)||0!==p(this).has(t.target).length||0!==p(".popover").has(t.target).length||p(this).popover("dispose")})}),p('[role="iconpicker"]').iconpicker()}(jQuery);