1bdd87d385a377c80189d1af7b13df308642fc5c
[nit.git] / share / nitweb / javascripts / index.js
1 /*
2 * Copyright 2016 Alexandre Terrasa <alexandre@moz-code.org>.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 (function() {
18 angular
19 .module('index', ['model', 'ngSanitize'])
20
21 .controller('IndexCtrl', ['Catalog', '$sce', '$scope', '$location', '$anchorScroll', function(Catalog, $sce, $scope, $location, $anchorScroll) {
22 this.loadHighlighted = function() {
23 Catalog.loadHightlighted(
24 function(data) {
25 $scope.highlighted = data;
26 }, function(err) {
27 $scope.error = err;
28 });
29 };
30
31 this.loadMostRequired = function() {
32 Catalog.loadMostRequired(
33 function(data) {
34 $scope.required = data;
35 }, function(err) {
36 $scope.error = err;
37 });
38 };
39
40 this.loadByTags = function() {
41 Catalog.loadByTags(
42 function(data) {
43 $scope.bytags = data;
44 }, function(err) {
45 $scope.error = err;
46 });
47 };
48
49 this.loadStats = function() {
50 Catalog.loadStats(
51 function(data) {
52 $scope.stats = data;
53 }, function(err) {
54 $scope.error = err;
55 });
56 };
57
58 this.loadContributors = function() {
59 Catalog.loadContributors(
60 function(data) {
61 $scope.contributors = data;
62 }, function(err) {
63 $scope.error = err;
64 });
65 };
66
67
68 this.scrollTo = function(hash) {
69 $anchorScroll(hash);
70 }
71
72 this.loadHighlighted();
73 this.loadStats();
74 this.loadContributors();
75 }])
76
77 .directive('contributorList', ['Model', function(Model) {
78 return {
79 restrict: 'E',
80 scope: {
81 listId: '@',
82 listTitle: '@',
83 listContributors: '='
84 },
85 templateUrl: '/directives/contributor-list.html'
86 };
87 }])
88 })();