forked from fanruan/fineui
Browse Source
Merge in VISUAL/fineui from ~ZHENFEI.LI/fineui:es6 to es6 * commit '0743286aeab2f97eaa800902a1661e74b761ab60': KERNEL-14035 refactor: layout相关es6es6
Zhenfei.Li-李振飞
2 years ago
34 changed files with 1901 additions and 1603 deletions
@ -0,0 +1,2 @@
|
||||
export { Layout } from "./layout"; |
||||
export * from "./layout/index"; |
@ -1,47 +1,54 @@
|
||||
import { shortcut } from "../../../decorator"; |
||||
import { Layout } from "../../layout"; |
||||
import { extend, isFunction } from "../../../2.base"; |
||||
|
||||
/** |
||||
* absolute实现的居中布局 |
||||
* @class BI.AbsoluteCenterLayout |
||||
* @extends BI.Layout |
||||
* @class AbsoluteCenterLayout |
||||
* @extends Layout |
||||
*/ |
||||
BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.AbsoluteCenterLayout.superclass.props.apply(this, arguments), { |
||||
@shortcut() |
||||
export class AbsoluteCenterLayout extends Layout { |
||||
static xtype ="bi.absolute_center_adapt"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-abs-c-a", |
||||
hgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
vgap: 0, |
||||
tgap: 0, |
||||
bgap: 0 |
||||
bgap: 0, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
render: function () { |
||||
BI.AbsoluteCenterLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
self.populate(newValue); |
||||
render() { |
||||
super.render(...arguments); |
||||
const o = this.options; |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
this.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.AbsoluteCenterLayout.superclass._addElement.apply(this, arguments); |
||||
_addElement(i, item) { |
||||
const o = this.options; |
||||
const w = super._addElement(...arguments); |
||||
w.element.css({ |
||||
position: "absolute", |
||||
left: this._optimiseGap(o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item)), |
||||
right: this._optimiseGap(o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item)), |
||||
top: this._optimiseGap(o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item)), |
||||
bottom: this._optimiseGap(o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item)), |
||||
margin: "auto" |
||||
margin: "auto", |
||||
}); |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.AbsoluteCenterLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.absolute_center_adapt", BI.AbsoluteCenterLayout); |
||||
} |
||||
|
@ -1,8 +1,9 @@
|
||||
import { shortcut } from "../../../decorator"; |
||||
|
||||
/** |
||||
* 水平方向居中容器 |
||||
* @class BI.HorizontalAdaptLayout |
||||
* @extends BI.Layout |
||||
*/ |
||||
BI.HorizontalAdaptLayout = function () { |
||||
}; |
||||
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout); |
||||
@shortcut() |
||||
export class HorizontalAdaptLayout { |
||||
static xtype = "bi.horizontal_adapt"; |
||||
} |
||||
|
@ -1,44 +1,50 @@
|
||||
import { shortcut } from "../../../decorator"; |
||||
import { Layout } from "../../layout"; |
||||
import { extend, isFunction } from "../../../2.base"; |
||||
|
||||
/** |
||||
* 水平方向居中自适应容器 |
||||
* @class BI.HorizontalAutoLayout |
||||
* @extends BI.Layout |
||||
* @class HorizontalAutoLayout |
||||
* @extends Layout |
||||
*/ |
||||
BI.HorizontalAutoLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.HorizontalAutoLayout.superclass.props.apply(this, arguments), { |
||||
@shortcut() |
||||
export class HorizontalAutoLayout extends Layout { |
||||
static xtype = "bi.horizontal_auto"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-h-o", |
||||
hgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
vgap: 0, |
||||
tgap: 0, |
||||
bgap: 0 |
||||
bgap: 0, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
render: function () { |
||||
BI.HorizontalAutoLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
self.populate(newValue); |
||||
render() { |
||||
super.render(...arguments); |
||||
const o = this.options; |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
this.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.HorizontalAutoLayout.superclass._addElement.apply(this, arguments); |
||||
_addElement(i, item) { |
||||
const w = super._addElement(...arguments); |
||||
w.element.css({ |
||||
position: "relative", |
||||
margin: "0px auto" |
||||
margin: "0px auto", |
||||
}); |
||||
this._handleGap(w, item, null, i); |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.horizontal_auto", BI.HorizontalAutoLayout); |
||||
} |
||||
|
@ -0,0 +1,13 @@
|
||||
export { AbsoluteCenterLayout } from "./absolute.center"; |
||||
export { AbsoluteHorizontalLayout } from "./absolute.horizontal"; |
||||
export { AbsoluteLeftRightVerticalAdaptLayout, AbsoluteRightVerticalAdaptLayout } from "./absolute.leftrightvertical"; |
||||
export { AbsoluteVerticalLayout } from "./absolute.vertical"; |
||||
export { CenterAdaptLayout } from "./adapt.center"; |
||||
export { HorizontalAdaptLayout } from "./adapt.horizontal"; |
||||
export { LeftRightVerticalAdaptLayout, LeftVerticalAdaptLayout, RightVerticalAdaptLayout } from "./adapt.leftrightvertical"; |
||||
export { TableAdaptLayout } from "./adapt.table"; |
||||
export { VerticalAdaptLayout } from "./adapt.vertical"; |
||||
export { HorizontalAutoLayout } from "./auto.horizontal"; |
||||
export { InlineCenterAdaptLayout } from "./inline.center"; |
||||
export { InlineHorizontalAdaptLayout } from "./inline.horizontal"; |
||||
export { InlineVerticalAdaptLayout } from "./inline.vertical"; |
@ -0,0 +1,17 @@
|
||||
export { AbsoluteLayout } from "./layout.absolute"; |
||||
export { AdaptiveLayout } from "./layout.adaptive"; |
||||
export { BorderLayout } from "./layout.border"; |
||||
export { CardLayout } from "./layout.card"; |
||||
export { DefaultLayout } from "./layout.default"; |
||||
export { DivisionLayout } from "./layout.division"; |
||||
export { FloatLeftLayout, FloatRightLayout } from "./layout.flow"; |
||||
export { GridLayout } from "./layout.grid"; |
||||
export { HorizontalLayout } from "./layout.horizontal"; |
||||
export { InlineLayout } from "./layout.inline"; |
||||
export { LatticeLayout } from "./layout.lattice"; |
||||
export { TableLayout } from "./layout.table"; |
||||
export { HTapeLayout, VTapeLayout } from "./layout.tape"; |
||||
export { TdLayout } from "./layout.td"; |
||||
export { VerticalLayout } from "./layout.vertical"; |
||||
export { WindowLayout } from "./layout.window"; |
||||
export * from "./adapt"; |
@ -1,115 +1,119 @@
|
||||
import { shortcut } from "../../decorator"; |
||||
import { Layout } from "../layout"; |
||||
import { extend, isFunction, map, parseFloat, isKey, pick, isNotNull, isNumber } from "../../2.base"; |
||||
|
||||
/** |
||||
* 固定子组件上下左右的布局容器 |
||||
* @class BI.AbsoluteLayout |
||||
* @extends BI.Layout |
||||
*/ |
||||
BI.AbsoluteLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.AbsoluteLayout.superclass.props.apply(this, arguments), { |
||||
@shortcut() |
||||
export class AbsoluteLayout extends Layout { |
||||
static xtype = "bi.absolute"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-abs", |
||||
hgap: null, |
||||
vgap: null, |
||||
lgap: null, |
||||
rgap: null, |
||||
tgap: null, |
||||
bgap: null |
||||
bgap: null, |
||||
}); |
||||
}, |
||||
render: function () { |
||||
BI.AbsoluteLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
self.populate(newValue); |
||||
} |
||||
|
||||
render() { |
||||
super.render(...arguments); |
||||
const o = this.options; |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
this.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.AbsoluteLayout.superclass._addElement.apply(this, arguments); |
||||
var left = 0, right = 0, top = 0, bottom = 0; |
||||
var offsets = BI.pick(item, ["top", "right", "bottom", "left"]); |
||||
_addElement(i, item) { |
||||
const o = this.options; |
||||
const w = super._addElement(...arguments); |
||||
let left = 0, right = 0, top = 0, bottom = 0; |
||||
let offsets = pick(item, ["top", "right", "bottom", "left"]); |
||||
|
||||
if (BI.isKey(item.inset)) { |
||||
var insets = BI.map((item.inset + "").split(" "), function (i, str) { |
||||
return BI.parseFloat(str); |
||||
}); |
||||
if (isKey(item.inset)) { |
||||
const insets = map((`${item.inset}`).split(" "), (i, str) => parseFloat(str)); |
||||
switch (insets.length) { |
||||
case 1: |
||||
offsets = {top: insets[0], bottom: insets[0], left: insets[0], right: insets[0]} |
||||
break; |
||||
case 2: |
||||
offsets = {top: insets[0], bottom: insets[0], left: insets[1], right: insets[1]} |
||||
break; |
||||
case 3: |
||||
offsets = {top: insets[0], left: insets[1], right: insets[1], bottom: insets[2]} |
||||
break |
||||
case 4: |
||||
default: |
||||
offsets = {top: insets[0], right: insets[1], bottom: insets[2], left: insets[3]} |
||||
break; |
||||
case 1: |
||||
offsets = { top: insets[0], bottom: insets[0], left: insets[0], right: insets[0] }; |
||||
break; |
||||
case 2: |
||||
offsets = { top: insets[0], bottom: insets[0], left: insets[1], right: insets[1] }; |
||||
break; |
||||
case 3: |
||||
offsets = { top: insets[0], left: insets[1], right: insets[1], bottom: insets[2] }; |
||||
break; |
||||
case 4: |
||||
default: |
||||
offsets = { top: insets[0], right: insets[1], bottom: insets[2], left: insets[3] }; |
||||
break; |
||||
} |
||||
} |
||||
if (BI.isNotNull(offsets.left)) { |
||||
w.element.css({left: BI.isNumber(offsets.left) ? this._optimiseGap(offsets.left) : offsets.left}); |
||||
if (isNotNull(offsets.left)) { |
||||
w.element.css({ left: isNumber(offsets.left) ? this._optimiseGap(offsets.left) : offsets.left }); |
||||
left += offsets.left; |
||||
} |
||||
if (BI.isNotNull(offsets.right)) { |
||||
w.element.css({right: BI.isNumber(offsets.right) ? this._optimiseGap(offsets.right) : offsets.right}); |
||||
if (isNotNull(offsets.right)) { |
||||
w.element.css({ right: isNumber(offsets.right) ? this._optimiseGap(offsets.right) : offsets.right }); |
||||
right += offsets.right; |
||||
} |
||||
if (BI.isNotNull(offsets.top)) { |
||||
w.element.css({top: BI.isNumber(offsets.top) ? this._optimiseGap(offsets.top) : offsets.top}); |
||||
if (isNotNull(offsets.top)) { |
||||
w.element.css({ top: isNumber(offsets.top) ? this._optimiseGap(offsets.top) : offsets.top }); |
||||
top += offsets.top; |
||||
} |
||||
if (BI.isNotNull(offsets.bottom)) { |
||||
w.element.css({bottom: BI.isNumber(offsets.bottom) ? this._optimiseGap(offsets.bottom) : offsets.bottom}); |
||||
if (isNotNull(offsets.bottom)) { |
||||
w.element.css({ bottom: isNumber(offsets.bottom) ? this._optimiseGap(offsets.bottom) : offsets.bottom }); |
||||
bottom += offsets.bottom; |
||||
} |
||||
|
||||
if (BI.isNotNull(o.hgap)) { |
||||
if (isNotNull(o.hgap)) { |
||||
left += o.hgap; |
||||
w.element.css({left: this._optimiseGap(left)}); |
||||
w.element.css({ left: this._optimiseGap(left) }); |
||||
right += o.hgap; |
||||
w.element.css({right: this._optimiseGap(right)}); |
||||
w.element.css({ right: this._optimiseGap(right) }); |
||||
} |
||||
if (BI.isNotNull(o.vgap)) { |
||||
if (isNotNull(o.vgap)) { |
||||
top += o.vgap; |
||||
w.element.css({top: this._optimiseGap(top)}); |
||||
w.element.css({ top: this._optimiseGap(top) }); |
||||
bottom += o.vgap; |
||||
w.element.css({bottom: this._optimiseGap(bottom)}); |
||||
w.element.css({ bottom: this._optimiseGap(bottom) }); |
||||
} |
||||
|
||||
if (BI.isNotNull(o.lgap)) { |
||||
if (isNotNull(o.lgap)) { |
||||
left += o.lgap; |
||||
w.element.css({left: this._optimiseGap(left)}); |
||||
w.element.css({ left: this._optimiseGap(left) }); |
||||
} |
||||
if (BI.isNotNull(o.rgap)) { |
||||
if (isNotNull(o.rgap)) { |
||||
right += o.rgap; |
||||
w.element.css({right: this._optimiseGap(right)}); |
||||
w.element.css({ right: this._optimiseGap(right) }); |
||||
} |
||||
if (BI.isNotNull(o.tgap)) { |
||||
if (isNotNull(o.tgap)) { |
||||
top += o.tgap; |
||||
w.element.css({top: this._optimiseGap(top)}); |
||||
w.element.css({ top: this._optimiseGap(top) }); |
||||
} |
||||
if (BI.isNotNull(o.bgap)) { |
||||
if (isNotNull(o.bgap)) { |
||||
bottom += o.bgap; |
||||
w.element.css({bottom: this._optimiseGap(bottom)}); |
||||
w.element.css({ bottom: this._optimiseGap(bottom) }); |
||||
} |
||||
|
||||
if (BI.isNotNull(item.width)) { |
||||
w.element.css({width: BI.isNumber(item.width) ? this._optimiseGap(item.width) : item.width}); |
||||
if (isNotNull(item.width)) { |
||||
w.element.css({ width: isNumber(item.width) ? this._optimiseGap(item.width) : item.width }); |
||||
} |
||||
if (BI.isNotNull(item.height)) { |
||||
w.element.css({height: BI.isNumber(item.height) ? this._optimiseGap(item.height) : item.height}); |
||||
if (isNotNull(item.height)) { |
||||
w.element.css({ height: isNumber(item.height) ? this._optimiseGap(item.height) : item.height }); |
||||
} |
||||
w.element.css({position: "absolute"}); |
||||
w.element.css({ position: "absolute" }); |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.AbsoluteLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.absolute", BI.AbsoluteLayout); |
||||
} |
||||
|
@ -1,63 +1,70 @@
|
||||
BI.AdaptiveLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.AdaptiveLayout.superclass.props.apply(this, arguments), { |
||||
import { shortcut } from "../../decorator"; |
||||
import { Layout } from "../layout"; |
||||
import { extend, isNumber, isNotNull, isFunction } from "../../2.base"; |
||||
|
||||
@shortcut() |
||||
export class AdaptiveLayout extends Layout { |
||||
static xtype = "bi.adaptive"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-adaptive", |
||||
hgap: 0, |
||||
vgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
tgap: 0, |
||||
bgap: 0 |
||||
bgap: 0, |
||||
}); |
||||
}, |
||||
render: function () { |
||||
BI.AdaptiveLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
} |
||||
|
||||
render() { |
||||
super.render(...arguments); |
||||
const self = this, o = this.options; |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
self.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.AdaptiveLayout.superclass._addElement.apply(this, arguments); |
||||
w.element.css({position: "relative"}); |
||||
if (BI.isNotNull(item.left)) { |
||||
_addElement(i, item) { |
||||
const w = super._addElement(...arguments); |
||||
w.element.css({ position: "relative" }); |
||||
if (isNotNull(item.left)) { |
||||
w.element.css({ |
||||
left: BI.isNumber(item.left) ? this._optimiseGap(item.left) : item.left |
||||
left: isNumber(item.left) ? this._optimiseGap(item.left) : item.left, |
||||
}); |
||||
} |
||||
if (BI.isNotNull(item.right)) { |
||||
if (isNotNull(item.right)) { |
||||
w.element.css({ |
||||
right: BI.isNumber(item.right) ? this._optimiseGap(item.right) : item.right |
||||
right: isNumber(item.right) ? this._optimiseGap(item.right) : item.right, |
||||
}); |
||||
} |
||||
if (BI.isNotNull(item.top)) { |
||||
if (isNotNull(item.top)) { |
||||
w.element.css({ |
||||
top: BI.isNumber(item.top) ? this._optimiseGap(item.top) : item.top |
||||
top: isNumber(item.top) ? this._optimiseGap(item.top) : item.top, |
||||
}); |
||||
} |
||||
if (BI.isNotNull(item.bottom)) { |
||||
if (isNotNull(item.bottom)) { |
||||
w.element.css({ |
||||
bottom: BI.isNumber(item.bottom) ? this._optimiseGap(item.bottom) : item.bottom |
||||
bottom: isNumber(item.bottom) ? this._optimiseGap(item.bottom) : item.bottom, |
||||
}); |
||||
} |
||||
|
||||
this._handleGap(w, item); |
||||
|
||||
if (BI.isNotNull(item.width)) { |
||||
w.element.css({width: BI.isNumber(item.width) ? this._optimiseGap(item.width) : item.width}); |
||||
if (isNotNull(item.width)) { |
||||
w.element.css({ width: isNumber(item.width) ? this._optimiseGap(item.width) : item.width }); |
||||
} |
||||
if (BI.isNotNull(item.height)) { |
||||
w.element.css({height: BI.isNumber(item.height) ? this._optimiseGap(item.height) : item.height}); |
||||
if (isNotNull(item.height)) { |
||||
w.element.css({ height: isNumber(item.height) ? this._optimiseGap(item.height) : item.height }); |
||||
} |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.AbsoluteLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.adaptive", BI.AdaptiveLayout); |
||||
} |
||||
|
@ -1,39 +1,47 @@
|
||||
import { shortcut } from "../../decorator"; |
||||
import { Layout } from "../layout"; |
||||
import { extend, isFunction } from "../../2.base"; |
||||
|
||||
/** |
||||
* 默认的布局方式 |
||||
* |
||||
* @class BI.DefaultLayout |
||||
* @extends BI.Layout |
||||
* @class DefaultLayout |
||||
* @extends Layout |
||||
*/ |
||||
BI.DefaultLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.DefaultLayout.superclass.props.apply(this, arguments), { |
||||
@shortcut() |
||||
export class DefaultLayout extends Layout { |
||||
static xtype = "bi.default"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
hgap: 0, |
||||
vgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
tgap: 0, |
||||
bgap: 0, |
||||
items: [] |
||||
items: [], |
||||
}); |
||||
}, |
||||
render: function () { |
||||
BI.DefaultLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
self.populate(newValue); |
||||
} |
||||
|
||||
render() { |
||||
super.render(...arguments); |
||||
const o = this.options; |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
this.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var w = BI.DefaultLayout.superclass._addElement.apply(this, arguments); |
||||
_addElement(i, item) { |
||||
const w = super._addElement(...arguments); |
||||
this._handleGap(w, item); |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.DefaultLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.default", BI.DefaultLayout); |
||||
} |
||||
|
@ -1,183 +1,196 @@
|
||||
import { shortcut } from "../../decorator"; |
||||
import { Layout } from "../layout"; |
||||
import { extend, isFunction, isNotNull, isNumber } from "../../2.base"; |
||||
import { pixFormat } from "../../constant"; |
||||
|
||||
/** |
||||
* 靠左对齐的自由浮动布局 |
||||
* @class BI.FloatLeftLayout |
||||
* @extends BI.Layout |
||||
* @class FloatLeftLayout |
||||
* @extends Layout |
||||
* |
||||
* @cfg {JSON} options 配置属性 |
||||
* @cfg {Number} [hgap=0] 水平间隙 |
||||
* @cfg {Number} [vgap=0] 垂直间隙 |
||||
*/ |
||||
BI.FloatLeftLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.FloatLeftLayout.superclass.props.apply(this, arguments), { |
||||
@shortcut() |
||||
export class FloatLeftLayout extends Layout { |
||||
static xtype = "bi.left"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-left clearfix", |
||||
hgap: 0, |
||||
vgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
tgap: 0, |
||||
bgap: 0 |
||||
bgap: 0, |
||||
}); |
||||
}, |
||||
render: function () { |
||||
BI.FloatLeftLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
} |
||||
|
||||
render() { |
||||
super.render(...arguments); |
||||
const o = this.options; |
||||
if (o.innerHgap !== 0) { |
||||
this.element.css({ |
||||
paddingLeft: this._optimiseGap(o.innerHgap), |
||||
paddingRight: this._optimiseGap(o.innerHgap) |
||||
}) |
||||
paddingRight: this._optimiseGap(o.innerHgap), |
||||
}); |
||||
} |
||||
if (o.innerVgap !== 0) { |
||||
this.element.css({ |
||||
paddingTop: this._optimiseGap(o.innerVgap), |
||||
paddingBottom: this._optimiseGap(o.innerVgap) |
||||
}) |
||||
paddingBottom: this._optimiseGap(o.innerVgap), |
||||
}); |
||||
} |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
self.populate(newValue); |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
this.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.FloatLeftLayout.superclass._addElement.apply(this, arguments); |
||||
w.element.css({position: "relative", float: "left"}); |
||||
if (BI.isNotNull(item.left)) { |
||||
w.element.css({left: BI.isNumber(item.left) ? this._optimiseGap(item.left) : item.left}); |
||||
_addElement(i, item) { |
||||
const o = this.options; |
||||
const w = super._addElement(...arguments); |
||||
w.element.css({ position: "relative", "float": "left" }); |
||||
if (isNotNull(item.left)) { |
||||
w.element.css({ left: isNumber(item.left) ? this._optimiseGap(item.left) : item.left }); |
||||
} |
||||
if (BI.isNotNull(item.right)) { |
||||
w.element.css({right: BI.isNumber(item.right) ? this._optimiseGap(item.right) : item.right}); |
||||
if (isNotNull(item.right)) { |
||||
w.element.css({ right: isNumber(item.right) ? this._optimiseGap(item.right) : item.right }); |
||||
} |
||||
if (BI.isNotNull(item.top)) { |
||||
w.element.css({top: BI.isNumber(item.top) ? this._optimiseGap(item.top) : item.top}); |
||||
if (isNotNull(item.top)) { |
||||
w.element.css({ top: isNumber(item.top) ? this._optimiseGap(item.top) : item.top }); |
||||
} |
||||
if (BI.isNotNull(item.bottom)) { |
||||
w.element.css({bottom: BI.isNumber(item.bottom) ? this._optimiseGap(item.bottom) : item.bottom}); |
||||
if (isNotNull(item.bottom)) { |
||||
w.element.css({ bottom: isNumber(item.bottom) ? this._optimiseGap(item.bottom) : item.bottom }); |
||||
} |
||||
if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { |
||||
var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
||||
const top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
||||
w.element.css({ |
||||
"margin-top": this._optimiseGap(top) |
||||
"margin-top": this._optimiseGap(top), |
||||
}); |
||||
} |
||||
if (o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { |
||||
var left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
||||
const left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
||||
w.element.css({ |
||||
"margin-left": this._optimiseGap(left) |
||||
"margin-left": this._optimiseGap(left), |
||||
}); |
||||
} |
||||
if (o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { |
||||
var right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
||||
const right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
||||
w.element.css({ |
||||
"margin-right": this._optimiseGap(right) |
||||
"margin-right": this._optimiseGap(right), |
||||
}); |
||||
} |
||||
if (o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { |
||||
var bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
||||
const bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
||||
w.element.css({ |
||||
"margin-bottom": this._optimiseGap(bottom) |
||||
"margin-bottom": this._optimiseGap(bottom), |
||||
}); |
||||
} |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.FloatLeftLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.left", BI.FloatLeftLayout); |
||||
} |
||||
|
||||
/** |
||||
* 靠右对齐的自由浮动布局 |
||||
* @class BI.FloatRightLayout |
||||
* @extends BI.Layout |
||||
* @class FloatRightLayout |
||||
* @extends Layout |
||||
* |
||||
* @cfg {JSON} options 配置属性 |
||||
* @cfg {Number} [hgap=0] 水平间隙 |
||||
* @cfg {Number} [vgap=0] 垂直间隙 |
||||
*/ |
||||
BI.FloatRightLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.FloatRightLayout.superclass.props.apply(this, arguments), { |
||||
@shortcut() |
||||
export class FloatRightLayout extends Layout { |
||||
static xtype = "bi.right"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-right clearfix", |
||||
hgap: 0, |
||||
vgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
tgap: 0, |
||||
bgap: 0 |
||||
bgap: 0, |
||||
}); |
||||
}, |
||||
render: function () { |
||||
BI.FloatRightLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
} |
||||
|
||||
render() { |
||||
super.render(...arguments); |
||||
const o = this.options; |
||||
if (o.innerHgap !== 0) { |
||||
this.element.css({ |
||||
paddingLeft: this._optimiseGap(o.innerHgap), |
||||
paddingRight: this._optimiseGap(o.innerHgap) |
||||
}) |
||||
paddingRight: this._optimiseGap(o.innerHgap), |
||||
}); |
||||
} |
||||
if (o.innerVgap !== 0) { |
||||
this.element.css({ |
||||
paddingTop: this._optimiseGap(o.innerVgap), |
||||
paddingBottom: this._optimiseGap(o.innerVgap) |
||||
}) |
||||
paddingBottom: this._optimiseGap(o.innerVgap), |
||||
}); |
||||
} |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
self.populate(newValue); |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
this.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.FloatRightLayout.superclass._addElement.apply(this, arguments); |
||||
w.element.css({position: "relative", float: "right"}); |
||||
if (BI.isNotNull(item.left)) { |
||||
w.element.css({left: BI.pixFormat(item.left)}); |
||||
_addElement(i, item) { |
||||
const o = this.options; |
||||
const w = super._addElement(...arguments); |
||||
w.element.css({ position: "relative", "float": "right" }); |
||||
if (isNotNull(item.left)) { |
||||
w.element.css({ left: pixFormat(item.left) }); |
||||
} |
||||
if (BI.isNotNull(item.right)) { |
||||
w.element.css({right: BI.pixFormat(item.right)}); |
||||
if (isNotNull(item.right)) { |
||||
w.element.css({ right: pixFormat(item.right) }); |
||||
} |
||||
if (BI.isNotNull(item.top)) { |
||||
w.element.css({top: BI.pixFormat(item.top)}); |
||||
if (isNotNull(item.top)) { |
||||
w.element.css({ top: pixFormat(item.top) }); |
||||
} |
||||
if (BI.isNotNull(item.bottom)) { |
||||
w.element.css({bottom: BI.pixFormat(item.bottom)}); |
||||
if (isNotNull(item.bottom)) { |
||||
w.element.css({ bottom: pixFormat(item.bottom) }); |
||||
} |
||||
if (o.vgap + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { |
||||
var top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
||||
const top = o.vgap / 2 + o.tgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
||||
w.element.css({ |
||||
"margin-top": this._optimiseGap(top) |
||||
"margin-top": this._optimiseGap(top), |
||||
}); |
||||
} |
||||
if (o.hgap + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { |
||||
var left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
||||
const left = o.hgap / 2 + o.lgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
||||
w.element.css({ |
||||
"margin-left": this._optimiseGap(left) |
||||
"margin-left": this._optimiseGap(left), |
||||
}); |
||||
} |
||||
if (o.hgap + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { |
||||
var right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
||||
const right = o.hgap / 2 + o.rgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
||||
w.element.css({ |
||||
"margin-right": this._optimiseGap(right) |
||||
"margin-right": this._optimiseGap(right), |
||||
}); |
||||
} |
||||
if (o.vgap + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { |
||||
var bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
||||
const bottom = o.vgap / 2 + o.bgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
||||
w.element.css({ |
||||
"margin-bottom": this._optimiseGap(bottom) |
||||
"margin-bottom": this._optimiseGap(bottom), |
||||
}); |
||||
} |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.FloatRightLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.right", BI.FloatRightLayout); |
||||
} |
||||
|
@ -1,8 +1,6 @@
|
||||
/** |
||||
* 水平布局 |
||||
* @class BI.HorizontalLayout |
||||
* @extends BI.Layout |
||||
*/ |
||||
BI.HorizontalLayout = function () { |
||||
}; |
||||
BI.shortcut("bi.horizontal", BI.HorizontalLayout); |
||||
import { shortcut } from "../../decorator"; |
||||
|
||||
@shortcut() |
||||
export class HorizontalLayout { |
||||
static xtype = "bi.horizontal"; |
||||
} |
||||
|
@ -1,43 +1,52 @@
|
||||
import { shortcut } from "../../decorator"; |
||||
import { Layout } from "../layout"; |
||||
import { extend, isFunction, sum } from "../../2.base"; |
||||
|
||||
/** |
||||
* 靠左对齐的自由浮动布局 |
||||
* @class BI.LatticeLayout |
||||
* @extends BI.Layout |
||||
* @class LatticeLayout |
||||
* @extends Layout |
||||
* |
||||
* @cfg {JSON} options 配置属性 |
||||
* @cfg {Number} [hgap=0] 水平间隙 |
||||
* @cfg {Number} [vgap=0] 垂直间隙 |
||||
*/ |
||||
BI.LatticeLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.LatticeLayout.superclass.props.apply(this, arguments), { |
||||
baseCls: "bi-lattice clearfix" |
||||
@shortcut() |
||||
export class LatticeLayout extends Layout { |
||||
static xtype = "bi.lattice"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-lattice clearfix", |
||||
// columnSize: [0.2, 0.2, 0.6],
|
||||
}); |
||||
}, |
||||
render: function () { |
||||
BI.LatticeLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
} |
||||
|
||||
render() { |
||||
super.render(...arguments); |
||||
const self = this, o = this.options; |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
self.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.LatticeLayout.superclass._addElement.apply(this, arguments); |
||||
_addElement(i, item) { |
||||
const o = this.options; |
||||
const w = super._addElement(...arguments); |
||||
let width; |
||||
if (o.columnSize && o.columnSize[i]) { |
||||
var width = o.columnSize[i] / BI.sum(o.columnSize) * 100 + "%"; |
||||
width = `${o.columnSize[i] / sum(o.columnSize) * 100}%`; |
||||
} else { |
||||
var width = 1 / this.options.items.length * 100 + "%"; |
||||
width = `${1 / this.options.items.length * 100}%`; |
||||
} |
||||
w.element.css({position: "relative", float: "left", width: width}); |
||||
w.element.css({ position: "relative", "float": "left", width }); |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.LatticeLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.lattice", BI.LatticeLayout); |
||||
} |
||||
|
@ -1,54 +1,63 @@
|
||||
import { shortcut } from "../../decorator"; |
||||
import { Layout } from "../layout"; |
||||
import { extend, isFunction } from "../../2.base"; |
||||
import { HorizontalAlign } from "../../constant"; |
||||
|
||||
/** |
||||
* 垂直布局 |
||||
* @class BI.VerticalLayout |
||||
* @extends BI.Layout |
||||
* @class VerticalLayout |
||||
* @extends Layout |
||||
*/ |
||||
BI.VerticalLayout = BI.inherit(BI.Layout, { |
||||
props: function () { |
||||
return BI.extend(BI.VerticalLayout.superclass.props.apply(this, arguments), { |
||||
@shortcut() |
||||
export class VerticalLayout extends Layout { |
||||
static xtype = "bi.vertical"; |
||||
|
||||
props() { |
||||
return extend(super.props(...arguments), { |
||||
baseCls: "bi-v", |
||||
horizontalAlign: BI.HorizontalAlign.Stretch, |
||||
horizontalAlign: HorizontalAlign.Stretch, |
||||
hgap: 0, |
||||
vgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
tgap: 0, |
||||
bgap: 0, |
||||
scrolly: true |
||||
scrolly: true, |
||||
}); |
||||
}, |
||||
render: function () { |
||||
BI.VerticalLayout.superclass.render.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { |
||||
self.populate(newValue); |
||||
} |
||||
|
||||
render() { |
||||
super.render(...arguments); |
||||
const o = this.options; |
||||
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
||||
this.populate(newValue); |
||||
}) : o.items; |
||||
this.populate(items); |
||||
}, |
||||
} |
||||
|
||||
_addElement: function (i, item) { |
||||
var o = this.options; |
||||
var w = BI.VerticalLayout.superclass._addElement.apply(this, arguments); |
||||
_addElement(i, item) { |
||||
const o = this.options; |
||||
const w = super._addElement(...arguments); |
||||
w.element.css({ |
||||
position: "relative" |
||||
position: "relative", |
||||
}); |
||||
this._handleGap(w, item, null, i); |
||||
if (o.horizontalAlign === BI.HorizontalAlign.Center) { |
||||
if (o.horizontalAlign === HorizontalAlign.Center) { |
||||
w.element.css({ |
||||
marginLeft: "auto", |
||||
marginRight: "auto" |
||||
marginRight: "auto", |
||||
}); |
||||
} else if (o.horizontalAlign === BI.HorizontalAlign.Right) { |
||||
} else if (o.horizontalAlign === HorizontalAlign.Right) { |
||||
w.element.css({ |
||||
marginLeft: "auto" |
||||
marginLeft: "auto", |
||||
}); |
||||
} |
||||
|
||||
return w; |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.VerticalLayout.superclass.populate.apply(this, arguments); |
||||
populate(...args) { |
||||
super.populate(...args); |
||||
this._mount(); |
||||
} |
||||
}); |
||||
BI.shortcut("bi.vertical", BI.VerticalLayout); |
||||
} |
||||
|
Loading…
Reference in new issue