Skip to content
This repository
  • 1 commit
  • 8 files changed
  • 0 comments
  • 1 contributor
2  Gemfile
@@ -14,13 +14,13 @@ gem 'carrierwave'
14 14
 gem 'mini_magick'
15 15
 gem 'fog'
16 16
 gem 'jquery-star-rating-rails'
17  
-gem 'client_side_validations'
18 17
 gem 'forum_monster'
19 18
 gem 'bb-ruby'
20 19
 gem 'koala'
21 20
 gem 'airbrake'
22 21
 gem 'maruku'
23 22
 gem 'simple_form'
  23
+gem 'client_side_validations', '3.2.0.beta.6', :git => 'https://github.com/bcardarella/client_side_validations.git'
24 24
 
25 25
 # le windows
26 26
 platforms :mswin, :mingw do
9  Gemfile.lock
... ...
@@ -1,3 +1,9 @@
  1
+GIT
  2
+  remote: https://github.com/bcardarella/client_side_validations.git
  3
+  revision: a7fcf0cecea15859d647f2205d8c466408062563
  4
+  specs:
  5
+    client_side_validations (3.2.0.beta.6)
  6
+
1 7
 GEM
2 8
   remote: http://rubygems.org/
3 9
   specs:
@@ -65,7 +71,6 @@ GEM
65 71
       activesupport (>= 3.2.0)
66 72
     childprocess (0.3.2)
67 73
       ffi (~> 1.0.6)
68  
-    client_side_validations (3.1.4)
69 74
     coffee-rails (3.2.2)
70 75
       coffee-script (>= 2.2.0)
71 76
       railties (~> 3.2.0)
@@ -264,7 +269,7 @@ DEPENDENCIES
264 269
   capybara
265 270
   carmen
266 271
   carrierwave
267  
-  client_side_validations
  272
+  client_side_validations (= 3.2.0.beta.6)!
268 273
   coffee-rails (~> 3.2.1)
269 274
   eventmachine (= 1.0.0.beta.4.1)
270 275
   factory_girl_rails
1  app/assets/javascripts/application.js
@@ -14,6 +14,7 @@
14 14
 //= require jquery
15 15
 //= require jquery_ujs
16 16
 //= require rails.validations
  17
+//= require rails.validations.simple_form
17 18
 //= require bootstrap
18 19
 //= require fullcalendar
19 20
 //= require_tree ./gmaps4rails
51  app/assets/javascripts/client_validations_custom.mak
... ...
@@ -0,0 +1,51 @@
  1
+(function() {
  2
+  $(document).ready(function() {
  3
+    return $("div.control-group").focusout(function() {
  4
+      if (!$("div.control-group").hasClass("error")) {
  5
+        return $(this).addClass("success");
  6
+      }
  7
+    });
  8
+  });
  9
+}).call(this);
  10
+
  11
+ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = {
  12
+  add: function(element, settings, message) {
  13
+    var errorElement, wrapper;
  14
+
  15
+    settings.wrapper_tag = ".control-group";
  16
+    settings.error_tag = "span";
  17
+    settings.error_class = "help-inline";
  18
+    settings.wrapper_error_class = "error";
  19
+    settings.wrapper_success = "success";
  20
+
  21
+    if (element.data('valid') !== false) {
  22
+      wrapper = element.closest(settings.wrapper_tag);
  23
+      wrapper.removeClass(settings.wrapper_success);
  24
+      wrapper.addClass(settings.wrapper_error_class);
  25
+      errorElement = $("<" + settings.error_tag + "/>", {
  26
+        "class": settings.error_class,
  27
+        text: message
  28
+      });
  29
+      return wrapper.find(".controls").append(errorElement);
  30
+    } else {
  31
+      wrapper = element.closest(settings.wrapper_tag);
  32
+      wrapper.addClass(settings.wrapper_error_class);
  33
+      return element.parent().find("" + settings.error_tag + "." + settings.error_class).text(message);
  34
+    }
  35
+  },
  36
+  remove: function(element, settings) {
  37
+    var errorElement, wrapper;
  38
+
  39
+    settings.wrapper_tag = ".control-group";
  40
+    settings.error_tag = "span";
  41
+    settings.error_class = "help-inline";
  42
+    settings.wrapper_error_class = "error";
  43
+    settings.wrapper_success = "success";
  44
+
  45
+    wrapper = element.closest("" + settings.wrapper_tag + "." + settings.wrapper_error_class);
  46
+    wrapper.removeClass(settings.wrapper_error_class);
  47
+    wrapper.addClass(settings.wrapper_success);
  48
+    errorElement = wrapper.find("" + settings.error_tag + "." + settings.error_class);
  49
+    return errorElement.remove();
  50
+  }
  51
+};
12  app/assets/stylesheets/application.css.scss
@@ -106,4 +106,16 @@ h3 small {
106 106
   width:400px;
107 107
   margin: 10px auto 0 auto;
108 108
   text-align:center;
  109
+}
  110
+
  111
+.simple_form .date .controls select {
  112
+  width: 75px;
  113
+}
  114
+.simple_form .date .controls select:nth-child(2) {
  115
+  width: 100px;
  116
+}
  117
+.simple_form .help-block {
  118
+  margin-top: 5px;
  119
+  color:#999999;
  120
+  font-size: 13px;
109 121
 }
55  app/views/day_homes/show.html.haml
@@ -5,8 +5,6 @@
5 5
   .span12
6 6
     %h2
