1 |
85ad3d82
|
Assos Assos
|
(function($) {
|
2 |
|
|
|
3 |
|
|
Drupal.admin = Drupal.admin || {};
|
4 |
|
|
Drupal.admin.behaviors = Drupal.admin.behaviors || {};
|
5 |
|
|
Drupal.admin.hashes = Drupal.admin.hashes || {};
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
Drupal.behaviors.adminMenu = {
|
14 |
|
|
attach: function (context, settings) {
|
15 |
|
|
|
16 |
|
|
settings.admin_menu = $.extend({
|
17 |
|
|
suppress: false,
|
18 |
|
|
margin_top: false,
|
19 |
|
|
position_fixed: false,
|
20 |
|
|
tweak_modules: false,
|
21 |
|
|
tweak_permissions: false,
|
22 |
|
|
tweak_tabs: false,
|
23 |
|
|
destination: '',
|
24 |
|
|
basePath: settings.basePath,
|
25 |
|
|
hash: 0,
|
26 |
|
|
replacements: {}
|
27 |
|
|
}, settings.admin_menu || {});
|
28 |
|
|
|
29 |
|
|
if (settings.admin_menu.suppress) {
|
30 |
|
|
return;
|
31 |
|
|
}
|
32 |
|
|
var $adminMenu = $('#admin-menu:not(.admin-menu-processed)', context);
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
if (!$adminMenu.length && settings.admin_menu.hash) {
|
36 |
|
|
Drupal.admin.getCache(settings.admin_menu.hash, function (response) {
|
37 |
|
|
if (typeof response == 'string' && response.length > 0) {
|
38 |
|
|
$('body', context).append(response);
|
39 |
|
|
}
|
40 |
|
|
var $adminMenu = $('#admin-menu:not(.admin-menu-processed)', context);
|
41 |
|
|
|
42 |
|
|
Drupal.admin.attachBehaviors(context, settings, $adminMenu);
|
43 |
|
|
|
44 |
|
|
$(window).triggerHandler('resize');
|
45 |
|
|
});
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
else {
|
49 |
|
|
|
50 |
|
|
Drupal.admin.attachBehaviors(context, settings, $adminMenu);
|
51 |
|
|
}
|
52 |
|
|
}
|
53 |
|
|
};
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
Drupal.behaviors.adminMenuCollapseModules = {
|
59 |
|
|
attach: function (context, settings) {
|
60 |
|
|
if (settings.admin_menu.tweak_modules) {
|
61 |
|
|
$('#system-modules fieldset:not(.collapsed)', context).addClass('collapsed');
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
};
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
Drupal.behaviors.adminMenuCollapsePermissions = {
|
70 |
|
|
attach: function (context, settings) {
|
71 |
|
|
if (settings.admin_menu.tweak_permissions) {
|
72 |
|
|
|
73 |
|
|
$('#permissions th:first', context).css({ width: $('#permissions th:first', context).width() });
|
74 |
|
|
|
75 |
|
|
$modules = $('#permissions tr:has(td.module)', context).once('admin-menu-tweak-permissions', function () {
|
76 |
|
|
var $module = $(this);
|
77 |
|
|
$module.bind('click.admin-menu', function () {
|
78 |
|
|
|
79 |
|
|
$module.nextAll().each(function () {
|
80 |
|
|
var $row = $(this);
|
81 |
|
|
if ($row.is(':has(td.module)')) {
|
82 |
|
|
return false;
|
83 |
|
|
}
|
84 |
|
|
$row.toggleClass('element-hidden');
|
85 |
|
|
});
|
86 |
|
|
});
|
87 |
|
|
});
|
88 |
|
|
|
89 |
|
|
if (window.location.hash.length) {
|
90 |
|
|
$modules = $modules.not(':has(' + window.location.hash + ')');
|
91 |
|
|
}
|
92 |
|
|
$modules.trigger('click.admin-menu');
|
93 |
|
|
}
|
94 |
|
|
}
|
95 |
|
|
};
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
Drupal.behaviors.adminMenuMarginTop = {
|
105 |
|
|
attach: function (context, settings) {
|
106 |
|
|
if (!settings.admin_menu.suppress && settings.admin_menu.margin_top) {
|
107 |
|
|
$('body:not(.admin-menu)', context).addClass('admin-menu');
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
};
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
Drupal.admin.getCache = function (hash, onSuccess) {
|
121 |
|
|
if (Drupal.admin.hashes.hash !== undefined) {
|
122 |
|
|
return Drupal.admin.hashes.hash;
|
123 |
|
|
}
|
124 |
|
|
$.ajax({
|
125 |
|
|
cache: true,
|
126 |
|
|
type: 'GET',
|
127 |
|
|
dataType: 'text',
|
128 |
|
|
global: false,
|
129 |
|
|
url: Drupal.settings.admin_menu.basePath.replace(/admin_menu/, 'js/admin_menu/cache/' + hash),
|
130 |
|
|
success: onSuccess,
|
131 |
|
|
complete: function (XMLHttpRequest, status) {
|
132 |
|
|
Drupal.admin.hashes.hash = status;
|
133 |
|
|
}
|
134 |
|
|
});
|
135 |
|
|
};
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
Drupal.admin.height = function() {
|
143 |
|
|
var $adminMenu = $('#admin-menu');
|
144 |
|
|
var height = $adminMenu.outerHeight();
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
if ($adminMenu.css('filter') && $adminMenu.css('filter').match(/DXImageTransform\.Microsoft\.Shadow/)) {
|
148 |
|
|
height -= $adminMenu.get(0).filters.item("DXImageTransform.Microsoft.Shadow").strength;
|
149 |
|
|
}
|
150 |
|
|
return height;
|
151 |
|
|
};
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) {
|
162 |
|
|
if ($adminMenu.length) {
|
163 |
|
|
$adminMenu.addClass('admin-menu-processed');
|
164 |
|
|
$.each(Drupal.admin.behaviors, function() {
|
165 |
|
|
this(context, settings, $adminMenu);
|
166 |
|
|
});
|
167 |
|
|
}
|
168 |
|
|
};
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
Drupal.admin.behaviors.positionFixed = function (context, settings, $adminMenu) {
|
174 |
|
|
if (settings.admin_menu.position_fixed) {
|
175 |
|
|
$adminMenu.addClass('admin-menu-position-fixed');
|
176 |
|
|
$adminMenu.css('position', 'fixed');
|
177 |
|
|
}
|
178 |
|
|
};
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
Drupal.admin.behaviors.pageTabs = function (context, settings, $adminMenu) {
|
184 |
|
|
if (settings.admin_menu.tweak_tabs) {
|
185 |
|
|
var $tabs = $(context).find('ul.tabs.primary');
|
186 |
|
|
$adminMenu.find('#admin-menu-wrapper > ul').eq(1)
|
187 |
|
|
.append($tabs.find('li').addClass('admin-menu-tab'));
|
188 |
|
|
$(context).find('ul.tabs.secondary')
|
189 |
|
|
.appendTo('#admin-menu-wrapper > ul > li.admin-menu-tab.active')
|
190 |
|
|
.removeClass('secondary');
|
191 |
|
|
$tabs.remove();
|
192 |
|
|
}
|
193 |
|
|
};
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
Drupal.admin.behaviors.replacements = function (context, settings, $adminMenu) {
|
199 |
|
|
for (var item in settings.admin_menu.replacements) {
|
200 |
|
|
$(item, $adminMenu).html(settings.admin_menu.replacements[item]);
|
201 |
|
|
}
|
202 |
|
|
};
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
Drupal.admin.behaviors.destination = function (context, settings, $adminMenu) {
|
208 |
|
|
if (settings.admin_menu.destination) {
|
209 |
|
|
$('a.admin-menu-destination', $adminMenu).each(function() {
|
210 |
|
|
this.search += (!this.search.length ? '?' : '&') + Drupal.settings.admin_menu.destination;
|
211 |
|
|
});
|
212 |
|
|
}
|
213 |
|
|
};
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) {
|
222 |
|
|
|
223 |
|
|
$('li.expandable', $adminMenu).hover(
|
224 |
|
|
function () {
|
225 |
|
|
|
226 |
|
|
clearTimeout(this.sfTimer);
|
227 |
|
|
|
228 |
|
|
$('> ul', this)
|
229 |
|
|
.css({left: 'auto', display: 'block'})
|
230 |
|
|
|
231 |
|
|
.parent().siblings('li').children('ul').css({left: '-999em', display: 'none'});
|
232 |
|
|
},
|
233 |
|
|
function () {
|
234 |
|
|
|
235 |
|
|
var uls = $('> ul', this);
|
236 |
|
|
this.sfTimer = setTimeout(function () {
|
237 |
|
|
uls.css({left: '-999em', display: 'none'});
|
238 |
|
|
}, 400);
|
239 |
|
|
}
|
240 |
|
|
);
|
241 |
|
|
};
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
Drupal.admin.behaviors.search = function (context, settings, $adminMenu) {
|
247 |
|
|
|
248 |
|
|
var $input = $('input.admin-menu-search', $adminMenu);
|
249 |
|
|
|
250 |
|
|
var needle = $input.val();
|
251 |
|
|
|
252 |
|
|
var links;
|
253 |
|
|
|
254 |
|
|
var needleMinLength = 2;
|
255 |
|
|
|
256 |
|
|
var $results = $('<div />').insertAfter($input);
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
function keyupHandler() {
|
262 |
|
|
var matches, $html, value = $(this).val();
|
263 |
|
|
|
264 |
|
|
if (value !== needle) {
|
265 |
|
|
needle = value;
|
266 |
|
|
|
267 |
|
|
if (!links && needle.length >= needleMinLength) {
|
268 |
|
|
|
269 |
|
|
links = buildSearchIndex($adminMenu.find('li:not(.admin-menu-action, .admin-menu-action li) > a'));
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
if (needle.length < needleMinLength) {
|
273 |
|
|
$results.empty();
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
if (needle.length >= needleMinLength && links) {
|
277 |
|
|
matches = findMatches(needle, links);
|
278 |
|
|
|
279 |
|
|
$html = buildResultsList(matches);
|
280 |
|
|
|
281 |
|
|
$results.empty().append($html);
|
282 |
|
|
}
|
283 |
|
|
}
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
function buildSearchIndex($links) {
|
290 |
|
|
return $links
|
291 |
|
|
.map(function () {
|
292 |
|
|
var text = (this.textContent || this.innerText);
|
293 |
|
|
|
294 |
|
|
if (typeof text === 'undefined') {
|
295 |
|
|
return;
|
296 |
|
|
}
|
297 |
|
|
return {
|
298 |
|
|
text: text,
|
299 |
|
|
textMatch: text.toLowerCase(),
|
300 |
|
|
element: this
|
301 |
|
|
};
|
302 |
|
|
});
|
303 |
|
|
}
|
304 |
|
|
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
function findMatches(needle, links) {
|
309 |
|
|
var needleMatch = needle.toLowerCase();
|
310 |
|
|
|
311 |
|
|
return $.grep(links, function (link) {
|
312 |
|
|
return link.textMatch.indexOf(needleMatch) !== -1;
|
313 |
|
|
});
|
314 |
|
|
}
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
function buildResultsList(matches) {
|
320 |
|
|
var $html = $('<ul class="dropdown admin-menu-search-results" />');
|
321 |
|
|
$.each(matches, function () {
|
322 |
|
|
var result = this.text;
|
323 |
|
|
var $element = $(this.element);
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
var $category = $element.closest('#admin-menu-wrapper > ul > li');
|
327 |
|
|
var categoryText = $category.find('> a').text()
|
328 |
|
|
if ($category.length && categoryText) {
|
329 |
|
|
result = categoryText + ': ' + result;
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
var $result = $('<li><a href="' + $element.attr('href') + '">' + result + '</a></li>');
|
333 |
|
|
$result.data('original-link', $(this.element).parent());
|
334 |
|
|
$html.append($result);
|
335 |
|
|
});
|
336 |
|
|
return $html;
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
function resultsHandler(e) {
|
343 |
|
|
var $this = $(this);
|
344 |
|
|
var show = e.type === 'mouseenter' || e.type === 'focusin';
|
345 |
|
|
$this.trigger(show ? 'showPath' : 'hidePath', [this]);
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
function resultsClickHandler(e, link) {
|
352 |
|
|
var $original = $(this).data('original-link');
|
353 |
|
|
$original.trigger('mouseleave');
|
354 |
|
|
$input.val('').trigger('keyup');
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
function highlightPathHandler(e, link) {
|
361 |
|
|
if (link) {
|
362 |
|
|
var $original = $(link).data('original-link');
|
363 |
|
|
var show = e.type === 'showPath';
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
$original.toggleClass('highlight', show);
|
367 |
|
|
$original.trigger(show ? 'mouseenter' : 'mouseleave');
|
368 |
|
|
}
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
|
372 |
|
|
$results.delegate('li', 'mouseenter mouseleave focus blur', resultsHandler);
|
373 |
|
|
|
374 |
|
|
$results.delegate('li', 'click', resultsClickHandler);
|
375 |
|
|
|
376 |
|
|
$adminMenu.delegate('.admin-menu-search-results li', 'showPath hidePath', highlightPathHandler);
|
377 |
|
|
|
378 |
|
|
$input.bind('keyup search', keyupHandler);
|
379 |
|
|
};
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
|
383 |
|
|
|
384 |
|
|
|
385 |
|
|
})(jQuery); |