Browse Source

Merge pull request #134 in ~GUY/fineui from ~WINDY/fineui:master to master

* commit '0cc24fcea1342cf5c93d9cca9bbeb5fa3a47ee64':
  控件抽象
master
windy 7 years ago
parent
commit
9029269da9
  1. 138
      bi/widget.js
  2. 27
      demo/js/widget/filemanager/demo.file.manager.js
  3. 141
      dist/bundle.js
  4. 18
      dist/bundle.min.js
  5. 138
      dist/widget.js
  6. 100
      src/widget/finetuningnumbereditor/custom.finetuning.number.editor.js
  7. 47
      src/widget/finetuningnumbereditor/finetuning.number.editor.js

138
bi/widget.js

@ -5486,35 +5486,36 @@ BI.extend(BI.FileManagerNav, {
});
BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/**
* Created by User on 2017/9/5.
* Created by windy on 2017/3/13.
* 数值微调器
*/
BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomFineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
validationChecker: function () {return true;},
valueFormatter: function (v) {return v;},
value: 0,
validationChecker: function () {
return true;
},
errorText: ""
})
},
_init: function () {
BI.CustomFineTuningNumberEditor.superclass._init.apply(this, arguments);
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: o.value,
value: o.valueFormatter(o.value),
validationChecker: o.validationChecker,
errorText: o.errorText
});
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
o.value = this.getValue();
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
@ -5523,8 +5524,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
@ -5533,8 +5534,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
BI.createWidget({
type: "bi.htape",
@ -5561,8 +5562,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
//微调
_finetuning: function(add){
var v = BI.parseFloat(this.editor.getValue());
this.editor.setValue(v.add(add));
var v = BI.parseFloat(this.getValue());
this.setValue(v.add(add));
},
setUpEnable: function (v) {
@ -5574,113 +5575,18 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
},
getValue: function () {
return this.editor.getValue();
},
setValue: function (v) {
this.editor.setValue(v);
}
});
BI.CustomFineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomFineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_fine_tuning_number_editor", BI.CustomFineTuningNumberEditor);/**
* Created by windy on 2017/3/13.
* 数值微调器
*/
BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
value: -1
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: this._alertInEditorValue(o.value),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
}
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this._finetuning(0);
BI.createWidget({
type: "bi.htape",
element: this,
items: [this.editor, {
el: {
type: "bi.grid",
columns: 1,
rows: 2,
items: [{
column: 0,
row: 0,
el: this.topBtn
}, {
column: 0,
row: 1,
el: this.bottomBtn
}]
},
width: 23
}]
});
},
_alertOutEditorValue: function(v){
return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
},
_alertInEditorValue: function(v){
return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
},
//微调
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) > -1);
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
return this.options.value;
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
var o = this.options;
o.value = v;
this.editor.setValue(o.valueFormatter(v));
}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/**
* 交互行为布局
*

27
demo/js/widget/filemanager/demo.file.manager.js

@ -46,21 +46,26 @@ Demo.FileManager = BI.inherit(BI.Widget, {
lastModify: 1454316355142
}];
var filemanager = BI.createWidget({
type: "bi.file_manager",
items: items
type: "bi.fine_tuning_number_editor",
validationChecker: function (v) {
return BI.parseFloat(v) <= 100 && BI.parseFloat(v) >= 0
},
height: 24,
width: 150,
errorText: "hahah"
});
filemanager.on(BI.FineTuningNumberEditor.EVENT_CHANGE, function () {
if(BI.parseFloat(this.getValue()) < 1){
filemanager.setBottomEnable(false);
}else{
filemanager.setBottomEnable(true);
}
});
return {
type: "bi.vtape",
type: "bi.vertical",
items: [{
el: filemanager,
height: "fill"
}, {
type: "bi.button",
text: "getValue",
handler: function () {
BI.Msg.alert("", JSON.stringify(filemanager.getValue()));
},
height: 25
height: 24
}]
}
}

141
dist/bundle.js vendored

@ -28,7 +28,8 @@ BI.i18n = {
"BI-Load_More": "加载更多",
"BI-Select_All": "全选",
"BI-Basic_Auto": "自动",
"BI-No_More_Data": "无更多数据"
"BI-No_More_Data": "无更多数据",
"BI-No_Selected_Value": "没有可选项"
};/*!
* jQuery JavaScript Library v1.9.1
* http://jquery.com/
@ -82542,35 +82543,36 @@ BI.extend(BI.FileManagerNav, {
});
BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/**
* Created by User on 2017/9/5.
* Created by windy on 2017/3/13.
* 数值微调器
*/
BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomFineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
validationChecker: function () {return true;},
valueFormatter: function (v) {return v;},
value: 0,
validationChecker: function () {
return true;
},
errorText: ""
})
},
_init: function () {
BI.CustomFineTuningNumberEditor.superclass._init.apply(this, arguments);
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: o.value,
value: o.valueFormatter(o.value),
validationChecker: o.validationChecker,
errorText: o.errorText
});
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
o.value = this.getValue();
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
@ -82579,8 +82581,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
@ -82589,8 +82591,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
BI.createWidget({
type: "bi.htape",
@ -82617,8 +82619,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
//微调
_finetuning: function(add){
var v = BI.parseFloat(this.editor.getValue());
this.editor.setValue(v.add(add));
var v = BI.parseFloat(this.getValue());
this.setValue(v.add(add));
},
setUpEnable: function (v) {
@ -82630,113 +82632,18 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
},
getValue: function () {
return this.editor.getValue();
},
setValue: function (v) {
this.editor.setValue(v);
}
});
BI.CustomFineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomFineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_fine_tuning_number_editor", BI.CustomFineTuningNumberEditor);/**
* Created by windy on 2017/3/13.
* 数值微调器
*/
BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
value: -1
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: this._alertInEditorValue(o.value),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
}
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this._finetuning(0);
BI.createWidget({
type: "bi.htape",
element: this,
items: [this.editor, {
el: {
type: "bi.grid",
columns: 1,
rows: 2,
items: [{
column: 0,
row: 0,
el: this.topBtn
}, {
column: 0,
row: 1,
el: this.bottomBtn
}]
},
width: 23
}]
});
},
_alertOutEditorValue: function(v){
return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
},
_alertInEditorValue: function(v){
return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
},
//微调
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) > -1);
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
return this.options.value;
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
var o = this.options;
o.value = v;
this.editor.setValue(o.valueFormatter(v));
}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/**
* 交互行为布局
*

18
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

138
dist/widget.js vendored

@ -5486,35 +5486,36 @@ BI.extend(BI.FileManagerNav, {
});
BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/**
* Created by User on 2017/9/5.
* Created by windy on 2017/3/13.
* 数值微调器
*/
BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomFineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
validationChecker: function () {return true;},
valueFormatter: function (v) {return v;},
value: 0,
validationChecker: function () {
return true;
},
errorText: ""
})
},
_init: function () {
BI.CustomFineTuningNumberEditor.superclass._init.apply(this, arguments);
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: o.value,
value: o.valueFormatter(o.value),
validationChecker: o.validationChecker,
errorText: o.errorText
});
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
o.value = this.getValue();
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
@ -5523,8 +5524,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
@ -5533,8 +5534,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
BI.createWidget({
type: "bi.htape",
@ -5561,8 +5562,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
//微调
_finetuning: function(add){
var v = BI.parseFloat(this.editor.getValue());
this.editor.setValue(v.add(add));
var v = BI.parseFloat(this.getValue());
this.setValue(v.add(add));
},
setUpEnable: function (v) {
@ -5574,113 +5575,18 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
},
getValue: function () {
return this.editor.getValue();
},
setValue: function (v) {
this.editor.setValue(v);
}
});
BI.CustomFineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomFineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_fine_tuning_number_editor", BI.CustomFineTuningNumberEditor);/**
* Created by windy on 2017/3/13.
* 数值微调器
*/
BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
value: -1
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: this._alertInEditorValue(o.value),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
}
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this._finetuning(0);
BI.createWidget({
type: "bi.htape",
element: this,
items: [this.editor, {
el: {
type: "bi.grid",
columns: 1,
rows: 2,
items: [{
column: 0,
row: 0,
el: this.topBtn
}, {
column: 0,
row: 1,
el: this.bottomBtn
}]
},
width: 23
}]
});
},
_alertOutEditorValue: function(v){
return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
},
_alertInEditorValue: function(v){
return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
},
//微调
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) > -1);
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
return this.options.value;
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
var o = this.options;
o.value = v;
this.editor.setValue(o.valueFormatter(v));
}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/**
* 交互行为布局
*

100
src/widget/finetuningnumbereditor/custom.finetuning.number.editor.js

@ -1,100 +0,0 @@
/**
* Created by User on 2017/9/5.
*/
BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomFineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
value: 0,
validationChecker: function () {
return true;
},
errorText: ""
})
},
_init: function () {
BI.CustomFineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: o.value,
validationChecker: o.validationChecker,
errorText: o.errorText
});
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
trigger: "lclick,",
cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM);
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [this.editor, {
el: {
type: "bi.grid",
columns: 1,
rows: 2,
items: [{
column: 0,
row: 0,
el: this.topBtn
}, {
column: 0,
row: 1,
el: this.bottomBtn
}]
},
width: 23
}]
});
},
//微调
_finetuning: function(add){
var v = BI.parseFloat(this.editor.getValue());
this.editor.setValue(v.add(add));
},
setUpEnable: function (v) {
this.topBtn.setEnable(!!v);
},
setBottomEnable: function (v) {
this.bottomBtn.setEnable(!!v);
},
getValue: function () {
return this.editor.getValue();
},
setValue: function (v) {
this.editor.setValue(v);
}
});
BI.CustomFineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomFineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_fine_tuning_number_editor", BI.CustomFineTuningNumberEditor);

