I am looking for a starting point to code plugins, primarily for Zepto.js (with fall back for jQuery). These will provide reusable functions for Tumblr theming.
However, I can't seem to find anything in depth about writing a plugin (with Zepto) as the example, apart from a small snippet on the Zepto site: http://zeptojs.com/
The code below is pieced together from reading various 'jQuery' plugin tutorials, but I am not 100% sure how solid it is.
;(function($){
$.extend($.fn, {
pluginName: function(el, options) {
// Set defaults
this.defaults = {
option: 'option',
onComplete: function() {}
};
// Combine defaults / options
var settings = $.extend({}, this.defaults, options);
// Do stuff
$.each(this, function() {
});
// Call back if needed
settings.onComplete.call(this);
// Return `this` for chain ability
return this;
}
});
}(window.Zepto || window.jQuery));
According to the Zepto documentation, my plugins method will be added to the Zepto object. Is this acceptable?
I would also like the option to use private / public functions contained in the plugin for flexibility.
I apologise if my questions come across as confusing or novice, but any help / improvements would be greatly appreciated.