Diffstat (limited to 'frontend/beta/js/YUI-extensions/data/AbstractDataModel.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/YUI-extensions/data/AbstractDataModel.js | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/data/AbstractDataModel.js b/frontend/beta/js/YUI-extensions/data/AbstractDataModel.js new file mode 100644 index 0000000..092ea75 --- a/dev/null +++ b/frontend/beta/js/YUI-extensions/data/AbstractDataModel.js | |||
@@ -0,0 +1,226 @@ | |||
1 | /** | ||
2 | * @class YAHOO.ext.grid.AbstractDataModel | ||
3 | * @extends YAHOO.ext.util.Observable | ||
4 | * This abstract class provides default implementations of the events required by the Grid. | ||
5 | It takes care of the creating the CustomEvents and provides some convenient methods for firing the events. <br><br> | ||
6 | * @constructor | ||
7 | */ | ||
8 | YAHOO.ext.grid.AbstractDataModel = function(){ | ||
9 | /** Fires when a cell is updated - fireDirect sig: (this, rowIndex, columnIndex) | ||
10 | * @private | ||
11 | * @type YAHOO.util.CustomEvent | ||
12 | * @deprecated Use addListener instead of accessing directly | ||
13 | */ | ||
14 | this.onCellUpdated = new YAHOO.util.CustomEvent('onCellUpdated'); | ||
15 | /** Fires when all data needs to be revalidated - fireDirect sig: (thisd) | ||
16 | * @private | ||
17 | * @type YAHOO.util.CustomEvent | ||
18 | * @deprecated Use addListener instead of accessing directly | ||
19 | */ | ||
20 | this.onTableDataChanged = new YAHOO.util.CustomEvent('onTableDataChanged'); | ||
21 | /** Fires when rows are deleted - fireDirect sig: (this, firstRowIndex, lastRowIndex) | ||
22 | * @private | ||
23 | * @type YAHOO.util.CustomEvent | ||
24 | * @deprecated Use addListener instead of accessing directly | ||
25 | */ | ||
26 | this.onRowsDeleted = new YAHOO.util.CustomEvent('onRowsDeleted'); | ||
27 | /** Fires when a rows are inserted - fireDirect sig: (this, firstRowIndex, lastRowIndex) | ||
28 | * @private | ||
29 | * @type YAHOO.util.CustomEvent | ||
30 | * @deprecated Use addListener instead of accessing directly | ||
31 | */ | ||
32 | this.onRowsInserted = new YAHOO.util.CustomEvent('onRowsInserted'); | ||
33 | /** Fires when a rows are updated - fireDirect sig: (this, firstRowIndex, lastRowIndex) | ||
34 | * @private | ||
35 | * @type YAHOO.util.CustomEvent | ||
36 | * @deprecated Use addListener instead of accessing directly | ||
37 | */ | ||
38 | this.onRowsUpdated = new YAHOO.util.CustomEvent('onRowsUpdated'); | ||
39 | /** Fires when a sort has reordered the rows - fireDirect sig: (this, sortColumnIndex, | ||
40 | * @private | ||
41 | * sortDirection = 'ASC' or 'DESC') | ||
42 | * @type YAHOO.util.CustomEvent | ||
43 | * @deprecated Use addListener instead of accessing directly | ||
44 | */ | ||
45 | this.onRowsSorted = new YAHOO.util.CustomEvent('onRowsSorted'); | ||
46 | |||
47 | this.events = { | ||
48 | /** | ||
49 | * @event cellupdated | ||
50 | * Fires when a cell is updated | ||
51 | * @param {DataModel} this | ||
52 | * @param {Number} rowIndex | ||
53 | * @param {Number} columnIndex | ||
54 | */ | ||
55 | 'cellupdated' : this.onCellUpdated, | ||
56 | /** | ||
57 | * @event datachanged | ||
58 | * Fires when the entire data structure has changed | ||
59 | * @param {DataModel} this | ||
60 | */ | ||
61 | 'datachanged' : this.onTableDataChanged, | ||
62 | /** | ||
63 | * @event rowsdeleted | ||
64 | * Fires when a range of rows have been deleted | ||
65 | * @param {DataModel} this | ||
66 | * @param {Number} firstRowIndex | ||
67 | * @param {Number} lastRowIndex | ||
68 | */ | ||
69 | 'rowsdeleted' : this.onRowsDeleted, | ||
70 | /** | ||
71 | * @event rowsinserted | ||
72 | * Fires when a range of rows have been inserted | ||
73 | * @param {DataModel} this | ||
74 | * @param {Number} firstRowIndex | ||
75 | * @param {Number} lastRowIndex | ||
76 | */ | ||
77 | 'rowsinserted' : this.onRowsInserted, | ||
78 | /** | ||
79 | * @event rowsupdated | ||
80 | * Fires when a range of rows have been updated | ||
81 | * @param {DataModel} this | ||
82 | * @param {Number} firstRowIndex | ||
83 | * @param {Number} lastRowIndex | ||
84 | */ | ||
85 | 'rowsupdated' : this.onRowsUpdated, | ||
86 | /** | ||
87 | * @event rowssorted | ||
88 | * Fires when the data has been sorted | ||
89 | * @param {DataModel} this | ||
90 | */ | ||
91 | 'rowssorted' : this.onRowsSorted | ||
92 | }; | ||
93 | }; | ||
94 | |||
95 | YAHOO.ext.grid.AbstractDataModel.prototype = { | ||
96 | |||
97 | fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent, | ||
98 | on : YAHOO.ext.util.Observable.prototype.on, | ||
99 | addListener : YAHOO.ext.util.Observable.prototype.addListener, | ||
100 | delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener, | ||
101 | removeListener : YAHOO.ext.util.Observable.prototype.removeListener, | ||
102 | purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners, | ||
103 | bufferedListener : YAHOO.ext.util.Observable.prototype.bufferedListener, | ||
104 | |||
105 | /** | ||
106 | * Notifies listeners that the value of the cell at [row, col] has been updated | ||
107 | * @deprecated | ||
108 | * @private | ||
109 | */ | ||
110 | fireCellUpdated : function(row, col){ | ||
111 | this.onCellUpdated.fireDirect(this, row, col); | ||
112 | }, | ||
113 | |||
114 | /** | ||
115 | * Notifies listeners that all data for the grid may have changed - use as a last resort. This | ||
116 | * also wipes out all selections a user might have made. | ||
117 | * @deprecated | ||
118 | * @private | ||
119 | */ | ||
120 | fireTableDataChanged : function(){ | ||
121 | this.onTableDataChanged.fireDirect(this); | ||
122 | }, | ||
123 | |||
124 | /** | ||
125 | * Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been deleted | ||
126 | * @deprecated | ||
127 | * @private | ||
128 | */ | ||
129 | fireRowsDeleted : function(firstRow, lastRow){ | ||
130 | this.onRowsDeleted.fireDirect(this, firstRow, lastRow); | ||
131 | }, | ||
132 | |||
133 | /** | ||
134 | * Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been inserted | ||
135 | * @deprecated | ||
136 | * @private | ||
137 | */ | ||
138 | fireRowsInserted : function(firstRow, lastRow){ | ||
139 | this.onRowsInserted.fireDirect(this, firstRow, lastRow); | ||
140 | }, | ||
141 | |||
142 | /** | ||
143 | * Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been updated | ||
144 | * @deprecated | ||
145 | * @private | ||
146 | */ | ||
147 | fireRowsUpdated : function(firstRow, lastRow){ | ||
148 | this.onRowsUpdated.fireDirect(this, firstRow, lastRow); | ||
149 | }, | ||
150 | |||
151 | /** | ||
152 | * Notifies listeners that rows have been sorted and any indexes may be invalid | ||
153 | * @deprecated | ||
154 | * @private | ||
155 | */ | ||
156 | fireRowsSorted : function(sortColumnIndex, sortDir, noRefresh){ | ||
157 | this.onRowsSorted.fireDirect(this, sortColumnIndex, sortDir, noRefresh); | ||
158 | }, | ||
159 | |||
160 | /** | ||
161 | * Empty interface method - Classes which extend AbstractDataModel should implement this method. | ||
162 | * See {@link YAHOO.ext.DefaultDataModel#sort} for an example implementation. | ||
163 | * @private | ||
164 | */ | ||
165 | sort : function(sortInfo, columnIndex, direction, suppressEvent){ | ||
166 | |||
167 | }, | ||
168 | |||
169 | /** | ||
170 | * Interface method to supply info regarding the Grid's current sort state - if overridden, | ||
171 | * this should return an object like this {column: this.sortColumn, direction: this.sortDir}. | ||
172 | * @return {Object} | ||
173 | */ | ||
174 | getSortState : function(){ | ||
175 | return {column: this.sortColumn, direction: this.sortDir}; | ||
176 | }, | ||
177 | |||
178 | /** | ||
179 | * Empty interface method - Classes which extend AbstractDataModel should implement this method. | ||
180 | * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. | ||
181 | * @private | ||
182 | */ | ||
183 | getRowCount : function(){ | ||
184 | |||
185 | }, | ||
186 | |||
187 | /** | ||
188 | * Empty interface method - Classes which extend AbstractDataModel should implement this method to support virtual row counts. | ||
189 | * @private | ||
190 | */ | ||
191 | getTotalRowCount : function(){ | ||
192 | return this.getRowCount(); | ||
193 | }, | ||
194 | |||
195 | |||
196 | /** | ||
197 | * Empty interface method - Classes which extend AbstractDataModel should implement this method. | ||
198 | * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. | ||
199 | * @private | ||
200 | */ | ||
201 | getRowId : function(rowIndex){ | ||
202 | |||
203 | }, | ||
204 | |||
205 | /** | ||
206 | * Empty interface method - Classes which extend AbstractDataModel should implement this method. | ||
207 | * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. | ||
208 | * @private | ||
209 | */ | ||
210 | getValueAt : function(rowIndex, colIndex){ | ||
211 | |||
212 | }, | ||
213 | |||
214 | /** | ||
215 | * Empty interface method - Classes which extend AbstractDataModel should implement this method. | ||
216 | * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. | ||
217 | * @private | ||
218 | */ | ||
219 | setValueAt : function(value, rowIndex, colIndex){ | ||
220 | |||
221 | }, | ||
222 | |||
223 | isPaged : function(){ | ||
224 | return false; | ||
225 | } | ||
226 | }; | ||