当前位置 : 主页 > 网络编程 > JavaScript >

easyui插件开发的基本结构

来源:互联网 收集:自由互联 发布时间:2021-06-28
easyui插件开发的基本结构 (function($) { $.fn.timeline = function(options) { if(typeof options == "string") { var params = []; for(var i = 1; i arguments.length; i++) { params.push(arguments[i]); } this.each(function() { $.fn.timeli
easyui插件开发的基本结构
(function($) {
    $.fn.timeline = function(options) {
        if(typeof options == "string") {
            var params = [];
            for(var i = 1; i < arguments.length; i++) {
                params.push(arguments[i]);
            }
            this.each(function() {
                $.fn.timeline.methods[options].apply(this, params);
            });
            return this;
        }
        options = options || {};

        return this.each(function() {
            var data = $.data(this, "timeline");
            var newOptions;
            if(data) {
                newOptions = $.extend(data.options, options);
                data.opts = newOptions;
            } else {
                newOptions = $.extend({}, $.fn.timeline.defaults, $.fn.timeline.parseOptions(this), options);
                $.data(this, "circle", {
                    options: newOptions
                });
            }

            var target = $(this);
        });

    }

    $.fn.timeline.methods = {

    }

    $.fn.timeline.parseOptions = function(target) {
        return $.extend({}, $.parser.parseOptions(target, ["data", {
            data: "array"
        }]));
    };

    $.fn.timeline.defaults = {
        data: []
    }

    $.parser.plugins.push('timeline');
})(jQuery);
网友评论