guy 4 years ago
parent
commit
f42a0bfd3a
  1. 498
      src/base/single/label/abstract.label.js
  2. 4
      src/core/wrapper/layout/flex/flex.horizontal.js
  3. 4
      src/core/wrapper/layout/flex/flex.vertical.js
  4. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js
  5. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js

498
src/base/single/label/abstract.label.js

@ -1,65 +1,84 @@
/** /**
* Created by dailer on 2019/6/19. * Created by dailer on 2019/6/19.
*/ */
!(function () {
var _isSupportFlex;
var isSupportFlex = function () {
if (_isSupportFlex == null) {
_isSupportFlex = !!(BI.isSupportCss3 && BI.isSupportCss3("flex"));
}
return _isSupportFlex;
};
BI.AbstractLabel = BI.inherit(BI.Single, {
BI.AbstractLabel = BI.inherit(BI.Single, { _defaultConfig: function (props) {
var conf = BI.AbstractLabel.superclass._defaultConfig.apply(this, arguments);
_defaultConfig: function (props) { return BI.extend(conf, {
var conf = BI.AbstractLabel.superclass._defaultConfig.apply(this, arguments); textAlign: "center",
return BI.extend(conf, { whiteSpace: "nowrap", // normal or nowrap
textAlign: "center", textWidth: null,
whiteSpace: "nowrap", // normal or nowrap textHeight: null,
textWidth: null, hgap: 0,
textHeight: null, vgap: 0,
hgap: 0, lgap: 0,
vgap: 0, rgap: 0,
lgap: 0, tgap: 0,
rgap: 0, bgap: 0,
tgap: 0, text: "",
bgap: 0, highLight: false,
text: "", handler: null
highLight: false, });
handler: null },
});
},
_createJson: function () { _createJson: function () {
var o = this.options; var o = this.options;
return { return {
type: "bi.text", type: "bi.text",
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
lineHeight: o.textHeight, lineHeight: o.textHeight,
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
highLight: o.highLight, highLight: o.highLight,
handler: o.handler handler: o.handler
}; };
}, },
_init: function () { _init: function () {
BI.AbstractLabel.superclass._init.apply(this, arguments); BI.AbstractLabel.superclass._init.apply(this, arguments);
if (this.options.textAlign === "center") { if (this.options.textAlign === "center") {
this._createCenterEl(); this._createCenterEl();
} else { } else {
this._createNotCenterEl(); this._createNotCenterEl();
} }
}, },
_createCenterEl: function () { _createCenterEl: function () {
var o = this.options; var o = this.options;
var json = this._createJson(); var json = this._createJson();
json.textAlign = "left"; json.textAlign = "left";
if (BI.isNumber(o.width) && o.width > 0) { if (BI.isNumber(o.width) && o.width > 0) {
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
json.maxWidth = o.textWidth; json.maxWidth = o.textWidth;
if (BI.isNumber(o.height) && o.height > 0) { // 1.1 if (BI.isNumber(o.height) && o.height > 0) { // 1.1
BI.createWidget({ 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", type: "bi.center_adapt",
height: o.height,
scrollable: o.whiteSpace === "normal", scrollable: o.whiteSpace === "normal",
element: this, element: this,
items: [ items: [
@ -70,7 +89,61 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
}); });
return; return;
} }
BI.createWidget({ // 1.2 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", type: "bi.center_adapt",
scrollable: o.whiteSpace === "normal", scrollable: o.whiteSpace === "normal",
element: this, element: this,
@ -82,7 +155,7 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
}); });
return; return;
} }
if (o.whiteSpace == "normal") { // 1.3 if (o.whiteSpace == "normal") { // 1.7
BI.extend(json, { BI.extend(json, {
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -94,13 +167,13 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
this.text = BI.createWidget(json); this.text = BI.createWidget(json);
BI.createWidget({ BI.createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
scrollable: o.whiteSpace === "normal", scrollable: true,
element: this, element: this,
items: [this.text] items: [this.text]
}); });
return; return;
} }
if (BI.isNumber(o.height) && o.height > 0) { // 1.4 if (BI.isNumber(o.height) && o.height > 0) { // 1.8
this.element.css({ this.element.css({
"line-height": o.height + "px" "line-height": o.height + "px"
}); });
@ -116,39 +189,6 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
})); }));
return; 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, { BI.extend(json, {
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -157,62 +197,52 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap
}); });
this.text = BI.createWidget(json);
this.text = BI.createWidget(BI.extend(json, {
maxWidth: "100%"
}));
BI.createWidget({ BI.createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
scrollable: true,
element: this, element: this,
items: [this.text] 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, { _createNotCenterEl: function () {
maxWidth: "100%" var o = this.options;
})); var adaptLayout = "bi.vertical_adapt";
BI.createWidget({ if (o.textAlign === "right" && (BI.isIE() || !isSupportFlex())) {
type: "bi.center_adapt", adaptLayout = "bi.right_vertical_adapt";
element: this, }
items: [this.text] var json = this._createJson();
}); if (BI.isNumber(o.width) && o.width > 0) {
}, if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
json.width = o.textWidth;
_createNotCenterEl: function () { if (BI.isNumber(o.height) && o.height > 0) { // 2.1
var o = this.options; BI.createWidget({
var adaptLayout = o.textAlign === "right" ? "bi.right_vertical_adapt" : "bi.vertical_adapt"; type: adaptLayout,
var json = this._createJson(); horizontalAlign: o.textAlign,
if (BI.isNumber(o.width) && o.width > 0) { height: o.height,
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { scrollable: o.whiteSpace === "normal",
json.width = o.textWidth; element: this,
if (BI.isNumber(o.height) && o.height > 0) { // 2.1 items: [
BI.createWidget({ {
el: (this.text = BI.createWidget(json))
}
]
});
return;
}
BI.createWidget({ // 2.2
type: adaptLayout, type: adaptLayout,
height: o.height, horizontalAlign: o.textAlign,
scrollable: o.whiteSpace === "normal", scrollable: o.whiteSpace === "normal",
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
element: this, element: this,
items: [ items: [
{ {
@ -222,8 +252,46 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
}); });
return; return;
} }
BI.createWidget({ // 2.2 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,
horizontalAlign: o.textAlign,
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, type: adaptLayout,
horizontalAlign: o.textAlign,
scrollable: o.whiteSpace === "normal", scrollable: o.whiteSpace === "normal",
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -240,8 +308,13 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
}); });
return; return;
} }
if (BI.isNumber(o.height) && o.height > 0) { // 2.3 if (BI.isNumber(o.height) && o.height > 0) {
this.text = BI.createWidget(BI.extend(json, { 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, element: this,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -250,124 +323,67 @@ BI.AbstractLabel = BI.inherit(BI.Single, {
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap
})); }));
if (o.whiteSpace !== "normal") {
this.element.css({
"line-height": o.height - (o.vgap * 2) + "px"
});
}
return; return;
} }
json.width = o.width - 2 * o.hgap - o.lgap - o.rgap; BI.extend(json, {
BI.createWidget({ // 2.4
type: adaptLayout,
scrollable: o.whiteSpace === "normal",
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap
element: this,
items: [{
el: (this.text = BI.createWidget(json))
}]
}); });
return;
} this.text = BI.createWidget(BI.extend(json, {
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { maxWidth: "100%"
json.width = o.textWidth; }));
BI.createWidget({ // 2.5 BI.createWidget({
type: adaptLayout, type: adaptLayout,
scrollable: o.whiteSpace === "normal", horizontalAlign: o.textAlign,
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
element: this, element: this,
items: [ scrollable: o.whiteSpace === "normal",
{ items: [this.text]
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, { doRedMark: function () {
maxWidth: "100%" this.text.doRedMark.apply(this.text, arguments);
})); },
BI.createWidget({
type: adaptLayout,
element: this,
scrollable: o.whiteSpace === "normal",
items: [this.text]
});
},
doRedMark: function () { unRedMark: function () {
this.text.doRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
}, },
unRedMark: function () { doHighLight: function () {
this.text.unRedMark.apply(this.text, arguments); this.text.doHighLight.apply(this.text, arguments);
}, },
doHighLight: function () { unHighLight: function () {
this.text.doHighLight.apply(this.text, arguments); this.text.unHighLight.apply(this.text, arguments);
}, },
unHighLight: function () { setText: function (v) {
this.text.unHighLight.apply(this.text, arguments); this.options.text = v;
}, this.text.setText(v);
},
setText: function (v) { getText: function () {
this.options.text = v; return this.options.text;
this.text.setText(v); },
},
getText: function () { setStyle: function (css) {
return this.options.text; this.text.setStyle(css);
}, },
setStyle: function (css) { setValue: function (v) {
this.text.setStyle(css); BI.AbstractLabel.superclass.setValue.apply(this, arguments);
}, if (!this.isReadOnly()) {
this.text.setValue(v);
}
},
setValue: function (v) { populate: function () {
BI.AbstractLabel.superclass.setValue.apply(this, arguments); BI.AbstractLabel.superclass.populate.apply(this, arguments);
if (!this.isReadOnly()) {
this.text.setValue(v);
} }
}, });
}());
populate: function () {
BI.AbstractLabel.superclass.populate.apply(this, arguments);
}
});

