guy 7 years ago
parent
commit
3cba004ef3
  1. 2
      Gruntfile.js
  2. 5
      demo/formula.js
  3. 48
      demo/js/base/demo.bubble.js
  4. 68
      demo/js/base/demo.button.js
  5. 33
      demo/js/base/demo.code_editor.js
  6. 96
      demo/js/base/demo.editor.js
  7. 21
      demo/js/base/demo.formula_editor.js
  8. 24
      demo/js/base/demo.icon_button.js
  9. 24
      demo/js/base/demo.image_button.js
  10. 138
      demo/js/base/demo.label.js
  11. 23
      demo/js/base/demo.message.js
  12. 26
      demo/js/base/demo.multifile_editor.js
  13. 23
      demo/js/base/demo.text_button.js
  14. 39
      demo/js/base/demo.textarea_editor.js
  15. 39
      demo/js/base/demo.title.js
  16. 55
      demo/js/base/demo.toast.js
  17. 307
      demo/js/config/base.js
  18. 2
      dist/base.css
  19. 40012
      dist/base.js
  20. 241
      dist/case.js
  21. 214
      dist/core.js
  22. 2
      src/base/formula/codemirror/addon/formula-hint.js
  23. 2
      src/base/formula/codemirror/addon/formula-mode.js
  24. 8736
      src/base/formula/codemirror/codemirror.js
  25. 4
      src/base/formula/config.js
  26. 437
      src/base/formula/formulaeditor.js
  27. 0
      src/base/single/tip/tip.bubble.js
  28. 0
      src/base/single/tip/tip.toast.js
  29. 0
      src/base/single/tip/tip.tooltip.js
  30. 6
      src/core/widget.js
  31. 2
      src/core/wrapper/layout.js
  32. 4
      src/core/wrapper/layout/adapt/absolute.center.js
  33. 4
      src/core/wrapper/layout/adapt/absolute.horizontal.js
  34. 4
      src/core/wrapper/layout/adapt/absolute.vertical.js
  35. 4
      src/core/wrapper/layout/adapt/adapt.center.js
  36. 4
      src/core/wrapper/layout/adapt/adapt.horizontal.js
  37. 26
      src/core/wrapper/layout/adapt/adapt.leftrightvertical.js
  38. 24
      src/core/wrapper/layout/adapt/adapt.vertical.js
  39. 4
      src/core/wrapper/layout/adapt/auto.horizontal.js
  40. 4
      src/core/wrapper/layout/adapt/float.center.js
  41. 4
      src/core/wrapper/layout/adapt/float.horizontal.js
  42. 4
      src/core/wrapper/layout/adapt/inline.center.js
  43. 4
      src/core/wrapper/layout/adapt/inline.vertical.js
  44. 4
      src/core/wrapper/layout/flex/flex.center.js
  45. 4
      src/core/wrapper/layout/flex/flex.horizontal.js
  46. 4
      src/core/wrapper/layout/flex/flex.vertical.center.js
  47. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js
  48. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js
  49. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js
  50. 4
      src/core/wrapper/layout/layout.absolute.js
  51. 4
      src/core/wrapper/layout/layout.adaptive.js
  52. 4
      src/core/wrapper/layout/layout.border.js
  53. 4
      src/core/wrapper/layout/layout.card.js
  54. 4
      src/core/wrapper/layout/layout.default.js
  55. 4
      src/core/wrapper/layout/layout.division.js
  56. 8
      src/core/wrapper/layout/layout.flow.js
  57. 4
      src/core/wrapper/layout/layout.grid.js
  58. 8
      src/core/wrapper/layout/layout.horizontal.js
  59. 4
      src/core/wrapper/layout/layout.inline.js
  60. 4
      src/core/wrapper/layout/layout.lattice.js
  61. 4
      src/core/wrapper/layout/layout.table.js
  62. 8
      src/core/wrapper/layout/layout.tape.js
  63. 4
      src/core/wrapper/layout/layout.td.js
  64. 4
      src/core/wrapper/layout/layout.vertical.js
  65. 4
      src/core/wrapper/layout/layout.window.js
  66. 4
      src/core/wrapper/layout/middle/middle.center.js
  67. 4
      src/core/wrapper/layout/middle/middle.float.center.js
  68. 4
      src/core/wrapper/layout/middle/middle.horizontal.js
  69. 4
      src/core/wrapper/layout/middle/middle.vertical.js
  70. 2
      src/css/base/single/button/button.css
  71. 2
      src/less/base/single/button/button.less
  72. 88
      src/third/codemirror/addon/formula-hint.js
  73. 80
      src/third/codemirror/addon/formula-mode.js
  74. 432
      src/third/codemirror/addon/show-hint.js

2
Gruntfile.js

@ -33,13 +33,13 @@ module.exports = function (grunt) {
//最基础的控件
baseJs: {
src: [
'src/third/codemirror/codemirror.js',
'src/third/**/*.js',
'src/base/pane.js',
'src/base/single/single.js',
'src/base/single/text.js',
'src/base/single/button/button.basic.js',
'src/base/single/button/button.node.js',
'src/base/single/tip/tip.js',
'src/base/combination/group.button.js',
'src/base/combination/tree.button.js',
'src/base/combination/map.button.js',

5
demo/formula.js

File diff suppressed because one or more lines are too long

48
demo/js/base/demo.bubble.js

@ -0,0 +1,48 @@
Demo.Bubble = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-bubble"
},
render: function () {
var items = [
{
el: {
type: 'bi.button',
text: 'bubble测试',
height : 30,
handler: function(){
BI.Bubbles.show("singleBubble1", "bubble测试", this);
}
}
}, {
el: {
type: 'bi.button',
text: 'bubble测试(居中显示)',
height : 30,
handler: function(){
BI.Bubbles.show("singleBubble2", "bubble测试", this, {
offsetStyle: "center"
});
}
}
}, {
el: {
type: 'bi.button',
text: 'bubble测试(右边显示)',
height : 30,
handler: function(){
BI.Bubbles.show("singleBubble3", "bubble测试", this, {
offsetStyle: "right"
});
}
}
}
];
return {
type: "bi.left",
vgap : 200,
hgap : 20,
items: items
}
}
});
$.shortcut("demo.bubble", Demo.Bubble);

68
demo/js/base/demo.button.js

@ -1,10 +1,74 @@
Demo.Button = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-face"
baseCls: "demo-button"
},
render: function () {
var items = [
{
el: {
type: 'bi.button',
text: '一般按钮',
level: 'common',
height: 30
}
}, {
el: {
type: 'bi.button',
text: '表示成功状态按钮',
level: 'success',
height: 30
}
},
{
el: {
type: 'bi.button',
text: '表示警告状态的按钮',
level: 'warning',
height: 30
}
}, {
el: {
type: 'bi.button',
text: '表示忽略状态的按钮',
level: 'ignore',
height: 30
}
}, {
el: {
type: 'bi.button',
text: '普通灰化按钮',
disabled: true,
level: 'success',
height: 30
}
}, {
el: {
type: 'bi.button',
text: '忽略状态灰化按钮',
disabled: true,
level: 'ignore',
height: 30
}
}, {
el: {
type: 'bi.button',
text: '带图标的按钮',
//level: 'ignore',
iconClass: "rename-font",
height: 30
}
}
];
BI.each(items, function (i, item) {
item.el.handler = function () {
BI.Msg.alert('按钮', this.options.text);
}
});
return {
type: "bi.vertical",
type: "bi.left",
vgap: 200,
hgap: 20,
items: items
}
}
});

33
demo/js/base/demo.code_editor.js

@ -0,0 +1,33 @@
Demo.CodeEditor = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-editor"
},
render: function () {
var editor = BI.createWidget({
type: "bi.code_editor",
cls: "mvc-border",
width: 600,
height: 400
});
BI.createWidget({
type: "bi.vertical",
element: this,
hgap: 30,
vgap: 20,
items: [editor, {
type: "bi.button",
text: "getValue",
handler: function () {
BI.Msg.toast(JSON.stringify(editor.getValue()));
}
}, {
type: "bi.button",
text: "setValue",
handler: function () {
editor.setValue("测试数据");
}
}]
})
}
});
$.shortcut("demo.code_editor", Demo.CodeEditor);

96
demo/js/base/demo.editor.js

@ -0,0 +1,96 @@
Demo.Editor = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-editor"
},
render: function () {
var editor1 = BI.createWidget({
type: "bi.editor",
cls: "mvc-border",
watermark: "alert信息显示在下面",
errorText: "字段不可重名!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
width: 200,
height: 30
});
editor1.on(BI.Editor.EVENT_ENTER, function () {
editor1.blur();
});
var editor2 = BI.createWidget({
type: "bi.editor",
cls: "mvc-border",
watermark: "输入'a'会有错误信息",
disabled: true,
errorText: "字段不可重名",
validationChecker: function (v) {
if (v == "a") {
return false;
}
return true;
},
allowBlank: true,
width: 200,
height: 30
});
var editor3 = BI.createWidget({
type: "bi.editor",
cls: "mvc-border",
watermark: "输入'a'会有错误信息且回车键不能退出编辑",
errorText: "字段不可重名",
validationChecker: function (v) {
if (v == "a") {
return false;
}
return true;
},
quitChecker: function (v) {
return false;
},
allowBlank: true,
width: 300,
height: 30
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: editor1,
left: 0,
top: 0
}, {
el: editor2,
left: 250,
top: 30
}, {
el: editor3,
left: 500,
top: 60
}, {
el: {
type: "bi.button",
text: "disable",
handler: function () {
editor1.setEnable(false);
editor2.setEnable(false);
editor3.setEnable(false);
},
height: 30
},
left: 100,
bottom: 60
}, {
el: {
type: "bi.button",
text: "enable",
handler: function () {
editor1.setEnable(true);
editor2.setEnable(true);
editor3.setEnable(true);
},
height: 30
},
left: 200,
bottom: 60
}]
})
}
});
$.shortcut("demo.editor", Demo.Editor);

21
demo/js/base/demo.formula_editor.js

@ -0,0 +1,21 @@
Demo.CodeEditor = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-editor"
},
render: function () {
this.formula = BI.createWidget({
type : 'bi.formula_editor',
width : 300,
height : 200,
value : 'SUM(C5, 16, 26)'
});
BI.createWidget({
type: "bi.left",
element: this,
items: [this.formula],
hgap: 20,
vgap: 20
})
}
});
$.shortcut("demo.formula_editor", Demo.CodeEditor);

24
demo/js/base/demo.icon_button.js

@ -0,0 +1,24 @@
Demo.Button = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-button"
},
render: function () {
var items = [
{
el: {
type: 'bi.icon_button',
cls: "rename-font",
width: 20,
height: 20
}
}
];
return {
type: "bi.left",
vgap: 200,
hgap: 20,
items: items
}
}
});
$.shortcut("demo.icon_button", Demo.Button);

24
demo/js/base/demo.image_button.js

@ -0,0 +1,24 @@
Demo.Button = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-button"
},
render: function () {
var items = [
{
el: {
type: 'bi.image_button',
src: "http://www.easyicon.net/api/resizeApi.php?id=1206741&size=128",
width: 100,
height: 100
}
}
];
return {
type: "bi.left",
vgap: 200,
hgap: 20,
items: items
}
}
});
$.shortcut("demo.image_button", Demo.Button);

138
demo/js/base/demo.label.js

@ -0,0 +1,138 @@
Demo.Label = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-label"
},
render: function () {
return {
type: "bi.vertical",
items: [{
type: "bi.label",
cls: "layout-bg6",
text: "这是一个label控件,默认居中",
textAlign: "center"
}, {
type: "bi.label",
cls: "layout-bg1",
text: "这是一个label控件, 高度为30,默认居中",
textAlign: "center",
height: 30
}, {
type: "bi.label",
cls: "layout-bg3",
text: "这是一个label控件,使用水平居左",
textAlign: "left",
height: 30
}, {
type: "bi.label",
cls: "layout-bg2",
text: "这是一个label控件,whiteSpace是normal,不设置高度,为了演示这个是真的是normal的,我凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数",
whiteSpace: "normal"
}, {
type: "bi.label",
cls: "layout-bg5",
text: "这是一个label控件,whiteSpace是默认的nowrap,不设置高度,为了演示这个是真的是nowrap的,我凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数"
}, {
type: "bi.label",
cls: "layout-bg7",
text: "这是一个label控件,whiteSpace是默认的nowrap,高度为30,为了演示这个是真的是nowrap的,我凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数",
height: 30
}, {
type: "bi.label",
cls: "layout-bg3",
text: "这是一个label控件,whiteSpace设置为normal,高度为60,为了演示这个是真的是normal的,我凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数",
whiteSpace: "normal",
height: 60
}, {
type: "bi.label",
cls: "layout-bg5",
text: "这是一个label控件,whiteSpace设置为normal,textHeight控制text的lineHeight,这样可以实现换行效果,我凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数",
whiteSpace: "normal",
textHeight: 30,
height: 60
}, {
type: "bi.label",
cls: "layout-bg1",
text: "这是一个label控件,whiteSpace设置为nowrap,textWidth控制text的width",
textWidth: 200,
height: 60
}, {
type: "bi.label",
cls: "layout-bg8",
text: "这是一个label控件,whiteSpace设置为normal,textWidth控制text的width,这样可以实现换行效果,我凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数,凑点字数",
whiteSpace: "normal",
textWidth: 200,
height: 60
}, {
type: "bi.label",
cls: "layout-bg7",
text: "whiteSpace为默认的nowrap,高度设置为60,宽度设置为300",
height: 60,
width: 300
}, {
type: "bi.label",
cls: "layout-bg6",
text: "设置了宽度300,高度60,whiteSpace设置为normal",
whiteSpace: "normal",
width: 300,
height: 60
}, {
type: "bi.label",
cls: "layout-bg8",
text: "textWidth设置为200,textHeight设置为30,width设置300,凑点字数看效果",
width: 300,
textWidth: 200,
textHeight: 30,
height: 60,
whiteSpace: "normal"
}, {
type: "bi.label",
cls: "layout-bg1",
text: "textWidth设置为200,width设置300,看下水平居左的换行效果",
textAlign: "left",
width: 300,
textWidth: 200,
textHeight: 30,
height: 60,
whiteSpace: "normal"
}, {
type: "bi.label",
cls: "layout-bg2",
text: "使用默认的nowrap,再去设置textHeight,只会有一行的效果",
textAlign: "left",
width: 300,
textWidth: 200,
textHeight: 30,
height: 60
}, {
type: "bi.left",
items: [{
type: "bi.label",
cls: "layout-bg3",
text: "在float布局中自适应的,不设高度和宽度,文字多长这个就有多长"
}],
height: 30
}, {
type: "bi.left",
items: [{
type: "bi.label",
cls: "layout-bg4",
text: "在float布局中自适应的,设置了宽度200,后面还有",
width: 200
}],
height: 30
}, {
type: "bi.left",
items: [{
type: "bi.label",
text: "在float布局中自适应的,设置了高度,文字多长这个就有多长",
cls: "layout-bg5",
height: 30
}],
height: 30
}],
hgap: 300,
vgap: 20
}
}
});
$.shortcut("demo.label", Demo.Label);

23
demo/js/base/demo.message.js

@ -0,0 +1,23 @@
Demo.Message = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-bubble"
},
render: function () {
return {
type: "bi.center_adapt",
items : [
{
el : {
type : 'bi.button',
text : '点击我弹出一个消息框',
height : 30,
handler : function() {
BI.Msg.alert('测试消息框', '我是测试消息框的内容');
}
}
}
]
}
}
});
$.shortcut("demo.message", Demo.Message);

26
demo/js/base/demo.multifile_editor.js

@ -0,0 +1,26 @@
Demo.CodeEditor = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-editor"
},
render: function () {
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.adaptive",
cls: "layout-bg1",
items: [{
type: "bi.multifile_editor",
width: 400,
height: 300
}],
width: 400,
height: 300
},
top: 50,
left: 50
}]
}
}
});
$.shortcut("demo.multifile_editor", Demo.CodeEditor);

23
demo/js/base/demo.text_button.js

@ -0,0 +1,23 @@
Demo.Button = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-button"
},
render: function () {
var items = [
{
el: {
type: 'bi.text_button',
text: '文字按钮',
height: 30
}
}
];
return {
type: "bi.left",
vgap: 200,
hgap: 20,
items: items
}
}
});
$.shortcut("demo.text_button", Demo.Button);

39
demo/js/base/demo.textarea_editor.js

@ -0,0 +1,39 @@
Demo.CodeEditor = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-editor"
},
render: function () {
var editor = BI.createWidget({
type: "bi.textarea_editor",
cls: "mvc-border",
width: 600,
height: 400
});
editor.on(BI.TextAreaEditor.EVENT_FOCUS, function () {
BI.Msg.toast("Focus");
});
editor.on(BI.TextAreaEditor.EVENT_BLUR, function () {
BI.Msg.toast("Blur");
});
BI.createWidget({
type: "bi.vertical",
element: this,
hgap: 30,
vgap: 20,
items: [editor, {
type: "bi.button",
text: "getValue",
handler: function () {
BI.Msg.toast(JSON.stringify(editor.getValue()));
}
}, {
type: "bi.button",
text: "setValue",
handler: function () {
editor.setValue("测试数据");
}
}]
})
}
});
$.shortcut("demo.textarea_editor", Demo.CodeEditor);

39
demo/js/base/demo.title.js

@ -0,0 +1,39 @@
Demo.Title = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-title"
},
render: function () {
return {
type: "bi.vertical",
items: [{
type: "bi.label",
cls: "layout-bg1",
height: 50,
title: "title提示",
text: "移上去有title提示",
textAlign: "center"
}, {
type: "bi.label",
cls: "layout-bg6",
height: 50,
disabled: true,
warningTitle: "title错误提示",
text: "移上去有title错误提示",
textAlign: "center"
}, {
type: "bi.label",
cls: "layout-bg2",
height: 50,
disabled: true,
tipType: "success",
title: "自定义title提示效果",
warningTitle: "自定义title提示效果",
text: "自定义title提示效果",
textAlign: "center"
}],
hgap: 300,
vgap: 20
}
}
});
$.shortcut("demo.title", Demo.Title);

55
demo/js/base/demo.toast.js

@ -0,0 +1,55 @@
Demo.Toast = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-toast"
},
render: function () {
var items = [
{
el: {
type: 'bi.button',
text: '简单Toast测试',
height : 30,
handler: function(){
BI.Msg.toast("这是一条简单的数据");
}
}
}, {
el: {
type: 'bi.button',
text: '很长的Toast测试',
height : 30,
handler: function(){
BI.Msg.toast("这是一条很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长的数据")
}
}
}, {
el: {
type: 'bi.button',
text: '非常长的Toast测试',
height : 30,
handler: function(){
BI.Msg.toast("这是一条非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长非常长的数据")
}
}
}, {
el: {
type: 'bi.button',
text: '错误提示Toast测试',
level: "warning",
height : 30,
handler: function(){
BI.Msg.toast("错误提示Toast测试", "warning");
}
}
}
];
BI.createWidget({
type: "bi.left",
element: this,
vgap : 200,
hgap : 20,
items: items
})
}
});
$.shortcut("demo.toast", Demo.Toast);

307
demo/js/config/base.js

@ -1,176 +1,199 @@
Demo.BASE_CONFIG = [{
id: 2,
text: "基础控件"
}, {
pId: 2,
id: 5,
text: "组合"
}, {
pId: 2,
id: 8,
text: "tree"
}, {
pId: 2,
id: 7,
text: "button"
}, {
pId: 2,
id: 9,
text: "listitem"
}, {
pId: 2,
id: 10,
text: "editor"
}, {
pId: 2,
text: "bi.canvas",
value: "demo.canvas"
text: "基础控件",
open: true,
}, {
pId: 2,
text: "bi.label",
value: "demo.label"
}, {
pId: 2,
text: "bi.collection",
value: "demo.collection"
text: "title提示",
value: "demo.title"
}, {
pId: 2,
text: "bi.farbtastic",
value: "demo.farbtastic"
text: "气泡提示",
value: "demo.bubble"
}, {
pId: 2,
text: "bi.formulaeditor",
value: "demo.formulaeditor"
text: "toast提示",
value: "demo.toast"
}, {
pId: 2,
text: "bi.message",
text: "message提示",
value: "demo.message"
}, {
pId: 2,
text: "bi.grid_view",
value: "demo.grid_view"
}, {
pId: 2,
id: 6,
text: "弹出层"
}, {
pId: 2,
text: "bi.pager",
value: "demo.pager"
}, {
pId: 2,
text: "bi.svg",
value: "demo.svg"
}, {
pId: 2,
text: "bi.table",
value: "demo.table"
}, {
pId: 5,
text: "bi.combo",
value: "demo.combo"
}, {
pId: 5,
text: "bi.expander",
value: "demo.expander"
}, {
pId: 5,
text: "bi.group_button",
value: "demo.group_button"
}, {
pId: 5,
text: "bi.group_combo",
value: "demo.group_combo"
}, {
pId: 5,
text: "bi.loader",
value: "demo.loader"
}, {
pId: 5,
text: "bi.navigation",
value: "demo.navigation"
}, {
pId: 5,
text: "bi.searcher",
value: "demo.searcher"
}, {
pId: 5,
text: "bi.switcher",
value: "demo.switcher"
}, {
pId: 5,
text: "bi.tab",
value: "demo.tab"
}, {
pId: 5,
text: "bi.tree_button",
value: "demo.tree_button"
}, {
pId: 6,
text: "bi.layer_float_box",
value: "demo.layer_float_box"
}, {
pId: 6,
text: "bi.layer_popup",
value: "demo.layer_popup"
}, {
pId: 6,
text: "bi.layer_scroll",
value: "demo.layer_scroll"
}, {
pId: 6,
text: "bi.layer_searcher",
value: "demo.layer_searcher"
}, {
pId: 7,
text: "bi.icon_button",
value: "demo.icon_button"
}, {
pId: 7,
text: "bi.image_button",
value: "demo.image_button"
id: 201,
text: "button"
}, {
pId: 7,
pId: 201,
text: "bi.button",
value: "demo.button"
}, {
pId: 7,
pId: 201,
text: "bi.text_button",
value: "demo.text_button"
}, {
pId: 8,
text: "bi.treeview",
value: "demo.treeview"
}, {
pId: 8,
text: "bi.synctree",
value: "demo.synctree"
pId: 201,
text: "bi.icon_button",
value: "demo.icon_button"
}, {
pId: 8,
text: "bi.parttree",
value: "demo.parttree"
pId: 201,
text: "bi.image_button",
value: "demo.image_button"
}, {
pId: 8,
text: "bi.customtree",
value: "demo.customtree"
pId: 2,
id: 202,
text: "editor"
}, {
pId: 9,
text: "bi.list_items",
value: "demo.list_items"
pId: 202,
text: "bi.editor",
value: "demo.editor"
}, {
pId: 10,
pId: 202,
text: "bi.code_editor",
value: "demo.code_editor"
}, {
pId: 10,
text: "bi.editor",
value: "demo.editor"
}, {
pId: 10,
pId: 202,
text: "bi.multifile_editor",
value: "demo.multifile_editor"
}, {
pId: 10,
text: "bi.text_area_editor",
value: "demo.text_area_editor"
}];
pId: 202,
text: "bi.textarea_editor",
value: "demo.textarea_editor"
}, {
pId: 202,
text: "bi.formula_editor",
value: "demo.formula_editor"
},
{
pId: 2,
id: 5,
text: "组合控件"
}, {
pId: 2,
id: 8,
text: "树控件"
}, {
pId: 2,
id: 7,
text: "按钮"
}, {
pId: 2,
id: 9,
text: "listitem"
}, {
pId: 2,
text: "bi.canvas",
value: "demo.canvas"
}, {
pId: 2,
text: "bi.collection",
value: "demo.collection"
}, {
pId: 2,
text: "bi.farbtastic",
value: "demo.farbtastic"
}, {
pId: 2,
text: "bi.message",
value: "demo.message"
}, {
pId: 2,
text: "bi.grid_view",
value: "demo.grid_view"
}, {
pId: 2,
id: 6,
text: "弹出层"
}, {
pId: 2,
text: "bi.pager",
value: "demo.pager"
}, {
pId: 2,
text: "bi.svg",
value: "demo.svg"
}, {
pId: 2,
text: "bi.table",
value: "demo.table"
}, {
pId: 5,
text: "bi.combo",
value: "demo.combo"
}, {
pId: 5,
text: "bi.expander",
value: "demo.expander"
}, {
pId: 5,
text: "bi.group_button",
value: "demo.group_button"
}, {
pId: 5,
text: "bi.group_combo",
value: "demo.group_combo"
}, {
pId: 5,
text: "bi.loader",
value: "demo.loader"
}, {
pId: 5,
text: "bi.navigation",
value: "demo.navigation"
}, {
pId: 5,
text: "bi.searcher",
value: "demo.searcher"
}, {
pId: 5,
text: "bi.switcher",
value: "demo.switcher"
}, {
pId: 5,
text: "bi.tab",
value: "demo.tab"
}, {
pId: 5,
text: "bi.tree_button",
value: "demo.tree_button"
}, {
pId: 6,
text: "bi.layer_float_box",
value: "demo.layer_float_box"
}, {
pId: 6,
text: "bi.layer_popup",
value: "demo.layer_popup"
}, {
pId: 6,
text: "bi.layer_scroll",
value: "demo.layer_scroll"
}, {
pId: 6,
text: "bi.layer_searcher",
value: "demo.layer_searcher"
}, {
pId: 8,
text: "bi.treeview",
value: "demo.treeview"
}, {
pId: 8,
text: "bi.synctree",
value: "demo.synctree"
}, {
pId: 8,
text: "bi.parttree",
value: "demo.parttree"
}, {
pId: 8,
text: "bi.customtree",
value: "demo.customtree"
}, {
pId: 9,
text: "bi.list_items",
value: "demo.list_items"
},];

2
dist/base.css vendored

@ -812,7 +812,7 @@ li.CodeMirror-hint-active {
background-color: #009de3;
text-align: center;
vertical-align: middle;
cursor: pointer !important;
cursor: pointer;
font-size: 14px;
}
.bi-button.button-common,

40012
dist/base.js vendored

File diff suppressed because it is too large Load Diff

241
dist/case.js vendored

