From aba3261fbb0670c7731fdc5fc7c8584c5a537a2a Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 18 Aug 2018 20:54:21 +0800 Subject: [PATCH] added --- Gruntfile.js | 4 +- demo/js/face.js | 14 +- dist/bundle.js | 995 +++++++++--------- dist/core.js | 143 +-- dist/demo.js | 14 +- dist/fineui.js | 995 +++++++++--------- dist/widget.js | 13 +- src/core/wrapper/layout.js | 6 +- src/core/wrapper/layout/adapt/adapt.center.js | 17 +- .../wrapper/layout/adapt/adapt.horizontal.js | 17 +- .../wrapper/layout/adapt/adapt.vertical.js | 17 +- .../flex/wrapper/flex.wrapper.center.js | 17 +- .../flex/wrapper/flex.wrapper.horizontal.js | 17 +- .../wrapper/flex.wrapper.vertical.center.js | 17 +- src/core/wrapper/layout/layout.horizontal.js | 18 +- src/core/wrapper/layout/layout.td.js | 17 +- 16 files changed, 1028 insertions(+), 1293 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index c35c6b304..43b2b85c8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -250,7 +250,7 @@ module.exports = function (grunt) { }, watch: { scripts: { - files: ["src/**/*", "demo/js/**/*.js", "demo/version.js", "demo/config.js", "demo/less/**/*.less"], + files: ["src/**/*.js", "src/**/*.less", "demo/js/**/*.js", "demo/version.js", "demo/config.js", "demo/less/**/*.less"], tasks: ["less", "concat"], options: { spanw: true, @@ -291,7 +291,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks("grunt-contrib-connect"); grunt.loadNpmTasks('grunt-contrib-clean'); - var defaultTask = ["clean", "less", "concat", "connect", "watch"]; + var defaultTask = ["less", "concat", "connect", "watch"]; grunt.registerTask("default", defaultTask); grunt.registerTask("compile", function () { grunt.config.set("connect.options.open", false); diff --git a/demo/js/face.js b/demo/js/face.js index d2574a3d8..a9f1072e9 100644 --- a/demo/js/face.js +++ b/demo/js/face.js @@ -548,20 +548,16 @@ Demo.Face = BI.inherit(BI.Widget, { return { type: "bi.grid", items: [[{ - column: 0, - row: 0, - el: { - type: "bi.layout" - } - }, { - column: 1, - row: 0, el: { type: "bi.vertical", - cls: "face-config bi-border-left", + cls: "face-config bi-border-right", items: [this._createBaseConfig(), this._createCommonConfig()] } + }, { + el: { + type: "bi.layout" + } }]] }; }, diff --git a/dist/bundle.js b/dist/bundle.js index aec65be61..d3ad5caaf 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -21344,469 +21344,499 @@ _.extend(BI.OB.prototype, { * * @cfg {JSON} options 配置属性 */ -BI.Widget = BI.inherit(BI.OB, { - _defaultConfig: function () { - return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), { - root: false, - tagName: "div", - attributes: null, - data: null, - tag: null, - disabled: false, - invisible: false, - invalid: false, - baseCls: "", - extraCls: "", - cls: "" - }); - }, +!(function () { + var lazy = (typeof document !== "undefined" && + typeof document.documentMode === "number") || + (typeof navigator !== "undefined" && + typeof navigator.userAgent === "string" && + /\bEdge\/\d/.test(navigator.userAgent)); + BI.Widget = BI.inherit(BI.OB, { + _defaultConfig: function () { + return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), { + root: false, + tagName: "div", + attributes: null, + data: null, + + tag: null, + disabled: false, + invisible: false, + invalid: false, + baseCls: "", + extraCls: "", + cls: "" + }); + }, - beforeInit: null, + beforeInit: null, - // 生命周期函数 - beforeCreate: null, + // 生命周期函数 + beforeCreate: null, - created: null, + created: null, - render: null, + render: null, - beforeMount: null, + beforeMount: null, - mounted: null, + mounted: null, - shouldUpdate: null, + shouldUpdate: null, - update: function () { - }, + update: function () { + }, - beforeDestroy: null, + beforeDestroy: null, - destroyed: null, + destroyed: null, - _init: function () { - BI.Widget.superclass._init.apply(this, arguments); - this._initRoot(); - this._initElementWidth(); - this._initElementHeight(); - this._initVisual(); - this._initState(); - if (this.beforeInit) { - this.__asking = true; - this.beforeInit(BI.bind(this._render, this)); - if (this.__asking === true) { - this.__async = true; + _init: function () { + BI.Widget.superclass._init.apply(this, arguments); + this._initRoot(); + this._initElementWidth(); + this._initElementHeight(); + this._initVisual(); + this._initState(); + if (this.isVisible()) { + this.rendered = true; + if (this.beforeInit) { + this.__asking = true; + this.beforeInit(BI.bind(this._render, this)); + if (this.__asking === true) { + this.__async = true; + } + } else { + this._render(); + } } - } else { - this._render(); - } - }, + if (this._isRoot) { + this._mount(); + } + }, - _render: function () { - this.__asking = false; - this.beforeCreate && this.beforeCreate(); - this._initElement(); - this._initEffects(); - this.created && this.created(); - }, + _render: function () { + this.__asking = false; + this.beforeCreate && this.beforeCreate(); + this._initElement(); + this._initEffects(); + this.created && this.created(); + }, - /** - * 初始化根节点 - * @private - */ - _initRoot: function () { - var o = this.options; - this.widgetName = o.widgetName || BI.uniqueId("widget"); - this._isRoot = o.root; - if (BI.isWidget(o.element)) { - if (o.element instanceof BI.Widget) { - this._parent = o.element; - this._parent.addWidget(this.widgetName, this); - } else { + /** + * 初始化根节点 + * @private + */ + _initRoot: function () { + var o = this.options; + this.widgetName = o.widgetName || BI.uniqueId("widget"); + this._isRoot = o.root; + if (BI.isWidget(o.element)) { + if (o.element instanceof BI.Widget) { + this._parent = o.element; + this._parent.addWidget(this.widgetName, this); + } else { + this._isRoot = true; + } + this.element = this.options.element.element; + } else if (o.element) { + // if (o.root !== true) { + // throw new Error("root is a required property"); + // } + this.element = $(o.element); this._isRoot = true; + } else { + this.element = $(document.createElement(o.tagName)); } - this.element = this.options.element.element; - } else if (o.element) { - // if (o.root !== true) { - // throw new Error("root is a required property"); - // } - this.element = $(o.element); - this._isRoot = true; - } else { - this.element = $(document.createElement(o.tagName)); - } - this.element._isWidget = true; - if (o.baseCls || o.extraCls || o.cls) { - this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || "")); - } - if (o.attributes) { - this.element.attr(o.attributes); - } - if (o.data) { - this.element.data(o.data); - } - this._children = {}; - }, - - _initElementWidth: function () { - var o = this.options; - if (BI.isWidthOrHeight(o.width)) { - this.element.css("width", o.width); - } - }, + this.element._isWidget = true; + if (o.baseCls || o.extraCls || o.cls) { + this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || "")); + } + if (o.attributes) { + this.element.attr(o.attributes); + } + if (o.data) { + this.element.data(o.data); + } + this._children = {}; + }, - _initElementHeight: function () { - var o = this.options; - if (BI.isWidthOrHeight(o.height)) { - this.element.css("height", o.height); - } - }, + _initElementWidth: function () { + var o = this.options; + if (BI.isWidthOrHeight(o.width)) { + this.element.css("width", o.width); + } + }, - _initVisual: function () { - var o = this.options; - if (o.invisible) { - // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 - this.element.css("display", "none"); - } - }, + _initElementHeight: function () { + var o = this.options; + if (BI.isWidthOrHeight(o.height)) { + this.element.css("height", o.height); + } + }, - _initEffects: function () { - var o = this.options; - if (o.disabled || o.invalid) { - if (this.options.disabled) { - this.setEnable(false); + _initVisual: function () { + var o = this.options; + if (o.invisible) { + // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 + this.element.css("display", "none"); } - if (this.options.invalid) { - this.setValid(false); + }, + + _initEffects: function () { + var o = this.options; + if (o.disabled || o.invalid) { + if (this.options.disabled) { + this.setEnable(false); + } + if (this.options.invalid) { + this.setValid(false); + } } - } - }, + }, - _initState: function () { - this._isMounted = false; - }, + _initState: function () { + this._isMounted = false; + }, - _initElement: function () { - var self = this; - var els = this.render && this.render(); - if (BI.isPlainObject(els)) { - els = [els]; - } - if (BI.isArray(els)) { - BI.each(els, function (i, el) { - BI.createWidget(el, { - element: self + _initElement: function () { + var self = this; + var els = this.render && 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 instanceof BI.Layout)) { - this._mount(); - // } - }, + } + // if (this._isRoot === true || !(this instanceof BI.Layout)) { + this._mount(); + // } + }, - _setParent: function (parent) { - this._parent = parent; - }, + _setParent: function (parent) { + this._parent = parent; + }, - _mount: function () { - var self = this; - var isMounted = this._isMounted; - if (isMounted || !this.isVisible() || this.__asking === true) { - return; - } - if (this._isRoot === true) { - isMounted = true; - } else if (this._parent && this._parent._isMounted === true) { - isMounted = true; - } - if (!isMounted) { - return; - } - this.beforeMount && this.beforeMount(); - this._isMounted = true; - this._mountChildren && this._mountChildren(); - BI.each(this._children, function (i, widget) { - !self.isEnabled() && widget._setEnable(false); - !self.isValid() && widget._setValid(false); - widget._mount && widget._mount(); - }); - this.mounted && this.mounted(); - }, + _mount: function () { + var self = this; + var isMounted = this._isMounted; + if (this._isMounting || isMounted || !this.isVisible() || this.__asking === true) { + return; + } + if (this._isRoot === true) { + isMounted = true; + } else if (this._parent && this._parent._isMounted === true) { + isMounted = true; + } + if (!isMounted) { + return; + } + this._isMounting = true; + if (!this.rendered) { + if (this.beforeInit) { + this.__asking = true; + this.beforeInit(BI.bind(this._render, this)); + if (this.__asking === true) { + this.__async = true; + } + } else { + this._render(); + } + } - _mountChildren: null, + this.beforeMount && this.beforeMount(); + this._isMounted = true; + !lazy && this._mountChildren && this._mountChildren(); + BI.each(this._children, function (i, widget) { + !self.isEnabled() && widget._setEnable(false); + !self.isValid() && widget._setValid(false); + widget._mount && widget._mount(); + }); + lazy && this._mountChildren && this._mountChildren(); + this.mounted && this.mounted(); + this._isMounting = false; + }, - isMounted: function () { - return this._isMounted; - }, + _mountChildren: null, - setWidth: function (w) { - this.options.width = w; - this._initElementWidth(); - }, + isMounted: function () { + return this._isMounted; + }, - setHeight: function (h) { - this.options.height = h; - this._initElementHeight(); - }, + setWidth: function (w) { + this.options.width = w; + this._initElementWidth(); + }, - _setEnable: function (enable) { - if (enable === true) { - this.options.disabled = false; - } else if (enable === false) { - this.options.disabled = true; - } - // 递归将所有子组件使能 - BI.each(this._children, function (i, child) { - !child._manualSetEnable && child._setEnable && child._setEnable(enable); - }); - }, + setHeight: function (h) { + this.options.height = h; + this._initElementHeight(); + }, - _setValid: function (valid) { - if (valid === true) { - this.options.invalid = false; - } else if (valid === false) { - this.options.invalid = true; - } - // 递归将所有子组件使有效 - BI.each(this._children, function (i, child) { - !child._manualSetValid && child._setValid && child._setValid(valid); - }); - }, + _setEnable: function (enable) { + if (enable === true) { + this.options.disabled = false; + } else if (enable === false) { + this.options.disabled = true; + } + // 递归将所有子组件使能 + BI.each(this._children, function (i, child) { + !child._manualSetEnable && child._setEnable && child._setEnable(enable); + }); + }, - _setVisible: function (visible) { - if (visible === true) { - this.options.invisible = false; - } else if (visible === false) { - this.options.invisible = true; - } - }, + _setValid: function (valid) { + if (valid === true) { + this.options.invalid = false; + } else if (valid === false) { + this.options.invalid = true; + } + // 递归将所有子组件使有效 + BI.each(this._children, function (i, child) { + !child._manualSetValid && child._setValid && child._setValid(valid); + }); + }, - setEnable: function (enable) { - this._manualSetEnable = true; - this._setEnable(enable); - if (enable === true) { - this.element.removeClass("base-disabled disabled"); - } else if (enable === false) { - this.element.addClass("base-disabled disabled"); - } - }, + _setVisible: function (visible) { + if (visible === true) { + this.options.invisible = false; + } else if (visible === false) { + this.options.invisible = true; + } + }, - setVisible: function (visible) { - this._setVisible(visible); - if (visible === true) { - // 用this.element.show()会把display属性改成block - this.element.css("display", ""); - this._mount(); - } else if (visible === false) { - this.element.css("display", "none"); - } - this.fireEvent(BI.Events.VIEW, visible); - }, + setEnable: function (enable) { + this._manualSetEnable = true; + this._setEnable(enable); + if (enable === true) { + this.element.removeClass("base-disabled disabled"); + } else if (enable === false) { + this.element.addClass("base-disabled disabled"); + } + }, - setValid: function (valid) { - this._manualSetValid = true; - this._setValid(valid); - if (valid === true) { - this.element.removeClass("base-invalid invalid"); - } else if (valid === false) { - this.element.addClass("base-invalid invalid"); - } - }, + setVisible: function (visible) { + this._setVisible(visible); + if (visible === true) { + // 用this.element.show()会把display属性改成block + this.element.css("display", ""); + this._mount(); + } else if (visible === false) { + this.element.css("display", "none"); + } + this.fireEvent(BI.Events.VIEW, visible); + }, - doBehavior: function () { - var args = arguments; - // 递归将所有子组件使有效 - BI.each(this._children, function (i, child) { - child.doBehavior && child.doBehavior.apply(child, args); - }); - }, + setValid: function (valid) { + this._manualSetValid = true; + this._setValid(valid); + if (valid === true) { + this.element.removeClass("base-invalid invalid"); + } else if (valid === false) { + this.element.addClass("base-invalid invalid"); + } + }, - getWidth: function () { - return this.options.width; - }, + doBehavior: function () { + var args = arguments; + // 递归将所有子组件使有效 + BI.each(this._children, function (i, child) { + child.doBehavior && child.doBehavior.apply(child, args); + }); + }, - getHeight: function () { - return this.options.height; - }, + getWidth: function () { + return this.options.width; + }, - isValid: function () { - return !this.options.invalid; - }, + getHeight: function () { + return this.options.height; + }, - addWidget: function (name, widget) { - var self = this; - if (name instanceof BI.Widget) { - widget = name; - name = widget.getName(); - } - if (BI.isKey(name)) { - name = name + ""; - } - name = name || widget.getName() || BI.uniqueId("widget"); - if (this._children[name]) { - throw new Error("name has already been existed"); - } - widget._setParent && widget._setParent(this); - widget.on(BI.Events.DESTROY, function () { - BI.remove(self._children, this); - }); - return (this._children[name] = widget); - }, + isValid: function () { + return !this.options.invalid; + }, - getWidgetByName: function (name) { - if (!BI.isKey(name) || name === this.getName()) { - return this; - } - name = name + ""; - var widget = void 0, other = {}; - BI.any(this._children, function (i, wi) { - if (i === name) { - widget = wi; - return true; + addWidget: function (name, widget) { + var self = this; + if (name instanceof BI.Widget) { + widget = name; + name = widget.getName(); } - other[i] = wi; - }); - if (!widget) { - BI.any(other, function (i, wi) { - return (widget = wi.getWidgetByName(i)); + if (BI.isKey(name)) { + name = name + ""; + } + name = name || widget.getName() || BI.uniqueId("widget"); + if (this._children[name]) { + throw new Error("name has already been existed"); + } + widget._setParent && widget._setParent(this); + widget.on(BI.Events.DESTROY, function () { + BI.remove(self._children, this); }); - } - return widget; - }, + return (this._children[name] = widget); + }, - removeWidget: function (nameOrWidget) { - var self = this; - if (BI.isWidget(nameOrWidget)) { - BI.remove(this._children, nameOrWidget); - } else { - delete this._children[nameOrWidget]; - } - }, + getWidgetByName: function (name) { + if (!BI.isKey(name) || name === this.getName()) { + return this; + } + name = name + ""; + var widget = void 0, other = {}; + BI.any(this._children, function (i, wi) { + if (i === name) { + widget = wi; + return true; + } + other[i] = wi; + }); + if (!widget) { + BI.any(other, function (i, wi) { + return (widget = wi.getWidgetByName(i)); + }); + } + return widget; + }, - hasWidget: function (name) { - return this._children[name] != null; - }, + removeWidget: function (nameOrWidget) { + var self = this; + if (BI.isWidget(nameOrWidget)) { + BI.remove(this._children, nameOrWidget); + } else { + delete this._children[nameOrWidget]; + } + }, - getName: function () { - return this.widgetName; - }, + hasWidget: function (name) { + return this._children[name] != null; + }, - setTag: function (tag) { - this.options.tag = tag; - }, + getName: function () { + return this.widgetName; + }, - getTag: function () { - return this.options.tag; - }, + setTag: function (tag) { + this.options.tag = tag; + }, - attr: function (key, value) { - var self = this; - if (BI.isPlainObject(key)) { - BI.each(key, function (k, v) { - self.attr(k, v); - }); - return; - } - if (BI.isNotNull(value)) { - return this.options[key] = value; - } - return this.options[key]; - }, + getTag: function () { + return this.options.tag; + }, - getText: function () { + attr: function (key, value) { + var self = this; + if (BI.isPlainObject(key)) { + BI.each(key, function (k, v) { + self.attr(k, v); + }); + return; + } + if (BI.isNotNull(value)) { + return this.options[key] = value; + } + return this.options[key]; + }, - }, + getText: function () { - setText: function (text) { + }, - }, + setText: function (text) { - getValue: function () { + }, - }, + getValue: function () { - setValue: function (value) { + }, - }, + setValue: function (value) { - isEnabled: function () { - return !this.options.disabled; - }, + }, - isVisible: function () { - return !this.options.invisible; - }, + isEnabled: function () { + return !this.options.disabled; + }, - disable: function () { - this.setEnable(false); - }, + isVisible: function () { + return !this.options.invisible; + }, - enable: function () { - this.setEnable(true); - }, + disable: function () { + this.setEnable(false); + }, - valid: function () { - this.setValid(true); - }, + enable: function () { + this.setEnable(true); + }, - invalid: function () { - this.setValid(false); - }, + valid: function () { + this.setValid(true); + }, - invisible: function () { - this.setVisible(false); - }, + invalid: function () { + this.setValid(false); + }, - visible: function () { - this.setVisible(true); - }, + invisible: function () { + this.setVisible(false); + }, - __d: function () { - this.beforeDestroy && this.beforeDestroy(); - BI.each(this._children, function (i, widget) { - widget && widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.destroyed && this.destroyed(); - }, + visible: function () { + this.setVisible(true); + }, - _unMount: function () { - this.__d(); - this.fireEvent(BI.Events.UNMOUNT); - this.purgeListeners(); - }, + __d: function () { + this.beforeDestroy && this.beforeDestroy(); + BI.each(this._children, function (i, widget) { + widget && widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + this.destroyed && this.destroyed(); + }, - isolate: function () { - if (this._parent) { - this._parent.removeWidget(this); - } - BI.DOM.hang([this]); - }, + _unMount: function () { + this.__d(); + this.fireEvent(BI.Events.UNMOUNT); + this.purgeListeners(); + }, - empty: function () { - BI.each(this._children, function (i, widget) { - widget && widget._unMount && widget._unMount(); - }); - this._children = {}; - this.element.empty(); - }, + isolate: function () { + if (this._parent) { + this._parent.removeWidget(this); + } + BI.DOM.hang([this]); + }, - _destroy: function () { - this.__d(); - this.element.destroy(); - this.purgeListeners(); - }, + empty: function () { + BI.each(this._children, function (i, widget) { + widget && widget._unMount && widget._unMount(); + }); + this._children = {}; + this.element.empty(); + }, - destroy: function () { - this.__d(); - this.element.destroy(); - this.fireEvent(BI.Events.DESTROY); - this._purgeRef(); - this.purgeListeners(); - } -});(function () { + _destroy: function () { + this.__d(); + this.element.destroy(); + this.purgeListeners(); + }, + + destroy: function () { + this.__d(); + this.element.destroy(); + this.fireEvent(BI.Events.DESTROY); + this._purgeRef(); + this.purgeListeners(); + } + }); +})(); +(function () { var kv = {}; BI.shortcut = function (xtype, cls) { if (kv[xtype] != null) { @@ -24339,6 +24369,10 @@ BI.Layout = BI.inherit(BI.Widget, { } }, + appendFragment: function (frag) { + this.element.append(frag); + }, + _mountChildren: function () { var self = this; var frag = document.createDocumentFragment(); @@ -24350,7 +24384,7 @@ BI.Layout = BI.inherit(BI.Widget, { } }); if (hasChild === true) { - this.element.append(frag); + this.appendFragment(frag); } }, @@ -30276,20 +30310,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -30393,20 +30416,9 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -30683,20 +30695,9 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, _getWrapper: function () { @@ -31277,20 +31278,9 @@ BI.FlexCenterLayout = 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -31362,20 +31352,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -31447,20 +31426,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -32590,23 +32558,11 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, - resize: function () { // console.log("horizontal layout do not need to resize"); }, @@ -33273,20 +33229,9 @@ BI.TdLayout = BI.inherit(BI.Layout, { 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); - } + appendFragment: function (frag) { + this.$table.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -67976,12 +67921,15 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }, value: this.storeValue }); - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.button_group], + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({ + scrolly: true, vgap: 5 - }); + }, opts.logic, { + items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Top, this.button_group) + })))); this.button_group.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); @@ -81324,7 +81272,7 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, { }); BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { - function initWatch (vm, watch) { + function initWatch(vm, watch) { vm._watchers || (vm._watchers = []); for (var key in watch) { var handler = watch[key]; @@ -81338,7 +81286,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { } } - function createWatcher (vm, keyOrFn, handler) { + function createWatcher(vm, keyOrFn, handler) { return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), { store: vm.store }); @@ -81347,24 +81295,24 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { var target = null; var targetStack = []; - function pushTarget (_target) { + function pushTarget(_target) { if (target) targetStack.push(target); Fix.Model.target = target = _target; } - function popTarget () { + function popTarget() { Fix.Model.target = target = targetStack.pop(); } var context = null; var contextStack = []; - function pushContext (_context) { + function pushContext(_context) { if (context) contextStack.push(context); Fix.Model.context = context = _context; } - function popContext () { + function popContext() { Fix.Model.context = context = contextStack.pop(); } @@ -81385,7 +81333,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { }, options); }; - function findStore (widget) { + function findStore(widget) { if (target != null) { return target; } @@ -81431,12 +81379,11 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { }; }); - var _init = BI.Widget.prototype._init; - BI.Widget.prototype._init = function () { - var self = this; + function createStore() { var needPop = false; - if (window.Fix && this._store) { + if (!this._storeCreated && window.Fix && this._store && this.isVisible()) { var store = findStore(this.options.context || this.options.element); + this._storeCreated = true; if (store) { pushTarget(store); needPop = true; @@ -81453,6 +81400,13 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { } needPop = true; } + return needPop; + } + + var _init = BI.Widget.prototype._init; + BI.Widget.prototype._init = function () { + var self = this; + var needPop = createStore.call(this); _init.apply(this, arguments); needPop && popTarget(); }; @@ -81491,6 +81445,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { _.each(["_mount"], function (name) { var old = BI.Widget.prototype[name]; old && (BI.Widget.prototype[name] = function () { + createStore.call(this); this.store && pushTarget(this.store); var res = old.apply(this, arguments); this.store && popTarget(); diff --git a/dist/core.js b/dist/core.js index 5d4be7c10..fba753c55 100644 --- a/dist/core.js +++ b/dist/core.js @@ -24339,6 +24339,10 @@ BI.Layout = BI.inherit(BI.Widget, { } }, + appendFragment: function (frag) { + this.element.append(frag); + }, + _mountChildren: function () { var self = this; var frag = document.createDocumentFragment(); @@ -24350,7 +24354,7 @@ BI.Layout = BI.inherit(BI.Widget, { } }); if (hasChild === true) { - this.element.append(frag); + this.appendFragment(frag); } }, @@ -30276,20 +30280,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -30393,20 +30386,9 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -30683,20 +30665,9 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, _getWrapper: function () { @@ -31277,20 +31248,9 @@ BI.FlexCenterLayout = 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -31362,20 +31322,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -31447,20 +31396,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -32590,23 +32528,11 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, - resize: function () { // console.log("horizontal layout do not need to resize"); }, @@ -33273,20 +33199,9 @@ BI.TdLayout = BI.inherit(BI.Layout, { 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); - } + appendFragment: function (frag) { + this.$table.append(frag); + this.element.append(this.$table); }, resize: function () { diff --git a/dist/demo.js b/dist/demo.js index 3d9fc346a..882ca8e15 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -7495,20 +7495,16 @@ BI.shortcut("demo.searcher_view", Demo.Func);Demo.Face = BI.inherit(BI.Widget, { return { type: "bi.grid", items: [[{ - column: 0, - row: 0, - el: { - type: "bi.layout" - } - }, { - column: 1, - row: 0, el: { type: "bi.vertical", - cls: "face-config bi-border-left", + cls: "face-config bi-border-right", items: [this._createBaseConfig(), this._createCommonConfig()] } + }, { + el: { + type: "bi.layout" + } }]] }; }, diff --git a/dist/fineui.js b/dist/fineui.js index aca576914..a16dae54e 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -21565,469 +21565,499 @@ _.extend(BI.OB.prototype, { * * @cfg {JSON} options 配置属性 */ -BI.Widget = BI.inherit(BI.OB, { - _defaultConfig: function () { - return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), { - root: false, - tagName: "div", - attributes: null, - data: null, - tag: null, - disabled: false, - invisible: false, - invalid: false, - baseCls: "", - extraCls: "", - cls: "" - }); - }, +!(function () { + var lazy = (typeof document !== "undefined" && + typeof document.documentMode === "number") || + (typeof navigator !== "undefined" && + typeof navigator.userAgent === "string" && + /\bEdge\/\d/.test(navigator.userAgent)); + BI.Widget = BI.inherit(BI.OB, { + _defaultConfig: function () { + return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), { + root: false, + tagName: "div", + attributes: null, + data: null, + + tag: null, + disabled: false, + invisible: false, + invalid: false, + baseCls: "", + extraCls: "", + cls: "" + }); + }, - beforeInit: null, + beforeInit: null, - // 生命周期函数 - beforeCreate: null, + // 生命周期函数 + beforeCreate: null, - created: null, + created: null, - render: null, + render: null, - beforeMount: null, + beforeMount: null, - mounted: null, + mounted: null, - shouldUpdate: null, + shouldUpdate: null, - update: function () { - }, + update: function () { + }, - beforeDestroy: null, + beforeDestroy: null, - destroyed: null, + destroyed: null, - _init: function () { - BI.Widget.superclass._init.apply(this, arguments); - this._initRoot(); - this._initElementWidth(); - this._initElementHeight(); - this._initVisual(); - this._initState(); - if (this.beforeInit) { - this.__asking = true; - this.beforeInit(BI.bind(this._render, this)); - if (this.__asking === true) { - this.__async = true; + _init: function () { + BI.Widget.superclass._init.apply(this, arguments); + this._initRoot(); + this._initElementWidth(); + this._initElementHeight(); + this._initVisual(); + this._initState(); + if (this.isVisible()) { + this.rendered = true; + if (this.beforeInit) { + this.__asking = true; + this.beforeInit(BI.bind(this._render, this)); + if (this.__asking === true) { + this.__async = true; + } + } else { + this._render(); + } } - } else { - this._render(); - } - }, + if (this._isRoot) { + this._mount(); + } + }, - _render: function () { - this.__asking = false; - this.beforeCreate && this.beforeCreate(); - this._initElement(); - this._initEffects(); - this.created && this.created(); - }, + _render: function () { + this.__asking = false; + this.beforeCreate && this.beforeCreate(); + this._initElement(); + this._initEffects(); + this.created && this.created(); + }, - /** - * 初始化根节点 - * @private - */ - _initRoot: function () { - var o = this.options; - this.widgetName = o.widgetName || BI.uniqueId("widget"); - this._isRoot = o.root; - if (BI.isWidget(o.element)) { - if (o.element instanceof BI.Widget) { - this._parent = o.element; - this._parent.addWidget(this.widgetName, this); - } else { + /** + * 初始化根节点 + * @private + */ + _initRoot: function () { + var o = this.options; + this.widgetName = o.widgetName || BI.uniqueId("widget"); + this._isRoot = o.root; + if (BI.isWidget(o.element)) { + if (o.element instanceof BI.Widget) { + this._parent = o.element; + this._parent.addWidget(this.widgetName, this); + } else { + this._isRoot = true; + } + this.element = this.options.element.element; + } else if (o.element) { + // if (o.root !== true) { + // throw new Error("root is a required property"); + // } + this.element = $(o.element); this._isRoot = true; + } else { + this.element = $(document.createElement(o.tagName)); } - this.element = this.options.element.element; - } else if (o.element) { - // if (o.root !== true) { - // throw new Error("root is a required property"); - // } - this.element = $(o.element); - this._isRoot = true; - } else { - this.element = $(document.createElement(o.tagName)); - } - this.element._isWidget = true; - if (o.baseCls || o.extraCls || o.cls) { - this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || "")); - } - if (o.attributes) { - this.element.attr(o.attributes); - } - if (o.data) { - this.element.data(o.data); - } - this._children = {}; - }, - - _initElementWidth: function () { - var o = this.options; - if (BI.isWidthOrHeight(o.width)) { - this.element.css("width", o.width); - } - }, + this.element._isWidget = true; + if (o.baseCls || o.extraCls || o.cls) { + this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || "")); + } + if (o.attributes) { + this.element.attr(o.attributes); + } + if (o.data) { + this.element.data(o.data); + } + this._children = {}; + }, - _initElementHeight: function () { - var o = this.options; - if (BI.isWidthOrHeight(o.height)) { - this.element.css("height", o.height); - } - }, + _initElementWidth: function () { + var o = this.options; + if (BI.isWidthOrHeight(o.width)) { + this.element.css("width", o.width); + } + }, - _initVisual: function () { - var o = this.options; - if (o.invisible) { - // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 - this.element.css("display", "none"); - } - }, + _initElementHeight: function () { + var o = this.options; + if (BI.isWidthOrHeight(o.height)) { + this.element.css("height", o.height); + } + }, - _initEffects: function () { - var o = this.options; - if (o.disabled || o.invalid) { - if (this.options.disabled) { - this.setEnable(false); + _initVisual: function () { + var o = this.options; + if (o.invisible) { + // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 + this.element.css("display", "none"); } - if (this.options.invalid) { - this.setValid(false); + }, + + _initEffects: function () { + var o = this.options; + if (o.disabled || o.invalid) { + if (this.options.disabled) { + this.setEnable(false); + } + if (this.options.invalid) { + this.setValid(false); + } } - } - }, + }, - _initState: function () { - this._isMounted = false; - }, + _initState: function () { + this._isMounted = false; + }, - _initElement: function () { - var self = this; - var els = this.render && this.render(); - if (BI.isPlainObject(els)) { - els = [els]; - } - if (BI.isArray(els)) { - BI.each(els, function (i, el) { - BI.createWidget(el, { - element: self + _initElement: function () { + var self = this; + var els = this.render && 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 instanceof BI.Layout)) { - this._mount(); - // } - }, + } + // if (this._isRoot === true || !(this instanceof BI.Layout)) { + this._mount(); + // } + }, - _setParent: function (parent) { - this._parent = parent; - }, + _setParent: function (parent) { + this._parent = parent; + }, - _mount: function () { - var self = this; - var isMounted = this._isMounted; - if (isMounted || !this.isVisible() || this.__asking === true) { - return; - } - if (this._isRoot === true) { - isMounted = true; - } else if (this._parent && this._parent._isMounted === true) { - isMounted = true; - } - if (!isMounted) { - return; - } - this.beforeMount && this.beforeMount(); - this._isMounted = true; - this._mountChildren && this._mountChildren(); - BI.each(this._children, function (i, widget) { - !self.isEnabled() && widget._setEnable(false); - !self.isValid() && widget._setValid(false); - widget._mount && widget._mount(); - }); - this.mounted && this.mounted(); - }, + _mount: function () { + var self = this; + var isMounted = this._isMounted; + if (this._isMounting || isMounted || !this.isVisible() || this.__asking === true) { + return; + } + if (this._isRoot === true) { + isMounted = true; + } else if (this._parent && this._parent._isMounted === true) { + isMounted = true; + } + if (!isMounted) { + return; + } + this._isMounting = true; + if (!this.rendered) { + if (this.beforeInit) { + this.__asking = true; + this.beforeInit(BI.bind(this._render, this)); + if (this.__asking === true) { + this.__async = true; + } + } else { + this._render(); + } + } - _mountChildren: null, + this.beforeMount && this.beforeMount(); + this._isMounted = true; + !lazy && this._mountChildren && this._mountChildren(); + BI.each(this._children, function (i, widget) { + !self.isEnabled() && widget._setEnable(false); + !self.isValid() && widget._setValid(false); + widget._mount && widget._mount(); + }); + lazy && this._mountChildren && this._mountChildren(); + this.mounted && this.mounted(); + this._isMounting = false; + }, - isMounted: function () { - return this._isMounted; - }, + _mountChildren: null, - setWidth: function (w) { - this.options.width = w; - this._initElementWidth(); - }, + isMounted: function () { + return this._isMounted; + }, - setHeight: function (h) { - this.options.height = h; - this._initElementHeight(); - }, + setWidth: function (w) { + this.options.width = w; + this._initElementWidth(); + }, - _setEnable: function (enable) { - if (enable === true) { - this.options.disabled = false; - } else if (enable === false) { - this.options.disabled = true; - } - // 递归将所有子组件使能 - BI.each(this._children, function (i, child) { - !child._manualSetEnable && child._setEnable && child._setEnable(enable); - }); - }, + setHeight: function (h) { + this.options.height = h; + this._initElementHeight(); + }, - _setValid: function (valid) { - if (valid === true) { - this.options.invalid = false; - } else if (valid === false) { - this.options.invalid = true; - } - // 递归将所有子组件使有效 - BI.each(this._children, function (i, child) { - !child._manualSetValid && child._setValid && child._setValid(valid); - }); - }, + _setEnable: function (enable) { + if (enable === true) { + this.options.disabled = false; + } else if (enable === false) { + this.options.disabled = true; + } + // 递归将所有子组件使能 + BI.each(this._children, function (i, child) { + !child._manualSetEnable && child._setEnable && child._setEnable(enable); + }); + }, - _setVisible: function (visible) { - if (visible === true) { - this.options.invisible = false; - } else if (visible === false) { - this.options.invisible = true; - } - }, + _setValid: function (valid) { + if (valid === true) { + this.options.invalid = false; + } else if (valid === false) { + this.options.invalid = true; + } + // 递归将所有子组件使有效 + BI.each(this._children, function (i, child) { + !child._manualSetValid && child._setValid && child._setValid(valid); + }); + }, - setEnable: function (enable) { - this._manualSetEnable = true; - this._setEnable(enable); - if (enable === true) { - this.element.removeClass("base-disabled disabled"); - } else if (enable === false) { - this.element.addClass("base-disabled disabled"); - } - }, + _setVisible: function (visible) { + if (visible === true) { + this.options.invisible = false; + } else if (visible === false) { + this.options.invisible = true; + } + }, - setVisible: function (visible) { - this._setVisible(visible); - if (visible === true) { - // 用this.element.show()会把display属性改成block - this.element.css("display", ""); - this._mount(); - } else if (visible === false) { - this.element.css("display", "none"); - } - this.fireEvent(BI.Events.VIEW, visible); - }, + setEnable: function (enable) { + this._manualSetEnable = true; + this._setEnable(enable); + if (enable === true) { + this.element.removeClass("base-disabled disabled"); + } else if (enable === false) { + this.element.addClass("base-disabled disabled"); + } + }, - setValid: function (valid) { - this._manualSetValid = true; - this._setValid(valid); - if (valid === true) { - this.element.removeClass("base-invalid invalid"); - } else if (valid === false) { - this.element.addClass("base-invalid invalid"); - } - }, + setVisible: function (visible) { + this._setVisible(visible); + if (visible === true) { + // 用this.element.show()会把display属性改成block + this.element.css("display", ""); + this._mount(); + } else if (visible === false) { + this.element.css("display", "none"); + } + this.fireEvent(BI.Events.VIEW, visible); + }, - doBehavior: function () { - var args = arguments; - // 递归将所有子组件使有效 - BI.each(this._children, function (i, child) { - child.doBehavior && child.doBehavior.apply(child, args); - }); - }, + setValid: function (valid) { + this._manualSetValid = true; + this._setValid(valid); + if (valid === true) { + this.element.removeClass("base-invalid invalid"); + } else if (valid === false) { + this.element.addClass("base-invalid invalid"); + } + }, - getWidth: function () { - return this.options.width; - }, + doBehavior: function () { + var args = arguments; + // 递归将所有子组件使有效 + BI.each(this._children, function (i, child) { + child.doBehavior && child.doBehavior.apply(child, args); + }); + }, - getHeight: function () { - return this.options.height; - }, + getWidth: function () { + return this.options.width; + }, - isValid: function () { - return !this.options.invalid; - }, + getHeight: function () { + return this.options.height; + }, - addWidget: function (name, widget) { - var self = this; - if (name instanceof BI.Widget) { - widget = name; - name = widget.getName(); - } - if (BI.isKey(name)) { - name = name + ""; - } - name = name || widget.getName() || BI.uniqueId("widget"); - if (this._children[name]) { - throw new Error("name has already been existed"); - } - widget._setParent && widget._setParent(this); - widget.on(BI.Events.DESTROY, function () { - BI.remove(self._children, this); - }); - return (this._children[name] = widget); - }, + isValid: function () { + return !this.options.invalid; + }, - getWidgetByName: function (name) { - if (!BI.isKey(name) || name === this.getName()) { - return this; - } - name = name + ""; - var widget = void 0, other = {}; - BI.any(this._children, function (i, wi) { - if (i === name) { - widget = wi; - return true; + addWidget: function (name, widget) { + var self = this; + if (name instanceof BI.Widget) { + widget = name; + name = widget.getName(); } - other[i] = wi; - }); - if (!widget) { - BI.any(other, function (i, wi) { - return (widget = wi.getWidgetByName(i)); + if (BI.isKey(name)) { + name = name + ""; + } + name = name || widget.getName() || BI.uniqueId("widget"); + if (this._children[name]) { + throw new Error("name has already been existed"); + } + widget._setParent && widget._setParent(this); + widget.on(BI.Events.DESTROY, function () { + BI.remove(self._children, this); }); - } - return widget; - }, + return (this._children[name] = widget); + }, - removeWidget: function (nameOrWidget) { - var self = this; - if (BI.isWidget(nameOrWidget)) { - BI.remove(this._children, nameOrWidget); - } else { - delete this._children[nameOrWidget]; - } - }, + getWidgetByName: function (name) { + if (!BI.isKey(name) || name === this.getName()) { + return this; + } + name = name + ""; + var widget = void 0, other = {}; + BI.any(this._children, function (i, wi) { + if (i === name) { + widget = wi; + return true; + } + other[i] = wi; + }); + if (!widget) { + BI.any(other, function (i, wi) { + return (widget = wi.getWidgetByName(i)); + }); + } + return widget; + }, - hasWidget: function (name) { - return this._children[name] != null; - }, + removeWidget: function (nameOrWidget) { + var self = this; + if (BI.isWidget(nameOrWidget)) { + BI.remove(this._children, nameOrWidget); + } else { + delete this._children[nameOrWidget]; + } + }, - getName: function () { - return this.widgetName; - }, + hasWidget: function (name) { + return this._children[name] != null; + }, - setTag: function (tag) { - this.options.tag = tag; - }, + getName: function () { + return this.widgetName; + }, - getTag: function () { - return this.options.tag; - }, + setTag: function (tag) { + this.options.tag = tag; + }, - attr: function (key, value) { - var self = this; - if (BI.isPlainObject(key)) { - BI.each(key, function (k, v) { - self.attr(k, v); - }); - return; - } - if (BI.isNotNull(value)) { - return this.options[key] = value; - } - return this.options[key]; - }, + getTag: function () { + return this.options.tag; + }, - getText: function () { + attr: function (key, value) { + var self = this; + if (BI.isPlainObject(key)) { + BI.each(key, function (k, v) { + self.attr(k, v); + }); + return; + } + if (BI.isNotNull(value)) { + return this.options[key] = value; + } + return this.options[key]; + }, - }, + getText: function () { - setText: function (text) { + }, - }, + setText: function (text) { - getValue: function () { + }, - }, + getValue: function () { - setValue: function (value) { + }, - }, + setValue: function (value) { - isEnabled: function () { - return !this.options.disabled; - }, + }, - isVisible: function () { - return !this.options.invisible; - }, + isEnabled: function () { + return !this.options.disabled; + }, - disable: function () { - this.setEnable(false); - }, + isVisible: function () { + return !this.options.invisible; + }, - enable: function () { - this.setEnable(true); - }, + disable: function () { + this.setEnable(false); + }, - valid: function () { - this.setValid(true); - }, + enable: function () { + this.setEnable(true); + }, - invalid: function () { - this.setValid(false); - }, + valid: function () { + this.setValid(true); + }, - invisible: function () { - this.setVisible(false); - }, + invalid: function () { + this.setValid(false); + }, - visible: function () { - this.setVisible(true); - }, + invisible: function () { + this.setVisible(false); + }, - __d: function () { - this.beforeDestroy && this.beforeDestroy(); - BI.each(this._children, function (i, widget) { - widget && widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.destroyed && this.destroyed(); - }, + visible: function () { + this.setVisible(true); + }, - _unMount: function () { - this.__d(); - this.fireEvent(BI.Events.UNMOUNT); - this.purgeListeners(); - }, + __d: function () { + this.beforeDestroy && this.beforeDestroy(); + BI.each(this._children, function (i, widget) { + widget && widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + this.destroyed && this.destroyed(); + }, - isolate: function () { - if (this._parent) { - this._parent.removeWidget(this); - } - BI.DOM.hang([this]); - }, + _unMount: function () { + this.__d(); + this.fireEvent(BI.Events.UNMOUNT); + this.purgeListeners(); + }, - empty: function () { - BI.each(this._children, function (i, widget) { - widget && widget._unMount && widget._unMount(); - }); - this._children = {}; - this.element.empty(); - }, + isolate: function () { + if (this._parent) { + this._parent.removeWidget(this); + } + BI.DOM.hang([this]); + }, - _destroy: function () { - this.__d(); - this.element.destroy(); - this.purgeListeners(); - }, + empty: function () { + BI.each(this._children, function (i, widget) { + widget && widget._unMount && widget._unMount(); + }); + this._children = {}; + this.element.empty(); + }, - destroy: function () { - this.__d(); - this.element.destroy(); - this.fireEvent(BI.Events.DESTROY); - this._purgeRef(); - this.purgeListeners(); - } -});(function () { + _destroy: function () { + this.__d(); + this.element.destroy(); + this.purgeListeners(); + }, + + destroy: function () { + this.__d(); + this.element.destroy(); + this.fireEvent(BI.Events.DESTROY); + this._purgeRef(); + this.purgeListeners(); + } + }); +})(); +(function () { var kv = {}; BI.shortcut = function (xtype, cls) { if (kv[xtype] != null) { @@ -24560,6 +24590,10 @@ BI.Layout = BI.inherit(BI.Widget, { } }, + appendFragment: function (frag) { + this.element.append(frag); + }, + _mountChildren: function () { var self = this; var frag = document.createDocumentFragment(); @@ -24571,7 +24605,7 @@ BI.Layout = BI.inherit(BI.Widget, { } }); if (hasChild === true) { - this.element.append(frag); + this.appendFragment(frag); } }, @@ -30497,20 +30531,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -30614,20 +30637,9 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -30904,20 +30916,9 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, _getWrapper: function () { @@ -31498,20 +31499,9 @@ BI.FlexCenterLayout = 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -31583,20 +31573,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -31668,20 +31647,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { @@ -32811,23 +32779,11 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, - resize: function () { // console.log("horizontal layout do not need to resize"); }, @@ -33494,20 +33450,9 @@ BI.TdLayout = BI.inherit(BI.Layout, { 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); - } + appendFragment: function (frag) { + this.$table.append(frag); + this.element.append(this.$table); }, resize: function () { @@ -68197,12 +68142,15 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }, value: this.storeValue }); - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.button_group], + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({ + scrolly: true, vgap: 5 - }); + }, opts.logic, { + items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Top, this.button_group) + })))); this.button_group.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); @@ -81545,7 +81493,7 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, { }); BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { - function initWatch (vm, watch) { + function initWatch(vm, watch) { vm._watchers || (vm._watchers = []); for (var key in watch) { var handler = watch[key]; @@ -81559,7 +81507,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { } } - function createWatcher (vm, keyOrFn, handler) { + function createWatcher(vm, keyOrFn, handler) { return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), { store: vm.store }); @@ -81568,24 +81516,24 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { var target = null; var targetStack = []; - function pushTarget (_target) { + function pushTarget(_target) { if (target) targetStack.push(target); Fix.Model.target = target = _target; } - function popTarget () { + function popTarget() { Fix.Model.target = target = targetStack.pop(); } var context = null; var contextStack = []; - function pushContext (_context) { + function pushContext(_context) { if (context) contextStack.push(context); Fix.Model.context = context = _context; } - function popContext () { + function popContext() { Fix.Model.context = context = contextStack.pop(); } @@ -81606,7 +81554,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { }, options); }; - function findStore (widget) { + function findStore(widget) { if (target != null) { return target; } @@ -81652,12 +81600,11 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { }; }); - var _init = BI.Widget.prototype._init; - BI.Widget.prototype._init = function () { - var self = this; + function createStore() { var needPop = false; - if (window.Fix && this._store) { + if (!this._storeCreated && window.Fix && this._store && this.isVisible()) { var store = findStore(this.options.context || this.options.element); + this._storeCreated = true; if (store) { pushTarget(store); needPop = true; @@ -81674,6 +81621,13 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { } needPop = true; } + return needPop; + } + + var _init = BI.Widget.prototype._init; + BI.Widget.prototype._init = function () { + var self = this; + var needPop = createStore.call(this); _init.apply(this, arguments); needPop && popTarget(); }; @@ -81712,6 +81666,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { _.each(["_mount"], function (name) { var old = BI.Widget.prototype[name]; old && (BI.Widget.prototype[name] = function () { + createStore.call(this); this.store && pushTarget(this.store); var res = old.apply(this, arguments); this.store && popTarget(); diff --git a/dist/widget.js b/dist/widget.js index c5f9df69a..00b98417b 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -9558,12 +9558,15 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }, value: this.storeValue }); - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.button_group], + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({ + scrolly: true, vgap: 5 - }); + }, opts.logic, { + items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Top, this.button_group) + })))); this.button_group.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index f338fa5a2..b0d476243 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -63,6 +63,10 @@ BI.Layout = BI.inherit(BI.Widget, { } }, + appendFragment: function (frag) { + this.element.append(frag); + }, + _mountChildren: function () { var self = this; var frag = document.createDocumentFragment(); @@ -74,7 +78,7 @@ BI.Layout = BI.inherit(BI.Widget, { } }); if (hasChild === true) { - this.element.append(frag); + this.appendFragment(frag); } }, diff --git a/src/core/wrapper/layout/adapt/adapt.center.js b/src/core/wrapper/layout/adapt/adapt.center.js index e80fbcf31..a09aaf4f2 100644 --- a/src/core/wrapper/layout/adapt/adapt.center.js +++ b/src/core/wrapper/layout/adapt/adapt.center.js @@ -87,20 +87,9 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { diff --git a/src/core/wrapper/layout/adapt/adapt.horizontal.js b/src/core/wrapper/layout/adapt/adapt.horizontal.js index 7b6fb1a69..3b672239c 100644 --- a/src/core/wrapper/layout/adapt/adapt.horizontal.js +++ b/src/core/wrapper/layout/adapt/adapt.horizontal.js @@ -86,20 +86,9 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, resize: function () { diff --git a/src/core/wrapper/layout/adapt/adapt.vertical.js b/src/core/wrapper/layout/adapt/adapt.vertical.js index d2cf0e03e..542be037d 100644 --- a/src/core/wrapper/layout/adapt/adapt.vertical.js +++ b/src/core/wrapper/layout/adapt/adapt.vertical.js @@ -87,20 +87,9 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, _getWrapper: function () { 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 220d6691f..a88b91534 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js @@ -24,20 +24,9 @@ BI.FlexCenterLayout = 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { 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 71274eac9..6940fc6a9 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js @@ -54,20 +54,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { 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 9800237fb..85f4109b3 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 @@ -54,20 +54,9 @@ 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); - } + appendFragment: function (frag) { + this.$wrapper.append(frag); + this.element.append(this.$wrapper); }, _getWrapper: function () { diff --git a/src/core/wrapper/layout/layout.horizontal.js b/src/core/wrapper/layout/layout.horizontal.js index b2d7a8b9a..20f90e5df 100644 --- a/src/core/wrapper/layout/layout.horizontal.js +++ b/src/core/wrapper/layout/layout.horizontal.js @@ -87,23 +87,11 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { return td; }, - _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); - } + appendFragment: function (frag) { + this.$tr.append(frag); + this.element.append(this.$table); }, - resize: function () { // console.log("horizontal layout do not need to resize"); }, diff --git a/src/core/wrapper/layout/layout.td.js b/src/core/wrapper/layout/layout.td.js index 476160927..1714f4da8 100644 --- a/src/core/wrapper/layout/layout.td.js +++ b/src/core/wrapper/layout/layout.td.js @@ -119,20 +119,9 @@ BI.TdLayout = BI.inherit(BI.Layout, { 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); - } + appendFragment: function (frag) { + this.$table.append(frag); + this.element.append(this.$table); }, resize: function () {