best_in_place 0.2.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/Gemfile +1 -0
- data/best_in_place.gemspec +2 -1
- data/{test_app/public → lib/assets}/javascripts/best_in_place.js +1 -3
- data/{public → lib/assets}/javascripts/jquery.purr.js +0 -0
- data/lib/best_in_place.rb +1 -3
- data/lib/best_in_place/engine.rb +7 -0
- data/lib/best_in_place/helper.rb +1 -2
- data/lib/best_in_place/test_helpers.rb +8 -21
- data/lib/best_in_place/version.rb +1 -1
- data/spec/helpers/best_in_place_spec.rb +2 -12
- data/spec/integration/double_init_spec.rb +2 -2
- data/spec/integration/js_spec.rb +12 -12
- data/test_app/Gemfile +10 -3
- data/test_app/{public → app/assets}/images/red_pen.png +0 -0
- data/test_app/{public → app/assets}/javascripts/application.js +3 -2
- data/test_app/{public → app/assets}/stylesheets/.gitkeep +0 -0
- data/test_app/{public → app/assets}/stylesheets/scaffold.css +0 -0
- data/test_app/{public → app/assets}/stylesheets/style.css +0 -0
- data/test_app/app/views/layouts/application.html.erb +1 -1
- data/test_app/config/application.rb +12 -3
- metadata +32 -29
- data/lib/best_in_place/utils.rb +0 -15
- data/lib/generators/best_in_place/setup_generator.rb +0 -11
- data/public/javascripts/best_in_place.js +0 -481
- data/public/javascripts/jquery-1.4.4.js +0 -7179
- data/spec/integration/text_area_spec.rb +0 -30
- data/test_app/public/images/rails.png +0 -0
- data/test_app/public/javascripts/jquery-1.4.4.min.js +0 -167
- data/test_app/public/javascripts/jquery.purr.js +0 -161
- data/test_app/public/javascripts/rails.js +0 -148
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/best_in_place.gemspec
CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "rails", "
|
22
|
+
s.add_dependency "rails", "~> 3.1.0"
|
23
|
+
s.add_dependency "jquery-rails"
|
23
24
|
|
24
25
|
s.add_development_dependency "rspec-rails", "~> 2.7.0"
|
25
26
|
s.add_development_dependency "nokogiri", ">= 1.5.0"
|
@@ -339,9 +339,7 @@ BestInPlaceEditor.forms = {
|
|
339
339
|
|
340
340
|
jQuery.fn.best_in_place = function() {
|
341
341
|
this.each(function(){
|
342
|
-
|
343
|
-
jQuery(this).data('bestInPlaceEditor', new BestInPlaceEditor(this));
|
344
|
-
}
|
342
|
+
jQuery(this).data('bestInPlaceEditor', new BestInPlaceEditor(this));
|
345
343
|
});
|
346
344
|
return this;
|
347
345
|
};
|
File without changes
|
data/lib/best_in_place.rb
CHANGED
data/lib/best_in_place/helper.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module BestInPlace
|
2
2
|
module BestInPlaceHelpers
|
3
|
-
|
4
3
|
def best_in_place(object, field, opts = {})
|
5
4
|
opts[:type] ||= :input
|
6
5
|
opts[:collection] ||= []
|
@@ -21,7 +20,7 @@ module BestInPlace
|
|
21
20
|
collection = opts[:collection].to_json
|
22
21
|
end
|
23
22
|
out = "<span class='best_in_place'"
|
24
|
-
out << " id='#{
|
23
|
+
out << " id='best_in_place_#{object.class.to_s.gsub("::", "_").underscore}_#{field}'"
|
25
24
|
out << " data-url='#{opts[:path].blank? ? url_for(object).to_s : url_for(opts[:path])}'"
|
26
25
|
out << " data-object='#{object.class.to_s.gsub("::", "_").underscore}'"
|
27
26
|
out << " data-collection='#{collection}'" unless collection.blank?
|
@@ -1,37 +1,24 @@
|
|
1
1
|
module BestInPlace
|
2
2
|
module TestHelpers
|
3
|
-
|
4
|
-
def bip_area(model, attr, new_value)
|
5
|
-
id = BestInPlace::Utils.build_best_in_place_id model, attr
|
6
|
-
page.execute_script <<-JS
|
7
|
-
$("##{id}").click();
|
8
|
-
$("##{id} form textarea").val('#{new_value}');
|
9
|
-
$("##{id} form textarea").blur();
|
10
|
-
JS
|
11
|
-
end
|
12
|
-
|
13
3
|
def bip_text(model, attr, new_value)
|
14
|
-
id = BestInPlace::Utils.build_best_in_place_id model, attr
|
15
4
|
page.execute_script <<-JS
|
16
|
-
$("
|
17
|
-
$("
|
18
|
-
$("
|
5
|
+
$("#best_in_place_#{model}_#{attr}").click();
|
6
|
+
$("#best_in_place_#{model}_#{attr} input[name='#{attr}']").val('#{new_value}');
|
7
|
+
$("#best_in_place_#{model}_#{attr} form").submit();
|
19
8
|
JS
|
20
9
|
end
|
21
10
|
|
22
11
|
def bip_bool(model, attr)
|
23
|
-
|
24
|
-
page.execute_script("$('##{id}').click();")
|
12
|
+
page.execute_script("$('#best_in_place_#{model}_#{attr}').click();")
|
25
13
|
end
|
26
14
|
|
27
15
|
def bip_select(model, attr, name)
|
28
|
-
id = BestInPlace::Utils.build_best_in_place_id model, attr
|
29
16
|
page.execute_script <<-JS
|
30
17
|
(function() {
|
31
|
-
$("
|
32
|
-
var opt_value = $("
|
33
|
-
$("
|
34
|
-
$("
|
18
|
+
$("#best_in_place_#{model}_#{attr}").click();
|
19
|
+
var opt_value = $("#best_in_place_#{model}_#{attr} select option:contains('#{name}')").attr('value');
|
20
|
+
$("#best_in_place_#{model}_#{attr} select option[value='" + opt_value + "']").attr('selected', true);
|
21
|
+
$("#best_in_place_#{model}_#{attr} select").change();
|
35
22
|
})();
|
36
23
|
JS
|
37
24
|
end
|
@@ -26,18 +26,8 @@ describe BestInPlace::BestInPlaceHelpers do
|
|
26
26
|
@span = nk.css("span")
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
@span.attribute("id").value.should == "best_in_place_user_#{@user.id}_name"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when it's not an AR model" do
|
36
|
-
it "shold generate an html id without any id" do
|
37
|
-
nk = Nokogiri::HTML.parse(helper.best_in_place [1,2,3], :first, :path => @user)
|
38
|
-
span = nk.css("span")
|
39
|
-
span.attribute("id").value.should == "best_in_place_array_first"
|
40
|
-
end
|
29
|
+
it "should have a proper id" do
|
30
|
+
@span.attribute("id").value.should == "best_in_place_user_name"
|
41
31
|
end
|
42
32
|
|
43
33
|
it "should have the best_in_place class" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
|
-
describe "Double initialization bug", :js => true do
|
4
|
+
describe "Double initialization bug", :js => true, :pending => true do
|
5
5
|
before do
|
6
6
|
@user = User.new :name => "Lucia",
|
7
7
|
:last_name => "Napoli",
|
@@ -21,7 +21,7 @@ describe "Double initialization bug", :js => true do
|
|
21
21
|
page.should have_content("No thanks")
|
22
22
|
end
|
23
23
|
|
24
|
-
bip_bool
|
24
|
+
bip_bool :user, :receive_email
|
25
25
|
|
26
26
|
visit double_init_user_path(@user)
|
27
27
|
within("#receive_email") do
|
data/spec/integration/js_spec.rb
CHANGED
@@ -35,14 +35,14 @@ describe "JS behaviour", :js => true do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
it "should be able to use bip_text to update a text field" do
|
38
|
+
it "should be able to use the bip_text to update a text field" do
|
39
39
|
@user.save!
|
40
40
|
visit user_path(@user)
|
41
41
|
within("#email") do
|
42
42
|
page.should have_content("lucianapoli@gmail.com")
|
43
43
|
end
|
44
44
|
|
45
|
-
bip_text
|
45
|
+
bip_text :user, :email, "new@email.com"
|
46
46
|
|
47
47
|
visit user_path(@user)
|
48
48
|
within("#email") do
|
@@ -54,13 +54,13 @@ describe "JS behaviour", :js => true do
|
|
54
54
|
@user.save!
|
55
55
|
visit user_path(@user)
|
56
56
|
|
57
|
-
bip_text
|
57
|
+
bip_text :user, :email, "new@email.com"
|
58
58
|
|
59
59
|
within("#email") do
|
60
60
|
page.should have_content("new@email.com")
|
61
61
|
end
|
62
62
|
|
63
|
-
bip_text
|
63
|
+
bip_text :user, :email, "new_two@email.com"
|
64
64
|
|
65
65
|
within("#email") do
|
66
66
|
page.should have_content("new_two@email.com")
|
@@ -76,10 +76,10 @@ describe "JS behaviour", :js => true do
|
|
76
76
|
@user.save!
|
77
77
|
visit user_path(@user)
|
78
78
|
|
79
|
-
bip_text
|
79
|
+
bip_text :user, :email, "wrong format"
|
80
80
|
page.should have_content("Email has wrong email format")
|
81
81
|
|
82
|
-
bip_text
|
82
|
+
bip_text :user, :email, "another@email.com"
|
83
83
|
within("#email") do
|
84
84
|
page.should have_content("another@email.com")
|
85
85
|
end
|
@@ -97,7 +97,7 @@ describe "JS behaviour", :js => true do
|
|
97
97
|
page.should have_content("Italy")
|
98
98
|
end
|
99
99
|
|
100
|
-
bip_select
|
100
|
+
bip_select :user, :country, "France"
|
101
101
|
|
102
102
|
visit user_path(@user)
|
103
103
|
within("#country") do
|
@@ -113,7 +113,7 @@ describe "JS behaviour", :js => true do
|
|
113
113
|
page.should have_content("No thanks")
|
114
114
|
end
|
115
115
|
|
116
|
-
bip_bool
|
116
|
+
bip_bool :user, :receive_email
|
117
117
|
|
118
118
|
visit user_path(@user)
|
119
119
|
within("#receive_email") do
|
@@ -125,7 +125,7 @@ describe "JS behaviour", :js => true do
|
|
125
125
|
@user.save!
|
126
126
|
visit user_path(@user)
|
127
127
|
|
128
|
-
bip_text
|
128
|
+
bip_text :user, :address, ""
|
129
129
|
page.should have_content("Address can't be blank")
|
130
130
|
within("#address") do
|
131
131
|
page.should have_content("Via Roma 99")
|
@@ -136,7 +136,7 @@ describe "JS behaviour", :js => true do
|
|
136
136
|
@user.save!
|
137
137
|
visit user_path(@user)
|
138
138
|
|
139
|
-
bip_text
|
139
|
+
bip_text :user, :last_name, "a"
|
140
140
|
page.should have_content("last_name has invalid length")
|
141
141
|
end
|
142
142
|
|
@@ -144,13 +144,13 @@ describe "JS behaviour", :js => true do
|
|
144
144
|
@user.save!
|
145
145
|
visit user_path(@user)
|
146
146
|
|
147
|
-
bip_text
|
147
|
+
bip_text :user, :last_name, "a"
|
148
148
|
|
149
149
|
within("#last_name") do
|
150
150
|
page.should have_content("Napoli")
|
151
151
|
end
|
152
152
|
|
153
|
-
bip_text
|
153
|
+
bip_text :user, :last_name, "Another"
|
154
154
|
|
155
155
|
within("#last_name") do
|
156
156
|
page.should have_content("Another")
|
data/test_app/Gemfile
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rails', '~> 3.
|
4
|
-
|
5
|
-
gem 'sqlite3-ruby', :require => 'sqlite3'
|
3
|
+
gem 'rails', '~> 3.1.0'
|
4
|
+
gem 'sqlite3'
|
6
5
|
|
7
6
|
gem 'best_in_place', :path => ".."
|
7
|
+
|
8
|
+
gem 'jquery-rails'
|
9
|
+
|
10
|
+
group :assets do
|
11
|
+
gem 'sass-rails', '~> 3.1.4'
|
12
|
+
gem 'coffee-rails', '~> 3.1.1'
|
13
|
+
gem 'uglifier', '>= 1.0.3'
|
14
|
+
end
|
File without changes
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
//= require jquery
|
2
|
+
//= require best_in_place
|
3
|
+
//= require jquery.purr
|
3
4
|
|
4
5
|
$(document).ready(function() {
|
5
6
|
/* Activating Best In Place */
|
File without changes
|
File without changes
|
File without changes
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<title>Best In Place TEST APP</title>
|
5
5
|
<%= stylesheet_link_tag "scaffold", "style" %>
|
6
|
-
<%= javascript_include_tag "
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
7
|
<%= csrf_meta_tag %>
|
8
8
|
</head>
|
9
9
|
<body>
|
@@ -2,9 +2,12 @@ require File.expand_path('../boot', __FILE__)
|
|
2
2
|
|
3
3
|
require 'rails/all'
|
4
4
|
|
5
|
-
|
6
|
-
# you
|
7
|
-
Bundler.require(
|
5
|
+
if defined?(Bundler)
|
6
|
+
# If you precompile assets before deploying to production, use this line
|
7
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
8
|
+
# If you want your assets lazily compiled in production, use this line
|
9
|
+
# Bundler.require(:default, :assets, Rails.env)
|
10
|
+
end
|
8
11
|
|
9
12
|
module BipApp
|
10
13
|
class Application < Rails::Application
|
@@ -38,5 +41,11 @@ module BipApp
|
|
38
41
|
|
39
42
|
# Configure sensitive parameters which will be filtered from the log file.
|
40
43
|
config.filter_parameters += [:password]
|
44
|
+
|
45
|
+
# Enable the asset pipeline
|
46
|
+
config.assets.enabled = true
|
47
|
+
|
48
|
+
# Version of your assets, change this if you want to expire all your assets
|
49
|
+
config.assets.version = '1.0'
|
41
50
|
end
|
42
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: best_in_place
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2011-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &81861640 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *81861640
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: jquery-rails
|
27
|
+
requirement: &81861380 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
20
31
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
32
|
+
version: '0'
|
22
33
|
type: :runtime
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *81861380
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rspec-rails
|
27
|
-
requirement: &
|
38
|
+
requirement: &81860990 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ~>
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: 2.7.0
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *81860990
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: nokogiri
|
38
|
-
requirement: &
|
49
|
+
requirement: &81860690 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: 1.5.0
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *81860690
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: capybara
|
49
|
-
requirement: &
|
60
|
+
requirement: &81860440 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,7 +65,7 @@ dependencies:
|
|
54
65
|
version: 1.0.1
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *81860440
|
58
69
|
description: BestInPlace is a jQuery script and a Rails 3 helper that provide the
|
59
70
|
method best_in_place to display any object field easily editable for the user by
|
60
71
|
just clicking on it. It supports input data, text data, boolean data and custom
|
@@ -72,24 +83,26 @@ files:
|
|
72
83
|
- README.md
|
73
84
|
- Rakefile
|
74
85
|
- best_in_place.gemspec
|
86
|
+
- lib/assets/javascripts/best_in_place.js
|
87
|
+
- lib/assets/javascripts/jquery.purr.js
|
75
88
|
- lib/best_in_place.rb
|
89
|
+
- lib/best_in_place/engine.rb
|
76
90
|
- lib/best_in_place/helper.rb
|
77
91
|
- lib/best_in_place/test_helpers.rb
|
78
|
-
- lib/best_in_place/utils.rb
|
79
92
|
- lib/best_in_place/version.rb
|
80
|
-
- lib/generators/best_in_place/setup_generator.rb
|
81
|
-
- public/javascripts/best_in_place.js
|
82
|
-
- public/javascripts/jquery-1.4.4.js
|
83
|
-
- public/javascripts/jquery.purr.js
|
84
93
|
- spec/helpers/best_in_place_spec.rb
|
85
94
|
- spec/integration/double_init_spec.rb
|
86
95
|
- spec/integration/js_spec.rb
|
87
|
-
- spec/integration/text_area_spec.rb
|
88
96
|
- spec/spec_helper.rb
|
89
97
|
- test_app/Gemfile
|
90
98
|
- test_app/Gemfile.lock
|
91
99
|
- test_app/README
|
92
100
|
- test_app/Rakefile
|
101
|
+
- test_app/app/assets/images/red_pen.png
|
102
|
+
- test_app/app/assets/javascripts/application.js
|
103
|
+
- test_app/app/assets/stylesheets/.gitkeep
|
104
|
+
- test_app/app/assets/stylesheets/scaffold.css
|
105
|
+
- test_app/app/assets/stylesheets/style.css
|
93
106
|
- test_app/app/controllers/application_controller.rb
|
94
107
|
- test_app/app/controllers/users_controller.rb
|
95
108
|
- test_app/app/helpers/application_helper.rb
|
@@ -129,17 +142,7 @@ files:
|
|
129
142
|
- test_app/public/422.html
|
130
143
|
- test_app/public/500.html
|
131
144
|
- test_app/public/favicon.ico
|
132
|
-
- test_app/public/images/rails.png
|
133
|
-
- test_app/public/images/red_pen.png
|
134
|
-
- test_app/public/javascripts/application.js
|
135
|
-
- test_app/public/javascripts/best_in_place.js
|
136
|
-
- test_app/public/javascripts/jquery-1.4.4.min.js
|
137
|
-
- test_app/public/javascripts/jquery.purr.js
|
138
|
-
- test_app/public/javascripts/rails.js
|
139
145
|
- test_app/public/robots.txt
|
140
|
-
- test_app/public/stylesheets/.gitkeep
|
141
|
-
- test_app/public/stylesheets/scaffold.css
|
142
|
-
- test_app/public/stylesheets/style.css
|
143
146
|
- test_app/script/rails
|
144
147
|
- test_app/test/fixtures/users.yml
|
145
148
|
- test_app/test/functional/users_controller_test.rb
|
@@ -162,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
165
|
version: '0'
|
163
166
|
segments:
|
164
167
|
- 0
|
165
|
-
hash:
|
168
|
+
hash: 151823247
|
166
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
170
|
none: false
|
168
171
|
requirements:
|
@@ -171,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
174
|
version: '0'
|
172
175
|
segments:
|
173
176
|
- 0
|
174
|
-
hash:
|
177
|
+
hash: 151823247
|
175
178
|
requirements: []
|
176
179
|
rubyforge_project: best_in_place
|
177
180
|
rubygems_version: 1.8.10
|