Yangman - Show all items box showed for a moment-update
[dlux.git] / modules / yangman-resources / src / main / resources / yangman / directives / yang-form-menu.directive.js
1 define(['angular'], function (angular) {
2     'use strict';
3
4     angular.module('app.yangman').directive('yangFormMenu', menuDirective);
5
6     menuDirective.$inject = [];
7
8     function menuDirective() {
9         return {
10             restrict: 'E',
11             templateUrl: 'src/app/yangman/views/directives/yang-form-menu.tpl.html',
12             scope: {
13                 node: '=',
14                 augmentations: '=',
15                 allowItems: '=',
16                 isActionMenu: '&',
17                 addListItemFunc: '&',
18                 addListItem: '=',
19                 yangForm: '=',
20                 yangList: '=',
21             },
22             controller: function ($scope) {
23                 var lastSection = null;
24
25                 $scope.infoBox = false;
26                 $scope.infoBoxSection = '';
27                 $scope.selectedListItem = 0;
28
29                 // methods
30                 $scope.switchSection = switchSection;
31                 $scope.hideInfoBox = hideInfoBox;
32
33                 /**
34                  * Switcher for info box section
35                  * @param section
36                  */
37                 function switchSection(section){
38                     if ( $scope.infoBox ) {
39                         if ( section === lastSection ) {
40                             $scope.infoBox = false;
41                         } else {
42                             $scope.infoBoxSection = section;
43                         }
44                     } else {
45                         $scope.infoBox = true;
46                         $scope.infoBoxSection = section;
47                     }
48                     lastSection = section;
49                 }
50
51                 /**
52                  * Hide menu info box
53                  */
54                 function hideInfoBox(){
55                     $scope.infoBox = false;
56                     angular.element('#infoBox').addClass('ng-hide');
57                 }
58
59                 $scope.$on('hideInfoBox', function () {
60                     hideInfoBox();
61                 });
62             },
63             link: function (scope, element, attrs) {
64                 scope.isActive = false;
65
66                 // methods
67                 scope.closeMenu = closeMenu;
68                 scope.openMenu = openMenu;
69
70                 /**
71                  * Close Yang menu
72                  */
73                 function closeMenu(){
74                     scope.isActive = false;
75                     scope.hideInfoBox();
76                 }
77
78                 /**
79                  * Open Yang menu
80                  */
81                 function openMenu(){
82                     scope.isActive = true;
83                 }
84
85             },
86         };
87     }
88 });