mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-23 15:44:43 +00:00
Merge branch 'master' of https://github.com/jquery/jquery-mobile
This commit is contained in:
commit
18d7b7902c
7 changed files with 63 additions and 18 deletions
|
|
@ -10,7 +10,7 @@ $('div').live('pagecreate',function(event){
|
|||
})
|
||||
.appendTo( $(this).find('.ui-content') )
|
||||
.wrap('<div class="jqm-themeswitcher">')
|
||||
.click(function(){
|
||||
.bind("vclick", function(){
|
||||
$.themeswitcher();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ $(document).bind("mobileinit", function(){
|
|||
|
||||
<dt>defaultDialogTransition (<em>string</em>, default: 'pop'):</dt>
|
||||
<dd>Set the default transition for dialog changes that use Ajax. Set to 'none' for no transitions by default.</dd>
|
||||
|
||||
<dt>minScrollBack (<em>string</em>, default: 150):</dt>
|
||||
<dd>Minimum scroll distance that will be remembered when returning to a page. </dd>
|
||||
|
||||
<dt>loadingMessage (<em>string</em>, default: "loading"):</dt>
|
||||
<dd>Set the text that appears when a page is loading. If set to false, the message will not appear at all.</dd>
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@
|
|||
//menu items
|
||||
$.each(themes, function( i ){
|
||||
$('<li><a href="#" data-'+ $.mobile.ns +'rel="back">' + themes[ i ].charAt(0).toUpperCase() + themes[ i ].substr(1) + '</a></li>')
|
||||
.click(function(){
|
||||
.bind("vclick", function(){
|
||||
addTheme( themes[i] );
|
||||
menuPage.dialog( "close" );
|
||||
return false;
|
||||
})
|
||||
.appendTo(menu);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@
|
|||
|
||||
//set default page transition - 'none' for no transitions
|
||||
defaultPageTransition: "slide",
|
||||
|
||||
//minimum scroll distance that will be remembered when returning to a page
|
||||
minScrollBack: screen.height / 2,
|
||||
|
||||
//set default dialog transition - 'none' for no transitions
|
||||
defaultDialogTransition: "pop",
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@ $.widget( "mobile.textinput", $.mobile.widget, {
|
|||
themeclass;
|
||||
|
||||
if ( !theme ) {
|
||||
var themedParent = this.element.closest("[class*='ui-bar-'],[class*='ui-body-']");
|
||||
theme = themedParent.length ?
|
||||
/ui-(bar|body)-([a-z])/.exec( themedParent.attr("class") )[2] :
|
||||
"c";
|
||||
var themedParent = this.element.closest("[class*='ui-bar-'],[class*='ui-body-']"),
|
||||
themeLetter = themedParent.length && /ui-(bar|body)-([a-z])/.exec( themedParent.attr("class") ),
|
||||
theme = themeLetter && themeLetter[2] || "c";
|
||||
}
|
||||
|
||||
themeclass = " ui-body-" + theme;
|
||||
|
|
|
|||
|
|
@ -385,20 +385,34 @@
|
|||
|
||||
//function for transitioning between two existing pages
|
||||
function transitionPages( toPage, fromPage, transition, reverse ) {
|
||||
$.mobile.silentScroll();
|
||||
|
||||
|
||||
//get current scroll distance
|
||||
var currScroll = $window.scrollTop();
|
||||
|
||||
var currScroll = $window.scrollTop(),
|
||||
toScroll = toPage.data( "lastScroll" ) || 0;
|
||||
|
||||
//if scrolled down, scroll to top
|
||||
if( currScroll ){
|
||||
window.scrollTo( 0, 0 );
|
||||
}
|
||||
|
||||
//if the Y location we're scrolling to is less than 10px, let it go for sake of smoothness
|
||||
if( toScroll < $.mobile.minScrollBack ){
|
||||
toScroll = 0;
|
||||
}
|
||||
|
||||
if( fromPage ) {
|
||||
//set as data for returning to that spot
|
||||
fromPage
|
||||
.height( screen.height + currScroll )
|
||||
.jqmData( "lastScroll", currScroll )
|
||||
.jqmData( "lastClicked", $activeClickedLink );
|
||||
|
||||
//trigger before show/hide events
|
||||
fromPage.data( "page" )._trigger( "beforehide", null, { nextPage: toPage } );
|
||||
}
|
||||
toPage.data( "page" )._trigger( "beforeshow", null, { prevPage: fromPage || $( "" ) } );
|
||||
toPage
|
||||
.height( screen.height + toScroll )
|
||||
.data( "page" )._trigger( "beforeshow", null, { prevPage: fromPage || $( "" ) } );
|
||||
|
||||
//clear page loader
|
||||
$.mobile.hidePageLoadingMsg();
|
||||
|
|
@ -410,20 +424,43 @@
|
|||
promise = th( transition, reverse, toPage, fromPage );
|
||||
|
||||
promise.done(function() {
|
||||
//reset toPage height bac
|
||||
toPage.height( "" );
|
||||
|
||||
//jump to top or prev scroll, sometimes on iOS the page has not rendered yet.
|
||||
$.mobile.silentScroll( toPage.jqmData( "lastScroll" ) || 0 );
|
||||
$( document ).one( "silentscroll", function() { reFocus( toPage ); } );
|
||||
if( toScroll ){
|
||||
$.mobile.silentScroll( toScroll );
|
||||
$( document ).one( "silentscroll", function() { reFocus( toPage ); } );
|
||||
}
|
||||
else{
|
||||
reFocus( toPage );
|
||||
}
|
||||
|
||||
//trigger show/hide events
|
||||
if( fromPage ) {
|
||||
fromPage.data( "page" )._trigger( "hide", null, { nextPage: toPage } );
|
||||
fromPage.height("").data( "page" )._trigger( "hide", null, { nextPage: toPage } );
|
||||
}
|
||||
|
||||
//trigger pageshow, define prevPage as either fromPage or empty jQuery obj
|
||||
toPage.data( "page" )._trigger( "show", null, { prevPage: fromPage || $( "" ) } );
|
||||
|
||||
resetActivePageHeight();
|
||||
|
||||
});
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
//simply set the active page's minimum height to screen height, depending on orientation
|
||||
function resetActivePageHeight(){
|
||||
var orientation = jQuery.event.special.orientationchange.orientation(),
|
||||
port = orientation === "portrait",
|
||||
winMin = port ? 480 : 320,
|
||||
screenHeight = port ? screen.height : screen.width,
|
||||
winHeight = Math.max( winMin, $( window ).height() ),
|
||||
pageMin = Math.min( screenHeight, winHeight );
|
||||
|
||||
$( ".ui-page-active" ).css( "min-height", pageMin );
|
||||
}
|
||||
|
||||
//shared page enhancements
|
||||
|
|
@ -952,9 +989,8 @@
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
//click routing - direct to HTTP or Ajax, accordingly
|
||||
$( document ).bind( "click", function( event ) {
|
||||
$( document ).bind( "vclick click", function( event ) {
|
||||
var link = findClosestLink( event.target );
|
||||
if ( !link ) {
|
||||
return;
|
||||
|
|
@ -1095,5 +1131,8 @@
|
|||
$.mobile.changePage( $.mobile.firstPage, { transition: transition, changeHash: false, fromHashChange: true } );
|
||||
}
|
||||
});
|
||||
|
||||
//set page min-heights to be device specific
|
||||
$( document ).bind( "pagecreate orientationchange", resetActivePageHeight );
|
||||
|
||||
})( jQuery );
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
/*orientations from js are available */
|
||||
.portrait,
|
||||
.portrait .ui-page,
|
||||
.portrait .ui-page { min-height: 420px; }
|
||||
.landscape,
|
||||
.landscape .ui-page { min-height: 100%; }
|
||||
.landscape .ui-page { min-height: 300px; }
|
||||
|
||||
/* loading screen */
|
||||
.ui-loading .ui-mobile-viewport { overflow: hidden !important; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue