Browse Source

Merge pull request #154168 in DEC/fineui from feature/x to bugfix/11.0

* commit '6e270d0bd4efe001a3fd003ee2600a45b121d007': (161 commits)
  auto upgrade version to 2.0.20220826175704
  bugfix: bug
  auto upgrade version to 2.0.20220826171804
  REPORT-77978 fix: 下拉树水印表现异常问题
  auto upgrade version to 2.0.20220826110757
  无JIRA fix:按钮 textAlign 失效
  auto upgrade version to 2.0.20220826090446
  auto upgrade version to 2.0.20220825194716
  DESIGN-4402 fix: 复选树视觉问题
  auto upgrade version to 2.0.20220825163610
  KERNEL-12552 feat: 不执行BI.init(),很多方法调用会出现问题
  BI-107557 单选下拉null值显示处理 && 更新图标
  auto upgrade version to 2.0.20220825115604
  chore: 修改loader
  auto upgrade version to 2.0.20220824175535
  DESIGN-4402 fix: 复选树视觉问题
  auto upgrade version to 2.0.20220824165610
  chore: 更新
  auto upgrade version to 2.0.20220823231616
  auto upgrade version to 2.0.20220823191436
  ...
research/test
superman 2 years ago
parent
commit
26d673429a
  1. 5
      .eslintrc
  2. 2
      .npmignore
  3. 4
      bi.lessconfig.json
  4. 32
      bin/cli/worker/cli.worker.js
  5. 48
      bin/cli/worker/template/main_thread.helper.t
  6. 13
      bin/cli/worker/template/main_thread/action/action.worker_ability_test.t
  7. 13
      bin/cli/worker/template/main_thread/main_thread.t
  8. 5
      bin/cli/worker/template/main_thread_template.ts
  9. 8
      bin/cli/worker/template/utils/action_type.t
  10. 13
      bin/cli/worker/template/utils/payload_type.t
  11. 24
      bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t
  12. 12
      bin/cli/worker/template/worker_thread/worker_thread.t
  13. 5
      bin/cli/worker/template/worker_thread_template.ts
  14. 528
      demo/config.js
  15. 211
      demo/js/base/button/demo.button.js
  16. 247
      demo/js/case/combo/demo.text_value_combo.js
  17. 5
      demo/js/case/tree/demo.level_tree.js
  18. 3
      demo/js/component/demo.treevaluechoosercombo.js
  19. 4
      demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js
  20. 4
      demo/js/widget/singletree/demo.multilayer_single_tree_combo.js
  21. 4
      demo/js/widget/singletree/demo.single_tree_combo.js
  22. 2
      demo/js/widget/tree/demo.multilayer_select_level_tree.js
  23. 38
      demo/js/widget/tree/demo.multilayer_single_level_tree.js
  24. BIN
      dist/font/iconfont.eot
  25. 476
      dist/font/iconfont.svg
  26. BIN
      dist/font/iconfont.ttf
  27. BIN
      dist/font/iconfont.woff
  28. BIN
      dist/font/iconfont.woff2
  29. BIN
      dist/images/2x/icon/dark/tree_solid_collapse_1.png
  30. BIN
      dist/images/2x/icon/dark/tree_solid_collapse_2.png
  31. BIN
      dist/images/2x/icon/dark/tree_solid_collapse_3.png
  32. BIN
      dist/images/2x/icon/dark/tree_solid_collapse_4.png
  33. BIN
      dist/images/2x/icon/dark/tree_solid_collapse_5.png
  34. BIN
      dist/images/2x/icon/dark/tree_solid_expand_1.png
  35. BIN
      dist/images/2x/icon/dark/tree_solid_expand_2.png
  36. BIN
      dist/images/2x/icon/dark/tree_solid_expand_3.png
  37. BIN
      dist/images/2x/icon/dark/tree_solid_expand_4.png
  38. BIN
      dist/images/2x/icon/dark/tree_solid_expand_5.png
  39. BIN
      dist/images/2x/icon/dark/tree_solid_vertical_line_1.png
  40. BIN
      dist/images/2x/icon/dark/tree_solid_vertical_line_2.png
  41. BIN
      dist/images/2x/icon/dark/tree_solid_vertical_line_3.png
  42. BIN
      dist/images/2x/icon/dark/tree_solid_vertical_line_4.png
  43. BIN
      dist/images/2x/icon/tree_solid_collapse_1.png
  44. BIN
      dist/images/2x/icon/tree_solid_collapse_2.png
  45. BIN
      dist/images/2x/icon/tree_solid_collapse_3.png
  46. BIN
      dist/images/2x/icon/tree_solid_collapse_4.png
  47. BIN
      dist/images/2x/icon/tree_solid_collapse_5.png
  48. BIN
      dist/images/2x/icon/tree_solid_expand_1.png
  49. BIN
      dist/images/2x/icon/tree_solid_expand_2.png
  50. BIN
      dist/images/2x/icon/tree_solid_expand_3.png
  51. BIN
      dist/images/2x/icon/tree_solid_expand_4.png
  52. BIN
      dist/images/2x/icon/tree_solid_expand_5.png
  53. BIN
      dist/images/2x/icon/tree_solid_vertical_line_2.png
  54. BIN
      dist/images/2x/icon/tree_solid_vertical_line_3.png
  55. BIN
      dist/images/2x/icon/tree_solid_vertical_line_4.png
  56. BIN
      dist/images/2x/icon/tree_vertical_line_1.png
  57. 4
      examples/worker_new/index.js
  58. 4
      examples/worker_new/worker.js
  59. 2
      lodash.md
  60. 4
      package.json
  61. 9
      plugins/webpack-fui-worker-plugin/constants.js
  62. 0
      plugins/webpack-fui-worker-plugin/empty.js
  63. 79
      plugins/webpack-fui-worker-plugin/index.js
  64. 137
      plugins/webpack-fui-worker-plugin/worker-loader.js
  65. 20
      src/base/0.base.js
  66. 20
      src/base/1.pane.js
  67. 9
      src/base/collection/__test__/collection.test.js
  68. 50
      src/base/collection/collection.js
  69. 42
      src/base/combination/bubble.js
  70. 38
      src/base/combination/combo.js
  71. 20
      src/base/combination/expander.js
  72. 40
      src/base/combination/group.button.js
  73. 18
      src/base/combination/group.combo.js
  74. 21
      src/base/combination/group.virtual.js
  75. 36
      src/base/combination/loader.js
  76. 19
      src/base/combination/navigation.js
  77. 34
      src/base/combination/searcher.js
  78. 18
      src/base/combination/switcher.js
  79. 16
      src/base/combination/tab.js
  80. 29
      src/base/combination/tree.button.js
  81. 6
      src/base/context.js
  82. 6
      src/base/el.js
  83. 4
      src/base/foundation/__test__/message.test.js
  84. 76
      src/base/foundation/message.js
  85. 7
      src/base/grid/__test__/grid.test.js
  86. 28
      src/base/grid/grid.js
  87. 9
      src/base/layer/__test__/layer.popover.test.js
  88. 72
      src/base/layer/layer.drawer.js
  89. 80
      src/base/layer/layer.popover.js
  90. 100
      src/base/layer/layer.popup.js
  91. 37
      src/base/layer/layer.searcher.js
  92. 13
      src/base/list/__test__/listview.test.js
  93. 23
      src/base/list/listview.js
  94. 23
      src/base/list/virtualgrouplist.js
  95. 22
      src/base/list/virtuallist.js
  96. 35
      src/base/pager/pager.js
  97. 12
      src/base/single/0.single.js
  98. 28
      src/base/single/1.text.js
  99. 27
      src/base/single/__test__/text.test.js
  100. 11
      src/base/single/a/__test__/a.test.js
  101. Some files were not shown because too many files have changed in this diff Show More

5
.eslintrc

@ -2,7 +2,8 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es6": true,
"jest": true
},
"globals": {
"window": true,
@ -30,7 +31,7 @@
"rules": {
"no-param-reassign": "off",
"quotes": [2, "double"],
"comma-dangle": ["error", "never"] // 多行对象字面量中要求拖尾逗号
"comma-dangle": ["error", { "arrays": "never", "objects": "always-multiline"}] // 多行对象字面量中要求拖尾逗号
}
}, {
"files": ["webpack/*.js", "./*.js", "lib/**/*.js", "lib/*.js", "./bin/*.js", "./bin/**/*.js"],

2
.npmignore

@ -40,3 +40,5 @@
!dist/2.0/bi.min.css
!bin/*
!bin/**/*
!plugins/*
!plugins/**/*

4
bi.lessconfig.json

@ -38,5 +38,7 @@
"@color-bi-color-toast-normal": "#2C60DB",
"@color-bi-color-toast-text": "#000A19",
"@color-bi-text-header-background": "rgba(9, 30, 64, 0.9)",
"@color-bi-text-header-background-theme-dark": "rgba(255, 255, 255, 0.9)"
"@color-bi-text-header-background-theme-dark": "rgba(255, 255, 255, 0.9)",
"@font-down-triangle": "e70b",
"@font-date": "e733"
}

32
bin/cli/worker/cli.worker.js

@ -1,17 +1,25 @@
const fs = require('fs');
const path = require('path');
function scanAndCreate(structure, root = process.cwd()) {
function first2UpperCase(str) {
return str.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase());
}
function scanAndCreate(structure, workerName, root = process.env.INIT_CWD) {
Object.keys(structure)
.forEach(name => {
if (typeof structure[name] === 'object') {
fs.mkdirSync(path.resolve(root, name));
scanAndCreate(structure[name], path.resolve(root, `./${name}`));
scanAndCreate(structure[name], workerName, path.resolve(root, `./${name}`));
} else if (structure[name] === '') {
fs.appendFileSync(path.resolve(root, name), '');
} else if (typeof structure[name] === 'string') {
const content = fs.readFileSync(structure[name]).toString();
let content = fs.readFileSync(structure[name]).toString();
content = content
.replace(/\${WorkerName}/g, first2UpperCase(workerName))
.replace(/\${workerName}/g, workerName);
fs.appendFileSync(path.resolve(root, name), content);
}
@ -33,20 +41,26 @@ module.exports = {
const structure = {
[`${name}_worker`]: {
'main_thread': {
action: {},
[`${name}_main_thread.ts`]: path.resolve(__dirname, './template/main_thread_template.ts'),
action: {
'action.worker_ability_test.ts': path.resolve(__dirname, './template/main_thread/action/action.worker_ability_test.t'),
},
[`${name}_main_thread.ts`]: path.resolve(__dirname, './template/main_thread/main_thread.t'),
},
utils: {
'action_type.ts': '',
'action_type.ts': path.resolve(__dirname, './template/utils/action_type.t'),
'payload_type.ts': path.resolve(__dirname, './template/utils/payload_type.t'),
},
'worker_thread': {
action: {},
[`${name}_worker_thread.ts`]: path.resolve(__dirname, './template/worker_thread_template.ts'),
action: {
'action.worker_ability_test.ts': path.resolve(__dirname, './template/worker_thread/action/action.worker_ability_test.t'),
},
[`${name}_worker_thread.ts`]: path.resolve(__dirname, './template/worker_thread/worker_thread.t'),
},
[`${name}_main_thread.helper.ts`]: path.resolve(__dirname, './template/main_thread.helper.t'),
},
};
scanAndCreate(structure);
scanAndCreate(structure, name);
},
};

48
bin/cli/worker/template/main_thread.helper.t

@ -0,0 +1,48 @@
import { ${WorkerName}MainThreadWorker } from './main_thread/${workerName}_main_thread';
// 不需要一起打包的话则不需要引入这行
// FuiWorkerPlugin中的属性会同步到fui-worker中同时支持loader行内传入属性
// 根据实际需求传入inline返回格式 true -> blob urlfalse -> servicePath
import { workerUrl } from 'fui-worker!./worker_thread/${workerName}_worker_thread';
export class ${WorkerName}WorkerHelper {
private worker: ${WorkerName}MainThreadWorker;
/**
* 拿到helper中的worker
*/
public getWorker() {
if (this.worker) {
return this.worker;
}
this.worker = BI.Workers.createWorker(${WorkerName}MainThreadWorker, {
workerUrl: this.urlFormatter(workerUrl),
workerName: BI.UUID(),
});
return this.worker;
}
/**
* 格式化worker url比如补充一些环境信息到参数里
* 可通过 #hash 将参数传入blob url
* @param url worker url
*/
private urlFormatter(url: string) {
return url;
}
/**
* 终止worker
*/
public terminate() {
this.worker?.terminate();
}
}
// 使用示例
// const workerHelper = new ${WorkerName}WorkerHelper();
// workerHelper.getWorker()
// .testCommunication()
// .then(res => console.log(res));

13
bin/cli/worker/template/main_thread/action/action.worker_ability_test.t

@ -0,0 +1,13 @@
import { WorkerAbilityTestActionType } from '../../utils/action_type';
import { WorkerAbilityTestPayload, WorkerAbilityTestReponse } from '../../utils/payload_type';
export class WorkerAbilityTestMainThreadAction extends BI.Workers.WorkerBaseAction {
/**
* 通信能力检测
*/
public communicationTest(): Promise<WorkerAbilityTestReponse['CommunicationTest']> {
const mainThreadPostTime: WorkerAbilityTestPayload['CommunicationTest'] = Date.now();
return this.controller.requestPromise(WorkerAbilityTestActionType.CommunicationTest, mainThreadPostTime);
}
}

13
bin/cli/worker/template/main_thread/main_thread.t

@ -0,0 +1,13 @@
import { WorkerAbilityTestMainThreadAction } from './action/action.worker_ability_test';
export class ${WorkerName}MainThreadWorker extends BI.Workers.MainThreadWorker {
private communicationTest: WorkerAbilityTestMainThreadAction;
public initActions(): void {
this.communicationTest = this.createAction(WorkerAbilityTestMainThreadAction);
}
public testCommunication() {
return this.communicationTest.communicationTest();
}
}

5
bin/cli/worker/template/main_thread_template.ts

@ -1,5 +0,0 @@
class CrudMainTreadWorker extends BI.Workers.MainThreadWorker {
protected initActions(): void {
// to init some actions
}
}

8
bin/cli/worker/template/utils/action_type.t

@ -0,0 +1,8 @@
/*
* Worker 事务标识
* 每类事务有命名空间, 包含多个具体事务
*/
export const enum WorkerAbilityTestActionType {
CommunicationTest = 'CommunicationTest',
}

13
bin/cli/worker/template/utils/payload_type.t

@ -0,0 +1,13 @@
/**
* 跨线程通信各事务的发送数据类型声明
*/
export interface WorkerAbilityTestPayload {
CommunicationTest: number;
}
/**
* 跨线程通信各事务的响应数据类型声明
*/
export interface WorkerAbilityTestReponse {
CommunicationTest: number;
}

24
bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t

@ -0,0 +1,24 @@
import { WorkerAbilityTestActionType } from '../../utils/action_type';
import { WorkerAbilityTestPayload, WorkerAbilityTestReponse } from '../../utils/payload_type';
export class WorkerAbilityTestWorkerThreadAction extends BI.Workers.WorkerBaseAction {
protected addActionHandler(): void {
this.controller.addActionHandler(
WorkerAbilityTestActionType.CommunicationTest,
this.communicationTest.bind(this)
);
}
/**
* 通信能力检测的处理器
*/
private communicationTest(
payload: WorkerAbilityTestPayload['CommunicationTest']
): WorkerAbilityTestReponse['CommunicationTest'] {
const mainThreadPostTime = payload;
// 收到主线程信息的耗时
const workerGetMessageDuration = Date.now() - mainThreadPostTime;
return workerGetMessageDuration;
}
}

12
bin/cli/worker/template/worker_thread/worker_thread.t

@ -0,0 +1,12 @@
// TODO: 这边需要先import fineui资源
import { WorkerAbilityTestWorkerThreadAction } from './action/action.worker_ability_test';
class ${WorkerName}WorkerTreadWorker extends BI.Workers.WorkerThreadWorker {
public communicationTest: WorkerAbilityTestWorkerThreadAction;
public initActions(): void {
this.communicationTest = this.createAction(WorkerAbilityTestWorkerThreadAction);
}
}
export const ${workerName}WorkerTreadWorker = BI.Workers.createWorker(${WorkerName}WorkerTreadWorker);

5
bin/cli/worker/template/worker_thread_template.ts

@ -1,5 +0,0 @@
class CrudWorkerTreadWorker extends BI.Workers.MainThreadWorker {
protected initActions(): void {
// to init some actions
}
}

528
demo/config.js

File diff suppressed because it is too large Load Diff

211
demo/js/base/button/demo.button.js

@ -1,277 +1,304 @@
(function () {
var JokerIcon = BI.inherit(BI.Widget, {
render: function () {
var self = this;
return {
type: "bi.label",
cls: "anim-rotate",
ref: function(ref) {
self.text = ref;
},
};
},
loading: function () {
this.text.setText("🤡");
},
loaded: function () {
this.text.setText("");
},
});
BI.shortcut("demo.joker.icon", JokerIcon);
}());
Demo.Button = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-button"
baseCls: "demo-button",
},
render: function () {
var items = [{
type: "bi.button",
text: "一般按钮",
text: "一般按钮1111111111111",
level: "common",
height: 30
whiteSpace: "nowrap",
width: 100,
height: 30,
handler() {
console.log("触发点击事件");
this.loading();
setTimeout(() => {
this.loaded();
}, 5 * 1000);
},
}, {
type: "bi.button",
text: "表示成功状态按钮",
level: "success",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示警告状态的按钮",
level: "warning",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示错误状态的按钮",
level: "error",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示忽略状态的按钮",
level: "ignore",
height: 30
height: 30,
}, {
type: "bi.button",
text: "普通灰化按钮",
disabled: true,
level: "success",
height: 30
height: 30,
}, {
type: "bi.button",
text: "忽略状态灰化按钮",
disabled: true,
level: "ignore",
height: 30
height: 30,
}, {
type: "bi.button",
text: "带图标的按钮",
// level: 'ignore',
iconCls: "close-font",
height: 30
height: 30,
}, {
type: "bi.button",
text: "一般按钮",
block: true,
level: "common",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示成功状态按钮",
block: true,
level: "success",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示警告状态的按钮",
block: true,
level: "warning",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示忽略状态的按钮",
block: true,
level: "ignore",
height: 30
height: 30,
}, {
type: "bi.button",
text: "普通灰化按钮",
block: true,
disabled: true,
level: "success",
height: 30
height: 30,
}, {
type: "bi.button",
text: "忽略状态灰化按钮",
block: true,
disabled: true,
level: "ignore",
height: 30
height: 30,
}, {
type: "bi.button",
text: "带图标的按钮",
block: true,
// level: 'ignore',
iconCls: "close-font",
height: 30
height: 30,
}, {
type: "bi.button",
text: "一般按钮",
clear: true,
level: "common",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示成功状态按钮",
clear: true,
level: "success",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示警告状态的按钮",
clear: true,
level: "warning",
height: 30
height: 30,
}, {
type: "bi.button",
text: "表示忽略状态的按钮",
clear: true,
level: "ignore",
height: 30
height: 30,
}, {
type: "bi.button",
text: "普通灰化按钮",
clear: true,
disabled: true,
level: "success",
height: 30
height: 30,
}, {
type: "bi.button",
text: "忽略状态灰化按钮",
clear: true,
disabled: true,
level: "ignore",
height: 30
height: 30,
}, {
type: "bi.button",
text: "带图标的按钮",
clear: true,
// level: 'ignore',
iconCls: "close-font",
height: 30
height: 30,
}, {
type: "bi.text_button",
text: "文字按钮",
height: 30
height: 30,
}, {
type: "bi.button",
text: "幽灵按钮(common)",
ghost: true,
height: 30
height: 30,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
height: 30
height: 30,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "warning",
height: 30
height: 30,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "error",
height: 30
height: 30,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "success",
height: 30
height: 30,
}, {
type: "bi.button",
text: "幽灵按钮(common)灰化",
disabled: true,
ghost: true,
height: 30
height: 30,
}, {
type: "bi.button",
text: "弹出bubble",
bubble: function () {
return BI.parseInt(Math.random() * 100) % 10 + "提示"
return BI.parseInt(Math.random() * 100) % 10 + "提示";
},
handler: function () {
BI.Msg.toast("1111");
},
height: 30
height: 30,
}, {
type: "bi.button",
text: "图标在上面的按钮,而且可以自动撑开高度",
text: "自动撑开",
iconCls: "close-font",
iconGap: 24,
iconPosition: "top"
},{
type: "bi.button",
text: "自动撑开高度",
iconCls: "close-font",
textHeight: 32,
iconGap: 24,
// textHeight: 32,
// height: 32,
iconGap: 64,
vgap: 16,
hgap: 100,
iconPosition: "top"
iconPosition: "bottom",
}, {
type: "bi.button",
text: "图标在下面的按钮",
iconCls: "close-font",
iconPosition: "bottom"
iconPosition: "bottom",
}, {
type: "bi.button",
text: "图标在左边的按钮",
iconCls: "close-font",
iconPosition: "left"
iconPosition: "left",
}, {
type: "bi.button",
text: "图标在右边的按钮",
iconCls: "close-font",
iconPosition: "right"
iconPosition: "right",
}, {
type: "bi.button",
text: "浅色的一般按钮",
iconCls: "plus-font",
light: true
light: true,
}, {
type: "bi.button",
text: "浅色的成功按钮",
level: "success",
iconCls: "plus-font",
light: true
light: true,
}, {
type: "bi.button",
text: "浅色的警告按钮",
level: "warning",
iconCls: "plus-font",
light: true
light: true,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "浅色的失败按钮",
level: "error",
cls: "hover-mask",
light: true
light: true,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "common",
plain: true
plain: true,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "success",
plain: true
plain: true,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "error",
plain: true
plain: true,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "warning",
plain: true
plain: true,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "ignore",
plain: true
plain: true,
}, {
type: "bi.button",
iconCls: "plus-font",
@ -282,20 +309,78 @@ Demo.Button = BI.inherit(BI.Widget, {
iconCls: "plus-font",
text: "朴素的按钮",
plain: true,
disabled: true
disabled: true,
}, {
type: "bi.button",
iconCls: "plus-font",
text: "点我,更改图标",
handler() {
this.i = this.i === undefined ? 0 : ++this.i;
this.i = this.i === undefined ? 0 : ++this.i;
const arr = ["text-background-font", "check-mark-ha-font", "close-font", "search-font", "date-change-h-font"];
if(this.i >= arr.length) {
if (this.i >= arr.length) {
this.i = 0;
}
this.setIcon(arr[this.i]);
},
height: 24
height: 24,
}, {
type: "bi.button",
text: "带加载的按钮",
handler() {
console.log("触发点击事件");
this.loading();
setTimeout(() => {
this.loaded();
}, 5 * 1000);
},
}, {
type: "bi.button",
text: "带加载的按钮",
iconCls: "circle-close-font",
handler() {
console.log("触发点击事件");
this.loading();
setTimeout(() => {
this.loaded();
}, 5 * 1000);
},
}, {
type: "bi.button",
clear: true,
text: "带加载的按钮",
iconCls: "circle-close-font",
handler() {
console.log("触发点击事件");
this.loading();
setTimeout(() => {
this.loaded();
}, 5 * 1000);
},
}, {
type: "bi.button",
text: "加载中的按钮",
loading: true,
handler() {
console.log("我是无法被触发的!");
},
}, {
type: "bi.button",
text: "自定义图标按钮(点我修改)",
icon: {
type: "demo.joker.icon",
},
handler() {
console.log("触发点击事件");
this.loading();
setTimeout(() => {
this.loaded();
}, 5 * 1000);
},
}, {
type: "bi.button",
text: "文字偏左的按钮",
textAlign: "left",
width: 200,
}];
return {
@ -305,10 +390,10 @@ Demo.Button = BI.inherit(BI.Widget, {
hgap: 20,
items: BI.map(items, function (index, value) {
return {
el: value
}
})
el: value,
};
}),
};
}
},
});
BI.shortcut("demo.button", Demo.Button);

247
demo/js/case/combo/demo.text_value_combo.js

@ -6,58 +6,207 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
baseCls: ""
},
render: function () {
var combo, wrapper;
var combo1, combo2;
var items = [{
text: "MVC-1",
iconCls: "date-font",
value: 1
}, {
text: "MVC-2",
iconCls: "search-font",
value: 2
}, {
text: "MVC-3",
iconCls: "pull-right-font",
value: 3
}];
// 创建下拉框各种场景用例
return {
type: "bi.button_group",
items: [{
type: "bi.text_value_combo",
ref: function () {
combo = this;
},
text: "默认值",
value: 22,
width: 300,
items: [{
text: "MVC-1",
iconCls: "date-font",
value: 1
}, {
text: "MVC-2",
iconCls: "search-font",
value: 2
type: "bi.vertical",
vgap: 20,
hgap: 20,
items: [
this.createCombo("无初始值,带提示文字", {
type: "bi.text_value_combo",
ref: (ref) => {
this.combo1 = ref;
},
defaultText: "请选择",
width: 300,
items: items,
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}),
this.createCombo("自动根据value匹配text", {
type: "bi.text_value_combo",
ref: function () {
combo = this;
},
defaultText: "请选择",
width: 300,
value: 1,
items: items,
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}),
this.createCombo("无初始值,可以清空", {
type: "bi.text_value_combo",
ref: function () {
combo = this;
},
defaultText: "请选择",
width: 300,
items: items,
allowClear: true,
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}),
this.createCombo("有初始值,可以清空", {
type: "bi.text_value_combo",
ref: function () {
combo = this;
},
defaultText: "请选择",
width: 300,
value: 1,
items: items,
allowClear: true,
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}),
this.createCombo("有初始值,value不匹配,自动标红,指定标红文字", {
type: "bi.text_value_combo",
ref: function () {
combo = this;
},
width: 300,
text: "MVC-111",
value: 111,
items: items,
allowClear: true,
defaultText: "请选择",
warningTitle: "value值不合法",
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}),
this.createCombo("无初始值,外部受控调用setValue", {
type: "bi.vertical",
items: [
{
type: "bi.text_value_combo",
ref: function () {
combo1 = this;
},
width: 300,
items: items,
allowClear: true,
defaultText: "请选择",
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}, {
el: {
type: "bi.button",
text: "setValue(1)",
handler: function () {
combo1.setValue();
},
},
vgap: 10,
}
]
}),
this.createCombo("无初始值,外部受控调用setStatus", {
type: "bi.vertical",
items: [
{
type: "bi.text_value_combo",
ref: function () {
combo2 = this;
},
width: 300,
items: items,
allowClear: true,
defaultText: "请选择",
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}, {
el: {
type: "bi.button",
text: "setStatus()",
handler: function () {
combo2.setStatus("error");
},
},
vgap: 10,
}
]
})
]
};
},
createCombo: function (text, combo) {
return {
type: "bi.vertical",
items: [
{
el: {
type: "bi.label",
textAlign: "left",
text,
},
bgap: 10
}, {
text: "MVC-3",
iconCls: "pull-right-font",
value: 3
}]
}, {
type: "bi.search_multi_text_value_combo",
items: Demo.CONSTANTS.ITEMS,
width: 200,
value: {
type: 1,
value: ["1", "2", "3"]
}
}, {
type: "bi.button",
width: 90,
height: 25,
handler: function () {
wrapper.populate();
}
}, {
type: 'bi.label',
height: 1000
}],
ref: function () {
wrapper = this;
},
layouts: [{
type: "bi.vertical",
vgap: 20
}]
el: combo,
bgap: 10,
},
]
};
}
});
BI.shortcut("demo.text_value_combo", Demo.TextValueCombo);
BI.shortcut("demo.text_value_combo", Demo.TextValueCombo);

5
demo/js/case/tree/demo.level_tree.js

@ -42,6 +42,11 @@ Demo.Func = BI.inherit(BI.Widget, {
pId: 1,
text: "子项3",
value: 13
}, {
id: 111,
pId: 11,
text: "子项1-1",
value: 111
}, {
id: 21,
pId: 2,

3
demo/js/component/demo.treevaluechoosercombo.js

@ -10,7 +10,8 @@ Demo.TreeValueChooser = BI.inherit(BI.Widget, {
// items: BI.deepClone(Demo.CONSTANTS.TREEITEMS),
itemsCreator: function (op, callback) {
callback(BI.deepClone(Demo.CONSTANTS.TREEITEMS));
}
},
defaultText: "请选择",
});
return {
type: "bi.vertical",

4
demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js

@ -16,7 +16,7 @@ Demo.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
ref: function (_ref) {
self.tree = _ref;
},
text: "默认值",
defaultText: "请选择",
items: items,
width: 300,
value: ["第五级文件1"]
@ -40,4 +40,4 @@ Demo.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
}
});
BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiLayerSelectTreeCombo);
BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiLayerSelectTreeCombo);

4
demo/js/widget/singletree/demo.multilayer_single_tree_combo.js

@ -16,7 +16,7 @@ Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
ref: function (_ref) {
self.tree = _ref;
},
text: "默认值",
defaultText: "请选择",
items: items,
width: 300
}, {
@ -39,4 +39,4 @@ Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
}
});
BI.shortcut("demo.multilayer_single_tree_combo", Demo.MultiLayerSingleTreeCombo);
BI.shortcut("demo.multilayer_single_tree_combo", Demo.MultiLayerSingleTreeCombo);

4
demo/js/widget/singletree/demo.single_tree_combo.js

@ -16,7 +16,7 @@ Demo.SingleTreeCombo = BI.inherit(BI.Widget, {
ref: function (_ref) {
self.tree = _ref;
},
text: "默认值",
defaultText: "请选择",
items: items,
width: 300,
value: "11"
@ -40,4 +40,4 @@ Demo.SingleTreeCombo = BI.inherit(BI.Widget, {
}
});
BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo);
BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo);

2
demo/js/widget/tree/demo.multilayer_select_level_tree.js

@ -33,7 +33,7 @@ Demo.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, {
height: 25,
text: "setValue (第二级文件1)",
handler: function () {
tree.setValue(["第二级文件1"]);
tree.setValue(["11"]);
}
},
height: 25

38
demo/js/widget/tree/demo.multilayer_single_level_tree.js

@ -46,27 +46,27 @@ Demo.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, {
mounted: function () {
var tree = [
// {id: -2, pId: 0, value: "根目录1", text: "根目录1"},
{id: -1, pId: 0, value: "根目录", text: "根目录"},
{id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1"},
{id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1"},
{id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2"},
{id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1"},
{id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1"},
{id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1"},
{id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2"},
{id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3"},
{id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2"},
{id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2"},
{id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2"},
{id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1"},
{id: 3, pId: -1, value: "第一级目录3", text: "第一级目录3"},
{id: 31, pId: 3, value: "第二级文件2", text: "第二级文件2"},
{id: 33, pId: 3, value: "第二级目录3", text: "第二级目录1"},
{id: 32, pId: 3, value: "第二级文件3", text: "第二级文件3"},
{id: 331, pId: 33, value: "第三级文件1", text: "第三级文件1"}
{ id: -1, pId: 0, value: "根目录", text: "根目录" },
{ id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1" },
{ id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1" },
{ id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2", disabled: true },
{ id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1" },
{ id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1" },
{ id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1" },
{ id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2" },
{ id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3" },
{ id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2" },
{ id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2" },
{ id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2" },
{ id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1" },
{ id: 3, pId: -1, value: "第一级目录3", text: "第一级目录3" },
{ id: 31, pId: 3, value: "第二级文件2", text: "第二级文件2" },
{ id: 33, pId: 3, value: "第二级目录3", text: "第二级目录1" },
{ id: 32, pId: 3, value: "第二级文件3", text: "第二级文件3" },
{ id: 331, pId: 33, value: "第三级文件1", text: "第三级文件1" }
];
this.tree.populate(tree);
}
});
BI.shortcut("demo.multilayer_single_level_tree", Demo.MultiLayerSingleLevelTree);
BI.shortcut("demo.multilayer_single_level_tree", Demo.MultiLayerSingleLevelTree);

BIN
dist/font/iconfont.eot vendored

Binary file not shown.

476
dist/font/iconfont.svg vendored

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 673 KiB

After

Width:  |  Height:  |  Size: 693 KiB

BIN
dist/font/iconfont.ttf vendored

Binary file not shown.

BIN
dist/font/iconfont.woff vendored

Binary file not shown.

BIN
dist/font/iconfont.woff2 vendored

Binary file not shown.

BIN
dist/images/2x/icon/dark/tree_solid_collapse_1.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 394 B

BIN
dist/images/2x/icon/dark/tree_solid_collapse_2.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 473 B

BIN
dist/images/2x/icon/dark/tree_solid_collapse_3.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

After

Width:  |  Height:  |  Size: 509 B

BIN
dist/images/2x/icon/dark/tree_solid_collapse_4.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

After

Width:  |  Height:  |  Size: 476 B

BIN
dist/images/2x/icon/dark/tree_solid_collapse_5.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

After

Width:  |  Height:  |  Size: 434 B

BIN
dist/images/2x/icon/dark/tree_solid_expand_1.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 330 B

BIN
dist/images/2x/icon/dark/tree_solid_expand_2.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 409 B

BIN
dist/images/2x/icon/dark/tree_solid_expand_3.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

After

Width:  |  Height:  |  Size: 466 B

BIN
dist/images/2x/icon/dark/tree_solid_expand_4.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

After

Width:  |  Height:  |  Size: 415 B

BIN
dist/images/2x/icon/dark/tree_solid_expand_5.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 376 B

BIN
dist/images/2x/icon/dark/tree_solid_vertical_line_1.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 216 B

BIN
dist/images/2x/icon/dark/tree_solid_vertical_line_2.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 233 B

BIN
dist/images/2x/icon/dark/tree_solid_vertical_line_3.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

BIN
dist/images/2x/icon/dark/tree_solid_vertical_line_4.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

BIN
dist/images/2x/icon/tree_solid_collapse_1.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 495 B

BIN
dist/images/2x/icon/tree_solid_collapse_2.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 581 B

BIN
dist/images/2x/icon/tree_solid_collapse_3.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 547 B

After

Width:  |  Height:  |  Size: 619 B

BIN
dist/images/2x/icon/tree_solid_collapse_4.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 B

After

Width:  |  Height:  |  Size: 580 B

BIN
dist/images/2x/icon/tree_solid_collapse_5.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 538 B

BIN
dist/images/2x/icon/tree_solid_expand_1.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 392 B

BIN
dist/images/2x/icon/tree_solid_expand_2.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 476 B

BIN
dist/images/2x/icon/tree_solid_expand_3.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 B

After

Width:  |  Height:  |  Size: 513 B

BIN
dist/images/2x/icon/tree_solid_expand_4.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 477 B

BIN
dist/images/2x/icon/tree_solid_expand_5.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 B

After

Width:  |  Height:  |  Size: 434 B

BIN
dist/images/2x/icon/tree_solid_vertical_line_2.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 233 B

BIN
dist/images/2x/icon/tree_solid_vertical_line_3.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

BIN
dist/images/2x/icon/tree_solid_vertical_line_4.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

BIN
dist/images/2x/icon/tree_vertical_line_1.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

After

Width:  |  Height:  |  Size: 216 B

4
examples/worker_new/index.js

@ -42,7 +42,7 @@ const HeartBeatCheckAction = BI.inherit(BI.Workers.WorkerBaseAction, {
}
});
var WorkerThreadWorker = BI.inherit(BI.Workers.MainThreadWorker, {
var MainThreadWorker = BI.inherit(BI.Workers.MainThreadWorker, {
initActions: function() {
this.cookieAction = this.createAction(CookieAction);
@ -64,7 +64,7 @@ var WorkerThreadWorker = BI.inherit(BI.Workers.MainThreadWorker, {
}
});
var mainThreadWorker = new WorkerThreadWorker({
var mainThreadWorker = BI.Workers.createWorker(MainThreadWorker, {
workerUrl: "./worker_new/worker.js",
workerName: "demo"
});

4
examples/worker_new/worker.js

@ -58,7 +58,7 @@ const HeartBeatCheckAction = BI.inherit(BI.Workers.WorkerBaseAction, {
}
});
var WorkerThreadWorker = BI.inherit(BI.Workers.WorkerThreadWorker, {
var MainThreadWorker = BI.inherit(BI.Workers.WorkerThreadWorker, {
initActions: function() {
this.cookieAction = this.createAction(CookieAction);
@ -75,6 +75,6 @@ var WorkerThreadWorker = BI.inherit(BI.Workers.WorkerThreadWorker, {
}
});
var workerThreadWorker = new WorkerThreadWorker();
var workerThreadWorker = BI.Workers.createWorker(MainThreadWorker);
workerThreadWorker.fetchCookie();

2
lodash.md

@ -1 +1 @@
lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after,unescape"
lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after,unescape,chunk"

4
package.json

@ -1,6 +1,6 @@
{
"name": "fineui",
"version": "2.0.20220720140353",
"version": "2.0.20220826175704",
"description": "fineui",
"main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts",
@ -11,7 +11,7 @@
"@babel/core": "^7.17.4",
"@babel/polyfill": "7.6.0",
"@fui/babel-preset-fineui": "^2.0.0",
"@fui/eslint-plugin": "1.0.15",
"@fui/eslint-plugin": "^1.0.15",
"@types/node": "15.6.1",
"autoprefixer": "9.6.1",
"babel-loader": "8.0.6",

9
plugins/webpack-fui-worker-plugin/constants.js

@ -0,0 +1,9 @@
const WorkerPluginName = 'FuiWorkerPlugin';
const WorkerLoaderName = 'FuiWorkerWorkerLoader';
const FileNamePrefix = 'worker-';
module.exports = {
WorkerPluginName,
WorkerLoaderName,
FileNamePrefix,
};

0
bin/cli/worker/template/action_type.ts → plugins/webpack-fui-worker-plugin/empty.js

79
plugins/webpack-fui-worker-plugin/index.js

@ -0,0 +1,79 @@
/*
* worker-plugin
*/
const path = require('path');
const webpack = require('webpack');
const { WorkerPluginName } = require('./constants');
const ModuleFilenameHelpers = require('webpack/lib/ModuleFilenameHelpers');
class FuiWorkerPlugin {
constructor(options = {}) {
this.options = options;
}
apply(compiler) {
// 为主线程构建添加 __WORKER__ 环境变量, 构建中区分不同线程源码, 实现代码拆减
compiler.hooks.afterPlugins.tap(WorkerPluginName, compiler => {
new webpack.DefinePlugin({
// __WORKER__ 表示当前所在线程是否是 worker 线程
// 主线程构建中为 false
__WORKER__: false,
}).apply(compiler);
});
// 添加自定义的worker entry-loader
compiler.hooks.afterResolvers.tap(WorkerPluginName, compiler => {
/**
* https://webpack.js.org/configuration/resolve/#resolveloader
* 使用 resolveloader 添加自定义的 worker loader
*/
if (!compiler.options.resolveLoader) {
compiler.options.resolveLoader = {
alias: {},
};
}
if (!compiler.options.resolveLoader.alias) {
compiler.options.resolveLoader.alias = {};
}
// 动态添加 worker 的 worker-loader, 命名为 "fui-worker"
compiler.options.resolveLoader.alias['fui-worker'] = path.resolve(__dirname, './worker-loader.js');
});
// 将FuiWorkerPlugin的参数传递给fui-worker loader
compiler.hooks.compilation.tap(WorkerPluginName, compilation => {
compilation.hooks.normalModuleLoader.tap(WorkerPluginName, (context, module) => {
// 仅提供给fui-worker
const fuiLoader = module.loaders.find(loader => loader.loader.indexOf('fui-worker') !== -1);
if (fuiLoader) {
const resource = module.resource;
if (!resource) return;
// fui-worker通过options读取
context.options = context.options || {};
const index = resource.indexOf('?');
if (ModuleFilenameHelpers.matchObject(
this.options,
index < 0 ? resource : resource.substr(0, index)
)) {
for (const key of Object.keys(this.options)) {
// 忽略关键属性
if (key === "include" || key === "exclude" || key === "test") {
continue;
}
context.options[key] = this.options[key];
}
}
}
})
})
}
}
module.exports = FuiWorkerPlugin;

137
plugins/webpack-fui-worker-plugin/worker-loader.js

@ -0,0 +1,137 @@
/*
* fui-worker worker-loader
*/
const webpack = require('webpack');
const loaderUtils = require('loader-utils');
const SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
const { WorkerLoaderName, FileNamePrefix } = require('./constants');
const { resolve } = require('path');
// 正常 loader 处理逻辑
function loader() {
const callback = this.async();
this.cacheable(false);
// 过滤掉当前的 worker-loader, 保留 worker 侧构建需要的其他 loader(babel-loader/ts-loader 等)
const otherLoaders = this.loaders.filter((loader, index) => {
if (index === this.loaderIndex) {
return false;
}
return true;
});
/**
* 拼接构建需要的 loader 字符串, 用于指定 childCompiler 的构建 loader
* 比如: /path/to/babel-loader/lib/index.js!/path/to/ts-loader/index.js!
*/
const loaderPath = otherLoaders.reduce((pre, loader) => `${pre}${loader.path}!`, '');
/**
* worker 独立构建的 entry
* 构建 loader + worker 源码入口文件路径
*
* https://webpack.js.org/concepts/loaders/#inline
* `!!` 实现在 childCompiler 中忽略其他所有 loader, 只保留主构建的 loader
* 不然 worker 入口在 childCompiler 中会继续由 worker-loader 处理, 造成死循环
*/
const workerEntry = `!!${loaderPath}${this.resourcePath}`;
// 把资源纳入构建流程的依赖, 实现 dev 模式下的 watch
this.addDependency(workerEntry);
// 生成的 service 独立 bundle 名称
const entryFileName = `${FileNamePrefix}index`;
// 获取传递给 loader 的 options
const options = Object.assign(loaderUtils.getOptions(this) || {}, this.options);
// 创建 childCompiler, 用于实现 worker 构建为独立 js 资源
const childCompiler = this._compilation.createChildCompiler(WorkerLoaderName, {
globalObject: 'this',
});
childCompiler.context = this._compiler.context;
// 指定独立构建的 entry 和生成 js 资源名称
new SingleEntryPlugin(this.context, workerEntry, entryFileName).apply(childCompiler);
// 设置 worker 侧的环境变量
new webpack.DefinePlugin({
__WORKER__: true,
}).apply(childCompiler);
// 添加 window 全局对象, 映射为 worker 线程全局对象 self
// 如果在 worker 源码中添加, 可能没有前置到所有引用模块前
new webpack.BannerPlugin({
banner: 'self.window = self;',
raw: true,
entryOnly: true,
}).apply(childCompiler);
// 去除源码中的less css引用
const regExp = /\.(css|less)$/;
new webpack.NormalModuleReplacementPlugin(
regExp,
result => {
if (regExp.test(result.request)) {
result.request = resolve(__dirname, './empty.js');
}
if (regExp.test(result.resource)) {
result.resource = resolve(__dirname, './empty.js');
}
},
).apply(childCompiler);
const subCache = `subcache ${__dirname} ${workerEntry}`;
childCompiler.hooks.compilation.tap(WorkerLoaderName, compilation => {
if (compilation.cache) {
if (!compilation.cache[subCache]) compilation.cache[subCache] = {};
compilation.cache = compilation.cache[subCache];
}
});
childCompiler.runAsChild((error, entries, compilation) => {
if (!error && compilation.errors && compilation.errors.length) {
// eslint-disable-next-line no-param-reassign
error = compilation.errors[0];
}
// compatible with Array (v4) and Set (v5) prototypes
const entry = entries && entries[0] && entries[0].files.values().next().value;
if (!error && !entry) {
// eslint-disable-next-line no-param-reassign
error = Error(`${WorkerLoaderName}, no entry for ${workerEntry}`);
}
if (error) {
return callback(error);
}
// 支持blob url形式
return options.inline
? callback(
null,
// 插入代码的转译和压缩由主构建配置的 babel/ts loader 处理, 不需要 worker-worker 来处理
// 添加 @ts-nocheck 避免 ts-check 报错
// 修复export const 下 const不会被转译的问题
`// @ts-nocheck
const blob = new Blob([${JSON.stringify(compilation.assets[entry].source())}]);
const workerUrl = window.URL.createObjectURL(blob);
export default workerUrl;
`
)
: callback(
null,
`// @ts-nocheck
const servicePath = __webpack_public_path__ + ${JSON.stringify(entry)};
export default servicePath;
`
)
});
return;
}
module.exports = loader;

20
src/base/0.base.js

@ -1,11 +1,9 @@
BI.prepares.push(function () {
BI.Resizers = new BI.ResizeController();
BI.Layers = new BI.LayerController();
BI.Maskers = new BI.MaskersController();
BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.PopoverController();
BI.Drawers = new BI.DrawerController();
BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
});
BI.Resizers = new BI.ResizeController();
BI.Layers = new BI.LayerController();
BI.Maskers = new BI.MaskersController();
BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.PopoverController();
BI.Drawers = new BI.DrawerController();
BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();

20
src/base/1.pane.js

@ -15,7 +15,7 @@ BI.Pane = BI.inherit(BI.Widget, {
loadingText: "",
loadingSize: "small",
overlap: true,
onLoaded: BI.emptyFn
onLoaded: BI.emptyFn,
});
},
@ -32,8 +32,8 @@ BI.Pane = BI.inherit(BI.Widget, {
},
cls: "bi-tips",
text: o.tipText,
height: 25
}]
height: 25,
}],
});
}
},
@ -42,7 +42,7 @@ BI.Pane = BI.inherit(BI.Widget, {
var self = this, o = this.options;
var loadingAnimation = BI.createWidget(BI.Providers.getProvider("bi.provider.system").getLoading({
loadingSize: o.loadingSize,
context: this
context: this,
}));
// pane在同步方式下由items决定tipText的显示与否
// loading的异步情况下由loaded后对面板的populate的时机决定
@ -53,7 +53,7 @@ BI.Pane = BI.inherit(BI.Widget, {
type: "bi.center_adapt",
cls: "loading-container",
items: this._getLoadingTipItems(loadingAnimation),
element: BI.Layers.make(this.getName() + "-loading", this)
element: BI.Layers.make(this.getName() + "-loading", this),
});
}
BI.Layers.show(self.getName() + "-loading");
@ -63,7 +63,7 @@ BI.Pane = BI.inherit(BI.Widget, {
type: "bi.center_adapt",
element: this,
cls: "loading-container",
items: this._getLoadingTipItems(loadingAnimation)
items: this._getLoadingTipItems(loadingAnimation),
});
}
self.fireEvent(BI.Pane.EVENT_LOADING);
@ -78,12 +78,12 @@ BI.Pane = BI.inherit(BI.Widget, {
var self = this, o = this.options;
var loadingTipItems = [{
type: "bi.horizontal_adapt",
items: [loadingTip]
items: [loadingTip],
}];
BI.isNotEmptyString(o.loadingText) && loadingTipItems.push({
type: "bi.text",
text: o.loadingText,
tgap: this._getSize(10)
tgap: this._getSize(10),
});
return [{
@ -91,7 +91,7 @@ BI.Pane = BI.inherit(BI.Widget, {
ref: function (_ref) {
self._loading = _ref;
},
items: loadingTipItems
items: loadingTipItems,
}];
},
@ -125,7 +125,7 @@ BI.Pane = BI.inherit(BI.Widget, {
populate: function (items) {
this.options.items = items || [];
this.check();
}
},
});
BI.Pane.EVENT_LOADED = "EVENT_LOADED";
BI.Pane.EVENT_LOADING = "EVENT_LOADING";

9
src/base/collection/__test__/collection.test.js

@ -5,7 +5,6 @@
*/
describe("CollectionTest", function () {
/**
* test_author_windy
*/
@ -15,7 +14,7 @@ describe("CollectionTest", function () {
for (var i = 0; i < cellCount; i++) {
items[i] = {
type: "bi.label",
text: i
text: i,
};
}
var grid = BI.Test.createWidget({
@ -28,11 +27,11 @@ describe("CollectionTest", function () {
x: index % 10 * 50,
y: Math.floor(index / 10) * 50,
width: 50,
height: 50
height: 50,
};
}
},
});
// TODO 列表展示类控件不知道该测什么,先标记一下
grid.destroy();
});
});
});

50
src/base/collection/collection.js

@ -24,7 +24,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
items: [],
itemFormatter: function (item, index) {
return item;
}
},
});
},
@ -38,7 +38,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
self._scrollLock = false;
}, 1000 / 60);
this.container = BI._lazyCreateWidget({
type: "bi.absolute"
type: "bi.absolute",
});
this.element.scroll(function () {
if (self._scrollLock === true) {
@ -49,7 +49,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
self._calculateChildrenToRender();
self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
scrollTop: o.scrollTop,
});
});
// 兼容一下
@ -58,7 +58,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (o.overflowY === false) {
scrollable = false;
} else {
scrollable = "y"
scrollable = "y";
}
} else {
if (o.overflowY === false) {
@ -71,7 +71,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
scrollable: scrollable,
scrolly: scrolly,
scrollx: scrollx,
items: [this.container]
items: [this.container],
});
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) {
self.populate(newValue);
@ -84,7 +84,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
// mounted之后绑定事件
mounted: function () {
var o = this.options;
var o = this.options;
if (o.scrollLeft !== 0 || o.scrollTop !== 0) {
this.element.scrollTop(o.scrollTop);
this.element.scrollLeft(o.scrollLeft);
@ -101,10 +101,10 @@ BI.CollectionView = BI.inherit(BI.Widget, {
for (var index = 0, len = o.items.length; index < len; index++) {
var cellMetadatum = o.cellSizeAndPositionGetter(index);
if (cellMetadatum.height == null || isNaN(cellMetadatum.height) ||
cellMetadatum.width == null || isNaN(cellMetadatum.width) ||
cellMetadatum.x == null || isNaN(cellMetadatum.x) ||
cellMetadatum.y == null || isNaN(cellMetadatum.y)) {
if (BI.isNull(cellMetadatum.height) || isNaN(cellMetadatum.height) ||
BI.isNull(cellMetadatum.width) || isNaN(cellMetadatum.width) ||
BI.isNull(cellMetadatum.x) || isNaN(cellMetadatum.x) ||
BI.isNull(cellMetadatum.y) || isNaN(cellMetadatum.y)) {
throw Error();
}
@ -124,16 +124,18 @@ BI.CollectionView = BI.inherit(BI.Widget, {
_cellRenderers: function (height, width, x, y) {
this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y);
return this._cellGroupRenderer();
},
_cellGroupRenderer: function () {
var self = this, o = this.options;
var self = this;
var rendered = [];
BI.each(this._lastRenderedCellIndices, function (i, index) {
var cellMetadata = self._sectionManager.getCellMetadata(index);
rendered.push(cellMetadata);
});
return rendered;
},
@ -167,16 +169,16 @@ BI.CollectionView = BI.inherit(BI.Widget, {
var topMap = BI.invert(tops);
// 存储上下左右四个边界
var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {};
var assertMinBorder = function (border, offset) {
if (border[offset] == null) {
function assertMinBorder(border, offset) {
if (BI.isNull(border[offset])) {
border[offset] = Number.MAX_VALUE;
}
};
var assertMaxBorder = function (border, offset) {
if (border[offset] == null) {
}
function assertMaxBorder(border, offset) {
if (BI.isNull(border[offset])) {
border[offset] = 0;
}
};
}
for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
var datum = childrenToDisplay[i];
var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1];
@ -194,7 +196,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
this.renderedCells[index].el.element.css("left", datum.x / BI.pixRatio + BI.pixUnit);
// }
// if (this.renderedCells[index]._top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y / BI.pixRatio + BI.pixUnit);
this.renderedCells[index].el.element.css("top", datum.y / BI.pixRatio + BI.pixUnit);
// }
renderedCells.push(child = this.renderedCells[index]);
} else {
@ -202,11 +204,11 @@ BI.CollectionView = BI.inherit(BI.Widget, {
child = BI._lazyCreateWidget(BI.extend({
type: "bi.label",
width: datum.width,
height: datum.height
height: datum.height,
}, item, {
cls: (item.cls || "") + " collection-cell" + (datum.y === 0 ? " first-row" : "") + (datum.x === 0 ? " first-col" : ""),
_left: datum.x,
_top: datum.y
_top: datum.y,
}));
renderedCells.push({
el: child,
@ -280,7 +282,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
var minY = BI.max(topBorder);
var maxY = BI.min(bottomBorder);
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY };
}
},
@ -339,7 +341,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.options.overflowX !== !!b) {
this.options.overflowX = !!b;
BI.nextTick(function () {
self.element.css({overflowX: b ? "auto" : "hidden"});
self.element.css({ overflowX: b ? "auto" : "hidden" });
});
}
},
@ -349,7 +351,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.options.overflowY !== !!b) {
this.options.overflowY = !!b;
BI.nextTick(function () {
self.element.css({overflowY: b ? "auto" : "hidden"});
self.element.css({ overflowY: b ? "auto" : "hidden" });
});
}
},
@ -396,7 +398,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
this.restore();
}
this._populate(items);
}
},
});
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut("bi.collection_view", BI.CollectionView);

42
src/base/combination/bubble.js

@ -6,17 +6,18 @@
BI.Bubble = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-popper",
attributes: {
tabIndex: -1
tabIndex: -1,
},
trigger: "click", // click || hover || click-hover || ""
toggle: true,
direction: "",
placement: "bottom-start", // top-start/top/top-end/bottom-start/bottom/bottom-end/left-start/left/left-end/right-start/right/right-end
logic: {
dynamic: true
dynamic: true,
},
container: null, // popupview放置的容器,默认为this.element
isDefaultInit: false,
@ -81,11 +82,11 @@
});
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: [
{ el: this.combo }
]
],
}))));
o.isDefaultInit && (this._assertPopupView());
},
@ -104,14 +105,14 @@
_initPullDownAction: function () {
var self = this, o = this.options;
var evs = (this.options.trigger || "").split(",");
var st = function (e) {
function st (e) {
if (o.stopEvent) {
e.stopEvent();
}
if (o.stopPropagation) {
e.stopPropagation();
}
};
}
var enterPopup = false;
@ -171,7 +172,7 @@
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
"trailing": false,
});
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e);
@ -194,7 +195,7 @@
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
"trailing": false,
});
self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) {
debounce(e);
@ -217,23 +218,25 @@
}
});
break;
default:
break;
}
});
},
_initCombo: function () {
this.combo = BI.createWidget(this.options.el, {
value: this.options.value
value: this.options.value,
});
},
_assertPopupView: function () {
var self = this, o = this.options;
if (this.popupView == null) {
if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, {
type: "bi.bubble_popup_view",
showArrow: o.showArrow,
value: o.value
value: o.value,
}, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.CLICK) {
@ -258,7 +261,7 @@
element: this.options.container || this,
items: [
{ el: this.popupView }
]
],
});
this._rendered = true;
}
@ -286,6 +289,7 @@
return;
}
this._hideView(e);
return true;
},
@ -319,7 +323,7 @@
},
_popupView: function (e) {
var self = this, o = this.options;
var o = this.options;
this._assertPopupViewRender();
this.fireEvent(BI.Bubble.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
@ -335,22 +339,22 @@
options: {
offset: function () {
return [o.adjustXOffset, (o.showArrow ? 12 : 0) + (o.adjustYOffset + o.adjustLength)];
}
}
},
},
}];
if (this.options.showArrow) {
modifiers.push({
name: "arrow",
options: {
padding: 4,
element: this.popupView.arrow.element[0]
}
element: this.popupView.arrow.element[0],
},
});
}
this.popper = BI.Popper.createPopper(this.combo.element[0], this.popupView.element[0], {
placement: o.placement,
strategy: "fixed",
modifiers: modifiers
modifiers: modifiers,
});
// this.adjustHeight(e);
@ -478,7 +482,7 @@
this.popper && this.popper.destroy();
this.popper = null;
this.popupView && this.popupView._destroy();
}
},
});
BI.Bubble.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
BI.Bubble.EVENT_CHANGE = "EVENT_CHANGE";

38
src/base/combination/combo.js

@ -1,26 +1,28 @@
!(function () {
var needHideWhenAnotherComboOpen = {};
var currentOpenedCombos = {};
/**
* @class BI.Combo
* @extends BI.Widget
*/
BI.Combo = BI.inherit(BI.Bubble, {
_const: {
TRIANGLE_LENGTH: 12
TRIANGLE_LENGTH: 12,
},
_defaultConfig: function () {
var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""),
attributes: {
tabIndex: -1
tabIndex: -1,
},
trigger: "click", // click || hover || click-hover || ""
toggle: true,
direction: "bottom", // top||bottom||left||right||top,left||top,right||bottom,left||bottom,right||right,innerRight||right,innerLeft||innerRight||innerLeft
logic: {
dynamic: true
dynamic: true,
},
container: null, // popupview放置的容器,默认为this.element
isDefaultInit: false,
@ -42,7 +44,7 @@
popup: {},
comboClass: "bi-combo-popup",
hoverClass: "bi-combo-hover",
belowMouse: false
belowMouse: false,
});
},
@ -90,11 +92,11 @@
});
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: [
{ el: this.combo }
]
],
}))));
o.isDefaultInit && (this._assertPopupView());
BI.Resizers.add(this.getName(), BI.bind(function (e) {
@ -107,11 +109,11 @@
_assertPopupView: function () {
var self = this, o = this.options;
if (this.popupView == null) {
if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, {
type: "bi.popup_view",
showArrow: o.showArrow,
value: o.value
value: o.value,
}, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.CLICK) {
@ -195,7 +197,7 @@
offset: function () {
return {
left: e.pageX,
top: e.pageY
top: e.pageY,
};
},
bounds: function () {
@ -204,7 +206,7 @@
x: e.offsetX,
y: e.offsetY,
width: 0,
height: 24
height: 24,
};
},
outerWidth: function () {
@ -212,8 +214,8 @@
},
outerHeight: function () {
return 24;
}
}
},
},
} : this.combo;
switch (o.direction) {
case "bottom":
@ -280,10 +282,12 @@
delete p.adaptHeight;
p.dir = "right";
break;
default:
break;
}
if ("adaptHeight" in p) {
this.resetListHeight(p["adaptHeight"]);
this.resetListHeight(p.adaptHeight);
}
var width = this.combo.element.outerWidth();
var height = this.combo.element.outerHeight();
@ -293,16 +297,16 @@
offsetStyle: o.offsetStyle,
adjustXOffset: o.adjustXOffset,
adjustYOffset: o.adjustYOffset,
offset: this.combo.element.offset()
offset: this.combo.element.offset(),
});
if ("left" in p) {
this.popupView.element.css({
left: p.left
left: p.left,
});
}
if ("top" in p) {
this.popupView.element.css({
top: p.top
top: p.top,
});
}
this.position = p;
@ -322,7 +326,7 @@
this.popupView && this.popupView._destroy();
delete needHideWhenAnotherComboOpen[this.getName()];
delete currentOpenedCombos[this.getName()];
}
},
});
BI.Combo.closeAll = function () {
BI.each(currentOpenedCombos, function (i, combo) {

20
src/base/combination/expander.js

@ -17,7 +17,7 @@ BI.Expander = BI.inherit(BI.Widget, {
el: {},
popup: {},
expanderClass: "bi-expander-popup",
hoverClass: "bi-expander-hover"
hoverClass: "bi-expander-hover",
});
},
@ -66,7 +66,7 @@ BI.Expander = BI.inherit(BI.Widget, {
element: this,
items: [
{ el: this.expander }
]
],
});
o.isDefaultInit && this._assertPopupView();
if (this.expander.isOpened() === true) {
@ -122,10 +122,12 @@ BI.Expander = BI.inherit(BI.Widget, {
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
"trailing": false,
}));
}
break;
default:
break;
}
});
},
@ -136,16 +138,16 @@ BI.Expander = BI.inherit(BI.Widget, {
_assertPopupView: function () {
var self = this, o = this.options;
if (this.popupView == null) {
if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(this.options.popup, {
type: "bi.button_group",
cls: "expander-popup",
layouts: [{
type: "bi.vertical",
hgap: 0,
vgap: 0
vgap: 0,
}],
value: o.value
value: o.value,
}, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -170,7 +172,7 @@ BI.Expander = BI.inherit(BI.Widget, {
element: this,
items: [
{ el: this.popupView }
]
],
});
this._rendered = true;
}
@ -255,6 +257,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (this.expander.options.id === id) {
return this.expander;
}
return this.popupView && this.popupView.getNodeById(id);
},
@ -262,12 +265,13 @@ BI.Expander = BI.inherit(BI.Widget, {
if (this.expander.getValue() === value) {
return this.expander;
}
return this.popupView && this.popupView.getNodeByValue(value);
},
destroy: function () {
BI.Expander.superclass.destroy.apply(this, arguments);
}
},
});
BI.Expander.EVENT_EXPAND = "EVENT_EXPAND";
BI.Expander.EVENT_COLLAPSE = "EVENT_COLLAPSE";

40
src/base/combination/group.button.js

@ -15,8 +15,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
layouts: [{
type: "bi.center",
hgap: 0,
vgap: 0
}]
vgap: 0,
}],
});
},
@ -25,7 +25,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
var behaviors = {};
BI.each(o.behaviors, function (key, rule) {
behaviors[key] = BI.BehaviorFactory.createBehavior(key, {
rule: rule
rule: rule,
});
});
this.behaviors = behaviors;
@ -42,9 +42,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
},
_createBtns: function (items) {
var o = this.options;
return BI.createWidgets(BI.createItems(items, {
type: "bi.text_button"
type: "bi.text_button",
}), this);
},
@ -66,6 +65,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
case BI.ButtonGroup.CHOOSE_TYPE_NONE:
self.setValue([]);
break;
default:
break;
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
@ -89,23 +90,26 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
return BI.extend({}, layouts[i], {
items: [
BI.extend({}, layouts[i].el, {
el: it
el: it,
})
]
],
});
});
}
return btns;
},
_packageSimpleItems: function (btns) {
var o = this.options;
return BI.map(o.items, function (i, item) {
if (BI.stripEL(item) === item) {
return btns[i];
}
return BI.extend({}, item, {
el: btns[i]
el: btns[i],
});
});
},
@ -122,12 +126,14 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
lay = BI.formatEL(lay.items[0]).el;
}
lay.items = items;
return layout;
},
// 如果是一个简单的layout
_isSimpleLayout: function () {
var o = this.options;
return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true;
},
@ -140,12 +146,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
},
prependItems: function (items) {
var o = this.options;
var btns = this._btnsCreator.apply(this, arguments);
this.buttons = BI.concat(btns, this.buttons);
if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) {
this.layouts.prependItems(btns);
return;
}
@ -154,13 +160,13 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
},
addItems: function (items) {
var o = this.options;
var btns = this._btnsCreator.apply(this, arguments);
this.buttons = BI.concat(this.buttons, btns);
// 如果是一个简单的layout
if (this._isSimpleLayout() && this.layouts && this.layouts.addItems) {
this.layouts.addItems(btns);
return;
}
@ -257,6 +263,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
v.push(item.getValue());
}
});
return v;
},
@ -267,6 +274,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
v.push(item.getValue());
}
});
return v;
},
@ -285,6 +293,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
btns.push(item);
}
});
return btns;
},
@ -295,6 +304,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
btns.push(item);
}
});
return btns;
},
@ -303,9 +313,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.getValue() === value) {
index = i;
return true;
}
});
return index;
},
@ -314,9 +326,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.options.id === id) {
node = item;
return true;
}
});
return node;
},
@ -325,9 +339,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.getValue() === value) {
node = item;
return true;
}
});
return node;
},
@ -349,14 +365,14 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
destroy: function () {
BI.ButtonGroup.superclass.destroy.apply(this, arguments);
this.options.items = [];
}
},
});
BI.extend(BI.ButtonGroup, {
CHOOSE_TYPE_SINGLE: BI.Selection.Single,
CHOOSE_TYPE_MULTI: BI.Selection.Multi,
CHOOSE_TYPE_ALL: BI.Selection.All,
CHOOSE_TYPE_NONE: BI.Selection.None,
CHOOSE_TYPE_DEFAULT: BI.Selection.Default
CHOOSE_TYPE_DEFAULT: BI.Selection.Default,
});
BI.ButtonGroup.EVENT_CHANGE = "EVENT_CHANGE";

