You are here

function dnd_library_add_ctools_modal in Scald: Media Management made easy 7

Handle adding CTools Modal JavaScript files.

It would be *really* nice if CTools implemented hook_library and allowed us to simply list ctools.modal as a dependency.

See also

ctools_modal_add_js.

1 call to dnd_library_add_ctools_modal()
dnd_library in modules/library/dnd/dnd.module
Implements hook_library().

File

modules/library/dnd/dnd.module, line 167

Code

function dnd_library_add_ctools_modal(&$libraries) {
  $ctools_path = drupal_get_path('module', 'ctools');
  $libraries['ctools.modal'] = array(
    'title' => 'CTools modal',
    'version' => '1.x',
  );
  $libraries['ctools.modal']['js'][$ctools_path . '/js/modal.js'] = array();
  $settings = array(
    'CToolsModal' => array(
      'loadingText' => t('Loading...'),
      'closeText' => t('Close Window'),
      'closeImage' => theme('image', array(
        'path' => ctools_image_path('icon-close-window.png'),
        'title' => t('Close window'),
        'alt' => t('Close window'),
      )),
      'throbber' => theme('image', array(
        'path' => ctools_image_path('throbber.gif'),
        'title' => t('Loading...'),
        'alt' => t('Loading'),
      )),
    ),
  );
  $libraries['ctools.modal']['js'][] = array(
    'type' => 'setting',
    'data' => $settings,
  );
  $modal_width = (double) variable_get('dnd_modal_width', 500);
  $modal_height = (double) variable_get('dnd_modal_height', 300);

  // Create our own javascript that will be used to theme a modal.
  $sample_style = array(
    'custom-style' => array(
      'modalSize' => array(
        'type' => $modal_width <= 1 ? 'scale' : 'fixed',
        'width' => $modal_width,
        'height' => $modal_height,
        'addWidth' => 20,
        'addHeight' => 15,
      ),
      'modalOptions' => array(
        'opacity' => 0.5,
        'background-color' => '#000',
      ),
      'animation' => 'fadeIn',
      'modalTheme' => 'CToolsSampleModal',
      'throbber' => theme('image', array(
        'path' => ctools_image_path('ajax-loader.gif', 'ctools_ajax_sample'),
        'alt' => t('Loading...'),
        'title' => t('Loading'),
      )),
    ),
  );
  $libraries['ctools.modal']['js'][] = array(
    'type' => 'setting',
    'data' => $sample_style,
  );
  $libraries['ctools.modal']['css'][$ctools_path . '/css/modal.css'] = array(
    'type' => 'file',
  );
  $libraries['ctools.modal']['dependencies'][] = array(
    'system',
    'drupal.progress',
  );
  $libraries['ctools.modal']['dependencies'][] = array(
    'system',
    'drupal.ajax',
  );
  $libraries['ctools.modal']['css'][$ctools_path . '/ctools_ajax_sample/css/ctools-ajax-sample.css'] = array(
    'type' => 'file',
  );
  $libraries['ctools.modal']['js'][$ctools_path . '/ctools_ajax_sample/js/ctools-ajax-sample.js'] = array();
}