Commit b1177ba6 authored by Dries's avatar Dries

- Patch #954804 by ksenzee, merlinofchaos: all .js in /misc should be registered as a library.

parent 732b57d1
......@@ -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',
......
......@@ -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>';
}
......
......@@ -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;
}
......
......@@ -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';
}
......
......@@ -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';
}
......
......@@ -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';
}
......
......@@ -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;
......
......@@ -206,7 +206,7 @@ function overlay_library() {
),
'dependencies' => array(
array('system', 'ui'),
array('system', 'jquery-bbq'),
array('system', 'jquery.bbq'),
),
);
// Overlay child.
......
......@@ -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;
}
......
......@@ -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')),
),
);
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment