Browse Source

Merge pull request #154 in FUI/fineui from ~GUY/fineui:master to master

* commit '36a9bb293b081ca2c640853530bc209fa9953edf':
  update
  去掉editor.code的mousedown
  number-editor修改
  update
  update
  BI-10584 文本组件遮盖
  update
  update
es6
guy 7 years ago
parent
commit
4e6751b86b
  1. 664
      bi/base.js
  2. 15
      bi/core.css
  3. 2
      bi/core.js
  4. 42
      bi/sliders.css
  5. 3
      bi/widget.css
  6. 3189
      bi/widget.js
  7. 664
      dist/base.js
  8. 18
      dist/bundle.css
  9. 2339
      dist/bundle.js
  10. 2
      dist/bundle.min.css
  11. 64
      dist/bundle.min.js
  12. 15
      dist/core.css
  13. 2
      dist/core.js
  14. 2410
      dist/demo.js
  15. 42
      dist/sliders.css
  16. 3
      dist/widget.css
  17. 3189
      dist/widget.js
  18. 4
      src/base/combination/combo.js
  19. 4
      src/base/single/button/button.basic.js
  20. 14
      src/base/single/editor/editor.code.js
  21. 2
      src/core/mvc/factory/factory.js
  22. 7
      src/css/core/normalize.css
  23. 8
      src/css/core/normalize2.css
  24. 3
      src/css/widget/multiselect/multiselect.insert.combo.css
  25. 7
      src/less/core/normalize.less
  26. 12
      src/less/core/normalize2.less
  27. 7
      src/less/widget/multiselect/multiselect.insert.combo.less
  28. 361
      src/widget/canvastable/collection.canvas.js
  29. 529
      src/widget/canvastable/table.canvas.js
  30. 357
      src/widget/multiselect/multiselect..insert.combo.js
  31. 76
      src/widget/multiselect/multiselect.combo.js
  32. 326
      src/widget/multiselectlist/multiselectlist.insert.js
  33. 60
      src/widget/multiselectlist/multiselectlist.js

664
bi/base.js

