- apply the padding to the wrapper element, not to the textarea
   apparently padding a textarea makes it shrink in firefox... ?
 - don't use manual padding, instead specify max-height for images
   extra-huge images are jolted, but they don't explode the layout
 - closing handled by view,
   gets rid of "Publisher.close is not a function" error msg
This commit is contained in:
Florian Staudacher 2012-02-19 21:14:12 +01:00
parent 0a49cfd866
commit 7c73a526dd
4 changed files with 15 additions and 25 deletions

View file

@ -29,7 +29,7 @@
$('#file-upload').addClass("loading"); $('#file-upload').addClass("loading");
$('#publisher').find("input[type='submit']").attr('disabled','disabled'); $('#publisher').find("input[type='submit']").attr('disabled','disabled');
$("#publisher textarea").addClass("with_attachments"); Publisher.wrapper().addClass("with_attachments");
$('#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' />" +
@ -43,7 +43,7 @@
url = responseJSON.data.photo.unprocessed_image.url, url = responseJSON.data.photo.unprocessed_image.url,
currentPlaceholder = $('li.loading').first(); currentPlaceholder = $('li.loading').first();
$("#publisher textarea").addClass("with_attachments"); Publisher.wrapper().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[]' />");
// replace image placeholders // replace image placeholders
@ -68,10 +68,8 @@
success: function() { success: function() {
photo.fadeOut(400, function(){ photo.fadeOut(400, function(){
photo.remove(); photo.remove();
textarea.css('paddingBottom', $("#photodropzone").height() + 10);
if ( $('.publisher_photo').length == 0){ if ( $('.publisher_photo').length == 0){
textarea.removeClass("with_attachments"); Publisher.wrapper().removeClass("with_attachments");
textarea.css('paddingBottom', '');
} }
}); });
} }

View file

@ -8,7 +8,7 @@ app.views.Publisher = Backbone.View.extend({
events : { events : {
"focus textarea" : "open", "focus textarea" : "open",
"click #hide_publisher" : "close", "click #hide_publisher" : "clear",
"submit form" : "createStatusMessage" "submit form" : "createStatusMessage"
}, },
@ -48,10 +48,8 @@ app.views.Publisher = Backbone.View.extend({
}, },
clear : function() { clear : function() {
this.$('textarea') this.$('textarea').val("");
.removeClass("with_attachments") this.$('#publisher_textarea_wrapper').removeClass("with_attachments");
.css("paddingBottom", "")
.val("");
// remove photos // remove photos
this.$("#photodropzone").find('li').remove(); this.$("#photodropzone").find('li').remove();

View file

@ -15,6 +15,10 @@ var Publisher = {
return Publisher.cachedInput = Publisher.cachedInput || Publisher.form().find('#status_message_fake_text'); return Publisher.cachedInput = Publisher.cachedInput || Publisher.form().find('#status_message_fake_text');
}, },
wrapper: function(){
return Publisher.cachedWrapper = Publisher.cachedWrapper || Publisher.form().find('#publisher_textarea_wrapper');
},
hiddenInput: function(){ hiddenInput: function(){
return Publisher.cachedHiddenInput= Publisher.cachedHiddenInput || Publisher.form().find('#status_message_text'); return Publisher.cachedHiddenInput= Publisher.cachedHiddenInput || Publisher.form().find('#status_message_text');
}, },
@ -37,10 +41,8 @@ var Publisher = {
clear: function(){ clear: function(){
$("#photodropzone").find('li').remove(); $("#photodropzone").find('li').remove();
Publisher.input() Publisher.input().mentionsInput("reset");
.removeClass("with_attachments") Publisher.wrapper().removeClass("with_attachments");
.css('paddingBottom', '')
.mentionsInput("reset");
}, },
bindServiceIcons: function(){ bindServiceIcons: function(){
@ -196,14 +198,6 @@ var Publisher = {
Publisher.bindServiceIcons(); Publisher.bindServiceIcons();
Publisher.bindAspectToggles(); Publisher.bindAspectToggles();
/* close text area */
Publisher.form().delegate("#hide_publisher", "click", function(){
$.each(Publisher.form().find("textarea"), function(idx, element){
$(element).val("");
});
Publisher.close();
});
Mentions.initialize(Publisher.input()); Mentions.initialize(Publisher.input());
Publisher.input().bind("focus", function(){ Publisher.input().bind("focus", function(){

View file

@ -835,9 +835,8 @@ form p.checkbox_select
:outline 0 :outline 0
:background transparent :background transparent
&.with_attachments &.with_attachments
:padding :padding-bottom 38px
:bottom 70px
#photodropzone #photodropzone
:z-index 3 :z-index 3
@ -852,6 +851,7 @@ form p.checkbox_select
:margin-right 4px :margin-right 4px
img img
:width 50px :width 50px
:max-height 55px
.circle .circle
@include border-radius(20px) @include border-radius(20px)