From fba54699afa9a203b4e1791f628a77f8538b2239 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 20 Mar 2017 17:41:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gruntfile.js | 8 +- demo.css | 6 +- demo.js | 119 ++---- demo/app.js | 98 +---- demo/css/main.css | 3 + demo/js/main.js | 18 + demo/less/main.less | 5 + demo/version.js | 3 + dist/base.js | 54 ++- dist/case.js | 374 ------------------ dist/core.js | 207 ++++++---- src/base/collection/collection.js | 4 + src/base/combination/combo.js | 22 +- src/base/combination/expander.js | 4 +- src/base/combination/group.button.js | 4 - src/base/combination/loader.js | 4 - src/base/combination/navigation.js | 4 - src/base/combination/searcher.js | 4 +- src/base/combination/switcher.js | 4 +- src/base/combination/tab.js | 4 +- src/config.js | 140 +++---- src/core/widget.js | 36 +- src/core/wrapper/layout.js | 6 +- src/core/wrapper/layout/adapt/adapt.center.js | 6 +- .../wrapper/layout/adapt/adapt.horizontal.js | 6 +- .../layout/adapt/adapt.leftrightvertical.js | 1 + .../wrapper/layout/adapt/adapt.vertical.js | 6 +- .../wrapper/layout/adapt/inline.center.js | 6 +- 28 files changed, 350 insertions(+), 806 deletions(-) create mode 100644 demo/css/main.css create mode 100644 demo/js/main.js create mode 100644 demo/less/main.less create mode 100644 demo/version.js diff --git a/Gruntfile.js b/Gruntfile.js index 6e86d9a9a..633cf6ad4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -52,7 +52,7 @@ module.exports = function (grunt) { dest: 'dist/case.js' }, coreCss: { - src: ['src/css/core/**/*.css','src/css/utils/**/*.css'], + src: ['src/css/core/**/*.css', 'src/css/utils/**/*.css'], dest: 'dist/core.css' }, baseCss: { @@ -61,8 +61,12 @@ module.exports = function (grunt) { }, demoJs: { - src: ['demo/**/*.js'], + src: ['demo/version.js', 'demo/**/*.js'], dest: 'demo.js' + }, + demoCss: { + src: ['demo/css/**/*.css'], + dest: 'demo.css' } }, diff --git a/demo.css b/demo.css index 818a06a82..beaf06ad6 100644 --- a/demo.css +++ b/demo.css @@ -1,3 +1,3 @@ -.bg1{ - background: #00B83F; -} \ No newline at end of file +.demo-main .bg1 { + background-color: #178cdf; +} diff --git a/demo.js b/demo.js index 3bae55ecd..ad2f0cf34 100644 --- a/demo.js +++ b/demo.js @@ -1,104 +1,31 @@ -$(function () { +Demo = { + version: 1.0 +};$(function () { var ref; - var w = BI.createWidget({ - type: "bi.float_center_adapt", - items: [{ - el: { - type: "bi.layout", - cls: 'bg1', - width: 100, - height: 100 - }, - left: 0, - top: 0 - }] - }); - var Widget = BI.inherit(BI.Widget, { - props: { - a: {} - }, - init: function () { - console.log("init"); - }, - beforeCreated: function () { - console.log("beforeCreated"); - }, - render: function () { - console.log("render"); - var items = [], header = [], columnSize = []; - - var rowCount = 100, columnCount = 100; - for (var i = 0; i < 1; i++) { - header[i] = []; - for (var j = 0; j < columnCount; j++) { - header[i][j] = { - type: "bi.label", - text: "表头" + i + "-" + j - } - columnSize[j] = 100; - } - } - for (var i = 0; i < rowCount; i++) { - items[i] = []; - for (var j = 0; j < columnCount; j++) { - items[i][j] = { - type: "bi.label", - text: (i < 3 ? 0 : i) + "-" + j - } - } - } - - var table = BI.createWidget({ - type: "bi.resizable_table", - el: { - type: "bi.collection_table", - isNeedMerge: true, - mergeCols: [0, 1], - mergeRule: function (col1, col2) { - return BI.isEqual(col1, col2); - } - }, - width: 600, - height: 500, - isResizeAdapt: true, - isNeedResize: true, - isNeedMerge: true, - isNeedFreeze: true, - freezeCols: [0, 1], - columnSize: columnSize, - items: items, - header: header - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: table, - left: 10, - right: 10, - top: 10, - bottom: 10 - }] - }) - }, - created: function () { - console.log("created"); - }, - mounted: function () { - console.log("mounted"); - }, - destroyed: function () { - console.log("destroyed") - } - }); - $.shortcut("t", Widget); BI.createWidget({ - type: "t", + type: "demo.main", ref: function (_ref) { console.log(_ref); ref = _ref; }, element: '#wrapper' - }) + }); // ref.destroy(); -}) \ No newline at end of file +});Demo.Main = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-main" + }, + render: function () { + return { + type: "bi.button_group", + layouts: [{ + type: "bi.vertical" + }], + items: [{ + type: "bi.button", + text: 1 + }] + } + } +}); +$.shortcut("demo.main", Demo.Main); \ No newline at end of file diff --git a/demo/app.js b/demo/app.js index 3bae55ecd..cfca022f7 100644 --- a/demo/app.js +++ b/demo/app.js @@ -1,104 +1,12 @@ $(function () { var ref; - var w = BI.createWidget({ - type: "bi.float_center_adapt", - items: [{ - el: { - type: "bi.layout", - cls: 'bg1', - width: 100, - height: 100 - }, - left: 0, - top: 0 - }] - }); - var Widget = BI.inherit(BI.Widget, { - props: { - a: {} - }, - init: function () { - console.log("init"); - }, - beforeCreated: function () { - console.log("beforeCreated"); - }, - render: function () { - console.log("render"); - var items = [], header = [], columnSize = []; - - var rowCount = 100, columnCount = 100; - for (var i = 0; i < 1; i++) { - header[i] = []; - for (var j = 0; j < columnCount; j++) { - header[i][j] = { - type: "bi.label", - text: "表头" + i + "-" + j - } - columnSize[j] = 100; - } - } - for (var i = 0; i < rowCount; i++) { - items[i] = []; - for (var j = 0; j < columnCount; j++) { - items[i][j] = { - type: "bi.label", - text: (i < 3 ? 0 : i) + "-" + j - } - } - } - - var table = BI.createWidget({ - type: "bi.resizable_table", - el: { - type: "bi.collection_table", - isNeedMerge: true, - mergeCols: [0, 1], - mergeRule: function (col1, col2) { - return BI.isEqual(col1, col2); - } - }, - width: 600, - height: 500, - isResizeAdapt: true, - isNeedResize: true, - isNeedMerge: true, - isNeedFreeze: true, - freezeCols: [0, 1], - columnSize: columnSize, - items: items, - header: header - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: table, - left: 10, - right: 10, - top: 10, - bottom: 10 - }] - }) - }, - created: function () { - console.log("created"); - }, - mounted: function () { - console.log("mounted"); - }, - destroyed: function () { - console.log("destroyed") - } - }); - $.shortcut("t", Widget); BI.createWidget({ - type: "t", + type: "demo.main", ref: function (_ref) { console.log(_ref); ref = _ref; }, element: '#wrapper' - }) + }); // ref.destroy(); -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/demo/css/main.css b/demo/css/main.css new file mode 100644 index 000000000..beaf06ad6 --- /dev/null +++ b/demo/css/main.css @@ -0,0 +1,3 @@ +.demo-main .bg1 { + background-color: #178cdf; +} diff --git a/demo/js/main.js b/demo/js/main.js new file mode 100644 index 000000000..12b2a50b6 --- /dev/null +++ b/demo/js/main.js @@ -0,0 +1,18 @@ +Demo.Main = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-main" + }, + render: function () { + return { + type: "bi.button_group", + layouts: [{ + type: "bi.vertical" + }], + items: [{ + type: "bi.button", + text: 1 + }] + } + } +}); +$.shortcut("demo.main", Demo.Main); \ No newline at end of file diff --git a/demo/less/main.less b/demo/less/main.less new file mode 100644 index 000000000..768d2220e --- /dev/null +++ b/demo/less/main.less @@ -0,0 +1,5 @@ +.demo-main { + & .bg1 { + background-color: #178cdf; + } +} \ No newline at end of file diff --git a/demo/version.js b/demo/version.js new file mode 100644 index 000000000..ecaa4de93 --- /dev/null +++ b/demo/version.js @@ -0,0 +1,3 @@ +Demo = { + version: 1.0 +}; \ No newline at end of file diff --git a/dist/base.js b/dist/base.js index 1ea6ce2d4..f065f714f 100644 --- a/dist/base.js +++ b/dist/base.js @@ -21435,6 +21435,10 @@ BI.Collection = BI.inherit(BI.Widget, { } }, + destroyed: function () { + this._debounceRelease = null; + }, + _calculateSizeAndPositionData: function () { var o = this.options; var cellMetadata = []; @@ -21899,35 +21903,35 @@ BI.Combo = BI.inherit(BI.Widget, { break; case "top": case "top,right": - p = $.getComboPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength,o.isNeedAdjustHeight, ['top', 'bottom', 'right', 'left'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ['top', 'bottom', 'right', 'left'], o.offsetStyle); break; case "left": case "left,bottom": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['left', 'right', 'bottom', 'top'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['left', 'right', 'bottom', 'top'], o.offsetStyle); break; case "right": case "right,bottom": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['right', 'left', 'bottom', 'top'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['right', 'left', 'bottom', 'top'], o.offsetStyle); break; case "top,left": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset|| o.adjustLength,o.isNeedAdjustHeight, ['top', 'bottom', 'left', 'right'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ['top', 'bottom', 'left', 'right'], o.offsetStyle); break; case "bottom,left": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset|| o.adjustLength,o.isNeedAdjustHeight, ['bottom', 'top', 'left', 'right'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ['bottom', 'top', 'left', 'right'], o.offsetStyle); break; case "left,top": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['left', 'right', 'top', 'bottom'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['left', 'right', 'top', 'bottom'], o.offsetStyle); break; case "right,top": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['right', 'left', 'top', 'bottom'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['right', 'left', 'top', 'bottom'], o.offsetStyle); break; case "top,custom": case "custom,top": - p = $.getTopAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength,o.isNeedAdjustHeight); + p = $.getTopAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight); break; case "custom,bottom": case "bottom,custom": - p = $.getBottomAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength,o.isNeedAdjustHeight); + p = $.getBottomAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight); break; case "left,custom": case "custom,left": @@ -22020,14 +22024,14 @@ BI.Combo = BI.inherit(BI.Widget, { this._toggle(); }, - destroy: function () { + destroyed: function () { $(document).unbind("mousedown." + this.getName()) .unbind("mousewheel." + this.getName()) .unbind("mouseenter." + this.getName()) .unbind("mousemove." + this.getName()) .unbind("mouseleave." + this.getName()); + this.popupView && this.popupView.destroy(); BI.Resizers.remove(this.getName()); - BI.Combo.superclass.destroy.apply(this, arguments); } }); BI.Combo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; @@ -22298,8 +22302,8 @@ BI.Expander = BI.inherit(BI.Widget, { return this.popupView && this.popupView.getNodeByValue(value); }, - destroy: function () { - BI.Expander.superclass.destroy.apply(this, arguments); + destroyed: function () { + this.popupView && this.popupView.destroy(); } }); BI.Expander.EVENT_EXPAND = "EVENT_EXPAND"; @@ -22614,10 +22618,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { } }); return node; - }, - - destroy: function () { - BI.ButtonGroup.superclass.destroy.apply(this, arguments); } }); BI.extend(BI.ButtonGroup, { @@ -22984,10 +22984,6 @@ BI.Loader = BI.inherit(BI.Widget, { BI.each([this.prev, this.next], function (i, ob) { ob && ob.setVisible(false); }); - }, - - destroy: function () { - BI.Loader.superclass.destroy.apply(this, arguments); } }); BI.Loader.EVENT_CHANGE = "EVENT_CHANGE"; @@ -23120,10 +23116,6 @@ BI.Navigation = BI.inherit(BI.Widget, { empty: function(){ this.layout.deleteAllCard(); this.cardMap = {}; - }, - - destroy: function(){ - BI.Navigation.superclass.destroy.apply(this, arguments); } }); BI.Navigation.EVENT_CHANGE = "EVENT_CHANGE"; @@ -23413,9 +23405,9 @@ BI.Searcher = BI.inherit(BI.Widget, { this.popupView && this.popupView.empty(); }, - destroy: function () { + destroyed: function () { + this.popupView && this.popupView.destroy(); BI.Maskers.remove(this.getName()); - BI.Searcher.superclass.destroy.apply(this, arguments); } }); BI.Searcher.EVENT_CHANGE = "EVENT_CHANGE"; @@ -23685,8 +23677,8 @@ BI.Switcher = BI.inherit(BI.Widget, { this.popupView && this.popupView.empty(); }, - destroy: function () { - BI.Switcher.superclass.destroy.apply(this, arguments); + destroyed: function () { + this.popupView && this.popupView.destroy(); } }); BI.Switcher.EVENT_EXPAND = "EVENT_EXPAND"; @@ -23817,9 +23809,9 @@ BI.Tab = BI.inherit(BI.Widget, { this.cardMap = {}; }, - destroy: function () { + destroyed: function () { + this.layout.deleteAllCard(); this.cardMap = {}; - BI.Tab.superclass.destroy.apply(this, arguments); } }); BI.Tab.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/dist/case.js b/dist/case.js index 83c882d11..a9e4f2c7a 100644 --- a/dist/case.js +++ b/dist/case.js @@ -2027,380 +2027,6 @@ BI.ComplexCanvas = BI.inherit(BI.Widget, { }); $.shortcut("bi.complex_canvas", BI.ComplexCanvas);/** - * 图表控件 - * @class BI.CombineChart - * @extends BI.Widget - */ -BI.CombineChart = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.CombineChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-combine-chart", - items: [], - xAxis: [{type: "category"}], - yAxis: [{type: "value"}], - types: [[], []], - formatConfig: function(config){return config;} - }) - }, - - _init: function () { - BI.CombineChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - //图可配置属性 - this.CombineChart = BI.createWidget({ - type: "bi.chart", - element: this - }); - this.CombineChart.on(BI.Chart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.CombineChart.EVENT_CHANGE, obj); - }); - - if (BI.isNotEmptyArray(o.items)) { - this.populate(o.items); - } - }, - - _formatItems: function (items) { - var result = [], self = this, o = this.options; - var yAxisIndex = 0; - BI.each(items, function (i, belongAxisItems) { - var combineItems = BI.ChartCombineFormatItemFactory.combineItems(o.types[i], belongAxisItems); - BI.each(combineItems, function (j, axisItems) { - if (BI.isArray(axisItems)) { - result = BI.concat(result, axisItems); - } else { - result.push(BI.extend(axisItems, {"yAxis": yAxisIndex})); - } - }); - if (BI.isNotEmptyArray(combineItems)) { - yAxisIndex++; - } - }); - var config = BI.ChartCombineFormatItemFactory.combineConfig(); - config.plotOptions.click = function () { - self.fireEvent(BI.CombineChart.EVENT_CHANGE, this.pointOption); - }; - return [result, config]; - }, - - setTypes: function (types) { - this.options.types = types || [[]]; - }, - - populate: function (items, types) { - var o = this.options; - if (BI.isNotNull(types)) { - this.setTypes(types); - } - var opts = this._formatItems(items); - BI.extend(opts[1], { - xAxis: o.xAxis, - yAxis: o.yAxis - }); - var result = o.formatConfig(opts[1], opts[0]); - this.CombineChart.populate(result[0], result[1]); - }, - - resize: function () { - this.CombineChart.resize(); - }, - - magnify: function(){ - this.CombineChart.magnify(); - } -}); -BI.CombineChart.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut('bi.combine_chart', BI.CombineChart);BI.ChartCombineFormatItemFactory = { - combineItems: function (types, items) { - var calItems = BI.values(items); - return BI.map(calItems, function (idx, item) { - return BI.ChartCombineFormatItemFactory.formatItems(types[idx], item); - }); - }, - - formatItems: function (type, items) { - var item = {}; - switch (type) { - case BICst.WIDGET.BAR: - case BICst.WIDGET.ACCUMULATE_BAR: - case BICst.WIDGET.COMPARE_BAR: - item = BI.extend({"type": "bar"}, items); - break; - case BICst.WIDGET.BUBBLE: - case BICst.WIDGET.FORCE_BUBBLE: - item = BI.extend({"type": "bubble"}, items); - break; - case BICst.WIDGET.SCATTER: - item = BI.extend({"type": "scatter"}, items); - break; - case BICst.WIDGET.AXIS: - case BICst.WIDGET.ACCUMULATE_AXIS: - case BICst.WIDGET.PERCENT_ACCUMULATE_AXIS: - case BICst.WIDGET.COMPARE_AXIS: - case BICst.WIDGET.FALL_AXIS: - item = BI.extend({"type": "column"}, items); - break; - case BICst.WIDGET.LINE: - item = BI.extend({"type": "line"}, items); - break; - case BICst.WIDGET.AREA: - case BICst.WIDGET.ACCUMULATE_AREA: - case BICst.WIDGET.COMPARE_AREA: - case BICst.WIDGET.RANGE_AREA: - case BICst.WIDGET.PERCENT_ACCUMULATE_AREA: - item = BI.extend({"type": "area"}, items); - break; - case BICst.WIDGET.DONUT: - item = BI.extend({"type": "pie"}, items); - break; - case BICst.WIDGET.RADAR: - case BICst.WIDGET.ACCUMULATE_RADAR: - item = BI.extend({"type": "radar"}, items); - break; - case BICst.WIDGET.PIE: - item = BI.extend({"type": "pie"}, items); - break; - case BICst.WIDGET.DASHBOARD: - item = BI.extend({"type": "gauge"}, items); - break; - case BICst.WIDGET.MAP: - item = BI.extend({"type": "areaMap"}, items); - break; - case BICst.WIDGET.GIS_MAP: - item = BI.extend({"type": "pointMap"}, items); - break; - default: - item = BI.extend({"type": "column"}, items); - break; - } - return item; - }, - - combineConfig: function () { - return { - "plotOptions": { - "rotatable": false, - "startAngle": 0, - "borderRadius": 0, - "endAngle": 360, - "innerRadius": "0.0%", - - "layout": "horizontal", - "hinge": "rgb(101,107,109)", - "dataLabels": { - "style": {fontFamily: "inherit", color: "#808080", fontSize: "12px"}, - "formatter": { - "identifier": "${VALUE}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat, - "XFormat": this._contentFormat2Decimal, - "YFormat": this._contentFormat2Decimal, - "sizeFormat": this._contentFormat2Decimal - }, - "align": "outside", - "enabled": false - }, - "percentageLabel": { - "formatter": { - "identifier": "${PERCENT}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat - }, - "style": { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", "color": "#808080", "fontSize": "12px" - }, - "align": "bottom", - "enabled": true - }, - "valueLabel": { - "formatter": { - "identifier": "${SERIES}${VALUE}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat - }, - "backgroundColor": "rgb(255,255,0)", - "style": { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", "color": "#808080", "fontSize": "12px" - }, - "align": "inside", - "enabled": true - }, - "hingeBackgroundColor": "rgb(220,242,249)", - "seriesLabel": { - "formatter": { - "identifier": "${CATEGORY}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat - }, - "style": { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", "color": "#808080", "fontSize": "12px" - }, - "align": "bottom", - "enabled": true - }, - "style": "pointer", - "paneBackgroundColor": "rgb(252,252,252)", - "needle": "rgb(229,113,90)", - - - "large": false, - "connectNulls": false, - "shadow": true, - "curve": false, - "sizeBy": "area", - "tooltip": { - "formatter": { - "identifier": "${SERIES}${X}${Y}${SIZE}{CATEGORY}${SERIES}${VALUE}", - "valueFormat": "function(){return window.FR ? FR.contentFormat(arguments[0], '#.##') : arguments[0];}", - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat, - "XFormat": this._contentFormat2Decimal, - "sizeFormat": this._contentFormat2Decimal, - "YFormat": this._contentFormat2Decimal - }, - "shared": false, - "padding": 5, - "backgroundColor": "rgba(0,0,0,0.4980392156862745)", - "borderColor": "rgb(0,0,0)", - "shadow": false, - "borderRadius": 2, - "borderWidth": 0, - "follow": false, - "enabled": true, - "animation": true, - style: { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", - "color": "#c4c6c6", - "fontSize": "12px", - "fontWeight": "" - } - }, - "maxSize": 80, - "fillColorOpacity": 1.0, - "step": false, - "force": false, - "minSize": 15, - "displayNegative": true, - "categoryGap": "16.0%", - "borderColor": "rgb(255,255,255)", - "borderWidth": 1, - "gap": "22.0%", - "animation": true, - "lineWidth": 2, - - bubble: { - "large": false, - "connectNulls": false, - "shadow": true, - "curve": false, - "sizeBy": "area", - "maxSize": 80, - "minSize": 15, - "lineWidth": 0, - "animation": true, - "fillColorOpacity": 0.699999988079071, - "marker": { - "symbol": "circle", - "radius": 28.39695010101295, - "enabled": true - } - } - }, - dTools: { - enabled: false, - style: { - fontFamily: "Microsoft YaHei, Hiragino Sans GB W3", - color: "#1a1a1a", - fontSize: "12px" - }, - backgroundColor: 'white' - }, - dataSheet: { - enabled: false, - "borderColor": "rgb(0,0,0)", - "borderWidth": 1, - "formatter": this._contentFormat2Decimal, - style: { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", "color": "#808080", "fontSize": "12px" - } - }, - "borderColor": "rgb(238,238,238)", - "shadow": false, - "legend": { - "borderColor": "rgb(204,204,204)", - "borderRadius": 0, - "shadow": false, - "borderWidth": 0, - "visible": true, - "style": { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", "color": "#1a1a1a", "fontSize": "12px" - }, - "position": "right", - "enabled": false - }, - "rangeLegend": { - "range": { - "min": 0, - "color": [ - [ - 0, - "rgb(182,226,255)" - ], - [ - 0.5, - "rgb(109,196,255)" - ], - [ - 1, - "rgb(36,167,255)" - ] - ], - "max": 266393 - }, - "enabled": false - }, - "zoom": {"zoomType": "xy", "zoomTool": {"visible": false, "resize": true, "from": "", "to": ""}}, - "plotBorderColor": "rgba(255,255,255,0)", - "tools": { - "hidden": true, - "toImage": {"enabled": true}, - "sort": {"enabled": true}, - "enabled": false, - "fullScreen": {"enabled": true} - }, - "plotBorderWidth": 0, - "colors": ["rgb(99,178,238)", "rgb(118,218,145)"], - "borderRadius": 0, - "borderWidth": 0, - "style": "normal", - "plotShadow": false, - "plotBorderRadius": 0 - }; - }, - - _contentFormat: function () { - return BI.contentFormat(arguments[0], '') - }, - - _contentFormat2Decimal: function () { - return BI.contentFormat(arguments[0], '#.##') - }, - - _contentFormatPercentage: function () { - return BI.contentFormat(arguments[0], '#.##%') - } -};/** * Created by roy on 15/10/16. * 上箭头与下箭头切换的树节点 */ diff --git a/dist/core.js b/dist/core.js index 2907fa248..86a4e0216 100644 --- a/dist/core.js +++ b/dist/core.js @@ -14205,7 +14205,7 @@ BI.Widget = BI.inherit(BI.OB, { this._parent = o.element; this._parent.addWidget(this.widgetName, this); this.element = this.options.element.element; - } else if (BI.isString(o.element)) { + } else if (o.element) { this.element = $(o.element); this._isRoot = true; } else { @@ -14321,7 +14321,7 @@ BI.Widget = BI.inherit(BI.OB, { BI.each(this._children, function (i, widget) { widget._unMount(); }); - this._children = []; + this._children = {}; this._parent = null; this._isMounted = false; this.destroyed(); @@ -14467,6 +14467,38 @@ BI.Widget = BI.inherit(BI.OB, { return !this.options.invisible; }, + disable: function () { + this.setEnable(false); + }, + + enable: function () { + this.setEnable(true); + }, + + valid: function () { + this.setValid(true); + }, + + invalid: function () { + this.setValid(false); + }, + + invisible: function () { + this.setVisible(false); + }, + + visible: function () { + this.setVisible(true); + }, + + empty: function () { + BI.each(this._children, function (i, widget) { + widget._unMount(); + }); + this._children = {}; + this.element.empty(); + }, + destroy: function () { this._unMount(); this.element.destroy(); @@ -19122,11 +19154,11 @@ BI.Layout = BI.inherit(BI.Widget, { _addElement: function (i, item) { var o = this.options; var w; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { w = BI.createWidget(item); - this.addWidget(this.getName() + i, w); + this.addWidget(this.getName() + "-" + i, w); } else { - w = this.getWidgetByName(this.getName() + i); + w = this.getWidgetByName(this.getName() + "-" + i); } return w; }, @@ -24147,7 +24179,7 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var td; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var w = BI.createWidget(item); w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); td = BI.createWidget({ @@ -24158,9 +24190,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { }, items: [w] }); - this.addWidget(this.getName() + i, td); + this.addWidget(this.getName() + "-" + i, td); } else { - td = this.getWidgetByName(this.getName() + i); + td = this.getWidgetByName(this.getName() + "-" + i); td.element.attr("width", width); } td.element.css({"max-width": o.columnSize[i]}); @@ -24269,7 +24301,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var td; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var w = BI.createWidget(item); w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); td = BI.createWidget({ @@ -24280,9 +24312,9 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { }, items: [w] }); - this.addWidget(this.getName() + i, td); + this.addWidget(this.getName() + "-" + i, td); } else { - td = this.getWidgetByName(this.getName() + i); + td = this.getWidgetByName(this.getName() + "-" + i); td.element.attr("width", width); } td.element.css({"max-width": o.columnSize[i] + "px"}); @@ -24424,6 +24456,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.LeftRightVerticalAdaptLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.left_right_vertical_adapt', BI.LeftRightVerticalAdaptLayout); @@ -24554,7 +24587,7 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var td; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var w = BI.createWidget(item); w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); td = BI.createWidget({ @@ -24565,9 +24598,9 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { }, items: [w] }); - this.addWidget(this.getName() + i, td); + this.addWidget(this.getName() + "-" + i, td); } else { - td = this.getWidgetByName(this.getName() + i); + td = this.getWidgetByName(this.getName() + "-" + i); td.element.attr("width", width); } @@ -24863,7 +24896,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { _addElement: function (i, item, length) { var o = this.options; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var t = BI.createWidget(item); t.element.css({ "position": "relative" @@ -24872,9 +24905,9 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { type: "bi.horizontal_auto", items: [t] }); - this.addWidget(this.getName() + i, w); + this.addWidget(this.getName() + "-" + i, w); } else { - var w = this.getWidgetByName(this.getName() + i); + var w = this.getWidgetByName(this.getName() + "-" + i); } w.element.css({ "position": "relative", @@ -27753,74 +27786,74 @@ Data.Source = BISource = { $(function () { //注册布局 var isSupportFlex = BI.isSupportCss3("flex"); - // BI.Plugin.registerWidget("bi.horizontal", function (ob) { - // if (isSupportFlex) { - // return BI.extend(ob, {type: "bi.flex_horizontal"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.center_adapt", function (ob) { - // if (isSupportFlex && ob.items && ob.items.length <= 1) { - // //有滚动条的情况下需要用到flex_wrapper_center布局 - // if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { - // //不是IE用flex_wrapper_center布局 - // if (!BI.isIE()) { - // return BI.extend(ob, {type: "bi.flex_wrapper_center"}); - // } - // return ob; - // } - // return BI.extend(ob, {type: "bi.flex_center"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.vertical_adapt", function (ob) { - // if (isSupportFlex) { - // //有滚动条的情况下需要用到flex_wrapper_center布局 - // if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { - // //不是IE用flex_wrapper_center布局 - // if (!BI.isIE()) { - // return BI.extend({}, ob, {type: "bi.flex_wrapper_vertical_center"}); - // } - // return ob; - // } - // return BI.extend(ob, {type: "bi.flex_vertical_center"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { - // if (isSupportFlex) { - // //有滚动条的情况下需要用到flex_wrapper_center布局 - // if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { - // //不是IE用flex_wrapper_center布局 - // if (!BI.isIE()) { - // return BI.extend({}, ob, {type: "bi.flex_wrapper_center"}); - // } - // return ob; - // } - // return BI.extend(ob, {type: "bi.flex_center"}); - // } else { - // return ob; - // } - // }); - // - // //注册控件 - // BI.Plugin.registerWidget("bi.grid_table", function (ob) { - // //IE下滚动条滑动效果不好,禁止掉 - // if (BI.isIE() || BI.isFireFox()) { - // return BI.extend(ob, {type: "bi.quick_grid_table"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.collection_table", function (ob) { - // //IE下滚动条滑动效果不好,禁止掉 - // if (BI.isIE() || BI.isFireFox()) { - // return BI.extend(ob, {type: "bi.quick_collection_table"}); - // } else { - // return ob; - // } - // }); + BI.Plugin.registerWidget("bi.horizontal", function (ob) { + if (isSupportFlex) { + return BI.extend(ob, {type: "bi.flex_horizontal"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.center_adapt", function (ob) { + if (isSupportFlex && ob.items && ob.items.length <= 1) { + //有滚动条的情况下需要用到flex_wrapper_center布局 + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { + //不是IE用flex_wrapper_center布局 + if (!BI.isIE()) { + return BI.extend(ob, {type: "bi.flex_wrapper_center"}); + } + return ob; + } + return BI.extend(ob, {type: "bi.flex_center"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.vertical_adapt", function (ob) { + if (isSupportFlex) { + //有滚动条的情况下需要用到flex_wrapper_center布局 + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { + //不是IE用flex_wrapper_center布局 + if (!BI.isIE()) { + return BI.extend({}, ob, {type: "bi.flex_wrapper_vertical_center"}); + } + return ob; + } + return BI.extend(ob, {type: "bi.flex_vertical_center"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { + if (isSupportFlex) { + //有滚动条的情况下需要用到flex_wrapper_center布局 + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { + //不是IE用flex_wrapper_center布局 + if (!BI.isIE()) { + return BI.extend({}, ob, {type: "bi.flex_wrapper_center"}); + } + return ob; + } + return BI.extend(ob, {type: "bi.flex_center"}); + } else { + return ob; + } + }); + + //注册控件 + BI.Plugin.registerWidget("bi.grid_table", function (ob) { + //IE下滚动条滑动效果不好,禁止掉 + if (BI.isIE() || BI.isFireFox()) { + return BI.extend(ob, {type: "bi.quick_grid_table"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.collection_table", function (ob) { + //IE下滚动条滑动效果不好,禁止掉 + if (BI.isIE() || BI.isFireFox()) { + return BI.extend(ob, {type: "bi.quick_collection_table"}); + } else { + return ob; + } + }); }); \ No newline at end of file diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 906055b29..fa991aa87 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -68,6 +68,10 @@ BI.Collection = BI.inherit(BI.Widget, { } }, + destroyed: function () { + this._debounceRelease = null; + }, + _calculateSizeAndPositionData: function () { var o = this.options; var cellMetadata = []; diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 444cb1ea4..75fb6b7a2 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -235,35 +235,35 @@ BI.Combo = BI.inherit(BI.Widget, { break; case "top": case "top,right": - p = $.getComboPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength,o.isNeedAdjustHeight, ['top', 'bottom', 'right', 'left'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ['top', 'bottom', 'right', 'left'], o.offsetStyle); break; case "left": case "left,bottom": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['left', 'right', 'bottom', 'top'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['left', 'right', 'bottom', 'top'], o.offsetStyle); break; case "right": case "right,bottom": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['right', 'left', 'bottom', 'top'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['right', 'left', 'bottom', 'top'], o.offsetStyle); break; case "top,left": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset|| o.adjustLength,o.isNeedAdjustHeight, ['top', 'bottom', 'left', 'right'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ['top', 'bottom', 'left', 'right'], o.offsetStyle); break; case "bottom,left": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset|| o.adjustLength,o.isNeedAdjustHeight, ['bottom', 'top', 'left', 'right'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ['bottom', 'top', 'left', 'right'], o.offsetStyle); break; case "left,top": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['left', 'right', 'top', 'bottom'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['left', 'right', 'top', 'bottom'], o.offsetStyle); break; case "right,top": - p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset|| o.adjustLength, o.adjustYOffset,o.isNeedAdjustHeight, ['right', 'left', 'top', 'bottom'], o.offsetStyle); + p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ['right', 'left', 'top', 'bottom'], o.offsetStyle); break; case "top,custom": case "custom,top": - p = $.getTopAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength,o.isNeedAdjustHeight); + p = $.getTopAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight); break; case "custom,bottom": case "bottom,custom": - p = $.getBottomAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength,o.isNeedAdjustHeight); + p = $.getBottomAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight); break; case "left,custom": case "custom,left": @@ -356,14 +356,14 @@ BI.Combo = BI.inherit(BI.Widget, { this._toggle(); }, - destroy: function () { + destroyed: function () { $(document).unbind("mousedown." + this.getName()) .unbind("mousewheel." + this.getName()) .unbind("mouseenter." + this.getName()) .unbind("mousemove." + this.getName()) .unbind("mouseleave." + this.getName()); + this.popupView && this.popupView.destroy(); BI.Resizers.remove(this.getName()); - BI.Combo.superclass.destroy.apply(this, arguments); } }); BI.Combo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; diff --git a/src/base/combination/expander.js b/src/base/combination/expander.js index 533e3e4d7..8e593cee1 100644 --- a/src/base/combination/expander.js +++ b/src/base/combination/expander.js @@ -254,8 +254,8 @@ BI.Expander = BI.inherit(BI.Widget, { return this.popupView && this.popupView.getNodeByValue(value); }, - destroy: function () { - BI.Expander.superclass.destroy.apply(this, arguments); + destroyed: function () { + this.popupView && this.popupView.destroy(); } }); BI.Expander.EVENT_EXPAND = "EVENT_EXPAND"; diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 75cf01387..c48b86304 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -298,10 +298,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { } }); return node; - }, - - destroy: function () { - BI.ButtonGroup.superclass.destroy.apply(this, arguments); } }); BI.extend(BI.ButtonGroup, { diff --git a/src/base/combination/loader.js b/src/base/combination/loader.js index 434a90f2a..331c2ea9b 100644 --- a/src/base/combination/loader.js +++ b/src/base/combination/loader.js @@ -252,10 +252,6 @@ BI.Loader = BI.inherit(BI.Widget, { BI.each([this.prev, this.next], function (i, ob) { ob && ob.setVisible(false); }); - }, - - destroy: function () { - BI.Loader.superclass.destroy.apply(this, arguments); } }); BI.Loader.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/combination/navigation.js b/src/base/combination/navigation.js index 524821ce3..4e2f13b48 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -127,10 +127,6 @@ BI.Navigation = BI.inherit(BI.Widget, { empty: function(){ this.layout.deleteAllCard(); this.cardMap = {}; - }, - - destroy: function(){ - BI.Navigation.superclass.destroy.apply(this, arguments); } }); BI.Navigation.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/combination/searcher.js b/src/base/combination/searcher.js index 59abc5356..1c441664c 100644 --- a/src/base/combination/searcher.js +++ b/src/base/combination/searcher.js @@ -283,9 +283,9 @@ BI.Searcher = BI.inherit(BI.Widget, { this.popupView && this.popupView.empty(); }, - destroy: function () { + destroyed: function () { + this.popupView && this.popupView.destroy(); BI.Maskers.remove(this.getName()); - BI.Searcher.superclass.destroy.apply(this, arguments); } }); BI.Searcher.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/combination/switcher.js b/src/base/combination/switcher.js index d7468578f..1a624481f 100644 --- a/src/base/combination/switcher.js +++ b/src/base/combination/switcher.js @@ -258,8 +258,8 @@ BI.Switcher = BI.inherit(BI.Widget, { this.popupView && this.popupView.empty(); }, - destroy: function () { - BI.Switcher.superclass.destroy.apply(this, arguments); + destroyed: function () { + this.popupView && this.popupView.destroy(); } }); BI.Switcher.EVENT_EXPAND = "EVENT_EXPAND"; diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index f12d3a150..74c874938 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -114,9 +114,9 @@ BI.Tab = BI.inherit(BI.Widget, { this.cardMap = {}; }, - destroy: function () { + destroyed: function () { + this.layout.deleteAllCard(); this.cardMap = {}; - BI.Tab.superclass.destroy.apply(this, arguments); } }); BI.Tab.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/config.js b/src/config.js index 72a1fdf2a..a6b62ffac 100644 --- a/src/config.js +++ b/src/config.js @@ -2,74 +2,74 @@ $(function () { //注册布局 var isSupportFlex = BI.isSupportCss3("flex"); - // BI.Plugin.registerWidget("bi.horizontal", function (ob) { - // if (isSupportFlex) { - // return BI.extend(ob, {type: "bi.flex_horizontal"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.center_adapt", function (ob) { - // if (isSupportFlex && ob.items && ob.items.length <= 1) { - // //有滚动条的情况下需要用到flex_wrapper_center布局 - // if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { - // //不是IE用flex_wrapper_center布局 - // if (!BI.isIE()) { - // return BI.extend(ob, {type: "bi.flex_wrapper_center"}); - // } - // return ob; - // } - // return BI.extend(ob, {type: "bi.flex_center"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.vertical_adapt", function (ob) { - // if (isSupportFlex) { - // //有滚动条的情况下需要用到flex_wrapper_center布局 - // if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { - // //不是IE用flex_wrapper_center布局 - // if (!BI.isIE()) { - // return BI.extend({}, ob, {type: "bi.flex_wrapper_vertical_center"}); - // } - // return ob; - // } - // return BI.extend(ob, {type: "bi.flex_vertical_center"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { - // if (isSupportFlex) { - // //有滚动条的情况下需要用到flex_wrapper_center布局 - // if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { - // //不是IE用flex_wrapper_center布局 - // if (!BI.isIE()) { - // return BI.extend({}, ob, {type: "bi.flex_wrapper_center"}); - // } - // return ob; - // } - // return BI.extend(ob, {type: "bi.flex_center"}); - // } else { - // return ob; - // } - // }); - // - // //注册控件 - // BI.Plugin.registerWidget("bi.grid_table", function (ob) { - // //IE下滚动条滑动效果不好,禁止掉 - // if (BI.isIE() || BI.isFireFox()) { - // return BI.extend(ob, {type: "bi.quick_grid_table"}); - // } else { - // return ob; - // } - // }); - // BI.Plugin.registerWidget("bi.collection_table", function (ob) { - // //IE下滚动条滑动效果不好,禁止掉 - // if (BI.isIE() || BI.isFireFox()) { - // return BI.extend(ob, {type: "bi.quick_collection_table"}); - // } else { - // return ob; - // } - // }); + BI.Plugin.registerWidget("bi.horizontal", function (ob) { + if (isSupportFlex) { + return BI.extend(ob, {type: "bi.flex_horizontal"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.center_adapt", function (ob) { + if (isSupportFlex && ob.items && ob.items.length <= 1) { + //有滚动条的情况下需要用到flex_wrapper_center布局 + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { + //不是IE用flex_wrapper_center布局 + if (!BI.isIE()) { + return BI.extend(ob, {type: "bi.flex_wrapper_center"}); + } + return ob; + } + return BI.extend(ob, {type: "bi.flex_center"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.vertical_adapt", function (ob) { + if (isSupportFlex) { + //有滚动条的情况下需要用到flex_wrapper_center布局 + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { + //不是IE用flex_wrapper_center布局 + if (!BI.isIE()) { + return BI.extend({}, ob, {type: "bi.flex_wrapper_vertical_center"}); + } + return ob; + } + return BI.extend(ob, {type: "bi.flex_vertical_center"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { + if (isSupportFlex) { + //有滚动条的情况下需要用到flex_wrapper_center布局 + if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { + //不是IE用flex_wrapper_center布局 + if (!BI.isIE()) { + return BI.extend({}, ob, {type: "bi.flex_wrapper_center"}); + } + return ob; + } + return BI.extend(ob, {type: "bi.flex_center"}); + } else { + return ob; + } + }); + + //注册控件 + BI.Plugin.registerWidget("bi.grid_table", function (ob) { + //IE下滚动条滑动效果不好,禁止掉 + if (BI.isIE() || BI.isFireFox()) { + return BI.extend(ob, {type: "bi.quick_grid_table"}); + } else { + return ob; + } + }); + BI.Plugin.registerWidget("bi.collection_table", function (ob) { + //IE下滚动条滑动效果不好,禁止掉 + if (BI.isIE() || BI.isFireFox()) { + return BI.extend(ob, {type: "bi.quick_collection_table"}); + } else { + return ob; + } + }); }); \ No newline at end of file diff --git a/src/core/widget.js b/src/core/widget.js index 1b151fbc9..cf55061ee 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -68,7 +68,7 @@ BI.Widget = BI.inherit(BI.OB, { this._parent = o.element; this._parent.addWidget(this.widgetName, this); this.element = this.options.element.element; - } else if (BI.isString(o.element)) { + } else if (o.element) { this.element = $(o.element); this._isRoot = true; } else { @@ -184,7 +184,7 @@ BI.Widget = BI.inherit(BI.OB, { BI.each(this._children, function (i, widget) { widget._unMount(); }); - this._children = []; + this._children = {}; this._parent = null; this._isMounted = false; this.destroyed(); @@ -330,6 +330,38 @@ BI.Widget = BI.inherit(BI.OB, { return !this.options.invisible; }, + disable: function () { + this.setEnable(false); + }, + + enable: function () { + this.setEnable(true); + }, + + valid: function () { + this.setValid(true); + }, + + invalid: function () { + this.setValid(false); + }, + + invisible: function () { + this.setVisible(false); + }, + + visible: function () { + this.setVisible(true); + }, + + empty: function () { + BI.each(this._children, function (i, widget) { + widget._unMount(); + }); + this._children = {}; + this.element.empty(); + }, + destroy: function () { this._unMount(); this.element.destroy(); diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 7c06d68c4..76b9db127 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -66,11 +66,11 @@ BI.Layout = BI.inherit(BI.Widget, { _addElement: function (i, item) { var o = this.options; var w; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { w = BI.createWidget(item); - this.addWidget(this.getName() + i, w); + this.addWidget(this.getName() + "-" + i, w); } else { - w = this.getWidgetByName(this.getName() + i); + w = this.getWidgetByName(this.getName() + "-" + i); } return w; }, diff --git a/src/core/wrapper/layout/adapt/adapt.center.js b/src/core/wrapper/layout/adapt/adapt.center.js index abc0e09b2..061dc1281 100644 --- a/src/core/wrapper/layout/adapt/adapt.center.js +++ b/src/core/wrapper/layout/adapt/adapt.center.js @@ -36,7 +36,7 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var td; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var w = BI.createWidget(item); w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); td = BI.createWidget({ @@ -47,9 +47,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { }, items: [w] }); - this.addWidget(this.getName() + i, td); + this.addWidget(this.getName() + "-" + i, td); } else { - td = this.getWidgetByName(this.getName() + i); + td = this.getWidgetByName(this.getName() + "-" + i); td.element.attr("width", width); } td.element.css({"max-width": o.columnSize[i]}); diff --git a/src/core/wrapper/layout/adapt/adapt.horizontal.js b/src/core/wrapper/layout/adapt/adapt.horizontal.js index 9e2a9ad4f..bdce5b6ed 100644 --- a/src/core/wrapper/layout/adapt/adapt.horizontal.js +++ b/src/core/wrapper/layout/adapt/adapt.horizontal.js @@ -36,7 +36,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var td; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var w = BI.createWidget(item); w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); td = BI.createWidget({ @@ -47,9 +47,9 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { }, items: [w] }); - this.addWidget(this.getName() + i, td); + this.addWidget(this.getName() + "-" + i, td); } else { - td = this.getWidgetByName(this.getName() + i); + td = this.getWidgetByName(this.getName() + "-" + i); td.element.attr("width", width); } td.element.css({"max-width": o.columnSize[i] + "px"}); diff --git a/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js b/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js index a5a5dbab8..aa7454936 100644 --- a/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js +++ b/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js @@ -70,6 +70,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.LeftRightVerticalAdaptLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.left_right_vertical_adapt', BI.LeftRightVerticalAdaptLayout); diff --git a/src/core/wrapper/layout/adapt/adapt.vertical.js b/src/core/wrapper/layout/adapt/adapt.vertical.js index 98ab83db5..429d234f2 100644 --- a/src/core/wrapper/layout/adapt/adapt.vertical.js +++ b/src/core/wrapper/layout/adapt/adapt.vertical.js @@ -35,7 +35,7 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var td; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var w = BI.createWidget(item); w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); td = BI.createWidget({ @@ -46,9 +46,9 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { }, items: [w] }); - this.addWidget(this.getName() + i, td); + this.addWidget(this.getName() + "-" + i, td); } else { - td = this.getWidgetByName(this.getName() + i); + td = this.getWidgetByName(this.getName() + "-" + i); td.element.attr("width", width); } diff --git a/src/core/wrapper/layout/adapt/inline.center.js b/src/core/wrapper/layout/adapt/inline.center.js index cb1e5acd2..72c94a5ad 100644 --- a/src/core/wrapper/layout/adapt/inline.center.js +++ b/src/core/wrapper/layout/adapt/inline.center.js @@ -29,7 +29,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { _addElement: function (i, item, length) { var o = this.options; - if (!this.hasWidget(this.getName() + i)) { + if (!this.hasWidget(this.getName() + "-" + i)) { var t = BI.createWidget(item); t.element.css({ "position": "relative" @@ -38,9 +38,9 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { type: "bi.horizontal_auto", items: [t] }); - this.addWidget(this.getName() + i, w); + this.addWidget(this.getName() + "-" + i, w); } else { - var w = this.getWidgetByName(this.getName() + i); + var w = this.getWidgetByName(this.getName() + "-" + i); } w.element.css({ "position": "relative",