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', ['ngSanitize', 'ui', 'model'])
21 .controller('EntityCtrl', ['Model', '$routeParams', '$scope', '$sce', function(Model
, $routeParams
, $scope
, $sce
) {
22 $scope
.entityId
= $routeParams
.id
;
24 this.loadEntityLinearization
= function() {
25 Model
.loadEntityLinearization($routeParams
.id
,
27 $scope
.linearization
= data
;
33 this.loadEntityDefs
= function() {
34 Model
.loadEntityDefs($routeParams
.id
,
42 this.loadEntityCode
= function() {
43 Model
.loadEntityCode($routeParams
.id
,
51 this.loadEntityGraph
= function(e
) {
52 Model
.loadEntityGraph($routeParams
.id
,
54 $scope
.graph
= $sce
.trustAsHtml(data
);
60 Model
.loadEntity($routeParams
.id
,
62 $scope
.mentity
= data
;
63 }, function(message
, status
) {
64 $scope
.error
= {message
: message
, status
: status
};
68 .directive('entityLink', function() {
74 templateUrl
: '/directives/entity/link.html'
78 .directive('entityDoc', function() {
84 templateUrl
: '/directives/entity/doc.html'
88 .directive('entitySignature', function() {
94 templateUrl
: '/directives/entity/signature.html'
98 .directive('entityNamespace', function() {
104 templateUrl
: '/directives/entity/namespace.html'
108 .directive('entityTag', function() {
115 templateUrl
: '/directives/entity/tag.html'
119 .directive('entityLocation', function() {
125 templateUrl
: '/directives/entity/location.html'
129 .directive('entityCard', function() {
136 templateUrl
: '/directives/entity/card.html'
140 .directive('entityList', function() {
147 listObjectFilter
: '=',
149 templateUrl
: '/directives/entity/list.html',
150 link
: function ($scope
, element
, attrs
) {
151 $scope
.showFilters
= false;
152 if(!$scope
.listObjectFilter
) {
153 $scope
.listObjectFilter
= {};
155 if(!$scope
.visibilityFilter
) {
156 $scope
.visibilityFilter
= {
162 $scope
.toggleFilters
= function() {
163 $scope
.showFilters
= !$scope
.showFilters
;
169 .directive('entityLinearization', function() {
177 templateUrl
: '/directives/entity/linearization.html'
181 .directive('entityDef', ['Model', function(Model
, Code
) {
188 templateUrl
: '/directives/entity/defcard.html',
189 link
: function ($scope
, element
, attrs
) {
190 $scope
.codeId
= 'code_' + $scope
.definition
.full_name
.replace(/[^a
-zA
-Z0
-9]/g
, '_');
191 $scope
.loadCardCode
= function() {
193 Model
.loadEntityCode($scope
.definition
.full_name
,
196 setTimeout(function() { // smooth collapse
197 $
('#' + $scope
.codeId
).collapse('show')
203 if($
('#' + $scope
.codeId
).hasClass('in')) {
204 $
('#' + $scope
.codeId
).collapse('hide');
206 $
('#' + $scope
.codeId
).collapse('show');