blob: 18b366102b319012d0ea147b6f2311d6f77e2cbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// $Id$
(function ($) {
/**
* Implementation of Drupal.behaviors for admin.
*/
Drupal.behaviors.admin = {
attach: function(context) {
// Set the initial state of the toolbar.
$('#toolbar', context).once('toolbar', Drupal.admin.toolbar.init);
// Toggling toolbar drawer.
$('#toolbar a.toggle', context).once('toolbar-toggle').click(function() {
Drupal.admin.toolbar.toggle();
return false;
});
// Set the most recently clicked item as active.
$('#toolbar a').once().click(function() {
$('#toolbar a').each(function() {
$(this).removeClass('active');
});
if ($(this).parents('div.toolbar-shortcuts').length) {
$(this).addClass('active');
}
});
}
};
/**
* Initialize cautiously to avoid collisions with other modules.
*/
Drupal.admin = Drupal.admin || {};
Drupal.admin.toolbar = Drupal.admin.toolbar || {};
/**
* Retrieve last saved cookie settings and set up the initial toolbar state.
*/
Drupal.admin.toolbar.init = function() {
// Retrieve the collapsed status from a stored cookie.
var collapsed = $.cookie('Drupal.admin.toolbar.collapsed');
// Expand or collapse the toolbar based on the cookie value.
if (collapsed == 1) {
Drupal.admin.toolbar.collapse();
}
else {
Drupal.admin.toolbar.expand();
}
}
/**
* Collapse the admin toolbar.
*/
Drupal.admin.toolbar.collapse = function() {
var toggle_text = Drupal.t('Open the drawer');
$('#toolbar div.toolbar-drawer').addClass('collapsed');
$('#toolbar a.toggle')
.removeClass('toggle-active')
.attr('title', toggle_text)
.html(toggle_text);
$('body').removeClass('toolbar-drawer');
$.cookie(
'Drupal.admin.toolbar.collapsed',
1,
{
path: Drupal.settings.basePath,
// The cookie should "never" expire.
expires: 36500
}
);
}
/**
* Expand the admin toolbar.
*/
Drupal.admin.toolbar.expand = function() {
var toggle_text = Drupal.t('Close the drawer');
$('#toolbar div.toolbar-drawer').removeClass('collapsed');
$('#toolbar a.toggle')
.addClass('toggle-active')
.attr('title', toggle_text)
.html(toggle_text);
$('body').addClass('toolbar-drawer');
$.cookie(
'Drupal.admin.toolbar.collapsed',
0,
{
path: Drupal.settings.basePath,
// The cookie should "never" expire.
expires: 36500
}
);
}
/**
* Toggle the admin toolbar.
*/
Drupal.admin.toolbar.toggle = function() {
if ($('#toolbar div.toolbar-drawer').hasClass('collapsed')) {
Drupal.admin.toolbar.expand();
}
else {
Drupal.admin.toolbar.collapse();
}
}
Drupal.admin.toolbar.height = function() {
return $("#toolbar").height();
}
})(jQuery);
|