forked from fanruan/fineui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.9 KiB
103 lines
2.9 KiB
8 years ago
|
/**
|
||
|
* 年份展示面板
|
||
|
*
|
||
|
* 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",
|
||
|
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",
|
||
|
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;
|
||
|
|
||
|
this.selectedYear = this._year = new Date().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,
|
||
|
logic: {
|
||
|
dynamic: true
|
||
|
},
|
||
|
tab: {
|
||
|
cls: "year-popup-navigation",
|
||
|
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);
|
||
|
});
|
||
|
},
|
||
|
|
||
|
getValue: function () {
|
||
|
return this.selectedYear;
|
||
|
},
|
||
|
|
||
|
setValue: function (v) {
|
||
|
var o = this.options;
|
||
|
if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) {
|
||
|
v = new Date().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";
|
||
|
$.shortcut("bi.year_popup", BI.YearPopup);
|