diff --git a/source/Ox.UI/js/Calendar/Ox.Calendar.js b/source/Ox.UI/js/Calendar/Ox.Calendar.js index 1e449121..8806c1fe 100644 --- a/source/Ox.UI/js/Calendar/Ox.Calendar.js +++ b/source/Ox.UI/js/Calendar/Ox.Calendar.js @@ -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(); diff --git a/source/Ox.UI/js/Calendar/Ox.ListCalendar.js b/source/Ox.UI/js/Calendar/Ox.ListCalendar.js index dcb3a3f1..70908959 100644 --- a/source/Ox.UI/js/Calendar/Ox.ListCalendar.js +++ b/source/Ox.UI/js/Calendar/Ox.ListCalendar.js @@ -479,7 +479,9 @@ Ox.ListCalendar = function(options, self) { self.options.addEvent(event, function(result) { event.id = result.data.id; self.options.events.push(event); + var time0 = +new Date() self.$list.options({items: Ox.clone(self.options.events, true)}); + Ox.print('TIME TO SET LIST OPTIONS:', +new Date() - time0); self.$calendar.addEvent(event); selectEvent(event); }); @@ -491,7 +493,9 @@ Ox.ListCalendar = function(options, self) { data = {id: id}; self.options.events[index][key] = value; data[key] = value; + var time0 = +new Date(); self.$list.options({items: Ox.clone(self.options.events, true)}); + Ox.print('TIME TO SET LIST OPTIONS:', +new Date() - time0); if (['name', 'type', 'start', 'end'].indexOf(key) > -1) { self.$calendar.editEvent(id, key, value); } @@ -507,11 +511,9 @@ Ox.ListCalendar = function(options, self) { ) }); } - self.options.editEvent(data, function(result) { // ... }); - } function initList(data) { @@ -545,7 +547,9 @@ Ox.ListCalendar = function(options, self) { var id = self.selectedEvent, index = Ox.getPositionById(self.options.events, id); self.options.events.splice(index, 1); + var time0 = +new Date(); self.$list.options({items: Ox.clone(self.options.events, true)}); + Ox.print('TIME TO SET LIST OPTIONS:', +new Date() - time0); self.$calendar.removeEvent(); selectEvent({}); self.options.removeEvent({id: id}, function(result) { diff --git a/source/Ox.UI/js/List/Ox.List.js b/source/Ox.UI/js/List/Ox.List.js index 2ad27914..fe06a264 100644 --- a/source/Ox.UI/js/List/Ox.List.js +++ b/source/Ox.UI/js/List/Ox.List.js @@ -687,18 +687,24 @@ Ox.List = function(options, self) { function loadItems() { self.$page.empty(); self.$items = []; + var timeC = 0, timeA = 0; self.options.items.forEach(function(item, pos) { // fixme: duplicated + var time0 = +new Date(); self.$items[pos] = Ox.ListItem({ construct: self.options.construct, data: item, position: pos, unique: self.options.unique }); + timeC += +new Date() - time0; isSelected(pos) && self.$items[pos].addClass('OxSelected'); + var time0 = +new Date(); self.$items[pos].appendTo(self.$page); + timeA += +new Date() - time0; }); self.selected.length && scrollToPosition(self.selected[0]); + Ox.print('CONSTRUCT:', timeC, 'APPEND:', timeA); // that.triggerEvent('init', {items: self.options.items.length}); // fixme: do sync lists need to trigger init? // will this only be reached in sync lists? diff --git a/source/Ox.UI/js/List/Ox.TextList.js b/source/Ox.UI/js/List/Ox.TextList.js index 512bcd45..befe04cb 100644 --- a/source/Ox.UI/js/List/Ox.TextList.js +++ b/source/Ox.UI/js/List/Ox.TextList.js @@ -404,30 +404,35 @@ Ox.TextList = function(options, self) { self.visibleColumns.forEach(function(v, i) { var clickable = Ox.isBoolean(v.clickable) ? v.clickable : v.clickable(data), editable = Ox.isBoolean(v.editable) ? v.editable : v.editable(data), + $cell; + if (v.tooltip) { $cell = Ox.Element({ - tooltip: v.tooltip ? function() { - return self.options.selected.indexOf(data[self.unique]) > -1 - ? (Ox.isString(v.tooltip) ? v.tooltip : v.tooltip(data)) : ''; - } : null - }) - .addClass( - 'OxCell OxColumn' + Ox.toTitleCase(v.id) + - (clickable ? ' OxClickable' : '') + - (editable ? ' OxEditable' : '') - ) - .css({ - width: (self.columnWidths[i] - (self.options.columnsVisible ? 9 : 8)) + 'px', - borderRightWidth: (self.options.columnsVisible ? 1 : 0) + 'px', - textAlign: v.align - }) - .html(v.id in data ? formatValue(v.id, data[v.id], data) : '') - .appendTo($item); + tooltip: function() { + return self.options.selected.indexOf(data[self.unique]) > -1 + ? (Ox.isString(v.tooltip) ? v.tooltip : v.tooltip(data)) : ''; + } + }); + } else { + $cell = $('