aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/user_controller.rb10
-rw-r--r--app/views/user/set_draft_profile_photo.rhtml9
2 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index e2998333c..85d09abc7 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -372,6 +372,16 @@ class UserController < ApplicationController
end
@draft_profile_photo.save
+ if params[:automatically_crop]
+ # no javascript, crop automatically
+ @profile_photo = ProfilePhoto.new(:data => @draft_profile_photo.data, :draft => false)
+ @user.set_profile_photo(@profile_photo)
+ @draft_profile_photo.destroy
+ flash[:notice] = "Thank you for updating your profile photo"
+ redirect_to user_url(@user)
+ return
+ end
+
render :template => 'user/set_crop_profile_photo.rhtml'
return
elsif !params[:submitted_crop_profile_photo].nil?
diff --git a/app/views/user/set_draft_profile_photo.rhtml b/app/views/user/set_draft_profile_photo.rhtml
index 2fffd519f..03ebb05d3 100644
--- a/app/views/user/set_draft_profile_photo.rhtml
+++ b/app/views/user/set_draft_profile_photo.rhtml
@@ -19,7 +19,14 @@
<p>
<%= hidden_field_tag 'submitted_draft_profile_photo', 1 %>
- <%= submit_tag "Next, crop your photo &gt;&gt;" %>
+
+ <script type="text/javascript" charset="utf-8">
+ document.write('<%= submit_tag "Next, crop your photo &gt;&gt;" %>');
+ </script>
+ <noscript>
+ <%= hidden_field_tag 'automatically_crop', 1 %>
+ <%= submit_tag "Done &gt;&gt;" %>
+ </noscript>
</p>
<% end %>