Skip to content

Commit 274e3f3

Browse files
Add search field.
1 parent bd2319f commit 274e3f3

File tree

7 files changed

+79
-15
lines changed

7 files changed

+79
-15
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [Bootstrap-Iconpicker v1.4.0](http://victor-valencia.github.io/bootstrap-iconpicker)
1+
# [Bootstrap-Iconpicker v1.5.0](http://victor-valencia.github.io/bootstrap-iconpicker)
22
![Iconpicker](bootstrap-iconpicker.png)
33

44
A simple iconpicker for Bootstrap 3.
@@ -18,7 +18,7 @@ Please note that this project is for <a href="http://getbootstrap.com/"><strong>
1818

1919
Three quick start options are available:
2020

21-
- [Download the latest release](https://github.com/victor-valencia/bootstrap-iconpicker/archive/v1.4.0.zip).
21+
- [Download the latest release](https://github.com/victor-valencia/bootstrap-iconpicker/archive/v1.5.0.zip).
2222
- Clone the repo: `git clone https://github.com/victor-valencia/bootstrap-iconpicker.git`.
2323
- Install with [Bower](http://bower.io): `bower install bootstrap-iconpicker`.
2424

@@ -56,6 +56,7 @@ See documentation and live examples here: <a href="http://victor-valencia.github
5656
- v1.3.0 - Support multiple versions of FontAwesome. @[victor-valencia](https://github.com/victor-valencia)
5757
- v1.3.1 - Bind body 'click' to solve issues for ajax loaded pages. @[crlcu](https://github.com/crlcu)
5858
- v1.4.0 - Support for customization of the component. @[victor-valencia](https://github.com/victor-valencia)
59+
- v1.5.0 - Add search field. @[victor-valencia](https://github.com/victor-valencia)
5960

6061
## Versioning
6162
For transparency into our release cycle and in striving to maintain backward compatibility, Bootstrap is maintained under [the Semantic Versioning guidelines](http://semver.org/). Sometimes we screw up, but we'll adhere to those rules whenever possible.

bootstrap-iconpicker.png

3.11 KB
Loading

bootstrap-iconpicker/css/bootstrap-iconpicker.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Bootstrap-iconpicker v1.4.0
2+
* Bootstrap-iconpicker v1.5.0
33
*
44
* Copyright 2013-2014 Victor Valencia Rico.
55
* Licensed under the Apache License v2.0
@@ -24,10 +24,19 @@
2424
margin: 2px;
2525
}
2626

27+
.table-icons td{
28+
min-width: 39px;
29+
}
30+
2731
.popover {
2832
max-width: inherit !important;
2933
}
3034

3135
.iconpicker-popover {
3236
z-index: 1050 !important;
37+
}
38+
39+
.iconpicker-popover .search-control {
40+
margin-bottom: 6px;
41+
margin-top: 6px;
3342
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/*!
2-
* Bootstrap-iconpicker v1.4.0
2+
* Bootstrap-iconpicker v1.5.0
33
*
44
* Copyright 2013-2014 Victor Valencia Rico.
55
* Licensed under the Apache License v2.0
66
* http://www.apache.org/licenses/LICENSE-2.0
77
*
88
* Designed and built with all the love in the world by @recktoner.
9-
*/.iconpicker .caret{margin-left:10px!important}.iconpicker{min-width:60px}.table-icons .btn{min-height:30px;min-width:35px;text-align:center;padding:0;margin:2px}.popover{max-width:inherit!important}.iconpicker-popover{z-index:1050!important}
9+
*/
10+
.iconpicker .caret{margin-left:10px!important}.iconpicker{min-width:60px}.table-icons .btn{min-height:30px;min-width:35px;text-align:center;padding:0;margin:2px}.table-icons td{min-width:39px}.popover{max-width:inherit!important}.iconpicker-popover{z-index:1050!important}.iconpicker-popover .search-control{margin-bottom:6px;margin-top:6px}

bootstrap-iconpicker/js/bootstrap-iconpicker.js

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* ========================================================================
2-
* Bootstrap: bootstrap-iconpicker.js v1.4.0 by @recktoner
2+
* Bootstrap: bootstrap-iconpicker.js v1.5.0 by @recktoner
33
* https://victor-valencia.github.com/bootstrap-iconpicker
44
* ========================================================================
55
* Copyright 2013-2014 Victor Valencia Rico.
@@ -243,7 +243,9 @@
243243
placement: 'bottom',
244244
arrowClass: 'btn-primary',
245245
selectedClass: 'btn-warning',
246-
unselectedClass: 'btn-default'
246+
unselectedClass: 'btn-default',
247+
search: true,
248+
searchText: 'Search icon'
247249
};
248250

249251
Iconpicker.prototype.createButtonBar = function(){
@@ -265,16 +267,26 @@
265267
}
266268
}
267269
op.table.find('thead').append(tr);
270+
if(op.search == true){
271+
var search = [
272+
'<tr>',
273+
' <td colspan="' + op.cols + '">',
274+
' <input type="text" class="form-control search-control" style="width: ' + op.cols * 39 + 'px;" placeholder="' + op.searchText + '">',
275+
' </td>',
276+
'</tr>'
277+
];
278+
op.table.find('thead').append(search.join(''));
279+
}
268280
};
269281

270282
Iconpicker.prototype.updateButtonBar = function(page){
271283
var op = this.options;
272284
var total_pages = Math.ceil( op.icons.length / (op.cols * op.rows) );
273-
op.table.find('.page-count').html(page + ' / ' + total_pages);
285+
op.table.find('.page-count').html(((total_pages == 0 ) ? 0: page) + ' / ' + total_pages);
274286
var btn_prev = op.table.find('.btn-previous');
275287
var btn_next = op.table.find('.btn-next');
276288
(page == 1) ? btn_prev.addClass('disabled'): btn_prev.removeClass('disabled');
277-
(page == total_pages) ? btn_next.addClass('disabled'): btn_next.removeClass('disabled');
289+
(page == total_pages || total_pages == 0) ? btn_next.addClass('disabled'): btn_next.removeClass('disabled');
278290
};
279291

280292
Iconpicker.prototype.bindEvents = function(){
@@ -288,6 +300,9 @@
288300
el.select($(this).val());
289301
el.$element.popover('destroy');
290302
});
303+
op.table.find('.search-control').off('keyup').on('keyup', function(e){
304+
el.changeList(1);
305+
});
291306
};
292307

293308
Iconpicker.prototype.select = function(icon){
@@ -319,6 +334,22 @@
319334

320335
Iconpicker.prototype.changeList = function(page){
321336
var op = this.options;
337+
var search = "";
338+
if(op.search == true){
339+
search = op.table.find('.search-control').val();
340+
if(search == ""){
341+
op.icons = Iconpicker.ICONSET[op.ic];
342+
}
343+
else{
344+
var result = [];
345+
$.each(Iconpicker.ICONSET[op.ic], function(i, v){
346+
if(v.indexOf(search) > -1){
347+
result.push(v);
348+
}
349+
});
350+
op.icons = result;
351+
}
352+
}
322353
this.updateButtonBar(page);
323354
var tbody = op.table.find('tbody').empty();
324355
var offset = (page - 1) * op.rows * op.cols;
@@ -358,6 +389,7 @@
358389
var op = data.options;
359390
var ic = (op.iconset == 'fontawesome') ? 'fa' : 'glyphicon';
360391
op = $.extend(op, {
392+
ic: ic,
361393
icons: Iconpicker.ICONSET[ic],
362394
iconClass: ic,
363395
iconClassFix: ic + '-',
@@ -371,7 +403,7 @@
371403
.append('<input type="hidden" ' + name + '></input>')
372404
.append('<span class="caret"></span>');
373405
$this.addClass('iconpicker');
374-
data.createButtonBar();
406+
data.createButtonBar();
375407
data.changeList(1);
376408
$this.on('click', function(e){
377409
e.preventDefault();

0 commit comments

Comments
 (0)