0
@@ -407,6 +407,7 @@ module ActionController
0
insertion = "insert_#{arg}".to_sym
0
raise ArgumentError, "Unknown RJS insertion type #{arg}" unless RJS_STATEMENTS[insertion]
0
statement = "(#{RJS_STATEMENTS[insertion]})"
0
@@ -418,6 +419,7 @@ module ActionController
0
statement = "#{RJS_STATEMENTS[:any]}"
0
+ position ||= Regexp.new(RJS_INSERTIONS.join('|'))
0
# Next argument we're looking for is the element identifier. If missing, we pick
0
@@ -434,9 +436,14 @@ module ActionController
0
Regexp.new("\\$\\(\"#{id}\"\\)#{statement}\\(#{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE)
0
when :remove, :show, :hide, :toggle
0
Regexp.new("#{statement}\\(\"#{id}\"\\)")
0
- Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE)
0
+ when :replace, :replace_html
0
+ Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)")
0
+ when :insert, :insert_html
0
+ Regexp.new("Element.insert\\(\\\"#{id}\\\", \\{ #{position}: #{RJS_PATTERN_HTML} \\}\\);")
0
+ Regexp.union(Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)"),
0
+ Regexp.new("Element.insert\\(\\\"#{id}\\\", \\{ #{position}: #{RJS_PATTERN_HTML} \\}\\);"))
0
# Duplicate the body since the next step involves destroying it.
0
@@ -445,7 +452,7 @@ module ActionController
0
matches = @response.body.match(pattern)
0
@response.body.gsub(pattern) do |match|
0
- html = unescape_rjs(
$2)
0
+ html = unescape_rjs(
match)
0
matches.concat HTML::Document.new(html).root.children.select { |n| n.tag? }
0
@@ -585,17 +592,16 @@ module ActionController
0
:hide => /Element\.hide/,
0
:toggle => /Element\.toggle/
0
+ RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
0
+ RJS_PATTERN_HTML = /"((\\"|[^"])*)"/
0
RJS_INSERTIONS = [:top, :bottom, :before, :after]
0
RJS_INSERTIONS.each do |insertion|
0
- RJS_STATEMENTS["insert_#{insertion}".to_sym] =
Regexp.new(Regexp.quote("new Insertion.#{insertion.to_s.camelize}"))0
+ RJS_STATEMENTS["insert_#{insertion}".to_sym] =
/Element.insert\(\"([^\"]*)\", \{ #{insertion.to_s.downcase}: #{RJS_PATTERN_HTML} \}\);/0
- RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
0
RJS_STATEMENTS[:insert_html] = Regexp.new(RJS_INSERTIONS.collect do |insertion|
0
-
Regexp.quote("new Insertion.#{insertion.to_s.camelize}")0
+
/Element.insert\(\"([^\"]*)\", \{ #{insertion.to_s.downcase}: #{RJS_PATTERN_HTML} \}\);/0
- RJS_PATTERN_HTML = /"((\\"|[^"])*)"/
0
- RJS_PATTERN_EVERYTHING = Regexp.new("#{RJS_STATEMENTS[:any]}\\(\"([^\"]*)\", #{RJS_PATTERN_HTML}\\)",
0
+ RJS_PATTERN_EVERYTHING = Regexp.new("#{RJS_STATEMENTS[:any]}\\(\"([^\"]*)\", #{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE)
0
RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/