1 | define([ |
---|
2 | "dojo/_base/declare", |
---|
3 | "dojo/_base/lang", |
---|
4 | "dojo/on", |
---|
5 | "dojox/calendar/Calendar", |
---|
6 | "dojox/calendar/MonthColumnView", |
---|
7 | "dojox/calendar/VerticalRenderer", |
---|
8 | "dojox/calendar/Mouse", |
---|
9 | "dojox/calendar/Keyboard", |
---|
10 | "dojo/text!./CalendarMonthColumn.html"], |
---|
11 | |
---|
12 | function( |
---|
13 | declare, |
---|
14 | lang, |
---|
15 | on, |
---|
16 | Calendar, |
---|
17 | MonthColumnView, |
---|
18 | VerticalRenderer, |
---|
19 | Mouse, |
---|
20 | Keyboard, |
---|
21 | template){ |
---|
22 | |
---|
23 | return declare("demo.ExtendedCalendar", Calendar, { |
---|
24 | |
---|
25 | // summary: |
---|
26 | // A Calendar subclass that embeds a month column view. |
---|
27 | |
---|
28 | templateString: template, |
---|
29 | |
---|
30 | verticalRenderer: VerticalRenderer, |
---|
31 | |
---|
32 | _createDefaultViews: function(){ |
---|
33 | this.inherited(arguments); |
---|
34 | // create the month column view. |
---|
35 | this.monthColumnView = declare([MonthColumnView, Keyboard, Mouse])({ |
---|
36 | verticalRenderer: VerticalRenderer |
---|
37 | }); |
---|
38 | |
---|
39 | this.monthColumnView.on("columnHeaderClick", lang.hitch(this, function(e){ |
---|
40 | this.set("dateInterval", "month"); |
---|
41 | this.set("dateIntervalSteps", 1); |
---|
42 | this.set("date", e.date); |
---|
43 | })); |
---|
44 | |
---|
45 | return [this.columnView, this.matrixView, this.monthColumnView]; |
---|
46 | }, |
---|
47 | |
---|
48 | _computeCurrentView: function(startDate, endDate, duration){ |
---|
49 | // show the month column view if the duration is greater than 31x2 days |
---|
50 | if(duration>62){ |
---|
51 | return this.monthColumnView; |
---|
52 | }else{ |
---|
53 | return this.inherited(arguments); |
---|
54 | } |
---|
55 | }, |
---|
56 | |
---|
57 | _configureView: function(view, index, timeInterval, duration){ |
---|
58 | // show only from January to June or from July to December |
---|
59 | if(view.viewKind == "monthColumns"){ |
---|
60 | var m = timeInterval[0].getMonth(); |
---|
61 | var d = this.newDate(timeInterval[0]); |
---|
62 | d.setMonth(m<6?0:6); |
---|
63 | view.set("startDate", d); |
---|
64 | view.set("columnCount", 6); |
---|
65 | }else{ |
---|
66 | this.inherited(arguments); |
---|
67 | } |
---|
68 | }, |
---|
69 | |
---|
70 | configureButtons: function(){ |
---|
71 | // configure the 6 months button |
---|
72 | this.inherited(arguments); |
---|
73 | if(this.sixMonthButton){ |
---|
74 | // should set label from resource bundle here! |
---|
75 | this.own( |
---|
76 | on(this.sixMonthButton, "click", lang.hitch(this, function(){ |
---|
77 | this.set("dateIntervalSteps", 6); |
---|
78 | this.set("dateInterval", "month"); |
---|
79 | })) |
---|
80 | ); |
---|
81 | } |
---|
82 | }, |
---|
83 | |
---|
84 | matrixViewRowHeaderClick: function(e){ |
---|
85 | this.set("dateInterval", "week"); |
---|
86 | this.set("dateIntervalSteps", 1); |
---|
87 | this.set("date", e.date); |
---|
88 | } |
---|
89 | |
---|
90 | }); |
---|
91 | }); |
---|