Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. # Popover
  2.  
  3. ## Overview
  4.  
  5. The popover plugin displays HTML in a container that overlays the page. It is triggered by clicking on a button or other UI element and the container is positioned near the element. The popover can be displayed and hidden at will.
  6.  
  7. ## Usage
  8.  
  9. The plugin must be provided with an options object and a jQuery collection of elements.
  10.  
  11. ```js
  12. $('.my-button').popover(options);
  13. ```
  14.  
  15. Clicking `.my-button` will toggle display of the popover.
  16.  
  17. To open or close a popover programmatically, trigger a `click` event on the element:
  18.  
  19. ```js
  20. $('.my-button').click();
  21. ```
  22.  
  23. ## Options
  24.  
  25. At minimum, the options must contain HTML to display:
  26.  
  27. ```js
  28. $('.my-button').popover({
  29. html: '<p>Hello world</p>'
  30. });
  31. ```
  32.  
  33. For shorthand, if you only need to specify the HTML you can just pass a string:
  34.  
  35. ```js
  36. // Equivalent to the previous example
  37. $('.my-button').popover('<p>Hello world</p>');
  38. ```
  39.  
  40. ### Options
  41.  
  42. Property | Type | Description
  43. --- | --- | ---
  44. `html` | String | Contents to be displayed (required)
  45. `badge` | Number | A value to be displayed in a badge superimposed over the toggle element. If the value is less than 1, no badge will be displayed.
  46. `display` | Object | Defines the display properties of the popover (see below)
  47.  
  48. ### Display options
  49.  
  50. Property | Type | Description
  51. --- | --- | ---
  52. `width` | String | The width of the popover (must be a CSS-friendly value; default: `auto`)
  53. `height` | String | The height of the popover (must be a CSS-friendly value; default: `auto`)
  54. `className` | String | Optional class name(s) to be added to the popover
  55.  
  56. ## Example with default values
  57.  
  58. ```js
  59. $('.my-button').popover({
  60. html: '',
  61. badge: 0,
  62. display: {
  63. width: 'auto',
  64. height: 'auto'
  65. }
  66. });
  67. ```
  68.  
  69. ## Specifications
  70.  
  71. Clicking outside of an open popover will close it.
  72.  
  73. Only one popover may be open at a time. If a popover is open when a second popover is triggered, the first popover is closed before opening the second popover.
  74.  
  75. The popover container has the class `.cui-popover`.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement