exclusively handle selectability of text via .OxSelectable and body.OxDragging (to be set/unset in dragstart/dragend handlers)

This commit is contained in:
rlx 2013-07-19 08:42:25 +00:00
parent f8816e7522
commit 564ce69a78
17 changed files with 53 additions and 39 deletions

View file

@ -19,18 +19,13 @@ blockquote {
body { body {
margin: 0; margin: 0;
overflow: hidden; overflow: hidden;
-moz-user-select: -moz-none; -moz-user-select: none;
-o-user-select: none; -o-user-select: none;
-webkit-user-select: none; -webkit-user-select: none;
} }
code, pre { code, pre {
font-family: Menlo, Monaco, DejaVu Sans Mono, Lucida Console, Consolas, Bitstream Vera Sans Mono, monospace; font-family: Menlo, Monaco, DejaVu Sans Mono, Lucida Console, Consolas, Bitstream Vera Sans Mono, monospace;
} }
div {
-moz-user-select: -moz-none;
-o-user-select: none;
-webkit-user-select: none;
}
div, input, textarea { div, input, textarea {
font-family: Lucida Grande, Segoe UI, DejaVu Sans, Lucida Sans Unicode, Helvetica, Arial, sans-serif; font-family: Lucida Grande, Segoe UI, DejaVu Sans, Lucida Sans Unicode, Helvetica, Arial, sans-serif;
font-size: 11px; font-size: 11px;
@ -81,6 +76,11 @@ td {
-o-user-select: text; -o-user-select: text;
-webkit-user-select: text; -webkit-user-select: text;
} }
body.OxDragging .OxSelectable {
-moz-user-select: none;
-o-user-select: none;
-webkit-user-select: none;
}
/* /*
================================================================================ ================================================================================
@ -523,9 +523,6 @@ Document
.OxDocument { .OxDocument {
padding: 8px; padding: 8px;
-moz-user-select: text;
-o-user-select: text;
-webkit-user-select: text;
} }
.OxDocument div { .OxDocument div {
border-width: 0; border-width: 0;
@ -533,9 +530,6 @@ Document
//font-family: Georgia, Palatino, DejaVu Serif, Book Antiqua, Palatino Linotype, Times New Roman, serif; //font-family: Georgia, Palatino, DejaVu Serif, Book Antiqua, Palatino Linotype, Times New Roman, serif;
font-size: 12px; font-size: 12px;
line-height: 18px; line-height: 18px;
-moz-user-select: text;
-o-user-select: text;
-webkit-user-select: text;
} }
.OxDocument h1 { .OxDocument h1 {
font-weight: bold; font-weight: bold;
@ -916,9 +910,6 @@ OxEditableContent
.OxEditableContent { .OxEditableContent {
outline: none; outline: none;
word-wrap: break-word; word-wrap: break-word;
-moz-user-select: text;
-o-user-select: text;
-webkit-user-select: text;
} }
.OxEditableContent.OxEditing { .OxEditableContent.OxEditing {
white-space: pre; white-space: pre;
@ -934,9 +925,6 @@ OxEditableElement
//cursor: pointer; //cursor: pointer;
padding: 0 0 0 1px; padding: 0 0 0 1px;
word-wrap: break-word; word-wrap: break-word;
-moz-user-select: text;
-o-user-select: text;
-webkit-user-select: text;
} }
.OxEditableElement div.OxInput { .OxEditableElement div.OxInput {
padding: 0 1px 0 0; padding: 0 1px 0 0;
@ -1071,6 +1059,8 @@ OxRange
float: left; float: left;
height: 14px; height: 14px;
-webkit-user-select: none; -webkit-user-select: none;
-o-user-select: none;
-moz-user-select: none;
} }
.OxRange > .OxTrack > div > img.OxFirstChild { .OxRange > .OxTrack > div > img.OxFirstChild {
border-top-left-radius: 7px; border-top-left-radius: 7px;
@ -1371,6 +1361,7 @@ Lists
cursor: pointer; cursor: pointer;
border-radius: 4px; border-radius: 4px;
//-moz-user-select: text; //-moz-user-select: text;
//-o-user-select: text;
//-webkit-user-select: text; //-webkit-user-select: text;
} }
.OxIconList .OxItem > .OxText > div > div, .OxIconList .OxItem > .OxText > div > div,
@ -1686,9 +1677,6 @@ Menus
.OxMainMenu > .OxTitle { .OxMainMenu > .OxTitle {
float: left; float: left;
cursor: default; cursor: default;
-moz-user-select: none;
-o-user-select: none;
-webkit-user-select: none;
} }
.OxMainMenu.OxLarge > .OxTitle { .OxMainMenu.OxLarge > .OxTitle {
height: 21px; height: 21px;
@ -1733,9 +1721,6 @@ Menus
z-index: 12; z-index: 12;
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
-moz-user-select: none;
-o-user-select: none;
-webkit-user-select: none;
} }
.OxMenu.OxRight { .OxMenu.OxRight {
border-top-right-radius: 4px; border-top-right-radius: 4px;
@ -2100,8 +2085,6 @@ SourceViewer
border-right-style: solid; border-right-style: solid;
font-size: 14px; font-size: 14px;
line-height: 20px; line-height: 20px;
-moz-user-select: text;
-webkit-user-select: text;
} }
.OxSourceViewer td.OxComment > code { .OxSourceViewer td.OxComment > code {
padding: 1px 3px 1px 3px; padding: 1px 3px 1px 3px;
@ -2140,12 +2123,10 @@ SyntaxHightlighter
} }
.OxSyntaxHighlighter > .OxSourceCode { .OxSyntaxHighlighter > .OxSourceCode {
white-space: nowrap; white-space: nowrap;
-moz-user-select: text;
-o-user-select: text;
-webkit-user-select: text;
} }
.OxSyntaxHighlighter > .OxSourceCode .OxLinebreak { .OxSyntaxHighlighter > .OxSourceCode .OxLinebreak {
//-moz-user-select: none; //-moz-user-select: none;
//-o-user-select: none;
//-webkit-user-select: none; //-webkit-user-select: none;
} }

View file

@ -77,6 +77,7 @@ Ox.Resizebar = function(options, self) {
function dragstart(data) { function dragstart(data) {
if (self.options.resizable && !self.options.collapsed) { if (self.options.resizable && !self.options.collapsed) {
Ox.$body.addClass('OxDragging');
self.drag = { self.drag = {
startPos: data[self.clientXY], startPos: data[self.clientXY],
startSize: self.options.size startSize: self.options.size
@ -121,6 +122,7 @@ Ox.Resizebar = function(options, self) {
function dragend() { function dragend() {
if (self.options.resizable && !self.options.collapsed) { if (self.options.resizable && !self.options.collapsed) {
Ox.$body.removeClass('OxDragging');
self.options.size != self.drag.startSize && triggerEvents('resizeend'); self.options.size != self.drag.startSize && triggerEvents('resizeend');
} }
} }

View file

@ -606,6 +606,7 @@ Ox.Calendar = function(options, self) {
function dragstart(data) { function dragstart(data) {
//if ($(e.target).is(':not(.OxLine > .OxEvent)')) { //if ($(e.target).is(':not(.OxLine > .OxEvent)')) {
Ox.$body.addClass('OxDragging');
self.drag = { self.drag = {
top: self.$container[0].scrollTop, top: self.$container[0].scrollTop,
x: data.clientX x: data.clientX
@ -642,6 +643,7 @@ Ox.Calendar = function(options, self) {
function dragend(data) { function dragend(data) {
if (self.drag) { if (self.drag) {
Ox.$body.removeClass('OxDragging');
dragafter(data); dragafter(data);
self.drag = null; self.drag = null;
} }
@ -659,6 +661,7 @@ Ox.Calendar = function(options, self) {
} }
function dragstartScrollbar(data) { function dragstartScrollbar(data) {
Ox.$body.addClass('OxDragging');
self.drag = {x: data.clientX}; self.drag = {x: data.clientX};
} }
@ -682,6 +685,7 @@ Ox.Calendar = function(options, self) {
} }
function dragendScrollbar(data) { function dragendScrollbar(data) {
Ox.$body.removeClass('OxDragging');
dragafterScrollbar(data); dragafterScrollbar(data);
self.drag = null; self.drag = null;
} }

View file

@ -67,7 +67,7 @@ Ox.DocPage = function(options, self) {
.appendTo(self.$toolbar); .appendTo(self.$toolbar);
} }
self.$page = Ox.Container().addClass('OxDocPage OxDocument'); self.$page = Ox.Container().addClass('OxDocPage OxDocument OxSelectable');
that.setElement( that.setElement(
Ox.SplitPanel({ Ox.SplitPanel({

View file

@ -64,7 +64,7 @@ Ox.SourceViewer = function(options, self) {
var $section = $('<tr>') var $section = $('<tr>')
.appendTo(self.$table), .appendTo(self.$table),
$comment = $('<td>') $comment = $('<td>')
.addClass('OxComment OxSerif') .addClass('OxComment OxSerif OxSelectable')
.html(Ox.addLinks(section.comment, true)) .html(Ox.addLinks(section.comment, true))
.appendTo($section), .appendTo($section),
$code = $('<td>') $code = $('<td>')

View file

@ -118,7 +118,7 @@ Ox.SyntaxHighlighter = function(options, self) {
}); });
$source = Ox.Element() $source = Ox.Element()
.addClass('OxSourceCode') .addClass('OxSourceCode OxSelectable')
.html(source) .html(source)
.appendTo(that); .appendTo(that);
if (self.options.lineLength) { if (self.options.lineLength) {

View file

@ -93,7 +93,7 @@ Ox.Editable = function(options, self) {
self.css = {}; self.css = {};
self.$value = Ox.Element(self.options.type == 'input' ? '<span>' : '<div>') self.$value = Ox.Element(self.options.type == 'input' ? '<span>' : '<div>')
.addClass('OxValue') .addClass('OxValue OxSelectable')
.html(formatValue()) .html(formatValue())
.appendTo(that); .appendTo(that);

View file

@ -42,7 +42,7 @@ Ox.EditableContent = function(options, self) {
!self.options.editing && self.$value.html(formatValue()); !self.options.editing && self.$value.html(formatValue());
} }
}) })
.addClass('OxEditableContent') .addClass('OxEditableContent OxSelectable')
.on({ .on({
blur: self.options.submitOnBlur ? submit : blur, blur: self.options.submitOnBlur ? submit : blur,
click: function(e) { click: function(e) {

View file

@ -424,6 +424,7 @@ Ox.List = function(options, self) {
|| $parent.is('.OxTarget') // table lists || $parent.is('.OxTarget') // table lists
|| $parent.parent().is('.OxTarget') // table lists with div inside cell || $parent.parent().is('.OxTarget') // table lists with div inside cell
) && !$target.is('.OxSpecialTarget')) { ) && !$target.is('.OxSpecialTarget')) {
Ox.$body.addClass('OxDragging');
self.drag = { self.drag = {
ids: self.options.selected ids: self.options.selected
}; };
@ -466,6 +467,7 @@ Ox.List = function(options, self) {
function dragend(data) { function dragend(data) {
if (self.drag) { if (self.drag) {
Ox.$body.removeClass('OxDragging');
that.triggerEvent('draganddropend', { that.triggerEvent('draganddropend', {
event: data, event: data,
ids: self.drag.ids ids: self.drag.ids
@ -933,6 +935,7 @@ Ox.List = function(options, self) {
} }
function movestart(data) { function movestart(data) {
Ox.$body.addClass('OxDragging');
var pos = findItemPosition(data), var pos = findItemPosition(data),
$items = self.$items.filter(function($item, i) { $items = self.$items.filter(function($item, i) {
if ($item.is('.OxSelected')) { if ($item.is('.OxSelected')) {
@ -973,6 +976,7 @@ Ox.List = function(options, self) {
function moveend(data) { function moveend(data) {
var ids = []; var ids = [];
Ox.$body.removeClass('OxDragging');
self.$items.forEach(function($item) { self.$items.forEach(function($item) {
$item.removeClass('OxDrag'); $item.removeClass('OxDrag');
ids.push($item.options('data')[self.options.unique]); ids.push($item.options('data')[self.options.unique]);

View file

@ -568,6 +568,7 @@ Ox.TableList = function(options, self) {
} }
function dragstartColumn(id, e) { function dragstartColumn(id, e) {
Ox.$body.addClass('OxDragging');
self.drag = { self.drag = {
columnOffsets: getColumnOffsets(), columnOffsets: getColumnOffsets(),
listOffset: that.$element.offset().left - that.$body.scrollLeft(), listOffset: that.$element.offset().left - that.$body.scrollLeft(),
@ -631,6 +632,7 @@ Ox.TableList = function(options, self) {
function dragendColumn(id, e) { function dragendColumn(id, e) {
var column = self.visibleColumns.splice(self.drag.stopPos, 1)[0], var column = self.visibleColumns.splice(self.drag.stopPos, 1)[0],
width = self.columnWidths.splice(self.drag.stopPos, 1)[0]; width = self.columnWidths.splice(self.drag.stopPos, 1)[0];
Ox.$body.removeClass('OxDragging');
self.visibleColumns.splice(self.drag.stopPos, 0, column); self.visibleColumns.splice(self.drag.stopPos, 0, column);
self.columnWidths.splice(self.drag.stopPos, 0, width); self.columnWidths.splice(self.drag.stopPos, 0, width);
that.$head.$content.empty(); that.$head.$content.empty();
@ -645,6 +647,7 @@ Ox.TableList = function(options, self) {
function dragstartResize(id, e) { function dragstartResize(id, e) {
var pos = getColumnPositionById(id); var pos = getColumnPositionById(id);
Ox.$body.addClass('OxDragging');
self.drag = { self.drag = {
startWidth: self.columnWidths[pos] startWidth: self.columnWidths[pos]
}; };
@ -662,6 +665,7 @@ Ox.TableList = function(options, self) {
function dragendResize(id, e) { function dragendResize(id, e) {
var pos = getColumnPositionById(id); var pos = getColumnPositionById(id);
// fixme: shouldn't this be resizecolumn? // fixme: shouldn't this be resizecolumn?
Ox.$body.removeClass('OxDragging');
that.triggerEvent('columnresize', { that.triggerEvent('columnresize', {
id: id, id: id,
width: self.columnWidths[pos] width: self.columnWidths[pos]

View file

@ -111,7 +111,7 @@ Ox.TreeList = function(options, self) {
$cell.appendTo($item); $cell.appendTo($item);
$icon && $icon.addClass(data.items ? 'OxToggle' : 'OxTarget').appendTo($cell); $icon && $icon.addClass(data.items ? 'OxToggle' : 'OxTarget').appendTo($cell);
$('<div>') $('<div>')
.addClass('OxCell OxTarget' + (!data.items ? ' OxSelectable' : '')) .addClass('OxCell OxTarget')
.css({ .css({
width: self.options.width - padding - 32 - Ox.UI.SCROLLBAR_SIZE + 'px' width: self.options.width - padding - 32 - Ox.UI.SCROLLBAR_SIZE + 'px'
}) })

View file

@ -101,7 +101,7 @@ Ox.MapMarker = function(options) {
} }
function dragstart(e) { function dragstart(e) {
Ox.$body.addClass('OxDragging');
} }
function drag(e) { function drag(e) {
@ -134,6 +134,7 @@ Ox.MapMarker = function(options) {
} }
function dragend(e) { function dragend(e) {
Ox.$body.removeClass('OxDragging');
that.map.triggerEvent('changeplaceend', that.place); that.map.triggerEvent('changeplaceend', that.place);
} }

View file

@ -37,6 +37,7 @@ Ox.MapRectangleMarker = function(options) {
}); });
function dragstart(e) { function dragstart(e) {
Ox.$body.addClass('OxDragging');
that.drag = { that.drag = {
lat: e.latLng.lat(), lat: e.latLng.lat(),
lng: e.latLng.lng() lng: e.latLng.lng()
@ -73,6 +74,7 @@ Ox.MapRectangleMarker = function(options) {
function dragend(e) { function dragend(e) {
var south; var south;
Ox.$body.removeClass('OxDragging');
if (that.place.south > that.place.north) { if (that.place.south > that.place.north) {
south = that.place.south; south = that.place.south;
that.place.south = that.place.north; that.place.south = that.place.north;

View file

@ -362,6 +362,7 @@ Ox.AnnotationFolder = function(options, self) {
function dragstart() { function dragstart() {
if (self.options.showWidget) { if (self.options.showWidget) {
Ox.$body.addClass('OxDragging');
self.drag = { self.drag = {
startSize: self.options.widgetSize startSize: self.options.widgetSize
}; };
@ -384,6 +385,7 @@ Ox.AnnotationFolder = function(options, self) {
function dragend(e) { function dragend(e) {
if (self.options.showWidget) { if (self.options.showWidget) {
Ox.$body.removeClass('OxDragging');
self.options.type == 'event' self.options.type == 'event'
? self.$calendar.resizeCalendar() ? self.$calendar.resizeCalendar()
: self.$map.resizeMap(); : self.$map.resizeMap();

View file

@ -49,7 +49,8 @@ Ox.LargeVideoTimeline = function(options, self) {
that.bindEvent({ that.bindEvent({
anyclick: click, anyclick: click,
dragstart: dragstart, dragstart: dragstart,
drag: drag drag: drag,
dragend: dragend
}); });
} }
@ -127,6 +128,7 @@ Ox.LargeVideoTimeline = function(options, self) {
} }
function dragstart(data) { function dragstart(data) {
Ox.$body.addClass('OxDragging');
self.drag = {x: data.clientX}; self.drag = {x: data.clientX};
} }
@ -140,6 +142,10 @@ Ox.LargeVideoTimeline = function(options, self) {
triggerPositionEvent(); triggerPositionEvent();
} }
function dragend() {
Ox.$body.removeClass('OxDragging');
}
function getImageURL(i, callback) { function getImageURL(i, callback) {
if (!self.isAsync) { if (!self.isAsync) {
callback(self.options.getImageURL(self.options.type, i)); callback(self.options.getImageURL(self.options.type, i));

View file

@ -1250,6 +1250,7 @@ Ox.VideoPlayer = function(options, self) {
} }
function dragstart() { function dragstart() {
Ox.$body.addClass('OxDragging');
self.drag = { self.drag = {
position: self.options.position, position: self.options.position,
paused: self.options.paused paused: self.options.paused
@ -1265,6 +1266,7 @@ Ox.VideoPlayer = function(options, self) {
} }
function dragend() { function dragend() {
Ox.$body.removeClass('OxDragging');
!self.drag.paused && togglePaused(); !self.drag.paused && togglePaused();
} }

View file

@ -234,6 +234,7 @@ Ox.Dialog = function(options, self) {
function dragstart(event) { function dragstart(event) {
var offset; var offset;
if (!$(event.target).is('.OxButton')) { if (!$(event.target).is('.OxButton')) {
Ox.$body.addClass('OxDragging');
offset = that.offset(); offset = that.offset();
self.drag = { self.drag = {
left: offset.left, left: offset.left,
@ -262,8 +263,11 @@ Ox.Dialog = function(options, self) {
} }
} }
function dragend() { function dragend(event) {
that.unwrap(); if (!$(event.target).is('.OxButton')) {
Ox.$body.removeClass('OxDragging');
that.unwrap();
}
} }
function getButtonById(id) { function getButtonById(id) {
@ -329,6 +333,7 @@ Ox.Dialog = function(options, self) {
} }
function resizestart(event) { function resizestart(event) {
Ox.$body.addClass('OxDragging');
var edge = event.target.className.slice(17).toLowerCase(), var edge = event.target.className.slice(17).toLowerCase(),
offset = that.offset(); offset = that.offset();
self.drag = { self.drag = {
@ -506,6 +511,7 @@ Ox.Dialog = function(options, self) {
} }
function resizeend() { function resizeend() {
Ox.$body.removeClass('OxDragging');
that.unwrap(); that.unwrap();
that.triggerEvent('resizeend', { that.triggerEvent('resizeend', {
width: self.options.width, width: self.options.width,