edit_mode 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/assets/javascripts/edit_mode/apply_edit_mode.js.coffee +6 -0
- data/lib/assets/javascripts/edit_mode/best_in_place.js.coffee +24 -20
- data/lib/assets/javascripts/edit_mode/initial_auto_hide.js.coffee +9 -4
- data/lib/assets/javascripts/edit_mode/show_only_in_edit_mode.js.coffee +24 -17
- data/lib/edit_mode/version.rb +1 -1
- data/test_app/Gemfile +2 -2
- metadata +14 -13
@@ -1,24 +1,28 @@
|
|
1
|
-
|
2
1
|
jQuery ->
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
2
|
+
|
3
|
+
jQuery.fn.apply_best_in_place = ->
|
4
|
+
this.best_in_place()
|
5
|
+
.addClass( "editable ")
|
6
|
+
.bind( "edit", (e) ->
|
7
|
+
$( this ).data( 'bestInPlaceEditor' ).activate()
|
8
|
+
$( this ).find( "*" ).unbind( 'blur' )
|
9
|
+
.unbind( 'click' )
|
10
|
+
.unbind( 'keyup' )
|
11
|
+
.unbind( 'submit' )
|
12
|
+
.bind( 'keyup', keyUpHandler )
|
13
|
+
e.stopPropagation()
|
14
|
+
)
|
15
|
+
.bind( "cancel", (e) ->
|
16
|
+
$( this ).data( 'bestInPlaceEditor' ).abort()
|
17
|
+
e.stopPropagation()
|
18
|
+
)
|
19
|
+
.bind( "save", (e) ->
|
20
|
+
$( this ).data( 'bestInPlaceEditor' ).update()
|
21
|
+
e.stopPropagation()
|
22
|
+
)
|
23
|
+
return this
|
24
|
+
|
25
|
+
$( ".best_in_place" ).apply_best_in_place()
|
22
26
|
|
23
27
|
keyUpHandler = (event) ->
|
24
28
|
if event.keyCode == 27
|
@@ -1,8 +1,13 @@
|
|
1
1
|
|
2
2
|
jQuery ->
|
3
3
|
|
4
|
-
|
5
|
-
# In order to use .hide() and .show() of jQuery, we need to restore the display css property
|
6
|
-
# and hide the elements via jQuery.
|
7
|
-
$( ".save_button,.cancel_button,.show_only_in_edit_mode" ).css( "visibility", "visible" ).hide()
|
4
|
+
jQuery.fn.apply_initial_auto_hide = ->
|
8
5
|
|
6
|
+
# The tool buttons and the .show_only_in_edit_mode elements first are hidden via css (in case JavaScript does not work).
|
7
|
+
# In order to use .hide() and .show() of jQuery, we need to restore the display css property
|
8
|
+
# and hide the elements via jQuery.
|
9
|
+
this.find( ".save_button,.cancel_button,.show_only_in_edit_mode" ).css( "visibility", "visible" ).hide()
|
10
|
+
|
11
|
+
return this
|
12
|
+
|
13
|
+
$( document ).apply_initial_auto_hide()
|
@@ -1,22 +1,29 @@
|
|
1
1
|
|
2
2
|
jQuery ->
|
3
3
|
|
4
|
-
|
5
|
-
# When edit mode is left, the events 'save' or 'cancel' are triggered.
|
6
|
-
# For <span class="show_only_in_edit_mode"></span> tags, these events are rather simple:
|
7
|
-
# Just show or hide these spans!
|
8
|
-
$( ".show_only_in_edit_mode" ).live( "edit", ->
|
9
|
-
$( this ).show()
|
10
|
-
).live( "save cancel", ->
|
11
|
-
$( this ).hide()
|
12
|
-
)
|
4
|
+
jQuery.fn.apply_show_only_in_edit_mode = ->
|
13
5
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
# When edit mode is entered, on all included '.editable' elements the 'edit' event is triggered.
|
7
|
+
# When edit mode is left, the events 'save' or 'cancel' are triggered.
|
8
|
+
# For <span class="show_only_in_edit_mode"></span> tags, these events are rather simple:
|
9
|
+
# Just show or hide these spans!
|
10
|
+
this.find( ".show_only_in_edit_mode" ).live( "edit", ->
|
11
|
+
$( this ).show()
|
12
|
+
).live( "save cancel", ->
|
13
|
+
$( this ).hide()
|
14
|
+
)
|
20
15
|
|
21
|
-
|
22
|
-
|
16
|
+
# 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", ->
|
18
|
+
$( this ).hide()
|
19
|
+
).live( "save cancel", ->
|
20
|
+
$( this ).show()
|
21
|
+
)
|
22
|
+
|
23
|
+
# In order to receive these events, the .show_only_in_edit_mode elements have to be .editable as well.
|
24
|
+
this.find( ".show_only_in_edit_mode,.do_not_show_in_edit_mode" ).addClass( "editable" )
|
25
|
+
|
26
|
+
return this
|
27
|
+
|
28
|
+
# Apply this to the whole document in the beginning.
|
29
|
+
$( document ).apply_show_only_in_edit_mode()
|
data/lib/edit_mode/version.rb
CHANGED
data/test_app/Gemfile
CHANGED
@@ -50,8 +50,8 @@ end
|
|
50
50
|
gem "mocha", :group => :test
|
51
51
|
|
52
52
|
# Edit Mode (This is the gem to demonstrate here.)
|
53
|
-
gem 'edit_mode', git: 'git://github.com/fiedl/edit_mode.git'
|
54
|
-
|
53
|
+
#gem 'edit_mode', git: 'git://github.com/fiedl/edit_mode.git'
|
54
|
+
gem 'edit_mode', path: '../'
|
55
55
|
|
56
56
|
|
57
57
|
# In-place editing (To show that this gem integrates best_in_place out of the box.)
|
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.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-10-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &69340560 !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: *
|
24
|
+
version_requirements: *69340560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jquery-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &69338730 !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: *
|
35
|
+
version_requirements: *69338730
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &69334730 !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: *
|
46
|
+
version_requirements: *69334730
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &69334140 !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: *
|
57
|
+
version_requirements: *69334140
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: nokogiri
|
60
|
-
requirement: &
|
60
|
+
requirement: &69333320 !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: *
|
68
|
+
version_requirements: *69333320
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: capybara
|
71
|
-
requirement: &
|
71
|
+
requirement: &69332760 !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: *
|
79
|
+
version_requirements: *69332760
|
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
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- Rakefile
|
99
99
|
- edit_mode.gemspec
|
100
100
|
- lib/assets/javascripts/edit_mode.js
|
101
|
+
- lib/assets/javascripts/edit_mode/apply_edit_mode.js.coffee
|
101
102
|
- lib/assets/javascripts/edit_mode/best_in_place.js.coffee
|
102
103
|
- lib/assets/javascripts/edit_mode/best_in_place.js.coffee~
|
103
104
|
- lib/assets/javascripts/edit_mode/edit_mode_group.js.coffee
|