Skip to content

Commit

Permalink
no need to reinvent confirm functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby committed Feb 11, 2012
1 parent 80378b5 commit 85503b6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
4 changes: 0 additions & 4 deletions app/assets/javascripts/main.js.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ jQuery $ ->
textarea.text(shareText(update))
focusTextArea(update)

# Delete update check
$(".remove-update").click ->
confirm "Are you sure you want to delete this update?"

# Manage reply state and service share checkboxes
updateTickyboxes = ->
return if(userTickiedBox)
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/users.js.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/updates/_detail.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
- if current_user and update.author.id == current_user.author.id
= form_tag "/updates/#{update.id}" do
%input{:type => "hidden", :name => "_method", :value => "delete"}
%input.remove-update{:type => "submit", :value => "I Regret This"}
= submit_tag "I Regret This", :class => "remove-update", :confirm => t(:remove_update, :scope => :confirms)
4 changes: 2 additions & 2 deletions app/views/updates/_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- unless defined?(id)
- id = (request.path_info.gsub("/", "_")[1..-1])
- id = (request.path_info.gsub("/", "_")[1..-1])

%ul.updates{:class => (controller.controller_name == "updates" ? "has-update-form" : ""), :id => id}
- updates.each do |update|
Expand Down Expand Up @@ -42,7 +42,7 @@
- if current_user and update.author.id == current_user.author.id
= form_tag "/updates/#{update.id}" do
%input{:type => "hidden", :name => "_method", :value => "delete"}
%input.remove-update{:type => "submit", :value => "I Regret This"}
= submit_tag "I Regret This", :class => "remove-update", :confirm => t(:remove_update, :scope => :confirms)

!= render :partial => "shared/pagination"

Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_list.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- if following
= form_tag "/subscriptions/#{author.feed.id}" do
%input{:type => "hidden", :name => "_method", :value => "delete"}
%input.button.unfollow{:type => "submit", :value => "Unfollow", :id => "unfollow-#{author.feed.id}"}
= submit_tag "Unfollow", :class => "button unfollow", :id => "unfollow-#{author.feed.id}", :confirm => t(:unfollow, :scope => :confirms)
- else
= form_tag "/subscriptions" do
%input{:type => "hidden", :name => "subscribe_to", :value => author.feed.id}
Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.

en:
hello: "Hello world"
confirms:
remove_update: "Are you sure you want to delete this update?"
unfollow: "Are you sure you want to unfollow this user?"

0 comments on commit 85503b6

Please sign in to comment.