From 85d71f43b8acf1828089b9d39b14abdcea8e3a76 Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Mon, 14 Jul 2014 19:31:47 +0900 Subject: [PATCH] Hopefully make SettingsService work with boolean values. --- res/app/components/stf/settings/settings-service.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/res/app/components/stf/settings/settings-service.js b/res/app/components/stf/settings/settings-service.js index 465edd5e..de730543 100644 --- a/res/app/components/stf/settings/settings-service.js +++ b/res/app/components/stf/settings/settings-service.js @@ -54,8 +54,12 @@ module.exports = function SettingsServiceFactory( } SettingsService.bind = function(scope, options) { + function value(possibleValue, defaultValue) { + return (possibleValue !== void 0) ? possibleValue : defaultValue + } + var source = options.source || options.target - , defaultValue = options.defaultValue || scope[options.target] + , defaultValue = value(options.defaultValue, scope[options.target]) scope.$watch( options.target @@ -79,13 +83,13 @@ module.exports = function SettingsServiceFactory( // settings were reset, for example. In that case we fall back // to the default value. if (newValue !== oldValue) { - scope[options.target] = newValue || defaultValue + scope[options.target] = value(newValue, defaultValue) } } , true ) - scope[options.target] = settings[source] || defaultValue + scope[options.target] = value(settings[source], defaultValue) } SettingsService.sync = function(object, options, monitor) {