diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-10-16 19:20:34 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-10-16 19:20:34 +0000 |
commit | 045074d4c51025a7c1561a9bf2e2a8b05441b23d (patch) | |
tree | bf64736c76784709788e4f6dc91acdbe9a01ddd2 /modules | |
parent | 60c5878351cc547dbfda260fefcf378491c958ec (diff) | |
download | brdo-045074d4c51025a7c1561a9bf2e2a8b05441b23d.tar.gz brdo-045074d4c51025a7c1561a9bf2e2a8b05441b23d.tar.bz2 |
- Patch #557272 by kkaefer, Rob Loach, quicksketch: added FAPI JavaScript States system.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/node/node.pages.inc | 6 | ||||
-rw-r--r-- | modules/system/system.admin.inc | 42 | ||||
-rw-r--r-- | modules/system/system.js | 13 | ||||
-rw-r--r-- | modules/system/system.module | 6 | ||||
-rw-r--r-- | modules/user/user.admin.inc | 54 | ||||
-rw-r--r-- | modules/user/user.js | 12 |
6 files changed, 84 insertions, 49 deletions
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index eee360cac..7f0c24cec 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -178,6 +178,12 @@ function node_form($form, &$form_state, $node) { '#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision, + '#states' => array( + // Check the revision log checkbox when the log textarea is filled in. + 'checked' => array( + 'textarea[name="log"]' => array('empty' => FALSE), + ), + ), ); $form['revision_information']['log'] = array( '#type' => 'textarea', diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 3694848bf..214a46ba5 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -493,13 +493,22 @@ function system_theme_settings($form, &$form_state, $key = '') { '#tree' => FALSE, '#description' => t('Check here if you want the theme to use the logo supplied with it.') ); - $form['logo']['logo_path'] = array( + $form['logo']['settings'] = array( + '#type' => 'container', + '#states' => array( + // Hide the logo settings when using the default logo. + 'invisible' => array( + 'input[name="default_logo"]' => array('checked' => TRUE), + ), + ), + ); + $form['logo']['settings']['logo_path'] = array( '#type' => 'textfield', '#title' => t('Path to custom logo'), '#default_value' => theme_get_setting('logo_path', $key), - '#description' => t('The path to the file you would like to use as your logo file instead of the default logo.')); - - $form['logo']['logo_upload'] = array( + '#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'), + ); + $form['logo']['settings']['logo_upload'] = array( '#type' => 'file', '#title' => t('Upload logo image'), '#maxlength' => 40, @@ -519,13 +528,22 @@ function system_theme_settings($form, &$form_state, $key = '') { '#default_value' => theme_get_setting('default_favicon', $key), '#description' => t('Check here if you want the theme to use the default shortcut icon.') ); - $form['favicon']['favicon_path'] = array( + $form['favicon']['settings'] = array( + '#type' => 'container', + '#states' => array( + // Hide the favicon settings when using the default favicon. + 'invisible' => array( + 'input[name="default_favicon"]' => array('checked' => TRUE), + ), + ), + ); + $form['favicon']['settings']['favicon_path'] = array( '#type' => 'textfield', '#title' => t('Path to custom icon'), '#default_value' => theme_get_setting('favicon_path', $key), '#description' => t('The path to the image file you would like to use as your custom shortcut icon.') ); - $form['favicon']['favicon_upload'] = array( + $form['favicon']['settings']['favicon_upload'] = array( '#type' => 'file', '#title' => t('Upload icon image'), '#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.") @@ -1660,12 +1678,16 @@ function system_regional_settings() { '#default_value' => $configurable_timezones, ); - $js_hide = !$configurable_timezones ? ' class="js-hide"' : ''; $form['timezone']['configurable_timezones_wrapper'] = array( - '#prefix' => '<div id="empty-timezone-message-wrapper"' . $js_hide . '>', - '#suffix' => '</div>', + '#type' => 'container', + '#states' => array( + // Hide the user configured timezone settings when users are forced to use + // the default setting. + 'invisible' => array( + 'input[name="configurable_timezones"]' => array('checked' => FALSE), + ), + ), ); - $form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = array( '#type' => 'checkbox', '#title' => t('Remind users at login if their time zone is not set.'), diff --git a/modules/system/system.js b/modules/system/system.js index 83a0c81db..b0ae974d2 100644 --- a/modules/system/system.js +++ b/modules/system/system.js @@ -115,19 +115,6 @@ Drupal.behaviors.dateTime = { }; /** - * Show/hide settings for user configurable time zones depending on whether - * users are able to set their own time zones or not. - */ -Drupal.behaviors.userTimeZones = { - attach: function (context, settings) { - $('#empty-timezone-message-wrapper .description').hide(); - $('#edit-configurable-timezones', context).change(function () { - $('#empty-timezone-message-wrapper').toggle(); - }); - } -}; - -/** * Show the powered by Drupal image preview */ Drupal.behaviors.poweredByPreview = { diff --git a/modules/system/system.module b/modules/system/system.module index cd35aa8ac..8b3270eab 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -490,6 +490,12 @@ function system_element_info() { '#default_tab' => '', '#process' => array('form_process_vertical_tabs'), ); + + $types['container'] = array( + '#theme_wrappers' => array('container'), + '#process' => array('form_process_container'), + ); + $types['token'] = array( '#input' => TRUE, '#theme' => array('hidden'), diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc index a5a4948e9..907b70a37 100644 --- a/modules/user/user.admin.inc +++ b/modules/user/user.admin.inc @@ -342,15 +342,14 @@ function user_admin_settings() { '#default_value' => $picture_support, ); drupal_add_js(drupal_get_path('module', 'user') . '/user.js'); - // If JS is enabled, and the checkbox defaults to off, hide all the settings - // on page load via CSS using the js-hide class so there's no flicker. - $css_class = 'user-admin-picture-settings'; - if (!$picture_support) { - $css_class .= ' js-hide'; - } $form['personalization']['pictures'] = array( - '#prefix' => '<div class="' . $css_class . '">', - '#suffix' => '</div>', + '#type' => 'container', + '#states' => array( + // Hide the additional picture settings when user pictures are disabled. + 'invisible' => array( + 'input[name="user_pictures"]' => array('checked' => FALSE), + ), + ), ); $form['personalization']['pictures']['user_picture_path'] = array( '#type' => 'textfield', @@ -511,13 +510,22 @@ function user_admin_settings() { '#title' => t('Notify user when account is activated.'), '#default_value' => variable_get('user_mail_status_activated_notify', TRUE), ); - $form['email_activated']['user_mail_status_activated_subject'] = array( + $form['email_activated']['settings'] = array( + '#type' => 'container', + '#states' => array( + // Hide the additional settings when this email is disabled. + 'invisible' => array( + 'input[name="user_mail_status_activated_notify"]' => array('checked' => FALSE), + ), + ), + ); + $form['email_activated']['settings']['user_mail_status_activated_subject'] = array( '#type' => 'textfield', '#title' => t('Subject'), '#default_value' => _user_mail_text('status_activated_subject'), '#maxlength' => 180, ); - $form['email_activated']['user_mail_status_activated_body'] = array( + $form['email_activated']['settings']['user_mail_status_activated_body'] = array( '#type' => 'textarea', '#title' => t('Body'), '#default_value' => _user_mail_text('status_activated_body'), @@ -537,13 +545,22 @@ function user_admin_settings() { '#title' => t('Notify user when account is blocked.'), '#default_value' => variable_get('user_mail_status_blocked_notify', FALSE), ); - $form['email_blocked']['user_mail_status_blocked_subject'] = array( + $form['email_blocked']['settings'] = array( + '#type' => 'container', + '#states' => array( + // Hide the additional settings when the blocked email is disabled. + 'invisible' => array( + 'input[name="user_mail_status_blocked_notify"]' => array('checked' => FALSE), + ), + ), + ); + $form['email_blocked']['settings']['user_mail_status_blocked_subject'] = array( '#type' => 'textfield', '#title' => t('Subject'), '#default_value' => _user_mail_text('status_blocked_subject'), '#maxlength' => 180, ); - $form['email_blocked']['user_mail_status_blocked_body'] = array( + $form['email_blocked']['settings']['user_mail_status_blocked_body'] = array( '#type' => 'textarea', '#title' => t('Body'), '#default_value' => _user_mail_text('status_blocked_body'), @@ -584,13 +601,22 @@ function user_admin_settings() { '#title' => t('Notify user when account is canceled.'), '#default_value' => variable_get('user_mail_status_canceled_notify', FALSE), ); - $form['email_canceled']['user_mail_status_canceled_subject'] = array( + $form['email_canceled']['settings'] = array( + '#type' => 'container', + '#states' => array( + // Hide the settings when the cancel notify checkbox is disabled. + 'invisible' => array( + 'input[name="user_mail_status_canceled_notify"]' => array('checked' => FALSE), + ), + ), + ); + $form['email_canceled']['settings']['user_mail_status_canceled_subject'] = array( '#type' => 'textfield', '#title' => t('Subject'), '#default_value' => _user_mail_text('status_canceled_subject'), '#maxlength' => 180, ); - $form['email_canceled']['user_mail_status_canceled_body'] = array( + $form['email_canceled']['settings']['user_mail_status_canceled_body'] = array( '#type' => 'textarea', '#title' => t('Body'), '#default_value' => _user_mail_text('status_canceled_body'), diff --git a/modules/user/user.js b/modules/user/user.js index 52279db67..c555c4d6f 100644 --- a/modules/user/user.js +++ b/modules/user/user.js @@ -176,16 +176,4 @@ Drupal.evaluatePasswordStrength = function (password, translate) { }; -/** - * Show all of the picture-related form elements at admin/config/people/accounts - * depending on whether user pictures are enabled or not. - */ -Drupal.behaviors.userSettings = { - attach: function (context, settings) { - $('#edit-user-pictures', context).change(function () { - $('div.user-admin-picture-settings', context).toggle(); - }); - } -}; - })(jQuery); |