client/app/slides/slides_controller.js
author rougeronj
Wed, 27 May 2015 19:02:43 +0200
changeset 99 c7c424e9eed5
parent 76 aa0a2d37faca
permissions -rw-r--r--
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
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(){
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
     2
    'use strict';
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
     4
    angular.module('ammicoSlides',['ngResource', 'ngRoute'])
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
     5
    .controller('slidesCtrl', function($scope, $routeParams, Slide, Utils){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
     6
        
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
     7
        $scope.slide = Slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
     8
            data = Utils.sanitizeUrls(data);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
     9
        });
37
81ed4fbb1a64 add save fonction on a slide and update template
rougeronj
parents: 31
diff changeset
    10
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    11
    })
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    12
    .directive('slideEditor', function() {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    13
        return {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    14
            restrict: 'AE',
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    15
            replace: true,
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    16
            scope: false,
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    17
            templateUrl: 'slides/data_editor.html',
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    18
            controller: function($scope){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    19
                $scope.slidesave = function(){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    20
                    if(typeof $scope.slide.tags === 'string'){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    21
                        $scope.slide.tags = $scope.slide.tags.split(',');
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    22
                        for (var i = $scope.slide.tags.length - 1; i >= 0; i--) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    23
                            $scope.slide.tags[i] = $scope.slide.tags[i].trim();
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    24
                        }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    25
                    }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    26
                    $scope.slide.editMode = false;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    27
                    $scope.slide.$update({format:'json'});
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    28
                };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    29
                $scope.doubleClick = function(){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    30
                    $scope.slide.editMode = true;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    31
                };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    32
            }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
diff changeset
    33
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 76
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
})();