2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-10-31 13:20:42 +00:00
|
|
|
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-10-31 13:20:42 +00:00
|
|
|
pandora.ui.sortSelect = function(isNavigationView) {
|
2011-10-09 12:46:35 +00:00
|
|
|
var isClipView = pandora.isClipView(),
|
2012-03-21 09:22:31 +00:00
|
|
|
items = isClipView ? pandora.site.clipKeys.map(function(key) {
|
2011-09-17 20:47:50 +00:00
|
|
|
return Ox.extend(Ox.clone(key), {
|
2011-09-23 10:44:54 +00:00
|
|
|
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
|
2011-09-17 20:47:50 +00:00
|
|
|
});
|
2012-03-21 09:22:31 +00:00
|
|
|
}) : [],
|
2011-10-09 12:46:35 +00:00
|
|
|
// fixme: a separator would be good
|
2012-03-21 09:22:31 +00:00
|
|
|
sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
|
|
|
|
that;
|
2011-09-23 10:44:54 +00:00
|
|
|
if (!pandora.user.ui.item) {
|
2012-05-24 08:22:56 +00:00
|
|
|
items = [].concat(
|
2012-03-21 09:22:31 +00:00
|
|
|
items,
|
2012-06-30 20:04:18 +00:00
|
|
|
pandora.site.sortKeys.map(function(key) {
|
2012-05-22 15:07:34 +00:00
|
|
|
return Ox.extend(Ox.clone(key), {
|
2011-10-09 12:46:35 +00:00
|
|
|
title: 'Sort by ' + key.title
|
2012-05-22 15:07:34 +00:00
|
|
|
});
|
2012-03-21 09:22:31 +00:00
|
|
|
})
|
|
|
|
);
|
2011-09-17 20:47:50 +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;
|
|
|
|
};
|
|
|
|
|