From 15e984eca6f9bf4e73fc3c48b7ba0fd0506fc40b Mon Sep 17 00:00:00 2001 From: toddparker Date: Wed, 12 Oct 2011 11:49:26 -0400 Subject: [PATCH] Re-vamped the navbar docs to fix incorrect info about icon positioning and theming. Fixes #1858, Fixes #1797, Fixes #2667, Fixes #1180, Fixes #2373 The docs incorrectly stated that the icon position could be set per link, but this is intended as a global setting for the navbar parent. This is working as designed and helps with visual consistency. If icon positioning needs to be be adjusted per link, you will need to manually apply the right classes through JS and may need to tweak CSS because top/bottom and left/right positions have different heights. --- docs/toolbars/docs-navbar.html | 142 +++++++++++++++++++++++++-------- 1 file changed, 108 insertions(+), 34 deletions(-) diff --git a/docs/toolbars/docs-navbar.html b/docs/toolbars/docs-navbar.html index ad5720c2..be1466c5 100755 --- a/docs/toolbars/docs-navbar.html +++ b/docs/toolbars/docs-navbar.html @@ -24,35 +24,32 @@

Simple navbar

-

jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar , typically within a header or footer.

- +

jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar, typically within a header or footer. There is also a persistent nav bar variation that works more like a tab bar that stays fixed as you navigate across pages.

A navbar is coded as an unordered list of links wrapped in a container element that has the data-role="navbar" attribute. To set one of links to the active (selected) state, add class="ui-btn-active" to the anchor. In this example, we have a two-button navbar in the footer with the "One" item set to active:


-<div data-role="footer">
-	<div data-role="navbar">
-		<ul>
-			<li><a href="a.html" class="ui-btn-active">One</a></li>
-			<li><a href="b.html">Two</a></li>
-		</ul>
-	</div><!-- /navbar -->
-</div><!-- /footer -->
+<div data-role="navbar">
+	<ul>
+		<li><a href="a.html" class="ui-btn-active">One</a></li>
+		<li><a href="b.html">Two</a></li>
+	</ul>
+</div><!-- /navbar -->
 

The navbar items are set to divide the space evenly so in this case, each button is 1/2 the width of the browser window:

-
+
-
+

Adding a third item will automatically make each button 1/3 the width of the browser window:

-
+
-
+

Adding a fourth more item will automatically make each button 1/4 the width of the browser window:

-
+
-
+

The navbar maxes out with 5 items, each 1/5 the width of the browser window:

-
+
-
+

If more than 5 items are added, the navbar will simply wrap to multiple lines:

-
  • One
  • @@ -106,17 +102,14 @@
  • Ten
-

As a fallback, navbars with 1 item will simply render as 100%.

-
-

Navbars in headers

@@ -135,9 +128,33 @@
+

Navbars in footers

+ +

If you want to add a navbar to the bottom of the page so it acts more like a tab bar, simply wrap the navbar in a container with a data-role="footer"

+

+<div data-role="footer">		
+	<div data-role="navbar">
+		<ul>
+			<li><a href="#">One</a></li>
+			<li><a href="#">Two</a></li>
+			<li><a href="#">Three</a></li>
+		</ul>
+	</div><!-- /navbar -->
+</div><!-- /footer -->
+
+
+
+ +
+
+

Icons in navbars

-

Icons can be added to navbar items by adding the data-icon attribute specifying a standard mobile icon to each anchor.

+

Icons can be added to navbar items by adding the data-icon attribute specifying a standard mobile icon to each anchor. By default icons are added above the text (data-iconpos="top"). The following examples add icons to a navbar in a footer.

@@ -149,14 +166,41 @@
-

Icons can be stacked above the labels by adding the data-iconpos="top" attribute to each anchor.

+

The icon position is set on the navbar container instead of for individual links within for visual consistency. For example, to place the icons below the labels, add the data-iconpos="bottom" attribute to navbar container.

+

+<div data-role="navbar" data-iconpos="bottom">
+
+

This will result in a bottom icon alignment:

+
+
+ +
+
+ +

The icon position can be set to data-iconpos="left":

-
+
+
+
+ +

Or the icon position can be set to data-iconpos="right":

+ +
+
+
@@ -194,14 +238,44 @@

Theming navbars

-

Navbars can be set to any theme color by data-theme attribute to the links and specifying any theme swatch.

+

Navbars inherit the theme swatch from their parent container, just like buttons. If a navbar is placed in header or footer toolbar, it will inherit the default toolbar swatch (A) for bars unless you set this in the markup.

+

Here are a few examples of navbars in various container swatches automatically inheriting their parent's swatch letter. Note that in these examples, instead of using a data-theme attribute, we're manually adding the swatch classes to apply the body swatch (ui-body-a) and the class to add the standard body padding (ui-body), but the inheritance works the same way:

-
-
+
+

Swatch A

+
+
+
+ +
+

Swatch B

+
+ +
+
+ +

To set to the theme color for a navbar item, add the data-theme attribute to the individual links and specify a theme swatch. Note that applying a theme swatch at the navbar container is not supported.

+
+
+