pandora/static/js/pandora/sortSelect.js

53 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-11-05 17:04:10 +00:00
'use strict';
pandora.ui.sortSelect = function(isNavigationView) {
var isClipView = pandora.isClipView(),
items = isClipView ? pandora.site.clipKeys.map(function(key) {
return Ox.extend(Ox.clone(key), {
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
});
}) : [],
// fixme: a separator would be good
sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
that;
if (!pandora.user.ui.item) {
2012-05-24 08:22:56 +00:00
items = [].concat(
items,
pandora.site.sortKeys.map(function(key) {
2012-05-22 15:07:34 +00:00
return Ox.extend(Ox.clone(key), {
title: 'Sort by ' + key.title
2012-05-22 15:07:34 +00:00
});
})
);
}
that = Ox.Select({
2011-12-21 15:34:28 +00:00
id: 'sortSelect',
items: items,
2011-12-22 07:27:48 +00:00
value: pandora.user.ui[sortKey][0].key,
2011-12-21 15:34:28 +00:00
width: isNavigationView ? 128 : 144
})
.css({
float: isNavigationView ? 'right' : 'left',
margin: isNavigationView ? '4px 4px 0 0' : '4px 0 0 4px'
})
.bindEvent({
change: function(data) {
var key = data.value;
pandora.UI.set(sortKey, [{
key: key,
operator: pandora.getSortOperator(key)
}]);
},
pandora_listsort: function(data) {
2011-12-22 07:27:48 +00:00
that.value(data.value[0].key);
2011-12-21 15:34:28 +00:00
},
pandora_itemsort: function(data) {
2011-12-22 07:27:48 +00:00
that.value(data.value[0].key);
2011-12-21 15:34:28 +00:00
}
});
2011-05-25 19:42:45 +00:00
return that;
};