@ -8171,247 +8171,6 @@ BI.extend(BI.TableTree, {
});
$.shortcut("bi.table_tree", BI.TableTree);/**
* guy
* 气泡提示
* @class BI.Bubble
* @extends BI.Tip
* @type {*|void|Object}
*/
BI.Bubble = BI.inherit(BI.Tip, {
_defaultConfig: function() {
return BI.extend(BI.Bubble.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-bubble",
direction: "top",
text: "",
height: 35
})
},
_init : function() {
BI.Bubble.superclass._init.apply(this, arguments);
var fn = function (e) {
e.stopPropagation();
e.stopEvent();
return false;
};
this.element.bind({"click": fn, "mousedown": fn, "mouseup": fn, "mouseover": fn, "mouseenter": fn, "mouseleave": fn, "mousemove": fn});
BI.createWidget({
type: "bi.left",
element: this,
items: [this["_" + this.options.direction]()]
})
},
_createBubbleText: function(){
return (this.text = BI.createWidget({
type: "bi.label",
cls: "bubble-text",
text: this.options.text,
hgap: 10,
height: 30
}));
},
_top: function(){
return BI.createWidget({
type: "bi.vertical",
items: [{
el: this._createBubbleText(),
height: 30
}, {
el: {
type: "bi.layout"
},
height: 3
}]
})
},
_bottom: function(){
return BI.createWidget({
type: "bi.vertical",
items: [{
el: {
type: "bi.layout"
},
height: 3
}, {
el: this._createBubbleText(),
height: 30
}]
})
},
_left: function(){
return BI.createWidget({
type: "bi.right",
items: [{
el: {
type: "bi.layout",
width: 3,
height: 30
}
}, {
el: this._createBubbleText()
}]
})
},
_right: function(){
return BI.createWidget({
type: "bi.inline",
items: [{
el: {
type: "bi.layout",
width: 3,
height: 30
}
}, {
el: this._createBubbleText()
}]
})
},
setText: function(text){
this.text.setText(text);
}
});
$.shortcut("bi.bubble", BI.Bubble);/**
* toast提示
*
* Created by GUY on 2015/9/7.
* @class BI.Toast
* @extends BI.Tip
*/
BI.Toast = BI.inherit(BI.Tip, {
_const: {
minWidth: 200,
hgap: 20
},
_defaultConfig: function () {
return BI.extend(BI.Toast.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-toast",
text: "",
level: "success",//success或warning
height: 30
})
},
_init: function () {
BI.Toast.superclass._init.apply(this, arguments);
var o = this.options;
this.element.css({
minWidth: this._const.minWidth + "px"
})
this.element.addClass("toast-" + o.level);
var fn = function (e) {
e.stopPropagation();
e.stopEvent();
return false;
};
this.element.bind({"click": fn, "mousedown": fn, "mouseup": fn, "mouseover": fn, "mouseenter": fn, "mouseleave": fn, "mousemove": fn});
this.text = BI.createWidget({
type: "bi.label",
element: this,
text: o.text,
height: 30,
hgap: this._const.hgap
})
},
setWidth: function(width){
this.element.width(width);
},
setText: function (text) {
this.text.setText(text);
}
});
$.shortcut("bi.toast", BI.Toast);/**
* toast提示
*
* Created by GUY on 2015/9/7.
* @class BI.Tooltip
* @extends BI.Tip
*/
BI.Tooltip = BI.inherit(BI.Tip, {
_const: {
hgap: 10
},
_defaultConfig: function () {
return BI.extend(BI.Tooltip.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-tooltip",
text: "",
level: "success",//success或warning
height: 20
})
},
_init: function () {
BI.Tooltip.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.element.addClass("tooltip-" + o.level);
var fn = function (e) {
e.stopPropagation();
e.stopEvent();
return false;
};
this.element.bind({
"click": fn,
"mousedown": fn,
"mouseup": fn,
"mouseover": fn,
"mouseenter": fn,
"mouseleave": fn,
"mousemove": fn
});
var texts = (o.text + "").split("\n");
if (texts.length > 1) {
BI.createWidget({
type: "bi.vertical",
element: this,
hgap: this._const.hgap,
items: BI.map(texts, function (i, text) {
return {
type: "bi.label",
textAlign: "left",
whiteSpace: "normal",
text: text,
textHeight: 16
}
})
})
} else {
this.text = BI.createWidget({
type: "bi.label",
element: this,
textAlign: "left",
whiteSpace: "normal",
text: o.text,
textHeight: 20,
hgap: this._const.hgap
});
}
},
setWidth: function (width) {
this.element.width(width - 2 * this._const.hgap);
},
setText: function (text) {
this.text && this.text.setText(text);
},
setLevel: function (level) {
this.element.removeClass("tooltip-success").removeClass("tooltip-warning");
this.element.addClass("tooltip-" + level);
}
});
$.shortcut("bi.tooltip", BI.Tooltip);/**
* guy
* 复选导航条
* Created by GUY on 2015/8/25.

214
dist/core.js vendored

@ -14434,9 +14434,9 @@ BI.Widget = BI.inherit(BI.OB, {
})
})
}
if (this._isRoot === true || !(this instanceof BI.Layout)) {
this._mount();
}
// if (this._isRoot === true || !(this instanceof BI.Layout)) {
this._mount();
// }
},
_setParent: function (parent) {
@ -19275,7 +19275,7 @@ BI.Layout = BI.inherit(BI.Widget, {
};
},
created: function () {
render: function () {
this._init4Margin();
this._init4Scroll();
},
@ -24805,8 +24805,8 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.AbsoluteCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -24851,8 +24851,8 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.AbsoluteHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteHorizontalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -24901,8 +24901,8 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.AbsoluteVerticalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteVerticalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -24953,8 +24953,8 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.CenterAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.CenterAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",
@ -25076,8 +25076,8 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",
@ -25200,8 +25200,8 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
rhgap: 0
});
},
created: function () {
BI.LeftRightVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -25266,8 +25266,8 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
hgap: 0
});
},
created: function () {
BI.LeftVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.LeftVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -25280,8 +25280,7 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
throw new Error("不能添加元素")
},
populate: function (items) {
BI.LeftVerticalAdaptLayout.superclass.populate.apply(this, arguments);
stroke: function (items) {
var o = this.options;
var left = BI.createWidget({
type: "bi.vertical_adapt",
@ -25296,6 +25295,10 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
element: this,
items: [left]
});
},
populate: function (items) {
BI.LeftVerticalAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
@ -25311,8 +25314,8 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
hgap: 0
});
},
created: function () {
BI.RightVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.RightVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -25325,8 +25328,7 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
throw new Error("不能添加元素")
},
populate: function (items) {
BI.RightVerticalAdaptLayout.superclass.populate.apply(this, arguments);
stroke: function (items) {
var o = this.options;
var right = BI.createWidget({
type: "bi.vertical_adapt",
@ -25341,6 +25343,10 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
element: this,
items: [right]
});
},
populate: function (items) {
BI.RightVerticalAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
@ -25350,20 +25356,18 @@ $.shortcut('bi.right_vertical_adapt', BI.RightVerticalAdaptLayout);/**
* @extends BI.Layout
*/
BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
_defaultConfig: function () {
return BI.extend(BI.VerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-vertical-adapt-layout",
columnSize: [],
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
props: {
baseCls: "bi-vertical-adapt-layout",
columnSize: [],
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
},
_init: function () {
BI.VerticalAdaptLayout.superclass._init.apply(this, arguments);
render: function () {
BI.VerticalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"height": "100%",
@ -25483,8 +25487,8 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.HorizontalAutoLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalAutoLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -25543,8 +25547,8 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
rgap: 0
});
},
created: function () {
BI.FloatCenterAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatCenterAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -25611,8 +25615,8 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
rgap: 0
});
},
created: function () {
BI.FloatHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatHorizontalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -25680,8 +25684,8 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.InlineCenterAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.InlineCenterAdaptLayout.superclass.render.apply(this, arguments);
this.element.css({
whiteSpace: "nowrap"
});
@ -25777,8 +25781,8 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.InlineVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.InlineVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.element.css({
whiteSpace: "nowrap"
});
@ -25840,8 +25844,8 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
baseCls: "bi-flex-center-layout"
});
},
created: function () {
BI.FlexCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -25883,8 +25887,8 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexHorizontalLayout.superclass.render.apply(this, arguments);
var o = this.options;
this.element.addClass(o.verticalAlign);
this.populate(this.options.items);
@ -25946,8 +25950,8 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexVerticalCenter.superclass.created.apply(this, arguments);
render: function () {
BI.FlexVerticalCenter.superclass.render.apply(this, arguments);
var o = this.options;
this.populate(this.options.items);
},
@ -26001,8 +26005,8 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
baseCls: "bi-flex-wrapper-center-layout clearfix"
});
},
created: function () {
BI.FlexCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexCenterLayout.superclass.render.apply(this, arguments);
this.$wrapper = $("<div>").addClass("flex-wrapper-center-layout-wrapper");
this.populate(this.options.items);
},
@ -26069,8 +26073,8 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexHorizontalLayout.superclass.render.apply(this, arguments);
var o = this.options;
this.$wrapper = $("<div>").addClass("flex-wrapper-horizontal-layout-wrapper " + o.verticalAlign);
this.populate(this.options.items);
@ -26156,8 +26160,8 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexVerticalCenter.superclass.created.apply(this, arguments);
render: function () {
BI.FlexVerticalCenter.superclass.render.apply(this, arguments);
var o = this.options;
this.$wrapper = $("<div>").addClass("flex-wrapper-vertical-center-wrapper");
this.populate(this.options.items);
@ -26239,8 +26243,8 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
bgap: null
});
},
created: function () {
BI.AbsoluteLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -26340,8 +26344,8 @@ $.shortcut('bi.absolute', BI.AbsoluteLayout);BI.AdaptiveLayout = BI.inherit(BI.L
bgap: null
});
},
created: function () {
BI.AdaptiveLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AdaptiveLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -26432,8 +26436,8 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
items: {}
});
},
created: function () {
BI.BorderLayout.superclass.created.apply(this, arguments);
render: function () {
BI.BorderLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -26565,8 +26569,8 @@ BI.CardLayout = BI.inherit(BI.Layout, {
items: []
});
},
created: function () {
BI.CardLayout.superclass.created.apply(this, arguments);
render: function () {
BI.CardLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -26729,8 +26733,8 @@ BI.DefaultLayout = BI.inherit(BI.Layout, {
items: []
});
},
created: function () {
BI.DefaultLayout.superclass.created.apply(this, arguments);
render: function () {
BI.DefaultLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -26807,8 +26811,8 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
//]
});
},
created: function () {
BI.DivisionLayout.superclass.created.apply(this, arguments);
render: function () {
BI.DivisionLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -26946,8 +26950,8 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FloatLeftLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatLeftLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -27011,8 +27015,8 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FloatRightLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatRightLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -27085,8 +27089,8 @@ BI.GridLayout = BI.inherit(BI.Layout, {
]*/
});
},
created: function () {
BI.GridLayout.superclass.created.apply(this, arguments);
render: function () {
BI.GridLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -27199,8 +27203,8 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"white-space": "nowrap",
@ -27321,8 +27325,8 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalCellLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalCellLayout.superclass.render.apply(this, arguments);
this.element.css({"display": "table", "vertical-align": "top"});
this.populate(this.options.items);
},
@ -27384,8 +27388,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.InlineLayout.superclass.created.apply(this, arguments);
render: function () {
BI.InlineLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -27441,8 +27445,8 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
//columnSize: [0.2, 0.2, 0.6],
});
},
created: function () {
BI.LatticeLayout.superclass.created.apply(this, arguments);
render: function () {
BI.LatticeLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -27501,8 +27505,8 @@ BI.TableLayout = BI.inherit(BI.Layout, {
]]
});
},
created: function () {
BI.TableLayout.superclass.created.apply(this, arguments);
render: function () {
BI.TableLayout.superclass.render.apply(this, arguments);
this.rows = 0;
this.populate(this.options.items);
},
@ -27649,8 +27653,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
]
});
},
created: function () {
BI.HTapeLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HTapeLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -27753,8 +27757,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
]
});
},
created: function () {
BI.VTapeLayout.superclass.created.apply(this, arguments);
render: function () {
BI.VTapeLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -27850,8 +27854,8 @@ BI.TdLayout = BI.inherit(BI.Layout, {
]]
});
},
created: function () {
BI.TdLayout.superclass.created.apply(this, arguments);
render: function () {
BI.TdLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",
@ -27984,8 +27988,8 @@ BI.VerticalLayout = BI.inherit(BI.Layout, {
scrolly: true
});
},
created: function () {
BI.VerticalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.VerticalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -28059,8 +28063,8 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
]]
});
},
created: function () {
BI.WindowLayout.superclass.created.apply(this, arguments);
render: function () {
BI.WindowLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -28232,8 +28236,8 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.CenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.CenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -28305,8 +28309,8 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FloatCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -28378,8 +28382,8 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -28450,8 +28454,8 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.VerticalCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.VerticalCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

2
src/base/formula/codemirror/addon/formula-hint.js vendored

@ -55,7 +55,7 @@
}
function getFormulaKeywords() {
return FormulaCollections;
return BI.FormulaCollections;
}
function formulaHint(editor, options) {

2
src/base/formula/codemirror/addon/formula-mode.js vendored

@ -11,7 +11,7 @@
}
var atoms = wordObj(['false', 'true']);
var keywords = wordObj(FormulaCollections);
var keywords = wordObj(BI.FormulaCollections);
function tokenBase(stream, state) {
if (stream.eatSpace()) {

8736
src/base/formula/codemirror/codemirror.js

File diff suppressed because it is too large Load Diff

4
src/base/formula/config.js

@ -0,0 +1,4 @@
/**
* Created by User on 2017/3/21.
*/
BI.FormulaCollections = ["abs","ABS","acos","ACOS","acosh","ACOSH","add2array","ADD2ARRAY","and","AND","array","ARRAY","asin","ASIN","asinh","ASINH","atan","ATAN","atan2","ATAN2","atanh","ATANH","average","AVERAGE","bitnot","BITNOT","bitoperation","BITOPERATION","ceiling","CEILING","char","CHAR","circular","CIRCULAR","class","CLASS","cnmoney","CNMONEY","code","CODE","col","COL","colcount","COLCOUNT","colname","COLNAME","combin","COMBIN","concatenate","CONCATENATE","correl","CORREL","cos","COS","cosh","COSH","count","COUNT","crosslayertotal","CROSSLAYERTOTAL","date","DATE","datedelta","DATEDELTA","datedif","DATEDIF","dateinmonth","DATEINMONTH","dateinquarter","DATEINQUARTER","dateinweek","DATEINWEEK","dateinyear","DATEINYEAR","datesubdate","DATESUBDATE","datetime","DATETIME","datetonumber","DATETONUMBER","day","DAY","days360","DAYS360","daysofmonth","DAYSOFMONTH","daysofquarter","DAYSOFQUARTER","daysofyear","DAYSOFYEAR","dayvalue","DAYVALUE","decimal","DECIMAL","decode","DECODE","degrees","DEGREES","encode","ENCODE","endwith","ENDWITH","enmoney","ENMONEY","ennumber","ENNUMBER","eval","EVAL","even","EVEN","exact","EXACT","exp","EXP","fact","FACT","fields","FIELDS","filename","FILENAME","filesize","FILESIZE","filetype","FILETYPE","find","FIND","floor","FLOOR","format","FORMAT","getuserdepartments","GETUSERDEPARTMENTS","getuserjobtitles","GETUSERJOBTITLES","greparray","GREPARRAY","hierarchy","HIERARCHY","hour","HOUR","i18n","I18N","if","IF","inarray","INARRAY","index","INDEX","indexof","INDEXOF","indexofarray","INDEXOFARRAY","int","INT","isnull","ISNULL","joinarray","JOINARRAY","jvm","JVM","layertotal","LAYERTOTAL","left","LEFT","len","LEN","let","LET","ln","LN","log","LOG","log10","LOG10","lower","LOWER","lunar","LUNAR","map","MAP","maparray","MAPARRAY","max","MAX","median","MEDIAN","mid","MID","min","MIN","minute","MINUTE","mod","MOD","mom","MOM","month","MONTH","monthdelta","MONTHDELTA","now","NOW","numto","NUMTO","nvl","NVL","odd","ODD","or","OR","pi","PI","power","POWER","product","PRODUCT","promotion","PROMOTION","proper","PROPER","proportion","PROPORTION","radians","RADIANS","rand","RAND","randbetween","RANDBETWEEN","range","RANGE","rank","RANK","records","RECORDS","regexp","REGEXP","removearray","REMOVEARRAY","repeat","REPEAT","replace","REPLACE","reverse","REVERSE","reversearray","REVERSEARRAY","right","RIGHT","round","ROUND","round5","ROUND5","rounddown","ROUNDDOWN","roundup","ROUNDUP","row","ROW","rowcount","ROWCOUNT","second","SECOND","seq","SEQ","sign","SIGN","sin","SIN","sinh","SINH","slicearray","SLICEARRAY","sort","SORT","sortarray","SORTARRAY","split","SPLIT","sql","SQL","sqrt","SQRT","startwith","STARTWITH","stdev","STDEV","substitute","SUBSTITUTE","sum","SUM","sumsq","SUMSQ","switch","SWITCH","tabledatafields","TABLEDATAFIELDS","tabledatas","TABLEDATAS","tables","TABLES","tan","TAN","tanh","TANH","time","TIME","tobigdecimal","TOBIGDECIMAL","tobinary","TOBINARY","todate","TODATE","today","TODAY","todouble","TODOUBLE","tohex","TOHEX","toimage","TOIMAGE","tointeger","TOINTEGER","tooctal","TOOCTAL","totext","TOTEXT","treelayer","TREELAYER","trim","TRIM","trunc","TRUNC","uniquearray","UNIQUEARRAY","upper","UPPER","uuid","UUID","value","VALUE","webimage","WEBIMAGE","week","WEEK","weekdate","WEEKDATE","weekday","WEEKDAY","weightedaverage","WEIGHTEDAVERAGE","year","YEAR","yeardelta","YEARDELTA"];

437
src/base/formula/formulaeditor.js

@ -1,235 +1,232 @@
;
(function ($) {
/**
* 公式编辑控件
* @class BI.FormulaEditor
* @extends BI.Widget
*/
BI.FormulaEditor = BI.inherit(BI.Single, {
_defaultConfig: function () {
return $.extend(BI.FormulaEditor.superclass._defaultConfig.apply(), {
baseCls: 'bi-formula-editor',
watermark: '',
value: '',
fieldTextValueMap: {},
showHint: true
});
},
_init: function () {
BI.FormulaEditor.superclass._init.apply(this, arguments);
var o = this.options, self = this;
this.editor = CodeMirror(this.element[0], {
textWrapping: true,
lineWrapping: true,
lineNumbers: false,
mode: 'formula'
});
this.editor.on("change", function (cm, change) {
self._checkWaterMark();
if(o.showHint){
CodeMirror.showHint(cm, CodeMirror.formulaHint, {completeSingle: false});
}
BI.nextTick(function () {
self.fireEvent(BI.FormulaEditor.EVENT_CHANGE)
});
/**
* 公式编辑控件
* @class BI.FormulaEditor
* @extends BI.Widget
*/
BI.FormulaEditor = BI.inherit(BI.Single, {
_defaultConfig: function () {
return $.extend(BI.FormulaEditor.superclass._defaultConfig.apply(), {
baseCls: 'bi-formula-editor',
watermark: '',
value: '',
fieldTextValueMap: {},
showHint: true
});
},
_init: function () {
BI.FormulaEditor.superclass._init.apply(this, arguments);
var o = this.options, self = this;
this.editor = CodeMirror(this.element[0], {
textWrapping: true,
lineWrapping: true,
lineNumbers: false,
mode: 'formula'
});
this.editor.on("change", function (cm, change) {
self._checkWaterMark();
if (o.showHint) {
CodeMirror.showHint(cm, CodeMirror.formulaHint, {completeSingle: false});
}
BI.nextTick(function () {
self.fireEvent(BI.FormulaEditor.EVENT_CHANGE)
});
});
this.editor.on("focus", function () {
self._checkWaterMark();
self.fireEvent(BI.FormulaEditor.EVENT_FOCUS);
});
this.editor.on("focus", function () {
self._checkWaterMark();
self.fireEvent(BI.FormulaEditor.EVENT_FOCUS);
});
this.editor.on("blur", function () {
self.fireEvent(BI.FormulaEditor.EVENT_BLUR);
});
this.editor.on("blur", function () {
self.fireEvent(BI.FormulaEditor.EVENT_BLUR);
});
if (BI.isKey(o.value)) {
self.setValue(o.value);
}
if (BI.isKey(o.value)) {
self.setValue(o.value);
}
if (BI.isKey(this.options.watermark)) {
var self = this;
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
whiteSpace: "nowrap",
textAlign: "left"
});
BI.createWidget({
type: "bi.absolute",
element: self,
items: [{
el: self.watermark,
left: 0,
top: 0
}]
});
if (BI.isKey(this.options.watermark)) {
var self = this;
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
whiteSpace: "nowrap",
textAlign: "left"
});
BI.createWidget({
type: "bi.absolute",
element: self,
items: [{
el: self.watermark,
left: 0,
top: 0
}]
});
this.watermark.element.bind(
"mousedown", function (e) {
self.insertString("");
self.editor.focus();
e.stopEvent();
}
);
this.watermark.element.bind("click", function (e) {
this.watermark.element.bind(
"mousedown", function (e) {
self.insertString("");
self.editor.focus();
e.stopEvent();
});
this.watermark.element.css({
position: "absolute",
left: 3,
right: 3,
top: 6,
bottom: 0
});
}
},
_checkWaterMark: function () {
var o = this.options;
if (!this.disabledWarterMark && BI.isEmptyString(this.editor.getValue()) && BI.isKey(o.watermark)) {
this.watermark && this.watermark.visible();
} else {
this.watermark && this.watermark.invisible();
}
},
disableWarterMark: function () {
this.disabledWarterMark = true;
this._checkWaterMark();
},
focus: function() {
this.editor.focus();
},
/**
* 添加字段
* @param field
*/
insertField: function (field) {
var from = this.editor.getCursor();
this.editor.replaceSelection(field);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: 'fieldName', atomic: true, startStyle : "start", endStyle:"end"});
this.editor.replaceSelection(" ");
this.editor.focus();
},
insertFunction: function (fn) {
var from = this.editor.getCursor();
this.editor.replaceSelection(fn);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: "#function", atomic: true});
this.editor.replaceSelection("() ");
to = this.editor.getCursor();
to.ch = to.ch - 2;
this.editor.setCursor(to);
this.editor.focus();
},
insertOperator: function (op) {
var from = this.editor.getCursor();
this.editor.replaceSelection(op);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: "%operator", atomic: true});
this.editor.replaceSelection(" ");
this.editor.focus();
},
setFunction: function (v) {
var from = this.editor.getCursor();
this.editor.replaceSelection(v);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: "#function", atomic: true});
},
insertString: function (str) {
this.editor.replaceSelection(str);
this.editor.focus();
},
getFormulaString: function () {
return this.editor.getValue();
},
getUsedFields: function () {
var fieldMap = this.options.fieldTextValueMap;
var fields = [];
this.editor.getValue(true, function (line) {
var value = line.text;
_.forEach(line.markedSpans, function (i, ms) {
switch (i.marker.className) {
case "fieldName":
var dId = fieldMap[value.substr(i.from, i.to - i.from)];
if (!fields.contains(dId)) {
fields.push(dId);
}
}
});
});
return fields;
},
getCheckString: function () {
return this.editor.getValue(true, function (line) {
var rawText = line.text, value = line.text, num = 0;
value.text = rawText;
_.forEach(line.markedSpans, function (i, ms) {
switch (i.marker.className) {
case "fieldName":
var fieldNameLength = i.to - i.from;
value = value.substr(0, i.from + num) + "$a" + value.substr(i.to + num, value.length);
num = num + 2 - fieldNameLength;
break;
}
});
return value;
}
);
this.watermark.element.bind("click", function (e) {
self.editor.focus();
e.stopEvent();
});
},
getValue: function () {
var fieldMap = this.options.fieldTextValueMap;
return this.editor.getValue("\n", function (line) {
var rawText = line.text, value = line.text, num = 0;
value.text = rawText;
_.forEach(line.markedSpans, function (i, ms) {
switch (i.marker.className) {
case "fieldName":
var fieldNameLength = i.to - i.from;
var fieldId = fieldMap[value.substr(i.from + num, fieldNameLength)];
value = value.substr(0, i.from + num) + "$\{" + fieldMap[value.substr(i.from + num, fieldNameLength)] + "\}" + value.substr(i.to + num, value.length);
num += fieldId.length - fieldNameLength + 3;
break;
}
});
return value;
this.watermark.element.css({
position: "absolute",
left: 3,
right: 3,
top: 6,
bottom: 0
});
},
}
},
_checkWaterMark: function () {
var o = this.options;
if (!this.disabledWarterMark && BI.isEmptyString(this.editor.getValue()) && BI.isKey(o.watermark)) {
this.watermark && this.watermark.visible();
} else {
this.watermark && this.watermark.invisible();
}
},
setValue: function (value) {
this.editor.setValue(value);
},
disableWarterMark: function () {
this.disabledWarterMark = true;
this._checkWaterMark();
},
setFieldTextValueMap: function (fieldTextValueMap) {
this.options.fieldTextValueMap = fieldTextValueMap;
},
focus: function () {
this.editor.focus();
},
refresh: function () {
var self = this;
BI.nextTick(function () {
self.editor.refresh();
/**
* 添加字段
* @param field
*/
insertField: function (field) {
var from = this.editor.getCursor();
this.editor.replaceSelection(field);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: 'fieldName', atomic: true, startStyle: "start", endStyle: "end"});
this.editor.replaceSelection(" ");
this.editor.focus();
},
insertFunction: function (fn) {
var from = this.editor.getCursor();
this.editor.replaceSelection(fn);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: "#function", atomic: true});
this.editor.replaceSelection("() ");
to = this.editor.getCursor();
to.ch = to.ch - 2;
this.editor.setCursor(to);
this.editor.focus();
},
insertOperator: function (op) {
var from = this.editor.getCursor();
this.editor.replaceSelection(op);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: "%operator", atomic: true});
this.editor.replaceSelection(" ");
this.editor.focus();
},
setFunction: function (v) {
var from = this.editor.getCursor();
this.editor.replaceSelection(v);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: "#function", atomic: true});
},
insertString: function (str) {
this.editor.replaceSelection(str);
this.editor.focus();
},
getFormulaString: function () {
return this.editor.getValue();
},
getUsedFields: function () {
var fieldMap = this.options.fieldTextValueMap;
var fields = [];
this.editor.getValue(true, function (line) {
var value = line.text;
_.forEach(line.markedSpans, function (i, ms) {
switch (i.marker.className) {
case "fieldName":
var dId = fieldMap[value.substr(i.from, i.to - i.from)];
if (!fields.contains(dId)) {
fields.push(dId);
}
}
});
}
});
return fields;
},
getCheckString: function () {
return this.editor.getValue(true, function (line) {
var rawText = line.text, value = line.text, num = 0;
value.text = rawText;
_.forEach(line.markedSpans, function (i, ms) {
switch (i.marker.className) {
case "fieldName":
var fieldNameLength = i.to - i.from;
value = value.substr(0, i.from + num) + "$a" + value.substr(i.to + num, value.length);
num = num + 2 - fieldNameLength;
break;
}
});
BI.FormulaEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.FormulaEditor.EVENT_BLUR = "EVENT_BLUR";
BI.FormulaEditor.EVENT_FOCUS = "EVENT_FOCUS";
$.shortcut("bi.formula", BI.FormulaEditor);
})(jQuery);
});
return value;
});
},
getValue: function () {
var fieldMap = this.options.fieldTextValueMap;
return this.editor.getValue("\n", function (line) {
var rawText = line.text, value = line.text, num = 0;
value.text = rawText;
_.forEach(line.markedSpans, function (i, ms) {
switch (i.marker.className) {
case "fieldName":
var fieldNameLength = i.to - i.from;
var fieldId = fieldMap[value.substr(i.from + num, fieldNameLength)];
value = value.substr(0, i.from + num) + "$\{" + fieldMap[value.substr(i.from + num, fieldNameLength)] + "\}" + value.substr(i.to + num, value.length);
num += fieldId.length - fieldNameLength + 3;
break;
}
});
return value;
});
},
setValue: function (value) {
this.editor.setValue(value);
},
setFieldTextValueMap: function (fieldTextValueMap) {
this.options.fieldTextValueMap = fieldTextValueMap;
},
refresh: function () {
var self = this;
BI.nextTick(function () {
self.editor.refresh();
});
}
});
BI.FormulaEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.FormulaEditor.EVENT_BLUR = "EVENT_BLUR";
BI.FormulaEditor.EVENT_FOCUS = "EVENT_FOCUS";
$.shortcut("bi.formula_editor", BI.FormulaEditor);

0
src/case/tip/tip.bubble.js → src/base/single/tip/tip.bubble.js

0
src/case/tip/tip.toast.js → src/base/single/tip/tip.toast.js

0
src/case/tip/tip.tooltip.js → src/base/single/tip/tip.tooltip.js

6
src/core/widget.js

@ -135,9 +135,9 @@ BI.Widget = BI.inherit(BI.OB, {
})
})
}
if (this._isRoot === true || !(this instanceof BI.Layout)) {
this._mount();
}
// if (this._isRoot === true || !(this instanceof BI.Layout)) {
this._mount();
// }
},
_setParent: function (parent) {

2
src/core/wrapper/layout.js

@ -18,7 +18,7 @@ BI.Layout = BI.inherit(BI.Widget, {
};
},
created: function () {
render: function () {
this._init4Margin();
this._init4Scroll();
},

4
src/core/wrapper/layout/adapt/absolute.center.js

@ -16,8 +16,8 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.AbsoluteCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/adapt/absolute.horizontal.js

@ -16,8 +16,8 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.AbsoluteHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteHorizontalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/adapt/absolute.vertical.js

@ -16,8 +16,8 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.AbsoluteVerticalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteVerticalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/adapt/adapt.center.js

@ -16,8 +16,8 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.CenterAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.CenterAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",

4
src/core/wrapper/layout/adapt/adapt.horizontal.js

@ -17,8 +17,8 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",

26
src/core/wrapper/layout/adapt/adapt.leftrightvertical.js

@ -20,8 +20,8 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
rhgap: 0
});
},
created: function () {
BI.LeftRightVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -86,8 +86,8 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
hgap: 0
});
},
created: function () {
BI.LeftVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.LeftVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -100,8 +100,7 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
throw new Error("不能添加元素")
},
populate: function (items) {
BI.LeftVerticalAdaptLayout.superclass.populate.apply(this, arguments);
stroke: function (items) {
var o = this.options;
var left = BI.createWidget({
type: "bi.vertical_adapt",
@ -116,6 +115,10 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
element: this,
items: [left]
});
},
populate: function (items) {
BI.LeftVerticalAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
@ -131,8 +134,8 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
hgap: 0
});
},
created: function () {
BI.RightVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.RightVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -145,8 +148,7 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
throw new Error("不能添加元素")
},
populate: function (items) {
BI.RightVerticalAdaptLayout.superclass.populate.apply(this, arguments);
stroke: function (items) {
var o = this.options;
var right = BI.createWidget({
type: "bi.vertical_adapt",
@ -161,6 +163,10 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
element: this,
items: [right]
});
},
populate: function (items) {
BI.RightVerticalAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});

