edit_mode 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/.travis.yml +2 -3
- data/Gemfile +1 -0
- data/Gemfile.lock +204 -0
- data/README.md +27 -13
- data/edit_mode.gemspec +2 -1
- data/lib/assets/javascripts/edit_mode/apply_edit_mode.js.coffee +1 -2
- data/lib/assets/javascripts/edit_mode/best_in_place.js.coffee +1 -2
- data/lib/assets/javascripts/edit_mode/edit_mode_group.js.coffee +1 -2
- data/lib/assets/javascripts/edit_mode/initial_auto_hide.js.coffee +1 -2
- data/lib/assets/javascripts/edit_mode/make_modal.js.coffee +1 -2
- data/lib/assets/javascripts/edit_mode/show_only_in_edit_mode.js.coffee +1 -2
- data/lib/assets/javascripts/edit_mode/tool_buttons.js.coffee +1 -2
- data/lib/edit_mode/version.rb +1 -1
- data/spec/integration/buttons_spec.rb +4 -4
- data/test_app/Gemfile +3 -3
- data/test_app/Gemfile.lock +155 -0
- data/test_app/README.md +27 -13
- data/test_app/app/assets/stylesheets/modifications.css.sass +5 -1
- data/test_app/app/helpers/markdown_helper.rb +21 -0
- data/test_app/app/models/user.rb +1 -1
- data/test_app/app/views/users/show.html.erb +11 -0
- data/test_app/db/migrate/20141107180745_add_description_to_users.rb +5 -0
- data/test_app/db/schema.rb +2 -1
- metadata +38 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 991ce0ccecb0a6a2e1fe3c4b89beafd161aefd55
|
4
|
+
data.tar.gz: af088d26b02ae13dcdbcdf9c9177b85cbb01a69f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b5159359661938f826158c56a974fe3c679367ddf15810b99073b37ab71011a65fe12a0957a976f76c61ed33924f68453ec0db6646f290a9652a6aec3707c4
|
7
|
+
data.tar.gz: d252d3d2e97f74953de2c0a54d6df9aa3dd8dac6a19812483a326b770a1594967928ad43de85293d629f056ae215b8500bdae0d9d3827cefb1ca93aaf95e0a15
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
rvm:
|
2
|
-
- 1.
|
3
|
-
- 2.0.0
|
2
|
+
- 2.1.5
|
4
3
|
|
5
4
|
#env: "RAILS_ENV=test DISPLAY=:99.0"
|
6
5
|
|
7
6
|
before_script:
|
8
|
-
- "sh -c 'cd test_app && bundle && bundle exec rake db:drop db:migrate'"
|
7
|
+
- "sh -c 'cd test_app && bundle install && bundle exec rake db:drop db:migrate'"
|
9
8
|
# - "sh -e /etc/init.d/xvfb start"
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/bernat/best_in_place.git
|
3
|
+
revision: df178520bf9ba405baee9528d5dbb630d6ff760c
|
4
|
+
specs:
|
5
|
+
best_in_place (2.1.0)
|
6
|
+
jquery-rails
|
7
|
+
rails (>= 3.1)
|
8
|
+
|
9
|
+
PATH
|
10
|
+
remote: .
|
11
|
+
specs:
|
12
|
+
edit_mode (1.0.1)
|
13
|
+
jquery-rails
|
14
|
+
jquery-turbolinks
|
15
|
+
rails (>= 3.2)
|
16
|
+
|
17
|
+
GEM
|
18
|
+
remote: https://rubygems.org/
|
19
|
+
specs:
|
20
|
+
actionmailer (3.2.15)
|
21
|
+
actionpack (= 3.2.15)
|
22
|
+
mail (~> 2.5.4)
|
23
|
+
actionpack (3.2.15)
|
24
|
+
activemodel (= 3.2.15)
|
25
|
+
activesupport (= 3.2.15)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
erubis (~> 2.7.0)
|
28
|
+
journey (~> 1.0.4)
|
29
|
+
rack (~> 1.4.5)
|
30
|
+
rack-cache (~> 1.2)
|
31
|
+
rack-test (~> 0.6.1)
|
32
|
+
sprockets (~> 2.2.1)
|
33
|
+
activemodel (3.2.15)
|
34
|
+
activesupport (= 3.2.15)
|
35
|
+
builder (~> 3.0.0)
|
36
|
+
activerecord (3.2.15)
|
37
|
+
activemodel (= 3.2.15)
|
38
|
+
activesupport (= 3.2.15)
|
39
|
+
arel (~> 3.0.2)
|
40
|
+
tzinfo (~> 0.3.29)
|
41
|
+
activeresource (3.2.15)
|
42
|
+
activemodel (= 3.2.15)
|
43
|
+
activesupport (= 3.2.15)
|
44
|
+
activesupport (3.2.15)
|
45
|
+
i18n (~> 0.6, >= 0.6.4)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
addressable (2.3.6)
|
48
|
+
arel (3.0.3)
|
49
|
+
builder (3.0.4)
|
50
|
+
capybara (1.1.2)
|
51
|
+
mime-types (>= 1.16)
|
52
|
+
nokogiri (>= 1.3.3)
|
53
|
+
rack (>= 1.0.0)
|
54
|
+
rack-test (>= 0.5.4)
|
55
|
+
selenium-webdriver (~> 2.0)
|
56
|
+
xpath (~> 0.1.4)
|
57
|
+
childprocess (0.3.9)
|
58
|
+
ffi (~> 1.0, >= 1.0.11)
|
59
|
+
coffee-rails (3.2.2)
|
60
|
+
coffee-script (>= 2.2.0)
|
61
|
+
railties (~> 3.2.0)
|
62
|
+
coffee-script (2.2.0)
|
63
|
+
coffee-script-source
|
64
|
+
execjs
|
65
|
+
coffee-script-source (1.6.3)
|
66
|
+
diff-lcs (1.1.3)
|
67
|
+
erubis (2.7.0)
|
68
|
+
eventmachine (1.0.3)
|
69
|
+
execjs (2.0.2)
|
70
|
+
faye-websocket (0.4.7)
|
71
|
+
eventmachine (>= 0.12.0)
|
72
|
+
ffi (1.9.3)
|
73
|
+
guard (1.0.1)
|
74
|
+
ffi (>= 0.5.0)
|
75
|
+
thor (~> 0.14.6)
|
76
|
+
guard-rspec (0.5.5)
|
77
|
+
guard (>= 0.8.4)
|
78
|
+
hike (1.2.3)
|
79
|
+
http_parser.rb (0.5.3)
|
80
|
+
i18n (0.6.5)
|
81
|
+
journey (1.0.4)
|
82
|
+
jquery-rails (3.0.4)
|
83
|
+
railties (>= 3.0, < 5.0)
|
84
|
+
thor (>= 0.14, < 2.0)
|
85
|
+
jquery-turbolinks (2.1.0)
|
86
|
+
railties (>= 3.1.0)
|
87
|
+
turbolinks
|
88
|
+
jquery-ui-rails (4.1.0)
|
89
|
+
railties (>= 3.1.0)
|
90
|
+
json (1.8.1)
|
91
|
+
launchy (2.4.3)
|
92
|
+
addressable (~> 2.3)
|
93
|
+
libv8 (3.16.14.3)
|
94
|
+
mail (2.5.4)
|
95
|
+
mime-types (~> 1.16)
|
96
|
+
treetop (~> 1.4.8)
|
97
|
+
mime-types (1.25.1)
|
98
|
+
mini_portile (0.5.2)
|
99
|
+
multi_json (1.8.2)
|
100
|
+
nokogiri (1.6.0)
|
101
|
+
mini_portile (~> 0.5.0)
|
102
|
+
poltergeist (1.0.3)
|
103
|
+
capybara (~> 1.1)
|
104
|
+
childprocess (~> 0.3)
|
105
|
+
faye-websocket (~> 0.4.4)
|
106
|
+
http_parser.rb (~> 0.5.3)
|
107
|
+
multi_json (~> 1.0)
|
108
|
+
polyglot (0.3.3)
|
109
|
+
rack (1.4.5)
|
110
|
+
rack-cache (1.2)
|
111
|
+
rack (>= 0.4)
|
112
|
+
rack-ssl (1.3.3)
|
113
|
+
rack
|
114
|
+
rack-test (0.6.2)
|
115
|
+
rack (>= 1.0)
|
116
|
+
rails (3.2.15)
|
117
|
+
actionmailer (= 3.2.15)
|
118
|
+
actionpack (= 3.2.15)
|
119
|
+
activerecord (= 3.2.15)
|
120
|
+
activeresource (= 3.2.15)
|
121
|
+
activesupport (= 3.2.15)
|
122
|
+
bundler (~> 1.0)
|
123
|
+
railties (= 3.2.15)
|
124
|
+
railties (3.2.15)
|
125
|
+
actionpack (= 3.2.15)
|
126
|
+
activesupport (= 3.2.15)
|
127
|
+
rack-ssl (~> 1.3.2)
|
128
|
+
rake (>= 0.8.7)
|
129
|
+
rdoc (~> 3.4)
|
130
|
+
thor (>= 0.14.6, < 2.0)
|
131
|
+
rake (10.1.0)
|
132
|
+
rdoc (3.12.2)
|
133
|
+
json (~> 1.4)
|
134
|
+
ref (1.0.5)
|
135
|
+
rspec (2.10.0)
|
136
|
+
rspec-core (~> 2.10.0)
|
137
|
+
rspec-expectations (~> 2.10.0)
|
138
|
+
rspec-mocks (~> 2.10.0)
|
139
|
+
rspec-core (2.10.1)
|
140
|
+
rspec-expectations (2.10.0)
|
141
|
+
diff-lcs (~> 1.1.3)
|
142
|
+
rspec-mocks (2.10.1)
|
143
|
+
rspec-rails (2.10.0)
|
144
|
+
actionpack (>= 3.0)
|
145
|
+
activesupport (>= 3.0)
|
146
|
+
railties (>= 3.0)
|
147
|
+
rspec (~> 2.10.0)
|
148
|
+
rubyzip (1.0.0)
|
149
|
+
sass (3.2.12)
|
150
|
+
sass-rails (3.2.6)
|
151
|
+
railties (~> 3.2.0)
|
152
|
+
sass (>= 3.1.10)
|
153
|
+
tilt (~> 1.3)
|
154
|
+
selenium-webdriver (2.37.0)
|
155
|
+
childprocess (>= 0.2.5)
|
156
|
+
multi_json (~> 1.0)
|
157
|
+
rubyzip (~> 1.0.0)
|
158
|
+
websocket (~> 1.0.4)
|
159
|
+
sprockets (2.2.2)
|
160
|
+
hike (~> 1.2)
|
161
|
+
multi_json (~> 1.0)
|
162
|
+
rack (~> 1.0)
|
163
|
+
tilt (~> 1.1, != 1.3.0)
|
164
|
+
sqlite3 (1.3.8)
|
165
|
+
therubyracer (0.12.0)
|
166
|
+
libv8 (~> 3.16.14.0)
|
167
|
+
ref
|
168
|
+
thor (0.14.6)
|
169
|
+
tilt (1.4.1)
|
170
|
+
treetop (1.4.15)
|
171
|
+
polyglot
|
172
|
+
polyglot (>= 0.3.1)
|
173
|
+
turbolinks (2.5.2)
|
174
|
+
coffee-rails
|
175
|
+
tzinfo (0.3.38)
|
176
|
+
websocket (1.0.7)
|
177
|
+
xpath (0.1.4)
|
178
|
+
nokogiri (~> 1.3)
|
179
|
+
|
180
|
+
PLATFORMS
|
181
|
+
ruby
|
182
|
+
|
183
|
+
DEPENDENCIES
|
184
|
+
best_in_place (>= 2.0.3)!
|
185
|
+
capybara (= 1.1.2)
|
186
|
+
coffee-rails
|
187
|
+
edit_mode!
|
188
|
+
execjs
|
189
|
+
guard (= 1.0.1)
|
190
|
+
guard-rspec (= 0.5.5)
|
191
|
+
jquery-rails (>= 2.2.0)
|
192
|
+
jquery-ui-rails
|
193
|
+
launchy
|
194
|
+
nokogiri
|
195
|
+
poltergeist
|
196
|
+
rake
|
197
|
+
rspec
|
198
|
+
rspec-core
|
199
|
+
rspec-expectations
|
200
|
+
rspec-mocks
|
201
|
+
rspec-rails (= 2.10.0)
|
202
|
+
sass-rails
|
203
|
+
sqlite3
|
204
|
+
therubyracer
|
data/README.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
<img src="https://github.com/fiedl/edit_mode/raw/master/test_app/app/assets/images/screenshot.png" height="300" align="right" vspace="20" hspace="20" />
|
4
4
|
|
5
|
-
*edit_mode* is a *ruby on rails gem* that allows you to toggle an edit mode on a normal show view.
|
6
|
-
Think of it as a grouped in-place editing.
|
5
|
+
*edit_mode* is a *ruby on rails gem* that allows you to toggle an edit mode on a normal show view.
|
6
|
+
Think of it as a grouped in-place editing.
|
7
7
|
This also toggles [best_in_place](https://github.com/bernat/best_in_place) fields.
|
8
8
|
|
9
|
-
The edit mode is activated by pressing an 'edit' button on a show view. This shows additional editing tools
|
10
|
-
and switches on the best_in_place form fields. When editing is finished, use 'save' or 'cancel' buttons to
|
11
|
-
quit the edit mode and return to a normal show view.
|
9
|
+
The edit mode is activated by pressing an 'edit' button on a show view. This shows additional editing tools
|
10
|
+
and switches on the best_in_place form fields. When editing is finished, use 'save' or 'cancel' buttons to
|
11
|
+
quit the edit mode and return to a normal show view.
|
12
12
|
Several editing groups per page are supported. Thus, you can have several 'boxes' to edit on a page.
|
13
13
|
|
14
14
|
## Demo
|
@@ -36,9 +36,12 @@ Or install it yourself as:
|
|
36
36
|
In `app/assets/javascripts/application.js`, add:
|
37
37
|
|
38
38
|
```javascript
|
39
|
+
//= require jquery.turbolinks
|
39
40
|
//= require edit_mode
|
40
41
|
```
|
41
|
-
|
42
|
+
|
43
|
+
If you experience trouble with javascript, check the correct loading order from [the jquery.turbolinks README](https://github.com/kossnocorp/jquery.turbolinks#usage).
|
44
|
+
|
42
45
|
In `app/assets/stylesheets/application.css`, add:
|
43
46
|
|
44
47
|
```css
|
@@ -62,7 +65,7 @@ You can also have several edit_mode_group spans on a page, as shown in the demo
|
|
62
65
|
|
63
66
|
### Tool Buttons
|
64
67
|
|
65
|
-
To enter and exit the edit mode, use buttons 'edit', 'save' and 'cancel'. These can be anchors, images, et cetera. They only have to have the correct css classes:
|
68
|
+
To enter and exit the edit mode, use buttons 'edit', 'save' and 'cancel'. These can be anchors, images, et cetera. They only have to have the correct css classes:
|
66
69
|
|
67
70
|
```html
|
68
71
|
<span class="edit_mode_group">
|
@@ -129,21 +132,35 @@ and triggers.
|
|
129
132
|
|
130
133
|
For example, if you have added a `<span id="my_new_edit_mode_span">...</span>` containing
|
131
134
|
the edit_mode elements using ajax, just call via javascript (jQuery):
|
132
|
-
|
135
|
+
|
133
136
|
```javascript
|
134
137
|
$( "#my_new_edit_mode_span" ).apply_edit_mode()
|
135
|
-
```
|
138
|
+
```
|
136
139
|
|
137
140
|
And if you want to enter edit_mode for this span, call instead:
|
138
|
-
|
141
|
+
|
139
142
|
```javascript
|
140
143
|
$( "#my_new_edit_mode_span" ).apply_edit_mode().trigger( "edit" )
|
141
144
|
```
|
142
145
|
|
146
|
+
### Deactivating the Modal
|
147
|
+
|
148
|
+
If you do not want the edit mode span to get modal when entering the edit mode, have a look at [the solution to issue #2](https://github.com/fiedl/edit_mode/issues/2).
|
149
|
+
|
143
150
|
## Documentation
|
144
151
|
|
145
152
|
http://rubydoc.info/github/fiedl/edit_mode/frames
|
146
153
|
|
154
|
+
## Demo App
|
155
|
+
|
156
|
+
* http://edit-mode-test-app.herokuapp.com/
|
157
|
+
* https://github.com/fiedl/edit_mode/tree/master/test_app
|
158
|
+
* Add heroku remote to git: http://stackoverflow.com/questions/5129598
|
159
|
+
* `brew install heroku-toolbelt`
|
160
|
+
* `heroku keys:add`
|
161
|
+
* `heroku git:remote -a edit-mode-test-app`
|
162
|
+
* Push test app to heroku: `git subtree push --prefix test_app heroku master` or `git push heroku \`git subtree split --prefix test_app master\`:master --force` ([SO](http://stackoverflow.com/a/10648623/2066546))
|
163
|
+
|
147
164
|
## Contributing
|
148
165
|
|
149
166
|
1. Fork it
|
@@ -151,6 +168,3 @@ http://rubydoc.info/github/fiedl/edit_mode/frames
|
|
151
168
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
152
169
|
4. Push to the branch (`git push origin my-new-feature`)
|
153
170
|
5. Create new Pull Request
|
154
|
-
|
155
|
-
|
156
|
-
|
data/edit_mode.gemspec
CHANGED
@@ -23,7 +23,8 @@ Gem::Specification.new do |gem|
|
|
23
23
|
|
24
24
|
gem.add_dependency "rails", ">= 3.2"
|
25
25
|
gem.add_dependency "jquery-rails"
|
26
|
-
|
26
|
+
gem.add_dependency 'jquery-turbolinks'
|
27
|
+
|
27
28
|
gem.add_development_dependency "rake"
|
28
29
|
gem.add_development_dependency "rspec-rails", ">= 2.8.0"
|
29
30
|
gem.add_development_dependency "nokogiri", ">= 1.5.0"
|
data/lib/edit_mode/version.rb
CHANGED
@@ -30,12 +30,12 @@ describe "button behaviour", js: true do
|
|
30
30
|
describe "edit button" do
|
31
31
|
|
32
32
|
it "should be visible outside and invisible in edit mode" do
|
33
|
-
page.should have_selector( ".edit_button", visible: true, count:
|
33
|
+
page.should have_selector( ".edit_button", visible: true, count: 3 )
|
34
34
|
click_on 'edit'
|
35
|
-
page.should have_selector( ".edit_button", visible: true, count: 1 )
|
36
|
-
page.should_not have_selector( ".edit_button", visible: true, count: 2 )
|
37
|
-
click_on 'cancel'
|
38
35
|
page.should have_selector( ".edit_button", visible: true, count: 2 )
|
36
|
+
page.should_not have_selector( ".edit_button", visible: true, count: 3 )
|
37
|
+
click_on 'cancel'
|
38
|
+
page.should have_selector( ".edit_button", visible: true, count: 3 )
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should activate the edit mode" do
|
data/test_app/Gemfile
CHANGED
@@ -39,7 +39,7 @@ end
|
|
39
39
|
# gem 'jbuilder'
|
40
40
|
|
41
41
|
# Use unicorn as the app server
|
42
|
-
|
42
|
+
gem 'unicorn'
|
43
43
|
|
44
44
|
# Deploy with Capistrano
|
45
45
|
# gem 'capistrano'
|
@@ -51,8 +51,8 @@ gem "mocha", :group => :test
|
|
51
51
|
|
52
52
|
# Edit Mode (This is the gem to demonstrate here.)
|
53
53
|
#gem 'edit_mode', git: 'git://github.com/fiedl/edit_mode.git'
|
54
|
-
gem 'edit_mode', path: '../'
|
55
|
-
|
54
|
+
gem 'edit_mode', '>= 1.0.1', path: '../'
|
56
55
|
|
57
56
|
# In-place editing (To show that this gem integrates best_in_place out of the box.)
|
58
57
|
gem 'best_in_place'
|
58
|
+
gem 'redcarpet'
|
@@ -0,0 +1,155 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
edit_mode (1.0.1)
|
5
|
+
jquery-rails
|
6
|
+
jquery-turbolinks
|
7
|
+
rails (>= 3.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (3.2.11)
|
13
|
+
actionpack (= 3.2.11)
|
14
|
+
mail (~> 2.4.4)
|
15
|
+
actionpack (3.2.11)
|
16
|
+
activemodel (= 3.2.11)
|
17
|
+
activesupport (= 3.2.11)
|
18
|
+
builder (~> 3.0.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
journey (~> 1.0.4)
|
21
|
+
rack (~> 1.4.0)
|
22
|
+
rack-cache (~> 1.2)
|
23
|
+
rack-test (~> 0.6.1)
|
24
|
+
sprockets (~> 2.2.1)
|
25
|
+
activemodel (3.2.11)
|
26
|
+
activesupport (= 3.2.11)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
activerecord (3.2.11)
|
29
|
+
activemodel (= 3.2.11)
|
30
|
+
activesupport (= 3.2.11)
|
31
|
+
arel (~> 3.0.2)
|
32
|
+
tzinfo (~> 0.3.29)
|
33
|
+
activeresource (3.2.11)
|
34
|
+
activemodel (= 3.2.11)
|
35
|
+
activesupport (= 3.2.11)
|
36
|
+
activesupport (3.2.11)
|
37
|
+
i18n (~> 0.6)
|
38
|
+
multi_json (~> 1.0)
|
39
|
+
arel (3.0.3)
|
40
|
+
best_in_place (2.1.0)
|
41
|
+
jquery-rails
|
42
|
+
rails (~> 3.1)
|
43
|
+
builder (3.0.4)
|
44
|
+
coffee-rails (3.2.2)
|
45
|
+
coffee-script (>= 2.2.0)
|
46
|
+
railties (~> 3.2.0)
|
47
|
+
coffee-script (2.2.0)
|
48
|
+
coffee-script-source
|
49
|
+
execjs
|
50
|
+
coffee-script-source (1.6.3)
|
51
|
+
erubis (2.7.0)
|
52
|
+
execjs (2.0.2)
|
53
|
+
hike (1.2.3)
|
54
|
+
i18n (0.6.11)
|
55
|
+
journey (1.0.4)
|
56
|
+
jquery-rails (3.1.2)
|
57
|
+
railties (>= 3.0, < 5.0)
|
58
|
+
thor (>= 0.14, < 2.0)
|
59
|
+
jquery-turbolinks (2.1.0)
|
60
|
+
railties (>= 3.1.0)
|
61
|
+
turbolinks
|
62
|
+
jquery-ui-rails (4.1.0)
|
63
|
+
railties (>= 3.1.0)
|
64
|
+
json (1.8.1)
|
65
|
+
kgio (2.9.2)
|
66
|
+
libv8 (3.16.14.3)
|
67
|
+
mail (2.4.4)
|
68
|
+
i18n (>= 0.4.0)
|
69
|
+
mime-types (~> 1.16)
|
70
|
+
treetop (~> 1.4.8)
|
71
|
+
metaclass (0.0.1)
|
72
|
+
mime-types (1.25.1)
|
73
|
+
mocha (0.14.0)
|
74
|
+
metaclass (~> 0.0.1)
|
75
|
+
multi_json (1.10.1)
|
76
|
+
nifty-generators (0.4.6)
|
77
|
+
pg (0.17.0)
|
78
|
+
polyglot (0.3.5)
|
79
|
+
rack (1.4.5)
|
80
|
+
rack-cache (1.2)
|
81
|
+
rack (>= 0.4)
|
82
|
+
rack-ssl (1.3.4)
|
83
|
+
rack
|
84
|
+
rack-test (0.6.2)
|
85
|
+
rack (>= 1.0)
|
86
|
+
rails (3.2.11)
|
87
|
+
actionmailer (= 3.2.11)
|
88
|
+
actionpack (= 3.2.11)
|
89
|
+
activerecord (= 3.2.11)
|
90
|
+
activeresource (= 3.2.11)
|
91
|
+
activesupport (= 3.2.11)
|
92
|
+
bundler (~> 1.0)
|
93
|
+
railties (= 3.2.11)
|
94
|
+
railties (3.2.11)
|
95
|
+
actionpack (= 3.2.11)
|
96
|
+
activesupport (= 3.2.11)
|
97
|
+
rack-ssl (~> 1.3.2)
|
98
|
+
rake (>= 0.8.7)
|
99
|
+
rdoc (~> 3.4)
|
100
|
+
thor (>= 0.14.6, < 2.0)
|
101
|
+
raindrops (0.13.0)
|
102
|
+
rake (10.3.2)
|
103
|
+
rdoc (3.12.2)
|
104
|
+
json (~> 1.4)
|
105
|
+
redcarpet (3.2.0)
|
106
|
+
ref (1.0.5)
|
107
|
+
sass (3.2.12)
|
108
|
+
sass-rails (3.2.6)
|
109
|
+
railties (~> 3.2.0)
|
110
|
+
sass (>= 3.1.10)
|
111
|
+
tilt (~> 1.3)
|
112
|
+
sprockets (2.2.3)
|
113
|
+
hike (~> 1.2)
|
114
|
+
multi_json (~> 1.0)
|
115
|
+
rack (~> 1.0)
|
116
|
+
tilt (~> 1.1, != 1.3.0)
|
117
|
+
sqlite3 (1.3.8)
|
118
|
+
therubyracer (0.12.0)
|
119
|
+
libv8 (~> 3.16.14.0)
|
120
|
+
ref
|
121
|
+
thor (0.19.1)
|
122
|
+
tilt (1.4.1)
|
123
|
+
treetop (1.4.15)
|
124
|
+
polyglot
|
125
|
+
polyglot (>= 0.3.1)
|
126
|
+
turbolinks (2.5.2)
|
127
|
+
coffee-rails
|
128
|
+
tzinfo (0.3.42)
|
129
|
+
uglifier (2.3.1)
|
130
|
+
execjs (>= 0.3.0)
|
131
|
+
json (>= 1.8.0)
|
132
|
+
unicorn (4.8.3)
|
133
|
+
kgio (~> 2.6)
|
134
|
+
rack
|
135
|
+
raindrops (~> 0.7)
|
136
|
+
|
137
|
+
PLATFORMS
|
138
|
+
ruby
|
139
|
+
|
140
|
+
DEPENDENCIES
|
141
|
+
best_in_place
|
142
|
+
coffee-rails (~> 3.2.1)
|
143
|
+
edit_mode (>= 1.0.1)!
|
144
|
+
jquery-rails
|
145
|
+
jquery-ui-rails
|
146
|
+
mocha
|
147
|
+
nifty-generators
|
148
|
+
pg
|
149
|
+
rails (= 3.2.11)
|
150
|
+
redcarpet
|
151
|
+
sass-rails (~> 3.2.3)
|
152
|
+
sqlite3
|
153
|
+
therubyracer
|
154
|
+
uglifier (>= 1.0.3)
|
155
|
+
unicorn
|
data/test_app/README.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
<img src="https://github.com/fiedl/edit_mode/raw/master/test_app/app/assets/images/screenshot.png" height="300" align="right" vspace="20" hspace="20" />
|
4
4
|
|
5
|
-
*edit_mode* is a *ruby on rails gem* that allows you to toggle an edit mode on a normal show view.
|
6
|
-
Think of it as a grouped in-place editing.
|
5
|
+
*edit_mode* is a *ruby on rails gem* that allows you to toggle an edit mode on a normal show view.
|
6
|
+
Think of it as a grouped in-place editing.
|
7
7
|
This also toggles [best_in_place](https://github.com/bernat/best_in_place) fields.
|
8
8
|
|
9
|
-
The edit mode is activated by pressing an 'edit' button on a show view. This shows additional editing tools
|
10
|
-
and switches on the best_in_place form fields. When editing is finished, use 'save' or 'cancel' buttons to
|
11
|
-
quit the edit mode and return to a normal show view.
|
9
|
+
The edit mode is activated by pressing an 'edit' button on a show view. This shows additional editing tools
|
10
|
+
and switches on the best_in_place form fields. When editing is finished, use 'save' or 'cancel' buttons to
|
11
|
+
quit the edit mode and return to a normal show view.
|
12
12
|
Several editing groups per page are supported. Thus, you can have several 'boxes' to edit on a page.
|
13
13
|
|
14
14
|
## Demo
|
@@ -36,9 +36,12 @@ Or install it yourself as:
|
|
36
36
|
In `app/assets/javascripts/application.js`, add:
|
37
37
|
|
38
38
|
```javascript
|
39
|
+
//= require jquery.turbolinks
|
39
40
|
//= require edit_mode
|
40
41
|
```
|
41
|
-
|
42
|
+
|
43
|
+
If you experience trouble with javascript, check the correct loading order from [the jquery.turbolinks README](https://github.com/kossnocorp/jquery.turbolinks#usage).
|
44
|
+
|
42
45
|
In `app/assets/stylesheets/application.css`, add:
|
43
46
|
|
44
47
|
```css
|
@@ -62,7 +65,7 @@ You can also have several edit_mode_group spans on a page, as shown in the demo
|
|
62
65
|
|
63
66
|
### Tool Buttons
|
64
67
|
|
65
|
-
To enter and exit the edit mode, use buttons 'edit', 'save' and 'cancel'. These can be anchors, images, et cetera. They only have to have the correct css classes:
|
68
|
+
To enter and exit the edit mode, use buttons 'edit', 'save' and 'cancel'. These can be anchors, images, et cetera. They only have to have the correct css classes:
|
66
69
|
|
67
70
|
```html
|
68
71
|
<span class="edit_mode_group">
|
@@ -129,21 +132,35 @@ and triggers.
|
|
129
132
|
|
130
133
|
For example, if you have added a `<span id="my_new_edit_mode_span">...</span>` containing
|
131
134
|
the edit_mode elements using ajax, just call via javascript (jQuery):
|
132
|
-
|
135
|
+
|
133
136
|
```javascript
|
134
137
|
$( "#my_new_edit_mode_span" ).apply_edit_mode()
|
135
|
-
```
|
138
|
+
```
|
136
139
|
|
137
140
|
And if you want to enter edit_mode for this span, call instead:
|
138
|
-
|
141
|
+
|
139
142
|
```javascript
|
140
143
|
$( "#my_new_edit_mode_span" ).apply_edit_mode().trigger( "edit" )
|
141
144
|
```
|
142
145
|
|
146
|
+
### Deactivating the Modal
|
147
|
+
|
148
|
+
If you do not want the edit mode span to get modal when entering the edit mode, have a look at [the solution to issue #2](https://github.com/fiedl/edit_mode/issues/2).
|
149
|
+
|
143
150
|
## Documentation
|
144
151
|
|
145
152
|
http://rubydoc.info/github/fiedl/edit_mode/frames
|
146
153
|
|
154
|
+
## Demo App
|
155
|
+
|
156
|
+
* http://edit-mode-test-app.herokuapp.com/
|
157
|
+
* https://github.com/fiedl/edit_mode/tree/master/test_app
|
158
|
+
* Add heroku remote to git: http://stackoverflow.com/questions/5129598
|
159
|
+
* `brew install heroku-toolbelt`
|
160
|
+
* `heroku keys:add`
|
161
|
+
* `heroku git:remote -a edit-mode-test-app`
|
162
|
+
* Push test app to heroku: `git subtree push --prefix test_app heroku master` or `git push heroku \`git subtree split --prefix test_app master\`:master --force` ([SO](http://stackoverflow.com/a/10648623/2066546))
|
163
|
+
|
147
164
|
## Contributing
|
148
165
|
|
149
166
|
1. Fork it
|
@@ -151,6 +168,3 @@ http://rubydoc.info/github/fiedl/edit_mode/frames
|
|
151
168
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
152
169
|
4. Push to the branch (`git push origin my-new-feature`)
|
153
170
|
5. Create new Pull Request
|
154
|
-
|
155
|
-
|
156
|
-
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module MarkdownHelper
|
2
|
+
# This method returns the given markdown code rendered as html.
|
3
|
+
# Have a look at these sources:
|
4
|
+
# * http://railscasts.com/episodes/272-markdown-with-redcarpet
|
5
|
+
# * https://github.com/vmg/redcarpet
|
6
|
+
# * http://daringfireball.net/projects/markdown/syntax
|
7
|
+
#
|
8
|
+
def markdown(text, options = nil)
|
9
|
+
options ||= { hard_wrap: true, filter_html: true, autolink: true, no_intraemphasis: true, fenced_code: true, gh_blockcode: true }
|
10
|
+
Redcarpet::Markdown.new(Redcarpet::Render::HTML, options).render(sanitize(text) || "").html_safe
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# In order to use the markdown helper method with best_in_place's :display_with argument,
|
15
|
+
# the ActionView::Base has to include the markdown method.
|
16
|
+
#
|
17
|
+
module ActionView
|
18
|
+
class Base
|
19
|
+
include MarkdownHelper
|
20
|
+
end
|
21
|
+
end
|
data/test_app/app/models/user.rb
CHANGED
@@ -26,6 +26,17 @@
|
|
26
26
|
</p>
|
27
27
|
</div>
|
28
28
|
|
29
|
+
<div class="edit_mode_group">
|
30
|
+
<span class="edit_mode_tools">
|
31
|
+
<a class="edit_button" href="#">edit</a>
|
32
|
+
<a class="cancel_button" href="#">cancel</a>
|
33
|
+
<a class="save_button" href="#">save</a>
|
34
|
+
</span>
|
35
|
+
|
36
|
+
<h2>Markdown Description</h2>
|
37
|
+
<%= best_in_place @user, :description, display_with: :markdown, type: :textarea %>
|
38
|
+
</div>
|
39
|
+
|
29
40
|
<div class="edit_mode_group">
|
30
41
|
<span class="edit_mode_tools">
|
31
42
|
<a class="edit_button" href="#">edit</a>
|
data/test_app/db/schema.rb
CHANGED
@@ -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 =>
|
14
|
+
ActiveRecord::Schema.define(:version => 20141107180745) do
|
15
15
|
|
16
16
|
create_table "users", :force => true do |t|
|
17
17
|
t.string "first_name"
|
@@ -19,6 +19,7 @@ ActiveRecord::Schema.define(:version => 20120607231941) do
|
|
19
19
|
t.date "date_of_birth"
|
20
20
|
t.datetime "created_at", :null => false
|
21
21
|
t.datetime "updated_at", :null => false
|
22
|
+
t.text "description"
|
22
23
|
end
|
23
24
|
|
24
25
|
end
|
metadata
CHANGED
@@ -1,97 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edit_mode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Fiedlschuster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jquery-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jquery-turbolinks
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec-rails
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: 2.8.0
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 2.8.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: nokogiri
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: 1.5.0
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: 1.5.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: capybara
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
description: The edit mode is activated by pressing an 'edit' button on a show view.
|
@@ -105,10 +119,11 @@ executables: []
|
|
105
119
|
extensions: []
|
106
120
|
extra_rdoc_files: []
|
107
121
|
files:
|
108
|
-
- .gitignore
|
109
|
-
- .rspec
|
110
|
-
- .travis.yml
|
122
|
+
- ".gitignore"
|
123
|
+
- ".rspec"
|
124
|
+
- ".travis.yml"
|
111
125
|
- Gemfile
|
126
|
+
- Gemfile.lock
|
112
127
|
- Guardfile
|
113
128
|
- LICENSE
|
114
129
|
- README.md
|
@@ -137,6 +152,7 @@ files:
|
|
137
152
|
- spec/spec_helper.rb
|
138
153
|
- test_app/.gitignore
|
139
154
|
- test_app/Gemfile
|
155
|
+
- test_app/Gemfile.lock
|
140
156
|
- test_app/README.md
|
141
157
|
- test_app/Rakefile
|
142
158
|
- test_app/app/assets/images/rails.png
|
@@ -153,6 +169,7 @@ files:
|
|
153
169
|
- test_app/app/helpers/application_helper.rb
|
154
170
|
- test_app/app/helpers/error_messages_helper.rb
|
155
171
|
- test_app/app/helpers/layout_helper.rb
|
172
|
+
- test_app/app/helpers/markdown_helper.rb
|
156
173
|
- test_app/app/helpers/users_helper.rb
|
157
174
|
- test_app/app/mailers/.gitkeep
|
158
175
|
- test_app/app/models/.gitkeep
|
@@ -182,6 +199,7 @@ files:
|
|
182
199
|
- test_app/config/locales/en.yml
|
183
200
|
- test_app/config/routes.rb
|
184
201
|
- test_app/db/migrate/20120607231941_create_users.rb
|
202
|
+
- test_app/db/migrate/20141107180745_add_description_to_users.rb
|
185
203
|
- test_app/db/schema.rb
|
186
204
|
- test_app/db/seeds.rb
|
187
205
|
- test_app/lib/assets/.gitkeep
|
@@ -208,17 +226,17 @@ require_paths:
|
|
208
226
|
- lib
|
209
227
|
required_ruby_version: !ruby/object:Gem::Requirement
|
210
228
|
requirements:
|
211
|
-
- -
|
229
|
+
- - ">="
|
212
230
|
- !ruby/object:Gem::Version
|
213
231
|
version: '0'
|
214
232
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
233
|
requirements:
|
216
|
-
- -
|
234
|
+
- - ">="
|
217
235
|
- !ruby/object:Gem::Version
|
218
236
|
version: '0'
|
219
237
|
requirements: []
|
220
238
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.2.2
|
222
240
|
signing_key:
|
223
241
|
specification_version: 4
|
224
242
|
summary: Toggle an edit mode on a show view. Think of it as a grouped in-place editing.
|