Skip to content

Commit

Permalink
Fixed bug #756 & #744 - New popup height calculation method.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2656 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
David Olivier committed Mar 31, 2007
1 parent 346f929 commit bc9949e
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions admin/html.php
Expand Up @@ -473,11 +473,9 @@
}
$surveysummary .= "<tr><td align=\"center\"><a href=\"#\" accesskey='d' onclick=\"document.getElementById('testsurvpopup').style.visibility='hidden';\"><font color=\"#DF3030\">".$clang->gT("Cancel")."</font></a></td></tr></table></div>";

if (count($tmp_survlangs) > 2)
{
$tmp_pheight = 127 + ((count($tmp_survlangs)-2) * 32);
$surveysummary .= "<script type='text/javascript'>document.getElementById('testsurvpopup').style.height='".$tmp_pheight."px';</script>";
}
$tmp_pheight = getPopupHeight();
$surveysummary .= "<script type='text/javascript'>document.getElementById('testsurvpopup').style.height='".$tmp_pheight."px';</script>";

}

if($sumrows5['browse_response'])
Expand Down Expand Up @@ -1094,7 +1092,7 @@
. "onmouseover=\"showTooltip(event,'".$clang->gT("Preview This Question", "js")."');return false\">"
. "<img src='$imagefiles/preview.png' title='' alt='' align='left' name='previewquestion' /></a>\n"
. "\t\t\t\t\t<img src='$imagefiles/seperator.gif' alt='' border='0' hspace='0' align='left' />\n";

$tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$tmp_survlangs[] = $baselang;
Expand All @@ -1106,12 +1104,8 @@
$surveysummary .= "<tr><td><a href=\"#\" accesskey='d' onclick=\"document.getElementById('previewquestion').style.visibility='hidden'; window.open('$scriptname?action=previewquestion&amp;sid=$surveyid&amp;qid=$qid&amp;lang=".$tmp_lang."', '_blank')\"><font color=\"#097300\"><b>".getLanguageNameFromCode($tmp_lang,false)."</b></font></a></td></tr>";
}
$surveysummary .= "<tr><td align=\"center\"><a href=\"#\" accesskey='d' onclick=\"document.getElementById('previewquestion').style.visibility='hidden';\"><font color=\"#DF3030\">".$clang->gT("Cancel")."</font></a></td></tr></table></div>";

if (count($tmp_survlangs) > 2)
{
$tmp_pheight = 127 + ((count($tmp_survlangs)-2) * 32);
$surveysummary .= "<script type='text/javascript'>document.getElementById('previewquestion').style.height='".$tmp_pheight."px';</script>";
}
$tmp_pheight = getPopupHeight();
$surveysummary .= "<script type='text/javascript'>document.getElementById('previewquestion').style.height='".$tmp_pheight."px';</script>";
}
}
else
Expand Down Expand Up @@ -2563,6 +2557,40 @@
}
}

function getPopupHeight()
{
global $clang, $surveyid;

$rowheight = 16;
$height = 0;
$bottomPad = 1;

// header text height
$htext = ceil(strlen($clang->gT("Please select a language:")) / 17);
$height += $rowheight * $htext;

// language list height
$survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$survlangs[] = $baselang;
rsort($survlangs);

foreach ($survlangs as $lang)
{
$ltext = ceil(strlen(getLanguageNameFromCode($lang,false)) / 10);
$height += $rowheight * $ltext;
//if ($ltext > 1) $height += (($ltext-1) * -1);
}

// footer height
$ftext = ceil(count($clang->gT("Cancel")) / 17);
$height += $rowheight * $ftext;

$height += $bottomPad;

return $height;
}

function replacenewline ($texttoreplace)
{
$texttoreplace = str_replace( "\n", '<br />', $texttoreplace);
Expand Down

0 comments on commit bc9949e

Please sign in to comment.