From e5f404f6eff7f4f3d18438390563b4f43b1b5295 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Thu, 27 Oct 2011 16:57:39 -0400 Subject: [PATCH] fix [re]load to show initial flipped/marked state --- client.coffee | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/client.coffee b/client.coffee index 6f8d230..177f3b4 100644 --- a/client.coffee +++ b/client.coffee @@ -23,27 +23,31 @@ unless Array::shuffle? new_button = (text) -> $ $ "
#{text}
" -instantiate_card = (model) -> - text = model.text - x = model.x - y = model.y - card = $ $ "
#{text}
" +instantiate_card = (card) -> + text = card.text + x = card.x + y = card.y + view = $ $ "
#{text}
" button_box = $ $ '
' flip_button = new_button "flip over" mark_button = new_button "mark" flip_button.bind 'click', -> - state.flip state.agent, model.number, ! card.hasClass 'flipped' + state.flip state.agent, card.number, ! view.hasClass 'flipped' mark_button.bind 'click', -> - state.mark state.agent, model.number, ! card.hasClass 'marked' + state.mark state.agent, card.number, ! view.hasClass 'marked' button_box.append flip_button button_box.append mark_button - card.append button_box - $table.append card - card.draggable stack: '.card' - card.bind 'dragstop', (event, ui) -> - p = card.position() - state.move state.agent, model.number, p.left, p.top - model.view = card + view.append button_box + if card.marked + view.addClass 'marked' + if card.flipped + view.addClass 'flipped' + $table.append view + view.draggable stack: '.card' + view.bind 'dragstop', (event, ui) -> + p = view.position() + state.move state.agent, card.number, p.left, p.top + card.view = view error_lag = 3 -- 1.7.10.4