Browse Source

Merge pull request #204870 in DEC/fineui from release/11.0 to final/11.0

* commit 'a1a2587fe0506d0623279bc51315ff17489fbdbd': (181 commits)
  BI-115904 fix: 【来源内测BUG】展开下拉树子节点,会出现重复数据 同步
  Pull request #3195: KERNEL-13158: context跳过popup
  REPORT-83685 fix: BI.parseDateTime方法对%l:%M:%S %p这种格式的日期解析出错(后面带%p 这种的都是同类型的报错)
  REPORT-83685 fix: BI.parseDateTime方法对%l:%M:%S %p这种格式的日期解析出错(后面带%p 这种的都是同类型的报错)
  auto upgrade version to 2.0.20221101100519
  auto upgrade version to 2.0.20221031221611
  REPORT-82014 fix:补齐AFTER_HIDEVIEW事件
  auto upgrade version to 2.0.20221031190602
  auto upgrade version to 2.0.20221031135635
  BI-115201 fix: 【6.0.3.3】下拉树下拉后不选择任何内容,前端多发一个data请求
  BI-115201 fix: 【6.0.3.3】下拉树下拉后不选择任何内容,前端多发一个data请求
  auto upgrade version to 2.0.20221031101438
  auto upgrade version to 2.0.20221031095439
  bugfix
  auto upgrade version to 2.0.20221028191610
  feature: 增加instruction组件
  feature: 增加instruction组件
  REPORT-83214 fix: 不允许编辑的下拉树展示多了滚动条(finui的bi.multilayer_single_tree_combo组件)
  auto upgrade version to 2.0.20221028145548
  auto upgrade version to 2.0.20221028143506
  ...
master
superman 2 years ago
parent
commit
9241162fa4
  1. 67
      _mobile/date.i18n.cn.js
  2. 2
      demo/js/config/widget.js
  3. 10
      demo/js/widget/multitree/demo.multi_tree_combo.js
  4. 2
      demo/less/face.less
  5. 9
      demo/less/main.less
  6. 2
      demo/less/north.less
  7. 4
      dist/fix/fix.compact.js
  8. 99
      examples/ThemeProvider.html
  9. 59
      examples/useContext.html
  10. 12
      examples/响应式布局.html
  11. 2
      package.json
  12. 55
      src/base/collection/collection.js
  13. 11
      src/base/combination/group.button.js
  14. 16
      src/base/combination/navigation.js
  15. 15
      src/base/combination/tab.js
  16. 20
      src/base/context.js
  17. 55
      src/base/grid/grid.js
  18. 16
      src/base/layer/layer.popup.js
  19. 3
      src/base/list/listview.js
  20. 9
      src/base/list/virtualgrouplist.js
  21. 12
      src/base/list/virtuallist.js
  22. 19
      src/base/single/0.single.js
  23. 14
      src/base/single/1.text.js
  24. 31
      src/base/single/button/button.basic.js
  25. 2
      src/base/single/button/buttons/button.icon.js
  26. 18
      src/base/single/button/buttons/button.js
  27. 1
      src/base/single/button/buttons/button.text.js
  28. 1
      src/base/single/button/listitem/blankiconicontextitem.js
  29. 1
      src/base/single/button/listitem/blankicontexticonitem.js
  30. 1
      src/base/single/button/listitem/blankicontextitem.js
  31. 1
      src/base/single/button/listitem/icontexticonitem.js
  32. 1
      src/base/single/button/listitem/icontextitem.js
  33. 1
      src/base/single/button/listitem/texticonitem.js
  34. 1
      src/base/single/button/listitem/textitem.js
  35. 1
      src/base/single/button/node/icontexticonnode.js
  36. 1
      src/base/single/button/node/icontextnode.js
  37. 1
      src/base/single/button/node/texticonnode.js
  38. 1
      src/base/single/button/node/textnode.js
  39. 5
      src/base/single/editor/editor.js
  40. 15
      src/base/single/html/html.js
  41. 76
      src/base/single/instruction/instruction.js
  42. 8
      src/base/single/label/abstract.label.js
  43. 2
      src/base/single/label/icon.label.js
  44. 4
      src/base/single/tip/tip.toast.js
  45. 2
      src/base/single/tip/tip.tooltip.js
  46. 6
      src/case/button/node/siwtcher.tree.node.js
  47. 6
      src/case/button/treeitem/treeitem.js
  48. 2
      src/case/calendar/calendar.date.item.js
  49. 4
      src/case/calendar/calendar.js
  50. 4
      src/case/colorchooser/colorchooser.js
  51. 6
      src/case/combo/icontextvaluecombo/combo.icontextvalue.js
  52. 11
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  53. 6
      src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js
  54. 6
      src/case/combo/textvaluecombo/combo.textvalue.js
  55. 24
      src/case/editor/editor.shelter.js
  56. 24
      src/case/editor/editor.sign.js
  57. 24
      src/case/editor/editor.state.js
  58. 44
      src/case/layer/panel.js
  59. 2
      src/case/linearsegment/button.linear.segment.js
  60. 2
      src/case/list/list.select.js
  61. 3
      src/case/segment/button.segment.js
  62. 2
      src/case/segment/segment.js
  63. 4
      src/case/tree/treeexpander/tree.expander.popup.js
  64. 8
      src/case/trigger/trigger.editor.js
  65. 20
      src/case/trigger/trigger.icon.text.js
  66. 5
      src/case/trigger/trigger.text.js
  67. 3
      src/case/trigger/trigger.text.select.small.js
  68. 2
      src/case/trigger/trigger.text.small.js
  69. 5
      src/case/ztree/1.asynctree.js
  70. 6
      src/component/treevaluechooser/combo.treevaluechooser.js
  71. 10
      src/core/2.base.js
  72. 33
      src/core/3.ob.js
  73. 62
      src/core/4.widget.js
  74. 20
      src/core/5.inject.js
  75. 66
      src/core/constant/date.i18n.js
  76. 26
      src/core/constant/var.js
  77. 5
      src/core/controller/controller.popover.js
  78. 5
      src/core/controller/controller.tooltips.js
  79. 4
      src/core/func/alias.js
  80. 73
      src/core/func/date.js
  81. 677
      src/core/platform/web/detectElementResize.js
  82. 2
      src/core/utils/events/mousemovetracker.js
  83. 10
      src/core/wrapper/layout.js
  84. 8
      src/core/wrapper/layout/layout.flow.js
  85. 8
      src/core/wrapper/layout/layout.inline.js
  86. 4
      src/core/wrapper/layout/layout.tape.js
  87. 2
      src/core/wrapper/layout/responsive/responsive.flex.horizontal.js
  88. 28
      src/core/wrapper/layout/sticky/sticky.horizontal.js
  89. 28
      src/core/wrapper/layout/sticky/sticky.vertical.js
  90. 3
      src/less/base/combo/combo.less
  91. 11
      src/less/base/single/button/button.half.less
  92. 7
      src/less/base/single/editor/editor.textarea.less
  93. 13
      src/less/base/single/input/checkbox.less
  94. 13
      src/less/base/single/input/radio.less
  95. 31
      src/less/base/single/instruction.less
  96. 10
      src/less/base/single/tip/tip.bubble.less
  97. 296
      src/less/base/tree/ztree.less
  98. 90
      src/less/case/tree/tree.item.less
  99. 28
      src/less/core/utils/common.less
  100. 6
      src/less/core/wrapper/inline.less
  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/js/config/widget.js

