Browse Source

Fixed merge conflict

es6
Impact-吴家豪 2 years ago
parent
commit
63ab82f65f
  1. 52
      src/base/single/bar/bar.loading.js
  2. 391
      src/base/single/button/button.basic.js
  3. 56
      src/base/single/button/button.node.js
  4. 48
      src/base/single/button/buttons/button.icon.js
  5. 85
      src/base/single/button/buttons/button.image.js
  6. 165
      src/base/single/button/buttons/button.js
  7. 72
      src/base/single/button/buttons/button.text.js
  8. 17
      src/base/single/button/index.js
  9. 79
      src/base/single/button/listitem/blankiconicontextitem.js
  10. 74
      src/base/single/button/listitem/blankicontexticonitem.js
  11. 75
      src/base/single/button/listitem/blankicontextitem.js
  12. 76
      src/base/single/button/listitem/icontexticonitem.js
  13. 73
      src/base/single/button/listitem/icontextitem.js
  14. 71
      src/base/single/button/listitem/texticonitem.js
  15. 69
      src/base/single/button/listitem/textitem.js
  16. 67
      src/base/single/button/node/icontexticonnode.js
  17. 66
      src/base/single/button/node/icontextnode.js
  18. 67
      src/base/single/button/node/texticonnode.js
  19. 65
      src/base/single/button/node/textnode.js
  20. 1
      src/base/single/index.js
  21. 3
      src/core/index.js

52
src/base/single/bar/bar.loading.js

@ -1,21 +1,26 @@
import { shortcut, emptyFn } from "../../../core"
/** /**
* guy * guy
* 加载条 * 加载条
* @type {*|void|Object} * @type {*|void|Object}
*/ */
BI.LoadingBar = BI.inherit(BI.Single, { @shortcut()
_defaultConfig: function () { class LoadingBar extends BI.Single {
var conf = BI.LoadingBar.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { static xtype = "bi.loading_bar";
_defaultConfig() {
const conf = super._defaultConfig.apply(this, arguments);
return {
...conf,
baseCls: (conf.baseCls || "") + " bi-loading-bar bi-tips", baseCls: (conf.baseCls || "") + " bi-loading-bar bi-tips",
height: 30, height: 30,
handler: BI.emptyFn, handler: emptyFn,
}); }
}, }
render: function () { render() {
var self = this;
this.loaded = BI.createWidget({ this.loaded = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",
cls: "loading-text bi-list-item-simple", cls: "loading-text bi-list-item-simple",
@ -23,8 +28,8 @@ BI.LoadingBar = BI.inherit(BI.Single, {
width: 120, width: 120,
handler: this.options.handler, handler: this.options.handler,
}); });
this.loaded.on(BI.Controller.EVENT_CHANGE, function (type) { this.loaded.on(BI.Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(BI.Controller.EVENT_CHANGE, args);
}); });
this.loading = BI.createWidget({ this.loading = BI.createWidget({
@ -33,11 +38,11 @@ BI.LoadingBar = BI.inherit(BI.Single, {
height: this.options.height, height: this.options.height,
cls: "loading-background cursor-default", cls: "loading-background cursor-default",
}); });
var loaded = BI.createWidget({ const loaded = BI.createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.loaded], items: [this.loaded],
}); });
var loading = BI.createWidget({ const loading = BI.createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.loading], items: [this.loading],
}); });
@ -53,29 +58,28 @@ BI.LoadingBar = BI.inherit(BI.Single, {
}], }],
}); });
this.invisible(); this.invisible();
}, }
_reset: function () { _reset() {
this.visible(); this.visible();
this.loaded.setText(BI.i18nText("BI-Load_More")); this.loaded.setText(BI.i18nText("BI-Load_More"));
this.loaded.enable(); this.loaded.enable();
}, }
setLoaded: function () { setLoaded() {
this._reset(); this._reset();
this.cardLayout.showCardByName("loaded"); this.cardLayout.showCardByName("loaded");
}, }
setEnd: function () { setEnd() {
this.setLoaded(); this.setLoaded();
this.loaded.setText(BI.i18nText("BI-No_More_Data")); this.loaded.setText(BI.i18nText("BI-No_More_Data"));
this.loaded.disable(); this.loaded.disable();
}, }
setLoading: function () { setLoading() {
this._reset(); this._reset();
this.cardLayout.showCardByName("loading"); this.cardLayout.showCardByName("loading");
}, }
}); }
BI.shortcut("bi.loading_bar", BI.LoadingBar);

391
src/base/single/button/button.basic.js

@ -1,15 +1,24 @@
import { Single } from "../0.single"
import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject, Controller } from "../../../core"
/** /**
* guy * guy
* @class BI.BasicButton * @class BasicButton
* @extends BI.Single * @extends Single
* *
* 一般的button父级 * 一般的button父级
*/ */
BI.BasicButton = BI.inherit(BI.Single, { @shortcut()
_defaultConfig: function () { export class BasicButton extends Single {
var conf = BI.BasicButton.superclass._defaultConfig.apply(this, arguments);
static xtype = "bi.basic_button";
static EVENT_CHANGE = "BasicButton.EVENT_CHANGE";
return BI.extend(conf, { _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), _baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""),
// el: {} // 可以通过el来创建button元素 // el: {} // 可以通过el来创建button元素
value: "", value: "",
@ -24,19 +33,18 @@ BI.BasicButton = BI.inherit(BI.Single, {
shadow: false, shadow: false,
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
trigger: null, trigger: null,
handler: BI.emptyFn, handler: emptyFn,
bubble: null, bubble: null,
debounce: true debounce: true
}); });
}, }
_init: function () { _init() {
var self = this; const opts = this.options;
var opts = this.options; opts.selected = isFunction(opts.selected) ? this.__watch(opts.selected, (context, newValue) => {
opts.selected = BI.isFunction(opts.selected) ? this.__watch(opts.selected, function (context, newValue) { this.setSelected(newValue);
self.setSelected(newValue);
}) : opts.selected; }) : opts.selected;
BI.BasicButton.superclass._init.apply(this, arguments); super._init(arguments);
if (opts.shadow) { if (opts.shadow) {
this._createShadow(); this._createShadow();
@ -44,9 +52,9 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (opts.level) { if (opts.level) {
this.element.addClass("button-" + opts.level); this.element.addClass("button-" + opts.level);
} }
}, }
_initRef: function () { _initRef() {
if (this.options.selected === true) { if (this.options.selected === true) {
this.setSelected(true); this.setSelected(true);
} }
@ -54,29 +62,29 @@ BI.BasicButton = BI.inherit(BI.Single, {
BI.nextTick(() => { BI.nextTick(() => {
!this.isDestroyed() && this.bindEvent(); !this.isDestroyed() && this.bindEvent();
}); });
BI.BasicButton.superclass._initRef.apply(this, arguments); super._initRef.apply(this, arguments);
}, }
// 默认render方法 // 默认render方法
render: function () { render() {
return this.options.el; return this.options.el;
}, }
_createShadow: function () { _createShadow() {
var self = this, o = this.options; const o = this.options;
function assertMask() { const assertMask = () => {
if (!self.$mask) { if (!this.$mask) {
self.$mask = BI.createWidget(BI.isObject(o.shadow) ? o.shadow : {}, { this.$mask = createWidget(isObject(o.shadow) ? o.shadow : {}, {
type: "bi.layout", type: "bi.layout",
cls: "bi-button-mask", cls: "bi-button-mask",
}); });
self.$mask.invisible(); this.$mask.invisible();
BI.createWidget({ createWidget({
type: "bi.absolute", type: "bi.absolute",
element: self, element: this,
items: [{ items: [{
el: self.$mask, el: this.$mask,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
@ -86,48 +94,129 @@ BI.BasicButton = BI.inherit(BI.Single, {
} }
} }
this.element.mouseup(function () { this.element.mouseup(() => {
if (!self._hover && !o.isShadowShowingOnSelected) { if (!this._hover && !o.isShadowShowingOnSelected) {
assertMask(); assertMask();
self.$mask.invisible(); this.$mask.invisible();
} }
}); });
this.element.on("mouseenter." + this.getName(), function (e) { this.element.on("mouseenter." + this.getName(), (e) => {
if (self.element.__isMouseInBounds__(e)) { if (this.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && !self._hover && (o.isShadowShowingOnSelected || !self.isSelected())) { if (this.isEnabled() && !this._hover && (o.isShadowShowingOnSelected || !this.isSelected())) {
assertMask(); assertMask();
self.$mask.visible(); this.$mask.visible();
} }
} }
}); });
this.element.on("mousemove." + this.getName(), function (e) { this.element.on("mousemove." + this.getName(), (e) => {
if (!self.element.__isMouseInBounds__(e)) { if (!this.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && !self._hover) { if (this.isEnabled() && !this._hover) {
assertMask(); assertMask();
self.$mask.invisible(); this.$mask.invisible();
} }
} }
}); });
this.element.on("mouseleave." + this.getName(), function () { this.element.on("mouseleave." + this.getName(), () => {
if (self.isEnabled() && !self._hover) { if (this.isEnabled() && !this._hover) {
assertMask(); assertMask();
self.$mask.invisible(); this.$mask.invisible();
} }
}); });
}, }
bindEvent: function () { bindEvent() {
var self = this; const o = this.options;
var o = this.options, hand = this.handle(); let hand = this.handle();
if (!hand) { if (!hand) {
return; return;
} }
hand = hand.element; hand = hand.element;
var triggerArr = (o.trigger || "").split(",");
BI.each(triggerArr, function (idx, trigger) { const getBubble = () => {
const bubble = o.bubble;
if (isFunction(bubble)) {
return bubble();
}
return bubble;
}
const clk = (e) => {
ev(e);
if (!this.isEnabled() || !this.isValid()) {
return;
}
if (this.isOnce() && this.isSelected()) {
return;
}
if (BI.isKey(o.bubble) || isFunction(o.bubble)) {
if (BI.isNull(this.combo)) {
let popup;
createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.bubble_combo",
trigger: "",
// bubble的提示不需要一直存在在界面上
destroyWhenHide: true,
ref: (_ref) => {
this.combo = _ref;
},
el: {
type: "bi.layout",
height: "100%",
},
popup: {
type: "bi.text_bubble_bar_popup_view",
text: getBubble(),
ref: (_ref) => {
popup = _ref;
},
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: (...args) => {
const [v] = args;
this.combo.hideView();
if (v) {
onClick.apply(this, args);
}
},
}],
},
listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
popup.populate(getBubble());
},
}],
},
left: 0,
right: 0,
bottom: 0,
top: 0,
}],
});
}
if (this.combo.isViewVisible()) {
this.combo.hideView();
} else {
this.combo.showView();
}
return;
}
onClick.apply(this, arguments);
}
const triggerArr = (o.trigger || "").split(",");
triggerArr.forEach((trigger) => {
let mouseDown = false;
switch (trigger) { switch (trigger) {
case "mouseup": case "mouseup":
var mouseDown = false;
hand.mousedown(function () { hand.mousedown(function () {
mouseDown = true; mouseDown = true;
}); });
@ -140,24 +229,24 @@ BI.BasicButton = BI.inherit(BI.Single, {
}); });
break; break;
case "mousedown": case "mousedown":
var mouseDown = false; // let mouseDown = false;
var selected = false; let selected = false;
hand.mousedown(function (e) { hand.mousedown((e) => {
// if (e.button === 0) { // if (e.button === 0) {
BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), (e) => {
// if (e.button === 0) { // if (e.button === 0) {
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { if (BI.DOM.isExist(this) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) {
// self.setSelected(!self.isSelected()); // self.setSelected(!self.isSelected());
self._trigger(); this._trigger();
} }
mouseDown = false; mouseDown = false;
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName());
// } // }
}); });
if (mouseDown === true) { if (mouseDown === true) {
return; return;
} }
if (self.isSelected()) { if (this.isSelected()) {
selected = true; selected = true;
} else { } else {
clk(e); clk(e);
@ -166,14 +255,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
ev(e); ev(e);
// } // }
}); });
hand.mouseup(function (e) { hand.mouseup((e) => {
// if (e.button === 0) { // if (e.button === 0) {
if (BI.DOM.isExist(self) && mouseDown === true && selected === true) { if (BI.DOM.isExist(this) && mouseDown === true && selected === true) {
clk(e); clk(e);
} }
mouseDown = false; mouseDown = false;
selected = false; selected = false;
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName());
// } // }
}); });
break; break;
@ -181,22 +270,21 @@ BI.BasicButton = BI.inherit(BI.Single, {
hand.dblclick(clk); hand.dblclick(clk);
break; break;
case "lclick": case "lclick":
var mouseDown = false; let interval;
var interval; hand.mousedown((e) => {
hand.mousedown(function (e) { Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), () => {
BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function () {
interval && clearInterval(interval); interval && clearInterval(interval);
interval = null; interval = null;
mouseDown = false; mouseDown = false;
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName());
}); });
if (mouseDown === true) { if (mouseDown === true) {
return; return;
} }
if (!self.isEnabled() || !self.isValid()) { if (!this.isEnabled() || !this.isValid()) {
return; return;
} }
if (self.isOnce() && self.isSelected()) { if (this.isOnce() && this.isSelected()) {
return; return;
} }
interval = setInterval(function () { interval = setInterval(function () {
@ -224,7 +312,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
}); });
// 之后的300ms点击无效 // 之后的300ms点击无效
var onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { let onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false, "trailing": false,
}) : this._doClick; }) : this._doClick;
@ -238,86 +326,13 @@ BI.BasicButton = BI.inherit(BI.Single, {
} }
} }
function clk(e) {
ev(e);
if (!self.isEnabled() || !self.isValid()) {
return;
}
if (self.isOnce() && self.isSelected()) {
return;
}
if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) {
if (BI.isNull(self.combo)) {
var popup;
BI.createWidget({
type: "bi.absolute",
element: self,
items: [{
el: {
type: "bi.bubble_combo",
trigger: "",
// bubble的提示不需要一直存在在界面上
destroyWhenHide: true,
ref: function () {
self.combo = this;
},
el: {
type: "bi.layout",
height: "100%",
},
popup: {
type: "bi.text_bubble_bar_popup_view",
text: getBubble(),
ref: function () {
popup = this;
},
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: function (v) {
self.combo.hideView();
if (v) {
onClick.apply(self, arguments);
}
},
}],
},
listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
popup.populate(getBubble());
},
}],
},
left: 0,
right: 0,
bottom: 0,
top: 0,
}],
});
}
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
return;
}
onClick.apply(self, arguments);
}
function getBubble() {
var bubble = self.options.bubble;
if (BI.isFunction(bubble)) {
return bubble();
}
return bubble;
} }
},
_trigger: function (e) { _trigger(e) {
var o = this.options; const o = this.options;
if (!this.isEnabled()) { if (!this.isEnabled()) {
return; return;
} }
@ -327,22 +342,22 @@ BI.BasicButton = BI.inherit(BI.Single, {
this.setSelected(!this.isSelected())); this.setSelected(!this.isSelected()));
} }
if (this.isValid()) { if (this.isValid()) {
var v = this.getValue(); const v = this.getValue();
o.handler.call(this, v, this, e); o.handler.call(this, v, this, e);
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, v, this, e); this.fireEvent(Controller.EVENT_CHANGE, BI.Events.CLICK, v, this, e);
this.fireEvent(BI.BasicButton.EVENT_CHANGE, v, this); this.fireEvent(BasicButton.EVENT_CHANGE, v, this);
if (o.action) { if (o.action) {
BI.Actions.runAction(o.action, "click", o, this); BI.Actions.runAction(o.action, "click", o, this);
} }
BI.Actions.runGlobalAction("click", o, this); BI.Actions.runGlobalAction("click", o, this);
} }
}, }
_doClick: function (e) { _doClick(e) {
if (!this.isEnabled() || !this.isValid()) { if (!this.isEnabled() || !this.isValid()) {
return; return;
} }
var isIntercepted = this.beforeClick(e); const isIntercepted = this.beforeClick(e);
// 如果事件已经被消费掉了,就不再触发点击事件 // 如果事件已经被消费掉了,就不再触发点击事件
if (isIntercepted) { if (isIntercepted) {
return; return;
@ -352,41 +367,41 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (this.isEnabled() && this.isValid()) { if (this.isEnabled() && this.isValid()) {
this.doClick(e); this.doClick(e);
} }
}, }
/** /**
* 子类可以得写这个方法如果返回为 true则可以阻止 handler 的触发 * 子类可以得写这个方法如果返回为 true则可以阻止 handler 的触发
*/ */
beforeClick: function () { beforeClick() {
}, }
doClick: function () { doClick() {
}, }
handle: function () { handle() {
return this; return this;
}, }
hover: function () { hover() {
this._hover = true; this._hover = true;
this.handle().element.addClass("hover"); this.handle().element.addClass("hover");
if (this.options.shadow) { if (this.options.shadow) {
this.$mask && this.$mask.setVisible(true); this.$mask && this.$mask.setVisible(true);
} }
}, }
dishover: function () { dishover() {
this._hover = false; this._hover = false;
this.handle().element.removeClass("hover"); this.handle().element.removeClass("hover");
if (this.options.shadow) { if (this.options.shadow) {
this.$mask && this.$mask.setVisible(false); this.$mask && this.$mask.setVisible(false);
} }
}, }
setSelected: function (b) { setSelected(b) {
var o = this.options; const o = this.options;
o.selected = b; o.selected = b;
if (b) { if (b) {
this.handle().element.addClass("active"); this.handle().element.addClass("active");
@ -397,39 +412,39 @@ BI.BasicButton = BI.inherit(BI.Single, {
this.$mask && this.$mask.setVisible(false); this.$mask && this.$mask.setVisible(false);
} }
this.options.setSelected && this.options.setSelected.call(this, b); this.options.setSelected && this.options.setSelected.call(this, b);
}, }
isSelected: function () { isSelected() {
return this.options.selected; return this.options.selected;
}, }
isOnce: function () { isOnce() {
return this.options.once; return this.options.once;
}, }
isForceSelected: function () { isForceSelected() {
return this.options.forceSelected; return this.options.forceSelected;
}, }
isForceNotSelected: function () { isForceNotSelected() {
return this.options.forceNotSelected; return this.options.forceNotSelected;
}, }
isDisableSelected: function () { isDisableSelected() {
return this.options.disableSelected; return this.options.disableSelected;
}, }
setText: function (text) { setText(text) {
this.options.text = text; this.options.text = text;
this.options.setText && this.options.setText.call(this, text); this.options.setText && this.options.setText.call(this, text);
}, }
getText: function () { getText() {
return this.options.text; return this.options.text;
}, }
_setEnable: function (enable) { _setEnable(enable) {
BI.BasicButton.superclass._setEnable.apply(this, arguments); super._setEnable.apply(this, arguments);
if (enable === true) { if (enable === true) {
this.element.removeClass("base-disabled disabled"); this.element.removeClass("base-disabled disabled");
} else if (enable === false) { } else if (enable === false) {
@ -440,12 +455,12 @@ BI.BasicButton = BI.inherit(BI.Single, {
this.$mask && this.$mask.setVisible(false); this.$mask && this.$mask.setVisible(false);
} }
} }
}, }
empty() {
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName());
super.empty.apply(this, arguments);
}
}
empty: function () {
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName());
BI.BasicButton.superclass.empty.apply(this, arguments);
},
});
BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";
BI.shortcut("bi.basic_button", BI.BasicButton);

56
src/base/single/button/button.node.js

@ -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);

48
src/base/single/button/buttons/button.icon.js

@ -1,13 +1,21 @@
import { BasicButton } from "../button.basic";
import { shortcut, extend, isNumber, createWidget, isNull } from "../../../../core";
/** /**
* @class BI.IconButton * @class IconButton
* @extends BI.BasicButton * @extends BasicButton
* 图标的button * 图标的button
*/ */
BI.IconButton = BI.inherit(BI.BasicButton, { @shortcut()
_defaultConfig: function () { export class IconButton extends BasicButton {
var conf = BI.IconButton.superclass._defaultConfig.apply(this, arguments);
static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.icon_button";
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-icon-button horizon-center", _baseCls: (conf._baseCls || "") + " bi-icon-button horizon-center",
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
@ -18,21 +26,21 @@ BI.IconButton = BI.inherit(BI.BasicButton, {
iconWidth: null, iconWidth: null,
iconHeight: null, iconHeight: null,
}); });
}, }
render: function () { render() {
var o = this.options; const o = this.options;
this.element.css({ this.element.css({
textAlign: "center", textAlign: "center",
}); });
this.icon = BI.createWidget({ this.icon = createWidget({
type: "bi.icon", type: "bi.icon",
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight, height: o.iconHeight,
}); });
if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) { if (isNumber(o.height) && o.height > 0 && isNull(o.iconWidth) && isNull(o.iconHeight)) {
this.element.css("lineHeight", BI.pixFormat(o.height)); this.element.css("lineHeight", BI.pixFormat(o.height));
BI.createWidget({ createWidget({
type: "bi.default", type: "bi.default",
element: this, element: this,
hgap: o.hgap, hgap: o.hgap,
@ -45,7 +53,7 @@ BI.IconButton = BI.inherit(BI.BasicButton, {
}); });
} else { } else {
this.element.css("lineHeight", "1"); this.element.css("lineHeight", "1");
BI.createWidget({ createWidget({
element: this, element: this,
type: "bi.center_adapt", type: "bi.center_adapt",
hgap: o.hgap, hgap: o.hgap,
@ -57,14 +65,12 @@ BI.IconButton = BI.inherit(BI.BasicButton, {
items: [this.icon], items: [this.icon],
}); });
} }
}, }
doClick: function () { doClick() {
BI.IconButton.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.IconButton.EVENT_CHANGE, this); this.fireEvent(IconButton.EVENT_CHANGE, this);
}
} }
}, }
});
BI.IconButton.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_button", BI.IconButton);

85
src/base/single/button/buttons/button.image.js

@ -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);

165
src/base/single/button/buttons/button.js

@ -1,40 +1,47 @@
(function () { import { BasicButton } from "../button.basic";
function isVertical(position) { import { isNumber, shortcut, isPlainObject, createWidget } from "../../../../core";
function isVertical(position) {
return position === "top" || position === "bottom"; return position === "top" || position === "bottom";
} }
var loadingCls = "button-loading-font anim-rotate"; const loadingCls = "button-loading-font anim-rotate";
/** /**
* 文字类型的按钮 * 文字类型的按钮
* @class BI.Button * @class Button
* @extends BI.BasicButton * @extends BasicButton
* *
* @cfg {JSON} options 配置属性 * @cfg {JSON} options 配置属性
* @cfg {'common'/'success'/'warning'/'ignore'} [options.level='common'] 按钮类型用不同颜色强调不同的场景 * @cfg {'common' / 'success' / 'warning' / 'ignore'} [options.level='common'] 按钮类型用不同颜色强调不同的场景
*/ */
BI.Button = BI.inherit(BI.BasicButton, { @shortcut()
export class Button extends BasicButton {
_const: { _const = {
iconWidth: 18, iconWidth: 18,
}, }
static xtype = "bi.button";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig: function (props) { _defaultConfig(props) {
var conf = BI.Button.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig.apply(this, arguments);
var adaptiveHeight = 0; let adaptiveHeight = 0;
if (isVertical(props.iconPosition)) { if (isVertical(props.iconPosition)) {
// 图标高度和文字高度默认相等 // 图标高度和文字高度默认相等
adaptiveHeight += (props.textHeight || 16) * 2; adaptiveHeight += (props.textHeight || 16) * 2;
adaptiveHeight += props.iconGap || 0; adaptiveHeight += props.iconGap || 0;
var tGap = props.tgap || props.vgap || 2; let tGap = props.tgap || props.vgap || 2;
var bGap = props.bgap || props.vgap || 2; let bGap = props.bgap || props.vgap || 2;
adaptiveHeight += (tGap + bGap); adaptiveHeight += (tGap + bGap);
} }
var clearMinWidth = props.block === true || props.clear === true || props.plain; let clearMinWidth = props.block === true || props.clear === true || props.plain;
return BI.extend(conf, { return {
...conf,
baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""),
attributes: { attributes: {
tabIndex: 1, tabIndex: 1,
@ -65,45 +72,45 @@
icon: "", icon: "",
iconGap: 0, iconGap: 0,
iconPosition: "left", iconPosition: "left",
}); }
}, }
render: function () { render() {
var o = this.options, self = this; const o = this.options;
// bi.center_adapt 作用:让 hgap 不影响 iconGap。 // bi.center_adapt 作用:让 hgap 不影响 iconGap。
BI.createWidget({ createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
horizontalAlign: o.textAlign, horizontalAlign: o.textAlign,
element: this, element: this,
ref: (ref) => { ref: (ref) => {
self.containerRef = ref; this.containerRef = ref;
}, },
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
items: self.generateItems(), items: this.generateItems(),
}); });
// 如果 options 对应的属性为 true 则给元素添加 class // 如果 options 对应的属性为 true 则给元素添加 class
var classArr = ["block", "clear", "ghost", "plain", "loading", "light"]; const classArr = ["block", "clear", "ghost", "plain", "loading", "light"];
BI.each(classArr, function (_, clz) { classArr.forEach(clz => {
if (BI.get(o, clz) === true) { if (BI.get(o, clz) === true) {
self.element.addClass(clz); this.element.addClass(clz);
} }
}); })
if (o.minWidth > 0) { if (o.minWidth > 0) {
this.element.css({ "min-width": BI.pixFormat(o.minWidth) }); this.element.css({ "min-width": BI.pixFormat(o.minWidth) });
} }
}, }
generateItems(defaultRenderIcon) { generateItems(defaultRenderIcon) {
var o = this.options; const o = this.options;
// 由于button默认情况下有个边框,所以要主动算行高 // 由于button默认情况下有个边框,所以要主动算行高
var lineHeight, textHeight = o.textHeight; let lineHeight, textHeight = o.textHeight;
var hasBorder = false; let hasBorder = false;
if (BI.isNumber(o.height)) { if (isNumber(o.height)) {
if (!isVertical(o.iconPosition)) { if (!isVertical(o.iconPosition)) {
if (!(o.clear && o.block && o.light)) { if (!(o.clear && o.block && o.light)) {
hasBorder = true; hasBorder = true;
@ -119,15 +126,15 @@
} }
} }
var iconInvisible = !(o.loading || o.iconCls || o.icon || defaultRenderIcon); const iconInvisible = !(o.loading || o.iconCls || o.icon || defaultRenderIcon);
var maxTextWidth = Math.max(o.minWidth, o.width); let maxTextWidth = Math.max(o.minWidth, o.width);
maxTextWidth -= (o.hgap * 2 + o.iconGap); maxTextWidth -= (o.hgap * 2 + o.iconGap);
// 减去图标水平占位宽度 // 减去图标水平占位宽度
maxTextWidth -= iconInvisible || isVertical(o.iconPosition) ? 0 : this._const.iconWidth; maxTextWidth -= iconInvisible || isVertical(o.iconPosition) ? 0 : this._const.iconWidth;
var textWidth = BI.isNull(o.textWidth) ? maxTextWidth : Math.min(o.textWidth, maxTextWidth); const textWidth = BI.isNull(o.textWidth) ? maxTextWidth : Math.min(o.textWidth, maxTextWidth);
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.label", type: "bi.label",
text: o.text, text: o.text,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
@ -145,10 +152,10 @@
this._iconRendered = true; this._iconRendered = true;
if (BI.isPlainObject(o.icon) && !o.loading) { if (isPlainObject(o.icon) && !o.loading) {
this.icon = BI.createWidget(o.icon); this.icon = createWidget(o.icon);
} else { } else {
this.icon = BI.createWidget({ this.icon = createWidget({
type: "bi.icon_label", type: "bi.icon_label",
cls: o.loading ? loadingCls : (o.iconCls || o.icon), cls: o.loading ? loadingCls : (o.iconCls || o.icon),
width: this._const.iconWidth, width: this._const.iconWidth,
@ -161,14 +168,14 @@
}); });
} }
var gapContainer = { const gapContainer = {
lgap: o.iconPosition === "left" && o.text ? o.iconGap : 0, lgap: o.iconPosition === "left" && o.text ? o.iconGap : 0,
rgap: o.iconPosition === "right" ? o.iconGap : 0, rgap: o.iconPosition === "right" ? o.iconGap : 0,
tgap: o.iconPosition === "top" ? o.iconGap : 0, tgap: o.iconPosition === "top" ? o.iconGap : 0,
bgap: o.iconPosition === "bottom" ? o.iconGap : 0, bgap: o.iconPosition === "bottom" ? o.iconGap : 0,
}; };
var items = [this.icon, BI.extend({ el: this.text }, gapContainer)]; const items = [this.icon, { el: this.text, ...gapContainer }];
if (o.iconPosition === "right" || o.iconPosition === "bottom") { if (o.iconPosition === "right" || o.iconPosition === "bottom") {
items.reverse(); items.reverse();
} }
@ -179,33 +186,33 @@
verticalAlign: "middle", verticalAlign: "middle",
items, items,
}]; }];
}, }
doClick: function () { doClick() {
BI.Button.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.Button.EVENT_CHANGE, this); this.fireEvent(Button.EVENT_CHANGE, this);
}
} }
},
_setEnable: function (enable) { _setEnable(enable) {
BI.Button.superclass._setEnable.apply(this, arguments); super._setEnable.apply(this, arguments);
if (enable === true) { if (enable === true) {
this.element.attr("tabIndex", 1); this.element.attr("tabIndex", 1);
} else if (enable === false) { } else if (enable === false) {
this.element.removeAttr("tabIndex"); this.element.removeAttr("tabIndex");
} }
}, }
beforeClick: function () { beforeClick() {
return this.isLoading(); return this.isLoading();
}, }
isLoading: function () { isLoading() {
return this._loading === undefined ? this.options.loading : this._loading; return this._loading === undefined ? this.options.loading : this._loading;
}, }
loading: function () { loading() {
this._loading = true; this._loading = true;
this.element.addClass("loading"); this.element.addClass("loading");
!this._iconRendered && this.containerRef.populate(this.generateItems(true)); !this._iconRendered && this.containerRef.populate(this.generateItems(true));
@ -216,9 +223,9 @@
this.icon.element.addClass(loadingCls); this.icon.element.addClass(loadingCls);
this.icon.setVisible(true); this.icon.setVisible(true);
} }
}, }
loaded: function () { loaded() {
this._loading = false; this._loading = false;
this.element.removeClass("loading"); this.element.removeClass("loading");
if (this.icon.loaded) { if (this.icon.loaded) {
@ -227,45 +234,43 @@
this.icon.element.removeClass(loadingCls); this.icon.element.removeClass(loadingCls);
this.icon.setVisible(!!this.options.iconCls); this.icon.setVisible(!!this.options.iconCls);
} }
}, }
setText: function (text) { setText(text) {
BI.Button.superclass.setText.apply(this, arguments); super.setText.apply(this, arguments);
this.text.setText(text); this.text.setText(text);
}, }
setValue: function (text) { setValue(text) {
BI.Button.superclass.setValue.apply(this, arguments); super.setValue.apply(this, arguments);
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue(text); this.text.setValue(text);
} }
}, }
setIcon: function (cls) { setIcon(cls) {
var o = this.options; const o = this.options;
!this._iconRendered && this.containerRef.populate(this.generateItems(true)); !this._iconRendered && this.containerRef.populate(this.generateItems(true));
if (this.icon && o.iconCls !== cls) { if (this.icon && o.iconCls !== cls) {
this.icon.element.removeClass(o.iconCls).addClass(cls); this.icon.element.removeClass(o.iconCls).addClass(cls);
o.iconCls = cls; o.iconCls = cls;
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
}); }
BI.shortcut("bi.button", BI.Button);
BI.Button.EVENT_CHANGE = "EVENT_CHANGE";
}());

72
src/base/single/button/buttons/button.text.js

@ -1,15 +1,23 @@
import { BasicButton } from "../button.basic";
import { shortcut, extend, createWidget } from "../../../../core";
/** /**
* guy * guy
* 可以点击的一行文字 * 可以点击的一行文字
* @class BI.TextButton * @class TextButton
* @extends BI.BasicButton * @extends BasicButton
* 文字button * 文字button
*/ */
BI.TextButton = BI.inherit(BI.BasicButton, { @shortcut()
_defaultConfig: function () { export class TextButton extends BasicButton {
var conf = BI.TextButton.superclass._defaultConfig.apply(this, arguments);
static xtype = "bi.text_button";
static EVENT_CHANGE = "EVENT_CHANGE";
return BI.extend(conf, { _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-button", baseCls: (conf.baseCls || "") + " bi-text-button",
textAlign: "center", textAlign: "center",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -21,11 +29,11 @@ BI.TextButton = BI.inherit(BI.BasicButton, {
vgap: 0, vgap: 0,
py: "", py: "",
}); });
}, }
render: function () { render() {
var o = this.options; const o = this.options;
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.label", type: "bi.label",
element: this, element: this,
textAlign: o.textAlign, textAlign: o.textAlign,
@ -43,48 +51,46 @@ BI.TextButton = BI.inherit(BI.BasicButton, {
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
}); });
}, }
doClick: function () { doClick() {
BI.TextButton.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.TextButton.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BI.TextButton.EVENT_CHANGE, this.getValue(), this);
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
setText: function (text) { setText(text) {
BI.TextButton.superclass.setText.apply(this, arguments); super.setText.apply(this, arguments);
text = BI.isArray(text) ? text.join(",") : text; text = BI.isArray(text) ? text.join(",") : text;
this.text.setText(text); this.text.setText(text);
}, }
setStyle: function (style) { setStyle(style) {
this.text.setStyle(style); this.text.setStyle(style);
}, }
setValue: function (text) { setValue(text) {
BI.TextButton.superclass.setValue.apply(this, arguments); super.setValue.apply(this, arguments);
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
text = BI.isArray(text) ? text.join(",") : text; text = BI.isArray(text) ? text.join(",") : text;
this.text.setValue(text); this.text.setValue(text);
} }
}, }
}); }
BI.TextButton.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_button", BI.TextButton);

17
src/base/single/button/index.js

@ -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";

79
src/base/single/button/listitem/blankiconicontextitem.js

@ -1,14 +1,21 @@
import { BasicButton } from "../button.basic"
import { emptyFn, shortcut } from "../../../../core"
/** /**
* 带有一个占位 * 带有一个占位
* *
* Created by GUY on 2015/9/11. * Created by GUY on 2015/9/11.
* @class BI.BlankIconIconTextItem * @class BlankIconIconTextItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, { @shortcut()
export class BlankIconIconTextItem extends BasicButton {
static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.blank_icon_icon_text_item";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.BlankIconIconTextItem.superclass._defaultConfig.apply(this, arguments); var conf = super._defaultConfig(arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-icon-text-item", baseCls: (conf.baseCls || "") + " bi-blank-icon-icon-text-item",
@ -22,10 +29,10 @@ BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -50,8 +57,8 @@ BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
hgap: o.textHgap, hgap: o.textHgap,
@ -65,54 +72,52 @@ BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, {
}, },
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.BlankIconIconTextItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.BlankIconIconTextItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BlankIconIconTextItem.EVENT_CHANGE, this.getValue(), this);
}
} }
},
setSelected: function (b) { setSelected(b) {
BI.BlankIconIconTextItem.superclass.setSelected.apply(this, arguments); super.setSelected.apply(this, arguments);
this.icon1.setSelected(b); this.icon1.setSelected(b);
this.icon2.setSelected(b); this.icon2.setSelected(b);
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
}); }
BI.BlankIconIconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.blank_icon_icon_text_item", BI.BlankIconIconTextItem);

74
src/base/single/button/listitem/blankicontexticonitem.js

@ -1,17 +1,24 @@
import { BasicButton } from "../button.basic"
import { emptyFn, shortcut, extend } from "../../../../core"
/** /**
* guy * guy
* 一个占位符和两个icon和一行数 组成的一行listitem * 一个占位符和两个icon和一行数 组成的一行listitem
* *
* Created by GUY on 2015/9/15. * Created by GUY on 2015/9/15.
* @class BI.BlankIconTextIconItem * @class BlankIconTextIconItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, { @shortcut()
export class BlankIconTextIconItem extends BasicButton {
static xtype = "bi.blank_icon_text_icon_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.BlankIconTextIconItem.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-text-icon-item", baseCls: (conf.baseCls || "") + " bi-blank-icon-text-icon-item",
iconCls1: "", iconCls1: "",
iconCls2: "", iconCls2: "",
@ -23,10 +30,10 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -44,8 +51,8 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
hgap: o.textHgap, hgap: o.textHgap,
@ -66,48 +73,47 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, {
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.BlankIconTextIconItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.BlankIconTextIconItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BI.BlankIconTextIconItem.EVENT_CHANGE, this.getValue(), this);
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
}); }
BI.BlankIconTextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.blank_icon_text_icon_item", BI.BlankIconTextIconItem);

75
src/base/single/button/listitem/blankicontextitem.js

@ -1,16 +1,23 @@
import { BasicButton } from "../button.basic"
import { extend, shortcut } from "../../../../core"
/** /**
* 带有一个占位 * 带有一个占位
* *
* Created by GUY on 2015/9/11. * Created by GUY on 2015/9/11.
* @class BI.BlankIconTextItem * @class BlankIconTextItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
BI.BlankIconTextItem = BI.inherit(BI.BasicButton, { @shortcut()
export class BlankIconTextItem extends BasicButton {
static xtype = "bi.blank_icon_text_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.BlankIconTextItem.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item", baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item",
blankWidth: 0, blankWidth: 0,
iconHeight: null, iconHeight: null,
@ -21,10 +28,10 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -42,8 +49,8 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
@ -58,48 +65,46 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, {
}, },
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.BlankIconTextItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.BlankIconTextItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BlankIconTextItem.EVENT_CHANGE, this.getValue(), this);
}
} }
},
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
}); }
BI.BlankIconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.blank_icon_text_item", BI.BlankIconTextItem);

76
src/base/single/button/listitem/icontexticonitem.js

@ -1,17 +1,25 @@
import { BasicButton } from "../button.basic"
import { extend, shortcut } from "../../../../core"
/** /**
* guy * guy
* 两个icon和一行数 组成的一行listitem * 两个icon和一行数 组成的一行listitem
* *
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.IconTextIconItem * @class IconTextIconItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
BI.IconTextIconItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () { @shortcut()
var conf = BI.IconTextIconItem.superclass._defaultConfig.apply(this, arguments); export class IconTextIconItem extends BasicButton {
static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.icon_text_icon_item";
return BI.extend(conf, { _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-icon-item", baseCls: (conf.baseCls || "") + " bi-icon-text-icon-item",
iconCls1: "", iconCls1: "",
iconCls2: "", iconCls2: "",
@ -22,10 +30,10 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -40,8 +48,8 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
hgap: o.textHgap, hgap: o.textHgap,
@ -62,48 +70,46 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, {
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.IconTextIconItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.IconTextIconItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(IconTextIconItem.EVENT_CHANGE, this.getValue(), this);
}
} }
},
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
}); }
BI.IconTextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_icon_item", BI.IconTextIconItem);

73
src/base/single/button/listitem/icontextitem.js

@ -1,16 +1,23 @@
import { BasicButton } from "../button.basic"
import { extend, shortcut } from "../../../../core"
/** /**
* guy * guy
* *
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.IconTextItem * @class IconTextItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
BI.IconTextItem = BI.inherit(BI.BasicButton, { @shortcut()
export class IconTextItem extends BasicButton {
static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.icon_text_item";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.IconTextItem.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-item", baseCls: (conf.baseCls || "") + " bi-icon-text-item",
direction: BI.Direction.Left, direction: BI.Direction.Left,
iconWrapperWidth: null, iconWrapperWidth: null,
@ -22,10 +29,10 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -40,8 +47,8 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
@ -56,48 +63,46 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, {
}, },
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.IconTextItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.IconTextItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BI.IconTextItem.EVENT_CHANGE, this.getValue(), this);
} }
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
}); }
BI.IconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_item", BI.IconTextItem);

71
src/base/single/button/listitem/texticonitem.js

@ -1,17 +1,24 @@
import { BasicButton } from "../button.basic"
import { extend, shortcut } from "../../../../core"
/** /**
* *
* 图标的button * 图标的button
* *
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.TextIconItem * @class TextIconItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
BI.TextIconItem = BI.inherit(BI.BasicButton, { @shortcut()
export class TextIconItem extends BasicButton {
static xtype = "bi.text_icon_item";
static EVENT_CHANGE = "EVENT_CHANGE"
_defaultConfig: function () { _defaultConfig() {
var conf = BI.TextIconItem.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-icon-item", baseCls: (conf.baseCls || "") + " bi-text-icon-item",
iconWrapperWidth: null, iconWrapperWidth: null,
iconHeight: null, iconHeight: null,
@ -22,10 +29,10 @@ BI.TextIconItem = BI.inherit(BI.BasicButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -56,48 +63,46 @@ BI.TextIconItem = BI.inherit(BI.BasicButton, {
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.TextIconItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.TextIconItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(TextIconItem.EVENT_CHANGE, this.getValue(), this);
}
} }
},
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
}); }
BI.TextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_icon_item", BI.TextIconItem);

69
src/base/single/button/listitem/textitem.js

@ -1,17 +1,24 @@
import { BasicButton } from "../button.basic"
import { extend, shortcut } from "../../../../core"
/** /**
* guy * guy
* 一个button和一行数 组成的一行listitem * 一个button和一行数 组成的一行listitem
* *
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.TextItem * @class TextItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
BI.TextItem = BI.inherit(BI.BasicButton, { @shortcut
export class TextItem extends BasicButton {
static xtype = "bi.text_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.TextItem.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-item", baseCls: (conf.baseCls || "") + " bi-text-item",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -20,10 +27,10 @@ BI.TextItem = BI.inherit(BI.BasicButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var o = this.options; const o = this.options;
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
element: this, element: this,
@ -40,48 +47,46 @@ BI.TextItem = BI.inherit(BI.BasicButton, {
keyword: o.keyword, keyword: o.keyword,
py: o.py, py: o.py,
}); });
}, }
doClick: function () { doClick() {
BI.TextItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.TextItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BI.TextItem.EVENT_CHANGE, this.getValue(), this);
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
}); }
BI.TextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_item", BI.TextItem);

67
src/base/single/button/node/icontexticonnode.js

@ -1,15 +1,22 @@
import { NodeButton } from "../button.node"
import { extend, shortcut } from "../../../../core"
/** /**
* guy * guy
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.IconTextIconNode * @class IconTextIconNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.IconTextIconNode = BI.inherit(BI.NodeButton, { @shortcut()
export class IconTextIconNode extends NodeButton {
static xtype = "bi.icon_text_icon_node";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.IconTextIconNode.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node", baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node",
iconCls1: "close-ha-font", iconCls1: "close-ha-font",
iconCls2: "close-ha-font", iconCls2: "close-ha-font",
@ -20,10 +27,10 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -38,8 +45,8 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
hgap: o.textHgap, hgap: o.textHgap,
@ -60,40 +67,38 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.IconTextIconNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.IconTextIconNode.EVENT_CHANGE, this.getValue(), this); this.fireEvent(IconTextIconNode.EVENT_CHANGE, this.getValue(), this);
}
} }
},
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
}); }
BI.IconTextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_icon_node", BI.IconTextIconNode);

66
src/base/single/button/node/icontextnode.js

@ -1,15 +1,22 @@
import { NodeButton } from "../button.node"
import { extend, shortcut } from "../../../../core"
/** /**
* guy * guy
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.IconTextNode * @class IconTextNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.IconTextNode = BI.inherit(BI.NodeButton, { @shortcut()
export class IconTextNode extends NodeButton {
static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.icon_text_node";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.IconTextNode.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-node", baseCls: (conf.baseCls || "") + " bi-icon-text-node",
cls: "close-ha-font", cls: "close-ha-font",
iconHeight: null, iconHeight: null,
@ -19,10 +26,10 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -37,8 +44,8 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
@ -53,40 +60,39 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
}, },
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.IconTextNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.IconTextNode.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BI.IconTextNode.EVENT_CHANGE, this.getValue(), this);
} }
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
}); }
BI.IconTextNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_node", BI.IconTextNode);

67
src/base/single/button/node/texticonnode.js

@ -1,14 +1,21 @@
import { NodeButton } from "../button.node"
import { extend, shortcut } from "../../../../core"
/** /**
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.TextIconNode * @class TextIconNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.TextIconNode = BI.inherit(BI.NodeButton, { @shortcut()
export default class TextIconNode extends NodeButton {
static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.text_icon_node";
_defaultConfig: function () { _defaultConfig() {
var conf = BI.TextIconNode.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-icon-node", baseCls: (conf.baseCls || "") + " bi-text-icon-node",
cls: "close-ha-font", cls: "close-ha-font",
iconHeight: null, iconHeight: null,
@ -18,10 +25,10 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -29,8 +36,8 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
items: [{ items: [{
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: (_ref) => {
self.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
@ -52,40 +59,38 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.TextIconNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.TextIconNode.EVENT_CHANGE, this.getValue(), this); this.fireEvent(TextIconNode.EVENT_CHANGE, this.getValue(), this);
}
} }
},
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
}); }
BI.TextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_icon_node", BI.TextIconNode);

65
src/base/single/button/node/textnode.js

@ -1,16 +1,25 @@
import { NodeButton } from "../button.node"
import { extend, shortcut } from "../../../../core"
/** /**
* guy * guy
* *
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.TextNode * @class TextNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.TextNode = BI.inherit(BI.NodeButton, { @shortcut()
export class TextNode extends NodeButton {
static xtype = "bi.text_node"
static EVENT_CHANGE = "EVENT_CHANGE"
_defaultConfig: function () { _defaultConfig() {
var conf = BI.TextNode.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-node", baseCls: (conf.baseCls || "") + " bi-text-node",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -19,10 +28,10 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
textLgap: 0, textLgap: 0,
textRgap: 0, textRgap: 0,
}); });
}, }
render: function () { render() {
var o = this.options; const o = this.options;
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
element: this, element: this,
@ -39,40 +48,38 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
keyword: o.keyword, keyword: o.keyword,
py: o.py, py: o.py,
}); });
}, }
doClick: function () { doClick() {
BI.TextNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.TextNode.EVENT_CHANGE, this.getValue(), this); this.fireEvent(TextNode.EVENT_CHANGE, this.getValue(), this);
}
} }
},
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, }
setValue: function () { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
} }
}, }
getValue: function () { getValue() {
return this.text.getValue(); return this.text.getValue();
}, }
setText: function () { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText.apply(this.text, arguments);
}, }
getText: function () { getText() {
return this.text.getText(); return this.text.getText();
}, }
}); }
BI.TextNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_node", BI.TextNode);

1
src/base/single/index.js

@ -8,3 +8,4 @@ export * from "./tip";
export * from "./label"; export * from "./label";
export * from "./input"; export * from "./input";
export * from "./editor"; export * from "./editor";
export * from "./button"

3
src/core/index.js

@ -21,6 +21,9 @@ export * from "./behavior";
export * from "./controller"; export * from "./controller";
export * from "./func"; export * from "./func";
// 有了后删掉
export const emptyFn = () => { }
export { export {
StyleLoaderManager, StyleLoaderManager,
ShowListener, ShowListener,

Loading…
Cancel
Save