Fix scroll position for esc out of edit."

master
Nick Sergeant 2012-02-19 13:01:28 -05:00
parent f8641c17c3
commit 17656e464b
2 changed files with 11 additions and 4 deletions

View File

@ -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');

View File

@ -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,
}