jquery-ui widget源码

<script>
    $.Widget = function () { }
    $.Widget._childConstructors = [];
    $.Widget.prototype = {
        widgetName: "widget",
        widgetEventPrefix: "",
        defaultElement: "<div>",
        options: {
            classes: {},
            disabled: false,
            create: null
        },
        _create: $.noop,
        _createWidget:function(){
            this._create();
        }
    };

    $.widget = function (name, base, prototype)
    {
        const constructor = function () {
            this._createWidget( options, element );
         }
        const proxiedPrototype = {};
        constructor.version = prototype.version;
        constructor[ '_proto' ] = assign({}, prototype);
        constructor[ '_childConstructors' ] = [];
        // 父类的prototype
        const basePrototype = new $.Widget();
        basePrototype.options = assign({}, basePrototype.options);
        // resizableRelatedOptions function类型
        // _create _init _createWrapper
        proxiedPrototype[ prop ] = (function (prop, fn)
        {
            function _super()
            {
                return $.Widget.prototype[ prop ].apply(this, arguments);
            }
            function _supperApply(args)
            {
                return $.Widget.prototype[ prop ].apply(this, args);
            }
            return function ()
            {
                var __super = this._super;
                var __superApply = this._supperApply;
                var returnValue;
                // 设置_super _superApply
                this._super = _super;
                this._superApply = _superApply;
                returnValue = value.apply(this, arguments);
                // 还原_super _superApply
                this._super = __super;
                this._superApply = __superApply;
                return returnValue;
            }
        })('_create', function () { });
        constructor.prototype = assign(
            basePrototype,
            { widgetEventPrefix: '' },
            proxiedPrototype,
            { constructor: constructor }
        );
        return constructor;
    }
    
	/**--------------------------------------------------------------------------------------------------------*/
	
	$.widget("ui.dialog", {
	version: "1.12.1",
	options: {},
	sizeRelatedOptions: {
		buttons: true,
		height: true,
		maxHeight: true,
		maxWidth: true,
		minHeight: true,
		minWidth: true,
		width: true
	},
	resizableRelatedOptions: {
		maxHeight: true,
		maxWidth: true,
		minHeight: true,
		minWidth: true
	},
	_create: function () {
		/**
			_create fn开始
			this._super = _super;
            this._superApply = _superApply;
            _create fn执行
			_createWrapper fn开始
			var __super = this._super;
            var __superApply = this._supperApply;
            _createWrapper fn结束
            _create fn结束
  		 */
		this._createWrapper();
	},
	_init: function () {
		if (this.options.autoOpen) {
			this.open();
		}
	},
	open: function () {},
	_createWrapper: function () {}
});
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值