PageSourceSearch

https://dstore.global/client/v1/public/bootstrap/js/bootstrap-dialog.js?v=1.0.01

js dstore.global collected 2026-09-25 11:24:27 UTC 34,716 bytes, 1,035 lines download raw bytes

1/* global define */
2
3/* ================================================
4 * Make use of Bootstrap's modal more monkey-friendly.
5 * 
6 * For Bootstrap 3.
7 * 
8 * [email protected]
9 * 
10 * https://github.com/nakupanda/bootstrap3-dialog
11 * 
12 * Licensed under The MIT License.
13 * ================================================ */
14(function(root, factory) {
15
16    "use strict";
17
18    // CommonJS module is defined
19    if (typeof module !== 'undefined' && module.exports) {
20        module.exports = factory(require('jquery')(root));
21    }
22    // AMD module is defined
23    else if (typeof define === "function" && define.amd) {
24        define("bootstrap-dialog", ["jquery"], function($) {
25            return factory($);
26        });
27    } else {
28        // planted over the root!
29        root.BootstrapDialog = factory(root.jQuery);
30    }
31
32}(this, function($) {
33
34    "use strict";
35
36    var BootstrapDialog = function(options) {
37        this.defaultOptions = $.extend(true, {
38            id: BootstrapDialog.newGuid(),
39            buttons: [],
40            data: {},
41            onshow: null,
42            onshown: null,
43            onhide: null,
44            onhidden: null
45        }, BootstrapDialog.defaultOptions);
46        this.indexedButtons = {};
47        this.registeredButtonHotkeys = {};
48        this.draggableData = {
49            isMouseDown: false,
50            mouseOffset: {}
51        };
52        this.realized = false;
53        this.opened = false;
54        this.initOptions(options);
55        this.holdThisInstance();
56    };
57
58    /**
59     *  Some constants.
60     */
61    BootstrapDialog.NAMESPACE = 'bootstrap-dialog';
62
63    BootstrapDialog.TYPE_DEFAULT = 'type-default';
64    BootstrapDialog.TYPE_INFO = 'type-info';
65    BootstrapDialog.TYPE_PRIMARY = 'type-primary';
66    BootstrapDialog.TYPE_SUCCESS = 'type-success';
67    BootstrapDialog.TYPE_WARNING = 'type-warning';
68    BootstrapDialog.TYPE_DANGER = 'type-danger';
69
70    BootstrapDialog.DEFAULT_TEXTS = {};
71    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = 'Information';
72    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO] = 'Information';
73    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY] = 'Information';
74    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS] = 'Success';
75    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING] = 'Warning';
76    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER] = 'Danger';
77
78    BootstrapDialog.SIZE_NORMAL = 'size-normal';
79    BootstrapDialog.SIZE_LARGE = 'size-large';
80
81    BootstrapDialog.BUTTON_SIZES = {};
82    BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = '';
83    BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE] = 'btn-lg';
84
85    BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk';
86
87    BootstrapDialog.ZINDEX_BACKDROP = 1040;
88    BootstrapDialog.ZINDEX_MODAL = 1050;
89
90    /**
91     * Default options.
92     */
93    BootstrapDialog.defaultOptions = {
94        type: BootstrapDialog.TYPE_PRIMARY,
95        size: BootstrapDialog.SIZE_NORMAL,
96        cssClass: '',
97        title: null,
98        message: null,
99        nl2br: true,
100        closable: true,
101        closeByBackdrop: true,
102        closeByKeyboard: true,
103        spinicon: BootstrapDialog.ICON_SPINNER,
104        autodestroy: true,
105        draggable: false,
106        animate: true
107    };
108
109    /**
110     * Config default options.
111     */
112    BootstrapDialog.configDefaultOptions = function(options) {
113        BootstrapDialog.defaultOptions = $.extend(true, BootstrapDialog.defaultOptions, options);
114    };
115
116    /**
117     * Open / Close all created dialogs all at once.
118     */
119    BootstrapDialog.dialogs = {};
120    BootstrapDialog.openAll = function() {
121        $.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
122            dialogInstance.open();
123        });
124    };
125    BootstrapDialog.closeAll = function() {
126        $.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
127            dialogInstance.close();
128        });
129    };
130
131    /**
132     * Move focus to next visible dialog.
133     */
134    BootstrapDialog.moveFocus = function() {
135        var lastDialogInstance = null;
136        $.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
137            lastDialogInstance = dialogInstance;
138        });
139        if (lastDialogInstance !== null && lastDialogInstance.isRealized()) {
140            lastDialogInstance.getModal().focus();
141        }
142    };
143
144    /**
145     * Show scrollbar if the last visible dialog needs one.
146     */
147    BootstrapDialog.showScrollbar = function() {
148        var lastDialogInstance = null;
149        $.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
150            lastDialogInstance = dialogInstance;
151        });
152        if (lastDialogInstance !== null && lastDialogInstance.isRealized() && lastDialogInstance.isOpened()) {
153            var bsModal = lastDialogInstance.getModal().data('bs.modal');
154            bsModal.checkScrollbar();
155            $('body').addClass('modal-open');
156            bsModal.setScrollbar();
157        }
158    };
159
160    BootstrapDialog.prototype = {
161        constructor: BootstrapDialog,
162        initOptions: function(options) {
163            this.options = $.extend(true, this.defaultOptions, options);
164
165            return this;
166        },
167        holdThisInstance: function() {
168            BootstrapDialog.dialogs[this.getId()] = this;
169
170            return this;
171        },
172        initModalStuff: function() {
173            this.setModal(this.createModal())
174            .setModalDialog(this.createModalDialog())
175            .setModalContent(this.createModalContent())
176            .setModalHeader(this.createModalHeader())
177            .setModalBody(this.createModalBody())
178            .setModalFooter(this.createModalFooter());
179
180            this.getModal().append(this.getModalDialog());
181            this.getModalDialog().append(this.getModalContent());
182            this.getModalContent()
183            .append(this.getModalHeader())
184            .append(this.getModalBody())
185            .append(this.getModalFooter());
186
187            return this;
188        },
189        createModal: function() {
190            var $modal = $('<div class="modal" tabindex="-1"></div>');
191            $modal.prop('id', this.getId());
192
193            return $modal;
194        },
195        getModal: function() {
196            return this.$modal;
197        },
198        setModal: function($modal) {
199            this.$modal = $modal;
200
201            return this;
202        },
203        createModalDialog: function() {
204            return $('<div class="modal-dialog modal-small"></div>');
205        },
206        getModalDialog: function() {
207            return this.$modalDialog;
208        },
209        setModalDialog: function($modalDialog) {
210            this.$modalDialog = $modalDialog;
211
212            return this;
213        },
214        createModalContent: function() {
215            return $('<div class="modal-content"></div>');
216        },
217        getModalContent: function() {
218            return this.$modalContent;
219        },
220        setModalContent: function($modalContent) {
221            this.$modalContent = $modalContent;
222
223            return this;
224        },
225        createModalHeader: function() {
226            return $('<div class="modal-header"></div>');
227        },
228        getModalHeader: function() {
229            return this.$modalHeader;
230        },
231        setModalHeader: function($modalHeader) {
232            this.$modalHeader = $modalHeader;
233
234            return this;
235        },
236        createModalBody: function() {
237            return $('<div class="modal-body"></div>');
238        },
239        getModalBody: function() {
240            return this.$modalBody;
241        },
242        setModalBody: function($modalBody) {
243            this.$modalBody = $modalBody;
244
245            return this;
246        },
247        createModalFooter: function() {
248            return $('<div class="modal-footer"></div>');
249        },
250        getModalFooter: function() {
251            return this.$modalFooter;
252        },
253        setModalFooter: function($modalFooter) {
254            this.$modalFooter = $modalFooter;
255
256            return this;
257        },
258        createDynamicContent: function(rawContent) {
259            var content = null;
260            if (typeof rawContent === 'function') {
261                content = rawContent.call(rawContent, this);
262            } else {
263                content = rawContent;
264            }
265            if (typeof content === 'string') {
266                content = this.formatStringContent(content);
267            }
268
269            return content;
270        },
271        formatStringContent: function(content) {
272            if (this.options.nl2br) {
273                return content.replace(/\r\n/g, '').replace(/[\r\n]/g, '').replace(/[\r\n]/g, '');
274            }
275
276            return content;
277        },
278        setData: function(key, value) {
279            this.options.data[key] = value;
280
281            return this;
282        },
283        getData: function(key) {
284            return this.options.data[key];
285        },
286        setId: function(id) {
287            this.options.id = id;
288
289            return this;
290        },
291        getId: function() {
292            return this.options.id;
293        },
294        getType: function() {
295            return this.options.type;
296        },
297        setType: function(type) {
298            this.options.type = type;
299            this.updateType();
300
301            return this;
302        },
303        updateType: function() {
304            if (this.isRealized()) {
305                var types = [BootstrapDialog.TYPE_DEFAULT,
306                    BootstrapDialog.TYPE_INFO,
307                    BootstrapDialog.TYPE_PRIMARY,
308                    BootstrapDialog.TYPE_SUCCESS,
309                    BootstrapDialog.TYPE_WARNING,
310                    BootstrapDialog.TYPE_DANGER];
311
312                this.getModal().removeClass(types.join(' ')).addClass(this.getType());
313            }
314
315            return this;
316        },
317        getSize: function() {
318            return this.options.size;
319        },
320        setSize: function(size) {
321            this.options.size = size;
322
323            return this;
324        },
325        getCssClass: function() {
326            return this.options.cssClass;
327        },
328        setCssClass: function(cssClass) {
329            this.options.cssClass = cssClass;
330
331            return this;
332        },
333        getTitle: function() {
334            return this.options.title;
335        },
336        setTitle: function(title) {
337            this.options.title = title;
338            this.updateTitle();
339
340            return this;
341        },
342        updateTitle: function() {
343            if (this.isRealized()) {
344                var title = this.getTitle() !== null ? this.createDynamicContent(this.getTitle()) : this.getDefaultText();
345                this.getModalHeader().find('.' + this.getNamespace('title')).html('').append(title);
346            }
347
348            return this;
349        },
350        getMessage: function() {
351            return this.options.message;
352        },
353        setMessage: function(message) {
354            this.options.message = message;
355            this.updateMessage();
356
357            return this;
358        },
359        updateMessage: function() {
360            if (this.isRealized()) {
361                var message = this.createDynamicContent(this.getMessage());
362                this.getModalBody().find('.' + this.getNamespace('message')).html('').append(message);
363            }
364
365            return this;
366        },
367        isClosable: function() {
368            return this.options.closable;
369        },
370        setClosable: function(closable) {
371            this.options.closable = closable;
372            this.updateClosable();
373
374            return this;
375        },
376        setCloseByBackdrop: function(closeByBackdrop) {
377            this.options.closeByBackdrop = closeByBackdrop;
378
379            return this;
380        },
381        canCloseByBackdrop: function() {
382            return this.options.closeByBackdrop;
383        },
384        setCloseByKeyboard: function(closeByKeyboard) {
385            this.options.closeByKeyboard = closeByKeyboard;
386
387            return this;
388        },
389        canCloseByKeyboard: function() {
390            return this.options.closeByKeyboard;
391        },
392        isAnimate: function() {
393            return this.options.animate;
394        },
395        setAnimate: function(animate) {
396            this.options.animate = animate;
397
398            return this;
399        },
400        updateAnimate: function() {
401            if (this.isRealized()) {
402                this.getModal().toggleClass('fade', this.isAnimate());
403            }
404
405            return this;
406        },
407        getSpinicon: function() {
408            return this.options.spinicon;
409        },
410        setSpinicon: function(spinicon) {
411            this.options.spinicon = spinicon;
412
413            return this;
414        },
415        addButton: function(button) {
416            this.options.buttons.push(button);
417
418            return this;
419        },
420        addButtons: function(buttons) {
421            var that = this;
422            $.each(buttons, function(index, button) {
423                that.addButton(button);
424            });
425
426            return this;
427        },
428        getButtons: function() {
429            return this.options.buttons;
430        },
431        setButtons: function(buttons) {
432            this.options.buttons = buttons;
433            this.updateButtons();
434
435            return this;
436        },
437        /**
438         * If there is id provided for a button option, it will be in dialog.indexedButtons list.
439         * 
440         * In that case you can use dialog.getButton(id) to find the button.
441         * 
442         * @param {type} id
443         * @returns {undefined}
444         */
445        getButton: function(id) {
446            if (typeof this.indexedButtons[id] !== 'undefined') {
447                return this.indexedButtons[id];
448            }
449
450            return null;
451        },
452        getButtonSize: function() {
453            if (typeof BootstrapDialog.BUTTON_SIZES[this.getSize()] !== 'undefined') {
454                return BootstrapDialog.BUTTON_SIZES[this.getSize()];
455            }
456
457            return '';
458        },
459        updateButtons: function() {
460            if (this.isRealized()) {
461                if (this.getButtons().length === 0) {
462                    this.getModalFooter().hide();
463                } else {
464                    this.getModalFooter().find('.' + this.getNamespace('footer')).html('').append(this.createFooterButtons());
465                }
466            }
467
468            return this;
469        },
470        isAutodestroy: function() {
471            return this.options.autodestroy;
472        },
473        setAutodestroy: function(autodestroy) {
474            this.options.autodestroy = autodestroy;
475        },
476        getDefaultText: function() {
477            return BootstrapDialog.DEFAULT_TEXTS[this.getType()];
478        },
479        getNamespace: function(name) {
480            return BootstrapDialog.NAMESPACE + '-' + name;
481        },
482        createHeaderContent: function() {
483            var $container = $('<div></div>');
484            $container.addClass(this.getNamespace('header'));
485
486            // title
487            $container.append(this.createTitleContent());
488
489            // Close button
490            $container.prepend(this.createCloseButton());
491
492            return $container;
493        },
494        createTitleContent: function() {
495            var $title = $('<div></div>');
496            $title.addClass(this.getNamespace('title'));
497
498            return $title;
499        },
500        createCloseButton: function() {
501            var $container = $('<div></div>');
502            $container.addClass(this.getNamespace('close-button'));
503            var $icon = $('<button class="close">&times;</button>');
504            $container.append($icon);
505            $container.on('click', {dialog: this}, function(event) {
506                event.data.dialog.close();
507            });
508
509            return $container;
510        },
511        createBodyContent: function() {
512            var $container = $('<div></div>');
513            $container.addClass(this.getNamespace('body'));
514
515            // Message
516            $container.append(this.createMessageContent());
517
518            return $container;
519        },
520        createMessageContent: function() {
521            var $message = $('<div></div>');
522            $message.addClass(this.getNamespace('message'));
523
524            return $message;
525        },
526        createFooterContent: function() {
527            var $container = $('<div></div>');
528            $container.addClass(this.getNamespace('footer'));
529
530            return $container;
531        },
532        createFooterButtons: function() {
533            var that = this;
534            var $container = $('<div></div>');
535            $container.addClass(this.getNamespace('footer-buttons'));
536            this.indexedButtons = {};
537            $.each(this.options.buttons, function(index, button) {
538                if (!button.id) {
539                    button.id = BootstrapDialog.newGuid();
540                }
541                var $button = that.createButton(button);
542                that.indexedButtons[button.id] = $button;
543                $container.append($button);
544            });
545
546            return $container;
547        },
548        createButton: function(button) {
549            var $button = $('<button class="btn"></button>');
550            $button.addClass(this.getButtonSize());
551            $button.prop('id', button.id);
552
553            // Icon
554            if (typeof button.icon !== 'undefined' && $.trim(button.icon) !== '') {
555                $button.append(this.createButtonIcon(button.icon));
556            }
557
558            // Label
559            if (typeof button.label !== 'undefined') {
560                $button.append(button.label);
561            }
562
563            // Css class
564            if (typeof button.cssClass !== 'undefined' && $.trim(button.cssClass) !== '') {
565                $button.addClass(button.cssClass);
566            } else {
567                $button.addClass('btn-default');
568            }
569
570            // Hotkey
571            if (typeof button.hotkey !== 'undefined') {
572                this.registeredButtonHotkeys[button.hotkey] = $button;
573            }
574
575            // Button on click
576            $button.on('click', {dialog: this, $button: $button, button: button}, function(event) {
577                var dialog = event.data.dialog;
578                var $button = event.data.$button;
579                var button = event.data.button;
580                if (typeof button.action === 'function') {
581                    button.action.call($button, dialog);
582                }
583
584                if (button.autospin) {
585                    $button.toggleSpin(true);
586                }
587            });
588
589            // Dynamically add extra functions to $button
590            this.enhanceButton($button);
591
592            return $button;
593        },
594        /**
595         * Dynamically add extra functions to $button
596         * 
597         * Using '$this' to reference 'this' is just for better readability.
598         * 
599         * @param {type} $button
600         * @returns {_L13.BootstrapDialog.prototype}
601         */
602        enhanceButton: function($button) {
603            $button.dialog = this;
604
605            // Enable / Disable
606            $button.toggleEnable = function(enable) {
607                var $this = this;
608                if (typeof enable !== 'undefined') {
609                    $this.prop("disabled", !enable).toggleClass('disabled', !enable);
610                } else {
611                    $this.prop("disabled", !$this.prop("disabled"));
612                }
613
614                return $this;
615            };
616            $button.enable = function() {
617                var $this = this;
618                $this.toggleEnable(true);
619
620                return $this;
621            };
622            $button.disable = function() {
623                var $this = this;
624                $this.toggleEnable(false);
625
626                return $this;
627            };
628
629            // Icon spinning, helpful for indicating ajax loading status.
630            $button.toggleSpin = function(spin) {
631                var $this = this;
632                var dialog = $this.dialog;
633                var $icon = $this.find('.' + dialog.getNamespace('button-icon'));
634                if (typeof spin === 'undefined') {
635                    spin = !($button.find('.icon-spin').length > 0);
636                }
637                if (spin) {
638                    $icon.hide();
639                    $button.prepend(dialog.createButtonIcon(dialog.getSpinicon()).addClass('icon-spin'));
640                } else {
641                    $icon.show();
642                    $button.find('.icon-spin').remove();
643                }
644
645                return $this;
646            };
647            $button.spin = function() {
648                var $this = this;
649                $this.toggleSpin(true);
650
651                return $this;
652            };
653            $button.stopSpin = function() {
654                var $this = this;
655                $this.toggleSpin(false);
656
657                return $this;
658            };
659
660            return this;
661        },
662        createButtonIcon: function(icon) {
663            var $icon = $('<span></span>');
664            $icon.addClass(this.getNamespace('button-icon')).addClass(icon);
665
666            return $icon;
667        },
668        /**
669         * Invoke this only after the dialog is realized.
670         * 
671         * @param {type} enable
672         * @returns {undefined}
673         */
674        enableButtons: function(enable) {
675            $.each(this.indexedButtons, function(id, $button) {
676                $button.toggleEnable(enable);
677            });
678
679            return this;
680        },
681        /**
682         * Invoke this only after the dialog is realized.
683         * 
684         * @returns {undefined}
685         */
686        updateClosable: function() {
687            if (this.isRealized()) {
688                // Close button
689                this.getModalHeader().find('.' + this.getNamespace('close-button')).toggle(this.isClosable());
690            }
691
692            return this;
693        },
694        /**
695         * Set handler for modal event 'show.bs.modal'.
696         * This is a setter!
697         */
698        onShow: function(onshow) {
699            this.options.onshow = onshow;
700
701            return this;
702        },
703        /**
704         * Set handler for modal event 'shown.bs.modal'.
705         * This is a setter!
706         */
707        onShown: function(onshown) {
708            this.options.onshown = onshown;
709
710            return this;
711        },
712        /**
713         * Set handler for modal event 'hide.bs.modal'.
714         * This is a setter!
715         */
716        onHide: function(onhide) {
717            this.options.onhide = onhide;
718
719            return this;
720        },
721        /**
722         * Set handler for modal event 'hidden.bs.modal'.
723         * This is a setter!
724         */
725        onHidden: function(onhidden) {
726            this.options.onhidden = onhidden;
727
728            return this;
729        },
730        isRealized: function() {
731            return this.realized;
732        },
733        setRealized: function(realized) {
734            this.realized = realized;
735
736            return this;
737        },
738        isOpened: function() {
739            return this.opened;
740        },
741        setOpened: function(opened) {
742            this.opened = opened;
743
744            return this;
745        },
746        handleModalEvents: function() {
747            this.getModal().on('show.bs.modal', {dialog: this}, function(event) {
748                var dialog = event.data.dialog;
749                if (typeof dialog.options.onshow === 'function') {
750                    return dialog.options.onshow(dialog);
751                }
752            });
753            this.getModal().on('shown.bs.modal', {dialog: this}, function(event) {
754                var dialog = event.data.dialog;
755                typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog);
756            });
757            this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
758                var dialog = event.data.dialog;
759                if (typeof dialog.options.onhide === 'function') {
760                    return dialog.options.onhide(dialog);
761                }
762            });
763            this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
764                var dialog = event.data.dialog;
765                typeof dialog.options.onhidden === 'function' && dialog.options.onhidden(dialog);
766                dialog.isAutodestroy() && $(this).remove();
767            });
768
769            // Backdrop, I did't find a way to change bs3 backdrop option after the dialog is popped up, so here's a new wheel.
770            this.getModal().on('mouseup', {dialog: this}, function(event) {
771                event.target === this && event.data.dialog.isClosable() && event.data.dialog.canCloseByBackdrop() && event.data.dialog.close();
772            });
773
774            // ESC key support
775            this.getModal().on('keyup', {dialog: this}, function(event) {
776                event.which === 27 && event.data.dialog.isClosable() && event.data.dialog.canCloseByKeyboard() && event.data.dialog.close();
777            });
778
779            // Button hotkey
780            this.getModal().on('keyup', {dialog: this}, function(event) {
781                var dialog = event.data.dialog;
782                if (typeof dialog.registeredButtonHotkeys[event.which] !== 'undefined') {
783                    var $button = $(dialog.registeredButtonHotkeys[event.which]);
784                    !$button.prop('disabled') && $button.focus().trigger('click');
785                }
786            });
787
788            return this;
789        },
790        makeModalDraggable: function() {
791            if (this.options.draggable) {
792                this.getModalHeader().addClass(this.getNamespace('draggable')).on('mousedown', {dialog: this}, function(event) {
793                    var dialog = event.data.dialog;
794                    dialog.draggableData.isMouseDown = true;
795                    var dialogOffset = dialog.getModalContent().offset();
796                    dialog.draggableData.mouseOffset = {
797                        top: event.clientY - dialogOffset.top,
798                        left: event.clientX - dialogOffset.left
799                    };
800                });
801                this.getModal().on('mouseup mouseleave', {dialog: this}, function(event) {
802                    event.data.dialog.draggableData.isMouseDown = false;
803                });
804                $('body').on('mousemove', {dialog: this}, function(event) {
805                    var dialog = event.data.dialog;
806                    if (!dialog.draggableData.isMouseDown) {
807                        return;
808                    }
809                    dialog.getModalContent().offset({
810                        top: event.clientY - dialog.draggableData.mouseOffset.top,
811                        left: event.clientX - dialog.draggableData.mouseOffset.left
812                    });
813                });
814            }
815
816            return this;
817        },
818        /**
819         * To make multiple opened dialogs look better.
820         */
821        updateZIndex: function() {
822            var dialogCount = 0;
823            $.each(BootstrapDialog.dialogs, function(dialogId, dialogInstance) {
824                dialogCount++;
825            });
826            if (dialogCount > 1) {
827                var $modal = this.getModal();
828                var $backdrop = $modal.data('bs.modal').$backdrop;
829                $modal.css('z-index', BootstrapDialog.ZINDEX_MODAL + (dialogCount - 1) * 20);
830                $backdrop.css('z-index', BootstrapDialog.ZINDEX_BACKDROP + (dialogCount - 1) * 20);
831            }
832
833            return this;
834        },
835        realize: function() {
836            this.initModalStuff();
837            this.getModal().addClass(BootstrapDialog.NAMESPACE)
838            .addClass(this.getSize())
839            .addClass(this.getCssClass());
840            this.getModalFooter().append(this.createFooterContent());
841            this.getModalHeader().append(this.createHeaderContent());
842            this.getModalBody().append(this.createBodyContent());
843            this.getModal().modal({
844                backdrop: 'static',
845                keyboard: false,
846                show: false
847            });
848            this.makeModalDraggable();
849            this.handleModalEvents();
850            this.setRealized(true);
851            this.updateButtons();
852            this.updateType();
853            this.updateTitle();
854            this.updateMessage();
855            this.updateClosable();
856            this.updateAnimate();
857
858            return this;
859        },
860        open: function() {
861            !this.isRealized() && this.realize();
862            this.getModal().modal('show');
863            this.updateZIndex();
864            this.setOpened(true);
865
866            return this;
867        },
868        close: function() {
869            this.getModal().modal('hide');
870            if (this.isAutodestroy()) {
871                delete BootstrapDialog.dialogs[this.getId()];
872            }
873            this.setOpened(false);
874
875            // Move focus to the last visible dialog.
876            BootstrapDialog.moveFocus();
877
878            // Show scrollbar if the last visible dialog needs one.
879            BootstrapDialog.showScrollbar();
880
881            return this;
882        }
883    };
884
885    /**
886     * RFC4122 version 4 compliant unique id creator.
887     *
888     * Added by https://github.com/tufanbarisyildirim/
889     *
890     *  @returns {String}
891     */
892    BootstrapDialog.newGuid = function() {
893        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
894            var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
895            return v.toString(16);
896        });
897    };
898
899    /* ================================================
900     * For lazy people
901     * ================================================ */
902
903    /**
904     * Shortcut function: show
905     * 
906     * @param {type} options
907     * @returns the created dialog instance
908     */
909    BootstrapDialog.show = function(options) {
910        return new BootstrapDialog(options).open();
911    };
912
913    /**
914     * Alert window
915     * 
916     * @returns the created dialog instance
917     */
918    BootstrapDialog.alert = function() {
919        var options = {};
920        var defaultOptions = {
921            type: BootstrapDialog.TYPE_PRIMARY,
922            title: null,
923            message: null,
924            closable: true,
925            buttonLabel: 'OK',
926            callback: null
927        };
928
929        if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) {
930            options = $.extend(true, defaultOptions, arguments[0]);
931        } else {
932            options = $.extend(true, defaultOptions, {
933                message: arguments[0],
934                closable: false,
935                buttonLabel: 'OK',
936                callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null
937            });
938        }
939
940        return new BootstrapDialog({
941            type: options.type,
942            title: options.title,
943            message: options.message,
944            closable: options.closable,
945            data: {
946                callback: options.callback
947            },
948            onhide: function(dialog) {
949                !dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
950            },
951            buttons: [{
952                    label: options.buttonLabel,
953                    action: function(dialog) {
954                        dialog.setData('btnClicked', true);
955                        typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
956                        dialog.close();
957                    }
958                }]
959        }).open();
960    };
961
962    /**
963     * Confirm window
964     * 
965     * @param {type} message
966     * @param {type} callback
967     * @returns the created dialog instance
968     */
969    BootstrapDialog.confirm = function(message, callback) {
970        return new BootstrapDialog({
971            title: 'Confirmation',
972            message: message,
973            closable: false,
974            data: {
975                'callback': callback
976            },
977            buttons: [{
978                    label: 'Cancel',
979                    action: function(dialog) {
980                        typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
981                        dialog.close();
982                    }
983                }, {
984                    label: 'OK',
985                    cssClass: 'btn-primary',
986                    action: function(dialog) {
987                        typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
988                        dialog.close();
989                    }
990                }]
991        }).open();
992    };
993
994    /**
995     * Warning window
996     * 
997     * @param {type} message
998     * @returns the created dialog instance
999     */
1000    BootstrapDialog.warning = function(message, callback) {
1001        return new BootstrapDialog({
1002            type: BootstrapDialog.TYPE_WARNING,
1003            message: message
1004        }).open();
1005    };
1006
1007    /**
1008     * Danger window
1009     * 
1010     * @param {type} message
1011     * @returns the created dialog instance
1012     */
1013    BootstrapDialog.danger = function(message, callback) {
1014        return new BootstrapDialog({
1015            type: BootstrapDialog.TYPE_DANGER,
1016            message: message
1017        }).open();
1018    };
1019
1020    /**
1021     * Success window
1022     * 
1023     * @param {type} message
1024     * @returns the created dialog instance
1025     */
1026    BootstrapDialog.success = function(message, callback) {
1027        return new BootstrapDialog({
1028            type: BootstrapDialog.TYPE_SUCCESS,
1029            message: message
1030        }).open();
1031    };
1032
1033    return BootstrapDialog;
1034
1035}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.