Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update with authlogic 2.0

  • Loading branch information...
commit a319babd522ea981415cffa2ce481899d5f56cc8 1 parent e1cd014
@binarylogic authored
Showing with 11,738 additions and 13,851 deletions.
  1. 0  app/controllers/{application.rb → application_controller.rb}
  2. +19 −14 app/controllers/users_controller.rb
  3. +2 −19 app/models/user.rb
  4. +1 −32 app/models/user_session.rb
  5. +3 −1 app/views/users/_form.erb
  6. +3 −2 config/boot.rb
  7. +3 −2 config/environment.rb
  8. +7 −3 db/migrate/20081103171327_create_users.rb
  9. +0 −19 db/migrate/20081119233359_add_users_openid_field.rb
  10. +72 −72 public/javascripts/controls.js
  11. +165 −164 public/javascripts/dragdrop.js
  12. +173 −165 public/javascripts/effects.js
  13. +362 −267 public/javascripts/prototype.js
  14. +1 −1  test/fixtures/users.yml
  15. +6 −3 test/functional/users_controller_test.rb
  16. +4 −4 test/test_helper.rb
  17. +13 −0 vendor/plugins/open_id_authentication/README
  18. +1 −0  vendor/plugins/open_id_authentication/init.rb
  19. +79 −12 vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
  20. +7 −1 vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb
  21. +5 −5 vendor/plugins/open_id_authentication/test/normalize_test.rb
  22. +3 −0  vendor/plugins/open_id_authentication/test/test_helper.rb
  23. +3 −0  vendor/rails/.gitignore
  24. 0  vendor/rails/REVISION_dd2eb1ea7c34eb6496feaf7e42100f37a8dae76b
  25. +0 −81 vendor/rails/Rakefile
  26. +22 −8 vendor/rails/actionmailer/CHANGELOG
  27. +1 −1  vendor/rails/actionmailer/MIT-LICENSE
  28. +1 −1  vendor/rails/actionmailer/Rakefile
  29. +24 −14 vendor/rails/actionmailer/lib/action_mailer.rb
  30. +55 −35 vendor/rails/actionmailer/lib/action_mailer/base.rb
  31. +2 −0  vendor/rails/actionmailer/lib/action_mailer/helpers.rb
  32. +0 −2  vendor/rails/actionmailer/lib/action_mailer/mail_helper.rb
  33. +6 −9 vendor/rails/actionmailer/lib/action_mailer/part.rb
  34. +5 −1 vendor/rails/actionmailer/lib/action_mailer/part_container.rb
  35. +1 −1  vendor/rails/actionmailer/lib/action_mailer/quoting.rb
  36. +1 −1  vendor/rails/actionmailer/lib/action_mailer/test_case.rb
  37. +1 −0  vendor/rails/actionmailer/lib/action_mailer/test_helper.rb
  38. +0 −1  vendor/rails/actionmailer/lib/action_mailer/utils.rb
  39. +0 −14 vendor/rails/actionmailer/lib/action_mailer/vendor.rb
  40. +1 −1  vendor/rails/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb
  41. +10 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/text_format.rb
  42. +17 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail.rb
  43. +2 −2 vendor/rails/actionmailer/lib/action_mailer/version.rb
  44. +18 −11 vendor/rails/actionmailer/test/abstract_unit.rb
  45. +54 −0 vendor/rails/actionmailer/test/asset_host_test.rb
  46. +1 −0  vendor/rails/actionmailer/test/fixtures/asset_host_mailer/email_with_asset.html.erb
  47. +1 −0  vendor/rails/actionmailer/test/fixtures/auto_layout_mailer/multipart.text.html.erb
  48. +1 −0  vendor/rails/actionmailer/test/fixtures/auto_layout_mailer/multipart.text.plain.erb
  49. +1 −0  vendor/rails/actionmailer/test/fixtures/layouts/auto_layout_mailer.text.erb
  50. +45 −0 vendor/rails/actionmailer/test/mail_layout_test.rb
  51. +51 −7 vendor/rails/actionmailer/test/mail_service_test.rb
  52. +4 −3 vendor/rails/actionmailer/test/quoting_test.rb
  53. +5 −5 vendor/rails/actionmailer/test/test_helper_test.rb
  54. +519 −365 vendor/rails/actionpack/CHANGELOG
  55. +1 −1  vendor/rails/actionpack/MIT-LICENSE
  56. +21 −75 vendor/rails/actionpack/README
  57. +1 −1  vendor/rails/actionpack/Rakefile
  58. +80 −43 vendor/rails/actionpack/lib/action_controller.rb
  59. +0 −69 vendor/rails/actionpack/lib/action_controller/assertions.rb
  60. +1 −0  vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb
  61. +43 −16 vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb
  62. +1 −1  vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb
  63. +17 −12 vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb
  64. +1 −4 vendor/rails/actionpack/lib/action_controller/assertions/tag_assertions.rb
  65. +209 −95 vendor/rails/actionpack/lib/action_controller/base.rb
  66. +9 −9 vendor/rails/actionpack/lib/action_controller/benchmarking.rb
  67. +9 −11 vendor/rails/actionpack/lib/action_controller/caching.rb
  68. +11 −18 vendor/rails/actionpack/lib/action_controller/caching/actions.rb
  69. +28 −20 vendor/rails/actionpack/lib/action_controller/caching/fragments.rb
  70. +13 −15 vendor/rails/actionpack/lib/action_controller/caching/pages.rb
  71. +0 −18 vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb
  72. +2 −2 vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb
  73. +0 −1  vendor/rails/actionpack/lib/action_controller/cgi_ext.rb
  74. +2 −0  vendor/rails/actionpack/lib/action_controller/cgi_ext/cookie.rb
  75. +0 −53 vendor/rails/actionpack/lib/action_controller/cgi_ext/session.rb
  76. +54 −162 vendor/rails/actionpack/lib/action_controller/cgi_process.rb
  77. +0 −169 vendor/rails/actionpack/lib/action_controller/components.rb
  78. +13 −25 vendor/rails/actionpack/lib/action_controller/cookies.rb
  79. +48 −123 vendor/rails/actionpack/lib/action_controller/dispatcher.rb
  80. +52 −0 vendor/rails/actionpack/lib/action_controller/failsafe.rb
  81. +38 −47 vendor/rails/actionpack/lib/action_controller/flash.rb
  82. +13 −9 vendor/rails/actionpack/lib/action_controller/helpers.rb
  83. +203 −23 vendor/rails/actionpack/lib/action_controller/http_authentication.rb
  84. +129 −71 vendor/rails/actionpack/lib/action_controller/integration.rb
  85. +36 −39 vendor/rails/actionpack/lib/action_controller/layout.rb
  86. +119 −0 vendor/rails/actionpack/lib/action_controller/middleware_stack.rb
  87. +13 −0 vendor/rails/actionpack/lib/action_controller/middlewares.rb
  88. +19 −4 vendor/rails/actionpack/lib/action_controller/mime_responds.rb
  89. +27 −3 vendor/rails/actionpack/lib/action_controller/mime_type.rb
  90. +71 −0 vendor/rails/actionpack/lib/action_controller/params_parser.rb
  91. +0 −1  vendor/rails/actionpack/lib/action_controller/performance_test.rb
  92. +38 −31 vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb
  93. +0 −303 vendor/rails/actionpack/lib/action_controller/rack_process.rb
  94. +14 −0 vendor/rails/actionpack/lib/action_controller/reloader.rb
  95. +107 −489 vendor/rails/actionpack/lib/action_controller/request.rb
  96. +8 −40 vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb
  97. +0 −169 vendor/rails/actionpack/lib/action_controller/request_profiler.rb
  98. +55 −35 vendor/rails/actionpack/lib/action_controller/rescue.rb
  99. +93 −46 vendor/rails/actionpack/lib/action_controller/resources.rb
  100. +118 −57 vendor/rails/actionpack/lib/action_controller/response.rb
  101. +28 −0 vendor/rails/actionpack/lib/action_controller/rewindable_input.rb
  102. +7 −7 vendor/rails/actionpack/lib/action_controller/routing.rb
  103. +27 −31 vendor/rails/actionpack/lib/action_controller/routing/builder.rb
  104. +16 −8 vendor/rails/actionpack/lib/action_controller/routing/optimisations.rb
  105. +3 −10 vendor/rails/actionpack/lib/action_controller/routing/recognition_optimisation.rb
  106. +16 −6 vendor/rails/actionpack/lib/action_controller/routing/route.rb
  107. +88 −36 vendor/rails/actionpack/lib/action_controller/routing/route_set.rb
  108. +4 −0 vendor/rails/actionpack/lib/action_controller/routing/routing_ext.rb
  109. +68 −15 vendor/rails/actionpack/lib/action_controller/routing/segments.rb
  110. +181 −0 vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb
  111. +0 −340 vendor/rails/actionpack/lib/action_controller/session/active_record_store.rb
  112. +201 −147 vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb
  113. +0 −32 vendor/rails/actionpack/lib/action_controller/session/drb_server.rb
  114. +0 −35 vendor/rails/actionpack/lib/action_controller/session/drb_store.rb
  115. +36 −83 vendor/rails/actionpack/lib/action_controller/session/mem_cache_store.rb
  116. +26 −134 vendor/rails/actionpack/lib/action_controller/session_management.rb
  117. +24 −7 vendor/rails/actionpack/lib/action_controller/streaming.rb
  118. +2 −2 vendor/rails/actionpack/lib/action_controller/templates/rescues/diagnostics.erb
  119. +2 −2 vendor/rails/actionpack/lib/action_controller/templates/rescues/template_error.erb
  120. +87 −30 vendor/rails/actionpack/lib/action_controller/test_case.rb
  121. +150 −106 vendor/rails/actionpack/lib/action_controller/test_process.rb
  122. +44 −0 vendor/rails/actionpack/lib/action_controller/uploaded_file.rb
  123. +3 −6 vendor/rails/actionpack/lib/action_controller/url_rewriter.rb
  124. +16 −0 vendor/rails/actionpack/lib/action_controller/vendor/html-scanner.rb
  125. +1 −1  vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
  126. +1 −1  vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
  127. +89 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack.rb
  128. +22 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb
  129. +37 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb
  130. +37 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb
  131. +58 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb
  132. +124 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb
  133. +51 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb
  134. +55 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb
  135. +40 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb
  136. +480 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb
  137. +63 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/builder.rb
  138. +36 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/cascade.rb
  139. +49 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/chunked.rb
  140. +61 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb
  141. +45 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb
  142. +29 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb
  143. +23 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_type.rb
  144. +85 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb
  145. +153 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/directory.rb
  146. +88 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/file.rb
  147. +48 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler.rb
  148. +61 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb
  149. +8 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb
  150. +89 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb
  151. +55 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb
  152. +84 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb
  153. +59 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb
  154. +8 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb
  155. +18 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb
  156. +67 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb
  157. +19 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/head.rb
  158. +462 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb
  159. +65 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lobster.rb
  160. +16 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lock.rb
  161. +27 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb
  162. +204 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mime.rb
  163. +160 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb
  164. +57 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/recursive.rb
  165. +64 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/reloader.rb
  166. +241 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb
  167. +179 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/response.rb
  168. +142 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb
  169. +91 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb
  170. +109 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb
  171. +100 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb
  172. +349 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb
  173. +106 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb
  174. +38 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb
  175. +55 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb
  176. +392 −0 vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb
  177. +1 −1  vendor/rails/actionpack/lib/action_controller/verification.rb
  178. +1 −1  vendor/rails/actionpack/lib/action_pack.rb
  179. +2 −2 vendor/rails/actionpack/lib/action_pack/version.rb
  180. +23 −18 vendor/rails/actionpack/lib/action_view.rb
  181. +64 −71 vendor/rails/actionpack/lib/action_view/base.rb
  182. +38 −0 vendor/rails/actionpack/lib/action_view/erb/util.rb
  183. +24 −5 vendor/rails/actionpack/lib/action_view/helpers.rb
  184. +2 −2 vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb
  185. +232 −361 vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb
  186. +10 −5 vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb
  187. +26 −5 vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb
  188. +8 −0 vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb
  189. +87 −12 vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb
  190. +316 −78 vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb
  191. +160 −18 vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb
  192. +12 −6 vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb
  193. +0 −3  vendor/rails/actionpack/lib/action_view/helpers/javascript_helper.rb
  194. +0 −963 vendor/rails/actionpack/lib/action_view/helpers/javascripts/controls.js
  195. +0 −972 vendor/rails/actionpack/lib/action_view/helpers/javascripts/dragdrop.js
  196. +0 −1,120 vendor/rails/actionpack/lib/action_view/helpers/javascripts/effects.js
  197. +0 −4,221 vendor/rails/actionpack/lib/action_view/helpers/javascripts/prototype.js
  198. +31 −19 vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb
  199. +2 −12 vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb
  200. +0 −10 vendor/rails/actionpack/lib/action_view/helpers/sanitize_helper.rb
  201. +1 −0  vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
  202. +9 −8 vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb
  203. +106 −129 vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb
  204. +22 −5 vendor/rails/actionpack/lib/action_view/helpers/translation_helper.rb
  205. +38 −4 vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb
  206. +1 −1  vendor/rails/actionpack/lib/action_view/inline_template.rb
  207. +20 −1 vendor/rails/actionpack/lib/action_view/locale/{en-US.yml → en.yml}
  208. +47 −10 vendor/rails/actionpack/lib/action_view/partials.rb
  209. +28 −84 vendor/rails/actionpack/lib/action_view/paths.rb
  210. +117 −0 vendor/rails/actionpack/lib/action_view/reloadable_template.rb
  211. +28 −27 vendor/rails/actionpack/lib/action_view/renderable.rb
  212. +3 −4 vendor/rails/actionpack/lib/action_view/renderable_partial.rb
  213. +162 −32 vendor/rails/actionpack/lib/action_view/template.rb
  214. +8 −9 vendor/rails/actionpack/lib/action_view/template_error.rb
  215. +23 −3 vendor/rails/actionpack/lib/action_view/template_handler.rb
  216. +9 −6 vendor/rails/actionpack/lib/action_view/template_handlers.rb
  217. +2 −39 vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb
  218. +1 −0  vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb
  219. +27 −1 vendor/rails/actionpack/lib/action_view/test_case.rb
  220. +23 −17 vendor/rails/actionpack/test/abstract_unit.rb
  221. +5 −4 vendor/rails/actionpack/test/active_record_unit.rb
  222. +139 −106 vendor/rails/actionpack/test/activerecord/active_record_store_test.rb
  223. +5 −21 vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  224. +25 −23 vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb
  225. +3 −6 vendor/rails/actionpack/test/controller/addresses_render_test.rb
  226. +83 −70 vendor/rails/actionpack/test/controller/assert_select_test.rb
  227. +11 −13 vendor/rails/actionpack/test/controller/base_test.rb
  228. +3 −3 vendor/rails/actionpack/test/controller/benchmark_test.rb
  229. +29 −17 vendor/rails/actionpack/test/controller/caching_test.rb
  230. +3 −6 vendor/rails/actionpack/test/controller/capture_test.rb
  231. +0 −262 vendor/rails/actionpack/test/controller/cgi_test.rb
  232. +0 −156 vendor/rails/actionpack/test/controller/components_test.rb
  233. +3 −6 vendor/rails/actionpack/test/controller/content_type_test.rb
  234. +31 −66 vendor/rails/actionpack/test/controller/cookie_test.rb
  235. +9 −11 vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
  236. +23 −33 vendor/rails/actionpack/test/controller/dispatcher_test.rb
  237. +8 −0 vendor/rails/actionpack/test/controller/fake_models.rb
  238. +6 −2 vendor/rails/actionpack/test/controller/filters_test.rb
  239. +2 −6 vendor/rails/actionpack/test/controller/flash_test.rb
  240. +15 −1 vendor/rails/actionpack/test/controller/helper_test.rb
  241. +1 −1  vendor/rails/actionpack/test/controller/html-scanner/document_test.rb
  242. +5 −1 vendor/rails/actionpack/test/controller/html-scanner/sanitizer_test.rb
  243. +0 −54 vendor/rails/actionpack/test/controller/http_authentication_test.rb
  244. +88 −0 vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb
Sorry, we could not display the entire diff because too many files (1,306) changed.
View
0  app/controllers/application.rb → app/controllers/application_controller.rb
File renamed without changes
View
33 app/controllers/users_controller.rb
@@ -1,5 +1,5 @@
class UsersController < ApplicationController
- before_filter :require_no_user, :only => [:new, :create]
+ #before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => [:show, :edit, :update]
def new
@@ -8,29 +8,34 @@ def new
def create
@user = User.new(params[:user])
- if @user.save
- flash[:notice] = "Account registered!"
- redirect_back_or_default account_url
- else
- render :action => :new
+ @user.save do |result|
+ if result
+ flash[:notice] = "Account registered!"
+ redirect_back_or_default account_url
+ else
+ render :action => :new
+ end
end
end
def show
- @user = @current_user
+ @user = current_user
end
def edit
- @user = @current_user
+ @user = current_user
end
def update
- @user = @current_user # makes our views "cleaner" and more consistent
- if @user.update_attributes(params[:user])
- flash[:notice] = "Account updated!"
- redirect_to account_url
- else
- render :action => :edit
+ @user = current_user # makes our views "cleaner" and more consistent
+ @user.attributes = params[:user]
+ @user.save do |result|
+ if result
+ flash[:notice] = "Account updated!"
+ redirect_to account_url
+ else
+ render :action => :edit
+ end
end
end
end
View
21 app/models/user.rb
@@ -1,20 +1,3 @@
class User < ActiveRecord::Base
- acts_as_authentic :login_field_validation_options => {:if => :openid_identifier_blank?}, :password_field_validation_options => {:if => :openid_identifier_blank?}
-
- validate :normalize_openid_identifier
- validates_uniqueness_of :openid_identifier, :allow_blank => true
-
- # For acts_as_authentic configuration
- def openid_identifier_blank?
- openid_identifier.blank?
- end
-
- private
- def normalize_openid_identifier
- begin
- self.openid_identifier = OpenIdAuthentication.normalize_url(openid_identifier) if !openid_identifier.blank?
- rescue OpenIdAuthentication::InvalidOpenId => e
- errors.add(:openid_identifier, e.message)
- end
- end
-end
+ acts_as_authentic
+end
View
33 app/models/user_session.rb
@@ -1,34 +1,3 @@
class UserSession < Authlogic::Session::Base
- attr_accessor :openid_identifier
-
- def authenticating_with_openid?
- !openid_identifier.blank? || controller.params[:open_id_complete]
- end
-
- def save(&block)
- if authenticating_with_openid?
- raise ArgumentError.new("You must supply a block to authenticate with OpenID") unless block_given?
-
- controller.send(:authenticate_with_open_id, openid_identifier) do |result, openid_identifier|
- if !result.successful?
- errors.add_to_base(result.message)
- yield false
- return
- end
-
- record = klass.find_by_openid_identifier(openid_identifier)
-
- if !record
- errors.add(:openid_identifier, "did not match any users in our database, have you set up your account to use OpenID?")
- yield false
- return
- end
-
- self.unauthorized_record = record
- super
- end
- else
- super
- end
- end
+ logout_on_timeout true
end
View
4 app/views/users/_form.erb
@@ -9,4 +9,6 @@
<br />
<%= form.label :openid_identifier, "Or use OpenID instead of a standard login / password" %><br />
<%= form.text_field :openid_identifier %><br />
-<br />
+<br />
+<%= form.label :email %><br />
+<%= form.text_field :email %><br />
View
5 config/boot.rb
@@ -44,6 +44,7 @@ class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
+ Rails::GemDependency.add_frozen_gem_path
end
end
@@ -67,7 +68,7 @@ def load_rails_gem
class << self
def rubygems_version
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+ Gem::RubyGemsVersion rescue nil
end
def gem_version
@@ -82,7 +83,7 @@ def gem_version
def load_rubygems
require 'rubygems'
- min_version = '1.1.1'
+ min_version = '1.3.1'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
View
5 config/environment.rb
@@ -26,13 +26,14 @@
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "aws-s3", :lib => "aws/s3"
config.gem "authlogic"
+ config.gem "authlogic-oid", :lib => "authlogic_openid"
# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
- config.plugin_paths += ["#{RAILS_ROOT}/../../Libs"]
- config.plugins = [:authlogic, :open_id_authentication]
+ #config.plugin_paths += ["#{RAILS_ROOT}/../../Libs"]
+ #config.plugins = [:authlogic, :authlogic_openid, :open_id_authentication]
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
View
10 db/migrate/20081103171327_create_users.rb
@@ -2,9 +2,11 @@ class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.timestamps
- t.string :login, :null => false
- t.string :crypted_password, :null => false
- t.string :password_salt, :null => false
+ t.string :login
+ t.string :crypted_password
+ t.string :password_salt
+ t.string :email, :null => false
+ t.string :openid_identifier
t.string :persistence_token, :null => false
t.integer :login_count, :default => 0, :null => false
t.datetime :last_request_at
@@ -15,6 +17,8 @@ def self.up
end
add_index :users, :login
+ add_index :users, :email
+ add_index :users, :openid_identifier
add_index :users, :persistence_token
add_index :users, :last_request_at
end
View
19 db/migrate/20081119233359_add_users_openid_field.rb
@@ -1,19 +0,0 @@
-class AddUsersOpenidField < ActiveRecord::Migration
- def self.up
- add_column :users, :openid_identifier, :string
- add_index :users, :openid_identifier
-
- change_column :users, :login, :string, :default => nil, :null => true
- change_column :users, :crypted_password, :string, :default => nil, :null => true
- change_column :users, :password_salt, :string, :default => nil, :null => true
- end
-
- def self.down
- remove_column :users, :openid_identifier
-
- [:login, :crypted_password, :password_salt].each do |field|
- User.all(:conditions => "#{field} is NULL").each { |user| user.update_attribute(field, "") if user.send(field).nil? }
- change_column :users, field, :string, :default => "", :null => false
- end
- end
-end
View
144 public/javascripts/controls.js
@@ -1,22 +1,22 @@
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
+// (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
// Rob Wills
-//
+//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
-// Autocompleter.Base handles all the autocompletion functionality
+// Autocompleter.Base handles all the autocompletion functionality
// that's independent of the data source for autocompletion. This
// includes drawing the autocompletion menu, observing keyboard
// and mouse events, and similar.
//
-// Specific autocompleters need to provide, at the very least,
+// Specific autocompleters need to provide, at the very least,
// a getUpdatedChoices function that will be invoked every time
-// the text inside the monitored textbox changes. This method
+// the text inside the monitored textbox changes. This method
// should get the text for which to provide autocompletion by
// invoking this.getToken(), NOT by directly accessing
// this.element.value. This is to allow incremental tokenized
@@ -30,23 +30,23 @@
// will incrementally autocomplete with a comma as the token.
// Additionally, ',' in the above example can be replaced with
// a token array, e.g. { tokens: [',', '\n'] } which
-// enables autocompletion on multiple tokens. This is most
-// useful when one of the tokens is \n (a newline), as it
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks.
if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library");
-var Autocompleter = { }
+var Autocompleter = { };
Autocompleter.Base = Class.create({
baseInitialize: function(element, update, options) {
- element = $(element)
- this.element = element;
- this.update = $(update);
- this.hasFocus = false;
- this.changed = false;
- this.active = false;
- this.index = 0;
+ element = $(element);
+ this.element = element;
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
this.entryCount = 0;
this.oldElementValue = this.element.value;
@@ -59,28 +59,28 @@ Autocompleter.Base = Class.create({
this.options.tokens = this.options.tokens || [];
this.options.frequency = this.options.frequency || 0.4;
this.options.minChars = this.options.minChars || 1;
- this.options.onShow = this.options.onShow ||
- function(element, update){
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
if(!update.style.position || update.style.position=='absolute') {
update.style.position = 'absolute';
Position.clone(element, update, {
- setHeight: false,
+ setHeight: false,
offsetTop: element.offsetHeight
});
}
Effect.Appear(update,{duration:0.15});
};
- this.options.onHide = this.options.onHide ||
+ this.options.onHide = this.options.onHide ||
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
- if(typeof(this.options.tokens) == 'string')
+ if(typeof(this.options.tokens) == 'string')
this.options.tokens = new Array(this.options.tokens);
// Force carriage returns as token delimiters anyway
if (!this.options.tokens.include('\n'))
this.options.tokens.push('\n');
this.observer = null;
-
+
this.element.setAttribute('autocomplete','off');
Element.hide(this.update);
@@ -91,10 +91,10 @@ Autocompleter.Base = Class.create({
show: function() {
if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
- if(!this.iefix &&
+ if(!this.iefix &&
(Prototype.Browser.IE) &&
(Element.getStyle(this.update, 'position')=='absolute')) {
- new Insertion.After(this.update,
+ new Insertion.After(this.update,
'<iframe id="' + this.update.id + '_iefix" '+
'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
@@ -102,7 +102,7 @@ Autocompleter.Base = Class.create({
}
if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
},
-
+
fixIEOverlapping: function() {
Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
this.iefix.style.zIndex = 1;
@@ -150,15 +150,15 @@ Autocompleter.Base = Class.create({
Event.stop(event);
return;
}
- else
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
(Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
if(this.observer) clearTimeout(this.observer);
- this.observer =
+ this.observer =
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
},
@@ -170,35 +170,35 @@ Autocompleter.Base = Class.create({
onHover: function(event) {
var element = Event.findElement(event, 'LI');
- if(this.index != element.autocompleteIndex)
+ if(this.index != element.autocompleteIndex)
{
this.index = element.autocompleteIndex;
this.render();
}
Event.stop(event);
},
-
+
onClick: function(event) {
var element = Event.findElement(event, 'LI');
this.index = element.autocompleteIndex;
this.selectEntry();
this.hide();
},
-
+
onBlur: function(event) {
// needed to make click events working
setTimeout(this.hide.bind(this), 250);
this.hasFocus = false;
- this.active = false;
- },
-
+ this.active = false;
+ },
+
render: function() {
if(this.entryCount > 0) {
for (var i = 0; i < this.entryCount; i++)
- this.index==i ?
- Element.addClassName(this.getEntry(i),"selected") :
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
Element.removeClassName(this.getEntry(i),"selected");
- if(this.hasFocus) {
+ if(this.hasFocus) {
this.show();
this.active = true;
}
@@ -207,27 +207,27 @@ Autocompleter.Base = Class.create({
this.hide();
}
},
-
+
markPrevious: function() {
- if(this.index > 0) this.index--
+ if(this.index > 0) this.index--;
else this.index = this.entryCount-1;
this.getEntry(this.index).scrollIntoView(true);
},
-
+
markNext: function() {
- if(this.index < this.entryCount-1) this.index++
+ if(this.index < this.entryCount-1) this.index++;
else this.index = 0;
this.getEntry(this.index).scrollIntoView(false);
},
-
+
getEntry: function(index) {
return this.update.firstChild.childNodes[index];
},
-
+
getCurrentEntry: function() {
return this.getEntry(this.index);
},
-
+
selectEntry: function() {
this.active = false;
this.updateElement(this.getCurrentEntry());
@@ -244,7 +244,7 @@ Autocompleter.Base = Class.create({
if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
} else
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
-
+
var bounds = this.getTokenBounds();
if (bounds[0] != -1) {
var newValue = this.element.value.substr(0, bounds[0]);
@@ -257,7 +257,7 @@ Autocompleter.Base = Class.create({
}
this.oldElementValue = this.element.value;
this.element.focus();
-
+
if (this.options.afterUpdateElement)
this.options.afterUpdateElement(this.element, selectedElement);
},
@@ -269,20 +269,20 @@ Autocompleter.Base = Class.create({
Element.cleanWhitespace(this.update.down());
if(this.update.firstChild && this.update.down().childNodes) {
- this.entryCount =
+ this.entryCount =
this.update.down().childNodes.length;
for (var i = 0; i < this.entryCount; i++) {
var entry = this.getEntry(i);
entry.autocompleteIndex = i;
this.addObservers(entry);
}
- } else {
+ } else {
this.entryCount = 0;
}
this.stopIndicator();
this.index = 0;
-
+
if(this.entryCount==1 && this.options.autoSelect) {
this.selectEntry();
this.hide();
@@ -298,7 +298,7 @@ Autocompleter.Base = Class.create({
},
onObserverEvent: function() {
- this.changed = false;
+ this.changed = false;
this.tokenBounds = null;
if(this.getToken().length>=this.options.minChars) {
this.getUpdatedChoices();
@@ -351,16 +351,16 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
getUpdatedChoices: function() {
this.startIndicator();
-
- var entry = encodeURIComponent(this.options.paramName) + '=' +
+
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ?
this.options.callback(this.element, entry) : entry;
- if(this.options.defaultParams)
+ if(this.options.defaultParams)
this.options.parameters += '&' + this.options.defaultParams;
-
+
new Ajax.Request(this.url, this.options);
},
@@ -382,7 +382,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
// - choices - How many autocompletion choices to offer
//
// - partialSearch - If false, the autocompleter will match entered
-// text only at the beginning of strings in the
+// text only at the beginning of strings in the
// autocomplete array. Defaults to true, which will
// match text at the beginning of any *word* in the
// strings in the autocomplete array. If you want to
@@ -399,7 +399,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
// - ignoreCase - Whether to ignore case when autocompleting.
// Defaults to true.
//
-// It's possible to pass in a custom function as the 'selector'
+// It's possible to pass in a custom function as the 'selector'
// option, if you prefer to write your own autocompletion logic.
// In that case, the other options above will not apply unless
// you support them.
@@ -427,20 +427,20 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
var entry = instance.getToken();
var count = 0;
- for (var i = 0; i < instance.options.array.length &&
- ret.length < instance.options.choices ; i++) {
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
var elem = instance.options.array[i];
- var foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
elem.indexOf(entry);
while (foundPos != -1) {
- if (foundPos == 0 && elem.length != entry.length) {
- ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
+ if (foundPos == 0 && elem.length != entry.length) {
+ ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
elem.substr(entry.length) + "</li>");
break;
- } else if (entry.length >= instance.options.partialChars &&
+ } else if (entry.length >= instance.options.partialChars &&
instance.options.partialSearch && foundPos != -1) {
if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
@@ -450,14 +450,14 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
}
}
- foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
elem.indexOf(entry, foundPos + 1);
}
}
if (partial.length)
- ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
return "<ul>" + ret.join('') + "</ul>";
}
}, options || { });
@@ -474,7 +474,7 @@ Field.scrollFreeActivate = function(field) {
setTimeout(function() {
Field.activate(field);
}, 1);
-}
+};
Ajax.InPlaceEditor = Class.create({
initialize: function(element, url, options) {
@@ -604,7 +604,7 @@ Ajax.InPlaceEditor = Class.create({
this.triggerCallback('onEnterHover');
},
getText: function() {
- return this.element.innerHTML;
+ return this.element.innerHTML.unescapeHTML();
},
handleAJAXFailure: function(transport) {
this.triggerCallback('onFailure', transport);
@@ -780,7 +780,7 @@ Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
onSuccess: function(transport) {
var js = transport.responseText.strip();
if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
- throw 'Server returned an invalid collection representation.';
+ throw('Server returned an invalid collection representation.');
this._collection = eval(js);
this.checkForExternalText();
}.bind(this),
@@ -937,7 +937,7 @@ Ajax.InPlaceCollectionEditor.DefaultOptions = {
loadingCollectionText: 'Loading options...'
};
-// Delayed observer, like Form.Element.Observer,
+// Delayed observer, like Form.Element.Observer,
// but waits for delay after last key input
// Ideal for live-search fields
@@ -947,7 +947,7 @@ Form.Element.DelayedObserver = Class.create({
this.element = $(element);
this.callback = callback;
this.timer = null;
- this.lastValue = $F(this.element);
+ this.lastValue = $F(this.element);
Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
},
delayedListener: function(event) {
@@ -960,4 +960,4 @@ Form.Element.DelayedObserver = Class.create({
this.timer = null;
this.callback(this.element, $F(this.element));
}
-});
+});
View
329 public/javascripts/dragdrop.js
@@ -1,6 +1,6 @@
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
-//
+// (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
+//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -32,7 +32,7 @@ var Droppables = {
options._containers.push($(containment));
}
}
-
+
if(options.accept) options.accept = [options.accept].flatten();
Element.makePositioned(element); // fix IE
@@ -40,34 +40,34 @@ var Droppables = {
this.drops.push(options);
},
-
+
findDeepestChild: function(drops) {
deepest = drops[0];
-
+
for (i = 1; i < drops.length; ++i)
if (Element.isParent(drops[i].element, deepest.element))
deepest = drops[i];
-
+
return deepest;
},
isContained: function(element, drop) {
var containmentNode;
if(drop.tree) {
- containmentNode = element.treeNode;
+ containmentNode = element.treeNode;
} else {
containmentNode = element.parentNode;
}
return drop._containers.detect(function(c) { return containmentNode == c });
},
-
+
isAffected: function(point, element, drop) {
return (
(drop.element!=element) &&
((!drop._containers) ||
this.isContained(element, drop)) &&
((!drop.accept) ||
- (Element.classNames(element).detect(
+ (Element.classNames(element).detect(
function(v) { return drop.accept.include(v) } ) )) &&
Position.within(drop.element, point[0], point[1]) );
},
@@ -87,12 +87,12 @@ var Droppables = {
show: function(point, element) {
if(!this.drops.length) return;
var drop, affected = [];
-
+
this.drops.each( function(drop) {
if(Droppables.isAffected(point, element, drop))
affected.push(drop);
});
-
+
if(affected.length>0)
drop = Droppables.findDeepestChild(affected);
@@ -101,7 +101,7 @@ var Droppables = {
Position.within(drop.element, point[0], point[1]);
if(drop.onHover)
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
-
+
if (drop != this.last_active) Droppables.activate(drop);
}
},
@@ -112,8 +112,8 @@ var Droppables = {
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
if (this.last_active.onDrop) {
- this.last_active.onDrop(element, this.last_active.element, event);
- return true;
+ this.last_active.onDrop(element, this.last_active.element, event);
+ return true;
}
},
@@ -121,25 +121,25 @@ var Droppables = {
if(this.last_active)
this.deactivate(this.last_active);
}
-}
+};
var Draggables = {
drags: [],
observers: [],
-
+
register: function(draggable) {
if(this.drags.length == 0) {
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress = this.keyPress.bindAsEventListener(this);
-
+
Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress);
}
this.drags.push(draggable);
},
-
+
unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) {
@@ -148,24 +148,24 @@ var Draggables = {
Event.stopObserving(document, "keypress", this.eventKeypress);
}
},
-
+
activate: function(draggable) {
- if(draggable.options.delay) {
- this._timeout = setTimeout(function() {
- Draggables._timeout = null;
- window.focus();
- Draggables.activeDraggable = draggable;
- }.bind(this), draggable.options.delay);
+ if(draggable.options.delay) {
+ this._timeout = setTimeout(function() {
+ Draggables._timeout = null;
+ window.focus();
+ Draggables.activeDraggable = draggable;
+ }.bind(this), draggable.options.delay);
} else {
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
this.activeDraggable = draggable;
}
},
-
+
deactivate: function() {
this.activeDraggable = null;
},
-
+
updateDrag: function(event) {
if(!this.activeDraggable) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -173,36 +173,36 @@ var Draggables = {
// the same coordinates, prevent needless redrawing (moz bug?)
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
this._lastPointer = pointer;
-
+
this.activeDraggable.updateDrag(event, pointer);
},
-
+
endDrag: function(event) {
- if(this._timeout) {
- clearTimeout(this._timeout);
- this._timeout = null;
+ if(this._timeout) {
+ clearTimeout(this._timeout);
+ this._timeout = null;
}
if(!this.activeDraggable) return;
this._lastPointer = null;
this.activeDraggable.endDrag(event);
this.activeDraggable = null;
},
-
+
keyPress: function(event) {
if(this.activeDraggable)
this.activeDraggable.keyPress(event);
},
-
+
addObserver: function(observer) {
this.observers.push(observer);
this._cacheObserverCallbacks();
},
-
+
removeObserver: function(element) { // element instead of observer fixes mem leaks
this.observers = this.observers.reject( function(o) { return o.element==element });
this._cacheObserverCallbacks();
},
-
+
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
if(this[eventName+'Count'] > 0)
this.observers.each( function(o) {
@@ -210,7 +210,7 @@ var Draggables = {
});
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
},
-
+
_cacheObserverCallbacks: function() {
['onStart','onEnd','onDrag'].each( function(eventName) {
Draggables[eventName+'Count'] = Draggables.observers.select(
@@ -218,7 +218,7 @@ var Draggables = {
).length;
});
}
-}
+};
/*--------------------------------------------------------------------------*/
@@ -234,12 +234,12 @@ var Draggable = Class.create({
},
endeffect: function(element) {
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
- new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'},
- afterFinish: function(){
- Draggable._dragging[element] = false
+ afterFinish: function(){
+ Draggable._dragging[element] = false
}
- });
+ });
},
zindex: 1000,
revert: false,
@@ -250,57 +250,57 @@ var Draggable = Class.create({
snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
delay: 0
};
-
+
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
Object.extend(defaults, {
starteffect: function(element) {
element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true;
- new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
+ new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
}
});
-
+
var options = Object.extend(defaults, arguments[1] || { });
this.element = $(element);
-
+
if(options.handle && Object.isString(options.handle))
this.handle = this.element.down('.'+options.handle, 0);
-
+
if(!this.handle) this.handle = $(options.handle);
if(!this.handle) this.handle = this.element;
-
+
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
options.scroll = $(options.scroll);
this._isScrollChild = Element.childOf(this.element, options.scroll);
}
- Element.makePositioned(this.element); // fix IE
+ Element.makePositioned(this.element); // fix IE
this.options = options;
- this.dragging = false;
+ this.dragging = false;
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
Event.observe(this.handle, "mousedown", this.eventMouseDown);
-
+
Draggables.register(this);
},
-
+
destroy: function() {
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
Draggables.unregister(this);
},
-
+
currentDelta: function() {
return([
parseInt(Element.getStyle(this.element,'left') || '0'),
parseInt(Element.getStyle(this.element,'top') || '0')]);
},
-
+
initDrag: function(event) {
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
Draggable._dragging[this.element]) return;
- if(Event.isLeftClick(event)) {
+ if(Event.isLeftClick(event)) {
// abort on form elements, fixes a Firefox issue
var src = Event.element(event);
if((tag_name = src.tagName.toUpperCase()) && (
@@ -309,34 +309,34 @@ var Draggable = Class.create({
tag_name=='OPTION' ||
tag_name=='BUTTON' ||
tag_name=='TEXTAREA')) return;
-
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var pos = Position.cumulativeOffset(this.element);
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
-
+
Draggables.activate(this);
Event.stop(event);
}
},
-
+
startDrag: function(event) {
this.dragging = true;
if(!this.delta)
this.delta = this.currentDelta();
-
+
if(this.options.zindex) {
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
this.element.style.zIndex = this.options.zindex;
}
-
+
if(this.options.ghosting) {
this._clone = this.element.cloneNode(true);
- this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
- if (!this.element._originallyAbsolute)
+ this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
+ if (!this._originallyAbsolute)
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element);
}
-
+
if(this.options.scroll) {
if (this.options.scroll == window) {
var where = this._getWindowScroll(this.options.scroll);
@@ -347,28 +347,28 @@ var Draggable = Class.create({
this.originalScrollTop = this.options.scroll.scrollTop;
}
}
-
+
Draggables.notify('onStart', this, event);
-
+
if(this.options.starteffect) this.options.starteffect(this.element);
},
-
+
updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event);
-
+
if(!this.options.quiet){
Position.prepare();
Droppables.show(pointer, this.element);
}
-
+
Draggables.notify('onDrag', this, event);
-
+
this.draw(pointer);
if(this.options.change) this.options.change(this);
-
+
if(this.options.scroll) {
this.stopScrolling();
-
+
var p;
if (this.options.scroll == window) {
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
@@ -386,16 +386,16 @@ var Draggable = Class.create({
if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
this.startScrolling(speed);
}
-
+
// fix AppleWebKit rendering
if(Prototype.Browser.WebKit) window.scrollBy(0,0);
-
+
Event.stop(event);
},
-
+
finishDrag: function(event, success) {
this.dragging = false;
-
+
if(this.options.quiet){
Position.prepare();
var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -403,24 +403,24 @@ var Draggable = Class.create({
}
if(this.options.ghosting) {
- if (!this.element._originallyAbsolute)
+ if (!this._originallyAbsolute)
Position.relativize(this.element);
- delete this.element._originallyAbsolute;
+ delete this._originallyAbsolute;
Element.remove(this._clone);
this._clone = null;
}
- var dropped = false;
- if(success) {
- dropped = Droppables.fire(event, this.element);
- if (!dropped) dropped = false;
+ var dropped = false;
+ if(success) {
+ dropped = Droppables.fire(event, this.element);
+ if (!dropped) dropped = false;
}
if(dropped && this.options.onDropped) this.options.onDropped(this.element);
Draggables.notify('onEnd', this, event);
var revert = this.options.revert;
if(revert && Object.isFunction(revert)) revert = revert(this.element);
-
+
var d = this.currentDelta();
if(revert && this.options.reverteffect) {
if (dropped == 0 || revert != 'failure')
@@ -433,67 +433,67 @@ var Draggable = Class.create({
if(this.options.zindex)
this.element.style.zIndex = this.originalZ;
- if(this.options.endeffect)
+ if(this.options.endeffect)
this.options.endeffect(this.element);
-
+
Draggables.deactivate(this);
Droppables.reset();
},
-
+
keyPress: function(event) {
if(event.keyCode!=Event.KEY_ESC) return;
this.finishDrag(event, false);
Event.stop(event);
},
-
+
endDrag: function(event) {
if(!this.dragging) return;
this.stopScrolling();
this.finishDrag(event, true);
Event.stop(event);
},
-
+
draw: function(point) {
var pos = Position.cumulativeOffset(this.element);
if(this.options.ghosting) {
var r = Position.realOffset(this.element);
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
}
-
+
var d = this.currentDelta();
pos[0] -= d[0]; pos[1] -= d[1];
-
+
if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
}
-
- var p = [0,1].map(function(i){
- return (point[i]-pos[i]-this.offset[i])
+
+ var p = [0,1].map(function(i){
+ return (point[i]-pos[i]-this.offset[i])
}.bind(this));
-
+
if(this.options.snap) {
if(Object.isFunction(this.options.snap)) {
p = this.options.snap(p[0],p[1],this);
} else {
if(Object.isArray(this.options.snap)) {
p = p.map( function(v, i) {
- return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this))
+ return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
} else {
p = p.map( function(v) {
- return (v/this.options.snap).round()*this.options.snap }.bind(this))
+ return (v/this.options.snap).round()*this.options.snap }.bind(this));
}
}}
-
+
var style = this.element.style;
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
style.left = p[0] + "px";
if((!this.options.constraint) || (this.options.constraint=='vertical'))
style.top = p[1] + "px";
-
+
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
},
-
+
stopScrolling: function() {
if(this.scrollInterval) {
clearInterval(this.scrollInterval);
@@ -501,14 +501,14 @@ var Draggable = Class.create({
Draggables._lastScrollPointer = null;
}
},
-
+
startScrolling: function(speed) {
if(!(speed[0] || speed[1])) return;
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
this.lastScrolled = new Date();
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
},
-
+
scroll: function() {
var current = new Date();
var delta = current - this.lastScrolled;
@@ -524,7 +524,7 @@ var Draggable = Class.create({
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
}
-
+
Position.prepare();
Droppables.show(Draggables._lastPointer, this.element);
Draggables.notify('onDrag', this);
@@ -538,10 +538,10 @@ var Draggable = Class.create({
Draggables._lastScrollPointer[1] = 0;
this.draw(Draggables._lastScrollPointer);
}
-
+
if(this.options.change) this.options.change(this);
},
-
+
_getWindowScroll: function(w) {
var T, L, W, H;
with (w.document) {
@@ -560,7 +560,7 @@ var Draggable = Class.create({
H = documentElement.clientHeight;
} else {
W = body.offsetWidth;
- H = body.offsetHeight
+ H = body.offsetHeight;
}
}
return { top: T, left: L, width: W, height: H };
@@ -577,11 +577,11 @@ var SortableObserver = Class.create({
this.observer = observer;
this.lastValue = Sortable.serialize(this.element);
},
-
+
onStart: function() {
this.lastValue = Sortable.serialize(this.element);
},
-
+
onEnd: function() {
Sortable.unmark();
if(this.lastValue != Sortable.serialize(this.element))
@@ -591,11 +591,11 @@ var SortableObserver = Class.create({
var Sortable = {
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
-
+
sortables: { },
-
+
_findRootElement: function(element) {
- while (element.tagName.toUpperCase() != "BODY") {
+ while (element.tagName.toUpperCase() != "BODY") {
if(element.id && Sortable.sortables[element.id]) return element;
element = element.parentNode;
}
@@ -606,22 +606,23 @@ var Sortable = {
if(!element) return;
return Sortable.sortables[element.id];
},
-
+
destroy: function(element){
- var s = Sortable.options(element);
-
+ element = $(element);
+ var s = Sortable.sortables[element.id];
+
if(s) {
Draggables.removeObserver(s.element);
s.droppables.each(function(d){ Droppables.remove(d) });
s.draggables.invoke('destroy');
-
+
delete Sortable.sortables[s.element.id];
}
},
create: function(element) {
element = $(element);
- var options = Object.extend({
+ var options = Object.extend({
element: element,
tag: 'li', // assumes li children, override with tag: 'tagname'
dropOnEmpty: false,
@@ -635,17 +636,17 @@ var Sortable = {
delay: 0,
hoverclass: null,
ghosting: false,
- quiet: false,
+ quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
format: this.SERIALIZE_RULE,
-
- // these take arrays of elements or ids and can be
+
+ // these take arrays of elements or ids and can be
// used for better initialization performance
elements: false,
handles: false,
-
+
onChange: Prototype.emptyFunction,
onUpdate: Prototype.emptyFunction
}, arguments[1] || { });
@@ -682,24 +683,24 @@ var Sortable = {
if(options.zindex)
options_for_draggable.zindex = options.zindex;
- // build options for the droppables
+ // build options for the droppables
var options_for_droppable = {
overlap: options.overlap,
containment: options.containment,
tree: options.tree,
hoverclass: options.hoverclass,
onHover: Sortable.onHover
- }
-
+ };
+
var options_for_tree = {
onHover: Sortable.onEmptyHover,
overlap: options.overlap,
containment: options.containment,
hoverclass: options.hoverclass
- }
+ };
// fix for gecko engine
- Element.cleanWhitespace(element);
+ Element.cleanWhitespace(element);
options.draggables = [];
options.droppables = [];
@@ -712,14 +713,14 @@ var Sortable = {
(options.elements || this.findElements(element, options) || []).each( function(e,i) {
var handle = options.handles ? $(options.handles[i]) :
- (options.handle ? $(e).select('.' + options.handle)[0] : e);
+ (options.handle ? $(e).select('.' + options.handle)[0] : e);
options.draggables.push(
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
Droppables.add(e, options_for_droppable);
if(options.tree) e.treeNode = element;
- options.droppables.push(e);
+ options.droppables.push(e);
});
-
+
if(options.tree) {
(Sortable.findTreeElements(element, options) || []).each( function(e) {
Droppables.add(e, options_for_tree);
@@ -741,7 +742,7 @@ var Sortable = {
return Element.findChildren(
element, options.only, options.tree ? true : false, options.tag);
},
-
+
findTreeElements: function(element, options) {
return Element.findChildren(
element, options.only, options.tree ? true : false, options.treeTag);
@@ -758,7 +759,7 @@ var Sortable = {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, dropon);
- if(dropon.parentNode!=oldParentNode)
+ if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
@@ -769,26 +770,26 @@ var Sortable = {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, nextElement);
- if(dropon.parentNode!=oldParentNode)
+ if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
}
},
-
+
onEmptyHover: function(element, dropon, overlap) {
var oldParentNode = element.parentNode;
var droponOptions = Sortable.options(dropon);
-
+
if(!Element.isParent(dropon, element)) {
var index;
-
+
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
var child = null;
-
+
if(children) {
var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
-
+
for (index = 0; index < children.length; index += 1) {
if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
offset -= Element.offsetSize (children[index], droponOptions.overlap);
@@ -801,9 +802,9 @@ var Sortable = {
}
}
}
-
+
dropon.insertBefore(element, child);
-
+
Sortable.options(oldParentNode).onChange(element);
droponOptions.onChange(element);
}
@@ -816,34 +817,34 @@ var Sortable = {
mark: function(dropon, position) {
// mark on ghosting only
var sortable = Sortable.options(dropon.parentNode);
- if(sortable && !sortable.ghosting) return;
+ if(sortable && !sortable.ghosting) return;
if(!Sortable._marker) {
- Sortable._marker =
+ Sortable._marker =
($('dropmarker') || Element.extend(document.createElement('DIV'))).
hide().addClassName('dropmarker').setStyle({position:'absolute'});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
- }
+ }
var offsets = Position.cumulativeOffset(dropon);
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
-
+
if(position=='after')
- if(sortable.overlap == 'horizontal')
+ if(sortable.overlap == 'horizontal')
Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
else
Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
-
+
Sortable._marker.show();
},
-
+
_tree: function(element, options, parent) {
var children = Sortable.findElements(element, options) || [];
-
+
for (var i = 0; i < children.length; ++i) {
var match = children[i].id.match(options.format);
if (!match) continue;
-
+
var child = {
id: encodeURIComponent(match ? match[1] : null),
element: element,
@@ -851,16 +852,16 @@ var Sortable = {
children: [],
position: parent.children.length,
container: $(children[i]).down(options.treeTag)
- }
-
+ };
+
/* Get the element containing the children and recurse over it */
if (child.container)
- this._tree(child.container, options, child)
-
+ this._tree(child.container, options, child);
+
parent.children.push (child);
}
- return parent;
+ return parent;
},
tree: function(element) {
@@ -873,15 +874,15 @@ var Sortable = {
name: element.id,
format: sortableOptions.format
}, arguments[1] || { });
-
+
var root = {
id: null,
parent: null,
children: [],
container: element,
position: 0
- }
-
+ };
+
return Sortable._tree(element, options, root);
},
@@ -897,7 +898,7 @@ var Sortable = {
sequence: function(element) {
element = $(element);
var options = Object.extend(this.options(element), arguments[1] || { });
-
+
return $(this.findElements(element, options) || []).map( function(item) {
return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
});
@@ -906,14 +907,14 @@ var Sortable = {
setSequence: function(element, new_sequence) {
element = $(element);
var options = Object.extend(this.options(element), arguments[2] || { });
-
+
var nodeMap = { };
this.findElements(element, options).each( function(n) {
if (n.id.match(options.format))
nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
n.parentNode.removeChild(n);
});
-
+
new_sequence.each(function(ident) {
var n = nodeMap[ident];
if (n) {
@@ -922,16 +923,16 @@ var Sortable = {
}
});
},
-
+
serialize: function(element) {
element = $(element);
var options = Object.extend(Sortable.options(element), arguments[1] || { });
var name = encodeURIComponent(
(arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
-
+
if (options.tree) {
return Sortable.tree(element, arguments[1]).children.map( function (item) {
- return [name + Sortable._constructIndex(item) + "[id]=" +
+ return [name + Sortable._constructIndex(item) + "[id]=" +
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
}).flatten().join('&');
} else {
@@ -940,16 +941,16 @@ var Sortable = {
}).join('&');
}
}
-}
+};
// Returns true if child is contained within element
Element.isParent = function(child, element) {
if (!child.parentNode || child == element) return false;
if (child.parentNode == element) return true;
return Element.isParent(child.parentNode, element);
-}
+};
-Element.findChildren = function(element, only, recursive, tagName) {
+Element.findChildren = function(element, only, recursive, tagName) {
if(!element.hasChildNodes()) return null;
tagName = tagName.toUpperCase();
if(only) only = [only].flatten();
@@ -965,8 +966,8 @@ Element.findChildren = function(element, only, recursive, tagName) {
});
return (elements.length>0 ? elements.flatten() : []);
-}
+};
Element.offsetSize = function (element, type) {
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
-}
+};
View
338 public/javascripts/effects.js
@@ -3,46 +3,46 @@
// Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/)
// Martin Bialasinki
-//
+//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
-// For details, see the script.aculo.us web site: http://script.aculo.us/
+// For details, see the script.aculo.us web site: http://script.aculo.us/
-// converts rgb() and #xxx to #xxxxxx format,
-// returns self (or first argument) if not convertable
-String.prototype.parseColor = function() {
+// converts rgb() and #xxx to #xxxxxx format,
+// returns self (or first argument) if not convertable
+String.prototype.parseColor = function() {
var color = '#';
- if (this.slice(0,4) == 'rgb(') {
- var cols = this.slice(4,this.length-1).split(',');
- var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
- } else {
- if (this.slice(0,1) == '#') {
- if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
- if (this.length==7) color = this.toLowerCase();
- }
- }
- return (color.length==7 ? color : (arguments[0] || this));
+ if (this.slice(0,4) == 'rgb(') {
+ var cols = this.slice(4,this.length-1).split(',');
+ var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
+ } else {
+ if (this.slice(0,1) == '#') {
+ if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
+ if (this.length==7) color = this.toLowerCase();
+ }
+ }
+ return (color.length==7 ? color : (arguments[0] || this));
};
/*--------------------------------------------------------------------------*/
-Element.collectTextNodes = function(element) {
+Element.collectTextNodes = function(element) {
return $A($(element).childNodes).collect( function(node) {
- return (node.nodeType==3 ? node.nodeValue :
+ return (node.nodeType==3 ? node.nodeValue :
(node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
}).flatten().join('');
};
-Element.collectTextNodesIgnoreClass = function(element, className) {
+Element.collectTextNodesIgnoreClass = function(element, className) {
return $A($(element).childNodes).collect( function(node) {
- return (node.nodeType==3 ? node.nodeValue :
- ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
+ return (node.nodeType==3 ? node.nodeValue :
+ ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
Element.collectTextNodesIgnoreClass(node, className) : ''));
}).flatten().join('');
};
Element.setContentZoom = function(element, percent) {
- element = $(element);
- element.setStyle({fontSize: (percent/100) + 'em'});
+ element = $(element);
+ element.setStyle({fontSize: (percent/100) + 'em'});
if (Prototype.Browser.WebKit) window.scrollBy(0,0);
return element;
};
@@ -70,28 +70,23 @@ var Effect = {
Transitions: {
linear: Prototype.K,
sinoidal: function(pos) {
- return (-Math.cos(pos*Math.PI)/2) + 0.5;
+ return (-Math.cos(pos*Math.PI)/2) + .5;
},
reverse: function(pos) {
return 1-pos;
},
flicker: function(pos) {
- var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
+ var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4;
return pos > 1 ? 1 : pos;
},