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.loadEntityDefs
= function() {
32 Model
.loadEntityDefs($routeParams
.id
,
40 this.loadEntityCode
= function() {
41 Model
.loadEntityCode($routeParams
.id
,
49 Model
.loadEntity($routeParams
.id
,
51 $scope
.mentity
= data
;
57 .directive('entityLink', function() {
63 templateUrl
: '/directives/entity/link.html'
67 .directive('entityDoc', function() {
73 templateUrl
: '/directives/entity/doc.html'
77 .directive('entitySignature', function() {
83 templateUrl
: '/directives/entity/signature.html'
87 .directive('entityTag', function() {
94 templateUrl
: '/directives/entity/tag.html'
98 .directive('entityLocation', function() {
104 templateUrl
: '/directives/entity/location.html'
108 .directive('entityCard', function() {
115 templateUrl
: '/directives/entity/card.html'
119 .directive('entityList', function() {
126 listObjectFilter
: '=',
128 templateUrl
: '/directives/entity/list.html',
129 link
: function ($scope
, element
, attrs
) {
130 $scope
.showFilters
= false;
131 if(!$scope
.listObjectFilter
) {
132 $scope
.listObjectFilter
= {};
134 if(!$scope
.visibilityFilter
) {
135 $scope
.visibilityFilter
= {
141 $scope
.toggleFilters
= function() {
142 $scope
.showFilters
= !$scope
.showFilters
;
148 .directive('entityLinearization', function() {
156 templateUrl
: '/directives/entity/linearization.html'
160 .directive('entityDef', ['Model', function(Model
, Code
) {
167 templateUrl
: '/directives/entity/defcard.html',
168 link
: function ($scope
, element
, attrs
) {
169 $scope
.codeId
= 'code_' + $scope
.definition
.full_name
.replace(/[^a
-zA
-Z0
-9]/g
, '_');
170 $scope
.loadCardCode
= function() {
172 Model
.loadEntityCode($scope
.definition
.full_name
,
175 setTimeout(function() { // smooth collapse
176 $
('#' + $scope
.codeId
).collapse('show')
182 if($
('#' + $scope
.codeId
).hasClass('in')) {
183 $
('#' + $scope
.codeId
).collapse('hide');
185 $
('#' + $scope
.codeId
).collapse('show');