diff --git a/core/includes/common.inc b/core/includes/common.inc
index 17e1363..06a099f 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3826,23 +3826,10 @@ function drupal_add_js($data = NULL, $options = NULL) {
'weight' => 0,
'browsers' => array(),
),
- 'core/misc/drupal.js' => array(
- 'data' => 'core/misc/drupal.js',
- 'type' => 'file',
- 'scope' => 'header',
- 'group' => JS_LIBRARY,
- 'every_page' => TRUE,
- 'weight' => -1,
- 'preprocess' => TRUE,
- 'cache' => TRUE,
- 'defer' => FALSE,
- 'async' => FALSE,
- 'browsers' => array(),
- ),
);
- // Register all required libraries.
+ // Impicit dependencies of JS settings.
drupal_add_library('system', 'jquery', TRUE);
- drupal_add_library('system', 'jquery.once', TRUE);
+ drupal_add_library('system', 'drupal', TRUE);
drupal_add_library('system', 'html5shiv', TRUE);
}
@@ -4228,7 +4215,7 @@ function drupal_aggregate_js(&$js_groups) {
* are the attached data. For example:
* @code
* $build['#attached'] = array(
- * 'js' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.js'),
+ * 'library' => array(array('taxonomy', 'taxonomy')),
* 'css' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.css'),
* );
* @endcode
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 47c14ab..5acb6ee 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -3405,7 +3405,7 @@ function theme_tableselect($variables) {
// checkboxes/radios in the first table column.
if ($element['#js_select']) {
// Add a "Select all" checkbox.
- drupal_add_js('core/misc/tableselect.js');
+ drupal_add_library('system', 'drupal.tableselect');
array_unshift($header, array('class' => array('select-all')));
}
else {
@@ -3594,7 +3594,7 @@ function form_process_machine_name($element, &$form_state) {
),
),
);
- $element['#attached']['js'][] = 'core/misc/machine-name.js';
+ $element['#attached']['library'][] = array('system', 'drupal.machine-name');
$element['#attached']['js'][] = $js_settings;
return $element;
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 45c7e51..498280e 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1525,9 +1525,9 @@ function install_configure_form($form, &$form_state, &$install_state) {
drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the online handbook.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'warning');
}
- drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
+ drupal_add_library('system', 'system');
// Add JavaScript time zone detection.
- drupal_add_js('core/misc/timezone.js');
+ drupal_add_library('system', 'drupal.timezone');
// We add these strings as settings because JavaScript translation does not
// work on install time.
drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail'))), 'setting');
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index f807979..d1d34aa 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1841,7 +1841,7 @@ function theme_table($variables) {
// Add sticky headers, if applicable.
if (count($header) && $sticky) {
- drupal_add_js('core/misc/tableheader.js');
+ drupal_add_library('system', 'drupal.tableheader');
// Add 'sticky-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
$attributes['class'][] = 'sticky-enabled';
diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc
index aa018da..192cb2f 100644
--- a/core/modules/block/block.admin.inc
+++ b/core/modules/block/block.admin.inc
@@ -82,8 +82,8 @@ function block_admin_display_prepare_blocks($theme) {
function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_regions = NULL) {
$path = drupal_get_path('module', 'block');
$form['#attached']['css'][] = $path . '/block.admin.css';
- $form['#attached']['js'][] = 'core/misc/tableheader.js';
- $form['#attached']['js'][] = $path . '/block.js';
+ $form['#attached']['library'][] = array('system', 'drupal.tableheader');
+ $form['#attached']['library'][] = array('block', 'block');
// Get a list of block regions if one was not provided.
if (!isset($block_regions)) {
@@ -346,7 +346,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
$form['visibility'] = array(
'#type' => 'vertical_tabs',
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'block') . '/block.js'),
+ 'library' => array(array('block', 'block')),
),
);
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 2592137..f9cd07b 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -1085,3 +1085,22 @@ function block_language_delete($language) {
->condition('langcode', $language->langcode)
->execute();
}
+
+/**
+ * Implements hook_library_info().
+ */
+function block_library_info() {
+ $libraries['block'] = array(
+ 'title' => 'Block',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'block') . '/block.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index 9231082..e59e782 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -544,7 +544,7 @@ function _book_add_form_elements(&$form, &$form_state, Node $node) {
'class' => array('book-outline-form'),
),
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'book') . '/book.js'),
+ 'library' => array(array('book', 'book')),
),
'#tree' => TRUE,
);
@@ -1454,3 +1454,22 @@ function book_menu_subtree_data($link) {
return $tree[$cid];
}
+
+/**
+ * Implements hook_library_info().
+ */
+function book_library_info() {
+ $libraries['book'] = array(
+ 'title' => 'Book',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'book') . '/book.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index b2b67a7..a958b97 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -184,9 +184,8 @@ function color_scheme_form($complete_form, &$form_state, $theme) {
'#options' => $color_sets,
'#default_value' => $scheme_name,
'#attached' => array(
- // Add Farbtastic color picker.
'library' => array(
- array('system', 'farbtastic'),
+ array('color', 'color'),
),
// Add custom CSS.
'css' => array(
@@ -194,7 +193,6 @@ function color_scheme_form($complete_form, &$form_state, $theme) {
),
// Add custom JavaScript.
'js' => array(
- $base . '/color.js',
array(
'data' => array(
'color' => array(
@@ -246,6 +244,7 @@ function theme_color_scheme_form($variables) {
$path = drupal_get_path('theme', $theme) . '/';
drupal_add_css($path . $info['preview_css']);
+ // TODO transform to add library
$preview_js_path = isset($info['preview_js']) ? $path . $info['preview_js'] : drupal_get_path('module', 'color') . '/' . 'preview.js';
// Add the JS at a weight below color.js.
drupal_add_js($preview_js_path, array('weight' => -1));
@@ -744,3 +743,35 @@ function _color_rgb2hsl($rgb) {
return array($h, $s, $l);
}
+
+/**
+ * Implements hook_library_info().
+ */
+function color_library_info() {
+ $libraries['color'] = array(
+ 'title' => 'Color',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'color') . '/color.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ array('system', 'farbtastic'),
+ array('color', 'color.preview'),
+ ),
+ );
+ $libraries['color.preview'] = array(
+ 'title' => 'Color preview',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'color') . '/preview.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index da5e25b..6970325 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1183,7 +1183,7 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
'class' => array('comment-node-type-settings-form'),
),
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
+ 'library' => array('comment', 'comment'),
),
);
// Unlike coment_form_node_form_alter(), all of these settings are applied
@@ -1261,8 +1261,8 @@ function comment_form_node_form_alter(&$form, $form_state) {
'class' => array('comment-node-settings-form'),
),
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
- ),
+ 'library' => array('comment', 'comment'),
+ ),
'#weight' => 30,
);
$comment_count = isset($node->nid) ? db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() : 0;
@@ -2154,3 +2154,22 @@ function comment_file_download_access($field, $entity_type, $entity) {
return FALSE;
}
}
+
+/**
+ * Implements hook_library_info().
+ */
+function comment_library_info() {
+ $libraries['comment'] = array(
+ 'title' => 'Comment',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'comment') . '/comment-node-form.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module
index a09d09f..5671967 100644
--- a/core/modules/contextual/contextual.module
+++ b/core/modules/contextual/contextual.module
@@ -51,6 +51,10 @@ function contextual_library_info() {
$path . '/contextual.base.css' => array(),
$path . '/contextual.theme.css' => array(),
),
+ 'dependencies' => array(
+ array('system', 'jquery.once'),
+ array('system', 'drupal'),
+ ),
);
return $libraries;
}
diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc
index 5871be0..19b26f2 100644
--- a/core/modules/field_ui/field_ui.admin.inc
+++ b/core/modules/field_ui/field_ui.admin.inc
@@ -641,7 +641,7 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
$form['#attached']['css'][] = drupal_get_path('module', 'field_ui') . '/field_ui.admin.css';
- $form['#attached']['js'][] = drupal_get_path('module', 'field_ui') . '/field_ui.js';
+ $form['#attached']['library'][] = array('field_ui', 'field_ui');
// Add settings for the update selects behavior.
$js_fields = array();
@@ -1228,7 +1228,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
- $form['#attached']['js'][] = drupal_get_path('module', 'field_ui') . '/field_ui.js';
+ $form['#attached']['library'][] = array('field_ui', 'field_ui');
$form['#attached']['css'][] = drupal_get_path('module', 'field_ui') . '/field_ui.admin.css';
// Add tabledrag behavior.
diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module
index 076cc23..f0e5f0e 100644
--- a/core/modules/field_ui/field_ui.module
+++ b/core/modules/field_ui/field_ui.module
@@ -380,3 +380,22 @@ function field_ui_form_node_type_form_submit($form, &$form_state) {
$form_state['redirect'] = _field_ui_bundle_admin_path('node', $form_state['values']['type']) .'/fields';
}
}
+
+/**
+ * Implements hook_library_info().
+ */
+function field_ui_library_info() {
+ $libraries['field_ui'] = array(
+ 'title' => 'Field UI',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'field_ui') . '/field_ui.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index 70314db..f1285bd 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -37,7 +37,7 @@ function file_field_settings_form($field, $instance, $has_data) {
$defaults = field_info_field_settings($field['type']);
$settings = array_merge($defaults, $field['settings']);
- $form['#attached']['js'][] = drupal_get_path('module', 'file') . '/file.js';
+ $form['#attached']['library'][] = array('file', 'file');
$form['display_field'] = array(
'#type' => 'checkbox',
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 24dd94f..bb15fa0 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -79,7 +79,7 @@ function file_element_info() {
'#extended' => FALSE,
'#attached' => array(
'css' => array($file_path . '/file.admin.css'),
- 'js' => array($file_path . '/file.js'),
+ 'library' => array(array('file','file')),
),
);
return $types;
@@ -1023,3 +1023,22 @@ function file_get_file_references(File $file, $field = NULL, $age = FIELD_LOAD_R
/**
* @} End of "defgroup file-module-api".
*/
+
+/**
+ * Implements hook_library_info().
+ */
+function file_library_info() {
+ $libraries['file'] = array(
+ 'title' => 'File',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'file') . '/file.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc
index 40a5eab..ded423f 100644
--- a/core/modules/filter/filter.admin.inc
+++ b/core/modules/filter/filter.admin.inc
@@ -120,7 +120,7 @@ function filter_admin_format_form($form, &$form_state, $format) {
$form['#format'] = $format;
$form['#tree'] = TRUE;
- $form['#attached']['js'][] = drupal_get_path('module', 'filter') . '/filter.admin.js';
+ $form['#attached']['library'][] = array('filter', 'filter.admin');
$form['#attached']['css'][] = drupal_get_path('module', 'filter') . '/filter.admin.css';
$form['name'] = array(
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 4d9bfef..48a1bd9 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -845,7 +845,7 @@ function filter_process_format($element) {
// Turn original element into a text format wrapper.
$path = drupal_get_path('module', 'filter');
- $element['#attached']['js'][] = $path . '/filter.js';
+ $element['#attached']['library'][] = array('filter', 'filter');
$element['#attached']['css'][] = $path . '/filter.admin.css';
// Setup child container for the text format widget.
@@ -1695,3 +1695,33 @@ function _filter_html_escape_tips($filter, $format, $long = FALSE) {
/**
* @} End of "defgroup standard_filters".
*/
+
+/**
+ * Implements hook_library_info().
+ */
+function filter_library_info() {
+ $libraries['filter.admin'] = array(
+ 'title' => 'Filter',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'filter') . '/filter.admin.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+ $libraries['filter'] = array(
+ 'title' => 'Filter',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'filter') . '/filter.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index f7c22c1..230a302 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -430,8 +430,7 @@ function locale_library_info_alter(&$libraries, $module) {
// locale.datepicker.js should be added in the JS_LIBRARY group, so that
// this attach behavior will execute early. JS_LIBRARY is the default for
// hook_library_info_alter(), thus does not have to be specified explicitly.
- $datepicker = drupal_get_path('module', 'locale') . '/locale.datepicker.js';
- $libraries['jquery.ui.datepicker']['js'][$datepicker] = array();
+ $libraries['jquery.ui.datepicker']['dependencies'][] = array('locale', 'locale.datepicker');
$libraries['jquery.ui.datepicker']['js'][] = array(
'data' => array(
'jquery' => array(
@@ -879,3 +878,34 @@ function _locale_rebuild_js($langcode = NULL) {
return TRUE;
}
}
+
+
+/**
+ * Implements hook_library_info().
+ */
+function locale_library_info() {
+ $libraries['locale.admin'] = array(
+ 'title' => 'Locale',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'locale') . '/locale.admin.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+ $libraries['locale.datepicker'] = array(
+ 'title' => 'Locale Datepicker UI',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'locale') . '/locale.datepicker.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery.ui.datepicker'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index 539c382..377a1bb 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -255,8 +255,8 @@ function locale_translate_edit_form($form, &$form_state) {
$form['#attached']['css'] = array(
$path . '/locale.admin.css',
);
- $form['#attached']['js'] = array(
- $path . '/locale.admin.js',
+ $form['#attached']['library'] = array(
+ array('locale', 'locale.admin')
);
$form['langcode'] = array(
diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module
index 653c17f..f54371f 100644
--- a/core/modules/menu/menu.module
+++ b/core/modules/menu/menu.module
@@ -650,7 +650,7 @@ function menu_form_node_form_alter(&$form, $form_state) {
'#collapsed' => !$link['link_title'],
'#group' => 'additional_settings',
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'menu') . '/menu.js'),
+ 'library' => array(array('menu', 'menu')),
),
'#tree' => TRUE,
'#weight' => -2,
@@ -755,7 +755,7 @@ function menu_form_node_type_form_alter(&$form, $form_state) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'menu') . '/menu.admin.js'),
+ 'library' => array(array('menu', 'menu.admin')),
),
'#group' => 'additional_settings',
);
@@ -819,3 +819,33 @@ function menu_preprocess_block(&$variables) {
$variables['attributes']['role'] = 'navigation';
}
}
+
+/**
+ * Implements hook_library_info().
+ */
+function menu_library_info() {
+ $libraries['menu'] = array(
+ 'title' => 'Menu',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'menu') . '/menu.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+ $libraries['menu.admin'] = array(
+ 'title' => 'Menu admin',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'menu') . '/menu.admin.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc
index 88495f4..d626302 100644
--- a/core/modules/node/content_types.inc
+++ b/core/modules/node/content_types.inc
@@ -127,7 +127,7 @@ function node_type_form($form, &$form_state, $type = NULL) {
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'node') . '/content_types.js'),
+ 'library' => array(array('node', 'node.content_types')),
),
);
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index d425232..4f4281a 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -222,7 +222,7 @@ function node_filter_form() {
$form['filters']['status']['actions']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
}
- drupal_add_js('core/misc/form.js');
+ drupal_add_library('system', 'drupal.form');
return $form;
}
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 2ef5fa9..f757fb9 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -3995,3 +3995,33 @@ function node_language_delete($language) {
->condition('langcode', $language->langcode)
->execute();
}
+
+/**
+ * Implements hook_library_info().
+ */
+function node_library_info() {
+ $libraries['node'] = array(
+ 'title' => 'Node',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'node') . '/node.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+ $libraries['node.content_types'] = array(
+ 'title' => 'Content types',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'node') . '/content_types.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module
index 5098216..318088f 100644
--- a/core/modules/openid/openid.module
+++ b/core/modules/openid/openid.module
@@ -135,8 +135,7 @@ function openid_form_user_login_alter(&$form, &$form_state) {
function _openid_user_login_form_alter(&$form, &$form_state) {
$form['#attached']['css'][] = drupal_get_path('module', 'openid') . '/openid.css';
- $form['#attached']['js'][] = drupal_get_path('module', 'openid') . '/openid.js';
- $form['#attached']['library'][] = array('system', 'jquery.cookie');
+ $form['#attached']['library'][] = array('openid', 'openid');
if (!empty($form_state['input']['openid_identifier'])) {
$form['name']['#required'] = FALSE;
$form['pass']['#required'] = FALSE;
@@ -1076,3 +1075,22 @@ function openid_cron() {
->condition('expires', REQUEST_TIME, '<')
->execute();
}
+
+/**
+ * Implements hook_library_info().
+ */
+function openid_library_info() {
+ $libraries['openid'] = array(
+ 'title' => 'OpenID',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'openid') . '/openid.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery.cookie')
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 3aaed7d..0e15ab6 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -200,7 +200,7 @@ function overlay_library_info() {
$module_path = drupal_get_path('module', 'overlay');
// Overlay parent.
- $libraries['parent'] = array(
+ $libraries['overlay.parent'] = array(
'title' => 'Overlay: Parent',
'website' => 'http://drupal.org/documentation/modules/overlay',
'version' => '1.0',
@@ -211,12 +211,13 @@ function overlay_library_info() {
$module_path . '/overlay-parent.css' => array(),
),
'dependencies' => array(
+ array('system', 'drupal'),
array('system', 'jquery.ui.core'),
array('system', 'jquery.bbq'),
),
);
// Overlay child.
- $libraries['child'] = array(
+ $libraries['overlay.child'] = array(
'title' => 'Overlay: Child',
'website' => 'http://drupal.org/documentation/modules/overlay',
'version' => '1.0',
@@ -226,6 +227,10 @@ function overlay_library_info() {
'css' => array(
$module_path . '/overlay-child.css' => array(),
),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery.once'),
+ ),
);
return $libraries;
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index 2baa603..db44394 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -129,7 +129,7 @@ function path_form_node_form_alter(&$form, $form_state) {
'class' => array('path-form'),
),
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'path') . '/path.js'),
+ 'library' => array(array('path', 'path')),
),
'#access' => user_access('create url aliases') || user_access('administer url aliases'),
'#weight' => 30,
@@ -314,3 +314,22 @@ function path_taxonomy_term_delete(Term $term) {
// Delete all aliases associated with this term.
path_delete(array('source' => 'taxonomy/term/' . $term->tid));
}
+
+/**
+ * Implements hook_library_info().
+ */
+function path_library_info() {
+ $libraries['path'] = array(
+ 'title' => 'Path',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'path') . '/path.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc
index 3345c59..9da6fcd 100644
--- a/core/modules/shortcut/shortcut.admin.inc
+++ b/core/modules/shortcut/shortcut.admin.inc
@@ -73,7 +73,7 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) {
}
$form['#attached'] = array(
- 'js' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.js'),
+ 'library' => array(array('shortcut', 'shortcut.admin')),
);
$form['actions'] = array('#type' => 'actions');
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index 27eb8c2..1c99716 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -766,3 +766,21 @@ function shortcut_set_title($shortcut_set) {
return $shortcut_set->title;
}
+/**
+ * Implements hook_library_info().
+ */
+function shortcut_library_info() {
+ $libraries['shortcut.admin'] = array(
+ 'title' => 'Shortcut',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'shortcut') . '/shortcut.admin.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 4138916..992a304 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -566,3 +566,22 @@ function simpletest_mail_alter(&$message) {
$message['send'] = FALSE;
}
}
+
+function simpletest_library_info() {
+ $libraries['simpletest'] = array(
+ 'title' => 'Simpletest',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'simpletest') . '/simpletest.js' => array(),
+ ),
+ 'css' => array(
+ drupal_get_path('module', 'simpletest') . '/simpletest.css' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal.tableselect'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/simpletest/simpletest.pages.inc b/core/modules/simpletest/simpletest.pages.inc
index a98b445..b293c48 100644
--- a/core/modules/simpletest/simpletest.pages.inc
+++ b/core/modules/simpletest/simpletest.pages.inc
@@ -68,9 +68,7 @@ function simpletest_test_form($form) {
function theme_simpletest_test_table($variables) {
$table = $variables['table'];
- drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
- drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js');
- drupal_add_js('core/misc/tableselect.js');
+ drupal_add_library('simpletest', 'simpletest');
// Create header for test selection table.
$header = array(
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 35f625a..b0b03bc 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -103,10 +103,8 @@ function statistics_permission() {
*/
function statistics_node_view(Node $node, $view_mode) {
if (!empty($node->nid) && $view_mode == 'full') {
- $node->content['#attached']['js'] = array(
- drupal_get_path('module', 'statistics') . '/statistics.js' => array(
- 'scope' => 'footer'
- ),
+ $node->content['#attached']['library'] = array(
+ array('statistics', 'statistics'),
);
$settings = array('nid' => $node->nid);
$node->content['#attached']['js'][] = array(
@@ -462,3 +460,22 @@ function statistics_preprocess_block(&$variables) {
$variables['attributes']['role'] = 'navigation';
}
}
+
+/**
+ * Implements hook_library_info().
+ */
+function statistics_library_info() {
+ $libraries['statistics'] = array(
+ 'title' => 'Statistics',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'statistics') . '/statistics.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index 8aa3ed4..e582472 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -1696,7 +1696,7 @@ function system_logging_settings_submit($form, &$form_state) {
* @see system_performance_settings_submit().
*/
function system_performance_settings($form, &$form_state) {
- drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
+ drupal_add_library('system', 'system');
$config = config('system.performance');
$form['clear_cache'] = array(
@@ -2886,7 +2886,8 @@ function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
'#default_value' => ($dfid ? $format->format : ''),
'#field_suffix' => ' ' . $now . '',
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ 'library' => array(array('system', 'system')),
+ 'js' => array($js_settings),
),
'#required' => TRUE,
);
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 3c434ae..4b43db4 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -1212,13 +1212,25 @@ function _system_batch_theme() {
* Implements hook_library_info().
*/
function system_library_info() {
+ // Drupal specific javascript.
+ $libraries['drupal'] = array(
+ 'title' => 'Drupal',
+ 'version' => VERSION,
+ 'js' => array(
+ 'core/misc/drupal.js' => array('group' => JS_LIBRARY, 'weight' => -18),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ ),
+ );
+
// Drupal's Ajax framework.
$libraries['drupal.ajax'] = array(
'title' => 'Drupal AJAX',
'website' => 'http://api.drupal.org/api/group/ajax/8',
'version' => VERSION,
'js' => array(
- 'core/misc/ajax.js' => array('group' => JS_LIBRARY, 'weight' => 2),
+ 'core/misc/ajax.js' => array('group' => JS_LIBRARY),
),
'dependencies' => array(
array('system', 'drupal.progress'),
@@ -1234,6 +1246,7 @@ function system_library_info() {
),
'dependencies' => array(
array('system', 'drupal.progress'),
+ array('system', 'jquery.once'),
),
);
@@ -1244,6 +1257,10 @@ function system_library_info() {
'js' => array(
'core/misc/progress.js' => array('group' => JS_DEFAULT),
),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery'),
+ ),
);
// Drupal's form library.
@@ -1251,7 +1268,11 @@ function system_library_info() {
'title' => 'Drupal form library',
'version' => VERSION,
'js' => array(
- 'core/misc/form.js' => array('group' => JS_LIBRARY, 'weight' => 1),
+ 'core/misc/form.js' => array('group' => JS_LIBRARY),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery.cookie'),
+ array('system', 'jquery.once'),
),
);
@@ -1260,7 +1281,11 @@ function system_library_info() {
'title' => 'Drupal states',
'version' => VERSION,
'js' => array(
- 'core/misc/states.js' => array('group' => JS_LIBRARY, 'weight' => 1),
+ 'core/misc/states.js' => array('group' => JS_LIBRARY),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery'),
),
);
@@ -1269,9 +1294,11 @@ function system_library_info() {
'title' => 'Drupal tabledrag',
'version' => VERSION,
'js' => array(
- 'core/misc/tabledrag.js' => array('group' => JS_LIBRARY, 'weight' => -1),
+ 'core/misc/tabledrag.js' => array('group' => JS_LIBRARY),
),
'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery.once'),
array('system', 'jquery.cookie'),
),
);
@@ -1296,6 +1323,10 @@ function system_library_info() {
'js' => array(
'core/misc/autocomplete.js' => array('group' => JS_DEFAULT),
),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
);
// jQuery.
@@ -1316,6 +1347,9 @@ function system_library_info() {
'js' => array(
'core/misc/jquery.once.js' => array('group' => JS_LIBRARY, 'weight' => -19),
),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ ),
);
// jQuery Form Plugin.
@@ -1339,6 +1373,9 @@ function system_library_info() {
'js' => array(
'core/misc/jquery.ba-bbq.js' => array(),
),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ ),
);
// Vertical Tabs.
@@ -1353,6 +1390,7 @@ function system_library_info() {
'core/misc/vertical-tabs.css' => array(),
),
'dependencies' => array(
+ array('system', 'jquery'),
// Vertical tabs relies on drupalGetSummary in form.js
array('system', 'drupal.form'),
),
@@ -1397,6 +1435,9 @@ function system_library_info() {
'core/misc/ui/themes/base/jquery.ui.core.css' => array(),
'core/misc/ui/themes/base/jquery.ui.theme.css' => array(),
),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ ),
);
$libraries['jquery.ui.accordion'] = array(
'title' => 'jQuery UI: Accordion',
@@ -1831,6 +1872,77 @@ function system_library_info() {
'js' => array(
'core/misc/ui/external/jquery.cookie.js' => array(),
),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ ),
+ );
+
+ $libraries['drupal.tableselect'] = array(
+ 'title' => 'Tableselect',
+ 'version' => VERSION,
+ 'js' => array(
+ 'core/misc/tableselect.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery'),
+ ),
+ );
+ $libraries['drupal.tableheader'] = array(
+ 'title' => 'Table header',
+ 'version' => VERSION,
+ 'js' => array(
+ 'core/misc/tableheader.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery.once'),
+ ),
+ );
+ $libraries['drupal.timezone'] = array(
+ 'title' => 'Timezone',
+ 'version' => VERSION,
+ 'js' => array(
+ 'core/misc/timezone.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery'),
+ ),
+ );
+ $libraries['drupal.machine-name'] = array(
+ 'title' => 'Machine name',
+ 'version' => VERSION,
+ 'js' => array(
+ 'core/misc/machine-name.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery'),
+ ),
+ );
+
+ $libraries['system'] = array(
+ 'title' => 'System',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'system') . '/system.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery'),
+ ),
+ );
+ $libraries['system.cron'] = array(
+ 'title' => 'System cron',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'system') . '/system.cron.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal'),
+ array('system', 'jquery'),
+ ),
);
return $libraries;
@@ -2272,7 +2384,7 @@ function system_user_timezone(&$form, &$form_state) {
if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) {
$form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Confirm the selection and click save.');
$form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
- drupal_add_js('core/misc/timezone.js');
+ drupal_add_library('system', 'drupal.timezone');
}
}
diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module
index 187fee5..a462b7b 100644
--- a/core/modules/system/tests/modules/common_test/common_test.module
+++ b/core/modules/system/tests/modules/common_test/common_test.module
@@ -261,6 +261,9 @@ function common_test_library_info() {
'css' => array(
'core/misc/farbtastic/farbtastic.css' => array(),
),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ ),
);
return $libraries;
}
diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc
index 19a24d4..ac24731 100644
--- a/core/modules/taxonomy/taxonomy.admin.inc
+++ b/core/modules/taxonomy/taxonomy.admin.inc
@@ -447,7 +447,7 @@ function theme_taxonomy_overview_terms($variables) {
if ($form['#parent_fields']) {
drupal_add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE);
drupal_add_tabledrag('taxonomy', 'depth', 'group', 'term-depth', NULL, NULL, FALSE);
- drupal_add_js(drupal_get_path('module', 'taxonomy') . '/taxonomy.js');
+ drupal_add_library('taxonomy', 'taxonomy');
drupal_add_js(array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), 'setting');
drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
}
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 0bb318d..90a42e1 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -1703,3 +1703,22 @@ function taxonomy_entity_query_alter($query) {
unset($conditions['bundle']);
}
}
+
+ /**
+ * Implements hook_library_info().
+ */
+function taxonomy_library_info() {
+ $libraries['taxonomy'] = array(
+ 'title' => 'Taxonomy',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'taxonomy') . '/taxonomy.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 70f12bf..ba2e68e 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -192,8 +192,11 @@ function toolbar_view() {
$build = array(
'#theme' => 'toolbar',
'#attached'=> array(
+ 'library' => array(
+ array('toolbar', 'toolbar'),
+ array('system', 'jquery.cookie'),
+ ),
'js' => array(
- $module_path . '/toolbar.js',
array(
'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
'type' => 'setting'
@@ -202,7 +205,6 @@ function toolbar_view() {
'css' => array(
$module_path . '/toolbar.css',
),
- 'library' => array(array('system', 'jquery.cookie')),
),
);
@@ -366,3 +368,23 @@ function toolbar_in_active_trail($path) {
}
return in_array($path, $active_paths);
}
+
+/**
+ * Implements hook_library_info().
+ */
+function toolbar_library_info() {
+ $libraries['toolbar'] = array(
+ 'title' => 'Toolbar',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'toolbar') . '/toolbar.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery.once'),
+ array('system', 'jquery.cookie'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module
index 909117f..78e926e 100644
--- a/core/modules/translation/translation.module
+++ b/core/modules/translation/translation.module
@@ -116,8 +116,8 @@ function translation_permission() {
function translation_form_node_type_form_alter(&$form, &$form_state) {
// Hide form element if default language is a constant.
// TODO: When form #states allows OR values change this to use form #states.
- $form['#attached']['js'] = array(
- drupal_get_path('module', 'translation') . '/translation.js',
+ $form['#attached']['library'] = array(
+ array('translation', 'translation'),
);
// Add translation option to content type form.
$form['language']['node_type_language_translation_enabled'] = array(
@@ -540,3 +540,22 @@ function translation_language_switch_links_alter(array &$links, $type, $path) {
}
}
}
+
+/**
+ * Implements hook_library_info().
+ */
+function translation_library_info() {
+ $libraries['translation'] = array(
+ 'title' => 'Translation',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'translation') . '/translation.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index fac9723..f97d365 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -359,7 +359,7 @@ function user_admin_settings() {
'#title' => t('Enable user pictures.'),
'#default_value' => $picture_support,
);
- drupal_add_js(drupal_get_path('module', 'user') . '/user.js');
+ drupal_add_library('user', 'user');
$form['personalization']['pictures'] = array(
'#type' => 'container',
'#states' => array(
@@ -721,7 +721,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
- $form['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.permissions.js';
+ $form['#attached']['library'][] = array('user', 'user.permissions');
return $form;
}
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 535a579..fd09f40 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -3063,7 +3063,7 @@ function user_form_process_password_confirm($element) {
),
);
- $element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
+ $element['#attached']['library'][] = array('user', 'user');
// Ensure settings are only added once per page.
static $already_added = FALSE;
if (!$already_added) {
@@ -3180,7 +3180,7 @@ function user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id
// a custom behavior, since the #states system would also synchronize on
// uncheck.
'#attached' => array(
- 'js' => array(drupal_get_path('module', 'user') . '/user.js'),
+ 'library' => array(array('user', 'user')),
),
);
@@ -3296,3 +3296,34 @@ function user_file_download_access($field, $entity_type, $entity) {
return user_view_access($entity);
}
}
+
+/**
+ * Implements hook_library_info().
+ */
+function user_library_info() {
+ $libraries['user'] = array(
+ 'title' => 'User',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'user') . '/user.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ $libraries['user.permissions'] = array(
+ 'title' => 'User permissions',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'user') . '/user.permissions.js' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
+
+ return $libraries;
+}