forked from fanruan/fineui
Joker.Wang-王顺
2 years ago
95 changed files with 3041 additions and 2729 deletions
@ -1,19 +1,24 @@
|
||||
import { IconButton } from "../../../base/single/button/buttons/button.icon"; |
||||
import { shortcut, extend } from "../../../core"; |
||||
|
||||
/** |
||||
* 统一的trigger图标按钮 |
||||
* |
||||
* Created by GUY on 2015/9/16. |
||||
* @class BI.TriggerIconButton |
||||
* @extends BI.IconButton |
||||
* @class TriggerIconButton |
||||
* @extends IconButton |
||||
*/ |
||||
BI.TriggerIconButton = BI.inherit(BI.IconButton, { |
||||
@shortcut() |
||||
export class TriggerIconButton extends IconButton { |
||||
static xtype = "bi.trigger_icon_button"; |
||||
EVENT_CHANGE = IconButton.EVENT_CHANGE; |
||||
|
||||
_defaultConfig() { |
||||
const conf = super._defaultConfig(arguments); |
||||
|
||||
_defaultConfig: function () { |
||||
var conf = BI.TriggerIconButton.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: (conf.baseCls || "") + " bi-trigger-icon-button overflow-hidden", |
||||
extraCls: "pull-down-font" |
||||
return extend(conf, { |
||||
baseCls: `${conf.baseCls || ""} bi-trigger-icon-button overflow-hidden`, |
||||
extraCls: "pull-down-font", |
||||
}); |
||||
} |
||||
}); |
||||
BI.TriggerIconButton.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE; |
||||
BI.shortcut("bi.trigger_icon_button", BI.TriggerIconButton); |
||||
} |
||||
|
@ -1,21 +1,28 @@
|
||||
import { IconButton } from "../../../../base/single/button/buttons/button.icon"; |
||||
import { shortcut, extend } from "../../../../core"; |
||||
|
||||
|
||||
/** |
||||
* guy |
||||
* @extends BI.Single |
||||
* @type {*|void|Object} |
||||
*/ |
||||
BI.HalfIconButton = BI.inherit(BI.IconButton, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
@shortcut() |
||||
export class HalfIconButton extends IconButton { |
||||
static xtype = "bi.half_icon_button"; |
||||
static EVENT_CHANGE = IconButton.EVENT_CHANGE |
||||
|
||||
_defaultConfig() { |
||||
const conf = super._defaultConfig(arguments); |
||||
|
||||
return extend(conf, { |
||||
extraCls: "bi-half-icon-button check-half-select-icon", |
||||
height: 16, |
||||
width: 16, |
||||
iconWidth: 16, |
||||
iconHeight: 16, |
||||
selected: false |
||||
selected: false, |
||||
}); |
||||
} |
||||
}); |
||||
BI.HalfIconButton.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE; |
||||
} |
||||
|
||||
BI.shortcut("bi.half_icon_button", BI.HalfIconButton); |
@ -0,0 +1,29 @@
|
||||
export { MultiSelectItem } from "./item.multiselect"; |
||||
export { SingleSelectIconTextItem } from "./item.singleselect.icontext"; |
||||
export { SingleSelectItem } from "./item.singleselect"; |
||||
export { SingleSelectRadioItem } from "./item.singleselect.radio"; |
||||
export { Switch } from "./switch"; |
||||
|
||||
export { IconChangeButton } from "./icon/icon.change"; |
||||
export { TriggerIconButton } from "./icon/icon.trigger"; |
||||
export { HalfIconButton } from "./icon/iconhalf/icon.half.image"; |
||||
export { HalfButton } from "./icon/iconhalf/icon.half"; |
||||
|
||||
export { ArrowNode } from "./node/node.arrow"; |
||||
export { FirstPlusGroupNode } from "./node/node.first.plus"; |
||||
export { IconArrowNode } from "./node/node.icon.arrow"; |
||||
export { LastPlusGroupNode } from "./node/node.last.plus"; |
||||
export { MidPlusGroupNode } from "./node/node.mid.plus"; |
||||
export { MultiLayerIconArrowNode } from "./node/node.multilayer.icon.arrow"; |
||||
export { PlusGroupNode } from "./node/node.plus"; |
||||
export { TreeNodeSwitcher } from "./node/siwtcher.tree.node"; |
||||
export { BasicTreeNode } from "./node/treenode"; |
||||
|
||||
export { FirstTreeLeafItem } from "./treeitem/item.first.treeleaf"; |
||||
export { IconTreeLeafItem } from "./treeitem/item.icon.treeleaf"; |
||||
export { LastTreeLeafItem } from "./treeitem/item.last.treeleaf"; |
||||
export { MidTreeLeafItem } from "./treeitem/item.mid.treeleaf"; |
||||
export { MultiLayerIconTreeLeafItem } from "./treeitem/item.multilayer.icon.treeleaf"; |
||||
export { RootTreeLeafItem } from "./treeitem/item.root.treeleaf"; |
||||
export { TreeTextLeafItem } from "./treeitem/item.treetextleaf"; |
||||
export { BasicTreeItem } from "./treeitem/treeitem"; |
@ -1,84 +1,95 @@
|
||||
/** |
||||
* Created by Windy on 2018/2/1. |
||||
*/ |
||||
BI.Switch = BI.inherit(BI.BasicButton, { |
||||
|
||||
constants: { |
||||
CIRCLE_SIZE: 12 |
||||
}, |
||||
import { BasicButton } from "../../base/single/button/button.basic"; |
||||
import { shortcut } from "../../core"; |
||||
|
||||
@shortcut() |
||||
export class Switch extends BasicButton { |
||||
static xtype = "bi.switch"; |
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
props: { |
||||
constants = { |
||||
CIRCLE_SIZE: 12, |
||||
}; |
||||
|
||||
props = { |
||||
extraCls: "bi-switch", |
||||
attributes: { |
||||
tabIndex: 1 |
||||
tabIndex: 1, |
||||
}, |
||||
height: 20, |
||||
width: 44, |
||||
showTip: false |
||||
}, |
||||
showTip: false, |
||||
}; |
||||
|
||||
render() { |
||||
const o = this.options, |
||||
c = this.constants; |
||||
const tgap = (o.height - c.CIRCLE_SIZE) / 2; |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options, c = this.constants; |
||||
var tgap = (o.height - c.CIRCLE_SIZE) / 2; |
||||
return { |
||||
type: "bi.absolute", |
||||
ref: function () { |
||||
self.layout = this; |
||||
ref: _ref => { |
||||
this.layout = _ref; |
||||
}, |
||||
items: [{ |
||||
items: [ |
||||
{ |
||||
el: { |
||||
type: "bi.text_button", |
||||
cls: "circle-button" |
||||
cls: "circle-button", |
||||
}, |
||||
width: 12, |
||||
height: 12, |
||||
top: tgap, |
||||
left: o.selected ? 28 : 4 |
||||
}, { |
||||
left: o.selected ? 28 : 4, |
||||
}, |
||||
{ |
||||
type: "bi.label", |
||||
text: BI.i18nText("BI-Basic_Simple_Open"), |
||||
cls: "content-tip", |
||||
left: 8, |
||||
top: tgap - 2, |
||||
invisible: !(o.showTip && o.selected), |
||||
ref: function (ref) { |
||||
self.openTip = ref; |
||||
} |
||||
}, { |
||||
ref: _ref => { |
||||
this.openTip = _ref; |
||||
}, |
||||
}, |
||||
{ |
||||
type: "bi.label", |
||||
text: BI.i18nText("BI-Basic_Simple_Close"), |
||||
cls: "content-tip", |
||||
right: 8, |
||||
top: tgap - 2, |
||||
invisible: !(o.showTip && !o.selected), |
||||
ref: function (ref) { |
||||
self.closeTip = ref; |
||||
ref: _ref => { |
||||
this.closeTip = _ref; |
||||
}, |
||||
} |
||||
}] |
||||
], |
||||
}; |
||||
}, |
||||
} |
||||
|
||||
_setEnable: function (enable) { |
||||
BI.Switch.superclass._setEnable.apply(this, arguments); |
||||
_setEnable(enable) { |
||||
super._setEnable.apply(this, arguments); |
||||
if (enable === true) { |
||||
this.element.attr("tabIndex", 1); |
||||
} else if (enable === false) { |
||||
this.element.removeAttr("tabIndex"); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setSelected: function (v) { |
||||
BI.Switch.superclass.setSelected.apply(this, arguments); |
||||
setSelected(v) { |
||||
super.setSelected.apply(this, arguments); |
||||
this.layout.attr("items")[0].left = v ? 28 : 4; |
||||
this.layout.resize(); |
||||
this.options.showTip && this.openTip.setVisible(v); |
||||
this.options.showTip && this.closeTip.setVisible(!v); |
||||
}, |
||||
} |
||||
|
||||
doClick: function () { |
||||
BI.Switch.superclass.doClick.apply(this, arguments); |
||||
this.fireEvent(BI.Switch.EVENT_CHANGE, this.isSelected()); |
||||
doClick() { |
||||
super.doClick.apply(this, arguments); |
||||
this.fireEvent(Switch.EVENT_CHANGE, this.isSelected()); |
||||
} |
||||
}); |
||||
BI.Switch.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.switch", BI.Switch); |
||||
} |
||||
|
@ -0,0 +1,7 @@
|
||||
import * as button from "./button"; |
||||
|
||||
Object.assign(BI, { |
||||
...button, |
||||
}); |
||||
|
||||
export * from "./button"; |
@ -1,2 +1,2 @@
|
||||
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 { HighlightBehavior } from "./behavior.highlight"; |
||||
export { RedMarkBehavior } from "./behavior.redmark"; |
||||
export { |
||||
HighlightBehavior, |
||||
RedMarkBehavior |
||||
}; |
||||
|
@ -0,0 +1,2 @@
|
||||
export { Events } from "./events"; |
||||
export * from "./var"; |
@ -1,9 +1,21 @@
|
||||
// export * from "../../typescript/core/decorator/decorator.ts";
|
||||
|
||||
import { shortcut as biShortcut, provider as biProvider } from "./5.inject"; |
||||
|
||||
/** |
||||
* 注册widget |
||||
*/ |
||||
import { shortcut as biShortcut } from "./5.inject"; |
||||
export function shortcut() { |
||||
return function decorator(Target) { |
||||
biShortcut(Target.xtype, Target); |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 注册provider |
||||
*/ |
||||
export function provider() { |
||||
return function decorator(Target) { |
||||
biProvider(Target.xtype, Target); |
||||
}; |
||||
} |
||||
|
@ -1,22 +1,25 @@
|
||||
export const registAttrFun = (Element) => { |
||||
Element.registerFunction('attr', function (key, value) { |
||||
var self = this; |
||||
if (BI.isObject(key)) { |
||||
BI.each(key, (k, v) => { |
||||
self.attr(k, v); |
||||
import { isObject, each, isNull, isNotNull } from "../../2.base"; |
||||
|
||||
export const registAttrFun = Element => { |
||||
Element.registerFunction("attr", function (key, value) { |
||||
if (isObject(key)) { |
||||
each(key, (k, v) => { |
||||
this.attr(k, v); |
||||
}); |
||||
|
||||
return this; |
||||
} |
||||
if (BI.isNull(value)) { |
||||
if (isNull(value)) { |
||||
return this.attribs[key]; |
||||
} |
||||
this.attribs[key] = value; |
||||
|
||||
return this; |
||||
}); |
||||
Element.registerFunction('hasAttrib', function (key) { |
||||
return this.attribs[key] != null; |
||||
Element.registerFunction("hasAttrib", function (key) { |
||||
return isNotNull(this.attribs[key]); |
||||
}); |
||||
Element.registerFunction('removeAttr', function (key) { |
||||
Element.registerFunction("removeAttr", function (key) { |
||||
delete this.attribs[key]; |
||||
}); |
||||
}; |
||||
|
@ -1,23 +1,23 @@
|
||||
export const registClassFun = (Element) => { |
||||
Element.registerFunction('addClass', function (classList) { |
||||
var self = this; |
||||
BI.each(classList.split(' '), (i, cls) => { |
||||
if (cls && !self.classMap[cls]) { |
||||
self.classList.push(cls); |
||||
export const registClassFun = Element => { |
||||
Element.registerFunction("addClass", function (classList) { |
||||
BI.each(classList.split(" "), (i, cls) => { |
||||
if (cls && !this.classMap[cls]) { |
||||
this.classList.push(cls); |
||||
} |
||||
cls && (self.classMap[cls] = true); |
||||
cls && (this.classMap[cls] = true); |
||||
}); |
||||
|
||||
return this; |
||||
}); |
||||
|
||||
Element.registerFunction('removeClass', function (classList) { |
||||
var self = this; |
||||
BI.each(classList.split(' '), (i, cls) => { |
||||
if (cls && self.classMap[cls]) { |
||||
delete self.classMap[cls]; |
||||
self.classList.splice(self.classList.indexOf(cls), 1); |
||||
Element.registerFunction("removeClass", function (classList) { |
||||
BI.each(classList.split(" "), (i, cls) => { |
||||
if (cls && this.classMap[cls]) { |
||||
delete this.classMap[cls]; |
||||
this.classList.splice(this.classList.indexOf(cls), 1); |
||||
} |
||||
}); |
||||
|
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,22 +1,26 @@
|
||||
export const registCssFun = (Element) => { |
||||
Element.registerFunction('css', function (key, value) { |
||||
var self = this; |
||||
if (BI.isObject(key)) { |
||||
BI.each(key, (k, v) => { |
||||
self.css(k, v); |
||||
import { isNull, isObject, each, trim, camelize } from "../../2.base"; |
||||
|
||||
export const registCssFun = Element => { |
||||
Element.registerFunction("css", function (key, value) { |
||||
if (isObject(key)) { |
||||
each(key, (k, v) => { |
||||
this.css(k, v); |
||||
}); |
||||
|
||||
return this; |
||||
} |
||||
key = BI.trim(BI.camelize(key)); |
||||
key = trim(camelize(key)); |
||||
|
||||
return css(this, key, value); |
||||
}); |
||||
}; |
||||
|
||||
const css = (elem, key, value) => { |
||||
key = BI.trim(BI.camelize(key)); |
||||
if (BI.isNull(value)) { |
||||
key = trim(camelize(key)); |
||||
if (isNull(value)) { |
||||
return elem.styles[key]; |
||||
} |
||||
elem.styles[key] = value; |
||||
|
||||
return elem; |
||||
}; |
||||
|
@ -1,12 +1,15 @@
|
||||
export const registDataFun = (Element) => { |
||||
Element.registerFunction('data', function (key, value) { |
||||
import { isNull } from "../../2.base"; |
||||
|
||||
export const registDataFun = Element => { |
||||
Element.registerFunction("data", function (key, value) { |
||||
if (!this._data) { |
||||
this._data = {}; |
||||
} |
||||
if (BI.isNull(value)) { |
||||
if (isNull(value)) { |
||||
return this._data[key]; |
||||
} |
||||
this._data[key] = value; |
||||
|
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,9 +1,10 @@
|
||||
export const registEmptyFun = (Element) => { |
||||
Element.registerFunction('empty', function (text) { |
||||
export const registEmptyFun = Element => { |
||||
Element.registerFunction("empty", function (text) { |
||||
this.children = []; |
||||
|
||||
return this; |
||||
}); |
||||
Element.registerFunction('destroy', function (text) { |
||||
Element.registerFunction("destroy", function (text) { |
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,32 +1,33 @@
|
||||
var returnThis = function () { |
||||
function returnThis () { |
||||
return this; |
||||
}; |
||||
export const registEventFun = (Element) => { |
||||
} |
||||
|
||||
export const registEventFun = Element => { |
||||
[ |
||||
'mousedown', |
||||
'mouseup', |
||||
'mousewheel', |
||||
'keydown', |
||||
'keyup', |
||||
'focus', |
||||
'focusin', |
||||
'focusout', |
||||
'click', |
||||
'on', |
||||
'off', |
||||
'bind', |
||||
'unbind', |
||||
'trigger', |
||||
'hover', |
||||
'scroll', |
||||
'scrollLeft', |
||||
'scrollTop', |
||||
'resize', |
||||
'show', |
||||
'hide', |
||||
'dblclick', |
||||
'blur', |
||||
].forEach((event) => { |
||||
"mousedown", |
||||
"mouseup", |
||||
"mousewheel", |
||||
"keydown", |
||||
"keyup", |
||||
"focus", |
||||
"focusin", |
||||
"focusout", |
||||
"click", |
||||
"on", |
||||
"off", |
||||
"bind", |
||||
"unbind", |
||||
"trigger", |
||||
"hover", |
||||
"scroll", |
||||
"scrollLeft", |
||||
"scrollTop", |
||||
"resize", |
||||
"show", |
||||
"hide", |
||||
"dblclick", |
||||
"blur" |
||||
].forEach(event => { |
||||
Element.registerFunction(event, returnThis); |
||||
}); |
||||
}; |
||||
|
@ -1,15 +1,19 @@
|
||||
export const registHtmlFun = (Element) => { |
||||
Element.registerFunction('html', function (text) { |
||||
if (text && text.charAt(0) === '<') { |
||||
BI.createWidget({ |
||||
type: 'bi.html', |
||||
import { createWidget } from "../../5.inject"; |
||||
import { htmlDecode } from "../../func"; |
||||
|
||||
export const registHtmlFun = Element => { |
||||
Element.registerFunction("html", function (text) { |
||||
if (text && text.charAt(0) === "<") { |
||||
createWidget({ |
||||
type: "bi.html", |
||||
element: this.widget, |
||||
html: text, |
||||
}); |
||||
this.originalHtml = text; |
||||
} else { |
||||
this.text = BI.htmlDecode(text); |
||||
this.text = htmlDecode(text); |
||||
} |
||||
|
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,6 +1,7 @@
|
||||
export const registKeywordMarkFun = (Element) => { |
||||
Element.registerFunction('__textKeywordMarked__', function (text) { |
||||
export const registKeywordMarkFun = Element => { |
||||
Element.registerFunction("__textKeywordMarked__", function (text) { |
||||
this[0].textContent = text; |
||||
|
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,65 +1,69 @@
|
||||
var skipArray = []; |
||||
var pxStyle = ['font-size', 'width', 'height']; |
||||
var _renderToHtml = function (root) { |
||||
var str = ''; |
||||
if (BI.isNull(root.originalHtml)) { |
||||
if (root.tag !== 'body') { |
||||
import { each, isNull, hyphenate, isNumeric, isKey } from "../../2.base"; |
||||
|
||||
const skipArray = []; |
||||
const pxStyle = ["font-size", "width", "height"]; |
||||
function _renderToHtml(root) { |
||||
let str = ""; |
||||
if (isNull(root.originalHtml)) { |
||||
if (root.tag !== "body") { |
||||
str += `<${root.tag}`; |
||||
if (root.classList.length > 0) { |
||||
str += ' class="'; |
||||
BI.each(root.classList, (i, cls) => { |
||||
str += " class=\""; |
||||
each(root.classList, (i, cls) => { |
||||
str += ` ${cls}`; |
||||
}); |
||||
str += '"'; |
||||
str += "\""; |
||||
} |
||||
str += ' style="'; |
||||
BI.each(root.originalStyles, (key, stl) => { |
||||
str += " style=\""; |
||||
each(root.originalStyles, (key, stl) => { |
||||
if ( |
||||
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; |
||||
} |
||||
key = BI.hyphenate(key); |
||||
if (key === 'font-family') { |
||||
stl = stl.replace(/\"/g, ''); |
||||
key = hyphenate(key); |
||||
if (key === "font-family") { |
||||
stl = stl.replace(/"/g, ""); |
||||
} |
||||
if (pxStyle.contains(key) && BI.isNumeric(stl)) { |
||||
stl += 'px'; |
||||
if (pxStyle.contains(key) && isNumeric(stl)) { |
||||
stl += "px"; |
||||
} |
||||
if (BI.isKey(stl)) { |
||||
if (isKey(stl)) { |
||||
str += ` ${key}:${stl};`; |
||||
} |
||||
}); |
||||
str += '"'; |
||||
BI.each(root.attribs, (key, attr) => { |
||||
if (BI.isKey(attr)) { |
||||
str += "\""; |
||||
each(root.attribs, (key, attr) => { |
||||
if (isKey(attr)) { |
||||
str += ` ${key}=${attr}`; |
||||
} |
||||
}); |
||||
if (root.textContent) { |
||||
str += ` title=${root.textContent}`; |
||||
} |
||||
str += '>'; |
||||
str += ">"; |
||||
} |
||||
// 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了
|
||||
// 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样
|
||||
BI.each(root.children, (i, child) => { |
||||
each(root.children, (i, child) => { |
||||
str += _renderToHtml(child); |
||||
}); |
||||
} else { |
||||
str += root.originalHtml; |
||||
} |
||||
if (root.tag !== 'body') { |
||||
if (root.tag !== "body") { |
||||
if (root.textContent) { |
||||
str += root.textContent; |
||||
} |
||||
str += `</${root.tag}>`; |
||||
} |
||||
|
||||
return str; |
||||
}; |
||||
export const registRenderToHtmlFun = (Element) => { |
||||
Element.registerFunction('renderToHtml', function () { |
||||
} |
||||
|
||||
export const registRenderToHtmlFun = Element => { |
||||
Element.registerFunction("renderToHtml", function () { |
||||
return _renderToHtml(this); |
||||
}); |
||||
}; |
||||
|
@ -1,50 +1,54 @@
|
||||
var skipArray = ['width', 'height']; |
||||
var _renderToString = function (root) { |
||||
var str = ''; |
||||
if (root.nodeName !== 'body') { |
||||
import { each, hyphenate } from "../../2.base"; |
||||
|
||||
const skipArray = ["width", "height"]; |
||||
function _renderToString(root) { |
||||
let str = ""; |
||||
if (root.nodeName !== "body") { |
||||
str += `<${root.nodeName}`; |
||||
if (root.classList.length > 0) { |
||||
str += ' class="'; |
||||
BI.each(root.classList, (i, cls) => { |
||||
str += " class=\""; |
||||
each(root.classList, (i, cls) => { |
||||
str += ` ${cls}`; |
||||
}); |
||||
str += '"'; |
||||
str += "\""; |
||||
} |
||||
str += ' style="'; |
||||
BI.each(root.styles, (key, stl) => { |
||||
str += " style=\""; |
||||
each(root.styles, (key, stl) => { |
||||
if (skipArray.includes(key)) { |
||||
return; |
||||
} |
||||
key = BI.hyphenate(key); |
||||
key = hyphenate(key); |
||||
str += ` ${key}:${stl};`; |
||||
}); |
||||
str += ` width:${root.width}px;`; |
||||
str += ` height:${root.height}px;`; |
||||
str += ' position: fixed;'; |
||||
str += " position: fixed;"; |
||||
str += ` left: ${root.position.x}px;`; |
||||
str += ` top: ${root.position.y}px;`; |
||||
str += '"'; |
||||
BI.each(root.attribs, (key, attr) => { |
||||
str += "\""; |
||||
each(root.attribs, (key, attr) => { |
||||
str += ` ${key}:${attr}`; |
||||
}); |
||||
str += '>'; |
||||
str += ">"; |
||||
} |
||||
BI.each(root.children, (i, child) => { |
||||
each(root.children, (i, child) => { |
||||
str += _renderToString(child); |
||||
}); |
||||
// if (root.htmlContent) {
|
||||
// str += root.htmlContent;
|
||||
// }
|
||||
if (root.nodeName !== 'body') { |
||||
if (root.nodeName !== "body") { |
||||
if (root.text) { |
||||
str += root.text; |
||||
} |
||||
str += `</${root.nodeName}>`; |
||||
} |
||||
|
||||
return str; |
||||
}; |
||||
export const registRenderToStringFun = (Element) => { |
||||
Element.registerFunction('renderToString', function () { |
||||
} |
||||
|
||||
export const registRenderToStringFun = Element => { |
||||
Element.registerFunction("renderToString", function () { |
||||
return _renderToString(this); |
||||
}); |
||||
}; |
||||
|
@ -1,10 +1,12 @@
|
||||
export const registTextFun = (Element) => { |
||||
Element.registerFunction('setText', function (text) { |
||||
export const registTextFun = Element => { |
||||
Element.registerFunction("setText", function (text) { |
||||
this.text = text; |
||||
|
||||
return this; |
||||
}); |
||||
Element.registerFunction('setValue', function (text) { |
||||
Element.registerFunction("setValue", function (text) { |
||||
this.text = text; |
||||
|
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,9 +1,11 @@
|
||||
export const registValFun = (Element) => { |
||||
Element.registerFunction('val', function (value) { |
||||
export const registValFun = Element => { |
||||
Element.registerFunction("val", function (value) { |
||||
if (BI.isNotNull(value)) { |
||||
this.text = `${value}`; |
||||
|
||||
return this; |
||||
} |
||||
|
||||
return this.text; |
||||
}); |
||||
}; |
||||
|
@ -1,58 +1,59 @@
|
||||
BI.Fragment = function () { |
||||
}; |
||||
import { isNotNull, isArray, isFunction, isKey, extend } from "./2.base"; |
||||
|
||||
BI.h = function (type, props, children) { |
||||
if (children != null) { |
||||
if (!BI.isArray(children)) { |
||||
export function Fragment () {} |
||||
|
||||
export function h (type, props, children) { |
||||
if (isNotNull(children)) { |
||||
if (!isArray(children)) { |
||||
children = [children]; |
||||
} |
||||
} else { |
||||
children = []; |
||||
} |
||||
if (arguments.length > 3) { |
||||
for (var i = 3; i < arguments.length; i++) { |
||||
if (BI.isArray(arguments[i])) { |
||||
for (let i = 3; i < arguments.length; i++) { |
||||
if (isArray(arguments[i])) { |
||||
children = children.concat(arguments[i]); |
||||
} else { |
||||
children.push(arguments[i]); |
||||
} |
||||
} |
||||
} |
||||
if (type === BI.Fragment) { |
||||
if (type === Fragment) { |
||||
return children; |
||||
} |
||||
if (BI.isFunction(type)) { |
||||
if (isFunction(type)) { |
||||
type = type.xtype || type; |
||||
} |
||||
if (type === "el") { |
||||
return BI.extend({ |
||||
el: children[0] |
||||
return extend({ |
||||
el: children[0], |
||||
}, props); |
||||
} |
||||
if (type === "left") { |
||||
return BI.extend({ |
||||
left: children |
||||
return extend({ |
||||
left: children, |
||||
}, props); |
||||
} |
||||
if (type === "right") { |
||||
return BI.extend({ |
||||
right: children |
||||
return extend({ |
||||
right: children, |
||||
}, props); |
||||
} |
||||
if (children.length === 1) { |
||||
if (BI.isKey(children[0])) { |
||||
return BI.extend({ |
||||
type: type |
||||
if (isKey(children[0])) { |
||||
return extend({ |
||||
type, |
||||
}, { text: children[0] }, props); |
||||
} |
||||
if (BI.isFunction(children[0])) { |
||||
return BI.extend({ |
||||
type: type |
||||
if (isFunction(children[0])) { |
||||
return extend({ |
||||
type, |
||||
}, { items: children[0] }, props); |
||||
} |
||||
} |
||||
|
||||
return BI.extend({ |
||||
type: type |
||||
return extend({ |
||||
type, |
||||
}, children.length > 0 ? { items: children } : {}, props); |
||||
}; |
||||
} |
||||
|
@ -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) { |
||||
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; |
||||
} |
||||
}, |
||||
import { OB } from "../3.ob"; |
||||
|
||||
createLogicItemsByDirection: function (direction) { |
||||
var layout; |
||||
var items = Array.prototype.slice.call(arguments, 1); |
||||
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; |
||||
export class Logic extends OB { |
||||
createLogic() { |
||||
return this.options || {}; |
||||
} |
||||
}; |
||||
} |
||||
|
Loading…
Reference in new issue