Sha256: 5b75775eec809bbdb270245706a88a7683c2730b6893c1dc427b4d7a72b2f838

Contents?: true

Size: 1.79 KB

Versions: 248

Compression:

Stored size: 1.79 KB

Contents

/**
 * @ngdoc directive
 * @name Bastion.components.directive:bstMenu
 * @restrict EA
 * @requires $window
 *
 * @description
 *   Provides a menu.
 */
angular.module('Bastion.components').directive('bstMenu', ['$window', function ($window) {
    return {
        restrict: 'EA',
        replace: true,
        scope: {
            'menu': '=bstMenu',
            'compact': '@'
        },
        templateUrl: 'components/views/bst-menu.html',
        controller: ['$scope', function ($scope) {
            $scope.dropdown = {};

            $scope.handleHover = function (item, mousein) {
                if (item.type === 'dropdown' && mousein) {
                    item.active = true;
                    $scope.dropdown = item.items;
                    $scope.dropdown.show = true;
                    $scope.dropdown.direction = $scope.menu.location;
                } else {
                    $scope.dropdown.show = false;

                    if (item !== $scope.menu.activeItem) {
                        item.active = false;
                    }
                }
            };

        }],
        link: function (scope, element, attrs) {
            var elementOriginalOffset;

            if (angular.isDefined(attrs.compact)) {
                elementOriginalOffset = angular.element(element).offset().top;

                angular.element($window).bind('scroll', function () {
                    var windowScrollTop = angular.element($window).scrollTop();

                    if (windowScrollTop > elementOriginalOffset + 2) {
                        element.parent().addClass('compact');
                    } else if (windowScrollTop < elementOriginalOffset) {
                        element.parent().removeClass('compact');
                    }
                });
            }
        }
    };
}]);

Version data entries

248 entries across 248 versions & 2 rubygems

Version Path
katello-4.14.2 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.15.0 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.15.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.15.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.14.1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.14.0 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.14.0.rc3 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.14.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.14.0.rc1.1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.14.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.13.1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.13.0 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.12.1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.13.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.12.0 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.12.0.rc3 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.12.0.rc2 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.12.0.rc1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.11.1 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js
katello-4.11.0 engines/bastion/app/assets/javascripts/bastion/components/bst-menu.directive.js