Browse Source

Merge pull request #204403 in DEC/fineui from feature/x to bugfix/11.0

* commit '0f2113953ccc95531ff6d2e32e1a4269f36da9a0': (121 commits)
  auto upgrade version to 2.0.20221024153423
  update
  auto upgrade version to 2.0.20221024105424
  auto upgrade version to 2.0.20221024101340
  无JIRA fix: 修复tape布局 NaN的场景
  auto upgrade version to 2.0.20221023144426
  update
  ThemeProvider
  Revert "无JIRA fix: _initElementHeight和_initElementWidth方法修复"
  无JIRA fix: 文本过滤组件
  auto upgrade version to 2.0.20221023105429
  反了
  auto upgrade version to 2.0.20221022222430
  bugfix
  bugfix
  toPix 和 pixFormat
  无JIRA fix: _initElementHeight和_initElementWidth方法修复
  auto upgrade version to 2.0.20221022202435
  auto upgrade version to 2.0.20221022183431
  增加toPix方法
  ...
research/test
superman 2 years ago
parent
commit
770dcc66de
  1. 67
      _mobile/date.i18n.cn.js
  2. 2
      demo/less/face.less
  3. 9
      demo/less/main.less
  4. 2
      demo/less/north.less
  5. 4
      dist/fix/fix.compact.js
  6. 99
      examples/ThemeProvider.html
  7. 59
      examples/useContext.html
  8. 12
      examples/响应式布局.html
  9. 2
      package.json
  10. 19
      src/base/collection/collection.js
  11. 7
      src/base/combination/group.button.js
  12. 5
      src/base/combination/navigation.js
  13. 2
      src/base/combination/tab.js
  14. 20
      src/base/context.js
  15. 19
      src/base/grid/grid.js
  16. 16
      src/base/layer/layer.popup.js
  17. 3
      src/base/list/listview.js
  18. 9
      src/base/list/virtualgrouplist.js
  19. 12
      src/base/list/virtuallist.js
  20. 19
      src/base/single/0.single.js
  21. 14
      src/base/single/1.text.js
  22. 2
      src/base/single/button/buttons/button.icon.js
  23. 18
      src/base/single/button/buttons/button.js
  24. 1
      src/base/single/button/buttons/button.text.js
  25. 1
      src/base/single/button/listitem/blankiconicontextitem.js
  26. 1
      src/base/single/button/listitem/blankicontexticonitem.js
  27. 1
      src/base/single/button/listitem/blankicontextitem.js
  28. 1
      src/base/single/button/listitem/icontexticonitem.js
  29. 1
      src/base/single/button/listitem/icontextitem.js
  30. 1
      src/base/single/button/listitem/texticonitem.js
  31. 1
      src/base/single/button/listitem/textitem.js
  32. 1
      src/base/single/button/node/icontexticonnode.js
  33. 1
      src/base/single/button/node/icontextnode.js
  34. 1
      src/base/single/button/node/texticonnode.js
  35. 1
      src/base/single/button/node/textnode.js
  36. 5
      src/base/single/editor/editor.js
  37. 15
      src/base/single/html/html.js
  38. 8
      src/base/single/label/abstract.label.js
  39. 2
      src/base/single/label/icon.label.js
  40. 4
      src/base/single/tip/tip.toast.js
  41. 2
      src/base/single/tip/tip.tooltip.js
  42. 6
      src/case/button/node/siwtcher.tree.node.js
  43. 6
      src/case/button/treeitem/treeitem.js
  44. 2
      src/case/calendar/calendar.date.item.js
  45. 4
      src/case/calendar/calendar.js
  46. 4
      src/case/colorchooser/colorchooser.js
  47. 6
      src/case/combo/icontextvaluecombo/combo.icontextvalue.js
  48. 9
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  49. 6
      src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js
  50. 6
      src/case/combo/textvaluecombo/combo.textvalue.js
  51. 24
      src/case/editor/editor.shelter.js
  52. 24
      src/case/editor/editor.sign.js
  53. 24
      src/case/editor/editor.state.js
  54. 4
      src/case/layer/panel.js
  55. 2
      src/case/linearsegment/button.linear.segment.js
  56. 2
      src/case/list/list.select.js
  57. 3
      src/case/segment/button.segment.js
  58. 2
      src/case/segment/segment.js
  59. 4
      src/case/tree/treeexpander/tree.expander.popup.js
  60. 8
      src/case/trigger/trigger.editor.js
  61. 20
      src/case/trigger/trigger.icon.text.js
  62. 5
      src/case/trigger/trigger.text.js
  63. 3
      src/case/trigger/trigger.text.select.small.js
  64. 2
      src/case/trigger/trigger.text.small.js
  65. 4
      src/core/2.base.js
  66. 33
      src/core/3.ob.js
  67. 61
      src/core/4.widget.js
  68. 8
      src/core/5.inject.js
  69. 66
      src/core/constant/date.i18n.js
  70. 26
      src/core/constant/var.js
  71. 5
      src/core/controller/controller.popover.js
  72. 5
      src/core/controller/controller.tooltips.js
  73. 2
      src/core/func/alias.js
  74. 73
      src/core/func/date.js
  75. 673
      src/core/platform/web/detectElementResize.js
  76. 10
      src/core/wrapper/layout.js
  77. 8
      src/core/wrapper/layout/layout.flow.js
  78. 8
      src/core/wrapper/layout/layout.inline.js
  79. 4
      src/core/wrapper/layout/layout.tape.js
  80. 2
      src/core/wrapper/layout/responsive/responsive.flex.horizontal.js
  81. 3
      src/less/base/combo/combo.less
  82. 5
      src/less/base/single/editor/editor.textarea.less
  83. 21
      src/less/base/tree/ztree.less
  84. 67
      src/less/case/tree/tree.item.less
  85. 6
      src/less/core/utils/common.less
  86. 6
      src/less/core/wrapper/inline.less
  87. 18
      src/less/core/wrapper/inline.old.less
  88. 27
      src/less/widget/singleslider/slider/widget.slider.less
  89. 1
      src/less/widget/year/popup.year.less
  90. 4
      src/widget/date/calendar/popup.month.js
  91. 10
      src/widget/dynamicdate/dynamicdate.combo.js
  92. 2
      src/widget/dynamicdate/dynamicdate.param.item.js
  93. 6
      src/widget/dynamicdate/dynamicdate.popup.js
  94. 3
      src/widget/dynamicdate/dynamicdate.trigger.js
  95. 8
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  96. 6
      src/widget/dynamicdatetime/dynamicdatetime.popup.js
  97. 40
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js
  98. 4
      src/widget/editor/editor.search.js
  99. 12
      src/widget/editor/editor.text.js
  100. 105
      src/widget/intervalslider/intervalslider.js
  101. Some files were not shown because too many files have changed in this diff Show More

67
_mobile/date.i18n.cn.js

@ -1,67 +0,0 @@
/**
* Created by astronaut007 on 2018/8/8
*/
// 牵扯到国际化这些常量在页面加载后再生效
// full day names
BI.Date = BI.Date || {};
BI.Date._DN = ["星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六",
"星期日"];
// short day names
BI.Date._SDN = ["日",
"一",
"二",
"三",
"四",
"五",
"六",
"日"];
// Monday first, etc.
BI.Date._FD = 1;
// full month namesdat
BI.Date._MN = [
"一月",
"二月",
"三月",
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"十一月",
"十二月"];
// short month names
BI.Date._SMN = [0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11];
BI.Date._QN = ["", "第1季度",
"第2季度",
"第3季度",
"第4季度"];
/** Adds the number of days array to the Date object. */
BI.Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// 实际上无论周几作为一周的第一天,周初周末都是在-6-0间做偏移,用一个数组就可以
BI.Date._OFFSET = [0, -1, -2, -3, -4, -5, -6];

2
demo/less/face.less

@ -3,7 +3,7 @@
.demo-face { .demo-face {
.face-config { .face-config {
.config-label { .config-label {
font-size: 14px; font-size: 1.4rem;
} }
.config-item { .config-item {
} }

9
demo/less/main.less

@ -63,6 +63,7 @@ body {
right: 0; right: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
font-size: 1.2rem;
} }
.bi-theme-dark body { .bi-theme-dark body {
@ -83,9 +84,7 @@ body {
-moz-transition: all 0.5s ease; -moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease; -o-transition: all 0.5s ease;
background: #3f8ce8; background: #3f8ce8;
-webkit-border-radius: 20px; border-radius: 2rem;
-moz-border-radius: 20px;
border-radius: 20px;
overflow: hidden; overflow: hidden;
overflow-x: hidden; overflow-x: hidden;
overflow-y: hidden; overflow-y: hidden;
@ -99,7 +98,5 @@ body {
} }
.bi-progress-bar-bar { .bi-progress-bar-bar {
-webkit-border-radius: 20px; border-radius: 2rem;
-moz-border-radius: 20px;
border-radius: 20px;
} }

2
demo/less/north.less

@ -6,7 +6,7 @@
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: @color-bi-text; color: @color-bi-text;
background-color: #367fa9; background-color: #367fa9;
font-size: 20px; font-size: 2rem;
font-weight: 300; font-weight: 300;
} }
} }

4
dist/fix/fix.compact.js vendored

@ -78,7 +78,7 @@
}, options); }, options);
}; };
function findStore (widget) { BI.Widget.findStore = function findStore (widget) {
if (target != null) { if (target != null) {
return target; return target;
} }
@ -110,7 +110,7 @@
return true; return true;
} }
if (this._store) { if (this._store) {
var store = findStore(this.options.context || this._parent || this.options.element || this._context); var store = BI.Widget.findStore(this.options.context || this._parent || this.options.element || this._context);
if (store) { if (store) {
pushTarget(store); pushTarget(store);
needPop = true; needPop = true;

99
examples/ThemeProvider.html

@ -0,0 +1,99 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<!-- <link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.min.css"/>
<script src="../dist/2.0/fineui.js"></script> -->
<link rel="stylesheet" type="text/css" href="http://fanruan.design/fineui/2.0/fineui.min.css"/>
<!-- <script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script>-->
<script src="http://localhost:9001/fineui.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
var Model = BI.inherit(BI.Model, {
state: function () {
return {
theme: "light"
};
},
childContext: ["theme"],
actions: {
toggle: function () {
this.model.theme = this.model.theme === "light" ? "dark" : "light";
}
}
});
BI.model("demo.model", Model);
var Child = BI.inherit(BI.Widget, {
render: function () {
var label;
return {
type: "bi.context",
context: "theme",
watch: function (newValue, oldValue) {
label.setText(newValue);
},
items: [(context) => {
return {
type: "bi.label",
height: 30,
ref: function (_ref) {
label = _ref;
},
text: context.model.theme
}
}]
};
}
});
BI.shortcut("demo.child", Child);
var Widget = BI.inherit(BI.Widget, {
props: {
baseCls: "my-parent"
},
_store: function () {
return BI.Models.getModel("demo.model");
},
setup: function () {
var child;
var store = BI.useStore();
return function () {
return {
type: "bi.vertical",
vgap: 20,
items: [{
type: "demo.child",
ref: function (_ref) {
child = _ref;
}
}, {
type: "bi.button",
text: "改变主题",
handler: function () {
store.toggle();
}
}]
};
};
}
});
BI.shortcut("demo.parent", Widget);
BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "demo.parent"
},
top: 100,
left: 100
}],
element: "#wrapper"
});
</script>
</body>
</html>

59
examples/useContext.html

@ -5,8 +5,15 @@
<!-- <link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.min.css"/> <!-- <link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.min.css"/>
<script src="../dist/2.0/fineui.js"></script> --> <script src="../dist/2.0/fineui.js"></script> -->
<link rel="stylesheet" type="text/css" href="http://fanruan.design/fineui/2.0/fineui.min.css"/> <link rel="stylesheet" type="text/css" href="http://fanruan.design/fineui/2.0/fineui.min.css"/>
<script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script> <!-- <script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script>-->
<script src="http://localhost:9001/fineui.js"></script>
</head> </head>
<style>
.my-parent {
--css-scale: 1;
font-size: calc(var(--css-scale) * 14px);
}
</style>
<body> <body>
<div id="wrapper"></div> <div id="wrapper"></div>
<script> <script>
@ -14,7 +21,8 @@
var Model = BI.inherit(BI.Model, { var Model = BI.inherit(BI.Model, {
state: function () { state: function () {
return { return {
expand: false expand: false,
cssScale: 2.0
}; };
}, },
childContext: ["text"], childContext: ["text"],
@ -33,6 +41,36 @@
}); });
BI.model("demo.model", Model); BI.model("demo.model", Model);
var oldFormat = BI.pixFormat;
BI.pixFormat = function (pix, border) {
var context = BI.useContext("cssScale");
if (!context) {
return oldFormat.apply(this, arguments);
}
if (!BI.isNumber(pix)) {
return pix;
}
if (border > 0) {
return "calc(var(--css-scale) * " + pix + "px" + " - " + border + "px"+")";
}
return "calc(var(--css-scale) * " + pix + "px)";
};
var oldPix = BI.toPix;
BI.toPix = function (pix, border) {
var context = BI.useContext("cssScale");
if (!context) {
return oldPix.apply(this, arguments);
}
if (!BI.isNumber(pix)) {
return pix;
}
if (border > 0) {
return "calc(var(--css-scale) * " + pix + "px" + " - " + border + "px"+")";
}
return "calc(var(--css-scale) * " + pix + "px)";
};
var Child = BI.inherit(BI.Widget, { var Child = BI.inherit(BI.Widget, {
render: function () { render: function () {
var label; var label;
@ -45,6 +83,7 @@
// }); // });
return { return {
type: "bi.label", type: "bi.label",
height: 30,
ref: function (_ref) { ref: function (_ref) {
label = _ref; label = _ref;
}, },
@ -60,6 +99,9 @@
BI.shortcut("demo.child", Child); BI.shortcut("demo.child", Child);
var Widget = BI.inherit(BI.Widget, { var Widget = BI.inherit(BI.Widget, {
props: {
baseCls: "my-parent"
},
_store: function () { _store: function () {
return BI.Models.getModel("demo.model"); return BI.Models.getModel("demo.model");
}, },
@ -67,6 +109,7 @@
var child; var child;
var store = BI.useStore(); var store = BI.useStore();
return function () { return function () {
this.element[0].style.setProperty('--css-scale', store.model.cssScale);
return { return {
type: "bi.vertical", type: "bi.vertical",
vgap: 20, vgap: 20,
@ -75,6 +118,18 @@
ref: function (_ref) { ref: function (_ref) {
child = _ref; child = _ref;
} }
}, {
type: "bi.dynamic_date_combo",
supportDynamic: false,
width: 200,
value: {
type: 1,
value: {
year: 2012,
month: 3,
day: 15
}
}
}] }]
}; };
}; };

12
examples/响应式布局.html

@ -53,13 +53,13 @@
box-shadow: 0 2px 5px rgb(0 0 0 / 16%), 0 2px 10px rgb(0 0 0 / 12%); box-shadow: 0 2px 5px rgb(0 0 0 / 16%), 0 2px 10px rgb(0 0 0 / 12%);
} }
.nav-logo { .nav-logo {
background-image: url(https://qn.wangchuan.cc/pullrequest-logo.svg); background-image: url(http://qn.wangchuan.cc/pullrequest-logo.svg);
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: 50%; background-position: 50%;
background-size: contain; background-size: contain;
} }
.image { .image {
background-image: url(https://qn.wangchuan.cc/hero-graphic.png); background-image: url(http://qn.wangchuan.cc/hero-graphic.png);
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: contain; background-size: contain;
} }
@ -79,7 +79,7 @@
border: 1px solid #4aa4e0; border: 1px solid #4aa4e0;
} }
.wave { .wave {
background-image: url(https://qn.wangchuan.cc/wave.png); background-image: url(http://qn.wangchuan.cc/wave.png);
background-size: cover; background-size: cover;
background-repeat: repeat-x; background-repeat: repeat-x;
} }
@ -205,7 +205,7 @@
maxWidth: "100%", maxWidth: "100%",
maxHeight: "100%", maxHeight: "100%",
}, },
src: "https://qn.wangchuan.cc/hero-graphic.png", src: "http://qn.wangchuan.cc/hero-graphic.png",
width: "auto", width: "auto",
height: "auto", height: "auto",
}, },
@ -318,7 +318,7 @@
maxWidth: "100%", maxWidth: "100%",
maxHeight: "100%", maxHeight: "100%",
}, },
src: "https://qn.wangchuan.cc/velocity.png", src: "http://qn.wangchuan.cc/velocity.png",
width: "auto", width: "auto",
height: "auto", height: "auto",
}, },
@ -358,7 +358,7 @@
maxWidth: "100%", maxWidth: "100%",
maxHeight: "100%", maxHeight: "100%",
}, },
src: "https://qn.wangchuan.cc/secure.png", src: "http://qn.wangchuan.cc/secure.png",
width: "auto", width: "auto",
height: "auto", height: "auto",
}, },

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fineui", "name": "fineui",
"version": "2.0.20221009164825", "version": "2.0.20221024153423",
"description": "fineui", "description": "fineui",
"main": "dist/fineui_without_conflict.min.js", "main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",

