From 4bdac7c195641062d9e02f75c9ba08e15e091582 Mon Sep 17 00:00:00 2001 From: Rolux Date: Sun, 21 Feb 2010 11:53:37 +0530 Subject: [PATCH] making dialog re-center on doubleclick on title bar --- build/css/ox.ui.css | 3 +++ build/js/ox.ui.js | 11 +++++++++++ demos/test/index.html | 12 ++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/build/css/ox.ui.css b/build/css/ox.ui.css index 72bccef..5551b51 100644 --- a/build/css/ox.ui.css +++ b/build/css/ox.ui.css @@ -118,6 +118,9 @@ Dialog .OxDialog > .OxButtonsBar > .OxButton.OxLeft { float: left; } +.OxDialog > .OxButtonsBar > .OxButton.OxLeft:first-child { + margin-left: 16px; +} .OxDialog > .OxButtonsBar > .OxButton.OxRight { float: right; } diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index b57e4d4..9b305f8 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -1269,6 +1269,7 @@ requires .addClass("OxTitleBar") //.html(self.options.title) .mousedown(drag) + .dblclick(center) .appendTo(that); that.$title = new Ox.Element() .addClass("OxTitle") @@ -1310,6 +1311,16 @@ requires that.$layer = new Ox.Element() .addClass("OxLayer"); + function center() { + that.css({ + left: 0, + top: parseInt(-$document.height() / 10) + "px", // fixme: duplicated + right: 0, + bottom: 0, + margin: "auto" + }); + } + function drag(event) { var documentWidth = $document.width(), documentHeight = $document.height(), diff --git a/demos/test/index.html b/demos/test/index.html index f548c0c..51d7225 100644 --- a/demos/test/index.html +++ b/demos/test/index.html @@ -195,10 +195,14 @@ var loginDialog = new Ox.Dialog({ buttons: [ - { value: "Register", click: function() { loginDialog.close(); } }, - { value: "Reset Password", click: function() { loginDialog.close(); } }, - { value: "Cancel", click: function() { loginDialog.close(); } }, - { value: "Login", click: function() { loginDialog.close(); } } + [ + { value: "Register", click: function() { loginDialog.close(); } }, + { value: "Reset Password", click: function() { loginDialog.close(); } } + ], + [ + { value: "Cancel", click: function() { loginDialog.close(); } }, + { value: "Login", click: function() { loginDialog.close(); } } + ] ], title: "Login" });