Fixed post view for anonymous users

This commit is contained in:
Marcin Kurczewski 2014-09-26 15:40:27 +02:00
parent d7d2e23e30
commit 04cce12a00
2 changed files with 14 additions and 8 deletions

View file

@ -21,8 +21,11 @@ App.Controls.TagInput = function(
inputConfirmed: null, inputConfirmed: null,
}; };
if ($underlyingInput.length !== 1) { if ($underlyingInput.length === 0) {
throw new Error('Cannot set tag input to more than one elements at once'); throw new Error('Tag input element was not found');
}
if ($underlyingInput.length > 1) {
throw new Error('Cannot set tag input to more than one element at once');
} }
if ($underlyingInput.attr('data-tagged')) { if ($underlyingInput.attr('data-tagged')) {
throw new Error('Tag input was already initialized for this element'); throw new Error('Tag input was already initialized for this element');

View file

@ -73,8 +73,10 @@ App.Presenters.PostPresenter = function(
$el.html(renderPostTemplate()); $el.html(renderPostTemplate());
$messages = $el.find('.messages'); $messages = $el.find('.messages');
if (editPrivileges.canChangeTags) {
tagInput = App.Controls.TagInput($el.find('form [name=tags]'), _, jQuery); tagInput = App.Controls.TagInput($el.find('form [name=tags]'), _, jQuery);
tagInput.inputConfirmed = editPost; tagInput.inputConfirmed = editPost;
}
postContentFileDropper = new App.Controls.FileDropper($el.find('form [name=content]'), _, jQuery); postContentFileDropper = new App.Controls.FileDropper($el.find('form [name=content]'), _, jQuery);
postContentFileDropper.onChange = postContentChanged; postContentFileDropper.onChange = postContentChanged;
@ -83,10 +85,11 @@ App.Presenters.PostPresenter = function(
postThumbnailFileDropper.onChange = postThumbnailChanged; postThumbnailFileDropper.onChange = postThumbnailChanged;
postThumbnailFileDropper.setNames = true; postThumbnailFileDropper.setNames = true;
if (_.any(editPrivileges)) {
keyboard.keyup('e', function() { keyboard.keyup('e', function() {
editButtonClicked(null); editButtonClicked(null);
}); });
}
$el.find('.post-edit-wrapper form').submit(editFormSubmitted); $el.find('.post-edit-wrapper form').submit(editFormSubmitted);
$el.find('.delete').click(deleteButtonClicked); $el.find('.delete').click(deleteButtonClicked);