jquery-pluginify
v1.0.4
Published
Convert plugin class into a jQuery plugin
Downloads
5
Readme
jQuery Pluginify
Convert plugin class into a jQuery plugin
Installation
npm i jquery-pluginify --save
Requires
ES6 Support
Options
| Name | Type | Description |
|-----------|--------|-------------|
| name | string | Plugin name reference
| classname | object | Class reference
| iterate | bool | Defaults to true.
| | | True - Defines a class for every instance of the elements found.
| | | False - Defines the class just once, and passes all element instances through to the class.
| shorthand | bool | Defaults to false. Generate a shorthand as $.name
| ignoreWarning | bool | Defaults to false. Set to true
if you want to ignore the fact the jQuery isn't found at the time of calling this function.
Example
class myClass {
constructor(elements, ...settings) {
// console.log(elements, settings);
}
}
Define default settings to apply to all instances of the class
myClass.settings = {};
Define settings like this:
pluginify('myPlugin', myClass, false, true);
Or like this (in any order):
pluginify({
name : 'myPlugin',
classname : myClass,
shorthand : false,
iterate : true,
});
How it might be used
$('nav ul li').myPlugin({...})