You are here

function media_library in D7 Media 7.4

Same name and namespace in other branches
  1. 7 media.module \media_library()
  2. 7.2 media.module \media_library()
  3. 7.3 media.module \media_library()

Implements hook_library().

File

./media.module, line 438
Media API

Code

function media_library() {
  $path = drupal_get_path('module', 'media');
  $info = system_get_info('module', 'media');
  $common = array(
    'website' => 'http://drupal.org/project/media',
    'version' => !empty($info['version']) ? $info['version'] : '7.x-2.x',
  );

  // Contains libraries common to other media modules.
  $libraries['media_base'] = array(
    'title' => 'Media base',
    'js' => array(
      $path . '/js/media.core.js' => array(
        'group' => JS_LIBRARY,
        'weight' => -5,
      ),
      $path . '/js/util/json2.js' => array(
        'group' => JS_LIBRARY,
      ),
      $path . '/js/util/ba-debug.min.js' => array(
        'group' => JS_LIBRARY,
      ),
    ),
    'css' => array(
      $path . '/css/media.css',
    ),
  );

  // Includes resources needed to launch the media browser.  Should be included
  // on pages where the media browser needs to be launched from.
  $libraries['media_browser'] = array(
    'title' => 'Media Browser popup libraries',
    'js' => array(
      $path . '/js/media.popups.js' => array(
        'group' => JS_DEFAULT,
      ),
    ),
    'dependencies' => array(
      array(
        'system',
        'ui.resizable',
      ),
      array(
        'system',
        'ui.draggable',
      ),
      array(
        'system',
        'ui.dialog',
      ),
      array(
        'media',
        'media_base',
      ),
    ),
  );

  // Resources needed in the media browser itself.
  $libraries['media_browser_page'] = array(
    'title' => 'Media browser',
    'js' => array(
      $path . '/js/media.browser.js' => array(
        'group' => JS_DEFAULT,
      ),
    ),
    'dependencies' => array(
      array(
        'system',
        'ui.tabs',
      ),
      array(
        'system',
        'ui.draggable',
      ),
      array(
        'system',
        'ui.dialog',
      ),
      array(
        'media',
        'media_base',
      ),
    ),
  );

  // Settings for the dialog etc.
  $settings = array(
    'browserUrl' => url('media/browser', array(
      'query' => array(
        'render' => 'media-popup',
      ),
    )),
    'styleSelectorUrl' => url('media/-media_id-/format-form', array(
      'query' => array(
        'render' => 'media-popup',
      ),
    )),
    'dialogOptions' => array(
      'dialogclass' => variable_get('media_dialogclass', 'media-wrapper'),
      'modal' => (bool) variable_get('media_modal', TRUE),
      'draggable' => (bool) variable_get('media_draggable', FALSE),
      'resizable' => (bool) variable_get('media_resizable', FALSE),
      'minwidth' => (int) variable_get('media_minwidth', 500),
      'width' => (int) variable_get('media_width', 670),
      'height' => (int) variable_get('media_height', 280),
      'position' => variable_get('media_position', 'center'),
      'overlay' => array(
        'backgroundcolor' => variable_get('media_backgroundcolor', '#000000'),
        'opacity' => (double) variable_get('media_opacity', 0.4),
      ),
      'zindex' => (int) variable_get('media_zindex', 10000),
    ),
  );
  $libraries['media_browser_settings'] = array(
    'title' => 'Media browser settings',
    'js' => array(
      0 => array(
        'data' => array(
          'media' => $settings,
        ),
        'type' => 'setting',
      ),
    ),
  );
  foreach ($libraries as &$library) {
    $library += $common;
  }
  return $libraries;
}