2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Only apply automatic text focus when working as an interviewer (otherwise may jump to strange part of page)

This commit is contained in:
Adam Zammit
2013-04-29 15:09:55 +10:00
parent 125e3713e3
commit 2b0cdce5f8
2 changed files with 27 additions and 2 deletions

View File

@@ -52,8 +52,35 @@ function templatereplace($line, $replacements=array(), $anonymized=false, $quest
if (stripos($line, "</head>"))
{
//queXS Addition
$textfocus = "";
$interviewer=returnglobal('interviewer');
if (!empty($interviewer) || (isset($_SESSION['interviewer']) && $_SESSION['interviewer'] == true))
{
$interviewer = true;
$_SESSION['interviewer'] = true;
}
else
{
$interviewer = false;
}
if ($interviewer)
{
$textfocus =
'<script type="text/javascript">
$(document).ready(function()
{
$(".text").focus();
$(".textarea").focus();
});
</script>';
}
$line = str_ireplace("</head>",
"<script type=\"text/javascript\" src=\"$rooturl/scripts/survey_runtime.js\"></script>\n"
. "$textfocus\n"
. use_firebug()
. "\t</head>", $line);
}

View File

@@ -6,8 +6,6 @@ $(document).ready(function()
if (typeof checkconditions!='undefined') checkconditions();
if (typeof template_onload!='undefined') template_onload();
prepareCellAdapters();
$(".text").focus();
$(".textarea").focus();
document['onkeypress'] = checkEnter;
if (typeof(focus_element) != 'undefined')
{