diff --git a/static/js/pandora/menu.js b/static/js/pandora/menu.js index 77d314bd1..867c17d0d 100644 --- a/static/js/pandora/menu.js +++ b/static/js/pandora/menu.js @@ -520,21 +520,25 @@ pandora.ui.mainMenu = function() { function getSortMenu() { var ui = pandora.user.ui, - isClipView = pandora.isClipView(ui.listView); + isClipView = pandora.isClipView(ui.listView), + items = isClipView ? pandora.site.clipKeys.map(function(key) { + return Ox.extend(Ox.clone(key), { + checked: ui.listSort[0].key == key.id, + title: 'Clip ' + key.title + }); + }) : []; return { id: 'sortMenu', title: 'Sort', items: [ { id: 'sortitems', title: 'Sort ' + (isClipView || ui.item ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [ { group: 'listsort', min: 1, max: 1, items: Ox.merge( - isClipView ? pandora.site.clipKeys.map(function(key) { - return Ox.extend(Ox.clone(key), { - checked: ui.listSort[0].key == key.id, - title: 'Clip ' + key.title - }); - }) : [], - !ui.item ? pandora.site.sortKeys.map(function(key) { - return Ox.extend({ + items, + Ox.map(pandora.site.sortKeys, function(key) { + return Ox.getIndexById(items, key.id) == -1 && ( + !key.capability + || pandora.site.capabilities[key.capability][pandora.user.level] + ) ? Ox.extend({ checked: ui.listSort[0].key == key.id - }, key); - }) : [] + }, key) : null; + }) ) } ] }, { id: 'orderitems', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [ diff --git a/static/js/pandora/sortSelect.js b/static/js/pandora/sortSelect.js index f44c6aee7..e3e30dffa 100644 --- a/static/js/pandora/sortSelect.js +++ b/static/js/pandora/sortSelect.js @@ -4,26 +4,26 @@ pandora.ui.sortSelect = function(isNavigationView) { var isClipView = pandora.isClipView(), - items = [], - sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort', - that; - if (isClipView) { - items = pandora.site.clipKeys.map(function(key) { + items = isClipView ? pandora.site.clipKeys.map(function(key) { return Ox.extend(Ox.clone(key), { title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title }); - }); + }) : [], // fixme: a separator would be good - // !pandora.user.ui.item && items.push({}); - } + sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort', + that; if (!pandora.user.ui.item) { - items = Ox.merge(items, Ox.map(pandora.site.sortKeys, function(key) { - return Ox.getIndexById(items, key.id) == -1 - ? Ox.extend(Ox.clone(key), { + items = Ox.merge( + items, + Ox.map(pandora.site.sortKeys, function(key) { + return Ox.getIndexById(items, key.id) == -1 && ( + !key.capability + || pandora.site.capabilities[key.capability][pandora.user.level] + ) ? Ox.extend(Ox.clone(key), { title: 'Sort by ' + key.title - }) - : null; - })); + }) : null; + }) + ); } that = Ox.Select({ id: 'sortSelect', diff --git a/static/js/pandora/status.js b/static/js/pandora/status.js deleted file mode 100644 index f79e5aa12..000000000 --- a/static/js/pandora/status.js +++ /dev/null @@ -1,25 +0,0 @@ -// vim: et:ts=4:sw=4:sts=4:ft=javascript -'use strict'; -pandora.ui.status = function(key, data) { - var itemName = data.items != 1 ? pandora.site.itemName.plural : pandora.site.itemName.singular, - segments = [], - that = Ox.toTitleCase(key) + ': '; - if (!pandora.user.ui.item && pandora.user.ui.listView == 'clip') { - itemName = data.items != 1 ? 'Clips' : 'Clip'; - } - segments.push(Ox.formatNumber(data.items) + ' '+ itemName); - if (data.runtime) - segments.push(Ox.formatDuration(data.runtime, 'short')); - if (data.files) - segments.push(data.files + ' file' + (data.files != 1 ? 's' : '')); - if (!data.runtime && data.duration) - segments.push(Ox.formatDuration(data.duration, 'short')); - else if (data.duration) - segments.push(Ox.formatDuration(data.duration)); - if (data.size) - segments.push(Ox.formatValue(data.size, 'B')); - if (data.pixels) - segments.push(Ox.formatValue(data.pixels, 'px')); - return that + segments.join(', '); -}; - diff --git a/static/js/pandora/statusbar.js b/static/js/pandora/statusbar.js index 679fc889a..d7f1bdc06 100644 --- a/static/js/pandora/statusbar.js +++ b/static/js/pandora/statusbar.js @@ -36,18 +36,17 @@ pandora.ui.statusbar = function() { : (pandora.site.itemName[data.items == 1 ? 'singular' : 'plural']), parts = []; parts.push(Ox.formatNumber(data.items) + ' '+ itemName); - if (data.runtime) + if (data.runtime) { parts.push(Ox.formatDuration(data.runtime, 'short')); - if (data.files) - parts.push(data.files + ' file' + (data.files == 1 ? '' : 's')); - if (!data.runtime && data.duration) + } else if (data.duration) { parts.push(Ox.formatDuration(data.duration, 'short')); - else if (data.duration) - parts.push(Ox.formatDuration(data.duration)); - if (data.size) - parts.push(Ox.formatValue(data.size, 'B')); - if (data.pixels) - parts.push(Ox.formatValue(data.pixels, 'px')); + } + if (pandora.site.capabilities.canSeeFiles[pandora.user.level]) { + data.files && parts.push(data.files + ' file' + (data.files == 1 ? '' : 's')); + data.duration && parts.push(Ox.formatDuration(data.duration)); + data.size && parts.push(Ox.formatValue(data.size, 'B')); + data.pixels && parts.push(Ox.formatValue(data.pixels, 'px')); + } return parts.join(', '); }