forked from 0x2620/oxjs
slightly faster text list construction for cells that don't have tooltips; make calendar layout deterministic for events that have the same time span
This commit is contained in:
parent
5948d2c2ce
commit
527f75b009
4 changed files with 44 additions and 26 deletions
|
|
@ -583,6 +583,7 @@ Ox.Calendar = function(options, self) {
|
|||
event.id = Ox.isUndefined(event.id) ? Ox.uid() : event.id;
|
||||
event.startTime = Ox.parseDate(event.start, true);
|
||||
event.endTime = Ox.parseDate(event.end, true);
|
||||
event.durationTime = event.endTime - event.startTime;
|
||||
event.rangeText = Ox.formatDateRange(event.start, event.end, true);
|
||||
event.durationText = Ox.formatDateRangeDuration(event.start, event.end, true);
|
||||
if (event.current) {
|
||||
|
|
@ -651,7 +652,8 @@ Ox.Calendar = function(options, self) {
|
|||
// filter out events with types not shown
|
||||
return self.options.showTypes.indexOf(event.type) > -1;
|
||||
}).sort(function(a, b) {
|
||||
// sort events (dates first, people last, longer before shorter)
|
||||
// sort events (dates first, people last, longer before shorter,
|
||||
// earlier before later, otherwise alphabetically by name)
|
||||
if (a.type == 'date' && b.type != 'date') {
|
||||
return -1;
|
||||
} else if (a.type != 'date' && b.type == 'date') {
|
||||
|
|
@ -660,10 +662,12 @@ Ox.Calendar = function(options, self) {
|
|||
return 1;
|
||||
} else if (a.type != 'person' && b.type == 'person') {
|
||||
return -1;
|
||||
} else if ((b.endTime - b.startTime) != (a.endTime - a.startTime)) {
|
||||
return (b.endTime - b.startTime) - (a.endTime - a.startTime);
|
||||
} else /*if (a.startTime < b.startTime || a.startTime > b.startTime)*/ {
|
||||
} else if (a.durationTime != b.durationTime) {
|
||||
return b.durationTime - a.durationTime;
|
||||
} else if (+a.startTime != +b.startTime) {
|
||||
return a.startTime - b.startTime;
|
||||
} else {
|
||||
return a.name < b.name ? -1 : 1;
|
||||
}
|
||||
}).forEach(function(event, i) {
|
||||
var line = self.lineEvents.length;
|
||||
|
|
@ -1124,7 +1128,7 @@ Ox.Calendar = function(options, self) {
|
|||
|
||||
that.removeEvent = function() {
|
||||
Ox.print('REMOVE ... SELF.OPTIONS', self.options)
|
||||
var index = Ox.getPositionById(self.options.events, self.selected);
|
||||
var index = Ox.getPositionById(self.options.events, self.options.selected);
|
||||
self.options.events.splice(index, 1);
|
||||
getLines();
|
||||
renderCalendar();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue