Browse Source

控件抽象

es6
windy 7 years ago
parent
commit
0cc24fcea1
  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.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** 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 () { _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", baseCls: "bi-fine-tuning-number-editor bi-border",
validationChecker: function () {return true;},
valueFormatter: function (v) {return v;},
value: 0, value: 0,
validationChecker: function () {
return true;
},
errorText: "" errorText: ""
}) })
}, },
_init: function () { _init: function () {
BI.CustomFineTuningNumberEditor.superclass._init.apply(this, arguments); BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
value: o.value, value: o.valueFormatter(o.value),
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
errorText: o.errorText errorText: o.errorText
}); });
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { 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(){ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.topBtn = BI.createWidget({ this.topBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
@ -5523,8 +5524,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1); self._finetuning(1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
@ -5533,8 +5534,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1); self._finetuning(-1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
@ -5561,8 +5562,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
//微调 //微调
_finetuning: function(add){ _finetuning: function(add){
var v = BI.parseFloat(this.editor.getValue()); var v = BI.parseFloat(this.getValue());
this.editor.setValue(v.add(add)); this.setValue(v.add(add));
}, },
setUpEnable: function (v) { setUpEnable: function (v) {
@ -5574,113 +5575,18 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
return this.editor.getValue(); return this.options.value;
},
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);
}, },
setValue: function (v) { setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v)); var o = this.options;
this._finetuning(0); o.value = v;
this.editor.setValue(o.valueFormatter(v));
} }
}); });
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/** 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 lastModify: 1454316355142
}]; }];
var filemanager = BI.createWidget({ var filemanager = BI.createWidget({
type: "bi.file_manager", type: "bi.fine_tuning_number_editor",
items: items 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 { return {
type: "bi.vtape", type: "bi.vertical",
items: [{ items: [{
el: filemanager, el: filemanager,
height: "fill" height: 24
}, {
type: "bi.button",
text: "getValue",
handler: function () {
BI.Msg.alert("", JSON.stringify(filemanager.getValue()));
},
height: 25
}] }]
} }
} }

141
dist/bundle.js vendored

@ -28,7 +28,8 @@ BI.i18n = {
"BI-Load_More": "加载更多", "BI-Load_More": "加载更多",
"BI-Select_All": "全选", "BI-Select_All": "全选",
"BI-Basic_Auto": "自动", "BI-Basic_Auto": "自动",
"BI-No_More_Data": "无更多数据" "BI-No_More_Data": "无更多数据",
"BI-No_Selected_Value": "没有可选项"
};/*! };/*!
* jQuery JavaScript Library v1.9.1 * jQuery JavaScript Library v1.9.1
* http://jquery.com/ * http://jquery.com/
@ -82542,35 +82543,36 @@ BI.extend(BI.FileManagerNav, {
}); });
BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** 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 () { _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", baseCls: "bi-fine-tuning-number-editor bi-border",
validationChecker: function () {return true;},
valueFormatter: function (v) {return v;},
value: 0, value: 0,
validationChecker: function () {
return true;
},
errorText: "" errorText: ""
}) })
}, },
_init: function () { _init: function () {
BI.CustomFineTuningNumberEditor.superclass._init.apply(this, arguments); BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
value: o.value, value: o.valueFormatter(o.value),
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
errorText: o.errorText errorText: o.errorText
}); });
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { 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(){ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.topBtn = BI.createWidget({ this.topBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
@ -82579,8 +82581,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1); self._finetuning(1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
@ -82589,8 +82591,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1); self._finetuning(-1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
@ -82617,8 +82619,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
//微调 //微调
_finetuning: function(add){ _finetuning: function(add){
var v = BI.parseFloat(this.editor.getValue()); var v = BI.parseFloat(this.getValue());
this.editor.setValue(v.add(add)); this.setValue(v.add(add));
}, },
setUpEnable: function (v) { setUpEnable: function (v) {
@ -82630,113 +82632,18 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
return this.editor.getValue(); return this.options.value;
},
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);
}, },
setValue: function (v) { setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v)); var o = this.options;
this._finetuning(0); o.value = v;
this.editor.setValue(o.valueFormatter(v));
} }
}); });
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/** 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.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE";
BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** 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 () { _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", baseCls: "bi-fine-tuning-number-editor bi-border",
validationChecker: function () {return true;},
valueFormatter: function (v) {return v;},
value: 0, value: 0,
validationChecker: function () {
return true;
},
errorText: "" errorText: ""
}) })
}, },
_init: function () { _init: function () {
BI.CustomFineTuningNumberEditor.superclass._init.apply(this, arguments); BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
value: o.value, value: o.valueFormatter(o.value),
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
errorText: o.errorText errorText: o.errorText
}); });
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { 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(){ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.topBtn = BI.createWidget({ this.topBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
@ -5523,8 +5524,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1); self._finetuning(1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
@ -5533,8 +5534,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1); self._finetuning(-1);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CHANGE); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.CustomFineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
@ -5561,8 +5562,8 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
//微调 //微调
_finetuning: function(add){ _finetuning: function(add){
var v = BI.parseFloat(this.editor.getValue()); var v = BI.parseFloat(this.getValue());
this.editor.setValue(v.add(add)); this.setValue(v.add(add));
}, },
setUpEnable: function (v) { setUpEnable: function (v) {
@ -5574,113 +5575,18 @@ BI.CustomFineTuningNumberEditor = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
return this.editor.getValue(); return this.options.value;
},
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);
}, },
setValue: function (v) { setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v)); var o = this.options;
this._finetuning(0); o.value = v;
this.editor.setValue(o.valueFormatter(v));
} }
}); });
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/** 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 () { _defaultConfig: function () {
return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border", 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({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
value: this._alertInEditorValue(o.value), value: o.valueFormatter(o.value),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"), validationChecker: o.validationChecker,
validationChecker: function(v){ errorText: o.errorText
return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1; });
} 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(){ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.topBtn = BI.createWidget({ this.topBtn = BI.createWidget({
@ -33,6 +37,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1); self._finetuning(1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = BI.createWidget({
@ -42,9 +47,9 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1); self._finetuning(-1);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CHANGE);
self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM);
}); });
this._finetuning(0);
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
element: this, 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){ setUpEnable: function (v) {
return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v; this.topBtn.setEnable(!!v);
}, },
//微调 setBottomEnable: function (v) {
_finetuning: function(add){ this.bottomBtn.setEnable(!!v);
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) > -1);
}, },
getValue: function () { getValue: function () {
var v = this.editor.getValue(); return this.options.value;
return this._alertOutEditorValue(v);
}, },
setValue: function (v) { setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v)); var o = this.options;
this._finetuning(0); o.value = v;
this.editor.setValue(o.valueFormatter(v));
} }
}); });
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.FineTuningNumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor); BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);
Loading…
Cancel
Save