| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"./_CalendarView", |
| 4 |
"dijit/_TemplatedMixin", |
| 5 |
"dojo/date", |
| 6 |
"dojo/dom-class", |
| 7 |
"dojo/_base/event", |
| 8 |
"dojo/text!./Calendar/CalendarYear.html", |
| 9 |
"./_CalendarMonthYearView" |
| 10 |
], function(declare, _CalendarView, _TemplatedMixin, dojoDate, domClass, event, template, _CalendarMonthYearView){ |
| 11 |
return declare("dojox.widget._CalendarYearView", [_CalendarView, _TemplatedMixin], { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
templateString: template, |
| 18 |
|
| 19 |
displayedYears: 6, |
| 20 |
|
| 21 |
postCreate: function(){ |
| 22 |
|
| 23 |
|
| 24 |
this.cloneClass(".dojoxCalendarYearTemplate", 3); |
| 25 |
this.cloneClass(".dojoxCalendarYearGroupTemplate", 2); |
| 26 |
this._populateYears(); |
| 27 |
this.addFx(".dojoxCalendarYearLabel", this.domNode); |
| 28 |
}, |
| 29 |
|
| 30 |
_setValueAttr: function(value){ |
| 31 |
this._populateYears(value.getFullYear()); |
| 32 |
}, |
| 33 |
|
| 34 |
_populateYears: _CalendarMonthYearView.prototype._populateYears, |
| 35 |
|
| 36 |
adjustDate: function(date, amount){ |
| 37 |
|
| 38 |
|
| 39 |
return dojoDate.add(date, "year", amount * 12); |
| 40 |
}, |
| 41 |
|
| 42 |
onClick: function(evt){ |
| 43 |
|
| 44 |
|
| 45 |
if(!domClass.contains(evt.target, "dojoxCalendarYearLabel")){event.stop(evt); return;} |
| 46 |
var year = Number(evt.target.innerHTML); |
| 47 |
var date = this.get("value"); |
| 48 |
date.setYear(year); |
| 49 |
this.onValueSelected(date, year); |
| 50 |
} |
| 51 |
}); |
| 52 |
}); |