From 0bed4daddf482a78fc82c5cfa946cd39d939963b Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 8 May 2015 10:39:53 -0400 Subject: [PATCH] #141 Implement reset button and turn off shadows So you can actually see the highlighted icon --- js/bootstrap-iconpicker.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/bootstrap-iconpicker.js b/js/bootstrap-iconpicker.js index e7728453..2935db22 100644 --- a/js/bootstrap-iconpicker.js +++ b/js/bootstrap-iconpicker.js @@ -67,7 +67,8 @@ searchText: 'Search icon', selectedClass: 'btn-warning', unselectedClass: 'btn-default', - resetButton: true + resetButton: true, + noIconSelectedClass: 'glyphicon glyphicon-ban-circle' }; // ICONPICKER PRIVATE METHODS @@ -133,6 +134,16 @@ Iconpicker.prototype.select = function (icon) { var op = this.options; var el = this.$element; + if (icon === '') { + op.icon = ''; + el.find('input').val(''); + el.find('i').attr('class', op.noIconSelectedClass); + el.find('i').css('color', '#FF0000'); + el.trigger({type:"change", icon: ''}); + op.table.find('button.' + op.selectedClass).removeClass(op.selectedClass); + return; + } + for (var i = 0; i < op.icons.length; i++) { if (this.matchEx(op.icons[i], icon)) { icon = op.icons[i]; @@ -155,6 +166,7 @@ el.find('input').val(icoStr); el.find('i').attr('class', '').addClass(icon.iconClass).addClass(icon.iconClassFix + icon.icon); + el.find('i').css('color', '#000000'); el.trigger({ type: "change", icon: icoStr }); op.table.find('button.' + op.selectedClass).removeClass(op.selectedClass); } @@ -220,7 +232,7 @@ if (pos < op.icons.length) { var ico = op.icons[pos]; var v = ico.iconClassFix + ico.icon; - btn.val(v).attr('title', v).append('').data('icon-picker-icon', ico).show(); + btn.val(v).attr('title', v).append('').data('icon-picker-icon', ico).show(); if (this.matchEx(ico, op.icon)) { console.log('matched'); btn.addClass(op.selectedClass).addClass('btn-icon-selected'); @@ -317,7 +329,7 @@ var resetButton = [ '', '', - '', + '', '', '' ];