<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!-- Sample by Mr. M. - Confederation College - IMD Program -->
<!-- from https://github.com/titosust/Bootstrap-icon-picker -->
<div class="container">
<div class="row">
<h2>Mr. M.'s Select TB icons with search.</h2>
<p>
<a href="http://getbootstrap.com/components/#glyphicons" target="_blank">Reference Documentation</a>
</p>
</div>
</div>
<div id="wraper">
<form method="post">
<input type="text" name="someName" class="icon-picker" placeholder="Click on icon and then search... " />
</form>
<hr>
<h3>How to change color of icons</h3>
With CSS you can change the color of icons.
<style>
.blue, .blue a {
color: #00f;
}
</style>
<span class="glyphicon glyphicon-search blue"></span>
</div> <!-- wraper -->
/*!
* Bootstrap 3.0 IconPicker Style
* Custom Style Elements for IconPicker
*
* Intigrated, Processed and Built with passion by @titosust; Web Developer @vizrt
*/
#wraper{position:absolute;width:400px; left:50%;margin-left: -200px;top:100px;}
input{padding-bottom: 30px;}
.icon-popup{
position: absolute;
width: 278px;
height: 268px;
color: #000;
font-size: 14px;
}
.icon-popup:before {
content: '';
display: inline-block;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-bottom-color: rgba(0,0,0,0.2);
position: absolute;
top: -7px;
left: 6px;
}
.icon-popup:after {
content: '';
display: inline-block;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
position: absolute;
top: -6px;
left: 7px;
}
.icon-popup a:hover{
background-color:#eee;
}
.icon-popup .icon-title{
position: relative;
background-color: #563d7c;
color: #fff;
border: 1px solid #463265;
}
.icon-popup .icon-title h4{
margin: 0;
padding: 8px 10px;
font-size: 17px;
font-weight: bold;
}
.pointer{
cursor: pointer;
}
.icon-popup .ip-control{
background-color: white;
height: 40px;
margin-top: -2px;
padding-top: 2px;
border-bottom: 1px solid #e5e5e5;
}
.icon-popup .ip-search{
width: 171px;
padding:2px 0px 5px 27px;
margin-left: 8px;
background-repeat: no-repeat;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAQAAAAEABcxq3DAAACcElEQVQ4y5XSQUiaYRgH8P+rzlSS6lKuZbkvvjq0NWfg0Xu1jO0gWbO5ctBtxDrtsE51CIJZgxWLMQbtsA7TQ5RX5ygPFbRD1rBJDko+ZtI++fT7nM8uDpoWrD+8p/d5fu8Dz8tQChEZs9nsk4ODgwcnJye8RqNRmpubd3ief69Wq1dwSTSl5tbt7e2VYDB4N51Ow2AwoFgsQpKkGxzH3Usmkx+amppGGWO5coARkXFra+vzwuLCnVau9ai3t3fWbDZHC4WCPhaL3Q8EAmMqxrTPJiYWTSbTWMUIv0Tx6fj4OE1OTsay2ewLIpo9f59IfPf6fD7l1fw8EVFXeb/q6+6uK5FIwOl0rhoMBhlA5HyBxXLzncPhWN/Y3IQgCP0VwOHhIQcALS0tqwDeMMY+lRfxPB8WBAHHx8dcBQBAyWQykGVZwxj7SUS6sqMSRdEoiiJUKpVSsYW2tradVCplDofDLiI6BVAPoACAlR44Da2HempqamCxWL5UAFardamzs9M5NTXt5nk+bbPZJAAmAL8B/FheXr4VCAa6bDYbdHodVawRAPb29t4ODAw8FgShODw8vGG321O5XE4dCoW4tbW120ajEfl8Hn19fTm/3/9Iq9V+/EchomvxePyl1+stNNQ3kE6nI71eTx0dHdTT3U11dXV0vbGRqquraWRkRM7n864LvyURWY+Oks8jkchSNBp9nclkfLIse0ZHfRIAqq2tJcYYDT0cuhy5KIqi9Hs8HgkAVVVVEQByuVzy2dnZ1ZDBwUEJADHGCADNzMyk/xv4i7jdbgkAtbe30/7+/vSVAACQZdk5Nzf3LR6PTwHAHzdFLfF/9+ryAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDEwLTAyLTExVDExOjIxOjA0LTA2OjAw10lxMgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAwNi0wNS0zMFQxMToxMzowNi0wNTowMGfB+zwAAAAASUVORK5CYII=) no-repeat 3px;
}
.icon-popup .icon-list{position:absolute;top: 43px;bottom:0;overflow: hidden;}
.icon-list ul{
margin: 0;
padding: 0;
margin-bottom: 10px;
}
.icon-popup .ip-control ul{margin: 4px 0;padding: 0;}
.icon-popup .ip-control ul li{float: left;list-style-type: none;}
.icon-popup .ip-control ul li a{margin-top: -3px;color:#373737;}
.icon-popup .ip-control ul li:first-child{margin-left: 3px;}
.icon-popup .ip-control ul li:last-child{position: absolute;right: 0;top: 9px;}
.icon-list ul li{
display: inline-block;
margin: 5px;
float: left;
border: 1px dotted #eee;
}
.icon-list ul li a{
display: block;
text-decoration: none;
color:#373737;
padding: 6px 10px;
}
.icon-list ul li a:hover{color:#000;}
/*
* Bootstrap 3.0 IconPicker - jQuery plugin for Icon selection
*
* Copyright (c) 20013 A. K. M. Rezaul Karim<titosust@gmail.com>
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* https://github.com/titosust/Bootstrap-icon-picker
*
* Version: 1.0.0
*
*/
// add this function to initialize
$(function () {
$(".icon-picker").iconPicker();
});
(function($) {
$.fn.iconPicker = function( options ) {
var mouseOver=false;
var $popup=null;
var icons=new Array("adjust","align-center","align-justify","align-left","align-right","arrow-down","arrow-left","arrow-right","arrow-up","asterisk","backward","ban-circle","barcode","bell","bold","book","bookmark","briefcase","bullhorn","calendar","camera","certificate","check","chevron-down","chevron-left","chevron-right","chevron-up","circle-arrow-down","circle-arrow-left","circle-arrow-right","circle-arrow-up","cloud","cloud-download","cloud-upload","cog","collapse-down","collapse-up","comment","compressed","copyright-mark","credit-card","cutlery","dashboard","download","download-alt","earphone","edit","eject","envelope","euro","exclamation-sign","expand","export","eye-close","eye-open","facetime-video","fast-backward","fast-forward","file","film","filter","fire","flag","flash","floppy-disk","floppy-open","floppy-remove","floppy-save","floppy-saved","folder-close","folder-open","font","forward","fullscreen","gbp","gift","glass","globe","hand-down","hand-left","hand-right","hand-up","hd-video","hdd","header","headphones","heart","heart-empty","home","import","inbox","indent-left","indent-right","info-sign","italic","leaf","link","list","list-alt","lock","log-in","log-out","magnet","map-marker","minus","minus-sign","move","music","new-window","off","ok","ok-circle","ok-sign","open","paperclip","pause","pencil","phone","phone-alt","picture","plane","play","play-circle","plus","plus-sign","print","pushpin","qrcode","question-sign","random","record","refresh","registration-mark","remove","remove-circle","remove-sign","repeat","resize-full","resize-horizontal","resize-small","resize-vertical","retweet","road","save","saved","screenshot","sd-video","search","send","share","share-alt","shopping-cart","signal","sort","sort-by-alphabet","sort-by-alphabet-alt","sort-by-attributes","sort-by-attributes-alt","sort-by-order","sort-by-order-alt","sound-5-1","sound-6-1","sound-7-1","sound-dolby","sound-stereo","star","star-empty","stats","step-backward","step-forward","stop","subtitles","tag","tags","tasks","text-height","text-width","th","th-large","th-list","thumbs-down","thumbs-up","time","tint","tower","transfer","trash","tree-conifer","tree-deciduous","unchecked","upload","usd","user","volume-down","volume-off","volume-up","warning-sign","wrench","zoom-in","zoom-out");
var settings = $.extend({
}, options);
return this.each( function() {
element=this;
if(!settings.buttonOnly && $(this).data("iconPicker")==undefined ){
$this=$(this).addClass("form-control");
$wraper=$("<div/>",{class:"input-group"});
$this.wrap($wraper);
$button=$("<span class=\"input-group-addon pointer\"><i class=\"glyphicon glyphicon-picture\"></i></span>");
$this.after($button);
(function(ele){
$button.click(function(){
createUI(ele);
showList(ele,icons);
});
})($this);
$(this).data("iconPicker",{attached:true});
}
function createUI($element){
$popup=$('<div/>',{
css: {
'top':$element.offset().top+$element.outerHeight()+6,
'left':$element.offset().left
},
class:'icon-popup'
})
$popup.html('<div class="ip-control"> \
<ul> \
<li><a href="javascript:;" class="btn" data-dir="-1"><span class="glyphicon glyphicon-fast-backward"></span></a></li> \
<li><input type="text" class="ip-search glyphicon glyphicon-search" placeholder="Search" /></li> \
<li><a href="javascript:;" class="btn" data-dir="1"><span class="glyphicon glyphicon-fast-forward"></span></a></li> \
</ul> \
</div> \
<div class="icon-list"> </div> \
').appendTo("body");
$popup.addClass('dropdown-menu').show();
$popup.mouseenter(function() { mouseOver=true; }).mouseleave(function() { mouseOver=false; });
var lastVal="", start_index=0,per_page=30,end_index=start_index+per_page;
$(".ip-control .btn",$popup).click(function(e){
e.stopPropagation();
var dir=$(this).attr("data-dir");
start_index=start_index+per_page*dir;
start_index=start_index<0?0:start_index;
if(start_index+per_page<=210){
$.each($(".icon-list>ul li"),function(i){
if(i>=start_index && i<start_index+per_page){
$(this).show();
}else{
$(this).hide();
}
});
}else{
start_index=180;
}
});
$('.ip-control .ip-search',$popup).on("keyup",function(e){
if(lastVal!=$(this).val()){
lastVal=$(this).val();
if(lastVal==""){
showList(icons);
}else{
showList($element, $(icons)
.map(function(i,v){
if(v.toLowerCase().indexOf(lastVal.toLowerCase())!=-1){return v}
}).get());
}
}
});
$(document).mouseup(function (e){
if (!$popup.is(e.target) && $popup.has(e.target).length === 0) {
removeInstance();
}
});
}
function removeInstance(){
$(".icon-popup").remove();
}
function showList($element,arrLis){
$ul=$("<ul>");
for (var i in arrLis) {
$ul.append("<li><a href=\"#\" title="+arrLis[i]+"><span class=\"glyphicon glyphicon-"+arrLis[i]+"\"></span></a></li>");
};
$(".icon-list",$popup).html($ul);
$(".icon-list li a",$popup).click(function(e){
e.preventDefault();
var title=$(this).attr("title");
$element.val("glyphicon glyphicon-"+title);
removeInstance();
});
}
});
}
}(jQuery));