/[drupal]/drupal/modules/toolbar/toolbar.js
ViewVC logotype

Contents of /drupal/modules/toolbar/toolbar.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Sat Oct 17 00:51:53 2009 UTC (5 weeks, 4 days ago) by dries
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10
Changes since 1.6: +7 -7 lines
File MIME type: text/javascript
- Patch #511286 by JacobSingh, David_Rothstein, dmitrig01, Gábor Hojtsy, ksenzee et al: add customizable shortcuts to the toolbar.
1 // $Id: toolbar.js,v 1.6 2009/09/15 20:50:48 dries Exp $
2 (function ($) {
3
4 /**
5 * Implementation of Drupal.behaviors for admin.
6 */
7 Drupal.behaviors.admin = {
8 attach: function(context) {
9
10 // Set the intial state of the toolbar.
11 $('#toolbar', context).once('toolbar', Drupal.admin.toolbar.init);
12
13 // Toggling toolbar drawer.
14 $('#toolbar span.toggle', context).once('toolbar-toggle').click(function() {
15 Drupal.admin.toolbar.toggle();
16 return false;
17 });
18 }
19 };
20
21 /**
22 * Initialize cautiously to avoid collisions with other modules.
23 */
24 Drupal.admin = Drupal.admin || {};
25 Drupal.admin.toolbar = Drupal.admin.toolbar || {};
26
27 /**
28 * Retrieve last saved cookie settings and set up the initial toolbar state.
29 */
30 Drupal.admin.toolbar.init = function() {
31 // Retrieve the collapsed status from a stored cookie.
32 var collapsed = $.cookie('Drupal.admin.toolbar.collapsed');
33
34 // Expand or collapse the toolbar based on the cookie value.
35 if (collapsed == 1) {
36 Drupal.admin.toolbar.collapse();
37 }
38 else {
39 Drupal.admin.toolbar.expand();
40 }
41 }
42
43 /**
44 * Collapse the admin toolbar.
45 */
46 Drupal.admin.toolbar.collapse = function() {
47 $('#toolbar div.toolbar-drawer').addClass('collapsed');
48 $('#toolbar span.toggle').removeClass('toggle-active');
49 $('body').removeClass('toolbar-drawer');
50 $.cookie(
51 'Drupal.admin.toolbar.collapsed',
52 1,
53 {path: Drupal.settings.basePath}
54 );
55 }
56
57 /**
58 * Expand the admin toolbar.
59 */
60 Drupal.admin.toolbar.expand = function() {
61 $('#toolbar div.toolbar-drawer').removeClass('collapsed');
62 $('#toolbar span.toggle').addClass('toggle-active');
63 $('body').addClass('toolbar-drawer');
64 $.cookie(
65 'Drupal.admin.toolbar.collapsed',
66 0,
67 {path: Drupal.settings.basePath}
68 );
69 }
70
71 /**
72 * Toggle the admin toolbar.
73 */
74 Drupal.admin.toolbar.toggle = function() {
75 if ($('#toolbar .toolbar-drawer').is('.collapsed')) {
76 Drupal.admin.toolbar.expand();
77 }
78 else {
79 Drupal.admin.toolbar.collapse();
80 }
81 }
82
83 Drupal.admin.toolbar.height = function() {
84 return $("#toolbar").height();
85 }
86
87 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.2