zsmj1994
4 years ago
19 changed files with 281 additions and 222 deletions
@ -0,0 +1,72 @@
|
||||
!(function () { |
||||
var Widget = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "bi-tree-expander", |
||||
layer: 0, // 第几层级
|
||||
isLastNode: false, // 是不是最后一个
|
||||
isFirstNode: false, // 是不是第一个
|
||||
selectable: false, |
||||
}, |
||||
|
||||
render: function () { |
||||
|
||||
var self = this; |
||||
var o = this.options; |
||||
|
||||
this.trigger = BI.createWidget(o.el, { |
||||
forceNotSelected: !o.selectable, |
||||
}); |
||||
this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) { |
||||
o.selectable && self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
return { |
||||
type: "bi.expander", |
||||
ref: function (_ref) { |
||||
self.expander = _ref; |
||||
}, |
||||
trigger: o.selectable ? "" : "click", |
||||
el: this.trigger, |
||||
isDefaultInit: o.isDefaultInit, |
||||
popup: { |
||||
type: "bi.tree_expander.popup", |
||||
layer: o.layer || o.el.layer, |
||||
isLastNode: o.isLastNode || o.el.isLastNode, |
||||
isFirstNode: o.isFirstNode || o.el.isFirstNode, |
||||
el: o.popup, |
||||
}, |
||||
listeners: [ |
||||
{ |
||||
eventName: BI.Controller.EVENT_CHANGE, |
||||
action: function (type) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
if (BI.contains(v, this.trigger.getValue())) { |
||||
this.trigger.setSelected(true); |
||||
this.expander.setValue([]); |
||||
} else { |
||||
this.trigger.setSelected(false); |
||||
this.expander.setValue(v); |
||||
} |
||||
}, |
||||
|
||||
getValue: function () { |
||||
if (this.trigger.isSelected()) { |
||||
return [this.trigger.getValue()]; |
||||
} |
||||
return this.expander.getValue(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.expander.populate(items); |
||||
}, |
||||
}); |
||||
|
||||
BI.shortcut("bi.tree_expander", Widget); |
||||
}()); |
@ -0,0 +1,47 @@
|
||||
!(function () { |
||||
var Widget = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "bi-tree-expander-popup", |
||||
layer: 0, // 第几层级
|
||||
el: {}, |
||||
isLastNode: false, |
||||
}, |
||||
|
||||
render: function () { |
||||
|
||||
var self = this; |
||||
var o = this.options; |
||||
|
||||
this.popupView = BI.createWidget(o.el, this); |
||||
|
||||
this.popupView.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.popupView.element.css("margin-left", -12 * o.layer); |
||||
this.element.css("margin-left", 12 * o.layer); |
||||
|
||||
return { |
||||
type: "bi.vertical", |
||||
cls: !o.isLastNode ? "line" : "", |
||||
scrolly: null, |
||||
items: [ |
||||
this.popupView, |
||||
], |
||||
}; |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.popupView.setValue(v); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.popupview.getValue(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.popupview.populate(items); |
||||
}, |
||||
}); |
||||
|
||||
BI.shortcut("bi.tree_expander.popup", Widget); |
||||
}()); |
@ -0,0 +1,9 @@
|
||||
@import "../../index"; |
||||
.bi-tree-expander-popup.line:before { |
||||
position: absolute; |
||||
content: ""; |
||||
border-left: 1px dashed #D0D4DA; |
||||
height: 100%; |
||||
left: 11px; |
||||
} |
||||
|
Loading…
Reference in new issue