From ee50437c3e799c2e209511a762aedac4c850795d Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Tue, 23 Jul 2013 21:57:37 -0400 Subject: [PATCH] Init: add option to prevent hiding url bar --- demos/faq/how-do-i-load-a-page.php | 13 +++--- demos/faq/how-do-i-turn-off-url-hiding.php | 52 ++++++++++++++++++++++ demos/nav-faq.php | 2 + js/jquery.mobile.defaults.js | 2 + js/jquery.mobile.init.js | 4 +- 5 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 demos/faq/how-do-i-turn-off-url-hiding.php diff --git a/demos/faq/how-do-i-load-a-page.php b/demos/faq/how-do-i-load-a-page.php index a2db164c00b..56a092db635 100644 --- a/demos/faq/how-do-i-load-a-page.php +++ b/demos/faq/how-do-i-load-a-page.php @@ -10,6 +10,11 @@ + @@ -25,15 +30,11 @@

Question:

-

How do I load a page?

+

How do I prevent jQuery Mobile from hiding the url bar?

Answer:

-

To load an external page, enhance its content, and insert it into the DOM, use the loadPage method. There are a lot of methods and properties that you can set when loading pages, but here is a simple example:

-

-//load the "about us" page into the DOM
-$.mobile.loadPage( "about/us.html" );
-
+

Set $.mobile.hideUrlBar = false; on mobileinit

All Questions & Answers diff --git a/demos/faq/how-do-i-turn-off-url-hiding.php b/demos/faq/how-do-i-turn-off-url-hiding.php new file mode 100644 index 00000000000..255915ea9ec --- /dev/null +++ b/demos/faq/how-do-i-turn-off-url-hiding.php @@ -0,0 +1,52 @@ + + + + + + Q&A - jQuery Mobile Demos - How do I prevent jQuery Mobile from hiding the url bar? + + + + + + + + + + +
+ +
+

jQuery Mobile Framework

+ Navigation + Search + +
+ +
+

Question:

+ +

How do I prevent jQuery Mobile from hiding the url bar?

+ +

Answer:

+ +

Set $.mobile.hideUrlBar = false; on mobileinit

+ + All Questions & Answers + +
+ + + + + +
+ + diff --git a/demos/nav-faq.php b/demos/nav-faq.php index 9b7a3de0ef5..89205375349 100644 --- a/demos/nav-faq.php +++ b/demos/nav-faq.php @@ -42,6 +42,8 @@
  • How do I load a page?
  • +
  • How do I turn off the automatic hiding of the url bar?
  • +
  • Events
  • How do I use touch and mouse events?
  • diff --git a/js/jquery.mobile.defaults.js b/js/jquery.mobile.defaults.js index d5cf38665bc..fd0db059a80 100644 --- a/js/jquery.mobile.defaults.js +++ b/js/jquery.mobile.defaults.js @@ -21,6 +21,8 @@ define( [ "jquery", "./jquery.mobile.ns", "json!../package.json" ], function( jQ // hash segment before &ui-page= is used to make Ajax request subPageUrlKey: "ui-page", + hideUrlBar: true, + // Class assigned to page currently in view, and during transitions activePageClass: "ui-page-active", diff --git a/js/jquery.mobile.init.js b/js/jquery.mobile.init.js index 3fe0974dfff..ec56c92517b 100644 --- a/js/jquery.mobile.init.js +++ b/js/jquery.mobile.init.js @@ -161,7 +161,9 @@ define([ // window load event // hide iOS browser chrome on load - $window.load( $.mobile.silentScroll ); + if( $.mobile.hideUrlBar ){ + $window.load( $.mobile.silentScroll ); + } if ( !$.support.cssPointerEvents ) { // IE and Opera don't support CSS pointer-events: none that we use to disable link-based buttons