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()});
function dragstart(event, e) {
function dragstart(data) {
if (self.options.resizable && !self.options.collapsed) {
self.drag = {
startPos: e[self.clientXY],
startPos: data[self.clientXY],
startSize: self.options.size
}
}
}
function drag(event, e) {
function drag(data) {
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;
self.options.size = Ox.limit(
self.drag.startSize + d * (self.isLeftOrTop ? 1 : -1),
@ -192,7 +192,7 @@ Ox.Resizebar = function(options, self) {
size: self.isLeftOrTop
? self.options.elements[1][self.dimensions[1]]()
: self.options.size
);
});
}
return that;

View file

@ -425,8 +425,8 @@ Ox.Calendar = function(options, self) {
renderCalendar();
}
function doubleclick(event, e) {
var $target = $(e.target),
function doubleclick(data) {
var $target = $(data.target),
id = $target.data('id');
if ($target.is('.OxLine > .OxEvent')) {
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)')) {
self.drag = {
top: self.$container.$element[0].scrollTop,
x: e.clientX
x: data.clientX
};
//}
}
function drag(event, e) {
function drag(data) {
if (self.drag) {
///*
var marginLeft = e.clientX - self.drag.x,
var marginLeft = data.clientX - self.drag.x,
scrollbarFactor = getScrollbarFactor();
self.$scalebar.css({
marginLeft: marginLeft + 'px'
@ -465,42 +465,42 @@ Ox.Calendar = function(options, self) {
self.$scrollbar.css({
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,
// dragging in the opposite direction should work immediately
}
}
function dragpause(event, e) {
function dragpause(data) {
if (self.drag) {
dragafter(e);
self.drag.x = e.clientX;
dragafter(data);
self.drag.x = data.clientX;
}
}
function dragend(event, e) {
function dragend(data) {
if (self.drag) {
dragafter(e);
dragafter(data);
self.drag = null;
}
}
function dragafter(e) {
function dragafter(data) {
self.$scalebar.css({marginLeft: 0});
self.$content.css({marginLeft: 0});
self.$scrollbar.css({marginLeft: 0});
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();
}
function dragstartScrollbar(event, e) {
self.drag = {x: e.clientX};
function dragstartScrollbar(data) {
self.drag = {x: data.clientX};
}
function dragScrollbar(event, e) {
var marginLeft = e.clientX - self.drag.x,
function dragScrollbar(data) {
var marginLeft = data.clientX - self.drag.x,
scrollbarFactor = getScrollbarFactor();
self.$scalebar.css({
marginLeft: (marginLeft * scrollbarFactor) + 'px'
@ -513,23 +513,23 @@ Ox.Calendar = function(options, self) {
});
}
function dragpauseScrollbar(event, e) {
dragafterScrollbar(e);
self.drag = {x: e.clientX};
function dragpauseScrollbar(data) {
dragafterScrollbar(data);
self.drag = {x: data.clientX};
}
function dragendScrollbar(event, e) {
dragafterScrollbar(e);
function dragendScrollbar(data) {
dragafterScrollbar(data);
self.drag = null;
}
function dragafterScrollbar(e) {
function dragafterScrollbar(data) {
// fixme: duplicated
self.$scalebar.css({marginLeft: 0});
self.$content.css({marginLeft: 0});
self.$scrollbar.css({marginLeft: 0});
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();
}
@ -984,8 +984,8 @@ Ox.Calendar = function(options, self) {
}
}
function singleclick(event, e) {
var $target = $(e.target),
function singleclick(data) {
var $target = $(data.target),
id = $target.data('id');
if ($target.is('.OxLine > .OxEvent')) {
if (id == self.options.selected) {

View file

@ -15,121 +15,121 @@ Ox.App <f> Basic application instance that communicates with a JSON API
Ox.App = function(options) {
options = options || {};
var self = {
options: Ox.extend({
timeout: 60000,
type: 'POST',
url: '/api/',
}, options || {}),
time: new Date()
},
that = Ox.Element({}, self);
var self = {
options: Ox.extend({
timeout: 60000,
type: 'POST',
url: '/api/',
}, options || {}),
time: new Date()
},
that = Ox.Element({}, Ox.extend({}, self));
that.api = {
api: function(callback) {
Ox.Request.send({
url: self.options.url,
data: {
action: 'api'
},
callback: callback
that.api = {
api: function(callback) {
Ox.Request.send({
url: self.options.url,
data: {
action: 'api'
},
callback: callback
});
},
cancel: function(id) {
Ox.Request.cancel(id);
}
};
$.ajaxSetup({
timeout: self.options.timeout,
type: self.options.type,
url: self.options.url
});
/*@
api <o> bakcend API
[action] <f> all api requests available on backend
cancel <f> cancel a request
options <f> get or set options
@*/
that.api.api(function(result) {
Ox.print('RESULT', result)
Ox.forEach(result.data.actions, function(val, key) {
that.api[key] = function(/*data, age, callback*/) {
var data = {}, age = -1, callback = null;
Ox.forEach(arguments, function(argument) {
if (Ox.isObject(argument)) {
data = argument;
} else if (Ox.isNumber(argument)) {
age = argument;
} else if (Ox.isFunction(argument)) {
callback = argument;
}
});
return Ox.Request.send(Ox.extend({
age: age,
callback: callback,
data: {
action: key,
data: JSON.stringify(data)
},
url: self.options.url
}, !val.cache ? {age: 0}: {}));
};
});
that.api.init(getUserData(), function(result) {
//Ox.UI.hideLoadingScreen();
that.triggerEvent({
load: result.data
});
});
});
function getUserData() {
return {
document: {
referrer: document.referrer
},
cancel: function(id) {
Ox.Request.cancel(id);
history: {
length: history.length
},
navigator: {
cookieEnabled: navigator.cookieEnabled,
plugins: Ox.makeArray(navigator.plugins).map(function(plugin) {
return plugin.name;
}),
userAgent: navigator.userAgent
},
screen: screen,
time: (+new Date() - self.time) / 1000,
window: {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth,
outerHeight: window.outerHeight,
outerWidth: window.outerWidth,
screenLeft: window.screenLeft,
screenTop: window.screenTop
}
};
}
$.ajaxSetup({
timeout: self.options.timeout,
type: self.options.type,
url: self.options.url
});
/*@
change <f> change key/value
(key, value) -> <u> currently not implemented
@*/
self.setOption = function(key, value) {
/*@
api <o> bakcend API
[action] <f> all api requests available on backend
cancel <f> cancel a request
options <f> get or set options
@*/
that.api.api(function(result) {
Ox.forEach(result.data.actions, function(val, key) {
that.api[key] = function(/*data, age, callback*/) {
var data = {}, age = -1, callback = null;
Ox.forEach(arguments, function(argument) {
if (Ox.isObject(argument)) {
data = argument;
} else if (Ox.isNumber(argument)) {
age = argument;
} else if (Ox.isFunction(argument)) {
callback = argument;
}
});
return Ox.Request.send(Ox.extend({
age: age,
callback: callback,
data: {
action: key,
data: JSON.stringify(data)
},
url: self.options.url
}, !val.cache ? {age: 0}: {}));
};
});
that.api.init(getUserData(), function(result) {
//Ox.UI.hideLoadingScreen();
that.triggerEvent({
load: result.data
});
});
});
};
function getUserData() {
return {
document: {
referrer: document.referrer
},
history: {
length: history.length
},
navigator: {
cookieEnabled: navigator.cookieEnabled,
plugins: Ox.makeArray(navigator.plugins).map(function(plugin) {
return plugin.name;
}),
userAgent: navigator.userAgent
},
screen: screen,
time: (+new Date() - self.time) / 1000,
window: {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth,
outerHeight: window.outerHeight,
outerWidth: window.outerWidth,
screenLeft: window.screenLeft,
screenTop: window.screenTop
}
};
}
/*@
options <f> get/set options, see Ox.getset
() -> <o> get options
(options) -> <o> update/set options
@*/
that.options = function() {
return Ox.getset(self.options, Array.prototype.slice.call(arguments), self.change, that);
};
/*@
change <f> change key/value
(key, value) -> <u> currently not implemented
@*/
self.change = function(key, value) {
};
/*@
options <f> get/set options, see Ox.getset
() -> <o> get options
(options) -> <o> update/set options
@*/
that.options = function() {
return Ox.getset(self.options, Array.prototype.slice.call(arguments), self.change, that);
};
return that;
return that;
};

View file

@ -64,7 +64,7 @@ Ox.Request = function(options) {
options <o> Options Object
@*/
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')
.bindEvent({
mousedown: function(event, e) {
clickArrow(e, i, true);
mousedown: function(data) {
clickArrow(data, i, true);
},
mouserepeat: function(event, e) {
clickArrow(e, i, false);
mouserepeat: function(data) {
clickArrow(data, i, false);
}
})
.appendTo(that.$element);
@ -143,23 +143,23 @@ Ox.Range = function(options, self) {
setThumb();
function clickArrow(e, i, animate) {
function clickArrow(data, i, animate) {
// 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
var isThumb = $(e.target).hasClass('OxThumb');
var isThumb = $(edatatarget).hasClass('OxThumb');
self.drag = {
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) {
setValue(getVal(e.clientX - self.drag.left - self.drag.offset))
function dragTrack(data) {
setValue(getVal(data.clientX - self.drag.left - self.drag.offset))
}
function getPx(val) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -101,24 +101,24 @@ Ox.LargeTimeline = function(options, self) {
setWidth();
setPosition();
function click(event, e) {
function click(data) {
self.options.position = Ox.limit(
getPosition(e), 0, self.options.duration
getPosition(data), 0, self.options.duration
);
setPosition();
triggerChangeEvent();
}
function dragstart(event, e) {
self.drag = {x: e.clientX};
function dragstart(data) {
self.drag = {x: data.clientX};
}
function drag(event, e) {
function drag(data) {
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
);
self.drag.x = e.clientX;
self.drag.x = data.clientX;
setPosition();
triggerChangeEvent();
}

View file

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

View file

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

View file

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