cahnory / jquery.easyplug Goto Github PK
View Code? Open in Web Editor NEWSimplify the creation of jQuery plugin
License: MIT License
Simplify the creation of jQuery plugin
License: MIT License
Each plugin made with easyPlug has three predefined methods attached to the Class object :
As getName seems to be a good name, space and prefix are too vague. Better names have to be found before this branch become the master one.
The reason I use a prefix instead of namespace for custom event is to prevent collision between events. If I use namespace we can't differentiate:
load.ns: plugin binding on load event
from:
load.ns: plugin custom event "load"
It could result in such case:
// Plugin bind on std load event
el.on('load.ns', function () {
// Do some stuff then trigger custom event
el.trigger('load.ns'); // loop
});
I agree that it could be avoid by defining a guideline but it's something I want to avoid.
The best way to use custom event is, until now:
$(elements).on(Plugin.events.customEventName, function () {});
I'm considering adding a new method to the Plugin object:
$(elements).on(Plugin.getEvent(customEventString), function () {});
The main goal is to ease the use of namespaced and/or multiple custom events.
You have signified that you have some intervention of qunit in your bower.json. So why not to dev some unit tests ? ;)
Suggestion : use karma + qunit + istanbul to do it. You will have automated tests, easy to write tests and code coverage report. If I have time, I will make a pull request this day to show you how to start.
Cheers !
It could be usefull to be able to define a function called when no element is matched. Or maybe only when no element were passed to the jQuery function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.