rails 2.1.2 → 2.2.2

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

Potentially problematic release.


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

Files changed (221) hide show
  1. data/CHANGELOG +27 -3
  2. data/Rakefile +70 -10
  3. data/bin/about +0 -0
  4. data/bin/console +0 -0
  5. data/bin/destroy +0 -0
  6. data/bin/generate +0 -0
  7. data/bin/performance/benchmarker +0 -0
  8. data/bin/performance/profiler +0 -0
  9. data/bin/performance/request +0 -0
  10. data/bin/plugin +0 -0
  11. data/bin/process/inspector +0 -0
  12. data/bin/process/reaper +0 -0
  13. data/bin/process/spawner +0 -0
  14. data/bin/runner +0 -0
  15. data/bin/server +0 -0
  16. data/config.ru +17 -0
  17. data/configs/apache.conf +0 -0
  18. data/configs/databases/ibm_db.yml +62 -0
  19. data/configs/databases/mysql.yml +3 -0
  20. data/configs/databases/postgresql.yml +3 -0
  21. data/configs/databases/sqlite2.yml +3 -0
  22. data/configs/databases/sqlite3.yml +3 -0
  23. data/configs/locales/en.yml +5 -0
  24. data/dispatches/dispatch.fcgi +1 -1
  25. data/dispatches/dispatch.rb +2 -2
  26. data/dispatches/gateway.cgi +2 -2
  27. data/doc/README_FOR_APP +5 -2
  28. data/doc/guides/html/2_2_release_notes.html +1185 -0
  29. data/doc/guides/html/actioncontroller_basics.html +1270 -0
  30. data/doc/guides/html/activerecord_validations_callbacks.html +749 -0
  31. data/doc/guides/html/association_basics.html +2585 -0
  32. data/doc/guides/html/authors.html +240 -0
  33. data/doc/guides/html/benchmarking_and_profiling.html +1018 -0
  34. data/doc/guides/html/caching_with_rails.html +583 -0
  35. data/doc/guides/html/command_line.html +434 -0
  36. data/doc/guides/html/configuring.html +438 -0
  37. data/doc/guides/html/creating_plugins.html +1594 -0
  38. data/doc/guides/html/debugging_rails_applications.html +1175 -0
  39. data/doc/guides/html/finders.html +1090 -0
  40. data/doc/guides/html/form_helpers.html +638 -0
  41. data/doc/guides/html/getting_started_with_rails.html +2066 -0
  42. data/doc/guides/html/index.html +349 -0
  43. data/doc/guides/html/layouts_and_rendering.html +1406 -0
  44. data/doc/guides/html/migrations.html +921 -0
  45. data/doc/guides/html/routing_outside_in.html +2213 -0
  46. data/doc/guides/html/security.html +1346 -0
  47. data/doc/guides/html/testing_rails_applications.html +1859 -0
  48. data/doc/guides/source/2_2_release_notes.txt +435 -0
  49. data/doc/guides/source/actioncontroller_basics/changelog.txt +5 -0
  50. data/doc/guides/source/actioncontroller_basics/cookies.txt +34 -0
  51. data/doc/guides/source/actioncontroller_basics/csrf.txt +32 -0
  52. data/doc/guides/source/actioncontroller_basics/filters.txt +119 -0
  53. data/doc/guides/source/actioncontroller_basics/http_auth.txt +24 -0
  54. data/doc/guides/source/actioncontroller_basics/index.txt +40 -0
  55. data/doc/guides/source/actioncontroller_basics/introduction.txt +9 -0
  56. data/doc/guides/source/actioncontroller_basics/methods.txt +39 -0
  57. data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +14 -0
  58. data/doc/guides/source/actioncontroller_basics/params.txt +93 -0
  59. data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +43 -0
  60. data/doc/guides/source/actioncontroller_basics/rescue.txt +67 -0
  61. data/doc/guides/source/actioncontroller_basics/session.txt +187 -0
  62. data/doc/guides/source/actioncontroller_basics/streaming.txt +91 -0
  63. data/doc/guides/source/actioncontroller_basics/verification.txt +40 -0
  64. data/doc/guides/source/active_record_basics.txt +181 -0
  65. data/doc/guides/source/activerecord_validations_callbacks.txt +404 -0
  66. data/doc/guides/source/association_basics.txt +1840 -0
  67. data/doc/guides/source/authors.txt +39 -0
  68. data/doc/guides/source/benchmarking_and_profiling/appendix.txt +95 -0
  69. data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +105 -0
  70. data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +185 -0
  71. data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +27 -0
  72. data/doc/guides/source/benchmarking_and_profiling/index.txt +242 -0
  73. data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +179 -0
  74. data/doc/guides/source/benchmarking_and_profiling/statistics.txt +57 -0
  75. data/doc/guides/source/caching_with_rails.txt +367 -0
  76. data/doc/guides/source/command_line.txt +147 -0
  77. data/doc/guides/source/configuring.txt +225 -0
  78. data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +191 -0
  79. data/doc/guides/source/creating_plugins/appendix.txt +46 -0
  80. data/doc/guides/source/creating_plugins/controllers.txt +59 -0
  81. data/doc/guides/source/creating_plugins/core_ext.txt +123 -0
  82. data/doc/guides/source/creating_plugins/custom_route.txt +69 -0
  83. data/doc/guides/source/creating_plugins/gem.txt +1 -0
  84. data/doc/guides/source/creating_plugins/generator_method.txt +89 -0
  85. data/doc/guides/source/creating_plugins/helpers.txt +51 -0
  86. data/doc/guides/source/creating_plugins/index.txt +52 -0
  87. data/doc/guides/source/creating_plugins/migration_generator.txt +156 -0
  88. data/doc/guides/source/creating_plugins/models.txt +76 -0
  89. data/doc/guides/source/creating_plugins/odds_and_ends.txt +69 -0
  90. data/doc/guides/source/creating_plugins/test_setup.txt +230 -0
  91. data/doc/guides/source/debugging_rails_applications.txt +733 -0
  92. data/doc/guides/source/finders.txt +668 -0
  93. data/doc/guides/source/form_helpers.txt +345 -0
  94. data/doc/guides/source/getting_started_with_rails.txt +1256 -0
  95. data/doc/guides/source/images/belongs_to.png +0 -0
  96. data/doc/guides/source/images/bullet.gif +0 -0
  97. data/doc/guides/source/images/csrf.png +0 -0
  98. data/doc/guides/source/images/habtm.png +0 -0
  99. data/doc/guides/source/images/has_many.png +0 -0
  100. data/doc/guides/source/images/has_many_through.png +0 -0
  101. data/doc/guides/source/images/has_one.png +0 -0
  102. data/doc/guides/source/images/has_one_through.png +0 -0
  103. data/doc/guides/source/images/header_backdrop.png +0 -0
  104. data/doc/guides/source/images/icons/README +5 -0
  105. data/doc/guides/source/images/icons/callouts/1.png +0 -0
  106. data/doc/guides/source/images/icons/callouts/10.png +0 -0
  107. data/doc/guides/source/images/icons/callouts/11.png +0 -0
  108. data/doc/guides/source/images/icons/callouts/12.png +0 -0
  109. data/doc/guides/source/images/icons/callouts/13.png +0 -0
  110. data/doc/guides/source/images/icons/callouts/14.png +0 -0
  111. data/doc/guides/source/images/icons/callouts/15.png +0 -0
  112. data/doc/guides/source/images/icons/callouts/2.png +0 -0
  113. data/doc/guides/source/images/icons/callouts/3.png +0 -0
  114. data/doc/guides/source/images/icons/callouts/4.png +0 -0
  115. data/doc/guides/source/images/icons/callouts/5.png +0 -0
  116. data/doc/guides/source/images/icons/callouts/6.png +0 -0
  117. data/doc/guides/source/images/icons/callouts/7.png +0 -0
  118. data/doc/guides/source/images/icons/callouts/8.png +0 -0
  119. data/doc/guides/source/images/icons/callouts/9.png +0 -0
  120. data/doc/guides/source/images/icons/caution.png +0 -0
  121. data/doc/guides/source/images/icons/example.png +0 -0
  122. data/doc/guides/source/images/icons/home.png +0 -0
  123. data/doc/guides/source/images/icons/important.png +0 -0
  124. data/doc/guides/source/images/icons/next.png +0 -0
  125. data/doc/guides/source/images/icons/note.png +0 -0
  126. data/doc/guides/source/images/icons/prev.png +0 -0
  127. data/doc/guides/source/images/icons/tip.png +0 -0
  128. data/doc/guides/source/images/icons/up.png +0 -0
  129. data/doc/guides/source/images/icons/warning.png +0 -0
  130. data/doc/guides/source/images/polymorphic.png +0 -0
  131. data/doc/guides/source/images/rails_logo_remix.gif +0 -0
  132. data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
  133. data/doc/guides/source/images/session_fixation.png +0 -0
  134. data/doc/guides/source/index.txt +118 -0
  135. data/doc/guides/source/layouts_and_rendering.txt +982 -0
  136. data/doc/guides/source/migrations/anatomy_of_a_migration.txt +85 -0
  137. data/doc/guides/source/migrations/changelog.txt +5 -0
  138. data/doc/guides/source/migrations/creating_a_migration.txt +109 -0
  139. data/doc/guides/source/migrations/foreign_keys.txt +8 -0
  140. data/doc/guides/source/migrations/index.txt +22 -0
  141. data/doc/guides/source/migrations/rakeing_around.txt +111 -0
  142. data/doc/guides/source/migrations/scheming.txt +47 -0
  143. data/doc/guides/source/migrations/using_models_in_migrations.txt +46 -0
  144. data/doc/guides/source/migrations/writing_a_migration.txt +159 -0
  145. data/doc/guides/source/routing_outside_in.txt +986 -0
  146. data/doc/guides/source/security.txt +984 -0
  147. data/doc/guides/source/stylesheets/base.css +358 -0
  148. data/doc/guides/source/stylesheets/forms.css +35 -0
  149. data/doc/guides/source/stylesheets/more.css +82 -0
  150. data/doc/guides/source/templates/guides.html.erb +97 -0
  151. data/doc/guides/source/templates/inline.css +165 -0
  152. data/doc/guides/source/testing_rails_applications.txt +995 -0
  153. data/environments/boot.rb +2 -2
  154. data/environments/environment.rb +9 -1
  155. data/environments/production.rb +3 -1
  156. data/helpers/performance_test.rb +9 -0
  157. data/html/500.html +4 -1
  158. data/html/javascripts/controls.js +72 -72
  159. data/html/javascripts/dragdrop.js +165 -164
  160. data/html/javascripts/effects.js +173 -165
  161. data/html/javascripts/prototype.js +362 -267
  162. data/lib/commands/console.rb +13 -0
  163. data/lib/commands/dbconsole.rb +2 -2
  164. data/lib/commands/ncgi/listener +2 -2
  165. data/lib/commands/ncgi/tracker +2 -2
  166. data/lib/commands/plugin.rb +41 -24
  167. data/lib/commands/process/spawner.rb +4 -4
  168. data/lib/commands/runner.rb +1 -1
  169. data/lib/commands/server.rb +11 -1
  170. data/lib/commands/servers/thin.rb +25 -0
  171. data/lib/fcgi_handler.rb +1 -3
  172. data/lib/initializer.rb +162 -39
  173. data/lib/performance_test_help.rb +5 -0
  174. data/lib/rails/gem_builder.rb +3 -3
  175. data/lib/rails/gem_dependency.rb +155 -33
  176. data/lib/rails/mongrel_server/commands.rb +1 -1
  177. data/lib/rails/plugin.rb +10 -2
  178. data/lib/rails/rack.rb +6 -0
  179. data/lib/rails/rack/logger.rb +28 -0
  180. data/lib/rails/rack/static.rb +35 -0
  181. data/lib/rails/vendor_gem_source_index.rb +140 -0
  182. data/lib/rails/version.rb +1 -1
  183. data/lib/rails_generator/commands.rb +10 -16
  184. data/lib/rails_generator/generated_attribute.rb +4 -0
  185. data/lib/rails_generator/generators/applications/app/app_generator.rb +9 -3
  186. data/lib/rails_generator/generators/components/controller/controller_generator.rb +1 -1
  187. data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +1 -1
  188. data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +1 -1
  189. data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +2 -2
  190. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +1 -1
  191. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +2 -3
  192. data/lib/rails_generator/generators/components/model/model_generator.rb +1 -1
  193. data/lib/rails_generator/generators/components/model/templates/model.rb +3 -0
  194. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +1 -1
  195. data/lib/rails_generator/generators/components/observer/observer_generator.rb +1 -1
  196. data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +1 -1
  197. data/lib/rails_generator/generators/components/performance_test/USAGE +8 -0
  198. data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +16 -0
  199. data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +9 -0
  200. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +11 -11
  201. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +1 -0
  202. data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +3 -0
  203. data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +4 -4
  204. data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -2
  205. data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +1 -1
  206. data/lib/rails_generator/generators/components/scaffold/USAGE +9 -5
  207. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +10 -3
  208. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +7 -7
  209. data/lib/rails_generator/scripts.rb +1 -1
  210. data/lib/rails_generator/scripts/destroy.rb +6 -7
  211. data/lib/rails_generator/secret_key_generator.rb +5 -147
  212. data/lib/tasks/annotations.rake +8 -11
  213. data/lib/tasks/databases.rake +42 -15
  214. data/lib/tasks/documentation.rake +15 -0
  215. data/lib/tasks/framework.rake +5 -1
  216. data/lib/tasks/gems.rake +24 -8
  217. data/lib/tasks/misc.rake +3 -4
  218. data/lib/tasks/testing.rake +25 -4
  219. data/lib/test_help.rb +1 -2
  220. data/lib/webrick_server.rb +2 -11
  221. metadata +165 -9
@@ -67,7 +67,7 @@ module Rails
67
67
 
68
68
  class << self
69
69
  def rubygems_version
70
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
70
+ Gem::RubyGemsVersion rescue nil
71
71
  end
72
72
 
73
73
  def gem_version
@@ -82,7 +82,7 @@ module Rails
82
82
 
83
83
  def load_rubygems
84
84
  require 'rubygems'
85
- min_version = '1.1.1'
85
+ min_version = '1.3.1'
86
86
  unless rubygems_version >= min_version
87
87
  $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
88
  exit 1
@@ -22,8 +22,10 @@ Rails::Initializer.run do |config|
22
22
 
23
23
  # Specify gems that this application depends on.
24
24
  # They can then be installed with "rake gems:install" on new installations.
25
+ # You have to specify the :lib option for libraries, where the Gem name (sqlite3-ruby) differs from the file itself (sqlite3)
25
26
  # config.gem "bj"
26
27
  # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
28
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
27
29
  # config.gem "aws-s3", :lib => "aws/s3"
28
30
 
29
31
  # Only load the plugins named here, in the order given. By default, all plugins
@@ -43,6 +45,11 @@ Rails::Initializer.run do |config|
43
45
  # Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
44
46
  config.time_zone = 'UTC'
45
47
 
48
+ # The internationalization framework can be changed to have another default locale (standard is :en) or more load paths.
49
+ # All files from config/locales/*.rb,yml are added automatically.
50
+ # config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')]
51
+ # config.i18n.default_locale = :de
52
+
46
53
  # Your secret key for verifying cookie session data integrity.
