(function() {
angular
- .module('entities', ['ui', 'model'])
+ .module('entities', ['ngSanitize', 'ui', 'model'])
- .controller('EntityCtrl', ['Model', '$routeParams', '$scope', function(Model, $routeParams, $scope) {
+ .controller('EntityCtrl', ['Model', '$routeParams', '$scope', '$sce', function(Model, $routeParams, $scope, $sce) {
this.loadEntityLinearization = function() {
Model.loadEntityLinearization($routeParams.id,
function(data) {
});
};
+ this.loadEntityDefs = function() {
+ Model.loadEntityDefs($routeParams.id,
+ function(data) {
+ $scope.defs = data;
+ }, function(err) {
+ $scope.error = err;
+ });
+ };
+
this.loadEntityCode = function() {
Model.loadEntityCode($routeParams.id,
function(data) {
});
};
+ this.loadEntityGraph = function(e) {
+ Model.loadEntityGraph($routeParams.id,
+ function(data) {
+ $scope.graph = $sce.trustAsHtml(data);
+ }, function(err) {
+ $scope.error = err;
+ });
+ };
+
Model.loadEntity($routeParams.id,
function(data) {
$scope.mentity = data;
};
})
+ .directive('entityNamespace', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ mentity: '='
+ },
+ templateUrl: '/directives/entity/namespace.html'
+ };
+ })
+
.directive('entityTag', function() {
return {
restrict: 'E',
definition: '=',
focus: '='
},
+ templateUrl: '/directives/entity/defcard.html',
link: function ($scope, element, attrs) {
- $scope.$watch("definition", function() {
- /*.loadEntityDefs($scope.definition.full_name,
- function(data) {
- $scope.mentity = data;
- }, function(err) {
- $scope.error = err;
- });
- Model.loadEntityCode($scope.definition.full_name,
- function(data) {
- $scope.code = data;
- }, function(err) {
- $scope.error = err;
- });*/
- });
- },
- templateUrl: '/directives/entity/defcard.html'
+ $scope.codeId = 'code_' + $scope.definition.full_name.replace(/[^a-zA-Z0-9]/g, '_');
+ $scope.loadCardCode = function() {
+ if(!$scope.code) {
+ Model.loadEntityCode($scope.definition.full_name,
+ function(data) {
+ $scope.code = data;
+ setTimeout(function() { // smooth collapse
+ $('#' + $scope.codeId).collapse('show')
+ }, 1);
+ }, function(err) {
+ $scope.code = err;
+ });
+ } else {
+ if($('#' + $scope.codeId).hasClass('in')) {
+ $('#' + $scope.codeId).collapse('hide');
+ } else {
+ $('#' + $scope.codeId).collapse('show');
+ }
+ }
+ };
+ }
};
}])
})();