vendor: 22,147 bytes, lines 1-617
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'), require('bootstrap')); 21 } 22 // AMD module is defined 23 else if (typeof define === "function" && define.amd) { 24 define("bootstrap-dialog", ["jquery", "bootstrap"], function ($) { 25 return factory($); 26 }); 27 } else { 28 // planted over the root! 29 root.BootstrapDialog = factory(root.jQuery); 30 } 31 32}(this ? this : window, function ($) { 33 34 "use strict"; 35 36 /* ================================================ 37 * Definition of BootstrapDialogModal. 38 * Extend Bootstrap Modal and override some functions. 39 * BootstrapDialogModal === Modified Modal. 40 * ================================================ */ 41 var Modal = bootstrap.Modal ? bootstrap.Modal : $.fn.modal.Constructor; 42 var BootstrapDialogModal = function (element, options) { 43 if(bootstrap && bootstrap.Modal && /^5\.[^\D0]\./.test(bootstrap.Modal.VERSION)) { 44 return new Modal(element, options); 45 } else if(bootstrap && bootstrap.Modal && /^5\.0\.2/.test(bootstrap.Modal.VERSION)) { 46 return new Modal(element, options); 47 } else if (/4\.1\.\d+/.test($.fn.modal.Constructor.VERSION)) { //FIXME for BootstrapV4 48 return new Modal(element, options); 49 } else { 50 Modal.call(this, element, options); 51 } 52 }; 53 BootstrapDialogModal.getModalVersion = function () { 54 var version = null; 55 if(bootstrap && bootstrap.Modal && /^5\.[^\D0]\./.test(bootstrap.Modal.VERSION)) { 56 version = 'v5.1'; 57 //not compatible with 5.0.1, regex upper bounds would have been better 58 } else if(bootstrap && bootstrap.Modal && /^5\.0\.[23456789]/.test(bootstrap.Modal.VERSION)) { 59 version = 'v5.1'; 60 } 61 else if (typeof $.fn.modal.Constructor.VERSION === 'undefined') { 62 version = 'v3.1'; 63 } else if (/3\.2\.\d+/.test($.fn.modal.Constructor.VERSION)) { 64 version = 'v3.2'; 65 } else if (/3\.3\.[1,2]/.test($.fn.modal.Constructor.VERSION)) { 66 version = 'v3.3'; // v3.3.1, v3.3.2 67 } else if (/4\.\d\.\d+/.test($.fn.modal.Constructor.VERSION)) { //FIXME for BootstrapV4 68 version = 'v4.1'; 69 } else { 70 version = 'v3.3.4'; 71 } 72 73 return version; 74 }; 75 BootstrapDialogModal.ORIGINAL_BODY_PADDING = parseInt(($('body').css('padding-right') || 0), 10); 76 BootstrapDialogModal.METHODS_TO_OVERRIDE = {}; 77 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.1'] = {}; 78 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.2'] = { 79 hide: function (e) { 80 if (e) { 81 e.preventDefault(); 82 } 83 e = $.Event('hide.bs.modal'); 84 85 this.$element.trigger(e); 86 87 if (!this.isShown || e.isDefaultPrevented()) { 88 return; 89 } 90 91 this.isShown = false; 92 93 // Remove css class 'modal-open' when the last opened dialog is closing. 94 var openedDialogs = this.getGlobalOpenedDialogs(); 95 if (openedDialogs.length === 0) { 96 this.$body.removeClass('modal-open'); 97 } 98 99 this.resetScrollbar(); 100 this.escape(); 101 102 $(document).off('focusin.bs.modal'); 103 104 this.$element 105 .removeClass('in') 106 .attr('aria-hidden', true) 107 .off('click.dismiss.bs.modal'); 108 109 $.support.transition && this.$element.hasClass('fade') ? 110 this.$element 111 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 112 .emulateTransitionEnd(300) : 113 this.hideModal(); 114 } 115 }; 116 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3'] = { 117 /** 118 * Overrided. 119 * 120 * @returns {undefined} 121 */ 122 setScrollbar: function () { 123 var bodyPad = BootstrapDialogModal.ORIGINAL_BODY_PADDING; 124 if (this.bodyIsOverflowing) { 125 this.$body.css('padding-right', bodyPad + this.scrollbarWidth); 126 } 127 }, 128 /** 129 * Overrided. 130 * 131 * @returns {undefined} 132 */ 133 resetScrollbar: function () { 134 var openedDialogs = this.getGlobalOpenedDialogs(); 135 if (openedDialogs.length === 0) { 136 this.$body.css('padding-right', BootstrapDialogModal.ORIGINAL_BODY_PADDING); 137 } 138 }, 139 /** 140 * Overrided. 141 * 142 * @returns {undefined} 143 */ 144 hideModal: function () { 145 this.$element.hide(); 146 this.backdrop($.proxy(function () { 147 var openedDialogs = this.getGlobalOpenedDialogs(); 148 if (openedDialogs.length === 0) { 149 this.$body.removeClass('modal-open'); 150 } 151 this.resetAdjustments(); 152 this.resetScrollbar(); 153 this.$element.trigger('hidden.bs.modal'); 154 }, this)); 155 } 156 }; 157 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']); 158 BootstrapDialogModal.METHODS_TO_OVERRIDE['v4.1'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']); //FIXME for BootstrapV4 159 BootstrapDialogModal.METHODS_TO_OVERRIDE['v5.1'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v4.1']); //FIXME for BootstrapV5 160 BootstrapDialogModal.prototype = { 161 constructor: BootstrapDialogModal, 162 /** 163 * New function, to get the dialogs that opened by BootstrapDialog. 164 * 165 * @returns {undefined} 166 */ 167 getGlobalOpenedDialogs: function () { 168 var openedDialogs = []; 169 $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { 170 if (dialogInstance.isRealized() && dialogInstance.isOpened()) { 171 openedDialogs.push(dialogInstance); 172 } 173 }); 174 175 return openedDialogs; 176 } 177 }; 178 179 // Add compatible methods. 180 BootstrapDialogModal.prototype = $.extend(BootstrapDialogModal.prototype, Modal.prototype, BootstrapDialogModal.METHODS_TO_OVERRIDE[BootstrapDialogModal.getModalVersion()]); 181 182 /* ================================================ 183 * Definition of BootstrapDialog. 184 * ================================================ */ 185 var BootstrapDialog = function (options) { 186 this.defaultOptions = $.extend(true, { 187 id: BootstrapDialog.newGuid(), 188 buttons: [], 189 data: {}, 190 onshow: null, 191 onshown: null, 192 onhide: null, 193 onhidden: null 194 }, BootstrapDialog.defaultOptions); 195 this.indexedButtons = {}; 196 this.registeredButtonHotkeys = {}; 197 this.draggableData = { 198 isMouseDown: false, 199 mouseOffset: {} 200 }; 201 this.realized = false; 202 this.opened = false; 203 this.initOptions(options); 204 this.holdThisInstance(); 205 }; 206 207 BootstrapDialog.BootstrapDialogModal = BootstrapDialogModal; 208 209 /** 210 * Some constants. 211 */ 212 BootstrapDialog.NAMESPACE = 'bootstrap-dialog'; 213 BootstrapDialog.TYPE_DEFAULT = 'type-default'; 214 BootstrapDialog.TYPE_INFO = 'type-info'; 215 BootstrapDialog.TYPE_PRIMARY = 'type-primary'; 216 BootstrapDialog.TYPE_SECONDARY = 'type-secondary'; 217 BootstrapDialog.TYPE_SUCCESS = 'type-success'; 218 BootstrapDialog.TYPE_WARNING = 'type-warning'; 219 BootstrapDialog.TYPE_DANGER = 'type-danger'; 220 BootstrapDialog.TYPE_DARK = 'type-dark'; 221 BootstrapDialog.TYPE_LIGHT = 'type-light'; 222 BootstrapDialog.DEFAULT_TEXTS = {}; 223 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = 'Default'; 224 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO] = 'Information'; 225 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY] = 'Primary'; 226 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SECONDARY] = 'Secondary'; 227 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS] = 'Success'; 228 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING] = 'Warning'; 229 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER] = 'Danger'; 230 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DARK] = 'Dark'; 231 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_LIGHT] = 'Light'; 232 BootstrapDialog.DEFAULT_TEXTS['OK'] = 'OK'; 233 BootstrapDialog.DEFAULT_TEXTS['CANCEL'] = 'Cancel'; 234 BootstrapDialog.DEFAULT_TEXTS['CONFIRM'] = 'Confirmation'; 235 BootstrapDialog.SIZE_NORMAL = 'size-normal'; 236 BootstrapDialog.SIZE_SMALL = 'size-small'; 237 BootstrapDialog.SIZE_WIDE = 'size-wide'; // size-wide is equal to modal-lg 238 BootstrapDialog.SIZE_EXTRAWIDE = 'size-extrawide'; // size-wide is equal to modal-lg 239 BootstrapDialog.SIZE_LARGE = 'size-large'; 240 BootstrapDialog.BUTTON_SIZES = {}; 241 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = ''; 242 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_SMALL] = 'btn-small'; 243 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_WIDE] = 'btn-block'; 244 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE] = 'btn-lg'; 245 BootstrapDialog.ICON_SPINNER = 'fas fa-spinner'; 246 BootstrapDialog.BUTTONS_ORDER_CANCEL_OK = 'btns-order-cancel-ok'; 247 BootstrapDialog.BUTTONS_ORDER_OK_CANCEL = 'btns-order-ok-cancel'; 248 BootstrapDialog.Z_INDEX_BACKDROP = 1040; 249 BootstrapDialog.Z_INDEX_MODAL = 1050; 250 251 /** 252 * Default options. 253 */ 254 BootstrapDialog.defaultOptions = { 255 type: BootstrapDialog.TYPE_PRIMARY, 256 size: BootstrapDialog.SIZE_NORMAL, 257 cssClass: '', 258 title: null, 259 message: null, 260 nl2br: true, 261 closable: true, 262 closeByBackdrop: true, 263 closeByKeyboard: true, 264 closeIcon: '×', 265 spinicon: BootstrapDialog.ICON_SPINNER, 266 autodestroy: true, 267 draggable: false, 268 animate: true, 269 description: '', 270 tabindex: -1, 271 verticalCentered:false, 272 btnsOrder: BootstrapDialog.BUTTONS_ORDER_CANCEL_OK 273 }; 274 275 /** 276 * Config default options. 277 */ 278 BootstrapDialog.configDefaultOptions = function (options) { 279 BootstrapDialog.defaultOptions = $.extend(true, BootstrapDialog.defaultOptions, options); 280 }; 281 282 /** 283 * Open / Close all created dialogs all at once. 284 */ 285 BootstrapDialog.dialogs = {}; 286 BootstrapDialog.openAll = function () { 287 $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { 288 dialogInstance.open(); 289 }); 290 }; 291 BootstrapDialog.closeAll = function () { 292 $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { 293 dialogInstance.close(); 294 }); 295 }; 296 297 /** 298 * Get dialog instance by given id. 299 * 300 * @returns dialog instance 301 */ 302 BootstrapDialog.getDialog = function (id) { 303 var dialog = null; 304 if (typeof BootstrapDialog.dialogs[id] !== 'undefined') { 305 dialog = BootstrapDialog.dialogs[id]; 306 } 307 308 return dialog; 309 }; 310 311 /** 312 * Set a dialog. 313 * 314 * @returns the dialog that has just been set. 315 */ 316 BootstrapDialog.setDialog = function (dialog) { 317 BootstrapDialog.dialogs[dialog.getId()] = dialog; 318 319 return dialog; 320 }; 321 322 /** 323 * Alias of BootstrapDialog.setDialog(dialog) 324 * 325 * @param {type} dialog 326 * @returns {unresolved} 327 */ 328 BootstrapDialog.addDialog = function (dialog) { 329 return BootstrapDialog.setDialog(dialog); 330 }; 331 332 /** 333 * Move focus to next visible dialog. 334 */ 335 BootstrapDialog.moveFocus = function () { 336 var lastDialogInstance = null; 337 $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { 338 if (dialogInstance.isRealized() && dialogInstance.isOpened()) { 339 lastDialogInstance = dialogInstance; 340 } 341 }); 342 if (lastDialogInstance !== null) { 343 lastDialogInstance.getModal().focus(); 344 } 345 }; 346 347 BootstrapDialog.METHODS_TO_OVERRIDE = {}; 348 BootstrapDialog.METHODS_TO_OVERRIDE['v3.1'] = { 349 /** 350 * To make multiple opened dialogs look better. 351 * 352 * Will be removed in later version, after Bootstrap Modal >= 3.3.0, updating z-index is unnecessary. 353 */ 354 updateZIndex: function () { 355 if (this.isOpened()) { 356 var zIndexBackdrop = BootstrapDialog.Z_INDEX_BACKDROP; 357 var zIndexModal = BootstrapDialog.Z_INDEX_MODAL; 358 var dialogCount = 0; 359 $.each(BootstrapDialog.dialogs, function (dialogId, dialogInstance) { 360 if (dialogInstance.isRealized() && dialogInstance.isOpened()) { 361 dialogCount++; 362 } 363 }); 364 var $modal = this.getModal(); 365 var $backdrop = this.getModalBackdrop($modal); //FIXME for BootstrapV4 366 $modal.css('z-index', zIndexModal + (dialogCount - 1) * 20); 367 $backdrop.css('z-index', zIndexBackdrop + (dialogCount - 1) * 20); 368 } 369 370 return this; 371 }, 372 open: function () { 373 !this.isRealized() && this.realize(); 374 this.getModal().modal('show'); 375 this.updateZIndex(); 376 377 return this; 378 } 379 }; 380 BootstrapDialog.METHODS_TO_OVERRIDE['v3.2'] = { 381 updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'], 382 open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'] 383 }; 384 BootstrapDialog.METHODS_TO_OVERRIDE['v3.3'] = {}; 385 BootstrapDialog.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']); 386 BootstrapDialog.METHODS_TO_OVERRIDE['v4.0'] = { //FIXME for BootstrapV4 387 getModalBackdrop: function ($modal) { 388 return $($modal.data('bs.modal')._backdrop); 389 }, 390 updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'], 391 open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'], 392 getModalForBootstrapDialogModal: function () { 393 return this.getModal().get(0); 394 } 395 }; 396 BootstrapDialog.METHODS_TO_OVERRIDE['v4.1'] = { //FIXME for BootstrapV4 397 getModalBackdrop: function ($modal) { 398 return $($modal.data('bs.modal')._backdrop); 399 }, 400 updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'], 401 open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'], 402 getModalForBootstrapDialogModal: function () { 403 return this.getModal().get(0); 404 } 405 }; 406 BootstrapDialog.METHODS_TO_OVERRIDE['v5.1'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v4.1'], { 407 createCloseButton: function () { 408 var $container = $('<div></div>'); 409 $container.addClass(this.getNamespace('close-button')); 410 var $icon = $('<button class="close" aria-label="close">x</button>'); 411 // $icon.append(this.options.closeIcon); 412 $container.append($icon); 413 $container.on('click', { dialog: this }, function (event) { 414 event.data.dialog.close(); 415 }); 416 417 return $container; 418 }, 419 }); 420 BootstrapDialog.prototype = { 421 constructor: BootstrapDialog, 422 initOptions: function (options) { 423 this.options = $.extend(true, this.defaultOptions, options); 424 425 return this; 426 }, 427 holdThisInstance: function () { 428 BootstrapDialog.addDialog(this); 429 430 return this; 431 }, 432 initModalStuff: function () { 433 434 435 this.setModal(this.createModal()) 436 .setModalDialog(this.createModalDialog()) 437 .setModalContent(this.createModalContent()) 438 .setModalHeader(this.createModalHeader()) 439 .setModalBody(this.createModalBody()) 440 .setModalFooter(this.createModalFooter()); 441 442 this.getModal().append(this.getModalDialog()); 443 this.getModalDialog().append(this.getModalContent()); 444 this.getModalContent() 445 .append(this.getModalHeader()) 446 .append(this.getModalBody()) 447 .append(this.getModalFooter()); 448 449 450 451 return this; 452 }, 453 createModal: function () { 454 var $modal = $('<div class="modal" role="dialog" aria-hidden="true"></div>'); 455 $modal.prop('id', this.getId()); 456 $modal.attr('aria-labelledby', this.getId() + '_title'); 457 458 return $modal; 459 }, 460 getModal: function () { 461 return this.$modal; 462 }, 463 setModal: function ($modal) { 464 this.$modal = $modal; 465 466 return this; 467 }, 468 getModalBackdrop: function ($modal) { //FIXME for BootstrapV4 469 return $modal.data('bs.modal').$backdrop; 470 }, 471 getModalForBootstrapDialogModal: function () { //FIXME for BootstrapV4 472 return this.getModal(); 473 }, 474 createModalDialog: function () { 475 return $('<div class="modal-dialog"></div>'); 476 }, 477 getModalDialog: function () { 478 return this.$modalDialog; 479 }, 480 setModalDialog: function ($modalDialog) { 481 this.$modalDialog = $modalDialog; 482 483 return this; 484 }, 485 createModalContent: function () { 486 return $('<div class="modal-content"></div>'); 487 }, 488 getModalContent: function () { 489 return this.$modalContent; 490 }, 491 setModalContent: function ($modalContent) { 492 this.$modalContent = $modalContent; 493 494 return this; 495 }, 496 createModalHeader: function () { 497 return $('<div class="modal-header"></div>'); 498 }, 499 getModalHeader: function () { 500 return this.$modalHeader; 501 }, 502 setModalHeader: function ($modalHeader) { 503 this.$modalHeader = $modalHeader; 504 505 return this; 506 }, 507 createModalBody: function () { 508 return $('<div class="modal-body"></div>'); 509 }, 510 getModalBody: function () { 511 return this.$modalBody; 512 }, 513 setModalBody: function ($modalBody) { 514 this.$modalBody = $modalBody; 515 516 return this; 517 }, 518 createModalFooter: function () { 519 return $('<div class="modal-footer"></div>'); 520 }, 521 getModalFooter: function () { 522 return this.$modalFooter; 523 }, 524 setModalFooter: function ($modalFooter) { 525 this.$modalFooter = $modalFooter; 526 527 return this; 528 }, 529 createDynamicContent: function (rawContent) { 530 var content = null; 531 if (typeof rawContent === 'function') { 532 content = rawContent.call(rawContent, this); 533 } else { 534 content = rawContent; 535 } 536 if (typeof content === 'string') { 537 content = this.formatStringContent(content); 538 } 539 540 return content; 541 }, 542 formatStringContent: function (content) { 543 if (this.options.nl2br) { 544 return content.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />'); 545 } 546 547 return content; 548 }, 549 setData: function (key, value) { 550 this.options.data[key] = value; 551 552 return this; 553 }, 554 getData: function (key) { 555 return this.options.data[key]; 556 }, 557 setId: function (id) { 558 this.options.id = id; 559 560 return this; 561 }, 562 getId: function () { 563 return this.options.id; 564 }, 565 getType: function () { 566 return this.options.type; 567 }, 568 setType: function (type) { 569 this.options.type = type; 570 this.updateType(); 571 572 return this; 573 }, 574 updateType: function () { 575 if (this.isRealized()) { 576 var types = [BootstrapDialog.TYPE_DEFAULT, 577 BootstrapDialog.TYPE_INFO, 578 BootstrapDialog.TYPE_PRIMARY, 579 BootstrapDialog.TYPE_SECONDARY, 580 BootstrapDialog.TYPE_SUCCESS, 581 BootstrapDialog.TYPE_WARNING, 582 BootstrapDialog.TYPE_DARK, 583 BootstrapDialog.TYPE_LIGHT, 584 BootstrapDialog.TYPE_DANGER]; 585 586 this.getModal().removeClass(types.join(' ')).addClass(this.getType()); 587 } 588 589 return this; 590 }, 591 getSize: function () { 592 return this.options.size; 593 }, 594 setSize: function (size) { 595 this.options.size = size; 596 this.updateSize(); 597 598 return this; 599 }, 600 updateSize: function () { 601 if (this.isRealized()) { 602 var dialog = this; 603 604 // Dialog size 605 this.getModal().removeClass(BootstrapDialog.SIZE_NORMAL) 606 .removeClass(BootstrapDialog.SIZE_SMALL) 607 .removeClass(BootstrapDialog.SIZE_WIDE) 608 .removeClass(BootstrapDialog.SIZE_EXTRAWIDE) 609 .removeClass(BootstrapDialog.SIZE_LARGE); 610 this.getModal().addClass(this.getSize()); 611 612 // Smaller dialog. 613 this.getModalDialog().removeClass('modal-sm'); 614 if (this.getSize() === BootstrapDialog.SIZE_SMALL) { 615 this.getModalDialog().addClass('modal-sm'); 616 } 617
vendor: 8,339 bytes, lines 618-869
618 // Wider dialog. 619 this.getModalDialog().removeClass('modal-lg'); 620 if (this.getSize() === BootstrapDialog.SIZE_WIDE) { 621 this.getModalDialog().addClass('modal-lg'); 622 } 623 // Extra Wide Dialog. 624 this.getModalDialog().removeClass('modal-xl'); 625 if (this.getSize() === BootstrapDialog.SIZE_EXTRAWIDE) { 626 this.getModalDialog().addClass('modal-xl'); 627 } 628 629 // Button size 630 $.each(this.options.buttons, function (index, button) { 631 var $button = dialog.getButton(button.id); 632 var buttonSizes = ['btn-lg', 'btn-sm', 'btn-xs']; 633 var sizeClassSpecified = false; 634 if (typeof button['cssClass'] === 'string') { 635 var btnClasses = button['cssClass'].split(' '); 636 $.each(btnClasses, function (index, btnClass) { 637 if ($.inArray(btnClass, buttonSizes) !== -1) { 638 sizeClassSpecified = true; 639 } 640 }); 641 } 642 if (!sizeClassSpecified) { 643 $button.removeClass(buttonSizes.join(' ')); 644 $button.addClass(dialog.getButtonSize()); 645 } 646 }); 647 } 648 649 return this; 650 }, 651 getCssClass: function () { 652 return this.options.cssClass; 653 }, 654 setCssClass: function (cssClass) { 655 this.options.cssClass = cssClass; 656 657 return this; 658 }, 659 getTitle: function () { 660 return this.options.title; 661 }, 662 setTitle: function (title) { 663 this.options.title = title; 664 this.updateTitle(); 665 666 return this; 667 }, 668 updateTitle: function () { 669 if (this.isRealized()) { 670 var title = this.getTitle() !== null ? this.createDynamicContent(this.getTitle()) : this.getDefaultText(); 671 this.getModalHeader().find('.' + this.getNamespace('title')).html('').append(title).prop('id', this.getId() + '_title'); 672 } 673 674 return this; 675 }, 676 getMessage: function () { 677 return this.options.message; 678 }, 679 setMessage: function (message) { 680 this.options.message = message; 681 this.updateMessage(); 682 683 return this; 684 }, 685 updateMessage: function () { 686 if (this.isRealized()) { 687 var message = this.createDynamicContent(this.getMessage()); 688 this.getModalBody().find('.' + this.getNamespace('message')).html('').append(message); 689 } 690 691 return this; 692 }, 693 isClosable: function () { 694 return this.options.closable; 695 }, 696 setClosable: function (closable) { 697 this.options.closable = closable; 698 this.updateClosable(); 699 700 return this; 701 }, 702 setCloseByBackdrop: function (closeByBackdrop) { 703 this.options.closeByBackdrop = closeByBackdrop; 704 705 return this; 706 }, 707 canCloseByBackdrop: function () { 708 return this.options.closeByBackdrop; 709 }, 710 setCloseByKeyboard: function (closeByKeyboard) { 711 this.options.closeByKeyboard = closeByKeyboard; 712 713 return this; 714 }, 715 canCloseByKeyboard: function () { 716 return this.options.closeByKeyboard; 717 }, 718 isAnimate: function () { 719 return this.options.animate; 720 }, 721 setAnimate: function (animate) { 722 this.options.animate = animate; 723 724 return this; 725 }, 726 updateAnimate: function () { 727 if (this.isRealized()) { 728 this.getModal().toggleClass('fade', this.isAnimate()); 729 } 730 731 return this; 732 }, 733 getSpinicon: function () { 734 return this.options.spinicon; 735 }, 736 setSpinicon: function (spinicon) { 737 this.options.spinicon = spinicon; 738 739 return this; 740 }, 741 addButton: function (button) { 742 this.options.buttons.push(button); 743 744 return this; 745 }, 746 addButtons: function (buttons) { 747 var that = this; 748 $.each(buttons, function (index, button) { 749 that.addButton(button); 750 }); 751 752 return this; 753 }, 754 getButtons: function () { 755 return this.options.buttons; 756 }, 757 setButtons: function (buttons) { 758 this.options.buttons = buttons; 759 this.updateButtons(); 760 761 return this; 762 }, 763 /** 764 * If there is id provided for a button option, it will be in dialog.indexedButtons list. 765 * 766 * In that case you can use dialog.getButton(id) to find the button. 767 * 768 * @param {type} id 769 * @returns {undefined} 770 */ 771 getButton: function (id) { 772 if (typeof this.indexedButtons[id] !== 'undefined') { 773 return this.indexedButtons[id]; 774 } 775 776 return null; 777 }, 778 getButtonSize: function () { 779 if (typeof BootstrapDialog.BUTTON_SIZES[this.getSize()] !== 'undefined') { 780 return BootstrapDialog.BUTTON_SIZES[this.getSize()]; 781 } 782 783 return ''; 784 }, 785 updateButtons: function () { 786 if (this.isRealized()) { 787 if (this.getButtons().length === 0) { 788 this.getModalFooter().hide(); 789 } else { 790 this.getModalFooter().show().closest('.modal-footer').append(this.createFooterButtons()); 791 } 792 } 793 794 return this; 795 }, 796 isAutodestroy: function () { 797 return this.options.autodestroy; 798 }, 799 setAutodestroy: function (autodestroy) { 800 this.options.autodestroy = autodestroy; 801 }, 802 getDescription: function () { 803 return this.options.description; 804 }, 805 setDescription: function (description) { 806 this.options.description = description; 807 808 return this; 809 }, 810 getVerticalCentered: function(){ 811 return this.options.verticalCentered; 812 }, 813 setVerticalCentered: function (verticalcentered) { 814 this.options.verticalCentered = verticalCentered; 815 816 return this; 817 }, 818 setTabindex: function (tabindex) { 819 this.options.tabindex = tabindex; 820 821 return this; 822 }, 823 getTabindex: function () { 824 return this.options.tabindex; 825 }, 826 updateTabindex: function () { 827 if (this.isRealized()) { 828 this.getModal().attr('tabindex', this.getTabindex()); 829 } 830 831 return this; 832 }, 833 getDefaultText: function () { 834 return BootstrapDialog.DEFAULT_TEXTS[this.getType()]; 835 }, 836 getNamespace: function (name) { 837 return BootstrapDialog.NAMESPACE + '-' + name; 838 }, 839 createHeaderContent: function () { 840 var $container = $('<div></div>'); 841 $container.addClass(this.getNamespace('header')); 842 843 // title 844 $container.append(this.createTitleContent()); 845 846 // Close button 847 $container.append(this.createCloseButton()); 848 849 return $container; 850 }, 851 createTitleContent: function () { 852 var $title = $('<div></div>'); 853 $title.addClass(this.getNamespace('title')); 854 855 return $title; 856 }, 857 createCloseButton: function () { 858 var $container = $('<div></div>'); 859 $container.addClass(this.getNamespace('close-button')); 860 var $icon = $('<button class="close" aria-label="close"></button>'); 861 $icon.append(this.options.closeIcon); 862 $container.append($icon); 863 $container.on('click', { dialog: this }, function (event) { 864 event.data.dialog.close(); 865 }); 866 867 return $container; 868 }, 869 createBodyContent: function () {
vendor: 16,591 bytes, lines 870-1330
870 var $container = $('<div></div>'); 871 $container.addClass(this.getNamespace('body')); 872 873 // Message 874 $container.append(this.createMessageContent()); 875 876 return $container; 877 }, 878 createMessageContent: function () { 879 var $message = $('<div></div>'); 880 $message.addClass(this.getNamespace('message')); 881 882 return $message; 883 }, 884 createFooterContent: function () { 885 var $container = $('<div></div>'); 886 $container.addClass(this.getNamespace('footer')); 887 888 return $container; 889 }, 890 createFooterButtons: function () { 891 var that = this; 892 893 var $container = that.$modalFooter;// $('<div></div>'); 894 //$container.addClass(this.getNamespace('footer-buttons')); 895 896 897 this.indexedButtons = {}; 898 $.each(this.options.buttons, function (index, button) { 899 if (!button.id) { 900 button.id = BootstrapDialog.newGuid(); 901 } 902 var $button = that.createButton(button); 903 that.indexedButtons[button.id] = $button; 904 $container.append($button); 905 }); 906 907 return $container; 908 }, 909 createButton: function (button) { 910 var $button = $('<button class="btn"></button>'); 911 $button.prop('id', button.id); 912 $button.data('button', button); 913 914 // Icon 915 if (typeof button.icon !== 'undefined' && $.trim(button.icon) !== '') { 916 $button.append(this.createButtonIcon(button.icon)); 917 } 918 919 // Label 920 if (typeof button.label !== 'undefined') { 921 $button.append(button.label); 922 } 923 924 // title 925 if (typeof button.title !== 'undefined') { 926 $button.attr('title', button.title); 927 } 928 929 // Css class 930 if (typeof button.cssClass !== 'undefined' && $.trim(button.cssClass) !== '') { 931 $button.addClass(button.cssClass); 932 } else { 933 $button.addClass('btn-secondary'); 934 } 935 936 // Data attributes 937 if (typeof button.data === 'object' && button.data.constructor === {}.constructor) { 938 $.each(button.data, function (key, value) { 939 $button.attr('data-' + key, value); 940 }); 941 } 942 943 // Hotkey 944 if (typeof button.hotkey !== 'undefined') { 945 this.registeredButtonHotkeys[button.hotkey] = $button; 946 } 947 948 // Button on click 949 $button.on('click', { dialog: this, $button: $button, button: button }, function (event) { 950 var dialog = event.data.dialog; 951 var $button = event.data.$button; 952 var button = $button.data('button'); 953 if (button.autospin) { 954 $button.toggleSpin(true); 955 } 956 if (typeof button.action === 'function') { 957 return button.action.call($button, dialog, event); 958 } 959 }); 960 961 // Dynamically add extra functions to $button 962 this.enhanceButton($button); 963 964 //Initialize enabled or not 965 if (typeof button.enabled !== 'undefined') { 966 $button.toggleEnable(button.enabled); 967 } 968 969 $button.addClass("bootstrap4-dialog-button"); 970 971 return $button; 972 }, 973 /** 974 * Dynamically add extra functions to $button 975 * 976 * Using '$this' to reference 'this' is just for better readability. 977 * 978 * @param {type} $button 979 * @returns {_L13.BootstrapDialog.prototype} 980 */ 981 enhanceButton: function ($button) { 982 $button.dialog = this; 983 984 // Enable / Disable 985 $button.toggleEnable = function (enable) { 986 var $this = this; 987 if (typeof enable !== 'undefined') { 988 $this.prop("disabled", !enable).toggleClass('disabled', !enable); 989 } else { 990 $this.prop("disabled", !$this.prop("disabled")); 991 } 992 993 return $this; 994 }; 995 $button.enable = function () { 996 var $this = this; 997 $this.toggleEnable(true); 998 999 return $this; 1000 }; 1001 $button.disable = function () { 1002 var $this = this; 1003 $this.toggleEnable(false); 1004 1005 return $this; 1006 }; 1007 1008 // Icon spinning, helpful for indicating ajax loading status. 1009 $button.toggleSpin = function (spin) { 1010 var $this = this; 1011 var dialog = $this.dialog; 1012 var $icon = $this.find('.' + dialog.getNamespace('button-icon')); 1013 if (typeof spin === 'undefined') { 1014 spin = !($button.find('.icon-spin').length > 0); 1015 } 1016 if (spin) { 1017 $icon.hide(); 1018 $button.prepend(dialog.createButtonIcon(dialog.getSpinicon()).addClass('icon-spin')); 1019 } else { 1020 $icon.show(); 1021 $button.find('.icon-spin').remove(); 1022 } 1023 1024 return $this; 1025 }; 1026 $button.spin = function () { 1027 var $this = this; 1028 $this.toggleSpin(true); 1029 1030 return $this; 1031 }; 1032 $button.stopSpin = function () { 1033 var $this = this; 1034 $this.toggleSpin(false); 1035 1036 return $this; 1037 }; 1038 1039 return this; 1040 }, 1041 createButtonIcon: function (icon) { 1042 var $icon = $('<span></span>'); 1043 $icon.addClass(this.getNamespace('button-icon')).addClass(icon); 1044 1045 return $icon; 1046 }, 1047 /** 1048 * Invoke this only after the dialog is realized. 1049 * 1050 * @param {type} enable 1051 * @returns {undefined} 1052 */ 1053 enableButtons: function (enable) { 1054 $.each(this.indexedButtons, function (id, $button) { 1055 $button.toggleEnable(enable); 1056 }); 1057 1058 return this; 1059 }, 1060 /** 1061 * Invoke this only after the dialog is realized. 1062 * 1063 * @returns {undefined} 1064 */ 1065 updateClosable: function () { 1066 if (this.isRealized()) { 1067 // Close button 1068 this.getModalHeader().find('.' + this.getNamespace('close-button')).toggle(this.isClosable()); 1069 } 1070 1071 return this; 1072 }, 1073 /** 1074 * Set handler for modal event 'show.bs.modal'. 1075 * This is a setter! 1076 */ 1077 onShow: function (onshow) { 1078 this.options.onshow = onshow; 1079 1080 return this; 1081 }, 1082 /** 1083 * Set handler for modal event 'shown.bs.modal'. 1084 * This is a setter! 1085 */ 1086 onShown: function (onshown) { 1087 this.options.onshown = onshown; 1088 1089 return this; 1090 }, 1091 /** 1092 * Set handler for modal event 'hide.bs.modal'. 1093 * This is a setter! 1094 */ 1095 onHide: function (onhide) { 1096 this.options.onhide = onhide; 1097 1098 return this; 1099 }, 1100 /** 1101 * Set handler for modal event 'hidden.bs.modal'. 1102 * This is a setter! 1103 */ 1104 onHidden: function (onhidden) { 1105 this.options.onhidden = onhidden; 1106 1107 return this; 1108 }, 1109 isRealized: function () { 1110 return this.realized; 1111 }, 1112 setRealized: function (realized) { 1113 this.realized = realized; 1114 1115 return this; 1116 }, 1117 isOpened: function () { 1118 return this.opened; 1119 }, 1120 setOpened: function (opened) { 1121 this.opened = opened; 1122 1123 return this; 1124 }, 1125 handleModalEvents: function () { 1126 this.getModal().on('show.bs.modal', { dialog: this }, function (event) { 1127 var dialog = event.data.dialog; 1128 dialog.setOpened(true); 1129 if (dialog.isModalEvent(event) && typeof dialog.options.onshow === 'function') { 1130 var openIt = dialog.options.onshow(dialog); 1131 if (openIt === false) { 1132 dialog.setOpened(false); 1133 } 1134 1135 return openIt; 1136 } 1137 }); 1138 this.getModal().on('shown.bs.modal', { dialog: this }, function (event) { 1139 var dialog = event.data.dialog; 1140 dialog.isModalEvent(event) && typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog); 1141 }); 1142 this.getModal().on('hide.bs.modal', { dialog: this }, function (event) { 1143 var dialog = event.data.dialog; 1144 dialog.setOpened(false); 1145 if (dialog.isModalEvent(event) && typeof dialog.options.onhide === 'function') { 1146 var hideIt = dialog.options.onhide(dialog); 1147 if (hideIt === false) { 1148 dialog.setOpened(true); 1149 } 1150 1151 return hideIt; 1152 } 1153 }); 1154 this.getModal().on('hidden.bs.modal', { dialog: this }, function (event) { 1155 var dialog = event.data.dialog; 1156 dialog.isModalEvent(event) && typeof dialog.options.onhidden === 'function' && dialog.options.onhidden(dialog); 1157 if (dialog.isAutodestroy()) { 1158 dialog.setRealized(false); 1159 delete BootstrapDialog.dialogs[dialog.getId()]; 1160 $(this).remove(); 1161 } 1162 BootstrapDialog.moveFocus(); 1163 if ($('.modal').hasClass('in') || $('.modal').hasClass('show')) { 1164 $('body').addClass('modal-open'); 1165 } 1166 }); 1167 1168 // ESC key support 1169 this.getModal().on('keyup', { dialog: this }, function (event) { 1170 event.which === 27 && event.data.dialog.isClosable() && event.data.dialog.canCloseByKeyboard() && event.data.dialog.close(); 1171 }); 1172 1173 // Button hotkey 1174 this.getModal().on('keyup', { dialog: this }, function (event) { 1175 var dialog = event.data.dialog; 1176 if (typeof dialog.registeredButtonHotkeys[event.which] !== 'undefined') { 1177 var $button = $(dialog.registeredButtonHotkeys[event.which]); 1178 !$button.prop('disabled') && !$button.is(':focus') && $button.focus().trigger('click'); 1179 } 1180 }); 1181 1182 return this; 1183 }, 1184 isModalEvent: function (event) { 1185 return typeof event.namespace !== 'undefined' && event.namespace === 'bs.modal'; 1186 }, 1187 makeModalDraggable: function () { 1188 if (this.options.draggable) { 1189 this.getModalHeader().addClass(this.getNamespace('draggable')).on('mousedown', { dialog: this }, function (event) { 1190 event.preventDefault(); 1191 var dialog = event.data.dialog; 1192 dialog.draggableData.isMouseDown = true; 1193 var dialogOffset = dialog.getModalDialog().offset(); 1194 dialog.draggableData.mouseOffset = { 1195 top: event.clientY - dialogOffset.top, 1196 left: event.clientX - dialogOffset.left 1197 }; 1198 }); 1199 this.getModal().on('mouseup', { dialog: this }, function (event) { 1200 event.data.dialog.draggableData.isMouseDown = false; 1201 }); 1202 $('body').on('mousemove', { dialog: this }, function (event) { 1203 var dialog = event.data.dialog; 1204 if (!dialog.draggableData.isMouseDown) { 1205 return; 1206 } 1207 dialog.getModalDialog().offset({ 1208 top: event.clientY - dialog.draggableData.mouseOffset.top, 1209 left: event.clientX - dialog.draggableData.mouseOffset.left 1210 }); 1211 }).on('mouseleave', { dialog: this }, function (event) { 1212 event.data.dialog.draggableData.isMouseDown = false; 1213 }); 1214 } 1215 1216 return this; 1217 }, 1218 realize: function () { 1219 this.initModalStuff(); 1220 this.getModal().addClass(BootstrapDialog.NAMESPACE) 1221 .addClass(this.getCssClass()); 1222 this.updateSize(); 1223 if (this.getDescription()) { 1224 this.getModal().attr('aria-describedby', this.getDescription()); 1225 } 1226 //this.getModalFooter().append(this.createFooterContent()); 1227 if(this.getVerticalCentered()){ 1228 this.getModalDialog().addClass('modal-dialog-centered'); 1229 } 1230 this.getModalHeader().append(this.createHeaderContent()); 1231 this.getModalBody().append(this.createBodyContent()); 1232 this.getModal().data('bs.modal', new BootstrapDialogModal(this.getModalForBootstrapDialogModal(), { //FIXME for BootstrapV4 1233 backdrop: (this.isClosable() && this.canCloseByBackdrop()) ? true : 'static', 1234 keyboard: false, 1235 show: false 1236 })); 1237 this.makeModalDraggable(); 1238 this.handleModalEvents(); 1239 this.setRealized(true); 1240 this.updateButtons(); 1241 this.updateType(); 1242 this.updateTitle(); 1243 this.updateMessage(); 1244 this.updateClosable(); 1245 this.updateAnimate(); 1246 this.updateSize(); 1247 this.updateTabindex(); 1248 1249 return this; 1250 }, 1251 open: function () { 1252 !this.isRealized() && this.realize(); 1253 this.getModal().modal('show'); 1254 1255 return this; 1256 }, 1257 close: function () { 1258 !this.isRealized() && this.realize(); 1259 this.getModal().modal('hide'); 1260 1261 return this; 1262 } 1263 }; 1264 1265 // Add compatible methods. 1266 BootstrapDialog.prototype = $.extend(BootstrapDialog.prototype, BootstrapDialog.METHODS_TO_OVERRIDE[BootstrapDialogModal.getModalVersion()]); 1267 1268 /** 1269 * RFC4122 version 4 compliant unique id creator. 1270 * 1271 * Added by https://github.com/tufanbarisyildirim/ 1272 * 1273 * @returns {String} 1274 */ 1275 BootstrapDialog.newGuid = function () { 1276 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 1277 var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8); 1278 return v.toString(16); 1279 }); 1280 }; 1281 1282 /* ================================================ 1283 * For lazy people 1284 * ================================================ */ 1285 1286 /** 1287 * Shortcut function: show 1288 * 1289 * @param {type} options 1290 * @returns the created dialog instance 1291 */ 1292 BootstrapDialog.show = function (options) { 1293 return new BootstrapDialog(options).open(); 1294 }; 1295 1296 /** 1297 * Alert window 1298 * 1299 * @returns the created dialog instance 1300 */ 1301 BootstrapDialog.alert = function () { 1302 var alertOptions = {}; 1303 var defaultAlertOptions = { 1304 type: BootstrapDialog.TYPE_PRIMARY, 1305 title: null, 1306 message: null, 1307 closable: false, 1308 draggable: false, 1309 buttonLabel: BootstrapDialog.DEFAULT_TEXTS.OK, 1310 buttonHotkey: null, 1311 callback: null 1312 }; 1313 1314 if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { 1315 alertOptions = $.extend(true, defaultAlertOptions, arguments[0]); 1316 } else { 1317 alertOptions = $.extend(true, defaultAlertOptions, { 1318 message: arguments[0], 1319 callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null 1320 }); 1321 } 1322 1323 var dialog = new BootstrapDialog(alertOptions); 1324 dialog.setData('callback', alertOptions.callback); 1325 dialog.addButton({ 1326 label: alertOptions.buttonLabel, 1327 hotkey: alertOptions.buttonHotkey, 1328 action: function (dialog) { 1329 if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, true) === false) { 1330 return false;
vendor: 4,643 bytes, lines 1331-1476
1331 } 1332 dialog.setData('btnClicked', true); 1333 1334 return dialog.close(); 1335 } 1336 }); 1337 if (typeof dialog.options.onhide === 'function') { 1338 dialog.onHide(function (dialog) { 1339 var hideIt = true; 1340 if (!dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function') { 1341 hideIt = dialog.getData('callback')(false); 1342 } 1343 if (hideIt === false) { 1344 return false; 1345 } 1346 hideIt = this.onhide(dialog); 1347 1348 return hideIt; 1349 }.bind({ 1350 onhide: dialog.options.onhide 1351 })); 1352 } else { 1353 dialog.onHide(function (dialog) { 1354 var hideIt = true; 1355 if (!dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function') { 1356 hideIt = dialog.getData('callback')(false); 1357 } 1358 1359 return hideIt; 1360 }); 1361 } 1362 1363 return dialog.open(); 1364 }; 1365 1366 /** 1367 * Confirm window 1368 * 1369 * @returns the created dialog instance 1370 */ 1371 BootstrapDialog.confirm = function () { 1372 var confirmOptions = {}; 1373 var defaultConfirmOptions = { 1374 type: BootstrapDialog.TYPE_PRIMARY, 1375 title: null, 1376 message: null, 1377 closable: false, 1378 draggable: false, 1379 btnCancelLabel: BootstrapDialog.DEFAULT_TEXTS.CANCEL, 1380 btnCancelClass: null, 1381 btnCancelHotkey: null, 1382 btnOKLabel: BootstrapDialog.DEFAULT_TEXTS.OK, 1383 btnOKClass: null, 1384 btnOKHotkey: null, 1385 btnsOrder: BootstrapDialog.defaultOptions.btnsOrder, 1386 callback: null 1387 }; 1388 if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { 1389 confirmOptions = $.extend(true, defaultConfirmOptions, arguments[0]); 1390 } else { 1391 confirmOptions = $.extend(true, defaultConfirmOptions, { 1392 message: arguments[0], 1393 callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null 1394 }); 1395 } 1396 if (confirmOptions.btnOKClass === null) { 1397 confirmOptions.btnOKClass = ['btn', confirmOptions.type.split('-')[1]].join('-'); 1398 } 1399 1400 var dialog = new BootstrapDialog(confirmOptions); 1401 dialog.setData('callback', confirmOptions.callback); 1402 1403 var buttons = [{ 1404 label: confirmOptions.btnCancelLabel, 1405 cssClass: confirmOptions.btnCancelClass, 1406 hotkey: confirmOptions.btnCancelHotkey, 1407 action: function (dialog) { 1408 if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, false) === false) { 1409 return false; 1410 } 1411 1412 return dialog.close(); 1413 } 1414 }, { 1415 label: confirmOptions.btnOKLabel, 1416 cssClass: confirmOptions.btnOKClass, 1417 hotkey: confirmOptions.btnOKHotkey, 1418 action: function (dialog) { 1419 if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, true) === false) { 1420 return false; 1421 } 1422 1423 return dialog.close(); 1424 } 1425 }]; 1426 if (confirmOptions.btnsOrder === BootstrapDialog.BUTTONS_ORDER_OK_CANCEL) { 1427 buttons.reverse(); 1428 } 1429 dialog.addButtons(buttons); 1430 1431 return dialog.open(); 1432 1433 }; 1434 1435 /** 1436 * Warning window 1437 * 1438 * @param {type} message 1439 * @returns the created dialog instance 1440 */ 1441 BootstrapDialog.warning = function (message, callback) { 1442 return new BootstrapDialog({ 1443 type: BootstrapDialog.TYPE_WARNING, 1444 message: message 1445 }).open(); 1446 }; 1447 1448 /** 1449 * Danger window 1450 * 1451 * @param {type} message 1452 * @returns the created dialog instance 1453 */ 1454 BootstrapDialog.danger = function (message, callback) { 1455 return new BootstrapDialog({ 1456 type: BootstrapDialog.TYPE_DANGER, 1457 message: message 1458 }).open(); 1459 }; 1460 1461 /** 1462 * Success window 1463 * 1464 * @param {type} message 1465 * @returns the created dialog instance 1466 */ 1467 BootstrapDialog.success = function (message, callback) { 1468 return new BootstrapDialog({ 1469 type: BootstrapDialog.TYPE_SUCCESS, 1470 message: message 1471 }).open(); 1472 }; 1473 1474 return BootstrapDialog; 1475 1476}));
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.