From ab20dd1bcd50125be5a310829ee939f74ee9a41f Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sun, 13 Jul 2014 00:54:34 -0700 Subject: [PATCH] markdownify js popovers --- docs/javascript/popovers.md | 507 +++++++++++++++++++----------------- 1 file changed, 261 insertions(+), 246 deletions(-) diff --git a/docs/javascript/popovers.md b/docs/javascript/popovers.md index 10bb424120..805f3d6694 100644 --- a/docs/javascript/popovers.md +++ b/docs/javascript/popovers.md @@ -3,97 +3,95 @@ layout: page title: Popovers --- -
-

Popovers popover.js

+Add small overlays of content, like those on the iPad, to any element for housing secondary information. -

Examples

-

Add small overlays of content, like those on the iPad, to any element for housing secondary information.

+
+

Plugin dependency

+

Popovers require the tooltip plugin to be included in your version of Bootstrap.

+
+
+

Opt-in functionality

+

For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.

+
+
+

Popovers in button groups and input groups require special setting

+

When using popovers on elements within a .btn-group or an .input-group, you'll have to specify the option container: 'body' (documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the popover is triggered).

+
+
+

Don't try to show popovers on hidden elements

+

Invoking $(...).popover('show') when the target element is display: none; will cause the popover to be incorrectly positioned.

+
+
+

Popovers on disabled elements require wrapper elements

+

To add a popover to a disabled or .disabled element, put the element inside of a <div> and apply the popover to that <div> instead.

+
-
-

Plugin dependency

-

Popovers require the tooltip plugin to be included in your version of Bootstrap.

-
-
-

Opt-in functionality

-

For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.

-
-
-

Popovers in button groups and input groups require special setting

-

When using popovers on elements within a .btn-group or an .input-group, you'll have to specify the option container: 'body' (documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the popover is triggered).

-
-
-

Don't try to show popovers on hidden elements

-

Invoking $(...).popover('show') when the target element is display: none; will cause the popover to be incorrectly positioned.

-
-
-

Popovers on disabled elements require wrapper elements

-

To add a popover to a disabled or .disabled element, put the element inside of a <div> and apply the popover to that <div> instead.

-
+### Static popover -

Static popover

-

Four options are available: top, right, bottom, and left aligned.

-
-
-
-

Popover top

-
-

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

-
+Four options are available: top, right, bottom, and left aligned. + +
+
+
+

Popover top

+
+

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

- -
-
-

Popover right

-
-

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

-
-
- -
-
-

Popover bottom

- -
-

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

-
-
- -
-
-

Popover left

-
-

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

-
-
- -
-

Live demo

-
- -
-{% highlight html %} - -{% endhighlight %} - -

Four directions

-
-
- - - - +
+
+

Popover right

+
+

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

-
+
+ +
+
+

Popover bottom

+ +
+

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

+
+
+ +
+
+

Popover left

+
+

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

+
+
+ +
+
+ +### Live demo + +{% example html %} + +{% endexample %} + +#### Four directions + +
+
+ + + + +
+
+ {% highlight html %} {% endhighlight %} -

Dismiss on next click

-

Use the focus trigger to dismiss popovers on the next click that the user makes.

-
- -
-{% highlight html %} +#### Dismiss on next click + +Use the `focus` trigger to dismiss popovers on the next click that the user makes. + +{% example html %} -{% endhighlight %} +{% endexample %} + {% highlight js %} $('.popover-dismiss').popover({ trigger: 'focus' }) {% endhighlight %} -
-

Multiple-line links

-

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 white-space: nowrap; to your anchors to avoid this.

-
+
+

Multiple-line links

+

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 white-space: nowrap; to your anchors to avoid this.

+
-

Usage

-

Enable popovers via JavaScript:

- {% highlight js %}$('#example').popover(options){% endhighlight %} +## Usage -

Options

-

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
animationbooleantrueApply a CSS fade transition to the popover
containerstring | falsefalse -

Appends the popover to a specific element. Example: container: 'body'. 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.

-
contentstring | function'' -

Default content value if data-content attribute isn't present.

-

If a function is given, it will be called with 1 argument, which is the element that the popover is attached to.

-
delaynumber | object0 -

Delay showing and hiding the popover (ms) - does not apply to manual trigger type

