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',
|
2011-09-23 10:44:54 +00:00
|
|
|
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), {
|
2011-10-13 10:39:22 +00:00
|
|
|
checked: view.id == ui[viewKey],
|
2011-09-28 17:32:03 +00:00
|
|
|
title: 'View ' + view.title
|
|
|
|
})
|
|
|
|
: null;
|
2011-05-25 19:42:45 +00:00
|
|
|
}),
|
2011-10-13 10:39:22 +00:00
|
|
|
width: !ui.item ? 144 : 128
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
margin: '4px 0 0 4px'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-09-23 10:44:54 +00:00
|
|
|
change: function(data) {
|
2011-11-07 21:04:44 +00:00
|
|
|
pandora.UI.set(viewKey, data.selected[0].id);
|
2011-09-27 23:30:13 +00:00
|
|
|
},
|
|
|
|
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-10-29 17:46:46 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|