Last active
February 11, 2024 22:23
-
-
Save adamwdraper/2951011 to your computer and use it in GitHub Desktop.
AMD jQuery plugin template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uses AMD or browser globals to create a jQuery plugin. | |
/** | |
* Name - jQuery Plugin | |
* | |
* Version: 0.0.1 (5/25/2012) | |
* Requires: jQuery v1.7+ | |
* | |
* Copyright (c) 2011 User - http://github.com/username | |
* Under MIT and GPL licenses: | |
* http://www.opensource.org/licenses/mit-license.php | |
* http://www.gnu.org/licenses/gpl.html | |
*/ | |
(function (factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['jquery'], factory); | |
} else { | |
// Browser globals | |
factory(jQuery); | |
} | |
}(function ($) { | |
var $this; | |
var methods = { | |
init : function( options ) { | |
return this.each(function(){ | |
var $this = $(this), | |
data = $this.data('initialized'); | |
if ( ! data ) { | |
$this = $(this); | |
$this.data('initialized', true); | |
} | |
}); | |
}, | |
value: function() { | |
}, | |
set: function(value) { | |
}, | |
reset: function() { | |
} | |
}; | |
$.fn.inputGrid = function( method ) { | |
if ( methods[method] ) { | |
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); | |
} else if ( typeof method === 'object' || ! method ) { | |
return methods.init.apply( this, arguments ); | |
} else { | |
$.error( 'Method ' + method + ' does not exist on jQuery.plugin' ); | |
} | |
}; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment