Last active
August 29, 2015 14:02
-
-
Save calledt/ce1e135ad6d3d7240c3e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** | |
| * jquery plugin template | |
| * @authors Kimi (huanggengtao@gmail.com) | |
| * @date 2014-10-15 09:54:42 | |
| * @version 0.0.1 | |
| */ | |
| ;(function($){ | |
| var Plugin = function( elem, options ) { | |
| this.elem = elem; | |
| this.$elem = $(elem); | |
| return this.init(options); | |
| }; | |
| Plugin.prototype = { | |
| constructor: Plugin, | |
| version: '0.0.1', | |
| init: function( options ) { | |
| this.options = $.extend({}, $.fn.plugin.default, options); | |
| // 这里写业务逻辑 | |
| return this; | |
| } | |
| }; | |
| $.fn.plugin = function( options ) { | |
| return this.each( function() { | |
| !$(this).data('jqplugin') && $.data(this, 'jqplugin', new Plugin(this, options)); | |
| }) | |
| } | |
| // 默认配置 | |
| $.fn.plugin.default = { | |
| foo: 1, | |
| bar: false | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment