Skip to content

Instantly share code, notes, and snippets.

@furf
Created September 13, 2009 18:51
Show Gist options
  • Save furf/186283 to your computer and use it in GitHub Desktop.
Save furf/186283 to your computer and use it in GitHub Desktop.
// jQuery plugin Textmate snippet
(function (\$) {
/**
* ${10:plugin}
*/
\$.fn.${10:plugin} = function(cfg) {
if (this.length === 0) {
return this;
}
/**
* Configuration
*/
cfg = $.extend(true,
// Private config
{},
// Public config
\$.fn.${10:plugin}.defaults,
// User config
cfg);
/**
* Private static methods
*/
/**
* Return instance
*/
return this.each(function() {
var \$this = \$(this);
});
};
\$.fn.${10:plugin}.defaults = {
${20:// Configuration properties}
};
})(jQuery);
// jQuery plugin template
(function ($) {
/**
* plugin
*/
$.fn.plugin = function(cfg) {
if (this.length === 0) {
return this;
}
/**
* Configuration
*/
cfg = .extend(true,
// Private config
{},
// Public config
$.fn.plugin.defaults,
// User config
cfg);
/**
* Private static methods
*/
/**
* Return instance
*/
return this.each(function() {
var $this = $(this);
});
};
$.fn.plugin.defaults = {
// Configuration properties
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment