Footer funzionante e fissato in basso
[YouAndWeb_TwoToc] / client / app / partner / partner.controller.js
1 'use strict';
2
3 angular.module('dashboardApp')
4   .controller('PartnerCtrl', function($scope, $http, datepickerPopupConfig, $stateParams) {
5
6   var baseLimit = 7;
7   $scope.limit = baseLimit;
8   var d = new Date();
9   d.setHours(0,0,0,0);
10   $scope.dataInizio = new Date(d);
11
12   $scope.posters = [];
13   var route;
14   $scope.loadCount = 0;
15   $scope.loadShows = function() {
16     route = '/api/shows?limit=' + $scope.limit;
17     if ($scope.dataInizio) {
18       route += '&date=' + $scope.dataInizio;
19     }
20     if ($scope.category) {
21       route += '&category=' + $scope.category;
22     }
23     if ($stateParams.lat && $stateParams.lng) {
24       route += '&lat=' + $stateParams.lat + '&lng=' + $stateParams.lng;
25     }
26     if ($scope.fulltext) {
27       route += '&fulltext=' + $scope.fulltext;
28     }
29         $http.get(route).then(function(response) {
30           $scope.posters = response.data;
31           $scope.limit += $scope.limit;
32       if ($scope.loadCount % 2 === 0) {
33         $scope.limit++;
34       }
35       $scope.loadCount++;
36         });
37   };
38   $scope.loadShows();
39
40
41   var posterCount = 0;
42   $scope.pCount = function(index) {
43     posterCount = index % 10 === 0 ? 0 : posterCount + 1;
44     return posterCount === 0 || posterCount === 6;
45   };
46
47   $scope.datepickers = {
48     dataInizio: false,
49     dataFine: false
50   };
51
52   $scope.open = function($event, which, whichnot) {
53     $event.preventDefault();
54     $event.stopPropagation();
55
56     $scope.datepickers[which]= true;
57     $scope.datepickers[whichnot]= false;
58   };
59
60   $scope.dateOptions = {
61     'year-format': 'yy',
62     'starting-day': 1,
63     'show-weeks': false
64   };
65
66   datepickerPopupConfig.showButtonBar = false;
67   datepickerPopupConfig.appendToBody = false;
68
69   $scope.minDate = new Date();
70   $scope.minDateFine = new Date();
71
72   $scope.searchShows = function() {
73     $scope.limit = baseLimit;
74     $scope.loadCount = 0;
75         $scope.loadShows();
76   };
77
78   // load categories
79   $http.get('/api/categories?active=true').then(function(response) {
80     $scope.categories = response.data;
81   });
82 });