2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
|
2011-08-17 09:29:42 +00:00
|
|
|
pandora.ui.list = function() { // fixme: remove view argument
|
2011-08-08 07:48:13 +00:00
|
|
|
var that, $map,
|
2011-08-17 09:29:42 +00:00
|
|
|
view = pandora.user.ui.lists[pandora.user.ui.list].listView,
|
|
|
|
preview = false
|
2011-05-25 19:42:45 +00:00
|
|
|
//Ox.print('constructList', view);
|
|
|
|
if (view == 'list') {
|
|
|
|
/*
|
|
|
|
keys = Ox.unique($.merge(
|
2011-06-06 15:48:11 +00:00
|
|
|
$.map(pandora.user.ui.lists[pandora.user.ui.list].columns, function(id) {
|
|
|
|
return Ox.getObjectById(pandora.site.sortKeys, id);
|
2011-05-25 19:42:45 +00:00
|
|
|
}),
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.site.sortKeys
|
2011-05-25 19:42:45 +00:00
|
|
|
));
|
|
|
|
Ox.print('$$$$', keys)
|
|
|
|
*/
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.TextList({
|
2011-09-04 04:15:12 +00:00
|
|
|
columns: /*Ox.merge([{
|
2011-09-04 01:52:41 +00:00
|
|
|
align: 'center',
|
|
|
|
defaultWidth: 16,
|
|
|
|
format: function(value, data) {
|
|
|
|
var icon, width, height, margin, marginCSS, borderRadius;
|
|
|
|
if (pandora.user.ui.icons == 'posters') {
|
|
|
|
icon = 'poster';
|
|
|
|
width = value < 1 ? Math.round(14 * value / 2) * 2 : 14;
|
|
|
|
height = value < 1 ? 14 : Math.round(14 / value / 2) * 2;
|
|
|
|
margin = value < 1 ? Math.floor(7 - width / 2) - 3 : Math.floor(7 - height / 2);
|
|
|
|
marginCSS = value < 1 ? '0 0 0 ' + margin + 'px' : margin + 'px 0 0 -3px';
|
|
|
|
borderRadius = 0;
|
|
|
|
} else {
|
|
|
|
icon = 'icon';
|
|
|
|
width = 14;
|
|
|
|
height = 14;
|
|
|
|
marginCSS = '0 0 0 -3px';
|
|
|
|
borderRadius = '3px';
|
|
|
|
}
|
|
|
|
return $('<img>').css({
|
|
|
|
width: width - 2 + 'px',
|
|
|
|
height: height - 2 + 'px',
|
|
|
|
border: '1px solid rgb(48, 48, 48)',
|
|
|
|
borderRadius: '2px',
|
|
|
|
margin: marginCSS,
|
|
|
|
background: '-webkit-linear-gradient(top, rgb(32, 32, 32), rgb(0, 0, 0))'
|
|
|
|
}).load(function() {
|
|
|
|
$(this).css({
|
|
|
|
width: width + 'px',
|
|
|
|
height: height + 'px',
|
|
|
|
border: 0,
|
|
|
|
borderRadius: borderRadius
|
|
|
|
//background: 'transparent'
|
|
|
|
})
|
|
|
|
}).attr({
|
|
|
|
src: '/' + data.id + '/' + icon + '14.jpg'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'posterRatio',
|
|
|
|
operator: '+',
|
|
|
|
position: 0,
|
|
|
|
removable: true,
|
2011-09-04 04:15:12 +00:00
|
|
|
title: 'Poster',
|
|
|
|
*//*
|
2011-09-04 01:52:41 +00:00
|
|
|
title: $('<img>').attr({
|
|
|
|
src: Ox.UI.getImageURL(
|
|
|
|
pandora.user.ui.icons == 'posters'
|
|
|
|
? 'symbolSetPoster' : 'symbolIcon'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '12px',
|
|
|
|
height: '12px',
|
|
|
|
padding: '2px',
|
|
|
|
}),
|
2011-09-04 04:15:12 +00:00
|
|
|
*//*
|
2011-09-04 01:52:41 +00:00
|
|
|
visible: true,
|
|
|
|
width: 16
|
2011-09-04 04:15:12 +00:00
|
|
|
}], */Ox.map(pandora.site.sortKeys, function(key) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var position = pandora.user.ui.lists[pandora.user.ui.list].columns.indexOf(key.id);
|
2011-05-25 19:42:45 +00:00
|
|
|
return {
|
|
|
|
align: ['string', 'text'].indexOf(
|
|
|
|
Ox.isArray(key.type) ? key.type[0]: key.type
|
|
|
|
) > -1 ? 'left' : 'right',
|
|
|
|
defaultWidth: key.columnWidth,
|
|
|
|
format: key.format,
|
|
|
|
id: key.id,
|
|
|
|
operator: pandora.getSortOperator(key.id),
|
|
|
|
position: position,
|
|
|
|
removable: !key.columnRequired,
|
|
|
|
title: key.title,
|
|
|
|
type: key.type,
|
|
|
|
unique: key.id == 'id',
|
|
|
|
visible: position > -1,
|
2011-06-06 15:48:11 +00:00
|
|
|
width: pandora.user.ui.lists[pandora.user.ui.list].columnWidth[key.id] || key.columnWidth
|
2011-05-25 19:42:45 +00:00
|
|
|
};
|
2011-09-04 04:15:12 +00:00
|
|
|
})/*)*/,
|
2011-05-25 19:42:45 +00:00
|
|
|
columnsMovable: true,
|
|
|
|
columnsRemovable: true,
|
|
|
|
columnsResizable: true,
|
|
|
|
columnsVisible: true,
|
2011-09-01 09:17:49 +00:00
|
|
|
draggable: true,
|
2011-05-25 19:42:45 +00:00
|
|
|
id: 'list',
|
|
|
|
items: function(data, callback) {
|
|
|
|
//Ox.print('data, pandora.Query.toObject', data, pandora.Query.toObject())
|
2011-08-24 06:32:59 +00:00
|
|
|
pandora.api.find(Ox.extend(data, {
|
|
|
|
query: pandora.user.ui.query
|
2011-05-25 19:42:45 +00:00
|
|
|
}), callback);
|
|
|
|
},
|
|
|
|
scrollbarVisible: true,
|
2011-08-17 13:23:17 +00:00
|
|
|
selected: pandora.user.ui.lists[pandora.user.ui.list].selected,
|
2011-06-06 15:48:11 +00:00
|
|
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-08-18 07:54:46 +00:00
|
|
|
columnchange: function(data) {
|
2011-06-27 13:39:35 +00:00
|
|
|
var columnWidth = {};
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.UI.set(['lists', pandora.user.ui.list, 'columns'].join('|'), data.ids);
|
2011-05-25 19:42:45 +00:00
|
|
|
/*
|
|
|
|
data.ids.forEach(function(id) {
|
|
|
|
columnWidth[id] =
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.lists[pandora.user.ui.list].columnWidth[id] ||
|
|
|
|
Ox.getObjectById(pandora.site.sortKeys, id).width
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.UI.set(['lists', pandora.user.ui.list, 'columnWidth'].join('|'), columnWidth);
|
2011-05-25 19:42:45 +00:00
|
|
|
*/
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
columnresize: function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.UI.set(['lists', pandora.user.ui.list, 'columnWidth', data.id].join('|'), data.width);
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
resize: function(data) { // this is the resize event of the split panel
|
2011-05-25 19:42:45 +00:00
|
|
|
that.size();
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
sort: function(data) {
|
|
|
|
Ox.print('---- SORT ----', data)
|
|
|
|
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + data.key);
|
|
|
|
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (data.operator == '+' ? 'ascending' : 'descending'));
|
|
|
|
pandora.$ui.sortSelect.selectItem(data.key);
|
|
|
|
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [{key: data.key, operator: data.operator}]);
|
|
|
|
pandora.URL.push(pandora.Query.toString());
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (view == 'icons') {
|
2011-08-17 09:29:42 +00:00
|
|
|
//alert(JSON.stringify(pandora.user.ui.lists[pandora.user.ui.list].selected))
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.IconList({
|
2011-08-17 15:52:58 +00:00
|
|
|
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16,
|
2011-08-07 20:25:33 +00:00
|
|
|
defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1,
|
2011-09-01 09:17:49 +00:00
|
|
|
draggable: true,
|
2011-05-25 19:42:45 +00:00
|
|
|
id: 'list',
|
|
|
|
item: function(data, sort, size) {
|
2011-08-06 18:00:15 +00:00
|
|
|
var icons = pandora.user.ui.icons,
|
2011-08-19 12:33:02 +00:00
|
|
|
ratio = icons == 'posters' ? data.posterRatio : 1;
|
2011-05-25 19:42:45 +00:00
|
|
|
size = size || 128;
|
|
|
|
return {
|
2011-08-24 06:19:34 +00:00
|
|
|
height: Math.round(ratio <= 1 ? size : size / ratio),
|
2011-08-06 18:00:15 +00:00
|
|
|
id: data.id,
|
2011-05-25 19:42:45 +00:00
|
|
|
info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key],
|
|
|
|
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
|
2011-08-06 18:00:15 +00:00
|
|
|
url: icons == 'posters'
|
|
|
|
? '/' + data.id + '/poster' + size + '.jpg'
|
|
|
|
: '/' + data.id + '/icon' + size + '.jpg',
|
2011-08-24 06:19:34 +00:00
|
|
|
width: Math.round(ratio >= 1 ? size : size * ratio)
|
2011-05-25 19:42:45 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
items: function(data, callback) {
|
|
|
|
//Ox.print('data, pandora.Query.toObject', data, pandora.Query.toObject())
|
2011-08-24 06:32:59 +00:00
|
|
|
pandora.api.find(Ox.extend(data, {
|
2011-08-24 06:19:34 +00:00
|
|
|
query: pandora.user.ui.query
|
2011-05-25 19:42:45 +00:00
|
|
|
}), callback);
|
|
|
|
},
|
2011-08-19 12:33:02 +00:00
|
|
|
keys: ['director', 'id', 'posterRatio', 'title', 'year'],
|
2011-08-17 09:29:42 +00:00
|
|
|
selected: pandora.user.ui.lists[pandora.user.ui.list].selected,
|
2011-05-25 19:42:45 +00:00
|
|
|
size: 128,
|
2011-06-06 15:48:11 +00:00
|
|
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
2011-05-25 19:42:45 +00:00
|
|
|
unique: 'id'
|
2011-06-16 20:00:10 +00:00
|
|
|
});
|
2011-06-27 13:39:35 +00:00
|
|
|
} else if (view == 'info') {
|
2011-08-19 02:13:16 +00:00
|
|
|
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
|
|
|
|
} else if (view == 'clips') {
|
|
|
|
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
|
|
|
|
} else if (view == 'timelines') {
|
|
|
|
that = Ox.InfoList({
|
2011-08-18 11:32:47 +00:00
|
|
|
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16,
|
|
|
|
defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1,
|
|
|
|
id: 'list',
|
|
|
|
item: function(data, sort, size) {
|
|
|
|
var icons = pandora.user.ui.icons,
|
2011-08-19 12:33:02 +00:00
|
|
|
ratio = icons == 'posters' ? data.posterRatio : 1;
|
2011-08-19 06:40:19 +00:00
|
|
|
size = 128;
|
2011-08-18 11:32:47 +00:00
|
|
|
return {
|
2011-08-19 06:40:19 +00:00
|
|
|
icon: {
|
|
|
|
height: ratio <= 1 ? size : size / ratio,
|
|
|
|
id: data.id,
|
|
|
|
info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key],
|
|
|
|
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
|
|
|
|
url: icons == 'posters'
|
|
|
|
? '/' + data.id + '/poster' + size + '.jpg'
|
|
|
|
: '/' + data.id + '/icon' + size + '.jpg',
|
|
|
|
width: ratio >= 1 ? size : size * ratio
|
|
|
|
},
|
|
|
|
info: {
|
|
|
|
css: {
|
|
|
|
margin: '-4px 0 0 -4px'
|
|
|
|
},
|
|
|
|
element: Ox.BlockVideoTimeline,
|
|
|
|
id: data.id,
|
|
|
|
options: {
|
|
|
|
duration: data.duration,
|
|
|
|
getImageURL: '/' + data.id + '/timeline16p.png'
|
|
|
|
}
|
|
|
|
}
|
2011-08-18 11:32:47 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
items: function(data, callback) {
|
2011-08-24 06:32:59 +00:00
|
|
|
pandora.api.find(Ox.extend(data, {
|
|
|
|
query: pandora.user.ui.query
|
2011-08-18 11:32:47 +00:00
|
|
|
}), callback);
|
|
|
|
},
|
2011-08-19 12:33:02 +00:00
|
|
|
keys: ['director', 'duration', 'id', 'posterRatio', 'title', 'year'],
|
2011-08-18 11:32:47 +00:00
|
|
|
selected: pandora.user.ui.lists[pandora.user.ui.list].selected,
|
2011-08-19 02:13:16 +00:00
|
|
|
size: 192,
|
2011-08-18 11:32:47 +00:00
|
|
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
|
|
|
unique: 'id'
|
2011-08-19 02:13:16 +00:00
|
|
|
});
|
2011-06-27 13:39:35 +00:00
|
|
|
} else if (view == 'maps') {
|
|
|
|
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
|
|
|
|
} else if (view == 'calendars') {
|
|
|
|
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
|
2011-06-16 20:00:10 +00:00
|
|
|
} else if (view == 'clip') {
|
2011-08-07 02:43:33 +00:00
|
|
|
var fixedRatio = 16/9;
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.IconList({
|
2011-08-07 02:43:33 +00:00
|
|
|
fixedRatio: fixedRatio,
|
2011-06-16 20:00:10 +00:00
|
|
|
item: function(data, sort, size) {
|
|
|
|
size = size || 128;
|
2011-08-19 14:43:05 +00:00
|
|
|
var ratio = data.videoRatio,
|
2011-08-07 02:43:33 +00:00
|
|
|
width = ratio > fixedRatio ? size : Math.round(size * ratio / fixedRatio),
|
|
|
|
height = Math.round(width / ratio),
|
2011-08-19 16:04:33 +00:00
|
|
|
url = '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg';
|
2011-06-16 20:00:10 +00:00
|
|
|
return {
|
|
|
|
height: height,
|
2011-08-19 16:04:33 +00:00
|
|
|
id: data.id,
|
2011-08-06 18:00:15 +00:00
|
|
|
info: Ox.formatDuration(data['in'], 'short') + ' - ' + Ox.formatDuration(data['out'], 'short'),
|
2011-06-16 20:00:10 +00:00
|
|
|
title: data.value,
|
|
|
|
url: url,
|
|
|
|
width: width
|
|
|
|
};
|
|
|
|
},
|
|
|
|
items: function(data, callback) {
|
2011-08-24 06:32:59 +00:00
|
|
|
var itemQuery = pandora.user.ui.query,
|
2011-06-17 07:44:45 +00:00
|
|
|
query = {conditions:[]};
|
|
|
|
//fixme: can this be in pandora.Query? dont just check for subtitles
|
|
|
|
itemQuery.conditions.forEach(function(q) {
|
2011-08-06 18:00:15 +00:00
|
|
|
if (q.key == 'subtitles') {
|
2011-06-17 07:44:45 +00:00
|
|
|
query.conditions.push({key: 'value', value: q.value, operator: q.operator});
|
|
|
|
}
|
|
|
|
});
|
2011-08-20 09:47:56 +00:00
|
|
|
pandora.api.findAnnotations(Ox.extend({
|
2011-06-17 07:44:45 +00:00
|
|
|
query: query,
|
|
|
|
itemQuery: itemQuery
|
2011-08-20 09:47:56 +00:00
|
|
|
}, data), callback);
|
2011-06-16 20:00:10 +00:00
|
|
|
},
|
2011-08-19 16:04:33 +00:00
|
|
|
keys: ['id', 'value', 'in', 'out', 'videoRatio'],
|
2011-08-18 14:02:29 +00:00
|
|
|
max: 1,
|
2011-06-16 20:00:10 +00:00
|
|
|
size: 128,
|
|
|
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
|
|
|
unique: 'id'
|
2011-06-20 16:56:18 +00:00
|
|
|
}).bindEvent({
|
2011-08-19 06:40:19 +00:00
|
|
|
init: function(data) {
|
|
|
|
pandora.$ui.total.html(pandora.ui.status('total', data));
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
open: function(data) {
|
2011-06-20 16:56:18 +00:00
|
|
|
var id = data.ids[0],
|
2011-08-19 16:04:33 +00:00
|
|
|
item = id.split('/')[0],
|
2011-06-20 16:56:18 +00:00
|
|
|
position = that.value(id, 'in');
|
|
|
|
pandora.UI.set('videoPosition|' + item, position);
|
|
|
|
pandora.URL.set(item + '/timeline');
|
2011-08-18 07:54:46 +00:00
|
|
|
},
|
2011-08-18 14:02:29 +00:00
|
|
|
openpreview: function(data) {
|
|
|
|
var $video = $('.OxItem.OxSelected > .OxIcon > .OxVideoPlayer');
|
2011-08-19 17:34:36 +00:00
|
|
|
if ($video) {
|
|
|
|
// trigger singleclick
|
|
|
|
$video.trigger('mousedown');
|
|
|
|
Ox.UI.$window.trigger('mouseup');
|
|
|
|
}
|
2011-08-19 16:04:33 +00:00
|
|
|
$video && Ox.print('OPENPREVIEW!!!@!')
|
2011-08-18 14:02:29 +00:00
|
|
|
that.closePreview();
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
select: function(data) {
|
2011-08-18 14:02:29 +00:00
|
|
|
if (data.ids.length) {
|
|
|
|
var id = data.ids[0],
|
|
|
|
item = id.split('/')[0], width, height,
|
|
|
|
$img = $('.OxItem.OxSelected > .OxIcon > img'),
|
|
|
|
$video = $('.OxItem.OxSelected > .OxIcon > .OxVideoPlayer');
|
|
|
|
pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), item);
|
|
|
|
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info(data.ids[0].split('/')[0]));
|
|
|
|
if ($img.length) {
|
2011-08-19 16:04:33 +00:00
|
|
|
var width = parseInt($img.css('width')),
|
|
|
|
height = parseInt($img.css('height'));
|
2011-08-19 18:08:51 +00:00
|
|
|
pandora.api.get({id: item, keys: ['durations']}, function(result) {
|
|
|
|
var points = [that.value(id, 'in'), that.value(id, 'out')],
|
|
|
|
partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points),
|
2011-08-19 16:04:33 +00:00
|
|
|
$player = Ox.VideoPlayer({
|
2011-08-18 14:02:29 +00:00
|
|
|
height: height,
|
2011-08-19 18:08:51 +00:00
|
|
|
'in': partsAndPoints.points[0],
|
|
|
|
out: partsAndPoints.points[1],
|
2011-08-18 14:02:29 +00:00
|
|
|
paused: true,
|
|
|
|
playInToOut: true,
|
2011-08-19 18:08:51 +00:00
|
|
|
poster: '/' + item + '/' + height + 'p' + points[0] + '.jpg',
|
2011-08-18 14:02:29 +00:00
|
|
|
width: width,
|
2011-08-19 18:08:51 +00:00
|
|
|
video: partsAndPoints.parts.map(function(i) {
|
2011-08-20 09:47:56 +00:00
|
|
|
return '/' + item + '/96p' + (i + 1) + '.' + pandora.user.videoFormat;
|
2011-08-19 16:04:33 +00:00
|
|
|
})
|
2011-08-18 14:02:29 +00:00
|
|
|
})
|
|
|
|
.addClass('OxTarget')
|
2011-08-19 02:13:16 +00:00
|
|
|
.bindEvent({
|
|
|
|
// doubleclick opens item
|
|
|
|
singleclick: function() {
|
2011-08-18 14:02:29 +00:00
|
|
|
$player.$element.is('.OxSelectedVideo') && $player.togglePaused();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$img.replaceWith($player.$element);
|
|
|
|
$('.OxSelectedVideo').removeClass('OxSelectedVideo');
|
|
|
|
$player.$element.addClass('OxSelectedVideo');
|
|
|
|
});
|
|
|
|
} else if ($video.length) {
|
|
|
|
// item select fires before video click
|
|
|
|
// so we have to make sure that selecting
|
|
|
|
// doesn't click through to play
|
|
|
|
setTimeout(function() {
|
|
|
|
$('.OxSelectedVideo').removeClass('OxSelectedVideo');
|
|
|
|
$video.addClass('OxSelectedVideo');
|
2011-08-19 02:13:16 +00:00
|
|
|
}, 300);
|
2011-08-18 14:02:29 +00:00
|
|
|
}
|
2011-08-19 20:38:19 +00:00
|
|
|
} else {
|
|
|
|
$('.OxSelectedVideo').removeClass('OxSelectedVideo');
|
2011-08-18 14:02:29 +00:00
|
|
|
}
|
2011-06-20 16:56:18 +00:00
|
|
|
}
|
2011-06-16 20:00:10 +00:00
|
|
|
});
|
2011-08-20 09:47:56 +00:00
|
|
|
} else if (view == 'player') {
|
|
|
|
that = Ox.VideoPlayer({
|
|
|
|
controlsBottom: ['play', 'previous', 'next', 'volume'],
|
|
|
|
controlsTop: ['fullscreen', 'scale'],
|
|
|
|
enableMouse: true,
|
|
|
|
height: 384,
|
|
|
|
paused: true,
|
|
|
|
position: 0,
|
|
|
|
video: function(range, callback) {
|
|
|
|
var callback = arguments[arguments.length - 1],
|
|
|
|
range = arguments.length == 2 ? arguments[0] : null,
|
2011-08-24 06:32:59 +00:00
|
|
|
itemQuery = pandora.user.ui.query,
|
2011-08-20 09:47:56 +00:00
|
|
|
query = {conditions:[]};
|
|
|
|
//fixme: can this be in pandora.Query? dont just check for subtitles
|
|
|
|
itemQuery.conditions.forEach(function(q) {
|
|
|
|
if (q.key == 'subtitles') {
|
|
|
|
query.conditions.push({key: 'value', value: q.value, operator: q.operator});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
pandora.api.findAnnotations(Ox.extend({
|
|
|
|
query: query,
|
|
|
|
itemQuery: itemQuery
|
|
|
|
}, range ? {
|
|
|
|
keys: ['id', 'in', 'out'],
|
|
|
|
range: range,
|
|
|
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort
|
|
|
|
} : {}), function(result) {
|
|
|
|
//Ox.print('API findAnnotations range', range, 'result', result.data);
|
|
|
|
if (!range) {
|
|
|
|
callback(result.data.items);
|
|
|
|
} else {
|
|
|
|
var counter = 0,
|
|
|
|
length = range[1] - range[0],
|
|
|
|
data = [];
|
|
|
|
result.data.items.forEach(function(item, i) {
|
|
|
|
var id = item.id.split('/')[0]
|
|
|
|
pandora.api.get({id: id, keys: ['durations']}, function(result) {
|
|
|
|
//Ox.print('API get item', id, 'result', result.data);
|
|
|
|
var points = [item['in'], item.out],
|
|
|
|
partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points);
|
|
|
|
data[i] = {
|
|
|
|
parts: partsAndPoints.parts.map(function(i) {
|
|
|
|
return '/' + id + '/96p' + (i + 1) + '.' + pandora.user.videoFormat;
|
|
|
|
}),
|
|
|
|
points: partsAndPoints.points
|
|
|
|
}
|
|
|
|
if (++counter == length) {
|
|
|
|
callback(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
width: 512
|
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
} else if (view == 'map') {
|
2011-08-07 23:43:21 +00:00
|
|
|
var fixedRatio = 16/9;
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.SplitPanel({
|
2011-05-25 19:42:45 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-06-06 15:48:11 +00:00
|
|
|
element: pandora.$ui.map = Ox.Map({
|
|
|
|
height: window.innerHeight - pandora.user.ui.showGroups * pandora.user.ui.groupsSize - 61,
|
2011-06-02 17:31:51 +00:00
|
|
|
places: function(data, callback) {
|
2011-08-24 06:32:59 +00:00
|
|
|
var itemQuery = pandora.user.ui.query,
|
2011-06-18 18:48:49 +00:00
|
|
|
query = {conditions:[]};
|
2011-08-24 06:32:59 +00:00
|
|
|
return pandora.api.findPlaces(Ox.extend(data, {
|
2011-06-18 18:48:49 +00:00
|
|
|
itemQuery: itemQuery,
|
|
|
|
query: query
|
|
|
|
}), callback);
|
2011-06-02 17:31:51 +00:00
|
|
|
},
|
|
|
|
showTypes: true,
|
|
|
|
toolbar: true,
|
2011-06-06 15:48:11 +00:00
|
|
|
width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE,
|
2011-06-20 15:02:53 +00:00
|
|
|
}).bindEvent({
|
|
|
|
selectplace: function(event, place) {
|
2011-06-20 16:14:38 +00:00
|
|
|
if(place && place.id[0] != '_') {
|
2011-06-20 15:02:53 +00:00
|
|
|
pandora.$ui.clips.options({
|
|
|
|
items: function(data, callback) {
|
2011-08-24 06:32:59 +00:00
|
|
|
return pandora.api.findAnnotations(Ox.extend(data, {
|
2011-06-20 15:02:53 +00:00
|
|
|
query: {
|
2011-06-20 16:14:38 +00:00
|
|
|
conditions:[{key: 'place', value: place.id, operator:'='}]
|
2011-06-20 15:02:53 +00:00
|
|
|
},
|
2011-08-24 06:32:59 +00:00
|
|
|
itemQuery: pandora.user.ui.query
|
2011-06-20 15:02:53 +00:00
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
pandora.$ui.clips.options({
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2011-06-02 17:31:51 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
{
|
2011-06-20 15:02:53 +00:00
|
|
|
element: pandora.$ui.clips = Ox.IconList({
|
2011-08-07 23:43:21 +00:00
|
|
|
fixedRatio: fixedRatio,
|
2011-06-20 15:02:53 +00:00
|
|
|
item: function(data, sort, size) {
|
2011-08-19 14:43:05 +00:00
|
|
|
Ox.print('RATIO', data.videoRatio);
|
2011-06-20 15:02:53 +00:00
|
|
|
size = size || 128;
|
2011-08-19 14:43:05 +00:00
|
|
|
var width = data.videoRatio < fixedRatio ? size : size * data.videoRatio / fixedRatio,
|
|
|
|
height = width / data.videoRatio,
|
2011-08-18 11:32:47 +00:00
|
|
|
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
|
2011-06-20 15:02:53 +00:00
|
|
|
return {
|
|
|
|
height: height,
|
2011-08-06 04:28:19 +00:00
|
|
|
id: data.id,
|
|
|
|
info: Ox.formatDuration(data['in'], 'short') + ' - '
|
|
|
|
+ Ox.formatDuration(data['out'], 'short'),
|
2011-06-20 15:02:53 +00:00
|
|
|
title: data.value,
|
|
|
|
url: url,
|
|
|
|
width: width
|
|
|
|
};
|
|
|
|
},
|
|
|
|
items: [],
|
2011-08-19 14:43:05 +00:00
|
|
|
keys: ['id', 'value', 'in', 'out', 'videoRatio', 'item'],
|
2011-06-20 15:02:53 +00:00
|
|
|
size: 128,
|
|
|
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
|
|
|
unique: 'id'
|
2011-06-20 16:56:18 +00:00
|
|
|
}).bindEvent({
|
2011-08-18 07:54:46 +00:00
|
|
|
open: function(data) {
|
2011-06-20 16:56:18 +00:00
|
|
|
var id = data.ids[0],
|
|
|
|
item = pandora.$ui.clips.value(id, 'item'),
|
|
|
|
position = pandora.$ui.clips.value(id, 'in');
|
|
|
|
pandora.UI.set('videoPosition|' + item, position);
|
|
|
|
pandora.URL.set(item + '/timeline');
|
|
|
|
}
|
2011-06-20 15:02:53 +00:00
|
|
|
}),
|
2011-06-02 17:31:51 +00:00
|
|
|
id: 'place',
|
|
|
|
size: 144 + Ox.UI.SCROLLBAR_SIZE
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
})
|
|
|
|
.bindEvent('resize', function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.map.resizeMap();
|
2011-06-02 17:31:51 +00:00
|
|
|
});
|
|
|
|
} else if (view == 'calendar') {
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.SplitPanel({
|
2011-06-02 17:31:51 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-06-06 15:48:11 +00:00
|
|
|
element: pandora.$ui.calendar = Ox.Calendar({
|
2011-06-02 17:31:51 +00:00
|
|
|
date: new Date(0),
|
|
|
|
events: [
|
|
|
|
{name: 'Thirty Years\' War', start: '1618', end: '1648', type: 'other'},
|
|
|
|
{name: 'American Civil War', start: '1861-04-12', end: '1865-04-09', type: 'other'},
|
|
|
|
{name: 'Franco-Prussian War', start: '1870-07-19', end: '1871-05-10', type: 'other'},
|
|
|
|
{name: 'World War One', start: '1914-07-28', end: '1918-11-11', type: 'other'},
|
|
|
|
{name: 'World War Two', start: '1939-09-01', end: '1945-09-02', type: 'other'},
|
2011-06-02 17:39:54 +00:00
|
|
|
{name: 'Cold War', start: '1947', end: '1991', type: 'other'},
|
|
|
|
{name: 'Korean War', start: '1950-06-25', end: '1953-07-27', type: 'other'},
|
2011-06-02 17:31:51 +00:00
|
|
|
{name: 'Algerian War', start: '1954-11-01', end: '1962-03-19', type: 'other'},
|
|
|
|
{name: 'Vietnam War', start: '1955-11-01', end: '1975-04-30', type: 'other'},
|
|
|
|
{name: 'Six-Day War', start: '1967-06-05', end: '1967-06-11', type: 'other'},
|
|
|
|
{name: 'Iran-Iraq War', start: '1980-09-22', end: '1988-08-20', type: 'other'},
|
|
|
|
{name: 'Gulf War', start: '1990-08-02', end: '1991-02-28', type: 'other'}
|
2011-05-25 19:42:45 +00:00
|
|
|
],
|
2011-06-06 15:48:11 +00:00
|
|
|
height: window.innerHeight - pandora.user.ui.showGroups * pandora.user.ui.groupsSize - 61,
|
2011-06-02 17:31:51 +00:00
|
|
|
range: [-5000, 5000],
|
2011-06-06 15:48:11 +00:00
|
|
|
width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE,
|
2011-06-02 17:31:51 +00:00
|
|
|
zoom: 4
|
|
|
|
})
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
2011-06-19 17:49:25 +00:00
|
|
|
element: Ox.Element(),
|
2011-05-25 19:42:45 +00:00
|
|
|
id: 'place',
|
2011-06-02 17:31:51 +00:00
|
|
|
size: 144 + Ox.UI.SCROLLBAR_SIZE
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
})
|
|
|
|
.bindEvent('resize', function() {
|
2011-06-02 17:31:51 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
} else {
|
2011-09-03 23:04:48 +00:00
|
|
|
// fixme: ???
|
2011-06-19 17:49:25 +00:00
|
|
|
$list = Ox.Element('<div>')
|
2011-05-25 19:42:45 +00:00
|
|
|
.css({
|
|
|
|
width: '100px',
|
|
|
|
height: '100px',
|
|
|
|
background: 'red'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-09-03 23:04:48 +00:00
|
|
|
var drag = {};
|
|
|
|
|
2011-08-28 06:24:01 +00:00
|
|
|
var $tooltip = Ox.Tooltip({
|
|
|
|
animate: false
|
|
|
|
});
|
|
|
|
|
2011-09-03 23:04:48 +00:00
|
|
|
function getTitle(e) {
|
|
|
|
var image, text;
|
|
|
|
if (drag.action == 'move' && drag.source.user != pandora.user.username) {
|
|
|
|
image = 'symbolClose'
|
|
|
|
text = 'You can only remove ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>from your own lists.';
|
|
|
|
} else if (drag.action == 'move' && drag.source.type == 'smart') {
|
|
|
|
image = 'symbolClose';
|
|
|
|
text = 'You can\'t remove ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>from smart lists.';
|
|
|
|
} else if (drag.target && drag.target.user != pandora.user.username) {
|
|
|
|
image = 'symbolClose'
|
|
|
|
text = 'You can only ' + drag.action + ' ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>to your own lists';
|
|
|
|
} else if (drag.target && drag.target.type == 'smart') {
|
|
|
|
image = 'symbolClose'
|
|
|
|
text = 'You can\'t ' + drag.action + ' ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>to smart lists';
|
|
|
|
} else {
|
|
|
|
image = drag.action == 'copy' ? 'symbolAdd' : 'symbolRemove';
|
|
|
|
text = Ox.toTitleCase(drag.action) + ' ' + (
|
2011-09-03 23:35:24 +00:00
|
|
|
Ox.isString(drag.item)
|
|
|
|
? '"' + drag.item + '"'
|
|
|
|
: drag.item + ' ' + pandora.site.itemName[
|
|
|
|
drag.item == 1 ? 'singular' : 'plural'
|
|
|
|
].toLowerCase()
|
|
|
|
) + '</br> to ' + (
|
|
|
|
drag.target && !drag.target.selected
|
|
|
|
? 'the list "' + drag.target.name + '"'
|
|
|
|
: 'another list'
|
|
|
|
);
|
2011-06-16 20:00:10 +00:00
|
|
|
}
|
2011-09-03 23:04:48 +00:00
|
|
|
return $('<div>')
|
|
|
|
.append(
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '16px',
|
|
|
|
height: '16px',
|
|
|
|
padding: '2px',
|
|
|
|
border: '2px solid rgb(192, 192, 192)',
|
|
|
|
borderRadius: '12px',
|
|
|
|
margin: '3px 2px 2px 2px'
|
|
|
|
})
|
|
|
|
.append(
|
|
|
|
$('<img>')
|
|
|
|
.attr({src: Ox.UI.getImageURL(image)})
|
|
|
|
.css({width: '16px', height: '16px'})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.append(
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
margin: '1px 2px 2px 2px',
|
|
|
|
fontSize: '11px',
|
|
|
|
whiteSpace: 'nowrap'
|
|
|
|
})
|
|
|
|
.html(text)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function keydown(e) {
|
|
|
|
if (e.metaKey) {
|
|
|
|
drag.action = 'move';
|
|
|
|
$tooltip.options({title: getTitle()}).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function keyup(e) {
|
|
|
|
if (drag.action == 'move') {
|
|
|
|
drag.action = 'copy';
|
|
|
|
$tooltip.options({title: getTitle()}).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
['list', 'icons'].indexOf(view) > -1 && that.bindEvent({
|
2011-08-18 07:54:46 +00:00
|
|
|
closepreview: function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.previewDialog.close();
|
2011-08-08 07:48:13 +00:00
|
|
|
preview = false;
|
|
|
|
//delete pandora.$ui.previewDialog;
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
copy: function(data) {
|
2011-05-25 19:42:45 +00:00
|
|
|
Ox.Clipboard.copy({
|
|
|
|
items: data.ids,
|
|
|
|
text: $.map(data.ids, function(id) {
|
2011-06-06 15:48:11 +00:00
|
|
|
return pandora.$ui.list.value(id, 'title');
|
2011-05-25 19:42:45 +00:00
|
|
|
}).join('\n')
|
|
|
|
});
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
'delete': function(data) {
|
2011-06-04 16:19:06 +00:00
|
|
|
pandora.getListData().editable && pandora.api.removeListItems({
|
2011-06-06 15:48:11 +00:00
|
|
|
list: pandora.user.ui.list,
|
2011-05-25 19:42:45 +00:00
|
|
|
items: data.ids
|
2011-06-04 16:19:06 +00:00
|
|
|
}, pandora.reloadList);
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-09-03 23:04:48 +00:00
|
|
|
draganddropstart: function(data) {
|
|
|
|
Ox.print('DRAGSTART', pandora.getListData());
|
|
|
|
drag.action = 'copy';
|
|
|
|
drag.ids = that.options('selected'),
|
|
|
|
drag.item = drag.ids.length == 1
|
|
|
|
? that.value(drag.ids[0], 'title')
|
|
|
|
: drag.ids.length;
|
|
|
|
drag.source = pandora.getListData(),
|
|
|
|
drag.targets = {};
|
|
|
|
Ox.forEach(pandora.$ui.folderList, function($list) {
|
|
|
|
$list.addClass('OxDroppable').find('.OxItem').each(function() {
|
|
|
|
var $item = $(this),
|
|
|
|
id = $item.data('id'),
|
|
|
|
data = $list.value(id);
|
|
|
|
Ox.print('DATA', data)
|
|
|
|
drag.targets[id] = Ox.extend({
|
|
|
|
editable: data.user == pandora.user.username
|
|
|
|
&& data.type == 'static',
|
|
|
|
selected: $item.is('.OxSelected')
|
|
|
|
}, data);
|
|
|
|
if (!drag.targets[id].selected && drag.targets[id].editable) {
|
|
|
|
$item.addClass('OxDroppable');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$tooltip.options({
|
|
|
|
title: getTitle(data._event)
|
|
|
|
}).show(data._event);
|
|
|
|
Ox.UI.$window.bind({
|
|
|
|
keydown: keydown,
|
|
|
|
keyup: keyup
|
|
|
|
});
|
|
|
|
},
|
|
|
|
draganddrop: function(data) {
|
|
|
|
$tooltip.options({
|
|
|
|
title: getTitle(data._event)
|
|
|
|
}).show(data._event);
|
|
|
|
},
|
|
|
|
draganddropenter: function(data) {
|
|
|
|
var $parent = $(data._event.target).parent(),
|
|
|
|
$item = $parent.is('.OxItem') ? $parent : $parent.parent();
|
|
|
|
$list = $item.parent().parent().parent().parent();
|
|
|
|
if ($list.is('.OxDroppable')) {
|
|
|
|
$item.addClass('OxDrop');
|
|
|
|
drag.target = drag.targets[$item.data('id')];
|
|
|
|
} else {
|
|
|
|
drag.target = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
draganddropleave: function(data) {
|
|
|
|
var $parent = $(data._event.target).parent(),
|
|
|
|
$item = $parent.is('.OxItem') ? $parent : $parent.parent();
|
|
|
|
if ($item.is('.OxDroppable')) {
|
|
|
|
$item.removeClass('OxDrop');
|
|
|
|
drag.target = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
draganddropend: function(data) {
|
|
|
|
Ox.print(data, drag, '------------');
|
2011-09-03 23:35:24 +00:00
|
|
|
Ox.UI.$window.unbind({
|
|
|
|
keydown: keydown,
|
|
|
|
keyup: keyup
|
|
|
|
});
|
|
|
|
if (drag.target && drag.target.editable && !drag.target.selected) {
|
2011-09-03 23:04:48 +00:00
|
|
|
if (drag.action == 'copy' || (
|
|
|
|
drag.action == 'move' && drag.source.editable
|
|
|
|
)) {
|
|
|
|
if (drag.action == 'move') {
|
|
|
|
pandora.api.removeListItems({
|
|
|
|
list: pandora.user.ui.list,
|
|
|
|
items: data.ids
|
|
|
|
}, pandora.reloadList);
|
|
|
|
}
|
|
|
|
pandora.api.addListItems({
|
|
|
|
list: drag.target.id,
|
|
|
|
items: data.ids
|
|
|
|
}, function() {
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
|
|
|
pandora.api.find({
|
|
|
|
query: {
|
|
|
|
conditions: [{key: 'list', value: drag.target.id, operator: '='}],
|
|
|
|
operator: ''
|
|
|
|
}
|
|
|
|
}, function(result) {
|
2011-09-04 11:31:05 +00:00
|
|
|
var folder = drag.target.status != 'featured' ? 'personal' : 'featured';
|
|
|
|
//Ox.print(drag.source.status, '//////', drag.target.status)
|
2011-09-03 23:04:48 +00:00
|
|
|
pandora.$ui.folderList[folder].value(
|
|
|
|
drag.target.id, 'items',
|
|
|
|
result.data.items
|
|
|
|
);
|
|
|
|
cleanup(500);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cleanup(0);
|
|
|
|
}
|
|
|
|
function cleanup(ms) {
|
|
|
|
drag = {};
|
|
|
|
setTimeout(function() {
|
|
|
|
$('.OxDroppable').removeClass('OxDroppable');
|
|
|
|
$('.OxDrop').removeClass('OxDrop');
|
|
|
|
$tooltip.hide();
|
|
|
|
}, ms);
|
|
|
|
}
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
init: function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.total.html(pandora.ui.status('total', data));
|
2011-05-25 19:42:45 +00:00
|
|
|
data = [];
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.site.totals, function(i, v) {
|
2011-05-25 19:42:45 +00:00
|
|
|
data[v.id] = 0;
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.selected.html(pandora.ui.status('selected', data));
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
open: function(data) {
|
2011-05-25 19:42:45 +00:00
|
|
|
var id = data.ids[0],
|
|
|
|
title = that.value(id, 'title');
|
|
|
|
pandora.URL.set(title, id);
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
openpreview: function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.requests.preview && pandora.api.cancel(pandora.requests.preview);
|
|
|
|
pandora.requests.preview = pandora.api.find({
|
2011-08-19 12:33:02 +00:00
|
|
|
keys: ['director', 'id', 'posterRatio', 'title'],
|
2011-05-25 19:42:45 +00:00
|
|
|
query: {
|
|
|
|
conditions: $.map(data.ids, function(id, i) {
|
|
|
|
return {
|
|
|
|
key: 'id',
|
|
|
|
value: id,
|
|
|
|
operator: '='
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
operator: '|'
|
|
|
|
}
|
|
|
|
}, function(result) {
|
2011-08-08 07:48:13 +00:00
|
|
|
var item = result.data.items[0],
|
2011-08-19 14:43:05 +00:00
|
|
|
title = item.title + ' (' + item.director + ')'
|
2011-08-21 03:12:46 +00:00
|
|
|
ratio = item.posterRatio,
|
2011-08-08 07:48:13 +00:00
|
|
|
windowWidth = window.innerWidth * 0.8,
|
|
|
|
windowHeight = window.innerHeight * 0.8,
|
|
|
|
windowRatio = windowWidth / windowHeight,
|
|
|
|
width = Math.round(ratio > windowRatio ? windowWidth : windowHeight * ratio),
|
|
|
|
height = Math.round(ratio < windowRatio ? windowHeight : windowWidth / ratio);
|
|
|
|
pandora.$ui.previewImage = $('<img>')
|
2011-08-21 03:12:46 +00:00
|
|
|
.attr({src: '/' + item.id + '/poster128.jpg'})
|
2011-08-08 07:48:13 +00:00
|
|
|
.css({width: width + 'px', height: height + 'px'})
|
|
|
|
$('<img>').load(function() {
|
|
|
|
pandora.$ui.previewImage.attr({src: $(this).attr('src')});
|
|
|
|
})
|
2011-08-21 03:12:46 +00:00
|
|
|
.attr({src: '/' + item.id + '/poster1024.jpg'});
|
2011-08-08 07:48:13 +00:00
|
|
|
if (!preview) {
|
|
|
|
if (!pandora.$ui.previewDialog) {
|
|
|
|
pandora.$ui.previewDialog = Ox.Dialog({
|
|
|
|
closeButton: true,
|
|
|
|
content: pandora.$ui.previewImage,
|
|
|
|
fixedRatio: true,
|
|
|
|
focus: false,
|
|
|
|
height: height,
|
|
|
|
maximizeButton: true,
|
|
|
|
title: title,
|
|
|
|
width: width
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
close: function() {
|
|
|
|
that.closePreview();
|
|
|
|
preview = false;
|
|
|
|
},
|
|
|
|
resize: function(event) {
|
|
|
|
pandora.$ui.previewImage.css({
|
|
|
|
width: event.width + 'px',
|
|
|
|
height: event.height + 'px'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.open();
|
|
|
|
} else {
|
|
|
|
pandora.$ui.previewDialog.options({
|
|
|
|
content: pandora.$ui.previewImage,
|
|
|
|
height: height,
|
|
|
|
title: title,
|
|
|
|
width: width
|
|
|
|
})
|
|
|
|
.open();
|
|
|
|
}
|
|
|
|
preview = true;
|
2011-05-25 19:42:45 +00:00
|
|
|
} else {
|
2011-08-08 07:48:13 +00:00
|
|
|
pandora.$ui.previewDialog.options({
|
2011-06-06 15:48:11 +00:00
|
|
|
content: pandora.$ui.previewImage,
|
2011-05-25 19:42:45 +00:00
|
|
|
title: title,
|
|
|
|
})
|
2011-08-08 07:48:13 +00:00
|
|
|
.setSize(width, height);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
paste: function(data) {
|
2011-06-04 16:19:06 +00:00
|
|
|
data.items && pandora.getListData().editable && pandora.api.addListItems({
|
2011-06-06 15:48:11 +00:00
|
|
|
list: pandora.user.ui.list,
|
2011-05-25 19:42:45 +00:00
|
|
|
items: data.items
|
2011-06-04 16:19:06 +00:00
|
|
|
}, pandora.reloadList);
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-08-18 07:54:46 +00:00
|
|
|
select: function(data) {
|
2011-05-25 19:42:45 +00:00
|
|
|
var $still, $timeline;
|
2011-08-17 13:23:17 +00:00
|
|
|
pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), data.ids);
|
|
|
|
//pandora.user.ui.lists[pandora.user.ui.list].selected = data.ids;
|
2011-05-25 19:42:45 +00:00
|
|
|
if (data.ids.length) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.mainMenu.enableItem('copy');
|
|
|
|
pandora.$ui.mainMenu.enableItem('openmovie');
|
2011-05-25 19:42:45 +00:00
|
|
|
} else {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.mainMenu.disableItem('copy');
|
|
|
|
pandora.$ui.mainMenu.disableItem('openmovie');
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2011-08-08 13:58:28 +00:00
|
|
|
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info(data.ids[0]));
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.api.find({
|
|
|
|
query: {
|
|
|
|
conditions: $.map(data.ids, function(id, i) {
|
|
|
|
return {
|
|
|
|
key: 'id',
|
|
|
|
value: id,
|
|
|
|
operator: '='
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
operator: '|'
|
|
|
|
}
|
|
|
|
}, function(result) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.selected.html(pandora.ui.status('selected', result.data));
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
that.display = function() { // fixme: used?
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.rightPanel.replaceElement(1, pandora.$ui.contentPanel = pandora.ui.contentPanel());
|
2011-05-25 19:42:45 +00:00
|
|
|
};
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|