summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-07-09 23:28:37 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-07-09 23:28:37 -0400
commit32df12ee322bbe07b11758b87599ba192e4515d4 (patch)
treedab819ad297338393f768f38384c582e71cf058b
parentcbcd3f3037ba9a66cb15e6ed788334d7b89f9c23 (diff)
clean up some styles and form stuff
Just look at the diff.
-rw-r--r--app/assets/stylesheets/bootstrapify.scss6
-rw-r--r--app/assets/stylesheets/scaffolds.scss22
-rw-r--r--app/models/user.rb3
-rw-r--r--app/views/alerts/index.html.erb2
-rw-r--r--app/views/common/_show_tournament.html.erb6
-rw-r--r--app/views/games/index.html.erb2
-rw-r--r--app/views/simple_captcha/_simple_captcha.erb41
-rw-r--r--app/views/teams/index.html.erb2
-rw-r--r--app/views/tournaments/show.html.erb8
-rw-r--r--app/views/users/index.html.erb2
-rw-r--r--app/views/users/new.html.erb33
11 files changed, 61 insertions, 66 deletions
diff --git a/app/assets/stylesheets/bootstrapify.scss b/app/assets/stylesheets/bootstrapify.scss
index 3ee7314..316847a 100644
--- a/app/assets/stylesheets/bootstrapify.scss
+++ b/app/assets/stylesheets/bootstrapify.scss
@@ -30,7 +30,7 @@
}
button,
-a[role="button"],
+*[role="button"],
input[type="submit"],
input[type="reset"],
input[type="button"] {
@@ -99,10 +99,12 @@ header nav {
form {
.field {
@extend .form-group;
+ .field_with_errors {
+ display: inline !important;
+ }
}
.field_with_errors {
@extend .has-error;
- display: inline;
}
}
diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss
index 08767ce..a223672 100644
--- a/app/assets/stylesheets/scaffolds.scss
+++ b/app/assets/stylesheets/scaffolds.scss
@@ -32,10 +32,12 @@
.simple-input-group {
white-space: nowrap;
display: table;
- .btn, .form-control {
+ span {
display: table-cell;
+ }
+ .btn, .form-control {
+ display: table-cell !important;
&:not(:last-child) {
- float: left;
@include border-right-radius(0);
}
&:not(:first-child) {
@@ -60,13 +62,15 @@
form#search {
- @extend .navbar-right;
- @extend .simple-input-group;
+ @extend .navbar-left;
+ div {
+ @extend .simple-input-group;
+ }
}
#user-actions {
@extend .navbar-btn;
- @extend .navbar-left;
+ @extend .navbar-right;
@extend .simple-input-group;
span {
padding-right: .25em;
@@ -154,10 +158,16 @@ form#search {
}
*/
-form[role="button"] {
+form.button_to, form.button_to div {
display: inline;
}
+div.field span.help-block {
+ float: right;
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
/* Elements *********************************************************/
footer {
diff --git a/app/models/user.rb b/app/models/user.rb
index 46cd532..99761e7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -45,7 +45,8 @@ class User < ActiveRecord::Base
before_save { self.email = email.downcase }
validates(:email,
presence: true,
- format: {with: /\A\S+@\S+\.\S+\z/i},
+ # This regex is taken from http://www.w3.org/TR/html5/forms.html#e-mail-state-%28type=email%29
+ format: {with: /\A[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/},
uniqueness: { case_sensitive: false })
# user_name:string_uniq
diff --git a/app/views/alerts/index.html.erb b/app/views/alerts/index.html.erb
index c978bea..5695486 100644
--- a/app/views/alerts/index.html.erb
+++ b/app/views/alerts/index.html.erb
@@ -19,7 +19,7 @@
<td><%= alert.message %></td>
<td><%= link_to 'Show', alert %></td>
<td><%= link_to 'Edit', edit_alert_path(alert) %></td>
- <td><%= link_to 'Destroy', alert, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= button_to 'Destroy', alert, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
<% else %>
diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb
index 02c70c6..3d4b066 100644
--- a/app/views/common/_show_tournament.html.erb
+++ b/app/views/common/_show_tournament.html.erb
@@ -47,7 +47,7 @@
<div class="col-md-2 col-sm-2 col-xs-2">
<% if signed_in? %>
<% if !target.players.include?(current_user) && target.status == 0 %>
- <%= form_tag(tournament_path(target), method: "put", role: :button) do %>
+ <%= form_tag(tournament_path(target), method: "put", class: :button_to) do %>
<input type="hidden" name="update_action" value="join">
<%= submit_tag("Join")%>
<% end %>
@@ -56,11 +56,11 @@
<% end %>
<% @user_bracket = target.brackets.find_by(user: current_user) %>
<% if target.status == 1 && target.stages.order(:id).first.scheduling_method == "elimination" && target.stages.order(:id).first.matches.order(:id).first.status < 2 && !@user_bracket %>
- <%= form_tag(tournament_brackets_path(target), method: "post", role: :button) do %>
+ <%= form_tag(tournament_brackets_path(target), method: "post", class: :button_to) do %>
<%= submit_tag("Make Bracket") %>
<% end %>
<% elsif @user_bracket && target.status == 4 %>
- <%= form_tag(tournament_bracket_path(@tournament, @bracket), method: 'put', role: :button) do %>
+ <%= form_tag(tournament_bracket_path(@tournament, @bracket), method: 'put', class: :button_to) do %>
<input type="hidden" name="update_action" value="results">
<%= submit_tag("Bracket Results") %>
<% end %>
diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb
index f12253c..5a1a270 100644
--- a/app/views/games/index.html.erb
+++ b/app/views/games/index.html.erb
@@ -28,7 +28,7 @@
<td><%= game.scoring_method %></td>
<td><%= link_to 'Show', game %></td>
<td><%= link_to 'Edit', edit_game_path(game) %></td>
- <td><%= link_to 'Destroy', game, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= button_to 'Destroy', game, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
diff --git a/app/views/simple_captcha/_simple_captcha.erb b/app/views/simple_captcha/_simple_captcha.erb
index 9968910..5e9da76 100644
--- a/app/views/simple_captcha/_simple_captcha.erb
+++ b/app/views/simple_captcha/_simple_captcha.erb
@@ -1,37 +1,6 @@
-<style type="text/CSS">
- .simple_captcha{border: 1px solid #ccc; padding: 5px !important;}
- .simple_captcha,
- .simple_captcha div{display: table;}
- .simple_captcha .simple_captcha_field,
- .simple_captcha .simple_captcha_image{
- border: 1px solid #ccc;
- margin: 0px 0px 2px 0px !important;
- padding: 0px !important;
- }
- .simple_captcha .simple_captcha_image img{
- margin: 0px !important;
- padding: 0px !important;
- width: 110px !important;
- }
- .simple_captcha .simple_captcha_label{font-size: 12px;}
- .simple_captcha .simple_captcha_field input{
- width: 150px !important;
- font-size: 16px;
- border: none;
- background-color: #efefef;
- }
-</style>
-
-<div class='simple_captcha'>
- <div class='simple_captcha_image'>
- <%= simple_captcha_options[:image] %>
- </div>
-
- <div class='simple_captcha_field'>
- <%= simple_captcha_options[:field] %>
- </div>
-
- <div class='simple_captcha_label'>
- <%= simple_captcha_options[:label] %>
- </div>
+<div class="field simple_captcha">
+ <label for="captcha"><%= simple_captcha_options[:label] %></label>
+ <%= simple_captcha_options[:image] %>
+ <span class="help-block">To make sure you aren't a robot.</span>
+ <%= simple_captcha_options[:field] %>
</div>
diff --git a/app/views/teams/index.html.erb b/app/views/teams/index.html.erb
index b077e10..397bfc6 100644
--- a/app/views/teams/index.html.erb
+++ b/app/views/teams/index.html.erb
@@ -14,7 +14,7 @@
<tr>
<td><%= link_to 'Show', team %></td>
<td><%= link_to 'Edit', edit_team_path(team) %></td>
- <td><%= link_to 'Destroy', team, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= button_to 'Destroy', team, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index 8d56f46..55a8f14 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -100,23 +100,23 @@
<div class="actions">
<%# If user can join, and user hasn't joined already, show a join tournment button %>
<% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %>
- <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %>
+ <%= form_tag(tournament_path(@tournament), method: "put", class: :button_to) do %>
<input type="hidden" name="update_action" value="join">
<%= submit_tag("Join Tournament") %>
<% end %>
<% elsif @tournament.players.include?(current_user) %>
- <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %>
+ <%= form_tag(tournament_path(@tournament), method: "put", class: :button_to) do %>
<input type="hidden" name="update_action" value="leave">
<%= submit_tag("Leave Tournament") %>
<% end %>
<% end %>
<%# If user is the host, let them start the tournment %>
<% if @tournament.check_permission(current_user, :edit) %>
- <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %>
+ <%= form_tag(tournament_path(@tournament), method: "put", class: :button_to) do %>
<input type="hidden" name="update_action" value="start">
<%= submit_tag("Start Tournament", disabled: (@tournament.players.count < @tournament.min_players_per_team * @tournament.min_teams_per_match)) %>
<% end %>
<%= link_to 'Edit Tournament', edit_tournament_path(@tournament), role: :button %>
- <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' }, role: :button %>
+ <%= button_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
</div>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index b2d5675..53b37b8 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -45,7 +45,7 @@
<td><%= user.user_name %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
- <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= button_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
index 03041d9..1445a0d 100644
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -26,24 +26,37 @@
<%= form_for @user do |f| %>
<%= render "common/error_messages", :target => @user %>
<div class="field">
- <%= f.label :name %><br>
- <%= f.text_field :name %>
+ <%= f.label :user_name %>
+ <span class="help-block">
+ This is the name you will use to log in.
+ It may consist of letters, numbers, <kbd>_</kbd>, and <kbd>-</kbd>.
+ </span>
+ <br>
+ <%= f.text_field :user_name %>
</div>
<div class="field">
- <%= f.label :email %><br>
- <%= f.text_field(:email, type: "email") %>
+ <%= f.label :password %>
+ <span class="help-block">
+ Must be at least 6 characters long.
+ </span>
+ <br>
+ <%= f.password_field(:password, required: :required, minlength: 6) %>
</div>
<div class="field">
- <%= f.label :user_name %><br>
- <%= f.text_field :user_name %>
+ <%= f.label(:password_confirmation, "Confirm Password") %><br>
+ <%= f.password_field(:password_confirmation, required: :required, minlength: 6) %>
</div>
<div class="field">
- <%= f.label :password %><br>
- <%= f.password_field :password %>
+ <%= f.label :name %>
+ <span class="help-block">
+ A display name; perhaps your real name, or perhaps an alias.
+ </span>
+ <br>
+ <%= f.text_field :name %>
</div>
<div class="field">
- <%= f.label(:password_confirmation, "Confirm Password") %><br>
- <%= f.password_field :password_confirmation %>
+ <%= f.label :email %><br>
+ <%= f.email_field(:email) %>
</div>
<div class="field">
<%= show_simple_captcha %>