Browse Source
Merge in VISUAL/fineui from ~ZHENFEI.LI/fineui:es6 to es6 * commit '8fcb09c1e3c2805906ed44cd4cda7426d3a2a65b': KERNEL-14035 refactor: 挂载Element KERNEL-14035 refactor: constant、element、logic文件夹及整体eslint一下es6
Zhenfei.Li-李振飞
2 years ago
43 changed files with 1384 additions and 1282 deletions
@ -1,2 +1,2 @@ |
|||||||
export { Action } from "./action"; |
export { Action } from "./action"; |
||||||
export { ShowAction } from "./action.show"; |
export { ShowAction, ActionFactory } from "./action.show"; |
||||||
|
@ -1,3 +1,26 @@ |
|||||||
|
|
||||||
|
import { HighlightBehavior } from "./behavior.highlight"; |
||||||
|
import { RedMarkBehavior } from "./behavior.redmark"; |
||||||
|
|
||||||
|
export const BehaviorFactory = { |
||||||
|
createBehavior (key, options) { |
||||||
|
let Behavior; |
||||||
|
switch (key) { |
||||||
|
case "highlight": |
||||||
|
Behavior = HighlightBehavior; |
||||||
|
break; |
||||||
|
case "redmark": |
||||||
|
Behavior = RedMarkBehavior; |
||||||
|
break; |
||||||
|
default: |
||||||
|
} |
||||||
|
|
||||||
|
return new Behavior(options); |
||||||
|
}, |
||||||
|
}; |
||||||
|
|
||||||
export { Behavior } from "./0.behavior"; |
export { Behavior } from "./0.behavior"; |
||||||
export { HighlightBehavior } from "./behavior.highlight"; |
export { |
||||||
export { RedMarkBehavior } from "./behavior.redmark"; |
HighlightBehavior, |
||||||
|
RedMarkBehavior |
||||||
|
}; |
||||||
|
@ -0,0 +1,2 @@ |
|||||||
|
export { Events } from "./events"; |
||||||
|
export * from "./var"; |
@ -1,22 +1,25 @@ |
|||||||
export const registAttrFun = (Element) => { |
import { isObject, each, isNull, isNotNull } from "../../2.base"; |
||||||
Element.registerFunction('attr', function (key, value) { |
|
||||||
var self = this; |
export const registAttrFun = Element => { |
||||||
if (BI.isObject(key)) { |
Element.registerFunction("attr", function (key, value) { |
||||||
BI.each(key, (k, v) => { |
if (isObject(key)) { |
||||||
self.attr(k, v); |
each(key, (k, v) => { |
||||||
|
this.attr(k, v); |
||||||
}); |
}); |
||||||
|
|
||||||
return this; |
return this; |
||||||
} |
} |
||||||
if (BI.isNull(value)) { |
if (isNull(value)) { |
||||||
return this.attribs[key]; |
return this.attribs[key]; |
||||||
} |
} |
||||||
this.attribs[key] = value; |
this.attribs[key] = value; |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
Element.registerFunction('hasAttrib', function (key) { |
Element.registerFunction("hasAttrib", function (key) { |
||||||
return this.attribs[key] != null; |
return isNotNull(this.attribs[key]); |
||||||
}); |
}); |
||||||
Element.registerFunction('removeAttr', function (key) { |
Element.registerFunction("removeAttr", function (key) { |
||||||
delete this.attribs[key]; |
delete this.attribs[key]; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,23 +1,23 @@ |
|||||||
export const registClassFun = (Element) => { |
export const registClassFun = Element => { |
||||||
Element.registerFunction('addClass', function (classList) { |
Element.registerFunction("addClass", function (classList) { |
||||||
var self = this; |
BI.each(classList.split(" "), (i, cls) => { |
||||||
BI.each(classList.split(' '), (i, cls) => { |
if (cls && !this.classMap[cls]) { |
||||||
if (cls && !self.classMap[cls]) { |
this.classList.push(cls); |
||||||
self.classList.push(cls); |
|
||||||
} |
} |
||||||
cls && (self.classMap[cls] = true); |
cls && (this.classMap[cls] = true); |
||||||
}); |
}); |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
|
|
||||||
Element.registerFunction('removeClass', function (classList) { |
Element.registerFunction("removeClass", function (classList) { |
||||||
var self = this; |
BI.each(classList.split(" "), (i, cls) => { |
||||||
BI.each(classList.split(' '), (i, cls) => { |
if (cls && this.classMap[cls]) { |
||||||
if (cls && self.classMap[cls]) { |
delete this.classMap[cls]; |
||||||
delete self.classMap[cls]; |
this.classList.splice(this.classList.indexOf(cls), 1); |
||||||
self.classList.splice(self.classList.indexOf(cls), 1); |
|
||||||
} |
} |
||||||
}); |
}); |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,22 +1,26 @@ |
|||||||
export const registCssFun = (Element) => { |
import { isNull, isObject, each, trim, camelize } from "../../2.base"; |
||||||
Element.registerFunction('css', function (key, value) { |
|
||||||
var self = this; |
export const registCssFun = Element => { |
||||||
if (BI.isObject(key)) { |
Element.registerFunction("css", function (key, value) { |
||||||
BI.each(key, (k, v) => { |
if (isObject(key)) { |
||||||
self.css(k, v); |
each(key, (k, v) => { |
||||||
|
this.css(k, v); |
||||||
}); |
}); |
||||||
|
|
||||||
return this; |
return this; |
||||||
} |
} |
||||||
key = BI.trim(BI.camelize(key)); |
key = trim(camelize(key)); |
||||||
|
|
||||||
return css(this, key, value); |
return css(this, key, value); |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
|
||||||
const css = (elem, key, value) => { |
const css = (elem, key, value) => { |
||||||
key = BI.trim(BI.camelize(key)); |
key = trim(camelize(key)); |
||||||
if (BI.isNull(value)) { |
if (isNull(value)) { |
||||||
return elem.styles[key]; |
return elem.styles[key]; |
||||||
} |
} |
||||||
elem.styles[key] = value; |
elem.styles[key] = value; |
||||||
|
|
||||||
return elem; |
return elem; |
||||||
}; |
}; |
||||||
|
@ -1,12 +1,15 @@ |
|||||||
export const registDataFun = (Element) => { |
import { isNull } from "../../2.base"; |
||||||
Element.registerFunction('data', function (key, value) { |
|
||||||
|
export const registDataFun = Element => { |
||||||
|
Element.registerFunction("data", function (key, value) { |
||||||
if (!this._data) { |
if (!this._data) { |
||||||
this._data = {}; |
this._data = {}; |
||||||
} |
} |
||||||
if (BI.isNull(value)) { |
if (isNull(value)) { |
||||||
return this._data[key]; |
return this._data[key]; |
||||||
} |
} |
||||||
this._data[key] = value; |
this._data[key] = value; |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,9 +1,10 @@ |
|||||||
export const registEmptyFun = (Element) => { |
export const registEmptyFun = Element => { |
||||||
Element.registerFunction('empty', function (text) { |
Element.registerFunction("empty", function (text) { |
||||||
this.children = []; |
this.children = []; |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
Element.registerFunction('destroy', function (text) { |
Element.registerFunction("destroy", function (text) { |
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,32 +1,33 @@ |
|||||||
var returnThis = function () { |
function returnThis () { |
||||||
return this; |
return this; |
||||||
}; |
} |
||||||
export const registEventFun = (Element) => { |
|
||||||
|
export const registEventFun = Element => { |
||||||
[ |
[ |
||||||
'mousedown', |
"mousedown", |
||||||
'mouseup', |
"mouseup", |
||||||
'mousewheel', |
"mousewheel", |
||||||
'keydown', |
"keydown", |
||||||
'keyup', |
"keyup", |
||||||
'focus', |
"focus", |
||||||
'focusin', |
"focusin", |
||||||
'focusout', |
"focusout", |
||||||
'click', |
"click", |
||||||
'on', |
"on", |
||||||
'off', |
"off", |
||||||
'bind', |
"bind", |
||||||
'unbind', |
"unbind", |
||||||
'trigger', |
"trigger", |
||||||
'hover', |
"hover", |
||||||
'scroll', |
"scroll", |
||||||
'scrollLeft', |
"scrollLeft", |
||||||
'scrollTop', |
"scrollTop", |
||||||
'resize', |
"resize", |
||||||
'show', |
"show", |
||||||
'hide', |
"hide", |
||||||
'dblclick', |
"dblclick", |
||||||
'blur', |
"blur" |
||||||
].forEach((event) => { |
].forEach(event => { |
||||||
Element.registerFunction(event, returnThis); |
Element.registerFunction(event, returnThis); |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,15 +1,19 @@ |
|||||||
export const registHtmlFun = (Element) => { |
import { createWidget } from "../../5.inject"; |
||||||
Element.registerFunction('html', function (text) { |
import { htmlDecode } from "../../func"; |
||||||
if (text && text.charAt(0) === '<') { |
|
||||||
BI.createWidget({ |
export const registHtmlFun = Element => { |
||||||
type: 'bi.html', |
Element.registerFunction("html", function (text) { |
||||||
|
if (text && text.charAt(0) === "<") { |
||||||
|
createWidget({ |
||||||
|
type: "bi.html", |
||||||
element: this.widget, |
element: this.widget, |
||||||
html: text, |
html: text, |
||||||
}); |
}); |
||||||
this.originalHtml = text; |
this.originalHtml = text; |
||||||
} else { |
} else { |
||||||
this.text = BI.htmlDecode(text); |
this.text = htmlDecode(text); |
||||||
} |
} |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,6 +1,7 @@ |
|||||||
export const registKeywordMarkFun = (Element) => { |
export const registKeywordMarkFun = Element => { |
||||||
Element.registerFunction('__textKeywordMarked__', function (text) { |
Element.registerFunction("__textKeywordMarked__", function (text) { |
||||||
this[0].textContent = text; |
this[0].textContent = text; |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,65 +1,69 @@ |
|||||||
var skipArray = []; |
import { each, isNull, hyphenate, isNumeric, isKey } from "../../2.base"; |
||||||
var pxStyle = ['font-size', 'width', 'height']; |
|
||||||
var _renderToHtml = function (root) { |
const skipArray = []; |
||||||
var str = ''; |
const pxStyle = ["font-size", "width", "height"]; |
||||||
if (BI.isNull(root.originalHtml)) { |
function _renderToHtml(root) { |
||||||
if (root.tag !== 'body') { |
let str = ""; |
||||||
|
if (isNull(root.originalHtml)) { |
||||||
|
if (root.tag !== "body") { |
||||||
str += `<${root.tag}`; |
str += `<${root.tag}`; |
||||||
if (root.classList.length > 0) { |
if (root.classList.length > 0) { |
||||||
str += ' class="'; |
str += " class=\""; |
||||||
BI.each(root.classList, (i, cls) => { |
each(root.classList, (i, cls) => { |
||||||
str += ` ${cls}`; |
str += ` ${cls}`; |
||||||
}); |
}); |
||||||
str += '"'; |
str += "\""; |
||||||
} |
} |
||||||
str += ' style="'; |
str += " style=\""; |
||||||
BI.each(root.originalStyles, (key, stl) => { |
each(root.originalStyles, (key, stl) => { |
||||||
if ( |
if ( |
||||||
skipArray.contains(key) || |
skipArray.contains(key) || |
||||||
(key == 'height' && root.classList.contains('bi-design-components-data-data-table-cell')) |
(key === "height" && root.classList.contains("bi-design-components-data-data-table-cell")) |
||||||
) { |
) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
key = BI.hyphenate(key); |
key = hyphenate(key); |
||||||
if (key === 'font-family') { |
if (key === "font-family") { |
||||||
stl = stl.replace(/\"/g, ''); |
stl = stl.replace(/"/g, ""); |
||||||
} |
} |
||||||
if (pxStyle.contains(key) && BI.isNumeric(stl)) { |
if (pxStyle.contains(key) && isNumeric(stl)) { |
||||||
stl += 'px'; |
stl += "px"; |
||||||
} |
} |
||||||
if (BI.isKey(stl)) { |
if (isKey(stl)) { |
||||||
str += ` ${key}:${stl};`; |
str += ` ${key}:${stl};`; |
||||||
} |
} |
||||||
}); |
}); |
||||||
str += '"'; |
str += "\""; |
||||||
BI.each(root.attribs, (key, attr) => { |
each(root.attribs, (key, attr) => { |
||||||
if (BI.isKey(attr)) { |
if (isKey(attr)) { |
||||||
str += ` ${key}=${attr}`; |
str += ` ${key}=${attr}`; |
||||||
} |
} |
||||||
}); |
}); |
||||||
if (root.textContent) { |
if (root.textContent) { |
||||||
str += ` title=${root.textContent}`; |
str += ` title=${root.textContent}`; |
||||||
} |
} |
||||||
str += '>'; |
str += ">"; |
||||||
} |
} |
||||||
// 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了
|
// 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了
|
||||||
// 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样
|
// 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样
|
||||||
BI.each(root.children, (i, child) => { |
each(root.children, (i, child) => { |
||||||
str += _renderToHtml(child); |
str += _renderToHtml(child); |
||||||
}); |
}); |
||||||
} else { |
} else { |
||||||
str += root.originalHtml; |
str += root.originalHtml; |
||||||
} |
} |
||||||
if (root.tag !== 'body') { |
if (root.tag !== "body") { |
||||||
if (root.textContent) { |
if (root.textContent) { |
||||||
str += root.textContent; |
str += root.textContent; |
||||||
} |
} |
||||||
str += `</${root.tag}>`; |
str += `</${root.tag}>`; |
||||||
} |
} |
||||||
|
|
||||||
return str; |
return str; |
||||||
}; |
} |
||||||
export const registRenderToHtmlFun = (Element) => { |
|
||||||
Element.registerFunction('renderToHtml', function () { |
export const registRenderToHtmlFun = Element => { |
||||||
|
Element.registerFunction("renderToHtml", function () { |
||||||
return _renderToHtml(this); |
return _renderToHtml(this); |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,50 +1,54 @@ |
|||||||
var skipArray = ['width', 'height']; |
import { each, hyphenate } from "../../2.base"; |
||||||
var _renderToString = function (root) { |
|
||||||
var str = ''; |
const skipArray = ["width", "height"]; |
||||||
if (root.nodeName !== 'body') { |
function _renderToString(root) { |
||||||
|
let str = ""; |
||||||
|
if (root.nodeName !== "body") { |
||||||
str += `<${root.nodeName}`; |
str += `<${root.nodeName}`; |
||||||
if (root.classList.length > 0) { |
if (root.classList.length > 0) { |
||||||
str += ' class="'; |
str += " class=\""; |
||||||
BI.each(root.classList, (i, cls) => { |
each(root.classList, (i, cls) => { |
||||||
str += ` ${cls}`; |
str += ` ${cls}`; |
||||||
}); |
}); |
||||||
str += '"'; |
str += "\""; |
||||||
} |
} |
||||||
str += ' style="'; |
str += " style=\""; |
||||||
BI.each(root.styles, (key, stl) => { |
each(root.styles, (key, stl) => { |
||||||
if (skipArray.includes(key)) { |
if (skipArray.includes(key)) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
key = BI.hyphenate(key); |
key = hyphenate(key); |
||||||
str += ` ${key}:${stl};`; |
str += ` ${key}:${stl};`; |
||||||
}); |
}); |
||||||
str += ` width:${root.width}px;`; |
str += ` width:${root.width}px;`; |
||||||
str += ` height:${root.height}px;`; |
str += ` height:${root.height}px;`; |
||||||
str += ' position: fixed;'; |
str += " position: fixed;"; |
||||||
str += ` left: ${root.position.x}px;`; |
str += ` left: ${root.position.x}px;`; |
||||||
str += ` top: ${root.position.y}px;`; |
str += ` top: ${root.position.y}px;`; |
||||||
str += '"'; |
str += "\""; |
||||||
BI.each(root.attribs, (key, attr) => { |
each(root.attribs, (key, attr) => { |
||||||
str += ` ${key}:${attr}`; |
str += ` ${key}:${attr}`; |
||||||
}); |
}); |
||||||
str += '>'; |
str += ">"; |
||||||
} |
} |
||||||
BI.each(root.children, (i, child) => { |
each(root.children, (i, child) => { |
||||||
str += _renderToString(child); |
str += _renderToString(child); |
||||||
}); |
}); |
||||||
// if (root.htmlContent) {
|
// if (root.htmlContent) {
|
||||||
// str += root.htmlContent;
|
// str += root.htmlContent;
|
||||||
// }
|
// }
|
||||||
if (root.nodeName !== 'body') { |
if (root.nodeName !== "body") { |
||||||
if (root.text) { |
if (root.text) { |
||||||
str += root.text; |
str += root.text; |
||||||
} |
} |
||||||
str += `</${root.nodeName}>`; |
str += `</${root.nodeName}>`; |
||||||
} |
} |
||||||
|
|
||||||
return str; |
return str; |
||||||
}; |
} |
||||||
export const registRenderToStringFun = (Element) => { |
|
||||||
Element.registerFunction('renderToString', function () { |
export const registRenderToStringFun = Element => { |
||||||
|
Element.registerFunction("renderToString", function () { |
||||||
return _renderToString(this); |
return _renderToString(this); |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,10 +1,12 @@ |
|||||||
export const registTextFun = (Element) => { |
export const registTextFun = Element => { |
||||||
Element.registerFunction('setText', function (text) { |
Element.registerFunction("setText", function (text) { |
||||||
this.text = text; |
this.text = text; |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
Element.registerFunction('setValue', function (text) { |
Element.registerFunction("setValue", function (text) { |
||||||
this.text = text; |
this.text = text; |
||||||
|
|
||||||
return this; |
return this; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -1,9 +1,11 @@ |
|||||||
export const registValFun = (Element) => { |
export const registValFun = Element => { |
||||||
Element.registerFunction('val', function (value) { |
Element.registerFunction("val", function (value) { |
||||||
if (BI.isNotNull(value)) { |
if (BI.isNotNull(value)) { |
||||||
this.text = `${value}`; |
this.text = `${value}`; |
||||||
|
|
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
return this.text; |
return this.text; |
||||||
}); |
}); |
||||||
}; |
}; |
||||||
|
@ -0,0 +1,83 @@ |
|||||||
|
import { Logic } from "./logic"; |
||||||
|
import { VerticalLayoutLogic, HorizontalLayoutLogic, TableLayoutLogic, HorizontalFillLayoutLogic } from "./logic.layout"; |
||||||
|
|
||||||
|
export const LogicFactory = { |
||||||
|
Type: { |
||||||
|
Vertical: "vertical", |
||||||
|
Horizontal: "horizontal", |
||||||
|
Table: "table", |
||||||
|
HorizontalFill: "horizontal_fill", |
||||||
|
}, |
||||||
|
createLogic (key, options) { |
||||||
|
let LogicCls; |
||||||
|
switch (key) { |
||||||
|
case LogicFactory.Type.Vertical: |
||||||
|
LogicCls = VerticalLayoutLogic; |
||||||
|
break; |
||||||
|
case LogicFactory.Type.Horizontal: |
||||||
|
LogicCls = HorizontalLayoutLogic; |
||||||
|
break; |
||||||
|
case LogicFactory.Type.Table: |
||||||
|
LogicCls = TableLayoutLogic; |
||||||
|
break; |
||||||
|
case LogicFactory.Type.HorizontalFill: |
||||||
|
LogicCls = HorizontalFillLayoutLogic; |
||||||
|
break; |
||||||
|
default: |
||||||
|
LogicCls = Logic; |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
return new LogicCls(options).createLogic(); |
||||||
|
}, |
||||||
|
|
||||||
|
createLogicTypeByDirection (direction) { |
||||||
|
switch (direction) { |
||||||
|
case BI.Direction.Top: |
||||||
|
case BI.Direction.Bottom: |
||||||
|
case BI.Direction.Custom: |
||||||
|
return BI.LogicFactory.Type.Vertical; |
||||||
|
case BI.Direction.Left: |
||||||
|
case BI.Direction.Right: |
||||||
|
return BI.LogicFactory.Type.Horizontal; |
||||||
|
default: |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
createLogicItemsByDirection (direction) { |
||||||
|
let items = Array.prototype.slice.call(arguments, 1); |
||||||
|
items = BI.map(items, (i, item) => { |
||||||
|
if (BI.isWidget(item)) { |
||||||
|
return { |
||||||
|
el: item, |
||||||
|
width: item.options.width, |
||||||
|
height: item.options.height, |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
return item; |
||||||
|
}); |
||||||
|
switch (direction) { |
||||||
|
case BI.Direction.Bottom: |
||||||
|
items.reverse(); |
||||||
|
break; |
||||||
|
case BI.Direction.Right: |
||||||
|
items.reverse(); |
||||||
|
break; |
||||||
|
case BI.Direction.Custom: |
||||||
|
items = items.slice(1); |
||||||
|
break; |
||||||
|
default: |
||||||
|
} |
||||||
|
|
||||||
|
return items; |
||||||
|
}, |
||||||
|
}; |
||||||
|
|
||||||
|
export { |
||||||
|
Logic, |
||||||
|
VerticalLayoutLogic, |
||||||
|
HorizontalLayoutLogic, |
||||||
|
TableLayoutLogic, |
||||||
|
HorizontalFillLayoutLogic |
||||||
|
}; |
@ -1,80 +1,8 @@ |
|||||||
/** |
|
||||||
* @class BI.Logic |
|
||||||
* @extends BI.OB |
|
||||||
*/ |
|
||||||
BI.Logic = BI.inherit(BI.OB, { |
|
||||||
createLogic: function () { |
|
||||||
return this.options || {}; |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
BI.LogicFactory = { |
|
||||||
Type: { |
|
||||||
Vertical: "vertical", |
|
||||||
Horizontal: "horizontal", |
|
||||||
Table: "table", |
|
||||||
HorizontalFill: "horizontal_fill" |
|
||||||
}, |
|
||||||
createLogic: function (key, options) { |
|
||||||
var logic; |
|
||||||
switch (key) { |
|
||||||
case BI.LogicFactory.Type.Vertical: |
|
||||||
logic = BI.VerticalLayoutLogic; |
|
||||||
break; |
|
||||||
case BI.LogicFactory.Type.Horizontal: |
|
||||||
logic = BI.HorizontalLayoutLogic; |
|
||||||
break; |
|
||||||
case BI.LogicFactory.Type.Table: |
|
||||||
logic = BI.TableLayoutLogic; |
|
||||||
break; |
|
||||||
case BI.LogicFactory.Type.HorizontalFill: |
|
||||||
logic = BI.HorizontalFillLayoutLogic; |
|
||||||
break; |
|
||||||
default: |
|
||||||
logic = BI.Logic; |
|
||||||
break; |
|
||||||
} |
|
||||||
return new logic(options).createLogic(); |
|
||||||
}, |
|
||||||
|
|
||||||
createLogicTypeByDirection: function (direction) { |
import { OB } from "../3.ob"; |
||||||
switch (direction) { |
|
||||||
case BI.Direction.Top: |
|
||||||
case BI.Direction.Bottom: |
|
||||||
case BI.Direction.Custom: |
|
||||||
return BI.LogicFactory.Type.Vertical; |
|
||||||
case BI.Direction.Left: |
|
||||||
case BI.Direction.Right: |
|
||||||
return BI.LogicFactory.Type.Horizontal; |
|
||||||
} |
|
||||||
}, |
|
||||||
|
|
||||||
createLogicItemsByDirection: function (direction) { |
export class Logic extends OB { |
||||||
var layout; |
createLogic() { |
||||||
var items = Array.prototype.slice.call(arguments, 1); |
return this.options || {}; |
||||||
items = BI.map(items, function (i, item) { |
|
||||||
if (BI.isWidget(item)) { |
|
||||||
return { |
|
||||||
el: item, |
|
||||||
width: item.options.width, |
|
||||||
height: item.options.height |
|
||||||
}; |
|
||||||
} |
|
||||||
return item; |
|
||||||
}); |
|
||||||
switch (direction) { |
|
||||||
case BI.Direction.Bottom: |
|
||||||
layout = BI.LogicFactory.Type.Vertical; |
|
||||||
items.reverse(); |
|
||||||
break; |
|
||||||
case BI.Direction.Right: |
|
||||||
layout = BI.LogicFactory.Type.Horizontal; |
|
||||||
items.reverse(); |
|
||||||
break; |
|
||||||
case BI.Direction.Custom: |
|
||||||
items = items.slice(1); |
|
||||||
break; |
|
||||||
} |
|
||||||
return items; |
|
||||||
} |
} |
||||||
}; |
} |
||||||
|
Loading…
Reference in new issue