Code Monkey home page Code Monkey logo

jquery.easyplug's People

Contributors

cahnory avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jquery.easyplug's Issues

Naming predefined "static" methods

Each plugin made with easyPlug has three predefined methods attached to the Class object :

  • getName: return the plugin index on which is attached to the jQuery object.
  • space: add plugin namespace to an events string. (eg: "foo bar" become "foo.pluginNamespace bar.pluginNamespace")
  • prefix: add plugin prefix for custom events, data indexes,โ€ฆ (eg "foo bar" become "pluginPrefix-foo pluginPrefix-bar")

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.

Namespace or prefix for custom event ?

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.

Add a getEvent function

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.

Add unit tests

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 !

Add an "empty" method

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.