From 7eabaa6b66bf3715df5bac2f28625f83380cb5f7 Mon Sep 17 00:00:00 2001 From: dailer Date: Wed, 19 Jun 2019 20:57:00 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-748=20feat:=20fineui=E7=9A=84html?= =?UTF-8?q?=E3=80=81htmlLabel=E6=8E=A7=E4=BB=B6=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96.=20=E5=8E=BB=E6=8E=89bi.html=20=E7=9A=84mouted=20?= =?UTF-8?q?=E4=B9=8B=E5=90=8EsetText=E9=80=BB=E8=BE=91.=20=E5=8E=BB?= =?UTF-8?q?=E9=99=A4label=E5=92=8Chtmllabel=E7=9A=84=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E4=BB=A3=E7=A0=81.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/html/html.js | 38 ++- src/base/single/label/abstract.label.js | 369 ++++++++++++++++++++++++ src/base/single/label/html.label.js | 361 +---------------------- src/base/single/label/label.js | 361 ++--------------------- src/base/single/text.js | 34 +-- 5 files changed, 436 insertions(+), 727 deletions(-) create mode 100644 src/base/single/label/abstract.label.js diff --git a/src/base/single/html/html.js b/src/base/single/html/html.js index 3d172691e..87d8a5732 100644 --- a/src/base/single/html/html.js +++ b/src/base/single/html/html.js @@ -4,22 +4,21 @@ * @extends BI.Single */ BI.Html = BI.inherit(BI.Single, { - _defaultConfig: function () { - var conf = BI.Html.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text", - textAlign: "left", - whiteSpace: "normal", - lineHeight: null, - handler: null, // 如果传入handler,表示处理文字的点击事件,不是区域的 - hgap: 0, - vgap: 0, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - text: "" - }); + + props: { + baseCls: "bi-html", + textAlign: "left", + whiteSpace: "normal", + lineHeight: null, + handler: null, // 如果传入handler,表示处理文字的点击事件,不是区域的 + hgap: 0, + vgap: 0, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + text: "", + highLight: false }, render: function () { @@ -75,16 +74,15 @@ BI.Html = BI.inherit(BI.Single, { } else { this.text = this; } - }, - - mounted: function () { - var o = this.options; if (BI.isKey(o.text)) { this.setText(o.text); } else if (BI.isKey(o.value)) { this.setText(o.value); } + if (o.highLight) { + this.doHighLight(); + } }, doHighLight: function () { diff --git a/src/base/single/label/abstract.label.js b/src/base/single/label/abstract.label.js new file mode 100644 index 000000000..f0513fb08 --- /dev/null +++ b/src/base/single/label/abstract.label.js @@ -0,0 +1,369 @@ +/** + * Created by dailer on 2019/6/19. + */ + +BI.AbstractLabel = BI.inherit(BI.Single, { + + props: { + textAlign: "center", + whiteSpace: "nowrap", // normal or nowrap + textWidth: null, + textHeight: null, + hgap: 0, + vgap: 0, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + text: "", + py: "", + keyword: "", + highLight: false + }, + + _createJson: function () { + var o = this.options; + return { + type: "bi.text", + textAlign: o.textAlign, + whiteSpace: o.whiteSpace, + lineHeight: o.textHeight, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword, + highLight: o.highLight + }; + }, + + _init: function () { + BI.AbstractLabel.superclass._init.apply(this, arguments); + + if (this.options.textAlign === "center") { + this._createCenterEl(); + } else { + this._createNotCenterEl(); + } + }, + + _createCenterEl: function () { + var o = this.options; + var json = this._createJson(); + json.textAlign = "left"; + if (BI.isNumber(o.width) && o.width > 0) { + if (BI.isNumber(o.textWidth) && o.textWidth > 0) { + json.maxWidth = o.textWidth; + if (BI.isNumber(o.height) && o.height > 0) { // 1.1 + BI.createWidget({ + type: "bi.center_adapt", + height: o.height, + scrollable: o.whiteSpace === "normal", + element: this, + items: [ + { + el: (this.text = BI.createWidget(json)) + } + ] + }); + return; + } + BI.createWidget({ // 1.2 + type: "bi.center_adapt", + scrollable: o.whiteSpace === "normal", + element: this, + items: [ + { + el: (this.text = BI.createWidget(json)) + } + ] + }); + return; + } + if (o.whiteSpace == "normal") { // 1.3 + BI.extend(json, { + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + }); + this.text = BI.createWidget(json); + BI.createWidget({ + type: "bi.center_adapt", + scrollable: o.whiteSpace === "normal", + element: this, + items: [this.text] + }); + return; + } + if (BI.isNumber(o.height) && o.height > 0) { // 1.4 + this.element.css({ + "line-height": o.height + "px" + }); + json.textAlign = o.textAlign; + this.text = BI.createWidget(BI.extend(json, { + element: this, + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + })); + return; + } + BI.extend(json, { // 1.5 + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap, + maxWidth: "100%" + }); + this.text = BI.createWidget(json); + BI.createWidget({ + type: "bi.center_adapt", + scrollable: o.whiteSpace === "normal", + element: this, + items: [this.text] + }); + return; + } + if (BI.isNumber(o.textWidth) && o.textWidth > 0) { // 1.6 + json.maxWidth = o.textWidth; + BI.createWidget({ + type: "bi.center_adapt", + scrollable: o.whiteSpace === "normal", + element: this, + items: [ + { + el: (this.text = BI.createWidget(json)) + } + ] + }); + return; + } + if (o.whiteSpace == "normal") { // 1.7 + BI.extend(json, { + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + }); + this.text = BI.createWidget(json); + BI.createWidget({ + type: "bi.center_adapt", + scrollable: true, + element: this, + items: [this.text] + }); + return; + } + if (BI.isNumber(o.height) && o.height > 0) { // 1.8 + this.element.css({ + "line-height": o.height + "px" + }); + json.textAlign = o.textAlign; + this.text = BI.createWidget(BI.extend(json, { + element: this, + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + })); + return; + } + BI.extend(json, { + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + }); + + this.text = BI.createWidget(BI.extend(json, { + maxWidth: "100%" + })); + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [this.text] + }); + }, + + _createNotCenterEl: function () { + var o = this.options; + var adaptLayout = o.textAlign === "right" ? "bi.right_vertical_adapt" : "bi.vertical_adapt"; + var json = this._createJson(); + if (BI.isNumber(o.width) && o.width > 0) { + if (BI.isNumber(o.textWidth) && o.textWidth > 0) { + json.width = o.textWidth; + if (BI.isNumber(o.height) && o.height > 0) { // 2.1 + BI.createWidget({ + type: adaptLayout, + height: o.height, + scrollable: o.whiteSpace === "normal", + element: this, + items: [ + { + el: (this.text = BI.createWidget(json)) + } + ] + }); + return; + } + BI.createWidget({ // 2.2 + type: adaptLayout, + scrollable: o.whiteSpace === "normal", + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap, + element: this, + items: [ + { + el: (this.text = BI.createWidget(json)) + } + ] + }); + return; + } + if (BI.isNumber(o.height) && o.height > 0) { // 2.3 + this.text = BI.createWidget(BI.extend(json, { + element: this, + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + })); + if (o.whiteSpace !== "normal") { + this.element.css({ + "line-height": o.height - (o.vgap * 2) + "px" + }); + } + return; + } + json.width = o.width - 2 * o.hgap - o.lgap - o.rgap; + BI.createWidget({ // 2.4 + type: adaptLayout, + scrollable: o.whiteSpace === "normal", + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap, + element: this, + items: [{ + el: (this.text = BI.createWidget(json)) + }] + }); + return; + } + if (BI.isNumber(o.textWidth) && o.textWidth > 0) { + json.width = o.textWidth; + BI.createWidget({ // 2.5 + type: adaptLayout, + scrollable: o.whiteSpace === "normal", + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap, + element: this, + items: [ + { + el: (this.text = BI.createWidget(json)) + } + ] + }); + return; + } + if (BI.isNumber(o.height) && o.height > 0) { + if (o.whiteSpace !== "normal") { + this.element.css({ + "line-height": o.height - (o.vgap * 2) + "px" + }); + } + this.text = BI.createWidget(BI.extend(json, { // 2.6 + element: this, + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + })); + return; + } + BI.extend(json, { + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap + }); + + this.text = BI.createWidget(BI.extend(json, { + maxWidth: "100%" + })); + BI.createWidget({ + type: adaptLayout, + element: this, + items: [this.text] + }); + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doHighLight: function () { + this.text.doHighLight.apply(this.text, arguments); + }, + + unHighLight: function () { + this.text.unHighLight.apply(this.text, arguments); + }, + + setText: function (v) { + this.options.text = v; + this.text.setText(v); + }, + + getText: function () { + return this.options.text; + }, + + setStyle: function (css) { + this.text.setStyle(css); + }, + + setValue: function (v) { + BI.AbstractLabel.superclass.setValue.apply(this, arguments); + if (!this.isReadOnly()) { + this.text.setValue(v); + } + }, + + populate: function () { + BI.AbstractLabel.superclass.populate.apply(this, arguments); + } +}); \ No newline at end of file diff --git a/src/base/single/label/html.label.js b/src/base/single/label/html.label.js index bd3e41701..50efd1f43 100644 --- a/src/base/single/label/html.label.js +++ b/src/base/single/label/html.label.js @@ -2,23 +2,21 @@ * Created by GUY on 2015/6/26. */ -BI.HtmlLabel = BI.inherit(BI.Single, { - _defaultConfig: function () { - var conf = BI.HtmlLabel.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-label", - textAlign: "center", - whiteSpace: "nowrap", // normal or nowrap - textWidth: null, - textHeight: null, - hgap: 0, - vgap: 0, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - text: "" - }); +BI.HtmlLabel = BI.inherit(BI.AbstractLabel, { + + props: { + baseCls: "bi-html-label", + textAlign: "center", + whiteSpace: "nowrap", // normal or nowrap + textWidth: null, + textHeight: null, + hgap: 0, + vgap: 0, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + text: "" }, _createJson: function () { @@ -31,335 +29,6 @@ BI.HtmlLabel = BI.inherit(BI.Single, { text: o.text, value: o.value }; - }, - - _init: function () { - BI.HtmlLabel.superclass._init.apply(this, arguments); - - if (this.options.textAlign === "center") { - this._createCenterEl(); - } else { - this._createNotCenterEl(); - } - }, - - _createCenterEl: function () { - var o = this.options; - var json = this._createJson(); - if (BI.isNumber(o.width) && o.width > 0) { - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { - json.maxWidth = o.textWidth; - if (BI.isNumber(o.height) && o.height > 0) { // 1.1 - BI.createWidget({ - type: "bi.center_adapt", - height: o.height, - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - BI.createWidget({ // 1.2 - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (o.whiteSpace == "normal") { - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - this.text = BI.createWidget(json); - BI.createWidget({ - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [this.text] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { - this.element.css({ - "line-height": o.height + "px" - }); - this.text = BI.createWidget(BI.extend(json, { - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - return; - } - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - maxWidth: "100%" - }); - this.text = BI.createWidget(json); - BI.createWidget({ - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [this.text] - }); - return; - } - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { - json.maxWidth = o.textWidth; - BI.createWidget({ - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (o.whiteSpace == "normal") { - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - this.text = BI.createWidget(json); - BI.createWidget({ - type: "bi.center_adapt", - scrollable: true, - element: this, - items: [this.text] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { - this.element.css({ - "line-height": o.height + "px" - }); - this.text = BI.createWidget(BI.extend(json, { - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - return; - } - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - - this.text = BI.createWidget(BI.extend(json, { - maxWidth: "100%" - })); - BI.createWidget({ - type: "bi.center_adapt", - element: this, - items: [this.text] - }); - }, - - _createNotCenterEl: function () { - var o = this.options; - var adaptLayout = o.textAlign === "right" ? "bi.right_vertical_adapt" : "bi.vertical_adapt"; - var json = this._createJson(); - if (BI.isNumber(o.width) && o.width > 0) { - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { - json.width = o.textWidth; - if (BI.isNumber(o.height) && o.height > 0) { - BI.createWidget({ - type: adaptLayout, - height: o.height, - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - BI.createWidget({ - type: adaptLayout, - scrollable: o.whiteSpace === "normal", - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { - this.text = BI.createWidget(BI.extend(json, { - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - if (o.whiteSpace !== "normal") { - this.element.css({ - "line-height": o.height - (o.vgap * 2) + "px" - }); - } - return; - } - json.width = o.width - 2 * o.hgap - o.lgap - o.rgap; - BI.createWidget({ - type: adaptLayout, - scrollable: o.whiteSpace === "normal", - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - element: this, - items: [{ - el: (this.text = BI.createWidget(json)) - }] - }); - return; - } - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { - json.width = o.textWidth; - BI.createWidget({ - type: adaptLayout, - scrollable: o.whiteSpace === "normal", - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { - if (o.whiteSpace !== "normal") { - this.element.css({ - "line-height": o.height - (o.vgap * 2) + "px" - }); - } - this.text = BI.createWidget(BI.extend(json, { - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - return; - } - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - - this.text = BI.createWidget(BI.extend(json, { - maxWidth: "100%" - })); - BI.createWidget({ - type: adaptLayout, - element: this, - items: [this.text] - }); - }, - - _setEnable: function (enable) { - BI.HtmlLabel.superclass._setEnable.apply(this, arguments); - if (enable === true) { - this.element.removeClass("base-disabled disabled"); - } else if (enable === false) { - this.element.addClass("base-disabled disabled"); - } - }, - - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - setText: function (v) { - this.options.text = v; - this.text.setText(v); - }, - - getText: function () { - return this.options.text; - }, - - setStyle: function (css) { - this.text.setStyle(css); - }, - - setValue: function (v) { - BI.HtmlLabel.superclass.setValue.apply(this, arguments); - if (!this.isReadOnly()) { - this.text.setValue(v); - } - }, - - populate: function () { - BI.HtmlLabel.superclass.populate.apply(this, arguments); } }); diff --git a/src/base/single/label/label.js b/src/base/single/label/label.js index f065ef9c9..6470a0bc2 100644 --- a/src/base/single/label/label.js +++ b/src/base/single/label/label.js @@ -2,26 +2,24 @@ * Created by GUY on 2015/6/26. */ -BI.Label = BI.inherit(BI.Single, { - _defaultConfig: function () { - var conf = BI.Label.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-label", - textAlign: "center", - whiteSpace: "nowrap", // normal or nowrap - textWidth: null, - textHeight: null, - hgap: 0, - vgap: 0, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - text: "", - py: "", - keyword: "", - highLight: false - }); +BI.Label = BI.inherit(BI.AbstractLabel, { + + props: { + baseCls: "bi-label", + textAlign: "center", + whiteSpace: "nowrap", // normal or nowrap + textWidth: null, + textHeight: null, + hgap: 0, + vgap: 0, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + text: "", + py: "", + keyword: "", + highLight: false }, _createJson: function () { @@ -39,335 +37,12 @@ BI.Label = BI.inherit(BI.Single, { }; }, - _init: function () { - BI.Label.superclass._init.apply(this, arguments); - - if (this.options.textAlign === "center") { - this._createCenterEl(); - } else { - this._createNotCenterEl(); - } - }, - - _createCenterEl: function () { - var o = this.options; - var json = this._createJson(); - json.textAlign = "left"; - if (BI.isNumber(o.width) && o.width > 0) { - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { - json.maxWidth = o.textWidth; - if (BI.isNumber(o.height) && o.height > 0) { // 1.1 - BI.createWidget({ - type: "bi.center_adapt", - height: o.height, - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - BI.createWidget({ // 1.2 - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (o.whiteSpace == "normal") { // 1.3 - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - this.text = BI.createWidget(json); - BI.createWidget({ - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [this.text] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { // 1.4 - this.element.css({ - "line-height": o.height + "px" - }); - json.textAlign = o.textAlign; - this.text = BI.createWidget(BI.extend(json, { - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - return; - } - BI.extend(json, { // 1.5 - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - maxWidth: "100%" - }); - this.text = BI.createWidget(json); - BI.createWidget({ - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [this.text] - }); - return; - } - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { // 1.6 - json.maxWidth = o.textWidth; - BI.createWidget({ - type: "bi.center_adapt", - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (o.whiteSpace == "normal") { // 1.7 - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - this.text = BI.createWidget(json); - BI.createWidget({ - type: "bi.center_adapt", - scrollable: true, - element: this, - items: [this.text] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { // 1.8 - this.element.css({ - "line-height": o.height + "px" - }); - json.textAlign = o.textAlign; - this.text = BI.createWidget(BI.extend(json, { - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - return; - } - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - - this.text = BI.createWidget(BI.extend(json, { - maxWidth: "100%" - })); - BI.createWidget({ - type: "bi.center_adapt", - element: this, - items: [this.text] - }); - }, - - _createNotCenterEl: function () { - var o = this.options; - var adaptLayout = o.textAlign === "right" ? "bi.right_vertical_adapt" : "bi.vertical_adapt"; - var json = this._createJson(); - if (BI.isNumber(o.width) && o.width > 0) { - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { - json.width = o.textWidth; - if (BI.isNumber(o.height) && o.height > 0) { // 2.1 - BI.createWidget({ - type: adaptLayout, - height: o.height, - scrollable: o.whiteSpace === "normal", - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - BI.createWidget({ // 2.2 - type: adaptLayout, - scrollable: o.whiteSpace === "normal", - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { // 2.3 - this.text = BI.createWidget(BI.extend(json, { - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - if (o.whiteSpace !== "normal") { - this.element.css({ - "line-height": o.height - (o.vgap * 2) + "px" - }); - } - return; - } - json.width = o.width - 2 * o.hgap - o.lgap - o.rgap; - BI.createWidget({ // 2.4 - type: adaptLayout, - scrollable: o.whiteSpace === "normal", - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - element: this, - items: [{ - el: (this.text = BI.createWidget(json)) - }] - }); - return; - } - if (BI.isNumber(o.textWidth) && o.textWidth > 0) { - json.width = o.textWidth; - BI.createWidget({ // 2.5 - type: adaptLayout, - scrollable: o.whiteSpace === "normal", - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - element: this, - items: [ - { - el: (this.text = BI.createWidget(json)) - } - ] - }); - return; - } - if (BI.isNumber(o.height) && o.height > 0) { - if (o.whiteSpace !== "normal") { - this.element.css({ - "line-height": o.height - (o.vgap * 2) + "px" - }); - } - this.text = BI.createWidget(BI.extend(json, { // 2.6 - element: this, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - })); - return; - } - BI.extend(json, { - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap - }); - - this.text = BI.createWidget(BI.extend(json, { - maxWidth: "100%" - })); - BI.createWidget({ - type: adaptLayout, - element: this, - items: [this.text] - }); - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, unRedMark: function () { this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - setText: function (v) { - this.options.text = v; - this.text.setText(v); - }, - - getText: function () { - return this.options.text; - }, - - setStyle: function (css) { - this.text.setStyle(css); - }, - - setValue: function (v) { - BI.Label.superclass.setValue.apply(this, arguments); - if (!this.isReadOnly()) { - this.text.setValue(v); - } - }, - - populate: function () { - BI.Label.superclass.populate.apply(this, arguments); } }); diff --git a/src/base/single/text.js b/src/base/single/text.js index 53e938d2a..426927d65 100644 --- a/src/base/single/text.js +++ b/src/base/single/text.js @@ -4,24 +4,22 @@ * @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, - handler: null, // 如果传入handler,表示处理文字的点击事件,不是区域的 - hgap: 0, - vgap: 0, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - text: "", - py: "", - highLight: false - }); + + props: { + baseCls: "bi-text", + textAlign: "left", + whiteSpace: "normal", + lineHeight: null, + handler: null, // 如果传入handler,表示处理文字的点击事件,不是区域的 + hgap: 0, + vgap: 0, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + text: "", + py: "", + highLight: false }, render: function () {