Skip to content

Instantly share code, notes, and snippets.

@lthurston
Created May 25, 2012 23:01
Show Gist options
  • Save lthurston/2791063 to your computer and use it in GitHub Desktop.
Save lthurston/2791063 to your computer and use it in GitHub Desktop.
jQuery Mobile 1.1 Modifications to Respect Static Base Href
jquery.mobile-1.1.0.js
@@ -7,6 +7,7 @@
* http://jquery.org/license
*
*/
+
(function ( root, doc, factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
@@ -3097,8 +3098,9 @@ $.mobile.transitionFallbacks = {};
page.jqmData( "title", newPageTitle );
}
- //rewrite src and href attrs to use a base url
- if( !$.support.dynamicBaseTag ) {
+ // Rewrite src and href attrs to use a base url if dynamicBaseTag support is off and no
+ // static base href value is set
+ if( !$.support.dynamicBaseTag && $.mobile.staticBaseHref == undefined) {
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' :
@@ -3581,7 +3583,15 @@ $.mobile.transitionFallbacks = {};
return false;
}
- var baseUrl = getClosestBaseUrl( $link ),
+ var baseUrl, href;
+
+ // If staticBaseHref is set, then that's the baseURL we're using, otherwise, find the closest
+ // base url
+ if($.mobile.staticBaseHref === undefined) {
+ baseUrl = getClosestBaseUrl( $link );
+ } else {
+ baseUrl = $.mobile.staticBaseHref;
+ }
//get href, if defined, otherwise default to empty hash
href = path.makeUrlAbsolute( $link.attr( "href" ) || "#", baseUrl );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment