ajax_modal_rails 1.0.11 → 1.0.12
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e66f785e054c0c9f3e9325e9db132040fc6086197b6c59cae71005438ac55333
|
4
|
+
data.tar.gz: aa1f2252e4873ab7f72d18ffa0fe38ac05a665a9f76874f969580a8281767a79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
61
|
-
|
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
|
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 =
|
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
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def ajax_modal_layout
|
34
|
+
"ajax_modal_rails/content"
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
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.
|
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-
|
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
|