ms dg improved styling, fixed delete

This commit is contained in:
maxwell 2011-03-17 13:07:01 -07:00
parent 61bffb50d6
commit 14ff1e0143
5 changed files with 41 additions and 60 deletions

View file

@ -5,8 +5,7 @@
class PhotosController < ApplicationController class PhotosController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
respond_to :html respond_to :html, :json
respond_to :json, :only => :show
def index def index
@post_type = :photos @post_type = :photos
@ -124,18 +123,21 @@ class PhotosController < ApplicationController
if photo if photo
photo.destroy photo.destroy
respond_to do |format|
format.json{ render :nothing => true, :status => 204 }
format.html do
flash[:notice] = I18n.t 'photos.destroy.notice' flash[:notice] = I18n.t 'photos.destroy.notice'
if photo.status_message_id if photo.status_message_id
respond_with photo, :location => photo.status_message respond_with photo, :location => photo.status_message
else else
respond_with photo, :location => person_photos_path(current_user.person) respond_with photo, :location => person_photos_path(current_user.person)
end end
end
end
else else
respond_with photo, :location => person_photos_path(current_user.person) respond_with photo, :location => person_photos_path(current_user.person)
end end
end end
def show def show

View file

@ -17,8 +17,6 @@
sizeLimit: 4194304, sizeLimit: 4194304,
onProgress: function(id, fileName, loaded, total){ onProgress: function(id, fileName, loaded, total){
var progress = Math.round(loaded / total * 100 );
$('#fileInfo').text(fileName + ' ' + progress + '%');
}, },
messages: { messages: {
@ -30,38 +28,39 @@
onSubmit: function(id, fileName){ onSubmit: function(id, fileName){
$('#file-upload').addClass("loading"); $('#file-upload').addClass("loading");
$('#publisher').find("input[type='submit']").attr('disabled','disabled'); $('#publisher').find("input[type='submit']").attr('disabled','disabled');
$("div.mention_helper").fadeTo(100, 0, function() {
$("#publisher .options_and_submit, #fileInfo").fadeIn(50);
});
$("#publisher textarea").addClass("with_attachments"); $("#publisher textarea").addClass("with_attachments");
$("#publisher_spinner").fadeIn(100);
$('#photodropzone').append( $('#photodropzone').append(
"<li class='publisher_photo loading' style='position:relative;'>" + "<li class='publisher_photo loading' style='position:relative;'>" +
"<img src='/images/ajax-loader2.gif' />" + "<img src='/images/ajax-loader2.gif' />" +
"</li>" "</li>"
); );
}, },
onComplete: function(id, fileName, responseJSON) { onComplete: function(id, fileName, responseJSON) {
$('#fileInfo').text(fileName + ' completed'); $('#fileInfo').text(fileName + ' completed');
var id = responseJSON.data.photo.id; var id = responseJSON.data.photo.id,
var url = responseJSON.data.photo.thumb_small; url = responseJSON.data.photo.url,
currentPlaceholder = $('li.loading').first();
$("#publisher textarea").addClass("with_attachments"); $("#publisher textarea").addClass("with_attachments");
$('#new_status_message').append("<input type='hidden' value='" + id + "' name='photos[]' />"); $('#new_status_message').append("<input type='hidden' value='" + id + "' name='photos[]' />");
$('li.loading').first().replaceWith(
"<li class='publisher_photo' style='position:relative;'>" + // replace image placeholders
"<img src='" + url +"' data-id='" + id + "' />" + var img = currentPlaceholder.find('img');
"<div class='x'> X </div>" + img.attr('src', url);
"<div class='circle'></div>" + img.attr('data-id', id);
"</li>" currentPlaceholder.removeClass('loading');
); currentPlaceholder.append("<div class='x'>X</div>" +
$('#publisher').find("input[type='submit']").removeAttr('disabled'); "<div class='circle'></div>");
$("#publisher textarea").css('paddingBottom', $("#photodropzone").height() + 10); ////
$('.x').live('click', function(){
var publisher = $('#publisher'),
textarea = publisher.find('textarea');
publisher.find("input[type='submit']").removeAttr('disabled');
$('.x').bind('click', function(){
var photo = $(this).closest('.publisher_photo'); var photo = $(this).closest('.publisher_photo');
photo.addClass("dim"); photo.addClass("dim");
$.ajax({url: "photos/" + photo.children('img').attr('data-id'), $.ajax({url: "photos/" + photo.children('img').attr('data-id'),
@ -69,24 +68,18 @@
success: function() { success: function() {
photo.fadeOut(400, function(){ photo.fadeOut(400, function(){
photo.remove(); photo.remove();
$("#publisher textarea").css('paddingBottom', $("#photodropzone").height() + 10); textarea.css('paddingBottom', $("#photodropzone").height() + 10);
if ( $('.publisher_photo').length == 0){ if ( $('.publisher_photo').length == 0){
$("#publisher textarea").removeClass("with_attachments"); textarea.removeClass("with_attachments");
$("#publisher textarea").css('paddingBottom', ''); textarea.css('paddingBottom', '');
} }
}); });
} }
}); });
}); });
}, },
onAllComplete: function(completed_files){ onAllComplete: function(completed_files){
$('#fileInfo').delay(1800).fadeOut(200, function() {
$("div.mention_helper").fadeTo(100, 100);
});
$("#publisher_spinner").fadeOut(100);
$('#file-upload').removeClass("loading");
} }
}); });

View file

@ -45,8 +45,6 @@
.right .right
#fileInfo
= image_tag 'ajax-loader.gif', :class => 'hidden', :id => "publisher_spinner"
= status.submit t('.share'), :disable_with => t('.posting'), :class => 'button' = status.submit t('.share'), :disable_with => t('.posting'), :class => 'button'
.public_toggle .public_toggle

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View file

@ -872,16 +872,6 @@ label
:position relative :position relative
:top 0 :top 0
ul
:padding 0
>li
:display inline
:margin-right 2px
img
:-webkit-border-radius 5px
:-moz-border-radius 5px
:border-radius 5px
input[type='text'], input[type='text'],
textarea textarea
:width 435px :width 435px
@ -1014,17 +1004,19 @@ label
:bottom 0 :bottom 0
:width 435px :width 435px
:left 5px :left 5px
:padding 0
li li
:display inline-block
:margin-right 4px :margin-right 4px
img img
:height 50px
:width 50px :width 50px
.circle .circle
:display none :display none
:z-index 1 :z-index 1
:position absolute :position absolute
:right -7px :right -7px
:top -47px :top -5px
:background :background
:color #333 :color #333
@ -1035,19 +1027,15 @@ label
:border 1px solid #fff :border 1px solid #fff
:-webkit-border-radius 10px :-webkit-border-radius 20px
:-moz-border-radius 10px :-moz-border-radius 20px
:border-radius 10px :border-radius 20px
:-webkit-box-shadow 0 1px 3px #000
:-moz-box-shadow 0 1px 3px #000
:box-shadow 0 1px 3px #000
.x .x
:display none :display none
:z-index 2 :z-index 2
:position absolute :position absolute
:top -45px :top -3px
:right -1px :right -1px
:font :font
:size small :size small