diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-19 17:17:10 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-19 17:17:10 +0000 |
commit | 38060a2cf0132a702c91adf60f344ad28c4e8e00 (patch) | |
tree | 217c5f7885a9c48ab8c006d4ba84862ee91e141d /app | |
parent | c178aded61c24b6037cd2dc403161427c8c0f836 (diff) | |
download | redmine-38060a2cf0132a702c91adf60f344ad28c4e8e00.tar.gz redmine-38060a2cf0132a702c91adf60f344ad28c4e8e00.zip |
Removes RJS from WatchersController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10047 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/watchers_controller.rb | 41 | ||||
-rw-r--r-- | app/views/watchers/_set_watcher.js.erb | 2 | ||||
-rw-r--r-- | app/views/watchers/append.js.erb | 4 | ||||
-rw-r--r-- | app/views/watchers/create.js.erb | 2 | ||||
-rw-r--r-- | app/views/watchers/destroy.js.erb | 1 | ||||
-rw-r--r-- | app/views/watchers/new.js.erb | 3 |
6 files changed, 16 insertions, 37 deletions
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index b6fe5e594..a0be20faf 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -33,15 +33,6 @@ class WatchersController < ApplicationController end def new - respond_to do |format| - format.js do - render :update do |page| - page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched} - page << "showModal('ajax-modal', '400px');" - page << "$('ajax-modal').addClassName('new-watcher');" - end - end - end end def create @@ -53,29 +44,14 @@ class WatchersController < ApplicationController end respond_to do |format| format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} - format.js do - render :update do |page| - page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched} - page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched} - end - end + format.js end end def append if params[:watcher].is_a?(Hash) user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]] - users = User.active.find_all_by_id(user_ids) - respond_to do |format| - format.js do - render :update do |page| - users.each do |user| - page << %|$$("#issue_watcher_user_ids_#{user.id}").each(function(el){el.remove();});| - end - page.insert_html :bottom, 'watchers_inputs', :text => watchers_checkboxes(nil, users, true) - end - end - end + @users = User.active.find_all_by_id(user_ids) end end @@ -83,11 +59,7 @@ class WatchersController < ApplicationController @watched.set_watcher(User.find(params[:user_id]), false) if request.post? respond_to do |format| format.html { redirect_to :back } - format.js do - render :update do |page| - page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched} - end - end + format.js end end @@ -117,12 +89,7 @@ private @watched.set_watcher(user, watching) respond_to do |format| format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} - format.js do - render(:update) do |page| - c = watcher_css(@watched) - page << %|$$(".#{c}").each(function(el){el.innerHTML="#{escape_javascript watcher_link(@watched, user)}"});| - end - end + format.js { render :partial => 'set_watcher', :locals => {:user => user, :watched => @watched} } end end end diff --git a/app/views/watchers/_set_watcher.js.erb b/app/views/watchers/_set_watcher.js.erb new file mode 100644 index 000000000..4f2a4318b --- /dev/null +++ b/app/views/watchers/_set_watcher.js.erb @@ -0,0 +1,2 @@ +<% selector = ".#{watcher_css(watched)}" %> +$$("<%= selector %>").each(function(el){el.update("<%= escape_javascript watcher_link(watched, user) %>")}); diff --git a/app/views/watchers/append.js.erb b/app/views/watchers/append.js.erb new file mode 100644 index 000000000..b5bde1e6d --- /dev/null +++ b/app/views/watchers/append.js.erb @@ -0,0 +1,4 @@ +<% @users.each do |user| %> + $$("#issue_watcher_user_ids_<%= user.id %>").each(function(el){el.remove();}); +<% end %> +Element.insert('watchers_inputs', '<%= escape_javascript(watchers_checkboxes(nil, @users, true)) %>'); diff --git a/app/views/watchers/create.js.erb b/app/views/watchers/create.js.erb new file mode 100644 index 000000000..d18152b76 --- /dev/null +++ b/app/views/watchers/create.js.erb @@ -0,0 +1,2 @@ +Element.update('ajax-modal', '<%= escape_javascript(render(:partial => 'watchers/new', :locals => {:watched => @watched})) %>'); +Element.update('watchers', '<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => @watched})) %>'); diff --git a/app/views/watchers/destroy.js.erb b/app/views/watchers/destroy.js.erb new file mode 100644 index 000000000..4c3bb1930 --- /dev/null +++ b/app/views/watchers/destroy.js.erb @@ -0,0 +1 @@ +Element.update('watchers', '<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => @watched})) %>'); diff --git a/app/views/watchers/new.js.erb b/app/views/watchers/new.js.erb new file mode 100644 index 000000000..c89dd1c95 --- /dev/null +++ b/app/views/watchers/new.js.erb @@ -0,0 +1,3 @@ +Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'watchers/new', :locals => {:watched => @watched}) %>'); +showModal('ajax-modal', '400px'); +$('ajax-modal').addClassName('new-watcher'); |