You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

card-widget.md 5.8KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. ---
  2. layout: page
  3. title: Card Widget Plugin
  4. ---
  5. The card widget plugin provides the functionality for collapsing, expanding and removing a card.
  6. ### Usage
  7. This plugin can be activated as a jQuery plugin or using the data API.
  8. #### Data API
  9. This plugin provides two `data-api` attributes. Any element using one of the following attributes should be placed
  10. within the `.card-tools` div, which is usually in the card header. For more information about the [card HTML structure](
  11. {% link components/cards.md %}), visit the card component documentation
  12. ##### `data-card-widget="collapse"`
  13. This attribute, when attached to a button, allows the box to be collapsed/expanded when clicked.
  14. <div class="row">
  15. <div class="col-12 col-md-4">
  16. <div class="card">
  17. <div class="card-header">
  18. <h3 class="card-title">Collapsible Card Example</h3>
  19. <div class="card-tools">
  20. <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
  21. </div>
  22. </div>
  23. <div class="card-body">
  24. The body of the card
  25. </div>
  26. </div>
  27. </div>
  28. <div class="col-12 col-md-8" markdown="1">
  29. ```html
  30. <div class="card">
  31. <div class="card-header">
  32. <h3 class="card-title">Collapsible Card Example</h3>
  33. <div class="card-tools">
  34. <!-- Collapse Button -->
  35. <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
  36. </div>
  37. <!-- /.card-tools -->
  38. </div>
  39. <!-- /.card-header -->
  40. <div class="card-body">
  41. The body of the card
  42. </div>
  43. <!-- /.card-body -->
  44. </div>
  45. <!-- /.card -->
  46. ```
  47. {: .max-height-300}
  48. </div>
  49. </div>
  50. ##### `data-card-widget="remove"`
  51. This attribute, when attached to a button, allows the box to be removed when clicked.
  52. <div class="row">
  53. <div class="col-12 col-md-4">
  54. <div class="card">
  55. <div class="card-header">
  56. <h3 class="card-title">Removable Card Example</h3>
  57. <div class="card-tools">
  58. <button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fas fa-times"></i></button>
  59. </div>
  60. </div>
  61. <div class="card-body">
  62. The body of the card
  63. </div>
  64. </div>
  65. </div>
  66. <div class="col-12 col-md-8" markdown="1">
  67. ```html
  68. <div class="card">
  69. <div class="card-header">
  70. <h3 class="card-title">Removable Card Example</h3>
  71. <div class="card-tools">
  72. <!-- Remove Button -->
  73. <button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fas fa-times"></i></button>
  74. </div>
  75. <!-- /.card-tools -->
  76. </div>
  77. <!-- /.card-header -->
  78. <div class="card-body">
  79. The body of the card
  80. </div>
  81. <!-- /.card-body -->
  82. </div>
  83. <!-- /.card -->
  84. ```
  85. {: .max-height-300}
  86. </div>
  87. </div>
  88. ##### `data-card-widget="maximize"`
  89. This attribute, when attached to a button, allows the box to be maximize/minimize when clicked.
  90. <div class="row">
  91. <div class="col-12 col-md-4">
  92. <div class="card">
  93. <div class="card-header">
  94. <h3 class="card-title">Maximizable Card Example</h3>
  95. <div class="card-tools">
  96. <button type="button" class="btn btn-tool" data-card-widget="maximize"><i class="fas fa-expand"></i></button>
  97. </div>
  98. </div>
  99. <div class="card-body">
  100. The body of the card
  101. </div>
  102. </div>
  103. </div>
  104. <div class="col-12 col-md-8" markdown="1">
  105. ```html
  106. <div class="card">
  107. <div class="card-header">
  108. <h3 class="card-title">Maximizable Card Example</h3>
  109. <div class="card-tools">
  110. <!-- Maximize Button -->
  111. <button type="button" class="btn btn-tool" data-card-widget="maximize"><i class="fas fa-expand"></i></button>
  112. </div>
  113. <!-- /.card-tools -->
  114. </div>
  115. <!-- /.card-header -->
  116. <div class="card-body">
  117. The body of the card
  118. </div>
  119. <!-- /.card-body -->
  120. </div>
  121. <!-- /.card -->
  122. ```
  123. {: .max-height-300}
  124. </div>
  125. </div>
  126. ###### jQuery
  127. {: .text-bold }
  128. To activate any button using jQuery, you must provide the removeTrigger and collapseTrigger options. Otherwise, the
  129. plugin will assume the default `data-card-widget` selectors.
  130. ```js
  131. $('#my-card').CardWidget(options)
  132. ```
  133. ##### Options
  134. {: .mt-4}
  135. |---
  136. | Name | Type | Default | Description
  137. |-|-|-|-
  138. |animationSpeed | Number | 300 | Speed of slide down/up animation in milliseconds.
  139. |collapseTrigger | String | `[data-card-widget="collapse"]` | jQuery selector to the element responsible for collapsing
  140. the box.
  141. |removeTrigger | String | `[data-card-widget="remove"]` | jQuery selector to the element responsible for removing the
  142. box.
  143. |maximizeTrigger | String | `[data-card-widget="maximize"]` | jQuery selector to the element responsible for maximizing
  144. the box.
  145. {: .table .table-bordered .bg-light}
  146. > ##### Tip!
  147. > You can use any option via the data-attributes like this.
  148. > ```html
  149. > <button type="button" class="btn btn-tool" data-card-widget="collapse" data-animation-speed="1000"><i class="fas fa-minus"></i></button>
  150. > ```
  151. {: .quote-info}
  152. ##### Events
  153. {: .mt-4}
  154. |---
  155. | Event Type | Description
  156. |-|-
  157. |expanded.lte.cardwidget | Triggered after a card expanded.
  158. |collapsed.lte.cardwidget | Triggered after a card collapsed.
  159. |maximized.lte.cardwidget | Triggered after a card maximized.
  160. |minimized.lte.cardwidget | Triggered after a card minimized.
  161. |removed.lte.cardwidget | Triggered after a card removed.
  162. {: .table .table-bordered .bg-light}
  163. Example: `$('#my-card').on('expanded.lte.cardwidget', handleExpandedEvent)`
  164. ##### Methods
  165. {: .mt-4}
  166. |---
  167. | Method | Description
  168. |-|-
  169. |collapse | Collapses the card
  170. |expand | Expands the card
  171. |remove | Removes the card
  172. |toggle | Toggles the state of the card between expanded and collapsed
  173. |maximize | Maximizes the card
  174. |minimize | Minimizes the card
  175. |toggleMaximize | Toggles the state of the card between maximized and minimized
  176. {: .table .table-bordered .bg-light}
  177. Example: `$('#my-card-widget').CardWidget('toggle')` or `$('#my-card').CardWidget('toggle')`