ajax 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +2 -1
- data/VERSION +1 -1
- data/lib/ajax/action_controller.rb +39 -21
- data/lib/ajax/railtie.rb +11 -1
- data/public/javascripts/ajax.js +6 -4
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -10,7 +10,8 @@ As of May 2010 Ajax is being used live in production on kazaa.com[http://www.kaz
|
|
10
10
|
|
11
11
|
== Changelog
|
12
12
|
|
13
|
-
* v1.1.
|
13
|
+
* v1.1.7: Fix layout handling for Rails 3
|
14
|
+
* v1.1.6: Fix redirect_to to handle resourceful redirects. [Rails 3]
|
14
15
|
* v1.1.5: Fix inclusion of +controller+ and +layout+ in <tt>Ajax-Info</tt> response header. Improve RSpec 1.* integration
|
15
16
|
* v1.1.4: Fix RSpec 2 integration
|
16
17
|
* v1.1.3: Guard against possible nil values for the redirect_to url and the referrers
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.7
|
@@ -39,7 +39,7 @@ module Ajax
|
|
39
39
|
# layout and render that. If it can't be found, the default layout
|
40
40
|
# is used.
|
41
41
|
def ajax_layout(template_name)
|
42
|
-
write_inheritable_attribute(:ajax_layout, template_name)
|
42
|
+
(self.is_a?(Class) ? self : self.class).write_inheritable_attribute(:ajax_layout, template_name)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -103,9 +103,11 @@ module Ajax
|
|
103
103
|
|
104
104
|
default = pick_layout(options)
|
105
105
|
default = default.path_without_format_and_extension unless default.nil?
|
106
|
-
ajax_layout = _layout_for_ajax(default)
|
107
|
-
|
108
|
-
|
106
|
+
if ajax_layout = _layout_for_ajax(default)
|
107
|
+
if ajax_layout = _find_ajax_layout(ajax_layout)
|
108
|
+
options[:layout] = ajax_layout.path_without_format_and_extension
|
109
|
+
end
|
110
|
+
end
|
109
111
|
end
|
110
112
|
render_without_ajax(options, extra_options, &block)
|
111
113
|
end
|
@@ -121,18 +123,14 @@ module Ajax
|
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
if
|
128
|
-
|
126
|
+
|
127
|
+
def _layout_for_option(name)
|
128
|
+
default = super
|
129
|
+
if !request.xhr? || !Ajax.is_enabled?
|
130
|
+
default
|
129
131
|
else
|
130
|
-
|
131
|
-
|
132
|
-
ajax_layout.virtual_path
|
133
|
-
else
|
134
|
-
layout_name
|
135
|
-
end
|
132
|
+
ajax_layout = _layout_for_ajax(default)
|
133
|
+
ajax_layout && template_exists?(ajax_layout) ? ajax_layout : default
|
136
134
|
end
|
137
135
|
end
|
138
136
|
end
|
@@ -147,8 +145,17 @@ module Ajax
|
|
147
145
|
#
|
148
146
|
# +controller+ is the result of calling ActionController#controller_name, so
|
149
147
|
# if your controller is ApplicationController the value will be <tt>'application'</tt>.
|
148
|
+
#
|
149
|
+
# +layout+ is the name of the layout without any path or extension. So for example if
|
150
|
+
# layouts/simple.html.erb or layouts/ajax/simple.html.erb are rendered the
|
151
|
+
# value of +layout+ would be <tt>'simple'</tt> in both cases.
|
150
152
|
def serialize_ajax_info
|
151
|
-
|
153
|
+
layout_name = if Ajax.app.rails?(3)
|
154
|
+
@_rendered_layout && @_rendered_layout.variable_name
|
155
|
+
else
|
156
|
+
active_layout
|
157
|
+
end
|
158
|
+
Ajax.set_header(response, :layout, layout_name)
|
152
159
|
Ajax.set_header(response, :controller, self.class.controller_name)
|
153
160
|
response.headers['Ajax-Info'] = Ajax.send(:serialize_hash, response.headers['Ajax-Info'])
|
154
161
|
end
|
@@ -245,15 +252,26 @@ END
|
|
245
252
|
ajax_layout = if ajax_layout.nil? && default.nil?
|
246
253
|
nil
|
247
254
|
elsif ajax_layout.nil? && !default.nil? # look for one with the default name in layouts/ajax
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
255
|
+
if default =~ /^layouts\/ajax\//
|
256
|
+
default
|
257
|
+
elsif !(default =~ /^ajax\//)
|
258
|
+
"ajax/#{default.sub(/layouts(\/)?/, '')}"
|
259
|
+
else
|
260
|
+
default
|
261
|
+
end
|
262
|
+
elsif ajax_layout.include?(?/) # path to specific layout
|
252
263
|
ajax_layout
|
264
|
+
else # layout name, look in ajax/
|
265
|
+
"ajax/#{ajax_layout}"
|
253
266
|
end
|
267
|
+
ajax_layout = ajax_layout =~ /\blayouts/ ? ajax_layout : "layouts/#{ajax_layout}" if ajax_layout
|
268
|
+
ajax_layout
|
269
|
+
end
|
270
|
+
|
271
|
+
def _find_ajax_layout(ajax_layout)
|
254
272
|
Ajax.app.rails?(3) ? find_template(ajax_layout) : find_layout(ajax_layout, 'html') if !ajax_layout.nil?
|
255
273
|
rescue ::ActionView::MissingTemplate
|
256
|
-
Ajax.logger.
|
274
|
+
Ajax.logger.warn("[ajax] layout #{ajax_layout.inspect} not found. Using default.")
|
257
275
|
nil
|
258
276
|
end
|
259
277
|
end
|
data/lib/ajax/railtie.rb
CHANGED
@@ -10,6 +10,16 @@ module Ajax
|
|
10
10
|
initializer 'ajax.action_integration' do
|
11
11
|
ActiveSupport.on_load :action_view do
|
12
12
|
include Ajax::ActionView
|
13
|
+
|
14
|
+
self.class_eval do
|
15
|
+
unless instance_methods.include?('_render_layout_with_tracking')
|
16
|
+
def _render_layout_with_tracking(layout, locals, &block)
|
17
|
+
controller.instance_variable_set(:@_rendered_layout, layout)
|
18
|
+
_render_layout_without_tracking(layout, locals, &block)
|
19
|
+
end
|
20
|
+
alias_method_chain :_render_layout, :tracking
|
21
|
+
end
|
22
|
+
end
|
13
23
|
end
|
14
24
|
ActiveSupport.on_load :action_controller do
|
15
25
|
include Ajax::ActionController
|
@@ -28,4 +38,4 @@ module Ajax
|
|
28
38
|
Ajax.logger = ::Rails.logger
|
29
39
|
end
|
30
40
|
end
|
31
|
-
end
|
41
|
+
end
|
data/public/javascripts/ajax.js
CHANGED
@@ -682,10 +682,12 @@ var Ajax = function(options) {
|
|
682
682
|
*/
|
683
683
|
self.hideLoadingImage = function() {
|
684
684
|
// check if a new request has already started
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
685
|
+
try {
|
686
|
+
if (self.current_request && self.current_request.status == 0) {
|
687
|
+
console.log("[AJAX] aborting hideLoadingImage.. ");
|
688
|
+
return;
|
689
|
+
}
|
690
|
+
} catch(e) {}
|
689
691
|
if (!self.show_loading_image) { return; }
|
690
692
|
if (!self.hide_loading_image_callback) {
|
691
693
|
$(document).unbind('mousemove', self.updateImagePosition);
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ajax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 7
|
10
|
+
version: 1.1.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Karl Varga
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-13 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|