Browse Source

Tabindex is a customizable option now.

Dante 10 years ago
parent
commit
e7e0cb94a7

+ 1 - 0
changelog.txt

@@ -1,6 +1,7 @@
 LASTEST NOT RELEASED
 ------------------------------
 * Merged #137, Add missing less and remove stray css file in src folder *
+* Tabindex is a customizable option now. *
 * Refs #142 *
 * Refs #145 *
 

+ 21 - 3
dist/js/bootstrap-dialog.js

@@ -236,7 +236,8 @@
         autodestroy: true,
         draggable: false,
         animate: true,
-        description: ''
+        description: '',
+        tabindex: -1
     };
 
     /**
@@ -347,8 +348,9 @@
             return this;
         },
         createModal: function() {
-            var $modal = $('<div class="modal" tabindex="-1" role="dialog" aria-hidden="true"></div>');
-            $modal.prop('id', this.getId()).attr('aria-labelledby', this.getId() + '_title');
+            var $modal = $('<div class="modal" role="dialog" aria-hidden="true"></div>');
+            $modal.prop('id', this.getId());
+            $modal.attr('aria-labelledby', this.getId() + '_title');
 
             return $modal;
         },
@@ -687,6 +689,21 @@
 
             return this;
         },
+        setTabindex: function(tabindex) {
+            this.options.tabindex = tabindex;
+
+            return this;
+        },
+        getTabindex: function() {
+            return this.options.tabindex;
+        },
+        updateTabindex: function() {
+            if (this.isRealized()) {
+                this.getModal().attr('tabindex', this.getTabindex());
+            }
+
+            return this;
+        },
         getDefaultText: function() {
             return BootstrapDialog.DEFAULT_TEXTS[this.getType()];
         },
@@ -1079,6 +1096,7 @@
             this.updateClosable();
             this.updateAnimate();
             this.updateSize();
+            this.updateTabindex();
 
             return this;
         },

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


+ 21 - 3
examples/assets/bootstrap-dialog/js/bootstrap-dialog.js

@@ -236,7 +236,8 @@
         autodestroy: true,
         draggable: false,
         animate: true,
-        description: ''
+        description: '',
+        tabindex: -1
     };
 
     /**
@@ -347,8 +348,9 @@
             return this;
         },
         createModal: function() {
-            var $modal = $('<div class="modal" tabindex="-1" role="dialog" aria-hidden="true"></div>');
-            $modal.prop('id', this.getId()).attr('aria-labelledby', this.getId() + '_title');
+            var $modal = $('<div class="modal" role="dialog" aria-hidden="true"></div>');
+            $modal.prop('id', this.getId());
+            $modal.attr('aria-labelledby', this.getId() + '_title');
 
             return $modal;
         },
@@ -687,6 +689,21 @@
 
             return this;
         },
+        setTabindex: function(tabindex) {
+            this.options.tabindex = tabindex;
+
+            return this;
+        },
+        getTabindex: function() {
+            return this.options.tabindex;
+        },
+        updateTabindex: function() {
+            if (this.isRealized()) {
+                this.getModal().attr('tabindex', this.getTabindex());
+            }
+
+            return this;
+        },
         getDefaultText: function() {
             return BootstrapDialog.DEFAULT_TEXTS[this.getType()];
         },
@@ -1079,6 +1096,7 @@
             this.updateClosable();
             this.updateAnimate();
             this.updateSize();
+            this.updateTabindex();
 
             return this;
         },

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


+ 27 - 0
examples/play/tabindex.html

@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src="../assets/jquery/jquery-1.10.2.min.js"></script>
+        <link href="../assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
+        <script src="../assets/bootstrap/js/bootstrap.min.js"></script>
+        <link href="../assets/bootstrap-dialog/css/bootstrap-dialog.min.css" rel="stylesheet" type="text/css" />
+        <script src="../assets/bootstrap-dialog/js/bootstrap-dialog.min.js"></script>
+        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
+        <title>Tabindex</title>
+        <meta charset="utf-8" />
+    </head>
+    <body>
+        <script type="text/javascript">
+            /**
+             * This example demonstrates how to custom tabindex attribute of the dialog.
+             */
+            $(function() {
+                var dialog = new BootstrapDialog({
+                    message: 'Custom tabindex.',
+                    tabindex: 10
+                });
+                dialog.open();
+            });
+        </script>
+    </body>
+</html>

+ 21 - 3
src/js/bootstrap-dialog.js

@@ -236,7 +236,8 @@
         autodestroy: true,
         draggable: false,
         animate: true,
-        description: ''
+        description: '',
+        tabindex: -1
     };
 
     /**
@@ -347,8 +348,9 @@
             return this;
         },
         createModal: function() {
-            var $modal = $('<div class="modal" tabindex="-1" role="dialog" aria-hidden="true"></div>');
-            $modal.prop('id', this.getId()).attr('aria-labelledby', this.getId() + '_title');
+            var $modal = $('<div class="modal" role="dialog" aria-hidden="true"></div>');
+            $modal.prop('id', this.getId());
+            $modal.attr('aria-labelledby', this.getId() + '_title');
 
             return $modal;
         },
@@ -687,6 +689,21 @@
 
             return this;
         },
+        setTabindex: function(tabindex) {
+            this.options.tabindex = tabindex;
+
+            return this;
+        },
+        getTabindex: function() {
+            return this.options.tabindex;
+        },
+        updateTabindex: function() {
+            if (this.isRealized()) {
+                this.getModal().attr('tabindex', this.getTabindex());
+            }
+
+            return this;
+        },
         getDefaultText: function() {
             return BootstrapDialog.DEFAULT_TEXTS[this.getType()];
         },
@@ -1079,6 +1096,7 @@
             this.updateClosable();
             this.updateAnimate();
             this.updateSize();
+            this.updateTabindex();
 
             return this;
         },