Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / _includes / js / collapse.html
1 <div class="bs-docs-section">
2   <h1 id="collapse" class="page-header">Collapse <small>collapse.js</small></h1>
3
4   <p class="lead">Flexible plugin that utilizes a handful of classes for easy toggle behavior.</p>
5
6   <div class="bs-callout bs-callout-danger" id="callout-collapse-dependency">
7     <h4>Plugin dependency</h4>
8     <p>Collapse requires the <a href="#transitions">transitions plugin</a> to be included in your version of Bootstrap.</p>
9   </div>
10
11   <h2 id="collapse-example">Example</h2>
12   <p>Click the buttons below to show and hide another element via class changes:</p>
13   <ul>
14     <li><code>.collapse</code> hides content</li>
15     <li><code>.collapsing</code> is applied during transitions</li>
16     <li><code>.collapse.in</code> shows content</li>
17   </ul>
18   <p>You can use a link with the <code>href</code> attribute, or a button with the <code>data-target</code> attribute. In both cases, the <code>data-toggle="collapse"</code> is required.</p>
19
20   <div class="bs-example">
21     <p>
22       <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
23         Link with href
24       </a>
25       <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
26         Button with data-target
27       </button>
28     </p>
29     <div class="collapse" id="collapseExample">
30       <div class="well">
31         Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
32       </div>
33     </div>
34   </div>
35 {% highlight html %}
36 <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
37   Link with href
38 </a>
39 <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
40   Button with data-target
41 </button>
42 <div class="collapse" id="collapseExample">
43   <div class="well">
44     ...
45   </div>
46 </div>
47 {% endhighlight %}
48
49   <h2 id="collapse-example-accordion">Accordion example</h2>
50   <p>Extend the default collapse behavior to create an accordion with the panel component.</p>
51
52   <div class="bs-example" data-example-id="collapse-accordion">
53     <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
54       <div class="panel panel-default">
55         <div class="panel-heading" role="tab" id="headingOne">
56           <h4 class="panel-title">
57             <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
58               Collapsible Group Item #1
59             </a>
60           </h4>
61         </div>
62         <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
63           <div class="panel-body">
64             Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
65           </div>
66         </div>
67       </div>
68       <div class="panel panel-default">
69         <div class="panel-heading" role="tab" id="headingTwo">
70           <h4 class="panel-title">
71             <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
72               Collapsible Group Item #2
73             </a>
74           </h4>
75         </div>
76         <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
77           <div class="panel-body">
78             Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
79           </div>
80         </div>
81       </div>
82       <div class="panel panel-default">
83         <div class="panel-heading" role="tab" id="headingThree">
84           <h4 class="panel-title">
85             <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
86               Collapsible Group Item #3
87             </a>
88           </h4>
89         </div>
90         <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
91           <div class="panel-body">
92             Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
93           </div>
94         </div>
95       </div>
96     </div>
97   </div><!-- /example -->
98 {% highlight html %}
99 <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
100   <div class="panel panel-default">
101     <div class="panel-heading" role="tab" id="headingOne">
102       <h4 class="panel-title">
103         <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
104           Collapsible Group Item #1
105         </a>
106       </h4>
107     </div>
108     <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
109       <div class="panel-body">
110         Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
111       </div>
112     </div>
113   </div>
114   <div class="panel panel-default">
115     <div class="panel-heading" role="tab" id="headingTwo">
116       <h4 class="panel-title">
117         <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
118           Collapsible Group Item #2
119         </a>
120       </h4>
121     </div>
122     <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
123       <div class="panel-body">
124         Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
125       </div>
126     </div>
127   </div>
128   <div class="panel panel-default">
129     <div class="panel-heading" role="tab" id="headingThree">
130       <h4 class="panel-title">
131         <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
132           Collapsible Group Item #3
133         </a>
134       </h4>
135     </div>
136     <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
137       <div class="panel-body">
138         Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
139       </div>
140     </div>
141   </div>
142 </div>
143 {% endhighlight %}
144
145   <p>It's also possible to swap out <code>.panel-body</code>s with <code>.list-group</code>s.</p>
146
147   <div class="panel-group" role="tablist">
148     <div class="panel panel-default">
149       <div class="panel-heading" role="tab" id="collapseListGroupHeading1">
150         <h4 class="panel-title">
151           <a class="collapsed" data-toggle="collapse" href="#collapseListGroup1" aria-expanded="false" aria-controls="collapseListGroup1">
152             Collapsible list group
153           </a>
154         </h4>
155       </div>
156       <div id="collapseListGroup1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseListGroupHeading1">
157         <ul class="list-group">
158           <li class="list-group-item">Bootply</li>
159           <li class="list-group-item">One itmus ac facilin</li>
160           <li class="list-group-item">Second eros</li>
161         </ul>
162         <div class="panel-footer">Footer</div>
163       </div>
164     </div>
165   </div>
166
167   <div class="bs-callout bs-callout-warning" id="callout-collapse-accessibility">
168     <h4>Make expand/collapse controls accessible</h4>
169     <p>Be sure to add <code>aria-expanded</code> to the control element. This attribute explicitly defines the current state of the collapsible element to screen readers and similar assistive technologies. If the collapsible element is closed by default, it should have a value of <code>aria-expanded="false"</code>. If you've set the collapsible element to be open by default using the <code>in</code> class, set <code>aria-expanded="true"</code> on the control instead. The plugin will automatically toggle this attribute based on whether or not the collapsible element has been opened or closed.</p>
170     <p>Additionally, if your control element is targetting a single collapsible element – i.e. the <code>data-target</code> attribute is pointing to an <code>id</code> selector – you may add an additional <code>aria-controls</code> attribute to the control element, containing the <code>id</code> of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.</p>
171   </div>
172
173   <h2 id="collapse-usage">Usage</h2>
174   <p>The collapse plugin utilizes a few classes to handle the heavy lifting:</p>
175   <ul>
176     <li><code>.collapse</code> hides the content</li>
177     <li><code>.collapse.in</code> shows the content</li>
178     <li><code>.collapsing</code> is added when the transition starts, and removed when it finishes</li>
179   </ul>
180   <p>These classes can be found in <code>component-animations.less</code>.</p>
181
182   <h3>Via data attributes</h3>
183   <p>Just add <code>data-toggle="collapse"</code> and a <code>data-target</code> to the element to automatically assign control of a collapsible element. The <code>data-target</code> attribute accepts a CSS selector to apply the collapse to. Be sure to add the class <code>collapse</code> to the collapsible element. If you'd like it to default open, add the additional class <code>in</code>.</p>
184   <p>To add accordion-like group management to a collapsible control, add the data attribute <code>data-parent="#selector"</code>. Refer to the demo to see this in action.</p>
185
186   <h3>Via JavaScript</h3>
187   <p>Enable manually with:</p>
188 {% highlight js %}
189 $('.collapse').collapse()
190 {% endhighlight %}
191
192   <h3 id="collapse-options">Options</h3>
193   <p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-parent=""</code>.</p>
194   <div class="table-responsive">
195     <table class="table table-bordered table-striped js-options-table">
196       <thead>
197        <tr>
198          <th>Name</th>
199          <th>type</th>
200          <th>default</th>
201          <th>description</th>
202        </tr>
203       </thead>
204       <tbody>
205        <tr>
206          <td>parent</td>
207          <td>selector</td>
208          <td>false</td>
209          <td>If a selector is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the <code>panel</code> class)</td>
210        </tr>
211        <tr>
212          <td>toggle</td>
213          <td>boolean</td>
214          <td>true</td>
215          <td>Toggles the collapsible element on invocation</td>
216        </tr>
217       </tbody>
218     </table>
219   </div><!-- /.table-responsive -->
220
221   <h3 id="collapse-methods">Methods</h3>
222
223   <h4><code>.collapse(options)</code></h4>
224   <p>Activates your content as a collapsible element. Accepts an optional options <code>object</code>.</p>
225 {% highlight js %}
226 $('#myCollapsible').collapse({
227   toggle: false
228 })
229 {% endhighlight %}
230
231   <h4><code>.collapse('toggle')</code></h4>
232   <p>Toggles a collapsible element to shown or hidden.</p>
233
234   <h4><code>.collapse('show')</code></h4>
235   <p>Shows a collapsible element.</p>
236
237   <h4><code>.collapse('hide')</code></h4>
238   <p>Hides a collapsible element.</p>
239
240   <h3 id="collapse-events">Events</h3>
241   <p>Bootstrap's collapse class exposes a few events for hooking into collapse functionality.</p>
242   <div class="table-responsive">
243     <table class="table table-bordered table-striped bs-events-table">
244       <thead>
245        <tr>
246          <th>Event Type</th>
247          <th>Description</th>
248        </tr>
249       </thead>
250       <tbody>
251        <tr>
252          <td>show.bs.collapse</td>
253          <td>This event fires immediately when the <code>show</code> instance method is called.</td>
254        </tr>
255        <tr>
256          <td>shown.bs.collapse</td>
257          <td>This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).</td>
258        </tr>
259        <tr>
260          <td>hide.bs.collapse</td>
261          <td>
262           This event is fired immediately when the <code>hide</code> method has been called.
263          </td>
264        </tr>
265        <tr>
266          <td>hidden.bs.collapse</td>
267          <td>This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).</td>
268        </tr>
269       </tbody>
270     </table>
271   </div><!-- /.table-responsive -->
272 {% highlight js %}
273 $('#myCollapsible').on('hidden.bs.collapse', function () {
274   // do something…
275 })
276 {% endhighlight %}
277 </div>