From 7c73a526dd15aa5765422b86b9d2333a1385c480 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Sun, 19 Feb 2012 21:14:12 +0100 Subject: [PATCH] fix for #2770 - 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 --- app/views/photos/_new_photo.haml | 8 +++----- public/javascripts/app/views/publisher_view.js | 8 +++----- public/javascripts/publisher.js | 18 ++++++------------ public/stylesheets/sass/application.sass | 6 +++--- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index bec158735..4da494f18 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -29,7 +29,7 @@ $('#file-upload').addClass("loading"); $('#publisher').find("input[type='submit']").attr('disabled','disabled'); - $("#publisher textarea").addClass("with_attachments"); + Publisher.wrapper().addClass("with_attachments"); $('#photodropzone').append( "
  • " + "" + @@ -43,7 +43,7 @@ url = responseJSON.data.photo.unprocessed_image.url, currentPlaceholder = $('li.loading').first(); - $("#publisher textarea").addClass("with_attachments"); + Publisher.wrapper().addClass("with_attachments"); $('#new_status_message').append(""); // replace image placeholders @@ -68,10 +68,8 @@ success: function() { photo.fadeOut(400, function(){ photo.remove(); - textarea.css('paddingBottom', $("#photodropzone").height() + 10); if ( $('.publisher_photo').length == 0){ - textarea.removeClass("with_attachments"); - textarea.css('paddingBottom', ''); + Publisher.wrapper().removeClass("with_attachments"); } }); } diff --git a/public/javascripts/app/views/publisher_view.js b/public/javascripts/app/views/publisher_view.js index 9945700a8..963949338 100644 --- a/public/javascripts/app/views/publisher_view.js +++ b/public/javascripts/app/views/publisher_view.js @@ -8,7 +8,7 @@ app.views.Publisher = Backbone.View.extend({ events : { "focus textarea" : "open", - "click #hide_publisher" : "close", + "click #hide_publisher" : "clear", "submit form" : "createStatusMessage" }, @@ -48,10 +48,8 @@ app.views.Publisher = Backbone.View.extend({ }, clear : function() { - this.$('textarea') - .removeClass("with_attachments") - .css("paddingBottom", "") - .val(""); + this.$('textarea').val(""); + this.$('#publisher_textarea_wrapper').removeClass("with_attachments"); // remove photos this.$("#photodropzone").find('li').remove(); diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index c4b15b530..cda29e862 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -15,6 +15,10 @@ var Publisher = { 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(){ return Publisher.cachedHiddenInput= Publisher.cachedHiddenInput || Publisher.form().find('#status_message_text'); }, @@ -37,10 +41,8 @@ var Publisher = { clear: function(){ $("#photodropzone").find('li').remove(); - Publisher.input() - .removeClass("with_attachments") - .css('paddingBottom', '') - .mentionsInput("reset"); + Publisher.input().mentionsInput("reset"); + Publisher.wrapper().removeClass("with_attachments"); }, bindServiceIcons: function(){ @@ -196,14 +198,6 @@ var Publisher = { Publisher.bindServiceIcons(); 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()); Publisher.input().bind("focus", function(){ diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index cee46c3c5..ad883e8d4 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -835,9 +835,8 @@ form p.checkbox_select :outline 0 :background transparent - &.with_attachments - :padding - :bottom 70px + &.with_attachments + :padding-bottom 38px #photodropzone :z-index 3 @@ -852,6 +851,7 @@ form p.checkbox_select :margin-right 4px img :width 50px + :max-height 55px .circle @include border-radius(20px)