@ -908,7 +908,9 @@ BI.BasicButton = BI.inherit(BI.Single, {
return; return;
} }
interval = setInterval(function () { interval = setInterval(function () {
self.doClick(); if(self.isEnabled()){
self.doClick();
}
}, 100); }, 100);
mouseDown = true; mouseDown = true;
ev(e); ev(e);
@ -3052,6 +3054,7 @@ BI.Combo = BI.inherit(BI.Widget, {
trigger: "click", trigger: "click",
toggle: true, toggle: true,
direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
container: null,//popupview放置的容器,默认为this.element
isDefaultInit: false, isDefaultInit: false,
destroyWhenHide: false, destroyWhenHide: false,
isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustHeight: true,//是否需要高度调整
@ -3248,7 +3251,7 @@ BI.Combo = BI.inherit(BI.Widget, {
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.vertical",
scrolly: false, scrolly: false,
element: this, element: this.options.container || this,
items: [ items: [
{el: this.popupView} {el: this.popupView}
] ]
@ -3261,6 +3264,7 @@ BI.Combo = BI.inherit(BI.Widget, {
// if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) { // if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) {
// return; // return;
// } // }
//BI-10290 公式combo双击公式内容会收起
if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {//BI-9887 CodeMirror的公式弹框需要特殊处理下 if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {//BI-9887 CodeMirror的公式弹框需要特殊处理下
return; return;
} }
@ -16407,68 +16411,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) { key: function (e) {
} }
});/** });/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar * @class BI.RichEditorTextToolbar
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, { BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background", baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [ buttons: [
{type: "bi.rich_editor_size_chooser"}, {type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"}, {type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"}, {type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"}, {type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"}, {type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"}, {type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"}, {type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"}, {type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"}, {type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"}, {type: "bi.rich_editor_param_button"},
], ],
height: 28 height: 28
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments); BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
BI.createWidget({ BI.createWidget({
type: "bi.left", type: "bi.left",
element: this, element: this,
items: BI.map(o.buttons, function (i, btn) { items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, { return BI.extend(btn, {
editor: o.editor editor: o.editor
}); });
}), }),
hgap: 3, hgap: 3,
vgap: 3 vgap: 3
}) })
}, },
mounted: function () { mounted: function () {
var self = this; var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框 if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () { this.element.mousedown(function () {
self._noSelect(self.element[0]); self._noSelect(self.element[0]);
}); });
this._noSelect(this.element[0]); this._noSelect(this.element[0]);
} }
}, },
_noSelect: function (element) { _noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on'); element.setAttribute('unselectable', 'on');
} }
for (var i = 0; i < element.childNodes.length; i++) { for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]); this._noSelect(element.childNodes[i]);
} }
} }
}); });
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/** BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器 * 富文本编辑器
* *
@ -16749,57 +16753,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
} }
}); });
}()); }());
/** /**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger * @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-background-font" cls: "text-background-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/** BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
@ -17067,214 +17071,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false); this.underline.setSelected(false);
}, },
}); });
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/** BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger * @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-font" cls: "text-color-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/** BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser * @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments); BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_background_color_chooser_trigger", type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"), title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue(); var backgroundColor = this.getValue();
o.editor.element.css({ o.editor.element.css({
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor) color: BI.DOM.getContrastColor(backgroundColor)
}); });
this.setValue(""); this.setValue("");
}); });
}, },
deactivate: function () { deactivate: function () {
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/** BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser * @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
command: "foreColor" command: "foreColor"
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments); BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_color_chooser_trigger", type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"), title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue()); self.doCommand(this.getValue());
}); });
}, },
deactivate: function () { deactivate: function () {
this.colorchooser.setValue(""); this.colorchooser.setValue("");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/** BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择 * 字体大小选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser * @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card", baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize", command: "FontSize",
width: 50, width: 50,
height: 20 height: 20
}); });
}, },
_items: [{ _items: [{
value: 1, value: 1,
text: "1(8pt)" text: "1(8pt)"
}, { }, {
value: 2, value: 2,
text: "2(10pt)" text: "2(10pt)"
}, { }, {
value: 3, value: 3,
text: "3(12pt)" text: "3(12pt)"
}, { }, {
value: 4, value: 4,
text: "4(14pt)" text: "4(14pt)"
}, { }, {
value: 5, value: 5,
text: "5(18pt)" text: "5(18pt)"
}, { }, {
value: 6, value: 6,
text: "6(24pt)" text: "6(24pt)"
}], }],
_init: function () { _init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments); BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.text_trigger", type: "bi.text_trigger",
readonly: true, readonly: true,
height: o.height, height: o.height,
triggerWidth: 12, triggerWidth: 12,
text: BI.i18nText("BI-Font_Size") text: BI.i18nText("BI-Font_Size")
}); });
this.combo = BI.createWidget({ this.combo = BI.createWidget({
type: "bi.combo", type: "bi.combo",
element: this, element: this,
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
maxWidth: 70, maxWidth: 70,
minWidth: 70, minWidth: 70,
el: { el: {
type: "bi.button_group", type: "bi.button_group",
items: BI.createItems(this._items, { items: BI.createItems(this._items, {
type: "bi.single_select_item" type: "bi.single_select_item"
}), }),
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }]
} }
} }
}); });
this.combo.on(BI.Combo.EVENT_CHANGE, function () { this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0]; var val = this.getValue()[0];
self.doCommand(val); self.doCommand(val);
this.hideView(); this.hideView();
this.setValue([]); this.setValue([]);
}) })
} }
}); });
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/** BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器 * 富文本编辑器
* *
@ -19060,13 +19064,13 @@ BI.CodeEditor = BI.inherit(BI.Single, {
self.fireEvent(BI.CodeEditor.EVENT_BLUR); self.fireEvent(BI.CodeEditor.EVENT_BLUR);
}); });
this.editor.on("mousedown", function (cm, e) { // this.editor.on("mousedown", function (cm, e) {
//IE下mousedown之后会触发blur,所以nextTick后再做focus // //IE下mousedown之后会触发blur,所以nextTick后再做focus
BI.nextTick(function () { // BI.nextTick(function () {
self.fireEvent(BI.CodeEditor.EVENT_FOCUS); // self.fireEvent(BI.CodeEditor.EVENT_FOCUS);
}); // });
e.stopPropagation(); // //e.stopPropagation();
}); // });
// this.editor.on("blur", function () { // this.editor.on("blur", function () {
// self.editor.execCommand("goLineEnd"); // self.editor.execCommand("goLineEnd");

15
bi/core.css

@ -220,13 +220,6 @@ input::-moz-focus-inner {
border: 0; border: 0;
padding: 0; padding: 0;
} }
input::-webkit-contacts-auto-fill-button {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
textarea { textarea {
overflow: auto; overflow: auto;
vertical-align: top; vertical-align: top;
@ -256,6 +249,14 @@ a {
a:focus { a:focus {
outline: 0; outline: 0;
} }
input::-webkit-contacts-auto-fill-button,
input::-ms-clear {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
input, input,
textarea { textarea {
margin: 0; margin: 0;

2
bi/core.js

@ -11181,7 +11181,7 @@ BI.Factory = {
// //
// } // }
// try { // try {
var view = new (eval(viewFunc))(_.extend({}, vData, { var view = new (this.parsePath(viewFunc)(window))(_.extend({}, vData, {
model: model, model: model,
parent: context, parent: context,
rootURL: url rootURL: url

42
bi/sliders.css

@ -24,15 +24,27 @@
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-single-slider-button .slider-button { .bi-single-slider-button .slider-button {
cursor: ew-resize; cursor: ew-resize;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-webkit-border-radius: 7px; -webkit-border-radius: 7px;
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .gray-track { .bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3); background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
@ -45,15 +57,3 @@
-moz-border-radius: 3px; -moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

3
bi/widget.css

@ -113,6 +113,9 @@
.bi-multi-select-combo .multi-select-trigger-icon-button { .bi-multi-select-combo .multi-select-trigger-icon-button {
font-size: 16px; font-size: 16px;
} }
.bi-multi-select-insert-combo .multi-select-trigger-icon-button {
font-size: 16px;
}
.bi-multi-select-trigger { .bi-multi-select-trigger {
-webkit-border-radius: 2px 2px 2px 2px; -webkit-border-radius: 2px 2px 2px 2px;
-moz-border-radius: 2px 2px 2px 2px; -moz-border-radius: 2px 2px 2px 2px;

3189
bi/widget.js

File diff suppressed because it is too large Load Diff

664
dist/base.js vendored

@ -908,7 +908,9 @@ BI.BasicButton = BI.inherit(BI.Single, {
return; return;
} }
interval = setInterval(function () { interval = setInterval(function () {
self.doClick(); if(self.isEnabled()){
self.doClick();
}
}, 100); }, 100);
mouseDown = true; mouseDown = true;
ev(e); ev(e);
@ -3052,6 +3054,7 @@ BI.Combo = BI.inherit(BI.Widget, {
trigger: "click", trigger: "click",
toggle: true, toggle: true,
direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
container: null,//popupview放置的容器,默认为this.element
isDefaultInit: false, isDefaultInit: false,
destroyWhenHide: false, destroyWhenHide: false,
isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustHeight: true,//是否需要高度调整
@ -3248,7 +3251,7 @@ BI.Combo = BI.inherit(BI.Widget, {
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.vertical",
scrolly: false, scrolly: false,
element: this, element: this.options.container || this,
items: [ items: [
{el: this.popupView} {el: this.popupView}
] ]
@ -3261,6 +3264,7 @@ BI.Combo = BI.inherit(BI.Widget, {
// if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) { // if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) {
// return; // return;
// } // }
//BI-10290 公式combo双击公式内容会收起
if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {//BI-9887 CodeMirror的公式弹框需要特殊处理下 if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {//BI-9887 CodeMirror的公式弹框需要特殊处理下
return; return;
} }
@ -16407,68 +16411,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) { key: function (e) {
} }
});/** });/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar * @class BI.RichEditorTextToolbar
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, { BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background", baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [ buttons: [
{type: "bi.rich_editor_size_chooser"}, {type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"}, {type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"}, {type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"}, {type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"}, {type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"}, {type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"}, {type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"}, {type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"}, {type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"}, {type: "bi.rich_editor_param_button"},
], ],
height: 28 height: 28
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments); BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
BI.createWidget({ BI.createWidget({
type: "bi.left", type: "bi.left",
element: this, element: this,
items: BI.map(o.buttons, function (i, btn) { items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, { return BI.extend(btn, {
editor: o.editor editor: o.editor
}); });
}), }),
hgap: 3, hgap: 3,
vgap: 3 vgap: 3
}) })
}, },
mounted: function () { mounted: function () {
var self = this; var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框 if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () { this.element.mousedown(function () {
self._noSelect(self.element[0]); self._noSelect(self.element[0]);
}); });
this._noSelect(this.element[0]); this._noSelect(this.element[0]);
} }
}, },
_noSelect: function (element) { _noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on'); element.setAttribute('unselectable', 'on');
} }
for (var i = 0; i < element.childNodes.length; i++) { for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]); this._noSelect(element.childNodes[i]);
} }
} }
}); });
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/** BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器 * 富文本编辑器
* *
@ -16749,57 +16753,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
} }
}); });
}()); }());
/** /**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger * @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-background-font" cls: "text-background-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/** BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
@ -17067,214 +17071,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false); this.underline.setSelected(false);
}, },
}); });
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/** BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger * @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-font" cls: "text-color-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/** BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser * @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments); BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_background_color_chooser_trigger", type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"), title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue(); var backgroundColor = this.getValue();
o.editor.element.css({ o.editor.element.css({
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor) color: BI.DOM.getContrastColor(backgroundColor)
}); });
this.setValue(""); this.setValue("");
}); });
}, },
deactivate: function () { deactivate: function () {
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/** BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser * @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
command: "foreColor" command: "foreColor"
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments); BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_color_chooser_trigger", type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"), title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue()); self.doCommand(this.getValue());
}); });
}, },
deactivate: function () { deactivate: function () {
this.colorchooser.setValue(""); this.colorchooser.setValue("");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/** BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择 * 字体大小选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser * @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card", baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize", command: "FontSize",
width: 50, width: 50,
height: 20 height: 20
}); });
}, },
_items: [{ _items: [{
value: 1, value: 1,
text: "1(8pt)" text: "1(8pt)"
}, { }, {
value: 2, value: 2,
text: "2(10pt)" text: "2(10pt)"
}, { }, {
value: 3, value: 3,
text: "3(12pt)" text: "3(12pt)"
}, { }, {
value: 4, value: 4,
text: "4(14pt)" text: "4(14pt)"
}, { }, {
value: 5, value: 5,
text: "5(18pt)" text: "5(18pt)"
}, { }, {
value: 6, value: 6,
text: "6(24pt)" text: "6(24pt)"
}], }],
_init: function () { _init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments); BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.text_trigger", type: "bi.text_trigger",
readonly: true, readonly: true,
height: o.height, height: o.height,
triggerWidth: 12, triggerWidth: 12,
text: BI.i18nText("BI-Font_Size") text: BI.i18nText("BI-Font_Size")
}); });
this.combo = BI.createWidget({ this.combo = BI.createWidget({
type: "bi.combo", type: "bi.combo",
element: this, element: this,
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
maxWidth: 70, maxWidth: 70,
minWidth: 70, minWidth: 70,
el: { el: {
type: "bi.button_group", type: "bi.button_group",
items: BI.createItems(this._items, { items: BI.createItems(this._items, {
type: "bi.single_select_item" type: "bi.single_select_item"
}), }),
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }]
} }
} }
}); });
this.combo.on(BI.Combo.EVENT_CHANGE, function () { this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0]; var val = this.getValue()[0];
self.doCommand(val); self.doCommand(val);
this.hideView(); this.hideView();
this.setValue([]); this.setValue([]);
}) })
} }
}); });
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/** BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器 * 富文本编辑器
* *
@ -19060,13 +19064,13 @@ BI.CodeEditor = BI.inherit(BI.Single, {
self.fireEvent(BI.CodeEditor.EVENT_BLUR); self.fireEvent(BI.CodeEditor.EVENT_BLUR);
}); });
this.editor.on("mousedown", function (cm, e) { // this.editor.on("mousedown", function (cm, e) {
//IE下mousedown之后会触发blur,所以nextTick后再做focus // //IE下mousedown之后会触发blur,所以nextTick后再做focus
BI.nextTick(function () { // BI.nextTick(function () {
self.fireEvent(BI.CodeEditor.EVENT_FOCUS); // self.fireEvent(BI.CodeEditor.EVENT_FOCUS);
}); // });
e.stopPropagation(); // //e.stopPropagation();
}); // });
// this.editor.on("blur", function () { // this.editor.on("blur", function () {
// self.editor.execCommand("goLineEnd"); // self.editor.execCommand("goLineEnd");

18
dist/bundle.css vendored

@ -220,13 +220,6 @@ input::-moz-focus-inner {
border: 0; border: 0;
padding: 0; padding: 0;
} }
input::-webkit-contacts-auto-fill-button {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
textarea { textarea {
overflow: auto; overflow: auto;
vertical-align: top; vertical-align: top;
@ -256,6 +249,14 @@ a {
a:focus { a:focus {
outline: 0; outline: 0;
} }
input::-webkit-contacts-auto-fill-button,
input::-ms-clear {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
input, input,
textarea { textarea {
margin: 0; margin: 0;
@ -3200,6 +3201,9 @@ ul.ztree.zTreeDragUL {
.bi-multi-select-combo .multi-select-trigger-icon-button { .bi-multi-select-combo .multi-select-trigger-icon-button {
font-size: 16px; font-size: 16px;
} }
.bi-multi-select-insert-combo .multi-select-trigger-icon-button {
font-size: 16px;
}
.bi-multi-select-trigger { .bi-multi-select-trigger {
-webkit-border-radius: 2px 2px 2px 2px; -webkit-border-radius: 2px 2px 2px 2px;
-moz-border-radius: 2px 2px 2px 2px; -moz-border-radius: 2px 2px 2px 2px;

2339
dist/bundle.js vendored

File diff suppressed because it is too large Load Diff

2
dist/bundle.min.css vendored

File diff suppressed because one or more lines are too long

64
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

15
dist/core.css vendored

@ -220,13 +220,6 @@ input::-moz-focus-inner {
border: 0; border: 0;
padding: 0; padding: 0;
} }
input::-webkit-contacts-auto-fill-button {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
textarea { textarea {
overflow: auto; overflow: auto;
vertical-align: top; vertical-align: top;
@ -256,6 +249,14 @@ a {
a:focus { a:focus {
outline: 0; outline: 0;
} }
input::-webkit-contacts-auto-fill-button,
input::-ms-clear {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
input, input,
textarea { textarea {
margin: 0; margin: 0;

2
dist/core.js vendored

@ -11181,7 +11181,7 @@ BI.Factory = {
// //
// } // }
// try { // try {
var view = new (eval(viewFunc))(_.extend({}, vData, { var view = new (this.parsePath(viewFunc)(window))(_.extend({}, vData, {
model: model, model: model,
parent: context, parent: context,
rootURL: url rootURL: url

2410
dist/demo.js vendored

File diff suppressed because it is too large Load Diff

42
dist/sliders.css vendored

@ -24,15 +24,27 @@
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-single-slider-button .slider-button { .bi-single-slider-button .slider-button {
cursor: ew-resize; cursor: ew-resize;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-webkit-border-radius: 7px; -webkit-border-radius: 7px;
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .gray-track { .bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3); background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
@ -45,15 +57,3 @@
-moz-border-radius: 3px; -moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

3
dist/widget.css vendored

@ -113,6 +113,9 @@
.bi-multi-select-combo .multi-select-trigger-icon-button { .bi-multi-select-combo .multi-select-trigger-icon-button {
font-size: 16px; font-size: 16px;
} }
.bi-multi-select-insert-combo .multi-select-trigger-icon-button {
font-size: 16px;
}
.bi-multi-select-trigger { .bi-multi-select-trigger {
-webkit-border-radius: 2px 2px 2px 2px; -webkit-border-radius: 2px 2px 2px 2px;
-moz-border-radius: 2px 2px 2px 2px; -moz-border-radius: 2px 2px 2px 2px;

3189
dist/widget.js vendored

File diff suppressed because it is too large Load Diff

4
src/base/combination/combo.js

@ -10,6 +10,7 @@ BI.Combo = BI.inherit(BI.Widget, {
trigger: "click", trigger: "click",
toggle: true, toggle: true,
direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
container: null,//popupview放置的容器,默认为this.element
isDefaultInit: false, isDefaultInit: false,
destroyWhenHide: false, destroyWhenHide: false,
isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustHeight: true,//是否需要高度调整
@ -206,7 +207,7 @@ BI.Combo = BI.inherit(BI.Widget, {
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.vertical",
scrolly: false, scrolly: false,
element: this, element: this.options.container || this,
items: [ items: [
{el: this.popupView} {el: this.popupView}
] ]
@ -219,6 +220,7 @@ BI.Combo = BI.inherit(BI.Widget, {
// if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) { // if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) {
// return; // return;
// } // }
//BI-10290 公式combo双击公式内容会收起
if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {//BI-9887 CodeMirror的公式弹框需要特殊处理下 if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {//BI-9887 CodeMirror的公式弹框需要特殊处理下
return; return;
} }

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

@ -177,7 +177,9 @@ BI.BasicButton = BI.inherit(BI.Single, {
return; return;
} }
interval = setInterval(function () { interval = setInterval(function () {
self.doClick(); if(self.isEnabled()){
self.doClick();
}
}, 100); }, 100);
mouseDown = true; mouseDown = true;
ev(e); ev(e);

14
src/base/single/editor/editor.code.js

@ -45,13 +45,13 @@ BI.CodeEditor = BI.inherit(BI.Single, {
self.fireEvent(BI.CodeEditor.EVENT_BLUR); self.fireEvent(BI.CodeEditor.EVENT_BLUR);
}); });
this.editor.on("mousedown", function (cm, e) { // this.editor.on("mousedown", function (cm, e) {
//IE下mousedown之后会触发blur,所以nextTick后再做focus // //IE下mousedown之后会触发blur,所以nextTick后再做focus
BI.nextTick(function () { // BI.nextTick(function () {
self.fireEvent(BI.CodeEditor.EVENT_FOCUS); // self.fireEvent(BI.CodeEditor.EVENT_FOCUS);
}); // });
e.stopPropagation(); // //e.stopPropagation();
}); // });
// this.editor.on("blur", function () { // this.editor.on("blur", function () {
// self.editor.execCommand("goLineEnd"); // self.editor.execCommand("goLineEnd");

2
src/core/mvc/factory/factory.js

@ -31,7 +31,7 @@ BI.Factory = {
// //
// } // }
// try { // try {
var view = new (eval(viewFunc))(_.extend({}, vData, { var view = new (this.parsePath(viewFunc)(window))(_.extend({}, vData, {
model: model, model: model,
parent: context, parent: context,
rootURL: url rootURL: url

7
src/css/core/normalize.css vendored

@ -220,13 +220,6 @@ input::-moz-focus-inner {
border: 0; border: 0;
padding: 0; padding: 0;
} }
input::-webkit-contacts-auto-fill-button {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
textarea { textarea {
overflow: auto; overflow: auto;
vertical-align: top; vertical-align: top;

8
src/css/core/normalize2.css

@ -19,6 +19,14 @@ a {
a:focus { a:focus {
outline: 0; outline: 0;
} }
input::-webkit-contacts-auto-fill-button,
input::-ms-clear {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
input, input,
textarea { textarea {
margin: 0; margin: 0;

3
src/css/widget/multiselect/multiselect.insert.combo.css

@ -0,0 +1,3 @@
.bi-multi-select-insert-combo .multi-select-trigger-icon-button {
font-size: 16px;
}

7
src/less/core/normalize.less vendored

@ -221,13 +221,6 @@ input::-moz-focus-inner {
border: 0; border: 0;
padding: 0 padding: 0
} }
input::-webkit-contacts-auto-fill-button {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
textarea { textarea {
overflow: auto; overflow: auto;
vertical-align: top vertical-align: top

12
src/less/core/normalize2.less

@ -14,6 +14,16 @@ a:focus {
outline: 0; outline: 0;
} }
input {
&::-webkit-contacts-auto-fill-button,&::-ms-clear {
visibility: hidden;
display: none !important;
pointer-events: none;
position: absolute;
right: 0;
}
}
input, input,
textarea { textarea {
margin: 0; margin: 0;
@ -42,4 +52,4 @@ i {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px; -webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }

7
src/less/widget/multiselect/multiselect.insert.combo.less

@ -0,0 +1,7 @@
@import "../../bibase";
.bi-multi-select-insert-combo{
& .multi-select-trigger-icon-button{
font-size: 16px;
}
}

361
src/widget/canvastable/collection.canvas.js

@ -1,361 +0,0 @@
/**
* Created By Shichao on 2017/10/17
* @class BI.CanvasCollectionView
* @extends BI.Widget
*/
BI.CanvasCollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CanvasCollectionView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-canvas-collection",
overflowX: true,
overflowY: true,
cellSizeAndPositionGetter: BI.emptyFn,
horizontalOverscanSize: 0,
verticalOverscanSize: 0,
scrollLeft: 0,
scrollTop: 0,
items: []
})
},
_init: function () {
BI.CanvasCollectionView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
this._scrollLock = false;
this.scrollTop = this.scrollLeft = 0;
this.summaryScrollTop = this.summaryScrollLeft = 0;
this._debounceRelease = BI.debounce(function () {
self._scrollLock = false;
}, 1000 / 60);
this.canvas = BI.createWidget({
type: "bi.canvas_new"
});
$(document).keydown(BI.bind(this._onResize, this)); // 防止在使用ctrl + 滚轮调整窗口大小时触发mousewheel事件
$(document).keyup(BI.bind(this._onResizeRelease, this))
this.element.mousewheel(BI.bind(this._onMouseWheel, this))
BI.createWidget({
type: "bi.vertical",
element: this,
scrollable: false,
scrolly: false,
scrollx: false,
items: [this.canvas]
});
if (o.items.length > 0) {
this._calculateSizeAndPositionData();
this._populate();
}
if (o.scrollLeft !== 0 || o.scrollTop !== 0) {
BI.nextTick(function () {
self.element.scrollTop(o.scrollTop);
self.element.scrollLeft(o.scrollLeft);
});
}
},
_onMouseWheel: function (e) {
var o = this.options;
if (this._scrollLock) {
return;
}
if (!this._isCtrlPressed) {
o.scrollTop += -e.originalEvent.wheelDelta;
o.scrollTop = BI.clamp(o.scrollTop, 0, this.maxScrollTop);
this._calculateChildrenToRender();
this.fireEvent(BI.CanvasCollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
}
},
_onResize: function (e) {
if (e.ctrlKey) {
this._isCtrlPressed = true;
} else {
this._isCtrlPressed = false;
}
},
_onResizeRelease: function (e) {
var Keys = {
CTRL: 17
};
var keyCode = e.keyCode;
if (keyCode === Keys.CTRL) {
this._isCtrlPressed = false;
}
},
_getMaxScrollTop: function () {
return this._height - this.options.height
},
_calculateSizeAndPositionData: function () {
var o = this.options;
var cellMetadata = [];
var sectionManager = new BI.SectionManager();
var height = 0;
var width = 0;
for (var index = 0, len = o.items.length; index < len; index++) {
var cellMetadatum = o.cellSizeAndPositionGetter(index);
if (cellMetadatum.height == null || isNaN(cellMetadatum.height) ||
cellMetadatum.width == null || isNaN(cellMetadatum.width) ||
cellMetadatum.x == null || isNaN(cellMetadatum.x) ||
cellMetadatum.y == null || isNaN(cellMetadatum.y)) {
throw Error();
}
height = Math.max(height, cellMetadatum.y + cellMetadatum.height);
width = Math.max(width, cellMetadatum.x + cellMetadatum.width);
cellMetadatum.index = index;
cellMetadata[index] = cellMetadatum;
sectionManager.registerCell(cellMetadatum, index);
}
this._cellMetadata = cellMetadata;
this._sectionManager = sectionManager;
if (this._height === height && this._width === width) {
this._isNeedReset = false;
} else {
this._height = height;
this._width = width;
this._isNeedReset = true;
}
this.maxScrollTop = this._getMaxScrollTop();
},
_cellRenderers: function (height, width, x, y) {
this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y);
return this._cellGroupRenderer();
},
_cellGroupRenderer: function () {
var self = this, o = this.options;
var rendered = [];
BI.each(this._lastRenderedCellIndices, function (i, index) {
var cellMetadata = self._sectionManager.getCellMetadata(index);
rendered.push(cellMetadata);
});
return rendered;
},
_calculateChildrenToRender: function () {
var x, y, cellWidth, cellHeight, cellRow, cellCol, value, self = this, o = this.options;
var scrollLeft = o.scrollLeft;
var scrollTop = o.scrollTop;
var left = Math.max(0, scrollLeft - o.horizontalOverscanSize);
var top = Math.max(0, scrollTop - o.verticalOverscanSize);
var right = Math.min(this._width, scrollLeft + o.width + o.horizontalOverscanSize);
var bottom = Math.min(this._height, scrollTop + o.height + o.verticalOverscanSize);
if (right > 0 && bottom > 0) {
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
this.canvas.remove(this.scrollLeft, this.scrollTop, o.width, o.height);
for (var i = 0; i < childrenToDisplay.length; i++) {
var datum = childrenToDisplay[i];
var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1];
var rect_tl_x = datum.x,
rect_tl_y = datum.y,
rect_tr_x = rect_tl_x + datum.width,
rect_bl_y = rect_tl_y + datum.height,
cell = o.items[datum.index].cell || o.items[datum.index],
background, color, fontWeight, text;
while (BI.isNull(cell.styles) && !BI.isFunction(cell.styleGetter)) {
cell = cell.cell;
}
if (BI.isNull(cell.styles) && BI.isFunction(cell.styleGetter)) {
background = cell.styleGetter().background;
color = cell.styleGetter().color;
fontWeight = cell.styleGetter().fontWeight;
} else if (!BI.isNull(cell.styles)) {
background = cell.styles.background;
color = cell.styles.color;
fontWeight = cell.styles.fontWeight;
}
if (BI.isNull(cell.text)) {
text = "";
} else {
text = cell.text;
}
if (!BI.isString(text)) {
text = text.toString();
}
if (this.scrollLeft !== o.scrollLeft) {
this.canvas.translate(this.scrollLeft - o.scrollLeft, 0);
this.scrollLeft = o.scrollLeft;
}
if (this.scrollTop !== o.scrollTop) {
this.canvas.translate(0, this.scrollTop - o.scrollTop);
this.scrollTop = o.scrollTop;
}
if (datum.x === 0 && datum.y === 0) {
this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, {
strokeStyle: "rgb(212, 218, 221)",
fillStyle: background
});
} else if (datum.x === 0) {
this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, {
strokeStyle: "rgb(212, 218, 221)",
fillStyle: background
});
} else if (datum.y === 0) {
this.canvas.solid(rect_tl_x, rect_tl_y, rect_tr_x, rect_tl_y, rect_tr_x, rect_bl_y, rect_tl_x, rect_bl_y, {
strokeStyle: "rgb(212, 218, 221)",
fillStyle: background
});
} else {
this.canvas.solid(rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, {
strokeStyle: "rgb(212, 218, 221)",
fillStyle: background
});
}
this.canvas.setFontWeight(fontWeight);
this.canvas.setFont();
var font = this.canvas.getContext().font,
textSize = this._getTextPixel(font),
textHeight = textSize,
textWidth = this.canvas.getContext().measureText(text).width,
dotsWidth = this.canvas.getContext().measureText("...").width;
var offsetX = this._calcOffsetX(textWidth, datum.width, "center"),
offsetY = this._calcOffsetY(textHeight, datum.height, "center");
if (textHeight > datum.height) {
this.canvas.text(datum.x + offsetX, datum.y + offsetY, "...", color);
} else if (textWidth + 4 > datum.width) {
var sliceIndex = Math.floor((datum.width - dotsWidth - 4) / textWidth * text.length);
this.canvas.text(datum.x + offsetX, datum.y + offsetY, text.slice(0, sliceIndex) + "...", color);
} else {
this.canvas.text(datum.x + offsetX, datum.y + offsetY, text, color);
}
this.canvas.stroke();
}
}
},
_getTextPixel: function (font) {
var p = font.split("px")[0],
s = p.split(" ");
for (var c in s) {
var num;
num = BI.parseInt(s[c]);
if (!BI.isNaN(num)) {
return num;
}
}
},
_calcOffsetX: function (textWidth, cellWidth, position) {
switch (position) {
case "center":
if (textWidth >= cellWidth) {
return 4;
} else {
return (cellWidth - textWidth) / 2;
}
case "right":
if (textWidth >= cellWidth) {
return 0;
} else {
return cellWidth - textWidth;
}
default:
return 0;
}
},
_calcOffsetY: function (textHeight, cellHeight, position) {
switch (position) {
case "center":
if (textHeight >= cellHeight) {
return textHeight;
} else {
return (cellHeight + textHeight) / 2;
}
case "bottom":
if (textHeight >= cellHeight) {
return cellHeight;
} else {
return cellHeight + textHeight;
}
default:
return textHeight;
}
},
_populate: function (items) {
var o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
}
if (o.items.length > 0) {
this.canvas.setBlock();
this.canvas.setWidth(o.width);
this.canvas.setHeight(o.height);
this.restore();
this._calculateChildrenToRender();
this.element.scrollTop(o.scrollTop);
this.element.scrollLeft(o.scrollLeft);
}
},
populate: function (items) {
if (items && items !== this.options.items) {
this.restore();
}
this._populate(items);
},
setWidth: function (width) {
BI.CanvasCollectionView.superclass.setWidth.apply(this, arguments);
this.options.width = width;
},
setHeight: function (height) {
BI.CanvasCollectionView.superclass.setHeight.apply(this, arguments);
this.options.height = height;
},
restore: function () {
this.canvas.remove(this.scrollLeft, this.scrollTop, this.options.width, this.options.height);
this.renderedKeys = [];
this._scrollLock = false;
},
setScrollLeft: function (scrollLeft) {
if (this.options.scrollLeft === scrollLeft) {
return;
}
this._scrollLock = true;
this.options.scrollLeft = scrollLeft;
this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollLeft(this.options.scrollLeft);
},
setScrollTop: function (scrollTop) {
if (this.options.scrollTop === scrollTop) {
return;
}
this._scrollLock = true;
this.options.scrollTop = scrollTop;
this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollTop(this.options.scrollTop);
},
getScrollLeft: function () {
return this.options.scrollLeft;
},
getScrollTop: function () {
return this.options.scrollTop;
}
})
BI.CanvasCollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut("bi.canvas_collection_view", BI.CanvasCollectionView);

