From d7aaec2262e475e2c0b2f72f5b62ef81062f7d25 Mon Sep 17 00:00:00 2001 From: Adrien Lemaire Date: Sat, 9 Aug 2014 18:57:17 +0900 Subject: [PATCH] fix bug switch audio wasn't working --- public/css/menu.styl | 4 ++-- public/js/controllers/authCtrl.js | 10 +++++++--- views/shared/header/menu.jade | 11 ++++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/public/css/menu.styl b/public/css/menu.styl index 700d763909..fcd3652893 100644 --- a/public/css/menu.styl +++ b/public/css/menu.styl @@ -154,7 +154,7 @@ .toolbar-notifs-no-messages padding: 0.382em 1em // Settings dropdown -.toolbar-settings +.toolbar-settings, .toolbar-audio @extend $hrpg-modal-dropdown-left .toolbar-controls @extend $hrpg-modal-controls @@ -166,7 +166,7 @@ @media screen and (max-width:768px) .toolbar-toggle display: none - .toolbar-mobile, .toolbar-settings + .toolbar-mobile, .toolbar-settings, .toolbar-audio .toolbar-submenu padding-left: 1em display: block diff --git a/public/js/controllers/authCtrl.js b/public/js/controllers/authCtrl.js index 7bd7618890..25f367ca39 100644 --- a/public/js/controllers/authCtrl.js +++ b/public/js/controllers/authCtrl.js @@ -79,7 +79,7 @@ angular.module('authCtrl', []) // Using controller: 'AuthCtrl' it causes problems }); } - } + }; $scope.passwordReset = function(email){ $http.post(API_URL + '/api/v2/user/reset-password', {email:email}) @@ -89,10 +89,14 @@ angular.module('authCtrl', []) .error(function(data){ alert(data.err); }); - } + }; $scope.expandMenu = function(menu) { $scope._expandedMenu = ($scope._expandedMenu == menu) ? null : menu; - } + }; + + $scope.switchAudio = function(bool) { + User.set({"preferences.sound": bool}); + }; } ]); diff --git a/views/shared/header/menu.jade b/views/shared/header/menu.jade index 22e3e18412..9babfcff5d 100644 --- a/views/shared/header/menu.jade +++ b/views/shared/header/menu.jade @@ -144,12 +144,13 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') div ul.toolbar-submenu(ng-click='expandMenu(null)') li - a(ng-if='user.preferences.sound', ng-click='set("preferences.sound",false)') - i.glyphicon.glyphicon-volume_down(tooltip=env.t('soundOff')) - li - a(ng-if='!user.preferences.sound', ng-click='set("preferences.sound",true)') - i.glyphicon.glyphicon-mute(tooltip=env.t('soundOn')) + label=env.t('switchSound') + a(ng-if='user.preferences.sound', ng-click='switchAudio(false)') + span.glyphicon.glyphicon-volume-down(tooltip=env.t('soundOff')) + a(ng-if='!user.preferences.sound', ng-click='switchAudio(true)') + span.glyphicon.glyphicon-volume-off(tooltip=env.t('soundOn')) li + label(for='audioTheme')=env.t('selectTheme') select#audioTheme( style='width:140px', ng-controller='SettingsCtrl',