disguise 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. data/README.rdoc +26 -24
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/app/models/domain_theme.rb +1 -1
  5. data/app/models/theme.rb +4 -4
  6. data/app/views/admin/themes/_theme.html.erb +3 -3
  7. data/app/views/admin/themes/edit.html.erb +9 -2
  8. data/config/locales/ar.yml +20 -0
  9. data/config/locales/bg.yml +20 -0
  10. data/config/locales/ca.yml +20 -0
  11. data/config/locales/cs.yml +20 -0
  12. data/{locales → config/locales}/da.yml +8 -8
  13. data/config/locales/de.yml +20 -0
  14. data/config/locales/el.yml +20 -0
  15. data/{locales → config/locales}/en.yml +0 -0
  16. data/config/locales/es.yml +20 -0
  17. data/config/locales/et.yml +20 -0
  18. data/config/locales/fa.yml +20 -0
  19. data/config/locales/fi.yml +20 -0
  20. data/{locales → config/locales}/fr.yml +8 -8
  21. data/config/locales/gl.yml +20 -0
  22. data/config/locales/hi.yml +20 -0
  23. data/config/locales/hr.yml +20 -0
  24. data/config/locales/hu.yml +20 -0
  25. data/config/locales/id.yml +20 -0
  26. data/config/locales/it.yml +20 -0
  27. data/config/locales/iw.yml +20 -0
  28. data/config/locales/ja.yml +20 -0
  29. data/config/locales/ko.yml +20 -0
  30. data/config/locales/lt.yml +20 -0
  31. data/config/locales/lv.yml +20 -0
  32. data/config/locales/mt.yml +20 -0
  33. data/config/locales/nl.yml +20 -0
  34. data/config/locales/no.yml +21 -0
  35. data/config/locales/pl.yml +20 -0
  36. data/config/locales/pt-PT.yml +20 -0
  37. data/{locales → config/locales}/pt.yml +0 -0
  38. data/config/locales/ro.yml +20 -0
  39. data/config/locales/ru.yml +20 -0
  40. data/config/locales/sk.yml +20 -0
  41. data/config/locales/sl.yml +20 -0
  42. data/{locales → config/locales}/sq.yml +7 -7
  43. data/config/locales/sr.yml +20 -0
  44. data/config/locales/sv.yml +20 -0
  45. data/config/locales/th.yml +20 -0
  46. data/config/locales/tl.yml +20 -0
  47. data/config/locales/tr.yml +20 -0
  48. data/config/locales/uk.yml +20 -0
  49. data/config/locales/vi.yml +20 -0
  50. data/config/locales/zh-CN.yml +20 -0
  51. data/config/locales/zh-TW.yml +20 -0
  52. data/config/locales/zh.yml +20 -0
  53. data/config/routes.rb +6 -0
  54. data/disguise.gemspec +157 -181
  55. data/lib/disguise.rb +2 -10
  56. data/lib/disguise/config.rb +22 -9
  57. data/lib/disguise/controllers/disguise_application.rb +58 -0
  58. data/lib/disguise/engine.rb +14 -0
  59. data/lib/tasks/diguise.rake +9 -0
  60. data/test/{rails_root → rails_test}/.gitignore +0 -0
  61. data/test/{rails_root → rails_test}/.rake_tasks +0 -0
  62. data/test/rails_test/Gemfile +18 -0
  63. data/test/rails_test/Gemfile.lock +114 -0
  64. data/test/{rails_root → rails_test}/Rakefile +2 -4
  65. data/test/{rails_root → rails_test}/app/controllers/admin/domain_themes_controller.rb +0 -0
  66. data/test/{rails_root → rails_test}/app/controllers/admin/themes_controller.rb +0 -0
  67. data/test/{rails_root → rails_test}/app/controllers/application_controller.rb +0 -0
  68. data/test/{rails_root → rails_test}/app/controllers/default_controller.rb +0 -0
  69. data/test/{rails_root → rails_test}/app/models/.keep +0 -0
  70. data/test/rails_test/app/models/user.rb +3 -0
  71. data/test/{rails_root → rails_test}/app/views/default/index.html.erb +0 -0
  72. data/test/{rails_root → rails_test}/app/views/layouts/default.html.erb +0 -0
  73. data/test/rails_test/config.ru +4 -0
  74. data/test/rails_test/config/application.rb +42 -0
  75. data/test/rails_test/config/boot.rb +13 -0
  76. data/test/rails_test/config/database.yml +14 -0
  77. data/test/rails_test/config/environment.rb +5 -0
  78. data/test/rails_test/config/environments/development.rb +26 -0
  79. data/test/rails_test/config/environments/production.rb +49 -0
  80. data/test/rails_test/config/environments/test.rb +35 -0
  81. data/test/rails_test/config/initializers/backtrace_silencers.rb +7 -0
  82. data/test/rails_test/config/initializers/disguise.rb +5 -0
  83. data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
  84. data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
  85. data/test/rails_test/config/initializers/secret_token.rb +7 -0
  86. data/test/rails_test/config/initializers/session_store.rb +8 -0
  87. data/test/rails_test/config/routes.rb +3 -0
  88. data/test/{rails_root → rails_test}/db/.keep +0 -0
  89. data/test/{rails_root → rails_test}/db/migrate/20090530170040_create_themes.rb +0 -0
  90. data/test/{rails_root → rails_test}/db/migrate/20090602041838_create_users.rb +0 -0
  91. data/test/{rails_root → rails_test}/db/migrate/20090606153236_create_domain_themes.rb +0 -0
  92. data/test/{rails_root → rails_test}/features/step_definitions/webrat_steps.rb +0 -0
  93. data/test/{rails_root → rails_test}/features/support/env.rb +0 -0
  94. data/test/{rails_root → rails_test}/public/.htaccess +0 -0
  95. data/test/rails_test/public/404.html +26 -0
  96. data/test/rails_test/public/422.html +26 -0
  97. data/test/rails_test/public/500.html +26 -0
  98. data/test/{rails_root → rails_test}/public/dispatch.rb +1 -1
  99. data/test/{rails_root → rails_test}/public/favicon.ico +0 -0
  100. data/test/{rails_root → rails_test}/public/images/blue/preview.gif +0 -0
  101. data/test/rails_test/public/images/rails.png +0 -0
  102. data/test/{rails_root → rails_test}/public/javascripts/application.js +0 -0
  103. data/test/{rails_root → rails_test}/public/javascripts/controls.js +75 -73
  104. data/test/{rails_root → rails_test}/public/javascripts/dragdrop.js +171 -169
  105. data/test/{rails_root → rails_test}/public/javascripts/effects.js +180 -177
  106. data/test/rails_test/public/javascripts/prototype.js +6001 -0
  107. data/test/rails_test/public/javascripts/rails.js +175 -0
  108. data/test/rails_test/public/robots.txt +5 -0
  109. data/test/{rails_root/public/stylesheets/.keep → rails_test/public/stylesheets/.gitkeep} +0 -0
  110. data/test/{rails_root/test/functional/.keep → rails_test/public/stylesheets/application.css} +0 -0
  111. data/test/rails_test/script/rails +6 -0
  112. data/test/{rails_root → rails_test}/test/factories.rb +0 -0
  113. data/test/{rails_root/test/integration → rails_test/test/functional}/.keep +0 -0
  114. data/test/{rails_root → rails_test}/test/functional/admin/domain_themes_controller_test.rb +6 -6
  115. data/test/{rails_root → rails_test}/test/functional/admin/themes_controller_test.rb +6 -6
  116. data/test/{rails_root → rails_test}/test/functional/default_controller_test.rb +2 -2
  117. data/test/{rails_root/test/mocks/development → rails_test/test/integration}/.keep +0 -0
  118. data/test/{rails_root → rails_test}/test/test_helper.rb +6 -9
  119. data/test/{rails_root/test/mocks/test → rails_test/test/unit}/.keep +0 -0
  120. data/test/{rails_root → rails_test}/test/unit/domain_theme_test.rb +2 -1
  121. data/test/{rails_root → rails_test}/test/unit/theme_test.rb +4 -2
  122. data/test/{rails_root → rails_test}/themes/blue/description.txt +0 -0
  123. data/test/{rails_root → rails_test}/themes/blue/locales/blue.yml +0 -0
  124. data/test/{rails_root → rails_test}/themes/blue/locales/en.yml +0 -0
  125. data/test/{rails_root → rails_test}/themes/blue/views/default/index.html.erb +0 -0
  126. data/test/{rails_root → rails_test}/themes/blue/views/layouts/default.html.erb +0 -0
  127. data/test/{rails_root → rails_test}/themes/blue/views/layouts/global/_footer.html.erb +0 -0
  128. data/test/{rails_root → rails_test}/themes/blue/views/layouts/global/_head.html.erb +0 -0
  129. data/test/{rails_root → rails_test}/themes/blue/views/layouts/global/_header.html.erb +0 -0
  130. data/test/{rails_root → rails_test}/themes/red/description.txt +0 -0
  131. data/test/{rails_root → rails_test}/themes/red/locales/en.yml +0 -0
  132. data/test/{rails_root → rails_test}/themes/red/views/layouts/default.html.erb +0 -0
  133. data/test/{rails_root → rails_test}/themes/red/views/layouts/global/_footer.html.erb +0 -0
  134. data/test/{rails_root → rails_test}/themes/red/views/layouts/global/_head.html.erb +0 -0
  135. data/test/{rails_root → rails_test}/themes/red/views/layouts/global/_header.html.erb +0 -0
  136. metadata +159 -183
  137. data/config/disguise_routes.rb +0 -7
  138. data/lib/action_controller/disguise_application.rb +0 -61
  139. data/lib/disguise/initialize_routes.rb +0 -8
  140. data/lib/disguise/tasks.rb +0 -34
  141. data/locales/ar.yml +0 -20
  142. data/locales/bg.yml +0 -20
  143. data/locales/ca.yml +0 -20
  144. data/locales/cs.yml +0 -20
  145. data/locales/de.yml +0 -20
  146. data/locales/el.yml +0 -20
  147. data/locales/es.yml +0 -20
  148. data/locales/et.yml +0 -20
  149. data/locales/fa.yml +0 -20
  150. data/locales/fi.yml +0 -20
  151. data/locales/gl.yml +0 -20
  152. data/locales/hi.yml +0 -20
  153. data/locales/hr.yml +0 -20
  154. data/locales/hu.yml +0 -20
  155. data/locales/id.yml +0 -20
  156. data/locales/it.yml +0 -20
  157. data/locales/iw.yml +0 -20
  158. data/locales/ja.yml +0 -20
  159. data/locales/ko.yml +0 -20
  160. data/locales/lt.yml +0 -20
  161. data/locales/lv.yml +0 -20
  162. data/locales/mt.yml +0 -20
  163. data/locales/nl.yml +0 -20
  164. data/locales/no.yml +0 -21
  165. data/locales/pl.yml +0 -20
  166. data/locales/pt-PT.yml +0 -20
  167. data/locales/ro.yml +0 -20
  168. data/locales/ru.yml +0 -20
  169. data/locales/sk.yml +0 -20
  170. data/locales/sl.yml +0 -20
  171. data/locales/sr.yml +0 -20
  172. data/locales/sv.yml +0 -20
  173. data/locales/th.yml +0 -20
  174. data/locales/tl.yml +0 -20
  175. data/locales/tr.yml +0 -20
  176. data/locales/uk.yml +0 -20
  177. data/locales/vi.yml +0 -20
  178. data/locales/zh-CN.yml +0 -20
  179. data/locales/zh-TW.yml +0 -20
  180. data/locales/zh.yml +0 -20
  181. data/rails/init.rb +0 -2
  182. data/tasks/rails.rake +0 -2
  183. data/test/rails_root/Capfile +0 -3
  184. data/test/rails_root/app/models/user.rb +0 -9
  185. data/test/rails_root/config/amazon_s3.yml +0 -14
  186. data/test/rails_root/config/boot.rb +0 -109
  187. data/test/rails_root/config/database.yml +0 -14
  188. data/test/rails_root/config/environment.rb +0 -21
  189. data/test/rails_root/config/environments/development.rb +0 -19
  190. data/test/rails_root/config/environments/production.rb +0 -1
  191. data/test/rails_root/config/environments/test.rb +0 -33
  192. data/test/rails_root/config/global_config.yml +0 -18
  193. data/test/rails_root/config/initializers/disguise.rb +0 -2
  194. data/test/rails_root/config/initializers/requires.rb +0 -13
  195. data/test/rails_root/config/initializers/s3_credentials.rb +0 -9
  196. data/test/rails_root/config/initializers/session_store.rb +0 -8
  197. data/test/rails_root/config/routes.rb +0 -7
  198. data/test/rails_root/public/404.html +0 -30
  199. data/test/rails_root/public/422.html +0 -30
  200. data/test/rails_root/public/500.html +0 -30
  201. data/test/rails_root/public/images/rails.png +0 -0
  202. data/test/rails_root/public/images/red/preview.gif +0 -0
  203. data/test/rails_root/public/javascripts/builder.js +0 -136
  204. data/test/rails_root/public/javascripts/prototype.js +0 -4225
  205. data/test/rails_root/public/javascripts/scriptaculous.js +0 -58
  206. data/test/rails_root/public/javascripts/slider.js +0 -277
  207. data/test/rails_root/public/javascripts/sound.js +0 -60
  208. data/test/rails_root/public/robots.txt +0 -1
  209. data/test/rails_root/public/stylesheets/themes/blue/styles.css +0 -1
  210. data/test/rails_root/public/stylesheets/themes/red/styles.css +0 -1
  211. data/test/rails_root/script/about +0 -3
  212. data/test/rails_root/script/breakpointer +0 -3
  213. data/test/rails_root/script/console +0 -3
  214. data/test/rails_root/script/create_project.rb +0 -52
  215. data/test/rails_root/script/cucumber +0 -7
  216. data/test/rails_root/script/dbconsole +0 -3
  217. data/test/rails_root/script/destroy +0 -3
  218. data/test/rails_root/script/generate +0 -3
  219. data/test/rails_root/script/performance/benchmarker +0 -3
  220. data/test/rails_root/script/performance/profiler +0 -3
  221. data/test/rails_root/script/performance/request +0 -3
  222. data/test/rails_root/script/plugin +0 -3
  223. data/test/rails_root/script/process/inspector +0 -3
  224. data/test/rails_root/script/process/reaper +0 -3
  225. data/test/rails_root/script/process/spawner +0 -3
  226. data/test/rails_root/script/runner +0 -3
  227. data/test/rails_root/script/server +0 -3
  228. data/test/rails_root/test/unit/.keep +0 -0
