Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / _includes / js / popovers.html
1 <div class="bs-docs-section">
2   <h1 id="popovers" class="page-header">Popovers <small>popover.js</small></h1>
3
4   <p>Add small overlays of content, like those on the iPad, to any element for housing secondary information.</p>
5   <p>Popovers whose both title and content are zero-length are never displayed.</p>
6
7   <div class="bs-callout bs-callout-danger" id="callout-popover-needs-tooltip">
8     <h4>Plugin dependency</h4>
9     <p>Popovers require the <a href="#tooltips">tooltip plugin</a> to be included in your version of Bootstrap.</p>
10   </div>
11   <div class="bs-callout bs-callout-danger" id="callout-popover-opt-in">
12     <h4>Opt-in functionality</h4>
13     <p>For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning <strong>you must initialize them yourself</strong>.</p>
14     <p>One way to initialize all popovers on a page would be to select them by their <code>data-toggle</code> attribute:</p>
15 {% highlight js %}
16 $(function () {
17   $('[data-toggle="popover"]').popover()
18 })
19 {% endhighlight %}
20   </div>
21   <div class="bs-callout bs-callout-warning" id="callout-popover-groups">
22     <h4>Popovers in button groups and input groups require special setting</h4>
23     <p>When using popovers on elements within a <code>.btn-group</code> or an <code>.input-group</code>, you'll have to specify the option <code>container: 'body'</code> (documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the popover is triggered).</p>
24   </div>
25   <div class="bs-callout bs-callout-warning" id="callout-popover-hidden">
26     <h4>Don't try to show popovers on hidden elements</h4>
27     <p>Invoking <code>$(...).popover('show')</code> when the target element is <code>display: none;</code> will cause the popover to be incorrectly positioned.</p>
28   </div>
29   <div class="bs-callout bs-callout-info" id="callout-popover-disabled">
30     <h4>Popovers on disabled elements require wrapper elements</h4>
31     <p>To add a popover to a <code>disabled</code> or <code>.disabled</code> element, put the element inside of a <code>&lt;div&gt;</code> and apply the popover to that <code>&lt;div&gt;</code> instead.</p>
32   </div>
33   <div class="bs-callout bs-callout-info" id="callout-popover-multiline">
34     <h4>Multiple-line links</h4>
35     <p>Sometimes you want to add a popover to a hyperlink that wraps multiple lines. The default behavior of the popover plugin is to center it horizontally and vertically. Add <code>white-space: nowrap;</code> to your anchors to avoid this.</p>
36   </div>
37
38   <h2 id="popovers-examples">Examples</h2>
39   <h3>Static popover</h3>
40   <p>Four options are available: top, right, bottom, and left aligned.</p>
41   <div class="bs-example bs-example-popover" data-example-id="static-popovers">
42     <div class="popover top">
43       <div class="arrow"></div>
44       <h3 class="popover-title">Popover top</h3>
45       <div class="popover-content">
46         <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p>
47       </div>
48     </div>
49
50     <div class="popover right">
51       <div class="arrow"></div>
52       <h3 class="popover-title">Popover right</h3>
53       <div class="popover-content">
54         <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p>
55       </div>
56     </div>
57
58     <div class="popover bottom">
59       <div class="arrow"></div>
60       <h3 class="popover-title">Popover bottom</h3>
61
62       <div class="popover-content">
63         <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p>
64       </div>
65     </div>
66
67     <div class="popover left">
68       <div class="arrow"></div>
69       <h3 class="popover-title">Popover left</h3>
70       <div class="popover-content">
71         <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p>
72       </div>
73     </div>
74
75     <div class="clearfix"></div>
76   </div>
77
78   <h3>Live demo</h3>
79   <div class="bs-example bs-example-padded-bottom">
80     <button type="button" class="btn btn-lg btn-danger bs-docs-popover" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
81   </div>
82 {% highlight html %}
83 <button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
84 {% endhighlight %}
85
86   <h4>Four directions</h4>
87   <div class="bs-example popover-demo">
88     <div class="bs-example-popovers">
89       <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="left" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
90         Popover on left
91       </button>
92       <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
93         Popover on top
94       </button>
95       <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
96         Popover on bottom
97       </button>
98       <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="right" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
99         Popover on right
100       </button>
101     </div>
102   </div><!-- /example -->
103 {% highlight html %}
104 <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="left" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
105   Popover on left
106 </button>
107
108 <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
109   Popover on top
110 </button>
111
112 <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Vivamus
113 sagittis lacus vel augue laoreet rutrum faucibus.">
114   Popover on bottom
115 </button>
116
117 <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="right" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
118   Popover on right
119 </button>
120 {% endhighlight %}
121
122   <h4>Dismiss on next click</h4>
123   <p>Use the <code>focus</code> trigger to dismiss popovers on the next click that the user makes.</p>
124   <div class="bs-callout bs-callout-danger" id="callout-popover-dismiss-click">
125     <h4>Specific markup required for dismiss-on-next-click</h4>
126     <p>For proper cross-browser and cross-platform behavior, you must use the <code>&lt;a&gt;</code> tag, <i>not</i> the <code>&lt;button&gt;</code> tag, and you also must include the <code>role="button"</code> and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#tabindex"><code>tabindex</code></a> attributes.</p>
127   </div>
128   <div class="bs-example bs-example-padded-bottom">
129     <a tabindex="0" class="btn btn-lg btn-danger bs-docs-popover" role="button" data-toggle="popover" data-trigger="focus" title="Dismissible popover" data-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
130   </div>
131 {% highlight html %}
132 <a tabindex="0" class="btn btn-lg btn-danger" role="button" data-toggle="popover" data-trigger="focus" title="Dismissible popover" data-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
133 {% endhighlight %}
134
135
136   <h2 id="popovers-usage">Usage</h2>
137   <p>Enable popovers via JavaScript:</p>
138   {% highlight js %}$('#example').popover(options){% endhighlight %}
139
140   <h3 id="popovers-options">Options</h3>
141   <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-animation=""</code>.</p>
142   <div class="table-responsive">
143     <table class="table table-bordered table-striped js-options-table js-options-table">
144       <thead>
145         <tr>
146           <th>Name</th>
147           <th>Type</th>
148           <th>Default</th>
149           <th>Description</th>
150         </tr>
151       </thead>
152       <tbody>
153         <tr>
154           <td>animation</td>
155           <td>boolean</td>
156           <td>true</td>
157           <td>Apply a CSS fade transition to the popover</td>
158         </tr>
159         <tr>
160           <td>container</td>
161           <td>string | false</td>
162           <td>false</td>
163           <td>
164             <p>Appends the popover to a specific element. Example: <code>container: 'body'</code>. This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize.</p>
165           </td>
166         </tr>
167         <tr>
168           <td>content</td>
169           <td>string | function</td>
170           <td>''</td>
171           <td>
172             <p>Default content value if <code>data-content</code> attribute isn't present.</p>
173             <p>If a function is given, it will be called with its <code>this</code> reference set to the element that the popover is attached to.</p>
174           </td>
175         </tr>
176         <tr>
177           <td>delay</td>
178           <td>number | object</td>
179           <td>0</td>
180           <td>
181            <p>Delay showing and hiding the popover (ms) - does not apply to manual trigger type</p>
182            <p>If a number is supplied, delay is applied to both hide/show</p>
183            <p>Object structure is: <code>delay: { "show": 500, "hide": 100 }</code></p>
184           </td>
185         </tr>
186         <tr>
187           <td>html</td>
188           <td>boolean</td>
189           <td>false</td>
190           <td>Insert HTML into the popover. If false, jQuery's <code>text</code> method will be used to insert content into the DOM. Use text if you're worried about XSS attacks.</td>
191         </tr>
192         <tr>
193           <td>placement</td>
194           <td>string | function</td>
195           <td>'right'</td>
196           <td>
197             <p>How to position the popover - top | bottom | left | right | auto.<br>When "auto" is specified, it will dynamically reorient the popover. For example, if placement is "auto left", the popover will display to the left when possible, otherwise it will display right.</p>
198             <p>When a function is used to determine the placement, it is called with the popover DOM node as its first argument and the triggering element DOM node as its second. The <code>this</code> context is set to the popover instance.</p>
199           </td>
200         </tr>
201         <tr>
202           <td>selector</td>
203           <td>string</td>
204           <td>false</td>
205           <td>If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See <a href="https://github.com/twbs/bootstrap/issues/4215">this</a> and <a href="http://jsbin.com/zopod/1/edit">an informative example</a>.</td>
206         </tr>
207         <tr>
208           <td>template</td>
209           <td>string</td>
210           <td><code>'&lt;div class="popover" role="tooltip"&gt;&lt;div class="arrow"&gt;&lt;/div&gt;&lt;h3 class="popover-title"&gt;&lt;/h3&gt;&lt;div class="popover-content"&gt;&lt;/div&gt;&lt;/div&gt;'</code></td>
211           <td>
212             <p>Base HTML to use when creating the popover.</p>
213             <p>The popover's <code>title</code> will be injected into the <code>.popover-title</code>.</p>
214             <p>The popover's <code>content</code> will be injected into the <code>.popover-content</code>.</p>
215             <p><code>.arrow</code> will become the popover's arrow.</p>
216             <p>The outermost wrapper element should have the <code>.popover</code> class.</p>
217           </td>
218         </tr>
219         <tr>
220           <td>title</td>
221           <td>string | function</td>
222           <td>''</td>
223           <td>
224             <p>Default title value if <code>title</code> attribute isn't present.</p>
225             <p>If a function is given, it will be called with its <code>this</code> reference set to the element that the popover is attached to.</p>
226           </td>
227         </tr>
228         <tr>
229           <td>trigger</td>
230           <td>string</td>
231           <td>'click'</td>
232           <td>How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.</td>
233         </tr>
234         <tr>
235           <td>viewport</td>
236           <td>string | object</td>
237           <td>{ selector: 'body', padding: 0 }</td>
238           <td>
239             <p>Keeps the popover within the bounds of this element. Example: <code>viewport: '#viewport'</code> or <code>{ "selector": "#viewport", "padding": 0 }</code></p>
240           </td>
241        </tr>
242       </tbody>
243     </table>
244   </div><!-- /.table-responsive -->
245   <div class="bs-callout bs-callout-info" id="callout-popover-data">
246     <h4>Data attributes for individual popovers</h4>
247     <p>Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.</p>
248   </div>
249
250   <h3>Methods</h3>
251   <h4><code>$().popover(options)</code></h4>
252   <p>Initializes popovers for an element collection.</p>
253
254   <h4><code>.popover('show')</code></h4>
255   <p>Reveals an element's popover. <strong>Returns to the caller before the popover has actually been shown</strong> (i.e. before the <code>shown.bs.popover</code> event occurs). This is considered a "manual" triggering of the popover. Popovers whose both title and content are zero-length are never displayed.</p>
256   {% highlight js %}$('#element').popover('show'){% endhighlight %}
257
258   <h4><code>.popover('hide')</code></h4>
259   <p>Hides an element's popover. <strong>Returns to the caller before the popover has actually been hidden</strong> (i.e. before the <code>hidden.bs.popover</code> event occurs). This is considered a "manual" triggering of the popover.</p>
260   {% highlight js %}$('#element').popover('hide'){% endhighlight %}
261
262   <h4><code>.popover('toggle')</code></h4>
263   <p>Toggles an element's popover. <strong>Returns to the caller before the popover has actually been shown or hidden</strong> (i.e. before the <code>shown.bs.popover</code> or <code>hidden.bs.popover</code> event occurs). This is considered a "manual" triggering of the popover.</p>
264   {% highlight js %}$('#element').popover('toggle'){% endhighlight %}
265
266   <h4><code>.popover('destroy')</code></h4>
267   <p>Hides and destroys an element's popover. Popovers that use delegation (which are created using <a href="#popovers-options">the <code>selector</code> option</a>) cannot be individually destroyed on descendant trigger elements.</p>
268   {% highlight js %}$('#element').popover('destroy'){% endhighlight %}
269
270   <h3 id="popovers-events">Events</h3>
271   <div class="table-responsive">
272     <table class="table table-bordered table-striped bs-events-table">
273       <thead>
274         <tr>
275           <th>Event Type</th>
276           <th>Description</th>
277         </tr>
278       </thead>
279       <tbody>
280         <tr>
281           <td>show.bs.popover</td>
282           <td>This event fires immediately when the <code>show</code> instance method is called.</td>
283         </tr>
284         <tr>
285           <td>shown.bs.popover</td>
286           <td>This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).</td>
287         </tr>
288         <tr>
289           <td>hide.bs.popover</td>
290           <td>This event is fired immediately when the <code>hide</code> instance method has been called.</td>
291         </tr>
292         <tr>
293           <td>hidden.bs.popover</td>
294           <td>This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).</td>
295         </tr>
296       </tbody>
297     </table>
298   </div><!-- /.table-responsive -->
299 {% highlight js %}
300 $('#myPopover').on('hidden.bs.popover', function () {
301   // do something…
302 })
303 {% endhighlight %}
304 </div>