18
src/base/combination/group.combo.js

@ -15,7 +15,7 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: {type: "bi.text_button", text: "", value: ""},
el: { type: "bi.text_button", text: "", value: "" },
items: [],
popup: {
@ -23,10 +23,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}
}
type: "bi.vertical",
}],
},
},
});
},
@ -71,9 +71,9 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
el: item,
popup: BI.extend({}, o.popup, {
el: BI.extend({
items: children
}, o.popup.el)
})
items: children,
}, o.popup.el),
}),
});
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -89,7 +89,7 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
setValue: function (v) {
this.combo.setValue(v);
}
},
});
BI.ComboGroup.EVENT_CHANGE = "EVENT_CHANGE";

21
src/base/combination/group.virtual.js

@ -6,8 +6,8 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
layouts: [{
type: "bi.center",
hgap: 0,
vgap: 0
}]
vgap: 0,
}],
});
},
@ -29,9 +29,10 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
var o = this.options;
var map = this.buttonMap = {};
var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts];
for (var i = layouts.length - 1; i > 0; i--) {
for (let i = layouts.length - 1; i > 0; i--) {
items = BI.map(items, function (k, it) {
var el = BI.stripEL(it);
return BI.extend({}, layouts[i], {
items: [
BI.extend({}, layouts[i].el, {
@ -40,13 +41,14 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
if (BI.isKey(map[el.value])) {
map[el.value] = _ref;
}
}
}, el)
},
}, el),
})
]
],
});
});
}
return items;
},
@ -60,6 +62,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
lay = BI.formatEL(lay.items[0]).el;
}
lay.items = items;
return layout;
},
@ -93,6 +96,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
}
}
});
return v;
},
@ -119,6 +123,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
}
}
});
return v;
},
@ -130,10 +135,10 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
this.layouts = BI.createWidget(BI.extend({ element: this }, this._packageLayout(items)));
} else {
this.layouts.populate(items, {
context: this
context: this,
});
}
}
},
});
BI.VirtualGroup.EVENT_CHANGE = "EVENT_CHANGE";

36
src/base/combination/loader.js

@ -14,12 +14,12 @@ BI.Loader = BI.inherit(BI.Widget, {
isDefaultInit: true, // 是否默认初始化数据
logic: {
dynamic: true,
scrolly: true
scrolly: true,
},
// 下面是button_group的属性
el: {
type: "bi.button_group"
type: "bi.button_group",
},
items: [],
@ -31,14 +31,14 @@ BI.Loader = BI.inherit(BI.Widget, {
prev: false,
next: {},
hasPrev: BI.emptyFn,
hasNext: BI.emptyFn
hasNext: BI.emptyFn,
});
},
_prevLoad: function () {
var self = this, o = this.options;
this.prev.setLoading();
o.itemsCreator.apply(this, [{times: --this.times}, function () {
o.itemsCreator.apply(this, [{ times: --this.times }, function () {
self.prev.setLoaded();
self.prependItems.apply(self, arguments);
}]);
@ -47,7 +47,7 @@ BI.Loader = BI.inherit(BI.Widget, {
_nextLoad: function () {
var self = this, o = this.options;
this.next.setLoading();
o.itemsCreator.apply(this, [{times: ++this.times}, function () {
o.itemsCreator.apply(this, [{ times: ++this.times }, function () {
self.next.setLoaded();
self.addItems.apply(self, arguments);
}]);
@ -61,7 +61,7 @@ BI.Loader = BI.inherit(BI.Widget, {
}
if (o.prev !== false) {
this.prev = BI.createWidget(BI.extend({
type: "bi.loading_bar"
type: "bi.loading_bar",
}, o.prev));
this.prev.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
@ -76,9 +76,9 @@ BI.Loader = BI.inherit(BI.Widget, {
items: o.items,
behaviors: {},
layouts: [{
type: "bi.vertical"
type: "bi.vertical",
}],
value: o.value
value: o.value,
});
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -89,7 +89,7 @@ BI.Loader = BI.inherit(BI.Widget, {
if (o.next !== false) {
this.next = BI.createWidget(BI.extend({
type: "bi.loading_bar"
type: "bi.loading_bar",
}, o.next));
this.next.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
@ -99,11 +99,11 @@ BI.Loader = BI.inherit(BI.Widget, {
}
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({
scrolly: true
scrolly: true,
}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.prev, this.button_group, this.next)
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.prev, this.button_group, this.next),
}))));
o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () {
@ -122,9 +122,10 @@ BI.Loader = BI.inherit(BI.Widget, {
if (BI.isNumber(o.count)) {
return this.count < o.count;
}
return !!o.hasPrev.apply(this, [{
times: this.times,
count: this.count
count: this.count,
}]);
},
@ -133,9 +134,10 @@ BI.Loader = BI.inherit(BI.Widget, {
if (BI.isNumber(o.count)) {
return this.count < o.count;
}
return !!o.hasNext.apply(this, [{
times: this.times,
count: this.count
count: this.count,
}]);
},
@ -168,13 +170,14 @@ BI.Loader = BI.inherit(BI.Widget, {
_populate: function (items) {
var self = this, o = this.options;
if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) {
o.itemsCreator.apply(this, [{times: 1}, function () {
o.itemsCreator.apply(this, [{ times: 1 }, function () {
if (arguments.length === 0) {
throw new Error("参数不能为空");
}
self.populate.apply(self, arguments);
o.onLoaded();
}]);
return false;
}
this.options.items = items;
@ -195,6 +198,7 @@ BI.Loader = BI.inherit(BI.Widget, {
this.prev.invisible();
}
}
return true;
},
@ -255,7 +259,7 @@ BI.Loader = BI.inherit(BI.Widget, {
destroy: function () {
BI.Loader.superclass.destroy.apply(this, arguments);
}
},
});
BI.Loader.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.loader", BI.Loader);

19
src/base/combination/navigation.js

@ -7,7 +7,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
return BI.extend(BI.Navigation.superclass._defaultConfig.apply(this, arguments), {
direction: "bottom", // top, bottom, left, right, custom
logic: {
dynamic: false
dynamic: false,
},
single: false,
showIndex: false,
@ -17,22 +17,22 @@ BI.Navigation = BI.inherit(BI.Widget, {
},
afterCardCreated: BI.emptyFn,
afterCardShow: BI.emptyFn
afterCardShow: BI.emptyFn,
});
},
render: function () {
var self = this, o = this.options;
this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"});
this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group" });
this.cardMap = {};
this.showIndex = 0;
this.layout = BI.createWidget({
type: "bi.card"
type: "bi.card",
});
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout)
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout),
}))));
@ -45,16 +45,17 @@ BI.Navigation = BI.inherit(BI.Widget, {
cardCreator: function (v) {
var card = o.cardCreator(v);
self.cardMap[v] = card;
return card;
},
afterCardCreated: BI.bind(this.afterCardCreated, this),
afterCardShow: BI.bind(this.afterCardShow, this)
afterCardShow: BI.bind(this.afterCardShow, this),
});
if (BI.isFunction(o.showIndex)) {
this.__watch(o.showIndex, function (context, newValue) {
self.setSelect(newValue);
})
});
}
},
@ -161,7 +162,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
destroy: function () {
BI.Navigation.superclass.destroy.apply(this, arguments);
}
},
});
BI.Navigation.EVENT_CHANGE = "EVENT_CHANGE";

34
src/base/combination/searcher.js

@ -28,17 +28,17 @@ BI.Searcher = BI.inherit(BI.Widget, {
},
el: {
type: "bi.search_editor"
type: "bi.search_editor",
},
popup: {
type: "bi.searcher_view"
type: "bi.searcher_view",
},
adapter: null,
masker: { // masker层
offset: {}
}
offset: {},
},
});
},
@ -46,7 +46,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
var self = this, o = this.options;
this.editor = BI.createWidget(o.el, {
type: "bi.search_editor"
type: "bi.search_editor",
});
BI.createWidget({
@ -58,13 +58,13 @@ BI.Searcher = BI.inherit(BI.Widget, {
bgap: o.bgap,
vgap: o.vgap,
hgap: o.hgap,
items: [this.editor]
items: [this.editor],
});
o.isDefaultInit && (this._assertPopupView());
var search = BI.debounce(BI.bind(this._search, this), BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
"trailing": false,
});
this.editor.on(BI.Controller.EVENT_CHANGE, function (type) {
switch (type) {
@ -82,6 +82,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
self._pauseSearch();
}
break;
default:
break;
}
});
},
@ -91,7 +93,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
if ((o.masker && !BI.Maskers.has(this.getName())) || (o.masker === false && !this.popupView)) {
this.popupView = BI.createWidget(o.popup, {
type: "bi.searcher_view",
chooseType: o.chooseType
chooseType: o.chooseType,
});
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -109,6 +111,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
values.push(obj.getValue());
o.adapter && o.adapter.setValue(values);
break;
default:
break;
}
}
self.fireEvent(BI.Searcher.EVENT_CHANGE, value, obj);
@ -121,7 +125,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (o.masker && !BI.Maskers.has(this.getName())) {
BI.Maskers.create(this.getName(), o.adapter, BI.extend({
container: this,
render: this.popupView
render: this.popupView,
}, o.masker), this);
}
},
@ -140,7 +144,6 @@ BI.Searcher = BI.inherit(BI.Widget, {
},
_pauseSearch: function () {
var o = this.options, name = this.getName();
this._stop = true;
BI.nextTick(function (name) {
BI.Maskers.hide(name);
@ -153,7 +156,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
},
_stopSearch: function () {
var o = this.options, name = this.getName();
var name = this.getName();
this._stop = true;
BI.Maskers.hide(name);
if (this._isSearching === true) {
@ -175,13 +178,14 @@ BI.Searcher = BI.inherit(BI.Widget, {
this.popupView.populate(find, match, keyword);
o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue());
self.fireEvent(BI.Searcher.EVENT_SEARCHING);
return;
}
this.popupView.loading && this.popupView.loading();
o.onSearch({
times: 1,
keyword: keyword,
selectedValues: o.adapter && o.adapter.getValue()
selectedValues: o.adapter && o.adapter.getValue(),
}, function (searchResult, matchResult) {
if (!self._stop && keyword === self.editor.getValue()) {
var args = [].slice.call(arguments);
@ -203,6 +207,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (BI.isEmptyString(res[res.length - 1])) {
res = res.slice(0, res.length - 1);
}
return BI.isNull(res) ? "" : res[res.length - 1];
}
},
@ -246,6 +251,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
hasMatched: function () {
this._assertPopupView();
return this.popupView.hasMatched();
},
@ -288,8 +294,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (BI.isNull(this.popupView)) {
return o.popup.value;
}
return this.popupView.getValue();
return this.popupView.getValue();
},
populate: function (result, searchResult, keyword) {
@ -319,7 +325,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
setWaterMark: function (v) {
this.editor.setWaterMark(v);
}
},
});
BI.Searcher.EVENT_CHANGE = "EVENT_CHANGE";
BI.Searcher.EVENT_START = "EVENT_START";

18
src/base/combination/switcher.js

@ -18,7 +18,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
adapter: null,
masker: {},
switcherClass: "bi-switcher-popup",
hoverClass: "bi-switcher-hover"
hoverClass: "bi-switcher-hover",
});
},
@ -66,7 +66,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
element: this,
items: [
{ el: this.switcher }
]
],
});
o.isDefaultInit && (this._assertPopupView());
},
@ -119,7 +119,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
}
}, BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
"trailing": false,
}));
}
break;
@ -129,7 +129,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
_initSwitcher: function () {
this.switcher = BI.createWidget(this.options.el, {
value: this.options.value
value: this.options.value,
});
},
@ -143,9 +143,9 @@ BI.Switcher = BI.inherit(BI.Widget, {
layouts: [{
type: "bi.vertical",
hgap: 0,
vgap: 0
vgap: 0,
}],
value: o.value
value: o.value,
}, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -160,7 +160,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
element: this,
items: [
{ el: this.popupView }
]
],
});
}
this._created = true;
@ -265,6 +265,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (this.switcher.attr("id") === id) {
return this.switcher;
}
return this.popupView && this.popupView.getNodeById(id);
},
@ -272,12 +273,13 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (this.switcher.getValue() === value) {
return this.switcher;
}
return this.popupView && this.popupView.getNodeByValue(value);
},
empty: function () {
this.popupView && this.popupView.empty();
}
},
});
BI.Switcher.EVENT_EXPAND = "EVENT_EXPAND";
BI.Switcher.EVENT_COLLAPSE = "EVENT_COLLAPSE";

16
src/base/combination/tab.js

@ -9,14 +9,14 @@ BI.Tab = BI.inherit(BI.Widget, {
direction: "top", // top, bottom, left, right, custom
single: false, // 是不是单页面
logic: {
dynamic: false
dynamic: false,
},
showIndex: false,
tab: false,
cardCreator: function (v) {
return BI.createWidget();
},
keepAlives: []
keepAlives: [],
});
},
@ -30,13 +30,13 @@ BI.Tab = BI.inherit(BI.Widget, {
}
this.cardMap = {};
this.layout = BI.createWidget({
type: "bi.card"
type: "bi.card",
});
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout)
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout),
}))));
var listener = new BI.ShowListener({
@ -51,7 +51,7 @@ BI.Tab = BI.inherit(BI.Widget, {
afterCardShow: function (v) {
self._deleteOtherCards(v);
self.curr = v;
}
},
});
listener.on(BI.ShowListener.EVENT_CHANGE, function (value) {
self.fireEvent(BI.Tab.EVENT_CHANGE, value, self);
@ -112,7 +112,7 @@ BI.Tab = BI.inherit(BI.Widget, {
},
removeTab: function (cardname) {
var self = this, o = this.options;
var self = this;
BI.any(this.cardMap, function (name, card) {
if (BI.isEqual(name, (cardname + ""))) {
self.layout.deleteCardByName(name);
@ -170,7 +170,7 @@ BI.Tab = BI.inherit(BI.Widget, {
destroy: function () {
this.cardMap = {};
BI.Tab.superclass.destroy.apply(this, arguments);
}
},
});
BI.Tab.EVENT_CHANGE = "EVENT_CHANGE";

29
src/base/combination/tree.button.js

@ -7,7 +7,7 @@
BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
_defaultConfig: function () {
return BI.extend(BI.ButtonTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-button-tree"
baseCls: "bi-button-tree",
});
},
@ -16,6 +16,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (!BI.isFunction(item.setSelected)) {
item.setNotSelectedValue(v);
return;
}
if (BI.deepContains(v, item.getValue())) {
@ -31,6 +32,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (BI.isFunction(item.setEnabledValue)) {
item.setEnabledValue(v);
return;
}
if (BI.deepContains(v, item.getValue())) {
@ -46,6 +48,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (!BI.isFunction(item.setSelected)) {
item.setValue(v);
return;
}
if (BI.deepContains(v, item.getValue())) {
@ -61,12 +64,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
v = BI.concat(v, item.getNotSelectedValue());
return;
}
if (item.isEnabled() && item.isSelected && !item.isSelected()) {
v.push(item.getValue());
}
});
return v;
},
@ -75,12 +80,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
v = BI.concat(v, item.getValue());
return;
}
if (item.isEnabled() && item.isSelected && item.isSelected()) {
v.push(item.getValue());
}
});
return v;
},
@ -89,12 +96,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
btns = btns.concat(item.getSelectedButtons());
return;
}
if (item.isSelected && item.isSelected()) {
btns.push(item);
}
});
return btns;
},
@ -103,12 +112,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
btns = btns.concat(item.getNotSelectedButtons());
return;
}
if (item.isSelected && !item.isSelected()) {
btns.push(item);
}
});
return btns;
},
@ -118,12 +129,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
leaves = leaves.concat(item.getAllLeaves());
return;
}
if (item.isEnabled()) {
leaves.push(item);
}
});
return leaves;
},
@ -133,9 +146,11 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
var vs = item.getValue();
if (item.isEnabled() && (vs === value || BI.contains(vs, value))) {
index = i;
return true;
}
});
return index;
},
@ -145,14 +160,17 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
if (item.isEnabled()) {
if (item.attr("id") === id) {
node = item;
return true;
} else if (BI.isFunction(item.getNodeById)) {
if (node = item.getNodeById(id)) {
node = item.getNodeById(id);
if (node) {
return true;
}
}
}
});
return node;
},
@ -161,17 +179,20 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.any(this.buttons, function (i, item) {
if (item.isEnabled()) {
if (BI.isFunction(item.getNodeByValue)) {
if (node = item.getNodeByValue(value)) {
node = item.getNodeByValue(value);
if (node) {
return true;
}
} else if (item.attr("value") === value) {
node = item;
return true;
}
}
});
return node;
}
},
});
BI.ButtonTree.EVENT_CHANGE = "EVENT_CHANGE";

6
src/base/context.js

@ -10,13 +10,13 @@ BI.Context = BI.inherit(BI.Widget, {
context: "",
watch: {},
el: {},
items: []
items: [],
},
render: function () {
var self = this, o = this.options;
this.context = BI.createWidget(o.items[0] || o.el, {
element: this
element: this,
});
this.context.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -40,6 +40,6 @@ BI.Context = BI.inherit(BI.Widget, {
populate: function () {
this.context.populate.apply(this, arguments);
}
},
});
BI.shortcut("bi.context", BI.Context);

6
src/base/el.js

@ -9,14 +9,14 @@ BI.EL = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.EL.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-el",
el: {}
el: {},
});
},
render: function () {
var self = this, o = this.options;
this.ele = BI.createWidget(o.el, {
element: this
element: this,
});
this.ele.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -33,6 +33,6 @@ BI.EL = BI.inherit(BI.Widget, {
populate: function () {
this.ele.populate.apply(this, arguments);
}
},
});
BI.shortcut("bi.el", BI.EL);

4
src/base/foundation/__test__/message.test.js

@ -4,7 +4,6 @@
* Created by windy on 2020/3/9
*/
describe("MessageTest", function () {
/**
* test_author_windy
*/
@ -24,7 +23,7 @@ describe("MessageTest", function () {
*/
it("toast_hand_close", function (done) {
BI.Msg.toast("message", {
autoClose: false
autoClose: false,
});
var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-toast").length).to.equal(1);
@ -44,4 +43,3 @@ describe("MessageTest", function () {
expect(body.find(".bi-toast").length).to.equal(1);
});
});

76
src/base/foundation/message.js

@ -3,8 +3,7 @@
* 弹出提示消息框用于模拟阻塞操作通过回调函数实现
* @class BI.Msg
*/
BI.Msg = function () {
BI.Msg = ((function () {
var $mask, $pop;
var messageShows = [];
@ -22,7 +21,7 @@ BI.Msg = function () {
// BI.Msg.prompt(title, message, value, callback, min_width);
},
toast: function (message, options, context) {
BI.isString(options) && (options = { level: options })
BI.isString(options) && (options = { level: options });
options = options || {};
context = context || BI.Widget._renderEngine.createElement("body");
var level = options.level || "common";
@ -41,12 +40,12 @@ BI.Msg = function () {
BI.remove(toastStack, toast.element);
var _height = BI.SIZE_CONSANTS.TOAST_TOP;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
element.css({ "top": _height });
_height += element.outerHeight() + 10;
});
callback();
}
}]
},
}],
});
var height = BI.SIZE_CONSANTS.TOAST_TOP;
BI.each(toastStack, function (i, element) {
@ -58,20 +57,21 @@ BI.Msg = function () {
items: [{
el: toast,
left: "50%",
top: height
}]
top: height,
}],
});
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.css({ "margin-left": -1 * toast.element.outerWidth() / 2 });
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy();
toast.destroy?.();
}, 5000);
return function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy();
toast.destroy?.();
};
},
_show: function (hasCancel, title, message, callback) {
@ -82,7 +82,7 @@ BI.Msg = function () {
left: 0,
right: 0,
bottom: 0,
opacity: 0.5
opacity: 0.5,
}).appendTo("body"));
$pop = BI.Widget._renderEngine.createElement("<div class=\"bi-message-depend\">").css({
position: "absolute",
@ -90,16 +90,16 @@ BI.Msg = function () {
top: 0,
left: 0,
right: 0,
bottom: 0
bottom: 0,
}).appendTo("body");
var close = function () {
function close () {
messageShows[messageShows.length - 1].destroy();
messageShows.pop();
if (messageShows.length === 0) {
$mask.remove();
$mask = null;
}
};
}
var controlItems = [];
if (hasCancel === true) {
controlItems.push({
@ -112,8 +112,8 @@ BI.Msg = function () {
if (BI.isFunction(callback)) {
callback.apply(null, [false]);
}
}
}
},
},
});
}
controlItems.push({
@ -125,8 +125,8 @@ BI.Msg = function () {
if (BI.isFunction(callback)) {
callback.apply(null, [true]);
}
}
}
},
},
});
var conf = {
element: $pop,
@ -135,7 +135,7 @@ BI.Msg = function () {
{
type: "bi.border",
attributes: {
tabIndex: 1
tabIndex: 1,
},
mounted: function () {
this.element.keyup(function (e) {
@ -173,8 +173,8 @@ BI.Msg = function () {
text: title || BI.i18nText("BI-Basic_Prompt"),
textAlign: "left",
hgap: 20,
height: 40
}
height: 40,
},
},
east: {
el: {
@ -186,13 +186,13 @@ BI.Msg = function () {
if (BI.isFunction(callback)) {
callback.apply(null, [false]);
}
}
},
},
width: 56
}
}
width: 56,
},
},
},
height: 40
height: 40,
},
center: {
el: BI.isPlainObject(message) ? message : {
@ -200,8 +200,8 @@ BI.Msg = function () {
vgap: 10,
hgap: 20,
whiteSpace: "normal",
text: message
}
text: message,
},
},
south: {
el: {
@ -210,25 +210,25 @@ BI.Msg = function () {
el: {
type: "bi.right_vertical_adapt",
lgap: 10,
items: controlItems
items: controlItems,
},
top: 0,
left: 20,
right: 20,
bottom: 0
}]
bottom: 0,
}],
},
height: 44
}
height: 44,
},
},
width: 450,
height: 200
height: 200,
}
]
],
};
messageShows[messageShows.length] = BI.createWidget(conf);
}
},
};
}();
})());

7
src/base/grid/__test__/grid.test.js

@ -4,7 +4,6 @@
* Created by windy on 2020/3/20
*/
describe("GridTest", function () {
/**
* test_author_windy
*/
@ -16,7 +15,7 @@ describe("GridTest", function () {
for (var j = 0; j < columnCount; j++) {
items[i][j] = {
type: "bi.label",
text: i + "-" + j
text: i + "-" + j,
};
}
}
@ -33,9 +32,9 @@ describe("GridTest", function () {
},
columnWidthGetter: function () {
return 100;
}
},
});
// TODO 性能展示类控件,不知道要测啥,标记一下
grid.destroy();
});
});
});

28
src/base/grid/grid.js

@ -27,7 +27,7 @@ BI.GridView = BI.inherit(BI.Widget, {
items: [],
itemFormatter: function (item, row, col) {
return item;
}
},
});
},
@ -41,7 +41,7 @@ BI.GridView = BI.inherit(BI.Widget, {
self._scrollLock = false;
}, 1000 / 60);
this.container = BI._lazyCreateWidget({
type: "bi.absolute"
type: "bi.absolute",
});
this.element.scroll(function () {
if (self._scrollLock === true) {
@ -52,7 +52,7 @@ BI.GridView = BI.inherit(BI.Widget, {
self._calculateChildrenToRender();
self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
scrollTop: o.scrollTop,
});
});
// 兼容一下
@ -61,7 +61,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (o.overflowY === false) {
scrollable = false;
} else {
scrollable = "y"
scrollable = "y";
}
} else {
if (o.overflowY === false) {
@ -74,7 +74,7 @@ BI.GridView = BI.inherit(BI.Widget, {
scrollable: scrollable,
scrolly: scrolly,
scrollx: scrollx,
items: [this.container]
items: [this.container],
});
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) {
self.populate(newValue);
@ -115,7 +115,7 @@ BI.GridView = BI.inherit(BI.Widget, {
_getOverscanIndices: function (cellCount, overscanCellsCount, startIndex, stopIndex) {
return {
overscanStartIndex: Math.max(0, startIndex - overscanCellsCount),
overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount)
overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount),
};
},
@ -197,20 +197,20 @@ BI.GridView = BI.inherit(BI.Widget, {
child = BI._lazyCreateWidget(BI.extend({
type: "bi.label",
width: columnDatum.size,
height: rowDatum.size
height: rowDatum.size,
}, item, {
cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""),
_rowIndex: rowIndex,
_columnIndex: columnIndex,
_left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment
_top: rowDatum.offset + verticalOffsetAdjustment,
}), this);
renderedCells.push({
el: child,
left: columnDatum.offset + horizontalOffsetAdjustment,
top: rowDatum.offset + verticalOffsetAdjustment,
_left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment
_top: rowDatum.offset + verticalOffsetAdjustment,
// _width: columnDatum.size,
// _height: rowDatum.size
});
@ -258,7 +258,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY };
}
},
@ -279,7 +279,7 @@ BI.GridView = BI.inherit(BI.Widget, {
},
_populate: function (items) {
var self = this, o = this.options;
var o = this.options;
this._reRange();
if (items && items !== this.options.items) {
this.options.items = items;
@ -333,7 +333,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.options.overflowX !== !!b) {
this.options.overflowX = !!b;
BI.nextTick(function () {
self.element.css({overflowX: b ? "auto" : "hidden"});
self.element.css({ overflowX: b ? "auto" : "hidden" });
});
}
},
@ -343,7 +343,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.options.overflowY !== !!b) {
this.options.overflowY = !!b;
BI.nextTick(function () {
self.element.css({overflowY: b ? "auto" : "hidden"});
self.element.css({ overflowY: b ? "auto" : "hidden" });
});
}
},
@ -398,7 +398,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this.restore();
}
this._populate(items);
}
},
});
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut("bi.grid_view", BI.GridView);

9
src/base/layer/__test__/layer.popover.test.js

@ -5,7 +5,6 @@
*/
describe("PopoverTest", function () {
/**
* test_author_windy
*/
@ -17,12 +16,12 @@ describe("PopoverTest", function () {
size: "normal",
header: {
type: "bi.label",
text: "这个是header"
text: "这个是header",
},
body: {
type: "bi.label",
text: "这个是body"
}
text: "这个是body",
},
}).open(id);
BI.delay(function () {
expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).to.equal(1);
@ -30,4 +29,4 @@ describe("PopoverTest", function () {
done();
}, 100);
});
});
});

72
src/base/layer/layer.drawer.js

@ -7,7 +7,7 @@ BI.Drawer = BI.inherit(BI.Widget, {
SIZE: {
SMALL: "small",
NORMAL: "normal",
BIG: "big"
BIG: "big",
},
props: {
baseCls: "bi-drawer bi-card",
@ -19,7 +19,7 @@ BI.Drawer = BI.inherit(BI.Widget, {
closable: true, // BI-40839 是否显示右上角的关闭按钮
bodyHgap: 20,
bodyTgap: 10,
bodyBgap: 10
bodyBgap: 10,
},
render: function () {
@ -33,20 +33,20 @@ BI.Drawer = BI.inherit(BI.Widget, {
type: "bi.absolute",
items: [{
el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, {
extraCls: "bi-font-bold"
extraCls: "bi-font-bold",
}) : {
type: "bi.label",
cls: "bi-font-bold",
height: o.headerHeight,
text: o.header,
title: o.header,
textAlign: "left"
textAlign: "left",
},
left: 20,
top: 0,
right: 0,
bottom: 0
}]
bottom: 0,
}],
}, {
el: o.closable ? {
type: "bi.icon_button",
@ -54,15 +54,15 @@ BI.Drawer = BI.inherit(BI.Widget, {
height: o.headerHeight,
handler: function () {
self.close();
}
},
} : {
type: "bi.layout"
type: "bi.layout",
},
width: 56
width: 56,
}],
height: o.headerHeight
height: o.headerHeight,
},
height: o.headerHeight
height: o.headerHeight,
}, {
el: {
type: "bi.vertical",
@ -72,17 +72,17 @@ BI.Drawer = BI.inherit(BI.Widget, {
self.body = this;
},
items: [{
el: o.body
}]
el: o.body,
}],
},
hgap: o.bodyHgap,
tgap: o.bodyTgap,
bgap: o.bodyBgap
bgap: o.bodyBgap,
}];
return BI.extend({
type: "bi.vtape",
items: items
items: items,
}, this._getSuitableSize());
},
@ -103,12 +103,12 @@ BI.Drawer = BI.inherit(BI.Widget, {
}
if (o.placement === "top" || o.placement === "bottom") {
return {
height: o.height || size
height: o.height || size,
};
}
if (o.placement === "left" || o.placement === "right") {
return {
width: o.width || size
width: o.width || size,
};
}
},
@ -120,30 +120,32 @@ BI.Drawer = BI.inherit(BI.Widget, {
self.element.css({
top: 0,
left: "100%",
bottom: 0
bottom: 0,
});
break;
case "left":
self.element.css({
top: 0,
right: "100%",
bottom: 0
bottom: 0,
});
break;
case "top":
self.element.css({
left: 0,
right: 0,
bottom: "100%"
bottom: "100%",
});
break;
case "bottom":
self.element.css({
left: 0,
right: 0,
top: "100%"
top: "100%",
});
break;
default:
break;
}
},
@ -154,24 +156,26 @@ BI.Drawer = BI.inherit(BI.Widget, {
switch (o.placement) {
case "right":
self.element.css({
transform: "translateX(-" + size.width + "px)"
left: "calc(100% - " + size.width + "px)",
});
break;
case "left":
self.element.css({
transform: "translateX(" + size.width + "px)"
right: "calc(100% - " + size.width + "px)",
});
break;
case "top":
self.element.css({
transform: "translateY(" + size.height + "px)"
bottom: "calc(100% - " + size.height + "px)",
});
break;
case "bottom":
self.element.css({
transform: "translateY(-" + size.height + "px)"
top: "calc(100% - " + size.height + "px)",
});
break;
default:
break;
}
callback && callback();
});
@ -182,17 +186,27 @@ BI.Drawer = BI.inherit(BI.Widget, {
requestAnimationFrame(function () {
switch (o.placement) {
case "right":
self.element.css({
left: "100%",
});
break;
case "left":
self.element.css({
transform: "translateX(0px)"
right: "100%",
});
break;
case "top":
self.element.css({
bottom: "100%",
});
break;
case "bottom":
self.element.css({
transform: "translateY(0px)"
top: "100%",
});
break;
default:
break;
}
setTimeout(callback, 300);
});
@ -213,11 +227,11 @@ BI.Drawer = BI.inherit(BI.Widget, {
},
setZindex: function (zindex) {
this.element.css({"z-index": zindex});
this.element.css({ "z-index": zindex });
},
destroyed: function () {
}
},
});
BI.shortcut("bi.drawer", BI.Drawer);

80
src/base/layer/layer.popover.js

@ -8,9 +8,9 @@ BI.Popover = BI.inherit(BI.Widget, {
SIZE: {
SMALL: "small",
NORMAL: "normal",
BIG: "big"
BIG: "big",
},
MAX_HEIGHT: 600
MAX_HEIGHT: 600,
},
props: function () {
@ -18,7 +18,7 @@ BI.Popover = BI.inherit(BI.Widget, {
baseCls: "bi-popover bi-card bi-border-radius",
size: "normal", // small, normal, big
logic: {
dynamic: false
dynamic: false,
},
header: null,
headerHeight: 40,
@ -27,7 +27,7 @@ BI.Popover = BI.inherit(BI.Widget, {
footerHeight: 44,
closable: true, // BI-40839 是否显示右上角的关闭按钮
bodyHgap: BI.SIZE_CONSANTS.H_GAP_SIZE,
bodyTgap: BI.SIZE_CONSANTS.V_GAP_SIZE
bodyTgap: BI.SIZE_CONSANTS.V_GAP_SIZE,
};
},
@ -45,11 +45,11 @@ BI.Popover = BI.inherit(BI.Widget, {
self.startY += deltaY;
self.element.css({
left: BI.clamp(self.startX, 0, W - self.element.width()) + "px",
top: BI.clamp(self.startY, 0, H - self.element.height()) + "px"
top: BI.clamp(self.startY, 0, H - self.element.height()) + "px",
});
// BI-12134 没有什么特别好的方法
BI.Resizers._resize({
target: self.element[0]
target: self.element[0],
});
}, function () {
self.tracker.releaseMouseMoves();
@ -66,21 +66,21 @@ BI.Popover = BI.inherit(BI.Widget, {
},
items: [{
el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, {
extraCls: "bi-font-bold"
extraCls: "bi-font-bold",
}) : {
type: "bi.label",
cls: "bi-font-bold",
height: o.headerHeight,
text: o.header,
title: o.header,
textAlign: "left"
textAlign: "left",
},
top: 0,
bottom: 0,
left: BI.SIZE_CONSANTS.H_GAP_SIZE,
right: o.closable ? 0 : BI.SIZE_CONSANTS.H_GAP_SIZE
}]
}
right: o.closable ? 0 : BI.SIZE_CONSANTS.H_GAP_SIZE,
}],
},
}, o.closable ? {
el: {
type: "bi.icon_button",
@ -88,13 +88,13 @@ BI.Popover = BI.inherit(BI.Widget, {
height: o.headerHeight,
handler: function () {
self.close();
}
},
},
width: 56
width: 56,
} : null],
height: o.headerHeight
height: o.headerHeight,
},
height: o.headerHeight
height: o.headerHeight,
}, o.logic.dynamic ? {
el: {
type: "bi.vertical",
@ -105,14 +105,14 @@ BI.Popover = BI.inherit(BI.Widget, {
},
css: {
"max-height": this._getSuitableBodyHeight(c.MAX_HEIGHT - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap),
"min-height": this._getSuitableBodyHeight(size.height - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap)
"min-height": this._getSuitableBodyHeight(size.height - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap),
},
items: [{
el: o.body
el: o.body,
}],
hgap: o.bodyHgap,
tgap: o.bodyTgap
}
tgap: o.bodyTgap,
},
} : {
el: {
type: "bi.absolute",
@ -121,9 +121,9 @@ BI.Popover = BI.inherit(BI.Widget, {
left: o.bodyHgap,
top: o.bodyTgap,
right: o.bodyHgap,
bottom: 0
}]
}
bottom: 0,
}],
},
}];
if (o.footer) {
items.push({
@ -134,41 +134,39 @@ BI.Popover = BI.inherit(BI.Widget, {
left: BI.SIZE_CONSANTS.H_GAP_SIZE,
top: 0,
right: BI.SIZE_CONSANTS.H_GAP_SIZE,
bottom: 0
bottom: 0,
}],
height: o.footerHeight
height: o.footerHeight,
},
height: o.footerHeight
height: o.footerHeight,
});
}
return BI.extend({
items: items,
width: this._getSuitableWidth(size.width)
width: this._getSuitableWidth(size.width),
}, o.logic.dynamic ? {
type: "bi.vertical",
scrolly: false
scrolly: false,
} : {
type: "bi.vtape",
height: this._getSuitableHeight(size.height)
height: this._getSuitableHeight(size.height),
});
},
// mounted之后绑定事件
mounted: function () {
var self = this;
var o = this.options;
this.dragger.element.mousedown(function (e) {
var pos = self.element.offset();
self.startX = pos.left;
self.startY = pos.top;
self.startX = self.element[0].offsetLeft;
self.startY = self.element[0].offsetTop;
self.tracker.captureMouseMoves(e);
});
},
_getSuitableBodyHeight: function (height) {
var o = this.options;
var c = this._constant;
return BI.clamp(height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap);
},
@ -205,7 +203,7 @@ BI.Popover = BI.inherit(BI.Widget, {
return {
width: o.width || size.width,
height: o.height || size.height,
type: size.type || "default"
type: size.type || "default",
};
},
@ -224,11 +222,11 @@ BI.Popover = BI.inherit(BI.Widget, {
},
setZindex: function (zindex) {
this.element.css({"z-index": zindex});
this.element.css({ "z-index": zindex });
},
destroyed: function () {
}
},
});
BI.shortcut("bi.popover", BI.Popover);
@ -236,7 +234,7 @@ BI.shortcut("bi.popover", BI.Popover);
BI.BarPopover = BI.inherit(BI.Popover, {
_defaultConfig: function () {
return BI.extend(BI.BarPopover.superclass._defaultConfig.apply(this, arguments), {
btns: [BI.i18nText("BI-Basic_OK"), BI.i18nText("BI-Basic_Cancel")]
btns: [BI.i18nText("BI-Basic_OK"), BI.i18nText("BI-Basic_Cancel")],
});
},
@ -254,7 +252,7 @@ BI.BarPopover = BI.inherit(BI.Popover, {
handler: function (v) {
self.fireEvent(BI.Popover.EVENT_CANCEL, v);
self.close(v);
}
},
}, {
type: "bi.button",
text: this.options.btns[0],
@ -263,10 +261,10 @@ BI.BarPopover = BI.inherit(BI.Popover, {
handler: function (v) {
self.fireEvent(BI.Popover.EVENT_CONFIRM, v);
self.close(v);
}
}]
},
}],
});
}
},
});
BI.shortcut("bi.bar_popover", BI.BarPopover);

100
src/base/layer/layer.popup.js

@ -5,7 +5,7 @@
*/
BI.PopupView = BI.inherit(BI.Widget, {
_const: {
TRIANGLE_LENGTH: 12
TRIANGLE_LENGTH: 12,
},
_defaultConfig: function (props) {
return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
@ -29,7 +29,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
stopEvent: false, // 是否停止mousedown、mouseup事件
stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡
logic: {
dynamic: true
dynamic: true,
},
tool: false, // 自定义工具栏
@ -42,30 +42,32 @@ BI.PopupView = BI.inherit(BI.Widget, {
chooseType: 0,
behaviors: {},
layouts: [{
type: "bi.vertical"
}]
}
type: "bi.vertical",
}],
},
});
},
render: function () {
var self = this, o = this.options;
var fn = function (e) {
function fn (e) {
e.stopPropagation();
}, stop = function (e) {
}
function stop (e) {
e.stopEvent();
return false;
};
}
this.element.css({
"z-index": BI.zIndex_popup,
"min-width": BI.isNumeric(o.minWidth) ? (o.minWidth / BI.pixRatio + BI.pixUnit) : o.minWidth,
"max-width": BI.isNumeric(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth
}).bind({click: fn});
"max-width": BI.isNumeric(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth,
}).bind({ click: fn });
this.element.bind("mousewheel", fn);
o.stopPropagation && this.element.bind({mousedown: fn, mouseup: fn, mouseover: fn});
o.stopEvent && this.element.bind({mousedown: stop, mouseup: stop, mouseover: stop});
o.stopPropagation && this.element.bind({ mousedown: fn, mouseup: fn, mouseover: fn });
o.stopEvent && this.element.bind({ mousedown: stop, mouseup: stop, mouseover: stop });
this.tool = this._createTool();
this.tab = this._createTab();
this.view = this._createView();
@ -79,7 +81,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
});
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
scrolly: false,
lgap: o.lgap,
@ -89,11 +91,11 @@ BI.PopupView = BI.inherit(BI.Widget, {
vgap: o.vgap,
hgap: o.hgap,
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, BI.extend({
cls: "list-view-outer bi-card list-view-shadow" + (o.primary ? " bi-primary" : "")
cls: "list-view-outer bi-card list-view-shadow" + (o.primary ? " bi-primary" : ""),
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tool, this.tab, this.view, this.toolbar)
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tool, this.tab, this.view, this.toolbar),
})))
)
),
}))));
if (o.showArrow) {
this.arrow = BI.createWidget({
@ -101,19 +103,19 @@ BI.PopupView = BI.inherit(BI.Widget, {
cls: "bi-bubble-arrow",
items: [{
type: "bi.layout",
cls: "bubble-arrow"
}]
cls: "bubble-arrow",
}],
});
this.arrowWrapper = BI.createWidget({
type: "bi.absolute",
cls: "bi-bubble-arrow-wrapper",
items: [{
el: this.arrow,
}]
}],
});
// 因为三角符号的原因位置变大了,需要占位
this.placeholder = BI.createWidget({
type: "bi.layout"
type: "bi.layout",
});
BI.createWidget({
type: "bi.absolute",
@ -123,22 +125,23 @@ BI.PopupView = BI.inherit(BI.Widget, {
left: 0,
top: 0,
}, {
el: this.placeholder
}]
el: this.placeholder,
}],
});
}
},
_createView: function () {
var o = this.options;
this.button_group = BI.createWidget(o.el, {type: "bi.button_group", value: o.value});
this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value });
this.button_group.element.css({
"min-height": BI.isNumeric(o.minHeight) ? (o.minHeight / BI.pixRatio + BI.pixUnit) : o.minHeight,
"padding-top": o.innerVgap / BI.pixRatio + BI.pixUnit,
"padding-bottom": o.innerVgap / BI.pixRatio + BI.pixUnit,
"padding-left": o.innerHgap / BI.pixRatio + BI.pixUnit,
"padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit
"padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit,
});
return this.button_group;
},
@ -147,6 +150,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
if (false === o.tool) {
return;
}
return BI.createWidget(o.tool);
},
@ -155,12 +159,13 @@ BI.PopupView = BI.inherit(BI.Widget, {
if (o.tabs.length === 0) {
return;
}
return BI.createWidget({
type: "bi.center",
cls: "list-view-tab",
height: 25,
items: o.tabs,
value: o.value
value: o.value,
});
},
@ -177,8 +182,8 @@ BI.PopupView = BI.inherit(BI.Widget, {
items: BI.createItems(o.buttons, {
once: false,
shadow: true,
isShadowShowingOnSelected: true
})
isShadowShowingOnSelected: true,
}),
});
},
@ -212,7 +217,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
direction = "bottom";
style = {
// 5表示留出一定的空间
left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft)
left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
};
wrapperStyle = {
top: o.tgap + o.vgap,
@ -225,13 +230,13 @@ BI.PopupView = BI.inherit(BI.Widget, {
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: ""
bottom: "",
};
break;
case "bottom,left":
direction = "bottom";
style = {
right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight)
right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight),
};
wrapperStyle = {
top: o.bgap + o.vgap,
@ -244,14 +249,14 @@ BI.PopupView = BI.inherit(BI.Widget, {
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: ""
bottom: "",
};
break;
case "top":
case "top,right":
direction = "top";
style = {
left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft)
left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
};
wrapperStyle = {
bottom: o.bgap + o.vgap,
@ -270,7 +275,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
case "top,left":
direction = "top";
style = {
right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight)
right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight),
};
wrapperStyle = {
bottom: o.bgap + o.vgap,
@ -290,7 +295,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
case "left,bottom":
direction = "left";
style = {
top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop)
top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
};
wrapperStyle = {
right: o.rgap + o.hgap,
@ -303,13 +308,13 @@ BI.PopupView = BI.inherit(BI.Widget, {
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: ""
left: "",
};
break;
case "left,top":
direction = "left";
style = {
bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom)
bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom),
};
wrapperStyle = {
right: o.rgap + o.hgap,
@ -322,14 +327,14 @@ BI.PopupView = BI.inherit(BI.Widget, {
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: ""
left: "",
};
break;
case "right":
case "right,bottom":
direction = "right";
style = {
top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop)
top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
};
wrapperStyle = {
left: o.lgap + o.hgap,
@ -342,13 +347,13 @@ BI.PopupView = BI.inherit(BI.Widget, {
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: ""
right: "",
};
break;
case "right,top":
direction = "right";
style = {
bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom)
bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom),
};
wrapperStyle = {
left: o.lgap + o.hgap,
@ -361,7 +366,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: ""
right: "",
};
break;
case "right,innerRight":
@ -372,8 +377,15 @@ BI.PopupView = BI.inherit(BI.Widget, {
break;
case "innerLeft":
break;
default:
break;
}
this.element.removeClass("left").removeClass("right").removeClass("top").removeClass("bottom").addClass(direction);
this.element
.removeClass("left")
.removeClass("right")
.removeClass("top")
.removeClass("bottom")
.addClass(direction);
this.arrow.element.css(style);
this.arrowWrapper.element.css(wrapperStyle);
this.placeholder.element.css(placeholderStyle);
@ -399,7 +411,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0);
var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap;
this.view.resetHeight ? this.view.resetHeight(resetHeight) :
this.view.element.css({"max-height": resetHeight / BI.pixRatio + BI.pixUnit});
this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit });
},
setValue: function (selectedValues) {
@ -409,7 +421,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
getValue: function () {
return this.view.getValue();
}
},
});
BI.PopupView.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.popup_view", BI.PopupView);

37
src/base/layer/layer.searcher.js

