correctly enable/disable 'find similar clips' menu entry

This commit is contained in:
rolux 2012-06-15 14:43:05 +00:00
parent 7f95c0ce6c
commit f9df691c24
6 changed files with 73 additions and 15 deletions

View file

@ -215,9 +215,11 @@ pandora.ui.clipList = function(videoRatio) {
//*/ //*/
} }
!ui.item && pandora.UI.set('listSelection', [item]); !ui.item && pandora.UI.set('listSelection', [item]);
pandora.$ui.mainMenu.enableItem('findsimilar');
} else { } else {
$('.OxSelectedVideo').removeClass('OxSelectedVideo'); $('.OxSelectedVideo').removeClass('OxSelectedVideo');
!ui.item && pandora.UI.set('listSelection', []); !ui.item && pandora.UI.set('listSelection', []);
pandora.$ui.mainMenu.disableItem('findsimilar');
} }
}, },
pandora_itemsort: function(data) { pandora_itemsort: function(data) {

View file

@ -359,7 +359,7 @@ pandora.ui.list = function() {
} else if (view == 'calendars') { } else if (view == 'calendars') {
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 == 'clip') { } else if (view == 'clip') {
that = pandora.ui.clipList(); that = pandora.$ui.clipList = pandora.ui.clipList();
} else if (view == 'video') { } else if (view == 'video') {
that = pandora.ui.clipPlayer(); that = pandora.ui.clipPlayer();
} else if (['map', 'calendar'].indexOf(view) > -1) { } else if (['map', 'calendar'].indexOf(view) > -1) {

View file

@ -130,7 +130,7 @@ pandora.ui.mainMenu = function() {
] }, ] },
{ id: 'advancedfind', title: 'Advanced Find...', keyboard: 'shift control f' }, { id: 'advancedfind', title: 'Advanced Find...', keyboard: 'shift control f' },
{}, {},
{ id: 'findsimilar', title: 'Find Similar Clips...', disabled: true, keyboard: 'alt control f'} { id: 'findsimilar', title: 'Find Similar Clips...', keyboard: 'alt control f', disabled: !pandora.getItemIdAndPosition() }
] }, ] },
{ id: 'dataMenu', title: 'Data', items: [ { id: 'dataMenu', title: 'Data', items: [
{ id: 'titles', title: 'Manage Titles...', disabled: !pandora.site.capabilities.canManageTitlesAndNames[pandora.user.level] }, { id: 'titles', title: 'Manage Titles...', disabled: !pandora.site.capabilities.canManageTitlesAndNames[pandora.user.level] },
@ -257,12 +257,13 @@ pandora.ui.mainMenu = function() {
} }
}, },
click: function(data) { click: function(data) {
if ([].concat( if ([
['home', 'software'], 'home', 'software', 'signup', 'signin', 'signout',
'preferences', 'tv', 'help'
].concat(
pandora.site.sitePages.map(function(page) { pandora.site.sitePages.map(function(page) {
return page.id; return page.id;
}), })
['signup', 'signin', 'signout', 'preferences', 'tv', 'help']
).indexOf(data.id) > -1) { ).indexOf(data.id) > -1) {
pandora.UI.set({page: data.id}); pandora.UI.set({page: data.id});
} else if (data.id == 'upload') { } else if (data.id == 'upload') {
@ -292,9 +293,9 @@ pandora.ui.mainMenu = function() {
} else if (data.id == 'fullscreen') { } else if (data.id == 'fullscreen') {
pandora.$ui.player.options({fullscreen: true}); pandora.$ui.player.options({fullscreen: true});
} else if (data.id == 'advancedfind') { } else if (data.id == 'advancedfind') {
if (!pandora.hasDialogOrScreen()) {
pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
} } else if (data.id == 'findsimilar') {
pandora.$ui.sequencesDialog = pandora.ui.sequencesDialog().open();
} else if (data.id == 'titles') { } else if (data.id == 'titles') {
(pandora.$ui.titlesDialog || ( (pandora.$ui.titlesDialog || (
pandora.$ui.titlesDialog = pandora.ui.titlesDialog() pandora.$ui.titlesDialog = pandora.ui.titlesDialog()
@ -345,7 +346,9 @@ pandora.ui.mainMenu = function() {
} }
}, },
key_alt_control_f: function() { key_alt_control_f: function() {
// ... if (!pandora.hasDialogOrScreen() && pandora.getItemIdAndPosition()) {
pandora.$ui.sequencesDialog = pandora.ui.sequencesDialog().open();
}
}, },
key_backtick: function() { key_backtick: function() {
changeFocus(1); changeFocus(1);
@ -470,9 +473,17 @@ pandora.ui.mainMenu = function() {
that[action]('showtimeline'); that[action]('showtimeline');
that[action]('fullscreen'); that[action]('fullscreen');
} }
that[
pandora.getItemIdAndPosition() ? 'enableItem' : 'disableItem'
]('findsimilar');
}, },
pandora_listselection: function(data) { pandora_listselection: function(data) {
that[data.value.length ? 'enableItem' : 'disableItem']('newlistfromselection'); that[
data.value.length ? 'enableItem' : 'disableItem'
]('newlistfromselection');
that[
pandora.getItemIdAndPosition() ? 'enableItem' : 'disableItem'
]('findsimilar');
}, },
pandora_listsort: function(data) { pandora_listsort: function(data) {
that.checkItem('sortMenu_sortitems_' + data.value[0].key); that.checkItem('sortMenu_sortitems_' + data.value[0].key);
@ -485,6 +496,9 @@ pandora.ui.mainMenu = function() {
if (pandora.isClipView() != pandora.isClipView(data.previousValue)) { if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
that.replaceMenu('sortMenu', getSortMenu()); that.replaceMenu('sortMenu', getSortMenu());
} }
that[
pandora.getItemIdAndPosition() ? 'enableItem' : 'disableItem'
]('findsimilar');
}, },
pandora_showannotations: function(data) { pandora_showannotations: function(data) {
that.setItemTitle('showannotations', (data.value ? 'Hide' : 'Show') + ' Annotations'); that.setItemTitle('showannotations', (data.value ? 'Hide' : 'Show') + ' Annotations');

View file

@ -227,7 +227,6 @@ pandora.ui.navigationView = function(type, videoRatio) {
}); });
type == 'map' && pandora.UI.set({mapSelection: id ? $element.options('find') : ''}); type == 'map' && pandora.UI.set({mapSelection: id ? $element.options('find') : ''});
} }
Ox.Log('', 'MAP SELECTION', id, data)
} }
function updateStatusbar(items) { function updateStatusbar(items) {

View file

@ -2,9 +2,10 @@
'use strict'; 'use strict';
pandora.ui.sequencesDialog = function(id, position) { pandora.ui.sequencesDialog = function() {
var dialogHeight = Math.round((window.innerHeight - 48) * 0.9), var data = pandora.getItemIdAndPosition(),
dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
dialogWidth = Math.round(window.innerWidth * 0.9), dialogWidth = Math.round(window.innerWidth * 0.9),
mode = pandora.user.ui.sequenceMode, mode = pandora.user.ui.sequenceMode,
sidebarWidth = 144, sidebarWidth = 144,
@ -22,7 +23,7 @@ pandora.ui.sequencesDialog = function(id, position) {
], ],
orientation: 'horizontal' orientation: 'horizontal'
}); });
pandora.api.getSequence({id: id, mode: mode, position: position}, function(result) { pandora.api.getSequence({id: data.id, mode: mode, position: data.position}, function(result) {
// result.data: {hash, in, out} // result.data: {hash, in, out}
var fixedRatio = 16/9, var fixedRatio = 16/9,
hash = result.data.hash, hash = result.data.hash,

View file

@ -631,6 +631,48 @@ pandora.getItemFind = function(find) {
return itemFind; return itemFind;
}; };
pandora.getItemIdAndPosition = function() {
var selected, ret, ui = pandora.user.ui;
function getIdAndPositionByClipId(clipId) {
var fps = 25, split = clipId.replace('-', '/').split('/');
return {
id: split[0],
position: Math.ceil(parseFloat(split[1]) * fps) / fps
};
}
function getIdAndPositionByItemId(itemId) {
return {
id: itemId,
position: ui.videoPoints[itemId] ? ui.videoPoints[itemId].position : 0
};
}
if (!ui.item) {
if (
ui.listView == 'timelines'
&& (selected = ui.listSelection).length == 1
) {
ret = getIdAndPositionByItemId(selected[0]);
} else if (
['clip', 'map', 'calendar'].indexOf(ui.listView) > -1
&& pandora.$ui.clipList
&& (selected = pandora.$ui.clipList.options('selected')).length == 1
) {
ret = getIdAndPositionByClipId(selected[0]);
}
} else {
if (['player', 'editor', 'timeline'].indexOf(ui.itemView) > -1) {
ret = getIdAndPositionByItemId(ui.item);
} else if (
['clips', 'map', 'calendar'].indexOf(ui.itemView) > -1
&& pandora.$ui.clipList
&& (selected = pandora.$ui.clipList.options('selected')).length == 1
) {
ret = getIdAndPositionByClipId(selected[0]);
}
}
return ret;
}
pandora.getListData = function(list) { pandora.getListData = function(list) {
var data = {}, folder; var data = {}, folder;
list = Ox.isUndefined(list) ? pandora.user.ui._list : list; list = Ox.isUndefined(list) ? pandora.user.ui._list : list;