1 |
85ad3d82
|
Assos Assos
|
(function ($) {
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
Drupal.behaviors.tableDrag = {
|
15 |
|
|
attach: function (context, settings) {
|
16 |
|
|
for (var base in settings.tableDrag) {
|
17 |
|
|
$('#' + base, context).once('tabledrag', function () {
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
Drupal.tableDrag[base] = new Drupal.tableDrag(this, settings.tableDrag[base]);
|
21 |
|
|
});
|
22 |
|
|
}
|
23 |
|
|
}
|
24 |
|
|
};
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
Drupal.tableDrag = function (table, tableSettings) {
|
35 |
|
|
var self = this;
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
this.table = table;
|
39 |
|
|
this.tableSettings = tableSettings;
|
40 |
|
|
this.dragObject = null;
|
41 |
|
|
this.rowObject = null;
|
42 |
|
|
this.oldRowElement = null;
|
43 |
|
|
this.oldY = 0;
|
44 |
|
|
this.changed = false;
|
45 |
|
|
this.maxDepth = 0;
|
46 |
|
|
this.rtl = $(this.table).css('direction') == 'rtl' ? -1 : 1;
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
this.scrollSettings = { amount: 4, interval: 50, trigger: 70 };
|
50 |
|
|
this.scrollInterval = null;
|
51 |
|
|
this.scrollY = 0;
|
52 |
|
|
this.windowHeight = 0;
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
this.indentEnabled = false;
|
58 |
|
|
for (var group in tableSettings) {
|
59 |
|
|
for (var n in tableSettings[group]) {
|
60 |
|
|
if (tableSettings[group][n].relationship == 'parent') {
|
61 |
|
|
this.indentEnabled = true;
|
62 |
|
|
}
|
63 |
|
|
if (tableSettings[group][n].limit > 0) {
|
64 |
|
|
this.maxDepth = tableSettings[group][n].limit;
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
if (this.indentEnabled) {
|
69 |
|
|
this.indentCount = 1;
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
var indent = Drupal.theme('tableDragIndentation');
|
75 |
|
|
var testRow = $('<tr/>').addClass('draggable').appendTo(table);
|
76 |
|
|
var testCell = $('<td/>').appendTo(testRow).prepend(indent).prepend(indent);
|
77 |
|
|
this.indentAmount = $('.indentation', testCell).get(1).offsetLeft - $('.indentation', testCell).get(0).offsetLeft;
|
78 |
|
|
testRow.remove();
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
$('> tr.draggable, > tbody > tr.draggable', table).each(function () { self.makeDraggable(this); });
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
$(table).before($('<a href="#" class="tabledrag-toggle-weight"></a>')
|
87 |
|
|
.attr('title', Drupal.t('Re-order rows by numerical weight instead of dragging.'))
|
88 |
|
|
.click(function () {
|
89 |
|
|
if ($.cookie('Drupal.tableDrag.showWeight') == 1) {
|
90 |
|
|
self.hideColumns();
|
91 |
|
|
}
|
92 |
|
|
else {
|
93 |
|
|
self.showColumns();
|
94 |
|
|
}
|
95 |
|
|
return false;
|
96 |
|
|
})
|
97 |
|
|
.wrap('<div class="tabledrag-toggle-weight-wrapper"></div>')
|
98 |
|
|
.parent()
|
99 |
|
|
);
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
self.initColumns();
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
$(document).bind('mousemove', function (event) { return self.dragRow(event, self); });
|
110 |
|
|
$(document).bind('mouseup', function (event) { return self.dropRow(event, self); });
|
111 |
|
|
};
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
Drupal.tableDrag.prototype.initColumns = function () {
|
122 |
|
|
for (var group in this.tableSettings) {
|
123 |
|
|
|
124 |
|
|
for (var d in this.tableSettings[group]) {
|
125 |
|
|
var field = $('.' + this.tableSettings[group][d].target + ':first', this.table);
|
126 |
|
|
if (field.length && this.tableSettings[group][d].hidden) {
|
127 |
|
|
var hidden = this.tableSettings[group][d].hidden;
|
128 |
|
|
var cell = field.closest('td');
|
129 |
|
|
break;
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
if (hidden && cell[0]) {
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
var columnIndex = $('> td', cell.parent()).index(cell.get(0)) + 1;
|
138 |
|
|
$('> thead > tr, > tbody > tr, > tr', this.table).each(function () {
|
139 |
|
|
|
140 |
|
|
var index = columnIndex;
|
141 |
|
|
var cells = $(this).children();
|
142 |
|
|
cells.each(function (n) {
|
143 |
|
|
if (n < index && this.colSpan && this.colSpan > 1) {
|
144 |
|
|
index -= this.colSpan - 1;
|
145 |
|
|
}
|
146 |
|
|
});
|
147 |
|
|
if (index > 0) {
|
148 |
|
|
cell = cells.filter(':nth-child(' + index + ')');
|
149 |
|
|
if (cell[0].colSpan && cell[0].colSpan > 1) {
|
150 |
|
|
|
151 |
|
|
cell.addClass('tabledrag-has-colspan');
|
152 |
|
|
}
|
153 |
|
|
else {
|
154 |
|
|
|
155 |
|
|
cell.addClass('tabledrag-hide');
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
});
|
159 |
|
|
}
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
if ($.cookie('Drupal.tableDrag.showWeight') === null) {
|
165 |
|
|
$.cookie('Drupal.tableDrag.showWeight', 0, {
|
166 |
|
|
path: Drupal.settings.basePath,
|
167 |
|
|
|
168 |
|
|
expires: 365
|
169 |
|
|
});
|
170 |
|
|
this.hideColumns();
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
else {
|
174 |
|
|
if ($.cookie('Drupal.tableDrag.showWeight') == 1) {
|
175 |
|
|
this.showColumns();
|
176 |
|
|
}
|
177 |
|
|
else {
|
178 |
|
|
this.hideColumns();
|
179 |
|
|
}
|
180 |
|
|
}
|
181 |
|
|
};
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
Drupal.tableDrag.prototype.hideColumns = function () {
|
188 |
|
|
|
189 |
|
|
$('.tabledrag-hide', 'table.tabledrag-processed').css('display', 'none');
|
190 |
|
|
|
191 |
|
|
$('.tabledrag-handle', 'table.tabledrag-processed').css('display', '');
|
192 |
|
|
|
193 |
|
|
$('.tabledrag-has-colspan', 'table.tabledrag-processed').each(function () {
|
194 |
|
|
this.colSpan = this.colSpan - 1;
|
195 |
|
|
});
|
196 |
|
|
|
197 |
|
|
$('.tabledrag-toggle-weight').text(Drupal.t('Show row weights'));
|
198 |
|
|
|
199 |
|
|
$.cookie('Drupal.tableDrag.showWeight', 0, {
|
200 |
|
|
path: Drupal.settings.basePath,
|
201 |
|
|
|
202 |
|
|
expires: 365
|
203 |
|
|
});
|
204 |
|
|
|
205 |
|
|
$('table.tabledrag-processed').trigger('columnschange', 'hide');
|
206 |
|
|
};
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
Drupal.tableDrag.prototype.showColumns = function () {
|
213 |
|
|
|
214 |
|
|
$('.tabledrag-hide', 'table.tabledrag-processed').css('display', '');
|
215 |
|
|
|
216 |
|
|
$('.tabledrag-handle', 'table.tabledrag-processed').css('display', 'none');
|
217 |
|
|
|
218 |
|
|
$('.tabledrag-has-colspan', 'table.tabledrag-processed').each(function () {
|
219 |
|
|
this.colSpan = this.colSpan + 1;
|
220 |
|
|
});
|
221 |
|
|
|
222 |
|
|
$('.tabledrag-toggle-weight').text(Drupal.t('Hide row weights'));
|
223 |
|
|
|
224 |
|
|
$.cookie('Drupal.tableDrag.showWeight', 1, {
|
225 |
|
|
path: Drupal.settings.basePath,
|
226 |
|
|
|
227 |
|
|
expires: 365
|
228 |
|
|
});
|
229 |
|
|
|
230 |
|
|
$('table.tabledrag-processed').trigger('columnschange', 'show');
|
231 |
|
|
};
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
Drupal.tableDrag.prototype.rowSettings = function (group, row) {
|
237 |
|
|
var field = $('.' + group, row);
|
238 |
|
|
for (var delta in this.tableSettings[group]) {
|
239 |
|
|
var targetClass = this.tableSettings[group][delta].target;
|
240 |
|
|
if (field.is('.' + targetClass)) {
|
241 |
|
|
|
242 |
|
|
var rowSettings = {};
|
243 |
|
|
for (var n in this.tableSettings[group][delta]) {
|
244 |
|
|
rowSettings[n] = this.tableSettings[group][delta][n];
|
245 |
|
|
}
|
246 |
|
|
return rowSettings;
|
247 |
|
|
}
|
248 |
|
|
}
|
249 |
|
|
};
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
Drupal.tableDrag.prototype.makeDraggable = function (item) {
|
255 |
|
|
var self = this;
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
var handle = $('<a href="#" class="tabledrag-handle"><div class="handle"> </div></a>').attr('title', Drupal.t('Drag to re-order'));
|
259 |
|
|
|
260 |
|
|
if ($('td:first .indentation:last', item).length) {
|
261 |
|
|
$('td:first .indentation:last', item).after(handle);
|
262 |
|
|
|
263 |
|
|
self.indentCount = Math.max($('.indentation', item).length, self.indentCount);
|
264 |
|
|
}
|
265 |
|
|
else {
|
266 |
|
|
$('td:first', item).prepend(handle);
|
267 |
|
|
}
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
handle.hover(function () {
|
271 |
|
|
self.dragObject == null ? $(this).addClass('tabledrag-handle-hover') : null;
|
272 |
|
|
}, function () {
|
273 |
|
|
self.dragObject == null ? $(this).removeClass('tabledrag-handle-hover') : null;
|
274 |
|
|
});
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
handle.mousedown(function (event) {
|
278 |
|
|
|
279 |
|
|
self.dragObject = {};
|
280 |
|
|
self.dragObject.initMouseOffset = self.getMouseOffset(item, event);
|
281 |
|
|
self.dragObject.initMouseCoords = self.mouseCoords(event);
|
282 |
|
|
if (self.indentEnabled) {
|
283 |
|
|
self.dragObject.indentMousePos = self.dragObject.initMouseCoords;
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
if (self.rowObject) {
|
288 |
|
|
$('a.tabledrag-handle', self.rowObject.element).blur();
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
|
292 |
|
|
self.rowObject = new self.row(item, 'mouse', self.indentEnabled, self.maxDepth, true);
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
self.table.topY = $(self.table).offset().top;
|
296 |
|
|
self.table.bottomY = self.table.topY + self.table.offsetHeight;
|
297 |
|
|
|
298 |
|
|
|
299 |
|
|
$(this).addClass('tabledrag-handle-hover');
|
300 |
|
|
$(item).addClass('drag');
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
$('body').addClass('drag');
|
304 |
|
|
if (self.oldRowElement) {
|
305 |
|
|
$(self.oldRowElement).removeClass('drag-previous');
|
306 |
|
|
}
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
if (navigator.userAgent.indexOf('MSIE 6.') != -1) {
|
310 |
|
|
$('select', this.table).css('display', 'none');
|
311 |
|
|
}
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
self.safeBlur = false;
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
self.onDrag();
|
319 |
|
|
return false;
|
320 |
|
|
});
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
handle.click(function () {
|
324 |
|
|
return false;
|
325 |
|
|
});
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
handle.focus(function () {
|
329 |
|
|
$(this).addClass('tabledrag-handle-hover');
|
330 |
|
|
self.safeBlur = true;
|
331 |
|
|
});
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
handle.blur(function (event) {
|
335 |
|
|
$(this).removeClass('tabledrag-handle-hover');
|
336 |
|
|
if (self.rowObject && self.safeBlur) {
|
337 |
|
|
self.dropRow(event, self);
|
338 |
|
|
}
|
339 |
|
|
});
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
handle.keydown(function (event) {
|
343 |
|
|
|
344 |
|
|
if (event.keyCode != 9 && !self.rowObject) {
|
345 |
|
|
self.rowObject = new self.row(item, 'keyboard', self.indentEnabled, self.maxDepth, true);
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
var keyChange = false;
|
349 |
|
|
switch (event.keyCode) {
|
350 |
|
|
case 37:
|
351 |
|
|
case 63234:
|
352 |
|
|
keyChange = true;
|
353 |
|
|
self.rowObject.indent(-1 * self.rtl);
|
354 |
|
|
break;
|
355 |
|
|
case 38:
|
356 |
|
|
case 63232:
|
357 |
|
|
var previousRow = $(self.rowObject.element).prev('tr').get(0);
|
358 |
|
|
while (previousRow && $(previousRow).is(':hidden')) {
|
359 |
|
|
previousRow = $(previousRow).prev('tr').get(0);
|
360 |
|
|
}
|
361 |
|
|
if (previousRow) {
|
362 |
|
|
self.safeBlur = false;
|
363 |
|
|
self.rowObject.direction = 'up';
|
364 |
|
|
keyChange = true;
|
365 |
|
|
|
366 |
|
|
if ($(item).is('.tabledrag-root')) {
|
367 |
|
|
|
368 |
|
|
var groupHeight = 0;
|
369 |
|
|
while (previousRow && $('.indentation', previousRow).length) {
|
370 |
|
|
previousRow = $(previousRow).prev('tr').get(0);
|
371 |
|
|
groupHeight += $(previousRow).is(':hidden') ? 0 : previousRow.offsetHeight;
|
372 |
|
|
}
|
373 |
|
|
if (previousRow) {
|
374 |
|
|
self.rowObject.swap('before', previousRow);
|
375 |
|
|
|
376 |
|
|
window.scrollBy(0, -groupHeight);
|
377 |
|
|
}
|
378 |
|
|
}
|
379 |
|
|
else if (self.table.tBodies[0].rows[0] != previousRow || $(previousRow).is('.draggable')) {
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
self.rowObject.swap('before', previousRow);
|
383 |
|
|
self.rowObject.interval = null;
|
384 |
|
|
self.rowObject.indent(0);
|
385 |
|
|
window.scrollBy(0, -parseInt(item.offsetHeight, 10));
|
386 |
|
|
}
|
387 |
|
|
handle.get(0).focus();
|
388 |
|
|
}
|
389 |
|
|
break;
|
390 |
|
|
case 39:
|
391 |
|
|
case 63235:
|
392 |
|
|
keyChange = true;
|
393 |
|
|
self.rowObject.indent(1 * self.rtl);
|
394 |
|
|
break;
|
395 |
|
|
case 40:
|
396 |
|
|
case 63233:
|
397 |
|
|
var nextRow = $(self.rowObject.group).filter(':last').next('tr').get(0);
|
398 |
|
|
while (nextRow && $(nextRow).is(':hidden')) {
|
399 |
|
|
nextRow = $(nextRow).next('tr').get(0);
|
400 |
|
|
}
|
401 |
|
|
if (nextRow) {
|
402 |
|
|
self.safeBlur = false;
|
403 |
|
|
self.rowObject.direction = 'down';
|
404 |
|
|
keyChange = true;
|
405 |
|
|
|
406 |
|
|
if ($(item).is('.tabledrag-root')) {
|
407 |
|
|
|
408 |
|
|
var groupHeight = 0;
|
409 |
|
|
var nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false);
|
410 |
|
|
if (nextGroup) {
|
411 |
|
|
$(nextGroup.group).each(function () {
|
412 |
|
|
groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight;
|
413 |
|
|
});
|
414 |
|
|
var nextGroupRow = $(nextGroup.group).filter(':last').get(0);
|
415 |
|
|
self.rowObject.swap('after', nextGroupRow);
|
416 |
|
|
|
417 |
|
|
window.scrollBy(0, parseInt(groupHeight, 10));
|
418 |
|
|
}
|
419 |
|
|
}
|
420 |
|
|
else {
|
421 |
|
|
|
422 |
|
|
self.rowObject.swap('after', nextRow);
|
423 |
|
|
self.rowObject.interval = null;
|
424 |
|
|
self.rowObject.indent(0);
|
425 |
|
|
window.scrollBy(0, parseInt(item.offsetHeight, 10));
|
426 |
|
|
}
|
427 |
|
|
handle.get(0).focus();
|
428 |
|
|
}
|
429 |
|
|
break;
|
430 |
|
|
}
|
431 |
|
|
|
432 |
|
|
if (self.rowObject && self.rowObject.changed == true) {
|
433 |
|
|
$(item).addClass('drag');
|
434 |
|
|
if (self.oldRowElement) {
|
435 |
|
|
$(self.oldRowElement).removeClass('drag-previous');
|
436 |
|
|
}
|
437 |
|
|
self.oldRowElement = item;
|
438 |
|
|
self.restripeTable();
|
439 |
|
|
self.onDrag();
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
|
443 |
|
|
if (keyChange) {
|
444 |
|
|
return false;
|
445 |
|
|
}
|
446 |
|
|
});
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
handle.keypress(function (event) {
|
452 |
|
|
switch (event.keyCode) {
|
453 |
|
|
case 37:
|
454 |
|
|
case 38:
|
455 |
|
|
case 39:
|
456 |
|
|
case 40:
|
457 |
|
|
return false;
|
458 |
|
|
}
|
459 |
|
|
});
|
460 |
|
|
};
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
Drupal.tableDrag.prototype.dragRow = function (event, self) {
|
466 |
|
|
if (self.dragObject) {
|
467 |
|
|
self.currentMouseCoords = self.mouseCoords(event);
|
468 |
|
|
|
469 |
|
|
var y = self.currentMouseCoords.y - self.dragObject.initMouseOffset.y;
|
470 |
|
|
var x = self.currentMouseCoords.x - self.dragObject.initMouseOffset.x;
|
471 |
|
|
|
472 |
|
|
|
473 |
|
|
if (y != self.oldY) {
|
474 |
|
|
self.rowObject.direction = y > self.oldY ? 'down' : 'up';
|
475 |
|
|
self.oldY = y;
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
var scrollAmount = self.checkScroll(self.currentMouseCoords.y);
|
479 |
|
|
|
480 |
|
|
clearInterval(self.scrollInterval);
|
481 |
|
|
|
482 |
|
|
if (scrollAmount > 0 && self.rowObject.direction == 'down' || scrollAmount < 0 && self.rowObject.direction == 'up') {
|
483 |
|
|
self.setScroll(scrollAmount);
|
484 |
|
|
}
|
485 |
|
|
|
486 |
|
|
|
487 |
|
|
var currentRow = self.findDropTargetRow(x, y);
|
488 |
|
|
if (currentRow) {
|
489 |
|
|
if (self.rowObject.direction == 'down') {
|
490 |
|
|
self.rowObject.swap('after', currentRow, self);
|
491 |
|
|
}
|
492 |
|
|
else {
|
493 |
|
|
self.rowObject.swap('before', currentRow, self);
|
494 |
|
|
}
|
495 |
|
|
self.restripeTable();
|
496 |
|
|
}
|
497 |
|
|
}
|
498 |
|
|
|
499 |
|
|
|
500 |
|
|
if (self.indentEnabled) {
|
501 |
|
|
var xDiff = self.currentMouseCoords.x - self.dragObject.indentMousePos.x;
|
502 |
|
|
|
503 |
|
|
var indentDiff = Math.round(xDiff / self.indentAmount * self.rtl);
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
var indentChange = self.rowObject.indent(indentDiff);
|
507 |
|
|
|
508 |
|
|
self.dragObject.indentMousePos.x += self.indentAmount * indentChange * self.rtl;
|
509 |
|
|
self.indentCount = Math.max(self.indentCount, self.rowObject.indents);
|
510 |
|
|
}
|
511 |
|
|
|
512 |
|
|
return false;
|
513 |
|
|
}
|
514 |
|
|
};
|
515 |
|
|
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
|
520 |
|
|
Drupal.tableDrag.prototype.dropRow = function (event, self) {
|
521 |
|
|
|
522 |
|
|
if (self.rowObject != null) {
|
523 |
|
|
var droppedRow = self.rowObject.element;
|
524 |
|
|
|
525 |
|
|
if (self.rowObject.changed == true) {
|
526 |
|
|
|
527 |
|
|
self.updateFields(droppedRow);
|
528 |
|
|
|
529 |
|
|
|
530 |
|
|
|
531 |
|
|
for (var group in self.tableSettings) {
|
532 |
|
|
var rowSettings = self.rowSettings(group, droppedRow);
|
533 |
|
|
if (rowSettings.relationship == 'group') {
|
534 |
|
|
for (var n in self.rowObject.children) {
|
535 |
|
|
self.updateField(self.rowObject.children[n], group);
|
536 |
|
|
}
|
537 |
|
|
}
|
538 |
|
|
}
|
539 |
|
|
|
540 |
|
|
self.rowObject.markChanged();
|
541 |
|
|
if (self.changed == false) {
|
542 |
|
|
$(Drupal.theme('tableDragChangedWarning')).insertBefore(self.table).hide().fadeIn('slow');
|
543 |
|
|
self.changed = true;
|
544 |
|
|
}
|
545 |
|
|
}
|
546 |
|
|
|
547 |
|
|
if (self.indentEnabled) {
|
548 |
|
|
self.rowObject.removeIndentClasses();
|
549 |
|
|
}
|
550 |
|
|
if (self.oldRowElement) {
|
551 |
|
|
$(self.oldRowElement).removeClass('drag-previous');
|
552 |
|
|
}
|
553 |
|
|
$(droppedRow).removeClass('drag').addClass('drag-previous');
|
554 |
|
|
self.oldRowElement = droppedRow;
|
555 |
|
|
self.onDrop();
|
556 |
|
|
self.rowObject = null;
|
557 |
|
|
}
|
558 |
|
|
|
559 |
|
|
|
560 |
|
|
if (self.dragObject != null) {
|
561 |
|
|
$('.tabledrag-handle', droppedRow).removeClass('tabledrag-handle-hover');
|
562 |
|
|
|
563 |
|
|
self.dragObject = null;
|
564 |
|
|
$('body').removeClass('drag');
|
565 |
|
|
clearInterval(self.scrollInterval);
|
566 |
|
|
|
567 |
|
|
|
568 |
|
|
if (navigator.userAgent.indexOf('MSIE 6.') != -1) {
|
569 |
|
|
$('select', this.table).css('display', 'block');
|
570 |
|
|
}
|
571 |
|
|
}
|
572 |
|
|
};
|
573 |
|
|
|
574 |
|
|
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
Drupal.tableDrag.prototype.mouseCoords = function (event) {
|
578 |
|
|
if (event.pageX || event.pageY) {
|
579 |
|
|
return { x: event.pageX, y: event.pageY };
|
580 |
|
|
}
|
581 |
|
|
return {
|
582 |
|
|
x: event.clientX + document.body.scrollLeft - document.body.clientLeft,
|
583 |
|
|
y: event.clientY + document.body.scrollTop - document.body.clientTop
|
584 |
|
|
};
|
585 |
|
|
};
|
586 |
|
|
|
587 |
|
|
|
588 |
|
|
|
589 |
|
|
|
590 |
|
|
|
591 |
|
|
Drupal.tableDrag.prototype.getMouseOffset = function (target, event) {
|
592 |
|
|
var docPos = $(target).offset();
|
593 |
|
|
var mousePos = this.mouseCoords(event);
|
594 |
|
|
return { x: mousePos.x - docPos.left, y: mousePos.y - docPos.top };
|
595 |
|
|
};
|
596 |
|
|
|
597 |
|
|
|
598 |
|
|
|
599 |
|
|
|
600 |
|
|
|
601 |
|
|
|
602 |
|
|
|
603 |
|
|
|
604 |
|
|
|
605 |
|
|
|
606 |
|
|
Drupal.tableDrag.prototype.findDropTargetRow = function (x, y) {
|
607 |
|
|
var rows = $(this.table.tBodies[0].rows).not(':hidden');
|
608 |
|
|
for (var n = 0; n < rows.length; n++) {
|
609 |
|
|
var row = rows[n];
|
610 |
|
|
var indentDiff = 0;
|
611 |
|
|
var rowY = $(row).offset().top;
|
612 |
|
|
|
613 |
|
|
|
614 |
|
|
|
615 |
|
|
if (row.offsetHeight == 0) {
|
616 |
|
|
var rowHeight = parseInt(row.firstChild.offsetHeight, 10) / 2;
|
617 |
|
|
}
|
618 |
|
|
|
619 |
|
|
else {
|
620 |
|
|
var rowHeight = parseInt(row.offsetHeight, 10) / 2;
|
621 |
|
|
}
|
622 |
|
|
|
623 |
|
|
|
624 |
|
|
if ((y > (rowY - rowHeight)) && (y < (rowY + rowHeight))) {
|
625 |
|
|
if (this.indentEnabled) {
|
626 |
|
|
|
627 |
|
|
for (var n in this.rowObject.group) {
|
628 |
|
|
if (this.rowObject.group[n] == row) {
|
629 |
|
|
return null;
|
630 |
|
|
}
|
631 |
|
|
}
|
632 |
|
|
}
|
633 |
|
|
else {
|
634 |
|
|
|
635 |
|
|
if (row == this.rowObject.element) {
|
636 |
|
|
return null;
|
637 |
|
|
}
|
638 |
|
|
}
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
if (!this.rowObject.isValidSwap(row)) {
|
642 |
|
|
return null;
|
643 |
|
|
}
|
644 |
|
|
|
645 |
|
|
|
646 |
|
|
|
647 |
|
|
|
648 |
|
|
while ($(row).is(':hidden') && $(row).prev('tr').is(':hidden')) {
|
649 |
|
|
row = $(row).prev('tr').get(0);
|
650 |
|
|
}
|
651 |
|
|
return row;
|
652 |
|
|
}
|
653 |
|
|
}
|
654 |
|
|
return null;
|
655 |
|
|
};
|
656 |
|
|
|
657 |
|
|
|
658 |
|
|
|
659 |
|
|
|
660 |
|
|
|
661 |
|
|
|
662 |
|
|
|
663 |
|
|
|
664 |
|
|
Drupal.tableDrag.prototype.updateFields = function (changedRow) {
|
665 |
|
|
for (var group in this.tableSettings) {
|
666 |
|
|
|
667 |
|
|
|
668 |
|
|
this.updateField(changedRow, group);
|
669 |
|
|
}
|
670 |
|
|
};
|
671 |
|
|
|
672 |
|
|
|
673 |
|
|
|
674 |
|
|
|
675 |
|
|
|
676 |
|
|
|
677 |
|
|
|
678 |
|
|
|
679 |
|
|
|
680 |
|
|
|
681 |
|
|
Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
|
682 |
|
|
var rowSettings = this.rowSettings(group, changedRow);
|
683 |
|
|
|
684 |
|
|
|
685 |
|
|
if (rowSettings.relationship == 'self' || rowSettings.relationship == 'group') {
|
686 |
|
|
var sourceRow = changedRow;
|
687 |
|
|
}
|
688 |
|
|
|
689 |
|
|
else if (rowSettings.relationship == 'sibling') {
|
690 |
|
|
var previousRow = $(changedRow).prev('tr').get(0);
|
691 |
|
|
var nextRow = $(changedRow).next('tr').get(0);
|
692 |
|
|
var sourceRow = changedRow;
|
693 |
|
|
if ($(previousRow).is('.draggable') && $('.' + group, previousRow).length) {
|
694 |
|
|
if (this.indentEnabled) {
|
695 |
|
|
if ($('.indentations', previousRow).length == $('.indentations', changedRow)) {
|
696 |
|
|
sourceRow = previousRow;
|
697 |
|
|
}
|
698 |
|
|
}
|
699 |
|
|
else {
|
700 |
|
|
sourceRow = previousRow;
|
701 |
|
|
}
|
702 |
|
|
}
|
703 |
|
|
else if ($(nextRow).is('.draggable') && $('.' + group, nextRow).length) {
|
704 |
|
|
if (this.indentEnabled) {
|
705 |
|
|
if ($('.indentations', nextRow).length == $('.indentations', changedRow)) {
|
706 |
|
|
sourceRow = nextRow;
|
707 |
|
|
}
|
708 |
|
|
}
|
709 |
|
|
else {
|
710 |
|
|
sourceRow = nextRow;
|
711 |
|
|
}
|
712 |
|
|
}
|
713 |
|
|
}
|
714 |
|
|
|
715 |
|
|
|
716 |
|
|
else if (rowSettings.relationship == 'parent') {
|
717 |
|
|
var previousRow = $(changedRow).prev('tr');
|
718 |
|
|
while (previousRow.length && $('.indentation', previousRow).length >= this.rowObject.indents) {
|
719 |
|
|
previousRow = previousRow.prev('tr');
|
720 |
|
|
}
|
721 |
|
|
|
722 |
|
|
if (previousRow.length) {
|
723 |
|
|
sourceRow = previousRow[0];
|
724 |
|
|
}
|
725 |
|
|
|
726 |
|
|
|
727 |
|
|
else {
|
728 |
|
|
|
729 |
|
|
|
730 |
|
|
|
731 |
|
|
sourceRow = $(this.table).find('tr.draggable:first').get(0);
|
732 |
|
|
if (sourceRow == this.rowObject.element) {
|
733 |
|
|
sourceRow = $(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0);
|
734 |
|
|
}
|
735 |
|
|
var useSibling = true;
|
736 |
|
|
}
|
737 |
|
|
}
|
738 |
|
|
|
739 |
|
|
|
740 |
|
|
|
741 |
|
|
this.copyDragClasses(sourceRow, changedRow, group);
|
742 |
|
|
rowSettings = this.rowSettings(group, changedRow);
|
743 |
|
|
|
744 |
|
|
|
745 |
|
|
|
746 |
|
|
if (useSibling) {
|
747 |
|
|
rowSettings.relationship = 'sibling';
|
748 |
|
|
rowSettings.source = rowSettings.target;
|
749 |
|
|
}
|
750 |
|
|
|
751 |
|
|
var targetClass = '.' + rowSettings.target;
|
752 |
|
|
var targetElement = $(targetClass, changedRow).get(0);
|
753 |
|
|
|
754 |
|
|
|
755 |
|
|
if (targetElement) {
|
756 |
|
|
var sourceClass = '.' + rowSettings.source;
|
757 |
|
|
var sourceElement = $(sourceClass, sourceRow).get(0);
|
758 |
|
|
switch (rowSettings.action) {
|
759 |
|
|
case 'depth':
|
760 |
|
|
|
761 |
|
|
targetElement.value = $('.indentation', $(sourceElement).closest('tr')).length;
|
762 |
|
|
break;
|
763 |
|
|
case 'match':
|
764 |
|
|
|
765 |
|
|
targetElement.value = sourceElement.value;
|
766 |
|
|
break;
|
767 |
|
|
case 'order':
|
768 |
|
|
var siblings = this.rowObject.findSiblings(rowSettings);
|
769 |
|
|
if ($(targetElement).is('select')) {
|
770 |
|
|
|
771 |
|
|
var values = [];
|
772 |
|
|
$('option', targetElement).each(function () {
|
773 |
|
|
values.push(this.value);
|
774 |
|
|
});
|
775 |
|
|
var maxVal = values[values.length - 1];
|
776 |
|
|
|
777 |
|
|
$(targetClass, siblings).each(function () {
|
778 |
|
|
|
779 |
|
|
if (values.length > 0) {
|
780 |
|
|
this.value = values.shift();
|
781 |
|
|
}
|
782 |
|
|
else {
|
783 |
|
|
this.value = maxVal;
|
784 |
|
|
}
|
785 |
|
|
});
|
786 |
|
|
}
|
787 |
|
|
else {
|
788 |
|
|
|
789 |
|
|
var weight = parseInt($(targetClass, siblings[0]).val(), 10) || 0;
|
790 |
|
|
$(targetClass, siblings).each(function () {
|
791 |
|
|
this.value = weight;
|
792 |
|
|
weight++;
|
793 |
|
|
});
|
794 |
|
|
}
|
795 |
|
|
break;
|
796 |
|
|
}
|
797 |
|
|
}
|
798 |
|
|
};
|
799 |
|
|
|
800 |
|
|
|
801 |
|
|
|
802 |
|
|
|
803 |
|
|
|
804 |
|
|
|
805 |
|
|
Drupal.tableDrag.prototype.copyDragClasses = function (sourceRow, targetRow, group) {
|
806 |
|
|
var sourceElement = $('.' + group, sourceRow);
|
807 |
|
|
var targetElement = $('.' + group, targetRow);
|
808 |
|
|
if (sourceElement.length && targetElement.length) {
|
809 |
|
|
targetElement[0].className = sourceElement[0].className;
|
810 |
|
|
}
|
811 |
|
|
};
|
812 |
|
|
|
813 |
|
|
Drupal.tableDrag.prototype.checkScroll = function (cursorY) {
|
814 |
|
|
var de = document.documentElement;
|
815 |
|
|
var b = document.body;
|
816 |
|
|
|
817 |
|
|
var windowHeight = this.windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth != 0 ? de.clientHeight : b.offsetHeight);
|
818 |
|
|
var scrollY = this.scrollY = (document.all ? (!de.scrollTop ? b.scrollTop : de.scrollTop) : (window.pageYOffset ? window.pageYOffset : window.scrollY));
|
819 |
|
|
var trigger = this.scrollSettings.trigger;
|
820 |
|
|
var delta = 0;
|
821 |
|
|
|
822 |
|
|
|
823 |
|
|
if (cursorY - scrollY > windowHeight - trigger) {
|
824 |
|
|
delta = trigger / (windowHeight + scrollY - cursorY);
|
825 |
|
|
delta = (delta > 0 && delta < trigger) ? delta : trigger;
|
826 |
|
|
return delta * this.scrollSettings.amount;
|
827 |
|
|
}
|
828 |
|
|
else if (cursorY - scrollY < trigger) {
|
829 |
|
|
delta = trigger / (cursorY - scrollY);
|
830 |
|
|
delta = (delta > 0 && delta < trigger) ? delta : trigger;
|
831 |
|
|
return -delta * this.scrollSettings.amount;
|
832 |
|
|
}
|
833 |
|
|
};
|
834 |
|
|
|
835 |
|
|
Drupal.tableDrag.prototype.setScroll = function (scrollAmount) {
|
836 |
|
|
var self = this;
|
837 |
|
|
|
838 |
|
|
this.scrollInterval = setInterval(function () {
|
839 |
|
|
|
840 |
|
|
self.checkScroll(self.currentMouseCoords.y);
|
841 |
|
|
var aboveTable = self.scrollY > self.table.topY;
|
842 |
|
|
var belowTable = self.scrollY + self.windowHeight < self.table.bottomY;
|
843 |
|
|
if (scrollAmount > 0 && belowTable || scrollAmount < 0 && aboveTable) {
|
844 |
|
|
window.scrollBy(0, scrollAmount);
|
845 |
|
|
}
|
846 |
|
|
}, this.scrollSettings.interval);
|
847 |
|
|
};
|
848 |
|
|
|
849 |
|
|
Drupal.tableDrag.prototype.restripeTable = function () {
|
850 |
|
|
|
851 |
|
|
|
852 |
|
|
|
853 |
|
|
$('> tbody > tr.draggable:visible, > tr.draggable:visible', this.table)
|
854 |
|
|
.removeClass('odd even')
|
855 |
|
|
.filter(':odd').addClass('even').end()
|
856 |
|
|
.filter(':even').addClass('odd');
|
857 |
|
|
};
|
858 |
|
|
|
859 |
|
|
|
860 |
|
|
|
861 |
|
|
|
862 |
|
|
Drupal.tableDrag.prototype.onDrag = function () {
|
863 |
|
|
return null;
|
864 |
|
|
};
|
865 |
|
|
|
866 |
|
|
|
867 |
|
|
|
868 |
|
|
|
869 |
|
|
Drupal.tableDrag.prototype.onDrop = function () {
|
870 |
|
|
return null;
|
871 |
|
|
};
|
872 |
|
|
|
873 |
|
|
|
874 |
|
|
|
875 |
|
|
|
876 |
|
|
|
877 |
|
|
|
878 |
|
|
|
879 |
|
|
|
880 |
|
|
|
881 |
|
|
|
882 |
|
|
|
883 |
|
|
|
884 |
|
|
|
885 |
|
|
|
886 |
|
|
|
887 |
|
|
Drupal.tableDrag.prototype.row = function (tableRow, method, indentEnabled, maxDepth, addClasses) {
|
888 |
|
|
this.element = tableRow;
|
889 |
|
|
this.method = method;
|
890 |
|
|
this.group = [tableRow];
|
891 |
|
|
this.groupDepth = $('.indentation', tableRow).length;
|
892 |
|
|
this.changed = false;
|
893 |
|
|
this.table = $(tableRow).closest('table').get(0);
|
894 |
|
|
this.indentEnabled = indentEnabled;
|
895 |
|
|
this.maxDepth = maxDepth;
|
896 |
|
|
this.direction = '';
|
897 |
|
|
|
898 |
|
|
if (this.indentEnabled) {
|
899 |
|
|
this.indents = $('.indentation', tableRow).length;
|
900 |
|
|
this.children = this.findChildren(addClasses);
|
901 |
|
|
this.group = $.merge(this.group, this.children);
|
902 |
|
|
|
903 |
|
|
for (var n = 0; n < this.group.length; n++) {
|
904 |
|
|
this.groupDepth = Math.max($('.indentation', this.group[n]).length, this.groupDepth);
|
905 |
|
|
}
|
906 |
|
|
}
|
907 |
|
|
};
|
908 |
|
|
|
909 |
|
|
|
910 |
|
|
|
911 |
|
|
|
912 |
|
|
|
913 |
|
|
|
914 |
|
|
|
915 |
|
|
Drupal.tableDrag.prototype.row.prototype.findChildren = function (addClasses) {
|
916 |
|
|
var parentIndentation = this.indents;
|
917 |
|
|
var currentRow = $(this.element, this.table).next('tr.draggable');
|
918 |
|
|
var rows = [];
|
919 |
|
|
var child = 0;
|
920 |
|
|
while (currentRow.length) {
|
921 |
|
|
var rowIndentation = $('.indentation', currentRow).length;
|
922 |
|
|
|
923 |
|
|
if (rowIndentation > parentIndentation) {
|
924 |
|
|
child++;
|
925 |
|
|
rows.push(currentRow[0]);
|
926 |
|
|
if (addClasses) {
|
927 |
|
|
$('.indentation', currentRow).each(function (indentNum) {
|
928 |
|
|
if (child == 1 && (indentNum == parentIndentation)) {
|
929 |
|
|
$(this).addClass('tree-child-first');
|
930 |
|
|
}
|
931 |
|
|
if (indentNum == parentIndentation) {
|
932 |
|
|
$(this).addClass('tree-child');
|
933 |
|
|
}
|
934 |
|
|
else if (indentNum > parentIndentation) {
|
935 |
|
|
$(this).addClass('tree-child-horizontal');
|
936 |
|
|
}
|
937 |
|
|
});
|
938 |
|
|
}
|
939 |
|
|
}
|
940 |
|
|
else {
|
941 |
|
|
break;
|
942 |
|
|
}
|
943 |
|
|
currentRow = currentRow.next('tr.draggable');
|
944 |
|
|
}
|
945 |
|
|
if (addClasses && rows.length) {
|
946 |
|
|
$('.indentation:nth-child(' + (parentIndentation + 1) + ')', rows[rows.length - 1]).addClass('tree-child-last');
|
947 |
|
|
}
|
948 |
|
|
return rows;
|
949 |
|
|
};
|
950 |
|
|
|
951 |
|
|
|
952 |
|
|
|
953 |
|
|
|
954 |
|
|
|
955 |
|
|
|
956 |
|
|
|
957 |
|
|
Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) {
|
958 |
|
|
if (this.indentEnabled) {
|
959 |
|
|
var prevRow, nextRow;
|
960 |
|
|
if (this.direction == 'down') {
|
961 |
|
|
prevRow = row;
|
962 |
|
|
nextRow = $(row).next('tr').get(0);
|
963 |
|
|
}
|
964 |
|
|
else {
|
965 |
|
|
prevRow = $(row).prev('tr').get(0);
|
966 |
|
|
nextRow = row;
|
967 |
|
|
}
|
968 |
|
|
this.interval = this.validIndentInterval(prevRow, nextRow);
|
969 |
|
|
|
970 |
|
|
|
971 |
|
|
if (this.interval.min > this.interval.max) {
|
972 |
|
|
return false;
|
973 |
|
|
}
|
974 |
|
|
}
|
975 |
|
|
|
976 |
|
|
|
977 |
|
|
if (this.table.tBodies[0].rows[0] == row && $(row).is(':not(.draggable)')) {
|
978 |
|
|
return false;
|
979 |
|
|
}
|
980 |
|
|
|
981 |
|
|
return true;
|
982 |
|
|
};
|
983 |
|
|
|
984 |
|
|
|
985 |
|
|
|
986 |
|
|
|
987 |
|
|
|
988 |
|
|
|
989 |
|
|
|
990 |
|
|
|
991 |
|
|
|
992 |
|
|
Drupal.tableDrag.prototype.row.prototype.swap = function (position, row) {
|
993 |
|
|
Drupal.detachBehaviors(this.group, Drupal.settings, 'move');
|
994 |
|
|
$(row)[position](this.group);
|
995 |
|
|
Drupal.attachBehaviors(this.group, Drupal.settings);
|
996 |
|
|
this.changed = true;
|
997 |
|
|
this.onSwap(row);
|
998 |
|
|
};
|
999 |
|
|
|
1000 |
|
|
|
1001 |
|
|
|
1002 |
|
|
|
1003 |
|
|
|
1004 |
|
|
|
1005 |
|
|
|
1006 |
|
|
|
1007 |
|
|
|
1008 |
|
|
|
1009 |
|
|
|
1010 |
|
|
|
1011 |
|
|
Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) {
|
1012 |
|
|
var minIndent, maxIndent;
|
1013 |
|
|
|
1014 |
|
|
|
1015 |
|
|
|
1016 |
|
|
minIndent = nextRow ? $('.indentation', nextRow).length : 0;
|
1017 |
|
|
|
1018 |
|
|
|
1019 |
|
|
if (!prevRow || $(prevRow).is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) {
|
1020 |
|
|
|
1021 |
|
|
|
1022 |
|
|
|
1023 |
|
|
|
1024 |
|
|
maxIndent = 0;
|
1025 |
|
|
}
|
1026 |
|
|
else {
|
1027 |
|
|
|
1028 |
|
|
maxIndent = $('.indentation', prevRow).length + ($(prevRow).is('.tabledrag-leaf') ? 0 : 1);
|
1029 |
|
|
|
1030 |
|
|
if (this.maxDepth) {
|
1031 |
|
|
maxIndent = Math.min(maxIndent, this.maxDepth - (this.groupDepth - this.indents));
|
1032 |
|
|
}
|
1033 |
|
|
}
|
1034 |
|
|
|
1035 |
|
|
return { 'min': minIndent, 'max': maxIndent };
|
1036 |
|
|
};
|
1037 |
|
|
|
1038 |
|
|
|
1039 |
|
|
|
1040 |
|
|
|
1041 |
|
|
|
1042 |
|
|
|
1043 |
|
|
|
1044 |
|
|
|
1045 |
|
|
|
1046 |
|
|
Drupal.tableDrag.prototype.row.prototype.indent = function (indentDiff) {
|
1047 |
|
|
|
1048 |
|
|
if (!this.interval) {
|
1049 |
|
|
var prevRow = $(this.element).prev('tr').get(0);
|
1050 |
|
|
var nextRow = $(this.group).filter(':last').next('tr').get(0);
|
1051 |
|
|
this.interval = this.validIndentInterval(prevRow, nextRow);
|
1052 |
|
|
}
|
1053 |
|
|
|
1054 |
|
|
|
1055 |
|
|
var indent = this.indents + indentDiff;
|
1056 |
|
|
indent = Math.max(indent, this.interval.min);
|
1057 |
|
|
indent = Math.min(indent, this.interval.max);
|
1058 |
|
|
indentDiff = indent - this.indents;
|
1059 |
|
|
|
1060 |
|
|
for (var n = 1; n <= Math.abs(indentDiff); n++) {
|
1061 |
|
|
|
1062 |
|
|
if (indentDiff < 0) {
|
1063 |
|
|
$('.indentation:first', this.group).remove();
|
1064 |
|
|
this.indents--;
|
1065 |
|
|
}
|
1066 |
|
|
else {
|
1067 |
|
|
$('td:first', this.group).prepend(Drupal.theme('tableDragIndentation'));
|
1068 |
|
|
this.indents++;
|
1069 |
|
|
}
|
1070 |
|
|
}
|
1071 |
|
|
if (indentDiff) {
|
1072 |
|
|
|
1073 |
|
|
this.changed = true;
|
1074 |
|
|
this.groupDepth += indentDiff;
|
1075 |
|
|
this.onIndent();
|
1076 |
|
|
}
|
1077 |
|
|
|
1078 |
|
|
return indentDiff;
|
1079 |
|
|
};
|
1080 |
|
|
|
1081 |
|
|
|
1082 |
|
|
|
1083 |
|
|
|
1084 |
|
|
|
1085 |
|
|
|
1086 |
|
|
|
1087 |
|
|
|
1088 |
|
|
Drupal.tableDrag.prototype.row.prototype.findSiblings = function (rowSettings) {
|
1089 |
|
|
var siblings = [];
|
1090 |
|
|
var directions = ['prev', 'next'];
|
1091 |
|
|
var rowIndentation = this.indents;
|
1092 |
|
|
for (var d = 0; d < directions.length; d++) {
|
1093 |
|
|
var checkRow = $(this.element)[directions[d]]();
|
1094 |
|
|
while (checkRow.length) {
|
1095 |
|
|
|
1096 |
|
|
if ($('.' + rowSettings.target, checkRow)) {
|
1097 |
|
|
|
1098 |
|
|
|
1099 |
|
|
if (this.indentEnabled) {
|
1100 |
|
|
var checkRowIndentation = $('.indentation', checkRow).length;
|
1101 |
|
|
}
|
1102 |
|
|
|
1103 |
|
|
if (!(this.indentEnabled) || (checkRowIndentation == rowIndentation)) {
|
1104 |
|
|
siblings.push(checkRow[0]);
|
1105 |
|
|
}
|
1106 |
|
|
else if (checkRowIndentation < rowIndentation) {
|
1107 |
|
|
|
1108 |
|
|
break;
|
1109 |
|
|
}
|
1110 |
|
|
}
|
1111 |
|
|
else {
|
1112 |
|
|
break;
|
1113 |
|
|
}
|
1114 |
|
|
checkRow = $(checkRow)[directions[d]]();
|
1115 |
|
|
}
|
1116 |
|
|
|
1117 |
|
|
|
1118 |
|
|
if (directions[d] == 'prev') {
|
1119 |
|
|
siblings.reverse();
|
1120 |
|
|
siblings.push(this.element);
|
1121 |
|
|
}
|
1122 |
|
|
}
|
1123 |
|
|
return siblings;
|
1124 |
|
|
};
|
1125 |
|
|
|
1126 |
|
|
|
1127 |
|
|
|
1128 |
|
|
|
1129 |
|
|
Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
|
1130 |
|
|
for (var n in this.children) {
|
1131 |
|
|
$('.indentation', this.children[n])
|
1132 |
|
|
.removeClass('tree-child')
|
1133 |
|
|
.removeClass('tree-child-first')
|
1134 |
|
|
.removeClass('tree-child-last')
|
1135 |
|
|
.removeClass('tree-child-horizontal');
|
1136 |
|
|
}
|
1137 |
|
|
};
|
1138 |
|
|
|
1139 |
|
|
|
1140 |
|
|
|
1141 |
|
|
|
1142 |
|
|
Drupal.tableDrag.prototype.row.prototype.markChanged = function () {
|
1143 |
|
|
var marker = Drupal.theme('tableDragChangedMarker');
|
1144 |
|
|
var cell = $('td:first', this.element);
|
1145 |
|
|
if ($('span.tabledrag-changed', cell).length == 0) {
|
1146 |
|
|
cell.append(marker);
|
1147 |
|
|
}
|
1148 |
|
|
};
|
1149 |
|
|
|
1150 |
|
|
|
1151 |
|
|
|
1152 |
|
|
|
1153 |
|
|
Drupal.tableDrag.prototype.row.prototype.onIndent = function () {
|
1154 |
|
|
return null;
|
1155 |
|
|
};
|
1156 |
|
|
|
1157 |
|
|
|
1158 |
|
|
|
1159 |
|
|
|
1160 |
|
|
Drupal.tableDrag.prototype.row.prototype.onSwap = function (swappedRow) {
|
1161 |
|
|
return null;
|
1162 |
|
|
};
|
1163 |
|
|
|
1164 |
|
|
Drupal.theme.prototype.tableDragChangedMarker = function () {
|
1165 |
|
|
return '<span class="warning tabledrag-changed">*</span>';
|
1166 |
|
|
};
|
1167 |
|
|
|
1168 |
|
|
Drupal.theme.prototype.tableDragIndentation = function () {
|
1169 |
|
|
return '<div class="indentation"> </div>';
|
1170 |
|
|
};
|
1171 |
|
|
|
1172 |
|
|
Drupal.theme.prototype.tableDragChangedWarning = function () {
|
1173 |
|
|
return '<div class="tabledrag-changed-warning messages warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t('Changes made in this table will not be saved until the form is submitted.') + '</div>';
|
1174 |
|
|
};
|
1175 |
|
|
|
1176 |
|
|
})(jQuery); |