From 1b9ed8622d12f1269e11b6c6bffbfe323f37c84e Mon Sep 17 00:00:00 2001 From: Nathan Haug Date: Mon, 16 Dec 2013 21:28:12 -0800 Subject: [PATCH] Issue #40: Converting all #dependency properties to #states, based off of http://drupal.org/node/1595022 by dawehner. --- .../handlers/views_handler_area_text.inc | 8 +- .../views/handlers/views_handler_argument.inc | 82 ++++--- .../views_handler_argument_string.inc | 6 +- .../views/handlers/views_handler_field.inc | 218 ++++++++++++------ .../handlers/views_handler_field_custom.inc | 6 +- .../handlers/views_handler_field_date.inc | 9 +- .../handlers/views_handler_field_math.inc | 2 +- .../handlers/views_handler_field_numeric.inc | 18 +- .../views_handler_field_prerender_list.inc | 6 +- .../views_handler_field_serialized.inc | 6 +- .../views/handlers/views_handler_filter.inc | 31 ++- .../views_handler_filter_in_operator.inc | 11 +- .../handlers/views_handler_filter_numeric.inc | 25 +- .../handlers/views_handler_filter_string.inc | 13 +- core/modules/views/includes/admin.inc | 39 +++- .../views_handler_argument_field_list.inc | 6 +- ...ews_handler_argument_field_list_string.inc | 6 +- .../field/views_handler_field_field.inc | 39 +++- .../views_plugin_argument_validate_node.inc | 6 +- ...s_handler_argument_term_node_tid_depth.inc | 6 +- .../views_handler_field_term_node_tid.inc | 9 +- .../views_handler_filter_term_node_tid.inc | 6 +- ...s_plugin_argument_default_taxonomy_tid.inc | 24 +- .../user/views_handler_field_user_name.inc | 6 +- .../views_plugin_argument_validate_user.inc | 8 +- .../views/plugins/views_plugin_cache_time.inc | 14 +- .../views/plugins/views_plugin_display.inc | 18 +- .../plugins/views_plugin_display_feed.inc | 6 +- .../plugins/views_plugin_display_page.inc | 103 +++++++-- .../plugins/views_plugin_exposed_form.inc | 24 +- .../views/plugins/views_plugin_pager_full.inc | 24 +- .../plugins/views_plugin_query_default.inc | 6 +- .../views/plugins/views_plugin_row_fields.inc | 15 +- .../views/plugins/views_plugin_style.inc | 16 +- .../plugins/views_plugin_style_summary.inc | 6 +- .../plugins/views_plugin_style_table.inc | 42 +++- .../views_ui_base_views_wizard.class.php | 35 +-- 37 files changed, 638 insertions(+), 267 deletions(-) diff --git a/core/modules/views/handlers/views_handler_area_text.inc b/core/modules/views/handlers/views_handler_area_text.inc index edb282f3204..e348a28ac1b 100644 --- a/core/modules/views/handlers/views_handler_area_text.inc +++ b/core/modules/views/handlers/views_handler_area_text.inc @@ -73,11 +73,11 @@ class views_handler_area_text extends views_handler_area { '#collapsed' => TRUE, '#value' => $output, '#id' => 'edit-options-token-help', - '#dependency' => array( - 'edit-options-tokenize' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[tokenize]"]' => array('checked' => TRUE), + ), ), - '#prefix' => '
', - '#suffix' => '
', ); } } diff --git a/core/modules/views/handlers/views_handler_argument.inc b/core/modules/views/handlers/views_handler_argument.inc index 42617e7a3ac..273d531a964 100644 --- a/core/modules/views/handlers/views_handler_argument.inc +++ b/core/modules/views/handlers/views_handler_argument.inc @@ -269,8 +269,10 @@ class views_handler_argument extends views_handler { '#size' => 20, '#default_value' => $this->options['exception']['title'], '#description' => t('Override the view and other argument titles. Use "%1" for the first argument, "%2" for the second, etc.'), - '#dependency' => array( - 'edit-options-exception-title-enable' => array('1'), + '#states' => array( + 'visible' => array( + ':input[name="options[exception][title_enable]"]' => array('checked' => TRUE), + ), ), ); @@ -304,8 +306,10 @@ class views_handler_argument extends views_handler { '#title_display' => 'invisible', '#default_value' => $this->options['title'], '#description' => t('Override the view and other argument titles. Use "%1" for the first argument, "%2" for the second, etc.'), - '#dependency' => array( - 'edit-options-title-enable' => array('1'), + '#states' => array( + 'visible' => array( + ':input[name="options[title_enable]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'argument_present', ); @@ -322,8 +326,10 @@ class views_handler_argument extends views_handler { '#title_display' => 'invisible', '#default_value' => $this->options['breadcrumb'], '#description' => t('Enter a breadcrumb name you would like to use. See "Title" for percent substitutions.'), - '#dependency' => array( - 'edit-options-breadcrumb-enable' => array('1'), + '#states' => array( + 'visible' => array( + ':input[name="options[breadcrumb_enable]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'argument_present', ); @@ -345,8 +351,10 @@ class views_handler_argument extends views_handler { '#type' => 'select', '#title' => t('Validator'), '#default_value' => $this->options['validate']['type'], - '#dependency' => array( - 'edit-options-specify-validation' => array('1'), + '#states' => array( + 'visible' => array( + ':input[name="options[specify_validation]"]' => array('checked' => TRUE), + ), ), ); @@ -382,11 +390,12 @@ class views_handler_argument extends views_handler { '#type' => 'item', // Even if the plugin has no options add the key to the form_state. '#input' => TRUE, // trick it into checking input to make #process run - '#dependency' => array( - 'edit-options-specify-validation' => array('1'), - 'edit-options-validate-type' => array($id), + '#states' => array( + 'visible' => array( + ':input[name="options[specify_validation]"]' => array('checked' => TRUE), + ':input[name="options[validate][type]"]' => array('value' => $id), + ), ), - '#dependency_count' => 2, '#id' => 'edit-options-validate-options-' . $id, ); $plugin->options_form($form['validate']['options'][$id], $form_state); @@ -404,8 +413,10 @@ class views_handler_argument extends views_handler { '#title' => t('Action to take if filter value does not validate'), '#default_value' => $this->options['validate']['fail'], '#options' => $validate_options, - '#dependency' => array( - 'edit-options-specify-validation' => array('1'), + '#states' => array( + 'visible' => array( + ':input[name="options[specify_validation]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'argument_present', ); @@ -560,8 +571,11 @@ class views_handler_argument extends views_handler { '#id' => 'edit-options-default-argument-type', '#title' => t('Type'), '#default_value' => $this->options['default_argument_type'], - - '#dependency' => array('radio:options[default_action]' => array('default')), + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'default'), + ), + ), // Views custom key, moves this element to the appropriate container // under the radio button. '#argument_option' => 'default', @@ -582,11 +596,12 @@ class views_handler_argument extends views_handler { '#type' => 'item', // Even if the plugin has no options add the key to the form_state. '#input' => TRUE, - '#dependency' => array( - 'radio:options[default_action]' => array('default'), - 'edit-options-default-argument-type' => array($id) + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'default'), + ':input[name="options[default_argument_type]"]' => array('value' => $id), + ), ), - '#dependency_count' => 2, ); $options[$id] = $info['title']; $plugin->options_form($form['argument_default'][$id], $form_state); @@ -623,7 +638,11 @@ class views_handler_argument extends views_handler { '#title' => t('Sort order'), '#options' => array('asc' => t('Ascending'), 'desc' => t('Descending')), '#default_value' => $this->options['summary']['sort_order'], - '#dependency' => array('radio:options[default_action]' => array('summary')), + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'summary'), + ), + ), ); $form['summary']['number_of_records'] = array( '#type' => 'radios', @@ -633,7 +652,11 @@ class views_handler_argument extends views_handler { 0 => $this->get_sort_name(), 1 => t('Number of records') ), - '#dependency' => array('radio:options[default_action]' => array('summary')), + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'summary'), + ), + ), ); $form['summary']['format'] = array( @@ -641,7 +664,11 @@ class views_handler_argument extends views_handler { '#title' => t('Format'), '#options' => $format_options, '#default_value' => $this->options['summary']['format'], - '#dependency' => array('radio:options[default_action]' => array('summary')), + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'summary'), + ), + ), ); foreach ($summary_plugins as $id => $info) { @@ -656,11 +683,12 @@ class views_handler_argument extends views_handler { '#id' => 'edit-options-summary-options-' . $id, '#type' => 'item', '#input' => TRUE, // trick it into checking input to make #process run - '#dependency' => array( - 'radio:options[default_action]' => array('summary'), - 'radio:options[summary][format]' => array($id), + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'summary'), + ':input[name="options[summary][format]"]' => array('value' => $id), + ), ), - '#dependency_count' => 2, ); $options[$id] = $info['title']; $plugin->options_form($form['summary']['options'][$id], $form_state); diff --git a/core/modules/views/handlers/views_handler_argument_string.inc b/core/modules/views/handlers/views_handler_argument_string.inc index dbb98fef446..fbe54696e4e 100644 --- a/core/modules/views/handlers/views_handler_argument_string.inc +++ b/core/modules/views/handlers/views_handler_argument_string.inc @@ -57,7 +57,11 @@ class views_handler_argument_string extends views_handler_argument { '#title' => t('Character limit'), '#description' => t('How many characters of the filter value to filter against. If set to 1, all fields starting with the first letter in the filter value would be matched.'), '#default_value' => $this->options['limit'], - '#dependency' => array('edit-options-glossary' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[glossary]"]' => array('checked' => TRUE), + ), + ), '#fieldset' => 'more', ); diff --git a/core/modules/views/handlers/views_handler_field.inc b/core/modules/views/handlers/views_handler_field.inc index 65210d9f6d9..f16410b2fbf 100644 --- a/core/modules/views/handlers/views_handler_field.inc +++ b/core/modules/views/handlers/views_handler_field.inc @@ -489,17 +489,22 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#title' => t('Label'), '#default_value' => $label, - '#dependency' => array( - 'edit-options-custom-label' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[custom_label]"]' => array('checked' => TRUE), + ), ), + '#weight' => -102, ); $form['element_label_colon'] = array( '#type' => 'checkbox', '#title' => t('Place a colon after the label'), '#default_value' => $this->options['element_label_colon'], - '#dependency' => array( - 'edit-options-custom-label' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[custom_label]"]' => array('checked' => TRUE), + ), ), '#weight' => -101, ); @@ -532,8 +537,10 @@ class views_handler_field extends views_handler { '#type' => 'select', '#default_value' => $this->options['element_type'], '#description' => t('Choose the HTML element to wrap around this field, e.g. H1, H2, etc.'), - '#dependency' => array( - 'edit-options-element-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_type_enable]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'style_settings', ); @@ -541,8 +548,10 @@ class views_handler_field extends views_handler { $form['element_class_enable'] = array( '#type' => 'checkbox', '#title' => t('Create a CSS class'), - '#dependency' => array( - 'edit-options-element-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_type_enable]"]' => array('checked' => TRUE), + ), ), '#default_value' => !empty($this->options['element_class']) || (string) $this->options['element_class'] == '0', '#fieldset' => 'style_settings', @@ -552,11 +561,12 @@ class views_handler_field extends views_handler { '#description' => t('You may use token substitutions from the rewriting section in this class.'), '#type' => 'textfield', '#default_value' => $this->options['element_class'], - '#dependency' => array( - 'edit-options-element-class-enable' => array(1), - 'edit-options-element-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_type_enable]"]' => array('checked' => TRUE), + ':input[name="options[element_class_enable]"]' => array('checked' => TRUE), + ), ), - '#dependency_count' => 2, '#fieldset' => 'style_settings', ); @@ -572,16 +582,20 @@ class views_handler_field extends views_handler { '#type' => 'select', '#default_value' => $this->options['element_label_type'], '#description' => t('Choose the HTML element to wrap around this label, e.g. H1, H2, etc.'), - '#dependency' => array( - 'edit-options-element-label-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_label_type_enable]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'style_settings', ); $form['element_label_class_enable'] = array( '#type' => 'checkbox', '#title' => t('Create a CSS class'), - '#dependency' => array( - 'edit-options-element-label-type-enable' => array(1) + '#states' => array( + 'visible' => array( + ':input[name="options[element_label_type_enable]"]' => array('checked' => TRUE), + ), ), '#default_value' => !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0', '#fieldset' => 'style_settings', @@ -591,11 +605,12 @@ class views_handler_field extends views_handler { '#description' => t('You may use token substitutions from the rewriting section in this class.'), '#type' => 'textfield', '#default_value' => $this->options['element_label_class'], - '#dependency' => array( - 'edit-options-element-label-class-enable' => array(1), - 'edit-options-element-label-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_label_type_enable]"]' => array('checked' => TRUE), + ':input[name="options[element_label_class_enable]"]' => array('checked' => TRUE), + ), ), - '#dependency_count' => 2, '#fieldset' => 'style_settings', ); @@ -611,8 +626,10 @@ class views_handler_field extends views_handler { '#type' => 'select', '#default_value' => $this->options['element_wrapper_type'], '#description' => t('Choose the HTML element to wrap around this field and label, e.g. H1, H2, etc. This may not be used if the field and label are not rendered together, such as with a table.'), - '#dependency' => array( - 'edit-options-element-wrapper-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_wrapper_type_enable]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'style_settings', ); @@ -620,8 +637,10 @@ class views_handler_field extends views_handler { $form['element_wrapper_class_enable'] = array( '#type' => 'checkbox', '#title' => t('Create a CSS class'), - '#dependency' => array( - 'edit-options-element-wrapper-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_wrapper_type_enable]"]' => array('checked' => TRUE), + ), ), '#default_value' => !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] == '0', '#fieldset' => 'style_settings', @@ -631,11 +650,12 @@ class views_handler_field extends views_handler { '#description' => t('You may use token substitutions from the rewriting section in this class.'), '#type' => 'textfield', '#default_value' => $this->options['element_wrapper_class'], - '#dependency' => array( - 'edit-options-element-wrapper-class-enable' => array(1), - 'edit-options-element-wrapper-type-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[element_wrapper_class_enable]"]' => array('checked' => TRUE), + ':input[name="options[element_wrapper_type_enable]"]' => array('checked' => TRUE), + ), ), - '#dependency_count' => 2, '#fieldset' => 'style_settings', ); @@ -669,8 +689,10 @@ class views_handler_field extends views_handler { '#type' => 'textarea', '#default_value' => $this->options['alter']['text'], '#description' => t('The text to display for this field. You may include HTML. You may enter data from this view as per the "Replacement patterns" below.'), - '#dependency' => array( - 'edit-options-alter-alter-text' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][alter_text]"]' => array('checked' => TRUE), + ), ), ); @@ -685,8 +707,10 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#default_value' => $this->options['alter']['path'], '#description' => t('The Drupal path or absolute URL for this link. You may enter data from this view as per the "Replacement patterns" below.'), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), '#maxlength' => 255, ); @@ -694,16 +718,20 @@ class views_handler_field extends views_handler { '#type' => 'checkbox', '#title' => t('Use absolute path'), '#default_value' => $this->options['alter']['absolute'], - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['replace_spaces'] = array( '#type' => 'checkbox', '#title' => t('Replace spaces with dashes'), '#default_value' => $this->options['alter']['replace_spaces'], - '#dependency' => array( - 'edit-options-alter-make-link' => array(1) + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['external'] = array( @@ -711,16 +739,20 @@ class views_handler_field extends views_handler { '#title' => t('External server URL'), '#default_value' => $this->options['alter']['external'], '#description' => t("Links to an external server using a full URL: e.g. 'http://www.example.com' or 'www.example.com'."), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['path_case'] = array( '#type' => 'select', '#title' => t('Transform the case'), '#description' => t('When printing url paths, how to transform the case of the filter value.'), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), '#options' => array( 'none' => t('No transform'), @@ -736,8 +768,10 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#default_value' => $this->options['alter']['link_class'], '#description' => t('The CSS class to apply to the link.'), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['alt'] = array( @@ -745,8 +779,10 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#default_value' => $this->options['alter']['alt'], '#description' => t('Text to place as "title" text which most browsers display as a tooltip when hovering over the link.'), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['rel'] = array( @@ -754,8 +790,10 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#default_value' => $this->options['alter']['rel'], '#description' => t('Include Rel attribute for use in lightbox2 or other javascript utility.'), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['prefix'] = array( @@ -763,8 +801,10 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#default_value' => $this->options['alter']['prefix'], '#description' => t('Any text to display before this link. You may include HTML.'), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['suffix'] = array( @@ -772,8 +812,10 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#default_value' => $this->options['alter']['suffix'], '#description' => t('Any text to display after this link. You may include HTML.'), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['target'] = array( @@ -781,8 +823,10 @@ class views_handler_field extends views_handler { '#type' => 'textfield', '#default_value' => $this->options['alter']['target'], '#description' => t("Target of the link, such as _blank, _parent or an iframe's name. This field is rarely used."), - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), ), ); @@ -834,10 +878,18 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#collapsible' => TRUE, '#collapsed' => TRUE, '#value' => $output, - '#dependency' => array( - 'edit-options-alter-make-link' => array(1), - 'edit-options-alter-alter-text' => array(1), - 'edit-options-alter-more-link' => array(1), + '#states' => array( + 'visible' => array( + array( + ':input[name="options[alter][make_link]"]' => array('checked' => TRUE), + ), + array( + ':input[name="options[alter][alter_text]"]' => array('checked' => TRUE), + ), + array( + ':input[name="options[alter][more_link]"]' => array('checked' => TRUE), + ), + ), ), ); @@ -853,8 +905,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#type' => 'textfield', '#default_value' => $this->options['alter']['max_length'], '#description' => t('The maximum number of characters this field can be.'), - '#dependency' => array( - 'edit-options-alter-trim' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][trim]"]' => array('checked' => TRUE), + ), ), ); @@ -863,8 +917,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#title' => t('Trim only on a word boundary'), '#description' => t('If checked, this field be trimmed only on a word boundary. This is guaranteed to be the maximum characters stated or less. If there are no word boundaries this could trim a field to nothing.'), '#default_value' => $this->options['alter']['word_boundary'], - '#dependency' => array( - 'edit-options-alter-trim' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][trim]"]' => array('checked' => TRUE), + ), ), ); @@ -873,8 +929,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#title' => t('Add an ellipsis'), '#description' => t('If checked, a "..." will be added if a field was trimmed.'), '#default_value' => $this->options['alter']['ellipsis'], - '#dependency' => array( - 'edit-options-alter-trim' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][trim]"]' => array('checked' => TRUE), + ), ), ); @@ -883,8 +941,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#title' => t('Add a read-more link if output is trimmed.'), '#description' => t('If checked, a read-more link will be added at the end of the trimmed output'), '#default_value' => $this->options['alter']['more_link'], - '#dependency' => array( - 'edit-options-alter-trim' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][trim]"]' => array('checked' => TRUE), + ), ), ); @@ -893,10 +953,11 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#title' => t('More link text'), '#default_value' => $this->options['alter']['more_link_text'], '#description' => t('The text which will be displayed on the more link. You may enter data from this view as per the "Replacement patterns" above.'), - '#dependency_count' => 2, - '#dependency' => array( - 'edit-options-alter-trim' => array(1), - 'edit-options-alter-more-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][trim]"]' => array('checked' => TRUE), + ':input[name="options[alter][more_link]"]' => array('checked' => TRUE), + ), ), ); $form['alter']['more_link_path'] = array( @@ -904,10 +965,11 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#title' => t('More link path'), '#default_value' => $this->options['alter']['more_link_path'], '#description' => t('The path which is used for the more link. You may enter data from this view as per the "Replacement patterns" above.'), - '#dependency_count' => 2, - '#dependency' => array( - 'edit-options-alter-trim' => array(1), - 'edit-options-alter-more-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][trim]"]' => array('checked' => TRUE), + ':input[name="options[alter][more_link]"]' => array('checked' => TRUE), + ), ), ); @@ -916,8 +978,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#title' => t('Field can contain HTML'), '#description' => t('If checked, HTML corrector will be run to ensure tags are properly closed after trimming.'), '#default_value' => $this->options['alter']['html'], - '#dependency' => array( - 'edit-options-alter-trim' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][trim]"]' => array('checked' => TRUE), + ), ), ); @@ -933,8 +997,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent '#title' => t('Preserve certain tags'), '#description' => t('List the tags that need to be preserved during the stripping process. example "<p> <br>" which will preserve all p and br elements'), '#default_value' => $this->options['alter']['preserve_tags'], - '#dependency' => array( - 'edit-options-alter-strip-tags' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[alter][strip_tags]"]' => array('checked' => TRUE), + ), ), ); diff --git a/core/modules/views/handlers/views_handler_field_custom.inc b/core/modules/views/handlers/views_handler_field_custom.inc index 66586de235e..7d3459ead4d 100644 --- a/core/modules/views/handlers/views_handler_field_custom.inc +++ b/core/modules/views/handlers/views_handler_field_custom.inc @@ -29,10 +29,8 @@ class views_handler_field_custom extends views_handler_field { // Remove the checkbox unset($form['alter']['alter_text']); - unset($form['alter']['text']['#dependency']); - unset($form['alter']['text']['#process']); - unset($form['alter']['help']['#dependency']); - unset($form['alter']['help']['#process']); + unset($form['alter']['text']['#states']); + unset($form['alter']['help']['#states']); $form['#pre_render'][] = 'views_handler_field_custom_pre_render_move_text'; } diff --git a/core/modules/views/handlers/views_handler_field_date.inc b/core/modules/views/handlers/views_handler_field_date.inc index 8517f0b5d16..67e05cd7ca8 100644 --- a/core/modules/views/handlers/views_handler_field_date.inc +++ b/core/modules/views/handlers/views_handler_field_date.inc @@ -49,7 +49,6 @@ class views_handler_field_date extends views_handler_field { '#title' => t('Custom date format'), '#description' => t('If "Custom", see the PHP manual for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')), '#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '', - '#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span')), ); $form['timezone'] = array( '#type' => 'select', @@ -57,9 +56,13 @@ class views_handler_field_date extends views_handler_field { '#description' => t('Timezone to be used for date output.'), '#options' => array('' => t('- Default site/user timezone -')) + system_time_zones(FALSE), '#default_value' => $this->options['timezone'], - '#dependency' => array('edit-options-date-format' => array_merge(array('custom'), array_keys($date_formats))), ); - + // Setup #states for all possible date_formats on the custom_date_format form element. + foreach (array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span') as $custom_date_possible) { + $form['custom_date_format']['#states']['visible'][] = array( + ':input[name="options[date_format]"]' => array('value' => $custom_date_possible), + ); + } parent::options_form($form, $form_state); } diff --git a/core/modules/views/handlers/views_handler_field_math.inc b/core/modules/views/handlers/views_handler_field_math.inc index 08fba0602d5..3172be9bc44 100644 --- a/core/modules/views/handlers/views_handler_field_math.inc +++ b/core/modules/views/handlers/views_handler_field_math.inc @@ -36,7 +36,7 @@ class views_handler_field_math extends views_handler_field_numeric { // Then move the existing help: $form['expression_help'] = $form['alter']['help']; - unset($form['expression_help']['#dependency']); + unset($form['expression_help']['#states']); unset($form['alter']['help']); } diff --git a/core/modules/views/handlers/views_handler_field_numeric.inc b/core/modules/views/handlers/views_handler_field_numeric.inc index d10d3d0b360..eb2a53b5f06 100644 --- a/core/modules/views/handlers/views_handler_field_numeric.inc +++ b/core/modules/views/handlers/views_handler_field_numeric.inc @@ -44,7 +44,11 @@ class views_handler_field_numeric extends views_handler_field { '#title' => t('Precision'), '#default_value' => $this->options['precision'], '#description' => t('Specify how many digits to print after the decimal point.'), - '#dependency' => array('edit-options-set-precision' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[set_precision]"]' => array('checked' => TRUE), + ), + ), '#size' => 2, ); $form['decimal'] = array( @@ -80,14 +84,22 @@ class views_handler_field_numeric extends views_handler_field { '#title' => t('Singular form'), '#default_value' => $this->options['format_plural_singular'], '#description' => t('Text to use for the singular form.'), - '#dependency' => array('edit-options-format-plural' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[format_plural]"]' => array('checked' => TRUE), + ), + ), ); $form['format_plural_plural'] = array( '#type' => 'textfield', '#title' => t('Plural form'), '#default_value' => $this->options['format_plural_plural'], '#description' => t('Text to use for the plural form, @count will be replaced with the value.'), - '#dependency' => array('edit-options-format-plural' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[format_plural]"]' => array('checked' => TRUE), + ), + ), ); $form['prefix'] = array( '#type' => 'textfield', diff --git a/core/modules/views/handlers/views_handler_field_prerender_list.inc b/core/modules/views/handlers/views_handler_field_prerender_list.inc index 00a571aa6f2..53e1f99e980 100644 --- a/core/modules/views/handlers/views_handler_field_prerender_list.inc +++ b/core/modules/views/handlers/views_handler_field_prerender_list.inc @@ -51,7 +51,11 @@ class views_handler_field_prerender_list extends views_handler_field { '#type' => 'textfield', '#title' => t('Separator'), '#default_value' => $this->options['separator'], - '#dependency' => array('radio:options[type]' => array('separator')), + '#states' => array( + 'visible' => array( + ':input[name="options[type]"]' => array('value' => 'separator'), + ), + ), ); parent::options_form($form, $form_state); } diff --git a/core/modules/views/handlers/views_handler_field_serialized.inc b/core/modules/views/handlers/views_handler_field_serialized.inc index 1579fce71f9..ef432b456be 100644 --- a/core/modules/views/handlers/views_handler_field_serialized.inc +++ b/core/modules/views/handlers/views_handler_field_serialized.inc @@ -38,7 +38,11 @@ class views_handler_field_serialized extends views_handler_field { '#type' => 'textfield', '#title' => t('Which key should be displayed'), '#default_value' => $this->options['key'], - '#dependency' => array('edit-options-format' => array('key')), + '#states' => array( + 'visible' => array( + ':input[name="options[format]"]' => array('value' => 'key'), + ), + ), ); } diff --git a/core/modules/views/handlers/views_handler_filter.inc b/core/modules/views/handlers/views_handler_filter.inc index f5db70f9261..b7c332edb49 100644 --- a/core/modules/views/handlers/views_handler_filter.inc +++ b/core/modules/views/handlers/views_handler_filter.inc @@ -516,8 +516,10 @@ class views_handler_filter extends views_handler { '#title' => t('Operator identifier'), '#size' => 40, '#description' => t('This will appear in the URL after the ? to identify this operator.'), - '#dependency' => array( - 'edit-options-expose-use-operator' => array(1) + '#states' => array( + 'visible' => array( + ':input[name="options[expose][use_operator]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'more', ); @@ -551,8 +553,10 @@ class views_handler_filter extends views_handler { '#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'), '#default_value' => $this->options['expose']['remember_roles'], '#options' => $role_options, - '#dependency' => array( - 'edit-options-expose-remember' => array(1), + '#states' => array( + 'invisible' => array( + ':input[name="options[expose][remember]"]' => array('checked' => FALSE), + ), ), ); @@ -942,9 +946,22 @@ class views_handler_filter extends views_handler { // are displayed. $without_children = TRUE; foreach (element_children($row['value']) as $children) { - if (isset($row['value'][$children]['#dependency']['edit-options-operator'])) { - $row['value'][$children]['#dependency']["edit-options-group-info-group-items-$item_id-operator"] = $row['value'][$children]['#dependency']['edit-options-operator']; - unset($row['value'][$children]['#dependency']['edit-options-operator']); + $has_state = FALSE; + $states = array(); + foreach ($row['value'][$children]['#states']['visible'] as $key => $state) { + if (isset($state[':input[name="options[operator]"]'])) { + $has_state = TRUE; + $states[$key] = $state[':input[name="options[operator]"]']['value']; + } + } + if ($has_state) { + foreach ($states as $key => $state) { + $row['value'][$children]['#states']['visible'][] = array( + ':input[name="options[group_info][group_items][' . $item_id . '][operator]"]' => array('value' => $state), + ); + unset($row['value'][$children]['#states']['visible'][$key]); + } + $row['value'][$children]['#title'] = ''; if (!empty($this->options['group_info']['group_items'][$item_id]['value'][$children])) { diff --git a/core/modules/views/handlers/views_handler_filter_in_operator.inc b/core/modules/views/handlers/views_handler_filter_in_operator.inc index fc2700bd15f..6af820a10d0 100644 --- a/core/modules/views/handlers/views_handler_filter_in_operator.inc +++ b/core/modules/views/handlers/views_handler_filter_in_operator.inc @@ -166,7 +166,7 @@ class views_handler_filter_in_operator extends views_handler_filter { $which = 'all'; if (!empty($form['operator'])) { - $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator'; + $source = ':input[name="options[operator]"]'; } if (!empty($form_state['exposed'])) { $identifier = $this->options['expose']['identifier']; @@ -176,7 +176,7 @@ class views_handler_filter_in_operator extends views_handler_filter { $which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none'; } else { - $source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']); + $source = ':input[name="' . $this->options['expose']['operator_id'] . '"]'; } if (!empty($this->options['expose']['reduce'])) { @@ -221,7 +221,12 @@ class views_handler_filter_in_operator extends views_handler_filter { $form['value']['#prefix'] = '
'; $form['value']['#suffix'] = '
'; } - $form['value']['#dependency'] = array($source => $this->operator_values(1)); + // Setup #states for all operators with one value. + foreach ($this->operator_values(1) as $operator) { + $form['value']['#states']['visible'][] = array( + $source => array('value' => $operator), + ); + } } } } diff --git a/core/modules/views/handlers/views_handler_filter_numeric.inc b/core/modules/views/handlers/views_handler_filter_numeric.inc index 03384f685ad..109081a9b45 100644 --- a/core/modules/views/handlers/views_handler_filter_numeric.inc +++ b/core/modules/views/handlers/views_handler_filter_numeric.inc @@ -145,7 +145,7 @@ class views_handler_filter_numeric extends views_handler_filter { // render the form items we need. $which = 'all'; if (!empty($form['operator'])) { - $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator'; + $source = ':input[name="options[operator]"]'; } if (!empty($form_state['exposed'])) { @@ -156,7 +156,7 @@ class views_handler_filter_numeric extends views_handler_filter { $which = in_array($this->operator, $this->operator_values(2)) ? 'minmax' : 'value'; } else { - $source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']); + $source = ':input[name="' . $this->options['expose']['operator_id'] . '"]'; } } @@ -166,8 +166,13 @@ class views_handler_filter_numeric extends views_handler_filter { '#title' => empty($form_state['exposed']) ? t('Value') : '', '#size' => 30, '#default_value' => $this->value['value'], - '#dependency' => array($source => $this->operator_values(1)), ); + // Setup #states for all operators with one value. + foreach ($this->operator_values(1) as $operator) { + $form['value']['value']['#states']['visible'][] = array( + $source => array('value' => $operator), + ); + } if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['value'])) { $form_state['input'][$identifier]['value'] = $this->value['value']; } @@ -200,11 +205,15 @@ class views_handler_filter_numeric extends views_handler_filter { '#default_value' => $this->value['max'], ); if ($which == 'all') { - $dependency = array( - '#dependency' => array($source => $this->operator_values(2)), - ); - $form['value']['min'] += $dependency; - $form['value']['max'] += $dependency; + $states = array(); + // Setup #states for all operators with two values. + foreach ($this->operator_values(2) as $operator) { + $states['#states']['visible'][] = array( + $source => array('value' => $operator), + ); + } + $form['value']['min'] += $states; + $form['value']['max'] += $states; } if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['min'])) { $form_state['input'][$identifier]['min'] = $this->value['min']; diff --git a/core/modules/views/handlers/views_handler_filter_string.inc b/core/modules/views/handlers/views_handler_filter_string.inc index c50eff448f7..930d576f7bc 100644 --- a/core/modules/views/handlers/views_handler_filter_string.inc +++ b/core/modules/views/handlers/views_handler_filter_string.inc @@ -187,7 +187,7 @@ class views_handler_filter_string extends views_handler_filter { // render the form items we need. $which = 'all'; if (!empty($form['operator'])) { - $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator'; + $source = ':input[name="options[operator]"]'; } if (!empty($form_state['exposed'])) { $identifier = $this->options['expose']['identifier']; @@ -197,7 +197,7 @@ class views_handler_filter_string extends views_handler_filter { $which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none'; } else { - $source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']); + $source = ':input[name="' . $this->options['expose']['operator_id'] . '"]'; } } @@ -213,9 +213,12 @@ class views_handler_filter_string extends views_handler_filter { } if ($which == 'all') { - $form['value'] += array( - '#dependency' => array($source => $this->operator_values(1)), - ); + // Setup #states for all operators with one value. + foreach ($this->operator_values(1) as $operator) { + $form['value']['#states']['visible'][] = array( + $source => array('value' => $operator), + ); + } } } diff --git a/core/modules/views/includes/admin.inc b/core/modules/views/includes/admin.inc index 33d88e04b35..e6fafae3f2e 100644 --- a/core/modules/views/includes/admin.inc +++ b/core/modules/views/includes/admin.inc @@ -397,8 +397,10 @@ function views_ui_add_form($form, &$form_state) { '#title_display' => 'invisible', '#size' => 64, '#default_value' => !empty($form_state['view']) ? $form_state['view']->description : '', - '#dependency' => array( - 'edit-description-enable' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="description_enable"]' => array('checked' => TRUE), + ), ), ); @@ -4932,24 +4934,33 @@ function views_ui_admin_settings_basic() { 'above' => t('Above the preview'), 'below' => t('Below the preview'), ), - '#id' => 'edit-show-sql', '#default_value' => variable_get('views_ui_show_sql_query_where', 'above'), - '#dependency' => array('edit-views-ui-show-preview-information' => array(TRUE)), - '#prefix' => '
', - '#suffix' => '
', + '#states' => array( + 'visible' => array( + ':input[name="views_ui_show_preview_information"]' => array('checked' => TRUE), + ), + ), ); $form['live_preview']['views_ui_show_sql_query'] = array( '#type' => 'checkbox', '#title' => t('Show the SQL query'), '#default_value' => variable_get('views_ui_show_sql_query', FALSE), - '#dependency' => array('edit-views-ui-show-preview-information' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="views_ui_show_preview_information"]' => array('checked' => TRUE), + ), + ), ); $form['live_preview']['views_ui_show_performance_statistics'] = array( '#type' => 'checkbox', '#title' => t('Show performance statistics'), '#default_value' => variable_get('views_ui_show_performance_statistics', FALSE), - '#dependency' => array('edit-views-ui-show-preview-information' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="views_ui_show_preview_information"]' => array('checked' => TRUE), + ), + ), ); $form['live_preview']['views_show_additional_queries'] = array( @@ -4957,7 +4968,11 @@ function views_ui_admin_settings_basic() { '#title' => t('Show other queries run during render during live preview'), '#description' => t("Drupal has the potential to run many queries while a view is being rendered. Checking this box will display every query run during view render as part of the live preview."), '#default_value' => variable_get('views_show_additional_queries', FALSE), - '#dependency' => array('edit-views-ui-show-preview-information' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="views_ui_show_preview_information"]' => array('checked' => TRUE), + ), + ), ); // $form['live_preview']['views_ui_show_performance_statistics_where'] = array( @@ -5042,7 +5057,11 @@ function views_ui_admin_settings_advanced() { '#title' => t('Page region to output performance statistics/debug messages'), '#default_value' => variable_get('views_devel_region', 'footer'), '#options' => $regions, - '#dependency' => array('edit-views-devel-output' => array(1)), + '#states' => array( + 'visible' => array( + ':input[name="views_devel_output"]' => array('checked' => TRUE), + ), + ), ); $options = views_fetch_plugin_names('display_extender'); diff --git a/core/modules/views/modules/field/views_handler_argument_field_list.inc b/core/modules/views/modules/field/views_handler_argument_field_list.inc index e0f7abe830e..965bd1857bf 100644 --- a/core/modules/views/modules/field/views_handler_argument_field_list.inc +++ b/core/modules/views/modules/field/views_handler_argument_field_list.inc @@ -39,7 +39,11 @@ class views_handler_argument_field_list extends views_handler_argument_numeric { '#title' => t('Display list value as human readable'), '#type' => 'checkbox', '#default_value' => $this->options['summary']['human'], - '#dependency' => array('radio:options[default_action]' => array('summary')), + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'summary'), + ), + ), ); } diff --git a/core/modules/views/modules/field/views_handler_argument_field_list_string.inc b/core/modules/views/modules/field/views_handler_argument_field_list_string.inc index 67a9f2d9998..c3537f33c15 100644 --- a/core/modules/views/modules/field/views_handler_argument_field_list_string.inc +++ b/core/modules/views/modules/field/views_handler_argument_field_list_string.inc @@ -40,7 +40,11 @@ class views_handler_argument_field_list_string extends views_handler_argument_st '#title' => t('Display list value as human readable'), '#type' => 'checkbox', '#default_value' => $this->options['summary']['human'], - '#dependency' => array('radio:options[default_action]' => array('summary')), + '#states' => array( + 'visible' => array( + ':input[name="options[default_action]"]' => array('value' => 'summary'), + ), + ), ); } diff --git a/core/modules/views/modules/field/views_handler_field_field.inc b/core/modules/views/modules/field/views_handler_field_field.inc index 740089a81b6..8bc1d6b74ce 100644 --- a/core/modules/views/modules/field/views_handler_field_field.inc +++ b/core/modules/views/modules/field/views_handler_field_field.inc @@ -551,7 +551,11 @@ class views_handler_field_field extends views_handler_field { 'ol' => t('Ordered list'), 'separator' => t('Simple separator'), ), - '#dependency' => array('edit-options-group-rows' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[group_rows]"]' => array('checked' => TRUE), + ), + ), '#default_value' => $this->options['multi_type'], '#fieldset' => 'multiple_field_settings', ); @@ -560,11 +564,12 @@ class views_handler_field_field extends views_handler_field { '#type' => 'textfield', '#title' => t('Separator'), '#default_value' => $this->options['separator'], - '#dependency' => array( - 'radio:options[multi_type]' => array('separator'), - 'edit-options-group-rows' => array(TRUE), + '#states' => array( + 'visible' => array( + ':input[name="options[group_rows]"]' => array('checked' => TRUE), + ':input[name="options[multi_type]"]' => array('value' => 'separator'), + ), ), - '#dependency_count' => 2, '#fieldset' => 'multiple_field_settings', ); @@ -576,7 +581,11 @@ class views_handler_field_field extends views_handler_field { '#options' => $options, '#default_value' => $this->options['delta_limit'], '#prefix' => '
', - '#dependency' => array('edit-options-group-rows' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[group_rows]"]' => array('checked' => TRUE), + ), + ), '#fieldset' => 'multiple_field_settings', ); @@ -587,7 +596,11 @@ class views_handler_field_field extends views_handler_field { '#field_prefix' => $prefix, '#field_suffix' => $suffix, '#default_value' => $this->options['delta_offset'], - '#dependency' => array('edit-options-group-rows' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[group_rows]"]' => array('checked' => TRUE), + ), + ), '#description' => t('(first item is 0)'), '#fieldset' => 'multiple_field_settings', ); @@ -596,7 +609,11 @@ class views_handler_field_field extends views_handler_field { '#type' => 'checkbox', '#default_value' => $this->options['delta_reversed'], '#suffix' => $suffix, - '#dependency' => array('edit-options-group-rows' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[group_rows]"]' => array('checked' => TRUE), + ), + ), '#description' => t('(start from last values)'), '#fieldset' => 'multiple_field_settings', ); @@ -605,7 +622,11 @@ class views_handler_field_field extends views_handler_field { '#type' => 'checkbox', '#default_value' => $this->options['delta_first_last'], '#suffix' => '
', - '#dependency' => array('edit-options-group-rows' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[group_rows]"]' => array('checked' => TRUE), + ), + ), '#fieldset' => 'multiple_field_settings', ); } diff --git a/core/modules/views/modules/node/views_plugin_argument_validate_node.inc b/core/modules/views/modules/node/views_plugin_argument_validate_node.inc index 018965da236..868a621dcde 100644 --- a/core/modules/views/modules/node/views_plugin_argument_validate_node.inc +++ b/core/modules/views/modules/node/views_plugin_argument_validate_node.inc @@ -44,7 +44,11 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate '#title' => t('Access operation to check'), '#options' => array('view' => t('View'), 'update' => t('Edit'), 'delete' => t('Delete')), '#default_value' => $this->options['access_op'], - '#dependency' => array('edit-options-validate-options-node-access' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[validate][options][node][access]"]' => array('checked' => TRUE), + ), + ), ); $form['nid_type'] = array( diff --git a/core/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc b/core/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc index 116a4dedebe..5b0b34d8f78 100644 --- a/core/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc +++ b/core/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc @@ -52,7 +52,11 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument '#title' => t("Use Drupal's taxonomy term path to create breadcrumb links"), '#description' => t('If selected, the links in the breadcrumb trail will be created using the standard drupal method instead of the custom views method. This is useful if you are using modules like taxonomy redirect to modify your taxonomy term links.'), '#default_value' => !empty($this->options['use_taxonomy_term_path']), - '#dependency' => array('edit-options-set-breadcrumb' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[set_breadcrumb]"]' => array('checked' => TRUE), + ), + ), ); parent::options_form($form, $form_state); } diff --git a/core/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc b/core/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc index 4c6362e5d03..e9efdab8612 100644 --- a/core/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc +++ b/core/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc @@ -65,13 +65,16 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li } $form['vocabularies'] = array( - '#prefix' => '
', - '#suffix' => '
', '#type' => 'checkboxes', '#title' => t('Vocabularies'), '#options' => $options, '#default_value' => $this->options['vocabularies'], - '#dependency' => array('edit-options-limit' => array(TRUE)), + '#states' => array( + 'visible' => array( + ':input[name="options[limit]"]' => array('checked' => TRUE), + ), + ), + ); parent::options_form($form, $form_state); diff --git a/core/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc b/core/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc index 7eb868f79ed..ec73eacbdb3 100644 --- a/core/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc +++ b/core/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc @@ -82,7 +82,11 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on '#type' => 'checkbox', '#title' => t('Show hierarchy in dropdown'), '#default_value' => !empty($this->options['hierarchy']), - '#dependency' => array('radio:options[type]' => array('select')), + '#states' => array( + 'visible' => array( + ':input[name="options[type]"]' => array('value' => 'select'), + ), + ), ); } diff --git a/core/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc b/core/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc index 9c1d81f9cf4..bdd7302eafa 100644 --- a/core/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc +++ b/core/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc @@ -51,9 +51,10 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d '#type' => 'checkbox', '#title' => t('Limit terms by vocabulary'), '#default_value'=> $this->options['limit'], - '#process' => array('form_process_checkbox', 'ctools_dependent_process'), - '#dependency' => array( - 'edit-options-argument-default-taxonomy-tid-node' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE), + ), ), ); @@ -64,16 +65,15 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d } $form['vocabularies'] = array( - '#prefix' => '
', - '#suffix' => '
', '#type' => 'checkboxes', '#title' => t('Vocabularies'), '#options' => $options, '#default_value' => $this->options['vocabularies'], - '#process' => array('form_process_checkboxes', 'ctools_dependent_process'), - '#dependency' => array( - 'edit-options-argument-default-taxonomy-tid-limit' => array(1), - 'edit-options-argument-default-taxonomy-tid-node' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[argument_default][taxonomy_tid][limit]"]' => array('checked' => TRUE), + ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE), + ), ), ); @@ -86,8 +86,10 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d ',' => t('Filter to items that share all terms'), '+' => t('Filter to items that share any term'), ), - '#dependency' => array( - 'edit-options-argument-default-taxonomy-tid-node' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE), + ), ), ); } diff --git a/core/modules/views/modules/user/views_handler_field_user_name.inc b/core/modules/views/modules/user/views_handler_field_user_name.inc index 45514519dd6..5d01511e355 100644 --- a/core/modules/views/modules/user/views_handler_field_user_name.inc +++ b/core/modules/views/modules/user/views_handler_field_user_name.inc @@ -50,8 +50,10 @@ class views_handler_field_user_name extends views_handler_field_user { '#title' => t('Text to display for anonymous users'), '#type' => 'textfield', '#default_value' => $this->options['anonymous_text'], - '#dependency' => array( - 'edit-options-overwrite-anonymous' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[overwrite_anonymous]"]' => array('checked' => TRUE), + ), ), '#fieldset' => 'more', ); diff --git a/core/modules/views/modules/user/views_plugin_argument_validate_user.inc b/core/modules/views/modules/user/views_plugin_argument_validate_user.inc index b7270944529..0d48be64bea 100644 --- a/core/modules/views/modules/user/views_plugin_argument_validate_user.inc +++ b/core/modules/views/modules/user/views_plugin_argument_validate_user.inc @@ -42,14 +42,14 @@ class views_plugin_argument_validate_user extends views_plugin_argument_validate $form['roles'] = array( '#type' => 'checkboxes', - '#prefix' => '
', - '#suffix' => '
', '#title' => t('Restrict to the selected roles'), '#options' => array_map('check_plain', user_roles(TRUE)), '#default_value' => $this->options['roles'], '#description' => t('If no roles are selected, users from any role will be allowed.'), - '#dependency' => array( - 'edit-options-validate-options-user-restrict-roles' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="options[validate][options][user][restrict_roles]"]' => array('checked' => TRUE), + ), ), ); } diff --git a/core/modules/views/plugins/views_plugin_cache_time.inc b/core/modules/views/plugins/views_plugin_cache_time.inc index 25245ea4cb6..3bce56ed0bb 100644 --- a/core/modules/views/plugins/views_plugin_cache_time.inc +++ b/core/modules/views/plugins/views_plugin_cache_time.inc @@ -41,9 +41,10 @@ class views_plugin_cache_time extends views_plugin_cache { '#maxlength' => '30', '#description' => t('Length of time in seconds raw query results should be cached.'), '#default_value' => $this->options['results_lifespan_custom'], - '#process' => array('form_process_select','ctools_dependent_process'), - '#dependency' => array( - 'edit-cache-options-results-lifespan' => array('custom'), + '#states' => array( + 'visible' => array( + ':input[name="cache_options[results_lifespan]"]' => array('value' => 'custom'), + ), ), ); $form['output_lifespan'] = array( @@ -60,9 +61,10 @@ class views_plugin_cache_time extends views_plugin_cache { '#maxlength' => '30', '#description' => t('Length of time in seconds rendered HTML output should be cached.'), '#default_value' => $this->options['output_lifespan_custom'], - '#process' => array('form_process_select','ctools_dependent_process'), - '#dependency' => array( - 'edit-cache-options-output-lifespan' => array('custom'), + '#states' => array( + 'visible' => array( + ':input[name="cache_options[output_lifespan]"]' => array('value' => 'custom'), + ), ), ); } diff --git a/core/modules/views/plugins/views_plugin_display.inc b/core/modules/views/plugins/views_plugin_display.inc index 75a32c513ad..0c3296277a2 100644 --- a/core/modules/views/plugins/views_plugin_display.inc +++ b/core/modules/views/plugins/views_plugin_display.inc @@ -1520,17 +1520,21 @@ class views_plugin_display extends views_plugin { '#title' => t("Display 'more' link only if there is more content"), '#description' => t("Leave this unchecked to display the 'more' link even if there are no more items to display."), '#default_value' => !$this->get_option('use_more_always'), - '#dependency' => array( - 'edit-use-more' => array(TRUE), + '#states' => array( + 'visible' => array( + ':input[name="use_more"]' => array('checked' => TRUE), ), + ), ); $form['use_more_text'] = array( '#type' => 'textfield', '#title' => t('More link text'), '#description' => t("The text to display for the more link."), '#default_value' => $this->get_option('use_more_text'), - '#dependency' => array( - 'edit-use-more' => array(TRUE), + '#states' => array( + 'visible' => array( + ':input[name="use_more"]' => array('checked' => TRUE), + ), ), ); break; @@ -1810,7 +1814,11 @@ class views_plugin_display extends views_plugin { '#title' => t('Custom URL'), '#default_value' => $this->get_option('link_url'), '#description' => t('A Drupal path or external URL the more link will point to. Note that this will override the link display setting above.') . $output, - '#dependency' => array('radio:link_display' => array('custom_url')), + '#states' => array( + 'visible' => array( + ':input[name="link_display"]' => array('value' => 'custom_url'), + ), + ), ); break; case 'analyze-theme': diff --git a/core/modules/views/plugins/views_plugin_display_feed.inc b/core/modules/views/plugins/views_plugin_display_feed.inc index bfd220c5d7c..19b6c06b5f9 100644 --- a/core/modules/views/plugins/views_plugin_display_feed.inc +++ b/core/modules/views/plugins/views_plugin_display_feed.inc @@ -153,7 +153,11 @@ class views_plugin_display_feed extends views_plugin_display_page { '#default_value' => $this->get_option('sitename_title'), ); $form['title'] = $title; - $form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE)); + $form['title']['#states'] = array( + 'visible' => array( + ':input[name="sitename_title"]' => array('checked' => FALSE), + ), + ); break; case 'displays': $form['#title'] .= t('Attach to'); diff --git a/core/modules/views/plugins/views_plugin_display_page.inc b/core/modules/views/plugins/views_plugin_display_page.inc index 7ca4bf7fe90..f85fe5748ea 100644 --- a/core/modules/views/plugins/views_plugin_display_page.inc +++ b/core/modules/views/plugins/views_plugin_display_page.inc @@ -342,20 +342,45 @@ class views_plugin_display_page extends views_plugin_display { ), '#default_value' => $menu['type'], ); + $form['menu']['title'] = array( '#prefix' => '
', '#title' => t('Title'), '#type' => 'textfield', '#default_value' => $menu['title'], '#description' => t('If set to normal or tab, enter the text to use for the menu item.'), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')), + '#states' => array( + 'visible' => array( + array( + ':input[name="menu[type]"]' => array('value' => 'normal'), + ), + array( + ':input[name="menu[type]"]' => array('value' => 'tab'), + ), + array( + ':input[name="menu[type]"]' => array('value' => 'default tab'), + ), + ), + ), ); $form['menu']['description'] = array( '#title' => t('Description'), '#type' => 'textfield', '#default_value' => $menu['description'], '#description' => t("If set to normal or tab, enter the text to use for the menu item's description."), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')), + '#states' => array( + 'visible' => array( + array( + ':input[name="menu[type]"]' => array('value' => 'normal'), + ), + array( + ':input[name="menu[type]"]' => array('value' => 'tab'), + ), + array( + ':input[name="menu[type]"]' => array('value' => 'default tab'), + ), + ), + ), ); // Only display the menu selector if menu module is enabled. @@ -366,7 +391,16 @@ class views_plugin_display_page extends views_plugin_display { '#options' => menu_get_menus(), '#default_value' => $menu['name'], '#description' => t('Insert item into an available menu.'), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab')), + '#states' => array( + 'visible' => array( + array( + ':input[name="menu[type]"]' => array('value' => 'normal'), + ), + array( + ':input[name="menu[type]"]' => array('value' => 'tab'), + ), + ), + ), ); } else { @@ -383,14 +417,30 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#default_value' => isset($menu['weight']) ? $menu['weight'] : 0, '#description' => t('The lower the weight the higher/further left it will appear.'), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')), + '#states' => array( + 'visible' => array( + array( + ':input[name="menu[type]"]' => array('value' => 'normal'), + ), + array( + ':input[name="menu[type]"]' => array('value' => 'tab'), + ), + array( + ':input[name="menu[type]"]' => array('value' => 'default tab'), + ), + ), + ), ); $form['menu']['context'] = array( '#title' => t('Context'), '#type' => 'checkbox', '#default_value' => !empty($menu['context']), '#description' => t('Displays the link in contextual links'), - '#dependency' => array('radio:menu[type]' => array('tab')), + '#states' => array( + 'visible' => array( + ':input[name="menu[type]"]' => array('value' => 'tab'), + ), + ), ); $form['menu']['context_only_inline'] = array( '#title' => t('Hide menu tab'), @@ -398,11 +448,12 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'checkbox', '#default_value' => !empty($menu['context_only_inline']), '#description' => t('Only display menu item entry in contextual links. Menu tab should not be displayed.'), - '#dependency' => array( - 'radio:menu[type]' => array('tab'), - 'edit-menu-context' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="menu[type]"]' => array('value' => 'tab'), + ':input[name="menu[context]"]' => array('checked' => TRUE), + ), ), - '#dependency_count' => 2, ); break; case 'tab_options': @@ -435,14 +486,32 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#default_value' => $tab_options['title'], '#description' => t('If creating a parent menu item, enter the title of the item.'), - '#dependency' => array('radio:tab_options[type]' => array('normal', 'tab')), + '#states' => array( + 'visible' => array( + array( + ':input[name="tab_options[type]"]' => array('value' => 'normal'), + ), + array( + ':input[name="tab_options[type]"]' => array('value' => 'tab'), + ), + ), + ), ); $form['tab_options']['description'] = array( '#title' => t('Description'), '#type' => 'textfield', '#default_value' => $tab_options['description'], '#description' => t('If creating a parent menu item, enter the description of the item.'), - '#dependency' => array('radio:tab_options[type]' => array('normal', 'tab')), + '#states' => array( + 'visible' => array( + array( + ':input[name="tab_options[type]"]' => array('value' => 'normal'), + ), + array( + ':input[name="tab_options[type]"]' => array('value' => 'tab'), + ), + ), + ), ); // Only display the menu selector if menu module is enabled. if (module_exists('menu')) { @@ -452,7 +521,11 @@ class views_plugin_display_page extends views_plugin_display { '#options' => menu_get_menus(), '#default_value' => $tab_options['name'], '#description' => t('Insert item into an available menu.'), - '#dependency' => array('radio:tab_options[type]' => array('normal')), + '#states' => array( + 'visible' => array( + ':input[name="tab_options[type]"]' => array('value' => 'normal'), + ), + ), ); } else { @@ -471,7 +544,11 @@ class views_plugin_display_page extends views_plugin_display { '#default_value' => $tab_options['weight'], '#size' => 5, '#description' => t('If the parent menu item is a tab, enter the weight of the tab. The lower the number, the more to the left it will be.'), - '#dependency' => array('radio:tab_options[type]' => array('tab')), + '#states' => array( + 'visible' => array( + ':input[name="tab_options[type]"]' => array('value' => 'tab'), + ), + ), ); break; } diff --git a/core/modules/views/plugins/views_plugin_exposed_form.inc b/core/modules/views/plugins/views_plugin_exposed_form.inc index 5d54600461a..a22f422052d 100644 --- a/core/modules/views/plugins/views_plugin_exposed_form.inc +++ b/core/modules/views/plugins/views_plugin_exposed_form.inc @@ -72,8 +72,10 @@ class views_plugin_exposed_form extends views_plugin { '#description' => t('Text to display in the reset button of the exposed form.'), '#default_value' => $this->options['reset_button_label'], '#required' => TRUE, - '#dependency' => array( - 'edit-exposed-form-options-reset-button' => array(1) + '#states' => array( + 'invisible' => array( + 'input[name="exposed_form_options[reset_button]"]' => array('checked' => FALSE), + ), ), ); @@ -98,7 +100,11 @@ class views_plugin_exposed_form extends views_plugin { '#description' => t('Text to use when exposed sort is ordered ascending.'), '#default_value' => $this->options['sort_asc_label'], '#required' => TRUE, - '#dependency' => array('edit-exposed-form-options-expose-sort-order' => array(TRUE)), + '#states' => array( + 'visible' => array( + 'input[name="exposed_form_options[expose_sort_order]"]' => array('checked' => TRUE), + ), + ), ); $form['sort_desc_label'] = array( @@ -107,7 +113,11 @@ class views_plugin_exposed_form extends views_plugin { '#description' => t('Text to use when exposed sort is ordered descending.'), '#default_value' => $this->options['sort_desc_label'], '#required' => TRUE, - '#dependency' => array('edit-exposed-form-options-expose-sort-order' => array(TRUE)), + '#states' => array( + 'visible' => array( + 'input[name="exposed_form_options[expose_sort_order]"]' => array('checked' => TRUE), + ), + ), ); $form['autosubmit'] = array( @@ -122,8 +132,10 @@ class views_plugin_exposed_form extends views_plugin { '#title' => t('Hide submit button'), '#description' => t('Hide submit button if javascript is enabled.'), '#default_value' => $this->options['autosubmit_hide'], - '#dependency' => array( - 'edit-exposed-form-options-autosubmit' => array(1), + '#states' => array( + 'invisible' => array( + 'input[name="exposed_form_options[autosubmit]"]' => array('checked' => FALSE), + ), ), ); } diff --git a/core/modules/views/plugins/views_plugin_pager_full.inc b/core/modules/views/plugins/views_plugin_pager_full.inc index aedb2237adc..4a5c17d888c 100644 --- a/core/modules/views/plugins/views_plugin_pager_full.inc +++ b/core/modules/views/plugins/views_plugin_pager_full.inc @@ -151,8 +151,10 @@ class views_plugin_pager_full extends views_plugin_pager { '#required' => TRUE, '#description' => t('Label to use in the exposed items per page form element.'), '#default_value' => $this->options['expose']['items_per_page_label'], - '#dependency' => array( - 'edit-pager-options-expose-items-per-page' => array(1) + '#states' => array( + 'invisible' => array( + 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE), + ), ), ); @@ -162,8 +164,10 @@ class views_plugin_pager_full extends views_plugin_pager { '#required' => TRUE, '#description' => t('Set between which values the user can choose when determining the items per page. Separated by comma.'), '#default_value' => $this->options['expose']['items_per_page_options'], - '#dependency' => array( - 'edit-pager-options-expose-items-per-page' => array(1) + '#states' => array( + 'invisible' => array( + 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE), + ), ), ); @@ -180,8 +184,10 @@ class views_plugin_pager_full extends views_plugin_pager { '#title' => t('All items label'), '#description' => t('Which label will be used to display all items'), '#default_value' => $this->options['expose']['items_per_page_options_all_label'], - '#dependency' => array( - 'edit-items-per-page-options-all' => array(1), + '#states' => array( + 'invisible' => array( + 'input[name="pager_options[expose][items_per_page_options_all]"]' => array('checked' => FALSE), + ), ), ); @@ -198,8 +204,10 @@ class views_plugin_pager_full extends views_plugin_pager { '#required' => TRUE, '#description' => t('Label to use in the exposed offset form element.'), '#default_value' => $this->options['expose']['offset_label'], - '#dependency' => array( - 'edit-pager-options-expose-offset' => array(1) + '#states' => array( + 'invisible' => array( + 'input[name="pager_options[expose][offset]"]' => array('checked' => FALSE), + ), ), ); } diff --git a/core/modules/views/plugins/views_plugin_query_default.inc b/core/modules/views/plugins/views_plugin_query_default.inc index 030c5ea0032..b1e0bedaab2 100644 --- a/core/modules/views/plugins/views_plugin_query_default.inc +++ b/core/modules/views/plugins/views_plugin_query_default.inc @@ -258,7 +258,11 @@ class views_plugin_query_default extends views_plugin_query { '#title' => t('Pure Distinct'), '#description' => t('This will prevent views from adding the base column to the distinct field. If this is not selected and the base column is a primary key, then a non-pure distinct will not function properly because the primary key is always unique.'), '#default_value' => !empty($this->options['pure_distinct']), - '#dependency' => array('edit-query-options-distinct' => '1'), + '#states' => array( + 'visible' => array( + ':input[name="query[options][distinct]"]' => array('checked' => TRUE), + ), + ), ); $form['slave'] = array( '#type' => 'checkbox', diff --git a/core/modules/views/plugins/views_plugin_row_fields.inc b/core/modules/views/plugins/views_plugin_row_fields.inc index b1c02e1fd11..c39b40b59dc 100644 --- a/core/modules/views/plugins/views_plugin_row_fields.inc +++ b/core/modules/views/plugins/views_plugin_row_fields.inc @@ -48,12 +48,11 @@ class views_plugin_row_fields extends views_plugin_row { '#options' => $options, '#default_value' => $this->options['inline'], '#description' => t('Inline fields will be displayed next to each other rather than one after another. Note that some fields will ignore this if they are block elements, particularly body fields and other formatted HTML.'), - '#dependency' => array( - 'edit-row-options-default-field-elements' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="row_options[default_field_elements]"]' => array('checked' => TRUE), + ), ), - '#prefix' => '
', - '#suffix' => '
', - ); $form['separator'] = array( @@ -62,8 +61,10 @@ class views_plugin_row_fields extends views_plugin_row { '#size' => 10, '#default_value' => isset($this->options['separator']) ? $this->options['separator'] : '', '#description' => t('The separator may be placed between inline fields to keep them from squishing up next to each other. You can use HTML in this field.'), - '#dependency' => array( - 'edit-row-options-default-field-elements' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="row_options[default_field_elements]"]' => array('checked' => TRUE), + ), ), ); diff --git a/core/modules/views/plugins/views_plugin_style.inc b/core/modules/views/plugins/views_plugin_style.inc index d355e1bc16b..020b33f817b 100644 --- a/core/modules/views/plugins/views_plugin_style.inc +++ b/core/modules/views/plugins/views_plugin_style.inc @@ -219,17 +219,21 @@ class views_plugin_style extends views_plugin { '#title' => t('Use rendered output to group rows'), '#default_value' => $grouping['rendered'], '#description' => t('If enabled the rendered output of the grouping field is used to group the rows.'), - '#dependency' => array( - 'edit-style-options-grouping-' . $i . '-field' => array_keys($field_labels), - ) + '#states' => array( + 'invisible' => array( + ':input[name="style_options[grouping][' . $i . '][field]"]' => array('value' => ''), + ), + ), ); $form['grouping'][$i]['rendered_strip'] = array( '#type' => 'checkbox', '#title' => t('Remove tags from rendered output'), '#default_value' => $grouping['rendered_strip'], - '#dependency' => array( - 'edit-style-options-grouping-' . $i . '-field' => array_keys($field_labels), - ) + '#states' => array( + 'invisible' => array( + ':input[name="style_options[grouping][' . $i . '][field]"]' => array('value' => ''), + ), + ), ); } } diff --git a/core/modules/views/plugins/views_plugin_style_summary.inc b/core/modules/views/plugins/views_plugin_style_summary.inc index 5081dd62eec..256c0e34161 100644 --- a/core/modules/views/plugins/views_plugin_style_summary.inc +++ b/core/modules/views/plugins/views_plugin_style_summary.inc @@ -54,8 +54,10 @@ class views_plugin_style_summary extends views_plugin_style { '#type' => 'textfield', '#title' => t('Items to display'), '#default_value' => $this->options['items_per_page'], - '#dependency' => array( - 'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1) + '#states' => array( + 'visible' => array( + ':input[name="options[summary][options][' . $this->definition['name'] . '][override]"]' => array('checked' => TRUE), + ), ), ); } diff --git a/core/modules/views/plugins/views_plugin_style_table.inc b/core/modules/views/plugins/views_plugin_style_table.inc index 45ed97634f5..7c9e2079a8f 100644 --- a/core/modules/views/plugins/views_plugin_style_table.inc +++ b/core/modules/views/plugins/views_plugin_style_table.inc @@ -216,9 +216,7 @@ class views_plugin_style_table extends views_plugin_style { } foreach ($columns as $field => $column) { - $safe = str_replace(array('][', '_', ' '), '-', $field); - // the $id of the column for dependency checking. - $id = 'edit-style-options-columns-' . $safe; + $column_selector = ':input[name="style_options[columns][' . $field . ']"]'; $form['columns'][$field] = array( '#type' => 'select', @@ -229,14 +227,22 @@ class views_plugin_style_table extends views_plugin_style { $form['info'][$field]['sortable'] = array( '#type' => 'checkbox', '#default_value' => !empty($this->options['info'][$field]['sortable']), - '#dependency' => array($id => array($field)), + '#states' => array( + 'visible' => array( + $column_selector => array('value' => $field), + ), + ), ); $form['info'][$field]['default_sort_order'] = array( '#type' => 'select', '#options' => array('asc' => t('Ascending'), 'desc' => t('Descending')), '#default_value' => !empty($this->options['info'][$field]['default_sort_order']) ? $this->options['info'][$field]['default_sort_order'] : 'asc', - '#dependency_count' => 2, - '#dependency' => array($id => array($field), 'edit-style-options-info-' . $safe . '-sortable' => array(1)), + '#states' => array( + 'visible' => array( + $column_selector => array('value' => $field), + ':input[name="style_options[info][' . $field . '][sortable]"]' => array('checked' => TRUE), + ), + ), ); // Provide an ID so we can have such things. $radio_id = drupal_html_id('edit-default-' . $field); @@ -248,7 +254,11 @@ class views_plugin_style_table extends views_plugin_style { // because 'radio' doesn't fully support '#id' =( '#attributes' => array('id' => $radio_id), '#default_value' => $default, - '#dependency' => array($id => array($field)), + '#states' => array( + 'visible' => array( + $column_selector => array('value' => $field), + ), + ), ); } $form['info'][$field]['align'] = array( @@ -260,18 +270,30 @@ class views_plugin_style_table extends views_plugin_style { 'views-align-center' => t('Center'), 'views-align-right' => t('Right'), ), - '#dependency' => array($id => array($field)), + '#states' => array( + 'visible' => array( + $column_selector => array('value' => $field), + ), + ), ); $form['info'][$field]['separator'] = array( '#type' => 'textfield', '#size' => 10, '#default_value' => isset($this->options['info'][$field]['separator']) ? $this->options['info'][$field]['separator'] : '', - '#dependency' => array($id => array($field)), + '#states' => array( + 'visible' => array( + $column_selector => array('value' => $field), + ), + ), ); $form['info'][$field]['empty_column'] = array( '#type' => 'checkbox', '#default_value' => isset($this->options['info'][$field]['empty_column']) ? $this->options['info'][$field]['empty_column'] : FALSE, - '#dependency' => array($id => array($field)), + '#states' => array( + 'visible' => array( + $column_selector => array('value' => $field), + ), + ), ); // markup for the field name diff --git a/core/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php b/core/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php index 891357257df..1c3b790bb49 100644 --- a/core/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php +++ b/core/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php @@ -103,8 +103,10 @@ function build_form($form, &$form_state) { $form['displays']['page']['options'] = array( '#type' => 'container', '#attributes' => array('class' => array('options-set'),), - '#dependency' => array( - 'edit-page-create' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="page[create]"]' => array('checked' => TRUE), + ), ), //'#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '
', @@ -147,7 +149,7 @@ function build_form($form, &$form_state) { '#size' => 5, '#element_validate' => array('views_element_validate_integer'), ); - $form['displays']['page']['options']['pager'] = array( + $form['displays']['page']['options']['pagerz'] = array( '#title' => t('Use a pager'), '#type' => 'checkbox', '#default_value' => TRUE, @@ -159,8 +161,10 @@ function build_form($form, &$form_state) { ); $form['displays']['page']['options']['link_properties'] = array( '#type' => 'container', - '#dependency' => array( - 'edit-page-link' => array(1), + '#states' => array( + 'visible' => array( + ':input[name="page[link]"]' => array('checked' => TRUE), + ), ), //'#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '