Skip to content

Commit

Permalink
feature/settings-tracking — Added possibility to disable tracking in …
Browse files Browse the repository at this point in the history
…settings.
  • Loading branch information
jeandat committed Mar 24, 2016
1 parent d0e56e1 commit 08dad3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/setting/setting-list.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ion-view.settings(view-title='Settings')
ion-list
ion-toggle(ng-model='vm.settings.enableAnimations', toggle-class='toggle-positive')
| Enable Animations
ion-toggle(ng-model='vm.settings.enableTracker', toggle-class='toggle-positive')
| Enable tracking
ion-item
button.button.button-assertive.button-small.button-block(ng-click='vm.clearCache()')
span(ng-bind="vm.clearing ? 'Clearing…' : 'Clear cache'")
Expand Down
18 changes: 16 additions & 2 deletions app/setting/setting.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
.module('app')
.factory('settingService', factory);

function factory($log, localStorageService, defaultCacheName, CacheFactory, ImgCache, $q, $ionicConfig) {
function factory($log, localStorageService, defaultCacheName, CacheFactory, ImgCache, $q, $ionicConfig, $window, trackerId) {

var defaults = {
enableAnimations: true
enableAnimations: true,
enableTracker: true
};

var service = {
Expand All @@ -26,6 +27,7 @@
function applyDiffAndPersist(newSettings, oldSettings){
// enableAnimations property
newSettings.enableAnimations !== oldSettings.enableAnimations && processEnableAnimations();
newSettings.enableTracker !== oldSettings.enableTracker && processEnableTracker();
persist();
}

Expand All @@ -43,6 +45,18 @@
service.settings.enableAnimations ? enableAnimations() : disableAnimations();
}

function processEnableTracker(){
service.settings.enableTracker ? enableTracker() : disableTracker();
}

function enableTracker(){
$window['ga-disable-' + trackerId] = false;
}

function disableTracker(){
$window['ga-disable-' + trackerId] = true;
}

function clearCache() {
return $q(function (resolve, reject) {

Expand Down

0 comments on commit 08dad3e

Please sign in to comment.