`
52web开发
  • 浏览: 23273 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

基于EasyUI的日历插件(my97)扩展

阅读更多

(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);

 

 默认的用法和easyui的原生插件是一样的,可以通过class实例化,也可以通过代码实例化

 

<input  class="easyui-my97" type="text">

 

<input  id="my97" type="text" name="">
$('#my97').my97(options);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics