crest_in_place 2.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.
Files changed (121) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +13 -0
  4. data/CHANGELOG.md +36 -0
  5. data/Gemfile +9 -0
  6. data/README.md +440 -0
  7. data/Rakefile +8 -0
  8. data/crest_in_place-2.1.0.gem +0 -0
  9. data/crest_in_place.gemspec +28 -0
  10. data/lib/assets/javascripts/best_in_place.js +740 -0
  11. data/lib/assets/javascripts/best_in_place.purr.js +10 -0
  12. data/lib/assets/javascripts/jquery.purr.js +135 -0
  13. data/lib/crest_in_place.rb +12 -0
  14. data/lib/crest_in_place/check_version.rb +8 -0
  15. data/lib/crest_in_place/controller_extensions.rb +28 -0
  16. data/lib/crest_in_place/display_methods.rb +44 -0
  17. data/lib/crest_in_place/engine.rb +8 -0
  18. data/lib/crest_in_place/helper.rb +132 -0
  19. data/lib/crest_in_place/railtie.rb +7 -0
  20. data/lib/crest_in_place/test_helpers.rb +42 -0
  21. data/lib/crest_in_place/utils.rb +21 -0
  22. data/lib/crest_in_place/version.rb +3 -0
  23. data/spec/helpers/best_in_place_spec.rb +429 -0
  24. data/spec/integration/double_init_spec.rb +34 -0
  25. data/spec/integration/js_spec.rb +1041 -0
  26. data/spec/integration/live_spec.rb +40 -0
  27. data/spec/integration/text_area_spec.rb +40 -0
  28. data/spec/spec_helper.rb +26 -0
  29. data/spec/support/retry_on_timeout.rb +10 -0
  30. data/test_app/Gemfile +16 -0
  31. data/test_app/README +256 -0
  32. data/test_app/Rakefile +7 -0
  33. data/test_app/app/assets/images/no.png +0 -0
  34. data/test_app/app/assets/images/red_pen.png +0 -0
  35. data/test_app/app/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  36. data/test_app/app/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  37. data/test_app/app/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
  38. data/test_app/app/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  39. data/test_app/app/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  40. data/test_app/app/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  41. data/test_app/app/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  42. data/test_app/app/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  43. data/test_app/app/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  44. data/test_app/app/assets/images/ui-icons_222222_256x240.png +0 -0
  45. data/test_app/app/assets/images/ui-icons_228ef1_256x240.png +0 -0
  46. data/test_app/app/assets/images/ui-icons_ef8c08_256x240.png +0 -0
  47. data/test_app/app/assets/images/ui-icons_ffd27a_256x240.png +0 -0
  48. data/test_app/app/assets/images/ui-icons_ffffff_256x240.png +0 -0
  49. data/test_app/app/assets/images/yes.png +0 -0
  50. data/test_app/app/assets/javascripts/application.js +35 -0
  51. data/test_app/app/assets/stylesheets/.gitkeep +0 -0
  52. data/test_app/app/assets/stylesheets/jquery-ui-1.8.16.custom.css.erb +357 -0
  53. data/test_app/app/assets/stylesheets/scaffold.css +60 -0
  54. data/test_app/app/assets/stylesheets/style.css.erb +87 -0
  55. data/test_app/app/controllers/admin/users_controller.rb +14 -0
  56. data/test_app/app/controllers/application_controller.rb +3 -0
  57. data/test_app/app/controllers/cuca/cars_controller.rb +16 -0
  58. data/test_app/app/controllers/users_controller.rb +99 -0
  59. data/test_app/app/helpers/application_helper.rb +2 -0
  60. data/test_app/app/helpers/users_helper.rb +29 -0
  61. data/test_app/app/models/cuca/car.rb +5 -0
  62. data/test_app/app/models/user.rb +27 -0
  63. data/test_app/app/views/admin/users/show.html.erb +20 -0
  64. data/test_app/app/views/cuca/cars/show.html.erb +13 -0
  65. data/test_app/app/views/layouts/application.html.erb +14 -0
  66. data/test_app/app/views/users/_form.html.erb +51 -0
  67. data/test_app/app/views/users/double_init.html.erb +72 -0
  68. data/test_app/app/views/users/edit.html.erb +5 -0
  69. data/test_app/app/views/users/email_field.html.erb +1 -0
  70. data/test_app/app/views/users/index.html.erb +25 -0
  71. data/test_app/app/views/users/new.html.erb +5 -0
  72. data/test_app/app/views/users/show.html.erb +141 -0
  73. data/test_app/app/views/users/show_ajax.html.erb +12 -0
  74. data/test_app/config.ru +4 -0
  75. data/test_app/config/application.rb +51 -0
  76. data/test_app/config/boot.rb +13 -0
  77. data/test_app/config/database.yml +22 -0
  78. data/test_app/config/environment.rb +5 -0
  79. data/test_app/config/environments/development.rb +25 -0
  80. data/test_app/config/environments/production.rb +49 -0
  81. data/test_app/config/environments/test.rb +35 -0
  82. data/test_app/config/initializers/backtrace_silencers.rb +7 -0
  83. data/test_app/config/initializers/countries.rb +1 -0
  84. data/test_app/config/initializers/default_date_format.rb +2 -0
  85. data/test_app/config/initializers/inflections.rb +10 -0
  86. data/test_app/config/initializers/mime_types.rb +5 -0
  87. data/test_app/config/initializers/secret_token.rb +7 -0
  88. data/test_app/config/initializers/session_store.rb +8 -0
  89. data/test_app/config/locales/en.yml +5 -0
  90. data/test_app/config/routes.rb +20 -0
  91. data/test_app/db/migrate/20101206205922_create_users.rb +18 -0
  92. data/test_app/db/migrate/20101212170114_add_receive_email_to_user.rb +9 -0
  93. data/test_app/db/migrate/20110115204441_add_description_to_user.rb +9 -0
  94. data/test_app/db/migrate/20111210084202_add_favorite_color_to_users.rb +5 -0
  95. data/test_app/db/migrate/20111210084251_add_favorite_books_to_users.rb +5 -0
  96. data/test_app/db/migrate/20111217215935_add_birth_date_to_users.rb +5 -0
  97. data/test_app/db/migrate/20111224181356_add_money_to_user.rb +5 -0
  98. data/test_app/db/migrate/20120513003308_create_cars.rb +11 -0
  99. data/test_app/db/migrate/20120607172609_add_favorite_movie_to_users.rb +5 -0
  100. data/test_app/db/migrate/20120616170454_add_money_proc_to_users.rb +6 -0
  101. data/test_app/db/migrate/20120620165212_add_height_to_user.rb +5 -0
  102. data/test_app/db/migrate/20130213224102_add_favorite_locale_to_users.rb +5 -0
  103. data/test_app/db/schema.rb +41 -0
  104. data/test_app/db/seeds.rb +19 -0
  105. data/test_app/doc/README_FOR_APP +2 -0
  106. data/test_app/lib/tasks/.gitkeep +0 -0
  107. data/test_app/lib/tasks/cron.rake +7 -0
  108. data/test_app/public/404.html +26 -0
  109. data/test_app/public/422.html +26 -0
  110. data/test_app/public/500.html +26 -0
  111. data/test_app/public/favicon.ico +0 -0
  112. data/test_app/public/robots.txt +5 -0
  113. data/test_app/script/rails +6 -0
  114. data/test_app/test/fixtures/users.yml +17 -0
  115. data/test_app/test/functional/users_controller_test.rb +49 -0
  116. data/test_app/test/performance/browsing_test.rb +9 -0
  117. data/test_app/test/test_helper.rb +13 -0
  118. data/test_app/test/unit/helpers/users_helper_test.rb +4 -0
  119. data/test_app/test/unit/user_test.rb +8 -0
  120. data/test_app/vendor/plugins/.gitkeep +0 -0
  121. metadata +256 -0
@@ -0,0 +1,14 @@
1
+ class Admin::UsersController < ApplicationController
2
+ def show
3
+ @user = User.find params[:id]
4
+ end
5
+
6
+ def update
7
+ @user = User.find(params[:id])
8
+
9
+ respond_to do |format|
10
+ @user.update_attributes(params[:user])
11
+ format.json { respond_with_bip(@user) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,16 @@
1
+ module Cuca
2
+ class CarsController < ApplicationController
3
+ def show
4
+ @car = Car.find params[:id]
5
+ end
6
+
7
+ def update
8
+ @car = Car.find params[:id]
9
+
10
+ respond_to do |format|
11
+ @car.update_attributes params[:cuca_car]
12
+ format.json { respond_with_bip(@car) }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,99 @@
1
+ class UsersController < ApplicationController
2
+ # GET /users
3
+ # GET /users.xml
4
+ def index
5
+ @users = User.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @users }
10
+ end
11
+ end
12
+
13
+ # GET /users/1
14
+ # GET /users/1.xml
15
+ def show
16
+ @user = User.find(params[:id])
17
+ @countries = COUNTRIES.to_a
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.xml { render :xml => @user }
22
+ end
23
+ end
24
+
25
+ def email_field
26
+ @user = User.find(params[:id])
27
+ render :action => :email_field, :layout => false
28
+ end
29
+
30
+ def show_ajax
31
+ @user = User.find(params[:id])
32
+ @countries = COUNTRIES.to_a
33
+ end
34
+
35
+ def double_init
36
+ @user = User.find(params[:id])
37
+ @countries = COUNTRIES.to_a
38
+ end
39
+
40
+ # GET /users/new
41
+ # GET /users/new.xml
42
+ def new
43
+ @user = User.new
44
+
45
+ respond_to do |format|
46
+ format.html # new.html.erb
47
+ format.xml { render :xml => @user }
48
+ end
49
+ end
50
+
51
+ # GET /users/1/edit
52
+ def edit
53
+ @user = User.find(params[:id])
54
+ end
55
+
56
+ # POST /users
57
+ # POST /users.xml
58
+ def create
59
+ @user = User.new(params[:user])
60
+
61
+ respond_to do |format|
62
+ if @user.save
63
+ format.html { redirect_to(@user, :notice => 'User was successfully created.') }
64
+ format.xml { render :xml => @user, :status => :created, :location => @user }
65
+ else
66
+ format.html { render :action => "new" }
67
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # PUT /users/1
73
+ # PUT /users/1.xml
74
+ def update
75
+ @user = User.find(params[:id])
76
+
77
+ respond_to do |format|
78
+ if @user.update_attributes(params[:user])
79
+ format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
80
+ format.json { respond_with_bip(@user) }
81
+ else
82
+ format.html { render :action => "edit" }
83
+ format.json { respond_with_bip(@user) }
84
+ end
85
+ end
86
+ end
87
+
88
+ # DELETE /users/1
89
+ # DELETE /users/1.xml
90
+ def destroy
91
+ @user = User.find(params[:id])
92
+ @user.destroy
93
+
94
+ respond_to do |format|
95
+ format.html { redirect_to(users_url) }
96
+ format.xml { head :ok }
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,29 @@
1
+ #encoding: utf-8
2
+ module UsersHelper
3
+ def height_collection
4
+ [
5
+ %{5' 1"} ,
6
+ %{5' 2"} ,
7
+ %{5' 3"} ,
8
+ %{5' 4"} ,
9
+ %{5' 5"} ,
10
+ %{5' 6"} ,
11
+ %{5' 7"} ,
12
+ %{5' 8"} ,
13
+ %{5' 9"} ,
14
+ %{5' 10"},
15
+ %{5' 11"},
16
+ %{6' 0"} ,
17
+ %{6' 1"} ,
18
+ %{6' 2"} ,
19
+ %{6' 3"} ,
20
+ %{6' 4"} ,
21
+ %{6' 5"} ,
22
+ %{6' 6"}
23
+ ]
24
+ end
25
+
26
+ def bb(value)
27
+ "#{value} €"
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module Cuca
2
+ class Car < ActiveRecord::Base
3
+
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ class User < ActiveRecord::Base
2
+ validates :name,
3
+ :length => { :minimum => 2, :maximum => 24, :message => "has invalid length"},
4
+ :presence => {:message => "can't be blank"}
5
+ validates :last_name,
6
+ :length => { :minimum => 2, :maximum => 50, :message => "has invalid length"},
7
+ :presence => {:message => "can't be blank"}
8
+ validates :address,
9
+ :length => { :minimum => 5, :message => "too short length"},
10
+ :presence => {:message => "can't be blank"}
11
+ validates :email,
12
+ :presence => {:message => "can't be blank"},
13
+ :format => {:with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :message => "has wrong email format"}
14
+ validates :zip, :numericality => true, :length => { :minimum => 5 }
15
+ validates_numericality_of :money, :allow_blank => true
16
+ validates_numericality_of :money_proc, :allow_blank => true
17
+
18
+ alias_attribute :money_custom, :money
19
+
20
+ def address_format
21
+ "<b>addr => [#{address}]</b>".html_safe
22
+ end
23
+
24
+ def markdown_desc
25
+ RDiscount.new(description).to_html.html_safe
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ <p id="notice"><%= notice %></p>
2
+ <div id="user_account">
3
+ <h1>User details</h1>
4
+ <%= link_to "Go back to USERS", users_path %>
5
+ <p style="margin-left:48em">Click to edit</p>
6
+ <table>
7
+ <tr>
8
+ <td id="name">
9
+ <%= best_in_place [:admin, @user], :name %>
10
+ </td>
11
+ </tr>
12
+ <tr>
13
+ <td>Last Name</td>
14
+ <td id="last_name">
15
+ <%= best_in_place [:admin, @user], :last_name, :nil => "Nothing to show" %>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ </div>
20
+
@@ -0,0 +1,13 @@
1
+ <p id="notice"><%= notice %></p>
2
+ <div id="user_account">
3
+ <h1>Car details</h1>
4
+ <p style="margin-left:48em">Click to edit</p>
5
+ <table>
6
+ <tr>
7
+ <td>Model</td>
8
+ <td id="model">
9
+ <%= best_in_place @car, :model %>
10
+ </td>
11
+ </tr>
12
+ </table>
13
+ </div>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Best In Place TEST APP</title>
5
+ <%= stylesheet_link_tag "scaffold", "style", "jquery-ui-1.8.16.custom" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,51 @@
1
+ <%= form_for(@user) do |f| %>
2
+ <% if @user.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @user.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :last_name %><br />
20
+ <%= f.text_field :last_name %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :height %><br />
24
+ <%= f.select :height, height_collection %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :address %><br />
28
+ <%= f.text_field :address %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :email %><br />
32
+ <%= f.text_field :email %>
33
+ </div>
34
+ <div class="field">
35
+ <%= f.label :zip %><br />
36
+ <%= f.text_field :zip %>
37
+ </div>
38
+ <div class="field">
39
+ <%= f.label :country %><br />
40
+ <%=
41
+ f.select :country, COUNTRIES.map {|c|
42
+ v0 = c[0]
43
+ c[0] = c[1]
44
+ c[1] = v0
45
+ c
46
+ }
47
+ %>
48
+ <div class="actions">
49
+ <%= f.submit %>
50
+ </div>
51
+ <% end %>
@@ -0,0 +1,72 @@
1
+ <p>This is a page that initializes best in place two times with testing purposes</p>
2
+ <div id="user_account">
3
+ <h1>User details</h1>
4
+ <%= link_to "Go back to USERS", users_path %>
5
+ <p style="margin-left:48em">Click to edit</p>
6
+ <table>
7
+ <tr>
8
+ <td>Name <a id="editme" href="#">(edit me)</a></td>
9
+ <td id="name">
10
+ <%= best_in_place @user, :name, :type => :input, :activator => "#editme" %>
11
+ </td>
12
+ </tr>
13
+ <tr>
14
+ <td>Last Name</td>
15
+ <td id="last_name">
16
+ <%= best_in_place @user, :last_name, :nil => "Nothing to show", :path => test_respond_with_user_path(@user) %>
17
+ </td>
18
+ </tr>
19
+ <tr>
20
+ <td>Email</td>
21
+ <td id="email">
22
+ <%= best_in_place @user, :email %>
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td>Address</td>
27
+ <td id="address">
28
+ <%= best_in_place @user, :address %>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td>ZIP</td>
33
+ <td id="zip">
34
+ <%= best_in_place @user, :zip %>
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td>Country</td>
39
+ <td id="country">
40
+ <%= best_in_place @user, :country, :type => :select, :collection => @countries %>
41
+ </td>
42
+ </tr>
43
+ <tr>
44
+ <td>Receive newsletter?</td>
45
+ <td id="receive_email">
46
+ <%= best_in_place @user, :receive_email, :type => :checkbox, :collection => ["No thanks", "Yes of course"] %>
47
+ </td>
48
+ </tr>
49
+ <tr>
50
+ <td>User description</td>
51
+ <td id="description">
52
+ <%= best_in_place @user, :description, :type => :textarea, :sanitize => false %>
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td>Alternative Money</td>
57
+ <td id="alt_money">
58
+ <%= best_in_place @user, :money, :display_with => :number_to_currency, :helper_options => {:unit => "€"} %>
59
+ </td>
60
+ </tr>
61
+ </table>
62
+ <br />
63
+ <hr />
64
+
65
+ </div>
66
+
67
+ <%= javascript_tag do %>
68
+ $(document).ready(function() {
69
+ /* Activating Best In Place */
70
+ jQuery(".best_in_place").best_in_place();
71
+ });
72
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1>Edit user</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1 @@
1
+ <%= best_in_place @user, :email %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing users</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th colspan="2">Name</th>
6
+ <th>Last name</th>
7
+ <th>Country</th>
8
+ </tr>
9
+
10
+ <% @users.each do |user| %>
11
+ <tr id="user_<%= user.id %>">
12
+ <td class="name">
13
+ <%= best_in_place user, :name,
14
+ activator: "#edit_#{user.id}",
15
+ display_with: :link_to,
16
+ helper_options: user_path(user) %>
17
+ </td>
18
+ <td><small><a href="#" id="edit_<%= user.id %>">edit</a></small></td>
19
+ <td><%= user.last_name %></td>
20
+ <td><%= COUNTRIES[user.country.to_i] %></td>
21
+ </tr>
22
+ <% end %>
23
+ </table>
24
+
25
+ <br />
@@ -0,0 +1,5 @@
1
+ <h1>New user</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,141 @@
1
+ <p id="notice"><%= notice %></p>
2
+ <div id="user_account">
3
+ <h1>User details</h1>
4
+ <%= link_to "Go back to USERS", users_path %>
5
+ <p style="margin-left:48em">Click to edit</p>
6
+ <table>
7
+ <tr>
8
+ <td>Name <a id="editme" href="#">(edit me)</a></td>
9
+ <td id="name">
10
+ <%= best_in_place @user, :name, :type => :input, :activator => "#editme" %>
11
+ </td>
12
+ </tr>
13
+ <tr>
14
+ <td>Last Name</td>
15
+ <td id="last_name">
16
+ <%= best_in_place @user, :last_name, :nil => "Nothing to show" %>
17
+ </td>
18
+ </tr>
19
+ <tr>
20
+ <td>Height</td>
21
+ <td id="height">
22
+ <%= best_in_place @user, :height, :type => :select, :collection => height_collection.zip(height_collection), :sanitize => false %>
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td>Email</td>
27
+ <td id="email">
28
+ <%= best_in_place @user, :email %>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td>Birth date</td>
33
+ <td id="birth_date">
34
+ <%= best_in_place @user, :birth_date, :type => :date %>
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td>Address</td>
39
+ <td id="address">
40
+ <%= best_in_place @user, :address, :display_as => :address_format %>
41
+ </td>
42
+ </tr>
43
+ <tr>
44
+ <td>ZIP</td>
45
+ <td id="zip">
46
+ <%= best_in_place @user, :zip %>
47
+ </td>
48
+ </tr>
49
+ <tr>
50
+ <td>Country</td>
51
+ <td id="country">
52
+ <%= best_in_place @user, :country, :type => :select, :collection => @countries, :inner_class => :some_class %>
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td>Receive newsletter?</td>
57
+ <td id="receive_email">
58
+ <%= best_in_place @user, :receive_email, :type => :checkbox, :collection => ["No thanks", "Yes of course"] %>
59
+ </td>
60
+ </tr>
61
+ <tr>
62
+ <td>Receive newsletter (image)?</td>
63
+ <td id="receive_email_image">
64
+ <%= best_in_place @user, :receive_email, :type => :checkbox, :collection => [image_tag('no.png'), image_tag('yes.png')] %>
65
+ </td>
66
+ </tr>
67
+ <tr>
68
+ <td>Favorite color</td>
69
+ <td id="favorite_color">
70
+ <%- opts = { :ok_button => 'Do it!', :cancel_button => 'Nope', :ok_button_class => 'custom-submit other-custom-submit', :cancel_button_class => 'custom-cancel other-custom-cancel' } %>
71
+ <%- opts.delete(:ok_button) if params[:suppress_ok_button] %>
72
+ <%- opts[:nil] = "<span class='nil'>Click to add your favorite color</span>" %>
73
+ <%= best_in_place @user, :favorite_color, opts %>
74
+ </td>
75
+ </tr>
76
+ <tr>
77
+ <td>Favorite locale</td>
78
+ <td id="favorite_locale">
79
+ <%= best_in_place @user, :favorite_locale, :nil => "N/A" %>
80
+ </td>
81
+ </tr>
82
+ <tr>
83
+ <td>Favorite books</td>
84
+ <td id="favorite_books">
85
+ <%- opts = { :type => :textarea, :ok_button => 'Save', :cancel_button => 'Cancel' } %>
86
+ <%- opts.delete(:ok_button) if params[:suppress_ok_button] %>
87
+ <%= best_in_place @user, :favorite_books, opts %>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <td>User description</td>
92
+ <td id="description">
93
+ <%= best_in_place @user, :description, :display_as => :markdown_desc, :type => :textarea, :sanitize => false %>
94
+ </td>
95
+ </tr>
96
+ <tr>
97
+ <td>Simple-formatted user description</td>
98
+ <td id="dw_description">
99
+ <%= best_in_place @user, :description, :display_with => :simple_format, :type => :textarea %>
100
+ </td>
101
+ </tr>
102
+ <tr>
103
+ <td>Money</td>
104
+ <td id="money">
105
+ <%= best_in_place @user, :money, :display_with => :number_to_currency %>
106
+ </td>
107
+ </tr>
108
+ <tr>
109
+ <td>Money with proc</td>
110
+ <td id="money_proc">
111
+ <%= best_in_place @user, :money_proc, :display_with => lambda{ |v| v.blank? ? "No money" : number_to_currency(v) } %>
112
+ </td>
113
+ </tr>
114
+ <tr>
115
+ <td>Money with custom helper</td>
116
+ <td id="money_custom">
117
+ <%= best_in_place @user, :money_custom, :display_with => lambda { |x| bb(x) } %>
118
+ </td>
119
+ </tr>
120
+ <tr>
121
+ <td>Favorite Movie</td>
122
+ <td id="favorite_movie">
123
+ <%- opts = { :ok_button => 'Do it!', :cancel_button => 'Nope', :use_confirm => false } %>
124
+ <%- opts.delete(:ok_button) if params[:suppress_ok_button] %>
125
+ <%= best_in_place @user, :favorite_movie, opts %>
126
+ </td>
127
+ </tr>
128
+ </table>
129
+ <br />
130
+ <hr />
131
+ <p>Try the <b>features of Best In Place</b>:</p>
132
+ <ul>
133
+ <li>Try giving wrong email values or too short address, inputs to see server errors.</li>
134
+ <li>Click on newsletter to change a boolean value</li>
135
+ <li>Click on country to change the value in a collection of values</li>
136
+ <li>Use the external handler to change the value of the name</li>
137
+ <li>Try making changes inside inputs or textareas and then press the ESC key to recover the old value</li>
138
+ </ul>
139
+ <p>More information on <a href="http://github.com/bernat/best_in_place">github</a> or <a href="http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/">bernatfarrero.com</a>.</p>
140
+
141
+ </div>