1 |
85ad3d82
|
Assos Assos
|
(function ($) {
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
Drupal.behaviors.blockSettingsSummary = {
|
7 |
|
|
attach: function (context) {
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
if (typeof jQuery.fn.drupalSetSummary == 'undefined') {
|
12 |
|
|
return;
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
$('fieldset#edit-path', context).drupalSetSummary(function (context) {
|
16 |
|
|
if (!$('textarea[name="pages"]', context).val()) {
|
17 |
|
|
return Drupal.t('Not restricted');
|
18 |
|
|
}
|
19 |
|
|
else {
|
20 |
|
|
return Drupal.t('Restricted to certain pages');
|
21 |
|
|
}
|
22 |
|
|
});
|
23 |
|
|
|
24 |
|
|
$('fieldset#edit-node-type', context).drupalSetSummary(function (context) {
|
25 |
|
|
var vals = [];
|
26 |
|
|
$('input[type="checkbox"]:checked', context).each(function () {
|
27 |
|
|
vals.push($.trim($(this).next('label').text()));
|
28 |
|
|
});
|
29 |
|
|
if (!vals.length) {
|
30 |
|
|
vals.push(Drupal.t('Not restricted'));
|
31 |
|
|
}
|
32 |
|
|
return vals.join(', ');
|
33 |
|
|
});
|
34 |
|
|
|
35 |
|
|
$('fieldset#edit-role', context).drupalSetSummary(function (context) {
|
36 |
|
|
var vals = [];
|
37 |
|
|
$('input[type="checkbox"]:checked', context).each(function () {
|
38 |
|
|
vals.push($.trim($(this).next('label').text()));
|
39 |
|
|
});
|
40 |
|
|
if (!vals.length) {
|
41 |
|
|
vals.push(Drupal.t('Not restricted'));
|
42 |
|
|
}
|
43 |
|
|
return vals.join(', ');
|
44 |
|
|
});
|
45 |
|
|
|
46 |
|
|
$('fieldset#edit-user', context).drupalSetSummary(function (context) {
|
47 |
|
|
var $radio = $('input[name="custom"]:checked', context);
|
48 |
|
|
if ($radio.val() == 0) {
|
49 |
|
|
return Drupal.t('Not customizable');
|
50 |
|
|
}
|
51 |
|
|
else {
|
52 |
|
|
return $radio.next('label').text();
|
53 |
|
|
}
|
54 |
|
|
});
|
55 |
|
|
}
|
56 |
|
|
};
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
Drupal.behaviors.blockDrag = {
|
65 |
|
|
attach: function (context, settings) {
|
66 |
|
|
|
67 |
|
|
if (typeof Drupal.tableDrag == 'undefined' || typeof Drupal.tableDrag.blocks == 'undefined') {
|
68 |
|
|
return;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
var table = $('table#blocks');
|
72 |
|
|
var tableDrag = Drupal.tableDrag.blocks;
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
tableDrag.row.prototype.onSwap = function (swappedRow) {
|
76 |
|
|
checkEmptyRegions(table, this);
|
77 |
|
|
};
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
Drupal.theme.tableDragChangedWarning = function () {
|
81 |
|
|
return '<div class="messages warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t('The changes to these blocks will not be saved until the <em>Save blocks</em> button is clicked.') + '</div>';
|
82 |
|
|
};
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
tableDrag.onDrop = function () {
|
86 |
|
|
dragObject = this;
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
var regionRow = $(dragObject.rowObject.element).prevAll('tr.region-message').get(0);
|
90 |
|
|
var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
91 |
|
|
var regionField = $('select.block-region-select', dragObject.rowObject.element);
|
92 |
|
|
|
93 |
|
|
if ($('option[value=' + regionName + ']', regionField).length == 0) {
|
94 |
|
|
|
95 |
|
|
alert(Drupal.t('The block cannot be placed in this region.'));
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
regionField.change();
|
99 |
|
|
}
|
100 |
|
|
else if ($(dragObject.rowObject.element).prev('tr').is('.region-message')) {
|
101 |
|
|
var weightField = $('select.block-weight', dragObject.rowObject.element);
|
102 |
|
|
var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
|
103 |
|
|
|
104 |
|
|
if (!regionField.is('.block-region-' + regionName)) {
|
105 |
|
|
regionField.removeClass('block-region-' + oldRegionName).addClass('block-region-' + regionName);
|
106 |
|
|
weightField.removeClass('block-weight-' + oldRegionName).addClass('block-weight-' + regionName);
|
107 |
|
|
regionField.val(regionName);
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
};
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
$('select.block-region-select', context).once('block-region-select', function () {
|
114 |
|
|
$(this).change(function (event) {
|
115 |
|
|
|
116 |
|
|
var row = $(this).closest('tr');
|
117 |
|
|
var select = $(this);
|
118 |
|
|
tableDrag.rowObject = new tableDrag.row(row);
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
table.find('.region-' + select[0].value + '-message').nextUntil('.region-message').last().before(row);
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
checkEmptyRegions(table, row);
|
125 |
|
|
|
126 |
|
|
select.get(0).blur();
|
127 |
|
|
});
|
128 |
|
|
});
|
129 |
|
|
|
130 |
|
|
var checkEmptyRegions = function (table, rowObject) {
|
131 |
|
|
$('tr.region-message', table).each(function () {
|
132 |
|
|
|
133 |
|
|
if ($(this).prev('tr').get(0) == rowObject.element) {
|
134 |
|
|
|
135 |
|
|
if ((rowObject.method != 'keyboard' || rowObject.direction == 'down')) {
|
136 |
|
|
rowObject.swap('after', this);
|
137 |
|
|
}
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').length == 0) {
|
141 |
|
|
$(this).removeClass('region-populated').addClass('region-empty');
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
else if ($(this).is('.region-empty')) {
|
145 |
|
|
$(this).removeClass('region-empty').addClass('region-populated');
|
146 |
|
|
}
|
147 |
|
|
});
|
148 |
|
|
};
|
149 |
|
|
}
|
150 |
|
|
};
|
151 |
|
|
|
152 |
|
|
})(jQuery); |