forked from Tencent/weui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
70 lines (64 loc) · 1.97 KB
/
example.js
File metadata and controls
70 lines (64 loc) · 1.97 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
65
66
67
68
69
70
/**
* Created by jfengjiang on 2015/9/11.
*/
$(function () {
// 页面栈
var stack = [];
var $container = $('.js_container');
$container.on('click', '.js_cell[data-id]', function () {
var id = $(this).data('id');
var $tpl = $($('#tpl_' + id).html()).addClass('slideIn').addClass(id);
$container.append($tpl);
stack.push($tpl);
history.pushState({id: id}, '', '#' + id);
$($tpl).on('webkitAnimationEnd', function (){
$(this).removeClass('slideIn');
}).on('animationend', function (){
$(this).removeClass('slideIn');
});
// tooltips
if (id == 'cell') {
$('.js_tooltips').show();
setTimeout(function (){
$('.js_tooltips').hide();
}, 3000);
}
});
// webkit will fired popstate on page loaded
$(window).on('popstate', function () {
var $top = stack.pop();
if (!$top) {
return;
}
$top.addClass('slideOut').on('animationend', function () {
$top.remove();
}).on('webkitAnimationEnd', function () {
$top.remove();
});
});
// toast
$container.on('click', '#showToast', function () {
$('#toast').show();
setTimeout(function () {
$('#toast').hide();
}, 5000);
});
$container.on('click', '#showLoadingToast', function () {
$('#loadingToast').show();
setTimeout(function () {
$('#loadingToast').hide();
}, 5000);
});
$container.on('click', '#showDialog1', function () {
$('#dialog1').show();
$('#dialog1').find('.weui_btn_dialog').on('click', function () {
$('#dialog1').hide();
});
});
$container.on('click', '#showDialog2', function () {
$('#dialog2').show();
$('#dialog2').find('.weui_btn_dialog').on('click', function () {
$('#dialog2').hide();
});
})
});