|
|
|
/**
|
|
|
|
* 年份展示面板
|
|
|
|
*
|
|
|
|
* Created by GUY on 2015/9/2.
|
|
|
|
* @class BI.YearPopup
|
|
|
|
* @extends BI.Trigger
|
|
|
|
*/
|
|
|
|
BI.YearPopup = BI.inherit(BI.Widget, {
|
|
|
|
|
|
|
|
_defaultConfig: function () {
|
|
|
|
return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
|
|
|
|
baseCls: "bi-year-popup",
|
|
|
|
behaviors: {},
|
|
|
|
min: "1900-01-01", // 最小日期
|
|
|
|
max: "2099-12-31" // 最大日期
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_createYearCalendar: function (v) {
|
|
|
|
var o = this.options, y = this._year;
|
|
|
|
|
|
|
|
var calendar = BI.createWidget({
|
|
|
|
type: "bi.year_calendar",
|
|
|
|
behaviors: o.behaviors,
|
|
|
|
min: o.min,
|
|
|
|
max: o.max,
|
|
|
|
logic: {
|
|
|
|
dynamic: true
|
|
|
|
},
|
|
|
|
year: y + v * 12
|
|
|
|
});
|
|
|
|
calendar.setValue(this._year);
|
|
|
|
return calendar;
|
|
|
|
},
|
|
|
|
|
|
|
|
_init: function () {
|
|
|
|
BI.YearPopup.superclass._init.apply(this, arguments);
|
|
|
|
var self = this, o = this.options;
|
|
|
|
|
|
|
|
this.selectedYear = this._year = BI.getDate().getFullYear();
|
|
|
|
|
|
|
|
var backBtn = BI.createWidget({
|
|
|
|
type: "bi.icon_button",
|
|
|
|
cls: "pre-page-h-font",
|
|
|
|
width: 25,
|
|
|
|
height: 25,
|
|
|
|
value: -1
|
|
|
|
});
|
|
|
|
|
|
|
|
var preBtn = BI.createWidget({
|
|
|
|
type: "bi.icon_button",
|
|
|
|
cls: "next-page-h-font",
|
|
|
|
width: 25,
|
|
|
|
height: 25,
|
|
|
|
value: 1
|
|
|
|
});
|
|
|
|
|
|
|
|
this.navigation = BI.createWidget({
|
|
|
|
type: "bi.navigation",
|
|
|
|
element: this,
|
|
|
|
single: true,
|
|
|
|
logic: {
|
|
|
|
dynamic: true
|
|
|
|
},
|
|
|
|
tab: {
|
|
|
|
cls: "year-popup-navigation bi-high-light bi-border-top",
|
|
|
|
height: 25,
|
|
|
|
items: [backBtn, preBtn]
|
|
|
|
},
|
|
|
|
cardCreator: BI.bind(this._createYearCalendar, this),
|
|
|
|
|
|
|
|
afterCardShow: function () {
|
|
|
|
this.setValue(self.selectedYear);
|
|
|
|
var calendar = this.getSelectedCard();
|
|
|
|
backBtn.setEnable(!calendar.isFrontYear());
|
|
|
|
preBtn.setEnable(!calendar.isFinalYear());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
|
|
|
|
self.selectedYear = this.getValue();
|
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
|
|
|
|
self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
|
|
|
|
});
|
|
|
|
|
|
|
|
if(BI.isKey(o.value)){
|
|
|
|
this.setValue(o.value);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function () {
|
|
|
|
return this.selectedYear;
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (v) {
|
|
|
|
var o = this.options;
|
|
|
|
if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) {
|
|
|
|
v = BI.getDate().getFullYear();
|
|
|
|
this.selectedYear = "";
|
|
|
|
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
|
|
|
|
this.navigation.setValue("");
|
|
|
|
} else {
|
|
|
|
this.selectedYear = v;
|
|
|
|
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
|
|
|
|
this.navigation.setValue(v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
|
|
|
|
BI.shortcut("bi.year_popup", BI.YearPopup);
|