Browse Source

Merge pull request #114009 in DEC/fineui from bugfix/11.0 to release/11.0

* commit '825027ce02ef839e776a0a9e204d51241274c41a': (148 commits)
  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
  auto upgrade version to 2.0.20220715145014
  auto upgrade version to 2.0.20220715144536
  无JIRA 解决一下single嵌套导致的tooltip一闪的问题.
  update ts
  ...
research/test
superman 2 years ago
parent
commit
f483a6350e
  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. 118
      demo/js/base/button/demo.button.js
  9. 20
      demo/js/base/tip/demo.title.js
  10. 71
      demo/js/base/tree/demo.sync_tree.js
  11. 4
      dist/fix/fix.compact.js
  12. 90
      dist/fix/fix.js
  13. 97
      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. 27
      src/base/1.pane.js
  20. 4
      src/base/combination/bubble.js
  21. 7
      src/base/combination/combo.js
  22. 4
      src/base/combination/expander.js
  23. 27
      src/base/combination/group.button.js
  24. 14
      src/base/combination/group.virtual.js
  25. 4
      src/base/combination/switcher.js
  26. 11
      src/base/combination/tab.js
  27. 16
      src/base/list/listview.js
  28. 11
      src/base/list/virtualgrouplist.js
  29. 9
      src/base/list/virtuallist.js
  30. 35
      src/base/single/0.single.js
  31. 4
      src/base/single/button/button.basic.js
  32. 33
      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. 16
      src/case/layer/pane.list.js
  41. 4
      src/case/list/list.select.js
  42. 4
      src/case/ztree/0.treeview.js
  43. 14
      src/case/ztree/1.asynctree.js
  44. 753
      src/case/ztree/jquery.ztree.core-3.5.js
  45. 17
      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. 20
      src/core/3.ob.js
  52. 8
      src/core/4.widget.js
  53. 41
      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. 49
      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. 20
      src/less/resource/app.less
  93. 16
      src/less/typographic.less
  94. 32
      src/router/0.router.js
  95. 8
      src/widget/editor/editor.text.js
  96. 259
      src/widget/multiselect/loader.js
  97. 22
      src/widget/multiselect/multiselect.combo.js
  98. 23
      src/widget/multiselect/multiselect.combo.nobar.js
  99. 25
      src/widget/multiselect/multiselect.loader.js
  100. 10
      src/widget/multiselect/multiselect.trigger.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", "parser": "@typescript-eslint/parser",
"parserOptions": { "parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 6, "ecmaVersion": 6,
"sourceType": "module", "sourceType": "module",
"ecmaFeatures": { "ecmaFeatures": {
@ -26,7 +25,7 @@
}, },
"plugins": ["@typescript-eslint/eslint-plugin"], "plugins": ["@typescript-eslint/eslint-plugin"],
"overrides": [{ "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", "extends": "plugin:@fui/es5",
"rules": { "rules": {
"no-param-reassign": "off", "no-param-reassign": "off",
@ -34,7 +33,10 @@
"comma-dangle": ["error", "never"] // 多行对象字面量中要求拖尾逗号 "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" "extends": "plugin:@fui/typescript"
}] }]
} }

2
.npmignore

@ -38,3 +38,5 @@
!.eslintrc !.eslintrc
!dist/2.0/jsy.min.css !dist/2.0/jsy.min.css
!dist/2.0/bi.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
}
}

118
demo/js/base/button/demo.button.js

@ -4,240 +4,181 @@ Demo.Button = BI.inherit(BI.Widget, {
}, },
render: function () { render: function () {
var items = [{ var items = [{
el: {
type: "bi.button", type: "bi.button",
text: "一般按钮", text: "一般按钮",
level: "common", level: "common",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示成功状态按钮", text: "表示成功状态按钮",
level: "success", level: "success",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示警告状态的按钮", text: "表示警告状态的按钮",
level: "warning", level: "warning",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示错误状态的按钮", text: "表示错误状态的按钮",
level: "error", level: "error",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示忽略状态的按钮", text: "表示忽略状态的按钮",
level: "ignore", level: "ignore",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "普通灰化按钮", text: "普通灰化按钮",
disabled: true, disabled: true,
level: "success", level: "success",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "忽略状态灰化按钮", text: "忽略状态灰化按钮",
disabled: true, disabled: true,
level: "ignore", level: "ignore",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "带图标的按钮", text: "带图标的按钮",
// level: 'ignore', // level: 'ignore',
iconCls: "close-font", iconCls: "close-font",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "一般按钮", text: "一般按钮",
block: true, block: true,
level: "common", level: "common",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示成功状态按钮", text: "表示成功状态按钮",
block: true, block: true,
level: "success", level: "success",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示警告状态的按钮", text: "表示警告状态的按钮",
block: true, block: true,
level: "warning", level: "warning",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示忽略状态的按钮", text: "表示忽略状态的按钮",
block: true, block: true,
level: "ignore", level: "ignore",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "普通灰化按钮", text: "普通灰化按钮",
block: true, block: true,
disabled: true, disabled: true,
level: "success", level: "success",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "忽略状态灰化按钮", text: "忽略状态灰化按钮",
block: true, block: true,
disabled: true, disabled: true,
level: "ignore", level: "ignore",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "带图标的按钮", text: "带图标的按钮",
block: true, block: true,
// level: 'ignore', // level: 'ignore',
iconCls: "close-font", iconCls: "close-font",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "一般按钮", text: "一般按钮",
clear: true, clear: true,
level: "common", level: "common",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示成功状态按钮", text: "表示成功状态按钮",
clear: true, clear: true,
level: "success", level: "success",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示警告状态的按钮", text: "表示警告状态的按钮",
clear: true, clear: true,
level: "warning", level: "warning",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "表示忽略状态的按钮", text: "表示忽略状态的按钮",
clear: true, clear: true,
level: "ignore", level: "ignore",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "普通灰化按钮", text: "普通灰化按钮",
clear: true, clear: true,
disabled: true, disabled: true,
level: "success", level: "success",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "忽略状态灰化按钮", text: "忽略状态灰化按钮",
clear: true, clear: true,
disabled: true, disabled: true,
level: "ignore", level: "ignore",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "带图标的按钮", text: "带图标的按钮",
clear: true, clear: true,
// level: 'ignore', // level: 'ignore',
iconCls: "close-font", iconCls: "close-font",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.text_button", type: "bi.text_button",
text: "文字按钮", text: "文字按钮",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
level: "warning", level: "warning",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
level: "error", level: "error",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
level: "success", level: "success",
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "幽灵按钮(common)灰化", text: "幽灵按钮(common)灰化",
disabled: true, disabled: true,
ghost: true, ghost: true,
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "弹出bubble", text: "弹出bubble",
bubble: function () { bubble: function () {
@ -247,17 +188,13 @@ Demo.Button = BI.inherit(BI.Widget, {
BI.Msg.toast("1111"); BI.Msg.toast("1111");
}, },
height: 30 height: 30
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "图标在上面的按钮,而且可以自动撑开高度", text: "图标在上面的按钮,而且可以自动撑开高度",
iconCls: "close-font", iconCls: "close-font",
iconGap: 24, iconGap: 24,
iconPosition: "top" iconPosition: "top"
}
},{ },{
el: {
type: "bi.button", type: "bi.button",
text: "自动撑开高度", text: "自动撑开高度",
iconCls: "close-font", iconCls: "close-font",
@ -266,129 +203,87 @@ Demo.Button = BI.inherit(BI.Widget, {
vgap: 16, vgap: 16,
hgap: 100, hgap: 100,
iconPosition: "top" iconPosition: "top"
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "图标在下面的按钮", text: "图标在下面的按钮",
iconCls: "close-font", iconCls: "close-font",
iconPosition: "bottom" iconPosition: "bottom"
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "图标在左边的按钮", text: "图标在左边的按钮",
iconCls: "close-font", iconCls: "close-font",
iconPosition: "left" iconPosition: "left"
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "图标在右边的按钮", text: "图标在右边的按钮",
iconCls: "close-font", iconCls: "close-font",
iconPosition: "right" iconPosition: "right"
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "浅色的一般按钮", text: "浅色的一般按钮",
iconCls: "plus-font", iconCls: "plus-font",
light: true light: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "浅色的成功按钮", text: "浅色的成功按钮",
level: "success", level: "success",
iconCls: "plus-font", iconCls: "plus-font",
light: true light: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
text: "浅色的警告按钮", text: "浅色的警告按钮",
level: "warning", level: "warning",
iconCls: "plus-font", iconCls: "plus-font",
light: true light: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "浅色的失败按钮", text: "浅色的失败按钮",
level: "error", level: "error",
cls: "hover-mask", cls: "hover-mask",
light: true light: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "common", level: "common",
plain: true plain: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "success", level: "success",
plain: true plain: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "error", level: "error",
plain: true plain: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "warning", level: "warning",
plain: true plain: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "ignore", level: "ignore",
plain: true plain: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮",
level: "ignore",
plain: true, plain: true,
disabled: true
}
}, {
el: {
type: "bi.button",
iconCls: "plus-font",
text: "朴素的按钮",
level: "error", level: "error",
plain: true,
disabled: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "common",
plain: true, plain: true,
disabled: true disabled: true
}
}, { }, {
el: {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "点我,更改图标", text: "点我,更改图标",
@ -401,19 +296,18 @@ Demo.Button = BI.inherit(BI.Widget, {
this.setIcon(arr[this.i]); this.setIcon(arr[this.i]);
}, },
height: 24 height: 24
}
}]; }];
// BI.each(items, function (i, item) {
// item.el.handler = function () {
// BI.Msg.alert("按钮", this.options.text);
// };
// });
return { return {
type: "bi.left", type: "bi.left",
scrolly: true, scrolly: true,
vgap: 100, vgap: 100,
hgap: 20, 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提示效果", warningTitle: "自定义title提示效果",
text: "自定义title提示效果", text: "自定义title提示效果",
textAlign: "center" 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, hgap: 300,
vgap: 20 vgap: 20

71
demo/js/base/tree/demo.sync_tree.js

@ -4,7 +4,10 @@ Demo.Func = BI.inherit(BI.Widget, {
}, },
mounted: function () { mounted: function () {
this.syncTree.stroke({ this.syncTree1.stroke({
keyword: "1"
});
this.syncTree2.stroke({
keyword: "1" keyword: "1"
}); });
}, },
@ -13,14 +16,19 @@ Demo.Func = BI.inherit(BI.Widget, {
var self = this; var self = this;
return { return {
type: "bi.vtape", type: "bi.vtape",
items: [{ rowSize: [0.5, 0.5],
items: [
{
type: "bi.vtape",
items: [
{
type: "bi.label", type: "bi.label",
height: 50, height: 50,
text: "可以异步获取数据的树" text: "可以异步获取数据的树"
}, { }, {
type: "bi.async_tree", type: "bi.async_tree",
ref: function (_ref) { ref: function (_ref) {
self.syncTree = _ref; self.syncTree1 = _ref;
}, },
paras: { paras: {
selectedValues: { "1": {}, "2": { "1": {} } } selectedValues: { "1": {}, "2": { "1": {} } }
@ -30,21 +38,68 @@ Demo.Func = BI.inherit(BI.Widget, {
items: [{ items: [{
id: (op.id || "") + "1", id: (op.id || "") + "1",
pId: op.id, pId: op.id,
text: 1, text: (op.id || "") + "1",
isParent: true isParent: true,
iconCls: "close-h-font"
}, { }, {
id: (op.id || "") + "2", id: (op.id || "") + "2",
pId: op.id, pId: op.id,
text: 2 text: (op.id || "") + "2",
iconCls: "search-font"
}, { }, {
id: (op.id || "") + "3", id: (op.id || "") + "3",
pId: op.id, pId: op.id,
text: 3 text: (op.id || "") + "3",
iconCls: "date-font"
}], }],
hasNext: BI.isNull(op.id) hasNext: BI.isNull(op.id)
}); });
} }
}] },
]
},
{
type: "bi.vtape",
items: [
{
type: "bi.label",
height: 50,
text: "showIcon属性搭配节点iconCls,可以显示图标"
}, {
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; cb = cb.handler;
} }
options = options || {}; 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 store: vm.store
})); }));
} }
@ -177,7 +177,7 @@
delete this.__cacheStore; delete this.__cacheStore;
}; };
_.each(["_render", "__afterRender", "_mount", "__afterMount"], function (name) { BI._.each(["_render", "__afterRender", "_mount", "__afterMount"], function (name) {
var old = BI.Widget.prototype[name]; var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () { old && (BI.Widget.prototype[name] = function () {
this.store && pushTarget(this.store); this.store && pushTarget(this.store);

90
dist/fix/fix.js vendored

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

97
dist/fix/fix.proxy.js vendored

@ -2,22 +2,16 @@
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) : typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Fix = {})); (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Fix = {}));
}(this, (function (exports) { 'use strict'; })(this, (function (exports) { 'use strict';
function _typeof(obj) { function _typeof(obj) {
"@babel/helpers - typeof"; "@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
_typeof = function (obj) {
return typeof obj; return typeof obj;
}; } : function (obj) {
} else { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
_typeof = function (obj) { }, _typeof(obj);
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
} }
function _classCallCheck(instance, Constructor) { function _classCallCheck(instance, Constructor) {
@ -39,6 +33,9 @@
function _createClass(Constructor, protoProps, staticProps) { function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps); if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor; return Constructor;
} }
@ -1631,7 +1628,7 @@
return mixinInjection[type]; return mixinInjection[type];
} }
function mixin(xtype, cls) { function mixin(xtype, cls) {
mixinInjection[xtype] = _.cloneDeep(cls); mixinInjection[xtype] = BI._.cloneDeep(cls);
} }
var queue = []; var queue = [];
@ -1710,7 +1707,7 @@
} }
function innerWatch(source, cb, options) { 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."); 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; deep = true;
} else if (_.isArray(source)) { } else if (BI._.isArray(source)) {
getter = function getter() { getter = function getter() {
return source.map(function (s) { return source.map(function (s) {
if (isRef(s)) { if (isRef(s)) {
return s.value; return s.value;
} else if (isReactive(s)) { } else if (isReactive(s)) {
return traverse(s); return traverse(s);
} else if (_.isFunction(s)) { } else if (BI._.isFunction(s)) {
return s.call(instance); return s.call(instance);
} else { } else {
warnInvalidSource(s); warnInvalidSource(s);
} }
}); });
}; };
} else if (_.isFunction(source)) { } else if (BI._.isFunction(source)) {
if (cb) { if (cb) {
// getter with cb // getter with cb
getter = function getter() { 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() { var job = function job() {
// 这里去掉的原因是,新增属性没有生效也会触发变化监听 // 这里去掉的原因是,新增属性没有生效也会触发变化监听
@ -1903,7 +1900,7 @@
function traverse(value) { function traverse(value) {
var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set(); 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; return value;
} }
@ -1911,7 +1908,7 @@
if (isRef(value)) { if (isRef(value)) {
traverse(value.value, seen); traverse(value.value, seen);
} else if (_.isArray(value)) { } else if (BI._.isArray(value)) {
for (var i = 0; i < value.length; i++) { for (var i = 0; i < value.length; i++) {
traverse(value[i], seen); traverse(value[i], seen);
} }
@ -1940,7 +1937,7 @@
var expr = ""; var expr = "";
for (var i = 0, len = binarys.length; i < len; i++) { 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]; expr += binarys[i];
} else { } else {
expr += "false"; expr += "false";
@ -1953,7 +1950,7 @@
function watchExp(model, getter) { function watchExp(model, getter) {
var result = getter.call(model, model); var result = getter.call(model, model);
if (_.isArray(result)) { if (BI._.isArray(result)) {
return result.concat(); return result.concat();
} }
@ -1974,14 +1971,14 @@
options.user = true; options.user = true;
var exps; var exps;
if (_.isFunction(expOrFn)) { if (BI._.isFunction(expOrFn)) {
var watcher = innerWatch(expOrFn, cb, options); var watcher = innerWatch(expOrFn, cb, options);
return function unwatchFn() { return function unwatchFn() {
watcher(); 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 paths = expOrFn.split(".");
var prePaths = paths.slice(0, paths.length - 1); var prePaths = paths.slice(0, paths.length - 1);
var preGetter = parsePath(prePaths.join(".")); var preGetter = parsePath(prePaths.join("."));
@ -2030,8 +2027,8 @@
} }
}; };
_.each(exps, function (exp, i) { BI._.each(exps, function (exp, i) {
if (_.has(operators, exp)) { if (BI._.has(operators, exp)) {
return; return;
} }
@ -2079,14 +2076,14 @@
return watchExp(_v2, _getter); return watchExp(_v2, _getter);
}, function (newValue, oldValue) { }, function (newValue, oldValue) {
// a.** 在a变化的时候不会触发change // a.** 在a变化的时候不会触发change
if (!_.isArray(newValue) && oldValue !== newValue) { if (!BI._.isArray(newValue) && oldValue !== newValue) {
return; return;
} }
callback(i, NaN, NaN, _.extend({ callback(i, NaN, NaN, BI._.extend({
index: i index: i
})); }));
}, _.extend({ }, BI._.extend({
deep: true deep: true
}, options))); }, options)));
return; return;
@ -2145,11 +2142,11 @@
changes = []; changes = [];
if (newValue === true) { if (newValue === true) {
callback(i, NaN, NaN, _.extend({ callback(i, NaN, NaN, BI._.extend({
index: i index: i
})); }));
} }
}, _.extend({}, options, { }, BI._.extend({}, options, {
deep: true, deep: true,
onTrigger: function onTrigger(_ref) { onTrigger: function onTrigger(_ref) {
var target = _ref.target, var target = _ref.target,
@ -2167,7 +2164,7 @@
watchers.push(innerWatch(function () { watchers.push(innerWatch(function () {
return watchExp(model, getter); return watchExp(model, getter);
}, function (newValue, oldValue) { }, function (newValue, oldValue) {
callback(i, newValue, oldValue, _.extend({ callback(i, newValue, oldValue, BI._.extend({
index: i index: i
})); }));
}, options)); }, options));
@ -2188,7 +2185,7 @@
var $$computed = vm.$$computed = {}; var $$computed = vm.$$computed = {};
for (var key in c) { 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) { for (var key in watch) {
var handler = watch[key]; var handler = watch[key];
if (_.isArray(handler)) { if (BI._.isArray(handler)) {
for (var i = 0; i < handler.length; i++) { for (var i = 0; i < handler.length; i++) {
vm._watchers.push(createWatcher(vm, key, handler[i])); vm._watchers.push(createWatcher(vm, key, handler[i]));
} }
@ -2218,25 +2215,25 @@
cb = vm[cb]; 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) { function initMethods(vm, methods) {
for (var key in 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) { function initMixins(vm, mixins) {
mixins = (mixins || []).slice(0); mixins = (mixins || []).slice(0);
_.each(mixins.reverse(), function (mixinType) { BI._.each(mixins.reverse(), function (mixinType) {
var mixin = getMixins(mixinType); var mixin = getMixins(mixinType);
for (var key in mixin) { for (var key in mixin) {
if (typeof mixin[key] !== "function") continue; if (typeof mixin[key] !== "function") continue;
if (_.has(vm, key)) continue; if (BI._.has(vm, key)) continue;
vm[key] = _.bind(mixin[key], vm); vm[key] = BI._.bind(mixin[key], vm);
} }
}); });
} }
@ -2329,7 +2326,7 @@
var inject = vm.inject || []; var inject = vm.inject || [];
var result = {}; var result = {};
_.each(inject, function (key) { BI._.each(inject, function (key) {
result[key] = getInjectValue(vm, key); result[key] = getInjectValue(vm, key);
}); });
@ -2346,7 +2343,7 @@
value: function _constructor(options, destroyHandler) { value: function _constructor(options, destroyHandler) {
this.options = options || {}; this.options = options || {};
this._parent = Model.target; 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 computed = this.computed;
var context = this.context; var context = this.context;
var inject = this.inject; var inject = this.inject;
@ -2354,14 +2351,14 @@
var watch = this.watch; var watch = this.watch;
var actions = this.actions; 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; var mixins = this.mixins;
defineProps(this); defineProps(this);
childContext && defineContext(this, childContext); childContext && defineContext(this, childContext);
initMixins(this, mixins); initMixins(this, mixins);
this.init(); this.init();
initState(this, _.extend(getInjectValues(this), state)); initState(this, BI._.extend(getInjectValues(this), state));
initComputed(this, computed); initComputed(this, computed);
REACTIVE && initWatch(this, watch); REACTIVE && initWatch(this, watch);
initMethods(this, actions); initMethods(this, actions);
@ -2379,10 +2376,10 @@
}, { }, {
key: "destroy", key: "destroy",
value: function destroy() { value: function destroy() {
_.each(this._watchers, function (unwatches) { BI._.each(this._watchers, function (unwatches) {
unwatches = _.isArray(unwatches) ? unwatches : [unwatches]; unwatches = BI._.isArray(unwatches) ? unwatches : [unwatches];
_.each(unwatches, function (unwatch) { BI._.each(unwatches, function (unwatch) {
unwatch(); unwatch();
}); });
}); });
@ -2398,7 +2395,7 @@
return Model; return Model;
}(); }();
function set(target, key, val) { function set(target, key, val) {
if (_.isArray(target)) { if (BI._.isArray(target)) {
target.length = Math.max(target.length, key); target.length = Math.max(target.length, key);
target.splice(key, 1, val); target.splice(key, 1, val);
return val; return val;
@ -2416,12 +2413,12 @@
return value; return value;
} }
function del(target, key) { function del(target, key) {
if (_.isArray(target)) { if (BI._.isArray(target)) {
target.splice(key, 1); target.splice(key, 1);
return; return;
} }
if (!_.has(target, key)) { if (!BI._.has(target, key)) {
return; return;
} }
@ -2441,7 +2438,7 @@
function toJSON(model) { function toJSON(model) {
var result; var result;
if (_.isArray(model)) { if (BI._.isArray(model)) {
result = []; result = [];
for (var i = 0, len = model.length; i < len; i++) { for (var i = 0, len = model.length; i < len; i++) {
@ -2475,4 +2472,4 @@
Object.defineProperty(exports, '__esModule', { value: true }); 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", "name": "fineui",
"version": "2.0.20220617213406", "version": "2.0.20220720140353",
"description": "fineui", "description": "fineui",
"main": "dist/fineui.min.js", "main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",
"bin": {
"fui-cli": "./bin/cli/cli.js"
},
"devDependencies": { "devDependencies": {
"@babel/core": "^7.17.4", "@babel/core": "^7.17.4",
"@babel/polyfill": "7.6.0", "@babel/polyfill": "7.6.0",
"@fui/babel-preset-fineui": "^2.0.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", "@types/node": "15.6.1",
"autoprefixer": "9.6.1", "autoprefixer": "9.6.1",
"babel-loader": "8.0.6", "babel-loader": "8.0.6",
@ -47,7 +50,7 @@
"source-map-loader": "0.2.4", "source-map-loader": "0.2.4",
"style-loader": "0.23.1", "style-loader": "0.23.1",
"terser-webpack-plugin": "4.2.3", "terser-webpack-plugin": "4.2.3",
"typescript": "3.5.2", "typescript": "3.9.2",
"webpack": "4.35.2", "webpack": "4.35.2",
"webpack-cli": "3.3.5", "webpack-cli": "3.3.5",
"webpack-dev-server": "3.7.2", "webpack-dev-server": "3.7.2",

27
src/base/1.pane.js

@ -40,30 +40,9 @@ BI.Pane = BI.inherit(BI.Widget, {
loading: function () { loading: function () {
var self = this, o = this.options; var self = this, o = this.options;
var isIE = BI.isIE(); var loadingAnimation = BI.Providers.getProvider("bi.provider.system").getLoading({
var loadingAnimation = BI.createWidget({ loadingSize: o.loadingSize,
type: "bi.horizontal", context: this
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)
}]
}); });
// pane在同步方式下由items决定tipText的显示与否 // pane在同步方式下由items决定tipText的显示与否
// loading的异步情况下由loaded后对面板的populate的时机决定 // loading的异步情况下由loaded后对面板的populate的时机决定

4
src/base/combination/bubble.js

@ -44,7 +44,9 @@
var self = this, o = this.options; var self = this, o = this.options;
this._initCombo(); 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) { this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {

7
src/base/combination/combo.js

@ -50,9 +50,14 @@
var self = this, o = this.options; var self = this, o = this.options;
this._initCombo(); 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) { this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.TOGGLE) {
self._toggle();
}
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self._popupView(); self._popupView();
} }

4
src/base/combination/expander.js

@ -26,7 +26,9 @@ BI.Expander = BI.inherit(BI.Widget, {
this._expanded = !!o.el.open; this._expanded = !!o.el.open;
this._initExpander(); 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) { this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {

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

@ -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 () { getNotSelectedValue: function () {
var v = []; var v = [];
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
@ -314,6 +331,16 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
return node; return node;
}, },
/**
* 滚动到指定的节点
*/
scrollToValue: function (value, scrollIntoViewOptions) {
var node = this.getNodeByValue(value);
if (node) {
node.element[0].scrollIntoView(scrollIntoViewOptions);
}
},
empty: function () { empty: function () {
BI.ButtonGroup.superclass.empty.apply(this, arguments); BI.ButtonGroup.superclass.empty.apply(this, arguments);
this.options.items = []; this.options.items = [];

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

@ -96,6 +96,20 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
return v; 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 () { getValue: function () {
var v = []; var v = [];
BI.each(this.buttonMap, function (i, item) { BI.each(this.buttonMap, function (i, item) {

4
src/base/combination/switcher.js

@ -26,7 +26,9 @@ BI.Switcher = BI.inherit(BI.Widget, {
var self = this, o = this.options; var self = this, o = this.options;
this._initSwitcher(); 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) { this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && self.isValid()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {

11
src/base/combination/tab.js

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

16
src/base/list/listview.js

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

11
src/base/list/virtualgrouplist.js

@ -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.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)));
this.container.populate(items.map(function (item, i) { 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 { } else {
for (var i = (start < 0 ? 0 : start); i <= end; i++) { 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.element.height(o.rowHeight * o.items.length - topHeight);
this.container.populate(items.map(function (item, i) { 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); this.bottomBlank.setHeight(0);
}, },
// 暂时只支持固定行高的场景
scrollTo: function (scrollTop) {
this.options.scrollTop = scrollTop;
this._calculateBlocksToRender();
this.element.scrollTop(scrollTop);
},
restore: function () { restore: function () {
this.options.scrollTop = 0; this.options.scrollTop = 0;
this._restore(); this._restore();

9
src/base/list/virtuallist.js

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

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

@ -9,6 +9,9 @@
* @extends BI.Widget * @extends BI.Widget
* @abstract * @abstract
*/ */
var delayingTooltips;
BI.Single = BI.inherit(BI.Widget, { BI.Single = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Single.superclass._defaultConfig.apply(this, arguments); var conf = BI.Single.superclass._defaultConfig.apply(this, arguments);
@ -17,17 +20,29 @@ BI.Single = BI.inherit(BI.Widget, {
title: null, title: null,
warningTitle: null, warningTitle: null,
tipType: null, // success或warning tipType: null, // success或warning
belowMouse: false // title是否跟随鼠标 belowMouse: false, // title是否跟随鼠标
enableHover: false
}); });
}, },
_showToolTip: function (e, opt) { _showToolTip: function (e, opt) {
opt || (opt = {}); opt || (opt = {});
var self = this, o = this.options; var o = this.options;
var type = this.getTipType() || (this.isEnabled() ? "success" : "warning"); var tooltipOpt = {};
var title = type === "success" ? this.getTitle() : (this.getWarningTitle() || this.getTitle()); var title = this.getTitle();
if (BI.isKey(title)) { if (BI.isPlainObject(title)) {
BI.Tooltips.show(e, this.getName(), title, type, this, opt); 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) { if (o.action) {
BI.Actions.runAction(o.action, "hover", o, this); BI.Actions.runAction(o.action, "hover", o, this);
} }
@ -51,7 +66,7 @@ BI.Single = BI.inherit(BI.Widget, {
self.setValue(newValue); self.setValue(newValue);
}) : o.value; }) : o.value;
BI.Single.superclass._init.apply(this, arguments); 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)) { || BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) {
this.enableHover({ this.enableHover({
belowMouse: o.belowMouse, belowMouse: o.belowMouse,
@ -78,14 +93,16 @@ BI.Single = BI.inherit(BI.Widget, {
this.element.on("mouseenter.title" + this.getName(), function (e) { this.element.on("mouseenter.title" + this.getName(), function (e) {
self._e = e; self._e = e;
if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) { if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) {
delayingTooltips = self.getName();
self.showTimeout = BI.delay(function () { self.showTimeout = BI.delay(function () {
if (BI.isNotNull(self.showTimeout)) { if (BI.isNotNull(self.showTimeout) && delayingTooltips === self.getName()) {
self._showToolTip(self._e || e, opt); self._showToolTip(self._e || e, opt);
} }
}, 200); }, 200);
} else if (self.getTipType() === "success" || self.isEnabled()) { } else if (self.getTipType() === "success" || self.isEnabled()) {
delayingTooltips = self.getName();
self.showTimeout = BI.delay(function () { self.showTimeout = BI.delay(function () {
if (BI.isNotNull(self.showTimeout)) { if (BI.isNotNull(self.showTimeout) && delayingTooltips === self.getName()) {
self._showToolTip(self._e || e, opt); self._showToolTip(self._e || e, opt);
} }
}, 500); }, 500);

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

@ -49,7 +49,9 @@ BI.BasicButton = BI.inherit(BI.Single, {
this.setSelected(true); this.setSelected(true);
} }
// 延迟绑定事件,这样可以将自己绑定的事情优先执行 // 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(this.bindEvent.bind(this)); BI.nextTick(() => {
!this.isDestroyed() && this.bindEvent();
});
BI.BasicButton.superclass._initRef.apply(this, arguments); BI.BasicButton.superclass._initRef.apply(this, arguments);
}, },

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

@ -30,12 +30,14 @@
adaptiveHeight += (tGap + bGap); adaptiveHeight += (tGap + bGap);
} }
var clearMinWidth = props.block === true || props.clear === true || props.plain;
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""),
attributes: { attributes: {
tabIndex: 1 tabIndex: 1
}, },
minWidth: (props.block === true || props.clear === true) ? 0 : 80, minWidth: clearMinWidth ? 0 : 80,
height: isVertical(props.iconPosition) ? adaptiveHeight : 24, height: isVertical(props.iconPosition) ? adaptiveHeight : 24,
shadow: props.clear !== true, shadow: props.clear !== true,
isShadowShowingOnSelected: true, isShadowShowingOnSelected: true,
@ -64,7 +66,7 @@
}, },
render: function () { render: function () {
var o = this.options; var o = this.options, self = this;
// 由于button默认情况下有个边框,所以要主动算行高 // 由于button默认情况下有个边框,所以要主动算行高
var lineHeight, textHeight = o.textHeight; var lineHeight, textHeight = o.textHeight;
@ -145,27 +147,18 @@
rgap: o.rgap, rgap: o.rgap,
element: this, element: this,
text: o.text, text: o.text,
value: o.value value: o.value,
title: null,
}); });
} }
if (o.block === true) { var classArr = ["block", "clear", "ghost", "plain", "loading", "light"];
this.element.addClass("block"); // 如果 options 对应的属性为 true 则给元素添加 class
} BI.each(classArr, function (_, clz) {
if (o.clear === true) { if (BI.get(o, clz) === true) {
this.element.addClass("clear"); self.element.addClass(clz);
}
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");
} }
});
if (o.minWidth > 0) { 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(); this.file.reset();
}, },
setUrl: function (v) {
this.file.setUrl(v);
},
setMaxFileLength: function (v) { setMaxFileLength: function (v) {
this.file.setMaxFileLength(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) { setMaxFileLength: function (v) {
this.options.maxLength = v; this.options.maxLength = v;
if (this.wrap) { if (this.wrap) {

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

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

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

@ -7,8 +7,8 @@
*/ */
BI.Tooltip = BI.inherit(BI.Tip, { BI.Tooltip = BI.inherit(BI.Tip, {
_const: { _const: {
hgap: 5, hgap: 8,
vgap: 3 vgap: 4
}, },
_defaultConfig: function () { _defaultConfig: function () {
@ -17,7 +17,8 @@ BI.Tooltip = BI.inherit(BI.Tip, {
text: "", text: "",
level: "success", // success或warning level: "success", // success或warning
stopEvent: false, stopEvent: false,
stopPropagation: false stopPropagation: false,
textAlign: "left",
}); });
}, },
@ -44,10 +45,11 @@ BI.Tooltip = BI.inherit(BI.Tip, {
type: "bi.vertical", type: "bi.vertical",
element: this, element: this,
hgap: this._const.hgap, hgap: this._const.hgap,
innerVgap: this._const.vgap,
items: BI.map(texts, function (i, text) { items: BI.map(texts, function (i, text) {
return { return {
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: o.textAlign,
whiteSpace: "normal", whiteSpace: "normal",
text: text, text: text,
textHeight: 18 textHeight: 18
@ -58,11 +60,12 @@ BI.Tooltip = BI.inherit(BI.Tip, {
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
element: this, element: this,
textAlign: "left", textAlign: o.textAlign,
whiteSpace: "normal", whiteSpace: "normal",
text: o.text, text: o.text,
textHeight: 18, 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, hideChecker: o.hideChecker,
offsetStyle: o.offsetStyle, offsetStyle: o.offsetStyle,
showArrow: true, showArrow: true,
comboClass: o.comboClass,
el: o.el, el: o.el,
popup: () => BI.extend({ popup: () => BI.extend({
type: "bi.bubble_popup_view", 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, width: o.height,
height: 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; var stateText = this._digest(o.value, o.items) || o.text;

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

@ -47,11 +47,15 @@ BI.ListPane = BI.inherit(BI.Pane, {
} }
o.itemsCreator(op, function () { o.itemsCreator(op, function () {
calback.apply(self, arguments); calback.apply(self, arguments);
op.times === 1 && BI.nextTick(function () { 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(); self.loaded();
// callback可能在loading之前执行, check保证显示正确 // callback可能在loading之前执行, check保证显示正确
self.check(); self.check();
}); });
}
}); });
}, },
hasNext: o.hasNext, hasNext: o.hasNext,
@ -150,6 +154,16 @@ BI.ListPane = BI.inherit(BI.Pane, {
this.button_group.setValue.apply(this.button_group, arguments); 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 () { getValue: function () {
return this.button_group.getValue.apply(this.button_group, arguments); return this.button_group.getValue.apply(this.button_group, arguments);
}, },

4
src/case/list/list.select.js

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

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

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

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

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

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

File diff suppressed because it is too large Load Diff

17
src/component/allvaluechooser/abstract.allvaluechooser.js

@ -40,6 +40,18 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
return text; 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) { _itemsCreator: function (options, callback) {
var self = this, o = this.options; var self = this, o = this.options;
if (!o.cache || !this.items) { if (!o.cache || !this.items) {
@ -50,6 +62,7 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
} else { } else {
call(this.items); call(this.items);
} }
function call(items) { function call(items) {
var keywords = (options.keywords || []).slice(); var keywords = (options.keywords || []).slice();
if (options.keyword) { if (options.keyword) {
@ -81,8 +94,8 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
return; return;
} }
callback({ callback({
items: resultItems, items: self._getItemsByTimes(resultItems, options.times),
hasNext: false 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 () { getValue: function () {
var val = this.list.getValue() || {}; var val = this.list.getValue() || {};
if (val.type === BI.Selection.All) { if (val.type === BI.Selection.Multi) {
return val.assist;
}
return val.value || []; return val.value || [];
}
return BI.difference(BI.map(this.items, "value"), val.value || []);
}, },
populate: function (items) { populate: function (items) {

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

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

4
src/component/form/form.js

@ -18,7 +18,8 @@
label: "", label: "",
el: {} el: {}
}], }],
labelWidth: "" labelWidth: "",
headerCls: "", // 左侧文字样式
}, },
render: function () { render: function () {
@ -44,6 +45,7 @@
height: item.el.height || 28, height: item.el.height || 28,
labelAlign: o.labelAlign, labelAlign: o.labelAlign,
labelWidth: o.labelWidth, labelWidth: o.labelWidth,
headerCls: o.headerCls,
el: item.el, el: item.el,
label: item.label, label: item.label,
tip: item.tip, 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. // loaded by a script tag in the presence of an AMD loader.
// See http://requirejs.org/docs/errors.html#mismatch for more details. // See http://requirejs.org/docs/errors.html#mismatch for more details.
// Use `_.noConflict` to remove Lodash from the global object. // 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 // Define as an anonymous module so, through path mapping, it can be
// referenced as the "underscore" module. // referenced as the "underscore" module.
@ -10270,6 +10270,6 @@
} }
else { else {
// Export to the global object. // Export to the global object.
root._ = lodash; BI._ = lodash;
} }
}.call(this)); }.call(this));

76
src/core/2.base.js

@ -11,19 +11,19 @@
}; };
var _apply = function (name) { var _apply = function (name) {
return function () { return function () {
return _[name].apply(_, arguments); return BI._[name].apply(BI._, arguments);
}; };
}; };
var _applyFunc = function (name) { var _applyFunc = function (name) {
return function () { return function () {
var args = Array.prototype.slice.call(arguments, 0); var args = Array.prototype.slice.call(arguments, 0);
args[1] = _.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1]; args[1] = BI._.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1];
return _[name].apply(_, args); return BI._[name].apply(BI._, args);
}; };
}; };
// Utility // Utility
_.extend(BI, { BI._.extend(BI, {
assert: function (v, is) { assert: function (v, is) {
if (this.isFunction(is)) { if (this.isFunction(is)) {
if (!is(v)) { 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); 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) { "sortBy", "groupBy", "indexBy", "countBy", "partition", "clamp"], function (name) {
if (name === "any") { if (name === "any") {
BI[name] = _applyFunc("some"); BI[name] = _applyFunc("some");
@ -157,7 +157,7 @@
BI[name] = _applyFunc(name); BI[name] = _applyFunc(name);
} }
}); });
_.extend(BI, { BI._.extend(BI, {
// 数数 // 数数
count: function (from, to, predicate) { count: function (from, to, predicate) {
var t; var t;
@ -217,10 +217,10 @@
}).join(""); }).join("");
} }
if (BI.isArray(obj1)) { if (BI.isArray(obj1)) {
return _.concat.apply([], arguments); return BI._.concat.apply([], arguments);
} }
if (BI.isObject(obj1)) { if (BI.isObject(obj1)) {
return _.extend.apply({}, arguments); return BI._.extend.apply({}, arguments);
} }
}, },
@ -254,7 +254,7 @@
backFindKey: function (obj, predicate, context) { backFindKey: function (obj, predicate, context) {
predicate = BI.iteratee(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--) { for (var i = keys.length - 1; i >= 0; i--) {
key = keys[i]; key = keys[i];
if (predicate(obj[key], key, obj)) { 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) { "difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name); BI[name] = _apply(name);
}); });
_.each(["findIndex", "findLastIndex"], function (name) { BI._.each(["findIndex", "findLastIndex"], function (name) {
BI[name] = _applyFunc(name); BI[name] = _applyFunc(name);
}); });
_.extend(BI, { BI._.extend(BI, {
// 构建一个长度为length的数组 // 构建一个长度为length的数组
makeArray: function (length, value) { makeArray: function (length, value) {
var res = []; var res = [];
@ -401,27 +401,27 @@
if (array == null) { if (array == null) {
return []; return [];
} }
if (!_.isBoolean(isSorted)) { if (!BI._.isBoolean(isSorted)) {
context = iteratee; context = iteratee;
iteratee = isSorted; iteratee = isSorted;
isSorted = false; isSorted = false;
} }
iteratee && (iteratee = traverse(iteratee, context)); 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", "defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty",
"isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite", "isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite",
"isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep"], function (name) { "isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep"], function (name) {
BI[name] = _apply(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); BI[name] = _applyFunc(name);
}); });
_.extend(BI, { BI._.extend(BI, {
inherit: function (sp, overrides) { inherit: function (sp, overrides) {
var sb = function () { var sb = function () {
@ -432,7 +432,7 @@
F.prototype = spp; F.prototype = spp;
sb.prototype = new F(); sb.prototype = new F();
sb.superclass = spp; sb.superclass = spp;
_.extend(sb.prototype, overrides, { BI._.extend(sb.prototype, overrides, {
superclass: sp superclass: sp
}); });
return sb; return sb;
@ -455,10 +455,10 @@
return false; return false;
} }
return BI.every(keys, function (i, key) { 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) { freeze: function (value) {
@ -524,13 +524,17 @@
isWindow: function (obj) { isWindow: function (obj) {
return obj != null && obj == obj.window; return obj != null && obj == obj.window;
},
isPromise: function(obj) {
return !!obj && (BI.isObject(obj) || BI.isFunction(obj)) && BI.isFunction(obj.then);
} }
}); });
// deep方法 // deep方法
_.extend(BI, { BI._.extend(BI, {
deepClone: _.cloneDeep, deepClone: BI._.cloneDeep,
deepExtend: _.merge, deepExtend: BI._.merge,
isDeepMatch: function (object, attrs) { isDeepMatch: function (object, attrs) {
var keys = BI.keys(attrs), length = keys.length; var keys = BI.keys(attrs), length = keys.length;
@ -548,8 +552,8 @@
}, },
contains: function (obj, target, fromIndex) { contains: function (obj, target, fromIndex) {
if (!_.isArrayLike(obj)) obj = _.values(obj); if (!BI._.isArrayLike(obj)) obj = BI._.values(obj);
return _.indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0; return BI._.indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0;
}, },
deepContains: function (obj, copy) { 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 () { 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 () { BI[name] = function () {
return _[name].apply(_, arguments); return BI._[name].apply(BI._, arguments);
}; };
}); });
_.extend(BI, { BI._.extend(BI, {
nextTick: (function () { nextTick: (function () {
var callbacks = []; var callbacks = [];
var pending = false; var pending = false;
@ -731,10 +735,10 @@
}); });
// 数字相关方法 // 数字相关方法
_.each(["random"], function (name) { BI._.each(["random"], function (name) {
BI[name] = _apply(name); BI[name] = _apply(name);
}); });
_.extend(BI, { BI._.extend(BI, {
parseInt: function (number) { parseInt: function (number) {
var radix = 10; var radix = 10;
@ -837,9 +841,9 @@
}); });
// 字符串相关方法 // 字符串相关方法
_.extend(BI, { BI._.extend(BI, {
trim: function () { trim: function () {
return _.trim.apply(_, arguments); return BI._.trim.apply(BI._, arguments);
}, },
toUpperCase: function (string) { toUpperCase: function (string) {
@ -965,7 +969,7 @@
}); });
// 日期相关方法 // 日期相关方法
_.extend(BI, { BI._.extend(BI, {
/** /**
* 是否是闰年 * 是否是闰年
* @param year * @param year

20
src/core/3.ob.js

@ -31,7 +31,7 @@
var OB = function (config) { var OB = function (config) {
this._constructor(config); this._constructor(config);
}; };
_.extend(OB.prototype, { BI._.extend(OB.prototype, {
props: {}, props: {},
init: null, init: null,
destroyed: null, destroyed: null,
@ -66,12 +66,12 @@
_initListeners: function () { _initListeners: function () {
var self = this; var self = this;
if (this.options.listeners != null) { if (this.options.listeners != null) {
_.each(this.options.listeners, function (lis, eventName) { BI._.each(this.options.listeners, function (lis, eventName) {
if (_.isFunction(lis)) { if (BI._.isFunction(lis)) {
self.on(eventName, lis); self.on(eventName, lis);
return; 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; delete this.options.listeners;
} }
@ -90,17 +90,17 @@
//释放当前对象 //释放当前对象
_purgeRef: function () { _purgeRef: function () {
if (this.options.__ref) { if (this.options.__ref) {
this.options.__ref.call(null); this.options.__ref.call(null, null);
this.options.__ref = null; this.options.__ref = null;
} }
if (this.options.ref) { if (this.options.ref) {
this.options.ref.call(null); this.options.ref.call(null, null);
this.options.ref = null; this.options.ref = null;
} }
}, },
_getEvents: function () { _getEvents: function () {
if (!_.isObject(this.events)) { if (!BI._.isObject(this.events)) {
this.events = {}; this.events = {};
} }
return this.events; return this.events;
@ -115,7 +115,7 @@
var self = this; var self = this;
eventName = eventName.toLowerCase(); eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (!_.isArray(fns)) { if (!BI._.isArray(fns)) {
fns = []; fns = [];
this._getEvents()[eventName] = fns; this._getEvents()[eventName] = fns;
} }
@ -151,9 +151,9 @@
delete this._getEvents()[eventName]; delete this._getEvents()[eventName];
} else { } else {
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (_.isArray(fns)) { if (BI._.isArray(fns)) {
var newFns = []; var newFns = [];
_.each(fns, function (ifn) { BI._.each(fns, function (ifn) {
if (ifn != fn) { if (ifn != fn) {
newFns.push(ifn); newFns.push(ifn);
} }

8
src/core/4.widget.js

@ -346,6 +346,7 @@
_initState: function () { _initState: function () {
this._isMounted = false; this._isMounted = false;
this._isDestroyed = false;
}, },
__initWatch: function () { __initWatch: function () {
@ -449,6 +450,10 @@
return this._isMounted; return this._isMounted;
}, },
isDestroyed: function () {
return this._isDestroyed;
},
setWidth: function (w) { setWidth: function (w) {
this.options.width = w; this.options.width = w;
this._initElementWidth(); this._initElementWidth();
@ -732,6 +737,9 @@
this._isMounted = false; this._isMounted = false;
callLifeHook(this, "destroyed"); callLifeHook(this, "destroyed");
this.destroyed = null; this.destroyed = null;
this._isDestroyed = true;
// this._purgeRef(); // 清除ref的时机还是要仔细考虑一下
}, },
_unMount: function () { _unMount: function () {

41
src/core/5.inject.js

@ -10,7 +10,7 @@
BI.module = BI.module || function (xtype, cls) { BI.module = BI.module || function (xtype, cls) {
if (moduleInjection[xtype] != null) { if (moduleInjection[xtype] != null) {
_global.console && console.error("module: [" + xtype + "] 已经注册过了"); _global.console && console.error("module: [" + xtype + "] 已经注册过了");
} } else {
if (BI.isFunction(cls)) { if (BI.isFunction(cls)) {
cls = cls(); cls = cls();
} }
@ -31,6 +31,8 @@
} }
} }
moduleInjection[xtype] = cls; moduleInjection[xtype] = cls;
}
return function () { return function () {
return BI.Modules.getModule(xtype); return BI.Modules.getModule(xtype);
}; };
@ -40,8 +42,10 @@
BI.constant = BI.constant || function (xtype, cls) { BI.constant = BI.constant || function (xtype, cls) {
if (constantInjection[xtype] != null) { if (constantInjection[xtype] != null) {
_global.console && console.error("constant: [" + xtype + "]已经注册过了"); _global.console && console.error("constant: [" + xtype + "]已经注册过了");
} } else {
constantInjection[xtype] = cls; constantInjection[xtype] = cls;
}
return function () { return function () {
return BI.Constants.getConstant(xtype); return BI.Constants.getConstant(xtype);
}; };
@ -51,8 +55,10 @@
BI.model = BI.model || function (xtype, cls) { BI.model = BI.model || function (xtype, cls) {
if (modelInjection[xtype] != null) { if (modelInjection[xtype] != null) {
_global.console && console.error("model: [" + xtype + "] 已经注册过了"); _global.console && console.error("model: [" + xtype + "] 已经注册过了");
} } else {
modelInjection[xtype] = cls; modelInjection[xtype] = cls;
}
return function (config) { return function (config) {
return BI.Models.getModel(xtype, config); return BI.Models.getModel(xtype, config);
}; };
@ -62,8 +68,10 @@
BI.store = BI.store || function (xtype, cls) { BI.store = BI.store || function (xtype, cls) {
if (storeInjection[xtype] != null) { if (storeInjection[xtype] != null) {
_global.console && console.error("store: [" + xtype + "] 已经注册过了"); _global.console && console.error("store: [" + xtype + "] 已经注册过了");
} } else {
storeInjection[xtype] = cls; storeInjection[xtype] = cls;
}
return function (config) { return function (config) {
return BI.Stores.getStore(xtype, config); return BI.Stores.getStore(xtype, config);
}; };
@ -74,7 +82,9 @@
if (serviceInjection[xtype] != null) { if (serviceInjection[xtype] != null) {
_global.console && console.error("service: [" + xtype + "] 已经注册过了"); _global.console && console.error("service: [" + xtype + "] 已经注册过了");
} }
serviceInjection[xtype] = cls; serviceInjection[xtype] = cls;
return function (config) { return function (config) {
return BI.Services.getService(xtype, config); return BI.Services.getService(xtype, config);
}; };
@ -84,20 +94,33 @@
BI.provider = BI.provider || function (xtype, cls) { BI.provider = BI.provider || function (xtype, cls) {
if (providerInjection[xtype] != null) { if (providerInjection[xtype] != null) {
_global.console && console.error("provider: [" + xtype + "] 已经注册过了"); _global.console && console.error("provider: [" + xtype + "] 已经注册过了");
} } else {
providerInjection[xtype] = cls; providerInjection[xtype] = cls;
}
return function (config) { return function (config) {
return BI.Providers.getProvider(xtype, config); return BI.Providers.getProvider(xtype, config);
}; };
}; };
var configFunctions = BI.OB.configFunctions = {}; var configFunctions = BI.OB.configFunctions = {};
var runConfigFunction = function (type) { var runConfigFunction = function (type, configFn) {
if (!type || !configFunctions[type]) { if (!type || !configFunctions[type]) {
return false; return false;
} }
var queue = 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]; delete configFunctions[type];
}
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies(); var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies();
var modules = moduleInjectionMap.components[type] var modules = moduleInjectionMap.components[type]
@ -176,6 +199,10 @@
fn: configFn, fn: configFn,
opt: opt opt: opt
}); });
if (opt.immediately) {
return runConfigFunction(type, configFn);
}
}; };
BI.getReference = BI.getReference || function (type, fn) { 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 * @class BI.Events
*/ */
_.extend(BI, { BI._.extend(BI, {
Events: { Events: {
/** /**
@ -143,6 +143,12 @@ _.extend(BI, {
*/ */
COLLAPSE: "_COLLAPSE", COLLAPSE: "_COLLAPSE",
/**
* @static
* @property 下拉菜单切换展开收起事件
*/
TOGGLE: "_TOGGLE",
/** /**
* @static * @static
* @property 回调事件 * @property 回调事件

2
src/core/constant/var.js

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

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

@ -12,17 +12,25 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
this.showingTips = {};// 存储正在显示的tooltip 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({ return BI.createWidget({
type: "bi.tooltip", type: "bi.tooltip",
text: text, ...opt,
level: level,
stopEvent: true stopEvent: true
}); });
}, },
// opt: {container: '', belowMouse: false} // opt: {container: '', belowMouse: false}
show: function (e, name, text, level, context, opt) { show: function (e, name, tooltipOpt, context, opt) {
opt || (opt = {}); opt || (opt = {});
var self = this; var self = this;
BI.each(this.showingTips, function (i, tip) { BI.each(this.showingTips, function (i, tip) {
@ -30,7 +38,7 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
}); });
this.showingTips = {}; this.showingTips = {};
if (!this.has(name)) { if (!this.has(name)) {
this.create(name, text, level, opt.container || "body"); this.create(name, tooltipOpt, opt.container || "body");
} }
if (!opt.belowMouse) { if (!opt.belowMouse) {
var offset = context.element.offset(); var offset = context.element.offset();
@ -41,7 +49,6 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
var top = offset.top + bounds.height + 5; var top = offset.top + bounds.height + 5;
} }
var tooltip = this.get(name); var tooltip = this.get(name);
tooltip.setText(text);
tooltip.element.css({ tooltip.element.css({
left: "0px", left: "0px",
top: "0px" top: "0px"
@ -84,9 +91,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
return this; return this;
}, },
create: function (name, text, level, context) { create: function (name, tooltipOpt, context) {
if (!this.has(name)) { if (!this.has(name)) {
var tooltip = this._createTooltip(text, level); var tooltip = this._createTooltip(tooltipOpt);
this.add(name, tooltip); this.add(name, tooltip);
BI.createWidget({ BI.createWidget({
type: "bi.absolute", 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) { BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) { if (BI.isPlainObject(o)) {
var result = {}; var result = {};
_.each(o, function (v, k) { BI._.each(o, function (v, k) {
if (!(typeof v === "string")) { if (!(typeof v === "string")) {
v = BI.jsonEncode(v); v = BI.jsonEncode(v);
} }
@ -603,7 +603,7 @@
return new Date(o.__time__); return new Date(o.__time__);
} }
for (var a in o) { 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; break;
} }
o[a] = arguments.callee(o[a]); o[a] = arguments.callee(o[a]);

2
src/core/func/array.js

@ -2,7 +2,7 @@
* 对数组对象的扩展 * 对数组对象的扩展
* @class Array * @class Array
*/ */
_.extend(BI, { BI._.extend(BI, {
pushArray: function (sArray, array) { pushArray: function (sArray, array) {
for (var i = 0; i < array.length; i++) { 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.DAY = 24 * BI.Date.HOUR;
BI.Date.WEEK = 7 * BI.Date.DAY; BI.Date.WEEK = 7 * BI.Date.DAY;
_.extend(BI, { BI._.extend(BI, {
/** /**
* 获取时区 * 获取时区
* @returns {String} * @returns {String}

4
src/core/func/function.js

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

2
src/core/func/number.js

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

4
src/core/func/string.js

@ -2,7 +2,7 @@
* 对字符串对象的扩展 * 对字符串对象的扩展
* @class String * @class String
*/ */
_.extend(BI, { BI._.extend(BI, {
/** /**
* 判断字符串是否已指定的字符串开始 * 判断字符串是否已指定的字符串开始
@ -65,7 +65,7 @@ _.extend(BI, {
} else { } else {
src += "&"; src += "&";
} }
_.each(paras, function (value, name) { BI._.each(paras, function (value, name) {
if (typeof(name) === "string") { if (typeof(name) === "string") {
src += name + "=" + value + "&"; 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) { BI.Plugin.configWidget("bi.horizontal_sticky", function (ob) {
if (!isSupportSticky) { 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) { BI.Plugin.configWidget("bi.vertical_sticky", function (ob) {
if (!isSupportSticky) { 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 () { isIE: function () {
if(!_global.navigator) { if(!_global.navigator) {
return false; return false;

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

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

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

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

4
src/core/plugin.js

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

2
src/core/structure/aes.js

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

2
src/core/structure/base64.js

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

49
src/core/system.js

@ -19,6 +19,40 @@
TOAST_TOP: 10, TOAST_TOP: 10,
H_GAP_SIZE: "M", H_GAP_SIZE: "M",
V_GAP_SIZE: "S" 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,8 +63,7 @@
"L": 24 "L": 24
}; };
var provider = function () { function provider () {
this.SYSTEM = system; this.SYSTEM = system;
this.setSize = function (opt) { this.setSize = function (opt) {
@ -60,6 +93,10 @@
BI.extend(system.dependencies, moduleConfig); BI.extend(system.dependencies, moduleConfig);
}; };
this.setLoadingCreator = function(creator) {
system.loadingCreator = creator;
};
this.$get = function () { this.$get = function () {
return BI.inherit(BI.OB, { return BI.inherit(BI.OB, {
@ -88,13 +125,17 @@
getDependencies: function () { getDependencies: function () {
return system.dependencies; return system.dependencies;
},
getLoading: function(config) {
return system.loadingCreator(config);
} }
}); });
}; };
}; }
BI.provider("bi.provider.system", provider); BI.provider("bi.provider.system", provider);
})(); }());
BI.prepares.push(function () { BI.prepares.push(function () {
BI.SIZE_CONSANTS = BI.Providers.getProvider("bi.provider.system").getSize(); 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(); return arrRslt.join(splitChar || "").toLowerCase();
}; };
_.extend(BI, { BI._.extend(BI, {
makeFirstPY: function (str, options) { makeFirstPY: function (str, options) {
options = options || {}; options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}

2
src/core/utils/i18n.js

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

6
src/core/wrapper/layout.js

@ -224,14 +224,14 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
} }
} else { } else {
var keys = _.keys(a), key; var keys = BI._.keys(a), key;
length = keys.length; length = keys.length;
if (_.keys(b).length !== length) { if (BI._.keys(b).length !== length) {
return false; return false;
} }
while (length--) { while (length--) {
key = keys[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; return false;
} }
} }

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

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

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

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

20
src/less/resource/app.less

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

16
src/less/typographic.less

@ -19,6 +19,7 @@
overflow-x: hidden; overflow-x: hidden;
overflow-y: hidden; overflow-y: hidden;
} }
.overflow-dot() { .overflow-dot() {
text-overflow: ellipsis; text-overflow: ellipsis;
overflow-x: hidden; overflow-x: hidden;
@ -36,18 +37,9 @@
} }
.user-select-disable() { .user-select-disable() {
-webkit-user-select: none; .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() { .user-select-enable() {
-webkit-user-select: text; .user-select(text);
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
-o-user-select: text;
user-select: text;
} }

32
src/router/0.router.js

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

8
src/widget/editor/editor.text.js

@ -35,8 +35,8 @@ BI.TextEditor = BI.inherit(BI.Widget, {
} }
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.editor", type: "bi.editor",
element: this,
simple: o.simple, simple: o.simple,
height: o.height - border,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
lgap: o.lgap, lgap: o.lgap,
@ -116,12 +116,6 @@ BI.TextEditor = BI.inherit(BI.Widget, {
this.editor.on(BI.Editor.EVENT_EMPTY, function () { this.editor.on(BI.Editor.EVENT_EMPTY, function () {
self.fireEvent(BI.TextEditor.EVENT_EMPTY); self.fireEvent(BI.TextEditor.EVENT_EMPTY);
}); });
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
});
}, },
setWaterMark: function (v) { setWaterMark: function (v) {

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);

22
src/widget/multiselect/multiselect.combo.js

@ -173,7 +173,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
}, },
value: o.value, value: o.value,
hideChecker: function (e) { hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0 && self.numberCounter.element.find(e.target).length === 0; return self.numberCounter.element.find(e.target).length === 0;
}, },
}); });
@ -198,21 +198,6 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
} }
}); });
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
width: o.height,
height: o.height,
cls: "multi-select-trigger-icon-button",
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({ this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher", type: "bi.multi_select_check_selected_switcher",
masker: { masker: {
@ -263,11 +248,6 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}, {
el: triggerBtn,
right: 0,
top: 0,
bottom: 0,
}, { }, {
el: { el: {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",

23
src/widget/multiselect/multiselect.combo.nobar.js

@ -174,8 +174,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
value: o.value value: o.value
}, },
hideChecker: function (e) { hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0 && return self.numberCounter.element.find(e.target).length === 0;
self.numberCounter.element.find(e.target).length === 0;
} }
}); });
@ -200,21 +199,6 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
} }
}); });
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
width: o.height,
height: o.height,
cls: "multi-select-trigger-icon-button"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({ this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher", type: "bi.multi_select_check_selected_switcher",
masker: { masker: {
@ -268,11 +252,6 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0
}, {
el: triggerBtn,
right: 0,
top: 0,
bottom: 0
}, { }, {
el: { el: {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",

25
src/widget/multiselect/multiselect.loader.js

@ -17,6 +17,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
}, },
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
itemFormatter: BI.emptyFn,
onLoaded: BI.emptyFn, onLoaded: BI.emptyFn,
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}); });
@ -43,23 +44,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
el: BI.extend({ el: BI.extend({
onLoaded: opts.onLoaded, onLoaded: opts.onLoaded,
el: { el: {
type: "bi.loader", type: "bi.multi_select_inner_loader",
isDefaultInit: false,
logic: {
dynamic: true,
scrolly: true
},
el: {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
behaviors: {
redmark: function () {
return true;
}
},
layouts: [{
type: "bi.vertical"
}]
}
} }
}, opts.el), }, opts.el),
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
@ -78,7 +63,8 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
text: txt, text: txt,
value: v, value: v,
title: txt, title: txt,
selected: self.storeValue.type === BI.Selection.Multi selected: self.storeValue.type === BI.Selection.Multi,
...opts.itemFormatter(v),
}; };
}); });
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
@ -87,7 +73,8 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
text: txt, text: txt,
value: startValue, value: startValue,
title: txt, title: txt,
selected: true selected: true,
...opts.itemFormatter(startValue),
}); });
} }
firstItems = self._createItems(json); firstItems = self._createItems(json);

10
src/widget/multiselect/multiselect.trigger.js

@ -83,7 +83,15 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
el: this.wrapNumberCounter, el: this.wrapNumberCounter,
width: 0 width: 0
}, { }, {
el: BI.createWidget(), el: {
type: "bi.trigger_icon_button",
height: o.height,
stopPropagation: true,
cls: "multi-select-trigger-icon-button",
handler: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.TOGGLE);
}
},
width: 24 width: 24
}] }]
}); });

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

Loading…
Cancel
Save