You are here

views_ajax_history.module in Views AJAX History 7

Same filename and directory in other branches
  1. 8 views_ajax_history.module

Add required JS to AJAX views.

File

views_ajax_history.module
View source
<?php

/**
 * @file
 * Add required JS to AJAX views.
 */

/**
 * Implements hook_views_pre_render().
 */
function views_ajax_history_views_pre_render(&$view) {
  if ($view->use_ajax && !$view->editing) {

    // @TODO add option to views form for html4+html5 or html5 only
    $history_js = libraries_get_path('history.js') . '/scripts/bundled/html4+html5/jquery.history.js';
    drupal_add_js($history_js, array(
      'group' => JS_LIBRARY,
    ));
    drupal_add_js(drupal_get_path('module', 'views_ajax_history') . '/views_ajax_history.js', array(
      'weight' => 10,
    ));
    drupal_add_js(array(
      'viewsAjaxHistory' => array(
        'renderPageItem' => isset($_GET['page']) ? $_GET['page'] : 0,
      ),
    ), 'setting');
  }
}

Functions