You are here

function uc_ajax_cart_init in Ubercart AJAX Cart 7.2

Same name and namespace in other branches
  1. 6.2 uc_ajax_cart.module \uc_ajax_cart_init()

File

./uc_ajax_cart.module, line 404

Code

function uc_ajax_cart_init() {
  static $loaded;
  if (isset($loaded) && $loaded === TRUE) {
    return;
  }

  /** Add standard js **/
  drupal_add_library('system', 'jquery.form');
  drupal_add_js(drupal_get_path('module', 'uc_ajax_cart') . '/js/jquery.blockui.js');
  drupal_add_js(drupal_get_path('module', 'uc_ajax_cart') . '/js/uc_ajax_cart.js');
  drupal_add_js(drupal_get_path('module', 'uc_ajax_cart') . '/js/jquery.cookie.js');
  drupal_add_css(drupal_get_path('module', 'uc_ajax_cart') . '/css/uc_ajax_cart.css');
  $settings = array(
    'CALLBACK' => url(UC_AJAX_CART_ADD_CALLBACK),
    'SHOW_CALLBACK' => url(UC_AJAX_CART_SHOW_CALLBACK),
    'ADD_TITLE' => t('Please wait'),
    // Message's title displayed when a product is being added to cart.
    'ADD_MESSAGE' => t('Add product to cart'),
    // Message displayed when a product is being added to cart.
    'REMOVE_TITLE' => t('Please wait'),
    // Message's title displayed when a product is being removed to cart.
    'REMOVE_MESSAGE' => t('Remove product from cart'),
    // Message displayed when a product is being removed from cart.
    'CART_LINK_CALLBACK' => url(UC_AJAX_CART_LINK_CALLBACK),
    'BLOCK_UI' => (int) variable_get('ajax_cart_message_effect', UC_AJAX_CART_DEFAULT_EFFECT),
    'TIMEOUT' => (int) variable_get('ajax_cart_message_timeout', UC_AJAX_CART_DEFAULT_TIMEOUT),
    'UPDATE_CALLBACK' => url(UC_AJAX_CART_UPDATE_CALLBACK),
    'UPDATE_MESSAGE' => t('Update cart'),
    // Message displayed when a product is being updated in cart.
    'UPDATE' => variable_get('uc_ajax_cart_closed_update', 0),
    'CART_OPERATION' => t('Cart'),
    // Message's title displayed when a product is being added to cart.
    'CART_VIEW_ON' => variable_get('uc_ajax_cart_cart_view', 0),
    'SHOW_VIEW_CALLBACK' => url(UC_AJAX_CART_SHOW_VIEW_CALLBACK),
    'TRACK_CLOSED_STATE' => variable_get('uc_ajax_cart_track_closed_state', 0),
    'INITIAL_CLOSED_STATE' => variable_get('uc_ajax_cart_closed_default', FALSE),
    'CART_PANE_EFFECT' => variable_get('uc_ajax_cart_pane_effect', 0),
    'CART_PANE_EFFECT_DURATION' => (int) variable_get('uc_ajax_cart_pane_effect_duration', UC_AJAX_CART_DEFAULT_PANE_EFFECT_DURATION),
    'HIDE_CART_OPERATIONS' => variable_get('uc_ajax_cart_hide_cart_op_msgs', FALSE),
    'COLLAPSIBLE_CART' => variable_get('uc_ajax_cart_closed', 0),
  );
  if (($include_exclude = variable_get('uc_ajax_cart_include_exclude', 0)) && ($ajaxify_class = variable_get('uc_ajax_cart_ajaxify_class', ''))) {
    $settings['AJAXIFY_CLASS_EXCLUDES'] = $include_exclude - 1;
    $settings['AJAXIFY_CLASS'] = $ajaxify_class;
  }
  drupal_add_js(array(
    'uc_ajax_cart' => $settings,
  ), array(
    'type' => 'setting',
    'scope' => 'footer',
    'group' => JS_DEFAULT,
  ));
  $loaded = TRUE;
}