Browse Source

Merge pull request #126469 in DEC/fineui from final/11.0 to persist/11.0

* commit 'c9631b84f544883d5aaccfb9321119620f354972': (152 commits)
  BI-110891 fix:同步fineui
  无JIRA任务 同步
  REPORT-76966 fix: 组件是否异步获取数据,和组件是否支持搜索分离开
  REPORT-76747 fix: IE环境下图标显示不正常
  auto upgrade version to 2.0.20220720140353
  auto upgrade version to 2.0.20220720111514
  无JIRA fix: titile问题
  feat: config中传下context
  feat: 准备demo
  auto upgrade version to 2.0.20220719204542
  auto upgrade version to 2.0.20220719203505
  KERNEL-12033 feat:复选列表添加itemFormatter属性,支持自定义节点类型
  auto upgrade version to 2.0.20220719110449
  KERNEL-12033 feat: 复选列表添加itemFormatter属性,支持自定义节点类型
  auto upgrade version to 2.0.20220718192331
  auto upgrade version to 2.0.20220718191454
  BI-109153 feat: tootip做一下兼容
  KERNEL-9708 refactor: 提取到system中实现
  无JRIA fix: bi.list_pane 回调后tiptext处理
  refactor: eslint fix
  ...
research/test
superman 2 years ago
parent
commit
f5042019e7
  1. 8
      .eslintrc
  2. 2
      .npmignore
  3. 44
      bin/cli/cli.js
  4. 62
      bin/cli/worker/cli.worker.js
  5. 0
      bin/cli/worker/template/action_type.ts
  6. 5
      bin/cli/worker/template/main_thread_template.ts
  7. 5
      bin/cli/worker/template/worker_thread_template.ts
  8. 700
      demo/js/base/button/demo.button.js
  9. 20
      demo/js/base/tip/demo.title.js
  10. 115
      demo/js/base/tree/demo.sync_tree.js
  11. 4
      dist/fix/fix.compact.js
  12. 124
      dist/fix/fix.js
  13. 131
      dist/fix/fix.proxy.js
  14. 15
      examples/worker_new.html
  15. 105
      examples/worker_new/index.js
  16. 80
      examples/worker_new/worker.js
  17. 104
      examples/替换loading动画.html
  18. 11
      package.json
  19. 29
      src/base/1.pane.js
  20. 10
      src/base/combination/bubble.js
  21. 11
      src/base/combination/combo.js
  22. 8
      src/base/combination/expander.js
  23. 29
      src/base/combination/group.button.js
  24. 16
      src/base/combination/group.virtual.js
  25. 10
      src/base/combination/switcher.js
  26. 23
      src/base/combination/tab.js
  27. 16
      src/base/list/listview.js
  28. 13
      src/base/list/virtualgrouplist.js
  29. 9
      src/base/list/virtuallist.js
  30. 35
      src/base/single/0.single.js
  31. 12
      src/base/single/button/button.basic.js
  32. 41
      src/base/single/button/buttons/button.js
  33. 4
      src/base/single/editor/editor.multifile.js
  34. 7
      src/base/single/input/file.js
  35. 20
      src/base/single/label/abstract.label.js
  36. 30
      src/base/single/tip/tip.toast.js
  37. 15
      src/base/single/tip/tip.tooltip.js
  38. 1
      src/case/combo/bubblecombo/combo.bubble.js
  39. 5
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  40. 26
      src/case/layer/pane.list.js
  41. 10
      src/case/list/list.select.js
  42. 4
      src/case/ztree/0.treeview.js
  43. 14
      src/case/ztree/1.asynctree.js
  44. 3647
      src/case/ztree/jquery.ztree.core-3.5.js
  45. 23
      src/component/allvaluechooser/abstract.allvaluechooser.js
  46. 7
      src/component/allvaluechooser/pane.allvaluechooser.js
  47. 2
      src/component/form/form.field.js
  48. 4
      src/component/form/form.js
  49. 4
      src/core/1.lodash.js
  50. 76
      src/core/2.base.js
  51. 22
      src/core/3.ob.js
  52. 26
      src/core/4.widget.js
  53. 75
      src/core/5.inject.js
  54. 7
      src/core/conflict.js
  55. 8
      src/core/constant/events.js
  56. 2
      src/core/constant/var.js
  57. 23
      src/core/controller/controller.tooltips.js
  58. 74
      src/core/element/element.js
  59. 31
      src/core/element/index.js
  60. 22
      src/core/element/plugins/attr.js
  61. 23
      src/core/element/plugins/class.js
  62. 22
      src/core/element/plugins/css.js
  63. 12
      src/core/element/plugins/data.js
  64. 9
      src/core/element/plugins/empty.js
  65. 32
      src/core/element/plugins/event.js
  66. 15
      src/core/element/plugins/html.js
  67. 31
      src/core/element/plugins/index.js
  68. 6
      src/core/element/plugins/keywordMark.js
  69. 65
      src/core/element/plugins/renderToHtml.js
  70. 50
      src/core/element/plugins/renderToString.js
  71. 10
      src/core/element/plugins/text.js
  72. 9
      src/core/element/plugins/val.js
  73. 4
      src/core/func/alias.js
  74. 2
      src/core/func/array.js
  75. 2
      src/core/func/date.js
  76. 4
      src/core/func/function.js
  77. 2
      src/core/func/number.js
  78. 4
      src/core/func/string.js
  79. 4
      src/core/platform/web/config.js
  80. 2
      src/core/platform/web/function.js
  81. 4
      src/core/platform/web/jquery/_jquery.js
  82. 2
      src/core/platform/web/load.js
  83. 4
      src/core/plugin.js
  84. 2
      src/core/structure/aes.js
  85. 2
      src/core/structure/base64.js
  86. 51
      src/core/system.js
  87. 2
      src/core/utils/chinesePY.js
  88. 2
      src/core/utils/i18n.js
  89. 6
      src/core/wrapper/layout.js
  90. 3
      src/less/base/single/button/button.less
  91. 33
      src/less/base/tree/ztree.less
  92. 2
      src/less/image.less
  93. 20
      src/less/resource/app.less
  94. 36
      src/less/typographic.less
  95. 32
      src/router/0.router.js
  96. 2
      src/widget/downlist/item.downlistgroup.js
  97. 12
      src/widget/editor/editor.text.js
  98. 6
      src/widget/multilayerselecttree/multilayerselecttree.combo.js
  99. 33
      src/widget/multilayersingletree/multilayersingletree.combo.js
  100. 259
      src/widget/multiselect/loader.js
  101. Some files were not shown because too many files have changed in this diff Show More

8
.eslintrc

@ -17,7 +17,6 @@
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
@ -26,7 +25,7 @@
},
"plugins": ["@typescript-eslint/eslint-plugin"],
"overrides": [{
"files": ["src/*.js","src/**/*.js", "demo/*.js", "demo/**/*.js", "i18n/**/*.js", "i18n/*.js", "test/**/*.js", "test/*.js"],
"files": ["src/*.js","src/**/*.js", "demo/*.js", "demo/**/*.js", "i18n/**/*.js", "i18n/*.js", "test/**/*.js", "test/*.js", "examples/*.js", "examples/**/*.js"],
"extends": "plugin:@fui/es5",
"rules": {
"no-param-reassign": "off",
@ -34,7 +33,10 @@
"comma-dangle": ["error", "never"] // 多行对象字面量中要求拖尾逗号
}
}, {
"files": ["webpack/*.js", "types/*.ts", "typescript/*.ts","typescript/**/*.ts", "./*.js", "lib/**/*.js", "lib/*.js"],
"files": ["webpack/*.js", "./*.js", "lib/**/*.js", "lib/*.js", "./bin/*.js", "./bin/**/*.js"],
"extends": "plugin:@fui/esnext"
}, {
"files": ["types/*.ts", "typescript/*.ts","typescript/**/*.ts"],
"extends": "plugin:@fui/typescript"
}]
}

2
.npmignore

@ -38,3 +38,5 @@
!.eslintrc
!dist/2.0/jsy.min.css
!dist/2.0/bi.min.css
!bin/*
!bin/**/*

44
bin/cli/cli.js

@ -0,0 +1,44 @@
#!/usr/bin/env node
const workerCmd = require('./worker/cli.worker');
function getArgs (startIndex = 1) {
const args = {};
process.argv
.slice(startIndex, process.argv.length)
.forEach(arg => {
// long arg
if (arg.slice(0, 2) === '--') {
const longArg = arg.split('=');
const longArgFlag = longArg[0].slice(2, longArg[0].length);
const longArgValue = longArg.length > 1 ? longArg[1] : true;
args[longArgFlag] = longArgValue;
// flags
} else if (arg[0] === '-') {
const flags = arg.slice(1, arg.length);
args[flags] = true;
}
});
return args;
}
const cmds = new Map([
['worker', workerCmd],
]);
const baseCmd = 'fui-cli';
const startIndex = process.argv.findIndex(argv => argv.indexOf(baseCmd) !== -1);
if (startIndex === -1) {
throw new Error(`Command ${baseCmd} not found in args`);
}
const cmd = process.argv[startIndex + 1];
if (cmds.has(cmd)) {
cmds.get(cmd)?.exec(getArgs(startIndex + 2));
} else {
throw new Error(`Command ${cmd} not supported`);
}

62
bin/cli/worker/cli.worker.js

@ -0,0 +1,62 @@
const fs = require('fs');
const path = require('path');
function scanAndCreate(structure, root = process.cwd()) {
Object.keys(structure)
.forEach(name => {
if (typeof structure[name] === 'object') {
fs.mkdirSync(path.resolve(root, name));
scanAndCreate(structure[name], 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();
fs.appendFileSync(path.resolve(root, name), content);
}
});
}
module.exports = {
exec: async args => {
if (!args.init) {
throw new Error(`Command init not found in args`);
}
if (!args.name) {
throw new Error('Command --name=... not found in args');
}
const name = args.name;
const structure = {
[`${name}_worker`]: {
'main_thread': {
action: {},
[`${name}_main_thread.ts`]: path.resolve(__dirname, './template/main_thread_template.ts'),
},
utils: {
'action_type.ts': '',
},
'worker_thread': {
action: {},
[`${name}_worker_thread.ts`]: path.resolve(__dirname, './template/worker_thread_template.ts'),
},
},
};
scanAndCreate(structure);
},
};
// 结构
// -xxx_worker
// -|--main_thread
// -|--|--action
// -|--|--xxx_main_thread.ts
// -|--utils
// -|--|--action_type.ts
// -|--worker_thread
// -|--|--action
// -|--|--worker_main_thread.ts

0
bin/cli/worker/template/action_type.ts

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

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

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

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

700
demo/js/base/button/demo.button.js

@ -4,416 +4,310 @@ Demo.Button = BI.inherit(BI.Widget, {
},
render: function () {
var items = [{
el: {
type: "bi.button",
text: "一般按钮",
level: "common",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示成功状态按钮",
level: "success",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示警告状态的按钮",
level: "warning",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示错误状态的按钮",
level: "error",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示忽略状态的按钮",
level: "ignore",
height: 30
}
}, {
el: {
type: "bi.button",
text: "普通灰化按钮",
disabled: true,
level: "success",
height: 30
}
}, {
el: {
type: "bi.button",
text: "忽略状态灰化按钮",
disabled: true,
level: "ignore",
height: 30
}
}, {
el: {
type: "bi.button",
text: "带图标的按钮",
// level: 'ignore',
iconCls: "close-font",
height: 30
}
}, {
el: {
type: "bi.button",
text: "一般按钮",
block: true,
level: "common",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示成功状态按钮",
block: true,
level: "success",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示警告状态的按钮",
block: true,
level: "warning",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示忽略状态的按钮",
block: true,
level: "ignore",
height: 30
}
}, {
el: {
type: "bi.button",
text: "普通灰化按钮",
block: true,
disabled: true,
level: "success",
height: 30
}
}, {
el: {
type: "bi.button",
text: "忽略状态灰化按钮",
block: true,
disabled: true,
level: "ignore",
height: 30
}
}, {
el: {
type: "bi.button",
text: "带图标的按钮",
block: true,
// level: 'ignore',
iconCls: "close-font",
height: 30
}
}, {
el: {
type: "bi.button",
text: "一般按钮",
clear: true,
level: "common",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示成功状态按钮",
clear: true,
level: "success",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示警告状态的按钮",
clear: true,
level: "warning",
height: 30
}
}, {
el: {
type: "bi.button",
text: "表示忽略状态的按钮",
clear: true,
level: "ignore",
height: 30
}
}, {
el: {
type: "bi.button",
text: "普通灰化按钮",
clear: true,
disabled: true,
level: "success",
height: 30
}
}, {
el: {
type: "bi.button",
text: "忽略状态灰化按钮",
clear: true,
disabled: true,
level: "ignore",
height: 30
}
}, {
el: {
type: "bi.button",
text: "带图标的按钮",
clear: true,
// level: 'ignore',
iconCls: "close-font",
height: 30
}
}, {
el: {
type: "bi.text_button",
text: "文字按钮",
height: 30
}
}, {
el: {
type: "bi.button",
text: "幽灵按钮(common)",
ghost: true,
height: 30
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
height: 30
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "warning",
height: 30
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "error",
height: 30
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "success",
height: 30
}
}, {
el: {
type: "bi.button",
text: "幽灵按钮(common)灰化",
disabled: true,
ghost: true,
height: 30
}
}, {
el: {
type: "bi.button",
text: "弹出bubble",
bubble: function () {
return BI.parseInt(Math.random() * 100) % 10 + "提示"
},
handler: function () {
BI.Msg.toast("1111");
},
height: 30
}
}, {
el: {
type: "bi.button",
text: "图标在上面的按钮,而且可以自动撑开高度",
iconCls: "close-font",
iconGap: 24,
iconPosition: "top"
}
type: "bi.button",
text: "一般按钮",
level: "common",
height: 30
}, {
type: "bi.button",
text: "表示成功状态按钮",
level: "success",
height: 30
}, {
type: "bi.button",
text: "表示警告状态的按钮",
level: "warning",
height: 30
}, {
type: "bi.button",
text: "表示错误状态的按钮",
level: "error",
height: 30
}, {
type: "bi.button",
text: "表示忽略状态的按钮",
level: "ignore",
height: 30
}, {
type: "bi.button",
text: "普通灰化按钮",
disabled: true,
level: "success",
height: 30
}, {
type: "bi.button",
text: "忽略状态灰化按钮",
disabled: true,
level: "ignore",
height: 30
}, {
type: "bi.button",
text: "带图标的按钮",
// level: 'ignore',
iconCls: "close-font",
height: 30
}, {
type: "bi.button",
text: "一般按钮",
block: true,
level: "common",
height: 30
}, {
type: "bi.button",
text: "表示成功状态按钮",
block: true,
level: "success",
height: 30
}, {
type: "bi.button",
text: "表示警告状态的按钮",
block: true,
level: "warning",
height: 30
}, {
type: "bi.button",
text: "表示忽略状态的按钮",
block: true,
level: "ignore",
height: 30
}, {
type: "bi.button",
text: "普通灰化按钮",
block: true,
disabled: true,
level: "success",
height: 30
}, {
type: "bi.button",
text: "忽略状态灰化按钮",
block: true,
disabled: true,
level: "ignore",
height: 30
}, {
type: "bi.button",
text: "带图标的按钮",
block: true,
// level: 'ignore',
iconCls: "close-font",
height: 30
}, {
type: "bi.button",
text: "一般按钮",
clear: true,
level: "common",
height: 30
}, {
type: "bi.button",
text: "表示成功状态按钮",
clear: true,
level: "success",
height: 30
}, {
type: "bi.button",
text: "表示警告状态的按钮",
clear: true,
level: "warning",
height: 30
}, {
type: "bi.button",
text: "表示忽略状态的按钮",
clear: true,
level: "ignore",
height: 30
}, {
type: "bi.button",
text: "普通灰化按钮",
clear: true,
disabled: true,
level: "success",
height: 30
}, {
type: "bi.button",
text: "忽略状态灰化按钮",
clear: true,
disabled: true,
level: "ignore",
height: 30
}, {
type: "bi.button",
text: "带图标的按钮",
clear: true,
// level: 'ignore',
iconCls: "close-font",
height: 30
}, {
type: "bi.text_button",
text: "文字按钮",
height: 30
}, {
type: "bi.button",
text: "幽灵按钮(common)",
ghost: true,
height: 30
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
height: 30
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "warning",
height: 30
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "error",
height: 30
}, {
type: "bi.button",
iconCls: "plus-font",
text: "幽灵按钮(common)",
ghost: true,
level: "success",
height: 30
}, {
type: "bi.button",
text: "幽灵按钮(common)灰化",
disabled: true,
ghost: true,
height: 30
}, {
type: "bi.button",
text: "弹出bubble",
bubble: function () {
return BI.parseInt(Math.random() * 100) % 10 + "提示"
},
handler: function () {
BI.Msg.toast("1111");
},
height: 30
}, {
type: "bi.button",
text: "图标在上面的按钮,而且可以自动撑开高度",
iconCls: "close-font",
iconGap: 24,
iconPosition: "top"
},{
el: {
type: "bi.button",
text: "自动撑开高度",
iconCls: "close-font",
textHeight: 32,
iconGap: 24,
vgap: 16,
hgap: 100,
iconPosition: "top"
}
}, {
el: {
type: "bi.button",
text: "图标在下面的按钮",
iconCls: "close-font",
iconPosition: "bottom"
}
}, {
el: {
type: "bi.button",
text: "图标在左边的按钮",
iconCls: "close-font",
iconPosition: "left"
}
}, {
el: {
type: "bi.button",
text: "图标在右边的按钮",
iconCls: "close-font",
iconPosition: "right"
}
}, {
el: {
type: "bi.button",
text: "浅色的一般按钮",
iconCls: "plus-font",
light: true
}
}, {
el: {
type: "bi.button",
text: "浅色的成功按钮",
level: "success",
iconCls: "plus-font",
light: true
}
}, {
el: {
type: "bi.button",
text: "浅色的警告按钮",
level: "warning",
iconCls: "plus-font",
light: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "浅色的失败按钮",
level: "error",
cls: "hover-mask",
light: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "common",
plain: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "success",
plain: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "error",
plain: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "warning",
plain: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "ignore",
plain: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "ignore",
plain: true,
disabled: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "error",
plain: true,
disabled: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "common",
plain: true,
disabled: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "点我,更改图标",
handler() {
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) {
this.i = 0;
}
this.setIcon(arr[this.i]);
},
height: 24
}
type: "bi.button",
text: "自动撑开高度",
iconCls: "close-font",
textHeight: 32,
iconGap: 24,
vgap: 16,
hgap: 100,
iconPosition: "top"
}, {
type: "bi.button",
text: "图标在下面的按钮",
iconCls: "close-font",
iconPosition: "bottom"
}, {
type: "bi.button",
text: "图标在左边的按钮",
iconCls: "close-font",
iconPosition: "left"
}, {
type: "bi.button",
text: "图标在右边的按钮",
iconCls: "close-font",
iconPosition: "right"
}, {
type: "bi.button",
text: "浅色的一般按钮",
iconCls: "plus-font",
light: true
}, {
type: "bi.button",
text: "浅色的成功按钮",
level: "success",
iconCls: "plus-font",
light: true
}, {
type: "bi.button",
text: "浅色的警告按钮",
level: "warning",
iconCls: "plus-font",
light: true
}, {
type: "bi.button",
iconCls: "plus-font",
text: "浅色的失败按钮",
level: "error",
cls: "hover-mask",
light: true
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "common",
plain: true
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "success",
plain: true
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "error",
plain: true
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "warning",
plain: true
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "ignore",
plain: true
}, {
type: "bi.button",
iconCls: "plus-font",
plain: true,
level: "error",
}, {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
plain: true,
disabled: true
}, {
type: "bi.button",
iconCls: "plus-font",
text: "点我,更改图标",
handler() {
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) {
this.i = 0;
}
this.setIcon(arr[this.i]);
},
height: 24
}];
// BI.each(items, function (i, item) {
// item.el.handler = function () {
// BI.Msg.alert("按钮", this.options.text);
// };
// });
return {
type: "bi.left",
scrolly: true,
vgap: 100,
hgap: 20,
items: items
items: BI.map(items, function (index, value) {
return {
el: value
}
})
};
}
});

20
demo/js/base/tip/demo.title.js

@ -30,6 +30,26 @@ Demo.Title = BI.inherit(BI.Widget, {
warningTitle: "自定义title提示效果",
text: "自定义title提示效果",
textAlign: "center"
}, {
type: "bi.label",
cls: "layout-bg3",
height: 50,
title: () => "函数返回值作为title提示",
text: "title提示支持函数",
textAlign: "center"
}, {
type: "bi.label",
cls: "layout-bg4",
height: 50,
title: function () {
return {
level: "success",
text: "自定义title\n提示效果",
textAlign: "center"
};
},
text: "title提示支持对象,作为bi.tooltip的props",
textAlign: "center"
}],
hgap: 300,
vgap: 20

115
demo/js/base/tree/demo.sync_tree.js

@ -4,7 +4,10 @@ Demo.Func = BI.inherit(BI.Widget, {
},
mounted: function () {
this.syncTree.stroke({
this.syncTree1.stroke({
keyword: "1"
});
this.syncTree2.stroke({
keyword: "1"
});
},
@ -13,38 +16,90 @@ Demo.Func = BI.inherit(BI.Widget, {
var self = this;
return {
type: "bi.vtape",
items: [{
type: "bi.label",
height: 50,
text: "可以异步获取数据的树"
}, {
type: "bi.async_tree",
ref: function (_ref) {
self.syncTree = _ref;
},
paras: {
selectedValues: {"1": {}, "2": {"1": {}}}
},
itemsCreator: function (op, callback) {
callback({
items: [{
id: (op.id || "") + "1",
pId: op.id,
text: 1,
isParent: true
rowSize: [0.5, 0.5],
items: [
{
type: "bi.vtape",
items: [
{
type: "bi.label",
height: 50,
text: "可以异步获取数据的树"
}, {
id: (op.id || "") + "2",
pId: op.id,
text: 2
type: "bi.async_tree",
ref: function (_ref) {
self.syncTree1 = _ref;
},
paras: {
selectedValues: { "1": {}, "2": { "1": {} } }
},
itemsCreator: function (op, callback) {
callback({
items: [{
id: (op.id || "") + "1",
pId: op.id,
text: (op.id || "") + "1",
isParent: true,
iconCls: "close-h-font"
}, {
id: (op.id || "") + "2",
pId: op.id,
text: (op.id || "") + "2",
iconCls: "search-font"
}, {
id: (op.id || "") + "3",
pId: op.id,
text: (op.id || "") + "3",
iconCls: "date-font"
}],
hasNext: BI.isNull(op.id)
});
}
},
]
},
{
type: "bi.vtape",
items: [
{
type: "bi.label",
height: 50,
text: "showIcon属性搭配节点iconCls,可以显示图标"
}, {
id: (op.id || "") + "3",
pId: op.id,
text: 3
}],
hasNext: BI.isNull(op.id)
});
type: "bi.async_tree",
ref: function (_ref) {
self.syncTree2 = _ref;
},
paras: {
selectedValues: { "1": {}, "2": { "1": {} } }
},
showIcon: true,
itemsCreator: function (op, callback) {
callback({
items: [{
id: (op.id || "") + "1",
pId: op.id,
text: (op.id || "") + "1",
isParent: true,
iconCls: "close-h-font"
}, {
id: (op.id || "") + "2",
pId: op.id,
text: (op.id || "") + "2",
iconCls: "search-font"
}, {
id: (op.id || "") + "3",
pId: op.id,
text: (op.id || "") + "3",
iconCls: "date-font"
}],
hasNext: BI.isNull(op.id)
});
}
},
]
}
}]
]
};
}

4
dist/fix/fix.compact.js vendored

@ -38,7 +38,7 @@
cb = cb.handler;
}
options = options || {};
return Fix.watch(vm.model, keyOrFn, _.bind(cb, vm), BI.extend(options, {
return Fix.watch(vm.model, keyOrFn, BI._.bind(cb, vm), BI.extend(options, {
store: vm.store
}));
}
@ -177,7 +177,7 @@
delete this.__cacheStore;
};
_.each(["_render", "__afterRender", "_mount", "__afterMount"], function (name) {
BI._.each(["_render", "__afterRender", "_mount", "__afterMount"], function (name) {
var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () {
this.store && pushTarget(this.store);

124
dist/fix/fix.js vendored

@ -96,8 +96,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
setImmediate(nextTickHandler);
};
} else if (typeof MessageChannel !== 'undefined' && (isNative(MessageChannel) ||
// PhantomJS
MessageChannel.toString() === '[object MessageChannelConstructor]')) {
// PhantomJS
MessageChannel.toString() === '[object MessageChannelConstructor]')) {
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = nextTickHandler;
@ -106,18 +106,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
};
} else
/* istanbul ignore next */
if (typeof Promise !== 'undefined' && isNative(Promise)) {
// use microtask in non-DOM environments, e.g. Weex
var p = Promise.resolve();
timerFunc = function timerFunc() {
p.then(nextTickHandler);
};
} else {
// fallback to setTimeout
timerFunc = function timerFunc() {
setTimeout(nextTickHandler, 0);
};
}
if (typeof Promise !== 'undefined' && isNative(Promise)) {
// use microtask in non-DOM environments, e.g. Weex
var p = Promise.resolve();
timerFunc = function timerFunc() {
p.then(nextTickHandler);
};
} else {
// fallback to setTimeout
timerFunc = function timerFunc() {
setTimeout(nextTickHandler, 0);
};
}
return function queueNextTick(cb, ctx) {
var _resolve = void 0;
@ -428,10 +428,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (this.active) {
var value = this.get();
if (value !== this.value ||
// Deep watchers and watchers on Object/Arrays should fire even
// when the value is the same, because the value may
// have mutated.
_.isObject(value) && options && options.refresh || this.deep) {
// Deep watchers and watchers on Object/Arrays should fire even
// when the value is the same, because the value may
// have mutated.
BI._.isObject(value) && options && options.refresh || this.deep) {
// set new value
var oldValue = this.value;
this.value = value;
@ -491,8 +491,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function _traverse(val, seen) {
var i = void 0,
keys = void 0;
var isA = _.isArray(val);
if (!isA && !_.isObject(val)) {
var isA = BI._.isArray(val);
if (!isA && !BI._.isObject(val)) {
return;
}
if (val.__ob__) {
@ -508,7 +508,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
_traverse(val[i], seen);
}
} else {
keys = _.keys(val);
keys = BI._.keys(val);
i = keys.length;
while (i--) {
_traverse(val[keys[i]], seen);
@ -518,7 +518,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var arrayProto = Array.prototype;
var arrayMethods = [];
_.each(['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'], function (method) {
BI._.each(['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'], function (method) {
var original = arrayProto[method];
arrayMethods[method] = function mutator() {
for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) {
@ -554,7 +554,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
};
});
var arrayKeys = _.keys(arrayMethods);
var arrayKeys = BI._.keys(arrayMethods);
var observerState = {
shouldConvert: true
@ -583,7 +583,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
this.value = value;
this.dep = new Dep();
this.vmCount = 0;
if (_.isArray(value)) {
if (BI._.isArray(value)) {
var augment = hasProto ? protoAugment : copyAugment;
augment(value, arrayMethods, arrayKeys);
this.model = this.observeArray(value);
@ -623,13 +623,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}
function observe(value, parentObserver, parentKey) {
if (!_.isObject(value)) {
if (!BI._.isObject(value)) {
return;
}
var ob = void 0;
if (value.__ob__ instanceof Observer) {
ob = value.__ob__;
} else if (observerState.shouldConvert && isExtensible(value) && (_.isArray(value) || isPlainObject(value))) {
} else if (observerState.shouldConvert && isExtensible(value) && (BI._.isArray(value) || isPlainObject(value))) {
ob = new Observer(value);
}
if (ob) {
@ -643,7 +643,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
dep.notify({ observer: observer, key: key, refresh: refresh });
if (observer) {
//触发a.*绑定的依赖
_.each(observer._deps, function (dep) {
BI._.each(observer._deps, function (dep) {
dep.notify({ observer: observer, key: key });
});
//触发a.**绑定的依赖
@ -651,7 +651,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
root = observer,
route = key || "";
while (parent) {
_.each(parent._scopeDeps, function (dep) {
BI._.each(parent._scopeDeps, function (dep) {
dep.notify({ observer: observer, key: key });
});
if (parent.parentKey != null) {
@ -674,7 +674,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function defineReactive(obj, observer, shallow) {
var props = {};
var model = void 0;
_.each(obj, function (val, key) {
BI._.each(obj, function (val, key) {
if (key in $$skipArray) {
return;
}
@ -691,7 +691,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
dep.depend();
if (childOb) {
childOb.dep.depend();
if (_.isArray(value)) {
if (BI._.isArray(value)) {
dependArray(value);
}
}
@ -740,7 +740,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
dep.depend();
if (childOb) {
childOb.dep.depend();
if (_.isArray(value)) {
if (BI._.isArray(value)) {
dependArray(value);
}
}
@ -767,12 +767,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
* already exist.
*/
function set(target, key, val) {
if (_.isArray(target)) {
if (BI._.isArray(target)) {
target.length = Math.max(target.length, key);
target.splice(key, 1, val);
return val;
}
if (_.has(target, key)) {
if (BI._.has(target, key)) {
target[key] = val;
return val;
}
@ -795,12 +795,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
* Delete a property and trigger change if necessary.
*/
function del(target, key) {
if (_.isArray(target)) {
if (BI._.isArray(target)) {
target.splice(key, 1);
return;
}
var ob = target.__ob__;
if (!_.has(target, key)) {
if (!BI._.has(target, key)) {
return;
}
if (!ob) {
@ -821,7 +821,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
for (var e, i = 0, l = value.length; i < l; i++) {
e = value[i];
e && e.__ob__ && e.__ob__.dep.depend();
if (_.isArray(e)) {
if (BI._.isArray(e)) {
dependArray(e);
}
}
@ -838,7 +838,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function runBinaryFunction(binarys) {
var expr = '';
for (var i = 0, len = binarys.length; i < len; i++) {
if (_.isBoolean(binarys[i]) || _.has(operators, binarys[i])) {
if (BI._.isBoolean(binarys[i]) || BI._.has(operators, binarys[i])) {
expr += binarys[i];
} else {
expr += 'false';
@ -863,7 +863,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
options = options || {};
options.user = true;
var exps = void 0;
if (_.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && expOrFn.indexOf("*") < 0) {
if (BI._.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9BI._.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && expOrFn.indexOf("*") < 0) {
var watcher = new Watcher(model, expOrFn, cb, options);
if (options.immediate) {
cb(watcher.value);
@ -900,8 +900,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}
}
};
_.each(exps, function (exp, i) {
if (_.has(operators, exp)) {
BI._.each(exps, function (exp, i) {
if (BI._.has(operators, exp)) {
return;
}
if (exp.indexOf("*") >= 0) {
@ -929,7 +929,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
_dep.depend();
return NaN;
}, function (newValue, oldValue, attrs) {
callback(i, newValue, oldValue, _.extend({ index: i }, attrs));
callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs));
}, options);
watchers.push(function unwatchFn() {
_w.teardown();
@ -955,7 +955,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var _regStr = routeToRegExp(exp);
var _dep2 = new Dep();
_root._globalDeps || (_root._globalDeps = {});
if (_.isArray(_root._globalDeps[_regStr])) {
if (BI._.isArray(_root._globalDeps[_regStr])) {
_root._globalDeps[_regStr].push(_dep2);
} else {
_root._globalDeps[_regStr] = [_dep2];
@ -965,7 +965,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
_dep2.depend();
return NaN;
}, function (newValue, oldValue, attrs) {
callback(i, newValue, oldValue, _.extend({ index: i }, attrs));
callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs));
}, options);
watchers.push(function unwatchFn() {
if (_root._globalDeps) {
@ -1005,7 +1005,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var regStr = routeToRegExp(exp);
var dep = new Dep();
root._globalDeps || (root._globalDeps = {});
if (_.isArray(root._globalDeps[regStr])) {
if (BI._.isArray(root._globalDeps[regStr])) {
root._globalDeps[regStr].push(dep);
} else {
root._globalDeps[regStr] = [dep];
@ -1015,7 +1015,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
dep.depend();
return NaN;
}, function (newValue, oldValue, attrs) {
callback(i, newValue, oldValue, _.extend({ index: i }, attrs));
callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs));
}, options);
watchers.push(function unwatchFn() {
if (root._globalDeps) {
@ -1029,7 +1029,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return;
}
var watcher = new Watcher(model, exp, function (newValue, oldValue, attrs) {
callback(i, newValue, oldValue, _.extend({ index: i }, attrs));
callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs));
}, options);
watchers.push(function unwatchFn() {
watcher.teardown();
@ -1045,7 +1045,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}
function mixin(xtype, cls) {
mixinInjection[xtype] = _.cloneDeep(cls);
mixinInjection[xtype] = BI._.cloneDeep(cls);
}
var computedWatcherOptions = { lazy: true };
@ -1119,7 +1119,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
vm._watchers || (vm._watchers = []);
for (var key in watch$$1) {
var handler = watch$$1[key];
if (_.isArray(handler)) {
if (BI._.isArray(handler)) {
for (var i = 0; i < handler.length; i++) {
vm._watchers.push(createWatcher(vm, key, handler[i]));
}
@ -1137,27 +1137,27 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (typeof cb === 'string') {
cb = vm[cb];
}
return watch(vm.model, keyOrFn, _.bind(cb, vm.$$model ? vm.model : vm), options);
return watch(vm.model, keyOrFn, BI._.bind(cb, vm.$$model ? vm.model : vm), options);
}
function initMethods(vm, methods) {
for (var key in methods) {
vm[key] = methods[key] == null ? noop : _.bind(methods[key], vm.$$model ? vm.model : vm);
vm[key] = methods[key] == null ? noop : BI._.bind(methods[key], vm.$$model ? vm.model : vm);
}
}
function initMixins(vm, mixins) {
mixins = (mixins || []).slice(0);
_.each(mixins.reverse(), function (mixinType) {
BI._.each(mixins.reverse(), function (mixinType) {
var mixin$$1 = getMixins(mixinType);
for (var key in mixin$$1) {
if (typeof mixin$$1[key] !== "function") continue;
if (_.has(vm, key)) continue;
if (BI._.has(vm, key)) continue;
vm[key] = _.bind(mixin$$1[key], vm.$$model ? vm.model : vm);
vm[key] = BI._.bind(mixin$$1[key], vm.$$model ? vm.model : vm);
}
});
}
@ -1282,7 +1282,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function getInjectValues(vm) {
var inject = vm.inject || [];
var result = {};
_.each(inject, function (key) {
BI._.each(inject, function (key) {
result[key] = getInjectValue(vm, key);
});
return result;
@ -1303,7 +1303,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
this.options = model || {};
}
this._parent = Model.target;
var state = _.isFunction(this.state) ? this.state() : this.state;
var state = BI._.isFunction(this.state) ? this.state() : this.state;
var computed = this.computed;
var context = this.context;
var inject = this.inject;
@ -1311,7 +1311,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var provide = this.provide;
var watch$$1 = this.watch;
var actions = this.actions;
var keys = _.keys(this.$$model).concat(_.keys(state)).concat(_.keys(computed)).concat(inject || []).concat(context || []);
var keys = BI._.keys(this.$$model).concat(BI._.keys(state)).concat(BI._.keys(computed)).concat(inject || []).concat(context || []);
var mixins = this.mixins;
defineProps(this, keys);
// deprecated
@ -1320,7 +1320,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
this.$$model && (this.model.__ob__ = this.$$model.__ob__);
initMixins(this, mixins);
this.init();
initState(this, _.extend(getInjectValues(this), state));
initState(this, BI._.extend(getInjectValues(this), state));
initComputed(this, computed);
REACTIVE && initWatch(this, watch$$1);
initMethods(this, actions);
@ -1341,9 +1341,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
for (var _key3 in this._computedWatchers) {
this._computedWatchers[_key3].teardown();
}
_.each(this._watchers, function (unwatches) {
unwatches = _.isArray(unwatches) ? unwatches : [unwatches];
_.each(unwatches, function (unwatch) {
BI._.each(this._watchers, function (unwatches) {
unwatches = BI._.isArray(unwatches) ? unwatches : [unwatches];
BI._.each(unwatches, function (unwatch) {
unwatch();
});
});
@ -1373,7 +1373,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function toJSON(model) {
var result = void 0;
if (_.isArray(model)) {
if (BI._.isArray(model)) {
result = [];
for (var i = 0, len = model.length; i < len; i++) {
result[i] = toJSON(model[i]);
@ -1381,7 +1381,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
} else if (model && isPlainObject(model)) {
result = {};
for (var _key4 in model) {
if (!_.has($$skipArray, _key4)) {
if (!BI._.has($$skipArray, _key4)) {
result[_key4] = toJSON(model[_key4]);
}
}

131
dist/fix/fix.proxy.js vendored

@ -2,22 +2,16 @@
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Fix = {}));
}(this, (function (exports) { 'use strict';
})(this, (function (exports) { 'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
@ -39,6 +33,9 @@
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
@ -542,10 +539,10 @@
if (type === "clear"
/* CLEAR */
) {
// collection being cleared
// trigger all effects for target
deps = _toConsumableArray(depsMap.values());
} else if (key === 'length' && isArray(target)) {
// collection being cleared
// trigger all effects for target
deps = _toConsumableArray(depsMap.values());
} else if (key === 'length' && isArray(target)) {
depsMap.forEach(function (dep, key) {
if (key === 'length' || key >= newValue) {
deps.push(dep);
@ -728,12 +725,12 @@
if (key === "__v_isReactive"
/* IS_REACTIVE */
) {
return !isReadonly;
} else if (key === "__v_isReadonly"
return !isReadonly;
} else if (key === "__v_isReadonly"
/* IS_READONLY */
) {
return isReadonly;
} else if (key === "__v_raw"
return isReadonly;
} else if (key === "__v_raw"
/* RAW */
&& receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
@ -1217,16 +1214,16 @@
if (key === "__v_isReactive"
/* IS_REACTIVE */
) {
return !isReadonly;
} else if (key === "__v_isReadonly"
return !isReadonly;
} else if (key === "__v_isReadonly"
/* IS_READONLY */
) {
return isReadonly;
} else if (key === "__v_raw"
return isReadonly;
} else if (key === "__v_raw"
/* RAW */
) {
return target;
}
return target;
}
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
};
@ -1335,8 +1332,8 @@
if (targetType === 0
/* INVALID */
) {
return target;
}
return target;
}
var proxy = new Proxy(target, targetType === 2
/* COLLECTION */
@ -1631,7 +1628,7 @@
return mixinInjection[type];
}
function mixin(xtype, cls) {
mixinInjection[xtype] = _.cloneDeep(cls);
mixinInjection[xtype] = BI._.cloneDeep(cls);
}
var queue = [];
@ -1710,7 +1707,7 @@
}
function innerWatch(source, cb, options) {
if (!_.isFunction(cb)) {
if (!BI._.isFunction(cb)) {
console.warn("`watch(fn, options?)` signature has been moved to a separate API. " + "Use `watchEffect(fn, options?)` instead. `watch` now only " + "supports `watch(source, cb, options?) signature.");
}
@ -1775,21 +1772,21 @@
};
deep = true;
} else if (_.isArray(source)) {
} else if (BI._.isArray(source)) {
getter = function getter() {
return source.map(function (s) {
if (isRef(s)) {
return s.value;
} else if (isReactive(s)) {
return traverse(s);
} else if (_.isFunction(s)) {
} else if (BI._.isFunction(s)) {
return s.call(instance);
} else {
warnInvalidSource(s);
}
});
};
} else if (_.isFunction(source)) {
} else if (BI._.isFunction(source)) {
if (cb) {
// getter with cb
getter = function getter() {
@ -1831,7 +1828,7 @@
};
};
var oldValue = _.isArray(source) ? [] : INITIAL_WATCHER_VALUE;
var oldValue = BI._.isArray(source) ? [] : INITIAL_WATCHER_VALUE;
var job = function job() {
// 这里去掉的原因是,新增属性没有生效也会触发变化监听
@ -1903,7 +1900,7 @@
function traverse(value) {
var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
if (!_.isObject(value) || seen.has(value)) {
if (!BI._.isObject(value) || seen.has(value)) {
return value;
}
@ -1911,7 +1908,7 @@
if (isRef(value)) {
traverse(value.value, seen);
} else if (_.isArray(value)) {
} else if (BI._.isArray(value)) {
for (var i = 0; i < value.length; i++) {
traverse(value[i], seen);
}
@ -1940,7 +1937,7 @@
var expr = "";
for (var i = 0, len = binarys.length; i < len; i++) {
if (_.isBoolean(binarys[i]) || _.has(operators, binarys[i])) {
if (BI._.isBoolean(binarys[i]) || BI._.has(operators, binarys[i])) {
expr += binarys[i];
} else {
expr += "false";
@ -1953,7 +1950,7 @@
function watchExp(model, getter) {
var result = getter.call(model, model);
if (_.isArray(result)) {
if (BI._.isArray(result)) {
return result.concat();
}
@ -1974,14 +1971,14 @@
options.user = true;
var exps;
if (_.isFunction(expOrFn)) {
if (BI._.isFunction(expOrFn)) {
var watcher = innerWatch(expOrFn, cb, options);
return function unwatchFn() {
watcher();
};
}
if (!(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) {
if (!(exps = expOrFn.match(/[a-zA-Z0-9BI._.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) {
var paths = expOrFn.split(".");
var prePaths = paths.slice(0, paths.length - 1);
var preGetter = parsePath(prePaths.join("."));
@ -2030,8 +2027,8 @@
}
};
_.each(exps, function (exp, i) {
if (_.has(operators, exp)) {
BI._.each(exps, function (exp, i) {
if (BI._.has(operators, exp)) {
return;
}
@ -2079,14 +2076,14 @@
return watchExp(_v2, _getter);
}, function (newValue, oldValue) {
// a.** 在a变化的时候不会触发change
if (!_.isArray(newValue) && oldValue !== newValue) {
if (!BI._.isArray(newValue) && oldValue !== newValue) {
return;
}
callback(i, NaN, NaN, _.extend({
callback(i, NaN, NaN, BI._.extend({
index: i
}));
}, _.extend({
}, BI._.extend({
deep: true
}, options)));
return;
@ -2145,11 +2142,11 @@
changes = [];
if (newValue === true) {
callback(i, NaN, NaN, _.extend({
callback(i, NaN, NaN, BI._.extend({
index: i
}));
}
}, _.extend({}, options, {
}, BI._.extend({}, options, {
deep: true,
onTrigger: function onTrigger(_ref) {
var target = _ref.target,
@ -2167,7 +2164,7 @@
watchers.push(innerWatch(function () {
return watchExp(model, getter);
}, function (newValue, oldValue) {
callback(i, newValue, oldValue, _.extend({
callback(i, newValue, oldValue, BI._.extend({
index: i
}));
}, options));
@ -2188,7 +2185,7 @@
var $$computed = vm.$$computed = {};
for (var key in c) {
$$computed[key] = computed(_.bind(c[key], vm));
$$computed[key] = computed(BI._.bind(c[key], vm));
}
}
@ -2198,7 +2195,7 @@
for (var key in watch) {
var handler = watch[key];
if (_.isArray(handler)) {
if (BI._.isArray(handler)) {
for (var i = 0; i < handler.length; i++) {
vm._watchers.push(createWatcher(vm, key, handler[i]));
}
@ -2218,25 +2215,25 @@
cb = vm[cb];
}
return watch(vm.model, keyOrFn, _.bind(cb, vm), options);
return watch(vm.model, keyOrFn, BI._.bind(cb, vm), options);
}
function initMethods(vm, methods) {
for (var key in methods) {
vm[key] = methods[key] == null ? noop : _.bind(methods[key], vm);
vm[key] = methods[key] == null ? noop : BI._.bind(methods[key], vm);
}
}
function initMixins(vm, mixins) {
mixins = (mixins || []).slice(0);
_.each(mixins.reverse(), function (mixinType) {
BI._.each(mixins.reverse(), function (mixinType) {
var mixin = getMixins(mixinType);
for (var key in mixin) {
if (typeof mixin[key] !== "function") continue;
if (_.has(vm, key)) continue;
vm[key] = _.bind(mixin[key], vm);
if (BI._.has(vm, key)) continue;
vm[key] = BI._.bind(mixin[key], vm);
}
});
}
@ -2329,7 +2326,7 @@
var inject = vm.inject || [];
var result = {};
_.each(inject, function (key) {
BI._.each(inject, function (key) {
result[key] = getInjectValue(vm, key);
});
@ -2346,7 +2343,7 @@
value: function _constructor(options, destroyHandler) {
this.options = options || {};
this._parent = Model.target;
var state = _.isFunction(this.state) ? this.state() : this.state;
var state = BI._.isFunction(this.state) ? this.state() : this.state;
var computed = this.computed;
var context = this.context;
var inject = this.inject;
@ -2354,14 +2351,14 @@
var watch = this.watch;
var actions = this.actions;
_.keys(state).concat(_.keys(computed)).concat(inject || []).concat(context || []);
BI._.keys(state).concat(BI._.keys(computed)).concat(inject || []).concat(context || []);
var mixins = this.mixins;
defineProps(this);
childContext && defineContext(this, childContext);
initMixins(this, mixins);
this.init();
initState(this, _.extend(getInjectValues(this), state));
initState(this, BI._.extend(getInjectValues(this), state));
initComputed(this, computed);
REACTIVE && initWatch(this, watch);
initMethods(this, actions);
@ -2379,10 +2376,10 @@
}, {
key: "destroy",
value: function destroy() {
_.each(this._watchers, function (unwatches) {
unwatches = _.isArray(unwatches) ? unwatches : [unwatches];
BI._.each(this._watchers, function (unwatches) {
unwatches = BI._.isArray(unwatches) ? unwatches : [unwatches];
_.each(unwatches, function (unwatch) {
BI._.each(unwatches, function (unwatch) {
unwatch();
});
});
@ -2398,7 +2395,7 @@
return Model;
}();
function set(target, key, val) {
if (_.isArray(target)) {
if (BI._.isArray(target)) {
target.length = Math.max(target.length, key);
target.splice(key, 1, val);
return val;
@ -2416,12 +2413,12 @@
return value;
}
function del(target, key) {
if (_.isArray(target)) {
if (BI._.isArray(target)) {
target.splice(key, 1);
return;
}
if (!_.has(target, key)) {
if (!BI._.has(target, key)) {
return;
}
@ -2441,7 +2438,7 @@
function toJSON(model) {
var result;
if (_.isArray(model)) {
if (BI._.isArray(model)) {
result = [];
for (var i = 0, len = model.length; i < len; i++) {
@ -2475,4 +2472,4 @@
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));

15
examples/worker_new.html

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="http://fanruan.design/fineui/2.0/fineui.min.css" />
<script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script src="./worker_new/index.js"></script>
</body>
</html>

105
examples/worker_new/index.js

@ -0,0 +1,105 @@
document.cookie = "test=demo";
// worker获取主线程资源
var CookieAction = BI.inherit(BI.Workers.WorkerBaseAction, {
addActionHandler: function() {
this.controller.addActionHandler("Cookie", this.getCookie.bind(this));
},
getCookie: function() {
return document.cookie;
}
});
// 调用worker计算
var FibonacciAction = BI.inherit(BI.Workers.WorkerBaseAction, {
addActionHandler: function() {},
getResult: function(times) {
return this.controller.requestPromise("Fibonacci", { times: times })
.then(function(v) {
console.log(v);
});
}
});
// 主线程与worker多次交互
const HeartBeatCheckAction = BI.inherit(BI.Workers.WorkerBaseAction, {
addActionHandler: function() {
this.controller.addActionHandler("HeartBeatChecked", this.recieveHeartBeatChecked.bind(this));
},
recieveHeartBeatChecked: function (payload) {
console.log("heartbeat: " + payload.time);
},
startHeatBeatCheck: function() {
return this.controller.request("HeartBeatCheckStart");
},
stopHeatBeatCheck: function() {
return this.controller.request("HeartBeatCheckStop");
}
});
var WorkerThreadWorker = BI.inherit(BI.Workers.MainThreadWorker, {
initActions: function() {
this.cookieAction = this.createAction(CookieAction);
this.fibonacciAction = this.createAction(FibonacciAction);
this.heartBeatCheckAction = this.createAction(HeartBeatCheckAction);
},
calculateFibonacci: function(times) {
this.fibonacciAction.getResult(times);
},
startHeatBeatCheck: function() {
this.heartBeatCheckAction.startHeatBeatCheck();
},
stopHeatBeatCheck: function() {
this.heartBeatCheckAction.stopHeatBeatCheck();
}
});
var mainThreadWorker = new WorkerThreadWorker({
workerUrl: "./worker_new/worker.js",
workerName: "demo"
});
BI.createWidget({
type: "bi.vertical",
element: "#wrapper",
vgap: 10,
hgap: 10,
items: [
{
type: "bi.button",
text: "点击计算斐波那契数列第40项",
width: 200,
handler: function() {
console.log("click");
mainThreadWorker.calculateFibonacci(40);
}
},
{
type: "bi.button",
text: "开始心跳",
width: 200,
handler: function() {
mainThreadWorker.startHeatBeatCheck();
}
},
{
type: "bi.button",
text: "停止心跳",
width: 200,
handler: function() {
mainThreadWorker.stopHeatBeatCheck();
}
}
]
});

80
examples/worker_new/worker.js

@ -0,0 +1,80 @@
self.importScripts("https://fanruan.design/fineui/fineui_without_jquery_polyfill.js");
var CookieAction = BI.inherit(BI.Workers.WorkerBaseAction, {
addActionHandler: function() {},
getCookie: function() {
return this.controller.requestPromise("Cookie");
}
});
function fibonacci(n) {
if (n === 1 || n === 2) {
return 1;
}
return fibonacci(n - 2) + fibonacci(n - 1);
}
var FibonacciAction = BI.inherit(BI.Workers.WorkerBaseAction, {
addActionHandler: function() {
this.controller.addActionHandler("Fibonacci", this.getResult.bind(this));
},
getResult: function(payload) {
return fibonacci(payload.times);
}
});
const HeartBeatCheckAction = BI.inherit(BI.Workers.WorkerBaseAction, {
addActionHandler: function() {
this.controller.addActionHandler("HeartBeatCheckStart", this.startHeatBeatCheck.bind(this));
this.controller.addActionHandler("HeartBeatCheckStop", this.stopHeatBeatCheck.bind(this));
},
startHeatBeatCheck: function() {
var self = this;
if (!this.timer) {
console.log("heart beat check started");
this.timer = setInterval(function() {
// 模拟请求
setTimeout(function() {
self.controller.request("HeartBeatChecked", {
time: new Date()
});
}, 50);
}, 5 * 1000);
} else {
console.log("heart beat has already started!");
}
},
stopHeatBeatCheck: function() {
console.log("heart beat check stopped");
clearInterval(this.timer);
}
});
var WorkerThreadWorker = BI.inherit(BI.Workers.WorkerThreadWorker, {
initActions: function() {
this.cookieAction = this.createAction(CookieAction);
this.fibonacciAction = this.createAction(FibonacciAction);
this.heartBeatCheckAction = this.createAction(HeartBeatCheckAction);
},
fetchCookie: function() {
return this.cookieAction.getCookie()
.then(function (v) {
console.log(v);
});
}
});
var workerThreadWorker = new WorkerThreadWorker();
workerThreadWorker.fetchCookie();

104
examples/替换loading动画.html

@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="https://fanruan.design/fineui/2.0/fineui_without_normalize.css" />
<!-- <script src="/fineui.js"></script> -->
<script src="https://fanruan.design/fineui/2.0/fineui.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
var LoadingPane = BI.inherit(BI.Pane, {});
BI.shortcut("demo.loading_pane", LoadingPane);
var loadingPane;
BI.createWidget({
type: "bi.vertical",
element: "#wrapper",
items: [{
type: "bi.vertical",
items: [{
type: "demo.loading_pane",
width: 800,
height: 600,
cls: "bi-border",
ref: function(ref) {
loadingPane = ref;
},
}, {
type: "bi.left",
rgap: 10,
items: [{
type: "bi.button",
text: "开始loading",
handler: function () {
loadingPane.loading();
},
}, {
type: "bi.button",
text: "停止loading",
handler: function () {
loadingPane.loaded();
},
}, {
type: "bi.button",
text: "设置文字loading",
handler: function () {
BI.config("bi.provider.system", function (provider) {
provider.setLoadingCreator(function () {
return {
type: "bi.label",
text: "我是被替换了的loading"
};
});
});
},
}, {
type: "bi.button",
text: "恢复波浪线loading",
handler: function () {
BI.config("bi.provider.system", function (provider) {
provider.setLoadingCreator(function () {
return {
type: "bi.horizontal",
cls: "bi-loading-widget",
height: 30,
width: 30,
hgap: 5,
vgap: 2.5,
items: [{
type: "bi.layout",
cls: "animate-rect rect1",
height: 25,
width: 2.5
}, {
type: "bi.layout",
cls: "animate-rect rect2",
height: 25,
width: 2.5
}, {
type: "bi.layout",
cls: "animate-rect rect3",
height: 25,
width: 2.5
}]
};
});
});
},
}]
}],
}],
});
</script>
</body>
</html>

11
package.json

@ -1,14 +1,17 @@
{
"name": "fineui",
"version": "2.0.20220617213406",
"version": "2.0.20220720140353",
"description": "fineui",
"main": "dist/fineui.min.js",
"main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts",
"bin": {
"fui-cli": "./bin/cli/cli.js"
},
"devDependencies": {
"@babel/core": "^7.17.4",
"@babel/polyfill": "7.6.0",
"@fui/babel-preset-fineui": "^2.0.0",
"@fui/eslint-plugin": "1.0.11",
"@fui/eslint-plugin": "1.0.15",
"@types/node": "15.6.1",
"autoprefixer": "9.6.1",
"babel-loader": "8.0.6",
@ -47,7 +50,7 @@
"source-map-loader": "0.2.4",
"style-loader": "0.23.1",
"terser-webpack-plugin": "4.2.3",
"typescript": "3.5.2",
"typescript": "3.9.2",
"webpack": "4.35.2",
"webpack-cli": "3.3.5",
"webpack-dev-server": "3.7.2",

29
src/base/1.pane.js

@ -40,31 +40,10 @@ BI.Pane = BI.inherit(BI.Widget, {
loading: function () {
var self = this, o = this.options;
var isIE = BI.isIE();
var loadingAnimation = BI.createWidget({
type: "bi.horizontal",
cls: "bi-loading-widget" + (isIE ? " wave-loading hack" : ""),
height: this._getSize(60),
width: this._getSize(60),
hgap: this._getSize(10),
vgap: 2.5,
items: isIE ? [] : [{
type: "bi.layout",
cls: "animate-rect rect1",
height: this._getSize(50),
width: this._getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect2",
height: this._getSize(50),
width: this._getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect3",
height: this._getSize(50),
width: this._getSize(5)
}]
});
var loadingAnimation = BI.createWidget(BI.Providers.getProvider("bi.provider.system").getLoading({
loadingSize: o.loadingSize,
context: this
}));
// pane在同步方式下由items决定tipText的显示与否
// loading的异步情况下由loaded后对面板的populate的时机决定
this.setTipVisible(false);

10
src/base/combination/bubble.js

@ -44,7 +44,9 @@
var self = this, o = this.options;
this._initCombo();
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
BI.nextTick(() => {
!this.isDestroyed() && this._initPullDownAction();
});
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
@ -82,7 +84,7 @@
element: this
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: [
{el: this.combo}
{ el: this.combo }
]
}))));
o.isDefaultInit && (this._assertPopupView());
@ -113,7 +115,7 @@
var enterPopup = false;
function hide (e) {
function hide(e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView(e);
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
@ -255,7 +257,7 @@
scrolly: false,
element: this.options.container || this,
items: [
{el: this.popupView}
{ el: this.popupView }
]
});
this._rendered = true;

11
src/base/combination/combo.js

@ -50,9 +50,14 @@
var self = this, o = this.options;
this._initCombo();
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
BI.nextTick(() => {
!this.isDestroyed() && this._initPullDownAction();
});
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.TOGGLE) {
self._toggle();
}
if (type === BI.Events.EXPAND) {
self._popupView();
}
@ -88,7 +93,7 @@
element: this
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: [
{el: this.combo}
{ el: this.combo }
]
}))));
o.isDefaultInit && (this._assertPopupView());
@ -153,7 +158,7 @@
this._assertPopupViewRender();
this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
this.popupView.css({left: -999999999, top: -99999999});
this.popupView.css({ left: -999999999, top: -99999999 });
this.popupView.visible();
BI.each(needHideWhenAnotherComboOpen, function (i, combo) {
if (i !== self.getName()) {

8
src/base/combination/expander.js

@ -26,7 +26,9 @@ BI.Expander = BI.inherit(BI.Widget, {
this._expanded = !!o.el.open;
this._initExpander();
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
BI.nextTick(() => {
!this.isDestroyed() && this._initPullDownAction();
});
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
@ -63,7 +65,7 @@ BI.Expander = BI.inherit(BI.Widget, {
scrolly: false,
element: this,
items: [
{el: this.expander}
{ el: this.expander }
]
});
o.isDefaultInit && this._assertPopupView();
@ -167,7 +169,7 @@ BI.Expander = BI.inherit(BI.Widget, {
scrolly: false,
element: this,
items: [
{el: this.popupView}
{ el: this.popupView }
]
});
this._rendered = true;

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

@ -197,7 +197,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
items = this._packageItems(items, this._packageBtns(this.buttons));
}
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
this.layouts = BI.createWidget(BI.extend({ element: this }, this._packageLayout(items)));
},
setNotSelectedValue: function (v) {
@ -233,6 +233,23 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
});
},
setValueMap: function (map) {
map = map || {};
BI.each(this.buttons, function (i, item) {
if (BI.isNotNull(map[item.getValue()])) {
item.setSelected && item.setSelected(true);
} else {
item.setSelected && item.setSelected(false);
}
});
},
setAllSelected: function (v) {
BI.each(this.getAllButtons(), function (i, btn) {
(btn.setSelected || btn.setAllSelected).apply(btn, [v]);
});
},
getNotSelectedValue: function () {
var v = [];
BI.each(this.buttons, function (i, item) {
@ -314,6 +331,16 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
return node;
},
/**
* 滚动到指定的节点
*/
scrollToValue: function (value, scrollIntoViewOptions) {
var node = this.getNodeByValue(value);
if (node) {
node.element[0].scrollIntoView(scrollIntoViewOptions);
}
},
empty: function () {
BI.ButtonGroup.superclass.empty.apply(this, arguments);
this.options.items = [];

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

@ -96,6 +96,20 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
return v;
},
getNodeByValue: function (value) {
return this.buttonMap[value];
},
/**
* 滚动到指定的节点
*/
scrollToValue: function (value, scrollIntoViewOptions) {
var node = this.getNodeByValue(value);
if (node) {
node.element[0].scrollIntoView(scrollIntoViewOptions);
}
},
getValue: function () {
var v = [];
BI.each(this.buttonMap, function (i, item) {
@ -113,7 +127,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
this.options.items = items;
items = this._packageBtns(items);
if (!this.layouts) {
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
this.layouts = BI.createWidget(BI.extend({ element: this }, this._packageLayout(items)));
} else {
this.layouts.populate(items, {
context: this

10
src/base/combination/switcher.js

@ -26,7 +26,9 @@ BI.Switcher = BI.inherit(BI.Widget, {
var self = this, o = this.options;
this._initSwitcher();
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this._initPullDownAction.bind(this));
BI.nextTick(() => {
!this.isDestroyed() && this._initPullDownAction();
});
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
@ -63,7 +65,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
scrolly: false,
element: this,
items: [
{el: this.switcher}
{ el: this.switcher }
]
});
o.isDefaultInit && (this._assertPopupView());
@ -136,7 +138,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (!this._created) {
this.popupView = BI.createWidget(o.popup, {
type: "bi.button_group",
element: o.adapter && BI.Maskers.create(this.getName(), o.adapter, BI.extend({container: this}, o.masker)),
element: o.adapter && BI.Maskers.create(this.getName(), o.adapter, BI.extend({ container: this }, o.masker)),
cls: "switcher-popup",
layouts: [{
type: "bi.vertical",
@ -157,7 +159,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
scrolly: false,
element: this,
items: [
{el: this.popupView}
{ el: this.popupView }
]
});
}

23
src/base/combination/tab.js

@ -86,15 +86,18 @@ BI.Tab = BI.inherit(BI.Widget, {
created: function () {
var self = this, o = this.options;
if (o.showIndex !== false) {
if (BI.isFunction(o.showIndex)) {
var v = this.__watch(o.showIndex, function (context, newValue) {
self.setSelect(newValue);
});
this.setSelect(v);
} else {
this.setSelect(o.showIndex);
}
var showIndex;
if (BI.isFunction(o.showIndex)) {
showIndex = this.__watch(o.showIndex, function (context, newValue) {
self.setSelect(newValue);
});
} else {
showIndex = o.showIndex;
}
if (showIndex !== false) {
this.setSelect(showIndex);
}
},
@ -135,7 +138,7 @@ BI.Tab = BI.inherit(BI.Widget, {
getTab: function (v) {
this._assertCard(v);
return this.layout.getCardByName(v);
return this.layout.getCardByName(v);
},
setValue: function (v) {

16
src/base/list/listview.js

@ -1,5 +1,5 @@
/**
* 表示当前对象
* 边滚动边加载的列表控件
*
* Created by GUY on 2017/5/23.
* @class BI.ListView
@ -33,8 +33,8 @@ BI.ListView = BI.inherit(BI.Widget, {
items: [BI.extend({
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
ref: function (_ref) {
self.container = _ref;
}
}, o.el)],
element: this
@ -69,8 +69,8 @@ BI.ListView = BI.inherit(BI.Widget, {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0;
var cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height();
@ -112,6 +112,12 @@ BI.ListView = BI.inherit(BI.Widget, {
this.cache = {};
},
scrollTo: function (scrollTop) {
this.options.scrollTop = scrollTop;
this._calculateBlocksToRender();
this.element.scrollTop(scrollTop);
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();

13
src/base/list/virtualgrouplist.js

@ -62,7 +62,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
}) : o.items;
this._populate();
this.ticking = false;
this.element.scroll(function() {
this.element.scroll(function () {
o.scrollTop = self.element.scrollTop();
if (!self.ticking) {
requestAnimationFrame(function () {
@ -123,7 +123,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
}
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)));
this.container.populate(items.map(function (item, i) {
return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i)
return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i);
}));
} else {
for (var i = (start < 0 ? 0 : start); i <= end; i++) {
@ -134,7 +134,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
}
this.container.element.height(o.rowHeight * o.items.length - topHeight);
this.container.populate(items.map(function (item, i) {
return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i)
return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i);
}));
}
},
@ -162,6 +162,13 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
this.bottomBlank.setHeight(0);
},
// 暂时只支持固定行高的场景
scrollTo: function (scrollTop) {
this.options.scrollTop = scrollTop;
this._calculateBlocksToRender();
this.element.scrollTop(scrollTop);
},
restore: function () {
this.options.scrollTop = 0;
this._restore();

9
src/base/list/virtuallist.js

@ -46,7 +46,6 @@ BI.VirtualList = BI.inherit(BI.Widget, {
self.bottomBlank = this;
}
}],
element: this
};
},
@ -78,7 +77,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
while ((lastHeight = getElementHeight()) < 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)
return o.itemFormatter(item, index + i);
}), this);
var addedHeight = getElementHeight() - lastHeight;
this.tree.set(cnt, addedHeight);
@ -177,6 +176,12 @@ BI.VirtualList = BI.inherit(BI.Widget, {
this.container.attr("items", []);
},
scrollTo: function (scrollTop) {
this.options.scrollTop = scrollTop;
this._calculateBlocksToRender();
this.element.scrollTop(scrollTop);
},
restore: function () {
this.renderedIndex = -1;
this._clearChildren();

35
src/base/single/0.single.js

@ -9,6 +9,9 @@
* @extends BI.Widget
* @abstract
*/
var delayingTooltips;
BI.Single = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.Single.superclass._defaultConfig.apply(this, arguments);
@ -17,17 +20,29 @@ BI.Single = BI.inherit(BI.Widget, {
title: null,
warningTitle: null,
tipType: null, // success或warning
belowMouse: false // title是否跟随鼠标
belowMouse: false, // title是否跟随鼠标
enableHover: false
});
},
_showToolTip: function (e, opt) {
opt || (opt = {});
var self = this, o = this.options;
var type = this.getTipType() || (this.isEnabled() ? "success" : "warning");
var title = type === "success" ? this.getTitle() : (this.getWarningTitle() || this.getTitle());
if (BI.isKey(title)) {
BI.Tooltips.show(e, this.getName(), title, type, this, opt);
var o = this.options;
var tooltipOpt = {};
var title = this.getTitle();
if (BI.isPlainObject(title)) {
tooltipOpt = title;
} else {
tooltipOpt.level = this.getTipType() || "success";
// 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况
if (BI.isNull(o.tipType) && !this.isEnabled()) {
tooltipOpt.text = (this.getWarningTitle() || title);
} else {
tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title);
}
}
if (BI.isKey(tooltipOpt.text)) {
BI.Tooltips.show(e, this.getName(), tooltipOpt, this, opt);
if (o.action) {
BI.Actions.runAction(o.action, "hover", o, this);
}
@ -51,7 +66,7 @@ BI.Single = BI.inherit(BI.Widget, {
self.setValue(newValue);
}) : o.value;
BI.Single.superclass._init.apply(this, arguments);
if (BI.isKey(o.title) || BI.isKey(o.warningTitle)
if (o.enableHover || BI.isKey(o.title) || BI.isKey(o.warningTitle)
|| BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) {
this.enableHover({
belowMouse: o.belowMouse,
@ -78,14 +93,16 @@ BI.Single = BI.inherit(BI.Widget, {
this.element.on("mouseenter.title" + this.getName(), function (e) {
self._e = e;
if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) {
delayingTooltips = self.getName();
self.showTimeout = BI.delay(function () {
if (BI.isNotNull(self.showTimeout)) {
if (BI.isNotNull(self.showTimeout) && delayingTooltips === self.getName()) {
self._showToolTip(self._e || e, opt);
}
}, 200);
} else if (self.getTipType() === "success" || self.isEnabled()) {
delayingTooltips = self.getName();
self.showTimeout = BI.delay(function () {
if (BI.isNotNull(self.showTimeout)) {
if (BI.isNotNull(self.showTimeout) && delayingTooltips === self.getName()) {
self._showToolTip(self._e || e, opt);
}
}, 500);

12
src/base/single/button/button.basic.js

@ -49,7 +49,9 @@ BI.BasicButton = BI.inherit(BI.Single, {
this.setSelected(true);
}
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this.bindEvent.bind(this));
BI.nextTick(() => {
!this.isDestroyed() && this.bindEvent();
});
BI.BasicButton.superclass._initRef.apply(this, arguments);
},
@ -211,7 +213,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
// enter键等同于点击
o.attributes && o.attributes.zIndex >= 0 && hand.keyup(function (e) {
if (e.keyCode === BI.KeyCode.ENTER) {
clk(e);
clk(e);
}
});
break;
@ -224,7 +226,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
"trailing": false
});
function ev (e) {
function ev(e) {
if (o.stopEvent) {
e.stopEvent();
}
@ -233,7 +235,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
}
}
function clk (e) {
function clk(e) {
ev(e);
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return;
@ -297,7 +299,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
onClick.apply(self, arguments);
}
function getBubble () {
function getBubble() {
var bubble = self.options.bubble;
if (BI.isFunction(bubble)) {
return bubble();

41
src/base/single/button/buttons/button.js

@ -30,12 +30,14 @@
adaptiveHeight += (tGap + bGap);
}
var clearMinWidth = props.block === true || props.clear === true || props.plain;
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""),
attributes: {
tabIndex: 1
},
minWidth: (props.block === true || props.clear === true) ? 0 : 80,
minWidth: clearMinWidth ? 0 : 80,
height: isVertical(props.iconPosition) ? adaptiveHeight : 24,
shadow: props.clear !== true,
isShadowShowingOnSelected: true,
@ -64,7 +66,7 @@
},
render: function () {
var o = this.options;
var o = this.options, self = this;
// 由于button默认情况下有个边框,所以要主动算行高
var lineHeight, textHeight = o.textHeight;
@ -110,12 +112,12 @@
tgap: o.iconPosition === "top" ? o.iconGap : 0,
bgap: o.iconPosition === "bottom" ? o.iconGap : 0
};
var items = [this.icon, BI.extend({el: this.text}, gapContainer)];
var items = [this.icon, BI.extend({ el: this.text }, gapContainer)];
if (isVertical(o.iconPosition)) {
layoutType = "bi.vertical";
}
if (o.iconPosition === "right" || o.iconPosition === "bottom") {
items = [BI.extend({el: this.text}, gapContainer), this.icon];
items = [BI.extend({ el: this.text }, gapContainer), this.icon];
}
BI.createWidget({
type: "bi.center_adapt",
@ -145,29 +147,20 @@
rgap: o.rgap,
element: this,
text: o.text,
value: o.value
value: o.value,
title: null,
});
}
if (o.block === true) {
this.element.addClass("block");
}
if (o.clear === true) {
this.element.addClass("clear");
}
if (o.ghost === true) {
this.element.addClass("ghost");
}
if (o.plain === true) {
this.element.addClass("plain");
}
if (o.loading === true) {
this.element.addClass("loading");
}
if (o.light === true) {
this.element.addClass("light");
}
var classArr = ["block", "clear", "ghost", "plain", "loading", "light"];
// 如果 options 对应的属性为 true 则给元素添加 class
BI.each(classArr, function (_, clz) {
if (BI.get(o, clz) === true) {
self.element.addClass(clz);
}
});
if (o.minWidth > 0) {
this.element.css({"min-width": o.minWidth / BI.pixRatio + BI.pixUnit});
this.element.css({ "min-width": o.minWidth / BI.pixRatio + BI.pixUnit });
}
},

4
src/base/single/editor/editor.multifile.js

@ -71,6 +71,10 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
this.file.reset();
},
setUrl: function (v) {
this.file.setUrl(v);
},
setMaxFileLength: function (v) {
this.file.setMaxFileLength(v);
},

7
src/base/single/input/file.js

@ -655,6 +655,13 @@
});
},
setUrl: function(v) {
this.options.url = v;
if (this.wrap) {
this.wrap.url = v;
}
},
setMaxFileLength: function (v) {
this.options.maxLength = v;
if (this.wrap) {

20
src/base/single/label/abstract.label.js

@ -18,10 +18,27 @@
tgap: 0,
bgap: 0,
highLight: false,
handler: null
handler: null,
enableHover: props.title !== null,
});
},
getTitle: function () {
var title = this.options.title;
var text = this.options.text;
if (BI.isFunction(title)) {
return title();
}
if (BI.isNotNull(title)) {
return title;
}
if (BI.isFunction(text)) {
return text();
}
return text;
},
_createJson: function () {
var o = this.options;
return {
@ -374,6 +391,7 @@
setValue: function (v) {
BI.AbstractLabel.superclass.setValue.apply(this, arguments);
if (!this.isReadOnly()) {
this.options.text = v;
this.text.setValue(v);
}
}

30
src/base/single/tip/tip.toast.js

@ -11,7 +11,6 @@ BI.Toast = BI.inherit(BI.Tip, {
minWidth: 100,
closableMaxWidth: 410,
maxWidth: 400,
hgap: 8
},
_defaultConfig: function () {
@ -21,7 +20,10 @@ BI.Toast = BI.inherit(BI.Tip, {
level: "success", // success或warning
autoClose: true,
closable: null,
vgap: 7,
textHeight: 20,
vgap: 10,
innerHgap: 4,
hgap: 8,
});
},
@ -46,7 +48,7 @@ BI.Toast = BI.inherit(BI.Tip, {
mouseleave: fn,
mousemove: fn
});
var cls = "close-font";
var cls;
switch (o.level) {
case "success":
cls = "toast-success-font";
@ -72,19 +74,18 @@ BI.Toast = BI.inherit(BI.Tip, {
var items = [{
type: "bi.icon_label",
cls: cls + " toast-icon",
width: 36
height: o.textHeight,
}, {
el: BI.isPlainObject(o.text) ? o.text : {
type: "bi.label",
whiteSpace: "normal",
text: o.text,
textHeight: 16,
textHeight: o.textHeight,
textAlign: "left"
},
rgap: hasCloseIcon() ? 0 : this._const.hgap
}];
var columnSize = [36, "fill"];
var columnSize = ["", "fill"];
if (hasCloseIcon()) {
items.push({
@ -93,23 +94,20 @@ BI.Toast = BI.inherit(BI.Tip, {
handler: function () {
self.destroy();
},
width: 36
height: o.textHeight,
});
columnSize.push(36);
columnSize.push("");
}
this.text = BI.createWidget({
return {
type: "bi.horizontal",
horizontalAlign: BI.HorizontalAlign.Stretch,
element: this,
items: items,
hgap: o.hgap,
vgap: o.vgap,
innerHgap: o.innerHgap,
columnSize: columnSize
});
},
setText: function (text) {
this.text.setText(text);
};
},
beforeDestroy: function () {

15
src/base/single/tip/tip.tooltip.js

@ -7,8 +7,8 @@
*/
BI.Tooltip = BI.inherit(BI.Tip, {
_const: {
hgap: 5,
vgap: 3
hgap: 8,
vgap: 4
},
_defaultConfig: function () {
@ -17,7 +17,8 @@ BI.Tooltip = BI.inherit(BI.Tip, {
text: "",
level: "success", // success或warning
stopEvent: false,
stopPropagation: false
stopPropagation: false,
textAlign: "left",
});
},
@ -44,10 +45,11 @@ BI.Tooltip = BI.inherit(BI.Tip, {
type: "bi.vertical",
element: this,
hgap: this._const.hgap,
innerVgap: this._const.vgap,
items: BI.map(texts, function (i, text) {
return {
type: "bi.label",
textAlign: "left",
textAlign: o.textAlign,
whiteSpace: "normal",
text: text,
textHeight: 18
@ -58,11 +60,12 @@ BI.Tooltip = BI.inherit(BI.Tip, {
this.text = BI.createWidget({
type: "bi.label",
element: this,
textAlign: "left",
textAlign: o.textAlign,
whiteSpace: "normal",
text: o.text,
textHeight: 18,
hgap: this._const.hgap
hgap: this._const.hgap,
vgap: this._const.vgap,
});
}
},

1
src/case/combo/bubblecombo/combo.bubble.js

@ -52,6 +52,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
hideChecker: o.hideChecker,
offsetStyle: o.offsetStyle,
showArrow: true,
comboClass: o.comboClass,
el: o.el,
popup: () => BI.extend({
type: "bi.bubble_popup_view",

5
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -24,7 +24,10 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
},
width: o.height,
height: o.height,
width: 24,
stopPropagation: true,
handler: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.TOGGLE);
}
};
var stateText = this._digest(o.value, o.items) || o.text;

26
src/case/layer/pane.list.js

@ -47,11 +47,15 @@ BI.ListPane = BI.inherit(BI.Pane, {
}
o.itemsCreator(op, function () {
calback.apply(self, arguments);
op.times === 1 && BI.nextTick(function () {
self.loaded();
// callback可能在loading之前执行, check保证显示正确
self.check();
});
o.items = BI.concat(o.items, BI.get(arguments, [0], []));
if (op.times === 1) {
o.items = BI.get(arguments, [0], []);
BI.nextTick(function () {
self.loaded();
// callback可能在loading之前执行, check保证显示正确
self.check();
});
}
});
},
hasNext: o.hasNext,
@ -113,7 +117,7 @@ BI.ListPane = BI.inherit(BI.Pane, {
populate: function (items) {
var self = this, o = this.options;
if (arguments.length === 0 && (BI.isFunction(this.button_group.attr("itemsCreator")))) {// 接管loader的populate方法
this.button_group.attr("itemsCreator").apply(this, [{times: 1}, function () {
this.button_group.attr("itemsCreator").apply(this, [{ times: 1 }, function () {
if (arguments.length === 0) {
throw new Error("参数不能为空");
}
@ -150,6 +154,16 @@ BI.ListPane = BI.inherit(BI.Pane, {
this.button_group.setValue.apply(this.button_group, arguments);
},
setAllSelected: function (v) {
if (this.button_group.setAllSelected) {
this.button_group.setAllSelected(v);
} else {
BI.each(this.getAllButtons(), function (i, btn) {
(btn.setSelected || btn.setAllSelected).apply(btn, [v]);
});
}
},
getValue: function () {
return this.button_group.getValue.apply(this.button_group, arguments);
},

10
src/case/list/list.select.js

@ -113,9 +113,13 @@ BI.SelectList = BI.inherit(BI.Widget, {
},
setAllSelected: function (v) {
BI.each(this.getAllButtons(), function (i, btn) {
(btn.setSelected || btn.setAllSelected).apply(btn, [v]);
});
if (this.list.setAllSelected) {
this.list.setAllSelected(v);
} else {
BI.each(this.getAllButtons(), function (i, btn) {
(btn.setSelected || btn.setAllSelected).apply(btn, [v]);
});
}
this.allSelected = !!v;
this.toolbar.setSelected(v);
this.toolbar.setHalfSelected(false);

4
src/case/ztree/0.treeview.js

@ -95,7 +95,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
expandSpeed: "",
nameIsHTML: true, // 节点可以用html标签代替
dblClickExpand: false,
showLine: o.showLine
showLine: o.showLine,
},
callback: {
beforeExpand: beforeExpand,
@ -360,7 +360,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
tagName: "span",
whiteSpace: "nowrap",
root: true,
keyword: o.paras.keyword
keyword: o.paras.keyword,
}, newNode, {
type: "bi.text",
text: BI.replaceAll(newNode.text, "\n", " ")

14
src/case/ztree/1.asynctree.js

@ -6,7 +6,10 @@
*/
BI.AsyncTree = BI.inherit(BI.TreeView, {
_defaultConfig: function () {
return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {});
return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {
showIcon: false,
showLine: true,
});
},
_init: function () {
BI.AsyncTree.superclass._init.apply(this, arguments);
@ -42,11 +45,14 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
},
view: {
showIcon: false,
showIcon: o.showIcon,
expandSpeed: "",
nameIsHTML: true,
dblClickExpand: false,
showLine: o.showLine
showLine: o.showLine,
nodeClasses: function (treeId, treeNode) {
return { add: [treeNode.iconCls || ""] };
}
},
callback: {
beforeCheck: beforeCheck,
@ -54,7 +60,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
beforeExpand: beforeExpand,
onExpand: onExpand,
onCollapse: onCollapse,
onClick: onClick
onClick: onClick,
}
};

3647
src/case/ztree/jquery.ztree.core-3.5.js

File diff suppressed because it is too large Load Diff

23
src/component/allvaluechooser/abstract.allvaluechooser.js

@ -40,6 +40,18 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
return text;
},
_getItemsByTimes: function (items, times) {
var res = [];
for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
res.push(items[i]);
}
return res;
},
_hasNextByTimes: function (items, times) {
return times * this._const.perPage < items.length;
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!o.cache || !this.items) {
@ -50,13 +62,14 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
} else {
call(this.items);
}
function call (items) {
function call(items) {
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
var resultItems = items;
if(BI.isNotEmptyArray(keywords)) {
if (BI.isNotEmptyArray(keywords)) {
resultItems = [];
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
@ -77,12 +90,12 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
return;
}
if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: resultItems.length});
callback({ count: resultItems.length });
return;
}
callback({
items: resultItems,
hasNext: false
items: self._getItemsByTimes(resultItems, options.times),
hasNext: self._hasNextByTimes(resultItems, options.times)
});
}
},

7
src/component/allvaluechooser/pane.allvaluechooser.js

@ -50,10 +50,11 @@ BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
getValue: function () {
var val = this.list.getValue() || {};
if (val.type === BI.Selection.All) {
return val.assist;
if (val.type === BI.Selection.Multi) {
return val.value || [];
}
return val.value || [];
return BI.difference(BI.map(this.items, "value"), val.value || []);
},
populate: function (items) {

2
src/component/form/form.field.js

@ -9,6 +9,7 @@
baseCls: "bi-form-field",
label: "",
el: {},
headerCls: "",
labelAlign: "right", // 文字默认右对齐
validate: function () {
return true;
@ -69,6 +70,7 @@
textAlign: o.labelAlign,
text: o.label,
width: o.labelWidth,
cls: o.headerCls,
rgap: 20 // 表单文字与右侧输入间距均为20px
}
}, field] : [field]

4
src/component/form/form.js

@ -18,7 +18,8 @@
label: "",
el: {}
}],
labelWidth: ""
labelWidth: "",
headerCls: "", // 左侧文字样式
},
render: function () {
@ -44,6 +45,7 @@
height: item.el.height || 28,
labelAlign: o.labelAlign,
labelWidth: o.labelWidth,
headerCls: o.headerCls,
el: item.el,
label: item.label,
tip: item.tip,

4
src/core/1.lodash.js

@ -10253,7 +10253,7 @@
// loaded by a script tag in the presence of an AMD loader.
// See http://requirejs.org/docs/errors.html#mismatch for more details.
// Use `_.noConflict` to remove Lodash from the global object.
root._ = lodash;
BI._ = lodash;
// Define as an anonymous module so, through path mapping, it can be
// referenced as the "underscore" module.
@ -10270,6 +10270,6 @@
}
else {
// Export to the global object.
root._ = lodash;
BI._ = lodash;
}
}.call(this));

76
src/core/2.base.js

@ -11,19 +11,19 @@
};
var _apply = function (name) {
return function () {
return _[name].apply(_, arguments);
return BI._[name].apply(BI._, arguments);
};
};
var _applyFunc = function (name) {
return function () {
var args = Array.prototype.slice.call(arguments, 0);
args[1] = _.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1];
return _[name].apply(_, args);
args[1] = BI._.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1];
return BI._[name].apply(BI._, args);
};
};
// Utility
_.extend(BI, {
BI._.extend(BI, {
assert: function (v, is) {
if (this.isFunction(is)) {
if (!is(v)) {
@ -146,10 +146,10 @@
});
// 集合相关方法
_.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
BI._.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
BI[name] = _apply(name);
});
_.each(["get", "set", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
BI._.each(["get", "set", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition", "clamp"], function (name) {
if (name === "any") {
BI[name] = _applyFunc("some");
@ -157,7 +157,7 @@
BI[name] = _applyFunc(name);
}
});
_.extend(BI, {
BI._.extend(BI, {
// 数数
count: function (from, to, predicate) {
var t;
@ -217,10 +217,10 @@
}).join("");
}
if (BI.isArray(obj1)) {
return _.concat.apply([], arguments);
return BI._.concat.apply([], arguments);
}
if (BI.isObject(obj1)) {
return _.extend.apply({}, arguments);
return BI._.extend.apply({}, arguments);
}
},
@ -254,7 +254,7 @@
backFindKey: function (obj, predicate, context) {
predicate = BI.iteratee(predicate, context);
var keys = _.keys(obj), key;
var keys = BI._.keys(obj), key;
for (var i = keys.length - 1; i >= 0; i--) {
key = keys[i];
if (predicate(obj[key], key, obj)) {
@ -347,14 +347,14 @@
});
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
BI._.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
BI._.each(["findIndex", "findLastIndex"], function (name) {
BI[name] = _applyFunc(name);
});
_.extend(BI, {
BI._.extend(BI, {
// 构建一个长度为length的数组
makeArray: function (length, value) {
var res = [];
@ -401,27 +401,27 @@
if (array == null) {
return [];
}
if (!_.isBoolean(isSorted)) {
if (!BI._.isBoolean(isSorted)) {
context = iteratee;
iteratee = isSorted;
isSorted = false;
}
iteratee && (iteratee = traverse(iteratee, context));
return _.uniq.call(_, array, isSorted, iteratee, context);
return BI._.uniq.call(BI._, array, isSorted, iteratee, context);
}
});
// 对象相关方法
_.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn",
BI._.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn",
"defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty",
"isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite",
"isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep"], function (name) {
BI[name] = _apply(name);
});
_.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) {
BI._.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) {
BI[name] = _applyFunc(name);
});
_.extend(BI, {
BI._.extend(BI, {
inherit: function (sp, overrides) {
var sb = function () {
@ -432,7 +432,7 @@
F.prototype = spp;
sb.prototype = new F();
sb.superclass = spp;
_.extend(sb.prototype, overrides, {
BI._.extend(sb.prototype, overrides, {
superclass: sp
});
return sb;
@ -455,10 +455,10 @@
return false;
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
return BI._.has(obj, key);
});
}
return _.has.apply(_, arguments);
return BI._.has.apply(BI._, arguments);
},
freeze: function (value) {
@ -524,13 +524,17 @@
isWindow: function (obj) {
return obj != null && obj == obj.window;
},
isPromise: function(obj) {
return !!obj && (BI.isObject(obj) || BI.isFunction(obj)) && BI.isFunction(obj.then);
}
});
// deep方法
_.extend(BI, {
deepClone: _.cloneDeep,
deepExtend: _.merge,
BI._.extend(BI, {
deepClone: BI._.cloneDeep,
deepExtend: BI._.merge,
isDeepMatch: function (object, attrs) {
var keys = BI.keys(attrs), length = keys.length;
@ -548,8 +552,8 @@
},
contains: function (obj, target, fromIndex) {
if (!_.isArrayLike(obj)) obj = _.values(obj);
return _.indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0;
if (!BI._.isArrayLike(obj)) obj = BI._.values(obj);
return BI._.indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0;
},
deepContains: function (obj, copy) {
@ -647,20 +651,20 @@
});
// 通用方法
_.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape", "before", "after"], function (name) {
BI._.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape", "before", "after"], function (name) {
BI[name] = function () {
return _[name].apply(_, arguments);
return BI._[name].apply(BI._, arguments);
};
});
// 事件相关方法
_.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) {
BI._.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) {
BI[name] = function () {
return _[name].apply(_, arguments);
return BI._[name].apply(BI._, arguments);
};
});
_.extend(BI, {
BI._.extend(BI, {
nextTick: (function () {
var callbacks = [];
var pending = false;
@ -731,10 +735,10 @@
});
// 数字相关方法
_.each(["random"], function (name) {
BI._.each(["random"], function (name) {
BI[name] = _apply(name);
});
_.extend(BI, {
BI._.extend(BI, {
parseInt: function (number) {
var radix = 10;
@ -837,9 +841,9 @@
});
// 字符串相关方法
_.extend(BI, {
BI._.extend(BI, {
trim: function () {
return _.trim.apply(_, arguments);
return BI._.trim.apply(BI._, arguments);
},
toUpperCase: function (string) {
@ -965,7 +969,7 @@
});
// 日期相关方法
_.extend(BI, {
BI._.extend(BI, {
/**
* 是否是闰年
* @param year

22
src/core/3.ob.js

@ -1,5 +1,5 @@
!(function () {
function extend () {
function extend() {
var target = arguments[0] || {}, length = arguments.length, i = 1, options, name, src, copy;
for (; i < length; i++) {
// Only deal with non-null/undefined values
@ -31,7 +31,7 @@
var OB = function (config) {
this._constructor(config);
};
_.extend(OB.prototype, {
BI._.extend(OB.prototype, {
props: {},
init: null,
destroyed: null,
@ -66,12 +66,12 @@
_initListeners: function () {
var self = this;
if (this.options.listeners != null) {
_.each(this.options.listeners, function (lis, eventName) {
if (_.isFunction(lis)) {
BI._.each(this.options.listeners, function (lis, eventName) {
if (BI._.isFunction(lis)) {
self.on(eventName, lis);
return;
}
(lis.target ? lis.target : self)[lis.once ? "once" : "on"](lis.eventName, _.bind(lis.action, self));
(lis.target ? lis.target : self)[lis.once ? "once" : "on"](lis.eventName, BI._.bind(lis.action, self));
});
delete this.options.listeners;
}
@ -90,17 +90,17 @@
//释放当前对象
_purgeRef: function () {
if (this.options.__ref) {
this.options.__ref.call(null);
this.options.__ref.call(null, null);
this.options.__ref = null;
}
if (this.options.ref) {
this.options.ref.call(null);
this.options.ref.call(null, null);
this.options.ref = null;
}
},
_getEvents: function () {
if (!_.isObject(this.events)) {
if (!BI._.isObject(this.events)) {
this.events = {};
}
return this.events;
@ -115,7 +115,7 @@
var self = this;
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName];
if (!_.isArray(fns)) {
if (!BI._.isArray(fns)) {
fns = [];
this._getEvents()[eventName] = fns;
}
@ -151,9 +151,9 @@
delete this._getEvents()[eventName];
} else {
var fns = this._getEvents()[eventName];
if (_.isArray(fns)) {
if (BI._.isArray(fns)) {
var newFns = [];
_.each(fns, function (ifn) {
BI._.each(fns, function (ifn) {
if (ifn != fn) {
newFns.push(ifn);
}

26
src/core/4.widget.js

@ -17,7 +17,7 @@
var requestAnimationFrame = _global.requestAnimationFrame || _global.webkitRequestAnimationFrame || _global.mozRequestAnimationFrame || _global.oRequestAnimationFrame || _global.msRequestAnimationFrame || _global.setTimeout;
function callLifeHook (self, life) {
function callLifeHook(self, life) {
var hooks = [], hook;
hook = self[life];
if (hook) {
@ -124,7 +124,7 @@
var initCallbackCalled = false;
var renderCallbackCalled = false;
function init () {
function init() {
// 加个保险
if (initCallbackCalled === true) {
_global.console && console.error("组件: 请检查beforeInit内部的写法,callback只能执行一次");
@ -132,7 +132,7 @@
}
initCallbackCalled = true;
function render () {
function render() {
// 加个保险
if (renderCallbackCalled === true) {
_global.console && console.error("组件: 请检查beforeRender内部的写法,callback只能执行一次");
@ -246,8 +246,8 @@
return getter.call(self, self);
}, (handler && function (v) {
handler.call(self, self, v);
}) || BI.emptyFn, BI.extend({deep: true}, options));
this._watchers.push(function unwatchFn () {
}) || BI.emptyFn, BI.extend({ deep: true }, options));
this._watchers.push(function unwatchFn() {
watcher.teardown();
});
return watcher.value;
@ -346,6 +346,7 @@
_initState: function () {
this._isMounted = false;
this._isDestroyed = false;
},
__initWatch: function () {
@ -449,6 +450,10 @@
return this._isMounted;
},
isDestroyed: function () {
return this._isDestroyed;
},
setWidth: function (w) {
this.options.width = w;
this._initElementWidth();
@ -681,11 +686,11 @@
},
isEnabled: function () {
return this.options.disabled === true ? false: !this.options._disabled;
return this.options.disabled === true ? false : !this.options._disabled;
},
isValid: function () {
return this.options.invalid === true ? false: !this.options._invalid;
return this.options.invalid === true ? false : !this.options._invalid;
},
isVisible: function () {
@ -732,6 +737,9 @@
this._isMounted = false;
callLifeHook(this, "destroyed");
this.destroyed = null;
this._isDestroyed = true;
// this._purgeRef(); // 清除ref的时机还是要仔细考虑一下
},
_unMount: function () {
@ -825,12 +833,12 @@
BI.Widget.context = context = contextStack.pop();
};
function pushTarget (_current) {
function pushTarget(_current) {
if (current) currentStack.push(current);
BI.Widget.current = current = _current;
}
function popTarget () {
function popTarget() {
BI.Widget.current = current = currentStack.pop();
}

75
src/core/5.inject.js

@ -10,27 +10,29 @@
BI.module = BI.module || function (xtype, cls) {
if (moduleInjection[xtype] != null) {
_global.console && console.error("module: [" + xtype + "] 已经注册过了");
}
if (BI.isFunction(cls)) {
cls = cls();
}
for (var k in moduleInjectionMap) {
if (cls[k]) {
for (var key in cls[k]) {
if (!moduleInjectionMap[k]) {
continue;
}
if (!moduleInjectionMap[k][key]) {
moduleInjectionMap[k][key] = [];
} else {
if (BI.isFunction(cls)) {
cls = cls();
}
for (var k in moduleInjectionMap) {
if (cls[k]) {
for (var key in cls[k]) {
if (!moduleInjectionMap[k]) {
continue;
}
if (!moduleInjectionMap[k][key]) {
moduleInjectionMap[k][key] = [];
}
moduleInjectionMap[k][key].push({
version: cls[k][key],
moduleId: xtype
});
}
moduleInjectionMap[k][key].push({
version: cls[k][key],
moduleId: xtype
});
}
}
moduleInjection[xtype] = cls;
}
moduleInjection[xtype] = cls;
return function () {
return BI.Modules.getModule(xtype);
};
@ -40,8 +42,10 @@
BI.constant = BI.constant || function (xtype, cls) {
if (constantInjection[xtype] != null) {
_global.console && console.error("constant: [" + xtype + "]已经注册过了");
} else {
constantInjection[xtype] = cls;
}
constantInjection[xtype] = cls;
return function () {
return BI.Constants.getConstant(xtype);
};
@ -51,8 +55,10 @@
BI.model = BI.model || function (xtype, cls) {
if (modelInjection[xtype] != null) {
_global.console && console.error("model: [" + xtype + "] 已经注册过了");
} else {
modelInjection[xtype] = cls;
}
modelInjection[xtype] = cls;
return function (config) {
return BI.Models.getModel(xtype, config);
};
@ -62,8 +68,10 @@
BI.store = BI.store || function (xtype, cls) {
if (storeInjection[xtype] != null) {
_global.console && console.error("store: [" + xtype + "] 已经注册过了");
} else {
storeInjection[xtype] = cls;
}
storeInjection[xtype] = cls;
return function (config) {
return BI.Stores.getStore(xtype, config);
};
@ -74,7 +82,9 @@
if (serviceInjection[xtype] != null) {
_global.console && console.error("service: [" + xtype + "] 已经注册过了");
}
serviceInjection[xtype] = cls;
return function (config) {
return BI.Services.getService(xtype, config);
};
@ -84,20 +94,33 @@
BI.provider = BI.provider || function (xtype, cls) {
if (providerInjection[xtype] != null) {
_global.console && console.error("provider: [" + xtype + "] 已经注册过了");
} else {
providerInjection[xtype] = cls;
}
providerInjection[xtype] = cls;
return function (config) {
return BI.Providers.getProvider(xtype, config);
};
};
var configFunctions = BI.OB.configFunctions = {};
var runConfigFunction = function (type) {
var runConfigFunction = function (type, configFn) {
if (!type || !configFunctions[type]) {
return false;
}
var queue = configFunctions[type];
delete configFunctions[type];
var queue = [];
if (configFn) {
queue = configFunctions[type].filter(function (conf) {
return conf.fn === configFn;
});
configFunctions[type] = configFunctions[type].filter(function (conf) {
return conf.fn !== configFn;
});
} else {
queue = configFunctions[type];
delete configFunctions[type];
}
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
var modules = moduleInjectionMap.components[type]
@ -176,6 +199,10 @@
fn: configFn,
opt: opt
});
if (opt.immediately) {
return runConfigFunction(type, configFn);
}
};
BI.getReference = BI.getReference || function (type, fn) {

7
src/core/conflict.js

@ -0,0 +1,7 @@
if (!_global.$ && !_global.jQuery) {
_global.jQuery = _global.$ = BI.jQuery;
}
if (!_global._) {
_global._ = BI._;
}

8
src/core/constant/events.js

@ -2,7 +2,7 @@
* 事件集合
* @class BI.Events
*/
_.extend(BI, {
BI._.extend(BI, {
Events: {
/**
@ -143,6 +143,12 @@ _.extend(BI, {
*/
COLLAPSE: "_COLLAPSE",
/**
* @static
* @property 下拉菜单切换展开收起事件
*/
TOGGLE: "_TOGGLE",
/**
* @static
* @property 回调事件

2
src/core/constant/var.js

@ -2,7 +2,7 @@
* 常量
*/
_.extend(BI, {
BI._.extend(BI, {
MAX: 0xfffffffffffffff,
MIN: -0xfffffffffffffff,
EVENT_RESPONSE_TIME: 200,

23
src/core/controller/controller.tooltips.js

@ -12,17 +12,25 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
this.showingTips = {};// 存储正在显示的tooltip
},
_createTooltip: function (text, level) {
/**
*
* @param opt
* @param opt.text {String} 文本
* @param opt.level {String} 级别, success或warning
* @param opt.textAlign {String} 文本对齐方式, left, center, right
* @returns {*}
* @private
*/
_createTooltip: function (opt) {
return BI.createWidget({
type: "bi.tooltip",
text: text,
level: level,
...opt,
stopEvent: true
});
},
// opt: {container: '', belowMouse: false}
show: function (e, name, text, level, context, opt) {
show: function (e, name, tooltipOpt, context, opt) {
opt || (opt = {});
var self = this;
BI.each(this.showingTips, function (i, tip) {
@ -30,7 +38,7 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
});
this.showingTips = {};
if (!this.has(name)) {
this.create(name, text, level, opt.container || "body");
this.create(name, tooltipOpt, opt.container || "body");
}
if (!opt.belowMouse) {
var offset = context.element.offset();
@ -41,7 +49,6 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
var top = offset.top + bounds.height + 5;
}
var tooltip = this.get(name);
tooltip.setText(text);
tooltip.element.css({
left: "0px",
top: "0px"
@ -84,9 +91,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
return this;
},
create: function (name, text, level, context) {
create: function (name, tooltipOpt, context) {
if (!this.has(name)) {
var tooltip = this._createTooltip(text, level);
var tooltip = this._createTooltip(tooltipOpt);
this.add(name, tooltip);
BI.createWidget({
type: "bi.absolute",

74
src/core/element/element.js

@ -0,0 +1,74 @@
import { registFunction } from './plugins';
export function Element(widget, attribs) {
this.l = this.r = this.t = this.b = 0; // 边框
this.marginLeft = this.marginRight = this.marginTop = this.marginBottom = 0; //间距
this.position = {};
this.classMap = {};
this.classList = [];
this.children = [];
this.attribs = attribs || {};
this.styles = {};
// 兼容处理
this['0'] = this;
this.style = {};
if (!widget) {
this.nodeName = 'body';
this.position.x = 0;
this.position.y = 0;
this.attribs.id = 'body';
} else if (BI.isWidget(widget)) {
this.widget = widget;
this.nodeName = widget.options.tagName;
this.textBaseLine = widget.options.textBaseLine;
} else if (BI.isString(widget)) {
this.nodeName = widget;
}
}
initElement(Element);
registFunction(Element);
function initElement(element) {
element.prototype = {
appendChild(child) {
child.parent = this;
if (this.children.push(child) !== 1) {
var sibling = this.children[this.children.length - 2];
sibling.next = child;
child.prev = sibling;
child.next = null;
}
},
append(child) {
child.parent = this;
if (this.children.push(child) !== 1) {
var sibling = this.children[this.children.length - 2];
sibling.next = child;
child.prev = sibling;
child.next = null;
}
},
getParent() {
return this.parent;
},
getSiblings() {
var parent = this.getParent();
return parent ? parent.getChildren() : [this];
},
getChildren() {
return this.children;
},
getBounds() {
return {};
},
width() {
},
height() {
}
};
}

31
src/core/element/index.js

@ -0,0 +1,31 @@
import { Element } from './element';
BI.Element = Element;
BI.Element.renderEngine = {
createElement: (widget) => {
// eslint-disable-next-line no-undef
if (BI.isWidget(widget)) {
var o = widget.options;
if (o.element instanceof Element) {
return o.element;
}
if (typeof o.element === 'string' && o.element !== 'body') {
o.root = false;
return new Element(widget);
}
if (o.root === true) {
return new Element();
}
}
// eslint-disable-next-line no-undef
if (BI.isString(widget)) {
return new Element(widget);
}
return new Element(widget);
},
createFragment() {
return new Element();
}
}

22
src/core/element/plugins/attr.js

@ -0,0 +1,22 @@
export const registAttrFun = (Element) => {
Element.registerFunction('attr', function (key, value) {
var self = this;
if (BI.isObject(key)) {
BI.each(key, (k, v) => {
self.attr(k, v);
});
return this;
}
if (BI.isNull(value)) {
return this.attribs[key];
}
this.attribs[key] = value;
return this;
});
Element.registerFunction('hasAttrib', function (key) {
return this.attribs[key] != null;
});
Element.registerFunction('removeAttr', function (key) {
delete this.attribs[key];
});
};

23
src/core/element/plugins/class.js

@ -0,0 +1,23 @@
export const registClassFun = (Element) => {
Element.registerFunction('addClass', function (classList) {
var self = this;
BI.each(classList.split(' '), (i, cls) => {
if (cls && !self.classMap[cls]) {
self.classList.push(cls);
}
cls && (self.classMap[cls] = true);
});
return this;
});
Element.registerFunction('removeClass', function (classList) {
var self = this;
BI.each(classList.split(' '), (i, cls) => {
if (cls && self.classMap[cls]) {
delete self.classMap[cls];
self.classList.splice(self.classList.indexOf(cls), 1);
}
});
return this;
});
};

22
src/core/element/plugins/css.js

@ -0,0 +1,22 @@
export const registCssFun = (Element) => {
Element.registerFunction('css', function (key, value) {
var self = this;
if (BI.isObject(key)) {
BI.each(key, (k, v) => {
self.css(k, v);
});
return this;
}
key = BI.trim(BI.camelize(key));
return css(this, key, value);
});
};
const css = (elem, key, value) => {
key = BI.trim(BI.camelize(key));
if (BI.isNull(value)) {
return elem.styles[key];
}
elem.styles[key] = value;
return elem;
};

12
src/core/element/plugins/data.js

@ -0,0 +1,12 @@
export const registDataFun = (Element) => {
Element.registerFunction('data', function (key, value) {
if (!this._data) {
this._data = {};
}
if (BI.isNull(value)) {
return this._data[key];
}
this._data[key] = value;
return this;
});
};

9
src/core/element/plugins/empty.js

@ -0,0 +1,9 @@
export const registEmptyFun = (Element) => {
Element.registerFunction('empty', function (text) {
this.children = [];
return this;
});
Element.registerFunction('destroy', function (text) {
return this;
});
};

32
src/core/element/plugins/event.js

@ -0,0 +1,32 @@
var returnThis = function () {
return this;
};
export const registEventFun = (Element) => {
[
'mousedown',
'mouseup',
'mousewheel',
'keydown',
'keyup',
'focus',
'focusin',
'focusout',
'click',
'on',
'off',
'bind',
'unbind',
'trigger',
'hover',
'scroll',
'scrollLeft',
'scrollTop',
'resize',
'show',
'hide',
'dblclick',
'blur',
].forEach((event) => {
Element.registerFunction(event, returnThis);
});
};

15
src/core/element/plugins/html.js

@ -0,0 +1,15 @@
export const registHtmlFun = (Element) => {
Element.registerFunction('html', function (text) {
if (text && text.charAt(0) === '<') {
BI.createWidget({
type: 'bi.html',
element: this.widget,
html: text,
});
this.originalHtml = text;
} else {
this.text = BI.htmlDecode(text);
}
return this;
});
};

31
src/core/element/plugins/index.js

@ -0,0 +1,31 @@
import { registAttrFun } from './attr';
import { registClassFun } from './class';
import { registCssFun } from './css';
import { registDataFun } from './data';
import { registEmptyFun } from './empty';
import { registEventFun } from './event';
import { registHtmlFun } from './html';
import { registKeywordMarkFun } from './keywordMark';
import { registRenderToHtmlFun } from './renderToHtml';
import { registRenderToStringFun } from './renderToString';
import { registTextFun } from './text';
import { registValFun } from './val';
export const registFunction = (Element) => {
var functionMap = {};
Element.registerFunction = (key, fn) => {
Element.prototype[key] = functionMap[key] = fn;
};
registAttrFun(Element);
registClassFun(Element);
registCssFun(Element);
registDataFun(Element);
registEmptyFun(Element);
registEventFun(Element);
registHtmlFun(Element);
registKeywordMarkFun(Element);
registRenderToStringFun(Element);
registRenderToHtmlFun(Element);
registTextFun(Element);
registValFun(Element);
};

6
src/core/element/plugins/keywordMark.js

@ -0,0 +1,6 @@
export const registKeywordMarkFun = (Element) => {
Element.registerFunction('__textKeywordMarked__', function (text) {
this[0].textContent = text;
return this;
});
};

65
src/core/element/plugins/renderToHtml.js

@ -0,0 +1,65 @@
var skipArray = [];
var pxStyle = ['font-size', 'width', 'height'];
var _renderToHtml = function (root) {
var str = '';
if (BI.isNull(root.originalHtml)) {
if (root.tag !== 'body') {
str += `<${root.tag}`;
if (root.classList.length > 0) {
str += ' class="';
BI.each(root.classList, (i, cls) => {
str += ` ${cls}`;
});
str += '"';
}
str += ' style="';
BI.each(root.originalStyles, (key, stl) => {
if (
skipArray.contains(key) ||
(key == 'height' && root.classList.contains('bi-design-components-data-data-table-cell'))
) {
return;
}
key = BI.hyphenate(key);
if (key === 'font-family') {
stl = stl.replace(/\"/g, '');
}
if (pxStyle.contains(key) && BI.isNumeric(stl)) {
stl += 'px';
}
if (BI.isKey(stl)) {
str += ` ${key}:${stl};`;
}
});
str += '"';
BI.each(root.attribs, (key, attr) => {
if (BI.isKey(attr)) {
str += ` ${key}=${attr}`;
}
});
if (root.textContent) {
str += ` title=${root.textContent}`;
}
str += '>';
}
// 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了
// 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样
BI.each(root.children, (i, child) => {
str += _renderToHtml(child);
});
} else {
str += root.originalHtml;
}
if (root.tag !== 'body') {
if (root.textContent) {
str += root.textContent;
}
str += `</${root.tag}>`;
}
return str;
};
export const registRenderToHtmlFun = (Element) => {
Element.registerFunction('renderToHtml', function () {
return _renderToHtml(this);
});
};

50
src/core/element/plugins/renderToString.js

@ -0,0 +1,50 @@
var skipArray = ['width', 'height'];
var _renderToString = function (root) {
var str = '';
if (root.nodeName !== 'body') {
str += `<${root.nodeName}`;
if (root.classList.length > 0) {
str += ' class="';
BI.each(root.classList, (i, cls) => {
str += ` ${cls}`;
});
str += '"';
}
str += ' style="';
BI.each(root.styles, (key, stl) => {
if (skipArray.includes(key)) {
return;
}
key = BI.hyphenate(key);
str += ` ${key}:${stl};`;
});
str += ` width:${root.width}px;`;
str += ` height:${root.height}px;`;
str += ' position: fixed;';
str += ` left: ${root.position.x}px;`;
str += ` top: ${root.position.y}px;`;
str += '"';
BI.each(root.attribs, (key, attr) => {
str += ` ${key}:${attr}`;
});
str += '>';
}
BI.each(root.children, (i, child) => {
str += _renderToString(child);
});
// if (root.htmlContent) {
// str += root.htmlContent;
// }
if (root.nodeName !== 'body') {
if (root.text) {
str += root.text;
}
str += `</${root.nodeName}>`;
}
return str;
};
export const registRenderToStringFun = (Element) => {
Element.registerFunction('renderToString', function () {
return _renderToString(this);
});
};

10
src/core/element/plugins/text.js

@ -0,0 +1,10 @@
export const registTextFun = (Element) => {
Element.registerFunction('setText', function (text) {
this.text = text;
return this;
});
Element.registerFunction('setValue', function (text) {
this.text = text;
return this;
});
};

9
src/core/element/plugins/val.js

@ -0,0 +1,9 @@
export const registValFun = (Element) => {
Element.registerFunction('val', function (value) {
if (BI.isNotNull(value)) {
this.text = `${value}`;
return this;
}
return this.text;
});
};

4
src/core/func/alias.js

@ -450,7 +450,7 @@
BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) {
var result = {};
_.each(o, function (v, k) {
BI._.each(o, function (v, k) {
if (!(typeof v === "string")) {
v = BI.jsonEncode(v);
}
@ -603,7 +603,7 @@
return new Date(o.__time__);
}
for (var a in o) {
if (o[a] == o || typeof o[a] === "object" || _.isFunction(o[a])) {
if (o[a] == o || typeof o[a] === "object" || BI._.isFunction(o[a])) {
break;
}
o[a] = arguments.callee(o[a]);

2
src/core/func/array.js

@ -2,7 +2,7 @@
* 对数组对象的扩展
* @class Array
*/
_.extend(BI, {
BI._.extend(BI, {
pushArray: function (sArray, array) {
for (var i = 0; i < array.length; i++) {

2
src/core/func/date.js

@ -6,7 +6,7 @@ BI.Date.HOUR = 60 * BI.Date.MINUTE;
BI.Date.DAY = 24 * BI.Date.HOUR;
BI.Date.WEEK = 7 * BI.Date.DAY;
_.extend(BI, {
BI._.extend(BI, {
/**
* 获取时区
* @returns {String}

4
src/core/func/function.js

@ -3,7 +3,7 @@
* Created by GUY on 2015/6/24.
*/
BI.Func = BI.Func || {};
_.extend(BI.Func, {
BI._.extend(BI.Func, {
/**
* 创建唯一的名字
* @param array
@ -143,7 +143,7 @@ _.extend(BI.Func, {
}
});
_.extend(BI, {
BI._.extend(BI, {
beforeFunc: function (sFunc, func) {
var __self = sFunc;
return function () {

2
src/core/func/number.js

@ -1,4 +1,4 @@
_.extend(BI, {
BI._.extend(BI, {
// 给Number类型增加一个add方法,调用起来更加方便。
add: function (num, arg) {
return accAdd(arg, num);

4
src/core/func/string.js

@ -2,7 +2,7 @@
* 对字符串对象的扩展
* @class String
*/
_.extend(BI, {
BI._.extend(BI, {
/**
* 判断字符串是否已指定的字符串开始
@ -65,7 +65,7 @@ _.extend(BI, {
} else {
src += "&";
}
_.each(paras, function (value, name) {
BI._.each(paras, function (value, name) {
if (typeof(name) === "string") {
src += name + "=" + value + "&";
}

4
src/core/platform/web/config.js

@ -210,12 +210,12 @@ BI.prepares.push(function () {
});
BI.Plugin.configWidget("bi.horizontal_sticky", function (ob) {
if (!isSupportSticky) {
return BI.extend({}, ob, {type: "bi.horizontal_fill"});
return BI.extend({ scrollx: true }, ob, {type: "bi.horizontal_fill"});
}
});
BI.Plugin.configWidget("bi.vertical_sticky", function (ob) {
if (!isSupportSticky) {
return BI.extend({}, ob, {type: "bi.vertical_fill"});
return BI.extend({ scrolly: true }, ob, {type: "bi.vertical_fill"});
}
});

2
src/core/platform/web/function.js

@ -1,5 +1,5 @@
// 浏览器相关方法
_.extend(BI, {
BI._.extend(BI, {
isIE: function () {
if(!_global.navigator) {
return false;

4
src/core/platform/web/jquery/_jquery.js vendored

@ -11012,10 +11012,6 @@
// Expose jQuery and $ identifiers, even in
// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566)
if (!window.$ && !window.jQuery) {
window.jQuery = window.$ = jQuery;
}
BI.jQuery = BI.$ = jQuery;
return jQuery;

2
src/core/platform/web/load.js

@ -1,4 +1,4 @@
_.extend(BI, {
BI._.extend(BI, {
$import: function () {
var _LOADED = {}; // alex:保存加载过的
function loadReady (src, must) {

4
src/core/plugin.js

@ -36,8 +36,8 @@ BI.Plugin = BI.Plugin || {};
},
config: function (widgetConfigFn, objectConfigFn) {
_GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(_.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]);
__GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(_.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]);
_GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(BI._.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]);
__GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(BI._.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]);
},
configWidget: function (type, fn, opt) {

2
src/core/structure/aes.js

@ -2308,7 +2308,7 @@
}());
_.extend(BI, {
BI._.extend(BI, {
/**
* aes加密方法
* aes-128-ecb

2
src/core/structure/base64.js

@ -57,7 +57,7 @@
return string;
};
_.extend(BI, {
BI._.extend(BI, {
encode: function (input) {
var output = "";

51
src/core/system.js

@ -19,6 +19,40 @@
TOAST_TOP: 10,
H_GAP_SIZE: "M",
V_GAP_SIZE: "S"
},
loadingCreator: function(config) {
var loadingSize = (config ? config.loadingSize : "small") || "small";
var isIE = BI.isIE();
function getSize(v) {
return Math.ceil(v / (loadingSize === "small" ? 2 : 1));
}
return {
type: "bi.horizontal",
cls: "bi-loading-widget" + (isIE ? " wave-loading hack" : ""),
height: getSize(60),
width: getSize(60),
hgap: getSize(10),
vgap: 2.5,
items: isIE ? [] : [{
type: "bi.layout",
cls: "animate-rect rect1",
height: getSize(50),
width: getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect2",
height: getSize(50),
width: getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect3",
height: getSize(50),
width: getSize(5)
}]
};
}
};
@ -29,12 +63,11 @@
"L": 24
};
var provider = function () {
function provider () {
this.SYSTEM = system;
this.setSize = function (opt) {
BI.deepExtend(system, {size: opt});
BI.deepExtend(system, { size: opt });
};
this.setResponsiveMode = function (mode) {
@ -60,6 +93,10 @@
BI.extend(system.dependencies, moduleConfig);
};
this.setLoadingCreator = function(creator) {
system.loadingCreator = creator;
};
this.$get = function () {
return BI.inherit(BI.OB, {
@ -88,13 +125,17 @@
getDependencies: function () {
return system.dependencies;
},
getLoading: function(config) {
return system.loadingCreator(config);
}
});
};
};
}
BI.provider("bi.provider.system", provider);
})();
}());
BI.prepares.push(function () {
BI.SIZE_CONSANTS = BI.Providers.getProvider("bi.provider.system").getSize();

2
src/core/utils/chinesePY.js

@ -422,7 +422,7 @@
return arrRslt.join(splitChar || "").toLowerCase();
};
_.extend(BI, {
BI._.extend(BI, {
makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;}

2
src/core/utils/i18n.js

@ -1,6 +1,6 @@
!(function () {
var i18nStore = {};
_.extend(BI, {
BI._.extend(BI, {
changeI18n: function (i18n) {
if (i18n) {
i18nStore = i18n;

6
src/core/wrapper/layout.js

@ -224,14 +224,14 @@ BI.Layout = BI.inherit(BI.Widget, {
}
}
} else {
var keys = _.keys(a), key;
var keys = BI._.keys(a), key;
length = keys.length;
if (_.keys(b).length !== length) {
if (BI._.keys(b).length !== length) {
return false;
}
while (length--) {
key = keys[length];
if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) {
if (!(BI._.has(b, key) && eq(a[key], b[key], aStack, bStack))) {
return false;
}
}

3
src/less/base/single/button/button.less

@ -467,6 +467,9 @@ body .bi-button, #body .bi-button {
& .popup-content{
font-size: @font-size-14;
}
.bi-button-mask {
pointer-events: none;
}
}
.bi-theme-dark {

33
src/less/base/tree/ztree.less

@ -17,7 +17,7 @@
line-height: 14px;
text-align: left;
white-space: pre;
outline: 0
outline: 0;
}
.ztree li ul {
@ -35,6 +35,7 @@
// 使用1倍图太模糊,这边就使用css自己画了,calc属性支持IE9, IE8反正会走hack, 不影响
.ztree li ul.line {
position: relative;
&:before {
position: absolute;
content: '';
@ -60,6 +61,7 @@
border-left: 1px dashed @border-color-dark-gray-line;
}
}
.ztree.solid li ul.line {
&:before {
border-left: 1px solid @border-color-dark-gray-line-theme-dark;
@ -68,19 +70,21 @@
}
.ztree li a {
padding: 1px 3px 0 0;
padding: 0 3px 0 0;
margin: 0;
cursor: pointer;
height: 23px;
height: 24px;
background-color: transparent;
text-decoration: none;
vertical-align: top;
display: inline-block;
.tree-node-text {
&:not(.disabled) {
&:hover {
.background-color(@color-bi-background-highlight, 10%);
}
&:active {
color: @color-bi-text-highlight;
.background-color(@color-bi-background-highlight, 15%);
@ -90,7 +94,7 @@
}
.ztree.solid li a {
height: 31px;
height: 32px;
}
.ztree li a.curSelectedNode {
@ -144,11 +148,24 @@
line-height: 32px;
}
.ztree li span.icon {
display: inline-block;
vertical-align: top;
text-align: center;
width: 24px;
height: 24px;
line-height: 24px;
}
.ztree li span.icon {
width: 32px;
height: 32px;
line-height: 32px;
}
.ztree li span.button {
line-height: 0;
margin: 0;
width: 16px;
height: 16px;
display: inline-block;
vertical-align: middle;
border: 0 none;
@ -163,18 +180,22 @@
&.bi-checkbox {
border: 1px solid @color-bi-border-dark-line;
box-sizing: border-box;
&.active {
background-color: @color-bi-background-highlight;
border-color: @color-bi-border-highlight;
}
&.disabled {
border: 1px solid @color-bi-border-disabled;
background-color: @color-bi-background-disabled;
&.active {
border-color: @color-bi-border-disabled;
}
}
}
&.bi-half-button {
border: 1px solid @color-bi-border-highlight;
box-sizing: border-box;

2
src/less/image.less

@ -333,7 +333,7 @@
@font-face {
font-family: "@{name}";
src: url('@{fontUrl}iconfont.eot');
src: url('@{fontUrl}iconfont.woff') format('woff'), /* chrome、firefox */ url('@{fontUrl}iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('@{fontUrl}iconfont.svg#svgFontName') format('svg'); /* iOS 4.1- */
src: url('@{fontUrl}iconfont.eot#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('@{fontUrl}iconfont.woff') format('woff'), /* chrome、firefox */ url('@{fontUrl}iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('@{fontUrl}iconfont.svg#svgFontName') format('svg'); /* iOS 4.1- */
}
}

20
src/less/resource/app.less

@ -14,7 +14,6 @@ body {
top: 0;
left: 0;
background-repeat: repeat;
.user-select-disable();
color: @color-bi-text-normal;
font: normal 12px "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Heiti, "黑体", sans-serif;
-webkit-font-smoothing: antialiased;
@ -29,6 +28,7 @@ body {
div, textarea {
scrollbar-color: fade(@scroll-color, 10%) fade(@scroll-color, 5%);
scrollbar-width: thin;
&::-webkit-scrollbar {
-webkit-appearance: none;
width: 10px;
@ -37,10 +37,10 @@ div, textarea {
&::-webkit-scrollbar-track {
.border-radius(5px);
.background-color(@scroll-color, 5%);
.background-color(@scroll-color, 0%);
&:hover {
.background-color(@scroll-color, 5%);
.background-color(@scroll-color, 0%);
}
}
@ -48,10 +48,11 @@ div, textarea {
border: 2px solid transparent;
background-clip: padding-box;
.border-radius(10px);
.background-color(@scroll-color, 10%);
.background-color(@scroll-color, 7%);
&:hover {
.background-color(@scroll-color, 30%);
.background-color(@scroll-color, 19%);
border: 1px solid transparent;
}
}
@ -63,23 +64,24 @@ div, textarea {
.bi-theme-dark {
div, textarea {
scrollbar-color: fade(@scroll-color-theme-dark, 10%) fade(@scroll-color-theme-dark, 5%);
&::-webkit-scrollbar {
-webkit-appearance: none;
}
&::-webkit-scrollbar-track {
.background-color(@scroll-color-theme-dark, 5%);
.background-color(@scroll-color-theme-dark, 0%);
&:hover {
.background-color(@scroll-color-theme-dark, 5%);
.background-color(@scroll-color-theme-dark, 0%);
}
}
&::-webkit-scrollbar-thumb {
.background-color(@scroll-color-theme-dark, 10%);
.background-color(@scroll-color-theme-dark, 7%);
&:hover {
.background-color(@scroll-color-theme-dark, 30%);
.background-color(@scroll-color-theme-dark, 19%);
}
}
}

36
src/less/typographic.less

@ -1,29 +1,30 @@
.x-overflow-auto(){
.x-overflow-auto() {
overflow-y: hidden;
overflow-x: auto;
}
.y-overflow-auto(){
.y-overflow-auto() {
overflow-x: hidden;
overflow-y: auto;
}
.overflow-auto(){
.overflow-auto() {
overflow: auto;
overflow-x: auto;
overflow-y: auto;
}
.overflow-hidden(){
.overflow-hidden() {
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
}
.overflow-dot(){
text-overflow:ellipsis;
.overflow-dot() {
text-overflow: ellipsis;
overflow-x: hidden;
overflow-y: hidden;
white-space:nowrap;
white-space: nowrap;
}
.user-select(@select) {
@ -35,19 +36,10 @@
user-select: @select;
}
.user-select-disable(){
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
.user-select-enable(){
-webkit-user-select: text;
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
-o-user-select: text;
user-select: text;
.user-select-disable() {
.user-select(none);
}
.user-select-enable() {
.user-select(text);
}

32
src/router/0.router.js

@ -16,7 +16,7 @@
once: function (name, callback, context) {
if (!eventsApi(this, "once", name, [callback, context]) || !callback) return this;
var self = this;
var once = _.once(function () {
var once = BI._.once(function () {
self.off(name, once);
callback.apply(this, arguments);
});
@ -37,7 +37,7 @@
return this;
}
var names = name ? [name] : _.keys(this._events);
var names = name ? [name] : BI._.keys(this._events);
for (var i = 0, length = names.length; i < length; i++) {
name = names[i];
@ -103,7 +103,7 @@
// listening to.
listenTo: function (obj, name, callback) {
var listeningTo = this._listeningTo || (this._listeningTo = {});
var id = obj._listenId || (obj._listenId = _.uniqueId("l"));
var id = obj._listenId || (obj._listenId = BI._.uniqueId("l"));
listeningTo[id] = obj;
if (!callback && typeof name === "object") callback = this;
obj.on(name, callback, this);
@ -123,7 +123,7 @@
return this;
}
if (!callback) return this;
var once = _.once(function () {
var once = BI._.once(function () {
this.stopListening(obj, name, once);
callback.apply(this, arguments);
});
@ -142,7 +142,7 @@
for (var id in listeningTo) {
obj = listeningTo[id];
obj.off(name, callback, this);
if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id];
if (remove || BI._.isEmpty(obj._events)) delete this._listeningTo[id];
}
return this;
}
@ -222,7 +222,7 @@
var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
// Set up all inheritable **BI.Router** properties and methods.
_.extend(Router.prototype, Events, {
BI._.extend(Router.prototype, Events, {
// _init is an empty function by default. Override it with your own
// initialization logic.
@ -236,8 +236,8 @@
// });
//
route: function (route, name, callback) {
if (!_.isRegExp(route)) route = this._routeToRegExp(route);
if (_.isFunction(name)) {
if (!BI._.isRegExp(route)) route = this._routeToRegExp(route);
if (BI._.isFunction(name)) {
callback = name;
name = "";
}
@ -271,8 +271,8 @@
// routes can be defined at the bottom of the route map.
_bindRoutes: function () {
if (!this.routes) return;
this.routes = _.result(this, "routes");
var route, routes = _.keys(this.routes);
this.routes = BI._.result(this, "routes");
var route, routes = BI._.keys(this.routes);
while ((route = routes.pop()) != null) {
this.route(route, this.routes[route]);
}
@ -295,7 +295,7 @@
// treated as `null` to normalize cross-browser behavior.
_extractParameters: function (route, fragment) {
var params = route.exec(fragment).slice(1);
return _.map(params, function (param, i) {
return BI._.map(params, function (param, i) {
// Don't decode the search params.
if (i === params.length - 1) return param || null;
var resultParam = null;
@ -322,7 +322,7 @@
// falls back to polling.
var History = function () {
this.handlers = [];
this.checkUrl = _.bind(this.checkUrl, this);
this.checkUrl = BI._.bind(this.checkUrl, this);
// Ensure that `History` can be used outside of the browser.
if (typeof window !== "undefined") {
@ -344,7 +344,7 @@
History.started = false;
// Set up all inheritable **BI.History** properties and methods.
_.extend(History.prototype, Events, {
BI._.extend(History.prototype, Events, {
// The default interval to poll for hash changes, if necessary, is
// twenty times a second.
@ -402,7 +402,7 @@
// Figure out the initial configuration. Do we need an iframe?
// Is pushState desired ... is it available?
this.options = _.extend({root: "/"}, this.options, options);
this.options = BI._.extend({root: "/"}, this.options, options);
this.root = this.options.root;
this._wantsHashChange = this.options.hashChange !== false;
this._hasHashChange = "onhashchange" in window;
@ -511,7 +511,7 @@
// remove a route match in routes
unRoute: function (route) {
var index = _.findIndex(this.handlers, function (handler) {
var index = BI._.findIndex(this.handlers, function (handler) {
return handler.route.test(route);
});
if (index > -1) {
@ -545,7 +545,7 @@
// returns `false`.
loadUrl: function (fragment) {
fragment = this.fragment = this.getFragment(fragment);
return _.some(this.handlers, function (handler) {
return BI._.some(this.handlers, function (handler) {
if (handler.route.test(fragment)) {
handler.callback(fragment);
return true;

2
src/widget/downlist/item.downlistgroup.js

@ -29,6 +29,8 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, {
cls: o.iconCls1,
width: 36,
height: o.height,
iconHeight: o.iconHeight,
iconWidth: 36,
disableSelected: true,
selected: this._digest(o.value)
});

12
src/widget/editor/editor.text.js

@ -28,15 +28,15 @@ BI.TextEditor = BI.inherit(BI.Widget, {
var self = this, o = this.options;
var border = o.simple ? 1 : 2;
if (BI.isNumber(o.height)) {
this.element.css({height: o.height - border});
this.element.css({ height: o.height - border });
}
if (BI.isNumber(o.width)) {
this.element.css({width: o.width - border});
this.element.css({ width: o.width - border });
}
this.editor = BI.createWidget({
type: "bi.editor",
element: this,
simple: o.simple,
height: o.height - border,
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
@ -116,12 +116,6 @@ BI.TextEditor = BI.inherit(BI.Widget, {
this.editor.on(BI.Editor.EVENT_EMPTY, function () {
self.fireEvent(BI.TextEditor.EVENT_EMPTY);
});
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
});
},
setWaterMark: function (v) {

6
src/widget/multilayerselecttree/multilayerselecttree.combo.js

@ -132,6 +132,11 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_STOP,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
@ -243,6 +248,7 @@ BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeCombo.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);

33
src/widget/multilayersingletree/multilayersingletree.combo.js

@ -36,11 +36,6 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig();
},
_shouldWrapper: function () {
var o = this.options;
return !o.allowEdit && o.itemsCreator === BI.emptyFn;
},
_getBaseConfig: function () {
var self = this, o = this.options;
return {
@ -99,7 +94,6 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
container: o.container,
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
self.trigger = _ref;
@ -136,6 +130,11 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_STOP,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
@ -184,13 +183,28 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
tipType: o.tipType,
warningTitle: o.warningTitle,
valueFormatter: o.valueFormatter,
}
},
});
},
_getAsyncConfig: function () {
var config = this._getBaseConfig();
return BI.extend(config, this._getSearchConfig());
var o = this.options, self = this;
var baseConfig = this._getBaseConfig();
return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : {
el: {
type: "bi.single_tree_trigger",
ref: function (_ref) {
self.textTrigger = _ref;
},
text: o.text,
height: o.height,
items: o.items,
value: o.value,
tipType: o.tipType,
warningTitle: o.warningTitle,
valueFormatter: o.valueFormatter,
},
});
},
getSearcher: function () {
@ -243,5 +257,6 @@ BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeCombo.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);

259
src/widget/multiselect/loader.js

@ -0,0 +1,259 @@
/**
* 加载控件
*
* Created by GUY on 2015/8/31.
* @class BI.Loader
* @extends BI.Widget
*/
BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectInnerLoader.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-select-inner-loader",
direction: "top",
isDefaultInit: true, // 是否默认初始化数据
logic: {
dynamic: true,
scrolly: true
},
// 下面是button_group的属性
el: {
type: "bi.button_group",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
behaviors: {
redmark: function () {
return true;
}
},
layouts: [{
type: "bi.vertical"
}]
},
items: [],
itemsCreator: BI.emptyFn,
onLoaded: BI.emptyFn,
// 下面是分页信息
count: false,
prev: false,
next: {},
hasPrev: BI.emptyFn,
hasNext: BI.emptyFn
});
},
_nextLoad: function () {
var self = this, o = this.options;
this.next.setLoading();
if (this.cachItems && this.cachItems.length > 0) {
this.next.setLoaded();
this.addItems(this.cachItems.slice(0, 100));
this.cachItems = this.cachItems.slice(100);
return;
}
o.itemsCreator.apply(this, [{times: ++this.times}, function () {
self.next.setLoaded();
self.addItems.apply(self, arguments);
}]);
},
render: function () {
var self = this, o = this.options;
if (o.itemsCreator === false) {
o.next = false;
}
this.button_group = BI.createWidget(o.el, {
type: "bi.button_group",
chooseType: 0,
items: o.items,
behaviors: {},
layouts: [{
type: "bi.vertical"
}],
value: o.value
});
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.CLICK) {
var node = self.cachGroup.getNodeByValue(value);
if (node) {
node.setSelected(obj.isSelected());
}
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.Loader.EVENT_CHANGE, obj);
}
});
var renderEngine = BI.Widget._renderEngine;
BI.Widget.registerRenderEngine(BI.Element.renderEngine);
this.cachGroup = BI.createWidget(o.el, {
type: "bi.button_group",
root: true,
chooseType: 0,
items: o.items,
behaviors: {},
layouts: [{
type: "bi.vertical"
}],
value: o.value
});
BI.Widget.registerRenderEngine(renderEngine);
if (o.next !== false) {
this.next = BI.createWidget(BI.extend({
type: "bi.loading_bar"
}, o.next));
this.next.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
self._nextLoad();
}
});
}
BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.button_group, this.next]
});
o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () {
o.isDefaultInit && BI.isEmpty(o.items) && this._populate();
}, this));
},
hasNext: function () {
var o = this.options;
if (BI.isNumber(o.count)) {
return this.count < o.count;
}
if (this.cachItems && this.cachItems.length > 0) {
return true;
}
return !!o.hasNext.apply(this, [{
times: this.times,
count: this.count
}]);
},
addItems: function (items) {
this.count += items.length;
if (BI.isObject(this.next)) {
if (this.hasNext()) {
this.options.items = this.options.items.concat(items);
this.next.setLoaded();
} else {
this.next.setEnd();
}
}
var renderEngine = BI.Widget._renderEngine;
BI.Widget.registerRenderEngine(BI.Element.renderEngine);
this.cachGroup.addItems.apply(this.cachGroup, arguments);
BI.Widget.registerRenderEngine(renderEngine);
this.button_group.addItems.apply(this.button_group, arguments);
},
_populate: function (items) {
var self = this, o = this.options;
if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) {
o.itemsCreator.apply(this, [{times: 1}, function (items, keyword) {
if (arguments.length === 0) {
throw new Error("参数不能为空");
}
self.populate.apply(self, arguments);
o.onLoaded();
}]);
return false;
}
this.options.items = (items || []).slice(0, 100);
this.times = 1;
this.count = 0;
this.count += items.length;
if (BI.isObject(this.next)) {
if (this.hasNext()) {
this.next.setLoaded();
} else {
this.next.invisible();
}
}
return true;
},
populate: function (items, keyword) {
if (this._populate.apply(this, arguments)) {
this.cachItems = [];
if (items.length > 100) {
this.cachItems = items.slice(100);
}
var renderEngine = BI.Widget._renderEngine;
BI.Widget.registerRenderEngine(BI.Element.renderEngine);
this.cachGroup.populate.call(this.cachGroup, items, keyword);
BI.Widget.registerRenderEngine(renderEngine);
this.button_group.populate.call(this.button_group, items.slice(0, 100), keyword);
}
},
setNotSelectedValue: function () {
this.button_group.setNotSelectedValue.apply(this.button_group, arguments);
this.cachGroup.setNotSelectedValue.apply(this.cachGroup, arguments);
},
getNotSelectedValue: function () {
return this.cachGroup.getNotSelectedValue();
},
setAllSelected: function (v) {
this.button_group.setAllSelected(v);
this.cachGroup.setAllSelected(v);
},
setValue: function (value) {
var map = BI.makeObject(BI.isArray(value) ? value : [value]);
this.cachGroup.setValueMap.call(this.cachGroup, map);
this.button_group.setValueMap.call(this.button_group, map);
},
getValue: function () {
return this.cachGroup.getValue.apply(this.cachGroup, arguments);
},
getAllButtons: function () {
return this.button_group.getAllButtons();
},
getAllLeaves: function () {
return this.button_group.getAllLeaves();
},
getSelectedButtons: function () {
return this.button_group.getSelectedButtons();
},
getNotSelectedButtons: function () {
return this.button_group.getNotSelectedButtons();
},
getIndexByValue: function (value) {
return this.button_group.getIndexByValue(value);
},
getNodeById: function (id) {
return this.button_group.getNodeById(id);
},
getNodeByValue: function (value) {
return this.button_group.getNodeByValue(value);
},
empty: function () {
this.button_group.empty();
this.cachGroup.empty();
BI.each([this.prev, this.next], function (i, ob) {
ob && ob.setVisible(false);
});
}
});
BI.MultiSelectInnerLoader.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_inner_loader", BI.MultiSelectInnerLoader);

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

Loading…
Cancel
Save