edit_mode 0.0.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdbdd5494cba8ac60e9ad179dcfe022f2f6305d2
4
- data.tar.gz: 722ab2362e8cf8ddf885aaee72c44784d44c7bc5
3
+ metadata.gz: 38c0c37c354fab2e8bb12c74efdd91f35f759403
4
+ data.tar.gz: 389732d6e83c1439e3ecf787555fd1fe31c4ec3d
5
5
  SHA512:
6
- metadata.gz: a75ab16d8ef645d0be48f8e2e1d1dc18bf3fa709dc954bb331de257734ffa650e4a110a768b8893a54b00ff3453f7fc9a713835e7389568e5f2247702016b45c
7
- data.tar.gz: e2a84da960d737cf87685771797453b40e67476fc39c53e9232fbc9c0876152af63df6f5a6b597963f18964625baab380e1d28fbe149ca143d1d4ff693073749
6
+ metadata.gz: acc64b9ac686cdb83ab6e74e941204894fe2c2d34bd82f61aca900c2ed5e3e292f98539e4994d76ebaf52b55e40812277339e076f3feedea51455500cc38a1d6
7
+ data.tar.gz: 480cb272a37d72e89e279200b64cb555c79e860bd5e09e74debeb11d697e53ac7c56b7a91f869339b113dc65e1cbcf359523ddfd11221b2dd7aab82e727d904e
@@ -1,6 +1,7 @@
1
1
  ready = ->
2
2
  jQuery.fn.apply_edit_mode = ->
3
3
  this.apply_initial_auto_hide()
4
+ this.apply_edit_mode_add_button_classes()
4
5
  this.apply_show_only_in_edit_mode()
5
6
  this.find( ".best_in_place" ).apply_best_in_place()
6
7
  return this
@@ -4,15 +4,18 @@ ready = ->
4
4
  # The <span class="edit_mode_group"></span> elements receive 'edit', 'save' and 'cancel' events,
5
5
  # when the user clicks the corresponding buttons '.edit_button', '.save_button' or '.cancel_button'.
6
6
  # The edit_mode_group has to pass these events down to the contained .editable elements.
