Browse Source

Merge remote-tracking branch 'origin/master'

es6
guy 7 years ago
parent
commit
6fb0afab35
  1. 642
      bi/base.js
  2. 42
      bi/sliders.css
  3. 457
      bi/sliders.js
  4. 642
      dist/base.js
  5. 642
      dist/bundle.js
  6. 2410
      dist/demo.js
  7. 42
      dist/sliders.css
  8. 457
      dist/sliders.js
  9. 122
      src/addons/sliders/js/intervalslider/intervalslider.js
  10. 121
      src/addons/sliders/js/intervalslider/intervalslider.label.js
  11. 73
      src/addons/sliders/js/singleslider/singleslider.js
  12. 73
      src/addons/sliders/js/singleslider/singleslider.label.js
  13. 68
      src/addons/sliders/js/singleslider/singleslider.normal.js

642
bi/base.js

@ -16267,68 +16267,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) {
}
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器
*
@ -16609,57 +16609,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
}
});
}());
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
*
* Created by GUY on 2015/11/26.
@ -16927,214 +16927,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false);
},
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 16,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 16,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器
*

42
bi/sliders.css

@ -24,27 +24,15 @@
-moz-border-radius: 7px;
border-radius: 7px;
}
.bi-single-slider-button .slider-button {
cursor: ew-resize;
-webkit-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);
-webkit-border-radius: 7px;
-moz-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-single-slider-button .slider-button {
cursor: ew-resize;
-webkit-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);
-webkit-border-radius: 7px;
-moz-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);
@ -57,3 +45,15 @@
-moz-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;
}

457
bi/sliders.js

@ -100,56 +100,11 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
this.sliderOne = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
self.labelOne.setValue(v);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
ui.helper.removeClass("dragging");
},
start: function (e, ui) {
ui.helper.removeClass("dragging").addClass("dragging");
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
self.labelTwo.setValue(v);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}
});
this._draggable(this.sliderOne, true);
this._draggable(this.sliderTwo, false);
this._setVisible(false);
BI.createWidget({
@ -179,6 +134,70 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
})
},
_rePosBySizeAfterMove: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
}else{
this._setLabelTwoPosition(significantPercent);
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
}
this._setBlueTrack();
},
_rePosBySizeAfterStop: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
},
_draggable: function (widget, isLeft) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
self._rePosBySizeAfterMove(size, isLeft);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
self._rePosBySizeAfterStop(size, isLeft);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createLabelWrapper: function () {
var c = this._constant;
return {
@ -371,13 +390,8 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
this.sliderOne.setEnable(enable);
this.sliderTwo.setEnable(enable);
},
_getPrecision: function () {
@ -542,56 +556,12 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
this.sliderOne = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
self.labelOne.setValue(v);
self.labelOne.setText(v + o.unit);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
self.labelTwo.setValue(v);
self.labelTwo.setText(v + o.unit);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}
});
this._draggable(this.sliderOne, true);
this._draggable(this.sliderTwo, false);
this._setVisible(false);
BI.createWidget({
@ -621,6 +591,70 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
})
},
_rePosBySizeAfterMove: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
}else{
this._setLabelTwoPosition(significantPercent);
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
}
this._setBlueTrack();
},
_rePosBySizeAfterStop: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
},
_draggable: function (widget, isLeft) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
self._rePosBySizeAfterMove(size, isLeft);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
self._rePosBySizeAfterStop(size, isLeft);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createLabelWrapper: function () {
var c = this._constant;
return {
@ -807,13 +841,8 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
this.sliderOne.setEnable(enable);
this.sliderTwo.setEnable(enable);
},
_getPrecision: function () {
@ -1218,28 +1247,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
@ -1342,6 +1350,56 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
})
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
@ -1511,28 +1569,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
@ -1614,6 +1651,56 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
})
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
@ -1769,25 +1856,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.value = v;
self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
@ -1849,6 +1918,54 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
}
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.value = v;
self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrack: function () {
var self = this;
var c = this._constant;

642
dist/base.js vendored

@ -16267,68 +16267,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) {
}
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器
*
@ -16609,57 +16609,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
}
});
}());
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
*
* Created by GUY on 2015/11/26.
@ -16927,214 +16927,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false);
},
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 16,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 16,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器
*

642
dist/bundle.js vendored

@ -42008,68 +42008,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) {
}
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器
*
@ -42350,57 +42350,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
}
});
}());
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
*
* Created by GUY on 2015/11/26.
@ -42668,214 +42668,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false);
},
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 16,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 16,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器
*

2410
dist/demo.js vendored

File diff suppressed because it is too large Load Diff

42
dist/sliders.css vendored

@ -24,27 +24,15 @@
-moz-border-radius: 7px;
border-radius: 7px;
}
.bi-single-slider-button .slider-button {
cursor: ew-resize;
-webkit-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);
-webkit-border-radius: 7px;
-moz-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-single-slider-button .slider-button {
cursor: ew-resize;
-webkit-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);
-webkit-border-radius: 7px;
-moz-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);
@ -57,3 +45,15 @@
-moz-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;
}

457
dist/sliders.js vendored

@ -100,56 +100,11 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
this.sliderOne = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
self.labelOne.setValue(v);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
ui.helper.removeClass("dragging");
},
start: function (e, ui) {
ui.helper.removeClass("dragging").addClass("dragging");
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
self.labelTwo.setValue(v);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}
});
this._draggable(this.sliderOne, true);
this._draggable(this.sliderTwo, false);
this._setVisible(false);
BI.createWidget({
@ -179,6 +134,70 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
})
},
_rePosBySizeAfterMove: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
}else{
this._setLabelTwoPosition(significantPercent);
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
}
this._setBlueTrack();
},
_rePosBySizeAfterStop: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
},
_draggable: function (widget, isLeft) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
self._rePosBySizeAfterMove(size, isLeft);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
self._rePosBySizeAfterStop(size, isLeft);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createLabelWrapper: function () {
var c = this._constant;
return {
@ -371,13 +390,8 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
this.sliderOne.setEnable(enable);
this.sliderTwo.setEnable(enable);
},
_getPrecision: function () {
@ -542,56 +556,12 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
this.sliderOne = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
self.labelOne.setValue(v);
self.labelOne.setText(v + o.unit);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
self.labelTwo.setValue(v);
self.labelTwo.setText(v + o.unit);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}
});
this._draggable(this.sliderOne, true);
this._draggable(this.sliderTwo, false);
this._setVisible(false);
BI.createWidget({
@ -621,6 +591,70 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
})
},
_rePosBySizeAfterMove: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
}else{
this._setLabelTwoPosition(significantPercent);
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
}
this._setBlueTrack();
},
_rePosBySizeAfterStop: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
},
_draggable: function (widget, isLeft) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
self._rePosBySizeAfterMove(size, isLeft);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
self._rePosBySizeAfterStop(size, isLeft);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createLabelWrapper: function () {
var c = this._constant;
return {
@ -807,13 +841,8 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
this.sliderOne.setEnable(enable);
this.sliderTwo.setEnable(enable);
},
_getPrecision: function () {
@ -1218,28 +1247,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
@ -1342,6 +1350,56 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
})
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
@ -1511,28 +1569,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
@ -1614,6 +1651,56 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
})
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
@ -1769,25 +1856,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.value = v;
self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
@ -1849,6 +1918,54 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
}
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.value = v;
self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrack: function () {
var self = this;
var c = this._constant;

122
src/addons/sliders/js/intervalslider/intervalslider.js

@ -100,56 +100,11 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
this.sliderOne = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
self.labelOne.setValue(v);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
ui.helper.removeClass("dragging");
},
start: function (e, ui) {
ui.helper.removeClass("dragging").addClass("dragging");
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
self.labelTwo.setValue(v);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}
});
this._draggable(this.sliderOne, true);
this._draggable(this.sliderTwo, false);
this._setVisible(false);
BI.createWidget({
@ -179,6 +134,70 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
})
},
_rePosBySizeAfterMove: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
}else{
this._setLabelTwoPosition(significantPercent);
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
}
this._setBlueTrack();
},
_rePosBySizeAfterStop: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
},
_draggable: function (widget, isLeft) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
self._rePosBySizeAfterMove(size, isLeft);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
self._rePosBySizeAfterStop(size, isLeft);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createLabelWrapper: function () {
var c = this._constant;
return {
@ -371,13 +390,8 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
this.sliderOne.setEnable(enable);
this.sliderTwo.setEnable(enable);
},
_getPrecision: function () {

121
src/addons/sliders/js/intervalslider/intervalslider.label.js

@ -58,56 +58,12 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
this.sliderOne = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
self.labelOne.setValue(v);
self.labelOne.setText(v + o.unit);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_button"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = self._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
self.labelTwo.setValue(v);
self.labelTwo.setText(v + o.unit);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}
});
this._draggable(this.sliderOne, true);
this._draggable(this.sliderTwo, false);
this._setVisible(false);
BI.createWidget({
@ -137,6 +93,70 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
})
},
_rePosBySizeAfterMove: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
}else{
this._setLabelTwoPosition(significantPercent);
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
}
this._setBlueTrack();
},
_rePosBySizeAfterStop: function (size, isLeft) {
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
},
_draggable: function (widget, isLeft) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
self._rePosBySizeAfterMove(size, isLeft);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
self._rePosBySizeAfterStop(size, isLeft);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.IntervalSliderLabel.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createLabelWrapper: function () {
var c = this._constant;
return {
@ -323,13 +343,8 @@ BI.IntervalSliderLabel = BI.inherit(BI.Widget, {
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
this.sliderOne.setEnable(enable);
this.sliderTwo.setEnable(enable);
},
_getPrecision: function () {

73
src/addons/sliders/js/singleslider/singleslider.js

@ -39,28 +39,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
@ -163,6 +142,56 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
})
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",

73
src/addons/sliders/js/singleslider/singleslider.label.js

@ -41,28 +41,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
@ -144,6 +123,56 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
})
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",

68
src/addons/sliders/js/singleslider/singleslider.normal.js

@ -28,25 +28,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
this.slider = BI.createWidget({
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.value = v;
self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this._draggable(this.slider);
var sliderVertical = BI.createWidget({
type: "bi.vertical",
@ -108,6 +90,54 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
}
},
_draggable: function (widget) {
var self = this, o = this.options;
var startDrag = false;
var size = 0, offset = 0, defaultSize = 0;
var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
size = optimizeSize(defaultSize + offset);
widget.element.addClass("dragging");
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = o.digit === false ? v : v.toFixed(o.digit);
self.value = v;
self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v);
}
}, function () {
if (startDrag === true) {
size = optimizeSize(size);
var percent = size * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
size = 0;
offset = 0;
defaultSize = size;
startDrag = false;
}
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}, document);
widget.element.on("mousedown", function (event) {
if(!widget.isEnabled()){
return;
}
defaultSize = this.offsetLeft;
optimizeSize(defaultSize);
mouseMoveTracker.captureMouseMoves(event);
});
function optimizeSize(s) {
return BI.clamp(s, 0, o.width);
}
},
_createTrack: function () {
var self = this;
var c = this._constant;

Loading…
Cancel
Save