Skip to content

Commit

Permalink
Autosave
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasselgren committed Aug 12, 2014
1 parent 1511950 commit fa3efac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions app/js/controller/ActivitiesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,41 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval
else{
console.log("Scope not modified");
}
}, 60000);
}, 30000);

}

var timeout = null;


$scope.$watch('data.currentActivity.description', function(newVal, oldVal){
$scope.$watch('data.currentActivity', function(newVal, oldVal){
if(newVal != oldVal){

if(timeout){
$timeout.cancel(timeout);
}

timeout = $timeout(function(){
console.log("data.currentActivity.description changed");
console.log("data.currentActivity changed");
$scope.modified = true;
console.log("modified = true");
},1000);
};
});

$scope.$watch('data.currentActivity.shortDescription', function(newVal, oldVal){
if(newVal != oldVal){
if(timeout){
$timeout.cancel(timeout);
}

timeout = $timeout(function(){
console.log("data.currentActivity.shortDescription changed");
$scope.modified = true;
console.log("modified = true");
},1000);
};
});
}, true);

// $scope.$watch('data.currentActivity.shortDescription', function(newVal, oldVal){
// if(newVal != oldVal){
// if(timeout){
// $timeout.cancel(timeout);
// }
//
// timeout = $timeout(function(){
// console.log("data.currentActivity.shortDescription changed");
// $scope.modified = true;
// console.log("modified = true");
// },1000);
// };
// });

$scope.$on('currentActivity.updated', function(event){
console.log(event);
Expand Down
2 changes: 1 addition & 1 deletion app/js/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ app.directive("thing", function(Data, backEndAdress, activityDataService){
scope: {
thing: "="
},
controller: function($scope){
controller: function($rootScope, $scope){

this.activityId = Data.currentActivity.id;
this.backEndAdress = backEndAdress;
Expand Down

0 comments on commit fa3efac

Please sign in to comment.