community_engine 2.3.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/.travis.yml +5 -4
- data/CHANGELOG +43 -5
- data/Gemfile +1 -16
- data/README.markdown +22 -19
- data/UPGRADING.markdown +10 -0
- data/about.yml +1 -1
- data/app/assets/javascripts/community_engine.js +187 -18
- data/app/assets/javascripts/cropper.js +86 -565
- data/app/assets/javascripts/forum.js +26 -71
- data/app/assets/javascripts/jquery.migrate.js +521 -0
- data/app/assets/stylesheets/_colors.css.scss +100 -0
- data/app/assets/stylesheets/_font.css.scss +17 -0
- data/app/assets/stylesheets/_forms.css.scss +20 -0
- data/app/assets/stylesheets/_forum.css.scss +0 -0
- data/app/assets/stylesheets/_grid.css.scss +7 -0
- data/app/assets/stylesheets/_layers.css.scss +7 -0
- data/app/assets/stylesheets/_layout.css.scss +28 -0
- data/app/assets/stylesheets/community_engine.css.scss +18 -0
- data/app/assets/stylesheets/cropper.css +6 -182
- data/app/controllers/activities_controller.rb +10 -10
- data/app/controllers/admin_controller.rb +23 -23
- data/app/controllers/ads_controller.rb +16 -5
- data/app/controllers/albums_controller.rb +11 -5
- data/app/controllers/base_controller.rb +5 -8
- data/app/controllers/categories_controller.rb +31 -31
- data/app/controllers/clippings_controller.rb +18 -12
- data/app/controllers/comments_controller.rb +17 -8
- data/app/controllers/events_controller.rb +25 -21
- data/app/controllers/favorites_controller.rb +12 -12
- data/app/controllers/forums_controller.rb +20 -9
- data/app/controllers/friendships_controller.rb +41 -48
- data/app/controllers/homepage_features_controller.rb +11 -5
- data/app/controllers/invitations_controller.rb +15 -9
- data/app/controllers/messages_controller.rb +25 -19
- data/app/controllers/metro_areas_controller.rb +9 -3
- data/app/controllers/moderators_controller.rb +1 -1
- data/app/controllers/monitorships_controller.rb +2 -2
- data/app/controllers/pages_controller.rb +16 -4
- data/app/controllers/password_resets_controller.rb +0 -1
- data/app/controllers/photos_controller.rb +32 -30
- data/app/controllers/posts_controller.rb +33 -17
- data/app/controllers/rsvps_controller.rb +8 -4
- data/app/controllers/sb_posts_controller.rb +22 -18
- data/app/controllers/sessions_controller.rb +2 -1
- data/app/controllers/sitemap_controller.rb +8 -8
- data/app/controllers/statistics_controller.rb +9 -8
- data/app/controllers/tags_controller.rb +26 -24
- data/app/controllers/topics_controller.rb +10 -6
- data/app/controllers/users_controller.rb +63 -34
- data/app/helpers/base_helper.rb +119 -29
- data/app/helpers/friendships_helper.rb +3 -3
- data/app/helpers/posts_helper.rb +5 -7
- data/app/models/acts_as_taggable_on/tag.rb +12 -13
- data/app/models/ad.rb +2 -5
- data/app/models/album.rb +0 -2
- data/app/models/category.rb +6 -7
- data/app/models/clipping.rb +2 -5
- data/app/models/clipping_image.rb +5 -5
- data/app/models/comment.rb +4 -5
- data/app/models/country.rb +2 -4
- data/app/models/event.rb +1 -2
- data/app/models/favorite.rb +5 -10
- data/app/models/forum.rb +0 -2
- data/app/models/friendship.rb +3 -5
- data/app/models/friendship_status.rb +0 -2
- data/app/models/homepage_feature.rb +4 -6
- data/app/models/invitation.rb +6 -8
- data/app/models/message.rb +25 -26
- data/app/models/message_thread.rb +1 -1
- data/app/models/metro_area.rb +0 -2
- data/app/models/page.rb +0 -2
- data/app/models/photo.rb +8 -8
- data/app/models/poll.rb +7 -9
- data/app/models/post.rb +11 -15
- data/app/models/role.rb +1 -2
- data/app/models/rsvp.rb +0 -3
- data/app/models/sb_post.rb +14 -9
- data/app/models/state.rb +0 -2
- data/app/models/topic.rb +5 -6
- data/app/models/user.rb +50 -63
- data/app/models/vote.rb +1 -1
- data/app/views/activities/_activity.html.haml +9 -9
- data/app/views/activities/destroy.js.erb +1 -0
- data/app/views/activities/index.html.haml +13 -13
- data/app/views/activities/network.html.haml +10 -13
- data/app/views/admin/comments.html.haml +48 -70
- data/app/views/admin/events.html.haml +20 -27
- data/app/views/admin/messages.html.haml +2 -3
- data/app/views/admin/update.js.erb +1 -0
- data/app/views/admin/users.html.haml +51 -66
- data/app/views/ads/_form.html.haml +21 -0
- data/app/views/ads/edit.html.haml +6 -46
- data/app/views/ads/index.html.haml +25 -39
- data/app/views/ads/new.html.haml +4 -43
- data/app/views/ads/show.html.haml +18 -35
- data/app/views/albums/_form.html.haml +17 -12
- data/app/views/albums/edit.html.haml +12 -14
- data/app/views/albums/new.html.haml +8 -13
- data/app/views/albums/show.html.haml +25 -32
- data/app/views/base/_homepage_banner_message.html.haml +5 -19
- data/app/views/base/advertise.html.haml +5 -8
- data/app/views/base/site_index.html.haml +25 -27
- data/app/views/categories/_form.html.haml +8 -0
- data/app/views/categories/_menu_item.html.haml +13 -0
- data/app/views/categories/_tips.html.haml +2 -2
- data/app/views/categories/edit.html.haml +3 -33
- data/app/views/categories/index.html.haml +18 -28
- data/app/views/categories/new.html.haml +3 -8
- data/app/views/categories/show.html.haml +33 -36
- data/app/views/clippings/_clipping.html.haml +10 -17
- data/app/views/clippings/_favorite.html.haml +14 -0
- data/app/views/clippings/_form.html.haml +15 -0
- data/app/views/clippings/_images.html.haml +1 -1
- data/app/views/clippings/_menu_item.html.haml +6 -0
- data/app/views/clippings/edit.html.haml +12 -23
- data/app/views/clippings/index.html.haml +29 -30
- data/app/views/clippings/load_images_from_uri.js.erb +1 -0
- data/app/views/clippings/new.html.haml +9 -26
- data/app/views/clippings/new_clipping.html.haml +30 -77
- data/app/views/clippings/show.html.haml +48 -53
- data/app/views/clippings/site_index.html.haml +19 -32
- data/app/views/comments/_comment.html.haml +40 -40
- data/app/views/comments/_comment_form.html.haml +22 -46
- data/app/views/comments/_edit_form.html.haml +13 -28
- data/app/views/comments/create.js.erb +25 -0
- data/app/views/comments/destroy.js.erb +3 -0
- data/app/views/comments/edit.js.erb +11 -0
- data/app/views/comments/index.html.haml +12 -22
- data/app/views/comments/update.js.erb +14 -0
- data/app/views/events/_event.html.haml +26 -24
- data/app/views/events/_form.html.haml +18 -0
- data/app/views/events/_menu_item.html.haml +6 -0
- data/app/views/events/_subscribe.html.haml +1 -1
- data/app/views/events/edit.html.haml +7 -32
- data/app/views/events/index.html.haml +11 -19
- data/app/views/events/new.html.haml +2 -31
- data/app/views/events/show.html.haml +54 -24
- data/app/views/favorites/create.js.erb +10 -0
- data/app/views/favorites/destroy.js.erb +6 -0
- data/app/views/favorites/index.html.haml +6 -8
- data/app/views/forums/_form.html.haml +10 -20
- data/app/views/forums/_menu_item.html.haml +6 -0
- data/app/views/forums/edit.html.haml +8 -10
- data/app/views/forums/index.html.haml +56 -64
- data/app/views/forums/new.html.haml +5 -8
- data/app/views/forums/show.html.haml +65 -72
- data/app/views/friendships/_friendship.html.haml +14 -16
- data/app/views/friendships/accepted.html.haml +7 -11
- data/app/views/friendships/create.js.haml +1 -0
- data/app/views/friendships/denied.html.haml +4 -8
- data/app/views/friendships/pending.html.haml +4 -6
- data/app/views/friendships/show.html.haml +10 -11
- data/app/views/homepage_features/_form.html.haml +6 -0
- data/app/views/homepage_features/edit.html.haml +5 -30
- data/app/views/homepage_features/index.html.haml +22 -28
- data/app/views/homepage_features/new.html.haml +2 -30
- data/app/views/homepage_features/show.html.haml +27 -29
- data/app/views/invitations/index.html.haml +8 -0
- data/app/views/invitations/new.html.haml +21 -30
- data/app/views/kaminari/bootstrap/_first_page.html.erb +13 -0
- data/app/views/kaminari/bootstrap/_gap.html.erb +8 -0
- data/app/views/kaminari/bootstrap/_last_page.html.erb +13 -0
- data/app/views/kaminari/bootstrap/_next_page.html.erb +13 -0
- data/app/views/kaminari/bootstrap/_page.html.erb +12 -0
- data/app/views/kaminari/bootstrap/_paginator.html.erb +25 -0
- data/app/views/kaminari/bootstrap/_prev_page.html.erb +13 -0
- data/app/views/layouts/application.html.haml +26 -37
- data/app/views/messages/_form.html.haml +6 -12
- data/app/views/messages/_inbox.html.haml +34 -39
- data/app/views/messages/_menu_item.html.haml +11 -0
- data/app/views/messages/_sent.html.haml +22 -33
- data/app/views/messages/_sidebar_nav.html.haml +12 -9
- data/app/views/messages/index.html.haml +2 -2
- data/app/views/messages/new.html.haml +2 -9
- data/app/views/messages/show.html.haml +28 -36
- data/app/views/metro_areas/_form.html.haml +6 -0
- data/app/views/metro_areas/edit.html.haml +6 -14
- data/app/views/metro_areas/index.html.haml +19 -26
- data/app/views/metro_areas/new.html.haml +4 -14
- data/app/views/metro_areas/show.html.haml +13 -21
- data/app/views/moderators/_toggle.html.haml +6 -0
- data/app/views/moderators/create.js.erb +5 -0
- data/app/views/moderators/destroy.js.erb +1 -0
- data/app/views/monitorships/create.js.erb +1 -0
- data/app/views/monitorships/destroy.js.erb +1 -0
- data/app/views/pages/_form.html.haml +16 -23
- data/app/views/pages/edit.html.haml +2 -14
- data/app/views/pages/index.html.haml +32 -32
- data/app/views/pages/new.html.haml +5 -12
- data/app/views/pages/show.html.haml +4 -8
- data/app/views/password_resets/edit.html.haml +6 -14
- data/app/views/password_resets/new.html.haml +7 -11
- data/app/views/photo_manager/index.html.haml +45 -43
- data/app/views/photos/_form.html.haml +24 -0
- data/app/views/photos/_manage_photos.html.haml +14 -6
- data/app/views/photos/_show_image_list.html.haml +2 -2
- data/app/views/photos/create.js.erb +1 -0
- data/app/views/photos/edit.html.haml +10 -38
- data/app/views/photos/index.html.haml +20 -20
- data/app/views/photos/manage_photos.js.erb +5 -0
- data/app/views/photos/new.html.haml +11 -49
- data/app/views/photos/recent.html.haml +6 -6
- data/app/views/photos/show.html.haml +48 -52
- data/app/views/polls/_edit.html.haml +6 -10
- data/app/views/polls/_excerpt.html.haml +3 -4
- data/app/views/polls/_new.html.haml +10 -9
- data/app/views/polls/_poll_ui.html.haml +30 -34
- data/app/views/posts/_author_profile.html.haml +12 -11
- data/app/views/posts/_favorited_post.html.haml +8 -10
- data/app/views/posts/_form.html.haml +40 -0
- data/app/views/posts/_menu_item.html.haml +6 -0
- data/app/views/posts/_post.html.haml +27 -24
- data/app/views/posts/_send_to_friend.html.haml +26 -0
- data/app/views/posts/edit.html.haml +11 -48
- data/app/views/posts/featured.html.haml +7 -12
- data/app/views/posts/index.html.haml +14 -18
- data/app/views/posts/manage.html.haml +44 -59
- data/app/views/posts/new.html.haml +9 -64
- data/app/views/posts/popular.html.haml +25 -30
- data/app/views/posts/preview.html.haml +27 -26
- data/app/views/posts/recent.html.haml +20 -27
- data/app/views/posts/send_to_friend.js.erb +3 -0
- data/app/views/posts/show.html.haml +67 -76
- data/app/views/rsvps/_form.html.haml +3 -0
- data/app/views/rsvps/edit.html.haml +3 -9
- data/app/views/rsvps/new.html.haml +3 -9
- data/app/views/sb_posts/_dummy_forum_post.html.haml +13 -0
- data/app/views/sb_posts/_edit.html.haml +6 -0
- data/app/views/sb_posts/_edit_script.js.erb +14 -0
- data/app/views/sb_posts/_reply_form.html.haml +14 -35
- data/app/views/sb_posts/_reply_script.js.erb +13 -0
- data/app/views/sb_posts/_sb_post.html.haml +31 -33
- data/app/views/sb_posts/create.js.erb +30 -0
- data/app/views/sb_posts/destroy.js.erb +2 -0
- data/app/views/sb_posts/edit.html.erb +4 -4
- data/app/views/sb_posts/edit.js.erb +14 -0
- data/app/views/sb_posts/index.html.haml +3 -16
- data/app/views/sb_posts/monitored.html.erb +3 -9
- data/app/views/sb_posts/update.js.erb +11 -0
- data/app/views/sessions/_menu_item.html.haml +28 -0
- data/app/views/sessions/new.html.haml +19 -24
- data/app/views/shared/_add_friend_link.html.haml +9 -0
- data/app/views/shared/_admin_nav.html.haml +6 -8
- data/app/views/shared/_contact.html.haml +1 -1
- data/app/views/shared/_end_javascript.html.haml +4 -4
- data/app/views/shared/_explore.html.haml +7 -6
- data/app/views/shared/_footer_content.html.haml +12 -10
- data/app/views/shared/_footer_links.html.haml +18 -0
- data/app/views/shared/_friend_link.html.haml +25 -0
- data/app/views/shared/_header.html.haml +22 -42
- data/app/views/shared/_jumbotron.html.haml +3 -0
- data/app/views/shared/_load_tinymce.js.erb +15 -0
- data/app/views/shared/_location_chooser.html.haml +26 -17
- data/app/views/shared/_login_sidebar.html.haml +6 -5
- data/app/views/shared/_messages.html.haml +6 -8
- data/app/views/shared/_scripts_and_styles.html.haml +1 -2
- data/app/views/shared/_sidebar.html.haml +1 -0
- data/app/views/shared/_tag_auto_complete.html.haml +19 -0
- data/app/views/shared/_widget.html.haml +3 -0
- data/app/views/sitemap/index.html.haml +15 -20
- data/app/views/statistics/index.html.haml +32 -40
- data/app/views/tags/edit.html.haml +12 -19
- data/app/views/tags/index.html.haml +16 -25
- data/app/views/tags/manage.html.haml +24 -33
- data/app/views/tags/show.html.haml +52 -58
- data/app/views/topics/_form.html.haml +23 -25
- data/app/views/topics/_recent_topics_sidebar.haml +1 -1
- data/app/views/topics/edit.html.haml +7 -9
- data/app/views/topics/new.html.haml +6 -21
- data/app/views/topics/show.html.haml +48 -106
- data/app/views/user_notifier/follow_up_comment_notice.text.erb +1 -1
- data/app/views/user_notifier/message_notification.text.erb +1 -1
- data/app/views/user_notifier/new_forum_post_notice.text.erb +1 -1
- data/app/views/users/_dashboard_nav.html.haml +36 -39
- data/app/views/users/_menu_item.html.haml +6 -0
- data/app/views/users/_omniauth_connect.html.haml +4 -4
- data/app/views/users/_profile_completeness.html.haml +3 -3
- data/app/views/users/_profile_user_info_sidebar.html.haml +40 -43
- data/app/views/users/_search_options.html.haml +9 -7
- data/app/views/users/_sidebar_user.html.haml +1 -1
- data/app/views/users/_user.html.haml +27 -28
- data/app/views/users/crop_profile_photo.html.haml +30 -37
- data/app/views/users/dashboard.html.haml +37 -41
- data/app/views/users/edit.html.haml +53 -71
- data/app/views/users/edit_account.html.haml +44 -64
- data/app/views/users/forgot_username.html.haml +6 -12
- data/app/views/users/index.html.haml +4 -14
- data/app/views/users/invite.html.haml +14 -25
- data/app/views/users/new.html.haml +27 -48
- data/app/views/users/resend_activation.html.haml +7 -12
- data/app/views/users/show.html.haml +88 -90
- data/app/views/users/signup_completed.html.haml +7 -7
- data/app/views/users/statistics.html.haml +17 -18
- data/app/views/users/update.js.erb +1 -0
- data/app/views/users/upload_profile_photo.html.haml +10 -15
- data/app/views/users/welcome_about.html.haml +54 -61
- data/app/views/users/welcome_invite.html.haml +16 -25
- data/app/views/users/welcome_photo.html.haml +18 -27
- data/app/views/votes/create.js.erb +5 -0
- data/community_engine.gemspec +49 -41
- data/config/application_config.rb +13 -16
- data/config/initializers/mce_options.rb +9 -32
- data/config/initializers/recaptcha_constants.rb +2 -2
- data/config/locales/de-DE.yml +1 -17
- data/config/locales/en.yml +18 -32
- data/config/locales/es-AR.yml +2 -14
- data/config/locales/es-ES.yml +0 -6
- data/config/locales/es-MX.yml +1 -9
- data/config/locales/fr-FR.yml +3 -17
- data/config/locales/ja-JP.yml +2 -18
- data/config/locales/ru-RU.yml +3 -21
- data/config/locales/sr-CP.yml +0 -4
- data/config/locales/sv-SE.yml +3 -20
- data/config/routes.rb +37 -42
- data/db/migrate/016_add_metro_areas.rb +2 -2
- data/db/migrate/039_create_activities_table.rb +2 -2
- data/db/migrate/056_create_roles.rb +8 -6
- data/db/migrate/069_create_pages.rb +3 -3
- data/db/migrate/081_upgrade_to_friendly_id_5x.rb +25 -0
- data/db/migrate/082_upgrade_to_acts_as_commentable_4x.rb +29 -0
- data/lib/activity_tracker.rb +3 -0
- data/{vendor/plugins/activity_tracker/lib → lib/activity_tracker}/activity.rb +6 -6
- data/{vendor/plugins/activity_tracker/lib → lib/activity_tracker}/activity_tracker.rb +0 -0
- data/{vendor/plugins/acts_as_publishable/init.rb → lib/acts_as_publishable.rb} +1 -1
- data/{vendor/plugins/acts_as_publishable/lib → lib/acts_as_publishable}/acts_as_publishable.rb +3 -3
- data/lib/community_engine.rb +31 -9
- data/lib/community_engine/engine.rb +17 -1
- data/lib/community_engine/engines_extensions.rb +1 -3
- data/lib/community_engine/version.rb +3 -3
- data/{config/initializers → lib/paperclip_processors}/cropper.rb +3 -3
- data/lib/resource_feeder.rb +3 -0
- data/{vendor/plugins/resource_feeder/lib → lib}/resource_feeder/atom.rb +0 -0
- data/{vendor/plugins/resource_feeder/lib → lib}/resource_feeder/rss.rb +0 -0
- data/{vendor/plugins/white_list/init.rb → lib/white_list.rb} +1 -1
- data/{vendor/plugins/white_list/lib → lib/white_list}/white_list_helper.rb +0 -0
- data/test/fixtures/messages.yml +2 -2
- data/test/functional/admin_controller_test.rb +11 -11
- data/test/functional/ads_controller_test.rb +11 -11
- data/test/functional/albums_controller_test.rb +4 -4
- data/test/functional/categories_controller_test.rb +4 -4
- data/test/functional/clippings_controller_test.rb +4 -4
- data/test/functional/comments_controller_test.rb +20 -16
- data/test/functional/events_controller_test.rb +6 -6
- data/test/functional/forums_controller_test.rb +8 -8
- data/test/functional/friendships_controller_test.rb +13 -18
- data/test/functional/homepage_features_controller_test.rb +5 -5
- data/test/functional/messages_controller_test.rb +6 -2
- data/test/functional/metro_areas_controller_test.rb +7 -7
- data/test/functional/moderators_controller_test.rb +1 -1
- data/test/functional/pages_controller_test.rb +2 -2
- data/test/functional/password_reset_controller_test.rb +2 -2
- data/test/functional/photos_controller_test.rb +16 -15
- data/test/functional/posts_controller_test.rb +4 -4
- data/test/functional/rsvps_controller_test.rb +6 -6
- data/test/functional/sb_posts_controller_test.rb +53 -50
- data/test/functional/sessions_controller_test.rb +4 -1
- data/test/functional/tags_controller_test.rb +1 -1
- data/test/functional/topics_controller_test.rb +10 -10
- data/test/functional/users_controller_test.rb +32 -19
- data/test/functional/votes_controller_test.rb +1 -1
- data/test/test_helper.rb +3 -1
- data/test/testapp/config/application.rb +1 -9
- data/test/testapp/config/environments/development.rb +1 -2
- data/test/testapp/config/environments/production.rb +2 -0
- data/test/testapp/config/environments/test.rb +1 -2
- data/test/testapp/config/initializers/omniauth.rb +3 -3
- data/test/testapp/config/initializers/secret_token.rb +1 -0
- data/test/testapp/db/schema.rb +143 -152
- data/test/unit/category_test.rb +2 -2
- data/test/unit/comment_test.rb +64 -53
- data/test/unit/event_test.rb +4 -4
- data/test/unit/forum_test.rb +1 -1
- data/test/unit/message_test.rb +7 -1
- data/test/unit/page_test.rb +2 -2
- data/test/unit/post_test.rb +47 -47
- data/test/unit/sb_post_test.rb +24 -20
- data/test/unit/topic_test.rb +7 -6
- data/test/unit/user_test.rb +75 -52
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/jcrop/jquery.Jcrop.js +1699 -0
- data/vendor/assets/javascripts/jcrop/jquery.color.js +661 -0
- data/vendor/assets/javascripts/tag-it/tag-it.js +597 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/jcrop/Jcrop.gif +0 -0
- data/vendor/assets/stylesheets/jcrop/jquery.Jcrop.min.css +28 -0
- data/vendor/assets/stylesheets/tag-it/tag-it.css +69 -0
- data/vendor/assets/stylesheets/tag-it/tagit.ui-zendesk.css +107 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/README +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/Rakefile +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/generators/publishing/publishing_generator.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/generators/publishing/templates/migration.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/install.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/test/acts_as_publishable_test.rb +0 -0
- data/vendor/{plugins/activity_tracker → converted2.3plugins_to_lib_leftovers/acts_as_publishable}/uninstall.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/README +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/Rakefile +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/test/atom_feed_test.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/test/rss_feed_test.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/test/test_helper.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/white_list/README +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/white_list/Rakefile +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/white_list/test/white_list_test.rb +0 -0
- metadata +348 -302
- data/app/assets/images/bg_h6btn.gif +0 -0
- data/app/assets/images/bg_navbar.gif +0 -0
- data/app/assets/images/clearbits/bg_rounded.gif +0 -0
- data/app/assets/images/clearbits/comment.gif +0 -0
- data/app/assets/images/clearbits/lock.gif +0 -0
- data/app/assets/images/clearbits/smile.gif +0 -0
- data/app/assets/images/close.gif +0 -0
- data/app/assets/images/cropper/marqueeHoriz.gif +0 -0
- data/app/assets/images/cropper/marqueeVert.gif +0 -0
- data/app/assets/images/feed.png +0 -0
- data/app/assets/images/icons/31.png +0 -0
- data/app/assets/images/icons/52.png +0 -0
- data/app/assets/images/icons/accept.png +0 -0
- data/app/assets/images/icons/activity_default.png +0 -0
- data/app/assets/images/icons/add.png +0 -0
- data/app/assets/images/icons/book.png +0 -0
- data/app/assets/images/icons/bullet_arrow_down.png +0 -0
- data/app/assets/images/icons/bullet_arrow_down_50.png +0 -0
- data/app/assets/images/icons/clipping.png +0 -0
- data/app/assets/images/icons/comment.png +0 -0
- data/app/assets/images/icons/comments.png +0 -0
- data/app/assets/images/icons/date.png +0 -0
- data/app/assets/images/icons/delete.png +0 -0
- data/app/assets/images/icons/email.png +0 -0
- data/app/assets/images/icons/email_edit.png +0 -0
- data/app/assets/images/icons/email_go.png +0 -0
- data/app/assets/images/icons/email_open.png +0 -0
- data/app/assets/images/icons/group_go.png +0 -0
- data/app/assets/images/icons/heart.png +0 -0
- data/app/assets/images/icons/heart_add.png +0 -0
- data/app/assets/images/icons/heart_off.png +0 -0
- data/app/assets/images/icons/page_white.png +0 -0
- data/app/assets/images/icons/page_white_magnify.png +0 -0
- data/app/assets/images/icons/picture.png +0 -0
- data/app/assets/images/icons/poll.png +0 -0
- data/app/assets/images/icons/post.png +0 -0
- data/app/assets/images/icons/printer.png +0 -0
- data/app/assets/images/icons/rss.png +0 -0
- data/app/assets/images/icons/slides.png +0 -0
- data/app/assets/images/icons/tag_blue.png +0 -0
- data/app/assets/images/icons/user.png +0 -0
- data/app/assets/images/icons/user_add.png +0 -0
- data/app/assets/images/icons/user_edit.png +0 -0
- data/app/assets/images/icons/user_go.png +0 -0
- data/app/assets/images/icons/vote.png +0 -0
- data/app/assets/images/icons/world.png +0 -0
- data/app/assets/images/icons/wrench.png +0 -0
- data/app/assets/images/logo.gif +0 -0
- data/app/assets/images/reply_background.png +0 -0
- data/app/assets/images/search.gif +0 -0
- data/app/assets/images/thumb.gif +0 -0
- data/app/assets/javascripts/builder.js +0 -136
- data/app/assets/javascripts/calendarview.js +0 -839
- data/app/assets/javascripts/lightbox.js +0 -151
- data/app/assets/javascripts/prototip-min.js +0 -27
- data/app/assets/javascripts/rails.js +0 -202
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/css/advimage.css +0 -84
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/editor_plugin.js +0 -52
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/editor_plugin_src.js +0 -45
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/image.htm +0 -180
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/img/sample.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/js/functions.js +0 -508
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/langs/en.js +0 -3
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/langs/en_dlg.js +0 -43
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/editor_plugin.js +0 -8
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/editor_plugin_src.js +0 -1001
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress10.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress11.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress12.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress2.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress3.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress4.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress5.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress6.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress7.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress8.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress9.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/restore.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/restore.png +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/langs/da.js +0 -5
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/langs/en.js +0 -5
- data/app/assets/stylesheets/community_engine.css +0 -6
- data/app/assets/stylesheets/forum.css +0 -605
- data/app/assets/stylesheets/prototip.css +0 -73
- data/app/assets/stylesheets/reset-fonts-grids.css +0 -8
- data/app/assets/stylesheets/screen.css +0 -977
- data/app/helpers/monitorships_helper.rb +0 -2
- data/app/views/activities/_icon.html.haml +0 -14
- data/app/views/activities/destroy.js.rjs +0 -1
- data/app/views/clippings/_meta.html.haml +0 -26
- data/app/views/clippings/load_images_from_uri.js.rjs +0 -1
- data/app/views/comments/create.js.rjs +0 -20
- data/app/views/comments/edit.js.rjs +0 -7
- data/app/views/comments/update.js.rjs +0 -9
- data/app/views/favorites/create.js.rjs +0 -17
- data/app/views/favorites/destroy.js.rjs +0 -14
- data/app/views/favorites/show.html.haml +0 -13
- data/app/views/friendships/_friendships.html.erb +0 -14
- data/app/views/friendships/index.html.erb +0 -3
- data/app/views/friendships/index.xml.builder +0 -29
- data/app/views/invitations/index.html.erb +0 -16
- data/app/views/moderators/_toggle.html.erb +0 -14
- data/app/views/moderators/create.js.rjs +0 -5
- data/app/views/moderators/destroy.js.rjs +0 -1
- data/app/views/monitorships/create.js.rjs +0 -4
- data/app/views/monitorships/destroy.js.rjs +0 -4
- data/app/views/photos/manage_photos.js.rjs +0 -5
- data/app/views/polls/_polls_sidebar.html.haml +0 -8
- data/app/views/posts/_send_to_friend.html.erb +0 -29
- data/app/views/sb_posts/_dummy_forum_post.html.erb +0 -13
- data/app/views/sb_posts/_edit.html.erb +0 -31
- data/app/views/sb_posts/create.js.rjs +0 -16
- data/app/views/sb_posts/edit.js.rjs +0 -6
- data/app/views/sb_posts/update.js.rjs +0 -5
- data/app/views/shared/_user_menu.html.haml +0 -21
- data/app/views/votes/create.js.rjs +0 -6
- data/db/migrate/090_add_comment_role.rb +0 -15
- data/vendor/plugins/activity_tracker/README +0 -4
- data/vendor/plugins/activity_tracker/Rakefile +0 -22
- data/vendor/plugins/activity_tracker/generators/activity_migration/USAGE +0 -13
- data/vendor/plugins/activity_tracker/generators/activity_migration/activity_migration_generator.rb +0 -11
- data/vendor/plugins/activity_tracker/generators/activity_migration/templates/migration.rb +0 -17
- data/vendor/plugins/activity_tracker/init.rb +0 -1
- data/vendor/plugins/activity_tracker/install.rb +0 -1
- data/vendor/plugins/activity_tracker/tasks/activity_tracker_tasks.rake +0 -4
- data/vendor/plugins/activity_tracker/test/abstract_unit.rb +0 -47
- data/vendor/plugins/activity_tracker/test/activity_tracker_test.rb +0 -48
- data/vendor/plugins/activity_tracker/test/database.yml +0 -18
- data/vendor/plugins/activity_tracker/test/debug.log +0 -3329
- data/vendor/plugins/activity_tracker/test/fixtures/test_post.rb +0 -5
- data/vendor/plugins/activity_tracker/test/fixtures/test_posts.yml +0 -3
- data/vendor/plugins/activity_tracker/test/fixtures/test_user.rb +0 -4
- data/vendor/plugins/activity_tracker/test/fixtures/test_users.yml +0 -6
- data/vendor/plugins/activity_tracker/test/schema.rb +0 -21
- data/vendor/plugins/acts_as_list/README +0 -23
- data/vendor/plugins/acts_as_list/init.rb +0 -3
- data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +0 -256
- data/vendor/plugins/acts_as_list/test/list_test.rb +0 -332
- data/vendor/plugins/acts_as_publishable/uninstall.rb +0 -1
- data/vendor/plugins/auto_complete/README +0 -23
- data/vendor/plugins/auto_complete/Rakefile +0 -22
- data/vendor/plugins/auto_complete/init.rb +0 -2
- data/vendor/plugins/auto_complete/lib/auto_complete.rb +0 -47
- data/vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb +0 -143
- data/vendor/plugins/auto_complete/test/auto_complete_test.rb +0 -67
- data/vendor/plugins/enumerations_mixin/.gitignore +0 -1
- data/vendor/plugins/enumerations_mixin/Gemfile +0 -1
- data/vendor/plugins/enumerations_mixin/LICENSE +0 -20
- data/vendor/plugins/enumerations_mixin/README.md +0 -120
- data/vendor/plugins/enumerations_mixin/README_ENUMERATIONS +0 -163
- data/vendor/plugins/enumerations_mixin/Rakefile +0 -14
- data/vendor/plugins/enumerations_mixin/VERSION +0 -1
- data/vendor/plugins/enumerations_mixin/enumerations_mixin.gemspec +0 -44
- data/vendor/plugins/enumerations_mixin/examples/virtual_enumerations_sample.rb +0 -76
- data/vendor/plugins/enumerations_mixin/init.rb +0 -21
- data/vendor/plugins/enumerations_mixin/lib/active_record/acts/enumerated.rb +0 -180
- data/vendor/plugins/enumerations_mixin/lib/active_record/aggregations/has_enumerated.rb +0 -60
- data/vendor/plugins/enumerations_mixin/lib/active_record/virtual_enumerations.rb +0 -68
- data/vendor/plugins/enumerations_mixin/lib/enumerations_mixin.rb +0 -12
- data/vendor/plugins/enumerations_mixin/virtual_enumerations_sample.rb +0 -76
- data/vendor/plugins/prototype_legacy_helper/README.markdown +0 -13
- data/vendor/plugins/prototype_legacy_helper/init.rb +0 -1
- data/vendor/plugins/prototype_legacy_helper/lib/prototype_legacy_helper.rb +0 -432
- data/vendor/plugins/prototype_legacy_helper/test/test_prototype_helper.rb +0 -297
- data/vendor/plugins/resource_feeder/init.rb +0 -2
- data/vendor/plugins/resource_feeder/lib/resource_feeder.rb +0 -2
- data/vendor/plugins/respond_to_parent/MIT-LICENSE +0 -20
- data/vendor/plugins/respond_to_parent/README +0 -47
- data/vendor/plugins/respond_to_parent/Rakefile +0 -22
- data/vendor/plugins/respond_to_parent/init.rb +0 -1
- data/vendor/plugins/respond_to_parent/install.rb +0 -1
- data/vendor/plugins/respond_to_parent/lib/responds_to_parent.rb +0 -70
- data/vendor/plugins/respond_to_parent/test/responds_to_parent_test.rb +0 -10
- data/vendor/plugins/respond_to_parent/test/test_helper.rb +0 -6
- data/vendor/plugins/respond_to_parent/uninstall.rb +0 -1
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2005 Trevor Squires
|
|
2
|
-
# Released under the MIT License. See the LICENSE file for more details.
|
|
3
|
-
|
|
4
|
-
module ActiveRecord
|
|
5
|
-
module Aggregations # :nodoc:
|
|
6
|
-
module HasEnumerated # :nodoc:
|
|
7
|
-
def self.append_features(base)
|
|
8
|
-
super
|
|
9
|
-
base.extend(MacroMethods)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
module MacroMethods
|
|
13
|
-
def has_enumerated(part_id, options = {})
|
|
14
|
-
options.assert_valid_keys(:class_name, :foreign_key, :on_lookup_failure)
|
|
15
|
-
|
|
16
|
-
name = part_id.id2name
|
|
17
|
-
class_name = (options[:class_name] || name).to_s.camelize
|
|
18
|
-
foreign_key = (options[:foreign_key] || "#{name}_id").to_s
|
|
19
|
-
failure = options[:on_lookup_failure]
|
|
20
|
-
|
|
21
|
-
module_eval <<-end_eval
|
|
22
|
-
def #{name}
|
|
23
|
-
rval = #{class_name}.lookup_id(self.#{foreign_key})
|
|
24
|
-
if rval.nil? && #{!failure.nil?}
|
|
25
|
-
return self.send(#{failure.inspect}, :read, #{name.inspect}, #{foreign_key.inspect}, #{class_name.inspect}, self.#{foreign_key})
|
|
26
|
-
end
|
|
27
|
-
return rval
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def #{name}=(arg)
|
|
31
|
-
case arg
|
|
32
|
-
when #{class_name}
|
|
33
|
-
val = #{class_name}.lookup_id(arg.id)
|
|
34
|
-
when String
|
|
35
|
-
val = #{class_name}.lookup_name(arg)
|
|
36
|
-
when Symbol
|
|
37
|
-
val = #{class_name}.lookup_name(arg.id2name)
|
|
38
|
-
when Fixnum
|
|
39
|
-
val = #{class_name}.lookup_id(arg)
|
|
40
|
-
when nil
|
|
41
|
-
val = nil
|
|
42
|
-
else
|
|
43
|
-
raise TypeError, "#{self.name}: #{name}= argument must be a #{class_name}, String, Symbol or Fixnum but got a: \#{arg.class.name}"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
if val.nil?
|
|
47
|
-
if #{failure.nil?}
|
|
48
|
-
raise ArgumentError, "#{self.name}: #{name}= can't assign a #{class_name} for a value of (\#{arg.inspect})"
|
|
49
|
-
end
|
|
50
|
-
self.send(#{failure.inspect}, :write, #{name.inspect}, #{foreign_key.inspect}, #{class_name.inspect}, arg)
|
|
51
|
-
else
|
|
52
|
-
self.#{foreign_key} = val.id
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end_eval
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2005 Trevor Squires
|
|
2
|
-
# Released under the MIT License. See the LICENSE file for more details.
|
|
3
|
-
|
|
4
|
-
module ActiveRecord
|
|
5
|
-
module VirtualEnumerations # :nodoc:
|
|
6
|
-
class << self
|
|
7
|
-
def define
|
|
8
|
-
raise ArgumentError, "#{self.name}: must pass a block to define()" unless block_given?
|
|
9
|
-
config = ActiveRecord::VirtualEnumerations::Config.new
|
|
10
|
-
yield config
|
|
11
|
-
@config = config # we only overwrite config if no exceptions were thrown
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def synthesize_if_defined(const)
|
|
15
|
-
options = @config[const]
|
|
16
|
-
return nil unless options
|
|
17
|
-
class_def = <<-end_eval
|
|
18
|
-
class #{const} < #{options[:extends]}
|
|
19
|
-
acts_as_enumerated :conditions => #{options[:conditions].inspect},
|
|
20
|
-
:order => #{options[:order].inspect},
|
|
21
|
-
:on_lookup_failure => #{options[:on_lookup_failure].inspect}
|
|
22
|
-
set_table_name(#{options[:table_name].inspect}) unless #{options[:table_name].nil?}
|
|
23
|
-
end
|
|
24
|
-
end_eval
|
|
25
|
-
eval(class_def, TOPLEVEL_BINDING)
|
|
26
|
-
rval = const_get(const)
|
|
27
|
-
if options[:post_synth_block]
|
|
28
|
-
rval.class_eval(&options[:post_synth_block])
|
|
29
|
-
end
|
|
30
|
-
return rval
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class Config
|
|
35
|
-
def initialize
|
|
36
|
-
@enumeration_defs = {}
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def define(arg, options = {}, &synth_block)
|
|
40
|
-
(arg.is_a?(Array) ? arg : [arg]).each do |class_name|
|
|
41
|
-
camel_name = class_name.to_s.camelize
|
|
42
|
-
raise ArgumentError, "ActiveRecord::VirtualEnumerations.define - invalid class_name argument (#{class_name.inspect})" if camel_name.blank?
|
|
43
|
-
raise ArgumentError, "ActiveRecord::VirtualEnumerations.define - class_name already defined (#{camel_name})" if @enumeration_defs[camel_name.to_sym]
|
|
44
|
-
options.assert_valid_keys(:table_name, :extends, :conditions, :order, :on_lookup_failure)
|
|
45
|
-
enum_def = options.clone
|
|
46
|
-
enum_def[:extends] ||= "ActiveRecord::Base"
|
|
47
|
-
enum_def[:post_synth_block] = synth_block
|
|
48
|
-
@enumeration_defs[camel_name.to_sym] = enum_def
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def [](arg)
|
|
53
|
-
@enumeration_defs[arg]
|
|
54
|
-
end
|
|
55
|
-
end #class Config
|
|
56
|
-
end #module VirtualEnumerations
|
|
57
|
-
end #module ActiveRecord
|
|
58
|
-
|
|
59
|
-
class Module # :nodoc:
|
|
60
|
-
alias_method :enumerations_original_const_missing, :const_missing
|
|
61
|
-
def const_missing(const_id)
|
|
62
|
-
# let rails have a go at loading it
|
|
63
|
-
enumerations_original_const_missing(const_id)
|
|
64
|
-
rescue NameError
|
|
65
|
-
# now it's our turn
|
|
66
|
-
ActiveRecord::VirtualEnumerations.synthesize_if_defined(const_id) or raise
|
|
67
|
-
end
|
|
68
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require "rails"
|
|
2
|
-
|
|
3
|
-
class EnumerationsMixin < Rails::Engine
|
|
4
|
-
config.autoload_paths << File.expand_path(File.join(__FILE__, "../"))
|
|
5
|
-
|
|
6
|
-
initializer 'enumerations_mixin' do
|
|
7
|
-
ActiveSupport.on_load(:active_record) do
|
|
8
|
-
include ActiveRecord::Acts::Enumerated
|
|
9
|
-
include ActiveRecord::Aggregations::HasEnumerated
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2005 Trevor Squires
|
|
2
|
-
# Released under the MIT License. See the LICENSE file for more details.
|
|
3
|
-
|
|
4
|
-
# Copy this file to Rails.root/config/virtual_enumerations.rb
|
|
5
|
-
# and configure it accordingly.
|
|
6
|
-
ActiveRecord::VirtualEnumerations.define do |config|
|
|
7
|
-
###
|
|
8
|
-
# USAGE (and don't worry, it doesn't have to be as ugly as this):
|
|
9
|
-
# config.define 'ClassName',
|
|
10
|
-
# :table_name => 'table', :extends => 'SuperclassName',
|
|
11
|
-
# :conditions => ['something = ?', "value"], :order => 'column ASC',
|
|
12
|
-
# :on_lookup_failure => :enforce_strict_literals do
|
|
13
|
-
# class_evaled_functions
|
|
14
|
-
# end
|
|
15
|
-
#
|
|
16
|
-
# 'ClassName', :table_name and :extends are used to define your virtual class.
|
|
17
|
-
# Note that 'ClassName' can be a :symbol or a 'CamelString'.
|
|
18
|
-
#
|
|
19
|
-
# The :conditions, :order and :on_lookup_failure arguments are passed to
|
|
20
|
-
# acts_as_enumerated in your virtual class. See README_ENUMERATIONS for info
|
|
21
|
-
# on how acts_as_enumerated works.
|
|
22
|
-
#
|
|
23
|
-
# The 'do' block will be class_eval'd by your virtual class after it has
|
|
24
|
-
# been loaded-on-demand.
|
|
25
|
-
#
|
|
26
|
-
###
|
|
27
|
-
# Okay, that's pretty long-winded.
|
|
28
|
-
# Everything after the initial 'class_name' is optional so for most applications, this
|
|
29
|
-
# is about as verbose as you're likely to get:
|
|
30
|
-
#
|
|
31
|
-
# config.define :booking_status, :order => 'position ASC'
|
|
32
|
-
#
|
|
33
|
-
# In the above example, ActiveRecord assumes the table will be called 'booking_statuses'
|
|
34
|
-
# and the table should have a 'position' column defined.
|
|
35
|
-
#
|
|
36
|
-
# If you've got a bunch of enumeration classes that share the same optional parameters
|
|
37
|
-
# you can pass an array of names as the first argument, saving your fingers from typing
|
|
38
|
-
# config.define over and over again:
|
|
39
|
-
#
|
|
40
|
-
# config.define [:booking_status, :card_issuer], :order => 'position ASC'
|
|
41
|
-
#
|
|
42
|
-
# You can also take advantage of ActiveRecord's STI:
|
|
43
|
-
#
|
|
44
|
-
# config.define :enum_record, :order => 'position ASC', :table_name => 'enumrecords'
|
|
45
|
-
# config.define [:booking_status, :card_issuer], :extends => 'EnumRecord'
|
|
46
|
-
#
|
|
47
|
-
# In the above example, all of the records are stored in the table called 'enumrecords'
|
|
48
|
-
# and all acts_as_enumerated parameters are automatically inherited by the
|
|
49
|
-
# subclasses (although you can override them if you want).
|
|
50
|
-
# You can also use :extends to extend a non-virtual model class (that's already in
|
|
51
|
-
# your models directory) if that floats your boat.
|
|
52
|
-
#
|
|
53
|
-
# Finally, that strange optional 'do' block.
|
|
54
|
-
# You may be struck by the need to tamper with your virtual enumeration class after
|
|
55
|
-
# it has been loaded-on-demand. This can be as simple as blessing it with a
|
|
56
|
-
# certain 'act':
|
|
57
|
-
#
|
|
58
|
-
# config.define :enum_record, :order => 'position ASC' do
|
|
59
|
-
# acts_as_list # but see README_ENUMERATIONS for rules about modifying your records
|
|
60
|
-
# end
|
|
61
|
-
#
|
|
62
|
-
# or you may be experimenting with the dark-side... singleton methods
|
|
63
|
-
#
|
|
64
|
-
# config.define :card_issuer do
|
|
65
|
-
# class << self[:visa]; def verify_number(arg); some_code_here; end; end
|
|
66
|
-
# class << self[:master_card]; def verify_number(arg); some_other_code_here; end; end
|
|
67
|
-
# end
|
|
68
|
-
#
|
|
69
|
-
# For virtual enumerations, this sort of tampering *has* to be defined in the
|
|
70
|
-
# config.define do block. This is because in development mode, rails loads and
|
|
71
|
-
# subsequently clobbers your model classes for each request. The 'do' block will
|
|
72
|
-
# be evaluated each time your model class is loaded-on-demand.
|
|
73
|
-
#
|
|
74
|
-
###
|
|
75
|
-
|
|
76
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Prototype Legacy Helper
|
|
2
|
-
|
|
3
|
-
This plugin adds support for `form_remote_tag`, etc from Rails 2 to Rails 3.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Either add the following to your `Gemfile` and run `bundle`:
|
|
8
|
-
|
|
9
|
-
gem 'prototype_legacy_helper', '0.0.0', :git => 'git://github.com/rails/prototype_legacy_helper.git'
|
|
10
|
-
|
|
11
|
-
or run the following command to vendor the plugin within your app:
|
|
12
|
-
|
|
13
|
-
rails plugin install git://github.com/rails/prototype_legacy_helper.git
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'prototype_legacy_helper'
|
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
module PrototypeHelper
|
|
2
|
-
# Creates a button with an onclick event which calls a remote action
|
|
3
|
-
# via XMLHttpRequest
|
|
4
|
-
# The options for specifying the target with :url
|
|
5
|
-
# and defining callbacks is the same as link_to_remote.
|
|
6
|
-
def button_to_remote(name, options = {}, html_options = {})
|
|
7
|
-
button_to_function(name, remote_function(options), html_options)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# Returns a button input tag with the element name of +name+ and a value (i.e., display text) of +value+
|
|
11
|
-
# that will submit form using XMLHttpRequest in the background instead of a regular POST request that
|
|
12
|
-
# reloads the page.
|
|
13
|
-
#
|
|
14
|
-
# # Create a button that submits to the create action
|
|
15
|
-
# #
|
|
16
|
-
# # Generates: <input name="create_btn" onclick="new Ajax.Request('/testing/create',
|
|
17
|
-
# # {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});
|
|
18
|
-
# # return false;" type="button" value="Create" />
|
|
19
|
-
# <%= submit_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %>
|
|
20
|
-
#
|
|
21
|
-
# # Submit to the remote action update and update the DIV succeed or fail based
|
|
22
|
-
# # on the success or failure of the request
|
|
23
|
-
# #
|
|
24
|
-
# # Generates: <input name="update_btn" onclick="new Ajax.Updater({success:'succeed',failure:'fail'},
|
|
25
|
-
# # '/testing/update', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});
|
|
26
|
-
# # return false;" type="button" value="Update" />
|
|
27
|
-
# <%= submit_to_remote 'update_btn', 'Update', :url => { :action => 'update' },
|
|
28
|
-
# :update => { :success => "succeed", :failure => "fail" }
|
|
29
|
-
#
|
|
30
|
-
# <tt>options</tt> argument is the same as in form_remote_tag.
|
|
31
|
-
def submit_to_remote(name, value, options = {})
|
|
32
|
-
options[:with] ||= 'Form.serialize(this.form)'
|
|
33
|
-
|
|
34
|
-
html_options = options.delete(:html) || {}
|
|
35
|
-
html_options[:name] = name
|
|
36
|
-
|
|
37
|
-
button_to_remote(value, options, html_options)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Returns a link to a remote action defined by <tt>options[:url]</tt>
|
|
41
|
-
# (using the url_for format) that's called in the background using
|
|
42
|
-
# XMLHttpRequest. The result of that request can then be inserted into a
|
|
43
|
-
# DOM object whose id can be specified with <tt>options[:update]</tt>.
|
|
44
|
-
# Usually, the result would be a partial prepared by the controller with
|
|
45
|
-
# render :partial.
|
|
46
|
-
#
|
|
47
|
-
# Examples:
|
|
48
|
-
# # Generates: <a href="#" onclick="new Ajax.Updater('posts', '/blog/destroy/3', {asynchronous:true, evalScripts:true});
|
|
49
|
-
# # return false;">Delete this post</a>
|
|
50
|
-
# link_to_remote "Delete this post", :update => "posts",
|
|
51
|
-
# :url => { :action => "destroy", :id => post.id }
|
|
52
|
-
#
|
|
53
|
-
# # Generates: <a href="#" onclick="new Ajax.Updater('emails', '/mail/list_emails', {asynchronous:true, evalScripts:true});
|
|
54
|
-
# # return false;"><img alt="Refresh" src="/images/refresh.png?" /></a>
|
|
55
|
-
# link_to_remote(image_tag("refresh"), :update => "emails",
|
|
56
|
-
# :url => { :action => "list_emails" })
|
|
57
|
-
#
|
|
58
|
-
# You can override the generated HTML options by specifying a hash in
|
|
59
|
-
# <tt>options[:html]</tt>.
|
|
60
|
-
#
|
|
61
|
-
# link_to_remote "Delete this post", :update => "posts",
|
|
62
|
-
# :url => post_url(@post), :method => :delete,
|
|
63
|
-
# :html => { :class => "destructive" }
|
|
64
|
-
#
|
|
65
|
-
# You can also specify a hash for <tt>options[:update]</tt> to allow for
|
|
66
|
-
# easy redirection of output to an other DOM element if a server-side
|
|
67
|
-
# error occurs:
|
|
68
|
-
#
|
|
69
|
-
# Example:
|
|
70
|
-
# # Generates: <a href="#" onclick="new Ajax.Updater({success:'posts',failure:'error'}, '/blog/destroy/5',
|
|
71
|
-
# # {asynchronous:true, evalScripts:true}); return false;">Delete this post</a>
|
|
72
|
-
# link_to_remote "Delete this post",
|
|
73
|
-
# :url => { :action => "destroy", :id => post.id },
|
|
74
|
-
# :update => { :success => "posts", :failure => "error" }
|
|
75
|
-
#
|
|
76
|
-
# Optionally, you can use the <tt>options[:position]</tt> parameter to
|
|
77
|
-
# influence how the target DOM element is updated. It must be one of
|
|
78
|
-
# <tt>:before</tt>, <tt>:top</tt>, <tt>:bottom</tt>, or <tt>:after</tt>.
|
|
79
|
-
#
|
|
80
|
-
# The method used is by default POST. You can also specify GET or you
|
|
81
|
-
# can simulate PUT or DELETE over POST. All specified with <tt>options[:method]</tt>
|
|
82
|
-
#
|
|
83
|
-
# Example:
|
|
84
|
-
# # Generates: <a href="#" onclick="new Ajax.Request('/person/4', {asynchronous:true, evalScripts:true, method:'delete'});
|
|
85
|
-
# # return false;">Destroy</a>
|
|
86
|
-
# link_to_remote "Destroy", :url => person_url(:id => person), :method => :delete
|
|
87
|
-
#
|
|
88
|
-
# By default, these remote requests are processed asynchronous during
|
|
89
|
-
# which various JavaScript callbacks can be triggered (for progress
|
|
90
|
-
# indicators and the likes). All callbacks get access to the
|
|
91
|
-
# <tt>request</tt> object, which holds the underlying XMLHttpRequest.
|
|
92
|
-
#
|
|
93
|
-
# To access the server response, use <tt>request.responseText</tt>, to
|
|
94
|
-
# find out the HTTP status, use <tt>request.status</tt>.
|
|
95
|
-
#
|
|
96
|
-
# Example:
|
|
97
|
-
# # Generates: <a href="#" onclick="new Ajax.Request('/words/undo?n=33', {asynchronous:true, evalScripts:true,
|
|
98
|
-
# # onComplete:function(request){undoRequestCompleted(request)}}); return false;">hello</a>
|
|
99
|
-
# word = 'hello'
|
|
100
|
-
# link_to_remote word,
|
|
101
|
-
# :url => { :action => "undo", :n => word_counter },
|
|
102
|
-
# :complete => "undoRequestCompleted(request)"
|
|
103
|
-
#
|
|
104
|
-
# The callbacks that may be specified are (in order):
|
|
105
|
-
#
|
|
106
|
-
# <tt>:loading</tt>:: Called when the remote document is being
|
|
107
|
-
# loaded with data by the browser.
|
|
108
|
-
# <tt>:loaded</tt>:: Called when the browser has finished loading
|
|
109
|
-
# the remote document.
|
|
110
|
-
# <tt>:interactive</tt>:: Called when the user can interact with the
|
|
111
|
-
# remote document, even though it has not
|
|
112
|
-
# finished loading.
|
|
113
|
-
# <tt>:success</tt>:: Called when the XMLHttpRequest is completed,
|
|
114
|
-
# and the HTTP status code is in the 2XX range.
|
|
115
|
-
# <tt>:failure</tt>:: Called when the XMLHttpRequest is completed,
|
|
116
|
-
# and the HTTP status code is not in the 2XX
|
|
117
|
-
# range.
|
|
118
|
-
# <tt>:complete</tt>:: Called when the XMLHttpRequest is complete
|
|
119
|
-
# (fires after success/failure if they are
|
|
120
|
-
# present).
|
|
121
|
-
#
|
|
122
|
-
# You can further refine <tt>:success</tt> and <tt>:failure</tt> by
|
|
123
|
-
# adding additional callbacks for specific status codes.
|
|
124
|
-
#
|
|
125
|
-
# Example:
|
|
126
|
-
# # Generates: <a href="#" onclick="new Ajax.Request('/testing/action', {asynchronous:true, evalScripts:true,
|
|
127
|
-
# # on404:function(request){alert('Not found...? Wrong URL...?')},
|
|
128
|
-
# # onFailure:function(request){alert('HTTP Error ' + request.status + '!')}}); return false;">hello</a>
|
|
129
|
-
# link_to_remote word,
|
|
130
|
-
# :url => { :action => "action" },
|
|
131
|
-
# 404 => "alert('Not found...? Wrong URL...?')",
|
|
132
|
-
# :failure => "alert('HTTP Error ' + request.status + '!')"
|
|
133
|
-
#
|
|
134
|
-
# A status code callback overrides the success/failure handlers if
|
|
135
|
-
# present.
|
|
136
|
-
#
|
|
137
|
-
# If you for some reason or another need synchronous processing (that'll
|
|
138
|
-
# block the browser while the request is happening), you can specify
|
|
139
|
-
# <tt>options[:type] = :synchronous</tt>.
|
|
140
|
-
#
|
|
141
|
-
# You can customize further browser side call logic by passing in
|
|
142
|
-
# JavaScript code snippets via some optional parameters. In their order
|
|
143
|
-
# of use these are:
|
|
144
|
-
#
|
|
145
|
-
# <tt>:confirm</tt>:: Adds confirmation dialog.
|
|
146
|
-
# <tt>:condition</tt>:: Perform remote request conditionally
|
|
147
|
-
# by this expression. Use this to
|
|
148
|
-
# describe browser-side conditions when
|
|
149
|
-
# request should not be initiated.
|
|
150
|
-
# <tt>:before</tt>:: Called before request is initiated.
|
|
151
|
-
# <tt>:after</tt>:: Called immediately after request was
|
|
152
|
-
# initiated and before <tt>:loading</tt>.
|
|
153
|
-
# <tt>:submit</tt>:: Specifies the DOM element ID that's used
|
|
154
|
-
# as the parent of the form elements. By
|
|
155
|
-
# default this is the current form, but
|
|
156
|
-
# it could just as well be the ID of a
|
|
157
|
-
# table row or any other DOM element.
|
|
158
|
-
# <tt>:with</tt>:: A JavaScript expression specifying
|
|
159
|
-
# the parameters for the XMLHttpRequest.
|
|
160
|
-
# Any expressions should return a valid
|
|
161
|
-
# URL query string.
|
|
162
|
-
#
|
|
163
|
-
# Example:
|
|
164
|
-
#
|
|
165
|
-
# :with => "'name=' + $('name').value"
|
|
166
|
-
#
|
|
167
|
-
# You can generate a link that uses AJAX in the general case, while
|
|
168
|
-
# degrading gracefully to plain link behavior in the absence of
|
|
169
|
-
# JavaScript by setting <tt>html_options[:href]</tt> to an alternate URL.
|
|
170
|
-
# Note the extra curly braces around the <tt>options</tt> hash separate
|
|
171
|
-
# it as the second parameter from <tt>html_options</tt>, the third.
|
|
172
|
-
#
|
|
173
|
-
# Example:
|
|
174
|
-
# link_to_remote "Delete this post",
|
|
175
|
-
# { :update => "posts", :url => { :action => "destroy", :id => post.id } },
|
|
176
|
-
# :href => url_for(:action => "destroy", :id => post.id)
|
|
177
|
-
def link_to_remote(name, options = {}, html_options = nil)
|
|
178
|
-
link_to_function(name, remote_function(options), html_options || options.delete(:html))
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
# Returns a form tag that will submit using XMLHttpRequest in the
|
|
182
|
-
# background instead of the regular reloading POST arrangement. Even
|
|
183
|
-
# though it's using JavaScript to serialize the form elements, the form
|
|
184
|
-
# submission will work just like a regular submission as viewed by the
|
|
185
|
-
# receiving side (all elements available in <tt>params</tt>). The options for
|
|
186
|
-
# specifying the target with <tt>:url</tt> and defining callbacks is the same as
|
|
187
|
-
# +link_to_remote+.
|
|
188
|
-
#
|
|
189
|
-
# A "fall-through" target for browsers that doesn't do JavaScript can be
|
|
190
|
-
# specified with the <tt>:action</tt>/<tt>:method</tt> options on <tt>:html</tt>.
|
|
191
|
-
#
|
|
192
|
-
# Example:
|
|
193
|
-
# # Generates:
|
|
194
|
-
# # <form action="/some/place" method="post" onsubmit="new Ajax.Request('',
|
|
195
|
-
# # {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">
|
|
196
|
-
# form_remote_tag :html => { :action =>
|
|
197
|
-
# url_for(:controller => "some", :action => "place") }
|
|
198
|
-
#
|
|
199
|
-
# The Hash passed to the <tt>:html</tt> key is equivalent to the options (2nd)
|
|
200
|
-
# argument in the FormTagHelper.form_tag method.
|
|
201
|
-
#
|
|
202
|
-
# By default the fall-through action is the same as the one specified in
|
|
203
|
-
# the <tt>:url</tt> (and the default method is <tt>:post</tt>).
|
|
204
|
-
#
|
|
205
|
-
# form_remote_tag also takes a block, like form_tag:
|
|
206
|
-
# # Generates:
|
|
207
|
-
# # <form action="/" method="post" onsubmit="new Ajax.Request('/',
|
|
208
|
-
# # {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});
|
|
209
|
-
# # return false;"> <div><input name="commit" type="submit" value="Save" /></div>
|
|
210
|
-
# # </form>
|
|
211
|
-
# <% form_remote_tag :url => '/posts' do -%>
|
|
212
|
-
# <div><%= submit_tag 'Save' %></div>
|
|
213
|
-
# <% end -%>
|
|
214
|
-
def form_remote_tag(options = {}, &block)
|
|
215
|
-
options[:form] = true
|
|
216
|
-
|
|
217
|
-
options[:html] ||= {}
|
|
218
|
-
options[:html][:onsubmit] =
|
|
219
|
-
(options[:html][:onsubmit] ? options[:html][:onsubmit] + "; " : "") +
|
|
220
|
-
"#{remote_function(options)}; return false;"
|
|
221
|
-
|
|
222
|
-
form_tag(options[:html].delete(:action) || url_for(options[:url]), options[:html], &block)
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
# Creates a form that will submit using XMLHttpRequest in the background
|
|
226
|
-
# instead of the regular reloading POST arrangement and a scope around a
|
|
227
|
-
# specific resource that is used as a base for questioning about
|
|
228
|
-
# values for the fields.
|
|
229
|
-
#
|
|
230
|
-
# === Resource
|
|
231
|
-
#
|
|
232
|
-
# Example:
|
|
233
|
-
# <% remote_form_for(@post) do |f| %>
|
|
234
|
-
# ...
|
|
235
|
-
# <% end %>
|
|
236
|
-
#
|
|
237
|
-
# This will expand to be the same as:
|
|
238
|
-
#
|
|
239
|
-
# <% remote_form_for :post, @post, :url => post_path(@post), :html => { :method => :put, :class => "edit_post", :id => "edit_post_45" } do |f| %>
|
|
240
|
-
# ...
|
|
241
|
-
# <% end %>
|
|
242
|
-
#
|
|
243
|
-
# === Nested Resource
|
|
244
|
-
#
|
|
245
|
-
# Example:
|
|
246
|
-
# <% remote_form_for([@post, @comment]) do |f| %>
|
|
247
|
-
# ...
|
|
248
|
-
# <% end %>
|
|
249
|
-
#
|
|
250
|
-
# This will expand to be the same as:
|
|
251
|
-
#
|
|
252
|
-
# <% remote_form_for :comment, @comment, :url => post_comment_path(@post, @comment), :html => { :method => :put, :class => "edit_comment", :id => "edit_comment_45" } do |f| %>
|
|
253
|
-
# ...
|
|
254
|
-
# <% end %>
|
|
255
|
-
#
|
|
256
|
-
# If you don't need to attach a form to a resource, then check out form_remote_tag
|
|
257
|
-
#
|
|
258
|
-
# See FormHelper#form_for for additional semantics.
|
|
259
|
-
def remote_form_for(record_or_name_or_array, *args, &proc)
|
|
260
|
-
options = args.extract_options!
|
|
261
|
-
|
|
262
|
-
case record_or_name_or_array
|
|
263
|
-
when String, Symbol
|
|
264
|
-
object_name = record_or_name_or_array
|
|
265
|
-
when Array
|
|
266
|
-
object = record_or_name_or_array.last
|
|
267
|
-
object_name = ActiveModel::Naming.singular(object)
|
|
268
|
-
apply_form_for_options!(record_or_name_or_array, options)
|
|
269
|
-
args.unshift object
|
|
270
|
-
else
|
|
271
|
-
object = record_or_name_or_array
|
|
272
|
-
object_name = ActiveModel::Naming.singular(record_or_name_or_array)
|
|
273
|
-
apply_form_for_options!(object, options)
|
|
274
|
-
args.unshift object
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
form_remote_tag options do
|
|
278
|
-
fields_for object_name, *(args << options), &proc
|
|
279
|
-
end
|
|
280
|
-
end
|
|
281
|
-
alias_method :form_remote_for, :remote_form_for
|
|
282
|
-
|
|
283
|
-
# Returns '<tt>eval(request.responseText)</tt>' which is the JavaScript function
|
|
284
|
-
# that +form_remote_tag+ can call in <tt>:complete</tt> to evaluate a multiple
|
|
285
|
-
# update return document using +update_element_function+ calls.
|
|
286
|
-
def evaluate_remote_response
|
|
287
|
-
"eval(request.responseText)"
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
# Observes the field with the DOM ID specified by +field_id+ and calls a
|
|
291
|
-
# callback when its contents have changed. The default callback is an
|
|
292
|
-
# Ajax call. By default the value of the observed field is sent as a
|
|
293
|
-
# parameter with the Ajax call.
|
|
294
|
-
#
|
|
295
|
-
# Example:
|
|
296
|
-
# # Generates: new Form.Element.Observer('suggest', 0.25, function(element, value) {new Ajax.Updater('suggest',
|
|
297
|
-
# # '/testing/find_suggestion', {asynchronous:true, evalScripts:true, parameters:'q=' + value})})
|
|
298
|
-
# <%= observe_field :suggest, :url => { :action => :find_suggestion },
|
|
299
|
-
# :frequency => 0.25,
|
|
300
|
-
# :update => :suggest,
|
|
301
|
-
# :with => 'q'
|
|
302
|
-
# %>
|
|
303
|
-
#
|
|
304
|
-
# Required +options+ are either of:
|
|
305
|
-
# <tt>:url</tt>:: +url_for+-style options for the action to call
|
|
306
|
-
# when the field has changed.
|
|
307
|
-
# <tt>:function</tt>:: Instead of making a remote call to a URL, you
|
|
308
|
-
# can specify javascript code to be called instead.
|
|
309
|
-
# Note that the value of this option is used as the
|
|
310
|
-
# *body* of the javascript function, a function definition
|
|
311
|
-
# with parameters named element and value will be generated for you
|
|
312
|
-
# for example:
|
|
313
|
-
# observe_field("glass", :frequency => 1, :function => "alert('Element changed')")
|
|
314
|
-
# will generate:
|
|
315
|
-
# new Form.Element.Observer('glass', 1, function(element, value) {alert('Element changed')})
|
|
316
|
-
# The element parameter is the DOM element being observed, and the value is its value at the
|
|
317
|
-
# time the observer is triggered.
|
|
318
|
-
#
|
|
319
|
-
# Additional options are:
|
|
320
|
-
# <tt>:frequency</tt>:: The frequency (in seconds) at which changes to
|
|
321
|
-
# this field will be detected. Not setting this
|
|
322
|
-
# option at all or to a value equal to or less than
|
|
323
|
-
# zero will use event based observation instead of
|
|
324
|
-
# time based observation.
|
|
325
|
-
# <tt>:update</tt>:: Specifies the DOM ID of the element whose
|
|
326
|
-
# innerHTML should be updated with the
|
|
327
|
-
# XMLHttpRequest response text.
|
|
328
|
-
# <tt>:with</tt>:: A JavaScript expression specifying the parameters
|
|
329
|
-
# for the XMLHttpRequest. The default is to send the
|
|
330
|
-
# key and value of the observed field. Any custom
|
|
331
|
-
# expressions should return a valid URL query string.
|
|
332
|
-
# The value of the field is stored in the JavaScript
|
|
333
|
-
# variable +value+.
|
|
334
|
-
#
|
|
335
|
-
# Examples
|
|
336
|
-
#
|
|
337
|
-
# :with => "'my_custom_key=' + value"
|
|
338
|
-
# :with => "'person[name]=' + prompt('New name')"
|
|
339
|
-
# :with => "Form.Element.serialize('other-field')"
|
|
340
|
-
#
|
|
341
|
-
# Finally
|
|
342
|
-
# :with => 'name'
|
|
343
|
-
# is shorthand for
|
|
344
|
-
# :with => "'name=' + value"
|
|
345
|
-
# This essentially just changes the key of the parameter.
|
|
346
|
-
#
|
|
347
|
-
# Additionally, you may specify any of the options documented in the
|
|
348
|
-
# <em>Common options</em> section at the top of this document.
|
|
349
|
-
#
|
|
350
|
-
# Example:
|
|
351
|
-
#
|
|
352
|
-
# # Sends params: {:title => 'Title of the book'} when the book_title input
|
|
353
|
-
# # field is changed.
|
|
354
|
-
# observe_field 'book_title',
|
|
355
|
-
# :url => 'http://example.com/books/edit/1',
|
|
356
|
-
# :with => 'title'
|
|
357
|
-
#
|
|
358
|
-
#
|
|
359
|
-
def observe_field(field_id, options = {})
|
|
360
|
-
if options[:frequency] && options[:frequency] > 0
|
|
361
|
-
build_observer('Form.Element.Observer', field_id, options)
|
|
362
|
-
else
|
|
363
|
-
build_observer('Form.Element.EventObserver', field_id, options)
|
|
364
|
-
end
|
|
365
|
-
end
|
|
366
|
-
|
|
367
|
-
# Observes the form with the DOM ID specified by +form_id+ and calls a
|
|
368
|
-
# callback when its contents have changed. The default callback is an
|
|
369
|
-
# Ajax call. By default all fields of the observed field are sent as
|
|
370
|
-
# parameters with the Ajax call.
|
|
371
|
-
#
|
|
372
|
-
# The +options+ for +observe_form+ are the same as the options for
|
|
373
|
-
# +observe_field+. The JavaScript variable +value+ available to the
|
|
374
|
-
# <tt>:with</tt> option is set to the serialized form by default.
|
|
375
|
-
def observe_form(form_id, options = {})
|
|
376
|
-
if options[:frequency]
|
|
377
|
-
build_observer('Form.Observer', form_id, options)
|
|
378
|
-
else
|
|
379
|
-
build_observer('Form.EventObserver', form_id, options)
|
|
380
|
-
end
|
|
381
|
-
end
|
|
382
|
-
|
|
383
|
-
# Periodically calls the specified url (<tt>options[:url]</tt>) every
|
|
384
|
-
# <tt>options[:frequency]</tt> seconds (default is 10). Usually used to
|
|
385
|
-
# update a specified div (<tt>options[:update]</tt>) with the results
|
|
386
|
-
# of the remote call. The options for specifying the target with <tt>:url</tt>
|
|
387
|
-
# and defining callbacks is the same as link_to_remote.
|
|
388
|
-
# Examples:
|
|
389
|
-
# # Call get_averages and put its results in 'avg' every 10 seconds
|
|
390
|
-
# # Generates:
|
|
391
|
-
# # new PeriodicalExecuter(function() {new Ajax.Updater('avg', '/grades/get_averages',
|
|
392
|
-
# # {asynchronous:true, evalScripts:true})}, 10)
|
|
393
|
-
# periodically_call_remote(:url => { :action => 'get_averages' }, :update => 'avg')
|
|
394
|
-
#
|
|
395
|
-
# # Call invoice every 10 seconds with the id of the customer
|
|
396
|
-
# # If it succeeds, update the invoice DIV; if it fails, update the error DIV
|
|
397
|
-
# # Generates:
|
|
398
|
-
# # new PeriodicalExecuter(function() {new Ajax.Updater({success:'invoice',failure:'error'},
|
|
399
|
-
# # '/testing/invoice/16', {asynchronous:true, evalScripts:true})}, 10)
|
|
400
|
-
# periodically_call_remote(:url => { :action => 'invoice', :id => customer.id },
|
|
401
|
-
# :update => { :success => "invoice", :failure => "error" }
|
|
402
|
-
#
|
|
403
|
-
# # Call update every 20 seconds and update the new_block DIV
|
|
404
|
-
# # Generates:
|
|
405
|
-
# # new PeriodicalExecuter(function() {new Ajax.Updater('news_block', 'update', {asynchronous:true, evalScripts:true})}, 20)
|
|
406
|
-
# periodically_call_remote(:url => 'update', :frequency => '20', :update => 'news_block')
|
|
407
|
-
#
|
|
408
|
-
def periodically_call_remote(options = {})
|
|
409
|
-
frequency = options[:frequency] || 10 # every ten seconds by default
|
|
410
|
-
code = "new PeriodicalExecuter(function() {#{remote_function(options)}}, #{frequency})"
|
|
411
|
-
javascript_tag(code)
|
|
412
|
-
end
|
|
413
|
-
|
|
414
|
-
protected
|
|
415
|
-
def build_observer(klass, name, options = {})
|
|
416
|
-
if options[:with] && (options[:with] !~ /[\{=(.]/)
|
|
417
|
-
options[:with] = "'#{options[:with]}=' + encodeURIComponent(value)"
|
|
418
|
-
else
|
|
419
|
-
options[:with] ||= 'value' unless options[:function]
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
callback = options[:function] || remote_function(options)
|
|
423
|
-
javascript = "new #{klass}('#{name}', "
|
|
424
|
-
javascript << "#{options[:frequency]}, " if options[:frequency]
|
|
425
|
-
javascript << "function(element, value) {"
|
|
426
|
-
javascript << "#{callback}}"
|
|
427
|
-
javascript << ")"
|
|
428
|
-
javascript_tag(javascript)
|
|
429
|
-
end
|
|
430
|
-
end
|
|
431
|
-
|
|
432
|
-
ActionController::Base.helper PrototypeHelper
|