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

39 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() {
2011-06-19 17:49:25 +00:00
var that = Ox.Select({
2011-05-25 19:42:45 +00:00
id: 'viewSelect',
2011-06-06 18:40:24 +00:00
items: !pandora.user.ui.item ? pandora.site.listViews.map(function(view) {
2011-05-25 19:42:45 +00:00
return $.extend($.extend({}, view), {
2011-06-06 15:48:11 +00:00
checked: pandora.user.ui.lists[pandora.user.ui.list].listView == view.id,
2011-05-25 19:42:45 +00:00
title: 'View ' + view.title
});
}) : pandora.site.itemViews.map(function(view) {
2011-05-25 19:42:45 +00:00
return $.extend($.extend({}, view), {
2011-06-06 15:48:11 +00:00
checked: pandora.user.ui.itemView == view.id,
2011-05-25 19:42:45 +00:00
title: 'View: ' + view.title
});
}),
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({
2011-06-06 15:48:11 +00:00
change: !pandora.user.ui.item ? function(event, data) {
2011-05-25 19:42:45 +00:00
var id = data.selected[0].id;
2011-06-06 15:48:11 +00:00
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + id);
pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), id);
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
pandora.URL.push(pandora.Query.toString());
2011-05-25 19:42:45 +00:00
} : function(event, data) {
var id = data.selected[0].id;
//pandora.UI.set({itemView: id});
2011-06-06 15:48:11 +00:00
pandora.URL.set(pandora.user.ui.item + '/' + id);
// pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = pandora.ui.item());
2011-05-25 19:42:45 +00:00
}
});
return that;
};