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('entities', ['ui', 'model'])
21 .controller('EntityCtrl', ['Model', '$routeParams', '$scope', function(Model
, $routeParams
, $scope
) {
22 this.loadEntityLinearization
= function() {
23 Model
.loadEntityLinearization($routeParams
.id
,
25 $scope
.linearization
= data
;
31 this.loadEntityCode
= function() {
32 Model
.loadEntityCode($routeParams
.id
,
40 Model
.loadEntity($routeParams
.id
,
42 $scope
.mentity
= data
;
48 .directive('entityLink', function() {
54 templateUrl
: '/directives/entity/link.html'
58 .directive('entityDoc', function() {
64 templateUrl
: '/directives/entity/doc.html'
68 .directive('entitySignature', function() {
74 templateUrl
: '/directives/entity/signature.html'
78 .directive('entityTag', function() {
85 templateUrl
: '/directives/entity/tag.html'
89 .directive('entityLocation', function() {
95 templateUrl
: '/directives/entity/location.html'
99 .directive('entityCard', function() {
106 templateUrl
: '/directives/entity/card.html'
110 .directive('entityList', function() {
117 listObjectFilter
: '=',
119 templateUrl
: '/directives/entity/list.html',
120 link
: function ($scope
, element
, attrs
) {
121 $scope
.showFilters
= false;
122 if(!$scope
.listObjectFilter
) {
123 $scope
.listObjectFilter
= {};
125 if(!$scope
.visibilityFilter
) {
126 $scope
.visibilityFilter
= {
132 $scope
.toggleFilters
= function() {
133 $scope
.showFilters
= !$scope
.showFilters
;
139 .directive('entityLinearization', function() {
147 templateUrl
: '/directives/entity/linearization.html'
151 .directive('entityDef', ['Model', function(Model
, Code
) {
158 templateUrl
: '/directives/entity/defcard.html',
159 link
: function ($scope
, element
, attrs
) {
160 $scope
.codeId
= 'code_' + $scope
.definition
.full_name
.replace(/[^a
-zA
-Z0
-9]/g
, '_');
161 $scope
.loadCardCode
= function() {
163 Model
.loadEntityCode($scope
.definition
.full_name
,
166 setTimeout(function() { // smooth collapse
167 $
('#' + $scope
.codeId
).collapse('show')
173 if($
('#' + $scope
.codeId
).hasClass('in')) {
174 $
('#' + $scope
.codeId
).collapse('hide');
176 $
('#' + $scope
.codeId
).collapse('show');