diff --git a/Gruntfile.js b/Gruntfile.js index d3707821b..6e86d9a9a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -58,6 +58,11 @@ module.exports = function (grunt) { baseCss: { src: ['src/css/base/**/*.css'], dest: 'dist/base.css' + }, + + demoJs: { + src: ['demo/**/*.js'], + dest: 'demo.js' } }, @@ -106,7 +111,7 @@ module.exports = function (grunt) { }, watch: { scripts: { - files: ['src/**/*.js'], + files: ['src/**/*.js', 'demo/**/*.js'], tasks: ['concat'], options: { spanw: true, diff --git a/demo.css b/demo.css new file mode 100644 index 000000000..818a06a82 --- /dev/null +++ b/demo.css @@ -0,0 +1,3 @@ +.bg1{ + background: #00B83F; +} \ No newline at end of file diff --git a/index.html b/demo.html similarity index 79% rename from index.html rename to demo.html index ab42c3371..200ef7694 100644 --- a/index.html +++ b/demo.html @@ -8,11 +8,13 @@ href="./dist/core.css"/> + - +
diff --git a/demo.js b/demo.js new file mode 100644 index 000000000..3bae55ecd --- /dev/null +++ b/demo.js @@ -0,0 +1,104 @@ +$(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", + ref: function (_ref) { + console.log(_ref); + ref = _ref; + }, + element: '#wrapper' + }) + // ref.destroy(); +}) \ No newline at end of file diff --git a/demo/app.js b/demo/app.js new file mode 100644 index 000000000..3bae55ecd --- /dev/null +++ b/demo/app.js @@ -0,0 +1,104 @@ +$(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", + ref: function (_ref) { + console.log(_ref); + ref = _ref; + }, + element: '#wrapper' + }) + // ref.destroy(); +}) \ No newline at end of file diff --git a/dist/base.js b/dist/base.js index e034c9faf..1ea6ce2d4 100644 --- a/dist/base.js +++ b/dist/base.js @@ -20537,7 +20537,7 @@ BI.Pane = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, items: [this._tipText], bgap: 25 }); @@ -20570,7 +20570,7 @@ BI.Pane = BI.inherit(BI.Widget, { this._loading.element.css("zIndex", 1); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this._loading, left: 0, @@ -20932,7 +20932,7 @@ BI.BasicButton = BI.inherit(BI.Single, { self.$mask.invisible(); BI.createWidget({ type: "bi.absolute", - element: self.element, + element: self, items: [{ el: self.$mask, left: 0, @@ -21366,94 +21366,6 @@ BI.Canvas = BI.inherit(BI.Widget, { } }); $.shortcut("bi.canvas", BI.Canvas);/** - * 图表控件 - * @class BI.Chart - * @extends BI.Widget - */ -BI.Chart = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.Chart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-chart" - }) - }, - - _init: function () { - BI.Chart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.isInit = false; - this.isSetOptions = false; - this.wants2SetData = false; - var width = 0; - var height = 0; - - this._resizer = BI.debounce(function () { - if (self.element.is(":visible") && self.vanCharts) { - self.vanCharts.resize(); - } - }, 30); - BI.Resizers.add(this.getName(), function (e) { - if (BI.isWindow(e.target) && self.element.is(":visible")) { - var newW = self.element.width(), newH = self.element.height(); - if (newW > 0 && newH > 0 && (width !== newW || height !== newH)) { - self._resizer(); - width = newW; - height = newH; - } - } - }); - }, - - _setData: function () { - this.vanCharts && this.vanCharts.setData(this.config); - }, - - resize: function () { - if (this.element.is(":visible") && this.isSetOptions === true) { - this._resizer(); - } - }, - - magnify: function () { - this.vanCharts && this.vanCharts.charts[0] && this.vanCharts.charts[0].refreshRestore(); - }, - - populate: function (items, options) { - var self = this, o = this.options; - o.items = items; - this.config = options || {}; - this.config.series = o.items; - - var setOptions = function () { - self.vanCharts.setOptions(self.config); - self.isSetOptions = true; - //if (self.wants2SetData === true) { - // self._setData(); - //} - }; - var init = function () { - if (self.element.is(":visible")) { - self.vanCharts = VanCharts.init(self.element[0]); - BI.nextTick(setOptions); - self.isInit = true; - } - }; - - if (this.isInit === false) { - BI.nextTick(init); - } - - if (this.element.is(":visible") && this.isSetOptions === true) { - this._setData(); - this.wants2SetData = null; - } else { - this.wants2SetData = true; - } - } -}); -BI.Chart.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut('bi.chart', BI.Chart);/** * Collection * * Created by GUY on 2016/1/15. @@ -21503,7 +21415,7 @@ BI.Collection = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, scrollable: o.overflowX === true && o.overflowY === true, scrolly: o.overflowX === false && o.overflowY === true, scrollx: o.overflowX === true && o.overflowY === false, @@ -21513,11 +21425,13 @@ BI.Collection = BI.inherit(BI.Widget, { this._calculateSizeAndPositionData(); this._populate(); } + }, + + mounted: function () { + var o = this.options; if (o.scrollLeft !== 0 || o.scrollTop !== 0) { - BI.nextTick(function () { - self.element.scrollTop(o.scrollTop); - self.element.scrollLeft(o.scrollLeft); - }); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); } }, @@ -21754,9 +21668,8 @@ $.shortcut('bi.collection_view', BI.Collection);/** */ BI.Combo = BI.inherit(BI.Widget, { _defaultConfig: function () { - var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-combo", + return BI.extend(BI.Combo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-combo", trigger: "click", toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right @@ -21812,7 +21725,7 @@ BI.Combo = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.combo} ] @@ -21909,7 +21822,7 @@ BI.Combo = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.popupView} ] @@ -22187,7 +22100,7 @@ BI.Expander = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.expander} ] @@ -22287,7 +22200,7 @@ BI.Expander = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.popupView} ] @@ -22579,7 +22492,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.buttons = this._btnsCreator.apply(this, arguments); var items = this._packageItems(items, this._packageBtns(this.buttons)); - this.layouts = BI.createWidget(BI.extend({element: this.element}, this._packageLayout(items))); + this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); }, setEnable: function (b) { @@ -22779,7 +22692,7 @@ BI.ComboGroup = BI.inherit(BI.Widget, { }) this.combo = BI.createWidget({ type: "bi.combo", - element: this.element, + element: this, height: o.height, trigger: o.trigger, direction: o.direction, @@ -22918,7 +22831,7 @@ BI.Loader = BI.inherit(BI.Widget, { } BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ scrolly: true }, o.logic, { @@ -23114,7 +23027,7 @@ BI.Navigation = BI.inherit(BI.Widget, { type: "bi.card" }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout) })))); @@ -23270,7 +23183,7 @@ BI.Searcher = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, lgap: o.lgap, rgap: o.rgap, tgap: o.tgap, @@ -23570,7 +23483,7 @@ BI.Switcher = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.switcher} ] @@ -23658,7 +23571,7 @@ BI.Switcher = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.popupView} ] @@ -23823,7 +23736,7 @@ BI.Tab = BI.inherit(BI.Widget, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout) })))); @@ -24199,7 +24112,7 @@ BI.ButtonMap = BI.inherit(BI.ButtonTree, { this.empty(); var packages = this._packageItems(items, this._packageBtns(array)); - BI.createWidget(BI.extend({element: this.element}, this._packageLayout(packages))); + BI.createWidget(BI.extend({element: this}, this._packageLayout(packages))); }, getIndexByValue: function (value) { @@ -24229,7 +24142,7 @@ BI.EL = BI.inherit(BI.Widget, { this.ele = BI.createWidget(o.el); BI.createWidget(o.layout, { type: "bi.adaptive", - element: this.element, + element: this, items: [this.ele] }); this.ele.on(BI.Controller.EVENT_CHANGE, function () { @@ -24342,7 +24255,7 @@ $.shortcut("bi.farbtastic", BI.Farbtastic);; }); BI.createWidget({ type: "bi.absolute", - element: self.element, + element: self, items: [{ el: self.watermark, left: 0, @@ -24734,7 +24647,7 @@ BI.Grid = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, scrollable: o.overflowX === true && o.overflowY === true, scrolly: o.overflowX === false && o.overflowY === true, scrollx: o.overflowX === true && o.overflowY === false, @@ -24743,11 +24656,13 @@ BI.Grid = BI.inherit(BI.Widget, { if (o.items.length > 0) { this._populate(); } + }, + + mounted: function () { + var o = this.options; if (o.scrollLeft !== 0 || o.scrollTop !== 0) { - BI.nextTick(function () { - self.element.scrollTop(o.scrollTop); - self.element.scrollLeft(o.scrollLeft); - }); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); } }, @@ -25021,7 +24936,7 @@ BI.FloatBox = BI.inherit(BI.Widget, { this._south = BI.createWidget(); BI.createWidget({ type: 'bi.border', - element: this.element, + element: this, items: { 'north': { el: { @@ -25196,7 +25111,7 @@ BI.PopupView = BI.inherit(BI.Widget, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { scrolly: false, lgap: o.lgap, @@ -25325,7 +25240,7 @@ BI.ScrollView = BI.inherit(BI.Widget, { }) BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, scrolly: false, items: [this.scroll] }) @@ -25339,7 +25254,7 @@ BI.ScrollView = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.dropdown, left: 0, @@ -25506,7 +25421,7 @@ BI.SearcherView = BI.inherit(BI.Pane, { BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, items: [this.matcher, this.spliter, this.searcher] }); }, @@ -25733,7 +25648,7 @@ BI.Pager = BI.inherit(BI.Widget, { this.button_group = BI.createWidget({ type: "bi.button_group", - element: this.element, + element: this, items: BI.createItems(view, { cls: "page-item", height: 23, @@ -25857,7 +25772,7 @@ BI.A = BI.inherit(BI.Text, { BI.A.superclass._init.apply(this, arguments); if (o.el) { BI.createWidget(o.el, { - element: this.element + element: this }); } } @@ -25910,7 +25825,7 @@ BI.LoadingBar = BI.inherit(BI.Single, { }) this.cardLayout = BI.createWidget({ type: "bi.card", - element: this.element, + element: this, items: [{ el: loaded, cardName: "loaded" @@ -25976,12 +25891,12 @@ BI.IconButton = BI.inherit(BI.BasicButton, { this.element.css("lineHeight", o.height + "px"); BI.createWidget({ type: "bi.default", - element: this.element, + element: this, items: [this.icon] }) } else { BI.createWidget({ - element: this.element, + element: this, type: 'bi.center_adapt', items: [this.icon] }); @@ -26027,13 +25942,13 @@ BI.ImageButton = BI.inherit(BI.BasicButton, { if (BI.isNumber(o.iconWidth) || BI.isNumber(o.iconHeight)) { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, items: [this.image] }) } else { BI.createWidget({ type: "bi.adaptive", - element: this.element, + element: this, items: [this.image], scrollable: false }) @@ -26140,7 +26055,7 @@ $.shortcut("bi.image_button", BI.ImageButton);(function ($) { BI.createWidget({ type: "bi.horizontal_auto", cls: "button-" + o.level + " " + o.iconClass, - element: this.element, + element: this, hgap: o.hgap, vgap: o.vgap, tgap: o.tgap, @@ -26167,7 +26082,7 @@ $.shortcut("bi.image_button", BI.ImageButton);(function ($) { bgap: o.bgap, lgap: o.lgap, rgap: o.rgap, - element: this.element, + element: this, text: o.text, value: o.value }); @@ -26253,7 +26168,7 @@ BI.TextButton = BI.inherit(BI.BasicButton, { var o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: o.textAlign, whiteSpace: o.whiteSpace, textWidth: o.textWidth, @@ -26369,7 +26284,7 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.center_adapt", @@ -26390,7 +26305,7 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", { type: "bi.layout", @@ -26506,7 +26421,7 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", blank, this.icon, this.text) })))); @@ -26618,7 +26533,7 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.center_adapt", @@ -26639,7 +26554,7 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank) })))); @@ -26744,7 +26659,7 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.icon, this.text) })))); @@ -26850,7 +26765,7 @@ BI.TextIconItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon) })))); @@ -26925,7 +26840,7 @@ BI.TextItem = BI.inherit(BI.BasicButton, { var o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: o.textAlign, whiteSpace: o.whiteSpace, textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight, @@ -27045,7 +26960,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { }) BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.center_adapt", @@ -27066,7 +26981,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank) })))); @@ -27162,7 +27077,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon, this.text) })))); @@ -27257,7 +27172,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon) })))); @@ -27323,7 +27238,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { var o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: o.textAlign, whiteSpace: o.whiteSpace, textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight, @@ -27436,7 +27351,7 @@ BI.CodeEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: watermark, top: 0, @@ -27613,7 +27528,7 @@ BI.Editor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: items }); this.editor.on(BI.Controller.EVENT_CHANGE, function () { @@ -27899,7 +27814,7 @@ BI.MultifileEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.adaptive", @@ -27966,7 +27881,7 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { this.content.element.css({"resize": "none"}); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.adaptive", @@ -29129,7 +29044,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)), @@ -29147,7 +29062,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.center_adapt", scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -29167,7 +29082,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [this.text] }); return; @@ -29179,7 +29094,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -29194,7 +29109,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.center_adapt", scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)) }] @@ -29206,7 +29121,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.center_adapt", scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -29226,7 +29141,7 @@ BI.Label = BI.inherit(BI.Single, { tgap: o.tgap, bgap: o.bgap, scrollable: true, - element: this.element, + element: this, items: [this.text] }); return; @@ -29240,7 +29155,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -29263,7 +29178,7 @@ BI.Label = BI.inherit(BI.Single, { "line-height": o.height + "px" }); this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", @@ -29284,13 +29199,13 @@ BI.Label = BI.inherit(BI.Single, { this.text = BI.createWidget(json); BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, items: [this.text] }); return; } this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", @@ -29309,7 +29224,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)), @@ -29333,7 +29248,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -29353,7 +29268,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [this.text] }); return; @@ -29365,7 +29280,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -29386,7 +29301,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)) }] @@ -29404,7 +29319,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -29424,7 +29339,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [this.text] }); return; @@ -29438,7 +29353,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -29461,7 +29376,7 @@ BI.Label = BI.inherit(BI.Single, { "line-height": o.height + "px" }); this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", @@ -29482,13 +29397,13 @@ BI.Label = BI.inherit(BI.Single, { this.text = BI.createWidget(json); BI.createWidget({ type: "bi.vertical_adapt", - element: this.element, + element: this, items: [this.text] }); return; } this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", @@ -29743,7 +29658,7 @@ BI.TableCell = BI.inherit(BI.Widget, { BI.TableCell.superclass._init.apply(this, arguments); BI.createWidget({ type: "bi.label", - element: this.element, + element: this, whiteSpace: "nowrap", textAlign: this.options.textAlign, height: this.options.height, @@ -29786,7 +29701,7 @@ BI.CollectionTableCell = BI.inherit(BI.Widget, { })); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.cell, left: 0, @@ -29913,7 +29828,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); this.contextLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topLeft, top: 0, @@ -29958,7 +29873,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); this.scrollBarLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topScrollbar, right: 0, @@ -30529,7 +30444,7 @@ BI.GridTableCell = BI.inherit(BI.Widget, { })); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.cell, left: 0, @@ -30658,7 +30573,7 @@ BI.GridTable = BI.inherit(BI.Widget, { }); this.contextLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topLeft, top: 0, @@ -30703,7 +30618,7 @@ BI.GridTable = BI.inherit(BI.Widget, { }); this.scrollBarLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topScrollbar, right: 0, @@ -31229,7 +31144,7 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { }); this.contextLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.face, left: 0, @@ -31551,7 +31466,7 @@ BI.GridTableHorizontalScrollbar = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.absolute", cls: "horizontal-scrollbar", - element: this.element, + element: this, width: o.size, height: BI.GridTableScrollbar.SIZE, items: [{ @@ -31613,7 +31528,7 @@ BI.TableHeaderCell = BI.inherit(BI.Widget, { BI.TableHeaderCell.superclass._init.apply(this, arguments); BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "center", height: this.options.height, text: this.options.text, @@ -32067,7 +31982,7 @@ BI.Table = BI.inherit(BI.Widget, { regionColumnSize = isRight ? [0, 'fill'] : ['fill', 0]; } this.partitions = BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("table", BI.extend({}, o.logic, { rows: 2, columns: 2, @@ -32675,7 +32590,7 @@ BI.Table = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.adaptive", cls: "bottom-right", - element: this.element, + element: this, scrollable: false, items: [this.scrollBottomRight] }); @@ -33818,7 +33733,7 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.cell, left: 0, @@ -33889,7 +33804,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { this.regionResizerHandler = this._createResizerHandler(); this.table = BI.createWidget(o.el, { type: "bi.grid_table", - element: this.element, + element: this, width: o.width, height: o.height, headerRowSize: o.headerRowSize, @@ -33911,7 +33826,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.regionResizerHandler, left: 0, @@ -34224,7 +34139,7 @@ BI.TreeView = BI.inherit(BI.Pane, { type: "bi.vertical", scrollable: true, scrolly: false, - element: this.element, + element: this, items: [this.container, this.tip] }); @@ -35176,7 +35091,7 @@ BI.CustomTree = BI.inherit(BI.Widget, { initTree: function (nodes) { var self = this, o = this.options; this.tree = BI.createWidget(o.el, { - element: this.element, + element: this, items: this._formatItems(nodes), itemsCreator: function (op, callback) { o.itemsCreator.apply(this, [op, function (items) { diff --git a/dist/case.js b/dist/case.js index 506b0606a..83c882d11 100644 --- a/dist/case.js +++ b/dist/case.js @@ -35,7 +35,7 @@ BI.IconChangeButton = BI.inherit(BI.Single, { var self = this, o = this.options; this.button = BI.createWidget({ type: "bi.icon_button", - element: this.element, + element: this, cls: o.iconClass, height: o.height, iconWidth: o.iconWidth, @@ -187,7 +187,7 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", { type: "bi.center_adapt", @@ -236,7 +236,7 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { var self = this, o = this.options; this.text = BI.createWidget({ type: "bi.icon_text_item", - element: this.element, + element: this, cls: o.iconClass, once: o.once, selected: o.selected, @@ -292,7 +292,7 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { var self = this, o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "left", whiteSpace: "nowrap", textHeight: o.height, @@ -365,7 +365,7 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", { type: "bi.center_adapt", @@ -446,7 +446,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -527,7 +527,7 @@ BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -628,7 +628,7 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, { el: icon }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -708,7 +708,7 @@ BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -788,7 +788,7 @@ BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -866,7 +866,7 @@ $.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArrow items.push(this.node); BI.createWidget({ type: "bi.td", - element: this.element, + element: this, columnSize: BI.makeArray(o.layer, 13), items: [items] }) @@ -953,7 +953,7 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -1032,7 +1032,7 @@ BI.TriangleGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -1124,7 +1124,7 @@ BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -1213,7 +1213,7 @@ $.shortcut("bi.first_tree_leaf_item", BI.FirstTreeLeafItem);BI.IconTreeLeafItem el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -1314,7 +1314,7 @@ BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -1417,7 +1417,7 @@ BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); @@ -1511,7 +1511,7 @@ BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { items.push(this.item); BI.createWidget({ type: "bi.td", - element: this.element, + element: this, columnSize: BI.makeArray(o.layer, 13), items: [items] }); @@ -1592,7 +1592,7 @@ BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, { }); BI.createWidget({ type: "bi.htape", - element: this.element, + element: this, items: [{ el: this.text }] @@ -1746,7 +1746,7 @@ BI.Calendar = BI.inherit(BI.Widget, { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("top", title, this.days) @@ -1885,7 +1885,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("top", this.years) @@ -1955,7 +1955,7 @@ BI.ComplexCanvas = BI.inherit(BI.Widget, { var o = this.options; this.canvas = BI.createWidget({ type: "bi.canvas", - element: this.element, + element: this, width: o.width, height: o.height }); @@ -2051,7 +2051,7 @@ BI.CombineChart = BI.inherit(BI.Widget, { //图可配置属性 this.CombineChart = BI.createWidget({ type: "bi.chart", - element: this.element + element: this }); this.CombineChart.on(BI.Chart.EVENT_CHANGE, function (obj) { self.fireEvent(BI.CombineChart.EVENT_CHANGE, obj); @@ -2797,7 +2797,7 @@ BI.ColorPicker = BI.inherit(BI.Widget, { var self = this, o = this.options; this.colors = BI.createWidget({ type: "bi.button_group", - element: this.element, + element: this, items: BI.createItems(o.items || this._items, { type: "bi.color_picker_button", once: false @@ -2887,7 +2887,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.htape", - element: this.element, + element: this, items: [{ el: this.colorShow, width: 'fill' @@ -3052,7 +3052,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.inline", - element: this.element, + element: this, items: [this.textContainer, this.editor] }); BI.Resizers.add(this.getName(), BI.bind(this._adjustInputWidth, this)); @@ -3217,7 +3217,7 @@ BI.ShelterEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -3288,7 +3288,7 @@ BI.ShelterEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); @@ -3471,7 +3471,7 @@ BI.SignEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -3535,7 +3535,7 @@ BI.SignEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); @@ -3724,7 +3724,7 @@ BI.StateEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -3786,7 +3786,7 @@ BI.StateEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); @@ -3979,7 +3979,7 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -4041,7 +4041,7 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); @@ -4192,7 +4192,7 @@ BI.HandStandBranchExpander = BI.inherit(BI.Widget, { this._initExpander(); this._initBranchView(); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, { type: "bi.center_adapt", @@ -4250,7 +4250,7 @@ BI.BranchExpander = BI.inherit(BI.Widget, { this._initExpander(); this._initBranchView(); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.expander, this.branchView) })))); @@ -4585,7 +4585,7 @@ BI.ListPane = BI.inherit(BI.Pane, { this.check(); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({ scrolly: true, lgap: o.lgap, @@ -4710,7 +4710,7 @@ BI.Panel = BI.inherit(BI.Widget,{ var o = this.options; BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("top", this._createTitle() ,this.options.el) @@ -4835,7 +4835,7 @@ BI.SelectList = BI.inherit(BI.Widget, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ scrolly: true }, o.logic, { @@ -4990,7 +4990,7 @@ BI.LazyLoader = BI.inherit(BI.Widget, { var all = o.items.length; this.loader = BI.createWidget({ type: "bi.loader", - element: this.element, + element: this, //下面是button_group的属性 el: o.el, @@ -5123,7 +5123,7 @@ BI.ListLoader = BI.inherit(BI.Widget, { this.button_group = BI.createWidget(o.el, { type: "bi.button_group", - element: this.element, + element: this, chooseType: 0, items: o.items, behaviors: {}, @@ -5151,7 +5151,7 @@ BI.ListLoader = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, items: [this.next] }); @@ -5311,7 +5311,7 @@ BI.SortList = BI.inherit(BI.Widget, { var self = this, o = this.options; this.loader = BI.createWidget({ type: "bi.list_loader", - element: this.element, + element: this, isDefaultInit: o.isDefaultInit, el: o.el, items: this._formatItems(o.items), @@ -5543,7 +5543,7 @@ BI.AllPagger = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, columnSize: [30, "", 36], items: [this.editor, this.allPages, this.pager] }) @@ -5619,7 +5619,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.absolute", scrollable: false, - element: this.element, + element: this, items: [{ el: this.vpager, top: 0, @@ -5906,7 +5906,7 @@ BI.NumberPager = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, columnSize: [20, "", 20, 36], items: [{type: "bi.label", text: "第"}, this.label, {type: "bi.label", text: "页"}, this.pager] }) @@ -6026,7 +6026,7 @@ BI.SkipPager = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, items: [{type: "bi.label", text: "第"}, this.editor, {type: "bi.label", text: "页"}, this.pager] }) }, @@ -6072,7 +6072,7 @@ BI.SegmentButton = BI.inherit(BI.BasicButton, { //} this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, height: opts.height-2, whiteSpace: opts.whiteSpace, text: opts.text, @@ -6113,7 +6113,7 @@ BI.Segment = BI.inherit(BI.Widget, { BI.Segment.superclass._init.apply(this, arguments); var self = this, o = this.options; this.buttonGroup = BI.createWidget({ - element: this.element, + element: this, type: "bi.button_group", items: BI.createItems(o.items, { type: "bi.segment_button", @@ -6287,7 +6287,7 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { var items = this._formatItems(o.items, deep); this.table = BI.createWidget({ type: "bi.table_view", - element: this.element, + element: this, logic: o.logic, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, @@ -6557,7 +6557,7 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { items = BI.DynamicSummaryTreeTable.formatSummaryItems(items, o.crossItems, deep); this.table = BI.createWidget({ type: "bi.table_view", - element: this.element, + element: this, logic: o.logic, isNeedResize: o.isNeedResize, @@ -6859,7 +6859,7 @@ BI.LayerTreeTableCell = BI.inherit(BI.Widget, { var o = this.options; BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "left", whiteSpace: "nowrap", height: o.height, @@ -7007,7 +7007,7 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { var items = this._formatItems(o.items); this.table = BI.createWidget({ type: "bi.table_view", - element: this.element, + element: this, logic: o.logic, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, @@ -7260,7 +7260,7 @@ BI.Tabler = BI.inherit(BI.Widget, { }) BI.createWidget({ type: "bi.vtape", - element: this.element, + element: this, items: [{ el: this.container }, { @@ -7313,7 +7313,7 @@ BI.Bubble = BI.inherit(BI.Tip, { this.element.bind({"click": fn, "mousedown": fn, "mouseup": fn, "mouseover": fn, "mouseenter": fn, "mouseleave": fn, "mousemove": fn}); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: [this["_" + this.options.direction]()] }) }, @@ -7430,7 +7430,7 @@ BI.Toast = BI.inherit(BI.Tip, { this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, text: o.text, height: 30, hgap: this._const.hgap @@ -7479,7 +7479,7 @@ BI.Tooltip = BI.inherit(BI.Tip, { this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "left", whiteSpace: "normal", text: o.text, @@ -7567,7 +7567,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }); BI.createWidget({ type: "bi.htape", - element: this.element, + element: this, items: [{ width: 36, el: { @@ -7655,7 +7655,7 @@ BI.HandStandBranchTree = BI.inherit(BI.Widget, { var self = this, o = this.options; this.branchTree = BI.createWidget({ type: "bi.custom_tree", - element: this.element, + element: this, expander: BI.extend({ type: "bi.handstand_branch_expander", el: {}, @@ -7709,7 +7709,7 @@ BI.BranchTree = BI.inherit(BI.Widget, { var self = this, o = this.options; this.branchTree = BI.createWidget({ type: "bi.custom_tree", - element: this.element, + element: this, expander: BI.extend({ type: "bi.branch_expander", el: {}, @@ -7874,7 +7874,7 @@ BI.LevelTree = BI.inherit(BI.Widget, { this._assertId(nodes); this.tree = BI.createWidget({ type: "bi.custom_tree", - element: this.element, + element: this, expander: BI.extend({ el: {}, popup: { @@ -7957,7 +7957,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, { this.structure = new BI.Tree(); this.tree = BI.createWidget({ type: "bi.tree", - element: this.element, + element: this, itemsCreator: function (op, callback) { var fn = function (items) { callback({ @@ -8106,7 +8106,7 @@ BI.EditorTrigger = BI.inherit(BI.Trigger, { }); BI.createWidget({ - element: this.element, + element: this, type: 'bi.htape', items: [ { @@ -8156,7 +8156,7 @@ BI.IconTrigger = BI.inherit(BI.Trigger, { BI.IconTrigger.superclass._init.apply(this, arguments); this.iconButton = BI.createWidget(o.el, { type: "bi.trigger_icon_button", - element: this.element, + element: this, width: o.width, height: o.height }); @@ -8199,7 +8199,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { }); BI.createWidget({ - element: this.element, + element: this, type: 'bi.htape', items: [ { @@ -8248,7 +8248,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { var self = this, o = this.options; this.trigger = BI.createWidget({ type: "bi.text_trigger", - element: this.element, + element: this, height: o.height }); if (BI.isKey(o.text)) { @@ -8301,7 +8301,7 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, { var self = this, o = this.options; this.trigger = BI.createWidget({ type: "bi.small_text_trigger", - element: this.element, + element: this, height: o.height - 2 }); if (BI.isKey(o.text)) { @@ -8369,7 +8369,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, { }); BI.createWidget({ - element: this.element, + element: this, type: 'bi.htape', items: [ { diff --git a/dist/core.js b/dist/core.js index 5b2004f8b..2907fa248 100644 --- a/dist/core.js +++ b/dist/core.js @@ -14004,15 +14004,28 @@ if (!window.BI) { * @abstract */ BI.OB = function (config) { - this.options = $.extend(this._defaultConfig(), config); + this.options = $.extend(this._defaultConfig(config), config); this._init(); - this._confirmEvents(); }; $.extend(BI.OB.prototype, { - _defaultConfig: function () { - return {}; + props: {}, + init: function () { }, + + _defaultConfig: function (config) { + if (BI.isFunction(this.props)) { + return this.props(config); + } + return this.props; + }, + _init: function () { + this._initListeners(); + this._initRef(); + this.init(); + }, + + _initListeners: function () { var self = this; if (this.options.listeners != null) { $.each(this.options.listeners, function (i, lis) { @@ -14023,22 +14036,22 @@ $.extend(BI.OB.prototype, { } }, - _confirmEvents: function () { - this.fireEvent(BI.Events.AFTERINIT); + //获得一个当前对象的引用 + _initRef: function () { + if (this.options.ref) { + this.options.ref.call(this, this); + } }, _getEvents: function () { if (!$.isArray(this.events)) { this.events = [] } - return this.events; }, /** * 给观察者绑定一个事件 - * e.g. 给填报页面添加一个提交失败事件:contentPane.on(BI.Events.WF, function() {alert("填报失败!");}); - * 给文本框控件p1添加一个初始化后事件:p1.on(BI.Evnets.AFTERINIT, function() {alert("初始化完成!");}); * @param {String} eventName 事件的名字 * @param {Function} fn 事件对应的执行函数 */ @@ -14104,11 +14117,19 @@ $.extend(BI.OB.prototype, { fireEvent: function () { var eventName = arguments[0].toLowerCase(); var fns = this._getEvents()[eventName]; - if ($.isArray(fns)) { - var args = Array.prototype.slice.call(arguments, 1) - for (var i = 0; i < fns.length; i++) { - if (fns[i].apply(this, args) === false) { - return false; + if (BI.isArray(fns)) { + if (BI.isArguments(arguments[1])) { + for (var i = 0; i < fns.length; i++) { + if (fns[i].apply(this, arguments[1]) === false) { + return false; + } + } + } else { + var args = Array.prototype.slice.call(arguments, 1); + for (var i = 0; i < fns.length; i++) { + if (fns[i].apply(this, args) === false) { + return false; + } } } } @@ -14123,42 +14144,54 @@ $.extend(BI.OB.prototype, { */ BI.Widget = BI.inherit(BI.OB, { _defaultConfig: function () { - return BI.extend(BI.Widget.superclass._defaultConfig.apply(this, arguments), { + return BI.extend({ tagName: "div", - attributes: {}, - data: {}, + attributes: null, + data: null, tag: null, - widgetName: "", disabled: false, invisible: false, invalid: false, baseCls: "", - extraCls: "", cls: "" - }) + }, BI.Widget.superclass._defaultConfig.call(this)) }, - _initOpts: function () { + //生命周期函数 + beforeCreated: function () { + + }, + + created: function () { + + }, + + render: function () { + + }, + + beforeMounted: function () { + + }, + + mounted: function () { + + }, + + destroyed: function () { }, _init: function () { - var o = this.options; - this._initOpts() - BI.isWidget(o.element) && (o.element = o.element.element); - BI.isString(o.element) && (o.element = $(o.element)); - o.renderEl || (o.renderEl = o.element); - o.element || (o.element = o.renderEl); - o.element || (o.renderEl = o.element = $(document.createElement(o.tagName))); - this.widgetName = o.widgetName || (o.widgetName = BI.uniqueId("widget")); + BI.Widget.superclass._init.apply(this, arguments); + this.beforeCreated(); this._initRoot(); this._initElementWidth(); this._initElementHeight(); this._initVisualEffects(); - o.extraCls && this.element.addClass(o.extraCls); - o.cls && this.element.addClass(o.cls); - this.element.attr(o.attributes).data(o.data); - this.widgets = {};//保存子组件 + this._initState(); + this._initElement(); + this.created(); }, /** @@ -14166,14 +14199,31 @@ BI.Widget = BI.inherit(BI.OB, { * @private */ _initRoot: function () { - if (this.options.renderEl != null) { - this.element = $(this.options.renderEl); + var o = this.options; + this.widgetName = o.widgetName || BI.uniqueId("widget"); + if (BI.isWidget(o.element)) { + this._parent = o.element; + this._parent.addWidget(this.widgetName, this); + this.element = this.options.element.element; + } else if (BI.isString(o.element)) { + this.element = $(o.element); + this._isRoot = true; } else { - this.element = this._defaultRoot(); + this.element = $(document.createElement(o.tagName)); } - if (this.options.baseCls) { - this.element.addClass(this.options.baseCls); + if (o.baseCls) { + this.element.addClass(o.baseCls); } + if (o.cls) { + this.element.addClass(o.cls); + } + if (o.attributes) { + this.element.attr(o.attributes); + } + if (o.data) { + this.element.data(o.data); + } + this._children = {}; }, _initElementWidth: function () { @@ -14191,42 +14241,90 @@ BI.Widget = BI.inherit(BI.OB, { }, _initVisualEffects: function () { - if (this.options.diabled || this.options.invalid) { - BI.nextTick(BI.bind(function () { - if (this.options.disabled) { - this.setEnable(false); - } - if (this.options.invalid) { - this.setValid(false); - } - }, this)); + var o = this.options; + if (o.invisible) { + this.element.hide(); + } + if (o.disabled) { + this.element.addClass("base-disabled disabled"); } + if (o.invalid) { + this.element.addClass("base-invalid invalid"); + } + }, - if (this.options.invisible) { - this.setVisible(false); + _initState: function () { + this._isMounted = false; + }, + + _initElement: function () { + var self = this; + var els = this.render(); + if (BI.isPlainObject(els)) { + els = [els]; + } + if (BI.isArray(els)) { + BI.each(els, function (i, el) { + BI.createWidget(el, { + element: self + }) + }) + } + if (this._isRoot === true) { + this._mount(); } }, - fireEvent: function () { - var eventName = arguments[0].toLowerCase(); - var fns = this._getEvents()[eventName]; - if (BI.isArray(fns)) { - if (BI.isArguments(arguments[1])) { - for (var i = 0; i < fns.length; i++) { - if (fns[i].apply(this, arguments[1]) === false) { - return false; - } - } - } else { - var args = Array.prototype.slice.call(arguments, 1); - for (var i = 0; i < fns.length; i++) { - if (fns[i].apply(this, args) === false) { - return false; - } - } + _setParent: function (parent) { + this._parent = parent; + }, + + _mount: function () { + var self = this; + var isMounted = this._isMounted; + if (isMounted) { + return; + } + if (this._isRoot === true) { + isMounted = true; + } else if (this._parent && this._parent._isMounted === true) { + isMounted = true; + } + if (!isMounted) { + return; + } + this.beforeMounted(); + this._isMounted = true; + this._mountChildren(); + BI.each(this._children, function (i, widget) { + widget._mount(); + }); + this.mounted(); + }, + + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; } + }); + if (hasChild === true) { + this.element.append(frag); } - return true; + }, + + _unMount: function () { + BI.each(this._children, function (i, widget) { + widget._unMount(); + }); + this._children = []; + this._parent = null; + this._isMounted = false; + this.destroyed(); }, setWidth: function (w) { @@ -14239,16 +14337,7 @@ BI.Widget = BI.inherit(BI.OB, { this._initElementHeight(); }, - setElement: function (widget) { - if (widget == this) { - return; - } - this.element = BI.isWidget(widget) ? widget.element : $(widget); - return this; - }, - setEnable: function (enable) { - BI.assert(enable, [true, false]); if (enable === true) { this.options.disabled = false; this.element.removeClass("base-disabled disabled"); @@ -14259,7 +14348,6 @@ BI.Widget = BI.inherit(BI.OB, { }, setVisible: function (visible) { - // BI.assert(visible, [true, false]); if (visible === true) { this.options.invisible = false; this.element.show(); @@ -14267,11 +14355,9 @@ BI.Widget = BI.inherit(BI.OB, { this.options.invisible = true; this.element.hide(); } - this.fireEvent(BI.Events.VIEW, visible); }, setValid: function (valid) { - // BI.assert(valid, [true, false]); this.options.invalid = !valid; if (valid === true) { this.element.removeClass("base-invalid invalid"); @@ -14292,32 +14378,21 @@ BI.Widget = BI.inherit(BI.OB, { return !this.options.invalid; }, - valid: function () { - this.setValid(true); - }, - - invalid: function () { - this.setValid(false); - }, - addWidget: function (name, widget) { var self = this; if (name instanceof BI.Widget) { widget = name; name = widget.getName(); } - if (!BI.isKey(name)) { - throw new Error("name cannot be null"); - } - name = BI.isKey(name) ? (name + "") : ""; - name = name || widget.getName() || BI.UUID(); - if (this.widgets[name]) { + name = name || widget.getName() || BI.uniqueId("widget"); + if (this._children[name]) { throw new Error("name has already been existed"); } + widget._setParent(this); widget.on(BI.Events.DESTROY, function () { - delete self.widgets[name] + delete self._children[name] }); - return (this.widgets[name] = widget); + return (this._children[name] = widget); }, getWidgetByName: function (name) { @@ -14326,7 +14401,7 @@ BI.Widget = BI.inherit(BI.OB, { } name = name + ""; var widget = void 0, other = {}; - BI.any(this.widgets, function (i, wi) { + BI.any(this._children, function (i, wi) { if (i === name) { widget = wi; return true; @@ -14341,26 +14416,16 @@ BI.Widget = BI.inherit(BI.OB, { return widget; }, - hasWidget: function (name) { - return this.widgets[name] != null; - }, - - getWidgets: function () { - return this.widgets; + removeWidget: function (name) { + delete this._children[name]; }, - getValidWidgets: function () { - var widgets = []; - BI.each(this.widgets, function (i, wi) { - if (wi.isValid()) { - widgets.push(wi); - } - }); - return widgets; + hasWidget: function (name) { + return this._children[name] != null; }, getName: function () { - return this.options.widgetName; + return this.widgetName; }, setTag: function (tag) { @@ -14390,12 +14455,8 @@ BI.Widget = BI.inherit(BI.OB, { }, - setValue: function (value, shouldFireEvent) { - - }, + setValue: function (value) { - getType: function () { - return this.options.type; }, isEnabled: function () { @@ -14406,58 +14467,10 @@ BI.Widget = BI.inherit(BI.OB, { return !this.options.invisible; }, - render: function () { - this.element.append(this.hang()); - return this; - }, - - hang: function () { - return BI.DOM.hang(BI.trans2Element(this.widgets)); - }, - - clear: function () { - this.hang(); - this.element.empty(); - this.widgets = {}; - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); - }); - this.element.empty(); - this.widgets = {}; - }, - destroy: function () { - this.empty(); - this.element.each(function () { - $(this).remove(); - if (BI.isIE()) { - this.outerHTML = ''; - } - }); + this._unMount(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); - }, - - _defaultRoot: function () { - return $("
"); - }, - - disable: function () { - this.setEnable(false); - }, - - enable: function () { - this.setEnable(true); - }, - - invisible: function () { - this.setVisible(false); - }, - - visible: function () { - this.setVisible(true); } });BI.Model = BI.inherit(BI.M, { _defaultConfig: function () { @@ -15046,7 +15059,7 @@ BI.View = BI.inherit(BI.V, { _vessel: function () { this._cardLayouts = {}; this._cardLayouts[this.getName()] = new BI.CardLayout({ - element: this.element + element: this }); var vessel = BI.createWidget(); this._cardLayouts[this.getName()].addCardByName(this.getName(), vessel); @@ -15438,7 +15451,7 @@ BI.View = BI.inherit(BI.V, { });(function ($) { var kv = {}; // alex:键(编辑器简称,如text)值(也是一个字符串,如FR.TextEditor)对 - $.shortcut = function (xtype, cls) { + $.shortcut = BI.shortcut = function (xtype, cls) { if (kv[xtype] != null) { throw ("shortcut:[" + xtype + "] has been registed"); } @@ -19052,24 +19065,20 @@ BI.Behavior = BI.inherit(BI.OB, { * @cfg {Boolean} [options.scrolly=false] 子组件超出容器边界之后是否会出现纵向滚动条 */ BI.Layout = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.Layout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return { scrollable: null, //true, false, null scrollx: false, //true, false scrolly: false, //true, false items: [] - }); + }; }, - _init: function () { - BI.Layout.superclass._init.apply(this, arguments); + + created: function () { this._init4Margin(); this._init4Scroll(); }, - /** - * 初始化布局与外层容器的边间距 - * @private - */ _init4Margin: function () { if (this.options.top) { this.element.css('top', this.options.top); @@ -19085,10 +19094,6 @@ BI.Layout = BI.inherit(BI.Widget, { } }, - /** - * 初始化布局的滚动形态 - * @private - */ _init4Scroll: function () { switch (this.options.scrollable) { case true: @@ -19137,12 +19142,8 @@ BI.Layout = BI.inherit(BI.Widget, { populate: function (items) { var self = this; - this.reset(items); - this.stroke(items); - }, - - reset: function (items) { this.options.items = items || []; + this.stroke(items); }, resize: function () { @@ -19155,6 +19156,7 @@ BI.Layout = BI.inherit(BI.Widget, { */ addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); w.element.appendTo(this.element); return w; @@ -19167,40 +19169,26 @@ BI.Layout = BI.inherit(BI.Widget, { }) }, - getValue: function (name) { - if (name) { - return this.getWidgetByName(name).getValue(); - } + getValue: function () { var value = []; - BI.each(this.widgets, function (i, wi) { - var v = wi.getValue(name); + BI.each(this._children, function (i, wi) { + var v = wi.getValue(); v = BI.isArray(v) ? v : [v]; value = value.concat(v); }); return value; }, - setValue: function (v, name) { - if (name) { - return this.getWidgetByName(name).setValue(v); - } - BI.each(this.widgets, function (i, wi) { + setValue: function (v) { + BI.each(this._children, function (i, wi) { wi.setValue(v); }) }, - setText: function (v, name) { - if (name) { - return this.getWidgetByName(name).setText(v); - } - BI.each(this.widgets, function (i, wi) { + setText: function (v) { + BI.each(this._children, function (i, wi) { wi.setText(v); }) - }, - - empty: function () { - BI.Layout.superclass.empty.apply(this, arguments); - this.reset(); } }); $.shortcut('bi.layout', BI.Layout);/** @@ -23979,8 +23967,8 @@ _.extend(BI, { * @extends BI.Layout */ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-center-layout", hgap: 0, lgap: 0, @@ -23991,8 +23979,8 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.AbsoluteCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24016,7 +24004,7 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteCenterLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute_center_adapt', BI.AbsoluteCenterLayout);/** @@ -24025,8 +24013,8 @@ $.shortcut('bi.absolute_center_adapt', BI.AbsoluteCenterLayout);/** * @extends BI.Layout */ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-horizontal-layout", hgap: 0, lgap: 0, @@ -24037,8 +24025,8 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.AbsoluteHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteHorizontalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24066,7 +24054,7 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteHorizontalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute_horizontal_adapt', BI.AbsoluteHorizontalLayout);/** @@ -24075,8 +24063,8 @@ $.shortcut('bi.absolute_horizontal_adapt', BI.AbsoluteHorizontalLayout);/** * @extends BI.Layout */ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteVerticalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteVerticalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-vertical-layout", hgap: 0, lgap: 0, @@ -24087,8 +24075,8 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.AbsoluteVerticalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteVerticalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24118,7 +24106,7 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteVerticalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute_vertical_adapt', BI.AbsoluteVerticalLayout);/** @@ -24127,8 +24115,8 @@ $.shortcut('bi.absolute_vertical_adapt', BI.AbsoluteVerticalLayout);/** * @extends BI.Layout */ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.CenterAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.CenterAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-center-adapt-layout", columnSize: [], hgap: 0, @@ -24139,14 +24127,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.CenterAdaptLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + created: function () { + BI.CenterAdaptLayout.superclass.created.apply(this, arguments); + this.$table = $("").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "width": "100%", "height": "100%", @@ -24154,12 +24137,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -24218,25 +24198,20 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); - } - return this; - }, - - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } }); - this.widgets = {}; - this.tr.empty(); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); + } }, resize: function () { @@ -24245,14 +24220,15 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.tr.element); + w.element.appendTo(this.$tr); return w; }, populate: function (items) { BI.CenterAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.center_adapt', BI.CenterAdaptLayout);/** @@ -24261,8 +24237,8 @@ $.shortcut('bi.center_adapt', BI.CenterAdaptLayout);/** * @extends BI.Layout */ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-adapt-layout", verticalAlign: BI.VerticalAlign.Middle, columnSize: [], @@ -24274,26 +24250,18 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalAdaptLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + created: function () { + BI.HorizontalAdaptLayout.superclass.created.apply(this, arguments); + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "width": "100%", "white-space": "nowrap", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -24351,24 +24319,20 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); - } - }, - - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } }); - this.widgets = {}; - this.tr.empty(); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); + } }, resize: function () { @@ -24377,14 +24341,15 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.tr.element); + w.element.appendTo(this.$tr); return w; }, populate: function (items) { BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal_adapt', BI.HorizontalAdaptLayout);/** @@ -24397,8 +24362,8 @@ $.shortcut('bi.horizontal_adapt', BI.HorizontalAdaptLayout);/** * @extends BI.Layout */ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-left-right-vertical-adapt-layout", items: {}, llgap: 0, @@ -24409,8 +24374,8 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { rhgap: 0 }); }, - _init: function () { - BI.LeftRightVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.LeftRightVerticalAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24436,10 +24401,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { left.element.css("height", "100%"); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: [left] }); - this.addWidget(left); } if ("right" in items) { var right = BI.createWidget({ @@ -24452,10 +24416,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { right.element.css("height", "100%"); BI.createWidget({ type: "bi.right", - element: this.element, + element: this, items: [right] }); - this.addWidget(right); } }, @@ -24467,8 +24430,8 @@ $.shortcut('bi.left_right_vertical_adapt', BI.LeftRightVerticalAdaptLayout); BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-left-vertical-adapt-layout", items: [], lgap: 0, @@ -24476,8 +24439,8 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { hgap: 0 }); }, - _init: function () { - BI.LeftVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.LeftVerticalAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24503,17 +24466,17 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { left.element.css("height", "100%"); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: [left] }); - this.addWidget(left); + this._mount(); } }); $.shortcut('bi.left_vertical_adapt', BI.LeftVerticalAdaptLayout); BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.RightVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.RightVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-right-vertical-adapt-layout", items: [], lgap: 0, @@ -24521,8 +24484,8 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { hgap: 0 }); }, - _init: function () { - BI.RightVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.RightVerticalAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24548,10 +24511,10 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { right.element.css("height", "100%"); BI.createWidget({ type: "bi.right", - element: this.element, + element: this, items: [right] }); - this.addWidget(right); + this._mount(); } }); $.shortcut('bi.right_vertical_adapt', BI.RightVerticalAdaptLayout);/** @@ -24574,24 +24537,16 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { }, _init: function () { BI.VerticalAdaptLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "height": "100%", "white-space": "nowrap", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -24650,24 +24605,28 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); } }, - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); - }); - this.widgets = {}; - this.tr.empty(); + addItem: function (item) { + var w = this._addElement(this.options.items.length, item); + w._mount(); + this.options.items.push(item); + w.element.appendTo(this.$tr); + return w; }, resize: function () { @@ -24676,7 +24635,7 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VerticalAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.vertical_adapt', BI.VerticalAdaptLayout);/** @@ -24685,8 +24644,8 @@ $.shortcut('bi.vertical_adapt', BI.VerticalAdaptLayout);/** * @extends BI.Layout */ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalAutoLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalAutoLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizon-auto-layout", hgap: 0, lgap: 0, @@ -24697,8 +24656,8 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.HorizontalAutoLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HorizontalAutoLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24738,15 +24697,15 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal_auto', BI.HorizontalAutoLayout);/** * 浮动的居中布局 */ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatCenterAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatCenterAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-center-adapt-layout", items: [], hgap: 0, @@ -24757,8 +24716,8 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { rgap: 0 }); }, - _init: function () { - BI.FloatCenterAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatCenterAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24771,9 +24730,21 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { throw new Error("不能添加元素") }, + mounted: function () { + var width = this.left.element.width(), + height = this.left.element.height(); + this.left.element.width(width).height(height).css("float", "none"); + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [this.left] + }); + this.removeWidget(this.container.getName()); + }, + stroke: function (items) { var self = this, o = this.options; - var left = BI.createWidget({ + this.left = BI.createWidget({ type: "bi.vertical", items: items, hgap: o.hgap, @@ -24784,35 +24755,25 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { rgap: o.rgap }); - BI.createWidget({ + this.container = BI.createWidget({ type: "bi.left", - element: this.element, - items: [left] + element: this, + items: [this.left] }); - BI.nextTick(function () { - var width = left.element.width(), - height = left.element.height(); - BI.DOM.hang([left]); - left.element.width(width).height(height).css("float", "none"); - BI.createWidget({ - type: "bi.center_adapt", - element: self.element, - items: [left] - }) - }); }, populate: function (items) { BI.FloatCenterAdaptLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.float_center_adapt', BI.FloatCenterAdaptLayout);/** * 浮动的水平居中布局 */ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-horizontal-adapt-layout", items: [], hgap: 0, @@ -24823,8 +24784,8 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { rgap: 0 }); }, - _init: function () { - BI.FloatHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatHorizontalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -24832,11 +24793,23 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { // console.log("float_horizontal_adapt布局不需要resize"); }, + mounted: function () { + var width = this.left.element.width(), + height = this.left.element.height(); + this.left.element.width(width).height(height).css("float", "none"); + BI.createWidget({ + type: "bi.horizontal_auto", + element: this, + items: [this.left] + }); + this.removeWidget(this.container.getName()); + }, + _addElement: function (i, item) { var self = this, o = this.options; - var left = BI.createWidget({ + this.left = BI.createWidget({ type: "bi.vertical", - items: [item], + items: items, hgap: o.hgap, vgap: o.vgap, tgap: o.tgap, @@ -24845,29 +24818,18 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { rgap: o.rgap }); - BI.createWidget({ + this.container = BI.createWidget({ type: "bi.left", - element: this.element, - items: [left] + element: this, + items: [this.left] }); - BI.nextTick(function () { - var width = left.element.width(), - height = left.element.height(); - BI.DOM.hang([left]); - left.element.width(width).height(height).css("float", "none"); - BI.createWidget({ - type: "bi.horizontal_auto", - element: self.element, - items: [left] - }) - }); - this.addWidget(left); return left; }, populate: function (items) { BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.horizontal_float', BI.FloatHorizontalLayout);/** @@ -24880,8 +24842,8 @@ $.shortcut('bi.horizontal_float', BI.FloatHorizontalLayout);/** * @cfg {Number} [vgap=0] 垂直间隙 */ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.InlineCenterAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.InlineCenterAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-inline-center-adapt-layout", hgap: 0, vgap: 0, @@ -24891,8 +24853,8 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.InlineCenterAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.InlineCenterAdaptLayout.superclass.created.apply(this, arguments); this.element.css({ whiteSpace: "nowrap" }); @@ -24964,7 +24926,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.InlineCenterAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.inline_center_adapt', BI.InlineCenterAdaptLayout);/** @@ -24977,8 +24939,8 @@ $.shortcut('bi.inline_center_adapt', BI.InlineCenterAdaptLayout);/** * @cfg {Number} [vgap=0] 垂直间隙 */ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.InlineVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.InlineVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-inline-vertical-adapt-layout", hgap: 0, vgap: 0, @@ -24988,8 +24950,8 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.InlineVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.InlineVerticalAdaptLayout.superclass.created.apply(this, arguments); this.element.css({ whiteSpace: "nowrap" }); @@ -25035,7 +24997,7 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.InlineVerticalAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.inline_vertical_adapt', BI.InlineVerticalAdaptLayout);/** @@ -25046,13 +25008,13 @@ $.shortcut('bi.inline_vertical_adapt', BI.InlineVerticalAdaptLayout);/** * @extends BI.Layout */ BI.FlexCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-center-layout" }); }, - _init: function () { - BI.FlexCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FlexCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -25069,7 +25031,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexCenterLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.flex_center', BI.FlexCenterLayout);/** @@ -25080,8 +25042,8 @@ $.shortcut('bi.flex_center', BI.FlexCenterLayout);/** * @extends BI.Layout */ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-horizontal-layout", verticalAlign: "middle", columnSize: [], @@ -25094,8 +25056,8 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FlexHorizontalLayout.superclass.created.apply(this, arguments); var o = this.options; this.element.addClass(o.verticalAlign); this.populate(this.options.items); @@ -25134,7 +25096,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexHorizontalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.flex_horizontal', BI.FlexHorizontalLayout);/** @@ -25145,8 +25107,8 @@ $.shortcut('bi.flex_horizontal', BI.FlexHorizontalLayout);/** * @extends BI.Layout */ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexVerticalCenter.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexVerticalCenter.superclass.props.apply(this, arguments), { baseCls: "bi-flex-vertical-center", columnSize: [], hgap: 0, @@ -25157,8 +25119,8 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexVerticalCenter.superclass._init.apply(this, arguments); + created: function () { + BI.FlexVerticalCenter.superclass.created.apply(this, arguments); var o = this.options; this.populate(this.options.items); }, @@ -25196,7 +25158,7 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexVerticalCenter.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.flex_vertical_center', BI.FlexVerticalCenter);/** @@ -25207,28 +25169,45 @@ $.shortcut('bi.flex_vertical_center', BI.FlexVerticalCenter);/** * @extends BI.Layout */ BI.FlexCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-wrapper-center-layout clearfix" }); }, - _init: function () { - BI.FlexCenterLayout.superclass._init.apply(this, arguments); - this.wrapper = $("
").addClass("flex-wrapper-center-layout-wrapper").appendTo(this.element); + created: function () { + BI.FlexCenterLayout.superclass.created.apply(this, arguments); + this.$wrapper = $("
").addClass("flex-wrapper-center-layout-wrapper"); this.populate(this.options.items); }, _addElement: function (i, item) { var o = this.options; var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments); - w.element.css({"position": "relative"}).appendTo(this.wrapper); + w.element.css({"position": "relative"}); return w; }, + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); + } + }, + addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.wrapper); + w.element.appendTo(this.$wrapper); return w; }, @@ -25238,6 +25217,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.flex_wrapper_center', BI.FlexCenterLayout);/** @@ -25248,8 +25228,8 @@ $.shortcut('bi.flex_wrapper_center', BI.FlexCenterLayout);/** * @extends BI.Layout */ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-wrapper-horizontal-layout clearfix", verticalAlign: "middle", columnSize: [], @@ -25262,17 +25242,17 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FlexHorizontalLayout.superclass.created.apply(this, arguments); var o = this.options; - this.wrapper = $("
").addClass("flex-wrapper-horizontal-layout-wrapper " + o.verticalAlign).appendTo(this.element); + this.$wrapper = $("
").addClass("flex-wrapper-horizontal-layout-wrapper " + o.verticalAlign); this.populate(this.options.items); }, _addElement: function (i, item) { var o = this.options; var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments); - w.element.css({"position": "relative"}).appendTo(this.wrapper); + w.element.css({"position": "relative"}); if (o.hgap + o.lgap + (item.lgap || 0) > 0) { w.element.css({ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" @@ -25296,10 +25276,27 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { return w; }, + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); + } + }, + addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.wrapper); + w.element.appendTo(this.$wrapper); return w; }, @@ -25309,6 +25306,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexHorizontalLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.flex_wrapper_horizontal', BI.FlexHorizontalLayout);/** @@ -25319,8 +25317,8 @@ $.shortcut('bi.flex_wrapper_horizontal', BI.FlexHorizontalLayout);/** * @extends BI.Layout */ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexVerticalCenter.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexVerticalCenter.superclass.props.apply(this, arguments), { baseCls: "bi-flex-wrapper-vertical-center clearfix", columnSize: [], hgap: 0, @@ -25331,17 +25329,17 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexVerticalCenter.superclass._init.apply(this, arguments); + created: function () { + BI.FlexVerticalCenter.superclass.created.apply(this, arguments); var o = this.options; - this.wrapper = $("
").addClass("flex-wrapper-vertical-center-wrapper").appendTo(this.element); + this.$wrapper = $("
").addClass("flex-wrapper-vertical-center-wrapper"); this.populate(this.options.items); }, _addElement: function (i, item) { var o = this.options; var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments); - w.element.css({"position": "relative"}).appendTo(this.wrapper); + w.element.css({"position": "relative"}); if (o.hgap + o.lgap + (item.lgap || 0) > 0) { w.element.css({ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" @@ -25365,10 +25363,26 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { return w; }, + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); + } + }, + addItem: function (item) { var w = this._addElement(this.options.items.length, item); this.options.items.push(item); - w.element.appendTo(this.wrapper); + w.element.appendTo(this.$wrapper); return w; }, @@ -25378,6 +25392,7 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexVerticalCenter.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.flex_wrapper_vertical_center', BI.FlexVerticalCenter);/** @@ -25386,8 +25401,8 @@ $.shortcut('bi.flex_wrapper_vertical_center', BI.FlexVerticalCenter);/** * @extends BI.Layout */ BI.AbsoluteLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-layout", hgap: null, vgap: null, @@ -25397,8 +25412,8 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, { bgap: null }); }, - _init: function () { - BI.AbsoluteLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -25469,6 +25484,7 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, { }, stroke: function (items) { + this.options.items = items || []; var self = this; BI.each(items, function (i, item) { if (!!item) { @@ -25482,12 +25498,12 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute', BI.AbsoluteLayout);BI.AdaptiveLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AdaptiveLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AdaptiveLayout.superclass.props.apply(this, arguments), { baseCls: "bi-adaptive-layout", hgap: null, vgap: null, @@ -25497,8 +25513,8 @@ $.shortcut('bi.absolute', BI.AbsoluteLayout);BI.AdaptiveLayout = BI.inherit(BI.L bgap: null }); }, - _init: function () { - BI.AdaptiveLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AdaptiveLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -25573,7 +25589,7 @@ $.shortcut('bi.absolute', BI.AbsoluteLayout);BI.AdaptiveLayout = BI.inherit(BI.L populate: function (items) { BI.AbsoluteLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.adaptive', BI.AdaptiveLayout);/** @@ -25583,14 +25599,14 @@ $.shortcut('bi.adaptive', BI.AdaptiveLayout);/** * @extends BI.Layout */ BI.BorderLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.BorderLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.BorderLayout.superclass.props.apply(this, arguments), { baseCls: "bi-border-layout", items: {} }); }, - _init: function () { - BI.BorderLayout.superclass._init.apply(this, arguments); + created: function () { + BI.BorderLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -25704,7 +25720,7 @@ BI.BorderLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.BorderLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.border', BI.BorderLayout);/** @@ -25716,14 +25732,14 @@ $.shortcut('bi.border', BI.BorderLayout);/** * @cfg {String} options.defaultShowName 默认展示的子组件名 */ BI.CardLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.CardLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.CardLayout.superclass.props.apply(this, arguments), { baseCls: "bi-card-layout", items: [] }); }, - _init: function () { - BI.CardLayout.superclass._init.apply(this, arguments); + created: function () { + BI.CardLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -25737,7 +25753,6 @@ BI.CardLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this; - this.clear(); this.showIndex = void 0; BI.each(items, function (i, item) { if (!!item) { @@ -25748,14 +25763,14 @@ BI.CardLayout = BI.inherit(BI.Layout, { var w = self.getWidgetByName(self._getCardName(item.cardName)); } w.element.css({"position": "absolute", "top": "0", "right": "0", "bottom": "0", "left": "0"}); - w.invisible(); + w.setVisible(false); } }); }, populate: function (items) { BI.CardLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); this.options.defaultShowName && this.showCardByName(this.options.defaultShowName); }, @@ -25768,7 +25783,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { if (!this.hasWidget(this._getCardName(cardName))) { throw new Error("cardName不存在,无法获取"); } - return this.widgets[this._getCardName(cardName)]; + return this._children[this._getCardName(cardName)]; }, deleteCardByName: function (cardName) { @@ -25780,7 +25795,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { return item.cardName == cardName; }); this.options.items.splice(index, 1); - delete this.widgets[this._getCardName(cardName)]; + delete this._children[this._getCardName(cardName)]; }, addCardByName: function (cardName, cardItem) { @@ -25805,7 +25820,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { } this.showIndex = this._getCardName(name); var flag = false; - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { if (self._getCardName(name) != i) { //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.element.hide(); @@ -25818,7 +25833,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { showLastCard: function () { var self = this; this.showIndex = this.lastShowIndex; - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { if (self.showIndex != i) { el.element.hide(); } else { @@ -25857,14 +25872,14 @@ BI.CardLayout = BI.inherit(BI.Layout, { }, hideAllCard: function () { - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { el.invisible(); }); }, isAllCardHide: function () { var flag = true; - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { if (el.isVisible()) { flag = true; return false; @@ -25872,11 +25887,6 @@ BI.CardLayout = BI.inherit(BI.Layout, { }); return flag; }, - - empty: function () { - BI.CardLayout.superclass.empty.apply(this, arguments); - this.showIndex = void 0; - } }); $.shortcut('bi.card', BI.CardLayout);/** * 默认的布局方式 @@ -25885,8 +25895,8 @@ $.shortcut('bi.card', BI.CardLayout);/** * @extends BI.Layout */ BI.DefaultLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.DefaultLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.DefaultLayout.superclass.props.apply(this, arguments), { hgap: 0, vgap: 0, lgap: 0, @@ -25896,8 +25906,8 @@ BI.DefaultLayout = BI.inherit(BI.Layout, { items: [] }); }, - _init: function () { - BI.DefaultLayout.superclass._init.apply(this, arguments); + created: function () { + BI.DefaultLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -25933,7 +25943,7 @@ BI.DefaultLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.DefaultLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.default', BI.DefaultLayout);/** @@ -25943,8 +25953,8 @@ $.shortcut('bi.default', BI.DefaultLayout);/** * @extends BI.Layout */ BI.DivisionLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.DivisionLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.DivisionLayout.superclass.props.apply(this, arguments), { baseCls: "bi-division-layout", columns: null, rows: null, @@ -25974,8 +25984,8 @@ BI.DivisionLayout = BI.inherit(BI.Layout, { //] }); }, - _init: function () { - BI.DivisionLayout.superclass._init.apply(this, arguments); + created: function () { + BI.DivisionLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -26089,7 +26099,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.DivisionLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.division', BI.DivisionLayout);/** @@ -26102,8 +26112,8 @@ $.shortcut('bi.division', BI.DivisionLayout);/** * @cfg {Number} [vgap=0] 垂直间隙 */ BI.FloatLeftLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatLeftLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatLeftLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-left-layout clearfix", hgap: 0, vgap: 0, @@ -26113,8 +26123,8 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FloatLeftLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatLeftLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -26152,7 +26162,7 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FloatLeftLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.left', BI.FloatLeftLayout); @@ -26167,8 +26177,8 @@ $.shortcut('bi.left', BI.FloatLeftLayout); * @cfg {Number} [vgap=0] 垂直间隙 */ BI.FloatRightLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatRightLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatRightLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-right-layout clearfix", hgap: 0, vgap: 0, @@ -26178,8 +26188,8 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FloatRightLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatRightLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -26217,7 +26227,7 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FloatRightLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.right', BI.FloatRightLayout);/** @@ -26227,8 +26237,8 @@ $.shortcut('bi.right', BI.FloatRightLayout);/** * @extends BI.Layout */ BI.GridLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.GridLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.GridLayout.superclass.props.apply(this, arguments), { baseCls: "bi-grid-layout", columns: null, rows: null, @@ -26252,8 +26262,8 @@ BI.GridLayout = BI.inherit(BI.Layout, { ]*/ }); }, - _init: function () { - BI.GridLayout.superclass._init.apply(this, arguments); + created: function () { + BI.GridLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -26343,7 +26353,7 @@ BI.GridLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.GridLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.grid', BI.GridLayout);/** @@ -26352,8 +26362,8 @@ $.shortcut('bi.grid', BI.GridLayout);/** * @extends BI.Layout */ BI.HorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-layout", verticalAlign: "middle", columnSize: [], @@ -26366,25 +26376,17 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + created: function () { + BI.HorizontalLayout.superclass.created.apply(this, arguments); + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "white-space": "nowrap", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -26442,26 +26444,22 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); } - return this; }, - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); - }); - this.widgets = {}; - this.tr.empty(); - }, resize: function () { // console.log("horizontal layout do not need to resize"); @@ -26469,14 +26467,15 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.tr.element); + w.element.appendTo(this.$tr); return w; }, populate: function (items) { BI.HorizontalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal', BI.HorizontalLayout); @@ -26487,8 +26486,8 @@ $.shortcut('bi.horizontal', BI.HorizontalLayout); * @extends BI.Layout */ BI.HorizontalCellLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalCellLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalCellLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-cell-layout", scrollable: true, hgap: 0, @@ -26499,8 +26498,8 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalCellLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HorizontalCellLayout.superclass.created.apply(this, arguments); this.element.css({"display": "table", "vertical-align": "top"}); this.populate(this.options.items); }, @@ -26538,7 +26537,7 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HorizontalCellLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal_cell', BI.HorizontalCellLayout);/** @@ -26551,8 +26550,8 @@ $.shortcut('bi.horizontal_cell', BI.HorizontalCellLayout);/** * @cfg {Number} [vgap=0] 垂直间隙 */ BI.InlineLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.InlineLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.InlineLayout.superclass.props.apply(this, arguments), { baseCls: "bi-inline-layout", hgap: 0, vgap: 0, @@ -26562,8 +26561,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.InlineLayout.superclass._init.apply(this, arguments); + created: function () { + BI.InlineLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -26600,7 +26599,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.InlineLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.inline', BI.InlineLayout);/** @@ -26613,14 +26612,14 @@ $.shortcut('bi.inline', BI.InlineLayout);/** * @cfg {Number} [vgap=0] 垂直间隙 */ BI.LatticeLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.LatticeLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.LatticeLayout.superclass.props.apply(this, arguments), { baseCls: "bi-lattice-layout clearfix" //columnSize: [0.2, 0.2, 0.6], }); }, - _init: function () { - BI.LatticeLayout.superclass._init.apply(this, arguments); + created: function () { + BI.LatticeLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -26648,7 +26647,7 @@ BI.LatticeLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.LatticeLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.lattice', BI.LatticeLayout);/** @@ -26658,8 +26657,8 @@ $.shortcut('bi.lattice', BI.LatticeLayout);/** * @extends BI.Layout */ BI.TableLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.TableLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.TableLayout.superclass.props.apply(this, arguments), { baseCls: "bi-table-layout", scrolly: true, columnSize: [200, 200, 'fill'], @@ -26679,8 +26678,8 @@ BI.TableLayout = BI.inherit(BI.Layout, { ]] }); }, - _init: function () { - BI.TableLayout.superclass._init.apply(this, arguments); + created: function () { + BI.TableLayout.superclass.created.apply(this, arguments); this.rows = 0; this.populate(this.options.items); }, @@ -26793,7 +26792,7 @@ BI.TableLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.TableLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.table', BI.TableLayout);/** @@ -26802,8 +26801,8 @@ $.shortcut('bi.table', BI.TableLayout);/** * @extends BI.Layout */ BI.HTapeLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HTapeLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HTapeLayout.superclass.props.apply(this, arguments), { baseCls: "bi-h-tape-layout", hgap: 0, vgap: 0, @@ -26827,8 +26826,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { ] }); }, - _init: function () { - BI.HTapeLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HTapeLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -26895,7 +26894,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HTapeLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.htape', BI.HTapeLayout); @@ -26906,8 +26905,8 @@ $.shortcut('bi.htape', BI.HTapeLayout); * @extends BI.Layout */ BI.VTapeLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.VTapeLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.VTapeLayout.superclass.props.apply(this, arguments), { baseCls: "bi-v-tape-layout", hgap: 0, vgap: 0, @@ -26931,8 +26930,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { ] }); }, - _init: function () { - BI.VTapeLayout.superclass._init.apply(this, arguments); + created: function () { + BI.VTapeLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -27000,7 +26999,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VTapeLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.vtape', BI.VTapeLayout);/** @@ -27009,8 +27008,8 @@ $.shortcut('bi.vtape', BI.VTapeLayout);/** * @extends BI.Layout */ BI.TdLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.TdLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.TdLayout.superclass.props.apply(this, arguments), { baseCls: "bi-td-layout", columnSize: [200, 200, 200], hgap: 0, @@ -27028,21 +27027,16 @@ BI.TdLayout = BI.inherit(BI.Layout, { ]] }); }, - _init: function () { - BI.TdLayout.superclass._init.apply(this, arguments); - this.table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - this.table.element.css({ + created: function () { + BI.TdLayout.superclass.created.apply(this, arguments); + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "width": "100%", "height": "100%", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); + }); this.rows = 0; this.populate(this.options.items); }, @@ -27113,10 +27107,26 @@ BI.TdLayout = BI.inherit(BI.Layout, { }); tr.addItem(td); } - this.table.element.append(tr.element); + this.addWidget(this.getName() + idx, tr); return tr; }, + _mountChildren: function(){ + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$table.append(frag); + this.element.append(this.$table); + } + }, + resize: function () { // console.log("td布局不需要resize"); }, @@ -27130,6 +27140,7 @@ BI.TdLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.TdLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.td', BI.TdLayout);/** @@ -27138,8 +27149,8 @@ $.shortcut('bi.td', BI.TdLayout);/** * @extends BI.Layout */ BI.VerticalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.VerticalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.VerticalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-vertical-layout", hgap: 0, vgap: 0, @@ -27150,8 +27161,8 @@ BI.VerticalLayout = BI.inherit(BI.Layout, { scrolly: true }); }, - _init: function () { - BI.VerticalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.VerticalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -27190,7 +27201,7 @@ BI.VerticalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VerticalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.vertical', BI.VerticalLayout);/** @@ -27199,8 +27210,8 @@ $.shortcut('bi.vertical', BI.VerticalLayout);/** * @extends BI.Layout */ BI.WindowLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.WindowLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.WindowLayout.superclass.props.apply(this, arguments), { baseCls: "bi-window-layout", columns: 3, rows: 2, @@ -27225,8 +27236,8 @@ BI.WindowLayout = BI.inherit(BI.Layout, { ]] }); }, - _init: function () { - BI.WindowLayout.superclass._init.apply(this, arguments); + created: function () { + BI.WindowLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -27377,7 +27388,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.WindowLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.window', BI.WindowLayout);/** @@ -27386,8 +27397,8 @@ $.shortcut('bi.window', BI.WindowLayout);/** * @extends BI.Layout */ BI.CenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.CenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.CenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-center-layout", hgap: 0, vgap: 0, @@ -27398,8 +27409,8 @@ BI.CenterLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.CenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.CenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -27414,14 +27425,13 @@ BI.CenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this, o = this.options; - this.clear(); var list = []; BI.each(items, function (i) { list.push({ column: i, row: 0, el: BI.createWidget({ - type: "bi.layout", + type: "bi.default", cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "") }) }); @@ -27437,13 +27447,13 @@ BI.CenterLayout = BI.inherit(BI.Layout, { bottom: o.vgap + o.bgap, width: "auto", height: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.grid", - element: this.element, + element: this, columns: list.length, rows: 1, items: list @@ -27452,6 +27462,7 @@ BI.CenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.CenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.center', BI.CenterLayout);/** @@ -27460,8 +27471,8 @@ $.shortcut('bi.center', BI.CenterLayout);/** * @extends BI.Layout */ BI.FloatCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-center-layout", hgap: 0, vgap: 0, @@ -27471,8 +27482,8 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FloatCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -27487,10 +27498,11 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this, o = this.options; - this.clear(); var list = [], width = 100 / items.length; BI.each(items, function (i) { - var widget = BI.createWidget(); + var widget = BI.createWidget({ + type: "bi.default" + }); widget.element.addClass("center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")).css({ width: width + "%", height: "100%" @@ -27510,19 +27522,20 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, { bottom: o.vgap + o.bgap, width: "auto", height: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: list }); }, populate: function (items) { BI.FloatCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.float_center', BI.FloatCenterLayout);/** @@ -27531,8 +27544,8 @@ $.shortcut('bi.float_center', BI.FloatCenterLayout);/** * @extends BI.Layout */ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-center-layout", hgap: 0, vgap: 0, @@ -27542,8 +27555,8 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HorizontalCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -27558,14 +27571,13 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var o = this.options; - this.clear(); var list = []; BI.each(items, function (i) { list.push({ column: i, row: 0, el: BI.createWidget({ - type: "bi.layout", + type: "bi.default", cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "") }) }); @@ -27580,13 +27592,13 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { top: o.vgap + o.tgap, bottom: o.vgap + o.bgap, width: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.grid", - element: this.element, + element: this, columns: list.length, rows: 1, items: list @@ -27595,6 +27607,7 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HorizontalCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.horizontal_center', BI.HorizontalCenterLayout);/** @@ -27603,8 +27616,8 @@ $.shortcut('bi.horizontal_center', BI.HorizontalCenterLayout);/** * @extends BI.Layout */ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.VerticalCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.VerticalCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-vertical-center-layout", hgap: 0, vgap: 0, @@ -27614,8 +27627,8 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.VerticalCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.VerticalCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -27630,14 +27643,13 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this, o = this.options; - this.clear(); var list = []; BI.each(items, function (i) { list.push({ column: 0, row: i, el: BI.createWidget({ - type: "bi.layout", + type: "bi.default", cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "") }) }); @@ -27652,13 +27664,13 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { top: o.vgap + o.tgap, bottom: o.vgap + o.bgap, height: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.grid", - element: this.element, + element: this, columns: 1, rows: list.length, items: list @@ -27667,6 +27679,7 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VerticalCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.vertical_center', BI.VerticalCenterLayout);/** @@ -27740,74 +27753,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/index.js b/index.js deleted file mode 100644 index 2c480d1d7..000000000 --- a/index.js +++ /dev/null @@ -1,56 +0,0 @@ -$(function(){ - 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", - }, - width: 600, - height: 500, - isResizeAdapt: true, - isNeedResize: true, - isNeedMerge: true, - mergeCols: [0, 1], - mergeRule: function (col1, col2) { - return BI.isEqual(col1, col2); - }, - isNeedFreeze: true, - freezeCols: [0, 1], - columnSize: columnSize, - items: items, - header: header - }); - BI.createWidget({ - type: "bi.absolute", - element: "#wrapper", - items: [{ - el: table, - left: 10, - right: 10, - top: 10, - bottom: 10 - }] - }) -}) \ No newline at end of file diff --git a/server.js b/server.js index a9fd0cede..8bce8676a 100644 --- a/server.js +++ b/server.js @@ -9,5 +9,5 @@ const port = 3000; app.use(express.static("./")); app.listen(port, function() { console.log("server start"); - open('http://localhost:' + port + '/index.html'); + open('http://localhost:' + port + '/demo.html'); }); diff --git a/src/base/chart/chart.js b/src/base/chart/chart.js deleted file mode 100644 index 6037c50bf..000000000 --- a/src/base/chart/chart.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 图表控件 - * @class BI.Chart - * @extends BI.Widget - */ -BI.Chart = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.Chart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-chart" - }) - }, - - _init: function () { - BI.Chart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.isInit = false; - this.isSetOptions = false; - this.wants2SetData = false; - var width = 0; - var height = 0; - - this._resizer = BI.debounce(function () { - if (self.element.is(":visible") && self.vanCharts) { - self.vanCharts.resize(); - } - }, 30); - BI.Resizers.add(this.getName(), function (e) { - if (BI.isWindow(e.target) && self.element.is(":visible")) { - var newW = self.element.width(), newH = self.element.height(); - if (newW > 0 && newH > 0 && (width !== newW || height !== newH)) { - self._resizer(); - width = newW; - height = newH; - } - } - }); - }, - - _setData: function () { - this.vanCharts && this.vanCharts.setData(this.config); - }, - - resize: function () { - if (this.element.is(":visible") && this.isSetOptions === true) { - this._resizer(); - } - }, - - magnify: function () { - this.vanCharts && this.vanCharts.charts[0] && this.vanCharts.charts[0].refreshRestore(); - }, - - populate: function (items, options) { - var self = this, o = this.options; - o.items = items; - this.config = options || {}; - this.config.series = o.items; - - var setOptions = function () { - self.vanCharts.setOptions(self.config); - self.isSetOptions = true; - //if (self.wants2SetData === true) { - // self._setData(); - //} - }; - var init = function () { - if (self.element.is(":visible")) { - self.vanCharts = VanCharts.init(self.element[0]); - BI.nextTick(setOptions); - self.isInit = true; - } - }; - - if (this.isInit === false) { - BI.nextTick(init); - } - - if (this.element.is(":visible") && this.isSetOptions === true) { - this._setData(); - this.wants2SetData = null; - } else { - this.wants2SetData = true; - } - } -}); -BI.Chart.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut('bi.chart', BI.Chart); \ No newline at end of file diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index e1e3ac45f..906055b29 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -48,7 +48,7 @@ BI.Collection = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, scrollable: o.overflowX === true && o.overflowY === true, scrolly: o.overflowX === false && o.overflowY === true, scrollx: o.overflowX === true && o.overflowY === false, @@ -58,11 +58,13 @@ BI.Collection = BI.inherit(BI.Widget, { this._calculateSizeAndPositionData(); this._populate(); } + }, + + mounted: function () { + var o = this.options; if (o.scrollLeft !== 0 || o.scrollTop !== 0) { - BI.nextTick(function () { - self.element.scrollTop(o.scrollTop); - self.element.scrollLeft(o.scrollLeft); - }); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); } }, diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index d3822b184..444cb1ea4 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -4,9 +4,8 @@ */ BI.Combo = BI.inherit(BI.Widget, { _defaultConfig: function () { - var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-combo", + return BI.extend(BI.Combo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-combo", trigger: "click", toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right @@ -62,7 +61,7 @@ BI.Combo = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.combo} ] @@ -159,7 +158,7 @@ BI.Combo = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.popupView} ] diff --git a/src/base/combination/expander.js b/src/base/combination/expander.js index ff66065fb..533e3e4d7 100644 --- a/src/base/combination/expander.js +++ b/src/base/combination/expander.js @@ -56,7 +56,7 @@ BI.Expander = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.expander} ] @@ -156,7 +156,7 @@ BI.Expander = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.popupView} ] diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 14ab52865..75cf01387 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -176,7 +176,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.buttons = this._btnsCreator.apply(this, arguments); var items = this._packageItems(items, this._packageBtns(this.buttons)); - this.layouts = BI.createWidget(BI.extend({element: this.element}, this._packageLayout(items))); + this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); }, setEnable: function (b) { diff --git a/src/base/combination/group.combo.js b/src/base/combination/group.combo.js index 4781ed9e8..b5df41d26 100644 --- a/src/base/combination/group.combo.js +++ b/src/base/combination/group.combo.js @@ -60,7 +60,7 @@ BI.ComboGroup = BI.inherit(BI.Widget, { }) this.combo = BI.createWidget({ type: "bi.combo", - element: this.element, + element: this, height: o.height, trigger: o.trigger, direction: o.direction, diff --git a/src/base/combination/loader.js b/src/base/combination/loader.js index 639a49100..434a90f2a 100644 --- a/src/base/combination/loader.js +++ b/src/base/combination/loader.js @@ -99,7 +99,7 @@ BI.Loader = BI.inherit(BI.Widget, { } BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ scrolly: true }, o.logic, { diff --git a/src/base/combination/navigation.js b/src/base/combination/navigation.js index e4b7eb553..524821ce3 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -34,7 +34,7 @@ BI.Navigation = BI.inherit(BI.Widget, { type: "bi.card" }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout) })))); diff --git a/src/base/combination/searcher.js b/src/base/combination/searcher.js index f9c89da37..59abc5356 100644 --- a/src/base/combination/searcher.js +++ b/src/base/combination/searcher.js @@ -53,7 +53,7 @@ BI.Searcher = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, lgap: o.lgap, rgap: o.rgap, tgap: o.tgap, diff --git a/src/base/combination/switcher.js b/src/base/combination/switcher.js index 92fe4a6a2..d7468578f 100644 --- a/src/base/combination/switcher.js +++ b/src/base/combination/switcher.js @@ -56,7 +56,7 @@ BI.Switcher = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.switcher} ] @@ -144,7 +144,7 @@ BI.Switcher = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [ {el: this.popupView} ] diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 4069603d9..f12d3a150 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -33,7 +33,7 @@ BI.Tab = BI.inherit(BI.Widget, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout) })))); diff --git a/src/base/combination/tree.button.js b/src/base/combination/tree.button.js index 17eb2032e..4b8bda42d 100644 --- a/src/base/combination/tree.button.js +++ b/src/base/combination/tree.button.js @@ -286,7 +286,7 @@ BI.ButtonMap = BI.inherit(BI.ButtonTree, { this.empty(); var packages = this._packageItems(items, this._packageBtns(array)); - BI.createWidget(BI.extend({element: this.element}, this._packageLayout(packages))); + BI.createWidget(BI.extend({element: this}, this._packageLayout(packages))); }, getIndexByValue: function (value) { diff --git a/src/base/el.js b/src/base/el.js index dbd6774ed..480e91e24 100644 --- a/src/base/el.js +++ b/src/base/el.js @@ -19,7 +19,7 @@ BI.EL = BI.inherit(BI.Widget, { this.ele = BI.createWidget(o.el); BI.createWidget(o.layout, { type: "bi.adaptive", - element: this.element, + element: this, items: [this.ele] }); this.ele.on(BI.Controller.EVENT_CHANGE, function () { diff --git a/src/base/formula/formulaeditor.js b/src/base/formula/formulaeditor.js index 06dc3e43a..d2433ebf9 100644 --- a/src/base/formula/formulaeditor.js +++ b/src/base/formula/formulaeditor.js @@ -56,7 +56,7 @@ }); BI.createWidget({ type: "bi.absolute", - element: self.element, + element: self, items: [{ el: self.watermark, left: 0, diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index a6f8e7504..03b5336a2 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -51,7 +51,7 @@ BI.Grid = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, scrollable: o.overflowX === true && o.overflowY === true, scrolly: o.overflowX === false && o.overflowY === true, scrollx: o.overflowX === true && o.overflowY === false, @@ -60,11 +60,13 @@ BI.Grid = BI.inherit(BI.Widget, { if (o.items.length > 0) { this._populate(); } + }, + + mounted: function () { + var o = this.options; if (o.scrollLeft !== 0 || o.scrollTop !== 0) { - BI.nextTick(function () { - self.element.scrollTop(o.scrollTop); - self.element.scrollLeft(o.scrollLeft); - }); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); } }, diff --git a/src/base/layer/layer.floatbox.js b/src/base/layer/layer.floatbox.js index 18741d225..2c95e48f2 100644 --- a/src/base/layer/layer.floatbox.js +++ b/src/base/layer/layer.floatbox.js @@ -41,7 +41,7 @@ BI.FloatBox = BI.inherit(BI.Widget, { this._south = BI.createWidget(); BI.createWidget({ type: 'bi.border', - element: this.element, + element: this, items: { 'north': { el: { diff --git a/src/base/layer/layer.popup.js b/src/base/layer/layer.popup.js index 92e648f93..634507705 100644 --- a/src/base/layer/layer.popup.js +++ b/src/base/layer/layer.popup.js @@ -70,7 +70,7 @@ BI.PopupView = BI.inherit(BI.Widget, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { scrolly: false, lgap: o.lgap, diff --git a/src/base/layer/layer.scroll.js b/src/base/layer/layer.scroll.js index d43e56f8f..01fe2652f 100644 --- a/src/base/layer/layer.scroll.js +++ b/src/base/layer/layer.scroll.js @@ -30,7 +30,7 @@ BI.ScrollView = BI.inherit(BI.Widget, { }) BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, scrolly: false, items: [this.scroll] }) @@ -44,7 +44,7 @@ BI.ScrollView = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.dropdown, left: 0, diff --git a/src/base/layer/layer.searcher.js b/src/base/layer/layer.searcher.js index caeadc6be..3caa71a21 100644 --- a/src/base/layer/layer.searcher.js +++ b/src/base/layer/layer.searcher.js @@ -94,7 +94,7 @@ BI.SearcherView = BI.inherit(BI.Pane, { BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, items: [this.matcher, this.spliter, this.searcher] }); }, diff --git a/src/base/pager/pager.js b/src/base/pager/pager.js index 434ae9be2..126cda329 100644 --- a/src/base/pager/pager.js +++ b/src/base/pager/pager.js @@ -183,7 +183,7 @@ BI.Pager = BI.inherit(BI.Widget, { this.button_group = BI.createWidget({ type: "bi.button_group", - element: this.element, + element: this, items: BI.createItems(view, { cls: "page-item", height: 23, diff --git a/src/base/pane.js b/src/base/pane.js index fee510c0c..941ab3996 100644 --- a/src/base/pane.js +++ b/src/base/pane.js @@ -32,7 +32,7 @@ BI.Pane = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, items: [this._tipText], bgap: 25 }); @@ -65,7 +65,7 @@ BI.Pane = BI.inherit(BI.Widget, { this._loading.element.css("zIndex", 1); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this._loading, left: 0, diff --git a/src/base/single/a/a.js b/src/base/single/a/a.js index fa37bf960..db50fe4b8 100644 --- a/src/base/single/a/a.js +++ b/src/base/single/a/a.js @@ -22,7 +22,7 @@ BI.A = BI.inherit(BI.Text, { BI.A.superclass._init.apply(this, arguments); if (o.el) { BI.createWidget(o.el, { - element: this.element + element: this }); } } diff --git a/src/base/single/bar/bar.loading.js b/src/base/single/bar/bar.loading.js index 8897362a8..326cb2579 100644 --- a/src/base/single/bar/bar.loading.js +++ b/src/base/single/bar/bar.loading.js @@ -45,7 +45,7 @@ BI.LoadingBar = BI.inherit(BI.Single, { }) this.cardLayout = BI.createWidget({ type: "bi.card", - element: this.element, + element: this, items: [{ el: loaded, cardName: "loaded" diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 700df075f..5a1b20dd8 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -53,7 +53,7 @@ BI.BasicButton = BI.inherit(BI.Single, { self.$mask.invisible(); BI.createWidget({ type: "bi.absolute", - element: self.element, + element: self, items: [{ el: self.$mask, left: 0, diff --git a/src/base/single/button/buttons/button.icon.js b/src/base/single/button/buttons/button.icon.js index f1581a267..6e65366e0 100644 --- a/src/base/single/button/buttons/button.icon.js +++ b/src/base/single/button/buttons/button.icon.js @@ -29,12 +29,12 @@ BI.IconButton = BI.inherit(BI.BasicButton, { this.element.css("lineHeight", o.height + "px"); BI.createWidget({ type: "bi.default", - element: this.element, + element: this, items: [this.icon] }) } else { BI.createWidget({ - element: this.element, + element: this, type: 'bi.center_adapt', items: [this.icon] }); diff --git a/src/base/single/button/buttons/button.image.js b/src/base/single/button/buttons/button.image.js index 329376dfd..7bc567d04 100644 --- a/src/base/single/button/buttons/button.image.js +++ b/src/base/single/button/buttons/button.image.js @@ -29,13 +29,13 @@ BI.ImageButton = BI.inherit(BI.BasicButton, { if (BI.isNumber(o.iconWidth) || BI.isNumber(o.iconHeight)) { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, items: [this.image] }) } else { BI.createWidget({ type: "bi.adaptive", - element: this.element, + element: this, items: [this.image], scrollable: false }) diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 85bfb857e..944a851e1 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -55,7 +55,7 @@ BI.createWidget({ type: "bi.horizontal_auto", cls: "button-" + o.level + " " + o.iconClass, - element: this.element, + element: this, hgap: o.hgap, vgap: o.vgap, tgap: o.tgap, @@ -82,7 +82,7 @@ bgap: o.bgap, lgap: o.lgap, rgap: o.rgap, - element: this.element, + element: this, text: o.text, value: o.value }); diff --git a/src/base/single/button/buttons/button.text.js b/src/base/single/button/buttons/button.text.js index 4a71dd13b..a66f5f36f 100644 --- a/src/base/single/button/buttons/button.text.js +++ b/src/base/single/button/buttons/button.text.js @@ -29,7 +29,7 @@ BI.TextButton = BI.inherit(BI.BasicButton, { var o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: o.textAlign, whiteSpace: o.whiteSpace, textWidth: o.textWidth, diff --git a/src/base/single/button/listitem/blankicontexticonitem.js b/src/base/single/button/listitem/blankicontexticonitem.js index 52af69590..e28e53447 100644 --- a/src/base/single/button/listitem/blankicontexticonitem.js +++ b/src/base/single/button/listitem/blankicontexticonitem.js @@ -59,7 +59,7 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.center_adapt", @@ -80,7 +80,7 @@ BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", { type: "bi.layout", diff --git a/src/base/single/button/listitem/blankicontextitem.js b/src/base/single/button/listitem/blankicontextitem.js index 10e9e6544..8b19b8697 100644 --- a/src/base/single/button/listitem/blankicontextitem.js +++ b/src/base/single/button/listitem/blankicontextitem.js @@ -60,7 +60,7 @@ BI.BlankIconTextItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", blank, this.icon, this.text) })))); diff --git a/src/base/single/button/listitem/icontexticonitem.js b/src/base/single/button/listitem/icontexticonitem.js index be6f2ac45..b9288498a 100644 --- a/src/base/single/button/listitem/icontexticonitem.js +++ b/src/base/single/button/listitem/icontexticonitem.js @@ -62,7 +62,7 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.center_adapt", @@ -83,7 +83,7 @@ BI.IconTextIconItem = BI.inherit(BI.BasicButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank) })))); diff --git a/src/base/single/button/listitem/icontextitem.js b/src/base/single/button/listitem/icontextitem.js index 1ae1fda9b..cff5af38b 100644 --- a/src/base/single/button/listitem/icontextitem.js +++ b/src/base/single/button/listitem/icontextitem.js @@ -55,7 +55,7 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.icon, this.text) })))); diff --git a/src/base/single/button/listitem/texticonitem.js b/src/base/single/button/listitem/texticonitem.js index 12749b65c..492d8371e 100644 --- a/src/base/single/button/listitem/texticonitem.js +++ b/src/base/single/button/listitem/texticonitem.js @@ -56,7 +56,7 @@ BI.TextIconItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon) })))); diff --git a/src/base/single/button/listitem/textitem.js b/src/base/single/button/listitem/textitem.js index ed5d32075..ee4d46f24 100644 --- a/src/base/single/button/listitem/textitem.js +++ b/src/base/single/button/listitem/textitem.js @@ -25,7 +25,7 @@ BI.TextItem = BI.inherit(BI.BasicButton, { var o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: o.textAlign, whiteSpace: o.whiteSpace, textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight, diff --git a/src/base/single/button/node/icontexticonnode.js b/src/base/single/button/node/icontexticonnode.js index 526ebbc42..a7b1b4586 100644 --- a/src/base/single/button/node/icontexticonnode.js +++ b/src/base/single/button/node/icontexticonnode.js @@ -60,7 +60,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { }) BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.center_adapt", @@ -81,7 +81,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank) })))); diff --git a/src/base/single/button/node/icontextnode.js b/src/base/single/button/node/icontextnode.js index a7e42abf3..809b34496 100644 --- a/src/base/single/button/node/icontextnode.js +++ b/src/base/single/button/node/icontextnode.js @@ -54,7 +54,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon, this.text) })))); diff --git a/src/base/single/button/node/texticonnode.js b/src/base/single/button/node/texticonnode.js index 4b2931ec7..42292e736 100644 --- a/src/base/single/button/node/texticonnode.js +++ b/src/base/single/button/node/texticonnode.js @@ -53,7 +53,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon) })))); diff --git a/src/base/single/button/node/textnode.js b/src/base/single/button/node/textnode.js index 3ddc1d3c3..4a774904a 100644 --- a/src/base/single/button/node/textnode.js +++ b/src/base/single/button/node/textnode.js @@ -24,7 +24,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { var o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: o.textAlign, whiteSpace: o.whiteSpace, textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight, diff --git a/src/base/single/editor/editor.code.js b/src/base/single/editor/editor.code.js index 434adcf6c..54a8b1150 100644 --- a/src/base/single/editor/editor.code.js +++ b/src/base/single/editor/editor.code.js @@ -61,7 +61,7 @@ BI.CodeEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: watermark, top: 0, diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 95081c2b0..521c39bb0 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -93,7 +93,7 @@ BI.Editor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: items }); this.editor.on(BI.Controller.EVENT_CHANGE, function () { diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index 3b1fb595b..b60d0b88c 100644 --- a/src/base/single/editor/editor.multifile.js +++ b/src/base/single/editor/editor.multifile.js @@ -50,7 +50,7 @@ BI.MultifileEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.adaptive", diff --git a/src/base/single/editor/editor.textarea.js b/src/base/single/editor/editor.textarea.js index d75a12029..44eea9206 100644 --- a/src/base/single/editor/editor.textarea.js +++ b/src/base/single/editor/editor.textarea.js @@ -24,7 +24,7 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { this.content.element.css({"resize": "none"}); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: { type: "bi.adaptive", diff --git a/src/base/single/label/label.js b/src/base/single/label/label.js index d9436104b..48cc0cc6e 100644 --- a/src/base/single/label/label.js +++ b/src/base/single/label/label.js @@ -59,7 +59,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)), @@ -77,7 +77,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.center_adapt", scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -97,7 +97,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [this.text] }); return; @@ -109,7 +109,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -124,7 +124,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.center_adapt", scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)) }] @@ -136,7 +136,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.center_adapt", scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -156,7 +156,7 @@ BI.Label = BI.inherit(BI.Single, { tgap: o.tgap, bgap: o.bgap, scrollable: true, - element: this.element, + element: this, items: [this.text] }); return; @@ -170,7 +170,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -193,7 +193,7 @@ BI.Label = BI.inherit(BI.Single, { "line-height": o.height + "px" }); this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", @@ -214,13 +214,13 @@ BI.Label = BI.inherit(BI.Single, { this.text = BI.createWidget(json); BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, items: [this.text] }); return; } this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", @@ -239,7 +239,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)), @@ -263,7 +263,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -283,7 +283,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [this.text] }); return; @@ -295,7 +295,7 @@ BI.Label = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -316,7 +316,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)) }] @@ -334,7 +334,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [ { el: (this.text = BI.createWidget(json)) @@ -354,7 +354,7 @@ BI.Label = BI.inherit(BI.Single, { rgap: o.rgap, tgap: o.tgap, bgap: o.bgap, - element: this.element, + element: this, items: [this.text] }); return; @@ -368,7 +368,7 @@ BI.Label = BI.inherit(BI.Single, { type: "bi.adaptive", height: o.height, scrollable: true, - element: this.element, + element: this, items: [{ el: (this.text = BI.createWidget(json)), left: o.hgap + o.lgap, @@ -391,7 +391,7 @@ BI.Label = BI.inherit(BI.Single, { "line-height": o.height + "px" }); this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", @@ -412,13 +412,13 @@ BI.Label = BI.inherit(BI.Single, { this.text = BI.createWidget(json); BI.createWidget({ type: "bi.vertical_adapt", - element: this.element, + element: this, items: [this.text] }); return; } this.text = BI.createWidget(BI.extend(json, { - element: this.element + element: this })); BI.createWidget({ type: "bi.layout", diff --git a/src/base/table/table.cell.js b/src/base/table/table.cell.js index fe924d83a..066ed0c4c 100644 --- a/src/base/table/table.cell.js +++ b/src/base/table/table.cell.js @@ -19,7 +19,7 @@ BI.TableCell = BI.inherit(BI.Widget, { BI.TableCell.superclass._init.apply(this, arguments); BI.createWidget({ type: "bi.label", - element: this.element, + element: this, whiteSpace: "nowrap", textAlign: this.options.textAlign, height: this.options.height, diff --git a/src/base/table/table.collection.cell.js b/src/base/table/table.collection.cell.js index 78c047b6f..8009e9507 100644 --- a/src/base/table/table.collection.cell.js +++ b/src/base/table/table.collection.cell.js @@ -30,7 +30,7 @@ BI.CollectionTableCell = BI.inherit(BI.Widget, { })); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.cell, left: 0, diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index 7e32bf186..e118abb5c 100644 --- a/src/base/table/table.collection.js +++ b/src/base/table/table.collection.js @@ -101,7 +101,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); this.contextLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topLeft, top: 0, @@ -146,7 +146,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); this.scrollBarLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topScrollbar, right: 0, diff --git a/src/base/table/table.grid.cell.js b/src/base/table/table.grid.cell.js index 8c57c41bd..9c42eec55 100644 --- a/src/base/table/table.grid.cell.js +++ b/src/base/table/table.grid.cell.js @@ -32,7 +32,7 @@ BI.GridTableCell = BI.inherit(BI.Widget, { })); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.cell, left: 0, diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 2a837f10a..b2f1cdfaa 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -103,7 +103,7 @@ BI.GridTable = BI.inherit(BI.Widget, { }); this.contextLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topLeft, top: 0, @@ -148,7 +148,7 @@ BI.GridTable = BI.inherit(BI.Widget, { }); this.scrollBarLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.topScrollbar, right: 0, diff --git a/src/base/table/table.grid.scrollbar.js b/src/base/table/table.grid.scrollbar.js index 6c99253cc..eaf8f9339 100644 --- a/src/base/table/table.grid.scrollbar.js +++ b/src/base/table/table.grid.scrollbar.js @@ -40,7 +40,7 @@ BI.GridTableScrollbar = BI.inherit(BI.Widget, { }); this.contextLayout = BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.face, left: 0, @@ -362,7 +362,7 @@ BI.GridTableHorizontalScrollbar = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.absolute", cls: "horizontal-scrollbar", - element: this.element, + element: this, width: o.size, height: BI.GridTableScrollbar.SIZE, items: [{ diff --git a/src/base/table/table.header.cell.js b/src/base/table/table.header.cell.js index 9a2496ab9..c1cefe3b7 100644 --- a/src/base/table/table.header.cell.js +++ b/src/base/table/table.header.cell.js @@ -18,7 +18,7 @@ BI.TableHeaderCell = BI.inherit(BI.Widget, { BI.TableHeaderCell.superclass._init.apply(this, arguments); BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "center", height: this.options.height, text: this.options.text, diff --git a/src/base/table/table.js b/src/base/table/table.js index 5c5ca3439..91d1b03de 100644 --- a/src/base/table/table.js +++ b/src/base/table/table.js @@ -443,7 +443,7 @@ BI.Table = BI.inherit(BI.Widget, { regionColumnSize = isRight ? [0, 'fill'] : ['fill', 0]; } this.partitions = BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("table", BI.extend({}, o.logic, { rows: 2, columns: 2, @@ -1051,7 +1051,7 @@ BI.Table = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.adaptive", cls: "bottom-right", - element: this.element, + element: this, scrollable: false, items: [this.scrollBottomRight] }); diff --git a/src/base/table/table.resizable.cell.js b/src/base/table/table.resizable.cell.js index 392d0f70d..caa3a5d5e 100644 --- a/src/base/table/table.resizable.cell.js +++ b/src/base/table/table.resizable.cell.js @@ -65,7 +65,7 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.cell, left: 0, diff --git a/src/base/table/table.resizable.js b/src/base/table/table.resizable.js index 6a9433091..2337e4b03 100644 --- a/src/base/table/table.resizable.js +++ b/src/base/table/table.resizable.js @@ -41,7 +41,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { this.regionResizerHandler = this._createResizerHandler(); this.table = BI.createWidget(o.el, { type: "bi.grid_table", - element: this.element, + element: this, width: o.width, height: o.height, headerRowSize: o.headerRowSize, @@ -63,7 +63,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.regionResizerHandler, left: 0, diff --git a/src/base/tree/1treeview.js b/src/base/tree/1treeview.js index b4e17661b..be25bed80 100644 --- a/src/base/tree/1treeview.js +++ b/src/base/tree/1treeview.js @@ -28,7 +28,7 @@ BI.TreeView = BI.inherit(BI.Pane, { type: "bi.vertical", scrollable: true, scrolly: false, - element: this.element, + element: this, items: [this.container, this.tip] }); diff --git a/src/base/tree/customtree.js b/src/base/tree/customtree.js index 01018362b..fa2d7ffec 100644 --- a/src/base/tree/customtree.js +++ b/src/base/tree/customtree.js @@ -87,7 +87,7 @@ BI.CustomTree = BI.inherit(BI.Widget, { initTree: function (nodes) { var self = this, o = this.options; this.tree = BI.createWidget(o.el, { - element: this.element, + element: this, items: this._formatItems(nodes), itemsCreator: function (op, callback) { o.itemsCreator.apply(this, [op, function (items) { diff --git a/src/case/button/icon/icon.change.js b/src/case/button/icon/icon.change.js index 37ddede2c..3ce39a294 100644 --- a/src/case/button/icon/icon.change.js +++ b/src/case/button/icon/icon.change.js @@ -35,7 +35,7 @@ BI.IconChangeButton = BI.inherit(BI.Single, { var self = this, o = this.options; this.button = BI.createWidget({ type: "bi.icon_button", - element: this.element, + element: this, cls: o.iconClass, height: o.height, iconWidth: o.iconWidth, diff --git a/src/case/button/item.multiselect.js b/src/case/button/item.multiselect.js index 91f8b315a..b43a3a5ec 100644 --- a/src/case/button/item.multiselect.js +++ b/src/case/button/item.multiselect.js @@ -40,7 +40,7 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", { type: "bi.center_adapt", diff --git a/src/case/button/item.singleselect.icontext.js b/src/case/button/item.singleselect.icontext.js index 25582d9a7..7936c00b2 100644 --- a/src/case/button/item.singleselect.icontext.js +++ b/src/case/button/item.singleselect.icontext.js @@ -18,7 +18,7 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { var self = this, o = this.options; this.text = BI.createWidget({ type: "bi.icon_text_item", - element: this.element, + element: this, cls: o.iconClass, once: o.once, selected: o.selected, diff --git a/src/case/button/item.singleselect.js b/src/case/button/item.singleselect.js index 277901488..cf817866e 100644 --- a/src/case/button/item.singleselect.js +++ b/src/case/button/item.singleselect.js @@ -16,7 +16,7 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { var self = this, o = this.options; this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "left", whiteSpace: "nowrap", textHeight: o.height, diff --git a/src/case/button/item.singleselect.radio.js b/src/case/button/item.singleselect.radio.js index ad0f8d1b9..6b31ded9e 100644 --- a/src/case/button/item.singleselect.radio.js +++ b/src/case/button/item.singleselect.radio.js @@ -41,7 +41,7 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("left", { type: "bi.center_adapt", diff --git a/src/case/button/node/node.arrow.js b/src/case/button/node/node.arrow.js index 2023342f6..b4e6b9c29 100644 --- a/src/case/button/node/node.arrow.js +++ b/src/case/button/node/node.arrow.js @@ -49,7 +49,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/node/node.first.plus.js b/src/case/button/node/node.first.plus.js index 2f513fba8..ca900cefa 100644 --- a/src/case/button/node/node.first.plus.js +++ b/src/case/button/node/node.first.plus.js @@ -51,7 +51,7 @@ BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/node/node.icon.arrow.js b/src/case/button/node/node.icon.arrow.js index 7c4b9225a..709e6e86a 100644 --- a/src/case/button/node/node.icon.arrow.js +++ b/src/case/button/node/node.icon.arrow.js @@ -72,7 +72,7 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, { el: icon }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/node/node.last.plus.js b/src/case/button/node/node.last.plus.js index f299e5631..1c151c0a3 100644 --- a/src/case/button/node/node.last.plus.js +++ b/src/case/button/node/node.last.plus.js @@ -51,7 +51,7 @@ BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/node/node.mid.plus.js b/src/case/button/node/node.mid.plus.js index b3ceb3911..4abee1630 100644 --- a/src/case/button/node/node.mid.plus.js +++ b/src/case/button/node/node.mid.plus.js @@ -51,7 +51,7 @@ BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/node/node.multilayer.icon.arrow.js b/src/case/button/node/node.multilayer.icon.arrow.js index 2acde6abd..a1faecdc7 100644 --- a/src/case/button/node/node.multilayer.icon.arrow.js +++ b/src/case/button/node/node.multilayer.icon.arrow.js @@ -49,7 +49,7 @@ BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, { items.push(this.node); BI.createWidget({ type: "bi.td", - element: this.element, + element: this, columnSize: BI.makeArray(o.layer, 13), items: [items] }) diff --git a/src/case/button/node/node.plus.js b/src/case/button/node/node.plus.js index 48292a09c..07e6b2d20 100644 --- a/src/case/button/node/node.plus.js +++ b/src/case/button/node/node.plus.js @@ -47,7 +47,7 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/node/node.triangle.js b/src/case/button/node/node.triangle.js index 752a1c29a..99e1fd661 100644 --- a/src/case/button/node/node.triangle.js +++ b/src/case/button/node/node.triangle.js @@ -50,7 +50,7 @@ BI.TriangleGroupNode = BI.inherit(BI.NodeButton, { el: this.checkbox }, this.text); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/treeitem/item.first.treeleaf.js b/src/case/button/treeitem/item.first.treeleaf.js index 20e7da0c6..ea4e690de 100644 --- a/src/case/button/treeitem/item.first.treeleaf.js +++ b/src/case/button/treeitem/item.first.treeleaf.js @@ -60,7 +60,7 @@ BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/treeitem/item.icon.treeleaf.js b/src/case/button/treeitem/item.icon.treeleaf.js index 10a2dd60e..3872d851b 100644 --- a/src/case/button/treeitem/item.icon.treeleaf.js +++ b/src/case/button/treeitem/item.icon.treeleaf.js @@ -46,7 +46,7 @@ BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, { el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/treeitem/item.last.treeleaf.js b/src/case/button/treeitem/item.last.treeleaf.js index 90c22454a..60f879bfe 100644 --- a/src/case/button/treeitem/item.last.treeleaf.js +++ b/src/case/button/treeitem/item.last.treeleaf.js @@ -60,7 +60,7 @@ BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/treeitem/item.mid.treeleaf.js b/src/case/button/treeitem/item.mid.treeleaf.js index c3cd0280c..e6fad1a67 100644 --- a/src/case/button/treeitem/item.mid.treeleaf.js +++ b/src/case/button/treeitem/item.mid.treeleaf.js @@ -60,7 +60,7 @@ BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { el: this.text }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { items: items })))); diff --git a/src/case/button/treeitem/item.multilayer.icon.treeleaf.js b/src/case/button/treeitem/item.multilayer.icon.treeleaf.js index 85cef4f31..1cea15420 100644 --- a/src/case/button/treeitem/item.multilayer.icon.treeleaf.js +++ b/src/case/button/treeitem/item.multilayer.icon.treeleaf.js @@ -51,7 +51,7 @@ BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { items.push(this.item); BI.createWidget({ type: "bi.td", - element: this.element, + element: this, columnSize: BI.makeArray(o.layer, 13), items: [items] }); diff --git a/src/case/button/treeitem/item.treetextleaf.js b/src/case/button/treeitem/item.treetextleaf.js index 5c0d45b93..b23ef7421 100644 --- a/src/case/button/treeitem/item.treetextleaf.js +++ b/src/case/button/treeitem/item.treetextleaf.js @@ -34,7 +34,7 @@ BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, { }); BI.createWidget({ type: "bi.htape", - element: this.element, + element: this, items: [{ el: this.text }] diff --git a/src/case/calendar/calendar.js b/src/case/calendar/calendar.js index 697722db5..d0db00233 100644 --- a/src/case/calendar/calendar.js +++ b/src/case/calendar/calendar.js @@ -120,7 +120,7 @@ BI.Calendar = BI.inherit(BI.Widget, { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }) BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("top", title, this.days) diff --git a/src/case/calendar/calendar.year.js b/src/case/calendar/calendar.year.js index ebd31588e..9ecffe4e1 100644 --- a/src/case/calendar/calendar.year.js +++ b/src/case/calendar/calendar.year.js @@ -88,7 +88,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("top", this.years) diff --git a/src/case/canvas/canvas.complex.js b/src/case/canvas/canvas.complex.js index e334916e2..ea2529d25 100644 --- a/src/case/canvas/canvas.complex.js +++ b/src/case/canvas/canvas.complex.js @@ -18,7 +18,7 @@ BI.ComplexCanvas = BI.inherit(BI.Widget, { var o = this.options; this.canvas = BI.createWidget({ type: "bi.canvas", - element: this.element, + element: this, width: o.width, height: o.height }); diff --git a/src/case/chart/chart.combine.js b/src/case/chart/chart.combine.js deleted file mode 100644 index c531fdc13..000000000 --- a/src/case/chart/chart.combine.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * 图表控件 - * @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.element - }); - 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); \ No newline at end of file diff --git a/src/case/chart/factory.charts.js b/src/case/chart/factory.charts.js deleted file mode 100644 index 76b245a2c..000000000 --- a/src/case/chart/factory.charts.js +++ /dev/null @@ -1,289 +0,0 @@ -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], '#.##%') - } -}; \ No newline at end of file diff --git a/src/case/colorpicker/colorpicker.js b/src/case/colorpicker/colorpicker.js index 278b43c4f..b7025bb97 100644 --- a/src/case/colorpicker/colorpicker.js +++ b/src/case/colorpicker/colorpicker.js @@ -154,7 +154,7 @@ BI.ColorPicker = BI.inherit(BI.Widget, { var self = this, o = this.options; this.colors = BI.createWidget({ type: "bi.button_group", - element: this.element, + element: this, items: BI.createItems(o.items || this._items, { type: "bi.color_picker_button", once: false diff --git a/src/case/colorpicker/editor.colorpicker.js b/src/case/colorpicker/editor.colorpicker.js index ad8563a67..97e9a04a2 100644 --- a/src/case/colorpicker/editor.colorpicker.js +++ b/src/case/colorpicker/editor.colorpicker.js @@ -56,7 +56,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.htape", - element: this.element, + element: this, items: [{ el: this.colorShow, width: 'fill' diff --git a/src/case/editor/editor.record.js b/src/case/editor/editor.record.js index a44d1a80f..c4cd59331 100644 --- a/src/case/editor/editor.record.js +++ b/src/case/editor/editor.record.js @@ -116,7 +116,7 @@ BI.RecordEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.inline", - element: this.element, + element: this, items: [this.textContainer, this.editor] }); BI.Resizers.add(this.getName(), BI.bind(this._adjustInputWidth, this)); diff --git a/src/case/editor/editor.shelter.js b/src/case/editor/editor.shelter.js index 3b08a3290..b2b78f00b 100644 --- a/src/case/editor/editor.shelter.js +++ b/src/case/editor/editor.shelter.js @@ -55,7 +55,7 @@ BI.ShelterEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -126,7 +126,7 @@ BI.ShelterEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); diff --git a/src/case/editor/editor.sign.js b/src/case/editor/editor.sign.js index 6ee3e9f9a..2691cba9a 100644 --- a/src/case/editor/editor.sign.js +++ b/src/case/editor/editor.sign.js @@ -64,7 +64,7 @@ BI.SignEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -128,7 +128,7 @@ BI.SignEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); diff --git a/src/case/editor/editor.state.js b/src/case/editor/editor.state.js index f830b5ee2..26e75d7bb 100644 --- a/src/case/editor/editor.state.js +++ b/src/case/editor/editor.state.js @@ -65,7 +65,7 @@ BI.StateEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -127,7 +127,7 @@ BI.StateEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); diff --git a/src/case/editor/editor.state.simple.js b/src/case/editor/editor.state.simple.js index 112bf0288..9f2007d0b 100644 --- a/src/case/editor/editor.state.simple.js +++ b/src/case/editor/editor.state.simple.js @@ -65,7 +65,7 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { }); BI.createWidget({ type: "bi.absolute", - element: this.element, + element: this, items: [{ el: this.text, left: 0, @@ -127,7 +127,7 @@ BI.SimpleStateEditor = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.vertical", scrolly: false, - element: this.element, + element: this, items: [this.editor] }); this._showHint(); diff --git a/src/case/expander/expander.branch.handstand.js b/src/case/expander/expander.branch.handstand.js index e86f0e3e1..cce5e1400 100644 --- a/src/case/expander/expander.branch.handstand.js +++ b/src/case/expander/expander.branch.handstand.js @@ -23,7 +23,7 @@ BI.HandStandBranchExpander = BI.inherit(BI.Widget, { this._initExpander(); this._initBranchView(); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, { type: "bi.center_adapt", diff --git a/src/case/expander/expander.branch.js b/src/case/expander/expander.branch.js index d2f5fd5a7..6dec2188a 100644 --- a/src/case/expander/expander.branch.js +++ b/src/case/expander/expander.branch.js @@ -22,7 +22,7 @@ BI.BranchExpander = BI.inherit(BI.Widget, { this._initExpander(); this._initBranchView(); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.expander, this.branchView) })))); diff --git a/src/case/layer/pane.list.js b/src/case/layer/pane.list.js index 27dbd9a9f..4267917f5 100644 --- a/src/case/layer/pane.list.js +++ b/src/case/layer/pane.list.js @@ -67,7 +67,7 @@ BI.ListPane = BI.inherit(BI.Pane, { this.check(); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({ scrolly: true, lgap: o.lgap, diff --git a/src/case/layer/panel.js b/src/case/layer/panel.js index dc25c8bc2..9f91402ff 100644 --- a/src/case/layer/panel.js +++ b/src/case/layer/panel.js @@ -21,7 +21,7 @@ BI.Panel = BI.inherit(BI.Widget,{ var o = this.options; BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { items: BI.LogicFactory.createLogicItemsByDirection("top", this._createTitle() ,this.options.el) diff --git a/src/case/list/list.select.js b/src/case/list/list.select.js index 97bbd42a0..8b97dd9f3 100644 --- a/src/case/list/list.select.js +++ b/src/case/list/list.select.js @@ -68,7 +68,7 @@ BI.SelectList = BI.inherit(BI.Widget, { }); BI.createWidget(BI.extend({ - element: this.element + element: this }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ scrolly: true }, o.logic, { diff --git a/src/case/loader/loader.lazy.js b/src/case/loader/loader.lazy.js index 451881709..ace22d6de 100644 --- a/src/case/loader/loader.lazy.js +++ b/src/case/loader/loader.lazy.js @@ -15,7 +15,7 @@ BI.LazyLoader = BI.inherit(BI.Widget, { var all = o.items.length; this.loader = BI.createWidget({ type: "bi.loader", - element: this.element, + element: this, //下面是button_group的属性 el: o.el, diff --git a/src/case/loader/loader.list.js b/src/case/loader/loader.list.js index c1e9b0617..88d95fd92 100644 --- a/src/case/loader/loader.list.js +++ b/src/case/loader/loader.list.js @@ -46,7 +46,7 @@ BI.ListLoader = BI.inherit(BI.Widget, { this.button_group = BI.createWidget(o.el, { type: "bi.button_group", - element: this.element, + element: this, chooseType: 0, items: o.items, behaviors: {}, @@ -74,7 +74,7 @@ BI.ListLoader = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.vertical", - element: this.element, + element: this, items: [this.next] }); diff --git a/src/case/loader/sort.list.js b/src/case/loader/sort.list.js index a8db91877..597d52b44 100644 --- a/src/case/loader/sort.list.js +++ b/src/case/loader/sort.list.js @@ -35,7 +35,7 @@ BI.SortList = BI.inherit(BI.Widget, { var self = this, o = this.options; this.loader = BI.createWidget({ type: "bi.list_loader", - element: this.element, + element: this, isDefaultInit: o.isDefaultInit, el: o.el, items: this._formatItems(o.items), diff --git a/src/case/pager/pager.all.js b/src/case/pager/pager.all.js index 62aa0ec21..16741bd10 100644 --- a/src/case/pager/pager.all.js +++ b/src/case/pager/pager.all.js @@ -91,7 +91,7 @@ BI.AllPagger = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, columnSize: [30, "", 36], items: [this.editor, this.allPages, this.pager] }) diff --git a/src/case/pager/pager.direction.js b/src/case/pager/pager.direction.js index 65221a9e3..4cbfd156a 100644 --- a/src/case/pager/pager.direction.js +++ b/src/case/pager/pager.direction.js @@ -41,7 +41,7 @@ BI.DirectionPager = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.absolute", scrollable: false, - element: this.element, + element: this, items: [{ el: this.vpager, top: 0, diff --git a/src/case/pager/pager.number.js b/src/case/pager/pager.number.js index 4dfd57923..02607345e 100644 --- a/src/case/pager/pager.number.js +++ b/src/case/pager/pager.number.js @@ -85,7 +85,7 @@ BI.NumberPager = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, columnSize: [20, "", 20, 36], items: [{type: "bi.label", text: "第"}, this.label, {type: "bi.label", text: "页"}, this.pager] }) diff --git a/src/case/pager/pager.skip.js b/src/case/pager/pager.skip.js index a2b087969..b43ba5ae6 100644 --- a/src/case/pager/pager.skip.js +++ b/src/case/pager/pager.skip.js @@ -90,7 +90,7 @@ BI.SkipPager = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.center_adapt", - element: this.element, + element: this, items: [{type: "bi.label", text: "第"}, this.editor, {type: "bi.label", text: "页"}, this.pager] }) }, diff --git a/src/case/segment/button.segment.js b/src/case/segment/button.segment.js index c59c1cf9d..071551f9c 100644 --- a/src/case/segment/button.segment.js +++ b/src/case/segment/button.segment.js @@ -25,7 +25,7 @@ BI.SegmentButton = BI.inherit(BI.BasicButton, { //} this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, height: opts.height-2, whiteSpace: opts.whiteSpace, text: opts.text, diff --git a/src/case/segment/segment.js b/src/case/segment/segment.js index ad91a5518..750b35a57 100644 --- a/src/case/segment/segment.js +++ b/src/case/segment/segment.js @@ -17,7 +17,7 @@ BI.Segment = BI.inherit(BI.Widget, { BI.Segment.superclass._init.apply(this, arguments); var self = this, o = this.options; this.buttonGroup = BI.createWidget({ - element: this.element, + element: this, type: "bi.button_group", items: BI.createItems(o.items, { type: "bi.segment_button", diff --git a/src/case/table/table.dynamicsummarylayertree.js b/src/case/table/table.dynamicsummarylayertree.js index f4f33a137..31f5af1f5 100644 --- a/src/case/table/table.dynamicsummarylayertree.js +++ b/src/case/table/table.dynamicsummarylayertree.js @@ -134,7 +134,7 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { var items = this._formatItems(o.items, deep); this.table = BI.createWidget({ type: "bi.table_view", - element: this.element, + element: this, logic: o.logic, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, diff --git a/src/case/table/table.dynamicsummarytree.js b/src/case/table/table.dynamicsummarytree.js index a859de641..b03f1f94c 100644 --- a/src/case/table/table.dynamicsummarytree.js +++ b/src/case/table/table.dynamicsummarytree.js @@ -78,7 +78,7 @@ BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { items = BI.DynamicSummaryTreeTable.formatSummaryItems(items, o.crossItems, deep); this.table = BI.createWidget({ type: "bi.table_view", - element: this.element, + element: this, logic: o.logic, isNeedResize: o.isNeedResize, diff --git a/src/case/table/table.layertree.cell.js b/src/case/table/table.layertree.cell.js index 324f3e54c..50ba6812c 100644 --- a/src/case/table/table.layertree.cell.js +++ b/src/case/table/table.layertree.cell.js @@ -17,7 +17,7 @@ BI.LayerTreeTableCell = BI.inherit(BI.Widget, { var o = this.options; BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "left", whiteSpace: "nowrap", height: o.height, diff --git a/src/case/table/table.layertree.js b/src/case/table/table.layertree.js index af51758f9..f2d79940d 100644 --- a/src/case/table/table.layertree.js +++ b/src/case/table/table.layertree.js @@ -134,7 +134,7 @@ BI.LayerTreeTable = BI.inherit(BI.Widget, { var items = this._formatItems(o.items); this.table = BI.createWidget({ type: "bi.table_view", - element: this.element, + element: this, logic: o.logic, isNeedResize: o.isNeedResize, isResizeAdapt: o.isResizeAdapt, diff --git a/src/case/table/tabler.js b/src/case/table/tabler.js index 03e28933a..42615420d 100644 --- a/src/case/table/tabler.js +++ b/src/case/table/tabler.js @@ -62,7 +62,7 @@ BI.Tabler = BI.inherit(BI.Widget, { }) BI.createWidget({ type: "bi.vtape", - element: this.element, + element: this, items: [{ el: this.container }, { diff --git a/src/case/tip/tip.bubble.js b/src/case/tip/tip.bubble.js index ae2605376..50987489a 100644 --- a/src/case/tip/tip.bubble.js +++ b/src/case/tip/tip.bubble.js @@ -24,7 +24,7 @@ BI.Bubble = BI.inherit(BI.Tip, { this.element.bind({"click": fn, "mousedown": fn, "mouseup": fn, "mouseover": fn, "mouseenter": fn, "mouseleave": fn, "mousemove": fn}); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: [this["_" + this.options.direction]()] }) }, diff --git a/src/case/tip/tip.toast.js b/src/case/tip/tip.toast.js index 02fd448d9..727f892dd 100644 --- a/src/case/tip/tip.toast.js +++ b/src/case/tip/tip.toast.js @@ -35,7 +35,7 @@ BI.Toast = BI.inherit(BI.Tip, { this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, text: o.text, height: 30, hgap: this._const.hgap diff --git a/src/case/tip/tip.tooltip.js b/src/case/tip/tip.tooltip.js index 2c1ffb6f5..6746ce544 100644 --- a/src/case/tip/tip.tooltip.js +++ b/src/case/tip/tip.tooltip.js @@ -31,7 +31,7 @@ BI.Tooltip = BI.inherit(BI.Tip, { this.text = BI.createWidget({ type: "bi.label", - element: this.element, + element: this, textAlign: "left", whiteSpace: "normal", text: o.text, diff --git a/src/case/toolbar/toolbar.multiselect.js b/src/case/toolbar/toolbar.multiselect.js index b85b96040..789081a37 100644 --- a/src/case/toolbar/toolbar.multiselect.js +++ b/src/case/toolbar/toolbar.multiselect.js @@ -63,7 +63,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }); BI.createWidget({ type: "bi.htape", - element: this.element, + element: this, items: [{ width: 36, el: { diff --git a/src/case/tree/tree.branch.handstand.js b/src/case/tree/tree.branch.handstand.js index 191f710f4..02b29c01b 100644 --- a/src/case/tree/tree.branch.handstand.js +++ b/src/case/tree/tree.branch.handstand.js @@ -18,7 +18,7 @@ BI.HandStandBranchTree = BI.inherit(BI.Widget, { var self = this, o = this.options; this.branchTree = BI.createWidget({ type: "bi.custom_tree", - element: this.element, + element: this, expander: BI.extend({ type: "bi.handstand_branch_expander", el: {}, diff --git a/src/case/tree/tree.branch.js b/src/case/tree/tree.branch.js index 1a07edd94..d7af2226d 100644 --- a/src/case/tree/tree.branch.js +++ b/src/case/tree/tree.branch.js @@ -18,7 +18,7 @@ BI.BranchTree = BI.inherit(BI.Widget, { var self = this, o = this.options; this.branchTree = BI.createWidget({ type: "bi.custom_tree", - element: this.element, + element: this, expander: BI.extend({ type: "bi.branch_expander", el: {}, diff --git a/src/case/tree/tree.level.js b/src/case/tree/tree.level.js index 52980fec5..c6c213ab5 100644 --- a/src/case/tree/tree.level.js +++ b/src/case/tree/tree.level.js @@ -72,7 +72,7 @@ BI.LevelTree = BI.inherit(BI.Widget, { this._assertId(nodes); this.tree = BI.createWidget({ type: "bi.custom_tree", - element: this.element, + element: this, expander: BI.extend({ el: {}, popup: { diff --git a/src/case/tree/tree.simple.js b/src/case/tree/tree.simple.js index 1cc837f18..6b4f1c2cb 100644 --- a/src/case/tree/tree.simple.js +++ b/src/case/tree/tree.simple.js @@ -19,7 +19,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, { this.structure = new BI.Tree(); this.tree = BI.createWidget({ type: "bi.tree", - element: this.element, + element: this, itemsCreator: function (op, callback) { var fn = function (items) { callback({ diff --git a/src/case/trigger/trigger.editor.js b/src/case/trigger/trigger.editor.js index 14e9e5794..5c78215c5 100644 --- a/src/case/trigger/trigger.editor.js +++ b/src/case/trigger/trigger.editor.js @@ -47,7 +47,7 @@ BI.EditorTrigger = BI.inherit(BI.Trigger, { }); BI.createWidget({ - element: this.element, + element: this, type: 'bi.htape', items: [ { diff --git a/src/case/trigger/trigger.icon.js b/src/case/trigger/trigger.icon.js index b3b96802f..330ca2703 100644 --- a/src/case/trigger/trigger.icon.js +++ b/src/case/trigger/trigger.icon.js @@ -19,7 +19,7 @@ BI.IconTrigger = BI.inherit(BI.Trigger, { BI.IconTrigger.superclass._init.apply(this, arguments); this.iconButton = BI.createWidget(o.el, { type: "bi.trigger_icon_button", - element: this.element, + element: this, width: o.width, height: o.height }); diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index 6a46d7cbb..d8a1a9857 100644 --- a/src/case/trigger/trigger.text.js +++ b/src/case/trigger/trigger.text.js @@ -35,7 +35,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { }); BI.createWidget({ - element: this.element, + element: this, type: 'bi.htape', items: [ { diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 2cce8dd90..5eec3ac3e 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -20,7 +20,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { var self = this, o = this.options; this.trigger = BI.createWidget({ type: "bi.text_trigger", - element: this.element, + element: this, height: o.height }); if (BI.isKey(o.text)) { diff --git a/src/case/trigger/trigger.text.select.small.js b/src/case/trigger/trigger.text.select.small.js index d78af084d..dc38eda39 100644 --- a/src/case/trigger/trigger.text.select.small.js +++ b/src/case/trigger/trigger.text.select.small.js @@ -19,7 +19,7 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, { var self = this, o = this.options; this.trigger = BI.createWidget({ type: "bi.small_text_trigger", - element: this.element, + element: this, height: o.height - 2 }); if (BI.isKey(o.text)) { diff --git a/src/case/trigger/trigger.text.small.js b/src/case/trigger/trigger.text.small.js index 8e661a8b8..f6a4c3863 100644 --- a/src/case/trigger/trigger.text.small.js +++ b/src/case/trigger/trigger.text.small.js @@ -34,7 +34,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, { }); BI.createWidget({ - element: this.element, + element: this, type: 'bi.htape', items: [ { diff --git a/src/config.js b/src/config.js index a6b62ffac..72a1fdf2a 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/ob.js b/src/core/ob.js index 4e768c9bc..700007636 100644 --- a/src/core/ob.js +++ b/src/core/ob.js @@ -4,15 +4,28 @@ * @abstract */ BI.OB = function (config) { - this.options = $.extend(this._defaultConfig(), config); + this.options = $.extend(this._defaultConfig(config), config); this._init(); - this._confirmEvents(); }; $.extend(BI.OB.prototype, { - _defaultConfig: function () { - return {}; + props: {}, + init: function () { }, + + _defaultConfig: function (config) { + if (BI.isFunction(this.props)) { + return this.props(config); + } + return this.props; + }, + _init: function () { + this._initListeners(); + this._initRef(); + this.init(); + }, + + _initListeners: function () { var self = this; if (this.options.listeners != null) { $.each(this.options.listeners, function (i, lis) { @@ -23,22 +36,22 @@ $.extend(BI.OB.prototype, { } }, - _confirmEvents: function () { - this.fireEvent(BI.Events.AFTERINIT); + //获得一个当前对象的引用 + _initRef: function () { + if (this.options.ref) { + this.options.ref.call(this, this); + } }, _getEvents: function () { if (!$.isArray(this.events)) { this.events = [] } - return this.events; }, /** * 给观察者绑定一个事件 - * e.g. 给填报页面添加一个提交失败事件:contentPane.on(BI.Events.WF, function() {alert("填报失败!");}); - * 给文本框控件p1添加一个初始化后事件:p1.on(BI.Evnets.AFTERINIT, function() {alert("初始化完成!");}); * @param {String} eventName 事件的名字 * @param {Function} fn 事件对应的执行函数 */ @@ -104,11 +117,19 @@ $.extend(BI.OB.prototype, { fireEvent: function () { var eventName = arguments[0].toLowerCase(); var fns = this._getEvents()[eventName]; - if ($.isArray(fns)) { - var args = Array.prototype.slice.call(arguments, 1) - for (var i = 0; i < fns.length; i++) { - if (fns[i].apply(this, args) === false) { - return false; + if (BI.isArray(fns)) { + if (BI.isArguments(arguments[1])) { + for (var i = 0; i < fns.length; i++) { + if (fns[i].apply(this, arguments[1]) === false) { + return false; + } + } + } else { + var args = Array.prototype.slice.call(arguments, 1); + for (var i = 0; i < fns.length; i++) { + if (fns[i].apply(this, args) === false) { + return false; + } } } } diff --git a/src/core/shortcut.js b/src/core/shortcut.js index f4c1aa0b3..265dd8a26 100644 --- a/src/core/shortcut.js +++ b/src/core/shortcut.js @@ -1,7 +1,7 @@ (function ($) { var kv = {}; // alex:键(编辑器简称,如text)值(也是一个字符串,如FR.TextEditor)对 - $.shortcut = function (xtype, cls) { + $.shortcut = BI.shortcut = function (xtype, cls) { if (kv[xtype] != null) { throw ("shortcut:[" + xtype + "] has been registed"); } diff --git a/src/core/view.js b/src/core/view.js index 8b714749e..0883a9da6 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -126,7 +126,7 @@ BI.View = BI.inherit(BI.V, { _vessel: function () { this._cardLayouts = {}; this._cardLayouts[this.getName()] = new BI.CardLayout({ - element: this.element + element: this }); var vessel = BI.createWidget(); this._cardLayouts[this.getName()].addCardByName(this.getName(), vessel); diff --git a/src/core/widget.js b/src/core/widget.js index f373bb2bf..1b151fbc9 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -7,42 +7,54 @@ */ BI.Widget = BI.inherit(BI.OB, { _defaultConfig: function () { - return BI.extend(BI.Widget.superclass._defaultConfig.apply(this, arguments), { + return BI.extend({ tagName: "div", - attributes: {}, - data: {}, + attributes: null, + data: null, tag: null, - widgetName: "", disabled: false, invisible: false, invalid: false, baseCls: "", - extraCls: "", cls: "" - }) + }, BI.Widget.superclass._defaultConfig.call(this)) }, - _initOpts: function () { + //生命周期函数 + beforeCreated: function () { + + }, + + created: function () { + + }, + + render: function () { + + }, + + beforeMounted: function () { + + }, + + mounted: function () { + + }, + + destroyed: function () { }, _init: function () { - var o = this.options; - this._initOpts() - BI.isWidget(o.element) && (o.element = o.element.element); - BI.isString(o.element) && (o.element = $(o.element)); - o.renderEl || (o.renderEl = o.element); - o.element || (o.element = o.renderEl); - o.element || (o.renderEl = o.element = $(document.createElement(o.tagName))); - this.widgetName = o.widgetName || (o.widgetName = BI.uniqueId("widget")); + BI.Widget.superclass._init.apply(this, arguments); + this.beforeCreated(); this._initRoot(); this._initElementWidth(); this._initElementHeight(); this._initVisualEffects(); - o.extraCls && this.element.addClass(o.extraCls); - o.cls && this.element.addClass(o.cls); - this.element.attr(o.attributes).data(o.data); - this.widgets = {};//保存子组件 + this._initState(); + this._initElement(); + this.created(); }, /** @@ -50,14 +62,31 @@ BI.Widget = BI.inherit(BI.OB, { * @private */ _initRoot: function () { - if (this.options.renderEl != null) { - this.element = $(this.options.renderEl); + var o = this.options; + this.widgetName = o.widgetName || BI.uniqueId("widget"); + if (BI.isWidget(o.element)) { + this._parent = o.element; + this._parent.addWidget(this.widgetName, this); + this.element = this.options.element.element; + } else if (BI.isString(o.element)) { + this.element = $(o.element); + this._isRoot = true; } else { - this.element = this._defaultRoot(); + this.element = $(document.createElement(o.tagName)); + } + if (o.baseCls) { + this.element.addClass(o.baseCls); + } + if (o.cls) { + this.element.addClass(o.cls); } - if (this.options.baseCls) { - this.element.addClass(this.options.baseCls); + if (o.attributes) { + this.element.attr(o.attributes); } + if (o.data) { + this.element.data(o.data); + } + this._children = {}; }, _initElementWidth: function () { @@ -75,42 +104,90 @@ BI.Widget = BI.inherit(BI.OB, { }, _initVisualEffects: function () { - if (this.options.diabled || this.options.invalid) { - BI.nextTick(BI.bind(function () { - if (this.options.disabled) { - this.setEnable(false); - } - if (this.options.invalid) { - this.setValid(false); - } - }, this)); + var o = this.options; + if (o.invisible) { + this.element.hide(); + } + if (o.disabled) { + this.element.addClass("base-disabled disabled"); + } + if (o.invalid) { + this.element.addClass("base-invalid invalid"); + } + }, + + _initState: function () { + this._isMounted = false; + }, + + _initElement: function () { + var self = this; + var els = this.render(); + if (BI.isPlainObject(els)) { + els = [els]; } + if (BI.isArray(els)) { + BI.each(els, function (i, el) { + BI.createWidget(el, { + element: self + }) + }) + } + if (this._isRoot === true) { + this._mount(); + } + }, - if (this.options.invisible) { - this.setVisible(false); + _setParent: function (parent) { + this._parent = parent; + }, + + _mount: function () { + var self = this; + var isMounted = this._isMounted; + if (isMounted) { + return; + } + if (this._isRoot === true) { + isMounted = true; + } else if (this._parent && this._parent._isMounted === true) { + isMounted = true; } + if (!isMounted) { + return; + } + this.beforeMounted(); + this._isMounted = true; + this._mountChildren(); + BI.each(this._children, function (i, widget) { + widget._mount(); + }); + this.mounted(); }, - fireEvent: function () { - var eventName = arguments[0].toLowerCase(); - var fns = this._getEvents()[eventName]; - if (BI.isArray(fns)) { - if (BI.isArguments(arguments[1])) { - for (var i = 0; i < fns.length; i++) { - if (fns[i].apply(this, arguments[1]) === false) { - return false; - } - } - } else { - var args = Array.prototype.slice.call(arguments, 1); - for (var i = 0; i < fns.length; i++) { - if (fns[i].apply(this, args) === false) { - return false; - } - } + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; } + }); + if (hasChild === true) { + this.element.append(frag); } - return true; + }, + + _unMount: function () { + BI.each(this._children, function (i, widget) { + widget._unMount(); + }); + this._children = []; + this._parent = null; + this._isMounted = false; + this.destroyed(); }, setWidth: function (w) { @@ -123,16 +200,7 @@ BI.Widget = BI.inherit(BI.OB, { this._initElementHeight(); }, - setElement: function (widget) { - if (widget == this) { - return; - } - this.element = BI.isWidget(widget) ? widget.element : $(widget); - return this; - }, - setEnable: function (enable) { - BI.assert(enable, [true, false]); if (enable === true) { this.options.disabled = false; this.element.removeClass("base-disabled disabled"); @@ -143,7 +211,6 @@ BI.Widget = BI.inherit(BI.OB, { }, setVisible: function (visible) { - // BI.assert(visible, [true, false]); if (visible === true) { this.options.invisible = false; this.element.show(); @@ -151,11 +218,9 @@ BI.Widget = BI.inherit(BI.OB, { this.options.invisible = true; this.element.hide(); } - this.fireEvent(BI.Events.VIEW, visible); }, setValid: function (valid) { - // BI.assert(valid, [true, false]); this.options.invalid = !valid; if (valid === true) { this.element.removeClass("base-invalid invalid"); @@ -176,32 +241,21 @@ BI.Widget = BI.inherit(BI.OB, { return !this.options.invalid; }, - valid: function () { - this.setValid(true); - }, - - invalid: function () { - this.setValid(false); - }, - addWidget: function (name, widget) { var self = this; if (name instanceof BI.Widget) { widget = name; name = widget.getName(); } - if (!BI.isKey(name)) { - throw new Error("name cannot be null"); - } - name = BI.isKey(name) ? (name + "") : ""; - name = name || widget.getName() || BI.UUID(); - if (this.widgets[name]) { + name = name || widget.getName() || BI.uniqueId("widget"); + if (this._children[name]) { throw new Error("name has already been existed"); } + widget._setParent(this); widget.on(BI.Events.DESTROY, function () { - delete self.widgets[name] + delete self._children[name] }); - return (this.widgets[name] = widget); + return (this._children[name] = widget); }, getWidgetByName: function (name) { @@ -210,7 +264,7 @@ BI.Widget = BI.inherit(BI.OB, { } name = name + ""; var widget = void 0, other = {}; - BI.any(this.widgets, function (i, wi) { + BI.any(this._children, function (i, wi) { if (i === name) { widget = wi; return true; @@ -225,26 +279,16 @@ BI.Widget = BI.inherit(BI.OB, { return widget; }, - hasWidget: function (name) { - return this.widgets[name] != null; - }, - - getWidgets: function () { - return this.widgets; + removeWidget: function (name) { + delete this._children[name]; }, - getValidWidgets: function () { - var widgets = []; - BI.each(this.widgets, function (i, wi) { - if (wi.isValid()) { - widgets.push(wi); - } - }); - return widgets; + hasWidget: function (name) { + return this._children[name] != null; }, getName: function () { - return this.options.widgetName; + return this.widgetName; }, setTag: function (tag) { @@ -274,12 +318,8 @@ BI.Widget = BI.inherit(BI.OB, { }, - setValue: function (value, shouldFireEvent) { - - }, + setValue: function (value) { - getType: function () { - return this.options.type; }, isEnabled: function () { @@ -290,57 +330,9 @@ BI.Widget = BI.inherit(BI.OB, { return !this.options.invisible; }, - render: function () { - this.element.append(this.hang()); - return this; - }, - - hang: function () { - return BI.DOM.hang(BI.trans2Element(this.widgets)); - }, - - clear: function () { - this.hang(); - this.element.empty(); - this.widgets = {}; - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); - }); - this.element.empty(); - this.widgets = {}; - }, - destroy: function () { - this.empty(); - this.element.each(function () { - $(this).remove(); - if (BI.isIE()) { - this.outerHTML = ''; - } - }); + this._unMount(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); - }, - - _defaultRoot: function () { - return $("
"); - }, - - disable: function () { - this.setEnable(false); - }, - - enable: function () { - this.setEnable(true); - }, - - invisible: function () { - this.setVisible(false); - }, - - visible: function () { - this.setVisible(true); } }); \ No newline at end of file diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 4bb47b32b..7c06d68c4 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -9,24 +9,20 @@ * @cfg {Boolean} [options.scrolly=false] 子组件超出容器边界之后是否会出现纵向滚动条 */ BI.Layout = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.Layout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return { scrollable: null, //true, false, null scrollx: false, //true, false scrolly: false, //true, false items: [] - }); + }; }, - _init: function () { - BI.Layout.superclass._init.apply(this, arguments); + + created: function () { this._init4Margin(); this._init4Scroll(); }, - /** - * 初始化布局与外层容器的边间距 - * @private - */ _init4Margin: function () { if (this.options.top) { this.element.css('top', this.options.top); @@ -42,10 +38,6 @@ BI.Layout = BI.inherit(BI.Widget, { } }, - /** - * 初始化布局的滚动形态 - * @private - */ _init4Scroll: function () { switch (this.options.scrollable) { case true: @@ -94,12 +86,8 @@ BI.Layout = BI.inherit(BI.Widget, { populate: function (items) { var self = this; - this.reset(items); - this.stroke(items); - }, - - reset: function (items) { this.options.items = items || []; + this.stroke(items); }, resize: function () { @@ -112,6 +100,7 @@ BI.Layout = BI.inherit(BI.Widget, { */ addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); w.element.appendTo(this.element); return w; @@ -124,40 +113,26 @@ BI.Layout = BI.inherit(BI.Widget, { }) }, - getValue: function (name) { - if (name) { - return this.getWidgetByName(name).getValue(); - } + getValue: function () { var value = []; - BI.each(this.widgets, function (i, wi) { - var v = wi.getValue(name); + BI.each(this._children, function (i, wi) { + var v = wi.getValue(); v = BI.isArray(v) ? v : [v]; value = value.concat(v); }); return value; }, - setValue: function (v, name) { - if (name) { - return this.getWidgetByName(name).setValue(v); - } - BI.each(this.widgets, function (i, wi) { + setValue: function (v) { + BI.each(this._children, function (i, wi) { wi.setValue(v); }) }, - setText: function (v, name) { - if (name) { - return this.getWidgetByName(name).setText(v); - } - BI.each(this.widgets, function (i, wi) { + setText: function (v) { + BI.each(this._children, function (i, wi) { wi.setText(v); }) - }, - - empty: function () { - BI.Layout.superclass.empty.apply(this, arguments); - this.reset(); } }); $.shortcut('bi.layout', BI.Layout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/absolute.center.js b/src/core/wrapper/layout/adapt/absolute.center.js index c7aebd58e..8c1d8a9a7 100644 --- a/src/core/wrapper/layout/adapt/absolute.center.js +++ b/src/core/wrapper/layout/adapt/absolute.center.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-center-layout", hgap: 0, lgap: 0, @@ -16,8 +16,8 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.AbsoluteCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -41,7 +41,7 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteCenterLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute_center_adapt', BI.AbsoluteCenterLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/absolute.horizontal.js b/src/core/wrapper/layout/adapt/absolute.horizontal.js index 4f4206055..67b12302f 100644 --- a/src/core/wrapper/layout/adapt/absolute.horizontal.js +++ b/src/core/wrapper/layout/adapt/absolute.horizontal.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-horizontal-layout", hgap: 0, lgap: 0, @@ -16,8 +16,8 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.AbsoluteHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteHorizontalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -45,7 +45,7 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteHorizontalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute_horizontal_adapt', BI.AbsoluteHorizontalLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/absolute.vertical.js b/src/core/wrapper/layout/adapt/absolute.vertical.js index f970341d0..c0192fdc3 100644 --- a/src/core/wrapper/layout/adapt/absolute.vertical.js +++ b/src/core/wrapper/layout/adapt/absolute.vertical.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteVerticalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteVerticalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-vertical-layout", hgap: 0, lgap: 0, @@ -16,8 +16,8 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.AbsoluteVerticalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteVerticalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -47,7 +47,7 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteVerticalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute_vertical_adapt', BI.AbsoluteVerticalLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/adapt.center.js b/src/core/wrapper/layout/adapt/adapt.center.js index 23148b99f..abc0e09b2 100644 --- a/src/core/wrapper/layout/adapt/adapt.center.js +++ b/src/core/wrapper/layout/adapt/adapt.center.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.CenterAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.CenterAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-center-adapt-layout", columnSize: [], hgap: 0, @@ -16,14 +16,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.CenterAdaptLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + created: function () { + BI.CenterAdaptLayout.superclass.created.apply(this, arguments); + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "width": "100%", "height": "100%", @@ -31,12 +26,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -95,25 +87,20 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); - } - return this; - }, - - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } }); - this.widgets = {}; - this.tr.empty(); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); + } }, resize: function () { @@ -122,14 +109,15 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.tr.element); + w.element.appendTo(this.$tr); return w; }, populate: function (items) { BI.CenterAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.center_adapt', BI.CenterAdaptLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/adapt.horizontal.js b/src/core/wrapper/layout/adapt/adapt.horizontal.js index da49f831d..9e2a9ad4f 100644 --- a/src/core/wrapper/layout/adapt/adapt.horizontal.js +++ b/src/core/wrapper/layout/adapt/adapt.horizontal.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-adapt-layout", verticalAlign: BI.VerticalAlign.Middle, columnSize: [], @@ -17,26 +17,18 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalAdaptLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + created: function () { + BI.HorizontalAdaptLayout.superclass.created.apply(this, arguments); + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "width": "100%", "white-space": "nowrap", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -94,24 +86,20 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); - } - }, - - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } }); - this.widgets = {}; - this.tr.empty(); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); + } }, resize: function () { @@ -120,14 +108,15 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.tr.element); + w.element.appendTo(this.$tr); return w; }, populate: function (items) { BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal_adapt', BI.HorizontalAdaptLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js b/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js index 463758f02..a5a5dbab8 100644 --- a/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js +++ b/src/core/wrapper/layout/adapt/adapt.leftrightvertical.js @@ -8,8 +8,8 @@ * @extends BI.Layout */ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-left-right-vertical-adapt-layout", items: {}, llgap: 0, @@ -20,8 +20,8 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { rhgap: 0 }); }, - _init: function () { - BI.LeftRightVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.LeftRightVerticalAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -47,10 +47,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { left.element.css("height", "100%"); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: [left] }); - this.addWidget(left); } if ("right" in items) { var right = BI.createWidget({ @@ -63,10 +62,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { right.element.css("height", "100%"); BI.createWidget({ type: "bi.right", - element: this.element, + element: this, items: [right] }); - this.addWidget(right); } }, @@ -78,8 +76,8 @@ $.shortcut('bi.left_right_vertical_adapt', BI.LeftRightVerticalAdaptLayout); BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-left-vertical-adapt-layout", items: [], lgap: 0, @@ -87,8 +85,8 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { hgap: 0 }); }, - _init: function () { - BI.LeftVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.LeftVerticalAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -114,17 +112,17 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { left.element.css("height", "100%"); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: [left] }); - this.addWidget(left); + this._mount(); } }); $.shortcut('bi.left_vertical_adapt', BI.LeftVerticalAdaptLayout); BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.RightVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.RightVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-right-vertical-adapt-layout", items: [], lgap: 0, @@ -132,8 +130,8 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { hgap: 0 }); }, - _init: function () { - BI.RightVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.RightVerticalAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -159,10 +157,10 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { right.element.css("height", "100%"); BI.createWidget({ type: "bi.right", - element: this.element, + element: this, items: [right] }); - this.addWidget(right); + this._mount(); } }); $.shortcut('bi.right_vertical_adapt', BI.RightVerticalAdaptLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/adapt.vertical.js b/src/core/wrapper/layout/adapt/adapt.vertical.js index 9d0d5bd12..98ab83db5 100644 --- a/src/core/wrapper/layout/adapt/adapt.vertical.js +++ b/src/core/wrapper/layout/adapt/adapt.vertical.js @@ -18,24 +18,16 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { }, _init: function () { BI.VerticalAdaptLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "height": "100%", "white-space": "nowrap", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -94,24 +86,28 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); } }, - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); - }, - - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); - }); - this.widgets = {}; - this.tr.empty(); + addItem: function (item) { + var w = this._addElement(this.options.items.length, item); + w._mount(); + this.options.items.push(item); + w.element.appendTo(this.$tr); + return w; }, resize: function () { @@ -120,7 +116,7 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VerticalAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.vertical_adapt', BI.VerticalAdaptLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/auto.horizontal.js b/src/core/wrapper/layout/adapt/auto.horizontal.js index e4c5c7dc9..1c37921c3 100644 --- a/src/core/wrapper/layout/adapt/auto.horizontal.js +++ b/src/core/wrapper/layout/adapt/auto.horizontal.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalAutoLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalAutoLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizon-auto-layout", hgap: 0, lgap: 0, @@ -16,8 +16,8 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.HorizontalAutoLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HorizontalAutoLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -57,7 +57,7 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal_auto', BI.HorizontalAutoLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/float.center.js b/src/core/wrapper/layout/adapt/float.center.js index b151baaea..262b603e6 100644 --- a/src/core/wrapper/layout/adapt/float.center.js +++ b/src/core/wrapper/layout/adapt/float.center.js @@ -2,8 +2,8 @@ * 浮动的居中布局 */ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatCenterAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatCenterAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-center-adapt-layout", items: [], hgap: 0, @@ -14,8 +14,8 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { rgap: 0 }); }, - _init: function () { - BI.FloatCenterAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatCenterAdaptLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -28,9 +28,21 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { throw new Error("不能添加元素") }, + mounted: function () { + var width = this.left.element.width(), + height = this.left.element.height(); + this.left.element.width(width).height(height).css("float", "none"); + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [this.left] + }); + this.removeWidget(this.container.getName()); + }, + stroke: function (items) { var self = this, o = this.options; - var left = BI.createWidget({ + this.left = BI.createWidget({ type: "bi.vertical", items: items, hgap: o.hgap, @@ -41,27 +53,17 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, { rgap: o.rgap }); - BI.createWidget({ + this.container = BI.createWidget({ type: "bi.left", - element: this.element, - items: [left] + element: this, + items: [this.left] }); - BI.nextTick(function () { - var width = left.element.width(), - height = left.element.height(); - BI.DOM.hang([left]); - left.element.width(width).height(height).css("float", "none"); - BI.createWidget({ - type: "bi.center_adapt", - element: self.element, - items: [left] - }) - }); }, populate: function (items) { BI.FloatCenterAdaptLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.float_center_adapt', BI.FloatCenterAdaptLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/float.horizontal.js b/src/core/wrapper/layout/adapt/float.horizontal.js index 1fa8da451..261ebc018 100644 --- a/src/core/wrapper/layout/adapt/float.horizontal.js +++ b/src/core/wrapper/layout/adapt/float.horizontal.js @@ -2,8 +2,8 @@ * 浮动的水平居中布局 */ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-horizontal-adapt-layout", items: [], hgap: 0, @@ -14,8 +14,8 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { rgap: 0 }); }, - _init: function () { - BI.FloatHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatHorizontalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -23,11 +23,23 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { // console.log("float_horizontal_adapt布局不需要resize"); }, + mounted: function () { + var width = this.left.element.width(), + height = this.left.element.height(); + this.left.element.width(width).height(height).css("float", "none"); + BI.createWidget({ + type: "bi.horizontal_auto", + element: this, + items: [this.left] + }); + this.removeWidget(this.container.getName()); + }, + _addElement: function (i, item) { var self = this, o = this.options; - var left = BI.createWidget({ + this.left = BI.createWidget({ type: "bi.vertical", - items: [item], + items: items, hgap: o.hgap, vgap: o.vgap, tgap: o.tgap, @@ -36,29 +48,18 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, { rgap: o.rgap }); - BI.createWidget({ + this.container = BI.createWidget({ type: "bi.left", - element: this.element, - items: [left] + element: this, + items: [this.left] }); - BI.nextTick(function () { - var width = left.element.width(), - height = left.element.height(); - BI.DOM.hang([left]); - left.element.width(width).height(height).css("float", "none"); - BI.createWidget({ - type: "bi.horizontal_auto", - element: self.element, - items: [left] - }) - }); - this.addWidget(left); return left; }, populate: function (items) { BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.horizontal_float', BI.FloatHorizontalLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/inline.center.js b/src/core/wrapper/layout/adapt/inline.center.js index c3191ae7a..cb1e5acd2 100644 --- a/src/core/wrapper/layout/adapt/inline.center.js +++ b/src/core/wrapper/layout/adapt/inline.center.js @@ -8,8 +8,8 @@ * @cfg {Number} [vgap=0] 垂直间隙 */ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.InlineCenterAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.InlineCenterAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-inline-center-adapt-layout", hgap: 0, vgap: 0, @@ -19,8 +19,8 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.InlineCenterAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.InlineCenterAdaptLayout.superclass.created.apply(this, arguments); this.element.css({ whiteSpace: "nowrap" }); @@ -92,7 +92,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.InlineCenterAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.inline_center_adapt', BI.InlineCenterAdaptLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/inline.vertical.js b/src/core/wrapper/layout/adapt/inline.vertical.js index 583f4dbda..2d1a19729 100644 --- a/src/core/wrapper/layout/adapt/inline.vertical.js +++ b/src/core/wrapper/layout/adapt/inline.vertical.js @@ -8,8 +8,8 @@ * @cfg {Number} [vgap=0] 垂直间隙 */ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.InlineVerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.InlineVerticalAdaptLayout.superclass.props.apply(this, arguments), { baseCls: "bi-inline-vertical-adapt-layout", hgap: 0, vgap: 0, @@ -19,8 +19,8 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.InlineVerticalAdaptLayout.superclass._init.apply(this, arguments); + created: function () { + BI.InlineVerticalAdaptLayout.superclass.created.apply(this, arguments); this.element.css({ whiteSpace: "nowrap" }); @@ -66,7 +66,7 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.InlineVerticalAdaptLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.inline_vertical_adapt', BI.InlineVerticalAdaptLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/flex/flex.center.js b/src/core/wrapper/layout/flex/flex.center.js index 50a4a28a1..63a2bf11d 100644 --- a/src/core/wrapper/layout/flex/flex.center.js +++ b/src/core/wrapper/layout/flex/flex.center.js @@ -6,13 +6,13 @@ * @extends BI.Layout */ BI.FlexCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-center-layout" }); }, - _init: function () { - BI.FlexCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FlexCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -29,7 +29,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexCenterLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.flex_center', BI.FlexCenterLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/flex/flex.horizontal.js b/src/core/wrapper/layout/flex/flex.horizontal.js index 64eb4454b..84a06b01f 100644 --- a/src/core/wrapper/layout/flex/flex.horizontal.js +++ b/src/core/wrapper/layout/flex/flex.horizontal.js @@ -6,8 +6,8 @@ * @extends BI.Layout */ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-horizontal-layout", verticalAlign: "middle", columnSize: [], @@ -20,8 +20,8 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FlexHorizontalLayout.superclass.created.apply(this, arguments); var o = this.options; this.element.addClass(o.verticalAlign); this.populate(this.options.items); @@ -60,7 +60,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexHorizontalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.flex_horizontal', BI.FlexHorizontalLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/flex/flex.vertical.center.js b/src/core/wrapper/layout/flex/flex.vertical.center.js index 90fae2c84..5fbdf34d7 100644 --- a/src/core/wrapper/layout/flex/flex.vertical.center.js +++ b/src/core/wrapper/layout/flex/flex.vertical.center.js @@ -6,8 +6,8 @@ * @extends BI.Layout */ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexVerticalCenter.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexVerticalCenter.superclass.props.apply(this, arguments), { baseCls: "bi-flex-vertical-center", columnSize: [], hgap: 0, @@ -18,8 +18,8 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexVerticalCenter.superclass._init.apply(this, arguments); + created: function () { + BI.FlexVerticalCenter.superclass.created.apply(this, arguments); var o = this.options; this.populate(this.options.items); }, @@ -57,7 +57,7 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexVerticalCenter.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.flex_vertical_center', BI.FlexVerticalCenter); \ No newline at end of file diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js index 38b94b58a..a4f2de509 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js @@ -6,28 +6,45 @@ * @extends BI.Layout */ BI.FlexCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-wrapper-center-layout clearfix" }); }, - _init: function () { - BI.FlexCenterLayout.superclass._init.apply(this, arguments); - this.wrapper = $("
").addClass("flex-wrapper-center-layout-wrapper").appendTo(this.element); + created: function () { + BI.FlexCenterLayout.superclass.created.apply(this, arguments); + this.$wrapper = $("
").addClass("flex-wrapper-center-layout-wrapper"); this.populate(this.options.items); }, _addElement: function (i, item) { var o = this.options; var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments); - w.element.css({"position": "relative"}).appendTo(this.wrapper); + w.element.css({"position": "relative"}); return w; }, + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); + } + }, + addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.wrapper); + w.element.appendTo(this.$wrapper); return w; }, @@ -37,6 +54,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.flex_wrapper_center', BI.FlexCenterLayout); \ No newline at end of file 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 19d3fac40..16e043c12 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js @@ -6,8 +6,8 @@ * @extends BI.Layout */ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexHorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexHorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-flex-wrapper-horizontal-layout clearfix", verticalAlign: "middle", columnSize: [], @@ -20,17 +20,17 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexHorizontalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FlexHorizontalLayout.superclass.created.apply(this, arguments); var o = this.options; - this.wrapper = $("
").addClass("flex-wrapper-horizontal-layout-wrapper " + o.verticalAlign).appendTo(this.element); + this.$wrapper = $("
").addClass("flex-wrapper-horizontal-layout-wrapper " + o.verticalAlign); this.populate(this.options.items); }, _addElement: function (i, item) { var o = this.options; var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments); - w.element.css({"position": "relative"}).appendTo(this.wrapper); + w.element.css({"position": "relative"}); if (o.hgap + o.lgap + (item.lgap || 0) > 0) { w.element.css({ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" @@ -54,10 +54,27 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { return w; }, + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); + } + }, + addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.wrapper); + w.element.appendTo(this.$wrapper); return w; }, @@ -67,6 +84,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexHorizontalLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.flex_wrapper_horizontal', BI.FlexHorizontalLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js index 01ab96d4e..4db3a5553 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js @@ -6,8 +6,8 @@ * @extends BI.Layout */ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FlexVerticalCenter.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FlexVerticalCenter.superclass.props.apply(this, arguments), { baseCls: "bi-flex-wrapper-vertical-center clearfix", columnSize: [], hgap: 0, @@ -18,17 +18,17 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FlexVerticalCenter.superclass._init.apply(this, arguments); + created: function () { + BI.FlexVerticalCenter.superclass.created.apply(this, arguments); var o = this.options; - this.wrapper = $("
").addClass("flex-wrapper-vertical-center-wrapper").appendTo(this.element); + this.$wrapper = $("
").addClass("flex-wrapper-vertical-center-wrapper"); this.populate(this.options.items); }, _addElement: function (i, item) { var o = this.options; var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments); - w.element.css({"position": "relative"}).appendTo(this.wrapper); + w.element.css({"position": "relative"}); if (o.hgap + o.lgap + (item.lgap || 0) > 0) { w.element.css({ "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" @@ -52,10 +52,26 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { return w; }, + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); + } + }, + addItem: function (item) { var w = this._addElement(this.options.items.length, item); this.options.items.push(item); - w.element.appendTo(this.wrapper); + w.element.appendTo(this.$wrapper); return w; }, @@ -65,6 +81,7 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { populate: function (items) { BI.FlexVerticalCenter.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.flex_wrapper_vertical_center', BI.FlexVerticalCenter); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.absolute.js b/src/core/wrapper/layout/layout.absolute.js index 09f5e9fec..b2403fea9 100644 --- a/src/core/wrapper/layout/layout.absolute.js +++ b/src/core/wrapper/layout/layout.absolute.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.AbsoluteLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AbsoluteLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AbsoluteLayout.superclass.props.apply(this, arguments), { baseCls: "bi-absolute-layout", hgap: null, vgap: null, @@ -15,8 +15,8 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, { bgap: null }); }, - _init: function () { - BI.AbsoluteLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AbsoluteLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -87,6 +87,7 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, { }, stroke: function (items) { + this.options.items = items || []; var self = this; BI.each(items, function (i, item) { if (!!item) { @@ -100,7 +101,7 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.absolute', BI.AbsoluteLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.adaptive.js b/src/core/wrapper/layout/layout.adaptive.js index eba36768b..26c680692 100644 --- a/src/core/wrapper/layout/layout.adaptive.js +++ b/src/core/wrapper/layout/layout.adaptive.js @@ -1,6 +1,6 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.AdaptiveLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.AdaptiveLayout.superclass.props.apply(this, arguments), { baseCls: "bi-adaptive-layout", hgap: null, vgap: null, @@ -10,8 +10,8 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, { bgap: null }); }, - _init: function () { - BI.AdaptiveLayout.superclass._init.apply(this, arguments); + created: function () { + BI.AdaptiveLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -86,7 +86,7 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.AbsoluteLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.adaptive', BI.AdaptiveLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.border.js b/src/core/wrapper/layout/layout.border.js index c110e0559..7e81a65ef 100644 --- a/src/core/wrapper/layout/layout.border.js +++ b/src/core/wrapper/layout/layout.border.js @@ -5,14 +5,14 @@ * @extends BI.Layout */ BI.BorderLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.BorderLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.BorderLayout.superclass.props.apply(this, arguments), { baseCls: "bi-border-layout", items: {} }); }, - _init: function () { - BI.BorderLayout.superclass._init.apply(this, arguments); + created: function () { + BI.BorderLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -126,7 +126,7 @@ BI.BorderLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.BorderLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.border', BI.BorderLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index 612bdf7e0..d24f5f79c 100644 --- a/src/core/wrapper/layout/layout.card.js +++ b/src/core/wrapper/layout/layout.card.js @@ -7,14 +7,14 @@ * @cfg {String} options.defaultShowName 默认展示的子组件名 */ BI.CardLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.CardLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.CardLayout.superclass.props.apply(this, arguments), { baseCls: "bi-card-layout", items: [] }); }, - _init: function () { - BI.CardLayout.superclass._init.apply(this, arguments); + created: function () { + BI.CardLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -28,7 +28,6 @@ BI.CardLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this; - this.clear(); this.showIndex = void 0; BI.each(items, function (i, item) { if (!!item) { @@ -39,14 +38,14 @@ BI.CardLayout = BI.inherit(BI.Layout, { var w = self.getWidgetByName(self._getCardName(item.cardName)); } w.element.css({"position": "absolute", "top": "0", "right": "0", "bottom": "0", "left": "0"}); - w.invisible(); + w.setVisible(false); } }); }, populate: function (items) { BI.CardLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); this.options.defaultShowName && this.showCardByName(this.options.defaultShowName); }, @@ -59,7 +58,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { if (!this.hasWidget(this._getCardName(cardName))) { throw new Error("cardName不存在,无法获取"); } - return this.widgets[this._getCardName(cardName)]; + return this._children[this._getCardName(cardName)]; }, deleteCardByName: function (cardName) { @@ -71,7 +70,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { return item.cardName == cardName; }); this.options.items.splice(index, 1); - delete this.widgets[this._getCardName(cardName)]; + delete this._children[this._getCardName(cardName)]; }, addCardByName: function (cardName, cardItem) { @@ -96,7 +95,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { } this.showIndex = this._getCardName(name); var flag = false; - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { if (self._getCardName(name) != i) { //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.element.hide(); @@ -109,7 +108,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { showLastCard: function () { var self = this; this.showIndex = this.lastShowIndex; - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { if (self.showIndex != i) { el.element.hide(); } else { @@ -148,14 +147,14 @@ BI.CardLayout = BI.inherit(BI.Layout, { }, hideAllCard: function () { - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { el.invisible(); }); }, isAllCardHide: function () { var flag = true; - BI.each(this.widgets, function (i, el) { + BI.each(this._children, function (i, el) { if (el.isVisible()) { flag = true; return false; @@ -163,10 +162,5 @@ BI.CardLayout = BI.inherit(BI.Layout, { }); return flag; }, - - empty: function () { - BI.CardLayout.superclass.empty.apply(this, arguments); - this.showIndex = void 0; - } }); $.shortcut('bi.card', BI.CardLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.default.js b/src/core/wrapper/layout/layout.default.js index 51c1bded2..d0f86c5dd 100644 --- a/src/core/wrapper/layout/layout.default.js +++ b/src/core/wrapper/layout/layout.default.js @@ -5,8 +5,8 @@ * @extends BI.Layout */ BI.DefaultLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.DefaultLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.DefaultLayout.superclass.props.apply(this, arguments), { hgap: 0, vgap: 0, lgap: 0, @@ -16,8 +16,8 @@ BI.DefaultLayout = BI.inherit(BI.Layout, { items: [] }); }, - _init: function () { - BI.DefaultLayout.superclass._init.apply(this, arguments); + created: function () { + BI.DefaultLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -53,7 +53,7 @@ BI.DefaultLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.DefaultLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.default', BI.DefaultLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.division.js b/src/core/wrapper/layout/layout.division.js index 57690f6d0..b4d831622 100644 --- a/src/core/wrapper/layout/layout.division.js +++ b/src/core/wrapper/layout/layout.division.js @@ -5,8 +5,8 @@ * @extends BI.Layout */ BI.DivisionLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.DivisionLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.DivisionLayout.superclass.props.apply(this, arguments), { baseCls: "bi-division-layout", columns: null, rows: null, @@ -36,8 +36,8 @@ BI.DivisionLayout = BI.inherit(BI.Layout, { //] }); }, - _init: function () { - BI.DivisionLayout.superclass._init.apply(this, arguments); + created: function () { + BI.DivisionLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -151,7 +151,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.DivisionLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.division', BI.DivisionLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.flow.js b/src/core/wrapper/layout/layout.flow.js index 7a2e87f90..7d1a8abbd 100644 --- a/src/core/wrapper/layout/layout.flow.js +++ b/src/core/wrapper/layout/layout.flow.js @@ -8,8 +8,8 @@ * @cfg {Number} [vgap=0] 垂直间隙 */ BI.FloatLeftLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatLeftLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatLeftLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-left-layout clearfix", hgap: 0, vgap: 0, @@ -19,8 +19,8 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FloatLeftLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatLeftLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -58,7 +58,7 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FloatLeftLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.left', BI.FloatLeftLayout); @@ -73,8 +73,8 @@ $.shortcut('bi.left', BI.FloatLeftLayout); * @cfg {Number} [vgap=0] 垂直间隙 */ BI.FloatRightLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatRightLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatRightLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-right-layout clearfix", hgap: 0, vgap: 0, @@ -84,8 +84,8 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FloatRightLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatRightLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -123,7 +123,7 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.FloatRightLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.right', BI.FloatRightLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.grid.js b/src/core/wrapper/layout/layout.grid.js index 257b7c20a..a76156595 100644 --- a/src/core/wrapper/layout/layout.grid.js +++ b/src/core/wrapper/layout/layout.grid.js @@ -5,8 +5,8 @@ * @extends BI.Layout */ BI.GridLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.GridLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.GridLayout.superclass.props.apply(this, arguments), { baseCls: "bi-grid-layout", columns: null, rows: null, @@ -30,8 +30,8 @@ BI.GridLayout = BI.inherit(BI.Layout, { ]*/ }); }, - _init: function () { - BI.GridLayout.superclass._init.apply(this, arguments); + created: function () { + BI.GridLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -121,7 +121,7 @@ BI.GridLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.GridLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.grid', BI.GridLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.horizontal.js b/src/core/wrapper/layout/layout.horizontal.js index 317100a21..e9cc362bd 100644 --- a/src/core/wrapper/layout/layout.horizontal.js +++ b/src/core/wrapper/layout/layout.horizontal.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.HorizontalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-layout", verticalAlign: "middle", columnSize: [], @@ -18,25 +18,17 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalLayout.superclass._init.apply(this, arguments); - var table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - table.element.css({ + created: function () { + BI.HorizontalLayout.superclass.created.apply(this, arguments); + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "white-space": "nowrap", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); - this.tr = BI.createWidget({ - type: "bi.layout", - tagName: "tr" }); - this.tr.element.appendTo(table.element); + this.$tr = $(""); + this.$tr.appendTo(this.$table); this.populate(this.options.items); }, @@ -94,26 +86,22 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { return td; }, - render: function () { - if (!BI.isEmpty(this.widgets)) { - this.tr.element.append(this.hang()); + _mountChildren: function () { + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$tr.append(frag); + this.element.append(this.$table); } - return this; - }, - - clear: function () { - this.hang(); - this.widgets = {}; - this.tr.empty(); }, - empty: function () { - BI.each(this.widgets, function (i, wi) { - wi.destroy(); - }); - this.widgets = {}; - this.tr.empty(); - }, resize: function () { // console.log("horizontal layout do not need to resize"); @@ -121,14 +109,15 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); + w._mount(); this.options.items.push(item); - w.element.appendTo(this.tr.element); + w.element.appendTo(this.$tr); return w; }, populate: function (items) { BI.HorizontalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal', BI.HorizontalLayout); @@ -139,8 +128,8 @@ $.shortcut('bi.horizontal', BI.HorizontalLayout); * @extends BI.Layout */ BI.HorizontalCellLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalCellLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalCellLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-cell-layout", scrollable: true, hgap: 0, @@ -151,8 +140,8 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalCellLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HorizontalCellLayout.superclass.created.apply(this, arguments); this.element.css({"display": "table", "vertical-align": "top"}); this.populate(this.options.items); }, @@ -190,7 +179,7 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HorizontalCellLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.horizontal_cell', BI.HorizontalCellLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.inline.js b/src/core/wrapper/layout/layout.inline.js index a7c613409..1359b0eec 100644 --- a/src/core/wrapper/layout/layout.inline.js +++ b/src/core/wrapper/layout/layout.inline.js @@ -8,8 +8,8 @@ * @cfg {Number} [vgap=0] 垂直间隙 */ BI.InlineLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.InlineLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.InlineLayout.superclass.props.apply(this, arguments), { baseCls: "bi-inline-layout", hgap: 0, vgap: 0, @@ -19,8 +19,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.InlineLayout.superclass._init.apply(this, arguments); + created: function () { + BI.InlineLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -57,7 +57,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.InlineLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.inline', BI.InlineLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.lattice.js b/src/core/wrapper/layout/layout.lattice.js index 2dd8bae8c..2c33ee636 100644 --- a/src/core/wrapper/layout/layout.lattice.js +++ b/src/core/wrapper/layout/layout.lattice.js @@ -8,14 +8,14 @@ * @cfg {Number} [vgap=0] 垂直间隙 */ BI.LatticeLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.LatticeLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.LatticeLayout.superclass.props.apply(this, arguments), { baseCls: "bi-lattice-layout clearfix" //columnSize: [0.2, 0.2, 0.6], }); }, - _init: function () { - BI.LatticeLayout.superclass._init.apply(this, arguments); + created: function () { + BI.LatticeLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -43,7 +43,7 @@ BI.LatticeLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.LatticeLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.lattice', BI.LatticeLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.table.js b/src/core/wrapper/layout/layout.table.js index 65b19b01f..84d577cb0 100644 --- a/src/core/wrapper/layout/layout.table.js +++ b/src/core/wrapper/layout/layout.table.js @@ -5,8 +5,8 @@ * @extends BI.Layout */ BI.TableLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.TableLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.TableLayout.superclass.props.apply(this, arguments), { baseCls: "bi-table-layout", scrolly: true, columnSize: [200, 200, 'fill'], @@ -26,8 +26,8 @@ BI.TableLayout = BI.inherit(BI.Layout, { ]] }); }, - _init: function () { - BI.TableLayout.superclass._init.apply(this, arguments); + created: function () { + BI.TableLayout.superclass.created.apply(this, arguments); this.rows = 0; this.populate(this.options.items); }, @@ -140,7 +140,7 @@ BI.TableLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.TableLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.table', BI.TableLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.tape.js b/src/core/wrapper/layout/layout.tape.js index e8981ef22..857097be1 100644 --- a/src/core/wrapper/layout/layout.tape.js +++ b/src/core/wrapper/layout/layout.tape.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.HTapeLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HTapeLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HTapeLayout.superclass.props.apply(this, arguments), { baseCls: "bi-h-tape-layout", hgap: 0, vgap: 0, @@ -29,8 +29,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { ] }); }, - _init: function () { - BI.HTapeLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HTapeLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -97,7 +97,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HTapeLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.htape', BI.HTapeLayout); @@ -108,8 +108,8 @@ $.shortcut('bi.htape', BI.HTapeLayout); * @extends BI.Layout */ BI.VTapeLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.VTapeLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.VTapeLayout.superclass.props.apply(this, arguments), { baseCls: "bi-v-tape-layout", hgap: 0, vgap: 0, @@ -133,8 +133,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { ] }); }, - _init: function () { - BI.VTapeLayout.superclass._init.apply(this, arguments); + created: function () { + BI.VTapeLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -202,7 +202,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VTapeLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.vtape', BI.VTapeLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.td.js b/src/core/wrapper/layout/layout.td.js index b32354196..c4ccb512b 100644 --- a/src/core/wrapper/layout/layout.td.js +++ b/src/core/wrapper/layout/layout.td.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.TdLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.TdLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.TdLayout.superclass.props.apply(this, arguments), { baseCls: "bi-td-layout", columnSize: [200, 200, 200], hgap: 0, @@ -23,21 +23,16 @@ BI.TdLayout = BI.inherit(BI.Layout, { ]] }); }, - _init: function () { - BI.TdLayout.superclass._init.apply(this, arguments); - this.table = BI.createWidget({ - type: "bi.layout", - tagName: "table", - attribute: {"cellspacing": 0, "cellpadding": 0} - }); - this.table.element.css({ + created: function () { + BI.TdLayout.superclass.created.apply(this, arguments); + this.$table = $("
").attr({"cellspacing": 0, "cellpadding": 0}).css({ "position": "relative", "width": "100%", "height": "100%", "border-spacing": "0px", "border": "none", "border-collapse": "separate" - }).appendTo(this.element); + }); this.rows = 0; this.populate(this.options.items); }, @@ -108,10 +103,26 @@ BI.TdLayout = BI.inherit(BI.Layout, { }); tr.addItem(td); } - this.table.element.append(tr.element); + this.addWidget(this.getName() + idx, tr); return tr; }, + _mountChildren: function(){ + var self = this; + var frag = document.createDocumentFragment(); + var hasChild = false; + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); + hasChild = true; + } + }); + if (hasChild === true) { + this.$table.append(frag); + this.element.append(this.$table); + } + }, + resize: function () { // console.log("td布局不需要resize"); }, @@ -125,6 +136,7 @@ BI.TdLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.TdLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.td', BI.TdLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.vertical.js b/src/core/wrapper/layout/layout.vertical.js index 77c14320e..2eb05ab9e 100644 --- a/src/core/wrapper/layout/layout.vertical.js +++ b/src/core/wrapper/layout/layout.vertical.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.VerticalLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.VerticalLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.VerticalLayout.superclass.props.apply(this, arguments), { baseCls: "bi-vertical-layout", hgap: 0, vgap: 0, @@ -16,8 +16,8 @@ BI.VerticalLayout = BI.inherit(BI.Layout, { scrolly: true }); }, - _init: function () { - BI.VerticalLayout.superclass._init.apply(this, arguments); + created: function () { + BI.VerticalLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -56,7 +56,7 @@ BI.VerticalLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VerticalLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.vertical', BI.VerticalLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.window.js b/src/core/wrapper/layout/layout.window.js index 1ae96a815..428fd14c1 100644 --- a/src/core/wrapper/layout/layout.window.js +++ b/src/core/wrapper/layout/layout.window.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.WindowLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.WindowLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.WindowLayout.superclass.props.apply(this, arguments), { baseCls: "bi-window-layout", columns: 3, rows: 2, @@ -30,8 +30,8 @@ BI.WindowLayout = BI.inherit(BI.Layout, { ]] }); }, - _init: function () { - BI.WindowLayout.superclass._init.apply(this, arguments); + created: function () { + BI.WindowLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -182,7 +182,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.WindowLayout.superclass.populate.apply(this, arguments); - this.render(); + this._mount(); } }); $.shortcut('bi.window', BI.WindowLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/middle/middle.center.js b/src/core/wrapper/layout/middle/middle.center.js index 07bbd9bba..f96bfefc9 100644 --- a/src/core/wrapper/layout/middle/middle.center.js +++ b/src/core/wrapper/layout/middle/middle.center.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.CenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.CenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.CenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-center-layout", hgap: 0, vgap: 0, @@ -16,8 +16,8 @@ BI.CenterLayout = BI.inherit(BI.Layout, { }); }, - _init: function () { - BI.CenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.CenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -32,14 +32,13 @@ BI.CenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this, o = this.options; - this.clear(); var list = []; BI.each(items, function (i) { list.push({ column: i, row: 0, el: BI.createWidget({ - type: "bi.layout", + type: "bi.default", cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "") }) }); @@ -55,13 +54,13 @@ BI.CenterLayout = BI.inherit(BI.Layout, { bottom: o.vgap + o.bgap, width: "auto", height: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.grid", - element: this.element, + element: this, columns: list.length, rows: 1, items: list @@ -70,6 +69,7 @@ BI.CenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.CenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.center', BI.CenterLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/middle/middle.float.center.js b/src/core/wrapper/layout/middle/middle.float.center.js index a248854e8..95b47e7f8 100644 --- a/src/core/wrapper/layout/middle/middle.float.center.js +++ b/src/core/wrapper/layout/middle/middle.float.center.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.FloatCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.FloatCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.FloatCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-float-center-layout", hgap: 0, vgap: 0, @@ -15,8 +15,8 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.FloatCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.FloatCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -31,10 +31,11 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this, o = this.options; - this.clear(); var list = [], width = 100 / items.length; BI.each(items, function (i) { - var widget = BI.createWidget(); + var widget = BI.createWidget({ + type: "bi.default" + }); widget.element.addClass("center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")).css({ width: width + "%", height: "100%" @@ -54,19 +55,20 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, { bottom: o.vgap + o.bgap, width: "auto", height: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.left", - element: this.element, + element: this, items: list }); }, populate: function (items) { BI.FloatCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.float_center', BI.FloatCenterLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/middle/middle.horizontal.js b/src/core/wrapper/layout/middle/middle.horizontal.js index 31ade4af6..0544ef7aa 100644 --- a/src/core/wrapper/layout/middle/middle.horizontal.js +++ b/src/core/wrapper/layout/middle/middle.horizontal.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.HorizontalCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.HorizontalCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-horizontal-center-layout", hgap: 0, vgap: 0, @@ -15,8 +15,8 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.HorizontalCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.HorizontalCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -31,14 +31,13 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var o = this.options; - this.clear(); var list = []; BI.each(items, function (i) { list.push({ column: i, row: 0, el: BI.createWidget({ - type: "bi.layout", + type: "bi.default", cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "") }) }); @@ -53,13 +52,13 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { top: o.vgap + o.tgap, bottom: o.vgap + o.bgap, width: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.grid", - element: this.element, + element: this, columns: list.length, rows: 1, items: list @@ -68,6 +67,7 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.HorizontalCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.horizontal_center', BI.HorizontalCenterLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/middle/middle.vertical.js b/src/core/wrapper/layout/middle/middle.vertical.js index dce69ef30..f9a8a23f8 100644 --- a/src/core/wrapper/layout/middle/middle.vertical.js +++ b/src/core/wrapper/layout/middle/middle.vertical.js @@ -4,8 +4,8 @@ * @extends BI.Layout */ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { - _defaultConfig: function () { - return BI.extend(BI.VerticalCenterLayout.superclass._defaultConfig.apply(this, arguments), { + props: function () { + return BI.extend(BI.VerticalCenterLayout.superclass.props.apply(this, arguments), { baseCls: "bi-vertical-center-layout", hgap: 0, vgap: 0, @@ -15,8 +15,8 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { bgap: 0 }); }, - _init: function () { - BI.VerticalCenterLayout.superclass._init.apply(this, arguments); + created: function () { + BI.VerticalCenterLayout.superclass.created.apply(this, arguments); this.populate(this.options.items); }, @@ -31,14 +31,13 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { stroke: function (items) { var self = this, o = this.options; - this.clear(); var list = []; BI.each(items, function (i) { list.push({ column: 0, row: i, el: BI.createWidget({ - type: "bi.layout", + type: "bi.default", cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "") }) }); @@ -53,13 +52,13 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { top: o.vgap + o.tgap, bottom: o.vgap + o.bgap, height: "auto" - }).appendTo(list[i].el.element); - self.addWidget(w); + }); + list[i].el.addItem(w); } }); BI.createWidget({ type: "bi.grid", - element: this.element, + element: this, columns: 1, rows: list.length, items: list @@ -68,6 +67,7 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, { populate: function (items) { BI.VerticalCenterLayout.superclass.populate.apply(this, arguments); + this._mount(); } }); $.shortcut('bi.vertical_center', BI.VerticalCenterLayout); \ No newline at end of file