Skip to content

Commit

Permalink
finished ajax update dialog box and repositioned it with the twitter …
Browse files Browse the repository at this point in the history
…button
  • Loading branch information
raist- committed Apr 29, 2012
1 parent 3a2c06e commit c4205c7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
15 changes: 14 additions & 1 deletion app/assets/stylesheets/scaffolds.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ div {
}

.twitter-share-button {
margin: 0px;
margin-left: 2px;
}

.clear{
Expand Down Expand Up @@ -249,3 +249,16 @@ a.img_link:hover {background-color:transparent !important;}
padding-top:-10px;
bottom:60px;
}

div.updateArea
{
width:80px;
margin-left: auto;
margin-right: auto;
margin-top: 5px;
}

#update
{
margin-bottom: 5px;
}
10 changes: 7 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class UsersController < ApplicationController


def run_update
notice = "Your address update has completed successfully!"
@notice = "Your address update has completed successfully!"
if (!current_user.valid_password? params[:password])
notice = "The password you entered is invalid!"
@notice = "The password you entered is invalid!"
end

if (notice != "The password you entered is invalid!")
Expand All @@ -24,7 +24,11 @@ def run_update
UpdateRunner.run_amazon({:email => amazon.email, :password => amazon.password, :full_name => amazon.full_name, :address1 => address.line1, :address2 => address.line2, :city => address.city, :state => address.state, :zip => address.zip, :country => amazon.country, :phone_number => "8471234567"})
end
end
redirect_to user_path(current_user), :notice => notice

respond_to do | format |
format.js {render :layout => false}
end
#redirect_to user_path(current_user), :notice => notice
end

def show
Expand Down
23 changes: 23 additions & 0 deletions app/views/users/run_update.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<% if @notice == "The password you entered is invalid!" %>

var password = $( "#password" );
password.addClass( "ui-state-error" );
ajaxTips = $( ".validateTips" );

ajaxTips
.text( "The password you entered is invalid!" )
.addClass( "ui-state-highlight" );
setTimeout(function() {
tips.removeClass( "ui-state-highlight", 1500 );
}, 500 );

$("#notice").html("");
<% else %>
/*Hide the div post_errors*/

<% flash[:notice] = "Your address update has completed successfully!" %>
$( "#dialog-form" ).dialog( "close" );

/*Update the html of the div flash_notice with the new one*/
$("#notice").html("<%= escape_javascript(flash[:notice])%>");
<% end %>

0 comments on commit c4205c7

Please sign in to comment.