24
src/core/wrapper/layout/adapt/adapt.vertical.js

@ -4,20 +4,18 @@
* @extends BI.Layout
*/
BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
_defaultConfig: function () {
return BI.extend(BI.VerticalAdaptLayout.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-vertical-adapt-layout",
columnSize: [],
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
props: {
baseCls: "bi-vertical-adapt-layout",
columnSize: [],
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
},
_init: function () {
BI.VerticalAdaptLayout.superclass._init.apply(this, arguments);
render: function () {
BI.VerticalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"height": "100%",

4
src/core/wrapper/layout/adapt/auto.horizontal.js

@ -16,8 +16,8 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.HorizontalAutoLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalAutoLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/adapt/float.center.js

@ -14,8 +14,8 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
rgap: 0
});
},
created: function () {
BI.FloatCenterAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatCenterAdaptLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/adapt/float.horizontal.js

@ -14,8 +14,8 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
rgap: 0
});
},
created: function () {
BI.FloatHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatHorizontalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/adapt/inline.center.js

@ -19,8 +19,8 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.InlineCenterAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.InlineCenterAdaptLayout.superclass.render.apply(this, arguments);
this.element.css({
whiteSpace: "nowrap"
});

4
src/core/wrapper/layout/adapt/inline.vertical.js

@ -19,8 +19,8 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.InlineVerticalAdaptLayout.superclass.created.apply(this, arguments);
render: function () {
BI.InlineVerticalAdaptLayout.superclass.render.apply(this, arguments);
this.element.css({
whiteSpace: "nowrap"
});

4
src/core/wrapper/layout/flex/flex.center.js

@ -11,8 +11,8 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
baseCls: "bi-flex-center-layout"
});
},
created: function () {
BI.FlexCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/flex/flex.horizontal.js

@ -20,8 +20,8 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexHorizontalLayout.superclass.render.apply(this, arguments);
var o = this.options;
this.element.addClass(o.verticalAlign);
this.populate(this.options.items);

4
src/core/wrapper/layout/flex/flex.vertical.center.js

@ -18,8 +18,8 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexVerticalCenter.superclass.created.apply(this, arguments);
render: function () {
BI.FlexVerticalCenter.superclass.render.apply(this, arguments);
var o = this.options;
this.populate(this.options.items);
},

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js

@ -11,8 +11,8 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
baseCls: "bi-flex-wrapper-center-layout clearfix"
});
},
created: function () {
BI.FlexCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexCenterLayout.superclass.render.apply(this, arguments);
this.$wrapper = $("<div>").addClass("flex-wrapper-center-layout-wrapper");
this.populate(this.options.items);
},

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js

@ -20,8 +20,8 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexHorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FlexHorizontalLayout.superclass.render.apply(this, arguments);
var o = this.options;
this.$wrapper = $("<div>").addClass("flex-wrapper-horizontal-layout-wrapper " + o.verticalAlign);
this.populate(this.options.items);

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js

@ -18,8 +18,8 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FlexVerticalCenter.superclass.created.apply(this, arguments);
render: function () {
BI.FlexVerticalCenter.superclass.render.apply(this, arguments);
var o = this.options;
this.$wrapper = $("<div>").addClass("flex-wrapper-vertical-center-wrapper");
this.populate(this.options.items);

4
src/core/wrapper/layout/layout.absolute.js

@ -15,8 +15,8 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
bgap: null
});
},
created: function () {
BI.AbsoluteLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AbsoluteLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.adaptive.js

@ -10,8 +10,8 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, {
bgap: null
});
},
created: function () {
BI.AdaptiveLayout.superclass.created.apply(this, arguments);
render: function () {
BI.AdaptiveLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.border.js

@ -11,8 +11,8 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
items: {}
});
},
created: function () {
BI.BorderLayout.superclass.created.apply(this, arguments);
render: function () {
BI.BorderLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.card.js

@ -13,8 +13,8 @@ BI.CardLayout = BI.inherit(BI.Layout, {
items: []
});
},
created: function () {
BI.CardLayout.superclass.created.apply(this, arguments);
render: function () {
BI.CardLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.default.js

@ -16,8 +16,8 @@ BI.DefaultLayout = BI.inherit(BI.Layout, {
items: []
});
},
created: function () {
BI.DefaultLayout.superclass.created.apply(this, arguments);
render: function () {
BI.DefaultLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.division.js

@ -36,8 +36,8 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
//]
});
},
created: function () {
BI.DivisionLayout.superclass.created.apply(this, arguments);
render: function () {
BI.DivisionLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

8
src/core/wrapper/layout/layout.flow.js

@ -19,8 +19,8 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FloatLeftLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatLeftLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -84,8 +84,8 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FloatRightLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatRightLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.grid.js

@ -30,8 +30,8 @@ BI.GridLayout = BI.inherit(BI.Layout, {
]*/
});
},
created: function () {
BI.GridLayout.superclass.created.apply(this, arguments);
render: function () {
BI.GridLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

8
src/core/wrapper/layout/layout.horizontal.js

@ -18,8 +18,8 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"white-space": "nowrap",
@ -140,8 +140,8 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalCellLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalCellLayout.superclass.render.apply(this, arguments);
this.element.css({"display": "table", "vertical-align": "top"});
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.inline.js

@ -19,8 +19,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.InlineLayout.superclass.created.apply(this, arguments);
render: function () {
BI.InlineLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.lattice.js

@ -14,8 +14,8 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
//columnSize: [0.2, 0.2, 0.6],
});
},
created: function () {
BI.LatticeLayout.superclass.created.apply(this, arguments);
render: function () {
BI.LatticeLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.table.js

@ -26,8 +26,8 @@ BI.TableLayout = BI.inherit(BI.Layout, {
]]
});
},
created: function () {
BI.TableLayout.superclass.created.apply(this, arguments);
render: function () {
BI.TableLayout.superclass.render.apply(this, arguments);
this.rows = 0;
this.populate(this.options.items);
},

8
src/core/wrapper/layout/layout.tape.js

@ -29,8 +29,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
]
});
},
created: function () {
BI.HTapeLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HTapeLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
@ -133,8 +133,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
]
});
},
created: function () {
BI.VTapeLayout.superclass.created.apply(this, arguments);
render: function () {
BI.VTapeLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.td.js

@ -23,8 +23,8 @@ BI.TdLayout = BI.inherit(BI.Layout, {
]]
});
},
created: function () {
BI.TdLayout.superclass.created.apply(this, arguments);
render: function () {
BI.TdLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",

4
src/core/wrapper/layout/layout.vertical.js

@ -16,8 +16,8 @@ BI.VerticalLayout = BI.inherit(BI.Layout, {
scrolly: true
});
},
created: function () {
BI.VerticalLayout.superclass.created.apply(this, arguments);
render: function () {
BI.VerticalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/layout.window.js

@ -30,8 +30,8 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
]]
});
},
created: function () {
BI.WindowLayout.superclass.created.apply(this, arguments);
render: function () {
BI.WindowLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/middle/middle.center.js

@ -16,8 +16,8 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
});
},
created: function () {
BI.CenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.CenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/middle/middle.float.center.js

@ -15,8 +15,8 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.FloatCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.FloatCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/middle/middle.horizontal.js

@ -15,8 +15,8 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.HorizontalCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.HorizontalCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

4
src/core/wrapper/layout/middle/middle.vertical.js

@ -15,8 +15,8 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
bgap: 0
});
},
created: function () {
BI.VerticalCenterLayout.superclass.created.apply(this, arguments);
render: function () {
BI.VerticalCenterLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},

2
src/css/base/single/button/button.css

@ -9,7 +9,7 @@
background-color: #009de3;
text-align: center;
vertical-align: middle;
cursor: pointer !important;
cursor: pointer;
font-size: 14px;
}
.bi-button.button-common,

2
src/less/base/single/button/button.less

@ -6,7 +6,7 @@
background-color: @color-bi-text-highlight;
text-align: center;
vertical-align: middle;
cursor: pointer !important;
cursor: pointer;
font-size: 14px;
&.button-common {
&, & .b-font {

88
src/third/codemirror/addon/formula-hint.js vendored

@ -1,88 +0,0 @@
(function (mod) {
mod(CodeMirror);
})(function (CodeMirror) {
var Pos = CodeMirror.Pos;
function forEach(arr, f) {
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
}
function arrayContains(arr, item) {
if (!Array.prototype.indexOf) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
return true;
}
}
return false;
}
return arr.indexOf(item) != -1;
}
function scriptHint(editor, keywords, getToken, options) {
// Find the token at the cursor
var cur = editor.getCursor(), token = getToken(editor, cur);
if (/\b(?:string)\b/.test(token.type)) {
return;
}
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
if (!/^[\w$_]*$/.test(token.string)) {
token = {
start: cur.ch, end: cur.ch, string: "", state: token.state,
type: token.string == "." ? "property" : null
};
} else if (token.end > cur.ch) {
token.end = cur.ch;
token.string = token.string.slice(0, cur.ch - token.start);
}
var tprop = token;
// If it is a property, find out what it is a property of.
while (tprop.type == "property") {
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (tprop.string != ".") return;
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (!context) var context = [];
context.push(tprop);
}
return {
list: getCompletions(token, context, keywords, options),
from: Pos(cur.line, token.start),
to: Pos(cur.line, token.end)
};
}
function getFormulaKeywords() {
return FormulaCollections;
}
function formulaHint(editor, options) {
return scriptHint(editor, getFormulaKeywords(),
function (e, cur) {
return e.getTokenAt(cur);
},
options);
};
CodeMirror.registerHelper("hint", "formula", formulaHint);
function getCompletions(token, context, keywords, options) {
var found = [], start = token.string;
if (!start) {
return found;
}
function maybeAdd(str) {
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) {
found.push(str);
}
}
if (context && context.length) {
context.pop();
} else {
forEach(keywords, maybeAdd);
}
return found;
}
});

80
src/third/codemirror/addon/formula-mode.js vendored

@ -1,80 +0,0 @@
(function (mod) {
mod(CodeMirror);
})(function (CodeMirror) {
"use strict";
CodeMirror.defineMode('formula', function () {
function wordObj(words) {
var o = {};
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
return o;
}
var atoms = wordObj(['false', 'true']);
var keywords = wordObj(FormulaCollections);
function tokenBase(stream, state) {
if (stream.eatSpace()) {
return null;
}
var ch = stream.next();
if (ch === '"' || ch === '\'') {
nextUntilUnescaped(stream, ch);
return "string";
}
if (/[\[\],\(\)]/.test(ch)) {
return 'bracket';
}
// richie:暂时不需要解析操作符号
//if (/[+\-*\/=<>!&|]/.test(ch)) {
// return 'operator';
//}
//if (/\d|\d./.test(ch)) {
// stream.eatWhile(/\d|\./);
// if (stream.eol() || !/\w/.test(stream.peek())) {
// return 'number';
// }
//}
stream.eatWhile(/[\w-]/);
var word = stream.current();
if (atoms.hasOwnProperty(word)) {
return "atom";
}
if (keywords.hasOwnProperty(word)) {
return "keyword";
}
return null;
}
function nextUntilUnescaped(stream, end) {
var escaped = false, next;
while ((next = stream.next()) != null) {
if (next === end && !escaped) {
return false;
}
escaped = !escaped && next === "\\";
}
return escaped;
}
function tokenize(stream, state) {
return (state.tokens[0] || tokenBase)(stream, state);
}
return {
startState: function () {
return {tokens: []};
},
token: function (stream, state) {
return tokenize(stream, state);
},
fold: "brace"
};
});
CodeMirror.defineMIME("text/fx-formula", "formula");
});

432
src/third/codemirror/addon/show-hint.js vendored

