--- a/js/jquery.mobile-1.0b2.js
+++ b/js/jquery.mobile-1.0b2.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Mobile v1.0b1
+ * jQuery Mobile v1.0b2
* http://jquerymobile.com/
*
* Copyright 2010, jQuery Project
@@ -274,20 +274,27 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
-(function($, undefined ) {
+
+(function( $, undefined ) {
$.widget( "mobile.widget", {
_getCreateOptions: function() {
+
var elem = this.element,
options = {};
+
$.each( this.options, function( option ) {
+
var value = elem.jqmData( option.replace( /[A-Z]/g, function( c ) {
- return "-" + c.toLowerCase();
- } ) );
+ return "-" + c.toLowerCase();
+ })
+ );
+
if ( value !== undefined ) {
options[ option ] = value;
}
});
+
return options;
}
});
@@ -299,14 +306,10 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
-(function($, undefined ) {
-
-var $window = $(window),
- $html = $( "html" ),
-
- //media-query-like width breakpoints, which are translated to classes on the html element
- resolutionBreakpoints = [320,480,768,1024];
-
+(function( $, undefined ) {
+
+var $window = $( window ),
+ $html = $( "html" );
/* $.mobile.media method: pass a CSS media type or query and get a bool return
note: this feature relies on actual media query support for media queries, though types will work most anywhere
@@ -323,17 +326,18 @@
return function( query ) {
if ( !( query in cache ) ) {
- var styleBlock = document.createElement('style'),
- cssrule = "@media " + query + " { #jquery-mediatest { position:absolute; } }";
- //must set type for IE!
- styleBlock.type = "text/css";
- if (styleBlock.styleSheet){
- styleBlock.styleSheet.cssText = cssrule;
- }
- else {
- styleBlock.appendChild(document.createTextNode(cssrule));
- }
-
+ var styleBlock = document.createElement( "style" ),
+ cssrule = "@media " + query + " { #jquery-mediatest { position:absolute; } }";
+
+ //must set type for IE!
+ styleBlock.type = "text/css";
+
+ if ( styleBlock.styleSheet ){
+ styleBlock.styleSheet.cssText = cssrule;
+ } else {
+ styleBlock.appendChild( document.createTextNode(cssrule) );
+ }
+
$html.prepend( fakeBody ).prepend( styleBlock );
cache[ query ] = testDiv.css( "position" ) === "absolute";
fakeBody.add( styleBlock ).remove();
@@ -341,122 +345,51 @@
return cache[ query ];
};
})();
-
-/*
- private function for adding/removing breakpoint classes to HTML element for faux media-query support
- It does not require media query support, instead using JS to detect screen width > cross-browser support
- This function is called on orientationchange, resize, and mobileinit, and is bound via the 'htmlclass' event namespace
-*/
-function detectResolutionBreakpoints(){
- var currWidth = $window.width(),
- minPrefix = "min-width-",
- maxPrefix = "max-width-",
- minBreakpoints = [],
- maxBreakpoints = [],
- unit = "px",
- breakpointClasses;
-
- $html.removeClass( minPrefix + resolutionBreakpoints.join(unit + " " + minPrefix) + unit + " " +
- maxPrefix + resolutionBreakpoints.join( unit + " " + maxPrefix) + unit );
-
- $.each(resolutionBreakpoints,function( i, breakPoint ){
- if( currWidth >= breakPoint ){
- minBreakpoints.push( minPrefix + breakPoint + unit );
- }
- if( currWidth <= breakPoint ){
- maxBreakpoints.push( maxPrefix + breakPoint + unit );
- }
- });
-
- if( minBreakpoints.length ){ breakpointClasses = minBreakpoints.join(" "); }
- if( maxBreakpoints.length ){ breakpointClasses += " " + maxBreakpoints.join(" "); }
-
- $html.addClass( breakpointClasses );
-};
-
-/* $.mobile.addResolutionBreakpoints method:
- pass either a number or an array of numbers and they'll be added to the min/max breakpoint classes
- Examples:
- $.mobile.addResolutionBreakpoints( 500 );
- $.mobile.addResolutionBreakpoints( [500, 1200] );
-*/
-$.mobile.addResolutionBreakpoints = function( newbps ){
- if( $.type( newbps ) === "array" ){
- resolutionBreakpoints = resolutionBreakpoints.concat( newbps );
- }
- else {
- resolutionBreakpoints.push( newbps );
- }
- resolutionBreakpoints.sort(function(a,b){ return a-b; });
- detectResolutionBreakpoints();
-};
-
-/* on mobileinit, add classes to HTML element
- and set handlers to update those on orientationchange and resize*/
-$(document).bind("mobileinit.htmlclass", function(){
- /* bind to orientationchange and resize
- to add classes to HTML element for min/max breakpoints and orientation */
- var ev = $.support.orientation;
- $window.bind("orientationchange.htmlclass throttledResize.htmlclass", function(event){
- //add orientation class to HTML element on flip/resize.
- if(event.orientation){
- $html.removeClass( "portrait landscape" ).addClass( event.orientation );
- }
- //add classes to HTML element for min/max breakpoints
- detectResolutionBreakpoints();
- });
-});
-
-/* Manually trigger an orientationchange event when the dom ready event fires.
- This will ensure that any viewport meta tag that may have been injected
- has taken effect already, allowing us to properly calculate the width of the
- document.
-*/
-$(function(){
- //trigger event manually
- $window.trigger( "orientationchange.htmlclass" );
-});
})(jQuery);/*
* jQuery Mobile Framework : support tests
* Copyright (c) jQuery Project
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
-* Note: Code is in draft form and is subject to change
*/
-( function( $, undefined ) {
-
-var fakeBody = $( "
" ).prependTo( "html" ),
+
+(function( $, undefined ) {
+
+var fakeBody = $( "" ).prependTo( "html" ),
fbCSS = fakeBody[ 0 ].style,
vendors = [ "webkit", "moz", "o" ],
- webos = "palmGetResource" in window, //only used to rule out scrollTop
+ webos = "palmGetResource" in window, //only used to rule out scrollTop
bb = window.blackberry; //only used to rule out box shadow, as it's filled opaque on BB
// thx Modernizr
-function propExists( prop ){
+function propExists( prop ) {
var uc_prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ),
- props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " );
- for( var v in props ){
- if( fbCSS[ v ] !== undefined ){
+ props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " );
+
+ for ( var v in props ){
+ if ( fbCSS[ v ] !== undefined ) {
return true;
}
}
}
-// test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
-function baseTagTest(){
+// Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
+function baseTagTest() {
var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
base = $( "head base" ),
fauxEle = null,
- href = "";
+ href = "",
+ link, rebase;
+
if ( !base.length ) {
- base = fauxEle = $( "" ).html( $(this).clone() ).html()
- .replace( self._typeAttributeRegex, " type=\""+ optType +"\" data-" + $.mobile.ns + "type=\""+type+"\" " ) );
- }
- });
-
- // We re-find form elements since the degredation code above
- // may have injected new elements. We cache the non-native control
- // query to reduce the number of times we search through the entire page.
-
- var allControls = this.element.find("input, textarea, select, button"),
- nonNativeControls = allControls.not(this.keepNative);
-
- // XXX: Temporary workaround for issue 785. Turn off autocorrect and
- // autocomplete since the popup they use can't be dismissed by
- // the user. Note that we test for the presence of the feature
- // by looking for the autocorrect property on the input element.
-
- var textInputs = allControls.filter( "input[type=text]" );
- if (textInputs.length && typeof textInputs[0].autocorrect !== "undefined") {
- textInputs.each(function(){
- // Set the attribute instead of the property just in case there
- // is code that attempts to make modifications via HTML.
- this.setAttribute("autocorrect", "off");
- this.setAttribute("autocomplete", "off");
- });
- }
-
- // enchance form controls
- nonNativeControls
- .filter( "[type='radio'], [type='checkbox']" )
- .checkboxradio();
-
- nonNativeControls
- .filter( "button, [type='button'], [type='submit'], [type='reset'], [type='image']" )
- .button();
-
- nonNativeControls
- .filter( "input, textarea" )
- .not( "[type='radio'], [type='checkbox'], [type='button'], [type='submit'], [type='reset'], [type='image'], [type='hidden']" )
- .textinput();
-
- nonNativeControls
- .filter( "input, select" )
- .filter( ":jqmData(role='slider'), :jqmData(type='range')" )
- .slider();
-
- nonNativeControls
- .filter( "select:not(:jqmData(role='slider'))" )
- .selectmenu();
+ $elem.addClass( "ui-page ui-body-" + o.theme );
}
});
@@ -1847,61 +1680,55 @@
(function( $, window, undefined ) {
- //jQuery.mobile configurable options
+ // jQuery.mobile configurable options
$.extend( $.mobile, {
- //namespace used framework-wide for data-attrs. Default is no namespace
+ // Namespace used framework-wide for data-attrs. Default is no namespace
ns: "",
- //define the url parameter used for referencing widget-generated sub-pages.
- //Translates to to example.html&ui-page=subpageIdentifier
- //hash segment before &ui-page= is used to make Ajax request
+ // Define the url parameter used for referencing widget-generated sub-pages.
+ // Translates to to example.html&ui-page=subpageIdentifier
+ // hash segment before &ui-page= is used to make Ajax request
subPageUrlKey: "ui-page",
- //anchor links with a data-rel, or pages with a data-role, that match these selectors will be untrackable in history
- //(no change in URL, not bookmarkable)
- nonHistorySelectors: "dialog",
-
- //class assigned to page currently in view, and during transitions
+ // Class assigned to page currently in view, and during transitions
activePageClass: "ui-page-active",
- //class used for "active" button state, from CSS framework
+ // Class used for "active" button state, from CSS framework
activeBtnClass: "ui-btn-active",
- //automatically handle clicks and form submissions through Ajax, when same-domain
+ // Automatically handle clicks and form submissions through Ajax, when same-domain
ajaxEnabled: true,
+
+ // Automatically load and show pages based on location.hash
+ hashListeningEnabled: true,
+
+ // 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",
+
+ // Show loading message during Ajax requests
+ // if false, message will not appear, but loading classes will still be toggled on html el
+ loadingMessage: "loading",
+
+ // Error response message - appears when an Ajax page request fails
+ pageLoadErrorMessage: "Error Loading Page",
- //When enabled, clicks and taps that result in Ajax page changes will happen slightly sooner on touch devices.
- //Also, it will prevent the address bar from appearing on platforms like iOS during page transitions.
- //This option has no effect on non-touch devices, but enabling it may interfere with jQuery plugins that bind to click events
- useFastClick: true,
-
- //automatically load and show pages based on location.hash
- hashListeningEnabled: true,
-
- //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",
-
- //show loading message during Ajax requests
- //if false, message will not appear, but loading classes will still be toggled on html el
- loadingMessage: "loading",
-
- //error response message - appears when an Ajax page request fails
- pageLoadErrorMessage: "Error Loading Page",
-
- //support conditions that must be met in order to proceed
- //default enhanced qualifications are media query support OR IE 7+
+ //automatically initialize the DOM when it's ready
+ autoInitializePage: true,
+
+ // Support conditions that must be met in order to proceed
+ // default enhanced qualifications are media query support OR IE 7+
gradeA: function(){
return $.support.mediaquery || $.mobile.browser.ie && $.mobile.browser.ie >= 7;
},
- //TODO might be useful upstream in jquery itself ?
+ // TODO might be useful upstream in jquery itself ?
keyCode: {
ALT: 18,
BACKSPACE: 8,
@@ -1937,9 +1764,9 @@
WINDOWS: 91 // COMMAND
},
- //scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
+ // Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
silentScroll: function( ypos ) {
- if( $.type( ypos ) !== "number" ){
+ if ( $.type( ypos ) !== "number" ) {
ypos = $.mobile.defaultHomeScroll;
}
@@ -1948,53 +1775,52 @@
setTimeout(function() {
window.scrollTo( 0, ypos );
- $(document).trigger( "silentscroll", { x: 0, y: ypos });
- },20);
+ $( document ).trigger( "silentscroll", { x: 0, y: ypos });
+ }, 20 );
setTimeout(function() {
$.event.special.scrollstart.enabled = true;
}, 150 );
},
- // compile the namespace normalization regex once
- normalizeRegex: /-([a-z])/g,
-
- // take a data attribute property, prepend the namespace
+ // Take a data attribute property, prepend the namespace
// and then camel case the attribute string
- nsNormalize: function(prop){
- if(!prop) return;
+ nsNormalize: function( prop ) {
+ if ( !prop ) {
+ return;
+ }
return $.camelCase( $.mobile.ns + prop );
}
});
- //mobile version of data and removeData and hasData methods
- //ensures all data is set and retrieved using jQuery Mobile's data namespace
- $.fn.jqmData = function( prop, value ){
- return this.data( prop ? $.mobile.nsNormalize(prop) : prop, value );
+ // Mobile version of data and removeData and hasData methods
+ // ensures all data is set and retrieved using jQuery Mobile's data namespace
+ $.fn.jqmData = function( prop, value ) {
+ return this.data( prop ? $.mobile.nsNormalize( prop ) : prop, value );
};
- $.jqmData = function( elem, prop, value ){
- return $.data( elem, $.mobile.nsNormalize(prop), value );
+ $.jqmData = function( elem, prop, value ) {
+ return $.data( elem, $.mobile.nsNormalize( prop ), value );
};
- $.fn.jqmRemoveData = function( prop ){
- return this.removeData( $.mobile.nsNormalize(prop) );
+ $.fn.jqmRemoveData = function( prop ) {
+ return this.removeData( $.mobile.nsNormalize( prop ) );
};
- $.jqmRemoveData = function( elem, prop ){
- return $.removeData( elem, $.mobile.nsNormalize(prop) );
+ $.jqmRemoveData = function( elem, prop ) {
+ return $.removeData( elem, $.mobile.nsNormalize( prop ) );
};
- $.jqmHasData = function( elem, prop ){
- return $.hasData( elem, $.mobile.nsNormalize(prop) );
+ $.jqmHasData = function( elem, prop ) {
+ return $.hasData( elem, $.mobile.nsNormalize( prop ) );
};
// Monkey-patching Sizzle to filter the :jqmData selector
var oldFind = $.find;
$.find = function( selector, context, ret, extra ) {
- selector = selector.replace(/:jqmData\(([^)]*)\)/g, "[data-" + ($.mobile.ns || "") + "$1]");
+ selector = selector.replace(/:jqmData\(([^)]*)\)/g, "[data-" + ( $.mobile.ns || "" ) + "$1]");
return oldFind.call( this, selector, context, ret, extra );
};
@@ -2006,7 +1832,7 @@
};
$.find.matchesSelector = function( node, expr ) {
- return $.find( expr, null, null, [node] ).length > 0;
+ return $.find( expr, null, null, [ node ] ).length > 0;
};
})( jQuery, this );
/*
@@ -2056,7 +1882,7 @@
parseUrl: function( url ) {
// If we're passed an object, we'll assume that it is
// a parsed url object and just return it back to the caller.
- if ( typeof url === "object" ) {
+ if ( $.type( url ) === "object" ) {
return url;
}
@@ -2097,10 +1923,10 @@
if ( relPath && relPath.charAt( 0 ) === "/" ) {
return relPath;
}
-
+
relPath = relPath || "";
- absPath = absPath ? absPath.replace( /^\/|\/?[^\/]*$/g, "" ) : "";
-
+ absPath = absPath ? absPath.replace( /^\/|(\/[^\/]*|[^\/]+)$/g, "" ) : "";
+
var absStack = absPath ? absPath.split( "/" ) : [],
relStack = relPath.split( "/" );
for ( var i = 0; i < relStack.length; i++ ) {
@@ -2143,7 +1969,7 @@
if ( !path.isRelativeUrl( relUrl ) ) {
return relUrl;
}
-
+
var relObj = path.parseUrl( relUrl ),
absObj = path.parseUrl( absUrl ),
protocol = relObj.protocol || absObj.protocol,
@@ -2152,7 +1978,7 @@
pathname = path.makePathAbsolute( relObj.pathname || absObj.filename, absObj.pathname ),
search = relObj.search || ( !hasPath && absObj.search ) || "",
hash = relObj.hash;
-
+
return protocol + "//" + authority + pathname + search + hash;
},
@@ -2167,7 +1993,9 @@
convertUrlToDataUrl: function( absUrl ) {
var u = path.parseUrl( absUrl );
if ( path.isEmbeddedPage( u ) ) {
- return u.hash.replace( /^#/, "" );
+ // For embedded pages, remove the dialog hash key as in getFilePath(),
+ // otherwise the Data Url won't match the id of the embedded Page.
+ return u.hash.split( dialogHashKey )[0].replace( /^#/, "" );
} else if ( path.isSameDomain( u, documentBase ) ) {
return u.hrefNoHash.replace( documentBase.domain, "" );
}
@@ -2246,7 +2074,8 @@
//urlHistory is purely here to make guesses at whether the back or forward button was clicked
//and provide an appropriate transition
urlHistory = {
- //array of pages that are visited during a single page load. each has a url and optional transition
+ // Array of pages that are visited during a single page load.
+ // Each has a url and optional transition, title, and pageUrl (which represents the file path, in cases where URL is obscured, such as dialogs)
stack: [],
//maintain an index number for the active page in the stack
@@ -2266,13 +2095,13 @@
},
// addNew is used whenever a new page is added
- addNew: function( url, transition, title, storedTo ) {
+ addNew: function( url, transition, title, pageUrl ) {
//if there's forward history, wipe it
if( urlHistory.getNext() ) {
urlHistory.clearForward();
}
- urlHistory.stack.push( {url : url, transition: transition, title: title, page: storedTo } );
+ urlHistory.stack.push( {url : url, transition: transition, title: title, pageUrl: pageUrl } );
urlHistory.activeIndex = urlHistory.stack.length - 1;
},
@@ -2396,29 +2225,29 @@
//function for transitioning between two existing pages
function transitionPages( toPage, fromPage, transition, reverse ) {
-
+
//get current scroll distance
var currScroll = $.support.scrollTop ? $window.scrollTop() : true,
toScroll = toPage.data( "lastScroll" ) || $.mobile.defaultHomeScroll,
screenHeight = getScreenHeight();
-
+
//if scrolled down, scroll to top
if( currScroll ){
window.scrollTo( 0, $.mobile.defaultHomeScroll );
}
-
+
//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( screenHeight + currScroll )
.jqmData( "lastScroll", currScroll )
.jqmData( "lastClicked", $activeClickedLink );
-
+
//trigger before show/hide events
fromPage.data( "page" )._trigger( "beforehide", null, { nextPage: toPage } );
}
@@ -2438,28 +2267,28 @@
promise.done(function() {
//reset toPage height bac
toPage.height( "" );
-
+
//jump to top or prev scroll, sometimes on iOS the page has not rendered yet.
if( toScroll ){
$.mobile.silentScroll( toScroll );
$( document ).one( "silentscroll", function() { reFocus( toPage ); } );
}
else{
- reFocus( toPage );
+ reFocus( toPage );
}
//trigger show/hide events
if( fromPage ) {
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 || $( "" ) } );
});
return promise;
}
-
+
//simply set the active page's minimum height to screen height, depending on orientation
function getScreenHeight(){
var orientation = jQuery.event.special.orientationchange.orientation(),
@@ -2471,7 +2300,7 @@
return pageMin;
}
-
+
//simply set the active page's minimum height to screen height, depending on orientation
function resetActivePageHeight(){
$( "." + $.mobile.activePageClass ).css( "min-height", getScreenHeight() );
@@ -2570,9 +2399,15 @@
// page is loaded off the network.
dupCachedPage = null,
+ // determine the current base url
+ findBaseWithDefault = function(){
+ var closestBase = ( $.mobile.activePage && getClosestBaseUrl( $.mobile.activePage ) );
+ return closestBase || documentBase.hrefNoHash;
+ },
+
// The absolute version of the URL passed into the function. This
// version of the URL may contain dialog/subpage params in it.
- absUrl = path.makeUrlAbsolute( url, documentBase.hrefNoHash );
+ absUrl = path.makeUrlAbsolute( url, findBaseWithDefault() );
// If the caller provided data, and we're using "get" request,
@@ -2618,19 +2453,36 @@
}
if ( settings.showLoadMsg ) {
- $.mobile.showPageLoadingMsg();
- }
-
- // Load the new page.
- $.ajax({
- url: fileUrl,
- type: settings.type,
- data: settings.data,
- dataType: "html",
- success: function( html ) {
- //pre-parse html to check for a data-url,
- //use it as the new fileUrl, base path, etc
- var all = $( "
" ),
+
+ // This configurable timeout allows cached pages a brief delay to load without showing a message
+ var loadMsgDelay = setTimeout(function(){
+ $.mobile.showPageLoadingMsg();
+ }, settings.loadMsgDelay ),
+
+ // Shared logic for clearing timeout and removing message.
+ hideMsg = function(){
+
+ // Stop message show timer
+ clearTimeout( loadMsgDelay );
+
+ // Hide loading message
+ $.mobile.hidePageLoadingMsg();
+ };
+ }
+
+ if ( !( $.mobile.allowCrossDomainPages || path.isSameDomain( documentUrl, absUrl ) ) ) {
+ deferred.reject( absUrl, options );
+ } else {
+ // Load the new page.
+ $.ajax({
+ url: fileUrl,
+ type: settings.type,
+ data: settings.data,
+ dataType: "html",
+ success: function( html ) {
+ //pre-parse html to check for a data-url,
+ //use it as the new fileUrl, base path, etc
+ var all = $( "
" ),
//page title regexp
newPageTitle = html.match( /
]*>([^<]*)/ ) && RegExp.$1,
@@ -2640,90 +2492,114 @@
dataUrlRegex = new RegExp( "\\bdata-" + $.mobile.ns + "url=[\"']?([^\"'>]*)[\"']?" );
- // data-url must be provided for the base tag so resource requests can be directed to the
- // correct url. loading into a temprorary element makes these requests immediately
- if( pageElemRegex.test( html )
- && RegExp.$1
- && dataUrlRegex.test( RegExp.$1 )
- && RegExp.$1 ) {
- url = fileUrl = path.getFilePath( RegExp.$1 );
- }
-
- if ( base ) {
- base.set( fileUrl );
- }
-
- //workaround to allow scripts to execute when included in page divs
- all.get( 0 ).innerHTML = html;
- page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first();
-
- if ( newPageTitle && !page.jqmData( "title" ) ) {
- page.jqmData( "title", newPageTitle );
- }
-
- //rewrite src and href attrs to use a base url
- if( !$.support.dynamicBaseTag ) {
- var newPath = path.get( fileUrl );
- page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() {
- var thisAttr = $( this ).is( '[href]' ) ? 'href' :
- $(this).is('[src]') ? 'src' : 'action',
- thisUrl = $( this ).attr( thisAttr );
-
- // XXX_jblas: We need to fix this so that it removes the document
- // base URL, and then prepends with the new page URL.
- //if full path exists and is same, chop it - helps IE out
- thisUrl = thisUrl.replace( location.protocol + '//' + location.host + location.pathname, '' );
-
- if( !/^(\w+:|#|\/)/.test( thisUrl ) ) {
- $( this ).attr( thisAttr, newPath + thisUrl );
+ // data-url must be provided for the base tag so resource requests can be directed to the
+ // correct url. loading into a temprorary element makes these requests immediately
+ if( pageElemRegex.test( html )
+ && RegExp.$1
+ && dataUrlRegex.test( RegExp.$1 )
+ && RegExp.$1 ) {
+ url = fileUrl = path.getFilePath( RegExp.$1 );
+ }
+ else{
+
+ }
+
+ if ( base ) {
+ base.set( fileUrl );
+ }
+
+ //workaround to allow scripts to execute when included in page divs
+ all.get( 0 ).innerHTML = html;
+ page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first();
+
+ //if page elem couldn't be found, create one and insert the body element's contents
+ if( !page.length ){
+ page = $( "" + html.split( /<\/?body[^>]*>/gmi )[1] + "
" );
+ }
+
+ if ( newPageTitle && !page.jqmData( "title" ) ) {
+ page.jqmData( "title", newPageTitle );
+ }
+
+ //rewrite src and href attrs to use a base url
+ if( !$.support.dynamicBaseTag ) {
+ var newPath = path.get( fileUrl );
+ page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() {
+ var thisAttr = $( this ).is( '[href]' ) ? 'href' :
+ $(this).is('[src]') ? 'src' : 'action',
+ thisUrl = $( this ).attr( thisAttr );
+
+ // XXX_jblas: We need to fix this so that it removes the document
+ // base URL, and then prepends with the new page URL.
+ //if full path exists and is same, chop it - helps IE out
+ thisUrl = thisUrl.replace( location.protocol + '//' + location.host + location.pathname, '' );
+
+ if( !/^(\w+:|#|\/)/.test( thisUrl ) ) {
+ $( this ).attr( thisAttr, newPath + thisUrl );
+ }
+ });
+ }
+
+ //append to page and enhance
+ page
+ .attr( "data-" + $.mobile.ns + "url", path.convertUrlToDataUrl( fileUrl ) )
+ .appendTo( settings.pageContainer );
+
+ // wait for page creation to leverage options defined on widget
+ page.one('pagecreate', function(){
+
+ // when dom caching is not enabled bind to remove the page on hide
+ if( !page.data("page").options.domCache ){
+ page.bind( "pagehide.remove", function(){
+ $(this).remove();
+ });
}
});
- }
-
- //append to page and enhance
- page
- .attr( "data-" + $.mobile.ns + "url", path.convertUrlToDataUrl( fileUrl ) )
- .appendTo( settings.pageContainer );
-
- enhancePage( page, settings.role );
-
- // Enhancing the page may result in new dialogs/sub pages being inserted
- // into the DOM. If the original absUrl refers to a sub-page, that is the
- // real page we are interested in.
- if ( absUrl.indexOf( "&" + $.mobile.subPageUrlKey ) > -1 ) {
- page = settings.pageContainer.children( ":jqmData(url='" + dataUrl + "')" );
- }
-
- // Remove loading message.
- if ( settings.showLoadMsg ) {
- $.mobile.hidePageLoadingMsg();
- }
-
- deferred.resolve( absUrl, options, page, dupCachedPage );
- },
- error: function() {
- //set base back to current path
- if( base ) {
- base.set( path.get() );
- }
-
- // Remove loading message.
-