new_responds_to_parent 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/new_responds_to_parent/action_controller.rb +12 -13
- data/new_responds_to_parent.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a6e47fac063ab31e7fcabea36959929247fdd85
|
4
|
+
data.tar.gz: d15eae08b73a78fb3f1ffcef0450207a3de29f05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95cacdd16d12450d572bc0bce6749d549cae2b6f68e89ba861d105b63df4551bf3c5af8fc040c1444804efc7d2e70d22c00b59478523164db08e82f5953baba1
|
7
|
+
data.tar.gz: 9f1ec84c47415b47f31a5c61dfa68d492d64324b5dc447aec581296f79ba86b23aa191b35118ed4e2150cf2aa051b20a23c9dbd863fac2f2df840a4ad93c6b8e
|
@@ -4,7 +4,7 @@ module NewRespondsToParent
|
|
4
4
|
# Executes the response body as JavaScript in the context of the parent window.
|
5
5
|
# Use this method of you are posting a form to a hidden IFRAME or if you would like
|
6
6
|
# to use IFRAME base RPC.
|
7
|
-
def responds_to_parent
|
7
|
+
def responds_to_parent
|
8
8
|
yield
|
9
9
|
|
10
10
|
if performed?
|
@@ -13,20 +13,20 @@ module NewRespondsToParent
|
|
13
13
|
|
14
14
|
# Either pull out a redirect or the request body
|
15
15
|
script = if response.headers['Location']
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
# TODO: erase_redirect_results is missing in rails 3.0 has to be implemented
|
17
|
+
# erase redirect
|
18
|
+
"document.location.href = #{location.to_s.inspect}"
|
19
|
+
else
|
20
|
+
response.body
|
21
21
|
end
|
22
22
|
|
23
23
|
# Escape quotes, linebreaks and slashes, maintaining previously escaped slashes
|
24
24
|
# Suggestions for improvement?
|
25
|
-
script = (script || '')
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
script = (script || '')
|
26
|
+
.gsub('\\', '\\\\\\')
|
27
|
+
.gsub(/\r\n|\r|\n/, '\\n')
|
28
|
+
.gsub(/['"]/, '\\\\\&')
|
29
|
+
.gsub('</script>', '</scr"+"ipt>')
|
30
30
|
|
31
31
|
# Clear out the previous render to prevent double render
|
32
32
|
response.request.env['action_controller.instance'].instance_variable_set(:@_response_body, nil)
|
@@ -38,8 +38,7 @@ module NewRespondsToParent
|
|
38
38
|
# setTimeout - scope the execution in the windows parent for safari
|
39
39
|
# window.eval - legal eval for Opera
|
40
40
|
render plain: "<html><body><script type='text/javascript' charset='utf-8'>
|
41
|
-
|
42
|
-
with(window.parent) { setTimeout(function() { window.eval('#{script}'); if (typeof(loc) !== 'undefined') loc.replace('about:blank'); }, 1) };
|
41
|
+
with(window.parent) { setTimeout(function() { window.eval('#{script}'); }, 1) };
|
43
42
|
</script></body></html>".html_safe
|
44
43
|
end
|
45
44
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{new_responds_to_parent}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["James Huynh"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2012-03-17}
|
13
13
|
s.description = %q{Adds responds_to_parent to your controller to respond to the parent document of your page. Make Ajaxy file uploads by posting the form to a hidden iframe, and respond with javascript call to the parent window. This gem version can support rails 3.0+}
|
14
14
|
s.email = %q{james@rubify.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: new_responds_to_parent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Huynh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2012-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|