A jquery plugin that for pick a icon.
- Main files
- Quick start
- Requirements
- Usage
- Examples
- Options
- Methods
- Events
- No conflict
- Browser support
- Contributing
- Development
- Changelog
- Copyright and license
dist/
├── jquery-asIconPicker.js
├── jquery-asIconPicker.es.js
├── jquery-asIconPicker.min.js
└── css/
├── asIconPicker.css
└── asIconPicker.min.css
Several quick start options are available:
- Development - unminified
- Production - minified
bower install jquery-asIconPicker --save
npm install jquery-asIconPicker --save
yarn add jquery-asIconPicker
If you want build from source:
git clone git@github.com:amazingSurge/jquery-asIconPicker.git
cd jquery-asIconPicker
npm install
npm install -g gulp-cli babel-cli
gulp build
Done!
jquery-asIconPicker
requires the latest version of jQuery
, asScrollbar
and asTooltip
.
<link rel="stylesheet" href="/path/to/asIconPicker.css">
<script src="/path/to/jquery.js"></script>
<script src="/path/to/jquery-asIconPicker.js"></script>
<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>
All you need to do is call the plugin on the element:
jQuery(function($) {
$('.example').asIconPicker();
});
There are some example usages that you can look at to get started. They can be found in the examples folder.
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 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 the icon selected.
var icon = $().asIconPicker('get');
Set the icon.
$().asIconPicker('set', 'search');
Get or set the icon.
// get the icon
var icon = $().asIconPicker('val');
// set the icon
$().asIconPicker('set', 'search');
Clear the value.
$().asIconPicker('clear');
Enable the icon picker functions.
$().asIconPicker('enable');
Disable the icon picker functions.
$().asIconPicker('disable');
Destroy the icon picker instance.
$().asIconPicker('destroy');
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. |
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>
Tested on all major browsers.
Latest ✓ | Latest ✓ | Latest ✓ | Latest ✓ | 9-11 ✓ | Latest ✓ |
As a jQuery plugin, you also need to see the jQuery Browser Support.
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:
- Bug reports
- Feature requests
- Pull requests
- Write test cases for open bug issues
- Contribute to the documentation
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.
To see the list of recent changes, see Releases section.
Copyright (C) 2016 amazingSurge.
Licensed under the LGPL license.