fix bugs with sorting clip lists of map and calendar views

This commit is contained in:
rolux 2011-10-13 12:04:27 +00:00
parent 199211c6aa
commit db42f6b2e3
8 changed files with 32 additions and 136 deletions

View file

@ -352,11 +352,11 @@ Ox.FilesView = function(options, self) {
});
function openFiles(data) {
Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances')))
//Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances')))
}
function selectFiles(data) {
Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances')))
//Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances')))
self.selected = data.ids;
self.$instancesList.options({
items: data.ids.length == 1

View file

@ -80,7 +80,8 @@ pandora.ui.browser = function() {
orientation: 'horizontal',
selected: [pandora.user.ui.item],
size: 64,
sort: pandora.user.ui.listSort,
sort: ['text', 'position'].indexOf(pandora.user.ui.listSort) > -1
? pandora.site.user.ui.listSort : pandora.user.ui.listSort,
unique: 'id'
})
.bindEvent({

View file

@ -177,6 +177,12 @@ pandora.ui.clipList = function(videoRatio) {
$('.OxSelectedVideo').removeClass('OxSelectedVideo');
!ui.item && pandora.UI.set('listSelection', []);
}
},
pandora_itemsort: function(data) {
that.options({sort: data.value});
},
pandora_listsort: function(data) {
that.options({sort: data.value});
}
});

View file

@ -39,108 +39,6 @@ pandora.ui.item = function() {
)
);
} else if (pandora.user.ui.itemView == 'calendar') {
var video = result.data.stream;
pandora.api.findEvents({
itemQuery: {conditions: [{key: 'id', value: pandora.user.ui.item, operator:'='}]},
keys: ['id', 'name', 'start', 'end'],
query: {}
}, function(r) {
if (r.data.items.length>0) {
pandora.$ui.contentPanel.replaceElement(1, Ox.SplitPanel({
elements: [
{
element: pandora.$ui.calendar = Ox.Calendar({
date: new Date(0),
events: r.data.items,
height: window.innerHeight - pandora.user.ui.showGroups * pandora.user.ui.groupsSize - 61,
range: [-5000, 5000],
width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE,
zoom: 4
}).bindEvent({
select: function(event) {
pandora.$ui.clips.options({
items: function(data, callback) {
pandora.api.findClips(Ox.extend(data, {
query: {
conditions:[{
key: 'event',
value: event.id,
operator:'=='
}]
},
itemQuery: {conditions: [{
key: 'id',
value: pandora.user.ui.item,
operator: '=='
}]}
}), callback);
}
});
}
})
},
{
element: Ox.Element(),
element: pandora.$ui.clips = Ox.IconList({
fixedRatio: video.aspectRatio,
item: function(data, sort, size) {
size = size || 128;
var width = size,
height = Math.round(size / video.aspectRatio),
itemId = data.id.split('/')[0],
url = '/' + itemId + '/' + height + 'p' + data['in'] + '.jpg';
return {
height: height,
id: data['id'],
info: Ox.formatDuration(data['in']) + ' - '
+ Ox.formatDuration(data['out']),
title: data.value,
url: url,
width: width
};
},
items: [],
keys: ['id', 'value', 'in', 'out'],
size: 128,
sort: pandora.user.ui.itemSort,
unique: 'id'
}).bindEvent({
open: function(data) {
var id = data.ids[0],
item = pandora.user.ui.item,
points = {
'in': pandora.$ui.clips.value(id, 'in'),
out: pandora.$ui.clips.value(id, 'out')
};
pandora.UI.set('videoPoints.' + item, Ox.extend(points, {
position: points['in']
}));
pandora.UI.set('itemView', 'timeline');
}
}),
id: 'place',
size: 144 + Ox.UI.SCROLLBAR_SIZE
}
],
orientation: 'horizontal'
})
.bindEvent('resize', function(data) {
}));
} else {
pandora.$ui.contentPanel.replaceElement(1,
Ox.Element()
.css({marginTop: '32px', fontSize: '12px', textAlign: 'center'})
.html(
'Sorry, <i>' + result.data.title
+ '</i> currently doesn\'t have a '
+ pandora.user.ui.itemView + ' view.'
));
}
});
} else if (pandora.user.ui.itemView == 'info') {
//Ox.print('result.data', result.data)
if (pandora.user.level == 'admin' && false) {
@ -201,11 +99,6 @@ pandora.ui.item = function() {
} else if (pandora.user.ui.itemView == 'clips') {
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.clips = pandora.ui.clipList(result.data.videoRatio)
.bindEvent({
pandora_itemsort: function(data) {
pandora.$ui.clips.options({sort: data.value});
}
})
);
} else if (pandora.user.ui.itemView == 'video') {
@ -388,7 +281,7 @@ pandora.ui.item = function() {
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio));
} else if (pandora.user.ui.itemView == 'calendar') {
pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('Calendar'));
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('calendar', result.data.videoRatio));
} else if (pandora.user.ui.itemView == 'data') {
var stats = Ox.Container();

View file

@ -390,17 +390,14 @@ pandora.ui.list = function() {
}, function(result) {
pandora.$ui.selected.html(pandora.ui.status('selected', result.data));
});
}
});
}
that.bindEvent({
// fixme: this is nonsense for map and calendar
},
pandora_listsort: function(data) {
that.options({sort: data.value});
}
});
}
if (pandora.user.ui.listView == 'grid') {
that.bindEvent({
pandora_icons: function(data) {

View file

@ -186,7 +186,10 @@ pandora.ui.navigationView = function(type, videoRatio) {
} else {
pandora.api.findEvents({
itemQuery: ui.find,
itemQuery: !ui.item ? ui.find : {
conditions: [{key: 'id', value: ui.item, operator: '=='}],
operator: '&'
},
keys: ['id', 'name', 'start', 'end'],
query: {},
range: [0, 1000000]
@ -277,20 +280,14 @@ pandora.ui.navigationView = function(type, videoRatio) {
$itemButton.options({disabled: !item});
}
that.bindEvent({
pandora_itemsort: function(data) {
ui.item && $list.options({sort: data.value});
},
pandora_listsort: function(data) {
!ui.item && $list.options({sort: data.value});
}
});
if (type == 'map') {
pandora.user.ui.mapFind = '';
pandora.user.ui.mapSelection = '';
}
// needed to it can recieve events from UI module
pandora.$ui.clipList = $list;
return that;
};

View file

@ -1,7 +1,8 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.orderButton = function() {
var that = Ox.Button({
var sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
that = Ox.Button({
id: 'orderButton',
title: getTitle(),
// tooltip: 'Change sort order',
@ -13,20 +14,21 @@ pandora.ui.orderButton = function() {
})
.bindEvent({
click: function(data) {
pandora.UI.set({
listSort: [{
key: pandora.user.ui.listSort[0].key,
operator: pandora.user.ui.listSort[0].operator == '+' ? '-' : '+'
}]
});
pandora.UI.set(sortKey, [{
key: pandora.user.ui[sortKey][0].key,
operator: pandora.user.ui[sortKey][0].operator == '+' ? '-' : '+'
}]);
that.options({title: getTitle()});
},
pandora_listsort: function() {
that.options({title: getTitle()});
},
pandora_itemsort: function() {
that.options({title: getTitle()});
}
});
function getTitle() {
return pandora.user.ui.listSort[0].operator == '+' ? 'up' : 'down';
return pandora.user.ui[sortKey][0].operator == '+' ? 'up' : 'down';
}
return that;
}

View file

@ -18,7 +18,7 @@ pandora.ui.toolbar = function() {
pandora.$ui.sortSelect = pandora.ui.sortSelect()
);
}
if (!ui.item) {
if (!ui.item || pandora.isClipView()) {
that.append(
pandora.$ui.orderButton = pandora.ui.orderButton()
);