Debian Codegraph @

dojox/calendar/MatrixView.js

raw symbols SCIP
1 define([
2 "dojo/_base/declare",
3 "dojo/_base/array",
4 "dojo/_base/event",
5 "dojo/_base/lang",
6 "dojo/_base/sniff",
7 "dojo/_base/fx",
8 "dojo/_base/html",
9 "dojo/on",
10 "dojo/dom",
11 "dojo/dom-class",
12 "dojo/dom-style",
13 "dojo/dom-geometry",
14 "dojo/dom-construct",
15 "dojo/query",
16 "dojo/i18n",
17 "./ViewBase",
18 "dojo/text!./templates/MatrixView.html",
19 "dijit/_TemplatedMixin"],
20
21 function(
22 declare,
23 arr,
24 event,
25 lang,
26 has,
27 fx,
28 html,
29 on,
30 dom,
31 domClass,
32 domStyle,
33 domGeometry,
34 domConstruct,
35 query,
36 i18n,
37 ViewBase,
38 template,
39 _TemplatedMixin){
40
41 /*=====
42 var __HeaderClickEventArgs = {
43 // summary:
44 // A column click event.
45 // index: Integer
46 // The column index.
47 // date: Date
48 // The date displayed by the column.
49 // triggerEvent: Event
50 // The origin event.
51 };
52 =====*/
53
54 /*=====
55 var __ExpandRendererClickEventArgs = {
56 // summary:
57 // A expand renderer click event.
58 // columnIndex: Integer
59 // The column index of the cell.
60 // rowIndex: Integer
61 // The row index of the cell.
62 // date: Date
63 // The date displayed by the cell.
64 // triggerEvent: Event
65 // The origin event.
66 };
67 =====*/
68
69 return declare("dojox.calendar.MatrixView", [ViewBase, _TemplatedMixin], {
70
71 // summary:
72 // The matrix view is a calendar view that displaying a matrix where each cell is a day.
73
74 templateString: template,
75
76 baseClass: "dojoxCalendarMatrixView",
77
78 _setTabIndexAttr: "domNode",
79
80 // viewKind: String
81 // Type of the view. Used by the calendar widget to determine how to configure the view.
82 // This view kind is "matrix".
83 viewKind: "matrix",
84
85 // renderData: Object
86 // The render data object contains all the data needed to render the widget.
87 renderData: null,
88
89 // startDate: Date
90 // The start date of the time interval displayed.
91 // If not set at initialization time, will be set to current day.
92 startDate: null,
93
94 // refStartTime: Date?
95 // (Optional) Start of the time interval of interest.
96 // It is used to style differently the displayed rows out of the
97 // time interval of interest.
98 refStartTime: null,
99
100 // refStartTime: Date?
101 // (Optional) End of the time interval of interest.
102 // It is used to style differently the displayed rows out of the
103 // time interval of interest.
104 refEndTime: null,
105
106 // columnCount: Integer
107 // The number of column to display (from the startDate).
108 columnCount: 7,
109
110 // rowCount: Integer
111 // The number of rows to display (from the startDate).
112 rowCount: 5,
113
114 // horizontalRenderer: Class
115 // The class use to create horizontal renderers.
116 horizontalRenderer: null,
117
118 // labelRenderer: Class
119 // The class use to create label renderers.
120 labelRenderer: null,
121
122 // expandRenderer: Class
123 // The class use to create drill down renderers.
124 expandRenderer: null,
125
126 // expandRenderer: Class
127 // The class use to create horizontal decoration renderers.
128 horizontalDecorationRenderer: null,
129
130 // percentOverlap: Integer
131 // The percentage of the renderer width used to superimpose one item renderers on another
132 // when two events are overlapping. By default 0.
133 percentOverlap: 0,
134
135 // verticalGap: Integer
136 // The number of pixels between two item renderers that are overlapping each other if the percentOverlap property is 0.
137 verticalGap: 2,
138
139 // horizontalRendererHeight: Integer
140 // The height in pixels of the horizontal and label renderers that is applied by the layout.
141 horizontalRendererHeight: 17,
142
143 // horizontalRendererHeight: Integer
144 // The height in pixels of the horizontal and label renderers that is applied by the layout.
145 labelRendererHeight: 14,
146
147 // expandRendererHeight: Integer
148 // The height in pixels of the expand/collapse renderers that is applied by the layout.
149 expandRendererHeight: 15,
150
151 // cellPaddingTop: Integer
152 // The top offset in pixels of each cell applied by the layout.
153 cellPaddingTop: 16,
154
155 // expandDuration: Integer
156 // Duration of the animation when expanding or collapsing a row.
157 expandDuration: 300,
158
159 // expandEasing: Function
160 // Easing function of the animation when expanding or collapsing a row (null by default).
161 expandEasing: null,
162
163 // layoutDuringResize: Boolean
164 // Indicates if the item renderers' position and size is updated or if they are hidden during a resize of the widget.
165 layoutDuringResize: false,
166
167 // roundToDay: Boolean
168 // For horizontal renderers that are not filling entire days, whether fill the day or not.
169 roundToDay: true,
170
171 // showCellLabel: Boolean
172 // Whether display or not the grid cells label (usually the day of month).
173 showCellLabel: true,
174
175 // scrollable: [private] Boolean
176 scrollable: false,
177
178 // resizeCursor: [private] Boolean
179 resizeCursor: "e-resize",
180
181 constructor: function(){
182 this.invalidatingProperties =
183 ["columnCount", "rowCount", "startDate", "horizontalRenderer", "horizontalDecaorationRenderer",
184 "labelRenderer", "expandRenderer", "rowHeaderDatePattern", "columnHeaderLabelLength",
185 "cellHeaderShortPattern", "cellHeaderLongPattern", "percentOverlap", "verticalGap",
186 "horizontalRendererHeight", "labelRendererHeight", "expandRendererHeight", "cellPaddingTop",
187 "roundToDay", "itemToRendererKindFunc", "layoutPriorityFunction", "formatItemTimeFunc", "textDir", "items"];
188
189 this._ddRendererList = [];
190 this._ddRendererPool = [];
191 this._rowHeaderHandles = [];
192 },
193
194 destroy: function(preserveDom){
195 this._cleanupRowHeader();
196 this.inherited(arguments);
197 },
198
199 postCreate: function(){
200 this.inherited(arguments);
201 this._initialized = true;
202 if(!this.invalidRendering){
203 this.refreshRendering();
204 }
205 },
206
207 _createRenderData: function(){
208
209 var rd = {};
210
211 rd.dateLocaleModule = this.dateLocaleModule;
212 rd.dateClassObj = this.dateClassObj;
213 rd.dateModule = this.dateModule; // arithmetics on Dates
214
215 rd.dates = [];
216
217 rd.columnCount = this.get("columnCount");
218 rd.rowCount = this.get("rowCount");
219
220 rd.sheetHeight = this.itemContainer.offsetHeight;
221
222 this._computeRowsHeight(rd);
223
224 var d = this.get("startDate");
225
226 if(d == null){
227 d = new rd.dateClassObj();
228 }
229
230 d = this.floorToDay(d, false, rd);
231
232 this.startDate = d;
233
234 for(var row = 0; row < rd.rowCount ; row++){
235 rd.dates.push([]);
236 for(var col = 0; col < rd.columnCount ; col++){
237 rd.dates[row].push(d);
238 d = this.addAndFloor(d, "day", 1);
239 }
240 }
241
242 rd.startTime = this.newDate(rd.dates[0][0], rd);
243 rd.endTime = this.newDate(rd.dates[rd.rowCount-1][rd.columnCount-1], rd);
244 rd.endTime = rd.dateModule.add(rd.endTime, "day", 1);
245 rd.endTime = this.floorToDay(rd.endTime, true);
246
247 if(this.displayedItemsInvalidated && !this._isEditing){
248 // while editing in no live layout we must not to recompute items (duplicate renderers)
249 this.displayedItemsInvalidated = false;
250 this._computeVisibleItems(rd);
251
252 }else if(this.renderData){
253 rd.items = this.renderData.items;
254 }
255
256 if(this.displayedDecorationItemsInvalidated){
257 rd.decorationItems = this.decorationStoreManager._computeVisibleItems(rd);
258
259 }else if (this.renderData){
260 rd.decorationItems = this.renderData.decorationItems;
261 }
262
263 rd.rtl = !this.isLeftToRight();
264
265 return rd;
266 },
267
268 _validateProperties: function(){
269
270 this.inherited(arguments);
271
272 if(this.columnCount<1 || isNaN(this.columnCount)){
273 this.columnCount = 1;
274 }
275
276 if(this.rowCount<1 || isNaN(this.rowCount)){
277 this.rowCount = 1;
278 }
279
280 if(isNaN(this.percentOverlap) || this.percentOverlap < 0 || this.percentOverlap > 100){
281 this.percentOverlap = 0;
282 }
283
284 if(isNaN(this.verticalGap) || this.verticalGap < 0){
285 this.verticalGap = 2;
286 }
287
288 if(isNaN(this.horizontalRendererHeight) || this.horizontalRendererHeight < 1){
289 this.horizontalRendererHeight = 17;
290 }
291
292 if(isNaN(this.labelRendererHeight) || this.labelRendererHeight < 1){
293 this.labelRendererHeight = 14;
294 }
295
296 if(isNaN(this.expandRendererHeight) || this.expandRendererHeight < 1){
297 this.expandRendererHeight = 15;
298 }
299
300 },
301
302 _setStartDateAttr: function(value){
303 this.displayedItemsInvalidated = true;
304 this._set("startDate", value);
305 },
306
307 _setColumnCountAttr: function(value){
308 this.displayedItemsInvalidated = true;
309 this._set("columnCount", value);
310 },
311
312 _setRowCountAttr: function(value){
313 this.displayedItemsInvalidated = true;
314 this._set("rowCount", value);
315 },
316
317 __fixEvt:function(e){
318 e.sheet = "primary";
319 e.source = this;
320 return e;
321 },
322
323 //////////////////////////////////////////
324 //
325 // Formatting functions
326 //
327 //////////////////////////////////////////
328
329 _formatRowHeaderLabel: function(/*Date*/d){
330 // summary:
331 // Computes the row header label for the specified time of day.
332 // By default the getWeekNumberLabel() function is called.
333 // The rowHeaderDatePattern property can be used to set a
334 // custom date pattern to the formatter.
335 // d: Date
336 // The date to format
337 // tags:
338 // protected
339
340 if(this.rowHeaderDatePattern){
341 return this.renderData.dateLocaleModule.format(d, {
342 selector: 'date',
343 datePattern: this.rowHeaderDatePattern
344 });
345 }else{
346 return this.getWeekNumberLabel(d);
347 }
348
349 },
350
351 _formatColumnHeaderLabel: function(d){
352 // summary:
353 // Computes the column header label for the specified date.
354 // By default a formatter is used, optionally the <code>columnHeaderLabelLength</code>
355 // property can be used to specify the length of the string.
356 // d: Date
357 // The date to format
358 // tags:
359 // protected
360
361 return this.renderData.dateLocaleModule.getNames('days', this.columnHeaderLabelLength ? this.columnHeaderLabelLength : 'wide', 'standAlone')[d.getDay()];
362 },
363
364 // cellHeaderShortPattern: String
365 // Custom date/time pattern for grid cell label to override default one coming from the CLDR.
366 // See dojo/date/locale documentation for format string.
367 cellHeaderShortPattern: null,
368
369 // cellHeaderLongPattern: String
370 // Custom date/time pattern for grid cell label to override default one coming from the CLDR.
371 // The long pattern is used for the first day of month or the first displayed day of a month.
372 // See dojo/date/locale documentation for format string.
373 cellHeaderLongPattern: null,
374
375 _formatGridCellLabel: function(d, row, col){
376 // summary:
377 // Computes the column header label for the specified date.
378 // By default a formatter is used, optionally the <code>cellHeaderLongPattern</code> and <code>cellHeaderShortPattern</code>
379 // properties can be used to set a custom date pattern to the formatter.
380 // d: Date
381 // The date to format.
382 // row: Integer
383 // The row that displays the current date.
384 // col: Integer
385 // The column that displays the current date.
386 // tags:
387 // protected
388
389 var isFirstDayOfMonth = row == 0 && col == 0 || d.getDate() == 1;
390 var format, rb;
391 if(isFirstDayOfMonth){
392 if(this.cellHeaderLongPattern){
393 format = this.cellHeaderLongPattern;
394 }else{
395 rb = i18n.getLocalization("dojo.cldr", this._calendar);
396 format = rb["dateFormatItem-MMMd"];
397 }
398 }else{
399 if(this.cellHeaderShortPattern){
400 format = this.cellHeaderShortPattern;
401 }else{
402 rb = i18n.getLocalization("dojo.cldr", this._calendar);
403 format = rb["dateFormatItem-d"];
404 }
405 }
406 return this.renderData.dateLocaleModule.format(d, {
407 selector: 'date',
408 datePattern: format
409 });
410 },
411
412 ////////////////////////////////////////////
413 //
414 // HTML structure management
415 //
416 ///////////////////////////////////////////
417
418 refreshRendering: function(){
419 this.inherited(arguments);
420
421 if(!this.domNode){
422 return;
423 }
424
425 this._validateProperties();
426
427 var oldRd = this.renderData;
428 var rd = this.renderData = this._createRenderData();
429
430 this._createRendering(rd, oldRd);
431
432 this._layoutDecorationRenderers(rd);
433 this._layoutRenderers(rd);
434 },
435
436 _createRendering: function(renderData, oldRenderData){
437 // summary:
438 // Creates the HTML structure (grid, place holders, headers, etc)
439 // renderData: Object
440 // The new render data
441 // oldRenderData: Object
442 // The previous render data
443 // tags:
444 // private
445
446 if(renderData.rowHeight <= 0){
447 renderData.columnCount = 1;
448 renderData.rowCount = 1;
449 renderData.invalidRowHeight = true;
450 return;
451 }
452
453 if(oldRenderData){
454 // make sure to have correct rowCount
455 if(this.itemContainerTable){
456 var rows = query(".dojoxCalendarItemContainerRow", this.itemContainerTable);
457 oldRenderData.rowCount = rows.length;
458 }
459 }
460
461 this._buildColumnHeader(renderData, oldRenderData);
462 this._buildRowHeader(renderData, oldRenderData);
463 this._buildGrid(renderData, oldRenderData);
464 this._buildItemContainer(renderData, oldRenderData);
465
466 if(this.buttonContainer && this.owner != null && this.owner.currentView == this){
467 domStyle.set(this.buttonContainer, {"right":0, "left":0});
468 }
469 },
470
471 _buildColumnHeader: function(/*Object*/ renderData, /*Object*/oldRenderData){
472 // summary:
473 // Creates incrementally the HTML structure of the column header and configures its content.
474 //
475 // renderData:
476 // The render data to display.
477 //
478 // oldRenderData:
479 // The previously render data displayed, if any.
480 // tags:
481 // private
482 var table = this.columnHeaderTable;
483
484 if(!table){
485 return;
486 }
487
488 var count = renderData.columnCount - (oldRenderData ? oldRenderData.columnCount : 0);
489
490 if(has("ie") == 8){
491 // workaround Internet Explorer 8 bug.
492 // if on the table, width: 100% and table-layout: fixed are set
493 // and columns are removed, width of remaining columns is not
494 // recomputed: must rebuild all.
495 if(this._colTableSave == null){
496 this._colTableSave = lang.clone(table);
497 }else if(count < 0){
498 this.columnHeader.removeChild(table);
499 domConstruct.destroy(table);
500 table = lang.clone(this._colTableSave);
501 this.columnHeaderTable = table;
502 this.columnHeader.appendChild(table);
503 count = renderData.columnCount;
504 }
505
506 } // else incremental dom add/remove for real browsers.
507
508 var tbodies = query("tbody", table);
509 var trs = query("tr", table);
510 var tbody, tr, td;
511
512 if(tbodies.length == 1){
513 tbody = tbodies[0];
514 }else{
515 tbody = html.create("tbody", null, table);
516 }
517
518 if(trs.length == 1){
519 tr = trs[0];
520 }else{
521 tr = domConstruct.create("tr", null, tbody);
522 }
523
524 // Build HTML structure (incremental)
525 if(count > 0){ // creation
526 for(var i=0; i < count; i++){
527 td = domConstruct.create("td", null, tr);
528 }
529 }else{ // deletion
530 count = -count;
531 for(var i=0; i < count; i++){
532 tr.removeChild(tr.lastChild);
533 }
534 }
535
536 // fill & configure
537 query("td", table).forEach(function(td, i){
538 td.className = "";
539 var d = renderData.dates[0][i];
540 this._setText(td, this._formatColumnHeaderLabel(d));
541 if(i == 0){
542 domClass.add(td, "first-child");
543 }else if(i == this.renderData.columnCount-1){
544 domClass.add(td, "last-child");
545 }
546 this.styleColumnHeaderCell(td, d, renderData);
547 }, this);
548
549 if(this.yearColumnHeaderContent){
550 var d = renderData.dates[0][0];
551 this._setText(this.yearColumnHeaderContent, renderData.dateLocaleModule.format(d,
552 {selector: "date", datePattern:"yyyy"}));
553 }
554 },
555
556 styleColumnHeaderCell: function(node, date, renderData){
557 // summary:
558 // Styles the CSS classes to the node that displays a column header cell.
559 // By default this method is setting the "dojoxCalendarWeekend" if the day of week represents a weekend.
560 // node: Node
561 // The DOM node that displays the column in the grid.
562 // date: Date
563 // The date displayed by this column
564 // renderData: Object
565 // The render data.
566 // tags:
567 // protected
568
569 domClass.add(node, this._cssDays[date.getDay()]);
570
571 if(this.isWeekEnd(date)){
572 domClass.add(node, "dojoxCalendarWeekend");
573 }
574 },
575
576 _rowHeaderHandles: null,
577
578 _cleanupRowHeader: function(){
579 // tags:
580 // private
581
582 while(this._rowHeaderHandles.length > 0){
583 var list = this._rowHeaderHandles.pop();
584 while(list.length>0){
585 list.pop().remove();
586 }
587 }
588 },
589
590
591 _rowHeaderClick: function(e){
592 // tags:
593 // private
594
595 var index = query("td", this.rowHeaderTable).indexOf(e.currentTarget);
596 this._onRowHeaderClick({
597 index: index,
598 date: this.renderData.dates[index][0],
599 triggerEvent: e
600 });
601 },
602
603 _buildRowHeader: function(renderData, oldRenderData){
604
605 // summary:
606 // Creates incrementally the HTML structure of the row header and configures its content.
607 //
608 // renderData:
609 // The render data to display.
610 //
611 // oldRenderData:
612 // The previously render data displayed, if any.
613 // tags:
614 // private
615
616 var rowHeaderTable = this.rowHeaderTable;
617
618 if(!rowHeaderTable){
619 return;
620 }
621
622 var tbodies = query("tbody", rowHeaderTable);
623 var tbody, tr, td;
624
625 if(tbodies.length == 1){
626 tbody = tbodies[0];
627 }else{
628 tbody = domConstruct.create("tbody", null, rowHeaderTable);
629 }
630
631 var count = renderData.rowCount - (oldRenderData ? oldRenderData.rowCount : 0);
632
633 // Build HTML structure
634 if(count>0){ // creation
635 for(var i=0; i < count; i++){
636 tr = domConstruct.create("tr", null, tbody);
637 td = domConstruct.create("td", null, tr);
638
639 var h = [];
640
641 h.push(on(td, "click", lang.hitch(this, this._rowHeaderClick)));
642
643 if(!has("touch")){
644 h.push(on(td, "mousedown", function(e){
645 domClass.add(e.currentTarget, "Active");
646 }));
647
648 h.push(on(td, "mouseup", function(e){
649 domClass.remove(e.currentTarget, "Active");
650 }));
651
652 h.push(on(td, "mouseover", function(e){
653 domClass.add(e.currentTarget, "Hover");
654 }));
655
656 h.push(on(td, "mouseout", function(e){
657 domClass.remove(e.currentTarget, "Hover");
658 }));
659 }
660 this._rowHeaderHandles.push(h);
661 }
662 }else{
663 count = -count;
664 // deletion of existing nodes
665 for(var i=0; i < count; i++){
666 tbody.removeChild(tbody.lastChild);
667 var list = this._rowHeaderHandles.pop();
668 while(list.length>0){
669 list.pop().remove();
670 }
671 }
672 }
673
674 // fill labels
675
676 query("tr", rowHeaderTable).forEach(function(tr, i){
677
678 domStyle.set(tr, "height", this._getRowHeight(i) + "px");
679
680 var d = renderData.dates[i][0];
681
682 var td = query("td", tr)[0];
683 td.className = "";
684 if(i == 0){
685 domClass.add(td, "first-child");
686 }
687 if(i == this.renderData.rowCount-1){
688 domClass.add(td, "last-child");
689 }
690
691 this.styleRowHeaderCell(td, d, renderData);
692
693 this._setText(td, this._formatRowHeaderLabel(d));
694 }, this);
695
696 },
697
698 styleRowHeaderCell: function(node, date, renderData){
699 // summary:
700 // Styles the CSS classes to the node that displays a row header cell.
701 // By default this method is doing nothing.
702 // node: Node
703 // The DOM node that displays the column in the grid.
704 // date: Date
705 // The date in the week.
706 // renderData: Object
707 // The render data.
708 // tags:
709 // protected
710
711
712 },
713
714 _buildGrid: function (renderData, oldRenderData){
715 // summary:
716 // Creates incrementally the HTML structure of the grid and configures its content.
717 //
718 // renderData:
719 // The render data to display.
720 //
721 // oldRenderData:
722 // The previously render data displayed, if any.
723 // tags:
724 // private
725
726 var table = this.gridTable;
727
728 if(!table){
729 return;
730 }
731
732 var currentTR = query("tr", table);
733
734 var rowDiff = renderData.rowCount - currentTR.length;
735 var addRows = rowDiff > 0;
736
737 var colDiff = renderData.columnCount - (currentTR ? query("td", currentTR[0]).length : 0);
738
739 if(has("ie") == 8){
740 // workaround Internet Explorer 8 bug.
741 // if on the table, width: 100% and table-layout: fixed are set
742 // and columns are removed, width of remaining columns is not
743 // recomputed: must rebuild all.
744 if(this._gridTableSave == null){
745 this._gridTableSave = lang.clone(table);
746 }else if(colDiff < 0){
747 this.grid.removeChild(table);
748 domConstruct.destroy(table);
749 table = lang.clone(this._gridTableSave);
750 this.gridTable = table;
751 this.grid.appendChild(table);
752 colDiff = renderData.columnCount;
753 rowDiff = renderData.rowCount;
754 addRows = true;
755 }
756 }
757
758 var tbodies = query("tbody", table);
759 var tbody;
760
761 if(tbodies.length == 1){
762 tbody = tbodies[0];
763 }else{
764 tbody = domConstruct.create("tbody", null, table);
765 }
766
767 // Build rows HTML structure (incremental)
768 if(addRows){ // creation
769 for(var i=0; i<rowDiff; i++){
770 domConstruct.create("tr", null, tbody);
771 }
772 }else{ // deletion
773 rowDiff = -rowDiff;
774 for(var i=0; i<rowDiff; i++){
775 tbody.removeChild(tbody.lastChild);
776 }
777 }
778
779 var rowIndex = renderData.rowCount - rowDiff;
780
781 var addCols = addRows || colDiff >0;
782 colDiff = addCols ? colDiff : -colDiff;
783
784 query("tr", table).forEach(function(tr, i){
785
786 if(addCols){ // creation
787 var len = i >= rowIndex ? renderData.columnCount : colDiff;
788 for(var i=0; i<len; i++){
789 var td = domConstruct.create("td", null, tr);
790 domConstruct.create("span", null, td);
791 }
792 }else{ // deletion
793 for(var i=0; i<colDiff; i++){
794 tr.removeChild(tr.lastChild);
795 }
796 }
797 });
798
799 // Set the CSS classes
800
801 query("tr", table).forEach(function (tr, row){
802
803 domStyle.set(tr, "height", this._getRowHeight(row) + "px");
804
805 tr.className = "";
806 // compatibility layer for IE7 & 8 that does not support :first-child and :last-child pseudo selectors
807 if(row == 0){
808 domClass.add(tr, "first-child");
809 }
810 if(row == renderData.rowCount-1){
811 domClass.add(tr, "last-child");
812 }
813
814 query("td", tr).forEach(function (td, col){
815
816 td.className = "";
817
818 if(col == 0){
819 domClass.add(td, "first-child");
820 }
821
822 if(col == renderData.columnCount-1){
823 domClass.add(td, "last-child");
824 }
825
826 var d = renderData.dates[row][col];
827
828 var span = query("span", td)[0];
829 this._setText(span, this.showCellLabel ? this._formatGridCellLabel(d, row, col): null);
830
831 this.styleGridCell(td, d, renderData);
832 }, this);
833 }, this);
834
835 },
836
837 // styleGridCellFunc: Function
838 // Custom function to customize the appearance of a grid cell by installing custom CSS class on the node.
839 // The signature of the function must be the same then the styleGridCell one.
840 // By default the defaultStyleGridCell function is used.
841 styleGridCellFunc: null,
842
843 defaultStyleGridCell: function(node, date, renderData){
844 // summary:
845 // Styles the CSS classes to the node that displays a cell.
846 // By default this method is setting the following CSS classes:
847 // - "dojoxCalendarToday" class name if the date displayed is the current date,
848 // - "dojoxCalendarWeekend" if the date represents a weekend or
849 // - "dojoxCalendarDayDisabled" if the date is out of the [refStartTime, refEndTime] interval.
850 // - the CSS class corresponding of the displayed day of week ("Sun", "Mon" and so on).
851 // node: Node
852 // The DOM node that displays the cell in the grid.
853 // date: Date
854 // The date displayed by this cell.
855 // renderData: Object
856 // The render data.
857 // tags:
858 // protected
859
860 domClass.add(node, this._cssDays[date.getDay()]);
861
862 var cal = this.dateModule;
863 if(this.isToday(date)){
864 domClass.add(node, "dojoxCalendarToday");
865 }else if(this.refStartTime != null && this.refEndTime != null &&
866 (cal.compare(date, this.refEndTime) >= 0 ||
867 cal.compare(cal.add(date, "day", 1), this.refStartTime) <= 0)){
868 domClass.add(node, "dojoxCalendarDayDisabled");
869 }else if(this.isWeekEnd(date)){
870 domClass.add(node, "dojoxCalendarWeekend");
871 }
872 },
873
874 styleGridCell: function(node, date, renderData){
875 // summary:
876 // Styles the CSS classes to the node that displays a cell.
877 // Delegates to styleGridCellFunc if defined or defaultStyleGridCell otherwise.
878 // node: Node
879 // The DOM node that displays the cell in the grid.
880 // date: Date
881 // The date displayed by this cell.
882 // renderData: Object
883 // The render data.
884 // tags:
885 // protected
886 if(this.styleGridCellFunc){
887 this.styleGridCellFunc(node, date, renderData);
888 }else{
889 this.defaultStyleGridCell(node, date, renderData);
890 }
891 },
892
893 _buildItemContainer: function(renderData, oldRenderData){
894 // summary:
895 // Creates the HTML structure of the item container and configures its content.
896 //
897 // renderData:
898 // The render data to display.
899 //
900 // oldRenderData:
901 // The previously render data displayed, if any.
902 // tags:
903 // private
904
905 var table = this.itemContainerTable;
906
907 if(!table){
908 return;
909 }
910
911 var rows = [];
912
913 var count = renderData.rowCount - (oldRenderData ? oldRenderData.rowCount : 0)
914
915 if(has("ie") == 8){
916 // workaround Internet Explorer 8 bug.
917 // if on the table, width: 100% and table-layout: fixed are set
918 // and columns are removed, width of remaining columns is not
919 // recomputed: must rebuild all.
920 if(this._itemTableSave == null){
921 this._itemTableSave = lang.clone(table);
922 }else if(count < 0){
923 this.itemContainer.removeChild(table);
924 this._recycleItemRenderers(true);
925 this._recycleExpandRenderers(true);
926 domConstruct.destroy(table);
927 table = lang.clone(this._itemTableSave);
928 this.itemContainerTable = table;
929 this.itemContainer.appendChild(table);
930 count = renderData.columnCount;
931 }
932
933 } // else incremental dom add/remove for real browsers.
934
935 var tbodies = query("tbody", table);
936 var tbody, tr, td, div;
937
938 if(tbodies.length == 1){
939 tbody = tbodies[0];
940 }else{
941 tbody = domConstruct.create("tbody", null, table);
942 }
943
944 // Build HTML structure (incremental)
945 if(count>0){ // creation
946 for(var i=0; i < count; i++){
947 tr = domConstruct.create("tr", null, tbody);
948 domClass.add(tr, "dojoxCalendarItemContainerRow");
949 td = domConstruct.create("td", null, tr);
950 div = domConstruct.create("div", null, td);
951 domClass.add(div, "dojoxCalendarContainerRow");
952 }
953 }else{ // deletion
954 count = -count;
955 for(var i=0; i < count; i++){
956 tbody.removeChild(tbody.lastChild);
957 }
958 }
959
960 query(".dojoxCalendarItemContainerRow", table).forEach(function(tr, i){
961 domStyle.set(tr, "height", this._getRowHeight(i) + "px");
962 rows.push(tr.childNodes[0].childNodes[0]);
963 }, this);
964
965 renderData.cells = rows;
966 },
967
968 resize: function(changeSize){
969 this.inherited(arguments);
970 this._resizeHandler(null, false);
971 },
972
973 _resizeHandler: function(e, apply){
974 // summary:
975 // Refreshes and apply the row height according to the widget height.
976 // e: Event
977 // The resize event (optional)
978 // apply: Boolean
979 // Whether take into account the layoutDuringResize flag to relayout item while resizing or not.
980 // tags:
981 // private
982
983 var rd = this.renderData;
984
985 if(rd == null){
986 this.refreshRendering();
987 return;
988 }
989
990 if(rd.sheetHeight != this.itemContainer.offsetHeight){
991 // refresh values
992 rd.sheetHeight = this.itemContainer.offsetHeight;
993 var expRow = this.getExpandedRowIndex();
994 if(expRow == -1){
995 this._computeRowsHeight();
996 this._resizeRows();
997 }else{
998 this.expandRow(rd.expandedRow, rd.expandedRowCol, 0, null, true);
999 }
1000 if(rd.invalidRowHeight){
1001 // complete recompute
1002 delete rd.invalidRowHeight;
1003 this.renderData = null;
1004 this.displayedItemsInvalidated = true;
1005 this.refreshRendering();
1006 return;
1007 }
1008 }
1009
1010 if(this.layoutDuringResize || apply){
1011 // Use a time for FF (at least). In FF the cell size and position info are not ready yet.
1012 setTimeout(lang.hitch(this, function(){
1013 this._layoutRenderers(this.renderData);
1014 this._layoutDecorationRenderers(this.renderData);
1015 }), 20);
1016
1017 }else{
1018 domStyle.set(this.itemContainer, "opacity", 0);
1019 this._recycleItemRenderers();
1020 this._recycleExpandRenderers();
1021 if(this._resizeTimer != undefined){
1022 clearTimeout(this._resizeTimer);
1023 }
1024 this._resizeTimer = setTimeout(lang.hitch(this, function(){
1025 delete this._resizeTimer;
1026 this._resizeRowsImpl(this.itemContainer, "tr");
1027 this._layoutRenderers(this.renderData);
1028 this._layoutDecorationRenderers(this.renderData);
1029 if(this.resizeAnimationDuration == 0){
1030 domStyle.set(this.itemContainer, "opacity", 1);
1031 }else{
1032 fx.fadeIn({node:this.itemContainer, curve:[0, 1]}).play(this.resizeAnimationDuration);
1033 }
1034 }), 200);
1035 }
1036
1037 },
1038
1039 // resizeAnimationDuration: Integer
1040 // Duration, in milliseconds, of the fade animation showing the item renderers after a widget resize.
1041 resizeAnimationDuration: 0,
1042
1043 /////////////////////////////////////////////
1044 //
1045 // Row height management
1046 //
1047 //////////////////////////////////////////////
1048
1049 getExpandedRowIndex: function(){
1050 // summary:
1051 // Returns the index of the expanded row or -1 if there's no row expanded.
1052 return this.renderData.expandedRow == null ? -1 : this.renderData.expandedRow;
1053 },
1054
1055 collapseRow: function(duration, easing, apply){
1056 // summary:
1057 // Collapses the expanded row, if any.
1058 // duration: Integer
1059 // Duration in milliseconds of the optional animation.
1060 // easing: Function
1061 // Easing function of the optional animation.
1062
1063 var rd = this.renderData;
1064
1065 if(apply == undefined){
1066 apply = true;
1067 }
1068 if(duration == undefined){
1069 duration = this.expandDuration;
1070 }
1071
1072 if(rd && rd.expandedRow != null && rd.expandedRow != -1){
1073 if(apply && duration){
1074 var index = rd.expandedRow;
1075 var oldSize = rd.expandedRowHeight;
1076 delete rd.expandedRow;
1077 this._computeRowsHeight(rd);
1078 var size = this._getRowHeight(index);
1079 rd.expandedRow = index;
1080
1081 this._recycleExpandRenderers();
1082 this._recycleItemRenderers();
1083 domStyle.set(this.itemContainer, "display", "none");
1084
1085 this._expandAnimation = new fx.Animation({
1086 curve: [oldSize, size],
1087 duration: duration,
1088 easing: easing,
1089 onAnimate: lang.hitch(this, function(size) {
1090 this._expandRowImpl(Math.floor(size));
1091 }),
1092 onEnd: lang.hitch(this, function(size) {
1093 this._expandAnimation = null;
1094 this._collapseRowImpl(false);
1095 this._resizeRows();
1096 domStyle.set(this.itemContainer, "display", "block");
1097 setTimeout(lang.hitch(this, function(){
1098 this._layoutRenderers(rd);
1099 }), 100);
1100 this.onExpandAnimationEnd(false);
1101 })
1102 });
1103
1104 this._expandAnimation.play();
1105 }else{
1106 this._collapseRowImpl(apply);
1107 }
1108 }
1109 },
1110
1111 _collapseRowImpl: function(apply){
1112 // tags:
1113 // private
1114
1115 var rd = this.renderData;
1116 delete rd.expandedRow;
1117 delete rd.expandedRowHeight;
1118 this._computeRowsHeight(rd);
1119 if(apply == undefined || apply){
1120 this._resizeRows();
1121 this._layoutRenderers(rd);
1122 }
1123 },
1124
1125 expandRow: function(rowIndex, colIndex, duration, easing, apply){
1126 // summary:
1127 // Expands the specified row.
1128 // rowIndex: Integer
1129 // The index of the row to expand.
1130 // colIndex: Integer?
1131 // The column index of the expand renderer that triggers the action, optional.
1132 // duration: Integer?
1133 // Duration in milliseconds of the optional animation.
1134 // easing: Function?
1135 // Easing function of the optional animation.
1136
1137 var rd = this.renderData;
1138 if(!rd || rowIndex < 0 || rowIndex >= rd.rowCount){
1139 return -1;
1140 }
1141 if(colIndex == undefined || colIndex < 0 || colIndex >= rd.columnCount){
1142 colIndex = -1; // ignore invalid values
1143 }
1144 if(apply == undefined){
1145 apply = true;
1146 }
1147 if(duration == undefined){
1148 duration = this.expandDuration;
1149 }
1150 if(easing == undefined){
1151 easing = this.expandEasing;
1152 }
1153
1154 var oldSize = this._getRowHeight(rowIndex);
1155 var size = rd.sheetHeight - Math.ceil(this.cellPaddingTop * (rd.rowCount-1));
1156
1157 rd.expandedRow = rowIndex;
1158 rd.expandedRowCol = colIndex;
1159 rd.expandedRowHeight = size;
1160
1161 if(apply){
1162 if(duration){
1163 //debugger;
1164 this._recycleExpandRenderers();
1165 this._recycleItemRenderers();
1166 domStyle.set(this.itemContainer, "display", "none");
1167
1168 this._expandAnimation = new fx.Animation({
1169 curve: [oldSize, size],
1170 duration: duration,
1171 delay:50,
1172 easing: easing,
1173 onAnimate: lang.hitch(this, function(size) {
1174 this._expandRowImpl(Math.floor(size));
1175 }),
1176 onEnd: lang.hitch(this, function(){
1177 this._expandAnimation = null;
1178 domStyle.set(this.itemContainer, "display", "block");
1179 setTimeout(lang.hitch(this, function(){
1180 this._expandRowImpl(size, true);
1181 }), 100);
1182 this.onExpandAnimationEnd(true);
1183 })
1184 });
1185 this._expandAnimation.play();
1186 }else{
1187 this._expandRowImpl(size, true);
1188 }
1189 }
1190 },
1191
1192 _expandRowImpl: function(size, layout){
1193 // tags:
1194 // private
1195
1196 var rd = this.renderData;
1197 rd.expandedRowHeight = size;
1198 this._computeRowsHeight(rd, rd.sheetHeight-size);
1199 this._resizeRows();
1200 if(layout){
1201 this._layoutRenderers(rd);
1202 }
1203 },
1204
1205 onExpandAnimationEnd: function(expand){
1206 // summary:
1207 // Event dispatched at the end of an expand or collapse animation.
1208 // expand: Boolean
1209 // Whether the finished animation was an expand or a collapse animation.
1210 // tags:
1211 // callback
1212
1213 },
1214
1215 _resizeRows: function(){
1216 // summary:
1217 // Refreshes the height of the underlying HTML objects.
1218 // tags:
1219 // private
1220
1221 if(this._getRowHeight(0) <= 0){
1222 return;
1223 }
1224
1225 if(this.rowHeaderTable){
1226 this._resizeRowsImpl(this.rowHeaderTable, "tr");
1227 }
1228 if(this.gridTable){
1229 this._resizeRowsImpl(this.gridTable, "tr");
1230 }
1231 if(this.itemContainerTable){
1232 this._resizeRowsImpl(this.itemContainerTable, "tr");
1233 }
1234 },
1235
1236 _computeRowsHeight:function(renderData, max){
1237 // summary:
1238 // 1. Determine if it's better to add or remove pixels
1239 // 2. distribute added/removed pixels on first and last rows.
1240 // if rows are not too small, it is not noticeable.
1241 // tags:
1242 // private
1243
1244 var rd = renderData == null ? this.renderData : renderData;
1245
1246 max = max || rd.sheetHeight;
1247
1248 max--;
1249
1250 if(has("ie") == 7){
1251 max -= rd.rowCount;
1252 }
1253
1254 if(rd.rowCount == 1){
1255 rd.rowHeight = max;
1256 rd.rowHeightFirst = max;
1257 rd.rowHeightLast = max;
1258 return;
1259 }
1260
1261 var count = rd.expandedRow == null ? rd.rowCount : rd.rowCount-1;
1262 var rhx = max / count;
1263 var rhf, rhl, rh;
1264
1265 var diffMin = max - (Math.floor(rhx) * count);
1266 var diffMax = Math.abs(max - (Math.ceil(rhx) * count));
1267 var diff;
1268
1269 var sign = 1;
1270 if(diffMin < diffMax){
1271 rh = Math.floor(rhx);
1272 diff = diffMin;
1273 }else{
1274 sign = -1;
1275 rh = Math.ceil(rhx);
1276 diff = diffMax;
1277 }
1278 rhf = rh + sign * Math.floor(diff/2);
1279 rhl = rhf + sign * (diff%2);
1280
1281 rd.rowHeight = rh;
1282 rd.rowHeightFirst = rhf;
1283 rd.rowHeightLast = rhl;
1284 },
1285
1286 _getRowHeight: function(index){
1287 // tags:
1288 // private
1289
1290 var rd = this.renderData;
1291 if(index == rd.expandedRow){
1292 return rd.expandedRowHeight;
1293 } else if(rd.expandedRow == 0 && index == 1 || index == 0){
1294 return rd.rowHeightFirst;
1295 } else if(rd.expandedRow == this.renderData.rowCount-1 &&
1296 index == this.renderData.rowCount-2 ||
1297 index == this.renderData.rowCount-1){
1298 return rd.rowHeightLast;
1299 }else{
1300 return rd.rowHeight;
1301 }
1302 },
1303
1304 _resizeRowsImpl: function(tableNode, query){
1305 // tags:
1306 // private
1307 dojo.query(query, tableNode).forEach(function(tr, i){
1308 domStyle.set(tr, "height", this._getRowHeight(i)+"px");
1309 }, this);
1310 },
1311
1312 ////////////////////////////////////////////
1313 //
1314 // Item renderers
1315 //
1316 ///////////////////////////////////////////
1317
1318 _setHorizontalRendererAttr: function(value){
1319 this._destroyRenderersByKind("horizontal");
1320 this._set("horizontalRenderer", value);
1321 },
1322
1323 _setLabelRendererAttr: function(value){
1324 this._destroyRenderersByKind("label");
1325 this._set("labelRenderer", value);
1326 },
1327
1328 _destroyExpandRenderer: function(renderer){
1329 // summary:
1330 // Destroys the expand renderer.
1331 // renderer: dojox/calendar/_RendererMixin
1332 // The item renderer to destroy.
1333 // tags:
1334 // protected
1335
1336 if(renderer["destroyRecursive"]){
1337 renderer.destroyRecursive();
1338 }
1339
1340 html.destroy(renderer.domNode);
1341 },
1342
1343 _setExpandRendererAttr: function(value){
1344 while(this._ddRendererList.length>0){
1345 this._destroyExpandRenderer(this._ddRendererList.pop());
1346 }
1347
1348 var pool = this._ddRendererPool;
1349 if(pool){
1350 while(pool.length > 0){
1351 this._destroyExpandRenderer(pool.pop());
1352 }
1353 }
1354 this._set("expandRenderer", value);
1355 },
1356
1357 _ddRendererList: null,
1358 _ddRendererPool: null,
1359
1360 _getExpandRenderer: function(date, items, rowIndex, colIndex, expanded){
1361 // tags:
1362 // private
1363
1364 if(this.expandRenderer == null){
1365 return null;
1366 }
1367
1368 var ir = this._ddRendererPool.pop();
1369 if(ir == null){
1370 ir = new this.expandRenderer();
1371 }
1372
1373 this._ddRendererList.push(ir);
1374
1375 ir.set("owner", this);
1376 ir.set("date", date);
1377 ir.set("items", items);
1378 ir.set("rowIndex", rowIndex);
1379 ir.set("columnIndex", colIndex);
1380 ir.set("expanded", expanded);
1381 return ir;
1382 },
1383
1384 _recycleExpandRenderers: function(remove){
1385 // tags:
1386 // private
1387
1388 for(var i=0; i<this._ddRendererList.length; i++){
1389 var ir = this._ddRendererList[i];
1390 ir.set("Up", false);
1391 ir.set("Down", false);
1392 if(remove){
1393 ir.domNode.parentNode.removeChild(ir.domNode);
1394 }
1395 domStyle.set(ir.domNode, "display", "none");
1396 }
1397 this._ddRendererPool = this._ddRendererPool.concat(this._ddRendererList);
1398 this._ddRendererList = [];
1399 },
1400
1401 _defaultItemToRendererKindFunc:function(item){
1402 // tags:
1403 // private
1404 var dur = Math.abs(this.renderData.dateModule.difference(item.startTime, item.endTime, "minute"));
1405 return dur >= 1440 ? "horizontal" : "label";
1406 },
1407
1408 ////////////////////////////////////////////
1409 //
1410 // Layout
1411 //
1412 ///////////////////////////////////////////
1413
1414 // naturalRowHeight: Integer[]
1415 // After an item layout has been done, contains for each row the natural height of the row.
1416 // Ie. the height, in pixels, needed to display all the item renderers.
1417 naturalRowsHeight: null,
1418
1419 _roundItemToDay: function(item){
1420 // tags:
1421 // private
1422
1423 var s = item.startTime, e = item.endTime;
1424
1425 if(!this.isStartOfDay(s)){
1426 s = this.floorToDay(s, false, this.renderData);
1427 }
1428 if(!this.isStartOfDay(e)){
1429 e = this.renderData.dateModule.add(e, "day", 1);
1430 e = this.floorToDay(e, true);
1431 }
1432 return {startTime:s, endTime:e};
1433 },
1434
1435 _sortItemsFunction: function(a, b){
1436 // tags:
1437 // private
1438
1439 if(this.roundToDay){
1440 a = this._roundItemToDay(a);
1441 b = this._roundItemToDay(b);
1442 }
1443 var res = this.dateModule.compare(a.startTime, b.startTime);
1444 if(res == 0){
1445 res = -1 * this.dateModule.compare(a.endTime, b.endTime);
1446 }
1447 return res;
1448 },
1449
1450 _overlapLayoutPass3: function(lanes){
1451 // summary:
1452 // Third pass of the overlap layout (optional). Compute the number of lanes used by sub interval.
1453 // lanes: Object[]
1454 // The array of lanes.
1455 // tags:
1456 // private
1457
1458 var pos=0, posEnd=0;
1459 var res = [];
1460
1461 var refPos = domGeometry.position(this.gridTable).x;
1462
1463 for(var col=0; col<this.renderData.columnCount; col++){
1464
1465 var stop = false;
1466 var colPos = domGeometry.position(this._getCellAt(0, col));
1467 pos = colPos.x - refPos;
1468 posEnd = pos + colPos.w;
1469
1470 for(var lane=lanes.length-1; lane>=0 && !stop; lane--){
1471 for (var i=0; i<lanes[lane].length; i++){
1472 var item = lanes[lane][i];
1473 stop = item.start < posEnd && pos < item.end;
1474 if(stop){
1475 res[col] = lane + 1;
1476 break;
1477 }
1478 }
1479 }
1480
1481 if(!stop){
1482 res[col] = 0;
1483 }
1484 }
1485
1486 return res;
1487 },
1488
1489 applyRendererZIndex: function(item, renderer, hovered, selected, edited, focused){
1490 // summary:
1491 // Applies the z-index to the renderer based on the state of the item.
1492 // This methods is setting a z-index of 20 is the item is selected or edited
1493 // and the current lane value computed by the overlap layout (i.e. the renderers
1494 // are stacked according to their lane).
1495 // item: Object
1496 // The render item.
1497 // renderer: Object
1498 // A renderer associated with the render item.
1499 // hovered: Boolean
1500 // Whether the item is hovered or not.
1501 // selected: Boolean
1502 // Whether the item is selected or not.
1503 // edited: Boolean
1504 // Whether the item is being edited not not.
1505 // focused: Boolean
1506 // Whether the item is focused not not.
1507 // tags:
1508 // private
1509
1510 domStyle.set(renderer.container, {"zIndex": edited || selected ? renderer.renderer.mobile ? 100 : 0: item.lane == undefined ? 1 : item.lane+1});
1511 },
1512
1513 _layoutDecorationRenderers: function(renderData){
1514 // tags:
1515 // private
1516 if(renderData == null || renderData.decorationItems == null || renderData.rowHeight <= 0){
1517 return;
1518 }
1519
1520 if(!this.gridTable || this._expandAnimation != null ||
1521 this.horizontalDecorationRenderer == null){
1522 this.decorationRendererManager.recycleItemRenderers();
1523 return;
1524 }
1525
1526 this._layoutStep = renderData.columnCount;
1527 this.renderData.gridTablePosX = domGeometry.position(this.gridTable).x;
1528
1529 this.inherited(arguments);
1530 },
1531
1532 _layoutRenderers: function(renderData){
1533 // tags:
1534 // private
1535 if(renderData == null || renderData.items == null || renderData.rowHeight <= 0){
1536 return;
1537 }
1538
1539 if(!this.gridTable || this._expandAnimation != null ||
1540 (this.horizontalRenderer == null && this.labelRenderer == null)){
1541 this._recycleItemRenderers();
1542 return;
1543 }
1544
1545 this.renderData.gridTablePosX = domGeometry.position(this.gridTable).x;
1546 this._layoutStep = renderData.columnCount;
1547 this._recycleExpandRenderers();
1548 this._hiddenItems = [];
1549 this._offsets = [];
1550 this.naturalRowsHeight = [];
1551
1552 this.inherited(arguments);
1553 },
1554
1555 _offsets: null,
1556
1557 _layoutInterval: function(/*Object*/renderData, /*Integer*/index, /*Date*/start, /*Date*/end, /*Object[]*/items, /*String*/itemsType){
1558 // tags:
1559 // private
1560
1561 if(this.renderData.cells == null){
1562 return;
1563 }
1564
1565 if(itemsType === "dataItems"){
1566
1567 var horizontalItems = [];
1568 var labelItems = [];
1569
1570 for(var i=0; i<items.length; i++){
1571 var item = items[i];
1572 var kind = this._itemToRendererKind(item);
1573 if(kind == "horizontal"){
1574 horizontalItems.push(item);
1575 }else if(kind == "label"){
1576 labelItems.push(item);
1577 }
1578 }
1579
1580 var expIndex = this.getExpandedRowIndex();
1581
1582 if(expIndex != -1 && expIndex != index){
1583 return; // when row is expanded, layout only expanded row
1584 }
1585
1586 var offsets;
1587
1588 var hiddenItems = [];
1589
1590 var hItems = null;
1591 var hOffsets = [];
1592 if(horizontalItems.length > 0 && this.horizontalRenderer){
1593 var hItems = this._createHorizontalLayoutItems(index, start, end, horizontalItems, itemsType);
1594 var hOverlapLayout = this._computeHorizontalOverlapLayout(hItems, hOffsets);
1595 }
1596
1597 var lItems;
1598 var lOffsets = [];
1599 if(labelItems.length > 0 && this.labelRenderer){
1600 lItems = this._createLabelLayoutItems(index, start, end, labelItems);
1601 this._computeLabelOffsets(lItems, lOffsets);
1602 }
1603
1604 var hasHiddenItems = this._computeColHasHiddenItems(index, hOffsets, lOffsets);
1605
1606 if(hItems != null){
1607 this._layoutHorizontalItemsImpl(index, hItems, hOverlapLayout, hasHiddenItems, hiddenItems, itemsType);
1608 }
1609
1610 if(lItems != null){
1611 this._layoutLabelItemsImpl(index, lItems, hasHiddenItems, hiddenItems, hOffsets, itemsType);
1612 }
1613
1614 this._layoutExpandRenderers(index, hasHiddenItems, hiddenItems);
1615
1616 this._hiddenItems[index] = hiddenItems;
1617 }else{ // itemsType === "decorationItems"
1618
1619 if(this.horizontalDecorationRenderer){
1620 var hItems = this._createHorizontalLayoutItems(index, start, end, items, itemsType);
1621 if(hItems != null){
1622 this._layoutHorizontalItemsImpl(index, hItems, null, false, null, itemsType);
1623 }
1624 }
1625 }
1626 },
1627
1628 _createHorizontalLayoutItems: function(/*Integer*/index, /*Date*/startTime, /*Date*/endTime, /*Object[]*/items, /*String*/itemsType){
1629 // tags:
1630 // private
1631
1632 var rd = this.renderData;
1633 var cal = rd.dateModule;
1634 var sign = rd.rtl ? -1 : 1;
1635 var layoutItems = [];
1636 var isDecoration = itemsType === "decorationItems";
1637
1638 // step 1: compute projected position and size
1639 for(var i = 0; i < items.length; i++){
1640
1641 var item = items[i];
1642 var overlap = this.computeRangeOverlap(rd, item.startTime, item.endTime, startTime, endTime);
1643
1644 var startOffset = cal.difference(startTime, this.floorToDay(overlap[0], false, rd), "day");
1645 var dayStart = rd.dates[index][startOffset];
1646
1647 var celPos = domGeometry.position(this._getCellAt(index, startOffset, false));
1648 var start = celPos.x - rd.gridTablePosX;
1649 if(rd.rtl){
1650 start += celPos.w;
1651 }
1652
1653 if(isDecoration && !item.isAllDay || !isDecoration && !this.roundToDay && !item.allDay){
1654 start += sign * this.computeProjectionOnDate(rd, dayStart, overlap[0], celPos.w);
1655 }
1656
1657 start = Math.ceil(start);
1658
1659 var endOffset = cal.difference(startTime, this.floorToDay(overlap[1], false, rd), "day");
1660
1661 var end;
1662 if(endOffset > rd.columnCount-1){
1663 celPos = domGeometry.position(this._getCellAt(index, rd.columnCount-1, false));
1664 if(rd.rtl){
1665 end = celPos.x - rd.gridTablePosX;
1666 }else{
1667 end = celPos.x - rd.gridTablePosX + celPos.w;
1668 }
1669 }else{
1670 dayStart = rd.dates[index][endOffset];
1671 celPos = domGeometry.position(this._getCellAt(index, endOffset, false));
1672 end = celPos.x - rd.gridTablePosX;
1673
1674 if(rd.rtl){
1675 end += celPos.w;
1676 }
1677
1678 if(!isDecoration && this.roundToDay){
1679 if(!this.isStartOfDay(overlap[1])){
1680 end += sign * celPos.w;
1681 }
1682 }else{
1683 end += sign * this.computeProjectionOnDate(rd, dayStart, overlap[1], celPos.w);
1684 }
1685 }
1686
1687 end = Math.floor(end);
1688
1689 if(rd.rtl){
1690 var t = end;
1691 end = start;
1692 start = t;
1693 }
1694
1695 if(end > start){ // invalid items are not displayed
1696 var litem = lang.mixin({
1697 start: start,
1698 end: end,
1699 range: overlap,
1700 item: item,
1701 startOffset: startOffset,
1702 endOffset: endOffset
1703 }, item);
1704 layoutItems.push(litem);
1705 }
1706 }
1707 return layoutItems;
1708 },
1709
1710 _computeHorizontalOverlapLayout: function(layoutItems, offsets){
1711 // tags:
1712 // private
1713
1714 var rd = this.renderData;
1715 var irHeight = this.horizontalRendererHeight;
1716 var overlapLayoutRes = this.computeOverlapping(layoutItems, this._overlapLayoutPass3);
1717 var vOverlap = this.percentOverlap / 100;
1718
1719 for(var i=0; i<rd.columnCount; i++){
1720 var numLanes = overlapLayoutRes.addedPassRes[i];
1721 var index = rd.rtl ? rd.columnCount - i - 1 : i;
1722 if(vOverlap == 0){
1723 offsets[index] = numLanes == 0 ? 0 : numLanes == 1 ? irHeight : irHeight + (numLanes-1) * (irHeight + this.verticalGap);
1724 }else{
1725 offsets[index] = numLanes == 0 ? 0 : numLanes * irHeight - (numLanes-1) * (vOverlap * irHeight) + this.verticalGap;
1726 }
1727 offsets[index] += this.cellPaddingTop;
1728 }
1729 return overlapLayoutRes;
1730 },
1731
1732 _createLabelLayoutItems: function(/*Integer*/index, /*Date*/startTime, /*Date*/endTime, /*Object[]*/items){
1733 // tags:
1734 // private
1735
1736 if(this.labelRenderer == null){
1737 return;
1738 }
1739
1740 var d;
1741 var rd = this.renderData;
1742 var cal = rd.dateModule;
1743
1744 var layoutItems = [];
1745
1746 for(var i = 0; i < items.length; i++){
1747 var item = items[i];
1748
1749 d = this.floorToDay(item.startTime, false, rd);
1750
1751 var comp = this.dateModule.compare;
1752
1753 // iterate on columns overlapped by this item to create one item per column
1754 //while(d < item.endTime && d < rd.endTime){
1755 while(comp(d, item.endTime) == -1 && comp(d, endTime) == -1){
1756
1757 var dayEnd = cal.add(d, "day", 1);
1758 dayEnd = this.floorToDay(dayEnd, true);
1759
1760 var overlap = this.computeRangeOverlap(rd, item.startTime, item.endTime, d, dayEnd);
1761 var startOffset = cal.difference(startTime, this.floorToDay(overlap[0], false, rd), "day");
1762
1763 if(startOffset >= this.columnCount){
1764 // If the offset is greater than the column count
1765 // the item will be processed in another row.
1766 break;
1767 }
1768
1769 if(startOffset >= 0){
1770 var list = layoutItems[startOffset];
1771 if(list == null){
1772 list = [];
1773 layoutItems[startOffset] = list;
1774 }
1775
1776 list.push(lang.mixin(
1777 { startOffset: startOffset,
1778 range: overlap,
1779 item: item
1780 }, item));
1781 }
1782
1783 d = cal.add(d, "day", 1);
1784 this.floorToDay(d, true);
1785 }
1786 }
1787 return layoutItems;
1788 },
1789
1790 _computeLabelOffsets: function(layoutItems, offsets){
1791 // tags:
1792 // private
1793
1794 for(var i=0; i<this.renderData.columnCount; i++){
1795 offsets[i] = layoutItems[i] == null ? 0 : layoutItems[i].length * (this.labelRendererHeight + this.verticalGap);
1796 }
1797 },
1798
1799 _computeColHasHiddenItems: function(index, hOffsets, lOffsets){
1800 // tags:
1801 // private
1802
1803 var res = [];
1804 var cellH = this._getRowHeight(index);
1805 var h;
1806 var maxH = 0;
1807 for(var i=0; i<this.renderData.columnCount; i++){
1808 h = hOffsets == null || hOffsets[i] == null ? this.cellPaddingTop : hOffsets[i];
1809 h += lOffsets == null || lOffsets[i] == null ? 0 : lOffsets[i];
1810 if(h > maxH){
1811 maxH = h;
1812 }
1813 res[i] = h > cellH;
1814 }
1815
1816 this.naturalRowsHeight[index] = maxH;
1817 return res;
1818 },
1819
1820 _layoutHorizontalItemsImpl: function(index, layoutItems, hOverlapLayout, hasHiddenItems, hiddenItems, itemsType){
1821
1822 // tags:
1823 // private
1824
1825 var rd = this.renderData;
1826 var cell = rd.cells[index];
1827 var cellH = this._getRowHeight(index);
1828 var irHeight = this.horizontalRendererHeight;
1829 var vOverlap = this.percentOverlap / 100;
1830
1831 for(var i=0; i<layoutItems.length; i++){
1832
1833 var item = layoutItems[i];
1834 var lane = item.lane;
1835
1836 if(itemsType === "dataItems"){
1837
1838 var posY = this.cellPaddingTop;
1839
1840 if(vOverlap == 0) {
1841 //no overlap and a padding between each event
1842 posY += lane * (irHeight + this.verticalGap);
1843 } else {
1844 // an overlap
1845 posY += lane * (irHeight - vOverlap * irHeight);
1846 }
1847
1848 var exp = false;
1849 var maxH = cellH;
1850 if(this.expandRenderer){
1851 for(var off=item.startOffset; off<=item.endOffset; off++){
1852 if(hasHiddenItems[off]){
1853 exp = true;
1854 break;
1855 }
1856 }
1857 maxH = exp ? cellH - this.expandRendererHeight : cellH;
1858 }
1859
1860 if(posY + irHeight <= maxH){
1861
1862 var ir = this._createRenderer(item, "horizontal", this.horizontalRenderer, "dojoxCalendarHorizontal");
1863
1864 var fullHeight = this.isItemBeingEdited(item) && !this.liveLayout && this._isEditing;
1865 var h = fullHeight ? cellH - this.cellPaddingTop : irHeight;
1866 var w = item.end - item.start;
1867 if (has("ie") >= 9 && item.start + w < this.itemContainer.offsetWidth) {
1868 w++;
1869 }
1870
1871 domStyle.set(ir.container, {
1872 "top": (fullHeight ? this.cellPaddingTop : posY) + "px",
1873 "left": item.start + "px",
1874 "width": w + "px",
1875 "height": h + "px"
1876 });
1877
1878 this._applyRendererLayout(item, ir, cell, w, h, "horizontal");
1879
1880 }else{
1881 // The items does not fit in view, fill hidden items per column
1882 for(var d=item.startOffset;d<item.endOffset;d++){
1883 if(hiddenItems[d] == null){
1884 hiddenItems[d] = [item.item];
1885 }else{
1886 hiddenItems[d].push(item.item);
1887 }
1888 }
1889 }
1890
1891 }else{ //itemsType === "decorationItems"
1892 var ir = this.decorationRendererManager.createRenderer(item, "horizontal", this.horizontalDecorationRenderer, "dojoxCalendarDecoration");
1893
1894 var h = cellH;
1895 var w = item.end - item.start;
1896 if (has("ie") >= 9 && item.start + w < this.itemContainer.offsetWidth) {
1897 w++;
1898 }
1899
1900 domStyle.set(ir.container, {
1901 "top": "0",
1902 "left": item.start + "px",
1903 "width": w + "px",
1904 "height": h + "px"
1905 });
1906
1907 domConstruct.place(ir.container, cell);
1908 domStyle.set(ir.container, "display", "block");
1909 }
1910 }
1911 },
1912
1913 _layoutLabelItemsImpl: function(index, layoutItems, hasHiddenItems, hiddenItems, hOffsets){
1914 // tags:
1915 // private
1916 var list, posY;
1917 var rd = this.renderData;
1918 var cell = rd.cells[index];
1919 var cellH = this._getRowHeight(index);
1920 var irHeight = this.labelRendererHeight;
1921 var maxW = domGeometry.getMarginBox(this.itemContainer).w;
1922
1923 for(var i=0; i<layoutItems.length; i++){
1924 list = layoutItems[i];
1925
1926 if(list != null){
1927
1928 // sort according to start time the list of label renderers
1929 list.sort(lang.hitch(this, function(a, b){
1930 return this.dateModule.compare(a.range[0], b.range[0]);
1931 }));
1932
1933 var maxH = this.expandRenderer ? (hasHiddenItems[i] ? cellH - this.expandRendererHeight: cellH) : cellH;
1934 posY = hOffsets == null || hOffsets[i] == null ? this.cellPaddingTop : hOffsets[i] + this.verticalGap;
1935 var celPos = domGeometry.position(this._getCellAt(index, i));
1936 var left = celPos.x - rd.gridTablePosX;
1937
1938 for(var j=0; j<list.length; j++){
1939
1940 if(posY + irHeight + this.verticalGap <= maxH){
1941 var item = list[j];
1942
1943 lang.mixin(item, {
1944 start: left,
1945 end: left + celPos.w
1946 });
1947
1948 var ir = this._createRenderer(item, "label", this.labelRenderer, "dojoxCalendarLabel");
1949
1950 var fullHeight = this.isItemBeingEdited(item) && !this.liveLayout && this._isEditing;
1951 var h = fullHeight ? this._getRowHeight(index) - this.cellPaddingTop : irHeight;
1952
1953 if(rd.rtl){
1954 item.start = maxW - item.end;
1955 item.end = item.start + celPos.w;
1956 }
1957
1958 domStyle.set(ir.container, {
1959 "top": (fullHeight ? this.cellPaddingTop : posY) + "px",
1960 "left": item.start + "px",
1961 "width": celPos.w + "px",
1962 "height": h + "px"
1963 });
1964
1965 this._applyRendererLayout(item, ir, cell, celPos.w, h, "label");
1966
1967 }else{
1968 break;
1969 }
1970 posY += irHeight + this.verticalGap;
1971 }
1972
1973 for(var j; j<list.length; j++){
1974 if(hiddenItems[i] == null){
1975 hiddenItems[i] = [list[j]];
1976 }else{
1977 hiddenItems[i].push(list[j]);
1978 }
1979 }
1980 }
1981 }
1982 },
1983
1984 _applyRendererLayout: function(item, ir, cell, w, h, kind){
1985 // tags:
1986 // private
1987
1988 var edited = this.isItemBeingEdited(item);
1989 var selected = this.isItemSelected(item);
1990 var hovered = this.isItemHovered(item);
1991 var focused = this.isItemFocused(item);
1992
1993 var renderer = ir.renderer;
1994
1995 renderer.set("hovered", hovered);
1996 renderer.set("selected", selected);
1997 renderer.set("edited", edited);
1998 renderer.set("focused", this.showFocus ? focused : false);
1999 renderer.set("moveEnabled", this.isItemMoveEnabled(item._item, kind));
2000 renderer.set("storeState", this.getItemStoreState(item));
2001
2002 if(kind != "label"){
2003 renderer.set("resizeEnabled", this.isItemResizeEnabled(item, kind));
2004 }
2005
2006 this.applyRendererZIndex(item, ir, hovered, selected, edited, focused);
2007
2008 if(renderer.updateRendering){
2009 renderer.updateRendering(w, h);
2010 }
2011
2012 domConstruct.place(ir.container, cell);
2013 domStyle.set(ir.container, "display", "block");
2014 },
2015
2016 _getCellAt: function(rowIndex, columnIndex, rtl){
2017 // tags:
2018 // private
2019
2020 if((rtl == undefined || rtl == true) && !this.isLeftToRight()){
2021 columnIndex = this.renderData.columnCount -1 - columnIndex;
2022 }
2023 return this.gridTable.childNodes[0].childNodes[rowIndex].childNodes[columnIndex];
2024 },
2025
2026 _layoutExpandRenderers: function(index, hasHiddenItems, hiddenItems){
2027 // tags:
2028 // private
2029
2030 if(!this.expandRenderer){
2031 return;
2032 }
2033 var rd = this.renderData;
2034 if(rd.expandedRow == index){
2035 if(rd.expandedRowCol != null && rd.expandedRowCol != -1){
2036 this._layoutExpandRendererImpl(rd.expandedRow, rd.expandedRowCol, null, true);
2037 }
2038 }else{
2039 if(rd.expandedRow == null){
2040 for(var i=0; i<rd.columnCount; i++){
2041 if(hasHiddenItems[i]){
2042 this._layoutExpandRendererImpl(index, rd.rtl ? rd.columnCount -1 -i: i, hiddenItems[i], false);
2043 }
2044 }
2045 }
2046 }
2047 },
2048
2049 _layoutExpandRendererImpl: function(rowIndex, colIndex, items, expanded){
2050 // tags:
2051 // private
2052
2053 var rd = this.renderData;
2054 var d = lang.clone(rd.dates[rowIndex][colIndex]);
2055 var ir = null;
2056 var cell = rd.cells[rowIndex];
2057
2058 ir = this._getExpandRenderer(d, items, rowIndex, colIndex, expanded);
2059
2060 var dim = domGeometry.position(this._getCellAt(rowIndex, colIndex));
2061 dim.x -= rd.gridTablePosX;
2062 this.layoutExpandRenderer(ir, d, items, dim, this.expandRendererHeight);
2063 domConstruct.place(ir.domNode, cell);
2064 domStyle.set(ir.domNode, "display", "block");
2065 },
2066
2067 layoutExpandRenderer: function(renderer, date, items, cellPosition, height){
2068 // summary:
2069 // Computes and sets the position of the expand/collapse renderers.
2070 // By default the renderer is set to take the width of the cell and is placed at the bottom of the cell.
2071 // The renderer DOM node is in a row that takes all the grid width.
2072 // renderer: Object
2073 // The renderer used in specified cell that indicates that some items cannot be displayed.
2074 // date: Date
2075 // The date displayed by the cell.
2076 // items: Object[]
2077 // The list of non visible items.
2078 // cellPosition: Object
2079 // An object that contains the position (x and y properties) and size of the cell (w and h properties).
2080 // tags:
2081 // private
2082 domStyle.set(renderer.domNode, {
2083 "left": cellPosition.x + "px",
2084 "width": cellPosition.w + "px",
2085 "height": height + "px",
2086 "top": (cellPosition.h - height -1) + "px"
2087 });
2088 },
2089
2090 /////////////////////////////////////////////
2091 //
2092 // Editing
2093 //
2094 //////////////////////////////////////////////
2095
2096 _onItemEditBeginGesture: function(e){
2097 // tags:
2098 // private
2099 var p = this._edProps;
2100
2101 var item = p.editedItem;
2102 var dates = e.dates;
2103
2104 var refTime = this.newDate(p.editKind == "resizeEnd" ? item.endTime : item.startTime);
2105
2106 if(p.rendererKind == "label"){
2107 // noop
2108 }else if(e.editKind == "move" && (item.allDay || this.roundToDay)){
2109 var cal = this.renderData.dateModule;
2110 p.dayOffset = cal.difference(
2111 this.floorToDay(dates[0], false, this.renderData),
2112 refTime, "day");
2113 } // else managed in super
2114
2115 this.inherited(arguments);
2116 },
2117
2118 _computeItemEditingTimes: function(item, editKind, rendererKind, times, eventSource){
2119 // tags:
2120 // private
2121 var cal = this.renderData.dateModule;
2122 var p = this._edProps;
2123
2124 if(rendererKind == "label"){ // noop
2125 }else if(item.allDay || this.roundToDay){
2126 var isStartOfDay = this.isStartOfDay(times[0]);
2127 switch(editKind){
2128 case "resizeEnd":
2129 if(!isStartOfDay && item.allDay){
2130 times[0] = cal.add(times[0], "day", 1); // no break;
2131 }
2132 case "resizeStart":
2133 if(!isStartOfDay){
2134 times[0] = this.floorToDay(times[0], true);
2135 }
2136 break;
2137 case "move":
2138 times[0] = cal.add(times[0], "day", p.dayOffset);
2139 break;
2140 case "resizeBoth":
2141 if(!isStartOfDay){
2142 times[0] = this.floorToDay(times[0], true);
2143 }
2144 if(!this.isStartOfDay(times[1])){
2145 times[1] = this.floorToDay(cal.add(times[1], "day", 1), true);
2146 }
2147 break;
2148 }
2149
2150 }else{
2151 times = this.inherited(arguments);
2152 }
2153
2154 return times;
2155 },
2156
2157
2158 /////////////////////////////////////////////
2159 //
2160 // Pixel to Time projection
2161 //
2162 //////////////////////////////////////////////
2163
2164 getTime: function(e, x, y, touchIndex){
2165 // summary:
2166 // Returns the time displayed at the specified point by this component.
2167 // e: Event
2168 // Optional mouse event.
2169 // x: Number
2170 // Position along the x-axis with respect to the sheet container used if event is not defined.
2171 // y: Number
2172 // Position along the y-axis with respect to the sheet container (scroll included) used if event is not defined.
2173 // touchIndex: Integer
2174 // If parameter 'e' is not null and a touch event, the index of the touch to use.
2175 // returns: Date
2176
2177 var rd = this.renderData;
2178
2179 if(e != null){
2180 var refPos = domGeometry.position(this.itemContainer, true);
2181
2182 if(e.touches){
2183
2184 touchIndex = touchIndex==undefined ? 0 : touchIndex;
2185
2186 x = e.touches[touchIndex].pageX - refPos.x;
2187 y = e.touches[touchIndex].pageY - refPos.y;
2188
2189 }else{
2190
2191 x = e.pageX - refPos.x;
2192 y = e.pageY - refPos.y;
2193 }
2194 }
2195
2196 var r = domGeometry.getContentBox(this.itemContainer);
2197
2198 if(x < 0){
2199 x = 0;
2200 }else if(x > r.w){
2201 x = r.w-1;
2202 }
2203
2204 if(y < 0){
2205 y = 0;
2206 }else if(y > r.h){
2207 y = r.h-1;
2208 }
2209
2210 // compute the date from column the time in day instead of time from start date of row to prevent DST hour offset.
2211
2212 var w = domGeometry.getMarginBox(this.itemContainer).w;
2213 var colW = w / rd.columnCount;
2214
2215 var row;
2216 if(rd.expandedRow == null){
2217 row = Math.floor(y / (domGeometry.getMarginBox(this.itemContainer).h / rd.rowCount));
2218 }else{
2219 row = rd.expandedRow; //other rows are not usable
2220 }
2221
2222 var r = domGeometry.getContentBox(this.itemContainer);
2223
2224 if(rd.rtl){
2225 x = r.w - x;
2226 }
2227
2228 var col = Math.floor(x / colW);
2229
2230 var tm = Math.floor((x-(col*colW)) * 1440 / colW);
2231
2232 var date = null;
2233 if(row < rd.dates.length && col < this.renderData.dates[row].length){
2234 date = this.newDate(this.renderData.dates[row][col]);
2235 date = this.renderData.dateModule.add(date, "minute", tm);
2236 }
2237
2238 return date;
2239 },
2240
2241 /////////////////////////////////////////////
2242 //
2243 // Event management
2244 //
2245 //////////////////////////////////////////////
2246
2247 _onGridMouseUp: function(e){
2248 // tags:
2249 // private
2250
2251 this.inherited(arguments);
2252
2253 if(this._gridMouseDown){
2254 this._gridMouseDown = false;
2255
2256 this._onGridClick({
2257 date: this.getTime(e),
2258 triggerEvent: e
2259 });
2260 }
2261 },
2262
2263 _onGridTouchEnd: function(e){
2264 // tags:
2265 // private
2266 this.inherited(arguments);
2267
2268 var g = this._gridProps;
2269
2270 if(g){
2271
2272 if(!this._isEditing){
2273
2274 // touched on grid and on touch start editing was ongoing.
2275 if(!g.fromItem && !g.editingOnStart){
2276 this.selectFromEvent(e, null, null, true);
2277 }
2278
2279 if(!g.fromItem){
2280
2281 if(this._pendingDoubleTap && this._pendingDoubleTap.grid){
2282
2283 this._onGridDoubleClick({
2284 date: this.getTime(this._gridProps.event),
2285 triggerEvent: this._gridProps.event
2286 });
2287
2288 clearTimeout(this._pendingDoubleTap.timer);
2289
2290 delete this._pendingDoubleTap;
2291
2292 }else{
2293
2294 this._onGridClick({
2295 date: this.getTime(this._gridProps.event),
2296 triggerEvent: this._gridProps.event
2297 });
2298
2299 this._pendingDoubleTap = {
2300 grid: true,
2301 timer: setTimeout(lang.hitch(this, function(){
2302 delete this._pendingDoubleTap;
2303 }), this.doubleTapDelay)
2304 };
2305 }
2306 }
2307 }
2308
2309 this._gridProps = null;
2310 }
2311 },
2312
2313
2314 /////////////////////////////////////////////
2315 //
2316 // Events
2317 //
2318 //////////////////////////////////////////////
2319
2320 _onRowHeaderClick: function(e){
2321 this._dispatchCalendarEvt(e, "onRowHeaderClick");
2322 // tags:
2323 // private
2324 },
2325
2326 onRowHeaderClick: function(e){
2327 // summary:
2328 // Event dispatched when a row header cell is clicked.
2329 // e: __HeaderClickEventArgs
2330 // Header click event.
2331 // tags:
2332 // callback
2333 },
2334
2335 expandRendererClickHandler: function(e, renderer){
2336 // summary:
2337 // Default action when an expand renderer is clicked.
2338 // e: Event
2339 // The mouse event.
2340 // renderer: Object
2341 // The expand renderer.
2342 // tags:
2343 // protected
2344
2345 event.stop(e);
2346
2347 var ri = renderer.get("rowIndex");
2348 var ci = renderer.get("columnIndex");
2349
2350 this._onExpandRendererClick(lang.mixin(this._createItemEditEvent(), {
2351 rowIndex: ri,
2352 columnIndex: ci,
2353 renderer: renderer,
2354 triggerEvent: e,
2355 date: this.renderData.dates[ri][ci]
2356 }));
2357 },
2358
2359 onExpandRendererClick: function(e){
2360 // summary:
2361 // Event dispatched when an expand renderer is clicked.
2362 // e: __ExpandRendererClickEventArgs
2363 // Expand renderer click event.
2364 // tags:
2365 // callback
2366 },
2367
2368 _onExpandRendererClick: function(e){
2369
2370 this._dispatchCalendarEvt(e, "onExpandRendererClick");
2371
2372 if(!e.isDefaultPrevented()){
2373
2374 if(this.getExpandedRowIndex() != -1){
2375 this.collapseRow();
2376 }else{
2377 this.expandRow(e.rowIndex, e.columnIndex);
2378 }
2379 }
2380 },
2381
2382
2383 ////////////////////////////////////////////
2384 //
2385 // Editing
2386 //
2387 ///////////////////////////////////////////
2388
2389 snapUnit: "minute",
2390 snapSteps: 15,
2391 minDurationUnit: "minute",
2392 minDurationSteps: 15,
2393 triggerExtent: 3,
2394 liveLayout: false,
2395 stayInView: true,
2396 allowStartEndSwap: true,
2397 allowResizeLessThan24H: false
2398
2399 });
2400 });