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