529
src/widget/canvastable/table.canvas.js

@ -1,529 +0,0 @@
/**
* Created by Shichao on 2017/10/18
* @class BI.CanvasTable
* @extends BI.Widget
*/
BI.CanvasTable = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CanvasTable.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-canvas-collection-table",
headerRowSize: 25,
rowSize: 25,
columnSize: [],
isNeedFreeze: false,
freezeCols: [],
isNeedMerge: false,
mergeCols: [],
mergeRule: BI.emptyFn,
header: [],
items: [],
regionColumnSize: []
});
},
_init: function () {
BI.CanvasTable.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this._scrollBarSize = BI.DOM.getScrollWidth();
this.topLeftCollection = BI.createWidget({
type: "bi.canvas_collection_view",
cellSizeAndPositionGetter: function (index) {
return self.topLeftItems[index];
}
});
this.topRightCollection = BI.createWidget({
type: "bi.canvas_collection_view",
cellSizeAndPositionGetter: function (index) {
return self.topRightItems[index];
}
});
this.topRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.bottomLeftCollection = BI.createWidget({
type: "bi.canvas_collection_view",
cellSizeAndPositionGetter: function (index) {
return self.bottomLeftItems[index];
}
});
this.bottomLeftCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollTop(scroll.scrollTop);
self.topLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.bottomRightCollection = BI.createWidget({
type: "bi.canvas_collection_view",
cellSizeAndPositionGetter: function (index) {
return self.bottomRightItems[index];
}
});
this.bottomRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) {
self.bottomLeftCollection.setScrollTop(scroll.scrollTop);
self.topRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.topLeft = BI.createWidget({
type: "bi.vertical",
scrollable: false,
scrolly: false,
items: [this.topLeftCollection]
});
this.topRight = BI.createWidget({
type: "bi.vertical",
scrollable: false,
scrolly: false,
items: [this.topRightCollection]
});
this.bottomLeft = BI.createWidget({
type: "bi.vertical",
scrollable: false,
scrolly: false,
items: [this.bottomLeftCollection]
});
this.bottomRight = BI.createWidget({
type: "bi.vertical",
scrollable: false,
scrolly: false,
items: [this.bottomRightCollection]
});
this.contextLayout = BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.topLeft,
top: 0,
left: 0,
}, {
el: this.topRight,
top: 0
}, {
el: this.bottomLeft,
left: 0
}, {
el: this.bottomRight,
}]
});
this.topScrollbar = BI.createWidget({
type: "bi.grid_table_scrollbar",
width: BI.GridTableScrollbar.SIZE
});
this.topScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollTop) {
self.bottomLeftCollection.setScrollTop(scrollTop);
self.bottomRightCollection.setScrollTop(scrollTop);
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.leftScrollbar = BI.createWidget({
type: "bi.grid_table_horizontal_scrollbar",
height: BI.GridTableScrollbar.SIZE
});
this.leftScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) {
self.topLeftCollection.setScrollLeft(scrollLeft);
self.bottomLeftCollection.setScrollLeft(scrollLeft);
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.rightScrollbar = BI.createWidget({
type: "bi.grid_table_horizontal_scrollbar",
height: BI.GridTableScrollbar.SIZE
});
this.rightScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) {
self.topRightCollection.setScrollLeft(scrollLeft);
self.bottomRightCollection.setScrollLeft(scrollLeft);
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.scrollBarLayout = BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.topScrollbar,
right: 0,
top: 0
}, {
el: this.leftScrollbar,
left: 0,
}, {
el: this.rightScrollbar,
}]
});
this._width = o.width - BI.GridTableScrollbar.SIZE;
this._height = o.height - BI.GridTableScrollbar.SIZE;
},
mounted: function () {
var o = this.options;
if (o.items.length > 0 || o.header.length > 0) {
this._digest();
this._populate();
}
},
attr: function () {
BI.CanvasTable.superclass.attr.apply(this, arguments);
},
_getFreezeColLength: function () {
return this.options.isNeedFreeze ? this.options.freezeCols.length : 0;
},
getRegionSize: function () {
var o = this.options;
var regionSize = o.regionColumnSize[0] || 0;
if (o.isNeedFreeze === false || o.freezeCols.length === 0) {
return 0;
}
if (!regionSize) {
BI.each(o.freezeCols, function (i, col) {
regionSize += o.columnSize[col];
});
}
return regionSize;
},
_getFreezeHeaderHeight: function () {
var o = this.options;
if (o.header.length * o.headerRowSize >= this._height) {
return 0;
}
return o.header.length * o.headerRowSize;
},
_getActualItems: function () {
var o = this.options;
if (o.header.length * o.headerRowSize >= this._height) {
return o.header.concat(o.items);
}
return o.items;
},
_digest: function () {
var o = this.options;
var freezeColLength = this._getFreezeColLength();
//如果表头位置不够,取消表头冻结
if (this._getFreezeHeaderHeight() <= 0) {
this.topLeftItems = [];
this.topRightItems = [];
this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length));
this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length));
} else {
this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols);
this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true);
this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols);
this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols);
}
},
_populateScrollbar: function () {
var o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [];
BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
totalLeftColumnSize += size;
} else {
totalRightColumnSize += size;
}
totalColumnSize += size;
if (i === 0) {
summaryColumnSizeArray[i] = size;
} else {
summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size;
}
});
this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize);
this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight());
this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop());
this.topScrollbar.populate();
this.leftScrollbar.setContentSize(totalLeftColumnSize);
this.leftScrollbar.setSize(regionSize);
this.leftScrollbar.setPosition(this.bottomLeftCollection.getScrollLeft());
this.leftScrollbar.populate();
this.rightScrollbar.setContentSize(totalRightColumnSize);
this.rightScrollbar.setSize(this._width - regionSize);
this.rightScrollbar.setPosition(this.bottomRightCollection.getScrollLeft());
this.rightScrollbar.populate();
var items = this.scrollBarLayout.attr("items");
items[0].top = this._getFreezeHeaderHeight();
items[1].top = this._height;
items[2].top = this._height;
items[2].left = regionSize;
this.scrollBarLayout.attr("items", items);
this.scrollBarLayout.resize();
},
_populateTable: function () {
var self = this, o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [];
var freezeColLength = this._getFreezeColLength();
var otlw = regionSize;
var otlh = this._getFreezeHeaderHeight();
var otrw = this._width - regionSize;
var otrh = this._getFreezeHeaderHeight();
var oblw = regionSize;
var oblh = this._height - otlh;
var obrw = this._width - regionSize;
var obrh = this._height - otrh;
var tlw = otlw + this._scrollBarSize;
var tlh = otlh + this._scrollBarSize;
var trw = otrw + this._scrollBarSize;
var trh = otrh + this._scrollBarSize;
var blw = oblw + this._scrollBarSize;
var blh = oblh + this._scrollBarSize;
var brw = obrw + this._scrollBarSize;
var brh = obrh + this._scrollBarSize;
this.topLeft.setWidth(otlw);
this.topLeft.setHeight(otlh);
this.topRight.setWidth(otrw);
this.topRight.setHeight(otrh);
this.bottomLeft.setWidth(oblw);
this.bottomLeft.setHeight(oblh);
this.bottomRight.setWidth(obrw);
this.bottomRight.setHeight(obrh);
this.topLeftCollection.setWidth(tlw);
this.topLeftCollection.setHeight(tlh);
this.topRightCollection.setWidth(trw);
this.topRightCollection.setHeight(trh);
this.bottomLeftCollection.setWidth(blw);
this.bottomLeftCollection.setHeight(blh);
this.bottomRightCollection.setWidth(brw);
this.bottomRightCollection.setHeight(brh);
var items = this.contextLayout.attr("items");
items[1].left = regionSize;
//items[2].top = this._getFreezeHeaderHeight();
items[2].top = otrh;
items[3].left = regionSize;
//items[3].top = this._getFreezeHeaderHeight();
items[3].top = otrh;
this.contextLayout.attr("items", items);
this.contextLayout.resize();
var leftHeader = [], rightHeader = [], leftItems = [], rightItems = [];
var run = function (positions, items, rendered) {
BI.each(positions, function (i, item) {
if (BI.isNull(items[item.row][item.col])) {
debugger
}
rendered.push(items[item.row][item.col]);
});
};
run(this.topLeftItems, o.header, leftHeader);
run(this.topRightItems, o.header, rightHeader);
run(this.bottomLeftItems, o.items, leftItems);
run(this.bottomRightItems, o.items, rightItems);
this.topLeftCollection._populate(leftHeader);
this.topRightCollection._populate(rightHeader);
this.bottomLeftCollection._populate(leftItems);
this.bottomRightCollection._populate(rightItems);
},
_populate: function () {
if (this._width <= 0 || this._height <= 0) {
return;
}
if (this._isNeedDigest === true) {
this._digest();
}
this._isNeedDigest = false;
this._populateTable();
this._populateScrollbar();
},
_serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) {
mergeCols = mergeCols || [];
mergeRows = mergeRows || [];
var self = this, o = this.options;
var result = [], cache = {}, preCol = {}, preRow = {}, map = {};
var summaryColumnSize = [];
for (var i = startCol; i < endCol; i++) {
if (i === startCol) {
summaryColumnSize[i] = columnSize[i];
} else {
summaryColumnSize[i] = summaryColumnSize[i - 1] + columnSize[i];
}
}
var mergeRow = function (i, j) {
preCol[j]._height += rowHeight;
preCol[j].__mergeRows.push(i);
};
var mergeCol = function (i, j) {
preRow[i]._width += columnSize[j];
preRow[i].__mergeCols.push(j);
};
var createOneEl = function (r, c) {
var width = columnSize[c];
var height = rowHeight;
map[r][c]._row = r;
map[r][c]._col = c;
map[r][c]._width = width;
map[r][c]._height = height;
preCol[c] = map[r][c];
preCol[c].__mergeRows = [r];
preRow[r] = map[r][c];
preRow[r].__mergeCols = [c];
result.push({
x: summaryColumnSize[c] - columnSize[c],
y: +r * rowHeight,
item: map[r][c]
});
};
BI.each(items, function (i, cols) {
for (var j = startCol; j < endCol; j++) {
if (!cache[i]) {
cache[i] = {};
}
if (!map[i]) {
map[i] = {};
}
cache[i][j] = cols[j];
map[i][j] = {};
if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) {
if (i === 0 && j === startCol) {
createOneEl(0, startCol);
} else if (j === startCol && i > 0) {
var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]);
if (isNeedMergeRow === true) {
mergeRow(i, j);
preRow[i] = preCol[j];
} else {
createOneEl(i, j);
}
} else if (i === 0 && j > startCol) {
var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]);
if (isNeedMergeCol === true) {
mergeCol(i, j);
preCol[j] = preRow[i];
} else {
createOneEl(i, j);
}
} else {
var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]);
var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]);
if (isNeedMergeCol && isNeedMergeRow) {
continue;
//mergeRow(i, j);//优先合并列
}
if (isNeedMergeCol) {
mergeCol(i, j);
}
if (isNeedMergeRow) {
mergeRow(i, j);
}
if (!isNeedMergeCol && !isNeedMergeRow) {
createOneEl(i, j);
}
}
} else {
createOneEl(i, j);
}
}
});
return BI.map(result, function (i, item) {
return {
x: item.x,
y: item.y,
row: item.item._row,
col: item.item._col,
width: item.item._width,
height: item.item._height
}
});
},
populate: function (items, header) {
if (items && this.options.items !== items) {
this._isNeedDigest = true;
this.options.items = items;
this._restore();
}
if (header && this.options.header !== header) {
this._isNeedDigest = true;
this.options.header = header;
this._restore();
}
this._populate();
},
_restore: function () {
this.topLeftCollection.restore();
this.topRightCollection.restore();
this.bottomLeftCollection.restore();
this.bottomRightCollection.restore();
},
restore: function () {
this._restore();
},
setWidth: function (width) {
BI.CanvasTable.superclass.setWidth.apply(this, arguments);
this._width = width - BI.GridTableScrollbar.SIZE;
},
setHeight: function (height) {
BI.CanvasTable.superclass.setHeight.apply(this, arguments);
this._height = height - BI.GridTableScrollbar.SIZE;
},
setVerticalScroll: function (scrollTop) {
this.bottomLeftCollection.setScrollTop(scrollTop);
this.bottomRightCollection.setScrollTop(scrollTop);
},
setLeftHorizontalScroll: function (scrollLeft) {
this.topLeftCollection.setScrollLeft(scrollLeft);
this.bottomLeftCollection.setScrollLeft(scrollLeft);
},
setRightHorizontalScroll: function (scrollLeft) {
this.topRightCollection.setScrollLeft(scrollLeft);
this.bottomRightCollection.setScrollLeft(scrollLeft);
},
getVerticalScroll: function () {
return this.bottomRightCollection.getScrollTop();
},
getLeftHorizontalScroll: function () {
return this.bottomLeftCollection.getScrollLeft();
},
getRightHorizontalScroll: function () {
return this.bottomRightCollection.getScrollLeft();
},
setColumnSize: function (columnSize) {
this._isNeedDigest = true;
this.options.columnSize = columnSize;
},
setRegionColumnSize: function (regionColumnSize) {
this._isNeedDigest = true;
this.options.regionColumnSize = regionColumnSize;
},
getColumnSize: function () {
return this.options.columnSize;
},
getRegionColumnSize: function () {
return this.options.regionColumnSize;
},
});
BI.shortcut("bi.canvas_table", BI.CanvasTable);

