pandora/static/js/userButton.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-08-08 12:59:42 +00:00
'use strict';
pandora.ui.userButton = function() {
var isGuest = pandora.user.level == 'guest',
that = Ox.Element().css({marginLeft: '3px'});
$('<div>')
.addClass('OxLight')
.css({
float: 'left',
marginTop: '2px',
fontSize: '9px'
})
.html(
isGuest ? 'not signed in'
: Ox.encodeHTMLEntities(pandora.user.username)
)
.appendTo(that);
Ox.Button({
style: 'symbol',
title: 'user',
tooltip: Ox._(
isGuest ? 'Click to sign up or doubleclick to sign in'
: 'Click to open preferences or doubleclick to sign out'
2013-08-08 12:59:42 +00:00
),
type: 'image'
})
.css({
float: 'left'
})
.bindEvent({
singleclick: function() {
pandora.UI.set({page: isGuest ? 'signup' : 'preferences'});
2013-08-08 12:59:42 +00:00
},
doubleclick: function() {
pandora.UI.set({page: isGuest ? 'signin' : 'signout'});
2013-08-08 12:59:42 +00:00
}
})
.appendTo(that);
return that;
};