mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-15 05:45:33 +08:00
Merge pull request #2883 from kartik-v/patch-14
Simplify inline script code
This commit is contained in:
@@ -5,29 +5,25 @@ use yii\helpers\Json;
|
||||
/* @var $this \yii\base\View */
|
||||
/* @var $url string */
|
||||
/* @var $enforceRedirect boolean */
|
||||
|
||||
$redirectJavaScript = <<<EOL
|
||||
function popupWindowRedirect(url, enforceRedirect)
|
||||
{
|
||||
if (window.opener && !window.opener.closed) {
|
||||
if (enforceRedirect === undefined || enforceRedirect) {
|
||||
window.opener.location = url;
|
||||
}
|
||||
window.opener.focus();
|
||||
window.close();
|
||||
} else {
|
||||
window.location = url;
|
||||
}
|
||||
}
|
||||
EOL;
|
||||
|
||||
$redirectJavaScript .= 'popupWindowRedirect(' . Json::encode($url) . ', ' . Json::encode($enforceRedirect) . ');';
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?= Html::script($redirectJavaScript) ?>
|
||||
<script>
|
||||
function popupWindowRedirect(url, enforceRedirect)
|
||||
{
|
||||
if (window.opener && !window.opener.closed) {
|
||||
if (enforceRedirect === undefined || enforceRedirect) {
|
||||
window.opener.location = url;
|
||||
}
|
||||
window.opener.focus();
|
||||
window.close();
|
||||
} else {
|
||||
window.location = url;
|
||||
}
|
||||
}
|
||||
popupWindowRedirect(<?= Json::encode($url) ?>, <?= Json::encode($enforceRedirect) ?>);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h2 id="title" style="display:none;">Redirecting back to the "<?= Yii::$app->name ?>"...</h2>
|
||||
|
||||
Reference in New Issue
Block a user