From e4f2021e12224e75693d9d230001f5d363c290fd Mon Sep 17 00:00:00 2001 From: Adrian Lee Date: Tue, 8 Oct 2013 12:40:14 -0700 Subject: [PATCH] feature(macAutocomplete): Uses $animate to append menu. Menu scope is fully isolated to prevent affecting $rootScope. BREAKING CHANGE: Changed autocomplete event from resetAutocomplete to reset-mac-autocomplete Related to #124 --- src/directives/autocomplete.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/directives/autocomplete.coffee b/src/directives/autocomplete.coffee index bdb8802..eee97a6 100644 --- a/src/directives/autocomplete.coffee +++ b/src/directives/autocomplete.coffee @@ -29,6 +29,7 @@ A directive for providing suggestions while typing into the field ### angular.module("Mac").directive "macAutocomplete", [ + "$animate" "$http" "$filter" "$compile" @@ -36,7 +37,7 @@ angular.module("Mac").directive "macAutocomplete", [ "$parse" "$rootScope" "keys" - ($http, $filter, $compile, $timeout, $parse, $rootScope, keys) -> + ($animate, $http, $filter, $compile, $timeout, $parse, $rootScope, keys) -> restrict: "E" templateUrl: "template/autocomplete.html" replace: true @@ -59,7 +60,7 @@ angular.module("Mac").directive "macAutocomplete", [ timeoutId = null onSelectBool = false - $menuScope = $rootScope.$new() + $menuScope = $rootScope.$new(true) $menuScope.items = [] $menuScope.index = 0 @@ -76,8 +77,8 @@ angular.module("Mac").directive "macAutocomplete", [ # If value is more than an empty string, # autocomplete is enabled and not 'onSelect' cycle if value and not disabled($scope) and not onSelectBool + $timeout.cancel timeoutId if timeoutId? if delay > 0 - $timeout.cancel timeoutId if timeoutId? timeoutId = $timeout -> queryData value , delay @@ -217,9 +218,9 @@ angular.module("Mac").directive "macAutocomplete", [ # # @event - # @name resetAutocomplete + # @name reset-mac-autocomplete # @description # Event to reset autocomplete # - $scope.$on "resetAutocomplete", -> reset() + $scope.$on "reset-mac-autocomplete", -> reset() ]