Skip to content

Instantly share code, notes, and snippets.

@andyhausmann
Created August 9, 2013 14:48
Show Gist options
  • Select an option

  • Save andyhausmann/6194226 to your computer and use it in GitHub Desktop.

Select an option

Save andyhausmann/6194226 to your computer and use it in GitHub Desktop.

Revisions

  1. andyhausmann created this gist Aug 9, 2013.
    40 changes: 40 additions & 0 deletions jQuery Plugin Template
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    (function($){

    "use strict";

    $.pluginName = function(el, options){
    var self = this;

    self.$el = $(el);
    self.el = el;
    self.$el.data('pluginName', self);

    self.init = function(){
    self.options = $.extend({},$.pluginName.defaultOptions, options);

    // Initialization code goes here.
    };

    // Example function
    //self.exampleFunction = function() {
    // Example function code goes here.
    //};

    // Run initializer
    self.init();
    };

    $.pluginName.defaultOptions = {
    origin: 'auto',
    target: 'auto'
    };

    $.fn.pluginName = function(options){
    return this.each(function(){
    (new $.pluginName(this, options));

    // Want to let your plugin do even more? Put it here.
    });
    };

    })(jQuery);