forked from 0x2620/pandora
add user and locale menu extra buttons
This commit is contained in:
parent
6e44c9021a
commit
722b9fb418
2 changed files with 75 additions and 0 deletions
30
static/js/localeButton.js
Normal file
30
static/js/localeButton.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
pandora.ui.localeButton = function() {
|
||||
|
||||
var isGuest = pandora.user.level == 'guest',
|
||||
|
||||
that = Ox.Element({
|
||||
tooltip: 'Click to change language'
|
||||
})
|
||||
.addClass('OxLight')
|
||||
.css({
|
||||
padding: '0 2px',
|
||||
margin: '2px 3px 2px 1px',
|
||||
fontSize: '9px'
|
||||
})
|
||||
.html('[' + pandora.user.ui.locale.toUpperCase() + ']')
|
||||
.bindEvent({
|
||||
anyclick: function() {
|
||||
if (isGuest) {
|
||||
pandora.$ui.appearanceDialog = pandora.ui.appearanceDialog().open();
|
||||
} else {
|
||||
pandora.UI.set({'part.preferences': 'appearance'});
|
||||
pandora.UI.set({page: 'preferences'});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return that;
|
||||
|
||||
};
|
45
static/js/userButton.js
Normal file
45
static/js/userButton.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
'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 in, doubleclick to sign up'
|
||||
: 'Click to open preferences, doubleclick to sign out'
|
||||
),
|
||||
type: 'image'
|
||||
})
|
||||
.css({
|
||||
float: 'left'
|
||||
})
|
||||
.bindEvent({
|
||||
singleclick: function() {
|
||||
pandora.UI.set({page: isGuest ? 'signin' : 'preferences'});
|
||||
},
|
||||
doubleclick: function() {
|
||||
pandora.UI.set({page: isGuest ? 'signup' : 'signout'});
|
||||
}
|
||||
})
|
||||
.appendTo(that);
|
||||
|
||||
return that;
|
||||
|
||||
};
|
Loading…
Reference in a new issue