`
erichua
  • 浏览: 510827 次
  • 性别: Icon_minigender_2
  • 来自: 远方
社区版块
存档分类
最新评论

JQuery读书笔记--JQuery的OOP编程模板

阅读更多
//
// create closure
//
(function($){
    // define the properties
    function object(){
        this.debug = false; // Change this to true to start debugging
        // define the defualts	
        this._defaults = { // Global defaults for all the date picker instances
}
        $.extend(this._defaults, this.regional['']); //apply some properties to defaults
    }
    //define the public method
    $.extend(object.prototype, {
        /* Class name added to elements to indicate already configured with a date picker. */
        markerClassName: 'hasDatepicker',
        
        /* Debug logging (if enabled). */
        log: function(){
            if (this.debug) 
                console.log.apply('', arguments);
        }
    });
    
    //define the private method
    /* Determine whether an object is an array. */
    function isArray(a){
        return (a &&
        (($.browser.safari && typeof a == 'object' && a.length) ||
        (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
    };
    
    //define the plug in
    $.fn.plugin = function(options){
    };
    //initial the object
    $.object = new object(); // singleton instance
    $.object.initialized = false;
})(jQuery);
 
2
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics