forked from fanruan/fineui
guy
6 years ago
21 changed files with 66260 additions and 760 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,152 +1,150 @@ |
|||||||
(function ($) { |
|
||||||
|
|
||||||
/** |
/** |
||||||
* 文字类型的按钮 |
* 文字类型的按钮 |
||||||
* @class BI.Button |
* @class BI.Button |
||||||
* @extends BI.BasicButton |
* @extends BI.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, { |
BI.Button = BI.inherit(BI.BasicButton, { |
||||||
|
|
||||||
_defaultConfig: function (props) { |
_defaultConfig: function (props) { |
||||||
var conf = BI.Button.superclass._defaultConfig.apply(this, arguments); |
var conf = BI.Button.superclass._defaultConfig.apply(this, arguments); |
||||||
return BI.extend(conf, { |
return BI.extend(conf, { |
||||||
baseCls: (conf.baseCls || "") + " bi-button", |
baseCls: (conf.baseCls || "") + " bi-button", |
||||||
minWidth: (props.block === true || props.clear === true) ? 0 : 80, |
minWidth: (props.block === true || props.clear === true) ? 0 : 80, |
||||||
height: 24, |
height: 24, |
||||||
shadow: props.clear !== true, |
shadow: props.clear !== true, |
||||||
isShadowShowingOnSelected: true, |
isShadowShowingOnSelected: true, |
||||||
readonly: true, |
readonly: true, |
||||||
iconCls: "", |
iconCls: "", |
||||||
level: "common", |
level: "common", |
||||||
block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制
|
block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制
|
||||||
clear: false, // 是否去掉边框和背景
|
clear: false, // 是否去掉边框和背景
|
||||||
ghost: false, // 是否幽灵显示, 即正常状态无背景
|
ghost: false, // 是否幽灵显示, 即正常状态无背景
|
||||||
textAlign: "center", |
textAlign: "center", |
||||||
whiteSpace: "nowrap", |
whiteSpace: "nowrap", |
||||||
forceCenter: false, |
forceCenter: false, |
||||||
textWidth: null, |
textWidth: null, |
||||||
textHeight: null, |
textHeight: null, |
||||||
hgap: props.clear ? 0 : 10, |
hgap: props.clear ? 0 : 10, |
||||||
vgap: 0, |
vgap: 0, |
||||||
tgap: 0, |
tgap: 0, |
||||||
bgap: 0, |
bgap: 0, |
||||||
lgap: 0, |
lgap: 0, |
||||||
rgap: 0 |
rgap: 0 |
||||||
}); |
}); |
||||||
}, |
}, |
||||||
|
|
||||||
_init: function () { |
_init: function () { |
||||||
BI.Button.superclass._init.apply(this, arguments); |
BI.Button.superclass._init.apply(this, arguments); |
||||||
var o = this.options, self = this; |
var o = this.options, self = this; |
||||||
if (BI.isNumber(o.height) && !o.clear && !o.block) { |
if (BI.isNumber(o.height) && !o.clear && !o.block) { |
||||||
this.element.css({height: o.height + "px", lineHeight: (o.height - 2) + "px"}); |
this.element.css({height: o.height + "px", lineHeight: (o.height - 2) + "px"}); |
||||||
} else if (o.clear || o.block) { |
} else if (o.clear || o.block) { |
||||||
this.element.css({lineHeight: o.height + "px"}); |
this.element.css({lineHeight: o.height + "px"}); |
||||||
} else { |
} else { |
||||||
this.element.css({lineHeight: (o.height - 2) + "px"}); |
this.element.css({lineHeight: (o.height - 2) + "px"}); |
||||||
} |
} |
||||||
if (BI.isKey(o.iconCls)) { |
if (BI.isKey(o.iconCls)) { |
||||||
this.icon = BI.createWidget({ |
this.icon = BI.createWidget({ |
||||||
type: "bi.icon", |
type: "bi.icon", |
||||||
width: 18, |
width: 18, |
||||||
height: o.height - 2 |
height: o.height - 2 |
||||||
}); |
}); |
||||||
this.text = BI.createWidget({ |
this.text = BI.createWidget({ |
||||||
type: "bi.label", |
type: "bi.label", |
||||||
text: o.text, |
text: o.text, |
||||||
value: o.value, |
value: o.value, |
||||||
height: o.height - 2 |
height: o.height - 2 |
||||||
}); |
}); |
||||||
BI.createWidget({ |
BI.createWidget({ |
||||||
type: "bi.horizontal_auto", |
type: "bi.horizontal_auto", |
||||||
cls: o.iconCls, |
cls: o.iconCls, |
||||||
element: this, |
element: this, |
||||||
hgap: o.hgap, |
hgap: o.hgap, |
||||||
vgap: o.vgap, |
vgap: o.vgap, |
||||||
tgap: o.tgap, |
tgap: o.tgap, |
||||||
bgap: o.bgap, |
bgap: o.bgap, |
||||||
lgap: o.lgap, |
lgap: o.lgap, |
||||||
rgap: o.rgap, |
rgap: o.rgap, |
||||||
items: [{ |
items: [{ |
||||||
type: "bi.horizontal", |
type: "bi.horizontal", |
||||||
items: [this.icon, this.text] |
items: [this.icon, this.text] |
||||||
}] |
}] |
||||||
}); |
}); |
||||||
} else { |
} else { |
||||||
this.text = BI.createWidget({ |
this.text = BI.createWidget({ |
||||||
type: "bi.label", |
type: "bi.label", |
||||||
textAlign: o.textAlign, |
textAlign: o.textAlign, |
||||||
whiteSpace: o.whiteSpace, |
whiteSpace: o.whiteSpace, |
||||||
forceCenter: o.forceCenter, |
forceCenter: o.forceCenter, |
||||||
textWidth: o.textWidth, |
textWidth: o.textWidth, |
||||||
textHeight: o.textHeight, |
textHeight: o.textHeight, |
||||||
hgap: o.hgap, |
hgap: o.hgap, |
||||||
vgap: o.vgap, |
vgap: o.vgap, |
||||||
tgap: o.tgap, |
tgap: o.tgap, |
||||||
bgap: o.bgap, |
bgap: o.bgap, |
||||||
lgap: o.lgap, |
lgap: o.lgap, |
||||||
rgap: o.rgap, |
rgap: o.rgap, |
||||||
element: this, |
element: this, |
||||||
text: o.text, |
text: o.text, |
||||||
value: o.value |
value: o.value |
||||||
}); |
}); |
||||||
} |
} |
||||||
if (o.block === true) { |
if (o.block === true) { |
||||||
this.element.addClass("block"); |
this.element.addClass("block"); |
||||||
} |
} |
||||||
if (o.clear === true) { |
if (o.clear === true) { |
||||||
this.element.addClass("clear"); |
this.element.addClass("clear"); |
||||||
} |
} |
||||||
if (o.ghost === true) { |
if (o.ghost === true) { |
||||||
this.element.addClass("ghost"); |
this.element.addClass("ghost"); |
||||||
} |
} |
||||||
if (o.minWidth > 0) { |
if (o.minWidth > 0) { |
||||||
this.element.css({"min-width": o.minWidth + "px"}); |
this.element.css({"min-width": o.minWidth + "px"}); |
||||||
} |
} |
||||||
}, |
}, |
||||||
|
|
||||||
doClick: function () { |
doClick: function () { |
||||||
BI.Button.superclass.doClick.apply(this, arguments); |
BI.Button.superclass.doClick.apply(this, arguments); |
||||||
if (this.isValid()) { |
if (this.isValid()) { |
||||||
this.fireEvent(BI.Button.EVENT_CHANGE, this); |
this.fireEvent(BI.Button.EVENT_CHANGE, this); |
||||||
} |
} |
||||||
}, |
}, |
||||||
|
|
||||||
setText: function (text) { |
setText: function (text) { |
||||||
BI.Button.superclass.setText.apply(this, arguments); |
BI.Button.superclass.setText.apply(this, arguments); |
||||||
this.text.setText(text); |
this.text.setText(text); |
||||||
}, |
}, |
||||||
|
|
||||||
setValue: function (text) { |
setValue: function (text) { |
||||||
BI.Button.superclass.setValue.apply(this, arguments); |
BI.Button.superclass.setValue.apply(this, arguments); |
||||||
if (!this.isReadOnly()) { |
if (!this.isReadOnly()) { |
||||||
this.text.setValue(text); |
this.text.setValue(text); |
||||||
} |
} |
||||||
}, |
}, |
||||||
|
|
||||||
doRedMark: function () { |
doRedMark: function () { |
||||||
this.text.doRedMark.apply(this.text, arguments); |
this.text.doRedMark.apply(this.text, arguments); |
||||||
}, |
}, |
||||||
|
|
||||||
unRedMark: function () { |
unRedMark: function () { |
||||||
this.text.unRedMark.apply(this.text, arguments); |
this.text.unRedMark.apply(this.text, arguments); |
||||||
}, |
}, |
||||||
|
|
||||||
doHighLight: function () { |
doHighLight: function () { |
||||||
this.text.doHighLight.apply(this.text, arguments); |
this.text.doHighLight.apply(this.text, arguments); |
||||||
}, |
}, |
||||||
|
|
||||||
unHighLight: function () { |
unHighLight: function () { |
||||||
this.text.unHighLight.apply(this.text, arguments); |
this.text.unHighLight.apply(this.text, arguments); |
||||||
}, |
}, |
||||||
|
|
||||||
destroy: function () { |
destroy: function () { |
||||||
BI.Button.superclass.destroy.apply(this, arguments); |
BI.Button.superclass.destroy.apply(this, arguments); |
||||||
} |
} |
||||||
}); |
}); |
||||||
BI.shortcut("bi.button", BI.Button); |
BI.shortcut("bi.button", BI.Button); |
||||||
BI.Button.EVENT_CHANGE = "EVENT_CHANGE"; |
BI.Button.EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
})(jQuery); |
|
||||||
|
Loading…
Reference in new issue