bootstrap-dialog.js 46 KB

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