<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.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 ---------->
<!-- FixUX.com by Marcelo Martins -->
<!-- from http://FixUX.com/ -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" id="bootstrap-css">
<div class="container">
<div class="row">
<h2>Bootstrap Font Awesome (4.7.0) Icon Picker.</h2>
<p>
<a href="http://fontawesome.io/icons/" target="_blank">Bootstrap Font Awesome Documentation <i class="fa fa-external-link"></i></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>
Simply use a CSS class to change the color of icons.
<style>
.red, .red a {
color: #ff0000;
}
.green, .green a {
color: #9fc163;
}
.blue, .blue a {
color: #00f;
}
</style>
<br />
<br />
CSS class="red" <code>.red a {color: #FF0;}</code> results in ........... <span class="fa fa-search red"></span><br />
CSS class="green" <code>.green a {color: #9FC;}</code> results in .... <span class="fa fa-search green"></span><br />
CSS class="blue" <code>.blue a {color: #00F;}</code> results in ......... <span class="fa fa-search blue"></span>
</div> <!-- wraper -->
/*!
* Bootstrap 3.3.7 IconPicker Style
* Custom Style Elements for IconPicker
*
* Fork from
* 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.3.7 Font Awesome IconPicker - jQuery plugin for Icon selection
*
* Credit Given to: Copyright (c) 20013 A. K. M. Rezaul Karim<titosust@gmail.com>
*
* Modified by Marcelo Martins<marceluta@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","barcode","bell","bold","book","bookmark","briefcase","bullhorn","calendar","camera","certificate","check","chevron-down","chevron-left","chevron-right","chevron-up","arrow-circle-down","arrow-circle-left","arrow-circle-right","arrow-circle-up","cloud","cloud-download","cloud-upload","cog","caret-square-o-down","caret-square-o-left","caret-square-o-right","caret-square-o-up","comment","compress","copyright","credit-card","cutlery","dashboard","download","cloud-download","phone","headphones","edit","eject","envelope","eur","exclamation","exclamation-triangle","exclamation-circle","expand","eye","eyedropper","eye-slash","video-camera","fast-backward","forward","step-forward","stop","pause","play","backward","fast-backward","step-backward","file","film","filter","fire","flag","flash","floppy-o","folder","folder-open","folder-o","folder-open-o","font","arrows-alt","gbp","gift","glass","globe","hand-o-down","hand-o-up","hand-o-left","hand-o-right","thumbs-down","thumbs-up","thumbs-o-down","thumbs-o-down","hourglass","hourglass-end","hourglass-half","hourglass-start","hourglass-o","hdd-o","header","heart","heartbeat","heart-o","medkit","home","inbox","indent","align-right","align-center","align-left","align-justify","info","info-circle","question","question-circle","italic","leaf","link","list","list-ol","list-ul","list-alt","th-list","bars","lock","unlock-alt","unlock","sign-in","sign-out","magnet","map","map-o","map-marker","map-signs","map-pin","street-view","location-arrow","minus","minus-circle","minus-square","minus-square-o","arrows","arrows-alt","music","external-link","external-link-square","power-off","check","check-circle","check-circle-o","check-square","check-square-o","paperclip","pause","pause-circle","pause-circle-o","pencil","pencil-square-o","pencil-square","phone","phone-square","picture-o","file-image-o","plane","paper-plane-o","paper-plane","play","play-circle","plus","plus-circle","plus-square-o","plus-square","print","qrcode","question","question-circle","question-circle-o","random","refresh","registered","times","repeat","expand","arrows-h","arrows-v","retweet","road","desktop","search","search-minus","search-plus","send","share","share-alt","shopping-cart","signal","sort","sort-numeric-desc","sort-numeric-asc","sort-amount-desc","sort-amount-asc","sort-alpha-desc","sort-alpha-asc","sort-asc","sort-desc","soundcloud","star","star-o","star-half","star-half-o","tag","tags","text-height","text-width","th","tint","exchange","trash","trash-o","tree","upload","usd","user","volume-down","volume-off","volume-up","exclamation","exclamation-triangle","exclamation-circle","wrench","search-plus","search-minus");
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=\"fa fa-picture-o blue\"></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="fa fa-fast-backward"></span></a></li> \
<li><input type="text" class="ip-search fa fa-search" placeholder="Search" /></li> \
<li><a href="javascript:;" class="btn" data-dir="1"><span class="fa fa-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=40,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<=270){
$.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=\"fa fa-"+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("fa fa-"+title);
removeInstance();
});
}
});
}
}(jQuery));