@ -192,7 +192,7 @@ Demo.WIDGET_CONFIG = [{
value: "demo.number_interval" value: "demo.number_interval"
}, { }, {
id: 420, id: 420,
text: "滚动sliders", text: "数值滑块sliders",
value: "demo.slider" value: "demo.slider"
}, { }, {
pId: 4, pId: 4,

10
demo/js/widget/multitree/demo.multi_tree_combo.js

@ -38,7 +38,15 @@ Demo.MultiTreeCombo = BI.inherit(BI.Widget, {
width: 300, width: 300,
value: { value: {
"根目录": {} "根目录": {}
} },
listeners: [
{
eventName: "EVENT_CONFIRM",
action: function () {
console.log("EVENT_CONFIRM", this.getValue());
}
}
]
}, { }, {
type: "bi.button", type: "bi.button",
text: "getValue", text: "getValue",

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.20221101100519",
"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",

55
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,
@ -289,12 +280,44 @@ BI.CollectionView = BI.inherit(BI.Widget, {
} }
}, },
_isOverflowX: function () {
var o = this.options;
// 兼容一下
var scrollable = o.scrollable, scrollx = o.scrollx;
if (o.overflowX === false) {
return false;
}
if (scrollx) {
return true;
}
if (scrollable === true || scrollable === "xy" || scrollable === "x") {
return true;
}
return false;
},
_isOverflowY: function () {
var o = this.options;
// 兼容一下
var scrollable = o.scrollable, scrolly = o.scrolly;
if (o.overflowX === false) {
return false;
}
if (scrolly) {
return true;
}
if (scrollable === true || scrollable === "xy" || scrollable === "y") {
return true;
}
return false;
},
_getMaxScrollLeft: function () { _getMaxScrollLeft: function () {
return Math.max(0, this._width - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._width - this.options.width + (this._isOverflowX() ? BI.DOM.getScrollWidth() : 0));
}, },
_getMaxScrollTop: function () { _getMaxScrollTop: function () {
return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._height - this.options.height + (this._isOverflowY() ? BI.DOM.getScrollWidth() : 0));
}, },
_populate: function (items) { _populate: function (items) {

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

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

16
src/base/combination/navigation.js

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

15
src/base/combination/tab.js

@ -43,10 +43,11 @@ BI.Tab = BI.inherit(BI.Widget, {
eventObj: this.tab, eventObj: this.tab,
cardLayout: this.layout, cardLayout: this.layout,
cardCreator: function (v) { cardCreator: function (v) {
var card = o.cardCreator.apply(self, arguments); BI.Widget.execWithContext(self, function () {
self.cardMap[v] = card; self.cardMap[v] = o.cardCreator(v);
});
return card; return self.cardMap[v];
}, },
afterCardShow: function (v) { afterCardShow: function (v) {
self._deleteOtherCards(v); self._deleteOtherCards(v);
@ -71,10 +72,12 @@ BI.Tab = BI.inherit(BI.Widget, {
}, },
_assertCard: function (v) { _assertCard: function (v) {
var self = this, o = this.options;
if (!this.layout.isCardExisted(v)) { if (!this.layout.isCardExisted(v)) {
var card = this.options.cardCreator(v); BI.Widget.execWithContext(this, function () {
this.cardMap[v] = card; self.cardMap[v] = o.cardCreator(v);
this.layout.addCardByName(v, card); });
this.layout.addCardByName(v, this.cardMap[v]);
} }
}, },

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);

55
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,
@ -271,12 +262,44 @@ BI.GridView = BI.inherit(BI.Widget, {
} }
}, },
_isOverflowX: function () {
var o = this.options;
// 兼容一下
var scrollable = o.scrollable, scrollx = o.scrollx;
if (o.overflowX === false) {
return false;
}
if (scrollx) {
return true;
}
if (scrollable === true || scrollable === "xy" || scrollable === "x") {
return true;
}
return false;
},
_isOverflowY: function () {
var o = this.options;
// 兼容一下
var scrollable = o.scrollable, scrolly = o.scrolly;
if (o.overflowX === false) {
return false;
}
if (scrolly) {
return true;
}
if (scrollable === true || scrollable === "xy" || scrollable === "y") {
return true;
}
return false;
},
_getMaxScrollLeft: function () { _getMaxScrollLeft: function () {
return Math.max(0, this._getContainerWidth() - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._getContainerWidth() - this.options.width + (this._isOverflowX() ? BI.DOM.getScrollWidth() : 0));
}, },
_getMaxScrollTop: function () { _getMaxScrollTop: function () {
return Math.max(0, this._getContainerHeight() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._getContainerHeight() - this.options.height + (this._isOverflowY() ? BI.DOM.getScrollWidth() : 0));
}, },
_getContainerWidth: function () { _getContainerWidth: function () {

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

@ -136,7 +136,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

@ -124,7 +124,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;
@ -132,7 +132,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);
})); }));
@ -188,6 +188,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

