🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

asIconPicker is a powerful jQuery plugin which enables the user to select a icon from a searchable font icon picker popup.

icon-picker

Documentation

jQuery asIconPicker bower NPM version Dependency Status prs-welcome

A jquery plugin that for pick a icon.

Table of contents

Main files

dist/ ├── jquery-asIconPicker.js ├── jquery-asIconPicker.es.js ├── jquery-asIconPicker.min.js └── css/     ├── asIconPicker.css     └── asIconPicker.min.css 

Quick start

Several quick start options are available:

Download the latest build

Install From Bower

bower install jquery-asIconPicker --save

Install From Npm

npm install jquery-asIconPicker --save

Install From Yarn

yarn add jquery-asIconPicker

Build From Source

If you want build from source:

git clone [email protected]:amazingSurge/jquery-asIconPicker.git cd jquery-asIconPicker npm install npm install -g gulp-cli babel-cli gulp build

Done!

Requirements

jquery-asIconPicker requires the latest version of jQuery, asScrollbar and asTooltip.

Usage

Including files:

<link rel="stylesheet" href="/path/to/asIconPicker.css"> <script src="/path/to/jquery.js"></script> <script src="/path/to/jquery-asIconPicker.js"></script>

Required HTML structure

<select name="icon" class="example">     <option>fa-user</option>     <option>fa-search</option>     <option>fa-caret-right</option>     <option>fa-star</option>     <option>fa-times</option>     <option>fa-refresh</option>     <option>fa-rocket</option>     <option>fa-eye</option>     <option>fa-tag</option>     <option>fa-bookmark</option>     <option>fa-heart</option>     <option>fa-adn</option>     <option>fa-cloud-upload</option>     <option>fa-phone-square</option>     <option>fa-cog</option>     <option>fa-wrench</option>     <option>fa-volume-down</option>     <option>fa-caret-down</option>     <option>fa-caret-up</option>     <option>fa-caret-left</option>     <option>fa-thumbs-up</option> </select>

Initialization

All you need to do is call the plugin on the element:

jQuery(function($) {   $('.example').asIconPicker();  });

Examples

There are some example usages that you can look at to get started. They can be found in the examples folder.

Options

jquery-asIconPicker can accept an options object to alter the way it behaves. You can see the default options by call $.asIconPicker.setDefaults(). The structure of an options object is as follows:

{   namespace: 'asIconPicker',   source: false, // Icons source   tooltip: true,   hasSearch: true,   extraClass: 'fa',   iconPrefix: 'fa-',   emptyText: 'None Selected',   searchText: 'Search',   cancelSelected: true,   keyboard: true,   flat: false,   heightToScroll: '290',    iconPicker() {     return '<div class="namespace-selector">' +       '<span class="namespace-selected-icon">' +       'None selected' +       '</span>' +       '<span class="namespace-selector-arrow">' +       '<i></i>' +       '</span>' +       '</div>' +       '<div class="namespace-selector-popup">' +       '<div class="namespace-icons-container"></div>' +       '</div>';   },   iconSearch() {     return '<div class="namespace-selector-search">' +       '<input type="text" name="" value="" placeholder="searchText" class="namespace-search-input"/>' +       '<i class="namespace-search-icon"></i>' +       '</div>';   },   formatNoMatches() {     return 'No matches found';   },   errorHanding() {},   process(value) {     if (value && value.match(this.iconPrefix)) {       return value.replace(this.iconPrefix, '');     }     return value;   },   parse(value) {     if (value.match(this.iconPrefix)) {       return value;     }     return this.iconPrefix + value;   },   // callback   onInit: null,   onReady: null,   onAfterFill: null } 

Methods

Methods are called on asIconPicker instances through the asIconPicker method itself. You can also save the instances to variable for further use.

// call directly $().asIconPicker('destroy');  // or var api = $().data('asIconPicker'); api.destroy();

get()

Get the icon selected.

var icon = $().asIconPicker('get');

set()

Set the icon.

$().asIconPicker('set', 'search');

val()

Get or set the icon.

// get the icon var icon = $().asIconPicker('val');   // set the icon $().asIconPicker('set', 'search');

clear()

Clear the value.

$().asIconPicker('clear');

enable()

Enable the icon picker functions.

$().asIconPicker('enable');

disable()

Disable the icon picker functions.

$().asIconPicker('disable');

destroy()

Destroy the icon picker instance.

$().asIconPicker('destroy');

Events

jquery-asIconPicker provides custom events for the plugin’s unique actions.

$('.the-element').on('asIconPicker::ready', function (e) {   // on instance ready }); 
Event Description
init Fires when the instance is setup for the first time.
ready Fires when the instance is ready for API use.
enable Fired when the enable instance method has been called.
disable Fired when the disable instance method has been called.
destroy Fires when an instance is destroyed.

No conflict

If you have to use other plugin with the same namespace, just call the $.asIconPicker.noConflict method to revert to it.

<script src="other-plugin.js"></script> <script src="jquery-asIconPicker.js"></script> <script>   $.asIconPicker.noConflict();   // Code that uses other plugin's "$().asIconPicker" can follow here. </script>

Browser support

Tested on all major browsers.

Safari Chrome Firefox Edge IE Opera
Latest ✓ Latest ✓ Latest ✓ Latest ✓ 9-11 ✓ Latest ✓

As a jQuery plugin, you also need to see the jQuery Browser Support.

Contributing

Anyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing. Make sure you're using the latest version of jquery-asIconPicker before submitting an issue. There are several ways to help out:

Development

jquery-asIconPicker is built modularly and uses Gulp as a build system to build its distributable files. To install the necessary dependencies for the build system, please run:

npm install -g gulp npm install -g babel-cli npm install

Then you can generate new distributable files from the sources, using:

gulp build 

More gulp tasks can be found here.

Changelog

To see the list of recent changes, see Releases section.

Copyright and license

Copyright (C) 2016 amazingSurge.

Licensed under the LGPL license.

⬆ back to top


You May Also Like