47
54
  # If you change this key, all old sessions will become invalid!
48
55
  # Make sure the secret is at least 30 characters and all random,
@@ -63,5 +70,6 @@ Rails::Initializer.run do |config|
63
70
  # config.active_record.schema_format = :sql
64
71
 
65
72
  # Activate observers that should always be running
66
- # config.active_record.observers = :cacher, :garbage_collector
73
+ # Please note that observers generated using script/generate observer need to have an _observer suffix
74
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
67
75
  end
@@ -4,13 +4,15 @@
4
4
  # Code is not reloaded between requests
5
5
  config.cache_classes = true
6
6
 
7
+ # Enable threaded mode
8
+ # config.threadsafe!
9
+
7
10
  # Use a different logger for distributed setups
8
11
  # config.logger = SyslogLogger.new
9
12
 
10
13
  # Full error reports are disabled and caching is turned on
11
14
  config.action_controller.consider_all_requests_local = false
12
15
  config.action_controller.perform_caching = true
13
- config.action_view.cache_template_loading = true
14
16
 
15
17
  # Use a different cache store in production
16
18
  # config.cache_store = :mem_cache_store
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionController::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -25,6 +25,9 @@
25
25
  <div class="dialog">
26
26
  <h1>We're sorry, but something went wrong.</h1>
