[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 import { b as isRTL, d as defineJQueryPlugin, B as BaseComponent, E as EventHandler, o as findShadowRoot, p as getUID, D as Data, n as noop, S as SelectorEngine, k as isElement, h as getElement, s as sanitizeHtml, M as Manipulator, a as typeCheckConfig, q as DefaultAllowlist } from './dom.js?5.1.3'; 2 import { P as Popper, c as createPopper } from './popper.js?5.1.3'; 3 4 /** 5 * -------------------------------------------------------------------------- 6 * Bootstrap (v5.1.3): tooltip.js 7 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 8 * -------------------------------------------------------------------------- 9 */ 10 /** 11 * ------------------------------------------------------------------------ 12 * Constants 13 * ------------------------------------------------------------------------ 14 */ 15 16 const NAME$1 = 'tooltip'; 17 const DATA_KEY$1 = 'bs.tooltip'; 18 const EVENT_KEY$1 = `.$DATA_KEY$1}`; 19 const CLASS_PREFIX$1 = 'bs-tooltip'; 20 const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); 21 const DefaultType$1 = { 22 animation: 'boolean', 23 template: 'string', 24 title: '(string|element|function)', 25 trigger: 'string', 26 delay: '(number|object)', 27 html: 'boolean', 28 selector: '(string|boolean)', 29 placement: '(string|function)', 30 offset: '(array|string|function)', 31 container: '(string|element|boolean)', 32 fallbackPlacements: 'array', 33 boundary: '(string|element)', 34 customClass: '(string|function)', 35 sanitize: 'boolean', 36 sanitizeFn: '(null|function)', 37 allowList: 'object', 38 popperConfig: '(null|object|function)' 39 }; 40 const AttachmentMap = { 41 AUTO: 'auto', 42 TOP: 'top', 43 RIGHT: isRTL() ? 'left' : 'right', 44 BOTTOM: 'bottom', 45 LEFT: isRTL() ? 'right' : 'left' 46 }; 47 const Default$1 = { 48 animation: true, 49 template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>', 50 trigger: 'hover focus', 51 title: '', 52 delay: 0, 53 html: false, 54 selector: false, 55 placement: 'top', 56 offset: [0, 0], 57 container: false, 58 fallbackPlacements: ['top', 'right', 'bottom', 'left'], 59 boundary: 'clippingParents', 60 customClass: '', 61 sanitize: true, 62 sanitizeFn: null, 63 allowList: DefaultAllowlist, 64 popperConfig: null 65 }; 66 const Event$1 = { 67 HIDE: `hide$EVENT_KEY$1}`, 68 HIDDEN: `hidden$EVENT_KEY$1}`, 69 SHOW: `show$EVENT_KEY$1}`, 70 SHOWN: `shown$EVENT_KEY$1}`, 71 INSERTED: `inserted$EVENT_KEY$1}`, 72 CLICK: `click$EVENT_KEY$1}`, 73 FOCUSIN: `focusin$EVENT_KEY$1}`, 74 FOCUSOUT: `focusout$EVENT_KEY$1}`, 75 MOUSEENTER: `mouseenter$EVENT_KEY$1}`, 76 MOUSELEAVE: `mouseleave$EVENT_KEY$1}` 77 }; 78 const CLASS_NAME_FADE = 'fade'; 79 const CLASS_NAME_MODAL = 'modal'; 80 const CLASS_NAME_SHOW = 'show'; 81 const HOVER_STATE_SHOW = 'show'; 82 const HOVER_STATE_OUT = 'out'; 83 const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; 84 const SELECTOR_MODAL = `.$CLASS_NAME_MODAL}`; 85 const EVENT_MODAL_HIDE = 'hide.bs.modal'; 86 const TRIGGER_HOVER = 'hover'; 87 const TRIGGER_FOCUS = 'focus'; 88 const TRIGGER_CLICK = 'click'; 89 const TRIGGER_MANUAL = 'manual'; 90 /** 91 * ------------------------------------------------------------------------ 92 * Class Definition 93 * ------------------------------------------------------------------------ 94 */ 95 96 class Tooltip extends BaseComponent { 97 constructor(element, config) { 98 if (typeof Popper === 'undefined') { 99 throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)'); 100 } 101 102 super(element); // private 103 104 this._isEnabled = true; 105 this._timeout = 0; 106 this._hoverState = ''; 107 this._activeTrigger = {}; 108 this._popper = null; // Protected 109 110 this._config = this._getConfig(config); 111 this.tip = null; 112 113 this._setListeners(); 114 } // Getters 115 116 117 static get Default() { 118 return Default$1; 119 } 120 121 static get NAME() { 122 return NAME$1; 123 } 124 125 static get Event() { 126 return Event$1; 127 } 128 129 static get DefaultType() { 130 return DefaultType$1; 131 } // Public 132 133 134 enable() { 135 this._isEnabled = true; 136 } 137 138 disable() { 139 this._isEnabled = false; 140 } 141 142 toggleEnabled() { 143 this._isEnabled = !this._isEnabled; 144 } 145 146 toggle(event) { 147 if (!this._isEnabled) { 148 return; 149 } 150 151 if (event) { 152 const context = this._initializeOnDelegatedTarget(event); 153 154 context._activeTrigger.click = !context._activeTrigger.click; 155 156 if (context._isWithActiveTrigger()) { 157 context._enter(null, context); 158 } else { 159 context._leave(null, context); 160 } 161 } else { 162 if (this.getTipElement().classList.contains(CLASS_NAME_SHOW)) { 163 this._leave(null, this); 164 165 return; 166 } 167 168 this._enter(null, this); 169 } 170 } 171 172 dispose() { 173 clearTimeout(this._timeout); 174 EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler); 175 176 if (this.tip) { 177 this.tip.remove(); 178 } 179 180 this._disposePopper(); 181 182 super.dispose(); 183 } 184 185 show() { 186 if (this._element.style.display === 'none') { 187 throw new Error('Please use show on visible elements'); 188 } 189 190 if (!(this.isWithContent() && this._isEnabled)) { 191 return; 192 } 193 194 const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW); 195 const shadowRoot = findShadowRoot(this._element); 196 const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element); 197 198 if (showEvent.defaultPrevented || !isInTheDom) { 199 return; 200 } // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-bs-original-title` 201 // This will be removed later in favor of a `setContent` method 202 203 204 if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) { 205 this._disposePopper(); 206 207 this.tip.remove(); 208 this.tip = null; 209 } 210 211 const tip = this.getTipElement(); 212 const tipId = getUID(this.constructor.NAME); 213 tip.setAttribute('id', tipId); 214 215 this._element.setAttribute('aria-describedby', tipId); 216 217 if (this._config.animation) { 218 tip.classList.add(CLASS_NAME_FADE); 219 } 220 221 const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; 222 223 const attachment = this._getAttachment(placement); 224 225 this._addAttachmentClass(attachment); 226 227 const { 228 container 229 } = this._config; 230 Data.set(tip, this.constructor.DATA_KEY, this); 231 232 if (!this._element.ownerDocument.documentElement.contains(this.tip)) { 233 container.append(tip); 234 EventHandler.trigger(this._element, this.constructor.Event.INSERTED); 235 } 236 237 if (this._popper) { 238 this._popper.update(); 239 } else { 240 this._popper = createPopper(this._element, tip, this._getPopperConfig(attachment)); 241 } 242 243 tip.classList.add(CLASS_NAME_SHOW); 244 245 const customClass = this._resolvePossibleFunction(this._config.customClass); 246 247 if (customClass) { 248 tip.classList.add(...customClass.split(' ')); 249 } // If this is a touch-enabled device we add extra 250 // empty mouseover listeners to the body's immediate children; 251 // only needed because of broken event delegation on iOS 252 // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html 253 254 255 if ('ontouchstart' in document.documentElement) { 256 [].concat(...document.body.children).forEach(element => { 257 EventHandler.on(element, 'mouseover', noop); 258 }); 259 } 260 261 const complete = () => { 262 const prevHoverState = this._hoverState; 263 this._hoverState = null; 264 EventHandler.trigger(this._element, this.constructor.Event.SHOWN); 265 266 if (prevHoverState === HOVER_STATE_OUT) { 267 this._leave(null, this); 268 } 269 }; 270 271 const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE); 272 273 this._queueCallback(complete, this.tip, isAnimated); 274 } 275 276 hide() { 277 if (!this._popper) { 278 return; 279 } 280 281 const tip = this.getTipElement(); 282 283 const complete = () => { 284 if (this._isWithActiveTrigger()) { 285 return; 286 } 287 288 if (this._hoverState !== HOVER_STATE_SHOW) { 289 tip.remove(); 290 } 291 292 this._cleanTipClass(); 293 294 this._element.removeAttribute('aria-describedby'); 295 296 EventHandler.trigger(this._element, this.constructor.Event.HIDDEN); 297 298 this._disposePopper(); 299 }; 300 301 const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE); 302 303 if (hideEvent.defaultPrevented) { 304 return; 305 } 306 307 tip.classList.remove(CLASS_NAME_SHOW); // If this is a touch-enabled device we remove the extra 308 // empty mouseover listeners we added for iOS support 309 310 if ('ontouchstart' in document.documentElement) { 311 [].concat(...document.body.children).forEach(element => EventHandler.off(element, 'mouseover', noop)); 312 } 313 314 this._activeTrigger[TRIGGER_CLICK] = false; 315 this._activeTrigger[TRIGGER_FOCUS] = false; 316 this._activeTrigger[TRIGGER_HOVER] = false; 317 const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE); 318 319 this._queueCallback(complete, this.tip, isAnimated); 320 321 this._hoverState = ''; 322 } 323 324 update() { 325 if (this._popper !== null) { 326 this._popper.update(); 327 } 328 } // Protected 329 330 331 isWithContent() { 332 return Boolean(this.getTitle()); 333 } 334 335 getTipElement() { 336 if (this.tip) { 337 return this.tip; 338 } 339 340 const element = document.createElement('div'); 341 element.innerHTML = this._config.template; 342 const tip = element.children[0]; 343 this.setContent(tip); 344 tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW); 345 this.tip = tip; 346 return this.tip; 347 } 348 349 setContent(tip) { 350 this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER); 351 } 352 353 _sanitizeAndSetContent(template, content, selector) { 354 const templateElement = SelectorEngine.findOne(selector, template); 355 356 if (!content && templateElement) { 357 templateElement.remove(); 358 return; 359 } // we use append for html objects to maintain js events 360 361 362 this.setElementContent(templateElement, content); 363 } 364 365 setElementContent(element, content) { 366 if (element === null) { 367 return; 368 } 369 370 if (isElement(content)) { 371 content = getElement(content); // content is a DOM node or a jQuery 372 373 if (this._config.html) { 374 if (content.parentNode !== element) { 375 element.innerHTML = ''; 376 element.append(content); 377 } 378 } else { 379 element.textContent = content.textContent; 380 } 381 382 return; 383 } 384 385 if (this._config.html) { 386 if (this._config.sanitize) { 387 content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn); 388 } 389 390 element.innerHTML = content; 391 } else { 392 element.textContent = content; 393 } 394 } 395 396 getTitle() { 397 const title = this._element.getAttribute('data-bs-original-title') || this._config.title; 398 399 return this._resolvePossibleFunction(title); 400 } 401 402 updateAttachment(attachment) { 403 if (attachment === 'right') { 404 return 'end'; 405 } 406 407 if (attachment === 'left') { 408 return 'start'; 409 } 410 411 return attachment; 412 } // Private 413 414 415 _initializeOnDelegatedTarget(event, context) { 416 return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()); 417 } 418 419 _getOffset() { 420 const { 421 offset 422 } = this._config; 423 424 if (typeof offset === 'string') { 425 return offset.split(',').map(val => Number.parseInt(val, 10)); 426 } 427 428 if (typeof offset === 'function') { 429 return popperData => offset(popperData, this._element); 430 } 431 432 return offset; 433 } 434 435 _resolvePossibleFunction(content) { 436 return typeof content === 'function' ? content.call(this._element) : content; 437 } 438 439 _getPopperConfig(attachment) { 440 const defaultBsPopperConfig = { 441 placement: attachment, 442 modifiers: [{ 443 name: 'flip', 444 options: { 445 fallbackPlacements: this._config.fallbackPlacements 446 } 447 }, { 448 name: 'offset', 449 options: { 450 offset: this._getOffset() 451 } 452 }, { 453 name: 'preventOverflow', 454 options: { 455 boundary: this._config.boundary 456 } 457 }, { 458 name: 'arrow', 459 options: { 460 element: `.$this.constructor.NAME}-arrow` 461 } 462 }, { 463 name: 'onChange', 464 enabled: true, 465 phase: 'afterWrite', 466 fn: data => this._handlePopperPlacementChange(data) 467 }], 468 onFirstUpdate: data => { 469 if (data.options.placement !== data.placement) { 470 this._handlePopperPlacementChange(data); 471 } 472 } 473 }; 474 return { ...defaultBsPopperConfig, 475 ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) 476 }; 477 } 478 479 _addAttachmentClass(attachment) { 480 this.getTipElement().classList.add(`$this._getBasicClassPrefix()}-$this.updateAttachment(attachment)}`); 481 } 482 483 _getAttachment(placement) { 484 return AttachmentMap[placement.toUpperCase()]; 485 } 486 487 _setListeners() { 488 const triggers = this._config.trigger.split(' '); 489 490 triggers.forEach(trigger => { 491 if (trigger === 'click') { 492 EventHandler.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event)); 493 } else if (trigger !== TRIGGER_MANUAL) { 494 const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN; 495 const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT; 496 EventHandler.on(this._element, eventIn, this._config.selector, event => this._enter(event)); 497 EventHandler.on(this._element, eventOut, this._config.selector, event => this._leave(event)); 498 } 499 }); 500 501 this._hideModalHandler = () => { 502 if (this._element) { 503 this.hide(); 504 } 505 }; 506 507 EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler); 508 509 if (this._config.selector) { 510 this._config = { ...this._config, 511 trigger: 'manual', 512 selector: '' 513 }; 514 } else { 515 this._fixTitle(); 516 } 517 } 518 519 _fixTitle() { 520 const title = this._element.getAttribute('title'); 521 522 const originalTitleType = typeof this._element.getAttribute('data-bs-original-title'); 523 524 if (title || originalTitleType !== 'string') { 525 this._element.setAttribute('data-bs-original-title', title || ''); 526 527 if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) { 528 this._element.setAttribute('aria-label', title); 529 } 530 531 this._element.setAttribute('title', ''); 532 } 533 } 534 535 _enter(event, context) { 536 context = this._initializeOnDelegatedTarget(event, context); 537 538 if (event) { 539 context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; 540 } 541 542 if (context.getTipElement().classList.contains(CLASS_NAME_SHOW) || context._hoverState === HOVER_STATE_SHOW) { 543 context._hoverState = HOVER_STATE_SHOW; 544 return; 545 } 546 547 clearTimeout(context._timeout); 548 context._hoverState = HOVER_STATE_SHOW; 549 550 if (!context._config.delay || !context._config.delay.show) { 551 context.show(); 552 return; 553 } 554 555 context._timeout = setTimeout(() => { 556 if (context._hoverState === HOVER_STATE_SHOW) { 557 context.show(); 558 } 559 }, context._config.delay.show); 560 } 561 562 _leave(event, context) { 563 context = this._initializeOnDelegatedTarget(event, context); 564 565 if (event) { 566 context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget); 567 } 568 569 if (context._isWithActiveTrigger()) { 570 return; 571 } 572 573 clearTimeout(context._timeout); 574 context._hoverState = HOVER_STATE_OUT; 575 576 if (!context._config.delay || !context._config.delay.hide) { 577 context.hide(); 578 return; 579 } 580 581 context._timeout = setTimeout(() => { 582 if (context._hoverState === HOVER_STATE_OUT) { 583 context.hide(); 584 } 585 }, context._config.delay.hide); 586 } 587 588 _isWithActiveTrigger() { 589 for (const trigger in this._activeTrigger) { 590 if (this._activeTrigger[trigger]) { 591 return true; 592 } 593 } 594 595 return false; 596 } 597 598 _getConfig(config) { 599 const dataAttributes = Manipulator.getDataAttributes(this._element); 600 Object.keys(dataAttributes).forEach(dataAttr => { 601 if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { 602 delete dataAttributes[dataAttr]; 603 } 604 }); 605 config = { ...this.constructor.Default, 606 ...dataAttributes, 607 ...(typeof config === 'object' && config ? config : {}) 608 }; 609 config.container = config.container === false ? document.body : getElement(config.container); 610 611 if (typeof config.delay === 'number') { 612 config.delay = { 613 show: config.delay, 614 hide: config.delay 615 }; 616 } 617 618 if (typeof config.title === 'number') { 619 config.title = config.title.toString(); 620 } 621 622 if (typeof config.content === 'number') { 623 config.content = config.content.toString(); 624 } 625 626 typeCheckConfig(NAME$1, config, this.constructor.DefaultType); 627 628 if (config.sanitize) { 629 config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn); 630 } 631 632 return config; 633 } 634 635 _getDelegateConfig() { 636 const config = {}; 637 638 for (const key in this._config) { 639 if (this.constructor.Default[key] !== this._config[key]) { 640 config[key] = this._config[key]; 641 } 642 } // In the future can be replaced with: 643 // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]]) 644 // `Object.fromEntries(keysWithDifferentValues)` 645 646 647 return config; 648 } 649 650 _cleanTipClass() { 651 const tip = this.getTipElement(); 652 const basicClassPrefixRegex = new RegExp(`(^|\\s)$this._getBasicClassPrefix()}\\S+`, 'g'); 653 const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex); 654 655 if (tabClass !== null && tabClass.length > 0) { 656 tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); 657 } 658 } 659 660 _getBasicClassPrefix() { 661 return CLASS_PREFIX$1; 662 } 663 664 _handlePopperPlacementChange(popperData) { 665 const { 666 state 667 } = popperData; 668 669 if (!state) { 670 return; 671 } 672 673 this.tip = state.elements.popper; 674 675 this._cleanTipClass(); 676 677 this._addAttachmentClass(this._getAttachment(state.placement)); 678 } 679 680 _disposePopper() { 681 if (this._popper) { 682 this._popper.destroy(); 683 684 this._popper = null; 685 } 686 } // Static 687 688 689 static jQueryInterface(config) { 690 return this.each(function () { 691 const data = Tooltip.getOrCreateInstance(this, config); 692 693 if (typeof config === 'string') { 694 if (typeof data[config] === 'undefined') { 695 throw new TypeError(`No method named "$config}"`); 696 } 697 698 data[config](); 699 } 700 }); 701 } 702 703 } 704 /** 705 * ------------------------------------------------------------------------ 706 * jQuery 707 * ------------------------------------------------------------------------ 708 * add .Tooltip to jQuery only if jQuery is present 709 */ 710 711 712 defineJQueryPlugin(Tooltip); 713 714 /** 715 * -------------------------------------------------------------------------- 716 * Bootstrap (v5.1.3): popover.js 717 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 718 * -------------------------------------------------------------------------- 719 */ 720 /** 721 * ------------------------------------------------------------------------ 722 * Constants 723 * ------------------------------------------------------------------------ 724 */ 725 726 const NAME = 'popover'; 727 const DATA_KEY = 'bs.popover'; 728 const EVENT_KEY = `.$DATA_KEY}`; 729 const CLASS_PREFIX = 'bs-popover'; 730 const Default = { ...Tooltip.Default, 731 placement: 'right', 732 offset: [0, 8], 733 trigger: 'click', 734 content: '', 735 template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>' 736 }; 737 const DefaultType = { ...Tooltip.DefaultType, 738 content: '(string|element|function)' 739 }; 740 const Event = { 741 HIDE: `hide$EVENT_KEY}`, 742 HIDDEN: `hidden$EVENT_KEY}`, 743 SHOW: `show$EVENT_KEY}`, 744 SHOWN: `shown$EVENT_KEY}`, 745 INSERTED: `inserted$EVENT_KEY}`, 746 CLICK: `click$EVENT_KEY}`, 747 FOCUSIN: `focusin$EVENT_KEY}`, 748 FOCUSOUT: `focusout$EVENT_KEY}`, 749 MOUSEENTER: `mouseenter$EVENT_KEY}`, 750 MOUSELEAVE: `mouseleave$EVENT_KEY}` 751 }; 752 const SELECTOR_TITLE = '.popover-header'; 753 const SELECTOR_CONTENT = '.popover-body'; 754 /** 755 * ------------------------------------------------------------------------ 756 * Class Definition 757 * ------------------------------------------------------------------------ 758 */ 759 760 class Popover extends Tooltip { 761 // Getters 762 static get Default() { 763 return Default; 764 } 765 766 static get NAME() { 767 return NAME; 768 } 769 770 static get Event() { 771 return Event; 772 } 773 774 static get DefaultType() { 775 return DefaultType; 776 } // Overrides 777 778 779 isWithContent() { 780 return this.getTitle() || this._getContent(); 781 } 782 783 setContent(tip) { 784 this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE); 785 786 this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT); 787 } // Private 788 789 790 _getContent() { 791 return this._resolvePossibleFunction(this._config.content); 792 } 793 794 _getBasicClassPrefix() { 795 return CLASS_PREFIX; 796 } // Static 797 798 799 static jQueryInterface(config) { 800 return this.each(function () { 801 const data = Popover.getOrCreateInstance(this, config); 802 803 if (typeof config === 'string') { 804 if (typeof data[config] === 'undefined') { 805 throw new TypeError(`No method named "$config}"`); 806 } 807 808 data[config](); 809 } 810 }); 811 } 812 813 } 814 /** 815 * ------------------------------------------------------------------------ 816 * jQuery 817 * ------------------------------------------------------------------------ 818 * add .Popover to jQuery only if jQuery is present 819 */ 820 821 822 defineJQueryPlugin(Popover); 823 824 window.bootstrap = window.bootstrap || {}; 825 window.bootstrap.Popover = Popover; 826 window.bootstrap.Tooltip = Tooltip; 827 828 if (Joomla && Joomla.getOptions) { 829 // Get the elements/configurations from the PHP 830 const tooltips = Joomla.getOptions('bootstrap.tooltip'); 831 const popovers = Joomla.getOptions('bootstrap.popover'); // Initialise the elements 832 833 if (typeof popovers === 'object' && popovers !== null) { 834 Object.keys(popovers).forEach(popover => { 835 const opt = popovers[popover]; 836 const options = { 837 animation: opt.animation ? opt.animation : true, 838 container: opt.container ? opt.container : false, 839 delay: opt.delay ? opt.delay : 0, 840 html: opt.html ? opt.html : false, 841 placement: opt.placement ? opt.placement : 'top', 842 selector: opt.selector ? opt.selector : false, 843 title: opt.title ? opt.title : '', 844 trigger: opt.trigger ? opt.trigger : 'click', 845 offset: opt.offset ? opt.offset : 0, 846 fallbackPlacement: opt.fallbackPlacement ? opt.fallbackPlacement : 'flip', 847 boundary: opt.boundary ? opt.boundary : 'scrollParent', 848 customClass: opt.customClass ? opt.customClass : '', 849 sanitize: opt.sanitize ? opt.sanitize : true, 850 sanitizeFn: opt.sanitizeFn ? opt.sanitizeFn : null, 851 popperConfig: opt.popperConfig ? opt.popperConfig : null 852 }; 853 854 if (opt.content) { 855 options.content = opt.content; 856 } 857 858 if (opt.template) { 859 options.template = opt.template; 860 } 861 862 if (opt.allowList) { 863 options.allowList = opt.allowList; 864 } 865 866 const elements = Array.from(document.querySelectorAll(popover)); 867 868 if (elements.length) { 869 elements.map(el => new window.bootstrap.Popover(el, options)); 870 } 871 }); 872 } // Initialise the elements 873 874 875 if (typeof tooltips === 'object' && tooltips !== null) { 876 Object.keys(tooltips).forEach(tooltip => { 877 const opt = tooltips[tooltip]; 878 const options = { 879 animation: opt.animation ? opt.animation : true, 880 container: opt.container ? opt.container : false, 881 delay: opt.delay ? opt.delay : 0, 882 html: opt.html ? opt.html : false, 883 selector: opt.selector ? opt.selector : false, 884 trigger: opt.trigger ? opt.trigger : 'hover focus', 885 fallbackPlacement: opt.fallbackPlacement ? opt.fallbackPlacement : null, 886 boundary: opt.boundary ? opt.boundary : 'clippingParents', 887 title: opt.title ? opt.title : '', 888 customClass: opt.customClass ? opt.customClass : '', 889 sanitize: opt.sanitize ? opt.sanitize : true, 890 sanitizeFn: opt.sanitizeFn ? opt.sanitizeFn : null, 891 popperConfig: opt.popperConfig ? opt.popperConfig : null 892 }; 893 894 if (opt.placement) { 895 options.placement = opt.placement; 896 } 897 898 if (opt.template) { 899 options.template = opt.template; 900 } 901 902 if (opt.allowList) { 903 options.allowList = opt.allowList; 904 } 905 906 const elements = Array.from(document.querySelectorAll(tooltip)); 907 908 if (elements.length) { 909 elements.map(el => new window.bootstrap.Tooltip(el, options)); 910 } 911 }); 912 } 913 } 914 915 export { Popover as P };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |