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