Browse Source

Updated examples

Dante 12 years ago
parent
commit
287010721f
2 changed files with 19 additions and 22 deletions
  1. 13 21
      assets/bootstrap-dialog/js/bootstrap-dialog.js
  2. 6 1
      index.html

+ 13 - 21
assets/bootstrap-dialog/js/bootstrap-dialog.js

@@ -19,7 +19,6 @@ var BootstrapDialog = null;
             message: null,
             message: null,
             buttons: [],
             buttons: [],
             closable: true,
             closable: true,
-            autospin: false,
             spinicon: BootstrapDialog.ICON_SPINNER,
             spinicon: BootstrapDialog.ICON_SPINNER,
             data: {},
             data: {},
             onshow: null,
             onshow: null,
@@ -204,14 +203,6 @@ var BootstrapDialog = null;
 
 
             return this;
             return this;
         },
         },
-        isAutospin: function() {
-            return this.options.autospin;
-        },
-        setAutospin: function(autospin) {
-            this.options.autospin = autospin;
-
-            return this;
-        },
         getSpinicon: function() {
         getSpinicon: function() {
             return this.options.spinicon;
             return this.options.spinicon;
         },
         },
@@ -369,19 +360,20 @@ var BootstrapDialog = null;
                 $button.addClass('btn-default');
                 $button.addClass('btn-default');
             }
             }
 
 
-            // Action
-            if (typeof button.action === 'function') {
-                $button.on('click', {dialog: this, callback: button.action}, function(event) {
-                    var dialog = event.data.dialog;
-                    event.data.callback.call(this, dialog);
+            // Button on click
+            $button.on('click', {dialog: this, button: button}, function(event) {
+                var dialog = event.data.dialog;
+                var button = event.data.button;
+                if (typeof button.action === 'function') {
+                    button.action.call(this, dialog);
+                }
 
 
-                    if (dialog.isAutospin()) {
-                        var $button = $(this);
-                        $button.find('.' + dialog.getNamespace('button-icon')).remove();
-                        $button.prepend(dialog.createButtonIcon(dialog.getSpinicon()).addClass('icon-spin'));
-                    }
-                });
-            }
+                if (button.autospin) {
+                    var $button = $(this);
+                    $button.find('.' + dialog.getNamespace('button-icon')).remove();
+                    $button.prepend(dialog.createButtonIcon(dialog.getSpinicon()).addClass('icon-spin'));
+                }
+            });
 
 
             return $button;
             return $button;
         },
         },

+ 6 - 1
index.html

@@ -190,11 +190,11 @@
         <!--
         <!--
         BootstrapDialog.show({
         BootstrapDialog.show({
             message: 'I sent ajax request!',
             message: 'I sent ajax request!',
-            autospin: true,
             buttons: [{
             buttons: [{
                 icon: 'glyphicon glyphicon-send',
                 icon: 'glyphicon glyphicon-send',
                 label: 'Send ajax request',
                 label: 'Send ajax request',
                 cssClass: 'btn-primary',
                 cssClass: 'btn-primary',
+                autospin: true,
                 action: function(dialogRef){
                 action: function(dialogRef){
                     dialogRef.enableButtons(false);
                     dialogRef.enableButtons(false);
                     dialogRef.setClosable(false);
                     dialogRef.setClosable(false);
@@ -203,6 +203,11 @@
                         dialogRef.close();
                         dialogRef.close();
                     }, 5000);
                     }, 5000);
                 }
                 }
+            }, {
+                label: 'Close',
+                action: function(dialogRef){
+                    dialogRef.close();
+                }
             }]
             }]
         });
         });
         -->
         -->