diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-14 00:06:58 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-14 00:06:58 +0200 |
commit | 9ffa462111b1d5b4c954464416fdc8daf69c9d3f (patch) | |
tree | b38e046662d4ae31d5b611166264e4d68500736a /theme/javascript/core/quiz.js | |
parent | 1bbef540157b513d3e336325a3d636885e15357e (diff) | |
download | gitbook-9ffa462111b1d5b4c954464416fdc8daf69c9d3f.zip gitbook-9ffa462111b1d5b4c954464416fdc8daf69c9d3f.tar.gz gitbook-9ffa462111b1d5b4c954464416fdc8daf69c9d3f.tar.bz2 |
Add base from clarity theme from @Nijikokun
Diffstat (limited to 'theme/javascript/core/quiz.js')
-rw-r--r-- | theme/javascript/core/quiz.js | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/theme/javascript/core/quiz.js b/theme/javascript/core/quiz.js deleted file mode 100644 index 7043641..0000000 --- a/theme/javascript/core/quiz.js +++ /dev/null @@ -1,52 +0,0 @@ -define([ - "jQuery", - "utils/execute", - "utils/analytic", - "core/state" -], function($, execute, analytic, state){ - // Bind an exercise - var prepareExercise = function($exercise) { - - $exercise.find(".quiz-answers input").click(function(e) { - e.preventDefault(); - }); - - // Submit: test code - $exercise.find(".action-submit").click(function(e) { - e.preventDefault(); - analytic.track("exercise.submit"); - $exercise.find("tr.alert-danger,li.alert-danger").removeClass("alert-danger"); - $exercise.find(".alert-success,.alert-danger").addClass("hidden"); - - $exercise.find(".quiz").each(function(q) { - var result = true; - var $answers = $exercise.find(".quiz-answers").slice(q).find("input[type=radio], input[type=checkbox]"); - $(this).find("input[type=radio],input[type=checkbox]").each(function(i) { - var correct = $(this).is(":checked") === $answers.slice(i).first().is(":checked"); - result = result && correct; - if (!correct) { - $(this).closest("tr, li").addClass("alert-danger"); - } - }); - $(this).find(result ? "div.alert-success" : "div.alert-danger").toggleClass("hidden"); - }); - - }); - - $exercise.find(".action-solution").click(function(e) { - $exercise.find(".quiz, .quiz-answers").toggleClass("hidden"); - }); - }; - - // Prepare all exercise - var init = function() { - state.$book.find("section.quiz").each(function() { - prepareExercise($(this)); - }); - }; - - return { - init: init, - prepare: prepareExercise - }; -}); |