PageRenderTime 60ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/docs/widgets/navbar/index.php

https://github.com/Intai/go-jquery-mobile
PHP | 312 lines | 256 code | 50 blank | 6 comment | 7 complexity | a72fce9f805c377197cbf303f5e9a7f1 MD5 | raw file
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Navbar - jQuery Mobile Demos</title>
  7. <link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css">
  8. <link rel="stylesheet" href="../../_assets/css/jqm-demos.css">
  9. <link rel="shortcut icon" href="../../favicon.ico">
  10. <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,700">
  11. <script src="../../../js/jquery.js"></script>
  12. <script src="../../_assets/js/"></script>
  13. <script src="../../../js/"></script>
  14. </head>
  15. <body>
  16. <div data-role="page" class="jqm-demos" data-quicklinks="true">
  17. <div data-role="header" class="jqm-header">
  18. <h1 class="jqm-logo"><a href="../../../"><img src="../../_assets/img/jquery-logo.png" alt="jQuery Mobile Framework"></a></h1>
  19. <a href="#" class="jqm-navmenu-link" data-icon="bars" data-iconpos="notext">Navigation</a>
  20. <a href="#" class="jqm-search-link" data-icon="search" data-iconpos="notext">Search</a>
  21. <?php include( '../../search.php' ); ?>
  22. </div><!-- /header -->
  23. <div data-role="content" class="jqm-content">
  24. <h1>Navbar <a href="http://api.jquerymobile.com/navbar/" data-ajax="false" data-role="button" data-inline="true" data-mini="true" data-icon="arrow-r" data-iconpos="right" class="jqm-api-link">API</a></h1>
  25. <p class="jqm-intro">jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar.
  26. </p>
  27. <h2>Navbar basics</h2>
  28. <p>A navbar is coded as an unordered list of links wrapped in a container element that has the <code> data-role="navbar"</code> attribute. When a link in the navbar is clicked it gets the active (selected) state. The <code>ui-btn-active</code> class is first removed from all anchors in the navbar before it is added to the activated link. If this is a link to another page, the class will be removed again after the transition has completed.</p>
  29. <p>To set an item to the active state, add <code>class="ui-btn-active"</code> to an anchor in the markup. Additionally add a class of <code>ui-state-persist</code> to make the framework restore the active state each time the page is shown while it exists in the DOM.</p>
  30. <p>Navbars with 1 item will render as 100% wide.</p>
  31. <div data-demo-html="true">
  32. <div data-role="navbar">
  33. <ul>
  34. <li><a href="#" class="ui-btn-active">One</a></li>
  35. </ul>
  36. </div><!-- /navbar -->
  37. </div><!--/demo-html -->
  38. <p>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:</p>
  39. <div data-demo-html="true">
  40. <div data-role="navbar">
  41. <ul>
  42. <li><a href="#" class="ui-btn-active">One</a></li>
  43. <li><a href="#">Two</a></li>
  44. </ul>
  45. </div><!-- /navbar -->
  46. </div><!--/demo-html -->
  47. <p>Adding a third item will automatically make each button 1/3 the width of the browser window:</p>
  48. <div data-demo-html="true">
  49. <div data-role="navbar">
  50. <ul>
  51. <li><a href="#" class="ui-btn-active">One</a></li>
  52. <li><a href="#">Two</a></li>
  53. <li><a href="#">Three</a></li>
  54. </ul>
  55. </div><!-- /navbar -->
  56. </div><!--/demo-html -->
  57. <p>Adding a fourth more item will automatically make each button 1/4 the width of the browser window:</p>
  58. <div data-demo-html="true">
  59. <div data-role="navbar" data-grid="c">
  60. <ul>
  61. <li><a href="#" class="ui-btn-active">One</a></li>
  62. <li><a href="#">Two</a></li>
  63. <li><a href="#">Three</a></li>
  64. <li><a href="#">Four</a></li>
  65. </ul>
  66. </div><!-- /navbar -->
  67. </div><!--/demo-html -->
  68. <p>The navbar maxes out with 5 items, each 1/5 the width of the browser window:</p>
  69. <div data-demo-html="true">
  70. <div data-role="navbar" data-grid="d">
  71. <ul>
  72. <li><a href="#" class="ui-btn-active">One</a></li>
  73. <li><a href="#">Two</a></li>
  74. <li><a href="#">Three</a></li>
  75. <li><a href="#">Four</a></li>
  76. <li><a href="#">Five</a></li>
  77. </ul>
  78. </div><!-- /navbar -->
  79. </div><!--/demo-html -->
  80. <h2>Multi-row</h2>
  81. <p>If more than 5 items are added, the navbar will simply wrap to multiple lines of two across:</p>
  82. <div data-demo-html="true">
  83. <div data-role="navbar">
  84. <ul>
  85. <li><a href="#" class="ui-btn-active">One</a></li>
  86. <li><a href="#">Two</a></li>
  87. <li><a href="#">Three</a></li>
  88. <li><a href="#">Four</a></li>
  89. <li><a href="#">Five</a></li>
  90. <li><a href="#">Six</a></li>
  91. <li><a href="#">Seven</a></li>
  92. <li><a href="#">Eight</a></li>
  93. <li><a href="#">Nine</a></li>
  94. <li><a href="#">Ten</a></li>
  95. </ul>
  96. </div><!-- /navbar -->
  97. </div><!--/demo-html -->
  98. <h2>Navbars in headers</h2>
  99. <p>If you want to add a navbar to the top of the page, you can still have a page title and buttons. Just add the navbar container inside the header block, right after the title and buttons in the source order.</p>
  100. <div data-demo-html="true">
  101. <div data-role="header">
  102. <h1>I'm a header</h1>
  103. <a href="#" data-icon="gear" class="ui-btn-right">Options</a>
  104. <div data-role="navbar">
  105. <ul>
  106. <li><a href="#">One</a></li>
  107. <li><a href="#">Two</a></li>
  108. <li><a href="#">Three</a></li>
  109. </ul>
  110. </div><!-- /navbar -->
  111. </div><!-- /header -->
  112. </div><!--/demo-html -->
  113. <h2>Navbars in footers</h2>
  114. <p>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 <code>data-role="footer"</code></p>
  115. <div data-demo-html="true">
  116. <div data-role="footer">
  117. <div data-role="navbar">
  118. <ul>
  119. <li><a href="#">One</a></li>
  120. <li><a href="#">Two</a></li>
  121. <li><a href="#">Three</a></li>
  122. </ul>
  123. </div><!-- /navbar -->
  124. <p style="text-align:center;">I'm the footer</p>
  125. </div><!-- /footer -->
  126. </div><!--/demo-html -->
  127. <h2>Persistent</h2>
  128. The <a href="footer-persist-a.php">persistent navbar</a> variation is designed to work more like a tab bar that stays fixed as you navigate across pages. To set an item to the active state upon initialization of the navbar, add <code>class="ui-btn-active"</code> to the corresponding anchor in your markup. Additionally add a class of <code>ui-state-persist</code> to make the framework restore the active state each time the page is shown while it exists in the DOM.
  129. <h2>Icons</h2>
  130. <p>Icons can be added to navbar items by adding the <code> data-icon</code> attribute specifying a <a href="../icons/">standard mobile icon</a> to each anchor. By default, icons are added above the text (<code>data-iconpos="top"</code>). The following examples add icons to a navbar in a footer.</p>
  131. <div data-demo-html="true">
  132. <div data-role="footer">
  133. <div data-role="navbar">
  134. <ul>
  135. <li><a href="#" data-icon="grid">Summary</a></li>
  136. <li><a href="#" data-icon="star" class="ui-btn-active">Favs</a></li>
  137. <li><a href="#" data-icon="gear">Setup</a></li>
  138. </ul>
  139. </div><!-- /navbar -->
  140. </div><!-- /footer -->
  141. </div><!--/demo-html -->
  142. <h2>Icon position</h2>
  143. <p>The icon position is set <em>on the navbar container</em> instead of for individual links within for visual consistency. For example, to place the icons below the labels, add the <code> data-iconpos="bottom"</code> attribute to the navbar container.</p>
  144. <div data-demo-html="true">
  145. <p>This will result in a bottom icon alignment:</p>
  146. <div data-role="footer">
  147. <div data-role="navbar" data-iconpos="bottom">
  148. <ul>
  149. <li><a href="#" data-icon="grid">Summary</a></li>
  150. <li><a href="#" data-icon="star" class="ui-btn-active">Favs</a></li>
  151. <li><a href="#" data-icon="gear">Setup</a></li>
  152. </ul>
  153. </div><!-- /navbar -->
  154. </div><!-- /footer -->
  155. </div><!--/demo-html -->
  156. <p>The icon position can be set to <code>data-iconpos="left"</code>:</p>
  157. <div data-demo-html="true">
  158. <div data-role="footer">
  159. <div data-role="navbar" data-iconpos="left">
  160. <ul>
  161. <li><a href="#" data-icon="grid">Summary</a></li>
  162. <li><a href="#" data-icon="star" class="ui-btn-active">Favs</a></li>
  163. <li><a href="#" data-icon="gear">Setup</a></li>
  164. </ul>
  165. </div><!-- /navbar -->
  166. </div><!-- /footer -->
  167. </div><!--/demo-html -->
  168. <p>Or the icon position can be set to <code>data-iconpos="right"</code>:</p>
  169. <div data-demo-html="true">
  170. <div data-role="footer">
  171. <div data-role="navbar" data-iconpos="right">
  172. <ul>
  173. <li><a href="#" data-icon="grid">Summary</a></li>
  174. <li><a href="#" data-icon="star" class="ui-btn-active">Favs</a></li>
  175. <li><a href="#" data-icon="gear">Setup</a></li>
  176. </ul>
  177. </div><!-- /navbar -->
  178. </div><!-- /footer -->
  179. </div><!--/demo-html -->
  180. <h2>3rd party icon sets</h2>
  181. <p>You can add any of the popular icon libraries like <a href="http://glyphish.com/">Glyphish</a> to achieve the iOS style tab that has large icons stacked on top of text labels. All that is required is a bit of custom styles to link to the icons and position them in the navbar. Here is an example using Glyphish icons and custom styles (view page source for styles) in our navbar:</p>
  182. <style>
  183. .nav-glyphish-example .ui-btn .ui-btn-inner { padding-top: 40px !important; }
  184. .nav-glyphish-example .ui-btn .ui-icon { width: 30px!important; height: 30px!important; margin-left: -15px !important; box-shadow: none!important; -moz-box-shadow: none!important; -webkit-box-shadow: none!important; -webkit-border-radius: 0 !important; border-radius: 0 !important; }
  185. #chat .ui-icon { background: url(../../_assets/img/glyphish-icons/09-chat2.png) 50% 50% no-repeat; background-size: 24px 22px; }
  186. #email .ui-icon { background: url(../../_assets/img/glyphish-icons/18-envelope.png) 50% 50% no-repeat; background-size: 24px 16px; }
  187. #login .ui-icon { background: url(../../_assets/img/glyphish-icons/30-key.png) 50% 50% no-repeat; background-size: 12px 26px; }
  188. #beer .ui-icon { background: url(../../_assets/img/glyphish-icons/88-beermug.png) 50% 50% no-repeat; background-size: 22px 27px; }
  189. #coffee .ui-icon { background: url(../../_assets/img/glyphish-icons/100-coffee.png) 50% 50% no-repeat; background-size: 20px 24px; }
  190. #skull .ui-icon { background: url(../../_assets/img/glyphish-icons/21-skull.png) 50% 50% no-repeat; background-size: 22px 24px; }
  191. </style>
  192. <div data-demo-html="true">
  193. <div data-role="footer" class="nav-glyphish-example">
  194. <div data-role="navbar" class="nav-glyphish-example" data-grid="d">
  195. <ul>
  196. <li><a href="#" id="chat" data-icon="custom">Chat</a></li>
  197. <li><a href="#" id="email" data-icon="custom">Email</a></li>
  198. <li><a href="#" id="skull" data-icon="custom">Danger</a></li>
  199. <li><a href="#" id="beer" data-icon="custom">Beer</a></li>
  200. <li><a href="#" id="coffee" data-icon="custom">Coffee</a></li>
  201. </ul>
  202. </div>
  203. </div>
  204. </div><!--/demo-html -->
  205. <p>Icons by Joseph Wain / <a href="http://glyphish.com/">glyphish.com</a>. Licensed under the <a href="http://creativecommons.org/licenses/by/3.0/us/">Creative Commons Attribution 3.0 United States License</a>.</p>
  206. <h2>Themes</h2>
  207. <p>Navbars inherit the theme swatch from their parent container, just like buttons. If a navbar is placed in the header or footer toolbar, it will inherit the default toolbar swatch "a" for bars unless you set this in the markup. </p>
  208. <p>Here are a few examples of navbars in various container swatches that automatically inherit their parent's swatch letter. Note that in these examples, instead of using a <code>data-theme</code> attribute, we're manually adding the swatch classes to apply the body swatch (<code>ui-body-a</code>) and the class to add the standard body padding (ui-body), but the inheritance works the same way:</p>
  209. <div data-demo-html="true">
  210. <div class="ui-body-a ui-body">
  211. <h3>Swatch "a"</h3>
  212. <div data-role="navbar">
  213. <ul>
  214. <li><a href="#" data-icon="grid">A</a></li>
  215. <li><a href="#" data-icon="star">B</a></li>
  216. <li><a href="#" data-icon="gear">C</a></li>
  217. <li><a href="#" data-icon="arrow-l">D</a></li>
  218. <li><a href="#" data-icon="arrow-r">E</a></li>
  219. </ul>
  220. </div><!-- /navbar -->
  221. </div><!-- /container -->
  222. </div><!--/demo-html -->
  223. <div data-demo-html="true">
  224. <div class="ui-body-d ui-body">
  225. <h3>Swatch "d"</h3>
  226. <div data-role="navbar">
  227. <ul>
  228. <li><a href="#" data-icon="grid">A</a></li>
  229. <li><a href="#" data-icon="star">B</a></li>
  230. <li><a href="#" data-icon="gear">C</a></li>
  231. <li><a href="#" data-icon="arrow-l">D</a></li>
  232. <li><a href="#" data-icon="arrow-r">E</a></li>
  233. </ul>
  234. </div><!-- /navbar -->
  235. </div><!-- /container -->
  236. </div><!--/demo-html -->
  237. <p>To set the theme color for a navbar item, add the <code>data-theme</code> attribute to the individual links and specify a theme swatch. Note that applying a theme swatch to the navbar container is <em>not</em> supported.</p>
  238. <div data-demo-html="true">
  239. <div data-role="footer">
  240. <div data-role="navbar">
  241. <ul>
  242. <li><a href="#" data-icon="grid"data-theme="a">A</a></li>
  243. <li><a href="#" data-icon="star" data-theme="b">B</a></li>
  244. <li><a href="#" data-icon="gear" data-theme="c">C</a></li>
  245. <li><a href="#" data-icon="arrow-l" data-theme="d">D</a></li>
  246. <li><a href="#" data-icon="arrow-r" data-theme="e">E</a></li>
  247. </ul>
  248. </div><!-- /navbar -->
  249. </div><!-- /footer -->
  250. </div><!--/demo-html -->
  251. </div><!-- /content -->
  252. <div data-role="footer" class="jqm-footer">
  253. <p class="jqm-version"></p>
  254. <p>Copyright 2013 The jQuery Foundation</p>
  255. </div><!-- /footer -->
  256. <?php include( '../../global-nav.php' ); ?>
  257. </div><!-- /page -->
  258. </body>
  259. </html>