forked from 0x2620/pandora
update sortElement, remove sortSelect and orderButton
This commit is contained in:
parent
0ca5432408
commit
c62df3ae10
4 changed files with 7 additions and 107 deletions
|
@ -1,40 +0,0 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
'use strict';
|
||||
pandora.ui.orderButton = function(isNavigationView) {
|
||||
var sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
|
||||
that = Ox.Button({
|
||||
id: 'orderButton',
|
||||
title: getTitle(),
|
||||
tooltip: getTooltip(),
|
||||
// tooltip: 'Change sort order',
|
||||
type: 'image'
|
||||
})
|
||||
.css({
|
||||
float: isNavigationView ? 'right' : 'left',
|
||||
margin: isNavigationView ? '4px 4px 0 0' : '4px 0 0 4px'
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
pandora.UI.set(sortKey, [{
|
||||
key: pandora.user.ui[sortKey][0].key,
|
||||
operator: pandora.user.ui[sortKey][0].operator == '+' ? '-' : '+'
|
||||
}]);
|
||||
updateButton();
|
||||
},
|
||||
pandora_listsort: updateButton,
|
||||
pandora_itemsort: updateButton
|
||||
});
|
||||
function getTitle() {
|
||||
return pandora.user.ui[sortKey][0].operator == '+' ? 'up' : 'down';
|
||||
}
|
||||
function getTooltip() {
|
||||
return pandora.user.ui[sortKey][0].operator == '+' ? 'Ascending' : 'Descending';
|
||||
}
|
||||
function updateButton() {
|
||||
that.options({
|
||||
title: getTitle(),
|
||||
tooltip: getTooltip()
|
||||
});
|
||||
}
|
||||
return that;
|
||||
}
|
|
@ -32,9 +32,7 @@ pandora.ui.sortElement = function(isNavigationView) {
|
|||
key: key,
|
||||
operator: pandora.getSortOperator(key)
|
||||
}]);
|
||||
},
|
||||
pandora_listsort: updateSelect,
|
||||
pandora_itemsort: updateSelect
|
||||
}
|
||||
}),
|
||||
|
||||
$orderButton = Ox.Button({
|
||||
|
@ -50,9 +48,7 @@ pandora.ui.sortElement = function(isNavigationView) {
|
|||
operator: pandora.user.ui[sortKey][0].operator == '+' ? '-' : '+'
|
||||
}]);
|
||||
updateButton();
|
||||
},
|
||||
pandora_listsort: updateButton,
|
||||
pandora_itemsort: updateButton
|
||||
}
|
||||
}),
|
||||
|
||||
that = Ox.FormElementGroup({
|
||||
|
@ -62,7 +58,8 @@ pandora.ui.sortElement = function(isNavigationView) {
|
|||
.css({
|
||||
float: isNavigationView ? 'right' : 'left',
|
||||
margin: isNavigationView ? '4px 4px 0 0' : '4px 0 0 4px'
|
||||
});
|
||||
})
|
||||
.bindEvent('pandora_' + sortKey.toLowerCase(), updateElement);
|
||||
|
||||
function getButtonTitle() {
|
||||
return pandora.user.ui[sortKey][0].operator == '+' ? 'up' : 'down';
|
||||
|
@ -72,17 +69,14 @@ pandora.ui.sortElement = function(isNavigationView) {
|
|||
return pandora.user.ui[sortKey][0].operator == '+' ? 'Ascending' : 'Descending';
|
||||
}
|
||||
|
||||
function updateButton() {
|
||||
function updateElement() {
|
||||
$sortSelect.value(pandora.user.ui[sortKey][0].key);
|
||||
$orderButton.options({
|
||||
title: getButtonTitle(),
|
||||
tooltip: getButtonTooltip()
|
||||
});
|
||||
}
|
||||
|
||||
function updateSelect(data) {
|
||||
$sortSelect.value(data.value[0].key);
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
|
@ -1,52 +0,0 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
|
||||
'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) {
|
||||
items = [].concat(
|
||||
items,
|
||||
pandora.site.sortKeys.map(function(key) {
|
||||
return Ox.extend(Ox.clone(key), {
|
||||
title: 'Sort by ' + key.title
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
that = Ox.Select({
|
||||
id: 'sortSelect',
|
||||
items: items,
|
||||
value: pandora.user.ui[sortKey][0].key,
|
||||
width: isNavigationView ? 116 + Ox.UI.SCROLLBAR_SIZE : 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) {
|
||||
that.value(data.value[0].key);
|
||||
},
|
||||
pandora_itemsort: function(data) {
|
||||
that.value(data.value[0].key);
|
||||
}
|
||||
});
|
||||
return that;
|
||||
};
|
||||
|
|
@ -77,9 +77,7 @@ pandora.ui.toolbar = function() {
|
|||
) + '</b>';
|
||||
}
|
||||
function getListTitleLeft() {
|
||||
return 316 - (
|
||||
['map', 'calendar'].indexOf(pandora.user.ui.listView) > -1 ? 180 : 0
|
||||
);
|
||||
return ['map', 'calendar'].indexOf(pandora.user.ui.listView) > -1 ? 152 : 316;
|
||||
}
|
||||
that.updateListName = function(listId) {
|
||||
pandora.$ui.listTitle.options({title: getListName(listId)});
|
||||
|
|
Loading…
Reference in a new issue