slickgrid-bootstrap-rails 0.0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/.gitignore +34 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +158 -0
  5. data/Rakefile +1 -0
  6. data/lib/slickgrid-bootstrap-rails/version.rb +7 -0
  7. data/lib/slickgrid-bootstrap-rails.rb +11 -0
  8. data/slickgrid-bootstrap-rails.gemspec +21 -0
  9. data/vendor/assets/images/actions.gif +0 -0
  10. data/vendor/assets/images/ajax-loader-small.gif +0 -0
  11. data/vendor/assets/images/arrow_redo.png +0 -0
  12. data/vendor/assets/images/arrow_right_peppermint.png +0 -0
  13. data/vendor/assets/images/arrow_right_spearmint.png +0 -0
  14. data/vendor/assets/images/arrow_undo.png +0 -0
  15. data/vendor/assets/images/bullet_blue.png +0 -0
  16. data/vendor/assets/images/bullet_star.png +0 -0
  17. data/vendor/assets/images/bullet_toggle_minus.png +0 -0
  18. data/vendor/assets/images/bullet_toggle_plus.png +0 -0
  19. data/vendor/assets/images/calendar.gif +0 -0
  20. data/vendor/assets/images/collapse.gif +0 -0
  21. data/vendor/assets/images/comment_yellow.gif +0 -0
  22. data/vendor/assets/images/down.gif +0 -0
  23. data/vendor/assets/images/drag-handle.png +0 -0
  24. data/vendor/assets/images/editor-helper-bg.gif +0 -0
  25. data/vendor/assets/images/expand.gif +0 -0
  26. data/vendor/assets/images/header-bg.gif +0 -0
  27. data/vendor/assets/images/header-columns-bg.gif +0 -0
  28. data/vendor/assets/images/header-columns-over-bg.gif +0 -0
  29. data/vendor/assets/images/help.png +0 -0
  30. data/vendor/assets/images/info.gif +0 -0
  31. data/vendor/assets/images/listview.gif +0 -0
  32. data/vendor/assets/images/pencil.gif +0 -0
  33. data/vendor/assets/images/row-over-bg.gif +0 -0
  34. data/vendor/assets/images/sort-asc.gif +0 -0
  35. data/vendor/assets/images/sort-asc.png +0 -0
  36. data/vendor/assets/images/sort-desc.gif +0 -0
  37. data/vendor/assets/images/sort-desc.png +0 -0
  38. data/vendor/assets/images/stripes.png +0 -0
  39. data/vendor/assets/images/tag_red.png +0 -0
  40. data/vendor/assets/images/tick.png +0 -0
  41. data/vendor/assets/images/user_identity.gif +0 -0
  42. data/vendor/assets/images/user_identity_plus.gif +0 -0
  43. data/vendor/assets/javascripts/bootstrap/slick.bootstrap.js +86 -0
  44. data/vendor/assets/javascripts/plugins/slick.autotooltips.js +48 -0
  45. data/vendor/assets/javascripts/plugins/slick.cellcopymanager.js +86 -0
  46. data/vendor/assets/javascripts/plugins/slick.cellrangedecorator.js +64 -0
  47. data/vendor/assets/javascripts/plugins/slick.cellrangeselector.js +111 -0
  48. data/vendor/assets/javascripts/plugins/slick.cellselectionmodel.js +92 -0
  49. data/vendor/assets/javascripts/plugins/slick.checkboxselectcolumn.js +153 -0
  50. data/vendor/assets/javascripts/plugins/slick.headerbuttons.js +177 -0
  51. data/vendor/assets/javascripts/plugins/slick.headermenu.js +272 -0
  52. data/vendor/assets/javascripts/plugins/slick.rowmovemanager.js +138 -0
  53. data/vendor/assets/javascripts/plugins/slick.rowselectionmodel.js +187 -0
  54. data/vendor/assets/javascripts/slick.core.js +430 -0
  55. data/vendor/assets/javascripts/slick.dataview.js +917 -0
  56. data/vendor/assets/javascripts/slick.editors.js.erb +512 -0
  57. data/vendor/assets/javascripts/slick.formatters.js.erb +55 -0
  58. data/vendor/assets/javascripts/slick.grid.js +3294 -0
  59. data/vendor/assets/javascripts/slick.groupitemmetadataprovider.js +139 -0
  60. data/vendor/assets/javascripts/slick.remotemodel.js +164 -0
  61. data/vendor/assets/javascripts/slickgrid-bootstrap-rails.js +13 -0
  62. data/vendor/assets/stylesheets/plugins/slick.headerbuttons.css +38 -0
  63. data/vendor/assets/stylesheets/plugins/slick.headermenu.css +58 -0
  64. data/vendor/assets/stylesheets/slick.grid.css.erb +157 -0
  65. data/vendor/assets/stylesheets/slickgrid-bootstrap-rails.css +4 -0
  66. data/vendor/assets/stylesheets/slickgrid-bootstrap.less +159 -0
  67. metadata +143 -0
@@ -0,0 +1,430 @@
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
+ });
29
+
30
+ /***
31
+ * An event object for passing data to event handlers and letting them control propagation.
32
+ * <p>This is pretty much identical to how W3C and jQuery implement events.</p>
33
+ * @class EventData
34
+ * @constructor
35
+ */
36
+ function EventData() {
37
+ var isPropagationStopped = false;
38
+ var isImmediatePropagationStopped = false;
39
+
40
+ /***
41
+ * Stops event from propagating up the DOM tree.
42
+ * @method stopPropagation
43
+ */
44
+ this.stopPropagation = function () {
45
+ isPropagationStopped = true;
46
+ };
47
+
48
+ /***
49
+ * Returns whether stopPropagation was called on this event object.
50
+ * @method isPropagationStopped
51
+ * @return {Boolean}
52
+ */
53
+ this.isPropagationStopped = function () {
54
+ return isPropagationStopped;
55
+ };
56
+
57
+ /***
58
+ * Prevents the rest of the handlers from being executed.
59
+ * @method stopImmediatePropagation
60
+ */
61
+ this.stopImmediatePropagation = function () {
62
+ isImmediatePropagationStopped = true;
63
+ };
64
+
65
+ /***
66
+ * Returns whether stopImmediatePropagation was called on this event object.\
67
+ * @method isImmediatePropagationStopped
68
+ * @return {Boolean}
69
+ */
70
+ this.isImmediatePropagationStopped = function () {
71
+ return isImmediatePropagationStopped;
72
+ }
73
+ }
74
+
75
+ /***
76
+ * A simple publisher-subscriber implementation.
77
+ * @class Event
78
+ * @constructor
79
+ */
80
+ function Event() {
81
+ var handlers = [];
82
+
83
+ /***
84
+ * Adds an event handler to be called when the event is fired.
85
+ * <p>Event handler will receive two arguments - an <code>EventData</code> and the <code>data</code>
86
+ * object the event was fired with.<p>
87
+ * @method subscribe
88
+ * @param fn {Function} Event handler.
89
+ */
90
+ this.subscribe = function (fn) {
91
+ handlers.push(fn);
92
+ };
93
+
94
+ /***
95
+ * Removes an event handler added with <code>subscribe(fn)</code>.
96
+ * @method unsubscribe
97
+ * @param fn {Function} Event handler to be removed.
98
+ */
99
+ this.unsubscribe = function (fn) {
100
+ for (var i = handlers.length - 1; i >= 0; i--) {
101
+ if (handlers[i] === fn) {
102
+ handlers.splice(i, 1);
103
+ }
104
+ }
105
+ };
106
+
107
+ /***
108
+ * Fires an event notifying all subscribers.
109
+ * @method notify
110
+ * @param args {Object} Additional data object to be passed to all handlers.
111
+ * @param e {EventData}
112
+ * Optional.
113
+ * An <code>EventData</code> object to be passed to all handlers.
114
+ * For DOM events, an existing W3C/jQuery event object can be passed in.
115
+ * @param scope {Object}
116
+ * Optional.
117
+ * The scope ("this") within which the handler will be executed.
118
+ * If not specified, the scope will be set to the <code>Event</code> instance.
119
+ */
120
+ this.notify = function (args, e, scope) {
121
+ e = e || new EventData();
122
+ scope = scope || this;
123
+
124
+ var returnValue;
125
+ for (var i = 0; i < handlers.length && !(e.isPropagationStopped() || e.isImmediatePropagationStopped()); i++) {
126
+ returnValue = handlers[i].call(scope, e, args);
127
+ }
128
+
129
+ return returnValue;
130
+ };
131
+ }
132
+
133
+ function EventHandler() {
134
+ var handlers = [];
135
+
136
+ this.subscribe = function (event, handler) {
137
+ handlers.push({
138
+ event: event,
139
+ handler: handler
140
+ });
141
+ event.subscribe(handler);
142
+
143
+ return this; // allow chaining
144
+ };
145
+
146
+ this.unsubscribe = function (event, handler) {
147
+ var i = handlers.length;
148
+ while (i--) {
149
+ if (handlers[i].event === event &&
150
+ handlers[i].handler === handler) {
151
+ handlers.splice(i, 1);
152
+ event.unsubscribe(handler);
153
+ return;
154
+ }
155
+ }
156
+
157
+ return this; // allow chaining
158
+ };
159
+
160
+ this.unsubscribeAll = function () {
161
+ var i = handlers.length;
162
+ while (i--) {
163
+ handlers[i].event.unsubscribe(handlers[i].handler);
164
+ }
165
+ handlers = [];
166
+
167
+ return this; // allow chaining
168
+ }
169
+ }
170
+
171
+ /***
172
+ * A structure containing a range of cells.
173
+ * @class Range
174
+ * @constructor
175
+ * @param fromRow {Integer} Starting row.
176
+ * @param fromCell {Integer} Starting cell.
177
+ * @param toRow {Integer} Optional. Ending row. Defaults to <code>fromRow</code>.
178
+ * @param toCell {Integer} Optional. Ending cell. Defaults to <code>fromCell</code>.
179
+ */
180
+ function Range(fromRow, fromCell, toRow, toCell) {
181
+ if (toRow === undefined && toCell === undefined) {
182
+ toRow = fromRow;
183
+ toCell = fromCell;
184
+ }
185
+
186
+ /***
187
+ * @property fromRow
188
+ * @type {Integer}
189
+ */
190
+ this.fromRow = Math.min(fromRow, toRow);
191
+
192
+ /***
193
+ * @property fromCell
194
+ * @type {Integer}
195
+ */
196
+ this.fromCell = Math.min(fromCell, toCell);
197
+
198
+ /***
199
+ * @property toRow
200
+ * @type {Integer}
201
+ */
202
+ this.toRow = Math.max(fromRow, toRow);
203
+
204
+ /***
205
+ * @property toCell
206
+ * @type {Integer}
207
+ */
208
+ this.toCell = Math.max(fromCell, toCell);
209
+
210
+ /***
211
+ * Returns whether a range represents a single row.
212
+ * @method isSingleRow
213
+ * @return {Boolean}
214
+ */
215
+ this.isSingleRow = function () {
216
+ return this.fromRow == this.toRow;
217
+ };
218
+
219
+ /***
220
+ * Returns whether a range represents a single cell.
221
+ * @method isSingleCell
222
+ * @return {Boolean}
223
+ */
224
+ this.isSingleCell = function () {
225
+ return this.fromRow == this.toRow && this.fromCell == this.toCell;
226
+ };
227
+
228
+ /***
229
+ * Returns whether a range contains a given cell.
230
+ * @method contains
231
+ * @param row {Integer}
232
+ * @param cell {Integer}
233
+ * @return {Boolean}
234
+ */
235
+ this.contains = function (row, cell) {
236
+ return row >= this.fromRow && row <= this.toRow &&
237
+ cell >= this.fromCell && cell <= this.toCell;
238
+ };
239
+
240
+ /***
241
+ * Returns a readable representation of a range.
242
+ * @method toString
243
+ * @return {String}
244
+ */
245
+ this.toString = function () {
246
+ if (this.isSingleCell()) {
247
+ return "(" + this.fromRow + ":" + this.fromCell + ")";
248
+ }
249
+ else {
250
+ return "(" + this.fromRow + ":" + this.fromCell + " - " + this.toRow + ":" + this.toCell + ")";
251
+ }
252
+ }
253
+ }
254
+
255
+
256
+ /***
257
+ * A base class that all special / non-data rows (like Group and GroupTotals) derive from.
258
+ * @class NonDataItem
259
+ * @constructor
260
+ */
261
+ function NonDataItem() {
262
+ this.__nonDataRow = true;
263
+ }
264
+
265
+
266
+ /***
267
+ * Information about a group of rows.
268
+ * @class Group
269
+ * @extends Slick.NonDataItem
270
+ * @constructor
271
+ */
272
+ function Group() {
273
+ this.__group = true;
274
+ this.__updated = false;
275
+
276
+ /***
277
+ * Number of rows in the group.
278
+ * @property count
279
+ * @type {Integer}
280
+ */
281
+ this.count = 0;
282
+
283
+ /***
284
+ * Grouping value.
285
+ * @property value
286
+ * @type {Object}
287
+ */
288
+ this.value = null;
289
+
290
+ /***
291
+ * Formatted display value of the group.
292
+ * @property title
293
+ * @type {String}
294
+ */
295
+ this.title = null;
296
+
297
+ /***
298
+ * Whether a group is collapsed.
299
+ * @property collapsed
300
+ * @type {Boolean}
301
+ */
302
+ this.collapsed = false;
303
+
304
+ /***
305
+ * GroupTotals, if any.
306
+ * @property totals
307
+ * @type {GroupTotals}
308
+ */
309
+ this.totals = null;
310
+ }
311
+
312
+ Group.prototype = new NonDataItem();
313
+
314
+ /***
315
+ * Compares two Group instances.
316
+ * @method equals
317
+ * @return {Boolean}
318
+ * @param group {Group} Group instance to compare to.
319
+ */
320
+ Group.prototype.equals = function (group) {
321
+ return this.value === group.value &&
322
+ this.count === group.count &&
323
+ this.collapsed === group.collapsed;
324
+ };
325
+
326
+ /***
327
+ * Information about group totals.
328
+ * An instance of GroupTotals will be created for each totals row and passed to the aggregators
329
+ * so that they can store arbitrary data in it. That data can later be accessed by group totals
330
+ * formatters during the display.
331
+ * @class GroupTotals
332
+ * @extends Slick.NonDataItem
333
+ * @constructor
334
+ */
335
+ function GroupTotals() {
336
+ this.__groupTotals = true;
337
+
338
+ /***
339
+ * Parent Group.
340
+ * @param group
341
+ * @type {Group}
342
+ */
343
+ this.group = null;
344
+ }
345
+
346
+ GroupTotals.prototype = new NonDataItem();
347
+
348
+ /***
349
+ * A locking helper to track the active edit controller and ensure that only a single controller
350
+ * can be active at a time. This prevents a whole class of state and validation synchronization
351
+ * issues. An edit controller (such as SlickGrid) can query if an active edit is in progress
352
+ * and attempt a commit or cancel before proceeding.
353
+ * @class EditorLock
354
+ * @constructor
355
+ */
356
+ function EditorLock() {
357
+ var activeEditController = null;
358
+
359
+ /***
360
+ * Returns true if a specified edit controller is active (has the edit lock).
361
+ * If the parameter is not specified, returns true if any edit controller is active.
362
+ * @method isActive
363
+ * @param editController {EditController}
364
+ * @return {Boolean}
365
+ */
366
+ this.isActive = function (editController) {
367
+ return (editController ? activeEditController === editController : activeEditController !== null);
368
+ };
369
+
370
+ /***
371
+ * Sets the specified edit controller as the active edit controller (acquire edit lock).
372
+ * If another edit controller is already active, and exception will be thrown.
373
+ * @method activate
374
+ * @param editController {EditController} edit controller acquiring the lock
375
+ */
376
+ this.activate = function (editController) {
377
+ if (editController === activeEditController) { // already activated?
378
+ return;
379
+ }
380
+ if (activeEditController !== null) {
381
+ throw "SlickGrid.EditorLock.activate: an editController is still active, can't activate another editController";
382
+ }
383
+ if (!editController.commitCurrentEdit) {
384
+ throw "SlickGrid.EditorLock.activate: editController must implement .commitCurrentEdit()";
385
+ }
386
+ if (!editController.cancelCurrentEdit) {
387
+ throw "SlickGrid.EditorLock.activate: editController must implement .cancelCurrentEdit()";
388
+ }
389
+ activeEditController = editController;
390
+ };
391
+
392
+ /***
393
+ * Unsets the specified edit controller as the active edit controller (release edit lock).
394
+ * If the specified edit controller is not the active one, an exception will be thrown.
395
+ * @method deactivate
396
+ * @param editController {EditController} edit controller releasing the lock
397
+ */
398
+ this.deactivate = function (editController) {
399
+ if (activeEditController !== editController) {
400
+ throw "SlickGrid.EditorLock.deactivate: specified editController is not the currently active one";
401
+ }
402
+ activeEditController = null;
403
+ };
404
+
405
+ /***
406
+ * Attempts to commit the current edit by calling "commitCurrentEdit" method on the active edit
407
+ * controller and returns whether the commit attempt was successful (commit may fail due to validation
408
+ * errors, etc.). Edit controller's "commitCurrentEdit" must return true if the commit has succeeded
409
+ * and false otherwise. If no edit controller is active, returns true.
410
+ * @method commitCurrentEdit
411
+ * @return {Boolean}
412
+ */
413
+ this.commitCurrentEdit = function () {
414
+ return (activeEditController ? activeEditController.commitCurrentEdit() : true);
415
+ };
416
+
417
+ /***
418
+ * Attempts to cancel the current edit by calling "cancelCurrentEdit" method on the active edit
419
+ * controller and returns whether the edit was successfully cancelled. If no edit controller is
420
+ * active, returns true.
421
+ * @method cancelCurrentEdit
422
+ * @return {Boolean}
423
+ */
424
+ this.cancelCurrentEdit = function cancelCurrentEdit() {
425
+ return (activeEditController ? activeEditController.cancelCurrentEdit() : true);
426
+ };
427
+ }
428
+ })(jQuery);
429
+
430
+