client/app/slides/slides_controller.js
author rougeronj
Fri, 22 May 2015 17:42:57 +0200
changeset 94 cb4cf30a1629
parent 76 aa0a2d37faca
child 99 c7c424e9eed5
permissions -rw-r--r--
adding possibility to update the informations of a book (title, etc.) and handle 'idBook' parameters in Slide urls to send back only the slides of a book (will replace BooksSlides)

(function(){
	'use strict';

	angular.module('ammicoSlides',['ngResource', 'ngRoute'])
	.controller('slidesCtrl', function($scope, $routeParams, ammicoApi){
		
		$scope.slide = ammicoApi.slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){
			data = ammicoApi.sanitizeUrls(data);
		});

	})
	.directive('slideEditor', function() {
		return {
			restrict: 'AE',
			replace: true,
			scope: false,
			templateUrl: 'slides/data_editor.html',
			controller: function($scope){
				$scope.slidesave = function(){
					if(typeof $scope.slide.tags === 'string'){
						$scope.slide.tags = $scope.slide.tags.split(',');
						for (var i = $scope.slide.tags.length - 1; i >= 0; i--) {
							$scope.slide.tags[i] = $scope.slide.tags[i].trim();
						}
					}
					$scope.slide.editMode = false;
					$scope.slide.$save({idSlide:$scope.slide.id, format:'json'});
				};
				$scope.doubleClick = function(){
					$scope.slide.editMode = true;
				};
			}
		};
	});

})();