@@ -0,0 +1,35 @@
1
+ RailsTest::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,5 @@
1
+ Disguise.configure do |config|
2
+ config.use_domain_for_themes = false # Changing theme per domain can be expense so it's off by default
3
+ config.themes_enabled = true # Turns disguise off/on.
4
+ config.theme_full_base_path = File.join(::Rails.root.to_s, 'themes') # Full path to the themes folder
5
+ end
@@ -1,8 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Add new inflection rules using the following format
3
+ # Add new inflection rules using the following format
4
4
  # (all these examples are active by default):
5
- # Inflector.inflections do |inflect|
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
6
  # inflect.plural /^(ox)$/i, '\1en'
7
7
  # inflect.singular /^(ox)en/i, '\1'
8
8
  # inflect.irregular 'person', 'people'
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ RailsTest::Application.config.secret_token = 'ea55c4d5e105735fdfb1caec46711b3dd14ec976d0ba95b4c0f575cb046cc358bce7a335ee36eb29253fb680ef8b838d871f6baeff48220fee8e9e42ab84774b'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ RailsTest::Application.config.session_store :cookie_store, :key => '_uploader_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rake db:sessions:create")
8
+ # RailsTest::Application.config.session_store :active_record_store
@@ -0,0 +1,3 @@
1
+ RailsTest::Application.routes.draw do
2
+ match ':controller(/:action(/:id(.:format)))'
3
+ end
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -1,6 +1,6 @@
1
1
  #!/opt/local/bin/ruby