4
src/core/wrapper/layout/flex/flex.horizontal.js

@ -36,7 +36,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
"flex-shrink": "0" "flex-shrink": "0"
}); });
if (o.columnSize[i] > 0) { if (o.columnSize[i] > 0) {
w.element.width(o.columnSize[i]); w.element.width(o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]);
} }
if (o.columnSize[i] === "fill") { if (o.columnSize[i] === "fill") {
w.element.css("flex", "1"); w.element.css("flex", "1");
@ -73,4 +73,4 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut("bi.flex_horizontal", BI.FlexHorizontalLayout); BI.shortcut("bi.flex_horizontal", BI.FlexHorizontalLayout);

4
src/core/wrapper/layout/flex/flex.vertical.js

@ -35,7 +35,7 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, {
"flex-shrink": "0" "flex-shrink": "0"
}); });
if (o.rowSize[i] > 0) { if (o.rowSize[i] > 0) {
w.element.height(o.rowSize[i]); w.element.height(o.rowSize[i] <= 1 ? (o.rowSize[i] * 100 + "%") : o.rowSize[i]);
} }
if (o.rowSize[i] === "fill") { if (o.rowSize[i] === "fill") {
w.element.css("flex", "1"); w.element.css("flex", "1");
@ -72,4 +72,4 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut("bi.flex_vertical", BI.FlexVerticalLayout); BI.shortcut("bi.flex_vertical", BI.FlexVerticalLayout);

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js

@ -37,7 +37,7 @@ BI.FlexWrapperHorizontalLayout = BI.inherit(BI.Layout, {
"flex-shrink": "0" "flex-shrink": "0"
}); });
if (o.columnSize[i] > 0) { if (o.columnSize[i] > 0) {
w.element.width(o.columnSize[i]); w.element.width(o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]);
} }
if (o.columnSize[i] === "fill") { if (o.columnSize[i] === "fill") {
w.element.css("flex", "1"); w.element.css("flex", "1");
@ -83,4 +83,4 @@ BI.FlexWrapperHorizontalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut("bi.flex_scrollable_horizontal", BI.FlexWrapperHorizontalLayout); BI.shortcut("bi.flex_scrollable_horizontal", BI.FlexWrapperHorizontalLayout);

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js

@ -37,7 +37,7 @@ BI.FlexWrapperVerticalLayout = BI.inherit(BI.Layout, {
"flex-shrink": "0" "flex-shrink": "0"
}); });
if (o.rowSize[i] > 0) { if (o.rowSize[i] > 0) {
w.element.height(o.rowSize[i]); w.element.height(o.rowSize[i] <= 1 ? (o.rowSize[i] * 100 + "%") : o.rowSize[i]);
} }
if (o.rowSize[i] === "fill") { if (o.rowSize[i] === "fill") {
w.element.css("flex", "1"); w.element.css("flex", "1");
@ -83,4 +83,4 @@ BI.FlexWrapperVerticalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut("bi.flex_scrollable_vertical", BI.FlexWrapperVerticalLayout); BI.shortcut("bi.flex_scrollable_vertical", BI.FlexWrapperVerticalLayout);

Loading…
Cancel
Save