Skip to content

Instantly share code, notes, and snippets.

@markyun
Created April 16, 2013 08:00
Show Gist options
  • Save markyun/5394213 to your computer and use it in GitHub Desktop.
Save markyun/5394213 to your computer and use it in GitHub Desktop.
my97的Jquery插件
/*my97的Jquery插件
<input class="my97" type="text">
<input id="my97" type="text" name="">
$('#my97').my97(options);
my97配置属性说明:http://www.my97.net/dp/demo/resource/3.asp
*/
(function ($) {
$.fn.my97 = function (options, params) {
if (typeof options == "string") {
return $.fn.my97.methods[options](this, params);
}
options = options || {};
if (!WdatePicker) {
alert("未引入My97js包!");
return;
}
return this.each(function () {
var data = $.data(this, "my97");
var newOptions;
if (data) {
newOptions = $.extend(data.options, options);
data.opts = newOptions;
} else {
newOptions = $.extend({}, $.fn.my97.defaults, $.fn.my97.parseOptions(this), options);
$.data(this, "my97", {
options : newOptions
});
}
$(this).addClass('Wdate').click(function () {
WdatePicker(newOptions);
});
});
};
$.fn.my97.methods = {
setValue : function (target, params) {
target.val(params);
},
getValue : function (target) {
return target.val();
},
clearValue : function (target) {
target.val('');
}
};
$.fn.my97.parseOptions = function (target) {
return $.extend({}, $.parser.parseOptions(target, ["el", "vel", "weekMethod", "lang", "skin", "dateFmt", "realDateFmt", "realTimeFmt", "realFullFmt", "minDate", "maxDate", "startDate", {
doubleCalendar : "boolean",
enableKeyboard : "boolean",
enableInputMask : "boolean",
autoUpdateOnChanged : "boolean",
firstDayOfWeek : "number",
isShowWeek : "boolean",
highLineWeekDay : "boolean",
isShowClear : "boolean",
isShowToday : "boolean",
isShowOthers : "boolean",
readOnly : "boolean",
errDealMode : "boolean",
autoPickDate : "boolean",
qsEnabled : "boolean",
autoShowQS : "boolean",
opposite : "boolean"
}
]));
};
$.fn.my97.defaults = {
dateFmt : 'yyyy-MM-dd HH:mm:ss'
};
$.parser.plugins.push('my97');
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment