| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /*! |
| 2 | - * Dialogs Manager v4.9.4 | |
| 2 | + * Dialogs Manager v4.8.1 | |
| 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]) { |
| @@ -311,10 +293,10 @@ | ||
| 311 | 293 | // Backwards compatibility |
| 312 | 294 | settings.closeButtonOptions.iconClass = settings.closeButtonClass; |
| 313 | 295 | } |
| 314 | 296 | |
| 315 | - const $button = $('<a>', settings.closeButtonOptions.attributes), | |
| 316 | - $buttonIcon = $(settings.closeButtonOptions.iconElement).addClass(settings.closeButtonOptions.iconClass); | |
| 297 | + const $button = $('<div>', settings.closeButtonOptions.attributes), | |
| 298 | + $buttonIcon = $('<i>', {class: settings.closeButtonOptions.iconClass}); | |
| 317 | 299 | |
| 318 | 300 | $button.append($buttonIcon); |
| 319 | 301 | |
| 320 | 302 | self.addElement('closeButton', $button); |
| @@ -333,15 +315,9 @@ | ||
| 333 | 315 | }); |
| 334 | 316 | |
| 335 | 317 | classes.push(self.getSettings('className')); |
| 336 | 318 | |
| 337 | - elements.widget | |
| 338 | - .addClass(classes.join(' ')) | |
| 339 | - .attr({ | |
| 340 | - 'aria-modal': true, | |
| 341 | - 'role': 'document', | |
| 342 | - 'tabindex': 0, | |
| 343 | - }); | |
| 319 | + elements.widget.addClass(classes.join(' ')); | |
| 344 | 320 | }; |
| 345 | 321 | |
| 346 | 322 | var initSettings = function(parent, userSettings) { |
| 347 | 323 | |
| @@ -353,12 +329,12 @@ | ||
| 353 | 329 | effects: parentSettings.effects, |
| 354 | 330 | classes: { |
| 355 | 331 | globalPrefix: parentSettings.classPrefix, |
| 356 | 332 | prefix: parentSettings.classPrefix + '-' + widgetName, |
| 357 | - preventScroll: parentSettings.classPrefix + '-prevent-scroll', | |
| 333 | + preventScroll: parentSettings.classPrefix + '-prevent-scroll' | |
| 358 | 334 | }, |
| 359 | 335 | selectors: { |
| 360 | - preventClose: '.' + parentSettings.classPrefix + '-prevent-close', | |
| 336 | + preventClose: '.' + parentSettings.classPrefix + '-prevent-close' | |
| 361 | 337 | }, |
| 362 | 338 | container: 'body', |
| 363 | 339 | preventScroll: false, |
| 364 | 340 | iframe: null, |
| @@ -364,15 +340,9 @@ | ||
| 364 | 340 | iframe: null, |
| 365 | 341 | closeButton: false, |
| 366 | 342 | closeButtonOptions: { |
| 367 | 343 | iconClass: parentSettings.classPrefix + '-close-button-icon', |
| 368 | - attributes: { | |
| 369 | - role: 'button', | |
| 370 | - 'tabindex': 0, | |
| 371 | - 'aria-label': 'Close', | |
| 372 | - href: '#', | |
| 373 | - }, | |
| 374 | - iconElement: '<i>', | |
| 344 | + attributes: {}, | |
| 375 | 345 | }, |
| 376 | 346 | position: { |
| 377 | 347 | element: 'widget', |
| 378 | 348 | my: 'center', |
| @@ -377,9 +347,9 @@ | ||
| 377 | 347 | element: 'widget', |
| 378 | 348 | my: 'center', |
| 379 | 349 | at: 'center', |
| 380 | 350 | enable: true, |
| 381 | - autoRefresh: false, | |
| 351 | + autoRefresh: false | |
| 382 | 352 | }, |
| 383 | 353 | hide: { |
| 384 | 354 | auto: false, |
| 385 | 355 | autoDelay: 5000, |
| @@ -387,10 +357,10 @@ | ||
| 387 | 357 | onOutsideClick: true, |
| 388 | 358 | onOutsideContextMenu: false, |
| 389 | 359 | onBackgroundClick: true, |
| 390 | 360 | onEscKeyPress: true, |
| 391 | - ignore: '', | |
| 392 | - }, | |
| 361 | + ignore: '' | |
| 362 | + } | |
| 393 | 363 | }; |
| 394 | 364 | |
| 395 | 365 | $.extend(true, settings, self.getDefaultSettings(), userSettings); |
| 396 | 366 | |
| @@ -482,15 +452,9 @@ | ||
| 482 | 452 | return $newElement; |
| 483 | 453 | }; |
| 484 | 454 | |
| 485 | 455 | this.destroy = function() { |
| 486 | - const widgetId = self.getElements('widget')?.attr('id'), | |
| 487 | - index = self.parent.openDialogs.lastIndexOf(widgetId); | |
| 488 | 456 | |
| 489 | - if (index !== -1) { | |
| 490 | - self.parent.openDialogs.splice(index, 1); | |
| 491 | - } | |
| 492 | - | |
| 493 | 457 | unbindEvents(); |
| 494 | 458 | |
| 495 | 459 | elements.widget.remove(); |
| 496 | 460 | |
| @@ -520,18 +484,8 @@ | ||
| 520 | 484 | if (! self.isVisible()) { |
| 521 | 485 | return; |
| 522 | 486 | } |
| 523 | 487 | |
| 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 | 488 | clearTimeout(hideTimeOut); |
| 535 | 489 | |
| 536 | 490 | callEffect('hide', arguments); |
| 537 | 491 | |
| @@ -551,10 +505,8 @@ | ||
| 551 | 505 | if (!(parent instanceof DialogsManager.Instance)) { |
| 552 | 506 | throw 'The ' + self.widgetName + ' must to be initialized from an instance of DialogsManager.Instance'; |
| 553 | 507 | } |
| 554 | 508 | |
| 555 | - self.parent = parent; | |
| 556 | - | |
| 557 | 509 | ensureClosureMethods(); |
| 558 | 510 | |
| 559 | 511 | self.trigger('init', properties); |
| 560 | 512 | |
| @@ -696,12 +648,8 @@ | ||
| 696 | 648 | } |
| 697 | 649 | |
| 698 | 650 | self.trigger('show'); |
| 699 | 651 | |
| 700 | - const widgetId = self.getElements('widget')?.attr('id'); | |
| 701 | - | |
| 702 | - self.parent.openDialogs.push(widgetId); | |
| 703 | - | |
| 704 | 652 | return self; |
| 705 | 653 | }; |
| 706 | 654 | |
| 707 | 655 | this.trigger = function(eventName, params) { |
| @@ -750,10 +698,9 @@ | ||
| 750 | 698 | |
| 751 | 699 | var self = this; |
| 752 | 700 | |
| 753 | 701 | if (self.getSettings('closeButton')) { |
| 754 | - self.getElements('closeButton').on('click', function(event) { | |
| 755 | - event.preventDefault(); | |
| 702 | + self.getElements('closeButton').on('click', function() { | |
| 756 | 703 | self.hide(); |
| 757 | 704 | }); |
| 758 | 705 | } |
| 759 | 706 | }; |
| @@ -824,9 +771,9 @@ | ||
| 824 | 771 | nextButtonIndex = 0; |
| 825 | 772 | } |
| 826 | 773 | } |
| 827 | 774 | |
| 828 | - this.focusedButton = this.buttons[nextButtonIndex].trigger('focus'); | |
| 775 | + this.focusedButton = this.buttons[nextButtonIndex].focus(); | |
| 829 | 776 | } |
| 830 | 777 | }, |
| 831 | 778 | addButton: function(options) { |
| 832 | 779 | |
| @@ -847,9 +794,9 @@ | ||
| 847 | 794 | if (settings.hide.onButtonClick) { |
| 848 | 795 | self.hide(); |
| 849 | 796 | } |
| 850 | 797 | |
| 851 | - if ('function' === typeof options.callback) { | |
| 798 | + if ($.isFunction(options.callback)) { | |
| 852 | 799 | options.callback.call(this, self); |
| 853 | 800 | } |
| 854 | 801 | }; |
| 855 | 802 | |
| @@ -920,9 +867,9 @@ | ||
| 920 | 867 | this.focusedButton = this.buttons[0]; |
| 921 | 868 | } |
| 922 | 869 | |
| 923 | 870 | if (this.focusedButton) { |
| 924 | - this.focusedButton.trigger('focus'); | |
| 871 | + this.focusedButton.focus(); | |
| 925 | 872 | } |
| 926 | 873 | }, |
| 927 | 874 | unbindHotKeys: function() { |
| 928 | 875 | |
| @@ -1052,6 +999,6 @@ | ||
| 1052 | 999 | // Exporting the DialogsManager variable to global |
| 1053 | 1000 | global.DialogsManager = DialogsManager; |
| 1054 | 1001 | })( |
| 1055 | 1002 | typeof jQuery !== 'undefined' ? jQuery : typeof require === 'function' && require('jquery'), |
| 1056 | - (typeof module !== 'undefined' && typeof module.exports !== 'undefined') ? module.exports : window | |
| 1003 | + typeof module !== 'undefined' ? module.exports : window | |
| 1057 | 1004 | ); |