fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.4 KiB

8 years ago
/**
* guy 表示一行数据通过position来定位位置的数据
* @class BI.Text
* @extends BI.Single
*/
BI.Text = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.Text.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text",
textAlign: "left",
whiteSpace: "normal",
lineHeight: null,
7 years ago
handler: null,//如果传入handler,表示处理文字的点击事件,不是区域的
8 years ago
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
text: "",
py: ""
})
},
_init: function () {
BI.Text.superclass._init.apply(this, arguments);
7 years ago
var self = this, o = this.options;
8 years ago
if (o.hgap + o.lgap > 0) {
7 years ago
this.element.css({
"padding-left": o.hgap + o.lgap + "px"
8 years ago
})
}
if (o.hgap + o.rgap > 0) {
7 years ago
this.element.css({
"padding-right": o.hgap + o.rgap + "px"
8 years ago
})
}
if (o.vgap + o.tgap > 0) {
7 years ago
this.element.css({
"padding-top": o.vgap + o.tgap + "px"
8 years ago
})
}
if (o.vgap + o.bgap > 0) {
7 years ago
this.element.css({
"padding-bottom": o.vgap + o.bgap + "px"
8 years ago
})
}
if (BI.isNumber(o.height)) {
this.element.css({"lineHeight": o.height + "px"});
}
if (BI.isNumber(o.lineHeight)) {
this.element.css({"lineHeight": o.lineHeight + "px"});
}
this.element.css({
"textAlign": o.textAlign,
"whiteSpace": o.whiteSpace
});
7 years ago
if (o.handler) {
this.text = BI.createWidget({
type: "bi.layout",
tagName: 'span'
});
this.text.element.click(function () {
o.handler(self.getValue());
});
BI.createWidget({
type: "bi.default",
element: this,
items: [this.text]
});
} else {
this.text = this;
}
if (BI.isKey(o.text)) {
this.setText(o.text);
} else if (BI.isKey(o.value)) {
this.setText(o.value);
}
8 years ago
if (BI.isKey(o.keyword)) {
7 years ago
this.element.__textKeywordMarked__(o.text, o.keyword, o.py);
8 years ago
}
},
doRedMark: function (keyword) {
var o = this.options;
this.text.element.__textKeywordMarked__(o.text || o.value, keyword, o.py);
},
unRedMark: function () {
var o = this.options;
this.text.element.__textKeywordMarked__(o.text || o.value, "", o.py);
},
doHighLight: function () {
this.text.element.addClass("bi-high-light");
},
unHighLight: function () {
this.text.element.removeClass("bi-high-light");
},
setValue: function (text) {
BI.Text.superclass.setValue.apply(this, arguments);
if (!this.isReadOnly()) {
8 years ago
this.setText(text);
8 years ago
}
},
setStyle: function (css) {
this.text.element.css(css)
},
8 years ago
setText: function (text) {
BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text;
8 years ago
this.text.element.text((text + "").replaceAll(" ", " "));
8 years ago
}
});
8 years ago
BI.shortcut("bi.text", BI.Text);