edit_mode 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/Gemfile.lock +6 -5
- data/lib/assets/javascripts/edit_mode/best_in_place.js.coffee +3 -0
- data/lib/assets/javascripts/edit_mode/edit_mode_group.js.coffee +34 -38
- data/lib/assets/javascripts/edit_mode/make_modal.js.coffee +24 -26
- data/lib/assets/javascripts/edit_mode/tool_buttons.js.coffee +3 -3
- data/lib/edit_mode/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e991c6ba65550a2509c7893bbfd55d7a44851ecc
|
4
|
+
data.tar.gz: 0add910a65b79645005eded01a224d3dc893a604
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 631103c22235104b9eb1a383ab6f5d6e597b7c46127ad15396646aeceab7a45ec92aa3603e14cd1dea2c05efec4116237cede0bf9500bbfb79c5e66d83f53326
|
7
|
+
data.tar.gz: f74c522bca1d7074ac97b4e8f9b86fbf0755cd4454ee5da68d09fe42aa5a7f0d9f50e11957bfd4d6f479938d95fa5dcf776efef3bfaf2bcbc600d222a85ebbd3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,7 +9,7 @@ GIT
|
|
9
9
|
PATH
|
10
10
|
remote: .
|
11
11
|
specs:
|
12
|
-
edit_mode (1.0.
|
12
|
+
edit_mode (1.0.2)
|
13
13
|
jquery-rails
|
14
14
|
jquery-turbolinks
|
15
15
|
rails (>= 3.2)
|
@@ -65,7 +65,7 @@ GEM
|
|
65
65
|
coffee-script-source (1.6.3)
|
66
66
|
diff-lcs (1.1.3)
|
67
67
|
erubis (2.7.0)
|
68
|
-
eventmachine (1.0.
|
68
|
+
eventmachine (1.0.7)
|
69
69
|
execjs (2.0.2)
|
70
70
|
faye-websocket (0.4.7)
|
71
71
|
eventmachine (>= 0.12.0)
|
@@ -161,7 +161,7 @@ GEM
|
|
161
161
|
multi_json (~> 1.0)
|
162
162
|
rack (~> 1.0)
|
163
163
|
tilt (~> 1.1, != 1.3.0)
|
164
|
-
sqlite3 (1.3.
|
164
|
+
sqlite3 (1.3.10)
|
165
165
|
therubyracer (0.12.0)
|
166
166
|
libv8 (~> 3.16.14.0)
|
167
167
|
ref
|
@@ -170,7 +170,7 @@ GEM
|
|
170
170
|
treetop (1.4.15)
|
171
171
|
polyglot
|
172
172
|
polyglot (>= 0.3.1)
|
173
|
-
turbolinks (2.5.
|
173
|
+
turbolinks (2.5.3)
|
174
174
|
coffee-rails
|
175
175
|
tzinfo (0.3.38)
|
176
176
|
websocket (1.0.7)
|
@@ -185,6 +185,7 @@ DEPENDENCIES
|
|
185
185
|
capybara (= 1.1.2)
|
186
186
|
coffee-rails
|
187
187
|
edit_mode!
|
188
|
+
eventmachine (>= 1.0.7)
|
188
189
|
execjs
|
189
190
|
guard (= 1.0.1)
|
190
191
|
guard-rspec (= 0.5.5)
|
@@ -200,5 +201,5 @@ DEPENDENCIES
|
|
200
201
|
rspec-mocks
|
201
202
|
rspec-rails (= 2.10.0)
|
202
203
|
sass-rails
|
203
|
-
sqlite3
|
204
|
+
sqlite3 (>= 1.3.10)
|
204
205
|
therubyracer
|
@@ -3,6 +3,7 @@ ready = ->
|
|
3
3
|
jQuery.fn.apply_best_in_place = ->
|
4
4
|
this.best_in_place()
|
5
5
|
.addClass( "editable ")
|
6
|
+
.unbind("edit")
|
6
7
|
.bind( "edit", (e) ->
|
7
8
|
$( this ).data( 'bestInPlaceEditor' ).activate()
|
8
9
|
$( this ).find( "*" ).unbind( 'blur' )
|
@@ -12,10 +13,12 @@ ready = ->
|
|
12
13
|
.bind( 'keyup', keyUpHandler )
|
13
14
|
e.stopPropagation()
|
14
15
|
)
|
16
|
+
.unbind("cancel")
|
15
17
|
.bind( "cancel", (e) ->
|
16
18
|
$( this ).data( 'bestInPlaceEditor' ).abort()
|
17
19
|
e.stopPropagation()
|
18
20
|
)
|
21
|
+
.unbind("save")
|
19
22
|
.bind( "save", (e) ->
|
20
23
|
$( this ).data( 'bestInPlaceEditor' ).update()
|
21
24
|
e.stopPropagation()
|
@@ -1,54 +1,50 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
# The <span class="edit_mode_group"></span> elements receive 'edit', 'save' and 'cancel' events,
|
3
|
+
# when the user clicks the corresponding buttons '.edit_button', '.save_button' or '.cancel_button'.
|
4
|
+
# The edit_mode_group has to pass these events down to the contained .editable elements.
|
3
5
|
|
4
|
-
|
5
|
-
# when the user clicks the corresponding buttons '.edit_button', '.save_button' or '.cancel_button'.
|
6
|
-
# The edit_mode_group has to pass these events down to the contained .editable elements.
|
6
|
+
$( document ).on( "edit", ".edit_mode_group", (e) ->
|
7
7
|
|
8
|
-
$(
|
8
|
+
unless $( this ).hasClass( "currently_in_edit_mode" )
|
9
|
+
$( this ).addClass( "currently_in_edit_mode" )
|
9
10
|
|
10
|
-
|
11
|
-
$( this ).
|
11
|
+
$( $( this ).find( ".editable" ).get().reverse() ).each ->
|
12
|
+
$( this ).trigger( "edit" )
|
12
13
|
|
13
|
-
|
14
|
-
$( this ).trigger( "edit" )
|
14
|
+
)
|
15
15
|
|
16
|
-
|
16
|
+
$( document ).on( "save", ".edit_mode_group", ->
|
17
17
|
|
18
|
-
$(
|
18
|
+
if $( this ).hasClass( "currently_in_edit_mode" )
|
19
|
+
$( this ).removeClass( "currently_in_edit_mode" )
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
edit_mode_group = $( this )
|
22
|
+
button_effect( $( this ).find( ".save_button" ), ->
|
23
|
+
edit_mode_group.find( ".editable" ).trigger( "save" )
|
24
|
+
)
|
22
25
|
|
23
|
-
|
24
|
-
button_effect( $( this ).find( ".save_button" ), ->
|
25
|
-
edit_mode_group.find( ".editable" ).trigger( "save" )
|
26
|
-
)
|
27
|
-
|
28
|
-
)
|
26
|
+
)
|
29
27
|
|
30
|
-
|
28
|
+
$( document ).on( "cancel", ".edit_mode_group", ->
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
if $( this ).hasClass( "currently_in_edit_mode" )
|
31
|
+
$( this ).removeClass( "currently_in_edit_mode" )
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
edit_mode_group.find( ".editable" ).trigger( "cancel" )
|
42
|
-
)
|
43
|
-
|
44
|
-
# if no cancel button exists, just trigger each element's cancel event.
|
45
|
-
else
|
33
|
+
edit_mode_group = $( this )
|
34
|
+
cancel_button = $( this ).find( ".cancel_button" )
|
35
|
+
|
36
|
+
# if there is a cancel button, animate it and then cancel all elements.
|
37
|
+
if cancel_button.size() > 0
|
38
|
+
button_effect( cancel_button, ->
|
46
39
|
edit_mode_group.find( ".editable" ).trigger( "cancel" )
|
40
|
+
)
|
41
|
+
|
42
|
+
# if no cancel button exists, just trigger each element's cancel event.
|
43
|
+
else
|
44
|
+
edit_mode_group.find( ".editable" ).trigger( "cancel" )
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
button_effect = ( button, callback ) ->
|
51
|
-
button.effect( "pulsate", { times: 2 }, "fast", callback )
|
46
|
+
)
|
52
47
|
|
48
|
+
button_effect = ( button, callback ) ->
|
49
|
+
button.effect( "pulsate", { times: 2 }, "fast", callback )
|
53
50
|
|
54
|
-
$(document).ready(ready)
|
@@ -1,31 +1,29 @@
|
|
1
1
|
|
2
|
-
ready = ->
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
# The <span class="edit_mode_group"></span> elements should be modal when in edit mode.
|
4
|
+
# That means that everything else should be greyed out.
|
5
|
+
# If the user clicks on the shaded (grey) area outside, the edit_mode_group is saved.
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
$( document ).on( "edit", ".edit_mode_group", ->
|
8
|
+
if $( document ).find( ".edit-mode-modal" ).size() == 0
|
9
|
+
#unless $( this ).hasClass( "edit-mode-modal" )
|
10
|
+
modal_edit_mode_group = $( this )
|
11
|
+
$( this ).addClass( "edit-mode-modal" )
|
12
|
+
$( "body" ).append( "<div class='edit-mode-modal-bg'></div>" )
|
13
|
+
$( "div.edit-mode-modal-bg" ).hide().fadeIn().click( ->
|
14
|
+
modal_edit_mode_group.trigger( "save" )
|
15
|
+
)
|
16
|
+
)
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
$( document ).on( "save cancel", ".edit_mode_group", ->
|
19
|
+
if $( this ).hasClass( "edit-mode-modal" )
|
20
|
+
unless $( this ).hasClass( "animating" )
|
21
|
+
$( this ).addClass( "animating" )
|
22
|
+
setTimeout( ->
|
23
|
+
$( "div.edit-mode-modal-bg" ).fadeOut( ->
|
24
|
+
$( this ).remove()
|
25
|
+
$( ".edit-mode-modal" ).removeClass( "edit-mode-modal animating" )
|
26
|
+
)
|
27
|
+
, 300 )
|
28
|
+
)
|
30
29
|
|
31
|
-
$(document).ready(ready)
|
@@ -11,15 +11,15 @@ ready = ->
|
|
11
11
|
this.find( ".edit_button" ).addClass( "do_not_show_in_edit_mode editable" )
|
12
12
|
|
13
13
|
# The buttons trigger the correspondig events of the surrounding edit_mode_group.
|
14
|
-
this.
|
14
|
+
this.off("click", ".edit_button").on("click", ".edit_button", (e) ->
|
15
15
|
$( this ).closest( ".edit_mode_group" ).trigger( "edit" )
|
16
16
|
e.preventDefault()
|
17
17
|
)
|
18
|
-
this.
|
18
|
+
this.off("click", ".save_button").on("click", ".save_button", (e) ->
|
19
19
|
$( this ).closest( ".edit_mode_group" ).trigger( "save" )
|
20
20
|
e.preventDefault()
|
21
21
|
)
|
22
|
-
this.
|
22
|
+
this.off("click", ".cancel_button").on("click", ".cancel_button", (e) ->
|
23
23
|
$( this ).closest( ".edit_mode_group" ).trigger( "cancel" )
|
24
24
|
e.preventDefault()
|
25
25
|
)
|
data/lib/edit_mode/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
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: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.4.5
|
240
240
|
signing_key:
|
241
241
|
specification_version: 4
|
242
242
|
summary: Toggle an edit mode on a show view. Think of it as a grouped in-place editing.
|