home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (uc_cart_block.js)

This example Drupal source code file (uc_cart_block.js) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

cart_block_toggle, else, function, if, php, true

The uc_cart_block.js Drupal example source code

// $Id: uc_cart_block.js,v 1.8.2.5 2009/09/21 14:34:47 islandusurper Exp $

/**
 * @file
 * Adds effects and behaviors to the cart block.
 */

/**
 * Set the behavior to (un)collapse the cart block on a click
 */
Drupal.behaviors.ucCollapseBlock = function(context) {
  $('.cart-block-title-bar:not(.ucCollapseBlock-processed)', context).addClass('ucCollapseBlock-processed').click(
    function() {
      cart_block_toggle();
    }
  );
}

/**
 * Collapse the shopping cart block at page load.
 */
$(document).ready(
  function() {
    if (Drupal.settings.ucCollapsedBlock == true) {
      // Add the appropriate title bar class.
      $('.cart-block-title-bar').addClass('cart-block-toggle');

      // Add the appropriate arrow class.
      $('.cart-block-arrow').removeClass('arrow-down').addClass('arrow-up');
    }
    else {
      // Add the appropriate arrow class.
      $('.cart-block-arrow').removeClass('arrow-up').addClass('arrow-down');
    }
  }
);

/**
 * Toggle the shopping cart block open and closed.
 */
function cart_block_toggle() {
  // Toggle the display of the cart contents table.
  $('#cart-block-contents').toggle();

  // Toggle the class of the cart block arrow.
  if ($('.cart-block-arrow').hasClass('arrow-up')) {
    $('.cart-block-arrow').removeClass('arrow-up').addClass('arrow-down');
  }
  else {
    $('.cart-block-arrow').removeClass('arrow-down').addClass('arrow-up');
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal uc_cart_block.js source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.