Commit 97e5a046 by Torkel Ödegaard

Fixed memory leak in bootstrap Typeahead code, Fixes #1497

parent 7293ee08
......@@ -37,14 +37,6 @@ function (angular, $, config) {
var getter = $parse(attr.type), panelType = getter($scope);
var newScope = $scope.$new();
$scope.kbnJqUiDraggableOptions = {
revert: 'invalid',
helper: function() {
return $('<div style="width:200px;height:100px;background: rgba(100,100,100,0.50);"/>');
},
placeholder: 'keep'
};
// compile the module and uncloack. We're done
function loadModule($module) {
$module.appendTo(elem);
......
......@@ -75,6 +75,11 @@ function (angular, app, _, $) {
$button.focus();
});
$scope.$on('$destroy', function() {
$button.unbind();
typeahead.destroy();
});
$compile(elem.contents())($scope);
}
};
......
......@@ -31,13 +31,6 @@ function (angular, $, config, _) {
$scope.setupDashboard(dashboardData);
};
$scope.registerWindowResizeEvent = function() {
angular.element(window).bind('resize', function() {
$timeout.cancel(resizeEventTimeout);
resizeEventTimeout = $timeout(function() { $scope.$broadcast('render'); }, 200);
});
};
$scope.setupDashboard = function(dashboardData) {
$rootScope.performance.dashboardLoadStart = new Date().getTime();
$rootScope.performance.panelsInitialized = 0;
......@@ -127,5 +120,15 @@ function (angular, $, config, _) {
$rootScope.$broadcast('render');
};
$scope.registerWindowResizeEvent = function() {
angular.element(window).bind('resize', function() {
$timeout.cancel(resizeEventTimeout);
resizeEventTimeout = $timeout(function() { $scope.$broadcast('render'); }, 200);
});
$scope.$on('$destroy', function() {
angular.element(window).unbind('resize');
});
};
});
});
......@@ -2050,6 +2050,11 @@
.on('click', $.proxy(this.click, this))
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
.on('mouseleave', 'li', $.proxy(this.mouseleave, this))
},
destroy: function () {
this.$element.off().removeData('typeahead');
this.$menu.off();
}
, eventSupported: function(eventName) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment