Sha256: 7a5c7c3efba92fe51bab80e1919650a4bf3c39a8f77d011d9168001bc1e0c122

Contents?: true

Size: 1.43 KB

Versions: 84

Compression:

Stored size: 1.43 KB

Contents

$(document).ready(function() {
  function updateAssessmentFormState() {
    var numberOfQuestions = $('#assessment .legend').length;
    var numberOfCheckedAnswers = $('#assessment input:checked').length;
    var numberOfUnansweredQuestions = numberOfQuestions - numberOfCheckedAnswers;

    var unansweredQuestionsBadge = $('#assessment .badge');
    if (numberOfUnansweredQuestions > 0) {
      if (numberOfUnansweredQuestions == 1) {
        unansweredQuestionsBadgeText = '<%= I18n.t 'woople_theme.assessment_form.unanswered_questions.one' %>';
      } else {
        unansweredQuestionsBadgeText = '<%= I18n.t 'woople_theme.assessment_form.unanswered_questions.other' %>'.replace('%{count}', numberOfUnansweredQuestions);
      }

      unansweredQuestionsBadge.text(unansweredQuestionsBadgeText);
    } else {
      if (phone()) {
        unansweredQuestionsBadge.hide();
      }

      unansweredQuestionsBadge.fadeOut();
      $('#assessment input[type=submit]').removeAttr('disabled');

      $('.touch #assessment .span4').addClass('collapse-height');
    }
  }

  $('#assessment').on('click', 'input[type=radio]', updateAssessmentFormState);

  var cancelButton = $('#assessment input[type=button]');
  cancelButton.click(function() {
    location.href = cancelButton.attr('data-course-path');
  });

  $('.touch #assessment label').click(function() {
    $(this).children('input').attr('checked', 'checked');
    updateAssessmentFormState();
  });
});

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
woople-theme-0.5.5 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.5.4 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.5.3 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.5.2 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.5.0.1 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.5.0 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.4.2 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.4.1 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.4.0 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.9 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.8 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.7 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.6 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.5 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.04 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.03 app/assets/javascripts/woople-theme/assessment_form.js.erb
woople-theme-0.3.02 app/assets/javascripts/assessment_form.js.erb
woople-theme-0.3.01 app/assets/javascripts/assessment_form.js.erb
woople-theme-0.3.0 app/assets/javascripts/assessment_form.js.erb
woople-theme-0.2.49 app/assets/javascripts/assessment_form.js.erb