| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /*! |
| 2 | - * Dialogs Manager v4.9.4 | |
| 2 | + * Dialogs Manager v4.9.0 | |
| 3 | 3 | * https://github.com/kobizz/dialogs-manager |
| 4 | 4 | * |
| 5 | 5 | * Copyright Kobi Zaltzberg |
| 6 | 6 | * Released under the MIT license |
| @@ -62,10 +62,8 @@ | ||
| 62 | 62 | |
| 63 | 63 | var self = this, |
| 64 | 64 | elements = {}, |
| 65 | 65 | settings = {}; |
| 66 | - | |
| 67 | - self.openDialogs = []; | |
| 68 | 66 | |
| 69 | 67 | var initElements = function() { |
| 70 | 68 | |
| 71 | 69 | elements.body = $('body'); |
| @@ -104,26 +102,10 @@ | ||
| 104 | 102 | |
| 105 | 103 | return Object.create(settings); |
| 106 | 104 | }; |
| 107 | 105 | |
| 108 | - this.maybeLoadAssets = async function () { | |
| 109 | - const isFrontend = !! window.elementorFrontend?.utils?.assetsLoader; | |
| 106 | + this.init = function(settings) { | |
| 110 | 107 | |
| 111 | - if ( ! isFrontend ) { | |
| 112 | - return; | |
| 113 | - } | |
| 114 | - | |
| 115 | - try { | |
| 116 | - await elementorFrontend.utils.assetsLoader.load( 'style', 'dialog' ); | |
| 117 | - } catch ( error ) { | |
| 118 | - console.error( 'Failed to load assets:', error ); | |
| 119 | - } | |
| 120 | - }; | |
| 121 | - | |
| 122 | - this.init = function (settings) { | |
| 123 | - | |
| 124 | - this.maybeLoadAssets(); | |
| 125 | - | |
| 126 | 108 | initSettings(settings); |
| 127 | 109 | |
| 128 | 110 | initElements(); |
| 129 | 111 | |
| @@ -180,9 +162,9 @@ | ||
| 180 | 162 | |
| 181 | 163 | var effect = settings.effects[intent], |
| 182 | 164 | $widget = elements.widget; |
| 183 | 165 | |
| 184 | - if ('function' === typeof effect) { | |
| 166 | + if ($.isFunction(effect)) { | |
| 185 | 167 | effect.apply($widget, params); |
| 186 | 168 | } else { |
| 187 | 169 | |
| 188 | 170 | if ($widget[effect]) { |
| @@ -353,12 +335,12 @@ | ||
| 353 | 335 | effects: parentSettings.effects, |
| 354 | 336 | classes: { |
| 355 | 337 | globalPrefix: parentSettings.classPrefix, |
| 356 | 338 | prefix: parentSettings.classPrefix + '-' + widgetName, |
| 357 | - preventScroll: parentSettings.classPrefix + '-prevent-scroll', | |
| 339 | + preventScroll: parentSettings.classPrefix + '-prevent-scroll' | |
| 358 | 340 | }, |
| 359 | 341 | selectors: { |
| 360 | - preventClose: '.' + parentSettings.classPrefix + '-prevent-close', | |
| 342 | + preventClose: '.' + parentSettings.classPrefix + '-prevent-close' | |
| 361 | 343 | }, |
| 362 | 344 | container: 'body', |
| 363 | 345 | preventScroll: false, |
| 364 | 346 | iframe: null, |
| @@ -368,9 +350,9 @@ | ||
| 368 | 350 | attributes: { |
| 369 | 351 | role: 'button', |
| 370 | 352 | 'tabindex': 0, |
| 371 | 353 | 'aria-label': 'Close', |
| 372 | - href: '#', | |
| 354 | + href: 'javascript:void(0);', | |
| 373 | 355 | }, |
| 374 | 356 | iconElement: '<i>', |
| 375 | 357 | }, |
| 376 | 358 | position: { |
| @@ -377,9 +359,9 @@ | ||
| 377 | 359 | element: 'widget', |
| 378 | 360 | my: 'center', |
| 379 | 361 | at: 'center', |
| 380 | 362 | enable: true, |
| 381 | - autoRefresh: false, | |
| 363 | + autoRefresh: false | |
| 382 | 364 | }, |
| 383 | 365 | hide: { |
| 384 | 366 | auto: false, |
| 385 | 367 | autoDelay: 5000, |
| @@ -387,9 +369,9 @@ | ||
| 387 | 369 | onOutsideClick: true, |
| 388 | 370 | onOutsideContextMenu: false, |
| 389 | 371 | onBackgroundClick: true, |
| 390 | 372 | onEscKeyPress: true, |
| 391 | - ignore: '', | |
| 373 | + ignore: '' | |
| 392 | 374 | }, |
| 393 | 375 | }; |
| 394 | 376 | |
| 395 | 377 | $.extend(true, settings, self.getDefaultSettings(), userSettings); |
| @@ -482,15 +464,9 @@ | ||
| 482 | 464 | return $newElement; |
| 483 | 465 | }; |
| 484 | 466 | |
| 485 | 467 | this.destroy = function() { |
| 486 | - const widgetId = self.getElements('widget')?.attr('id'), | |
| 487 | - index = self.parent.openDialogs.lastIndexOf(widgetId); | |
| 488 | 468 | |
| 489 | - if (index !== -1) { | |
| 490 | - self.parent.openDialogs.splice(index, 1); | |
| 491 | - } | |
| 492 | - | |
| 493 | 469 | unbindEvents(); |
| 494 | 470 | |
| 495 | 471 | elements.widget.remove(); |
| 496 | 472 | |
| @@ -520,18 +496,8 @@ | ||
| 520 | 496 | if (! self.isVisible()) { |
| 521 | 497 | return; |
| 522 | 498 | } |
| 523 | 499 | |
| 524 | - const widgetId = self.getElements('widget')?.attr('id'), | |
| 525 | - openDialogs = self.parent.openDialogs, | |
| 526 | - topDialogId = openDialogs[openDialogs.length - 1]; | |
| 527 | - | |
| 528 | - if (topDialogId !== widgetId) { | |
| 529 | - return; | |
| 530 | - } | |
| 531 | - | |
| 532 | - openDialogs.pop(); | |
| 533 | - | |
| 534 | 500 | clearTimeout(hideTimeOut); |
| 535 | 501 | |
| 536 | 502 | callEffect('hide', arguments); |
| 537 | 503 | |
| @@ -551,10 +517,8 @@ | ||
| 551 | 517 | if (!(parent instanceof DialogsManager.Instance)) { |
| 552 | 518 | throw 'The ' + self.widgetName + ' must to be initialized from an instance of DialogsManager.Instance'; |
| 553 | 519 | } |
| 554 | 520 | |
| 555 | - self.parent = parent; | |
| 556 | - | |
| 557 | 521 | ensureClosureMethods(); |
| 558 | 522 | |
| 559 | 523 | self.trigger('init', properties); |
| 560 | 524 | |
| @@ -696,12 +660,8 @@ | ||
| 696 | 660 | } |
| 697 | 661 | |
| 698 | 662 | self.trigger('show'); |
| 699 | 663 | |
| 700 | - const widgetId = self.getElements('widget')?.attr('id'); | |
| 701 | - | |
| 702 | - self.parent.openDialogs.push(widgetId); | |
| 703 | - | |
| 704 | 664 | return self; |
| 705 | 665 | }; |
| 706 | 666 | |
| 707 | 667 | this.trigger = function(eventName, params) { |
| @@ -750,10 +710,9 @@ | ||
| 750 | 710 | |
| 751 | 711 | var self = this; |
| 752 | 712 | |
| 753 | 713 | if (self.getSettings('closeButton')) { |
| 754 | - self.getElements('closeButton').on('click', function(event) { | |
| 755 | - event.preventDefault(); | |
| 714 | + self.getElements('closeButton').on('click', function() { | |
| 756 | 715 | self.hide(); |
| 757 | 716 | }); |
| 758 | 717 | } |
| 759 | 718 | }; |
| @@ -824,9 +783,9 @@ | ||
| 824 | 783 | nextButtonIndex = 0; |
| 825 | 784 | } |
| 826 | 785 | } |
| 827 | 786 | |
| 828 | - this.focusedButton = this.buttons[nextButtonIndex].trigger('focus'); | |
| 787 | + this.focusedButton = this.buttons[nextButtonIndex].focus(); | |
| 829 | 788 | } |
| 830 | 789 | }, |
| 831 | 790 | addButton: function(options) { |
| 832 | 791 | |
| @@ -847,9 +806,9 @@ | ||
| 847 | 806 | if (settings.hide.onButtonClick) { |
| 848 | 807 | self.hide(); |
| 849 | 808 | } |
| 850 | 809 | |
| 851 | - if ('function' === typeof options.callback) { | |
| 810 | + if ($.isFunction(options.callback)) { | |
| 852 | 811 | options.callback.call(this, self); |
| 853 | 812 | } |
| 854 | 813 | }; |
| 855 | 814 | |
| @@ -920,9 +879,9 @@ | ||
| 920 | 879 | this.focusedButton = this.buttons[0]; |
| 921 | 880 | } |
| 922 | 881 | |
| 923 | 882 | if (this.focusedButton) { |
| 924 | - this.focusedButton.trigger('focus'); | |
| 883 | + this.focusedButton.focus(); | |
| 925 | 884 | } |
| 926 | 885 | }, |
| 927 | 886 | unbindHotKeys: function() { |
| 928 | 887 | |