@ -153,8 +153,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();
}); });
@ -208,10 +208,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,

31
src/base/single/button/button.basic.js

@ -184,7 +184,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
var mouseDown = false; var mouseDown = false;
var interval; var interval;
hand.mousedown(function (e) { hand.mousedown(function (e) {
BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function () {
interval && clearInterval(interval); interval && clearInterval(interval);
interval = null; interval = null;
mouseDown = false; mouseDown = false;
@ -193,13 +193,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (mouseDown === true) { if (mouseDown === true) {
return; return;
} }
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || !self.isValid()) {
return;
}
if (self.isOnce() && self.isSelected()) {
return; return;
} }
interval = setInterval(function () { interval = setInterval(function () {
if (self.isEnabled()) { clk(e)
self.doClick();
}
}, 180); }, 180);
mouseDown = true; mouseDown = true;
ev(e); ev(e);
@ -239,7 +240,10 @@ BI.BasicButton = BI.inherit(BI.Single, {
function clk(e) { function clk(e) {
ev(e); ev(e);
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || !self.isValid()) {
return;
}
if (self.isOnce() && self.isSelected()) {
return; return;
} }
if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) {
@ -335,16 +339,17 @@ BI.BasicButton = BI.inherit(BI.Single, {
}, },
_doClick: function (e) { _doClick: function (e) {
if (this.isValid()) { if (!this.isEnabled() || !this.isValid()) {
var isIntercepted = this.beforeClick(e); return;
// 如果事件已经被消费掉了,就不再触发点击事件 }
if (isIntercepted) { var isIntercepted = this.beforeClick(e);
return; // 如果事件已经被消费掉了,就不再触发点击事件
} if (isIntercepted) {
return;
} }
this._trigger(e); this._trigger(e);
if (this.isValid()) { if (this.isEnabled() && this.isValid()) {
this.doClick(e); this.doClick(e);
} }
}, },

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,

76
src/base/single/instruction/instruction.js

@ -0,0 +1,76 @@
BI.Instruction = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.Link.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-instruction",
height: 20,
level: "error",
textAlign: "left",
whiteSpace: "nowrap",
hgap: 5
});
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.label",
ref: function (_ref) {
self.text = _ref;
},
cls: "instruction-" + o.level,
textAlign: o.textAlign,
whiteSpace: o.whiteSpace,
textHeight: o.height,
height: o.height,
hgap: o.hgap,
rgap: o.rgap,
lgap: o.lgap,
vgap: o.vgap,
text: o.text,
keyword: o.keyword,
value: o.value,
py: o.py
};
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
setText: function (v) {
this.options.text = v;
this.text.setText(v);
},
getText: function () {
return this.options.text;
},
setStyle: function (css) {
this.text.setStyle(css);
},
setValue: function (v) {
this.text.setValue(v);
},
getValue: function () {
this.text.getValue();
}
});
BI.shortcut("bi.instruction", BI.Instruction);

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,

11
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,
@ -94,6 +91,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
action: function () { action: function () {
self.trigger.stopEditing(); self.trigger.stopEditing();
self.fireEvent(BI.SearchTextValueCombo.EVENT_AFTER_HIDEVIEW);
} }
}, { }, {
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
@ -151,4 +149,5 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
}); });
BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.SearchTextValueCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"
BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo); BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);

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)) {

44
src/case/layer/panel.js

@ -11,22 +11,18 @@ BI.Panel = BI.inherit(BI.Widget, {
titleHeight: 30, titleHeight: 30,
titleButtons: [], titleButtons: [],
el: {}, el: {},
logic: { // logic: {
dynamic: false // dynamic: false
} // }
}); });
}, },
_init: function () { render: function () {
BI.Panel.superclass._init.apply(this, arguments); return {
var o = this.options; type: "bi.vertical_fill",
rowSize: ["", "fill"],
BI.createWidget(BI.extend({ items: [this._createTitle(), this.options.el]
element: this };
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("top", this._createTitle()
, this.options.el)
}))));
}, },
_createTitle: function () { _createTitle: function () {
@ -56,18 +52,18 @@ BI.Panel = BI.inherit(BI.Widget, {
}); });
return { return {
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]
},
lhgap: 10,
rhgap: 10
}, },
height: o.titleHeight - 1 lhgap: 10,
rhgap: 10
// },
// 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: ""
} }
] ]
}); });

5
src/case/ztree/1.asynctree.js

@ -1,6 +1,6 @@
/** /**
* guy * guy
* 步树 * 步树
* @class BI.AsyncTree * @class BI.AsyncTree
* @extends BI.TreeView * @extends BI.TreeView
*/ */
@ -194,7 +194,8 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
// 展开节点会将halfCheck置为false以开启自动计算半选, 所以第一次展开节点的时候需要在置为false之前获取配置 // 展开节点会将halfCheck置为false以开启自动计算半选, 所以第一次展开节点的时候需要在置为false之前获取配置
var checkState = treeNode.getCheckStatus(); var checkState = treeNode.getCheckStatus();
if (!treeNode.children) { if (!treeNode.children && !treeNode.requested) {
treeNode.requested = true;
setTimeout(function () { setTimeout(function () {
getNodes({ getNodes({
times: 1, times: 1,

6
src/component/treevaluechooser/combo.treevaluechooser.js

@ -73,6 +73,11 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
action: function () { action: function () {
self.fireEvent(BI.TreeValueChooserCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.TreeValueChooserCombo.EVENT_BEFORE_POPUPVIEW);
} }
}, {
eventName: BI.MultiTreeCombo.EVENT_AFTER_HIDEVIEW,
action: function () {
self.fireEvent(BI.TreeValueChooserCombo.EVENT_AFTER_HIDEVIEW);
}
}] }]
}); });
}, },
@ -128,4 +133,5 @@ BI.TreeValueChooserCombo.EVENT_BLUR = "EVENT_BLUR";
BI.TreeValueChooserCombo.EVENT_STOP = "EVENT_STOP"; BI.TreeValueChooserCombo.EVENT_STOP = "EVENT_STOP";
BI.TreeValueChooserCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; BI.TreeValueChooserCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.TreeValueChooserCombo.EVENT_SEARCHING = "EVENT_SEARCHING"; BI.TreeValueChooserCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.TreeValueChooserCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
BI.shortcut("bi.tree_value_chooser_combo", BI.TreeValueChooserCombo); BI.shortcut("bi.tree_value_chooser_combo", BI.TreeValueChooserCombo);

