2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-08-17 13:23:17 +00:00
|
|
|
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.toolbar = function() {
|
2011-10-01 13:51:18 +00:00
|
|
|
var ui = pandora.user.ui,
|
2011-10-31 13:20:42 +00:00
|
|
|
isNavigationView = !ui.item
|
|
|
|
&& ['map', 'calendar'].indexOf(ui.listView) > -1,
|
2011-10-01 13:51:18 +00:00
|
|
|
that = Ox.Bar({
|
2011-05-25 19:42:45 +00:00
|
|
|
size: 24
|
|
|
|
}).css({
|
|
|
|
zIndex: 2 // fixme: remove later
|
|
|
|
});
|
2011-10-01 13:51:18 +00:00
|
|
|
ui.item && that.append(
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.backButton = pandora.ui.backButton()
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
|
|
|
that.append(
|
2011-10-29 17:46:46 +00:00
|
|
|
pandora.$ui.viewSelect = pandora.ui.viewSelect()
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
2011-10-31 14:22:28 +00:00
|
|
|
!ui.item && !isNavigationView && that.append(
|
2011-10-30 16:49:29 +00:00
|
|
|
pandora.$ui.sortSelect = pandora.ui.sortSelect()
|
|
|
|
).append(
|
|
|
|
pandora.$ui.orderButton = pandora.ui.orderButton()
|
|
|
|
);
|
2012-03-20 10:13:06 +00:00
|
|
|
that.append(
|
|
|
|
!ui.item
|
|
|
|
? pandora.$ui.listTitle = Ox.Label({
|
|
|
|
textAlign: 'center',
|
2012-04-19 08:29:38 +00:00
|
|
|
title: getListName(pandora.user.ui._list)
|
2012-03-20 10:13:06 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: getListTitleLeft() + 'px',
|
|
|
|
top: '4px',
|
|
|
|
right: (ui._list ? 324 : 310) + 'px',
|
|
|
|
width: 'auto'
|
|
|
|
})
|
|
|
|
: pandora.$ui.itemTitle = Ox.Label({
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '236px',
|
|
|
|
top: '4px',
|
|
|
|
right: (ui._list ? 324 : 310) + 'px',
|
|
|
|
width: 'auto'
|
|
|
|
})
|
|
|
|
.hide()
|
2011-10-30 21:05:57 +00:00
|
|
|
);
|
2011-05-25 19:42:45 +00:00
|
|
|
that.append(
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.findElement = pandora.ui.findElement()
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
2011-09-27 23:30:13 +00:00
|
|
|
that.bindEvent({
|
|
|
|
pandora_listview: function(data) {
|
2012-03-20 09:45:40 +00:00
|
|
|
var isNavigationView, wasNavigationView;
|
|
|
|
if (!pandora.user.ui.item) {
|
|
|
|
isNavigationView = ['map', 'calendar'].indexOf(data.value) > -1;
|
|
|
|
wasNavigationView = ['map', 'calendar'].indexOf(data.previousValue) > -1;
|
|
|
|
if (isNavigationView != wasNavigationView) {
|
|
|
|
if (isNavigationView) {
|
|
|
|
pandora.$ui.sortSelect.remove();
|
|
|
|
pandora.$ui.orderButton.remove();
|
|
|
|
} else {
|
|
|
|
pandora.$ui.sortSelect = pandora.ui.sortSelect().insertAfter(pandora.$ui.viewSelect);
|
|
|
|
pandora.$ui.orderButton = pandora.ui.orderButton().insertAfter(pandora.$ui.sortSelect);
|
|
|
|
}
|
2012-03-20 10:13:06 +00:00
|
|
|
pandora.$ui.listTitle.css({left: getListTitleLeft() + 'px'});
|
2012-03-20 09:45:40 +00:00
|
|
|
} else if ((data.value == 'clip') != (data.previousValue == 'clip')) {
|
|
|
|
pandora.$ui.sortSelect.replaceWith(
|
|
|
|
pandora.$ui.sortSelect = pandora.ui.sortSelect()
|
|
|
|
);
|
2011-10-31 14:22:28 +00:00
|
|
|
}
|
2011-09-27 22:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-20 10:13:06 +00:00
|
|
|
});
|
2012-04-19 08:29:38 +00:00
|
|
|
function getListName(listId) {
|
|
|
|
return '<b>' + (
|
|
|
|
listId == ''
|
|
|
|
? 'All ' + pandora.site.itemName.plural
|
2012-05-24 09:56:52 +00:00
|
|
|
: Ox.encodeHTMLEntities(listId.slice(listId.indexOf(':') + 1))
|
2012-04-19 08:29:38 +00:00
|
|
|
) + '</b>';
|
2012-03-20 10:13:06 +00:00
|
|
|
}
|
|
|
|
function getListTitleLeft() {
|
2012-03-20 19:16:16 +00:00
|
|
|
return 320 - (
|
2012-03-20 19:17:53 +00:00
|
|
|
['map', 'calendar'].indexOf(pandora.user.ui.listView) > -1 ? 168 : 0
|
2012-03-20 10:13:06 +00:00
|
|
|
);
|
|
|
|
}
|
2012-04-19 08:29:38 +00:00
|
|
|
that.updateListName = function(listId) {
|
|
|
|
pandora.$ui.listTitle.options({title: getListName(listId)});
|
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|