27
27
  <p>We've been notified about this issue and we'll take a look at it shortly.</p>
28
+ <p><small>(If you're the administrator of this website, then please read
29
+ the log file "<%= "<%s>" % "%=h RAILS_ENV %" %>.log"
30
+ to find out what went wrong.)</small></p>
28
31
  </div>
29
32
  </body>
30
- </html>
33
+ </html>
@@ -1,22 +1,22 @@
1
1
  // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
- // (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
3
- // (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
2
+ // (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
3
+ // (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
4
4
  // Contributors:
5
5
  // Richard Livsey
6
6
  // Rahul Bhargava
7
7
  // Rob Wills
8
- //
8
+ //
9
9
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
10
10
  // For details, see the script.aculo.us web site: http://script.aculo.us/
11
11
 
12
- // Autocompleter.Base handles all the autocompletion functionality
12
+ // Autocompleter.Base handles all the autocompletion functionality
13
13
  // that's independent of the data source for autocompletion. This
14
14
  // includes drawing the autocompletion menu, observing keyboard
15
15
  // and mouse events, and similar.
16
16
  //
17
- // Specific autocompleters need to provide, at the very least,
17
+ // Specific autocompleters need to provide, at the very least,
18
18
  // a getUpdatedChoices function that will be invoked every time
