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:
1 parent
7c8f148fa8
commit
9f32e91e05
2 files changed
+13
-7
No files matched your search
@@ -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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user