You are here

function ctools_modal_add_plugin_js in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/modal.inc \ctools_modal_add_plugin_js()

@todo Deprecated this.

2 calls to ctools_modal_add_plugin_js()
ctools_context_admin_includes in includes/context-admin.inc
Include all context administrative include files, css, javascript.
ctools_context_handler_edit_criteria in includes/context-task-handler.inc
Form to choose context based selection rules for a task handler.

File

includes/modal.inc, line 79
Implement a modal form using AJAX.

Code

function ctools_modal_add_plugin_js($plugins) {
  $css = array();
  $js = array(
    drupal_get_path('module', 'ctools') . '/js/dependent.js' => TRUE,
  );
  foreach ($plugins as $subtype) {
    if (isset($subtype['js'])) {
      foreach ($subtype['js'] as $file) {
        if (file_exists($file)) {
          $js[$file] = TRUE;
        }
        elseif (file_exists($subtype['path'] . '/' . $file)) {
          $js[$subtype['path'] . '/' . $file] = TRUE;
        }
      }
    }
    if (isset($subtype['css'])) {
      foreach ($subtype['css'] as $file) {
        if (file_exists($file)) {
          $css[$file] = TRUE;
        }
        elseif (file_exists($subtype['path'] . '/' . $file)) {
          $css[$subtype['path'] . '/' . $file] = TRUE;
        }
      }
    }
  }
  foreach (array_keys($js) as $file) {
    drupal_add_js($file);
  }
  foreach (array_keys($css) as $file) {
    drupal_add_css($file);
  }
}