From 7ae79f12e34d873a2f4c058cf2fe3d880c8eb2a0 Mon Sep 17 00:00:00 2001 From: "Zhenfei.Li" Date: Thu, 5 Jan 2023 15:19:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?KERNEL-14001=20refactor:=20plguin=E3=80=81s?= =?UTF-8?q?ystem=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/0.foundation.js | 9 +- src/core/6.plugin.js | 204 +++++++++++++++++----------------- src/core/decorator.js | 14 ++- src/core/h.js | 49 +++++---- src/core/index.js | 17 ++- src/core/system.js | 232 ++++++++++++++++++++------------------- src/core/version.js | 2 +- src/core/worker.js | 101 ++++++++--------- 8 files changed, 330 insertions(+), 298 deletions(-) diff --git a/src/core/0.foundation.js b/src/core/0.foundation.js index ea69e97a9..96c6e59ba 100644 --- a/src/core/0.foundation.js +++ b/src/core/0.foundation.js @@ -1,10 +1,11 @@ +/* eslint-disable eqeqeq */ /** * Created by richie on 15/7/8. */ /** * 初始化BI对象 */ -var _global = undefined; +let _global = undefined; if (typeof window !== "undefined") { _global = window; } else if (typeof global !== "undefined") { @@ -20,8 +21,8 @@ if (_global) { } if (_global.BI == null) { - _global.BI = {prepares: []}; + _global.BI = { prepares: [] }; } -if(_global.BI.prepares == null) { +if (_global.BI.prepares == null) { _global.BI.prepares = []; -} \ No newline at end of file +} diff --git a/src/core/6.plugin.js b/src/core/6.plugin.js index bbfd5e5ac..e0561b4fd 100644 --- a/src/core/6.plugin.js +++ b/src/core/6.plugin.js @@ -1,123 +1,127 @@ -BI.Plugin = BI.Plugin || {}; -!(function () { - var _WidgetsPlugin = {}; - var _ObjectPlugin = {}; - var _ConfigPlugin = {}; - var _ConfigRenderPlugin = {}; - var _GlobalWidgetConfigFns = []; - var __GlobalObjectConfigFns = []; - BI.defaults(BI.Plugin, { +const _WidgetsPlugin = {}; +const _ObjectPlugin = {}; +const _ConfigPlugin = {}; +const _ConfigRenderPlugin = {}; +let _GlobalWidgetConfigFns = []; +let __GlobalObjectConfigFns = []; - getWidget: function (type, options) { - if (_GlobalWidgetConfigFns.length > 0) { - var fns = _GlobalWidgetConfigFns.slice(0); - for (var i = fns.length - 1; i >= 0; i--) { - fns[i](type, options); - } +export const Plugin = { + getWidget (type, options) { + if (_GlobalWidgetConfigFns.length > 0) { + const fns = _GlobalWidgetConfigFns.slice(0); + for (let i = fns.length - 1; i >= 0; i--) { + fns[i](type, options); } + } - var res; - if (_ConfigPlugin[type]) { - for (var i = _ConfigPlugin[type].length - 1; i >= 0; i--) { - if (res = _ConfigPlugin[type][i](options)) { - options = res; - } + let res; + if (_ConfigPlugin[type]) { + for (let i = _ConfigPlugin[type].length - 1; i >= 0; i--) { + res = _ConfigPlugin[type][i](options); + if (res) { + options = res; } } - // Deprecated - if (_WidgetsPlugin[type]) { - for (var i = _WidgetsPlugin[type].length - 1; i >= 0; i--) { - if (res = _WidgetsPlugin[type][i](options)) { - return res; - } + } + // Deprecated + if (_WidgetsPlugin[type]) { + for (let i = _WidgetsPlugin[type].length - 1; i >= 0; i--) { + res = _WidgetsPlugin[type][i](options); + if (res) { + return res; } } - return options; - }, + } + + return options; + }, - config: function (widgetConfigFn, objectConfigFn) { - _GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(BI._.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]); - __GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(BI._.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]); - }, + config (widgetConfigFn, objectConfigFn) { + _GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(BI._.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]); + __GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(BI._.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]); + }, - configWidget: function (type, fn, opt) { - // opt.single: true 最后一次注册有效 - if (!_ConfigPlugin[type] || (opt && opt.single)) { - _ConfigPlugin[type] = []; - } - _ConfigPlugin[type].push(fn); - }, + configWidget (type, fn, opt) { + // opt.single: true 最后一次注册有效 + if (!_ConfigPlugin[type] || (opt && opt.single)) { + _ConfigPlugin[type] = []; + } + _ConfigPlugin[type].push(fn); + }, - getRender: function (type, rendered) { - var res; - if (_ConfigRenderPlugin[type]) { - for (var i = _ConfigRenderPlugin[type].length - 1; i >= 0; i--) { - if (res = _ConfigRenderPlugin[type][i](rendered)) { - rendered = res; - } + getRender (type, rendered) { + let res; + if (_ConfigRenderPlugin[type]) { + for (let i = _ConfigRenderPlugin[type].length - 1; i >= 0; i--) { + res = _ConfigRenderPlugin[type][i](rendered); + if (res) { + rendered = res; } } - return rendered; - }, + } + + return rendered; + }, - configRender: function (type, fn) { - if (!_ConfigRenderPlugin[type]) { - _ConfigRenderPlugin[type] = []; - } - _ConfigRenderPlugin[type].push(fn); - }, + configRender (type, fn) { + if (!_ConfigRenderPlugin[type]) { + _ConfigRenderPlugin[type] = []; + } + _ConfigRenderPlugin[type].push(fn); + }, - // Deprecated - registerWidget: function (type, fn) { - if (!_WidgetsPlugin[type]) { - _WidgetsPlugin[type] = []; - } - if (_WidgetsPlugin[type].length > 0) { - console.log("组件已经注册过了!"); - } - _WidgetsPlugin[type].push(fn); - }, + // Deprecated + registerWidget (type, fn) { + if (!_WidgetsPlugin[type]) { + _WidgetsPlugin[type] = []; + } + if (_WidgetsPlugin[type].length > 0) { + console.log("组件已经注册过了!"); + } + _WidgetsPlugin[type].push(fn); + }, - // Deprecated - relieveWidget: function (type) { - delete _WidgetsPlugin[type]; - }, + // Deprecated + relieveWidget (type) { + delete _WidgetsPlugin[type]; + }, - getObject: function (type, object) { - if (__GlobalObjectConfigFns.length > 0) { - var fns = __GlobalObjectConfigFns.slice(0); - for (var i = fns.length - 1; i >= 0; i--) { - fns[i](type, object); - } + getObject (type, object) { + if (__GlobalObjectConfigFns.length > 0) { + const fns = __GlobalObjectConfigFns.slice(0); + for (let i = fns.length - 1; i >= 0; i--) { + fns[i](type, object); } + } - if (_ObjectPlugin[type]) { - var res; - for (var i = 0, len = _ObjectPlugin[type].length; i < len; i++) { - if (res = _ObjectPlugin[type][i](object)) { - object = res; - } + let res; + if (_ObjectPlugin[type]) { + for (let i = 0, len = _ObjectPlugin[type].length; i < len; i++) { + res = _ObjectPlugin[type][i](object); + if (res) { + object = res; } } - return res || object; - }, - - hasObject: function (type) { - return __GlobalObjectConfigFns.length > 0 || !!_ObjectPlugin[type]; - }, + } + + return res || object; + }, - registerObject: function (type, fn) { - if (!_ObjectPlugin[type]) { - _ObjectPlugin[type] = []; - } - if (_ObjectPlugin[type].length > 0) { - console.log("对象已经注册过了!"); - } - _ObjectPlugin[type].push(fn); - }, + hasObject (type) { + return __GlobalObjectConfigFns.length > 0 || !!_ObjectPlugin[type]; + }, - relieveObject: function (type) { - delete _ObjectPlugin[type]; + registerObject (type, fn) { + if (!_ObjectPlugin[type]) { + _ObjectPlugin[type] = []; + } + if (_ObjectPlugin[type].length > 0) { + console.log("对象已经注册过了!"); } - }); -})(); + _ObjectPlugin[type].push(fn); + }, + + relieveObject (type) { + delete _ObjectPlugin[type]; + }, +}; diff --git a/src/core/decorator.js b/src/core/decorator.js index af7a6e005..0e5d5e097 100644 --- a/src/core/decorator.js +++ b/src/core/decorator.js @@ -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); + }; +} diff --git a/src/core/h.js b/src/core/h.js index b768b1415..c413788c2 100644 --- a/src/core/h.js +++ b/src/core/h.js @@ -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); -}; +} diff --git a/src/core/index.js b/src/core/index.js index b7cf86b47..37c581af2 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,16 +2,18 @@ import * as base from "./2.base"; import * as ob from "./3.ob"; import * as widget from "./4.widget"; import * as inject from "./5.inject"; +import { Plugin } from "./6.plugin"; +import * as h from "./h"; import * as action from "./action"; import * as behavior from "./behavior"; import * as controllers from "./controller"; import * as func from "./func"; import * as structure from "./structure"; -import {StyleLoaderManager} from "./loader/loader.style"; -import "./h"; -import {ShowListener} from "./listener/listener.show"; -import {shortcut} from "./decorator"; +import { StyleLoaderManager } from "./loader/loader.style"; +import { ShowListener } from "./listener/listener.show"; +import { useInWorker } from "./worker"; +export * from "./decorator"; export * from "./2.base"; export * from "./3.ob"; export * from "./4.widget"; @@ -21,6 +23,7 @@ export * from "./behavior"; export * from "./controller"; export * from "./func"; export * from "./structure"; +export * from "./h"; // 有了后删掉 export const emptyFn = () => { }; @@ -28,7 +31,8 @@ export const emptyFn = () => { }; export { StyleLoaderManager, ShowListener, - shortcut + Plugin, + useInWorker }; Object.assign(BI, { @@ -36,6 +40,7 @@ Object.assign(BI, { ...ob, ...widget, ...inject, + Plugin, ...behavior, component: inject.shortcut, ...action, @@ -44,4 +49,6 @@ Object.assign(BI, { StyleLoaderManager, ShowListener, ...structure, + useInWorker, + ...h, }); diff --git a/src/core/system.js b/src/core/system.js index 545057e49..93be82dc4 100644 --- a/src/core/system.js +++ b/src/core/system.js @@ -3,142 +3,146 @@ * @version 2.0 * Created by windy on 2021/6/30 */ +import { deepExtend, extend, inherit } from "./2.base"; +import { OB } from "./3.ob"; +import { Providers } from "./5.inject"; +import { provider } from "./decorator"; + // 系统参数常量 -!(function () { - var system = { - dependencies: {}, - layoutOptimize: false, - responsiveMode: false, - workerMode: false, - size: { - // 尺寸 - // 通用尺寸 - TOOL_BAR_HEIGHT: 24, - LIST_ITEM_HEIGHT: 24, - TRIGGER_HEIGHT: 24, - TOAST_TOP: 10, - H_GAP_SIZE: "M", - V_GAP_SIZE: "S" - }, - loadingCreator: function(config) { - var loadingSize = (config ? config.loadingSize : "small") || "small"; - - var isIE = BI.isIE(); - - function getSize(v) { - return Math.ceil(v / (loadingSize === "small" ? 2 : 1)); - } - - return { - type: "bi.horizontal", - cls: "bi-loading-widget" + (isIE ? " wave-loading hack" : ""), - height: getSize(60), - width: getSize(60), - hgap: getSize(10), - vgap: 2.5, - items: isIE ? [] : [{ - type: "bi.layout", - cls: "animate-rect rect1", - height: getSize(50), - width: getSize(5) - }, { - type: "bi.layout", - cls: "animate-rect rect2", - height: getSize(50), - width: getSize(5) - }, { - type: "bi.layout", - cls: "animate-rect rect3", - height: getSize(50), - width: getSize(5) - }] - }; +const system = { + dependencies: {}, + layoutOptimize: false, + responsiveMode: false, + workerMode: false, + size: { + // 尺寸 + // 通用尺寸 + TOOL_BAR_HEIGHT: 24, + LIST_ITEM_HEIGHT: 24, + TRIGGER_HEIGHT: 24, + TOAST_TOP: 10, + H_GAP_SIZE: "M", + V_GAP_SIZE: "S", + }, + loadingCreator(config) { + const loadingSize = (config ? config.loadingSize : "small") || "small"; + + const isIE = BI.isIE(); + + function getSize(v) { + return Math.ceil(v / (loadingSize === "small" ? 2 : 1)); } - }; - // 具体尺寸还没定,先写着 - var sizeMap = { - "S": 10, - "M": 20, - "L": 24 - }; + return { + type: "bi.horizontal", + cls: `bi-loading-widget${isIE ? " wave-loading hack" : ""}`, + height: getSize(60), + width: getSize(60), + hgap: getSize(10), + vgap: 2.5, + items: isIE ? [] : [{ + type: "bi.layout", + cls: "animate-rect rect1", + height: getSize(50), + width: getSize(5), + }, { + type: "bi.layout", + cls: "animate-rect rect2", + height: getSize(50), + width: getSize(5), + }, { + type: "bi.layout", + cls: "animate-rect rect3", + height: getSize(50), + width: getSize(5), + }], + }; + }, +}; - function provider () { - this.SYSTEM = system; +// 具体尺寸还没定,先写着 +const sizeMap = { + S: 10, + M: 20, + L: 24, +}; - this.setSize = function (opt) { - BI.deepExtend(system, { size: opt }); - }; +@provider() +export class SystemProvider { + static xtype = "bi.provider.system"; - this.setResponsiveMode = function (mode) { - system.responsiveMode = !!mode; - }; + SYSTEM = system; - this.setWorkerMode = function (mode) { - system.workerMode = !!mode; - }; + setSize(opt) { + deepExtend(system, { size: opt }); + } - this.setLayoutOptimize = function (layoutOptimize) { - system.layoutOptimize = layoutOptimize; - }; + setResponsiveMode(mode) { + system.responsiveMode = !!mode; + } - this.addDependency = function (moduleId, minVersion, maxVersion) { - system.dependencies[moduleId] = { - min: minVersion, - max: maxVersion - }; - }; + setWorkerMode(mode) { + system.workerMode = !!mode; + } - this.addDependencies = function (moduleConfig) { - BI.extend(system.dependencies, moduleConfig); - }; + setLayoutOptimize(layoutOptimize) { + system.layoutOptimize = layoutOptimize; + } - this.setLoadingCreator = function(creator) { - system.loadingCreator = creator; + addDependency(moduleId, minVersion, maxVersion) { + system.dependencies[moduleId] = { + min: minVersion, + max: maxVersion, }; + } + + addDependencies(moduleConfig) { + extend(system.dependencies, moduleConfig); + } - this.$get = function () { - return BI.inherit(BI.OB, { + setLoadingCreator = function(creator) { + system.loadingCreator = creator; + }; - getSize: function () { - var size = system.size; - var H_GAP_SIZE = sizeMap[size.H_GAP_SIZE]; - var V_GAP_SIZE = sizeMap[size.V_GAP_SIZE]; + $get() { + return inherit(OB, { - return BI.extend({}, size, { - H_GAP_SIZE: H_GAP_SIZE, - V_GAP_SIZE: V_GAP_SIZE - }); - }, + getSize () { + const size = system.size; + const H_GAP_SIZE = sizeMap[size.H_GAP_SIZE]; + const V_GAP_SIZE = sizeMap[size.V_GAP_SIZE]; - getResponsiveMode: function () { - return system.responsiveMode; - }, + return extend({}, size, { + H_GAP_SIZE, + V_GAP_SIZE, + }); + }, - getWorkerMode: function () { - return system.workerMode; - }, + getResponsiveMode () { + return system.responsiveMode; + }, - getLayoutOptimize: function () { - return system.layoutOptimize; - }, + getWorkerMode () { + return system.workerMode; + }, - getDependencies: function () { - return system.dependencies; - }, + getLayoutOptimize () { + return system.layoutOptimize; + }, - getLoading: function(config) { - return system.loadingCreator(config); - } - }); - }; - } + getDependencies () { + return system.dependencies; + }, - BI.provider("bi.provider.system", provider); -}()); + getLoading(config) { + return system.loadingCreator(config); + }, + }); + } +} -BI.prepares.push(function () { - BI.SIZE_CONSANTS = BI.Providers.getProvider("bi.provider.system").getSize(); +BI.prepares.push(() => { + BI.SIZE_CONSANTS = Providers.getProvider("bi.provider.system").getSize(); // 不再增加线型的配置了,之后不维护前置版本直接删掉,都用实线连接线 BI.STYLE_CONSTANTS = {}; BI.STYLE_CONSTANTS.LINK_LINE_TYPE = BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT === 24 ? "dashed" : "solid"; diff --git a/src/core/version.js b/src/core/version.js index a850da743..88665e6e3 100644 --- a/src/core/version.js +++ b/src/core/version.js @@ -1 +1 @@ -BI.version = "2.0"; \ No newline at end of file +BI.version = "2.0"; diff --git a/src/core/worker.js b/src/core/worker.js index d3ba08ee4..643e77e1a 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -1,51 +1,54 @@ -!(function () { - BI.useInWorker = function () { - function createWatcher (model, keyOrFn, cb, options) { - if (BI.isPlainObject(cb)) { - options = cb; - cb = cb.handler; - } - options = options || {}; - return Fix.watch(model, keyOrFn, cb, BI.extend(options, { - store: model - })); +import { isPlainObject, extend, each, isArray } from "./2.base"; +import { Models } from "./5.inject"; + +export function useInWorker () { + function createWatcher (model, keyOrFn, cb, options) { + if (isPlainObject(cb)) { + options = cb; + cb = cb.handler; } + options = options || {}; + + return Fix.watch(model, keyOrFn, cb, extend(options, { + store: model, + })); + } - var models = {}, watches = {}; - addEventListener("message", function (e) { - var data = e.data; - switch (data.eventType) { - case "action": - models[data.name][data.action].apply(models[data.name], data.args); - break; - case "destroy": - BI.each(watches[data.name], function (i, unwatches) { - unwatches = BI.isArray(unwatches) ? unwatches : [unwatches]; - BI.each(unwatches, function (j, unwatch) { - unwatch(); - }); - }); - delete models[data.name]; - delete watches[data.name]; - break; - case "create": - var store = models[data.name] = BI.Models.getModel(data.type, data.options); - watches[data.name] = []; - BI.each(data.watches, function (i, key) { - watches[data.name].push(createWatcher(store.model, key, function (newValue, oldValue) { - postMessage(BI.extend({}, data, { - eventType: "watch", - currentWatchType: key - }, {args: [newValue, oldValue]})); - })); - }); - postMessage(BI.extend({}, data, { - eventType: "create" - }, {msg: store.model})); - break; - default: - break; - } - }, false); - }; -}()); + const models = {}, watches = {}; + addEventListener("message", e => { + const data = e.data; + let store; + switch (data.eventType) { + case "action": + models[data.name][data.action](...data.args); + break; + case "destroy": + each(watches[data.name], (i, unwatches) => { + unwatches = isArray(unwatches) ? unwatches : [unwatches]; + each(unwatches, (j, unwatch) => { + unwatch(); + }); + }); + delete models[data.name]; + delete watches[data.name]; + break; + case "create": + store = models[data.name] = Models.getModel(data.type, data.options); + watches[data.name] = []; + each(data.watches, (i, key) => { + watches[data.name].push(createWatcher(store.model, key, (newValue, oldValue) => { + postMessage(extend({}, data, { + eventType: "watch", + currentWatchType: key, + }, { args: [newValue, oldValue] })); + })); + }); + postMessage(extend({}, data, { + eventType: "create", + }, { msg: store.model })); + break; + default: + break; + } + }, false); +} From a18cd23e1c19bfd6452242437472cc8f85e75b3a Mon Sep 17 00:00:00 2001 From: Treecat Date: Fri, 6 Jan 2023 11:12:42 +0800 Subject: [PATCH 2/4] =?UTF-8?q?case/button=E6=96=87=E4=BB=B6=E5=A4=B9=20es?= =?UTF-8?q?6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/button/button.basic.js | 211 +++++++++--------- src/base/single/button/button.node.js | 9 +- .../single/button/buttons/button.image.js | 3 +- src/base/single/button/buttons/button.js | 25 +-- src/base/single/button/buttons/button.text.js | 11 +- src/base/single/button/index.js | 2 +- .../button/listitem/blankiconicontextitem.js | 23 +- .../button/listitem/blankicontexticonitem.js | 21 +- .../button/listitem/blankicontextitem.js | 21 +- .../button/listitem/icontexticonitem.js | 21 +- .../single/button/listitem/icontextitem.js | 21 +- .../single/button/listitem/texticonitem.js | 21 +- src/base/single/button/listitem/textitem.js | 19 +- .../single/button/node/icontexticonnode.js | 17 +- src/base/single/button/node/icontextnode.js | 17 +- src/base/single/button/node/texticonnode.js | 17 +- src/base/single/button/node/textnode.js | 15 +- src/case/button/icon/icon.change.js | 68 +++--- src/case/button/icon/icon.trigger.js | 29 ++- .../button/icon/iconhalf/icon.half.image.js | 23 +- src/case/button/icon/iconhalf/icon.half.js | 36 +-- src/case/button/index.js | 29 +++ src/case/button/item.multiselect.js | 64 +++--- src/case/button/item.singleselect.icontext.js | 60 ++--- src/case/button/item.singleselect.js | 65 +++--- src/case/button/item.singleselect.radio.js | 69 +++--- src/case/button/node/node.arrow.js | 71 +++--- src/case/button/node/node.first.plus.js | 82 ++++--- src/case/button/node/node.icon.arrow.js | 99 ++++---- src/case/button/node/node.last.plus.js | 93 ++++---- src/case/button/node/node.mid.plus.js | 85 +++---- .../button/node/node.multilayer.icon.arrow.js | 88 ++++---- src/case/button/node/node.plus.js | 79 ++++--- src/case/button/node/siwtcher.tree.node.js | 45 ++-- src/case/button/node/treenode.js | 79 ++++--- src/case/button/switch.js | 119 +++++----- .../button/treeitem/item.first.treeleaf.js | 108 ++++----- .../button/treeitem/item.icon.treeleaf.js | 86 +++---- .../button/treeitem/item.last.treeleaf.js | 110 ++++----- src/case/button/treeitem/item.mid.treeleaf.js | 110 ++++----- .../treeitem/item.multilayer.icon.treeleaf.js | 94 ++++---- .../button/treeitem/item.root.treeleaf.js | 78 ++++--- src/case/button/treeitem/item.treetextleaf.js | 68 +++--- src/case/button/treeitem/treeitem.js | 64 +++--- src/case/index.js | 7 + 45 files changed, 1330 insertions(+), 1152 deletions(-) create mode 100644 src/case/button/index.js create mode 100644 src/case/index.js diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 9375ec638..f2f09216c 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -1,5 +1,5 @@ -import { Single } from "../0.single" -import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject, Controller } from "../../../core" +import { Single } from "../0.single"; +import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject, Controller } from "../../../core"; /** * guy @@ -10,7 +10,6 @@ import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject, */ @shortcut() export class BasicButton extends Single { - static xtype = "bi.basic_button"; static EVENT_CHANGE = "BasicButton.EVENT_CHANGE"; @@ -19,7 +18,7 @@ export class BasicButton extends Single { const conf = super._defaultConfig(arguments); return extend(conf, { - _baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), + _baseCls: `${conf._baseCls || ""} bi-basic-button${conf.invalid ? "" : " cursor-pointer"}${(BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""}`, // el: {} // 可以通过el来创建button元素 value: "", stopEvent: false, @@ -35,7 +34,7 @@ export class BasicButton extends Single { trigger: null, handler: emptyFn, bubble: null, - debounce: true + debounce: true, }); } @@ -50,7 +49,7 @@ export class BasicButton extends Single { this._createShadow(); } if (opts.level) { - this.element.addClass("button-" + opts.level); + this.element.addClass(`button-${opts.level}`); } } @@ -92,7 +91,7 @@ export class BasicButton extends Single { }], }); } - } + }; this.element.mouseup(() => { if (!this._hover && !o.isShadowShowingOnSelected) { @@ -100,7 +99,7 @@ export class BasicButton extends Single { this.$mask.invisible(); } }); - this.element.on("mouseenter." + this.getName(), (e) => { + this.element.on(`mouseenter.${this.getName()}`, e => { if (this.element.__isMouseInBounds__(e)) { if (this.isEnabled() && !this._hover && (o.isShadowShowingOnSelected || !this.isSelected())) { assertMask(); @@ -108,7 +107,7 @@ export class BasicButton extends Single { } } }); - this.element.on("mousemove." + this.getName(), (e) => { + this.element.on(`mousemove.${this.getName()}`, e => { if (!this.element.__isMouseInBounds__(e)) { if (this.isEnabled() && !this._hover) { assertMask(); @@ -116,7 +115,7 @@ export class BasicButton extends Single { } } }); - this.element.on("mouseleave." + this.getName(), () => { + this.element.on(`mouseleave.${this.getName()}`, () => { if (this.isEnabled() && !this._hover) { assertMask(); this.$mask.invisible(); @@ -139,9 +138,9 @@ export class BasicButton extends Single { } return bubble; - } + }; - const clk = (e) => { + const clk = e => { ev(e); if (!this.isEnabled() || !this.isValid()) { return; @@ -161,7 +160,7 @@ export class BasicButton extends Single { trigger: "", // bubble的提示不需要一直存在在界面上 destroyWhenHide: true, - ref: (_ref) => { + ref: _ref => { this.combo = _ref; }, el: { @@ -171,7 +170,7 @@ export class BasicButton extends Single { popup: { type: "bi.text_bubble_bar_popup_view", text: getBubble(), - ref: (_ref) => { + ref: _ref => { popup = _ref; }, listeners: [{ @@ -187,7 +186,7 @@ export class BasicButton extends Single { }, listeners: [{ eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, - action: function () { + action () { popup.populate(getBubble()); }, }], @@ -208,113 +207,113 @@ export class BasicButton extends Single { return; } onClick.apply(this, arguments); - } + }; const triggerArr = (o.trigger || "").split(","); - triggerArr.forEach((trigger) => { + triggerArr.forEach(trigger => { let mouseDown = false; + let selected = false; + let interval; switch (trigger) { - case "mouseup": - hand.mousedown(function () { - mouseDown = true; - }); - hand.mouseup(function (e) { - if (mouseDown === true) { - clk(e); - } - mouseDown = false; - ev(e); - }); - break; - case "mousedown": - // let mouseDown = false; - let selected = false; - hand.mousedown((e) => { + case "mouseup": + hand.mousedown(() => { + mouseDown = true; + }); + hand.mouseup(e => { + if (mouseDown === true) { + clk(e); + } + mouseDown = false; + ev(e); + }); + break; + case "mousedown": + // let mouseDown = false; + hand.mousedown(e => { + // if (e.button === 0) { + Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, e => { // if (e.button === 0) { - Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), (e) => { - // if (e.button === 0) { - if (BI.DOM.isExist(this) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { - // self.setSelected(!self.isSelected()); - this._trigger(); - } - mouseDown = false; - Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); - // } - }); - if (mouseDown === true) { - return; - } - if (this.isSelected()) { - selected = true; - } else { - clk(e); + if (BI.DOM.isExist(this) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { + // self.setSelected(!self.isSelected()); + this._trigger(); } - mouseDown = true; - ev(e); + mouseDown = false; + Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`); // } }); - hand.mouseup((e) => { - // if (e.button === 0) { - if (BI.DOM.isExist(this) && mouseDown === true && selected === true) { - clk(e); - } + if (mouseDown === true) { + return; + } + if (this.isSelected()) { + selected = true; + } else { + clk(e); + } + mouseDown = true; + ev(e); + // } + }); + hand.mouseup(e => { + // if (e.button === 0) { + if (BI.DOM.isExist(this) && mouseDown === true && selected === true) { + clk(e); + } + mouseDown = false; + selected = false; + Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`); + // } + }); + break; + case "dblclick": + hand.dblclick(clk); + break; + case "lclick": + hand.mousedown(e => { + Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, () => { + interval && clearInterval(interval); + interval = null; mouseDown = false; - selected = false; - Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); - // } + Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`); }); - break; - case "dblclick": - hand.dblclick(clk); - break; - case "lclick": - let interval; - hand.mousedown((e) => { - Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), () => { - interval && clearInterval(interval); - interval = null; - mouseDown = false; - Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); - }); - if (mouseDown === true) { - return; - } - if (!this.isEnabled() || !this.isValid()) { - return; - } - if (this.isOnce() && this.isSelected()) { - return; - } - interval = setInterval(function () { - clk(e) - }, 180); - mouseDown = true; + if (mouseDown === true) { + return; + } + if (!this.isEnabled() || !this.isValid()) { + return; + } + if (this.isOnce() && this.isSelected()) { + return; + } + interval = setInterval(() => { + clk(e); + }, 180); + mouseDown = true; + ev(e); + }); + break; + default: + if (o.stopEvent || o.stopPropagation) { + hand.mousedown(e => { ev(e); }); - break; - default: - if (o.stopEvent || o.stopPropagation) { - hand.mousedown(function (e) { - ev(e); - }); + } + hand.click(clk); + // enter键等同于点击 + o.attributes && o.attributes.zIndex >= 0 && hand.keyup(e => { + if (e.keyCode === BI.KeyCode.ENTER) { + clk(e); } - hand.click(clk); - // enter键等同于点击 - o.attributes && o.attributes.zIndex >= 0 && hand.keyup(function (e) { - if (e.keyCode === BI.KeyCode.ENTER) { - clk(e); - } - }); - break; + }); + break; } }); // 之后的300ms点击无效 - let onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { - "leading": true, - "trailing": false, + const onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { + leading: true, + trailing: false, }) : this._doClick; function ev(e) { @@ -325,10 +324,6 @@ export class BasicButton extends Single { e.stopPropagation(); } } - - - - } _trigger(e) { @@ -458,7 +453,7 @@ export class BasicButton extends Single { } empty() { - Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); + Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`); super.empty.apply(this, arguments); } } diff --git a/src/base/single/button/button.node.js b/src/base/single/button/button.node.js index 6b2988eb3..7b8cc4632 100644 --- a/src/base/single/button/button.node.js +++ b/src/base/single/button/button.node.js @@ -1,5 +1,5 @@ -import { BasicButton } from "./button.basic" -import { shortcut, extend, Controller } from "../../../core" +import { BasicButton } from "./button.basic"; +import { shortcut, extend, Controller } from "../../../core"; /** * 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 @@ -11,14 +11,13 @@ import { shortcut, extend, Controller } from "../../../core" */ @shortcut() export class NodeButton extends BasicButton { - static xtype = "bi.node_button"; _defaultConfig() { const conf = super._defaultConfig(arguments); return extend(conf, { - _baseCls: (conf._baseCls || "") + " bi-node", + _baseCls: `${conf._baseCls || ""} bi-node`, open: false, once: false, }); @@ -57,4 +56,4 @@ export class NodeButton extends BasicButton { this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); } } -} \ No newline at end of file +} diff --git a/src/base/single/button/buttons/button.image.js b/src/base/single/button/buttons/button.image.js index 290313fb2..c6486e359 100644 --- a/src/base/single/button/buttons/button.image.js +++ b/src/base/single/button/buttons/button.image.js @@ -11,7 +11,6 @@ import { shortcut, extend, isNumber, createWidget } from "../../../../core"; */ @shortcut() export class ImageButton extends BasicButton { - static EVENT_CHANGE = "EVENT_CHANGE"; static xtype = "bi.image_button"; @@ -19,7 +18,7 @@ export class ImageButton extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-image-button", + baseCls: `${conf.baseCls || ""} bi-image-button`, src: "", iconWidth: "100%", iconHeight: "100%", diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 567e115f9..674400853 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -17,7 +17,6 @@ const loadingCls = "button-loading-font anim-rotate"; */ @shortcut() export class Button extends BasicButton { - _const = { iconWidth: 18, } @@ -33,16 +32,16 @@ export class Button extends BasicButton { // 图标高度和文字高度默认相等 adaptiveHeight += (props.textHeight || 16) * 2; adaptiveHeight += props.iconGap || 0; - let tGap = props.tgap || props.vgap || 2; - let bGap = props.bgap || props.vgap || 2; + const tGap = props.tgap || props.vgap || 2; + const bGap = props.bgap || props.vgap || 2; adaptiveHeight += (tGap + bGap); } - let clearMinWidth = props.block === true || props.clear === true || props.plain; + const clearMinWidth = props.block === true || props.clear === true || props.plain; return { ...conf, - baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), + baseCls: `${conf.baseCls || ""} bi-button${(BI.isIE() && BI.isIE9Below()) ? " hack" : ""}`, attributes: { tabIndex: 1, }, @@ -72,7 +71,7 @@ export class Button extends BasicButton { icon: "", iconGap: 0, iconPosition: "left", - } + }; } render() { @@ -83,7 +82,7 @@ export class Button extends BasicButton { type: "bi.center_adapt", horizontalAlign: o.textAlign, element: this, - ref: (ref) => { + ref: ref => { this.containerRef = ref; }, hgap: o.hgap, @@ -97,7 +96,7 @@ export class Button extends BasicButton { if (BI.get(o, clz) === true) { this.element.addClass(clz); } - }) + }); if (o.minWidth > 0) { this.element.css({ "min-width": BI.pixFormat(o.minWidth) }); @@ -139,7 +138,7 @@ export class Button extends BasicButton { text: o.text, whiteSpace: o.whiteSpace, textAlign: o.textAlign, - textWidth: textWidth, + textWidth, textHeight: BI.toPix(textHeight, hasBorder ? 2 : 0), height: BI.toPix(lineHeight, hasBorder ? 2 : 0), value: o.value, @@ -258,19 +257,19 @@ export class Button extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } } diff --git a/src/base/single/button/buttons/button.text.js b/src/base/single/button/buttons/button.text.js index a7fed2d76..281047b55 100644 --- a/src/base/single/button/buttons/button.text.js +++ b/src/base/single/button/buttons/button.text.js @@ -10,7 +10,6 @@ import { shortcut, extend, createWidget } from "../../../../core"; */ @shortcut() export class TextButton extends BasicButton { - static xtype = "bi.text_button"; static EVENT_CHANGE = "EVENT_CHANGE"; @@ -18,7 +17,7 @@ export class TextButton extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-button", + baseCls: `${conf.baseCls || ""} bi-text-button`, textAlign: "center", whiteSpace: "nowrap", textWidth: null, @@ -61,19 +60,19 @@ export class TextButton extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } setText(text) { diff --git a/src/base/single/button/index.js b/src/base/single/button/index.js index b483234a0..691aa85f7 100644 --- a/src/base/single/button/index.js +++ b/src/base/single/button/index.js @@ -14,4 +14,4 @@ export { TextItem } from "./listitem/textitem"; export { IconTextIconNode } from "./node/icontexticonnode"; export { IconTextNode } from "./node/icontextnode"; export { TextIconNode } from "./node/texticonnode"; -export { TextNode } from "./node/textnode"; \ No newline at end of file +export { TextNode } from "./node/textnode"; diff --git a/src/base/single/button/listitem/blankiconicontextitem.js b/src/base/single/button/listitem/blankiconicontextitem.js index b826fb558..2a471e7b7 100644 --- a/src/base/single/button/listitem/blankiconicontextitem.js +++ b/src/base/single/button/listitem/blankiconicontextitem.js @@ -1,5 +1,5 @@ -import { BasicButton } from "../button.basic" -import { emptyFn, shortcut } from "../../../../core" +import { BasicButton } from "../button.basic"; +import { shortcut } from "../../../../core"; /** * 带有一个占位 @@ -10,15 +10,14 @@ import { emptyFn, shortcut } from "../../../../core" */ @shortcut() export class BlankIconIconTextItem extends BasicButton { - static EVENT_CHANGE = "EVENT_CHANGE"; static xtype = "bi.blank_icon_icon_text_item"; _defaultConfig() { - var conf = super._defaultConfig(arguments); + const conf = super._defaultConfig(arguments); return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-blank-icon-icon-text-item", + baseCls: `${conf.baseCls || ""} bi-blank-icon-icon-text-item`, iconCls1: "", iconCls2: "", blankWidth: 0, @@ -57,7 +56,7 @@ export class BlankIconIconTextItem extends BasicButton { }, { el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, textAlign: "left", @@ -89,7 +88,7 @@ export class BlankIconIconTextItem extends BasicButton { setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -98,7 +97,7 @@ export class BlankIconIconTextItem extends BasicButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { @@ -106,18 +105,18 @@ export class BlankIconIconTextItem extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } } diff --git a/src/base/single/button/listitem/blankicontexticonitem.js b/src/base/single/button/listitem/blankicontexticonitem.js index 91b7bcbe2..217906da8 100644 --- a/src/base/single/button/listitem/blankicontexticonitem.js +++ b/src/base/single/button/listitem/blankicontexticonitem.js @@ -1,5 +1,5 @@ -import { BasicButton } from "../button.basic" -import { emptyFn, shortcut, extend } from "../../../../core" +import { BasicButton } from "../button.basic"; +import { shortcut, extend } from "../../../../core"; /** * guy @@ -11,7 +11,6 @@ import { emptyFn, shortcut, extend } from "../../../../core" */ @shortcut() export class BlankIconTextIconItem extends BasicButton { - static xtype = "bi.blank_icon_text_icon_item"; static EVENT_CHANGE = "EVENT_CHANGE"; @@ -19,7 +18,7 @@ export class BlankIconTextIconItem extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-blank-icon-text-icon-item", + baseCls: `${conf.baseCls || ""} bi-blank-icon-text-icon-item`, iconCls1: "", iconCls2: "", blankWidth: 0, @@ -51,7 +50,7 @@ export class BlankIconTextIconItem extends BasicButton { }, { el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, textAlign: "left", @@ -83,24 +82,24 @@ export class BlankIconTextIconItem extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -109,7 +108,7 @@ export class BlankIconTextIconItem extends BasicButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { diff --git a/src/base/single/button/listitem/blankicontextitem.js b/src/base/single/button/listitem/blankicontextitem.js index fb63eb8fb..fd2b34d32 100644 --- a/src/base/single/button/listitem/blankicontextitem.js +++ b/src/base/single/button/listitem/blankicontextitem.js @@ -1,5 +1,5 @@ -import { BasicButton } from "../button.basic" -import { extend, shortcut } from "../../../../core" +import { BasicButton } from "../button.basic"; +import { extend, shortcut } from "../../../../core"; /** * 带有一个占位 @@ -10,7 +10,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut() export class BlankIconTextItem extends BasicButton { - static xtype = "bi.blank_icon_text_item"; static EVENT_CHANGE = "EVENT_CHANGE"; @@ -18,7 +17,7 @@ export class BlankIconTextItem extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item", + baseCls: `${conf.baseCls || ""} bi-blank-icon-text-item`, blankWidth: 0, iconHeight: null, iconWidth: null, @@ -49,7 +48,7 @@ export class BlankIconTextItem extends BasicButton { }, { el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, cls: "list-item-text", @@ -76,7 +75,7 @@ export class BlankIconTextItem extends BasicButton { setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -85,7 +84,7 @@ export class BlankIconTextItem extends BasicButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { @@ -93,18 +92,18 @@ export class BlankIconTextItem extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } } diff --git a/src/base/single/button/listitem/icontexticonitem.js b/src/base/single/button/listitem/icontexticonitem.js index 8aadfdd47..1209e8054 100644 --- a/src/base/single/button/listitem/icontexticonitem.js +++ b/src/base/single/button/listitem/icontexticonitem.js @@ -1,5 +1,5 @@ -import { BasicButton } from "../button.basic" -import { extend, shortcut } from "../../../../core" +import { BasicButton } from "../button.basic"; +import { extend, shortcut } from "../../../../core"; /** * guy @@ -12,7 +12,6 @@ import { extend, shortcut } from "../../../../core" @shortcut() export class IconTextIconItem extends BasicButton { - static EVENT_CHANGE = "EVENT_CHANGE"; static xtype = "bi.icon_text_icon_item"; @@ -20,7 +19,7 @@ export class IconTextIconItem extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-icon-text-icon-item", + baseCls: `${conf.baseCls || ""} bi-icon-text-icon-item`, iconCls1: "", iconCls2: "", iconHeight: null, @@ -48,7 +47,7 @@ export class IconTextIconItem extends BasicButton { }, { el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, textAlign: "left", @@ -80,24 +79,24 @@ export class IconTextIconItem extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -106,7 +105,7 @@ export class IconTextIconItem extends BasicButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { diff --git a/src/base/single/button/listitem/icontextitem.js b/src/base/single/button/listitem/icontextitem.js index 7aa02bdb3..70ce49654 100644 --- a/src/base/single/button/listitem/icontextitem.js +++ b/src/base/single/button/listitem/icontextitem.js @@ -1,5 +1,5 @@ -import { BasicButton } from "../button.basic" -import { extend, shortcut } from "../../../../core" +import { BasicButton } from "../button.basic"; +import { extend, shortcut } from "../../../../core"; /** * guy @@ -10,7 +10,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut() export class IconTextItem extends BasicButton { - static EVENT_CHANGE = "EVENT_CHANGE"; static xtype = "bi.icon_text_item"; @@ -18,7 +17,7 @@ export class IconTextItem extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-icon-text-item", + baseCls: `${conf.baseCls || ""} bi-icon-text-item`, direction: BI.Direction.Left, iconWrapperWidth: null, iconHeight: null, @@ -47,7 +46,7 @@ export class IconTextItem extends BasicButton { }, { el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, cls: "list-item-text", @@ -74,7 +73,7 @@ export class IconTextItem extends BasicButton { setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -83,7 +82,7 @@ export class IconTextItem extends BasicButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { @@ -91,18 +90,18 @@ export class IconTextItem extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } } diff --git a/src/base/single/button/listitem/texticonitem.js b/src/base/single/button/listitem/texticonitem.js index a8b8077fd..db9b30478 100644 --- a/src/base/single/button/listitem/texticonitem.js +++ b/src/base/single/button/listitem/texticonitem.js @@ -1,5 +1,5 @@ -import { BasicButton } from "../button.basic" -import { extend, shortcut } from "../../../../core" +import { BasicButton } from "../button.basic"; +import { extend, shortcut } from "../../../../core"; /** * @@ -11,7 +11,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut() export class TextIconItem extends BasicButton { - static xtype = "bi.text_icon_item"; static EVENT_CHANGE = "EVENT_CHANGE" @@ -19,7 +18,7 @@ export class TextIconItem extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-icon-item", + baseCls: `${conf.baseCls || ""} bi-text-icon-item`, iconWrapperWidth: null, iconHeight: null, iconWidth: null, @@ -40,7 +39,7 @@ export class TextIconItem extends BasicButton { items: [{ el: { type: "bi.label", - ref: function (_ref) { + ref (_ref) { self.text = _ref; }, cls: "list-item-text", @@ -74,7 +73,7 @@ export class TextIconItem extends BasicButton { setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -83,7 +82,7 @@ export class TextIconItem extends BasicButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { @@ -91,18 +90,18 @@ export class TextIconItem extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } } diff --git a/src/base/single/button/listitem/textitem.js b/src/base/single/button/listitem/textitem.js index 82fa1e7ea..a1bb719b5 100644 --- a/src/base/single/button/listitem/textitem.js +++ b/src/base/single/button/listitem/textitem.js @@ -1,5 +1,5 @@ -import { BasicButton } from "../button.basic" -import { extend, shortcut } from "../../../../core" +import { BasicButton } from "../button.basic"; +import { extend, shortcut } from "../../../../core"; /** * guy @@ -11,7 +11,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut export class TextItem extends BasicButton { - static xtype = "bi.text_item"; static EVENT_CHANGE = "EVENT_CHANGE"; @@ -19,7 +18,7 @@ export class TextItem extends BasicButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-item", + baseCls: `${conf.baseCls || ""} bi-text-item`, textAlign: "left", whiteSpace: "nowrap", textHgap: 0, @@ -57,24 +56,24 @@ export class TextItem extends BasicButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } doHighLight() { - this.text.doHighLight.apply(this.text, arguments); + this.text.doHighLight(...arguments); } unHighLight() { - this.text.unHighLight.apply(this.text, arguments); + this.text.unHighLight(...arguments); } setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -83,7 +82,7 @@ export class TextItem extends BasicButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { diff --git a/src/base/single/button/node/icontexticonnode.js b/src/base/single/button/node/icontexticonnode.js index 7cbff7f74..a08b63c8d 100644 --- a/src/base/single/button/node/icontexticonnode.js +++ b/src/base/single/button/node/icontexticonnode.js @@ -1,5 +1,5 @@ -import { NodeButton } from "../button.node" -import { extend, shortcut } from "../../../../core" +import { NodeButton } from "../button.node"; +import { extend, shortcut } from "../../../../core"; /** * guy @@ -9,7 +9,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut() export class IconTextIconNode extends NodeButton { - static xtype = "bi.icon_text_icon_node"; static EVENT_CHANGE = "EVENT_CHANGE"; @@ -17,7 +16,7 @@ export class IconTextIconNode extends NodeButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node", + baseCls: `${conf.baseCls || ""} bi-icon-text-icon-node`, iconCls1: "close-ha-font", iconCls2: "close-ha-font", iconHeight: null, @@ -45,7 +44,7 @@ export class IconTextIconNode extends NodeButton { }, { el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, textAlign: "left", @@ -77,16 +76,16 @@ export class IconTextIconNode extends NodeButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -95,7 +94,7 @@ export class IconTextIconNode extends NodeButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { diff --git a/src/base/single/button/node/icontextnode.js b/src/base/single/button/node/icontextnode.js index 6a6260432..5135030db 100644 --- a/src/base/single/button/node/icontextnode.js +++ b/src/base/single/button/node/icontextnode.js @@ -1,5 +1,5 @@ -import { NodeButton } from "../button.node" -import { extend, shortcut } from "../../../../core" +import { NodeButton } from "../button.node"; +import { extend, shortcut } from "../../../../core"; /** * guy @@ -9,7 +9,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut() export class IconTextNode extends NodeButton { - static EVENT_CHANGE = "EVENT_CHANGE"; static xtype = "bi.icon_text_node"; @@ -17,7 +16,7 @@ export class IconTextNode extends NodeButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-icon-text-node", + baseCls: `${conf.baseCls || ""} bi-icon-text-node`, cls: "close-ha-font", iconHeight: null, iconWidth: null, @@ -44,7 +43,7 @@ export class IconTextNode extends NodeButton { }, { el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, cls: "list-item-text", @@ -71,7 +70,7 @@ export class IconTextNode extends NodeButton { setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -80,7 +79,7 @@ export class IconTextNode extends NodeButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { @@ -88,11 +87,11 @@ export class IconTextNode extends NodeButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } } diff --git a/src/base/single/button/node/texticonnode.js b/src/base/single/button/node/texticonnode.js index 02a205047..cc3f2dea8 100644 --- a/src/base/single/button/node/texticonnode.js +++ b/src/base/single/button/node/texticonnode.js @@ -1,5 +1,5 @@ -import { NodeButton } from "../button.node" -import { extend, shortcut } from "../../../../core" +import { NodeButton } from "../button.node"; +import { extend, shortcut } from "../../../../core"; /** * Created by GUY on 2015/9/9. @@ -8,7 +8,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut() export default class TextIconNode extends NodeButton { - static EVENT_CHANGE = "EVENT_CHANGE"; static xtype = "bi.text_icon_node"; @@ -16,7 +15,7 @@ export default class TextIconNode extends NodeButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-icon-node", + baseCls: `${conf.baseCls || ""} bi-text-icon-node`, cls: "close-ha-font", iconHeight: null, iconWidth: null, @@ -36,7 +35,7 @@ export default class TextIconNode extends NodeButton { items: [{ el: { type: "bi.label", - ref: (_ref) => { + ref: _ref => { this.text = _ref; }, cls: "list-item-text", @@ -70,7 +69,7 @@ export default class TextIconNode extends NodeButton { setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -79,7 +78,7 @@ export default class TextIconNode extends NodeButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { @@ -87,10 +86,10 @@ export default class TextIconNode extends NodeButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } } diff --git a/src/base/single/button/node/textnode.js b/src/base/single/button/node/textnode.js index 80aadb0d3..e6e990cf7 100644 --- a/src/base/single/button/node/textnode.js +++ b/src/base/single/button/node/textnode.js @@ -1,5 +1,5 @@ -import { NodeButton } from "../button.node" -import { extend, shortcut } from "../../../../core" +import { NodeButton } from "../button.node"; +import { extend, shortcut } from "../../../../core"; /** * guy @@ -10,7 +10,6 @@ import { extend, shortcut } from "../../../../core" */ @shortcut() export class TextNode extends NodeButton { - static xtype = "bi.text_node" static EVENT_CHANGE = "EVENT_CHANGE" @@ -20,7 +19,7 @@ export class TextNode extends NodeButton { const conf = super._defaultConfig(arguments); return extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-node", + baseCls: `${conf.baseCls || ""} bi-text-node`, textAlign: "left", whiteSpace: "nowrap", textHgap: 0, @@ -58,16 +57,16 @@ export class TextNode extends NodeButton { } doRedMark() { - this.text.doRedMark.apply(this.text, arguments); + this.text.doRedMark(...arguments); } unRedMark() { - this.text.unRedMark.apply(this.text, arguments); + this.text.unRedMark(...arguments); } setValue() { if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); + this.text.setValue(...arguments); } } @@ -76,7 +75,7 @@ export class TextNode extends NodeButton { } setText() { - this.text.setText.apply(this.text, arguments); + this.text.setText(...arguments); } getText() { diff --git a/src/case/button/icon/icon.change.js b/src/case/button/icon/icon.change.js index e65160879..3e5ad6c46 100644 --- a/src/case/button/icon/icon.change.js +++ b/src/case/button/icon/icon.change.js @@ -1,15 +1,25 @@ +import { Single } from "../../../base/single/0.single"; +import { IconButton } from "../../../base/single/button/buttons/button.icon"; +import { shortcut, extend, emptyFn, isFunction, createWidget, Controller } from "../../../core"; + /** * 可以改变图标的button * * Created by GUY on 2016/2/2. * - * @class BI.IconChangeButton - * @extends BI.Single + * @class IconChangeButton + * @extends Single */ -BI.IconChangeButton = BI.inherit(BI.Single, { - _defaultConfig: function () { - var conf = BI.IconChangeButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { +@shortcut() +export class IconChangeButton extends Single { + static xtype = "bi.icon_change_button"; + static EVENT_CHANGE = "EVENT_CHANGE"; + + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { baseCls: "bi-icon-change-button", iconCls: "", iconWidth: null, @@ -24,19 +34,19 @@ BI.IconChangeButton = BI.inherit(BI.Single, { disableSelected: false, // 使能选中 shadow: false, - isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 + isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 trigger: null, - handler: BI.emptyFn + handler: emptyFn, }); - }, + } - _init: function () { - var self = this, o = this.options; - o.iconCls = BI.isFunction(o.iconCls) ? this.__watch(o.iconCls, function (context, newValue) { - self.setIcon(newValue); + _init() { + const o = this.options; + o.iconCls = isFunction(o.iconCls) ? this.__watch(o.iconCls, (context, newValue) => { + this.setIcon(newValue); }) : o.iconCls; - BI.IconChangeButton.superclass._init.apply(this, arguments); - this.button = BI.createWidget({ + super._init.apply(this, arguments); + this.button = createWidget({ type: "bi.icon_button", element: this, cls: o.iconCls, @@ -55,32 +65,30 @@ BI.IconChangeButton = BI.inherit(BI.Single, { shadow: o.shadow, isShadowShowingOnSelected: o.isShadowShowingOnSelected, trigger: o.trigger, - handler: o.handler + handler: o.handler, }); - this.button.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + this.button.on(Controller.EVENT_CHANGE, (...args) => { + this.fireEvent(Controller.EVENT_CHANGE, args); }); - this.button.on(BI.IconButton.EVENT_CHANGE, function () { - self.fireEvent(BI.IconChangeButton.EVENT_CHANGE, arguments); + this.button.on(IconButton.EVENT_CHANGE, (...args) => { + this.fireEvent(IconChangeButton.EVENT_CHANGE, args); }); - }, + } - isSelected: function () { + isSelected() { return this.button.isSelected(); - }, + } - setSelected: function (b) { + setSelected(b) { this.button.setSelected(b); - }, + } - setIcon: function (cls) { - var o = this.options; + setIcon(cls) { + const o = this.options; if (o.iconCls !== cls) { this.element.removeClass(o.iconCls).addClass(cls); o.iconCls = cls; } } -}); -BI.IconChangeButton.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.icon_change_button", BI.IconChangeButton); +} diff --git a/src/case/button/icon/icon.trigger.js b/src/case/button/icon/icon.trigger.js index daa76b121..1c799edd4 100644 --- a/src/case/button/icon/icon.trigger.js +++ b/src/case/button/icon/icon.trigger.js @@ -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, { - - _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" +@shortcut() +export class TriggerIconButton extends IconButton { + static xtype = "bi.trigger_icon_button"; + EVENT_CHANGE = IconButton.EVENT_CHANGE; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + 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); +} diff --git a/src/case/button/icon/iconhalf/icon.half.image.js b/src/case/button/icon/iconhalf/icon.half.image.js index a9e9d0014..e165b4d23 100644 --- a/src/case/button/icon/iconhalf/icon.half.image.js +++ b/src/case/button/icon/iconhalf/icon.half.image.js @@ -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); \ No newline at end of file diff --git a/src/case/button/icon/iconhalf/icon.half.js b/src/case/button/icon/iconhalf/icon.half.js index f8c23afc4..1efe6c110 100644 --- a/src/case/button/icon/iconhalf/icon.half.js +++ b/src/case/button/icon/iconhalf/icon.half.js @@ -1,22 +1,31 @@ +import { BasicButton } from "../../../../base/single/button/button.basic"; +import { shortcut, extend } from "../../../../core"; + /** * guy * @extends BI.Single * @type {*|void|Object} */ -BI.HalfButton = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { +@shortcut() +export class HalfButton extends BasicButton { + static xtype = "bi.half_button"; + static EVENT_CHANGE = "EVENT_CHANGE"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { selected: false, width: 14, height: 14, iconWidth: 14, iconHeight: 14, }); - }, + } - render: function () { - var o = this.options; + render() { + const o = this.options; + return { type: "bi.center_adapt", items: [{ @@ -26,15 +35,12 @@ BI.HalfButton = BI.inherit(BI.BasicButton, { height: o.iconHeight, }], }; - }, + } - doClick: function () { - BI.HalfButton.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); if (this.isValid()) { - this.fireEvent(BI.HalfButton.EVENT_CHANGE); + this.fireEvent(HalfButton.EVENT_CHANGE); } } -}); -BI.HalfButton.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.half_button", BI.HalfButton); +} diff --git a/src/case/button/index.js b/src/case/button/index.js new file mode 100644 index 000000000..f19d10b13 --- /dev/null +++ b/src/case/button/index.js @@ -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"; diff --git a/src/case/button/item.multiselect.js b/src/case/button/item.multiselect.js index b90fafac5..df74642c9 100644 --- a/src/case/button/item.multiselect.js +++ b/src/case/button/item.multiselect.js @@ -1,36 +1,45 @@ +import { BasicButton } from "../../base/single/button/button.basic"; +import { shortcut, extend, createWidget } from "../../core"; + /** * guy * 复选框item * @type {*|void|Object} */ -BI.MultiSelectItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), { +@shortcut() +export class MultiSelectItem extends BasicButton { + static xtype = "bi.multi_select_item"; + static EVENT_CHANGE = "EVENT_CHANGE"; + + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-multi-select-item", attributes: { - tabIndex: 1 + tabIndex: 1, }, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, iconWrapperWidth: 26, }); - }, + } - render: function () { - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" + render() { + const o = this.options; + this.checkbox = createWidget({ + type: "bi.checkbox", }); + return { type: "bi.vertical_adapt", columnSize: [o.iconWrapperWidth || o.height, "fill"], items: [{ type: "bi.center_adapt", - items: [this.checkbox] + items: [this.checkbox], }, { el: { type: "bi.label", - ref: function (_ref) { - self.text = _ref; + ref: _ref => { + this.text = _ref; }, cls: "list-item-text", textAlign: "left", @@ -44,11 +53,11 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { text: o.text, keyword: o.keyword, value: o.value, - py: o.py - } - }] + py: o.py, + }, + }], }; - }, + } // _setEnable: function (enable) { // BI.MultiSelectItem.superclass._setEnable.apply(this, arguments); @@ -59,25 +68,24 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { // } // }, - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { + doClick() { BI.MultiSelectItem.superclass.doClick.apply(this, arguments); if (this.isValid()) { this.fireEvent(BI.MultiSelectItem.EVENT_CHANGE, this.getValue(), this); } - }, + } - setSelected: function (v) { + setSelected(v) { BI.MultiSelectItem.superclass.setSelected.apply(this, arguments); this.checkbox.setSelected(v); } -}); -BI.MultiSelectItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_item", BI.MultiSelectItem); +} + diff --git a/src/case/button/item.singleselect.icontext.js b/src/case/button/item.singleselect.icontext.js index 47960e9fa..d92f59050 100644 --- a/src/case/button/item.singleselect.icontext.js +++ b/src/case/button/item.singleselect.icontext.js @@ -1,24 +1,30 @@ +import { Single } from "../../base/single/0.single"; +import { shortcut, extend, createWidget, Controller } from "../../core"; + /** * Created by GUY on 2016/2/2. * * @class BI.SingleSelectIconTextItem * @extends BI.BasicButton */ -BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectIconTextItem.superclass._defaultConfig.apply(this, arguments), { +@shortcut() +export class SingleSelectIconTextItem extends Single { + static xtype = "bi.single_select_icon_text_item"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-single-select-icon-text-item bi-list-item-active", attributes: { - tabIndex: 1 + tabIndex: 1, }, iconCls: "", - height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, }); - }, + } - render: function () { - var self = this, o = this.options; - this.text = BI.createWidget({ + render() { + const o = this.options; + this.text = createWidget({ type: "bi.icon_text_item", element: this, cls: o.iconCls, @@ -35,37 +41,37 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { text: o.text, keyword: o.keyword, value: o.value, - py: o.py + py: o.py, }); - this.text.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + this.text.on(Controller.EVENT_CHANGE, function () { + self.fireEvent(Controller.EVENT_CHANGE, arguments); }); - }, + } - _setEnable: function (enable) { - BI.SingleSelectIconTextItem.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"); } - }, + } - isSelected: function () { + isSelected() { return this.text.isSelected(); - }, + } - setSelected: function (b) { + setSelected(b) { this.text.setSelected(b); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); + unRedMark() { + this.text.unRedMark(...arguments); } -}); +} + -BI.shortcut("bi.single_select_icon_text_item", BI.SingleSelectIconTextItem); diff --git a/src/case/button/item.singleselect.js b/src/case/button/item.singleselect.js index 50a1cf6db..9b3e682c7 100644 --- a/src/case/button/item.singleselect.js +++ b/src/case/button/item.singleselect.js @@ -1,19 +1,26 @@ -BI.SingleSelectItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), { +import { BasicButton } from "../../base/single/button/button.basic"; +import { shortcut, extend, createWidget } from "../../core"; + +@shortcut() +export class SingleSelectItem extends BasicButton { + static xtype = "bi.single_select_item"; + static EVENT_CHANGE = "EVENT_CHANGE"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-single-select-item bi-list-item-active", attributes: { - tabIndex: 1 + tabIndex: 1, }, textHgap: 10, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - textAlign: "left" + textAlign: "left", }); - }, + } - render: function () { - var self = this, o = this.options; - this.text = BI.createWidget({ + render() { + const o = this.options; + this.text = createWidget({ type: "bi.label", element: this, textAlign: o.textAlign, @@ -27,38 +34,38 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { text: o.text, keyword: o.keyword, value: o.value, - py: o.py + py: o.py, }); - }, + } - _setEnable: function (enable) { - BI.SingleSelectItem.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"); } - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { - BI.SingleSelectItem.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); if (this.isValid()) { - this.fireEvent(BI.SingleSelectItem.EVENT_CHANGE, this.isSelected(), this); + this.fireEvent(SingleSelectItem.EVENT_CHANGE, this.isSelected(), this); } - }, + } - setSelected: function (v) { - BI.SingleSelectItem.superclass.setSelected.apply(this, arguments); + setSelected(v) { + super.setSelected.apply(this, arguments); } -}); +} + + -BI.SingleSelectItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_select_item", BI.SingleSelectItem); diff --git a/src/case/button/item.singleselect.radio.js b/src/case/button/item.singleselect.radio.js index 74ebe49c9..19a04f120 100644 --- a/src/case/button/item.singleselect.radio.js +++ b/src/case/button/item.singleselect.radio.js @@ -1,23 +1,31 @@ +import { BasicButton } from "../../base/single/button/button.basic"; +import { shortcut, extend } from "../../core"; + /** * guy * 单选框item * @type {*|void|Object} */ -BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectRadioItem.superclass._defaultConfig.apply(this, arguments), { +@shortcut() +export class SingleSelectRadioItem extends BasicButton { + static xtype = "bi.single_select_radio_item"; + static EVENT_CHANGE = "EVENT_CHANGE"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-single-select-radio-item", attributes: { - tabIndex: 1 + tabIndex: 1, }, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, iconWrapperWidth: 16, textHgap: 10, }); - }, + } + + render() { + const o = this.options; - render: function () { - var self = this, o = this.options; return { type: "bi.vertical_adapt", columnSize: [o.iconWrapperWidth || o.height, "fill"], @@ -25,15 +33,15 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { type: "bi.center_adapt", items: [{ type: "bi.radio", - ref: function (_ref) { - self.radio = _ref; + ref: _ref => { + this.radio = _ref; }, - }] + }], }, { el: { type: "bi.label", - ref: function (_ref) { - self.text = _ref; + ref: _ref => { + this.text = _ref; }, cls: "list-item-text", textAlign: "left", @@ -47,42 +55,39 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { text: o.text, keyword: o.keyword, value: o.value, - py: o.py - } - }] + py: o.py, + }, + }], }; - }, + } - _setEnable: function (enable) { - BI.SingleSelectRadioItem.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"); } - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { + doClick() { BI.SingleSelectRadioItem.superclass.doClick.apply(this, arguments); if (this.isValid()) { this.fireEvent(BI.SingleSelectRadioItem.EVENT_CHANGE, this.isSelected(), this); } - }, + } - setSelected: function (v) { + setSelected(v) { BI.SingleSelectRadioItem.superclass.setSelected.apply(this, arguments); this.radio.setSelected(v); - } -}); +} -BI.SingleSelectRadioItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_select_radio_item", BI.SingleSelectRadioItem); diff --git a/src/case/button/node/node.arrow.js b/src/case/button/node/node.arrow.js index d0b21ca7c..08cc58605 100644 --- a/src/case/button/node/node.arrow.js +++ b/src/case/button/node/node.arrow.js @@ -1,34 +1,42 @@ +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend, createWidget } from "../../../core"; + /** * Created by roy on 15/10/16. */ -BI.ArrowNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.ArrowNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-arrow-group-node bi-list-item", +@shortcut() +export class ArrowNode extends NodeButton { + static xtype = "bi.arrow_group_node"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-arrow-group-node bi-list-item`, id: "", pId: "", open: false, height: 24, - iconWrapperWidth: 16 + iconWrapperWidth: 16, }); - }, + } - render: function () { - var self = this, o = this.options; - this.checkbox = BI.createWidget({ + render() { + const o = this.options; + this.checkbox = createWidget({ type: "bi.arrow_group_node_checkbox", expandIcon: o.expandIcon, collapseIcon: o.collapseIcon, }); + return { type: "bi.vertical_adapt", columnSize: [o.iconWrapperWidth || o.height, "fill"], items: [this.checkbox, { el: { type: "bi.label", - ref: function (_ref) { - self.text = _ref; + ref: _ref => { + this.text = _ref; }, textAlign: "left", whiteSpace: "nowrap", @@ -41,34 +49,33 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword - } - }] + keyword: o.keyword, + }, + }], }; - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { - BI.ArrowNode.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); this.checkbox.setSelected(this.isOpened()); - }, + } - setText: function (text) { - BI.ArrowNode.superclass.setText.apply(this, arguments); + setText(text) { + super.setText.apply(this, arguments); this.text.setText(text); - }, + } - setOpened: function (v) { - BI.ArrowNode.superclass.setOpened.apply(this, arguments); + setOpened(v) { + super.setOpened.apply(this, arguments); this.checkbox.setSelected(v); } -}); +} -BI.shortcut("bi.arrow_group_node", BI.ArrowNode); diff --git a/src/case/button/node/node.first.plus.js b/src/case/button/node/node.first.plus.js index 989cdec0b..60a266d49 100644 --- a/src/case/button/node/node.first.plus.js +++ b/src/case/button/node/node.first.plus.js @@ -1,33 +1,42 @@ +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend, createWidget, Controller } from "../../../core"; + + /** * 加号表示的组节点 * Created by GUY on 2015/9/6. - * @class BI.FirstPlusGroupNode - * @extends BI.NodeButton + * @class FirstPlusGroupNode + * @extends NodeButton */ -BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.FirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-first-plus-group-node bi-list-item", +@shortcut() +export class FirstPlusGroupNode extends NodeButton { + static xtype = "bi.first_plus_group_node"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-first-plus-group-node bi-list-item`, logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", open: false, - height: 24 + height: 24, }); - }, - _init: function () { - BI.FirstPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.checkbox = createWidget({ type: "bi.first_tree_node_checkbox", stopPropagation: true, iconHeight: o.height, - iconWidth: o.height + iconWidth: o.height, }); - this.text = BI.createWidget({ + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -37,9 +46,9 @@ BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + this.checkbox.on(Controller.EVENT_CHANGE, function (type) { if (type === BI.Events.CLICK) { if (this.isSelected()) { self.triggerExpand(); @@ -48,37 +57,36 @@ BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, { } } }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - el: this.checkbox + el: this.checkbox, }, this.text); BI.createWidget(BI.extend({ - element: this + element: this, }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items + items, })))); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { - BI.FirstPlusGroupNode.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); this.checkbox.setSelected(this.isSelected()); - }, + } - setOpened: function (v) { - BI.FirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + setOpened(v) { + super.setOpened.apply(this, arguments); if (BI.isNotNull(this.checkbox)) { this.checkbox.setSelected(v); } } -}); +} -BI.shortcut("bi.first_plus_group_node", BI.FirstPlusGroupNode); diff --git a/src/case/button/node/node.icon.arrow.js b/src/case/button/node/node.icon.arrow.js index d641e655d..2aa910a9b 100644 --- a/src/case/button/node/node.icon.arrow.js +++ b/src/case/button/node/node.icon.arrow.js @@ -1,18 +1,24 @@ +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend, createWidget, Controller } from "../../../core"; + /** * Created by User on 2016/3/31. - */ -/** + * * > + icon + 文本 - * @class BI.IconArrowNode - * @extends BI.NodeButton + * @class IconArrowNode + * @extends NodeButton */ -BI.IconArrowNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.IconArrowNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-icon-arrow-node bi-list-item", +@shortcut() +export class IconArrowNode extends NodeButton { + static xtype = "bi.icon_arrow_node"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-icon-arrow-node bi-list-item`, logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", @@ -21,29 +27,30 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, { iconHeight: 12, iconWidth: 12, iconCls: "", - iconWrapperWidth: 16 + iconWrapperWidth: 16, }); - }, - _init: function () { - BI.IconArrowNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.checkbox = createWidget({ type: "bi.arrow_group_node_checkbox", expandIcon: o.expandIcon, collapseIcon: o.collapseIcon, width: 24, - stopPropagation: true + stopPropagation: true, }); - var icon = BI.createWidget({ + const icon = createWidget({ type: "bi.icon_label", width: 24, cls: o.iconCls, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, }); - this.text = BI.createWidget({ + createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -53,52 +60,50 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + this.checkbox.on(Controller.EVENT_CHANGE, type => { if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); + if (this.checkbox.isSelected()) { + this.triggerExpand(); } else { - self.triggerCollapse(); + this.triggerCollapse(); } } }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { width: o.iconWrapperWidth, - el: this.checkbox + el: this.checkbox, }, { width: 16, - el: icon + el: icon, }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items, - rgap: 5 + createWidget(extend({ + element: this, + }, BI.LogicFactory.createLogic(type, extend(o.logic, { + items, + rgap: 5, })))); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark () { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { + doClick() { BI.IconArrowNode.superclass.doClick.apply(this, arguments); this.checkbox.setSelected(this.isSelected()); - }, + } - setOpened: function (v) { + setOpened(v) { BI.IconArrowNode.superclass.setOpened.apply(this, arguments); if (BI.isNotNull(this.checkbox)) { this.checkbox.setSelected(v); } } -}); - -BI.shortcut("bi.icon_arrow_node", BI.IconArrowNode); +} diff --git a/src/case/button/node/node.last.plus.js b/src/case/button/node/node.last.plus.js index c1a949e3b..0dba75eaf 100644 --- a/src/case/button/node/node.last.plus.js +++ b/src/case/button/node/node.last.plus.js @@ -1,33 +1,40 @@ +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend, createWidget, isNotNull } from "../../../core"; + /** * 加号表示的组节点 * Created by GUY on 2015/9/6. - * @class BI.LastPlusGroupNode - * @extends BI.NodeButton + * @class LastPlusGroupNode + * @extends NodeButton */ -BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.LastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-last-plus-group-node bi-list-item", +@shortcut() +export class LastPlusGroupNode extends NodeButton { + static xtype = "bi.last_plus_group_node"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-last-plus-group-node bi-list-item`, logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", open: false, - height: 24 + height: 24, }); - }, - _init: function () { + } + _init() { BI.LastPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ + const o = this.options; + this.checkbox = createWidget({ type: "bi.last_tree_node_checkbox", stopPropagation: true, iconHeight: o.height, - iconWidth: o.height + iconWidth: o.height, }); - this.text = BI.createWidget({ + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -37,48 +44,46 @@ BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if(type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); + this.checkbox.on(BI.Controller.EVENT_CHANGE, type => { + if (type === BI.Events.CLICK) { + if (this.checkbox.isSelected()) { + this.triggerExpand(); } else { - self.triggerCollapse(); + this.triggerCollapse(); } } }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - el: this.checkbox + el: this.checkbox, }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items + createWidget(extend({ + element: this, + }, BI.LogicFactory.createLogic(type, extend(o.logic, { + items, })))); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { - BI.LastPlusGroupNode.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); this.checkbox.setSelected(this.isSelected()); - }, + } - setOpened: function (v) { - BI.LastPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { + setOpened(v) { + super.setOpened.apply(this, arguments); + if (isNotNull(this.checkbox)) { this.checkbox.setSelected(v); } } -}); - -BI.shortcut("bi.last_plus_group_node", BI.LastPlusGroupNode); \ No newline at end of file +} diff --git a/src/case/button/node/node.mid.plus.js b/src/case/button/node/node.mid.plus.js index 839565114..94ce8b1b9 100644 --- a/src/case/button/node/node.mid.plus.js +++ b/src/case/button/node/node.mid.plus.js @@ -1,33 +1,41 @@ +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend, createWidget, Controller } from "../../../core"; + /** * 加号表示的组节点 * Created by GUY on 2015/9/6. * @class BI.MidPlusGroupNode * @extends BI.NodeButton */ -BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-mid-plus-group-node bi-list-item", +@shortcut +export class MidPlusGroupNode extends NodeButton { + static xtype = "bi.mid_plus_group_node"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-mid-plus-group-node bi-list-item`, logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", open: false, - height: 24 + height: 24, }); - }, - _init: function () { - BI.MidPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.checkbox = createWidget({ type: "bi.mid_tree_node_checkbox", stopPropagation: true, iconHeight: o.height, - iconWidth: o.height + iconWidth: o.height, }); - this.text = BI.createWidget({ + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -37,48 +45,47 @@ BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + this.checkbox.on(Controller.EVENT_CHANGE, type => { if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); + if (this.checkbox.isSelected()) { + this.triggerExpand(); } else { - self.triggerCollapse(); + this.triggerCollapse(); } } }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - el: this.checkbox + el: this.checkbox, }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items + createWidget(extend({ + element: this, + }, BI.LogicFactory.createLogic(type, extend(o.logic, { + items, })))); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { - BI.MidPlusGroupNode.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); this.checkbox.setSelected(this.isSelected()); - }, + } - setOpened: function (v) { + setOpened(v) { BI.MidPlusGroupNode.superclass.setOpened.apply(this, arguments); if (BI.isNotNull(this.checkbox)) { this.checkbox.setSelected(v); } } -}); +} -BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode); \ No newline at end of file diff --git a/src/case/button/node/node.multilayer.icon.arrow.js b/src/case/button/node/node.multilayer.icon.arrow.js index ffa9c50ea..c1a9b35da 100644 --- a/src/case/button/node/node.multilayer.icon.arrow.js +++ b/src/case/button/node/node.multilayer.icon.arrow.js @@ -1,7 +1,14 @@ -BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerIconArrowNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend, createWidget, Controller, count } from "../../../core"; + +@shortcut() +export class MultiLayerIconArrowNode extends NodeButton { + static xtype = "bi.multilayer_icon_arrow_node"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { extraCls: "bi-multilayer-icon-arrow-node bi-list-item", layer: 0, // 第几层级 id: "", @@ -10,13 +17,14 @@ BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, { height: 24, iconHeight: 16, iconWidth: 16, - iconCls: "" + iconCls: "", }); - }, - _init: function () { - BI.MultiLayerIconArrowNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.node = createWidget({ type: "bi.icon_arrow_node", iconCls: o.iconCls, cls: "bi-list-item-none", @@ -30,60 +38,58 @@ BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - self.setSelected(self.isSelected()); - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + this.node.on(Controller.EVENT_CHANGE, (...args) => { + this.setSelected(this.isSelected()); + this.fireEvent(Controller.EVENT_CHANGE, args); }); - var items = []; - BI.count(0, o.layer, function () { + const items = []; + count(0, o.layer, () => { items.push({ type: "bi.layout", width: 15, - height: o.height + height: o.height, }); }); items.push(this.node); - BI.createWidget({ + createWidget({ type: "bi.horizontal_adapt", element: this, columnSize: BI.makeArray(o.layer, 15), - items: items + items, }); - }, + } - isOnce: function () { + isOnce() { return true; - }, + } - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, + doRedMark() { + this.node.doRedMark(...arguments); + } - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, + unRedMark() { + this.node.unRedMark(...arguments); + } - isSelected: function () { + isSelected() { return this.node.isSelected(); - }, + } - setSelected: function (b) { - BI.MultiLayerIconArrowNode.superclass.setSelected.apply(this, arguments); + setSelected(b) { + super.setSelected.apply(this, arguments); this.node.setSelected(b); - }, + } - doClick: function () { - BI.NodeButton.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); this.node.setSelected(this.isSelected()); - }, + } - setOpened: function (v) { - BI.MultiLayerIconArrowNode.superclass.setOpened.apply(this, arguments); + setOpened(v) { + super.setOpened.apply(this, arguments); this.node.setOpened(v); } -}); - -BI.shortcut("bi.multilayer_icon_arrow_node", BI.MultiLayerIconArrowNode); +} diff --git a/src/case/button/node/node.plus.js b/src/case/button/node/node.plus.js index 4b9477ea7..f3f08b0cf 100644 --- a/src/case/button/node/node.plus.js +++ b/src/case/button/node/node.plus.js @@ -1,42 +1,51 @@ +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend, createWidget, Controller } from "../../../core"; + /** * 加号表示的组节点 * Created by GUY on 2015/9/6. - * @class BI.PlusGroupNode - * @extends BI.NodeButton + * @class PlusGroupNode + * @extends NodeButton */ -BI.PlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.PlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-plus-group-node bi-list-item", +@shortcut() +export class PlusGroupNode extends NodeButton { + static xtype = "bi.plus_group_node"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-plus-group-node bi-list-item`, id: "", pId: "", open: false, - height: 24 + height: 24, }); - }, + } - render: function () { - var self = this, o = this.options; - this.checkbox = BI.createWidget({ + render() { + const o = this.options; + this.checkbox = createWidget({ type: "bi.tree_node_checkbox", iconHeight: o.height, - iconWidth: o.iconWrapperWidth || o.height + iconWidth: o.iconWrapperWidth || o.height, }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + this.checkbox.on(Controller.EVENT_CHANGE, (...args) => { + const [type] = args; if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); + this.setSelected(this.isSelected()); } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + this.fireEvent(Controller.EVENT_CHANGE, args); }); + return { type: "bi.vertical_adapt", columnSize: [o.iconWrapperWidth || o.height, "fill"], items: [this.checkbox, { el: { type: "bi.label", - ref: function (_ref) { - self.text = _ref; + ref: _ref => { + this.text = _ref; }, textAlign: "left", whiteSpace: "nowrap", @@ -49,31 +58,29 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, keyword: o.keyword, - py: o.py - } - }] + py: o.py, + }, + }], }; - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { - BI.PlusGroupNode.superclass.doClick.apply(this, arguments); + doClick() { + super.doClick.apply(this, arguments); this.checkbox.setSelected(this.isSelected()); - }, + } - setOpened: function (v) { - BI.PlusGroupNode.superclass.setOpened.apply(this, arguments); + setOpened(v) { + super.setOpened.apply(this, arguments); if (this.checkbox) { this.checkbox.setSelected(v); } } -}); - -BI.shortcut("bi.plus_group_node", BI.PlusGroupNode); +} diff --git a/src/case/button/node/siwtcher.tree.node.js b/src/case/button/node/siwtcher.tree.node.js index 8669f697b..46519ecb5 100644 --- a/src/case/button/node/siwtcher.tree.node.js +++ b/src/case/button/node/siwtcher.tree.node.js @@ -1,17 +1,23 @@ -BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - return BI.extend(BI.TreeNodeSwitcher.superclass._defaultConfig.apply(this, arguments), { +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend } from "../../../core"; + +@shortcut() +export class TreeNodeSwitcher extends NodeButton { + static xtype = "bi.tree_node_switcher"; + static EVENT_CHANGE = "EVENT_CHANGE"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { baseCls: "bi-tree-node-switcher", iconWidth: 24, iconHeight: 24, isFirstNode: false, isLastNode: false, - layer: 0 + layer: 0, }); - }, - - render: function () { + } + render() { const [collapse, expand] = this.getIconCls(); return { @@ -20,10 +26,10 @@ BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, { iconHeight: this.options.iconHeight, cls: this.options.open ? expand : collapse, }; - }, + } - getIconCls: function () { - var options = this.options; + getIconCls() { + const options = this.options; if (options.layer === 0 && options.isFirstNode && options.isLastNode) { // 只有一层,并且是第一个节点,并且是最后一个节点 return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type1", "tree-expand-icon-type1"]; @@ -37,23 +43,20 @@ BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, { // 其他情况 return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; } - }, + } - setOpened: function (b) { - BI.TreeNodeSwitcher.superclass.setOpened.apply(this, arguments); + setOpened(b) { + super.setOpened.apply(this, arguments); const [collapse, expand] = this.getIconCls(); if (b) { this.element.addClass(expand).removeClass(collapse); } else { this.element.addClass(collapse).removeClass(expand); } - }, - - doClick: function () { - BI.TreeNodeSwitcher.superclass.doClick.apply(this, arguments); - this.fireEvent(BI.TreeNodeSwitcher.EVENT_CHANGE, this); } -}); -BI.TreeNodeSwitcher.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.tree_node_switcher", BI.TreeNodeSwitcher); + doClick() { + super.doClick.apply(this, arguments); + this.fireEvent(TreeNodeSwitcher.EVENT_CHANGE, this); + } +} diff --git a/src/case/button/node/treenode.js b/src/case/button/node/treenode.js index c557f791c..b2977e50a 100644 --- a/src/case/button/node/treenode.js +++ b/src/case/button/node/treenode.js @@ -1,8 +1,15 @@ -BI.BasicTreeNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function (props) { - var conf = BI.BasicTreeNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-tree-node " + (props.selectable ? "bi-list-item-active" : "bi-list-item"), +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend } from "../../../core"; + +@shortcut() +export class BasicTreeNode extends NodeButton { + static xtype = "bi.tree_node"; + + _defaultConfig(props) { + const conf = super._defaultConfig.apply(this, arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-tree-node ${props.selectable ? "bi-list-item-active" : "bi-list-item"}`, id: "", pId: "", open: false, @@ -14,15 +21,15 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, { selectable: true, disabled: false, // disabled不会影响展开收起功能 }); - }, + } - render: function () { - var self = this, o = this.options; + render() { + const o = this.options; const checkbox = { type: "bi.tree_node_switcher", - __ref: function (_ref) { - self.switcher = _ref; + __ref: _ref => { + this.switcher = _ref; }, iconHeight: o.height, iconWidth: o.iconWrapperWidth || o.height, @@ -32,7 +39,7 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, { layer: o.layer, ...o.switcherIcon, stopPropagation: o.selectable, - mounted: function () { + mounted () { this.setEnable(true); }, listeners: [ @@ -42,9 +49,9 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, { if (!this.isEnabled() || o.selectable) { this.isOpened() ? this.triggerCollapse() : this.triggerExpand(); } - } + }, } - ] + ], }; return { @@ -53,12 +60,12 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, { items: [ { el: checkbox, - lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半 + lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半 }, { el: { type: "bi.label", - ref: function (_ref) { - self.text = _ref; + ref: _ref => { + this.text = _ref; }, textAlign: "left", whiteSpace: "nowrap", @@ -71,36 +78,36 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, keyword: o.keyword, - py: o.py - } + py: o.py, + }, } - ] + ], }; - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doClick: function () { + doClick() { if (this.options.selectable) { return; } - BI.BasicTreeNode.superclass.doClick.apply(this, arguments); - }, + super.doClick.apply(this, arguments); + } - setOpened: function (v) { - BI.BasicTreeNode.superclass.setOpened.apply(this, arguments); + setOpened(v) { + super.setOpened.apply(this, arguments); this.switcher.setOpened(v); - }, + } - setValue: function () { - BI.BasicTreeNode.superclass.setValue.apply(this, arguments); + setValue() { + super.setValue.apply(this, arguments); } -}); +} + -BI.shortcut("bi.tree_node", BI.BasicTreeNode); diff --git a/src/case/button/switch.js b/src/case/button/switch.js index 1ca2bd2b6..c05baa832 100644 --- a/src/case/button/switch.js +++ b/src/case/button/switch.js @@ -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"; - props: { +@shortcut() +export class Switch extends BasicButton { + static xtype = "bi.switch"; + static EVENT_CHANGE = "EVENT_CHANGE"; + + constants = { + CIRCLE_SIZE: 12, + }; + + props = { extraCls: "bi-switch", attributes: { - tabIndex: 1 + tabIndex: 1, }, height: 20, width: 44, - showTip: false - }, + showTip: false, + }; - render: function () { - var self = this, o = this.options, c = this.constants; - var tgap = (o.height - c.CIRCLE_SIZE) / 2; + render() { + const o = this.options, + c = this.constants; + const tgap = (o.height - c.CIRCLE_SIZE) / 2; + return { type: "bi.absolute", - ref: function () { - self.layout = this; + ref: _ref => { + this.layout = _ref; }, - items: [{ - el: { - type: "bi.text_button", - cls: "circle-button" + items: [ + { + el: { + type: "bi.text_button", + cls: "circle-button", + }, + width: 12, + height: 12, + top: tgap, + left: o.selected ? 28 : 4, }, - width: 12, - height: 12, - top: tgap, - 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; - } - }, { - 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; + { + type: "bi.label", + text: BI.i18nText("BI-Basic_Simple_Open"), + cls: "content-tip", + left: 8, + top: tgap - 2, + invisible: !(o.showTip && o.selected), + 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: _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); +} diff --git a/src/case/button/treeitem/item.first.treeleaf.js b/src/case/button/treeitem/item.first.treeleaf.js index 52663de39..d09376bc0 100644 --- a/src/case/button/treeitem/item.first.treeleaf.js +++ b/src/case/button/treeitem/item.first.treeleaf.js @@ -1,20 +1,27 @@ -BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.FirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { +import { BasicButton } from "../../../base/single/button/button.basic"; +import { shortcut, extend, createWidget } from "../../../core"; + +@shortcut() +export class FirstTreeLeafItem extends BasicButton { + static xtype = "bi.first_tree_leaf_item"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-first-tree-leaf-item bi-list-item-active", logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", layer: 0, - height: 24 + height: 24, }); - }, - _init: function () { - BI.FirstTreeLeafItem.superclass._init.apply(this, arguments); - var o = this.options; - this.text = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -24,76 +31,75 @@ BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, el: { type: "bi.layout", cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(), width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, - height: o.height - } + height: o.height, + }, }), { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, el: { type: "bi.layout", cls: this._getFirstLineCls(), width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - height: o.height - } + height: o.height, + }, }, { - el: this.text + el: this.text, }); - BI.createWidget(BI.extend({ - element: this + createWidget(extend({ + element: this, }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items + items, })))); - }, + } - _getBaseLineCls: function () { + _getBaseLineCls() { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { - case "solid": - return "base-solid-line-conn-background"; - default: - return "base-line-conn-background"; + case "solid": + return "base-solid-line-conn-background"; + default: + return "base-line-conn-background"; } - }, + } - _getFirstLineCls: function () { + _getFirstLineCls() { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { - case "solid": - return "first-solid-line-conn-background"; - default: - return "first-line-conn-background"; + case "solid": + return "first-solid-line-conn-background"; + default: + return "first-line-conn-background"; } - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, + doHighLight() { + this.text.doHighLight(...arguments); + } - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, + unHighLight() { + this.text.unHighLight(...arguments); + } - getId: function () { + getId() { return this.options.id; - }, + } - getPId: function () { + getPId() { return this.options.pId; } -}); +} -BI.shortcut("bi.first_tree_leaf_item", BI.FirstTreeLeafItem); \ No newline at end of file diff --git a/src/case/button/treeitem/item.icon.treeleaf.js b/src/case/button/treeitem/item.icon.treeleaf.js index 92fd5e348..280270774 100644 --- a/src/case/button/treeitem/item.icon.treeleaf.js +++ b/src/case/button/treeitem/item.icon.treeleaf.js @@ -1,33 +1,39 @@ -BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.IconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { +import { BasicButton } from "../../../base/single/button/button.basic"; +import { shortcut, extend, createWidget } from "../../../core"; + +@shortcut() +export class IconTreeLeafItem extends BasicButton { + static xtype = "bi.icon_tree_leaf_item"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-icon-tree-leaf-item bi-list-item-active", logic: { - dynamic: false + dynamic: false, }, height: 24, iconWidth: 16, iconHeight: 16, - iconCls: "" + iconCls: "", }); - }, + } - _init: function () { - BI.IconTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; + _init() { + super._init.apply(this, arguments); + const o = this.options; - var icon = BI.createWidget({ + const icon = createWidget({ type: "bi.center_adapt", width: 24, cls: o.iconCls, items: [{ type: "bi.icon", width: o.iconWidth, - height: o.iconHeight - }] + height: o.iconHeight, + }], }); - this.text = BI.createWidget({ + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -37,46 +43,44 @@ BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { width: 16, - el: icon + el: icon, }, { - el: this.text + el: this.text, }); - BI.createWidget(BI.extend({ - element: this + createWidget(BI.extend({ + element: this, }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items, - hgap: 5 + items, + hgap: 5, })))); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, + doHighLight() { + this.text.doHighLight(...arguments); + } - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, + unHighLight() { + this.text.unHighLight(...arguments); + } - getId: function () { + getId() { return this.options.id; - }, + } - getPId: function () { + getPId() { return this.options.pId; } -}); - -BI.shortcut("bi.icon_tree_leaf_item", BI.IconTreeLeafItem); \ No newline at end of file +} diff --git a/src/case/button/treeitem/item.last.treeleaf.js b/src/case/button/treeitem/item.last.treeleaf.js index 76449063e..887b95a2f 100644 --- a/src/case/button/treeitem/item.last.treeleaf.js +++ b/src/case/button/treeitem/item.last.treeleaf.js @@ -1,20 +1,27 @@ -BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.LastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { +import { BasicButton } from "../../../base/single/button/button.basic"; +import { shortcut, extend, createWidget } from "../../../core"; + +@shortcut() +export class LastTreeLeafItem extends BasicButton { + static xtype = "bi.last_tree_leaf_item"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-last-tree-leaf-item bi-list-item-active", logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", layer: 0, - height: 24 + height: 24, }); - }, - _init: function () { - BI.LastTreeLeafItem.superclass._init.apply(this, arguments); - var o = this.options; - this.text = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -24,76 +31,75 @@ BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, el: { type: "bi.layout", cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(), width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, - height: o.height - } + height: o.height, + }, }), { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, el: { type: "bi.layout", cls: this._getLastLineCls(), width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - height: o.height - } + height: o.height, + }, }, { - el: this.text + el: this.text, }); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items + createWidget(BI.extend({ + element: this, + }, BI.LogicFactory.createLogic(type, extend(o.logic, { + items, })))); - }, + } - _getBaseLineCls: function () { + _getBaseLineCls() { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { - case "solid": - return "base-solid-line-conn-background"; - default: - return "base-line-conn-background"; + case "solid": + return "base-solid-line-conn-background"; + default: + return "base-line-conn-background"; } - }, + } - _getLastLineCls: function () { + _getLastLineCls() { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { - case "solid": - return "last-solid-line-conn-background"; - default: - return "last-line-conn-background"; + case "solid": + return "last-solid-line-conn-background"; + default: + return "last-line-conn-background"; } - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, + doHighLight() { + this.text.doHighLight(...arguments); + } - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, + unHighLight() { + this.text.unHighLight(...arguments); + } - getId: function () { + getId() { return this.options.id; - }, + } - getPId: function () { + getPId() { return this.options.pId; } -}); +} -BI.shortcut("bi.last_tree_leaf_item", BI.LastTreeLeafItem); \ No newline at end of file diff --git a/src/case/button/treeitem/item.mid.treeleaf.js b/src/case/button/treeitem/item.mid.treeleaf.js index 58af36e4e..69e7bee6b 100644 --- a/src/case/button/treeitem/item.mid.treeleaf.js +++ b/src/case/button/treeitem/item.mid.treeleaf.js @@ -1,20 +1,27 @@ -BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { +import { BasicButton } from "../../../base/single/button/button.basic"; +import { shortcut, extend, createWidget } from "../../../core"; + +@shortcut() +export class MidTreeLeafItem extends BasicButton { + static xtype = "bi.mid_tree_leaf_item"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-mid-tree-leaf-item bi-list-item-active", logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", layer: 0, - height: 24 + height: 24, }); - }, - _init: function () { - BI.MidTreeLeafItem.superclass._init.apply(this, arguments); - var o = this.options; - this.text = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -24,76 +31,75 @@ BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, el: { type: "bi.layout", cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(), width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, - height: o.height - } + height: o.height, + }, }), { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, el: { type: "bi.layout", cls: this._getMidLineCls(), width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - height: o.height - } + height: o.height, + }, }, { - el: this.text + el: this.text, }); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items + createWidget(extend({ + element: this, + }, BI.LogicFactory.createLogic(type, extend(o.logic, { + items, })))); - }, + } - _getBaseLineCls: function () { + _getBaseLineCls() { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { - case "solid": - return "base-solid-line-conn-background"; - default: - return "base-line-conn-background"; + case "solid": + return "base-solid-line-conn-background"; + default: + return "base-line-conn-background"; } - }, + } - _getMidLineCls: function () { + _getMidLineCls() { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { - case "solid": - return "mid-solid-line-conn-background"; - default: - return "mid-line-conn-background"; + case "solid": + return "mid-solid-line-conn-background"; + default: + return "mid-line-conn-background"; } - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark () { + this.text.unRedMark(...arguments); + } - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, + doHighLight() { + this.text.doHighLight(...arguments); + } - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, + unHighLight() { + this.text.unHighLight(...arguments); + } - getId: function () { + getId() { return this.options.id; - }, + } - getPId: function () { + getPId() { return this.options.pId; } -}); +} -BI.shortcut("bi.mid_tree_leaf_item", BI.MidTreeLeafItem); \ No newline at end of file diff --git a/src/case/button/treeitem/item.multilayer.icon.treeleaf.js b/src/case/button/treeitem/item.multilayer.icon.treeleaf.js index 363a348c0..2d5e043fb 100644 --- a/src/case/button/treeitem/item.multilayer.icon.treeleaf.js +++ b/src/case/button/treeitem/item.multilayer.icon.treeleaf.js @@ -1,22 +1,29 @@ +import { BasicButton } from "../../../base/single/button/button.basic"; +import { shortcut, extend, createWidget, Controller, makeArray } from "../../../core"; + /** * @class BI.MultiLayerIconTreeLeafItem * @extends BI.BasicButton */ -BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiLayerIconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { +@shortcut() +export class MultiLayerIconTreeLeafItem extends BasicButton { + static xtype = "bi.multilayer_icon_tree_leaf_item"; + + _defaultConfig() { + return extend(super._defaultConfig(arguments), { extraCls: "bi-multilayer-icon-tree-leaf-item bi-list-item-active", layer: 0, height: 24, iconCls: "", iconHeight: 16, - iconWidth: 16 + iconWidth: 16, }); - }, - _init: function () { - BI.MultiLayerIconTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.item = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.item = createWidget({ type: "bi.icon_tree_leaf_item", cls: "bi-list-item-none", iconCls: o.iconCls, @@ -30,69 +37,70 @@ BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { py: o.py, keyword: o.keyword, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, }); - this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + this.item.on(Controller.EVENT_CHANGE, (...args) => { + const [type] = args; if (type === BI.Events.CLICK) {// 本身实现click功能 return; } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + this.fireEvent(Controller.EVENT_CHANGE, args); }); - var items = []; - BI.count(0, o.layer, function () { + const items = []; + BI.count(0, o.layer, () => { items.push({ type: "bi.layout", width: 15, - height: o.height + height: o.height, }); }); items.push(this.item); - BI.createWidget({ + createWidget({ type: "bi.horizontal_adapt", element: this, - columnSize: BI.makeArray(o.layer, 15), - items: items + columnSize: makeArray(o.layer, 15), + items, }); - }, - - doRedMark: function () { - this.item.doRedMark.apply(this.item, arguments); - }, + } - unRedMark: function () { - this.item.unRedMark.apply(this.item, arguments); - }, + doRedMark () { + this.item.doRedMark(...arguments); + } - doHighLight: function () { - this.item.doHighLight.apply(this.item, arguments); - }, + unRedMark () { + this.item.unRedMark(...arguments); + } + + doHighLight() { + this.item.doHighLight(...arguments); + } - unHighLight: function () { - this.item.unHighLight.apply(this.item, arguments); - }, + unHighLight () { + this.item.unHighLight(...arguments); + } - getId: function () { + getId () { return this.options.id; - }, + } - getPId: function () { + getPId () { return this.options.pId; - }, + } - doClick: function () { + doClick () { BI.MultiLayerIconTreeLeafItem.superclass.doClick.apply(this, arguments); this.item.setSelected(this.isSelected()); - }, + } - setSelected: function (v) { + setSelected(v) { BI.MultiLayerIconTreeLeafItem.superclass.setSelected.apply(this, arguments); this.item.setSelected(v); - }, + } - getValue: function () { + getValue() { return this.options.value; } -}); +} + -BI.shortcut("bi.multilayer_icon_tree_leaf_item", BI.MultiLayerIconTreeLeafItem); diff --git a/src/case/button/treeitem/item.root.treeleaf.js b/src/case/button/treeitem/item.root.treeleaf.js index f4637afdc..f6fdd9c81 100644 --- a/src/case/button/treeitem/item.root.treeleaf.js +++ b/src/case/button/treeitem/item.root.treeleaf.js @@ -1,22 +1,27 @@ -BI.RootTreeLeafItem = BI.inherit(BI.BasicButton, { - props: { +import { BasicButton } from "../../../base/single/button/button.basic"; +import { shortcut, extend } from "../../../core"; + +@shortcut() +export class RootTreeLeafItem extends BasicButton { + static xtype = "bi.root_tree_leaf_item"; + + props = { baseCls: "bi-root-tree-leaf-item bi-list-item-active", logic: { - dynamic: false + dynamic: false, }, id: "", pId: "", layer: 0, - height: 24 - }, + height: 24, + } - render: function () { - var self = this; - var o = this.options; - var text = { + render() { + const o = this.options; + const text = { type: "bi.label", - ref: function (_ref) { - self.text = _ref; + ref: _ref => { + this.text = _ref; }, textAlign: "left", whiteSpace: "nowrap", @@ -26,49 +31,48 @@ BI.RootTreeLeafItem = BI.inherit(BI.BasicButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }; - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, el: { type: "bi.layout", width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - height: o.height - } + height: o.height, + }, }, { - el: text + el: text, }); - return BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items + return BI.LogicFactory.createLogic(type, extend(o.logic, { + items, })); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, + doHighLight() { + this.text.doHighLight(...arguments); + } - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, + unHighLight() { + this.text.unHighLight(...arguments); + } - getId: function () { + getId() { return this.options.id; - }, + } - getPId: function () { + getPId() { return this.options.pId; } -}); +} -BI.shortcut("bi.root_tree_leaf_item", BI.RootTreeLeafItem); diff --git a/src/case/button/treeitem/item.treetextleaf.js b/src/case/button/treeitem/item.treetextleaf.js index 872663fd0..2dca402e8 100644 --- a/src/case/button/treeitem/item.treetextleaf.js +++ b/src/case/button/treeitem/item.treetextleaf.js @@ -1,25 +1,32 @@ +import { BasicButton } from "../../../base/single/button/button.basic"; +import { shortcut, extend, createWidget } from "../../../core"; + /** * 树叶子节点 * Created by GUY on 2015/9/6. * @class BI.TreeTextLeafItem * @extends BI.BasicButton */ -BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.TreeTextLeafItem.superclass._defaultConfig.apply(this, arguments), { +@shortcut() +export class TreeTextLeafItem extends BasicButton { + static xtype = "bi.tree_text_leaf_item"; + + _defaultConfig() { + return extend(super._defaultConfig.apply(this, arguments), { extraCls: "bi-tree-text-leaf-item bi-list-item-active", id: "", pId: "", height: 24, hgap: 0, lgap: 0, - rgap: 0 + rgap: 0, }); - }, - _init: function () { - BI.TreeTextLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.text = BI.createWidget({ + } + + _init() { + super._init.apply(this, arguments); + const o = this.options; + this.text = createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", @@ -31,40 +38,39 @@ BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, { text: o.text, value: o.value, py: o.py, - keyword: o.keyword + keyword: o.keyword, }); - BI.createWidget({ + createWidget({ type: "bi.htape", element: this, items: [{ - el: this.text - }] + el: this.text, + }], }); - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, + doHighLight() { + this.text.doHighLight(...arguments); + } - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, + unHighLight() { + this.text.unHighLight(...arguments); + } - getId: function () { + getId() { return this.options.id; - }, + } - getPId: function () { + getPId() { return this.options.pId; } -}); +} -BI.shortcut("bi.tree_text_leaf_item", BI.TreeTextLeafItem); diff --git a/src/case/button/treeitem/treeitem.js b/src/case/button/treeitem/treeitem.js index 4ab512a29..c6235facd 100644 --- a/src/case/button/treeitem/treeitem.js +++ b/src/case/button/treeitem/treeitem.js @@ -1,8 +1,15 @@ -BI.BasicTreeItem = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.BasicTreeItem.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-tree-item bi-list-item-active", +import { NodeButton } from "../../../base/single/button/button.node"; +import { shortcut, extend } from "../../../core"; + +@shortcut() +export class BasicTreeItem extends NodeButton { + static xtype = "bi.tree_item"; + + _defaultConfig() { + const conf = super._defaultConfig(arguments); + + return extend(conf, { + baseCls: `${conf.baseCls || ""} bi-tree-item bi-list-item-active`, id: "", pId: "", height: 24, @@ -10,10 +17,10 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, { isFirstNode: false, isLastNode: false, }); - }, + } - render: function () { - var self = this, o = this.options; + render() { + const o = this.options; return { type: "bi.vertical_adapt", @@ -26,13 +33,13 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, { width: o.height, cls: this.getLineCls(), }, - lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半 + lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半 }, { el: { type: "bi.label", - ref: function (_ref) { - self.text = _ref; + ref: _ref => { + this.text = _ref; }, textAlign: "left", whiteSpace: "nowrap", @@ -45,15 +52,15 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, keyword: o.keyword, - py: o.py + py: o.py, }, } - ] + ], }; - }, + } - getLineCls: function () { - var options = this.options; + getLineCls() { + const options = this.options; if (options.layer === 0 && options.isFirstNode && options.isLastNode) { return ""; } else if (options.layer === 0 && options.isFirstNode) { @@ -63,24 +70,21 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, { } else { return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-mid-solid-line-conn-background" : "mid-line-conn-background"; } - }, + } - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, + doRedMark() { + this.text.doRedMark(...arguments); + } - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, + unRedMark() { + this.text.unRedMark(...arguments); + } - getId: function () { + getId() { return this.options.id; - }, + } - getPId: function () { + getPId() { return this.options.pId; } - -}); - -BI.shortcut("bi.tree_item", BI.BasicTreeItem); +} diff --git a/src/case/index.js b/src/case/index.js new file mode 100644 index 000000000..5e8b11baf --- /dev/null +++ b/src/case/index.js @@ -0,0 +1,7 @@ +import * as button from "./button"; + +Object.assign(BI, { + ...button, +}); + +export * from "./button"; From 4addb6aefd86ad8dc1a9cce735b26e7074951e3c Mon Sep 17 00:00:00 2001 From: "Zhenfei.Li" Date: Fri, 6 Jan 2023 11:16:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?KERNEL-14035=20refactor:=20constant?= =?UTF-8?q?=E3=80=81element=E3=80=81logic=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E5=8F=8A=E6=95=B4=E4=BD=93eslint=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/1.pane.js | 12 +- src/core/2.base.js | 3 +- src/core/action/action.js | 15 +- src/core/action/action.show.js | 17 +- src/core/action/index.js | 2 +- src/core/behavior/0.behavior.js | 24 +- src/core/behavior/behavior.highlight.js | 26 +- src/core/behavior/behavior.redmark.js | 21 +- src/core/behavior/index.js | 27 +- src/core/constant/events.js | 879 ++++++++++---------- src/core/constant/index.js | 2 + src/core/constant/var.js | 327 ++++---- src/core/controller/0.controller.js | 4 +- src/core/controller/controller.broadcast.js | 11 +- src/core/controller/controller.bubbles.js | 38 +- src/core/controller/controller.drawer.js | 38 +- src/core/controller/controller.layer.js | 55 +- src/core/controller/controller.masker.js | 2 +- src/core/controller/controller.popover.js | 46 +- src/core/controller/controller.resizer.js | 21 +- src/core/controller/controller.tooltips.js | 40 +- src/core/controller/index.js | 2 +- src/core/element/element.js | 124 +-- src/core/element/index.js | 21 +- src/core/element/plugins/attr.js | 45 +- src/core/element/plugins/class.js | 38 +- src/core/element/plugins/css.js | 40 +- src/core/element/plugins/data.js | 25 +- src/core/element/plugins/empty.js | 17 +- src/core/element/plugins/event.js | 63 +- src/core/element/plugins/html.js | 32 +- src/core/element/plugins/index.js | 58 +- src/core/element/plugins/keywordMark.js | 11 +- src/core/element/plugins/renderToHtml.js | 124 +-- src/core/element/plugins/renderToString.js | 96 ++- src/core/element/plugins/text.js | 20 +- src/core/element/plugins/val.js | 18 +- src/core/index.js | 9 +- src/core/listener/listener.show.js | 20 +- src/core/loader/loader.style.js | 9 +- src/core/logic/index.js | 83 ++ src/core/logic/logic.js | 82 +- src/core/logic/logic.layout.js | 109 ++- 43 files changed, 1377 insertions(+), 1279 deletions(-) create mode 100644 src/core/constant/index.js create mode 100644 src/core/logic/index.js diff --git a/src/base/1.pane.js b/src/base/1.pane.js index ebbaac636..1e6bf38b5 100644 --- a/src/base/1.pane.js +++ b/src/base/1.pane.js @@ -33,7 +33,7 @@ export class Pane extends Widget { element: this, items: [{ type: "bi.label", - ref: (_ref) => { + ref: _ref => { this._tipText = _ref; }, cls: "bi-tips", @@ -54,15 +54,15 @@ export class Pane extends Widget { // loading的异步情况下由loaded后对面板的populate的时机决定 this.setTipVisible(false); if (o.overlap === true) { - if (!Layers.has(this.getName() + "-loading")) { + if (!Layers.has(`${this.getName()}-loading`)) { createWidget({ type: "bi.center_adapt", cls: "loading-container", items: this._getLoadingTipItems(loadingAnimation), - element: Layers.make(this.getName() + "-loading", this), + element: Layers.make(`${this.getName()}-loading`, this), }); } - Layers.show(this.getName() + "-loading"); + Layers.show(`${this.getName()}-loading`); } else if (isNull(this._loading)) { loadingAnimation.element.css("zIndex", 1); createWidget({ @@ -94,7 +94,7 @@ export class Pane extends Widget { return [{ type: "bi.vertical", - ref: (_ref) => { + ref: _ref => { this._loading = _ref; }, items: loadingTipItems, @@ -102,7 +102,7 @@ export class Pane extends Widget { } loaded() { - Layers.remove(this.getName() + "-loading"); + Layers.remove(`${this.getName()}-loading`); this._loading && this._loading.destroy(); this.options.onLoaded(); this.fireEvent(Pane.EVENT_LOADED); diff --git a/src/core/2.base.js b/src/core/2.base.js index 4fe7583de..003839ec4 100644 --- a/src/core/2.base.js +++ b/src/core/2.base.js @@ -488,7 +488,7 @@ BI._.each([ "keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn", "defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty", "isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite", - "isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep" + "isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep", "pickBy" ], name => { BI[name] = _apply(name); }); @@ -526,6 +526,7 @@ export const isNaN = BI.isNaN; export const isUndefined = BI.isUndefined; export const zipObject = BI.zipObject; export const cloneDeep = BI.cloneDeep; +export const pickBy = BI.pickBy; BI._.each(["mapObject", "findKey", "pick", "omit", "tap"], name => { BI[name] = _applyFunc(name); diff --git a/src/core/action/action.js b/src/core/action/action.js index b87ea1e21..bfe20fd80 100644 --- a/src/core/action/action.js +++ b/src/core/action/action.js @@ -6,10 +6,11 @@ * @abstract */ import { OB } from "../3.ob"; + export class Action extends OB { props = { src: null, - tar: null + tar: null, }; actionPerformed(src, tar, callback) { @@ -20,15 +21,3 @@ export class Action extends OB { } } - -BI.ActionFactory = { - createAction: function (key, options) { - var action; - switch (key) { - case "show": - action = BI.ShowAction; - break; - } - return new action(options); - } -}; diff --git a/src/core/action/action.show.js b/src/core/action/action.show.js index 1084ec542..8ed0162f1 100644 --- a/src/core/action/action.show.js +++ b/src/core/action/action.show.js @@ -1,10 +1,9 @@ /** * guy * 由一个元素切换到另一个元素的行为 - * @class BI.ShowAction - * @extends BI.Action */ import { Action } from "./action"; + export class ShowAction extends Action { actionPerformed(src, tar, callback) { tar = tar || this.options.tar; @@ -18,3 +17,17 @@ export class ShowAction extends Action { callback && callback(); } } + +export const ActionFactory = { + createAction (key, options) { + let Action; + switch (key) { + case "show": + Action = ShowAction; + break; + default: + } + + return new Action(options); + }, +}; diff --git a/src/core/action/index.js b/src/core/action/index.js index f82304e43..c73457134 100644 --- a/src/core/action/index.js +++ b/src/core/action/index.js @@ -1,2 +1,2 @@ export { Action } from "./action"; -export { ShowAction } from "./action.show"; \ No newline at end of file +export { ShowAction, ActionFactory } from "./action.show"; diff --git a/src/core/behavior/0.behavior.js b/src/core/behavior/0.behavior.js index 5adc59d3d..22496e242 100644 --- a/src/core/behavior/0.behavior.js +++ b/src/core/behavior/0.behavior.js @@ -1,30 +1,14 @@ -BI.BehaviorFactory = { - createBehavior: function (key, options) { - var behavior; - switch (key) { - case "highlight": - behavior = BI.HighlightBehavior; - break; - case "redmark": - behavior = BI.RedMarkBehavior; - break; - } - return new behavior(options); - } -}; - /** * guy * 行为控件 - * @class BI.Behavior - * @extends BI.OB */ - import { OB } from "../3.ob"; +import { extend } from "../2.base"; + export class Behavior extends OB { _defaultConfig() { - return BI.extend(super._defaultConfig(arguments), { - rule: () => true + return extend(super._defaultConfig(arguments), { + rule: () => true, }); } diff --git a/src/core/behavior/behavior.highlight.js b/src/core/behavior/behavior.highlight.js index 1c0676b90..f66355c65 100644 --- a/src/core/behavior/behavior.highlight.js +++ b/src/core/behavior/behavior.highlight.js @@ -1,33 +1,33 @@ /** * guy - * - * @class BI.HighlightBehavior - * @extends BI.Behavior */ import { Behavior } from "./0.behavior"; +import { isFunction, each } from "../2.base"; +import { Single } from "../../base"; + export class HighlightBehavior extends Behavior { doBehavior(items) { const args = Array.prototype.slice.call(arguments, 1), - o = this.options; - BI.each(items, function (i, item) { - if (item instanceof BI.Single) { - const rule = o.rule(item.getValue(), item); + { rule } = this.options; + each(items, (i, item) => { + if (item instanceof Single) { + const rules = rule(item.getValue(), item); function doBe (run) { if (run === true) { - item.doHighLight && item.doHighLight.apply(item, args); + item.doHighLight && item.doHighLight(...args); } else { - item.unHighLight && item.unHighLight.apply(item, args); + item.unHighLight && item.unHighLight(...args); } } - if (BI.isFunction(rule)) { - rule(doBe); + if (isFunction(rules)) { + rules(doBe); } else { - doBe(rule); + doBe(rules); } } else { - item.doBehavior && item.doBehavior.apply(item, args); + item.doBehavior && item.doBehavior(...args); } }); } diff --git a/src/core/behavior/behavior.redmark.js b/src/core/behavior/behavior.redmark.js index 5beb0797f..7ca2b9df2 100644 --- a/src/core/behavior/behavior.redmark.js +++ b/src/core/behavior/behavior.redmark.js @@ -1,23 +1,24 @@ /** * guy * 标红行为 - * @class BI.RedMarkBehavior - * @extends BI.Behavior */ import { Behavior } from "./0.behavior"; +import { each } from "../2.base"; +import { Single } from "../../base"; + export class RedMarkBehavior extends Behavior { doBehavior(items) { - const args = Array.prototype.slice.call(arguments, 1), - o = this.options; - BI.each(items, function (i, item) { - if(item instanceof BI.Single) { - if (o.rule(item.getValue(), item)) { - item.doRedMark && item.doRedMark.apply(item, args); + const args = Array.prototype.slice.call(arguments, 1), + { rule } = this.options; + each(items, (i, item) => { + if (item instanceof Single) { + if (rule(item.getValue(), item)) { + item.doRedMark && item.doRedMark(...args); } else { - item.doRedMark && item.unRedMark.apply(item, args); + item.doRedMark && item.unRedMark(...args); } } else { - item.doBehavior && item.doBehavior.apply(item, args); + item.doBehavior && item.doBehavior(...args); } }); } diff --git a/src/core/behavior/index.js b/src/core/behavior/index.js index ee2ae69ed..52d5f6499 100644 --- a/src/core/behavior/index.js +++ b/src/core/behavior/index.js @@ -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"; \ No newline at end of file +export { + HighlightBehavior, + RedMarkBehavior +}; diff --git a/src/core/constant/events.js b/src/core/constant/events.js index 76eb97021..656f2e9ca 100644 --- a/src/core/constant/events.js +++ b/src/core/constant/events.js @@ -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", +}; diff --git a/src/core/constant/index.js b/src/core/constant/index.js new file mode 100644 index 000000000..205529687 --- /dev/null +++ b/src/core/constant/index.js @@ -0,0 +1,2 @@ +export { Events } from "./events"; +export * from "./var"; diff --git a/src/core/constant/var.js b/src/core/constant/var.js index f9acb8b30..a109324c0 100644 --- a/src/core/constant/var.js +++ b/src/core/constant/var.js @@ -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() {} diff --git a/src/core/controller/0.controller.js b/src/core/controller/0.controller.js index 0841a9358..7cda6a2a5 100644 --- a/src/core/controller/0.controller.js +++ b/src/core/controller/0.controller.js @@ -2,11 +2,9 @@ * guy * 控制器 * Controller层超类 - * @class BI.Controller - * @extends BI.OB - * @abstract */ import { OB } from "../3.ob"; + export class Controller extends OB { static EVENT_CHANGE = "__EVENT_CHANGE__"; } diff --git a/src/core/controller/controller.broadcast.js b/src/core/controller/controller.broadcast.js index f0cc90c8d..3f1eb3035 100644 --- a/src/core/controller/controller.broadcast.js +++ b/src/core/controller/controller.broadcast.js @@ -2,9 +2,10 @@ * 广播 * * Created by GUY on 2015/12/23. - * @class */ import { Controller } from "./0.controller"; +import { each, remove } from "../2.base"; + export class BroadcastController extends Controller { init() { this._broadcasts = {}; @@ -15,23 +16,25 @@ export class BroadcastController extends Controller { this._broadcasts[name] = []; } this._broadcasts[name].push(fn); + return () => this.remove(name, fn); } send(name) { const args = [].slice.call(arguments, 1); - BI.each(this._broadcasts[name], (i, fn) => fn.apply(null, args)); + each(this._broadcasts[name], (i, fn) => fn(...args)); } remove(name, fn) { if (fn) { - BI.remove(this._broadcasts[name], (index, cb) => fn === cb); + remove(this._broadcasts[name], (index, cb) => fn === cb); if (this._broadcasts[name].length === 0) { delete this._broadcasts[name]; } } else { delete this._broadcasts[name]; } + return this; } -} \ No newline at end of file +} diff --git a/src/core/controller/controller.bubbles.js b/src/core/controller/controller.bubbles.js index e596eac60..64147fdcc 100644 --- a/src/core/controller/controller.bubbles.js +++ b/src/core/controller/controller.bubbles.js @@ -3,9 +3,11 @@ * 控制气泡图的显示方向 * * Created by GUY on 2015/8/21. - * @class */ import { Controller } from "./0.controller"; +import { isNotNull, each } from "../2.base"; +import { createWidget } from "../5.inject"; + export class BubblesController extends Controller { init() { this.storeBubbles = {}; @@ -30,12 +32,12 @@ export class BubblesController extends Controller { // const fixed = opt.fixed !== false; if (!this.storeBubbles[name]) { - this.storeBubbles[name] = BI.createWidget({ + this.storeBubbles[name] = createWidget({ type: "bi.text", - cls: "bi-bubble" + " bubble-" + level, - text: text, + cls: `bi-bubble bubble-${level}`, + text, hgap: 5, - height: 18 + height: 18, }); } const bubble = this.storeBubbles[name]; @@ -43,14 +45,14 @@ export class BubblesController extends Controller { bubble.setText(text); } - BI.createWidget({ + createWidget({ type: "bi.default", element: container, items: [ { - el: bubble + el: bubble, } - ] + ], }); if (this.storePoppers[name]) { this.storePoppers[name].destroy(); @@ -59,32 +61,34 @@ export class BubblesController extends Controller { placement: ({ left: "top-start", center: "top", - right: "top-end" + right: "top-end", })[offsetStyle], strategy: "fixed", modifiers: [ { name: "offset", options: { - offset: [adjustXOffset, adjustYOffset] - } + offset: [adjustXOffset, adjustYOffset], + }, }, { name: "preventOverflow", - enabled: false + enabled: false, } - ] + ], }); + return this; } hide(name) { this.remove(name); + return this; } has(name) { - return this.storeBubbles[name] != null; + return isNotNull(this.storeBubbles[name]); } remove(name) { @@ -94,14 +98,16 @@ export class BubblesController extends Controller { this.storeBubbles[name].destroy(); this.storePoppers[name] && this.storePoppers[name].destroy(); delete this.storeBubbles[name]; + return this; } removeAll() { - BI.each(this.storeBubbles, (name, bubble) => bubble.destroy()); - BI.each(this.storePoppers, (name, popper) => popper.destroy()); + each(this.storeBubbles, (name, bubble) => bubble.destroy()); + each(this.storePoppers, (name, popper) => popper.destroy()); this.storeBubbles = {}; this.storePoppers = {}; + return this; } } diff --git a/src/core/controller/controller.drawer.js b/src/core/controller/controller.drawer.js index 51a80b734..806d8c67b 100644 --- a/src/core/controller/controller.drawer.js +++ b/src/core/controller/controller.drawer.js @@ -1,10 +1,11 @@ /** * guy * popover弹出层控制器, z-index在100w层级 - * @class BI.popoverController - * @extends BI.Controller */ import { Controller } from "./0.controller"; +import { each, isNotNull } from "../2.base"; +import { createWidget } from "../5.inject"; + export class DrawerController extends Controller { constructor() { super(); @@ -13,7 +14,7 @@ export class DrawerController extends Controller { } props = { modal: true, // 模态窗口 - render: "body" + render: "body", } init() { @@ -28,15 +29,15 @@ export class DrawerController extends Controller { if (this.has(name)) { return this; } - const popover = BI.createWidget(options || {}, { - type: "bi.drawer" + const popover = createWidget(options || {}, { + type: "bi.drawer", }, context); this.add(name, popover, options, context); + return this; } open(name) { - const o = this.options; if (!this.has(name)) { return this; } @@ -59,6 +60,7 @@ export class DrawerController extends Controller { const popover = this.get(name); popover.show && popover.show(); } + return this; } @@ -71,6 +73,7 @@ export class DrawerController extends Controller { this.floatContainer[name].invisible(); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); } + return this; } @@ -91,23 +94,23 @@ export class DrawerController extends Controller { if (this.has(name)) { return this; } - this.floatContainer[name] = BI.createWidget({ + this.floatContainer[name] = createWidget({ type: "bi.absolute", cls: "bi-popup-view", items: [{ - el: (this.floatLayer[name] = BI.createWidget({ + el: (this.floatLayer[name] = createWidget({ type: "bi.absolute", - items: [popover] + items: [popover], }, context)), left: 0, right: 0, top: 0, - bottom: 0 - }] + bottom: 0, + }], }); this.floatManager[name] = popover; popover.on(BI.Drawer.EVENT_CLOSE, () => this.close(name)); - BI.createWidget({ + createWidget({ type: "bi.absolute", element: options.container || this.options.render, items: [{ @@ -115,9 +118,10 @@ export class DrawerController extends Controller { left: 0, right: 0, top: 0, - bottom: 0 - }] + bottom: 0, + }], }); + return this; } @@ -126,7 +130,7 @@ export class DrawerController extends Controller { } has(name) { - return BI.isNotNull(this.floatManager[name]); + return isNotNull(this.floatManager[name]); } remove(name) { @@ -140,11 +144,12 @@ export class DrawerController extends Controller { delete this.zindexMap[name]; delete this.floatContainer[name]; delete this.floatOpened[name]; + return this; } removeAll() { - BI.each(this.floatContainer, (name, container) => { + each(this.floatContainer, (name, container) => { container.destroy(); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); }); @@ -153,6 +158,7 @@ export class DrawerController extends Controller { this.floatContainer = {}; this.floatOpened = {}; this.zindexMap = {}; + return this; } } diff --git a/src/core/controller/controller.layer.js b/src/core/controller/controller.layer.js index 6356588ab..eb47237e1 100644 --- a/src/core/controller/controller.layer.js +++ b/src/core/controller/controller.layer.js @@ -2,9 +2,12 @@ * 弹出层面板控制器, z-index在10w层级 * * Created by GUY on 2015/6/24. - * @class */ import { Controller } from "./0.controller"; +import { isNull, isNotNull, each, keys, isWidget, isNotEmptyString, extend } from "../2.base"; +import { Widget } from "../4.widget"; +import { createWidget } from "../5.inject"; + export class LayerController extends Controller { constructor() { super(); @@ -12,7 +15,7 @@ export class LayerController extends Controller { } props = { - render: "body" + render: "body", } init() { @@ -22,11 +25,11 @@ export class LayerController extends Controller { } _initResizer() { - this.resizer = BI.Resizers.add("layerController" + BI.uniqueId(), BI.bind(this._resize, this)); + this.resizer = BI.Resizers.add(`layerController${BI.uniqueId()}`, BI.bind(this._resize, this)); } _resize() { - BI.each(this.layouts, function (i, layer) { + each(this.layouts, (i, layer) => { if (layer.element.is(":visible")) { layer.element.trigger("__resize__"); } @@ -34,37 +37,38 @@ export class LayerController extends Controller { } make(name, container, op, context) { - if (BI.isWidget(container)) { + if (isWidget(container)) { op = op || {}; op.container = container; } else { context = op; op = container; } + return this.create(name, null, op, context); } create(name, from, op, context) { - BI.isNull(this.resizer) && this._initResizer(); + isNull(this.resizer) && this._initResizer(); if (this.has(name)) { return this.get(name); } op || (op = {}); const offset = op.offset || {}; let w = from; - if (BI.isWidget(from)) { + if (isWidget(from)) { w = from.element; } - if (BI.isNotEmptyString(w)) { - w = BI.Widget._renderEngine.createElement(w); + if (isNotEmptyString(w)) { + w = Widget._renderEngine.createElement(w); } if (this.has(name)) { return this.get(name); } - const widget = BI.createWidget((op.render || {}), BI.extend({ - type: "bi.layout" + const widget = createWidget((op.render || {}), extend({ + type: "bi.layout", }, op), context); - const layout = BI.createWidget({ + const layout = createWidget({ type: "bi.absolute", invisible: true, items: [ @@ -73,11 +77,11 @@ export class LayerController extends Controller { left: 0, right: 0, top: 0, - bottom: 0 + bottom: 0, } - ] + ], }, context); - BI.createWidget({ + createWidget({ type: "bi.absolute", element: op.container || this.options.render, items: [ @@ -86,20 +90,19 @@ export class LayerController extends Controller { left: offset.left || 0, right: offset.right || 0, top: offset.top || 0, - bottom: offset.bottom || 0 + bottom: offset.bottom || 0, } - ] + ], }); if (w) { layout.element.addClass("bi-popup-view"); function getComputedPosition() { - - var css = { + const css = { left: w.offset().left + (offset.left || 0), top: w.offset().top + (offset.top || 0), width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "", - height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || "" + height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || "", }; const { top, left, scaleY, scaleX } = BI.DOM.getPositionRelativeContainingBlockRect(layout.element[0]); @@ -112,12 +115,13 @@ export class LayerController extends Controller { layout.element.css(getComputedPosition()); - layout.element.on("__resize__", function () { + layout.element.on("__resize__", () => { w.is(":visible") && layout.element.css(getComputedPosition()); }); } this.add(name, widget, layout); + return widget; } @@ -127,6 +131,7 @@ export class LayerController extends Controller { } this._getLayout(name).visible(); this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__"); + return this; } @@ -136,6 +141,7 @@ export class LayerController extends Controller { } this._getLayout(name).invisible(); this._getLayout(name).element.hide(0, callback); + return this; } @@ -151,6 +157,7 @@ export class LayerController extends Controller { this.layerManager[name] = layer; this.layouts[name] = layout; layout.element.css("z-index", this.zindex++); + return this; } @@ -163,7 +170,7 @@ export class LayerController extends Controller { } has(name) { - return this.layerManager[name] != null; + return isNotNull(this.layerManager[name]); } remove(name) { @@ -174,16 +181,18 @@ export class LayerController extends Controller { this.layouts[name].destroy(); delete this.layerManager[name]; delete this.layouts[name]; + return this; } removeAll() { - BI.each(BI.keys(this.layerManager), (index, name) => { + each(keys(this.layerManager), (index, name) => { this.layerManager[name].destroy(); this.layouts[name].destroy(); }); this.layerManager = {}; this.layouts = {}; + return this; } } diff --git a/src/core/controller/controller.masker.js b/src/core/controller/controller.masker.js index 7ff0532bc..6a2fa10d6 100644 --- a/src/core/controller/controller.masker.js +++ b/src/core/controller/controller.masker.js @@ -2,9 +2,9 @@ * 遮罩面板, z-index在1亿层级 * * Created by GUY on 2015/6/24. - * @class */ import { LayerController } from "./controller.layer"; + export class MaskersController extends LayerController { init() { super.init(arguments); diff --git a/src/core/controller/controller.popover.js b/src/core/controller/controller.popover.js index dc8e6a14d..9d6bc9700 100644 --- a/src/core/controller/controller.popover.js +++ b/src/core/controller/controller.popover.js @@ -1,10 +1,12 @@ /** * guy * popover弹出层控制器, z-index在100w层级 - * @class BI.popoverController - * @extends BI.Controller */ import { Controller } from "./0.controller"; +import { isNotNull, each } from "../2.base"; +import { Widget } from "../4.widget"; +import { createWidget } from "../5.inject"; + export class PopoverController extends Controller { constructor() { super(); @@ -14,7 +16,7 @@ export class PopoverController extends Controller { props = { modal: true, // 模态窗口 - render: "body" + render: "body", } init() { @@ -30,10 +32,11 @@ export class PopoverController extends Controller { if (this.has(name)) { return this; } - const popover = BI.createWidget(options || {}, { - type: "bi.popover" + const popover = createWidget(options || {}, { + type: "bi.popover", }, context); this.add(name, popover, options, context); + return this; } @@ -52,8 +55,8 @@ export class PopoverController extends Controller { this.floatContainer[name].visible(); const popover = this.get(name); popover.show && popover.show(); - const W = BI.Widget._renderEngine.createElement(this.options.render).width(), - H = BI.Widget._renderEngine.createElement(this.options.render).height(); + const W = Widget._renderEngine.createElement(this.options.render).width(), + H = Widget._renderEngine.createElement(this.options.render).height(); const w = popover.element.width(), h = popover.element.height(); let left = (W - w) / 2, top = (H - h) / 2; if (left < 0) { @@ -64,10 +67,11 @@ export class PopoverController extends Controller { } popover.element.css({ // 这里直接用px就可以 - left: left + "px", - top: top + "px" + left: `${left}px`, + top: `${top}px`, }); } + return this; } @@ -80,6 +84,7 @@ export class PopoverController extends Controller { this.floatContainer[name].invisible(); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); } + return this; } @@ -100,23 +105,23 @@ export class PopoverController extends Controller { if (this.has(name)) { return this; } - this.floatContainer[name] = BI.createWidget({ + this.floatContainer[name] = createWidget({ type: "bi.absolute", cls: "bi-popup-view", items: [{ - el: (this.floatLayer[name] = BI.createWidget({ + el: (this.floatLayer[name] = createWidget({ type: "bi.absolute", - items: [popover] + items: [popover], }, context)), left: 0, right: 0, top: 0, - bottom: 0 - }] + bottom: 0, + }], }); this.floatManager[name] = popover; popover.on(BI.Popover.EVENT_CLOSE, () => this.close(name)); - BI.createWidget({ + createWidget({ type: "bi.absolute", element: options.container || this.options.render, items: [{ @@ -124,9 +129,10 @@ export class PopoverController extends Controller { left: 0, right: 0, top: 0, - bottom: 0 - }] + bottom: 0, + }], }); + return this; } @@ -135,7 +141,7 @@ export class PopoverController extends Controller { } has(name) { - return BI.isNotNull(this.floatManager[name]); + return isNotNull(this.floatManager[name]); } remove(name) { @@ -149,11 +155,12 @@ export class PopoverController extends Controller { delete this.zindexMap[name]; delete this.floatContainer[name]; delete this.floatOpened[name]; + return this; } removeAll() { - BI.each(this.floatContainer, (name, container) => { + each(this.floatContainer, (name, container) => { container.destroy(); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); }); @@ -162,6 +169,7 @@ export class PopoverController extends Controller { this.floatContainer = {}; this.floatOpened = {}; this.zindexMap = {}; + return this; } diff --git a/src/core/controller/controller.resizer.js b/src/core/controller/controller.resizer.js index 5b8c400b8..e14ee1ad0 100644 --- a/src/core/controller/controller.resizer.js +++ b/src/core/controller/controller.resizer.js @@ -2,49 +2,53 @@ * window.resize 控制器 * * Created by GUY on 2015/6/24. - * @class */ import { Controller } from "./0.controller"; -export class ResizeController extends Controller { +import { isNull, each, debounce, isNotNull, isFunction } from "../2.base"; +import { Widget } from "../4.widget"; +export class ResizeController extends Controller { init() { this.resizerManger = {}; } _initResizeListener() { - this.resizeHandler = BI.debounce((ev) => this._resize(ev), 30); + this.resizeHandler = debounce(ev => this._resize(ev), 30); if ("onorientationchange" in _global) { _global.onorientationchange = this.resizeHandler; } else { - BI.Widget._renderEngine.createElement(_global).resize(this.resizeHandler); + Widget._renderEngine.createElement(_global).resize(this.resizeHandler); } } _resize(ev) { - BI.each(this.resizerManger, function (key, resizer) { + each(this.resizerManger, (key, resizer) => { if (resizer instanceof BI.$) { if (resizer.is(":visible")) { resizer.trigger("__resize__"); } + return; } if (resizer instanceof BI.Layout) { resizer.resize(); + return; } - if (BI.isFunction(resizer)) { + if (isFunction(resizer)) { resizer(ev); } }); } add(name, resizer) { - BI.isNull(this.resizeHandler) && this._initResizeListener(); + isNull(this.resizeHandler) && this._initResizeListener(); if (this.has(name)) { return this; } this.resizerManger[name] = resizer; + return () => this.remove(name); } @@ -53,7 +57,7 @@ export class ResizeController extends Controller { } has(name) { - return this.resizerManger[name] != null; + return isNotNull(this.resizerManger[name]); } remove(name) { @@ -61,6 +65,7 @@ export class ResizeController extends Controller { return this; } delete this.resizerManger[name]; + return this; } } diff --git a/src/core/controller/controller.tooltips.js b/src/core/controller/controller.tooltips.js index e084caba9..da571a504 100644 --- a/src/core/controller/controller.tooltips.js +++ b/src/core/controller/controller.tooltips.js @@ -3,10 +3,12 @@ * 控制tooltip的显示, 且页面中只有一个tooltip显示 * * Created by GUY on 2015/9/8. - * @class BI.TooltipsController - * @extends BI.Controller */ import { Controller } from "./0.controller"; +import { each, isNotNull } from "../2.base"; +import { Widget } from "../4.widget"; +import { createWidget } from "../5.inject"; + export class TooltipsController extends Controller { init() { this.tooltipsManager = {}; @@ -23,17 +25,17 @@ export class TooltipsController extends Controller { * @private */ _createTooltip(opt) { - return BI.createWidget({ + return createWidget({ type: "bi.tooltip", ...opt, - stopEvent: true + stopEvent: true, }); } // opt: {container: '', belowMouse: false} show(e, name, tooltipOpt, context, opt) { opt || (opt = {}); - BI.each(this.showingTips, (i, tip) => this.hide(i)); + each(this.showingTips, (i, tip) => this.hide(i)); this.showingTips = {}; if (!this.has(name)) { this.create(name, tooltipOpt, document.fullscreenElement ? context : (opt.container || "body")); @@ -51,7 +53,7 @@ export class TooltipsController extends Controller { const tooltip = this.get(name); tooltip.element.css({ left: "0px", - top: "0px" + top: "0px", }); tooltip.visible(); tooltip.element.height(tooltip.element[0].scrollHeight); @@ -60,10 +62,10 @@ export class TooltipsController extends Controller { // const scale = context.element.offset().left / context.element.get(0).getBoundingClientRect().left; // const x = (e.pageX || e.clientX) * scale + 15, y = (e.pageY || e.clientY) * scale + 15; let x = (e.pageX || e.clientX) + 15, y = (e.pageY || e.clientY) + 15; - if (x + tooltip.element.outerWidth() > BI.Widget._renderEngine.createElement("body").outerWidth()) { + if (x + tooltip.element.outerWidth() > Widget._renderEngine.createElement("body").outerWidth()) { x -= tooltip.element.outerWidth() + 15; } - const bodyHeight = BI.Widget._renderEngine.createElement("body").outerHeight(); + const bodyHeight = Widget._renderEngine.createElement("body").outerHeight(); if (y + tooltip.element.outerHeight() > bodyHeight || top + tooltip.element.outerHeight() > bodyHeight) { y -= tooltip.element.outerHeight() + 15; !opt.belowMouse && (y = Math.min(y, offset.top - tooltip.element.outerHeight() - 5)); @@ -72,13 +74,14 @@ export class TooltipsController extends Controller { } tooltip.element.css({ // 这里直接用px就可以 - left: x < 0 ? 0 : x + "px", - top: y < 0 ? 0 : y + "px" + left: x < 0 ? 0 : `${x}px`, + top: y < 0 ? 0 : `${y}px`, }); tooltip.element.hover(() => { this.remove(name); - context.element.trigger("mouseleave.title" + context.getName()); + context.element.trigger(`mouseleave.title${context.getName()}`); }); + return this; } @@ -89,6 +92,7 @@ export class TooltipsController extends Controller { delete this.showingTips[name]; this.get(name).element.hide(0, callback); this.get(name).invisible(); + return this; } @@ -96,15 +100,16 @@ export class TooltipsController extends Controller { if (!this.has(name)) { const tooltip = this._createTooltip(tooltipOpt); this.add(name, tooltip); - BI.createWidget({ + createWidget({ type: "bi.absolute", element: context || "body", items: [{ - el: tooltip - }] + el: tooltip, + }], }); tooltip.invisible(); } + return this.get(name); } @@ -113,6 +118,7 @@ export class TooltipsController extends Controller { return this; } this.set(name, bubble); + return this; } @@ -125,7 +131,7 @@ export class TooltipsController extends Controller { } has(name) { - return this.tooltipsManager[name] != null; + return isNotNull(this.tooltipsManager[name]); } remove(name) { @@ -134,15 +140,17 @@ export class TooltipsController extends Controller { } this.tooltipsManager[name].destroy(); delete this.tooltipsManager[name]; + return this; } removeAll() { - BI.each(this.tooltipsManager, function (name, tooltip) { + each(this.tooltipsManager, (name, tooltip) => { tooltip.destroy(); }); this.tooltipsManager = {}; this.showingTips = {}; + return this; } } diff --git a/src/core/controller/index.js b/src/core/controller/index.js index 91701e15f..c025e0daa 100644 --- a/src/core/controller/index.js +++ b/src/core/controller/index.js @@ -6,4 +6,4 @@ export { LayerController } from "./controller.layer"; export { MaskersController } from "./controller.masker"; export { PopoverController } from "./controller.popover"; export { ResizeController } from "./controller.resizer"; -export { TooltipsController } from "./controller.tooltips"; \ No newline at end of file +export { TooltipsController } from "./controller.tooltips"; diff --git a/src/core/element/element.js b/src/core/element/element.js index 7bf1c9d4a..9b08c0762 100644 --- a/src/core/element/element.js +++ b/src/core/element/element.js @@ -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() { - } - }; + }, + }; } diff --git a/src/core/element/index.js b/src/core/element/index.js index bbc4eb926..070afb0f3 100644 --- a/src/core/element/index.js +++ b/src/core/element/index.js @@ -1,16 +1,17 @@ -import { Element } from './element'; +import { Element } from "./element"; +import { isString, isWidget } from "../2.base"; BI.Element = Element; BI.Element.renderEngine = { - createElement: (widget) => { - // eslint-disable-next-line no-undef - if (BI.isWidget(widget)) { - var o = widget.options; + createElement: widget => { + if (isWidget(widget)) { + const o = widget.options; if (o.element instanceof Element) { return o.element; } - if (typeof o.element === 'string' && o.element !== 'body') { + if (typeof o.element === "string" && o.element !== "body") { o.root = false; + return new Element(widget); } @@ -18,14 +19,14 @@ BI.Element.renderEngine = { return new Element(); } } - // eslint-disable-next-line no-undef - if (BI.isString(widget)) { + if (isString(widget)) { return new Element(widget); } + return new Element(widget); }, createFragment() { return new Element(); - } -} + }, +}; diff --git a/src/core/element/plugins/attr.js b/src/core/element/plugins/attr.js index 3ae918f29..a680955c7 100644 --- a/src/core/element/plugins/attr.js +++ b/src/core/element/plugins/attr.js @@ -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]; + }); }; diff --git a/src/core/element/plugins/class.js b/src/core/element/plugins/class.js index ce46e6864..1c4c8eaba 100644 --- a/src/core/element/plugins/class.js +++ b/src/core/element/plugins/class.js @@ -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; - }); }; diff --git a/src/core/element/plugins/css.js b/src/core/element/plugins/css.js index e1826a155..f5372da0e 100644 --- a/src/core/element/plugins/css.js +++ b/src/core/element/plugins/css.js @@ -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; }; diff --git a/src/core/element/plugins/data.js b/src/core/element/plugins/data.js index e141c96c3..0e7cbb2d5 100644 --- a/src/core/element/plugins/data.js +++ b/src/core/element/plugins/data.js @@ -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; + }); }; diff --git a/src/core/element/plugins/empty.js b/src/core/element/plugins/empty.js index dbe5e0c1d..3cfe0177c 100644 --- a/src/core/element/plugins/empty.js +++ b/src/core/element/plugins/empty.js @@ -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; + }); }; diff --git a/src/core/element/plugins/event.js b/src/core/element/plugins/event.js index 38004ed88..66d89de97 100644 --- a/src/core/element/plugins/event.js +++ b/src/core/element/plugins/event.js @@ -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); + }); }; diff --git a/src/core/element/plugins/html.js b/src/core/element/plugins/html.js index b115f9388..18cf233d6 100644 --- a/src/core/element/plugins/html.js +++ b/src/core/element/plugins/html.js @@ -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; + }); }; diff --git a/src/core/element/plugins/index.js b/src/core/element/plugins/index.js index c32aab4dc..79e2f692c 100644 --- a/src/core/element/plugins/index.js +++ b/src/core/element/plugins/index.js @@ -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); }; diff --git a/src/core/element/plugins/keywordMark.js b/src/core/element/plugins/keywordMark.js index a7eab83dd..f0fcca96e 100644 --- a/src/core/element/plugins/keywordMark.js +++ b/src/core/element/plugins/keywordMark.js @@ -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; + }); }; diff --git a/src/core/element/plugins/renderToHtml.js b/src/core/element/plugins/renderToHtml.js index 525afe062..a9db9f755 100644 --- a/src/core/element/plugins/renderToHtml.js +++ b/src/core/element/plugins/renderToHtml.js @@ -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 += ``; } - // 特殊处理,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 += ``; - } - return str; -}; -export const registRenderToHtmlFun = (Element) => { - Element.registerFunction('renderToHtml', function () { - return _renderToHtml(this); - }); }; diff --git a/src/core/element/plugins/renderToString.js b/src/core/element/plugins/renderToString.js index f0073f258..6ab9734dd 100644 --- a/src/core/element/plugins/renderToString.js +++ b/src/core/element/plugins/renderToString.js @@ -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 += ``; } - str += ``; - } - 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); + }); }; diff --git a/src/core/element/plugins/text.js b/src/core/element/plugins/text.js index 555195251..8e51fd178 100644 --- a/src/core/element/plugins/text.js +++ b/src/core/element/plugins/text.js @@ -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; + }); }; diff --git a/src/core/element/plugins/val.js b/src/core/element/plugins/val.js index f4b868918..e1e515c19 100644 --- a/src/core/element/plugins/val.js +++ b/src/core/element/plugins/val.js @@ -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; + }); }; diff --git a/src/core/index.js b/src/core/index.js index 37c581af2..a492a0d96 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -12,6 +12,8 @@ import * as structure from "./structure"; import { StyleLoaderManager } from "./loader/loader.style"; import { ShowListener } from "./listener/listener.show"; import { useInWorker } from "./worker"; +import * as constant from "./constant"; +import * as logic from "./logic"; export * from "./decorator"; export * from "./2.base"; @@ -24,9 +26,8 @@ export * from "./controller"; export * from "./func"; export * from "./structure"; export * from "./h"; - -// 有了后删掉 -export const emptyFn = () => { }; +export * from "./constant"; +export * from "./logic"; export { StyleLoaderManager, @@ -42,12 +43,14 @@ Object.assign(BI, { ...inject, Plugin, ...behavior, + ...constant, component: inject.shortcut, ...action, ...controllers, ...func, StyleLoaderManager, ShowListener, + ...logic, ...structure, useInWorker, ...h, diff --git a/src/core/listener/listener.show.js b/src/core/listener/listener.show.js index 25ddc7ea2..f761b9d91 100644 --- a/src/core/listener/listener.show.js +++ b/src/core/listener/listener.show.js @@ -1,14 +1,12 @@ /** * guy * 检测某个Widget的EventChange事件然后去show某个card - * @type {*|void|Object} - * @class BI.ShowListener - * @extends BI.OB */ import { OB } from "../3.ob"; -import { isArray, isNull, nextTick, } from "../2.base"; +import { isArray, isNull, nextTick } from "../2.base"; import { createWidget } from "../5.inject"; import { Controller } from "../controller/0.controller"; +import { Events, emptyFn } from "../constant"; export class ShowListener extends OB { static EVENT_CHANGE = "EVENT_CHANGE"; @@ -17,12 +15,10 @@ export class ShowListener extends OB { return { eventObj: createWidget(), cardLayout: null, - cardNameCreator: (v) => { - return v; - }, - cardCreator: BI.emptyFn, - afterCardCreated: BI.emptyFn, - afterCardShow: BI.emptyFn + cardNameCreator: v => v, + cardCreator: emptyFn, + afterCardCreated: emptyFn, + afterCardShow: emptyFn, }; } @@ -30,13 +26,13 @@ export class ShowListener extends OB { const { eventObj, cardLayout, afterCardCreated, cardNameCreator, cardCreator, afterCardShow } = this.options; if (eventObj) { eventObj.on(Controller.EVENT_CHANGE, (type, v, ob) => { - if (type === BI.Events.CLICK) { + if (type === Events.CLICK) { v = v || eventObj.getValue(); v = isArray(v) ? (v.length > 1 ? v.toString() : v[0]) : v; if (isNull(v)) { throw new Error("不能为null"); } - var cardName = cardNameCreator(v); + const cardName = cardNameCreator(v); if (!cardLayout.isCardExisted(cardName)) { const card = cardCreator(cardName); cardLayout.addCardByName(cardName, card); diff --git a/src/core/loader/loader.style.js b/src/core/loader/loader.style.js index 1c65a2ede..f89aea175 100644 --- a/src/core/loader/loader.style.js +++ b/src/core/loader/loader.style.js @@ -2,13 +2,13 @@ * style加载管理器 * * Created by GUY on 2015/9/7. - * @class */ +import { extend, isNotNull } from "../2.base"; import { OB } from "../3.ob"; export class StyleLoaderManager extends OB { _defaultConfig() { - return BI.extend(super._defaultConfig(arguments), {}); + return extend(super._defaultConfig(arguments), {}); } _init() { @@ -17,7 +17,7 @@ export class StyleLoaderManager extends OB { } loadStyle(name, styleString) { - if(!_global.document) { + if (!_global.document) { return; } const d = document, styles = d.createElement("style"); @@ -38,7 +38,7 @@ export class StyleLoaderManager extends OB { } has(name) { - return this.stylesManager[name] != null; + return isNotNull(this.stylesManager[name]); } removeStyle(name) { @@ -47,6 +47,7 @@ export class StyleLoaderManager extends OB { } this.stylesManager[name].parentNode.removeChild(this.stylesManager[name]); delete this.stylesManager[name]; + return this; } } diff --git a/src/core/logic/index.js b/src/core/logic/index.js new file mode 100644 index 000000000..0397ce345 --- /dev/null +++ b/src/core/logic/index.js @@ -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 +}; diff --git a/src/core/logic/logic.js b/src/core/logic/logic.js index fab052e19..fd7223510 100644 --- a/src/core/logic/logic.js +++ b/src/core/logic/logic.js @@ -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 || {}; } -}; +} diff --git a/src/core/logic/logic.layout.js b/src/core/logic/logic.layout.js index babd2306c..1251c6aee 100644 --- a/src/core/logic/logic.layout.js +++ b/src/core/logic/logic.layout.js @@ -1,13 +1,13 @@ +import { Logic } from "./logic"; +import { isNotNull, each, pickBy } from "../2.base"; + /** * guy * 上下布局逻辑 * 上下布局的时候要考虑到是动态布局还是静态布局 - * - * @class BI.VerticalLayoutLogic - * @extends BI.Logic */ -BI.VerticalLayoutLogic = BI.inherit(BI.Logic, { - props: function () { +export class VerticalLayoutLogic extends Logic { + props() { return { dynamic: false, scrollable: null, @@ -21,18 +21,20 @@ BI.VerticalLayoutLogic = BI.inherit(BI.Logic, { tgap: 0, bgap: 0, innerVgap: 0, - innerHgap: 0 + innerHgap: 0, }; - }, + } - createLogic: function () { - var layout, o = this.options; + createLogic() { + let layout; + const o = this.options; if (o.dynamic) { layout = "bi.vertical"; } else { layout = "bi.vtape"; } - return BI._.pickBy({ + + return pickBy({ type: layout, scrollable: o.scrollable, scrolly: o.scrolly, @@ -49,22 +51,19 @@ BI.VerticalLayoutLogic = BI.inherit(BI.Logic, { horizontalAlign: o.horizontalAlign, verticalAlign: o.verticalAlign, columnSize: o.columnSize, - rowSize: o.rowSize - }, BI.isNotNull); + rowSize: o.rowSize, + }, isNotNull); } -}); +} /** * guy * 左右布局逻辑 * 左右布局的时候要考虑到是动态布局还是静态布局 - * - * @class BI.HorizontalLayoutLogic - * @extends BI.Logic */ -BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, { - props: function () { +export class HorizontalLayoutLogic extends Logic { + props() { return { dynamic: false, scrollable: null, @@ -78,18 +77,20 @@ BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, { tgap: 0, bgap: 0, innerVgap: 0, - innerHgap: 0 + innerHgap: 0, }; - }, + } - createLogic: function () { - var layout, o = this.options; + createLogic() { + let layout; + const o = this.options; if (o.dynamic) { layout = "bi.vertical_adapt"; } else { layout = "bi.htape"; } - return BI._.pickBy({ + + return pickBy({ type: layout, scrollable: o.scrollable, scrolly: o.scrolly, @@ -106,21 +107,18 @@ BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, { horizontalAlign: o.horizontalAlign, verticalAlign: o.verticalAlign, columnSize: o.columnSize, - rowSize: o.rowSize - }, BI.isNotNull); + rowSize: o.rowSize, + }, isNotNull); } -}); +} /** * guy * 表格布局逻辑 * 表格布局的时候要考虑到是动态布局还是静态布局 - * - * @class BI.TableLayoutLogic - * @extends BI.OB */ -BI.TableLayoutLogic = BI.inherit(BI.Logic, { - props: function () { +export class TableLayoutLogic extends Logic { + props() { return { dynamic: false, scrollable: null, @@ -132,18 +130,20 @@ BI.TableLayoutLogic = BI.inherit(BI.Logic, { rowSize: [], hgap: 0, vgap: 0, - items: [] + items: [], }; - }, + } - createLogic: function () { - var layout, o = this.options; + createLogic() { + let layout; + const o = this.options; if (o.dynamic) { layout = "bi.table"; } else { layout = "bi.window"; } - return BI._.pickBy({ + + return pickBy({ type: layout, scrollable: o.scrollable, scrolly: o.scrolly, @@ -156,20 +156,17 @@ BI.TableLayoutLogic = BI.inherit(BI.Logic, { horizontalAlign: o.horizontalAlign, verticalAlign: o.verticalAlign, columnSize: o.columnSize, - rowSize: o.rowSize - }, BI.isNotNull); + rowSize: o.rowSize, + }, isNotNull); } -}); +} /** * guy * 左右充满布局逻辑 - * - * @class BI.HorizontalFillLayoutLogic - * @extends BI.Logic */ -BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { - props: function () { +export class HorizontalFillLayoutLogic extends Logic { + props() { return { dynamic: false, scrollable: null, @@ -183,14 +180,15 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { tgap: 0, bgap: 0, innerVgap: 0, - innerHgap: 0 + innerHgap: 0, }; - }, + } - createLogic: function () { - var layout, o = this.options; - var columnSize = []; - BI.each(o.items, function (i, item) { + createLogic() { + let layout; + const o = this.options; + const columnSize = []; + each(o.items, (i, item) => { columnSize.push(item.width || 0); }); if (o.dynamic) { @@ -198,7 +196,8 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { } else { layout = "bi.htape"; } - return BI._.pickBy({ + + return pickBy({ type: layout, scrollable: o.scrollable, scrolly: o.scrolly, @@ -214,8 +213,8 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { items: o.items, horizontalAlign: o.horizontalAlign, verticalAlign: o.verticalAlign, - columnSize: columnSize, - rowSize: o.rowSize - }, BI.isNotNull); + columnSize, + rowSize: o.rowSize, + }, isNotNull); } -}); +} From 8fcb09c1e3c2805906ed44cd4cda7426d3a2a65b Mon Sep 17 00:00:00 2001 From: "Zhenfei.Li" Date: Fri, 6 Jan 2023 11:31:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?KERNEL-14035=20refactor:=20=E6=8C=82?= =?UTF-8?q?=E8=BD=BDElement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/element/index.js | 5 +++-- src/core/index.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/element/index.js b/src/core/element/index.js index 070afb0f3..da27b0719 100644 --- a/src/core/element/index.js +++ b/src/core/element/index.js @@ -1,8 +1,7 @@ import { Element } from "./element"; import { isString, isWidget } from "../2.base"; -BI.Element = Element; -BI.Element.renderEngine = { +Element.renderEngine = { createElement: widget => { if (isWidget(widget)) { const o = widget.options; @@ -30,3 +29,5 @@ BI.Element.renderEngine = { return new Element(); }, }; + +export { Element }; diff --git a/src/core/index.js b/src/core/index.js index a492a0d96..49d7b2125 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -14,6 +14,7 @@ import { ShowListener } from "./listener/listener.show"; import { useInWorker } from "./worker"; import * as constant from "./constant"; import * as logic from "./logic"; +import { Element } from "./element"; export * from "./decorator"; export * from "./2.base"; @@ -33,7 +34,8 @@ export { StyleLoaderManager, ShowListener, Plugin, - useInWorker + useInWorker, + Element }; Object.assign(BI, { @@ -47,6 +49,7 @@ Object.assign(BI, { component: inject.shortcut, ...action, ...controllers, + Element, ...func, StyleLoaderManager, ShowListener,