Turned lazyload into jquery plugin, used for announcements
On call of the lazyload plugin, all matched img elements will be checked if they have a data-src attribute. If so, their src attribute will be replaced with the contents of the data-src attribute (effectively loading the image) and the data-src attribute will be removed (so that multiple calls don't call multiple processing).
This commit is contained in:
parent
7c8f148fa8
commit
9f32e91e05
2 changed files with 13 additions and 7 deletions
|
|
@ -144,13 +144,7 @@ $(function() {
|
|||
if (!self.loginState.isAdmin()) return;
|
||||
|
||||
// lazy load images that still need lazy-loading
|
||||
$("#plugin_announcements_dialog_content article img").each(function (index, element) {
|
||||
var src = element.getAttribute("data-src");
|
||||
if (src) {
|
||||
element.setAttribute("src", src);
|
||||
element.removeAttribute("data-src");
|
||||
}
|
||||
});
|
||||
$("#plugin_announcements_dialog_content article img").lazyload();
|
||||
|
||||
self.announcementDialogContent.scrollTop(0);
|
||||
|
||||
|
|
|
|||
|
|
@ -444,6 +444,18 @@ $(function() {
|
|||
}
|
||||
};
|
||||
|
||||
$.fn.lazyload = function() {
|
||||
return this.each(function() {
|
||||
if (this.tagName.toLowerCase() != "img") return;
|
||||
|
||||
var src = this.getAttribute("data-src");
|
||||
if (src) {
|
||||
this.setAttribute("src", src);
|
||||
this.removeAttribute("data-src");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Use bootstrap tabdrop for tabs and pills
|
||||
$('.nav-pills, .nav-tabs').tabdrop();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue