mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-29 10:24:45 +00:00
Initial changes to allow for cross-domain URLs to be loaded as pages within Phone Gap's web view. I still need to figure out how we're going to set the application URL hash for these cross-domain URLs, and allow for reloading the URL via deep links.
This commit is contained in:
parent
b3cfe8778f
commit
2aab30b7a6
1 changed files with 21 additions and 4 deletions
|
|
@ -279,6 +279,9 @@
|
|||
//history stack
|
||||
$.mobile.urlHistory = urlHistory;
|
||||
|
||||
//enable cross-domain page support
|
||||
$.mobile.allowCrossDomainPages = false;
|
||||
|
||||
// changepage function
|
||||
$.mobile.changePage = function( to, transition, reverse, changeHash, fromHashChange ){
|
||||
//from is always the currently viewed page
|
||||
|
|
@ -667,10 +670,8 @@
|
|||
//rel set to external
|
||||
isEmbeddedPage = path.isEmbeddedPage( url ),
|
||||
|
||||
//check for protocol or rel and its not an embedded page
|
||||
//TODO overlap in logic from isExternal, rel=external check should be
|
||||
// moved into more comprehensive isExternalLink
|
||||
isExternal = path.isExternal( url ) || (isRelExternal && !isEmbeddedPage),
|
||||
//is the url something browser should handle?
|
||||
isExternal = false,
|
||||
|
||||
//if target attr is specified we mimic _blank... for now
|
||||
hasTarget = $this.is( "[target]" ),
|
||||
|
|
@ -678,6 +679,22 @@
|
|||
//if data-ajax attr is set to false, use the default behavior of a link
|
||||
hasAjaxDisabled = $this.is( "[data-ajax='false']" );
|
||||
|
||||
//check for protocol or rel and its not an embedded page
|
||||
//TODO overlap in logic from isExternal, rel=external check should be
|
||||
// moved into more comprehensive isExternalLink
|
||||
if (path.isExternal(url)) {
|
||||
// Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR
|
||||
// requests if the document doing the request was loaded via the file:// protocol.
|
||||
// This is usually to allow the application to "phone home" and fetch app specific
|
||||
// data. We normally let the browser handle external/cross-domain urls, but if the
|
||||
// allowCrossDomainPages option is true, we will allow cross-domain http/https
|
||||
// requests to go through our page loading logic.
|
||||
isExternal = ($.mobile.allowCrossDomainPages && location.protocol === "file:" && url.search(/^https?:/) != -1) ? false : true;
|
||||
}
|
||||
else {
|
||||
isExternal = (isRelExternal && !isEmbeddedPage);
|
||||
}
|
||||
|
||||
//if there's a data-rel=back attr, go back in history
|
||||
if( $this.is( "[data-rel='back']" ) ){
|
||||
window.history.back();
|
||||
|
|
|
|||
Loading…
Reference in a new issue