357
src/widget/multiselect/multiselect..insert.combo.js

@ -0,0 +1,357 @@
/**
*
* @class BI.MultiSelectInsertCombo
* @extends BI.Single
*/
BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-insert-combo',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 28
});
},
_init: function () {
BI.MultiSelectInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
};
this.storeValue = {};
//标记正在请求数据
this.requesting = false;
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
// adapter: this.popup,
masker: {
offset: {
left: 1,
top: 1,
right: 2,
bottom: 33
}
},
valueFormatter: o.valueFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
//预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self._setStartValue("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
// if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
//如果在不选的状态下直接把该值添加进来
if (self.storeValue.type === BI.Selection.Multi) {
self.storeValue.value.pushDistinct(keyword);
}
self.combo.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
})
// }
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
}
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () {
assertShowValue();
});
} else {
self._join(this.getValue(), function () {
assertShowValue();
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.combo = BI.createWidget({
type: "bi.combo",
toggle: false,
el: this.trigger,
adjustLength: 1,
popup: {
type: 'bi.multi_select_popup_view',
ref: function () {
self.popup = this;
self.trigger.setAdapter(this);
},
listeners: [{
eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
action: function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
});
}
}, {
eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
action: function () {
self._defaultState();
}
}, {
eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
action: function () {
self.setValue();
self._defaultState();
}
}],
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: function () {
BI.nextTick(function () {
self.combo.adjustWidth();
self.combo.adjustHeight();
self.trigger.getCounter().adjustView();
self.trigger.getSearcher().adjustView();
});
}
},
hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0;
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
this.setValue(self.storeValue);
BI.nextTick(function () {
self.populate();
});
});
//当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
this.wants2Quit = false;
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
//important:关闭弹出时又可能没有退出编辑状态
self.trigger.stopEditing();
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM);
}
});
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
width: o.height,
height: o.height,
cls: "multi-select-trigger-icon-button bi-border-left"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.trigger.getCounter().hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.combo,
left: 0,
right: 0,
top: 0,
bottom: 0
}, {
el: triggerBtn,
right: 0,
top: 0,
bottom: 0
}]
})
},
_defaultState: function () {
this.trigger.stopEditing();
this.combo.hideView();
},
_assertValue: function (val) {
val || (val = {});
val.type || (val.type = BI.Selection.Multi);
val.value || (val.value = []);
},
_makeMap: function (values) {
return BI.makeObject(values || []);
},
_joinKeywords: function (keywords, callback) {
var self = this, o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA,
keywords: keywords
}, function (ob) {
var values = BI.pluck(ob.items, "value");
digest(values);
});
function digest(items) {
var selectedMap = self._makeMap(items);
BI.each(keywords, function (i, val) {
if (BI.isNotNull(selectedMap[val])) {
self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
}
});
self._adjust(callback);
}
},
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];
BI.each(items, function (i, item) {
if (BI.isNotNull(selectedMap[items[i]])) {
delete selectedMap[items[i]];
}
if (BI.isNull(notSelectedMap[items[i]])) {
newItems.push(item);
}
});
self.storeValue.value = newItems.concat(BI.values(selectedMap));
self._adjust(callback);
})
},
_adjust: function (callback) {
var self = this, o = this.options;
adjust();
callback();
function adjust() {
if (self.wants2Quit === true) {
self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
}
},
_join: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this._assertValue(this.storeValue);
if (this.storeValue.type === res.type) {
var map = this._makeMap(this.storeValue.value);
BI.each(res.value, function (i, v) {
if (!map[v]) {
self.storeValue.value.push(v);
map[v] = v;
}
});
var change = false;
BI.each(res.assist, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
this._joinAll(res, callback);
},
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue);
},
getValue: function () {
return BI.deepClone(this.storeValue);
},
populate: function () {
this.combo.populate.apply(this.combo, arguments);
}
});
BI.extend(BI.MultiSelectInsertCombo, {
REQ_GET_DATA_LENGTH: 0,
REQ_GET_ALL_DATA: -1
});
BI.MultiSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut('bi.multi_select_insert_combo', BI.MultiSelectInsertCombo);

76
src/widget/multiselect/multiselect.combo.js

@ -59,23 +59,19 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self._setStartValue(""); self._setStartValue("");
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
// if (this.getSearcher().hasMatched()) { if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword(); var keyword = this.getSearcher().getKeyword();
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
//如果在不选的状态下直接把该值添加进来 self.combo.setValue(self.storeValue);
if (self.storeValue.type === BI.Selection.Multi) { self._setStartValue(keyword);
self.storeValue.value.pushDistinct(keyword); assertShowValue();
} self.populate();
self.combo.setValue(self.storeValue); self._setStartValue("");
self._setStartValue(keyword); })
assertShowValue(); }
self.populate();
self._setStartValue("");
})
// }
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords); var last = BI.last(keywords);
@ -290,32 +286,32 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_adjust: function (callback) { _adjust: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
// if (!this._count) { if (!this._count) {
// o.itemsCreator({ o.itemsCreator({
// type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
// }, function (res) { }, function (res) {
// self._count = res.count; self._count = res.count;
// adjust(); adjust();
// callback(); callback();
// }); });
// } else { } else {
adjust(); adjust();
callback(); callback();
// } }
function adjust() { function adjust() {
// if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
// self.storeValue = { self.storeValue = {
// type: BI.Selection.Multi, type: BI.Selection.Multi,
// value: [] value: []
// } }
// } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
// self.storeValue = { self.storeValue = {
// type: BI.Selection.All, type: BI.Selection.All,
// value: [] value: []
// } }
// } }
if (self.wants2Quit === true) { if (self.wants2Quit === true) {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false; self.wants2Quit = false;

326
src/widget/multiselectlist/multiselectlist.insert.js

@ -0,0 +1,326 @@
/**
* Created by zcf_1 on 2017/5/2.
*/
BI.MultiSelectInsertList = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectInsertList.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-insert-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn
})
},
_init: function () {
BI.MultiSelectInsertList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
// self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
type: "bi.multi_select_loader",
cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
logic: {
dynamic: false
},
// onLoaded: o.onLoaded,
el: {}
});
this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
assertShowValue();
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
});
this.searcherPane = BI.createWidget({
type: "bi.multi_select_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self._setStartValue("");
this.setValue(BI.deepClone(self.storeValue));
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue("");
self.adapter.setValue(self.storeValue);
//需要刷新回到初始界面,否则搜索的结果不能放在最前面
self.adapter.populate();
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
var keyword = this.getKeyword();
if (this.hasMatched()) {
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
if (self.storeValue.type === BI.Selection.Multi) {
self.storeValue.value.pushDistinct(keyword)
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
})
} else {
if (self.storeValue.type === BI.Selection.Multi) {
self.storeValue.value.pushDistinct(keyword)
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
self.adapter.populate();
if (self.storeValue.type === BI.Selection.Multi) {
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
}
}
}
}, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeyword();
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
} else {
self.adapter.setValue(self.storeValue);
assertShowValue();
}
});
}
}
}, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function (value, obj) {
if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () {
assertShowValue();
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
});
} else {
self._join(this.getValue(), function () {
assertShowValue();
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
});
}
}
}]
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: this.trigger,
height: 30
}, {
el: this.adapter,
height: "fill"
}]
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
})
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
_defaultState: function () {
this.trigger.stopEditing();
},
_assertValue: function (val) {
val || (val = {});
val.type || (val.type = BI.Selection.Multi);
val.value || (val.value = []);
},
_makeMap: function (values) {
return BI.makeObject(values || []);
},
_joinKeywords: function (keywords, callback) {
var self = this, o = this.options;
this._assertValue(this.storeValue);
if (!this._allData) {
o.itemsCreator({
type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA
}, function (ob) {
self._allData = BI.pluck(ob.items, "value");
digest(self._allData);
})
} else {
digest(this._allData)
}
function digest(items) {
var selectedMap = self._makeMap(items);
BI.each(keywords, function (i, val) {
if (BI.isNotNull(selectedMap[val])) {
self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
}
});
callback();
}
},
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
o.itemsCreator({
type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA,
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
callback();
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];
BI.each(items, function (i, item) {
if (BI.isNotNull(selectedMap[items[i]])) {
delete selectedMap[items[i]];
}
if (BI.isNull(notSelectedMap[items[i]])) {
newItems.push(item);
}
});
self.storeValue.value = newItems.concat(BI.values(selectedMap));
callback();
})
},
_join: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this._assertValue(this.storeValue);
if (this.storeValue.type === res.type) {
var map = this._makeMap(this.storeValue.value);
BI.each(res.value, function (i, v) {
if (!map[v]) {
self.storeValue.value.push(v);
map[v] = v;
}
});
var change = false;
BI.each(res.assist, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
callback();
return;
}
this._joinAll(res, callback);
},
_setStartValue: function (value) {
this._startValue = value;
this.adapter.setStartValue(value);
},
isAllSelected: function () {
return this.adapter.isAllSelected();
},
resize: function () {
// this.trigger.getCounter().adjustView();
// this.trigger.adjustView();
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
getValue: function () {
return BI.deepClone(this.storeValue);
},
populate: function () {
this._count = null;
this._allData = null;
this.adapter.populate.apply(this.adapter, arguments);
this.trigger.populate.apply(this.trigger, arguments);
}
});
BI.extend(BI.MultiSelectInsertList, {
REQ_GET_DATA_LENGTH: 0,
REQ_GET_ALL_DATA: -1
});
BI.MultiSelectInsertList.EVENT_CHANGE = "BI.MultiSelectInsertList.EVENT_CHANGE";
BI.shortcut("bi.multi_select_insert_list", BI.MultiSelectInsertList);

60
src/widget/multiselectlist/multiselectlist.js

@ -90,9 +90,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
if (self.storeValue.type === BI.Selection.Multi) {
self.storeValue.value.pushDistinct(keyword)
}
self._showAdapter(); self._showAdapter();
self.adapter.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
@ -101,16 +98,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
self._setStartValue(""); self._setStartValue("");
self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
}) })
} else {
if (self.storeValue.type === BI.Selection.Multi) {
self.storeValue.value.pushDistinct(keyword)
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
self.adapter.populate();
if (self.storeValue.type === BI.Selection.Multi) {
self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
}
} }
} }
}, { }, {
@ -263,32 +250,31 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
_adjust: function (callback) { _adjust: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
// if (!this._count) { if (!this._count) {
// o.itemsCreator({ o.itemsCreator({
// type: BI.MultiSelectList.REQ_GET_DATA_LENGTH type: BI.MultiSelectList.REQ_GET_DATA_LENGTH
// }, function (res) { }, function (res) {
// self._count = res.count; self._count = res.count;
// adjust(); adjust();
// callback(); callback();
// }); });
// } else { } else {
adjust(); adjust();
callback(); callback();
}
// }
function adjust() { function adjust() {
// if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
// self.storeValue = { self.storeValue = {
// type: BI.Selection.Multi, type: BI.Selection.Multi,
// value: [] value: []
// } }
// } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
// self.storeValue = { self.storeValue = {
// type: BI.Selection.All, type: BI.Selection.All,
// value: [] value: []
// } }
// } }
} }
}, },

Loading…
Cancel
Save