123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>jQuery Mobile Docs - Header Bars</title>
- <link rel="stylesheet" href="../../jquery.mobile-1.0.1.min.css" />
- <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
- <script src="../../jquery.js"></script>
- <script src="../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
- <script src="../_assets/js/jqm-docs.js"></script>
- <script src="../../jquery.mobile-1.0.1.min.js"></script>
- </head>
- <body>
- <div data-role="page" class="type-interior">
- <div data-role="header" data-theme="f">
- <h1>Header bars</h1>
- <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
- </div><!-- /header -->
- <div data-role="content">
- <div class="content-primary">
- <h2>Header structure</h2>
- <p>The <code>header</code> is a toolbar at the top of the page that usually contains the page title text and optional buttons positioned to the the left and/or right of the title for navigation or actions.</p>
-
- <p>The title text is normally an H1 heading element but it's possible to use any heading level (H1-H6) to allow for semantic flexibility. For example, a page containing multiple mobile 'pages' may use a H1 element on the home 'page' and a H2 element on the secondary pages. All heading levels are styled identically by default to maintain visual consistency.</p>
- <div class="highlight">
- <pre>
- <span class="nt"><div</span> <strong><span class="na">data-role=</span><span class="s">"header"</span></strong><span class="nt">></span>
- <span class="nt"><h1></span>Page Title<span class="nt"></h1></span>
- <span class="nt"></div></span>
- </pre>
- </div>
- <h2>Default header features</h2>
- <p>The <code>header</code> toolbar is themed with the "a" swatch by default (black in the default theme) but you can easily <a href="bars-themes.html">set the theme swatch color</a>.</p>
-
- <div data-role="header" data-position="inline">
- <h1>Page title</h1>
- </div>
-
- <h2>Adding buttons</h2>
-
-
-
-
-
- <p>In the standard header configuration, there are slots for buttons on either side of the text heading. Each button is typically an <code>anchor</code> element, but any valid <a href="../buttons/buttons-types.html">button markup</a> will work. To save space, buttons in toolbars are set to <a href="../buttons/buttons-inline.html">inline styling</a> so the button is only as wide as the text and icons it contains. </p>
-
-
- <h3>Default button positioning</h3>
-
- <p>The header plugin looks for immediate children of the header container, and automatically sets the first link in the left button slot and the second link in the right. In this example, the 'Cancel' button will appear in the left slot and 'Save' will appear in the right slot based on their sequence in the source order. </p>
-
- <pre><code>
- <div data-role="header" data-position="inline">
- <a href="index.html" data-icon="delete">Cancel</a>
- <h1>Edit Contact</h1>
- <a href="index.html" data-icon="check">Save</a>
- </div>
- </code></pre>
-
-
- <div data-role="header" data-position="inline">
- <a href="index.html" data-icon="delete">Cancel</a>
- <h1>Edit Contact</h1>
- <a href="index.html" data-icon="check">Save</a>
- </div>
- <p>Buttons automatically adopt the swatch color of the bar they sit in, so a link in a header bar with the "a" color will also be styled as "a" colored buttons. It's simple to make a button visually stand out — here, we add the <code> data-theme</code> attribute and set the color swatch for the button to "b" to make the "Save" button pop.</p>
-
- <pre><code>
- <div data-role="header" data-position="inline">
- <a href="index.html" data-icon="delete">Cancel</a>
- <h1>Edit Contact</h1>
- <a href="index.html" data-icon="check" data-theme="b">Save</a>
- </div>
- </code></pre>
-
-
- <div data-role="header" data-position="inline">
- <a href="index.html" data-icon="delete">Cancel</a>
- <h1>Edit Contact</h1>
- <a href="index.html" data-icon="check" data-theme="b">Save</a>
- </div>
-
- <h3>Controlling button position with classes</h3>
-
- <p>The button position can also be controlled by adding classes to the button anchors, rather than relying on source order. This is especially useful if you only want a button in the right slot. To specify the button position, add the class of <code>ui-btn-left</code> or <code>ui-btn-right</code> to the anchor.</p>
-
- <div class="highlight">
- <pre><code>
- <div data-role="header" data-position="inline"
- <h1>Page Title</h1>
- <a href="index.html" data-icon="gear" class="ui-btn-right">Options</a>
- </div>
- </code></pre>
- </div>
- <div data-role="header" data-position="inline" >
- <h1>Page Title</h1>
- <a href="index.html" data-icon="gear" class="ui-btn-right">Options</a>
- </div>
-
-
- <h2>Adding Back buttons</h2>
-
- <p>jQuery Mobile has a feature to automatically create and append "back" buttons to any header, though it is disabled by default. This is primarily useful in chromeless installed applications, such as those running in a native app web view. The framework automatically generates a "back" button on a header when the page plugin's <code>addBackBtn</code> option is true. This can also be set via markup if the page div has a <code>data-add-back-btn="true"</code> attribute. </p>
-
-
- <p>If you use the attribute <code>data-rel="back"</code> on an anchor, any clicks on that anchor will mimic the back button, going back one history entry and ignoring the anchor's default href. This is particularly useful when linking back to a named page, such as a link that says "home", or when generating "back" buttons with JavaScript, such as a button to close a dialog. When using this feature in your source markup, <strong>be sure to provide a meaningful href that actually points to the URL of the referring page (this will allow the feature to work for users in C-Grade browsers</strong>. Also, please keep in mind that if you just want a reverse transition without actually going back in history, you should use the <code>data-direction="reverse"</code> attribute instead.</p>
-
- <h2>Customizing the back button text</h2>
-
- <p>If you'd like to configure the back button text, you can either use the <code>data-back-btn-text="previous"</code> attribute on your page element, or set it programmatically via the page plugin's options: <br /><code>$.mobile.page.prototype.options.backBtnText = "previous";</code></p>
-
- <h3>Default back button style</h3>
- <p>If you'd like to configure the back button role-theme, you can use: <br /><code>$.mobile.page.prototype.options.backBtnTheme = "a";</code><br />
- If you're doing this programmatically, set this option inside the mobileinit event handler.</p>
- <h2>Custom header configurations</h2>
- <p>If you need to to create a header that doesn't follow the default configuration, simply wrap your custom styled markup in a container <code>div</code> inside the header container and the plugin won't apply the automatic button logic so you can write custom styles for laying out the content in your header.</p>
- <p>It's also possible to create custom bars without using the header data-role at all. For example, start with any container and add the <code>ui-bar</code> class to apply standard bar padding and add the <code>ui-bar-b</code> class to assign the bar swatch styles from your theme (the "b" can be any swatch letter).</p>
-
- <pre><code>
- <div <strong>class="ui-bar ui-bar-b"</strong>>
- <h3>I'm just a div with bar classes and a <a href="#" data-role="button">Button</a></h3>
- </div>
- </code></pre>
- <p>This will produce this bar:</p>
- <div class="ui-bar ui-bar-b">
- <h3>I'm just a div with bar classes and a <a href="#" data-role="button">Button</a></h3>
- </div>
-
- <p>By writing some simple styles, it's easy to build little message bars like this:</p>
- <!-- Yes, the inline styles aren't recommended in a real system but they are used to simply illustrate how to tweak CSS -->
- <div class="ui-bar ui-bar-e">
- <h3 style="float:left; margin-top:8px;">This is an alert message with dismiss button. </h3>
- <div style="float:right; margin-top:4px;"><a href="#" data-role="button" data-icon="delete" data-iconpos="notext">Button</a></div>
- <p style="clear:both; font-size:85%; margin-bottom:8px;">And here's some additional text in a paragraph.</p>
- </div>
- </div><!--/content-primary -->
- <div class="content-secondary">
- <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
- <h3>More in this section</h3>
- <ul data-role="listview" data-theme="c" data-dividertheme="d">
- <li data-role="list-divider">Toolbars</li>
- <li><a href="docs-bars.html">Toolbar basics</a></li>
- <li data-theme="a"><a href="docs-headers.html">Header bars</a></li>
- <li><a href="docs-footers.html">Footer bars</a></li>
- <li><a href="docs-navbar.html">Navbars</a></li>
- <li><a href="bars-fixed.html">Fixed positioning</a></li>
- <li><a href="bars-fullscreen.html">Fullscreen positioning</a></li>
- <li><a href="footer-persist-a.html">Persistent footer navbar</a></li>
- <li><a href="bars-themes.html">Theming toolbars</a></li>
- </ul>
- </div>
- </div>
- </div><!-- /content -->
- <div data-role="footer" class="footer-docs" data-theme="c">
- <p>© 2011-2012 The jQuery Project</p>
- </div>
- </div><!-- /page -->
- </body>
- </html>
|