ajax_modal_rails 1.0.6 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -1
- data/app/assets/javascripts/ajax_modal_rails/index.coffee +5 -8
- data/app/controllers/ajax_modal_rails/controller.rb +17 -13
- data/app/views/ajax_modal_rails/close_modal_and_reload_page.html.erb +3 -0
- data/lib/ajax_modal_rails/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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
|
data/README.md
CHANGED
@@ -42,6 +42,8 @@ A controller that is processing actions to be loaded in a modal should `include
|
|
42
42
|
|
43
43
|
The mixin sets the appropriate layout for modal requests and adds behavior that allows a modal request that results in a redirect to redirect the whole page.
|
44
44
|
|
45
|
+
Note that a controller that includes the `AjaxModalRails::Controller` module will have a few things done to it, including overriding the default implementation of `redirect_to` and also have it's default `layout` set. These modifications should be pretty innocuous as they only take effect for ajax modal requests and fall back to the default behavior otherwise, but if you encounter unexpected behavior be sure to examine the code in [app/controllers/ajax_modal_rails/controller.rb](app/controllers/ajax_modal_rails/controller.rb) You can then either copy the file into your own repository and make modifications there or just add appropriate code to your including controllers.
|
46
|
+
|
45
47
|
## Example
|
46
48
|
|
47
49
|
These snippets are taken from the included [example application](spec/dummy)
|
@@ -77,4 +79,4 @@ The provided modal views and javascript require [Twitter Bootstrap 4.0](https://
|
|
77
79
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
78
80
|
|
79
81
|
## Gratitude
|
80
|
-
This gem was made possible by a Professional Development benefit from my employer, [Green River](http://www.greenriver.com)
|
82
|
+
This gem was made possible by a Professional Development benefit from my employer, [Green River](http://www.greenriver.com)
|
@@ -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,29 +1,29 @@
|
|
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:
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coffee-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 4.
|
75
|
+
version: 4.5.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 4.
|
82
|
+
version: 4.5.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -238,8 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
239
|
- !ruby/object:Gem::Version
|
239
240
|
version: '0'
|
240
241
|
requirements: []
|
241
|
-
|
242
|
-
rubygems_version: 2.6.13
|
242
|
+
rubygems_version: 3.1.2
|
243
243
|
signing_key:
|
244
244
|
specification_version: 4
|
245
245
|
summary: simple ajax-driven modals for rails. uses bootstrap 4
|