Skip to content

Commit

Permalink
refactored frame partials again and broke bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
tritchie committed Oct 2, 2011
1 parent 440b920 commit 6276a4b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 37 deletions.
13 changes: 12 additions & 1 deletion app/helpers/frames_helper.rb
Expand Up @@ -48,7 +48,7 @@ def bonusboxes
[box1, box2]
end
def bonusattrs
if Frame.find(@game.current_frame).position == 11
if Frame.find(@game.currentframe).position == 11
{:class => 'bonusbox'}
else
{:class => 'box2'}
Expand All @@ -57,4 +57,15 @@ def bonusattrs
def bonusframe?
@frame.position == 11
end
def bonus
@frame = frameat 11
if active?
render :partial => 'frames/activeframe'
else
render :partial => 'frames/inactiveframe'
end
end
def frameat(position)
@game.frames.where(:position => position)[0]
end
end
27 changes: 11 additions & 16 deletions app/views/frames/_activeframe.html.haml
@@ -1,16 +1,11 @@
%table
= form_for(@frame) do |f|
%tr
%td.ball1
= f.text_field :ball1, :size => 1, :onchange => "this.form.submit();"
%td.ball2
= f.text_field :ball2, :size => 1, :onchange => "this.form.submit();"
-if @frame.ball1 == nil
:javascript
document.getElementById("frame_ball1").focus();
-elsif @frame.ball2 == nil
:javascript
document.getElementById("frame_ball2").focus();
%tr
%td 1st
%td 2nd
= form_for(@frame) do |f|
%td.ball1
= f.text_field :ball1, :size => 1, :onchange => "this.form.submit();"
%td.ball2
= f.text_field :ball2, :size => 1, :onchange => "this.form.submit();"
-if @frame.ball1 == nil
:javascript
document.getElementById("frame_ball1").focus();
-elsif @frame.ball2 == nil
:javascript
document.getElementById("frame_ball2").focus();
4 changes: 4 additions & 0 deletions app/views/frames/_bonusframe.html.haml
@@ -0,0 +1,4 @@
%td{bonusattrs}
=bonusboxes[0]
%td{bonusattrs}
=bonusboxes[1]
24 changes: 8 additions & 16 deletions app/views/frames/_inactiveframe.html.haml
@@ -1,16 +1,8 @@
-#(:url => {:controller => 'games', :action => 'update', :id => @game.id})}
-#{:onclick => (:url => {:controller => 'games', :action => 'update', :game => {:current_frame => @frame.id}})}
%table
%tr
%td.box1
= box1
%td.box2
= box2
-if @frame.position == 10
%td{bonusattrs}
=bonusboxes[0]
%td{bonusattrs}
=bonusboxes[1]
%tr
%td.total{:colspan => 2}
= total
%td
-editable? ? link = {:href => "/games/#{@game.id}/update/#{@frame.id}"} : link = {}
%a{link}
%table
%td.box1
= box1
%td.box2
= box2
18 changes: 14 additions & 4 deletions app/views/shared/_frame.html.haml
@@ -1,7 +1,17 @@
%td{frameattrs}
-if active?
=render :partial => 'frames/activeframe'
%table
%tr
=render :partial => 'frames/activeframe'
=bonus if @frame.position == 10
%tr
%td 1st
%td 2nd
-else
-editable? ? link = {:href => "/games/#{@game.id}/update/#{@frame.id}"} : link = {}
%a{link}
=render :partial => 'frames/inactiveframe'
%table
%tr
=render :partial => 'frames/inactiveframe'
=bonus if @frame.position == 10
%tr
%td.total{:colspan => 2}
= total

0 comments on commit 6276a4b

Please sign in to comment.