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(
|
2013-03-01 06:08:51 +00:00
|
|
|
pandora.$ui.sortElement = pandora.ui.sortElement()
|
2011-10-30 16:49:29 +00:00
|
|
|
);
|
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
|
|
|
})
|
2013-07-19 09:34:01 +00:00
|
|
|
.addClass('OxSelectable')
|
2012-03-20 10:13:06 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: getListTitleLeft() + 'px',
|
|
|
|
top: '4px',
|
2014-01-19 09:54:02 +00:00
|
|
|
right: (ui._list ? 340 : 326) + 'px',
|
2013-07-19 09:34:01 +00:00
|
|
|
width: 'auto'
|
2012-03-20 10:13:06 +00:00
|
|
|
})
|
|
|
|
: pandora.$ui.itemTitle = Ox.Label({
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
2013-07-19 09:34:01 +00:00
|
|
|
.addClass('OxSelectable')
|
2012-03-20 10:13:06 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '236px',
|
|
|
|
top: '4px',
|
2014-01-19 09:54:02 +00:00
|
|
|
right: (ui._list ? 340 : 326) + 'px',
|
2013-07-19 09:34:01 +00:00
|
|
|
width: 'auto'
|
2012-03-20 10:13:06 +00:00
|
|
|
})
|
|
|
|
.hide()
|
2011-10-30 21:05:57 +00:00
|
|
|
);
|
2013-07-08 11:30:33 +00:00
|
|
|
(!ui.item ? pandora.$ui.listTitle : pandora.$ui.itemTitle).bindEvent({
|
|
|
|
doubleclick: function() {
|
|
|
|
if (!ui.item) {
|
|
|
|
pandora.$ui.list && pandora.$ui.list.animate({scrollTop: 0}, 250);
|
|
|
|
} else {
|
|
|
|
pandora.$ui.browser.scrollToSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
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) {
|
2013-03-01 06:08:51 +00:00
|
|
|
pandora.$ui.sortElement.remove();
|
2012-03-20 09:45:40 +00:00
|
|
|
} else {
|
2013-03-01 06:08:51 +00:00
|
|
|
pandora.$ui.sortElement = pandora.ui.sortElement().insertAfter(pandora.$ui.viewSelect);
|
2012-03-20 09:45:40 +00:00
|
|
|
}
|
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')) {
|
2013-03-01 06:08:51 +00:00
|
|
|
pandora.$ui.sortElement.replaceWith(
|
|
|
|
pandora.$ui.sortElement = pandora.ui.sortElement()
|
2012-03-20 09:45:40 +00:00
|
|
|
);
|
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 == ''
|
2014-02-13 16:24:52 +00:00
|
|
|
? Ox._('All {0}', [Ox._(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() {
|
2013-03-01 07:27:34 +00:00
|
|
|
return ['map', 'calendar'].indexOf(pandora.user.ui.listView) > -1 ? 152 : 316;
|
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;
|
|
|
|
};
|
|
|
|
|