{"size": 1000, "ext": "js", "max_stars_repo_path": "_uix/src/scripts/controllers/calendar.js", "max_stars_repo_name": "stephenbaidu/church-membership", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_uix/src/scripts/controllers/calendar.js", "max_issues_repo_name": "stephenbaidu/church-membership", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_uix/src/scripts/controllers/calendar.js", "max_forks_repo_name": "stephenbaidu/church-membership", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.2222222222, "max_line_length": 60, "alphanum_fraction": 0.541}
'use strict';

/**
 * @ngdoc function
 * @name uixApp.controller:CalendarCtrl
 * @description
 * # CalendarCtrl
 * Controller of the uixApp
 */
angular.module('uixApp')
  .controller('CalendarCtrl', function (APP, $http) {
    var vm = this;

    vm.routeName = null;

    // Initial calender values
    vm.view = 'month';
    vm.events = [];
    vm.viewDate = new Date();
    vm.viewTitle = '';

    vm.initRoute = function (routeName, options) {
      vm.routeName = routeName;
      options = options || {};

      if (options.view) {
        vm.view = options.view;
      }
      
      vm.reload();
    }

    vm.reload = function () {
      $http.get(APP.apiPrefix + 'dashboard/' + vm.routeName)
        .success(function (data) {
          vm.events = _.map(data, function (e) {
            // e.startsAt = moment(e.startsAt).toDate();
            // e.endsAt = moment(e.endsAt).toDate();
            e.incrementsBadgeTotal = false;
            return e;
          });
        });
    }
  });
