From 00ef6bdb62dcbee2d078db2a7215946a11a513d1 Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 9 Jun 2016 17:54:03 -0300 Subject: [PATCH 1/2] Fix color selection - IOs --- public/views/preferencesColor.html | 17 +++------ src/js/controllers/preferencesColor.js | 53 +++++++++++++------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/public/views/preferencesColor.html b/public/views/preferencesColor.html index a26b2d4d4..e995aa399 100644 --- a/public/views/preferencesColor.html +++ b/public/views/preferencesColor.html @@ -1,18 +1,11 @@ -
- - -
+

-
    -
  • + + - -
  • -
+
-
diff --git a/src/js/controllers/preferencesColor.js b/src/js/controllers/preferencesColor.js index 7aa84db56..5caa2d42b 100644 --- a/src/js/controllers/preferencesColor.js +++ b/src/js/controllers/preferencesColor.js @@ -2,30 +2,35 @@ angular.module('copayApp.controllers').controller('preferencesColorController', function($scope, $timeout, $log, configService, profileService, go) { - var config = configService.getSync(); - this.colorOpts = [ - '#DD4B39', - '#F38F12', - '#FAA77F', - '#D0B136', - '#9EDD72', - '#29BB9C', - '#019477', - '#77DADA', - '#4A90E2', - '#484ED3', - '#9B59B6', - '#E856EF', - '#FF599E', - '#7A8C9E', - ]; - + var config; var fc = profileService.focusedClient; var walletId = fc.credentials.walletId; - var config = configService.getSync(); - config.colorFor = config.colorFor || {}; - this.color = config.colorFor[walletId] || '#4A90E2'; + this.init = function() { + this.colorList = [ + '#DD4B39', + '#F38F12', + '#FAA77F', + '#D0B136', + '#9EDD72', + '#29BB9C', + '#019477', + '#77DADA', + '#4A90E2', + '#484ED3', + '#9B59B6', + '#E856EF', + '#FF599E', + '#7A8C9E', + ]; + + config = configService.getSync(); + config.colorFor = config.colorFor || {}; + + $scope.data = { + currentColor: config.colorFor[walletId] || '#4A90E2' + }; + }; this.save = function(color) { var self = this; @@ -35,13 +40,9 @@ angular.module('copayApp.controllers').controller('preferencesColorController', opts.colorFor[walletId] = color; configService.set(opts, function(err) { - if (err) $log.warn(err); go.preferences(); + if (err) $log.warn(err); $scope.$emit('Local/ColorUpdated'); - $timeout(function() { - $scope.$apply(); - }, 100); }); - }; }); From aa49f03fc1fb34e1ed595a184576b0f784e8e22a Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 10 Jun 2016 09:41:13 -0300 Subject: [PATCH 2/2] use scope only --- public/views/preferencesColor.html | 4 +-- src/js/controllers/preferencesColor.js | 45 +++++++++++--------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/public/views/preferencesColor.html b/public/views/preferencesColor.html index e995aa399..5c0c33faf 100644 --- a/public/views/preferencesColor.html +++ b/public/views/preferencesColor.html @@ -2,10 +2,10 @@ ng-init="titleSection='Color'; goBackToState = 'preferences'">
-
+

- +
diff --git a/src/js/controllers/preferencesColor.js b/src/js/controllers/preferencesColor.js index 5caa2d42b..5281d0166 100644 --- a/src/js/controllers/preferencesColor.js +++ b/src/js/controllers/preferencesColor.js @@ -1,13 +1,8 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesColorController', - function($scope, $timeout, $log, configService, profileService, go) { - var config; - var fc = profileService.focusedClient; - var walletId = fc.credentials.walletId; +angular.module('copayApp.controllers').controller('preferencesColorController', function($scope, $log, configService, profileService, go) { - this.init = function() { - this.colorList = [ + $scope.colorList = [ '#DD4B39', '#F38F12', '#FAA77F', @@ -24,25 +19,23 @@ angular.module('copayApp.controllers').controller('preferencesColorController', '#7A8C9E', ]; - config = configService.getSync(); - config.colorFor = config.colorFor || {}; + var fc = profileService.focusedClient; + var walletId = fc.credentials.walletId; + var config = configService.getSync(); + config.colorFor = config.colorFor || {}; - $scope.data = { - currentColor: config.colorFor[walletId] || '#4A90E2' - }; + $scope.currentColor = config.colorFor[walletId] || '#4A90E2'; + + $scope.save = function(color) { + var opts = { + colorFor: {} }; + opts.colorFor[walletId] = color; - this.save = function(color) { - var self = this; - var opts = { - colorFor: {} - }; - opts.colorFor[walletId] = color; - - configService.set(opts, function(err) { - go.preferences(); - if (err) $log.warn(err); - $scope.$emit('Local/ColorUpdated'); - }); - }; - }); + configService.set(opts, function(err) { + go.preferences(); + if (err) $log.warn(err); + $scope.$emit('Local/ColorUpdated'); + }); + }; +});