some bugfixes

This commit is contained in:
rlx 2011-09-17 11:49:29 +00:00
parent 4cc754a28d
commit ef1fa5fe84
14 changed files with 228 additions and 229 deletions

View file

@ -63,18 +63,18 @@ Ox.Resizebar = function(options, self) {
that.css({cursor: getCursor()}); that.css({cursor: getCursor()});
function dragstart(event, e) { function dragstart(data) {
if (self.options.resizable && !self.options.collapsed) { if (self.options.resizable && !self.options.collapsed) {
self.drag = { self.drag = {
startPos: e[self.clientXY], startPos: data[self.clientXY],
startSize: self.options.size startSize: self.options.size
} }
} }
} }
function drag(event, e) { function drag(data) {
if (self.options.resizable && !self.options.collapsed) { if (self.options.resizable && !self.options.collapsed) {
var d = e[self.clientXY] - self.drag.startPos, var d = data[self.clientXY] - self.drag.startPos,
size = self.options.size; size = self.options.size;
self.options.size = Ox.limit( self.options.size = Ox.limit(
self.drag.startSize + d * (self.isLeftOrTop ? 1 : -1), self.drag.startSize + d * (self.isLeftOrTop ? 1 : -1),
@ -192,7 +192,7 @@ Ox.Resizebar = function(options, self) {
size: self.isLeftOrTop size: self.isLeftOrTop
? self.options.elements[1][self.dimensions[1]]() ? self.options.elements[1][self.dimensions[1]]()
: self.options.size : self.options.size
); });
} }
return that; return that;

View file

@ -425,8 +425,8 @@ Ox.Calendar = function(options, self) {
renderCalendar(); renderCalendar();
} }
function doubleclick(event, e) { function doubleclick(data) {
var $target = $(e.target), var $target = $(data.target),
id = $target.data('id'); id = $target.data('id');
if ($target.is('.OxLine > .OxEvent')) { if ($target.is('.OxLine > .OxEvent')) {
selectEvent(id, $target); selectEvent(id, $target);
@ -442,19 +442,19 @@ Ox.Calendar = function(options, self) {
} }
} }
function dragstart(event, e) { function dragstart(data) {
//if ($(e.target).is(':not(.OxLine > .OxEvent)')) { //if ($(e.target).is(':not(.OxLine > .OxEvent)')) {
self.drag = { self.drag = {
top: self.$container.$element[0].scrollTop, top: self.$container.$element[0].scrollTop,
x: e.clientX x: data.clientX
}; };
//} //}
} }
function drag(event, e) { function drag(data) {
if (self.drag) { if (self.drag) {
///* ///*
var marginLeft = e.clientX - self.drag.x, var marginLeft = data.clientX - self.drag.x,
scrollbarFactor = getScrollbarFactor(); scrollbarFactor = getScrollbarFactor();
self.$scalebar.css({ self.$scalebar.css({
marginLeft: marginLeft + 'px' marginLeft: marginLeft + 'px'
@ -465,42 +465,42 @@ Ox.Calendar = function(options, self) {
self.$scrollbar.css({ self.$scrollbar.css({
marginLeft: Math.round(marginLeft / scrollbarFactor) + 'px' marginLeft: Math.round(marginLeft / scrollbarFactor) + 'px'
}); });
scrollTo(self.drag.top - e.clientDY); scrollTo(self.drag.top - data.clientDY);
// fixme: after dragging too far in one direction, // fixme: after dragging too far in one direction,
// dragging in the opposite direction should work immediately // dragging in the opposite direction should work immediately
} }
} }
function dragpause(event, e) { function dragpause(data) {
if (self.drag) { if (self.drag) {
dragafter(e); dragafter(data);
self.drag.x = e.clientX; self.drag.x = data.clientX;
} }
} }
function dragend(event, e) { function dragend(data) {
if (self.drag) { if (self.drag) {
dragafter(e); dragafter(data);
self.drag = null; self.drag = null;
} }
} }
function dragafter(e) { function dragafter(data) {
self.$scalebar.css({marginLeft: 0}); self.$scalebar.css({marginLeft: 0});
self.$content.css({marginLeft: 0}); self.$content.css({marginLeft: 0});
self.$scrollbar.css({marginLeft: 0}); self.$scrollbar.css({marginLeft: 0});
self.options.date = new Date( self.options.date = new Date(
+self.options.date - (e.clientX - self.drag.x) * getSecondsPerPixel() * 1000 +self.options.date - (data.clientX - self.drag.x) * getSecondsPerPixel() * 1000
); );
renderCalendar(); renderCalendar();
} }
function dragstartScrollbar(event, e) { function dragstartScrollbar(data) {
self.drag = {x: e.clientX}; self.drag = {x: data.clientX};
} }
function dragScrollbar(event, e) { function dragScrollbar(data) {
var marginLeft = e.clientX - self.drag.x, var marginLeft = data.clientX - self.drag.x,
scrollbarFactor = getScrollbarFactor(); scrollbarFactor = getScrollbarFactor();
self.$scalebar.css({ self.$scalebar.css({
marginLeft: (marginLeft * scrollbarFactor) + 'px' marginLeft: (marginLeft * scrollbarFactor) + 'px'
@ -513,23 +513,23 @@ Ox.Calendar = function(options, self) {
}); });
} }
function dragpauseScrollbar(event, e) { function dragpauseScrollbar(data) {
dragafterScrollbar(e); dragafterScrollbar(data);
self.drag = {x: e.clientX}; self.drag = {x: data.clientX};
} }
function dragendScrollbar(event, e) { function dragendScrollbar(data) {
dragafterScrollbar(e); dragafterScrollbar(data);
self.drag = null; self.drag = null;
} }
function dragafterScrollbar(e) { function dragafterScrollbar(data) {
// fixme: duplicated // fixme: duplicated
self.$scalebar.css({marginLeft: 0}); self.$scalebar.css({marginLeft: 0});
self.$content.css({marginLeft: 0}); self.$content.css({marginLeft: 0});
self.$scrollbar.css({marginLeft: 0}); self.$scrollbar.css({marginLeft: 0});
self.options.date = new Date( self.options.date = new Date(
+self.options.date + (self.drag.x - e.clientX) * getSecondsPerPixel() * 1000 * getScrollbarFactor() +self.options.date + (self.drag.x - data.clientX) * getSecondsPerPixel() * 1000 * getScrollbarFactor()
); );
renderCalendar(); renderCalendar();
} }
@ -984,8 +984,8 @@ Ox.Calendar = function(options, self) {
} }
} }
function singleclick(event, e) { function singleclick(data) {
var $target = $(e.target), var $target = $(data.target),
id = $target.data('id'); id = $target.data('id');
if ($target.is('.OxLine > .OxEvent')) { if ($target.is('.OxLine > .OxEvent')) {
if (id == self.options.selected) { if (id == self.options.selected) {

View file

@ -15,7 +15,6 @@ Ox.App <f> Basic application instance that communicates with a JSON API
Ox.App = function(options) { Ox.App = function(options) {
options = options || {};
var self = { var self = {
options: Ox.extend({ options: Ox.extend({
timeout: 60000, timeout: 60000,
@ -24,7 +23,7 @@ Ox.App = function(options) {
}, options || {}), }, options || {}),
time: new Date() time: new Date()
}, },
that = Ox.Element({}, self); that = Ox.Element({}, Ox.extend({}, self));
that.api = { that.api = {
api: function(callback) { api: function(callback) {
@ -54,6 +53,7 @@ Ox.App = function(options) {
options <f> get or set options options <f> get or set options
@*/ @*/
that.api.api(function(result) { that.api.api(function(result) {
Ox.print('RESULT', result)
Ox.forEach(result.data.actions, function(val, key) { Ox.forEach(result.data.actions, function(val, key) {
that.api[key] = function(/*data, age, callback*/) { that.api[key] = function(/*data, age, callback*/) {
var data = {}, age = -1, callback = null; var data = {}, age = -1, callback = null;
@ -117,7 +117,7 @@ Ox.App = function(options) {
change <f> change key/value change <f> change key/value
(key, value) -> <u> currently not implemented (key, value) -> <u> currently not implemented
@*/ @*/
self.change = function(key, value) { self.setOption = function(key, value) {
}; };

View file

@ -64,7 +64,7 @@ Ox.Request = function(options) {
options <o> Options Object options <o> Options Object
@*/ @*/
options: function(options) { options: function(options) {
return Ox.getset(self.options, options, $.noop(), this); return Ox.getset(self.options, options, function() {}, this);
}, },
/*@ /*@

View file

@ -73,11 +73,11 @@ Ox.Range = function(options, self) {
}) })
.addClass('OxArrow') .addClass('OxArrow')
.bindEvent({ .bindEvent({
mousedown: function(event, e) { mousedown: function(data) {
clickArrow(e, i, true); clickArrow(data, i, true);
}, },
mouserepeat: function(event, e) { mouserepeat: function(data) {
clickArrow(e, i, false); clickArrow(data, i, false);
} }
}) })
.appendTo(that.$element); .appendTo(that.$element);
@ -143,23 +143,23 @@ Ox.Range = function(options, self) {
setThumb(); setThumb();
function clickArrow(e, i, animate) { function clickArrow(data, i, animate) {
// fixme: shift doesn't work, see menu scrolling // fixme: shift doesn't work, see menu scrolling
setValue(self.options.value + self.options.arrowStep * (i == 0 ? -1 : 1) * (e.shiftKey ? 2 : 1), animate); setValue(self.options.value + self.options.arrowStep * (i == 0 ? -1 : 1) * (data.shiftKey ? 2 : 1), animate);
} }
function clickTrack(event, e) { function clickTrack(data) {
// fixme: thumb ends up a bit too far on the right // fixme: thumb ends up a bit too far on the right
var isThumb = $(e.target).hasClass('OxThumb'); var isThumb = $(edatatarget).hasClass('OxThumb');
self.drag = { self.drag = {
left: self.$track.offset().left, left: self.$track.offset().left,
offset: isThumb ? e.clientX - self.$thumb.offset().left - 8 /*self.thumbSize / 2*/ : 0 offset: isThumb ? data.clientX - self.$thumb.offset().left - 8 /*self.thumbSize / 2*/ : 0
}; };
setValue(getVal(e.clientX - self.drag.left - self.drag.offset), !isThumb); setValue(getVal(data.clientX - self.drag.left - self.drag.offset), !isThumb);
} }
function dragTrack(event, e) { function dragTrack(data) {
setValue(getVal(e.clientX - self.drag.left - self.drag.offset)) setValue(getVal(data.clientX - self.drag.left - self.drag.offset))
} }
function getPx(val) { function getPx(val) {

View file

@ -345,8 +345,8 @@ Ox.List = function(options, self) {
} }
} }
function dragstart(event, e) { function dragstart(data) {
var $target = $(e.target), var $target = $(data.target),
$parent = $target.parent(); $parent = $target.parent();
if ( if (
$target.is('.OxTarget') // icon lists $target.is('.OxTarget') // icon lists
@ -360,44 +360,44 @@ Ox.List = function(options, self) {
// automatically passed already, somewhere? // automatically passed already, somewhere?
that.triggerEvent('draganddropstart', { that.triggerEvent('draganddropstart', {
ids: self.drag.ids, ids: self.drag.ids,
_event: e _event: data
}); });
} }
} }
function drag(event, e) { function drag(data) {
self.drag && that.triggerEvent('draganddrop', { self.drag && that.triggerEvent('draganddrop', {
ids: self.drag.ids, ids: self.drag.ids,
_event: e _event: data
}); });
} }
function dragpause(event, e) { function dragpause(data) {
self.drag && that.triggerEvent('draganddroppause', { self.drag && that.triggerEvent('draganddroppause', {
ids: self.drag.ids, ids: self.drag.ids,
_event: e _event: data
}); });
} }
function dragenter(event, e) { function dragenter(data) {
self.drag && that.triggerEvent('draganddropenter', { self.drag && that.triggerEvent('draganddropenter', {
ids: self.drag.ids, ids: self.drag.ids,
_event: e _event: data
}); });
} }
function dragleave(event, e) { function dragleave(data) {
self.drag && that.triggerEvent('draganddropleave', { self.drag && that.triggerEvent('draganddropleave', {
ids: self.drag.ids, ids: self.drag.ids,
_event: e _event: data
}); });
} }
function dragend(event, e) { function dragend(data) {
if (self.drag) { if (self.drag) {
that.triggerEvent('draganddropend', { that.triggerEvent('draganddropend', {
ids: self.drag.ids, ids: self.drag.ids,
_event: e _event: data
}); });
delete self.drag; delete self.drag;
} }
@ -763,12 +763,12 @@ Ox.List = function(options, self) {
loadPage(page + 1, fn); loadPage(page + 1, fn);
} }
function mousedown(event, e) { function mousedown(data) {
var pos = findItemPosition(e); var pos = findItemPosition(data);
self.hadFocus = that.hasFocus(); self.hadFocus = that.hasFocus();
that.gainFocus(); that.gainFocus();
if (pos > -1) { if (pos > -1) {
if (e.metaKey) { if (data.metaKey) {
if (!isSelected(pos) && (self.options.max == -1 || self.options.max > self.selected.length)) { if (!isSelected(pos) && (self.options.max == -1 || self.options.max > self.selected.length)) {
// meta-click on unselected item // meta-click on unselected item
addToSelection(pos); addToSelection(pos);
@ -776,7 +776,7 @@ Ox.List = function(options, self) {
// meta-click on selected item // meta-click on selected item
deselect(pos); deselect(pos);
} }
} else if (e.shiftKey) { } else if (data.shiftKey) {
if (self.options.max == -1) { if (self.options.max == -1) {
// shift-click on item // shift-click on item
addAllToSelection(pos); addAllToSelection(pos);
@ -785,20 +785,20 @@ Ox.List = function(options, self) {
// click on unselected item // click on unselected item
select(pos); select(pos);
} }
} else if (!$(e.target).is('.OxToggle') && self.options.min == 0) { } else if (!$(data.target).is('.OxToggle') && self.options.min == 0) {
// click on empty area // click on empty area
selectNone(); selectNone();
} }
} }
function movestart(event, e) { function movestart(data) {
self.drag = { self.drag = {
pos: findItemPosition(e) pos: findItemPosition(data)
}; };
Ox.extend(self.drag, { Ox.extend(self.drag, {
id: self.$items[self.drag.pos].options('data')[self.options.unique], id: self.$items[self.drag.pos].options('data')[self.options.unique],
startPos: self.drag.pos, startPos: self.drag.pos,
startY: e.clientY, startY: data.clientY,
stopPos: self.drag.pos stopPos: self.drag.pos
}); });
self.$items[self.drag.pos] self.$items[self.drag.pos]
@ -808,8 +808,8 @@ Ox.List = function(options, self) {
}); });
} }
function move(event, e) { function move(data) {
var clientY = e.clientY - that.offset()['top'], var clientY = data.clientY - that.offset()['top'],
offset = clientY % 16, offset = clientY % 16,
position = Ox.limit(parseInt(clientY / 16), 0, self.$items.length - 1); position = Ox.limit(parseInt(clientY / 16), 0, self.$items.length - 1);
if (position < self.drag.pos) { if (position < self.drag.pos) {
@ -823,7 +823,7 @@ Ox.List = function(options, self) {
} }
} }
function moveend(event, e) { function moveend(data) {
var $item = self.$items[self.drag.pos]; var $item = self.$items[self.drag.pos];
$item.removeClass('OxDrag') $item.removeClass('OxDrag')
.css({ .css({
@ -839,10 +839,10 @@ Ox.List = function(options, self) {
delete self.drag; delete self.drag;
} }
function singleclick(event, e) { function singleclick(data) {
// these can't trigger on mousedown, // these can't trigger on mousedown,
// since it could be a doubleclick // since it could be a doubleclick
var pos = findItemPosition(e), var pos = findItemPosition(data),
clickable, editable; clickable, editable;
//alert('singleclick') //alert('singleclick')
if (pos > -1) { if (pos > -1) {
@ -867,7 +867,7 @@ Ox.List = function(options, self) {
} }
} }
function doubleclick(event, e) { function doubleclick(data) {
open(); open();
} }

View file

@ -326,17 +326,17 @@ Ox.TextList = function(options, self) {
// if columns are movable, bind drag events // if columns are movable, bind drag events
if (self.options.columnsMovable) { if (self.options.columnsMovable) {
self.$heads[i].bindEvent({ self.$heads[i].bindEvent({
dragstart: function(event, e) { dragstart: function(data) {
dragstartColumn(column.id, e); dragstartColumn(column.id, data);
}, },
drag: function(event, e) { drag: function(data) {
dragColumn(column.id, e); dragColumn(column.id, data);
}, },
dragpause: function(event, e) { dragpause: function(data) {
dragpauseColumn(column.id, e); dragpauseColumn(column.id, data);
}, },
dragend: function(event, e) { dragend: function(data) {
dragendColumn(column.id, e); dragendColumn(column.id, data);
} }
}) })
} }
@ -369,17 +369,17 @@ Ox.TextList = function(options, self) {
if (self.options.columnsResizable) { if (self.options.columnsResizable) {
$resize.addClass('OxResizable') $resize.addClass('OxResizable')
.bindEvent({ .bindEvent({
doubleclick: function(event, e) { doubleclick: function(data) {
resetColumn(column.id, e); resetColumn(column.id, data);
}, },
dragstart: function(event, e) { dragstart: function(data) {
dragstartResize(column.id, e); dragstartResize(column.id, data);
}, },
drag: function(event, e) { drag: function(data) {
dragResize(column.id, e); dragResize(column.id, data);
}, },
dragend: function(event, e) { dragend: function(data) {
dragendResize(column.id, e); dragendResize(column.id, data);
} }
}); });
} }

View file

@ -273,10 +273,9 @@ Ox.SplitPanel = function(options, self) {
'collapsed': element.collapsed 'collapsed': element.collapsed
}); });
element = self.options.elements[pos == 0 ? 1 : pos - 1]; element = self.options.elements[pos == 0 ? 1 : pos - 1];
element.element.triggerEvent( element.element.triggerEvent('resize', {size:
'resize',
element.element[self.dimensions[0]]() element.element[self.dimensions[0]]()
); });
}); });
}; };
@ -356,14 +355,14 @@ Ox.SplitPanel_ = function(options, self) {
anyclick: function() { anyclick: function() {
that.toggle(i); that.toggle(i);
}, },
dragstart: function(event, e) { dragstart: function(data) {
dragstart(i, e); dragstart(i, data);
}, },
drag: function(event, e) { drag: function(data) {
drag(i, e); drag(i, data);
}, },
dragend: function(event, e) { dragend: function(data) {
dragend(i, e); dragend(i, data);
}, },
}) })
.append($('<div>').addClass('OxSpace')) .append($('<div>').addClass('OxSpace'))

View file

@ -29,8 +29,8 @@ Ox.BlockTimeline = function(options, self) {
.mouseleave(mouseleave) .mouseleave(mouseleave)
.mousemove(mousemove) .mousemove(mousemove)
.bindEvent({ .bindEvent({
drag: function(event, e) { drag: function(data) {
mousedown(e); mousedown(data);
} }
}); });

View file

@ -26,8 +26,8 @@ Ox.BlockVideoTimeline = function(options, self) {
mousemove: mousemove mousemove: mousemove
}) })
.bindEvent({ .bindEvent({
drag: function(event, e) { drag: function(data) {
mousedown(e); mousedown(data);
} }
}); });

View file

@ -101,24 +101,24 @@ Ox.LargeTimeline = function(options, self) {
setWidth(); setWidth();
setPosition(); setPosition();
function click(event, e) { function click(data) {
self.options.position = Ox.limit( self.options.position = Ox.limit(
getPosition(e), 0, self.options.duration getPosition(data), 0, self.options.duration
); );
setPosition(); setPosition();
triggerChangeEvent(); triggerChangeEvent();
} }
function dragstart(event, e) { function dragstart(data) {
self.drag = {x: e.clientX}; self.drag = {x: data.clientX};
} }
function drag(event, e) { function drag(data) {
self.options.position = Ox.limit( self.options.position = Ox.limit(
self.options.position + (self.drag.x - e.clientX) / self.fps, self.options.position + (self.drag.x - data.clientX) / self.fps,
0, self.options.duration 0, self.options.duration
); );
self.drag.x = e.clientX; self.drag.x = data.clientX;
setPosition(); setPosition();
triggerChangeEvent(); triggerChangeEvent();
} }

View file

@ -94,24 +94,24 @@ Ox.LargeVideoTimeline = function(options, self) {
setWidth(); setWidth();
setPosition(); setPosition();
function click(event, e) { function click(data) {
self.options.position = Ox.round(Ox.limit( self.options.position = Ox.round(Ox.limit(
getPosition(e), 0, self.options.duration getPosition(data), 0, self.options.duration
), 3); ), 3);
setPosition(); setPosition();
triggerPositionEvent(); triggerPositionEvent();
} }
function dragstart(event, e) { function dragstart(data) {
self.drag = {x: e.clientX}; self.drag = {x: data.clientX};
} }
function drag(event, e) { function drag(data) {
self.options.position = Ox.round(Ox.limit( self.options.position = Ox.round(Ox.limit(
self.options.position + (self.drag.x - e.clientX) / self.fps, self.options.position + (self.drag.x - data.clientX) / self.fps,
0, self.options.duration 0, self.options.duration
), 3); ), 3);
self.drag.x = e.clientX; self.drag.x = data.clientX;
setPosition(); setPosition();
triggerPositionEvent(); triggerPositionEvent();
} }

View file

@ -29,8 +29,8 @@ Ox.SmallTimeline = function(options, self) {
.mouseleave(mouseleave) .mouseleave(mouseleave)
.mousemove(mousemove) .mousemove(mousemove)
.bindEvent({ .bindEvent({
drag: function(event, e) { drag: function(data) {
mousedown(e); mousedown(data);
} }
}); });

View file

@ -55,12 +55,12 @@ Ox.SmallVideoTimeline = function(options, self) {
mousedown: mousedown mousedown: mousedown
}) })
.bindEvent({ .bindEvent({
drag: function(event, e) { drag: function(data) {
mousedown(e); mousedown(data);
}, },
dragend: function(event, e) { dragend: function(data) {
self.triggered = false; self.triggered = false;
mousedown(e); mousedown(data);
} }
}) })
.appendTo(that); .appendTo(that);