diff --git a/brewman/brewman/static/offline.appcache b/brewman/brewman/static/offline.appcache index cd92621f..b4fcc144 100644 --- a/brewman/brewman/static/offline.appcache +++ b/brewman/brewman/static/offline.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version 2013-05-18.1 +# version 2013-05-18.2 CACHE: /partial/404.html diff --git a/brewman/brewman/static/scripts/angular_directive.js b/brewman/brewman/static/scripts/angular_directive.js index 283648e8..0893012a 100644 --- a/brewman/brewman/static/scripts/angular_directive.js +++ b/brewman/brewman/static/scripts/angular_directive.js @@ -5,24 +5,32 @@ overlord_directive.directive('ngAutocomplete', ['$q', '$parse', 'DeepLabel', fun return { restrict: 'A', link: function (scope, element, attrs, ngModel) { - var labels = [], + var labelsCache = {}, + mappedCache = {}, + labels = [], mapped = {}, deepLabel = DeepLabel; - - element.typeahead({ source: function (query, process) { - var Entity = angular.injector(['overlord.service']).get(attrs.resource); - Entity.autocomplete({term: query, count: 20}, function (result) { - labels = []; - mapped = {}; - $.each(result, function (i, item) { - var label = deepLabel(item, attrs.label); - mapped[label] = item - labels.push(label) - }) - process(labels) - }); + if (query in labelsCache) { + labels = labelsCache[query]; + mapped = mappedCache[query]; + process(labels); + } else { + var Entity = angular.injector(['overlord.service']).get(attrs.resource); + Entity.autocomplete({term: query, count: 20}, function (result) { + labels = []; + mapped = {}; + $.each(result, function (i, item) { + var label = deepLabel(item, attrs.label); + mapped[label] = item + labels.push(label) + }) + labelsCache[query] = labels; + mappedCache[query] = mapped; + process(labels) + }); + } }, minLength: 1, items: 20,