Commit eefb872c authored by Dries's avatar Dries

- Patch #951262 by sun: move #ajax default settings from PHP into JS.

parent bc3f72a9
......@@ -613,15 +613,10 @@ function ajax_pre_render_element($element) {
$settings += array(
'path' => 'system/ajax',
'options' => array(),
'selector' => '#' . $element['#id'],
'effect' => 'none',
'speed' => 'none',
'method' => 'replaceWith',
'progress' => array('type' => 'throbber'),
);
// @todo Legacy support. Remove in Drupal 8.
if ($settings['method'] == 'replace') {
if (isset($settings['method']) && $settings['method'] == 'replace') {
$settings['method'] = 'replaceWith';
}
......@@ -659,7 +654,7 @@ function ajax_pre_render_element($element) {
}
// Convert a simple #ajax['progress'] string into an array.
if (is_string($settings['progress'])) {
if (isset($settings['progress']) && is_string($settings['progress'])) {
$settings['progress'] = array('type' => $settings['progress']);
}
// Change progress path to a full URL.
......
......@@ -25,6 +25,9 @@ Drupal.behaviors.AJAX = {
if (!$('#' + base + '.ajax-processed').length) {
var element_settings = settings.ajax[base];
if (typeof element_settings.selector == 'undefined') {
element_settings.selector = '#' + base;
}
$(element_settings.selector).each(function () {
element_settings.element = this;
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
......@@ -100,11 +103,11 @@ Drupal.ajax = function (base, element, element_settings) {
keypress: true,
selector: '#' + base,
effect: 'none',
speed: 'slow',
speed: 'none',
method: 'replaceWith',
progress: {
type: 'bar',
message: 'Please wait...'
type: 'throbber',
message: Drupal.t('Please wait...')
},
submit: {
'js': true
......
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