uploaded photos show in the publisher textarea instead of outside and above. fixed comment textarea on show pages.
This commit is contained in:
parent
4425c3df83
commit
bb0375d2f8
5 changed files with 49 additions and 21 deletions
|
|
@ -17,7 +17,7 @@ class Photo < Post
|
|||
key :random_string
|
||||
|
||||
key :status_message_id, ObjectId
|
||||
|
||||
|
||||
timestamps!
|
||||
|
||||
belongs_to :status_message
|
||||
|
|
@ -30,8 +30,8 @@ class Photo < Post
|
|||
#before_destroy :delete_parent_if_no_photos_or_message
|
||||
def ownership_of_status_message
|
||||
message = StatusMessage.find_by_id(self.status_message_id)
|
||||
if status_message_id && message
|
||||
self.diaspora_handle == message.diaspora_handle
|
||||
if status_message_id && message
|
||||
self.diaspora_handle == message.diaspora_handle
|
||||
else
|
||||
true
|
||||
end
|
||||
|
|
@ -85,7 +85,7 @@ class Photo < Post
|
|||
pod_url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||
"#{pod_url}#{url(*args)}"
|
||||
end
|
||||
|
||||
|
||||
def self.gen_random_string(len)
|
||||
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
||||
string = ""
|
||||
|
|
@ -98,11 +98,12 @@ class Photo < Post
|
|||
:photo => {
|
||||
:id => self.id,
|
||||
:url => self.url(:thumb_medium),
|
||||
:thumb_small => self.url(:thumb_small),
|
||||
:caption => self.caption
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def self.hash_from_post_ids post_ids
|
||||
hash = {}
|
||||
photos = self.on_statuses(post_ids)
|
||||
|
|
@ -115,7 +116,7 @@ class Photo < Post
|
|||
hash.each_value {|photos| photos.sort!{|p1, p2| p1.created_at <=> p2.created_at }}
|
||||
hash
|
||||
end
|
||||
scope :on_statuses, lambda { |post_ids|
|
||||
scope :on_statuses, lambda { |post_ids|
|
||||
where(:status_message_id.in => post_ids)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
button: document.getElementById('file-upload'),
|
||||
sizeLimit: 4194304,
|
||||
|
||||
|
||||
onProgress: function(id, fileName, loaded, total){
|
||||
var progress = Math.round(loaded / total * 100 );
|
||||
$('#fileInfo').text(fileName + ' ' + progress + '%');
|
||||
|
|
@ -37,7 +36,10 @@
|
|||
$("#publisher_spinner").fadeOut(100);
|
||||
$('#file-upload').removeClass("loading");
|
||||
var id = responseJSON.data.photo.id;
|
||||
var url = responseJSON.data.photo.url;
|
||||
var url = responseJSON.data.photo.thumb_small;
|
||||
|
||||
$("#publisher textarea").addClass("with_attachments");
|
||||
|
||||
$('#new_status_message').append("<input type='hidden' value='" + id + "' name='photos[]' />");
|
||||
$('#photodropzone').append(
|
||||
"<li style='position:relative;'>" +
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
.content_creation
|
||||
= form_for(StatusMessage.new, :remote => true) do |status|
|
||||
%ul#photodropzone
|
||||
= status.error_messages
|
||||
#file-upload
|
||||
= image_tag 'icons/photos.png'
|
||||
|
|
@ -48,7 +47,9 @@
|
|||
|
||||
%p
|
||||
%params
|
||||
= status.text_area :message, :rows => 2, :value => params[:prefill]
|
||||
#publisher_textarea_wrapper
|
||||
%ul#photodropzone
|
||||
= status.text_area :message, :rows => 2, :value => params[:prefill]
|
||||
|
||||
= status.hidden_field :aspect_ids, :value => (aspect == :all ? aspect : aspect.id)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ var Stream = {
|
|||
$stream.delegate("textarea.comment_box", "focus", function(evt) {
|
||||
var commentBox = $(this);
|
||||
commentBox
|
||||
.attr('rows',2)
|
||||
.addClass('force_open')
|
||||
.closest("li").find(".submit_instructions").removeClass('hidden');
|
||||
});
|
||||
|
||||
|
|
@ -34,8 +36,9 @@ var Stream = {
|
|||
var commentBox = $(this);
|
||||
if (!commentBox.val()) {
|
||||
commentBox
|
||||
.attr('rows',2)
|
||||
.css('height','2.4em')
|
||||
.attr('rows',1)
|
||||
.removeClass('force_open')
|
||||
.css('height','1.4em')
|
||||
.closest("li").find(".submit_instructions").addClass('hidden');
|
||||
}
|
||||
});
|
||||
|
|
@ -92,12 +95,18 @@ var Stream = {
|
|||
});
|
||||
});
|
||||
|
||||
$(".new_status_message").bind('ajax:loading', function(data, json, xhr) {
|
||||
$("#photodropzone").find('li').remove();
|
||||
$("#publisher textarea").removeClass("with_attachments");
|
||||
});
|
||||
|
||||
$(".new_status_message").bind('ajax:success', function(data, json, xhr) {
|
||||
json = $.parseJSON(json);
|
||||
WebSocketReceiver.addPostToStream(json['post_id'], json['html']);
|
||||
//collapse publisher
|
||||
$("#publisher").addClass("closed");
|
||||
$("#photodropzone").find('li').remove();
|
||||
$("#publisher textarea").removeClass("with_attachments");
|
||||
});
|
||||
$(".new_status_message").bind('ajax:failure', function(data, html, xhr) {
|
||||
alert('failed to post message!');
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ form
|
|||
:font
|
||||
:size auto
|
||||
|
||||
|
||||
.hidden
|
||||
:display none
|
||||
|
||||
|
|
@ -376,7 +375,7 @@ li.message
|
|||
:right 5px
|
||||
|
||||
&:hover
|
||||
div.info, .time, .from
|
||||
div.info, .time, .from h4
|
||||
a
|
||||
:color #107FC9
|
||||
&:hover
|
||||
|
|
@ -508,19 +507,17 @@ li.message
|
|||
:background none
|
||||
:border none
|
||||
|
||||
ul.comments
|
||||
textarea
|
||||
:width 324px
|
||||
|
||||
.stream ul.comments
|
||||
.avatar
|
||||
:width 30px
|
||||
:height 30px
|
||||
|
||||
form
|
||||
:margin
|
||||
:right 12px
|
||||
|
||||
input.comment_submit
|
||||
:display none
|
||||
:margin
|
||||
:right -10px
|
||||
|
||||
ul.comments
|
||||
:margin 0
|
||||
|
|
@ -531,7 +528,10 @@ ul.comments
|
|||
|
||||
textarea
|
||||
:width 100%
|
||||
:height 2.4em
|
||||
:height 1.4em
|
||||
|
||||
.force_open
|
||||
:min-height 2.4em
|
||||
|
||||
li.comment
|
||||
:list
|
||||
|
|
@ -910,6 +910,21 @@ label
|
|||
&.loading
|
||||
:opacity 0.5
|
||||
|
||||
#publisher_textarea_wrapper
|
||||
:position relative
|
||||
textarea
|
||||
:z-index 2
|
||||
|
||||
&.with_attachments
|
||||
:padding
|
||||
:bottom 70px
|
||||
|
||||
#photodropzone
|
||||
:z-index 3
|
||||
:position absolute
|
||||
:bottom 0
|
||||
:left 5px
|
||||
|
||||
.field_with_submit
|
||||
input[type='text']
|
||||
:width 82%
|
||||
|
|
|
|||
Loading…
Reference in a new issue