Commit c76be454 authored by hbcui1984's avatar hbcui1984

补充preload函数

parent 39192bcc
This diff is collapsed.
This diff is collapsed.
...@@ -127,18 +127,19 @@ ...@@ -127,18 +127,19 @@
if (slideTogether) { if (slideTogether) {
left = '-70%'; left = '-70%';
} }
menu = mui.createWindow({ menu = mui.openWindow({
id: 'offcanvas-plus-menu', id: 'offcanvas-plus-menu',
url: 'offcanvas-plus-menu.html', url: 'offcanvas-plus-menu.html',
styles: { styles: {
left: left, left: left,
width: '70%', width: '70%',
zindex: 9998 zindex: 9998
},
show:{
aniShow:'none'
} }
}); });
if (menu) { //初始化主页面位置
menu.show('none');
}
mui.currentWebview.setStyle({ mui.currentWebview.setStyle({
left: 0 left: 0
}); });
......
...@@ -124,16 +124,18 @@ ...@@ -124,16 +124,18 @@
if(slideTogether){ if(slideTogether){
left = '100%'; left = '100%';
} }
menu = mui.createWindow({ menu = mui.openWindow({
id: 'offcanvas-plus-menu', id: 'offcanvas-plus-menu',
url: 'offcanvas-plus-menu.html', url: 'offcanvas-plus-menu.html',
styles: { styles: {
left: '30%', left: '30%',
width:'70%', width:'70%',
zindex: 9998 zindex: 9998
},
show:{
aniShow:'none'
} }
}); });
menu.show('none');
mui.currentWebview.setStyle({left:0}); mui.currentWebview.setStyle({left:0});
}); });
//点击侧滑按钮 //点击侧滑按钮
......
This diff is collapsed.
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
</li>--> </li>-->
</ul> </ul>
</li> </li>
<li class="mui-table-view-cell"> <li class="mui-table-view-cell">
<a class="mui-navigate-right" href="examples/icons.html"> <a class="mui-navigate-right" href="examples/icons.html">
icon(图标) icon(图标)
...@@ -361,7 +361,7 @@ ...@@ -361,7 +361,7 @@
</li> </li>
</ul> </ul>
</li> </li>
<li class="mui-table-view-cell"> <li class="mui-table-view-cell">
<a class="mui-navigate-right" href="examples/radio.html"> <a class="mui-navigate-right" href="examples/radio.html">
radio(单选框) radio(单选框)
...@@ -394,9 +394,9 @@ ...@@ -394,9 +394,9 @@
switch(开关) switch(开关)
</a> </a>
</li> </li>
<li class="mui-table-view-cell mui-collapse"> <li class="mui-table-view-cell mui-collapse">
<a class="mui-navigate-right" href="#"> <a class="mui-navigate-right" href="#">
tab bar(选项卡) tab bar(选项卡)
...@@ -407,7 +407,7 @@ ...@@ -407,7 +407,7 @@
div模式 div模式
</a> </a>
</li> </li>
<li class="mui-table-view-cell"> <li class="mui-table-view-cell">
<a class="mui-navigate-right" href="examples/tab-webview-main.html"> <a class="mui-navigate-right" href="examples/tab-webview-main.html">
webview模式 webview模式
</a> </a>
...@@ -453,7 +453,7 @@ ...@@ -453,7 +453,7 @@
弹出窗口(Modals) 弹出窗口(Modals)
</a> </a>
</li>--> </li>-->
<!--<li class="mui-table-view-cell"> <!--<li class="mui-table-view-cell">
<a class="mui-navigate-right" href="examples/preload.html"> <a class="mui-navigate-right" href="examples/preload.html">
...@@ -502,110 +502,109 @@ ...@@ -502,110 +502,109 @@
</ul> </ul>
</div> </div>
<script> <script>
var limit = 5,count = 0; var limit = 3,
count = 0;
mui.init({ mui.init({
preloadLimit: limit, //同时并存的预加载窗口数量 preloadLimit: limit, //同时并存的预加载窗口数量
swipeBack: false, swipeBack: false,
}); });
$.plusReady(function() { (function($) {
//初始化一级列表的预加载 $.plusReady(function() {
$('#list>.mui-table-view-cell', document.body).each(function() { //初始化一级列表的预加载
//只预加载一级列表,二级列表在其展开时再预加载; $('#list>.mui-table-view-cell', document.body).each(function() {
if (!this.classList.contains('mui-collapse')) { //只预加载一级列表,二级列表在其展开时再预加载;
var url = this.querySelector('a').getAttribute("href"); if (!this.classList.contains('mui-collapse')) {
//预加载,默认使用url作为其id var url = this.querySelector('a').getAttribute("href");
$.createWindow({ //预加载,默认使用url作为其id
url: url, $.preload({
preload: true url: url,
}); });
if (++count >= limit) { if (++count >= limit) {
return false; return false;
}
} }
} });
});
//监听展开事件,预加载二级列表的前几个; //监听展开事件,预加载二级列表的前几个;
$('#list').on('expand', '.mui-collapse', function(e) { $('#list').on('expand', '.mui-collapse', function(e) {
count = 0; count = 0;
$('.mui-table-view a', this).each(function() { $('.mui-table-view a', this).each(function() {
var url = this.getAttribute("href"); var url = this.getAttribute("href");
if (~url.indexOf('.html')) { if (~url.indexOf('.html')) {
//单独处理侧滑导航的index //单独处理侧滑导航的index
if(~url.indexOf('offcanvas-')){ if (~url.indexOf('offcanvas-')) {
$.createWindow({ $.preload({
url: url, url: url,
styles:{ styles: {
zindex:9999 zindex: 9999
}, },
preload: true });
}); } else {
}else{ $.preload({
$.createWindow({ url: url,
url: url, });
preload: true }
}); if (++count >= limit) {
} return false;
if(++count>=limit){ }
return false;
} }
} });
}); });
});
// 关闭启动界面 // 关闭启动界面
plus.navigator.closeSplashscreen(); plus.navigator.closeSplashscreen();
//下拉刷新两个平台有区别; //下拉刷新两个平台有区别;
if ($.os.ios) { if ($.os.ios) {
document.getElementById('pull-refresh-pandora').style.display = "none"; document.getElementById('pull-refresh-pandora').style.display = "none";
} else if ($.os.android) { } else if ($.os.android) {
document.getElementById('pull-refresh-h5').style.display = "none"; document.getElementById('pull-refresh-h5').style.display = "none";
var list = document.querySelectorAll('.ios-only'); var list = document.querySelectorAll('.ios-only');
if(list){ if (list) {
for(var i=0;i<list.length;i++){ for (var i = 0; i < list.length; i++) {
list[i].style.display = 'none'; list[i].style.display = 'none';
}
} }
} }
} });
});
/**
/** * 处理链接点击事件
* 处理链接点击事件 */
*/ $.ready(function() {
$.ready(function() { $('body').on('tap', 'a', function(e) {
$('body').on('tap', 'a', function(e) { var id = this.getAttribute('href');
var id = this.getAttribute('href'); if (id) {
if (id) { if (~id.indexOf('.html')) {
if (~id.indexOf('.html')) { if (window.plus) {
if (window.plus) { //侧滑导航涉及Index问题,需要单独处理;
//侧滑导航涉及Index问题,需要单独处理; if (~id.indexOf('offcanvas-')) {
if(~id.indexOf('offcanvas-')){ $.openWindow({
$.openWindow({ id: id,
id: id, url: this.href,
url: this.href, styles: {
styles:{ zindex: 9999
zindex:9999 },
}, preload: true
preload: true });
}); } else {
}else{ $.openWindow({
$.openWindow({ id: id,
id: id, url: this.href,
url: this.href, preload: true
preload:true });
}); }
} else {
document.location.href = this.href;
}
} else {
if (typeof plus !== 'undefined') {
plus.runtime.openURL(id);
}
}
} }
} else { });
document.location.href = this.href; });
} })(mui);
} else {
if (typeof plus !== 'undefined') {
plus.runtime.openURL(id);
}
}
}
});
});
</script> </script>
</body> </body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment