media1.query.js
2.29 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(function() {
function setFontsize() {
var fontSize = 0;
fontSize = document.documentElement.clientWidth / 375 * 15;
document.documentElement.style.cssText = 'font-size:' + fontSize + 'px !important';
}
setFontsize();
window.addEventListener("resize", setFontsize, false);
})();
var ModalHelper = (function(bodyCls) {
var scrollTop;
return {
afterOpen: function() {
scrollTop = document.scrollingElement.scrollTop;
document.body.classList.add(bodyCls);
document.body.style.top = -scrollTop + 'px';
},
beforeClose: function() {
document.body.classList.remove(bodyCls);
// scrollTop lost after set position:fixed, restore it back.
document.scrollingElement.scrollTop = scrollTop;
}
};
})('modal-open');
/* loading */
(function($) {
var template =
'<div class="loading-wrapper">' +
' <div class="mask"></div>' +
' <div class="m-loading middle middle-content text-center border-radius">' +
' <i class="icon-loading"></i>' +
' <div class="text m-t-xs text-sm"></div>' +
' </div>' +
'</div>';
var defaultOpts = {
selector: 'body',
mark: true,
text: '正在提交...',
loadimg: ''
};
function hide () {
this.dom.hide();
return this;
}
function show () {
this.dom.show();
return this;
}
function config (options) {
this.dom.find('.content').text(options.text);
if (options.mark) {
this.dom.find('.mark').show();
} else {
this.dom.find('.mark').hide();
}
if (options.text) {
this.dom.find('.text').show().text(options.text);
} else {
this.dom.find('.text').hide();
}
this.dom.find('.icon-loading').addClass(options.loading);
return this;
}
var loading = function(options) {
var $dom = $(template);
var opts = $.extend({}, defaultOpts, options || {}, {});
var obj = {
dom: $dom,
hide: hide,
show: show,
reset: config
};
obj.reset(opts);
$(opts.selector).append($dom);
return obj;
};
$.extend({
loading: loading
});
})(jQuery);