fix various menu and menu integration bugs

This commit is contained in:
rolux 2012-03-18 14:59:00 +00:00
parent 21fc25e7fd
commit 4ad4962d33
4 changed files with 58 additions and 32 deletions

View file

@ -40,10 +40,10 @@ pandora.ui.contentPanel = function() {
} }
}, },
pandora_itemview: function() { pandora_itemview: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); pandora.user.ui.item && that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
}, },
pandora_listview: function() { pandora_listview: function() {
that.replaceElement(1, pandora.$ui.list = pandora.ui.list()); !pandora.user.ui.item && that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
}, },
pandora_showbrowser: function(data) { pandora_showbrowser: function(data) {
data.value == that.options('elements')[0].collapsed && that.toggle(0); data.value == that.options('elements')[0].collapsed && that.toggle(0);

View file

@ -18,8 +18,6 @@ pandora.ui.findElement = function() {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
Ox.print(data);
//pandora.$ui.mainMenu.checkItem('findMenu_find_' + ...);
pandora.$ui.findInput.options({ pandora.$ui.findInput.options({
autocomplete: autocompleteFunction() autocomplete: autocompleteFunction()
}).focusInput(true); }).focusInput(true);
@ -50,8 +48,10 @@ pandora.ui.findElement = function() {
change: function(data) { change: function(data) {
if (data.value == 'advanced') { if (data.value == 'advanced') {
that.update(); that.update();
// fixme: uncheck menu item!
pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
} else { } else {
pandora.$ui.mainMenu.checkItem('findMenu_find_' + data.value);
pandora.$ui.findInput.options({ pandora.$ui.findInput.options({
autocomplete: autocompleteFunction(), autocomplete: autocompleteFunction(),
placeholder: '' placeholder: ''

View file

@ -53,8 +53,8 @@ pandora.ui.mainMenu = function() {
{ id: 'invertselection', title: 'Invert Selection', disabled: true, keyboard: 'alt control a' } { id: 'invertselection', title: 'Invert Selection', disabled: true, keyboard: 'alt control a' }
] }, ] },
{ id: 'viewMenu', title: 'View', items: [ { id: 'viewMenu', title: 'View', items: [
{ id: 'movies', title: 'View ' + pandora.site.itemName.plural, items: [ { id: 'items', title: 'View ' + pandora.site.itemName.plural, items: [
{ group: 'viewmovies', min: 1, max: 1, items: pandora.site.listViews.map(function(view) { { group: 'listview', min: 1, max: 1, items: pandora.site.listViews.map(function(view) {
return Ox.extend({ return Ox.extend({
checked: ui.listView == view.id, checked: ui.listView == view.id,
}, view); }, view);
@ -81,16 +81,16 @@ pandora.ui.mainMenu = function() {
{ id: 'resetcolumns', title: 'Reset Layout', disabled: true } { id: 'resetcolumns', title: 'Reset Layout', disabled: true }
] }, ] },
{}, {},
{ id: 'openmovie', title: ['Open ' + pandora.site.itemName.singular, 'Open ' + pandora.site.itemName.plural], items: [ { id: 'item', title: ['Open ' + pandora.site.itemName.singular, 'Open ' + pandora.site.itemName.plural], items: [
{ group: 'itemview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) { { group: 'itemview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) {
return Ox.extend({ return Ox.extend({
checked: ui.itemView == view.id, checked: ui.itemView == view.id,
}, view); }, view);
}) }, }) },
] }, ] },
{ id: 'openvideo', title: 'Open Video Links', items: [ { id: 'clips', title: 'Open Clips', items: [
{ group: 'videoview', min: 1, max: 1, items: ['player', 'editor'].map(function(view) { { group: 'videoview', min: 1, max: 1, items: ['video', 'timeline'].map(function(view) {
return {id: view, title: Ox.toTitleCase(view), checked: ui.videoView == view}; return {id: view, title: view == 'video' ? 'Player' : 'Editor', checked: ui.videoView == view};
}) } }) }
] }, ] },
{}, {},
@ -121,13 +121,15 @@ pandora.ui.mainMenu = function() {
getSortMenu(), getSortMenu(),
{ id: 'findMenu', title: 'Find', items: [ { id: 'findMenu', title: 'Find', items: [
{ id: 'find', title: 'Find', items: [ { id: 'find', title: 'Find', items: [
{ group: 'find', min: 1, max: 1, items: pandora.site.findKeys.map(function(key, i) { { group: 'find', min: 0, max: 1, items: pandora.site.findKeys.map(function(key, i) {
return Ox.extend({ return Ox.extend({
checked: key.id == findState.key checked: key.id == findState.key
}, key); }, key);
}) } }) }
] }, ] },
{ 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}
] }, ] },
{ id: 'dataMenu', title: 'Data', items: [ { id: 'dataMenu', title: 'Data', items: [
{ id: 'titles', title: 'Manage Titles...', disabled: !isAdmin }, { id: 'titles', title: 'Manage Titles...', disabled: !isAdmin },
@ -171,9 +173,22 @@ pandora.ui.mainMenu = function() {
that.checkItem('allitems'); that.checkItem('allitems');
} }
} else if (data.id == 'find') { } else if (data.id == 'find') {
pandora.$ui.findSelect.value(value); if (value) {
pandora.$ui.findSelect.value(value);
} else {
that.checkItem('findMenu_find_' + pandora.$ui.findSelect.value());
}
} else if (data.id == 'itemview') { } else if (data.id == 'itemview') {
pandora.UI.set({itemView: value}); pandora.UI.set({itemView: value});
} else if (data.id == 'listview') {
var set = {listView: value};
if (
!pandora.isClipView(key, pandora.user.ui.item)
&& ['title', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1
) {
set.listSort = pandora.site.user.ui.listSort;
}
pandora.UI.set(set);
} else if (Ox.startsWith(data.id, 'orderfilter')) { } else if (Ox.startsWith(data.id, 'orderfilter')) {
var filters = Ox.clone(pandora.user.ui.filters), var filters = Ox.clone(pandora.user.ui.filters),
id = data.id.replace('orderfilter', ''), id = data.id.replace('orderfilter', ''),
@ -185,10 +200,12 @@ pandora.ui.mainMenu = function() {
}); });
filters[index].sort[0].operator = operator; filters[index].sort[0].operator = operator;
pandora.UI.set({filters: filters}); pandora.UI.set({filters: filters});
} else if (data.id == 'ordermovies') { } else if (data.id == 'listorder') {
var key = pandora.user.ui.listSort[0].key, var key = pandora.user.ui.listSort[0].key,
operator = value == 'ascending' ? '+' : '-'; operator = value == 'ascending' ? '+' : '-';
pandora.UI.set({listSort: [{key: key, operator: operator}]}); pandora.UI.set({listSort: [{key: key, operator: operator}]});
} else if (data.id == 'listsort') {
pandora.UI.set({listSort: [{key: value, operator: ''}]});
} else if (data.id == 'settheme') { } else if (data.id == 'settheme') {
Ox.Theme(value); Ox.Theme(value);
pandora.UI.set('theme', value); pandora.UI.set('theme', value);
@ -210,19 +227,18 @@ pandora.ui.mainMenu = function() {
}); });
filters[index].sort[0].key = key; filters[index].sort[0].key = key;
pandora.UI.set({filters: filters}); pandora.UI.set({filters: filters});
} else if (data.id == 'sortmovies') { } else if (data.id == 'videoview') {
pandora.UI.set({listSort: [{key: value, operator: ''}]}); var set = {videoView: value};
if (
value == 'video' && ui.itemView == 'timeline'
|| value == 'timeline' && ui.itemView == 'video'
) {
set.itemView = value;
}
Ox.print('SET', set)
pandora.UI.set(set);
} else if (data.id == 'viewicons') { } else if (data.id == 'viewicons') {
pandora.UI.set({icons: value}); pandora.UI.set({icons: value});
} else if (data.id == 'viewmovies') {
var set = {listView: value};
if (
!pandora.isClipView(key, pandora.user.ui.item)
&& ['title', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1
) {
set.listSort = pandora.site.user.ui.listSort;
}
pandora.UI.set(set);
} else if (data.id.substr(0, 8) == 'viewlist') { } else if (data.id.substr(0, 8) == 'viewlist') {
pandora.UI.set({ pandora.UI.set({
find: { find: {
@ -415,6 +431,10 @@ pandora.ui.mainMenu = function() {
pandora_itemview: function(data) { pandora_itemview: function(data) {
var isVideoView = ['video', 'timeline'].indexOf(data.value) > -1, var isVideoView = ['video', 'timeline'].indexOf(data.value) > -1,
wasVideoView = ['video', 'timeline'].indexOf(data.previousValue) > -1; wasVideoView = ['video', 'timeline'].indexOf(data.previousValue) > -1;
that.checkItem('viewMenu_item_' + data.value);
if (isVideoView) {
that.checkItem('viewMenu_clips_' + data.value);
}
if (isVideoView != wasVideoView) { if (isVideoView != wasVideoView) {
that[isVideoView ? 'enableItem' : 'disableItem']('showannotations'); that[isVideoView ? 'enableItem' : 'disableItem']('showannotations');
} }
@ -425,8 +445,14 @@ pandora.ui.mainMenu = function() {
pandora_listselection: function(data) { pandora_listselection: function(data) {
that[data.value.length ? 'enableItem' : 'disableItem']('newlistfromselection'); that[data.value.length ? 'enableItem' : 'disableItem']('newlistfromselection');
}, },
pandora_listsort: function(data) {
that.checkItem('sortMenu_sortitems_' + data.value[0].key);
that.checkItem('sortMenu_orderitems_' + (
data.value[0].operator == '+' ? 'ascending' : 'descending')
);
},
pandora_listview: function(data) { pandora_listview: function(data) {
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + data.value); that.checkItem('viewMenu_items_' + data.value);
if (pandora.isClipView() != pandora.isClipView(data.previousValue)) { if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
that.replaceMenu('sortMenu', getSortMenu()); that.replaceMenu('sortMenu', getSortMenu());
} }
@ -494,8 +520,8 @@ pandora.ui.mainMenu = function() {
var ui = pandora.user.ui, var ui = pandora.user.ui,
isClipView = pandora.isClipView(ui.listView); isClipView = pandora.isClipView(ui.listView);
return { id: 'sortMenu', title: 'Sort', items: [ return { id: 'sortMenu', title: 'Sort', items: [
{ id: 'sortmovies', title: 'Sort ' + (isClipView || ui.item ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [ { id: 'sortitems', title: 'Sort ' + (isClipView || ui.item ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
{ group: 'sortmovies', min: 1, max: 1, items: Ox.merge( { group: 'listsort', min: 1, max: 1, items: Ox.merge(
isClipView ? pandora.site.clipKeys.map(function(key) { isClipView ? pandora.site.clipKeys.map(function(key) {
return Ox.extend(Ox.clone(key), { return Ox.extend(Ox.clone(key), {
checked: ui.listSort[0].key == key.id, checked: ui.listSort[0].key == key.id,
@ -509,8 +535,8 @@ pandora.ui.mainMenu = function() {
}) : [] }) : []
) } ) }
] }, ] },
{ id: 'ordermovies', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [ { id: 'orderitems', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [
{ group: 'ordermovies', min: 1, max: 1, items: [ { group: 'listorder', min: 1, max: 1, items: [
{ id: 'ascending', title: 'Ascending', checked: (ui.listSort[0].operator || pandora.getSortOperator(ui.listSort[0].key)) == '+' }, { id: 'ascending', title: 'Ascending', checked: (ui.listSort[0].operator || pandora.getSortOperator(ui.listSort[0].key)) == '+' },
{ id: 'descending', title: 'Descending', checked: (ui.listSort[0].operator || pandora.getSortOperator(ui.listSort[0].key)) == '-' } { id: 'descending', title: 'Descending', checked: (ui.listSort[0].operator || pandora.getSortOperator(ui.listSort[0].key)) == '-' }
]} ]}

View file

@ -29,10 +29,10 @@ pandora.ui.viewSelect = function() {
pandora.UI.set(viewKey, data.value); pandora.UI.set(viewKey, data.value);
}, },
pandora_listview: function(data) { pandora_listview: function(data) {
that.value(data.value); !ui.item && that.value(data.value);
}, },
pandora_itemview: function(data) { pandora_itemview: function(data) {
that.value(data.value); ui.item && that.value(data.value);
} }
}); });
return that; return that;