19
src/base/collection/collection.js

@ -187,20 +187,11 @@ BI.CollectionView = BI.inherit(BI.Widget, {
var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1]; var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1];
var child; var child;
if (index >= 0) { if (index >= 0) {
// if (datum.width !== this.renderedCells[index]._width) {
// this.renderedCells[index]._width = datum.width;
this.renderedCells[index].el.setWidth(datum.width); this.renderedCells[index].el.setWidth(datum.width);
// }
// if (datum.height !== this.renderedCells[index]._height) {
// this.renderedCells[index]._height = datum.height;
this.renderedCells[index].el.setHeight(datum.height); this.renderedCells[index].el.setHeight(datum.height);
// } // 这里只使用px
// if (this.renderedCells[index]._left !== datum.x) { this.renderedCells[index].el.element.css("left", datum.x + "px");
this.renderedCells[index].el.element.css("left", datum.x / BI.pixRatio + BI.pixUnit); this.renderedCells[index].el.element.css("top", datum.y + "px");
// }
// if (this.renderedCells[index]._top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y / BI.pixRatio + BI.pixUnit);
// }
renderedCells.push(child = this.renderedCells[index]); renderedCells.push(child = this.renderedCells[index]);
} else { } else {
var item = o.itemFormatter(o.items[datum.index], datum.index); var item = o.itemFormatter(o.items[datum.index], datum.index);
@ -215,8 +206,8 @@ BI.CollectionView = BI.inherit(BI.Widget, {
})); }));
renderedCells.push({ renderedCells.push({
el: child, el: child,
left: datum.x, left: datum.x + "px",
top: datum.y, top: datum.y + "px",
_left: datum.x, _left: datum.x,
_top: datum.y, _top: datum.y,
// _width: datum.width, // _width: datum.width,

7
src/base/combination/group.button.js

@ -42,9 +42,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
_createBtns: function (items) { _createBtns: function (items) {
return BI.createWidgets(BI.createItems(items, { BI.Widget.pushContext(this);
var btns = BI.createWidgets(BI.createItems(items, {
type: "bi.text_button", type: "bi.text_button",
}), this); }));
BI.Widget.popContext();
return btns;
}, },
_btnsCreator: function (items) { _btnsCreator: function (items) {

5
src/base/combination/navigation.js

@ -43,9 +43,10 @@ BI.Navigation = BI.inherit(BI.Widget, {
return self.showIndex + v; return self.showIndex + v;
}, },
cardCreator: function (v) { cardCreator: function (v) {
BI.Widget.pushContext(self);
var card = o.cardCreator(v); var card = o.cardCreator(v);
BI.Widget.popContext();
self.cardMap[v] = card; self.cardMap[v] = card;
return card; return card;
}, },
afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardCreated: BI.bind(this.afterCardCreated, this),
@ -104,7 +105,9 @@ BI.Navigation = BI.inherit(BI.Widget, {
_assertCard: function (v) { _assertCard: function (v) {
if (!this.layout.isCardExisted(v)) { if (!this.layout.isCardExisted(v)) {
BI.Widget.pushContext(this);
var card = this.options.cardCreator(v); var card = this.options.cardCreator(v);
BI.Widget.popContext();
this.cardMap[v] = card; this.cardMap[v] = card;
this.layout.addCardByName(v, card); this.layout.addCardByName(v, card);
this.afterCardCreated(v); this.afterCardCreated(v);

2
src/base/combination/tab.js

@ -72,7 +72,9 @@ BI.Tab = BI.inherit(BI.Widget, {
_assertCard: function (v) { _assertCard: function (v) {
if (!this.layout.isCardExisted(v)) { if (!this.layout.isCardExisted(v)) {
BI.Widget.pushContext(this);
var card = this.options.cardCreator(v); var card = this.options.cardCreator(v);
BI.Widget.popContext();
this.cardMap[v] = card; this.cardMap[v] = card;
this.layout.addCardByName(v, card); this.layout.addCardByName(v, card);
} }

20
src/base/context.js

@ -15,31 +15,33 @@ BI.Context = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.context = BI.createWidget(o.items[0] || o.el, { if (o.context) {
this.context = BI.useContext(o.context);
}
this.widget = BI.createWidget((o.items[0] || o.el)(this.context), {
element: this, element: this,
}); });
this.context.on(BI.Controller.EVENT_CHANGE, function () { this.widget.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
}, },
created: function () { __initWatch: function () {
BI.Context.superclass.__initWatch.call(this);
var o = this.options; var o = this.options;
if (o.context) { BI.watch(this.context, o.context, o.watch);
BI.watch(o.context, o.watch);
}
}, },
setValue: function (v) { setValue: function (v) {
this.context.setValue(v); this.widget.setValue(v);
}, },
getValue: function () { getValue: function () {
return this.context.getValue(); return this.widget.getValue();
}, },
populate: function () { populate: function () {
this.context.populate.apply(this, arguments); this.widget.populate.apply(this, arguments);
}, },
}); });
BI.shortcut("bi.context", BI.Context); BI.shortcut("bi.context", BI.Context);

19
src/base/grid/grid.js

@ -185,20 +185,11 @@ BI.GridView = BI.inherit(BI.Widget, {
var index = this.renderedKeys[key] && this.renderedKeys[key][2]; var index = this.renderedKeys[key] && this.renderedKeys[key][2];
var child; var child;
if (index >= 0) { if (index >= 0) {
// if (columnDatum.size !== this.renderedCells[index]._width) {
// this.renderedCells[index]._width = columnDatum.size;
this.renderedCells[index].el.setWidth(columnDatum.size); this.renderedCells[index].el.setWidth(columnDatum.size);
// }
// if (rowDatum.size !== this.renderedCells[index]._height) {
// this.renderedCells[index]._height = rowDatum.size;
this.renderedCells[index].el.setHeight(rowDatum.size); this.renderedCells[index].el.setHeight(rowDatum.size);
// } // 这里只使用px
// if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) { this.renderedCells[index].el.element.css("left", columnDatum.offset + horizontalOffsetAdjustment + "px");
this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); this.renderedCells[index].el.element.css("top", rowDatum.offset + verticalOffsetAdjustment + "px");
// }
// if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) / BI.pixRatio + BI.pixUnit);
// }
child = this.renderedCells[index].el; child = this.renderedCells[index].el;
renderedCells.push(this.renderedCells[index]); renderedCells.push(this.renderedCells[index]);
} else { } else {
@ -216,8 +207,8 @@ BI.GridView = BI.inherit(BI.Widget, {
}), this); }), this);
renderedCells.push({ renderedCells.push({
el: child, el: child,
left: columnDatum.offset + horizontalOffsetAdjustment, left: columnDatum.offset + horizontalOffsetAdjustment + "px",
top: rowDatum.offset + verticalOffsetAdjustment, top: rowDatum.offset + verticalOffsetAdjustment + "px",
_left: columnDatum.offset + horizontalOffsetAdjustment, _left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment, _top: rowDatum.offset + verticalOffsetAdjustment,
// _width: columnDatum.size, // _width: columnDatum.size,

16
src/base/layer/layer.popup.js

@ -60,8 +60,8 @@ BI.PopupView = BI.inherit(BI.Widget, {
} }
this.element.css({ this.element.css({
"z-index": BI.zIndex_popup, "z-index": BI.zIndex_popup,
"min-width": BI.isNumeric(o.minWidth) ? (o.minWidth / BI.pixRatio + BI.pixUnit) : o.minWidth, "min-width": BI.pixFormat(o.minWidth),
"max-width": BI.isNumeric(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth, "max-width": BI.pixFormat(o.maxWidth),
}).bind({ click: fn }); }).bind({ click: fn });
this.element.bind("mousewheel", fn); this.element.bind("mousewheel", fn);
@ -135,11 +135,11 @@ BI.PopupView = BI.inherit(BI.Widget, {
var o = this.options; var o = this.options;
this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value }); this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value });
this.button_group.element.css({ this.button_group.element.css({
"min-height": BI.isNumeric(o.minHeight) ? (o.minHeight / BI.pixRatio + BI.pixUnit) : o.minHeight, "min-height": BI.pixFormat(o.minHeight),
"padding-top": o.innerVgap / BI.pixRatio + BI.pixUnit, "padding-top": BI.pixFormat(o.innerVgap),
"padding-bottom": o.innerVgap / BI.pixRatio + BI.pixUnit, "padding-bottom": BI.pixFormat(o.innerVgap),
"padding-left": o.innerHgap / BI.pixRatio + BI.pixUnit, "padding-left": BI.pixFormat(o.innerHgap),
"padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit, "padding-right": BI.pixFormat(o.innerHgap),
}); });
return this.button_group; return this.button_group;
@ -411,7 +411,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0); toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0);
var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap; var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap;
this.view.resetHeight ? this.view.resetHeight(resetHeight) : this.view.resetHeight ? this.view.resetHeight(resetHeight) :
this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit }); this.view.element.css({ "max-height": BI.pixFormat(resetHeight) });
}, },
setValue: function (selectedValues) { setValue: function (selectedValues) {

3
src/base/list/listview.js

@ -131,7 +131,8 @@ BI.ListView = BI.inherit(BI.Widget, {
this._populate(items); this._populate(items);
}, },
destroyed: function () { beforeDestroy: function () {
BI.ResizeDetector.removeResizeListener(this);
this.restore(); this.restore();
}, },
}); });

9
src/base/list/virtualgrouplist.js

@ -119,7 +119,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
var end = this.tree.leastUpperBound(minContentHeightTo); var end = this.tree.leastUpperBound(minContentHeightTo);
var items = []; var items = [];
var topHeight = this.tree.sumTo(Math.max(-1, start - 1)); var topHeight = this.tree.sumTo(Math.max(-1, start - 1));
this.topBlank.setHeight(topHeight); this.topBlank.setHeight(topHeight + "px");
if (this._isAutoHeight()) { if (this._isAutoHeight()) {
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) { for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
var index = i * o.blockSize; var index = i * o.blockSize;
@ -127,7 +127,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
items.push(o.items[j]); items.push(o.items[j]);
} }
} }
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex))); this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)) + "px");
this.container.populate(items.map(function (item, i) { this.container.populate(items.map(function (item, i) {
return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i); return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i);
})); }));
@ -183,6 +183,11 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
this._populate(items); this._populate(items);
}, },
beforeDestroy: function () {
BI.ResizeDetector.removeResizeListener(this);
this.restore();
}
}); });
BI.shortcut("bi.virtual_group_list", BI.VirtualGroupList); BI.shortcut("bi.virtual_group_list", BI.VirtualGroupList);

12
src/base/list/virtuallist.js

@ -148,8 +148,8 @@ BI.VirtualList = BI.inherit(BI.Widget, {
} }
this.container.element.prepend(firstFragment); this.container.element.prepend(firstFragment);
this.container.element.append(lastFragment); this.container.element.append(lastFragment);
this.topBlank.setHeight(this.tree.sumTo(Math.max(-1, start - 1))); this.topBlank.setHeight(this.tree.sumTo(Math.max(-1, start - 1)) + "px");
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex))); this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)) + "px");
BI.each(needMount, function (i, child) { BI.each(needMount, function (i, child) {
child && child._mount(); child && child._mount();
}); });
@ -203,10 +203,10 @@ BI.VirtualList = BI.inherit(BI.Widget, {
this._populate(items); this._populate(items);
}, },
destroyed: function () { beforeDestroy: function () {
this.cache = {}; BI.ResizeDetector.removeResizeListener(this);
this.renderedIndex = -1; this.restore();
}, }
}); });
BI.shortcut("bi.virtual_list", BI.VirtualList); BI.shortcut("bi.virtual_list", BI.VirtualList);

19
src/base/single/0.single.js

@ -67,6 +67,10 @@ BI.Single = BI.inherit(BI.Widget, {
self.setValue(newValue); self.setValue(newValue);
}) : o.value; }) : o.value;
BI.Single.superclass._init.apply(this, arguments); BI.Single.superclass._init.apply(this, arguments);
},
_mounted: function () {
var o = this.options;
if (o.enableHover || BI.isKey(o.title) || BI.isKey(o.warningTitle) if (o.enableHover || BI.isKey(o.title) || BI.isKey(o.warningTitle)
|| BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) { || BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) {
this.enableHover({ this.enableHover({
@ -91,7 +95,7 @@ BI.Single = BI.inherit(BI.Widget, {
opt || (opt = {}); opt || (opt = {});
var self = this; var self = this;
if (!this._hoverBinded) { if (!this._hoverBinded) {
this.element.on("mouseenter.title" + this.getName(), function (e) { this.element.unbind("mouseenter.title").on("mouseenter.title", function (e) {
self._e = e; self._e = e;
if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) { if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) {
delayingTooltips = self.getName(); delayingTooltips = self.getName();
@ -109,7 +113,7 @@ BI.Single = BI.inherit(BI.Widget, {
}, 500); }, 500);
} }
}); });
this.element.on("mousemove.title" + this.getName(), function (e) { this.element.unbind("mousemove.title").on("mousemove.title", function (e) {
self._e = e; self._e = e;
if (BI.isNotNull(self.showTimeout)) { if (BI.isNotNull(self.showTimeout)) {
clearTimeout(self.showTimeout); clearTimeout(self.showTimeout);
@ -138,7 +142,7 @@ BI.Single = BI.inherit(BI.Widget, {
} }
}, 500); }, 500);
}); });
this.element.on("mouseleave.title" + this.getName(), function (e) { this.element.unbind("mouseleave.title").on("mouseleave.title", function (e) {
self._e = null; self._e = null;
self._clearTimeOut(); self._clearTimeOut();
self._hideTooltip(); self._hideTooltip();
@ -151,9 +155,9 @@ BI.Single = BI.inherit(BI.Widget, {
// 取消hover事件 // 取消hover事件
this._clearTimeOut(); this._clearTimeOut();
this._hideTooltip(); this._hideTooltip();
this.element.unbind("mouseenter.title" + this.getName()) this.element.unbind("mouseenter.title")
.unbind("mousemove.title" + this.getName()) .unbind("mousemove.title")
.unbind("mouseleave.title" + this.getName()); .unbind("mouseleave.title");
this._hoverBinded = false; this._hoverBinded = false;
}, },
@ -217,8 +221,7 @@ BI.Single = BI.inherit(BI.Widget, {
return this.options.value; return this.options.value;
}, },
__d: function () { _destroyed: function () {
BI.Single.superclass.__d.call(this);
if (BI.isNotNull(this.showTimeout)) { if (BI.isNotNull(this.showTimeout)) {
clearTimeout(this.showTimeout); clearTimeout(this.showTimeout);
this.showTimeout = null; this.showTimeout = null;

14
src/base/single/1.text.js

@ -26,32 +26,32 @@
var self = this, o = this.options; var self = this, o = this.options;
if (o.hgap + o.lgap > 0) { if (o.hgap + o.lgap > 0) {
this.element.css({ this.element.css({
"padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit, "padding-left": BI.pixFormat(o.hgap + o.lgap),
}); });
} }
if (o.hgap + o.rgap > 0) { if (o.hgap + o.rgap > 0) {
this.element.css({ this.element.css({
"padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit, "padding-right": BI.pixFormat(o.hgap + o.rgap),
}); });
} }
if (o.vgap + o.tgap > 0) { if (o.vgap + o.tgap > 0) {
this.element.css({ this.element.css({
"padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit, "padding-top": BI.pixFormat(o.vgap + o.tgap),
}); });
} }
if (o.vgap + o.bgap > 0) { if (o.vgap + o.bgap > 0) {
this.element.css({ this.element.css({
"padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit, "padding-bottom": BI.pixFormat(o.vgap + o.bgap),
}); });
} }
if (BI.isWidthOrHeight(o.height)) { if (BI.isWidthOrHeight(o.height)) {
this.element.css({ lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height }); this.element.css({ lineHeight: BI.pixFormat(o.height) });
} }
if (BI.isWidthOrHeight(o.lineHeight)) { if (BI.isWidthOrHeight(o.lineHeight)) {
this.element.css({ lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight }); this.element.css({ lineHeight: BI.pixFormat(o.lineHeight) });
} }
if (BI.isWidthOrHeight(o.maxWidth)) { if (BI.isWidthOrHeight(o.maxWidth)) {
this.element.css({ maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth }); this.element.css({ maxWidth: BI.pixFormat(o.maxWidth) });
} }
this.element.css({ this.element.css({
textAlign: o.textAlign, textAlign: o.textAlign,

2
src/base/single/button/buttons/button.icon.js

@ -31,7 +31,7 @@ BI.IconButton = BI.inherit(BI.BasicButton, {
height: o.iconHeight, height: o.iconHeight,
}); });
if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) { if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) {
this.element.css("lineHeight", o.height / BI.pixRatio + BI.pixUnit); this.element.css("lineHeight", BI.pixFormat(o.height));
BI.createWidget({ BI.createWidget({
type: "bi.default", type: "bi.default",
element: this, element: this,

18
src/base/single/button/buttons/button.js

@ -73,13 +73,13 @@
// 由于button默认情况下有个边框,所以要主动算行高 // 由于button默认情况下有个边框,所以要主动算行高
var lineHeight, textHeight = o.textHeight; var lineHeight, textHeight = o.textHeight;
var hasBorder = false
if (BI.isNumber(o.height)) { if (BI.isNumber(o.height)) {
if (!isVertical(o.iconPosition)) { if (!isVertical(o.iconPosition)) {
if (o.clear || o.block || o.light) { if (!(o.clear && o.block && o.light)) {
lineHeight = o.height; hasBorder = true;
} else {
lineHeight = o.height - 2;
} }
lineHeight = o.height;
} else { } else {
lineHeight = textHeight; lineHeight = textHeight;
} }
@ -98,8 +98,8 @@
type: "bi.icon_label", type: "bi.icon_label",
cls: o.loading ? loadingCls : (o.iconCls || o.icon), cls: o.loading ? loadingCls : (o.iconCls || o.icon),
width: this._const.iconWidth, width: this._const.iconWidth,
height: lineHeight, height: BI.toPix(lineHeight, hasBorder ? 2 : 0),
lineHeight: lineHeight, lineHeight: BI.toPix(lineHeight, hasBorder ? 2 : 0),
// 不设置,自定义按钮无法居中 // 不设置,自定义按钮无法居中
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
@ -120,8 +120,8 @@
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
textAlign: o.textAlign, textAlign: o.textAlign,
textWidth: textWidth, textWidth: textWidth,
textHeight: textHeight, textHeight: BI.toPix(textHeight, hasBorder ? 2 : 0),
height: lineHeight, height: BI.toPix(lineHeight, hasBorder ? 2 : 0),
value: o.value, value: o.value,
title: null, title: null,
}); });
@ -163,7 +163,7 @@
}); });
if (o.minWidth > 0) { if (o.minWidth > 0) {
this.element.css({ "min-width": o.minWidth / BI.pixRatio + BI.pixUnit }); this.element.css({ "min-width": BI.pixFormat(o.minWidth) });
} }
}, },

1
src/base/single/button/buttons/button.text.js

@ -42,7 +42,6 @@ BI.TextButton = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
title: null,
}); });
}, },

1
src/base/single/button/listitem/blankiconicontextitem.js

@ -62,7 +62,6 @@ BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}], }],
}; };

