Web/Content/js/select-ui.min.js
(开头部分) 12KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
(function($, undefined) {
$.uedWidget = function(name, base, prototype) {
var namespace = name.split( "." )[0], fullName;
name = name.split( "." )[1];
fullName = namespace + "-" + name;
// 例如参数name='ued.tabs',变成namespace='ued',name='tabs',fullName='ued-tabs'
// base默认为Widget类,组件默认会继承base类的所有方法
if (!prototype) {
prototype = base;
base = $.UEDWidget;
}
// create selector for plugin
$.expr[ ":" ][fullName] = function(elem) {
return !!$.data(elem, name);
};
// 创建命名空间$.ued.tabs
$[namespace] = $[namespace] || {};
// 组件的构造函数
$[ namespace ][name] = function(options, element) {
// allow instantiation without initializing for simple inheritance
if (arguments.length) {
this._createWidget(options, element);
}
};
// 初始化父类,一般调用了$.Widget
var basePrototype = new base();
// we need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
// $.each( basePrototype, function( key, val ) {
// if ( $.isPlainObject(val) ) {
// basePrototype[ key ] = $.extend( {}, val );
// }
// });
basePrototype.options = $.extend(true, {}, basePrototype.options);
// 给om.tabs继承父类的所有原型方法和参数
$[ namespace ][name].prototype = $.extend(true, basePrototype, {
namespace : namespace,
widgetName : name,
// 组件的事件名前缀,调用_trigger的时候会默认给trigger的事件加上前缀
// 例如_trigger('create')实际会触发'tabscreate'事件
widgetEventPrefix : $[ namespace ][name].prototype.widgetEventPrefix || name,
widgetBaseClass : fullName
}, prototype);
// 把tabs方法挂到jquery对象上,也就是$('#tab1').tabs();
var temp = $.uedWidget.bridge(name, $[ namespace ][name]);
};
$.uedWidget.bridge = function(name, object) {
$.fn[name] = function(options) {
// 如果tabs方法第一个参数是string类型,则认为是调用组件的方法,否则调用options方法
var isMethodCall = typeof options === "string", args = Array.prototype.slice.call(arguments, 1), returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ? $.extend.apply(null, [true, options].concat(args)) : options;
// '_'开头的方法被认为是内部方法,不会被执行,如$('#tab1').tabs('_init')
if (isMethodCall && options.charAt(0) === "_") {
return returnValue;
}
后面还有 270 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
