use scope only
This commit is contained in:
parent
00ef6bdb62
commit
aa49f03fc1
2 changed files with 21 additions and 28 deletions
|
|
@ -2,10 +2,10 @@
|
||||||
ng-init="titleSection='Color'; goBackToState = 'preferences'">
|
ng-init="titleSection='Color'; goBackToState = 'preferences'">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content preferences" ng-controller="preferencesColorController as p" ng-init="p.init()">
|
<div class="content preferences" ng-controller="preferencesColorController">
|
||||||
<h4></h4>
|
<h4></h4>
|
||||||
|
|
||||||
<ion-radio class="size-12" ng-repeat="c in p.colorList" ng-value="c" ng-model="data.currentColor" ng-click="p.save(c)">
|
<ion-radio class="size-12" ng-repeat="c in colorList" ng-value="c" ng-model="currentColor" ng-click="save(c)">
|
||||||
<span ng-style="{'color': c}">█</span>
|
<span ng-style="{'color': c}">█</span>
|
||||||
</ion-radio>
|
</ion-radio>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesColorController',
|
angular.module('copayApp.controllers').controller('preferencesColorController', function($scope, $log, configService, profileService, go) {
|
||||||
function($scope, $timeout, $log, configService, profileService, go) {
|
|
||||||
var config;
|
|
||||||
var fc = profileService.focusedClient;
|
|
||||||
var walletId = fc.credentials.walletId;
|
|
||||||
|
|
||||||
this.init = function() {
|
$scope.colorList = [
|
||||||
this.colorList = [
|
|
||||||
'#DD4B39',
|
'#DD4B39',
|
||||||
'#F38F12',
|
'#F38F12',
|
||||||
'#FAA77F',
|
'#FAA77F',
|
||||||
|
|
@ -24,25 +19,23 @@ angular.module('copayApp.controllers').controller('preferencesColorController',
|
||||||
'#7A8C9E',
|
'#7A8C9E',
|
||||||
];
|
];
|
||||||
|
|
||||||
config = configService.getSync();
|
var fc = profileService.focusedClient;
|
||||||
config.colorFor = config.colorFor || {};
|
var walletId = fc.credentials.walletId;
|
||||||
|
var config = configService.getSync();
|
||||||
|
config.colorFor = config.colorFor || {};
|
||||||
|
|
||||||
$scope.data = {
|
$scope.currentColor = config.colorFor[walletId] || '#4A90E2';
|
||||||
currentColor: config.colorFor[walletId] || '#4A90E2'
|
|
||||||
};
|
$scope.save = function(color) {
|
||||||
|
var opts = {
|
||||||
|
colorFor: {}
|
||||||
};
|
};
|
||||||
|
opts.colorFor[walletId] = color;
|
||||||
|
|
||||||
this.save = function(color) {
|
configService.set(opts, function(err) {
|
||||||
var self = this;
|
go.preferences();
|
||||||
var opts = {
|
if (err) $log.warn(err);
|
||||||
colorFor: {}
|
$scope.$emit('Local/ColorUpdated');
|
||||||
};
|
});
|
||||||
opts.colorFor[walletId] = color;
|
};
|
||||||
|
});
|
||||||
configService.set(opts, function(err) {
|
|
||||||
go.preferences();
|
|
||||||
if (err) $log.warn(err);
|
|
||||||
$scope.$emit('Local/ColorUpdated');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue