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