From 722b9fb4184eb76446260f81ebc4c7fa6d742f89 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 8 Aug 2013 12:59:42 +0000 Subject: [PATCH] add user and locale menu extra buttons --- static/js/localeButton.js | 30 ++++++++++++++++++++++++++ static/js/userButton.js | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 static/js/localeButton.js create mode 100644 static/js/userButton.js diff --git a/static/js/localeButton.js b/static/js/localeButton.js new file mode 100644 index 000000000..5659e932e --- /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 000000000..9cabc05ea --- /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