1 |
85ad3d82
|
Assos Assos
|
(function ($) {
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
Drupal.behaviors.profileDrag = {
|
11 |
|
|
attach: function (context, settings) {
|
12 |
|
|
var table = $('#profile-fields');
|
13 |
|
|
var tableDrag = Drupal.tableDrag['profile-fields'];
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
tableDrag.row.prototype.onSwap = function (swappedRow) {
|
17 |
|
|
var rowObject = this;
|
18 |
|
|
$('tr.category-message', table).each(function () {
|
19 |
|
|
|
20 |
|
|
if ($(this).prev('tr').get(0) == rowObject.element) {
|
21 |
|
|
|
22 |
|
|
if ((rowObject.method != 'keyboard' || rowObject.direction == 'down')) {
|
23 |
|
|
rowObject.swap('after', this);
|
24 |
|
|
}
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').length == 0) {
|
28 |
|
|
$(this).removeClass('category-populated').addClass('category-empty');
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
else if ($(this).is('.category-empty')) {
|
32 |
|
|
$(this).removeClass('category-empty').addClass('category-populated');
|
33 |
|
|
}
|
34 |
|
|
});
|
35 |
|
|
};
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
tableDrag.onDrop = function () {
|
39 |
|
|
dragObject = this;
|
40 |
|
|
if ($(dragObject.rowObject.element).prev('tr').is('.category-message')) {
|
41 |
|
|
var categoryRow = $(dragObject.rowObject.element).prev('tr').get(0);
|
42 |
|
|
var categoryNum = categoryRow.className.replace(/([^ ]+[ ]+)*category-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
43 |
|
|
var categoryField = $('select.profile-category', dragObject.rowObject.element);
|
44 |
|
|
var weightField = $('select.profile-weight', dragObject.rowObject.element);
|
45 |
|
|
var oldcategoryNum = weightField[0].className.replace(/([^ ]+[ ]+)*profile-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
|
46 |
|
|
|
47 |
|
|
if (!categoryField.is('.profile-category-' + categoryNum)) {
|
48 |
|
|
categoryField.removeClass('profile-category-' + oldcategoryNum).addClass('profile-category-' + categoryNum);
|
49 |
|
|
weightField.removeClass('profile-weight-' + oldcategoryNum).addClass('profile-weight-' + categoryNum);
|
50 |
|
|
|
51 |
|
|
categoryField.val(categoryField[0].options[categoryNum].value);
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
|
|
};
|
55 |
|
|
}
|
56 |
|
|
};
|
57 |
|
|
|
58 |
|
|
})(jQuery); |