Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jquery/jquery-mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
jblas committed Sep 13, 2011
2 parents 1a92be0 + 942b0c2 commit 56a2272
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 24 deletions.
5 changes: 5 additions & 0 deletions js/jquery.mobile.forms.select.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
this.setButtonCount();
},

// open and close preserved in native selects
// to simplify users code when looping over selects
open: $.noop,
close: $.noop,

disable: function() {
this._setDisabled( true );
this.button.addClass( "ui-disabled" );
Expand Down
12 changes: 8 additions & 4 deletions js/jquery.mobile.listview.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
$li = this.element.children( "li" );
// at create time the li are not visible yet so we need to rely on .ui-screen-hidden
$visibleli = create?$li.not( ".ui-screen-hidden" ):$li.filter( ":visible" );

this._removeCorners( $li );

// Select the first visible li element
Expand Down Expand Up @@ -206,7 +206,7 @@ $.widget( "mobile.listview", $.mobile.widget, {

self._itemApply( $list, item );
}

this._refreshCorners( create );
},

Expand Down Expand Up @@ -269,8 +269,12 @@ $.widget( "mobile.listview", $.mobile.widget, {

}).listview();

//on pagehide, remove any nested pages along with the parent page, as long as they aren't active
if( hasSubPages && parentPage.data("page").options.domCache === false ){
// on pagehide, remove any nested pages along with the parent page, as long as they aren't active
// and aren't embedded
if( hasSubPages &&
parentPage.is( "jqmData(external-page='true')" ) &&
parentPage.data("page").options.domCache === false ) {

var newRemove = function( e, ui ){
var nextPage = ui.nextPage, npURL;

Expand Down
42 changes: 23 additions & 19 deletions js/jquery.mobile.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,26 +398,26 @@
$.mobile.changePage.apply( null, pageTransitionQueue.pop() );
}
}

// Save the last scroll distance per page, before it is hidden
var getLastScroll = (function( lastScrollEnabled ){
return function(){
if( !lastScrollEnabled ){
lastScrollEnabled = true;
return;
}

lastScrollEnabled = false;

var active = $.mobile.urlHistory.getActive(),
activePage = $( ".ui-page-active" ),
scrollElem = $( window ),
touchOverflow = $.support.touchOverflow && $.mobile.touchOverflowEnabled;

if( touchOverflow ){
scrollElem = activePage.is( ".ui-native-fixed" ) ? activePage.find( ".ui-content" ) : activePage;
}
}

if( active ){
var lastScroll = scrollElem.scrollTop();

Expand All @@ -427,12 +427,12 @@
}
};
})( true );

// to get last scroll, we need to get scrolltop before the page change
// using beforechangepage or popstate/hashchange (whichever comes first)
$( document ).bind( "beforechangepage", getLastScroll );
$( window ).bind( $.support.pushState ? "popstate" : "hashchange", getLastScroll );

// Make the iOS clock quick-scroll work again if we're using native overflow scrolling
/*
if( $.support.touchOverflow ){
Expand All @@ -454,30 +454,30 @@
touchOverflow = $.support.touchOverflow && $.mobile.touchOverflowEnabled,
toScroll = active.lastScroll || ( touchOverflow ? 0 : $.mobile.defaultHomeScroll ),
screenHeight = getScreenHeight();

// Scroll to top, hide addr bar
window.scrollTo( 0, $.mobile.defaultHomeScroll );

if( fromPage ) {
//trigger before show/hide events
fromPage.data( "page" )._trigger( "beforehide", null, { nextPage: toPage } );
}

if( !touchOverflow){
toPage.height( screenHeight + toScroll );
}
}

toPage.data( "page" )._trigger( "beforeshow", null, { prevPage: fromPage || $( "" ) } );

//clear page loader
$.mobile.hidePageLoadingMsg();

if( touchOverflow && toScroll ){

toPage.addClass( "ui-mobile-pre-transition" );
// Send focus to page as it is now display: block
reFocus( toPage );

//set page's scrollTop to remembered distance
if( toPage.is( ".ui-native-fixed" ) ){
toPage.find( ".ui-content" ).scrollTop( toScroll );
Expand All @@ -500,7 +500,7 @@
// Send focus to the newly shown page
reFocus( toPage );
}

// Jump to top or prev scroll, sometimes on iOS the page has not rendered yet.
if( !touchOverflow ){
$.mobile.silentScroll( toScroll );
Expand All @@ -511,7 +511,7 @@
if( !touchOverflow ){
fromPage.height( "" );
}

fromPage.data( "page" )._trigger( "hide", null, { nextPage: toPage } );
}

Expand All @@ -533,7 +533,7 @@

return pageMin;
}

$.mobile.getScreenHeight = getScreenHeight;

//simply set the active page's minimum height to screen height, depending on orientation
Expand Down Expand Up @@ -784,8 +784,12 @@
}

//append to page and enhance
// TODO taging a page with external to make sure that embedded pages aren't removed
// by the various page handling code is bad. Having page handling code in many
// places is bad. Solutions post 1.0
page
.attr( "data-" + $.mobile.ns + "url", path.convertUrlToDataUrl( fileUrl ) )
.attr( "data-" + $.mobile.ns + "external-page", true )
.appendTo( settings.pageContainer );

// wait for page creation to leverage options defined on widget
Expand Down Expand Up @@ -920,7 +924,7 @@
mpc.trigger( pbcEvent, triggerData );

mpc.trigger( "beforechangepage", triggerData ); // XXX: DEPRECATED for 1.0

// If the default behavior is prevented, stop here!
if( pbcEvent.isDefaultPrevented() ){
return;
Expand Down
1 change: 1 addition & 0 deletions tests/unit/listview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ <h1>Basic List View</h1>
<li><a href="#basic-link-results">Home</a></li>
<li><a href="#basic-link-results">Back</a></li>
<li><a href="#basic-link-results">Return</a></li>
<li><a href="#nested-list-test" id="nested-list-test-anchor">Nested List Test</a></li>
</ul>
</div>
<a href="cache-tests/nested.html" id="cached-tests"></a>
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/listview/listview_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,4 +730,25 @@
}
]);
});

asyncTest( "embedded listview page with nested pages is not removed from the dom", function() {
$.testHelper.pageSequence([
function() {
// open the nested list page
same( $("div#nested-list-test").length, 1 );
$( "a#nested-list-test-anchor" ).click();
},

function() {
// go back to the origin page
window.history.back();
},

function() {
// make sure the page is still in place
same( $("div#nested-list-test").length, 1 );
start();
}
]);
});
})(jQuery);
10 changes: 9 additions & 1 deletion tests/unit/select/select_native.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@
var select = $( "#native-refresh" ),
button = select.siblings( '.ui-btn-inner' ),
text = "foo";

same(button.text(), "default");
select.find( "option" ).remove(); //remove the loading message
select.append('<option value="1">' + text + '</option>');
select.selectmenu('refresh');
same(button.text(), text);
});

// issue 2424
test( "native selects should provide open and close as a no-op", function() {
// exception will prevent test success if undef
$( "#native-refresh" ).selectmenu( 'open' );
$( "#native-refresh" ).selectmenu( 'close' );
ok( true );
});
})(jQuery);

0 comments on commit 56a2272

Please sign in to comment.