カテゴリ: jQuery
記事投稿日: 2013年3月28日
記事更新日: 2013年4月21日


By: Phil Whitehouse
今後、よく使いそうなのでストックしておきます。
まずはヘッダー。
/* * hoge.js 0.0.0 - 簡単な説明 * * Copyright (c) 2013 Web Atlier Midori * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * Since: 2013-0-0 * Modified: 2013-0-0 * * jQuery 1.8.2 */
jQueryプラグインはMITライセンスが多いと思います。
次に、プラグイン本体。
;(function($){
$.fn.hoge = function(options){
// デフォルト・パラメータの取得
var opts = $.extend({}, $.fn.hoge.defaults, options);
// パラメータにはopts.xxxでアクセス
return this.each(function(){
});
}
/* デフォルトパラメータ */
$.fn.hoge.defaults = {
apikey: 'none',
service_url: 'http://hoge',
mode: 1,
opacity: 0.5
};
})(jQuery);
※hogeの箇所に記号は使えない(アンダーバーも不可)ので注意。
コメントを残す