diff --git a/snipt/media/js/src/modules/snipt.js b/snipt/media/js/src/modules/snipt.js index f8a9eb1..aacc35b 100644 --- a/snipt/media/js/src/modules/snipt.js +++ b/snipt/media/js/src/modules/snipt.js @@ -270,9 +270,13 @@ if ($('section#main-edit:visible').length) { $('section#main-edit').hide(); $('section#main').show(); - $('html, body').animate({ - scrollTop: $selected.offset().top - 50 - }, 0); + if (SniptList.$snipts.index($selected) === 0) { + window.scrollTo(0, 0); + } else { + $('html, body').animate({ + scrollTop: $selected.offset().top - 50 + }, 0); + } } else { if ($selected) { $selected.trigger('deselect'); diff --git a/snipt/snipts/views.py b/snipt/snipts/views.py index 4484a1e..25d6b89 100644 --- a/snipt/snipts/views.py +++ b/snipt/snipts/views.py @@ -75,14 +75,17 @@ def detail(request, username, snipt_slug): if user == request.user: tags = tags.filter(snipt__user=user) + public = False else: tags = tags.filter(snipt__user=user, snipt__public=True) + public = True tags = tags.annotate(count=Count('taggit_taggeditem_items__id')) tags = tags.order_by('-count', 'name') return { + 'public': public, 'snipt': snipt, - 'user': user, 'tags': tags, + 'user': user, }