Merge pull request #5001 from Zauberstuhl/fixed_unauthorized_report_prompt

Hide SPV controls unless authenticated
This commit is contained in:
Jonne Haß 2014-06-18 21:45:27 +02:00
commit 0843db468e
4 changed files with 50 additions and 37 deletions

View file

@ -4,7 +4,6 @@ app.views.Feedback = app.views.Base.extend({
className : "info",
events: {
"click *[rel='auth-required']" : "requireAuth",
"click .like" : "toggleLike",
"click .reshare" : "resharePost",
"click .post_report" : "report"
@ -39,11 +38,5 @@ app.views.Feedback = app.views.Base.extend({
if(evt) { evt.preventDefault(); }
if(!window.confirm(Diaspora.I18n.t("reshares.post", {name: this.model.reshareAuthor().name}))) { return }
this.model.interactions.reshare();
},
requireAuth : function(evt) {
if( app.currentUser.authenticated() ) { return }
alert("you must be logged in to do that!")
return false;
}
});

View file

@ -7,6 +7,17 @@ app.views.SinglePostActions = app.views.Feedback.extend({
}, app.views.Feedback.prototype.events);
},
presenter: function() {
var interactions = this.model.interactions
return _.extend(this.defaultPresenter(), {
authorIsNotCurrentUser : this.authorIsNotCurrentUser(),
userCanReshare : interactions.userCanReshare(),
userLike : interactions.userLike(),
userReshare : interactions.userReshare()
})
},
renderPluginWidgets : function() {
app.views.Base.prototype.renderPluginWidgets.apply(this);
this.$('a').tooltip({placement: 'bottom'});
@ -16,6 +27,10 @@ app.views.SinglePostActions = app.views.Feedback.extend({
$('.comment_stream .comment_box').focus();
$('html,body').animate({scrollTop: $('.comment_stream .comment_box').offset().top - ($('.comment_stream .comment_box').height() + 20)});
return false;
},
authorIsNotCurrentUser: function() {
return app.currentUser.authenticated() && this.model.get("author").id != app.user().id
}
});

View file

@ -7,14 +7,16 @@
<div class="bd">
<div class="controls">
{{#if canRemove}}
<a href="#" class="delete comment_delete" title="{{t "delete"}}">
<div alt="Deletelabel" class="icons-deletelabel" />
<a/>
{{else}}
<a href="#" data-type="comment" class="comment_report" title="{{t "report.name"}}">
<div class="icons-report"/>
</a>
{{#if loggedIn}}
{{#if canRemove}}
<a href="#" class="delete comment_delete" title="{{t "delete"}}">
<div alt="Deletelabel" class="icons-deletelabel" />
<a/>
{{else}}
<a href="#" data-type="comment" class="comment_report" title="{{t "report.name"}}">
<div class="icons-report"/>
</a>
{{/if}}
{{/if}}
</div>

View file

@ -1,30 +1,33 @@
<div class='pull-right'>
<a href="#" rel="auth-required" class="like" title="{{#if userLike}} {{t "viewer.unlike"}} {{else}} {{t "viewer.like"}} {{/if}}">
{{#if userLike}}
<i class="entypo heart red large"></i>
{{else}}
<i class="entypo heart gray large"></i>
{{/if}}
{{#if loggedIn}}
<a href="#" class="like" title="{{#if userLike}} {{t "viewer.unlike"}} {{else}} {{t "viewer.like"}} {{/if}}">
{{#if userLike}}
<i class="entypo heart red large"></i>
{{else}}
<i class="entypo heart gray large"></i>
{{/if}}
</a>
<a href="#" rel="auth-required" class="focus-comment" title="{{t "viewer.comment"}}">
<a href="#" class="focus-comment" title="{{t "viewer.comment"}}">
<i class="entypo comment gray large"></i>
</a>
{{#if userCanReshare}}
<a href="#" rel="auth-required" class="reshare" title="{{t "viewer.reshare"}}">
<i class="entypo retweet gray large"></i>
</a>
<a href="#" class="reshare" title="{{t "viewer.reshare"}}">
<i class="entypo retweet gray large"></i>
</a>
{{else}}
{{#if userReshare}}
<a href="#" rel="auth-required" class="reshare-viewonly" title="{{t "viewer.reshared"}}">
<i class="entypo retweet blue large"></i>
</a>
{{/if}}
{{#if userReshare}}
<a href="#" class="reshare-viewonly" title="{{t "viewer.reshared"}}">
<i class="entypo retweet blue large"></i>
</a>
{{/if}}
{{/if}}
<a href="#" rel="auth-required" data-type="post" class="post_report" title="{{t "report.name"}}">
<i class="entypo gray large">&#x21;</i>
</a>
</div>
{{#if authorIsNotCurrentUser}}
<a href="#" data-type="post" class="post_report" title="{{t "report.name"}}">
<i class="entypo gray large">&#x21;</i>
</a>
{{/if}}
{{/if}}
</div>