You are here

function responsive_preview_library in Responsive Theme Preview 7

Implements hook_library().

File

./responsive_preview.module, line 240
Provides a component that previews the a page in various device dimensions.

Code

function responsive_preview_library() {
  $path = drupal_get_path('module', 'responsive_preview');
  $options = array(
    'scope' => 'footer',
    'defer' => TRUE,
  );
  $libraries['responsive-preview'] = array(
    'title' => 'Preview layouts',
    'version' => VERSION,
    'css' => array(
      $path . '/css/responsive-preview.base.css',
      $path . '/css/responsive-preview.theme.css',
      $path . '/css/responsive-preview.icons.css',
    ),
    'js' => array(
      // Monkey-patch in jQuery UI 1.10 Position at $.fn.position_responsive_preview.
      $path . '/js/jquery/ducktape.position.js' => $options,
      $path . '/js/responsive-preview.js' => $options,
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'responsive_preview',
        'debounce',
      ),
      array(
        'responsive_preview',
        'displace',
      ),
      array(
        'responsive_preview',
        'underscore',
      ),
      array(
        'responsive_preview',
        'backbone',
      ),
    ),
  );

  // A utility function to avoid stampeding function invocations.
  $libraries['debounce'] = array(
    'title' => 'Debounce',
    'version' => VERSION,
    'js' => array(
      $path . '/js/debounce.js' => array(
        'group' => JS_LIBRARY,
        'weight' => -19,
      ),
    ),
  );

  // A utility function determine viewport offset distances.
  $libraries['displace'] = array(
    'title' => 'Responsive preview displace',
    'version' => VERSION,
    'js' => array(
      $path . '/js/displace.js' => array(
        'group' => JS_LIBRARY,
      ),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'responsive_preview',
        'debounce',
      ),
    ),
  );

  // Underscore
  $libraries['underscore'] = _responsive_preview_convert_libraries_to_library(libraries_detect('underscore'), array(
    'group' => JS_LIBRARY,
    'weight' => -20,
  ));

  // Backbone
  $libraries['backbone'] = _responsive_preview_convert_libraries_to_library(libraries_detect('backbone'), array(
    'group' => JS_LIBRARY,
    'weight' => -19,
  ));
  return $libraries;
}