ajax_modal_rails 1.0.11 → 1.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ee4e3b7e2d6a4ddb14bd27b3179a0ac68f64550860afaee1f939ccc35742a07
4
- data.tar.gz: 0d2a91587e598c640ccc4c40102e40860bc5cd97e8d7eab94f28e4cb8a239981
3
+ metadata.gz: e66f785e054c0c9f3e9325e9db132040fc6086197b6c59cae71005438ac55333
4
+ data.tar.gz: aa1f2252e4873ab7f72d18ffa0fe38ac05a665a9f76874f969580a8281767a79
5
5
  SHA512:
6
- metadata.gz: 5f08e1b419c1753210b26fb1f88fa98f713885652be567f1d8448333114ddc5d10f2230e8883900d77e2f3e62de251632d4f6723d694bbb78eb502f1ae609755
7
- data.tar.gz: 737aba34c5c95ca942d3b5a6e508e5e779e686ddfffdc4f27d4e098c4dde0d6c65aece28f07668e99dae74b271fc653dc29dbff1c95a029385ce32436613b625
6
+ metadata.gz: b5aff934fb6b38f47f57d26c14f0412c719cc2d3e82413d9d09d0489ac8b527b012aad7257daf394e8a753eff17a87a8b34d6f709b86a57b889700397d8a2631
7
+ data.tar.gz: 8dfef6e192d6c811701c17d6db5a3a63579955e097c76276d52ac6484ce6608c6d3cb8478a311e320ab5c881f52fbcedd8afc19322c272486f623f27afe1ed24
@@ -32,7 +32,6 @@ class window.AjaxModal
32
32
  @open
33
33
 
34
34
  _registerForms: ->
35
- # scope.find(@formTriggersSelector).attr('data-remote', true)
36
35
  $('body').on 'submit', @formTriggersSelector, (event) =>
37
36
  form = event.currentTarget
38
37
  event.preventDefault()
@@ -50,15 +49,13 @@ class window.AjaxModal
50
49
  @open
51
50
  return false
52
51
 
53
-
54
- # $('body').on 'ajax:complete', @formTriggersSelector, (event, data, status, xhr) =>
55
- # @_registerForms @content
56
-
57
- # maybe don't need this for bootstrap
58
52
  _registerClose: ->
59
53
  @modal.on 'click', '[data-ajax-modal-close]', =>
60
- @modal.modal('hide')
61
- @reset()
54
+ @close
55
+
56
+ close: ->
57
+ @modal.modal('hide')
58
+ @reset()
62
59
 
63
60
  open: ->
64
61
  @modal.modal 'show'
@@ -1,6 +1,7 @@
1
1
  module AjaxModalRails::Controller
2
2
  # This module sets up controllers to load their content in a modal
3
- # in response to pjax requests. See pjax-modals.js.coffee for client side details
3
+ # in response to ajax requests. See app/assets/javascripts/ajax_modal_rails/index.cofee
4
+ # for client side details
4
5
  #
5
6
  # calling render will render a template to the modal
6
7
  # and calling redirect_to will trigger a redirect on the underlying page
@@ -9,7 +10,7 @@ module AjaxModalRails::Controller
9
10
  # and forms should have `data-submits-to-pjax-modal`
10
11
 
11
12
  extend ActiveSupport::Concern
12
- HEADER = 'HTTP_X_AJAX_MODAL'
13
+ HEADER = "HTTP_X_AJAX_MODAL"
13
14
 
14
15
  included do
15
16
  layout ->(c) { ajax_modal_request? ? ajax_modal_layout : nil }
@@ -17,27 +18,30 @@ module AjaxModalRails::Controller
17
18
  def redirect_to_with_xhr_redirect(*args)
18
19
  if ajax_modal_request?
19
20
  flash.merge! args.last if args.length > 1
20
- render "ajax_modal_rails/redirect_via_js", layout: ajax_modal_layout, locals: {redirect: url_for(args.first)}
21
+ render "ajax_modal_rails/redirect_via_js", layout: ajax_modal_layout, locals: { redirect: url_for(args.first) }
21
22
  else
22
23
  redirect_to_without_xhr_redirect(*args)
23
24
  end
24
25
  end
26
+
25
27
  alias_method :redirect_to_without_xhr_redirect, :redirect_to
26
28
  alias_method :redirect_to, :redirect_to_with_xhr_redirect
27
-
28
29
  end
29
30
 
30
31
  private
31
32
 
32
- def ajax_modal_layout
33
- 'ajax_modal_rails/content'
34
- end
33
+ def ajax_modal_layout
34
+ "ajax_modal_rails/content"
35
+ end
35
36
 
36
- def ajax_modal_request?
37
- # TODO implement w/ special request header just catch all xhr for now
38
- # can always override in controller if necessary
39
- # request.env['HTTP_X_AJAX_MODAL'].present?
40
- request.env[HEADER].present?
41
- end
37
+ def ajax_modal_request?
38
+ # TODO implement w/ special request header just catch all xhr for now
39
+ # can always override in controller if necessary
40
+ # request.env['HTTP_X_AJAX_MODAL'].present?
41
+ request.env[HEADER].present?
42
+ end
42
43
 
44
+ def render_close_modal_and_reload_page
45
+ render "ajax_modal_rails/close_modal_and_reload_page", layout: ajax_modal_layout
46
+ end
43
47
  end
@@ -0,0 +1,3 @@
1
+ <script>
2
+ window.location.reload()
3
+ </script>
@@ -1,3 +1,3 @@
1
1
  module AjaxModalRails
2
- VERSION = "1.0.11"
2
+ VERSION = "1.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ajax_modal_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafe Rosen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2020-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -206,6 +206,7 @@ files:
206
206
  - app/assets/javascripts/ajax_modal_rails/index.coffee
207
207
  - app/controllers/ajax_modal_rails/controller.rb
208
208
  - app/views/ajax_modal_rails/_frame.html.erb
209
+ - app/views/ajax_modal_rails/close_modal_and_reload_page.html.erb
209
210
  - app/views/ajax_modal_rails/redirect_via_js.html.erb
210
211
  - app/views/layouts/ajax_modal_rails/content.html.erb
211
212
  - config/routes.rb