|
|
@ -3,13 +3,18 @@ BI.Plugin = BI.Plugin || {}; |
|
|
|
var _WidgetsPlugin = {}; |
|
|
|
var _WidgetsPlugin = {}; |
|
|
|
var _ObjectPlugin = {}; |
|
|
|
var _ObjectPlugin = {}; |
|
|
|
var _ConfigPlugin = {}; |
|
|
|
var _ConfigPlugin = {}; |
|
|
|
var _GlobalWidgetConfigFn, _GlobalObjectConfigFn; |
|
|
|
var _GlobalWidgetConfigFns = []; |
|
|
|
|
|
|
|
var __GlobalObjectConfigFns = []; |
|
|
|
BI.extend(BI.Plugin, { |
|
|
|
BI.extend(BI.Plugin, { |
|
|
|
|
|
|
|
|
|
|
|
getWidget: function (type, options) { |
|
|
|
getWidget: function (type, options) { |
|
|
|
if (_GlobalWidgetConfigFn) { |
|
|
|
if (_GlobalWidgetConfigFns.length > 0) { |
|
|
|
_GlobalWidgetConfigFn(type, options); |
|
|
|
var fns = _GlobalWidgetConfigFns.slice(0); |
|
|
|
|
|
|
|
for (var i = fns.length - 1; i >= 0; i--) { |
|
|
|
|
|
|
|
fns[i](type, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var res; |
|
|
|
var res; |
|
|
|
if (_ConfigPlugin[type]) { |
|
|
|
if (_ConfigPlugin[type]) { |
|
|
|
for (var i = _ConfigPlugin[type].length - 1; i >= 0; i--) { |
|
|
|
for (var i = _ConfigPlugin[type].length - 1; i >= 0; i--) { |
|
|
@ -30,8 +35,8 @@ BI.Plugin = BI.Plugin || {}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
config: function (widgetConfigFn, objectConfigFn) { |
|
|
|
config: function (widgetConfigFn, objectConfigFn) { |
|
|
|
_GlobalWidgetConfigFn = widgetConfigFn; |
|
|
|
_GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(_.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]); |
|
|
|
_GlobalObjectConfigFn = objectConfigFn; |
|
|
|
__GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(_.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
configWidget: function (type, fn) { |
|
|
|
configWidget: function (type, fn) { |
|
|
@ -56,15 +61,19 @@ BI.Plugin = BI.Plugin || {}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
getObject: function (type, object) { |
|
|
|
getObject: function (type, object) { |
|
|
|
if (_GlobalObjectConfigFn) { |
|
|
|
if (__GlobalObjectConfigFns.length > 0) { |
|
|
|
_GlobalObjectConfigFn(type, object); |
|
|
|
var fns = __GlobalObjectConfigFns.slice(0); |
|
|
|
|
|
|
|
for (var i = fns.length - 1; i >= 0; i--) { |
|
|
|
|
|
|
|
fns[i](type, object); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_ObjectPlugin[type]) { |
|
|
|
if (_ObjectPlugin[type]) { |
|
|
|
var res; |
|
|
|
var res; |
|
|
|
for (var i = 0, len = _ObjectPlugin[type].length; i < len; i++) { |
|
|
|
for (var i = 0, len = _ObjectPlugin[type].length; i < len; i++) { |
|
|
|
if (res = _ObjectPlugin[type][i](object)) { |
|
|
|
if (res = _ObjectPlugin[type][i](object)) { |
|
|
|
object = res; |
|
|
|
object = res; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return res || object; |
|
|
|
return res || object; |
|
|
|