pandora/static/js/toolbar.js

103 lines
3.5 KiB
JavaScript
Raw Normal View History

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,
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
);
!ui.item && !isNavigationView && that.append(
pandora.$ui.sortElement = pandora.ui.sortElement()
);
that.append(
!ui.item
? pandora.$ui.listTitle = Ox.Label({
textAlign: 'center',
title: getListName(pandora.user.ui._list)
})
.addClass('OxSelectable')
.css({
position: 'absolute',
left: getListTitleLeft() + 'px',
top: '4px',
2014-01-19 09:54:02 +00:00
right: (ui._list ? 340 : 326) + 'px',
width: 'auto'
})
: pandora.$ui.itemTitle = Ox.Label({
textAlign: 'center'
})
.addClass('OxSelectable')
.css({
position: 'absolute',
left: '236px',
top: '4px',
2014-01-19 09:54:02 +00:00
right: (ui._list ? 340 : 326) + 'px',
width: 'auto'
})
.hide()
2011-10-30 21:05:57 +00:00
);
(!ui.item ? pandora.$ui.listTitle : pandora.$ui.itemTitle).bindEvent({
doubleclick: function() {
if (!ui.item) {
pandora.$ui.list && (
ui.listView == 'list'
? pandora.$ui.list.$body
: 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
);
that.bindEvent({
pandora_listview: function(data) {
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.sortElement.remove();
} else {
pandora.$ui.sortElement = pandora.ui.sortElement().insertAfter(pandora.$ui.viewSelect);
}
pandora.$ui.listTitle.css({left: getListTitleLeft() + 'px'});
} else if ((data.value == 'clip') != (data.previousValue == 'clip')) {
pandora.$ui.sortElement.replaceWith(
pandora.$ui.sortElement = pandora.ui.sortElement()
);
}
2011-09-27 22:12:37 +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))
) + '</b>';
}
function getListTitleLeft() {
return ['map', 'calendar'].indexOf(pandora.user.ui.listView) > -1 ? 152 : 316;
}
that.updateListName = function(listId) {
2023-07-07 10:44:17 +00:00
pandora.$ui.listTitle && pandora.$ui.listTitle.options({title: getListName(listId)});
};
2011-05-25 19:42:45 +00:00
return that;
};