"use strict"; /** * Created by sohan rao on 11/20/2015. */ (function () { 'use strict'; angular.module('myitsmApp') .directive('nestedDropdown', ['events', function (events) { return { restrict: 'E', replace: true, templateUrl: 'views/common/nested-dropdown.html', scope: { dropdownOptions: '=', selectedOption: '=' }, link: function init(scope) { scope.isOpen = false; scope.toggleMode = false; scope.toggleDropdown = function () { scope.toggleMode = true; scope.isOpen = !scope.isOpen; }; scope.selectOption = function (option) { scope.selectedOption = option; scope.isOpen = false; }; scope.$on(events.ASSET_CONSOLE_FILTER_CLICK, function (event, evt) { if (!evt) { if (!scope.toggleMode) { scope.$apply(function () { scope.isOpen = false; }); } else { scope.toggleMode = false; } } else { if (scope.isOpen) { if (evt.which === 40) { $(evt.target).next()[0].focus(); } else if (evt.which === 38) { $(evt.target).prev()[0].focus(); } } } }); } }; }]); }());