10
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));
} }
@ -486,7 +486,7 @@
if (typeof w === "number") { if (typeof w === "number") {
return w >= 0; return w >= 0;
} else if (typeof w === "string") { } else if (typeof w === "string") {
return /^\d{1,3}(\.\d)?%$/.test(w) || w === "auto" || /^\d+px$/.test(w) || /^calc/.test(w); return /^\d{1,3}(\.\d)?%$/.test(w) || w === "auto" || /^\d+(\.\d+)?px$/.test(w) || /^calc/.test(w);
} }
}, },
@ -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 = [];
@ -1079,7 +1079,7 @@
case "%b": case "%b":
case "%B": case "%B":
for (j = 0; j < 12; ++j) { for (j = 0; j < 12; ++j) {
if (BI.Date._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { if (BI.getMonthName(j).substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) {
m = j; m = j;
break; break;
} }
@ -1144,7 +1144,7 @@
if (a[i].search(/[a-zA-Z]+/) != -1) { if (a[i].search(/[a-zA-Z]+/) != -1) {
var t = -1; var t = -1;
for (j = 0; j < 12; ++j) { for (j = 0; j < 12; ++j) {
if (BI.Date._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { if (BI.getMonthName(j).substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) {
t = j; t = j;
break; break;
} }

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 = {};
}, },
/** /**
* 触发绑定过的事件 * 触发绑定过的事件
* *

62
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;
@ -847,6 +857,17 @@
BI.Widget.context = context = contextStack.pop(); BI.Widget.context = context = contextStack.pop();
}; };
BI.Widget.execWithContext = function (context, execFunc) {
BI.Widget.pushContext(context);
try {
execFunc();
} catch (e) {
throw e;
} finally {
BI.Widget.popContext();
}
};
function pushTarget(_current) { function pushTarget(_current) {
if (current) currentStack.push(current); if (current) currentStack.push(current);
BI.Widget.current = current = _current; BI.Widget.current = current = _current;
@ -892,18 +913,29 @@
}; };
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; }
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;
} }
p = p._parent; vm = vm._parent;
} }
return null;
} }
} }
return BI.Model.target; return vm;
}; };
BI.watch = function (vm, watch, handler) { BI.watch = function (vm, watch, handler) {

20
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)) {
w.listeners = (w.listeners || []).concat([{ if (!w.listeners || BI.isArray(w.listeners)) {
eventName: BI.Events.MOUNT, w.listeners = (w.listeners || []).concat([{
action: function () { eventName: BI.Events.MOUNT,
BI.Plugin.getObject(elType, this); action: function () {
} 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);

4
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) {
@ -815,7 +815,7 @@
break; break;
case "M": // 月 case "M": // 月
if (len > 2) { if (len > 2) {
str = BI.Date._MN[date.getMonth()]; str = BI.getMonthName(date.getMonth());
} else if (len < 2) { } else if (len < 2) {
str = date.getMonth() + 1; str = date.getMonth() + 1;
} else { } else {

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)

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

@ -1,122 +1,559 @@
/** /**
* 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";
expandChild.style.height = expand.offsetHeight + 1 + "px";
expand.scrollLeft = expand.scrollWidth;
expand.scrollTop = expand.scrollHeight;
};
var checkTriggers = function (element) {
return element.offsetWidth !== element.__resizeLast__.width ||
element.offsetHeight !== element.__resizeLast__.height;
};
var scrollListener = function (e) {
var element = this;
resetTriggers(this);
if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
this.__resizeRAF__ = requestFrame(function () {
if (checkTriggers(element)) {
element.__resizeLast__.width = element.offsetWidth;
element.__resizeLast__.height = element.offsetHeight;
element.__resizeListeners__.forEach(function (fn) {
fn.call(element, e);
});
}
}); });
} else {
event = document.createEvent('Event');
event.initEvent('error', false, false);
event.message = msg;
}
window.dispatchEvent(event);
};
var ResizeObserverBoxOptions;
(function (ResizeObserverBoxOptions) {
ResizeObserverBoxOptions["BORDER_BOX"] = "border-box";
ResizeObserverBoxOptions["CONTENT_BOX"] = "content-box";
ResizeObserverBoxOptions["DEVICE_PIXEL_CONTENT_BOX"] = "device-pixel-content-box";
})(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
var freeze = function (obj) {
return Object.freeze(obj);
};
var ResizeObserverSize = (function () {
function ResizeObserverSize(inlineSize, blockSize) {
this.inlineSize = inlineSize;
this.blockSize = blockSize;
freeze(this);
}
return ResizeObserverSize;
}());
var DOMRectReadOnly = (function () {
function DOMRectReadOnly(x, y, width, height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.top = this.y;
this.left = this.x;
this.bottom = this.top + this.height;
this.right = this.left + this.width;
return freeze(this);
}
DOMRectReadOnly.prototype.toJSON = function () {
var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left,
width = _a.width, height = _a.height;
return { x: x, y: y, top: top, right: right, bottom: bottom, left: left, width: width, height: height };
}; };
DOMRectReadOnly.fromRect = function (rectangle) {
return new DOMRectReadOnly(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
};
return DOMRectReadOnly;
}());
/* Detect CSS Animations support to detect element display/re-attach */ var isSVG = function (target) {
var animation = false, return target instanceof SVGElement && 'getBBox' in target;
animationstring = "animation", };
keyframeprefix = "", var isHidden = function (target) {
animationstartevent = "animationstart", if (isSVG(target)) {
domPrefixes = "Webkit Moz O ms".split(" "), var _a = target.getBBox(), width = _a.width, height = _a.height;
startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), return !width && !height;
pfx = ""; }
{ var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
var elm = document.createElement("fakeelement"); return !(offsetWidth || offsetHeight || target.getClientRects().length);
if (elm.style.animationName !== undefined) { };
animation = true; var isElement = function (obj) {
} var _a;
if (obj instanceof Element) {
if (animation === false) { return true;
for (var i = 0; i < domPrefixes.length; i++) { }
if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) { var scope = (_a = obj === null || obj === void 0 ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
pfx = domPrefixes[i]; return !!(scope && obj instanceof scope.Element);
animationstring = pfx + "Animation"; };
keyframeprefix = "-" + pfx.toLowerCase() + "-"; var isReplacedElement = function (target) {
animationstartevent = startEvents[i]; switch (target.tagName) {
animation = true; case 'INPUT':
break; if (target.type !== 'image') {
} 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 process = function () {
var depth = 0;
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 watching = 0;
var isWatching = function () {
return !!watching;
};
var CATCH_PERIOD = 250;
var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
var events = ['resize', 'load', 'transitionend', 'animationend', 'animationstart', 'animationiteration', 'keyup', 'keydown', 'mouseup', 'mousedown', 'mouseover', 'mouseout', 'blur', 'focus'];
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();
};
} }
var animationName = "resizeanim"; Scheduler.prototype.run = function (timeout) {
var animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } "; var _this = this;
var animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; "; 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 {
_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 createStyles = function () { var skipNotifyOnElement = function (target) {
if (!stylesCreated) { return !isSVG(target) && !isReplacedElement(target) && getComputedStyle(target).display === 'inline';
// opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360 };
var css = (animationKeyframes ? animationKeyframes : "") + var ResizeObservation = (function () {
".resize-triggers { " + (animationStyle ? animationStyle : "") + "visibility: hidden; opacity: 0; } " + function ResizeObservation(target, observedBox) {
".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%; }", this.target = target;
head = document.head || document.getElementsByTagName("head")[0], this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
style = document.createElement("style"); this.lastReportedSize = {
inlineSize: -1, blockSize: -1
};
}
style.type = "text/css"; ResizeObservation.prototype.isActive = function () {
if (style.styleSheet) { var size = calculateBoxSize(this.target, this.observedBox, true);
style.styleSheet.cssText = css; if (skipNotifyOnElement(this.target)) {
} else { this.lastReportedSize = size;
style.appendChild(document.createTextNode(css)); }
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;
}
head.appendChild(style); return ResizeObserverDetail;
stylesCreated = true; }());
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() {
}
ResizeObserverController.connect = function (resizeObserver, callback) {
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(); BI.$(element).is(":visible") && listener();
}); });
}); });
resizeObserver.observe(element); resizeObserver.observe(element);
@ -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);
} }
}; };

2
src/core/utils/events/mousemovetracker.js

@ -44,7 +44,7 @@
this._x = event.clientX; this._x = event.clientX;
this._y = event.clientY; this._y = event.clientY;
} }
event.preventDefault ? event.preventDefault() : (event.returnValue = false); // event.preventDefault ? event.preventDefault() : (event.returnValue = false);
}, },
releaseMouseMoves: function () { releaseMouseMoves: function () {

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);

28
src/core/wrapper/layout/sticky/sticky.horizontal.js

@ -21,13 +21,29 @@ BI.HorizontalStickyLayout = BI.inherit(BI.FlexHorizontalLayout, {
} }
} }
if (columnSize !== "fill") { if (columnSize !== "fill") {
var firstItemFill = o.columnSize[0] === "fill" || o.items[0].width === "fill"; var fillIndex;
w.element.css({ BI.count(0, o.items.length - 1, index => {
position: "sticky", if (BI.isNotNull(fillIndex)) {
zIndex: 1, return;
left: firstItemFill ? "" : 0, }
right: firstItemFill ? 0 : "" if ((o.columnSize[index] === "fill" || o.items[index].width === "fill")) {
fillIndex = index;
}
}); });
if (fillIndex > i) {
w.element.css({
position: "sticky",
zIndex: 1,
left: 0,
});
} else {
w.element.css({
position: "sticky",
zIndex: 1,
right: 0
});
}
} else { } else {
w.element.css({ w.element.css({
overflow: "" overflow: ""

28
src/core/wrapper/layout/sticky/sticky.vertical.js

@ -21,13 +21,29 @@ BI.VerticalStickyLayout = BI.inherit(BI.FlexVerticalLayout, {
} }
} }
if (rowSize !== "fill") { if (rowSize !== "fill") {
var firstItemFill = o.rowSize[0] === "fill" || o.items[0].height === "fill"; var fillIndex;
w.element.css({ BI.count(0, o.items.length - 1, index => {
position: "sticky", if (BI.isNotNull(fillIndex)) {
zIndex: 1, return;
top: firstItemFill ? "" : 0, }
bottom: firstItemFill ? 0 : "" if ((o.rowSize[index] === "fill" || o.items[index].height === "fill")) {
fillIndex = index;
}
}); });
if (fillIndex > i) {
w.element.css({
position: "sticky",
zIndex: 1,
top: 0,
});
} else {
w.element.css({
position: "sticky",
zIndex: 1,
bottom: 0
});
}
} else { } else {
w.element.css({ w.element.css({
overflow: "" overflow: ""

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 {

11
src/less/base/single/button/button.half.less

@ -6,10 +6,13 @@
&:after { &:after {
position: absolute; position: absolute;
left: 2px; .border-radius(2px);
top: 2px; display: table;
width: 8px; left: 50%;
height: 8px; top: 50%;
width: 70%;
height: 70%;
.transform(translate(-50%, -50%));
background-color: @color-bi-background-half-button-content; background-color: @color-bi-background-half-button-content;
content: ''; content: '';
} }

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

@ -6,10 +6,11 @@
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%;

13
src/less/base/single/input/checkbox.less

@ -6,20 +6,21 @@
border: 1px solid @color-bi-border-checkbox; border: 1px solid @color-bi-border-checkbox;
.box-sizing(border-box); .box-sizing(border-box);
.transition(all .1s); .transition(all .1s);
&:after { &:after {
position: absolute; position: absolute;
display: table; display: table;
// 百分比会出现像素误差 top: 45%;
top: 6px; left: 18%;
left: 2px;
border: 2px solid transparent; border: 2px solid transparent;
border: calc(var(--css-scale, 1) * 2px) solid transparent;
border-top: 0; border-top: 0;
border-left: 0; border-left: 0;
width: 6px; width: 50%;
height: 9px; height: 75%;
.box-sizing(border-box); .box-sizing(border-box);
.transform(rotate(45deg) scale(1) translate(-50%, -50%)); .transform(rotate(45deg) scale(1) translate(-50%, -50%));
@transition: all .1s cubic-bezier(.71,-.46,.88,.6),opacity .1s; @transition: all .1s cubic-bezier(.71, -.46, .88, .6), opacity .1s;
.transition(@transition); .transition(@transition);
content: ''; content: '';
} }

13
src/less/base/single/input/radio.less

@ -2,13 +2,15 @@
.bi-radio { .bi-radio {
& .radio-content, &.radio-content { & .radio-content, &.radio-content {
.border-radius(8px); .border-radius(50%);
border: 1px solid @color-bi-border-radio; border: 1px solid @color-bi-border-radio;
.box-sizing(border-box); .box-sizing(border-box);
.transition(all .1s); .transition(all .1s);
&:after { &:after {
content: ""; content: "";
} }
&.hover, &:hover { &.hover, &:hover {
border-color: @color-bi-border-hover-active-radio; border-color: @color-bi-border-hover-active-radio;
} }
@ -18,16 +20,15 @@
border-color: @color-bi-border-hover-active-radio; border-color: @color-bi-border-hover-active-radio;
background-color: @color-bi-background-active-radio; background-color: @color-bi-background-active-radio;
&:after { &:after {
width: 8px; width: 50%;
height: 8px; height: 50%;
display: table;
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
.border-radius(4px); .border-radius(50%);
background-color: @color-bi-background-active-radio-content; background-color: @color-bi-background-active-radio-content;
.transform(translate(-50%, -50%)); .transform(translate(-50%, -50%));
@transition: all .1s cubic-bezier(.71,-.46,.88,.6),opacity .1s; @transition: all .1s cubic-bezier(.71, -.46, .88, .6), opacity .1s;
.transition(@transition); .transition(@transition);
} }
} }

31
src/less/base/single/instruction.less

@ -0,0 +1,31 @@
@import "../../index.less";
.bi-instruction {
.border-radius(2px);
&.instruction-error{
background: @color-bi-background-bubble-error;
color: @color-bi-text-failure;
}
&.instruction-common{
background: @color-bi-background-bubble-normal;
color: @color-bi-text-highlight;
}
&.instruction-success{
background: @color-bi-background-bubble-success;
color: @color-bi-text-success;
}
&.instruction-warning{
background: @color-bi-background-bubble-warning;
color: @color-bi-text-redmark;
}
}
.bi-theme-dark {
.bi-instruction.instruction-error {
background: @color-bi-background-bubble-error-theme-dark;
}
}

10
src/less/base/single/tip/tip.bubble.less

@ -9,10 +9,6 @@
color: @color-bi-text-failure; color: @color-bi-text-failure;
} }
.bi-theme-dark &.bubble-error {
background: @color-bi-background-bubble-error-theme-dark;
}
&.bubble-common{ &.bubble-common{
background: @color-bi-background-bubble-normal; background: @color-bi-background-bubble-normal;
color: @color-bi-text-highlight; color: @color-bi-text-highlight;
@ -28,3 +24,9 @@
color: @color-bi-text-redmark; color: @color-bi-text-redmark;
} }
} }
.bi-theme-dark {
.bi-bubble.bubble-error {
background: @color-bi-background-bubble-error-theme-dark;
}
}

296
src/less/base/tree/ztree.less

@ -1,5 +1,10 @@
@import "../../index.less"; @import "../../index.less";
.use-scale(@property, @pix) {
@{property} : @pix; //不支持css变量的浏览器
@{property} : calc(var(--css-scale, 1) * @pix);
}
.ztree * { .ztree * {
padding: 0; padding: 0;
margin: 0; margin: 0;
@ -27,7 +32,7 @@
.ztree.solid li ul { .ztree.solid li ul {
margin: 0; margin: 0;
padding: 0 0 0 24px .use-scale(padding-left, 24px);
} }
// 此处不用2倍图,改用css画虚线 // 此处不用2倍图,改用css画虚线
@ -50,7 +55,7 @@
&:before { &:before {
border-left: 1px solid @border-color-dark-gray-line; border-left: 1px solid @border-color-dark-gray-line;
height: 100%; height: 100%;
left: 14px; .use-scale(left, 14px);
margin-top: 0; margin-top: 0;
} }
} }
@ -67,6 +72,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 {
@ -92,35 +118,8 @@
} }
.ztree.solid li a { .ztree.solid li a {
height: 30px; //height: 30px;
} .use-scale(height, 30px);
.ztree li a.curSelectedNode {
}
.ztree li a.curSelectedNode_Edit {
padding-top: 0px;
background-color: #FFE6B0;
color: black;
height: 16px;
border: 1px #FFB951 solid;
opacity: 0.8;
}
.ztree li a.tmpTargetNode_inner {
padding-top: 0px;
background-color: #316AC5;
color: white;
height: 16px;
border: 1px #316AC5 solid;
opacity: 0.8;
filter: alpha(opacity=80)
}
.ztree li a.tmpTargetNode_prev {
}
.ztree li a.tmpTargetNode_next {
} }
.ztree li a input.rename { .ztree li a input.rename {
@ -142,7 +141,8 @@
} }
.ztree.solid li span { .ztree.solid li span {
line-height: 30px; //line-height: 30px;
.use-scale(line-height, 30px);
} }
.ztree li span.icon { .ztree li span.icon {
@ -162,10 +162,6 @@
vertical-align: middle; vertical-align: middle;
border: 0 none; border: 0 none;
cursor: pointer; cursor: pointer;
outline: none;
background-color: transparent;
background-repeat: no-repeat;
background-attachment: scroll;
} }
.ztree li span.button.chk { .ztree li span.button.chk {
@ -194,57 +190,100 @@
} }
} }
.ztree.solid li span.button.roots_docu {
.ztree li span.button.chk { background: none;
position: relative; position: relative;
width: 14px;
height: 14px;
margin: 0 3px 0 0;
cursor: auto
}
.ztree li span.button.chk.checkbox_false_disable { &:before {
background-position: 0 -56px position: absolute;
} bottom: 0;
left: -1px;
width: 50%;
height: 50%;
border-right: 1px solid @border-color-dark-gray-line;
content: '';
}
.ztree li span.button.chk.checkbox_true_disable { &:after {
background-position: -14px -56px position: absolute;
top: 0;
right: 0;
height: 50%;
width: 50%;
border-bottom: 1px solid @border-color-dark-gray-line;
content: '';
}
} }
.ztree li span.button.chk.radio_false_full { .ztree.solid li span.button.center_docu {
background-position: -28px 0 background: none;
} position: relative;
.ztree li span.button.chk.radio_false_full_focus { &:before {
background-position: -28px -14px position: absolute;
} top: 0;
left: -1px;
width: 50%;
height: 100%;
border-right: 1px solid @border-color-dark-gray-line;
content: '';
}
.ztree li span.button.chk.radio_false_part { &:after {
background-position: -28px -28px position: absolute;
top: 0;
right: 0;
height: 50%;
width: 50%;
border-bottom: 1px solid @border-color-dark-gray-line;
content: '';
}
} }
.ztree li span.button.chk.radio_false_part_focus { .ztree.solid li span.button.bottom_docu {
background-position: -28px -42px background: none;
} position: relative;
.ztree li span.button.chk.radio_false_disable { &:before {
background-position: -28px -56px position: absolute;
} top: 0;
left: -1px;
width: 50%;
height: 50%;
border-right: 1px solid @border-color-dark-gray-line;
content: '';
}
.ztree li span.button.chk.radio_true_full { &:after {
background-position: -42px 0 position: absolute;
top: 0;
right: 1px;
height: 50%;
width: 50%;
border-bottom: 1px solid @border-color-dark-gray-line;
content: '';
}
} }
.ztree li span.button.chk.radio_true_full_focus { .bi-theme-dark {
background-position: -42px -14px; .ztree.solid li span.button.center_docu, .ztree.solid li span.button.bottom_docu {
} &:before {
border-right: 1px solid @border-color-dark-gray-line-theme-dark;
}
.ztree li span.button.chk.radio_true_part { &:after {
background-position: -42px -28px border-bottom: 1px solid @border-color-dark-gray-line-theme-dark;
}
}
} }
.ztree li span.button.chk.radio_true_part_focus {
background-position: -42px -42px .ztree li span.button.chk {
position: relative;
.use-scale(width, 14px);
.use-scale(height, 14px);
margin: 0 3px 0 0;
cursor: auto
} }
.ztree li span.button.chk.checkbox_true_full { .ztree li span.button.chk.checkbox_true_full {
@ -271,73 +310,16 @@
} }
} }
.ztree li span.button.chk.radio_true_disable {
background-position: -42px -56px
}
.ztree li span.button.switch { .ztree li span.button.switch {
width: 24px; width: 24px;
height: 24px height: 24px
} }
.ztree.solid li span.button.switch { .ztree.solid li span.button.switch {
width: 30px; .use-scale(width, 30px);
height: 30px .use-scale(height, 30px);
} //width: 30px;
//height: 30px;
.ztree li span.button.switch.noline_open {
width: 0;
}
.ztree li span.button.switch.noline_close {
width: 0;
}
.ztree li span.button.noline_open {
background-position: -92px -72px
}
.ztree li span.button.noline_close {
background-position: -74px -72px
}
.ztree li span.button.root_docu {
background: none;
}
.ztree li span.button.noline_docu {
background: none;
width: 0;
}
.ztree li span.button.ico_open {
margin-right: 2px;
background-position: -110px -16px;
vertical-align: top;
}
.ztree li span.button.ico_close {
margin-right: 2px;
background-position: -110px 0;
vertical-align: top;
}
.ztree li span.button.ico_docu {
margin-right: 2px;
background-position: -110px -32px;
vertical-align: top;
}
.ztree li span.button.edit {
margin-right: 2px;
background-position: -110px -48px;
vertical-align: top;
}
.ztree li span.button.remove {
margin-right: 2px;
background-position: -110px -64px;
vertical-align: top;
} }
.ztree li span.button.ico_loading { .ztree li span.button.ico_loading {
@ -345,53 +327,3 @@
margin-right: 2px; margin-right: 2px;
vertical-align: top; vertical-align: top;
} }
ul.tmpTargetzTree {
background-color: #FFE6B0;
opacity: 0.8;
filter: alpha(opacity=80)
}
span.tmpzTreeMove_arrow {
width: 16px;
height: 16px;
display: inline-block;
padding: 0;
margin: 2px 0 0 1px;
border: 0 none;
position: absolute;
background-color: transparent;
background-repeat: no-repeat;
background-attachment: scroll;
background-position: -110px -80px;
}
ul.ztree.zTreeDragUL {
margin: 0;
padding: 0;
position: absolute;
width: auto;
height: auto;
overflow: hidden;
background-color: #cfcfcf;
border: 1px #00B83F dotted;
opacity: 0.8;
filter: alpha(opacity=80)
}
.zTreeMask {
z-index: 10000;
background-color: #cfcfcf;
opacity: 0.0;
filter: alpha(opacity=0);
position: absolute
}
/* level style*/
/*.ztree li span.button.level0 {
display:none;
}
.ztree li ul.level0 {
padding:0;
background:none;
}*/

90
src/less/case/tree/tree.item.less

@ -0,0 +1,90 @@
@import "../../index.less";
.tree-first-solid-line-conn-background {
&:before {
position: absolute;
bottom: 0;
left: -1px;
width: 50%;
height: 50%;
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-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;
}
}
}

28
src/less/core/utils/common.less

@ -74,9 +74,10 @@
border-color: @color-bi-border-highlight; border-color: @color-bi-border-highlight;
} }
// ie下不支持focus-within, 和上面写在一起会导致ie下:hover不生效 // ie下不支持focus-within, 和上面写在一起会导致ie下:hover不生效
&:focus-within{ &:focus-within {
border-color: @color-bi-border-highlight; border-color: @color-bi-border-highlight;
} }
&.disabled { &.disabled {
&:hover { &:hover {
border-color: @border-color-line; border-color: @border-color-line;
@ -84,6 +85,14 @@
} }
} }
.base-disabled {
.bi-focus-shadow {
&:hover {
border-color: @border-color-line;
}
}
}
.bi-theme-dark { .bi-theme-dark {
.bi-focus-shadow { .bi-focus-shadow {
&.disabled { &.disabled {
@ -94,6 +103,16 @@
} }
} }
.bi-theme-dark {
.base-disabled {
.bi-focus-shadow {
&:hover {
border-color: @border-color-line-theme-dark;
}
}
}
}
.clearfix { .clearfix {
.clearfix(); .clearfix();
} }
@ -102,6 +121,7 @@
.bi-background { .bi-background {
background-color: @color-bi-background-normal; background-color: @color-bi-background-normal;
color: @color-bi-text-background; color: @color-bi-text-background;
& .bi-input { & .bi-input {
color: @color-bi-text-background; color: @color-bi-text-background;
} }
@ -570,7 +590,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 +611,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;
}
}
} }

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

Loading…
Cancel
Save