commit f2a3c9027d95a9f9b3025807f6287c688f345f43 Author: Nathan Haug Date: Thu Mar 14 12:32:09 2013 -0700 Reroll diff --git a/core/lib/Drupal/Core/Ajax/RedirectCommand.php b/core/lib/Drupal/Core/Ajax/RedirectCommand.php new file mode 100644 index 0000000..220c4c9 --- /dev/null +++ b/core/lib/Drupal/Core/Ajax/RedirectCommand.php @@ -0,0 +1,45 @@ +url = $url; + } + + /** + * Implements \Drupal\Core\Ajax\CommandInterface:render(). + */ + public function render() { + return array( + 'command' => 'redirect', + 'url' => $this->url, + ); + } + +} diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 08303f0..1b5d0ca 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -607,9 +607,9 @@ Drupal.ajax.prototype.commands = { }, /** - * Command to set the window.location. + * Command to set the window.location, redirecting the browser. */ - setWindowLocation: function (ajax, response, status) { + redirect: function (ajax, response, status) { window.location = response.url; }, diff --git a/core/misc/dialog.ajax.js b/core/misc/dialog.ajax.js index a30e0d9..90c9d26 100644 --- a/core/misc/dialog.ajax.js +++ b/core/misc/dialog.ajax.js @@ -9,9 +9,9 @@ Drupal.behaviors.dialog = { attach: function () { - // Provide a known 'drupal-modal' dom element for Drupal code to use for - // modal dialogs. Since there can be multiple non-modal dialogs at a time, - // it is the responsibility of calling code to create the elements it needs. + // Provide a known 'drupal-modal' DOM element for Drupal-based modal + // dialogs. Non-modal dialogs are responsible for creating their own + // elements, since there can be multiple non-modal dialogs at a time. if (!$('#drupal-modal').length) { $('
').hide().appendTo('body'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxCommandsUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxCommandsUnitTest.php index 6b1a831..9247297 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxCommandsUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxCommandsUnitTest.php @@ -30,7 +30,7 @@ use Drupal\Core\Ajax\CloseModalDialogCommand; use Drupal\Core\Ajax\SetDialogOptionCommand; use Drupal\Core\Ajax\SetDialogTitleCommand; -use Drupal\Core\Ajax\SetWindowLocationCommand; +use Drupal\Core\Ajax\RedirectCommand; /** * Tests for all AJAX Commands. @@ -417,16 +417,16 @@ function testSetDialogTitleCommand() { } /** - * Tests that SetWindowLocationCommand objects can be constructed and rendered. + * Tests that RedirectCommand objects can be constructed and rendered. */ - function testSetWindowLocationCommand() { - $command = new SetWindowLocationCommand('http://example.com'); + function testRedirectCommand() { + $command = new RedirectCommand('http://example.com'); $expected = array( - 'command' => 'setWindowLocation', + 'command' => 'redirect', 'url' => 'http://example.com', ); - $this->assertEqual($command->render(), $expected, 'SetWindowLocationCommand::render() with the expected command array.'); + $this->assertEqual($command->render(), $expected, 'RedirectCommand::render() with the expected command array.'); } }