[483] | 1 | define([ |
---|
| 2 | "dojo/_base/declare", |
---|
| 3 | "dojo/_base/event", |
---|
| 4 | "dojo/_base/lang", |
---|
| 5 | "dojo/_base/sniff", |
---|
| 6 | "dojo/_base/fx", |
---|
| 7 | "dojo/dom", |
---|
| 8 | "dojo/dom-class", |
---|
| 9 | "dojo/dom-style", |
---|
| 10 | "dojo/dom-geometry", |
---|
| 11 | "dojo/dom-construct", |
---|
| 12 | "dojo/on", |
---|
| 13 | "dojo/date", |
---|
| 14 | "dojo/date/locale", |
---|
| 15 | "dojo/query", |
---|
| 16 | "dojox/html/metrics", |
---|
| 17 | "./SimpleColumnView", |
---|
| 18 | "dojo/text!./templates/ColumnView.html", |
---|
| 19 | "./ColumnViewSecondarySheet"], |
---|
| 20 | |
---|
| 21 | function( |
---|
| 22 | declare, |
---|
| 23 | event, |
---|
| 24 | lang, |
---|
| 25 | has, |
---|
| 26 | fx, |
---|
| 27 | dom, |
---|
| 28 | domClass, |
---|
| 29 | domStyle, |
---|
| 30 | domGeometry, |
---|
| 31 | domConstruct, |
---|
| 32 | on, |
---|
| 33 | date, |
---|
| 34 | locale, |
---|
| 35 | query, |
---|
| 36 | metrics, |
---|
| 37 | SimpleColumnView, |
---|
| 38 | template, |
---|
| 39 | ColumnViewSecondarySheet){ |
---|
| 40 | |
---|
| 41 | return declare("dojox.calendar.ColumnView", SimpleColumnView, { |
---|
| 42 | |
---|
| 43 | // summary: |
---|
| 44 | // This class defines a simple column view that also uses a secondary |
---|
| 45 | // sheet to display long or all day events. |
---|
| 46 | // By default an dojox.calendar.ColumnViewSecondarySheet instance is created. |
---|
| 47 | // Set the secondarySheetClass property to define the class to instantiate, |
---|
| 48 | // for example to mix the default class with Mouse, Keyboard or Touch plugins. |
---|
| 49 | |
---|
| 50 | templateString: template, |
---|
| 51 | |
---|
| 52 | baseClass: "dojoxCalendarColumnView", |
---|
| 53 | |
---|
| 54 | // secondarySheetClass: Class |
---|
| 55 | // The secondary sheet class, by default dojox.calendar.ColumnViewSecondarySheet. |
---|
| 56 | secondarySheetClass: ColumnViewSecondarySheet, |
---|
| 57 | |
---|
| 58 | // secondarySheetProps: Object |
---|
| 59 | // Secondary sheet constructor parameters. |
---|
| 60 | secondarySheetProps: null, |
---|
| 61 | |
---|
| 62 | // headerPadding: Integer |
---|
| 63 | // Padding between the header (composed of the secondary sheet and the column header) |
---|
| 64 | // and the primary sheet. |
---|
| 65 | headerPadding: 3, |
---|
| 66 | |
---|
| 67 | buildRendering: function(){ |
---|
| 68 | this.inherited(arguments); |
---|
| 69 | if(this.secondarySheetNode){ |
---|
| 70 | var args = lang.mixin({owner: this}, this.secondarySheetProps); |
---|
| 71 | this.secondarySheet = new this.secondarySheetClass(args, this.secondarySheetNode); |
---|
| 72 | this.secondarySheetNode = this.secondarySheet.domNode; |
---|
| 73 | } |
---|
| 74 | }, |
---|
| 75 | |
---|
| 76 | destroy: function(preserveDom){ |
---|
| 77 | if(this.secondarySheet){ |
---|
| 78 | this.secondarySheet.destroy(preserveDom); |
---|
| 79 | } |
---|
| 80 | this.inherited(arguments); |
---|
| 81 | }, |
---|
| 82 | |
---|
| 83 | _setVisibility: function(value){ |
---|
| 84 | // tags: |
---|
| 85 | // private |
---|
| 86 | |
---|
| 87 | this.inherited(arguments); |
---|
| 88 | if(this.secondarySheet){ |
---|
| 89 | this.secondarySheet._setVisibility(value); |
---|
| 90 | } |
---|
| 91 | }, |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | resize: function(changedSize){ |
---|
| 95 | // tags: |
---|
| 96 | // private |
---|
| 97 | |
---|
| 98 | this.inherited(arguments); |
---|
| 99 | if(this.secondarySheet){ |
---|
| 100 | // secondary sheet is sized by CSS |
---|
| 101 | this.secondarySheet.resize(); |
---|
| 102 | } |
---|
| 103 | }, |
---|
| 104 | |
---|
| 105 | invalidateLayout: function(){ |
---|
| 106 | // tags: |
---|
| 107 | // private |
---|
| 108 | |
---|
| 109 | this._layoutRenderers(this.renderData); |
---|
| 110 | if(this.secondarySheet){ |
---|
| 111 | this.secondarySheet._layoutRenderers(this.secondarySheet.renderData); |
---|
| 112 | } |
---|
| 113 | }, |
---|
| 114 | |
---|
| 115 | onRowHeaderClick: function(e){ |
---|
| 116 | // summary: |
---|
| 117 | // Event dispatched when the row header cell of the secondary sheet is clicked. |
---|
| 118 | // tags: |
---|
| 119 | // callback |
---|
| 120 | |
---|
| 121 | }, |
---|
| 122 | |
---|
| 123 | resizeSecondarySheet: function(height){ |
---|
| 124 | // summary: |
---|
| 125 | // Resizes the secondary sheet header and relayout the other sub components according this new height. |
---|
| 126 | // Warning: this method is only available for the default template and default CSS. |
---|
| 127 | // height: Integer |
---|
| 128 | // The new height in pixels. |
---|
| 129 | if(this.secondarySheetNode){ |
---|
| 130 | var headerH = domGeometry.getMarginBox(this.header).h; |
---|
| 131 | domStyle.set(this.secondarySheetNode, "height", height+"px"); |
---|
| 132 | this.secondarySheet._resizeHandler(null, true); |
---|
| 133 | var top = (height + headerH + this.headerPadding)+"px"; |
---|
| 134 | domStyle.set(this.scrollContainer, "top", top); |
---|
| 135 | if(this.vScrollBar){ |
---|
| 136 | domStyle.set(this.vScrollBar, "top", top); |
---|
| 137 | } |
---|
| 138 | } |
---|
| 139 | }, |
---|
| 140 | |
---|
| 141 | updateRenderers: function(obj, stateOnly){ |
---|
| 142 | this.inherited(arguments); |
---|
| 143 | if(this.secondarySheet){ |
---|
| 144 | this.secondarySheet.updateRenderers(obj, stateOnly); |
---|
| 145 | } |
---|
| 146 | }, |
---|
| 147 | |
---|
| 148 | _setItemsAttr: function(value){ |
---|
| 149 | this.inherited(arguments); |
---|
| 150 | if(this.secondarySheet){ |
---|
| 151 | this.secondarySheet.set("items", value); |
---|
| 152 | } |
---|
| 153 | }, |
---|
| 154 | |
---|
| 155 | _setStartDateAttr: function(value){ |
---|
| 156 | this.inherited(arguments); |
---|
| 157 | if(this.secondarySheet){ |
---|
| 158 | this.secondarySheet.set("startDate", value); |
---|
| 159 | } |
---|
| 160 | }, |
---|
| 161 | |
---|
| 162 | _setColumnCountAttr: function(value){ |
---|
| 163 | this.inherited(arguments); |
---|
| 164 | if(this.secondarySheet){ |
---|
| 165 | this.secondarySheet.set("columnCount", value); |
---|
| 166 | } |
---|
| 167 | }, |
---|
| 168 | |
---|
| 169 | _setHorizontalRendererAttr: function(value){ |
---|
| 170 | if(this.secondarySheet){ |
---|
| 171 | this.secondarySheet.set("horizontalRenderer", value); |
---|
| 172 | } |
---|
| 173 | }, |
---|
| 174 | |
---|
| 175 | _getHorizontalRendererAttr: function(){ |
---|
| 176 | if(this.secondarySheet){ |
---|
| 177 | return this.secondarySheet.get("horizontalRenderer"); |
---|
| 178 | } |
---|
| 179 | return null; |
---|
| 180 | }, |
---|
| 181 | |
---|
| 182 | _setExpandRendererAttr: function(value){ |
---|
| 183 | if(this.secondarySheet){ |
---|
| 184 | this.secondarySheet.set("expandRenderer", value); |
---|
| 185 | } |
---|
| 186 | }, |
---|
| 187 | |
---|
| 188 | _getExpandRendererAttr: function(){ |
---|
| 189 | if(this.secondarySheet){ |
---|
| 190 | return this.secondarySheet.get("expandRenderer"); |
---|
| 191 | } |
---|
| 192 | return null; |
---|
| 193 | }, |
---|
| 194 | |
---|
| 195 | _setTextDirAttr: function(value){ |
---|
| 196 | this.secondarySheet.set("textDir", value); |
---|
| 197 | this._set("textDir", value); |
---|
| 198 | }, |
---|
| 199 | |
---|
| 200 | _defaultItemToRendererKindFunc: function(item){ |
---|
| 201 | return item.allDay ? null : "vertical"; // String |
---|
| 202 | }, |
---|
| 203 | |
---|
| 204 | getSecondarySheet: function(){ |
---|
| 205 | // summary: |
---|
| 206 | // Returns the secondary sheet |
---|
| 207 | // returns: dojox/calendar/MatrixView |
---|
| 208 | return this.secondarySheet; |
---|
| 209 | }, |
---|
| 210 | |
---|
| 211 | _onGridTouchStart: function(e){ |
---|
| 212 | this.inherited(arguments); |
---|
| 213 | this._doEndItemEditing(this.secondarySheet, "touch"); |
---|
| 214 | }, |
---|
| 215 | |
---|
| 216 | _onGridMouseDown: function(e){ |
---|
| 217 | this.inherited(arguments); |
---|
| 218 | this._doEndItemEditing(this.secondarySheet, "mouse"); |
---|
| 219 | }, |
---|
| 220 | |
---|
| 221 | _configureScrollBar: function(renderData){ |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | this.inherited(arguments); |
---|
| 225 | if(this.secondarySheetNode){ |
---|
| 226 | var atRight = this.isLeftToRight() ? true : this.scrollBarRTLPosition == "right"; |
---|
| 227 | domStyle.set(this.secondarySheetNode, atRight ? "right" : "left", renderData.scrollbarWidth + "px"); |
---|
| 228 | domStyle.set(this.secondarySheetNode, atRight ? "left" : "right", "0"); |
---|
| 229 | } |
---|
| 230 | }, |
---|
| 231 | |
---|
| 232 | _refreshItemsRendering: function(){ |
---|
| 233 | this.inherited(arguments); |
---|
| 234 | if(this.secondarySheet){ |
---|
| 235 | var rd = this.secondarySheet.renderData; |
---|
| 236 | this.secondarySheet._computeVisibleItems(rd); |
---|
| 237 | this.secondarySheet._layoutRenderers(rd); |
---|
| 238 | } |
---|
| 239 | }, |
---|
| 240 | |
---|
| 241 | _layoutRenderers: function(renderData){ |
---|
| 242 | if(!this.secondarySheet._domReady){ |
---|
| 243 | this.secondarySheet._domReady = true; |
---|
| 244 | this.secondarySheet._layoutRenderers(this.secondarySheet.renderData); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | this.inherited(arguments); |
---|
| 248 | }, |
---|
| 249 | |
---|
| 250 | invalidateRendering: function(){ |
---|
| 251 | if(this.secondarySheet){ |
---|
| 252 | this.secondarySheet.invalidateRendering(); |
---|
| 253 | } |
---|
| 254 | this.inherited(arguments); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | }); |
---|
| 258 | }); |
---|