Dante 11 years ago
parent
commit
176c0789a1

+ 16 - 1
dist/js/bootstrap-dialog.js

@@ -296,6 +296,21 @@
         },
         setType: function(type) {
             this.options.type = type;
+            this.updateType();
+
+            return this;
+        },
+        updateType: function() {
+            if (this.isRealized()) {
+                var types = [BootstrapDialog.TYPE_DEFAULT,
+                    BootstrapDialog.TYPE_INFO,
+                    BootstrapDialog.TYPE_PRIMARY,
+                    BootstrapDialog.TYPE_SUCCESS,
+                    BootstrapDialog.TYPE_WARNING,
+                    BootstrapDialog.TYPE_DANGER];
+
+                this.getModal().removeClass(types.join(' ')).addClass(this.getType());
+            }
 
             return this;
         },
@@ -820,7 +835,6 @@
         realize: function() {
             this.initModalStuff();
             this.getModal().addClass(BootstrapDialog.NAMESPACE)
-            .addClass(this.getType())
             .addClass(this.getSize())
             .addClass(this.getCssClass());
             this.getModalFooter().append(this.createFooterContent());
@@ -835,6 +849,7 @@
             this.handleModalEvents();
             this.setRealized(true);
             this.updateButtons();
+            this.updateType();
             this.updateTitle();
             this.updateMessage();
             this.updateClosable();

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


+ 16 - 1
examples/assets/bootstrap-dialog/js/bootstrap-dialog.js

@@ -296,6 +296,21 @@
         },
         setType: function(type) {
             this.options.type = type;
+            this.updateType();
+
+            return this;
+        },
+        updateType: function() {
+            if (this.isRealized()) {
+                var types = [BootstrapDialog.TYPE_DEFAULT,
+                    BootstrapDialog.TYPE_INFO,
+                    BootstrapDialog.TYPE_PRIMARY,
+                    BootstrapDialog.TYPE_SUCCESS,
+                    BootstrapDialog.TYPE_WARNING,
+                    BootstrapDialog.TYPE_DANGER];
+
+                this.getModal().removeClass(types.join(' ')).addClass(this.getType());
+            }
 
             return this;
         },
@@ -820,7 +835,6 @@
         realize: function() {
             this.initModalStuff();
             this.getModal().addClass(BootstrapDialog.NAMESPACE)
-            .addClass(this.getType())
             .addClass(this.getSize())
             .addClass(this.getCssClass());
             this.getModalFooter().append(this.createFooterContent());
@@ -835,6 +849,7 @@
             this.handleModalEvents();
             this.setRealized(true);
             this.updateButtons();
+            this.updateType();
             this.updateTitle();
             this.updateMessage();
             this.updateClosable();

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


+ 30 - 0
examples/index.html

@@ -371,6 +371,36 @@
         -->
     </div>
     
+    <a name="changing-dialog-type"></a>
+    <h3>Changing dialog type</h3>
+    <div class="source-code runnable">
+        <!--
+        var types = [BootstrapDialog.TYPE_DEFAULT, 
+                     BootstrapDialog.TYPE_INFO, 
+                     BootstrapDialog.TYPE_PRIMARY, 
+                     BootstrapDialog.TYPE_SUCCESS, 
+                     BootstrapDialog.TYPE_WARNING, 
+                     BootstrapDialog.TYPE_DANGER];
+                     
+        var buttons = [];
+        $.each(types, function(index, type) {
+            buttons.push({
+                label: type,
+                cssClass: 'btn-default btn-sm',
+                action: function(dialog) {
+                    dialog.setType(type);
+                }
+            });
+        });
+
+        BootstrapDialog.show({
+            title: 'Changing dialog type',
+            message: 'Click buttons below...',
+            buttons: buttons
+        });
+        -->
+    </div>
+    
     <h3>Larger dialog</h3>
     <p>
         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.

+ 16 - 1
src/js/bootstrap-dialog.js

@@ -296,6 +296,21 @@
         },
         setType: function(type) {
             this.options.type = type;
+            this.updateType();
+
+            return this;
+        },
+        updateType: function() {
+            if (this.isRealized()) {
+                var types = [BootstrapDialog.TYPE_DEFAULT,
+                    BootstrapDialog.TYPE_INFO,
+                    BootstrapDialog.TYPE_PRIMARY,
+                    BootstrapDialog.TYPE_SUCCESS,
+                    BootstrapDialog.TYPE_WARNING,
+                    BootstrapDialog.TYPE_DANGER];
+
+                this.getModal().removeClass(types.join(' ')).addClass(this.getType());
+            }
 
             return this;
         },
@@ -820,7 +835,6 @@
         realize: function() {
             this.initModalStuff();
             this.getModal().addClass(BootstrapDialog.NAMESPACE)
-            .addClass(this.getType())
             .addClass(this.getSize())
             .addClass(this.getCssClass());
             this.getModalFooter().append(this.createFooterContent());
@@ -835,6 +849,7 @@
             this.handleModalEvents();
             this.setRealized(true);
             this.updateButtons();
+            this.updateType();
             this.updateTitle();
             this.updateMessage();
             this.updateClosable();