Skip to content
This repository was archived by the owner on Dec 23, 2020. It is now read-only.

marknotton/jquery-pluginify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Convert ES6 class into a jQuery plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published