client/app/slides/slides_controller.js
author rougeronj
Wed, 08 Apr 2015 00:36:37 +0200
changeset 77 ee963d1c409b
parent 76 aa0a2d37faca
child 99 c7c424e9eed5
permissions -rw-r--r--
Add new serializer for the data send by Orpheo. We receive XML so we parse it to json. Then we parse some html to get the proper data of each attribute. Add xmlToJson parser module to requirements.txt
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'])
55
10fd23382e76 split ammico $resource to a new .Service
rougeronj
parents: 54
diff changeset
     5
	.controller('slidesCtrl', function($scope, $routeParams, ammicoApi){
40
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 37
diff changeset
     6
		
55
10fd23382e76 split ammico $resource to a new .Service
rougeronj
parents: 54
diff changeset
     7
		$scope.slide = ammicoApi.slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){
10fd23382e76 split ammico $resource to a new .Service
rougeronj
parents: 54
diff changeset
     8
			data = ammicoApi.sanitizeUrls(data);
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
     9
		});
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    10
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
    11
	})
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    12
	.directive('slideEditor', function() {
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    13
		return {
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    14
			restrict: 'AE',
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    15
			replace: true,
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    16
			scope: false,
70
e7e9f2ff6f10 Rename with snake_case
rougeronj
parents: 55
diff changeset
    17
			templateUrl: 'slides/data_editor.html',
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    18
			controller: function($scope){
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    19
				$scope.slidesave = function(){
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    20
					if(typeof $scope.slide.tags === 'string'){
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    21
						$scope.slide.tags = $scope.slide.tags.split(',');
40
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 37
diff changeset
    22
						for (var i = $scope.slide.tags.length - 1; i >= 0; i--) {
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 37
diff changeset
    23
							$scope.slide.tags[i] = $scope.slide.tags[i].trim();
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 37
diff changeset
    24
						}
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    25
					}
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    26
					$scope.slide.editMode = false;
76
aa0a2d37faca show the data of the json received from the server (normalize the exchanged data)
rougeronj
parents: 70
diff changeset
    27
					$scope.slide.$save({idSlide:$scope.slide.id, format:'json'});
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    28
				};
40
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 37
diff changeset
    29
				$scope.doubleClick = function(){
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 37
diff changeset
    30
					$scope.slide.editMode = true;
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 37
diff changeset
    31
				};
37
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
		};
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
    34
	});
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
})();