From eefb872c9416c10a891b0915cd5af32cdd9f4e52 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Fri, 17 Dec 2010 01:03:58 +0000
Subject: [PATCH] - Patch #951262 by sun: move #ajax default settings from PHP
 into JS.

---
 includes/ajax.inc | 9 ++-------
 misc/ajax.js      | 9 ++++++---
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/includes/ajax.inc b/includes/ajax.inc
index 899ab4547db6..af7e6da22a10 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -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.
diff --git a/misc/ajax.js b/misc/ajax.js
index 96be838b55e8..4672e3eb30ba 100644
--- a/misc/ajax.js
+++ b/misc/ajax.js
@@ -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
-- 
GitLab