2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2012-03-21 04:58:02 +00:00
|
|
|
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
2012-03-21 04:58:02 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.statusbar = function() {
|
2012-03-21 04:58:02 +00:00
|
|
|
|
|
|
|
var $text = {
|
|
|
|
titleTotal: Ox.Element('<span>').html('Total: '),
|
|
|
|
total: Ox.Element('<span>'),
|
|
|
|
titleSelected: Ox.Element('<span>').html(' — Selected: '),
|
|
|
|
selected: Ox.Element('<span>'),
|
|
|
|
loading: Ox.Element('<span>').html('Loading...')
|
|
|
|
},
|
|
|
|
|
|
|
|
that = Ox.Bar({size: 16})
|
|
|
|
.css({
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.append(
|
|
|
|
Ox.Element()
|
|
|
|
.css({
|
|
|
|
marginTop: '2px',
|
|
|
|
fontSize: '9px'
|
|
|
|
})
|
|
|
|
.append($text.loading)
|
|
|
|
.append($text.titleTotal)
|
|
|
|
.append($text.total)
|
|
|
|
.append($text.titleSelected)
|
|
|
|
.append($text.selected)
|
|
|
|
);
|
|
|
|
|
|
|
|
function getText(data) {
|
|
|
|
var ui = pandora.user.ui,
|
2012-03-21 09:36:11 +00:00
|
|
|
canSeeFiles = pandora.site.capabilities.canSeeFiles[pandora.user.level],
|
2012-03-21 13:39:36 +00:00
|
|
|
canSeeSize = pandora.site.capabilities.canSeeSize[pandora.user.level],
|
2012-03-21 04:58:02 +00:00
|
|
|
itemName = ui.listView == 'clip'
|
|
|
|
? (data.items == 1 ? 'Clip' : 'Clips')
|
|
|
|
: (pandora.site.itemName[data.items == 1 ? 'singular' : 'plural']),
|
|
|
|
parts = [];
|
|
|
|
parts.push(Ox.formatNumber(data.items) + ' '+ itemName);
|
2012-03-21 09:22:31 +00:00
|
|
|
if (data.runtime) {
|
2012-03-21 04:58:02 +00:00
|
|
|
parts.push(Ox.formatDuration(data.runtime, 'short'));
|
2012-03-21 09:22:31 +00:00
|
|
|
} else if (data.duration) {
|
2012-03-21 04:58:02 +00:00
|
|
|
parts.push(Ox.formatDuration(data.duration, 'short'));
|
2012-03-21 09:22:31 +00:00
|
|
|
}
|
2012-03-21 09:36:11 +00:00
|
|
|
if (canSeeFiles) {
|
2012-03-21 13:07:19 +00:00
|
|
|
data.files && parts.push(
|
|
|
|
Ox.formatNumber(data.files) + ' file' + (data.files == 1 ? '' : 's')
|
|
|
|
);
|
2012-03-21 09:22:31 +00:00
|
|
|
data.duration && parts.push(Ox.formatDuration(data.duration));
|
2012-03-21 09:36:11 +00:00
|
|
|
}
|
2012-03-21 13:39:36 +00:00
|
|
|
if (canSeeSize) {
|
2012-03-21 09:22:31 +00:00
|
|
|
data.size && parts.push(Ox.formatValue(data.size, 'B'));
|
2012-03-21 09:36:11 +00:00
|
|
|
}
|
|
|
|
if (canSeeFiles) {
|
2012-03-21 09:22:31 +00:00
|
|
|
data.pixels && parts.push(Ox.formatValue(data.pixels, 'px'));
|
|
|
|
}
|
2012-03-21 04:58:02 +00:00
|
|
|
return parts.join(', ');
|
|
|
|
}
|
|
|
|
|
|
|
|
function setTotal() {
|
|
|
|
pandora.api.find({
|
|
|
|
query: pandora.user.ui.find,
|
|
|
|
sort: pandora.user.ui.listSort
|
|
|
|
}, function(result) {
|
|
|
|
that.set('selected', {items: 0});
|
|
|
|
that.set('total', result.data);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
that.set = function(key, data) {
|
|
|
|
if (key == 'loading') {
|
|
|
|
Ox.forEach($text, function($element, key) {
|
|
|
|
$element[key == 'loading' ? 'show' : 'hide']();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$text.loading.hide();
|
|
|
|
if (key == 'selected') {
|
|
|
|
if (data.items == 0) {
|
|
|
|
$text.titleTotal.hide();
|
|
|
|
$text.titleSelected.hide();
|
|
|
|
$text.selected.hide();
|
|
|
|
} else {
|
|
|
|
$text.titleTotal.show();
|
|
|
|
$text.titleSelected.show();
|
|
|
|
$text.selected.html(getText(data)).show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$text.total.html(getText(data)).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
that.bindEvent({
|
|
|
|
pandora_find: function() {
|
|
|
|
that.set('loading');
|
|
|
|
if (['map', 'calendar'].indexOf(pandora.user.ui.listView) > -1) {
|
|
|
|
setTotal();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pandora_listview: function(data) {
|
|
|
|
var isNavigationView = ['map', 'calendar'].indexOf(data.value) > -1,
|
|
|
|
wasNavigationView = ['map', 'calendar'].indexOf(data.previousValue) > -1;
|
|
|
|
that.set('loading');
|
|
|
|
if (isNavigationView && !wasNavigationView) {
|
|
|
|
setTotal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
that.set('loading');
|
|
|
|
if (['map', 'calendar'].indexOf(pandora.user.ui.listView) > -1) {
|
|
|
|
setTotal();
|
|
|
|
}
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
2012-03-21 04:58:02 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
};
|
|
|
|
|