7 7
       = @day_home.name
8  
-    %h2
9  
-      you've got the right one
10 8
     %p
11 9
       :plain
12 10
         <div class="fb-like" data-href="#{day_home_slug_url(@day_home.slug)}" data-send="false" data-layout="button_count" data-width="55" data-show-faces="false"></div>
@@ -82,49 +80,34 @@
82 80
     #contact-form.modal
83 81
       %h3
84 82
         Contact #{@day_home.name}
85  
-      = simple_form_for @day_home_contact, :url => contact_day_home_path(@day_home), :validate => true do |cf|
86  
-        - if @day_home_contact.errors.any?
87  
-          %div#errorExplanation
88  
-            %h2
89  
-              = pluralize(@user.errors.count, "error")
90  
-              prohibited this user from being saved: 
91  
-            %ul
92  
-              -@user.errors.full_messages.each do |msg|
93  
-                %li
94  
-                  = msg          
95  
-            </ul>  
96  
-          </div>  
  83
+      = simple_form_for @day_home_contact, :url => contact_day_home_path(@day_home),:validate=>true do |cf|            
97 84
         .span4.well
98 85
           = cf.input :name, :label=>"Your name"
99 86
           = cf.input :email, :label=>"Your email"
100 87
           = cf.input :phone, :label=>"Your phone"          
101 88
 
102  
-        .span4.well.form-horizontal
103  
-          = cf.label "Child's name:"
104  
-          = cf.text_field :email, :class => "required"
105  
-
106  
-          = cf.label "Child's Birthday"
107  
-          = cf.text_field :email, :class => "required"
108  
-          = cf.text_field :email, :class => "required"
109  
-
110  
-          = cf.label "Start Date"
111  
-          = cf.text_field :email, :class => "required"        
112  
-          
113  
-          = cf.label "Your address (optional):"
114  
-          = cf.text_field :email
115  
-                  
116  
-        .span9
117  
-          = cf.label "Regarding:"
118  
-          = cf.text_field :subject
  89
+        .span4.well
  90
+          = cf.input :child_name, :label =>"Child's name"
  91
+          = cf.input :child_birth_date, :discard_day => true                             
  92
+          = cf.input :child_start_date, :label=>"Desired Start Date"
119 93
           
120  
-          .remember
121  
-            = cf.label "Message:"
  94
+          = cf.input :home_address, :label=>false do             
  95
+            =cf.label :home_address, :style => 'display:inline;'
  96
+            %i.icon-info-sign{:rel=>"tooltip", :title=> "If you are contacting a licensed dayhome, this helps the agency find other options if this one won't work." }
  97
+            =cf.text_field :home_address
  98
+            
  99
+        .span9.remember
  100
+          = cf.input :subject,:label=>"Regarding" 
  101
+          = cf.error :subject, :id => 'subject_error'
  102
+
  103
+          = cf.input :message, :label=>false do
  104
+            =cf.label :message, :label=>"Message", :style => 'display:inline;'
122 105
             %i.icon-info-sign{:rel=>"tooltip", :title=> "Make sure to include contact information in your message!" }
123  
-          = cf.text_area :message, :style => 'height: 150px !important;'
124  
-
  106
+            = cf.text_area :message, :style => 'height: 150px !important;'
  107
+            
125 108
         = cf.hidden_field :day_home_email, :value => @day_home_contact.day_home_email
126 109
         .submit
127  
-          = cf.submit "Contact", :class => 'btn btn-primary span3'
  110
+          = cf.button :submit,  "Contact", :class => 'btn btn-primary span3'
128 111
   .span4
129 112
     = link_to 'Contact Dayhome', '#contact-form', :rel => 'modal:open', :class => "callToActionButton gradient"
130 113
 .row
12  db/migrate/20120905171055_add_properties_to_day_home_contact.rb
... ...
@@ -0,0 +1,12 @@
  1
+class AddPropertiesToDayHomeContact < ActiveRecord::Migration
  2
+  def change
  3
+    add_column :day_home_contacts, :child_name, :string
  4
+
  5
+    add_column :day_home_contacts, :child_birth_date, :date
  6
+
  7
+    add_column :day_home_contacts, :child_start_date, :date
  8
+
  9
+    add_column :day_home_contacts, :home_address, :string
  10
+
  11
+  end
  12
+end
10  db/schema.rb
@@ -11,7 +11,7 @@
11 11
 #
12 12
 # It's strongly recommended to check this file into your version control system.
13 13
 
14  
-ActiveRecord::Schema.define(:version => 20120803195020) do
  14
+ActiveRecord::Schema.define(:version => 20120905171055) do
15 15
 
16 16
   create_table "availability_types", :force => true do |t|
17 17
     t.string   "kind"
@@ -61,8 +61,12 @@
61 61
     t.string   "subject"
62 62
     t.text     "message"
63 63
     t.integer  "day_home_id"
64  
-    t.datetime "created_at",     :null => false
65  
-    t.datetime "updated_at",     :null => false
  64
+    t.datetime "created_at",       :null => false
  65
+    t.datetime "updated_at",       :null => false
  66
+    t.string   "child_name"
  67
+    t.date     "child_birth_date"
  68
+    t.date     "child_start_date"
  69
+    t.string   "home_address"
66 70
   end
67 71
 
68 72
   add_index "day_home_contacts", ["day_home_id"], :name => "index_day_home_contacts_on_day_home_id"

No commit comments for this range

Something went wrong with that request. Please try again.