Commit 14fbd557 authored by catch's avatar catch
Browse files

Issue #1574484 by tim.plunkett, nod_: Replace authorize.js with states.

parent 777a7b91
......@@ -21,10 +21,6 @@ function authorize_filetransfer_form($form, &$form_state) {
// If possible, we want to post this form securely via https.
$form['#https'] = TRUE;
// CSS we depend on lives in modules/system/maintenance.css, which is loaded
// via the default maintenance theme.
$form['#attached']['js'][] = $base_url . '/misc/authorize.js';
// Get all the available ways to transfer files.
if (empty($_SESSION['authorize_filetransfer_info'])) {
drupal_set_message(t('Unable to continue, no available methods of file transfer'), 'error');
......@@ -83,7 +79,6 @@ function authorize_filetransfer_form($form, &$form_state) {
'#type' => 'submit',
'#value' => t('Continue'),
'#weight' => 100,
'#attributes' => array('style' => 'display:none'),
);
// Build a container for each connection type.
......@@ -92,6 +87,11 @@ function authorize_filetransfer_form($form, &$form_state) {
$form['connection_settings'][$name] = array(
'#type' => 'container',
'#attributes' => array('class' => array("filetransfer-$name", 'filetransfer')),
'#states' => array(
'visible' => array(
'select[name="connection_settings[authorize_filetransfer_default]"]' => array('value' => $name),
),
),
);
// We can't use #prefix on the container itself since then the header won't
// be hidden and shown when the containers are being manipulated via JS.
......
/**
* @file
* Conditionally hide or show the appropriate settings and saved defaults
* on the file transfer connection settings form used by authorize.php.
*/
(function ($) {
"use strict";
Drupal.behaviors.authorizeFileTransferForm = {
attach: function(context) {
$('#edit-connection-settings-authorize-filetransfer-default').change(function() {
$('.filetransfer').hide().filter('.filetransfer-' + $(this).val()).show();
});
$('.filetransfer').hide().filter('.filetransfer-' + $('#edit-connection-settings-authorize-filetransfer-default').val()).show();
// Removes the float on the select box (used for non-JS interface).
if ($('.connection-settings-update-filetransfer-default-wrapper').length > 0) {
$('.connection-settings-update-filetransfer-default-wrapper').css('float', 'none');
}
// Hides the submit button for non-js users.
$('#edit-submit-connection').hide();
$('#edit-submit-process').show();
}
};
})(jQuery);
/**
* Update styles
*/
......@@ -26,16 +25,21 @@
/**
* Authorize.php styles
*/
.connection-settings-update-filetransfer-default-wrapper {
float: left;
}
#edit-submit-connection {
clear: both;
}
#edit-submit-process,
.filetransfer {
display: none;
clear: both;
}
.js #edit-submit-connection {
display: none;
}
.js #edit-submit-process {
display: block;
}
#edit-connection-settings-change-connection-type {
margin: 2.6em 0.5em 0em 1em;
}
......
......@@ -1321,12 +1321,12 @@ class CommonJavaScriptTestCase extends WebTestBase {
// same regardless of whether aggregation is enabled, so ensure this
// expected order, first with aggregation off.
drupal_add_js('core/misc/ajax.js');
drupal_add_js('core/misc/authorize.js', array('every_page' => TRUE));
drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE));
drupal_add_js('core/misc/autocomplete.js');
drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
$javascript = drupal_get_js();
$expected = implode("\n", array(
'<script type="text/javascript" src="' . file_create_url('core/misc/authorize.js') . '?' . $default_query_string . '"></script>',
'<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '"></script>',
'<script type="text/javascript" src="' . file_create_url('core/misc/batch.js') . '?' . $default_query_string . '"></script>',
'<script type="text/javascript" src="' . file_create_url('core/misc/ajax.js') . '?' . $default_query_string . '"></script>',
'<script type="text/javascript" src="' . file_create_url('core/misc/autocomplete.js') . '?' . $default_query_string . '"></script>',
......@@ -1340,13 +1340,13 @@ class CommonJavaScriptTestCase extends WebTestBase {
$config->set('preprocess_js', 1);
$config->save();
drupal_add_js('core/misc/ajax.js');
drupal_add_js('core/misc/authorize.js', array('every_page' => TRUE));
drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE));
drupal_add_js('core/misc/autocomplete.js');
drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
$js_items = drupal_add_js();
$javascript = drupal_get_js();
$expected = implode("\n", array(
'<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/authorize.js' => $js_items['core/misc/authorize.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js']))) . '"></script>',
'<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/collapse.js' => $js_items['core/misc/collapse.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js']))) . '"></script>',
'<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/ajax.js' => $js_items['core/misc/ajax.js'], 'core/misc/autocomplete.js' => $js_items['core/misc/autocomplete.js']))) . '"></script>',
));
$this->assertTrue(strpos($javascript, $expected) > 0, t('JavaScript is aggregated in the expected groups and order.'));
......
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