edit_mode 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,21 +9,24 @@ group :test, :development do
9
9
  gem 'rspec-expectations'
10
10
  gem 'rspec-mocks'
11
11
  gem 'nokogiri'
12
- gem 'capybara'
12
+ gem 'capybara', '1.1.2'
13
13
  gem 'execjs'
14
14
  gem 'therubyracer', :platform => :ruby
15
15
 
16
16
  gem 'guard', '1.0.1'
17
17
  gem 'rspec-rails', '2.10.0'
18
18
  gem 'guard-rspec', '0.5.5'
19
-
19
+ # gem 'poltergeist'
20
+ gem 'selenium-webdriver', '>=2.29.0'
21
+ # gem 'capybara-webkit'
20
22
  end
21
23
 
22
24
  group :test do
23
- gem 'best_in_place'
24
25
  gem 'sass-rails'
26
+ # gem 'best_in_place', path: "../best_in_place"
27
+ gem 'best_in_place', '>=2.0.3', git: "https://github.com/bernat/best_in_place.git"
25
28
  end
26
29
 
27
- gem 'jquery-rails'
30
+ gem 'jquery-rails', '>=2.2.0'
28
31
  gem 'coffee-rails'
29
32
  gem 'sqlite3'
data/README.md CHANGED
@@ -121,6 +121,25 @@ jQuery ->
121
121
  )
122
122
  ```
123
123
 
124
+ ### Adding .editable Elements Using Ajax
125
+
126
+ If you would like to add .editable elements (e.g. `.best_in_place` elements or `.show_only_in_edit_mode` elements) using
127
+ ajax, you have to call `apply_edit_mode()` on the newly added elements in order to have them provide the proper methods
128
+ and triggers.
129
+
130
+ For example, if you have added a `<span id="my_new_edit_mode_span">...</span>` containing
131
+ the edit_mode elements using ajax, just call via javascript (jQuery):
132
+
133
+ ```javascript
134
+ $( "#my_new_edit_mode_span" ).apply_edit_mode()
135
+ ```
136
+
137
+ And if you want to enter edit_mode for this span, call instead:
138
+
139
+ ```javascript
140
+ $( "#my_new_edit_mode_span" ).apply_edit_mode().trigger( "edit" )
141
+ ```
142
+
124
143
  ## Documentation
125
144
 
126
145
  http://rubydoc.info/github/fiedl/edit_mode/frames
@@ -7,16 +7,19 @@ jQuery ->
7
7
  # When edit mode is left, the events 'save' or 'cancel' are triggered.
8
8
  # For <span class="show_only_in_edit_mode"></span> tags, these events are rather simple:
9
9
  # Just show or hide these spans!
10
- this.find( ".show_only_in_edit_mode" ).live( "edit", ->
10
+
11
+ this.on( 'edit', '.show_only_in_edit_mode', ->
11
12
  $( this ).show()
12
- ).live( "save cancel", ->
13
+ )
14
+ this.on( 'save cancel', '.show_only_in_edit_mode', ->
13
15
  $( this ).hide()
14
16
  )
15
17
 
16
18
  # And just the opposite for <span class="do_not_show_in_edit_mode"></span>.
17
- this.find( ".do_not_show_in_edit_mode" ).live( "edit", ->
19
+ this.on( 'edit', '.do_not_show_in_edit_mode', ->
18
20
  $( this ).hide()
19
- ).live( "save cancel", ->
21
+ )
22
+ this.on( 'save cancel', '.do_not_show_in_edit_mode', ->
20
23
  $( this ).show()
21
24
  )
22
25
 
@@ -1,3 +1,3 @@
1
1
  module EditMode
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -8,6 +8,25 @@ describe "button behaviour", js: true do
8
8
  visit user_path( @user )
9
9
  end
10
10
 
11
+ describe "javascript requirements: " do
12
+ describe "edit event" do
13
+ describe "on a best_in_place element" do
14
+ it "should show the input field for editing" do
15
+ page.should_not have_selector "input"
16
+ page.execute_script( " $('.best_in_place.editable:first').trigger('edit') " )
17
+ page.should have_selector( "input", count: 1 )
18
+ end
19
+ end
20
+ describe "on an edit_mode_group" do
21
+ it "should show the input fields for all contained best_in_place fields" do
22
+ page.should_not have_selector "input"
23
+ page.execute_script( " $('.edit_mode_group:first').trigger('edit') " )
24
+ page.should have_selector( "input", count: 2 )
25
+ end
26
+ end
27
+ end
28
+ end
29
+
11
30
  describe "edit button" do
12
31
 
13
32
  it "should be visible outside and invisible in edit mode" do
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,14 @@ require File.expand_path('../../test_app/config/environment', __FILE__)
7
7
  require "rspec/rails"
8
8
  require "nokogiri"
9
9
 
10
+ Capybara.javascript_driver = :selenium
11
+ #Capybara.javascript_driver = :webkit
12
+
13
+ # changing back to selenium-webdriver, since phantom js (poltergeist) keeps crashing.
14
+ # SF 2013-01-21
15
+ #require 'capybara/poltergeist'
16
+ #Capybara.javascript_driver = :poltergeist
17
+
10
18
  # Load support files
11
19
  #Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each{|f| require f}
12
20
 
data/test_app/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '3.2.3'
3
+ gem 'rails', '3.2.11'
4
4
 
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
data/test_app/README.md CHANGED
@@ -121,6 +121,25 @@ jQuery ->
121
121
  )
122
122
  ```
123
123
 
124
+ ### Adding .editable Elements Using Ajax
125
+
126
+ If you would like to add .editable elements (e.g. `.best_in_place` elements or `.show_only_in_edit_mode` elements) using
127
+ ajax, you have to call `apply_edit_mode()` on the newly added elements in order to have them provide the proper methods
128
+ and triggers.
129
+
130
+ For example, if you have added a `<span id="my_new_edit_mode_span">...</span>` containing
131
+ the edit_mode elements using ajax, just call via javascript (jQuery):
132
+
133
+ ```javascript
134
+ $( "#my_new_edit_mode_span" ).apply_edit_mode()
135
+ ```
136
+
137
+ And if you want to enter edit_mode for this span, call instead:
138
+
139
+ ```javascript
140
+ $( "#my_new_edit_mode_span" ).apply_edit_mode().trigger( "edit" )
141
+ ```
142
+
124
143
  ## Documentation
125
144
 
126
145
  http://rubydoc.info/github/fiedl/edit_mode/frames
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edit_mode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-02 00:00:00.000000000 Z
12
+ date: 2013-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &69340560 !ruby/object:Gem::Requirement
16
+ requirement: &75473480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *69340560
24
+ version_requirements: *75473480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &69338730 !ruby/object:Gem::Requirement
27
+ requirement: &75473270 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *69338730
35
+ version_requirements: *75473270
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &69334730 !ruby/object:Gem::Requirement
38
+ requirement: &75473040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *69334730
46
+ version_requirements: *75473040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
- requirement: &69334140 !ruby/object:Gem::Requirement
49
+ requirement: &75472790 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.8.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *69334140
57
+ version_requirements: *75472790
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &69333320 !ruby/object:Gem::Requirement
60
+ requirement: &75472540 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.5.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *69333320
68
+ version_requirements: *75472540
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &69332760 !ruby/object:Gem::Requirement
71
+ requirement: &75472350 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *69332760
79
+ version_requirements: *75472350
80
80
  description: The edit mode is activated by pressing an 'edit' button on a show view.
81
81
  This shows additional editing tools and switches on the best_in_place form fields.
82
82
  When editing is finished, use 'save' or 'cancel' buttons to quit the edit mode and