Skip to content

Commit

Permalink
Fixed issue #05383: Keyboard-less operation doesn't work for all inpu…
Browse files Browse the repository at this point in the history
…t fields

Dev Enabled keyboard for all text inputs and textareas
Dev Added keyup trigger to keyboard to fire conditions and other onkeyup functions

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10711 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Tony Partner committed Aug 12, 2011
1 parent 0841640 commit 655df9d
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 27 deletions.
80 changes: 71 additions & 9 deletions application/helpers/qanda_helper.php
Expand Up @@ -2682,11 +2682,21 @@ function do_list_radio($ia)
// ---------------------------------------------------------------
function do_listwithcomment($ia)
{
global $maxoptionsize, $dropdownthreshold, $lwcdropdowns;
global $maxoptionsize, $dropdownthreshold, $lwcdropdowns, $thissurvey;
$CI =& get_instance();
$dbprefix = $CI->db->dbprefix;
$clang = $CI->limesurvey_lang;

if ($thissurvey['nokeyboard']=='Y')
{
vIncludeKeypad();
$kpclass = "text-keypad";
}
else
{
$kpclass = "";
}

if ($ia[8] == 'Y')
{
$checkconditionFunction = "checkconditions";
Expand Down Expand Up @@ -2772,7 +2782,7 @@ function do_listwithcomment($ia)
<p class="comment">
<label for="answer'.$ia[1].'comment">'.$hint_comment.':</label>
<textarea class="textarea" name="'.$ia[1].'comment" id="answer'.$ia[1].'comment" rows="'.floor($tarows).'" cols="30" >';
<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'comment" id="answer'.$ia[1].'comment" rows="'.floor($tarows).'" cols="30" >';
// --> END NEW FEATURE - SAVE
if (isset($_SESSION[$fname2]) && $_SESSION[$fname2])
{
Expand Down Expand Up @@ -3099,6 +3109,16 @@ function do_multiplechoice($ia)
$dbprefix = $CI->db->dbprefix;
$clang = $CI->limesurvey_lang;

if ($thissurvey['nokeyboard']=='Y')
{
vIncludeKeypad();
$kpclass = "text-keypad";
}
else
{
$kpclass = "";
}

// Find out if any questions have attributes which reference this questions
// based on value of attribute. This could be array_filter and array_filter_exclude

Expand Down Expand Up @@ -3428,7 +3448,7 @@ function excludeAllOthers$ia[1](value, doconditioncheck)
$answer .= " $checkconditionFunction(document.getElementById(\"answer$myfname\").value, document.getElementById(\"answer$myfname\").name, document.getElementById(\"answer$myfname\").type);";
$answer .= "' />
<label for=\"answer$myfname\" class=\"answertext\">".$othertext."</label>
<input class=\"text\" type=\"text\" name=\"$myfname\" id=\"answer$myfname\"";
<input class=\"text ".$kpclass."\" type=\"text\" name=\"$myfname\" id=\"answer$myfname\"";
if (isset($_SESSION[$myfname]))
{
$answer .= ' value="'.htmlspecialchars($_SESSION[$myfname],ENT_QUOTES).'"';
Expand Down Expand Up @@ -3602,6 +3622,16 @@ function do_multiplechoice_withcomments($ia)
$dbprefix = $CI->db->dbprefix;
$clang = $CI->limesurvey_lang;

if ($thissurvey['nokeyboard']=='Y')
{
vIncludeKeypad();
$kpclass = "text-keypad";
}
else
{
$kpclass = "";
}

$attribute_ref=false;
$qaquery = "SELECT qid,attribute FROM ".$CI->db->dbprefix('question_attributes')." WHERE value LIKE '".strtolower($ia[2])."'";
$qaresult = db_execute_assoc($qaquery); //Checked
Expand Down Expand Up @@ -3751,7 +3781,7 @@ function do_multiplechoice_withcomments($ia)
$answer_main .= "' />\n";
$fn++;
$answer_main .= "</span>\n<span class=\"comment\">\n\t<label for='answer$myfname2' class=\"answer-comment\">\n"
."<input class='text' type='text' size='40' id='answer$myfname2' name='$myfname2' title='".$clang->gT("Make a comment on your choice here:")."' value='";
."<input class='text ".$kpclass."' type='text' size='40' id='answer$myfname2' name='$myfname2' title='".$clang->gT("Make a comment on your choice here:")."' value='";
if (isset($_SESSION[$myfname2])) {$answer_main .= htmlspecialchars($_SESSION[$myfname2],ENT_QUOTES);}
// --> START NEW FEATURE - SAVE
$answer_main .= "' onclick='cancelBubbleThis(event);' onkeyup='if (jQuery.trim($(\"#answer{$myfname2}\").val())!=\"\") { document.getElementById(\"answer{$myfname}\").checked=true;$checkconditionFunction(document.getElementById(\"answer{$myfname}\").value,\"$myfname\",\"checkbox\");}' onkeyup='".$callmaxanswscriptcheckbox2."(document.getElementById(\"answer{$myfname}\"))' />\n\t</label>\n</span>\n"
Expand All @@ -3769,7 +3799,7 @@ function do_multiplechoice_withcomments($ia)
$myfname2 = $myfname.'comment';
$anscount = $anscount + 2;
$answer_main .= "\t<li class=\"other\">\n<span class=\"option\">\n"
. "\t<label for=\"answer$myfname\" class=\"answertext\">\n".$othertext."\n<input class=\"text other\" $numbersonly type=\"text\" name=\"$myfname\" id=\"answer$myfname\" title=\"".$clang->gT('Other').'" size="10"';
. "\t<label for=\"answer$myfname\" class=\"answertext\">\n".$othertext."\n<input class=\"text other ".$kpclass."\" $numbersonly type=\"text\" name=\"$myfname\" id=\"answer$myfname\" title=\"".$clang->gT('Other').'" size="10"';
if ($_SESSION[$myfname])
{
$answer_main .= ' value="'.htmlspecialchars($_SESSION[$myfname],ENT_QUOTES).'"';
Expand Down Expand Up @@ -5228,10 +5258,21 @@ function getLatLongFromIp($ip){
// ---------------------------------------------------------------
function do_longfreetext($ia)
{
global $js_header_includes;
global $js_header_includes, $thissurvey;
$CI =& get_instance();
$clang = $CI->limesurvey_lang;

if ($thissurvey['nokeyboard']=='Y')
{
vIncludeKeypad();
$kpclass = "text-keypad";
}
else
{
$kpclass = "";
}


if ($ia[8] == 'Y')
{
$checkconditionFunction = "checkconditions";
Expand Down Expand Up @@ -5286,7 +5327,7 @@ function textLimit(field, maxlen) {


// --> START NEW FEATURE - SAVE
$answer .= '<textarea class="textarea" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
$answer .= '<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
.'rows="'.$drows.'" cols="'.$tiwidth.'" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
// --> END NEW FEATURE - SAVE

Expand All @@ -5310,9 +5351,20 @@ function textLimit(field, maxlen) {
// ---------------------------------------------------------------
function do_hugefreetext($ia)
{
global $thissurvey;
$CI =& get_instance();
$clang = $CI->limesurvey_lang;

if ($thissurvey['nokeyboard']=='Y')
{
vIncludeKeypad();
$kpclass = "text-keypad";
}
else
{
$kpclass = "";
}

if ($ia[8] == 'Y')
{
$checkconditionFunction = "checkconditions";
Expand Down Expand Up @@ -5367,7 +5419,7 @@ function textLimit(field, maxlen) {
// --> START ENHANCEMENT - TEXT INPUT WIDTH

// --> START NEW FEATURE - SAVE
$answer .= '<textarea class="textarea" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
$answer .= '<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
.'rows="'.$drows.'" cols="'.$tiwidth.'" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
// --> END NEW FEATURE - SAVE

Expand Down Expand Up @@ -6557,6 +6609,16 @@ function do_array_multitext($ia)
$clang = $CI->limesurvey_lang;
$dbprefix = $CI->db->dbprefix;

if ($thissurvey['nokeyboard']=='Y')
{
vIncludeKeypad();
$kpclass = "text-keypad";
}
else
{
$kpclass = "";
}

if ($ia[8] == 'Y')
{
$checkconditionFunction = "checkconditions";
Expand Down Expand Up @@ -6835,7 +6897,7 @@ function do_array_multitext($ia)
$answer .= "\t<td class=\"answer_cell_00$ld\">\n"
. "\t\t\t\t<label for=\"answer{$myfname2}\">\n"
. "\t\t\t\t<input type=\"hidden\" name=\"java{$myfname2}\" id=\"java{$myfname2}\" />\n"
. "\t\t\t\t<input type=\"text\" name=\"$myfname2\" id=\"answer{$myfname2}\" title=\""
. "\t\t\t\t<input type=\"text\" name=\"$myfname2\" id=\"answer{$myfname2}\" class=\"".$kpclass."\" title=\""
. FlattenText($labelans[$thiskey]).'" '
. 'size="'.$inputwidth.'" '
. ' value="'.str_replace ('"', "'", str_replace('\\', '', $myfname2value))."\" />\n";
Expand Down
48 changes: 30 additions & 18 deletions scripts/survey_runtime.js
Expand Up @@ -14,25 +14,37 @@ $(document).ready(function()
});

// Keypad/keyboard
var kp = $("input.num-keypad");
if(kp.length) kp.keypad({showAnim: 'fadeIn', keypadOnly: false});
kp = $("input.text-keypad");
if(kp.length)
{
var spacer = $.keypad.HALF_SPACE;
for(var i = 0; i != 8; ++i) spacer += $.keypad.SPACE;
kp.keypad({
showAnim: 'fadeIn',
keypadOnly: false,
layout: [
spacer + $.keypad.CLEAR + $.keypad.CLOSE, $.keypad.SPACE,
'!@#$%^&*()_=' + $.keypad.HALF_SPACE + $.keypad.BACK,
$.keypad.HALF_SPACE + '`~[]{}<>\\|/' + $.keypad.SPACE + $.keypad.SPACE + '789',
'qwertyuiop\'"' + $.keypad.HALF_SPACE + $.keypad.SPACE + '456',
$.keypad.HALF_SPACE + 'asdfghjkl;:' + $.keypad.SPACE + $.keypad.SPACE + '123',
$.keypad.SPACE + 'zxcvbnm,.?' + $.keypad.SPACE + $.keypad.SPACE + $.keypad.HALF_SPACE + '-0+',
$.keypad.SHIFT + $.keypad.SPACE_BAR + $.keypad.ENTER]});
var kp = $("input.num-keypad");
if(kp.length)
{
kp.keypad({
showAnim: 'fadeIn', keypadOnly: false,
onKeypress: function(key, value, inst) {
$(this).trigger('keyup');
}
});
}
kp = $(".text-keypad");
if(kp.length)
{
var spacer = $.keypad.HALF_SPACE;
for(var i = 0; i != 8; ++i) spacer += $.keypad.SPACE;
kp.keypad({
showAnim: 'fadeIn',
keypadOnly: false,
layout: [
spacer + $.keypad.CLEAR + $.keypad.CLOSE, $.keypad.SPACE,
'!@#$%^&*()_=' + $.keypad.HALF_SPACE + $.keypad.BACK,
$.keypad.HALF_SPACE + '`~[]{}<>\\|/' + $.keypad.SPACE + $.keypad.SPACE + '789',
'qwertyuiop\'"' + $.keypad.HALF_SPACE + $.keypad.SPACE + '456',
$.keypad.HALF_SPACE + 'asdfghjkl;:' + $.keypad.SPACE + $.keypad.SPACE + '123',
$.keypad.SPACE + 'zxcvbnm,.?' + $.keypad.SPACE + $.keypad.SPACE + $.keypad.HALF_SPACE + '-0+',
$.keypad.SHIFT + $.keypad.SPACE_BAR + $.keypad.ENTER],
onKeypress: function(key, value, inst) {
$(this).trigger('keyup');
}
});
}

// Maps
$(".location").each(function(index,element){
Expand Down

0 comments on commit 655df9d

Please sign in to comment.