47
src/widget/finetuningnumbereditor/finetuning.number.editor.js

@ -6,7 +6,10 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
value: -1
validationChecker: function () {return true;},
valueFormatter: function (v) {return v;},
value: 0,
errorText: ""
})
},
@ -16,14 +19,15 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
value: this._alertInEditorValue(o.value),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1;
}
value: o.valueFormatter(o.value),
validationChecker: o.validationChecker,
errorText: o.errorText
});
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () {
o.value = this.getValue();
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
@ -33,6 +37,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
@ -42,9 +47,9 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
});
this._finetuning(0);
BI.createWidget({
type: "bi.htape",
element: this,
@ -68,31 +73,31 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
});
},
_alertOutEditorValue: function(v){
return v === BI.i18nText("BI-Basic_Auto") ? -1 : v;
//微调
_finetuning: function(add){
var v = BI.parseFloat(this.getValue());
this.setValue(v.add(add));
},
_alertInEditorValue: function(v){
return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v;
setUpEnable: function (v) {
this.topBtn.setEnable(!!v);
},
//微调
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) > -1);
setBottomEnable: function (v) {
this.bottomBtn.setEnable(!!v);
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
return this.options.value;
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
var o = this.options;
o.value = v;
this.editor.setValue(o.valueFormatter(v));
}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);
Loading…
Cancel
Save