Post edit link: focus the form on click

This commit is contained in:
Marcin Kurczewski 2013-10-27 22:47:20 +01:00
parent c4d5263422
commit 2f8d43cb4b

View file

@ -12,17 +12,20 @@ $(function()
var tags = []; var tags = [];
$.getJSON('/tags?json', function(data) $.getJSON('/tags?json', function(data)
{ {
aDom.removeClass('inactive');
var formDom = $('form.edit-post');
tags = data['tags']; tags = data['tags'];
if (!$(formDom).is(':visible'))
{
var tagItOptions = getTagItOptions(); var tagItOptions = getTagItOptions();
tagItOptions.availableTags = tags; tagItOptions.availableTags = tags;
tagItOptions.placeholderText = $('.tags input').attr('placeholder'); tagItOptions.placeholderText = $('.tags input').attr('placeholder');
$('.tags input').tagit(tagItOptions); $('.tags input').tagit(tagItOptions);
e.preventDefault();
var formDom = $('form.edit-post');
formDom.show().css('height', formDom.height()).hide().slideDown(); formDom.show().css('height', formDom.height()).hide().slideDown();
}
formDom.find('input[type=text]:visible:eq(0)').focus();
$('html, body').animate({ scrollTop: $(formDom).offset().top + 'px' }, 'fast'); $('html, body').animate({ scrollTop: $(formDom).offset().top + 'px' }, 'fast');
}); });
}); });