ajax_modal_rails 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: f8a097482ac0d66acab2dc3cd309d30ac82f55ca
4
- data.tar.gz: 91f2d8a4fb8e8afc93f4d3c94b764a7c4528011e
3
+ metadata.gz: 4a77b001fa8a1be628edc3125925d3de35b33c6e
4
+ data.tar.gz: 9fec48b8c2aba9d6a26f0523081af60348ed6e61
5
5
  SHA512:
6
- metadata.gz: a6fee6360573c3b17b20bf1a21c4c45406042311bec16beab3f1220845546dbc38e4133bb7a53f8c4f627d4feaf08c2c445f6f47ba2759d85b8526e6fb3d66df
7
- data.tar.gz: 9c51d390060be4a84e4f3919215986675853e3ca38d04775c59790af4ad1a7ea951e1fd1322241d4d47723667cc68d402fb5de4ed5cdf94ab050976d32b26888
6
+ metadata.gz: 18f7fde5218671c7da121fa2b7523a575cf00d71d48a4c567fb8dcf7c6393b76d3edaead92add4a5f4b27e9670c6ad63d38037d3f68b5c1ca7e057cdb2d8d6d2
7
+ data.tar.gz: 1335579f97251241965ec1b45b009cd97139bcd7238e3c8ef9dd4c7df90f5befc825a2de8df285ee0fd90812d8c4e9f8c6517bb57f10176eb62c676ac571b7c8
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # AjaxModalRails
2
- This plugin provides a simple way to do common modal interactions in a rails app. Add a single data attribute to links and forms and include a controller mixin to load pages via ajax in a modal.
2
+ This plugin provides a simple way to do common modal interactions in a rails app. Keep your nice thin scaffolded controller, and just include a single mixin. Then add data attribute to links and forms to load pages via ajax in a modal.
3
+
4
+ ![demo screencast](doc/demo.gif)
5
+
6
+ ![demo screencast](doc/demo.gif)
3
7
 
4
8
  ## Installation
5
9
  Add this line to your application's Gemfile:
@@ -40,7 +44,7 @@ The mixin sets the appropriate layout for modal requests and adds behavior that
40
44
 
41
45
  ## Example
42
46
 
43
- These snippets are taken from the included [example application](blob/master/spec/dummy)
47
+ These snippets are taken from the included [example application](spec/dummy)
44
48
 
45
49
  *app/controllers/messages_controller.rb*
46
50
  ```ruby
@@ -20,8 +20,16 @@ class window.AjaxModal
20
20
  e.preventDefault()
21
21
  @loading.show()
22
22
  @open()
23
- @content.load e.currentTarget.getAttribute("href"), (data) =>
24
- @loading.hide()
23
+ $.ajax
24
+ url: e.currentTarget.getAttribute("href"),
25
+ dataType: 'html',
26
+ headers: {
27
+ 'X_AJAX_MODAL': true
28
+ },
29
+ complete: (xhr, status) =>
30
+ @loading.hide()
31
+ @content.html xhr.responseText
32
+ @open
25
33
 
26
34
  _registerForms: ->
27
35
  console.log $(@formTriggersSelector).toArray()
@@ -34,12 +42,14 @@ class window.AjaxModal
34
42
  url: form.getAttribute('action')
35
43
  type: form.getAttribute('method')
36
44
  dataType: 'html',
37
- data: $(form).serialize()
45
+ data: $(form).serialize(),
46
+ headers: {
47
+ 'X_AJAX_MODAL': true
48
+ },
38
49
  complete: (xhr, status) =>
39
50
  @loading.hide()
40
51
  @content.html xhr.responseText
41
52
  @open
42
- @_registerLinks @content
43
53
  return false
44
54
 
45
55
 
@@ -9,17 +9,11 @@ module AjaxModalRails::Controller
9
9
  # and forms should have `data-submits-to-pjax-modal`
10
10
 
11
11
  extend ActiveSupport::Concern
12
+ HEADER = 'HTTP_X_AJAX_MODAL'
12
13
 
13
14
  included do
14
15
  layout ->(c) { ajax_modal_request? ? ajax_modal_layout : nil }
15
16
 
16
- def form_html_options
17
- Hash.new.tap do |result|
18
- result['data-submits-to-pjax-modal'] = true if ajax_modal_request?
19
- end
20
- end
21
- helper_method :form_html_options
22
-
23
17
  def redirect_to_with_xhr_redirect(*args)
24
18
  if ajax_modal_request?
25
19
  flash.merge! args.last if args.length > 1
@@ -43,7 +37,7 @@ module AjaxModalRails::Controller
43
37
  # TODO implement w/ special request header just catch all xhr for now
44
38
  # can always override in controller if necessary
45
39
  # request.env['HTTP_X_AJAX_MODAL'].present?
46
- request.xhr?
40
+ request.env[HEADER].present?
47
41
  end
48
42
 
49
43
  end
@@ -1,3 +1,3 @@
1
1
  module AjaxModalRails
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafe Rosen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-29 00:00:00.000000000 Z
11
+ date: 2017-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- - !ruby/object:Gem::Dependency
56
- name: turbolinks
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: jquery-rails
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +164,20 @@ dependencies:
178
164
  - - ">="
179
165
  - !ruby/object:Gem::Version
180
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry-rails
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
181
  description:
182
182
  email:
183
183
  - existentialmutt@gmail.com