0.0.10 • Published 7 years ago

fe-jquery-plugin v0.0.10

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
7 years ago

Jquery Plugin Base Class

Simple base class that sets up :

- plugin name - instance reference as data attr on element - plugin method exec from element via string - destruction life cycle.

Usage

Creating a plugin

...
plugin = require 'fe-jquery-plugin'

class Foo extends plugin

	@defaults:
		activeClass: 'active'

	initialize: (@options)->
		super(@options)
		# rest of your per instance initialisation here

	bar: ->
		@destroy()
		@element.remove()

Foo.register()
...

Using it

Attach it to an element as per usual jquery shenanigans.

...
$('#foo').Foo({activeClass: 'buwahaha' });
...

But now:

...
$('#foo').Foo('destroy');
...

Also, the plugin instance is available on the object:

...
var instance = $('#foo').data('Foo');
console.log(instance);
// => Foo

Testing

tests are outlined, and require fullfilling.

0.0.10

7 years ago