jquery-pluginify

1.0.4 • Public • Published

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({...})

Credit

monkeymonk benjasHu

Readme

Keywords

none

Package Sidebar

Install

npm i jquery-pluginify

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

8.43 kB

Total Files

5

Last publish

Collaborators

  • marknotton