client/app/slides/slides_controller.js
author rougeronj
Tue, 24 Mar 2015 17:46:53 +0100
changeset 37 81ed4fbb1a64
parent 31 8d016c195d79
child 40 4b3bebe4355d
permissions -rw-r--r--
add save fonction on a slide and update template
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
(function(){
31
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
     2
	'use strict';
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
31
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
     4
	angular.module('ammicoSlides',['ngResource', 'ngRoute'])
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
     5
	.controller('slidesCtrl', function($scope, $routeParams, searchApi, $sce){
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
     6
31
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
     7
		$scope.slide = searchApi.slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
     8
			data.details.description =  $sce.trustAsHtml(data.details.description);
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
     9
		});
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    10
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    11
		$scope.save = function(){
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    12
			$scope.slide.$save({idSlide:$routeParams.idSlide, format:'json'});
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    13
		};
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    14
31
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
    15
	})
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    16
	.directive('slideEditor', function() {
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    17
		return {
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    18
			restrict: 'AE',
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    19
			replace: true,
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    20
			scope: false,
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    21
			templateUrl: 'slides/dataEditor.html',
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    22
			controller: function($scope){
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    23
				$scope.slidesave = function(){
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    24
					if(typeof $scope.slide.tags === 'string'){
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    25
						$scope.slide.tags = $scope.slide.tags.split(',');
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    26
					}
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    27
					for (var i = $scope.slide.tags.length - 1; i >= 0; i--) {
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    28
						$scope.slide.tags[i] = $scope.slide.tags[i].trim();
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    29
					}
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    30
					$scope.slide.editMode = false;
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    31
					$scope.save();
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    32
				};
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    33
			}
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    34
		};
31
8d016c195d79 get info of a slide and show it. Sanitize html from description field and add it to the scope
rougeronj
parents: 26
diff changeset
    35
	});
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
})();