2
2
 
3
- require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
3
+ require File.dirname(__FILE__) + "/../config/environment" unless defined?(::Rails.root.to_s)
4
4
 
5
5
  # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
6
  # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
@@ -1,22 +1,24 @@
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)
1
+ // script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
2
+
3
+ // Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
+ // (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
5
+ // (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
4
6
  // Contributors:
5
7
  // Richard Livsey
6
8
  // Rahul Bhargava
7
9
  // Rob Wills
8
- //
10
+ //
9
11
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
10
12
  // For details, see the script.aculo.us web site: http://script.aculo.us/
11
13
 
12
- // Autocompleter.Base handles all the autocompletion functionality
14
+ // Autocompleter.Base handles all the autocompletion functionality
13
15
  // that's independent of the data source for autocompletion. This
14
16
  // includes drawing the autocompletion menu, observing keyboard
15
17
  // and mouse events, and similar.
16
18
  //
17
- // Specific autocompleters need to provide, at the very least,
19
+ // Specific autocompleters need to provide, at the very least,
18
20
  // a getUpdatedChoices function that will be invoked every time
19
- // the text inside the monitored textbox changes. This method
21
+ // the text inside the monitored textbox changes. This method
20
22
  // should get the text for which to provide autocompletion by
21
23
  // invoking this.getToken(), NOT by directly accessing
