{"size": 2684, "ext": "js", "max_stars_repo_path": "app/components/helpMenu.js", "max_stars_repo_name": "maumad/WebtroPie", "max_stars_repo_stars_event_min_datetime": "2022-02-19T19:20:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-19T19:20:04.000Z", "max_issues_repo_path": "app/components/helpMenu.js", "max_issues_repo_name": "maumad/WebtroPie", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/components/helpMenu.js", "max_forks_repo_name": "maumad/WebtroPie", "max_forks_repo_forks_event_min_datetime": "2019-09-07T12:32:21.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-07T12:32:21.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 34.8571428571, "max_line_length": 112, "alphanum_fraction": 0.4284649776}
/**
 * helpMenu.js
 *
 * Horizontal menu with dropdown/dropup submenus generated from menu array
 * 
 * inputs
 *     list : contains menu configuration, array of menu options
 *     obj : Theme configuration object for the helpmenu (position, font, etc.)
 */
(function() {

    'use strict';

    angular
        .module('WebtroPie.components')
        .directive('helpMenu', helpMenu);

    function helpMenu()
    {
        var directive = {
            restrict: 'E',
            replace: true,
            scope: true,
            transclude: true,
            template: '<div class="helpsystembar" ng-style="vm.obj.style">'+
                          '<span ng-repeat="item in vm.list" class="dropdown"'+
                                  ' ng-click="item.click()"'+
                                  ' ng-mouseover="hover=true"'+
                                  ' ng-mouseout="hover=false"'+
                                  ' ng-show="vm.show(item)">'+
                              '<div class="filters" help-inverter>'+
                                  '<icon svg="item.svg" color="item.color||obj.iconcolor.hex"></icon>'+
                                  "{{item.langButton?' '+app.config.lang.button[item.langButton]:''}}"+
                              '</div>'+
                              '<div ng-class="app.styler.helpMenuOptionClasses"'+
                                    ' ng-style="app.styler.helpTextColorBorder"'+
                                    ' ng-show="hover && item.menu"'+
                                    ' ng-click="hover=false">'+
                                 '<a ng-repeat="option in item.menu" help-inverter'+
                                    ' ng-click="option.click()" >{{app.config.lang[vm.view][option.text]}}</a>'+
                              '</div>'+
                          '</span>'+
                          '<ng-transclude></ng-transclude>'+
                      '</div>',
            controller: controller,
            controllerAs: 'vm',
            bindToController: { list: '=', obj: '=', view: '@' },
        };
        return directive;
    }

    controller.$inject = ['$scope'];

    function controller($scope)
    {
        var vm = this;
        vm.show = show;

        // show when either there is no show expression
        // or when show expression is true
        function show(item)
        {
            if (!item)
            {
                return false;
            }
            else if (!item.show) // no show expression
            {
                return true;
            }
            $scope.$eval('result=' + item.show);
            return $scope.result;
        }
    }

})();