1
src/base/single/button/listitem/blankicontexticonitem.js

@ -56,7 +56,6 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}, { }, {
type: "bi.icon_label", type: "bi.icon_label",

1
src/base/single/button/listitem/blankicontextitem.js

@ -55,7 +55,6 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}], }],
}; };

1
src/base/single/button/listitem/icontexticonitem.js

@ -52,7 +52,6 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}, { }, {
type: "bi.icon_label", type: "bi.icon_label",

1
src/base/single/button/listitem/icontextitem.js

@ -53,7 +53,6 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}], }],
}; };

1
src/base/single/button/listitem/texticonitem.js

@ -46,7 +46,6 @@ BI.TextIconItem = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}, { }, {
type: "bi.icon_label", type: "bi.icon_label",

1
src/base/single/button/listitem/textitem.js

@ -39,7 +39,6 @@ BI.TextItem = BI.inherit(BI.BasicButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
py: o.py, py: o.py,
title: null,
}); });
}, },

1
src/base/single/button/node/icontexticonnode.js

@ -50,7 +50,6 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}, { }, {
type: "bi.icon_label", type: "bi.icon_label",

1
src/base/single/button/node/icontextnode.js

@ -50,7 +50,6 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}], }],
}; };

1
src/base/single/button/node/texticonnode.js

@ -42,7 +42,6 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height, height: o.height,
title: null,
}, },
}, { }, {
type: "bi.icon_label", type: "bi.icon_label",

1
src/base/single/button/node/textnode.js

@ -38,7 +38,6 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
py: o.py, py: o.py,
title: null,
}); });
}, },

5
src/base/single/editor/editor.js

@ -344,6 +344,11 @@ BI.Editor = BI.inherit(BI.Single, {
return this.editor.isValid(); return this.editor.isValid();
}, },
setValid: function (b) {
this.editor.setValid(b);
this._checkError();
},
destroyed: function () { destroyed: function () {
BI.Bubbles.remove(this.getName()); BI.Bubbles.remove(this.getName());
}, },

15
src/base/single/html/html.js

@ -25,33 +25,36 @@ BI.Html = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
if (o.hgap + o.lgap > 0) { if (o.hgap + o.lgap > 0) {
this.element.css({ this.element.css({
"padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit, "padding-left": BI.pixFormat(o.hgap + o.lgap),
}); });
} }
if (o.hgap + o.rgap > 0) { if (o.hgap + o.rgap > 0) {
this.element.css({ this.element.css({
"padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit, "padding-right": BI.pixFormat(o.hgap + o.rgap),
}); });
} }
if (o.vgap + o.tgap > 0) { if (o.vgap + o.tgap > 0) {
this.element.css({ this.element.css({
"padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit, "padding-top": BI.pixFormat(o.vgap + o.tgap),
}); });
} }
if (o.vgap + o.bgap > 0) { if (o.vgap + o.bgap > 0) {
this.element.css({ this.element.css({
"padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit, "padding-bottom": BI.pixFormat(o.vgap + o.bgap),
}); });
} }
if (BI.isNumber(o.height)) { if (BI.isNumber(o.height)) {
this.element.css({ lineHeight: o.height / BI.pixRatio + BI.pixUnit }); this.element.css({ lineHeight: BI.pixFormat(o.height) });
} }
if (BI.isNumber(o.lineHeight)) { if (BI.isNumber(o.lineHeight)) {
this.element.css({ lineHeight: o.lineHeight / BI.pixRatio + BI.pixUnit }); this.element.css({ lineHeight: BI.pixFormat(o.lineHeight) });
} }
if (BI.isWidthOrHeight(o.maxWidth)) { if (BI.isWidthOrHeight(o.maxWidth)) {
this.element.css({ maxWidth: o.maxWidth }); this.element.css({ maxWidth: o.maxWidth });
} }
if (BI.isNumber(o.maxWidth)) {
this.element.css({ maxWidth: BI.pixFormat(o.maxWidth) })
}
this.element.css({ this.element.css({
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,

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

@ -109,7 +109,7 @@
} }
if (BI.isNumber(o.height) && o.height > 0) { // 1.4 if (BI.isNumber(o.height) && o.height > 0) { // 1.4
this.element.css({ this.element.css({
"line-height": o.height / BI.pixRatio + BI.pixUnit, "line-height": BI.pixFormat(o.height),
}); });
json.textAlign = o.textAlign; json.textAlign = o.textAlign;
delete json.maxWidth; delete json.maxWidth;
@ -183,7 +183,7 @@
} }
if (BI.isNumber(o.height) && o.height > 0) { // 1.8 if (BI.isNumber(o.height) && o.height > 0) { // 1.8
this.element.css({ this.element.css({
"line-height": o.height / BI.pixRatio + BI.pixUnit, "line-height": BI.pixFormat(o.height),
}); });
json.textAlign = o.textAlign; json.textAlign = o.textAlign;
delete json.maxWidth; delete json.maxWidth;
@ -263,7 +263,7 @@
if (BI.isNumber(o.height) && o.height > 0) { // 2.3 if (BI.isNumber(o.height) && o.height > 0) { // 2.3
if (o.whiteSpace !== "normal") { if (o.whiteSpace !== "normal") {
this.element.css({ this.element.css({
"line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit, "line-height": BI.pixFormat(o.height - (o.vgap * 2)),
}); });
} }
delete json.maxWidth; delete json.maxWidth;
@ -325,7 +325,7 @@
if (BI.isNumber(o.height) && o.height > 0) { if (BI.isNumber(o.height) && o.height > 0) {
if (o.whiteSpace !== "normal") { if (o.whiteSpace !== "normal") {
this.element.css({ this.element.css({
"line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit, "line-height": BI.pixFormat(o.height - (o.vgap * 2)),
}); });
} }
delete json.maxWidth; delete json.maxWidth;

2
src/base/single/label/icon.label.js

@ -29,7 +29,7 @@ BI.IconLabel = BI.inherit(BI.Single, {
height: o.iconHeight, height: o.iconHeight,
}); });
if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) { if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) {
this.element.css("lineHeight", (o.lineHeight || o.height) / BI.pixRatio + BI.pixUnit); this.element.css("lineHeight", BI.pixFormat(o.lineHeight || o.height));
BI.createWidget({ BI.createWidget({
type: "bi.default", type: "bi.default",
element: this, element: this,

4
src/base/single/tip/tip.toast.js

@ -30,8 +30,8 @@ BI.Toast = BI.inherit(BI.Tip, {
render: function () { render: function () {
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.element.css({ this.element.css({
minWidth: (o.closable ? c.closableMinWidth : c.minWidth) / BI.pixRatio + BI.pixUnit, minWidth: BI.pixFormat(o.closable ? c.closableMinWidth : c.minWidth),
maxWidth: (o.closable ? c.closableMaxWidth : c.maxWidth) / BI.pixRatio + BI.pixUnit, maxWidth: BI.pixFormat(o.closable ? c.closableMaxWidth : c.maxWidth),
}); });
this.element.addClass("toast-" + o.level); this.element.addClass("toast-" + o.level);
function fn(e) { function fn(e) {

2
src/base/single/tip/tip.tooltip.js

@ -73,7 +73,7 @@ BI.Tooltip = BI.inherit(BI.Tip, {
}, },
setWidth: function (width) { setWidth: function (width) {
this.element.width(width - 2 * this._const.hgap); this.element.width(BI.pixFormat(width - 2 * this._const.hgap));
}, },
setText: function (text) { setText: function (text) {

6
src/case/button/node/siwtcher.tree.node.js

@ -29,13 +29,13 @@ BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type1", "tree-expand-icon-type1"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type1", "tree-expand-icon-type1"];
} else if (options.layer === 0 && options.isFirstNode) { } else if (options.layer === 0 && options.isFirstNode) {
// 第一层,并且是第一个节点 // 第一层,并且是第一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type2", "tree-solid-expand-icon-type2"] : ["tree-collapse-icon-type2", "tree-expand-icon-type2"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type2", "tree-expand-icon-type2"];
} else if (options.isLastNode) { } else if (options.isLastNode) {
// 最后一个节点 // 最后一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type4", "tree-solid-expand-icon-type4"] : ["tree-collapse-icon-type4", "tree-expand-icon-type4"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"];
} else { } else {
// 其他情况 // 其他情况
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type3", "tree-solid-expand-icon-type3"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type4", "tree-expand-icon-type4"];
} }
}, },

6
src/case/button/treeitem/treeitem.js

@ -57,11 +57,11 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, {
if (options.layer === 0 && options.isFirstNode && options.isLastNode) { if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
return ""; return "";
} else if (options.layer === 0 && options.isFirstNode) { } else if (options.layer === 0 && options.isFirstNode) {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "first-solid-line-conn-background" : "first-line-conn-background"; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-first-solid-line-conn-background" : "first-line-conn-background";
} else if (options.isLastNode) { } else if (options.isLastNode) {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "last-solid-line-conn-background" : "last-line-conn-background"; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-last-solid-line-conn-background" : "last-line-conn-background";
} else { } else {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "mid-solid-line-conn-background" : "mid-line-conn-background"; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-mid-solid-line-conn-background" : "mid-line-conn-background";
} }
}, },

2
src/case/calendar/calendar.date.item.js

@ -4,6 +4,7 @@
BI.CalendarDateItem = BI.inherit(BI.BasicButton, { BI.CalendarDateItem = BI.inherit(BI.BasicButton, {
props: function() { props: function() {
return { return {
baseCls: "bi-calendar-date-item",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8,
} }
}, },
@ -17,7 +18,6 @@ BI.CalendarDateItem = BI.inherit(BI.BasicButton, {
type: "bi.text_item", type: "bi.text_item",
cls: "bi-border-radius bi-list-item-select", cls: "bi-border-radius bi-list-item-select",
textAlign: "center", textAlign: "center",
whiteSpace: "normal",
text: o.text, text: o.text,
value: o.value, value: o.value,
ref: function () { ref: function () {

4
src/case/calendar/calendar.js

@ -120,7 +120,7 @@ BI.Calendar = BI.inherit(BI.Widget, {
_getWeekLabel: function () { _getWeekLabel: function () {
return BI.map(BI.range(0, 7), function (idx, v) { return BI.map(BI.range(0, 7), function (idx, v) {
return BI.Date._SDN[(v + BI.StartOfWeek) % 7]; return BI.getShortDayName((v + BI.StartOfWeek) % 7);
}); });
}, },
@ -158,8 +158,6 @@ BI.Calendar = BI.inherit(BI.Widget, {
var month = td.lastMonth ? o.month - 1 : (td.nextMonth ? o.month + 1 : o.month); var month = td.lastMonth ? o.month - 1 : (td.nextMonth ? o.month + 1 : o.month);
return BI.extend(td, { return BI.extend(td, {
type: "bi.calendar_date_item", type: "bi.calendar_date_item",
textAlign: "center",
whiteSpace: "normal",
once: false, once: false,
forceSelected: true, forceSelected: true,
value: o.year + "-" + month + "-" + td.text, value: o.year + "-" + month + "-" + td.text,

4
src/case/colorchooser/colorchooser.js

@ -36,8 +36,8 @@ BI.ColorChooser = BI.inherit(BI.Widget, {
self.trigger = _ref; self.trigger = _ref;
}, },
value: o.value, value: o.value,
width: o.el.type ? o.width : o.width - 2, width: o.el.type ? o.width : BI.toPix(o.width, 2),
height: o.el.type ? o.height : o.height - 2 height: o.el.type ? o.height : BI.toPix(o.height, 2)
}, o.el), }, o.el),
popup: () => ({ popup: () => ({
el: BI.extend({ el: BI.extend({

6
src/case/combo/icontextvaluecombo/combo.icontextvalue.js

@ -15,8 +15,6 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
var self = this, o = this.options; var self = this, o = this.options;
BI.isNumeric(o.width) && (o.width -= 2);
BI.isNumeric(o.height) && (o.height -= 2);
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) {
self.setValue(newValue); self.setValue(newValue);
}) : o.value; }) : o.value;
@ -28,7 +26,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
type: "bi.select_icon_text_trigger", type: "bi.select_icon_text_trigger",
cls: "icon-text-value-trigger", cls: "icon-text-value-trigger",
items: o.items, items: o.items,
height: o.height, height: BI.toPix(o.height, 2),
text: o.text, text: o.text,
iconCls: o.iconCls, iconCls: o.iconCls,
value: o.value, value: o.value,
@ -56,6 +54,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
}); });
this.textIconCombo = BI.createWidget({ this.textIconCombo = BI.createWidget({
type: "bi.combo", type: "bi.combo",
height: BI.toPix(o.height, 2),
width: BI.toPix(o.width, 2),
element: this, element: this,
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,

9
src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js

@ -23,16 +23,13 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
self.populate(newValue); self.populate(newValue);
}) : o.items; }) : o.items;
var height = BI.isNumeric(o.height) ? (o.height - (o.simple ? 1 : 2)) : o.height;
var width = BI.isNumeric(o.width) ? (o.width - 2) : o.width;
return { return {
type: "bi.combo", type: "bi.combo",
cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow",
container: o.container, container: o.container,
adjustLength: 2, adjustLength: 2,
height: height, height: BI.toPix(o.height, o.simple ? 1 : 2),
width: width, width: BI.toPix(o.width, 2),
ref: function () { ref: function () {
self.combo = this; self.combo = this;
}, },
@ -44,7 +41,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
self.trigger = this; self.trigger = this;
}, },
items: o.items, items: o.items,
height: height, height: BI.toPix(o.height, o.simple ? 1 : 2),
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
value: o.value, value: o.value,

6
src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js

@ -16,8 +16,6 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
var self = this, o = this.options; var self = this, o = this.options;
BI.isNumeric(o.width) && (o.width -= 2);
BI.isNumeric(o.height) && (o.height -= 2);
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) {
self.setValue(newValue); self.setValue(newValue);
}) : o.value; }) : o.value;
@ -29,7 +27,7 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, {
type: "bi.select_text_trigger", type: "bi.select_text_trigger",
cls: "text-value-trigger", cls: "text-value-trigger",
items: o.items, items: o.items,
height: o.height, height: BI.toPix(o.height, 2),
text: o.text, text: o.text,
value: o.value value: o.value
}); });
@ -52,6 +50,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, {
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,
element: this, element: this,
width: BI.toPix(o.width, 2),
height: BI.toPix(o.height, 2),
adjustLength: 2, adjustLength: 2,
el: this.trigger, el: this.trigger,
popup: { popup: {

6
src/case/combo/textvaluecombo/combo.textvalue.js

@ -22,8 +22,6 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
var self = this, o = this.options; var self = this, o = this.options;
BI.isNumeric(o.width) && (o.width -= (o.simple ? 0 : 2));
BI.isNumeric(o.height) && (o.height -= (o.simple ? 1 : 2));
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) {
self.setValue(newValue); self.setValue(newValue);
}) : o.value; }) : o.value;
@ -57,7 +55,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
ref: ref => this.trigger = ref, ref: ref => this.trigger = ref,
cls: "text-value-trigger", cls: "text-value-trigger",
items: o.items, items: o.items,
height: o.height, height: BI.toPix(o.height, o.simple ? 1 : 2),
text: o.text, text: o.text,
value: o.value, value: o.value,
title, title,
@ -118,6 +116,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
return { return {
type: "bi.combo", type: "bi.combo",
height: BI.toPix(o.height, 2),
width: BI.toPix(o.width, 2),
ref: ref => this.combo = ref, ref: ref => this.combo = ref,
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,

24
src/case/editor/editor.shelter.js

@ -58,17 +58,6 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
height: o.height, height: o.height,
hgap: o.hgap + 2 hgap: o.hgap + 2
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.text.on(BI.Controller.EVENT_CHANGE, function () { this.text.on(BI.Controller.EVENT_CHANGE, function () {
arguments[2] = self; arguments[2] = self;
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -134,10 +123,17 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.ShelterEditor.EVENT_EMPTY, arguments); self.fireEvent(BI.ShelterEditor.EVENT_EMPTY, arguments);
}); });
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.absolute",
scrolly: false,
element: this, element: this,
items: [this.editor] items: [
{
el: this.text,
inset: 0,
}, {
el: this.editor,
inset: 0,
}
]
}); });
this._showHint(); this._showHint();
self._checkText(); self._checkText();

24
src/case/editor/editor.sign.js

@ -68,17 +68,6 @@ BI.SignEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.SignEditor.EVENT_CLICK_LABEL); self.fireEvent(BI.SignEditor.EVENT_CLICK_LABEL);
}); });
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
@ -137,10 +126,17 @@ BI.SignEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.SignEditor.EVENT_EMPTY, arguments); self.fireEvent(BI.SignEditor.EVENT_EMPTY, arguments);
}); });
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.absolute",
scrolly: false,
element: this, element: this,
items: [this.editor] items: [
{
el: this.text,
inset: 0,
}, {
el: this.editor,
inset: 0,
}
]
}); });
this._showHint(); this._showHint();
self._checkText(); self._checkText();

