diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/application/layout.js.coffee | 21 | ||||
-rw-r--r-- | app/assets/stylesheets/custom.css.scss | 4 | ||||
-rw-r--r-- | app/views/layouts/application.html.erb | 5 | ||||
-rw-r--r-- | app/views/tournaments/_form.html.erb | 107 |
4 files changed, 90 insertions, 47 deletions
diff --git a/app/assets/javascripts/application/layout.js.coffee b/app/assets/javascripts/application/layout.js.coffee new file mode 100644 index 0000000..da0bc67 --- /dev/null +++ b/app/assets/javascripts/application/layout.js.coffee @@ -0,0 +1,21 @@ +json_url = "/alerts.json" + +page_visited = false +starting_size = 0 +update = (alerts) -> + if !page_visited + starting_size = alerts.length + page_visited = true + + if alerts.length > starting_size + $("#alerts-ajax").css("display", "inline"); + return + + setTimeout (-> + $.ajax(url: json_url).done update + return + ), 2000 + +# Now kick off the whole process +window.onload = -> + $.ajax(url: json_url).done update
\ No newline at end of file diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index 9e9e63a..b274a0d 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -24,6 +24,10 @@ header > nav { } } +#alerts-ajax { + display: none; +} + .btn-custom-orange { color: white; background-color: rgb(255, 69, 0); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9eea734..f3535e9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -35,9 +35,8 @@ <%= link_to "Create Alert", new_alert_path, :class => "create-alert" %> <% end %> <%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout" %> - <%= link_to "", alerts_path, :class => "alerts"%> - - + <%# if there is an unread alert then I wanna be able to show the notification icon by saying :style => display:inline. This will be Done by Guntas once he figures out how to get unread alerts. Psuedo if alerts.unread > 0 then display else don't.%> + <%= link_to "", alerts_path, :class => "alerts", :id => "alerts-ajax"%> <% else %> <%= link_to "Log in", new_session_path, :class => "signin" %> <%= link_to "Sign up", new_user_path, :class => "signup" %> diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 986bc70..2a871ea 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -1,16 +1,20 @@ <%= render "common/error_messages", :target => @tournament %> -<fieldset><legend style="color:rgb(221, 145, 37)">Attributes</legend> -<%= form_for(@tournament, url: new_tournament_path, method: "get") do |f| %> - <%= render "common/error_messages", :target => @tournament %> - <p> - <%= f.label :game_id, "Select a game type" %> - <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> - <%= f.submit("Select") %> - </p> -<% end %> +<fieldset> + + <legend style="color:rgb(221, 145, 37)">Attributes + </legend> + + <%= form_for(@tournament, url: new_tournament_path, method: "get") do |f| %> + <%= render "common/error_messages", :target => @tournament %> + <p> + <%= f.label :game_id, "Select a game type" %> + <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> + <%= f.submit("Select") %> + </p> + <% end %> -<% if @tournament.game.nil? %> - </fieldset> + <% if @tournament.game.nil? %> +</fieldset> <% else %> <%= form_for(@tournament, url: tournaments_path, method: "post") do |f| %> <p> @@ -19,17 +23,20 @@ </p> <div> <p> - <table><tbody> - <tr> - <td></td> - <th style="padding:5px">Minimum</th> - <th style="padding:5px">Maximum</th></tr> - <tr> - <th>Players per team: </th> - <td style="padding:5px"><%= f.text_field(:min_players_per_team, type: :number, min: 1) %></td> - <td style="padding:5px"><%= f.text_field(:max_players_per_team, type: :number, min: 1) %></td> - </tr> - </tbody></table> + <table> + <tbody> + <tr> + <td></td> + <th style="padding:5px">Minimum</th> + <th style="padding:5px">Maximum</th> + </tr> + <tr> + <th>Players per team: </th> + <td style="padding:5px"><%= f.text_field(:min_players_per_team, type: :number, min: 1) %></td> + <td style="padding:5px"><%= f.text_field(:max_players_per_team, type: :number, min: 1) %></td> + </tr> + </tbody> + </table> </p> </div> @@ -55,9 +62,11 @@ <%= f.select(:sampling_method, @tournament.sampling_methods.map{|method| [method.humanize, method]}) %> </p> - </fieldset> +</fieldset> - <fieldset><legend style="color:rgb(221, 145, 37)">Settings</legend> +<fieldset> + <legend style="color:rgb(221, 145, 37)">Settings + </legend> <%= f.fields_for :settings do |setting_fields| %> <% @tournament.tournament_settings.each do |setting| %><p> <%= setting_fields.label setting.name %> @@ -85,29 +94,39 @@ <% when 5 %> <%= setting_fields.select( setting.name, setting.type_opt.split(',').collect {|opt| opt.humanize.titleize} ) %> <% end %> - </p><% end %> - <% end %> - </fieldset> - - <%= f.fields_for :stages do |stages_fields| %><fieldset><legend style="color:rgb(221, 145, 37)">Stages</legend> - <label for="num_stages">Number of tournament stages</label> - <input type="number" name="num_stages" min="1" value="<%= params[:num_stages].to_i %>"> - <%# stage_fields.submit("Set Stages") %> - <% for i in 1..(params[:num_stages].to_i) do %> - <p> - <%= stages_fields.fields_for i.to_s do |stage_fields| %><fieldset><legend style="color:rgb(221, 145, 37)">Stage <%= i %></legend> - <%= stage_fields.label :scheduling_method %> - <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %> - <%= stage_fields.label :seeding_method %> - <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %> - </fieldset><% end %> - </p> + </p> <% end %> - </fieldset> <% end %> +</fieldset> + + <%= f.fields_for :stages do |stages_fields| %> + <fieldset> + + <legend style="color:rgb(221, 145, 37)">Stages + + </legend> + <label for="num_stages">Number of tournament stages + </label> + <input type="number" name="num_stages" min="1" value="<%= params[:num_stages].to_i %>"> + <%# stage_fields.submit("Set Stages") %> + <% for i in 1..(params[:num_stages].to_i) do %> + <p> + <%= stages_fields.fields_for i.to_s do |stage_fields| %> + <fieldset> + <legend style="color:rgb(221, 145, 37)">Stage <%= i %> + </legend> + <%= stage_fields.label :scheduling_method %> + <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %> + <%= stage_fields.label :seeding_method %> + <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %> + </fieldset> + <% end %> + </p> + <% end %> + </fieldset> + <% end %> <%= f.submit %> - <%# render 'stages' %> - <% end %> <% end %> +<% end %> |