Commit f678137c authored by jwhat's avatar jwhat Committed by japerry

Issue #1530010 by jwhat: Option for ctools_ajax_command_redirect() to open URL in new window

parent b46af3df
......@@ -414,12 +414,15 @@ function ctools_ajax_command_restripe($selector) {
* A delay before applying the redirection, in milliseconds.
* @param $options
* An array of options to pass to the url() function.
* @param $new_window
* A bool to determine if the URL should open in a new window.
*/
function ctools_ajax_command_redirect($url, $delay = 0, $options = array()) {
function ctools_ajax_command_redirect($url, $delay = 0, $options = array(), $new_window = FALSE) {
return array(
'command' => 'redirect',
'url' => url($url, $options),
'delay' => $delay,
'new_window' => $new_window,
);
}
......
......@@ -501,9 +501,17 @@
Drupal.CTools.AJAX.commands.redirect = function(data) {
if (data.delay > 0) {
setTimeout(function () {
location.href = data.url;
if (data.new_window) {
window.open(data.url, '_blank');
}
else {
location.href = data.url;
}
}, data.delay);
}
else if (data.new_window) {
window.open(data.url, '_blank');
}
else {
location.href = data.url;
}
......
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