Added handling for global redirect and handling of ?cd=10 in redirect url, which should trigger the url to be loaded inside the top window

This commit is contained in:
Andreas Stöckel 2010-06-11 08:08:07 +00:00
parent e513532840
commit 04267ed34d
2 changed files with 23 additions and 5 deletions

View File

@ -323,10 +323,16 @@ class egw_json_response
*
* @param string $url
*/
public function redirect($url)
public function redirect($url, $global = false)
{
//self::script("location.href = '$url';");
$this->addGeneric('redirect', $url);
if (is_string($url) && is_bool($global))
{
//self::script("location.href = '$url';");
$this->addGeneric('redirect', array(
'url' => $url,
'global' => $global,
));
}
}
/**

View File

@ -229,9 +229,21 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
}
break;
case 'redirect':
if (typeof res.data == 'string')
if (typeof res.data.url == 'string' &&
typeof res.data.global == 'boolean')
{
window.location.href = res.data;
//Special handling for framework reload
if (res.data.url.indexOf("?cd=10") > 0)
res.data.global = true;
if (res.data.global)
{
egw_topWindow().location.href = res.data.url;
}
else
{
window.location.href = res.data.url;
}
}
break;
}