@ -1,432 +0,0 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function (mod) {
mod(CodeMirror);
})(function (CodeMirror) {
"use strict";
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
// This is the old interface, kept around for now to stay
// backwards-compatible.
CodeMirror.showHint = function (cm, getHints, options) {
if (!getHints) return cm.showHint(options);
if (options && options.async) getHints.async = true;
var newOpts = {hint: getHints};
if (options) for (var prop in options) newOpts[prop] = options[prop];
return cm.showHint(newOpts);
};
CodeMirror.defineExtension("showHint", function (options) {
// We want a single cursor position.
if (this.listSelections().length > 1 || this.somethingSelected()) return;
if (this.state.completionActive) this.state.completionActive.close();
var completion = this.state.completionActive = new Completion(this, options);
if (!completion.options.hint) return;
CodeMirror.signal(this, "startCompletion", this);
completion.update(true);
});
function Completion(cm, options) {
this.cm = cm;
this.options = this.buildOptions(options);
this.widget = null;
this.debounce = 0;
this.tick = 0;
this.startPos = this.cm.getCursor();
this.startLen = this.cm.getLine(this.startPos.line).length;
var self = this;
cm.on("cursorActivity", this.activityFunc = function () {
self.cursorActivity();
});
}
var requestAnimationFrame = window.requestAnimationFrame || function (fn) {
return setTimeout(fn, 1000 / 60);
};
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
Completion.prototype = {
close: function () {
if (!this.active()) return;
this.cm.state.completionActive = null;
this.tick = null;
this.cm.off("cursorActivity", this.activityFunc);
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
if (this.widget) this.widget.close();
CodeMirror.signal(this.cm, "endCompletion", this.cm);
},
active: function () {
return this.cm.state.completionActive == this;
},
pick: function (data, i) {
var completion = data.list[i];
if (completion.hint) completion.hint(this.cm, data, completion);
else {
this.cm.replaceRange(getText(completion), completion.from || data.from,
completion.to || data.to, "complete");
var to = this.cm.getCursor();
this.cm.markText(completion.from || data.from, to, {className: "#function", atomic: true});
this.cm.replaceSelection("() ");
to = this.cm.getCursor();
to.ch = to.ch - 2;
this.cm.setCursor(to);
this.cm.focus();
}
CodeMirror.signal(data, "pick", completion);
this.close();
},
cursorActivity: function () {
if (this.debounce) {
cancelAnimationFrame(this.debounce);
this.debounce = 0;
}
var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
(pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
this.close();
} else {
var self = this;
this.debounce = requestAnimationFrame(function () {
self.update();
});
if (this.widget) this.widget.disable();
}
},
update: function (first) {
if (this.tick == null) return;
if (this.data) CodeMirror.signal(this.data, "update");
if (!this.options.hint.async) {
this.finishUpdate(this.options.hint(this.cm, this.options), first);
} else {
var myTick = ++this.tick, self = this;
this.options.hint(this.cm, function (data) {
if (self.tick == myTick) self.finishUpdate(data, first);
}, this.options);
}
},
finishUpdate: function (data, first) {
this.data = data;
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
if (this.widget) this.widget.close();
if (data && data.list.length) {
if (picked && data.list.length == 1) {
this.pick(data, 0);
} else {
this.widget = new Widget(this, data);
CodeMirror.signal(data, "shown");
}
}
},
buildOptions: function (options) {
var editor = this.cm.options.hintOptions;
var out = {};
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
if (editor) for (var prop in editor)
if (editor[prop] !== undefined) out[prop] = editor[prop];
if (options) for (var prop in options)
if (options[prop] !== undefined) out[prop] = options[prop];
return out;
}
};
function getText(completion) {
if (typeof completion == "string") return completion;
else return completion.text;
}
function buildKeyMap(completion, handle) {
var baseMap = {
Up: function () {
handle.moveFocus(-1);
},
Down: function () {
handle.moveFocus(1);
},
PageUp: function () {
handle.moveFocus(-handle.menuSize() + 1, true);
},
PageDown: function () {
handle.moveFocus(handle.menuSize() - 1, true);
},
Home: function () {
handle.setFocus(0);
},
End: function () {
handle.setFocus(handle.length - 1);
},
Enter: handle.pick,
Tab: handle.pick,
Esc: handle.close
};
var custom = completion.options.customKeys;
var ourMap = custom ? {} : baseMap;
function addBinding(key, val) {
var bound;
if (typeof val != "string")
bound = function (cm) {
return val(cm, handle);
};
// This mechanism is deprecated
else if (baseMap.hasOwnProperty(val))
bound = baseMap[val];
else
bound = val;
ourMap[key] = bound;
}
if (custom)
for (var key in custom) if (custom.hasOwnProperty(key))
addBinding(key, custom[key]);
var extra = completion.options.extraKeys;
if (extra)
for (var key in extra) if (extra.hasOwnProperty(key))
addBinding(key, extra[key]);
return ourMap;
}
function getHintElement(hintsElement, el) {
while (el && el != hintsElement) {
if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
el = el.parentNode;
}
}
function Widget(completion, data) {
this.completion = completion;
this.data = data;
this.picked = false;
var widget = this, cm = completion.cm;
var hints = this.hints = document.createElement("ul");
hints.className = "CodeMirror-hints";
this.selectedHint = data.selectedHint || 0;
var completions = data.list;
for (var i = 0; i < completions.length; ++i) {
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
if (cur.className != null) className = cur.className + " " + className;
elt.className = className;
if (cur.render) cur.render(elt, data, cur);
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
elt.hintId = i;
}
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
var left = pos.left, top = pos.bottom, below = true;
hints.style.left = left + "px";
hints.style.top = top + "px";
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
(completion.options.container || document.body).appendChild(hints);
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
if (overlapY > 0) {
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
if (curTop - height > 0) { // Fits above cursor
hints.style.top = (top = pos.top - height) + "px";
below = false;
} else if (height > winH) {
hints.style.height = (winH - 5) + "px";
hints.style.top = (top = pos.bottom - box.top) + "px";
var cursor = cm.getCursor();
if (data.from.ch != cursor.ch) {
pos = cm.cursorCoords(cursor);
hints.style.left = (left = pos.left) + "px";
box = hints.getBoundingClientRect();
}
}
}
var overlapX = box.right - winW;
if (overlapX > 0) {
if (box.right - box.left > winW) {
hints.style.width = (winW - 5) + "px";
overlapX -= (box.right - box.left) - winW;
}
hints.style.left = (left = pos.left - overlapX) + "px";
}
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
moveFocus: function (n, avoidWrap) {
widget.changeActive(widget.selectedHint + n, avoidWrap);
},
setFocus: function (n) {
widget.changeActive(n);
},
menuSize: function () {
return widget.screenAmount();
},
length: completions.length,
close: function () {
completion.close();
},
pick: function () {
widget.pick();
},
data: data
}));
if (completion.options.closeOnUnfocus) {
var closingOnBlur;
cm.on("blur", this.onBlur = function () {
closingOnBlur = setTimeout(function () {
completion.close();
}, 100);
});
cm.on("focus", this.onFocus = function () {
clearTimeout(closingOnBlur);
});
}
var startScroll = cm.getScrollInfo();
cm.on("scroll", this.onScroll = function () {
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
var newTop = top + startScroll.top - curScroll.top;
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
if (!below) point += hints.offsetHeight;
if (point <= editor.top || point >= editor.bottom) return completion.close();
hints.style.top = newTop + "px";
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
});
CodeMirror.on(hints, "dblclick", function (e) {
var t = getHintElement(hints, e.target || e.srcElement);
if (t && t.hintId != null) {
widget.changeActive(t.hintId);
widget.pick();
}
});
CodeMirror.on(hints, "click", function (e) {
var t = getHintElement(hints, e.target || e.srcElement);
if (t && t.hintId != null) {
widget.changeActive(t.hintId);
if (completion.options.completeOnSingleClick) widget.pick();
}
});
CodeMirror.on(hints, "mousedown", function () {
setTimeout(function () {
cm.focus();
}, 20);
});
CodeMirror.signal(data, "select", completions[0], hints.firstChild);
return true;
}
Widget.prototype = {
close: function () {
if (this.completion.widget != this) return;
this.completion.widget = null;
this.hints.parentNode.removeChild(this.hints);
this.completion.cm.removeKeyMap(this.keyMap);
var cm = this.completion.cm;
if (this.completion.options.closeOnUnfocus) {
cm.off("blur", this.onBlur);
cm.off("focus", this.onFocus);
}
cm.off("scroll", this.onScroll);
},
disable: function () {
this.completion.cm.removeKeyMap(this.keyMap);
var widget = this;
this.keyMap = {
Enter: function () {
widget.picked = true;
}
};
this.completion.cm.addKeyMap(this.keyMap);
},
pick: function () {
this.completion.pick(this.data, this.selectedHint);
},
changeActive: function (i, avoidWrap) {
if (i >= this.data.list.length)
i = avoidWrap ? this.data.list.length - 1 : 0;
else if (i < 0)
i = avoidWrap ? 0 : this.data.list.length - 1;
if (this.selectedHint == i) return;
var node = this.hints.childNodes[this.selectedHint];
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
node = this.hints.childNodes[this.selectedHint = i];
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
if (node.offsetTop < this.hints.scrollTop)
this.hints.scrollTop = node.offsetTop - 3;
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
},
screenAmount: function () {
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
}
};
CodeMirror.registerHelper("hint", "auto", function (cm, options) {
var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
if (helpers.length) {
for (var i = 0; i < helpers.length; i++) {
var cur = helpers[i](cm, options);
if (cur && cur.list.length) return cur;
}
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
if (words) return CodeMirror.hint.fromList(cm, {words: words});
} else if (CodeMirror.hint.anyword) {
return CodeMirror.hint.anyword(cm, options);
}
});
CodeMirror.registerHelper("hint", "fromList", function (cm, options) {
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
var found = [];
for (var i = 0; i < options.words.length; i++) {
var word = options.words[i];
if (word.slice(0, token.string.length) == token.string)
found.push(word);
}
if (found.length) return {
list: found,
from: CodeMirror.Pos(cur.line, token.start),
to: CodeMirror.Pos(cur.line, token.end)
};
});
CodeMirror.commands.autocomplete = CodeMirror.showHint;
var defaultOptions = {
hint: CodeMirror.hint.auto,
completeSingle: true,
alignWithWord: true,
closeCharacters: /[\s()\[\]{};:>,]/,
closeOnUnfocus: true,
completeOnSingleClick: true,
container: null,
customKeys: null,
extraKeys: null
};
CodeMirror.defineOption("hintOptions", null);
});
Loading…
Cancel
Save