Skip to content

Commit

Permalink
Merge f7223a8 into ad2a0a9
Browse files Browse the repository at this point in the history
  • Loading branch information
dioxmio committed Apr 14, 2016
2 parents ad2a0a9 + f7223a8 commit 6eb5303
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 41 deletions.
3 changes: 3 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"angular": "~1.2.18",
"angular-mocks": "~1.2.18",
"angular-ui-tinymce": "latest"
},
"resolutions": {
"angular": "~1.2.18"
}
}
86 changes: 45 additions & 41 deletions src/mentio.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,54 +194,58 @@ angular.module('mentio', [])
}
);

$document.on(
'click', function () {
if ($scope.isActive()) {
$scope.$apply(function () {
$scope.hideAll();
});
}
function clickElement() {
if ($scope.isActive()) {
$scope.$apply(function () {
$scope.hideAll();
});
}
);

$document.on(
'keydown keypress paste', function (event) {
var activeMenuScope = $scope.getActiveMenuScope();
if (activeMenuScope) {
if (event.which === 9 || event.which === 13) {
event.preventDefault();
activeMenuScope.selectActive();
}
}

if (event.which === 27) {
event.preventDefault();
activeMenuScope.$apply(function () {
activeMenuScope.hideMenu();
});
}
function keypressElement(event) {
var activeMenuScope = $scope.getActiveMenuScope();
if (activeMenuScope) {
if (event.which === 9 || event.which === 13) {
event.preventDefault();
activeMenuScope.selectActive();
}

if (event.which === 40) {
event.preventDefault();
activeMenuScope.$apply(function () {
activeMenuScope.activateNextItem();
});
activeMenuScope.adjustScroll(1);
}
if (event.which === 27) {
event.preventDefault();
activeMenuScope.$apply(function () {
activeMenuScope.hideMenu();
});
}

if (event.which === 38) {
event.preventDefault();
activeMenuScope.$apply(function () {
activeMenuScope.activatePreviousItem();
});
activeMenuScope.adjustScroll(-1);
}
if (event.which === 40) {
event.preventDefault();
activeMenuScope.$apply(function () {
activeMenuScope.activateNextItem();
});
activeMenuScope.adjustScroll(1);
}

if (event.which === 37 || event.which === 39) {
event.preventDefault();
}
if (event.which === 38) {
event.preventDefault();
activeMenuScope.$apply(function () {
activeMenuScope.activatePreviousItem();
});
activeMenuScope.adjustScroll(-1);
}

if (event.which === 37 || event.which === 39) {
event.preventDefault();
}
}
);
}

$document.on('click', clickElement);
$document.on('keydown keypress paste', keypressElement);

$scope.$on('$destroy', function() {
$document.off('click', clickElement);
$document.off('keydown keypress paste', keypressElement);
});
},
link: function (scope, element, attrs) {
scope.triggerCharMap = {};
Expand Down

0 comments on commit 6eb5303

Please sign in to comment.