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
1.4 KiB
59 lines
1.4 KiB
import { BasicButton } from "./button.basic"; |
|
import { shortcut, extend, Controller } from "../../../core"; |
|
|
|
/** |
|
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 |
|
* |
|
* Created by GUY on 2015/9/9. |
|
* @class NodeButton |
|
* @extends BasicButton |
|
* @abstract |
|
*/ |
|
@shortcut() |
|
export class NodeButton extends BasicButton { |
|
static xtype = "bi.node_button"; |
|
|
|
_defaultConfig() { |
|
const conf = super._defaultConfig(arguments); |
|
|
|
return extend(conf, { |
|
_baseCls: `${conf._baseCls || ""} bi-node`, |
|
open: false, |
|
once: false, |
|
}); |
|
} |
|
|
|
_initRef() { |
|
if (this.isOpened()) { |
|
this.setOpened(this.isOpened()); |
|
} |
|
super._initRef(...arguments); |
|
} |
|
|
|
doClick() { |
|
super.doClick(...arguments); |
|
this.setOpened(!this.isOpened()); |
|
} |
|
|
|
isOpened() { |
|
return !!this.options.open; |
|
} |
|
|
|
setOpened(b) { |
|
this.options.open = !!b; |
|
} |
|
|
|
triggerCollapse() { |
|
if (this.isOpened()) { |
|
this.setOpened(false); |
|
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this); |
|
} |
|
} |
|
|
|
triggerExpand() { |
|
if (!this.isOpened()) { |
|
this.setOpened(true); |
|
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); |
|
} |
|
} |
|
}
|
|
|