Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~teller/fineui

es6
iapyang 3 years ago
parent
commit
94094274b1
  1. 2
      changelog.md
  2. 26
      dist/fix/fix.proxy.js
  3. BIN
      dist/font/iconfont.eot
  4. 6
      dist/font/iconfont.svg
  5. BIN
      dist/font/iconfont.ttf
  6. BIN
      dist/font/iconfont.woff
  7. BIN
      dist/font/iconfont.woff2
  8. 3203
      dist/router.js
  9. 1
      index.html
  10. 2
      package.json
  11. 513
      src/base/combination/bubble.js
  12. 285
      src/base/combination/combo.js
  13. 3
      src/base/combination/expander.js
  14. 3
      src/base/combination/switcher.js
  15. 5
      src/base/foundation/message.js
  16. 12
      src/base/list/virtualgrouplist.js
  17. 3
      src/base/single/button/button.basic.js
  18. 4
      src/base/single/button/buttons/button.js
  19. 11
      src/base/single/tip/tip.toast.js
  20. 2
      src/case/button/item.singleselect.js
  21. 2
      src/case/checkbox/check.arrownode.js
  22. 5
      src/case/checkbox/check.checkingmarknode.js
  23. 283
      src/case/colorchooser/colorchooser.popup.hex.js
  24. 2
      src/case/colorchooser/colorpicker/colorpicker.hex.js
  25. 2
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.js
  26. 1
      src/case/combo/bubblecombo/combo.bubble.js
  27. 4
      src/case/combo/iconcombo/trigger.iconcombo.js
  28. 24
      src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js
  29. 5
      src/case/combo/textvaluecheckcombo/popup.textvaluecheck.js
  30. 24
      src/case/combo/textvaluecombo/popup.textvalue.js
  31. 7
      src/case/editor/editor.clear.js
  32. 2
      src/case/segment/button.segment.js
  33. 2
      src/core/platform/web/function.js
  34. 61
      src/less/base/combo/combo.bubble.less
  35. 2
      src/less/base/segment/segment.less
  36. 53
      src/less/lib/colors.less
  37. 99
      src/less/lib/constant.less
  38. 627
      src/router/0.router.js
  39. 3654
      src/router/router.js
  40. 4
      src/widget/multiselect/multiselect.insert.combo.js
  41. 4
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  42. 15
      src/widget/multiselect/trigger/searcher.multiselect.insert.js
  43. 21
      src/widget/multiselectlist/multiselectlist.insert.js
  44. 21
      src/widget/multiselectlist/multiselectlist.insert.nobar.js
  45. 25
      src/widget/singleselect/search/singleselect.search.loader.js
  46. 23
      src/widget/singleselect/singleselect.loader.js
  47. 2
      webpack/attachments.js
  48. 1
      webpack/dirs.js
  49. 2
      webpack/webpack.common.js

2
changelog.md

@ -1,5 +1,7 @@
# 更新日志 # 更新日志
2.0(2021-12) 2.0(2021-12)
- toast支持closable属性,可控制是否显示关闭按钮
- 新增气泡弹框控件
- BI.point支持widget添加埋点 - BI.point支持widget添加埋点
- childContext废弃,替换成provide - childContext废弃,替换成provide
- 支持BI.useContext获取上下文环境 - 支持BI.useContext获取上下文环境

26
dist/fix/fix.proxy.js vendored

@ -74,18 +74,21 @@
} }
function _iterableToArray(iter) { function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
} }
function _iterableToArrayLimit(arr, i) { function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = []; var _arr = [];
var _n = true; var _n = true;
var _d = false; var _d = false;
var _e = undefined;
var _s, _e;
try { try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value); _arr.push(_s.value);
if (i && _arr.length === i) break; if (i && _arr.length === i) break;
@ -130,9 +133,9 @@
} }
function _createForOfIteratorHelper(o, allowArrayLike) { function _createForOfIteratorHelper(o, allowArrayLike) {
var it; var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it; if (it) o = it;
var i = 0; var i = 0;
@ -165,7 +168,7 @@
err; err;
return { return {
s: function () { s: function () {
it = o[Symbol.iterator](); it = it.call(o);
}, },
n: function () { n: function () {
var step = it.next(); var step = it.next();
@ -1485,6 +1488,8 @@
return cRef; return cRef;
} }
Promise.resolve();
function noop() {} function noop() {}
function isNative(Ctor) { function isNative(Ctor) {
return typeof Ctor === "function" && /native code/.test(Ctor.toString()); return typeof Ctor === "function" && /native code/.test(Ctor.toString());
@ -1630,14 +1635,13 @@
} }
var queue = []; var queue = [];
var activatedChildren = [];
var has = {}; var has = {};
var waiting = false; var waiting = false;
var flushing = false; var flushing = false;
var index = 0; var index = 0;
function resetSchedulerState() { function resetSchedulerState() {
index = queue.length = activatedChildren.length = 0; index = queue.length = 0;
has = {}; has = {};
waiting = flushing = false; waiting = flushing = false;
} }
@ -2074,7 +2078,7 @@
return watchExp(_v2, _getter); return watchExp(_v2, _getter);
}, function (newValue, oldValue) { }, function (newValue, oldValue) {
// a.** 在a变化的时候不会触发change // a.** 在a变化的时候不会触发change
if (oldValue !== newValue) { if (!_.isArray(newValue) && oldValue !== newValue) {
return; return;
} }
@ -2144,7 +2148,7 @@
index: i index: i
})); }));
} }
}, BI.extend({}, options, { }, _.extend({}, options, {
deep: true, deep: true,
onTrigger: function onTrigger(_ref) { onTrigger: function onTrigger(_ref) {
var target = _ref.target, var target = _ref.target,

BIN
dist/font/iconfont.eot vendored

Binary file not shown.

6
dist/font/iconfont.svg vendored

@ -14,11 +14,11 @@
/> />
<missing-glyph /> <missing-glyph />
<glyph glyph-name="a-xiangxingtu3x" unicode="&#59525;" d="M341.333333 555.733333H279.466667V598.485333h-42.666667v-42.752H170.666667v-299.221333h66.133333v-85.504h42.666667v85.504H341.333333V555.733333zM596.010667 682.666667h-63.018667V768h-41.984v-85.333333H427.946667v-256h63.018666v-42.666667h41.984v42.666667h63.018667V682.666667z m-42.026667-213.333334h-83.968V640h83.968v-170.666667zM874.666667 1.322667h-725.333334a21.333333 21.333333 0 0 0 0 42.666666h725.333334a21.333333 21.333333 0 0 0 0-42.666666M789.333333 643.413333H853.333333v-171.008h-64v-130.389333h-42.666666V472.405333H682.666667V643.370667h64v40.618666h42.666666v-40.618666z" horiz-adv-x="1024" /> <glyph glyph-name="xiangxingtu" unicode="&#59528;" d="M332.032 582.4H253.632V640H199.68v-57.6H115.968v-403.2H199.68V64h54.016v115.2h78.336zM608 732.416H536V832h-48v-99.584H416v-298.624h72V384h48v49.792H608V732.416z m-48-248.832h-96v199.04h96v-199.04zM935.104-64H88.96C75.136-64 64-49.664 64-32s11.136 32 24.896 32H935.04c13.76 0 24.896-14.336 24.896-32s-11.136-32-24.896-32zM827.456 651.904h82.24V286.08H827.52V192h-54.912V286.144h-82.24V651.904h82.24V704h54.912z" horiz-adv-x="1024" />
<glyph glyph-name="a-sangjitu3x-1" unicode="&#59526;" d="M152.490667 582.229333c3.669333 3.456 37.546667 34.090667 94.72 48.341334 76.032 19.029333 155.562667 0.810667 236.373333-54.144 69.546667-47.274667 141.653333-71.509333 214.272-71.978667h2.218667c66.133333 0 120.234667 19.541333 156.885333 38.229333l3.498667-70.912L960 637.866667l-194.688 6.826666 63.573333-44.458666c-56.448-29.738667-170.368-64.384-308.906666 29.781333-54.144 36.821333-109.397333 59.776-164.181334 68.266667a309.12 309.12 0 0 1-130.261333-7.381334c-73.130667-20.138667-117.333333-61.397333-117.717333-61.781333a32.426667 32.426667 0 0 1-1.024-45.653333 32.426667 32.426667 0 0 1 45.696-1.194667z m713.472-175.573333c-6.101333-5.290667-152.149333-127.573333-347.008 4.906667-54.186667 36.778667-109.397333 59.733333-164.224 68.266666a309.077333 309.077333 0 0 1-130.218667-7.381333c-73.685333-20.352-117.290667-61.44-117.717333-61.824a32.170667 32.170667 0 0 1-0.938667-45.738667 32.128 32.128 0 0 1 45.738667-0.981333c0.341333 0.341333 34.261333 32.213333 93.098666 47.274667 75.861333 19.413333 158.122667 1.024 237.866667-53.162667 69.546667-47.317333 141.653333-71.509333 214.272-72.021333h2.176c125.098667 0 208.64 71.125333 209.493333 71.808a32.384 32.384 0 0 1-42.538666 48.853333z m-1.024-220.373333c-6.101333-5.248-152.149333-127.530667-347.008 4.949333-154.026667 104.704-280.618667 74.24-351.189334 39.210667l-3.2 64.725333L64 129.109333l194.688-6.826666-68.608 47.914666a245.717333 245.717333 0 0 0 53.205333 20.565334c52.992 13.653333 137.344 15.530667 238.250667-53.077334 68.949333-46.848 140.373333-71.082667 212.352-71.978666h4.096c123.861333 0 205.952 68.778667 209.493333 71.765333a32.426667 32.426667 0 0 1-42.496 48.810667z" horiz-adv-x="1024" /> <glyph glyph-name="sangjitu" unicode="&#59529;" d="M130.176 0L128 215.552l2.176-107.776L128 215.552c2.176 0 173.76 8.128 336.832 159.04C537.792 441.92 591.36 512 638.592 573.952c77.184 102.4 143.68 188.672 248.832 194.048L896 552.448c-38.592-2.752-75.072-48.512-135.168-129.344-49.28-64.704-111.552-145.536-195.2-223.68C355.392 5.376 138.752 0 130.176 0zM64 832h83.2v-896H64V832z m812.8 0H960v-896h-83.2V832zM925.696 128c-80 0-304 21.12-452.544 223.36C349.696 520.512 130.304 526.528 128 526.528L130.304 768c11.392 0 297.152-6.016 477.696-247.552 121.152-166.016 338.304-147.904 338.304-147.904L960 131.008c-4.544-3.008-16-3.008-34.304-3.008z m8.576-128c-73.92 0-272.64 17.664-406.592 191.552C382.144 383.168 130.304 389.12 128 389.12V448c11.52 0 272.64-2.944 432-215.168 145.6-191.552 395.072-170.88 397.44-170.88l2.24-59.008c2.304-2.944-9.216-2.944-25.408-2.944z" horiz-adv-x="1024" />
<glyph glyph-name="a-sangjitu3x" unicode="&#59527;" d="M169.898667 123.989333l-1.92 152.746667 1.92-76.373333-1.92 76.373333c1.92 0 154.794667 5.674667 299.989333 112.597333 64.981333 47.701333 112.725333 97.322667 154.752 141.226667 68.778667 72.533333 128 133.632 221.653333 137.429333l7.637334-152.704c-34.389333-1.877333-66.901333-34.346667-120.362667-91.605333-43.946667-45.824-99.370667-103.082667-173.866667-158.421333-187.264-137.429333-380.245333-141.226667-387.84-141.226667zM128 768h76.8v-768H128V768z m691.2 0H896v-768h-76.8V768zM835.328 250.154667c-66.944 0-254.293333 13.44-378.581333 141.653333-103.253333 107.221333-286.848 111.061333-288.768 111.061333l1.92 153.130667c9.557333 0 248.576-3.84 399.658666-156.970667 101.333333-105.301333 282.965333-93.781333 282.965334-93.781333l11.477333-153.173333c-3.84-1.92-13.397333-1.92-28.672-1.92z m5.717333-130.133334c-61.184 0-225.621333 11.477333-336.512 124.416-120.448 124.416-328.874667 128.256-330.794666 128.256v38.272c9.557333 0 225.621333-1.92 357.546666-139.733333 120.490667-124.416 326.997333-111.018667 328.874667-111.018667l1.92-38.314666c1.92-1.877333-7.68-1.877333-21.034667-1.877334z" horiz-adv-x="1024" /> <glyph glyph-name="liuxiangtu" unicode="&#59530;" d="M101.12 623.488c4.224 4.16 42.88 41.088 108.288 58.368 86.912 22.912 177.792 0.896 270.08-65.408 79.552-57.024 161.92-86.272 244.928-86.848h2.56c75.52 0 137.408 23.552 179.264 46.08l3.968-85.568L1024 690.56l-222.528 8.256 72.704-53.632c-64.512-35.904-194.752-77.76-353.024 35.904C459.264 725.568 396.096 753.28 333.44 763.52a335.104 335.104 0 0 1-148.8-8.832C101.056 730.24 50.56 680.448 50.112 680a40.704 40.704 0 0 1-1.216-55.04 35.712 35.712 0 0 1 52.224-1.472zM916.544 411.52c-7.04-6.4-173.888-153.92-396.608 5.952-61.888 44.416-124.992 72.128-187.648 82.368a335.104 335.104 0 0 1-148.864-8.96C99.2 466.496 49.408 416.896 48.896 416.384a39.936 39.936 0 0 1-11.392-27.328 40 40 0 0 1 10.304-27.84 35.648 35.648 0 0 1 52.288-1.152c0.384 0.32 39.168 38.848 106.432 57.024 86.656 23.424 180.672 1.28 271.872-64.192 79.488-57.088 161.856-86.336 244.864-86.912h2.496c142.912 0 238.464 85.824 239.36 86.656a40.64 40.64 0 0 1 3.52 54.976 35.712 35.712 0 0 1-52.096 3.968z m-1.152-265.92c-7.04-6.4-173.952-153.984-396.608 5.952-176 126.336-320.64 89.6-401.408 47.296l-3.584 78.08L0 76.544l222.528-8.256-78.4 57.856c16.32 9.088 36.736 18.304 60.8 24.832 60.544 16.512 156.928 18.752 272.256-64.064 78.784-56.576 160.448-85.76 242.688-86.848h2.176l2.56-0.064c141.504 0 235.328 83.072 239.36 86.656a40.704 40.704 0 0 1 3.52 55.04 35.712 35.712 0 0 1-52.096 3.84z" horiz-adv-x="1024" />
<glyph glyph-name="baocun" unicode="&#59043;" d="M160 800h704a64 64 0 0 0 64-64v-704a64 64 0 0 0-64-64h-704a64 64 0 0 0-64 64v704a64 64 0 0 0 64 64z m128-64h-128v-704h704v704h-128v-256a64 64 0 0 0-64-64h-320a64 64 0 0 0-64 64v256z m64 0v-256h320v256h-320z m256-32a32 32 0 0 0 32-32v-128a32 32 0 0 0-64 0v128a32 32 0 0 0 32 32z" horiz-adv-x="1024" /> <glyph glyph-name="baocun" unicode="&#59043;" d="M160 800h704a64 64 0 0 0 64-64v-704a64 64 0 0 0-64-64h-704a64 64 0 0 0-64 64v704a64 64 0 0 0 64 64z m128-64h-128v-704h704v704h-128v-256a64 64 0 0 0-64-64h-320a64 64 0 0 0-64 64v256z m64 0v-256h320v256h-320z m256-32a32 32 0 0 0 32-32v-128a32 32 0 0 0-64 0v128a32 32 0 0 0 32 32z" horiz-adv-x="1024" />

Before

Width:  |  Height:  |  Size: 456 KiB

After

Width:  |  Height:  |  Size: 455 KiB

BIN
dist/font/iconfont.ttf vendored

Binary file not shown.

BIN
dist/font/iconfont.woff vendored

Binary file not shown.

BIN
dist/font/iconfont.woff2 vendored

Binary file not shown.

3203
dist/router.js vendored

File diff suppressed because it is too large Load Diff

1
index.html

@ -11,5 +11,4 @@
<div id="wrapper"></div> <div id="wrapper"></div>
</body> </body>
<script src="./dist/demo.js"></script> <script src="./dist/demo.js"></script>
<script src="./dist/router.js"></script>
</html> </html>

2
package.json

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

513
src/base/combination/bubble.js

@ -0,0 +1,513 @@
!(function () {
/**
* @class BI.Bubble
* @extends BI.Widget
*/
BI.Bubble = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-popper",
attributes: {
tabIndex: -1
},
trigger: "click", // click || hover || click-hover || ""
toggle: true,
direction: "",
placement: "bottom-start", // top-start/top/top-end/bottom-start/bottom/bottom-end/left-start/left/left-end/right-start/right/right-end
logic: {
dynamic: true
},
container: null, // popupview放置的容器,默认为this.element
isDefaultInit: false,
destroyWhenHide: false,
hideWhenClickOutside: true,
showArrow: true,
hideWhenBlur: false,
isNeedAdjustHeight: true, // 是否需要高度调整
isNeedAdjustWidth: true,
stopEvent: false,
stopPropagation: false,
adjustLength: 0, // 调整的距离
adjustXOffset: 0,
adjustYOffset: 0,
hideChecker: BI.emptyFn,
offsetStyle: "left", // left,right,center
el: {},
popup: {},
comboClass: "bi-combo-popup",
hoverClass: "bi-combo-hover",
});
},
render: function () {
var self = this, o = this.options;
this._initCombo();
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
if (type === BI.Events.COLLAPSE) {
self._hideView();
}
if (type === BI.Events.EXPAND) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Bubble.EVENT_EXPAND);
}
if (type === BI.Events.COLLAPSE) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.isViewVisible() && self.fireEvent(BI.Bubble.EVENT_COLLAPSE);
}
if (type === BI.Events.CLICK) {
self.fireEvent(BI.Bubble.EVENT_TRIGGER_CHANGE, obj);
}
}
});
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.addClass(o.hoverClass);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.removeClass(o.hoverClass);
}
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: [
{el: this.combo}
]
}))));
o.isDefaultInit && (this._assertPopupView());
},
_toggle: function (e) {
this._assertPopupViewRender();
if (this.popupView.isVisible()) {
this._hideView(e);
} else {
if (this.isEnabled()) {
this._popupView(e);
}
}
},
_initPullDownAction: function () {
var self = this, o = this.options;
var evs = (this.options.trigger || "").split(",");
var st = function (e) {
if (o.stopEvent) {
e.stopEvent();
}
if (o.stopPropagation) {
e.stopPropagation();
}
};
var enterPopup = false;
function hide (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView(e);
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Bubble.EVENT_COLLAPSE);
}
self.popupView && self.popupView.element.off("mouseenter." + self.getName()).off("mouseleave." + self.getName());
enterPopup = false;
}
BI.each(evs, function (i, ev) {
switch (ev) {
case "hover":
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView(e);
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Bubble.EVENT_EXPAND);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.popupView) {
self.popupView.element.on("mouseenter." + self.getName(), function (e) {
enterPopup = true;
self.popupView.element.on("mouseleave." + self.getName(), function (e) {
hide(e);
});
self.popupView.element.off("mouseenter." + self.getName());
});
BI.defer(function () {
if (!enterPopup) {
hide(e);
}
}, 50);
}
});
break;
case "click":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
// if (!o.toggle && self.isViewVisible()) {
// return;
// }
o.toggle ? self._toggle(e) : self._popupView(e);
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Bubble.EVENT_EXPAND);
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Bubble.EVENT_COLLAPSE);
}
}
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
});
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e);
st(e);
});
break;
case "click-hover":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
// if (self.isViewVisible()) {
// return;
// }
self._popupView(e);
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Bubble.EVENT_EXPAND);
}
}
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
});
self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) {
debounce(e);
st(e);
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.popupView) {
self.popupView.element.on("mouseenter." + self.getName(), function (e) {
enterPopup = true;
self.popupView.element.on("mouseleave." + self.getName(), function (e) {
hide(e);
});
self.popupView.element.off("mouseenter." + self.getName());
});
BI.delay(function () {
if (!enterPopup) {
hide(e);
}
}, 50);
}
});
break;
}
});
},
_initCombo: function () {
this.combo = BI.createWidget(this.options.el, {
value: this.options.value
});
if (this.options.showArrow) {
this.arrow = BI.createWidget({
type: "bi.absolute",
cls: "bi-bubble-arrow",
items: [{
type: "bi.layout",
cls: "bubble-arrow"
}]
});
}
},
_assertPopupView: function () {
var self = this, o = this.options;
if (this.popupView == null) {
this.popupView = BI.createWidget(this.options.popup, {
type: "bi.bubble_popup_view",
value: o.value
}, this);
if (this.options.showArrow) {
BI.createWidget({
type: "bi.absolute",
element: this.popupView,
items: [{
el: this.arrow
}]
});
}
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.CLICK) {
self.combo.setValue(self.getValue());
self.fireEvent(BI.Bubble.EVENT_CHANGE, value, obj);
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.popupView.setVisible(false);
BI.nextTick(function () {
self.fireEvent(BI.Bubble.EVENT_AFTER_INIT);
});
}
},
_assertPopupViewRender: function () {
this._assertPopupView();
if (!this._rendered) {
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this.options.container || this,
items: [
{el: this.popupView}
]
});
this._rendered = true;
}
},
_hideIf: function (e, skipTriggerChecker) {
// if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) {
// return;
// }
// BI-10290 公式combo双击公式内容会收起
if (e && ((skipTriggerChecker !== true && this.element.find(e.target).length > 0)
|| (this.popupView && this.popupView.element.find(e.target).length > 0)
|| e.target.className === "CodeMirror-cursor" || BI.Widget._renderEngine.createElement(e.target).closest(".CodeMirror-hints").length > 0)) {// BI-9887 CodeMirror的公式弹框需要特殊处理下
var directions = this.options.direction.split(",");
if (BI.contains(directions, "innerLeft") || BI.contains(directions, "innerRight")) {
// popup可以出现在trigger内部的combo,滚动时不需要消失,而是调整位置
this.adjustWidth();
this.adjustHeight();
}
return;
}
var isHide = this.options.hideChecker.apply(this, [e]);
if (isHide === false) {
return;
}
this._hideView(e);
return true;
},
_hideView: function (e) {
var o = this.options;
this.fireEvent(BI.Bubble.EVENT_BEFORE_HIDEVIEW);
if (this.options.destroyWhenHide === true) {
this.popupView && this.popupView.destroy();
this.popupView = null;
this._rendered = false;
} else {
this.popupView && this.popupView.invisible();
}
if (!e || !this.combo.element.__isMouseInBounds__(e)) {
this.element.removeClass(this.options.hoverClass);
// 应对bi-focus-shadow在收起时不失焦
this.element.blur();
}
if (this.popper) {
this.popper.destroy();
this.popper = null;
}
this.element.removeClass(this.options.comboClass);
BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName());
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName());
this.fireEvent(BI.Bubble.EVENT_AFTER_HIDEVIEW);
},
_popupView: function (e) {
var self = this, o = this.options;
this._assertPopupViewRender();
this.fireEvent(BI.Bubble.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
this.popupView.css({left: -999999999, top: -99999999});
this.popupView.visible();
this.adjustWidth(e);
if (this.popper) {
this.popper.destroy();
}
var modifiers = [{
name: "offset",
options: {
offset: function () {
return [o.adjustXOffset, (o.showArrow ? 9 : 0) + (o.adjustYOffset || o.adjustLength)];
}
}
}];
if (this.options.showArrow) {
modifiers.push({
name: "arrow",
options: {
padding: 5,
element: this.arrow.element[0]
}
});
}
this.popper = BI.Popper.createPopper(this.combo.element[0], this.popupView.element[0], {
placement: o.placement,
strategy: "fixed",
modifiers: modifiers
});
// this.adjustHeight(e);
this.element.addClass(this.options.comboClass);
o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName());
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName());
o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).bind("mousedown." + this.getName(), BI.bind(this._hideIf, this));
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).bind("blur." + this.getName(), BI.bind(this._hideIf, this));
this.fireEvent(BI.Bubble.EVENT_AFTER_POPUPVIEW);
},
adjustWidth: function (e) {
var o = this.options;
if (!this.popupView) {
return;
}
if (o.isNeedAdjustWidth === true) {
this.resetListWidth("");
var width = this.popupView.element.outerWidth();
var maxW = this.element.outerWidth() || o.width;
// BI-93885 最大列宽算法调整
if (maxW < 500) {
if (width >= 500) {
maxW = 500;
} else if (width > maxW) {
// 防止小数导致差那么一点
maxW = width + 1;
}
}
// if (width > maxW + 80) {
// maxW = maxW + 80;
// } else if (width > maxW) {
// maxW = width;
// }
this.resetListWidth(maxW < 100 ? 100 : maxW);
}
},
adjustHeight: function () {
},
resetListHeight: function (h) {
this._assertPopupView();
this.popupView.resetHeight && this.popupView.resetHeight(h);
},
resetListWidth: function (w) {
this._assertPopupView();
this.popupView.resetWidth && this.popupView.resetWidth(w);
},
populate: function (items) {
this._assertPopupView();
this.popupView.populate.apply(this.popupView, arguments);
this.combo.populate && this.combo.populate.apply(this.combo, arguments);
},
_setEnable: function (arg) {
BI.Bubble.superclass._setEnable.apply(this, arguments);
if (arg === true) {
this.element.removeClass("base-disabled disabled");
} else if (arg === false) {
this.element.addClass("base-disabled disabled");
}
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {
this.combo.setValue(v);
if (BI.isNull(this.popupView)) {
this.options.popup.value = v;
} else {
this.popupView.setValue(v);
}
},
getValue: function () {
if (BI.isNull(this.popupView)) {
return this.options.popup.value;
} else {
return this.popupView.getValue();
}
},
isViewVisible: function () {
return this.isEnabled() && this.combo.isEnabled() && !!this.popupView && this.popupView.isVisible();
},
showView: function (e) {
// 减少popup 调整宽高的次数
if (this.isEnabled() && this.combo.isEnabled() && !this.isViewVisible()) {
this._popupView(e);
}
},
hideView: function (e) {
this._hideView(e);
},
getView: function () {
return this.popupView;
},
getPopupPosition: function () {
return this.position;
},
toggle: function () {
this._toggle();
},
destroyed: function () {
BI.Widget._renderEngine.createElement(document)
.unbind("click." + this.getName())
.unbind("mousedown." + this.getName())
.unbind("mouseenter." + this.getName())
.unbind("mouseleave." + this.getName());
BI.Widget._renderEngine.createElement(window)
.unbind("blur." + this.getName());
this.popper && this.popper.destroy();
this.popper = null;
this.popupView && this.popupView._destroy();
}
});
BI.Bubble.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
BI.Bubble.EVENT_CHANGE = "EVENT_CHANGE";
BI.Bubble.EVENT_EXPAND = "EVENT_EXPAND";
BI.Bubble.EVENT_COLLAPSE = "EVENT_COLLAPSE";
BI.Bubble.EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
BI.Bubble.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.Bubble.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW";
BI.Bubble.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW";
BI.Bubble.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
BI.shortcut("bi.bubble", BI.Bubble);
}());

285
src/base/combination/combo.js

@ -4,9 +4,9 @@
* @class BI.Combo * @class BI.Combo
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.Combo = BI.inherit(BI.Widget, { BI.Combo = BI.inherit(BI.Bubble, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""),
attributes: { attributes: {
@ -23,6 +23,7 @@
destroyWhenHide: false, destroyWhenHide: false,
hideWhenBlur: true, hideWhenBlur: true,
hideWhenAnotherComboOpen: false, hideWhenAnotherComboOpen: false,
hideWhenClickOutside: true,
isNeedAdjustHeight: true, // 是否需要高度调整 isNeedAdjustHeight: true, // 是否需要高度调整
isNeedAdjustWidth: true, isNeedAdjustWidth: true,
stopEvent: false, stopEvent: false,
@ -43,7 +44,8 @@
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this._initCombo(); this._initCombo();
this._initPullDownAction(); // 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
@ -93,137 +95,6 @@
}, this)); }, this));
}, },
_toggle: function (e) {
this._assertPopupViewRender();
if (this.popupView.isVisible()) {
this._hideView(e);
} else {
if (this.isEnabled()) {
this._popupView(e);
}
}
},
_initPullDownAction: function () {
var self = this, o = this.options;
var evs = (this.options.trigger || "").split(",");
var st = function (e) {
if (o.stopEvent) {
e.stopEvent();
}
if (o.stopPropagation) {
e.stopPropagation();
}
};
var enterPopup = false;
function hide(e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView(e);
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
}
self.popupView && self.popupView.element.off("mouseenter." + self.getName()).off("mouseleave." + self.getName());
enterPopup = false;
}
BI.each(evs, function (i, ev) {
switch (ev) {
case "hover":
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView(e);
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.popupView) {
self.popupView.element.on("mouseenter." + self.getName(), function (e) {
enterPopup = true;
self.popupView.element.on("mouseleave." + self.getName(), function (e) {
hide(e);
});
self.popupView.element.off("mouseenter." + self.getName());
});
BI.defer(function () {
if (!enterPopup) {
hide(e);
}
}, 50);
}
});
break;
case "click":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
// if (!o.toggle && self.isViewVisible()) {
// return;
// }
o.toggle ? self._toggle(e) : self._popupView(e);
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
}
}
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
});
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e);
st(e);
});
break;
case "click-hover":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
// if (self.isViewVisible()) {
// return;
// }
self._popupView(e);
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
}
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
});
self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) {
debounce(e);
st(e);
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.popupView) {
self.popupView.element.on("mouseenter." + self.getName(), function (e) {
enterPopup = true;
self.popupView.element.on("mouseleave." + self.getName(), function (e) {
hide(e);
});
self.popupView.element.off("mouseenter." + self.getName());
});
BI.delay(function () {
if (!enterPopup) {
hide(e);
}
}, 50);
}
});
break;
}
});
},
_initCombo: function () { _initCombo: function () {
this.combo = BI.createWidget(this.options.el, { this.combo = BI.createWidget(this.options.el, {
value: this.options.value value: this.options.value
@ -251,46 +122,6 @@
} }
}, },
_assertPopupViewRender: function () {
this._assertPopupView();
if (!this._rendered) {
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this.options.container || this,
items: [
{ el: this.popupView }
]
});
this._rendered = true;
}
},
_hideIf: function (e, skipTriggerChecker) {
// if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) {
// return;
// }
// BI-10290 公式combo双击公式内容会收起
if (e && ((skipTriggerChecker !== true && this.element.find(e.target).length > 0)
|| (this.popupView && this.popupView.element.find(e.target).length > 0)
|| e.target.className === "CodeMirror-cursor" || BI.Widget._renderEngine.createElement(e.target).closest(".CodeMirror-hints").length > 0)) {// BI-9887 CodeMirror的公式弹框需要特殊处理下
var directions = this.options.direction.split(",");
if (BI.contains(directions, "innerLeft") || BI.contains(directions, "innerRight")) {
// popup可以出现在trigger内部的combo,滚动时不需要消失,而是调整位置
this.adjustWidth();
this.adjustHeight();
}
return;
}
var isHide = this.options.hideChecker.apply(this, [e]);
if (isHide === false) {
return;
}
this._hideView(e);
return true;
},
_hideView: function (e) { _hideView: function (e) {
var o = this.options; var o = this.options;
this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW); this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW);
@ -335,42 +166,16 @@
this.adjustHeight(e); this.adjustHeight(e);
this.element.addClass(this.options.comboClass); this.element.addClass(this.options.comboClass);
BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName());
BI.Widget._renderEngine.createElement(document).unbind("mousewheel." + this.getName());
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName()); BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName());
BI.Widget._renderEngine.createElement(document).bind("mousedown." + this.getName(), BI.bind(this._hideIf, this)).bind("mousewheel." + this.getName(), BI.bind(this._hideIf, this)); o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).bind("mousedown." + this.getName(), BI.bind(this._hideIf, this)).bind("mousewheel." + this.getName(), BI.bind(this._hideIf, this));
BI.Widget._renderEngine.createElement(document).bind("mousewheel." + this.getName(), BI.bind(this._hideIf, this));
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).bind("blur." + this.getName(), BI.bind(this._hideIf, this)); BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).bind("blur." + this.getName(), BI.bind(this._hideIf, this));
this.fireEvent(BI.Combo.EVENT_AFTER_POPUPVIEW); this.fireEvent(BI.Combo.EVENT_AFTER_POPUPVIEW);
}, },
adjustWidth: function (e) {
var o = this.options;
if (!this.popupView) {
return;
}
if (o.isNeedAdjustWidth === true) {
this.resetListWidth("");
var width = this.popupView.element.outerWidth();
var maxW = this.element.outerWidth() || o.width;
// BI-93885 最大列宽算法调整
if (maxW < 500) {
if (width >= 500) {
maxW = 500;
} else if(width > maxW) {
// 防止小数导致差那么一点
maxW = width + 1;
}
}
// if (width > maxW + 80) {
// maxW = maxW + 80;
// } else if (width > maxW) {
// maxW = width;
// }
this.resetListWidth(maxW < 100 ? 100 : maxW);
}
},
adjustHeight: function (e) { adjustHeight: function (e) {
var o = this.options, p = {}; var o = this.options, p = {};
if (!this.popupView) { if (!this.popupView) {
@ -483,84 +288,12 @@
this.popupView.setVisible(isVisible); this.popupView.setVisible(isVisible);
}, },
resetListHeight: function (h) {
this._assertPopupView();
this.popupView.resetHeight && this.popupView.resetHeight(h);
},
resetListWidth: function (w) {
this._assertPopupView();
this.popupView.resetWidth && this.popupView.resetWidth(w);
},
populate: function (items) {
this._assertPopupView();
this.popupView.populate.apply(this.popupView, arguments);
this.combo.populate && this.combo.populate.apply(this.combo, arguments);
},
_setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments);
if (arg === true) {
this.element.removeClass("base-disabled disabled");
} else if (arg === false) {
this.element.addClass("base-disabled disabled");
}
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {
this.combo.setValue(v);
if (BI.isNull(this.popupView)) {
this.options.popup.value = v;
} else {
this.popupView.setValue(v);
}
},
getValue: function () {
if (BI.isNull(this.popupView)) {
return this.options.popup.value;
} else {
return this.popupView.getValue();
}
},
isViewVisible: function () {
return this.isEnabled() && this.combo.isEnabled() && !!this.popupView && this.popupView.isVisible();
},
showView: function (e) {
// 减少popup 调整宽高的次数
if (this.isEnabled() && this.combo.isEnabled() && !this.isViewVisible()) {
this._popupView(e);
}
},
hideView: function (e) {
this._hideView(e);
},
getView: function () {
return this.popupView;
},
getPopupPosition: function () {
return this.position;
},
toggle: function () {
this._toggle();
},
destroyed: function () { destroyed: function () {
BI.Widget._renderEngine.createElement(document) BI.Widget._renderEngine.createElement(document)
.unbind("click." + this.getName()) .unbind("click." + this.getName())
.unbind("mousedown." + this.getName()) .unbind("mousedown." + this.getName())
.unbind("mousewheel." + this.getName()) .unbind("mousewheel." + this.getName())
.unbind("mouseenter." + this.getName()) .unbind("mouseenter." + this.getName())
.unbind("mousemove." + this.getName())
.unbind("mouseleave." + this.getName()); .unbind("mouseleave." + this.getName());
BI.Widget._renderEngine.createElement(window) BI.Widget._renderEngine.createElement(window)
.unbind("blur." + this.getName()); .unbind("blur." + this.getName());

3
src/base/combination/expander.js

@ -25,7 +25,8 @@ BI.Expander = BI.inherit(BI.Widget, {
var self = this, o = this.options; var self = this, o = this.options;
this._expanded = !!o.el.open; this._expanded = !!o.el.open;
this._initExpander(); this._initExpander();
this._initPullDownAction(); // 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {

3
src/base/combination/switcher.js

@ -25,7 +25,8 @@ BI.Switcher = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this._initSwitcher(); this._initSwitcher();
this._initPullDownAction(); // 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {

5
src/base/foundation/message.js

@ -32,6 +32,7 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
closable: options.closable,
text: message, text: message,
listeners: [{ listeners: [{
eventName: BI.Toast.EVENT_DESTORY, eventName: BI.Toast.EVENT_DESTORY,
@ -67,6 +68,10 @@ BI.Msg = function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy(); toast.destroy();
}, 5000); }, 5000);
return function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy();
};
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
BI.isNull($mask) && ($mask = BI.Widget._renderEngine.createElement("<div class=\"bi-z-index-mask\">").css({ BI.isNull($mask) && ($mask = BI.Widget._renderEngine.createElement("<div class=\"bi-z-index-mask\">").css({

12
src/base/list/virtualgrouplist.js

@ -55,18 +55,10 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
mounted: function () { mounted: function () {
var self = this, o = this.options; var self = this, o = this.options;
this._populate(); this._populate();
this._debounceRelease = BI.debounce(function () { this.element.scroll(BI.debounce(function (e) {
self._scrollLock = false;
}, 30);
this.element.scroll(function (e) {
if (self._scrollLock === true) {
return;
}
self._scrollLock = true;
o.scrollTop = self.element.scrollTop(); o.scrollTop = self.element.scrollTop();
self._debounceRelease();
self._calculateBlocksToRender(); self._calculateBlocksToRender();
}); }, 30));
BI.ResizeDetector.addResizeListener(this, function () { BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender(); self._calculateBlocksToRender();
}); });

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

@ -44,7 +44,8 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (this.options.selected === true) { if (this.options.selected === true) {
this.setSelected(true); this.setSelected(true);
} }
this.bindEvent(); // 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this.bindEvent.bind(this));
BI.BasicButton.superclass._initRef.apply(this, arguments); BI.BasicButton.superclass._initRef.apply(this, arguments);
}, },

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

@ -61,7 +61,7 @@ BI.Button = BI.inherit(BI.BasicButton, {
type: "bi.icon_label", type: "bi.icon_label",
cls: o.iconCls, cls: o.iconCls,
width: this._const.iconWidth, width: this._const.iconWidth,
height: o.height, height: lineHeight,
lineHeight: lineHeight, lineHeight: lineHeight,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight
@ -71,7 +71,7 @@ BI.Button = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
textWidth: BI.isNotNull(o.textWidth) ? o.textWidth - this._const.iconWidth : null, textWidth: BI.isNotNull(o.textWidth) ? o.textWidth - this._const.iconWidth : null,
textHeight: textHeight, textHeight: textHeight,
height: o.height, height: lineHeight,
value: o.value value: o.value
}); });
BI.createWidget({ BI.createWidget({

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

@ -15,7 +15,9 @@ BI.Toast = BI.inherit(BI.Tip, {
return BI.extend(BI.Toast.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.Toast.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-toast", extraCls: "bi-toast",
text: "", text: "",
level: "success" // success或warning level: "success", // success或warning
autoClose: true,
closable: null
}); });
}, },
@ -56,6 +58,9 @@ BI.Toast = BI.inherit(BI.Tip, {
break; break;
} }
var hasCloseIcon = function () {
return o.closable === true || (o.closable === null && o.autoClose === false);
};
var items = [{ var items = [{
type: "bi.icon_label", type: "bi.icon_label",
cls: cls + " toast-icon", cls: cls + " toast-icon",
@ -68,12 +73,12 @@ BI.Toast = BI.inherit(BI.Tip, {
textHeight: 16, textHeight: 16,
textAlign: "left" textAlign: "left"
}, },
rgap: o.autoClose ? this._const.hgap : 0 rgap: hasCloseIcon() ? 0 : this._const.hgap
}]; }];
var columnSize = [36, "fill"]; var columnSize = [36, "fill"];
if (o.autoClose === false) { if (hasCloseIcon()) {
items.push({ items.push({
type: "bi.icon_button", type: "bi.icon_button",
cls: "close-font toast-icon", cls: "close-font toast-icon",

2
src/case/button/item.singleselect.js

@ -21,8 +21,6 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
title: o.title || o.text,
warningTitle: o.warningTitle,
py: o.py py: o.py
}); });
}, },

2
src/case/checkbox/check.arrownode.js

@ -5,7 +5,7 @@
BI.ArrowTreeGroupNodeCheckbox = BI.inherit(BI.IconButton, { BI.ArrowTreeGroupNodeCheckbox = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.ArrowTreeGroupNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.ArrowTreeGroupNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-arrow-group-node-checkbox" extraCls: "bi-arrow-group-node-checkbox expander-right-font"
}); });
}, },

5
src/case/checkbox/check.checkingmarknode.js

@ -6,14 +6,9 @@
BI.CheckingMarkNode = BI.inherit(BI.IconButton, { BI.CheckingMarkNode = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend( BI.CheckingMarkNode.superclass._defaultConfig.apply(this, arguments), { return BI.extend( BI.CheckingMarkNode.superclass._defaultConfig.apply(this, arguments), {
extraCls: "check-mark-font"
}); });
}, },
_init: function () {
BI.CheckingMarkNode.superclass._init.apply(this, arguments);
this.setSelected(this.options.selected);
},
setSelected: function (v) { setSelected: function (v) {
BI.CheckingMarkNode.superclass.setSelected.apply(this, arguments); BI.CheckingMarkNode.superclass.setSelected.apply(this, arguments);
if(v === true) { if(v === true) {

283
src/case/colorchooser/colorchooser.popup.hex.js

@ -16,32 +16,59 @@ BI.HexColorChooserPopup = BI.inherit(BI.Widget, {
var self = this, o = this.options; var self = this, o = this.options;
var hasRecommendColors = BI.isNotNull(o.recommendColorsGetter()); var hasRecommendColors = BI.isNotNull(o.recommendColorsGetter());
return [{ return [{
el: { type: "bi.vertical",
type: 'bi.vertical', items: [{
items: [{ el: {
el: { type: "bi.vertical",
type: "bi.vertical", hgap: 15,
hgap: 15, items: [BI.extend({
items: [BI.extend({ type: o.simple ? "bi.simple_hex_color_picker_editor" : "bi.hex_color_picker_editor",
type: o.simple ? "bi.simple_hex_color_picker_editor" : "bi.hex_color_picker_editor", value: o.value,
height: o.simple ? 36 : 70,
listeners: [{
eventName: BI.ColorPickerEditor.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self._dealStoreColors();
self.fireEvent(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, arguments);
}
}],
ref: function (_ref) {
self.colorEditor = _ref;
}
}, o.editor), {
el: {
type: "bi.hex_color_picker",
cls: "bi-border-bottom bi-border-right",
items: [this._digestStoreColors(this._getStoreColors())],
height: 22,
value: o.value, value: o.value,
height: o.simple ? 36 : 70,
listeners: [{ listeners: [{
eventName: BI.ColorPickerEditor.EVENT_CHANGE, eventName: BI.ColorPicker.EVENT_CHANGE,
action: function () { action: function () {
self.setValue(this.getValue()); self.setValue(this.getValue()[0]);
self._dealStoreColors(); self._dealStoreColors();
self.fireEvent(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, arguments); self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
} }
}], }],
ref: function (_ref) { ref: function (_ref) {
self.colorEditor = _ref; self.storeColors = _ref;
} }
}, o.editor), { },
el: { tgap: 10,
height: 22
}, {
el: hasRecommendColors ? {
type: "bi.vertical",
items: [{
type: "bi.label",
text: BI.i18nText("BI-Basic_Recommend_Color"),
textAlign: "left",
height: 24
}, {
type: "bi.hex_color_picker", type: "bi.hex_color_picker",
cls: "bi-border-bottom bi-border-right", cls: "bi-border-bottom bi-border-right",
items: [this._digestStoreColors(this._getStoreColors())], items: [this._digestStoreColors(o.recommendColorsGetter())],
height: 22, height: 22,
value: o.value, value: o.value,
listeners: [{ listeners: [{
@ -53,144 +80,111 @@ BI.HexColorChooserPopup = BI.inherit(BI.Widget, {
} }
}], }],
ref: function (_ref) { ref: function (_ref) {
self.storeColors = _ref; self.recommendColors = _ref;
} }
}, }]
tgap: 10, } : {type: "bi.layout"},
height: 22 tgap: hasRecommendColors ? 10 : 0,
}, { height: hasRecommendColors ? 47 : 0
el: hasRecommendColors ? { }, {
type: 'bi.vertical',
items: [{
type: 'bi.label',
text: BI.i18nText('BI-Basic_Recommend_Color'),
textAlign: 'left',
height: 24,
}, {
type: "bi.hex_color_picker",
cls: "bi-border-bottom bi-border-right",
items: [this._digestStoreColors(o.recommendColorsGetter())],
height: 22,
value: o.value,
listeners: [{
eventName: BI.ColorPicker.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue()[0]);
self._dealStoreColors();
self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
}
}],
ref: function (_ref) {
self.recommendColors = _ref;
}
}]
} : { type: 'bi.layout' },
tgap: hasRecommendColors ? 10 : 0,
height: hasRecommendColors ? 47 : 0
}, {
el: {
type: 'bi.layout',
cls: 'bi-border-top',
},
vgap: 10,
height: 1
}, {
type: 'bi.absolute',
items: [{
el: {
type: "bi.hex_color_picker",
space: true,
value: o.value,
listeners: [{
eventName: BI.ColorPicker.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue()[0]);
self._dealStoreColors();
self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
}
}],
ref: function (_ref) {
self.colorPicker = _ref;
},
},
top: 0,
left: 0,
right: 0,
bottom: 1,
}],
height: 80,
}]
}
}, {
el: {
type: "bi.combo",
cls: "bi-border-top",
container: null,
direction: "right,top",
isNeedAdjustHeight: false,
el: { el: {
type: "bi.text_item", type: "bi.layout",
cls: "color-chooser-popup-more bi-list-item", cls: "bi-border-top"
textAlign: "center",
height: 24,
textLgap: 10,
text: BI.i18nText("BI-Basic_More") + "..."
}, },
popup: { vgap: 10,
type: "bi.popup_panel", height: 1
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")], }, {
title: BI.i18nText("BI-Custom_Color"), type: "bi.absolute",
items: [{
el: { el: {
type: "bi.custom_color_chooser", type: "bi.hex_color_picker",
editor: o.editor, space: true,
value: o.value,
listeners: [{
eventName: BI.ColorPicker.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue()[0]);
self._dealStoreColors();
self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
}
}],
ref: function (_ref) { ref: function (_ref) {
self.customColorChooser = _ref; self.colorPicker = _ref;
} }
}, },
stopPropagation: false, top: 0,
bgap: -1, left: 0,
rgap: 1, right: 0,
lgap: 1, bottom: 1
minWidth: 227, }],
listeners: [{ height: 80
eventName: BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON, }]
action: function (index) { }
switch (index) { }, {
case 0: el: {
self.more.hideView(); type: "bi.combo",
break; cls: "bi-border-top",
case 1: container: null,
var color = self.customColorChooser.getValue(); direction: "right,top",
// farbtastic选择器没有透明和自动选项,点击保存不应该设置透明 isNeedAdjustHeight: false,
if (BI.isNotEmptyString(color)) { el: {
self.setValue(color); type: "bi.text_item",
self._dealStoreColors(); cls: "color-chooser-popup-more bi-list-item",
} textAlign: "center",
self.more.hideView(); height: 24,
self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); textLgap: 10,
break; text: BI.i18nText("BI-Basic_More") + "..."
} },
} popup: {
}] type: "bi.popup_panel",
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")],
title: BI.i18nText("BI-Custom_Color"),
el: {
type: "bi.custom_color_chooser",
editor: o.editor,
ref: function (_ref) {
self.customColorChooser = _ref;
}
}, },
stopPropagation: false,
bgap: -1,
rgap: 1,
lgap: 1,
minWidth: 227,
listeners: [{ listeners: [{
eventName: BI.Combo.EVENT_AFTER_POPUPVIEW, eventName: BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON,
action: function () { action: function (index) {
self.customColorChooser.setValue(self.getValue()); switch (index) {
case 0:
self.more.hideView();
break;
case 1:
var color = self.customColorChooser.getValue();
// farbtastic选择器没有透明和自动选项,点击保存不应该设置透明
if (BI.isNotEmptyString(color)) {
self.setValue(color);
self._dealStoreColors();
}
self.more.hideView();
self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
break;
}
} }
}], }]
ref: function (_ref) {
self.more = _ref;
}
}, },
tgap: 10, listeners: [{
height: 24 eventName: BI.Combo.EVENT_AFTER_POPUPVIEW,
}] action: function () {
}, self.customColorChooser.setValue(self.getValue());
left: 0, }
right: 0, }],
top: 0, ref: function (_ref) {
bottom: 0 self.more = _ref;
}
},
tgap: 10,
height: 24
}]
}, { }, {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [{
@ -212,7 +206,6 @@ BI.HexColorChooserPopup = BI.inherit(BI.Widget, {
// 这里就实现的不好了,setValue里面有个editor,editor的setValue会检测错误然后出bubble提示 // 这里就实现的不好了,setValue里面有个editor,editor的setValue会检测错误然后出bubble提示
mounted: function () { mounted: function () {
var self = this;
var o = this.options; var o = this.options;
if (BI.isNotNull(o.value)) { if (BI.isNotNull(o.value)) {
this.setValue(o.value); this.setValue(o.value);
@ -251,7 +244,7 @@ BI.HexColorChooserPopup = BI.inherit(BI.Widget, {
return items; return items;
}, },
_getStoreColors: function() { _getStoreColors: function () {
var self = this, o = this.options; var self = this, o = this.options;
var colorsArray = BI.string2Array(BI.Cache.getItem("colors") || ""); var colorsArray = BI.string2Array(BI.Cache.getItem("colors") || "");
return BI.filter(colorsArray, function (idx, color) { return BI.filter(colorsArray, function (idx, color) {

2
src/case/colorchooser/colorpicker/colorpicker.hex.js

@ -110,8 +110,6 @@ BI.HexColorPicker = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.colors = BI.createWidget();
return { return {
type: "bi.button_group", type: "bi.button_group",
items: this._digest(o.items || this._items), items: this._digest(o.items || this._items),

2
src/case/colorchooser/colorpicker/editor.colorpicker.hex.js

@ -61,7 +61,7 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
tgap: 10, tgap: 10,
items: [{ items: [{
type: 'bi.vertical_adapt', type: 'bi.vertical_adapt',
columnSize: [0.5, 'fill'], columnSize: ["fill", 'fill'],
height: 24, height: 24,
items: [{ items: [{
type: "bi.color_picker_show_button", type: "bi.color_picker_show_button",

1
src/case/combo/bubblecombo/combo.bubble.js

@ -137,6 +137,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
this.triangle && this.triangle.destroy(); this.triangle && this.triangle.destroy();
this.triangle = BI.createWidget(op, { this.triangle = BI.createWidget(op, {
type: "bi.center_adapt", type: "bi.center_adapt",
scrollable: false,
cls: "button-combo-triangle-wrapper", cls: "button-combo-triangle-wrapper",
items: [{ items: [{
type: "bi.layout", type: "bi.layout",

4
src/case/combo/iconcombo/trigger.iconcombo.js

@ -42,9 +42,9 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, {
cls: "icon-combo-down-icon trigger-triangle-font font-size-12", cls: "icon-combo-down-icon trigger-triangle-font font-size-12",
width: 12, width: 12,
height: 8, height: 8,
selected: BI.isNotEmptyString(iconCls) selected: BI.isNotEmptyString(iconCls),
invisible: !o.isShowDown
}); });
this.down.setVisible(o.isShowDown);
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,

24
src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js

@ -17,11 +17,7 @@ BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
ref: function () { ref: function () {
self.popup = this; self.popup = this;
}, },
items: BI.createItems(o.items, { items: this._formatItems(o.items),
type: "bi.single_select_item",
textAlign: o.textAlign,
height: 24
}),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
@ -45,6 +41,18 @@ BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
}; };
}, },
_formatItems: function (items) {
var o = this.options;
return BI.map(items, function (i, item) {
return BI.extend({
type: "bi.single_select_item",
textAlign: o.textAlign,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
title: item.title || item.text
}, item);
});
},
// mounted之后做check // mounted之后做check
mounted: function() { mounted: function() {
this.check(); this.check();
@ -53,11 +61,7 @@ BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
populate: function (find, match, keyword) { populate: function (find, match, keyword) {
var items = BI.concat(find, match); var items = BI.concat(find, match);
BI.SearchTextValueComboPopup.superclass.populate.apply(this, items); BI.SearchTextValueComboPopup.superclass.populate.apply(this, items);
items = BI.createItems(items, { this.popup.populate(this._formatItems(items), keyword);
type: "bi.single_select_item",
height: 24
});
this.popup.populate(items, keyword);
}, },
getValue: function () { getValue: function () {

5
src/case/combo/textvaluecheckcombo/popup.textvaluecheck.js

@ -35,11 +35,14 @@ BI.TextValueCheckComboPopup = BI.inherit(BI.Pane, {
}, },
_formatItems: function (items) { _formatItems: function (items) {
var o = this.options;
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
return BI.extend({ return BI.extend({
type: "bi.single_select_item", type: "bi.single_select_item",
cls: "bi-list-item", cls: "bi-list-item",
height: 24 textAlign: o.textAlign,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
title: item.title || item.text
}, item); }, item);
}); });
}, },

24
src/case/combo/textvaluecombo/popup.textvalue.js

@ -11,11 +11,7 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
var o = this.options, self = this; var o = this.options, self = this;
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.button_group", type: "bi.button_group",
items: BI.createItems(o.items, { items: this._formatItems(o.items),
type: "bi.single_select_item",
textAlign: o.textAlign,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}),
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
@ -39,13 +35,21 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
}); });
}, },
_formatItems: function (items) {
var o = this.options;
return BI.map(items, function (i, item) {
return BI.extend({
type: "bi.single_select_item",
textAlign: o.textAlign,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
title: item.title || item.text
}, item);
});
},
populate: function (items) { populate: function (items) {
BI.TextValueComboPopup.superclass.populate.apply(this, arguments); BI.TextValueComboPopup.superclass.populate.apply(this, arguments);
items = BI.createItems(items, { this.popup.populate(this._formatItems(items));
type: "bi.single_select_item",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
});
this.popup.populate(items);
}, },
getValue: function () { getValue: function () {

7
src/case/editor/editor.clear.js

@ -32,6 +32,7 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
this.clear = BI.createWidget({ this.clear = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
stopEvent: true, stopEvent: true,
invisible: !BI.isKey(o.value),
cls: "search-close-h-font" cls: "search-close-h-font"
}); });
this.clear.on(BI.IconButton.EVENT_CHANGE, function () { this.clear.on(BI.IconButton.EVENT_CHANGE, function () {
@ -113,12 +114,6 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
this.editor.on(BI.Editor.EVENT_STOP, function () { this.editor.on(BI.Editor.EVENT_STOP, function () {
self.fireEvent(BI.ClearEditor.EVENT_STOP); self.fireEvent(BI.ClearEditor.EVENT_STOP);
}); });
if (BI.isKey(o.value)) {
this.clear.visible();
} else {
this.clear.invisible();
}
}, },
_checkClear: function () { _checkClear: function () {

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

@ -10,7 +10,7 @@ BI.SegmentButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.SegmentButton.superclass._defaultConfig.apply(this, arguments); var conf = BI.SegmentButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-segment-button bi-list-item-select", baseCls: (conf.baseCls || "") + " bi-segment-button bi-list-item-select bi-card",
shadow: true, shadow: true,
readonly: true, readonly: true,
hgap: 5 hgap: 5

2
src/core/platform/web/function.js

@ -44,7 +44,7 @@ _.extend(BI, {
if(!_global.navigator) { if(!_global.navigator) {
return false; return false;
} }
return /edge/i.test(navigator.userAgent.toLowerCase()); return /edg/i.test(navigator.userAgent.toLowerCase());
}, },
isChrome: function () { isChrome: function () {

61
src/less/base/combo/combo.bubble.less

@ -32,7 +32,68 @@
} }
} }
.bi-popup-view[data-popper-placement^='top'] {
> .bi-bubble-arrow {
bottom: -10px;
> .bubble-arrow {
bottom: 6px;
}
}
}
.bi-popup-view[data-popper-placement^='bottom'] {
> .bi-bubble-arrow {
top: -10px;
> .bubble-arrow {
top: 6px;
}
}
}
.bi-popup-view[data-popper-placement^='left'] {
> .bi-bubble-arrow {
right: -10px;
> .bubble-arrow {
right: 6px;
}
}
}
.bi-popup-view[data-popper-placement^='right'] {
> .bi-bubble-arrow {
left: -10px;
> .bubble-arrow {
left: 6px;
}
}
}
.bi-bubble-arrow {
width: 10px;
height: 10px;
overflow: hidden;
.bubble-arrow {
width: 10px;
height: 10px;
position: absolute;
&:before {
width: 10px;
height: 10px;
position: absolute;
content: "";
background: @color-bi-background-default;
top: 0;
left: 0;
transition: transform 0.2s ease-out 0s, visibility 0.2s ease-out 0s;
visibility: visible;
transform: translateX(0px) rotate(-135deg);
transform-origin: center center;
.box-shadow(3px 3px 10px 0,rgba(0,0,0,6%));
}
}
}
.bi-theme-dark { .bi-theme-dark {
.bubble-arrow:before {
background: @color-bi-background-default-theme-dark;
}
.bi-bubble-combo { .bi-bubble-combo {
& .bubble-combo-triangle-left, & .bubble-combo-triangle-right, & .bubble-combo-triangle-top, & .bubble-combo-triangle-bottom { & .bubble-combo-triangle-left, & .bubble-combo-triangle-right, & .bubble-combo-triangle-top, & .bubble-combo-triangle-bottom {
&:before { &:before {

2
src/less/base/segment/segment.less

@ -3,7 +3,6 @@
.bi-segment{ .bi-segment{
& > .center-element{ & > .center-element{
.overflow-hidden(); .overflow-hidden();
background: @color-bi-background-default;
border-right: 1px solid @color-bi-border-highlight; border-right: 1px solid @color-bi-border-highlight;
border-top: 1px solid @color-bi-border-highlight; border-top: 1px solid @color-bi-border-highlight;
border-bottom: 1px solid @color-bi-border-highlight; border-bottom: 1px solid @color-bi-border-highlight;
@ -24,7 +23,6 @@
.bi-segment { .bi-segment {
& > .center-element{ & > .center-element{
.overflow-hidden(); .overflow-hidden();
background: @color-bi-background-default-theme-dark;
border-right: 1px solid @color-bi-border-line-theme-dark; border-right: 1px solid @color-bi-border-line-theme-dark;
border-top: 1px solid @color-bi-border-line-theme-dark; border-top: 1px solid @color-bi-border-line-theme-dark;
border-bottom: 1px solid @color-bi-border-line-theme-dark; border-bottom: 1px solid @color-bi-border-line-theme-dark;

53
src/less/lib/colors.less

@ -126,56 +126,3 @@
@color-bi-border-warning: @border-color-warning; @color-bi-border-warning: @border-color-warning;
//边框提亮 //边框提亮
@color-bi-border-highlight: @border-color-highlight; @color-bi-border-highlight: @border-color-highlight;
//颜色百分比
//green
@color-bi-green-80: fade(@font-color-success, 80);
@color-bi-green-60: fade(@font-color-success, 60);
@color-bi-green-40: fade(@font-color-success, 40);
@color-bi-green-30: fade(@font-color-success, 30);
@color-bi-green-20: fade(@font-color-success, 20);
@color-bi-green-10: fade(@font-color-success, 10);
@color-bi-green-5: fade(@font-color-success, 5);
//blue
@color-bi-blue-80: fade(@font-color-highlight, 80);
@color-bi-blue-60: fade(@font-color-highlight, 60);
@color-bi-blue-40: fade(@font-color-highlight, 40);
@color-bi-blue-30: fade(@font-color-highlight, 30);
@color-bi-blue-20: fade(@font-color-highlight, 20);
@color-bi-blue-10: fade(@font-color-highlight, 10);
@color-bi-blue-5: fade(@font-color-highlight, 5);
//light-blue
@color-bi-light-blue-80: fade(@font-color-light-highlight, 80);
@color-bi-light-blue-60: fade(@font-color-light-highlight, 60);
@color-bi-light-blue-40: fade(@font-color-light-highlight, 40);
@color-bi-light-blue-30: fade(@font-color-light-highlight, 30);
@color-bi-light-blue-20: fade(@font-color-light-highlight, 20);
@color-bi-light-blue-10: fade(@font-color-light-highlight, 10);
@color-bi-light-blue-5: fade(@font-color-light-highlight, 5);
// orange
@color-bi-orange-80: fade(@font-color-warning, 80);
@color-bi-orange-60: fade(@font-color-warning, 60);
@color-bi-orange-40: fade(@font-color-warning, 40);
@color-bi-orange-30: fade(@font-color-warning, 30);
@color-bi-orange-20: fade(@font-color-warning, 20);
@color-bi-orange-10: fade(@font-color-warning, 10);
@color-bi-orange-5: fade(@font-color-warning, 5);
// red
@color-bi-red-80: fade(@font-color-negative, 80);
@color-bi-red-60: fade(@font-color-negative, 60);
@color-bi-red-40: fade(@font-color-negative, 40);
@color-bi-red-30: fade(@font-color-negative, 30);
@color-bi-red-20: fade(@font-color-negative, 20);
@color-bi-red-10: fade(@font-color-negative, 10);
@color-bi-red-5: fade(@font-color-negative, 5);
// yellow
@color-bi-yellow-80: fade(@font-color-yellow, 90);
@color-bi-yellow-60: fade(@font-color-yellow, 60);
@color-bi-yellow-40: fade(@font-color-yellow, 40);
@color-bi-yellow-20: fade(@font-color-yellow, 20);
@color-bi-yellow-5: fade(@font-color-yellow, 5);

99
src/less/lib/constant.less

@ -20,6 +20,75 @@
@opacity-15: 0.15; @opacity-15: 0.15;
@opacity-20: 0.2; @opacity-20: 0.2;
//色板
//green
@color-bi-green-100: #13cd66;
@color-bi-green-80: fade(@color-bi-green-100, 80);
@color-bi-green-60: fade(@color-bi-green-100, 60);
@color-bi-green-40: fade(@color-bi-green-100, 40);
@color-bi-green-30: fade(@color-bi-green-100, 30);
@color-bi-green-20: fade(@color-bi-green-100, 20);
@color-bi-green-10: fade(@color-bi-green-100, 10);
@color-bi-green-5: fade(@color-bi-green-100, 5);
//cyan
@color-bi-green-100: #13cd66;
@color-bi-green-80: fade(@color-bi-green-100, 80);
@color-bi-green-60: fade(@color-bi-green-100, 60);
@color-bi-green-40: fade(@color-bi-green-100, 40);
@color-bi-green-30: fade(@color-bi-green-100, 30);
@color-bi-green-20: fade(@color-bi-green-100, 20);
@color-bi-green-10: fade(@color-bi-green-100, 10);
@color-bi-green-5: fade(@color-bi-green-100, 5);
//blue
@color-bi-blue-100: #3685f2;
@color-bi-blue-80: fade(@color-bi-blue-100, 80);
@color-bi-blue-60: fade(@color-bi-blue-100, 60);
@color-bi-blue-40: fade(@color-bi-blue-100, 40);
@color-bi-blue-30: fade(@color-bi-blue-100, 30);
@color-bi-blue-20: fade(@color-bi-blue-100, 20);
@color-bi-blue-10: fade(@color-bi-blue-100, 10);
@color-bi-blue-5: fade(@color-bi-blue-100, 5);
//light-blue
@color-bi-light-blue-100: #eaf2fd;
@color-bi-light-blue-80: fade(@color-bi-light-blue-100, 80);
@color-bi-light-blue-60: fade(@color-bi-light-blue-100, 60);
@color-bi-light-blue-40: fade(@color-bi-light-blue-100, 40);
@color-bi-light-blue-30: fade(@color-bi-light-blue-100, 30);
@color-bi-light-blue-20: fade(@color-bi-light-blue-100, 20);
@color-bi-light-blue-10: fade(@color-bi-light-blue-100, 10);
@color-bi-light-blue-5: fade(@color-bi-light-blue-100, 5);
// orange
@color-bi-orange-100: #faaa39;
@color-bi-orange-80: fade(@color-bi-orange-100, 80);
@color-bi-orange-60: fade(@color-bi-orange-100, 60);
@color-bi-orange-40: fade(@color-bi-orange-100, 40);
@color-bi-orange-30: fade(@color-bi-orange-100, 30);
@color-bi-orange-20: fade(@color-bi-orange-100, 20);
@color-bi-orange-10: fade(@color-bi-orange-100, 10);
@color-bi-orange-5: fade(@color-bi-orange-100, 5);
// red
@color-bi-red-100: #e65251;
@color-bi-red-80: fade(@color-bi-red-100, 80);
@color-bi-red-60: fade(@color-bi-red-100, 60);
@color-bi-red-40: fade(@color-bi-red-100, 40);
@color-bi-red-30: fade(@color-bi-red-100, 30);
@color-bi-red-20: fade(@color-bi-red-100, 20);
@color-bi-red-10: fade(@color-bi-red-100, 10);
@color-bi-red-5: fade(@color-bi-red-100, 5);
// yellow
@font-color-yellow-100: #ffc101;
@color-bi-yellow-80: fade(@font-color-yellow-100, 90);
@color-bi-yellow-60: fade(@font-color-yellow-100, 60);
@color-bi-yellow-40: fade(@font-color-yellow-100, 40);
@color-bi-yellow-20: fade(@font-color-yellow-100, 20);
@color-bi-yellow-5: fade(@font-color-yellow-100, 5);
//font color //font color
@font-color-black: #232e40; @font-color-black: #232e40;
@font-color-normal: #3d4d66; @font-color-normal: #3d4d66;
@ -35,15 +104,15 @@
@font-color-gray: #999999; @font-color-gray: #999999;
@font-color-white: #ffffff; @font-color-white: #ffffff;
@font-color-white-theme-dark: #20263b; @font-color-white-theme-dark: #20263b;
@font-color-light-highlight: #eaf2fd; @font-color-light-highlight: @color-bi-light-blue-100;
@font-color-medium-highlight: #d7e7fc; @font-color-medium-highlight: #d7e7fc;
@font-color-highlight: #3685f2; @font-color-highlight: @color-bi-blue-100;
@font-color-blue: #23beef; @font-color-blue: #23beef;
@font-color-light-blue: #e9f8fd; @font-color-light-blue: #e9f8fd;
@font-color-success: #13cd66; @font-color-success: @color-bi-green-100;
@font-color-warning: #faaa39; @font-color-warning: @color-bi-orange-100;
@font-color-negative: #e65251; @font-color-negative: @color-bi-red-100;
@font-color-yellow: #ffc101; @font-color-yellow: @font-color-yellow-100;
//background color //background color
@background-color-black: #232E40; @background-color-black: #232E40;
@ -54,9 +123,9 @@
@background-color-default-theme-dark: #20263b; @background-color-default-theme-dark: #20263b;
@background-color-normal: #f7f8fa; @background-color-normal: #f7f8fa;
@background-color-normal-theme-dark: #191b2b; @background-color-normal-theme-dark: #191b2b;
@background-color-light-highlight: #eaf2fd; @background-color-light-highlight: @color-bi-light-blue-100;
@background-color-medium-highlight: #d7e7fc; @background-color-medium-highlight: #d7e7fc;
@background-color-highlight: #3685f2; @background-color-highlight: @color-bi-blue-100;
@background-color-blue: #23beef; @background-color-blue: #23beef;
@background-color-light-blue: #e9f8fd; @background-color-light-blue: #e9f8fd;
@background-color-dark: #d4dadd; @background-color-dark: #d4dadd;
@ -70,15 +139,15 @@
@background-color-disabled-theme-dark: #292f45; @background-color-disabled-theme-dark: #292f45;
@background-color-light-disabled: #9ea6b2; @background-color-light-disabled: #9ea6b2;
@background-color-light-disabled-theme-dark: #878d9f; @background-color-light-disabled-theme-dark: #878d9f;
@background-color-yellow: #ffc101; @background-color-yellow: @font-color-yellow-100;
@background-color-negative: #e65251; @background-color-negative: @color-bi-red-100;
@background-color-light-negative: #ffecec; @background-color-light-negative: #ffecec;
@background-color-dark-negative: #3A2940; @background-color-dark-negative: #3A2940;
@background-color-light-warning: #feeed7; @background-color-light-warning: #feeed7;
@background-color-warning: #faaa39; @background-color-warning: @color-bi-orange-100;
@background-color-dark-success: #13cd66; @background-color-dark-success: @color-bi-green-100;
@background-color-light-success: #e1f4e7; @background-color-light-success: #e1f4e7;
@background-color-normal-success: #647185; @background-color-normal-success: #647185;
@ -93,11 +162,11 @@
@border-color-dark-gray-line-theme-dark: #606479; @border-color-dark-gray-line-theme-dark: #606479;
@border-color-dark-line: #9ea6b2; @border-color-dark-line: #9ea6b2;
@border-color-dark-line-theme-dark: #878d9f; @border-color-dark-line-theme-dark: #878d9f;
@border-color-highlight: #3685f2; @border-color-highlight: @color-bi-blue-100;
@border-color-success: #13cd66; @border-color-success: @color-bi-green-100;
@border-color-warning: #fbb03b; @border-color-warning: #fbb03b;
@border-color-negative: #e65251; @border-color-negative: @color-bi-red-100;
@border-color-light-negative: #f4cbcb; @border-color-light-negative: #f4cbcb;
@border-color-normal-success: #647185; @border-color-normal-success: #647185;

627
src/router/0.router.js

@ -0,0 +1,627 @@
(function () {
var Events = {
// Bind an event to a `callback` function. Passing `"all"` will bind
// the callback to all events fired.
on: function (name, callback, context) {
if (!eventsApi(this, "on", name, [callback, context]) || !callback) return this;
this._events || (this._events = {});
var events = this._events[name] || (this._events[name] = []);
events.push({callback: callback, context: context, ctx: context || this});
return this;
},
// Bind an event to only be triggered a single time. After the first time
// the callback is invoked, it will be removed.
once: function (name, callback, context) {
if (!eventsApi(this, "once", name, [callback, context]) || !callback) return this;
var self = this;
var once = _.once(function () {
self.off(name, once);
callback.apply(this, arguments);
});
once._callback = callback;
return this.on(name, once, context);
},
// Remove one or many callbacks. If `context` is null, removes all
// callbacks with that function. If `callback` is null, removes all
// callbacks for the event. If `name` is null, removes all bound
// callbacks for all events.
off: function (name, callback, context) {
if (!this._events || !eventsApi(this, "off", name, [callback, context])) return this;
// Remove all callbacks for all events.
if (!name && !callback && !context) {
this._events = void 0;
return this;
}
var names = name ? [name] : _.keys(this._events);
for (var i = 0, length = names.length; i < length; i++) {
name = names[i];
// Bail out if there are no events stored.
var events = this._events[name];
if (!events) continue;
// Remove all callbacks for this event.
if (!callback && !context) {
delete this._events[name];
continue;
}
// Find any remaining events.
var remaining = [];
for (var j = 0, k = events.length; j < k; j++) {
var event = events[j];
if (
callback && callback !== event.callback &&
callback !== event.callback._callback ||
context && context !== event.context
) {
remaining.push(event);
}
}
// Replace events if there are any remaining. Otherwise, clean up.
if (remaining.length) {
this._events[name] = remaining;
} else {
delete this._events[name];
}
}
return this;
},
un: function () {
this.off.apply(this, arguments);
},
// Trigger one or many events, firing all bound callbacks. Callbacks are
// passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to
// receive the true name of the event as the first argument).
trigger: function (name) {
if (!this._events) return this;
var args = slice.call(arguments, 1);
if (!eventsApi(this, "trigger", name, args)) return this;
var events = this._events[name];
var allEvents = this._events.all;
if (events) triggerEvents(events, args);
if (allEvents) triggerEvents(allEvents, arguments);
return this;
},
fireEvent: function () {
this.trigger.apply(this, arguments);
},
// Inversion-of-control versions of `on` and `once`. Tell *this* object to
// listen to an event in another object ... keeping track of what it's
// listening to.
listenTo: function (obj, name, callback) {
var listeningTo = this._listeningTo || (this._listeningTo = {});
var id = obj._listenId || (obj._listenId = _.uniqueId("l"));
listeningTo[id] = obj;
if (!callback && typeof name === "object") callback = this;
obj.on(name, callback, this);
return this;
},
listenToOnce: function (obj, name, callback) {
if (typeof name === "object") {
for (var event in name) this.listenToOnce(obj, event, name[event]);
return this;
}
if (eventSplitter.test(name)) {
var names = name.split(eventSplitter);
for (var i = 0, length = names.length; i < length; i++) {
this.listenToOnce(obj, names[i], callback);
}
return this;
}
if (!callback) return this;
var once = _.once(function () {
this.stopListening(obj, name, once);
callback.apply(this, arguments);
});
once._callback = callback;
return this.listenTo(obj, name, once);
},
// Tell this object to stop listening to either specific events ... or
// to every object it's currently listening to.
stopListening: function (obj, name, callback) {
var listeningTo = this._listeningTo;
if (!listeningTo) return this;
var remove = !name && !callback;
if (!callback && typeof name === "object") callback = this;
if (obj) (listeningTo = {})[obj._listenId] = obj;
for (var id in listeningTo) {
obj = listeningTo[id];
obj.off(name, callback, this);
if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id];
}
return this;
}
};
// Regular expression used to split event strings.
var eventSplitter = /\s+/;
// Implement fancy features of the Events API such as multiple event
// names `"change blur"` and jQuery-style event maps `{change: action}`
// in terms of the existing API.
var eventsApi = function (obj, action, name, rest) {
if (!name) return true;
// Handle event maps.
if (typeof name === "object") {
for (var key in name) {
obj[action].apply(obj, [key, name[key]].concat(rest));
}
return false;
}
// Handle space separated event names.
if (eventSplitter.test(name)) {
var names = name.split(eventSplitter);
for (var i = 0, length = names.length; i < length; i++) {
obj[action].apply(obj, [names[i]].concat(rest));
}
return false;
}
return true;
};
// A difficult-to-believe, but optimized internal dispatch function for
// triggering events. Tries to keep the usual cases speedy (most internal
// BI events have 3 arguments).
var triggerEvents = function (events, args) {
var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
switch (args.length) {
case 0:
while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
return;
case 2:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
return;
case 3:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
return;
default:
while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
return;
}
};
// BI.Router
// ---------------
// Routers map faux-URLs to actions, and fire events when routes are
// matched. Creating a new one sets its `routes` hash, if not set statically.
var Router = BI.Router = function (options) {
options || (options = {});
if (options.routes) this.routes = options.routes;
this._bindRoutes();
this._init.apply(this, arguments);
};
// Cached regular expressions for matching named param parts and splatted
// parts of route strings.
var optionalParam = /\((.*?)\)/g;
var namedParam = /(\(\?)?:\w+/g;
var splatParam = /\*\w+/g;
var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
// Set up all inheritable **BI.Router** properties and methods.
_.extend(Router.prototype, Events, {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function () {
},
// Manually bind a single named route to a callback. For example:
//
// this.route('search/:query/p:num', 'search', function(query, num) {
// ...
// });
//
route: function (route, name, callback) {
if (!_.isRegExp(route)) route = this._routeToRegExp(route);
if (_.isFunction(name)) {
callback = name;
name = "";
}
if (!callback) callback = this[name];
var router = this;
BI.history.route(route, function (fragment) {
var args = router._extractParameters(route, fragment);
if (router.execute(callback, args, name) !== false) {
router.trigger.apply(router, ["route:" + name].concat(args));
router.trigger("route", name, args);
BI.history.trigger("route", router, name, args);
}
});
return this;
},
// Execute a route handler with the provided parameters. This is an
// excellent place to do pre-route setup or post-route cleanup.
execute: function (callback, args, name) {
if (callback) callback.apply(this, args);
},
// Simple proxy to `BI.history` to save a fragment into the history.
navigate: function (fragment, options) {
BI.history.navigate(fragment, options);
return this;
},
// Bind all defined routes to `BI.history`. We have to reverse the
// order of the routes here to support behavior where the most general
// routes can be defined at the bottom of the route map.
_bindRoutes: function () {
if (!this.routes) return;
this.routes = _.result(this, "routes");
var route, routes = _.keys(this.routes);
while ((route = routes.pop()) != null) {
this.route(route, this.routes[route]);
}
},
// Convert a route string into a regular expression, suitable for matching
// against the current location hash.
_routeToRegExp: function (route) {
route = route.replace(escapeRegExp, "\\$&")
.replace(optionalParam, "(?:$1)?")
.replace(namedParam, function (match, optional) {
return optional ? match : "([^/?]+)";
})
.replace(splatParam, "([^?]*?)");
return new RegExp("^" + route + "(?:\\?([\\s\\S]*))?$");
},
// Given a route, and a URL fragment that it matches, return the array of
// extracted decoded parameters. Empty or unmatched parameters will be
// treated as `null` to normalize cross-browser behavior.
_extractParameters: function (route, fragment) {
var params = route.exec(fragment).slice(1);
return _.map(params, function (param, i) {
// Don't decode the search params.
if (i === params.length - 1) return param || null;
var resultParam = null;
if (param) {
try {
resultParam = decodeURIComponent(param);
} catch (e) {
resultParam = param;
}
}
return resultParam;
});
}
});
// History
// ----------------
// Handles cross-browser history management, based on either
// [pushState](http://diveintohtml5.info/history.html) and real URLs, or
// [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)
// and URL fragments. If the browser supports neither (old IE, natch),
// falls back to polling.
var History = function () {
this.handlers = [];
this.checkUrl = _.bind(this.checkUrl, this);
// Ensure that `History` can be used outside of the browser.
if (typeof window !== "undefined") {
this.location = _global.location;
this.history = _global.history;
}
};
// Cached regex for stripping a leading hash/slash and trailing space.
var routeStripper = /^[#\/]|\s+$/g;
// Cached regex for stripping leading and trailing slashes.
var rootStripper = /^\/+|\/+$/g;
// Cached regex for stripping urls of hash.
var pathStripper = /#.*$/;
// Has the history handling already been started?
History.started = false;
// Set up all inheritable **BI.History** properties and methods.
_.extend(History.prototype, Events, {
// The default interval to poll for hash changes, if necessary, is
// twenty times a second.
interval: 50,
// Are we at the app root?
atRoot: function () {
var path = this.location.pathname.replace(/[^\/]$/, "$&/");
return path === this.root && !this.getSearch();
},
// In IE6, the hash fragment and search params are incorrect if the
// fragment contains `?`.
getSearch: function () {
var match = this.location.href.replace(/#.*/, "").match(/\?.+/);
return match ? match[0] : "";
},
// Gets the true hash value. Cannot use location.hash directly due to bug
// in Firefox where location.hash will always be decoded.
getHash: function (window) {
var match = (window || this).location.href.match(/#(.*)$/);
return match ? match[1] : "";
},
// Get the pathname and search params, without the root.
getPath: function () {
var path = this.location.pathname + this.getSearch();
try {
path = decodeURI(path);
} catch(e) {
}
var root = this.root.slice(0, -1);
if (!path.indexOf(root)) path = path.slice(root.length);
return path.charAt(0) === "/" ? path.slice(1) : path;
},
// Get the cross-browser normalized URL fragment from the path or hash.
getFragment: function (fragment) {
if (fragment == null) {
if (this._hasPushState || !this._wantsHashChange) {
fragment = this.getPath();
} else {
fragment = this.getHash();
}
}
return fragment.replace(routeStripper, "");
},
// Start the hash change handling, returning `true` if the current URL matches
// an existing route, and `false` otherwise.
start: function (options) {
if (History.started) throw new Error("BI.history has already been started");
History.started = true;
// Figure out the initial configuration. Do we need an iframe?
// Is pushState desired ... is it available?
this.options = _.extend({root: "/"}, this.options, options);
this.root = this.options.root;
this._wantsHashChange = this.options.hashChange !== false;
this._hasHashChange = "onhashchange" in window;
this._wantsPushState = !!this.options.pushState;
this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
this.fragment = this.getFragment();
// Normalize root to always include a leading and trailing slash.
this.root = ("/" + this.root + "/").replace(rootStripper, "/");
// Transition from hashChange to pushState or vice versa if both are
// requested.
if (this._wantsHashChange && this._wantsPushState) {
// If we've started off with a route from a `pushState`-enabled
// browser, but we're currently in a browser that doesn't support it...
if (!this._hasPushState && !this.atRoot()) {
var root = this.root.slice(0, -1) || "/";
this.location.replace(root + "#" + this.getPath());
// Return immediately as browser will do redirect to new url
return true;
// Or if we've started out with a hash-based route, but we're currently
// in a browser where it could be `pushState`-based instead...
} else if (this._hasPushState && this.atRoot()) {
this.navigate(this.getHash(), {replace: true});
}
}
// Proxy an iframe to handle location events if the browser doesn't
// support the `hashchange` event, HTML5 history, or the user wants
// `hashChange` but not `pushState`.
if (!this._hasHashChange && this._wantsHashChange && (!this._wantsPushState || !this._hasPushState)) {
var iframe = document.createElement("iframe");
iframe.src = "javascript:0";
iframe.style.display = "none";
iframe.tabIndex = -1;
var body = document.body;
// Using `appendChild` will throw on IE < 9 if the document is not ready.
this.iframe = body.insertBefore(iframe, body.firstChild).contentWindow;
this.iframe.document.open().close();
this.iframe.location.hash = "#" + this.fragment;
}
// Add a cross-platform `addEventListener` shim for older browsers.
var addEventListener = _global.addEventListener || function (eventName, listener) {
return attachEvent("on" + eventName, listener);
};
// Depending on whether we're using pushState or hashes, and whether
// 'onhashchange' is supported, determine how we check the URL state.
if (this._hasPushState) {
addEventListener("popstate", this.checkUrl, false);
} else if (this._wantsHashChange && this._hasHashChange && !this.iframe) {
addEventListener("hashchange", this.checkUrl, false);
} else if (this._wantsHashChange) {
this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
}
if (!this.options.silent) return this.loadUrl();
},
// Disable BI.history, perhaps temporarily. Not useful in a real app,
// but possibly useful for unit testing Routers.
stop: function () {
// Add a cross-platform `removeEventListener` shim for older browsers.
var removeEventListener = _global.removeEventListener || function (eventName, listener) {
return detachEvent("on" + eventName, listener);
};
// Remove window listeners.
if (this._hasPushState) {
removeEventListener("popstate", this.checkUrl, false);
} else if (this._wantsHashChange && this._hasHashChange && !this.iframe) {
removeEventListener("hashchange", this.checkUrl, false);
}
// Clean up the iframe if necessary.
if (this.iframe) {
document.body.removeChild(this.iframe.frameElement);
this.iframe = null;
}
// Some environments will throw when clearing an undefined interval.
if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
History.started = false;
},
// Add a route to be tested when the fragment changes. Routes added later
// may override previous routes.
route: function (route, callback) {
this.handlers.unshift({route: route, callback: callback});
},
// check route is Exist. if exist, return the route
checkRoute: function (route) {
for (var i = 0; i < this.handlers.length; i++) {
if (this.handlers[i].route.toString() === Router.prototype._routeToRegExp(route).toString()) {
return this.handlers[i];
}
}
return null;
},
// remove a route match in routes
unRoute: function (route) {
var index = _.findIndex(this.handlers, function (handler) {
return handler.route.test(route);
});
if (index > -1) {
this.handlers.splice(index, 1);
}
},
// Checks the current URL to see if it has changed, and if it has,
// calls `loadUrl`, normalizing across the hidden iframe.
checkUrl: function (e) {
var current = this.getFragment();
try {
// getFragment 得到的值是编码过的,而this.fragment是没有编码过的
// 英文路径没有问题,遇上中文和空格有问题了
current = decodeURIComponent(current);
} catch(e) {
}
// If the user pressed the back button, the iframe's hash will have
// changed and we should use that for comparison.
if (current === this.fragment && this.iframe) {
current = this.getHash(this.iframe);
}
if (current === this.fragment) return false;
if (this.iframe) this.navigate(current);
this.loadUrl();
},
// Attempt to load the current URL fragment. If a route succeeds with a
// match, returns `true`. If no defined routes matches the fragment,
// returns `false`.
loadUrl: function (fragment) {
fragment = this.fragment = this.getFragment(fragment);
return _.some(this.handlers, function (handler) {
if (handler.route.test(fragment)) {
handler.callback(fragment);
return true;
}
});
},
// Save a fragment into the hash history, or replace the URL state if the
// 'replace' option is passed. You are responsible for properly URL-encoding
// the fragment in advance.
//
// The options object can contain `trigger: true` if you wish to have the
// route callback be fired (not usually desirable), or `replace: true`, if
// you wish to modify the current URL without adding an entry to the history.
navigate: function (fragment, options) {
if (!History.started) return false;
if (!options || options === true) options = {trigger: !!options};
// Normalize the fragment.
fragment = this.getFragment(fragment || "");
// Don't include a trailing slash on the root.
var root = this.root;
if (fragment === "" || fragment.charAt(0) === "?") {
root = root.slice(0, -1) || "/";
}
var url = root + fragment;
// Strip the hash and decode for matching.
fragment = fragment.replace(pathStripper, "")
try {
fragment = decodeURI(fragment);
} catch(e) {
}
if (this.fragment === fragment) return;
this.fragment = fragment;
// If pushState is available, we use it to set the fragment as a real URL.
if (this._hasPushState) {
this.history[options.replace ? "replaceState" : "pushState"]({}, document.title, url);
// If hash changes haven't been explicitly disabled, update the hash
// fragment to store history.
} else if (this._wantsHashChange) {
this._updateHash(this.location, fragment, options.replace);
if (this.iframe && (fragment !== this.getHash(this.iframe))) {
// Opening and closing the iframe tricks IE7 and earlier to push a
// history entry on hash-tag change. When replace is true, we don't
// want this.
if (!options.replace) this.iframe.document.open().close();
this._updateHash(this.iframe.location, fragment, options.replace);
}
// If you've told us that you explicitly don't want fallback hashchange-
// based history, then `navigate` becomes a page refresh.
} else {
return this.location.assign(url);
}
if (options.trigger) return this.loadUrl(fragment);
},
// Update the hash location, either replacing the current entry, or adding
// a new one to the browser history.
_updateHash: function (location, fragment, replace) {
if (replace) {
var href = location.href.replace(/(javascript:|#).*$/, "");
location.replace(href + "#" + fragment);
} else {
// Some browsers require that `hash` contains a leading #.
location.hash = "#" + fragment;
}
}
});
// Create the default BI.history.
BI.history = new History;
}());

3654
src/router/router.js

File diff suppressed because it is too large Load Diff

4
src/widget/multiselect/multiselect.insert.combo.js

@ -81,7 +81,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords.slice(0, 2000), function () { self._joinKeywords(keywords, function () {
if (BI.endWith(last, BI.BlankSplitChar)) { if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
assertShowValue(); assertShowValue();
@ -93,7 +93,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
} }
self._dataChange = true; self._dataChange = true;
}); });
keywords.length > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); this.getSearcher().getKeywordsLength() > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
} }
self.fireEvent(BI.MultiSelectInsertCombo.EVENT_SEARCHING); self.fireEvent(BI.MultiSelectInsertCombo.EVENT_SEARCHING);
}); });

4
src/widget/multiselect/multiselect.insert.combo.nobar.js

@ -76,7 +76,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords.slice(0, 2000), function () { self._joinKeywords(keywords, function () {
if (BI.endWith(last, BI.BlankSplitChar)) { if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
assertShowValue(); assertShowValue();
@ -88,7 +88,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
} }
self._dataChange = true; self._dataChange = true;
}); });
keywords.length > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); this.getSearcher().getKeywordsLength() > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
} }
}); });

15
src/widget/multiselect/trigger/searcher.multiselect.insert.js

@ -89,7 +89,7 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
}); });
this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
var keywords = this.getKeywords(); var keywords = this.getKeywords();
self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, keywords); self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000));
}); });
if (BI.isNotNull(o.value)) { if (BI.isNotNull(o.value)) {
this.setState(o.value); this.setState(o.value);
@ -108,8 +108,19 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
this.searcher.stopSearch(); this.searcher.stopSearch();
}, },
getKeywordsLength: function () {
var keywords = this.editor.getKeywords();
return keywords[keywords.length - 1] === BI.BlankSplitChar ? keywords.length - 1 : keywords.length;
},
getKeyword: function () { getKeyword: function () {
return this.editor.getKeyword(); var keywords = this.editor.getKeywords().slice(0, 2000);
if (keywords[keywords.length - 1] === BI.BlankSplitChar) {
keywords = keywords.slice(0, keywords.length - 1);
}
return BI.isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
}, },
hasMatched: function () { hasMatched: function () {

21
src/widget/multiselectlist/multiselectlist.insert.js

@ -101,7 +101,11 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
}, { }, {
eventName: BI.Searcher.EVENT_PAUSE, eventName: BI.Searcher.EVENT_PAUSE,
action: function () { action: function () {
var keyword = this.getKeyword(); var keywords = self._getKeywords();
if (keywords[keywords.length - 1] === BI.BlankSplitChar) {
keywords = keywords.slice(0, keywords.length - 1);
}
var keyword = BI.isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
@ -126,7 +130,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords.slice(0, 2000), function () { self._joinKeywords(keywords, function () {
if (BI.endWith(last, BI.BlankSplitChar)) { if (BI.endWith(last, BI.BlankSplitChar)) {
self.adapter.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
@ -138,7 +142,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
} }
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
}); });
keywords.length > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); self._getKeywordsLength() > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
} }
} }
}, { }, {
@ -191,10 +195,17 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
keywords = keywords.slice(0, keywords.length - 1); keywords = keywords.slice(0, keywords.length - 1);
} }
if (/\u200b\s\u200b$/.test(val)) { if (/\u200b\s\u200b$/.test(val)) {
return keywords.concat([BI.BlankSplitChar]); keywords = keywords.concat([BI.BlankSplitChar]);
} }
return keywords; return keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000);
},
_getKeywordsLength: function () {
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
return keywords.length - 1;
}, },
_showAdapter: function () { _showAdapter: function () {

21
src/widget/multiselectlist/multiselectlist.insert.nobar.js

@ -105,7 +105,11 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
}, { }, {
eventName: BI.Searcher.EVENT_PAUSE, eventName: BI.Searcher.EVENT_PAUSE,
action: function () { action: function () {
var keyword = this.getKeyword(); var keywords = self._getKeywords();
if (keywords[keywords.length - 1] === BI.BlankSplitChar) {
keywords = keywords.slice(0, keywords.length - 1);
}
var keyword = BI.isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
@ -129,7 +133,7 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords.slice(0, 2000), function () { self._joinKeywords(keywords, function () {
if (BI.endWith(last, BI.BlankSplitChar)) { if (BI.endWith(last, BI.BlankSplitChar)) {
self.adapter.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
@ -141,7 +145,7 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
} }
self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
}); });
keywords.length > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); self._getKeywordsLength() > 2000 && BI.Msg.alert(BI.i18nText("BI-Basic_Prompt"), BI.i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
} }
} }
}, { }, {
@ -197,10 +201,17 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
keywords = keywords.slice(0, keywords.length - 1); keywords = keywords.slice(0, keywords.length - 1);
} }
if (/\u200b\s\u200b$/.test(val)) { if (/\u200b\s\u200b$/.test(val)) {
return keywords.concat([BI.BlankSplitChar]); keywords = keywords.concat([BI.BlankSplitChar]);
} }
return keywords; return keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000);
},
_getKeywordsLength: function () {
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
return keywords.length - 1;
}, },
_showAdapter: function () { _showAdapter: function () {

25
src/widget/singleselect/search/singleselect.search.loader.js

@ -10,6 +10,9 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
return BI.extend(BI.SingleSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SingleSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-select-search-loader", baseCls: "bi-single-select-search-loader",
allowNoSelect: false, allowNoSelect: false,
logic: {
dynamic: false
},
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
keywordGetter: BI.emptyFn, keywordGetter: BI.emptyFn,
valueFormatter: BI.emptyFn valueFormatter: BI.emptyFn
@ -86,16 +89,18 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
}, },
_createItems: function (items) { _createItems: function (items) {
return BI.createItems(items, { var o = this.options;
type: this.options.allowNoSelect ? "bi.single_select_item" : "bi.single_select_radio_item", return BI.map(items, function (i, item) {
cls: "bi-list-item-active", return BI.extend({
logic: { type: o.allowNoSelect ? "bi.single_select_item" : "bi.single_select_radio_item",
dynamic: false logic: o.logic,
}, cls: "bi-list-item-active",
height: 25, height: 24,
selected: false, selected: false,
iconWrapperWidth: 26, iconWrapperWidth: 26,
hgap: this.options.allowNoSelect ? 10 : 0 hgap: o.allowNoSelect ? 10 : 0,
title: item.title || item.text
}, item);
}); });
}, },

23
src/widget/singleselect/singleselect.loader.js

@ -108,14 +108,18 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
_createItems: function (items) { _createItems: function (items) {
return BI.createItems(items, { var o = this.options;
type: this.options.allowNoSelect ? "bi.single_select_item" : "bi.single_select_radio_item", return BI.map(items, function (i, item) {
logic: this.options.logic, return BI.extend({
cls: "bi-list-item-active", type: o.allowNoSelect ? "bi.single_select_item" : "bi.single_select_radio_item",
height: 24, logic: o.logic,
selected: false, cls: "bi-list-item-active",
iconWrapperWidth: 26, height: 24,
hgap: this.options.allowNoSelect ? 10 : 0 selected: false,
iconWrapperWidth: 26,
hgap: o.allowNoSelect ? 10 : 0,
title: item.title || item.text
}, item);
}); });
}, },
@ -126,7 +130,8 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, 30); }, 30);
}, },
_assertValue: function (val) {}, _assertValue: function (val) {
},
setStartValue: function (v) { setStartValue: function (v) {
this._startValue = v; this._startValue = v;

2
webpack/attachments.js

@ -183,11 +183,11 @@ const fineuiWithoutJqueryAndPolyfillJs = [].concat(
const demo = [].concat( const demo = [].concat(
basicAttachmentMap.polyfill, basicAttachmentMap.polyfill,
basicAttachmentMap.core, basicAttachmentMap.core,
basicAttachmentMap.router,
basicAttachmentMap.fix, basicAttachmentMap.fix,
basicAttachmentMap.base, basicAttachmentMap.base,
basicAttachmentMap.case, basicAttachmentMap.case,
basicAttachmentMap.widget, basicAttachmentMap.widget,
basicAttachmentMap.router,
sync(["public/less/app.less", "public/less/**/*.less"]), sync(["public/less/app.less", "public/less/**/*.less"]),
[fixCompact, workerCompact], [fixCompact, workerCompact],
basicAttachmentMap.config, basicAttachmentMap.config,

1
webpack/dirs.js

@ -5,6 +5,7 @@ module.exports = {
PRIVATE: path.resolve(__dirname, "../private"), PRIVATE: path.resolve(__dirname, "../private"),
BABEL_CONFIG: path.resolve(__dirname, "../babel.config.js"), BABEL_CONFIG: path.resolve(__dirname, "../babel.config.js"),
TYPESCRIPT: path.resolve(__dirname, "../typescript"), TYPESCRIPT: path.resolve(__dirname, "../typescript"),
ROUTER: path.resolve(__dirname, "../src/router"),
SRC: path.resolve(__dirname, "../src"), SRC: path.resolve(__dirname, "../src"),
DEMO: path.resolve(__dirname, "../demo"), DEMO: path.resolve(__dirname, "../demo"),
PUBLIC: path.resolve(__dirname, "../public"), PUBLIC: path.resolve(__dirname, "../public"),

2
webpack/webpack.common.js

@ -38,7 +38,7 @@ module.exports = {
rules: [ rules: [
{ {
test: /\.(js|ts)$/, test: /\.(js|ts)$/,
include: [dirs.NODE_MODULES, dirs.PRIVATE, dirs.TYPESCRIPT], include: [dirs.NODE_MODULES, dirs.PRIVATE, dirs.TYPESCRIPT, dirs.ROUTER],
exclude: /node_modules(\/|\\)core-js/, exclude: /node_modules(\/|\\)core-js/,
use: [ use: [
{ {

Loading…
Cancel
Save