optimize ajaxify

- do not call $.timeago twice on topic load and for widgets
- do not use toLocaleString for each timeago string, use a single
Intl.DateTimeFormat instance instead
- do not call format for empty timeago strings, ie a post that isnt
edited doesnt have a timeago string
- do not call isTouchDevice for every element
- remove app.replaceSelfLinks, this is superceded with /me route
- store references to jquery objects in navigator instead of creating
them on every scroll
This commit is contained in:
Baris Usakli
2018-11-17 14:07:48 -05:00
parent 6ade156ba5
commit c343b93a37
9 changed files with 88 additions and 102 deletions

View File

@@ -3,11 +3,9 @@
(function (ajaxify) {
ajaxify.widgets = {};
ajaxify.widgets.render = function (template, callback) {
callback = callback || function () {};
ajaxify.widgets.render = function (template) {
if (template.match(/^admin/)) {
return callback();
return;
}
var locations = Object.keys(ajaxify.data.widgets);
@@ -42,6 +40,7 @@
area = $('#content [widget-area="' + location + '"]');
if (html && area.length) {
area.html(html);
area.find('img:not(.not-responsive)').addClass('img-responsive');
}
if (widgetsAtLocation.length) {
@@ -49,16 +48,6 @@
}
});
var widgetAreas = $('#content [widget-area]');
widgetAreas.find('img:not(.not-responsive)').addClass('img-responsive');
widgetAreas.find('.timeago').timeago();
widgetAreas.find('img[title].teaser-pic,img[title].user-img').each(function () {
$(this).tooltip({
placement: 'top',
title: $(this).attr('title'),
});
});
$(window).trigger('action:widgets.loaded', {});
callback();
};
}(ajaxify || {}));