prevent dialog from being dragged off-screen in webkit; make layer transparent even if mouseup occurs outside it

This commit is contained in:
Rolux 2010-03-06 13:59:13 +01:00
parent 3abb6e31ea
commit 42f3df9517
3 changed files with 30 additions and 11 deletions

View File

@ -66,6 +66,9 @@ Forms
//border: 1px solid rgb(160, 160, 160); //border: 1px solid rgb(160, 160, 160);
color: rgb(64, 64, 64); color: rgb(64, 64, 64);
} }
.OxThemeClassic .OxInputLabel {
color: rgb(64, 64, 64);
}
.OxThemeClassic .OxButton, .OxThemeClassic .OxButton,
.OxThemeClassic div.OxInput, .OxThemeClassic div.OxInput,
.OxThemeClassic .OxRange { .OxThemeClassic .OxRange {

View File

@ -11,14 +11,17 @@ Base
body { body {
margin: 0; margin: 0;
overflow: hidden; overflow: hidden;
//-webkit-user-select: none -webkit-user-select: none
}
div {
-webkit-user-select: none
} }
div, input, textarea { div, input, textarea {
font-family: Lucida Grande, Lucida Sans Unicode, Segoe UI; font-family: Lucida Grande, Lucida Sans Unicode, Segoe UI;
font-size: 11px; font-size: 11px;
} }
td { td {
padding: 0px; padding: 0;
} }
/* /*

View File

@ -1241,6 +1241,8 @@ requires
Ox.Dialog = function(options, self) { Ox.Dialog = function(options, self) {
// fixme: dialog should be derived from a generic draggable // 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 || {}, var self = self || {},
that = new Ox.Element("div", self) that = new Ox.Element("div", self)
.defaults({ .defaults({
@ -1317,26 +1319,30 @@ requires
} }
function drag(event) { function drag(event) {
var documentWidth = $document.width(), var bodyWidth = $body.width(),
documentHeight = $document.height(), bodyHeight = $document.height(),
elementWidth = that.width(), elementWidth = that.width(),
offset = that.offset(), offset = that.offset(),
x = event.clientX, x = event.clientX,
y = event.clientY; y = event.clientY;
$window.mousemove(function(event) { $window.mousemove(function(event) {
/*
$("*").css({ $("*").css({
WebkitUserSelect: "none" WebkitUserSelect: "none"
}); });
*/
that.css({ that.css({
margin: 0 margin: 0
}); });
var left = Ox.limit( var left = Ox.limit(
offset.left - x + event.clientX, offset.left - x + event.clientX,
24 - elementWidth, documentWidth - 24 24 - elementWidth, bodyWidth - 24
//0, documentWidth - elementWidth
), ),
top = Ox.limit( top = Ox.limit(
offset.top - y + event.clientY, offset.top - y + event.clientY,
24, documentHeight - 24 24, bodyHeight - 24
//24, documentHeight - elementHeight
); );
that.css({ that.css({
left: left + "px", left: left + "px",
@ -1345,23 +1351,24 @@ requires
}); });
$window.one("mouseup", function() { $window.one("mouseup", function() {
$window.unbind("mousemove"); $window.unbind("mousemove");
/*
$("*").css({ $("*").css({
WebkitUserSelect: "auto" WebkitUserSelect: "auto"
}); });
}); */
});
} }
function mousedownLayer() { function mousedownLayer() {
that.$layer.stop().animate({ that.$layer.stop().animate({
opacity: 0.5 opacity: 0.5
}, 50); }, 0);
} }
function mouseupLayer() { function mouseupLayer() {
that.$layer.stop().animate({ that.$layer.stop().animate({
opacity: 0 opacity: 0
}, 50); }, 0);
} }
function reset() { function reset() {
@ -1383,9 +1390,11 @@ requires
x = event.clientX, x = event.clientX,
y = event.clientY; y = event.clientY;
$window.mousemove(function(event) { $window.mousemove(function(event) {
/*
$("*").css({ $("*").css({
WebkitUserSelect: "none" WebkitUserSelect: "none"
}); });
*/
that.css({ that.css({
left: offset.left, left: offset.left,
top: offset.top, top: offset.top,
@ -1405,9 +1414,11 @@ requires
}); });
$window.one("mouseup", function() { $window.one("mouseup", function() {
$window.unbind("mousemove"); $window.unbind("mousemove");
/*
$("*").css({ $("*").css({
WebkitUserSelect: "auto" WebkitUserSelect: "auto"
}); });
*/
}); });
} }
@ -1431,6 +1442,7 @@ requires
that.$layer.remove(); that.$layer.remove();
callback(); callback();
}); });
$window.unbind("mouseup", mouseupLayer)
return that; return that;
} }
@ -1451,9 +1463,10 @@ requires
reset(); reset();
that.css({ that.css({
opacity: 0 opacity: 0
}).appendTo($body).animate({ }).appendTo($("body > div")).animate({
opacity: 1 opacity: 1
}, 200); }, 200);
$window.bind("mouseup", mouseupLayer)
return that; return that;
} }