From 42f3df9517d94239535d3a0e1cac399247a8528e Mon Sep 17 00:00:00 2001 From: Rolux Date: Sat, 6 Mar 2010 13:59:13 +0100 Subject: [PATCH] prevent dialog from being dragged off-screen in webkit; make layer transparent even if mouseup occurs outside it --- build/css/ox.ui.classic.css | 3 +++ build/css/ox.ui.css | 7 +++++-- build/js/ox.ui.js | 31 ++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/build/css/ox.ui.classic.css b/build/css/ox.ui.classic.css index dd11ef0..1819106 100644 --- a/build/css/ox.ui.classic.css +++ b/build/css/ox.ui.classic.css @@ -66,6 +66,9 @@ Forms //border: 1px solid rgb(160, 160, 160); color: rgb(64, 64, 64); } +.OxThemeClassic .OxInputLabel { + color: rgb(64, 64, 64); +} .OxThemeClassic .OxButton, .OxThemeClassic div.OxInput, .OxThemeClassic .OxRange { diff --git a/build/css/ox.ui.css b/build/css/ox.ui.css index d636aec..8e2d342 100644 --- a/build/css/ox.ui.css +++ b/build/css/ox.ui.css @@ -11,14 +11,17 @@ Base body { margin: 0; overflow: hidden; - //-webkit-user-select: none + -webkit-user-select: none +} +div { + -webkit-user-select: none } div, input, textarea { font-family: Lucida Grande, Lucida Sans Unicode, Segoe UI; font-size: 11px; } td { - padding: 0px; + padding: 0; } /* diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 8909dba..addefe7 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -1241,6 +1241,8 @@ requires Ox.Dialog = function(options, self) { // fixme: dialog should be derived from a generic draggable + // fixme: to prevent dragging off-screen in safari, + // append dialog to (currently non-existing) viewport var self = self || {}, that = new Ox.Element("div", self) .defaults({ @@ -1317,26 +1319,30 @@ requires } function drag(event) { - var documentWidth = $document.width(), - documentHeight = $document.height(), + var bodyWidth = $body.width(), + bodyHeight = $document.height(), elementWidth = that.width(), offset = that.offset(), x = event.clientX, y = event.clientY; $window.mousemove(function(event) { + /* $("*").css({ WebkitUserSelect: "none" }); + */ that.css({ margin: 0 }); var left = Ox.limit( offset.left - x + event.clientX, - 24 - elementWidth, documentWidth - 24 + 24 - elementWidth, bodyWidth - 24 + //0, documentWidth - elementWidth ), top = Ox.limit( offset.top - y + event.clientY, - 24, documentHeight - 24 + 24, bodyHeight - 24 + //24, documentHeight - elementHeight ); that.css({ left: left + "px", @@ -1345,23 +1351,24 @@ requires }); $window.one("mouseup", function() { $window.unbind("mousemove"); + /* $("*").css({ WebkitUserSelect: "auto" }); - }); - + */ + }); } function mousedownLayer() { that.$layer.stop().animate({ opacity: 0.5 - }, 50); + }, 0); } function mouseupLayer() { that.$layer.stop().animate({ opacity: 0 - }, 50); + }, 0); } function reset() { @@ -1383,9 +1390,11 @@ requires x = event.clientX, y = event.clientY; $window.mousemove(function(event) { + /* $("*").css({ WebkitUserSelect: "none" }); + */ that.css({ left: offset.left, top: offset.top, @@ -1405,9 +1414,11 @@ requires }); $window.one("mouseup", function() { $window.unbind("mousemove"); + /* $("*").css({ WebkitUserSelect: "auto" }); + */ }); } @@ -1431,6 +1442,7 @@ requires that.$layer.remove(); callback(); }); + $window.unbind("mouseup", mouseupLayer) return that; } @@ -1451,9 +1463,10 @@ requires reset(); that.css({ opacity: 0 - }).appendTo($body).animate({ + }).appendTo($("body > div")).animate({ opacity: 1 }, 200); + $window.bind("mouseup", mouseupLayer) return that; }