22
24
  // this.element.value. This is to allow incremental tokenized
@@ -30,23 +32,23 @@
30
32
  // will incrementally autocomplete with a comma as the token.
31
33
  // Additionally, ',' in the above example can be replaced with
32
34
  // 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
35
+ // enables autocompletion on multiple tokens. This is most
36
+ // useful when one of the tokens is \n (a newline), as it
35
37
  // allows smart autocompletion after linebreaks.
36
38
 
37
39
  if(typeof Effect == 'undefined')
38
40
  throw("controls.js requires including script.aculo.us' effects.js library");
39
41
 
40
- var Autocompleter = { }
42
+ var Autocompleter = { };
41
43
  Autocompleter.Base = Class.create({
42
44
  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;
45
+ element = $(element);
46
+ this.element = element;
47
+ this.update = $(update);
48
+ this.hasFocus = false;
49
+ this.changed = false;
50
+ this.active = false;
51
+ this.index = 0;
50
52
  this.entryCount = 0;
51
53
  this.oldElementValue = this.element.value;
52
54
 
@@ -59,28 +61,28 @@ Autocompleter.Base = Class.create({
59
61
  this.options.tokens = this.options.tokens || [];
60
62
  this.options.frequency = this.options.frequency || 0.4;
61
63
  this.options.minChars = this.options.minChars || 1;
62
- this.options.onShow = this.options.onShow ||
63
- function(element, update){
64
+ this.options.onShow = this.options.onShow ||
65
+ function(element, update){
64
66
  if(!update.style.position || update.style.position=='absolute') {
65
67
  update.style.position = 'absolute';
66
68
  Position.clone(element, update, {
67
- setHeight: false,
69
+ setHeight: false,
68
70
  offsetTop: element.offsetHeight
69
71
  });
70
72
  }
71
73
  Effect.Appear(update,{duration:0.15});
72
74
  };
73
- this.options.onHide = this.options.onHide ||
75
+ this.options.onHide = this.options.onHide ||
74
76
  function(element, update){ new Effect.Fade(update,{duration:0.15}) };
75
77
 
76
- if(typeof(this.options.tokens) == 'string')
78
+ if(typeof(this.options.tokens) == 'string')
77
79
  this.options.tokens = new Array(this.options.tokens);
78
80
  // Force carriage returns as token delimiters anyway
79
81
  if (!this.options.tokens.include('\n'))
80
82
  this.options.tokens.push('\n');
81
83
 
82
84
  this.observer = null;
83
-
85
+
84
86
  this.element.setAttribute('autocomplete','off');
85
87
 
86
88
  Element.hide(this.update);
@@ -91,10 +93,10 @@ Autocompleter.Base = Class.create({
91
93
 
92
94
  show: function() {
93
95
  if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
94
- if(!this.iefix &&
96
+ if(!this.iefix &&
95
97
  (Prototype.Browser.IE) &&
96
98
  (Element.getStyle(this.update, 'position')=='absolute')) {
97
- new Insertion.After(this.update,
99
+ new Insertion.After(this.update,
98
100
  '<iframe id="' + this.update.id + '_iefix" '+
99
101
  'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
100
102
  'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
@@ -102,7 +104,7 @@ Autocompleter.Base = Class.create({
102
104
  }
103
105
  if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
104
106
  },
105
-
107
+
106
108
  fixIEOverlapping: function() {
107
109
  Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
108
110
  this.iefix.style.zIndex = 1;
@@ -150,15 +152,15 @@ Autocompleter.Base = Class.create({
150
152
  Event.stop(event);
151
153
  return;
152
154
  }
153
- else
154
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
155
+ else
156
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
155
157
  (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
156
158
 
157
159
  this.changed = true;
158
160
  this.hasFocus = true;
159
161
 
160
162
  if(this.observer) clearTimeout(this.observer);
161
- this.observer =
163
+ this.observer =
162
164
  setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
163
165
  },
164
166
 
@@ -170,35 +172,35 @@ Autocompleter.Base = Class.create({
170
172
 
171
173
  onHover: function(event) {
172
174
  var element = Event.findElement(event, 'LI');
173
- if(this.index != element.autocompleteIndex)
175
+ if(this.index != element.autocompleteIndex)
174
176
  {
175
177
  this.index = element.autocompleteIndex;
176
178
  this.render();
177
179
  }
178
180
  Event.stop(event);
179
181
  },
180
-
182
+
181
183
  onClick: function(event) {
182
184
  var element = Event.findElement(event, 'LI');
183
185
  this.index = element.autocompleteIndex;
184
186
  this.selectEntry();
185
187
  this.hide();
186
188
  },
187
-
189
+
188
190
  onBlur: function(event) {
189
191
  // needed to make click events working
190
192
  setTimeout(this.hide.bind(this), 250);
191
193
  this.hasFocus = false;
192
- this.active = false;
193
- },
194
-
194
+ this.active = false;
195
+ },
196
+
195
197
  render: function() {
196
198
  if(this.entryCount > 0) {
197
199
  for (var i = 0; i < this.entryCount; i++)
198
- this.index==i ?
199
- Element.addClassName(this.getEntry(i),"selected") :
200
+ this.index==i ?
201
+ Element.addClassName(this.getEntry(i),"selected") :
200
202
  Element.removeClassName(this.getEntry(i),"selected");
201
- if(this.hasFocus) {
203
+ if(this.hasFocus) {
202
204
  this.show();
203
205
  this.active = true;
204
206
  }
@@ -207,27 +209,27 @@ Autocompleter.Base = Class.create({
207
209
  this.hide();
208
210
  }
209
211
  },
210
-
212
+
211
213
  markPrevious: function() {
212
- if(this.index > 0) this.index--
214
+ if(this.index > 0) this.index--;
213
215
  else this.index = this.entryCount-1;
214
216
  this.getEntry(this.index).scrollIntoView(true);
215
217
  },
216
-
218
+
217
219
  markNext: function() {
218
- if(this.index < this.entryCount-1) this.index++
220
+ if(this.index < this.entryCount-1) this.index++;
219
221
  else this.index = 0;
220
222
  this.getEntry(this.index).scrollIntoView(false);
221
223
  },
222
-
224
+
223
225
  getEntry: function(index) {
224
226
  return this.update.firstChild.childNodes[index];
225
227
  },
226
-
228
+
227
229
  getCurrentEntry: function() {
228
230
  return this.getEntry(this.index);
229
231
  },
230
-
232
+
231
233
  selectEntry: function() {
232
234
  this.active = false;
233
235
  this.updateElement(this.getCurrentEntry());
@@ -244,7 +246,7 @@ Autocompleter.Base = Class.create({
244
246
  if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
245
247
  } else
246
248
  value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
247
-
249
+
248
250
  var bounds = this.getTokenBounds();
249
251
  if (bounds[0] != -1) {
250
252
  var newValue = this.element.value.substr(0, bounds[0]);
@@ -257,7 +259,7 @@ Autocompleter.Base = Class.create({
257
259
  }
258
260
  this.oldElementValue = this.element.value;
259
261
  this.element.focus();
260
-
262
+
261
263
  if (this.options.afterUpdateElement)
262
264
  this.options.afterUpdateElement(this.element, selectedElement);
263
265
  },
@@ -269,20 +271,20 @@ Autocompleter.Base = Class.create({
269
271
  Element.cleanWhitespace(this.update.down());
270
272
 
271
273
  if(this.update.firstChild && this.update.down().childNodes) {
272
- this.entryCount =
274
+ this.entryCount =
273
275
  this.update.down().childNodes.length;
274
276
  for (var i = 0; i < this.entryCount; i++) {
275
277
  var entry = this.getEntry(i);
276
278
  entry.autocompleteIndex = i;
277
279
  this.addObservers(entry);
278
280
  }
279
- } else {
281
+ } else {
280
282
  this.entryCount = 0;
281
283
  }
282
284
 
283
285
  this.stopIndicator();
284
286
  this.index = 0;
285
-
287
+
286
288
  if(this.entryCount==1 && this.options.autoSelect) {
287
289
  this.selectEntry();
288
290
  this.hide();
@@ -298,7 +300,7 @@ Autocompleter.Base = Class.create({
298
300
  },
299
301
 
300
302
  onObserverEvent: function() {
301
- this.changed = false;
303
+ this.changed = false;
302
304
  this.tokenBounds = null;
303
305
  if(this.getToken().length>=this.options.minChars) {
304
306
  this.getUpdatedChoices();
@@ -351,16 +353,16 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
351
353
 
352
354
  getUpdatedChoices: function() {
353
355
  this.startIndicator();
354
-
355
- var entry = encodeURIComponent(this.options.paramName) + '=' +
356
+
357
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
356
358
  encodeURIComponent(this.getToken());
357
359
 
358
360
  this.options.parameters = this.options.callback ?
359
361
  this.options.callback(this.element, entry) : entry;
360
362
 
361
- if(this.options.defaultParams)
363
+ if(this.options.defaultParams)
362
364
  this.options.parameters += '&' + this.options.defaultParams;
363
-
365
+
364
366
  new Ajax.Request(this.url, this.options);
365
367
  },
366
368
 
@@ -382,7 +384,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
382
384
  // - choices - How many autocompletion choices to offer
383
385
  //
384
386
  // - partialSearch - If false, the autocompleter will match entered
385
- // text only at the beginning of strings in the
387
+ // text only at the beginning of strings in the
386
388
  // autocomplete array. Defaults to true, which will
387
389
  // match text at the beginning of any *word* in the
388
390
  // strings in the autocomplete array. If you want to
@@ -399,7 +401,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
399
401
  // - ignoreCase - Whether to ignore case when autocompleting.
400
402
  // Defaults to true.
401
403
  //
402
- // It's possible to pass in a custom function as the 'selector'
404
+ // It's possible to pass in a custom function as the 'selector'
403
405
  // option, if you prefer to write your own autocompletion logic.
404
406
  // In that case, the other options above will not apply unless
405
407
  // you support them.
@@ -427,20 +429,20 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
427
429
  var entry = instance.getToken();
428
430
  var count = 0;
429
431
 
430
- for (var i = 0; i < instance.options.array.length &&
431
- ret.length < instance.options.choices ; i++) {
432
+ for (var i = 0; i < instance.options.array.length &&
433
+ ret.length < instance.options.choices ; i++) {
432
434
 
433
435
  var elem = instance.options.array[i];
434
- var foundPos = instance.options.ignoreCase ?
435
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
436
+ var foundPos = instance.options.ignoreCase ?
437
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
436
438
  elem.indexOf(entry);
437
439
 
438
440
  while (foundPos != -1) {
439
- if (foundPos == 0 && elem.length != entry.length) {
440
- ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
441
+ if (foundPos == 0 && elem.length != entry.length) {
442
+ ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
441
443
  elem.substr(entry.length) + "</li>");
442
444
  break;
443
- } else if (entry.length >= instance.options.partialChars &&
445
+ } else if (entry.length >= instance.options.partialChars &&
444
446
  instance.options.partialSearch && foundPos != -1) {
445
447
  if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
446
448
  partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
@@ -450,14 +452,14 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
450
452
  }
451
453
  }
452
454
 
453
- foundPos = instance.options.ignoreCase ?
454
- elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
455
+ foundPos = instance.options.ignoreCase ?
456
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
455
457
  elem.indexOf(entry, foundPos + 1);
456
458
 
457
459
  }
458
460
  }
459
461
  if (partial.length)
460
- ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
462
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
461
463
  return "<ul>" + ret.join('') + "</ul>";
462
464
  }
463
465
  }, options || { });
@@ -474,7 +476,7 @@ Field.scrollFreeActivate = function(field) {
474
476
  setTimeout(function() {
475
477
  Field.activate(field);
476
478
  }, 1);
477
- }
479
+ };
478
480
 
479
481
  Ajax.InPlaceEditor = Class.create({
480
482
  initialize: function(element, url, options) {
@@ -604,7 +606,7 @@ Ajax.InPlaceEditor = Class.create({
604
606
  this.triggerCallback('onEnterHover');
605
607
  },
606
608
  getText: function() {
607
- return this.element.innerHTML;
609
+ return this.element.innerHTML.unescapeHTML();
608
610
  },
609
611
  handleAJAXFailure: function(transport) {
610
612
  this.triggerCallback('onFailure', transport);
@@ -780,7 +782,7 @@ Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
780
782
  onSuccess: function(transport) {
781
783
  var js = transport.responseText.strip();
782
784
  if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
783
- throw 'Server returned an invalid collection representation.';
785
+ throw('Server returned an invalid collection representation.');
784
786
  this._collection = eval(js);
785
787
  this.checkForExternalText();
786
788
  }.bind(this),
@@ -937,7 +939,7 @@ Ajax.InPlaceCollectionEditor.DefaultOptions = {
937
939
  loadingCollectionText: 'Loading options...'
938
940
  };
939
941
 
940
- // Delayed observer, like Form.Element.Observer,
942
+ // Delayed observer, like Form.Element.Observer,
941
943
  // but waits for delay after last key input
942
944
  // Ideal for live-search fields
943
945
 
@@ -947,7 +949,7 @@ Form.Element.DelayedObserver = Class.create({
947
949
  this.element = $(element);
948
950
  this.callback = callback;
949
951
  this.timer = null;
950
- this.lastValue = $F(this.element);
952
+ this.lastValue = $F(this.element);
951
953
  Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
952
954
  },
953
955
  delayedListener: function(event) {
@@ -960,4 +962,4 @@ Form.Element.DelayedObserver = Class.create({
960
962
  this.timer = null;
961
963
  this.callback(this.element, $F(this.element));
962
964
  }
963
- });
965
+ });