tournament 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 3.2.0 / 2009-03-14
2
+ * Fix team selection page to not jump around when using arrow keys
3
+ with the autocomplete pop ups.
4
+ * Allow switch between seed and matchup order in team selection page.
5
+ * Minor cosmetic formatting changes.
6
+
1
7
  == 3.1.1 / 2009-03-13
2
8
  * Bugfixes for showing add entry links. Makes sure participants can
3
9
  add entries once the teams are set.
data/lib/tournament.rb CHANGED
@@ -7,7 +7,7 @@ unless defined? Tournament
7
7
  module Tournament
8
8
 
9
9
  # :stopdoc:
10
- VERSION = '3.1.1'
10
+ VERSION = '3.2.0'
11
11
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
12
12
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
13
13
  # :startdoc:
@@ -6,7 +6,7 @@ class Pool < ActiveRecord::Base
6
6
  before_save :marshal_pool
7
7
  belongs_to :user
8
8
  has_many :entries
9
- has_many :user_entries, :class_name => 'Entry', :conditions => ['user_id != ?', '#{user_id}']
9
+ has_many :user_entries, :class_name => 'Entry', :conditions => ['user_id != ?', '#{user_id}'], :include => :user, :order => 'users.login, entries.name'
10
10
  has_many :users, :through => :user_entries
11
11
  has_many :pending_entries, :class_name => 'Entry', :conditions => ['completed = ? and user_id != ?', false, '#{user_id}']
12
12
  has_one :tournament_entry, :class_name => 'Entry', :conditions => ['user_id = \'#{user_id}\'']
@@ -8,7 +8,7 @@
8
8
  <% @pools.each do |p| -%>
9
9
  <tr>
10
10
  <td><%=link_to p.name, :action => 'pool', :id => p.id%></td>
11
- <td><%=p.starts_at.to_formatted_s(:short)%></td>
11
+ <td><%=p.starts_at.to_formatted_s(:long)%></td>
12
12
  </tr>
13
13
  <% end %>
14
14
  </table>
@@ -3,7 +3,7 @@
3
3
  <% if Pool.active_pools.size > 0 %>
4
4
  <% Pool.active_pools.each do |pool| -%>
5
5
  <div class="poollistblock">
6
- <span class="poollisthead"><%= pool.name %></span>
6
+ <span class="poollisthead<%= pool.completed? ? ' poollistheaddone' : ''%>"><%= pool.name %></span>
7
7
  <small>
8
8
  <% if current_user && pool.user_id == current_user.id %>
9
9
  <% if pool.tournament_entry -%>
@@ -31,7 +31,7 @@ Total Entries: <%= pool.user_entries.size%>
31
31
  Last Update: <%=pool.updated_at.to_formatted_s(:long)%>
32
32
  </div>
33
33
  <div class="poollistinfodetail">
34
- Entry Fee: $<%=pool.fee%>
34
+ Entry Fee: <%=number_to_currency(pool.fee)%>
35
35
  </div>
36
36
  <% if pool.user_entries.size > 0 -%>
37
37
  <div class="poollistinfodetail">
@@ -39,7 +39,7 @@ Payouts:
39
39
  <% take = pool.user_entries.size * pool.fee.to_f -
40
40
  (pool.payouts.inject(0) {|sum, p| sum += p.kind == '$' ? p.payout.to_i : 0}) %>
41
41
  <% pool.payouts.delete_if{|p| p.kind.blank?}.sort_by {|p| p.rank }.each do |p| -%>
42
- <%=p.rank != 'L' ? p.rank.to_i.ordinal : 'Last'%>: $<%=p.kind == '$' ? p.payout : p.payout.to_f / 100.0 * take%>&nbsp;&nbsp;
42
+ <%=p.rank != 'L' ? p.rank.to_i.ordinal : 'Last'%>: <%=number_to_currency(p.kind == '$' ? p.payout : p.payout.to_f / 100.0 * take)%>&nbsp;&nbsp;
43
43
  <% end -%>
44
44
  </div>
45
45
  <% end -%>
@@ -17,19 +17,22 @@
17
17
  <p>
18
18
  <i>Same color region champs play each other in final four:</i>
19
19
  </p>
20
+ <p>
21
+ Order: <%= button_to_function('Seed Order', 'switch_to_seed_order()', :id => 'seed_button', :disabled => true) %> <%= button_to_function('Matchup Order', 'switch_to_matchup_order()', :id => 'matchup_button')%>
22
+ </p>
20
23
  <%= form_tag({:controller => 'teams', :action => 'change', :id => @pool.id}, {:method => "POST"}) %>
21
24
  <% @pool.region_seedings.each_with_index do |arr, index| -%>
22
25
  <% region_name = arr[0]; teams = arr[1] %>
23
26
  <div class="<%= cycle('regionLeft', 'regionRight', :name => 'tbclass')%> <%= cycle('regionTop', 'regionTop', 'regionBottom', 'regionBottom', :name => 'lrclass')%>">
24
27
  Region Name: <input type="text" name="region<%=index%>[name]" value="<%=region_name%>">
25
- <table>
28
+ <table id="<%="region_#{index}"%>">
26
29
  <tr>
27
30
  <th>Seed</th>
28
31
  <th>Name</th>
29
32
  <th>Short<br/>Name</th>
30
33
  </tr>
31
34
  <% teams.each_with_index do |team, seed_idx| -%>
32
- <tr>
35
+ <tr id="<%="region_#{index}_#{seed_idx}"%>">
33
36
  <td>
34
37
  <%= seed_idx + 1%>
35
38
  </td>
@@ -1,2 +1,65 @@
1
1
  // Place your application-specific JavaScript functions and classes here
2
2
  // This file is automatically included by javascript_include_tag :defaults
3
+ var swapMethod = {
4
+ swap: function(element, el) {
5
+ element = $(element);
6
+ el = $(el);
7
+
8
+ if (element == el) return element;
9
+
10
+ var clone = el.cloneNode(false); // no need to clone deep
11
+ Element.replace(element, clone);
12
+ Element.replace(el, element);
13
+ Element.replace(clone, el); // make sure references (like event observers) are kept
14
+ return element;
15
+ }
16
+ }
17
+ Element.addMethods(swapMethod);
18
+
19
+ var swaps = [
20
+ [15,2],
21
+ [10,7],
22
+ [7,14],
23
+ [10,3],
24
+ [10,11],
25
+ [7,6],
26
+ [3,13],
27
+ [7,4],
28
+ [6,12],
29
+ [4,9],
30
+ [3,8],
31
+ [2,16]
32
+ ];
33
+ var order = 'seed';
34
+
35
+ function switch_to_seed_order() {
36
+ if (order == 'seed') {
37
+ return;
38
+ }
39
+ $('matchup_button').enable();
40
+ $('seed_button').disable();
41
+ order = 'seed';
42
+ apply_swaps(swaps.reverse());
43
+ }
44
+
45
+ function switch_to_matchup_order() {
46
+ if (order == 'matchup') {
47
+ return;
48
+ }
49
+ $('matchup_button').disable();
50
+ $('seed_button').enable();
51
+ order = 'matchup';
52
+ apply_swaps(swaps.reverse());
53
+ }
54
+
55
+ function apply_swaps(swaps) {
56
+ for(var region = 0; region < 4; ++region) {
57
+ swaps.forEach(function(s) {
58
+ var index1 = s[0] - 1;
59
+ var index2 = s[1] - 1;
60
+ var node1 = $('region_' + region + '_' + index1);
61
+ var node2 = $('region_' + region + '_' + index2);
62
+ node1.swap(node2);
63
+ });
64
+ }
65
+ }
@@ -211,13 +211,21 @@ Autocompleter.Base = Class.create({
211
211
  markPrevious: function() {
212
212
  if(this.index > 0) this.index--;
213
213
  else this.index = this.entryCount-1;
214
- this.getEntry(this.index).scrollIntoView(true);
214
+ var entry = this.getEntry(this.index);
215
+ var doff = document.viewport.getScrollOffsets();
216
+ var eoff = entry.cumulativeOffset();
217
+ if (eoff[1] < doff[1])
218
+ entry.scrollIntoView(true);
215
219
  },
216
220
 
217
221
  markNext: function() {
218
222
  if(this.index < this.entryCount-1) this.index++;
219
223
  else this.index = 0;
220
- this.getEntry(this.index).scrollIntoView(false);
224
+ var entry = this.getEntry(this.index);
225
+ var doff = document.viewport.getScrollOffsets();
226
+ var eoff = entry.cumulativeOffset();
227
+ if (eoff[1] + entry.getHeight() > doff[1] + document.viewport.getHeight())
228
+ entry.scrollIntoView(false);
221
229
  },
222
230
 
223
231
  getEntry: function(index) {
@@ -960,4 +968,4 @@ Form.Element.DelayedObserver = Class.create({
960
968
  this.timer = null;
961
969
  this.callback(this.element, $F(this.element));
962
970
  }
963
- });
971
+ });
@@ -13,6 +13,7 @@ h1 {
13
13
  }
14
14
  .poollistblock {
15
15
  margin-left: 10px;
16
+ margin-bottom: 30px;
16
17
  }
17
18
  .poollistinfo {
18
19
  margin-left: 20px;
@@ -27,6 +28,9 @@ h1 {
27
28
  font-weight: bold;
28
29
  color: green;
29
30
  }
31
+ .poollistheaddone {
32
+ color: gray;
33
+ }
30
34
  #wrap {
31
35
  margin:0 auto;
32
36
  width:auto;
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 3
7
- - 1
8
- - 1
9
- version: 3.1.1
7
+ - 2
8
+ - 0
9
+ version: 3.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Douglas A. Seifert
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-13 00:00:00 -08:00
17
+ date: 2010-03-13 23:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency