add rudimentary support for itemFind

This commit is contained in:
rolux 2011-10-30 09:49:12 +00:00
parent 9342bcd391
commit d4e1bc7e56
5 changed files with 129 additions and 101 deletions

View file

@ -488,6 +488,7 @@
{"id": "data", "title": "Data"}, {"id": "data", "title": "Data"},
{"id": "files", "title": "Files"} {"id": "files", "title": "Files"}
], ],
// fixme: should be renamed to annotationLayers
"layers": [ "layers": [
{ {
"id": "privatenotes", "id": "privatenotes",
@ -601,6 +602,7 @@
"icons": "posters", "icons": "posters",
"infoIconSize": 256, "infoIconSize": 256,
"item": "", "item": "",
"itemFind": {"conditions": [], "operator": "&"},
"itemSort": [{"key": "position", "operator": "+"}], "itemSort": [{"key": "position", "operator": "+"}],
"itemView": "info", "itemView": "info",
"listColumns": ["title", "director", "country", "year", "language", "runtime", "genre"], "listColumns": ["title", "director", "country", "year", "language", "runtime", "genre"],

View file

@ -65,7 +65,9 @@ pandora.UI = (function() {
Ox.forEach(listSettings, function(listSetting, setting) { Ox.forEach(listSettings, function(listSetting, setting) {
if (!pandora.user.ui.lists[list]) { if (!pandora.user.ui.lists[list]) {
// add default list setting and copy to settings // add default list setting and copy to settings
add['lists.' + that.encode(list) + '.' + listSetting] = pandora.site.user.ui[setting]; add[
'lists.' + that.encode(list) + '.' + listSetting
] = pandora.site.user.ui[setting];
add[setting] = pandora.site.user.ui[setting]; add[setting] = pandora.site.user.ui[setting];
} else { } else {
// copy lists setting to settings // copy lists setting to settings
@ -73,12 +75,13 @@ pandora.UI = (function() {
} }
}); });
} }
add.itemFind = pandora.isItemFind(args.find)
? args.find : pandora.site.user.ui.itemFind;
} }
// it is important to check for find first, so that if find // it is important to check for find first, so that if find
// changes list, pandora.user.ui._list is correct here // changes list, pandora.user.ui._list is correct here
var item = args['item'] || pandora.user.ui.item, var item = args['item'] || pandora.user.ui.item,
list = pandora.user.ui._list || ''; list = pandora.user.ui._list || '';
Ox.print('item/list', item, list, '...', args['videoPoints.' + item])
if (!pandora.user.ui.lists[list]) { if (!pandora.user.ui.lists[list]) {
add['lists.' + that.encode(list)] = {}; add['lists.' + that.encode(list)] = {};
} }

View file

@ -98,12 +98,13 @@ pandora.URL = (function() {
if (!pandora.user.ui.item) { if (!pandora.user.ui.item) {
state.view = pandora.user.ui.listView; state.view = pandora.user.ui.listView;
state.sort = pandora.user.ui.listSort; state.sort = pandora.user.ui.listSort;
state.find = pandora.user.ui.find;
} else { } else {
state.item = pandora.user.ui.item; state.item = pandora.user.ui.item;
state.view = pandora.user.ui.itemView; state.view = pandora.user.ui.itemView;
state.sort = pandora.user.ui.itemSort; state.sort = pandora.user.ui.itemSort;
state.find = pandora.user.ui.itemFind;
} }
state.find = pandora.user.ui.find
} }
Ox.print('STATE .................... ->', state) Ox.print('STATE .................... ->', state)
return state; return state;
@ -139,9 +140,10 @@ pandora.URL = (function() {
if (state.page == 'home') { if (state.page == 'home') {
//pandora.$ui.home = pandora.ui.home().showScreen(); //pandora.$ui.home = pandora.ui.home().showScreen();
pandora.$ui.home = pandora.ui.home().fadeInScreen(); pandora.$ui.home = pandora.ui.home().fadeInScreen();
} else if ([ } else if (
'about', 'contact', 'faq', 'news', 'rights', 'software', 'terms', 'tour' Ox.getPositionById(pandora.site.sitePages, state.page) > -1
].indexOf(state.page) > -1) { || state.page == 'software'
) {
pandora.$ui.siteDialog = pandora.ui.siteDialog(state.page).open(); pandora.$ui.siteDialog = pandora.ui.siteDialog(state.page).open();
} else if (state.page == 'help') { } else if (state.page == 'help') {
pandora.$ui.helpDialog = pandora.ui.helpDialog().open(); pandora.$ui.helpDialog = pandora.ui.helpDialog().open();
@ -168,8 +170,7 @@ pandora.URL = (function() {
var set = { var set = {
section: state.type == pandora.site.itemsSection ? 'items' : state.type, section: state.type == pandora.site.itemsSection ? 'items' : state.type,
item: state.item, item: state.item
//find: state.find
}; };
if (state.view) { if (state.view) {
@ -195,6 +196,8 @@ pandora.URL = (function() {
set['mapFind'] = state.span.substr(1); set['mapFind'] = state.span.substr(1);
set['mapSelection'] = ''; set['mapSelection'] = '';
} }
} else if (state.view == 'calendar') {
// ...
} }
} }
@ -202,17 +205,20 @@ pandora.URL = (function() {
set[!state.item ? 'listSort' : 'itemSort'] = state.sort; set[!state.item ? 'listSort' : 'itemSort'] = state.sort;
} }
///*
if (state.find) { if (state.find) {
find = state.find; if (!state.item) {
set.find = find; find = state.find;
} else { set.find = state.find;
} else if (pandora.isItemFind(state.find)) {
set.itemFind = state.find;
}
}
if (!find) {
find = pandora.user.ui.find; find = pandora.user.ui.find;
pandora.user.ui._list = pandora.getListsState(find) pandora.user.ui._list = pandora.getListsState(find)
pandora.user.ui._groupsState = pandora.getGroupsState(find); pandora.user.ui._groupsState = pandora.getGroupsState(find);
pandora.user.ui._findState = pandora.getFindState(find); pandora.user.ui._findState = pandora.getFindState(find);
} }
//*/
Ox.Request.cancel(); Ox.Request.cancel();
$('video').each(function() { $('video').each(function() {

View file

@ -148,16 +148,13 @@ pandora.ui.item = function() {
); );
} else if (pandora.user.ui.itemView == 'video') { } else if (pandora.user.ui.itemView == 'video') {
// fixme: duplicated
var clipsQuery = pandora.getClipsQuery(),
isClipsQuery = !!clipsQuery.conditions.length;
// ...
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({ pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
annotationsSize: pandora.user.ui.annotationsSize, annotationsSize: pandora.user.ui.annotationsSize,
censored: censored, censored: censored,
cuts: result.data.cuts || [], cuts: result.data.cuts || [],
duration: result.data.duration, duration: result.data.duration,
find: isClipsQuery ? clipsQuery.conditions[0].value : '', find: pandora.user.ui.itemFind.conditions[0]
? pandora.user.ui.itemFind.conditions[0].value : '',
getTimelineImageURL: function(i) { getTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
}, },
@ -176,6 +173,12 @@ pandora.ui.item = function() {
volume: pandora.user.ui.videoVolume, volume: pandora.user.ui.videoVolume,
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({ }).bindEvent({
find: function(data) {
pandora.UI.set('itemFind', {
conditions: [{key: 'subtitles', value: data.find, operator: '='}],
operator: '&'
});
},
muted: function(data) { muted: function(data) {
pandora.UI.set('muted', data.muted); pandora.UI.set('muted', data.muted);
}, },
@ -203,89 +206,96 @@ pandora.ui.item = function() {
})); }));
} else if (pandora.user.ui.itemView == 'timeline') { } else if (pandora.user.ui.itemView == 'timeline') {
var clipsQuery = pandora.getClipsQuery(), pandora.$ui.contentPanel.replaceElement(1,
isClipsQuery = !!clipsQuery.conditions.length; pandora.$ui.editor = Ox.VideoEditor({
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = Ox.VideoEditor({ annotationsSize: pandora.user.ui.annotationsSize,
annotationsSize: pandora.user.ui.annotationsSize, censored: censored,
censored: censored, cuts: result.data.cuts || [],
cuts: result.data.cuts || [], duration: result.data.duration,
duration: result.data.duration, find: pandora.user.ui.itemFind.conditions[0]
find: isClipsQuery ? clipsQuery.conditions[0].value : '', ? pandora.user.ui.itemFind.conditions[0].value : '',
getFrameURL: function(position) { getFrameURL: function(position) {
return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg'; return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg';
}, },
getLargeTimelineImageURL: function(i) { getLargeTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
}, },
getSmallTimelineImageURL: function(i) { getSmallTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline16p' + i + '.png'; return '/' + pandora.user.ui.item + '/timeline16p' + i + '.png';
}, },
height: pandora.$ui.contentPanel.size(1), height: pandora.$ui.contentPanel.size(1),
id: 'editor', id: 'editor',
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'], 'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
layers: layers, layers: layers,
muted: pandora.user.ui.videoMuted, muted: pandora.user.ui.videoMuted,
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out, out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position, position: pandora.user.ui.videoPoints[pandora.user.ui.item].position,
posterFrame: parseInt(video.duration / 2), posterFrame: parseInt(video.duration / 2),
showAnnotations: pandora.user.ui.showAnnotations, showAnnotations: pandora.user.ui.showAnnotations,
showLargeTimeline: true, showLargeTimeline: true,
subtitles: subtitles, subtitles: subtitles,
tooltips: true, tooltips: true,
video: video, video: video,
videoRatio: result.data.videoRatio, videoRatio: result.data.videoRatio,
videoSize: pandora.user.ui.videoSize, videoSize: pandora.user.ui.videoSize,
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({ }).bindEvent({
points: function(data) { find: function(data) {
pandora.UI.set('videoPoints.' + pandora.user.ui.item, { pandora.UI.set('itemFind', {
'in': data['in'], conditions: [{key: 'subtitles', value: data.find, operator: '='}],
out: data.out, operator: '&'
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position });
}); },
}, points: function(data) {
position: function(data) { pandora.UI.set('videoPoints.' + pandora.user.ui.item, {
pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position); 'in': data['in'],
}, out: data.out,
resize: function(data) { position: pandora.user.ui.videoPoints[pandora.user.ui.item].position
Ox.print('RESIZE!!', data.size) });
pandora.$ui.editor.options({ },
height: data.size position: function(data) {
}); pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position);
}, },
resizeend: function(data) { resize: function(data) {
pandora.UI.set({annotationsSize: data.size}); Ox.print('RESIZE!!', data.size)
}, pandora.$ui.editor.options({
togglesize: function(data) { height: data.size
pandora.UI.set({videoSize: data.size}); });
}, },
addannotation: function(data) { resizeend: function(data) {
Ox.print('addAnnotation', data); pandora.UI.set({annotationsSize: data.size});
data.item = pandora.user.ui.item; },
data.value = 'Click to edit'; togglesize: function(data) {
pandora.api.addAnnotation(data, function(result) { pandora.UI.set({videoSize: data.size});
pandora.$ui.editor.addAnnotation(data.layer, result.data); },
}); addannotation: function(data) {
}, Ox.print('addAnnotation', data);
removeannotations: function(data) { data.item = pandora.user.ui.item;
pandora.api.removeAnnotations(data, function(result) { data.value = 'Click to edit';
//fixme: check for errors pandora.api.addAnnotation(data, function(result) {
pandora.$ui.editor.removeAnnotations(data.layer, data.ids); pandora.$ui.editor.addAnnotation(data.layer, result.data);
}); });
}, },
toggleannotations: function(data) { removeannotations: function(data) {
pandora.UI.set('showAnnotations', data.showAnnotations); pandora.api.removeAnnotations(data, function(result) {
}, //fixme: check for errors
updateannotation: function(data) { pandora.$ui.editor.removeAnnotations(data.layer, data.ids);
//fixme: check that edit was successfull });
pandora.api.editAnnotation(data, function(result) { },
Ox.print('done updateAnnotation', result); toggleannotations: function(data) {
}); pandora.UI.set('showAnnotations', data.showAnnotations);
}, },
pandora_showannotations: function(data) { updateannotation: function(data) {
pandora.$ui.editor.options({showAnnotations: data.value}); //fixme: check that edit was successfull
} pandora.api.editAnnotation(data, function(result) {
})); Ox.print('done updateAnnotation', result);
});
},
pandora_showannotations: function(data) {
pandora.$ui.editor.options({showAnnotations: data.value});
}
})
);
that.bindEvent('resize', function(data) { that.bindEvent('resize', function(data) {
//Ox.print('resize item', data) //Ox.print('resize item', data)
pandora.$ui.editor.options({ pandora.$ui.editor.options({

View file

@ -435,6 +435,7 @@ pandora.getClipsItems = function(width) {
}; };
pandora.getClipsQuery = function() { pandora.getClipsQuery = function() {
// fixme: nice, but not needed
function addClipsConditions(conditions) { function addClipsConditions(conditions) {
conditions.forEach(function(condition) { conditions.forEach(function(condition) {
if (condition.conditions) { if (condition.conditions) {
@ -678,6 +679,12 @@ pandora.isClipView = function(view, item) {
).indexOf(view) > -1; ).indexOf(view) > -1;
}; };
pandora.isItemFind = function(find) {
return find.conditions.length == 1
&& Ox.getPositionById(pandora.site.layers, find.conditions[0].key) > -1
&& find.conditions[0].operator == '=';
};
pandora.signin = function(data) { pandora.signin = function(data) {
pandora.user = data.user; pandora.user = data.user;
pandora.user.ui._list = pandora.getListsState(pandora.user.ui.find); pandora.user.ui._list = pandora.getListsState(pandora.user.ui.find);