Treecat
2 years ago
20 changed files with 1094 additions and 944 deletions
@ -1,54 +1,60 @@
|
||||
import { BasicButton } from "./button.basic" |
||||
import { shortcut, extend, Controller } from "../../../core" |
||||
|
||||
/** |
||||
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 |
||||
* |
||||
* Created by GUY on 2015/9/9. |
||||
* @class BI.NodeButton |
||||
* @extends BI.BasicButton |
||||
* @class NodeButton |
||||
* @extends BasicButton |
||||
* @abstract |
||||
*/ |
||||
BI.NodeButton = BI.inherit(BI.BasicButton, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); |
||||
@shortcut() |
||||
export class NodeButton extends BasicButton { |
||||
|
||||
static xtype = "bi.node_button"; |
||||
|
||||
_defaultConfig() { |
||||
const conf = super._defaultConfig(arguments); |
||||
|
||||
return BI.extend(conf, { |
||||
return extend(conf, { |
||||
_baseCls: (conf._baseCls || "") + " bi-node", |
||||
open: false, |
||||
once: false, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_initRef: function () { |
||||
_initRef() { |
||||
if (this.isOpened()) { |
||||
this.setOpened(this.isOpened()); |
||||
} |
||||
BI.NodeButton.superclass._initRef.apply(this, arguments); |
||||
}, |
||||
super._initRef.apply(this, arguments); |
||||
} |
||||
|
||||
doClick: function () { |
||||
BI.NodeButton.superclass.doClick.apply(this, arguments); |
||||
doClick() { |
||||
super.doClick.apply(this, arguments); |
||||
this.setOpened(!this.isOpened()); |
||||
}, |
||||
} |
||||
|
||||
isOpened: function () { |
||||
isOpened() { |
||||
return !!this.options.open; |
||||
}, |
||||
} |
||||
|
||||
setOpened: function (b) { |
||||
setOpened(b) { |
||||
this.options.open = !!b; |
||||
}, |
||||
} |
||||
|
||||
triggerCollapse: function () { |
||||
triggerCollapse() { |
||||
if (this.isOpened()) { |
||||
this.setOpened(false); |
||||
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this); |
||||
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
triggerExpand: function () { |
||||
triggerExpand() { |
||||
if (!this.isOpened()) { |
||||
this.setOpened(true); |
||||
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); |
||||
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); |
||||
} |
||||
}, |
||||
}); |
||||
BI.shortcut("bi.node_button", BI.NodeButton); |
||||
} |
||||
} |
@ -1,87 +1,94 @@
|
||||
import { BasicButton } from "../button.basic"; |
||||
import { shortcut, extend, isNumber, createWidget } from "../../../../core"; |
||||
|
||||
|
||||
/** |
||||
* 图片的button |
||||
* |
||||
* Created by GUY on 2016/1/27. |
||||
* @class BI.ImageButton |
||||
* @extends BI.BasicButton |
||||
* @class ImageButton |
||||
* @extends BasicButton |
||||
*/ |
||||
BI.ImageButton = BI.inherit(BI.BasicButton, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.ImageButton.superclass._defaultConfig.apply(this, arguments); |
||||
@shortcut() |
||||
export class ImageButton extends BasicButton { |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
static xtype = "bi.image_button"; |
||||
|
||||
_defaultConfig() { |
||||
const conf = super._defaultConfig(arguments); |
||||
|
||||
return BI.extend(conf, { |
||||
return extend(conf, { |
||||
baseCls: (conf.baseCls || "") + " bi-image-button", |
||||
src: "", |
||||
iconWidth: "100%", |
||||
iconHeight: "100%", |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
render: function () { |
||||
var o = this.options; |
||||
this.image = BI.createWidget({ |
||||
render() { |
||||
const o = this.options; |
||||
this.image = createWidget({ |
||||
type: "bi.img", |
||||
width: o.iconWidth, |
||||
height: o.iconHeight, |
||||
src: o.src, |
||||
}); |
||||
if (BI.isNumber(o.iconWidth) || BI.isNumber(o.iconHeight)) { |
||||
BI.createWidget({ |
||||
if (isNumber(o.iconWidth) || isNumber(o.iconHeight)) { |
||||
createWidget({ |
||||
type: "bi.center_adapt", |
||||
element: this, |
||||
items: [this.image], |
||||
}); |
||||
} else { |
||||
BI.createWidget({ |
||||
createWidget({ |
||||
type: "bi.adaptive", |
||||
element: this, |
||||
items: [this.image], |
||||
scrollable: false, |
||||
}); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setWidth: function (w) { |
||||
BI.ImageButton.superclass.setWidth.apply(this, arguments); |
||||
setWidth(w) { |
||||
super.setWidth.apply(this, arguments); |
||||
this.options.width = w; |
||||
}, |
||||
} |
||||
|
||||
setHeight: function (h) { |
||||
BI.ImageButton.superclass.setHeight.apply(this, arguments); |
||||
setHeight(h) { |
||||
super.setHeight.apply(this, arguments); |
||||
this.options.height = h; |
||||
}, |
||||
} |
||||
|
||||
setImageWidth: function (w) { |
||||
setImageWidth(w) { |
||||
this.image.setWidth(w); |
||||
}, |
||||
} |
||||
|
||||
setImageHeight: function (h) { |
||||
setImageHeight(h) { |
||||
this.image.setHeight(h); |
||||
}, |
||||
} |
||||
|
||||
getImageWidth: function () { |
||||
getImageWidth() { |
||||
return this.image.element.width(); |
||||
}, |
||||
} |
||||
|
||||
getImageHeight: function () { |
||||
getImageHeight() { |
||||
return this.image.element.height(); |
||||
}, |
||||
} |
||||
|
||||
setSrc: function (src) { |
||||
setSrc(src) { |
||||
this.options.src = src; |
||||
this.image.setSrc(src); |
||||
}, |
||||
} |
||||
|
||||
getSrc: function () { |
||||
getSrc() { |
||||
return this.image.getSrc(); |
||||
}, |
||||
} |
||||
|
||||
doClick: function () { |
||||
BI.ImageButton.superclass.doClick.apply(this, arguments); |
||||
doClick() { |
||||
super.doClick.apply(this, arguments); |
||||
if (this.isValid()) { |
||||
this.fireEvent(BI.ImageButton.EVENT_CHANGE, this); |
||||
this.fireEvent(ImageButton.EVENT_CHANGE, this); |
||||
} |
||||
}, |
||||
}); |
||||
BI.ImageButton.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.image_button", BI.ImageButton); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue