diff --git a/bi.lessconfig.json b/bi.lessconfig.json index a5f1d669f..fafccaff8 100644 --- a/bi.lessconfig.json +++ b/bi.lessconfig.json @@ -4,21 +4,28 @@ "@color-light-blue-100": "#19B8EA", "@color-orange-100": "#FAAA39", "@color-red-100": "#E65251", - "@color-black": "#000A19", + "@color-black": "#091E40", "@color-light-gray": "#ECEEF3", "@color-light-gray-theme-dark": "#292F45", + "@border-color-line": "rgba(9, 30, 64, 0.15)", + "@border-color-light-line": "#E6E9EF", "@border-color-dark-line": "#2E3A4D", "@color-sliver-theme-dark": "#363E55", - "@border-color-disabled": "#E7E8EB", - + "@border-color-disabled": "rgba(9, 30, 64, 0.07)", + "@font-color-gray": "rgba(9, 30, 64, 0.9)", + "@font-color-light-gray": "rgba(9, 30, 64, 0.66)", + "@font-color-tips": "rgba(9, 30, 64, 0.47)", + "@font-color-disabled": "rgba(9, 30, 64, 0.25)", "@color-bi-background-active-radio": "transparent", + "@color-bi-border-radio": "rgba(9, 30, 64, 0.37)", + "@color-bi-border-disabled-radio": "rgba(9, 30, 64, 0.19)", "@color-bi-background-active-radio-content": "#2C60DB", - "@color-bi-background-disabled-active-radio-content": "#D0D4DA", + "@color-bi-background-disabled-active-radio-content": "#FFFFFF", "@color-bi-background-disabled-active-radio-content-theme-dark": "#606479", "@color-bi-background-disabled-active-checkbox-content": "#FFFFFF", "@color-bi-background-disabled-active-checkbox-content-theme-dark": "#606479", - "@color-bi-background-tooltip-success": "#2E3A4D", "@color-bi-text-header-background": "#647185", + "@color-bi-background-tooltip-success": "#2E3A4D", "@color-bi-border-tooltip-success": "#2E3A4D", "@color-bi-background-toast-success": "#FFFFFF", "@color-bi-background-toast-warning": "#FFFFFF", @@ -28,5 +35,6 @@ "@color-bi-color-toast-warning": "#FAAA39", "@color-bi-color-toast-error": "#E65251", "@color-bi-color-toast-normal": "#2C60DB", - "@color-bi-color-toast-text": "#000A19" + "@color-bi-color-toast-text": "#000A19", + "@color-bi-color-toast-shadow": "rgba(9, 30, 64, 0.16)" } diff --git a/changelog.md b/changelog.md index f6824f6d6..dbcca9ccd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,19 @@ # 更新日志 + +3.0(2022-05) +- 下拉选择框支持清空 + +3.0(2022-03) +- 支持响应式 +- 全面支持Typescript +- 增加JSX支持 +- 布局组件支持更多动态特性 +- 底层API支持动画 +- 增加WebWorker支持 +- 支持路由 +- 插件支持版本控制 +- Fix数据流支持proxy版本 + 2.0(2022-01) - 提供自定义表单 diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 0aa54de07..6098389e7 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -193,6 +193,41 @@ Demo.Button = BI.inherit(BI.Widget, { ghost: true, height: 30 } + }, { + el: { + type: "bi.button", + iconCls: "plus-font", + text: "幽灵按钮(common)", + ghost: true, + height: 30 + } + }, { + el: { + type: "bi.button", + iconCls: "plus-font", + text: "幽灵按钮(common)", + ghost: true, + level: "warning", + height: 30 + } + }, { + el: { + type: "bi.button", + iconCls: "plus-font", + text: "幽灵按钮(common)", + ghost: true, + level: "error", + height: 30 + } + }, { + el: { + type: "bi.button", + iconCls: "plus-font", + text: "幽灵按钮(common)", + ghost: true, + level: "success", + height: 30 + } }, { el: { type: "bi.button", @@ -213,6 +248,67 @@ Demo.Button = BI.inherit(BI.Widget, { }, height: 30 } + }, { + el: { + type: "bi.button", + text: "图标在上面的按钮,而且可以自动撑开高度", + iconCls: "close-font", + iconGap: 24, + iconPosition: "top" + } + }, { + el: { + type: "bi.button", + text: "图标在下面的按钮", + iconCls: "close-font", + iconPosition: "bottom" + } + }, { + el: { + type: "bi.button", + text: "图标在左边的按钮", + iconCls: "close-font", + iconPosition: "left" + } + }, { + el: { + type: "bi.button", + text: "图标在右边的按钮", + iconCls: "close-font", + iconPosition: "right" + } + }, { + el: { + type: "bi.button", + text: "浅色的一般按钮", + iconCls: "plus-font", + light: true + } + }, { + el: { + type: "bi.button", + text: "浅色的成功按钮", + level: "success", + iconCls: "plus-font", + light: true + } + }, { + el: { + type: "bi.button", + text: "浅色的警告按钮", + level: "warning", + iconCls: "plus-font", + light: true + } + }, { + el: { + type: "bi.button", + iconCls: "plus-font", + text: "浅色的失败按钮", + level: "error", + cls: "hover-mask", + light: true + } }]; // BI.each(items, function (i, item) { // item.el.handler = function () { @@ -228,4 +324,4 @@ Demo.Button = BI.inherit(BI.Widget, { }; } }); -BI.shortcut("demo.button", Demo.Button); \ No newline at end of file +BI.shortcut("demo.button", Demo.Button); diff --git a/dist/fix/fix.js b/dist/fix/fix.js index 6e1d60013..52a6a7907 100644 --- a/dist/fix/fix.js +++ b/dist/fix/fix.js @@ -11,47 +11,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); } - var rhashcode = /\d\.\d{4}/; - - //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript - function makeHashCode(prefix) { - /* istanbul ignore next*/ - prefix = prefix || 'bi'; - /* istanbul ignore next*/ - return String(Math.random() + Math.random()).replace(rhashcode, prefix); - } - var hasProto = '__proto__' in {}; - var isIE = function isIE() { - if (typeof navigator === "undefined") { - return false; - } - return (/(msie|trident)/i.test(navigator.userAgent.toLowerCase()) - ); - }; - - var getIEVersion = function getIEVersion() { - var version = 0; - if (typeof navigator === "undefined") { - return false; - } - var agent = navigator.userAgent.toLowerCase(); - var v1 = agent.match(/(?:msie\s([\w.]+))/); - var v2 = agent.match(/(?:trident.*rv:([\w.]+))/); - if (v1 && v2 && v1[1] && v2[1]) { - version = Math.max(v1[1] * 1, v2[1] * 1); - } else if (v1 && v1[1]) { - version = v1[1] * 1; - } else if (v2 && v2[1]) { - version = v2[1] * 1; - } else { - version = 0; - } - return version; - }; - var isIE9Below = isIE() && getIEVersion() < 9; - var _toString = Object.prototype.toString; function isPlainObject(obj) { @@ -135,8 +96,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons setImmediate(nextTickHandler); }; } else if (typeof MessageChannel !== 'undefined' && (isNative(MessageChannel) || - // PhantomJS - MessageChannel.toString() === '[object MessageChannelConstructor]')) { + // PhantomJS + MessageChannel.toString() === '[object MessageChannelConstructor]')) { var channel = new MessageChannel(); var port = channel.port2; channel.port1.onmessage = nextTickHandler; @@ -145,18 +106,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons }; } else /* istanbul ignore next */ - if (typeof Promise !== 'undefined' && isNative(Promise)) { - // use microtask in non-DOM environments, e.g. Weex - var p = Promise.resolve(); - timerFunc = function timerFunc() { - p.then(nextTickHandler); - }; - } else { - // fallback to setTimeout - timerFunc = function timerFunc() { - setTimeout(nextTickHandler, 0); - }; - } + if (typeof Promise !== 'undefined' && isNative(Promise)) { + // use microtask in non-DOM environments, e.g. Weex + var p = Promise.resolve(); + timerFunc = function timerFunc() { + p.then(nextTickHandler); + }; + } else { + // fallback to setTimeout + timerFunc = function timerFunc() { + setTimeout(nextTickHandler, 0); + }; + } return function queueNextTick(cb, ctx) { var _resolve = void 0; @@ -266,7 +227,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var createViewModel = Object.defineProperties; var defineProperty = void 0; - var timeBucket = new Date() - 0; /* istanbul ignore if*/ if (!canHideProperty) { if ('__defineGetter__' in {}) { @@ -291,76 +251,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons return obj; }; } - /* istanbul ignore if*/ - if (isIE9Below) { - var VBClassPool = {}; - window.execScript([// jshint ignore:line - 'Function parseVB(code)', '\tExecuteGlobal(code)', 'End Function' //转换一段文本为VB代码 - ].join('\n'), 'VBScript'); - - var VBMediator = function VBMediator(instance, accessors, name, value) { - // jshint ignore:line - var accessor = accessors[name]; - if (arguments.length === 4) { - accessor.set.call(instance, value); - } else { - return accessor.get.call(instance); - } - }; - createViewModel = function createViewModel(name, accessors, properties) { - // jshint ignore:line - var buffer = []; - buffer.push('\tPrivate [$vbsetter]', '\tPublic [$accessors]', '\tPublic Default Function [$vbthis](ac' + timeBucket + ', s' + timeBucket + ')', '\t\tSet [$accessors] = ac' + timeBucket + ': set [$vbsetter] = s' + timeBucket, '\t\tSet [$vbthis] = Me', //链式调用 - '\tEnd Function'); - //添加普通属性,因为VBScript对象不能像JS那样随意增删属性,必须在这里预先定义好 - var uniq = { - $vbthis: true, - $vbsetter: true, - $accessors: true - }; - for (name in $$skipArray) { - if (!uniq[name]) { - buffer.push('\tPublic [' + name + ']'); - uniq[name] = true; - } - } - //添加访问器属性 - for (name in accessors) { - if (uniq[name]) { - continue; - } - uniq[name] = true; - buffer.push( - //由于不知对方会传入什么,因此set, let都用上 - '\tPublic Property Let [' + name + '](val' + timeBucket + ')', //setter - '\t\tCall [$vbsetter](Me, [$accessors], "' + name + '", val' + timeBucket + ')', '\tEnd Property', '\tPublic Property Set [' + name + '](val' + timeBucket + ')', //setter - '\t\tCall [$vbsetter](Me, [$accessors], "' + name + '", val' + timeBucket + ')', '\tEnd Property', '\tPublic Property Get [' + name + ']', //getter - '\tOn Error Resume Next', //必须优先使用set语句,否则它会误将数组当字符串返回 - '\t\tSet[' + name + '] = [$vbsetter](Me, [$accessors],"' + name + '")', '\tIf Err.Number <> 0 Then', '\t\t[' + name + '] = [$vbsetter](Me, [$accessors],"' + name + '")', '\tEnd If', '\tOn Error Goto 0', '\tEnd Property'); - } - - for (name in properties) { - if (!uniq[name]) { - uniq[name] = true; - buffer.push('\tPublic [' + name + ']'); - } - } - - buffer.push('\tPublic [hasOwnProperty]'); - buffer.push('End Class'); - var body = buffer.join('\r\n'); - var className = VBClassPool[body]; - if (!className) { - className = makeHashCode('VBClass'); - window.parseVB('Class ' + className + body); - window.parseVB(['Function ' + className + 'Factory(acc, vbm)', //创建实例并传入两个关键的参数 - '\tDim o', '\tSet o = (New ' + className + ')(acc, vbm)', '\tSet ' + className + 'Factory = o', 'End Function'].join('\r\n')); - VBClassPool[body] = className; - } - var ret = window[className + 'Factory'](accessors, VBMediator); //得到其产品 - return ret; //得到其产品 - }; - } } var createViewModel$1 = createViewModel; @@ -538,10 +428,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons if (this.active) { var value = this.get(); if (value !== this.value || - // Deep watchers and watchers on Object/Arrays should fire even - // when the value is the same, because the value may - // have mutated. - _.isObject(value) && options && options.refresh || this.deep) { + // Deep watchers and watchers on Object/Arrays should fire even + // when the value is the same, because the value may + // have mutated. + _.isObject(value) && options && options.refresh || this.deep) { // set new value var oldValue = this.value; this.value = value; @@ -700,11 +590,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } else { this.model = this.walk(value); } - if (isIE9Below) { - this.model['__ob__'] = this; - } else { - def(this.model, "__ob__", this); - } + def(this.model, "__ob__", this); } Observer.prototype.walk = function walk(obj) { @@ -788,53 +674,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function defineReactive(obj, observer, shallow) { var props = {}; var model = void 0; - // if (typeof Proxy === 'function') { - // const deps = {}, childObs = {}, cache = {} - // _.each(obj, function (val, key) { - // if (key in $$skipArray) { - // return - // } - // cache[key] = val - // const dep = deps[key] = (observer && observer['__dep' + key]) || new Dep() - // observer && (observer['__dep' + key] = dep) - // childObs[key] = !shallow && observe(val, observer, key) - // }) - // return model = new Proxy(props, { - // has: function (target, key) { - // return key in obj; - // }, - // get: function (target, key) { - // if (key in $$skipArray) { - // return target[key] - // } - // const value = cache[key] - // if (Dep.target) { - // deps[key].depend() - // if (childObs[key]) { - // childObs[key].dep.depend() - // if (_.isArray(value)) { - // dependArray(value) - // } - // } - // } - // return value - // }, - // set: function (target, key, newVal) { - // if (key in $$skipArray) { - // return target[key] = newVal - // } - // const value = cache[key], dep = deps[key] - // if (newVal === value || (newVal !== newVal && value !== value)) { - // return newVal - // } - // cache[key] = newVal - // childObs[key] = !shallow && observe(newVal, observer, key) - // obj[key] = childObs[key] ? childObs[key].model : newVal - // notify(model, key, dep) - // return obj[key] - // } - // }) - // } _.each(obj, function (val, key) { if (key in $$skipArray) { return; @@ -878,6 +717,50 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons return model = createViewModel$1(obj, props); } + function defineReactiveProperty(obj, key, val, shallow) { + + var dep = new Dep(); + + var configurable = isConfigurable(obj, key); + if (!configurable) { + return; + } + + if (arguments.length === 2) { + val = obj[key]; + } + + var childOb = !shallow && observe(val); + Object.defineProperty(obj, key, { + enumerable: true, + configurable: true, + get: function reactiveGetter() { + var value = childOb ? childOb.model : val; + if (Dep.target) { + dep.depend(); + if (childOb) { + childOb.dep.depend(); + if (_.isArray(value)) { + dependArray(value); + } + } + } + return value; + }, + set: function reactiveSetter(newVal) { + var value = childOb ? childOb.model : val; + if (newVal === value || newVal !== newVal && value !== value) { + return; + } + + childOb = configurable && !shallow && observe(newVal); + val = newVal; + obj[key] = childOb ? childOb.model : newVal; + dep.notify(); + } + }); + } + /** * Set a property on an object. Adds the new property and * triggers change notification if the property doesn't @@ -1522,6 +1405,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons exports.observe = observe; exports.notify = notify; exports.defineReactive = defineReactive; + exports.defineReactiveProperty = defineReactiveProperty; exports.set = set; exports.freeze = freeze; exports.del = del; diff --git a/dist/font/iconfont.eot b/dist/font/iconfont.eot index f5457bc8e..6cd1f1cf2 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 3bff3722b..c70fa76fe 100644 --- a/dist/font/iconfont.svg +++ b/dist/font/iconfont.svg @@ -14,6 +14,156 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -36,22 +186,6 @@ - - - - - - - - - - - - - - - - @@ -80,11 +214,11 @@ - + - + @@ -92,11 +226,11 @@ - + - + - + @@ -148,12 +282,6 @@ - - - - - - @@ -182,9 +310,9 @@ - + - + @@ -198,29 +326,11 @@ - - - - - - - - - - - - - - - - - + - - - + @@ -228,25 +338,15 @@ - - - - - - - - - - - + - + - + - + - + @@ -270,11 +370,11 @@ - + - + @@ -304,13 +404,13 @@ - + - + @@ -438,7 +538,7 @@ - + @@ -498,21 +598,21 @@ - + - + - + - + - + @@ -524,7 +624,7 @@ - + @@ -532,9 +632,9 @@ - + - + @@ -542,31 +642,31 @@ - + - + - + - + - + - + @@ -584,7 +684,7 @@ - + @@ -596,7 +696,7 @@ - + @@ -624,7 +724,7 @@ - + @@ -686,7 +786,7 @@ - + @@ -710,23 +810,23 @@ - + - + - + - + @@ -742,7 +842,7 @@ - + @@ -752,7 +852,7 @@ - + @@ -770,19 +870,19 @@ - + - + - + @@ -794,17 +894,17 @@ - + - + - + @@ -822,13 +922,13 @@ - + - + @@ -844,7 +944,7 @@ - + @@ -888,7 +988,7 @@ - + @@ -898,7 +998,7 @@ - + @@ -922,7 +1022,7 @@ - + @@ -962,7 +1062,7 @@ - + @@ -972,7 +1072,7 @@ - + @@ -1020,43 +1120,43 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -1068,67 +1168,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1150,23 +1250,23 @@ - + - + - + - + @@ -1200,7 +1300,7 @@ - + @@ -1210,17 +1310,17 @@ - + - + - + @@ -1228,7 +1328,7 @@ - + @@ -1280,7 +1380,7 @@ - + @@ -1294,7 +1394,7 @@ - + @@ -1310,13 +1410,13 @@ - + - + @@ -1336,7 +1436,7 @@ - + @@ -1370,19 +1470,19 @@ - + - + - + @@ -1396,7 +1496,7 @@ - + @@ -1420,7 +1520,7 @@ - + @@ -1450,7 +1550,7 @@ - + @@ -1458,11 +1558,11 @@ - + - + @@ -1478,7 +1578,7 @@ - + @@ -1486,19 +1586,19 @@ - + - + - + - + @@ -1510,15 +1610,15 @@ - + - + - + - + @@ -1534,33 +1634,33 @@ - + - + - + - + - + - + - + @@ -1600,7 +1700,7 @@ - + @@ -1616,15 +1716,15 @@ - + - + - + @@ -1648,13 +1748,13 @@ - + - + @@ -1666,15 +1766,15 @@ - + - + - + @@ -1688,27 +1788,27 @@ - + - + - + - + - + - + diff --git a/dist/font/iconfont.ttf b/dist/font/iconfont.ttf index c19a5fc27..76debf9d2 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 f25ee6f70..ea016fed7 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 36c093a94..1d6e0c461 100644 Binary files a/dist/font/iconfont.woff2 and b/dist/font/iconfont.woff2 differ diff --git a/package.json b/package.json index b3355d4f6..14f7108ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220505161347", + "version": "2.0.20220615141348", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/base/combination/searcher.js b/src/base/combination/searcher.js index c4fd29025..0989b4c8a 100644 --- a/src/base/combination/searcher.js +++ b/src/base/combination/searcher.js @@ -183,7 +183,7 @@ BI.Searcher = BI.inherit(BI.Widget, { keyword: keyword, selectedValues: o.adapter && o.adapter.getValue() }, function (searchResult, matchResult) { - if (!self._stop) { + if (!self._stop && keyword === self.editor.getValue()) { var args = [].slice.call(arguments); if (args.length > 0) { args.push(keyword); diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index b264660a7..334851235 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -130,99 +130,99 @@ BI.GridView = BI.inherit(BI.Widget, { var visibleColumnIndices = this._columnSizeAndPositionManager.getVisibleCellRange(width, scrollLeft); var visibleRowIndices = this._rowSizeAndPositionManager.getVisibleCellRange(height, scrollTop); - if (BI.isEmpty(visibleColumnIndices) || BI.isEmpty(visibleRowIndices)) { - return; - } - var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft); - var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop); - - this._renderedColumnStartIndex = visibleColumnIndices.start; - this._renderedColumnStopIndex = visibleColumnIndices.stop; - this._renderedRowStartIndex = visibleRowIndices.start; - this._renderedRowStopIndex = visibleRowIndices.stop; - - var overscanColumnIndices = this._getOverscanIndices(this.columnCount, overscanColumnCount, this._renderedColumnStartIndex, this._renderedColumnStopIndex); - - var overscanRowIndices = this._getOverscanIndices(this.rowCount, overscanRowCount, this._renderedRowStartIndex, this._renderedRowStopIndex); - - var columnStartIndex = overscanColumnIndices.overscanStartIndex; - var columnStopIndex = overscanColumnIndices.overscanStopIndex; - var rowStartIndex = overscanRowIndices.overscanStartIndex; - var rowStopIndex = overscanRowIndices.overscanStopIndex; - - // 算区间size - var minRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStartIndex); - var minColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStartIndex); - var maxRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStopIndex); - var maxColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStopIndex); - var top = minRowDatum.offset + verticalOffsetAdjustment; - var left = minColumnDatum.offset + horizontalOffsetAdjustment; - var bottom = maxRowDatum.offset + verticalOffsetAdjustment + maxRowDatum.size; - var right = maxColumnDatum.offset + horizontalOffsetAdjustment + maxColumnDatum.size; - // 如果滚动的区间并没有超出渲染的范围 - if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) { - return; - } - var renderedCells = [], renderedKeys = {}, renderedWidgets = {}; - var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; - var count = 0; - for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { - var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); - - for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) { - var key = rowIndex + "-" + columnIndex; - var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); - - var index = this.renderedKeys[key] && this.renderedKeys[key][2]; - var child; - if (index >= 0) { - // if (columnDatum.size !== this.renderedCells[index]._width) { - // this.renderedCells[index]._width = columnDatum.size; - this.renderedCells[index].el.setWidth(columnDatum.size); - // } - // if (rowDatum.size !== this.renderedCells[index]._height) { - // this.renderedCells[index]._height = rowDatum.size; - this.renderedCells[index].el.setHeight(rowDatum.size); - // } - // if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) { - this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); - // } - // if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) { - this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); - // } - child = this.renderedCells[index].el; - renderedCells.push(this.renderedCells[index]); - } else { - var item = o.itemFormatter(o.items[rowIndex][columnIndex], rowIndex, columnIndex); - child = BI._lazyCreateWidget(BI.extend({ - type: "bi.label", - width: columnDatum.size, - height: rowDatum.size - }, item, { - cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""), - _rowIndex: rowIndex, - _columnIndex: columnIndex, - _left: columnDatum.offset + horizontalOffsetAdjustment, - _top: rowDatum.offset + verticalOffsetAdjustment - }), this); - renderedCells.push({ - el: child, - left: columnDatum.offset + horizontalOffsetAdjustment, - top: rowDatum.offset + verticalOffsetAdjustment, - _left: columnDatum.offset + horizontalOffsetAdjustment, - _top: rowDatum.offset + verticalOffsetAdjustment - // _width: columnDatum.size, - // _height: rowDatum.size - }); + // 没有可见的单元格就干掉所有渲染过的 + if (!BI.isEmpty(visibleColumnIndices) && !BI.isEmpty(visibleRowIndices)) { + var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft); + var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop); + + this._renderedColumnStartIndex = visibleColumnIndices.start; + this._renderedColumnStopIndex = visibleColumnIndices.stop; + this._renderedRowStartIndex = visibleRowIndices.start; + this._renderedRowStopIndex = visibleRowIndices.stop; + + var overscanColumnIndices = this._getOverscanIndices(this.columnCount, overscanColumnCount, this._renderedColumnStartIndex, this._renderedColumnStopIndex); + + var overscanRowIndices = this._getOverscanIndices(this.rowCount, overscanRowCount, this._renderedRowStartIndex, this._renderedRowStopIndex); + + var columnStartIndex = overscanColumnIndices.overscanStartIndex; + var columnStopIndex = overscanColumnIndices.overscanStopIndex; + var rowStartIndex = overscanRowIndices.overscanStartIndex; + var rowStopIndex = overscanRowIndices.overscanStopIndex; + + // 算区间size + var minRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStartIndex); + var minColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStartIndex); + var maxRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStopIndex); + var maxColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStopIndex); + var top = minRowDatum.offset + verticalOffsetAdjustment; + var left = minColumnDatum.offset + horizontalOffsetAdjustment; + var bottom = maxRowDatum.offset + verticalOffsetAdjustment + maxRowDatum.size; + var right = maxColumnDatum.offset + horizontalOffsetAdjustment + maxColumnDatum.size; + // 如果滚动的区间并没有超出渲染的范围 + if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) { + return; + } + + var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; + var count = 0; + for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { + var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); + + for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) { + var key = rowIndex + "-" + columnIndex; + var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); + + var index = this.renderedKeys[key] && this.renderedKeys[key][2]; + var child; + if (index >= 0) { + // if (columnDatum.size !== this.renderedCells[index]._width) { + // this.renderedCells[index]._width = columnDatum.size; + this.renderedCells[index].el.setWidth(columnDatum.size); + // } + // if (rowDatum.size !== this.renderedCells[index]._height) { + // this.renderedCells[index]._height = rowDatum.size; + this.renderedCells[index].el.setHeight(rowDatum.size); + // } + // if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) { + this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); + // } + // if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) { + this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); + // } + child = this.renderedCells[index].el; + renderedCells.push(this.renderedCells[index]); + } else { + var item = o.itemFormatter(o.items[rowIndex][columnIndex], rowIndex, columnIndex); + child = BI._lazyCreateWidget(BI.extend({ + type: "bi.label", + width: columnDatum.size, + height: rowDatum.size + }, item, { + cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""), + _rowIndex: rowIndex, + _columnIndex: columnIndex, + _left: columnDatum.offset + horizontalOffsetAdjustment, + _top: rowDatum.offset + verticalOffsetAdjustment + }), this); + renderedCells.push({ + el: child, + left: columnDatum.offset + horizontalOffsetAdjustment, + top: rowDatum.offset + verticalOffsetAdjustment, + _left: columnDatum.offset + horizontalOffsetAdjustment, + _top: rowDatum.offset + verticalOffsetAdjustment + // _width: columnDatum.size, + // _height: rowDatum.size + }); + } + minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment); + maxX = Math.max(maxX, columnDatum.offset + horizontalOffsetAdjustment + columnDatum.size); + minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); + maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); + renderedKeys[key] = [rowIndex, columnIndex, count]; + renderedWidgets[count] = child; + count++; } - minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment); - maxX = Math.max(maxX, columnDatum.offset + horizontalOffsetAdjustment + columnDatum.size); - minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); - maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); - renderedKeys[key] = [rowIndex, columnIndex, count]; - renderedWidgets[count] = child; - count++; } } // 已存在的, 需要添加的和需要删除的 diff --git a/src/base/list/virtualgrouplist.js b/src/base/list/virtualgrouplist.js index 9039552c2..0eae74875 100644 --- a/src/base/list/virtualgrouplist.js +++ b/src/base/list/virtualgrouplist.js @@ -14,6 +14,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { scrollTop: 0, rowHeight: "auto", items: [], + el: {}, itemFormatter: function (item, index) { return item; } @@ -39,10 +40,10 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { ref: function () { self.container = this; }, - layouts: [{ + layouts: [BI.extend({ type: "bi.vertical", scrolly: false - }] + }, o.el)] }, { type: "bi.layout", ref: function () { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 0863d0935..1eb9c0f22 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -1,169 +1,212 @@ -/** - * 文字类型的按钮 - * @class BI.Button - * @extends BI.BasicButton - * - * @cfg {JSON} options 配置属性 - * @cfg {'common'/'success'/'warning'/'ignore'} [options.level='common'] 按钮类型,用不同颜色强调不同的场景 - */ -BI.Button = BI.inherit(BI.BasicButton, { +(function () { + function isVertical(position) { + return position === "top" || position === "bottom"; + } + + /** + * 文字类型的按钮 + * @class BI.Button + * @extends BI.BasicButton + * + * @cfg {JSON} options 配置属性 + * @cfg {'common'/'success'/'warning'/'ignore'} [options.level='common'] 按钮类型,用不同颜色强调不同的场景 + */ + BI.Button = BI.inherit(BI.BasicButton, { - _const: { - iconWidth: 18 - }, + _const: { + iconWidth: 16 + }, - _defaultConfig: function (props) { - var conf = BI.Button.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), - attributes: { - tabIndex: 1 - }, - minWidth: (props.block === true || props.clear === true) ? 0 : 80, - height: 24, - shadow: props.clear !== true, - isShadowShowingOnSelected: true, - readonly: true, - iconCls: "", - level: "common", - block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制 - clear: false, // 是否去掉边框和背景 - ghost: false, // 是否幽灵显示, 即正常状态无背景 - textAlign: "center", - whiteSpace: "nowrap", - textWidth: null, - textHeight: null, - hgap: props.clear ? 0 : 10, - vgap: 0, - tgap: 0, - bgap: 0, - lgap: 0, - rgap: 0 - }); - }, + _defaultConfig: function (props) { + var conf = BI.Button.superclass._defaultConfig.apply(this, arguments); - render: function () { - var o = this.options, self = this; + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), + attributes: { + tabIndex: 1 + }, + minWidth: (props.block === true || props.clear === true) ? 0 : 80, + // 44 = 垂直间距 6 + 边框 2 + 图标 16 + 图标和文字间隔 8 + 文字 12 + height: isVertical(props.iconPosition) ? 44 + ((props.iconGap || 8) - 8) : 24, + shadow: props.clear !== true, + isShadowShowingOnSelected: true, + readonly: true, + iconCls: "", + level: "common", + block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制 + clear: false, // 是否去掉边框和背景 + ghost: false, // 是否幽灵显示, 即正常状态无背景 + loading: false, // 是否处于加载中 + light: false, // 是否使用浅色 + textAlign: "center", + whiteSpace: "nowrap", + textWidth: null, + textHeight: null, + hgap: props.clear ? 0 : 10, + vgap: 0, + tgap: 0, + bgap: 0, + lgap: 0, + rgap: 0, + iconGap: 8, + iconPosition: "left" + }); + }, - // 由于button默认情况下有个边框,所以要主动算行高 - var lineHeight, textHeight = o.textHeight; - if (BI.isNumber(o.height)) { - if (o.clear || o.block) { - lineHeight = o.height; + render: function () { + var o = this.options; + + // 由于button默认情况下有个边框,所以要主动算行高 + var lineHeight, textHeight = o.textHeight; + if (BI.isNumber(o.height)) { + if (!isVertical(o.iconPosition)) { + if (o.clear || o.block || o.light) { + lineHeight = o.height; + } else { + lineHeight = o.height - 2; + } + } else { + lineHeight = textHeight; + } + } + if (!textHeight) { + if (o.whiteSpace === "nowrap") { + textHeight = lineHeight; + } + } + if (BI.isKey(o.iconCls)) { + this.icon = BI.createWidget({ + type: "bi.icon_label", + cls: o.iconCls, + width: this._const.iconWidth, + height: lineHeight, + lineHeight: lineHeight + }); + this.text = BI.createWidget({ + type: "bi.label", + text: o.text, + textWidth: BI.isNotNull(o.textWidth) ? o.textWidth - this._const.iconWidth : null, + textHeight: textHeight, + height: lineHeight, + value: o.value + }); + var layoutType = "bi.horizontal"; + var gapContainer = { + lgap: o.iconPosition === "left" && o.text ? o.iconGap : 0, + rgap: o.iconPosition === "right" ? o.iconGap : 0, + tgap: o.iconPosition === "top" ? o.iconGap : 0, + bgap: o.iconPosition === "bottom" ? o.iconGap : 0 + }; + var items = [this.icon, BI.extend({el: this.text}, gapContainer)]; + if (isVertical(o.iconPosition)) { + layoutType = "bi.vertical"; + } + if (o.iconPosition === "right" || o.iconPosition === "bottom") { + items = [BI.extend({el: this.text}, gapContainer), this.icon]; + } + BI.createWidget({ + type: "bi.center_adapt", + element: this, + hgap: o.hgap, + vgap: o.vgap, + items: [{ + type: layoutType, + horizontalAlign: "center", + verticalAlign: "middle", + items: items + }] + }); } else { - lineHeight = o.height - 2; + this.text = BI.createWidget({ + type: "bi.label", + height: o.height, + textAlign: o.textAlign, + whiteSpace: o.whiteSpace, + textWidth: o.textWidth, + textHeight: textHeight, + hgap: o.hgap, + vgap: o.vgap, + tgap: o.tgap, + bgap: o.bgap, + lgap: o.lgap, + rgap: o.rgap, + element: this, + text: o.text, + value: o.value + }); } - } - if (!textHeight) { - if (o.whiteSpace === "nowrap") { - textHeight = lineHeight; + if (o.block === true) { + this.element.addClass("block"); } - } - if (BI.isKey(o.iconCls)) { - this.icon = BI.createWidget({ - type: "bi.icon_label", - cls: o.iconCls, - width: this._const.iconWidth, - height: lineHeight, - lineHeight: lineHeight, - iconWidth: o.iconWidth, - iconHeight: o.iconHeight - }); - this.text = BI.createWidget({ - type: "bi.label", - text: o.text, - textWidth: BI.isNotNull(o.textWidth) ? o.textWidth - this._const.iconWidth : null, - textHeight: textHeight, - height: lineHeight, - value: o.value - }); - BI.createWidget({ - type: "bi.center_adapt", - element: this, - hgap: o.hgap, - vgap: o.vgap, - items: [{ - type: "bi.horizontal", - columnSize: ["", "fill"], - items: [this.icon, this.text] - }] - }); - } else { - this.text = BI.createWidget({ - type: "bi.label", - height: o.height, - textAlign: o.textAlign, - whiteSpace: o.whiteSpace, - textWidth: o.textWidth, - textHeight: textHeight, - hgap: o.hgap, - vgap: o.vgap, - tgap: o.tgap, - bgap: o.bgap, - lgap: o.lgap, - rgap: o.rgap, - element: this, - text: o.text, - value: o.value - }); - } - if (o.block === true) { - this.element.addClass("block"); - } - if (o.clear === true) { - this.element.addClass("clear"); - } - if (o.ghost === true) { - this.element.addClass("ghost"); - } - if (o.minWidth > 0) { - this.element.css({"min-width": o.minWidth / BI.pixRatio + BI.pixUnit}); - } - }, + if (o.clear === true) { + this.element.addClass("clear"); + } + if (o.ghost === true) { + this.element.addClass("ghost"); + } + if (o.loading === true) { + this.element.addClass("loading"); + } + if (o.light === true) { + this.element.addClass("light"); + } + if (o.minWidth > 0) { + this.element.css({"min-width": o.minWidth / BI.pixRatio + BI.pixUnit}); + } + }, - doClick: function () { - BI.Button.superclass.doClick.apply(this, arguments); - if (this.isValid()) { - this.fireEvent(BI.Button.EVENT_CHANGE, this); - } - }, + doClick: function () { + BI.Button.superclass.doClick.apply(this, arguments); + if (this.isValid()) { + this.fireEvent(BI.Button.EVENT_CHANGE, this); + } + }, - _setEnable: function (enable) { - BI.Button.superclass._setEnable.apply(this, arguments); - if (enable === true) { - this.element.attr("tabIndex", 1); - } else if (enable === false) { - this.element.removeAttr("tabIndex"); - } - }, + _setEnable: function (enable) { + BI.Button.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.attr("tabIndex", 1); + } else if (enable === false) { + this.element.removeAttr("tabIndex"); + } + }, - setText: function (text) { - BI.Button.superclass.setText.apply(this, arguments); - this.text.setText(text); - }, + setLoading: function (loading) { + if (loading) { + this.element.addClass("loading"); + } else { + this.element.removeClass("loading"); + } + }, - setValue: function (text) { - BI.Button.superclass.setValue.apply(this, arguments); - if (!this.isReadOnly()) { - this.text.setValue(text); - } - }, + setText: function (text) { + BI.Button.superclass.setText.apply(this, arguments); + this.text.setText(text); + }, - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + setValue: function (text) { + BI.Button.superclass.setValue.apply(this, arguments); + if (!this.isReadOnly()) { + this.text.setValue(text); + } + }, - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - } -}); -BI.shortcut("bi.button", BI.Button); -BI.Button.EVENT_CHANGE = "EVENT_CHANGE"; + doHighLight: function () { + this.text.doHighLight.apply(this.text, arguments); + }, + + unHighLight: function () { + this.text.unHighLight.apply(this.text, arguments); + } + }); + BI.shortcut("bi.button", BI.Button); + BI.Button.EVENT_CHANGE = "EVENT_CHANGE"; +}()); diff --git a/src/base/single/button/listitem/blankiconicontextitem.js b/src/base/single/button/listitem/blankiconicontextitem.js index ed8f0b6d1..2f1531835 100644 --- a/src/base/single/button/listitem/blankiconicontextitem.js +++ b/src/base/single/button/listitem/blankiconicontextitem.js @@ -10,10 +10,7 @@ BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, { _defaultConfig: function () { var conf = BI.BlankIconIconTextItem.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item", - logic: { - dynamic: false - }, + baseCls: (conf.baseCls || "") + " bi-blank-icon-icon-text-item", iconCls1: "", iconCls2: "", blankWidth: 0, diff --git a/src/base/single/button/listitem/blankicontexticonitem.js b/src/base/single/button/listitem/blankicontexticonitem.js index 815589387..aeb876e9c 100644 --- a/src/base/single/button/listitem/blankicontexticonitem.js +++ b/src/base/single/button/listitem/blankicontexticonitem.js @@ -12,9 +12,6 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, { var conf = BI.BlankIconTextIconItem.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-blank-icon-text-icon-item", - logic: { - dynamic: false - }, iconCls1: "", iconCls2: "", blankWidth: 0, diff --git a/src/base/single/button/listitem/blankicontextitem.js b/src/base/single/button/listitem/blankicontextitem.js index 54be05c5b..158d05bf6 100644 --- a/src/base/single/button/listitem/blankicontextitem.js +++ b/src/base/single/button/listitem/blankicontextitem.js @@ -11,9 +11,6 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, { var conf = BI.BlankIconTextItem.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item", - logic: { - dynamic: false - }, blankWidth: 0, iconHeight: null, iconWidth: null, diff --git a/src/base/single/button/listitem/icontexticonitem.js b/src/base/single/button/listitem/icontexticonitem.js index 8db8ae483..4658bc471 100644 --- a/src/base/single/button/listitem/icontexticonitem.js +++ b/src/base/single/button/listitem/icontexticonitem.js @@ -12,9 +12,6 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, { var conf = BI.IconTextIconItem.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-icon-text-icon-item", - logic: { - dynamic: false - }, iconCls1: "", iconCls2: "", iconHeight: null, diff --git a/src/base/single/button/listitem/icontextitem.js b/src/base/single/button/listitem/icontextitem.js index 76c19e25d..a54da86f4 100644 --- a/src/base/single/button/listitem/icontextitem.js +++ b/src/base/single/button/listitem/icontextitem.js @@ -12,9 +12,6 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, { return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-icon-text-item", direction: BI.Direction.Left, - logic: { - dynamic: false - }, iconWrapperWidth: null, iconHeight: null, iconWidth: null, diff --git a/src/base/single/button/listitem/texticonitem.js b/src/base/single/button/listitem/texticonitem.js index 92c696780..a423195d4 100644 --- a/src/base/single/button/listitem/texticonitem.js +++ b/src/base/single/button/listitem/texticonitem.js @@ -12,9 +12,6 @@ BI.TextIconItem = BI.inherit(BI.BasicButton, { var conf = BI.TextIconItem.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-text-icon-item", - logic: { - dynamic: false - }, iconWrapperWidth: null, iconHeight: null, iconWidth: null, diff --git a/src/base/single/button/node/icontexticonnode.js b/src/base/single/button/node/icontexticonnode.js index 79bc0167f..13d967425 100644 --- a/src/base/single/button/node/icontexticonnode.js +++ b/src/base/single/button/node/icontexticonnode.js @@ -10,9 +10,6 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { var conf = BI.IconTextIconNode.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node", - logic: { - dynamic: false - }, iconCls1: "close-ha-font", iconCls2: "close-ha-font", iconHeight: null, diff --git a/src/base/single/button/node/icontextnode.js b/src/base/single/button/node/icontextnode.js index 00f1adf86..5c9f1a4ca 100644 --- a/src/base/single/button/node/icontextnode.js +++ b/src/base/single/button/node/icontextnode.js @@ -10,9 +10,6 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { var conf = BI.IconTextNode.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-icon-text-node", - logic: { - dynamic: false - }, cls: "close-ha-font", iconHeight: null, iconWidth: null, diff --git a/src/base/single/button/node/texticonnode.js b/src/base/single/button/node/texticonnode.js index 67844bddc..6671c19a1 100644 --- a/src/base/single/button/node/texticonnode.js +++ b/src/base/single/button/node/texticonnode.js @@ -9,9 +9,6 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { var conf = BI.TextIconNode.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-text-icon-node", - logic: { - dynamic: false - }, cls: "close-ha-font", iconHeight: null, iconWidth: null, diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 2d9941bb4..5322124d9 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -240,9 +240,6 @@ BI.Editor = BI.inherit(BI.Single, { }, setWaterMark: function (v) { - if (!BI.isKey(v)) { - return; - } this.options.watermark = v; @@ -261,6 +258,7 @@ BI.Editor = BI.inherit(BI.Single, { }); } this.watermark.setText(v); + this._checkWaterMark(); }, _setErrorVisible: function (b) { diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index 1175d01c7..7aec220f0 100644 --- a/src/base/single/editor/editor.multifile.js +++ b/src/base/single/editor/editor.multifile.js @@ -31,7 +31,8 @@ BI.MultifileEditor = BI.inherit(BI.Widget, { accept: o.accept, maxSize: o.maxSize, maxLength: o.maxLength, - title: o.title + title: o.title, + errorText: o.errorText, }); this.file.on(BI.File.EVENT_CHANGE, function () { self.fireEvent(BI.MultifileEditor.EVENT_CHANGE, arguments); diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index 802e8472f..b86963f41 100644 --- a/src/base/single/input/file.js +++ b/src/base/single/input/file.js @@ -445,8 +445,9 @@ url: "", multiple: true, accept: "", // .png,.pdf,image/jpg,image/* 等 - maxSize: -1, // 1024 * 1024 - maxLength: -1 // 无限制, 与multiple配合使用 + maxSize: -1, // 1024 * 1024 单位b + maxLength: -1, // 无限制, 与multiple配合使用 + errorText: BI.emptyFn, }); }, @@ -472,12 +473,10 @@ // handlers _wrap.onloadstart = function (rpe, xhr) { - // BI.Msg.toast("loadstart"); self.fireEvent(BI.File.EVENT_UPLOADSTART, arguments); }; _wrap.onprogress = function (rpe, xhr) { - // BI.Msg.toast("onprogress"); // percent for each bar // fileSize is -1 only if browser does not support file info access @@ -561,21 +560,26 @@ var validateFileType = fileTypeValidate(value, wrap.fileType); if (!validateFileType) { // 文件类型不支持 - BI.Msg.toast(BI.i18nText("BI-Upload_File_Type_Error"), { level: "error" }); + BI.Msg.toast(o.errorText({ + errorType: 0, + file: item + }) || BI.i18nText("BI-Upload_File_Type_Error", wrap.fileType), { level: "error" }); self.fireEvent(BI.File.EVENT_ERROR, { errorType: 0, file: item }); } else if (wrap.maxSize !== -1 && size && wrap.maxSize < size) { // 文件大小不支持 - BI.Msg.toast(BI.i18nText("BI-Upload_File_Size_Error"), { level: "error" }); + BI.Msg.toast(o.errorText({ + errorType: 1, + file: item + }) || BI.i18nText("BI-Upload_File_Size_Error", Math.ceil(wrap.maxSize / 1024 / 1024)), { level: "error" }); self.fireEvent(BI.File.EVENT_ERROR, { errorType: 1, file: item }); } else { wrap.files.unshift(item); - // BI.Msg.toast(value); } } } diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index 41e1ca0de..e868a5747 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -206,14 +206,29 @@ BI.Input = BI.inherit(BI.Single, { this._lastValue = this.getValue(); }, - _checkValidationOnValueChange: function () { - var o = this.options; + _checkValidationOnValueChange: function (callback) { + var self = this, o = this.options; var v = this.getValue(); - this.setValid( - (o.allowBlank === true && BI.trim(v) == "") || ( - BI.isNotEmptyString(BI.trim(v)) && o.validationChecker.apply(this, [BI.trim(v)]) !== false - ) - ); + if (o.allowBlank === true && BI.trim(v) == "") { + this.setValid(true); + callback && callback(); + return; + } + if (BI.trim(v) == "") { + this.setValid(false); + callback && callback(); + return; + } + var checker = o.validationChecker.apply(this, [BI.trim(v)]); + if (checker instanceof Promise) { + checker.then(function (validate) { + self.setValid(validate !== false); + callback && callback(); + }) + } else { + this.setValid(checker !== false); + callback && callback(); + } }, focus: function () { @@ -245,14 +260,16 @@ BI.Input = BI.inherit(BI.Single, { }, setValue: function (textValue) { + var self = this; this.element.val(textValue); - BI.nextTick(BI.bind(function () { - this._checkValidationOnValueChange(); - this._defaultState(); - if (this.isValid()) { - this._lastValidValue = this._lastSubmitValue = this.getValue(); - } - }, this)); + BI.nextTick(function () { + self._checkValidationOnValueChange(function () { + self._defaultState(); + if (self.isValid()) { + self._lastValidValue = self._lastSubmitValue = self.getValue(); + } + }); + }); }, getValue: function () { diff --git a/src/base/single/tip/tip.toast.js b/src/base/single/tip/tip.toast.js index ffbf2b336..a9a7aeb7e 100644 --- a/src/base/single/tip/tip.toast.js +++ b/src/base/single/tip/tip.toast.js @@ -8,7 +8,7 @@ BI.Toast = BI.inherit(BI.Tip, { _const: { closableMinWidth: 146, - minWidth: 124, + minWidth: 100, closableMaxWidth: 410, maxWidth: 400, hgap: 8 @@ -20,7 +20,8 @@ BI.Toast = BI.inherit(BI.Tip, { text: "", level: "success", // success或warning autoClose: true, - closable: null + closable: null, + vgap: 7, }); }, @@ -56,6 +57,9 @@ BI.Toast = BI.inherit(BI.Tip, { case "warning": cls = "toast-warning-font"; break; + case "loading": + cls = "toast-loading-font anim-rotate"; + break; case "normal": default: cls = "toast-message-font"; @@ -99,7 +103,7 @@ BI.Toast = BI.inherit(BI.Tip, { horizontalAlign: BI.HorizontalAlign.Stretch, element: this, items: items, - vgap: 12, + vgap: o.vgap, columnSize: columnSize }); }, diff --git a/src/case/button/item.multiselect.js b/src/case/button/item.multiselect.js index f72ea6e12..0d44b6da8 100644 --- a/src/case/button/item.multiselect.js +++ b/src/case/button/item.multiselect.js @@ -11,9 +11,6 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { tabIndex: 1 }, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - logic: { - dynamic: false - }, iconWrapperWidth: 26, }); }, diff --git a/src/case/button/item.singleselect.radio.js b/src/case/button/item.singleselect.radio.js index 882f912e9..a7c5fe04b 100644 --- a/src/case/button/item.singleselect.radio.js +++ b/src/case/button/item.singleselect.radio.js @@ -10,9 +10,6 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { attributes: { tabIndex: 1 }, - logic: { - dynamic: false - }, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, iconWrapperWidth: 16, textHgap: 10, @@ -31,6 +28,16 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { ref: function (_ref) { self.radio = _ref; }, + listeners: [ + { + eventName: BI.Controller.EVENT_CHANGE, + action: function (type) { + if (type === BI.Events.CLICK) { + self.setSelected(self.isSelected()); + } + } + } + ], }] }, { el: { diff --git a/src/case/button/node/node.arrow.js b/src/case/button/node/node.arrow.js index 052858e52..d0b21ca7c 100644 --- a/src/case/button/node/node.arrow.js +++ b/src/case/button/node/node.arrow.js @@ -6,9 +6,6 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, { var conf = BI.ArrowNode.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-arrow-group-node bi-list-item", - logic: { - dynamic: false - }, id: "", pId: "", open: false, @@ -20,7 +17,9 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, { render: function () { var self = this, o = this.options; this.checkbox = BI.createWidget({ - type: "bi.arrow_group_node_checkbox" + type: "bi.arrow_group_node_checkbox", + expandIcon: o.expandIcon, + collapseIcon: o.collapseIcon, }); return { type: "bi.vertical_adapt", diff --git a/src/case/button/node/node.icon.arrow.js b/src/case/button/node/node.icon.arrow.js index 1cfa52925..d641e655d 100644 --- a/src/case/button/node/node.icon.arrow.js +++ b/src/case/button/node/node.icon.arrow.js @@ -29,6 +29,8 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.arrow_group_node_checkbox", + expandIcon: o.expandIcon, + collapseIcon: o.collapseIcon, width: 24, stopPropagation: true }); diff --git a/src/case/button/node/node.plus.js b/src/case/button/node/node.plus.js index ec38ca0e0..4b9477ea7 100644 --- a/src/case/button/node/node.plus.js +++ b/src/case/button/node/node.plus.js @@ -9,13 +9,9 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { var conf = BI.PlusGroupNode.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-plus-group-node bi-list-item", - logic: { - dynamic: false - }, id: "", pId: "", open: false, - iconWrapperWidth: null, height: 24 }); }, diff --git a/src/case/button/switch.js b/src/case/button/switch.js index ba4de99d2..2cfbf8839 100644 --- a/src/case/button/switch.js +++ b/src/case/button/switch.js @@ -14,9 +14,6 @@ BI.Switch = BI.inherit(BI.BasicButton, { }, height: 20, width: 44, - logic: { - dynamic: false - }, showTip: false }, diff --git a/src/case/checkbox/check.arrownode.js b/src/case/checkbox/check.arrownode.js index 26447aca6..3347f83d0 100644 --- a/src/case/checkbox/check.arrownode.js +++ b/src/case/checkbox/check.arrownode.js @@ -3,18 +3,22 @@ * 右与下箭头切换的树节点 */ BI.ArrowTreeGroupNodeCheckbox = BI.inherit(BI.IconButton, { - _defaultConfig: function () { - return BI.extend(BI.ArrowTreeGroupNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-arrow-group-node-checkbox expander-right-font" - }); + + props: function (conf) { + return { + extraCls: "bi-arrow-group-node-checkbox " + (conf.collapseIcon || "expander-right-font"), + expandIcon: "expander-down-font", + collapseIcon: "expander-right-font" + }; }, setSelected: function (v) { + var o = this.options; BI.ArrowTreeGroupNodeCheckbox.superclass.setSelected.apply(this, arguments); if(v) { - this.element.removeClass("expander-right-font").addClass("expander-down-font"); + this.element.removeClass(o.collapseIcon).addClass(o.expandIcon); } else { - this.element.removeClass("expander-down-font").addClass("expander-right-font"); + this.element.removeClass(o.expandIcon).addClass(o.collapseIcon); } } }); diff --git a/src/case/colorchooser/colorchooser.js b/src/case/colorchooser/colorchooser.js index 737b3a189..991be4a77 100644 --- a/src/case/colorchooser/colorchooser.js +++ b/src/case/colorchooser/colorchooser.js @@ -13,6 +13,7 @@ BI.ColorChooser = BI.inherit(BI.Widget, { value: "", height: 24, el: {}, + simple: false }); }, @@ -30,6 +31,7 @@ BI.ColorChooser = BI.inherit(BI.Widget, { isNeedAdjustHeight: false, el: BI.extend({ type: o.width <= 24 ? "bi.color_chooser_trigger" : "bi.long_color_chooser_trigger", + simple: o.simple, ref: function (_ref) { self.trigger = _ref; }, diff --git a/src/case/colorchooser/colorchooser.simple.js b/src/case/colorchooser/colorchooser.simple.js index b360efbf3..28517ea6d 100644 --- a/src/case/colorchooser/colorchooser.simple.js +++ b/src/case/colorchooser/colorchooser.simple.js @@ -20,6 +20,7 @@ BI.SimpleColorChooser = BI.inherit(BI.Widget, { this.combo = BI.createWidget({ type: "bi.color_chooser", + simple: o.simple, element: this, container: o.container, value: o.value, @@ -61,4 +62,4 @@ BI.SimpleColorChooser = BI.inherit(BI.Widget, { }); BI.SimpleColorChooser.EVENT_CHANGE = "EVENT_CHANGE"; BI.SimpleColorChooser.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; -BI.shortcut("bi.simple_color_chooser", BI.SimpleColorChooser); \ No newline at end of file +BI.shortcut("bi.simple_color_chooser", BI.SimpleColorChooser); diff --git a/src/case/colorchooser/colorchooser.trigger.js b/src/case/colorchooser/colorchooser.trigger.js index 9f8e370e7..af2039226 100644 --- a/src/case/colorchooser/colorchooser.trigger.js +++ b/src/case/colorchooser/colorchooser.trigger.js @@ -10,7 +10,7 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, { _defaultConfig: function (config) { var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border"), + baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), height: 22 }); }, diff --git a/src/case/colorchooser/colorchooser.trigger.long.js b/src/case/colorchooser/colorchooser.trigger.long.js index e6c518c08..773b3d326 100644 --- a/src/case/colorchooser/colorchooser.trigger.long.js +++ b/src/case/colorchooser/colorchooser.trigger.long.js @@ -10,7 +10,7 @@ BI.LongColorChooserTrigger = BI.inherit(BI.Trigger, { _defaultConfig: function (config) { var conf = BI.LongColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border"), + baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), height: 24 }); }, diff --git a/src/case/combo/bubblecombo/popup.bubble.js b/src/case/combo/bubblecombo/popup.bubble.js index c65905821..7bc1f500c 100644 --- a/src/case/combo/bubblecombo/popup.bubble.js +++ b/src/case/combo/bubblecombo/popup.bubble.js @@ -48,8 +48,8 @@ BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, { if (BI.isWidget(buttonOpt)) { items.push({ el: buttonOpt, - lgap: i === 0 ? 20 : 15, - rgap: i === o.buttons.length - 1 ? 20 : 0 + lgap: i === 0 ? 15 : 10, + rgap: i === o.buttons.length - 1 ? 15 : 0 }); } else { items.push({ @@ -60,14 +60,14 @@ BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, { self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v); } }, buttonOpt), - lgap: i === 0 ? 20 : 15, - rgap: i === o.buttons.length - 1 ? 20 : 0 + lgap: i === 0 ? 15 : 10, + rgap: i === o.buttons.length - 1 ? 15 : 0 }); } }); return BI.createWidget({ type: "bi.right_vertical_adapt", - height: 54, + height: 44, items: items }); }, @@ -90,7 +90,7 @@ BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, { }] }); - button.element.css("min-height", o.minHeight - 54); + button.element.css("min-height", o.minHeight - 44); return button; } diff --git a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js index 92732d9b1..a4d324da1 100644 --- a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js +++ b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js @@ -5,7 +5,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { _defaultConfig: function (config) { return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-icon-text-value-combo bi-border-radius " + (config.simple ? "bi-border-bottom" : "bi-border"), + baseCls: "bi-icon-text-value-combo " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), height: 24, iconHeight: null, iconWidth: null, diff --git a/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js index ac3fad335..8de574c76 100644 --- a/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js +++ b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js @@ -11,6 +11,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { items: [], tipType: "", warningTitle: "", + allowClear: false, }, render: function () { @@ -21,105 +22,86 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { self.populate(newValue); }) : o.items; + + var height = BI.isNumeric(o.height) ? (o.height - (o.simple ? 1 : 2)) : o.height; + var width = BI.isNumeric(o.width) ? (o.width - 2) : o.width; + return { - type: "bi.absolute", - items: [{ + type: "bi.combo", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", + container: o.container, + adjustLength: 2, + height: height, + width: width, + toggle: false, + ref: function () { + self.combo = this; + }, + el: { + type: "bi.search_text_value_trigger", + cls: "search-text-value-trigger", + watermark: o.watermark, + ref: function () { + self.trigger = this; + }, + items: o.items, + height: height, + text: o.text, + defaultText: o.defaultText, + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, + title: o.title, + allowClear: o.allowClear, + listeners: [{ + eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()[0]); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }, { + eventName: BI.SearchTextValueTrigger.EVENT_CLEAR, + action: function () { + self._clear(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + popup: { el: { - type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-focus-shadow", - container: o.container, - adjustLength: 2, - toggle: false, + type: "bi.text_value_combo_popup", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + value: o.value, + items: o.items, ref: function () { - self.combo = this; - }, - el: { - type: "bi.search_text_value_trigger", - cls: "search-text-value-trigger", - watermark: o.watermark, - ref: function () { - self.trigger = this; - }, - items: o.items, - height: o.height - (o.simple ? 1 : 2), - text: o.text, - defaultText: o.defaultText, - value: o.value, - tipType: o.tipType, - warningTitle: o.warningTitle, - title: o.title, - listeners: [{ - eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, - action: function () { - self.setValue(this.getValue()); - self.combo.hideView(); - self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); - } - }] - }, - popup: { - el: { - type: "bi.text_value_combo_popup", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - value: o.value, - items: o.items, - ref: function () { - self.popup = this; - self.trigger.getSearcher().setAdapter(self.popup); - }, - listeners: [{ - eventName: BI.TextValueComboPopup.EVENT_CHANGE, - action: function () { - self.setValue(this.getValue()); - self.combo.hideView(); - self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); - } - }] - }, - value: o.value, - maxHeight: 252, - minHeight: 25 + self.popup = this; + self.trigger.getSearcher().setAdapter(self.popup); }, listeners: [{ - eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + eventName: BI.TextValueComboPopup.EVENT_CHANGE, action: function () { - self.trigger.stopEditing(); - } - }, { - eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, - action: function () { - self.fireEvent(BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW); - } - }], - hideChecker: function (e) { - return self.triggerBtn.element.find(e.target).length === 0; - } - }, - left: 0, - right: 0, - bottom: 0, - top: 0 - }, { - el: { - type: "bi.trigger_icon_button", - cls: "trigger-icon-button", - ref: function () { - self.triggerBtn = this; - }, - width: o.height, - height: o.height, - handler: function () { - if (self.combo.isViewVisible()) { + self.setValue(this.getValue()[0]); self.combo.hideView(); - } else { - self.combo.showView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); } - } + }] }, - right: 0, - bottom: 0, - top: 0 - }] + value: o.value, + maxHeight: 252, + minHeight: 25 + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function () { + self.trigger.stopEditing(); + } + }, { + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, + action: function () { + self.fireEvent(BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW); + } + }], }; }, @@ -130,6 +112,10 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { } }, + _clear: function () { + this.setValue(); + }, + _checkError: function (v) { if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { this.trigger.options.tipType = "success"; diff --git a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js index 7e84a4452..3344d1804 100644 --- a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js +++ b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js @@ -5,16 +5,33 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { props: function () { return { - extraCls: "bi-search-text-value-trigger", + baseCls: "bi-search-text-value-trigger", height: 24, - watermark: BI.i18nText("BI-Basic_Search") + watermark: BI.i18nText("BI-Basic_Search"), + allowClear: false, + title: () => this.editor.getText(), }; }, render: function () { var self = this, o = this.options; + + var triggerButton = { + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function () { + self.triggerBtn = this; + }, + width: o.height, + height: o.height, + width: 24, + }; + + var stateText = this._digest(o.value, o.items) || o.text; + return { - type: "bi.htape", + type: "bi.horizontal_fill", + columnSize: ["fill", 24], items: [ { el: { @@ -24,16 +41,15 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { }, isAutoSearch: false, el: { - type: "bi.state_editor", + type: "bi.default_text_editor", ref: function () { self.editor = this; }, watermark: o.watermark, defaultText: o.defaultText, - text: this._digest(o.value, o.items), + text: stateText, value: o.value, height: o.height, - tipText: "" }, popup: { type: "bi.search_text_value_combo_popup", @@ -55,10 +71,31 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { }] } }, { - el: { - type: "bi.layout", - width: 24 - }, + el: o.allowClear ? { + type: "bi.vertical_adapt", + horizontalAlign: "left", + scrollable: false, + items: [ + { + el: { + type: "bi.icon_button", + ref: function (_ref) { + self.clearBtn = _ref; + }, + cls: "close-h-font " + (o.allowClear ? "clear-button" : ""), + stopPropagation: true, + invisible: !BI.isNotEmptyString(stateText), + width: o.height, + height: o.height, + handler: function () { + self.fireEvent(BI.SearchTextValueTrigger.EVENT_CLEAR); + }, + }, + }, { + el: triggerButton, + } + ] + } : triggerButton, width: 24 } ] @@ -69,22 +106,11 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { this.editor.setState(v); }, - _digest: function (vals, items) { - var o = this.options; - vals = BI.isArray(vals) ? vals : [vals]; - var result = []; - var formatItems = BI.Tree.transformToArrayFormat(items); - BI.each(formatItems, function (i, item) { - if (BI.deepContains(vals, item.value) && !BI.contains(result, item.text || item.value)) { - result.push(item.text || item.value); - } + _digest: function (value, items) { + var result = BI.find(items, function (i, item) { + return item.value === value; }); - - if (result.length > 0) { - return result.join(","); - } else { - return BI.isFunction(o.text) ? o.text() : o.text; - } + return result?.text; }, stopEditing: function () { @@ -100,7 +126,9 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { }, setValue: function (vals) { - this._setState(this._digest(vals, this.options.items)); + var digestText = this._digest(vals, this.options.items); + this._setState(digestText); + this.options.allowClear && this.clearBtn.setVisible(BI.isNotEmptyString(digestText)); }, getValue: function () { @@ -111,4 +139,5 @@ BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SearchTextValueTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger); diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 6b9ef321b..19b9425e3 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -7,11 +7,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { _defaultConfig: function (config) { return BI.extend(BI.TextValueCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-text-value-combo " + (config.simple ? "bi-border-bottom" : "bi-border"), + baseCls: "bi-text-value-combo " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), height: 24, chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, text: "", value: "", + allowClear: false, }); }, @@ -33,7 +34,17 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { height: o.height, text: o.text, value: o.value, - warningTitle: o.warningTitle + warningTitle: o.warningTitle, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.SelectTextTrigger.EVENT_CLEAR, + action: function () { + self._clear(); + self.fireEvent(BI.TextValueCombo.EVENT_CHANGE); + } + } + ], }); this.popup = BI.createWidget({ type: "bi.text_value_combo_popup", @@ -62,28 +73,32 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { minHeight: 25 } }); - if(BI.isKey(o.value)) { + if (BI.isKey(o.value)) { this._checkError(o.value); } }, + _clear: function () { + this.setValue(); + }, + _checkError: function (v) { - if(BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { - this.trigger.options.tipType = "success"; - this.element.removeClass("combo-error"); - } else { - v = BI.isArray(v) ? v : [v]; - var result = BI.find(this.options.items, function (idx, item) { - return BI.contains(v, item.value); - }); - if (BI.isNull(result)) { - this.trigger.setTipType("warning"); - this.element.removeClass("combo-error").addClass("combo-error"); - } else { - this.trigger.setTipType("success"); - this.element.removeClass("combo-error"); + v = BI.isArray(v) ? v[0] : v; + var tipType = null; + var result = BI.find(this.options.items, function (idx, item) { + return v === item.value; + }); + if (BI.isNull(result)) { + if (this.isEnabled()) { + tipType = "warning"; } + this.element.addClass("error"); + this.trigger.element.addClass("error"); + } else { + this.element.removeClass("error"); + this.trigger.element.removeClass("error"); } + this.trigger.setTipType(tipType); }, setValue: function (v) { diff --git a/src/case/editor/editor.clear.js b/src/case/editor/editor.clear.js index 253d32431..6fd199a43 100644 --- a/src/case/editor/editor.clear.js +++ b/src/case/editor/editor.clear.js @@ -17,8 +17,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, { }); }, _init: function () { - BI.ClearEditor.superclass._init.apply(this, arguments); var self = this, o = this.options; + o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) : o.value; + BI.ClearEditor.superclass._init.apply(this, arguments); this.editor = BI.createWidget({ type: "bi.editor", simple: o.simple, diff --git a/src/case/editor/editor.defaulttext.js b/src/case/editor/editor.defaulttext.js new file mode 100644 index 000000000..5c01c7a01 --- /dev/null +++ b/src/case/editor/editor.defaulttext.js @@ -0,0 +1,282 @@ +/** + * dailer + * 有默认提示文字的输入框 + * @class BI.DefaultTextEditor + * @extends BI.Widget + */ +BI.DefaultTextEditor = BI.inherit(BI.Widget, { + props: function () { + return { + baseCls: "bi-default-text-editor", + hgap: 4, + vgap: 2, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + validationChecker: BI.emptyFn, + quitChecker: BI.emptyFn, + allowBlank: true, + watermark: "", + errorText: "", + height: 24, + defaultText: "", // 默认显示值,默认显示值与显示值的区别是默认显示值标记灰色 + text: "", // 显示值 + el: {} + }; + }, + + render: function () { + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.editor", + simple: o.simple, + height: o.height, + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap, + value: o.value, + validationChecker: o.validationChecker, + quitChecker: o.quitChecker, + allowBlank: o.allowBlank, + watermark: o.watermark, + errorText: o.errorText, + invisible: true, + }); + this.text = BI.createWidget({ + type: "bi.text_button", + cls: BI.isKey(o.text) ? "tip-text-style" : "bi-water-mark tip-text-style", + textAlign: "left", + height: o.height, + text: BI.isKey(o.text) ? o.text : o.defaultText, + hgap: o.hgap + 2, + handler: function () { + self._showInput(); + self.editor.focus(); + self.editor.setValue(""); + }, + title: o.title, + warningTitle: o.warningTitle, + tipType: o.tipType + }); + this.text.on(BI.TextButton.EVENT_CHANGE, function () { + BI.nextTick(function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_CLICK_LABEL); + }); + }); + + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.editor.on(BI.Editor.EVENT_FOCUS, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_FOCUS, arguments); + }); + this.editor.on(BI.Editor.EVENT_BLUR, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_BLUR, arguments); + }); + this.editor.on(BI.Editor.EVENT_CLICK, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_CLICK, arguments); + }); + this.editor.on(BI.Editor.EVENT_CHANGE, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_CHANGE, arguments); + }); + this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { + self.fireEvent(BI.DefaultTextEditor.EVENT_KEY_DOWN, arguments); + }); + + this.editor.on(BI.Editor.EVENT_VALID, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_VALID, arguments); + }); + this.editor.on(BI.Editor.EVENT_CONFIRM, function () { + self._showHint(); + self.fireEvent(BI.DefaultTextEditor.EVENT_CONFIRM, arguments); + }); + this.editor.on(BI.Editor.EVENT_CHANGE_CONFIRM, function () { + self._showHint(); + self.fireEvent(BI.DefaultTextEditor.EVENT_CHANGE_CONFIRM, arguments); + }); + this.editor.on(BI.Editor.EVENT_START, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_START, arguments); + }); + this.editor.on(BI.Editor.EVENT_PAUSE, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_PAUSE, arguments); + }); + this.editor.on(BI.Editor.EVENT_STOP, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_STOP, arguments); + }); + this.editor.on(BI.Editor.EVENT_SPACE, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_SPACE, arguments); + }); + this.editor.on(BI.Editor.EVENT_ERROR, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_ERROR, arguments); + }); + this.editor.on(BI.Editor.EVENT_ENTER, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_ENTER, arguments); + }); + this.editor.on(BI.Editor.EVENT_RESTRICT, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_RESTRICT, arguments); + }); + this.editor.on(BI.Editor.EVENT_EMPTY, function () { + self.fireEvent(BI.DefaultTextEditor.EVENT_EMPTY, arguments); + }); + + return { + type: "bi.absolute", + items: [ + { + el: this.editor, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: this.text, + left: 0, + right: 0, + top: 0, + bottom: 0 + } + ] + }; + }, + + setWaterMark: function (v) { + this.options.watermark = v; + this.editor.setWaterMark(v); + }, + + setTitle: function (title) { + this.text.setTitle(title); + }, + + setWarningTitle: function (title) { + this.text.setWarningTitle(title); + }, + + doRedMark: function () { + if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { + return; + } + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doHighLight: function () { + if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { + return; + } + this.text.doHighLight.apply(this.text, arguments); + }, + + unHighLight: function () { + this.text.unHighLight.apply(this.text, arguments); + }, + + focus: function () { + if (this.options.disabled === false) { + this._showInput(); + this.editor.focus(); + } + }, + + blur: function () { + this.editor.blur(); + this._showHint(); + }, + + _showInput: function () { + this.editor.visible(); + this.text.invisible(); + }, + + _showHint: function () { + this.editor.invisible(); + this.text.visible(); + }, + + _setText: function (v) { + this.text.setText(v); + this.text.setTitle(v); + }, + + isValid: function () { + return this.editor.isValid(); + }, + + setErrorText: function (text) { + this.editor.setErrorText(text); + }, + + getErrorText: function () { + return this.editor.getErrorText(); + }, + + isEditing: function () { + return this.editor.isEditing(); + }, + + getLastValidValue: function () { + return this.editor.getLastValidValue(); + }, + + getLastChangedValue: function () { + return this.editor.getLastChangedValue(); + }, + + setValue: function (k) { + this.editor.setValue(k); + }, + + getValue: function () { + return this.editor.getValue(); + }, + + getState: function () { + return this.text.getValue(); + }, + + setState: function (v) { + var o = this.options; + if (BI.isKey(v)) { + this.text.setText(v); + this.text.element.removeClass("bi-water-mark"); + return; + } + this.text.setText(o.defaultText); + this.text.element.addClass("bi-water-mark"); + }, + + setTipType: function (v) { + this.text.options.tipType = v; + }, + + getText: function () { + return this.text.getText(); + } +}); +BI.DefaultTextEditor.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DefaultTextEditor.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DefaultTextEditor.EVENT_BLUR = "EVENT_BLUR"; +BI.DefaultTextEditor.EVENT_CLICK = "EVENT_CLICK"; +BI.DefaultTextEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.DefaultTextEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; + +BI.DefaultTextEditor.EVENT_START = "EVENT_START"; +BI.DefaultTextEditor.EVENT_PAUSE = "EVENT_PAUSE"; +BI.DefaultTextEditor.EVENT_STOP = "EVENT_STOP"; +BI.DefaultTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DefaultTextEditor.EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"; +BI.DefaultTextEditor.EVENT_VALID = "EVENT_VALID"; +BI.DefaultTextEditor.EVENT_ERROR = "EVENT_ERROR"; +BI.DefaultTextEditor.EVENT_ENTER = "EVENT_ENTER"; +BI.DefaultTextEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; +BI.DefaultTextEditor.EVENT_SPACE = "EVENT_SPACE"; +BI.DefaultTextEditor.EVENT_EMPTY = "EVENT_EMPTY"; + +BI.shortcut("bi.default_text_editor", BI.DefaultTextEditor); diff --git a/src/case/editor/editor.shelter.js b/src/case/editor/editor.shelter.js index dec410d87..39def9d77 100644 --- a/src/case/editor/editor.shelter.js +++ b/src/case/editor/editor.shelter.js @@ -26,8 +26,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, { }, _init: function () { - BI.ShelterEditor.superclass._init.apply(this, arguments); var self = this, o = this.options; + o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) : o.value; + BI.ShelterEditor.superclass._init.apply(this, arguments); this.editor = BI.createWidget({ type: "bi.editor", simple: o.simple, diff --git a/src/case/editor/editor.sign.js b/src/case/editor/editor.sign.js index f2ae0560f..330c31dfe 100644 --- a/src/case/editor/editor.sign.js +++ b/src/case/editor/editor.sign.js @@ -26,8 +26,11 @@ BI.SignEditor = BI.inherit(BI.Widget, { }, _init: function () { - BI.SignEditor.superclass._init.apply(this, arguments); var self = this, o = this.options; + o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) : o.value; + BI.SignEditor.superclass._init.apply(this, arguments); this.editor = BI.createWidget({ type: "bi.editor", simple: o.simple, @@ -171,6 +174,10 @@ BI.SignEditor = BI.inherit(BI.Widget, { this.text.setTitle(title); }, + setTipType: function (v) { + this.text.setTipType(v); + }, + setWarningTitle: function (title) { this.text.setWarningTitle(title); }, @@ -275,4 +282,4 @@ BI.SignEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; BI.SignEditor.EVENT_SPACE = "EVENT_SPACE"; BI.SignEditor.EVENT_EMPTY = "EVENT_EMPTY"; -BI.shortcut("bi.sign_editor", BI.SignEditor); \ No newline at end of file +BI.shortcut("bi.sign_editor", BI.SignEditor); diff --git a/src/case/layer/panel.js b/src/case/layer/panel.js index d24b7b546..949f8cbd5 100644 --- a/src/case/layer/panel.js +++ b/src/case/layer/panel.js @@ -8,6 +8,7 @@ BI.Panel = BI.inherit(BI.Widget, { return BI.extend(BI.Panel.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-panel bi-border", title: "", + titleHeight: 30, titleButtons: [], el: {}, logic: { @@ -34,7 +35,7 @@ BI.Panel = BI.inherit(BI.Widget, { type: "bi.label", cls: "panel-title-text", text: o.title, - height: 30 + height: o.titleHeight }); this.button_group = BI.createWidget({ @@ -58,7 +59,7 @@ BI.Panel = BI.inherit(BI.Widget, { el: { type: "bi.left_right_vertical_adapt", cls: "panel-title bi-header-background bi-border-bottom", - height: 29, + height: o.titleHeight - 1, items: { left: [this.text], right: [this.button_group] @@ -66,7 +67,7 @@ BI.Panel = BI.inherit(BI.Widget, { lhgap: 10, rhgap: 10 }, - height: 29 + height: o.titleHeight - 1 }; }, diff --git a/src/case/tree/treeexpander/tree.expander.popup.js b/src/case/tree/treeexpander/tree.expander.popup.js index bf2c6addb..96f9fe259 100644 --- a/src/case/tree/treeexpander/tree.expander.popup.js +++ b/src/case/tree/treeexpander/tree.expander.popup.js @@ -22,8 +22,8 @@ this.popupView.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); - this.popupView.element.css("margin-left", -offset * o.layer); - this.element.css("margin-left", offset * o.layer); + this.popupView.element.css("margin-left", -offset * (o.layer + 1)); + this.element.css("margin-left", offset * (o.layer + 1)); return { type: "bi.vertical", diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index e8ee789df..8acee1c78 100644 --- a/src/case/trigger/trigger.text.js +++ b/src/case/trigger/trigger.text.js @@ -7,25 +7,27 @@ */ BI.TextTrigger = BI.inherit(BI.Trigger, { - _defaultConfig: function () { + props: function () { var self = this; - var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-trigger", + return { + baseCls: "bi-text-trigger", height: 24, textHgap: 6, textCls: "", + allowClear: false, title: function () { return self.text.getText(); } - }); + }; }, - _init: function () { - BI.TextTrigger.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options, c = this._const; - this.text = BI.createWidget({ + var text = { type: "bi.label", + ref: function (_ref) { + self.text = _ref; + }, cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""), textAlign: "left", height: o.height, @@ -39,32 +41,59 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { tgap: o.textTgap, bgap: o.textBgap, readonly: o.readonly - }); - this.trigerButton = BI.createWidget({ + }; + + var triggerButton = { type: "bi.trigger_icon_button", + ref: function (_ref) { + self.triggerButton = _ref; + }, width: o.triggerWidth || o.height - }); + }; - BI.createWidget({ - element: this, + return ({ type: "bi.horizontal_fill", + columnSize: ["fill", o.triggerWidth || o.height], items: [ { - el: this.text, + el: text, width: "fill" }, { - el: this.trigerButton, - width: o.triggerWidth || o.height + el: o.allowClear ? { + type: "bi.vertical_adapt", + horizontalAlign: "left", + scrollable: false, + items: [ + { + el: { + type: "bi.icon_button", + ref: function (_ref) { + self.clearBtn = _ref; + }, + cls: "close-h-font " + (o.allowClear ? "clear-button" : ""), + stopPropagation: true, + width: o.triggerWidth || o.height, + height: o.height, + invisible: !BI.isNotEmptyString(o.text), + handler: function () { + self.fireEvent(BI.TextTrigger.EVENT_CLEAR); + }, + }, + }, { + el: triggerButton, + } + ] + } : triggerButton, } ] }); }, - getTextor: function() { + getTextor: function () { return this.text; }, - setTextCls: function(cls) { + setTextCls: function (cls) { var o = this.options; var oldCls = o.textCls; o.textCls = cls; @@ -73,6 +102,9 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { setText: function (text) { this.text.setText(text); + if (this.options.allowClear) { + this.clearBtn.setVisible(BI.isNotEmptyString(text)); + } }, setTipType: function (v) { @@ -80,4 +112,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { this.options.tipType = v; } }); + +BI.TextTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.text_trigger", BI.TextTrigger); diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 8b24c1c9c..4ec177764 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -11,6 +11,8 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-select-text-trigger", height: 24, + allowClear: false, + valueFormatter: BI.emptyFn, }); }, @@ -32,11 +34,21 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { textTgap: o.textTgap, textBgap: o.textBgap, tipType: o.tipType, - warningTitle: o.warningTitle + warningTitle: o.warningTitle, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.TextTrigger.EVENT_CLEAR, + action: function () { + self.setText(""); + self.fireEvent(BI.SelectTextTrigger.EVENT_CLEAR); + } + } + ] }); }, - _digest: function(vals, items){ + _digest: function (vals, items) { var o = this.options; vals = BI.isArray(vals) ? vals : [vals]; var result = []; @@ -50,16 +62,21 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { if (result.length > 0) { return { textCls: "", - text: result.join(",") - } + text: o.valueFormatter(vals[0]) || result.join(","), // 只保留单个value的场景,后续会把BI.isArray(vals) ? vals : [vals];这种都去掉 + }; } else { return { textCls: "bi-water-mark", text: BI.isFunction(o.text) ? o.text() : o.text - } + }; } }, + setText: function (text) { + this.options.text = text; + this.trigger.setText(text); + }, + setValue: function (vals) { var formatValue = this._digest(vals, this.options.items); this.trigger.setTextCls(formatValue.textCls); @@ -67,10 +84,11 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { }, setTipType: function (v) { + this.options.tipType = v; this.trigger.setTipType(v); }, - getTextor: function() { + getTextor: function () { return this.trigger.getTextor(); }, @@ -78,4 +96,6 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { this.options.items = items; } }); + +BI.SelectTextTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger); diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index 2ee02010f..2ba474460 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -110,7 +110,7 @@ BI.TreeView = BI.inherit(BI.Pane, { }; var className = "dark", perTime = 100; - function onClick (event, treeId, treeNode) { + function onClick(event, treeId, treeNode) { // 当前点击节点的状态是半选,且为true_part, 则将其改为false_part,使得点击半选后切换到的是全选 var checked = treeNode.checked; var status = treeNode.getCheckStatus(); @@ -121,7 +121,7 @@ BI.TreeView = BI.inherit(BI.Pane, { self.nodes.checkNode(treeNode, !checked, true, true); } - function getUrl (treeId, treeNode) { + function getUrl(treeId, treeNode) { var parentNode = self._getParentValues(treeNode); treeNode.times = treeNode.times || 1; var param = "id=" + treeNode.id @@ -132,7 +132,7 @@ BI.TreeView = BI.inherit(BI.Pane, { return "&" + param; } - function beforeExpand (treeId, treeNode) { + function beforeExpand(treeId, treeNode) { if (!treeNode.isAjaxing) { if (!treeNode.children) { treeNode.times = 1; @@ -147,7 +147,7 @@ BI.TreeView = BI.inherit(BI.Pane, { } - function onAsyncSuccess (event, treeId, treeNode, msg) { + function onAsyncSuccess(event, treeId, treeNode, msg) { treeNode.halfCheck = false; if (!msg || msg.length === 0 || /^[\s,\S]*<\/html>$/gi.test(msg) || self._stop) { return; @@ -170,14 +170,14 @@ BI.TreeView = BI.inherit(BI.Pane, { } } - function onAsyncError (event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) { + function onAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) { var zTree = self.nodes; BI.Msg.toast("Error!", "warning"); // treeNode.icon = ""; // zTree.updateNode(treeNode); } - function ajaxGetNodes (treeNode, reloadType) { + function ajaxGetNodes(treeNode, reloadType) { var zTree = self.nodes; if (reloadType == "refresh") { zTree.updateNode(treeNode); // 刷新一下当前节点,如果treeNode.xxx被改了的话 @@ -185,7 +185,7 @@ BI.TreeView = BI.inherit(BI.Pane, { zTree.reAsyncChildNodes(treeNode, reloadType, true); // 强制加载子节点,reloadType === refresh为先清空再加载,否则为追加到现有子节点之后 } - function beforeCheck (treeId, treeNode) { + function beforeCheck(treeId, treeNode) { if (treeNode.disabled) { return false; } @@ -195,7 +195,7 @@ BI.TreeView = BI.inherit(BI.Pane, { if (treeNode.checked === true) { // 将展开的节点halfCheck设为false,解决展开节点存在halfCheck=true的情况 guy // 所有的半选状态都需要取消halfCheck=true的情况 - function track (children) { + function track(children) { BI.each(children, function (i, ch) { if (ch.halfCheck === true) { ch.halfCheck = false; @@ -217,24 +217,18 @@ BI.TreeView = BI.inherit(BI.Pane, { } } - function onCheck (event, treeId, treeNode) { + function onCheck(event, treeId, treeNode) { if (treeNode.disabled) { return false; } self._selectTreeNode(treeId, treeNode); } - function onExpand (event, treeId, treeNode) { - if (treeNode.disabled) { - return false; - } + function onExpand(event, treeId, treeNode) { treeNode.halfCheck = false; } - function onCollapse (event, treeId, treeNode) { - if (treeNode.disabled) { - return false; - } + function onCollapse(event, treeId, treeNode) { } return setting; @@ -325,7 +319,7 @@ BI.TreeView = BI.inherit(BI.Pane, { var hashMap = {}; var rootNoots = this.nodes.getNodes(); track(rootNoots); // 可以看到这个方法没有递归调用,所以在_getHalfSelectedValues中需要关心全选的节点 - function track (nodes) { + function track(nodes) { BI.each(nodes, function (i, node) { var checkState = node.getCheckStatus(); if (checkState.checked === true || checkState.half === true) { @@ -503,7 +497,7 @@ BI.TreeView = BI.inherit(BI.Pane, { }, checkAll: function (checked) { - function setNode (children) { + function setNode(children) { BI.each(children, function (i, child) { child.halfCheck = false; setNode(child.children); @@ -545,7 +539,7 @@ BI.TreeView = BI.inherit(BI.Pane, { BI.each(values, function (v, op) { var nodes = treeObj.getNodesByParam(param, v, null); BI.each(nodes, function (j, node) { - BI.extend(node, {checked: true}, op); + BI.extend(node, { checked: true }, op); treeObj.updateNode(node); }); }); diff --git a/src/case/ztree/1.asynctree.js b/src/case/ztree/1.asynctree.js index 261f2d112..0bc90c55b 100644 --- a/src/case/ztree/1.asynctree.js +++ b/src/case/ztree/1.asynctree.js @@ -58,7 +58,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { } }; - function onClick (event, treeId, treeNode) { + function onClick(event, treeId, treeNode) { if (treeNode.disabled) { return false; } @@ -72,7 +72,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { zTree.checkNode(treeNode, !checked, true, true); } - function beforeCheck (treeId, treeNode) { + function beforeCheck(treeId, treeNode) { if (treeNode.disabled) { return false; } @@ -82,7 +82,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { if (treeNode.checked === true) { // 将展开的节点halfCheck设为false,解决展开节点存在halfCheck=true的情况 guy // 所有的半选状态都需要取消halfCheck=true的情况 - function track (children) { + function track(children) { BI.each(children, function (i, ch) { ch.halfCheck = false; track(ch.children); @@ -103,31 +103,22 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { } } - function beforeExpand (treeId, treeNode) { - if (treeNode.disabled) { - return false; - } + function beforeExpand(treeId, treeNode) { self._beforeExpandNode(treeId, treeNode); } - function onCheck (event, treeId, treeNode) { + function onCheck(event, treeId, treeNode) { if (treeNode.disabled) { return false; } self._selectTreeNode(treeId, treeNode); } - function onExpand (event, treeId, treeNode) { - if (treeNode.disabled) { - return false; - } + function onExpand(event, treeId, treeNode) { treeNode.halfCheck = false; } - function onCollapse (event, treeId, treeNode) { - if (treeNode.disabled) { - return false; - } + function onCollapse(event, treeId, treeNode) { treeNode.halfCheck = false; } @@ -216,7 +207,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { track([], valueA, valueB); track([], valueB, valueA); - function track (parent, node, compare) { + function track(parent, node, compare) { BI.each(node, function (n, item) { if (BI.isNull(compare[n])) { self._addTreeNode(map, parent, n, item); diff --git a/src/core/platform/web/config.js b/src/core/platform/web/config.js index 3bd279aab..eeda344b0 100644 --- a/src/core/platform/web/config.js +++ b/src/core/platform/web/config.js @@ -45,6 +45,25 @@ BI.prepares.push(function () { scrollx: true }, ob, {type: "bi.inline"}); }); + BI.Plugin.configWidget("bi.vertical", function (ob) { + if (ob.horizontalAlign === BI.HorizontalAlign.Left || ob.horizontalAlign === BI.HorizontalAlign.Right) { + if (isSupportFlex()) { + return BI.extend({}, ob, {type: "bi.flex_vertical"}); + } + return BI.extend({}, ob, { + horizontalAlign: BI.HorizontalAlign.Stretch, + type: "bi.vertical", + items: BI.map(ob.items, function (i, item) { + return { + type: "bi.inline", + horizontalAlign: ob.horizontalAlign, + items: [item] + }; + }) + }); + } + return ob; + }); BI.Plugin.configWidget("bi.inline", function (ob) { // 当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了,降级table处理吧 var hasAutoAndFillColumnSize = false; diff --git a/src/core/system.js b/src/core/system.js index 123bd88be..652a9c256 100644 --- a/src/core/system.js +++ b/src/core/system.js @@ -7,6 +7,7 @@ !(function () { var system = { dependencies: {}, + layoutOptimize: false, responsiveMode: false, workerMode: false, size: { @@ -24,7 +25,7 @@ // 具体尺寸还没定,先写着 var sizeMap = { "S": 10, - "M" : 20, + "M": 20, "L": 24 }; @@ -44,6 +45,10 @@ system.workerMode = !!mode; }; + this.setLayoutOptimize = function (layoutOptimize) { + system.layoutOptimize = layoutOptimize; + }; + this.addDependency = function (moduleId, minVersion, maxVersion) { system.dependencies[moduleId] = { min: minVersion, @@ -77,6 +82,10 @@ return system.workerMode; }, + getLayoutOptimize: function () { + return system.layoutOptimize; + }, + getDependencies: function () { return system.dependencies; } diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 2bb053c6d..7a41ee0ae 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -16,7 +16,7 @@ BI.Layout = BI.inherit(BI.Widget, { scrolly: false, // true, false items: [], innerHgap: 0, - innerVgap: 0, + innerVgap: 0 }; }, @@ -292,6 +292,43 @@ BI.Layout = BI.inherit(BI.Widget, { return (gap > 0 && gap < 1) ? (gap * 100).toFixed(1) + "%" : gap / BI.pixRatio + BI.pixUnit; }, + _optimiseItemLgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? ((item._lgap || 0) + (item.lgap || 0)) : item._lgap) || 0; + } + return (item._lgap || 0) + (item.lgap || 0); + }, + _optimiseItemRgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? ((item._rgap || 0) + (item.rgap || 0)) : item._rgap) || 0; + } + return (item._rgap || 0) + (item.rgap || 0); + }, + _optimiseItemTgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? ((item._tgap || 0) + (item.tgap || 0)) : item._tgap) || 0; + } + return (item._tgap || 0) + (item.tgap || 0); + }, + _optimiseItemBgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? ((item._bgap || 0) + (item.bgap || 0)) : item._bgap) || 0; + } + return (item._bgap || 0) + (item.bgap || 0); + }, + _optimiseItemHgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? ((item._hgap || 0) + (item.hgap || 0)) : item._hgap) || 0; + } + return (item._hgap || 0) + (item.hgap || 0); + }, + _optimiseItemVgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? ((item._vgap || 0) + (item.vgap || 0)) : item._vgap) || 0; + } + return (item._vgap || 0) + (item.vgap || 0); + }, + _handleGap: function (w, item, hIndex, vIndex) { var o = this.options; var innerLgap, innerRgap, innerTgap, innerBgap; @@ -304,26 +341,26 @@ BI.Layout = BI.inherit(BI.Widget, { innerTgap = vIndex === 0 ? o.innerVgap : 0; innerBgap = vIndex === o.items.length - 1 ? o.innerVgap : 0; } - if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - var top = ((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0); + if (o.vgap + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = ((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - var left = ((BI.isNull(hIndex) || hIndex === 0) ? o.hgap : 0) + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0); + if (o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = ((BI.isNull(hIndex) || hIndex === 0) ? o.hgap : 0) + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - var right = o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0); + if (o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-right": this._optimiseGap(right) }); } - if (o.vgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - var bottom = o.vgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0); + if (o.vgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = o.vgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-bottom": this._optimiseGap(bottom) }); @@ -337,27 +374,27 @@ BI.Layout = BI.inherit(BI.Widget, { innerLgap = innerRgap = o.innerHgap; innerTgap = index === 0 ? o.innerVgap : 0; innerBgap = index === o.items.length - 1 ? o.innerVgap : 0; - if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + (item.tgap || 0) + (item.vgap || 0); + if (o.vgap + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - var left = o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0); + if (o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - var right = o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0); + if (o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-right": this._optimiseGap(right) }); } // 这里的代码是关键 - if (o.vgap + o.hgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + innerBgap + (item.bgap || 0) + (item.vgap || 0); + if (o.vgap + o.hgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-bottom": this._optimiseGap(bottom) }); diff --git a/src/core/wrapper/layout/adapt/absolute.center.js b/src/core/wrapper/layout/adapt/absolute.center.js index 67d37c4bc..14a122f00 100644 --- a/src/core/wrapper/layout/adapt/absolute.center.js +++ b/src/core/wrapper/layout/adapt/absolute.center.js @@ -30,10 +30,10 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { var w = BI.AbsoluteCenterLayout.superclass._addElement.apply(this, arguments); w.element.css({ position: "absolute", - left: this._optimiseGap(o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)), - right: this._optimiseGap(o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)), - top: this._optimiseGap(o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)), - bottom: this._optimiseGap(o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)), + left: this._optimiseGap(o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item)), + right: this._optimiseGap(o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item)), + top: this._optimiseGap(o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item)), + bottom: this._optimiseGap(o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item)), margin: "auto" }); return w; diff --git a/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js b/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js index 148897cfe..25d5aab94 100644 --- a/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js +++ b/src/core/wrapper/layout/adapt/absolute.leftrightvertical.js @@ -37,7 +37,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { }, _formatItems: function (items) { - var o = this.options; + var self = this, o = this.options; var left, right; if (BI.isArray(items)) { BI.each(items, function (i, item) { @@ -56,17 +56,17 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { el: BI.stripEL(item), width: item.width }; - if (o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - json.tgap = o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0); + if (o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { + json.tgap = o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item); } - if (o.lhgap + o.llgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + (item.lgap || 0) + (item.hgap || 0); + if (o.lhgap + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } - if (o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - json.bgap = o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0); + if (o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { + json.bgap = o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); } return json; }); @@ -75,17 +75,17 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { el: BI.stripEL(item), width: item.width }; - if (o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - json.tgap = o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0); + if (o.rvgap + o.rtgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { + json.tgap = o.rvgap + o.rtgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item); } - if (o.rhgap + o.rlgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + (item.lgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } - if (o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - json.bgap = o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0); + if (o.rvgap + o.rbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { + json.bgap = o.rvgap + o.rbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); } return json; }); diff --git a/src/core/wrapper/layout/adapt/adapt.table.js b/src/core/wrapper/layout/adapt/adapt.table.js index 9af2aa8cc..5691840af 100644 --- a/src/core/wrapper/layout/adapt/adapt.table.js +++ b/src/core/wrapper/layout/adapt/adapt.table.js @@ -70,8 +70,8 @@ BI.TableAdaptLayout = BI.inherit(BI.Layout, { td.element.width(width); } if (o.verticalAlign === BI.VerticalAlign.Stretch) { - var top = o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0), - bottom = o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0); + var top = o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item), + bottom = o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css("height", "calc(100% - " + this._optimiseGap(top + bottom) + ")"); } // 对于表现为td的元素设置最大宽度,有几点需要注意 diff --git a/src/core/wrapper/layout/fill/auto.vtape.js b/src/core/wrapper/layout/fill/auto.vtape.js index 16491ebab..efc784f5d 100644 --- a/src/core/wrapper/layout/fill/auto.vtape.js +++ b/src/core/wrapper/layout/fill/auto.vtape.js @@ -60,10 +60,10 @@ BI.AutoVerticalTapeLayout = BI.inherit(BI.Layout, { if (preRowSize === "") { preRowSize = self.layout.getWidgetByName(self._getChildName(i - 1)).element.height(); } - top[i] = top[i - 1] + preRowSize + (items[i - 1].tgap || 0) + (items[i - 1].bgap || 0) + 2 * (items[i - 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + top[i] = top[i - 1] + preRowSize + self._optimiseItemTgap(items[i - 1]) + self._optimiseItemBgap(items[i - 1]) + 2 * self._optimiseItemVgap(items[i - 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - top: self._optimiseGap(top[i] + (item.vgap || 0) + (item.tgap || 0) + o.vgap + o.tgap) + top: self._optimiseGap(top[i] + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) + o.vgap + o.tgap) }); if (rowSize === "fill") { @@ -81,10 +81,10 @@ BI.AutoVerticalTapeLayout = BI.inherit(BI.Layout, { if (nextRowSize === "") { nextRowSize = self.layout.getWidgetByName(self._getChildName(i + 1)).element.height(); } - bottom[i] = bottom[i + 1] + nextRowSize + (items[i + 1].tgap || 0) + (items[i + 1].bgap || 0) + 2 * (items[i + 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + bottom[i] = bottom[i + 1] + nextRowSize + self._optimiseItemTgap(items[i + 1]) + self._optimiseItemBgap(items[i + 1]) + 2 * self._optimiseItemVgap(items[i + 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - bottom: self._optimiseGap(bottom[i] + (item.vgap || 0) + (item.bgap || 0) + o.vgap + o.bgap), + bottom: self._optimiseGap(bottom[i] + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) + o.vgap + o.bgap), }); if (rowSize === "fill") { diff --git a/src/core/wrapper/layout/fill/float.fill.horizontal.js b/src/core/wrapper/layout/fill/float.fill.horizontal.js index d6607703b..512ffb627 100644 --- a/src/core/wrapper/layout/fill/float.fill.horizontal.js +++ b/src/core/wrapper/layout/fill/float.fill.horizontal.js @@ -45,41 +45,41 @@ BI.FloatHorizontalFillLayout = BI.inherit(BI.Layout, { } else { var w = BI._lazyCreateWidget(item); } - if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.tgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { w.element.css({ - "margin-top": self._optimiseGap(o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) + "margin-top": self._optimiseGap(o.vgap + o.tgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item)) }); } if (desc) { - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-right": self._optimiseGap((i === o.items.length - 1 ? o.hgap : 0) + o.rgap + (item.rgap || 0) + (item.hgap || 0)) + "margin-right": self._optimiseGap((i === o.items.length - 1 ? o.hgap : 0) + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item)) }); } - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-left": self._optimiseGap(o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)) + "margin-left": self._optimiseGap(o.hgap + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item)) }); } } else { - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-left": self._optimiseGap((i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) + "margin-left": self._optimiseGap((i === 0 ? o.hgap : 0) + o.lgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item)) }); } - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { w.element.css({ - "margin-right": self._optimiseGap(o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) + "margin-right": self._optimiseGap(o.hgap + o.rgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item)) }); } } - if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.bgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { w.element.css({ - "margin-bottom": self._optimiseGap(o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) + "margin-bottom": self._optimiseGap(o.vgap + o.bgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item)) }); } - var top = o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0), - bottom = o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0); + var top = o.vgap + o.tgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item), + bottom = o.vgap + o.bgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); if (o.verticalAlign === BI.VerticalAlign.Stretch && BI.isNull(item.height)) { w.element.css({ height: "calc(100% - " + self._optimiseGap(top + bottom) + ")" diff --git a/src/core/wrapper/layout/flex/flex.horizontal.js b/src/core/wrapper/layout/flex/flex.horizontal.js index 7d53dfe0e..75326335b 100644 --- a/src/core/wrapper/layout/flex/flex.horizontal.js +++ b/src/core/wrapper/layout/flex/flex.horizontal.js @@ -82,6 +82,9 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { if (columnSize === "fill") { w.element.addClass("f-f"); } + if (columnSize === "" || columnSize === "auto") { + w.element.addClass("f-auto"); + } w.element.addClass("c-e"); if (i === 0) { w.element.addClass("f-c"); diff --git a/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js b/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js index 322d48fb4..b52b1e456 100644 --- a/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js +++ b/src/core/wrapper/layout/flex/flex.leftrightvertical.center.js @@ -2,6 +2,7 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { props: function () { return BI.extend(BI.FlexLeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-f-lr-v-c", + columnSize: [], items: {}, llgap: 0, lrgap: 0, @@ -20,22 +21,24 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { render: function () { var o = this.options, self = this; BI.FlexLeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments); + var items = this._formatItems(o.items); return { type: "bi.flex_vertical_adapt", ref: function (_ref) { self.layout = _ref; }, - items: this._formatItems(o.items), + columnSize: o.columnSize.slice(0, (o.items.left || []).length).concat((o.items.right || []).length > 0 ? [""] : []), + items: items, scrollx: o.scrollx, scrolly: o.scrolly, scrollable: o.scrollable, innerHgap: o.innerHgap, - innerVgap: o.innerVgap, + innerVgap: o.innerVgap }; }, _formatItems: function (items) { - var o = this.options; + var self = this, o = this.options; var left, right; if (BI.isArray(items)) { BI.each(items, function (i, item) { @@ -53,23 +56,24 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { var json = { el: BI.stripEL(item) }; - if (o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - json.tgap = o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0); + if (o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) !== 0) { + json.tgap = o.lvgap + o.ltgap + self._optimiseItemTgap(item) + self._optimiseItemVgap(item); } - if (o.lhgap + o.llgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + (item.lgap || 0) + (item.hgap || 0); + if (o.lhgap + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } - if (o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - json.bgap = o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0); + if (o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) !== 0) { + json.bgap = o.lvgap + o.lbgap + self._optimiseItemBgap(item) + self._optimiseItemVgap(item); } return json; }); return leftItems.concat({ el: { type: "bi.flex_vertical_adapt", + columnSize: o.columnSize.slice(leftItems.length), css: { "margin-left": "auto" }, diff --git a/src/core/wrapper/layout/flex/flex.vertical.js b/src/core/wrapper/layout/flex/flex.vertical.js index 46b175e9b..1c56586cc 100644 --- a/src/core/wrapper/layout/flex/flex.vertical.js +++ b/src/core/wrapper/layout/flex/flex.vertical.js @@ -81,6 +81,9 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, { if (rowSize === "fill") { w.element.addClass("f-f"); } + if (rowSize === "" || rowSize === "auto") { + w.element.addClass("f-auto"); + } w.element.addClass("c-e"); if (i === 0) { w.element.addClass("f-c"); 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 8c803abaa..fa90b0543 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js @@ -79,6 +79,10 @@ BI.FlexWrapperHorizontalLayout = BI.inherit(BI.Layout, { w.element.addClass("f-f"); this.element.addClass("f-f"); } + if (columnSize === "" || columnSize === "auto") { + w.element.addClass("f-auto"); + this.element.addClass("f-auto"); + } w.element.addClass("c-e"); if (i === 0) { w.element.addClass("f-c"); 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 33609e717..76beeb601 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js @@ -79,6 +79,10 @@ BI.FlexWrapperVerticalLayout = BI.inherit(BI.Layout, { w.element.addClass("f-f"); this.element.addClass("f-f"); } + if (rowSize === "" || rowSize === "auto") { + w.element.addClass("f-auto"); + this.element.addClass("f-auto"); + } w.element.addClass("c-e"); if (i === 0) { w.element.addClass("f-c"); diff --git a/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js b/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js index 26bea2558..9de105651 100644 --- a/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js +++ b/src/core/wrapper/layout/float/float.absolute.leftrightvertical.js @@ -38,7 +38,7 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { }, _formatItems: function (items) { - var o = this.options; + var self = this, o = this.options; var left, right; if (BI.isArray(items)) { BI.each(items, function (i, item) { @@ -68,11 +68,11 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { // if (o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { // json.tgap = o.lvgap + o.ltgap + (item.tgap || 0) + (item.vgap || 0); // } - if (o.lhgap + o.llgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + (item.lgap || 0) + (item.hgap || 0); + if (o.lhgap + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.lhgap + o.lrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.lhgap + o.lrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } // if (o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { // json.bgap = o.lvgap + o.lbgap + (item.bgap || 0) + (item.vgap || 0); @@ -95,11 +95,11 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { // if (o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { // json.tgap = o.rvgap + o.rtgap + (item.tgap || 0) + (item.vgap || 0); // } - if (o.rhgap + o.rlgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + (item.lgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) !== 0) { + json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + self._optimiseItemLgap(item) + self._optimiseItemHgap(item); } - if (o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - json.rgap = o.rhgap + o.rrgap + (item.rgap || 0) + (item.hgap || 0); + if (o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) !== 0) { + json.rgap = o.rhgap + o.rrgap + self._optimiseItemRgap(item) + self._optimiseItemHgap(item); } // if (o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { // json.bgap = o.rvgap + o.rbgap + (item.bgap || 0) + (item.vgap || 0); diff --git a/src/core/wrapper/layout/layout.flow.js b/src/core/wrapper/layout/layout.flow.js index 4efc35123..e3c26638d 100644 --- a/src/core/wrapper/layout/layout.flow.js +++ b/src/core/wrapper/layout/layout.flow.js @@ -56,26 +56,26 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, { if (BI.isNotNull(item.bottom)) { w.element.css({bottom: BI.isNumber(item.bottom) ? this._optimiseGap(item.bottom) : item.bottom}); } - if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - var top = o.vgap / 2 + o.tgap + (item.tgap || 0) + (item.vgap || 0); + if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - var left = o.hgap / 2 + o.lgap + (item.lgap || 0) + (item.hgap || 0); + if (o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - var right = o.hgap / 2 + o.rgap + (item.rgap || 0) + (item.hgap || 0); + if (o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ "margin-right": this._optimiseGap(right) }); } - if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - var bottom = o.vgap / 2 + o.bgap + (item.bgap || 0) + (item.vgap || 0); + if (o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ "margin-bottom": this._optimiseGap(bottom) }); @@ -148,24 +148,28 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, { if (BI.isNotNull(item.bottom)) { w.element.css({bottom: BI.isNumber(item.bottom) ? item.bottom / BI.pixRatio + BI.pixUnit : item.bottom}); } - if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { + var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); w.element.css({ - "margin-top": (o.vgap / 2 + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { + var left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); w.element.css({ - "margin-left": (o.hgap / 2 + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { + if (o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { + var right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); w.element.css({ - "margin-right": (o.hgap / 2 + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-right": this._optimiseGap(right) }); } - if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { + if (o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { + var bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); w.element.css({ - "margin-bottom": (o.vgap / 2 + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit + "margin-bottom": this._optimiseGap(bottom) }); } return w; diff --git a/src/core/wrapper/layout/layout.inline.js b/src/core/wrapper/layout/layout.inline.js index a1d889337..99fa1b96e 100644 --- a/src/core/wrapper/layout/layout.inline.js +++ b/src/core/wrapper/layout/layout.inline.js @@ -40,7 +40,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, { _addElement: function (i, item) { var o = this.options; var w = BI.InlineLayout.superclass._addElement.apply(this, arguments); - var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width >= 1 ? null : item.width; + var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; if (o.columnSize.length > 0) { if (item.width >= 1 && o.columnSize[i] >= 1 && o.columnSize[i] !== item.width) { columnSize = null; @@ -66,7 +66,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, { autoCount++; cz = 0; } - gap += o.hgap + o.lgap + o.rgap + (o.items[k].lgap || 0) + (o.items[k].rgap || 0) + (o.items[k].hgap || 0); + gap += o.hgap + o.lgap + o.rgap + this._optimiseItemLgap(o.items[k]) + this._optimiseItemRgap(o.items[k]) + this._optimiseItemHgap(o.items[k]); length += cz; } length = length > 0 && length < 1 ? (length * 100).toFixed(1) + "%" : length / BI.pixRatio + BI.pixUnit; @@ -84,8 +84,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, { } this._handleGap(w, item, i); if (o.verticalAlign === BI.VerticalAlign.Stretch && BI.isNull(item.height)) { - var top = o.innerVgap + o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0), - bottom = o.innerVgap + o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0); + var top = o.innerVgap + o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item), + bottom = o.innerVgap + o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); var gap = (top + bottom) > 0 && (top + bottom) < 1 ? ((top + bottom) * 100).toFixed(1) + "%" : (top + bottom) / BI.pixRatio + BI.pixUnit; w.element.css("height", "calc(100% - " + gap + ")"); } diff --git a/src/core/wrapper/layout/layout.tape.js b/src/core/wrapper/layout/layout.tape.js index 8652862da..a3fa8bcf0 100644 --- a/src/core/wrapper/layout/layout.tape.js +++ b/src/core/wrapper/layout/layout.tape.js @@ -53,8 +53,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { } w.element.css({ position: "absolute", - top: self._optimiseGap((item.vgap || 0) + (item.tgap || 0) + o.innerVgap + o.vgap + o.tgap), - bottom: self._optimiseGap((item.bgap || 0) + (item.vgap || 0) + o.innerVgap + o.vgap + o.bgap), + top: self._optimiseGap(self._optimiseItemTgap(item) + self._optimiseItemVgap(item) + o.innerVgap + o.vgap + o.tgap), + bottom: self._optimiseGap(self._optimiseItemBgap(item) + self._optimiseItemVgap(item) + o.innerVgap + o.vgap + o.bgap), width: BI.isNumber(columnSize) ? self._optimiseGap(columnSize) : "" }); if (o.verticalAlign === BI.VerticalAlign.Middle) { @@ -86,10 +86,10 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { } if (BI.isNull(left[i])) { var preColumnSize = o.columnSize.length > 0 ? o.columnSize[i - 1] : items[i - 1].width; - left[i] = left[i - 1] + preColumnSize + (items[i - 1].lgap || 0) + (items[i - 1].rgap || 0) + 2 * (items[i - 1].hgap || 0) + o.hgap + o.lgap + o.rgap; + left[i] = left[i - 1] + preColumnSize + self._optimiseItemLgap(items[i - 1]) + self._optimiseItemRgap(items[i - 1]) + 2 * self._optimiseItemHgap(items[i - 1]) + o.hgap + o.lgap + o.rgap; } w.element.css({ - left: self._optimiseGap(left[i] + (item.lgap || 0) + (item.hgap || 0) + o.hgap + o.lgap) + left: self._optimiseGap(left[i] + self._optimiseItemLgap(item) + self._optimiseItemHgap(item) + o.hgap + o.lgap) }); if (columnSize === "" || columnSize === "fill") { @@ -104,10 +104,10 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; if (BI.isNull(right[i])) { var nextColumnSize = o.columnSize.length > 0 ? o.columnSize[i + 1] : items[i + 1].width; - right[i] = right[i + 1] + nextColumnSize + (items[i + 1].lgap || 0) + (items[i + 1].rgap || 0) + 2 * (items[i + 1].hgap || 0) + o.hgap + o.lgap + o.rgap; + right[i] = right[i + 1] + nextColumnSize + self._optimiseItemLgap(items[i + 1]) + self._optimiseItemRgap(items[i + 1]) + 2 * self._optimiseItemHgap(items[i + 1]) + o.hgap + o.lgap + o.rgap; } w.element.css({ - right: self._optimiseGap(right[i] + (item.rgap || 0) + (item.hgap || 0) + o.hgap + o.rgap) + right: self._optimiseGap(right[i] + self._optimiseItemRgap(item) + self._optimiseItemHgap(item) + o.hgap + o.rgap) }); if (columnSize === "" || columnSize === "fill") { @@ -178,8 +178,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { } w.element.css({ position: "absolute", - left: self._optimiseGap((item.lgap || 0) + (item.hgap || 0) + o.innerHgap + o.hgap + o.lgap), - right: self._optimiseGap((item.hgap || 0) + (item.rgap || 0) + o.innerHgap + o.hgap + o.rgap), + left: self._optimiseGap(self._optimiseItemLgap(item) + self._optimiseItemHgap(item) + o.innerHgap + o.hgap + o.lgap), + right: self._optimiseGap(self._optimiseItemRgap(item) + self._optimiseItemHgap(item) + o.innerHgap + o.hgap + o.rgap), height: BI.isNumber(rowSize) ? self._optimiseGap(rowSize) : "" }); if (o.horizontalAlign === BI.HorizontalAlign.Center) { @@ -211,10 +211,10 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { } if (BI.isNull(top[i])) { var preRowSize = o.rowSize.length > 0 ? o.rowSize[i - 1] : items[i - 1].height; - top[i] = top[i - 1] + preRowSize + (items[i - 1].tgap || 0) + (items[i - 1].bgap || 0) + 2 * (items[i - 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + top[i] = top[i - 1] + preRowSize + self._optimiseItemTgap(items[i - 1]) + self._optimiseItemBgap(items[i - 1]) + 2 * self._optimiseItemVgap(items[i - 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - top: self._optimiseGap(top[i] + (item.vgap || 0) + (item.tgap || 0) + o.vgap + o.tgap) + top: self._optimiseGap(top[i] + self._optimiseItemTgap(item) + self._optimiseItemVgap(item) + o.vgap + o.tgap) }); if (rowSize === "" || rowSize === "fill") { @@ -229,10 +229,10 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { var rowSize = o.rowSize.length > 0 ? o.rowSize[i] : item.height; if (BI.isNull(bottom[i])) { var nextRowSize = o.rowSize.length > 0 ? o.rowSize[i + 1] : items[i + 1].height; - bottom[i] = bottom[i + 1] + nextRowSize + (items[i + 1].tgap || 0) + (items[i + 1].bgap || 0) + 2 * (items[i + 1].vgap || 0) + o.vgap + o.tgap + o.bgap; + bottom[i] = bottom[i + 1] + nextRowSize + self._optimiseItemTgap(items[i + 1]) + self._optimiseItemBgap(items[i + 1]) + 2 * self._optimiseItemVgap(items[i + 1]) + o.vgap + o.tgap + o.bgap; } w.element.css({ - bottom: self._optimiseGap(bottom[i] + (item.vgap || 0) + (item.bgap || 0) + o.vgap + o.bgap) + bottom: self._optimiseGap(bottom[i] + self._optimiseItemBgap(item) + self._optimiseItemVgap(item) + o.vgap + o.bgap) }); if (rowSize === "" || rowSize === "fill") { diff --git a/src/core/wrapper/layout/layout.td.js b/src/core/wrapper/layout/layout.td.js index 17a469754..cb3221570 100644 --- a/src/core/wrapper/layout/layout.td.js +++ b/src/core/wrapper/layout/layout.td.js @@ -92,8 +92,8 @@ BI.TdLayout = BI.inherit(BI.Layout, { for (var i = 0; i < arr.length; i++) { var w = BI._lazyCreateWidget(arr[i]); if (o.verticalAlign === BI.VerticalAlign.Stretch) { - var top = o.vgap + o.tgap + (arr[i].tgap || 0) + (arr[i].vgap || 0), - bottom = o.vgap + o.bgap + (arr[i].bgap || 0) + (arr[i].vgap || 0); + var top = o.vgap + o.tgap + this._optimiseItemTgap(arr[i]) + this._optimiseItemVgap(arr[i]), + bottom = o.vgap + o.bgap + this._optimiseItemBgap(arr[i]) + this._optimiseItemVgap(arr[i]); w.element.css("height", "calc(100% - " + this._optimiseGap(top + bottom) + ")"); } w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"}); diff --git a/src/core/wrapper/layout/sticky/sticky.horizontal.js b/src/core/wrapper/layout/sticky/sticky.horizontal.js index c5b644542..a59dd6edf 100644 --- a/src/core/wrapper/layout/sticky/sticky.horizontal.js +++ b/src/core/wrapper/layout/sticky/sticky.horizontal.js @@ -5,7 +5,8 @@ BI.HorizontalStickyLayout = BI.inherit(BI.FlexHorizontalLayout, { props: function () { return BI.extend(BI.HorizontalStickyLayout.superclass.props.apply(this, arguments), { extraCls: "bi-h-sticky", - horizontalAlign: BI.HorizontalAlign.Stretch, + scrollx: true, + // horizontalAlign: BI.HorizontalAlign.Stretch, verticalAlign: BI.VerticalAlign.Stretch }); }, diff --git a/src/core/wrapper/layout/sticky/sticky.vertical.js b/src/core/wrapper/layout/sticky/sticky.vertical.js index a5ba3d837..970d84eef 100644 --- a/src/core/wrapper/layout/sticky/sticky.vertical.js +++ b/src/core/wrapper/layout/sticky/sticky.vertical.js @@ -5,8 +5,9 @@ BI.VerticalStickyLayout = BI.inherit(BI.FlexVerticalLayout, { props: function () { return BI.extend(BI.VerticalStickyLayout.superclass.props.apply(this, arguments), { extraCls: "bi-v-sticky", + scrolly: true, horizontalAlign: BI.HorizontalAlign.Stretch, - verticalAlign: BI.VerticalAlign.Stretch + // verticalAlign: BI.VerticalAlign.Stretch }); }, diff --git a/src/less/base/colorchooser/colorchooser.trigger.less b/src/less/base/colorchooser/colorchooser.trigger.less index a647bb9f2..721231f3c 100644 --- a/src/less/base/colorchooser/colorchooser.trigger.less +++ b/src/less/base/colorchooser/colorchooser.trigger.less @@ -1,9 +1,5 @@ @import "../../index.less"; -.bi-color-chooser-trigger { - .border-radius(2px); -} - .bi-combo-popup { &>.bi-color-chooser-trigger { border-color: @color-bi-border-hover-combo; diff --git a/src/less/base/combo/combo.less b/src/less/base/combo/combo.less index 9725ac58a..206953d4b 100644 --- a/src/less/base/combo/combo.less +++ b/src/less/base/combo/combo.less @@ -1,19 +1,22 @@ @import "../../index.less"; + @val: transform .3s ease; .bi-combo { & > .bi-trigger { - & .bi-trigger-icon-button{ + & .bi-trigger-icon-button { & .x-icon { .rotate(0deg); .transition(@val); } } } + &.bi-combo-popup { display: block !important; visibility: visible !important; + & > .bi-trigger { - & .bi-trigger-icon-button{ + & .bi-trigger-icon-button { & .x-icon { .rotate(180deg); .transition(@val); @@ -21,11 +24,13 @@ } } } + &.bi-combo-popup, &.bi-combo-hover, &:hover { &.bi-border, &.bi-border-bottom { border-color: @color-bi-border-hover-combo; } } + &.disabled { &.bi-combo-hover, &:hover { &.bi-border, &.bi-border-bottom { @@ -33,6 +38,36 @@ } } } + + &.error { + &.bi-combo-hover, &:hover { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + } + } + + + // 将来统一变成combo的特性 + //&.status-error { + // &.bi-border, &.bi-border-bottom { + // border-color: @border-color-negative; + // } + // + // .bi-trigger .select-text-label { + // color: @color-bi-text-error-text-trigger; + // } + //} + // + //&.status-warning { + // &.bi-border, &.bi-border-bottom { + // border-color: @border-color-warning; + // } + // + // .bi-trigger .select-text-label { + // color: @font-color-warning; + // } + //} } .bi-theme-dark { diff --git a/src/less/base/combo/combo.searchtextvalue.less b/src/less/base/combo/combo.searchtextvalue.less index 5d5a5524c..6ae0eca15 100644 --- a/src/less/base/combo/combo.searchtextvalue.less +++ b/src/less/base/combo/combo.searchtextvalue.less @@ -1,33 +1,19 @@ @import "../../index.less"; -@val: transform .3s ease; -.bi-search-text-value-combo{ - & .trigger-icon-button{ + +.bi-search-text-value-combo { + & .trigger-icon-button { font-size: 16px; } - & .search-text-value-trigger{ - .border-radius(2px); - } + &.combo-error { - & .bi-search-text-value-trigger{ + & .bi-search-text-value-trigger { & .bi-text-button { color: @color-bi-text-error-hover-search-text-value-combo; } } - &>.bi-border, &>.bi-border-bottom { + + &.bi-border, &.bi-border-bottom { border-color: @border-color-negative; } } - // 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 - & .bi-combo.bi-combo-popup + .bi-trigger-icon-button { - & .x-icon { - .rotate(180deg); - .transition(@val); - } - } - & .bi-combo + .bi-trigger-icon-button { - & .x-icon { - .rotate(0deg); - .transition(@val); - } - } } diff --git a/src/less/base/combo/combo.textvalue.less b/src/less/base/combo/combo.textvalue.less deleted file mode 100644 index 1feec1972..000000000 --- a/src/less/base/combo/combo.textvalue.less +++ /dev/null @@ -1,14 +0,0 @@ -@import "../../index.less"; - -.bi-text-value-combo { - &.combo-error { - & .bi-select-text-trigger { - & .select-text-label { - color: @color-bi-text-error-hover-text-value-combo; - } - } - &.bi-border, &.bi-border-bottom { - border-color: @border-color-negative; - } - } -} \ No newline at end of file diff --git a/src/less/base/editor/editor.search.less b/src/less/base/editor/editor.search.less index cf29965b0..0793d33be 100644 --- a/src/less/base/editor/editor.search.less +++ b/src/less/base/editor/editor.search.less @@ -1,7 +1,6 @@ @import "../../index.less"; /*************BI.SearchEditor******************/ .bi-search-editor { - .border-radius(2px); & .circle-close-font{ font-size: @font-size-18; } diff --git a/src/less/base/single/button/button.less b/src/less/base/single/button/button.less index e34c4f5f0..f6f24bfa6 100644 --- a/src/less/base/single/button/button.less +++ b/src/less/base/single/button/button.less @@ -41,6 +41,22 @@ body .bi-button, #body .bi-button { &, & .b-font:before { color: @color-bi-text-common-button; } + &.light { + border-width: 0; + background-color: @color-bi-background-common-light-button; + + &, & .b-font:before { + color: @color-bi-text-common-light-button; + } + + &:hover, &:focus { + background-color: @color-bi-background-hover-common-light-button; + } + + &.active { + background-color: @color-bi-background-active-common-light-button; + } + } &.clear, &.clear .b-font:before { color: @color-bi-text-common-clear-button; } @@ -48,7 +64,7 @@ body .bi-button, #body .bi-button { &, & .b-font:before { color: @color-bi-text-common-ghost-button; } - &:hover, &:focus { + &:hover, &:focus, &:hover .b-font:before, &:focus .b-font:before { color: @color-bi-text; background-color: @color-bi-background-hover-common-ghost-button; } @@ -92,6 +108,22 @@ body .bi-button, #body .bi-button { background-color: @color-bi-background-success-button; border-color: @color-bi-border-success-button; } + &.light { + border-width: 0; + background-color: @color-bi-background-success-light-button; + + &, & .b-font:before { + color: @color-bi-text-success-light-button; + } + + &:hover, &:focus { + background-color: @color-bi-background-hover-success-light-button; + } + + &.active { + background-color: @color-bi-background-active-success-light-button; + } + } &.clear { &, & .b-font:before { color: @color-bi-text-success-clear-button; @@ -104,7 +136,7 @@ body .bi-button, #body .bi-button { color: @color-bi-text-success-ghost-button; } background-color: transparent; - &:hover, &:focus { + &:hover, &:focus, &:hover .b-font:before, &:focus .b-font:before { color: @color-bi-text; background-color: @color-bi-background-success-button; } @@ -121,6 +153,22 @@ body .bi-button, #body .bi-button { background-color: @color-bi-background-warning-button; border-color: @color-bi-border-warning-button; } + &.light { + border-width: 0; + background-color: @color-bi-background-warning-light-button; + + &, & .b-font:before { + color: @color-bi-text-warning-light-button; + } + + &:hover, &:focus { + background-color: @color-bi-background-hover-warning-light-button; + } + + &.active { + background-color: @color-bi-background-active-warning-light-button; + } + } &.clear { &, & .b-font:before { color: @color-bi-text-warning-clear-button; @@ -133,7 +181,7 @@ body .bi-button, #body .bi-button { color: @color-bi-text-warning-ghost-button; } background-color: transparent; - &:hover, &:focus { + &:hover, &:focus, &:hover .b-font:before, &:focus .b-font:before { color: @color-bi-text; background-color: @color-bi-background-warning-button; } @@ -150,6 +198,22 @@ body .bi-button, #body .bi-button { background-color: @color-bi-background-error-button; border-color: @color-bi-border-error-button; } + &.light { + border-width: 0; + background-color: @color-bi-background-error-light-button; + + &, & .b-font:before { + color: @color-bi-text-error-light-button; + } + + &:hover, &:focus { + background-color: @color-bi-background-hover-error-light-button; + } + + &.active { + background-color: @color-bi-background-active-error-light-button; + } + } &.clear { &, & .b-font:before { color: @color-bi-text-error-clear-button; @@ -162,7 +226,7 @@ body .bi-button, #body .bi-button { color: @color-bi-text-error-ghost-button; } background-color: transparent; - &:hover, &:focus { + &:hover, &:focus, &:hover .b-font:before, &:focus .b-font:before { color: @color-bi-text; background-color: @color-bi-background-error-button; } diff --git a/src/less/base/single/tip/tip.toast.less b/src/less/base/single/tip/tip.toast.less index 875dfa586..cb39afe70 100644 --- a/src/less/base/single/tip/tip.toast.less +++ b/src/less/base/single/tip/tip.toast.less @@ -1,22 +1,28 @@ @import "../../../index.less"; -.bi-toast{ +.bi-toast { color: @color-bi-color-toast-text; line-height: @font-size-16; .border-radius(2px); - &.toast-success{ + .box-shadow(0 6px 20px -2px, @color-bi-color-toast-shadow); + + &.toast-success { background: @color-bi-background-toast-success; } - &.toast-warning{ + + &.toast-warning { background: @color-bi-background-toast-warning; } - &.toast-error{ + + &.toast-error { background: @color-bi-background-toast-error; } - &.toast-normal, &.toast-common{ + + &.toast-normal, &.toast-common, &.toast-loading { background: @color-bi-background-toast-normal; } - & .toast-icon{ + + & .toast-icon { font-size: @font-size-16; } } diff --git a/src/less/base/tree/tree.expander.less b/src/less/base/tree/tree.expander.less index 04bdd64ac..b0e6ce76a 100644 --- a/src/less/base/tree/tree.expander.less +++ b/src/less/base/tree/tree.expander.less @@ -1,28 +1,42 @@ @import "../../index.less"; -@import "../../image.less"; @import "../../lib/icon.less"; -.bi-tree-expander-popup.line:before { - position: absolute; - content: ""; - height: 100%; - width: 24px; - .imagePath(@icon-tree-vertical-line-1, 0, 0, repeat-y); -} -.bi-tree-expander-popup.line.solid:before { - .imagePath(@icon-tree-solid-vertical-line-1, 0, 0, repeat-y); - width: 24px; - left: 8px; +.bi-tree-expander-popup.line { + + &:before { + border-left: 1px dashed @border-color-dark-gray-line; + position: absolute; + content: ""; + height: 100%; + left: -1px; + } + + &.solid:before { + border-left: 1px solid @border-color-dark-gray-line; + position: absolute; + content: ""; + height: 100%; + left: -1px; + } } .bi-theme-dark { - .bi-tree-expander-popup.line:before { - width: 24px; - .imagePath(@icon-tree-vertical-line-1-theme-dark, 0, 0, repeat-y); - } - .bi-tree-expander-popup.line.solid:before { - .imagePath(@icon-tree-solid-vertical-line-1-theme-dark, 0, 0, repeat-y); - width: 24px; - left: 8px; + .bi-tree-expander-popup.line { + + &:before { + border-left: 1px dashed @border-color-dark-gray-line-theme-dark; + position: absolute; + content: ""; + height: 100%; + left: -1px; + } + + &.solid:before { + border-left: 1px solid @border-color-dark-gray-line-theme-dark; + position: absolute; + content: ""; + height: 100%; + left: -1px; + } } } diff --git a/src/less/base/trigger/trigger.searchtextvalue.less b/src/less/base/trigger/trigger.searchtextvalue.less new file mode 100644 index 000000000..457589b20 --- /dev/null +++ b/src/less/base/trigger/trigger.searchtextvalue.less @@ -0,0 +1,15 @@ +@import "../../index.less"; + +.bi-search-text-value-trigger { + &.error .select-text-label { + color: @color-bi-text-error-text-trigger; + } + + .clear-button { + display: none; + } + + &:hover .clear-button { + display: block; + } +} diff --git a/src/less/base/trigger/trigger.text.less b/src/less/base/trigger/trigger.text.less new file mode 100644 index 000000000..758d7c48d --- /dev/null +++ b/src/less/base/trigger/trigger.text.less @@ -0,0 +1,15 @@ +@import "../../index.less"; + +.bi-text-trigger { + &.error .select-text-label { + color: @color-bi-text-error-text-trigger; + } + + .clear-button { + display: none; + } + + &:hover .clear-button { + display: block; + } +} diff --git a/src/less/core/utils/common.less b/src/less/core/utils/common.less index fd9b61c4a..036778c59 100644 --- a/src/less/core/utils/common.less +++ b/src/less/core/utils/common.less @@ -175,6 +175,18 @@ } } +.bi-theme-dark { + .bi-tips { + color: @color-bi-text-tips-theme-dark; + & .bi-input { + color: @color-bi-text-tips-theme-dark;; + } + & .bi-textarea { + color: @color-bi-text-tips-theme-dark; + } + } +} + // 边框 .bi-border { border: 1px solid @color-bi-border-line; @@ -339,6 +351,14 @@ .border-radius(2px); } +.bi-border-corner-left-radius { + .border-corner-left-radius(2px, 2px); +} + +.bi-border-corner-right-radius { + .border-corner-right-radius(2px, 2px); +} + .bi-font-bold { font-weight: 700; } diff --git a/src/less/core/wrapper/flex.horizontal.less b/src/less/core/wrapper/flex.horizontal.less index a6a38704d..1ae9458c5 100644 --- a/src/less/core/wrapper/flex.horizontal.less +++ b/src/less/core/wrapper/flex.horizontal.less @@ -169,7 +169,10 @@ } > .f-f { - min-width: 0; + &:not(.f-s-n) { + min-width: 1px; + } + -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; @@ -180,4 +183,10 @@ -ms-flex-shrink: 1; flex-shrink: 1; } + + > .f-auto { + &:not(.f-s-n) { + min-width: 1px; + } + } } diff --git a/src/less/core/wrapper/flex.vertical.less b/src/less/core/wrapper/flex.vertical.less index 5b97ea999..3d1b23d50 100644 --- a/src/less/core/wrapper/flex.vertical.less +++ b/src/less/core/wrapper/flex.vertical.less @@ -168,7 +168,10 @@ } > .f-f { - min-height: 0; + &:not(.f-s-n) { + min-height: 1px; + } + -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; @@ -179,4 +182,10 @@ -ms-flex-shrink: 1; flex-shrink: 1; } + + > .f-auto { + &:not(.f-s-n) { + min-width: 1px; + } + } } diff --git a/src/less/core/wrapper/flex.wrapper.horizontal.less b/src/less/core/wrapper/flex.wrapper.horizontal.less index 1b38fa0be..fedf8e853 100644 --- a/src/less/core/wrapper/flex.wrapper.horizontal.less +++ b/src/less/core/wrapper/flex.wrapper.horizontal.less @@ -265,7 +265,10 @@ } > .f-f { - min-width: 0; + &:not(.f-s-n) { + min-width: 1px; + } + -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; @@ -276,5 +279,11 @@ -ms-flex-shrink: 1; flex-shrink: 1; } + + > .f-auto { + &:not(.f-s-n) { + min-width: 1px; + } + } } } diff --git a/src/less/core/wrapper/flex.wrapper.vertical.less b/src/less/core/wrapper/flex.wrapper.vertical.less index 09693c348..32200f498 100644 --- a/src/less/core/wrapper/flex.wrapper.vertical.less +++ b/src/less/core/wrapper/flex.wrapper.vertical.less @@ -259,7 +259,10 @@ } > .f-f { - min-height: 0; + &:not(.f-s-n) { + min-height: 1px; + } + -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; @@ -270,5 +273,11 @@ -ms-flex-shrink: 1; flex-shrink: 1; } + + > .f-auto { + &:not(.f-s-n) { + min-width: 1px; + } + } } } diff --git a/src/less/lib/colors.less b/src/less/lib/colors.less index 060768c03..dca2a9989 100644 --- a/src/less/lib/colors.less +++ b/src/less/lib/colors.less @@ -34,6 +34,7 @@ @color-bi-text-success: @font-color-success; //失败字体颜色 @color-bi-text-failure: @font-color-negative; + //基本提亮颜色 @color-bi-text-highlight: @font-color-highlight; //标红色 @@ -98,6 +99,9 @@ @color-bi-background-highlight: @background-color-highlight; //背景提亮色(浅) @color-bi-background-light-highlight: @background-color-light-highlight; +// 浅蓝色的背景 +@color-bi-background-light-blue: @color-blue-10; + //黑色边框色 @color-bi-border-black: @border-color-black; diff --git a/src/less/lib/font.less b/src/less/lib/font.less index d4760ec0e..ce865e30e 100644 --- a/src/less/lib/font.less +++ b/src/less/lib/font.less @@ -51,6 +51,7 @@ @font-tip-success: "e1db"; @font-tip-warning: "e1d7"; @font-tip-message: "e1d9"; +@font-tip-loading: "e7cd"; @font-key: "e1d0"; diff --git a/src/less/lib/theme.less b/src/less/lib/theme.less index db42c9ef4..2a570c985 100644 --- a/src/less/lib/theme.less +++ b/src/less/lib/theme.less @@ -32,6 +32,7 @@ @color-bi-color-toast-error: @color-bi-text; @color-bi-color-toast-normal: @color-bi-text; @color-bi-color-toast-text: @color-bi-text; +@color-bi-color-toast-shadow: @color-bi-background-black; //bubble @color-bi-background-bubble-success: @color-bi-background-light-success; @@ -72,6 +73,12 @@ @color-bi-background-hover-common-ghost-button: @color-bi-background-highlight; @color-bi-text-hover-common-ghost-button-theme-dark: @color-bi-text-normal; @color-bi-background-hover-common-ghost-button-theme-dark: @color-bi-background-default; + +@color-bi-text-common-light-button: @color-bi-text-highlight; +@color-bi-background-common-light-button: @color-bi-background-light-blue; +@color-bi-background-hover-common-light-button: @color-bi-background-light-blue; +@color-bi-background-active-common-light-button: @color-bi-background-light-blue; + @color-bi-background-active-common-ghost-button: @color-bi-background-highlight; @color-bi-background-active-common-ghost-button-theme-dark: @color-bi-background-default; @color-bi-text-ignore-button: @color-bi-text-highlight; @@ -80,18 +87,34 @@ @color-bi-background-ignore-button-theme-dark: @color-bi-background-default-theme-dark; @color-bi-background-hover-ignore-button-theme-dark: @color-blue-10; @color-bi-background-active-ignore-button-theme-dark: @color-blue-10; + @color-bi-text-success-button: @color-bi-text; @color-bi-background-success-button: @color-bi-background-success; @color-bi-border-success-button: @color-bi-border-success; @color-bi-text-success-clear-button: @color-bi-text-success; @color-bi-text-success-ghost-button: @color-bi-text-success; +@color-bi-text-success-light-button: @color-bi-text-success; +@color-bi-background-success-light-button: @color-bi-background-light-success; +@color-bi-background-hover-success-light-button: @color-bi-background-light-success; +@color-bi-background-active-success-light-button: @color-bi-background-light-success; + @color-bi-text-warning-button: @color-bi-text; +@color-bi-text-warning-light-button: @color-bi-text-redmark; +@color-bi-background-warning-light-button: @color-bi-background-light-warning; +@color-bi-background-hover-warning-light-button: @color-bi-background-light-warning; +@color-bi-background-active-warning-light-button: @color-bi-background-light-warning; + @color-bi-background-warning-button: @color-bi-background-warning; @color-bi-border-warning-button: @color-bi-border-warning; @color-bi-text-warning-clear-button: @color-bi-text-redmark; @color-bi-text-warning-ghost-button: @color-bi-text-redmark; + @color-bi-text-error-button: @color-bi-text; +@color-bi-background-error-light-button: @color-bi-background-light-failure; @color-bi-background-error-button: @color-bi-background-failure; +@color-bi-text-error-light-button: @color-bi-text-failure; +@color-bi-background-hover-error-light-button: @color-bi-background-light-failure; +@color-bi-background-active-error-light-button: @color-bi-background-light-failure; @color-bi-border-error-button: @color-bi-border-failure; @color-bi-text-error-clear-button: @color-bi-text-failure; @color-bi-text-error-ghost-button: @color-bi-text-failure; @@ -179,6 +202,7 @@ @color-bi-border-hover-text-value-down-list-combo: @color-bi-border-highlight; @color-bi-border-hover-text-value-check-combo: @color-bi-border-highlight; @color-bi-text-error-hover-text-value-combo: @color-bi-text-failure; +@color-bi-text-error-text-trigger: @color-bi-text-failure; @color-bi-text-error-hover-text-value-icon-combo: @color-bi-text-failure; @color-bi-text-error-hover-search-text-value-combo: @color-bi-text-failure; @color-bi-background-bubble-combo-triangle: @color-bi-background-default; diff --git a/src/less/resource/font.less b/src/less/resource/font.less index a6551f864..be6730eca 100644 --- a/src/less/resource/font.less +++ b/src/less/resource/font.less @@ -86,6 +86,7 @@ .font(toast-success-font, @font-tip-success, @color-bi-color-toast-success); .font(toast-warning-font, @font-tip-warning, @color-bi-color-toast-warning); .font(toast-message-font, @font-tip-message, @color-bi-color-toast-normal); +.font(toast-loading-font, @font-tip-loading, @color-bi-color-toast-normal); //数值区间 .font(less-font, @font-less); diff --git a/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less b/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less index ca3a79fbc..d1c5771dc 100644 --- a/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less +++ b/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less @@ -1,20 +1,24 @@ @import "../../index.less"; -@val: transform .3s ease; + .bi-multilayer-select-tree-combo { - & .trigger-icon-button{ - font-size: @font-size-16; - } - // 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 - & .bi-combo.bi-combo-popup + .bi-trigger-icon-button { - & .x-icon { - .rotate(180deg); - .transition(@val); + + &.status-error { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + + .bi-trigger .select-text-label, .tip-text-style { + color: @color-bi-text-error-text-trigger; } } - & .bi-combo + .bi-trigger-icon-button { - & .x-icon { - .rotate(0deg); - .transition(@val); + + &.status-warning { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-warning; + } + + .bi-trigger .select-text-label { + color: @font-color-warning; } } } diff --git a/src/less/widget/multilayersingletree/multilayersingletree.combo.less b/src/less/widget/multilayersingletree/multilayersingletree.combo.less index af046bc74..15df50877 100644 --- a/src/less/widget/multilayersingletree/multilayersingletree.combo.less +++ b/src/less/widget/multilayersingletree/multilayersingletree.combo.less @@ -1,20 +1,23 @@ @import "../../index.less"; -@val: transform .3s ease; + .bi-multilayer-single-tree-combo { - & .trigger-icon-button{ - font-size: @font-size-16; - } - // 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 - & .bi-combo.bi-combo-popup + .bi-trigger-icon-button { - & .x-icon { - .rotate(180deg); - .transition(@val); + &.status-error { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + + .bi-trigger .select-text-label, .tip-text-style { + color: @color-bi-text-error-text-trigger; } } - & .bi-combo + .bi-trigger-icon-button { - & .x-icon { - .rotate(0deg); - .transition(@val); + + &.status-warning { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-warning; + } + + .bi-trigger .select-text-label { + color: @font-color-warning; } } } diff --git a/src/less/widget/numbereditor/number.editor.less b/src/less/widget/numbereditor/number.editor.less index ba8ab84ac..f91442d49 100644 --- a/src/less/widget/numbereditor/number.editor.less +++ b/src/less/widget/numbereditor/number.editor.less @@ -1,7 +1,6 @@ @import "../../index.less"; .bi-number-editor { - .border-radius(2px); & .pull-down-font { font-size: @font-size-12; } diff --git a/src/less/widget/numberinterval/numberinterval.less b/src/less/widget/numberinterval/numberinterval.less index 67b5a835a..72566b2a9 100644 --- a/src/less/widget/numberinterval/numberinterval.less +++ b/src/less/widget/numberinterval/numberinterval.less @@ -4,14 +4,7 @@ &.hack { .border-radius(0px); } - & .number-interval-small-editor { - .border-corner-left-radius(2px, 2px); - } - & .number-interval-big-editor { - .border-corner-right-radius(2px, 2px); - } & .number-interval-big-combo { - .border-corner-left-radius(2px, 2px); & .bi-icon-combo-trigger { & .icon-combo-trigger-icon { font-size: @font-size-14; @@ -20,7 +13,6 @@ } & .number-interval-small-combo { - .border-corner-right-radius(2px, 2px); & .bi-icon-combo-trigger { & .icon-combo-trigger-icon { font-size: @font-size-14; diff --git a/src/less/widget/year/trigger.year.less b/src/less/widget/year/trigger.year.less index ed8d0d442..800955966 100644 --- a/src/less/widget/year/trigger.year.less +++ b/src/less/widget/year/trigger.year.less @@ -1,4 +1,4 @@ @import "../../index.less"; .bi-year-trigger{ - .border-radius(2px); + } \ No newline at end of file diff --git a/src/router/router.js b/src/router/router.js index 7a44bb5d9..40ca8f3c4 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -3130,6 +3130,7 @@ routes: this.options.routes, base: this.options.base, }); + Fix.defineReactiveProperty(BI.Router.$router.history, "current"); this.$router.beforeEach(function (to, from, next) { if (to.matched.length === 0) { //如果上级也未匹配到路由则跳转主页面,如果上级能匹配到则转上级路由 @@ -3193,7 +3194,8 @@ }; }, destroyed: function () { - BI.remove(cbs, this._callbackListener); + // BI.remove方法会把第二个参数当迭代器执行导致方法多执行一遍 + cbs.splice(cbs.indexOf(this._callbackListener), 1); } }); BI.shortcut("bi.router_view", BI.RouterView); diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js index 80b414f73..be615e6ea 100644 --- a/src/widget/downlist/combo.downlist.js +++ b/src/widget/downlist/combo.downlist.js @@ -14,41 +14,27 @@ BI.DownListCombo = BI.inherit(BI.Widget, { stopPropagation: false, el: {}, minWidth: 140, - maxHeight: 1000 + maxHeight: 1000, + destroyWhenHide: false }); }, _init: function () { BI.DownListCombo.superclass._init.apply(this, arguments); var self = this, o = this.options; - this.popupview = BI.createWidget({ - type: "bi.down_list_popup", - items: o.items, - chooseType: o.chooseType, - value: o.value - }); - - this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) { - self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); - self.downlistcombo.hideView(); - }); - - this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { - self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); - self.downlistcombo.hideView(); - }); - this.downlistcombo = BI.createWidget({ element: this, type: "bi.combo", trigger: o.trigger, isNeedAdjustWidth: false, + isDefaultInit: true, container: o.container, adjustLength: o.adjustLength, direction: o.direction, belowMouse: o.belowMouse, stopPropagation: o.stopPropagation, + destroyWhenHide: o.destroyWhenHide, el: BI.createWidget(o.el, { type: "bi.icon_trigger", extraCls: o.iconCls, @@ -56,7 +42,28 @@ BI.DownListCombo = BI.inherit(BI.Widget, { height: o.height }), popup: { - el: this.popupview, + el: { + type: "bi.down_list_popup", + ref: function (ref) { + self.popupView = ref; + }, + items: o.items, + chooseType: o.chooseType, + value: o.value, + listeners: [{ + eventName: BI.DownListPopup.EVENT_CHANGE, + action: function (value) { + self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); + self.downlistcombo.hideView(); + } + }, { + eventName: BI.DownListPopup.EVENT_SON_VALUE_CHANGE, + action: function (value, fatherValue) { + self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); + self.downlistcombo.hideView(); + } + }] + }, stopPropagation: o.stopPropagation, maxHeight: o.maxHeight, minWidth: o.minWidth @@ -77,18 +84,27 @@ BI.DownListCombo = BI.inherit(BI.Widget, { }, populate: function (items) { - this.popupview.populate(items); + this.popupView.populate(items); }, setValue: function (v) { - this.popupview.setValue(v); + this.popupView.setValue(v); }, + getValue: function () { - return this.popupview.getValue(); + return this.popupView.getValue(); + }, + + adjustWidth: function () { + this.downlistcombo.adjustWidth(); + }, + + adjustHeight: function () { + this.downlistcombo.adjustHeight(); } }); BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.down_list_combo", BI.DownListCombo); \ No newline at end of file +BI.shortcut("bi.down_list_combo", BI.DownListCombo); diff --git a/src/widget/downlist/popup.downlist.js b/src/widget/downlist/popup.downlist.js index 35d395334..0e802a695 100644 --- a/src/widget/downlist/popup.downlist.js +++ b/src/widget/downlist/popup.downlist.js @@ -153,8 +153,7 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }], cls: "bi-down-list-spliter-container cursor-pointer", vgap: 5, - lgap: 10, - rgap: 0 + hgap: 12 }); result.push(spliter_container); } diff --git a/src/widget/dynamicdate/dynamicdate.combo.js b/src/widget/dynamicdate/dynamicdate.combo.js index 185e1ca35..75c3739af 100644 --- a/src/widget/dynamicdate/dynamicdate.combo.js +++ b/src/widget/dynamicdate/dynamicdate.combo.js @@ -38,7 +38,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { items: [{ el: { type: "bi.combo", - cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", + cls: (opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", container: opts.container, ref: function () { self.combo = this; diff --git a/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/src/widget/dynamicdatetime/dynamicdatetime.combo.js index d533205fe..176eff1ae 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.combo.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.combo.js @@ -38,7 +38,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { items: [{ el: { type: "bi.combo", - cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", + cls: (opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", destroyWhenHide: true, container: opts.container, ref: function () { diff --git a/src/widget/editor/editor.search.js b/src/widget/editor/editor.search.js index 14f8cb5f4..b1747849a 100644 --- a/src/widget/editor/editor.search.js +++ b/src/widget/editor/editor.search.js @@ -5,7 +5,7 @@ BI.SearchEditor = BI.inherit(BI.Widget, { _defaultConfig: function (config) { var conf = BI.SearchEditor.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - baseCls: "bi-search-editor bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border"), + baseCls: "bi-search-editor bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), height: 24, errorText: "", watermark: BI.i18nText("BI-Basic_Search"), @@ -34,7 +34,7 @@ BI.SearchEditor = BI.inherit(BI.Widget, { type: "bi.icon_button", stopEvent: true, cls: "close-font", - invisible: BI.isKey(o.value) + invisible: !BI.isKey(o.value) }); this.clear.on(BI.IconButton.EVENT_CHANGE, function () { self.setValue(""); diff --git a/src/widget/multilayerdownlist/popup.downlist.js b/src/widget/multilayerdownlist/popup.downlist.js index fa222005d..7483349de 100644 --- a/src/widget/multilayerdownlist/popup.downlist.js +++ b/src/widget/multilayerdownlist/popup.downlist.js @@ -150,7 +150,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { }], cls: "bi-down-list-spliter-container cursor-pointer", vgap: 5, - lgap: 10 + hgap: 12, }); result.push(spliter_container); } diff --git a/src/widget/multilayerselecttree/multilayerselecttree.combo.js b/src/widget/multilayerselecttree/multilayerselecttree.combo.js index 6365ef484..48ff0cbe0 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.combo.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.combo.js @@ -16,66 +16,29 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { allowEdit: false, allowSearchValue: false, allowInsertValue: false, - isNeedAdjustWidth: true + isNeedAdjustWidth: true, + status: "", // "error","warning" }); }, _init: function () { var o = this.options; - if (this._shouldWrapper()) { - o.height -= 2; - BI.isNumeric(o.width) && (o.width -= 2); - } + BI.isNumeric(o.width) && (o.width -= 2); + BI.isNumeric(o.height) && (o.height -= 2); BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); }, render: function () { var self = this, o = this.options; - var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); - - return this._shouldWrapper() ? combo : { - type: "bi.absolute", - items: [{ - el: combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.trigger_icon_button", - cls: "trigger-icon-button", - ref: function (_ref) { - self.triggerBtn = _ref; - }, - width: o.height, - height: o.height, - handler: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - } - }, - right: 0, - bottom: 0, - top: 0 - }] - }; - }, - - _shouldWrapper: function () { - var o = this.options; - return !o.allowEdit && o.itemsCreator === BI.emptyFn; + return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); }, _getBaseConfig: function () { var self = this, o = this.options; return { type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom " : "bi-border bi-border-radius ") + (BI.isKey(o.status) ? ("status-" + o.status) : ""), container: o.container, destroyWhenHide: o.destroyWhenHide, adjustLength: 2, @@ -122,7 +85,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { }; }, - _getSearchConfig: function() { + _getSearchConfig: function () { var self = this, o = this.options; return { el: { @@ -139,7 +102,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, watermark: o.watermark, - height: o.height - (o.simple ? 1 : 2), + // height: o.height - (o.simple ? 1 : 2), + height: o.height, text: o.text, value: o.value, tipType: o.tipType, @@ -184,7 +148,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { // IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿 // 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以 // 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪 - return (o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0) ? false : self.triggerBtn.element.find(e.target).length === 0; + return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0); }, listeners: [{ @@ -198,7 +162,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW); } }] - } + }; }, _getSyncConfig: function () { @@ -207,13 +171,15 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { el: { type: "bi.single_tree_trigger", - ref: function(_ref) { + ref: function (_ref) { self.textTrigger = _ref; }, text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, } }); }, @@ -236,6 +202,22 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor(); }, + clear: function () { + // do some work + }, + + setStatus: function (status) { + if (BI.isKey(this.options.status)) { + this.element.removeClass("status-" + this.options.status); + } + this.element.addClass("status-" + status); + this.options.status = status; + }, + + setTipType: function (v) { + this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v); + }, + populate: function (items) { this.combo.populate(items); }, diff --git a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js index 4b66b58f7..11789b5ac 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js @@ -3,7 +3,7 @@ */ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { - props: function() { + props: function () { return { extraCls: "bi-multi-layer-select-tree-trigger", height: 24, @@ -16,11 +16,12 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { render: function () { var self = this, o = this.options; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { this._initData(); } - var content = { - type: "bi.htape", + + return { + type: "bi.horizontal_fill", items: [ { el: { @@ -86,7 +87,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, onSearch: function (obj, callback) { var keyword = obj.keyword; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { callback(self._getSearchItems(keyword)); o.allowInsertValue && self.popup.setKeyword(keyword); } else { @@ -99,51 +100,37 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE); } }] - } + }, + width: "fill", }, { el: { - type: "bi.layout", - width: 24 + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function (_ref) { + self.triggerBtn = _ref; + }, + width: 24, }, - width: 24 + width: 24, } ] }; - - return o.allowEdit ? content : { - type: "bi.absolute", - items: [{ - el: content, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.layout" - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] - }; }, - _initData: function() { + _initData: function () { var o = this.options; this.tree = new BI.Tree(); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.tree.initTree(this.nodes); }, - _getSearchItems: function(keyword) { + _getSearchItems: function (keyword) { var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); - if(find.find.length > 0 || find.match.length > 0) { + if (find.find.length > 0 || find.match.length > 0) { items.push(node); return true; } @@ -151,7 +138,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { return this._fillTreeStructure4Search(items, "id"); }, - _createJson: function(node, open) { + _createJson: function (node, open) { return { id: node.id, pId: node.pId, @@ -159,10 +146,10 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { value: node.value, isParent: BI.isNotEmptyArray(node.children), open: open - } + }; }, - _getChildren: function(node) { + _getChildren: function (node) { var self = this; node.children = node.children || []; var nodes = []; @@ -179,7 +166,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { var result = []; var queue = []; BI.each(leaves, function (idx, node) { - queue.push({pId: node.pId}); + queue.push({ pId: node.pId }); result.push(node); result = result.concat(self._getChildren(node)); }); @@ -188,7 +175,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); if (pNode != null) { pNode.open = true; - queue.push({pId: pNode.pId}); + queue.push({ pId: pNode.pId }); result.push(pNode); } } @@ -259,4 +246,4 @@ BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP"; BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START"; BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; -BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); \ No newline at end of file +BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); diff --git a/src/widget/multilayersingletree/multilayersingletree.combo.js b/src/widget/multilayersingletree/multilayersingletree.combo.js index 779e645bf..63f43b4f9 100644 --- a/src/widget/multilayersingletree/multilayersingletree.combo.js +++ b/src/widget/multilayersingletree/multilayersingletree.combo.js @@ -19,55 +19,21 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { allowEdit: false, allowSearchValue: false, allowInsertValue: false, - isNeedAdjustWidth: true + isNeedAdjustWidth: true, }); }, _init: function () { var o = this.options; - if (this._shouldWrapper()) { - o.height -= 2; - BI.isNumeric(o.width) && (o.width -= 2); - } + BI.isNumeric(o.width) && (o.width -= 2); + BI.isNumeric(o.height) && (o.height -= 2); BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); }, render: function () { var self = this, o = this.options; - var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); - - return this._shouldWrapper() ? combo : { - type: "bi.absolute", - height: o.height, - items: [{ - el: combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.trigger_icon_button", - cls: "trigger-icon-button", - ref: function (_ref) { - self.triggerBtn = _ref; - }, - width: o.height, - height: o.height, - handler: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - } - }, - right: 0, - bottom: 0, - top: 0 - }] - }; + return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); }, _shouldWrapper: function () { @@ -79,7 +45,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; return { type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius ") + (BI.isKey(o.status) ? ("status-" + o.status) : ""), container: o.container, destroyWhenHide: o.destroyWhenHide, adjustLength: 2, @@ -125,7 +91,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { }; }, - _getSearchConfig: function() { + _getSearchConfig: function () { var self = this, o = this.options; return { el: { @@ -142,7 +108,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { items: o.items, itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, - height: o.height - (o.simple ? 1 : 2), + height: o.height, text: o.text, value: o.value, tipType: o.tipType, @@ -186,7 +152,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { // IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿 // 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以 // 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪 - return (o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0) ? false : self.triggerBtn.element.find(e.target).length === 0 + return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0); }, listeners: [{ eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, @@ -199,7 +165,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW); } }] - } + }; }, _getSyncConfig: function () { @@ -208,13 +174,16 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { el: { type: "bi.single_tree_trigger", - ref: function(_ref) { + ref: function (_ref) { self.textTrigger = _ref; }, text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, + valueFormatter: o.valueFormatter, } }); }, @@ -237,6 +206,18 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { return this.combo.getValue(); }, + setStatus: function (status) { + if (BI.isKey(this.options.status)) { + this.element.removeClass("status-" + this.options.status); + } + this.element.addClass("status-" + status); + this.options.status = status; + }, + + setTipType: function (v) { + this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v); + }, + populate: function (items) { this.combo.populate(items); }, diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js index 75a515129..8c58b0c8c 100644 --- a/src/widget/multilayersingletree/multilayersingletree.trigger.js +++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js @@ -3,7 +3,7 @@ */ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { - props: function() { + props: function () { return { extraCls: "bi-multi-layer-single-tree-trigger", height: 24, @@ -16,11 +16,12 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { render: function () { var self = this, o = this.options; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { this._initData(); } - var content = { - type: "bi.htape", + + return { + type: "bi.horizontal_fill", items: [ { el: { @@ -86,7 +87,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, onSearch: function (obj, callback) { var keyword = obj.keyword; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { callback(self._getSearchItems(keyword)); o.allowInsertValue && self.popup.setKeyword(keyword); } else { @@ -99,51 +100,37 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE); } }] - } + }, + width: "fill", }, { el: { - type: "bi.layout", - width: 24 + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function (_ref) { + self.triggerBtn = _ref; + }, + width: 24, }, width: 24 } ] }; - - return o.allowEdit ? content : { - type: "bi.absolute", - items: [{ - el: content, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.layout" - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] - }; }, - _initData: function() { + _initData: function () { var o = this.options; this.tree = new BI.Tree(); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.tree.initTree(this.nodes); }, - _getSearchItems: function(keyword) { + _getSearchItems: function (keyword) { var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); - if(find.find.length > 0 || find.match.length > 0) { + if (find.find.length > 0 || find.match.length > 0) { items.push(node); return true; } @@ -151,7 +138,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { return this._fillTreeStructure4Search(items, "id"); }, - _createJson: function(node, open) { + _createJson: function (node, open) { return { id: node.id, pId: node.pId, @@ -159,10 +146,10 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { value: node.value, isParent: BI.isNotEmptyArray(node.children), open: open - } + }; }, - _getChildren: function(node) { + _getChildren: function (node) { var self = this; node.children = node.children || []; var nodes = []; @@ -179,7 +166,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { var result = []; var queue = []; BI.each(leaves, function (idx, node) { - queue.push({pId: node.pId}); + queue.push({ pId: node.pId }); result.push(node); result = result.concat(self._getChildren(node)); }); @@ -188,7 +175,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); if (pNode != null) { pNode.open = true; - queue.push({pId: pNode.pId}); + queue.push({ pId: pNode.pId }); result.push(pNode); } } @@ -260,4 +247,4 @@ BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP"; BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START"; BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; -BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger); \ No newline at end of file +BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger); diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index 254aa0340..23d5385b8 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -124,7 +124,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), toggle: !o.allowEdit, container: o.container, el: this.trigger, diff --git a/src/widget/multiselect/multiselect.combo.nobar.js b/src/widget/multiselect/multiselect.combo.nobar.js index 06138cf4b..ff4cc5d34 100644 --- a/src/widget/multiselect/multiselect.combo.nobar.js +++ b/src/widget/multiselect/multiselect.combo.nobar.js @@ -122,7 +122,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), toggle: false, container: o.container, el: this.trigger, diff --git a/src/widget/multiselect/multiselect.insert.combo.js b/src/widget/multiselect/multiselect.insert.combo.js index b5906f856..b1b4a202e 100644 --- a/src/widget/multiselect/multiselect.insert.combo.js +++ b/src/widget/multiselect/multiselect.insert.combo.js @@ -125,7 +125,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), toggle: !o.allowEdit, el: this.trigger, adjustLength: 1, diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js index de4f9eb35..1b92a9622 100644 --- a/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -117,7 +117,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), toggle: false, container: o.container, el: this.trigger, diff --git a/src/widget/multiselect/trigger/button.checkselected.js b/src/widget/multiselect/trigger/button.checkselected.js index 47a5ca995..17468061f 100644 --- a/src/widget/multiselect/trigger/button.checkselected.js +++ b/src/widget/multiselect/trigger/button.checkselected.js @@ -40,7 +40,7 @@ BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, { self.numberCounter.setText(self.numberCounter.getTag()); }); this.setVisible(false); - if(BI.isNotNull(o.value)){ + if (BI.isNotNull(o.value)) { this.setValue(o.value); } }, @@ -51,6 +51,9 @@ BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, { o.itemsCreator({ type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH }, function (res) { + if (self.options.value.type !== BI.Selection.All) { + return; + } if (BI.isNotEmptyString(res.count)) { BI.nextTick(function () { self.numberCounter.setText(res.count); diff --git a/src/widget/multiselect/trigger/searcher.multiselect.insert.js b/src/widget/multiselect/trigger/searcher.multiselect.insert.js index 404a0e4e8..36b3a115f 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.insert.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.insert.js @@ -63,7 +63,11 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { var keyword = self.editor.getKeyword(); op.keywords = [keyword]; this.setKeyword(keyword); - o.itemsCreator(op, callback); + o.itemsCreator(op, function () { + if (keyword === self.editor.getValue()) { + callback.apply(null, arguments); + } + }); }, itemHeight: o.itemHeight, value: o.value, @@ -174,7 +178,7 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { } }, - getState: function() { + getState: function () { return this.editor.getState(); }, diff --git a/src/widget/multiselect/trigger/searcher.multiselect.js b/src/widget/multiselect/trigger/searcher.multiselect.js index ab2688eb4..4dbfbead7 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.js @@ -51,7 +51,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { callback(); }, el: this.editor, - popup: BI.extend({ type: "bi.multi_select_search_pane", valueFormatter: o.valueFormatter, @@ -61,7 +60,15 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { itemsCreator: function (op, callback) { var keyword = self.editor.getValue(); op.keywords = [keyword]; - o.itemsCreator(op, callback); + o.itemsCreator(op, function () { + var keyword = self.editor.getValue(); + op.keywords = [keyword]; + o.itemsCreator(op, function () { + if (keyword === self.editor.getValue()) { + callback.apply(null, arguments); + } + }); + }); }, itemHeight: o.itemHeight, value: o.value diff --git a/src/widget/multitree/multi.tree.combo.js b/src/widget/multitree/multi.tree.combo.js index 40fc91a14..4e42df154 100644 --- a/src/widget/multitree/multi.tree.combo.js +++ b/src/widget/multitree/multi.tree.combo.js @@ -49,7 +49,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), toggle: !o.allowEdit, container: o.container, el: this.trigger, diff --git a/src/widget/multitree/multi.tree.insert.combo.js b/src/widget/multitree/multi.tree.insert.combo.js index 76f9c0b5c..9694b3556 100644 --- a/src/widget/multitree/multi.tree.insert.combo.js +++ b/src/widget/multitree/multi.tree.insert.combo.js @@ -65,7 +65,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), toggle: !o.allowEdit, container: o.container, el: this.trigger, diff --git a/src/widget/multitree/multi.tree.list.combo.js b/src/widget/multitree/multi.tree.list.combo.js index 198eb53fc..ff5a2864a 100644 --- a/src/widget/multitree/multi.tree.list.combo.js +++ b/src/widget/multitree/multi.tree.list.combo.js @@ -80,7 +80,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), toggle: !o.allowEdit, container: o.container, el: this.trigger, diff --git a/src/widget/numbereditor/number.editor.js b/src/widget/numbereditor/number.editor.js index c62497afe..596105947 100644 --- a/src/widget/numbereditor/number.editor.js +++ b/src/widget/numbereditor/number.editor.js @@ -5,7 +5,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, { _defaultConfig: function (conf) { return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-number-editor bi-focus-shadow " + (conf.simple ? "bi-border-bottom" : "bi-border"), + baseCls: "bi-number-editor bi-focus-shadow " + (conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), validationChecker: BI.emptyFn, valueFormatter: function (v) { return v; diff --git a/src/widget/numberinterval/numberinterval.js b/src/widget/numberinterval/numberinterval.js index 9e2df9825..88b640130 100644 --- a/src/widget/numberinterval/numberinterval.js +++ b/src/widget/numberinterval/numberinterval.js @@ -36,7 +36,7 @@ BI.NumberInterval = BI.inherit(BI.Single, { BI.NumberInterval.superclass._init.apply(this, arguments); this.smallEditor = BI.createWidget({ type: "bi.number_interval_single_editor", - height: o.height - 2, + height: o.height - (o.simple ? 1 : 2), watermark: o.watermark, allowBlank: o.allowBlank, value: o.min, @@ -55,13 +55,13 @@ BI.NumberInterval = BI.inherit(BI.Single, { } return true; }, - cls: "number-interval-small-editor bi-border" + cls: "number-interval-small-editor " + (o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius") }); this.smallTip = BI.createWidget({ type: "bi.label", text: o.numTip, - height: o.height - 2, + height: o.height - (o.simple ? 1 : 2), invisible: true }); BI.createWidget({ @@ -76,7 +76,7 @@ BI.NumberInterval = BI.inherit(BI.Single, { this.bigEditor = BI.createWidget({ type: "bi.number_interval_single_editor", - height: o.height - 2, + height: o.height - (o.simple ? 1 : 2), watermark: o.watermark, allowBlank: o.allowBlank, value: o.max, @@ -93,13 +93,13 @@ BI.NumberInterval = BI.inherit(BI.Single, { } return true; }, - cls: "number-interval-big-editor bi-border" + cls: "number-interval-big-editor" + (o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius") }); this.bigTip = BI.createWidget({ type: "bi.label", text: o.numTip, - height: o.height - 2, + height: o.height - (o.simple ? 1 : 2), invisible: true }); BI.createWidget({ @@ -113,8 +113,8 @@ BI.NumberInterval = BI.inherit(BI.Single, { }); this.smallCombo = BI.createWidget({ type: "bi.icon_combo", - cls: "number-interval-small-combo bi-border-top bi-border-bottom bi-border-right", - height: o.height - 2, + cls: "number-interval-small-combo" + (o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"), + height: o.height - (o.simple ? 0 : 2), items: [{ text: "(" + BI.i18nText("BI-Less_Than") + ")", iconCls: "less-font", @@ -132,8 +132,8 @@ BI.NumberInterval = BI.inherit(BI.Single, { } this.bigCombo = BI.createWidget({ type: "bi.icon_combo", - cls: "number-interval-big-combo bi-border-top bi-border-bottom bi-border-left", - height: o.height - 2, + cls: "number-interval-big-combo" + (o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"), + height: o.height - (o.simple ? 0 : 2), items: [{ text: "(" + BI.i18nText("BI-Less_Than") + ")", iconCls: "less-font", @@ -152,9 +152,9 @@ BI.NumberInterval = BI.inherit(BI.Single, { this.label = BI.createWidget({ type: "bi.label", text: BI.i18nText("BI-Basic_Value"), - textHeight: o.height - c.border * 2, - width: c.width - c.border * 2, - height: o.height - c.border * 2, + textHeight: o.height - (o.simple ? 0 : c.border * 2), + width: c.width - (o.simple ? 0 : c.border * 2), + height: o.height - (o.simple ? 0 : c.border * 2), level: "warning", tipType: "warning" }); diff --git a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js index cb7fddf9a..a3def7ccf 100644 --- a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js +++ b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js @@ -35,7 +35,7 @@ BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, { this.trigger = BI.createWidget({ type: "bi.search_multi_select_trigger", text: o.text, - height: o.height - 2, + height: o.height - (o.simple ? 1 : 2), // adapter: this.popup, masker: { offset: { @@ -111,7 +111,7 @@ BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: "bi-border bi-border-radius", + cls: o.simple ? "bi-border-bottom" : "bi-border bi-border-radius", toggle: false, container: o.container, el: this.trigger, diff --git a/src/widget/selecttree/nodes/node.first.plus.js b/src/widget/selecttree/nodes/node.first.plus.js index f8f23c2b5..378eac230 100644 --- a/src/widget/selecttree/nodes/node.first.plus.js +++ b/src/widget/selecttree/nodes/node.first.plus.js @@ -24,7 +24,9 @@ BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.first_tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/nodes/node.last.plus.js b/src/widget/selecttree/nodes/node.last.plus.js index 2c4cca80c..f8e764e10 100644 --- a/src/widget/selecttree/nodes/node.last.plus.js +++ b/src/widget/selecttree/nodes/node.last.plus.js @@ -24,7 +24,9 @@ BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.last_tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/nodes/node.mid.plus.js b/src/widget/selecttree/nodes/node.mid.plus.js index 289136242..ddafe5704 100644 --- a/src/widget/selecttree/nodes/node.mid.plus.js +++ b/src/widget/selecttree/nodes/node.mid.plus.js @@ -24,7 +24,9 @@ BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.mid_tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/nodes/node.plus.js b/src/widget/selecttree/nodes/node.plus.js index e0f8e8632..d5cd39c66 100644 --- a/src/widget/selecttree/nodes/node.plus.js +++ b/src/widget/selecttree/nodes/node.plus.js @@ -24,7 +24,9 @@ BI.SelectTreePlusGroupNode = BI.inherit(BI.NodeButton, { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.tree_node_checkbox", - stopPropagation: true + stopPropagation: true, + iconHeight: o.height, + iconWidth: o.iconWrapperWidth || o.height }); this.text = BI.createWidget({ type: "bi.label", diff --git a/src/widget/selecttree/selecttree.combo.js b/src/widget/selecttree/selecttree.combo.js index 98c542686..c6aca0c62 100644 --- a/src/widget/selecttree/selecttree.combo.js +++ b/src/widget/selecttree/selecttree.combo.js @@ -11,6 +11,7 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { text: "", items: [], value: "", + allowClear: false, }); }, @@ -25,7 +26,13 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + allowClear: o.allowClear, + warningTitle: o.warningTitle, + }); + + this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () { + self._clear(); }); this.popup = BI.createWidget({ @@ -53,12 +60,43 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { self.setValue(self.popup.getValue()); self.combo.hideView(); }); + + if (BI.isKey(o.value)) { + this._checkError(o.value); + } + }, + + _checkError: function (v) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + this.trigger.options.tipType = "success"; + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } else { + v = BI.isArray(v) ? v : [v]; + var result = BI.find(this.options.items, function (idx, item) { + return BI.contains(v, item.value); + }); + if (BI.isNull(result)) { + this.trigger.setTipType("warning"); + this.element.removeClass("error").addClass("error"); + this.trigger.element.removeClass("error").addClass("error"); + } else { + this.trigger.setTipType("success"); + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } + } + }, + + _clear: function () { + this.setValue([]); }, setValue: function (v) { v = BI.isArray(v) ? v : [v]; this.trigger.setValue(v); this.popup.setValue(v); + this._checkError(v); }, getValue: function () { @@ -71,4 +109,4 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { }); -BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo); \ No newline at end of file +BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo); diff --git a/src/widget/singleselect/singleselect.combo.js b/src/widget/singleselect/singleselect.combo.js index fae620c93..fac81d8d7 100644 --- a/src/widget/singleselect/singleselect.combo.js +++ b/src/widget/singleselect/singleselect.combo.js @@ -83,7 +83,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), container: o.container, toggle: false, el: this.trigger, diff --git a/src/widget/singleselect/singleselect.insert.combo.js b/src/widget/singleselect/singleselect.insert.combo.js index 46754e1dc..faa3511be 100644 --- a/src/widget/singleselect/singleselect.insert.combo.js +++ b/src/widget/singleselect/singleselect.insert.combo.js @@ -94,7 +94,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { this.combo = BI.createWidget({ type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), container: o.container, toggle: false, el: this.trigger, diff --git a/src/widget/singletree/singletree.combo.js b/src/widget/singletree/singletree.combo.js index ce6d255d4..ad6b85268 100644 --- a/src/widget/singletree/singletree.combo.js +++ b/src/widget/singletree/singletree.combo.js @@ -6,12 +6,13 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { _defaultConfig: function (config) { return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-tree-combo bi-border-radius " + (config.simple ? "bi-border-bottom" : "bi-border"), + baseCls: "bi-single-tree-combo " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), trigger: {}, height: 24, text: "", items: [], value: "", + allowClear: false, }); }, @@ -26,9 +27,15 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + allowClear: o.allowClear, + warningTitle: o.warningTitle, }, o.trigger)); + this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () { + self._clear(); + }); + this.popup = BI.createWidget({ type: "bi.single_level_tree", items: o.items, @@ -58,6 +65,36 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { self.combo.hideView(); self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); }); + + if (BI.isKey(o.value)) { + this._checkError(o.value); + } + }, + + _checkError: function (v) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + this.trigger.options.tipType = "success"; + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } else { + v = BI.isArray(v) ? v : [v]; + var result = BI.find(this.options.items, function (idx, item) { + return BI.contains(v, item.value); + }); + if (BI.isNull(result)) { + this.trigger.setTipType("warning"); + this.element.removeClass("error").addClass("error"); + this.trigger.element.removeClass("error").addClass("error"); + } else { + this.trigger.setTipType("success"); + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } + } + }, + + _clear: function () { + this.setValue([]); }, populate: function (items) { @@ -68,6 +105,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { v = BI.isArray(v) ? v : [v]; this.trigger.setValue(v); this.popup.setValue(v); + this._checkError(v); }, getValue: function () { @@ -77,4 +115,4 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { BI.SingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); \ No newline at end of file +BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); diff --git a/src/widget/singletree/singletree.trigger.js b/src/widget/singletree/singletree.trigger.js index 91183c033..8c5193d2d 100644 --- a/src/widget/singletree/singletree.trigger.js +++ b/src/widget/singletree/singletree.trigger.js @@ -11,7 +11,9 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { height: 24, text: "", items: [], - value: "" + value: "", + allowClear: false, + valueFormatter: BI.emptyFn, }); }, @@ -26,7 +28,19 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { text: o.text, items: o.items, height: o.height, - value: o.value + warningTitle: o.warningTitle, + tipType: o.tipType, + value: o.value, + allowClear: o.allowClear, + valueFormatter: o.valueFormatter, + listeners: [ + { + eventName: BI.SelectTextTrigger.EVENT_CLEAR, + action: function () { + self.fireEvent(BI.SingleTreeTrigger.EVENT_CLEAR); + } + } + ] }); }, @@ -47,11 +61,16 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { this._checkTitle(); }, + setTipType: function (v) { + this.options.tipType = v; + this.trigger.setTipType(v); + }, + getValue: function () { return this.options.value || []; }, - getTextor: function() { + getTextor: function () { return this.trigger.getTextor(); }, @@ -61,4 +80,5 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { }); +BI.SingleTreeTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger); diff --git a/src/widget/timeinterval/dateinterval.js b/src/widget/timeinterval/dateinterval.js index ca6895301..e20188d37 100644 --- a/src/widget/timeinterval/dateinterval.js +++ b/src/widget/timeinterval/dateinterval.js @@ -72,6 +72,7 @@ BI.DateInterval = BI.inherit(BI.Single, { supportDynamic: o.supportDynamic, minDate: o.minDate, maxDate: o.maxDate, + simple: o.simple, behaviors: o.behaviors, watermark: o.watermark, value: v, diff --git a/src/widget/timeinterval/timeinterval.js b/src/widget/timeinterval/timeinterval.js index 56a9df8fb..95fd88bfe 100644 --- a/src/widget/timeinterval/timeinterval.js +++ b/src/widget/timeinterval/timeinterval.js @@ -69,6 +69,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { var self = this, o = this.options; var combo = BI.createWidget({ type: "bi.dynamic_date_time_combo", + simple: o.simple, supportDynamic: o.supportDynamic, minDate: o.minDate, maxDate: o.maxDate, diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js index 1774ca384..cf6485d13 100644 --- a/src/widget/year/combo.year.js +++ b/src/widget/year/combo.year.js @@ -133,7 +133,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { items: [{ el: { type: "bi.htape", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", ref: function () { self.comboWrapper = this; }, diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index fe8976b2f..2a9cb1fde 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -93,7 +93,7 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { BI.createWidget({ element: this, type: "bi.horizontal_fill", - columnSize: ["fill", ""], + columnSize: ["fill", "", ""], items: [{ el: this.editor }, { @@ -106,8 +106,7 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { el: { type: "bi.trigger_icon_button", width: this._const.iconWidth - }, - width: this._const.iconWidth + } }] }); this.setValue(o.value); diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js index 4bc1285e9..45431225b 100644 --- a/src/widget/yearmonth/combo.yearmonth.js +++ b/src/widget/yearmonth/combo.yearmonth.js @@ -132,7 +132,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { items: [{ el: { type: "bi.htape", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", ref: function () { self.comboWrapper = this; }, diff --git a/src/widget/yearquarter/combo.yearquarter.js b/src/widget/yearquarter/combo.yearquarter.js index ae42bec41..16537990c 100644 --- a/src/widget/yearquarter/combo.yearquarter.js +++ b/src/widget/yearquarter/combo.yearquarter.js @@ -135,7 +135,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { items: [{ el: { type: "bi.htape", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", + cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", ref: function () { self.comboWrapper = this; }, diff --git a/typescript/base/foundation/message.ts b/typescript/base/foundation/message.ts index 63790d1cb..ad0e7bac0 100644 --- a/typescript/base/foundation/message.ts +++ b/typescript/base/foundation/message.ts @@ -1,6 +1,13 @@ +type toastOptions = { + level: "success" | "warning" | "error" | "normal" | "loading" + autoClose?: boolean + callback?: Function + closable?: boolean +} + export type _msg = { - alert: (title: string, message?: string | {[key: string]: any}, callback?: (result?: boolean)=>void) => void - confirm: (title: string, message?: string | {[key: string]: any}, callback?: (result: boolean)=>void) => void - prompt: (title: string, message?: string, value?: any, callback?: (result: string) => void, minWidth?: number) => void - toast: (message: string, options?: object | string, context?: HTMLElement) => void + alert: (title: string, message?: string | { [key: string]: any }, callback?: (result?: boolean) => void) => void + confirm: (title: string, message?: string | { [key: string]: any }, callback?: (result: boolean) => void) => void + prompt: (title: string, message?: string, value?: any, callback?: (result: string) => void, minWidth?: number) => void + toast: (message: string | Obj, options?: toastOptions | string, context?: HTMLElement) => Function } diff --git a/typescript/base/single/button/listitem/icontexticonitem.ts b/typescript/base/single/button/listitem/icontexticonitem.ts index 60523b376..6bdea4a64 100644 --- a/typescript/base/single/button/listitem/icontexticonitem.ts +++ b/typescript/base/single/button/listitem/icontexticonitem.ts @@ -5,9 +5,6 @@ export declare class IconTextIconItem extends BasicButton { static EVENT_CHANGE: string; props: { - logic?: { - dynamic: boolean; - }; iconCls1?: string; iconCls2?: string; iconHeight?: number; diff --git a/typescript/base/single/button/listitem/icontextitem.ts b/typescript/base/single/button/listitem/icontextitem.ts index 5e3f3d6e9..e7143eb7f 100644 --- a/typescript/base/single/button/listitem/icontextitem.ts +++ b/typescript/base/single/button/listitem/icontextitem.ts @@ -6,9 +6,6 @@ export declare class IconTextItem extends BasicButton { props: { direction?: string; - logic?: { - dynamic: boolean; - }; iconWrapperWidth?: number; iconCls?: string; iconHeight?: number; diff --git a/typescript/base/single/label/abstract.label.ts b/typescript/base/single/label/abstract.label.ts index 966651b84..431d79ab6 100644 --- a/typescript/base/single/label/abstract.label.ts +++ b/typescript/base/single/label/abstract.label.ts @@ -4,7 +4,7 @@ export declare class AbstractLabel extends Single { static xtype: string; props: { - textAlign?: "left" | "center" | "right"; + textAlign?: "left" | "center" | "right" | "justify"; whiteSpace?: "nowrap" | "normal"; textWidth?: number | null; textHeight?: number | null; diff --git a/typescript/case/button/item.multiselect.ts b/typescript/case/button/item.multiselect.ts index 9e439ab95..3d5011ea3 100644 --- a/typescript/case/button/item.multiselect.ts +++ b/typescript/case/button/item.multiselect.ts @@ -6,9 +6,6 @@ export declare class MultiSelectItem extends BasicButton { static EVENT_CHANGE: string; props: { - logic: { - dynamic: boolean; - } text: string; iconWrapperWidth: number; textLgap: number; diff --git a/typescript/case/button/item.singleselect.radio.ts b/typescript/case/button/item.singleselect.radio.ts index 725d2339d..6d21684c6 100644 --- a/typescript/case/button/item.singleselect.radio.ts +++ b/typescript/case/button/item.singleselect.radio.ts @@ -6,9 +6,6 @@ export declare class SingleSelectRadioItem extends BasicButton { props: { iconWrapperWidth: number; - logic: { - dynamic: boolean; - }; textHgap: number; textLgap: number; textRgap: number; diff --git a/typescript/case/colorchooser/colorchooser.simple.ts b/typescript/case/colorchooser/colorchooser.simple.ts index 4ecb0d7c3..274a1f140 100644 --- a/typescript/case/colorchooser/colorchooser.simple.ts +++ b/typescript/case/colorchooser/colorchooser.simple.ts @@ -3,7 +3,8 @@ import { Widget } from '../../core/widget'; export declare class SimpleColorChooser extends Widget { static xtype: string; static EVENT_CHANGE: string; - + static EVENT_AFTER_POPUPVIEW: string; + isViewVisible(): boolean; hideView(): void; diff --git a/typescript/case/colorchooser/colorchooser.ts b/typescript/case/colorchooser/colorchooser.ts new file mode 100644 index 000000000..b58869e37 --- /dev/null +++ b/typescript/case/colorchooser/colorchooser.ts @@ -0,0 +1,13 @@ +import { Widget } from '../../core/widget'; + +export declare class ColorChooser extends Widget { + static xtype: string; + static EVENT_CHANGE: string; + static EVENT_AFTER_POPUPVIEW: string; + + isViewVisible(): boolean; + + hideView(): void; + + showView(): void; +} diff --git a/typescript/index.ts b/typescript/index.ts index 448266b96..fa9a08d19 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -82,6 +82,7 @@ import { MultiSelectCombo } from "./widget/multiselect/multiselect.combo"; import { SearchEditor } from "./widget/editor/editor.search"; import { MultiLayerSingleLevelTree } from "./widget/multilayersingletree/multilayersingletree.leveltree"; import { SimpleColorChooser } from "./case/colorchooser/colorchooser.simple"; +import { ColorChooser } from './case/colorchooser/colorchooser'; import { A } from "./base/a/a"; import { Html } from "./base/single/html/html"; import { Switcher } from "./base/combination/switcher"; @@ -307,6 +308,7 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils { SearchEditor: typeof SearchEditor; MultiLayerSingleLevelTree: typeof MultiLayerSingleLevelTree; SimpleColorChooser: typeof SimpleColorChooser; + ColorChooser: typeof ColorChooser; AbstractAllValueChooser: typeof AbstractAllValueChooser; AllValueChooserCombo: typeof AllValueChooserCombo; TextAreaEditor: typeof TextAreaEditor; @@ -496,6 +498,7 @@ export { Text, Pane, MultiLayerSingleLevelTree, + ColorChooser, SimpleColorChooser, AbstractAllValueChooser, AllValueChooserCombo, diff --git a/typescript/router/router.ts b/typescript/router/router.ts index 262c9debe..75fded652 100644 --- a/typescript/router/router.ts +++ b/typescript/router/router.ts @@ -1,12 +1,211 @@ +type Component = any +type Dictionary = { [key: string]: T } +type ErrorHandler = (err: Error) => void + +export type RouterMode = "hash" | "history" | "abstract" +export type RawLocation = string | Location +export type RedirectOption = RawLocation | ((to: Route) => RawLocation) +export type NavigationGuardNext = ( + to?: RawLocation | false | void, +) => void + +export type NavigationGuard = ( + to: Route, + from: Route, + next: NavigationGuardNext, +) => any + +interface _History { + current: Route; +} + +export declare class VueRouter { + constructor(options?: Obj) + + mode: RouterMode; + currentRoute: Route; + + history: _History; + + beforeEach(guard: NavigationGuard): Function + + beforeResolve(guard: NavigationGuard): Function + + afterEach(hook: (to: Route, from: Route) => any): Function + + push(location: RawLocation): Promise + + replace(location: RawLocation): Promise + + push( + location: RawLocation, + onComplete?: Function, + onAbort?: ErrorHandler, + ): void + + replace( + location: RawLocation, + onComplete?: Function, + onAbort?: ErrorHandler, + ): void + + go(n: number): void + + back(): void + + forward(): void + + match(raw: RawLocation, current?: Route, redirectedFrom?: Location): Route + + getMatchedComponents(to?: RawLocation | Route): Component[] + + onReady(cb: Function, errorCb?: ErrorHandler): void + + onError(cb: ErrorHandler): void + + addRoutes(routes: RouteConfig[]): void + + addRoute(parent: string, route: RouteConfig): void + addRoute(route: RouteConfig): void + + getRoutes(): RouteRecordPublic[] + + resolve( + to: RawLocation, + current?: Route, + append?: boolean, + ): { + location: Location + route: Route + href: string + // backwards compat + normalizedTo: Location + resolved: Route + } + +} + +type RoutePropsFunction = (route: Route) => Object + +interface _RouteConfigBase { + path: string; + name?: string; + children?: RouteConfig[]; + redirect?: RedirectOption; + alias?: string | string[]; + meta?: RouteMeta; + beforeEnter?: NavigationGuard; + caseSensitive?: boolean; + pathToRegexpOptions?: PathToRegexpOptions; +} + +interface RouteConfigSingleView extends _RouteConfigBase { + component?: Component; + props?: boolean | Object | RoutePropsFunction; +} + +interface RouteConfigMultipleViews extends _RouteConfigBase { + components?: Dictionary; + props?: Dictionary; +} + +type RouteConfig = RouteConfigSingleView | RouteConfigMultipleViews + +interface PathToRegexpOptions { + sensitive?: boolean; + strict?: boolean; + end?: boolean; +} + +interface _RouteConfigBase { + path: string; + name?: string; + children?: RouteConfig[]; + redirect?: RedirectOption; + alias?: string | string[]; + meta?: RouteMeta; + beforeEnter?: NavigationGuard; + caseSensitive?: boolean; + pathToRegexpOptions?: PathToRegexpOptions; +} + +interface RouteRecord { + path: string; + regex: RegExp; + components: Dictionary; + name?: string; + parent?: RouteRecord; + redirect?: RedirectOption; + matchAs?: string; + meta: RouteMeta; + beforeEnter?: ( + route: Route, + redirect: (location: RawLocation) => void, + next: () => void, + ) => any; + props: + | boolean + | Object + | RoutePropsFunction + | Dictionary; +} + +interface RouteRecordPublic { + path: string; + components: Dictionary; + name?: string; + redirect?: RedirectOption; + meta: any; + beforeEnter?: ( + route: Route, + redirect: (location: RawLocation) => void, + next: () => void, + ) => any; + props: + | boolean + | Object + | RoutePropsFunction + | Dictionary; +} + + +interface Location { + name?: string; + path?: string; + hash?: string; + query?: Dictionary; + params?: Dictionary; + append?: boolean; + replace?: boolean; +} + +interface Route { + path: string; + name?: string | null; + hash: string; + query: Dictionary; + params: Dictionary; + fullPath: string; + matched: RouteRecord[]; + redirectedFrom?: string; + meta?: RouteMeta; +} + +interface RouteMeta extends Record { +} + + export declare class Router { - constructor(op: {[key: string]: any}); + constructor(op: { [key: string]: any }); + + static $router: VueRouter; route(route: string, callback: Function): this; route(route: string, name: string, callback?: Function): this; execute(callback?: Function, args?: any[]): void; - navigate(fragment: string, options?: {[key: string]: any} | boolean): this; + navigate(fragment: string, options?: { [key: string]: any } | boolean): this; } export declare class History { @@ -20,13 +219,13 @@ export declare class History { getFragment(fragment?: string): string; - start(op?: {[key: string]: any}): void; + start(op?: { [key: string]: any }): void; stop(): void; route(route: string, callback: Function): void; - checkRoute(route: string): { route: string, callback: Function}; + checkRoute(route: string): { route: string, callback: Function }; unRoute(route: string): void; @@ -34,5 +233,5 @@ export declare class History { loadUrl(fragment: string): boolean; - navigate(fragment: string, options?: {[key: string]: any} | boolean): void; + navigate(fragment: string, options?: { [key: string]: any } | boolean): void; } diff --git a/typescript/widget/downlist/combo.downlist.ts b/typescript/widget/downlist/combo.downlist.ts index e587df6d8..6cc88db52 100644 --- a/typescript/widget/downlist/combo.downlist.ts +++ b/typescript/widget/downlist/combo.downlist.ts @@ -5,10 +5,14 @@ export declare class DownListCombo extends Widget { static EVENT_CHANGE: string; static EVENT_SON_VALUE_CHANGE: string; static EVENT_BEFORE_POPUPVIEW: string; - + hideView: () => void; showView: (e?: any) => void; populate: (items?: any) => void; + + adjustWidth: (e?: MouseEvent) => void; + + adjustHeight: (e?: MouseEvent) => void; } diff --git a/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts b/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts index 1fc9e1519..6146190b8 100644 --- a/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts +++ b/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts @@ -21,4 +21,6 @@ export declare class MultiLayerSelectTreeCombo extends Widget { blur(): void; showView(): void; + + setStatus(status: "error" | "warning"): void; } diff --git a/typescript/widget/multilayersingletree/multilayersingletree.combo.ts b/typescript/widget/multilayersingletree/multilayersingletree.combo.ts index fcecc32c4..ebbf5c607 100644 --- a/typescript/widget/multilayersingletree/multilayersingletree.combo.ts +++ b/typescript/widget/multilayersingletree/multilayersingletree.combo.ts @@ -21,4 +21,6 @@ export declare class MultiLayerSingleTreeCombo extends Widget { blur(): void; showView(): void; + + setStatus(status: "error" | "warning"): void; }