You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.5 KiB
59 lines
2.5 KiB
BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, { |
|
_defaultConfig: function () { |
|
return BI.extend(BI.TreeNodeSwitcher.superclass._defaultConfig.apply(this, arguments), { |
|
baseCls: "bi-tree-node-switcher", |
|
iconWidth: 24, |
|
iconHeight: 24, |
|
isFirstNode: false, |
|
isLastNode: false, |
|
layer: 0 |
|
}); |
|
}, |
|
|
|
render: function () { |
|
|
|
const [collapse, expand] = this.getIconCls(); |
|
|
|
return { |
|
type: "bi.icon_label", |
|
iconWidth: this.options.iconWidth, |
|
iconHeight: this.options.iconHeight, |
|
cls: this.options.open ? expand : collapse, |
|
}; |
|
}, |
|
|
|
getIconCls: function () { |
|
var options = this.options; |
|
if (options.layer === 0 && options.isFirstNode && options.isLastNode) { |
|
// 只有一层,并且是第一个节点,并且是最后一个节点 |
|
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type1", "tree-expand-icon-type1"]; |
|
} else if (options.layer === 0 && options.isFirstNode) { |
|
// 第一层,并且是第一个节点 |
|
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type2", "tree-expand-icon-type2"]; |
|
} else if (options.isLastNode) { |
|
// 最后一个节点 |
|
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type4", "tree-expand-icon-type4"]; |
|
} else { |
|
// 其他情况 |
|
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; |
|
} |
|
}, |
|
|
|
setOpened: function (b) { |
|
BI.TreeNodeSwitcher.superclass.setOpened.apply(this, arguments); |
|
const [collapse, expand] = this.getIconCls(); |
|
if (b) { |
|
this.element.addClass(expand).removeClass(collapse); |
|
} else { |
|
this.element.addClass(collapse).removeClass(expand); |
|
} |
|
}, |
|
|
|
doClick: function () { |
|
BI.TreeNodeSwitcher.superclass.doClick.apply(this, arguments); |
|
this.fireEvent(BI.TreeNodeSwitcher.EVENT_CHANGE, this); |
|
} |
|
}); |
|
|
|
BI.TreeNodeSwitcher.EVENT_CHANGE = "EVENT_CHANGE"; |
|
BI.shortcut("bi.tree_node_switcher", BI.TreeNodeSwitcher);
|
|
|