diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 3d0045999..09c2d0614 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -488,6 +488,7 @@ {"id": "data", "title": "Data"}, {"id": "files", "title": "Files"} ], + // fixme: should be renamed to annotationLayers "layers": [ { "id": "privatenotes", @@ -601,6 +602,7 @@ "icons": "posters", "infoIconSize": 256, "item": "", + "itemFind": {"conditions": [], "operator": "&"}, "itemSort": [{"key": "position", "operator": "+"}], "itemView": "info", "listColumns": ["title", "director", "country", "year", "language", "runtime", "genre"], diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index c24849117..53e565c79 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -65,7 +65,9 @@ pandora.UI = (function() { Ox.forEach(listSettings, function(listSetting, setting) { if (!pandora.user.ui.lists[list]) { // 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]; } else { // 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 // changes list, pandora.user.ui._list is correct here var item = args['item'] || pandora.user.ui.item, list = pandora.user.ui._list || ''; - Ox.print('item/list', item, list, '...', args['videoPoints.' + item]) if (!pandora.user.ui.lists[list]) { add['lists.' + that.encode(list)] = {}; } diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index b25ddf774..22f8f757e 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -98,12 +98,13 @@ pandora.URL = (function() { if (!pandora.user.ui.item) { state.view = pandora.user.ui.listView; state.sort = pandora.user.ui.listSort; + state.find = pandora.user.ui.find; } else { state.item = pandora.user.ui.item; state.view = pandora.user.ui.itemView; state.sort = pandora.user.ui.itemSort; + state.find = pandora.user.ui.itemFind; } - state.find = pandora.user.ui.find } Ox.print('STATE .................... ->', state) return state; @@ -139,9 +140,10 @@ pandora.URL = (function() { if (state.page == 'home') { //pandora.$ui.home = pandora.ui.home().showScreen(); pandora.$ui.home = pandora.ui.home().fadeInScreen(); - } else if ([ - 'about', 'contact', 'faq', 'news', 'rights', 'software', 'terms', 'tour' - ].indexOf(state.page) > -1) { + } else if ( + Ox.getPositionById(pandora.site.sitePages, state.page) > -1 + || state.page == 'software' + ) { pandora.$ui.siteDialog = pandora.ui.siteDialog(state.page).open(); } else if (state.page == 'help') { pandora.$ui.helpDialog = pandora.ui.helpDialog().open(); @@ -168,8 +170,7 @@ pandora.URL = (function() { var set = { section: state.type == pandora.site.itemsSection ? 'items' : state.type, - item: state.item, - //find: state.find + item: state.item }; if (state.view) { @@ -195,6 +196,8 @@ pandora.URL = (function() { set['mapFind'] = state.span.substr(1); set['mapSelection'] = ''; } + } else if (state.view == 'calendar') { + // ... } } @@ -202,17 +205,20 @@ pandora.URL = (function() { set[!state.item ? 'listSort' : 'itemSort'] = state.sort; } - ///* if (state.find) { - find = state.find; - set.find = find; - } else { + if (!state.item) { + find = state.find; + set.find = state.find; + } else if (pandora.isItemFind(state.find)) { + set.itemFind = state.find; + } + } + if (!find) { find = pandora.user.ui.find; pandora.user.ui._list = pandora.getListsState(find) pandora.user.ui._groupsState = pandora.getGroupsState(find); pandora.user.ui._findState = pandora.getFindState(find); } - //*/ Ox.Request.cancel(); $('video').each(function() { diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index f94b55400..8eafa4400 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -148,16 +148,13 @@ pandora.ui.item = function() { ); } 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({ annotationsSize: pandora.user.ui.annotationsSize, censored: censored, cuts: result.data.cuts || [], 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) { return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; }, @@ -176,6 +173,12 @@ pandora.ui.item = function() { volume: pandora.user.ui.videoVolume, width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 }).bindEvent({ + find: function(data) { + pandora.UI.set('itemFind', { + conditions: [{key: 'subtitles', value: data.find, operator: '='}], + operator: '&' + }); + }, muted: function(data) { pandora.UI.set('muted', data.muted); }, @@ -203,89 +206,96 @@ pandora.ui.item = function() { })); } else if (pandora.user.ui.itemView == 'timeline') { - var clipsQuery = pandora.getClipsQuery(), - isClipsQuery = !!clipsQuery.conditions.length; - pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = Ox.VideoEditor({ - annotationsSize: pandora.user.ui.annotationsSize, - censored: censored, - cuts: result.data.cuts || [], - duration: result.data.duration, - find: isClipsQuery ? clipsQuery.conditions[0].value : '', - getFrameURL: function(position) { - return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg'; - }, - getLargeTimelineImageURL: function(i) { - return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; - }, - getSmallTimelineImageURL: function(i) { - return '/' + pandora.user.ui.item + '/timeline16p' + i + '.png'; - }, - height: pandora.$ui.contentPanel.size(1), - id: 'editor', - 'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'], - layers: layers, - muted: pandora.user.ui.videoMuted, - out: pandora.user.ui.videoPoints[pandora.user.ui.item].out, - position: pandora.user.ui.videoPoints[pandora.user.ui.item].position, - posterFrame: parseInt(video.duration / 2), - showAnnotations: pandora.user.ui.showAnnotations, - showLargeTimeline: true, - subtitles: subtitles, - tooltips: true, - video: video, - videoRatio: result.data.videoRatio, - videoSize: pandora.user.ui.videoSize, - width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 - }).bindEvent({ - points: function(data) { - pandora.UI.set('videoPoints.' + pandora.user.ui.item, { - 'in': data['in'], - out: data.out, - position: pandora.user.ui.videoPoints[pandora.user.ui.item].position - }); - }, - position: function(data) { - pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position); - }, - resize: function(data) { - Ox.print('RESIZE!!', data.size) - pandora.$ui.editor.options({ - height: data.size - }); - }, - resizeend: function(data) { - pandora.UI.set({annotationsSize: data.size}); - }, - togglesize: function(data) { - pandora.UI.set({videoSize: data.size}); - }, - addannotation: function(data) { - Ox.print('addAnnotation', data); - data.item = pandora.user.ui.item; - data.value = 'Click to edit'; - pandora.api.addAnnotation(data, function(result) { - pandora.$ui.editor.addAnnotation(data.layer, result.data); - }); - }, - removeannotations: function(data) { - pandora.api.removeAnnotations(data, function(result) { - //fixme: check for errors - pandora.$ui.editor.removeAnnotations(data.layer, data.ids); - }); - }, - toggleannotations: function(data) { - pandora.UI.set('showAnnotations', data.showAnnotations); - }, - updateannotation: function(data) { - //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}); - } - })); + pandora.$ui.contentPanel.replaceElement(1, + pandora.$ui.editor = Ox.VideoEditor({ + annotationsSize: pandora.user.ui.annotationsSize, + censored: censored, + cuts: result.data.cuts || [], + duration: result.data.duration, + find: pandora.user.ui.itemFind.conditions[0] + ? pandora.user.ui.itemFind.conditions[0].value : '', + getFrameURL: function(position) { + return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg'; + }, + getLargeTimelineImageURL: function(i) { + return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; + }, + getSmallTimelineImageURL: function(i) { + return '/' + pandora.user.ui.item + '/timeline16p' + i + '.png'; + }, + height: pandora.$ui.contentPanel.size(1), + id: 'editor', + 'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'], + layers: layers, + muted: pandora.user.ui.videoMuted, + out: pandora.user.ui.videoPoints[pandora.user.ui.item].out, + position: pandora.user.ui.videoPoints[pandora.user.ui.item].position, + posterFrame: parseInt(video.duration / 2), + showAnnotations: pandora.user.ui.showAnnotations, + showLargeTimeline: true, + subtitles: subtitles, + tooltips: true, + video: video, + videoRatio: result.data.videoRatio, + videoSize: pandora.user.ui.videoSize, + width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 + }).bindEvent({ + find: function(data) { + pandora.UI.set('itemFind', { + conditions: [{key: 'subtitles', value: data.find, operator: '='}], + operator: '&' + }); + }, + points: function(data) { + pandora.UI.set('videoPoints.' + pandora.user.ui.item, { + 'in': data['in'], + out: data.out, + position: pandora.user.ui.videoPoints[pandora.user.ui.item].position + }); + }, + position: function(data) { + pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position); + }, + resize: function(data) { + Ox.print('RESIZE!!', data.size) + pandora.$ui.editor.options({ + height: data.size + }); + }, + resizeend: function(data) { + pandora.UI.set({annotationsSize: data.size}); + }, + togglesize: function(data) { + pandora.UI.set({videoSize: data.size}); + }, + addannotation: function(data) { + Ox.print('addAnnotation', data); + data.item = pandora.user.ui.item; + data.value = 'Click to edit'; + pandora.api.addAnnotation(data, function(result) { + pandora.$ui.editor.addAnnotation(data.layer, result.data); + }); + }, + removeannotations: function(data) { + pandora.api.removeAnnotations(data, function(result) { + //fixme: check for errors + pandora.$ui.editor.removeAnnotations(data.layer, data.ids); + }); + }, + toggleannotations: function(data) { + pandora.UI.set('showAnnotations', data.showAnnotations); + }, + updateannotation: function(data) { + //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) { //Ox.print('resize item', data) pandora.$ui.editor.options({ diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 721355e6d..a8754b279 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -435,6 +435,7 @@ pandora.getClipsItems = function(width) { }; pandora.getClipsQuery = function() { + // fixme: nice, but not needed function addClipsConditions(conditions) { conditions.forEach(function(condition) { if (condition.conditions) { @@ -678,6 +679,12 @@ pandora.isClipView = function(view, item) { ).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.user = data.user; pandora.user.ui._list = pandora.getListsState(pandora.user.ui.find);