-

If a number is supplied, delay is applied to both hide/show

-

Object structure is: delay: { "show": 500, "hide": 100 }

-
htmlbooleanfalseInsert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks.
placementstring | function'right'How to position the popover - top | bottom | left | right | auto.
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.
selectorstringfalseIf 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 this and an informative example.
templatestring'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' -

Base HTML to use when creating the popover.

-

The popover's title will be injected into the .popover-title.

-

The popover's content will be injected into the .popover-content.

-

.arrow will become the popover's arrow.

-

The outermost wrapper element should have the .popover class.

-
titlestring | function''Default title value if title attribute isn't present
triggerstring'click'How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.
viewportstring | object{ selector: 'body', padding: 0 } -

Keeps the popover within the bounds of this element. Example: viewport: '#viewport' or { "selector": "#viewport", "padding": 0 }

-
-
-
-

Data attributes for individual popovers

-

Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.

-
+Enable popovers via JavaScript: -

Methods

-

$().popover(options)

-

Initializes popovers for an element collection.

+{% highlight js %}$('#example').popover(options){% endhighlight %} -

.popover('show')

-

Reveals an elements popover.

- {% highlight js %}$('#element').popover('show'){% endhighlight %} +### Options -

.popover('hide')

-

Hides an elements popover.

- {% highlight js %}$('#element').popover('hide'){% endhighlight %} +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-animation=""`. -

.popover('toggle')

-

Toggles an elements popover.

- {% highlight js %}$('#element').popover('toggle'){% endhighlight %} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
animationbooleantrueApply a CSS fade transition to the popover
containerstring | falsefalse +

Appends the popover to a specific element. Example: container: 'body'. 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.

+
contentstring | function'' +

Default content value if data-content attribute isn't present.

+

If a function is given, it will be called with 1 argument, which is the element that the popover is attached to.

+
delaynumber | object0 +

Delay showing and hiding the popover (ms) - does not apply to manual trigger type

+

If a number is supplied, delay is applied to both hide/show

+

Object structure is: delay: { "show": 500, "hide": 100 }

+
htmlbooleanfalseInsert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks.
placementstring | function'right'How to position the popover - top | bottom | left | right | auto.
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.
selectorstringfalseIf 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 this and an informative example.
templatestring'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' +

Base HTML to use when creating the popover.

+

The popover's title will be injected into the .popover-title.

+

The popover's content will be injected into the .popover-content.

+

.arrow will become the popover's arrow.

+

The outermost wrapper element should have the .popover class.

+
titlestring | function''Default title value if title attribute isn't present
triggerstring'click'How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.
viewportstring | object{ selector: 'body', padding: 0 } +

Keeps the popover within the bounds of this element. Example: viewport: '#viewport' or { "selector": "#viewport", "padding": 0 }

+
+
+ +
+

Data attributes for individual popovers

+

Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.

+
+ +### Methods + +#### $().popover(options) + +Initializes popovers for an element collection. + +#### .popover('show') + +Reveals an elements popover. + +{% highlight js %}$('#element').popover('show'){% endhighlight %} + +#### .popover('hide') + +Hides an elements popover. + +{% highlight js %}$('#element').popover('hide'){% endhighlight %} + +#### .popover('toggle') + +Toggles an elements popover. + +{% highlight js %}$('#element').popover('toggle'){% endhighlight %} + +#### .popover('destroy') + +Hides and destroys an element's popover. + +{% highlight js %}$('#element').popover('destroy'){% endhighlight %} + +### Events + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Event TypeDescription
show.bs.popoverThis event fires immediately when the show instance method is called.
shown.bs.popoverThis event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).
hide.bs.popoverThis event is fired immediately when the hide instance method has been called.
hidden.bs.popoverThis event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).
+
-

.popover('destroy')

-

Hides and destroys an element's popover.

- {% highlight js %}$('#element').popover('destroy'){% endhighlight %} -

Events

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
Event TypeDescription
show.bs.popoverThis event fires immediately when the show instance method is called.
shown.bs.popoverThis event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).
hide.bs.popoverThis event is fired immediately when the hide instance method has been called.
hidden.bs.popoverThis event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).
-
{% highlight js %} $('#myPopover').on('hidden.bs.popover', function () { // do something… }) {% endhighlight %} -