≡

wincent.dev

  • Products
  • Blog
  • Wiki
  • Issues
You are viewing an historical archive of past issues. Please report new issues to the appropriate project issue tracker on GitHub.
Home » Issues » Feature request #1278

Feature request #1278: Replace Prototype and Scriptaculous with jQuery and Unobtrusive JavaScript

Kind feature request
Product wincent.dev
When Created 2009-04-17T08:47:59Z, updated 2009-04-21T16:42:55Z
Status closed
Reporter Greg Hurrell
Tags no tags

Description

I've written about this on my blog:

  • https://wincent.dev/blog/switching-to-jquery

And there have been a couple of tweets as well:

  • https://wincent.dev/twitter/31
  • https://wincent.dev/twitter/35

The purpose of this ticket is to track what still needs to be done before I can take the final step and delete the legacy files.

Comments

  1. Greg Hurrell 2009-04-17T08:50:17Z

    Calls that I am going to have to search for and replace (taken from this page on the jRails website):

    Prototype

    • form_remote_for
    • form_remote_tag
    • link_to_remote
    • observe_field
    • observe_form
    • periodically_call_remote
    • remote_form_for
    • submit_to_remote

    Scriptaculous

    • draggable_element
    • drop_receiving_element
    • sortable_element
    • visual_effect

    RJS

    • hide
    • insert_html
    • remove
    • replace
    • replace_html
    • show
    • toggle
  2. Greg Hurrell 2009-04-17T09:00:33Z

    Luckily I didn't stick too much AJAX stuff in the code base before deciding to make the switch. This is what a quick search with ack has found:

    Prototype

    link_to_remote

    app/helpers/articles_helper.rb
    3:    link_to_remote 'update', common_options, :class => 'update_link'
    
    app/helpers/posts_helper.rb
    17:    link_to_remote 'update', common_options, :class => 'update_link'
    
    app/helpers/tweets_helper.rb
    14:    link_to_remote 'update', common_options, :class => 'update_link'

    observe_field

    app/helpers/articles_helper.rb
    7:    observe_field 'article_body', common_options.merge({:frequency => 30.0})
    
    app/helpers/posts_helper.rb
    21:    observe_field 'post_excerpt', common_options.merge({:frequency => 30.0})
    25:    observe_field 'post_body', common_options.merge({:frequency => 30.0})
    
    app/helpers/tweets_helper.rb
    18:    observe_field 'tweet_body', common_options.merge({ :frequency => 5.0 })

    submit_to_remote

    app/helpers/application_helper.rb
    192:      button = submit_to_remote 'button', 'destroy',
    203:      button = submit_to_remote 'button', 'ham',

    Scriptaculous

    visual_effect

    app/controllers/admin/issues_controller.rb
    17:        page.visual_effect :highlight, "issue_#{@issue.id}", :duration => 1.5
    18:        page.visual_effect :fade, "issue_#{@issue.id}_ham_form"
    
    app/controllers/comments_controller.rb
    105:            page.visual_effect :highlight, "comment_#{@comment.id}", :duration => 1.5
    106:            page.visual_effect :fade, "comment_#{@comment.id}_ham_form"
    125:          page.visual_effect :fade, "comment_#{@comment.id}"
    
    app/controllers/issues_controller.rb
    109:            page.visual_effect :highlight, "issue_#{@issue.id}", :duration => 1.5
    110:            page.visual_effect :fade, "issue_#{@issue.id}_ham_form"
    141:          page.visual_effect :fade, "issue_#{@issue.id}"
    
    app/controllers/topics_controller.rb
    83:            page.visual_effect :highlight, "topic_#{@topic.id}", :duration => 1.5
    84:            page.visual_effect :fade, "topic_#{@topic.id}_ham_form"
    102:          page.visual_effect :fade, "topic_#{topic.id}"

    Other

    More stuff found with ack which will have to be looked at.

    link_to_function

    Both of these use Prototype and in any case aren't Unobtrusive JavaScript.

    app/helpers/issues_helper.rb
    41:    link_to_function link_text, "$('issue_search').toggle(); $('issue_summary').focus();",
    
    app/views/layouts/application.haml
    35:          =link_to_function 'Search', "$('search').toggle(); $('search_box').focus();", :href => search_index_url
  3. Greg Hurrell 2009-04-17T10:17:23Z

    Oops, almost forgot to add the "in place" editor fields:

    app/controllers/admin/forums_controller.rb
    3:  in_place_edit_for :forum, :position
    4:  in_place_edit_for :forum, :name
    5:  in_place_edit_for :forum, :description
    
    app/controllers/admin/posts_controller.rb
    3:  in_place_edit_for :post, :title
    4:  in_place_edit_for :post, :permalink
    
    app/controllers/admin/tags_controller.rb
    3:  in_place_edit_for :tag, :name
    
    app/controllers/issues_controller.rb
    10:  in_place_edit_for :issue, :summary
    
    app/controllers/links_controller.rb
    4:  in_place_edit_for :link, :uri
    5:  in_place_edit_for :link, :permalink
    
    app/views/admin/forums/index.html.haml
    12:        %td=in_place_editor_field :forum, :position
    13:        %td=in_place_editor_field :forum, :name
    14:        %td=in_place_editor_field :forum, :description
    
    app/views/admin/posts/index.html.haml
    10:      %td=in_place_editor_field :post, :title
    11:      %td=in_place_editor_field :post, :permalink
    
    app/views/admin/tags/index.html.haml
    9:      %td=in_place_editor_field :tag, :name
    
    app/views/js/issues/show.js.erb
    31:  function edit_in_place(selector, class_name, attribute_name, url) {
    175:    edit_in_place('div.issue', 'issue', 'summary', '/issues/');
    183:    edit_in_place('div.issue', 'issue', 'pending_tags', '/issues/');
    
    app/views/links/index.html.haml
    12:      %td=in_place_editor_field :link, :uri
    13:      %td=in_place_editor_field :link, :permalink
  4. Greg Hurrell 2009-04-18T15:21:12Z

    Status changed:

    • From: New
    • To: Open
  5. Greg Hurrell 2009-04-20T06:05:11Z

    Ok, all the in-place-editor fields have been replaced and I've deleted the old plug-in.

  6. Greg Hurrell 2009-04-20T17:51:59Z

    Ok, all the visual_effect stuff has now been replaced, as has all the stuff which ultimately depends on the submit_to_remote method ("ham" and "destroy" buttons).

    All that's left to reimplement now are the live previews, I believe.

  7. Greg Hurrell 2009-04-21T16:42:47Z

    All done.

  8. Greg Hurrell 2009-04-21T16:42:55Z

    Status changed:

    • From: Open
    • To: Closed
Add a comment

Comments are now closed for this issue.

  • contact
  • legal

Menu

  • Blog
  • Wiki
  • Issues
  • Snippets