7
- $( ".edit_mode_group" ).bind( "edit", (e) ->
7
+
8
+ $( document ).on( "edit", ".edit_mode_group", (e) ->
9
+
8
10
  unless $( this ).hasClass( "currently_in_edit_mode" )
9
11
  $( this ).addClass( "currently_in_edit_mode" )
10
12
 
11
13
  $( $( this ).find( ".editable" ).get().reverse() ).each ->
12
14
  $( this ).trigger( "edit" )
15
+
13
16
  )
14
17
 
15
- $( ".edit_mode_group" ).bind( "save", ->
18
+ $( document ).on( "save", ".edit_mode_group", ->
16
19
 
17
20
  if $( this ).hasClass( "currently_in_edit_mode" )
18
21
  $( this ).removeClass( "currently_in_edit_mode" )
@@ -24,15 +27,23 @@ ready = ->
24
27
 
25
28
  )
26
29
 
27
- $( ".edit_mode_group" ).bind( "cancel", ->
30
+ $( document ).on( "cancel", ".edit_mode_group", ->
28
31
 
29
32
  if $( this ).hasClass( "currently_in_edit_mode" )
30
33
  $( this ).removeClass( "currently_in_edit_mode" )
31
34
 
32
35
  edit_mode_group = $( this )
33
- button_effect( $( this ).find( ".cancel_button" ), ->
36
+ cancel_button = $( this ).find( ".cancel_button" )
37
+
38
+ # if there is a cancel button, animate it and then cancel all elements.
39
+ if cancel_button.size() > 0
40
+ button_effect( cancel_button, ->
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
34
46
  edit_mode_group.find( ".editable" ).trigger( "cancel" )
35
- )
36
47
 
37
48
  )
38
49
 
@@ -5,8 +5,9 @@ ready = ->
5
5
  # That means that everything else should be greyed out.
6
6
  # If the user clicks on the shaded (grey) area outside, the edit_mode_group is saved.
7
7
 
8
- $( ".edit_mode_group" ).bind( "edit", ->
9
- unless $( this ).hasClass( "edit-mode-modal" )
8
+ $( document ).on( "edit", ".edit_mode_group", ->
9
+ if $( document ).find( ".edit-mode-modal" ).size() == 0
10
+ #unless $( this ).hasClass( "edit-mode-modal" )
10
11
  modal_edit_mode_group = $( this )
11
12
  $( this ).addClass( "edit-mode-modal" )
12
13
  $( "body" ).append( "<div class='edit-mode-modal-bg'></div>" )
@@ -15,7 +16,7 @@ ready = ->
15
16
  )
16
17
  )
17
18
 
18
- $( ".edit_mode_group" ).bind( "save cancel", ->
19
+ $( document ).on( "save cancel", ".edit_mode_group", ->
19
20
  if $( this ).hasClass( "edit-mode-modal" )
20
21
  unless $( this ).hasClass( "animating" )
21
22
  $( this ).addClass( "animating" )
@@ -1,26 +1,33 @@
1
1
 
2
2
  ready = ->
3
+
4
+ jQuery.fn.apply_edit_mode_add_button_classes = ->
3
5
 
4
- # The 'save' and the 'cancel' button are only to be shown in edit mode.
5
- # In order to receive the proper 'edit', 'save', 'cancel' events, they also have to be .editable.
6
- $( ".save_button,.cancel_button" ).addClass( "show_only_in_edit_mode editable" )
6
+ # The 'save' and the 'cancel' button are only to be shown in edit mode.
7
+ # In order to receive the proper 'edit', 'save', 'cancel' events, they also have to be .editable.
8
+ this.find( ".save_button,.cancel_button" ).addClass( "show_only_in_edit_mode editable" )
9
+
10
+ # The 'edit' button is only to be shown when not in edit mode.
11
+ this.find( ".edit_button" ).addClass( "do_not_show_in_edit_mode editable" )
12
+
13
+ # The buttons trigger the correspondig events of the surrounding edit_mode_group.
14
+ this.on( "click", ".edit_button", (e) ->
15
+ $( this ).closest( ".edit_mode_group" ).trigger( "edit" )
16
+ e.preventDefault()
17
+ )
18
+ this.on( "click", ".save_button", (e) ->
19
+ $( this ).closest( ".edit_mode_group" ).trigger( "save" )
20
+ e.preventDefault()
21
+ )
22
+ this.on( "click", ".cancel_button", (e) ->
23
+ $( this ).closest( ".edit_mode_group" ).trigger( "cancel" )
24
+ e.preventDefault()
25
+ )
7
26
 
8
- # The 'edit' button is only to be shown when not in edit mode.
9
- $( ".edit_button" ).addClass( "do_not_show_in_edit_mode editable" )
27
+ return this
28
+
29
+ $( document ).apply_edit_mode_add_button_classes()
10
30
 
11
- # The buttons trigger the correspondig events of the surrounding edit_mode_group.
12
- $( ".edit_button" ).click ( (e) ->
13
- $( this ).closest( ".edit_mode_group" ).trigger( "edit" )
14
- e.preventDefault()
15
- )
16
- $( ".save_button" ).click( (e) ->
17
- $( this ).closest( ".edit_mode_group" ).trigger( "save" )
18
- e.preventDefault()
19
- )
20
- $( ".cancel_button" ).click( (e) ->
21
- $( this ).closest( ".edit_mode_group" ).trigger( "cancel" )
22
- e.preventDefault()
23
- )
24
31
 
25
32
  $(document).ready(ready)
26
33
  $(document).on('page:load', ready)
@@ -1,3 +1,3 @@
1
1
  module EditMode
2
- VERSION = "0.0.9"
2
+ VERSION = "1.0.0"
3
3
  end
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: 0.0.9
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Fiedlschuster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-26 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -117,7 +117,6 @@ files:
117
117
  - lib/assets/javascripts/edit_mode.js
118
118
  - lib/assets/javascripts/edit_mode/apply_edit_mode.js.coffee
119
119
  - lib/assets/javascripts/edit_mode/best_in_place.js.coffee
120
- - lib/assets/javascripts/edit_mode/best_in_place.js.coffee~
121
120
  - lib/assets/javascripts/edit_mode/edit_mode_group.js.coffee
122
121
  - lib/assets/javascripts/edit_mode/initial_auto_hide.js.coffee
123
122
  - lib/assets/javascripts/edit_mode/make_modal.js.coffee
@@ -219,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
218
  version: '0'
220
219
  requirements: []
221
220
  rubyforge_project:
222
- rubygems_version: 2.0.0
221
+ rubygems_version: 2.0.3
223
222
  signing_key:
224
223
  specification_version: 4
225
224
  summary: Toggle an edit mode on a show view. Think of it as a grouped in-place editing.
@@ -228,4 +227,3 @@ test_files:
228
227
  - spec/integration/buttons_spec.rb
229
228
  - spec/integration/show_only_in_edit_mode_spec.rb
230
229
  - spec/spec_helper.rb
231
- has_rdoc:
@@ -1,26 +0,0 @@
1
-
2
- jQuery ->
3
- $( ".best_in_place" ).best_in_place()
4
- .addClass( "editable ")
5
- .bind( "edit", ->
6
- alert( "activated" )
7
- $( this ).data( 'bestInPlaceEditor' ).activate()
8
- $( this ).find( "*" ).unbind( 'blur' )
9
- .unbind( 'click' )
10
- .unbind( 'keyup' )
11
- .unbind( 'submit' )
12
- .bind( 'keyup', keyUpHandler )
13
- )
14
- .bind( "cancel", ->
15
- $( this ).data( 'bestInPlaceEditor' ).abort()
16
- )
17
- .bind( "save", ->
18
- $( this ).data( 'bestInPlaceEditor' ).update()
19
- )
20
-
21
- keyUpHandler = (event) ->
22
- if event.keyCode == 27
23
- $( this ).closest( ".edit_mode_group" ).trigger( "cancel" )
24
- if event.keyCode == 13
25
- unless $( event.target ).is( "textarea" )
26
- $( this ).closest( ".edit_mode_group" ).trigger( "save" )