slickgrid 2.3.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +20 -0
  4. data/README.md +30 -0
  5. data/lib/slickgrid.rb +6 -0
  6. data/lib/slickgrid/version.rb +3 -0
  7. data/slickgrid.gemspec +20 -0
  8. data/vendor/assets/images/slickgrid/CheckboxN.png +0 -0
  9. data/vendor/assets/images/slickgrid/CheckboxY.png +0 -0
  10. data/vendor/assets/images/slickgrid/GrpCheckboxN.png +0 -0
  11. data/vendor/assets/images/slickgrid/GrpCheckboxY.png +0 -0
  12. data/vendor/assets/images/slickgrid/actions.gif +0 -0
  13. data/vendor/assets/images/slickgrid/ajax-loader-small.gif +0 -0
  14. data/vendor/assets/images/slickgrid/arrow-right.gif +0 -0
  15. data/vendor/assets/images/slickgrid/arrow_redo.png +0 -0
  16. data/vendor/assets/images/slickgrid/arrow_right_peppermint.png +0 -0
  17. data/vendor/assets/images/slickgrid/arrow_right_spearmint.png +0 -0
  18. data/vendor/assets/images/slickgrid/arrow_undo.png +0 -0
  19. data/vendor/assets/images/slickgrid/bullet_blue.png +0 -0
  20. data/vendor/assets/images/slickgrid/bullet_star.png +0 -0
  21. data/vendor/assets/images/slickgrid/bullet_toggle_minus.png +0 -0
  22. data/vendor/assets/images/slickgrid/bullet_toggle_plus.png +0 -0
  23. data/vendor/assets/images/slickgrid/calendar.gif +0 -0
  24. data/vendor/assets/images/slickgrid/collapse.gif +0 -0
  25. data/vendor/assets/images/slickgrid/comment_yellow.gif +0 -0
  26. data/vendor/assets/images/slickgrid/delete.png +0 -0
  27. data/vendor/assets/images/slickgrid/down.gif +0 -0
  28. data/vendor/assets/images/slickgrid/drag-handle.png +0 -0
  29. data/vendor/assets/images/slickgrid/editor-helper-bg.gif +0 -0
  30. data/vendor/assets/images/slickgrid/expand.gif +0 -0
  31. data/vendor/assets/images/slickgrid/header-bg.gif +0 -0
  32. data/vendor/assets/images/slickgrid/header-columns-bg.gif +0 -0
  33. data/vendor/assets/images/slickgrid/header-columns-over-bg.gif +0 -0
  34. data/vendor/assets/images/slickgrid/help.png +0 -0
  35. data/vendor/assets/images/slickgrid/info.gif +0 -0
  36. data/vendor/assets/images/slickgrid/listview.gif +0 -0
  37. data/vendor/assets/images/slickgrid/pencil.gif +0 -0
  38. data/vendor/assets/images/slickgrid/row-over-bg.gif +0 -0
  39. data/vendor/assets/images/slickgrid/sort-asc.gif +0 -0
  40. data/vendor/assets/images/slickgrid/sort-asc.png +0 -0
  41. data/vendor/assets/images/slickgrid/sort-desc.gif +0 -0
  42. data/vendor/assets/images/slickgrid/sort-desc.png +0 -0
  43. data/vendor/assets/images/slickgrid/stripes.png +0 -0
  44. data/vendor/assets/images/slickgrid/tag_red.png +0 -0
  45. data/vendor/assets/images/slickgrid/tick.png +0 -0
  46. data/vendor/assets/images/slickgrid/user_identity.gif +0 -0
  47. data/vendor/assets/images/slickgrid/user_identity_plus.gif +0 -0
  48. data/vendor/assets/javascripts/slickgrid.js +5 -0
  49. data/vendor/assets/javascripts/slickgrid/controls/columnpicker.js +221 -0
  50. data/vendor/assets/javascripts/slickgrid/controls/gridmenu.js +429 -0
  51. data/vendor/assets/javascripts/slickgrid/controls/pager.js +154 -0
  52. data/vendor/assets/javascripts/slickgrid/core.js +493 -0
  53. data/vendor/assets/javascripts/slickgrid/dataview.js +1220 -0
  54. data/vendor/assets/javascripts/slickgrid/editors.js +640 -0
  55. data/vendor/assets/javascripts/slickgrid/formatters.js +65 -0
  56. data/vendor/assets/javascripts/slickgrid/grid.js +3990 -0
  57. data/vendor/assets/javascripts/slickgrid/groupitemmetadataprovider.js +172 -0
  58. data/vendor/assets/javascripts/slickgrid/plugins/autotooltips.js +83 -0
  59. data/vendor/assets/javascripts/slickgrid/plugins/cellcopymanager.js +88 -0
  60. data/vendor/assets/javascripts/slickgrid/plugins/cellexternalcopymanager.js +452 -0
  61. data/vendor/assets/javascripts/slickgrid/plugins/cellrangedecorator.js +72 -0
  62. data/vendor/assets/javascripts/slickgrid/plugins/cellrangeselector.js +123 -0
  63. data/vendor/assets/javascripts/slickgrid/plugins/cellselectionmodel.js +168 -0
  64. data/vendor/assets/javascripts/slickgrid/plugins/checkboxselectcolumn.js +202 -0
  65. data/vendor/assets/javascripts/slickgrid/plugins/draggablegrouping.js +207 -0
  66. data/vendor/assets/javascripts/slickgrid/plugins/headerbuttons.js +177 -0
  67. data/vendor/assets/javascripts/slickgrid/plugins/headermenu.js +296 -0
  68. data/vendor/assets/javascripts/slickgrid/plugins/rowdetailview.js +455 -0
  69. data/vendor/assets/javascripts/slickgrid/plugins/rowmovemanager.js +138 -0
  70. data/vendor/assets/javascripts/slickgrid/plugins/rowselectionmodel.js +191 -0
  71. data/vendor/assets/javascripts/slickgrid/remotemodel.js +169 -0
  72. data/vendor/assets/stylesheets/slickgrid.scss +1 -0
  73. data/vendor/assets/stylesheets/slickgrid/controls/columnpicker.css +46 -0
  74. data/vendor/assets/stylesheets/slickgrid/controls/gridmenu.css +113 -0
  75. data/vendor/assets/stylesheets/slickgrid/controls/pager.css +41 -0
  76. data/vendor/assets/stylesheets/slickgrid/default-theme.css +132 -0
  77. data/vendor/assets/stylesheets/slickgrid/grid.css +189 -0
  78. data/vendor/assets/stylesheets/slickgrid/plugins/headerbuttons.css +39 -0
  79. data/vendor/assets/stylesheets/slickgrid/plugins/headermenu.css +59 -0
  80. data/vendor/assets/stylesheets/slickgrid/plugins/rowdetailview.css +39 -0
  81. metadata +165 -0