19
- // the text inside the monitored textbox changes. This method
19
+ // the text inside the monitored textbox changes. This method
20
20
  // should get the text for which to provide autocompletion by
21
21
  // invoking this.getToken(), NOT by directly accessing
22
22
  // this.element.value. This is to allow incremental tokenized
@@ -30,23 +30,23 @@
30
30
  // will incrementally autocomplete with a comma as the token.
31
31
  // Additionally, ',' in the above example can be replaced with
32
32
  // a token array, e.g. { tokens: [',', '\n'] } which
33
- // enables autocompletion on multiple tokens. This is most
34
- // useful when one of the tokens is \n (a newline), as it
33
+ // enables autocompletion on multiple tokens. This is most
34
+ // useful when one of the tokens is \n (a newline), as it
35
35
  // allows smart autocompletion after linebreaks.
36
36
 
37
37
  if(typeof Effect == 'undefined')
38
38
  throw("controls.js requires including script.aculo.us' effects.js library");
39
39
 
40
- var Autocompleter = { }
40
+ var Autocompleter = { };
41
41
  Autocompleter.Base = Class.create({
42
42
  baseInitialize: function(element, update, options) {
43
- element = $(element)
44
- this.element = element;
45
- this.update = $(update);
46
- this.hasFocus = false;
47
- this.changed = false;
48
- this.active = false;
49
- this.index = 0;
43
+ element = $(element);
44
+ this.element = element;
45
+ this.update = $(update);
46
+ this.hasFocus = false;
47
+ this.changed = false;
48
+ this.active = false;
49
+ this.index = 0;
50
50
  this.entryCount = 0;
51
51
  this.oldElementValue = this.element.value;
52
52
 
@@ -59,28 +59,28 @@ Autocompleter.Base = Class.create({
59
59
  this.options.tokens = this.options.tokens || [];
60
60
  this.options.frequency = this.options.frequency || 0.4;
61
61
  this.options.minChars = this.options.minChars || 1;
62
- this.options.onShow = this.options.onShow ||
63
- function(element, update){
62
+ this.options.onShow = this.options.onShow ||
63
+ function(element, update){
64
64
  if(!update.style.position || update.style.position=='absolute') {
65
65
  update.style.position = 'absolute';
66
66
  Position.clone(element, update, {
67
- setHeight: false,
67
+ setHeight: false,
68
68
  offsetTop: element.offsetHeight
69
69
  });
70
70
  }
71
71
  Effect.Appear(update,{duration:0.15});
72
72
  };
73
- this.options.onHide = this.options.onHide ||
73
+ this.options.onHide = this.options.onHide ||
74
74
  function(element, update){ new Effect.Fade(update,{duration:0.15}) };
75
75
 
76
- if(typeof(this.options.tokens) == 'string')
76
+ if(typeof(this.options.tokens) == 'string')
77
77
  this.options.tokens = new Array(this.options.tokens);
78
78
  // Force carriage returns as token delimiters anyway
79
79
  if (!this.options.tokens.include('\n'))
80
80
  this.options.tokens.push('\n');
81
81
 
82
82
  this.observer = null;
83
-
83
+
84
84
  this.element.setAttribute('autocomplete','off');
85
85
 
86
86
  Element.hide(this.update);
@@ -91,10 +91,10 @@ Autocompleter.Base = Class.create({
91
91
 
92
92
  show: function() {
93
93
  if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
94
- if(!this.iefix &&
94
+ if(!this.iefix &&
95
95
  (Prototype.Browser.IE) &&
96
96
  (Element.getStyle(this.update, 'position')=='absolute')) {
97
- new Insertion.After(this.update,
97
+ new Insertion.After(this.update,
98
98
  '<iframe id="' + this.update.id + '_iefix" '+
99
99
  'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
100
100
  'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
@@ -102,7 +102,7 @@ Autocompleter.Base = Class.create({
102
102
  }
103
103
  if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
104
104
  },
105
-
105
+
106
106
  fixIEOverlapping: function() {
107
107
  Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
108
108
  this.iefix.style.zIndex = 1;
@@ -150,15 +150,15 @@ Autocompleter.Base = Class.create({
150
150
  Event.stop(event);
151
151
  return;
152
152
  }
153
- else
154
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
153
+ else
154
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
155
155
  (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
156
156
 
157
157
  this.changed = true;
158
158
  this.hasFocus = true;
159
159
 
160
160
  if(this.observer) clearTimeout(this.observer);
161
- this.observer =
161
+ this.observer =
162
162
  setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
163
163
  },
164
164
 
@@ -170,35 +170,35 @@ Autocompleter.Base = Class.create({
170
170
 
171
171
  onHover: function(event) {
172
172
  var element = Event.findElement(event, 'LI');
173
- if(this.index != element.autocompleteIndex)
173
+ if(this.index != element.autocompleteIndex)
174
174
  {
175
175
  this.index = element.autocompleteIndex;
176
176
  this.render();
177
177
  }
178
178
  Event.stop(event);
179
179
  },
180
-
180
+
181
181
  onClick: function(event) {
182
182
  var element = Event.findElement(event, 'LI');
183
183
  this.index = element.autocompleteIndex;
184
184
  this.selectEntry();
185
185
  this.hide();
186
186
  },
187
-
187
+
188
188
  onBlur: function(event) {
189
189
  // needed to make click events working
190
190
  setTimeout(this.hide.bind(this), 250);
191
191
  this.hasFocus = false;
192
- this.active = false;
193
- },
194
-
192
+ this.active = false;
193
+ },
194
+
195
195
  render: function() {
196
196
  if(this.entryCount > 0) {
197
197
  for (var i = 0; i < this.entryCount; i++)
198
- this.index==i ?
199
- Element.addClassName(this.getEntry(i),"selected") :
198
+ this.index==i ?
199
+ Element.addClassName(this.getEntry(i),"selected") :
200
200
  Element.removeClassName(this.getEntry(i),"selected");
201
- if(this.hasFocus) {
201
+ if(this.hasFocus) {
202
202
  this.show();
203
203
  this.active = true;
204
204
  }
@@ -207,27 +207,27 @@ Autocompleter.Base = Class.create({
207
207
  this.hide();
208
208
  }
209
209
  },
210
-
210
+
211
211
  markPrevious: function() {
212
- if(this.index > 0) this.index--
212
+ if(this.index > 0) this.index--;
213
213
  else this.index = this.entryCount-1;
214
214
  this.getEntry(this.index).scrollIntoView(true);
215
215
  },
216
-
216
+
217
217
  markNext: function() {
218
- if(this.index < this.entryCount-1) this.index++
218
+ if(this.index < this.entryCount-1) this.index++;
219
219
  else this.index = 0;
220
220
  this.getEntry(this.index).scrollIntoView(false);
221
221
  },
222
-
222
+
223
223
  getEntry: function(index) {
224
224
  return this.update.firstChild.childNodes[index];
225
225
  },
226
-
226
+
227
227
  getCurrentEntry: function() {
228
228
  return this.getEntry(this.index);
229
229
  },
230
-
230
+
231
231
  selectEntry: function() {
232
232
  this.active = false;
233
233
  this.updateElement(this.getCurrentEntry());
@@ -244,7 +244,7 @@ Autocompleter.Base = Class.create({
244
244
  if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
245
245
  } else
246
246
  value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
247
-
247
+
248
248
  var bounds = this.getTokenBounds();
249
249
  if (bounds[0] != -1) {
250
250
  var newValue = this.element.value.substr(0, bounds[0]);
@@ -257,7 +257,7 @@ Autocompleter.Base = Class.create({
257
257
  }
258
258
  this.oldElementValue = this.element.value;
259
259
  this.element.focus();
260
-
260
+
261
261
  if (this.options.afterUpdateElement)
262
262
  this.options.afterUpdateElement(this.element, selectedElement);
263
263
  },
@@ -269,20 +269,20 @@ Autocompleter.Base = Class.create({
269
269
  Element.cleanWhitespace(this.update.down());
270
270
 
271
271
  if(this.update.firstChild && this.update.down().childNodes) {
272
- this.entryCount =
272
+ this.entryCount =
273
273
  this.update.down().childNodes.length;
274
274
  for (var i = 0; i < this.entryCount; i++) {
275
275
  var entry = this.getEntry(i);
276
276
  entry.autocompleteIndex = i;
277
277
  this.addObservers(entry);
278
278
  }
279
- } else {
279
+ } else {
280
280
  this.entryCount = 0;
281
281
  }
282
282
 
283
283
  this.stopIndicator();
284
284
  this.index = 0;
285
-
285
+
286
286
  if(this.entryCount==1 && this.options.autoSelect) {
287
287
  this.selectEntry();
288
288
  this.hide();
@@ -298,7 +298,7 @@ Autocompleter.Base = Class.create({
298
298
  },
299
299
 
300
300
  onObserverEvent: function() {
301
- this.changed = false;
301
+ this.changed = false;
302
302
  this.tokenBounds = null;
303
303
  if(this.getToken().length>=this.options.minChars) {
304
304
  this.getUpdatedChoices();
@@ -351,16 +351,16 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
351
351
 
352
352
  getUpdatedChoices: function() {
353
353
  this.startIndicator();
354
-
355
- var entry = encodeURIComponent(this.options.paramName) + '=' +
354
+
355
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
356
356
  encodeURIComponent(this.getToken());
357
357
 
358
358
  this.options.parameters = this.options.callback ?
359
359
  this.options.callback(this.element, entry) : entry;
360
360
 
361
- if(this.options.defaultParams)
361
+ if(this.options.defaultParams)
362
362
  this.options.parameters += '&' + this.options.defaultParams;
363
-
363
+
364
364
  new Ajax.Request(this.url, this.options);
365
365
  },
366
366
 
@@ -382,7 +382,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
382
382
  // - choices - How many autocompletion choices to offer
383
383
  //
384
384
  // - partialSearch - If false, the autocompleter will match entered
385
- // text only at the beginning of strings in the
385
+ // text only at the beginning of strings in the
386
386
  // autocomplete array. Defaults to true, which will
387
387
  // match text at the beginning of any *word* in the
388
388
  // strings in the autocomplete array. If you want to
@@ -399,7 +399,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
399
399
  // - ignoreCase - Whether to ignore case when autocompleting.
400
400
  // Defaults to true.
401
401
  //
402
- // It's possible to pass in a custom function as the 'selector'
402
+ // It's possible to pass in a custom function as the 'selector'
403
403
  // option, if you prefer to write your own autocompletion logic.
404
404
  // In that case, the other options above will not apply unless
405
405
  // you support them.
@@ -427,20 +427,20 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
427
427
  var entry = instance.getToken();
428
428
  var count = 0;
429
429
 
430
- for (var i = 0; i < instance.options.array.length &&
431
- ret.length < instance.options.choices ; i++) {
430
+ for (var i = 0; i < instance.options.array.length &&
431
+ ret.length < instance.options.choices ; i++) {
432
432
 
433
433
  var elem = instance.options.array[i];
434
- var foundPos = instance.options.ignoreCase ?
435
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
434
+ var foundPos = instance.options.ignoreCase ?
435
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
436
436
  elem.indexOf(entry);
437
437
 
438
438
  while (foundPos != -1) {
439
- if (foundPos == 0 && elem.length != entry.length) {
440
- ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
439
+ if (foundPos == 0 && elem.length != entry.length) {
440
+ ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
441
441
  elem.substr(entry.length) + "</li>");
442
442
  break;
443
- } else if (entry.length >= instance.options.partialChars &&
443
+ } else if (entry.length >= instance.options.partialChars &&
444
444
  instance.options.partialSearch && foundPos != -1) {
445
445
  if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
446
446
  partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
@@ -450,14 +450,14 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
450
450
  }
451
451
  }
452
452
 
453
- foundPos = instance.options.ignoreCase ?
454
- elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
453
+ foundPos = instance.options.ignoreCase ?
454
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
455
455
  elem.indexOf(entry, foundPos + 1);
456
456
 
457
457
  }
458
458
  }
459
459
  if (partial.length)
460
- ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
460
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
461
461
  return "<ul>" + ret.join('') + "</ul>";
462
462
  }
463
463
  }, options || { });
@@ -474,7 +474,7 @@ Field.scrollFreeActivate = function(field) {
474
474
  setTimeout(function() {
475
475
  Field.activate(field);
476
476
  }, 1);
477
- }
477
+ };
478
478
 
479
479
  Ajax.InPlaceEditor = Class.create({
480
480
  initialize: function(element, url, options) {
@@ -604,7 +604,7 @@ Ajax.InPlaceEditor = Class.create({
604
604
  this.triggerCallback('onEnterHover');
605
605
  },
606
606
  getText: function() {
607
- return this.element.innerHTML;
607
+ return this.element.innerHTML.unescapeHTML();
608
608
  },
609
609
  handleAJAXFailure: function(transport) {
610
610
  this.triggerCallback('onFailure', transport);
@@ -780,7 +780,7 @@ Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
780
780
  onSuccess: function(transport) {
781
781
  var js = transport.responseText.strip();
782
782
  if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
783
- throw 'Server returned an invalid collection representation.';
783
+ throw('Server returned an invalid collection representation.');
784
784
  this._collection = eval(js);
785
785
  this.checkForExternalText();
786
786
  }.bind(this),
@@ -937,7 +937,7 @@ Ajax.InPlaceCollectionEditor.DefaultOptions = {
937
937
  loadingCollectionText: 'Loading options...'
938
938
  };
939
939
 
940
- // Delayed observer, like Form.Element.Observer,
940
+ // Delayed observer, like Form.Element.Observer,
941
941
  // but waits for delay after last key input
942
942
  // Ideal for live-search fields
943
943
 
@@ -947,7 +947,7 @@ Form.Element.DelayedObserver = Class.create({
947
947
  this.element = $(element);
948
948
  this.callback = callback;
949
949
  this.timer = null;
950
- this.lastValue = $F(this.element);
950
+ this.lastValue = $F(this.element);
951
951
  Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
952
952
  },
953
953
  delayedListener: function(event) {
@@ -960,4 +960,4 @@ Form.Element.DelayedObserver = Class.create({
960
960
  this.timer = null;
961
961
  this.callback(this.element, $F(this.element));
962
962
  }
963
- });
963
+ });