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.
@@ -0,0 +1,6 @@
1
+ jQuery ->
2
+ jQuery.fn.apply_edit_mode = ->
3
+ this.apply_initial_auto_hide()
4
+ this.apply_show_only_in_edit_mode()
5
+ this.find( ".best_in_place" ).apply_best_in_place()
6
+ return this
@@ -1,24 +1,28 @@
1
-
2
1
  jQuery ->
3
- $( ".best_in_place" ).best_in_place()
4
- .addClass( "editable ")
5
- .bind( "edit", (e) ->
6
- $( this ).data( 'bestInPlaceEditor' ).activate()
7
- $( this ).find( "*" ).unbind( 'blur' )
8
- .unbind( 'click' )
9
- .unbind( 'keyup' )
10
- .unbind( 'submit' )
11
- .bind( 'keyup', keyUpHandler )
12
- e.stopPropagation()
13
- )
14
- .bind( "cancel", (e) ->
15
- $( this ).data( 'bestInPlaceEditor' ).abort()
16
- e.stopPropagation()
17
- )
18
- .bind( "save", (e) ->
19
- $( this ).data( 'bestInPlaceEditor' ).update()
20
- e.stopPropagation()
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
- # The tool buttons and the .show_only_in_edit_mode elements first are hidden via css (in case JavaScript does not work).
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
- # When edit mode is entered, on all included '.editable' elements the 'edit' event is triggered.
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
- # And just the opposite for <span class="do_not_show_in_edit_mode"></span>.
15
- $( ".do_not_show_in_edit_mode" ).live( "edit", ->
16
- $( this ).hide()
17
- ).live( "save cancel", ->
18
- $( this ).show()
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
- # In order to receive these events, the .show_only_in_edit_mode elements have to be .editable as well.
22
- $( ".show_only_in_edit_mode,.do_not_show_in_edit_mode" ).addClass( "editable" )
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()
@@ -1,3 +1,3 @@
1
1
  module EditMode
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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
- #gem 'edit_mode', path: '../'
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.5
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: &74896990 !ruby/object:Gem::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: *74896990
24
+ version_requirements: *69340560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &74896660 !ruby/object:Gem::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: *74896660
35
+ version_requirements: *69338730
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &74896300 !ruby/object:Gem::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: *74896300
46
+ version_requirements: *69334730
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
- requirement: &74895810 !ruby/object:Gem::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: *74895810
57
+ version_requirements: *69334140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &74895390 !ruby/object:Gem::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: *74895390
68
+ version_requirements: *69333320
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &74895040 !ruby/object:Gem::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: *74895040
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