forked from fanruan/fineui
windy
8 years ago
157 changed files with 25556 additions and 60360 deletions
File diff suppressed because one or more lines are too long
@ -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); |
@ -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 |
||||
} |
||||
} |
||||
}); |
||||
|
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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); |
@ -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" |
||||
},]; |
File diff suppressed because it is too large
Load Diff
@ -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"]; |
@ -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); |
||||
|
@ -1,464 +0,0 @@
|
||||
BICst.HISTORY_VERSION = {}; |
||||
BICst.HISTORY_VERSION.VERSION_4_0 = 4.0; |
||||
BICst.HISTORY_VERSION.VERSION_4_1 = 4.01; |
||||
BICst.REPORT_AUTH = {}; |
||||
BICst.REPORT_AUTH.NONE = 0; |
||||
BICst.REPORT_AUTH.EDIT = 1; |
||||
BICst.REPORT_AUTH.VIEW = 2; |
||||
BICst.TARGET_STYLE = {}; |
||||
BICst.TARGET_STYLE.ICON_STYLE = {}; |
||||
BICst.TARGET_STYLE.ICON_STYLE.NONE = 1; |
||||
BICst.TARGET_STYLE.ICON_STYLE.POINT = 2; |
||||
BICst.TARGET_STYLE.ICON_STYLE.ARROW = 3; |
||||
BICst.TARGET_STYLE.NUM_LEVEL = {}; |
||||
BICst.TARGET_STYLE.NUM_LEVEL.NORMAL = 1; |
||||
BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND = 2; |
||||
BICst.TARGET_STYLE.NUM_LEVEL.MILLION = 3; |
||||
BICst.TARGET_STYLE.NUM_LEVEL.YI = 4; |
||||
BICst.TARGET_STYLE.NUM_LEVEL.PERCENT = 5; |
||||
BICst.TARGET_STYLE.FORMAT = {}; |
||||
BICst.TARGET_STYLE.FORMAT.NORMAL = -1; |
||||
BICst.TARGET_STYLE.FORMAT.ZERO2POINT = 0; |
||||
BICst.TARGET_STYLE.FORMAT.ONE2POINT = 1; |
||||
BICst.TARGET_STYLE.FORMAT.TWO2POINT = 2; |
||||
BICst.MULTI_PATH_STATUS = {}; |
||||
BICst.MULTI_PATH_STATUS.NEED_GENERATE_CUBE = 0; |
||||
BICst.MULTI_PATH_STATUS.NOT_NEED_GENERATE_CUBE = 1; |
||||
BICst.CUSTOM_GROUP = {}; |
||||
BICst.CUSTOM_GROUP.UNGROUP2OTHER = {}; |
||||
BICst.CUSTOM_GROUP.UNGROUP2OTHER.NOTSELECTED = 0; |
||||
BICst.CUSTOM_GROUP.UNGROUP2OTHER.SELECTED = 1; |
||||
BICst.REPORT_STATUS = {}; |
||||
BICst.REPORT_STATUS.APPLYING = 1; |
||||
BICst.REPORT_STATUS.HANGOUT = 2; |
||||
BICst.REPORT_STATUS.NORMAL = 3; |
||||
BICst.FIELD_ID = {}; |
||||
BICst.FIELD_ID.HEAD = "81c48028-1401-11e6-a148-3e1d05defe78"; |
||||
BICst.TREE_LABEL = {}; |
||||
BICst.TREE_LABEL.TREE_LABEL_ITEM_COUNT_NUM = 40; |
||||
BICst.TREE = {}; |
||||
BICst.TREE.TREE_REQ_TYPE = {}; |
||||
BICst.TREE.TREE_REQ_TYPE.INIT_DATA = 0; |
||||
BICst.TREE.TREE_REQ_TYPE.SEARCH_DATA = 1; |
||||
BICst.TREE.TREE_REQ_TYPE.SELECTED_DATA = 3; |
||||
BICst.TREE.TREE_REQ_TYPE.ADJUST_DATA = 2; |
||||
BICst.TREE.TREE_REQ_TYPE.DISPLAY_DATA = 4; |
||||
BICst.TREE.TREE_ITEM_COUNT_PER_PAGE = 100; |
||||
BICst.BUSINESS_TABLE_TYPE = {}; |
||||
BICst.BUSINESS_TABLE_TYPE.NORMAL = 0; |
||||
BICst.EXPANDER_TYPE = {}; |
||||
BICst.EXPANDER_TYPE.NONE = false; |
||||
BICst.EXPANDER_TYPE.ALL = true; |
||||
BICst.SORT = {}; |
||||
BICst.SORT.ASC = 0; |
||||
BICst.SORT.DESC = 1; |
||||
BICst.SORT.CUSTOM = 2; |
||||
BICst.SORT.NONE = 3; |
||||
BICst.SORT.NUMBER_ASC = 4; |
||||
BICst.SORT.NUMBER_DESC = 5; |
||||
BICst.TABLE_PAGE_OPERATOR = {}; |
||||
BICst.TABLE_PAGE_OPERATOR.ALL_PAGE = -1; |
||||
BICst.TABLE_PAGE_OPERATOR.REFRESH = 0; |
||||
BICst.TABLE_PAGE_OPERATOR.COLUMN_PRE = 1; |
||||
BICst.TABLE_PAGE_OPERATOR.COLUMN_NEXT = 2; |
||||
BICst.TABLE_PAGE_OPERATOR.ROW_PRE = 3; |
||||
BICst.TABLE_PAGE_OPERATOR.ROW_NEXT = 4; |
||||
BICst.TABLE_PAGE_OPERATOR.EXPAND = 5; |
||||
BICst.TABLE_PAGE = {}; |
||||
BICst.TABLE_PAGE.VERTICAL_PRE = 0; |
||||
BICst.TABLE_PAGE.VERTICAL_NEXT = 1; |
||||
BICst.TABLE_PAGE.HORIZON_PRE = 2; |
||||
BICst.TABLE_PAGE.HORIZON_NEXT = 3; |
||||
BICst.TABLE_PAGE.TOTAL_PAGE = 4; |
||||
BICst.TABLE_WIDGET = {}; |
||||
BICst.TABLE_WIDGET.GROUP_TYPE = 1; |
||||
BICst.TABLE_WIDGET.CROSS_TYPE = 2; |
||||
BICst.TABLE_WIDGET.COMPLEX_TYPE = 3; |
||||
BICst.REGION = {}; |
||||
BICst.REGION.DIMENSION1 = "10000"; |
||||
BICst.REGION.DIMENSION2 = "20000"; |
||||
BICst.REGION.TARGET1 = "30000"; |
||||
BICst.REGION.TARGET2 = "40000"; |
||||
BICst.REGION.TARGET3 = "50000"; |
||||
BICst.EXPORT = {}; |
||||
BICst.EXPORT.EXCEL = 1; |
||||
BICst.EXPORT.PDF = 2; |
||||
BICst.WIDGET = {}; |
||||
BICst.WIDGET.TABLE = 1; |
||||
BICst.WIDGET.CROSS_TABLE = 2; |
||||
BICst.WIDGET.COMPLEX_TABLE = 3; |
||||
BICst.WIDGET.DETAIL = 4; |
||||
BICst.WIDGET.AXIS = 5; |
||||
BICst.WIDGET.ACCUMULATE_AXIS = 6; |
||||
BICst.WIDGET.PERCENT_ACCUMULATE_AXIS = 7; |
||||
BICst.WIDGET.COMPARE_AXIS = 8; |
||||
BICst.WIDGET.FALL_AXIS = 9; |
||||
BICst.WIDGET.BAR = 10; |
||||
BICst.WIDGET.ACCUMULATE_BAR = 11; |
||||
BICst.WIDGET.COMPARE_BAR = 12; |
||||
BICst.WIDGET.LINE = 13; |
||||
BICst.WIDGET.AREA = 14; |
||||
BICst.WIDGET.ACCUMULATE_AREA = 15; |
||||
BICst.WIDGET.PERCENT_ACCUMULATE_AREA = 16; |
||||
BICst.WIDGET.COMPARE_AREA = 17; |
||||
BICst.WIDGET.RANGE_AREA = 18; |
||||
BICst.WIDGET.COMBINE_CHART = 19; |
||||
BICst.WIDGET.MULTI_AXIS_COMBINE_CHART = 20; |
||||
BICst.WIDGET.PIE = 21; |
||||
BICst.WIDGET.DONUT = 22; |
||||
BICst.WIDGET.MAP = 23; |
||||
BICst.WIDGET.GIS_MAP = 24; |
||||
BICst.WIDGET.DASHBOARD = 25; |
||||
BICst.WIDGET.BUBBLE = 26; |
||||
BICst.WIDGET.FORCE_BUBBLE = 27; |
||||
BICst.WIDGET.SCATTER = 28; |
||||
BICst.WIDGET.RADAR = 29; |
||||
BICst.WIDGET.ACCUMULATE_RADAR = 30; |
||||
BICst.WIDGET.FUNNEL = 31; |
||||
BICst.WIDGET.RECT_TREE = 39; |
||||
BICst.WIDGET.MULTI_PIE = 40; |
||||
BICst.WIDGET.HEAT_MAP = 65; |
||||
BICst.WIDGET.PARETO = 66; |
||||
BICst.WIDGET.STRING = 32; |
||||
BICst.WIDGET.NUMBER = 33; |
||||
BICst.WIDGET.TREE = 34; |
||||
BICst.WIDGET.SINGLE_SLIDER = 35; |
||||
BICst.WIDGET.INTERVAL_SLIDER = 36; |
||||
BICst.WIDGET.LIST_LABEL = 37; |
||||
BICst.WIDGET.TREE_LABEL = 38; |
||||
BICst.WIDGET.STRING_LIST = 59; |
||||
BICst.WIDGET.TREE_LIST = 60; |
||||
BICst.WIDGET.DATE_PANE = 61; |
||||
BICst.WIDGET.DATE = 48; |
||||
BICst.WIDGET.YEAR = 49; |
||||
BICst.WIDGET.QUARTER = 50; |
||||
BICst.WIDGET.MONTH = 51; |
||||
BICst.WIDGET.YMD = 52; |
||||
BICst.WIDGET.QUERY = 53; |
||||
BICst.WIDGET.RESET = 54; |
||||
BICst.WIDGET.CONTENT = 55; |
||||
BICst.WIDGET.IMAGE = 56; |
||||
BICst.WIDGET.WEB = 57; |
||||
BICst.WIDGET.GENERAL_QUERY = 58; |
||||
BICst.WIDGET.TABLE_SHOW = 64; |
||||
BICst.WIDGET.NONE = -1; |
||||
BICst.TARGET_TYPE = {}; |
||||
BICst.TARGET_TYPE.CAL_POSITION = {}; |
||||
BICst.TARGET_TYPE.CAL_POSITION.ALL = 0; |
||||
BICst.TARGET_TYPE.CAL_POSITION.INGROUP = 1; |
||||
BICst.TARGET_TYPE.CAL_VALUE = {}; |
||||
BICst.TARGET_TYPE.CAL_VALUE.PERIOD_TYPE = {}; |
||||
BICst.TARGET_TYPE.CAL_VALUE.PERIOD_TYPE.VALUE = 0; |
||||
BICst.TARGET_TYPE.CAL_VALUE.PERIOD_TYPE.RATE = 1; |
||||
BICst.TARGET_TYPE.CAL_VALUE.SUMMARY_TYPE = {}; |
||||
BICst.TARGET_TYPE.CAL_VALUE.SUMMARY_TYPE.SUM = 0; |
||||
BICst.TARGET_TYPE.CAL_VALUE.SUMMARY_TYPE.MAX = 1; |
||||
BICst.TARGET_TYPE.CAL_VALUE.SUMMARY_TYPE.MIN = 2; |
||||
BICst.TARGET_TYPE.CAL_VALUE.SUMMARY_TYPE.AVG = 3; |
||||
BICst.TARGET_TYPE.CAL_VALUE.RANK_TPYE = {}; |
||||
BICst.TARGET_TYPE.CAL_VALUE.RANK_TPYE.ASC = 0; |
||||
BICst.TARGET_TYPE.CAL_VALUE.RANK_TPYE.DESC = 1; |
||||
BICst.TARGET_TYPE.CAL_VALUE.SUM_OF_ALL = 0; |
||||
BICst.TARGET_TYPE.CAL_VALUE.PERIOD = 1; |
||||
BICst.TARGET_TYPE.CAL_VALUE.SUM_OF_ABOVE = 2; |
||||
BICst.TARGET_TYPE.CAL_VALUE.RANK = 3; |
||||
BICst.TARGET_TYPE.CAL = {}; |
||||
BICst.TARGET_TYPE.CAL.FORMULA = 0; |
||||
BICst.TARGET_TYPE.CAL.CONFIGURATION = 1; |
||||
BICst.TARGET_TYPE.STRING = 1; |
||||
BICst.TARGET_TYPE.NUMBER = 2; |
||||
BICst.TARGET_TYPE.DATE = 3; |
||||
BICst.TARGET_TYPE.COUNTER = 4; |
||||
BICst.TARGET_TYPE.FORMULA = 5; |
||||
BICst.TARGET_TYPE.YEAR_ON_YEAR_RATE = 6; |
||||
BICst.TARGET_TYPE.MONTH_ON_MONTH_RATE = 7; |
||||
BICst.TARGET_TYPE.YEAR_ON_YEAR_VALUE = 8; |
||||
BICst.TARGET_TYPE.MONTH_ON_MONTH_VALUE = 9; |
||||
BICst.TARGET_TYPE.SUM_OF_ABOVE = 10; |
||||
BICst.TARGET_TYPE.SUM_OF_ABOVE_IN_GROUP = 11; |
||||
BICst.TARGET_TYPE.SUM_OF_ALL = 12; |
||||
BICst.TARGET_TYPE.SUM_OF_ALL_IN_GROUP = 13; |
||||
BICst.TARGET_TYPE.RANK = 14; |
||||
BICst.TARGET_TYPE.RANK_IN_GROUP = 15; |
||||
BICst.DIMENSION_FILTER_DATE = {}; |
||||
BICst.DIMENSION_FILTER_DATE.BELONG_VALUE = 98; |
||||
BICst.DIMENSION_FILTER_DATE.NOT_BELONG_VALUE = 99; |
||||
BICst.DIMENSION_FILTER_DATE.IS_NULL = 100; |
||||
BICst.DIMENSION_FILTER_DATE.NOT_NULL = 101; |
||||
BICst.DIMENSION_FILTER_DATE.TOP_N = 102; |
||||
BICst.DIMENSION_FILTER_DATE.BOTTOM_N = 103; |
||||
BICst.DIMENSION_FILTER_DATE.CONTAIN = 104; |
||||
BICst.DIMENSION_FILTER_DATE.NOT_CONTAIN = 105; |
||||
BICst.DIMENSION_FILTER_DATE.BEGIN_WITH = 106; |
||||
BICst.DIMENSION_FILTER_DATE.END_WITH = 107; |
||||
BICst.FILTER_TYPE = {}; |
||||
BICst.FILTER_TYPE.AND = 80; |
||||
BICst.FILTER_TYPE.OR = 81; |
||||
BICst.FILTER_TYPE.FORMULA = 82; |
||||
BICst.FILTER_TYPE.EMPTY_FORMULA = 90; |
||||
BICst.FILTER_TYPE.EMPTY_CONDITION = 91; |
||||
BICst.FILTER_TYPE.NUMBER_SUM = 83; |
||||
BICst.FILTER_TYPE.NUMBER_AVG = 84; |
||||
BICst.FILTER_TYPE.NUMBER_MAX = 85; |
||||
BICst.FILTER_TYPE.NUMBER_MIN = 86; |
||||
BICst.FILTER_TYPE.NUMBER_COUNT = 87; |
||||
BICst.FILTER_TYPE.TREE_FILTER = 88; |
||||
BICst.FILTER_TYPE.COLUMNFILTER = 89; |
||||
BICst.FILTER_TYPE.DIMENSION_TARGET_VALUE_FILTER = 96; |
||||
BICst.FILTER_TYPE.DIMENSION_SELF_FILTER = 97; |
||||
BICst.FILTER_DATE = {}; |
||||
BICst.FILTER_DATE.BELONG_DATE_RANGE = 64; |
||||
BICst.FILTER_DATE.BELONG_WIDGET_VALUE = 65; |
||||
BICst.FILTER_DATE.NOT_BELONG_DATE_RANGE = 66; |
||||
BICst.FILTER_DATE.NOT_BELONG_WIDGET_VALUE = 67; |
||||
BICst.FILTER_DATE.MORE_THAN = 68; |
||||
BICst.FILTER_DATE.LESS_THAN = 69; |
||||
BICst.FILTER_DATE.EQUAL_TO = 70; |
||||
BICst.FILTER_DATE.NOT_EQUAL_TO = 71; |
||||
BICst.FILTER_DATE.IS_NULL = 72; |
||||
BICst.FILTER_DATE.NOT_NULL = 73; |
||||
BICst.FILTER_DATE.EARLY_THAN = 74; |
||||
BICst.FILTER_DATE.LATER_THAN = 75; |
||||
BICst.FILTER_DATE.CONTAINS = 76; |
||||
BICst.FILTER_DATE.CONTAINS_DAY = 77; |
||||
BICst.FILTER_DATE.DAY_EQUAL_TO = 78; |
||||
BICst.FILTER_DATE.DAY_NOT_EQUAL_TO = 79; |
||||
BICst.TARGET_FILTER_NUMBER = {}; |
||||
BICst.TARGET_FILTER_NUMBER.EQUAL_TO = 48; |
||||
BICst.TARGET_FILTER_NUMBER.NOT_EQUAL_TO = 49; |
||||
BICst.TARGET_FILTER_NUMBER.BELONG_VALUE = 50; |
||||
BICst.TARGET_FILTER_NUMBER.BELONG_USER = 51; |
||||
BICst.TARGET_FILTER_NUMBER.NOT_BELONG_VALUE = 52; |
||||
BICst.TARGET_FILTER_NUMBER.NOT_BELONG_USER = 53; |
||||
BICst.TARGET_FILTER_NUMBER.IS_NULL = 54; |
||||
BICst.TARGET_FILTER_NUMBER.NOT_NULL = 55; |
||||
BICst.TARGET_FILTER_NUMBER.CONTAINS = 56; |
||||
BICst.TARGET_FILTER_NUMBER.NOT_CONTAINS = 57; |
||||
BICst.TARGET_FILTER_NUMBER.LARGE_THAN_CAL_LINE = 58; |
||||
BICst.TARGET_FILTER_NUMBER.LARGE_OR_EQUAL_CAL_LINE = 59; |
||||
BICst.TARGET_FILTER_NUMBER.SMALL_THAN_CAL_LINE = 60; |
||||
BICst.TARGET_FILTER_NUMBER.SMALL_OR_EQUAL_CAL_LINE = 61; |
||||
BICst.TARGET_FILTER_NUMBER.TOP_N = 62; |
||||
BICst.TARGET_FILTER_NUMBER.BOTTOM_N = 63; |
||||
BICst.TARGET_FILTER_STRING = {}; |
||||
BICst.TARGET_FILTER_STRING.BELONG_VALUE = 32; |
||||
BICst.TARGET_FILTER_STRING.BELONG_USER = 33; |
||||
BICst.TARGET_FILTER_STRING.NOT_BELONG_VALUE = 34; |
||||
BICst.TARGET_FILTER_STRING.NOT_BELONG_USER = 35; |
||||
BICst.TARGET_FILTER_STRING.CONTAIN = 36; |
||||
BICst.TARGET_FILTER_STRING.NOT_CONTAIN = 37; |
||||
BICst.TARGET_FILTER_STRING.IS_NULL = 38; |
||||
BICst.TARGET_FILTER_STRING.NOT_NULL = 39; |
||||
BICst.TARGET_FILTER_STRING.BEGIN_WITH = 40; |
||||
BICst.TARGET_FILTER_STRING.END_WITH = 41; |
||||
BICst.TARGET_FILTER_STRING.NOT_BEGIN_WITH = 42; |
||||
BICst.TARGET_FILTER_STRING.NOT_END_WITH = 43; |
||||
BICst.TARGET_FILTER_STRING.VAGUE_CONTAIN = 46; |
||||
BICst.TARGET_FILTER_STRING.NOT_VAGUE_CONTAIN = 47; |
||||
BICst.DIMENSION_FILTER_NUMBER = {}; |
||||
BICst.DIMENSION_FILTER_NUMBER.BELONG_VALUE = 16; |
||||
BICst.DIMENSION_FILTER_NUMBER.BELONG_USER = 17; |
||||
BICst.DIMENSION_FILTER_NUMBER.NOT_BELONG_VALUE = 18; |
||||
BICst.DIMENSION_FILTER_NUMBER.NOT_BELONG_USER = 19; |
||||
BICst.DIMENSION_FILTER_NUMBER.MORE_THAN_AVG = 20; |
||||
BICst.DIMENSION_FILTER_NUMBER.LESS_THAN_AVG = 21; |
||||
BICst.DIMENSION_FILTER_NUMBER.IS_NULL = 22; |
||||
BICst.DIMENSION_FILTER_NUMBER.NOT_NULL = 23; |
||||
BICst.DIMENSION_FILTER_NUMBER.TOP_N = 24; |
||||
BICst.DIMENSION_FILTER_NUMBER.BOTTOM_N = 25; |
||||
BICst.DIMENSION_FILTER_STRING = {}; |
||||
BICst.DIMENSION_FILTER_STRING.BELONG_VALUE = 0; |
||||
BICst.DIMENSION_FILTER_STRING.BELONG_USER = 1; |
||||
BICst.DIMENSION_FILTER_STRING.NOT_BELONG_VALUE = 2; |
||||
BICst.DIMENSION_FILTER_STRING.NOT_BELONG_USER = 3; |
||||
BICst.DIMENSION_FILTER_STRING.CONTAIN = 4; |
||||
BICst.DIMENSION_FILTER_STRING.NOT_CONTAIN = 5; |
||||
BICst.DIMENSION_FILTER_STRING.IS_NULL = 6; |
||||
BICst.DIMENSION_FILTER_STRING.NOT_NULL = 7; |
||||
BICst.DIMENSION_FILTER_STRING.BEGIN_WITH = 8; |
||||
BICst.DIMENSION_FILTER_STRING.END_WITH = 9; |
||||
BICst.DIMENSION_FILTER_STRING.TOP_N = 10; |
||||
BICst.DIMENSION_FILTER_STRING.BOTTOM_N = 11; |
||||
BICst.DIMENSION_FILTER_STRING.NOT_BEGIN_WITH = 12; |
||||
BICst.DIMENSION_FILTER_STRING.NOT_END_WITH = 13; |
||||
BICst.DIMENSION_FILTER_STRING.VAGUE_CONTAIN = 14; |
||||
BICst.DIMENSION_FILTER_STRING.NOT_VAGUE_CONTAIN = 15; |
||||
BICst.GROUP = {}; |
||||
BICst.GROUP.NO_GROUP = 0; |
||||
BICst.GROUP.AUTO_GROUP = 3; |
||||
BICst.GROUP.CUSTOM_GROUP = 4; |
||||
BICst.GROUP.CUSTOM_NUMBER_GROUP = 5; |
||||
BICst.GROUP.Y = 6; |
||||
BICst.GROUP.S = 7; |
||||
BICst.GROUP.M = 8; |
||||
BICst.GROUP.W = 9; |
||||
BICst.GROUP.YMD = 10; |
||||
BICst.GROUP.YD = 11; |
||||
BICst.GROUP.MD = 12; |
||||
BICst.GROUP.YMDHMS = 13; |
||||
BICst.GROUP.ID_GROUP = 14; |
||||
BICst.GROUP.HOUR = 15; |
||||
BICst.GROUP.MINUTE = 16; |
||||
BICst.GROUP.SECOND = 17; |
||||
BICst.GROUP.WEEK_COUNT = 18; |
||||
BICst.GROUP.D = 19; |
||||
BICst.GROUP.YM = 20; |
||||
BICst.GROUP.YW = 21; |
||||
BICst.GROUP.YMDH = 22; |
||||
BICst.GROUP.YMDHM = 23; |
||||
BICst.GROUP.YS = 24; |
||||
BICst.SUMMARY_TYPE = {}; |
||||
BICst.SUMMARY_TYPE.SUM = 0; |
||||
BICst.SUMMARY_TYPE.MAX = 1; |
||||
BICst.SUMMARY_TYPE.MIN = 2; |
||||
BICst.SUMMARY_TYPE.AVG = 3; |
||||
BICst.SUMMARY_TYPE.COUNT = 4; |
||||
BICst.SUMMARY_TYPE.APPEND = 5; |
||||
BICst.SUMMARY_TYPE.RECORD_COUNT = 6; |
||||
BICst.BI_REPORT = {}; |
||||
BICst.BI_REPORT.NULL = 0; |
||||
BICst.BI_REPORT.SUBMITED = 1; |
||||
BICst.BI_REPORT.PUBLISHED = 2; |
||||
BICst.VERSION = "4.0.2"; |
||||
BICst.SYSTEM_TIME = "__system_time-3e1d05defe78__"; |
||||
|
||||
BICst.ETL_ADD_COLUMN_TYPE = {}; |
||||
BICst.ETL_ADD_COLUMN_TYPE.FORMULA = "formula"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.DATE_DIFF = "date_diff"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.DATE_YEAR = "date_year"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.DATE_SEASON = "date_season"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.DATE_MONTH = "date_month"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.EXPR_CPP = "expr_same_period"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.EXPR_LP = "expr_last_period"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.EXPR_CPP_PERCENT = "expr_same_period_percent"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.EXPR_LP_PERCENT = "expr_last_period_percent"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.EXPR_SUM = "expr_sum"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.EXPR_ACC = "expr_acc"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.EXPR_RANK = "expr_rank"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.GROUP = "group_value"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.SINGLE_VALUE = "single_value"; |
||||
BICst.ETL_ADD_COLUMN_TYPE.VALUE_CONVERT = "value_convert"; |
||||
BICst.JSON_KEYS = {}; |
||||
BICst.JSON_KEYS.STATISTIC_ELEMENT = "_src"; |
||||
BICst.JSON_KEYS.FILED_MAX_VALUE = "max"; |
||||
BICst.JSON_KEYS.FIELD_MIN_VALUE = "min"; |
||||
BICst.JSON_KEYS.FILTER_VALUE = "filter_value"; |
||||
BICst.JSON_KEYS.FILTER_CONDITION = "condition"; |
||||
BICst.JSON_KEYS.FILTER_AND_OR = "andor"; |
||||
BICst.JSON_KEYS.FILTER_TYPE = "filter_type"; |
||||
BICst.JSON_KEYS.FIELD_ID = "field_id"; |
||||
BICst.JSON_KEYS.FIELD_TYPE = "field_type"; |
||||
BICst.JSON_KEYS.FIELD_VALUE = "field_value"; |
||||
BICst.JSON_KEYS.FIELD_NAME = "field_name"; |
||||
BICst.JSON_KEYS.TYPE = "type"; |
||||
BICst.JSON_KEYS.VALUE = "value"; |
||||
BICst.JSON_KEYS.EXPANDER = "expander"; |
||||
BICst.JSON_KEYS.EXPANDER_X = "x"; |
||||
BICst.JSON_KEYS.EXPANDER_Y = "y"; |
||||
BICst.JSON_KEYS.CLICKEDVALUE = "clickedvalue"; |
||||
BICst.JSON_KEYS.SETTTINGS = "settings"; |
||||
BICst.JSON_KEYS.ID = "id"; |
||||
BICst.JSON_KEYS.TABLES = "tables"; |
||||
BICst.JSON_KEYS.TABLE = "table"; |
||||
BICst.JSON_KEYS.FIELDS = "fields"; |
||||
BICst.JSON_KEYS.FIELD = "field"; |
||||
BICst.JSON_KEYS.ETL_TYPE = "etl_type"; |
||||
BICst.JSON_KEYS.ETL_VALUE = "etl_value"; |
||||
BICst.JSON_KEYS.TABLE_TYPE = "table_type"; |
||||
BICst.JSON_KEYS.HAS_NEXT = "hasNext"; |
||||
BICst.JSON_KEYS.CONNECTION_NAME = "connection_name"; |
||||
BICst.JSON_KEYS.TABLE_NAME = "table_name"; |
||||
BICst.JSON_KEYS.TRAN_NAME = "tran_name"; |
||||
BICst.JSON_KEYS.TABLE_TRAN_NAME = "table_tran_name"; |
||||
BICst.JSON_KEYS.FIELD_TRAN_NAME = "field_tran_name"; |
||||
BICst.JSON_KEYS.GROUP_NAME = "group_name"; |
||||
BICst.JSON_KEYS.PACKAGE_NAME = "package_name"; |
||||
BICst.JSON_KEYS.RELATIONS = "relations"; |
||||
BICst.JSON_KEYS.TRANSLATIONS = "translations"; |
||||
BICst.JSON_KEYS.UPDATESETTING = "update_setting"; |
||||
BICst.JSON_KEYS.PACKAGE_ID = "package_id"; |
||||
BICst.JSON_KEYS.CONNECTION_SET = "connectionSet"; |
||||
BICst.JSON_KEYS.PRIMARY_KEY_MAP = "primKeyMap"; |
||||
BICst.JSON_KEYS.FOREIGN_KEY_MAP = "foreignKeyMap"; |
||||
|
||||
BICst.DATA_CONFIG_DESIGN = {}; |
||||
BICst.DATA_CONFIG_DESIGN.NO = 0; |
||||
BICst.DATA_CONFIG_DESIGN.YES = 1; |
||||
BICst.DATA_CONFIG_AUTHORITY = {}; |
||||
BICst.DATA_CONFIG_AUTHORITY.PACKAGE_MANAGER = {}; |
||||
BICst.DATA_CONFIG_AUTHORITY.PACKAGE_MANAGER.NODE = "__package_manager_node__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.PACKAGE_MANAGER.PAGE = "__package_manager_page__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.PACKAGE_MANAGER.SERVER_CONNECTION = "__package_server_connection__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.PACKAGE_MANAGER.DATA_CONNECTION = "__package_data_connection__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.DATA_CONNECTION = {}; |
||||
BICst.DATA_CONFIG_AUTHORITY.DATA_CONNECTION.NODE = "__data_connection_node__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.DATA_CONNECTION.PAGE = "__data_connection_page__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.MULTI_PATH_SETTING = "__multi_path_setting__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.PACKAGE_AUTHORITY = "__package_authority__"; |
||||
BICst.DATA_CONFIG_AUTHORITY.FINE_INDEX_UPDATE = "__fine_index_update__"; |
||||
BICst.GLOBAL_UPDATE_TYPE = {}; |
||||
BICst.GLOBAL_UPDATE_TYPE.PART_UPDATE = "_part_update_"; |
||||
BICst.GLOBAL_UPDATE_TYPE.COMPLETE_UPDATE = "_complete_update_"; |
||||
BICst.GLOBAL_UPDATE_TYPE.META_UPDATE = "_meta_update_"; |
||||
BICst.CUBE_UPDATE_TYPE = {}; |
||||
BICst.CUBE_UPDATE_TYPE.GLOBAL_UPDATE = "__global_update__"; |
||||
BICst.CUBE_UPDATE_TYPE.SINGLETABLE_UPDATE = "__singleTable_update__"; |
||||
BICst.SINGLE_TABLE_UPDATE = {}; |
||||
BICst.SINGLE_TABLE_UPDATE.TOGETHER = 0; |
||||
BICst.SINGLE_TABLE_UPDATE.NEVER = 1; |
||||
BICst.SINGLE_TABLE_UPDATE_TYPE = {}; |
||||
BICst.SINGLE_TABLE_UPDATE_TYPE.ALL = 0; |
||||
BICst.SINGLE_TABLE_UPDATE_TYPE.PART = 1; |
||||
BICst.SINGLE_TABLE_UPDATE_TYPE.NEVER = 2; |
||||
BICst.UPDATE_FREQUENCY = {}; |
||||
BICst.UPDATE_FREQUENCY.EVER_DAY = 0; |
||||
BICst.UPDATE_FREQUENCY.EVER_SUNDAY = 1; |
||||
BICst.UPDATE_FREQUENCY.EVER_MONDAY = 2; |
||||
BICst.UPDATE_FREQUENCY.EVER_TUESDAY = 3; |
||||
BICst.UPDATE_FREQUENCY.EVER_WEDNESDAY = 4; |
||||
BICst.UPDATE_FREQUENCY.EVER_THURSDAY = 5; |
||||
BICst.UPDATE_FREQUENCY.EVER_FRIDAY = 6; |
||||
BICst.UPDATE_FREQUENCY.EVER_SATURDAY = 7; |
||||
BICst.UPDATE_FREQUENCY.EVER_MONTH = 10; |
||||
BICst.REQ_DATA_TYPE = {}; |
||||
BICst.REQ_DATA_TYPE.REQ_GET_ALL_DATA = -1; |
||||
BICst.REQ_DATA_TYPE.REQ_GET_DATA_LENGTH = 0; |
||||
BICst.TRANS_TYPE = {}; |
||||
BICst.TRANS_TYPE.READ_FROM_DB = "db"; |
||||
BICst.TRANS_TYPE.READ_FROM_TABLEDATA = "tabledata"; |
||||
BICst.TRANS_TYPE.CHOOSE = "choose"; |
||||
BICst.CONNECTION = {}; |
||||
BICst.CONNECTION.ETL_CONNECTION = "__FR_BI_ETL__"; |
||||
BICst.CONNECTION.SERVER_CONNECTION = "__FR_BI_SERVER__"; |
||||
BICst.CONNECTION.SQL_CONNECTION = "__FR_BI_SQL__"; |
||||
BICst.CONNECTION.EXCEL_CONNECTION = "__FR_BI_EXCEL__"; |
||||
BICst.COLUMN = {}; |
||||
BICst.COLUMN.NUMBER = 32; |
||||
BICst.COLUMN.STRING = 16; |
||||
BICst.COLUMN.DATE = 48; |
||||
BICst.COLUMN.COUNTER = 64; |
||||
BICst.COLUMN.ROW = 80; |
||||
BICst.CLASS = {}; |
||||
BICst.CLASS.INTEGER = 0; |
||||
BICst.CLASS.LONG = 1; |
||||
BICst.CLASS.DOUBLE = 2; |
||||
BICst.CLASS.FLOAT = 3; |
||||
BICst.CLASS.DATE = 4; |
||||
BICst.CLASS.STRING = 5; |
||||
BICst.CLASS.BOOLEAN = 6; |
||||
BICst.CLASS.TIMESTAMP = 7; |
||||
BICst.CLASS.DECIMAL = 8; |
||||
BICst.CLASS.TIME = 9; |
||||
BICst.CLASS.BYTE = 10; |
||||
BICst.CLASS.ROW = 16; |
||||
BICst.SYSTEM_USER_NAME = "__system_user_name__"; |
||||
BICst.LAST_UPDATE_TIME = "__last_update_time__"; |
||||
BICst.CURRENT_UPDATE_TIME = "__current_update_time__"; |
||||
|
||||
BICst.FUNCTION = {}; |
||||
BICst.FUNCTION.TEXT = 1; |
||||
BICst.FUNCTION.MATH = 2; |
||||
BICst.FUNCTION.DATE = 3; |
||||
BICst.FUNCTION.ARRAY = 4; |
||||
BICst.FUNCTION.LOGIC = 5; |
||||
BICst.FUNCTION.OTHER = 6; |
@ -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; |
||||
} |
||||
}); |
@ -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"); |
||||
}); |
@ -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); |
||||
}); |
@ -1,59 +0,0 @@
|
||||
/** |
||||
* 新建并选中某个分组按钮 |
||||
* |
||||
* Created by GUY on 2015/9/25. |
||||
* @class BI.Copy2GroupAddButton |
||||
* @extends BI.BasicButton |
||||
*/ |
||||
BI.Copy2GroupAddButton = BI.inherit(BI.BasicButton, { |
||||
|
||||
_defaultConfig: function () { |
||||
var conf = BI.Copy2GroupAddButton.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: (conf.baseCls || "") + ' bi-copy2group-add-button', |
||||
shadow: true, |
||||
isShadowShowingOnSelected: true, |
||||
height: 30 |
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.Copy2GroupAddButton.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.text = BI.createWidget({ |
||||
type: "bi.label", |
||||
textAlign: "left", |
||||
text: BI.i18nText("BI-Create_And_Select") + "\"江苏\"", |
||||
height: o.height |
||||
}) |
||||
BI.createWidget({ |
||||
type: "bi.htape", |
||||
element: this, |
||||
items: [{ |
||||
el: { |
||||
type: "bi.icon_button", |
||||
cls: "move2group-add-font" |
||||
}, |
||||
width: 30 |
||||
}, { |
||||
el: this.text |
||||
}] |
||||
}) |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.text.setValue(BI.i18nText("BI-Create_And_Select") + "\"" + v + "\""); |
||||
this.setTitle(BI.i18nText("BI-Create_And_Select") + "\"" + v + "\"", { |
||||
container: "body" |
||||
}); |
||||
}, |
||||
|
||||
doClick: function () { |
||||
BI.Copy2GroupAddButton.superclass.doClick.apply(this, arguments); |
||||
if (this.isValid()) { |
||||
this.fireEvent(BI.Copy2GroupAddButton.EVENT_CHANGE); |
||||
} |
||||
} |
||||
}); |
||||
BI.Copy2GroupAddButton.EVENT_CHANGE = "Copy2GroupAddButton.EVENT_CHANGE"; |
||||
$.shortcut('bi.copy2group_add_button', BI.Copy2GroupAddButton); |
@ -1,153 +0,0 @@
|
||||
/** |
||||
* 复制到分组下拉框 |
||||
* |
||||
* Created by GUY on 2015/9/25. |
||||
* @class BI.Copy2GroupCombo |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.Copy2GroupCombo = BI.inherit(BI.Single, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.Copy2GroupCombo.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: (conf.baseCls || "") + " bi-copy2group-combo", |
||||
height: 30, |
||||
tipType: "warning", |
||||
items: [] |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
BI.Copy2GroupCombo.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
|
||||
this.trigger = BI.createWidget({ |
||||
type: "bi.button", |
||||
text: BI.i18nText("BI-Copy_To_Group"), |
||||
height: o.height |
||||
}); |
||||
|
||||
this.tools = BI.createWidget({ |
||||
type: "bi.copy2group_bar" |
||||
}); |
||||
|
||||
this.tools.on(BI.Copy2GroupBar.EVENT_START, function () { |
||||
self.combo.adjustHeight(); |
||||
self.searcher.adjustHeight(); |
||||
}); |
||||
this.tools.on(BI.Copy2GroupBar.EVENT_EMPTY, function () { |
||||
self.combo.adjustHeight(); |
||||
}); |
||||
this.tools.on(BI.Copy2GroupBar.EVENT_CLICK_BUTTON, function () { |
||||
self.fireEvent(BI.Copy2GroupCombo.EVENT_CLICK_BUTTON); |
||||
self.searcher.stopSearch(); |
||||
}); |
||||
this.tools.on(BI.Copy2GroupBar.EVENT_CHANGE, function () { |
||||
this.setButtonVisible(!self.searcher.hasMatched()); |
||||
self.combo.adjustHeight(); |
||||
self.searcher.adjustHeight(); |
||||
}); |
||||
|
||||
this.popup = this._createPopup(this.options.items); |
||||
|
||||
|
||||
this.searcher = BI.createWidget({ |
||||
type: "bi.searcher", |
||||
el: this.tools, |
||||
chooseType: BI.Selection.Multi, |
||||
adapter: this.popup |
||||
}); |
||||
|
||||
this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { |
||||
|
||||
}); |
||||
|
||||
this.multipopup = BI.createWidget({ |
||||
type: "bi.multi_popup_view", |
||||
width: 200, |
||||
stopPropagation: false, |
||||
el: this.popup, |
||||
tool: this.searcher |
||||
}); |
||||
|
||||
|
||||
this.combo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
isNeedAdjustWidth: false, |
||||
element: this, |
||||
el: this.trigger, |
||||
popup: this.multipopup |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { |
||||
self.fireEvent(BI.Copy2GroupCombo.EVENT_BEFORE_POPUPVIEW); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { |
||||
self.searcher.stopSearch(); |
||||
}); |
||||
|
||||
this.multipopup.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (value) { |
||||
switch (value) { |
||||
case 0 : |
||||
self.fireEvent(BI.Copy2GroupCombo.EVENT_CONFIRM); |
||||
self.combo.hideView(); |
||||
break; |
||||
default : |
||||
break; |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
_createItems: function (items) { |
||||
return BI.createItems(items, { |
||||
type: "bi.multi_select_item", |
||||
height: 25, |
||||
handler: function (v) { |
||||
|
||||
} |
||||
}) |
||||
}, |
||||
|
||||
_createPopup: function (items, opt) { |
||||
return BI.createWidget(BI.extend({ |
||||
type: "bi.button_group", |
||||
items: this._createItems(items), |
||||
chooseType: 1, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}] |
||||
}, opt)); |
||||
}, |
||||
|
||||
|
||||
scrollToBottom: function () { |
||||
var self = this; |
||||
BI.delay(function () { |
||||
self.popup.element.scrollTop(BI.MAX); |
||||
}, 30); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.options.items = items; |
||||
this.combo.populate(this._createItems(items)); |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.combo.setValue(v); |
||||
this.searcher.setValue(v); |
||||
}, |
||||
|
||||
setEnable: function (enable) { |
||||
this.combo.setEnable.apply(this.combo, arguments); |
||||
}, |
||||
|
||||
getTargetValue: function () { |
||||
return this.tools.getValue(); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.searcher.getValue(); |
||||
} |
||||
}); |
||||
BI.Copy2GroupCombo.EVENT_BEFORE_POPUPVIEW = "Copy2GroupCombo.EVENT_BEFORE_POPUPVIEW"; |
||||
BI.Copy2GroupCombo.EVENT_CHANGE = "Copy2GroupCombo.EVENT_CHANGE"; |
||||
BI.Copy2GroupCombo.EVENT_CONFIRM = "Copy2GroupCombo.EVENT_CONFIRM"; |
||||
BI.Copy2GroupCombo.EVENT_CLICK_BUTTON = "Copy2GroupCombo.EVENT_CLICK_BUTTON"; |
||||
$.shortcut('bi.copy2group_combo', BI.Copy2GroupCombo); |
@ -1,85 +0,0 @@
|
||||
/** |
||||
* guy |
||||
* 复选导航条 |
||||
* Created by GUY on 2015/9/25. |
||||
* @class BI.Copy2GroupBar |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.Copy2GroupBar = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.Copy2GroupBar.superclass._defaultConfig.apply(this, arguments), { |
||||
extraCls: "bi-copy2group-bar" |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.Copy2GroupBar.superclass._init.apply(this, arguments); |
||||
var self = this; |
||||
this.search = BI.createWidget({ |
||||
type: "bi.text_editor", |
||||
watermark: BI.i18nText("BI-Search_And_Create_Group"), |
||||
allowBlank: true |
||||
}); |
||||
|
||||
this.search.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
|
||||
this.search.on(BI.TextEditor.EVENT_CHANGE, function () { |
||||
self.button.setValue(this.getValue()); |
||||
if(this.getValue() !== "") { |
||||
self.fireEvent(BI.Copy2GroupBar.EVENT_CHANGE); |
||||
} |
||||
}); |
||||
|
||||
this.search.on(BI.TextEditor.EVENT_EMPTY, function () { |
||||
self.button.invisible(); |
||||
self.fireEvent(BI.Copy2GroupBar.EVENT_EMPTY); |
||||
}); |
||||
|
||||
this.search.on(BI.TextEditor.EVENT_START, function () { |
||||
self.button.visible(); |
||||
self.fireEvent(BI.Copy2GroupBar.EVENT_START); |
||||
}); |
||||
|
||||
this.button = BI.createWidget({ |
||||
type: "bi.copy2group_add_button" |
||||
}); |
||||
|
||||
this.button.on(BI.Copy2GroupAddButton.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Copy2GroupBar.EVENT_CLICK_BUTTON); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.vertical", |
||||
element: this, |
||||
vgap: 5, |
||||
hgap: 5, |
||||
items: [this.search, this.button] |
||||
}); |
||||
|
||||
this.button.invisible(); |
||||
}, |
||||
|
||||
blur: function(){ |
||||
this.search.blur(); |
||||
}, |
||||
|
||||
setButtonVisible: function (b) { |
||||
this.button.setVisible(b); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.search.getValue(); |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.search.setValue(v); |
||||
this.button.setValue(v); |
||||
} |
||||
}); |
||||
BI.Copy2GroupBar.EVENT_CHANGE = "Copy2GroupBar.EVENT_CHANGE"; |
||||
BI.Copy2GroupBar.EVENT_START = "Copy2GroupBar.EVENT_START"; |
||||
BI.Copy2GroupBar.EVENT_EMPTY = "Copy2GroupBar.EVENT_EMPTY"; |
||||
BI.Copy2GroupBar.EVENT_CLICK_BUTTON = "Copy2GroupBar.EVENT_CLICK_BUTTON"; |
||||
$.shortcut("bi.copy2group_bar", BI.Copy2GroupBar); |
@ -1,61 +0,0 @@
|
||||
/** |
||||
* 日期控件中的月份下拉框 |
||||
* |
||||
* Created by GUY on 2015/9/7. |
||||
* @class BI.MonthDateCombo |
||||
* @extends BI.Trigger |
||||
*/ |
||||
BI.MonthDateCombo = BI.inherit(BI.Trigger, { |
||||
_defaultConfig: function() { |
||||
return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-month-combo", |
||||
height: 25 |
||||
}); |
||||
}, |
||||
_init: function() { |
||||
BI.MonthDateCombo.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
|
||||
this.trigger = BI.createWidget({ |
||||
type: "bi.date_triangle_trigger" |
||||
}); |
||||
|
||||
this.popup = BI.createWidget({ |
||||
type: "bi.month_popup" |
||||
}); |
||||
|
||||
this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ |
||||
self.setValue(self.popup.getValue()); |
||||
}) |
||||
|
||||
|
||||
this.combo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
offsetStyle: "center", |
||||
element: this, |
||||
isNeedAdjustHeight: false, |
||||
isNeedAdjustWidth: false, |
||||
el: this.trigger, |
||||
popup: { |
||||
minWidth: 85, |
||||
stopPropagation: false, |
||||
el: this.popup |
||||
} |
||||
}) |
||||
this.combo.on(BI.Combo.EVENT_CHANGE, function(){ |
||||
self.combo.hideView(); |
||||
self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE); |
||||
}); |
||||
}, |
||||
|
||||
setValue: function(v){ |
||||
this.trigger.setValue(v + 1); |
||||
this.popup.setValue(v); |
||||
}, |
||||
|
||||
getValue: function(){ |
||||
return this.popup.getValue(); |
||||
} |
||||
}); |
||||
BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut('bi.month_date_combo', BI.MonthDateCombo); |
@ -1,66 +0,0 @@
|
||||
/** |
||||
* 年份下拉框 |
||||
* |
||||
* Created by GUY on 2015/9/7. |
||||
* @class BI.YearDateCombo |
||||
* @extends BI.Trigger |
||||
*/ |
||||
BI.YearDateCombo = BI.inherit(BI.Trigger, { |
||||
_defaultConfig: function() { |
||||
return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-year-combo", |
||||
min: '1900-01-01', //最小日期
|
||||
max: '2099-12-31', //最大日期
|
||||
height: 25 |
||||
}); |
||||
}, |
||||
_init: function() { |
||||
BI.YearDateCombo.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
|
||||
this.trigger = BI.createWidget({ |
||||
type: "bi.date_triangle_trigger" |
||||
}); |
||||
|
||||
this.popup = BI.createWidget({ |
||||
type: "bi.year_popup", |
||||
min: o.min, |
||||
max: o.max |
||||
}); |
||||
|
||||
this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ |
||||
self.setValue(self.popup.getValue()); |
||||
self.combo.hideView(); |
||||
self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); |
||||
}) |
||||
|
||||
|
||||
this.combo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
offsetStyle: "center", |
||||
element: this, |
||||
isNeedAdjustHeight: false, |
||||
isNeedAdjustWidth: false, |
||||
el: this.trigger, |
||||
popup: { |
||||
minWidth: 85, |
||||
stopPropagation: false, |
||||
el: this.popup |
||||
} |
||||
}) |
||||
this.combo.on(BI.Combo.EVENT_CHANGE, function(){ |
||||
self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); |
||||
}) |
||||
}, |
||||
|
||||
setValue: function(v){ |
||||
this.trigger.setValue(v); |
||||
this.popup.setValue(v); |
||||
}, |
||||
|
||||
getValue: function(){ |
||||
return this.popup.getValue(); |
||||
} |
||||
}); |
||||
BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut('bi.year_date_combo', BI.YearDateCombo); |
@ -1,127 +0,0 @@
|
||||
/** |
||||
* Created by GUY on 2015/9/7. |
||||
* @class BI.DatePicker |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.DatePicker = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: "bi-date-picker", |
||||
height: 25, |
||||
min: '1900-01-01', //最小日期
|
||||
max: '2099-12-31' //最大日期
|
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.DatePicker.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this._year = new Date().getFullYear(); |
||||
this._month = new Date().getMonth(); |
||||
this.left = BI.createWidget({ |
||||
type: "bi.icon_button", |
||||
cls: "pre-page-h-font", |
||||
width: 25, |
||||
height: 25 |
||||
}); |
||||
this.left.on(BI.IconButton.EVENT_CHANGE, function () { |
||||
if (self._month === 0) { |
||||
self.setValue({ |
||||
year: self.year.getValue() - 1, |
||||
month: 11 |
||||
}) |
||||
} else { |
||||
self.setValue({ |
||||
year: self.year.getValue(), |
||||
month: self.month.getValue() - 1 |
||||
}) |
||||
} |
||||
self.fireEvent(BI.DatePicker.EVENT_CHANGE); |
||||
}); |
||||
|
||||
this.right = BI.createWidget({ |
||||
type: "bi.icon_button", |
||||
cls: "next-page-h-font", |
||||
width: 25, |
||||
height: 25 |
||||
}); |
||||
|
||||
this.right.on(BI.IconButton.EVENT_CHANGE, function () { |
||||
if (self._month === 11) { |
||||
self.setValue({ |
||||
year: self.year.getValue() + 1, |
||||
month: 0 |
||||
}) |
||||
} else { |
||||
self.setValue({ |
||||
year: self.year.getValue(), |
||||
month: self.month.getValue() + 1 |
||||
}) |
||||
} |
||||
self.fireEvent(BI.DatePicker.EVENT_CHANGE); |
||||
}); |
||||
|
||||
this.year = BI.createWidget({ |
||||
type: "bi.year_date_combo", |
||||
min: o.min, |
||||
max: o.max |
||||
}); |
||||
this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { |
||||
self.setValue({ |
||||
year: self.year.getValue(), |
||||
month: self.month.getValue() |
||||
}); |
||||
self.fireEvent(BI.DatePicker.EVENT_CHANGE); |
||||
}) |
||||
this.month = BI.createWidget({ |
||||
type: "bi.month_date_combo" |
||||
}); |
||||
this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () { |
||||
self.setValue({ |
||||
year: self.year.getValue(), |
||||
month: self.month.getValue() |
||||
}); |
||||
self.fireEvent(BI.DatePicker.EVENT_CHANGE); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.htape", |
||||
element: this, |
||||
items: [{ |
||||
el: this.left, |
||||
width: 25 |
||||
}, { |
||||
type: "bi.center_adapt", |
||||
items: [{ |
||||
type: "bi.horizontal", |
||||
width: 100, |
||||
items: [this.year, this.month] |
||||
}] |
||||
}, { |
||||
el: this.right, |
||||
width: 25 |
||||
}] |
||||
}) |
||||
this.setValue({ |
||||
year: this._year, |
||||
month: this._month |
||||
}) |
||||
}, |
||||
|
||||
setValue: function (ob) { |
||||
this._year = ob.year; |
||||
this._month = ob.month; |
||||
this.year.setValue(ob.year); |
||||
this.month.setValue(ob.month); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return { |
||||
year: this.year.getValue(), |
||||
month: this.month.getValue() |
||||
} |
||||
} |
||||
}); |
||||
BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE" |
||||
$.shortcut("bi.date_picker", BI.DatePicker); |
@ -1,96 +0,0 @@
|
||||
/** |
||||
* Created by GUY on 2015/9/7. |
||||
* @class BI.DateCalendarPopup |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.DateCalendarPopup = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: "bi-date-calendar-popup", |
||||
min: '1900-01-01', //最小日期
|
||||
max: '2099-12-31', //最大日期
|
||||
selectedTime: null |
||||
}) |
||||
}, |
||||
|
||||
_createNav: function (v) { |
||||
var date = BI.Calendar.getDateJSONByPage(v); |
||||
var calendar = BI.createWidget({ |
||||
type: "bi.calendar", |
||||
logic: { |
||||
dynamic: true |
||||
}, |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
year: date.year, |
||||
month: date.month, |
||||
day: this.selectedTime.day |
||||
}); |
||||
return calendar; |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.DateCalendarPopup.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.today = new Date(); |
||||
this._year = this.today.getFullYear(); |
||||
this._month = this.today.getMonth(); |
||||
this._day = this.today.getDate(); |
||||
|
||||
this.selectedTime = o.selectedTime || { |
||||
year: this._year, |
||||
month: this._month, |
||||
day: this._day |
||||
}; |
||||
this.datePicker = BI.createWidget({ |
||||
type: "bi.date_picker", |
||||
min: o.min, |
||||
max: o.max |
||||
}); |
||||
|
||||
this.calendar = BI.createWidget({ |
||||
direction: "top", |
||||
element: this, |
||||
logic: { |
||||
dynamic: true |
||||
}, |
||||
type: "bi.navigation", |
||||
tab: this.datePicker, |
||||
cardCreator: BI.bind(this._createNav, this), |
||||
|
||||
afterCardCreated: function () { |
||||
|
||||
}, |
||||
|
||||
afterCardShow: function () { |
||||
this.setValue(self.selectedTime); |
||||
} |
||||
}); |
||||
|
||||
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { |
||||
self.selectedTime = self.datePicker.getValue(); |
||||
self.selectedTime.day = 1; |
||||
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); |
||||
}); |
||||
|
||||
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { |
||||
self.selectedTime = self.calendar.getValue(); |
||||
self.setValue(self.selectedTime); |
||||
self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); |
||||
}); |
||||
}, |
||||
|
||||
setValue: function (timeOb) { |
||||
this.datePicker.setValue(timeOb); |
||||
this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); |
||||
this.calendar.setValue(timeOb); |
||||
this.selectedTime = timeOb; |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.selectedTime; |
||||
} |
||||
}); |
||||
BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup); |
@ -1,70 +0,0 @@
|
||||
/** |
||||
* 日期控件中的年份或月份trigger |
||||
* |
||||
* Created by GUY on 2015/9/7. |
||||
* @class BI.DateTriangleTrigger |
||||
* @extends BI.Trigger |
||||
*/ |
||||
BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { |
||||
_const: { |
||||
height: 25, |
||||
iconWidth: 16, |
||||
iconHeight: 13 |
||||
}, |
||||
|
||||
_defaultConfig: function() { |
||||
return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", |
||||
height: 25 |
||||
}); |
||||
}, |
||||
_init: function() { |
||||
BI.DateTriangleTrigger.superclass._init.apply(this, arguments); |
||||
var o = this.options, c = this._const; |
||||
this.text = BI.createWidget({ |
||||
type: "bi.label", |
||||
cls: "list-item-text", |
||||
textAlign: "right", |
||||
text: o.text, |
||||
value: o.value, |
||||
height: c.height |
||||
}) |
||||
this.icon = BI.createWidget({ |
||||
type: "bi.icon", |
||||
width: c.iconWidth, |
||||
height: c.iconHeight |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.center_adapt", |
||||
element: this, |
||||
items: [{ |
||||
type: "bi.center_adapt", |
||||
width: 50, |
||||
height: c.height, |
||||
items: [this.text, this.icon] |
||||
}] |
||||
}) |
||||
}, |
||||
|
||||
setValue: function(v){ |
||||
this.text.setValue(v); |
||||
}, |
||||
|
||||
getValue: function(){ |
||||
return this.text.getValue(); |
||||
}, |
||||
|
||||
setText: function(v){ |
||||
this.text.setText(v); |
||||
}, |
||||
|
||||
getText: function(){ |
||||
return this.item.getText(); |
||||
}, |
||||
|
||||
getKey: function(){ |
||||
|
||||
} |
||||
}); |
||||
$.shortcut('bi.date_triangle_trigger', BI.DateTriangleTrigger); |
@ -1,59 +0,0 @@
|
||||
/** |
||||
* 日期下拉框 |
||||
* |
||||
* Created by GUY on 2015/9/7. |
||||
* @class BI.DateCombo |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.DateCombo = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-date-combo", |
||||
height: 30 |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
BI.DateCombo.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
|
||||
this.trigger = BI.createWidget({ |
||||
type: "bi.date_trigger" |
||||
}); |
||||
|
||||
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { |
||||
self.combo.toggle(); |
||||
}); |
||||
|
||||
this.popup = BI.createWidget({ |
||||
type: "bi.date_calendar_popup" |
||||
}); |
||||
|
||||
this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { |
||||
self.setValue(self.popup.getValue()); |
||||
}); |
||||
|
||||
this.combo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
toggle: false, |
||||
element: this, |
||||
isNeedAdjustHeight: false, |
||||
isNeedAdjustWidth: false, |
||||
el: this.trigger, |
||||
popup: { |
||||
width: 270, |
||||
el: this.popup, |
||||
stopPropagation: false |
||||
} |
||||
}) |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.trigger.setValue(v); |
||||
this.popup.setValue(v); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.popup.getValue(); |
||||
} |
||||
}); |
||||
$.shortcut('bi.date_combo', BI.DateCombo); |
@ -1,269 +0,0 @@
|
||||
BI.DateTrigger = BI.inherit(BI.Trigger, { |
||||
_const: { |
||||
hgap: 4, |
||||
vgap: 2, |
||||
triggerWidth: 30, |
||||
watermark: BI.i18nText("BI-Unrestricted"), |
||||
yearLength: 4, |
||||
yearMonthLength: 7 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), { |
||||
extraCls: "bi-date-trigger", |
||||
min: '1900-01-01', //最小日期
|
||||
max: '2099-12-31', //最大日期
|
||||
height: 25 |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
BI.DateTrigger.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options, c = this._const; |
||||
this.editor = BI.createWidget({ |
||||
type: "bi.sign_editor", |
||||
height: o.height, |
||||
validationChecker: function (v) { |
||||
var date = v.match(/\d+/g); |
||||
self._autoAppend(v, date); |
||||
return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({ |
||||
year: date[0], |
||||
month: date[1], |
||||
day: date[2] |
||||
}); |
||||
}, |
||||
quitChecker: function () { |
||||
return false; |
||||
}, |
||||
hgap: c.hgap, |
||||
vgap: c.vgap, |
||||
allowBlank: true, |
||||
watermark: c.watermark, |
||||
errorText: function () { |
||||
if (self.editor.isEditing()) { |
||||
return BI.i18nText("BI-Date_Trigger_Error_Text"); |
||||
} |
||||
return BI.i18nText("BI-Year_Trigger_Invalid_Text"); |
||||
} |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { |
||||
self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN) |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { |
||||
self.fireEvent(BI.DateTrigger.EVENT_FOCUS); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_VALID, function () { |
||||
self.fireEvent(BI.DateTrigger.EVENT_VALID); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_ERROR, function () { |
||||
self.fireEvent(BI.DateTrigger.EVENT_ERROR); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { |
||||
var value = self.editor.getValue(); |
||||
if (BI.isNotNull(value)) { |
||||
self.editor.setState(value); |
||||
} |
||||
|
||||
if (BI.isNotEmptyString(value)) { |
||||
var date = value.split("-"); |
||||
self.store_value = { |
||||
type: BICst.MULTI_DATE_CALENDAR, |
||||
value:{ |
||||
year: date[0] | 0, |
||||
month: date[1] - 1, |
||||
day: date[2] | 0 |
||||
} |
||||
}; |
||||
} |
||||
self.fireEvent(BI.DateTrigger.EVENT_CONFIRM); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_SPACE, function () { |
||||
if (self.editor.isValid()) { |
||||
self.editor.blur(); |
||||
} |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_START, function () { |
||||
self.fireEvent(BI.DateTrigger.EVENT_START); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_STOP, function () { |
||||
self.fireEvent(BI.DateTrigger.EVENT_STOP); |
||||
}); |
||||
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.DateTrigger.EVENT_CHANGE); |
||||
}); |
||||
BI.createWidget({ |
||||
type: "bi.htape", |
||||
element: this, |
||||
items: [{ |
||||
el: BI.createWidget(), |
||||
width: 30 |
||||
}, { |
||||
el: this.editor |
||||
}] |
||||
}) |
||||
}, |
||||
_dateCheck: function (date) { |
||||
return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; |
||||
}, |
||||
_checkVoid: function (obj) { |
||||
return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; |
||||
}, |
||||
_autoAppend: function (v, dateObj) { |
||||
var self = this; |
||||
var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); |
||||
var yearCheck = function (v) { |
||||
return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max; |
||||
}; |
||||
var monthCheck = function (v) { |
||||
return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max; |
||||
}; |
||||
if (BI.isNotNull(dateObj) && Date.checkLegal(v)) { |
||||
switch (v.length) { |
||||
case this._const.yearLength: |
||||
if (yearCheck(v)) { |
||||
this.editor.setValue(v + "-"); |
||||
} |
||||
break; |
||||
case this._const.yearMonthLength: |
||||
if (monthCheck(v)) { |
||||
this.editor.setValue(v + "-"); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
var type, value, self = this; |
||||
var date = new Date(); |
||||
this.store_value = v; |
||||
if (BI.isNotNull(v)) { |
||||
type = v.type || BICst.MULTI_DATE_CALENDAR; value = v.value; |
||||
if(BI.isNull(value)){ |
||||
value = v; |
||||
} |
||||
} |
||||
var _setInnerValue = function (date, text) { |
||||
var dateStr = date.print("%Y-%x-%e"); |
||||
self.editor.setState(dateStr); |
||||
self.editor.setValue(dateStr); |
||||
self.setTitle(text + ":" + dateStr); |
||||
}; |
||||
switch (type) { |
||||
case BICst.MULTI_DATE_YEAR_PREV: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_PREV]; |
||||
date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate()); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_YEAR_AFTER: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_AFTER]; |
||||
date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate()); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_YEAR_BEGIN: |
||||
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_BEGIN]; |
||||
date = new Date(date.getFullYear(), 0, 1); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_YEAR_END: |
||||
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_END]; |
||||
date = new Date(date.getFullYear(), 11, 31); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_QUARTER_PREV: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_PREV]; |
||||
date = new Date().getBeforeMulQuarter(value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_QUARTER_AFTER: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_AFTER]; |
||||
date = new Date().getAfterMulQuarter(value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_QUARTER_BEGIN: |
||||
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_BEGIN]; |
||||
date = new Date().getQuarterStartDate(); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_QUARTER_END: |
||||
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_END]; |
||||
date = new Date().getQuarterEndDate(); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_MONTH_PREV: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_PREV]; |
||||
date = new Date().getBeforeMultiMonth(value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_MONTH_AFTER: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_AFTER]; |
||||
date = new Date().getAfterMultiMonth(value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_MONTH_BEGIN: |
||||
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_BEGIN]; |
||||
date = new Date(date.getFullYear(), date.getMonth(), 1); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_MONTH_END: |
||||
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_END]; |
||||
date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_WEEK_PREV: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_PREV]; |
||||
date = date.getOffsetDate(-7 * value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_WEEK_AFTER: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_AFTER]; |
||||
date = date.getOffsetDate(7 * value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_DAY_PREV: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_PREV]; |
||||
date = date.getOffsetDate(-1 * value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_DAY_AFTER: |
||||
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_AFTER]; |
||||
date = date.getOffsetDate(1 * value); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
case BICst.MULTI_DATE_DAY_TODAY: |
||||
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_TODAY]; |
||||
date = new Date(); |
||||
_setInnerValue(date, text); |
||||
break; |
||||
default: |
||||
if (BI.isNull(value) || BI.isNull(value.day)) { |
||||
this.editor.setState(""); |
||||
this.editor.setValue(""); |
||||
this.setTitle(""); |
||||
} else { |
||||
var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day; |
||||
this.editor.setState(dateStr); |
||||
this.editor.setValue(dateStr); |
||||
this.setTitle(dateStr); |
||||
} |
||||
break; |
||||
} |
||||
}, |
||||
|
||||
getKey: function () { |
||||
return this.editor.getValue(); |
||||
}, |
||||
getValue: function () { |
||||
return this.store_value; |
||||
} |
||||
|
||||
}); |
||||
BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; |
||||
BI.DateTrigger.EVENT_START = "EVENT_START"; |
||||
BI.DateTrigger.EVENT_STOP = "EVENT_STOP"; |
||||
BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||
BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.DateTrigger.EVENT_VALID = "EVENT_VALID"; |
||||
BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR"; |
||||
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; |
||||
BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; |
||||
$.shortcut("bi.date_trigger", BI.DateTrigger); |
@ -1,49 +0,0 @@
|
||||
/** |
||||
* 过滤条件抽象类 |
||||
* |
||||
* @class BI.AbstractFilterItem |
||||
* @extend BI.Widget |
||||
*/ |
||||
BI.AbstractFilterItem = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.AbstractFilterItem.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-filter-item" |
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.AbstractFilterItem.superclass._init.apply(this, arguments); |
||||
}, |
||||
|
||||
isSelectedCondition: function () { |
||||
return this.emptyItem && this.emptyItem.isVisible(); |
||||
}, |
||||
|
||||
setSelectedCondition: function (b) { |
||||
if (!!b) { |
||||
if (!this.emptyItem) { |
||||
this.emptyItem = BI.createWidget({ |
||||
type: "bi.absolute", |
||||
height: 40, |
||||
cls: "filter-item-empty-item", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.center_adapt", |
||||
cls: "empty-filter-item-leaf" |
||||
} |
||||
}], |
||||
hgap: 10, |
||||
vgap: 5 |
||||
}); |
||||
BI.createWidget({ |
||||
type: "bi.vertical", |
||||
element: this, |
||||
items: [this.emptyItem], |
||||
scrolly: false |
||||
}); |
||||
} |
||||
} |
||||
this.emptyItem && this.emptyItem.setVisible(b); |
||||
} |
||||
}); |
@ -1,79 +0,0 @@
|
||||
/** |
||||
* @class BI.FilterExpander |
||||
* @extend BI.AbstractFilterItem |
||||
* 过滤树的一个expander节点 |
||||
*/ |
||||
BI.FilterExpander = BI.inherit(BI.AbstractFilterItem, { |
||||
|
||||
_constant: { |
||||
EXPANDER_WIDTH: 20 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
var conf = BI.FilterExpander.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
baseCls: (conf.baseCls || "") + " bi-filter-expander", |
||||
el: {}, |
||||
popup: {} |
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.FilterExpander.superclass._init.apply(this, arguments); |
||||
this._initExpander(); |
||||
this._initConditionsView(); |
||||
BI.createWidget({ |
||||
type: "bi.horizontal_adapt", |
||||
element: this, |
||||
items: [this.expander, this.conditionsView] |
||||
}); |
||||
}, |
||||
|
||||
_initExpander: function () { |
||||
var self = this, o = this.options; |
||||
var value = o.value, text = ""; |
||||
if (value === BICst.FILTER_TYPE.AND) { |
||||
text = BI.i18nText("BI-Basic_And"); |
||||
} else { |
||||
text = BI.i18nText("BI-Basic_Or"); |
||||
} |
||||
this.expander = BI.createWidget({ |
||||
type: "bi.text_button", |
||||
cls: "condition-and-or", |
||||
text: text, |
||||
value: value, |
||||
id: o.id, |
||||
width: this._constant.EXPANDER_WIDTH, |
||||
height: "100%" |
||||
}); |
||||
this.expander.on(BI.Controller.EVENT_CHANGE, function (type) { |
||||
arguments[2] = self; |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
}, |
||||
|
||||
_initConditionsView: function () { |
||||
var self = this, popup = this.options.popup; |
||||
this.conditionsView = BI.createWidget(popup); |
||||
this.conditionsView.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return { |
||||
type: this.expander.getValue(), |
||||
value: this.conditionsView.getValue(), |
||||
id: this.options.id |
||||
}; |
||||
}, |
||||
|
||||
setValue: function () { |
||||
|
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.conditionsView.populate.apply(this.conditionsView, arguments); |
||||
} |
||||
}); |
||||
$.shortcut("bi.filter_expander", BI.FilterExpander); |
@ -1,181 +0,0 @@
|
||||
/** |
||||
* 过滤 |
||||
* |
||||
* Created by GUY on 2015/11/20. |
||||
* @class BI.Filter |
||||
* @extend BI.Widget |
||||
*/ |
||||
BI.Filter = BI.inherit(BI.Widget, { |
||||
|
||||
constants: { |
||||
FIELD_TYPE_NUMBER: 1, |
||||
FIELD_TYPE_STRING: 0, |
||||
FIELD_TYPE_DATE: 2 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.Filter.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-filter", |
||||
expander: {}, |
||||
items: [], |
||||
el: {}, |
||||
itemCreator: BI.empty |
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.Filter.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.filter = BI.createWidget(o.el,{ |
||||
type: "bi.filter_operation", |
||||
expander: o.expander, |
||||
items: o.items, |
||||
element: this |
||||
}); |
||||
this.filter.on(BI.FilterOperation.EVENT_OPERATION, function (type) { |
||||
switch (type) { |
||||
case BICst.FILTER_OPERATION_CONDITION: |
||||
case BICst.FILTER_OPERATION_CONDITION_AND: |
||||
self._addAndOrCondition(BICst.FILTER_TYPE.EMPTY_CONDITION); |
||||
break; |
||||
case BICst.FILTER_OPERATION_CONDITION_OR: |
||||
self._addAndOrCondition(BICst.FILTER_TYPE.EMPTY_CONDITION, 1); |
||||
break; |
||||
case BICst.FILTER_OPERATION_FORMULA: |
||||
case BICst.FILTER_OPERATION_FORMULA_AND: |
||||
self._addAndOrCondition(BICst.FILTER_TYPE.EMPTY_FORMULA); |
||||
break; |
||||
case BICst.FILTER_OPERATION_FORMULA_OR: |
||||
self._addAndOrCondition(BICst.FILTER_TYPE.EMPTY_FORMULA, 1); |
||||
break; |
||||
} |
||||
}); |
||||
this.filter.on(BI.FilterOperation.EVENT_DESTROY_ITEM, function (id) { |
||||
self._removeCondition(id); |
||||
}); |
||||
|
||||
this.tree = new BI.Tree(); |
||||
this.tree.initTree(o.items); |
||||
}, |
||||
|
||||
_removeCondition: function (id) { |
||||
var finded = this.tree.search(id); |
||||
if (BI.isNotNull(finded)) { |
||||
var parent = finded.getParent(); |
||||
parent.removeChild(id); |
||||
if (parent.getChildrenLength() <= 1) { |
||||
var prev = parent.getParent(); |
||||
if (BI.isNotNull(prev)) { |
||||
var index = prev.getChildIndex(parent.id); |
||||
prev.removeChildByIndex(index); |
||||
if (parent.getChildrenLength() === 1) { |
||||
prev.addChild(parent.getFirstChild(), index); |
||||
} |
||||
} |
||||
} |
||||
this._populate(this.tree.toJSONWithNode()); |
||||
this.fireEvent(BI.Filter.EVENT_CHANGE); |
||||
} |
||||
}, |
||||
|
||||
_createEmptyNode: function (type) { |
||||
var node = new BI.Node(BI.UUID()); |
||||
node.set("data", { |
||||
value: type |
||||
}); |
||||
return node; |
||||
}, |
||||
|
||||
_insertAndOrCondition: function (id, formulaOrField, type) { |
||||
var ANDOR = ["AND", "OR"]; |
||||
type || (type = 0); |
||||
var finded = this.tree.search(id); |
||||
if (BI.isNotNull(finded)) { |
||||
var data = finded.get("data"); |
||||
var parent = finded.getParent(); |
||||
var index = parent.getChildIndex(finded.id); |
||||
var pdata = parent.get("data") || {}; |
||||
var node = this._createEmptyNode(formulaOrField); |
||||
if (data.value === BICst.FILTER_TYPE[ANDOR[type]]) { |
||||
this.tree.addNode(finded, node); |
||||
return; |
||||
} |
||||
if (data.value === BICst.FILTER_TYPE[ANDOR[1 - type]]) { |
||||
if (pdata.value === BICst.FILTER_TYPE[ANDOR[type]]) { |
||||
parent.addChild(node, index + 1); |
||||
return; |
||||
} |
||||
} |
||||
if ((data.value === BICst.FILTER_TYPE[ANDOR[1 - type]] && pdata.value !== BICst.FILTER_TYPE[ANDOR[type]]) |
||||
|| pdata.value === BICst.FILTER_TYPE[ANDOR[1 - type]] |
||||
|| (pdata.value !== BICst.FILTER_TYPE.AND && pdata.value !== BICst.FILTER_TYPE.OR)) { |
||||
var andor = new BI.Node(BI.UUID()); |
||||
andor.set("data", { |
||||
value: BICst.FILTER_TYPE[ANDOR[type]], |
||||
children: [finded.get("data"), node.get("data")] |
||||
}); |
||||
parent.removeChildByIndex(index); |
||||
parent.addChild(andor, index); |
||||
andor.addChild(finded); |
||||
andor.addChild(node); |
||||
return; |
||||
} |
||||
parent.addChild(node, index + 1); |
||||
} |
||||
}, |
||||
|
||||
_addAndOrCondition: function (formulaOrField, type) { |
||||
var ANDOR = ["AND", "OR"]; |
||||
type || (type = 0); |
||||
var o = this.options; |
||||
var currentSelectItem = this.filter.getCurrentSelectItem(); |
||||
if (BI.isNotNull(currentSelectItem)) { |
||||
var id = currentSelectItem.attr("id"); |
||||
this._insertAndOrCondition(id, formulaOrField, type); |
||||
} else { |
||||
var node = this._createEmptyNode(formulaOrField); |
||||
var root = this.tree.getRoot(); |
||||
var child = root.getLastChild(); |
||||
if (BI.isNotNull(child)) { |
||||
var data = child.get("data"); |
||||
if (data.value === BICst.FILTER_TYPE[ANDOR[type]]) { |
||||
this.tree.addNode(child, node); |
||||
} else { |
||||
var andor = new BI.Node(BI.UUID()); |
||||
andor.set("data", { |
||||
value: BICst.FILTER_TYPE[ANDOR[type]], |
||||
children: [child.get("data"), node.get("data")] |
||||
}); |
||||
root.removeChild(child.id); |
||||
this.tree.addNode(andor); |
||||
this.tree.addNode(andor, child); |
||||
this.tree.addNode(andor, node); |
||||
} |
||||
} else { |
||||
this.tree.addNode(node); |
||||
} |
||||
} |
||||
this._populate(this.tree.toJSONWithNode()); |
||||
this.fireEvent(BI.Filter.EVENT_CHANGE); |
||||
}, |
||||
|
||||
_populate: function (items) { |
||||
var self = this, o = this.options; |
||||
o.items = items; |
||||
ArrayUtils.traversal(items, function (i, item) { |
||||
o.itemCreator(item); |
||||
}); |
||||
this.filter.populate.apply(this.filter, [items]); |
||||
}, |
||||
|
||||
populate: function (conditions) { |
||||
this.tree.initTree(conditions); |
||||
this._populate(this.tree.toJSONWithNode()); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.filter.getValue(); |
||||
} |
||||
}); |
||||
BI.Filter.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut("bi.filter", BI.Filter); |
@ -1,219 +0,0 @@
|
||||
/** |
||||
* 过滤条件 |
||||
* |
||||
* Created by GUY on 2015/9/25. |
||||
* @class BI.FilterOperation |
||||
* @extend BI.Widget |
||||
*/ |
||||
BI.FilterOperation = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.FilterOperation.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-filter-operation", |
||||
expander: {}, |
||||
items: [], |
||||
selections: [BICst.FILTER_OPERATION_CONDITION, BICst.FILTER_OPERATION_FORMULA], |
||||
itemsCreator: BI.emptyFn |
||||
}) |
||||
}, |
||||
|
||||
_defaultState: function () { |
||||
if (BI.isNotNull(this.currentSelected)) { |
||||
this.currentSelected.setSelectedCondition(false); |
||||
} |
||||
this.buttonComboTab.setSelect(BI.FilterOperation.OPERATION_ADD_CONDITION); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.FilterOperation.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.currentSelected = null; |
||||
|
||||
this.filter = BI.createWidget({ |
||||
type: "bi.filter_pane", |
||||
expander: o.expander, |
||||
items: o.items, |
||||
itemsCreator: o.itemsCreator |
||||
}); |
||||
this.filter.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { |
||||
if (type === BI.Events.CLICK) { |
||||
if (BI.isNotNull(self.currentSelected) && self.currentSelected === obj) { |
||||
obj.setSelectedCondition(!obj.isSelectedCondition()); |
||||
} else { |
||||
if (BI.isNotNull(self.currentSelected)) { |
||||
self.currentSelected.setSelectedCondition(false); |
||||
} |
||||
self.currentSelected = obj; |
||||
obj.setSelectedCondition(true); |
||||
} |
||||
if (self.currentSelected.isSelectedCondition()) { |
||||
self.buttonComboTab.setSelect(BI.FilterOperation.OPERATION_ADD_ANDOR_CONDITION); |
||||
} else { |
||||
self.buttonComboTab.setSelect(BI.FilterOperation.OPERATION_ADD_CONDITION); |
||||
} |
||||
} |
||||
if (type === BI.Events.DESTROY) { |
||||
if (self.currentSelected === obj) { |
||||
self.currentSelected = null; |
||||
self.buttonComboTab.setSelect(BI.FilterOperation.OPERATION_ADD_CONDITION); |
||||
} |
||||
self.fireEvent(BI.FilterOperation.EVENT_DESTROY_ITEM, value, obj); |
||||
} |
||||
}); |
||||
this.filter.on(BI.FilterPane.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.FilterOperation.EVENT_CHANGE, arguments); |
||||
}); |
||||
var operation = this._buildOperationTab(); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.vtape", |
||||
element: this, |
||||
items: [{ |
||||
el: operation, |
||||
height: 40 |
||||
}, { |
||||
el: { |
||||
type: "bi.absolute", |
||||
scrollable: true, |
||||
items: [{ |
||||
el: { |
||||
type: "bi.left", |
||||
items: [ |
||||
this.filter |
||||
] |
||||
}, |
||||
top: 0, |
||||
right: 2, |
||||
bottom: 0, |
||||
left: 0 |
||||
}] |
||||
} |
||||
}] |
||||
}) |
||||
}, |
||||
|
||||
_buildOperationTab: function () { |
||||
this.buttonComboTab = BI.createWidget({ |
||||
type: "bi.tab", |
||||
tab: null, |
||||
cardCreator: BI.bind(this._createTabs, this) |
||||
}); |
||||
this.buttonComboTab.setSelect(BI.FilterOperation.OPERATION_ADD_CONDITION); |
||||
return this.buttonComboTab; |
||||
}, |
||||
|
||||
_createTabs: function (v) { |
||||
var self = this; |
||||
switch (v) { |
||||
case BI.FilterOperation.OPERATION_ADD_CONDITION: |
||||
var btnGroup = BI.createWidget({ |
||||
type: "bi.button_group", |
||||
items: BI.createItems(self._createButtons(), { |
||||
type: "bi.button", |
||||
forceNotSelected: true, |
||||
level: "ignore", |
||||
height: 25 |
||||
}), |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_DEFAULT, |
||||
layouts: [{ |
||||
type: "bi.right", |
||||
hgap: 10, |
||||
vgap: 5 |
||||
}] |
||||
}); |
||||
btnGroup.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { |
||||
self.fireEvent(BI.FilterOperation.EVENT_OPERATION, obj.getValue()); |
||||
self._defaultState(); |
||||
}); |
||||
return btnGroup; |
||||
case BI.FilterOperation.OPERATION_ADD_ANDOR_CONDITION: |
||||
var btnGroup = BI.createWidget({ |
||||
type: "bi.button_group", |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_DEFAULT, |
||||
items: self._createCombos(), |
||||
layouts: [{ |
||||
type: "bi.right", |
||||
hgap: 10, |
||||
vgap: 5 |
||||
}] |
||||
}); |
||||
return btnGroup; |
||||
} |
||||
}, |
||||
|
||||
_createButtons: function(){ |
||||
var buttons = []; |
||||
BI.each(this.options.selections, function(i, type){ |
||||
switch (type){ |
||||
case BICst.FILTER_OPERATION_FORMULA: |
||||
buttons.push({ |
||||
text: BI.i18nText("BI-Add_Formula"), |
||||
value: BICst.FILTER_OPERATION_FORMULA |
||||
}); |
||||
break; |
||||
case BICst.FILTER_OPERATION_CONDITION: |
||||
buttons.push({ |
||||
text: BI.i18nText("BI-Add_Condition"), |
||||
value: BICst.FILTER_OPERATION_CONDITION |
||||
}); |
||||
break; |
||||
} |
||||
}); |
||||
return buttons; |
||||
}, |
||||
|
||||
_createCombos: function () { |
||||
var self = this, combos = []; |
||||
BI.each(this.options.selections, function(i, type){ |
||||
var text = "", items = []; |
||||
switch (type) { |
||||
case BICst.FILTER_OPERATION_FORMULA: |
||||
text = BI.i18nText("BI-Add_Formula"); |
||||
items = BICst.FILTER_ADD_FORMULA_COMBO; |
||||
break; |
||||
case BICst.FILTER_OPERATION_CONDITION: |
||||
text = BI.i18nText("BI-Add_Condition"); |
||||
items = BICst.FILTER_ADD_CONDITION_COMBO; |
||||
break; |
||||
} |
||||
var addCombo = BI.createWidget({ |
||||
type: "bi.static_combo", |
||||
text: text, |
||||
width: 90, |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_NONE, |
||||
items: BI.createItems(items, { |
||||
type: "bi.single_select_item", |
||||
height: 25 |
||||
}) |
||||
}); |
||||
addCombo.on(BI.Combo.EVENT_CHANGE, function (value, obj) { |
||||
self.fireEvent(BI.FilterOperation.EVENT_OPERATION, obj.getValue()); |
||||
self._defaultState(); |
||||
}); |
||||
combos.push(addCombo); |
||||
}); |
||||
return combos; |
||||
}, |
||||
|
||||
getCurrentSelectItem: function () { |
||||
if (BI.isNotNull(this.currentSelected) && this.currentSelected.isSelectedCondition()) { |
||||
return this.currentSelected; |
||||
} |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
|
||||
this.filter.populate.apply(this.filter, arguments); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.filter.getValue(); |
||||
} |
||||
}); |
||||
BI.extend(BI.FilterOperation, { |
||||
OPERATION_ADD_CONDITION: 0, |
||||
OPERATION_ADD_ANDOR_CONDITION: 1 |
||||
}); |
||||
BI.FilterOperation.EVENT_OPERATION = "EVENT_OPERATION"; |
||||
BI.FilterOperation.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.FilterOperation.EVENT_DESTROY_ITEM = "BI.FilterOperation.EVENT_DESTROY_ITEM"; |
||||
$.shortcut("bi.filter_operation", BI.FilterOperation); |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue