Require login for the tags button

@DanBurton
This commit is contained in:
Chris Done 2014-11-13 22:34:34 +01:00
parent 972fc5ae18
commit 9fe7d95389

View File

@ -1,4 +1,5 @@
$(function(){ $(function(){
var loggedIn = $('.user-handle').length > 0;
var tags = Object.create(null); var tags = Object.create(null);
$('.tags').find('.tag').each(function(){ $('.tags').find('.tag').each(function(){
tags[$(this).find('a').text()] = true; tags[$(this).find('a').text()] = true;
@ -13,8 +14,6 @@ $(function(){
} }
}); });
$('#like').click(function(){ $('#like').click(function(){
var loggedIn = $('.user-handle').length > 0;
var $this = $(this); var $this = $(this);
if (loggedIn) { if (loggedIn) {
@ -39,10 +38,11 @@ $(function(){
$.post("@{PackageUnlikeR pn}"); $.post("@{PackageUnlikeR pn}");
} }
} else { } else {
window.location.href = '@{AuthR LoginR}'; login();
} }
}); });
$('#add-tag').click(function(){ $('#add-tag').click(function(){
if (!loggedIn) login();
$('#add-tag-form').toggleClass('hidden'); $('#add-tag-form').toggleClass('hidden');
$('#new-tag').focus(); $('#new-tag').focus();
}); });
@ -105,3 +105,7 @@ if( Object.create === undefined ) {
return new F(); return new F();
}; };
} }
function login(){
window.location.href = '@{AuthR LoginR}';
}