-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.html
159 lines (147 loc) · 3.58 KB
/
template.html
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.min.css">
<style>
html,
body {
background-color: #efeff4;
}
.mui-loader {
position: absolute;
top: 25%;
width: 100%;
height: 60%;
color: #888;
font-size: 14px;
text-align: center;
}
.mui-fadein {
opacity: 1;
}
.mui-fadeout {
opacity: 0;
}
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeout {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@-webkit-keyframes fadeout {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a id="back" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<a id="menu" class="mui-action-menu mui-icon mui-icon-bars mui-pull-right" style="display: none;"></a>
<h1 id="title" class="mui-title"></h1>
</header>
<div class="mui-loader">加载中...</div>
</body>
<script src="js/mui.min.js"></script>
<script type="text/javascript">
//启用双击监听
mui.init({
gestureConfig:{
doubletap:true
}
});
var contentWebview = null,self = null;
mui.plusReady(function () {
self = plus.webview.currentWebview();
});
mui.back = function() {
self.hide('auto');
setTimeout(function() {
titleElem.className = 'mui-title mui-fadeout';
titleElem.innerText = '';
if(contentWebview==null){
contentWebview = self.children()[0];
}
contentWebview.hide("none");
}, 350);
}
var titleElem = document.getElementById("title")
var menuElem = document.getElementById("menu")
window.addEventListener("updateHeader", function(e) {
var title = e.detail.title;
var showMenu = e.detail.showMenu;
var href = e.detail.target;
var aniShow = e.detail.aniShow;
titleElem.innerHTML = title;
titleElem.className = "mui-title mui-fadein";
var display = showMenu ? "" : "none";
if (showMenu) {
mui.options.keyEventBind.menubutton = true;
} else {
mui.options.keyEventBind.menubutton = false;
}
menu.style.display = display;
if(mui.os.android&&aniShow&&parseFloat(mui.os.version)>=4.4){
if(contentWebview==null){
contentWebview = self.children()[0];
}
if (contentWebview.getURL() != href) {
contentWebview.loadURL(href);
} else {
contentWebview.show();
}
setTimeout(function () {
self.show(aniShow);
},10);
}
});
menuElem.addEventListener('tap', function(e) {
e.stopPropagation();
if(contentWebview==null){
contentWebview = plus.webview.currentWebview().children()[0];
}
contentWebview.evalJS('mui("#topPopover").popover("toggle")');
});
document.querySelector('header').addEventListener('doubletap',function () {
if(contentWebview==null){
contentWebview = plus.webview.currentWebview().children()[0];
}
contentWebview.evalJS('mui.scrollTo(0, 100)');
});
mui.menu = function () {
if(menuElem.style.display !== "none"){
if(contentWebview==null){
contentWebview = plus.webview.currentWebview().children()[0];
}
contentWebview.evalJS('mui("#topPopover").popover("toggle")');
}
}
</script>
</html>