You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

386 lines
15 KiB

  1. ---
  2. layout : 'default'
  3. css : 'side'
  4. title : 'Tab'
  5. description : 'A tab is a section of content tied to a navigation menu'
  6. type : 'UI Module'
  7. ---
  8. <script src="/javascript/tab.js"></script>
  9. <%- @partial('header') %>
  10. <div class="main container">
  11. <div class="peek">
  12. <div class="ui vertical pointing secondary menu">
  13. <a class="item">Examples</a>
  14. <a class="item">Coupling</a>
  15. <a class="item">Behavior</a>
  16. <a class="item">Settings</a>
  17. </div>
  18. </div>
  19. <h2 class="ui dividing header">Examples</h2>
  20. <div class="first no example">
  21. <h4 class="ui header">Opening tabs with menus</h4>
  22. <p>Tabs are usually used in concert with an element that activates the tab. When using tabs, unlike other UI components, the menu or activating element is initialized instead of the tab.</p>
  23. <p>Tabs are connected to their activators with a metadata attribute <code>data-tab</code>. This should be added to both the activating element and the tab itself.</p>
  24. <div class="ignored ui info message">
  25. <h4 class="ui header">Default tabs</h4>
  26. <p>After any tab is opened it will look for a default tab to open inside of the current tab. This is the first tab that begins with the same stem url as the parent tab. For example a tab with the path <code>data-tab="home"</code> might open a tab automatically <code>data-tab="/home/inbox"</code>.</p>
  27. <p>This will happen recursively for every tab open, allowing as many levels of tabs as you like</p>
  28. </div>
  29. <div class="code" data-type="javascript">
  30. $('.first.example .menu .item')
  31. .tab({
  32. context: '.first.example'
  33. })
  34. ;
  35. </div>
  36. <div class="code" data-type="html" data-label="true">
  37. <div class="ui pointing secondary menu">
  38. <a class="active item" data-tab="first">First</a>
  39. <a class="item" data-tab="second">Second</a>
  40. <a class="item" data-tab="third">Third</a>
  41. </div>
  42. <div class="ui active tab segment" data-tab="first">
  43. <div class="ui top attached tabular menu">
  44. <a class="active item" data-tab="first/a">1A</a>
  45. <a class="item" data-tab="first/b">1B</a>
  46. <a class="item" data-tab="first/c">1C</a>
  47. </div>
  48. <div class="ui bottom attached active tab segment" data-tab="first/a">1A</div>
  49. <div class="ui bottom attached tab segment" data-tab="first/b">1B</div>
  50. <div class="ui bottom attached tab segment" data-tab="first/c">1C</div>
  51. </div>
  52. <div class="ui tab segment" data-tab="second">...</div>
  53. <div class="ui tab segment" data-tab="third">...</div>
  54. </div>
  55. <div class="ui pointing secondary menu">
  56. <a class="active item" data-tab="first">First</a>
  57. <a class="item" data-tab="second">Second</a>
  58. <a class="item" data-tab="third">Third</a>
  59. </div>
  60. <div class="ui active tab segment" data-tab="first">
  61. <div class="ui top attached tabular menu">
  62. <a class="active item" data-tab="first/a">1A</a>
  63. <a class="item" data-tab="first/b">1B</a>
  64. <a class="item" data-tab="first/c">1C</a>
  65. </div>
  66. <div class="ui bottom attached active tab segment" data-tab="first/a">1A</div>
  67. <div class="ui bottom attached tab segment" data-tab="first/b">1B</div>
  68. <div class="ui bottom attached tab segment" data-tab="first/c">1C</div>
  69. </div>
  70. <div class="ui tab segment" data-tab="second">
  71. <div class="ui top attached tabular menu">
  72. <a class="item" data-tab="second/a">2A</a>
  73. <a class="item" data-tab="second/b">2B</a>
  74. <a class="item" data-tab="second/c">2C</a>
  75. </div>
  76. <div class="ui bottom attached tab segment" data-tab="second/a">2A</div>
  77. <div class="ui bottom attached tab segment" data-tab="second/b">2B</div>
  78. <div class="ui bottom attached tab segment" data-tab="second/c">2C</div>
  79. </div>
  80. <div class="ui tab segment" data-tab="third">
  81. <div class="ui top attached tabular menu">
  82. <a class="item" data-tab="third/a">3A</a>
  83. <a class="item" data-tab="third/b">3B</a>
  84. <a class="item" data-tab="third/c">3C</a>
  85. </div>
  86. <div class="ui bottom attached tab segment" data-tab="third/a">3A</div>
  87. <div class="ui bottom attached tab segment" data-tab="third/b">3B</div>
  88. <div class="ui bottom attached tab segment" data-tab="third/c">3C</div>
  89. </div>
  90. </div>
  91. <h2 class="ui dividing header">Optional Coupling</h2>
  92. <div class="history no example">
  93. <h4 class="ui header">Managing History with Tabs</h4>
  94. <p>Tabs can attach to a history change event to allow for tabs to maintain history events. Tabs use Asual's <a href="https://github.com/asual/jquery-address">Address library</a> to provide cross-browser push state support. This makes sure in browser that don't support push state, <code>hashchange</code> is used with in page anchors to provide history functionality.</p>
  95. <div class="ignored ui warning message">
  96. <h4 class="header">Setup Paths</h4>
  97. Make sure when you use history to specify the path. This is required for determining the stem url from the part of the url maintaining in page history. The path is the URL without any tabs open. This cannot usually be set automatically because on future page refreshes the URL may include an internal link. Using the incorrect path will cause the module to work incorrectly, producing unexpected results.
  98. </div>
  99. <div class="ignored ui red message">
  100. <h4 class="header">Route your URLs</h4>
  101. Be sure to set up routes on your server for any url used with history. If you use history to change the url to a location that does not exist, it will 404 on the next refresh. The docs for example, are static github hosted pages, so will 404 if the page url changes
  102. </div>
  103. <div class="code" data-type="javascript">
  104. $('.history.example .menu .item')
  105. .tab({
  106. context : '.history.example',
  107. history : true,
  108. path : '/modules/tab.html'
  109. })
  110. ;
  111. </div>
  112. <div class="ui pointing secondary menu">
  113. <a class="active item" data-tab="first">First</a>
  114. <a class="item" data-tab="second">Second</a>
  115. <a class="item" data-tab="third">Third</a>
  116. </div>
  117. <div class="ui active tab segment" data-tab="first">
  118. <div class="ui top attached tabular menu">
  119. <a class="active item" data-tab="first/a">1A</a>
  120. <a class="item" data-tab="first/b">1B</a>
  121. <a class="item" data-tab="first/c">1C</a>
  122. </div>
  123. <div class="ui bottom attached active tab segment" data-tab="first/a">1A</div>
  124. <div class="ui bottom attached tab segment" data-tab="first/b">1B</div>
  125. <div class="ui bottom attached tab segment" data-tab="first/c">1C</div>
  126. </div>
  127. <div class="ui tab segment" data-tab="second">
  128. <div class="ui top attached tabular menu">
  129. <a class="item" data-tab="second/a">2A</a>
  130. <a class="item" data-tab="second/b">2B</a>
  131. <a class="item" data-tab="second/c">2C</a>
  132. </div>
  133. <div class="ui bottom attached tab segment" data-tab="second/a">2A</div>
  134. <div class="ui bottom attached tab segment" data-tab="second/b">2B</div>
  135. <div class="ui bottom attached tab segment" data-tab="second/c">2C</div>
  136. </div>
  137. <div class="ui tab segment" data-tab="third">
  138. <div class="ui top attached tabular menu">
  139. <a class="item" data-tab="third/a">3A</a>
  140. <a class="item" data-tab="third/b">3B</a>
  141. <a class="item" data-tab="third/c">3C</a>
  142. </div>
  143. <div class="ui bottom attached tab segment" data-tab="third/a">3A</div>
  144. <div class="ui bottom attached tab segment" data-tab="third/b">3B</div>
  145. <div class="ui bottom attached tab segment" data-tab="third/c">3C</div>
  146. </div>
  147. </div>
  148. <div class="dynamic no example">
  149. <h4 class="header">Retreiving Dynamic Tab Content</h4>
  150. <p>The easiest way to setup dynamic content is to use the parameter <code>auto</code>, this will automatically retrieve content at a remote url matching the url set in the browser. The URL will receive an addition HTTP Header <code>'X-Remote': true</code>. You can use this on your server's back-end to determine whether a request is an AJAX request from a tab</p>
  151. <p>This uses a similar technique to <a href="https://github.com/defunkt/jquery-pjax">pJax</a> or Rail's <a href="https://github.com/rails/turbolinks/">turbolinks</a>.</p>
  152. <div class="ignored ui info message">There are a variety of settings for configuring dynamic content behavior. Visit the tab settings section for more information</div>
  153. <div class="code" data-type="javascript">
  154. $('.dynamic.example .menu .item')
  155. .tab({
  156. context : '.dynamic.example',
  157. auto : true,
  158. path : '/modules/tab.html'
  159. })
  160. ;
  161. </div>
  162. <div class="ui pointing secondary menu">
  163. <a class="active item" data-tab="first">First</a>
  164. <a class="item" data-tab="second">Second</a>
  165. <a class="item" data-tab="third">Third</a>
  166. </div>
  167. <div class="ui active tab segment" data-tab="first">
  168. <div class="ui top attached tabular menu">
  169. <a class="active item" data-tab="first/a">1A</a>
  170. <a class="item" data-tab="first/b">1B</a>
  171. <a class="item" data-tab="first/c">1C</a>
  172. </div>
  173. <div class="ui bottom attached active tab segment" data-tab="first/a"></div>
  174. <div class="ui bottom attached tab segment" data-tab="first/b"></div>
  175. <div class="ui bottom attached tab segment" data-tab="first/c"></div>
  176. </div>
  177. <div class="ui tab segment" data-tab="second">
  178. <div class="ui top attached tabular menu">
  179. <a class="item" data-tab="second/a">2A</a>
  180. <a class="item" data-tab="second/b">2B</a>
  181. <a class="item" data-tab="second/c">2C</a>
  182. </div>
  183. <div class="ui bottom attached tab segment" data-tab="second/a"></div>
  184. <div class="ui bottom attached tab segment" data-tab="second/b"></div>
  185. <div class="ui bottom attached tab segment" data-tab="second/c"></div>
  186. </div>
  187. <div class="ui tab segment" data-tab="third">
  188. <div class="ui top attached tabular menu">
  189. <a class="item" data-tab="third/a">3A</a>
  190. <a class="item" data-tab="third/b">3B</a>
  191. <a class="item" data-tab="third/c">3C</a>
  192. </div>
  193. <div class="ui bottom attached tab segment" data-tab="third/a"></div>
  194. <div class="ui bottom attached tab segment" data-tab="third/b"></div>
  195. <div class="ui bottom attached tab segment" data-tab="third/c"></div>
  196. </div>
  197. </div>
  198. <h2 class="ui dividing header">Behavior</h2>
  199. All the following behaviors can be called using the syntax <code>$('.foo').tab('behavior name', argumentOne, argumentTwo)</code>
  200. <table class="ui definition celled table segment">
  201. <tr>
  202. <td>attach events(selector, event)</td>
  203. <td>Attaches tab action to given selector. Default event if none specified is toggle</td>
  204. </tr>
  205. <tr>
  206. <td>show</td>
  207. <td>Shows tab</td>
  208. </tr>
  209. <tr>
  210. <td>hide</td>
  211. <td>Hides tab</td>
  212. </tr>
  213. <tr>
  214. <td>toggle</td>
  215. <td>Toggles visibility of tab</td>
  216. </tr>
  217. <tr>
  218. <td>is open</td>
  219. <td>Returns whether tab is open</td>
  220. </tr>
  221. <tr>
  222. <td>is closed</td>
  223. <td>Returns whether tab is closed</td>
  224. </tr>
  225. <tr>
  226. <td>push page</td>
  227. <td>Pushes page content to be visible alongside tab</td>
  228. </tr>
  229. <tr>
  230. <td>get direction</td>
  231. <td>Returns direction of current tab</td>
  232. </tr>
  233. <tr>
  234. <td>pull page</td>
  235. <td>Returns page content to original position</td>
  236. </tr>
  237. <tr>
  238. <td>add body css</td>
  239. <td>Adds stylesheet to page head to trigger tab animations</td>
  240. </tr>
  241. <tr>
  242. <td>remove body css</td>
  243. <td>Removes any inline stylesheets for tab animation</td>
  244. </tr>
  245. <tr>
  246. <td>get transition event</td>
  247. <td>Returns vendor prefixed transition end event</td>
  248. </tr>
  249. </table>
  250. <h2 class="ui dividing header">Settings</h2>
  251. <h3 class="ui header">
  252. Transition Settings
  253. <div class="sub header">Form settings modify the transition behavior</div>
  254. </h3>
  255. <table class="ui red celled sortable definition table segment">
  256. <thead>
  257. <th>Setting</th>
  258. <th class="four wide">Default</th>
  259. <th>Description</th>
  260. </thead>
  261. <tbody>
  262. <tr>
  263. <td>overlay</td>
  264. <td>false</td>
  265. <td>Whether tab should overlay page instead of pushing page to the side</td>
  266. </tr>
  267. <tr>
  268. <td>useCSS</td>
  269. <td>true</td>
  270. <td>Whether to use css animations or fallback javascript animations</td>
  271. </tr>
  272. <tr>
  273. <td>duration</td>
  274. <td>300</td>
  275. <td>Duration of side bar animation</td>
  276. </tr>
  277. </tbody>
  278. </table>
  279. <h3 class="ui header">
  280. DOM Settings
  281. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  282. </h3>
  283. <table class="ui celled purple definition table segment">
  284. <thead>
  285. <th>Setting</th>
  286. <th class="six wide">Default</th>
  287. <th>Description</th>
  288. </thead>
  289. <tbody>
  290. <tr>
  291. <td>namespace</td>
  292. <td>tab</td>
  293. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  294. </tr>
  295. <tr>
  296. <td>className</td>
  297. <td>
  298. <div class="code">
  299. className: {
  300. active : 'active',
  301. pushed : 'pushed',
  302. top : 'top',
  303. left : 'left',
  304. right : 'right',
  305. bottom : 'bottom'
  306. }
  307. </div>
  308. </td>
  309. <td>Class names used to attach style to state</td>
  310. </tr>
  311. </tbody>
  312. </table>
  313. <div class="ui horizontal divider"><i class="icon setting"></i></div>
  314. <h3 class="ui header">
  315. Debug Settings
  316. <div class="sub header">Debug settings controls debug output to the console</div>
  317. </h3>
  318. <table class="ui blue celled sortable definition table segment">
  319. <thead>
  320. <th>Setting</th>
  321. <th class="four wide">Default</th>
  322. <th>Description</th>
  323. </thead>
  324. <tbody>
  325. <tr>
  326. <td>name</td>
  327. <td>Tab</td>
  328. <td>Name used in debug logs</td>
  329. </tr>
  330. <tr>
  331. <td>debug</td>
  332. <td>True</td>
  333. <td>Provides standard debug output to console</td>
  334. </tr>
  335. <tr>
  336. <td>performance</td>
  337. <td>True</td>
  338. <td>Provides standard debug output to console</td>
  339. </tr>
  340. <tr>
  341. <td>verbose</td>
  342. <td>True</td>
  343. <td>Provides ancillary debug output to console</td>
  344. </tr>
  345. <tr>
  346. <td>errors</td>
  347. <td colspan="2">
  348. <div class="code">
  349. error : {
  350. method : 'The method you called is not defined.',
  351. notFound : 'There were no elements that matched the specified selector'
  352. }
  353. </div>
  354. </td>
  355. </tr>
  356. </tbody>
  357. </table>
  358. </div>
  359. </body>
  360. </html>