let the user upload an image without touching the textarea, improved check in Photo#process to not yield no method on nil error in some cases

This commit is contained in:
MrZYX 2011-03-27 21:08:30 +02:00
parent c4bc24d485
commit 315fdabd76
2 changed files with 4 additions and 3 deletions

View file

@ -101,7 +101,7 @@ class Photo < Post
end
def process
return false if unprocessed_image.path.include?('.gif') || self.processed?
return false if self.processed? || unprocessed_image.path.include?('.gif')
processed_image.store!(unprocessed_image) #Ultra naive
save!
end

View file

@ -272,9 +272,10 @@ var Publisher = {
determineSubmitAvailability: function(){
var onlyWhitespaces = (Publisher.input().val().trim() == '');
var isSubmitDisabled = Publisher.submit().attr('disabled');
if (onlyWhitespaces && !isSubmitDisabled) {
var isPhotoAttached = ($("#photodropzone").children().length > 0)
if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) {
Publisher.submit().attr('disabled', true);
} else if (!onlyWhitespaces && isSubmitDisabled) {
} else if ((!onlyWhitespaces || isPhotoAttached) && isSubmitDisabled) {
Publisher.submit().removeAttr('disabled');
}
},