From 04cce12a00d14b97c3a5bc87a2a7ee0390818e06 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 26 Sep 2014 15:40:27 +0200 Subject: [PATCH] Fixed post view for anonymous users --- public_html/js/Controls/TagInput.js | 7 +++++-- public_html/js/Presenters/PostPresenter.js | 15 +++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/public_html/js/Controls/TagInput.js b/public_html/js/Controls/TagInput.js index 1d06598b..09f45623 100644 --- a/public_html/js/Controls/TagInput.js +++ b/public_html/js/Controls/TagInput.js @@ -21,8 +21,11 @@ App.Controls.TagInput = function( inputConfirmed: null, }; - if ($underlyingInput.length !== 1) { - throw new Error('Cannot set tag input to more than one elements at once'); + if ($underlyingInput.length === 0) { + 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')) { throw new Error('Tag input was already initialized for this element'); diff --git a/public_html/js/Presenters/PostPresenter.js b/public_html/js/Presenters/PostPresenter.js index fa0b5912..287452a1 100644 --- a/public_html/js/Presenters/PostPresenter.js +++ b/public_html/js/Presenters/PostPresenter.js @@ -73,8 +73,10 @@ App.Presenters.PostPresenter = function( $el.html(renderPostTemplate()); $messages = $el.find('.messages'); - tagInput = App.Controls.TagInput($el.find('form [name=tags]'), _, jQuery); - tagInput.inputConfirmed = editPost; + if (editPrivileges.canChangeTags) { + tagInput = App.Controls.TagInput($el.find('form [name=tags]'), _, jQuery); + tagInput.inputConfirmed = editPost; + } postContentFileDropper = new App.Controls.FileDropper($el.find('form [name=content]'), _, jQuery); postContentFileDropper.onChange = postContentChanged; @@ -83,10 +85,11 @@ App.Presenters.PostPresenter = function( postThumbnailFileDropper.onChange = postThumbnailChanged; postThumbnailFileDropper.setNames = true; - keyboard.keyup('e', function() { - editButtonClicked(null); - }); - + if (_.any(editPrivileges)) { + keyboard.keyup('e', function() { + editButtonClicked(null); + }); + } $el.find('.post-edit-wrapper form').submit(editFormSubmitted); $el.find('.delete').click(deleteButtonClicked);