pandora/static/js/pandora/ui/viewSelect.js

47 lines
1.6 KiB
JavaScript
Raw Normal View History

2011-07-29 18:37:11 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-05-25 19:42:45 +00:00
pandora.ui.viewSelect = function() {
var sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
viewKey = !pandora.user.ui.item ? 'listView' : 'itemView',
that = Ox.Select({
2011-05-25 19:42:45 +00:00
id: 'viewSelect',
2011-09-28 17:32:03 +00:00
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), {
checked: view.id == pandora.user.ui[viewKey],
title: 'View ' + view.title
})
: null;
2011-05-25 19:42:45 +00:00
}),
2011-06-06 15:48:11 +00:00
width: !pandora.user.ui.item ? 144 : 128
2011-05-25 19:42:45 +00:00
})
.css({
float: 'left',
margin: '4px 0 0 4px'
})
.bindEvent({
change: function(data) {
var key = data.selected[0].id,
set = {};
set[viewKey] = key
if (
!pandora.isClipView(key, pandora.user.ui.item)
&& ['title', 'position'].indexOf(pandora.user.ui[sortKey][0].key) > -1
) {
set[sortKey] = pandora.site.user.ui.listSort;
}
pandora.UI.set(set);
},
pandora_listview: function(data) {
that.selectItem(data.value);
},
pandora_itemview: function(data) {
that.selectItem(data.value);
2011-05-25 19:42:45 +00:00
}
});
2011-05-25 19:42:45 +00:00
return that;
};