@@ -0,0 +1,154 @@
1
+ (function ($) {
2
+ function SlickGridPager(dataView, grid, $container, options) {
3
+ var $status;
4
+ var _options;
5
+ var _defaults = {
6
+ showAllText: "Showing all {rowCount} rows",
7
+ showPageText: "Showing page {pageNum} of {pageCount}"
8
+ };
9
+
10
+ function init() {
11
+ _options = $.extend(true, {}, _defaults, options);
12
+
13
+ dataView.onPagingInfoChanged.subscribe(function (e, pagingInfo) {
14
+ updatePager(pagingInfo);
15
+ });
16
+
17
+ constructPagerUI();
18
+ updatePager(dataView.getPagingInfo());
19
+ }
20
+
21
+ function getNavState() {
22
+ var cannotLeaveEditMode = !Slick.GlobalEditorLock.commitCurrentEdit();
23
+ var pagingInfo = dataView.getPagingInfo();
24
+ var lastPage = pagingInfo.totalPages - 1;
25
+
26
+ return {
27
+ canGotoFirst: !cannotLeaveEditMode && pagingInfo.pageSize != 0 && pagingInfo.pageNum > 0,
28
+ canGotoLast: !cannotLeaveEditMode && pagingInfo.pageSize != 0 && pagingInfo.pageNum != lastPage,
29
+ canGotoPrev: !cannotLeaveEditMode && pagingInfo.pageSize != 0 && pagingInfo.pageNum > 0,
30
+ canGotoNext: !cannotLeaveEditMode && pagingInfo.pageSize != 0 && pagingInfo.pageNum < lastPage,
31
+ pagingInfo: pagingInfo
32
+ }
33
+ }
34
+
35
+ function setPageSize(n) {
36
+ dataView.setRefreshHints({
37
+ isFilterUnchanged: true
38
+ });
39
+ dataView.setPagingOptions({pageSize: n});
40
+ }
41
+
42
+ function gotoFirst() {
43
+ if (getNavState().canGotoFirst) {
44
+ dataView.setPagingOptions({pageNum: 0});
45
+ }
46
+ }
47
+
48
+ function gotoLast() {
49
+ var state = getNavState();
50
+ if (state.canGotoLast) {
51
+ dataView.setPagingOptions({pageNum: state.pagingInfo.totalPages - 1});
52
+ }
53
+ }
54
+
55
+ function gotoPrev() {
56
+ var state = getNavState();
57
+ if (state.canGotoPrev) {
58
+ dataView.setPagingOptions({pageNum: state.pagingInfo.pageNum - 1});
59
+ }
60
+ }
61
+
62
+ function gotoNext() {
63
+ var state = getNavState();
64
+ if (state.canGotoNext) {
65
+ dataView.setPagingOptions({pageNum: state.pagingInfo.pageNum + 1});
66
+ }
67
+ }
68
+
69
+ function constructPagerUI() {
70
+ $container.empty();
71
+
72
+ var $nav = $("<span class='slick-pager-nav' />").appendTo($container);
73
+ var $settings = $("<span class='slick-pager-settings' />").appendTo($container);
74
+ $status = $("<span class='slick-pager-status' />").appendTo($container);
75
+
76
+ $settings
77
+ .append("<span class='slick-pager-settings-expanded' style='display:none'>Show: <a data=0>All</a><a data='-1'>Auto</a><a data=25>25</a><a data=50>50</a><a data=100>100</a></span>");
78
+
79
+ $settings.find("a[data]").click(function (e) {
80
+ var pagesize = $(e.target).attr("data");
81
+ if (pagesize != undefined) {
82
+ if (pagesize == -1) {
83
+ var vp = grid.getViewport();
84
+ setPageSize(vp.bottom - vp.top);
85
+ } else {
86
+ setPageSize(parseInt(pagesize));
87
+ }
88
+ }
89
+ });
90
+
91
+ var icon_prefix = "<span class='ui-state-default ui-corner-all ui-icon-container'><span class='ui-icon ";
92
+ var icon_suffix = "' /></span>";
93
+
94
+ $(icon_prefix + "ui-icon-lightbulb" + icon_suffix)
95
+ .click(function () {
96
+ $(".slick-pager-settings-expanded").toggle()
97
+ })
98
+ .appendTo($settings);
99
+
100
+ $(icon_prefix + "ui-icon-seek-first" + icon_suffix)
101
+ .click(gotoFirst)
102
+ .appendTo($nav);
103
+
104
+ $(icon_prefix + "ui-icon-seek-prev" + icon_suffix)
105
+ .click(gotoPrev)
106
+ .appendTo($nav);
107
+
108
+ $(icon_prefix + "ui-icon-seek-next" + icon_suffix)
109
+ .click(gotoNext)
110
+ .appendTo($nav);
111
+
112
+ $(icon_prefix + "ui-icon-seek-end" + icon_suffix)
113
+ .click(gotoLast)
114
+ .appendTo($nav);
115
+
116
+ $container.find(".ui-icon-container")
117
+ .hover(function () {
118
+ $(this).toggleClass("ui-state-hover");
119
+ });
120
+
121
+ $container.children().wrapAll("<div class='slick-pager' />");
122
+ }
123
+
124
+
125
+ function updatePager(pagingInfo) {
126
+ var state = getNavState();
127
+
128
+ $container.find(".slick-pager-nav span").removeClass("ui-state-disabled");
129
+ if (!state.canGotoFirst) {
130
+ $container.find(".ui-icon-seek-first").addClass("ui-state-disabled");
131
+ }
132
+ if (!state.canGotoLast) {
133
+ $container.find(".ui-icon-seek-end").addClass("ui-state-disabled");
134
+ }
135
+ if (!state.canGotoNext) {
136
+ $container.find(".ui-icon-seek-next").addClass("ui-state-disabled");
137
+ }
138
+ if (!state.canGotoPrev) {
139
+ $container.find(".ui-icon-seek-prev").addClass("ui-state-disabled");
140
+ }
141
+
142
+ if (pagingInfo.pageSize == 0) {
143
+ $status.text(_options.showAllText.replace('{rowCount}', pagingInfo.totalRows + "").replace('{pageCount}', pagingInfo.totalPages + ""));
144
+ } else {
145
+ $status.text(_options.showPageText.replace('{pageNum}', pagingInfo.pageNum + 1 + "").replace('{pageCount}', pagingInfo.totalPages + ""));
146
+ }
147
+ }
148
+
149
+ init();
150
+ }
151
+
152
+ // Slick.Controls.Pager
153
+ $.extend(true, window, { Slick:{ Controls:{ Pager:SlickGridPager }}});
154
+ })(jQuery);
@@ -0,0 +1,493 @@
1
+ /***
2
+ * Contains core SlickGrid classes.
3
+ * @module Core
4
+ * @namespace Slick
5
+ */
6
+
7
+ (function ($) {
8
+ // register namespace
9
+ $.extend(true, window, {
10
+ "Slick": {
11
+ "Event": Event,
12
+ "EventData": EventData,
13
+ "EventHandler": EventHandler,
14
+ "Range": Range,
15
+ "NonDataRow": NonDataItem,
16
+ "Group": Group,
17
+ "GroupTotals": GroupTotals,
18
+ "EditorLock": EditorLock,
19
+
20
+ /***
21
+ * A global singleton editor lock.
22
+ * @class GlobalEditorLock
23
+ * @static
24
+ * @constructor
25
+ */
26
+ "GlobalEditorLock": new EditorLock(),
27
+
28
+ "keyCode": {
29
+ BACKSPACE: 8,
30
+ DELETE: 46,
31
+ DOWN: 40,
32
+ END: 35,
33
+ ENTER: 13,
34
+ ESCAPE: 27,
35
+ HOME: 36,
36
+ INSERT: 45,
37
+ LEFT: 37,
38
+ PAGE_DOWN: 34,
39
+ PAGE_UP: 33,
40
+ RIGHT: 39,
41
+ TAB: 9,
42
+ UP: 38,
43
+ A: 65
44
+ },
45
+ "preClickClassName" : "slick-edit-preclick"
46
+ }
47
+ });
48
+
49
+ /***
50
+ * An event object for passing data to event handlers and letting them control propagation.
51
+ * <p>This is pretty much identical to how W3C and jQuery implement events.</p>
52
+ * @class EventData
53
+ * @constructor
54
+ */
55
+ function EventData() {
56
+ var isPropagationStopped = false;
57
+ var isImmediatePropagationStopped = false;
58
+
59
+ /***
60
+ * Stops event from propagating up the DOM tree.
61
+ * @method stopPropagation
62
+ */
63
+ this.stopPropagation = function () {
64
+ isPropagationStopped = true;
65
+ };
66
+
67
+ /***
68
+ * Returns whether stopPropagation was called on this event object.
69
+ * @method isPropagationStopped
70
+ * @return {Boolean}
71
+ */
72
+ this.isPropagationStopped = function () {
73
+ return isPropagationStopped;
74
+ };
75
+
76
+ /***
77
+ * Prevents the rest of the handlers from being executed.
78
+ * @method stopImmediatePropagation
79
+ */
80
+ this.stopImmediatePropagation = function () {
81
+ isImmediatePropagationStopped = true;
82
+ };
83
+
84
+ /***
85
+ * Returns whether stopImmediatePropagation was called on this event object.\
86
+ * @method isImmediatePropagationStopped
87
+ * @return {Boolean}
88
+ */
89
+ this.isImmediatePropagationStopped = function () {
90
+ return isImmediatePropagationStopped;
91
+ }
92
+ }
93
+
94
+ /***
95
+ * A simple publisher-subscriber implementation.
96
+ * @class Event
97
+ * @constructor
98
+ */
99
+ function Event() {
100
+ var handlers = [];
101
+
102
+ /***
103
+ * Adds an event handler to be called when the event is fired.
104
+ * <p>Event handler will receive two arguments - an <code>EventData</code> and the <code>data</code>
105
+ * object the event was fired with.<p>
106
+ * @method subscribe
107
+ * @param fn {Function} Event handler.
108
+ */
109
+ this.subscribe = function (fn) {
110
+ handlers.push(fn);
111
+ };
112
+
113
+ /***
114
+ * Removes an event handler added with <code>subscribe(fn)</code>.
115
+ * @method unsubscribe
116
+ * @param fn {Function} Event handler to be removed.
117
+ */
118
+ this.unsubscribe = function (fn) {
119
+ for (var i = handlers.length - 1; i >= 0; i--) {
120
+ if (handlers[i] === fn) {
121
+ handlers.splice(i, 1);
122
+ }
123
+ }
124
+ };
125
+
126
+ /***
127
+ * Fires an event notifying all subscribers.
128
+ * @method notify
129
+ * @param args {Object} Additional data object to be passed to all handlers.
130
+ * @param e {EventData}
131
+ * Optional.
132
+ * An <code>EventData</code> object to be passed to all handlers.
133
+ * For DOM events, an existing W3C/jQuery event object can be passed in.
134
+ * @param scope {Object}
135
+ * Optional.
136
+ * The scope ("this") within which the handler will be executed.
137
+ * If not specified, the scope will be set to the <code>Event</code> instance.
138
+ */
139
+ this.notify = function (args, e, scope) {
140
+ e = e || new EventData();
141
+ scope = scope || this;
142
+
143
+ var returnValue;
144
+ for (var i = 0; i < handlers.length && !(e.isPropagationStopped() || e.isImmediatePropagationStopped()); i++) {
145
+ returnValue = handlers[i].call(scope, e, args);
146
+ }
147
+
148
+ return returnValue;
149
+ };
150
+ }
151
+
152
+ function EventHandler() {
153
+ var handlers = [];
154
+
155
+ this.subscribe = function (event, handler) {
156
+ handlers.push({
157
+ event: event,
158
+ handler: handler
159
+ });
160
+ event.subscribe(handler);
161
+
162
+ return this; // allow chaining
163
+ };
164
+
165
+ this.unsubscribe = function (event, handler) {
166
+ var i = handlers.length;
167
+ while (i--) {
168
+ if (handlers[i].event === event &&
169
+ handlers[i].handler === handler) {
170
+ handlers.splice(i, 1);
171
+ event.unsubscribe(handler);
172
+ return;
173
+ }
174
+ }
175
+
176
+ return this; // allow chaining
177
+ };
178
+
179
+ this.unsubscribeAll = function () {
180
+ var i = handlers.length;
181
+ while (i--) {
182
+ handlers[i].event.unsubscribe(handlers[i].handler);
183
+ }
184
+ handlers = [];
185
+
186
+ return this; // allow chaining
187
+ }
188
+ }
189
+
190
+ /***
191
+ * A structure containing a range of cells.
192
+ * @class Range
193
+ * @constructor
194
+ * @param fromRow {Integer} Starting row.
195
+ * @param fromCell {Integer} Starting cell.
196
+ * @param toRow {Integer} Optional. Ending row. Defaults to <code>fromRow</code>.
197
+ * @param toCell {Integer} Optional. Ending cell. Defaults to <code>fromCell</code>.
198
+ */
199
+ function Range(fromRow, fromCell, toRow, toCell) {
200
+ if (toRow === undefined && toCell === undefined) {
201
+ toRow = fromRow;
202
+ toCell = fromCell;
203
+ }
204
+
205
+ /***
206
+ * @property fromRow
207
+ * @type {Integer}
208
+ */
209
+ this.fromRow = Math.min(fromRow, toRow);
210
+
211
+ /***
212
+ * @property fromCell
213
+ * @type {Integer}
214
+ */
215
+ this.fromCell = Math.min(fromCell, toCell);
216
+
217
+ /***
218
+ * @property toRow
219
+ * @type {Integer}
220
+ */
221
+ this.toRow = Math.max(fromRow, toRow);
222
+
223
+ /***
224
+ * @property toCell
225
+ * @type {Integer}
226
+ */
227
+ this.toCell = Math.max(fromCell, toCell);
228
+
229
+ /***
230
+ * Returns whether a range represents a single row.
231
+ * @method isSingleRow
232
+ * @return {Boolean}
233
+ */
234
+ this.isSingleRow = function () {
235
+ return this.fromRow == this.toRow;
236
+ };
237
+
238
+ /***
239
+ * Returns whether a range represents a single cell.
240
+ * @method isSingleCell
241
+ * @return {Boolean}
242
+ */
243
+ this.isSingleCell = function () {
244
+ return this.fromRow == this.toRow && this.fromCell == this.toCell;
245
+ };
246
+
247
+ /***
248
+ * Returns whether a range contains a given cell.
249
+ * @method contains
250
+ * @param row {Integer}
251
+ * @param cell {Integer}
252
+ * @return {Boolean}
253
+ */
254
+ this.contains = function (row, cell) {
255
+ return row >= this.fromRow && row <= this.toRow &&
256
+ cell >= this.fromCell && cell <= this.toCell;
257
+ };
258
+
259
+ /***
260
+ * Returns a readable representation of a range.
261
+ * @method toString
262
+ * @return {String}
263
+ */
264
+ this.toString = function () {
265
+ if (this.isSingleCell()) {
266
+ return "(" + this.fromRow + ":" + this.fromCell + ")";
267
+ }
268
+ else {
269
+ return "(" + this.fromRow + ":" + this.fromCell + " - " + this.toRow + ":" + this.toCell + ")";
270
+ }
271
+ }
272
+ }
273
+
274
+
275
+ /***
276
+ * A base class that all special / non-data rows (like Group and GroupTotals) derive from.
277
+ * @class NonDataItem
278
+ * @constructor
279
+ */
280
+ function NonDataItem() {
281
+ this.__nonDataRow = true;
282
+ }
283
+
284
+
285
+ /***
286
+ * Information about a group of rows.
287
+ * @class Group
288
+ * @extends Slick.NonDataItem
289
+ * @constructor
290
+ */
291
+ function Group() {
292
+ this.__group = true;
293
+
294
+ /**
295
+ * Grouping level, starting with 0.
296
+ * @property level
297
+ * @type {Number}
298
+ */
299
+ this.level = 0;
300
+
301
+ /***
302
+ * Number of rows in the group.
303
+ * @property count
304
+ * @type {Integer}
305
+ */
306
+ this.count = 0;
307
+
308
+ /***
309
+ * Grouping value.
310
+ * @property value
311
+ * @type {Object}
312
+ */
313
+ this.value = null;
314
+
315
+ /***
316
+ * Formatted display value of the group.
317
+ * @property title
318
+ * @type {String}
319
+ */
320
+ this.title = null;
321
+
322
+ /***
323
+ * Whether a group is collapsed.
324
+ * @property collapsed
325
+ * @type {Boolean}
326
+ */
327
+ this.collapsed = false;
328
+
329
+ /***
330
+ * Whether a group selection checkbox is checked.
331
+ * @property selectChecked
332
+ * @type {Boolean}
333
+ */
334
+ this.selectChecked = false;
335
+
336
+ /***
337
+ * GroupTotals, if any.
338
+ * @property totals
339
+ * @type {GroupTotals}
340
+ */
341
+ this.totals = null;
342
+
343
+ /**
344
+ * Rows that are part of the group.
345
+ * @property rows
346
+ * @type {Array}
347
+ */
348
+ this.rows = [];
349
+
350
+ /**
351
+ * Sub-groups that are part of the group.
352
+ * @property groups
353
+ * @type {Array}
354
+ */
355
+ this.groups = null;
356
+
357
+ /**
358
+ * A unique key used to identify the group. This key can be used in calls to DataView
359
+ * collapseGroup() or expandGroup().
360
+ * @property groupingKey
361
+ * @type {Object}
362
+ */
363
+ this.groupingKey = null;
364
+ }
365
+
366
+ Group.prototype = new NonDataItem();
367
+
368
+ /***
369
+ * Compares two Group instances.
370
+ * @method equals
371
+ * @return {Boolean}
372
+ * @param group {Group} Group instance to compare to.
373
+ */
374
+ Group.prototype.equals = function (group) {
375
+ return this.value === group.value &&
376
+ this.count === group.count &&
377
+ this.collapsed === group.collapsed &&
378
+ this.title === group.title;
379
+ };
380
+
381
+ /***
382
+ * Information about group totals.
383
+ * An instance of GroupTotals will be created for each totals row and passed to the aggregators
384
+ * so that they can store arbitrary data in it. That data can later be accessed by group totals
385
+ * formatters during the display.
386
+ * @class GroupTotals
387
+ * @extends Slick.NonDataItem
388
+ * @constructor
389
+ */
390
+ function GroupTotals() {
391
+ this.__groupTotals = true;
392
+
393
+ /***
394
+ * Parent Group.
395
+ * @param group
396
+ * @type {Group}
397
+ */
398
+ this.group = null;
399
+
400
+ /***
401
+ * Whether the totals have been fully initialized / calculated.
402
+ * Will be set to false for lazy-calculated group totals.
403
+ * @param initialized
404
+ * @type {Boolean}
405
+ */
406
+ this.initialized = false;
407
+ }
408
+
409
+ GroupTotals.prototype = new NonDataItem();
410
+
411
+ /***
412
+ * A locking helper to track the active edit controller and ensure that only a single controller
413
+ * can be active at a time. This prevents a whole class of state and validation synchronization
414
+ * issues. An edit controller (such as SlickGrid) can query if an active edit is in progress
415
+ * and attempt a commit or cancel before proceeding.
416
+ * @class EditorLock
417
+ * @constructor
418
+ */
419
+ function EditorLock() {
420
+ var activeEditController = null;
421
+
422
+ /***
423
+ * Returns true if a specified edit controller is active (has the edit lock).
424
+ * If the parameter is not specified, returns true if any edit controller is active.
425
+ * @method isActive
426
+ * @param editController {EditController}
427
+ * @return {Boolean}
428
+ */
429
+ this.isActive = function (editController) {
430
+ return (editController ? activeEditController === editController : activeEditController !== null);
431
+ };
432
+
433
+ /***
434
+ * Sets the specified edit controller as the active edit controller (acquire edit lock).
435
+ * If another edit controller is already active, and exception will be throw new Error(.
436
+ * @method activate
437
+ * @param editController {EditController} edit controller acquiring the lock
438
+ */
439
+ this.activate = function (editController) {
440
+ if (editController === activeEditController) { // already activated?
441
+ return;
442
+ }
443
+ if (activeEditController !== null) {
444
+ throw new Error("SlickGrid.EditorLock.activate: an editController is still active, can't activate another editController");
445
+ }
446
+ if (!editController.commitCurrentEdit) {
447
+ throw new Error("SlickGrid.EditorLock.activate: editController must implement .commitCurrentEdit()");
448
+ }
449
+ if (!editController.cancelCurrentEdit) {
450
+ throw new Error("SlickGrid.EditorLock.activate: editController must implement .cancelCurrentEdit()");
451
+ }
452
+ activeEditController = editController;
453
+ };
454
+
455
+ /***
456
+ * Unsets the specified edit controller as the active edit controller (release edit lock).
457
+ * If the specified edit controller is not the active one, an exception will be throw new Error(.
458
+ * @method deactivate
459
+ * @param editController {EditController} edit controller releasing the lock
460
+ */
461
+ this.deactivate = function (editController) {
462
+ if (activeEditController !== editController) {
463
+ throw new Error("SlickGrid.EditorLock.deactivate: specified editController is not the currently active one");
464
+ }
465
+ activeEditController = null;
466
+ };
467
+
468
+ /***
469
+ * Attempts to commit the current edit by calling "commitCurrentEdit" method on the active edit
470
+ * controller and returns whether the commit attempt was successful (commit may fail due to validation
471
+ * errors, etc.). Edit controller's "commitCurrentEdit" must return true if the commit has succeeded
472
+ * and false otherwise. If no edit controller is active, returns true.
473
+ * @method commitCurrentEdit
474
+ * @return {Boolean}
475
+ */
476
+ this.commitCurrentEdit = function () {
477
+ return (activeEditController ? activeEditController.commitCurrentEdit() : true);
478
+ };
479
+
480
+ /***
481
+ * Attempts to cancel the current edit by calling "cancelCurrentEdit" method on the active edit
482
+ * controller and returns whether the edit was successfully cancelled. If no edit controller is
483
+ * active, returns true.
484
+ * @method cancelCurrentEdit
485
+ * @return {Boolean}
486
+ */
487
+ this.cancelCurrentEdit = function cancelCurrentEdit() {
488
+ return (activeEditController ? activeEditController.cancelCurrentEdit() : true);
489
+ };
490
+ }
491
+ })(jQuery);
492
+
493
+