From 41afd86fe78177d7a1657f7f538e8d09f0706b4f Mon Sep 17 00:00:00 2001
From: Daniel Vincent Grippi <Dan@SPEEDRACER.local>
Date: Tue, 7 Sep 2010 12:03:43 -0700
Subject: [PATCH] DG IZ; fixed photos.

---
 app/controllers/photos_controller.rb |  2 +-
 app/views/photos/_new_photo.haml     | 22 ++++++++++++++++++
 public/javascripts/photos.js         | 34 ++++------------------------
 public/stylesheets/application.css   |  2 ++
 4 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index 88391fc4f2..111ede90a8 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -30,7 +30,7 @@ class PhotosController < ApplicationController
   def new
     @photo = Photo.new
     @album = current_user.album_by_id(params[:album_id])
-    render :partial => "new_photo"
+    render :partial => 'new_photo'
   end
   
   def destroy
diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml
index 32fd2a3e88..b33f03c836 100644
--- a/app/views/photos/_new_photo.haml
+++ b/app/views/photos/_new_photo.haml
@@ -1,3 +1,25 @@
+:javascript
+  $(function() {
+    $("#photo_image").html5_upload({
+      // WE INSERT ALBUM_ID PARAM HERE
+      url: "/photos?album_id=#{@album.id}",   
+      sendBoundary: window.FormData || $.browser.mozilla,
+      onStart: function(event, total) {
+        return confirm("You are about to upload " + total + " photos. Are you sure?");
+      },
+      onFinish: function(event, total){
+        $("#add_photo_button .button").html( "Add Photos" );
+        $("#add_photo_loader").fadeOut(400);
+      },
+      onStart: function(event, total){
+        $("#add_photo_pane").fadeOut(400);
+        $("#add_photo_button .button").html( "Uploading Photos" );
+        $("#add_photo_loader").fadeIn(400);
+        return true;
+      }
+    });
+  });
+
 %h1
   %span{:id=>"photo_title_status"}
     Add photos to
diff --git a/public/javascripts/photos.js b/public/javascripts/photos.js
index 3980c008e1..f771e8c921 100644
--- a/public/javascripts/photos.js
+++ b/public/javascripts/photos.js
@@ -17,35 +17,9 @@ $(document).ready(function(){
 });//end document ready
 
 function reset_photo_fancybox(){
-        album_id = $(".album_id")[0].id;
-        ajax = $.get("/photos/new?album_id=" + album_id, function(){
-          $("#new_photo_pane").html(ajax.responseText)
-        });
+    album_id = $(".album_id")[0].id;
+    ajax = $.get("/photos/new?album_id=" + album_id, function(){
+      $("#new_photo_pane").html(ajax.responseText)
+    });
 }
 
-$("#photo_image").html5_upload({
-  // WE INSERT ALBUM_ID PARAM HERE
-  url: "/photos?album_id="+$(".album_id")[0].id,   
-  sendBoundary: window.FormData || $.browser.mozilla,
-  setName: function(text) {
-    $("#progress_report_name").text(text);
-  },
-  onFinish: function(event, total){
-    $("#add_photo_button").html( "Add Photos" );
-    $("#add_photo_loader").fadeOut(400);
-
-    $("#photo_title_status").text("Done!");
-    $("#progress_report").html("Good job me!");
-
-    $("#add_photo_button").addClass("uploading_complete");
-   },
-  onStart: function(event, total){
-    $("#add_photo_button").html( "Uploading Photos" );
-    $("#add_photo_loader").fadeIn(400);
-
-    $("form.new_photo").fadeOut(0);
-    $("#progress_report").fadeIn(0);
-    $("#photo_title_status").text("Uploading...");
-    return true;
-  }
-});
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 75ba1f34c7..3e13ae3303 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -412,6 +412,8 @@ h1.big_text {
   float: right; }
 
 .back {
+  margin: 0;
+  padding: 0;
   font-size: 12px;
   font-weight: normal; }
 
-- 
GitLab