From 2f8d43cb4b276d2f2d3f2900392c63f7b7603762 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 27 Oct 2013 22:47:20 +0100 Subject: [PATCH] Post edit link: focus the form on click --- public_html/media/js/post-view.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/public_html/media/js/post-view.js b/public_html/media/js/post-view.js index b650fc03..b1a01f2c 100644 --- a/public_html/media/js/post-view.js +++ b/public_html/media/js/post-view.js @@ -12,17 +12,20 @@ $(function() var tags = []; $.getJSON('/tags?json', function(data) { + aDom.removeClass('inactive'); + var formDom = $('form.edit-post'); tags = data['tags']; - var tagItOptions = getTagItOptions(); - tagItOptions.availableTags = tags; - tagItOptions.placeholderText = $('.tags input').attr('placeholder'); - $('.tags input').tagit(tagItOptions); - - e.preventDefault(); - var formDom = $('form.edit-post'); - formDom.show().css('height', formDom.height()).hide().slideDown(); + if (!$(formDom).is(':visible')) + { + var tagItOptions = getTagItOptions(); + tagItOptions.availableTags = tags; + tagItOptions.placeholderText = $('.tags input').attr('placeholder'); + $('.tags input').tagit(tagItOptions); + 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'); }); });