JS optimization: move creation of inline reply placeholders to server-side so we don't have to create them client-side (which causes reflows and takes about 25-30ms on my test system)

Using live instead of bind for the event handling, we don't have to play any games on the ones that we do add at runtime. Yay!
This commit is contained in:
Brion Vibber
2011-03-11 15:20:20 -08:00
parent 10e5cb482e
commit 2bccd18d9a
2 changed files with 56 additions and 30 deletions

View File

@@ -627,26 +627,23 @@ var SN = { // StatusNet
'<input class="placeholder">' +
'</li>');
placeholder.find('input')
.val(SN.msg('reply_placeholder'))
.focus(function() {
SN.U.NoticeInlineReplyTrigger(notice);
return false;
});
.val(SN.msg('reply_placeholder'));
list.append(placeholder);
},
/**
* Setup function -- DOES NOT apply immediately.
*
* Sets up event handlers for favor/disfavor forms to submit via XHR.
* Sets up event handlers for inline reply mini-form placeholders.
* Uses 'live' rather than 'bind', so applies to future as well as present items.
*/
NoticeInlineReplySetup: function() {
$('.threaded-replies').each(function() {
var list = $(this);
var notice = list.closest('.notice');
SN.U.NoticeInlineReplyPlaceholder(notice);
});
$('li.notice-reply-placeholder input')
.live('focus', function() {
var notice = $(this).closest('li.notice');
SN.U.NoticeInlineReplyTrigger(notice);
return false;
});
},
/**