]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: added stack option.
authorScott González <scott.gonzalez@gmail.com>
Tue, 3 Jun 2008 13:03:53 +0000 (13:03 +0000)
committerScott González <scott.gonzalez@gmail.com>
Tue, 3 Jun 2008 13:03:53 +0000 (13:03 +0000)
ui/source/ui.dialog.js

index 4c1f9b0f7a9a03fd61838f33e3276e1c46822125..9976c192a2c24ede2dc6667f31a46a252faadc0a 100644 (file)
@@ -45,7 +45,13 @@ $.widget("ui.dialog", {
                var uiDialogContainer = uiDialogContent.parent().addClass('ui-dialog-container').css({position: 'relative'});\r
                var uiDialog = (this.uiDialog = uiDialogContainer.parent()).hide()\r
                        .addClass('ui-dialog').addClass(options.dialogClass)\r
-                       .css({position: 'absolute', width: options.width, height: options.height, overflow: 'hidden'}); \r
+                       .css({\r
+                               position: 'absolute',\r
+                               width: options.width,\r
+                               height: options.height,\r
+                               overflow: 'hidden',\r
+                               zIndex: options.zIndex\r
+                       });\r
 \r
                var classNames = uiDialogContent.attr('className').split(' ');\r
 \r
@@ -123,7 +129,7 @@ $.widget("ui.dialog", {
                        uiDialog.draggable({\r
                                handle: '.ui-dialog-titlebar',\r
                                start: function(e, ui) {\r
-                                       self.activate();\r
+                                       self.moveToTop();\r
                                        (options.dragStart && options.dragStart.apply(this, arguments));\r
                                },\r
                                drag: options.drag,\r
@@ -136,10 +142,7 @@ $.widget("ui.dialog", {
                }\r
        \r
                uiDialog.mousedown(function() {\r
-                       self.activate();\r
-               });\r
-               uiDialogTitlebar.click(function() {\r
-                       self.activate();\r
+                       self.moveToTop();\r
                });\r
                \r
                (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());\r
@@ -229,7 +232,6 @@ $.widget("ui.dialog", {
                this.position(this.options.position);\r
                this.uiDialog.show();\r
                this.moveToTop();\r
-               this.activate();\r
                \r
                // CALLBACK: open\r
                var openEV = null;\r
@@ -239,18 +241,10 @@ $.widget("ui.dialog", {
                this.uiDialogTitlebarClose.focus();\r
                this.element.triggerHandler("dialogopen", [openEV, openUI], this.options.open);\r
        },\r
-\r
-       activate: function() {\r
-               // Move modeless dialogs to the top when they're activated. Even\r
-               // if there is a modal dialog in the window, the modeless dialog\r
-               // should be on top because it must have been opened after the modal\r
-               // dialog. Modal dialogs don't get moved to the top because that\r
-               // would make any modeless dialogs that it spawned unusable until\r
-               // the modal dialog is closed.\r
-               (!this.options.modal && this.moveToTop());\r
-       },\r
-               \r
+       \r
        moveToTop: function() {\r
+               if (this.options.modal || !this.options.stack) { return; }\r
+               \r
                var maxZ = this.options.zIndex, options = this.options;\r
                $('.ui-dialog:visible').each(function() {\r
                        maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);\r
@@ -258,7 +252,7 @@ $.widget("ui.dialog", {
                (this.overlay && this.overlay.$el.css('z-index', ++maxZ));\r
                this.uiDialog.css('z-index', ++maxZ);\r
        },\r
-               \r
+       \r
        close: function() {\r
                (this.overlay && this.overlay.destroy());\r
                this.uiDialog.hide();\r
@@ -298,6 +292,7 @@ $.extend($.ui.dialog, {
                overlay: {},\r
                position: 'center',\r
                resizable: true,\r
+               stack: true,\r
                width: 300,\r
                zIndex: 1000\r
        },\r