actionpack 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

@@ -236,7 +236,39 @@ class LegacyRouteSetTests < Test::Unit::TestCase
236
236
  map.connect ':controller/:action/:id'
237
237
  end
238
238
  end
239
+
240
+ def test_should_list_options_diff_when_routing_requirements_dont_match
241
+ rs.draw do |map|
242
+ map.post 'post/:id', :controller=> 'post', :action=> 'show', :requirements => {:id => /\d+/}
243
+ end
244
+ exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'post', :action => 'show', :bad_param => "foo", :use_route => "post") }
245
+ assert_match /^post_url failed to generate/, exception.message
246
+ from_match = exception.message.match(/from \{[^\}]+\}/).to_s
247
+ assert_match /:bad_param=>"foo"/, from_match
248
+ assert_match /:action=>"show"/, from_match
249
+ assert_match /:controller=>"post"/, from_match
250
+
251
+ expected_match = exception.message.match(/expected: \{[^\}]+\}/).to_s
252
+ assert_no_match /:bad_param=>"foo"/, expected_match
253
+ assert_match /:action=>"show"/, expected_match
254
+ assert_match /:controller=>"post"/, expected_match
239
255
 
256
+ diff_match = exception.message.match(/diff: \{[^\}]+\}/).to_s
257
+ assert_match /:bad_param=>"foo"/, diff_match
258
+ assert_no_match /:action=>"show"/, diff_match
259
+ assert_no_match /:controller=>"post"/, diff_match
260
+ end
261
+
262
+ # this specifies the case where your formerly would get a very confusing error message with an empty diff
263
+ def test_should_have_better_error_message_when_options_diff_is_empty
264
+ rs.draw do |map|
265
+ map.content '/content/:query', :controller => 'content', :action => 'show'
266
+ end
267
+ exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'content', :action => 'show', :use_route => "content") }
268
+ expected_message = %[content_url failed to generate from {:action=>"show", :controller=>"content"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["content", :query] - are they all satisifed?]
269
+ assert_equal expected_message, exception.message
270
+ end
271
+
240
272
  def test_dynamic_path_allowed
241
273
  rs.draw do |map|
242
274
  map.connect '*path', :controller => 'content', :action => 'show_file'
@@ -8,6 +8,12 @@ class TestTest < Test::Unit::TestCase
8
8
  render :text => 'ignore me'
9
9
  end
10
10
 
11
+ def set_session
12
+ session['string'] = 'A wonder'
13
+ session[:symbol] = 'it works'
14
+ render :text => 'Success'
15
+ end
16
+
11
17
  def render_raw_post
12
18
  raise Test::Unit::AssertionFailedError, "#raw_post is blank" if request.raw_post.blank?
13
19
  render :text => request.raw_post
@@ -111,6 +117,14 @@ HTML
111
117
  assert_equal '>value<', flash['test']
112
118
  end
113
119
 
120
+ def test_process_with_session
121
+ process :set_session
122
+ assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key"
123
+ assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access"
124
+ assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access"
125
+ assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access"
126
+ end
127
+
114
128
  def test_process_with_request_uri_with_no_params
115
129
  process :test_uri
116
130
  assert_equal "/test_test/test/test_uri", @response.body
@@ -360,6 +360,25 @@ class FormOptionsHelperTest < Test::Unit::TestCase
360
360
  )
361
361
  end
362
362
 
363
+ def test_collection_select_with_multiple_option_appends_array_brackets
364
+ @posts = [
365
+ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
366
+ Post.new("Babe went home", "Babe", "To a little house", "shh!"),
367
+ Post.new("Cabe went home", "Cabe", "To a little house", "shh!")
368
+ ]
369
+
370
+ @post = Post.new
371
+ @post.author_name = "Babe"
372
+
373
+ expected = "<select id=\"post_author_name\" name=\"post[author_name][]\" multiple=\"multiple\"><option value=\"\"></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>"
374
+
375
+ # Should suffix default name with [].
376
+ assert_dom_equal expected, collection_select("post", "author_name", @posts, "author_name", "author_name", { :include_blank => true }, :multiple => true)
377
+
378
+ # Shouldn't suffix custom name with [].
379
+ assert_dom_equal expected, collection_select("post", "author_name", @posts, "author_name", "author_name", { :include_blank => true, :name => 'post[author_name][]' }, :multiple => true)
380
+ end
381
+
363
382
  def test_country_select
364
383
  @post = Post.new
365
384
  @post.origin = "Denmark"
@@ -130,7 +130,9 @@ class TextHelperTest < Test::Unit::TestCase
130
130
  http://www.rubyonrails.com/contact;new
131
131
  http://www.rubyonrails.com/contact;new%20with%20spaces
132
132
  http://www.rubyonrails.com/contact;new?with=query&string=params
133
- http://www.rubyonrails.com/~minam/contact;new?with=query&string=params)
133
+ http://www.rubyonrails.com/~minam/contact;new?with=query&string=params
134
+ http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007
135
+ )
134
136
 
135
137
  urls.each do |url|
136
138
  assert_equal %(<a href="#{url}">#{url}</a>), auto_link(url)
@@ -151,6 +153,14 @@ class TextHelperTest < Test::Unit::TestCase
151
153
  link4_result = %{<a href="#{link4_raw}">#{link4_raw}</a>}
152
154
  link5_raw = 'http://foo.example.com:3000/controller/action'
153
155
  link5_result = %{<a href="#{link5_raw}">#{link5_raw}</a>}
156
+ link6_raw = 'http://foo.example.com:3000/controller/action+pack'
157
+ link6_result = %{<a href="#{link6_raw}">#{link6_raw}</a>}
158
+ link7_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor-123'
159
+ link7_result = %{<a href="#{link7_raw}">#{link7_raw}</a>}
160
+ link8_raw = 'http://foo.example.com:3000/controller/action.html'
161
+ link8_result = %{<a href="#{link8_raw}">#{link8_raw}</a>}
162
+ link9_raw = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html'
163
+ link9_result = %{<a href="#{link9_raw}">#{link9_raw}</a>}
154
164
 
155
165
  assert_equal %(hello #{email_result}), auto_link("hello #{email_raw}", :email_addresses)
156
166
  assert_equal %(Go to #{link_result}), auto_link("Go to #{link_raw}", :urls)
@@ -176,6 +186,20 @@ class TextHelperTest < Test::Unit::TestCase
176
186
  assert_equal %(<p>Link #{link4_result}</p>), auto_link("<p>Link #{link4_raw}</p>")
177
187
  assert_equal %(<p>#{link4_result} Link</p>), auto_link("<p>#{link4_raw} Link</p>")
178
188
  assert_equal %(<p>#{link5_result} Link</p>), auto_link("<p>#{link5_raw} Link</p>")
189
+ assert_equal %(<p>#{link6_result} Link</p>), auto_link("<p>#{link6_raw} Link</p>")
190
+ assert_equal %(<p>#{link7_result} Link</p>), auto_link("<p>#{link7_raw} Link</p>")
191
+ assert_equal %(Go to #{link8_result}), auto_link("Go to #{link8_raw}", :urls)
192
+ assert_equal %(Go to #{link8_raw}), auto_link("Go to #{link8_raw}", :email_addresses)
193
+ assert_equal %(<p>Link #{link8_result}</p>), auto_link("<p>Link #{link8_raw}</p>")
194
+ assert_equal %(<p>#{link8_result} Link</p>), auto_link("<p>#{link8_raw} Link</p>")
195
+ assert_equal %(Go to #{link8_result}.), auto_link(%(Go to #{link8_raw}.))
196
+ assert_equal %(<p>Go to #{link8_result}. seriously, #{link8_result}? i think I'll say hello to #{email_result}. instead.</p>), auto_link(%(<p>Go to #{link8_raw}. seriously, #{link8_raw}? i think I'll say hello to #{email_raw}. instead.</p>))
197
+ assert_equal %(Go to #{link9_result}), auto_link("Go to #{link9_raw}", :urls)
198
+ assert_equal %(Go to #{link9_raw}), auto_link("Go to #{link9_raw}", :email_addresses)
199
+ assert_equal %(<p>Link #{link9_result}</p>), auto_link("<p>Link #{link9_raw}</p>")
200
+ assert_equal %(<p>#{link9_result} Link</p>), auto_link("<p>#{link9_raw} Link</p>")
201
+ assert_equal %(Go to #{link9_result}.), auto_link(%(Go to #{link9_raw}.))
202
+ assert_equal %(<p>Go to #{link9_result}. seriously, #{link9_result}? i think I'll say hello to #{email_result}. instead.</p>), auto_link(%(<p>Go to #{link9_raw}. seriously, #{link9_raw}? i think I'll say hello to #{email_raw}. instead.</p>))
179
203
  assert_equal '', auto_link(nil)
180
204
  assert_equal '', auto_link('')
181
205
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: actionpack
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.13.1
7
- date: 2007-01-18 00:00:00 -06:00
6
+ version: 1.13.2
7
+ date: 2007-02-05 00:00:00 -06:00
8
8
  summary: Web-flow and rendering framework putting the VC in MVC.
9
9
  require_paths:
10
10
  - lib
@@ -67,7 +67,6 @@ files:
67
67
  - lib/action_controller/rescue.rb
68
68
  - lib/action_controller/resources.rb
69
69
  - lib/action_controller/response.rb
70
- - lib/action_controller/response.rb.rej
71
70
  - lib/action_controller/routing.rb
72
71
  - lib/action_controller/scaffolding.rb
73
72
  - lib/action_controller/session
@@ -150,7 +149,6 @@ files:
150
149
  - lib/action_view/helpers/javascripts/dragdrop.js
151
150
  - lib/action_view/helpers/javascripts/effects.js
152
151
  - lib/action_view/helpers/javascripts/prototype.js
153
- - lib/action_view/helpers/javascripts/prototype.js.rej
154
152
  - test/abstract_unit.rb
155
153
  - test/active_record_unit.rb
156
154
  - test/activerecord
@@ -377,5 +375,5 @@ dependencies:
377
375
  requirements:
378
376
  - - "="
379
377
  - !ruby/object:Gem::Version
380
- version: 1.4.0
378
+ version: 1.4.1
381
379
  version:
@@ -1,17 +0,0 @@
1
- ***************
2
- *** 27,33 ****
3
-
4
- def redirect(to_url, permanently = false)
5
- @headers["Status"] = "302 Found" unless @headers["Status"] == "301 Moved Permanently"
6
- - @headers["location"] = to_url
7
-
8
- @body = "<html><body>You are being <a href=\"#{to_url}\">redirected</a>.</body></html>"
9
- end
10
- --- 27,33 ----
11
-
12
- def redirect(to_url, permanently = false)
13
- @headers["Status"] = "302 Found" unless @headers["Status"] == "301 Moved Permanently"
14
- + @headers["Location"] = to_url
15
-
16
- @body = "<html><body>You are being <a href=\"#{to_url}\">redirected</a>.</body></html>"
17
- end
@@ -1,561 +0,0 @@
1
- ***************
2
- *** 1,4 ****
3
- /* Prototype JavaScript framework, version 1.5.0_rc2
4
- - * (c) 2005, 2006 Sam Stephenson <sam@conio.net>
5
- *
6
- * Prototype is freely distributable under the terms of an MIT-style license.
7
- --- 1,4 ----
8
- /* Prototype JavaScript framework, version 1.5.0_rc2
9
- + * (c) 2005-2007 Sam Stephenson
10
- *
11
- * Prototype is freely distributable under the terms of an MIT-style license.
12
- ***************
13
- *** 146,149 ****
14
- }
15
- }
16
- Object.extend(String.prototype, {
17
- gsub: function(pattern, replacement) {
18
- --- 146,153 ----
19
- }
20
- }
21
- + String.interpret = function(value){
22
- + return value == null ? '' : String(value);
23
- + }
24
- +
25
- Object.extend(String.prototype, {
26
- gsub: function(pattern, replacement) {
27
- ***************
28
- *** 154,158 ****
29
- if (match = source.match(pattern)) {
30
- result += source.slice(0, match.index);
31
- - result += (replacement(match) || '').toString();
32
- source = source.slice(match.index + match[0].length);
33
- } else {
34
- --- 158,162 ----
35
- if (match = source.match(pattern)) {
36
- result += source.slice(0, match.index);
37
- + result += String.interpret(replacement(match));
38
- source = source.slice(match.index + match[0].length);
39
- } else {
40
- ***************
41
- *** 248,269 ****
42
- },
43
-
44
- camelize: function() {
45
- - var oStringList = this.split('-');
46
- - if (oStringList.length == 1) return oStringList[0];
47
- -
48
- - var camelizedString = this.indexOf('-') == 0
49
- - ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
50
- - : oStringList[0];
51
- -
52
- - for (var i = 1, length = oStringList.length; i < length; i++) {
53
- - var s = oStringList[i];
54
- - camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
55
- - }
56
- -
57
- - return camelizedString;
58
- },
59
-
60
- underscore: function() {
61
- - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'-').toLowerCase();
62
- },
63
-
64
- --- 252,280 ----
65
- },
66
-
67
- + succ: function() {
68
- + return this.slice(0, this.length - 1) +
69
- + String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
70
- + },
71
- +
72
- camelize: function() {
73
- + var parts = this.split('-'), len = parts.length;
74
- + if (len == 1) return parts[0];
75
- +
76
- + var camelized = this.charAt(0) == '-'
77
- + ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
78
- + : parts[0];
79
- +
80
- + for (var i = 1; i < len; i++)
81
- + camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
82
- +
83
- + return camelized;
84
- + },
85
- +
86
- + capitalize: function(){
87
- + return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
88
- },
89
-
90
- underscore: function() {
91
- + return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
92
- },
93
-
94
- ***************
95
- *** 301,305 ****
96
- var before = match[1];
97
- if (before == '\\') return match[2];
98
- - return before + (object[match[3]] || '').toString();
99
- });
100
- }
101
- --- 312,316 ----
102
- var before = match[1];
103
- if (before == '\\') return match[2];
104
- + return before + String.interpret(object[match[3]]);
105
- });
106
- }
107
- ***************
108
- *** 330,334 ****
109
- while ((index += number) < array.length)
110
- slices.push(array.slice(index, index+number));
111
- - return slices.collect(iterator || Prototype.K);
112
- },
113
-
114
- --- 341,345 ----
115
- while ((index += number) < array.length)
116
- slices.push(array.slice(index, index+number));
117
- + return slices.map(iterator);
118
- },
119
-
120
- ***************
121
- *** 354,358 ****
122
- var results = [];
123
- this.each(function(value, index) {
124
- - results.push(iterator(value, index));
125
- });
126
- return results;
127
- --- 365,369 ----
128
- var results = [];
129
- this.each(function(value, index) {
130
- + results.push((iterator || Prototype.K)(value, index));
131
- });
132
- return results;
133
- ***************
134
- *** 401,410 ****
135
-
136
- inGroupsOf: function(number, fillWith) {
137
- - fillWith = fillWith || null;
138
- - var results = this.eachSlice(number);
139
- - if (results.length > 0) (number - results.last().length).times(function() {
140
- - results.last().push(fillWith)
141
- - });
142
- - return results;
143
- },
144
-
145
- --- 412,420 ----
146
-
147
- inGroupsOf: function(number, fillWith) {
148
- + fillWith = fillWith === undefined ? null : fillWith;
149
- + return this.eachSlice(number, function(slice) {
150
- + while(slice.length < number) slice.push(fillWith);
151
- + return slice;
152
- + });
153
- },
154
-
155
- ***************
156
- *** 418,422 ****
157
- invoke: function(method) {
158
- var args = $A(arguments).slice(1);
159
- - return this.collect(function(value) {
160
- return value[method].apply(value, args);
161
- });
162
- --- 428,432 ----
163
- invoke: function(method) {
164
- var args = $A(arguments).slice(1);
165
- + return this.map(function(value) {
166
- return value[method].apply(value, args);
167
- });
168
- ***************
169
- *** 470,474 ****
170
-
171
- sortBy: function(iterator) {
172
- - return this.collect(function(value, index) {
173
- return {value: value, criteria: iterator(value, index)};
174
- }).sort(function(left, right) {
175
- --- 480,484 ----
176
-
177
- sortBy: function(iterator) {
178
- + return this.map(function(value, index) {
179
- return {value: value, criteria: iterator(value, index)};
180
- }).sort(function(left, right) {
181
- ***************
182
- *** 479,483 ****
183
-
184
- toArray: function() {
185
- - return this.collect(Prototype.K);
186
- },
187
-
188
- --- 489,493 ----
189
-
190
- toArray: function() {
191
- + return this.map();
192
- },
193
-
194
- ***************
195
- *** 491,494 ****
196
- return iterator(collections.pluck(index));
197
- });
198
- },
199
-
200
- --- 501,508 ----
201
- return iterator(collections.pluck(index));
202
- });
203
- + },
204
- +
205
- + size: function() {
206
- + return this.toArray().length;
207
- },
208
-
209
- ***************
210
- *** 543,547 ****
211
- compact: function() {
212
- return this.select(function(value) {
213
- - return value != undefined || value != null;
214
- });
215
- },
216
- --- 557,561 ----
217
- compact: function() {
218
- return this.select(function(value) {
219
- + return value != null;
220
- });
221
- },
222
- ***************
223
- *** 585,588 ****
224
- },
225
-
226
- inspect: function() {
227
- return '[' + this.map(Object.inspect).join(', ') + ']';
228
- --- 599,606 ----
229
- },
230
-
231
- + size: function() {
232
- + return this.length;
233
- + },
234
- +
235
- inspect: function() {
236
- return '[' + this.map(Object.inspect).join(', ') + ']';
237
- ***************
238
- *** 591,594 ****
239
-
240
- Array.prototype.toArray = Array.prototype.clone;
241
-
242
- if(window.opera){
243
- --- 609,617 ----
244
-
245
- Array.prototype.toArray = Array.prototype.clone;
246
- +
247
- + function $w(string){
248
- + string = string.strip();
249
- + return string ? string.split(/\s+/) : [];
250
- + }
251
-
252
- if(window.opera){
253
- ***************
254
- *** 802,807 ****
255
-
256
- this.transport.open(this.options.method.toUpperCase(), this.url,
257
- - this.options.asynchronous, this.options.username,
258
- - this.options.password);
259
-
260
- if (this.options.asynchronous)
261
- --- 825,829 ----
262
-
263
- this.transport.open(this.options.method.toUpperCase(), this.url,
264
- + this.options.asynchronous);
265
-
266
- if (this.options.asynchronous)
267
- ***************
268
- *** 885,888 ****
269
- this.dispatchException(e);
270
- }
271
- }
272
-
273
- --- 907,914 ----
274
- this.dispatchException(e);
275
- }
276
- +
277
- + if ((this.getHeader('Content-type') || 'text/javascript').strip().
278
- + match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
279
- + this.evalResponse();
280
- }
281
-
282
- ***************
283
- *** 895,902 ****
284
-
285
- if (state == 'Complete') {
286
- - if ((this.getHeader('Content-type') || '').strip().
287
- - match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
288
- - this.evalResponse();
289
- -
290
- // avoid memory leak in MSIE: clean up
291
- this.transport.onreadystatechange = Prototype.emptyFunction;
292
- --- 921,924 ----
293
-
294
- if (state == 'Complete') {
295
- // avoid memory leak in MSIE: clean up
296
- this.transport.onreadystatechange = Prototype.emptyFunction;
297
- ***************
298
- *** 1058,1063 ****
299
-
300
- Element.extend = function(element) {
301
- - if (!element) return;
302
- - if (_nativeExtensions || element.nodeType == 3) return element;
303
-
304
- if (!element._extended && element.tagName && element != window) {
305
- --- 1080,1084 ----
306
-
307
- Element.extend = function(element) {
308
- + if (!element || _nativeExtensions || element.nodeType == 3) return element;
309
-
310
- if (!element._extended && element.tagName && element != window) {
311
- ***************
312
- *** 1163,1168 ****
313
-
314
- descendants: function(element) {
315
- - element = $(element);
316
- - return $A(element.getElementsByTagName('*'));
317
- },
318
-
319
- --- 1184,1188 ----
320
-
321
- descendants: function(element) {
322
- + return $A($(element).getElementsByTagName('*'));
323
- },
324
-
325
- ***************
326
- *** 1188,1195 ****
327
-
328
- match: function(element, selector) {
329
- - element = $(element);
330
- if (typeof selector == 'string')
331
- selector = new Selector(selector);
332
- - return selector.match(element);
333
- },
334
-
335
- --- 1208,1214 ----
336
-
337
- match: function(element, selector) {
338
- if (typeof selector == 'string')
339
- selector = new Selector(selector);
340
- + return selector.match($(element));
341
- },
342
-
343
- ***************
344
- *** 1216,1220 ****
345
-
346
- getElementsByClassName: function(element, className) {
347
- - element = $(element);
348
- return document.getElementsByClassName(className, element);
349
- },
350
- --- 1235,1238 ----
351
-
352
- getElementsByClassName: function(element, className) {
353
- return document.getElementsByClassName(className, element);
354
- },
355
- ***************
356
- *** 1225,1230 ****
357
-
358
- getHeight: function(element) {
359
- - element = $(element);
360
- - return element.offsetHeight;
361
- },
362
-
363
- --- 1243,1247 ----
364
-
365
- getHeight: function(element) {
366
- + return $(element).offsetHeight;
367
- },
368
-
369
- ***************
370
- *** 1252,1255 ****
371
- if (!(element = $(element))) return;
372
- Element.classNames(element).remove(className);
373
- return element;
374
- },
375
- --- 1269,1278 ----
376
- if (!(element = $(element))) return;
377
- Element.classNames(element).remove(className);
378
- + return element;
379
- + },
380
- +
381
- + toggleClassName: function(element, className) {
382
- + if (!(element = $(element))) return;
383
- + Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className);
384
- return element;
385
- },
386
- ***************
387
- *** 1291,1297 ****
388
- scrollTo: function(element) {
389
- element = $(element);
390
- - var x = element.x ? element.x : element.offsetLeft,
391
- - y = element.y ? element.y : element.offsetTop;
392
- - window.scrollTo(x, y);
393
- return element;
394
- },
395
- --- 1314,1319 ----
396
- scrollTo: function(element) {
397
- element = $(element);
398
- + var pos = Position.cumulativeOffset(element);
399
- + window.scrollTo(pos[0], pos[1]);
400
- return element;
401
- },
402
- ***************
403
- *** 1299,1320 ****
404
- getStyle: function(element, style) {
405
- element = $(element);
406
- - var inline = (style == 'float' ?
407
- - (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat') : style);
408
- - var value = element.style[inline.camelize()];
409
- if (!value) {
410
- if (document.defaultView && document.defaultView.getComputedStyle) {
411
- var css = document.defaultView.getComputedStyle(element, null);
412
- - value = css ? css.getPropertyValue(style) : null;
413
- } else if (element.currentStyle) {
414
- - value = element.currentStyle[inline.camelize()];
415
- }
416
- }
417
-
418
- if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none'))
419
- - value = element['offset'+style.charAt(0).toUpperCase()+style.substring(1)] + 'px';
420
-
421
- if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
422
- if (Element.getStyle(element, 'position') == 'static') value = 'auto';
423
- -
424
- return value == 'auto' ? null : value;
425
- },
426
- --- 1321,1347 ----
427
- getStyle: function(element, style) {
428
- element = $(element);
429
- + var camelizedStyle = (style == 'float' ?
430
- + (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat') : style).camelize();
431
- + var value = element.style[camelizedStyle];
432
- if (!value) {
433
- if (document.defaultView && document.defaultView.getComputedStyle) {
434
- var css = document.defaultView.getComputedStyle(element, null);
435
- + value = css ? css[camelizedStyle] : null;
436
- } else if (element.currentStyle) {
437
- + value = element.currentStyle[camelizedStyle];
438
- }
439
- }
440
-
441
- if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none'))
442
- + value = element['offset'+style.capitalize()] + 'px';
443
-
444
- if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
445
- if (Element.getStyle(element, 'position') == 'static') value = 'auto';
446
- + if(style == 'opacity') {
447
- + if(value) return parseFloat(value);
448
- + if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
449
- + if(value[1]) return parseFloat(value[1]) / 100;
450
- + return 1.0;
451
- + }
452
- return value == 'auto' ? null : value;
453
- },
454
- ***************
455
- *** 1322,1329 ****
456
- setStyle: function(element, style) {
457
- element = $(element);
458
- - for (var name in style)
459
- - element.style[ (name == 'float' ?
460
- - ((typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat') : name).camelize()
461
- - ] = style[name];
462
- return element;
463
- },
464
- --- 1349,1369 ----
465
- setStyle: function(element, style) {
466
- element = $(element);
467
- + for (var name in style) {
468
- + var value = style[name];
469
- + if(name == 'opacity') {
470
- + if (value == 1) {
471
- + value = (/Gecko/.test(navigator.userAgent) &&
472
- + !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0;
473
- + if(/MSIE/.test(navigator.userAgent) && !window.opera)
474
- + element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
475
- + } else {
476
- + if(value < 0.00001) value = 0;
477
- + if(/MSIE/.test(navigator.userAgent) && !window.opera)
478
- + element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
479
- + 'alpha(opacity='+value*100+')';
480
- + }
481
- + } else if(name == 'float') name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat';
482
- + element.style[name.camelize()] = value;
483
- + }
484
- return element;
485
- },
486
- ***************
487
- *** 1652,1656 ****
488
- conditions.push('true');
489
- if (clause = params.id)
490
- - conditions.push('element.id == ' + clause.inspect());
491
- if (clause = params.tagName)
492
- conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
493
- --- 1692,1696 ----
494
- conditions.push('true');
495
- if (clause = params.id)
496
- + conditions.push('element.getAttribute("id") == ' + clause.inspect());
497
- if (clause = params.tagName)
498
- conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
499
- ***************
500
- *** 1713,1717 ****
501
- matchElements: function(elements, expression) {
502
- var selector = new Selector(expression);
503
- - return elements.select(selector.match.bind(selector)).collect(Element.extend);
504
- },
505
-
506
- --- 1753,1757 ----
507
- matchElements: function(elements, expression) {
508
- var selector = new Selector(expression);
509
- + return elements.select(selector.match.bind(selector)).map(Element.extend);
510
- },
511
-
512
- ***************
513
- *** 1753,1757 ****
514
- Form.Methods = {
515
- serialize: function(form) {
516
- - return Form.serializeElements($(form).getElements());
517
- },
518
-
519
- --- 1793,1797 ----
520
- Form.Methods = {
521
- serialize: function(form) {
522
- + return Form.serializeElements(Form.getElements(form));
523
- },
524
-
525
- ***************
526
- *** 1768,1777 ****
527
- getInputs: function(form, typeName, name) {
528
- form = $(form);
529
- - var inputs = form.getElementsByTagName('input');
530
-
531
- if (!typeName && !name)
532
- - return inputs;
533
- -
534
- - var matchingInputs = new Array();
535
- for (var i = 0, length = inputs.length; i < length; i++) {
536
- var input = inputs[i];
537
- --- 1808,1816 ----
538
- getInputs: function(form, typeName, name) {
539
- form = $(form);
540
- + var inputs = form.getElementsByTagName('input'), matchingInputs = [];
541
-
542
- if (!typeName && !name)
543
- + return $A(inputs).map(Element.extend);
544
- +
545
- for (var i = 0, length = inputs.length; i < length; i++) {
546
- var input = inputs[i];
547
- ***************
548
- *** 1969,1973 ****
549
- onTimerEvent: function() {
550
- var value = this.getValue();
551
- - if (this.lastValue != value) {
552
- this.callback(this.element, value);
553
- this.lastValue = value;
554
- --- 2008,2014 ----
555
- onTimerEvent: function() {
556
- var value = this.getValue();
557
- + var changed = ('string' == typeof this.lastValue && 'string' == typeof value
558
- + ? this.lastValue != value : String(this.lastValue) != String(value));
559
- + if (changed) {
560
- this.callback(this.element, value);
561
- this.lastValue = value;