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 { 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 |
||||
}; |
||||
|
@ -1,444 +1,441 @@
|
||||
/** |
||||
* 事件集合 |
||||
* @class BI.Events |
||||
*/ |
||||
BI._.extend(BI, { |
||||
Events: { |
||||
|
||||
/** |
||||
* @static |
||||
* @property keydown事件 |
||||
*/ |
||||
KEYDOWN: "_KEYDOWN", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 回撤事件 |
||||
*/ |
||||
BACKSPACE: "_BACKSPACE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 空格事件 |
||||
*/ |
||||
SPACE: "_SPACE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 回车事件 |
||||
*/ |
||||
ENTER: "_ENTER", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 确定事件 |
||||
*/ |
||||
CONFIRM: "_CONFIRM", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 错误事件 |
||||
*/ |
||||
ERROR: "_ERROR", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 暂停事件 |
||||
*/ |
||||
PAUSE: "_PAUSE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property destroy事件 |
||||
*/ |
||||
DESTROY: "_DESTROY", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 挂载事件 |
||||
*/ |
||||
MOUNT: "_MOUNT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 取消挂载事件 |
||||
*/ |
||||
UNMOUNT: "_UNMOUNT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 清除选择 |
||||
*/ |
||||
CLEAR: "_CLEAR", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 添加数据 |
||||
*/ |
||||
ADD: "_ADD", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 正在编辑状态事件 |
||||
*/ |
||||
EDITING: "_EDITING", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 空状态事件 |
||||
*/ |
||||
EMPTY: "_EMPTY", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 显示隐藏事件 |
||||
*/ |
||||
VIEW: "_VIEW", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 窗体改变大小 |
||||
*/ |
||||
RESIZE: "_RESIZE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 编辑前事件 |
||||
*/ |
||||
BEFOREEDIT: "_BEFOREEDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 编辑后事件 |
||||
*/ |
||||
AFTEREDIT: "_AFTEREDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 开始编辑事件 |
||||
*/ |
||||
STARTEDIT: "_STARTEDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 停止编辑事件 |
||||
*/ |
||||
STOPEDIT: "_STOPEDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 值改变事件 |
||||
*/ |
||||
CHANGE: "_CHANGE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 下拉弹出菜单事件 |
||||
*/ |
||||
EXPAND: "_EXPAND", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 关闭下拉菜单事件 |
||||
*/ |
||||
COLLAPSE: "_COLLAPSE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 下拉菜单切换展开收起事件 |
||||
*/ |
||||
TOGGLE: "_TOGGLE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 回调事件 |
||||
*/ |
||||
CALLBACK: "_CALLBACK", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 点击事件 |
||||
*/ |
||||
CLICK: "_CLICK", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 状态改变事件,一般是用在复选按钮和单选按钮 |
||||
*/ |
||||
STATECHANGE: "_STATECHANGE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 状态改变前事件 |
||||
*/ |
||||
BEFORESTATECHANGE: "_BEFORESTATECHANGE", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property 初始化事件 |
||||
*/ |
||||
INIT: "_INIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 初始化后事件 |
||||
*/ |
||||
AFTERINIT: "_AFTERINIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 滚动条滚动事件 |
||||
*/ |
||||
SCROLL: "_SCROLL", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property 开始加载事件 |
||||
*/ |
||||
STARTLOAD: "_STARTLOAD", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 加载后事件 |
||||
*/ |
||||
AFTERLOAD: "_AFTERLOAD", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交前事件 |
||||
*/ |
||||
BS: "beforesubmit", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交后事件 |
||||
*/ |
||||
AS: "aftersubmit", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交完成事件 |
||||
*/ |
||||
SC: "submitcomplete", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交失败事件 |
||||
*/ |
||||
SF: "submitfailure", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交成功事件 |
||||
*/ |
||||
SS: "submitsuccess", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 校验提交前事件 |
||||
*/ |
||||
BVW: "beforeverifywrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 校验提交后事件 |
||||
*/ |
||||
AVW: "afterverifywrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 校验后事件 |
||||
*/ |
||||
AV: "afterverify", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报前事件 |
||||
*/ |
||||
BW: "beforewrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报后事件 |
||||
*/ |
||||
AW: "afterwrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报成功事件 |
||||
*/ |
||||
WS: "writesuccess", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报失败事件 |
||||
*/ |
||||
WF: "writefailure", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 添加行前事件 |
||||
*/ |
||||
BA: "beforeappend", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 添加行后事件 |
||||
*/ |
||||
AA: "afterappend", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 删除行前事件 |
||||
*/ |
||||
BD: "beforedelete", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 删除行后事件 |
||||
*/ |
||||
AD: "beforedelete", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 未提交离开事件 |
||||
*/ |
||||
UC: "unloadcheck", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF导出前事件 |
||||
*/ |
||||
BTOPDF: "beforetopdf", |
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF导出后事件 |
||||
*/ |
||||
ATOPDF: "aftertopdf", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导出前事件 |
||||
*/ |
||||
BTOEXCEL: "beforetoexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导出后事件 |
||||
*/ |
||||
ATOEXCEL: "aftertoexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Word导出前事件 |
||||
*/ |
||||
BTOWORD: "beforetoword", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Word导出后事件 |
||||
*/ |
||||
ATOWORD: "aftertoword", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 图片导出前事件 |
||||
*/ |
||||
BTOIMAGE: "beforetoimage", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 图片导出后事件 |
||||
*/ |
||||
ATOIMAGE: "aftertoimage", |
||||
|
||||
/** |
||||
* @static |
||||
* @property HTML导出前事件 |
||||
*/ |
||||
BTOHTML: "beforetohtml", |
||||
|
||||
/** |
||||
* @static |
||||
* @property HTML导出后事件 |
||||
*/ |
||||
ATOHTML: "aftertohtml", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导入前事件 |
||||
*/ |
||||
BIMEXCEL: "beforeimportexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导出后事件 |
||||
*/ |
||||
AIMEXCEL: "afterimportexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF打印前事件 |
||||
*/ |
||||
BPDFPRINT: "beforepdfprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF打印后事件 |
||||
*/ |
||||
APDFPRINT: "afterpdfprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Flash打印前事件 |
||||
*/ |
||||
BFLASHPRINT: "beforeflashprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Flash打印后事件 |
||||
*/ |
||||
AFLASHPRINT: "afterflashprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Applet打印前事件 |
||||
*/ |
||||
BAPPLETPRINT: "beforeappletprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Applet打印后事件 |
||||
*/ |
||||
AAPPLETPRINT: "afterappletprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 服务器打印前事件 |
||||
*/ |
||||
BSEVERPRINT: "beforeserverprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 服务器打印后事件 |
||||
*/ |
||||
ASERVERPRINT: "afterserverprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 邮件发送前事件 |
||||
*/ |
||||
BEMAIL: "beforeemail", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 邮件发送后事件 |
||||
*/ |
||||
AEMAIL: "afteremail" |
||||
} |
||||
}); |
||||
export const Events = { |
||||
|
||||
/** |
||||
* @static |
||||
* @property keydown事件 |
||||
*/ |
||||
KEYDOWN: "_KEYDOWN", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 回撤事件 |
||||
*/ |
||||
BACKSPACE: "_BACKSPACE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 空格事件 |
||||
*/ |
||||
SPACE: "_SPACE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 回车事件 |
||||
*/ |
||||
ENTER: "_ENTER", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 确定事件 |
||||
*/ |
||||
CONFIRM: "_CONFIRM", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 错误事件 |
||||
*/ |
||||
ERROR: "_ERROR", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 暂停事件 |
||||
*/ |
||||
PAUSE: "_PAUSE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property destroy事件 |
||||
*/ |
||||
DESTROY: "_DESTROY", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 挂载事件 |
||||
*/ |
||||
MOUNT: "_MOUNT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 取消挂载事件 |
||||
*/ |
||||
UNMOUNT: "_UNMOUNT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 清除选择 |
||||
*/ |
||||
CLEAR: "_CLEAR", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 添加数据 |
||||
*/ |
||||
ADD: "_ADD", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 正在编辑状态事件 |
||||
*/ |
||||
EDITING: "_EDITING", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 空状态事件 |
||||
*/ |
||||
EMPTY: "_EMPTY", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 显示隐藏事件 |
||||
*/ |
||||
VIEW: "_VIEW", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 窗体改变大小 |
||||
*/ |
||||
RESIZE: "_RESIZE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 编辑前事件 |
||||
*/ |
||||
BEFOREEDIT: "_BEFOREEDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 编辑后事件 |
||||
*/ |
||||
AFTEREDIT: "_AFTEREDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 开始编辑事件 |
||||
*/ |
||||
STARTEDIT: "_STARTEDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 停止编辑事件 |
||||
*/ |
||||
STOPEDIT: "_STOPEDIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 值改变事件 |
||||
*/ |
||||
CHANGE: "_CHANGE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 下拉弹出菜单事件 |
||||
*/ |
||||
EXPAND: "_EXPAND", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 关闭下拉菜单事件 |
||||
*/ |
||||
COLLAPSE: "_COLLAPSE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 下拉菜单切换展开收起事件 |
||||
*/ |
||||
TOGGLE: "_TOGGLE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 回调事件 |
||||
*/ |
||||
CALLBACK: "_CALLBACK", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 点击事件 |
||||
*/ |
||||
CLICK: "_CLICK", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 状态改变事件,一般是用在复选按钮和单选按钮 |
||||
*/ |
||||
STATECHANGE: "_STATECHANGE", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 状态改变前事件 |
||||
*/ |
||||
BEFORESTATECHANGE: "_BEFORESTATECHANGE", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property 初始化事件 |
||||
*/ |
||||
INIT: "_INIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 初始化后事件 |
||||
*/ |
||||
AFTERINIT: "_AFTERINIT", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 滚动条滚动事件 |
||||
*/ |
||||
SCROLL: "_SCROLL", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property 开始加载事件 |
||||
*/ |
||||
STARTLOAD: "_STARTLOAD", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 加载后事件 |
||||
*/ |
||||
AFTERLOAD: "_AFTERLOAD", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交前事件 |
||||
*/ |
||||
BS: "beforesubmit", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交后事件 |
||||
*/ |
||||
AS: "aftersubmit", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交完成事件 |
||||
*/ |
||||
SC: "submitcomplete", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交失败事件 |
||||
*/ |
||||
SF: "submitfailure", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 提交成功事件 |
||||
*/ |
||||
SS: "submitsuccess", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 校验提交前事件 |
||||
*/ |
||||
BVW: "beforeverifywrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 校验提交后事件 |
||||
*/ |
||||
AVW: "afterverifywrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 校验后事件 |
||||
*/ |
||||
AV: "afterverify", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报前事件 |
||||
*/ |
||||
BW: "beforewrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报后事件 |
||||
*/ |
||||
AW: "afterwrite", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报成功事件 |
||||
*/ |
||||
WS: "writesuccess", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 填报失败事件 |
||||
*/ |
||||
WF: "writefailure", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 添加行前事件 |
||||
*/ |
||||
BA: "beforeappend", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 添加行后事件 |
||||
*/ |
||||
AA: "afterappend", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 删除行前事件 |
||||
*/ |
||||
BD: "beforedelete", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 删除行后事件 |
||||
*/ |
||||
AD: "beforedelete", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 未提交离开事件 |
||||
*/ |
||||
UC: "unloadcheck", |
||||
|
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF导出前事件 |
||||
*/ |
||||
BTOPDF: "beforetopdf", |
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF导出后事件 |
||||
*/ |
||||
ATOPDF: "aftertopdf", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导出前事件 |
||||
*/ |
||||
BTOEXCEL: "beforetoexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导出后事件 |
||||
*/ |
||||
ATOEXCEL: "aftertoexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Word导出前事件 |
||||
*/ |
||||
BTOWORD: "beforetoword", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Word导出后事件 |
||||
*/ |
||||
ATOWORD: "aftertoword", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 图片导出前事件 |
||||
*/ |
||||
BTOIMAGE: "beforetoimage", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 图片导出后事件 |
||||
*/ |
||||
ATOIMAGE: "aftertoimage", |
||||
|
||||
/** |
||||
* @static |
||||
* @property HTML导出前事件 |
||||
*/ |
||||
BTOHTML: "beforetohtml", |
||||
|
||||
/** |
||||
* @static |
||||
* @property HTML导出后事件 |
||||
*/ |
||||
ATOHTML: "aftertohtml", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导入前事件 |
||||
*/ |
||||
BIMEXCEL: "beforeimportexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Excel导出后事件 |
||||
*/ |
||||
AIMEXCEL: "afterimportexcel", |
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF打印前事件 |
||||
*/ |
||||
BPDFPRINT: "beforepdfprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property PDF打印后事件 |
||||
*/ |
||||
APDFPRINT: "afterpdfprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Flash打印前事件 |
||||
*/ |
||||
BFLASHPRINT: "beforeflashprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Flash打印后事件 |
||||
*/ |
||||
AFLASHPRINT: "afterflashprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Applet打印前事件 |
||||
*/ |
||||
BAPPLETPRINT: "beforeappletprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property Applet打印后事件 |
||||
*/ |
||||
AAPPLETPRINT: "afterappletprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 服务器打印前事件 |
||||
*/ |
||||
BSEVERPRINT: "beforeserverprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 服务器打印后事件 |
||||
*/ |
||||
ASERVERPRINT: "afterserverprint", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 邮件发送前事件 |
||||
*/ |
||||
BEMAIL: "beforeemail", |
||||
|
||||
/** |
||||
* @static |
||||
* @property 邮件发送后事件 |
||||
*/ |
||||
AEMAIL: "afteremail", |
||||
}; |
||||
|
@ -0,0 +1,2 @@
|
||||
export { Events } from "./events"; |
||||
export * from "./var"; |
@ -1,167 +1,170 @@
|
||||
/** |
||||
* 常量 |
||||
*/ |
||||
import { isNumber } from "../2.base"; |
||||
|
||||
BI._.extend(BI, { |
||||
MAX: 0xfffffffffffffff, |
||||
MIN: -0xfffffffffffffff, |
||||
EVENT_RESPONSE_TIME: 200, |
||||
EVENT_BLUR: true, |
||||
zIndex_layer: 1e5, |
||||
zIndex_popover: 1e6, |
||||
zIndex_popup: 1e7, |
||||
zIndex_masker: 1e8, |
||||
zIndex_tip: 1e9, |
||||
emptyStr: "", |
||||
pixUnit: "px", |
||||
pixRatio: 1, |
||||
// 一定返回最终的单位
|
||||
pixFormat: function (pix, border) { |
||||
if (!BI.isNumber(pix)) { |
||||
return pix; |
||||
} |
||||
if (BI.pixUnit === "px") { |
||||
return (pix / BI.pixRatio - (border || 0)) + BI.pixUnit; |
||||
} |
||||
var length = pix / BI.pixRatio + BI.pixUnit; |
||||
if (border > 0) { |
||||
return `calc(${length} - ${border + "px"})`; |
||||
} |
||||
return length; |
||||
}, |
||||
toPix: function (pix, border) { |
||||
if (!BI.isNumber(pix)) { |
||||
return pix; |
||||
} |
||||
if (BI.pixUnit === "px") { |
||||
return pix - (border || 0) * BI.pixRatio; |
||||
} |
||||
if (border > 0) { |
||||
return `calc(${pix / BI.pixRatio + BI.pixUnit} - ${border + "px"})`; |
||||
} |
||||
export const MAX = 0xfffffffffffffff; |
||||
export const MIN = -0xfffffffffffffff; |
||||
export const EVENT_RESPONSE_TIME = 200; |
||||
export const EVENT_BLUR = true; |
||||
export const zIndex_layer = 1e5; |
||||
export const zIndex_popover = 1e6; |
||||
export const zIndex_popup = 1e7; |
||||
export const zIndex_masker = 1e8; |
||||
export const zIndex_tip = 1e9; |
||||
export const emptyStr = ""; |
||||
export const pixUnit = "px"; |
||||
export const pixRatio = 1; |
||||
export const empty = null; |
||||
export const Key = { |
||||
48: "0", |
||||
49: "1", |
||||
50: "2", |
||||
51: "3", |
||||
52: "4", |
||||
53: "5", |
||||
54: "6", |
||||
55: "7", |
||||
56: "8", |
||||
57: "9", |
||||
65: "a", |
||||
66: "b", |
||||
67: "c", |
||||
68: "d", |
||||
69: "e", |
||||
70: "f", |
||||
71: "g", |
||||
72: "h", |
||||
73: "i", |
||||
74: "j", |
||||
75: "k", |
||||
76: "l", |
||||
77: "m", |
||||
78: "n", |
||||
79: "o", |
||||
80: "p", |
||||
81: "q", |
||||
82: "r", |
||||
83: "s", |
||||
84: "t", |
||||
85: "u", |
||||
86: "v", |
||||
87: "w", |
||||
88: "x", |
||||
89: "y", |
||||
90: "z", |
||||
96: "0", |
||||
97: "1", |
||||
98: "2", |
||||
99: "3", |
||||
100: "4", |
||||
101: "5", |
||||
102: "6", |
||||
103: "7", |
||||
104: "8", |
||||
105: "9", |
||||
106: "*", |
||||
107: "+", |
||||
109: "-", |
||||
110: ".", |
||||
111: "/", |
||||
}; |
||||
export const KeyCode = { |
||||
BACKSPACE: 8, |
||||
COMMA: 188, |
||||
DELETE: 46, |
||||
DOWN: 40, |
||||
END: 35, |
||||
ENTER: 13, |
||||
ESCAPE: 27, |
||||
HOME: 36, |
||||
LEFT: 37, |
||||
NUMPAD_ADD: 107, |
||||
NUMPAD_DECIMAL: 110, |
||||
NUMPAD_DIVIDE: 111, |
||||
NUMPAD_ENTER: 108, |
||||
NUMPAD_MULTIPLY: 106, |
||||
NUMPAD_SUBTRACT: 109, |
||||
PAGE_DOWN: 34, |
||||
PAGE_UP: 33, |
||||
PERIOD: 190, |
||||
RIGHT: 39, |
||||
SPACE: 32, |
||||
TAB: 9, |
||||
UP: 38, |
||||
}; |
||||
export const Status = { |
||||
SUCCESS: 1, |
||||
WRONG: 2, |
||||
START: 3, |
||||
END: 4, |
||||
WAITING: 5, |
||||
READY: 6, |
||||
RUNNING: 7, |
||||
OUTOFBOUNDS: 8, |
||||
NULL: -1, |
||||
}; |
||||
export const Direction = { |
||||
Top: "top", |
||||
Bottom: "bottom", |
||||
Left: "left", |
||||
Right: "right", |
||||
Custom: "custom", |
||||
}; |
||||
export const Axis = { |
||||
Vertical: "vertical", |
||||
Horizontal: "horizontal", |
||||
}; |
||||
export const Selection = { |
||||
Default: -2, |
||||
None: -1, |
||||
Single: 0, |
||||
Multi: 1, |
||||
All: 2, |
||||
}; |
||||
export const HorizontalAlign = { |
||||
Left: "left", |
||||
Right: "right", |
||||
Center: "center", |
||||
Stretch: "stretch", |
||||
}; |
||||
export const VerticalAlign = { |
||||
Middle: "middle", |
||||
Top: "top", |
||||
Bottom: "bottom", |
||||
Stretch: "stretch", |
||||
}; |
||||
export const StartOfWeek = 1; |
||||
export const BlankSplitChar = "\u200b \u200b"; |
||||
|
||||
// 一定返回最终的单位
|
||||
export function pixFormat(pix, border) { |
||||
if (!isNumber(pix)) { |
||||
return pix; |
||||
} |
||||
if (pixUnit === "px") { |
||||
return (pix / pixRatio - (border || 0)) + pixUnit; |
||||
} |
||||
const length = pix / pixRatio + pixUnit; |
||||
if (border > 0) { |
||||
return `calc(${length} - ${`${border}px`})`; |
||||
} |
||||
|
||||
return length; |
||||
} |
||||
|
||||
export function toPix(pix, border) { |
||||
if (!isNumber(pix)) { |
||||
return pix; |
||||
}, |
||||
emptyFn: function () { |
||||
}, |
||||
empty: null, |
||||
Key: { |
||||
48: "0", |
||||
49: "1", |
||||
50: "2", |
||||
51: "3", |
||||
52: "4", |
||||
53: "5", |
||||
54: "6", |
||||
55: "7", |
||||
56: "8", |
||||
57: "9", |
||||
65: "a", |
||||
66: "b", |
||||
67: "c", |
||||
68: "d", |
||||
69: "e", |
||||
70: "f", |
||||
71: "g", |
||||
72: "h", |
||||
73: "i", |
||||
74: "j", |
||||
75: "k", |
||||
76: "l", |
||||
77: "m", |
||||
78: "n", |
||||
79: "o", |
||||
80: "p", |
||||
81: "q", |
||||
82: "r", |
||||
83: "s", |
||||
84: "t", |
||||
85: "u", |
||||
86: "v", |
||||
87: "w", |
||||
88: "x", |
||||
89: "y", |
||||
90: "z", |
||||
96: "0", |
||||
97: "1", |
||||
98: "2", |
||||
99: "3", |
||||
100: "4", |
||||
101: "5", |
||||
102: "6", |
||||
103: "7", |
||||
104: "8", |
||||
105: "9", |
||||
106: "*", |
||||
107: "+", |
||||
109: "-", |
||||
110: ".", |
||||
111: "/" |
||||
}, |
||||
KeyCode: { |
||||
BACKSPACE: 8, |
||||
COMMA: 188, |
||||
DELETE: 46, |
||||
DOWN: 40, |
||||
END: 35, |
||||
ENTER: 13, |
||||
ESCAPE: 27, |
||||
HOME: 36, |
||||
LEFT: 37, |
||||
NUMPAD_ADD: 107, |
||||
NUMPAD_DECIMAL: 110, |
||||
NUMPAD_DIVIDE: 111, |
||||
NUMPAD_ENTER: 108, |
||||
NUMPAD_MULTIPLY: 106, |
||||
NUMPAD_SUBTRACT: 109, |
||||
PAGE_DOWN: 34, |
||||
PAGE_UP: 33, |
||||
PERIOD: 190, |
||||
RIGHT: 39, |
||||
SPACE: 32, |
||||
TAB: 9, |
||||
UP: 38 |
||||
}, |
||||
Status: { |
||||
SUCCESS: 1, |
||||
WRONG: 2, |
||||
START: 3, |
||||
END: 4, |
||||
WAITING: 5, |
||||
READY: 6, |
||||
RUNNING: 7, |
||||
OUTOFBOUNDS: 8, |
||||
NULL: -1 |
||||
}, |
||||
Direction: { |
||||
Top: "top", |
||||
Bottom: "bottom", |
||||
Left: "left", |
||||
Right: "right", |
||||
Custom: "custom" |
||||
}, |
||||
Axis: { |
||||
Vertical: "vertical", |
||||
Horizontal: "horizontal" |
||||
}, |
||||
Selection: { |
||||
Default: -2, |
||||
None: -1, |
||||
Single: 0, |
||||
Multi: 1, |
||||
All: 2 |
||||
}, |
||||
HorizontalAlign: { |
||||
Left: "left", |
||||
Right: "right", |
||||
Center: "center", |
||||
Stretch: "stretch" |
||||
}, |
||||
VerticalAlign: { |
||||
Middle: "middle", |
||||
Top: "top", |
||||
Bottom: "bottom", |
||||
Stretch: "stretch" |
||||
}, |
||||
StartOfWeek: 1, |
||||
BlankSplitChar: "\u200b \u200b", |
||||
}); |
||||
} |
||||
if (pixUnit === "px") { |
||||
return pix - (border || 0) * pixRatio; |
||||
} |
||||
if (border > 0) { |
||||
return `calc(${pix / pixRatio + pixUnit} - ${`${border}px`})`; |
||||
} |
||||
|
||||
return pix; |
||||
} |
||||
|
||||
export function emptyFn() {} |
||||
|
@ -1,74 +1,76 @@
|
||||
import { registFunction } from './plugins'; |
||||
import { registFunction } from "./plugins"; |
||||
import { isWidget, isString } from "../2.base"; |
||||
|
||||
export function Element(widget, attribs) { |
||||
this.l = this.r = this.t = this.b = 0; // 边框
|
||||
this.marginLeft = this.marginRight = this.marginTop = this.marginBottom = 0; //间距
|
||||
this.position = {}; |
||||
this.classMap = {}; |
||||
this.classList = []; |
||||
this.children = []; |
||||
this.attribs = attribs || {}; |
||||
this.styles = {}; |
||||
// 兼容处理
|
||||
this['0'] = this; |
||||
this.style = {}; |
||||
if (!widget) { |
||||
this.nodeName = 'body'; |
||||
this.position.x = 0; |
||||
this.position.y = 0; |
||||
this.attribs.id = 'body'; |
||||
} else if (BI.isWidget(widget)) { |
||||
this.widget = widget; |
||||
this.nodeName = widget.options.tagName; |
||||
this.textBaseLine = widget.options.textBaseLine; |
||||
} else if (BI.isString(widget)) { |
||||
this.nodeName = widget; |
||||
} |
||||
this.l = this.r = this.t = this.b = 0; // 边框
|
||||
this.marginLeft = this.marginRight = this.marginTop = this.marginBottom = 0; // 间距
|
||||
this.position = {}; |
||||
this.classMap = {}; |
||||
this.classList = []; |
||||
this.children = []; |
||||
this.attribs = attribs || {}; |
||||
this.styles = {}; |
||||
// 兼容处理
|
||||
this["0"] = this; |
||||
this.style = {}; |
||||
if (!widget) { |
||||
this.nodeName = "body"; |
||||
this.position.x = 0; |
||||
this.position.y = 0; |
||||
this.attribs.id = "body"; |
||||
} else if (isWidget(widget)) { |
||||
this.widget = widget; |
||||
this.nodeName = widget.options.tagName; |
||||
this.textBaseLine = widget.options.textBaseLine; |
||||
} else if (isString(widget)) { |
||||
this.nodeName = widget; |
||||
} |
||||
} |
||||
|
||||
initElement(Element); |
||||
registFunction(Element); |
||||
|
||||
function initElement(element) { |
||||
element.prototype = { |
||||
appendChild(child) { |
||||
child.parent = this; |
||||
if (this.children.push(child) !== 1) { |
||||
var sibling = this.children[this.children.length - 2]; |
||||
sibling.next = child; |
||||
child.prev = sibling; |
||||
child.next = null; |
||||
} |
||||
}, |
||||
append(child) { |
||||
child.parent = this; |
||||
if (this.children.push(child) !== 1) { |
||||
var sibling = this.children[this.children.length - 2]; |
||||
sibling.next = child; |
||||
child.prev = sibling; |
||||
child.next = null; |
||||
} |
||||
}, |
||||
getParent() { |
||||
return this.parent; |
||||
}, |
||||
getSiblings() { |
||||
var parent = this.getParent(); |
||||
return parent ? parent.getChildren() : [this]; |
||||
}, |
||||
getChildren() { |
||||
return this.children; |
||||
}, |
||||
element.prototype = { |
||||
appendChild(child) { |
||||
child.parent = this; |
||||
if (this.children.push(child) !== 1) { |
||||
const sibling = this.children[this.children.length - 2]; |
||||
sibling.next = child; |
||||
child.prev = sibling; |
||||
child.next = null; |
||||
} |
||||
}, |
||||
append(child) { |
||||
child.parent = this; |
||||
if (this.children.push(child) !== 1) { |
||||
const sibling = this.children[this.children.length - 2]; |
||||
sibling.next = child; |
||||
child.prev = sibling; |
||||
child.next = null; |
||||
} |
||||
}, |
||||
getParent() { |
||||
return this.parent; |
||||
}, |
||||
getSiblings() { |
||||
const parent = this.getParent(); |
||||
|
||||
return parent ? parent.getChildren() : [this]; |
||||
}, |
||||
getChildren() { |
||||
return this.children; |
||||
}, |
||||
|
||||
getBounds() { |
||||
return {}; |
||||
}, |
||||
getBounds() { |
||||
return {}; |
||||
}, |
||||
|
||||
width() { |
||||
width() { |
||||
|
||||
}, |
||||
height() { |
||||
}, |
||||
height() { |
||||
|
||||
} |
||||
}; |
||||
}, |
||||
}; |
||||
} |
||||
|
@ -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); |
||||
}); |
||||
return this; |
||||
} |
||||
if (BI.isNull(value)) { |
||||
return this.attribs[key]; |
||||
} |
||||
this.attribs[key] = value; |
||||
return this; |
||||
}); |
||||
Element.registerFunction('hasAttrib', function (key) { |
||||
return this.attribs[key] != null; |
||||
}); |
||||
Element.registerFunction('removeAttr', function (key) { |
||||
delete this.attribs[key]; |
||||
}); |
||||
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 (isNull(value)) { |
||||
return this.attribs[key]; |
||||
} |
||||
this.attribs[key] = value; |
||||
|
||||
return this; |
||||
}); |
||||
Element.registerFunction("hasAttrib", function (key) { |
||||
return isNotNull(this.attribs[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); |
||||
} |
||||
cls && (self.classMap[cls] = true); |
||||
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 && (this.classMap[cls] = true); |
||||
}); |
||||
|
||||
return this; |
||||
}); |
||||
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; |
||||
}); |
||||
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); |
||||
}); |
||||
return this; |
||||
} |
||||
key = BI.trim(BI.camelize(key)); |
||||
return css(this, key, value); |
||||
}); |
||||
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 = trim(camelize(key)); |
||||
|
||||
return css(this, key, value); |
||||
}); |
||||
}; |
||||
|
||||
const css = (elem, key, value) => { |
||||
key = BI.trim(BI.camelize(key)); |
||||
if (BI.isNull(value)) { |
||||
return elem.styles[key]; |
||||
} |
||||
elem.styles[key] = value; |
||||
return elem; |
||||
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) { |
||||
if (!this._data) { |
||||
this._data = {}; |
||||
} |
||||
if (BI.isNull(value)) { |
||||
return this._data[key]; |
||||
} |
||||
this._data[key] = value; |
||||
return this; |
||||
}); |
||||
import { isNull } from "../../2.base"; |
||||
|
||||
export const registDataFun = Element => { |
||||
Element.registerFunction("data", function (key, value) { |
||||
if (!this._data) { |
||||
this._data = {}; |
||||
} |
||||
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) { |
||||
this.children = []; |
||||
return this; |
||||
}); |
||||
Element.registerFunction('destroy', function (text) { |
||||
return this; |
||||
}); |
||||
export const registEmptyFun = Element => { |
||||
Element.registerFunction("empty", function (text) { |
||||
this.children = []; |
||||
|
||||
return this; |
||||
}); |
||||
Element.registerFunction("destroy", function (text) { |
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,32 +1,33 @@
|
||||
var returnThis = function () { |
||||
return this; |
||||
}; |
||||
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) => { |
||||
Element.registerFunction(event, returnThis); |
||||
}); |
||||
function returnThis () { |
||||
return this; |
||||
} |
||||
|
||||
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 => { |
||||
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', |
||||
element: this.widget, |
||||
html: text, |
||||
}); |
||||
this.originalHtml = text; |
||||
} else { |
||||
this.text = BI.htmlDecode(text); |
||||
} |
||||
return this; |
||||
}); |
||||
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 = htmlDecode(text); |
||||
} |
||||
|
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,31 +1,31 @@
|
||||
import { registAttrFun } from './attr'; |
||||
import { registClassFun } from './class'; |
||||
import { registCssFun } from './css'; |
||||
import { registDataFun } from './data'; |
||||
import { registEmptyFun } from './empty'; |
||||
import { registEventFun } from './event'; |
||||
import { registHtmlFun } from './html'; |
||||
import { registKeywordMarkFun } from './keywordMark'; |
||||
import { registRenderToHtmlFun } from './renderToHtml'; |
||||
import { registRenderToStringFun } from './renderToString'; |
||||
import { registTextFun } from './text'; |
||||
import { registValFun } from './val'; |
||||
import { registAttrFun } from "./attr"; |
||||
import { registClassFun } from "./class"; |
||||
import { registCssFun } from "./css"; |
||||
import { registDataFun } from "./data"; |
||||
import { registEmptyFun } from "./empty"; |
||||
import { registEventFun } from "./event"; |
||||
import { registHtmlFun } from "./html"; |
||||
import { registKeywordMarkFun } from "./keywordMark"; |
||||
import { registRenderToHtmlFun } from "./renderToHtml"; |
||||
import { registRenderToStringFun } from "./renderToString"; |
||||
import { registTextFun } from "./text"; |
||||
import { registValFun } from "./val"; |
||||
|
||||
export const registFunction = (Element) => { |
||||
var functionMap = {}; |
||||
Element.registerFunction = (key, fn) => { |
||||
Element.prototype[key] = functionMap[key] = fn; |
||||
}; |
||||
registAttrFun(Element); |
||||
registClassFun(Element); |
||||
registCssFun(Element); |
||||
registDataFun(Element); |
||||
registEmptyFun(Element); |
||||
registEventFun(Element); |
||||
registHtmlFun(Element); |
||||
registKeywordMarkFun(Element); |
||||
registRenderToStringFun(Element); |
||||
registRenderToHtmlFun(Element); |
||||
registTextFun(Element); |
||||
registValFun(Element); |
||||
export const registFunction = Element => { |
||||
const functionMap = {}; |
||||
Element.registerFunction = (key, fn) => { |
||||
Element.prototype[key] = functionMap[key] = fn; |
||||
}; |
||||
registAttrFun(Element); |
||||
registClassFun(Element); |
||||
registCssFun(Element); |
||||
registDataFun(Element); |
||||
registEmptyFun(Element); |
||||
registEventFun(Element); |
||||
registHtmlFun(Element); |
||||
registKeywordMarkFun(Element); |
||||
registRenderToStringFun(Element); |
||||
registRenderToHtmlFun(Element); |
||||
registTextFun(Element); |
||||
registValFun(Element); |
||||
}; |
||||
|
@ -1,6 +1,7 @@
|
||||
export const registKeywordMarkFun = (Element) => { |
||||
Element.registerFunction('__textKeywordMarked__', function (text) { |
||||
this[0].textContent = text; |
||||
return this; |
||||
}); |
||||
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') { |
||||
str += `<${root.tag}`; |
||||
if (root.classList.length > 0) { |
||||
str += ' class="'; |
||||
BI.each(root.classList, (i, cls) => { |
||||
str += ` ${cls}`; |
||||
}); |
||||
str += '"'; |
||||
} |
||||
str += ' style="'; |
||||
BI.each(root.originalStyles, (key, stl) => { |
||||
if ( |
||||
skipArray.contains(key) || |
||||
(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, ''); |
||||
} |
||||
if (pxStyle.contains(key) && BI.isNumeric(stl)) { |
||||
stl += 'px'; |
||||
} |
||||
if (BI.isKey(stl)) { |
||||
str += ` ${key}:${stl};`; |
||||
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=\""; |
||||
each(root.classList, (i, cls) => { |
||||
str += ` ${cls}`; |
||||
}); |
||||
str += "\""; |
||||
} |
||||
str += " style=\""; |
||||
each(root.originalStyles, (key, stl) => { |
||||
if ( |
||||
skipArray.contains(key) || |
||||
(key === "height" && root.classList.contains("bi-design-components-data-data-table-cell")) |
||||
) { |
||||
return; |
||||
} |
||||
key = hyphenate(key); |
||||
if (key === "font-family") { |
||||
stl = stl.replace(/"/g, ""); |
||||
} |
||||
if (pxStyle.contains(key) && isNumeric(stl)) { |
||||
stl += "px"; |
||||
} |
||||
if (isKey(stl)) { |
||||
str += ` ${key}:${stl};`; |
||||
} |
||||
}); |
||||
str += "\""; |
||||
each(root.attribs, (key, attr) => { |
||||
if (isKey(attr)) { |
||||
str += ` ${key}=${attr}`; |
||||
} |
||||
}); |
||||
if (root.textContent) { |
||||
str += ` title=${root.textContent}`; |
||||
} |
||||
str += ">"; |
||||
} |
||||
}); |
||||
str += '"'; |
||||
BI.each(root.attribs, (key, attr) => { |
||||
if (BI.isKey(attr)) { |
||||
str += ` ${key}=${attr}`; |
||||
// 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了
|
||||
// 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样
|
||||
each(root.children, (i, child) => { |
||||
str += _renderToHtml(child); |
||||
}); |
||||
} else { |
||||
str += root.originalHtml; |
||||
} |
||||
if (root.tag !== "body") { |
||||
if (root.textContent) { |
||||
str += root.textContent; |
||||
} |
||||
}); |
||||
if (root.textContent) { |
||||
str += ` title=${root.textContent}`; |
||||
} |
||||
str += '>'; |
||||
str += `</${root.tag}>`; |
||||
} |
||||
// 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了
|
||||
// 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样
|
||||
BI.each(root.children, (i, child) => { |
||||
str += _renderToHtml(child); |
||||
|
||||
return str; |
||||
} |
||||
|
||||
export const registRenderToHtmlFun = Element => { |
||||
Element.registerFunction("renderToHtml", function () { |
||||
return _renderToHtml(this); |
||||
}); |
||||
} else { |
||||
str += root.originalHtml; |
||||
} |
||||
if (root.tag !== 'body') { |
||||
if (root.textContent) { |
||||
str += root.textContent; |
||||
} |
||||
str += `</${root.tag}>`; |
||||
} |
||||
return str; |
||||
}; |
||||
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') { |
||||
str += `<${root.nodeName}`; |
||||
if (root.classList.length > 0) { |
||||
str += ' class="'; |
||||
BI.each(root.classList, (i, cls) => { |
||||
str += ` ${cls}`; |
||||
}); |
||||
str += '"'; |
||||
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=\""; |
||||
each(root.classList, (i, cls) => { |
||||
str += ` ${cls}`; |
||||
}); |
||||
str += "\""; |
||||
} |
||||
str += " style=\""; |
||||
each(root.styles, (key, stl) => { |
||||
if (skipArray.includes(key)) { |
||||
return; |
||||
} |
||||
key = hyphenate(key); |
||||
str += ` ${key}:${stl};`; |
||||
}); |
||||
str += ` width:${root.width}px;`; |
||||
str += ` height:${root.height}px;`; |
||||
str += " position: fixed;"; |
||||
str += ` left: ${root.position.x}px;`; |
||||
str += ` top: ${root.position.y}px;`; |
||||
str += "\""; |
||||
each(root.attribs, (key, attr) => { |
||||
str += ` ${key}:${attr}`; |
||||
}); |
||||
str += ">"; |
||||
} |
||||
str += ' style="'; |
||||
BI.each(root.styles, (key, stl) => { |
||||
if (skipArray.includes(key)) { |
||||
return; |
||||
} |
||||
key = BI.hyphenate(key); |
||||
str += ` ${key}:${stl};`; |
||||
each(root.children, (i, child) => { |
||||
str += _renderToString(child); |
||||
}); |
||||
str += ` width:${root.width}px;`; |
||||
str += ` height:${root.height}px;`; |
||||
str += ' position: fixed;'; |
||||
str += ` left: ${root.position.x}px;`; |
||||
str += ` top: ${root.position.y}px;`; |
||||
str += '"'; |
||||
BI.each(root.attribs, (key, attr) => { |
||||
str += ` ${key}:${attr}`; |
||||
}); |
||||
str += '>'; |
||||
} |
||||
BI.each(root.children, (i, child) => { |
||||
str += _renderToString(child); |
||||
}); |
||||
// if (root.htmlContent) {
|
||||
// str += root.htmlContent;
|
||||
// }
|
||||
if (root.nodeName !== 'body') { |
||||
if (root.text) { |
||||
str += root.text; |
||||
// if (root.htmlContent) {
|
||||
// str += root.htmlContent;
|
||||
// }
|
||||
if (root.nodeName !== "body") { |
||||
if (root.text) { |
||||
str += root.text; |
||||
} |
||||
str += `</${root.nodeName}>`; |
||||
} |
||||
str += `</${root.nodeName}>`; |
||||
} |
||||
return str; |
||||
}; |
||||
export const registRenderToStringFun = (Element) => { |
||||
Element.registerFunction('renderToString', function () { |
||||
return _renderToString(this); |
||||
}); |
||||
|
||||
return str; |
||||
} |
||||
|
||||
export const registRenderToStringFun = Element => { |
||||
Element.registerFunction("renderToString", function () { |
||||
return _renderToString(this); |
||||
}); |
||||
}; |
||||
|
@ -1,10 +1,12 @@
|
||||
export const registTextFun = (Element) => { |
||||
Element.registerFunction('setText', function (text) { |
||||
this.text = text; |
||||
return this; |
||||
}); |
||||
Element.registerFunction('setValue', function (text) { |
||||
this.text = text; |
||||
return this; |
||||
}); |
||||
export const registTextFun = Element => { |
||||
Element.registerFunction("setText", function (text) { |
||||
this.text = text; |
||||
|
||||
return this; |
||||
}); |
||||
Element.registerFunction("setValue", function (text) { |
||||
this.text = text; |
||||
|
||||
return this; |
||||
}); |
||||
}; |
||||
|
@ -1,9 +1,11 @@
|
||||
export const registValFun = (Element) => { |
||||
Element.registerFunction('val', function (value) { |
||||
if (BI.isNotNull(value)) { |
||||
this.text = `${value}`; |
||||
return this; |
||||
} |
||||
return this.text; |
||||
}); |
||||
export const registValFun = Element => { |
||||
Element.registerFunction("val", function (value) { |
||||
if (BI.isNotNull(value)) { |
||||
this.text = `${value}`; |
||||
|
||||
return this; |
||||
} |
||||
|
||||
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(); |
||||
}, |
||||
import { OB } from "../3.ob"; |
||||
|
||||
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; |
||||
} |
||||
}, |
||||
|
||||
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