summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2010-11-30 17:16:37 (GMT)
committerDries Buytaert2010-11-30 17:16:37 (GMT)
commitb1177ba603e3fe62c568a9a236cc371aefafc2dc (patch)
tree89f4d9f843eb500c6754edc1e8cd5358da2695e5
parent732b57d10d0b344510e35d6223f36eecf62c0821 (diff)
- Patch #954804 by ksenzee, merlinofchaos: all .js in /misc should be registered as a library.
-rw-r--r--includes/ajax.inc8
-rw-r--r--includes/batch.inc3
-rw-r--r--includes/common.inc6
-rw-r--r--includes/form.inc10
-rw-r--r--modules/comment/comment.module2
-rw-r--r--modules/contact/contact.pages.inc4
-rw-r--r--modules/openid/openid.module2
-rw-r--r--modules/overlay/overlay.module2
-rw-r--r--modules/system/system.module106
-rw-r--r--modules/toolbar/toolbar.module2
-rw-r--r--modules/user/user.module2
11 files changed, 119 insertions, 28 deletions
diff --git a/includes/ajax.inc b/includes/ajax.inc
index 24824a6..899ab45 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -604,8 +604,8 @@ function ajax_pre_render_element($element) {
// Attach JavaScript settings to the element.
if (isset($element['#ajax']['event'])) {
- $element['#attached']['library'][] = array('system', 'form');
- $element['#attached']['js']['misc/ajax.js'] = array('group' => JS_LIBRARY, 'weight' => 2);
+ $element['#attached']['library'][] = array('system', 'jquery.form');
+ $element['#attached']['library'][] = array('system', 'drupal.ajax');
$settings = $element['#ajax'];
@@ -667,10 +667,6 @@ function ajax_pre_render_element($element) {
$settings['progress']['url'] = url($settings['progress']['path']);
unset($settings['progress']['path']);
}
- // Add progress.js if we're doing a bar display.
- if ($settings['progress']['type'] == 'bar') {
- $element['#attached']['js']['misc/progress.js'] = array('cache' => FALSE);
- }
$element['#attached']['js'][] = array(
'type' => 'setting',
diff --git a/includes/batch.inc b/includes/batch.inc
index e4ddb06..1510a62 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -139,8 +139,7 @@ function _batch_progress_page_js() {
),
);
drupal_add_js($js_setting, 'setting');
- drupal_add_js('misc/progress.js', array('cache' => FALSE));
- drupal_add_js('misc/batch.js', array('cache' => FALSE));
+ drupal_add_library('system', 'drupal.batch');
return '<div id="progress"></div>';
}
diff --git a/includes/common.inc b/includes/common.inc
index 65a25fd..56e2769 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3951,7 +3951,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
);
// Register all required libraries.
drupal_add_library('system', 'jquery', TRUE);
- drupal_add_library('system', 'once', TRUE);
+ drupal_add_library('system', 'jquery.once', TRUE);
}
switch ($options['type']) {
@@ -4428,7 +4428,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
* @see form_example_states_form()
*/
function drupal_process_states(&$elements) {
- $elements['#attached']['js']['misc/states.js'] = array('group' => JS_LIBRARY, 'weight' => 1);
+ $elements['#attached']['library'][] = array('system', 'drupal.states');
$elements['#attached']['js'][] = array(
'type' => 'setting',
'data' => array('states' => array('#' . $elements['#id'] => $elements['#states'])),
@@ -4654,7 +4654,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
// Add the table drag JavaScript to the page before the module JavaScript
// to ensure that table drag behaviors are registered before any module
// uses it.
- drupal_add_js('misc/jquery.cookie.js', array('weight' => -2));
+ drupal_add_library('system', 'jquery.cookie');
drupal_add_js('misc/tabledrag.js', array('weight' => -1));
$js_added = TRUE;
}
diff --git a/includes/form.inc b/includes/form.inc
index de3e61e..3aae8cf 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -3380,7 +3380,7 @@ function form_process_fieldset(&$element, &$form_state) {
}
// Contains form element summary functionalities.
- $element['#attached']['js']['misc/form.js'] = array('group' => JS_LIBRARY, 'weight' => 1);
+ $element['#attached']['library'][] = array('system', 'drupal.form');
// The .form-wrapper class is required for #states to treat fieldsets like
// containers.
@@ -3390,7 +3390,7 @@ function form_process_fieldset(&$element, &$form_state) {
// Collapsible fieldsets
if (!empty($element['#collapsible'])) {
- $element['#attached']['js'][] = 'misc/collapse.js';
+ $element['#attached']['library'][] = array('system', 'drupal.collapse');
$element['#attributes']['class'][] = 'collapsible';
if (!empty($element['#collapsed'])) {
$element['#attributes']['class'][] = 'collapsed';
@@ -3506,7 +3506,7 @@ function form_process_vertical_tabs($element, &$form_state) {
function theme_vertical_tabs($variables) {
$element = $variables['element'];
// Add required JavaScript and Stylesheet.
- drupal_add_library('system', 'vertical-tabs');
+ drupal_add_library('system', 'drupal.vertical-tabs');
$output = '<h2 class="element-invisible">' . t('Vertical Tabs') . '</h2>';
$output .= '<div class="vertical-tabs-panes">' . $element['#children'] . '</div>';
@@ -3615,7 +3615,7 @@ function theme_textfield($variables) {
$extra = '';
if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) {
- drupal_add_js('misc/autocomplete.js');
+ drupal_add_library('system', 'drupal.autocomplete');
$element['#attributes']['class'][] = 'form-autocomplete';
$attributes = array();
@@ -3677,7 +3677,7 @@ function theme_textarea($variables) {
// Add resizable behavior.
if (!empty($element['#resizable'])) {
- drupal_add_js('misc/textarea.js');
+ drupal_add_library('system', 'drupal.textarea');
$wrapper_attributes['class'][] = 'resizable';
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index aa7f2ad..96b399b 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -1852,7 +1852,7 @@ function comment_form($form, &$form_state, $comment) {
$is_admin = (!empty($comment->cid) && user_access('administer comments'));
if (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
- $form['#attached']['library'][] = array('system', 'cookie');
+ $form['#attached']['library'][] = array('system', 'jquery.cookie');
$form['#attributes']['class'][] = 'user-info-from-cookie';
}
diff --git a/modules/contact/contact.pages.inc b/modules/contact/contact.pages.inc
index 50156f3..662896b 100644
--- a/modules/contact/contact.pages.inc
+++ b/modules/contact/contact.pages.inc
@@ -57,7 +57,7 @@ function contact_site_form($form, &$form_state) {
}
if (!$user->uid) {
- $form['#attached']['library'][] = array('system', 'cookie');
+ $form['#attached']['library'][] = array('system', 'jquery.cookie');
$form['#attributes']['class'][] = 'user-info-from-cookie';
}
@@ -187,7 +187,7 @@ function contact_personal_form($form, &$form_state, $recipient) {
drupal_set_title(t('Contact @username', array('@username' => format_username($recipient))), PASS_THROUGH);
if (!$user->uid) {
- $form['#attached']['library'][] = array('system', 'cookie');
+ $form['#attached']['library'][] = array('system', 'jquery.cookie');
$form['#attributes']['class'][] = 'user-info-from-cookie';
}
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index 3e1b2c9..0ab7c70 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -137,7 +137,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', 'cookie');
+ $form['#attached']['library'][] = array('system', 'jquery.cookie');
if (!empty($form_state['input']['openid_identifier'])) {
$form['name']['#required'] = FALSE;
$form['pass']['#required'] = FALSE;
diff --git a/modules/overlay/overlay.module b/modules/overlay/overlay.module
index e278a01..7cf44b9 100644
--- a/modules/overlay/overlay.module
+++ b/modules/overlay/overlay.module
@@ -206,7 +206,7 @@ function overlay_library() {
),
'dependencies' => array(
array('system', 'ui'),
- array('system', 'jquery-bbq'),
+ array('system', 'jquery.bbq'),
),
);
// Overlay child.
diff --git a/modules/system/system.module b/modules/system/system.module
index 4459683..5d2e91f 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -1079,6 +1079,89 @@ function _system_batch_theme() {
* Implements hook_library().
*/
function system_library() {
+ // Drupal's AJAX framework.
+ $libraries['drupal.ajax'] = array(
+ 'title' => 'Drupal AJAX',
+ 'website' => 'http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax/7',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/ajax.js' => array('group' => JS_LIBRARY, 'weight' => 2),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal.progress'),
+ ),
+ );
+
+ // Drupal's batch API.
+ $libraries['drupal.batch'] = array(
+ 'title' => 'Drupal batch API',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/batch.js' => array('cache' => FALSE),
+ ),
+ 'dependencies' => array(
+ array('system', 'drupal.progress'),
+ ),
+ );
+
+ // Drupal's progress indicator.
+ $libraries['drupal.progress'] = array(
+ 'title' => 'Drupal progress indicator',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/progress.js' => array('cache' => FALSE),
+ ),
+ );
+
+ // Drupal's form library.
+ $libraries['drupal.form'] = array(
+ 'title' => 'Drupal form library',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/form.js' => array('group' => JS_LIBRARY, 'weight' => 1),
+ ),
+ );
+
+ // Drupal's states library.
+ $libraries['drupal.states'] = array(
+ 'title' => 'Drupal states',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/states.js' => array('group' => JS_LIBRARY, 'weight' => 1),
+ ),
+ );
+
+ // Drupal's collapsible fieldset.
+ $libraries['drupal.collapse'] = array(
+ 'title' => 'Drupal collapsible fieldset',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/collapse.js' => array(),
+ ),
+ 'dependencies' => array(
+ // collapse.js relies on drupalGetSummary in form.js
+ array('system', 'drupal.form'),
+ ),
+ );
+
+ // Drupal's resizable textarea.
+ $libraries['drupal.textarea'] = array(
+ 'title' => 'Drupal resizable textarea',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/textarea.js' => array(),
+ ),
+ );
+
+ // Drupal's autocomplete widget.
+ $libraries['drupal.autocomplete'] = array(
+ 'title' => 'Drupal autocomplete',
+ 'version' => VERSION,
+ 'js' => array(
+ 'misc/autocomplete.js' => array(),
+ ),
+ );
+
// jQuery.
$libraries['jquery'] = array(
'title' => 'jQuery',
@@ -1090,7 +1173,7 @@ function system_library() {
);
// jQuery Once.
- $libraries['once'] = array(
+ $libraries['jquery.once'] = array(
'title' => 'jQuery Once',
'website' => 'http://plugins.jquery.com/project/once',
'version' => '1.2',
@@ -1100,7 +1183,7 @@ function system_library() {
);
// jQuery Form Plugin.
- $libraries['form'] = array(
+ $libraries['jquery.form'] = array(
'title' => 'jQuery Form Plugin',
'website' => 'http://malsup.com/jquery/form/',
'version' => '2.49',
@@ -1110,7 +1193,7 @@ function system_library() {
);
// jQuery BBQ plugin.
- $libraries['jquery-bbq'] = array(
+ $libraries['jquery.bbq'] = array(
'title' => 'jQuery BBQ',
'website' => 'http://benalman.com/projects/jquery-bbq-plugin/',
'version' => '1.2.1',
@@ -1120,7 +1203,7 @@ function system_library() {
);
// Vertical Tabs.
- $libraries['vertical-tabs'] = array(
+ $libraries['drupal.vertical-tabs'] = array(
'title' => 'Vertical Tabs',
'website' => 'http://drupal.org/node/323112',
'version' => '1.0',
@@ -1130,6 +1213,10 @@ function system_library() {
'css' => array(
'misc/vertical-tabs.css' => array(),
),
+ 'dependencies' => array(
+ // Vertical tabs relies on drupalGetSummary in form.js
+ array('system', 'drupal.form'),
+ ),
);
// Farbtastic.
@@ -1146,7 +1233,7 @@ function system_library() {
);
// Cookie.
- $libraries['cookie'] = array(
+ $libraries['jquery.cookie'] = array(
'title' => 'Cookie',
'website' => 'http://plugins.jquery.com/project/cookie',
'version' => '1.0',
@@ -1536,6 +1623,15 @@ function system_library() {
),
);
+ // These library names are deprecated. Earlier versions of Drupal 7 didn't
+ // consistently namespace their libraries, so these names are included for
+ // backwards compatibility with those versions.
+ $libraries['once'] = &$libraries['jquery.once'];
+ $libraries['form'] = &$libraries['jquery.form'];
+ $libraries['jquery-bbq'] = &$libraries['jquery.bbq'];
+ $libraries['vertical-tabs'] = &$libraries['drupal.vertical-tabs'];
+ $libraries['cookie'] = &$libraries['jquery.cookie'];
+
return $libraries;
}
diff --git a/modules/toolbar/toolbar.module b/modules/toolbar/toolbar.module
index af39ac4..bd774c5 100644
--- a/modules/toolbar/toolbar.module
+++ b/modules/toolbar/toolbar.module
@@ -188,7 +188,6 @@ function toolbar_view() {
'#attached'=> array(
'js' => array(
$module_path . '/toolbar.js',
- array('data' => 'misc/jquery.cookie.js', 'group' => JS_LIBRARY, 'weight' => 2),
array(
'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
'type' => 'setting'
@@ -197,6 +196,7 @@ function toolbar_view() {
'css' => array(
$module_path . '/toolbar.css',
),
+ 'library' => array(array('system', 'jquery.cookie')),
),
);
diff --git a/modules/user/user.module b/modules/user/user.module
index 96c26e0..67d8ee5 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -3540,7 +3540,7 @@ function user_register_form($form, &$form_state) {
$form['#user'] = drupal_anonymous_user();
$form['#user_category'] = 'register';
- $form['#attached']['library'][] = array('system', 'cookie');
+ $form['#attached']['library'][] = array('system', 'jquery.cookie');
$form['#attributes']['class'][] = 'user-info-from-cookie';
// Start with the default user account fields.