editing captions on photos uses remote forms. removed photo in album from WSR.
This commit is contained in:
parent
c4a270ef8b
commit
752d50a6a9
8 changed files with 84 additions and 132 deletions
|
|
@ -79,7 +79,7 @@ class PhotosController < ApplicationController
|
||||||
flash[:notice] = I18n.t 'photos.destroy.notice'
|
flash[:notice] = I18n.t 'photos.destroy.notice'
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_with :location => photos_path
|
respond_with :location => photo.status_message
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
@ -106,11 +106,17 @@ class PhotosController < ApplicationController
|
||||||
photo = current_user.my_posts.where(:_id => params[:id]).first
|
photo = current_user.my_posts.where(:_id => params[:id]).first
|
||||||
if photo
|
if photo
|
||||||
if current_user.update_post( photo, params[:photo] )
|
if current_user.update_post( photo, params[:photo] )
|
||||||
flash[:notice] = I18n.t 'photos.update.notice'
|
flash.now[:notice] = I18n.t 'photos.update.notice'
|
||||||
respond_with photo
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js{ render :json => photo, :status => 200 }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
flash[:error] = I18n.t 'photos.update.error'
|
flash.now[:error] = I18n.t 'photos.update.error'
|
||||||
redirect_to [:edit, photo]
|
respond_to do |format|
|
||||||
|
format.html{ redirect_to [:edit, photo] }
|
||||||
|
format.js{ render :status => 403 }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
redirect_to person_photos_path(current_user.person)
|
redirect_to person_photos_path(current_user.person)
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,8 @@ class Photo < Post
|
||||||
{
|
{
|
||||||
:photo => {
|
:photo => {
|
||||||
:id => self.id,
|
:id => self.id,
|
||||||
:url => self.url(:thumb_medium)
|
:url => self.url(:thumb_medium),
|
||||||
|
:caption => self.caption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,74 +3,81 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
- content_for :head do
|
- content_for :head do
|
||||||
=javascript_include_tag 'photo'
|
:javascript
|
||||||
|
$(document).ready( function(){
|
||||||
|
$("#edit_photo_toggle").bind('click', function() {
|
||||||
|
$("#photo_edit_options").toggle();
|
||||||
|
$(".edit_photo input[type='text']").first().focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.edit_photo').bind('ajax:loading', function(data, json, xhr) {
|
||||||
|
$("#photo_edit_options").toggle();
|
||||||
|
$("#photo_spinner").show();
|
||||||
|
$("#show_photo").find("img").fadeTo(200,0.3);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.edit_photo').bind('ajax:failure', function(data, json, xhr) {
|
||||||
|
alert('Failed to delete photo. Are you sure you own this?');
|
||||||
|
$("#show_photo").find("img").fadeTo(200,1);
|
||||||
|
$("#photo_spinner").hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.edit_photo').bind('ajax:success', function(data, json, xhr) {
|
||||||
|
json = $.parseJSON(json);
|
||||||
|
$(".edit_photo input[type='text']").val(json['photo']['caption']);
|
||||||
|
$("#caption").html(json['photo']['caption']);
|
||||||
|
$("#show_photo").find("img").fadeTo(200,1);
|
||||||
|
$("#photo_spinner").hide();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
= render 'shared/author_info', :person => @photo.person, :post => @photo
|
= render 'shared/author_info', :person => @photo.person, :post => @photo
|
||||||
|
|
||||||
/ we need to do next photo here
|
|
||||||
/- if @photo.album
|
|
||||||
/= link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch', :id => "prev_photo"
|
|
||||||
/|
|
|
||||||
/= link_to "#{t('.full_size')}", @photo.url
|
|
||||||
/|
|
|
||||||
/= link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch', :id => "next_photo"
|
|
||||||
|
|
||||||
.span-14.append-1.last
|
.span-14.append-1.last
|
||||||
%div{:data=>{:guid=>@photo.id}}
|
%div{:data=>{:guid=>@photo.id}}
|
||||||
#show_photo
|
#show_photo
|
||||||
|
|
||||||
-if @ownership
|
-if @ownership
|
||||||
|
= image_tag 'ajax-loader.gif', :id => "photo_spinner", :class => "hidden"
|
||||||
.edit_pane
|
.edit_pane
|
||||||
.controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}}
|
.controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}}
|
||||||
= link_to t('.make_profile_photo'), '#', :class => "make_profile_photo"
|
= link_to t('.make_profile_photo'), '#', :class => "make_profile_photo"
|
||||||
|
|
|
||||||
|
= link_to 'edit', '#', :id => "edit_photo_toggle"
|
||||||
= image_tag @photo.url(:scaled_full)
|
= image_tag @photo.url(:scaled_full)
|
||||||
|
|
||||||
-else
|
-else
|
||||||
= image_tag @photo.url(:scaled_full)
|
= image_tag @photo.url(:scaled_full)
|
||||||
|
|
||||||
.caption
|
#caption
|
||||||
= @photo.caption
|
= @photo.caption
|
||||||
|
|
||||||
%br
|
%br
|
||||||
%br
|
|
||||||
%br
|
|
||||||
|
|
||||||
-if @ownership
|
-if @ownership
|
||||||
= link_to t('.edit_photo'),'javascript:void(0)', :id => "edit-desc", :class => "edit-desc"
|
#photo_edit_options
|
||||||
|
%h4 Edit photo description / delete photo
|
||||||
-if @ownership
|
%p
|
||||||
%div{:class => 'clear'}
|
= form_for @photo, :remote => true do |p|
|
||||||
-if !@photo.caption or @photo.caption == ""
|
|
||||||
= link_to t('.add_a_description'),'javascript:void(0)', :id => "add-description", :class => "edit-desc"
|
|
||||||
|
|
||||||
%br
|
|
||||||
%br
|
|
||||||
|
|
||||||
= form_for @photo do |p|
|
|
||||||
= p.text_field :caption, :value => @photo.caption
|
= p.text_field :caption, :value => @photo.caption
|
||||||
= p.submit t('.update_photo')
|
= p.submit t('.update_photo')
|
||||||
%div{:class => 'clear'}
|
%p
|
||||||
|
= button_to t('.delete_photo'), @photo, :confirm => t('are_you_sure'), :method => :delete
|
||||||
-if @ownership
|
|
||||||
= link_to t('.delete_photo'), @photo, :confirm => t('are_you_sure'), :method => :delete, :class => 'button'
|
|
||||||
|
|
||||||
.span-9.last
|
.span-9.last
|
||||||
|
|
||||||
- if @photo.status_message_id
|
- if @photo.status_message_id
|
||||||
#original_post_info
|
#original_post_info
|
||||||
%h4{:style=>"margin-bottom:5px;position:relative;"}
|
%h4{:style=>"position:relative;"}
|
||||||
Original Post
|
Original Post
|
||||||
= link_to 'view', @photo.status_message
|
= link_to 'view', @photo.status_message
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= @photo.status_message.message
|
= @photo.status_message.message
|
||||||
|
|
||||||
|
%p
|
||||||
- for photo in @photo.status_message.photos
|
- for photo in @photo.status_message.photos
|
||||||
= link_to (image_tag photo.url(:thumb_small)), object_path(photo)
|
= link_to (image_tag photo.url(:thumb_small)), object_path(photo)
|
||||||
%br
|
|
||||||
|
|
||||||
%h4{:style=>"margin-bottom:5px;"} Comments
|
%h4 Comments
|
||||||
%div{id => 'photo_stream', :class => 'stream show'}
|
%div{:id => 'photo_stream', :class => 'stream show'}
|
||||||
%li.message{:data=>{:guid=>@photo.id}}
|
%li.message{:data=>{:guid=>@photo.id}}
|
||||||
= render "comments/comments", :post => @photo
|
= render "comments/comments", :post => @photo
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
.from
|
.from
|
||||||
%h2
|
%h2
|
||||||
= person.real_name
|
= person.real_name
|
||||||
- if defined?(post)
|
- if defined?(post) && current_user.owns?(post)
|
||||||
.aspect
|
.aspect
|
||||||
➔
|
➔
|
||||||
%ul
|
%ul
|
||||||
|
|
@ -15,4 +15,3 @@
|
||||||
#person_nav_links
|
#person_nav_links
|
||||||
= link_to t('.view_profile'), person_path(person)
|
= link_to t('.view_profile'), person_path(person)
|
||||||
= link_to t('_photos'), person_photos_path(person)
|
= link_to t('_photos'), person_photos_path(person)
|
||||||
= link_to t('.status_messages'), person_status_messages_path(person)
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
.content
|
.content
|
||||||
.from
|
.from
|
||||||
= link_to post.person.real_name, post.person
|
= link_to post.person.real_name, post.person
|
||||||
|
|
||||||
|
- if current_user.owns?(post)
|
||||||
.aspect
|
.aspect
|
||||||
➔
|
➔
|
||||||
%ul
|
%ul
|
||||||
|
|
|
||||||
|
|
@ -4,56 +4,3 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
$(document).keydown(function(e){
|
|
||||||
switch(e.keyCode) {
|
|
||||||
case 37:
|
|
||||||
if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus
|
|
||||||
window.location = $("#prev_photo").attr('href');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 39:
|
|
||||||
if(!$("textarea").hasClass("hasfocus")){
|
|
||||||
window.location = $("#next_photo").attr('href');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
var $edit_photo = $(".edit_photo");
|
|
||||||
|
|
||||||
//add a clas to verify if a textarea has focus
|
|
||||||
$("textarea").live('focus',function(){
|
|
||||||
$(this).addClass("hasfocus");
|
|
||||||
});
|
|
||||||
$("textarea").live('blur',function(){
|
|
||||||
$(this).removeClass("hasfocus");
|
|
||||||
});
|
|
||||||
|
|
||||||
//show form to add description
|
|
||||||
$(".edit-desc").click(function(){
|
|
||||||
$(".edit_photo").toggle();
|
|
||||||
});
|
|
||||||
|
|
||||||
//Add a description with ajax request
|
|
||||||
$("#photo_submit").click(function(event){
|
|
||||||
event.preventDefault();
|
|
||||||
var method = $edit_photo.attr("method");
|
|
||||||
var url = $edit_photo.attr("action");
|
|
||||||
var data = $edit_photo.serialize();
|
|
||||||
$(".description").text($("#photo_caption").val());
|
|
||||||
$edit_photo.toggle();
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: method,
|
|
||||||
url: url,
|
|
||||||
data: data,
|
|
||||||
success: function(response){
|
|
||||||
$("#add-description").remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ var WebSocketReceiver = {
|
||||||
}else if (obj['class']=="comments"){
|
}else if (obj['class']=="comments"){
|
||||||
WebSocketReceiver.processComment(obj['post_id'], obj['html'], {'notification':obj['notification'], 'mine?':obj['mine?'], 'my_post?':obj['my_post?']})
|
WebSocketReceiver.processComment(obj['post_id'], obj['html'], {'notification':obj['notification'], 'mine?':obj['mine?'], 'my_post?':obj['my_post?']})
|
||||||
|
|
||||||
}else if (obj['class']=='photos' && WebSocketReceiver.onPageForClass('albums')){
|
|
||||||
WebSocketReceiver.processPhotoInAlbum(obj['photo_hash'])
|
|
||||||
}else{
|
}else{
|
||||||
WebSocketReceiver.processPost(obj['class'], obj['html'], obj['aspect_ids'])
|
WebSocketReceiver.processPost(obj['class'], obj['html'], obj['aspect_ids'])
|
||||||
}
|
}
|
||||||
|
|
@ -104,21 +102,6 @@ var WebSocketReceiver = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
processPhotoInAlbum: function(photoHash){
|
|
||||||
if (location.href.indexOf(photoHash['album_id']) == -1){
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
html = "<div class=\'image_thumb\' id=\'"+photoHash['id']+"\' style=\'padding-right:3px;\'> \
|
|
||||||
<a href=\"/photos/"+ photoHash['id'] +"\"> \
|
|
||||||
<img alt=\"New thumbnail\" src=\""+ photoHash['thumb_url'] +"\" /> \
|
|
||||||
</a> </div>"
|
|
||||||
$("#thumbnails").append( $(html) )
|
|
||||||
$("#"+ photoHash['id'] + " img").load( function() {
|
|
||||||
$(this).fadeIn("slow");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onPageForClass: function(className){
|
onPageForClass: function(className){
|
||||||
return (location.href.indexOf(className) != -1 );
|
return (location.href.indexOf(className) != -1 );
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ a
|
||||||
h1, h2, h3, h4
|
h1, h2, h3, h4
|
||||||
:color #444
|
:color #444
|
||||||
|
|
||||||
|
h4
|
||||||
|
:margin
|
||||||
|
:bottom 5px
|
||||||
|
|
||||||
ol, ul
|
ol, ul
|
||||||
:list-style none
|
:list-style none
|
||||||
|
|
||||||
|
|
@ -679,7 +683,12 @@ li.message .from .right
|
||||||
:border 1px solid #eee
|
:border 1px solid #eee
|
||||||
:bottom 1px solid #ddd
|
:bottom 1px solid #ddd
|
||||||
|
|
||||||
.caption
|
#photo_spinner
|
||||||
|
:position absolute
|
||||||
|
:height 100px
|
||||||
|
:width 100px
|
||||||
|
|
||||||
|
#caption
|
||||||
:min-height 20px
|
:min-height 20px
|
||||||
:padding 0 10px
|
:padding 0 10px
|
||||||
:font
|
:font
|
||||||
|
|
@ -1279,7 +1288,7 @@ input[type="search"]
|
||||||
.fancybox_content
|
.fancybox_content
|
||||||
:display none
|
:display none
|
||||||
|
|
||||||
.edit_photo
|
#photo_edit_options
|
||||||
:display none
|
:display none
|
||||||
|
|
||||||
#section_header
|
#section_header
|
||||||
|
|
@ -1922,8 +1931,6 @@ h3,h4
|
||||||
a
|
a
|
||||||
:font
|
:font
|
||||||
:size 12px
|
:size 12px
|
||||||
|
|
||||||
|
|
||||||
img
|
img
|
||||||
:-webkit-box-shadow 0 1px 2px #666
|
:-webkit-box-shadow 0 1px 2px #666
|
||||||
:-moz-box-shadow 0 1px 2px #666
|
:-moz-box-shadow 0 1px 2px #666
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue