Skip to content

Commit

Permalink
解决hello mui首页连按两次back键无法退出App的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hbcui1984 committed Nov 23, 2014
1 parent 9ba90bb commit 81a372e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
18 changes: 0 additions & 18 deletions examples/hello-mui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@ <h1 class="mui-title">Hello mui</h1>

var menu = null,showMenu = false;
mui.plusReady(function() {
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
plus.key.addEventListener('backbutton', function(){
//首次按键,提示‘再按一次退出应用’
if(!first){
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function(){
first = null;
},1000);
}else{
if(new Date().getTime()-first<1000){
plus.runtime.quit();
}
}
}, false);

//处理侧滑导航,为了避免和子页面初始化等竞争资源,延迟加载侧滑页面;
setTimeout(function () {
menu= mui.preload({
Expand Down
17 changes: 17 additions & 0 deletions examples/hello-mui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,23 @@
});
$.plusReady(function() {
plus.navigator.closeSplashscreen();
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
plus.key.addEventListener('backbutton', function(){
//首次按键,提示‘再按一次退出应用’
if(!first){
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function(){
first = null;
},1000);
}else{
if(new Date().getTime()-first<1000){
plus.runtime.quit();
}
}
}, false);
//预加载下拉刷新
$.preload({
id:"examples/pullrefresh-main.html",
Expand Down

0 comments on commit 81a372e

Please sign in to comment.