pandora/static/js/pandora/viewSelect.js
2011-12-22 07:27:48 +00:00

40 lines
1.3 KiB
JavaScript

// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
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) {
that.value(data.value);
},
pandora_itemview: function(data) {
that.value(data.value);
}
});
return that;
};