Sha256: 75e67cefec8f512bb8906ca3331fcd4112d39567e0ff3a140302b9bcc2c401d5
Contents?: true
Size: 1.75 KB
Versions: 9
Compression:
Stored size: 1.75 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 (attrs.compact !== undefined) { elementOriginalOffset = $(element).offset().top; angular.element($window).bind('scroll', function () { var windowScrollTop = $($window).scrollTop(); if (windowScrollTop > elementOriginalOffset + 2) { element.parent().addClass('compact'); } else if (windowScrollTop < elementOriginalOffset) { element.parent().removeClass('compact'); } }); } } }; }]);
Version data entries
9 entries across 9 versions & 1 rubygems