2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.viewSelect = function() {
|
2011-10-13 10:39:22 +00:00
|
|
|
var ui = pandora.user.ui,
|
|
|
|
sortKey = !ui.item ? 'listSort' : 'itemSort',
|
|
|
|
viewKey = !ui.item ? 'listView' : 'itemView',
|
2012-05-22 15:07:34 +00:00
|
|
|
items = pandora.site[viewKey + 's'].filter(function(view) {
|
2013-05-27 10:13:59 +00:00
|
|
|
return view.id != 'data' && view.id != 'media';
|
2012-05-22 15:07:34 +00:00
|
|
|
}).map(function(view) {
|
2013-05-09 10:13:58 +00:00
|
|
|
return {id: view.id, title: Ox._('View {0}', [Ox._(view.title)])};
|
2012-04-24 12:13:14 +00:00
|
|
|
}),
|
|
|
|
that;
|
|
|
|
if (
|
|
|
|
viewKey == 'itemView'
|
|
|
|
&& pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level]
|
|
|
|
) {
|
2012-05-24 08:22:56 +00:00
|
|
|
items = items.concat([
|
2012-04-24 12:13:14 +00:00
|
|
|
{},
|
2013-05-09 10:13:58 +00:00
|
|
|
{id: 'data', title: Ox._('View Data')},
|
2013-05-27 10:13:59 +00:00
|
|
|
{id: 'media', title: Ox._('View Media')}
|
2012-04-24 12:13:14 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|