forked from 0x2620/oxjs
update map and calendar
This commit is contained in:
parent
f61e39a788
commit
30088ad0b1
5 changed files with 73 additions and 96 deletions
|
|
@ -44,10 +44,12 @@ Ox.Calendar = function(options, self) {
|
|||
})
|
||||
.options(options || {})
|
||||
.addClass('OxCalendar')
|
||||
/*
|
||||
.css({
|
||||
//width: self.options.width + 'px',
|
||||
//height: self.options.height + 'px'
|
||||
width: self.options.width + 'px',
|
||||
height: self.options.height + 'px'
|
||||
})
|
||||
*/
|
||||
.bindEvent({
|
||||
key_0: function() {
|
||||
panToSelected();
|
||||
|
|
@ -294,22 +296,21 @@ Ox.Calendar = function(options, self) {
|
|||
|
||||
self.$typeSelect = Ox.Select({
|
||||
items: [
|
||||
{id: 'date', title: 'Dates', checked: self.options.showTypes.indexOf('date') > -1},
|
||||
{id: 'place', title: 'Places', checked: self.options.showTypes.indexOf('place') > -1},
|
||||
{id: 'person', title: 'People', checked: self.options.showTypes.indexOf('person') > -1},
|
||||
{id: 'other', title: 'Other', checked: self.options.showTypes.indexOf('other') > -1}
|
||||
{id: 'date', title: 'Dates'},
|
||||
{id: 'place', title: 'Places'},
|
||||
{id: 'person', title: 'People'},
|
||||
{id: 'other', title: 'Other'}
|
||||
],
|
||||
max: -1,
|
||||
min: 1,
|
||||
title: 'Show...',
|
||||
value: self.options.showTypes,
|
||||
width: 80
|
||||
})
|
||||
.css({float: 'left', margin: '4px'})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
self.options.showTypes = data.value.map(function(type) {
|
||||
return type.id;
|
||||
});
|
||||
self.options.showTypes = data.value;
|
||||
getLines();
|
||||
renderCalendar();
|
||||
}
|
||||
|
|
@ -589,7 +590,8 @@ Ox.Calendar = function(options, self) {
|
|||
self.$content.css({marginLeft: 0});
|
||||
self.$scrollbar.css({marginLeft: 0});
|
||||
self.options.date = new Date(
|
||||
+self.options.date - (data.clientX - self.drag.x) * getSecondsPerPixel() * 1000
|
||||
+self.options.date
|
||||
- (data.clientX - self.drag.x) * getSecondsPerPixel() * 1000
|
||||
);
|
||||
renderCalendar();
|
||||
}
|
||||
|
|
@ -628,7 +630,9 @@ Ox.Calendar = function(options, self) {
|
|||
self.$content.css({marginLeft: 0});
|
||||
self.$scrollbar.css({marginLeft: 0});
|
||||
self.options.date = new Date(
|
||||
+self.options.date + (self.drag.x - data.clientX) * getSecondsPerPixel() * 1000 * getScrollbarFactor()
|
||||
+self.options.date
|
||||
+ (self.drag.x - data.clientX) * getSecondsPerPixel() * 1000
|
||||
* getScrollbarFactor()
|
||||
);
|
||||
renderCalendar();
|
||||
}
|
||||
|
|
@ -643,21 +647,21 @@ Ox.Calendar = function(options, self) {
|
|||
value = unit.value(self.options.date),
|
||||
width = Math.round(unit.seconds * getPixelsPerSecond(zoom)),
|
||||
n = Math.ceil(self.options.width * 1.5/* * 16*/ / width);
|
||||
Ox.loop(-n, n + 1, function(i) {
|
||||
if (u == 0 || Ox.mod(value + i, 2)) {
|
||||
$elements.push(
|
||||
Ox.Element()
|
||||
.addClass(
|
||||
u == 0 ? 'line' : ''
|
||||
)
|
||||
.css({
|
||||
left: getPosition(unit.date(value + i), zoom) + 'px',
|
||||
width: (u == 0 ? 1 : width) + 'px',
|
||||
height: self.contentHeight + 'px'
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
Ox.loop(-n, n + 1, function(i) {
|
||||
if (u == 0 || Ox.mod(value + i, 2)) {
|
||||
$elements.push(
|
||||
Ox.Element()
|
||||
.addClass(
|
||||
u == 0 ? 'line' : ''
|
||||
)
|
||||
.css({
|
||||
left: getPosition(unit.date(value + i), zoom) + 'px',
|
||||
width: (u == 0 ? 1 : width) + 'px',
|
||||
height: self.contentHeight + 'px'
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
return $elements;
|
||||
}
|
||||
|
|
@ -869,8 +873,6 @@ Ox.Calendar = function(options, self) {
|
|||
value = unit.value(self.options.date),
|
||||
width = unit.seconds * getPixelsPerSecond(zoom),
|
||||
n = Math.ceil(self.options.width * 1.5/* * 16*/ / width);
|
||||
//Ox.Log('Calendar', zoom, getUnits(zoom).map(function(u) {return u.name(value)}).join('/'))
|
||||
//Ox.Log('Calendar', 'VALUE', value)
|
||||
Ox.loop(-n, n + 1, function(i) {
|
||||
$elements.push(
|
||||
getEventElement({
|
||||
|
|
@ -947,9 +949,11 @@ Ox.Calendar = function(options, self) {
|
|||
|
||||
function overlaps(eventA, eventB) {
|
||||
return (
|
||||
eventA.startTime >= eventB.startTime && eventA.startTime < eventB.endTime
|
||||
eventA.startTime >= eventB.startTime
|
||||
&& eventA.startTime < eventB.endTime
|
||||
) || (
|
||||
eventB.startTime >= eventA.startTime && eventB.startTime < eventA.endTime
|
||||
eventB.startTime >= eventA.startTime
|
||||
&& eventB.startTime < eventA.endTime
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -958,9 +962,13 @@ Ox.Calendar = function(options, self) {
|
|||
}
|
||||
|
||||
function panTo(date, line) {
|
||||
var delta = Math.round((date - self.options.date) / 1000 * getPixelsPerSecond()),
|
||||
var delta = Math.round(
|
||||
(date - self.options.date) / 1000 * getPixelsPerSecond()
|
||||
),
|
||||
// 250 ms for half the width of the visible area
|
||||
ms = 250 * Math.min(Math.abs(delta) / (self.$content.width() / 2), 1);
|
||||
ms = 250 * Math.min(
|
||||
Math.abs(delta) / (self.$content.width() / 2), 1
|
||||
);
|
||||
self.$scalebar.stop().animate({
|
||||
marginLeft: -delta + 'px'
|
||||
}, ms);
|
||||
|
|
@ -1203,7 +1211,7 @@ Ox.Calendar = function(options, self) {
|
|||
};
|
||||
|
||||
that.addEvent = function(event) {
|
||||
Ox.Log('Calendar', 'CALENDAR ADD EVENT', event)
|
||||
// Ox.Log('Calendar', 'CALENDAR ADD EVENT', event)
|
||||
event = getEventData(event);
|
||||
self.options.events.push(event);
|
||||
getLines();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue