Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Added "fromPage" option to changePage(). This used to be in there b…

…efore the navigation re-work, I just added it back in.

- Added "dataUrl" option to changePage(). This allows a caller to specify a page element to change to, but specify an alternate URL for location display purposes. This is useful for dynamic applications that re-use and over-write existing page content to avoid overwhelming the DOM.

- Renamed the "beforechangepage" and "changepage" events to "pagebeforechange" and "pagechange" respectively. This was done to match the page widget naming of its notifications. Left the triggers for the old events in place but with DEPRECATED comments.

- Renamed the properties of the data object passed to the page events.
  • Loading branch information...
commit 6aa8c8f3b0cb769d2caac329834c605d9af32d9e 1 parent 701b381
@jblas jblas authored
Showing with 27 additions and 11 deletions.
  1. +27 −11 js/jquery.mobile.navigation.js
View
38 js/jquery.mobile.navigation.js
@@ -831,18 +831,28 @@
// Make sure we have a pageContainer to work with.
settings.pageContainer = settings.pageContainer || $.mobile.pageContainer;
+ // Make sure we have a fromPage.
+ settings.fromPage = settings.fromPage || $.mobile.activePage;
+
var mpc = settings.pageContainer,
- bcpEvent = new $.Event( "beforechangepage" ),
- url = toPage;
+ pbcEvent = new $.Event( "pagebeforechange" ),
+ triggerData = { toPage: toPage, options: settings };
// Let listeners know we're about to change the current page.
- mpc.trigger( bcpEvent, { url: url, settings: settings } );
+ mpc.trigger( pbcEvent, triggerData );
+
+ mpc.trigger( "beforechangepage", triggerData ); // XXX: DEPRECATED for 1.0
// If the default behavior is prevented, stop here!
- if( bcpEvent.isDefaultPrevented() ){
+ if( pbcEvent.isDefaultPrevented() ){
return;
}
-
+
+ // We allow "pagebeforechange" observers to modify the toPage in the trigger
+ // data to allow for redirects. Make sure our toPage is updated.
+
+ toPage = triggerData.toPage;
+
// Set the isPageTransitioning flag to prevent any requests from
// entering this method while we are in the midst of loading a page
// or transitioning.
@@ -869,15 +879,16 @@
//release transition lock so navigation is free again
releasePageTransitionLock();
- settings.pageContainer.trigger("changepagefailed");
+ settings.pageContainer.trigger( "pagechangefailed", triggerData );
+ settings.pageContainer.trigger( "changepagefailed", triggerData ); // XXX: DEPRECATED for 1.0
});
return;
}
// The caller passed us a real page DOM element. Update our
// internal state and then trigger a transition to the page.
- var fromPage = $.mobile.activePage,
- url = toPage.jqmData( "url" ),
+ var fromPage = settings.fromPage,
+ url = ( settings.dataUrl && path.convertUrlToDataUrl( settings.dataUrl ) ) || toPage.jqmData( "url" ),
// The pageUrl var is usually the same as url, except when url is obscured as a dialog url. pageUrl always contains the file path
pageUrl = url,
fileUrl = path.getFilePath( url ),
@@ -895,7 +906,8 @@
// to the same page.
if( fromPage && fromPage[0] === toPage[0] ) {
isPageTransitioning = false;
- mpc.trigger( "changepage" );
+ mpc.trigger( "pagechange", triggerData );
+ mpc.trigger( "changepage", triggerData ); // XXX: DEPRECATED for 1.0
return;
}
@@ -982,7 +994,9 @@
releasePageTransitionLock();
// Let listeners know we're all done changing the current page.
- mpc.trigger( "changepage" );
+ mpc.trigger( "pagechange", triggerData );
+
+ mpc.trigger( "changepage", triggerData ); // XXX: DEPRECATED for 1.0
});
};
@@ -994,7 +1008,9 @@
role: undefined, // By default we rely on the role defined by the @data-role attribute.
duplicateCachedPage: undefined,
pageContainer: undefined,
- showLoadMsg: true //loading message shows by default when pages are being fetched during changePage
+ showLoadMsg: true, //loading message shows by default when pages are being fetched during changePage
+ dataUrl: undefined,
+ fromPage: undefined
};
/* Event Bindings - hashchange, submit, and click */
Please sign in to comment.
Something went wrong with that request. Please try again.