Skip to content

Commit c787743

Browse files
eddiemongejohnbender
authored andcommitted
Add in more link rewrite test cases, and warning message
1 parent d64dd4f commit c787743

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

docs/_assets/js/jqm-docs.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,24 @@ if ( location.protocol.substr(0,4) === 'file' ||
6464
// Start with links with only the trailing slash, and then move on to the ones that start with ..
6565
$( "a" )
6666
.filter( "[href='/']" ).attr( "href", "/index.html" ).end()
67-
.filter( "[href^='..']" ).filter( "[href$='/']" ).each(function() {
68-
this.href = $(this).attr("href")+"index.html";
67+
.filter( "[href^='..']" ).each(function() {
68+
var href = $( this ).attr( "href" ),
69+
append = "";
70+
71+
if ( href.substr(-2, 2) === '..' ) {
72+
append = "/index.html";
73+
}
74+
else if ( href.substr(-1, 1) === '/' ) {
75+
append = "index.html";
76+
}
77+
else if ( href.substr(-4, 4) !== 'html' ) {
78+
append = "/index.html";
79+
}
80+
else if ( href.substr(-2, 2) === '..' ) {
81+
append = "/index.html";
82+
}
83+
84+
this.href = href + append;
6985
});
7086
});
7187

@@ -78,6 +94,19 @@ if ( location.protocol.substr(0,4) === 'file' ||
7894
// Ajax doesn't work so turn it off
7995
$( document ).bind( "mobileinit", function() {
8096
$.mobile.ajaxEnabled = false;
97+
98+
var message = $( '<div>' , {
99+
"class": "ui-footer ui-bar-e",
100+
"style": "overflow: auto"
101+
});
102+
103+
message
104+
.append( "<h3>Note: Navigation may not work if viewed locally</h3>" )
105+
.append( "<p>The AJAX-based navigation used throughout the jQuery Mobile docs may need to be viewed on a web server to work in certain browsers such as Chrome. If you see an error message when you click a link, try a different browser or <a href='https://github.com/jquery/jquery-mobile/wiki/Downloadable-Docs-Help'>view help</a>.</p>" );
106+
107+
$( document ).bind( "pagecreate", function() {
108+
$( "div.ui-page" ).append( message );
109+
});
81110
});
82111
});
83112
}

0 commit comments

Comments
 (0)