From ea63c773c6105b764d789f00e0e344c74f5f9333 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Sat, 11 Sep 2010 12:34:47 -0400 Subject: [PATCH] rearranged the places where overlays are first shown, and where the auto-hide timer is called --- js/jQuery.fixHeaderFooter.js | 9 ++------- js/jQuery.mobile.js | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/js/jQuery.fixHeaderFooter.js b/js/jQuery.fixHeaderFooter.js index 21ccc3a8..a90bf484 100644 --- a/js/jQuery.fixHeaderFooter.js +++ b/js/jQuery.fixHeaderFooter.js @@ -12,11 +12,11 @@ $.fn.fixHeaderFooter = function(options){ ignoreTargets: 'a,input,textarea,select,button,label,.ui-headfoot-placehold', transition: el.find('[data-headfoottransition]').attr('data-headfoottransition') || ['slidedown','slideup'], //also accepts a string, like 'fade'. All animations work, but fade and slidedown/up look best - overlayOnly: el.find('.ui-fullscreen').length //if this is true, we should set the parent div to height 0 to force overlays...? + overlayOnly: el.find('.ui-fullscreen').length },options); var els = el.find('.ui-header,.ui-footer').wrap('
'), - posLoop = setInterval(function(){ els.trigger('setTop'); }, 20), + //posLoop = setInterval(function(){ els.trigger('setTop'); }, 20), tIsArray = $.isArray(o.transition); //add transition types @@ -123,11 +123,6 @@ $.fn.fixHeaderFooter = function(options){ $(window) .bind('load',function(){ els.trigger('overlayIn'); - - setTimeout(function(){ - els.trigger('overlayOut'); - if(posLoop){ clearInterval(posLoop); } - }, 2000); if(o.overlayOnly){ //to-do...for a photo-viewer or something full-screen diff --git a/js/jQuery.mobile.js b/js/jQuery.mobile.js index 57cfd799..820fb436 100644 --- a/js/jQuery.mobile.js +++ b/js/jQuery.mobile.js @@ -23,6 +23,7 @@ orientation, backBtnText = "Back", prevUrl = location.hash, + hashNavUnderway = false, //vars for custom event tracking scrolling = false, touching = false, @@ -294,6 +295,7 @@ //turn on/off page loading message.. also hides the ui-content div function pageLoading(done){ if(done){ + hideToolbarsAfterDelay(); //remove loading msg $html.removeClass('ui-loading'); //fade in page content, remove loading msg @@ -322,7 +324,8 @@ to.animationComplete(function(){ from.add(to).removeClass(' out in reverse '+ transitions); from.removeClass(activePageClass); - pageLoading(true); + to.find('.ui-header,.ui-footer').trigger('overlayIn'); + pageLoading(true); }); if(back){ currentTransition = 'slide'; } }; @@ -338,6 +341,12 @@ setTimeout(callback, transitionDuration); } }; + + function hideToolbarsAfterDelay(){ + setTimeout(function(){ + $('.ui-header,.ui-footer').trigger('overlayOut'); + }, 2000); + } //markup-driven enhancements, to be called on any ui-page upon loading function mobilize($el){ @@ -399,11 +408,11 @@ back = (url === prevUrl); if(url){ + hashNavUnderway = true; //see if content is present - NOTE: local urls aren't working right now - need logic to kill # var localDiv = $('[id="'+url+'"]'); if(localDiv.length){ changePage($('.ui-page-active'), localDiv, back); - pageLoading(true); } else { //ajax it in pageLoading(); @@ -414,7 +423,6 @@ $(this).html( $(this).find('.ui-page:eq(0)').html() ); mobilize($(this)); changePage($('.ui-page-active'), $(this), back); - pageLoading(true); }); } } @@ -429,8 +437,9 @@ } else{ startPage.addClass(activePageClass); + startPage.find('.ui-header,.ui-footer').trigger('overlayIn'); + pageLoading(true); } - pageLoading(true); } }); @@ -458,12 +467,14 @@ $body.bind('swiperight.jqm',function(){ history.go(-1); return false; - }); + }); //some debug stuff for the events pages $('body').bind('scrollstart scrollstop swipe swipeleft swiperight tap taphold turn',function(e){ $('#eventlogger').prepend('
Event fired: '+ e.type +'
'); }); + + }); })(jQuery, this); \ No newline at end of file