app/assets/javascripts/social_stream/documents.wall.js in social_stream-documents-2.0.2 vs app/assets/javascripts/social_stream/documents.wall.js in social_stream-documents-2.0.3

- old
+ new

@@ -26,25 +26,40 @@ }).insertAfter('.wall_input textarea.document_description'); $('.wall_input button.new_document').click(function(event){ event.preventDefault(); - $('label[for="new_document_title"]').show(); + $('.wall_input input[type=file]').trigger('click'); + }); - $('#post_text'). - attr('name', 'document[title]'). - attr('placeholder', I18n.t('document.title.input')); + $('.wall_input input[type=file]').change(function(){ + if ($(this).val()) { + $('label[for="new_document_title"]').show(); - $('#new_document_description').show().val($('#post_text').val()); + $('#post_text'). + attr('name', 'document[title]'). + attr('placeholder', I18n.t('document.title.input')); - SocialStream.Wall.changeAction($(this).attr('data-path')); - SocialStream.Wall.changeParams('document'); + $('#new_document_description').show().val($('#post_text').val()); - $('.wall_input input[type=file]').trigger('click'); - }); + SocialStream.Wall.changeAction($(this).closest('form').find('button.new_document').attr('data-path')); + SocialStream.Wall.changeParams('document'); - $('.wall_input input[type=file]').change(function(){ - $("#post_text").val($(this).val().replace(/C:\\fakepath\\/i, '')); + $("#post_text").val($(this).val().replace(/C:\\fakepath\\/i, '')); + } else { + $('label[for="new_document_title"]').hide(); + + $('#post_text'). + attr('name', 'post[text]'). + attr('placeholder', I18n.t('post.input')); + + $('#new_document_description').hide(); + + SocialStream.Wall.changeAction(); + SocialStream.Wall.changeParams(); + + $("#post_text").val($('#new_document_description').val()); + } }); }; SS.Wall.callbackRegister('show', initWall); })(SocialStream, jQuery);