detail.js 1.12 KB
/**
 * PLUS+STAR详情页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */

var $ = require('yoho.zepto'),
    ellipsis = require('mlellipsis'),
    lazyLoad = require('yoho.lazyload');

var $intro = $('#intro'),
    $imt = $('#intro-more-txt'),
    $infosContainer = $('#related-infos-container');

var info = require('../info');

var mIntro, aIntro;

ellipsis.init();

//Init LazyLoad
lazyLoad($('img.lazy'));

//文字介绍文字截取
$intro[0].mlellipsis(3);

//获取截取文字和完整文字
setTimeout(function() {
    mIntro = $intro.text();
    aIntro = $intro.attr('title');
});

info.initInfosEvt($infosContainer);
info.setLazyLoadAndMellipsis($infosContainer.find('.guang-info'));

//文字介绍收起与展开
$('#more-intro').bind('touchstart', function() {
    var $this = $(this);

    $this.toggleClass('spread');

    if ($this.hasClass('spread')) {

        //显示
        $intro.text(aIntro);
        $imt.text('收起');
    } else {

        //隐藏
        $intro.text(mIntro);
        $imt.text('more');
    }
});

//品牌收藏
$('#brand-like').bind('touchstart', function(e) {
    e.preventDefault();
});