Skip to content

Commit

Permalink
New feature #5762 : empty class on empty input type text
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed May 11, 2012
1 parent 591414d commit 178ab1c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
6 changes: 3 additions & 3 deletions application/helpers/qanda_helper.php
Expand Up @@ -2519,17 +2519,17 @@ function do_multiplechoice($ia)
$answer .= " if(this.checked===true) { document.getElementById(\"answer$myfname\").focus(); }; LEMflagMandOther(\"$myfname\",this.checked);";
$answer .= "' />
<label for=\"answer$myfname\" class=\"answertext\">".$othertext."</label>
<input class=\"text ".$kpclass."\" type=\"text\" name=\"$myfname\" id=\"answer$myfname\"";
<input class=\"text ".$kpclass."\" type=\"text\" name=\"$myfname\" id=\"answer$myfname\" value=\"";
if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]))
{
$dispVal = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname];
if ($aQuestionAttributes['other_numbers_only']==1)
{
$dispVal = str_replace('.',$sSeperator,$dispVal);
}
$answer .= ' value="'.htmlspecialchars($dispVal,ENT_QUOTES).'"';
$answer .= htmlspecialchars($dispVal,ENT_QUOTES);
}
$answer .= " onchange='$(\"#java{$myfname}\").val(this.value);$oth_checkconditionFunction(this.value, this.name, this.type);if ($.trim($(\"#java{$myfname}\").val())!=\"\") { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } else { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"\"); }; LEMflagMandOther(\"$myfname\",this.checked);' $numbersonly />";
$answer .= "\" onchange='$(\"#java{$myfname}\").val(this.value);$oth_checkconditionFunction(this.value, this.name, this.type);if ($.trim($(\"#java{$myfname}\").val())!=\"\") { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } else { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"\"); }; LEMflagMandOther(\"$myfname\",this.checked);' $numbersonly />";
$answer .= '<input type="hidden" name="java'.$myfname.'" id="java'.$myfname.'" value="';

// if ($maxansw > 0)
Expand Down
30 changes: 28 additions & 2 deletions scripts/survey_runtime.js
Expand Up @@ -2,9 +2,9 @@ var DOM1;
$(document).ready(function()
{

// Jquery-ui avigation buttons
// Jquery-ui navigation buttons
navbuttonsJqueryUi();

addClassEmpty();
DOM1 = (typeof document.getElementsByTagName!='undefined');
if (typeof LEMsetTabIndexes === 'function') { LEMsetTabIndexes(); }
if (typeof checkconditions!='undefined') checkconditions();
Expand Down Expand Up @@ -156,6 +156,32 @@ function navbuttonsJqueryUi(){
$('#movesubmitbtn, input.saveall, input.clearall').button();
}

// Put a empty class on empty answer text item (limit to answers part)
function addClassEmpty(){
$('.answer-item input.text[value=""]').addClass('empty');
$('.answer-item input[type=text][value=""]').addClass('empty');
$('.answer-item textarea').each(function(index) {
if ($(this).val() == ""){
$(this).addClass('empty');
}
});

$(".answer-item input.text,.text-item input[type=text]").live("blur", function(){
if ($(this).val() == ""){
$(this).addClass('empty');
}else{
$(this).removeClass('empty');
}
});
$(".answer-item textarea").live("blur", function(){
if ($(this).val() == ""){
$(this).addClass('empty');
}else{
$(this).removeClass('empty');
}
});
}


gmaps = new Object;
osmaps = new Object;
Expand Down
27 changes: 0 additions & 27 deletions templates/citronade/template.js
Expand Up @@ -41,31 +41,6 @@ function autoDisabledComment(){
});
}

// Add empty class to input text and textarea
function addClassEmpty(){
$('.answers-wrapper input.text[value=""]').addClass('empty');
$('.answers-wrapper input[type=text][value=""]').addClass('empty');
$('.answers-wrapper textarea').each(function(index) {
if ($(this).val() == ""){
$(this).addClass('empty');
}
});

$("input.text,input[type=text]").live("blur", function(){
if ($(this).val() == ""){
$(this).addClass('empty');
}else{
$(this).removeClass('empty');
}
});
$("textarea").live("blur", function(){
if ($(this).val() == ""){
$(this).addClass('empty');
}else{
$(this).removeClass('empty');
}
});
}
// Replace common alert with jquery-ui dialog
function jalert(text) {
var $dialog = $('<div></div>')
Expand All @@ -88,8 +63,6 @@ function jalert(text) {

$(document).ready(function(){
//autoDisabledComment();
addClassEmpty();

})


3 comments on commit 178ab1c

@Shnoulle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Did i put an .mandatory input.empty class on default template.css and other included template ?

@limesurvey-translations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@Shnoulle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.