24
src/case/editor/editor.state.js

@ -77,17 +77,6 @@ BI.StateEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.StateEditor.EVENT_CLICK_LABEL); self.fireEvent(BI.StateEditor.EVENT_CLICK_LABEL);
}); });
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
@ -143,10 +132,17 @@ BI.StateEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.StateEditor.EVENT_EMPTY, arguments); self.fireEvent(BI.StateEditor.EVENT_EMPTY, arguments);
}); });
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.absolute",
scrolly: false,
element: this, element: this,
items: [this.editor] items: [
{
el: this.text,
inset: 0,
}, {
el: this.editor,
inset: 0,
}
]
}); });
this._showHint(); this._showHint();
if (BI.isNotNull(o.text)) { if (BI.isNotNull(o.text)) {

4
src/case/layer/panel.js

@ -59,7 +59,7 @@ BI.Panel = BI.inherit(BI.Widget, {
el: { el: {
type: "bi.left_right_vertical_adapt", type: "bi.left_right_vertical_adapt",
cls: "panel-title bi-header-background bi-border-bottom", cls: "panel-title bi-header-background bi-border-bottom",
height: o.titleHeight - 1, height: BI.toPix(o.titleHeight, 1),
items: { items: {
left: [this.text], left: [this.text],
right: [this.button_group] right: [this.button_group]
@ -67,7 +67,7 @@ BI.Panel = BI.inherit(BI.Widget, {
lhgap: 10, lhgap: 10,
rhgap: 10 rhgap: 10
}, },
height: o.titleHeight - 1 height: BI.toPix(o.titleHeight, 1)
}; };
}, },

2
src/case/linearsegment/button.linear.segment.js

@ -15,7 +15,7 @@ BI.LinearSegmentButton = BI.inherit(BI.BasicButton, {
type: "bi.label", type: "bi.label",
text: o.text, text: o.text,
height: o.height, height: o.height,
textHeight: o.height - 2, textHeight: BI.toPix(o.height, 2),
value: o.value, value: o.value,
hgap: o.hgap, hgap: o.hgap,
ref: function () { ref: function () {

2
src/case/list/list.select.js

@ -192,7 +192,7 @@ BI.SelectList = BI.inherit(BI.Widget, {
resetHeight: function (h) { resetHeight: function (h) {
var toolHeight = ( this.toolbar.element.outerHeight() || 25) * ( this.toolbar.isVisible() ? 1 : 0); var toolHeight = ( this.toolbar.element.outerHeight() || 25) * ( this.toolbar.isVisible() ? 1 : 0);
this.list.resetHeight ? this.list.resetHeight(h - toolHeight) : this.list.resetHeight ? this.list.resetHeight(h - toolHeight) :
this.list.element.css({"max-height": (h - toolHeight) / BI.pixRatio + BI.pixUnit}); this.list.element.css({"max-height": BI.pixFormat(h - toolHeight)});
}, },
setNotSelectedValue: function () { setNotSelectedValue: function () {

3
src/case/segment/button.segment.js

@ -20,9 +20,6 @@ BI.SegmentButton = BI.inherit(BI.BasicButton, {
_init: function () { _init: function () {
BI.SegmentButton.superclass._init.apply(this, arguments); BI.SegmentButton.superclass._init.apply(this, arguments);
var opts = this.options, self = this; var opts = this.options, self = this;
// if (BI.isNumber(opts.height) && BI.isNull(opts.lineHeight)) {
// this.element.css({lineHeight : (opts.height - 2) + 'px'});
// }
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
element: this, element: this,

2
src/case/segment/segment.js

@ -22,7 +22,7 @@ BI.Segment = BI.inherit(BI.Widget, {
value: o.value, value: o.value,
items: BI.createItems(o.items, { items: BI.createItems(o.items, {
type: "bi.segment_button", type: "bi.segment_button",
height: o.height - 2, height: BI.toPix(o.height, 2),
whiteSpace: o.whiteSpace whiteSpace: o.whiteSpace
}), }),
layout: [ layout: [

4
src/case/tree/treeexpander/tree.expander.popup.js

@ -25,8 +25,8 @@
}); });
if (o.showLine) { if (o.showLine) {
this.popupView.element.css("margin-left", -offset * (o.layer + 1)); this.popupView.element.css("margin-left", BI.pixFormat(-offset * (o.layer + 1)));
this.element.css("margin-left", offset * (o.layer + 1)); this.element.css("margin-left", BI.pixFormat(offset * (o.layer + 1)));
} }
return { return {

8
src/case/trigger/trigger.editor.js

@ -20,12 +20,11 @@ BI.EditorTrigger = BI.inherit(BI.Trigger, {
}, },
_init: function () { _init: function () {
this.options.height -= 2;
BI.EditorTrigger.superclass._init.apply(this, arguments); BI.EditorTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: BI.toPix(o.height, 2),
value: o.value, value: o.value,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
@ -58,6 +57,7 @@ BI.EditorTrigger = BI.inherit(BI.Trigger, {
BI.createWidget({ BI.createWidget({
element: this, element: this,
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
height: BI.toPix(o.height, 2),
items: [ items: [
{ {
el: this.editor, el: this.editor,
@ -65,9 +65,9 @@ BI.EditorTrigger = BI.inherit(BI.Trigger, {
}, { }, {
el: { el: {
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
width: o.triggerWidth || o.height width: o.triggerWidth || BI.toPix(o.height, 2)
}, },
width: o.triggerWidth || o.height width: ""
} }
] ]
}); });

20
src/case/trigger/trigger.icon.text.js

@ -42,7 +42,7 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, {
BI.createWidget({ BI.createWidget({
element: this, element: this,
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: [BI.isEmptyString(o.iconCls) ? 0 : (o.iconWrapperWidth || o.height), "fill", o.triggerWidth || o.height], columnSize: ["", "fill", ""],
ref: function (_ref) { ref: function (_ref) {
self.wrapper = _ref; self.wrapper = _ref;
}, },
@ -50,7 +50,9 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, {
el: { el: {
type: "bi.icon_change_button", type: "bi.icon_change_button",
cls: "icon-combo-trigger-icon", cls: "icon-combo-trigger-icon",
width: o.triggerWidth || o.height,
iconCls: o.iconCls, iconCls: o.iconCls,
invisible: !o.iconCls,
ref: function (_ref) { ref: function (_ref) {
self.icon = _ref; self.icon = _ref;
}, },
@ -74,21 +76,7 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, {
setIcon: function (iconCls) { setIcon: function (iconCls) {
var o = this.options; var o = this.options;
this.icon.setIcon(iconCls); this.icon.setIcon(iconCls);
var iconItem = this.wrapper.attr("items")[0]; this.icon.setVisible(!!iconCls);
var textItem = this.wrapper.attr("items")[1];
if (BI.isNull(iconCls) || BI.isEmptyString(iconCls)) {
if (iconItem.width !== 0) {
iconItem.width = 0;
textItem.lgap = 5;
this.wrapper.resize();
}
} else {
if (iconItem.width !== (o.iconWrapperWidth || o.height)) {
iconItem.width = (o.iconWrapperWidth || o.height);
textItem.lgap = 0;
this.wrapper.resize();
}
}
}, },
setTextCls: function (cls) { setTextCls: function (cls) {

5
src/case/trigger/trigger.text.js

@ -60,7 +60,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
return ({ return ({
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: ["fill", o.triggerWidth || o.height], columnSize: ["fill", ""],
items: [ items: [
{ {
el: label, el: label,
@ -68,6 +68,8 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
}, { }, {
el: o.allowClear ? { el: o.allowClear ? {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
width: o.triggerWidth || o.height,
height: o.height,
horizontalAlign: "left", horizontalAlign: "left",
scrollable: false, scrollable: false,
items: [ items: [
@ -80,7 +82,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
cls: "close-h-font " + (o.allowClear ? "clear-button" : ""), cls: "close-h-font " + (o.allowClear ? "clear-button" : ""),
stopPropagation: true, stopPropagation: true,
width: o.triggerWidth || o.height, width: o.triggerWidth || o.height,
height: o.height,
invisible: !BI.isNotEmptyString(o.text), invisible: !BI.isNotEmptyString(o.text),
handler: function () { handler: function () {
self.fireEvent(BI.TextTrigger.EVENT_CLEAR); self.fireEvent(BI.TextTrigger.EVENT_CLEAR);

3
src/case/trigger/trigger.text.select.small.js

@ -14,14 +14,13 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, {
}, },
_init: function () { _init: function () {
this.options.height -= 2;
BI.SmallSelectTextTrigger.superclass._init.apply(this, arguments); BI.SmallSelectTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var obj = this._digest(o.value, o.items); var obj = this._digest(o.value, o.items);
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.small_text_trigger", type: "bi.small_text_trigger",
element: this, element: this,
height: o.height, height: BI.toPix(o.height, 2),
text: obj.text, text: obj.text,
cls: obj.cls, cls: obj.cls,
textHgap: o.textHgap, textHgap: o.textHgap,

2
src/case/trigger/trigger.text.small.js

@ -43,7 +43,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
width: "fill" width: "fill"
}, { }, {
el: this.trigerButton, el: this.trigerButton,
width: o.triggerWidth || o.height width: ""
} }
] ]
}); });

4
src/core/2.base.js

@ -389,7 +389,7 @@
} }
for (var i = 0, len = array.length; i < len; i++) { for (var i = 0, len = array.length; i < len; i++) {
if (BI.isArray(array[i])) { if (BI.isArray(array[i])) {
res.push(arguments.callee(array[i], value)); res.push(BI.makeArrayByArray(array[i], value));
} else { } else {
res.push(BI.deepClone(value)); res.push(BI.deepClone(value));
} }
@ -987,7 +987,7 @@
* @param DD * @param DD
* @param minDate '1900-01-01' * @param minDate '1900-01-01'
* @param maxDate '2099-12-31' * @param maxDate '2099-12-31'
* @returns {Array} 若无效返回无效状态 * @returns {Array} 若无效返回无效状态,数组第一位为无效属性,第二位缺省为超下限,1为超上限
*/ */
checkDateVoid: function (YY, MM, DD, minDate, maxDate) { checkDateVoid: function (YY, MM, DD, minDate, maxDate) {
var back = []; var back = [];

33
src/core/3.ob.js

@ -33,7 +33,9 @@
}; };
BI._.extend(OB.prototype, { BI._.extend(OB.prototype, {
props: {}, props: {},
init: null, init: null,
destroyed: null, destroyed: null,
_constructor: function (config) { _constructor: function (config) {
@ -71,6 +73,12 @@
self.on(eventName, lis); self.on(eventName, lis);
return; return;
} }
if (BI._.isArray(lis)) {
BI._.each(lis, function (l) {
self.on(eventName, l);
});
return;
}
(lis.target ? lis.target : self)[lis.once ? "once" : "on"](lis.eventName, BI._.bind(lis.action, self)); (lis.target ? lis.target : self)[lis.once ? "once" : "on"](lis.eventName, BI._.bind(lis.action, self));
}); });
delete this.options.listeners; delete this.options.listeners;
@ -79,23 +87,25 @@
// 获得一个当前对象的引用 // 获得一个当前对象的引用
_initRef: function () { _initRef: function () {
if (this.options.__ref) { var o = this.options;
this.options.__ref.call(this, this); if (o.__ref) {
BI.isFunction(o.__ref) ? o.__ref.call(this, this) : o.__ref.current = this;
} }
if (this.options.ref) { if (o.ref) {
this.options.ref.call(this, this); BI.isFunction(o.ref) ? o.ref.call(this, this) : o.ref.current = this;
} }
}, },
//释放当前对象 //释放当前对象
_purgeRef: function () { _purgeRef: function () {
if (this.options.__ref) { var o = this.options;
this.options.__ref.call(null, null); if (o.__ref) {
this.options.__ref = null; BI.isFunction(o.__ref) ? o.__ref.call(null, null) : o.__ref.current = null;
o.__ref = null;
} }
if (this.options.ref) { if (o.ref) {
this.options.ref.call(null, null); BI.isFunction(o.ref) ? o.ref.call(null, null) : o.ref.current = null;
this.options.ref = null; o.ref = null;
} }
}, },
@ -138,6 +148,7 @@
}; };
this.on(eventName, proxy); this.on(eventName, proxy);
}, },
/** /**
* 解除观察者绑定的指定事件 * 解除观察者绑定的指定事件
* @param {String} eventName 要解除绑定事件的名字 * @param {String} eventName 要解除绑定事件的名字
@ -162,6 +173,7 @@
} }
} }
}, },
/** /**
* 清除观察者的所有事件绑定 * 清除观察者的所有事件绑定
*/ */
@ -169,6 +181,7 @@
/* alex:清空events*/ /* alex:清空events*/
this.events = {}; this.events = {};
}, },
/** /**
* 触发绑定过的事件 * 触发绑定过的事件
* *

61
src/core/4.widget.js

@ -97,6 +97,8 @@
beforeMount: null, beforeMount: null,
mounted: null, mounted: null,
// 不想重写mounted时用
_mounted: null,
shouldUpdate: null, shouldUpdate: null,
@ -109,11 +111,11 @@
beforeDestroy: null, beforeDestroy: null,
destroyed: null, destroyed: null,
// 不想重写destroyed时用
_destroyed: null,
_init: function () { _init: function () {
BI.Widget.superclass._init.apply(this, arguments); BI.Widget.superclass._init.apply(this, arguments);
this._initElementWidth();
this._initElementHeight();
this._initVisual(); this._initVisual();
this._initState(); this._initState();
this._initRender(); this._initRender();
@ -199,6 +201,8 @@
_initCurrent: function () { _initCurrent: function () {
var self = this, o = this.options; var self = this, o = this.options;
this._initElementWidth();
this._initElementHeight();
if (o._baseCls || o.baseCls || o.extraCls) { if (o._baseCls || o.baseCls || o.extraCls) {
this.element.addClass((o._baseCls || "") + " " + (o.baseCls || "") + " " + (o.extraCls || "")); this.element.addClass((o._baseCls || "") + " " + (o.baseCls || "") + " " + (o.extraCls || ""));
} }
@ -285,14 +289,14 @@
_initElementWidth: function () { _initElementWidth: function () {
var o = this.options; var o = this.options;
if (BI.isWidthOrHeight(o.width)) { if (BI.isWidthOrHeight(o.width)) {
this.element.css("width", BI.isNumber(o.width) ? o.width / BI.pixRatio + BI.pixUnit : o.width); this.element.css("width", BI.pixFormat(o.width));
} }
}, },
_initElementHeight: function () { _initElementHeight: function () {
var o = this.options; var o = this.options;
if (BI.isWidthOrHeight(o.height)) { if (BI.isWidthOrHeight(o.height)) {
this.element.css("height", BI.isNumber(o.height) ? o.height / BI.pixRatio + BI.pixUnit : o.height); this.element.css("height", BI.pixFormat(o.height));
} }
}, },
@ -304,7 +308,7 @@
}) : o.invisible; }) : o.invisible;
if (invisible) { if (invisible) {
// 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none"); this.__setElementVisible(false);
} }
} }
}, },
@ -429,6 +433,7 @@
child.__afterMount && child.__afterMount(lifeHook, predicate); child.__afterMount && child.__afterMount(lifeHook, predicate);
} }
if (lifeHook !== false && !this.__async) { if (lifeHook !== false && !this.__async) {
callLifeHook(this, "_mounted");
callLifeHook(this, "mounted"); callLifeHook(this, "mounted");
this.fireEvent(BI.Events.MOUNT); this.fireEvent(BI.Events.MOUNT);
} }
@ -508,13 +513,17 @@
} }
}, },
__setElementVisible: function (visible) {
this.element.css("display", visible ? "" : "none");
},
_innerSetVisible: function (visible) { _innerSetVisible: function (visible) {
var self = this, o = this.options; var self = this, o = this.options;
var lastVisible = !o.invisible; var lastVisible = !o.invisible;
this._setVisible(visible); this._setVisible(visible);
if (visible === true) { if (visible === true) {
// 用this.element.show()会把display属性改成block // 用this.element.show()会把display属性改成block
this.element.css("display", ""); this.__setElementVisible(true);
this._mount(); this._mount();
if (o.animation && !lastVisible) { if (o.animation && !lastVisible) {
this.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active").addClass(o.animation + "-enter"); this.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active").addClass(o.animation + "-enter");
@ -547,10 +556,10 @@
} }
this._animationDuring = setTimeout(function () { this._animationDuring = setTimeout(function () {
self.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active"); self.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active");
self.element.css("display", "none"); self.__setElementVisible(false);
}, o.animationDuring); }, o.animationDuring);
} else { } else {
this.element.css("display", "none"); this.__setElementVisible(false);
} }
} }
}, },
@ -736,6 +745,7 @@
this.__d(); this.__d();
this._parent = null; this._parent = null;
this._isMounted = false; this._isMounted = false;
callLifeHook(this, "_destroyed");
callLifeHook(this, "destroyed"); callLifeHook(this, "destroyed");
this.destroyed = null; this.destroyed = null;
this._isDestroyed = true; this._isDestroyed = true;
@ -892,18 +902,39 @@
}; };
BI.useContext = function (inject) { BI.useContext = function (inject) {
if (BI.Model.target) { // 通过组件找最近的store
var p = BI.Model.target; var vm = BI.Widget.findStore(BI.Widget.current || BI.Widget.context);
if (vm) {
if (inject) { if (inject) {
while (p) { if (vm.$$computed && inject in vm.$$computed) {
if (p.$$context && inject in p.$$context) { return vm;
return p;
} }
p = p._parent; if (vm.$$state && inject in vm.$$state) {
return vm;
} }
if (vm.$$model && inject in vm.$$model) {
return vm;
} }
while (vm) {
if (vm.$$context && inject in vm.$$context) {
return vm;
}
vm = vm._parent;
}
return null;
}
}
return vm;
};
BI.execWithContext = function (_context, fn) {
BI.Widget.pushContext(_context);
try {
fn();
} catch (e) {
// nothing
} }
return BI.Model.target; BI.Widget.popContext();
}; };
BI.watch = function (vm, watch, handler) { BI.watch = function (vm, watch, handler) {

8
src/core/5.inject.js

@ -471,12 +471,20 @@
var wType = (w.type && w.type.xtype) || w.type; var wType = (w.type && w.type.xtype) || w.type;
if (wType === elType) { if (wType === elType) {
if (BI.Plugin.hasObject(elType)) { if (BI.Plugin.hasObject(elType)) {
if (!w.listeners || BI.isArray(w.listeners)) {
w.listeners = (w.listeners || []).concat([{ w.listeners = (w.listeners || []).concat([{
eventName: BI.Events.MOUNT, eventName: BI.Events.MOUNT,
action: function () { action: function () {
BI.Plugin.getObject(elType, this); BI.Plugin.getObject(elType, this);
} }
}]); }]);
} else {
w.listeners[BI.Events.MOUNT] = [
function () {
BI.Plugin.getObject(elType, this);
}
].concat(w.listeners[BI.Events.MOUNT] || []);
}
} }
return createWidget(w, context, lazy); return createWidget(w, context, lazy);
} }

66
src/core/constant/date.i18n.js

@ -1,66 +0,0 @@
BI.prepares.push(function () {
BI.Date = BI.Date || {};
// 牵扯到国际化这些常量在页面加载后再生效
// full day names
BI.Date._DN = [BI.i18nText("BI-Basic_Sunday"),
BI.i18nText("BI-Basic_Monday"),
BI.i18nText("BI-Basic_Tuesday"),
BI.i18nText("BI-Basic_Wednesday"),
BI.i18nText("BI-Basic_Thursday"),
BI.i18nText("BI-Basic_Friday"),
BI.i18nText("BI-Basic_Saturday"),
BI.i18nText("BI-Basic_Sunday")];
// short day names
BI.Date._SDN = [BI.i18nText("BI-Basic_Simple_Sunday"),
BI.i18nText("BI-Basic_Simple_Monday"),
BI.i18nText("BI-Basic_Simple_Tuesday"),
BI.i18nText("BI-Basic_Simple_Wednesday"),
BI.i18nText("BI-Basic_Simple_Thursday"),
BI.i18nText("BI-Basic_Simple_Friday"),
BI.i18nText("BI-Basic_Simple_Saturday"),
BI.i18nText("BI-Basic_Simple_Sunday")];
// Monday first, etc.
BI.Date._FD = 1;
// full month namesdat
BI.Date._MN = [
BI.i18nText("BI-Basic_January"),
BI.i18nText("BI-Basic_February"),
BI.i18nText("BI-Basic_March"),
BI.i18nText("BI-Basic_April"),
BI.i18nText("BI-Basic_May"),
BI.i18nText("BI-Basic_June"),
BI.i18nText("BI-Basic_July"),
BI.i18nText("BI-Basic_August"),
BI.i18nText("BI-Basic_September"),
BI.i18nText("BI-Basic_October"),
BI.i18nText("BI-Basic_November"),
BI.i18nText("BI-Basic_December")];
// short month names
BI.Date._SMN = [0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11];
BI.Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_2"),
BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */
BI.Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// 实际上无论周几作为一周的第一天,周初周末都是在-6-0间做偏移,用一个数组就可以
BI.Date._OFFSET = [0, -1, -2, -3, -4, -5, -6];
});

26
src/core/constant/var.js

@ -15,6 +15,32 @@ BI._.extend(BI, {
emptyStr: "", emptyStr: "",
pixUnit: "px", pixUnit: "px",
pixRatio: 1, pixRatio: 1,
// 一定返回最终的单位
pixFormat: function (pix, border) {
if (!BI.isNumber(pix)) {
return pix;
}
if (BI.pixUnit === "px") {
return (pix / BI.pixRatio - (border || 0)) + BI.pixUnit;
}
var length = pix / BI.pixRatio + BI.pixUnit;
if (border > 0) {
return `calc(${length} - ${border + "px"})`;
}
return length;
},
toPix: function (pix, border) {
if (!BI.isNumber(pix)) {
return pix;
}
if (BI.pixUnit === "px") {
return pix - (border || 0) * BI.pixRatio;
}
if (border > 0) {
return `calc(${pix / BI.pixRatio + BI.pixUnit} - ${border + "px"})`;
}
return pix;
},
emptyFn: function () { emptyFn: function () {
}, },
empty: null, empty: null,

5
src/core/controller/controller.popover.js

@ -59,8 +59,9 @@ BI.PopoverController = BI.inherit(BI.Controller, {
top = 0; top = 0;
} }
popover.element.css({ popover.element.css({
left: left / BI.pixRatio + BI.pixUnit, // 这里直接用px就可以
top: top / BI.pixRatio + BI.pixUnit left: left + "px",
top: top + "px"
}); });
} }
return this; return this;

5
src/core/controller/controller.tooltips.js

@ -71,8 +71,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
!opt.belowMouse && (y = Math.max(y, top)); !opt.belowMouse && (y = Math.max(y, top));
} }
tooltip.element.css({ tooltip.element.css({
left: x < 0 ? 0 : x / BI.pixRatio + BI.pixUnit, // 这里直接用px就可以
top: y < 0 ? 0 : y / BI.pixRatio + BI.pixUnit left: x < 0 ? 0 : x + "px",
top: y < 0 ? 0 : y + "px"
}); });
tooltip.element.hover(function () { tooltip.element.hover(function () {
self.remove(name); self.remove(name);

2
src/core/func/alias.js

@ -804,7 +804,7 @@
var str = jfmt.str, len = jfmt.len, ch = jfmt["char"]; var str = jfmt.str, len = jfmt.len, ch = jfmt["char"];
switch (ch) { switch (ch) {
case "E": // 星期 case "E": // 星期
str = BI.Date._DN[date.getDay()]; str = BI.getFullDayName(date.getDay());
break; break;
case "y": // 年 case "y": // 年
if (len <= 3) { if (len <= 3) {

73
src/core/func/date.js

@ -6,6 +6,29 @@ BI.Date.HOUR = 60 * BI.Date.MINUTE;
BI.Date.DAY = 24 * BI.Date.HOUR; BI.Date.DAY = 24 * BI.Date.HOUR;
BI.Date.WEEK = 7 * BI.Date.DAY; BI.Date.WEEK = 7 * BI.Date.DAY;
// Monday first, etc.
BI.Date._FD = 1;
// short month names
BI.Date._SMN = [0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11];
/** Adds the number of days array to the Date object. */
BI.Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// 实际上无论周几作为一周的第一天,周初周末都是在-6-0间做偏移,用一个数组就可以
BI.Date._OFFSET = [0, -1, -2, -3, -4, -5, -6];
BI._.extend(BI, { BI._.extend(BI, {
/** /**
* 获取时区 * 获取时区
@ -136,6 +159,50 @@ BI._.extend(BI, {
return BI.getOffsetDate(date, BI.Date._OFFSET[w < startOfWeek ? (7 + w - startOfWeek) : (w - startOfWeek)] + 6); return BI.getOffsetDate(date, BI.Date._OFFSET[w < startOfWeek ? (7 + w - startOfWeek) : (w - startOfWeek)] + 6);
}, },
getFullDayName: function (index) {
return [BI.i18nText("BI-Basic_Sunday"),
BI.i18nText("BI-Basic_Monday"),
BI.i18nText("BI-Basic_Tuesday"),
BI.i18nText("BI-Basic_Wednesday"),
BI.i18nText("BI-Basic_Thursday"),
BI.i18nText("BI-Basic_Friday"),
BI.i18nText("BI-Basic_Saturday"),
BI.i18nText("BI-Basic_Sunday")][index];
},
getShortDayName: function (index) {
return [BI.i18nText("BI-Basic_Simple_Sunday"),
BI.i18nText("BI-Basic_Simple_Monday"),
BI.i18nText("BI-Basic_Simple_Tuesday"),
BI.i18nText("BI-Basic_Simple_Wednesday"),
BI.i18nText("BI-Basic_Simple_Thursday"),
BI.i18nText("BI-Basic_Simple_Friday"),
BI.i18nText("BI-Basic_Simple_Saturday"),
BI.i18nText("BI-Basic_Simple_Sunday")][index];
},
getMonthName: function (index) {
return [BI.i18nText("BI-Basic_January"),
BI.i18nText("BI-Basic_February"),
BI.i18nText("BI-Basic_March"),
BI.i18nText("BI-Basic_April"),
BI.i18nText("BI-Basic_May"),
BI.i18nText("BI-Basic_June"),
BI.i18nText("BI-Basic_July"),
BI.i18nText("BI-Basic_August"),
BI.i18nText("BI-Basic_September"),
BI.i18nText("BI-Basic_October"),
BI.i18nText("BI-Basic_November"),
BI.i18nText("BI-Basic_December")][index]
},
getQuarterName: function (index) {
return ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_2"),
BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")][index];
},
// 格式化打印日期 // 格式化打印日期
print: function (date, str) { print: function (date, str) {
var m = date.getMonth(); var m = date.getMonth();
@ -158,10 +225,10 @@ BI._.extend(BI, {
} }
var min = date.getMinutes(); var min = date.getMinutes();
var sec = date.getSeconds(); var sec = date.getSeconds();
s["%a"] = BI.Date._SDN[w]; // abbreviated weekday name [FIXME: I18N] s["%a"] = BI.getShortDayName(w); // abbreviated weekday name [FIXME: I18N]
s["%A"] = BI.Date._DN[w]; // full weekday name s["%A"] = BI.getFullDayName(w); // full weekday name
s["%b"] = BI.Date._SMN[m]; // abbreviated month name [FIXME: I18N] s["%b"] = BI.Date._SMN[m]; // abbreviated month name [FIXME: I18N]
s["%B"] = BI.Date._MN[m]; // full month name s["%B"] = BI.getMonthName(m); // full month name
// FIXME: %c : preferred date and time representation for the current locale // FIXME: %c : preferred date and time representation for the current locale
s["%C"] = 1 + Math.floor(y / 100); // the century number s["%C"] = 1 + Math.floor(y / 100); // the century number
s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31) s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)

673
src/core/platform/web/detectElementResize.js

@ -1,120 +1,557 @@
/** /**
* Detect Element Resize. * Detect Element Resize.
* Forked in order to guard against unsafe 'window' and 'document' references. * A minimal library which polyfills the ResizeObserver API and is entirely based on the latest Draft Specification.
* * https://github.com/juggle/resize-observer
* https://github.com/sdecima/javascript-detect-element-resize * version: 3.4.0
* Sebastian Decima
*
* version: 0.5.3
**/ **/
!(function () { var ResizeObserverPolyfill = (function (exports) {
var attachEvent = _global.document && _global.document.attachEvent, 'use strict';
stylesCreated = false;
var resizeObservers = [];
if (_global.document && !attachEvent) {
var requestFrame = (function () { var hasActiveObservations = function () {
var raf = _global.requestAnimationFrame || _global.mozRequestAnimationFrame || _global.webkitRequestAnimationFrame || return resizeObservers.some(function (ro) {
function (fn) { return _global.setTimeout(fn, 20); }; return ro.activeTargets.length > 0;
return function (fn) { return raf(fn); }; });
})(); };
var cancelFrame = (function () { var hasSkippedObservations = function () {
var cancel = _global.cancelAnimationFrame || _global.mozCancelAnimationFrame || _global.webkitCancelAnimationFrame || return resizeObservers.some(function (ro) {
_global.clearTimeout; return ro.skippedTargets.length > 0;
return function (id) { return cancel(id); }; });
})(); };
var resetTriggers = function (element) { var msg = 'ResizeObserver loop completed with undelivered notifications.';
var triggers = element.__resizeTriggers__, var deliverResizeLoopError = function () {
expand = triggers.firstElementChild, var event;
contract = triggers.lastElementChild, if (typeof ErrorEvent === 'function') {
expandChild = expand.firstElementChild; event = new ErrorEvent('error', {
contract.scrollLeft = contract.scrollWidth; message: msg
contract.scrollTop = contract.scrollHeight; });
expandChild.style.width = expand.offsetWidth + 1 + "px"; } else {
expandChild.style.height = expand.offsetHeight + 1 + "px"; event = document.createEvent('Event');
expand.scrollLeft = expand.scrollWidth; event.initEvent('error', false, false);
expand.scrollTop = expand.scrollHeight; event.message = msg;
}; }
window.dispatchEvent(event);
var checkTriggers = function (element) { };
return element.offsetWidth !== element.__resizeLast__.width ||
element.offsetHeight !== element.__resizeLast__.height; var ResizeObserverBoxOptions;
}; (function (ResizeObserverBoxOptions) {
ResizeObserverBoxOptions["BORDER_BOX"] = "border-box";
var scrollListener = function (e) { ResizeObserverBoxOptions["CONTENT_BOX"] = "content-box";
var element = this; ResizeObserverBoxOptions["DEVICE_PIXEL_CONTENT_BOX"] = "device-pixel-content-box";
resetTriggers(this); })(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
this.__resizeRAF__ = requestFrame(function () { var freeze = function (obj) {
if (checkTriggers(element)) { return Object.freeze(obj);
element.__resizeLast__.width = element.offsetWidth; };
element.__resizeLast__.height = element.offsetHeight;
element.__resizeListeners__.forEach(function (fn) { var ResizeObserverSize = (function () {
fn.call(element, e); function ResizeObserverSize(inlineSize, blockSize) {
}); this.inlineSize = inlineSize;
} this.blockSize = blockSize;
}); freeze(this);
}; }
/* Detect CSS Animations support to detect element display/re-attach */ return ResizeObserverSize;
var animation = false, }());
animationstring = "animation",
keyframeprefix = "", var DOMRectReadOnly = (function () {
animationstartevent = "animationstart", function DOMRectReadOnly(x, y, width, height) {
domPrefixes = "Webkit Moz O ms".split(" "), this.x = x;
startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), this.y = y;
pfx = ""; this.width = width;
{ this.height = height;
var elm = document.createElement("fakeelement"); this.top = this.y;
if (elm.style.animationName !== undefined) { this.left = this.x;
animation = true; this.bottom = this.top + this.height;
} this.right = this.left + this.width;
return freeze(this);
if (animation === false) { }
for (var i = 0; i < domPrefixes.length; i++) {
if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) { DOMRectReadOnly.prototype.toJSON = function () {
pfx = domPrefixes[i]; var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left,
animationstring = pfx + "Animation"; width = _a.width, height = _a.height;
keyframeprefix = "-" + pfx.toLowerCase() + "-"; return { x: x, y: y, top: top, right: right, bottom: bottom, left: left, width: width, height: height };
animationstartevent = startEvents[i]; };
animation = true; DOMRectReadOnly.fromRect = function (rectangle) {
return new DOMRectReadOnly(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
};
return DOMRectReadOnly;
}());
var isSVG = function (target) {
return target instanceof SVGElement && 'getBBox' in target;
};
var isHidden = function (target) {
if (isSVG(target)) {
var _a = target.getBBox(), width = _a.width, height = _a.height;
return !width && !height;
}
var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
return !(offsetWidth || offsetHeight || target.getClientRects().length);
};
var isElement = function (obj) {
var _a;
if (obj instanceof Element) {
return true;
}
var scope = (_a = obj === null || obj === void 0 ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
return !!(scope && obj instanceof scope.Element);
};
var isReplacedElement = function (target) {
switch (target.tagName) {
case 'INPUT':
if (target.type !== 'image') {
break; break;
} }
case 'VIDEO':
case 'AUDIO':
case 'EMBED':
case 'OBJECT':
case 'CANVAS':
case 'IFRAME':
case 'IMG':
return true;
}
return false;
};
var global = typeof window !== 'undefined' ? window : {};
var cache = new WeakMap();
var scrollRegexp = /auto|scroll/;
var verticalRegexp = /^tb|vertical/;
var IE = (/msie|trident/i).test(global.navigator && global.navigator.userAgent);
var parseDimension = function (pixel) {
return parseFloat(pixel || '0');
};
var size = function (inlineSize, blockSize, switchSizes) {
if (inlineSize === void 0) {
inlineSize = 0;
}
if (blockSize === void 0) {
blockSize = 0;
}
if (switchSizes === void 0) {
switchSizes = false;
}
return new ResizeObserverSize((switchSizes ? blockSize : inlineSize) || 0, (switchSizes ? inlineSize : blockSize) || 0);
};
var zeroBoxes = freeze({
devicePixelContentBoxSize: size(),
borderBoxSize: size(),
contentBoxSize: size(),
contentRect: new DOMRectReadOnly(0, 0, 0, 0)
});
var calculateBoxSizes = function (target, forceRecalculation) {
if (forceRecalculation === void 0) {
forceRecalculation = false;
}
if (cache.has(target) && !forceRecalculation) {
return cache.get(target);
}
if (isHidden(target)) {
cache.set(target, zeroBoxes);
return zeroBoxes;
}
var cs = getComputedStyle(target);
var svg = isSVG(target) && target.ownerSVGElement && target.getBBox();
var removePadding = !IE && cs.boxSizing === 'border-box';
var switchSizes = verticalRegexp.test(cs.writingMode || '');
var canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || '');
var canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || '');
var paddingTop = svg ? 0 : parseDimension(cs.paddingTop);
var paddingRight = svg ? 0 : parseDimension(cs.paddingRight);
var paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom);
var paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft);
var borderTop = svg ? 0 : parseDimension(cs.borderTopWidth);
var borderRight = svg ? 0 : parseDimension(cs.borderRightWidth);
var borderBottom = svg ? 0 : parseDimension(cs.borderBottomWidth);
var borderLeft = svg ? 0 : parseDimension(cs.borderLeftWidth);
var horizontalPadding = paddingLeft + paddingRight;
var verticalPadding = paddingTop + paddingBottom;
var horizontalBorderArea = borderLeft + borderRight;
var verticalBorderArea = borderTop + borderBottom;
var horizontalScrollbarThickness = !canScrollHorizontally ? 0 : target.offsetHeight - verticalBorderArea - target.clientHeight;
var verticalScrollbarThickness = !canScrollVertically ? 0 : target.offsetWidth - horizontalBorderArea - target.clientWidth;
var widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0;
var heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0;
var contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness;
var contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness;
var borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea;
var borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea;
var boxes = freeze({
devicePixelContentBoxSize: size(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
borderBoxSize: size(borderBoxWidth, borderBoxHeight, switchSizes),
contentBoxSize: size(contentWidth, contentHeight, switchSizes),
contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
});
cache.set(target, boxes);
return boxes;
};
var calculateBoxSize = function (target, observedBox, forceRecalculation) {
var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize,
contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
switch (observedBox) {
case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
return devicePixelContentBoxSize;
case ResizeObserverBoxOptions.BORDER_BOX:
return borderBoxSize;
default:
return contentBoxSize;
}
};
var ResizeObserverEntry = (function () {
function ResizeObserverEntry(target) {
var boxes = calculateBoxSizes(target);
this.target = target;
this.contentRect = boxes.contentRect;
this.borderBoxSize = freeze([boxes.borderBoxSize]);
this.contentBoxSize = freeze([boxes.contentBoxSize]);
this.devicePixelContentBoxSize = freeze([boxes.devicePixelContentBoxSize]);
}
return ResizeObserverEntry;
}());
var calculateDepthForNode = function (node) {
if (isHidden(node)) {
return Infinity;
}
var depth = 0;
var parent = node.parentNode;
while (parent) {
depth += 1;
parent = parent.parentNode;
}
return depth;
};
var broadcastActiveObservations = function () {
var shallowestDepth = Infinity;
var callbacks = [];
resizeObservers.forEach(function processObserver(ro) {
if (ro.activeTargets.length === 0) {
return;
}
var entries = [];
ro.activeTargets.forEach(function processTarget(ot) {
var entry = new ResizeObserverEntry(ot.target);
var targetDepth = calculateDepthForNode(ot.target);
entries.push(entry);
ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox);
if (targetDepth < shallowestDepth) {
shallowestDepth = targetDepth;
}
});
callbacks.push(function resizeObserverCallback() {
ro.callback.call(ro.observer, entries, ro.observer);
});
ro.activeTargets.splice(0, ro.activeTargets.length);
});
for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
var callback = callbacks_1[_i];
callback();
} }
return shallowestDepth;
};
var gatherActiveObservationsAtDepth = function (depth) {
resizeObservers.forEach(function processObserver(ro) {
ro.activeTargets.splice(0, ro.activeTargets.length);
ro.skippedTargets.splice(0, ro.skippedTargets.length);
ro.observationTargets.forEach(function processTarget(ot) {
if (ot.isActive()) {
if (calculateDepthForNode(ot.target) > depth) {
ro.activeTargets.push(ot);
} else {
ro.skippedTargets.push(ot);
} }
} }
});
});
};
var animationName = "resizeanim"; var process = function () {
var animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } "; var depth = 0;
var animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; "; gatherActiveObservationsAtDepth(depth);
while (hasActiveObservations()) {
depth = broadcastActiveObservations();
gatherActiveObservationsAtDepth(depth);
}
if (hasSkippedObservations()) {
deliverResizeLoopError();
} }
return depth > 0;
};
var trigger;
var callbacks = [];
var notify = function () {
return callbacks.splice(0).forEach(function (cb) {
return cb();
});
};
var queueMicroTask = function (callback) {
if (!trigger) {
var toggle_1 = 0;
var el_1 = document.createTextNode('');
var config = { characterData: true };
new MutationObserver(function () {
return notify();
}).observe(el_1, config);
trigger = function () {
el_1.textContent = "".concat(toggle_1 ? toggle_1-- : toggle_1++);
};
}
callbacks.push(callback);
trigger();
};
var queueResizeObserver = function (cb) {
queueMicroTask(function ResizeObserver() {
requestAnimationFrame(cb);
});
};
var createStyles = function () { var watching = 0;
if (!stylesCreated) { var isWatching = function () {
// opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360 return !!watching;
var css = (animationKeyframes ? animationKeyframes : "") + };
".resize-triggers { " + (animationStyle ? animationStyle : "") + "visibility: hidden; opacity: 0; } " + var CATCH_PERIOD = 250;
".resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }", var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
head = document.head || document.getElementsByTagName("head")[0], var events = ['resize', 'load', 'transitionend', 'animationend', 'animationstart', 'animationiteration', 'keyup', 'keydown', 'mouseup', 'mousedown', 'mouseover', 'mouseout', 'blur', 'focus'];
style = document.createElement("style"); var time = function (timeout) {
if (timeout === void 0) {
timeout = 0;
}
return Date.now() + timeout;
};
var scheduled = false;
var Scheduler = (function () {
function Scheduler() {
var _this = this;
this.stopped = true;
this.listener = function () {
return _this.schedule();
};
}
style.type = "text/css"; Scheduler.prototype.run = function (timeout) {
if (style.styleSheet) { var _this = this;
style.styleSheet.cssText = css; if (timeout === void 0) {
timeout = CATCH_PERIOD;
}
if (scheduled) {
return;
}
scheduled = true;
var until = time(timeout);
queueResizeObserver(function () {
var elementsHaveResized = false;
try {
elementsHaveResized = process();
} finally {
scheduled = false;
timeout = until - time();
if (!isWatching()) {
return;
}
if (elementsHaveResized) {
_this.run(1000);
} else if (timeout > 0) {
_this.run(timeout);
} else { } else {
style.appendChild(document.createTextNode(css)); _this.start();
}
}
});
};
Scheduler.prototype.schedule = function () {
this.stop();
this.run();
};
Scheduler.prototype.observe = function () {
var _this = this;
var cb = function () {
return _this.observer && _this.observer.observe(document.body, observerConfig);
};
document.body ? cb() : global.addEventListener('DOMContentLoaded', cb);
};
Scheduler.prototype.start = function () {
var _this = this;
if (this.stopped) {
this.stopped = false;
this.observer = new MutationObserver(this.listener);
this.observe();
events.forEach(function (name) {
return global.addEventListener(name, _this.listener, true);
});
}
};
Scheduler.prototype.stop = function () {
var _this = this;
if (!this.stopped) {
this.observer && this.observer.disconnect();
events.forEach(function (name) {
return global.removeEventListener(name, _this.listener, true);
});
this.stopped = true;
}
};
return Scheduler;
}());
var scheduler = new Scheduler();
var updateCount = function (n) {
!watching && n > 0 && scheduler.start();
watching += n;
!watching && scheduler.stop();
};
var skipNotifyOnElement = function (target) {
return !isSVG(target) && !isReplacedElement(target) && getComputedStyle(target).display === 'inline';
};
var ResizeObservation = (function () {
function ResizeObservation(target, observedBox) {
this.target = target;
this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
this.lastReportedSize = {
inlineSize: -1, blockSize: -1
};
}
ResizeObservation.prototype.isActive = function () {
var size = calculateBoxSize(this.target, this.observedBox, true);
if (skipNotifyOnElement(this.target)) {
this.lastReportedSize = size;
}
if (this.lastReportedSize.inlineSize !== size.inlineSize || this.lastReportedSize.blockSize !== size.blockSize) {
return true;
}
return false;
};
return ResizeObservation;
}());
var ResizeObserverDetail = (function () {
function ResizeObserverDetail(resizeObserver, callback) {
this.activeTargets = [];
this.skippedTargets = [];
this.observationTargets = [];
this.observer = resizeObserver;
this.callback = callback;
}
return ResizeObserverDetail;
}());
var observerMap = new WeakMap();
var getObservationIndex = function (observationTargets, target) {
for (var i = 0; i < observationTargets.length; i += 1) {
if (observationTargets[i].target === target) {
return i;
}
}
return -1;
};
var ResizeObserverController = (function () {
function ResizeObserverController() {
} }
head.appendChild(style); ResizeObserverController.connect = function (resizeObserver, callback) {
stylesCreated = true; var detail = new ResizeObserverDetail(resizeObserver, callback);
observerMap.set(resizeObserver, detail);
};
ResizeObserverController.observe = function (resizeObserver, target, options) {
var detail = observerMap.get(resizeObserver);
var firstObservation = detail.observationTargets.length === 0;
if (getObservationIndex(detail.observationTargets, target) < 0) {
firstObservation && resizeObservers.push(detail);
detail.observationTargets.push(new ResizeObservation(target, options && options.box));
updateCount(1);
scheduler.schedule();
}
};
ResizeObserverController.unobserve = function (resizeObserver, target) {
var detail = observerMap.get(resizeObserver);
var index = getObservationIndex(detail.observationTargets, target);
var lastObservation = detail.observationTargets.length === 1;
if (index >= 0) {
lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1);
detail.observationTargets.splice(index, 1);
updateCount(-1);
}
};
ResizeObserverController.disconnect = function (resizeObserver) {
var _this = this;
var detail = observerMap.get(resizeObserver);
detail.observationTargets.slice().forEach(function (ot) {
return _this.unobserve(resizeObserver, ot.target);
});
detail.activeTargets.splice(0, detail.activeTargets.length);
};
return ResizeObserverController;
}());
var ResizeObserver = (function () {
function ResizeObserver(callback) {
if (arguments.length === 0) {
throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (typeof callback !== 'function') {
throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
} }
ResizeObserverController.connect(this, callback);
}
ResizeObserver.prototype.observe = function (target, options) {
if (arguments.length === 0) {
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (!isElement(target)) {
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
}
ResizeObserverController.observe(this, target, options);
};
ResizeObserver.prototype.unobserve = function (target) {
if (arguments.length === 0) {
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (!isElement(target)) {
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
}
ResizeObserverController.unobserve(this, target);
};
ResizeObserver.prototype.disconnect = function () {
ResizeObserverController.disconnect(this);
};
ResizeObserver.toString = function () {
return 'function ResizeObserver () { [polyfill code] }';
}; };
return ResizeObserver;
}());
exports.ResizeObserver = ResizeObserver;
exports.ResizeObserverEntry = ResizeObserverEntry;
exports.ResizeObserverSize = ResizeObserverSize;
Object.defineProperty(exports, '__esModule', { value: true });
return exports;
})({});
var ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill.ResizeObserver;
!(function () {
var addResizeListener = function (element, fn) { var addResizeListener = function (element, fn) {
if (window.ResizeObserver) { if (ResizeObserver) {
if (!element.__resizeObserver__) { if (!element.__resizeObserver__) {
var resizeObserver = new window.ResizeObserver(function () { var resizeObserver = new ResizeObserver(function () {
element.__resizeListeners__.forEach(function (listener) { element.__resizeListeners__.forEach(function (listener) {
listener(); listener();
}); });
@ -126,47 +563,24 @@
element.__resizeListeners__ = []; element.__resizeListeners__ = [];
} }
element.__resizeListeners__.push(fn); element.__resizeListeners__.push(fn);
} else if (attachEvent) {
element.attachEvent("onresize", fn);
BI.nextTick(fn);
} else {
if (!element.__resizeTriggers__) {
if (getComputedStyle(element).position === "static") element.style.position = "relative";
createStyles();
element.__resizeLast__ = {};
element.__resizeListeners__ = [];
(element.__resizeTriggers__ = document.createElement("div")).className = "resize-triggers";
element.__resizeTriggers__.innerHTML = "<div class=\"expand-trigger\"><div></div></div>" +
"<div class=\"contract-trigger\"></div>";
element.appendChild(element.__resizeTriggers__);
resetTriggers(element);
element.addEventListener("scroll", scrollListener, true);
/* Listen for a css animation to detect element display/re-attach */
animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
if (e.animationName === animationName) {resetTriggers(element);}
});
}
element.__resizeListeners__.push(fn);
} }
}; };
var removeResizeListener = function (element, fn) { var removeResizeListener = function (element, fn) {
if (window.ResizeObserver) { if (ResizeObserver) {
if (BI.isNull(fn)) {
element.__resizeListeners__ = [];
element.__resizeObserver__ && element.__resizeObserver__.unobserve(element);
element.__resizeObserver__ = null;
return;
}
var index = element.__resizeListeners__.indexOf(fn); var index = element.__resizeListeners__.indexOf(fn);
if (index >= 0) { if (index >= 0) {
element.__resizeListeners__.splice(index, 1); element.__resizeListeners__.splice(index, 1);
if (!element.__resizeListeners__.length) { if (!element.__resizeListeners__.length) {
element.__resizeObserver__ && element.__resizeObserver__.unobserve(element); element.__resizeObserver__ && element.__resizeObserver__.unobserve(element);
element.__resizeObserver__ = null;
} }
} }
} else if (attachEvent) {
element.detachEvent("onresize", fn);
} else {
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) {
element.removeEventListener("scroll", scrollListener);
element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
}
} }
}; };
@ -176,8 +590,7 @@
return function () { return function () {
removeResizeListener(widget.element[0], fn); removeResizeListener(widget.element[0], fn);
}; };
}, }, removeResizeListener: function (widget, fn) {
removeResizeListener: function (widget, fn) {
removeResizeListener(widget.element[0], fn); removeResizeListener(widget.element[0], fn);
} }
}; };

10
src/core/wrapper/layout.js

@ -42,16 +42,16 @@ BI.Layout = BI.inherit(BI.Widget, {
_init4Margin: function () { _init4Margin: function () {
if (this.options.top) { if (this.options.top) {
this.element.css("top", BI.isNumber(this.options.top) ? this.options.top / BI.pixRatio + BI.pixUnit : this.options.top); this.element.css("top", BI.pixFormat(this.options.top));
} }
if (this.options.left) { if (this.options.left) {
this.element.css("left", BI.isNumber(this.options.left) ? this.options.left / BI.pixRatio + BI.pixUnit : this.options.left); this.element.css("left", BI.pixFormat(this.options.left));
} }
if (this.options.bottom) { if (this.options.bottom) {
this.element.css("bottom", BI.isNumber(this.options.bottom) ? this.options.bottom / BI.pixRatio + BI.pixUnit : this.options.bottom); this.element.css("bottom", BI.pixFormat(this.options.bottom));
} }
if (this.options.right) { if (this.options.right) {
this.element.css("right", BI.isNumber(this.options.right) ? this.options.right / BI.pixRatio + BI.pixUnit : this.options.right); this.element.css("right", BI.pixFormat(this.options.right));
} }
}, },
@ -289,7 +289,7 @@ BI.Layout = BI.inherit(BI.Widget, {
}, },
_optimiseGap: function (gap) { _optimiseGap: function (gap) {
return (gap > 0 && gap < 1) ? (gap * 100).toFixed(1) + "%" : gap / BI.pixRatio + BI.pixUnit; return (gap > 0 && gap < 1) ? (gap * 100).toFixed(1) + "%" : BI.pixFormat(gap);
}, },
_optimiseItemLgap: function (item) { _optimiseItemLgap: function (item) {

8
src/core/wrapper/layout/layout.flow.js

@ -137,16 +137,16 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, {
var w = BI.FloatRightLayout.superclass._addElement.apply(this, arguments); var w = BI.FloatRightLayout.superclass._addElement.apply(this, arguments);
w.element.css({position: "relative", float: "right"}); w.element.css({position: "relative", float: "right"});
if (BI.isNotNull(item.left)) { if (BI.isNotNull(item.left)) {
w.element.css({left: BI.isNumber(item.left) ? item.left / BI.pixRatio + BI.pixUnit : item.left}); w.element.css({left: BI.pixFormat(item.left)});
} }
if (BI.isNotNull(item.right)) { if (BI.isNotNull(item.right)) {
w.element.css({right: BI.isNumber(item.right) ? item.right / BI.pixRatio + BI.pixUnit : item.right}); w.element.css({right: BI.pixFormat(item.right)});
} }
if (BI.isNotNull(item.top)) { if (BI.isNotNull(item.top)) {
w.element.css({top: BI.isNumber(item.top) ? item.top / BI.pixRatio + BI.pixUnit : item.top}); w.element.css({top: BI.pixFormat(item.top)});
} }
if (BI.isNotNull(item.bottom)) { if (BI.isNotNull(item.bottom)) {
w.element.css({bottom: BI.isNumber(item.bottom) ? item.bottom / BI.pixRatio + BI.pixUnit : item.bottom}); w.element.css({bottom: BI.pixFormat(item.bottom)});
} }
if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) {
var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item);

8
src/core/wrapper/layout/layout.inline.js

@ -47,7 +47,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
} }
} }
if (columnSize > 0) { if (columnSize > 0) {
w.element.width(columnSize < 1 ? ((columnSize * 100).toFixed(1) + "%") : (columnSize / BI.pixRatio + BI.pixUnit)); w.element.width(columnSize < 1 ? ((columnSize * 100).toFixed(1) + "%") : BI.pixFormat(columnSize));
} }
w.element.css({ w.element.css({
position: "relative", position: "relative",
@ -69,8 +69,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
gap += o.hgap + o.lgap + o.rgap + this._optimiseItemLgap(o.items[k]) + this._optimiseItemRgap(o.items[k]) + this._optimiseItemHgap(o.items[k]); gap += o.hgap + o.lgap + o.rgap + this._optimiseItemLgap(o.items[k]) + this._optimiseItemRgap(o.items[k]) + this._optimiseItemHgap(o.items[k]);
length += cz; length += cz;
} }
length = length > 0 && length < 1 ? (length * 100).toFixed(1) + "%" : length / BI.pixRatio + BI.pixUnit; length = length > 0 && length < 1 ? (length * 100).toFixed(1) + "%" : BI.pixFormat(length);
gap = gap > 0 && gap < 1 ? (gap * 100).toFixed(1) + "%" : gap / BI.pixRatio + BI.pixUnit; gap = gap > 0 && gap < 1 ? (gap * 100).toFixed(1) + "%" : BI.pixFormat(gap);
if (columnSize === "fill") { if (columnSize === "fill") {
w.element.css("min-width", "calc((100% - " + length + " - " + gap + ")" + (fillCount > 1 ? "/" + fillCount : "") + ")"); w.element.css("min-width", "calc((100% - " + length + " - " + gap + ")" + (fillCount > 1 ? "/" + fillCount : "") + ")");
} }
@ -86,7 +86,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
if (o.verticalAlign === BI.VerticalAlign.Stretch && BI.isNull(item.height)) { if (o.verticalAlign === BI.VerticalAlign.Stretch && BI.isNull(item.height)) {
var top = o.innerVgap + o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item), var top = o.innerVgap + o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item),
bottom = o.innerVgap + o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); bottom = o.innerVgap + o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item);
var gap = (top + bottom) > 0 && (top + bottom) < 1 ? ((top + bottom) * 100).toFixed(1) + "%" : (top + bottom) / BI.pixRatio + BI.pixUnit; var gap = (top + bottom) > 0 && (top + bottom) < 1 ? ((top + bottom) * 100).toFixed(1) + "%" : BI.pixFormat(top + bottom);
w.element.css("height", "calc(100% - " + gap + ")"); w.element.css("height", "calc(100% - " + gap + ")");
} }
return w; return w;

4
src/core/wrapper/layout/layout.tape.js

@ -92,7 +92,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
left: self._optimiseGap(left[i] + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) + o.hgap + o.lgap) left: self._optimiseGap(left[i] + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) + o.hgap + o.lgap)
}); });
if (columnSize === "" || columnSize === "fill") { if (BI.isNull(columnSize) || columnSize === "" || columnSize === "fill") {
return true; return true;
} }
}); });
@ -110,7 +110,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
right: self._optimiseGap(right[i] + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) + o.hgap + o.rgap) right: self._optimiseGap(right[i] + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) + o.hgap + o.rgap)
}); });
if (columnSize === "" || columnSize === "fill") { if (BI.isNull(columnSize) || columnSize === "" || columnSize === "fill") {
return true; return true;
} }
}); });

2
src/core/wrapper/layout/responsive/responsive.flex.horizontal.js

@ -51,7 +51,7 @@ BI.ResponsiveFlexHorizontalLayout = BI.inherit(BI.FlexHorizontalLayout, {
}, },
destroyed: function () { destroyed: function () {
this.unResize(); this.unResize?.();
} }
}); });
BI.shortcut("bi.responsive_flex_horizontal", BI.ResponsiveFlexHorizontalLayout); BI.shortcut("bi.responsive_flex_horizontal", BI.ResponsiveFlexHorizontalLayout);

3
src/less/base/combo/combo.less

@ -12,9 +12,6 @@
} }
&.bi-combo-popup { &.bi-combo-popup {
display: block !important;
visibility: visible !important;
& > .bi-trigger { & > .bi-trigger {
& .bi-trigger-icon-button { & .bi-trigger-icon-button {
& .x-icon { & .x-icon {

5
src/less/base/single/editor/editor.textarea.less

@ -6,11 +6,12 @@
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-all; word-break: break-all;
font-size: @font-size-12; font-size: @font-size-12;
font-size: calc(var(--css-scale, 1) * @font-size-12);
line-height: 21px; line-height: 21px;
& { line-height: calc(var(--css-scale, 1) * 21px);
border: none; border: none;
} }
}
& .textarea-watermark{ & .textarea-watermark{
max-height: 100%; max-height: 100%;
} }

21
src/less/base/tree/ztree.less

@ -67,6 +67,27 @@
border-left: 1px solid @border-color-dark-gray-line-theme-dark; border-left: 1px solid @border-color-dark-gray-line-theme-dark;
} }
} }
&.bi-checkbox {
border: 1px solid @color-bi-border-checkbox-theme-dark;
&.active {
background-color: @color-bi-background-active-checkbox-theme-dark;
border-color: @color-bi-border-hover-active-checkbox-theme-dark;
}
&.disabled {
background-color: @color-bi-background-disabled-checkbox-theme-dark;
&.active {
border-color: @color-bi-border-disabled-checkbox-theme-dark;
}
}
}
&.bi-half-button {
border: 1px solid @color-bi-border-hover-active-checkbox-theme-dark;
}
} }
.ztree li a { .ztree li a {

67
src/less/case/tree/tree.item.less

@ -0,0 +1,67 @@
@import "../../index.less";
.tree-first-solid-line-conn-background, .tree-mid-solid-line-conn-background {
&:before {
position: absolute;
top: 0;
left: -1px;
width: 50%;
height: 100%;
border-right: 1px solid @border-color-dark-gray-line;
content: '';
}
&:after {
position: absolute;
top: 0;
right: 0;
height: 50%;
width: 50%;
border-bottom: 1px solid @border-color-dark-gray-line;
content: '';
}
}
.tree-last-solid-line-conn-background {
&:before {
position: absolute;
top: 0;
left: -1px;
width: 50%;
height: 50%;
border-right: 1px solid @border-color-dark-gray-line;
content: '';
}
&:after {
position: absolute;
top: 0;
right: 1px;
height: 50%;
width: 50%;
border-bottom: 1px solid @border-color-dark-gray-line;
content: '';
}
}
.bi-theme-dark {
.tree-first-solid-line-conn-background, .tree-mid-solid-line-conn-background {
&:before {
border-right: 1px solid @border-color-dark-gray-line-theme-dark;
}
&:after {
border-bottom: 1px solid @border-color-dark-gray-line-theme-dark;
}
}
.tree-last-solid-line-conn-background {
&:before {
border-right: 1px solid @border-color-dark-gray-line-theme-dark;
}
&:after {
border-bottom: 1px solid @border-color-dark-gray-line-theme-dark;
}
}
}

6
src/less/core/utils/common.less

@ -570,7 +570,7 @@
// hover-visible的原子化形式 // hover-visible的原子化形式
.bi-hover-visible-container { .bi-hover-visible-container {
&:where(:not(&:hover)) .bi-hover-visible-item { &:where(:not(&:hover)) .bi-hover-visible-item:not(.bi-combo-popup) {
display: none; display: none;
} }
@ -591,11 +591,11 @@
// } // }
//} //}
& .bi-hover-visible-item { & .bi-hover-visible-item:not(.bi-combo-popup) {
visibility: hidden; visibility: hidden;
} }
&:hover .bi-hover-visible-item { &:hover .bi-hover-visible-item:not(.bi-combo-popup) {
visibility: visible; visibility: visible;
} }
} }

6
src/less/core/wrapper/inline.less

@ -15,10 +15,4 @@
display: inline-block !important; display: inline-block !important;
} }
} }
& > .bi-combo {
&.bi-combo-popup {
display: inline-block !important;
}
}
} }

18
src/less/core/wrapper/inline.old.less

@ -14,12 +14,6 @@
display: inline-block !important; display: inline-block !important;
} }
} }
& > .bi-combo {
&.bi-combo-popup {
display: inline-block !important;
}
}
} }
.bi-inline-horizontal-adapt-layout { .bi-inline-horizontal-adapt-layout {
@ -38,12 +32,6 @@
display: inline-block !important; display: inline-block !important;
} }
} }
& > .bi-combo {
&.bi-combo-popup {
display: inline-block !important;
}
}
} }
.bi-inline-vertical-adapt-layout { .bi-inline-vertical-adapt-layout {
@ -62,10 +50,4 @@
display: inline-block !important; display: inline-block !important;
} }
} }
& > .bi-combo {
&.bi-combo-popup {
display: inline-block !important;
}
}
} }

27
src/less/widget/singleslider/slider/widget.slider.less

@ -1,41 +1,31 @@
@import "../../../index.less"; @import "../../../index.less";
.bi-single-slider-button { .bi-single-slider-button {
& .slider-button { transform: translateX(-50%);
cursor: ew-resize; cursor: ew-resize;
border-width: 2px; border-width: 2px;
border-style: solid; border-style: solid;
.border-radius(8px); .border-radius(50%);
background-color: @color-bi-background-slider-button; background-color: @color-bi-background-slider-button;
height: 8px;
width: 8px;
top: 8px;
left: -6px;
&:hover, &.hover { &:hover, &.hover {
.border-radius(10px);
background-color: @color-bi-background-hover-slider-button; background-color: @color-bi-background-hover-slider-button;
width: 12px; transform: scale(1.2) translateX(-50%);
height: 12px; .box-shadow(0 2px 4px 1px, rgba(0, 35, 11, 20%));
top: 6px;
left: -8px;
.box-shadow(0 2px 4px 1px,rgba(0, 35, 11, 20%));
} }
&.disabled { &.disabled {
border-color: @color-bi-border-disabled-slider-button; border-color: @color-bi-border-disabled-slider-button;
&:hover, &.hover { &:hover, &.hover {
background-color: @color-bi-background-hover-disabled-slider-button; background-color: @color-bi-background-hover-disabled-slider-button;
width: 12px;
height: 12px;
top: 6px;
left: -8px;
}
} }
} }
} }
.bi-theme-dark { .bi-theme-dark {
.bi-single-slider-button { .bi-single-slider-button {
& .slider-button {
background-color: @color-bi-background-slider-button; background-color: @color-bi-background-slider-button;
&:hover, &.hover { &:hover, &.hover {
background-color: @color-bi-background-hover-slider-button-theme-dark; background-color: @color-bi-background-hover-slider-button-theme-dark;
@ -46,5 +36,4 @@
} }
} }
} }
}
} }

