找到static/js/forum_viewthread.js
查找
- function lazyload(className) {
- var obj = this;
- lazyload.className = className;
- this.getOffset = function (el, isLeft) {
- var retValue = 0 ;
- while (el != null ) {
- retValue += el["offset" + (isLeft ? "Left" : "Top" )];
- el = el.offsetParent;
- }
- return retValue;
- };
- this.initImages = function (ele) {
- lazyload.imgs = [];
- var eles = lazyload.className ? $C(lazyload.className, ele) : [document.body];
- for (var i = 0; i < eles.length; i++) {
- var imgs = eles[i].getElementsByTagName('IMG');
- for(var j = 0; j < imgs.length; j++) {
- if(imgs[j].getAttribute('file') && !imgs[j].getAttribute('lazyloaded')) {
- if(this.getOffset(imgs[j]) > document.documentElement.clientHeight) {
- lazyload.imgs.push(imgs[j]);
- } else {
- imgs[j].setAttribute('src', imgs[j].getAttribute('file'));
- }
- }
- }
- }
- };
- this.showImage = function() {
- this.initImages();
- if(!lazyload.imgs.length) return false;
- var imgs = [];
- var scrollTop = Math.max(document.documentElement.scrollTop , document.body.scrollTop);
- for (var i=0; i<lazyload.imgs.length; i++) {
- var img = lazyload.imgs[i];
- var offsetTop = this.getOffset(img);
- if (offsetTop > document.documentElement.clientHeight && (offsetTop - scrollTop < document.documentElement.clientHeight)) {
- img.setAttribute('src', img.getAttribute('file') ? img.getAttribute('file') : img.getAttribute('src'));
- img.setAttribute('lazyloaded', true);
- } else {
- imgs.push(img);
- }
- }
- lazyload.imgs = imgs;
- return true;
- };
- this.initImages();
- _attachEvent(window, 'scroll', function(){obj.showImage();});
- }
复制代码 替换为
- function lazyload(className) {
- var obj = this;
- lazyload.className = className;
- this.getOffset = function (el, isLeft) {
- var retValue = 0 ;
- while (el != null ) {
- retValue += el["offset" + (isLeft ? "Left" : "Top" )];
- el = el.offsetParent;
- }
- return retValue;
- };
- this.initImages = function (ele) {
- lazyload.imgs = [];
- var eles = lazyload.className ? $C(lazyload.className, ele) : [document.body];
- for (var i = 0; i < eles.length; i++) {
- var imgs = eles[i].getElementsByTagName('IMG');
- for(var j = 0; j < imgs.length; j++) {
- if(imgs[j].getAttribute('file') && !imgs[j].getAttribute('lazyloaded')) {
- if(this.getOffset(imgs[j]) > document.documentElement.clientHeight) {
- lazyload.imgs.push(imgs[j]);
- } else {
- imgs[j].setAttribute('src', imgs[j].getAttribute('file'));
- imgs[j].setAttribute('lazyloaded', 'true');
- }
- }
- }
- }
- };
- this.showImage = function() {
- this.initImages();
- if(!lazyload.imgs.length) return false;
- var imgs = [];
- var scrollTop = Math.max(document.documentElement.scrollTop , document.body.scrollTop);
- for (var i=0; i<lazyload.imgs.length; i++) {
- var img = lazyload.imgs[i];
- var offsetTop = this.getOffset(img);
- if (!img.getAttribute('lazyloaded') && offsetTop > document.documentElement.clientHeight && (offsetTop - scrollTop < document.documentElement.clientHeight)) {
- var dom = document.createElement('div');
- var width = img.getAttribute('width') ? img.getAttribute('width') : 100;
- var height = img.getAttribute('height') ? img.getAttribute('height') : 100;
- dom.innerHTML = '<div style="width: '+width+'px; height: '+height+'px;background: url('+IMGDIR + '/loading.gif) no-repeat center center;"></div>';
- img.parentNode.insertBefore(dom.childNodes[0], img);
- img.onload = function () {if(!this.getAttribute('_load')) {this.setAttribute('_load', 1);this.style.width = this.style.height = '';this.parentNode.removeChild(this.previousSibling);}};
- img.style.width = img.style.height = '1px';
- img.setAttribute('src', img.getAttribute('file') ? img.getAttribute('file') : img.getAttribute('src'));
- img.setAttribute('lazyloaded', true);
- } else {
- imgs.push(img);
- }
- }
- lazyload.imgs = imgs;
- return true;
- };
- this.showImage();
- _attachEvent(window, 'scroll', function(){obj.showImage();});
- }
- function update_collection(){
- sum = 1;
- $('collectionnumber').innerText = parseInt($('collectionnumber').innerText)+sum;
- }
复制代码
图标有了但是外链图片不能缩放郁闷啊
|