Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow local browsing of the docs without a web server #3117

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

eddiemonge commented Nov 19, 2011

No description provided.

Contributor

eddiemonge commented Nov 19, 2011

Potential fix for #3113
This may affect phonegap since i think it uses: file:// but im not sure.

Contributor

toddparker commented Nov 21, 2011

I don't think we should disable AJAX is browsing locally if we can avoid it. I'd prefer to add in the URL fix here, but leave AJAX on and add in the messaging about the server requirement. Otherwise, you won't see transitions and other important features.

Contributor

eddiemonge commented Nov 21, 2011

How about an automatic ajax check to see if it should be disabled?

@johnbender johnbender commented on an outdated diff Nov 21, 2011

docs/_assets/js/jqm-docs.js
+});
+
+
+// Turn off AJAX for local file browsing
+if ( location.protocol.substr(0,4) === 'file' ||
+ location.protocol.substr(0,11) === '*-extension' ||
+ location.protocol.substr(0,6) === 'widget' ) {
+ $( function() {
+ // Check to see if ajax can be used. This does a quick ajax request and blocks the page until its done
+ // Start with links with only the trailing slash, and then move on to the ones that start with ..
+ $( "a" )
+ .filter( "[href='/']" ).attr( "href", "/index.html" ).end()
+ .filter( "[href^='..']" ).filter( "[href$='/']" ).each(function() {
+ this.href = $(this).attr("href")+"index.html";
@johnbender

johnbender Nov 21, 2011

Contributor

I think we also need to do this on changePage when the ajax requests are working for these protocols to alter new links. Sorry I didn't think of this earlier.

Contributor

johnbender commented Nov 21, 2011

@eddiemonge

@toddparker and I were thinking a big yellow warning that sits above the content (ie a direct descendant of body) and uses the warning css (http://jquerymobile.com/demos/1.0/docs/api/events.html at the top) added from the js here should be fine.

Contributor

toddparker commented Nov 21, 2011

@johnbender - simple mockup of the yellow bar of doom (and helpful information) here:
http://jsbin.com/amixum/9/edit

Content isn't right if we auto disable ajax, but that's the style.

Contributor

johnbender commented Nov 22, 2011

@eddimonge

I pulled your changes and I'm working on adding the warning (almost done), though I'm still unclear on why we need to index.html to anything other than the links with a trailing slash. I have a feeling I'm missing some corner case you've accounted for.

Contributor

eddiemonge commented Nov 22, 2011

@johnbender Since its adding it to all links on the page, I was account for the following examples:

  • href="/"
  • href="../"
  • href="../../" and any number of ../ added in.

However, there may also be external links that added in like:

  • href="twitter.com/"
  • href="jquerymobile.com/test/"
  • href="google.com"

So the first check tests for a single slash, which is safe and easy to do.
The second check looks for starting ".." and also has to end in /:

  • href="../docs/"
  • href="../demos/"

One link style I forgot about is the non-trailing slash ones:

  • href="../docs"
  • href="../demos"

Other links:

  • href="../docs/.."
  • href="../demos/.."
  • href="../docs.html"
  • href="../demos.html"
Contributor

eddiemonge commented Nov 22, 2011

@johnbender @toddparker I added in more url rewrites and the warning message. I have it appending to the footer of the page. I can change it to somewhere else if need be.

Contributor

toddparker commented Nov 22, 2011

Is there a way to preview the message before pushing?

.................................. . . . .
Todd Parker
Partner, Filament Group Inc.
102 South Street #3 Boston, MA 02111
todd@filamentgroup.com // 617.953.1617

On Nov 21, 2011, at 10:05 PM, "Eddie Monge Jr." reply@reply.github.com wrote:

@johnbender @toddparker I added in more url rewrites and the warning message. I have it appending to the footer of the page. I can change it to somewhere else if need be.


Reply to this email directly or view it on GitHub:
#3117 (comment)

Contributor

eddiemonge commented Nov 22, 2011

Pull from my repo or copy the jqmdocs.js file into your source, make docs, unzip and test

Contributor

johnbender commented Nov 22, 2011

@eddiemonge @toddparker

I'll pull eddie's latest and add the pagechange binding that I created on my end tomorrow morning.

Contributor

johnbender commented Nov 22, 2011

changes pushed

@johnbender johnbender closed this Nov 22, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment