+ $msg = $(".message", @element)
+ $msg.text("Wynik: #{score[0]} / #{score[1]}")
+ if score[0] == score[1]
+ $msg.addClass("maxscore")
+ else
+ $msg.removeClass("maxscore")
+
+
+ draggable_equal: ($draggable1, $draggable2) ->
+ return false
+
+ draggable_accept: ($draggable, $droppable) ->
+ dropped = $droppable.closest("ul, ol").find(".draggable")
+ for d in dropped
+ if @draggable_equal $draggable, $(d)
+ return false
+ return true
+
+ draggable_move: ($draggable, $placeholder, ismultiple) ->
+ $added = $draggable.clone()
+ $added.data("original", $draggable.get(0))
+ if not ismultiple
+ $draggable.addClass('disabled').draggable('disable')
+
+ $placeholder.after($added)
+ if not $placeholder.hasClass('multiple')
+ $placeholder.hide()
+ if $added.is(".add-li")
+ $added.wrap("<li/>")
+
+ $added.append('<span class="remove">x</span><div class="clr"></div>')
+ $('.remove', $added).click (ev) =>
+ @retry()
+ if not ismultiple
+ $($added.data('original')).removeClass('disabled').draggable('enable')
+
+ if $added.is(".add-li")
+ $added = $added.closest('li')
+ $added.prev(".placeholder:not(.multiple)").show()
+ $added.remove()
+
+
+## XXX co z issortable?
+ dragging: (ismultiple, issortable) ->
+ $(".question", @element).each (i, question) =>
+ draggable_opts =
+ revert: 'invalid'
+ helper: 'clone'
+ start: @retry
+
+ $(".draggable", question).draggable(draggable_opts)
+ self = this
+ $(".placeholder", question).droppable
+ accept: (draggable) ->
+ $draggable = $(draggable)
+ is_accepted = true
+
+ if not $draggable.is(".draggable")
+ is_accepted = false
+
+ if is_accepted
+ is_accepted= self.draggable_accept $draggable, $(this)
+
+ if is_accepted
+ $(this).addClass 'accepting'
+ else
+ $(this).removeClass 'accepting'
+ return is_accepted
+
+ drop: (ev, ui) =>
+ $(ev.target).removeClass 'accepting dragover'
+
+ @draggable_move $(ui.draggable), $(ev.target), ismultiple
+
+ # $added = $(ui.draggable).clone()
+ # $added.data("original", ui.draggable)
+ # if not ismultiple
+ # $(ui.draggable).addClass('disabled').draggable('disable')