|
16 | 16 | <div :class="['card-header',{'header-toggle':isExpandableCard}, cardType, borderType]" |
17 | 17 | @click.prevent.stop="isExpandableCard && toggle()" |
18 | 18 | @mouseover="onHeaderHover = true" @mouseleave="onHeaderHover = false"> |
19 | | - <div class="header-wrapper" ref="headerWrapper"> |
| 19 | + <div class="caret-wrapper"> |
| 20 | + <span :class="['glyphicon', localExpanded ? 'glyphicon-chevron-down' : 'glyphicon-chevron-right']" v-if="showCaret"></span> |
| 21 | + </div> |
| 22 | + <div class="header-wrapper"> |
20 | 23 | <slot name="header"> |
21 | 24 | <div :class="['card-title', cardType, {'text-white':!isLightBg}]" v-html="headerContent"></div> |
22 | 25 | </slot> |
|
204 | 207 | return this.cardType === 'bg-light' || this.cardType === 'bg-white' || this.cardType === 'bg-warning'; |
205 | 208 | }, |
206 | 209 | headerContent () { |
207 | | - return this.renderedHeader; |
| 210 | + return md.render(this.header); |
208 | 211 | }, |
209 | 212 | altContent () { |
210 | | - return this.alt && md.render(this.alt) || this.renderedHeader; |
211 | | - }, |
212 | | - renderedHeader () { |
213 | | - if (!this.header) { |
214 | | - return ''; |
215 | | - } |
216 | | -
|
217 | | - let htmlRenderedHeader = md.render(this.header).trim(); |
218 | | -
|
219 | | - if (this.isSeamless) { |
220 | | - // insert the caret to the header content |
221 | | - let caretAdded = false; |
222 | | -
|
223 | | - // if the header content is wrapped by a <p> or any <h1>, <h2>, ... |
224 | | - // then it must be inserted inside these HTML tags, otherwise the |
225 | | - // header content will not be in the same line as caret |
226 | | - const tags = ['<p>', '<h1>', '<h2>', '<h3>', '<h4>', '<h5>', '<h6>']; |
227 | | - tags.forEach(tag => { |
228 | | - if (!caretAdded && htmlRenderedHeader.startsWith(tag)) { |
229 | | - htmlRenderedHeader = this.insertCaretInsideHeader(htmlRenderedHeader); |
230 | | - caretAdded = true; |
231 | | - } |
232 | | - }); |
233 | | -
|
234 | | - if (!caretAdded) { |
235 | | - htmlRenderedHeader = this.caretHtml + ' ' + htmlRenderedHeader; |
236 | | - } |
237 | | - } |
238 | | - return htmlRenderedHeader; |
| 213 | + return this.alt && md.render(this.alt) || md.render(this.header); |
239 | 214 | }, |
240 | 215 | hasSrc () { |
241 | 216 | return this.src && this.src.length > 0; |
|
246 | 221 | } else { |
247 | 222 | return onHeaderHover; |
248 | 223 | } |
249 | | - }, |
250 | | - caretHtml () { |
251 | | - if (this.localExpanded) { |
252 | | - return '<span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span>' |
253 | | - } else { |
254 | | - return '<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>' |
255 | | - } |
256 | | - }, |
257 | | - hasCustomHeader () { |
258 | | - return this.$slots.header !== undefined; |
259 | 224 | } |
260 | 225 | }, |
261 | 226 | data () { |
|
299 | 264 | if (isOpen && this.hasSrc) { |
300 | 265 | this.$refs.retriever.fetch() |
301 | 266 | } |
302 | | - }, |
303 | | - insertCaretInsideHeader(originalHeaderHTML) { |
304 | | - const wrappedElementName = jQuery(originalHeaderHTML).attr("name"); |
305 | | - return jQuery(originalHeaderHTML).unwrap().prepend(this.caretHtml + ' ') |
306 | | - .wrap(`<${wrappedElementName}></${wrappedElementName}>`).parent().html(); |
307 | 267 | } |
308 | 268 | }, |
309 | 269 | watch: { |
|
332 | 292 | if (this.hasSrc && (this.preloadBool || this.expandedBool)) { |
333 | 293 | this.$refs.retriever.fetch() |
334 | 294 | } |
335 | | -
|
336 | | - if (this.hasCustomHeader) { |
337 | | - this.$refs.headerWrapper.innerHTML = |
338 | | - this.insertCaretInsideHeader(this.$refs.headerWrapper.innerHTML); |
339 | | - } |
340 | 295 | }); |
341 | 296 | const panelHeader = this.$slots.header ? this.$refs.headerWrapper.innerHTML : this.headerContent; |
342 | 297 | const panelHeaderText = jQuery(panelHeader).wrap('<div></div>').parent().find(':header').text(); |
|
363 | 318 | margin: 0px !important; |
364 | 319 | } |
365 | 320 |
|
| 321 | + .caret-wrapper { |
| 322 | + float: left; |
| 323 | + display: inline-block; |
| 324 | + width: 32px; |
| 325 | + } |
| 326 | +
|
366 | 327 | .header-wrapper { |
367 | 328 | display: inline-block; |
368 | | - width: 72%; |
| 329 | + width: calc(100% - 32px - 96px); |
369 | 330 | } |
370 | 331 |
|
371 | 332 | .button-wrapper { |
372 | 333 | float: right; |
373 | 334 | display: inline-block; |
374 | | - width: 28%; |
| 335 | + width: 96px; |
375 | 336 | } |
376 | 337 |
|
377 | 338 | .header-toggle { |
|
450 | 411 | /* Bootstrap extra small(xs) responsive breakpoint */ |
451 | 412 | @media (max-width: 575.98px) { |
452 | 413 |
|
| 414 | + .caret-wrapper { |
| 415 | + float: left; |
| 416 | + display: inline-block; |
| 417 | + width: 32px; |
| 418 | + } |
| 419 | +
|
453 | 420 | .header-wrapper { |
454 | | - width: 88%; |
| 421 | + display: inline-block; |
| 422 | + width: calc(100% - 32px - 32px); |
455 | 423 | } |
456 | 424 |
|
457 | 425 | .button-wrapper { |
458 | | - width: 12%; |
| 426 | + float: right; |
| 427 | + display: inline-block; |
| 428 | + width: 32px; |
459 | 429 | } |
460 | 430 |
|
461 | 431 | .card-body { |
|
0 commit comments