Merge: Added contributing guidelines and link from readme
[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 .run(['$anchorScroll', function($anchorScroll) {
22 $anchorScroll.yOffset = 80;
23 }])
24
25 .controller('IndexCtrl', ['Catalog', '$routeParams', '$sce', '$scope', '$location', '$anchorScroll', function(Catalog, $routeParams, $sce, $scope, $location, $anchorScroll) {
26 this.loadHighlighted = function() {
27 Catalog.loadHightlighted(
28 function(data) {
29 $scope.highlighted = data;
30 }, function(err) {
31 $scope.error = err;
32 });
33 };
34
35 this.loadMostRequired = function() {
36 Catalog.loadMostRequired(
37 function(data) {
38 $scope.required = data;
39 }, function(err) {
40 $scope.error = err;
41 });
42 };
43
44 this.loadByTags = function() {
45 Catalog.loadByTags(
46 function(data) {
47 $scope.bytags = data;
48 }, function(err) {
49 $scope.error = err;
50 });
51 };
52
53 this.loadStats = function() {
54 Catalog.loadStats(
55 function(data) {
56 $scope.stats = data;
57 }, function(err) {
58 $scope.error = err;
59 });
60 };
61
62 this.loadContributors = function() {
63 Catalog.loadContributors(
64 function(data) {
65 $scope.contributors = data;
66 }, function(err) {
67 $scope.error = err;
68 });
69 };
70
71
72 this.scrollTo = function(hash) {
73 $anchorScroll(hash);
74 }
75
76 this.loadHighlighted();
77 this.loadStats();
78 this.loadContributors();
79 }])
80
81 .directive('contributorList', ['Model', function(Model) {
82 return {
83 restrict: 'E',
84 scope: {
85 listId: '@',
86 listTitle: '@',
87 listContributors: '='
88 },
89 templateUrl: '/directives/contributor-list.html'
90 };
91 }])
92 })();