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 | // summary: |
---|
13 | // A Calendar view listing 12 years |
---|
14 | |
---|
15 | // templateString: String |
---|
16 | // The template to be used to construct the widget. |
---|
17 | templateString: template, |
---|
18 | |
---|
19 | displayedYears: 6, |
---|
20 | |
---|
21 | postCreate: function(){ |
---|
22 | // summary: |
---|
23 | // Constructs the view |
---|
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 | // summary: |
---|
38 | // Adjusts the value of a date. It moves it by 12 years each time. |
---|
39 | return dojoDate.add(date, "year", amount * 12); |
---|
40 | }, |
---|
41 | |
---|
42 | onClick: function(evt){ |
---|
43 | // summary: |
---|
44 | // Handles clicks on year values. |
---|
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 | }); |
---|