@ -9,35 +9,36 @@
BI.SearcherView = BI.inherit(BI.Pane, {
_defaultConfig: function () {
var conf = BI.SearcherView.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-searcher-view bi-card",
tipText: BI.i18nText("BI-No_Select"),
chooseType: BI.Selection.Single,
matcher: {// 完全匹配的构造器
matcher: { // 完全匹配的构造器
type: "bi.button_group",
behaviors: {
redmark: function () {
return true;
}
},
},
items: [],
layouts: [{
type: "bi.vertical"
}]
type: "bi.vertical",
}],
},
searcher: {
type: "bi.button_group",
behaviors: {
redmark: function () {
return true;
}
},
},
items: [],
layouts: [{
type: "bi.vertical"
}]
}
type: "bi.vertical",
}],
},
});
},
@ -50,12 +51,12 @@ BI.SearcherView = BI.inherit(BI.Pane, {
behaviors: {
redmark: function () {
return true;
}
},
},
layouts: [{
type: "bi.vertical"
type: "bi.vertical",
}],
value: o.value
value: o.value,
});
this.matcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -70,8 +71,8 @@ BI.SearcherView = BI.inherit(BI.Pane, {
items: [{
type: "bi.layout",
height: 1,
cls: "searcher-view-spliter bi-background"
}]
cls: "searcher-view-spliter bi-background",
}],
});
this.searcher = BI.createWidget(o.searcher, {
type: "bi.button_group",
@ -79,12 +80,12 @@ BI.SearcherView = BI.inherit(BI.Pane, {
behaviors: {
redmark: function () {
return true;
}
},
},
layouts: [{
type: "bi.vertical"
type: "bi.vertical",
}],
value: o.value
value: o.value,
});
this.searcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -96,7 +97,7 @@ BI.SearcherView = BI.inherit(BI.Pane, {
BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.matcher, this.spliter, this.searcher]
items: [this.matcher, this.spliter, this.searcher],
});
},
@ -133,7 +134,7 @@ BI.SearcherView = BI.inherit(BI.Pane, {
hasMatched: function () {
return this.matcher.getAllButtons().length > 0;
}
},
});
BI.SearcherView.EVENT_CHANGE = "EVENT_CHANGE";

13
src/base/list/__test__/listview.test.js

@ -6,7 +6,6 @@
// TODO 展示类控件测什么没想好标记一下
describe("ListView && VirtualList", function () {
/**
* test_author_windy
*/
@ -14,16 +13,16 @@ describe("ListView && VirtualList", function () {
var a = BI.Test.createWidget({
type: "bi.list_view",
el: {
type: "bi.left"
type: "bi.left",
},
items: BI.map(BI.range(0, 100), function (i, item) {
return BI.extend({}, item, {
type: "bi.label",
width: 200,
height: 200,
text: (i + 1)
text: (i + 1),
});
})
}),
});
a.destroy();
});
@ -39,10 +38,10 @@ describe("ListView && VirtualList", function () {
return BI.extend({}, item, {
type: "bi.label",
height: 30,
text: (i + 1) + "." + item.text
text: (i + 1) + "." + item.text,
});
})
}),
});
a.destroy();
});
});
});

23
src/base/list/listview.js

@ -16,18 +16,18 @@ BI.ListView = BI.inherit(BI.Widget, {
items: [],
itemFormatter: function (item, index) {
return item;
}
},
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [BI.extend({
@ -35,9 +35,9 @@ BI.ListView = BI.inherit(BI.Widget, {
scrolly: false,
ref: function (_ref) {
self.container = _ref;
}
},
}, o.el)],
element: this
element: this,
};
},
@ -72,10 +72,13 @@ BI.ListView = BI.inherit(BI.Widget, {
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0;
var cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
function getElementHeight() {
return self.container.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
}
lastHeight = getElementHeight();
while ((lastHeight) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items.map(function (item, i) {
return o.itemFormatter(item, index + i);
@ -84,16 +87,16 @@ BI.ListView = BI.inherit(BI.Widget, {
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
height: addedHeight,
};
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
lastHeight = getElementHeight();
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
},
@ -127,7 +130,7 @@ BI.ListView = BI.inherit(BI.Widget, {
destroyed: function () {
this.restore();
}
},
});
BI.shortcut("bi.list_view", BI.ListView);

23
src/base/list/virtualgrouplist.js

@ -17,7 +17,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
el: {},
itemFormatter: function (item, index) {
return item;
}
},
};
},
@ -27,13 +27,14 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
},
}, {
type: "bi.virtual_group",
height: o.rowHeight * o.items.length,
@ -42,15 +43,15 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
},
layouts: [BI.extend({
type: "bi.vertical",
scrolly: false
}, o.el)]
scrolly: false,
}, o.el)],
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
},
}],
element: this
element: this,
};
},
@ -87,10 +88,11 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.renderedIndex + 1) * o.blockSize, cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
function getElementHeight () {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
};
while ((lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight()) < minContentHeight && index < o.items.length) {
}
lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight();
while (lastHeight < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container[self.renderedIndex === -1 ? "populate" : "addItems"](items.map(function (item, i) {
return o.itemFormatter(item, index + i);
@ -100,6 +102,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight();
}
},
@ -176,7 +179,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
populate: function (items) {
this._populate(items);
}
},
});
BI.shortcut("bi.virtual_group_list", BI.VirtualGroupList);

22
src/base/list/virtuallist.js

@ -15,36 +15,36 @@ BI.VirtualList = BI.inherit(BI.Widget, {
items: [],
itemFormatter: function (item, index) {
return item;
}
},
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
var self = this;
return {
type: "bi.vertical",
items: [{
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
},
}, {
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
},
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
},
}],
};
},
@ -71,10 +71,11 @@ BI.VirtualList = BI.inherit(BI.Widget, {
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.renderedIndex + 1) * o.blockSize, cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
function getElementHeight() {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
}
lastHeight = getElementHeight();
while (lastHeight < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items.map(function (item, i) {
return o.itemFormatter(item, index + i);
@ -84,6 +85,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
lastHeight = getElementHeight();
}
},
@ -202,7 +204,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
destroyed: function () {
this.cache = {};
this.renderedIndex = -1;
}
},
});
BI.shortcut("bi.virtual_list", BI.VirtualList);

35
src/base/pager/pager.js

@ -13,7 +13,7 @@ BI.Pager = BI.inherit(BI.Widget, {
layouts: [{
type: "bi.horizontal",
hgap: 10,
vgap: 0
vgap: 0,
}],
dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态
@ -36,12 +36,11 @@ BI.Pager = BI.inherit(BI.Widget, {
return 1;
},
hasPrev: BI.emptyFn, // pages不可用时有效
hasNext: BI.emptyFn // pages不可用时有效
hasNext: BI.emptyFn, // pages不可用时有效
});
},
render: function () {
var self = this;
this.currPage = BI.result(this.options, "curr");
// 翻页太灵敏
// this._lock = false;
@ -79,13 +78,13 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({
text: prev,
value: "prev",
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false)
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false),
});
} else {
view.push({
el: BI.extend({
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false)
}, prev)
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false),
}, prev),
});
}
}
@ -95,13 +94,13 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({
text: first,
value: "first",
disabled: !(dict.index > 1 && groups !== 0)
disabled: !(dict.index > 1 && groups !== 0),
});
if (dict.index > 1 && groups !== 0 && groups !== pages - 1) {
view.push({
type: "bi.label",
cls: "page-ellipsis",
text: "\u2026"
text: "\u2026",
});
}
}
@ -127,12 +126,12 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({
text: s,
value: s,
selected: true
selected: true,
});
} else {
view.push({
text: s,
value: s
value: s,
});
}
}
@ -143,13 +142,13 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({
type: "bi.label",
cls: "page-ellipsis",
text: "\u2026"
text: "\u2026",
});
}
view.push({
text: last,
value: "last",
disabled: !(pages > groups && dict.end < pages && groups !== 0)
disabled: !(pages > groups && dict.end < pages && groups !== 0),
});
}
@ -171,8 +170,8 @@ BI.Pager = BI.inherit(BI.Widget, {
return {
el: BI.extend({
disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow)
}, next)
disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow),
}, next),
};
}()));
}
@ -185,13 +184,13 @@ BI.Pager = BI.inherit(BI.Widget, {
cls: "bi-list-item-select bi-border-radius",
height: 23,
hgap: v.el ? 0 : 10,
stopPropagation: true
stopPropagation: true,
}, BI.stripEL(v));
return BI.formatEL(v);
}),
behaviors: o.behaviors,
layouts: o.layouts
layouts: o.layouts,
});
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
// if (self._lock === true) {
@ -220,7 +219,7 @@ BI.Pager = BI.inherit(BI.Widget, {
}
o.jump.apply(self, [{
pages: pages,
curr: self.currPage
curr: self.currPage,
}]);
self._populate();
self.fireEvent(BI.Pager.EVENT_CHANGE, obj);
@ -293,7 +292,7 @@ BI.Pager = BI.inherit(BI.Widget, {
populate: function () {
this._populate();
}
},
});
BI.Pager.EVENT_CHANGE = "EVENT_CHANGE";
BI.Pager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE";

12
src/base/single/0.single.js

@ -15,13 +15,14 @@ var delayingTooltips;
BI.Single = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.Single.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
readonly: false,
title: null,
warningTitle: null,
tipType: null, // success或warning
belowMouse: false, // title是否跟随鼠标
enableHover: false
belowMouse: false, // title是否跟随鼠标
enableHover: false,
});
},
@ -70,7 +71,7 @@ BI.Single = BI.inherit(BI.Widget, {
|| BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) {
this.enableHover({
belowMouse: o.belowMouse,
container: o.container
container: o.container,
});
}
},
@ -136,7 +137,6 @@ BI.Single = BI.inherit(BI.Widget, {
}
}
}, 500);
});
this.element.on("mouseleave.title" + this.getName(), function (e) {
self._e = null;
@ -193,6 +193,7 @@ BI.Single = BI.inherit(BI.Widget, {
if (BI.isFunction(title)) {
return title();
}
return title;
},
@ -201,6 +202,7 @@ BI.Single = BI.inherit(BI.Widget, {
if (BI.isFunction(title)) {
return title();
}
return title;
},
@ -222,6 +224,6 @@ BI.Single = BI.inherit(BI.Widget, {
this.showTimeout = null;
}
BI.Tooltips.remove(this.getName());
}
},
});
BI.shortcut("bi.single", BI.Single);

28
src/base/single/1.text.js

@ -19,58 +19,58 @@
tgap: 0,
bgap: 0,
py: "",
highLight: false
highLight: false,
},
render: function () {
var self = this, o = this.options;
if (o.hgap + o.lgap > 0) {
this.element.css({
"padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit
"padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit,
});
}
if (o.hgap + o.rgap > 0) {
this.element.css({
"padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit
"padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit,
});
}
if (o.vgap + o.tgap > 0) {
this.element.css({
"padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit
"padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit,
});
}
if (o.vgap + o.bgap > 0) {
this.element.css({
"padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit
"padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit,
});
}
if (BI.isWidthOrHeight(o.height)) {
this.element.css({lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height});
this.element.css({ lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height });
}
if (BI.isWidthOrHeight(o.lineHeight)) {
this.element.css({lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight});
this.element.css({ lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight });
}
if (BI.isWidthOrHeight(o.maxWidth)) {
this.element.css({maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth});
this.element.css({ maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth });
}
this.element.css({
textAlign: o.textAlign,
whiteSpace: this._getTextWrap(),
textOverflow: o.whiteSpace === "nowrap" ? "ellipsis" : "",
overflow: o.whiteSpace === "nowrap" ? "" : (BI.isWidthOrHeight(o.height) ? "auto" : "")
overflow: o.whiteSpace === "nowrap" ? "" : (BI.isWidthOrHeight(o.height) ? "auto" : ""),
});
if (o.handler && o.handler !== BI.emptyFn) {
this.text = BI.createWidget({
type: "bi.layout",
tagName: "span"
tagName: "span",
});
this.text.element.click(function (e) {
o.handler.call(self, self.getValue(), self, e);
!o.disabled && o.invalid && o.handler.call(self, self.getValue(), self, e);
});
BI.createWidget({
type: "bi.default",
element: this,
items: [this.text]
items: [this.text],
});
} else {
this.text = this;
@ -108,6 +108,7 @@
_getShowText: function () {
var o = this.options;
var text = BI.isFunction(o.text) ? o.text() : o.text;
return BI.isKey(text) ? BI.Text.formatText(text + "") : text;
},
@ -153,7 +154,7 @@
BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text;
this._doRedMark(this.options.keyword);
}
},
});
var formatters = [];
BI.Text.addTextFormatter = function (formatter) {
@ -165,6 +166,7 @@
text = formatters[i](text);
}
}
return text;
};
BI.shortcut("bi.text", BI.Text);

27
src/base/single/__test__/text.test.js

@ -2,13 +2,12 @@
* Created by windy on 2018/01/23.
*/
describe("TextTest", function () {
/**
* test_author_windy
*/
it("setText", function () {
var text = BI.Test.createWidget({
type: "bi.text"
type: "bi.text",
});
text.setText("AAA");
expect(text.element.text()).to.equal("AAA");
@ -20,9 +19,9 @@ describe("TextTest", function () {
*/
it("setStyle", function () {
var text = BI.Test.createWidget({
type: "bi.text"
type: "bi.text",
});
text.setStyle({"color": "red"});
text.setStyle({ "color": "red" });
expect(text.element.getStyle("color")).to.equal("rgb(255, 0, 0)");
text.destroy();
});
@ -34,7 +33,7 @@ describe("TextTest", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "AAA",
highLight: true
highLight: true,
});
expect(text.element.getStyle("color")).to.equal("rgb(54, 133, 242)");
text.destroy();
@ -47,7 +46,7 @@ describe("TextTest", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "我是要标红的A",
keyword: "A"
keyword: "A",
});
expect(text.element.children(".bi-keyword-red-mark").length).to.not.equal(0);
text.destroy();
@ -61,7 +60,7 @@ describe("TextTest", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "AAA",
highLight: true
highLight: true,
});
text.unHighLight();
expect(text.element.getStyle("color")).to.not.equal("rgb(54, 133, 242)");
@ -75,7 +74,7 @@ describe("TextTest", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "我是要标红的A",
keyword: "A"
keyword: "A",
});
text.unRedMark();
expect(text.element.children(".bi-keyword-red-mark").length).to.equal(0);
@ -103,7 +102,7 @@ describe("TextTest", function () {
type: "bi.text",
text: "我是要标红的A",
vgap: 10,
hgap: 10
hgap: 10,
});
expect(text.element.css("padding")).to.equal("10px");
text.destroy();
@ -129,7 +128,7 @@ describe("TextTest", function () {
type: "bi.text",
text: "我是A",
lineHeight: 12,
height: 24
height: 24,
});
expect(text.element.css("height")).to.equal("24px");
expect(text.element.css("line-height")).to.equal("12px");
@ -145,7 +144,7 @@ describe("TextTest", function () {
text: "我是A",
handler: function () {
text.setText("handler");
}
},
});
BI.nextTick(function () {
text.text.element.click();
@ -162,7 +161,7 @@ describe("TextTest", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "",
value: "aaaa"
value: "aaaa",
});
expect(text.element.text()).to.equal("");
text.destroy();
@ -174,7 +173,7 @@ describe("TextTest", function () {
it("text的value属性1", function () {
var text = BI.Test.createWidget({
type: "bi.text",
value: "aaaa"
value: "aaaa",
});
expect(text.element.text()).to.equal("aaaa");
text.destroy();
@ -187,7 +186,7 @@ describe("TextTest", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: null,
value: "aaaa"
value: "aaaa",
});
expect(text.element.text()).to.equal("");
text.destroy();

11
src/base/single/a/__test__/a.test.js

@ -2,16 +2,15 @@
* Created by windy on 2018/01/23.
*/
describe("ALinkTest", function () {
/**
* test_author_windy
*/
it("A初始化测试", function () {
var a = BI.Test.createWidget({
type: "bi.a",
text: "CCC"
text: "CCC",
});
expect(a.element.is('a')).to.equal(true);
expect(a.element.is("a")).to.equal(true);
a.destroy();
});
@ -23,10 +22,10 @@ describe("ALinkTest", function () {
type: "bi.a",
text: "DDD",
el: {
type: "bi.label"
}
type: "bi.label",
},
});
expect(a.element.is('a') && a.element.hasClass("bi-label")).to.equal(true);
expect(a.element.is("a") && a.element.hasClass("bi-label")).to.equal(true);
a.destroy();
});
});

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save