added photos to status messages
This commit is contained in:
parent
f6491816a3
commit
fb0dc2db7e
7 changed files with 74 additions and 19 deletions
|
|
@ -9,12 +9,22 @@ class StatusMessagesController < ApplicationController
|
|||
respond_to :json, :only => :show
|
||||
|
||||
def create
|
||||
puts params.inspect
|
||||
|
||||
|
||||
@photos = Photo.all(:id.in => params[:photos])
|
||||
|
||||
puts @photos.inspect
|
||||
|
||||
|
||||
|
||||
|
||||
public_flag = params[:status_message][:public]
|
||||
public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false
|
||||
params[:status_message][:public] = public_flag
|
||||
|
||||
status_message = current_user.build_post(:status_message, params[:status_message])
|
||||
|
||||
status_message.photos += @photos
|
||||
if status_message.save(:safe => true)
|
||||
raise 'MongoMapper failed to catch a failed save' unless status_message.id
|
||||
current_user.dispatch_post(status_message, :to => params[:status_message][:to])
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class Photo < Post
|
|||
{
|
||||
:photo => {
|
||||
:id => self.id,
|
||||
:url => self.url(:thumb_small)
|
||||
:url => self.url(:thumb_medium)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class StatusMessage < Post
|
|||
xml_accessor :message
|
||||
|
||||
key :message, String
|
||||
many :photos, :class => Photo
|
||||
validates_presence_of :message
|
||||
|
||||
attr_accessible :message
|
||||
|
|
|
|||
|
|
@ -12,13 +12,17 @@
|
|||
debug: true,
|
||||
button: document.getElementById('file-upload'),
|
||||
sizeLimit: 5000048,
|
||||
onSubmit: function(id, fileName){
|
||||
$('#file-upload').text("loading");
|
||||
},
|
||||
|
||||
|
||||
onComplete: function(id, fileName, responseJSON){
|
||||
//var obj = jQuery.parseJSON(responseJSON.data);
|
||||
alert(responseJSON.data.photo.url);
|
||||
$('#file-upload').text("add photos");
|
||||
var id = responseJSON.data.photo.id;
|
||||
alert($('#new_status_message').length);
|
||||
var url = responseJSON.data.photo.url;
|
||||
$('#new_status_message').append("<input type='hidden' value='" + id + "' name='photos[]' />");
|
||||
|
||||
$('#photodropzone').append("<li><img src='" + url +"' data-id='" + id + "' /></li>");
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,25 +15,27 @@
|
|||
// $("#publisher .options_and_submit").fadeIn(50);
|
||||
//});
|
||||
|
||||
$("#publisher form").live("submit", function(evt){
|
||||
$("#publisher .options_and_submit").hide();
|
||||
});
|
||||
//$("#publisher form").live("submit", function(evt){
|
||||
//$("#publisher .options_and_submit").hide();
|
||||
//});
|
||||
|
||||
#publisher
|
||||
= owner_image_link
|
||||
|
||||
= form_for StatusMessage.new, :html => {:multipart => true,}, :remote => true do |status|
|
||||
|
||||
%ul#photodropzone
|
||||
= status.error_messages
|
||||
%params
|
||||
= status.label :message, t('.post_a_message_to', :aspect => (aspect == :all ? "everyone" : aspect))
|
||||
= status.text_area :message, :rows => 2, :value => params[:prefill]
|
||||
#file-upload.button
|
||||
add photos
|
||||
|
||||
%p
|
||||
%params
|
||||
= status.label :message, t('.post_a_message_to', :aspect => (aspect == :all ? "everyone" : aspect))
|
||||
= status.text_area :message, :rows => 2, :value => params[:prefill]
|
||||
|
||||
= status.hidden_field :to, :value => (aspect == :all ? aspect : aspect.id)
|
||||
|
||||
.options_and_submit
|
||||
#file-upload.button
|
||||
drag a photo to upload
|
||||
- if aspect == :all
|
||||
= status.submit t('.share'), :title => t('.share_with_all'), :disable_with => t('.posting')
|
||||
- else
|
||||
|
|
@ -54,5 +56,5 @@
|
|||
.fancybox_content
|
||||
#question_mark_pane
|
||||
= render 'shared/public_explain'
|
||||
#publisher_photo_upload
|
||||
= render 'photos/new_photo', :aspect_id => (aspect == :all ? aspect : aspect.id)
|
||||
#publisher_photo_upload
|
||||
= render 'photos/new_photo', :aspect_id => (aspect == :all ? aspect : aspect.id)
|
||||
|
|
|
|||
|
|
@ -3,3 +3,7 @@
|
|||
-# the COPYRIGHT file.
|
||||
|
||||
= markdownify(post.message)
|
||||
%br
|
||||
- for photo in post.photos
|
||||
/= render 'photos/photo', :post => photo
|
||||
= image_tag photo.url(:thumb_medium)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ a
|
|||
h1, h2, h3, h4
|
||||
:color #444
|
||||
|
||||
ol, ul
|
||||
:list-style none
|
||||
|
||||
.hidden
|
||||
:display none
|
||||
|
||||
|
|
@ -720,6 +723,30 @@ label
|
|||
:text
|
||||
:shadow 0 1px 1px #eee
|
||||
|
||||
#file-upload
|
||||
:z-index 5
|
||||
:float right
|
||||
:height 34px
|
||||
:width 70px
|
||||
:margin 0
|
||||
:background
|
||||
:color #107FC9
|
||||
|
||||
:-webkit-border-radius 0 5px 5px 0
|
||||
:-moz-border-radius 0 5px 5px 0
|
||||
:border-radius 0 5px 5px 0
|
||||
|
||||
:background -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(0,123,194)), color-stop(1, rgb(65,182,250)))
|
||||
:background -moz-linear-gradient( center bottom, rgb(0,123,194) 0%, rgb(65,182,250) 100%)
|
||||
|
||||
:padding 9px
|
||||
|
||||
:font
|
||||
:size 18px
|
||||
:weight bold
|
||||
:color #eee
|
||||
:text-shadow 0 1px 0 #333
|
||||
|
||||
#publisher
|
||||
:color #999
|
||||
:position relative
|
||||
|
|
@ -747,13 +774,20 @@ label
|
|||
:left 65px
|
||||
:top 0
|
||||
|
||||
ul
|
||||
>li
|
||||
:display inline
|
||||
:margin-right 2px
|
||||
img
|
||||
:border-radius 5px
|
||||
|
||||
|
||||
textarea
|
||||
:height 42px
|
||||
:display block
|
||||
|
||||
input[type='text'],
|
||||
textarea
|
||||
:width 490px
|
||||
:width 400px
|
||||
:margin 0
|
||||
|
||||
.options_and_submit
|
||||
|
|
|
|||
Loading…
Reference in a new issue