loading.js
1.3 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
/**
* Loading mask
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/29
*/
var $ = require('yoho-jquery');
var $page = $('.yoho-page');
var $loading,
hasInit = false;
/** modify by liangzhifeng at 2015.11.2 */
// 初始化
function init($container, options) {
var className = options && options.className || '';
var html = '<div class="loading-mask ' + className + ' hide">' +
'<div class="loading">' +
'<div></div><div></div><div></div>' +
'</div>' +
'</div>';
hasInit = true;
if (!$container) {
$container = $page;
}
$container.append(html);
$loading = $container.children('.loading-mask');
$('body').on('touchstart touchmove touchend', '.loading-mask', function() {
return false;
});
}
// 显示loading
function showLoadingMask() {
// if (!hasInit) {
// init();
// hasInit = true;
// }
// $loading.removeClass('hide');
}
// 隐藏loading
function hideLoadingMask() {
// if (!hasInit) {
// init();
// hasInit = true;
// }
// $loading.addClass('hide');
}
exports.init = init;
exports.showLoadingMask = showLoadingMask;
exports.hideLoadingMask = hideLoadingMask;
exports.show = showLoadingMask;
exports.hide = hideLoadingMask;