Skip to content
Snippets Groups Projects
Select Git revision
  • 2011-11-14
  • master default
  • issue-752
  • develop
  • issue-677
  • issue-677-original-with-migrate
  • issue-716
  • issue-654
  • issue-732
  • issue-737
  • issue-735
  • issue-707
  • issue-706
  • issue-705
  • issue-703
  • issue-696
  • issue-690
  • issue-675
  • issue-670
  • issue-635
  • issue-404
  • 7.19
  • 2012-04-18
  • 2012-04-03
  • 2012-04-02
  • 2012-03-01
  • 2012-02-07
  • 20120207
  • 2012-01-13
  • 2012-01-12
  • 2011-12-16
  • 2011-12-05
  • 2011-11-17
  • 2011-11-08.2
  • 2011-11-08
  • 2011-11-01
  • 2011-10-27
  • 2011-10-06
  • 2011-10-03
  • 2011-09-19
40 results

toolbar.js

Blame
  • Forked from UNL Information Services / UNL-CMS
    640 commits behind, 1 commit ahead of the upstream repository.
    user avatar
    Tim Steiner authored
    git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@751 20a16fea-79d4-4915-8869-1ea9d5ebf173
    636cbb7e
    History
    toolbar.js 2.64 KiB
    (function ($) {
    
    Drupal.toolbar = Drupal.toolbar || {};
    
    /**
     * Attach toggling behavior and notify the overlay of the toolbar.
     */
    Drupal.behaviors.toolbar = {
      attach: function(context) {
    
        // Set the initial state of the toolbar.
        $('#toolbar', context).once('toolbar', Drupal.toolbar.init);
    
        // Toggling toolbar drawer.
        $('#toolbar a.toggle', context).once('toolbar-toggle').click(function(e) {
          Drupal.toolbar.toggle();
          // Allow resize event handlers to recalculate sizes/positions.
          $(window).triggerHandler('resize');
          return false;
        });
      }
    };
    
    /**
     * Retrieve last saved cookie settings and set up the initial toolbar state.
     */
    Drupal.toolbar.init = function() {
      // Retrieve the collapsed status from a stored cookie.
      var collapsed = $.cookie('Drupal.toolbar.collapsed');
    
      // Expand or collapse the toolbar based on the cookie value.
      if (collapsed == 1) {
        Drupal.toolbar.collapse();
      }
      else {
        Drupal.toolbar.expand();
      }
    };
    
    /**
     * Collapse the toolbar.
     */
    Drupal.toolbar.collapse = function() {
      var toggle_text = Drupal.t('Show shortcuts');
      $('#toolbar div.toolbar-drawer').addClass('collapsed');
      $('#toolbar a.toggle')
        .removeClass('toggle-active')
        .attr('title',  toggle_text)
        .html(toggle_text);
      $('body').removeClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
      $.cookie(
        'Drupal.toolbar.collapsed',
        1,
        {
          path: Drupal.settings.basePath,
          // The cookie should "never" expire.
          expires: 36500
        }
      );
    };
    
    /**
     * Expand the toolbar.
     */
    Drupal.toolbar.expand = function() {
      var toggle_text = Drupal.t('Hide shortcuts');
      $('#toolbar div.toolbar-drawer').removeClass('collapsed');
      $('#toolbar a.toggle')
        .addClass('toggle-active')
        .attr('title',  toggle_text)
        .html(toggle_text);
      $('body').addClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
      $.cookie(
        'Drupal.toolbar.collapsed',
        0,
        {
          path: Drupal.settings.basePath,
          // The cookie should "never" expire.
          expires: 36500
        }
      );
    };
    
    /**
     * Toggle the toolbar.
     */
    Drupal.toolbar.toggle = function() {
      if ($('#toolbar div.toolbar-drawer').hasClass('collapsed')) {
        Drupal.toolbar.expand();
      }
      else {
        Drupal.toolbar.collapse();
      }
    };
    
    Drupal.toolbar.height = function() {
      var height = $('#toolbar').outerHeight();
      // In IE, Shadow filter adds some extra height, so we need to remove it from
      // the returned height.
      if ($('#toolbar').css('filter').match(/DXImageTransform\.Microsoft\.Shadow/)) {
        height -= $('#toolbar').get(0).filters.item("DXImageTransform.Microsoft.Shadow").strength;
      }
      return height;
    };
    
    })(jQuery);