1 (function(){ |
1 (function(){ |
2 'use strict'; |
2 'use strict'; |
3 |
3 |
4 angular.module('ammicoSlides',['ngResource', 'ngRoute']) |
4 angular.module('ammicoSlides',['ngResource', 'ngRoute']) |
5 .controller('slidesCtrl', function($scope, $routeParams, ammicoApi){ |
5 .controller('slidesCtrl', function($scope, $routeParams, Slide, Utils){ |
6 |
6 |
7 $scope.slide = ammicoApi.slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){ |
7 $scope.slide = Slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){ |
8 data = ammicoApi.sanitizeUrls(data); |
8 data = Utils.sanitizeUrls(data); |
9 }); |
9 }); |
10 |
10 |
11 }) |
11 }) |
12 .directive('slideEditor', function() { |
12 .directive('slideEditor', function() { |
13 return { |
13 return { |
14 restrict: 'AE', |
14 restrict: 'AE', |
15 replace: true, |
15 replace: true, |
16 scope: false, |
16 scope: false, |
17 templateUrl: 'slides/data_editor.html', |
17 templateUrl: 'slides/data_editor.html', |
18 controller: function($scope){ |
18 controller: function($scope){ |
19 $scope.slidesave = function(){ |
19 $scope.slidesave = function(){ |
20 if(typeof $scope.slide.tags === 'string'){ |
20 if(typeof $scope.slide.tags === 'string'){ |
21 $scope.slide.tags = $scope.slide.tags.split(','); |
21 $scope.slide.tags = $scope.slide.tags.split(','); |
22 for (var i = $scope.slide.tags.length - 1; i >= 0; i--) { |
22 for (var i = $scope.slide.tags.length - 1; i >= 0; i--) { |
23 $scope.slide.tags[i] = $scope.slide.tags[i].trim(); |
23 $scope.slide.tags[i] = $scope.slide.tags[i].trim(); |
24 } |
24 } |
25 } |
25 } |
26 $scope.slide.editMode = false; |
26 $scope.slide.editMode = false; |
27 $scope.slide.$save({idSlide:$scope.slide.id, format:'json'}); |
27 $scope.slide.$update({format:'json'}); |
28 }; |
28 }; |
29 $scope.doubleClick = function(){ |
29 $scope.doubleClick = function(){ |
30 $scope.slide.editMode = true; |
30 $scope.slide.editMode = true; |
31 }; |
31 }; |
32 } |
32 } |
33 }; |
33 }; |
34 }); |
34 }); |
35 |
35 |
36 })(); |
36 })(); |