From ad08f22f1ad3b605e78933b6dc6075f534c0e1b9 Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Sat, 5 Jan 2019 22:41:13 +0000 Subject: [PATCH] - allow clicking anywhere in the row of the topic list and of options of radio and checkbox questions --- static/js/topic.js | 17 +++++++++++++++++ templates/question-checkbox.html | 3 ++- templates/question-radio.html | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/static/js/topic.js b/static/js/topic.js index b74440e..4b33a33 100644 --- a/static/js/topic.js +++ b/static/js/topic.js @@ -71,6 +71,23 @@ function new_question(type, question, tries, progress) { $('#topic_progress').css('width', (100*progress)+'%').attr('aria-valuenow', 100*progress); MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question_div"]); + if (type == "radio") { + $(".list-group-item").click(function () { + var index = $(this).index(); + $("div.list-group input:radio").eq(index).prop("checked", true); + + // $('a.list-group-item-primary').removeClass('list-group-item-primary'); + // $(this).addClass('list-group-item-primary'); + }); + } + else if (type == "checkbox") { + $(".list-group-item").click(function () { + var index = $(this).index(); + $("div.list-group input:checkbox").eq(index).trigger("click"); + }); + } + + // enable shift+enter to submit $("input:text, input:radio, input:checkbox").keydown(function (e) { if (e.keyCode == 13) { diff --git a/templates/question-checkbox.html b/templates/question-checkbox.html index 0be69f3..6940b9d 100644 --- a/templates/question-checkbox.html +++ b/templates/question-checkbox.html @@ -7,7 +7,8 @@ {% for n,opt in enumerate(question['options']) %}
- +
diff --git a/templates/question-radio.html b/templates/question-radio.html index 3a8e0c3..12c19f6 100644 --- a/templates/question-radio.html +++ b/templates/question-radio.html @@ -7,7 +7,8 @@ {% for n,opt in enumerate(question['options']) %}
- +
-- libgit2 0.21.2