1
src/less/widget/year/popup.year.less

@ -2,7 +2,6 @@
.bi-year-popup { .bi-year-popup {
& .year-popup-navigation { & .year-popup-navigation {
line-height: 30px;
& > .center-element { & > .center-element {
border-left: 1px solid @color-bi-border-year-popup; border-left: 1px solid @color-bi-border-year-popup;
} }

4
src/widget/date/calendar/popup.month.js

@ -49,6 +49,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, {
}, },
_getItems: function(m) { _getItems: function(m) {
BI.Widget.pushContext(this);
// 纵向排列月 // 纵向排列月
var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]; var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
var items = []; var items = [];
@ -67,7 +68,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, {
whiteSpace: "nowrap", whiteSpace: "nowrap",
once: false, once: false,
forceSelected: true, forceSelected: true,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT - 1, height: BI.toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
width: 30, width: 30,
value: td, value: td,
text: td, text: td,
@ -75,6 +76,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, {
}; };
}); });
}); });
BI.Widget.popContext();
return items; return items;
}, },

10
src/widget/dynamicdate/dynamicdate.combo.js

@ -50,13 +50,13 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
el: { el: {
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: [this.constants.iconWidth, "fill"], columnSize: [this.constants.iconWidth, "fill"],
height: opts.height - border, height: BI.toPix(opts.height, border),
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-trigger-icon-button date-change-h-font",
width: opts.height - border, width: BI.toPix(opts.height, border),
height: opts.height - border, height: BI.toPix(opts.height, border),
ref: function () { ref: function () {
self.changeIcon = this; self.changeIcon = this;
} }
@ -69,8 +69,8 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
format: opts.format, format: opts.format,
allowEdit: opts.allowEdit, allowEdit: opts.allowEdit,
watermark: opts.watermark, watermark: opts.watermark,
iconWidth: opts.height - border, iconWidth: BI.toPix(opts.height, border),
height: opts.height - border, height: BI.toPix(opts.height, border),
value: opts.value, value: opts.value,
ref: function () { ref: function () {
self.trigger = this; self.trigger = this;

2
src/widget/dynamicdate/dynamicdate.param.item.js

@ -21,7 +21,7 @@ BI.DynamicDateParamItem = BI.inherit(BI.Widget, {
el: { el: {
type: "bi.sign_editor", type: "bi.sign_editor",
cls: "bi-border bi-focus-shadow bi-border-radius", cls: "bi-border bi-focus-shadow bi-border-radius",
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 2, height: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2),
validationChecker: function (v) { validationChecker: function (v) {
return BI.isNaturalNumber(v); return BI.isNaturalNumber(v);
}, },

6
src/widget/dynamicdate/dynamicdate.popup.js

@ -26,7 +26,7 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
cls: "bi-high-light bi-split-top", cls: "bi-high-light bi-split-top",
shadow: true, shadow: true,
text: BI.i18nText("BI-Basic_Clear"), text: BI.i18nText("BI-Basic_Clear"),
textHeight: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 1, textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
listeners: [{ listeners: [{
eventName: BI.TextButton.EVENT_CHANGE, eventName: BI.TextButton.EVENT_CHANGE,
action: function () { action: function () {
@ -37,7 +37,7 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
type: "bi.text_button", type: "bi.text_button",
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true, shadow: true,
textHeight: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 1, textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
text: BI.i18nText("BI-Multi_Date_Today"), text: BI.i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(), disabled: this._checkTodayValid(),
ref: function () { ref: function () {
@ -52,7 +52,7 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
}, { }, {
type: "bi.text_button", type: "bi.text_button",
cls: "bi-high-light bi-split-top", cls: "bi-high-light bi-split-top",
textHeight: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 1, textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true, shadow: true,
text: BI.i18nText("BI-Basic_OK"), text: BI.i18nText("BI-Basic_OK"),
listeners: [{ listeners: [{

3
src/widget/dynamicdate/dynamicdate.trigger.js

@ -152,6 +152,9 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
_getTitle: function () { _getTitle: function () {
var storeValue = this.storeValue || {}; var storeValue = this.storeValue || {};
if (BI.isEmptyObject(storeValue)) {
return this.options.watermark;
}
var type = storeValue.type || BI.DynamicDateCombo.Static; var type = storeValue.type || BI.DynamicDateCombo.Static;
var value = storeValue.value; var value = storeValue.value;
switch (type) { switch (type) {

8
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -8,7 +8,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
}, },
props: { props: {
baseCls: "bi-dynamic-date-combo", baseCls: "bi-dynamic-date--time-combo",
height: 24, height: 24,
minDate: "1900-01-01", minDate: "1900-01-01",
maxDate: "2099-12-31", maxDate: "2099-12-31",
@ -50,13 +50,13 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
el: { el: {
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: [this.constants.iconWidth, "fill"], columnSize: [this.constants.iconWidth, "fill"],
height: opts.height - border, height: BI.toPix(opts.height, border),
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-trigger-icon-button date-change-h-font",
width: this.constants.iconWidth, width: this.constants.iconWidth,
height: opts.height - border, height: BI.toPix(opts.height, border),
ref: function () { ref: function () {
self.changeIcon = this; self.changeIcon = this;
} }
@ -70,7 +70,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
watermark: opts.watermark, watermark: opts.watermark,
format: opts.format, format: opts.format,
iconWidth: this.constants.iconWidth, iconWidth: this.constants.iconWidth,
height: opts.height - border, height: BI.toPix(opts.height, border),
value: opts.value, value: opts.value,
ref: function () { ref: function () {
self.trigger = this; self.trigger = this;

6
src/widget/dynamicdatetime/dynamicdatetime.popup.js

@ -25,7 +25,7 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
items: [[{ items: [[{
type: "bi.text_button", type: "bi.text_button",
cls: "bi-high-light bi-split-top", cls: "bi-high-light bi-split-top",
textHeight: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 1, textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true, shadow: true,
text: BI.i18nText("BI-Basic_Clear"), text: BI.i18nText("BI-Basic_Clear"),
listeners: [{ listeners: [{
@ -37,7 +37,7 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
}, { }, {
type: "bi.text_button", type: "bi.text_button",
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
textHeight: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 1, textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true, shadow: true,
text: BI.i18nText("BI-Multi_Date_Today"), text: BI.i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(), disabled: this._checkTodayValid(),
@ -53,7 +53,7 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
}, { }, {
type: "bi.text_button", type: "bi.text_button",
cls: "bi-high-light bi-split-top", cls: "bi-high-light bi-split-top",
textHeight: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT - 1, textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true, shadow: true,
text: BI.i18nText("BI-Basic_OK"), text: BI.i18nText("BI-Basic_OK"),
listeners: [{ listeners: [{

40
src/widget/dynamicdatetime/dynamicdatetime.trigger.js

@ -9,7 +9,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
iconWidth: 24 iconWidth: 24
}, },
props: { props: () => ({
extraCls: "bi-date-time-trigger", extraCls: "bi-date-time-trigger",
min: "1900-01-01", // 最小日期 min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 max: "2099-12-31", // 最大日期
@ -17,8 +17,8 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
iconWidth: 24, iconWidth: 24,
format: "", // 显示的日期格式化方式 format: "", // 显示的日期格式化方式
allowEdit: true, // 是否允许编辑 allowEdit: true, // 是否允许编辑
watermark: "" watermark: BI.i18nText("BI-Basic_Unrestricted"),
}, }),
_init: function () { _init: function () {
BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments); BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments);
@ -44,7 +44,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
hgap: c.hgap, hgap: c.hgap,
vgap: c.vgap, vgap: c.vgap,
allowBlank: true, allowBlank: true,
watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"), watermark: o.watermark,
errorText: function (v) { errorText: function (v) {
var str = ""; var str = "";
if (!BI.isKey(o.format)) { if (!BI.isKey(o.format)) {
@ -149,7 +149,11 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
}, },
_getTitle: function () { _getTitle: function () {
var o = this.options;
var storeValue = this.storeValue || {}; var storeValue = this.storeValue || {};
if (BI.isEmptyObject(storeValue)) {
return o.watermark;
}
var type = storeValue.type || BI.DynamicDateCombo.Static; var type = storeValue.type || BI.DynamicDateCombo.Static;
var value = storeValue.value; var value = storeValue.value;
switch (type) { switch (type) {
@ -197,7 +201,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
// 这边不能直接用\d+去切日期, 因为format格式可能是20190607这样的没有分割符的 = = // 这边不能直接用\d+去切日期, 因为format格式可能是20190607这样的没有分割符的 = =
// 先看一下是否是合法的, 如果合法就变成标准格式的走原来的流程, 不合法不关心 // 先看一下是否是合法的, 如果合法就变成标准格式的走原来的流程, 不合法不关心
var date = BI.parseDateTime(v, this._getFormatString()); var date = BI.parseDateTime(v, this._getFormatString());
if(BI.print(date, this._getFormatString()) === v) { if (BI.print(date, this._getFormatString()) === v) {
v = BI.print(date, c.compareFormat); v = BI.print(date, c.compareFormat);
result = [0, 1, 2]; result = [0, 1, 2];
} }
@ -214,7 +218,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
BI.isNumeric(v) && v.length === 1 && (suffixArray[idx] = "0" + v); BI.isNumeric(v) && v.length === 1 && (suffixArray[idx] = "0" + v);
}); });
// hh:mm // hh:mm
if(suffixArray.length === 2 && !hasSecond) { if (suffixArray.length === 2 && !hasSecond) {
suffixArray.push("00"); suffixArray.push("00");
} }
var suffixString = suffixArray.join(":"); var suffixString = suffixArray.join(":");
@ -283,42 +287,42 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
_getText: function (obj) { _getText: function (obj) {
var value = ""; var value = "";
var endText = ""; var endText = "";
if(BI.isNotNull(obj.year)) { if (BI.isNotNull(obj.year)) {
if(BI.parseInt(obj.year) !== 0) { if (BI.parseInt(obj.year) !== 0) {
value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
} }
endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position);
} }
if(BI.isNotNull(obj.quarter)) { if (BI.isNotNull(obj.quarter)) {
if(BI.parseInt(obj.quarter) !== 0) { if (BI.parseInt(obj.quarter) !== 0) {
value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
} }
endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position);
} }
if(BI.isNotNull(obj.month)) { if (BI.isNotNull(obj.month)) {
if(BI.parseInt(obj.month) !== 0) { if (BI.parseInt(obj.month) !== 0) {
value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
} }
endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position);
} }
if(BI.isNotNull(obj.week)) { if (BI.isNotNull(obj.week)) {
if(BI.parseInt(obj.week) !== 0) { if (BI.parseInt(obj.week) !== 0) {
value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
} }
endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position);
} }
if(BI.isNotNull(obj.day)) { if (BI.isNotNull(obj.day)) {
if(BI.parseInt(obj.day) !== 0) { if (BI.parseInt(obj.day) !== 0) {
value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
} }
endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : "";
} }
if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { if (BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) {
value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
} }
return value + endText; return value + endText;
function getPositionText (baseText, position) { function getPositionText(baseText, position) {
switch (position) { switch (position) {
case BI.DynamicDateCard.OFFSET.BEGIN: case BI.DynamicDateCard.OFFSET.BEGIN:
return baseText + BI.i18nText("BI-Basic_Begin_Start"); return baseText + BI.i18nText("BI-Basic_Begin_Start");

4
src/widget/editor/editor.search.js

@ -15,13 +15,12 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
}); });
}, },
_init: function () { _init: function () {
this.options.height -= this.options.simple ? 1 : 2;
BI.SearchEditor.superclass._init.apply(this, arguments); BI.SearchEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget(o.el, { this.editor = BI.createWidget(o.el, {
type: "bi.editor", type: "bi.editor",
simple: o.simple, simple: o.simple,
height: o.height, height: BI.toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark, watermark: o.watermark,
allowBlank: true, allowBlank: true,
hgap: 1, hgap: 1,
@ -45,6 +44,7 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
}); });
BI.createWidget({ BI.createWidget({
element: this, element: this,
height: BI.toPix(o.height, o.simple ? 1 : 2),
type: "bi.htape", type: "bi.htape",
items: [ items: [
{ {

12
src/widget/editor/editor.text.js

@ -26,15 +26,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
var border = o.simple ? 1 : 2; var border = o.simple ? 1 : 2;
if (BI.isNumber(o.height)) {
this.element.css({ height: o.height - border });
}
if (BI.isNumber(o.width)) {
this.element.css({ width: o.width - border });
}
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.editor", type: "bi.editor",
element: this, element: this,
width: BI.toPix(o.width, border),
height: BI.toPix(o.height, border),
simple: o.simple, simple: o.simple,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -142,6 +138,10 @@ BI.TextEditor = BI.inherit(BI.Widget, {
return this.editor.isValid(); return this.editor.isValid();
}, },
setValid: function (b) {
this.editor.setValid(b);
},
setValue: function (v) { setValue: function (v) {
this.editor.setValue(v); this.editor.setValue(v);
}, },

105
src/widget/intervalslider/intervalslider.js

@ -60,8 +60,8 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
cls: "slider-editor-button", cls: "slider-editor-button",
text: this.options.unit, text: this.options.unit,
allowBlank: false, allowBlank: false,
width: c.EDITOR_WIDTH - 2, width: BI.toPix(c.EDITOR_WIDTH, 2),
height: c.EDITOR_HEIGHT - 2, height: BI.toPix(c.EDITOR_HEIGHT, 2),
validationChecker: function (v) { validationChecker: function (v) {
return self._checkValidation(v); return self._checkValidation(v);
} }
@ -88,8 +88,8 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
cls: "slider-editor-button", cls: "slider-editor-button",
text: this.options.unit, text: this.options.unit,
allowBlank: false, allowBlank: false,
width: c.EDITOR_WIDTH - 2, width: BI.toPix(c.EDITOR_WIDTH, 2),
height: c.EDITOR_HEIGHT - 2, height: BI.toPix(c.EDITOR_HEIGHT, 2),
validationChecker: function (v) { validationChecker: function (v) {
return self._checkValidation(v); return self._checkValidation(v);
} }
@ -122,28 +122,29 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
this._setVisible(false); this._setVisible(false);
return { return {
type: "bi.vertical_fill",
rowSize: [30, 30],
items: [
this._createLabelWrapper(),
{
type: "bi.absolute", type: "bi.absolute",
element: this, items: [
items: [{ {
el: { el: {
type: "bi.vertical", type: "bi.horizontal",
items: [{ horizontalAlign: "stretch",
type: "bi.absolute", verticalAlign: "middle",
columnSize: ["fill"],
items: [{ items: [{
el: this.track, el: this.track,
width: "100%",
height: c.TRACK_HEIGHT
}]
}], }],
hgap: 7, hgap: 10,
height: c.TRACK_HEIGHT
}, },
top: 23, inset: 0
left: 0,
width: "100%"
}, },
this._createLabelWrapper(), this._createSliderWrapper(),
this._createSliderWrapper() ]
}
] ]
}; };
}, },
@ -225,14 +226,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
items: [{ items: [{
el: this.labelOne, el: this.labelOne,
top: 0, top: 0,
left: "0%" left: 0,
}] }]
}, { }, {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [{
el: this.labelTwo, el: this.labelTwo,
top: 0, top: 0,
left: "100%" right: 0,
}] }]
}], }],
rgap: c.EDITOR_R_GAP, rgap: c.EDITOR_R_GAP,
@ -248,58 +249,62 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
var c = this._constant; var c = this._constant;
return { return {
el: { el: {
type: "bi.vertical", type: "bi.horizontal",
items: [{ horizontalAlign: "stretch",
verticalAlign: "middle",
items: [
{
type: "bi.absolute", type: "bi.absolute",
items: [{ height: 12,
width: "fill",
items: [
{
el: this.sliderOne, el: this.sliderOne,
top: 0, top: 1,
left: "0%" bottom: 0,
}] left: 0
}, { }, {
type: "bi.absolute",
items: [{
el: this.sliderTwo, el: this.sliderTwo,
top: 0, top: 1,
bottom: 0,
left: "100%" left: "100%"
}] }
}], ],
hgap: c.SLIDER_WIDTH_HALF, }
height: c.SLIDER_HEIGHT ],
hgap: 10,
}, },
top: 20, inset: 0
left: 0,
width: "100%"
}; };
}, },
_createTrackWrapper: function () { _createTrackWrapper: function () {
return BI.createWidget({ return BI.createWidget({
type: "bi.horizontal",
cls: "track-wrapper",
horizontalAlign: "stretch",
verticalAlign: "middle",
columnSize: ["fill"],
scrollx: false,
items: [
{
type: "bi.absolute", type: "bi.absolute",
items: [{ height: 6,
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{ items: [{
el: this.grayTrack, el: this.grayTrack,
top: 0, top: 0,
left: 0, left: 0,
bottom: 0,
width: "100%" width: "100%"
}, { }, {
el: this.blueTrack, el: this.blueTrack,
top: 0, top: 0,
left: 0, left: 0,
bottom: 0,
width: "0%" width: "0%"
}] }]
}], }
hgap: 8, ],
height: 8
},
top: 8,
left: 0,
width: "100%"
}]
}); });
}, },

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save