PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev4
Elementor Website Builder – more than just a page builder v3.26.0-dev4
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / assets / lib / dialog / dialog.js

dialog.js in Elementor Website Builder – more than just a page builder 3.26.0-dev4, at assets/lib/dialog/dialog.js

1,034 lines 20.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*!
2 * Dialogs Manager v4.9.3
3 * https://github.com/kobizz/dialogs-manager
4 *
5 * Copyright Kobi Zaltzberg
6 * Released under the MIT license
7 * https://github.com/kobizz/dialogs-manager/blob/master/LICENSE.txt
8 */
9
10 (function($, global) {
11 'use strict';
12
13 /*
14 * Dialog Manager
15 */
16 var DialogsManager = {
17 widgetsTypes: {},
18 createWidgetType: function(typeName, properties, Parent) {
19
20 if (!Parent) {
21 Parent = this.Widget;
22 }
23
24 var WidgetType = function() {
25
26 Parent.apply(this, arguments);
27 };
28
29 var prototype = WidgetType.prototype = new Parent(typeName);
30
31 prototype.types = prototype.types.concat([typeName]);
32
33 $.extend(prototype, properties);
34
35 prototype.constructor = WidgetType;
36
37 WidgetType.extend = function(typeName, properties) {
38
39 return DialogsManager.createWidgetType(typeName, properties, WidgetType);
40 };
41
42 return WidgetType;
43 },
44 addWidgetType: function(typeName, properties, Parent) {
45
46 if (properties && properties.prototype instanceof this.Widget) {
47 return this.widgetsTypes[typeName] = properties;
48 }
49
50 return this.widgetsTypes[typeName] = this.createWidgetType(typeName, properties, Parent);
51 },
52 getWidgetType: function(widgetType) {
53
54 return this.widgetsTypes[widgetType];
55 }
56 };
57
58 /*
59 * Dialog Manager instances constructor
60 */
61 DialogsManager.Instance = function() {
62
63 var self = this,
64 elements = {},
65 settings = {};
66
67 var initElements = function() {
68
69 elements.body = $('body');
70 };
71
72 var initSettings = function(options) {
73
74 var defaultSettings = {
75 classPrefix: 'dialog',
76 effects: {
77 show: 'fadeIn',
78 hide: 'fadeOut'
79 }
80 };
81
82 $.extend(settings, defaultSettings, options);
83 };
84
85 this.createWidget = function(widgetType, properties) {
86
87 var WidgetTypeConstructor = DialogsManager.getWidgetType(widgetType),
88 widget = new WidgetTypeConstructor(widgetType);
89
90 properties = properties || {};
91
92 widget.init(self, properties);
93
94 return widget;
95 };
96
97 this.getSettings = function(property) {
98
99 if (property) {
100 return settings[property];
101 }
102
103 return Object.create(settings);
104 };
105
106 this.maybeLoadAssets = async function () {
107 const isFrontend = !! window.elementorFrontend?.utils?.assetsLoader;
108
109 if ( ! isFrontend ) {
110 return;
111 }
112
113 try {
114 await elementorFrontend.utils.assetsLoader.load( 'style', 'dialog' );
115 } catch ( error ) {
116 console.error( 'Failed to load assets:', error );
117 }
118 };
119
120 this.init = function (settings) {
121
122 this.maybeLoadAssets();
123
124 initSettings(settings);
125
126 initElements();
127
128 return self;
129 };
130
131 self.init();
132 };
133
134 /*
135 * Widget types constructor
136 */
137 DialogsManager.Widget = function(widgetName) {
138
139 var self = this,
140 settings = {},
141 events = {},
142 elements = {},
143 hideTimeOut = 0,
144 baseClosureMethods = ['refreshPosition'];
145
146 var bindEvents = function() {
147
148 var windows = [elements.window];
149
150 if (elements.iframe) {
151 windows.push(jQuery(elements.iframe[0].contentWindow));
152 }
153
154 windows.forEach(function(window) {
155 if (settings.hide.onEscKeyPress) {
156 window.on('keyup', onWindowKeyUp);
157 }
158
159 if (settings.hide.onOutsideClick) {
160 window[0].addEventListener('click', hideOnOutsideClick, true);
161 }
162
163 if (settings.hide.onOutsideContextMenu) {
164 window[0].addEventListener('contextmenu', hideOnOutsideClick, true);
165 }
166
167 if (settings.position.autoRefresh) {
168 window.on('resize', self.refreshPosition);
169 }
170 });
171
172 if (settings.hide.onClick || settings.hide.onBackgroundClick) {
173 elements.widget.on('click', hideOnClick);
174 }
175 };
176
177 var callEffect = function(intent, params) {
178
179 var effect = settings.effects[intent],
180 $widget = elements.widget;
181
182 if ('function' === typeof effect) {
183 effect.apply($widget, params);
184 } else {
185
186 if ($widget[effect]) {
187 $widget[effect].apply($widget, params);
188 } else {
189 throw 'Reference Error: The effect ' + effect + ' not found';
190 }
191 }
192 };
193
194 var ensureClosureMethods = function() {
195
196 var closureMethodsNames = baseClosureMethods.concat(self.getClosureMethods());
197
198 $.each(closureMethodsNames, function() {
199
200 var methodName = this,
201 oldMethod = self[methodName];
202
203 self[methodName] = function() {
204
205 oldMethod.apply(self, arguments);
206 };
207 });
208 };
209
210 var fixIframePosition = function(position) {
211 if (! position.my) {
212 return;
213 }
214
215 var horizontalOffsetRegex = /left|right/,
216 extraOffsetRegex = /([+-]\d+)?$/,
217 iframeOffset = elements.iframe.offset(),
218 iframeWindow = elements.iframe[0].contentWindow,
219 myParts = position.my.split(' '),
220 fixedParts = [];
221
222 if (myParts.length === 1) {
223 if (horizontalOffsetRegex.test(myParts[0])) {
224 myParts.push('center');
225 } else {
226 myParts.unshift('center');
227 }
228 }
229
230 myParts.forEach(function(part, index) {
231 var fixedPart = part.replace(extraOffsetRegex, function(partOffset) {
232 partOffset = +partOffset || 0;
233
234 if (! index) {
235 partOffset += iframeOffset.left - iframeWindow.scrollX;
236 } else {
237 partOffset += iframeOffset.top - iframeWindow.scrollY;
238 }
239
240 if (partOffset >= 0) {
241 partOffset = '+' + partOffset;
242 }
243
244 return partOffset;
245 });
246
247 fixedParts.push(fixedPart);
248 });
249
250 position.my = fixedParts.join(' ');
251 };
252
253 var hideOnClick = function(event) {
254
255 if (isContextMenuClickEvent(event)) {
256 return;
257 }
258
259 if (settings.hide.onClick) {
260
261 if ($(event.target).closest(settings.selectors.preventClose).length) {
262 return;
263 }
264 } else if (event.target !== this) {
265 return;
266 }
267
268 self.hide();
269 };
270
271 var isIgnoredTarget = function(event) {
272
273 if (! settings.hide.ignore) {
274 return false;
275 }
276
277 return !! $(event.target).closest(settings.hide.ignore).length;
278 };
279
280 var hideOnOutsideClick = function(event) {
281
282 if (isContextMenuClickEvent(event) || $(event.target).closest(elements.widget).length || isIgnoredTarget(event)) {
283 return;
284 }
285
286 self.hide();
287 };
288
289 var initElements = function() {
290
291 self.addElement('widget');
292
293 self.addElement('header');
294
295 self.addElement('message');
296
297 self.addElement('window', window);
298
299 self.addElement('body', document.body);
300
301 self.addElement('container', settings.container);
302
303 if (settings.iframe) {
304 self.addElement('iframe', settings.iframe);
305 }
306
307 if (settings.closeButton) {
308 if ( settings.closeButtonClass ) {
309 // Backwards compatibility
310 settings.closeButtonOptions.iconClass = settings.closeButtonClass;
311 }
312
313 const $button = $('<a>', settings.closeButtonOptions.attributes),
314 $buttonIcon = $(settings.closeButtonOptions.iconElement).addClass(settings.closeButtonOptions.iconClass);
315
316 $button.append($buttonIcon);
317
318 self.addElement('closeButton', $button);
319 }
320
321 var id = self.getSettings('id');
322
323 if (id) {
324 self.setID(id);
325 }
326
327 var classes = [];
328
329 $.each(self.types, function() {
330 classes.push(settings.classes.globalPrefix + '-type-' + this);
331 });
332
333 classes.push(self.getSettings('className'));
334
335 elements.widget
336 .addClass(classes.join(' '))
337 .attr({
338 'aria-modal': true,
339 'role': 'document',
340 'tabindex': 0,
341 });
342 };
343
344 var initSettings = function(parent, userSettings) {
345
346 var parentSettings = $.extend(true, {}, parent.getSettings());
347
348 settings = {
349 headerMessage: '',
350 message: '',
351 effects: parentSettings.effects,
352 classes: {
353 globalPrefix: parentSettings.classPrefix,
354 prefix: parentSettings.classPrefix + '-' + widgetName,
355 preventScroll: parentSettings.classPrefix + '-prevent-scroll',
356 },
357 selectors: {
358 preventClose: '.' + parentSettings.classPrefix + '-prevent-close',
359 },
360 container: 'body',
361 preventScroll: false,
362 iframe: null,
363 closeButton: false,
364 closeButtonOptions: {
365 iconClass: parentSettings.classPrefix + '-close-button-icon',
366 attributes: {
367 role: 'button',
368 'tabindex': 0,
369 'aria-label': 'Close',
370 href: '#',
371 },
372 iconElement: '<i>',
373 },
374 position: {
375 element: 'widget',
376 my: 'center',
377 at: 'center',
378 enable: true,
379 autoRefresh: false,
380 },
381 hide: {
382 auto: false,
383 autoDelay: 5000,
384 onClick: false,
385 onOutsideClick: true,
386 onOutsideContextMenu: false,
387 onBackgroundClick: true,
388 onEscKeyPress: true,
389 ignore: '',
390 },
391 };
392
393 $.extend(true, settings, self.getDefaultSettings(), userSettings);
394
395 initSettingsEvents();
396 };
397
398 var initSettingsEvents = function() {
399
400 $.each(settings, function(settingKey) {
401
402 var eventName = settingKey.match(/^on([A-Z].*)/);
403
404 if (!eventName) {
405 return;
406 }
407
408 eventName = eventName[1].charAt(0).toLowerCase() + eventName[1].slice(1);
409
410 self.on(eventName, this);
411 });
412 };
413
414 var isContextMenuClickEvent = function(event) {
415 // Firefox fires `click` event on every `contextmenu` event.
416 return event.type === 'click' && event.button === 2;
417 };
418
419 var normalizeClassName = function(name) {
420
421 return name.replace(/([a-z])([A-Z])/g, function() {
422
423 return arguments[1] + '-' + arguments[2].toLowerCase();
424 });
425 };
426
427 var onWindowKeyUp = function(event) {
428 var ESC_KEY = 27,
429 keyCode = event.which;
430
431 if (ESC_KEY === keyCode) {
432 self.hide();
433 }
434 };
435
436 var unbindEvents = function() {
437
438 var windows = [elements.window];
439
440 if (elements.iframe) {
441 windows.push(jQuery(elements.iframe[0].contentWindow));
442 }
443
444 windows.forEach(function(window) {
445 if (settings.hide.onEscKeyPress) {
446 window.off('keyup', onWindowKeyUp);
447 }
448
449 if (settings.hide.onOutsideClick) {
450 window[0].removeEventListener('click', hideOnOutsideClick, true);
451 }
452
453 if (settings.hide.onOutsideContextMenu) {
454 window[0].removeEventListener('contextmenu', hideOnOutsideClick, true);
455 }
456
457 if (settings.position.autoRefresh) {
458 window.off('resize', self.refreshPosition);
459 }
460 });
461
462 if (settings.hide.onClick || settings.hide.onBackgroundClick) {
463 elements.widget.off('click', hideOnClick);
464 }
465 };
466
467 this.addElement = function(name, element, classes) {
468
469 var $newElement = elements[name] = $(element || '<div>'),
470 normalizedName = normalizeClassName(name);
471
472 classes = classes ? classes + ' ' : '';
473
474 classes += settings.classes.globalPrefix + '-' + normalizedName;
475
476 classes += ' ' + settings.classes.prefix + '-' + normalizedName;
477
478 $newElement.addClass(classes);
479
480 return $newElement;
481 };
482
483 this.destroy = function() {
484
485 unbindEvents();
486
487 elements.widget.remove();
488
489 self.trigger('destroy');
490
491 return self;
492 };
493
494 this.getElements = function(item) {
495
496 return item ? elements[item] : elements;
497 };
498
499 this.getSettings = function(setting) {
500
501 var copy = Object.create(settings);
502
503 if (setting) {
504 return copy[setting];
505 }
506
507 return copy;
508 };
509
510 this.hide = function() {
511
512 if (! self.isVisible()) {
513 return;
514 }
515
516 clearTimeout(hideTimeOut);
517
518 callEffect('hide', arguments);
519
520 unbindEvents();
521
522 if (settings.preventScroll) {
523 self.getElements('body').removeClass(settings.classes.preventScroll);
524 }
525
526 self.trigger('hide');
527
528 return self;
529 };
530
531 this.init = function(parent, properties) {
532
533 if (!(parent instanceof DialogsManager.Instance)) {
534 throw 'The ' + self.widgetName + ' must to be initialized from an instance of DialogsManager.Instance';
535 }
536
537 ensureClosureMethods();
538
539 self.trigger('init', properties);
540
541 initSettings(parent, properties);
542
543 initElements();
544
545 self.buildWidget();
546
547 self.attachEvents();
548
549 self.trigger('ready');
550
551 return self;
552 };
553
554 this.isVisible = function() {
555
556 return elements.widget.is(':visible');
557 };
558
559 this.on = function(eventName, callback) {
560
561 if ('object' === typeof eventName) {
562 $.each(eventName, function(singleEventName) {
563 self.on(singleEventName, this);
564 });
565
566 return self;
567 }
568
569 var eventNames = eventName.split(' ');
570
571 eventNames.forEach(function(singleEventName) {
572 if (!events[singleEventName]) {
573 events[singleEventName] = [];
574 }
575
576 events[singleEventName].push(callback);
577 });
578
579 return self;
580 };
581
582 this.off = function(eventName, callback) {
583
584 if (! events[ eventName ]) {
585 return self;
586 }
587
588 if (! callback) {
589 delete events[eventName];
590
591 return self;
592 }
593
594 var callbackIndex = events[eventName].indexOf(callback);
595
596 if (-1 !== callbackIndex) {
597 events[eventName].splice(callbackIndex, 1);
598 }
599
600 return self;
601 };
602
603 this.refreshPosition = function() {
604
605 if (! settings.position.enable) {
606 return;
607 }
608
609 var position = $.extend({}, settings.position);
610
611 if (elements[position.of]) {
612 position.of = elements[position.of];
613 }
614
615 if (! position.of) {
616 position.of = window;
617 }
618
619 if (settings.iframe) {
620 fixIframePosition(position);
621 }
622
623 elements[position.element].position(position);
624 };
625
626 this.setID = function(id) {
627
628 elements.widget.attr('id', id);
629
630 return self;
631 };
632
633 this.setHeaderMessage = function(message) {
634
635 self.getElements('header').html(message);
636
637 return self;
638 };
639
640 this.setMessage = function(message) {
641
642 elements.message.html(message);
643
644 return self;
645 };
646
647 this.setSettings = function(key, value) {
648
649 if (jQuery.isPlainObject(value)) {
650 $.extend(true, settings[key], value);
651 } else {
652 settings[key] = value;
653 }
654
655 return self;
656 };
657
658 this.show = function() {
659
660 clearTimeout(hideTimeOut);
661
662 elements.widget.appendTo(elements.container).hide();
663
664 callEffect('show', arguments);
665
666 self.refreshPosition();
667
668 if (settings.hide.auto) {
669 hideTimeOut = setTimeout(self.hide, settings.hide.autoDelay);
670 }
671
672 bindEvents();
673
674 if (settings.preventScroll) {
675 self.getElements('body').addClass(settings.classes.preventScroll);
676 }
677
678 self.trigger('show');
679
680 return self;
681 };
682
683 this.trigger = function(eventName, params) {
684
685 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1);
686
687 if (self[methodName]) {
688 self[methodName](params);
689 }
690
691 var callbacks = events[eventName];
692
693 if (!callbacks) {
694 return;
695 }
696
697 $.each(callbacks, function(index, callback) {
698
699 callback.call(self, params);
700 });
701
702 return self;
703 };
704 };
705
706 DialogsManager.Widget.prototype.types = [];
707
708 // Inheritable widget methods
709 DialogsManager.Widget.prototype.buildWidget = function() {
710
711 var elements = this.getElements(),
712 settings = this.getSettings();
713
714 elements.widget.append(elements.header, elements.message);
715
716 this.setHeaderMessage(settings.headerMessage);
717
718 this.setMessage(settings.message);
719
720 if (this.getSettings('closeButton')) {
721 elements.widget.prepend(elements.closeButton);
722 }
723 };
724
725 DialogsManager.Widget.prototype.attachEvents = function() {
726
727 var self = this;
728
729 if (self.getSettings('closeButton')) {
730 self.getElements('closeButton').on('click', function(event) {
731 event.preventDefault();
732 self.hide();
733 });
734 }
735 };
736
737 DialogsManager.Widget.prototype.getDefaultSettings = function() {
738
739 return {};
740 };
741
742 DialogsManager.Widget.prototype.getClosureMethods = function() {
743
744 return [];
745 };
746
747 DialogsManager.Widget.prototype.onHide = function() {
748 };
749
750 DialogsManager.Widget.prototype.onShow = function() {
751 };
752
753 DialogsManager.Widget.prototype.onInit = function() {
754 };
755
756 DialogsManager.Widget.prototype.onReady = function() {
757 };
758
759 DialogsManager.widgetsTypes.simple = DialogsManager.Widget;
760
761 DialogsManager.addWidgetType('buttons', {
762 activeKeyUp: function(event) {
763
764 var TAB_KEY = 9;
765
766 if (event.which === TAB_KEY) {
767 event.preventDefault();
768 }
769
770 if (this.hotKeys[event.which]) {
771 this.hotKeys[event.which](this);
772 }
773 },
774 activeKeyDown: function(event) {
775
776 if (!this.focusedButton) {
777 return;
778 }
779
780 var TAB_KEY = 9;
781
782 if (event.which === TAB_KEY) {
783 event.preventDefault();
784
785 var currentButtonIndex = this.focusedButton.index(),
786 nextButtonIndex;
787
788 if (event.shiftKey) {
789
790 nextButtonIndex = currentButtonIndex - 1;
791
792 if (nextButtonIndex < 0) {
793 nextButtonIndex = this.buttons.length - 1;
794 }
795 } else {
796
797 nextButtonIndex = currentButtonIndex + 1;
798
799 if (nextButtonIndex >= this.buttons.length) {
800 nextButtonIndex = 0;
801 }
802 }
803
804 this.focusedButton = this.buttons[nextButtonIndex].trigger('focus');
805 }
806 },
807 addButton: function(options) {
808
809 var self = this,
810 settings = self.getSettings(),
811 buttonSettings = jQuery.extend(settings.button, options);
812
813 var classes = options.classes ? options.classes + ' ' : '';
814
815 classes += settings.classes.globalPrefix + '-button';
816
817 var $button = self.addElement(options.name, $('<' + buttonSettings.tag + '>').html(options.text), classes);
818
819 self.buttons.push($button);
820
821 var buttonFn = function() {
822
823 if (settings.hide.onButtonClick) {
824 self.hide();
825 }
826
827 if ('function' === typeof options.callback) {
828 options.callback.call(this, self);
829 }
830 };
831
832 $button.on('click', buttonFn);
833
834 if (options.hotKey) {
835 this.hotKeys[options.hotKey] = buttonFn;
836 }
837
838 this.getElements('buttonsWrapper').append($button);
839
840 if (options.focus) {
841 this.focusedButton = $button;
842 }
843
844 return self;
845 },
846 bindHotKeys: function() {
847
848 this.getElements('window').on({
849 keyup: this.activeKeyUp,
850 keydown: this.activeKeyDown
851 });
852 },
853 buildWidget: function() {
854
855 DialogsManager.Widget.prototype.buildWidget.apply(this, arguments);
856
857 var $buttonsWrapper = this.addElement('buttonsWrapper');
858
859 this.getElements('widget').append($buttonsWrapper);
860 },
861 getClosureMethods: function() {
862
863 return [
864 'activeKeyUp',
865 'activeKeyDown'
866 ];
867 },
868 getDefaultSettings: function() {
869
870 return {
871 hide: {
872 onButtonClick: true
873 },
874 button: {
875 tag: 'button'
876 }
877 };
878 },
879 onHide: function() {
880
881 this.unbindHotKeys();
882 },
883 onInit: function() {
884
885 this.buttons = [];
886
887 this.hotKeys = {};
888
889 this.focusedButton = null;
890 },
891 onShow: function() {
892
893 this.bindHotKeys();
894
895 if (!this.focusedButton) {
896 this.focusedButton = this.buttons[0];
897 }
898
899 if (this.focusedButton) {
900 this.focusedButton.trigger('focus');
901 }
902 },
903 unbindHotKeys: function() {
904
905 this.getElements('window').off({
906 keyup: this.activeKeyUp,
907 keydown: this.activeKeyDown
908 });
909 }
910 });
911
912 DialogsManager.addWidgetType('lightbox', DialogsManager.getWidgetType('buttons').extend('lightbox', {
913 getDefaultSettings: function() {
914
915 var settings = DialogsManager.getWidgetType('buttons').prototype.getDefaultSettings.apply(this, arguments);
916
917 return $.extend(true, settings, {
918 contentWidth: 'auto',
919 contentHeight: 'auto',
920 position: {
921 element: 'widgetContent',
922 of: 'widget',
923 autoRefresh: true
924 }
925 });
926 },
927 buildWidget: function() {
928
929 DialogsManager.getWidgetType('buttons').prototype.buildWidget.apply(this, arguments);
930
931 var $widgetContent = this.addElement('widgetContent'),
932 elements = this.getElements();
933
934 $widgetContent.append(elements.header, elements.message, elements.buttonsWrapper);
935
936 elements.widget.html($widgetContent);
937
938 if (elements.closeButton) {
939 $widgetContent.prepend(elements.closeButton);
940 }
941 },
942 onReady: function() {
943
944 var elements = this.getElements(),
945 settings = this.getSettings();
946
947 if ('auto' !== settings.contentWidth) {
948 elements.message.width(settings.contentWidth);
949 }
950
951 if ('auto' !== settings.contentHeight) {
952 elements.message.height(settings.contentHeight);
953 }
954 }
955 }));
956
957 DialogsManager.addWidgetType('confirm', DialogsManager.getWidgetType('lightbox').extend('confirm', {
958 onReady: function() {
959
960 DialogsManager.getWidgetType('lightbox').prototype.onReady.apply(this, arguments);
961
962 var strings = this.getSettings('strings'),
963 isDefaultCancel = this.getSettings('defaultOption') === 'cancel';
964
965 this.addButton({
966 name: 'cancel',
967 text: strings.cancel,
968 callback: function(widget) {
969
970 widget.trigger('cancel');
971 },
972 focus: isDefaultCancel
973 });
974
975 this.addButton({
976 name: 'ok',
977 text: strings.confirm,
978 callback: function(widget) {
979
980 widget.trigger('confirm');
981 },
982 focus: !isDefaultCancel
983 });
984 },
985 getDefaultSettings: function() {
986
987 var settings = DialogsManager.getWidgetType('lightbox').prototype.getDefaultSettings.apply(this, arguments);
988
989 settings.strings = {
990 confirm: 'OK',
991 cancel: 'Cancel'
992 };
993
994 settings.defaultOption = 'cancel';
995
996 return settings;
997 }
998 }));
999
1000 DialogsManager.addWidgetType('alert', DialogsManager.getWidgetType('lightbox').extend('alert', {
1001 onReady: function() {
1002
1003 DialogsManager.getWidgetType('lightbox').prototype.onReady.apply(this, arguments);
1004
1005 var strings = this.getSettings('strings');
1006
1007 this.addButton({
1008 name: 'ok',
1009 text: strings.confirm,
1010 callback: function(widget) {
1011
1012 widget.trigger('confirm');
1013 }
1014 });
1015 },
1016 getDefaultSettings: function() {
1017
1018 var settings = DialogsManager.getWidgetType('lightbox').prototype.getDefaultSettings.apply(this, arguments);
1019
1020 settings.strings = {
1021 confirm: 'OK'
1022 };
1023
1024 return settings;
1025 }
1026 }));
1027
1028 // Exporting the DialogsManager variable to global
1029 global.DialogsManager = DialogsManager;
1030 })(
1031 typeof jQuery !== 'undefined' ? jQuery : typeof require === 'function' && require('jquery'),
1032 (typeof module !== 'undefined' && typeof module.exports !== 'undefined') ? module.exports : window
1033 );
1034