f33a4398f56ff48d9a09e3aef85fbd62beadef98
2 * Copyright 2016 Alexandre Terrasa <alexandre@moz-code.org>.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 .module('ui', [ 'model' ])
21 .controller('SearchCtrl', ['Model', '$routeParams', '$scope', '$location', function(Model
, $routeParams
, $scope
, $location
) {
24 $scope
.reset
= function() {
25 $scope
.activeItem
= 0;
29 $scope
.update
= function(e
) {
32 } else if(e
.keyCode
== 40) {
34 } else if(e
.keyCode
== 27) {
35 $scope
.selectEscape();
36 } else if(e
.keyCode
== 13) {
41 $scope
.selectUp
= function() {
42 if($scope
.activeItem
> 0) {
43 $scope
.activeItem
-= 1;
47 $scope
.selectDown
= function() {
48 if($scope
.activeItem
< $scope
.results
.length
- 1) {
49 $scope
.activeItem
+= 1;
53 $scope
.selectEnter
= function(e
) {
54 $location
.url($scope
.results
[$scope
.activeItem
].web_url
);
58 $scope
.selectEscape
= function() {
62 $scope
.setActive
= function(index
) {
63 $scope
.activeItem
= index
;
66 $scope
.search
= function() {
71 Model
.search($scope
.query
, 10,
74 $scope
.results
= data
;
84 .directive('searchCard', function() {
91 templateUrl
: '/directives/search/card.html'
95 .directive('uiFilters', function() {
104 templateUrl
: '/directives/ui-filter-button-vis.html',
105 link
: function ($scope
, element
, attrs
) {
106 $scope
.toggle
= function() {
107 $scope
.property
= !$scope
.property
;
113 .filter('visibility', function() {
114 return function(input
, visibilityFilter
) {
116 input
.forEach(function(entry
) {
117 if(visibilityFilter
.public == false && entry
.visibility
== "public") {
120 if(visibilityFilter
.protected == false && entry
.visibility
== "protected") {
123 if(visibilityFilter
.private == false && entry
.visibility
== "private") {
132 .directive('uiFilterForm', function() {
137 visibilityFilter
: '='
140 templateUrl
: '/directives/ui-filter-form.html'
144 .directive('uiFilterField', function() {
151 templateUrl
: '/directives/ui-filter-field.html'
155 .directive('uiFilterGroupVis', function() {
162 templateUrl
: '/directives/ui-filter-group-vis.html'
166 .directive('uiFilterButtonVis', function() {
175 templateUrl
: '/directives/ui-filter-button-vis.html',
176 link
: function ($scope
, element
, attrs
) {
177 $scope
.toggle
= function() {
178 $scope
.property
= !$scope
.property
;