Browse Source

统一slider

es6
windy 7 years ago
parent
commit
803fc24bbd
  1. 225
      bi/widget.js
  2. 4
      demo/js/widget/slider/demo.slider.js
  3. 225
      dist/bundle.js
  4. 18
      dist/bundle.min.js
  5. 4
      dist/demo.js
  6. 225
      dist/widget.js
  7. 15
      src/widget/intervalslider/intervalslider.js
  8. 205
      src/widget/singleslider/button/editor.sign.text.js
  9. 6
      src/widget/singleslider/singleslider.js

225
bi/widget.js

@ -5620,7 +5620,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-interval-slider bi-slider-track"
baseCls: "bi-interval-slider bi-slider-track",
digit: false,
unit: ""
})
},
@ -5652,8 +5654,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
this.track = this._createTrackWrapper();
this.labelOne = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
text: this.options.unit,
errorText: "",
allowBlank: false,
width: c.EDITOR_WIDTH,
@ -5678,9 +5681,10 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
});
this.labelTwo = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: this.options.unit,
allowBlank: false,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
@ -5741,10 +5745,12 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
_rePosBySizeAfterMove: function (size, isLeft) {
var o = this.options;
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
@ -6056,8 +6062,11 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
setValue: function (v) {
var o = this.options;
var valueOne = BI.parseFloat(v.min);
var valueTwo = BI.parseFloat(v.max);
valueOne = o.digit === false ? valueOne : valueOne.toFixed(o.digit);
valueTwo = o.digit === false ? valueTwo : valueTwo.toFixed(o.digit);
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
this.valueOne = valueOne;
@ -17276,6 +17285,210 @@ BI.SequenceTable = BI.inherit(BI.Widget, {
}
});
BI.shortcut('bi.sequence_table', BI.SequenceTable);/**
* Created by User on 2017/11/16.
*/
BI.SignTextEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.SignTextEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
hgap: 4,
vgap: 2,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn,
allowBlank: true,
watermark: "",
errorText: "",
value: "",
text: "",
height: 24
})
},
_init: function () {
BI.SignTextEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.editor",
height: o.height,
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
});
this.text = BI.createWidget({
type: "bi.text_button",
cls: "sign-editor-text",
title: o.title,
warningTitle: o.warningTitle,
tipType: o.tipType,
textAlign: "left",
height: o.height,
hgap: 4,
handler: function () {
self._showInput();
self.editor.focus();
self.editor.selectAll();
}
});
this.text.on(BI.TextButton.EVENT_CHANGE, function () {
BI.nextTick(function () {
self.fireEvent(BI.SignTextEditor.EVENT_CLICK_LABEL)
});
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
self._showHint();
self._checkText();
self.fireEvent(BI.SignTextEditor.EVENT_CONFIRM, arguments);
});
this.editor.on(BI.Editor.EVENT_ERROR, function () {
self._checkText();
});
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
});
this._showHint();
self._checkText();
},
_checkText: function () {
var o = this.options;
BI.nextTick(BI.bind(function () {
if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark");
} else {
var v = this.editor.getValue();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
this.text.element.removeClass("bi-water-mark");
}
}, this));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
setTitle: function (title) {
this.text.setTitle(title);
},
setWarningTitle: function (title) {
this.text.setWarningTitle(title);
},
focus: function () {
this._showInput();
this.editor.focus();
},
blur: function () {
this.editor.blur();
this._showHint();
this._checkText();
},
doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
isValid: function () {
return this.editor.isValid();
},
setErrorText: function (text) {
this.editor.setErrorText(text);
},
getErrorText: function () {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) {
this.editor.setValue(v);
this._checkText();
},
getValue: function () {
return this.editor.getValue();
},
getState: function () {
return this.text.getValue();
},
setState: function (v) {
var o = this.options;
this._showHint();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
}
});
BI.SignTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.sign_text_editor", BI.SignTextEditor);/**
* Created by zcf on 2016/9/22.
*/
BI.SliderIconButton = BI.inherit(BI.Widget, {
@ -17322,7 +17535,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track",
digit: false
digit: false,
unit: ""
});
},
_init: function () {
@ -17382,9 +17596,10 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}
});
this.label = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: o.unit,
width: c.EDITOR_WIDTH - 2,
allowBlank: false,
validationChecker: function (v) {

4
demo/js/widget/slider/demo.slider.js

@ -45,7 +45,7 @@ Demo.Slider = BI.inherit(BI.Widget, {
normalSingleSlider.populate();
var singleSliderLabel = BI.createWidget({
type: "bi.single_slider_label",
type: "bi.single_slider",
width: o.width,
height: o.height,
digit: 0,
@ -75,7 +75,7 @@ Demo.Slider = BI.inherit(BI.Widget, {
intervalSlider.populate();
var intervalSliderLabel = BI.createWidget({
type: "bi.interval_slider_label",
type: "bi.interval_slider",
width: o.width,
unit: "个",
cls: "layout-bg-white"

225
dist/bundle.js vendored

@ -80697,7 +80697,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-interval-slider bi-slider-track"
baseCls: "bi-interval-slider bi-slider-track",
digit: false,
unit: ""
})
},
@ -80729,8 +80731,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
this.track = this._createTrackWrapper();
this.labelOne = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
text: this.options.unit,
errorText: "",
allowBlank: false,
width: c.EDITOR_WIDTH,
@ -80755,9 +80758,10 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
});
this.labelTwo = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: this.options.unit,
allowBlank: false,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
@ -80818,10 +80822,12 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
_rePosBySizeAfterMove: function (size, isLeft) {
var o = this.options;
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
@ -81133,8 +81139,11 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
setValue: function (v) {
var o = this.options;
var valueOne = BI.parseFloat(v.min);
var valueTwo = BI.parseFloat(v.max);
valueOne = o.digit === false ? valueOne : valueOne.toFixed(o.digit);
valueTwo = o.digit === false ? valueTwo : valueTwo.toFixed(o.digit);
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
this.valueOne = valueOne;
@ -92353,6 +92362,210 @@ BI.SequenceTable = BI.inherit(BI.Widget, {
}
});
BI.shortcut('bi.sequence_table', BI.SequenceTable);/**
* Created by User on 2017/11/16.
*/
BI.SignTextEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.SignTextEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
hgap: 4,
vgap: 2,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn,
allowBlank: true,
watermark: "",
errorText: "",
value: "",
text: "",
height: 24
})
},
_init: function () {
BI.SignTextEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.editor",
height: o.height,
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
});
this.text = BI.createWidget({
type: "bi.text_button",
cls: "sign-editor-text",
title: o.title,
warningTitle: o.warningTitle,
tipType: o.tipType,
textAlign: "left",
height: o.height,
hgap: 4,
handler: function () {
self._showInput();
self.editor.focus();
self.editor.selectAll();
}
});
this.text.on(BI.TextButton.EVENT_CHANGE, function () {
BI.nextTick(function () {
self.fireEvent(BI.SignTextEditor.EVENT_CLICK_LABEL)
});
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
self._showHint();
self._checkText();
self.fireEvent(BI.SignTextEditor.EVENT_CONFIRM, arguments);
});
this.editor.on(BI.Editor.EVENT_ERROR, function () {
self._checkText();
});
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
});
this._showHint();
self._checkText();
},
_checkText: function () {
var o = this.options;
BI.nextTick(BI.bind(function () {
if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark");
} else {
var v = this.editor.getValue();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
this.text.element.removeClass("bi-water-mark");
}
}, this));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
setTitle: function (title) {
this.text.setTitle(title);
},
setWarningTitle: function (title) {
this.text.setWarningTitle(title);
},
focus: function () {
this._showInput();
this.editor.focus();
},
blur: function () {
this.editor.blur();
this._showHint();
this._checkText();
},
doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
isValid: function () {
return this.editor.isValid();
},
setErrorText: function (text) {
this.editor.setErrorText(text);
},
getErrorText: function () {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) {
this.editor.setValue(v);
this._checkText();
},
getValue: function () {
return this.editor.getValue();
},
getState: function () {
return this.text.getValue();
},
setState: function (v) {
var o = this.options;
this._showHint();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
}
});
BI.SignTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.sign_text_editor", BI.SignTextEditor);/**
* Created by zcf on 2016/9/22.
*/
BI.SliderIconButton = BI.inherit(BI.Widget, {
@ -92399,7 +92612,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track",
digit: false
digit: false,
unit: ""
});
},
_init: function () {
@ -92459,9 +92673,10 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}
});
this.label = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: o.unit,
width: c.EDITOR_WIDTH - 2,
allowBlank: false,
validationChecker: function (v) {

18
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

4
dist/demo.js vendored

@ -13031,7 +13031,7 @@ Demo.Slider = BI.inherit(BI.Widget, {
normalSingleSlider.populate();
var singleSliderLabel = BI.createWidget({
type: "bi.single_slider_label",
type: "bi.single_slider",
width: o.width,
height: o.height,
digit: 0,
@ -13061,7 +13061,7 @@ Demo.Slider = BI.inherit(BI.Widget, {
intervalSlider.populate();
var intervalSliderLabel = BI.createWidget({
type: "bi.interval_slider_label",
type: "bi.interval_slider",
width: o.width,
unit: "个",
cls: "layout-bg-white"

225
dist/widget.js vendored

@ -5620,7 +5620,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-interval-slider bi-slider-track"
baseCls: "bi-interval-slider bi-slider-track",
digit: false,
unit: ""
})
},
@ -5652,8 +5654,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
this.track = this._createTrackWrapper();
this.labelOne = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
text: this.options.unit,
errorText: "",
allowBlank: false,
width: c.EDITOR_WIDTH,
@ -5678,9 +5681,10 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
});
this.labelTwo = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: this.options.unit,
allowBlank: false,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
@ -5741,10 +5745,12 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
_rePosBySizeAfterMove: function (size, isLeft) {
var o = this.options;
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
@ -6056,8 +6062,11 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
setValue: function (v) {
var o = this.options;
var valueOne = BI.parseFloat(v.min);
var valueTwo = BI.parseFloat(v.max);
valueOne = o.digit === false ? valueOne : valueOne.toFixed(o.digit);
valueTwo = o.digit === false ? valueTwo : valueTwo.toFixed(o.digit);
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
this.valueOne = valueOne;
@ -17276,6 +17285,210 @@ BI.SequenceTable = BI.inherit(BI.Widget, {
}
});
BI.shortcut('bi.sequence_table', BI.SequenceTable);/**
* Created by User on 2017/11/16.
*/
BI.SignTextEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.SignTextEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
hgap: 4,
vgap: 2,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn,
allowBlank: true,
watermark: "",
errorText: "",
value: "",
text: "",
height: 24
})
},
_init: function () {
BI.SignTextEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.editor",
height: o.height,
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
});
this.text = BI.createWidget({
type: "bi.text_button",
cls: "sign-editor-text",
title: o.title,
warningTitle: o.warningTitle,
tipType: o.tipType,
textAlign: "left",
height: o.height,
hgap: 4,
handler: function () {
self._showInput();
self.editor.focus();
self.editor.selectAll();
}
});
this.text.on(BI.TextButton.EVENT_CHANGE, function () {
BI.nextTick(function () {
self.fireEvent(BI.SignTextEditor.EVENT_CLICK_LABEL)
});
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
self._showHint();
self._checkText();
self.fireEvent(BI.SignTextEditor.EVENT_CONFIRM, arguments);
});
this.editor.on(BI.Editor.EVENT_ERROR, function () {
self._checkText();
});
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
});
this._showHint();
self._checkText();
},
_checkText: function () {
var o = this.options;
BI.nextTick(BI.bind(function () {
if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark");
} else {
var v = this.editor.getValue();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
this.text.element.removeClass("bi-water-mark");
}
}, this));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
setTitle: function (title) {
this.text.setTitle(title);
},
setWarningTitle: function (title) {
this.text.setWarningTitle(title);
},
focus: function () {
this._showInput();
this.editor.focus();
},
blur: function () {
this.editor.blur();
this._showHint();
this._checkText();
},
doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
isValid: function () {
return this.editor.isValid();
},
setErrorText: function (text) {
this.editor.setErrorText(text);
},
getErrorText: function () {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) {
this.editor.setValue(v);
this._checkText();
},
getValue: function () {
return this.editor.getValue();
},
getState: function () {
return this.text.getValue();
},
setState: function (v) {
var o = this.options;
this._showHint();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
}
});
BI.SignTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.sign_text_editor", BI.SignTextEditor);/**
* Created by zcf on 2016/9/22.
*/
BI.SliderIconButton = BI.inherit(BI.Widget, {
@ -17322,7 +17535,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track",
digit: false
digit: false,
unit: ""
});
},
_init: function () {
@ -17382,9 +17596,10 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}
});
this.label = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: o.unit,
width: c.EDITOR_WIDTH - 2,
allowBlank: false,
validationChecker: function (v) {

15
src/widget/intervalslider/intervalslider.js

@ -14,7 +14,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-interval-slider bi-slider-track"
baseCls: "bi-interval-slider bi-slider-track",
digit: false,
unit: ""
})
},
@ -46,8 +48,9 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
this.track = this._createTrackWrapper();
this.labelOne = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
text: this.options.unit,
errorText: "",
allowBlank: false,
width: c.EDITOR_WIDTH,
@ -72,9 +75,10 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
});
this.labelTwo = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: this.options.unit,
allowBlank: false,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
@ -135,10 +139,12 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
_rePosBySizeAfterMove: function (size, isLeft) {
var o = this.options;
var percent = size * 100 / (this._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
var v = this._getValueByPercent(significantPercent);
v = this._assertValue(v);
v = o.digit === false ? v : v.toFixed(o.digit);
if(isLeft){
this._setLabelOnePosition(significantPercent);
this._setSliderOnePosition(significantPercent);
@ -450,8 +456,11 @@ BI.IntervalSlider = BI.inherit(BI.Widget, {
},
setValue: function (v) {
var o = this.options;
var valueOne = BI.parseFloat(v.min);
var valueTwo = BI.parseFloat(v.max);
valueOne = o.digit === false ? valueOne : valueOne.toFixed(o.digit);
valueTwo = o.digit === false ? valueTwo : valueTwo.toFixed(o.digit);
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
this.valueOne = valueOne;

205
src/widget/singleslider/button/editor.sign.text.js

@ -0,0 +1,205 @@
/**
* Created by User on 2017/11/16.
*/
BI.SignTextEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.SignTextEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
hgap: 4,
vgap: 2,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn,
allowBlank: true,
watermark: "",
errorText: "",
value: "",
text: "",
height: 24
})
},
_init: function () {
BI.SignTextEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.editor",
height: o.height,
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
});
this.text = BI.createWidget({
type: "bi.text_button",
cls: "sign-editor-text",
title: o.title,
warningTitle: o.warningTitle,
tipType: o.tipType,
textAlign: "left",
height: o.height,
hgap: 4,
handler: function () {
self._showInput();
self.editor.focus();
self.editor.selectAll();
}
});
this.text.on(BI.TextButton.EVENT_CHANGE, function () {
BI.nextTick(function () {
self.fireEvent(BI.SignTextEditor.EVENT_CLICK_LABEL)
});
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
self._showHint();
self._checkText();
self.fireEvent(BI.SignTextEditor.EVENT_CONFIRM, arguments);
});
this.editor.on(BI.Editor.EVENT_ERROR, function () {
self._checkText();
});
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
});
this._showHint();
self._checkText();
},
_checkText: function () {
var o = this.options;
BI.nextTick(BI.bind(function () {
if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark");
} else {
var v = this.editor.getValue();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
this.text.element.removeClass("bi-water-mark");
}
}, this));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
setTitle: function (title) {
this.text.setTitle(title);
},
setWarningTitle: function (title) {
this.text.setWarningTitle(title);
},
focus: function () {
this._showInput();
this.editor.focus();
},
blur: function () {
this.editor.blur();
this._showHint();
this._checkText();
},
doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
isValid: function () {
return this.editor.isValid();
},
setErrorText: function (text) {
this.editor.setErrorText(text);
},
getErrorText: function () {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) {
this.editor.setValue(v);
this._checkText();
},
getValue: function () {
return this.editor.getValue();
},
getState: function () {
return this.text.getValue();
},
setState: function (v) {
var o = this.options;
this._showHint();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
this.text.setValue(v);
}
});
BI.SignTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.sign_text_editor", BI.SignTextEditor);

6
src/widget/singleslider/singleslider.js

@ -13,7 +13,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track",
digit: false
digit: false,
unit: ""
});
},
_init: function () {
@ -73,9 +74,10 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}
});
this.label = BI.createWidget({
type: "bi.sign_editor",
type: "bi.sign_text_editor",
cls: "slider-editor-button",
errorText: "",
text: o.unit,
width: c.EDITOR_WIDTH - 2,
allowBlank: false,
validationChecker: function (v) {

Loading…
Cancel
Save