Blame view

public/js/home/qrcode.page.js 1.61 KB
weiqingting authored
1 2 3
var $ = require('yoho-jquery');
var Slide = require('../plugins/yohoui/YH.slide');
weiqingting authored
4 5
var $item = $('li', '.qrctxt');
var len = $item.length, slide;
weiqingting authored
6
htoooth authored
7 8
require('../common');
weiqingting authored
9 10
function slideDo(to) {
    $item.each(function(index) {
weiqingting authored
11 12 13 14 15 16 17 18 19
        index === to ? $(this).stop().animate({
            opacity: 1,
            zIndex: 1
        }, 400) : $(this).stop().animate({
            opacity: 0,
            zIndex: 0
        }, 400);
        to === 0 ? $('.prev').addClass('gray') : $('.prev').removeClass('gray');
        to === len - 1 ? $('.next').addClass('gray') : $('.next').removeClass('gray');
weiqingting authored
20 21 22 23 24
    });
}

slideDo(0);
weiqingting authored
25 26
slide = new Slide({
    length: len,
weiqingting authored
27 28 29 30 31 32
    loop: false,
    auto: false,
    timeout: 2,
    index: 0
});
slide.on('change', function(data) {
weiqingting authored
33
    slideDo(data.to);
weiqingting authored
34
});
weiqingting authored
35 36 37 38 39
$('.prev', '.qrcmain-switch').click(function() {
    slide.prev();
});
$('.next', '.qrcmain-switch').click(function() {
    slide.next();
weiqingting authored
40
});
41 42
$('.btn-qcode').click(function() {
    var html = ['<ul>'];
yyq authored
43
44
    $('.center', '.qrctxt').each(function() {
yyq authored
45 46
        var _src, _bianhao, _zuoweihao;
47
        html.push('<li>');
yyq authored
48 49 50 51 52 53 54
        _src = $(this).find('img').attr('src');
        html.push('<img src=\'' + _src + '\'/>');
        _bianhao = $(this).find('.bianhao').text();
        html.push('<p>' + _bianhao + '</p>');
        _zuoweihao = $(this).find('.zuoweihao').text();
        if (_zuoweihao) {
            html.push('<p>' + _zuoweihao + '</p>');
weiqingting authored
55
        }
56
        html.push('</li>');
weiqingting authored
57
    });
58
    html.push('</ul>');
weiqingting authored
59
hongweigao authored
60
    $('.print-content').html(html.join(''));
61
    document.body.innerHTML = $('#print_wrap').show().html();
weiqingting authored
62 63 64
    window.print();
    return false;
});