From 612484c0b66506fb40bb4e018089d261eb8beeaf Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 31 Jul 2015 12:52:29 +0200 Subject: [PATCH] ensures more jquery event listeners are unbound --- .../directives/editors/umbAutoResize.directive.js | 2 +- .../common/directives/util/detectfold.directive.js | 12 ++++++------ .../googlemaps/googlemaps.controller.js | 8 +++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js index 73a6848972..b79f738f28 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js @@ -27,7 +27,7 @@ angular.module("umbraco.directives") $('a[data-toggle="tab"]').on('shown', update); scope.$on('$destroy', function() { - $('a[data-toggle="tab"]').unbind("shown", update); + $('a[data-toggle="tab"]').off("shown", update); }); }; }); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js index addcaea854..b7f01a1a44 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js @@ -6,7 +6,8 @@ **/ angular.module("umbraco.directives.html") .directive('detectFold', function ($timeout, $log, windowResizeListener) { - return { + return { + require: "^?umbTabs", restrict: 'A', link: function (scope, el, attrs) { @@ -33,15 +34,14 @@ angular.module("umbraco.directives.html") windowResizeListener.register(resizeCallback); - //TODO: Need to listen for tabs - - $('a[data-toggle="tab"]').on('shown', function (e) { - calculate(); - }); + + //Required for backwards compat for bootstrap tabs + $('a[data-toggle="tab"]').on('shown', calculate); //ensure to unregister scope.$on('$destroy', function() { windowResizeListener.unregister(resizeCallback); + $('a[data-toggle="tab"]').off('shown', calculate); }); } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/googlemaps/googlemaps.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/googlemaps/googlemaps.controller.js index bb9a3b3e7d..fe788d2e67 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/googlemaps/googlemaps.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/googlemaps/googlemaps.controller.js @@ -58,8 +58,14 @@ angular.module("umbraco") }); }); - $('a[data-toggle="tab"]').on('shown', function (e) { + var tabShown = function(e) { google.maps.event.trigger(map, 'resize'); + }; + + $('a[data-toggle="tab"]').on('shown', tabShown); + + $scope.$on('$destroy', function () { + $('a[data-toggle="tab"]').off('shown', tabShown); }); }