Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / _includes / js / tabs.html
1 <div class="bs-docs-section">
2   <h1 id="tabs" class="page-header">Togglable tabs <small>tab.js</small></h1>
3
4   <h2 id="tabs-examples">Example tabs</h2>
5   <p>Add quick, dynamic tab functionality to transition through panes of local content, even via dropdown menus.</p>
6   <div class="bs-example bs-example-tabs" role="tabpanel" data-example-id="togglable-tabs">
7     <ul id="myTab" class="nav nav-tabs" role="tablist">
8       <li role="presentation" class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">Home</a></li>
9       <li role="presentation"><a href="#profile" role="tab" id="profile-tab" data-toggle="tab" aria-controls="profile">Profile</a></li>
10       <li role="presentation" class="dropdown">
11         <a href="#" id="myTabDrop1" class="dropdown-toggle" data-toggle="dropdown" aria-controls="myTabDrop1-contents">Dropdown <span class="caret"></span></a>
12         <ul class="dropdown-menu" role="menu" aria-labelledby="myTabDrop1" id="myTabDrop1-contents">
13           <li><a href="#dropdown1" tabindex="-1" role="tab" id="dropdown1-tab" data-toggle="tab" aria-controls="dropdown1">@fat</a></li>
14           <li><a href="#dropdown2" tabindex="-1" role="tab" id="dropdown2-tab" data-toggle="tab" aria-controls="dropdown2">@mdo</a></li>
15         </ul>
16       </li>
17     </ul>
18     <div id="myTabContent" class="tab-content">
19       <div role="tabpanel" class="tab-pane fade in active" id="home" aria-labelledBy="home-tab">
20         <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
21       </div>
22       <div role="tabpanel" class="tab-pane fade" id="profile" aria-labelledBy="profile-tab">
23         <p>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p>
24       </div>
25       <div role="tabpanel" class="tab-pane fade" id="dropdown1" aria-labelledBy="dropdown1-tab">
26         <p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p>
27       </div>
28       <div role="tabpanel" class="tab-pane fade" id="dropdown2" aria-labelledBy="dropdown2-tab">
29         <p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p>
30       </div>
31     </div>
32   </div><!-- /example -->
33
34   <div class="bs-callout bs-callout-info" id="callout-tabs-extends-component">
35     <h4>Extends tabbed navigation</h4>
36     <p>This plugin extends the <a href="../components/#nav-tabs">tabbed navigation component</a> to add tabbable areas.</p>
37   </div>
38
39
40   <h2 id="tabs-usage">Usage</h2>
41   <p>Enable tabbable tabs via JavaScript (each tab needs to be activated individually):</p>
42
43 {% highlight js %}
44 $('#myTab a').click(function (e) {
45   e.preventDefault()
46   $(this).tab('show')
47 })
48 {% endhighlight %}
49
50   <p>You can activate individual tabs in several ways:</p>
51
52 {% highlight js %}
53 $('#myTab a[href="#profile"]').tab('show') // Select tab by name
54 $('#myTab a:first').tab('show') // Select first tab
55 $('#myTab a:last').tab('show') // Select last tab
56 $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed)
57 {% endhighlight %}
58
59   <h3>Markup</h3>
60   <p>You can activate a tab or pill navigation without writing any JavaScript by simply specifying <code>data-toggle="tab"</code> or <code>data-toggle="pill"</code> on an element. Adding the <code>nav</code> and <code>nav-tabs</code> classes to the tab <code>ul</code> will apply the Bootstrap <a href="../components/#nav-tabs">tab styling</a>, while adding the <code>nav</code> and <code>nav-pills</code> classes will apply <a href="../components/#nav-pills">pill styling</a>.</p>
61 {% highlight html %}
62 <div role="tabpanel">
63
64   <!-- Nav tabs -->
65   <ul class="nav nav-tabs" role="tablist">
66     <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
67     <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
68     <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
69     <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
70   </ul>
71
72   <!-- Tab panes -->
73   <div class="tab-content">
74     <div role="tabpanel" class="tab-pane active" id="home">...</div>
75     <div role="tabpanel" class="tab-pane" id="profile">...</div>
76     <div role="tabpanel" class="tab-pane" id="messages">...</div>
77     <div role="tabpanel" class="tab-pane" id="settings">...</div>
78   </div>
79
80 </div>
81 {% endhighlight %}
82
83   <h3>Fade effect</h3>
84   <p>To make tabs fade in, add <code>.fade</code> to each <code>.tab-pane</code>. The first tab pane must also have <code>.in</code> to properly fade in initial content.</p>
85 {% highlight html %}
86 <div class="tab-content">
87   <div role="tabpanel" class="tab-pane fade in active" id="home">...</div>
88   <div role="tabpanel" class="tab-pane fade" id="profile">...</div>
89   <div role="tabpanel" class="tab-pane fade" id="messages">...</div>
90   <div role="tabpanel" class="tab-pane fade" id="settings">...</div>
91 </div>
92 {% endhighlight %}
93
94   <h3 id="tabs-methods">Methods</h3>
95   <h4><code>$().tab</code></h4>
96   <p>
97     Activates a tab element and content container. Tab should have either a <code>data-target</code> or an <code>href</code> targeting a container node in the DOM.
98   </p>
99 {% highlight html %}
100 <ul class="nav nav-tabs" role="tablist" id="myTab">
101   <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
102   <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
103   <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
104   <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
105 </ul>
106
107 <div class="tab-content">
108   <div role="tabpanel" class="tab-pane active" id="home">...</div>
109   <div role="tabpanel" class="tab-pane" id="profile">...</div>
110   <div role="tabpanel" class="tab-pane" id="messages">...</div>
111   <div role="tabpanel" class="tab-pane" id="settings">...</div>
112 </div>
113
114 <script>
115   $(function () {
116     $('#myTab a:last').tab('show')
117   })
118 </script>
119 {% endhighlight %}
120
121   <h3 id="tabs-events">Events</h3>
122   <p>When showing a new tab, the events fire in the following order:</p>
123   <ol>
124     <li><code>hide.bs.tab</code> (on the current active tab)</li>
125     <li><code>show.bs.tab</code> (on the to-be-shown tab)</li>
126     <li><code>hidden.bs.tab</code> (on the previous active tab, the same one as for the <code>hide.bs.tab</code> event)</li>
127     <li><code>shown.bs.tab</code> (on the newly-active just-shown tab, the same one as for the <code>show.bs.tab</code> event)</li>
128   </ol>
129   <p>If no tab was already active, then the <code>hide.bs.tab</code> and <code>hidden.bs.tab</code> events will not be fired.</p>
130   <div class="table-responsive">
131     <table class="table table-bordered table-striped bs-events-table">
132       <thead>
133        <tr>
134          <th>Event Type</th>
135          <th>Description</th>
136        </tr>
137       </thead>
138       <tbody>
139        <tr>
140          <td>show.bs.tab</td>
141          <td>This event fires on tab show, but before the new tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td>
142       </tr>
143       <tr>
144          <td>shown.bs.tab</td>
145          <td>This event fires on tab show after a tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td>
146        </tr>
147        <tr>
148          <td>hide.bs.tab</td>
149          <td>This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use <code>event.target</code> and <code>event.relatedTarget</code> to target the current active tab and the new soon-to-be-active tab, respectively.</td>
150        </tr>
151        <tr>
152          <td>hidden.bs.tab</td>
153          <td>This event fires after a new tab is shown (and thus the previous active tab is hidden). Use <code>event.target</code> and <code>event.relatedTarget</code> to target the previous active tab and the new active tab, respectively.</td>
154        </tr>
155       </tbody>
156     </table>
157   </div><!-- /.table-responsive -->
158 {% highlight js %}
159 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
160   e.target // newly activated tab
161   e.relatedTarget // previous active tab
162 })
163 {% endhighlight %}
164 </div>