diff --git a/demo/js/config/widget.js b/demo/js/config/widget.js index 37b467282..d2e1b1d5b 100644 --- a/demo/js/config/widget.js +++ b/demo/js/config/widget.js @@ -194,4 +194,12 @@ Demo.WIDGET_CONFIG = [{ id: 420, text: "滚动sliders", value: "demo.slider" +}, { + pId: 4, + id: 414, + text: "折叠面板" +}, { + pId: 414, + text: "bi.collapse", + value: "demo.collapse" }]; \ No newline at end of file diff --git a/demo/js/widget/collapase/API.md b/demo/js/widget/collapase/API.md new file mode 100644 index 000000000..2ba16aa32 --- /dev/null +++ b/demo/js/widget/collapase/API.md @@ -0,0 +1,12 @@ +## API + +### bi.collapse + +| 参数 | 说明 | 类型 | 默认值 | +| ---------- | ---------- | ------- | -------------------- | +| accordion | 手风琴模式 | boolean | false | +| bordered | 带边框风格的折叠面板 | boolean | true | +| ghost | 使折叠面板透明且无边框 | boolean | false | +| openMotion | 展开动画 | object | { animation: "bi-slide-up", animationDuring: 100} +| value | 初始化选中面板的 key | string\[]
number\[] | - | +| listeners | 监听切换面板事件 | [{eventName: "EVENT_EXPAND", action:(activeKey) => void}] | - | diff --git a/demo/js/widget/collapase/demo.collapse.js b/demo/js/widget/collapase/demo.collapse.js new file mode 100644 index 000000000..b75e29c57 --- /dev/null +++ b/demo/js/widget/collapase/demo.collapse.js @@ -0,0 +1,59 @@ +Demo.Collapse = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-collapse" + }, + + render: function () { + var self = this; + + var items = [{ + value: "test", + popup: { + cls: "mvc-border", + items: BI.createItems([{ + text: "项目1", + value: 1 + }, { + text: "项目2", + value: 2 + }, { + text: "项目3", + value: 3 + }, { + text: "项目4", + value: 4 + }], { + type: "bi.single_select_item", + height: 25 + }) + } + }, { + value: 2, + popup: { + type: "bi.label", + value: "给岁月以文明,而不是给文明以岁月" + } + }, { + value: 3, + popup: { + type: "bi.label", + value: "漂流瓶隐没于黑暗里,在一千米见方的宇宙中,只有生态球里的小太阳发出一点光芒。在这个小小的生命世界中,几只清澈的水球在零重力环境中静静地飘浮着,有一条小鱼从一只水球中蹦出,跃入另一只水球,轻盈地穿游于绿藻之间。" + } + }]; + + return { + type: "bi.vertical", + items: [{ + type: "bi.collapse", + accordion: true, + items: items, + value: [2], + }], + width: '60%', + tgap: 100, + hgap: 100 + }; + } +}); + +BI.shortcut("demo.collapse", Demo.Collapse); diff --git a/dist/font/iconfont.eot b/dist/font/iconfont.eot index e65645dbd..f5457bc8e 100644 Binary files a/dist/font/iconfont.eot and b/dist/font/iconfont.eot differ diff --git a/dist/font/iconfont.svg b/dist/font/iconfont.svg index a04b152fa..3bff3722b 100644 --- a/dist/font/iconfont.svg +++ b/dist/font/iconfont.svg @@ -14,6 +14,74 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -78,12 +146,6 @@ - - - - - - @@ -96,8 +158,6 @@ - - @@ -200,7 +260,7 @@ - + @@ -228,7 +288,7 @@ - + @@ -250,7 +310,7 @@ - + @@ -492,7 +552,7 @@ - + @@ -534,7 +594,7 @@ - + @@ -548,13 +608,13 @@ - + - + @@ -656,7 +716,7 @@ - + @@ -1072,7 +1132,7 @@ - + @@ -1130,7 +1190,7 @@ - + @@ -1328,7 +1388,7 @@ - + diff --git a/dist/font/iconfont.ttf b/dist/font/iconfont.ttf index 09cb798ae..c19a5fc27 100644 Binary files a/dist/font/iconfont.ttf and b/dist/font/iconfont.ttf differ diff --git a/dist/font/iconfont.woff b/dist/font/iconfont.woff index fb99c8512..f25ee6f70 100644 Binary files a/dist/font/iconfont.woff and b/dist/font/iconfont.woff differ diff --git a/dist/font/iconfont.woff2 b/dist/font/iconfont.woff2 index 5b9bb3bd0..36c093a94 100644 Binary files a/dist/font/iconfont.woff2 and b/dist/font/iconfont.woff2 differ diff --git a/package.json b/package.json index 33e8c0d44..3740833eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220323114543", + "version": "2.0.20220413172348", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/base/combination/bubble.js b/src/base/combination/bubble.js index e35fa38ca..11af9cb7a 100644 --- a/src/base/combination/bubble.js +++ b/src/base/combination/bubble.js @@ -228,7 +228,7 @@ _assertPopupView: function () { var self = this, o = this.options; if (this.popupView == null) { - this.popupView = BI.createWidget(this.options.popup, { + this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { type: "bi.bubble_popup_view", showArrow: o.showArrow, value: o.value @@ -332,7 +332,7 @@ name: "offset", options: { offset: function () { - return [o.adjustXOffset, (o.showArrow ? 9 : 0) + (o.adjustYOffset + o.adjustLength)]; + return [o.adjustXOffset, (o.showArrow ? 12 : 0) + (o.adjustYOffset + o.adjustLength)]; } } }]; @@ -340,7 +340,7 @@ modifiers.push({ name: "arrow", options: { - padding: 5, + padding: 4, element: this.popupView.arrow.element[0] } }); diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index bdb488e4c..ddf020a62 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -7,7 +7,7 @@ */ BI.Combo = BI.inherit(BI.Bubble, { _const: { - TRIANGLE_LENGTH: 9 + TRIANGLE_LENGTH: 12 }, _defaultConfig: function () { var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); @@ -103,7 +103,7 @@ _assertPopupView: function () { var self = this, o = this.options; if (this.popupView == null) { - this.popupView = BI.createWidget(this.options.popup, { + this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { type: "bi.popup_view", showArrow: o.showArrow, value: o.value diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 4df7b392e..a9ba5c23c 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -33,11 +33,9 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { self.populate(newValue); }) : o.items; this.populate(items); - if (BI.isFunction(o.value)) { - this.__watch(o.value, function (context, newValue) { - self.setValue(newValue); - }) - } + o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) : o.value; if (BI.isKey(o.value) || BI.isNotEmptyArray(o.value)) { this.setValue(o.value); } diff --git a/src/base/combination/group.virtual.js b/src/base/combination/group.virtual.js index eb2b63b85..e816ab108 100644 --- a/src/base/combination/group.virtual.js +++ b/src/base/combination/group.virtual.js @@ -17,11 +17,9 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { self.populate(newValue); }) : o.items; this.populate(items); - if (BI.isFunction(o.value)) { - this.__watch(o.value, function (context, newValue) { - self.setValue(newValue); - }) - } + o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) : o.value; if (BI.isKey(o.value)) { this.setValue(o.value); } @@ -66,11 +64,11 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { }, addItems: function (items) { - this.layouts.addItems(items); + this.layouts.addItems(items, this); }, prependItems: function (items) { - this.layouts.prependItems(items); + this.layouts.prependItems(items, this); }, setValue: function (v) { diff --git a/src/base/layer/layer.popup.js b/src/base/layer/layer.popup.js index a4cd139b3..8e747d24f 100644 --- a/src/base/layer/layer.popup.js +++ b/src/base/layer/layer.popup.js @@ -5,7 +5,7 @@ */ BI.PopupView = BI.inherit(BI.Widget, { _const: { - TRIANGLE_LENGTH: 9 + TRIANGLE_LENGTH: 12 }, _defaultConfig: function (props) { return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), { @@ -185,7 +185,7 @@ BI.PopupView = BI.inherit(BI.Widget, { setDirection: function (direction, position) { var o = this.options; if (o.showArrow) { - var style, wrapperStyle, placeholderStyle; + var style = {}, wrapperStyle = {}, placeholderStyle = {}; var adjustXOffset = position.adjustXOffset || 0; var adjustYOffset = position.adjustYOffset || 0; var bodyBounds = BI.Widget._renderEngine.createElement("body").bounds(); @@ -197,22 +197,22 @@ BI.PopupView = BI.inherit(BI.Widget, { var offsetStyle = position.offsetStyle; var middle = offsetStyle === "center" || offsetStyle === "middle"; - var minLeft = Math.max(5, offset.left + 5 + popupWidth - bodyWidth); - var minRight = Math.max(5, popupWidth - (offset.left + 5)); - var minTop = Math.max(5, offset.top + 5 + popupHeight - bodyHeight); - var minBottom = Math.max(5, popupHeight - (offset.top + 5)); + var minLeft = Math.max(4, offset.left + 4 + popupWidth - bodyWidth); + var minRight = Math.max(4, popupWidth - (offset.left + 4)); + var minTop = Math.max(4, offset.top + 4 + popupHeight - bodyHeight); + var minBottom = Math.max(4, popupHeight - (offset.top + 4)); - var maxLeft = Math.min(popupWidth - 12 - 5, offset.left + position.width - 12 - 5); - var maxRight = Math.min(popupWidth - 12 - 5, bodyWidth - (offset.left + position.width - 12 - 5)); - var maxTop = Math.min(popupHeight - 12 - 5, offset.top + position.height - 12 - 5); - var maxBottom = Math.min(popupHeight - 12 - 5, bodyHeight - (offset.top + position.height - 12 - 5)); + var maxLeft = Math.min(popupWidth - 16 - 4, offset.left + position.width - 16 - 4); + var maxRight = Math.min(popupWidth - 16 - 4, bodyWidth - (offset.left + position.width - 16 - 4)); + var maxTop = Math.min(popupHeight - 16 - 4, offset.top + position.height - 16 - 4); + var maxBottom = Math.min(popupHeight - 16 - 4, bodyHeight - (offset.top + position.height - 16 - 4)); switch (direction) { case "bottom": case "bottom,right": direction = "bottom"; style = { // 5表示留出一定的空间 - left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 6, minLeft, maxLeft) + left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft) }; wrapperStyle = { top: o.tgap + o.vgap, @@ -231,7 +231,7 @@ BI.PopupView = BI.inherit(BI.Widget, { case "bottom,left": direction = "bottom"; style = { - right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 6, minRight, maxRight) + right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight) }; wrapperStyle = { top: o.bgap + o.vgap, @@ -251,7 +251,7 @@ BI.PopupView = BI.inherit(BI.Widget, { case "top,right": direction = "top"; style = { - left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 6, minLeft, maxLeft) + left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft) }; wrapperStyle = { bottom: o.bgap + o.vgap, @@ -270,7 +270,7 @@ BI.PopupView = BI.inherit(BI.Widget, { case "top,left": direction = "top"; style = { - right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 6, minRight, maxRight) + right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight) }; wrapperStyle = { bottom: o.bgap + o.vgap, @@ -290,7 +290,7 @@ BI.PopupView = BI.inherit(BI.Widget, { case "left,bottom": direction = "left"; style = { - top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 6, minTop, maxTop) + top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop) }; wrapperStyle = { right: o.rgap + o.hgap, @@ -309,7 +309,7 @@ BI.PopupView = BI.inherit(BI.Widget, { case "left,top": direction = "left"; style = { - bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 6, minBottom, maxBottom) + bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom) }; wrapperStyle = { right: o.rgap + o.hgap, @@ -329,7 +329,7 @@ BI.PopupView = BI.inherit(BI.Widget, { case "right,bottom": direction = "right"; style = { - top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 6, minTop, maxTop) + top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop) }; wrapperStyle = { left: o.lgap + o.hgap, @@ -348,7 +348,7 @@ BI.PopupView = BI.inherit(BI.Widget, { case "right,top": direction = "right"; style = { - bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 6, minBottom, maxBottom) + bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom) }; wrapperStyle = { left: o.lgap + o.hgap, diff --git a/src/base/list/virtualgrouplist.js b/src/base/list/virtualgrouplist.js index 7a4a9323b..9039552c2 100644 --- a/src/base/list/virtualgrouplist.js +++ b/src/base/list/virtualgrouplist.js @@ -21,7 +21,6 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { }, init: function () { - var self = this; this.renderedIndex = -1; }, @@ -90,10 +89,10 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { var getElementHeight = function () { return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height(); }; - while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) { + while ((lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight()) < minContentHeight && index < o.items.length) { var items = o.items.slice(index, index + o.blockSize); - this.container.addItems(items.map(function (item, i) { - return o.itemFormatter(item, index + i) + this.container[self.renderedIndex === -1 ? "populate" : "addItems"](items.map(function (item, i) { + return o.itemFormatter(item, index + i); }), this); var addedHeight = getElementHeight() - lastHeight; this.tree.set(cnt, addedHeight); @@ -142,7 +141,9 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { _populate: function (items) { var o = this.options; if (items && this.options.items !== items) { + // 重新populate一组items,需要重新对线段树分块 this.options.items = items; + this._restore(); } this.tree = BI.PrefixIntervalTree.uniform(Math.ceil(o.items.length / o.blockSize), this._isAutoHeight() ? 0 : o.rowHeight * o.blockSize); @@ -153,14 +154,18 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { } }, - restore: function () { + _restore: function () { this.renderedIndex = -1; - this.options.scrollTop = 0; // 依赖于cache的占位元素也要初始化 this.topBlank.setHeight(0); this.bottomBlank.setHeight(0); }, + restore: function () { + this.options.scrollTop = 0; + this._restore(); + }, + populate: function (items) { this._populate(items); } diff --git a/src/base/pager/pager.js b/src/base/pager/pager.js index 6689774f6..64ea9a942 100644 --- a/src/base/pager/pager.js +++ b/src/base/pager/pager.js @@ -12,6 +12,8 @@ BI.Pager = BI.inherit(BI.Widget, { behaviors: {}, layouts: [{ type: "bi.horizontal", + hgap: 10, + vgap: 0 }], dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态 @@ -24,7 +26,6 @@ BI.Pager = BI.inherit(BI.Widget, { }, // 初始化当前页 groups: 0, // 连续显示分页数 jump: BI.emptyFn, // 分页的回调函数 - first: false, // 是否显示首页 last: false, // 是否显示尾页 prev: "上一页", @@ -35,7 +36,7 @@ BI.Pager = BI.inherit(BI.Widget, { return 1; }, hasPrev: BI.emptyFn, // pages不可用时有效 - hasNext: BI.emptyFn // pages不可用时有效 + hasNext: BI.emptyFn // pages不可用时有效 }); }, @@ -81,9 +82,11 @@ BI.Pager = BI.inherit(BI.Widget, { disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) }); } else { - view.push(BI.extend({ - disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) - }, prev)); + view.push({ + el: BI.extend({ + disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) + }, prev) + }); } } @@ -94,7 +97,7 @@ BI.Pager = BI.inherit(BI.Widget, { value: "first", disabled: !(dict.index > 1 && groups !== 0) }); - if (dict.index > 1 && groups !== 0) { + if (dict.index > 1 && groups !== 0 && groups !== pages - 1) { view.push({ type: "bi.label", cls: "page-ellipsis", @@ -108,6 +111,7 @@ BI.Pager = BI.inherit(BI.Widget, { dict.start = dict.index > 1 ? curr - dict.poor : 1; dict.end = dict.index > 1 ? (function () { var max = curr + (groups - dict.poor - 1); + return max > pages ? pages : max; }()) : groups; if (dict.end - dict.start < groups - 1) { // 最后一组状态 @@ -135,7 +139,7 @@ BI.Pager = BI.inherit(BI.Widget, { // 总页数大于连续分页数,且当前组最大页小于总页,输出尾页 if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) { - if (pages > groups && dict.end < pages && groups !== 0) { + if (pages > groups && dict.end < pages && groups !== 0 && groups !== pages - 1) { view.push({ type: "bi.label", cls: "page-ellipsis", @@ -155,28 +159,36 @@ BI.Pager = BI.inherit(BI.Widget, { view.push((function () { if (BI.isKey(next)) { if (pages === false) { - return {text: next, value: "next", disabled: o.hasNext(curr) === false}; + return { text: next, value: "next", disabled: o.hasNext(curr) === false }; } + return (dict.flow && curr === pages) ? - {text: next, value: "next", disabled: true} + { text: next, value: "next", disabled: true } : - {text: next, value: "next", disabled: !(curr !== pages && next || dict.flow)}; + { text: next, value: "next", disabled: !(curr !== pages && next || dict.flow) }; } - return BI.extend({ - disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) - }, next); + return { + el: BI.extend({ + disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) + }, next) + }; }())); } this.button_group = BI.createWidget({ type: "bi.button_group", element: this, - items: BI.createItems(view, { - cls: "bi-list-item-select bi-border-radius", - height: 23, - stopPropagation: true + items: BI.map(view, function (idx, v) { + v = BI.extend({ + cls: "bi-list-item-select bi-border-radius", + height: 23, + hgap: v.el ? 0 : 10, + stopPropagation: true + }, BI.stripEL(v)); + + return BI.formatEL(v); }), behaviors: o.behaviors, layouts: o.layouts @@ -230,6 +242,7 @@ BI.Pager = BI.inherit(BI.Widget, { v || (v = 1); var o = this.options; var pages = this.options.pages; + return pages === false ? o.hasPrev(v) : v > 1; }, @@ -237,6 +250,7 @@ BI.Pager = BI.inherit(BI.Widget, { v || (v = 1); var o = this.options; var pages = this.options.pages; + return pages === false ? o.hasNext(v) : v < pages; }, @@ -265,7 +279,7 @@ BI.Pager = BI.inherit(BI.Widget, { return BI.MIN; case "last": return BI.MAX; - default : + default: return val; } }, diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index 50ec58bdc..802e8472f 100644 --- a/src/base/single/input/file.js +++ b/src/base/single/input/file.js @@ -97,7 +97,7 @@ split = "onabort.onerror.onloadstart.onprogress".split("."), length = split.length, CRLF = "\r\n", - xhr = this.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"), + xhr = XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"), sendFile; // FireFox 3+, Safari 4 beta (Chrome 2 beta file is buggy and will not work) diff --git a/src/case/colorchooser/farbtastic/farbtastic.js b/src/case/colorchooser/farbtastic/farbtastic.js index a5ec6736b..0bf1061b0 100644 --- a/src/case/colorchooser/farbtastic/farbtastic.js +++ b/src/case/colorchooser/farbtastic/farbtastic.js @@ -16,6 +16,7 @@ BI.Farbtastic = BI.inherit(BI.BasicButton, { render: function () { var self = this; + this._defaultState(); return { type: "bi.absolute", items: [{ @@ -87,6 +88,10 @@ BI.Farbtastic = BI.inherit(BI.BasicButton, { } }, + _defaultState: function () { + this.hsl = [0, 0, 0]; + }, + _unpack: function (color) { if (color.length === 7) { return [parseInt("0x" + color.substring(1, 3)) / 255, diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 2f1db8b2d..e143efab0 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -53,12 +53,12 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { offsetStyle: o.offsetStyle, showArrow: true, el: o.el, - popup: BI.extend({ + popup: () => BI.extend({ type: "bi.bubble_popup_view", animation: "bi-zoom-big", animationDuring: 200, primary: o.primary - }, o.popup) + }, BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup) }); this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); diff --git a/src/case/list/list.select.js b/src/case/list/list.select.js index 12f71e383..12037b9a9 100644 --- a/src/case/list/list.select.js +++ b/src/case/list/list.select.js @@ -93,10 +93,23 @@ BI.SelectList = BI.inherit(BI.Widget, { var notSelectLength = this.getAllLeaves().length - selectLength; var hasNext = this.list.hasNext(); var isAlreadyAllSelected = this.toolbar.isSelected(); - var isHalf = selectLength > 0 && (notSelectLength > 0 || (!isAlreadyAllSelected && hasNext)); - isHalf = isHalf || (notSelectLength > 0 && hasNext && isAlreadyAllSelected); + var isHalf = selectLength > 0 && notSelectLength > 0; + var allSelected = isAlreadyAllSelected; + + if (this.isAllSelected() === false) { + hasNext && (isHalf = selectLength > 0); + if (!isAlreadyAllSelected && notSelectLength === 0 && !hasNext) { + allSelected = true; + } + } else { + hasNext && (isHalf = notSelectLength > 0); + if (!isAlreadyAllSelected && notSelectLength === 0) { + allSelected = true; + } + } + this.toolbar.setHalfSelected(isHalf); - !isHalf && this.toolbar.setSelected(selectLength > 0 && notSelectLength <= 0 && (!hasNext || isAlreadyAllSelected)); + !isHalf && this.toolbar.setSelected(allSelected); }, setAllSelected: function (v) { diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index 79ffd5bb6..2ee02010f 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -347,33 +347,33 @@ BI.TreeView = BI.inherit(BI.Pane, { _dealWidthNodes: function (nodes) { var self = this, o = this.options; var ns = BI.Tree.arrayFormat(nodes); - BI.each(ns, function (i, n) { - n.isParent = n.isParent || n.parent; + return BI.map(ns, function (i, n) { + var newNode = BI.extend({}, n); + newNode.isParent = newNode.isParent || newNode.parent; // n.value = BI.isUndefined(n.value) ? n.text : n.value; // n.text = BI.isUndefined(n.text) ? n.value : n.text; // if (n.text === null) { // n.text = ""; // } - if (BI.isNull(n.title)) { - n.title = n.text; + if (BI.isNull(newNode.title)) { + newNode.title = newNode.text; } - if (n.disabled) { - n.title = n.warningTitle || n.title; + if (newNode.disabled) { + newNode.title = newNode.warningTitle || newNode.title; } var text = BI.createWidget(BI.extend({ cls: "tree-node-text", - css: { - display: "inline" - }, + tagName: "span", whiteSpace: "nowrap", root: true, keyword: o.paras.keyword - }, n, { - type: "bi.text" + }, newNode, { + type: "bi.text", + text: BI.replaceAll(newNode.text, "\n", " ") })); var fragment = BI.Widget._renderEngine.createElement("
"); fragment.append(text.element[0]); - n.text = fragment.html(); + newNode.text = fragment.html(); // // 处理标红 // if (BI.isNotNull(n.text)) { // if (BI.isKey(o.paras.keyword)) { @@ -382,8 +382,8 @@ BI.TreeView = BI.inherit(BI.Pane, { // n.text = BI.htmlEncode(BI.Text.formatText(n.text + "")); // } // } + return newNode; }); - return nodes; }, _loadMore: function () { diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js index 5b3a1f580..eb918abf9 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -549,7 +549,9 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { checked: state[0], halfCheck: state[1], open: o.open, - disabled: nodes[i].disabled + disabled: nodes[i].disabled, + title: nodes[i].title || nodes[i].text, + warningTitle: nodes[i].warningTitle, }); } // 如果指定节点全部打开 @@ -588,7 +590,9 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { checked: state[0], halfCheck: state[1], open: self.options.open, - disabled: node.disabled + disabled: node.disabled, + title: node.title || node.text, + warningTitle: node.warningTitle, }); }); } diff --git a/src/core/0.foundation.js b/src/core/0.foundation.js index 067178cbd..ea69e97a9 100644 --- a/src/core/0.foundation.js +++ b/src/core/0.foundation.js @@ -4,7 +4,7 @@ /** * 初始化BI对象 */ -_global = undefined; +var _global = undefined; if (typeof window !== "undefined") { _global = window; } else if (typeof global !== "undefined") { @@ -14,6 +14,11 @@ if (typeof window !== "undefined") { } else { _global = this; } + +if (_global) { + _global._global = _global; +} + if (_global.BI == null) { _global.BI = {prepares: []}; } diff --git a/src/core/2.base.js b/src/core/2.base.js index 16a4a9f70..4a2a2df68 100644 --- a/src/core/2.base.js +++ b/src/core/2.base.js @@ -3,20 +3,6 @@ * Create By GUY 2014\11\17 * */ -_global = undefined; -if (typeof window !== "undefined") { - _global = window; -} else if (typeof global !== "undefined") { - _global = global; -} else if (typeof self !== "undefined") { - _global = self; -} else { - _global = this; -} -if (!_global.BI) { - _global.BI = {}; -} - !(function (undefined) { var traverse = function (func, context) { return function (value, key, obj) { diff --git a/src/core/4.widget.js b/src/core/4.widget.js index deb7758ab..861fce38f 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -398,6 +398,10 @@ lifeHook !== false && !this.__async && callLifeHook(this, "beforeMount"); this._isMounted = true; this.__isMounting = false; + for (var key in this._children) { + var child = this._children[key]; + child._mount && child._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1); + } if (this._parent) { if (!this._parent.isEnabled()) { this._setEnable(false); @@ -406,10 +410,6 @@ this._setValid(false); } } - for (var key in this._children) { - var child = this._children[key]; - child._mount && child._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1); - } this._mountChildren && this._mountChildren(); if (layer === 0) { // mounted里面会执行scrollTo之类的方法,如果放宏任务里会闪 @@ -461,9 +461,9 @@ _setEnable: function (enable) { if (enable === true) { - this.options.disabled = false; + this.options._disabled = false; } else if (enable === false) { - this.options.disabled = true; + this.options._disabled = true; } // 递归将所有子组件使能 BI.each(this._children, function (i, child) { @@ -473,9 +473,9 @@ _setValid: function (valid) { if (valid === true) { - this.options.invalid = false; + this.options._invalid = false; } else if (valid === false) { - this.options.invalid = true; + this.options._invalid = true; } // 递归将所有子组件使有效 BI.each(this._children, function (i, child) { @@ -493,6 +493,7 @@ setEnable: function (enable) { this._manualSetEnable = true; + this.options.disabled = !enable; this._setEnable(enable); if (enable === true) { this.element.removeClass("base-disabled disabled"); @@ -555,6 +556,7 @@ setValid: function (valid) { this._manualSetValid = true; + this.options.invalid = !valid; this._setValid(valid); if (valid === true) { this.element.removeClass("base-invalid invalid"); @@ -579,10 +581,6 @@ return this.options.height; }, - isValid: function () { - return !this.options.invalid; - }, - addWidget: function (name, widget) { var self = this; if (name instanceof BI.Widget) { @@ -597,12 +595,6 @@ throw new Error("组件:组件名已存在,不能进行添加"); } widget._setParent && widget._setParent(this); - // if (this.options.disabled) { - // widget.options && (widget.options.disabled = true); - // } - // if (this.options.invalid) { - // widget.options && (widget.options.invalid = true); - // } widget.on(BI.Events.DESTROY, function () { BI.remove(self._children, this); }); @@ -689,7 +681,11 @@ }, isEnabled: function () { - return !this.options.disabled; + return this.options.disabled === true ? false: !this.options._disabled; + }, + + isValid: function () { + return this.options.invalid === true ? false: !this.options._invalid; }, isVisible: function () { diff --git a/src/core/platform/web/config.js b/src/core/platform/web/config.js index 0076811fd..3bd279aab 100644 --- a/src/core/platform/web/config.js +++ b/src/core/platform/web/config.js @@ -49,7 +49,7 @@ BI.prepares.push(function () { // 当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了,降级table处理吧 var hasAutoAndFillColumnSize = false; if (ob.columnSize && ob.columnSize.length > 0) { - if (ob.columnSize.indexOf("") >= 0 && ob.columnSize.indexOf("fill") >= 0) { + if ((ob.columnSize.indexOf("") >= 0 || ob.columnSize.indexOf("auto") >= 0) && ob.columnSize.indexOf("fill") >= 0) { hasAutoAndFillColumnSize = true; } } else { @@ -57,7 +57,7 @@ BI.prepares.push(function () { BI.each(ob.items, function (i, item) { if (item.width === "fill") { hasFill = true; - } else if (BI.isNull(item.width) || item.width === "") { + } else if (BI.isNull(item.width) || item.width === "" || item.width === "auto") { hasAuto = true; } }); @@ -173,7 +173,7 @@ BI.prepares.push(function () { } var hasAuto = false; if (ob.rowSize && ob.rowSize.length > 0) { - if (ob.rowSize.indexOf("") >= 0) { + if (ob.rowSize.indexOf("") >= 0 || ob.rowSize.indexOf("auto") >= 0) { hasAuto = true; } } else { diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js index 52976e103..05757959d 100644 --- a/src/core/platform/web/dom.js +++ b/src/core/platform/web/dom.js @@ -628,20 +628,20 @@ return pos; default : if (BI.DOM.isBottomSpaceLarger(combo)) { - pos = BI.DOM.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight); + top = BI.DOM.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight).top; firstDir = "bottom"; } else { - pos = BI.DOM.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight); + top = BI.DOM.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight).top; firstDir = "top"; } if (leftRight[0] === "right") { - left = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth, needAdaptHeight).left; - pos.left = left; + pos = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth, needAdaptHeight); + pos.top = top; pos.dir = firstDir + "," + pos.dir; return pos; } - left = BI.DOM.getRightAlignPosition(combo, popup, extraWidth).left; - pos.left = left; + pos = BI.DOM.getRightAlignPosition(combo, popup, extraWidth); + pos.top = top; pos.dir = firstDir + "," + pos.dir; return pos; } diff --git a/src/core/wrapper/layout/flex/flex.horizontal.js b/src/core/wrapper/layout/flex/flex.horizontal.js index 1d921c89f..7b87a2d1c 100644 --- a/src/core/wrapper/layout/flex/flex.horizontal.js +++ b/src/core/wrapper/layout/flex/flex.horizontal.js @@ -40,10 +40,10 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { _hasFill: function () { var o = this.options; if (o.columnSize.length > 0) { - return o.columnSize.indexOf("fill") >= 0; + return o.columnSize.indexOf("fill") >= 0 || o.columnSize.indexOf("auto") >= 0; } return BI.some(o.items, function (i, item) { - if (item.width === "fill") { + if (item.width === "fill" || item.width === "auto") { return true; } }); diff --git a/src/core/wrapper/layout/flex/flex.vertical.js b/src/core/wrapper/layout/flex/flex.vertical.js index e885f5b9e..4f9ee1119 100644 --- a/src/core/wrapper/layout/flex/flex.vertical.js +++ b/src/core/wrapper/layout/flex/flex.vertical.js @@ -39,10 +39,10 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, { _hasFill: function () { var o = this.options; if (o.rowSize.length > 0) { - return o.rowSize.indexOf("fill") >= 0; + return o.rowSize.indexOf("fill") >= 0 || o.rowSize.indexOf("auto") >= 0; } return BI.some(o.items, function (i, item) { - if (item.height === "fill") { + if (item.height === "fill" || item.height === "auto") { return true; } }); diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js index 94e10fb14..d159d8890 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js @@ -36,10 +36,10 @@ BI.FlexWrapperHorizontalLayout = BI.inherit(BI.Layout, { _hasFill: function () { var o = this.options; if (o.columnSize.length > 0) { - return o.columnSize.indexOf("fill") >= 0; + return o.columnSize.indexOf("fill") >= 0 || o.columnSize.indexOf("auto") >= 0; } return BI.some(o.items, function (i, item) { - if (item.width === "fill") { + if (item.width === "fill" || item.width === "auto") { return true; } }); diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js index f9d85948f..0f1c9b166 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js @@ -36,10 +36,10 @@ BI.FlexWrapperVerticalLayout = BI.inherit(BI.Layout, { _hasFill: function () { var o = this.options; if (o.rowSize.length > 0) { - return o.rowSize.indexOf("fill") >= 0; + return o.rowSize.indexOf("fill") >= 0 || o.rowSize.indexOf("auto") >= 0; } return BI.some(o.items, function (i, item) { - if (item.height === "fill") { + if (item.height === "fill" || item.height === "auto") { return true; } }); diff --git a/src/less/base/combo/popup.bubble.less b/src/less/base/combo/popup.bubble.less index 4a324ac95..2bfd50acc 100644 --- a/src/less/base/combo/popup.bubble.less +++ b/src/less/base/combo/popup.bubble.less @@ -5,4 +5,4 @@ .box-shadows(0px 9px 28px 8px rgba(0, 0, 0, 0.05), 0px 6px 16px 0px rgba(0, 0, 0, 0.08), 0px 3px 6px -4px rgba(0, 0, 0, 0.12)); .border-radius(4px); } -} \ No newline at end of file +} diff --git a/src/less/base/single/button/button.half.less b/src/less/base/single/button/button.half.less index 79669689e..b02f0b25b 100644 --- a/src/less/base/single/button/button.half.less +++ b/src/less/base/single/button/button.half.less @@ -12,4 +12,10 @@ background-color: @color-bi-background-half-button-content; content: ''; } + &, + .disabled { + &:after { + background-color: @color-bi-background-disabled-half-button-content; + } + } } diff --git a/src/less/base/view/popupview.less b/src/less/base/view/popupview.less index 318518b57..c9aeb1333 100644 --- a/src/less/base/view/popupview.less +++ b/src/less/base/view/popupview.less @@ -33,9 +33,9 @@ left: 0; > .bi-bubble-arrow { bottom: -12px; - width: 14px; + width: 16px; > .bubble-arrow { - bottom: 8px; + bottom: 7px; left: 1px; } } @@ -47,9 +47,9 @@ left: 0; > .bi-bubble-arrow { top: -12px; - width: 14px; + width: 16px; > .bubble-arrow { - top: 8px; + top: 7px; left: 1px; } } @@ -61,9 +61,9 @@ top: 0; > .bi-bubble-arrow { right: -12px; - height: 14px; + height: 16px; > .bubble-arrow { - right: 8px; + right: 7px; top: 1px; } } @@ -75,9 +75,9 @@ top: 0; > .bi-bubble-arrow { left: -12px; - height: 14px; + height: 16px; > .bubble-arrow { - left: 8px; + left: 7px; top: 1px; } } @@ -85,18 +85,18 @@ } .bi-bubble-arrow { - width: 12px; - height: 12px; + width: 14px; + height: 14px; // 消除祖先节点设置的line-height:normal对空白节点的行高影响 line-height: 0; overflow: hidden; .bubble-arrow { - width: 12px; - height: 12px; + width: 14px; + height: 14px; position: absolute; &:before { - width: 12px; - height: 12px; + width: 14px; + height: 14px; position: absolute; content: ""; background: @color-bi-background-default; @@ -106,7 +106,8 @@ visibility: visible; transform: translateX(0px) rotate(-135deg); transform-origin: center center; - .box-shadow(3px 3px 10px 0,rgba(0,0,0,6%)); + .box-shadow(3px 3px 10px 0,rgba(0, 0, 0, 6%)); + .border-radius(2px); } } } diff --git a/src/less/lib/theme.less b/src/less/lib/theme.less index d83ef3789..9fddef950 100644 --- a/src/less/lib/theme.less +++ b/src/less/lib/theme.less @@ -195,6 +195,7 @@ @color-bi-split-disabled-segment: @color-bi-border-disabled; // 半选 @color-bi-background-half-button-content: @color-bi-background-highlight; +@color-bi-background-disabled-half-button-content: @color-bi-background-light-disabled; // items @color-bi-text-active-single-select-icon-text-item: @color-bi-text-highlight; // editor diff --git a/src/widget/collapse/collapse.js b/src/widget/collapse/collapse.js new file mode 100644 index 000000000..f899c3588 --- /dev/null +++ b/src/widget/collapse/collapse.js @@ -0,0 +1,108 @@ +BI.Collapse = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-collapse", + items: [], + value: [], + trigger: "click", + accordion: false, + bordered: true, + ghost: false, + isDefaultInit: false, + openMotion: { + animation: "bi-slide-up", + animationDuring: 200 + } + }, + + render: function () { + var o = this.options; + + var collapseCls = o.ghost ? "" : "bi-background " + (o.bordered ? "bi-border bi-border-radius" : ""); + + this.expanders = {}; + + return { + type: "bi.vertical", + cls: collapseCls, + items: this._getItems(this.options.items) + + }; + }, + + _getItems: function (items) { + var self = this, o = this.options; + + return BI.map(items, function (index, item) { + var isActive = BI.contains(self._getCurrentValue(o.value), item.value); + var cls = o.ghost || index === 0 ? "" : "bi-border-top"; + + var el = BI.extend({ + type: "bi.arrow_group_node", + height: 30, + text: item.text, + value: item.value, + open: isActive + }, item.el); + + var popup = BI.extend({ + animation: o.openMotion.animation, + animationDuring: o.openMotion.animationDuring + }, item.popup); + + return BI.extend({ + type: "bi.expander", + cls: cls, + isDefaultInit: o.isDefaultInit, + trigger: o.trigger, + listeners: [{ + eventName: BI.Expander.EVENT_EXPAND, + action: function () { + self._hideOtherExpander(item.value); + self.fireEvent(BI.Collapse.EVENT_EXPAND, item.value); + } + }] + }, item, { + el: el, + popup: popup, + ref: function (_ref) { + BI.isFunction(item.ref) && item.ref(_ref); + self.expanders[item.value] = _ref; + } + }); + }); + }, + + _hideOtherExpander: function (expandKey) { + if (this.options.accordion) { + BI.each(this.expanders, function (key, expander) { + key !== (expandKey + "") && expander.hideView(); + }); + } + }, + + _getCurrentValue: function (v) { + var values = BI.isNotEmptyArray(v) ? v : BI.isKey(v) ? [v] : []; + + return this.options.accordion ? values.slice(0, 1) : values; + }, + + getValue: function () { + var value = []; + BI.each(this.expanders, function (key, expander) { + expander.isExpanded() && value.push(key); + }); + + return value; + }, + + setValue: function (v) { + var values = BI.map(this._getCurrentValue(v), function (idx, value) {return value + "";}); + BI.each(this.expanders, function (key, expander) { + BI.contains(values, key) ? expander.showView() : expander.hideView(); + }); + } +}); + +BI.Collapse.EVENT_EXPAND = "EVENT_EXPAND"; +BI.shortcut("bi.collapse", BI.Collapse); diff --git a/src/widget/downlist/item.downlistgroup.js b/src/widget/downlist/item.downlistgroup.js index d89132f47..31492b78b 100644 --- a/src/widget/downlist/item.downlistgroup.js +++ b/src/widget/downlist/item.downlistgroup.js @@ -28,6 +28,7 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { type: "bi.icon_button", cls: o.iconCls1, width: 36, + height: o.height, disableSelected: true, selected: this._digest(o.value) }); diff --git a/src/widget/downlist/popup.downlist.js b/src/widget/downlist/popup.downlist.js index 5abb8fe96..35d395334 100644 --- a/src/widget/downlist/popup.downlist.js +++ b/src/widget/downlist/popup.downlist.js @@ -26,8 +26,8 @@ BI.DownListPopup = BI.inherit(BI.Pane, { this.singleValues = []; this.childValueMap = {}; this.fatherValueMap = {}; - this.items = BI.deepClone(this.options.items); - var self = this, o = this.options, children = this._createChildren(this.items); + this.items = []; + var self = this, o = this.options, children = this._createPopupItems(o.items); this.popup = BI.createWidget({ type: "bi.button_tree", items: BI.createItems(children, @@ -75,7 +75,7 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }); }, - _createChildren: function (items) { + _createPopupItems: function (items) { var self = this, result = []; // 不能修改populate进来的item的引用 BI.each(items, function (i, it) { @@ -84,8 +84,11 @@ BI.DownListPopup = BI.inherit(BI.Pane, { items: [] }; - BI.each(it, function (i, item) { - if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { + var storeItem = []; + + BI.each(it, function (i, sourceItem) { + var item = BI.extend({}, sourceItem); + if (BI.isNotEmptyArray(sourceItem.children) && !BI.isEmpty(sourceItem.el)) { item.type = "bi.combo_group"; // popup未初始化返回的是options中的value, 在经过buttontree的getValue concat之后,无法区分值来自options // 还是item自身, 这边控制defaultInit为true来避免这个问题 @@ -93,12 +96,13 @@ BI.DownListPopup = BI.inherit(BI.Pane, { item.cls = "down-list-group"; item.trigger = "hover"; item.isNeedAdjustWidth = false; - item.el.title = item.el.title || item.el.text; + item.el = sourceItem.el; + item.el.title = sourceItem.el.title || sourceItem.el.text; item.el.type = "bi.down_list_group_item"; item.el.logic = { dynamic: true }; - item.el.height = item.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT; + item.el.height = sourceItem.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT; item.el.iconCls2 = self.constants.nextIcon; item.popup = { lgap: 1, @@ -113,30 +117,10 @@ BI.DownListPopup = BI.inherit(BI.Pane, { innerVgap: 5, maxHeight: 378 }; - item.el.childValues = []; - item.items = item.children; - BI.each(item.children, function (i, child) { - var fatherValue = BI.deepClone(item.el.value); - var childValue = BI.deepClone(child.value); - self.singleValues.push(child.value); - child.type = child.type || "bi.down_list_item"; - child.extraCls = " child-down-list-item"; - child.title = child.title || child.text; - child.textRgap = 10; - child.isNeedAdjustWidth = false; - child.logic = { - dynamic: true - }; - child.father = fatherValue; - child.childValue = child.value; - self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; - self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; - child.value = self._createChildValue(fatherValue, childValue); - item.el.childValues.push(child.value); - }); + self._createChildren(item, sourceItem); } else { - item.type = item.type || "bi.down_list_item"; - item.title = item.title || item.text; + item.type = sourceItem.type || "bi.down_list_item"; + item.title = sourceItem.title || sourceItem.text; item.textRgap = 10; item.isNeedAdjustWidth = false; item.logic = { @@ -146,6 +130,7 @@ BI.DownListPopup = BI.inherit(BI.Pane, { var el_done = {}; el_done.el = item; item_done.items.push(el_done); + storeItem.push(item); }); if (self._isGroup(item_done.items)) { BI.each(item_done.items, function (i, item) { @@ -154,6 +139,7 @@ BI.DownListPopup = BI.inherit(BI.Pane, { } result.push(item_done); + self.items.push(storeItem); if (self._needSpliter(i, items.length)) { var spliter_container = BI.createWidget({ type: "bi.vertical", @@ -176,6 +162,33 @@ BI.DownListPopup = BI.inherit(BI.Pane, { return result; }, + _createChildren: function (targetItem, sourceItem) { + var self = this; + targetItem.el.childValues = []; + targetItem.items = targetItem.children = []; + BI.each(sourceItem.children, function (i, child) { + var item = BI.extend({}, child); + var fatherValue = BI.deepClone(targetItem.el.value); + var childValue = BI.deepClone(item.value); + self.singleValues.push(item.value); + item.type = item.type || "bi.down_list_item"; + item.extraCls = " child-down-list-item"; + item.title = item.title || item.text; + item.textRgap = 10; + item.isNeedAdjustWidth = false; + item.logic = { + dynamic: true + }; + item.father = fatherValue; + item.childValue = item.value; + self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; + self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; + item.value = self._createChildValue(fatherValue, childValue); + targetItem.el.childValues.push(item.value); + targetItem.items.push(item); + }); + }, + _isGroup: function (i) { return i.length > 1; }, @@ -239,11 +252,11 @@ BI.DownListPopup = BI.inherit(BI.Pane, { populate: function (items) { BI.DownListPopup.superclass.populate.apply(this, arguments); - this.items = BI.deepClone(items); + this.items = []; this.childValueMap = {}; this.fatherValueMap = {}; this.singleValues = []; - var children = this._createChildren(this.items); + var children = this._createPopupItems(items); var popupItem = BI.createItems(children, {}, { adjustLength: -2 diff --git a/src/widget/multilayerdownlist/popup.downlist.js b/src/widget/multilayerdownlist/popup.downlist.js index c18351220..fa222005d 100644 --- a/src/widget/multilayerdownlist/popup.downlist.js +++ b/src/widget/multilayerdownlist/popup.downlist.js @@ -26,6 +26,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { this.singleValues = []; this.childValueMap = {}; this.fatherValueMap = {}; + this.items = []; var self = this, o = this.options, children = this._createPopupItems(o.items); this.popup = BI.createWidget({ type: "bi.button_tree", @@ -83,19 +84,22 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { type: "bi.down_list_group", items: [] }; + var storeItem = []; - BI.each(it, function (i, item) { - if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { + BI.each(it, function (i, sourceItem) { + var item = BI.extend({}, sourceItem); + if (BI.isNotEmptyArray(sourceItem.children) && !BI.isEmpty(sourceItem.el)) { item.type = "bi.combo_group"; item.cls = "down-list-group"; item.trigger = "hover"; item.isNeedAdjustWidth = false; - item.el.title = item.el.title || item.el.text; + item.el = sourceItem.el; + item.el.title = sourceItem.el.title || sourceItem.el.text; item.el.type = "bi.down_list_group_item"; item.el.logic = { dynamic: true }; - item.el.height = item.el.height || self.constants.height; + item.el.height = sourceItem.el.height || self.constants.height; item.el.iconCls2 = self.constants.nextIcon; item.popup = { lgap: 1, @@ -110,10 +114,10 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { innerVgap: 5, maxHeight: 378, }; - self._createChildren(item); + self._createChildren(item, sourceItem); } else { - item.type = item.type || "bi.down_list_item"; - item.title = item.title || item.text; + item.type = sourceItem.type || "bi.down_list_item"; + item.title = sourceItem.title || sourceItem.text; item.textRgap = 10; item.isNeedAdjustWidth = false; item.logic = { @@ -123,6 +127,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { var el_done = {}; el_done.el = item; item_done.items.push(el_done); + storeItem.push(item); }); if (self._isGroup(item_done.items)) { BI.each(item_done.items, function (i, item) { @@ -131,6 +136,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { } result.push(item_done); + self.items.push(storeItem); if (self._needSpliter(i, items.length)) { var spliter_container = BI.createWidget({ type: "bi.vertical", @@ -152,34 +158,35 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { return result; }, - _createChildren: function (item) { + _createChildren: function (targetItem, sourceItem) { var self = this; - this._formatEL(item).el.childValues = []; - item.items = item.children; - BI.each(item.children, function (i, child) { - child = child.el ? BI.extend(child.el, {children: child.children}) : child; - var fatherValue = BI.deepClone(self._formatEL(item).el.value); - var childValue = BI.deepClone(child.value); - self.singleValues.push(child.value); - child.type = child.type || "bi.down_list_item"; - child.extraCls = " child-down-list-item"; - child.title = child.title || child.text; - child.textRgap = 10; - child.isNeedAdjustWidth = false; - child.logic = { + this._formatEL(targetItem).el.childValues = []; + targetItem.items = targetItem.children = []; + BI.each(sourceItem.children, function (i, child) { + var item = child.el ? BI.extend({}, child.el, {children: child.children}) : BI.extend({}, child); + var fatherValue = BI.deepClone(self._formatEL(targetItem).el.value); + var childValue = BI.deepClone(item.value); + self.singleValues.push(item.value); + item.type = item.type || "bi.down_list_item"; + item.extraCls = " child-down-list-item"; + item.title = item.title || item.text; + item.textRgap = 10; + item.isNeedAdjustWidth = false; + item.logic = { dynamic: true }; - child.father = fatherValue; + item.father = fatherValue; self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; - child.value = self._createChildValue(fatherValue, childValue); - self._formatEL(item).el.childValues.push(child.value); + item.value = self._createChildValue(fatherValue, childValue); + self._formatEL(targetItem).el.childValues.push(item.value); if (BI.isNotEmptyArray(child.children)) { - child.type = "bi.down_list_group_item"; - child.iconCls2 = self.constants.nextIcon; - child.height = child.height || self.constants.height; - self._createChildren(child); + item.type = "bi.down_list_group_item"; + item.iconCls2 = self.constants.nextIcon; + item.height = child.height || self.constants.height; + self._createChildren(item, child); } + targetItem.items.push(item); }); }, @@ -228,7 +235,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { _checkValues: function (values) { var self = this, o = this.options; var value = []; - BI.each(o.items, function (idx, itemGroup) { + BI.each(this.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)) { var childValues = getChildrenValue(item); @@ -277,6 +284,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { self.childValueMap = {}; self.fatherValueMap = {}; self.singleValues = []; + this.items = []; var children = self._createPopupItems(items); var popupItem = BI.createItems(children, {}, { diff --git a/src/widget/singleselect/singleselect.combo.js b/src/widget/singleselect/singleselect.combo.js index fb873438f..fae620c93 100644 --- a/src/widget/singleselect/singleselect.combo.js +++ b/src/widget/singleselect/singleselect.combo.js @@ -10,6 +10,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { baseCls: "bi-single-select-combo", allowNoSelect: false, itemsCreator: BI.emptyFn, + itemWrapper: BI.emptyFn, valueFormatter: BI.emptyFn, height: 24, allowEdit: true @@ -107,6 +108,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { } }], itemsCreator: o.itemsCreator, + itemWrapper: o.itemWrapper, valueFormatter: o.valueFormatter, onLoaded: function () { BI.nextTick(function () { diff --git a/src/widget/singleselect/singleselect.insert.combo.js b/src/widget/singleselect/singleselect.insert.combo.js index b8b21cd09..46754e1dc 100644 --- a/src/widget/singleselect/singleselect.insert.combo.js +++ b/src/widget/singleselect/singleselect.insert.combo.js @@ -10,6 +10,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { baseCls: "bi-single-select-combo", allowNoSelect: false, itemsCreator: BI.emptyFn, + itemWrapper: BI.emptyFn, valueFormatter: BI.emptyFn, height: 24, allowEdit: true, @@ -118,6 +119,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { } }], itemsCreator: o.itemsCreator, + itemWrapper: o.itemWrapper, valueFormatter: o.valueFormatter, onLoaded: function () { BI.nextTick(function () { diff --git a/src/widget/singleselect/singleselect.loader.js b/src/widget/singleselect/singleselect.loader.js index 1f27b6425..645bdad66 100644 --- a/src/widget/singleselect/singleselect.loader.js +++ b/src/widget/singleselect/singleselect.loader.js @@ -22,6 +22,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, { allowNoSelect: false, valueFormatter: BI.emptyFn, itemsCreator: BI.emptyFn, + itemWrapper: BI.emptyFn, onLoaded: BI.emptyFn }); }, @@ -69,7 +70,12 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, { if (op.times === 1 && !BI.isUndefined(self.storeValue)) { var json = BI.map([self.storeValue], function (i, v) { var txt = opts.valueFormatter(v) || v; - return { + return opts.itemWrapper({ + text: txt, + value: v, + title: txt, + selected: true + }) || { text: txt, value: v, title: txt, @@ -117,7 +123,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, { height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, selected: false, iconWrapperWidth: 26, - hgap: o.allowNoSelect ? 10 : 0, + textHgap: o.allowNoSelect ? 10 : 0, title: item.title || item.text }, item); }); diff --git a/src/widget/singleselect/singleselect.popup.view.js b/src/widget/singleselect/singleselect.popup.view.js index 4e33c004f..ffa8766bd 100644 --- a/src/widget/singleselect/singleselect.popup.view.js +++ b/src/widget/singleselect/singleselect.popup.view.js @@ -14,6 +14,7 @@ BI.SingleSelectPopupView = BI.inherit(BI.Widget, { maxHeight: 400, valueFormatter: BI.emptyFn, itemsCreator: BI.emptyFn, + itemWrapper: BI.emptyFn, onLoaded: BI.emptyFn }); }, @@ -26,6 +27,7 @@ BI.SingleSelectPopupView = BI.inherit(BI.Widget, { type: "bi.single_select_loader", allowNoSelect: opts.allowNoSelect, itemsCreator: opts.itemsCreator, + itemWrapper: opts.itemWrapper, valueFormatter: opts.valueFormatter, onLoaded: opts.onLoaded, value: opts.value diff --git a/src/widget/singleselect/singleselectlist.insert.js b/src/widget/singleselect/singleselectlist.insert.js index db1722abc..f9bce32e6 100644 --- a/src/widget/singleselect/singleselectlist.insert.js +++ b/src/widget/singleselect/singleselectlist.insert.js @@ -9,6 +9,7 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { baseCls: "bi-multi-select-insert-list", allowNoSelect: false, itemsCreator: BI.emptyFn, + itemWrapper: BI.emptyFn, valueFormatter: BI.emptyFn, searcherHeight: 24, }); @@ -30,6 +31,7 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { cls: "popup-single-select-list bi-border-left bi-border-right bi-border-bottom", itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, + itemWrapper: o.itemWrapper, logic: { dynamic: true }, diff --git a/typescript/widget/collapse/collapse.ts b/typescript/widget/collapse/collapse.ts new file mode 100644 index 000000000..949987186 --- /dev/null +++ b/typescript/widget/collapse/collapse.ts @@ -0,0 +1,10 @@ +import { Widget } from "../../core/widget"; + +export declare class Collapse extends Widget { + static xtype: string; + static EVENT_EXPAND: string; + + getValue(): string[]; + + setValue(v: string[]): void; +} diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index 7d8dd939c..05cb95648 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -23,6 +23,7 @@ module.exports = merge.smart(common, { utils: attachments.utils, "utils.min": attachments.utils, "fineui_without_jquery_polyfill": attachments.fineuiWithoutJqueryAndPolyfillJs, + "fineui_without_jquery_polyfill.min": attachments.fineuiWithoutJqueryAndPolyfillJs, "2.0/fineui": attachments.bundle, "2.0/fineui.min": attachments.bundle, "2.0/fineui_without_normalize": attachments.bundleWithoutNormalize,