"Bootstrap Icon Picker"
Bootstrap 3.1.0 Snippet by Geniusone

<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 Twitter Bootstrap Documentation</a> </p> </div> </div> <div class="container"> <div class="row"> <div class="col-xs-offset-4 col-xs-4"> <form method="post"> <input type="text" name="someName" class="icon-picker" data-toggle="iconpicker" placeholder="Click on the image to select an icon ->" /> </form> </div> </div> </div
.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; height: 28px; padding:2px 0px 5px 27px; margin-left: 8px; background-repeat: no-repeat; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAAC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ottom: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;}
$(function () { $('[data-toggle="iconpicker"]').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 icons = [ { icon: "glyphicon glyphicon-asterisk", tags: "asterisk" }, { icon: "glyphicon glyphicon-plus", tags: "plus" }, { icon: "glyphicon glyphicon-euro", tags: "euro" }, { icon: "glyphicon glyphicon-minus", tags: "minus" }, { icon: "glyphicon glyphicon-cloud", tags: "cloud" }, { icon: "glyphicon glyphicon-envelope", tags: "envelope" }, { icon: "glyphicon glyphicon-pencil", tags: "pencil" }, { icon: "glyphicon glyphicon-glass", tags: "glass" }, { icon: "glyphicon glyphicon-music", tags: "music" }, { icon: "glyphicon glyphicon-search", tags: "search" }, { icon: "glyphicon glyphicon-heart", tags: "heart" }, { icon: "glyphicon glyphicon-star", tags: "star" }, { icon: "glyphicon glyphicon-star-empty", tags: "star-empty" }, { icon: "glyphicon glyphicon-user", tags: "user" }, { icon: "glyphicon glyphicon-film", tags: "film" }, { icon: "glyphicon glyphicon-th-large", tags: "th-large" }, { icon: "glyphicon glyphicon-th", tags: "th" }, { icon: "glyphicon glyphicon-th-list", tags: "th-list" }, { icon: "glyphicon glyphicon-ok", tags: "ok" }, { icon: "glyphicon glyphicon-remove", tags: "remove" }, { icon: "glyphicon glyphicon-zoom-in", tags: "zoom-in" }, { icon: "glyphicon glyphicon-zoom-out", tags: "zoom-out" }, { icon: "glyphicon glyphicon-off", tags: "off" }, { icon: "glyphicon glyphicon-signal", tags: "signal" }, { icon: "glyphicon glyphicon-cog", tags: "cog" }, { icon: "glyphicon glyphicon-trash", tags: "trash" }, { icon: "glyphicon glyphicon-home", tags: "home" }, { icon: "glyphicon glyphicon-file", tags: "file" }, { icon: "glyphicon glyphicon-time", tags: "time" }, { icon: "glyphicon glyphicon-road", tags: "road" }, { icon: "glyphicon glyphicon-download-alt", tags: "download-alt" }, { icon: "glyphicon glyphicon-download", tags: "download" }, { icon: "glyphicon glyphicon-upload", tags: "upload" }, { icon: "glyphicon glyphicon-inbox", tags: "inbox" }, { icon: "glyphicon glyphicon-play-circle", tags: "play-circle" }, { icon: "glyphicon glyphicon-repeat", tags: "repeat" }, { icon: "glyphicon glyphicon-refresh", tags: "refresh" }, { icon: "glyphicon glyphicon-list-alt", tags: "list-alt" }, { icon: "glyphicon glyphicon-flag", tags: "flag" }, { icon: "glyphicon glyphicon-headphones", tags: "headphones" }, { icon: "glyphicon glyphicon-volume-off", tags: "volume-off" }, { icon: "glyphicon glyphicon-volume-down", tags: "volume-down" }, { icon: "glyphicon glyphicon-volume-up", tags: "volume-up" }, { icon: "glyphicon glyphicon-qrcode", tags: "qrcode" }, { icon: "glyphicon glyphicon-barcode", tags: "barcode" }, { icon: "glyphicon glyphicon-tag", tags: "tag" }, { icon: "glyphicon glyphicon-tags", tags: "tags" }, { icon: "glyphicon glyphicon-book", tags: "book" }, { icon: "glyphicon glyphicon-bookmark", tags: "bookmark" }, { icon: "glyphicon glyphicon-print", tags: "print" }, { icon: "glyphicon glyphicon-camera", tags: "camera" }, { icon: "glyphicon glyphicon-font", tags: "font" }, { icon: "glyphicon glyphicon-bold", tags: "bold" }, { icon: "glyphicon glyphicon-italic", tags: "italic" }, { icon: "glyphicon glyphicon-text-height", tags: "text-height" }, { icon: "glyphicon glyphicon-text-width", tags: "text-width" }, { icon: "glyphicon glyphicon-align-left", tags: "align-left" }, { icon: "glyphicon glyphicon-align-center", tags: "align-center" }, { icon: "glyphicon glyphicon-align-right", tags: "align-right" }, { icon: "glyphicon glyphicon-align-justify", tags: "align-justify" }, { icon: "glyphicon glyphicon-list", tags: "list" }, { icon: "glyphicon glyphicon-indent-left", tags: "indent-left" }, { icon: "glyphicon glyphicon-indent-right", tags: "indent-right" }, { icon: "glyphicon glyphicon-facetime-video", tags: "facetime-video" }, { icon: "glyphicon glyphicon-picture", tags: "picture" }, { icon: "glyphicon glyphicon-map-marker", tags: "map-marker" }, { icon: "glyphicon glyphicon-adjust", tags: "adjust" }, { icon: "glyphicon glyphicon-tint", tags: "tint" }, { icon: "glyphicon glyphicon-edit", tags: "edit" }, { icon: "glyphicon glyphicon-share", tags: "share" }, { icon: "glyphicon glyphicon-check", tags: "check" }, { icon: "glyphicon glyphicon-move", tags: "move" }, { icon: "glyphicon glyphicon-step-backward", tags: "step-backward" }, { icon: "glyphicon glyphicon-fast-backward", tags: "fast-backward" }, { icon: "glyphicon glyphicon-backward", tags: "backward" }, { icon: "glyphicon glyphicon-play", tags: "play" }, { icon: "glyphicon glyphicon-pause", tags: "pause" }, { icon: "glyphicon glyphicon-stop", tags: "stop" }, { icon: "glyphicon glyphicon-forward", tags: "forward" }, { icon: "glyphicon glyphicon-fast-forward", tags: "fast-forward" }, { icon: "glyphicon glyphicon-step-forward", tags: "step-forward" }, { icon: "glyphicon glyphicon-eject", tags: "eject" }, { icon: "glyphicon glyphicon-chevron-left", tags: "chevron-left" }, { icon: "glyphicon glyphicon-chevron-right", tags: "chevron-right" }, { icon: "glyphicon glyphicon-plus-sign", tags: "plus-sign" }, { icon: "glyphicon glyphicon-minus-sign", tags: "minus-sign" }, { icon: "glyphicon glyphicon-remove-sign", tags: "remove-sign" }, { icon: "glyphicon glyphicon-ok-sign", tags: "ok-sign" }, { icon: "glyphicon glyphicon-question-sign", tags: "question-sign" }, { icon: "glyphicon glyphicon-info-sign", tags: "info-sign" }, { icon: "glyphicon glyphicon-screenshot", tags: "screenshot" }, { icon: "glyphicon glyphicon-remove-circle", tags: "remove-circle" }, { icon: "glyphicon glyphicon-ok-circle", tags: "ok-circle" }, { icon: "glyphicon glyphicon-ban-circle", tags: "ban-circle" }, { icon: "glyphicon glyphicon-arrow-left", tags: "arrow-left" }, { icon: "glyphicon glyphicon-arrow-right", tags: "arrow-right" }, { icon: "glyphicon glyphicon-arrow-up", tags: "arrow-up" }, { icon: "glyphicon glyphicon-arrow-down", tags: "arrow-down" }, { icon: "glyphicon glyphicon-share-alt", tags: "share-alt" }, { icon: "glyphicon glyphicon-resize-full", tags: "resize-full" }, { icon: "glyphicon glyphicon-resize-small", tags: "resize-small" }, { icon: "glyphicon glyphicon-exclamation-sign", tags: "exclamation-sign" }, { icon: "glyphicon glyphicon-gift", tags: "gift" }, { icon: "glyphicon glyphicon-leaf", tags: "leaf" }, { icon: "glyphicon glyphicon-fire", tags: "fire" }, { icon: "glyphicon glyphicon-eye-open", tags: "eye-open" }, { icon: "glyphicon glyphicon-eye-close", tags: "eye-close" }, { icon: "glyphicon glyphicon-warning-sign", tags: "warning-sign" }, { icon: "glyphicon glyphicon-plane", tags: "plane" }, { icon: "glyphicon glyphicon-calendar", tags: "calendar" }, { icon: "glyphicon glyphicon-random", tags: "random" }, { icon: "glyphicon glyphicon-comment", tags: "comment" }, { icon: "glyphicon glyphicon-magnet", tags: "magnet" }, { icon: "glyphicon glyphicon-chevron-up", tags: "chevron-up" }, { icon: "glyphicon glyphicon-chevron-down", tags: "chevron-down" }, { icon: "glyphicon glyphicon-retweet", tags: "retweet" }, { icon: "glyphicon glyphicon-shopping-cart", tags: "shopping-cart" }, { icon: "glyphicon glyphicon-folder-close", tags: "folder-close" }, { icon: "glyphicon glyphicon-folder-open", tags: "folder-open" } ] 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"><span class="glyphicon glyphicon-picture"></span></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 form-control" 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(!$(this).val()) { showList($element, icons); }else{ showList($element, getObjects(icons, 'tags', $(this).val())); } }); $(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].tags+'"><span class="'+arrLis[i].icon+'"></span></a></li>'); }; $(".icon-list",$popup).html($ul); $(".icon-list li a",$popup).click(function(e){ e.preventDefault(); var title = $(this).find('span').attr("class"); $element.val(title); removeInstance(); }); } function getObjects(obj, key, val) { var objects = []; for (var i in obj) { if (!obj.hasOwnProperty(i)) continue; if (typeof obj[i] == 'object') { objects = objects.concat(getObjects(obj[i], key, val)); } else if (i == key && obj[key].toLowerCase().indexOf(val) >= 0) { objects.push(obj); } } console.log(objects) return objects; } }); } }(jQuery));

Related: See More


Questions / Comments: