Debian Codegraph @

dojox/calendar/ColumnViewSecondarySheet.js

raw symbols SCIP
1 define([
2 "dojo/_base/array",
3 "dojo/_base/declare",
4 "dojo/_base/event",
5 "dojo/_base/lang",
6 "dojo/dom-geometry",
7 "dojo/dom-style",
8 "./MatrixView",
9 "dojo/text!./templates/ColumnViewSecondarySheet.html"],
10
11 function(arr,
12 declare,
13 event,
14 lang,
15 domGeometry,
16 domStyle,
17 MatrixView,
18 template){
19
20 return declare("dojox.calendar.ColumnViewSecondarySheet", MatrixView, {
21
22 // summary:
23 // This class defines a matrix view designed to be embedded in a column view,
24 // usually to display long or all day events on one row.
25
26 templateString: template,
27
28 rowCount: 1,
29
30 cellPaddingTop: 4,
31
32 roundToDay: false,
33
34 _defaultHeight: -1,
35
36 layoutDuringResize: true,
37
38 buildRendering: function(){
39 this.inherited(arguments);
40 this._hScrollNodes = [this.gridTable, this.itemContainerTable];
41 },
42
43 _configureHScrollDomNodes: function(styleWidth){
44 arr.forEach(this._hScrollNodes, function(elt){
45 domStyle.set(elt, "width", styleWidth);
46 }, this);
47 },
48
49 _defaultItemToRendererKindFunc: function(item){
50 // tags:
51 // private
52 return item.allDay ? "horizontal" : null;
53 },
54
55 _formatGridCellLabel: function(){return null;},
56
57 _formatRowHeaderLabel: function(){return null;},
58
59
60 // events redispatch
61 __fixEvt:function(e){
62 e.sheet = "secondary";
63 e.source = this;
64 return e;
65 },
66
67 _dispatchCalendarEvt: function(e, name){
68 e = this.inherited(arguments);
69 if(this.owner.owner){ // the calendar
70 this.owner.owner[name](e);
71 }
72 },
73
74 _layoutExpandRenderers: function(index, hasHiddenItems, hiddenItems){
75 if(!this.expandRenderer || this._expandedRowCol == -1){
76 return;
77 }
78 var h = domGeometry.getMarginBox(this.domNode).h;
79 if(this._defaultHeight == -1 || // not set
80 this._defaultHeight === 0){ // initialized at 0, must be reset
81 this._defaultHeight = h;
82 }
83
84 if(this._defaultHeight != h && h >= this._getExpandedHeight() ||
85 this._expandedRowCol !== undefined && this._expandedRowCol !== -1){
86 var col = this._expandedRowCol;
87 if(col >= this.renderData.columnCount){
88 col = 0;
89 }
90 this._layoutExpandRendererImpl(0, col, null, true);
91 }else{
92 this.inherited(arguments);
93 }
94 },
95
96 expandRendererClickHandler: function(e, renderer){
97 // summary:
98 // Default action when an expand renderer is clicked.
99 // This method will expand the secondary sheet to show all the events.
100 // e: Event
101 // The mouse event.
102 // renderer: Object
103 // The renderer that was clicked.
104 // tags:
105 // callback
106
107 event.stop(e);
108
109 var h = domGeometry.getMarginBox(this.domNode).h;
110 var expandedH = this._getExpandedHeight();
111 if(this._defaultHeight == h || h < expandedH){
112 this._expandedRowCol = renderer.columnIndex;
113 this.owner.resizeSecondarySheet(expandedH);
114 }else{
115 delete this._expandedRowCol;
116 this.owner.resizeSecondarySheet(this._defaultHeight);
117 }
118 },
119
120
121 _getExpandedHeight: function(){
122 // tags:
123 // private
124
125 return (this.naturalRowsHeight && this.naturalRowsHeight.length > 0 ? this.naturalRowsHeight[0] : 0) +
126 this.expandRendererHeight + this.verticalGap + this.verticalGap;
127 },
128
129 _layoutRenderers: function(renderData){
130 if(!this._domReady){
131 return;
132 }
133 this.inherited(arguments);
134 // make sure to show the expand/collapse renderer if no item is displayed but the row was expanded.
135 if(!renderData.items || renderData.items.length === 0){
136 this._layoutExpandRenderers(0, false, null);
137 }
138 }
139
140 });
141 });