list.js: pandora.user.ui -> ui

This commit is contained in:
rolux 2014-01-23 14:35:38 +00:00
parent 189c6feba9
commit 4c8f87b2d0

View file

@ -4,7 +4,8 @@
pandora.ui.list = function() { pandora.ui.list = function() {
var that, var that,
view = pandora.user.ui.listView; ui = pandora.user.ui,
view = ui.listView;
if (view == 'list') { if (view == 'list') {
that = Ox.TableList({ that = Ox.TableList({
@ -13,7 +14,7 @@ pandora.ui.list = function() {
defaultWidth: 16, defaultWidth: 16,
format: function(value, data) { format: function(value, data) {
var icon, width, height, margin, marginCSS, borderRadius; var icon, width, height, margin, marginCSS, borderRadius;
if (pandora.user.ui.icons == 'posters') { if (ui.icons == 'posters') {
icon = 'poster'; icon = 'poster';
width = value < 1 ? Math.round(14 * value / 2) * 2 : 14; width = value < 1 ? Math.round(14 * value / 2) * 2 : 14;
height = value < 1 ? 14 : Math.round(14 / value / 2) * 2; height = value < 1 ? 14 : Math.round(14 / value / 2) * 2;
@ -49,14 +50,14 @@ pandora.ui.list = function() {
id: 'posterRatio', id: 'posterRatio',
resizable: false, resizable: false,
title: Ox._('Icon'), title: Ox._('Icon'),
titleImage: pandora.user.ui.icons == 'posters' ? 'SetPoster' : 'Icon', titleImage: ui.icons == 'posters' ? 'SetPoster' : 'Icon',
visible: pandora.user.ui.listColumns.indexOf('posterRatio') > -1, visible: ui.listColumns.indexOf('posterRatio') > -1,
width: 16 width: 16
}], pandora.site.sortKeys.filter(function(key) { }], pandora.site.sortKeys.filter(function(key) {
return !key.capability return !key.capability
|| pandora.site.capabilities[key.capability][pandora.user.level]; || pandora.site.capabilities[key.capability][pandora.user.level];
}).map(function(key) { }).map(function(key) {
var position = pandora.user.ui.listColumns.indexOf(key.id); var position = ui.listColumns.indexOf(key.id);
return { return {
addable: key.id != 'random', addable: key.id != 'random',
align: ['string', 'text'].indexOf( align: ['string', 'text'].indexOf(
@ -71,7 +72,7 @@ pandora.ui.list = function() {
title: Ox._(key.title), title: Ox._(key.title),
type: key.type, type: key.type,
visible: position > -1, visible: position > -1,
width: pandora.user.ui.listColumnWidth[key.id] || key.columnWidth width: ui.listColumnWidth[key.id] || key.columnWidth
}; };
})), })),
columnsMovable: true, columnsMovable: true,
@ -83,14 +84,14 @@ pandora.ui.list = function() {
items: function(data, callback) { items: function(data, callback) {
//Ox.Log('', 'data, pandora.Query.toObject', data, pandora.Query.toObject()) //Ox.Log('', 'data, pandora.Query.toObject', data, pandora.Query.toObject())
pandora.api.find(Ox.extend(data, { pandora.api.find(Ox.extend(data, {
query: pandora.user.ui.find, query: ui.find,
keys: data.keys ? ['modified'].concat(data.keys) : void 0 keys: data.keys ? ['modified'].concat(data.keys) : void 0
}), callback); }), callback);
return Ox.clone(data, true); return Ox.clone(data, true);
}, },
scrollbarVisible: true, scrollbarVisible: true,
selected: pandora.user.ui.listSelection, selected: ui.listSelection,
sort: pandora.user.ui.listSort, sort: ui.listSort,
unique: 'id' unique: 'id'
}) })
.bindEvent({ .bindEvent({
@ -100,7 +101,7 @@ pandora.ui.list = function() {
/* /*
data.ids.forEach(function(id) { data.ids.forEach(function(id) {
columnWidth[id] = columnWidth[id] =
pandora.user.ui.lists[pandora.user.ui.list].columnWidth[id] ui.lists[ui.list].columnWidth[id]
|| Ox.getObjectById(pandora.site.sortKeys, id).width || Ox.getObjectById(pandora.site.sortKeys, id).width
}); });
pandora.UI.set({listColumnWidth: columnWidth}); pandora.UI.set({listColumnWidth: columnWidth});
@ -120,13 +121,12 @@ pandora.ui.list = function() {
}); });
} else if (view == 'grid') { } else if (view == 'grid') {
that = Ox.IconList({ that = Ox.IconList({
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16, borderRadius: ui.icons == 'posters' ? 0 : 16,
defaultRatio: pandora.user.ui.icons == 'posters' ? pandora.site.posters.ratio : 1, defaultRatio: ui.icons == 'posters' ? pandora.site.posters.ratio : 1,
draggable: true, draggable: true,
id: 'list', id: 'list',
item: function(data, sort, size) { item: function(data, sort, size) {
var ui = pandora.user.ui, var ratio = ui.icons == 'posters'
ratio = ui.icons == 'posters'
? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1, ? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1,
url = '/' + data.id + '/' + ( url = '/' + data.id + '/' + (
ui.icons == 'posters' ui.icons == 'posters'
@ -162,14 +162,14 @@ pandora.ui.list = function() {
}, },
items: function(data, callback) { items: function(data, callback) {
pandora.api.find(Ox.extend(data, { pandora.api.find(Ox.extend(data, {
query: pandora.user.ui.find query: ui.find
}), callback); }), callback);
return Ox.clone(data, true); return Ox.clone(data, true);
}, },
keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'], keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'],
selected: pandora.user.ui.listSelection, selected: ui.listSelection,
size: 128, size: 128,
sort: pandora.user.ui.listSort, sort: ui.listSort,
unique: 'id' unique: 'id'
}) })
.addClass('OxMedia'); .addClass('OxMedia');
@ -177,14 +177,13 @@ pandora.ui.list = function() {
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.'); that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
} else if (view == 'clips') { } else if (view == 'clips') {
that = Ox.InfoList({ that = Ox.InfoList({
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16, borderRadius: ui.icons == 'posters' ? 0 : 16,
defaultRatio: pandora.user.ui.icons == 'posters' ? pandora.site.posters.ratio : 1, defaultRatio: ui.icons == 'posters' ? pandora.site.posters.ratio : 1,
draggable: true, draggable: true,
id: 'list', id: 'list',
item: function(data, sort, size) { item: function(data, sort, size) {
size = 128; size = 128;
var ui = pandora.user.ui, var ratio = ui.icons == 'posters'
ratio = ui.icons == 'posters'
? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1, ? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1,
url = '/' + data.id + '/' + ( url = '/' + data.id + '/' + (
ui.icons == 'posters' ui.icons == 'posters'
@ -232,7 +231,7 @@ pandora.ui.list = function() {
}, },
items: function(data, callback) { items: function(data, callback) {
pandora.api.find(Ox.extend(data, { pandora.api.find(Ox.extend(data, {
query: pandora.user.ui.find, query: ui.find,
clips: { clips: {
query: pandora.getClipsQuery(), query: pandora.getClipsQuery(),
items: pandora.getClipsItems(), items: pandora.getClipsItems(),
@ -242,12 +241,12 @@ pandora.ui.list = function() {
return Ox.clone(data, true); return Ox.clone(data, true);
}, },
keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'title', 'videoRatio', 'year'], keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'title', 'videoRatio', 'year'],
selected: pandora.user.ui.listSelection, selected: ui.listSelection,
size: 192, size: 192,
sort: pandora.user.ui.listSort, sort: ui.listSort,
unique: 'id', unique: 'id',
width: window.innerWidth width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1 - ui.showSidebar * ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE - Ox.UI.SCROLLBAR_SIZE
}) })
.addClass('OxMedia') .addClass('OxMedia')
@ -261,15 +260,14 @@ pandora.ui.list = function() {
}); });
} else if (view == 'timelines') { } else if (view == 'timelines') {
that = Ox.InfoList({ that = Ox.InfoList({
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16, borderRadius: ui.icons == 'posters' ? 0 : 16,
defaultRatio: pandora.user.ui.icons == 'posters' ? pandora.site.posters.ratio : 1, defaultRatio: ui.icons == 'posters' ? pandora.site.posters.ratio : 1,
draggable: true, draggable: true,
id: 'list', id: 'list',
item: function(data, sort, size) { item: function(data, sort, size) {
size = 128; size = 128;
var clipsQuery = pandora.getClipsQuery(), var clipsQuery = pandora.getClipsQuery(),
isClipsQuery = !!clipsQuery.conditions.length, isClipsQuery = !!clipsQuery.conditions.length,
ui = pandora.user.ui,
ratio = ui.icons == 'posters' ratio = ui.icons == 'posters'
? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1, ? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1,
url = '/' + data.id + '/' + ( url = '/' + data.id + '/' + (
@ -308,7 +306,7 @@ pandora.ui.list = function() {
element: Ox.BlockVideoTimeline, element: Ox.BlockVideoTimeline,
events: { events: {
position: function(event) { position: function(event) {
if (pandora.user.ui.videoPoints[data.id]) { if (ui.videoPoints[data.id]) {
pandora.UI.set('videoPoints.' + data.id + '.position', event.position); pandora.UI.set('videoPoints.' + data.id + '.position', event.position);
} else { } else {
pandora.UI.set('videoPoints.' + data.id, {'in': 0, out: 0, position: event.position}); pandora.UI.set('videoPoints.' + data.id, {'in': 0, out: 0, position: event.position});
@ -327,15 +325,15 @@ pandora.ui.list = function() {
getImageURL: function(type, i) { getImageURL: function(type, i) {
return '/' + data.id + '/timeline' + type + '16p' + i + '.jpg'; return '/' + data.id + '/timeline' + type + '16p' + i + '.jpg';
}, },
position: pandora.user.ui.videoPoints[data.id] position: ui.videoPoints[data.id]
? pandora.user.ui.videoPoints[data.id].position : 0, ? ui.videoPoints[data.id].position : 0,
results: isClipsQuery ? data.clips.map(function(clip) { results: isClipsQuery ? data.clips.map(function(clip) {
return {'in': clip['in'], out: clip.out}; return {'in': clip['in'], out: clip.out};
}) : [], }) : [],
subtitles: isClipsQuery ? data.clips.map(function(clip) { subtitles: isClipsQuery ? data.clips.map(function(clip) {
return {'in': clip['in'], out: clip.out, text: clip.annotations[0].value}; return {'in': clip['in'], out: clip.out, text: clip.annotations[0].value};
}) : [], }) : [],
type: pandora.user.ui.videoTimeline type: ui.videoTimeline
} }
} : { } : {
css: {marginTop: '2px'}, css: {marginTop: '2px'},
@ -349,7 +347,7 @@ pandora.ui.list = function() {
var clipsQuery = pandora.getClipsQuery(), var clipsQuery = pandora.getClipsQuery(),
isClipsQuery = !!clipsQuery.conditions.length; isClipsQuery = !!clipsQuery.conditions.length;
pandora.api.find(Ox.extend(data, Ox.extend({ pandora.api.find(Ox.extend(data, Ox.extend({
query: pandora.user.ui.find query: ui.find
}, isClipsQuery ? {clips: { }, isClipsQuery ? {clips: {
query: clipsQuery, query: clipsQuery,
items: 1000000, items: 1000000,
@ -358,9 +356,9 @@ pandora.ui.list = function() {
return Ox.clone(data, true); return Ox.clone(data, true);
}, },
keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'rendered', 'title', 'year'], keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'rendered', 'title', 'year'],
selected: pandora.user.ui.listSelection, selected: ui.listSelection,
size: 192, size: 192,
sort: pandora.user.ui.listSort, sort: ui.listSort,
unique: 'id' unique: 'id'
}) })
.bindEvent({ .bindEvent({
@ -402,7 +400,7 @@ pandora.ui.list = function() {
var listData = pandora.getListData(); var listData = pandora.getListData();
if (listData.editable && listData.type == 'static') { if (listData.editable && listData.type == 'static') {
pandora.clipboard.copy(data.ids, 'item'); pandora.clipboard.copy(data.ids, 'item');
pandora.doHistory('cut', data.ids, pandora.user.ui._list, function() { pandora.doHistory('cut', data.ids, ui._list, function() {
pandora.UI.set({listSelection: []}); pandora.UI.set({listSelection: []});
pandora.reloadList(); pandora.reloadList();
}); });
@ -412,7 +410,7 @@ pandora.ui.list = function() {
var listData = pandora.getListData(); var listData = pandora.getListData();
if (listData.editable && listData.type == 'static') { if (listData.editable && listData.type == 'static') {
pandora.clipboard.add(data.ids, 'item'); pandora.clipboard.add(data.ids, 'item');
pandora.doHistory('cut', data.ids, pandora.user.ui._list, function() { pandora.doHistory('cut', data.ids, ui._list, function() {
pandora.UI.set({listSelection: []}); pandora.UI.set({listSelection: []});
pandora.reloadList(); pandora.reloadList();
}); });
@ -421,7 +419,7 @@ pandora.ui.list = function() {
'delete': function(data) { 'delete': function(data) {
var listData = pandora.getListData(); var listData = pandora.getListData();
if (listData.editable && listData.type == 'static') { if (listData.editable && listData.type == 'static') {
pandora.doHistory('delete', data.ids, pandora.user.ui._list, function() { pandora.doHistory('delete', data.ids, ui._list, function() {
pandora.UI.set({listSelection: []}); pandora.UI.set({listSelection: []});
pandora.reloadList(); pandora.reloadList();
}); });
@ -454,9 +452,9 @@ pandora.ui.list = function() {
open: function(data) { open: function(data) {
var set = {item: data.ids[0]}; var set = {item: data.ids[0]};
if (data.isSpecialTarget) { if (data.isSpecialTarget) {
set.itemView = pandora.user.ui.videoView; set.itemView = ui.videoView;
} }
if (['accessed', 'timesaccessed'].indexOf(pandora.user.ui.listSort[0].key) > -1) { if (['accessed', 'timesaccessed'].indexOf(ui.listSort[0].key) > -1) {
Ox.Request.clearCache('find'); Ox.Request.clearCache('find');
} }
pandora.UI.set(set); pandora.UI.set(set);
@ -478,7 +476,7 @@ pandora.ui.list = function() {
paste: function(data) { paste: function(data) {
var items = pandora.clipboard.paste(); var items = pandora.clipboard.paste();
if (items.length && pandora.clipboard.type() == 'item' && pandora.getListData().editable) { if (items.length && pandora.clipboard.type() == 'item' && pandora.getListData().editable) {
pandora.doHistory('paste', items, pandora.user.ui._list, function() { pandora.doHistory('paste', items, ui._list, function() {
pandora.UI.set({listSelection: items}); pandora.UI.set({listSelection: items});
pandora.reloadList(); pandora.reloadList();
}); });
@ -503,7 +501,7 @@ pandora.ui.list = function() {
}; };
} else { } else {
query = { query = {
conditions: [pandora.user.ui.find].concat( conditions: [ui.find].concat(
data.rest.map(function(id) { data.rest.map(function(id) {
return { return {
key: 'id', key: 'id',
@ -538,7 +536,7 @@ pandora.ui.list = function() {
var src, previousSrc; var src, previousSrc;
// fixme: doesn't update title icon, passes useless options // fixme: doesn't update title icon, passes useless options
if (hasIcons()) { if (hasIcons()) {
if (pandora.user.ui.listView == 'list') { if (ui.listView == 'list') {
src = Ox.UI.getImageURL( src = Ox.UI.getImageURL(
data.value == 'posters' ? 'symbolSetPoster' : 'symbolIcon' data.value == 'posters' ? 'symbolSetPoster' : 'symbolIcon'
); );
@ -557,7 +555,7 @@ pandora.ui.list = function() {
}, },
pandora_showsiteposters: function() { pandora_showsiteposters: function() {
// fixme: should be disabled if ui.icons != 'posters' // fixme: should be disabled if ui.icons != 'posters'
hasIcons() && pandora.user.ui.icons == 'posters' && that.reloadList(true); hasIcons() && ui.icons == 'posters' && that.reloadList(true);
} }
}); });
} }
@ -572,9 +570,9 @@ pandora.ui.list = function() {
function hasIcons() { function hasIcons() {
return ( return (
pandora.user.ui.listView == 'list' ui.listView == 'list'
&& pandora.user.ui.listColumns.indexOf('posterRatio') > -1 && ui.listColumns.indexOf('posterRatio') > -1
) || ['grid', 'timelines'].indexOf(pandora.user.ui.listView) > -1; ) || ['grid', 'timelines'].indexOf(ui.listView) > -1;
} }
return that; return that;