From 32df12ee322bbe07b11758b87599ba192e4515d4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 9 Jul 2014 23:28:37 -0400 Subject: clean up some styles and form stuff Just look at the diff. --- app/assets/stylesheets/bootstrapify.scss | 6 ++-- app/assets/stylesheets/scaffolds.scss | 22 +++++++++++---- app/models/user.rb | 3 +- app/views/alerts/index.html.erb | 2 +- app/views/common/_show_tournament.html.erb | 6 ++-- app/views/games/index.html.erb | 2 +- app/views/simple_captcha/_simple_captcha.erb | 41 ++++------------------------ app/views/teams/index.html.erb | 2 +- app/views/tournaments/show.html.erb | 8 +++--- app/views/users/index.html.erb | 2 +- app/views/users/new.html.erb | 33 +++++++++++++++------- 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 @@ <%= alert.message %> <%= link_to 'Show', alert %> <%= link_to 'Edit', edit_alert_path(alert) %> - <%= link_to 'Destroy', alert, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= button_to 'Destroy', alert, method: :delete, data: { confirm: 'Are you sure?' } %> <% 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 @@
<% 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 %> <%= 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 %> <%= 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 @@ <%= game.scoring_method %> <%= link_to 'Show', game %> <%= link_to 'Edit', edit_game_path(game) %> - <%= link_to 'Destroy', game, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= button_to 'Destroy', game, method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> 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 @@ - - -
-
- <%= simple_captcha_options[:image] %> -
- -
- <%= simple_captcha_options[:field] %> -
- -
- <%= simple_captcha_options[:label] %> -
+
+ + <%= simple_captcha_options[:image] %> + To make sure you aren't a robot. + <%= simple_captcha_options[:field] %>
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 @@ <%= link_to 'Show', team %> <%= link_to 'Edit', edit_team_path(team) %> - <%= link_to 'Destroy', team, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= button_to 'Destroy', team, method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> 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 @@
<%# 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 %> <%= 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 %> <%= 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 %> <%= 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 %>
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 @@ <%= user.user_name %> <%= link_to 'Show', user %> <%= link_to 'Edit', edit_user_path(user) %> - <%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= button_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> 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 %>
- <%= f.label :name %>
- <%= f.text_field :name %> + <%= f.label :user_name %> + + This is the name you will use to log in. + It may consist of letters, numbers, _, and -. + +
+ <%= f.text_field :user_name %>
- <%= f.label :email %>
- <%= f.text_field(:email, type: "email") %> + <%= f.label :password %> + + Must be at least 6 characters long. + +
+ <%= f.password_field(:password, required: :required, minlength: 6) %>
- <%= f.label :user_name %>
- <%= f.text_field :user_name %> + <%= f.label(:password_confirmation, "Confirm Password") %>
+ <%= f.password_field(:password_confirmation, required: :required, minlength: 6) %>
- <%= f.label :password %>
- <%= f.password_field :password %> + <%= f.label :name %> + + A display name; perhaps your real name, or perhaps an alias. + +
+ <%= f.text_field :name %>
- <%= f.label(:password_confirmation, "Confirm Password") %>
- <%= f.password_field :password_confirmation %> + <%= f.label :email %>
+ <%= f.email_field(:email) %>
<%= show_simple_captcha %> -- cgit v1.2.3