Skip to content

Commit

Permalink
Fixed a bug with Firefox where the cursor keys in the question type s…
Browse files Browse the repository at this point in the history
…elect box did not properly change the visibility of surrounding controls

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2180 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Dec 7, 2006
1 parent a8f97e2 commit cb30ed2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
8 changes: 5 additions & 3 deletions admin/html.php
Expand Up @@ -2144,7 +2144,7 @@
. "\t</tr>\n"
. "\t<tr>\n"
. "\t\t<td align='right'><strong>"._("Type:")."</strong></td>\n"
. "\t\t<td><select name='type' onchange='OtherSelection(this.options[this.selectedIndex].value);'>\n"
. "\t\t<td><SELECT name='type' onchange='OtherSelection(this.options[this.selectedIndex].value);'>\n"
. getqtypelist($eqrow['type'])
. "\t\t</select></td>\n"
. "\t</tr>\n";
Expand Down Expand Up @@ -2336,7 +2336,7 @@
. "\t\t<td align='right'><strong>"._("Type:")."</strong></td>\n";
if ($activated != "Y")
{
$editquestion .= "\t\t<td><select id='question_type' name='type' "
$editquestion .= "\t\t<td><SELECT id='question_type' name='type' "
. "onchange='OtherSelection(this.options[this.selectedIndex].value);'>\n"
. getqtypelist($eqrow['type'])
. "\t\t</select></td>\n";
Expand Down Expand Up @@ -3753,7 +3753,9 @@ function replacenewline ($texttoreplace)
function questionjavascript($type, $qattributes)
{
$newquestion = "<script type='text/javascript'>\n"
. "<!--\n";
. "<!--\n"
."if (navigator.userAgent.indexOf(\"Gecko\") != -1)\n"
."window.addEventListener(\"load\", init_gecko_select_hack, false);\n";
$jc=0;
$newquestion .= "\t\t\tvar qtypes = new Array();\n";
$newquestion .= "\t\t\tvar qnames = new Array();\n\n";
Expand Down
23 changes: 22 additions & 1 deletion admin/scripts/validation.js
Expand Up @@ -18,11 +18,32 @@ function validatefilename ( form )


// If the length of the element's string is 0 then display helper message
function isEmpty(elem, helperMsg){
function isEmpty(elem, helperMsg)
{
if(elem.value.length == 0){
alert(helperMsg);
elem.focus(); // set the focus to this input
return false;
}
return true;
}


// (c) 2006 Simon Wunderlin, License: GPL, hacks want to be free ;)
// This fix forces Firefox to fire the onchange event if someone changes select box with cursor keys
function ev_gecko_select_keyup_ev(Ev) {
// prevent tab, alt, ctrl keys from fireing the event
if (Ev.keyCode && (Ev.keyCode == 1 || Ev.keyCode == 9 ||
Ev.keyCode == 16 || Ev.altKey || Ev.ctrlKey))
return true;
Ev.target.onchange();
return true;
}

function init_gecko_select_hack() {
var selects = document.getElementsByTagName("SELECT");
for(i=0; i<selects.length; i++)
selects.item(i).addEventListener("keyup", ev_gecko_select_keyup_ev, false);
return true;
}

0 comments on commit cb30ed2

Please sign in to comment.