index.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="assets/jquery/jquery-1.10.2.min.js"></script>
  5. <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  6. <script src="assets/bootstrap/js/bootstrap.min.js"></script>
  7. <script src="assets/prettify/run_prettify.js"></script>
  8. <link href="assets/bootstrap-dialog/css/bootstrap-dialog.css" rel="stylesheet" type="text/css" />
  9. <script src="assets/bootstrap-dialog/js/bootstrap-dialog.js"></script>
  10. <meta charset="utf-8" />
  11. <title>BootstrapDialog examples</title>
  12. </head>
  13. <body style="padding-bottom: 100px;">
  14. <div class="container">
  15. <h2>Make use of Twitter Bootstrap's modal more monkey-friendly.</h2>
  16. <hr />
  17. <p>
  18. Monkeys love the <a href="http://getbootstrap.com/javascript/#modals" target="_blank">Modal Dialog from Twitter Bootstrap</a>, but they're getting angry because they have to write this stuff:
  19. </p>
  20. <pre class="prettyprint">&lt;div class="modal fade"&gt;<br /> &lt;div class="modal-dialog"&gt;<br /> &lt;div class="modal-content"&gt;<br /> &lt;div class="modal-header"&gt;<br /> &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&times;&lt;/button&gt;<br /> &lt;h4 class="modal-title"&gt;Modal title&lt;/h4&gt;<br /> &lt;/div&gt;<br /> &lt;div class="modal-body"&gt;<br /> &lt;p&gt;One fine body&hellip;&lt;/p&gt;<br /> &lt;/div&gt;<br /> &lt;div class="modal-footer"&gt;<br /> &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;<br /> &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;<br /> &lt;/div&gt;<br /> &lt;/div&gt;&lt;!-- /.modal-content --&gt;<br /> &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;<br />&lt;/div&gt;&lt;!-- /.modal --&gt;
  21. </pre>
  22. <p>
  23. What they want is more like this:
  24. </p>
  25. <div class="source-code runnable">
  26. BootstrapDialog.alert('I want banana!');
  27. </div>
  28. <p></p>
  29. <p>
  30. Like it? See <a href="#available-options">Available Options</a> or try more <a href="#examples">Examples</a> below.
  31. </p>
  32. <!-- Examples -->
  33. <a name="examples"></a>
  34. <h2>Examples</h2>
  35. <hr />
  36. <h3>Simplest</h3>
  37. <p>Provide only the message to show, and keep all other things default.</p>
  38. <div class="source-code runnable">
  39. <!--
  40. BootstrapDialog.show({
  41. message: 'Hi Apple!'
  42. });
  43. -->
  44. </div>
  45. <h3>Title</h3>
  46. <div class="source-code runnable">
  47. <!--
  48. BootstrapDialog.show({
  49. title: 'Say-hello dialog',
  50. message: 'Hi Apple!'
  51. });
  52. -->
  53. </div>
  54. <h3>Buttons</h3>
  55. <div class="source-code runnable">
  56. <!--
  57. BootstrapDialog.show({
  58. message: 'Hi Apple!',
  59. buttons: [{
  60. label: 'Button 1'
  61. }, {
  62. label: 'Button 2',
  63. cssClass: 'btn-primary',
  64. action: function(){
  65. alert('Hi Orange!');
  66. }
  67. }, {
  68. icon: 'glyphicon glyphicon-ban-circle',
  69. label: 'Button 3',
  70. cssClass: 'btn-warning'
  71. }, {
  72. label: 'Close',
  73. action: function(dialogItself){
  74. dialogItself.close();
  75. }
  76. }]
  77. });
  78. -->
  79. </div>
  80. <h3>Creating dialog instances</h3>
  81. <p>BootstrapDialog.show(...) is just a shortcut method, if you need dialog instances, use 'new'.</p>
  82. <div class="source-code runnable">
  83. <!--
  84. // Using init options
  85. var dialogInstance1 = new BootstrapDialog({
  86. title: 'Dialog instance 1',
  87. message: 'Hi Apple!'
  88. });
  89. dialogInstance1.open();
  90. // Construct by using setters
  91. var dialogInstance2 = new BootstrapDialog();
  92. dialogInstance2.setTitle('Dialog instance 2');
  93. dialogInstance2.setMessage('Hi Orange!');
  94. dialogInstance2.setType(BootstrapDialog.TYPE_SUCCESS);
  95. dialogInstance2.open();
  96. // Using chain callings
  97. var dialogInstance3 = new BootstrapDialog()
  98. .setTitle('Dialog instance 3')
  99. .setMessage('Hi Everybody!')
  100. .setType(BootstrapDialog.TYPE_INFO)
  101. .open();
  102. -->
  103. </div>
  104. <h3>Open / Close multiple dialogs</h3>
  105. <p>This example demonstrates opening and closing a batch of dialogs at one time. <br />Dialog that created by BootstrapDialog will be in a container <strong>BootstrapDialog.dialogs</strong> before it's closed and destroyed, iterate <strong>BootstrapDialog.dialogs</strong> to find all dialogs that havn't been destroyed.</p>
  106. <div class="source-code runnable">
  107. <!--
  108. var howManyDialogs = 5;
  109. for(var i = 1; i <= howManyDialogs; i++) {
  110. var dialog = new BootstrapDialog({
  111. title: 'Dialog No.' + i,
  112. message: 'Hello Houston, this is dialog No.' + i,
  113. buttons: [{
  114. label: 'Close this dialog.',
  115. action: function(dialogRef){
  116. dialogRef.close();
  117. }
  118. }, {
  119. label: 'Close ALL opened dialogs',
  120. cssClass: 'btn-warning',
  121. action: function(){
  122. $.each(BootstrapDialog.dialogs, function(id, dialog){
  123. dialog.close();
  124. });
  125. }
  126. }]
  127. });
  128. dialog.open();
  129. }
  130. -->
  131. </div>
  132. <h3>Button with identifier</h3>
  133. <div class="source-code runnable">
  134. <!--
  135. var dialog = new BootstrapDialog({
  136. message: 'Hi Apple!',
  137. buttons: [{
  138. id: 'btn-1',
  139. label: 'Button 1'
  140. }]
  141. });
  142. dialog.realize();
  143. var btn1 = dialog.getButton('btn-1');
  144. btn1.click({'name': 'Apple'}, function(event){
  145. alert('Hi, ' + event.data.name);
  146. });
  147. dialog.open();
  148. -->
  149. </div>
  150. <h3>Message types</h3>
  151. <div class="source-code runnable">
  152. <!--
  153. var types = [BootstrapDialog.TYPE_DEFAULT,
  154. BootstrapDialog.TYPE_INFO,
  155. BootstrapDialog.TYPE_PRIMARY,
  156. BootstrapDialog.TYPE_SUCCESS,
  157. BootstrapDialog.TYPE_WARNING,
  158. BootstrapDialog.TYPE_DANGER];
  159. $.each(types, function(index, type){
  160. BootstrapDialog.show({
  161. type: type,
  162. title: 'Message type: ' + type,
  163. message: 'What to do next?',
  164. buttons: [{
  165. label: 'I do nothing.'
  166. }]
  167. });
  168. });
  169. -->
  170. </div>
  171. <h3>Larger dialog</h3>
  172. <p>
  173. By default, the dialog size is 'size-normal' or BootstrapDialog.SIZE_NORMAL, but you can have a larger dialog by setting option 'size' to 'size-large' or BootstrapDialog.SIZE_LARGE.
  174. </p>
  175. <div class="source-code runnable">
  176. <!--
  177. BootstrapDialog.show({
  178. size: BootstrapDialog.SIZE_LARGE,
  179. message: 'Hi Apple!',
  180. buttons: [{
  181. label: 'Button 1'
  182. }, {
  183. label: 'Button 2',
  184. cssClass: 'btn-primary',
  185. action: function(){
  186. alert('Hi Orange!');
  187. }
  188. }, {
  189. icon: 'glyphicon glyphicon-ban-circle',
  190. label: 'Button 3',
  191. cssClass: 'btn-warning'
  192. }, {
  193. label: 'Close',
  194. action: function(dialogItself){
  195. dialogItself.close();
  196. }
  197. }]
  198. });
  199. -->
  200. </div>
  201. <h3>Rich message</h3>
  202. <p>BootstrapDialog supports displaying rich content, so you can even use a video clip as your message in the dialog.</p>
  203. <div class="source-code runnable">
  204. <!--
  205. var $textAndPic = $('<div></div>');
  206. $textAndPic.append('Who\'s this? <br />');
  207. $textAndPic.append('<img src="./images/pig.ico" />');
  208. BootstrapDialog.show({
  209. title: 'Guess who that is',
  210. message: $textAndPic,
  211. buttons: [{
  212. label: 'Acky',
  213. action: function(dialogRef){
  214. dialogRef.close();
  215. }
  216. }, {
  217. label: 'Robert',
  218. action: function(dialogRef){
  219. dialogRef.close();
  220. }
  221. }]
  222. });
  223. -->
  224. </div>
  225. <h3>Dialog closable / unclosable</h3>
  226. <p>
  227. If option 'closable' is set to false, the default closing behaviors will be disabled, but you can still close the dialog by using dialog.close().
  228. </p>
  229. <div class="source-code runnable">
  230. <!--
  231. BootstrapDialog.show({
  232. message: 'Hi Apple!',
  233. closable: false,
  234. buttons: [{
  235. label: 'Dialog CLOSABLE!',
  236. cssClass: 'btn-success',
  237. action: function(dialogRef){
  238. dialogRef.setClosable(true);
  239. }
  240. }, {
  241. label: 'Dialog UNCLOSABLE!',
  242. cssClass: 'btn-warning',
  243. action: function(dialogRef){
  244. dialogRef.setClosable(false);
  245. }
  246. }, {
  247. label: 'Close the dialog',
  248. action: function(dialogRef){
  249. dialogRef.close();
  250. }
  251. }]
  252. });
  253. -->
  254. </div>
  255. <h3>Auto spinning icon</h3>
  256. <p>
  257. Lazy guys must love this.
  258. </p>
  259. <div class="source-code runnable">
  260. <!--
  261. BootstrapDialog.show({
  262. message: 'I send ajax request!',
  263. buttons: [{
  264. icon: 'glyphicon glyphicon-send',
  265. label: 'Send ajax request',
  266. cssClass: 'btn-primary',
  267. autospin: true,
  268. action: function(dialogRef){
  269. dialogRef.enableButtons(false);
  270. dialogRef.setClosable(false);
  271. dialogRef.getModalBody().html('Dialog closes in 5 seconds.');
  272. setTimeout(function(){
  273. dialogRef.close();
  274. }, 5000);
  275. }
  276. }, {
  277. label: 'Close',
  278. action: function(dialogRef){
  279. dialogRef.close();
  280. }
  281. }]
  282. });
  283. -->
  284. </div>
  285. <h3>Manipulating your dialog</h3>
  286. <div class="source-code runnable">
  287. <!--
  288. var dialog = new BootstrapDialog({
  289. message: function(dialogRef){
  290. var $message = $('<div>OK, this dialog has no header and footer, but you can close the dialog using this button: </div>');
  291. var $button = $('<button class="btn btn-primary btn-lg btn-block">Close the dialog</button>');
  292. $button.on('click', {dialogRef: dialogRef}, function(event){
  293. event.data.dialogRef.close();
  294. });
  295. $message.append($button);
  296. return $message;
  297. },
  298. closable: false
  299. });
  300. dialog.realize();
  301. dialog.getModalHeader().hide();
  302. dialog.getModalFooter().hide();
  303. dialog.getModalBody().css('background-color', '#0088cc');
  304. dialog.getModalBody().css('color', '#fff');
  305. dialog.open();
  306. -->
  307. </div>
  308. <h3>Data binding</h3>
  309. <div class="source-code runnable">
  310. <!--
  311. var data1 = 'Apple';
  312. var data2 = 'Orange';
  313. var data3 = ['Banana', 'Pear'];
  314. BootstrapDialog.show({
  315. message: 'Hi Apple!',
  316. data: {
  317. 'data1': data1,
  318. 'data2': data2,
  319. 'data3': data3
  320. },
  321. buttons: [{
  322. label: 'See what you got',
  323. cssClass: 'btn-primary',
  324. action: function(dialogRef){
  325. alert(dialogRef.getData('data1'));
  326. alert(dialogRef.getData('data2'));
  327. alert(dialogRef.getData('data3').join(', '));
  328. }
  329. }]
  330. });
  331. -->
  332. </div>
  333. <h3>Dialog events</h3>
  334. <p>
  335. Two dialog level events are supported currently: onshow, onhide. <br />
  336. Please note that if you're going to use setters to configure event handlers, use dialog.onShow(function) and dialog.onHide(function).
  337. </p>
  338. <div class="source-code runnable">
  339. <!--
  340. BootstrapDialog.show({
  341. message: 'Hello world!',
  342. onshow: function(dialogRef){
  343. alert('Dialog is popping up, its message is ' + dialogRef.getMessage());
  344. },
  345. onhide: function(dialogRef){
  346. alert('Dialog is popping down, its message is ' + dialogRef.getMessage());
  347. }
  348. });
  349. -->
  350. </div>
  351. <h2>More shortcut methods</h2>
  352. <hr />
  353. <h3>Alert</h3>
  354. <div class="source-code runnable">
  355. <!--
  356. BootstrapDialog.alert('Hi Apple!');
  357. -->
  358. </div>
  359. <h3>Alert with callback</h3>
  360. <div class="source-code runnable">
  361. <!--
  362. BootstrapDialog.alert('Hi Apple!', function(){
  363. alert('Hi Orange!');
  364. });
  365. -->
  366. </div>
  367. <h3>Confirm</h3>
  368. <div class="source-code runnable">
  369. <!--
  370. BootstrapDialog.confirm('Hi Apple, are you sure?');
  371. -->
  372. </div>
  373. <h3>Confirm with callback</h3>
  374. <div class="source-code runnable">
  375. <!--
  376. BootstrapDialog.confirm('Hi Apple, are you sure?', function(result){
  377. if(result) {
  378. alert('Yup.');
  379. }else {
  380. alert('Nope.');
  381. }
  382. });
  383. -->
  384. </div>
  385. <h3>Source code of the shortcut methods above</h3>
  386. <p>
  387. I mean you can write your owned handy stuff :)
  388. </p>
  389. <div class="source-code">
  390. <!--
  391. /**
  392. * Alert window
  393. *
  394. * @param {type} message
  395. * @param {type} callback
  396. * @returns {undefined}
  397. */
  398. BootstrapDialog.alert = function(message, callback) {
  399. new BootstrapDialog({
  400. message: message,
  401. data: {
  402. 'callback': callback
  403. },
  404. closable: false,
  405. buttons: [{
  406. label: 'OK',
  407. action: function(dialog) {
  408. typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
  409. dialog.close();
  410. }
  411. }]
  412. }).open();
  413. };
  414. /**
  415. * Confirm window
  416. *
  417. * @param {type} message
  418. * @param {type} callback
  419. * @returns {undefined}
  420. */
  421. BootstrapDialog.confirm = function(message, callback) {
  422. new BootstrapDialog({
  423. title: 'Confirmation',
  424. message: message,
  425. closable: false,
  426. data: {
  427. 'callback': callback
  428. },
  429. buttons: [{
  430. label: 'Cancel',
  431. action: function(dialog) {
  432. typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
  433. dialog.close();
  434. }
  435. }, {
  436. label: 'OK',
  437. cssClass: 'btn-primary',
  438. action: function(dialog) {
  439. typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
  440. dialog.close();
  441. }
  442. }]
  443. }).open();
  444. };
  445. -->
  446. </div>
  447. <!-- Available options -->
  448. <a name="available-options"></a>
  449. <h2>Available options</h2>
  450. <hr />
  451. <p>
  452. Please note that all options described below are <strong>optional</strong>, but you will have a weird dialog if you don't even give it a message to display.
  453. <br />
  454. Most options can be set via init options or property setters.
  455. </p>
  456. <table class="table table-bordered">
  457. <thead>
  458. <tr>
  459. <th>
  460. Option
  461. </th>
  462. <th>
  463. Possible values
  464. </th>
  465. <th>
  466. Description
  467. </th>
  468. </tr>
  469. </thead>
  470. <tbody>
  471. <tr>
  472. <td>type</td>
  473. <td>
  474. BootstrapDialog.TYPE_DEFAULT or 'type-default' <br />
  475. BootstrapDialog.TYPE_INFO or 'type-info' <br />
  476. <strong>BootstrapDialog.TYPE_PRIMARY or 'type-primary' (default)</strong> <br />
  477. BootstrapDialog.TYPE_SUCCESS or 'type-success' <br />
  478. BootstrapDialog.TYPE_WARNING or 'type-warning' <br />
  479. BootstrapDialog.TYPE_DANGER or 'type-danger'
  480. </td>
  481. <td>
  482. Give your dialog a specific look, color scheme can be seen on <a href="http://getbootstrap.com/css/#buttons" target="_blank">Bootstrap's Button</a>.
  483. </td>
  484. </tr>
  485. <tr>
  486. <td>size</td>
  487. <td>
  488. <strong>BootstrapDialog.SIZE_NORMAL or 'size-normal' (default)</strong> <br />
  489. BootstrapDialog.SIZE_LARGE or 'size-large' <br />
  490. </td>
  491. <td>
  492. -
  493. </td>
  494. </tr>
  495. <tr>
  496. <td>title</td>
  497. <td>
  498. String or Object(html)
  499. </td>
  500. <td>
  501. -
  502. </td>
  503. </tr>
  504. <tr>
  505. <td>message</td>
  506. <td>
  507. String or Object(html)
  508. </td>
  509. <td>
  510. -
  511. </td>
  512. </tr>
  513. <tr>
  514. <td>buttons</td>
  515. <td>
  516. array
  517. </td>
  518. <td>
  519. Examples:
  520. <div class="source-code runnable">
  521. BootstrapDialog.show({
  522. title: 'Say-hello dialog',
  523. message: 'Hello world!',
  524. buttons: [{
  525. id: 'btn-ok',
  526. icon: 'glyphicon glyphicon-check',
  527. label: 'OK',
  528. cssClass: 'btn-primary',
  529. autospin: false,
  530. action: function(dialogRef){
  531. dialogRef.close();
  532. }
  533. }]
  534. });
  535. </div>
  536. <strong>id</strong>: optional, if id is set, you can use dialogInstance.getButton(id) to get the button later. <br />
  537. <strong>icon</strong>: optional, if set, the specified icon will be added to the button. <br />
  538. <strong>cssClass</strong>: optinal, additional css class to be added to the button. <br />
  539. <strong>autospin</strong>: optinal, if it's true, after clicked the button a spinning icon appears. <br />
  540. <strong>action</strong>: optional, if provided, the callback will be invoked after the button is clicked, and the dialog instance will be passed to the callback function.
  541. </td>
  542. </tr>
  543. <tr>
  544. <td>closable</td>
  545. <td>
  546. true | false
  547. </td>
  548. <td>
  549. When set to <strong>true</strong>, you can close the dialog by: <br />
  550. <ul>
  551. <li>Clicking the close icon in dialog header.</li>
  552. <li>Clicking outside the dialog.</li>
  553. <li>ESC key.</li>
  554. </ul>
  555. </td>
  556. </tr>
  557. <tr>
  558. <td>spinicon</td>
  559. <td>
  560. Icon class name, for example 'glyphicon glyphicon-check'. <br />
  561. <strong>Default value is 'glyphicon glyphicon-asterisk'.</strong>
  562. </td>
  563. <td>
  564. Specify what icon to be used as the spinning icon when button's 'autospin' is set to true.
  565. </td>
  566. </tr>
  567. <tr>
  568. <td>data</td>
  569. <td>
  570. Key-value object. For example {'id' : '100'}
  571. </td>
  572. <td>
  573. Data to be bound to the dialog.
  574. </td>
  575. </tr>
  576. <tr>
  577. <td>onshow</td>
  578. <td>
  579. function
  580. </td>
  581. <td>
  582. If provided, it will be invoked when the dialog is popping up. <br />
  583. </td>
  584. </tr>
  585. <tr>
  586. <td>onhide</td>
  587. <td>
  588. function
  589. </td>
  590. <td>
  591. If provided, it will be invoked when the dialog is popping down. <br />
  592. </td>
  593. </tr>
  594. <tr>
  595. <td>autodestroy</td>
  596. <td>
  597. <strong>true (default)</strong> | false
  598. </td>
  599. <td>
  600. When it's true, all modal stuff will be removed from the DOM tree after the dialog is popped down, set it to false if you need your dialog (same instance) pups up and down again and again.
  601. </td>
  602. </tr>
  603. </tbody>
  604. </table>
  605. <!-- Available methods -->
  606. <a name="available-methods"></a>
  607. <h2>Available methods</h2>
  608. <hr />
  609. <table class="table table-bordered">
  610. <thead>
  611. <tr>
  612. <th>
  613. Method
  614. </th>
  615. <th>
  616. Description
  617. </th>
  618. </tr>
  619. </thead>
  620. <tbody>
  621. <tr>
  622. <td>open()</td>
  623. <td>Open the dialog. Usage: dialogInstance.open()</td>
  624. </tr>
  625. <tr>
  626. <td>close()</td>
  627. <td>Close the dialog. Usage: dialogInstance.close()</td>
  628. </tr>
  629. <tr>
  630. <td>getModal()</td>
  631. <td>Return the raw modal, equivalent to $('&lt;div class='modal fade'...&gt;&lt;/div&gt;')</td>
  632. </tr>
  633. <tr>
  634. <td>getModalDialog()</td>
  635. <td>Return the raw modal dialog.</td>
  636. </tr>
  637. <tr>
  638. <td>getModalContent()</td>
  639. <td>Return the raw modal content.</td>
  640. </tr>
  641. <tr>
  642. <td>getModalHeader()</td>
  643. <td>Return the raw modal header.</td>
  644. </tr>
  645. <tr>
  646. <td>getModalBody()</td>
  647. <td>Return the raw modal body.</td>
  648. </tr>
  649. <tr>
  650. <td>getModalFooter()</td>
  651. <td>Return the raw modal footer.</td>
  652. </tr>
  653. <tr>
  654. <td>getData(key)</td>
  655. <td>Get data entry according to the given key, returns null if no data entry found.</td>
  656. </tr>
  657. <tr>
  658. <td>setData(key, value)</td>
  659. <td>Bind data entry to dialog instance, value can be any types that javascript supports. </td>
  660. </tr>
  661. <tr>
  662. <td>enableButtons(boolean)</td>
  663. <td>Disable all buttons in dialog footer when it's false, enable all when it's true.</td>
  664. </tr>
  665. <tr>
  666. <td>setClosable(boolean)</td>
  667. <td>When set to true (default), dialog can be closed by clicking close icon in dialog header, or by clicking outside the dialog, or, ESC key is pressed.</td>
  668. </tr>
  669. <tr>
  670. <td>realize()</td>
  671. <td>Calling dialog.open() will automatically get this method called first, but if you want to do something on your dialog before it's shown, you can manually call dialog.realize() before calling dialog.open().</td>
  672. </tr>
  673. </tbody>
  674. </table>
  675. <hr />
  676. <footer class="text-center"><a href="https://github.com/nakupanda/bootstrap3-dialog">Go to the project.</a> | <a href="mailto:javanoob@hotmail.com">Contact me</a> if you can help to improve this example page.</footer>
  677. </div>
  678. <script type="text/javascript">
  679. $(function(){
  680. $('.source-code').each(function(index){
  681. var $section = $(this);
  682. var code = $(this).html().replace('<!--', '').replace('-->', '');
  683. // Code preview
  684. var $codePreview = $('<pre class="prettyprint lang-javascript"></pre>');
  685. $codePreview.text(code);
  686. $section.html($codePreview);
  687. // Run code
  688. if($section.hasClass('runnable')){
  689. var $button = $('<button class="btn btn-primary">Run the code</button>');
  690. $button.on('click', {code: code}, function(event){
  691. eval(event.data.code);
  692. });
  693. $button.insertAfter($section);
  694. $('<div class="clearfix" style="margin-bottom: 10px;"></div>').insertAfter($button);
  695. }
  696. });
  697. });
  698. </script>
  699. </body>
  700. </html>