|
348 | 348 | //cache the comparison once.
|
349 | 349 | documentBaseDiffers = ( documentUrl.hrefNoHash !== documentBase.hrefNoHash );
|
350 | 350 |
|
351 |
| - //base element management, defined depending on dynamic base tag support |
352 |
| - var base = $.support.dynamicBaseTag ? { |
| 351 | + //base element management, defined depending on dynamic base tag support and if rewriteBase is enabled |
| 352 | + if ($.mobile.rewriteBase) { |
| 353 | + var base = $.support.dynamicBaseTag ? { |
353 | 354 |
|
354 |
| - //define base element, for use in routing asset urls that are referenced in Ajax-requested markup |
355 |
| - element: ( $base.length ? $base : $( "<base>", { href: documentBase.hrefNoHash } ).prependTo( $head ) ), |
| 355 | + //define base element, for use in routing asset urls that are referenced in Ajax-requested markup |
| 356 | + element: ( $base.length ? $base : $( "<base>", { href: documentBase.hrefNoHash } ).prependTo( $head ) ), |
356 | 357 |
|
357 |
| - //set the generated BASE element's href attribute to a new page's base path |
358 |
| - set: function( href ) { |
359 |
| - base.element.attr( "href", path.makeUrlAbsolute( href, documentBase ) ); |
360 |
| - }, |
| 358 | + //set the generated BASE element's href attribute to a new page's base path |
| 359 | + set: function( href ) { |
| 360 | + base.element.attr( "href", path.makeUrlAbsolute( href, documentBase ) ); |
| 361 | + }, |
361 | 362 |
|
362 |
| - //set the generated BASE element's href attribute to a new page's base path |
363 |
| - reset: function() { |
364 |
| - base.element.attr( "href", documentBase.hrefNoHash ); |
365 |
| - } |
| 363 | + //set the generated BASE element's href attribute to a new page's base path |
| 364 | + reset: function() { |
| 365 | + base.element.attr( "href", documentBase.hrefNoHash ); |
| 366 | + } |
366 | 367 |
|
367 |
| - } : undefined; |
| 368 | + } : undefined; |
| 369 | + } else { |
| 370 | + var base = jQuery("head base").attr("href"); |
| 371 | + } |
368 | 372 |
|
369 | 373 | /*
|
370 | 374 | internal utility functions
|
|
837 | 841 | page.jqmData( "title", newPageTitle );
|
838 | 842 | }
|
839 | 843 |
|
840 |
| - //rewrite src and href attrs to use a base url |
841 |
| - if( !$.support.dynamicBaseTag ) { |
842 |
| - var newPath = path.get( fileUrl ); |
843 |
| - page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() { |
844 |
| - var thisAttr = $( this ).is( '[href]' ) ? 'href' : |
845 |
| - $(this).is('[src]') ? 'src' : 'action', |
846 |
| - thisUrl = $( this ).attr( thisAttr ); |
847 |
| - |
848 |
| - // XXX_jblas: We need to fix this so that it removes the document |
849 |
| - // base URL, and then prepends with the new page URL. |
850 |
| - //if full path exists and is same, chop it - helps IE out |
851 |
| - thisUrl = thisUrl.replace( location.protocol + '//' + location.host + location.pathname, '' ); |
852 |
| - |
853 |
| - if( !/^(\w+:|#|\/)/.test( thisUrl ) ) { |
854 |
| - $( this ).attr( thisAttr, newPath + thisUrl ); |
855 |
| - } |
856 |
| - }); |
| 844 | + //rewrite src and href attrs to use a base url if rewriteBase is enabled |
| 845 | + if ($.mobile.rewriteBase) { |
| 846 | + if( !$.support.dynamicBaseTag ) { |
| 847 | + var newPath = path.get( fileUrl ); |
| 848 | + page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() { |
| 849 | + var thisAttr = $( this ).is( '[href]' ) ? 'href' : |
| 850 | + $(this).is('[src]') ? 'src' : 'action', |
| 851 | + thisUrl = $( this ).attr( thisAttr ); |
| 852 | + |
| 853 | + // XXX_jblas: We need to fix this so that it removes the document |
| 854 | + // base URL, and then prepends with the new page URL. |
| 855 | + //if full path exists and is same, chop it - helps IE out |
| 856 | + thisUrl = thisUrl.replace( location.protocol + '//' + location.host + location.pathname, '' ); |
| 857 | + |
| 858 | + if( !/^(\w+:|#|\/)/.test( thisUrl ) ) { |
| 859 | + $( this ).attr( thisAttr, newPath + thisUrl ); |
| 860 | + } |
| 861 | + }); |
| 862 | + } |
857 | 863 | }
|
858 | 864 |
|
859 | 865 | //append to page and enhance
|
|
0 commit comments