Browse Source

Two more events are supported: onshown, onhidden.

Dante 11 years ago
parent
commit
e5def1f618

+ 29 - 9
examples/assets/bootstrap-dialog/js/bootstrap-dialog.js

@@ -19,7 +19,9 @@
             buttons: [],
             buttons: [],
             data: {},
             data: {},
             onshow: null,
             onshow: null,
-            onhide: null
+            onshown: null,
+            onhide: null,
+            onhidden: null
         }, BootstrapDialog.defaultOptions);
         }, BootstrapDialog.defaultOptions);
         this.indexedButtons = {};
         this.indexedButtons = {};
         this.registeredButtonHotkeys = {};
         this.registeredButtonHotkeys = {};
@@ -582,11 +584,8 @@
             return this;
             return this;
         },
         },
         /**
         /**
-         * Set handler for modal event 'show'.
+         * Set handler for modal event 'show.bs.modal'.
          * This is a setter!
          * This is a setter!
-         * 
-         * @param {type} onopen
-         * @returns {_L9.BootstrapDialog.prototype}
          */
          */
         onShow: function(onshow) {
         onShow: function(onshow) {
             this.options.onshow = onshow;
             this.options.onshow = onshow;
@@ -594,17 +593,32 @@
             return this;
             return this;
         },
         },
         /**
         /**
-         * Set handler for modal event 'hide'.
+         * Set handler for modal event 'shown.bs.modal'.
+         * This is a setter!
+         */
+        onShown: function(onshown) {
+            this.options.onshown = onshown;
+
+            return this;
+        },
+        /**
+         * Set handler for modal event 'hide.bs.modal'.
          * This is a setter!
          * This is a setter!
-         * 
-         * @param {type} onclose
-         * @returns {_L9.BootstrapDialog.prototype}
          */
          */
         onHide: function(onhide) {
         onHide: function(onhide) {
             this.options.onhide = onhide;
             this.options.onhide = onhide;
 
 
             return this;
             return this;
         },
         },
+        /**
+         * Set handler for modal event 'hidden.bs.modal'.
+         * This is a setter!
+         */
+        onHidden: function(onhidden) {
+            this.options.onhidden = onhidden;
+
+            return this;
+        },
         isRealized: function() {
         isRealized: function() {
             return this.realized;
             return this.realized;
         },
         },
@@ -627,12 +641,18 @@
                 typeof dialog.options.onshow === 'function' && dialog.options.onshow(dialog);
                 typeof dialog.options.onshow === 'function' && dialog.options.onshow(dialog);
                 dialog.showPageScrollBar(true);
                 dialog.showPageScrollBar(true);
             });
             });
+            this.getModal().on('shown.bs.modal', {dialog: this}, function(event) {
+                var dialog = event.data.dialog;
+                typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog);
+                dialog.showPageScrollBar(true);
+            });
             this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
             this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 var dialog = event.data.dialog;
                 typeof dialog.options.onhide === 'function' && dialog.options.onhide(dialog);
                 typeof dialog.options.onhide === 'function' && dialog.options.onhide(dialog);
             });
             });
             this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
             this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 var dialog = event.data.dialog;
+                typeof dialog.options.onhidden === 'function' && dialog.options.onhidden(dialog);
                 dialog.isAutodestroy() && $(this).remove();
                 dialog.isAutodestroy() && $(this).remove();
                 dialog.showPageScrollBar(false);
                 dialog.showPageScrollBar(false);
             });
             });

File diff suppressed because it is too large
+ 1 - 1
examples/assets/bootstrap-dialog/js/bootstrap-dialog.min.js


+ 24 - 1
examples/index.html

@@ -557,7 +557,6 @@
     
     
     <h3>Dialog events</h3>
     <h3>Dialog events</h3>
     <p>
     <p>
-        Two dialog level events are supported currently: onshow, onhide. <br />
         Please note that if you're going to use setters to configure event handlers, use dialog.onShow(function) and dialog.onHide(function).
         Please note that if you're going to use setters to configure event handlers, use dialog.onShow(function) and dialog.onHide(function).
     </p>
     </p>
     <div class="source-code runnable">
     <div class="source-code runnable">
@@ -567,8 +566,14 @@
             onshow: function(dialogRef){
             onshow: function(dialogRef){
                 alert('Dialog is popping up, its message is ' + dialogRef.getMessage());
                 alert('Dialog is popping up, its message is ' + dialogRef.getMessage());
             },
             },
