forked from fanruan/fineui
Zhenfei.Li
6 years ago
192 changed files with 238841 additions and 69005 deletions
@ -1,215 +0,0 @@
|
||||
/** |
||||
* guy |
||||
* 二级树 |
||||
* @class BI.PlatformLevelTree |
||||
* @extends BI.Select |
||||
*/ |
||||
BI.PlatformLevelTree = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "platform-level-tree", |
||||
itemsCreator: BI.emptyFn |
||||
}, |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
this.tree = BI.createWidget({ |
||||
type: "bi.custom_tree", |
||||
element: this, |
||||
expander: { |
||||
type: "bi.select_tree_expander", |
||||
isDefaultInit: false, |
||||
el: {}, |
||||
popup: { |
||||
type: "bi.custom_tree" |
||||
} |
||||
}, |
||||
|
||||
itemsCreator: function (op, callback) { |
||||
o.itemsCreator(op, function (items) { |
||||
callback(self._formatItems(items)); |
||||
}); |
||||
}, |
||||
|
||||
el: { |
||||
type: "bi.loader", |
||||
next: false, |
||||
el: { |
||||
type: "bi.button_tree", |
||||
chooseType: 0, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}] |
||||
} |
||||
} |
||||
}); |
||||
this.tree.on(BI.CustomTree.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.PlatformLevelTree.EVENT_CHANGE, arguments); |
||||
}); |
||||
}, |
||||
|
||||
_formatItems: function (nodes) { |
||||
var self = this; |
||||
BI.each(nodes, function (i, node) { |
||||
var extend = {}; |
||||
if (node.isParent === true || BI.isNotEmptyArray(node.children)) { |
||||
switch (i) { |
||||
case 0 : |
||||
extend.type = "bi.multilayer_select_tree_first_plus_group_node"; |
||||
break; |
||||
case nodes.length - 1 : |
||||
extend.type = "bi.multilayer_select_tree_last_plus_group_node"; |
||||
break; |
||||
default : |
||||
extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; |
||||
break; |
||||
} |
||||
BI.defaults(node, extend); |
||||
} else { |
||||
switch (i) { |
||||
case nodes.length - 1: |
||||
extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; |
||||
break; |
||||
default : |
||||
extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; |
||||
} |
||||
BI.defaults(node, extend); |
||||
} |
||||
}); |
||||
return nodes; |
||||
}, |
||||
|
||||
populate: function () { |
||||
this.tree.populate(); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.tree.getValue(); |
||||
} |
||||
}); |
||||
BI.PlatformLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.platform_level_tree", BI.PlatformLevelTree); |
||||
|
||||
|
||||
BI.DemoLevelTree = BI.inherit(BI.Widget, { |
||||
|
||||
render: function () { |
||||
var self = this; |
||||
return { |
||||
type: "bi.vtape", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.platform_level_tree", |
||||
ref: function () { |
||||
self.tree = this; |
||||
}, |
||||
itemsCreator: function (op, callback) { |
||||
if (!op.node) {// 根节点
|
||||
callback([{ |
||||
id: 1, |
||||
pId: 0, |
||||
text: "A", |
||||
value: 1, |
||||
isParent: true |
||||
}, { |
||||
id: 2, |
||||
pId: 0, |
||||
text: "B", |
||||
value: 2, |
||||
isParent: true, |
||||
open: true |
||||
}]); |
||||
} else { |
||||
if (op.node.id == 1) { |
||||
callback([ |
||||
{ |
||||
id: 11, |
||||
pId: 1, |
||||
text: "test11", |
||||
value: 11, |
||||
layer: 1, |
||||
isParent: true |
||||
}, |
||||
{ |
||||
id: 12, |
||||
pId: 1, |
||||
text: "test12", |
||||
value: 12, |
||||
layer: 1 |
||||
}, |
||||
{ |
||||
id: 13, |
||||
pId: 1, |
||||
text: "test13", |
||||
value: 13, |
||||
layer: 1 |
||||
}, |
||||
{ |
||||
id: 14, |
||||
pId: 1, |
||||
text: "test14", |
||||
value: 14, |
||||
layer: 1, |
||||
height: 35 |
||||
}, |
||||
{ |
||||
id: 15, |
||||
pId: 1, |
||||
text: "test15", |
||||
value: 15, |
||||
layer: 1 |
||||
}, |
||||
{ |
||||
id: 16, |
||||
pId: 1, |
||||
text: "test16", |
||||
value: 16, |
||||
layer: 1 |
||||
}, |
||||
{id: 17, pId: 1, text: "test17", layer: 1, value: 17} |
||||
]); |
||||
} else if (op.node.id == 2) { |
||||
callback([{ |
||||
id: 21, |
||||
pId: 2, |
||||
text: "test21", |
||||
value: 21, |
||||
layer: 1 |
||||
}, |
||||
{ |
||||
id: 22, |
||||
pId: 2, |
||||
text: "test22", |
||||
value: 22, |
||||
layer: 1 |
||||
}]); |
||||
} else if (op.node.id == 11) { |
||||
callback([{ |
||||
id: 111, |
||||
pId: 11, |
||||
text: "test111", |
||||
value: 111, |
||||
layer: 2 |
||||
}]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, { |
||||
el: { |
||||
type: "bi.button", |
||||
text: "确定", |
||||
handler: function () { |
||||
BI.Msg.toast(JSON.stringify(self.tree.getValue())); |
||||
} |
||||
}, |
||||
height: 25 |
||||
}] |
||||
|
||||
}; |
||||
}, |
||||
|
||||
mounted: function () { |
||||
|
||||
} |
||||
}); |
||||
BI.shortcut("demo.platform_level_tree", BI.DemoLevelTree); |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,325 @@
|
||||
;(function () { |
||||
function initWatch(vm, watch) { |
||||
vm._watchers || (vm._watchers = []); |
||||
for (var key in watch) { |
||||
var handler = watch[key]; |
||||
if (BI.isArray(handler)) { |
||||
for (var i = 0; i < handler.length; i++) { |
||||
vm._watchers.push(createWatcher(vm, key, handler[i])); |
||||
} |
||||
} else { |
||||
vm._watchers.push(createWatcher(vm, key, handler)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function createWatcher(vm, keyOrFn, handler) { |
||||
return Fix.watch(vm.store, keyOrFn, _.bind(handler, vm), { |
||||
store: vm.store |
||||
}); |
||||
} |
||||
|
||||
var target = null; |
||||
var targetStack = []; |
||||
|
||||
function pushTarget(_target) { |
||||
if (target) targetStack.push(target); |
||||
Fix.Model.target = target = _target; |
||||
} |
||||
|
||||
function popTarget() { |
||||
Fix.Model.target = target = targetStack.pop(); |
||||
} |
||||
|
||||
var context = null; |
||||
var contextStack = []; |
||||
|
||||
function pushContext(_context) { |
||||
if (context) contextStack.push(context); |
||||
Fix.Model.context = context = _context; |
||||
} |
||||
|
||||
function popContext() { |
||||
Fix.Model.context = context = contextStack.pop(); |
||||
} |
||||
|
||||
var oldWatch = Fix.watch; |
||||
Fix.watch = function (model, expOrFn, cb, options) { |
||||
if (BI.isPlainObject(cb)) { |
||||
options = cb; |
||||
cb = cb.handler; |
||||
} |
||||
if (typeof cb === "string") { |
||||
cb = model[cb]; |
||||
} |
||||
return oldWatch.call(this, model, expOrFn, function () { |
||||
options && options.store && pushTarget(options.store); |
||||
var res = cb.apply(this, arguments); |
||||
options && options.store && popTarget(); |
||||
return res; |
||||
}, options); |
||||
}; |
||||
|
||||
function findStore(widget) { |
||||
if (target != null) { |
||||
return target; |
||||
} |
||||
widget = widget || context; |
||||
var p = widget; |
||||
while (p) { |
||||
if (p instanceof Fix.Model || p.store || p.__cacheStore) { |
||||
break; |
||||
} |
||||
p = p._parent || (p.options && p.options.element); |
||||
} |
||||
if (p) { |
||||
if (p instanceof Fix.Model) { |
||||
return widget.__cacheStore = p; |
||||
} |
||||
widget.__cacheStore = p.store || p.__cacheStore; |
||||
return p.__cacheStore || p.store; |
||||
} |
||||
} |
||||
|
||||
var _create = BI.createWidget; |
||||
BI.createWidget = function (item, options, context) { |
||||
var pushed = false; |
||||
if (BI.isWidget(options)) { |
||||
pushContext(options); |
||||
pushed = true; |
||||
} else if (context != null) { |
||||
pushContext(context); |
||||
pushed = true; |
||||
} |
||||
var result = _create.apply(this, arguments); |
||||
pushed && popContext(); |
||||
return result; |
||||
}; |
||||
|
||||
_.each(["populate", "addItems", "prependItems"], function (name) { |
||||
var old = BI.Loader.prototype[name]; |
||||
BI.Loader.prototype[name] = function () { |
||||
pushContext(this); |
||||
var result = old.apply(this, arguments); |
||||
popContext(); |
||||
return result; |
||||
}; |
||||
}); |
||||
|
||||
function createStore() { |
||||
var needPop = false; |
||||
if (_global.Fix && this._store) { |
||||
var store = findStore(this.options.context || this.options.element); |
||||
if (store) { |
||||
pushTarget(store); |
||||
needPop = true; |
||||
} |
||||
this.store = this._store(); |
||||
this.store && (this.store._widget = this); |
||||
needPop && popTarget(); |
||||
needPop = false; |
||||
pushTarget(this.store); |
||||
if (this.store instanceof Fix.Model) { |
||||
this.model = this.store.model; |
||||
} else { |
||||
this.model = this.store; |
||||
} |
||||
needPop = true; |
||||
} |
||||
return needPop; |
||||
} |
||||
|
||||
BI.Widget.prototype._init = function () { |
||||
BI.Widget.superclass._init.apply(this, arguments); |
||||
this._initRoot(); |
||||
this._initElementWidth(); |
||||
this._initElementHeight(); |
||||
this._initVisual(); |
||||
this._initState(); |
||||
if (this.beforeInit) { |
||||
this.__asking = true; |
||||
this.beforeInit(BI.bind(function () { |
||||
if (this.model && this.model.$vm) { |
||||
this.model.$vm.$digest() |
||||
} |
||||
this._render(); |
||||
}, this)); |
||||
if (this.__asking === true) { |
||||
this.__async = true; |
||||
} |
||||
} else { |
||||
this._render(); |
||||
} |
||||
} |
||||
|
||||
var _init = BI.Widget.prototype._init; |
||||
BI.Widget.prototype._init = function () { |
||||
var self = this; |
||||
var needPop = createStore.call(this); |
||||
_init.apply(this, arguments); |
||||
needPop && popTarget(); |
||||
}; |
||||
|
||||
var _render = BI.Widget.prototype._render; |
||||
BI.Widget.prototype._render = function () { |
||||
var needPop = false; |
||||
if (_global.Fix && this._store) { |
||||
needPop = true; |
||||
pushTarget(this.store); |
||||
initWatch(this, this.watch); |
||||
} |
||||
_render.apply(this, arguments); |
||||
needPop && popTarget(); |
||||
}; |
||||
|
||||
var unMount = BI.Widget.prototype.__d; |
||||
BI.Widget.prototype.__d = function () { |
||||
unMount.apply(this, arguments); |
||||
this.store && BI.isFunction(this.store.destroy) && this.store.destroy(); |
||||
BI.each(this._watchers, function (i, unwatches) { |
||||
unwatches = BI.isArray(unwatches) ? unwatches : [unwatches]; |
||||
BI.each(unwatches, function (j, unwatch) { |
||||
unwatch(); |
||||
}); |
||||
}); |
||||
this._watchers && (this._watchers = []); |
||||
if (this.store) { |
||||
this.store._parent && (this.store._parent = null); |
||||
this.store._widget && (this.store._widget = null); |
||||
this.store = null; |
||||
} |
||||
delete this.__cacheStore; |
||||
}; |
||||
|
||||
_.each(["_mount"], function (name) { |
||||
var old = BI.Widget.prototype[name]; |
||||
old && (BI.Widget.prototype[name] = function () { |
||||
this.store && pushTarget(this.store); |
||||
var res = old.apply(this, arguments); |
||||
this.store && popTarget(); |
||||
return res; |
||||
}); |
||||
}); |
||||
|
||||
var additionFunc = function () { |
||||
BI.nextTick(function () { |
||||
Fix && Fix.refreshAll && Fix.refreshAll(); |
||||
}); |
||||
}; |
||||
|
||||
$(document).ajaxComplete(additionFunc); |
||||
|
||||
if (BI.history) { |
||||
var navigate = BI.history.navigate; |
||||
// navigate之后不会立即变化有一段延迟
|
||||
BI.history.navigate = function () { |
||||
navigate.apply(this, arguments); |
||||
BI.defer(function () { |
||||
additionFunc(); |
||||
}, 200); |
||||
} |
||||
var back = window.history.back; |
||||
window.history.back = function () { |
||||
back.apply(this, arguments); |
||||
BI.defer(function () { |
||||
additionFunc(); |
||||
}, 200); |
||||
} |
||||
} |
||||
|
||||
if (BI.Router) { |
||||
var execute = BI.Router.prototype.execute; |
||||
BI.Router.prototype.execute = function () { |
||||
execute.apply(this, arguments); |
||||
additionFunc(); |
||||
} |
||||
} |
||||
|
||||
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min", |
||||
"sortBy", "groupBy", "indexBy", "countBy", "partition", |
||||
"keys", "allKeys", "values", "pairs", "invert", |
||||
"mapObject", "findKey", "pick", "omit", "tap"], function (name) { |
||||
var old = BI[name]; |
||||
BI[name] = function (obj, fn, context) { |
||||
return typeof fn === "function" ? old(obj, function (key, value) { |
||||
if (!(key in Fix.$$skipArray)) { |
||||
return fn.apply(this, arguments); |
||||
} |
||||
}, context) : old.apply(this, arguments); |
||||
}; |
||||
}); |
||||
BI.isEmpty = function (ob) { |
||||
if (BI.isPlainObject(ob) && ob.__ob__) { |
||||
return BI.keys(ob).length === 0; |
||||
} |
||||
return _.isEmpty(ob); |
||||
}; |
||||
BI.keys = function (ob) { |
||||
var keys = _.keys(ob); |
||||
var nKeys = []; |
||||
for (var i = 0; i < keys.length; i++) { |
||||
if (!(keys[i] in Fix.$$skipArray)) { |
||||
nKeys.push(keys[i]); |
||||
} |
||||
} |
||||
return nKeys; |
||||
}; |
||||
BI.values = function (ob) { |
||||
var keys = BI.keys(obj); |
||||
var length = keys.length; |
||||
var values = []; |
||||
for (var i = 0; i < length; i++) { |
||||
values[i] = obj[keys[i]]; |
||||
} |
||||
return values; |
||||
}; |
||||
BI.extend = function () { |
||||
var args = Array.prototype.slice.call(arguments); |
||||
if (args.length < 1) { |
||||
return {}; |
||||
} |
||||
var object = args[0]; |
||||
var i = 1; |
||||
while (i < args.length) { |
||||
BI.each(args[i], function (key, v) { |
||||
object[key] = v; |
||||
}); |
||||
i++; |
||||
} |
||||
return object; |
||||
}; |
||||
BI.size = function (ob) { |
||||
if (BI.isPlainObject(ob) && ob.__ob__) { |
||||
return BI.keys(ob).length; |
||||
} |
||||
return _.size(ob); |
||||
}; |
||||
BI.isEmptyObject = function (ob) { |
||||
return BI.size(ob) === 0; |
||||
}; |
||||
BI.deepClone = function (ob) { |
||||
return Fix.toJSON(ob); |
||||
}; |
||||
|
||||
Fix.set = function (obj, k, v) { |
||||
try { |
||||
if(obj) { |
||||
obj[k] = v; |
||||
} |
||||
} catch (e) { |
||||
|
||||
} finally { |
||||
return _.cloneDeep(obj); |
||||
} |
||||
} |
||||
Fix.del = function (obj, k) { |
||||
try { |
||||
delete obj[k]; |
||||
} catch (e) { |
||||
|
||||
} finally { |
||||
return _.cloneDeep(obj); |
||||
} |
||||
} |
||||
BI.watch = Fix.watch; |
||||
}()); |
Binary file not shown.
Before Width: | Height: | Size: 260 KiB After Width: | Height: | Size: 253 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 11 KiB |
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim" |
||||
lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge" |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue