qrcode.page.js
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var $ = require('yoho-jquery');
var Slide = require('../plugins/yohoui/YH.slide');
var $item = $('li', '.qrctxt');
var len = $item.length, slide;
require('../common');
function slideDo(to) {
$item.each(function(index) {
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');
});
}
slideDo(0);
slide = new Slide({
length: len,
loop: false,
auto: false,
timeout: 2,
index: 0
});
slide.on('change', function(data) {
slideDo(data.to);
});
$('.prev', '.qrcmain-switch').click(function() {
slide.prev();
});
$('.next', '.qrcmain-switch').click(function() {
slide.next();
});
$('.btn-qcode').click(function() {
var html = ['<ul>'];
$('.center', '.qrctxt').each(function() {
var _src, _bianhao, _zuoweihao;
html.push('<li>');
_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>');
}
html.push('</li>');
});
html.push('</ul>');
$('.print-content').html(html.join(''));
document.body.innerHTML = $('#print_wrap').show().html();
window.print();
return false;
});