1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
(function ($) {
|
3 |
|
|
|
4 |
8a7e43dd
|
Florent Torregrosa
|
Drupal.ModuleFilter.tabs = {};
|
5 |
|
|
Drupal.ModuleFilter.enabling = {};
|
6 |
|
|
Drupal.ModuleFilter.disabling = {};
|
7 |
|
|
|
8 |
|
|
Drupal.ModuleFilter.jQueryIsNewer = function() {
|
9 |
|
|
if (Drupal.ModuleFilter.jQueryNewer == undefined) {
|
10 |
|
|
var v1parts = $.fn.jquery.split('.');
|
11 |
|
|
var v2parts = new Array('1', '4', '4');
|
12 |
|
|
|
13 |
|
|
for (var i = 0; i < v1parts.length; ++i) {
|
14 |
|
|
if (v2parts.length == i) {
|
15 |
|
|
Drupal.ModuleFilter.jQueryNewer = true;
|
16 |
|
|
return Drupal.ModuleFilter.jQueryNewer;
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
if (v1parts[i] == v2parts[i]) {
|
20 |
|
|
continue;
|
21 |
|
|
}
|
22 |
|
|
else if (v1parts[i] > v2parts[i]) {
|
23 |
|
|
Drupal.ModuleFilter.jQueryNewer = true;
|
24 |
|
|
return Drupal.ModuleFilter.jQueryNewer;
|
25 |
|
|
}
|
26 |
|
|
else {
|
27 |
|
|
Drupal.ModuleFilter.jQueryNewer = false;
|
28 |
|
|
return Drupal.ModuleFilter.jQueryNewer;
|
29 |
|
|
}
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
if (v1parts.length != v2parts.length) {
|
33 |
|
|
Drupal.ModuleFilter.jQueryNewer = false;
|
34 |
|
|
return Drupal.ModuleFilter.jQueryNewer;
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
Drupal.ModuleFilter.jQueryNewer = false;
|
38 |
|
|
}
|
39 |
|
|
return Drupal.ModuleFilter.jQueryNewer;
|
40 |
|
|
};
|
41 |
|
|
|
42 |
|
|
Drupal.behaviors.moduleFilterTabs = {
|
43 |
|
|
attach: function(context) {
|
44 |
|
|
if (Drupal.settings.moduleFilter.tabs) {
|
45 |
|
|
$('#module-filter-wrapper table:not(.sticky-header)', context).once('module-filter-tabs', function() {
|
46 |
|
|
var $modules = $('#module-filter-modules');
|
47 |
|
|
var moduleFilter = $('input[name="module_filter[name]"]').data('moduleFilter');
|
48 |
|
|
var table = $(this);
|
49 |
|
|
|
50 |
|
|
$('thead', table).show();
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
$('tr.admin-package-header', table).remove();
|
54 |
85ad3d82
|
Assos Assos
|
|
55 |
8a7e43dd
|
Florent Torregrosa
|
var $tabsWrapper = $('<div id="module-filter-tabs"></div>');
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
var tabs = '<ul>';
|
59 |
|
|
for (var i in Drupal.settings.moduleFilter.packageIDs) {
|
60 |
|
|
var id = Drupal.settings.moduleFilter.packageIDs[i];
|
61 |
|
|
|
62 |
|
|
var name = id;
|
63 |
|
|
var tabClass = 'project-tab';
|
64 |
|
|
var title = null;
|
65 |
|
|
var summary = (Drupal.settings.moduleFilter.countEnabled) ? '<span class="count">' + Drupal.ModuleFilter.countSummary(id) + '</span>' : '';
|
66 |
|
|
|
67 |
|
|
switch (id) {
|
68 |
|
|
case 'all':
|
69 |
|
|
name = Drupal.t('All');
|
70 |
|
|
break;
|
71 |
|
|
case 'new':
|
72 |
|
|
name = Drupal.t('New');
|
73 |
|
|
title = Drupal.t('Modules installed within the last week.');
|
74 |
|
|
if (Drupal.settings.moduleFilter.enabledCounts['new'].total == 0) {
|
75 |
|
|
tabClass += ' disabled';
|
76 |
|
|
summary += '<span>' + Drupal.t('No modules added within the last week.') + '</span>';
|
77 |
|
|
}
|
78 |
|
|
break;
|
79 |
|
|
case 'recent':
|
80 |
|
|
name = Drupal.t('Recent');
|
81 |
|
|
title = Drupal.t('Modules enabled/disabled within the last week.');
|
82 |
|
|
if (Drupal.settings.moduleFilter.enabledCounts['recent'].total == 0) {
|
83 |
|
|
tabClass += ' disabled';
|
84 |
|
|
summary += '<span>' + Drupal.t('No modules were enabled or disabled within the last week.') + '</span>';
|
85 |
|
|
}
|
86 |
|
|
break;
|
87 |
|
|
default:
|
88 |
|
|
var $row = $('#' + id + '-package');
|
89 |
|
|
name = $.trim($row.text());
|
90 |
|
|
$row.remove();
|
91 |
|
|
break;
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
tabs += '<li id="' + id + '-tab" class="' + tabClass + '"><a href="#' + id + '" class="overlay-exclude"' + (title ? ' title="' + title + '"' : '') + '><strong>' + name + '</strong><span class="summary">' + summary + '</span></a></li>';
|
95 |
|
|
}
|
96 |
|
|
tabs += '</ul>';
|
97 |
|
|
$tabsWrapper.append(tabs);
|
98 |
|
|
$modules.before($tabsWrapper);
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
$('#module-filter-tabs li').each(function() {
|
102 |
|
|
var $tab = $(this);
|
103 |
|
|
var id = $tab.attr('id');
|
104 |
|
|
Drupal.ModuleFilter.tabs[id] = new Drupal.ModuleFilter.Tab($tab, id);
|
105 |
|
|
});
|
106 |
|
|
|
107 |
|
|
$('tbody td.checkbox input', $modules).change(function() {
|
108 |
|
|
var $checkbox = $(this);
|
109 |
|
|
var key = $checkbox.parents('tr').data('indexKey');
|
110 |
|
|
|
111 |
|
|
moduleFilter.index[key].status = $checkbox.is(':checked');
|
112 |
|
|
|
113 |
|
|
if (Drupal.settings.moduleFilter.visualAid) {
|
114 |
|
|
var type = ($checkbox.is(':checked')) ? 'enable' : 'disable';
|
115 |
|
|
Drupal.ModuleFilter.updateVisualAid(type, $checkbox.parents('tr'));
|
116 |
|
|
}
|
117 |
|
|
});
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
var rows = $('tbody tr.module', table).get();
|
121 |
|
|
rows.sort(function(a, b) {
|
122 |
|
|
var compA = $('td:nth(1)', a).text().toLowerCase();
|
123 |
|
|
var compB = $('td:nth(1)', b).text().toLowerCase();
|
124 |
|
|
return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
|
125 |
|
|
});
|
126 |
|
|
$.each(rows, function(idx, itm) { table.append(itm); });
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
$('tr.module', table)
|
130 |
|
|
.removeClass('odd even')
|
131 |
|
|
.filter(':odd').addClass('even').end()
|
132 |
|
|
.filter(':even').addClass('odd');
|
133 |
|
|
|
134 |
|
|
moduleFilter.adjustHeight();
|
135 |
|
|
|
136 |
|
|
moduleFilter.element.bind('moduleFilter:start', function() {
|
137 |
|
|
moduleFilter.tabResults = {
|
138 |
|
|
'all-tab': { items: {}, count: 0 },
|
139 |
|
|
'recent-tab': { items: {}, count: 0 },
|
140 |
|
|
'new-tab': { items: {}, count: 0 }
|
141 |
|
|
};
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
for (var i in Drupal.ModuleFilter.tabs) {
|
145 |
|
|
if (Drupal.ModuleFilter.tabs[i].resultInfo != undefined) {
|
146 |
|
|
Drupal.ModuleFilter.tabs[i].resultInfo.empty();
|
147 |
85ad3d82
|
Assos Assos
|
}
|
148 |
8a7e43dd
|
Florent Torregrosa
|
}
|
149 |
|
|
});
|
150 |
|
|
|
151 |
|
|
moduleFilter.element.bind('moduleFilter:finish', function(e, data) {
|
152 |
|
|
$.each(moduleFilter.index, function(key, item) {
|
153 |
|
|
if (!item.element.hasClass('js-hide')) {
|
154 |
|
|
var id = Drupal.ModuleFilter.getTabID(item.element);
|
155 |
85ad3d82
|
Assos Assos
|
|
156 |
8a7e43dd
|
Florent Torregrosa
|
if (moduleFilter.tabResults[id] == undefined) {
|
157 |
|
|
moduleFilter.tabResults[id] = { items: {}, count: 0 };
|
158 |
|
|
}
|
159 |
|
|
if (moduleFilter.tabResults[id].items[item.key] == undefined) {
|
160 |
|
|
|
161 |
|
|
moduleFilter.tabResults['all-tab'].count++;
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
if (item.element.hasClass('recent-module')) {
|
165 |
|
|
moduleFilter.tabResults['recent-tab'].count++;
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
if (item.element.hasClass('new-module')) {
|
170 |
|
|
moduleFilter.tabResults['new-tab'].count++;
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
moduleFilter.tabResults[id].items[item.key] = item;
|
174 |
|
|
moduleFilter.tabResults[id].count++;
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
if (Drupal.ModuleFilter.activeTab != undefined && Drupal.ModuleFilter.activeTab.id != 'all-tab') {
|
178 |
|
|
if ((Drupal.ModuleFilter.activeTab.id == 'recent-tab' && !item.element.hasClass('recent-module')) || (Drupal.ModuleFilter.activeTab.id == 'new-tab' && !item.element.hasClass('new-module')) || (Drupal.ModuleFilter.activeTab.id != 'recent-tab' && Drupal.ModuleFilter.activeTab.id != 'new-tab' && id != Drupal.ModuleFilter.activeTab.id)) {
|
179 |
|
|
|
180 |
|
|
item.element.addClass('js-hide');
|
181 |
|
|
}
|
182 |
85ad3d82
|
Assos Assos
|
}
|
183 |
|
|
}
|
184 |
8a7e43dd
|
Florent Torregrosa
|
});
|
185 |
85ad3d82
|
Assos Assos
|
|
186 |
8a7e43dd
|
Florent Torregrosa
|
if (Drupal.settings.moduleFilter.visualAid) {
|
187 |
|
|
if (moduleFilter.text) {
|
188 |
|
|
|
189 |
|
|
for (var id in moduleFilter.tabResults) {
|
190 |
|
|
var tab = Drupal.ModuleFilter.tabs[id];
|
191 |
85ad3d82
|
Assos Assos
|
|
192 |
8a7e43dd
|
Florent Torregrosa
|
if (tab.resultInfo == undefined) {
|
193 |
|
|
var resultInfo = '<span class="result-info"></span>'
|
194 |
|
|
$('a', tab.element).prepend(resultInfo);
|
195 |
|
|
tab.resultInfo = $('span.result-info', tab.element);
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
tab.resultInfo.append(moduleFilter.tabResults[id].count);
|
199 |
|
|
}
|
200 |
|
|
|
201 |
|
|
if (Drupal.settings.moduleFilter.hideEmptyTabs) {
|
202 |
|
|
for (var id in Drupal.ModuleFilter.tabs) {
|
203 |
|
|
if (moduleFilter.tabResults[id] != undefined) {
|
204 |
|
|
Drupal.ModuleFilter.tabs[id].element.show();
|
205 |
|
|
}
|
206 |
|
|
else if (Drupal.ModuleFilter.activeTab == undefined || Drupal.ModuleFilter.activeTab.id != id) {
|
207 |
|
|
Drupal.ModuleFilter.tabs[id].element.hide();
|
208 |
|
|
}
|
209 |
|
|
}
|
210 |
|
|
}
|
211 |
|
|
}
|
212 |
|
|
else {
|
213 |
|
|
|
214 |
|
|
if (Drupal.settings.moduleFilter.hideEmptyTabs) {
|
215 |
|
|
$('#module-filter-tabs li').show();
|
216 |
|
|
}
|
217 |
|
|
}
|
218 |
85ad3d82
|
Assos Assos
|
}
|
219 |
8a7e43dd
|
Florent Torregrosa
|
|
220 |
|
|
if ((Drupal.ModuleFilter.activeTab != undefined && (moduleFilter.tabResults[Drupal.ModuleFilter.activeTab.id] == undefined || moduleFilter.tabResults[Drupal.ModuleFilter.activeTab.id].count <= 0))) {
|
221 |
|
|
|
222 |
|
|
moduleFilter.results = 0;
|
223 |
85ad3d82
|
Assos Assos
|
}
|
224 |
8a7e43dd
|
Florent Torregrosa
|
|
225 |
|
|
moduleFilter.adjustHeight();
|
226 |
85ad3d82
|
Assos Assos
|
});
|
227 |
|
|
|
228 |
8a7e43dd
|
Florent Torregrosa
|
if (Drupal.settings.moduleFilter.useURLFragment) {
|
229 |
|
|
$(window).bind('hashchange.module-filter', $.proxy(Drupal.ModuleFilter, 'eventHandlerOperateByURLFragment')).triggerHandler('hashchange.module-filter');
|
230 |
|
|
}
|
231 |
|
|
else {
|
232 |
|
|
Drupal.ModuleFilter.selectTab();
|
233 |
|
|
}
|
234 |
85ad3d82
|
Assos Assos
|
|
235 |
8a7e43dd
|
Florent Torregrosa
|
if (Drupal.settings.moduleFilter.useSwitch) {
|
236 |
|
|
$('td.checkbox div.form-item').hide();
|
237 |
|
|
$('td.checkbox').each(function(i) {
|
238 |
|
|
var $cell = $(this);
|
239 |
|
|
var $checkbox = $(':checkbox', $cell);
|
240 |
|
|
var $switch = $('.toggle-enable', $cell);
|
241 |
|
|
$switch.removeClass('js-hide').click(function() {
|
242 |
|
|
if (!$(this).hasClass('disabled')) {
|
243 |
|
|
if (Drupal.ModuleFilter.jQueryIsNewer()) {
|
244 |
|
|
$checkbox.click();
|
245 |
|
|
}
|
246 |
|
|
else {
|
247 |
|
|
$checkbox.click().change();
|
248 |
|
|
}
|
249 |
|
|
}
|
250 |
|
|
});
|
251 |
|
|
$checkbox.click(function() {
|
252 |
|
|
if (!$switch.hasClass('disabled')) {
|
253 |
|
|
$switch.toggleClass('off');
|
254 |
|
|
}
|
255 |
|
|
});
|
256 |
|
|
});
|
257 |
85ad3d82
|
Assos Assos
|
}
|
258 |
8a7e43dd
|
Florent Torregrosa
|
|
259 |
|
|
var $tabs = $('#module-filter-tabs');
|
260 |
|
|
|
261 |
|
|
function getParentTopOffset($obj, offset) {
|
262 |
|
|
var $parent = $obj.offsetParent();
|
263 |
|
|
if ($obj[0] != $parent[0]) {
|
264 |
|
|
offset += $parent.position().top;
|
265 |
|
|
return getParentTopOffset($parent, offset);
|
266 |
|
|
}
|
267 |
|
|
return offset;
|
268 |
85ad3d82
|
Assos Assos
|
}
|
269 |
8a7e43dd
|
Florent Torregrosa
|
|
270 |
|
|
var tabsTopOffset = null;
|
271 |
|
|
function getParentsTopOffset() {
|
272 |
|
|
if (tabsTopOffset === null) {
|
273 |
|
|
tabsTopOffset = getParentTopOffset($tabs.parent(), 0);
|
274 |
|
|
}
|
275 |
|
|
return tabsTopOffset;
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
function viewportTop() {
|
279 |
|
|
var top = $(window).scrollTop();
|
280 |
|
|
return top;
|
281 |
85ad3d82
|
Assos Assos
|
}
|
282 |
|
|
|
283 |
8a7e43dd
|
Florent Torregrosa
|
function viewportBottom() {
|
284 |
|
|
var top = $(window).scrollTop();
|
285 |
|
|
var bottom = top + $(window).height();
|
286 |
85ad3d82
|
Assos Assos
|
|
287 |
8a7e43dd
|
Florent Torregrosa
|
bottom -= $('#page-actions').height();
|
288 |
85ad3d82
|
Assos Assos
|
|
289 |
8a7e43dd
|
Florent Torregrosa
|
return bottom;
|
290 |
85ad3d82
|
Assos Assos
|
}
|
291 |
8a7e43dd
|
Florent Torregrosa
|
|
292 |
|
|
function fixToTop(top) {
|
293 |
|
|
if ($tabs.hasClass('bottom-fixed')) {
|
294 |
|
|
$tabs.css({
|
295 |
|
|
'position': 'absolute',
|
296 |
|
|
'top': $tabs.position().top - getParentsTopOffset(),
|
297 |
|
|
'bottom': 'auto'
|
298 |
|
|
});
|
299 |
|
|
$tabs.removeClass('bottom-fixed');
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
if (($tabs.css('position') == 'absolute' && $tabs.offset().top - top >= 0) || ($tabs.css('position') != 'absolute' && $tabs.offset().top - top <= 0)) {
|
303 |
|
|
$tabs.addClass('top-fixed');
|
304 |
|
|
$tabs.attr('style', '');
|
305 |
|
|
}
|
306 |
|
|
}
|
307 |
|
|
|
308 |
|
|
function fixToBottom(bottom) {
|
309 |
|
|
if ($tabs.hasClass('top-fixed')) {
|
310 |
|
|
$tabs.css({
|
311 |
|
|
'position': 'absolute',
|
312 |
|
|
'top': $tabs.position().top - getParentsTopOffset(),
|
313 |
|
|
'bottom': 'auto'
|
314 |
|
|
});
|
315 |
|
|
$tabs.removeClass('top-fixed');
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
if ($tabs.offset().top + $tabs.height() - bottom <= 0) {
|
319 |
|
|
$tabs.addClass('bottom-fixed');
|
320 |
|
|
var style = '';
|
321 |
|
|
var pageActionsHeight = $('#page-actions').height();
|
322 |
|
|
if (pageActionsHeight > 0) {
|
323 |
|
|
style = 'bottom: ' + pageActionsHeight + 'px';
|
324 |
|
|
}
|
325 |
|
|
else if (Drupal.settings.moduleFilter.dynamicPosition) {
|
326 |
|
|
|
327 |
|
|
}
|
328 |
|
|
$tabs.attr('style', style);
|
329 |
|
|
}
|
330 |
85ad3d82
|
Assos Assos
|
}
|
331 |
|
|
|
332 |
8a7e43dd
|
Florent Torregrosa
|
var lastTop = 0;
|
333 |
|
|
$(window).scroll(function() {
|
334 |
|
|
var top = viewportTop();
|
335 |
|
|
var bottom = viewportBottom();
|
336 |
85ad3d82
|
Assos Assos
|
|
337 |
8a7e43dd
|
Florent Torregrosa
|
if ($modules.offset().top >= top) {
|
338 |
|
|
$tabs.removeClass('top-fixed').attr('style', '');
|
339 |
|
|
}
|
340 |
|
|
else {
|
341 |
|
|
if (top > lastTop) {
|
342 |
|
|
if ($tabs.height() > bottom - top) {
|
343 |
|
|
fixToBottom(bottom);
|
344 |
|
|
}
|
345 |
|
|
else {
|
346 |
|
|
fixToTop(top);
|
347 |
|
|
}
|
348 |
|
|
}
|
349 |
|
|
else {
|
350 |
|
|
fixToTop(top);
|
351 |
|
|
}
|
352 |
|
|
}
|
353 |
|
|
lastTop = top;
|
354 |
|
|
});
|
355 |
|
|
|
356 |
|
|
moduleFilter.adjustHeight();
|
357 |
|
|
});
|
358 |
|
|
}
|
359 |
85ad3d82
|
Assos Assos
|
}
|
360 |
8a7e43dd
|
Florent Torregrosa
|
};
|
361 |
|
|
|
362 |
|
|
Drupal.ModuleFilter.Tab = function(element, id) {
|
363 |
|
|
var self = this;
|
364 |
|
|
|
365 |
|
|
this.id = id;
|
366 |
|
|
this.hash = id.substring(0, id.length - 4);
|
367 |
|
|
this.element = element;
|
368 |
|
|
|
369 |
|
|
$('a', this.element).click(function() {
|
370 |
|
|
if (!Drupal.settings.moduleFilter.useURLFragment) {
|
371 |
|
|
var hash = (!self.element.hasClass('selected')) ? self.hash : 'all';
|
372 |
|
|
Drupal.ModuleFilter.selectTab(hash);
|
373 |
|
|
return false;
|
374 |
|
|
}
|
375 |
85ad3d82
|
Assos Assos
|
|
376 |
8a7e43dd
|
Florent Torregrosa
|
if (self.element.hasClass('selected')) {
|
377 |
|
|
|
378 |
|
|
window.location.hash = 'all';
|
379 |
|
|
return false;
|
380 |
85ad3d82
|
Assos Assos
|
}
|
381 |
8a7e43dd
|
Florent Torregrosa
|
});
|
382 |
|
|
|
383 |
|
|
$('tr.' + this.id, $('#system-modules')).hover(
|
384 |
|
|
function() {
|
385 |
|
|
self.element.addClass('suggest');
|
386 |
|
|
},
|
387 |
|
|
function() {
|
388 |
|
|
self.element.removeClass('suggest');
|
389 |
85ad3d82
|
Assos Assos
|
}
|
390 |
8a7e43dd
|
Florent Torregrosa
|
);
|
391 |
|
|
};
|
392 |
85ad3d82
|
Assos Assos
|
|
393 |
8a7e43dd
|
Florent Torregrosa
|
Drupal.ModuleFilter.selectTab = function(hash) {
|
394 |
|
|
if (!hash || Drupal.ModuleFilter.tabs[hash + '-tab'] == undefined || Drupal.settings.moduleFilter.enabledCounts[hash].total == 0) {
|
395 |
|
|
if (Drupal.settings.moduleFilter.rememberActiveTab) {
|
396 |
|
|
var activeTab = Drupal.ModuleFilter.getState('activeTab');
|
397 |
|
|
if (activeTab && Drupal.ModuleFilter.tabs[activeTab + '-tab'] != undefined) {
|
398 |
|
|
hash = activeTab;
|
399 |
|
|
}
|
400 |
|
|
}
|
401 |
85ad3d82
|
Assos Assos
|
|
402 |
8a7e43dd
|
Florent Torregrosa
|
if (!hash) {
|
403 |
|
|
hash = 'all';
|
404 |
|
|
}
|
405 |
85ad3d82
|
Assos Assos
|
}
|
406 |
|
|
|
407 |
8a7e43dd
|
Florent Torregrosa
|
if (Drupal.ModuleFilter.activeTab != undefined) {
|
408 |
|
|
Drupal.ModuleFilter.activeTab.element.removeClass('selected');
|
409 |
85ad3d82
|
Assos Assos
|
}
|
410 |
|
|
|
411 |
8a7e43dd
|
Florent Torregrosa
|
Drupal.ModuleFilter.activeTab = Drupal.ModuleFilter.tabs[hash + '-tab'];
|
412 |
|
|
Drupal.ModuleFilter.activeTab.element.addClass('selected');
|
413 |
|
|
|
414 |
|
|
var moduleFilter = $('input[name="module_filter[name]"]').data('moduleFilter');
|
415 |
|
|
var filter = moduleFilter.applyFilter();
|
416 |
|
|
|
417 |
|
|
if (!Drupal.ModuleFilter.modulesTop) {
|
418 |
|
|
Drupal.ModuleFilter.modulesTop = $('#module-filter-modules').offset().top;
|
419 |
|
|
}
|
420 |
|
|
else {
|
421 |
7d7b5830
|
Assos Assos
|
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
var headerOffset = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0;
|
425 |
8a7e43dd
|
Florent Torregrosa
|
|
426 |
|
|
$('html, body').animate({
|
427 |
7d7b5830
|
Assos Assos
|
scrollTop: Drupal.ModuleFilter.modulesTop - headerOffset
|
428 |
8a7e43dd
|
Florent Torregrosa
|
}, 500);
|
429 |
|
|
|
430 |
85ad3d82
|
Assos Assos
|
}
|
431 |
|
|
|
432 |
8a7e43dd
|
Florent Torregrosa
|
Drupal.ModuleFilter.setState('activeTab', hash);
|
433 |
|
|
};
|
434 |
|
|
|
435 |
|
|
Drupal.ModuleFilter.eventHandlerOperateByURLFragment = function(event) {
|
436 |
|
|
var hash = $.param.fragment();
|
437 |
|
|
Drupal.ModuleFilter.selectTab(hash);
|
438 |
|
|
};
|
439 |
|
|
|
440 |
|
|
Drupal.ModuleFilter.countSummary = function(id) {
|
441 |
|
|
return Drupal.t('@enabled of @total', { '@enabled': Drupal.settings.moduleFilter.enabledCounts[id].enabled, '@total': Drupal.settings.moduleFilter.enabledCounts[id].total });
|
442 |
|
|
};
|
443 |
|
|
|
444 |
|
|
Drupal.ModuleFilter.Tab.prototype.updateEnabling = function(name, remove) {
|
445 |
|
|
this.enabling = this.enabling || {};
|
446 |
|
|
if (!remove) {
|
447 |
|
|
this.enabling[name] = name;
|
448 |
|
|
}
|
449 |
|
|
else {
|
450 |
|
|
delete this.enabling[name];
|
451 |
85ad3d82
|
Assos Assos
|
}
|
452 |
8a7e43dd
|
Florent Torregrosa
|
};
|
453 |
85ad3d82
|
Assos Assos
|
|
454 |
8a7e43dd
|
Florent Torregrosa
|
Drupal.ModuleFilter.Tab.prototype.updateDisabling = function(name, remove) {
|
455 |
|
|
this.disabling = this.disabling || {};
|
456 |
|
|
if (!remove) {
|
457 |
|
|
this.disabling[name] = name;
|
458 |
|
|
}
|
459 |
|
|
else {
|
460 |
|
|
delete this.disabling[name];
|
461 |
|
|
}
|
462 |
|
|
};
|
463 |
|
|
|
464 |
|
|
Drupal.ModuleFilter.Tab.prototype.updateVisualAid = function() {
|
465 |
|
|
var visualAid = '';
|
466 |
|
|
var enabling = new Array();
|
467 |
|
|
var disabling = new Array();
|
468 |
|
|
|
469 |
|
|
if (this.enabling != undefined) {
|
470 |
|
|
for (var i in this.enabling) {
|
471 |
|
|
enabling.push(this.enabling[i]);
|
472 |
85ad3d82
|
Assos Assos
|
}
|
473 |
8a7e43dd
|
Florent Torregrosa
|
if (enabling.length > 0) {
|
474 |
|
|
enabling.sort();
|
475 |
|
|
visualAid += '<span class="enabling">+' + enabling.join('</span>, <span class="enabling">') + '</span>';
|
476 |
85ad3d82
|
Assos Assos
|
}
|
477 |
8a7e43dd
|
Florent Torregrosa
|
}
|
478 |
|
|
if (this.disabling != undefined) {
|
479 |
|
|
for (var i in this.disabling) {
|
480 |
|
|
disabling.push(this.disabling[i]);
|
481 |
|
|
}
|
482 |
|
|
if (disabling.length > 0) {
|
483 |
|
|
disabling.sort();
|
484 |
|
|
if (enabling.length > 0) {
|
485 |
|
|
visualAid += '<br />';
|
486 |
|
|
}
|
487 |
|
|
visualAid += '<span class="disabling">-' + disabling.join('</span>, <span class="disabling">') + '</span>';
|
488 |
85ad3d82
|
Assos Assos
|
}
|
489 |
8a7e43dd
|
Florent Torregrosa
|
}
|
490 |
85ad3d82
|
Assos Assos
|
|
491 |
8a7e43dd
|
Florent Torregrosa
|
if (this.visualAid == undefined) {
|
492 |
|
|
$('a span.summary', this.element).append('<span class="visual-aid"></span>');
|
493 |
|
|
this.visualAid = $('span.visual-aid', this.element);
|
494 |
85ad3d82
|
Assos Assos
|
}
|
495 |
|
|
|
496 |
8a7e43dd
|
Florent Torregrosa
|
this.visualAid.empty().append(visualAid);
|
497 |
|
|
};
|
498 |
|
|
|
499 |
|
|
Drupal.ModuleFilter.getTabID = function($row) {
|
500 |
|
|
var id = $row.data('moduleFilterTabID');
|
501 |
|
|
if (!id) {
|
502 |
|
|
|
503 |
|
|
var classes = $row.attr('class').split(' ');
|
504 |
85ad3d82
|
Assos Assos
|
for (var i in classes) {
|
505 |
8a7e43dd
|
Florent Torregrosa
|
if (Drupal.ModuleFilter.tabs[classes[i]] != undefined) {
|
506 |
|
|
id = classes[i];
|
507 |
85ad3d82
|
Assos Assos
|
break;
|
508 |
|
|
}
|
509 |
|
|
}
|
510 |
8a7e43dd
|
Florent Torregrosa
|
$row.data('moduleFilterTabID', id);
|
511 |
|
|
}
|
512 |
|
|
return id;
|
513 |
|
|
};
|
514 |
85ad3d82
|
Assos Assos
|
|
515 |
8a7e43dd
|
Florent Torregrosa
|
Drupal.ModuleFilter.updateVisualAid = function(type, $row) {
|
516 |
|
|
var id = Drupal.ModuleFilter.getTabID($row);
|
517 |
85ad3d82
|
Assos Assos
|
|
518 |
8a7e43dd
|
Florent Torregrosa
|
if (!id) {
|
519 |
|
|
return false;
|
520 |
|
|
}
|
521 |
85ad3d82
|
Assos Assos
|
|
522 |
8a7e43dd
|
Florent Torregrosa
|
var tab = Drupal.ModuleFilter.tabs[id];
|
523 |
|
|
var name = $('td:nth(1) strong', $row).text();
|
524 |
|
|
switch (type) {
|
525 |
|
|
case 'enable':
|
526 |
|
|
if (Drupal.ModuleFilter.disabling[id + name] != undefined) {
|
527 |
|
|
delete Drupal.ModuleFilter.disabling[id + name];
|
528 |
|
|
tab.updateDisabling(name, true);
|
529 |
|
|
$row.removeClass('disabling');
|
530 |
|
|
}
|
531 |
|
|
else {
|
532 |
|
|
Drupal.ModuleFilter.enabling[id + name] = name;
|
533 |
|
|
tab.updateEnabling(name);
|
534 |
|
|
$row.addClass('enabling');
|
535 |
|
|
}
|
536 |
|
|
break;
|
537 |
|
|
case 'disable':
|
538 |
|
|
if (Drupal.ModuleFilter.enabling[id + name] != undefined) {
|
539 |
|
|
delete Drupal.ModuleFilter.enabling[id + name];
|
540 |
|
|
tab.updateEnabling(name, true);
|
541 |
|
|
$row.removeClass('enabling');
|
542 |
|
|
}
|
543 |
|
|
else {
|
544 |
|
|
Drupal.ModuleFilter.disabling[id + name] = name;
|
545 |
|
|
tab.updateDisabling(name);
|
546 |
|
|
$row.addClass('disabling');
|
547 |
|
|
}
|
548 |
|
|
break;
|
549 |
85ad3d82
|
Assos Assos
|
}
|
550 |
8a7e43dd
|
Florent Torregrosa
|
|
551 |
|
|
tab.updateVisualAid();
|
552 |
|
|
};
|
553 |
|
|
|
554 |
|
|
Drupal.ModuleFilter.Filter.prototype.adjustHeight = function() {
|
555 |
|
|
|
556 |
|
|
var minHeight = $('#module-filter-tabs ul').height() + 10;
|
557 |
|
|
minHeight += $('#module-filter-tabs #module-filter-submit').height();
|
558 |
|
|
$('#module-filter-modules').css('min-height', minHeight);
|
559 |
|
|
this.element.trigger('moduleFilter:adjustHeight');
|
560 |
|
|
}
|
561 |
|
|
|
562 |
85ad3d82
|
Assos Assos
|
})(jQuery); |