diff --git a/static/js/localeButton.js b/static/js/localeButton.js new file mode 100644 index 00000000..5659e932 --- /dev/null +++ b/static/js/localeButton.js @@ -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; + +}; \ No newline at end of file diff --git a/static/js/userButton.js b/static/js/userButton.js new file mode 100644 index 00000000..9cabc05e --- /dev/null +++ b/static/js/userButton.js @@ -0,0 +1,45 @@ +'use strict'; + +pandora.ui.userButton = function() { + + var isGuest = pandora.user.level == 'guest', + that = Ox.Element().css({marginLeft: '3px'}); + + $('
') + .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; + +}; \ No newline at end of file