X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/f3798df576ae72e99210acc544e6a72967a0cd2a..a85740df875a17b21d94b777b4152e77dbae6e28:/redakcja/static/edumed/js/edumed.coffee?ds=inline diff --git a/redakcja/static/edumed/js/edumed.coffee b/redakcja/static/edumed/js/edumed.coffee index cccc90aa..4bd8bed9 100644 --- a/redakcja/static/edumed/js/edumed.coffee +++ b/redakcja/static/edumed/js/edumed.coffee @@ -190,6 +190,55 @@ class Zastap extends Excercise $(chld).remove() +class Przyporzadkuj extends Excercise + constructor: (element) -> + super element + + if @element.attr('multiple')? + @multiple = true + else + @multiple = false + + $(".question", @element).each (i, question) => + draggable_opts = + revert: 'invalid' + helper: if @multiple then "clone" else null + + $(".draggable", question).draggable(draggable_opts) + .droppable({ + accept: ".draggable" + }) + + $(".predicate .droppable", question).droppable + accept: ".draggable" + drop: (ev, ui) -> + is_multiple = ui.draggable.is(".multiple") + + added = ui.draggable.clone() + + added.attr('style', '') + $(this).append(added) + added.draggable(draggable_opts) + + if not is_multiple + ui.draggable.remove() + + $(".subject", question).droppable + accept: ".draggable" + drop: (ev, ui) -> + is_multiple = ui.draggable.is(".multiple") + + added = ui.draggable.clone() + + added.attr('style', '') + if not is_multiple + $(this).append(added) + added.draggable(draggable_opts) + + ui.draggable.remove() + + + ########## @@ -199,6 +248,7 @@ excercise = (ele) -> uporzadkuj: Uporzadkuj luki: Luki zastap: Zastap + przyporzadkuj: Przyporzadkuj cls = es[$(ele).attr('data-type')]