mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 23:42:12 +00:00
feat(audio): refactor user.preferences.{sound,soundTheme} into just
user.preferences.sound. Fix audio dropdown bug by moving to list-items instead
This commit is contained in:
parent
06b6b4cde0
commit
39911ef8e0
5 changed files with 11 additions and 31 deletions
|
|
@ -94,9 +94,5 @@ angular.module('authCtrl', [])
|
|||
$scope.expandMenu = function(menu) {
|
||||
$scope._expandedMenu = ($scope._expandedMenu == menu) ? null : menu;
|
||||
};
|
||||
|
||||
$scope.switchAudio = function(bool) {
|
||||
User.set({"preferences.sound": bool});
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||
|
||||
$rootScope.playSound = function(id){
|
||||
if (!user.preferences.sound) return;
|
||||
var theme = user.preferences.soundTheme;
|
||||
var theme = user.preferences.sound;
|
||||
var file = 'audio/' + theme + '/' + id;
|
||||
document.getElementById('oggSource').src = file + '.ogg';
|
||||
document.getElementById('mp3Source').src = file + '.mp3';
|
||||
|
|
|
|||
|
|
@ -142,10 +142,5 @@ habitrpg.controller('SettingsCtrl',
|
|||
window.location.href = '/api/v2/coupons?limit='+codes.count+'&_id='+User.user._id+'&apiToken='+User.user.apiToken;
|
||||
})
|
||||
}
|
||||
|
||||
// Audio list of themes
|
||||
$scope.soundThemes = {
|
||||
'danielTheBard': 'Daniel the Bard'
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -255,8 +255,7 @@ var UserSchema = new Schema({
|
|||
skin: {type:String, 'default':'915533'},
|
||||
shirt: {type: String, 'default': 'blue'},
|
||||
timezoneOffset: Number,
|
||||
sound: Boolean,
|
||||
soundTheme: {type:String, 'default':'danielTheBard'},
|
||||
sound: {type:String, 'default':'off', enum: ['off','danielTheBard']},
|
||||
language: String,
|
||||
automaticAllocation: Boolean,
|
||||
allocationMode: {type:String, enum: ['flat','classbased','taskbased'], 'default': 'flat'},
|
||||
|
|
|
|||
|
|
@ -137,27 +137,17 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}')
|
|||
li.toolbar-controls-button
|
||||
a(ng-click='expandMenu(null)')=env.t('close')
|
||||
li.toolbar-audio
|
||||
a(ng-click='expandMenu("music")')
|
||||
span.glyphicon.glyphicon-music
|
||||
div(ng-if='_expandedMenu=="music"')
|
||||
h4=env.t('music')
|
||||
a(ng-click='expandMenu("audio")')
|
||||
span.glyphicon(ng-class="{'glyphicon-volume-off':user.preferences.sound=='off', 'glyphicon-volume-up':user.preferences.sound!='off'}")
|
||||
div(ng-if='_expandedMenu=="audio"',style='min-width:150px')
|
||||
h4=env.t('audioTheme')
|
||||
div
|
||||
ul.toolbar-submenu(ng-click='expandMenu(null)')
|
||||
li
|
||||
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',
|
||||
ng-model='user.preferences.soundTheme',
|
||||
ng-options='k as v for (k , v) in soundThemes',
|
||||
ng-change='set("preferences.soundTheme", user.preferences.soundTheme)'
|
||||
)
|
||||
// Using [{k,v}] instead of {k:v,k:v} to maintain order ('off' at top)
|
||||
for theme in ['off','danielTheBard']
|
||||
li
|
||||
a(ng-class="{'bg-primary':user.preferences.sound=='#{theme}'}", ng-click="set({'preferences.sound':'#{theme}'})")=env.t('audioTheme_'+theme)
|
||||
|
||||
li.toolbar-sync
|
||||
a(ng-click='User.sync()', popover=env.t('sync'),popover-placement='bottom',popover-trigger='mouseenter')
|
||||
span.glyphicon.glyphicon-refresh
|
||||
|
|
|
|||
Loading…
Reference in a new issue