saunter.js 1.05 KB
/**
 * "逛"js
 * @author: yue.liu@yoho.cn
 * @date;2015/3/31
 */

var $ = require('jquery'),
    ellipsis = require('mlellipsis'),
    timer = null;

require('lazyload');
require('./saunter/article-type-three');
require('./saunter/article-type-three-optimize');

/**
 * 初始化页面加载时的文字截取和图片懒加载功能
 */
exports.init = function() {
    //相关文章截取文字
    ellipsis.init();
    
    clearTimeout(timer);
    timer = setTimeout(function() {
        //图片懒加载
        $("img.lazy").lazyload({
            placeholder     : "data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=="
        });

        $("img.lazy").lazyload({
            placeholder     : "data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==",
            event           : "load",
            container       : $(".thumb-container")
        });

        //截取文字
        $(".post-list").find("span").each(function(){
            $(this).mlellipsis(2);
        });
    }, 0)
};