From 5cee28bef1290cddcd1760a1c659f440c480ab6f Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 24 Apr 2012 12:13:14 +0000 Subject: [PATCH] in viewSelect, add separator between standard and extra item views --- static/js/pandora/viewSelect.js | 66 ++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/static/js/pandora/viewSelect.js b/static/js/pandora/viewSelect.js index 2e2b2c06..fdc01df2 100644 --- a/static/js/pandora/viewSelect.js +++ b/static/js/pandora/viewSelect.js @@ -6,35 +6,43 @@ pandora.ui.viewSelect = function() { var ui = pandora.user.ui, sortKey = !ui.item ? 'listSort' : 'itemSort', viewKey = !ui.item ? 'listView' : 'itemView', - that = Ox.Select({ - id: 'viewSelect', - items: Ox.map(pandora.site[viewKey + 's'], function(view) { - return viewKey == 'listView' - || ['data', 'files'].indexOf(view.id) == -1 - || pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level] - ? Ox.extend(Ox.clone(view), { - title: 'View ' + view.title - }) - : null; - }), - value: ui[viewKey], - width: !ui.item ? 144 : 128 - }) - .css({ - float: 'left', - margin: '4px 0 0 4px' - }) - .bindEvent({ - change: function(data) { - pandora.UI.set(viewKey, data.value); - }, - pandora_listview: function(data) { - !ui.item && that.value(data.value); - }, - pandora_itemview: function(data) { - ui.item && that.value(data.value); - } - }); + items = Ox.map(pandora.site[viewKey + 's'], function(view) { + return ['data', 'files'].indexOf(view.id) == -1 + ? {id: view.id, title: 'View ' + view.title} + : null; + }), + that; + if ( + viewKey == 'itemView' + && pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level] + ) { + Ox.merge(items, [ + {}, + {id: 'data', title: 'View Data'}, + {id: 'files', title: 'View Files'} + ]); + } + that = Ox.Select({ + id: 'viewSelect', + items: items, + value: ui[viewKey], + width: !ui.item ? 144 : 128 + }) + .css({ + float: 'left', + margin: '4px 0 0 4px' + }) + .bindEvent({ + change: function(data) { + pandora.UI.set(viewKey, data.value); + }, + pandora_listview: function(data) { + !ui.item && that.value(data.value); + }, + pandora_itemview: function(data) { + ui.item && that.value(data.value); + } + }); return that; };