/** * Created by GUY on 2015/9/7. * @class BI.DateCalendarPopup * @extends BI.Widget */ BI.DateCalendarPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { var conf = BI.DateCalendarPopup.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.DateCalendarPopup.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.element, logic: { dynamic: true }, type: "bi.navigation", tab: this.datePicker, cardCreator: BI.bind(this._createNav, this), afterCardCreated: function () { }, afterCardShow: function () { this.setValue(self.selectedTime); } }); 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.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);