forked from fanruan/fineui
Impact-吴家豪
2 years ago
21 changed files with 1075 additions and 945 deletions
@ -1,54 +1,60 @@ |
|||||||
|
import { BasicButton } from "./button.basic" |
||||||
|
import { shortcut, extend, Controller } from "../../../core" |
||||||
|
|
||||||
/** |
/** |
||||||
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 |
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 |
||||||
* |
* |
||||||
* Created by GUY on 2015/9/9. |
* Created by GUY on 2015/9/9. |
||||||
* @class BI.NodeButton |
* @class NodeButton |
||||||
* @extends BI.BasicButton |
* @extends BasicButton |
||||||
* @abstract |
* @abstract |
||||||
*/ |
*/ |
||||||
BI.NodeButton = BI.inherit(BI.BasicButton, { |
@shortcut() |
||||||
_defaultConfig: function () { |
export class NodeButton extends BasicButton { |
||||||
var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); |
|
||||||
|
static xtype = "bi.node_button"; |
||||||
|
|
||||||
|
_defaultConfig() { |
||||||
|
const conf = super._defaultConfig(arguments); |
||||||
|
|
||||||
return BI.extend(conf, { |
return extend(conf, { |
||||||
_baseCls: (conf._baseCls || "") + " bi-node", |
_baseCls: (conf._baseCls || "") + " bi-node", |
||||||
open: false, |
open: false, |
||||||
once: false, |
once: false, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_initRef: function () { |
_initRef() { |
||||||
if (this.isOpened()) { |
if (this.isOpened()) { |
||||||
this.setOpened(this.isOpened()); |
this.setOpened(this.isOpened()); |
||||||
} |
} |
||||||
BI.NodeButton.superclass._initRef.apply(this, arguments); |
super._initRef.apply(this, arguments); |
||||||
}, |
} |
||||||
|
|
||||||
doClick: function () { |
doClick() { |
||||||
BI.NodeButton.superclass.doClick.apply(this, arguments); |
super.doClick.apply(this, arguments); |
||||||
this.setOpened(!this.isOpened()); |
this.setOpened(!this.isOpened()); |
||||||
}, |
} |
||||||
|
|
||||||
isOpened: function () { |
isOpened() { |
||||||
return !!this.options.open; |
return !!this.options.open; |
||||||
}, |
} |
||||||
|
|
||||||
setOpened: function (b) { |
setOpened(b) { |
||||||
this.options.open = !!b; |
this.options.open = !!b; |
||||||
}, |
} |
||||||
|
|
||||||
triggerCollapse: function () { |
triggerCollapse() { |
||||||
if (this.isOpened()) { |
if (this.isOpened()) { |
||||||
this.setOpened(false); |
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()) { |
if (!this.isOpened()) { |
||||||
this.setOpened(true); |
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 |
* 图片的button |
||||||
* |
* |
||||||
* Created by GUY on 2016/1/27. |
* Created by GUY on 2016/1/27. |
||||||
* @class BI.ImageButton |
* @class ImageButton |
||||||
* @extends BI.BasicButton |
* @extends BasicButton |
||||||
*/ |
*/ |
||||||
BI.ImageButton = BI.inherit(BI.BasicButton, { |
@shortcut() |
||||||
_defaultConfig: function () { |
export class ImageButton extends BasicButton { |
||||||
var conf = BI.ImageButton.superclass._defaultConfig.apply(this, arguments); |
|
||||||
|
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", |
baseCls: (conf.baseCls || "") + " bi-image-button", |
||||||
src: "", |
src: "", |
||||||
iconWidth: "100%", |
iconWidth: "100%", |
||||||
iconHeight: "100%", |
iconHeight: "100%", |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
render: function () { |
render() { |
||||||
var o = this.options; |
const o = this.options; |
||||||
this.image = BI.createWidget({ |
this.image = createWidget({ |
||||||
type: "bi.img", |
type: "bi.img", |
||||||
width: o.iconWidth, |
width: o.iconWidth, |
||||||
height: o.iconHeight, |
height: o.iconHeight, |
||||||
src: o.src, |
src: o.src, |
||||||
}); |
}); |
||||||
if (BI.isNumber(o.iconWidth) || BI.isNumber(o.iconHeight)) { |
if (isNumber(o.iconWidth) || isNumber(o.iconHeight)) { |
||||||
BI.createWidget({ |
createWidget({ |
||||||
type: "bi.center_adapt", |
type: "bi.center_adapt", |
||||||
element: this, |
element: this, |
||||||
items: [this.image], |
items: [this.image], |
||||||
}); |
}); |
||||||
} else { |
} else { |
||||||
BI.createWidget({ |
createWidget({ |
||||||
type: "bi.adaptive", |
type: "bi.adaptive", |
||||||
element: this, |
element: this, |
||||||
items: [this.image], |
items: [this.image], |
||||||
scrollable: false, |
scrollable: false, |
||||||
}); |
}); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setWidth: function (w) { |
setWidth(w) { |
||||||
BI.ImageButton.superclass.setWidth.apply(this, arguments); |
super.setWidth.apply(this, arguments); |
||||||
this.options.width = w; |
this.options.width = w; |
||||||
}, |
} |
||||||
|
|
||||||
setHeight: function (h) { |
setHeight(h) { |
||||||
BI.ImageButton.superclass.setHeight.apply(this, arguments); |
super.setHeight.apply(this, arguments); |
||||||
this.options.height = h; |
this.options.height = h; |
||||||
}, |
} |
||||||
|
|
||||||
setImageWidth: function (w) { |
setImageWidth(w) { |
||||||
this.image.setWidth(w); |
this.image.setWidth(w); |
||||||
}, |
} |
||||||
|
|
||||||
setImageHeight: function (h) { |
setImageHeight(h) { |
||||||
this.image.setHeight(h); |
this.image.setHeight(h); |
||||||
}, |
} |
||||||
|
|
||||||
getImageWidth: function () { |
getImageWidth() { |
||||||
return this.image.element.width(); |
return this.image.element.width(); |
||||||
}, |
} |
||||||
|
|
||||||
getImageHeight: function () { |
getImageHeight() { |
||||||
return this.image.element.height(); |
return this.image.element.height(); |
||||||
}, |
} |
||||||
|
|
||||||
setSrc: function (src) { |
setSrc(src) { |
||||||
this.options.src = src; |
this.options.src = src; |
||||||
this.image.setSrc(src); |
this.image.setSrc(src); |
||||||
}, |
} |
||||||
|
|
||||||
getSrc: function () { |
getSrc() { |
||||||
return this.image.getSrc(); |
return this.image.getSrc(); |
||||||
}, |
} |
||||||
|
|
||||||
doClick: function () { |
doClick() { |
||||||
BI.ImageButton.superclass.doClick.apply(this, arguments); |
super.doClick.apply(this, arguments); |
||||||
if (this.isValid()) { |
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); |
|
||||||
|
@ -0,0 +1,17 @@ |
|||||||
|
export { BasicButton } from "./button.basic"; |
||||||
|
export { NodeButton } from "./button.node"; |
||||||
|
export { Button } from "./buttons/button"; |
||||||
|
export { IconButton } from "./buttons/button.icon"; |
||||||
|
export { ImageButton } from "./buttons/button.image"; |
||||||
|
export { TextButton } from "./buttons/button.text"; |
||||||
|
export { BlankIconIconTextItem } from "./listitem/blankiconicontextitem"; |
||||||
|
export { BlankIconTextIconItem } from "./listitem/blankicontexticonitem"; |
||||||
|
export { BlankIconTextItem } from "./listitem/blankicontextitem"; |
||||||
|
export { IconTextIconItem } from "./listitem/icontexticonitem"; |
||||||
|
export { IconTextItem } from "./listitem/icontextitem"; |
||||||
|
export { TextIconItem } from "./listitem/texticonitem"; |
||||||
|
export { TextItem } from "./listitem/textitem"; |
||||||
|
export { IconTextIconNode } from "./node/icontexticonnode"; |
||||||
|
export { IconTextNode } from "./node/icontextnode"; |
||||||
|
export { TextIconNode } from "./node/texticonnode"; |
||||||
|
export { TextNode } from "./node/textnode"; |
Loading…
Reference in new issue