Commit dd4ddfe0 by Kartik Visweswaran

Simplify inline script code

Simplify the rendering of the inline script (using direct markup), eliminating need for using PHP variable to store value using HEREDOC.
parent f9befd58
......@@ -5,10 +5,13 @@ use yii\helpers\Json;
/* @var $this \yii\base\View */
/* @var $url string */
/* @var $enforceRedirect boolean */
$redirectJavaScript = <<<EOL
function popupWindowRedirect(url, enforceRedirect)
{
?>
<!DOCTYPE html>
<html>
<head>
<script>
function popupWindowRedirect(url, enforceRedirect)
{
if (window.opener && !window.opener.closed) {
if (enforceRedirect === undefined || enforceRedirect) {
window.opener.location = url;
......@@ -18,16 +21,9 @@ function popupWindowRedirect(url, enforceRedirect)
} else {
window.location = url;
}
}
EOL;
$redirectJavaScript .= 'popupWindowRedirect(' . Json::encode($url) . ', ' . Json::encode($enforceRedirect) . ');';
?>
<!DOCTYPE html>
<html>
<head>
<?= Html::script($redirectJavaScript) ?>
}
popupWindowRedirect(<?= Json::encode($url) ?>, <?= Json::encode($enforceRedirect) ?>);
</script>
</head>
<body>
<h2 id="title" style="display:none;">Redirecting back to the &quot;<?= Yii::$app->name ?>&quot;...</h2>
......
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