forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewmode.js
More file actions
27 lines (23 loc) · 976 Bytes
/
viewmode.js
File metadata and controls
27 lines (23 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
gg.directive('viewmode', ['$rootScope', 'User', function($rootScope, User) {
return {
restrict: 'C',
link: function($scope) {
$scope.staircase = function() {
if (!($rootScope.user)) return false;
if (!($rootScope.user.view_mode)) return false;
return $rootScope.user.view_mode == 1
}
$scope.toggleStaircase = function() {
console.log('toggleStaircase', $rootScope.user);
if (!($rootScope.user)) return;
$rootScope.user.view_mode = !($rootScope.user.view_mode);
// argh, it seems that angular takes the response from a
// $save and stuffs it into the object. but Rails default
// update does NOT return JSON of the object. which
// convention is more conventional? i'll say Rails
throwawayuser = new User($rootScope.user);
throwawayuser.$save({id:throwawayuser.id});
}
}
}
}]);