diff --git a/app/models/photo.rb b/app/models/photo.rb
index 6b5232fb4..d397d017e 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -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)
}
diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml
index 3f62608ab..fcdf09e35 100644
--- a/app/views/photos/_new_photo.haml
+++ b/app/views/photos/_new_photo.haml
@@ -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("");
$('#photodropzone').append(
"
" +
diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml
index 352addec4..ec3eeb388 100644
--- a/app/views/shared/_publisher.haml
+++ b/app/views/shared/_publisher.haml
@@ -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)
diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js
index b52fbbbfc..0def21961 100644
--- a/public/javascripts/stream.js
+++ b/public/javascripts/stream.js
@@ -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!');
diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass
index 88fad15a0..4d3338247 100644
--- a/public/stylesheets/sass/application.sass
+++ b/public/stylesheets/sass/application.sass
@@ -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%