+            onshown: function(dialogRef){
+                alert('Dialog is popped up.');
+            },
             onhide: function(dialogRef){
             onhide: function(dialogRef){
                 alert('Dialog is popping down, its message is ' + dialogRef.getMessage());
                 alert('Dialog is popping down, its message is ' + dialogRef.getMessage());
+            },
+            onhidden: function(dialogRef){
+                alert('Dialog is popped down.');
             }
             }
         });
         });
         -->
         -->
@@ -843,6 +848,15 @@ BootstrapDialog.show({
                 </td>
                 </td>
             </tr>
             </tr>
             <tr>
             <tr>
+                <td>onshown</td>
+                <td>
+                    function
+                </td>
+                <td>
+                    If provided, it will be invoked when the dialog is popped up. <br />
+                </td>
+            </tr>
+            <tr>
                 <td>onhide</td>
                 <td>onhide</td>
                 <td>
                 <td>
                     function
                     function
@@ -852,6 +866,15 @@ BootstrapDialog.show({
                 </td>
                 </td>
             </tr>
             </tr>
             <tr>
             <tr>
+                <td>onhidden</td>
+                <td>
+                    function
+                </td>
+                <td>
+                    If provided, it will be invoked when the dialog is popped down. <br />
+                </td>
+            </tr>
+            <tr>
                 <td>autodestroy</td>
                 <td>autodestroy</td>
                 <td>
                 <td>
                     <strong>true (default)</strong> | false
                     <strong>true (default)</strong> | false

+ 29 - 9
js/bootstrap-dialog.js

@@ -19,7 +19,9 @@
             buttons: [],
             buttons: [],
             data: {},
             data: {},
             onshow: null,
             onshow: null,
-            onhide: null
+            onshown: null,
+            onhide: null,
+            onhidden: null
         }, BootstrapDialog.defaultOptions);
         }, BootstrapDialog.defaultOptions);
         this.indexedButtons = {};
         this.indexedButtons = {};
         this.registeredButtonHotkeys = {};
         this.registeredButtonHotkeys = {};
@@ -582,11 +584,8 @@
             return this;
             return this;
         },
         },
         /**
         /**
-         * Set handler for modal event 'show'.
+         * Set handler for modal event 'show.bs.modal'.
          * This is a setter!
          * This is a setter!
-         * 
-         * @param {type} onopen
-         * @returns {_L9.BootstrapDialog.prototype}
          */
          */
         onShow: function(onshow) {
         onShow: function(onshow) {
             this.options.onshow = onshow;
             this.options.onshow = onshow;
@@ -594,17 +593,32 @@
             return this;
             return this;
         },
         },
         /**
         /**
-         * Set handler for modal event 'hide'.
+         * Set handler for modal event 'shown.bs.modal'.
+         * This is a setter!
+         */
+        onShown: function(onshown) {
+            this.options.onshown = onshown;
+
+            return this;
+        },
+        /**
+         * Set handler for modal event 'hide.bs.modal'.
          * This is a setter!
          * This is a setter!
-         * 
-         * @param {type} onclose
-         * @returns {_L9.BootstrapDialog.prototype}
          */
          */
         onHide: function(onhide) {
         onHide: function(onhide) {
             this.options.onhide = onhide;
             this.options.onhide = onhide;
 
 
             return this;
             return this;
         },
         },
+        /**
+         * Set handler for modal event 'hidden.bs.modal'.
+         * This is a setter!
+         */
+        onHidden: function(onhidden) {
+            this.options.onhidden = onhidden;
+
+            return this;
+        },
         isRealized: function() {
         isRealized: function() {
             return this.realized;
             return this.realized;
         },
         },
@@ -627,12 +641,18 @@
                 typeof dialog.options.onshow === 'function' && dialog.options.onshow(dialog);
                 typeof dialog.options.onshow === 'function' && dialog.options.onshow(dialog);
                 dialog.showPageScrollBar(true);
                 dialog.showPageScrollBar(true);
             });
             });
+            this.getModal().on('shown.bs.modal', {dialog: this}, function(event) {
+                var dialog = event.data.dialog;
+                typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog);
+                dialog.showPageScrollBar(true);
+            });
             this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
             this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 var dialog = event.data.dialog;
                 typeof dialog.options.onhide === 'function' && dialog.options.onhide(dialog);
                 typeof dialog.options.onhide === 'function' && dialog.options.onhide(dialog);
             });
             });
             this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
             this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 var dialog = event.data.dialog;
+                typeof dialog.options.onhidden === 'function' && dialog.options.onhidden(dialog);
                 dialog.isAutodestroy() && $(this).remove();
                 dialog.isAutodestroy() && $(this).remove();
                 dialog.showPageScrollBar(false);
                 dialog.showPageScrollBar(false);
             });
             });

File diff suppressed because it is too large
+ 1 - 1
js/bootstrap-dialog.min.js