浏览代码

Two more events are supported: onshown, onhidden.

Dante 11 年之前
父节点
当前提交
e5def1f618

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

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

文件差异内容过多而无法显示
+ 1 - 1
examples/assets/bootstrap-dialog/js/bootstrap-dialog.min.js


+ 24 - 1
examples/index.html

@@ -557,7 +557,6 @@
     
     <h3>Dialog events</h3>
     <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).
     </p>
     <div class="source-code runnable">
@@ -567,8 +566,14 @@
             onshow: function(dialogRef){
                 alert('Dialog is popping up, its message is ' + dialogRef.getMessage());
             },
+            onshown: function(dialogRef){
+                alert('Dialog is popped up.');
+            },
             onhide: function(dialogRef){
                 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>
             </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>
                     function
@@ -852,6 +866,15 @@ BootstrapDialog.show({
                 </td>
             </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>
                     <strong>true (default)</strong> | false

+ 29 - 9
js/bootstrap-dialog.js

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

文件差异内容过多而无法显示
+ 1 - 1
js/bootstrap-dialog.min.js