forked from fanruan/fineui
16 changed files with 59304 additions and 308 deletions
@ -0,0 +1,44 @@ |
|||||||
|
/** |
||||||
|
* Created by Dailer on 2017/7/11. |
||||||
|
*/ |
||||||
|
Demo.Date = BI.inherit(BI.Widget, { |
||||||
|
props: { |
||||||
|
baseCls: "demo-date" |
||||||
|
}, |
||||||
|
|
||||||
|
_init: function () { |
||||||
|
Demo.Date.superclass._init.apply(this, arguments); |
||||||
|
}, |
||||||
|
|
||||||
|
render: function () { |
||||||
|
|
||||||
|
return { |
||||||
|
type: "bi.horizontal_auto", |
||||||
|
vgap: 10, |
||||||
|
items: [{ |
||||||
|
type: "bi.date_combo", |
||||||
|
width: 300 |
||||||
|
}, { |
||||||
|
type: "bi.date_picker", |
||||||
|
width: 300 |
||||||
|
}, { |
||||||
|
type: "bi.date_trigger", |
||||||
|
width: 300 |
||||||
|
}, { |
||||||
|
type: "bi.date_calendar_popup", |
||||||
|
width: 300 |
||||||
|
}, { |
||||||
|
type: "bi.date_triangle_trigger", |
||||||
|
width: 300 |
||||||
|
}, { |
||||||
|
type: "bi.calendar", |
||||||
|
logic: { |
||||||
|
dynamic: true |
||||||
|
}, |
||||||
|
width: 300 |
||||||
|
}] |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
BI.shortcut("demo.all_date_widget", Demo.Date); |
@ -0,0 +1,119 @@ |
|||||||
|
/** |
||||||
|
* Created by Dailer on 2017/7/18. |
||||||
|
*/ |
||||||
|
Demo.TestEditor = BI.inherit(BI.Widget, { |
||||||
|
props: { |
||||||
|
baseCls: "" |
||||||
|
}, |
||||||
|
render: function () { |
||||||
|
var editor = BI.createWidget({ |
||||||
|
type: "bi.sign_editor", |
||||||
|
cls: "bi-border", |
||||||
|
width: 90, |
||||||
|
height: 28, |
||||||
|
}); |
||||||
|
|
||||||
|
var test = BI.createWidget({ |
||||||
|
type: "bi.test_editor", |
||||||
|
// formatter: function (v) {
|
||||||
|
// return v + "%";
|
||||||
|
// },
|
||||||
|
value: 12, |
||||||
|
width: 90, |
||||||
|
height: 28, |
||||||
|
step: 1 |
||||||
|
}); |
||||||
|
|
||||||
|
var timetunning = BI.createWidget({ |
||||||
|
type: "bi.time_tunning", |
||||||
|
currentTime: { |
||||||
|
hour: 13, |
||||||
|
minute: 45, |
||||||
|
second: 50 |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
var dateTimeCombo = BI.createWidget({ |
||||||
|
type: "bi.date_time_combo", |
||||||
|
width: 300 |
||||||
|
}); |
||||||
|
|
||||||
|
var enable = 1; |
||||||
|
|
||||||
|
return { |
||||||
|
type: "bi.horizontal_auto", |
||||||
|
items: [{ |
||||||
|
el: test |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: "bi.left", |
||||||
|
items: [{ |
||||||
|
el: editor |
||||||
|
}, { |
||||||
|
type: "bi.button", |
||||||
|
text: "设置step", |
||||||
|
width: 90, |
||||||
|
height: 28, |
||||||
|
handler: function () { |
||||||
|
test.setStep(editor.getValue()); |
||||||
|
BI.Msg.toast("设置成功") |
||||||
|
}, |
||||||
|
lgap: 5 |
||||||
|
}, { |
||||||
|
type: "bi.button", |
||||||
|
text: "toggle disabled", |
||||||
|
height: 28, |
||||||
|
handler: function () { |
||||||
|
enable *= -1; |
||||||
|
test.setEnable(Boolean(1 + enable)); |
||||||
|
BI.Msg.toast("设置成功") |
||||||
|
}, |
||||||
|
lgap: 20 |
||||||
|
}] |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: "bi.left", |
||||||
|
items: [ |
||||||
|
timetunning, |
||||||
|
{ |
||||||
|
type: "bi.label", |
||||||
|
text: "时间选择控件,自动进位与退位,返回数据自动对小于10的数补0", |
||||||
|
whiteSpace: "normal", |
||||||
|
cls: "layout-bg3", |
||||||
|
height: 50, |
||||||
|
width: 400, |
||||||
|
lgap: 10 |
||||||
|
} |
||||||
|
], |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: "bi.left", |
||||||
|
items: [{ |
||||||
|
type: "bi.button", |
||||||
|
text: "getCurrentTime", |
||||||
|
cls: "layout-bg1", |
||||||
|
handler: function () { |
||||||
|
BI.Msg.alert("JSON 形式", JSON.stringify(timetunning.getCurrentTime())); |
||||||
|
} |
||||||
|
}, { |
||||||
|
type: "bi.button", |
||||||
|
text: "getCurrentTimeStr", |
||||||
|
cls: "layout-bg1", |
||||||
|
handler: function () { |
||||||
|
BI.Msg.alert("字符串形式", timetunning.getCurrentTimeStr()); |
||||||
|
} |
||||||
|
}], |
||||||
|
hgap: 10 |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: "bi.left", |
||||||
|
items: [dateTimeCombo] |
||||||
|
} |
||||||
|
], |
||||||
|
vgap: 20, |
||||||
|
hgap: 10 |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
BI.shortcut("demo.test_editor", Demo.TestEditor); |
@ -0,0 +1,94 @@ |
|||||||
|
/** |
||||||
|
* Created by dailer on 2017/7/19. |
||||||
|
* 日期时间练习 |
||||||
|
*/ |
||||||
|
|
||||||
|
BI.DateTimeCombo = BI.inherit(BI.Widget, { |
||||||
|
_defaultConfig: function () { |
||||||
|
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), { |
||||||
|
baseCls: "bi-fine-tuning-number-editor bi-border", |
||||||
|
selectedTime: { |
||||||
|
year: 2017, |
||||||
|
month: 0, |
||||||
|
day: 1, |
||||||
|
hour: 0, |
||||||
|
minute: 0, |
||||||
|
second: 0 |
||||||
|
}, |
||||||
|
height: 30 |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
_init: function () { |
||||||
|
BI.DateCombo.superclass._init.apply(this, arguments); |
||||||
|
var self = this, |
||||||
|
o = this.options; |
||||||
|
|
||||||
|
this.trigger = BI.createWidget({ |
||||||
|
type: "bi.date_trigger" |
||||||
|
}); |
||||||
|
|
||||||
|
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { |
||||||
|
self.combo.toggle(); |
||||||
|
}); |
||||||
|
|
||||||
|
this.popup = BI.createWidget({ |
||||||
|
type: "bi.date_time_popup" |
||||||
|
}); |
||||||
|
|
||||||
|
this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { |
||||||
|
self.setValue(self.popup.getValue()); |
||||||
|
}); |
||||||
|
|
||||||
|
this.combo = BI.createWidget({ |
||||||
|
type: "bi.combo", |
||||||
|
toggle: false, |
||||||
|
element: this, |
||||||
|
isNeedAdjustHeight: false, |
||||||
|
isNeedAdjustWidth: false, |
||||||
|
el: this.trigger, |
||||||
|
popup: { |
||||||
|
width: 270, |
||||||
|
el: this.popup, |
||||||
|
stopPropagation: false |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
|
||||||
|
_reviseMinute: function () { |
||||||
|
this.m._finetuning(this.s.isNeedRevise); |
||||||
|
this._reviseHour(); |
||||||
|
}, |
||||||
|
|
||||||
|
_reviseHour: function () { |
||||||
|
this.h._finetuning(this.m.isNeedRevise); |
||||||
|
}, |
||||||
|
|
||||||
|
getCurrentTime: function () { |
||||||
|
return { |
||||||
|
hour: this.h.getValue(), |
||||||
|
minute: this.m.getValue(), |
||||||
|
second: this.s.getValue() |
||||||
|
}; |
||||||
|
}, |
||||||
|
|
||||||
|
_format: function (p) { |
||||||
|
return p < 10 ? ('0' + p) : p |
||||||
|
}, |
||||||
|
|
||||||
|
getCurrentTimeStr: function () { |
||||||
|
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue()) |
||||||
|
}, |
||||||
|
|
||||||
|
setStep: function (step) { |
||||||
|
this.step = step || this.step; |
||||||
|
}, |
||||||
|
|
||||||
|
setValue: function (v) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||||
|
BI.shortcut("bi.date_time_combo", BI.DateTimeCombo); |
@ -0,0 +1,123 @@ |
|||||||
|
/** |
||||||
|
* Created by GUY on 2015/9/7. |
||||||
|
* @class BI.DateCalendarPopup |
||||||
|
* @extends BI.Widget |
||||||
|
*/ |
||||||
|
BI.DateTimePopup = BI.inherit(BI.Widget, { |
||||||
|
_defaultConfig: function () { |
||||||
|
var conf = BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments); |
||||||
|
return BI.extend(conf, { |
||||||
|
baseCls: "bi-date-calendar-popup", |
||||||
|
min: '1900-01-01', //最小日期
|
||||||
|
max: '2099-12-31', //最大日期
|
||||||
|
selectedTime: null |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
_createNav: function (v) { |
||||||
|
var date = BI.Calendar.getDateJSONByPage(v); |
||||||
|
var calendar = BI.createWidget({ |
||||||
|
type: "bi.calendar", |
||||||
|
logic: { |
||||||
|
dynamic: true |
||||||
|
}, |
||||||
|
min: this.options.min, |
||||||
|
max: this.options.max, |
||||||
|
year: date.year, |
||||||
|
month: date.month, |
||||||
|
day: this.selectedTime.day |
||||||
|
}); |
||||||
|
return calendar |
||||||
|
}, |
||||||
|
|
||||||
|
_init: function () { |
||||||
|
BI.DateTimePopup.superclass._init.apply(this, arguments); |
||||||
|
var self = this, |
||||||
|
o = this.options; |
||||||
|
this.today = new Date(); |
||||||
|
this._year = this.today.getFullYear(); |
||||||
|
this._month = this.today.getMonth(); |
||||||
|
this._day = this.today.getDate(); |
||||||
|
|
||||||
|
this.selectedTime = o.selectedTime || { |
||||||
|
year: this._year, |
||||||
|
month: this._month, |
||||||
|
day: this._day |
||||||
|
}; |
||||||
|
this.datePicker = BI.createWidget({ |
||||||
|
type: "bi.date_picker", |
||||||
|
min: o.min, |
||||||
|
max: o.max |
||||||
|
}); |
||||||
|
|
||||||
|
this.calendar = BI.createWidget({ |
||||||
|
direction: "top", |
||||||
|
// element: this,
|
||||||
|
logic: { |
||||||
|
dynamic: true |
||||||
|
}, |
||||||
|
type: "bi.navigation", |
||||||
|
tab: this.datePicker, |
||||||
|
cardCreator: BI.bind(this._createNav, this), |
||||||
|
|
||||||
|
afterCardCreated: function () { |
||||||
|
|
||||||
|
}, |
||||||
|
|
||||||
|
afterCardShow: function () { |
||||||
|
this.setValue(self.selectedTime); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
this.timeTunning = BI.createWidget({ |
||||||
|
type: "bi.time_tunning" |
||||||
|
}); |
||||||
|
|
||||||
|
this.buttons = BI.createWidget({ |
||||||
|
type: "bi.button_group", |
||||||
|
items: [{ |
||||||
|
type: "bi.text_button", |
||||||
|
text: BI.i18nText('BI-Basic_Clears') |
||||||
|
}, { |
||||||
|
type: "bi.text_button", |
||||||
|
text: BI.i18nText("BI-Basic_Sure") |
||||||
|
}], |
||||||
|
chooseType: 0, |
||||||
|
behaviors: {}, |
||||||
|
layouts: [{ |
||||||
|
type: "bi.center_adapt" |
||||||
|
}] |
||||||
|
}); |
||||||
|
|
||||||
|
this.dateTime = BI.createWidget({ |
||||||
|
type: "bi.vertical", |
||||||
|
element: this, |
||||||
|
items: [this.calendar, this.timeTunning, this.buttons] |
||||||
|
}); |
||||||
|
|
||||||
|
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { |
||||||
|
self.selectedTime = self.datePicker.getValue(); |
||||||
|
self.selectedTime.day = 1; |
||||||
|
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); |
||||||
|
}); |
||||||
|
|
||||||
|
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { |
||||||
|
self.selectedTime = self.calendar.getValue(); |
||||||
|
self.setValue(self.selectedTime); |
||||||
|
self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); |
||||||
|
}); |
||||||
|
}, |
||||||
|
|
||||||
|
setValue: function (timeOb) { |
||||||
|
this.datePicker.setValue(timeOb); |
||||||
|
this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); |
||||||
|
this.calendar.setValue(timeOb); |
||||||
|
this.selectedTime = timeOb; |
||||||
|
}, |
||||||
|
|
||||||
|
getValue: function () { |
||||||
|
return this.selectedTime; |
||||||
|
} |
||||||
|
}); |
||||||
|
BI.DateTimePopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
BI.shortcut("bi.date_time_popup", BI.DateTimePopup); |
@ -0,0 +1,154 @@ |
|||||||
|
/** |
||||||
|
* Created by dailer on 2017/7/19. |
||||||
|
* 时间微调器练习 |
||||||
|
*/ |
||||||
|
|
||||||
|
BI.TimeTuning = BI.inherit(BI.Widget, { |
||||||
|
_defaultConfig: function () { |
||||||
|
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), { |
||||||
|
baseCls: "bi-fine-tuning-number-editor bi-border", |
||||||
|
disabled: false, |
||||||
|
currentTime: { |
||||||
|
hour: 0, |
||||||
|
minute: 0, |
||||||
|
second: 0 |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
_init: function () { |
||||||
|
BI.TimeTuning.superclass._init.apply(this, arguments); |
||||||
|
var self = this, |
||||||
|
o = this.options; |
||||||
|
if (o.formatter == BI.emptyFn) { |
||||||
|
this.formatter = function (v) { |
||||||
|
return v; |
||||||
|
} |
||||||
|
} else { |
||||||
|
this.formatter = o.formatter; |
||||||
|
} |
||||||
|
|
||||||
|
this.parser = o.parser; |
||||||
|
this.step = o.step; |
||||||
|
this.min = o.min; |
||||||
|
this.max = o.max; |
||||||
|
this.currentTime = BI.deepClone(o.currentTime); |
||||||
|
this.last = { |
||||||
|
lastH: o.currentTime.hour, |
||||||
|
lastM: o.currentTime.minute, |
||||||
|
lastS: o.currentTime.second |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//时
|
||||||
|
this.h = BI.createWidget({ |
||||||
|
type: "bi.test_editor", |
||||||
|
value: this.currentTime.hour, |
||||||
|
min: 0, |
||||||
|
max: 23, |
||||||
|
width: 60, |
||||||
|
height: 30 |
||||||
|
}); |
||||||
|
this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {}); |
||||||
|
|
||||||
|
//分
|
||||||
|
this.m = BI.createWidget({ |
||||||
|
type: "bi.test_editor", |
||||||
|
value: this.currentTime.minute, |
||||||
|
min: 0, |
||||||
|
max: 59, |
||||||
|
width: 60, |
||||||
|
height: 30 |
||||||
|
}) |
||||||
|
this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { |
||||||
|
self._reviseHour(); |
||||||
|
}); |
||||||
|
|
||||||
|
//秒
|
||||||
|
this.s = BI.createWidget({ |
||||||
|
type: "bi.test_editor", |
||||||
|
value: this.currentTime.second, |
||||||
|
min: 0, |
||||||
|
max: 59, |
||||||
|
width: 60, |
||||||
|
height: 30 |
||||||
|
}) |
||||||
|
this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { |
||||||
|
self._reviseMinute(); |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.editor = BI.createWidget({ |
||||||
|
type: "bi.horizontal", |
||||||
|
items: [{ |
||||||
|
type: "bi.label", |
||||||
|
text: "时间", |
||||||
|
width: 45, |
||||||
|
height: 30 |
||||||
|
}, |
||||||
|
this.h, |
||||||
|
{ |
||||||
|
type: "bi.text", |
||||||
|
text: ":", |
||||||
|
textAlign: "center", |
||||||
|
width: 15 |
||||||
|
}, |
||||||
|
this.m, |
||||||
|
{ |
||||||
|
type: "bi.text", |
||||||
|
text: ":", |
||||||
|
textAlign: "center", |
||||||
|
width: 15 |
||||||
|
}, |
||||||
|
this.s |
||||||
|
] |
||||||
|
}); |
||||||
|
|
||||||
|
BI.createWidget({ |
||||||
|
type: "bi.htape", |
||||||
|
cls: "bi-border demo-clolor", |
||||||
|
element: this, |
||||||
|
items: [this.editor], |
||||||
|
width: 270, |
||||||
|
height: 50 |
||||||
|
}); |
||||||
|
}, |
||||||
|
|
||||||
|
_reviseMinute: function () { |
||||||
|
this.m._finetuning(this.s.isNeedRevise); |
||||||
|
this._reviseHour(); |
||||||
|
}, |
||||||
|
|
||||||
|
_reviseHour: function () { |
||||||
|
this.h._finetuning(this.m.isNeedRevise); |
||||||
|
}, |
||||||
|
|
||||||
|
getCurrentTime: function () { |
||||||
|
return { |
||||||
|
hour: this.h.getValue(), |
||||||
|
minute: this.m.getValue(), |
||||||
|
second: this.s.getValue() |
||||||
|
}; |
||||||
|
}, |
||||||
|
|
||||||
|
_format: function (p) { |
||||||
|
return p < 10 ? ('0' + p) : p |
||||||
|
}, |
||||||
|
|
||||||
|
getCurrentTimeStr: function () { |
||||||
|
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue()) |
||||||
|
}, |
||||||
|
|
||||||
|
setStep: function (step) { |
||||||
|
this.step = step || this.step; |
||||||
|
}, |
||||||
|
|
||||||
|
setValue: function (v) { |
||||||
|
this.value = v; |
||||||
|
this.editor.setValue(); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
BI.TimeTuning.EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||||
|
BI.shortcut("bi.time_tunning", BI.TimeTuning); |
@ -0,0 +1,152 @@ |
|||||||
|
/** |
||||||
|
* Created by dailer on 2017/7/18. |
||||||
|
* 数值微调器练习 |
||||||
|
*/ |
||||||
|
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: 0, |
||||||
|
disabled: false, |
||||||
|
min: 0, |
||||||
|
max: 100000, |
||||||
|
step: 1, |
||||||
|
formatter: BI.emptyFn, |
||||||
|
parser: BI.emptyFn |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
_init: function () { |
||||||
|
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments); |
||||||
|
var self = this, |
||||||
|
o = this.options; |
||||||
|
if (o.formatter == BI.emptyFn) { |
||||||
|
this.formatter = function (v) { |
||||||
|
return v; |
||||||
|
} |
||||||
|
} else { |
||||||
|
this.formatter = o.formatter; |
||||||
|
} |
||||||
|
|
||||||
|
this.parser = o.parser; |
||||||
|
this.step = o.step; |
||||||
|
this.min = o.min; |
||||||
|
this.max = o.max; |
||||||
|
this.value = o.value; |
||||||
|
this.isNeedRevise = 0; |
||||||
|
|
||||||
|
this.editor = BI.createWidget({ |
||||||
|
type: "bi.sign_editor", |
||||||
|
value: o.value, |
||||||
|
errorText: BI.i18nText("BI-Please_Input_Natural_Number") |
||||||
|
}); |
||||||
|
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { |
||||||
|
self.setValue(self.editor.getValue()); |
||||||
|
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._isNeedRevise(); |
||||||
|
|
||||||
|
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: 30 |
||||||
|
}] |
||||||
|
}); |
||||||
|
}, |
||||||
|
|
||||||
|
//微调
|
||||||
|
_finetuning: function (add) { |
||||||
|
//窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法
|
||||||
|
var v = BI.parseFloat(this.editor.getValue()) * 1000000000000; |
||||||
|
var addend = add * this.step * 1000000000000; |
||||||
|
var result = (v + addend) / 1000000000000; |
||||||
|
|
||||||
|
if (result > this.max) { |
||||||
|
this.editor.setValue(this.formatter(this.min)); |
||||||
|
this.isNeedRevise = 1; |
||||||
|
this.value = this.min; |
||||||
|
return; |
||||||
|
} |
||||||
|
if (result < this.min) { |
||||||
|
this.editor.setValue(this.formatter(this.max)); |
||||||
|
this.isNeedRevise = -1; |
||||||
|
this.value = this.max; |
||||||
|
return; |
||||||
|
} |
||||||
|
this.value = result; |
||||||
|
this.isNeedRevise = 0; |
||||||
|
this.editor.setValue(this.formatter(result)); |
||||||
|
|
||||||
|
}, |
||||||
|
|
||||||
|
_isNeedRevise: function () { |
||||||
|
// console.log(this.editor.getValue() - this.value);
|
||||||
|
}, |
||||||
|
|
||||||
|
getMinAndMax: function () { |
||||||
|
return { |
||||||
|
min: this.min, |
||||||
|
max: this.max |
||||||
|
}; |
||||||
|
}, |
||||||
|
|
||||||
|
getStep: function () { |
||||||
|
return this.step; |
||||||
|
}, |
||||||
|
|
||||||
|
getValue: function () { |
||||||
|
return this.value; |
||||||
|
}, |
||||||
|
|
||||||
|
setStep: function (step) { |
||||||
|
this.step = step || this.step; |
||||||
|
}, |
||||||
|
|
||||||
|
setValue: function (v) { |
||||||
|
this.value = v; |
||||||
|
this.editor.setValue(this.formatter(v)); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||||
|
BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor); |
Loading…
Reference in new issue