guy 7 years ago
parent
commit
770fad2723
  1. 60
      bi/base.js
  2. 60
      docs/base.js
  3. 60
      src/base/single/text.js

60
bi/base.js

@ -478,6 +478,7 @@ BI.Text = BI.inherit(BI.Single, {
textAlign: "left", textAlign: "left",
whiteSpace: "normal", whiteSpace: "normal",
lineHeight: null, lineHeight: null,
handler: null,//如果传入handler,表示处理文字的点击事件,不是区域的
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -491,39 +492,25 @@ BI.Text = BI.inherit(BI.Single, {
_init: function () { _init: function () {
BI.Text.superclass._init.apply(this, arguments); BI.Text.superclass._init.apply(this, arguments);
var o = this.options; var self = this, o = this.options;
this.text = BI.createWidget({
type: "bi.layout",
cls: "bi-text"
});
BI.createWidget({
type: "bi.default",
element: this,
items: [this.text]
});
if (BI.isKey(o.text)) {
this.setText(o.text);
} else if (BI.isKey(o.value)) {
this.setText(o.value);
}
if (o.hgap + o.lgap > 0) { if (o.hgap + o.lgap > 0) {
this.text.element.css({ this.element.css({
"margin-left": o.hgap + o.lgap + "px" "padding-left": o.hgap + o.lgap + "px"
}) })
} }
if (o.hgap + o.rgap > 0) { if (o.hgap + o.rgap > 0) {
this.text.element.css({ this.element.css({
"margin-right": o.hgap + o.rgap + "px" "padding-right": o.hgap + o.rgap + "px"
}) })
} }
if (o.vgap + o.tgap > 0) { if (o.vgap + o.tgap > 0) {
this.text.element.css({ this.element.css({
"margin-top": o.vgap + o.tgap + "px" "padding-top": o.vgap + o.tgap + "px"
}) })
} }
if (o.vgap + o.bgap > 0) { if (o.vgap + o.bgap > 0) {
this.text.element.css({ this.element.css({
"margin-bottom": o.vgap + o.bgap + "px" "padding-bottom": o.vgap + o.bgap + "px"
}) })
} }
if (BI.isNumber(o.height)) { if (BI.isNumber(o.height)) {
@ -532,16 +519,33 @@ BI.Text = BI.inherit(BI.Single, {
if (BI.isNumber(o.lineHeight)) { if (BI.isNumber(o.lineHeight)) {
this.element.css({"lineHeight": o.lineHeight + "px"}); this.element.css({"lineHeight": o.lineHeight + "px"});
} }
this.text.element.css({
"textAlign": o.textAlign,
"whiteSpace": o.whiteSpace
});
this.element.css({ this.element.css({
"textAlign": o.textAlign, "textAlign": o.textAlign,
"whiteSpace": o.whiteSpace "whiteSpace": o.whiteSpace
}); });
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);
}
if (BI.isKey(o.keyword)) { if (BI.isKey(o.keyword)) {
this.text.element.__textKeywordMarked__(o.text, o.keyword, o.py); this.element.__textKeywordMarked__(o.text, o.keyword, o.py);
} }
}, },

60
docs/base.js

@ -478,6 +478,7 @@ BI.Text = BI.inherit(BI.Single, {
textAlign: "left", textAlign: "left",
whiteSpace: "normal", whiteSpace: "normal",
lineHeight: null, lineHeight: null,
handler: null,//如果传入handler,表示处理文字的点击事件,不是区域的
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -491,39 +492,25 @@ BI.Text = BI.inherit(BI.Single, {
_init: function () { _init: function () {
BI.Text.superclass._init.apply(this, arguments); BI.Text.superclass._init.apply(this, arguments);
var o = this.options; var self = this, o = this.options;
this.text = BI.createWidget({
type: "bi.layout",
cls: "bi-text"
});
BI.createWidget({
type: "bi.default",
element: this,
items: [this.text]
});
if (BI.isKey(o.text)) {
this.setText(o.text);
} else if (BI.isKey(o.value)) {
this.setText(o.value);
}
if (o.hgap + o.lgap > 0) { if (o.hgap + o.lgap > 0) {
this.text.element.css({ this.element.css({
"margin-left": o.hgap + o.lgap + "px" "padding-left": o.hgap + o.lgap + "px"
}) })
} }
if (o.hgap + o.rgap > 0) { if (o.hgap + o.rgap > 0) {
this.text.element.css({ this.element.css({
"margin-right": o.hgap + o.rgap + "px" "padding-right": o.hgap + o.rgap + "px"
}) })
} }
if (o.vgap + o.tgap > 0) { if (o.vgap + o.tgap > 0) {
this.text.element.css({ this.element.css({
"margin-top": o.vgap + o.tgap + "px" "padding-top": o.vgap + o.tgap + "px"
}) })
} }
if (o.vgap + o.bgap > 0) { if (o.vgap + o.bgap > 0) {
this.text.element.css({ this.element.css({
"margin-bottom": o.vgap + o.bgap + "px" "padding-bottom": o.vgap + o.bgap + "px"
}) })
} }
if (BI.isNumber(o.height)) { if (BI.isNumber(o.height)) {
@ -532,16 +519,33 @@ BI.Text = BI.inherit(BI.Single, {
if (BI.isNumber(o.lineHeight)) { if (BI.isNumber(o.lineHeight)) {
this.element.css({"lineHeight": o.lineHeight + "px"}); this.element.css({"lineHeight": o.lineHeight + "px"});
} }
this.text.element.css({
"textAlign": o.textAlign,
"whiteSpace": o.whiteSpace
});
this.element.css({ this.element.css({
"textAlign": o.textAlign, "textAlign": o.textAlign,
"whiteSpace": o.whiteSpace "whiteSpace": o.whiteSpace
}); });
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);
}
if (BI.isKey(o.keyword)) { if (BI.isKey(o.keyword)) {
this.text.element.__textKeywordMarked__(o.text, o.keyword, o.py); this.element.__textKeywordMarked__(o.text, o.keyword, o.py);
} }
}, },

60
src/base/single/text.js

@ -11,6 +11,7 @@ BI.Text = BI.inherit(BI.Single, {
textAlign: "left", textAlign: "left",
whiteSpace: "normal", whiteSpace: "normal",
lineHeight: null, lineHeight: null,
handler: null,//如果传入handler,表示处理文字的点击事件,不是区域的
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -24,39 +25,25 @@ BI.Text = BI.inherit(BI.Single, {
_init: function () { _init: function () {
BI.Text.superclass._init.apply(this, arguments); BI.Text.superclass._init.apply(this, arguments);
var o = this.options; var self = this, o = this.options;
this.text = BI.createWidget({
type: "bi.layout",
cls: "bi-text"
});
BI.createWidget({
type: "bi.default",
element: this,
items: [this.text]
});
if (BI.isKey(o.text)) {
this.setText(o.text);
} else if (BI.isKey(o.value)) {
this.setText(o.value);
}
if (o.hgap + o.lgap > 0) { if (o.hgap + o.lgap > 0) {
this.text.element.css({ this.element.css({
"margin-left": o.hgap + o.lgap + "px" "padding-left": o.hgap + o.lgap + "px"
}) })
} }
if (o.hgap + o.rgap > 0) { if (o.hgap + o.rgap > 0) {
this.text.element.css({ this.element.css({
"margin-right": o.hgap + o.rgap + "px" "padding-right": o.hgap + o.rgap + "px"
}) })
} }
if (o.vgap + o.tgap > 0) { if (o.vgap + o.tgap > 0) {
this.text.element.css({ this.element.css({
"margin-top": o.vgap + o.tgap + "px" "padding-top": o.vgap + o.tgap + "px"
}) })
} }
if (o.vgap + o.bgap > 0) { if (o.vgap + o.bgap > 0) {
this.text.element.css({ this.element.css({
"margin-bottom": o.vgap + o.bgap + "px" "padding-bottom": o.vgap + o.bgap + "px"
}) })
} }
if (BI.isNumber(o.height)) { if (BI.isNumber(o.height)) {
@ -65,16 +52,33 @@ BI.Text = BI.inherit(BI.Single, {
if (BI.isNumber(o.lineHeight)) { if (BI.isNumber(o.lineHeight)) {
this.element.css({"lineHeight": o.lineHeight + "px"}); this.element.css({"lineHeight": o.lineHeight + "px"});
} }
this.text.element.css({
"textAlign": o.textAlign,
"whiteSpace": o.whiteSpace
});
this.element.css({ this.element.css({
"textAlign": o.textAlign, "textAlign": o.textAlign,
"whiteSpace": o.whiteSpace "whiteSpace": o.whiteSpace
}); });
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);
}
if (BI.isKey(o.keyword)) { if (BI.isKey(o.keyword)) {
this.text.element.__textKeywordMarked__(o.text, o.keyword, o.py); this.element.__textKeywordMarked__(o.text, o.keyword, o.py);
} }
}, },

Loading…
Cancel
Save