diff --git a/platform/commonUI/general/bundle.js b/platform/commonUI/general/bundle.js index b2eccc1732..1ec3c5a1f4 100644 --- a/platform/commonUI/general/bundle.js +++ b/platform/commonUI/general/bundle.js @@ -259,7 +259,7 @@ define([ "implementation": ClickAwayController, "depends": [ "$document", - "$scope" + "$timeout" ] }, { diff --git a/platform/commonUI/general/src/controllers/ClickAwayController.js b/platform/commonUI/general/src/controllers/ClickAwayController.js index 94ae71c2ea..6a01c528e9 100644 --- a/platform/commonUI/general/src/controllers/ClickAwayController.js +++ b/platform/commonUI/general/src/controllers/ClickAwayController.js @@ -34,7 +34,7 @@ define( * @param $scope the scope in which this controller is active * @param $document the document element, injected by Angular */ - function ClickAwayController($document, $scope) { + function ClickAwayController($document, $timeout) { var self = this; this.state = false; @@ -44,7 +44,7 @@ define( // `clickaway` action occurs after `toggle` if `toggle` is // triggered by a click/mouseup. this.clickaway = function () { - $scope.$apply(function () { + $timeout(function () { self.deactivate(); }); }; diff --git a/platform/commonUI/general/src/controllers/ToggleController.js b/platform/commonUI/general/src/controllers/ToggleController.js index 728d912c9a..8930c7fef2 100644 --- a/platform/commonUI/general/src/controllers/ToggleController.js +++ b/platform/commonUI/general/src/controllers/ToggleController.js @@ -33,6 +33,8 @@ define( */ function ToggleController() { this.state = false; + + this.setState = this.setState.bind(this); } /** diff --git a/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js b/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js index 8edf90e2c6..22b4035919 100644 --- a/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js @@ -26,7 +26,7 @@ define( describe("The click-away controller", function () { var mockDocument, - mockScope, + mockTimeout, controller; beforeEach(function () { @@ -34,11 +34,10 @@ define( "$document", ["on", "off"] ); - mockScope = jasmine.createSpyObj('$scope', ['$apply']); - + mockTimeout = jasmine.createSpy('timeout'); controller = new ClickAwayController( mockDocument, - mockScope + mockTimeout ); }); @@ -78,15 +77,18 @@ define( }); it("deactivates and detaches listener on document click", function () { - var callback, apply; + var callback, timeout; controller.setState(true); callback = mockDocument.on.mostRecentCall.args[1]; callback(); - apply = mockScope.$apply.mostRecentCall.args[0]; - apply(); + timeout = mockTimeout.mostRecentCall.args[0]; + timeout(); expect(controller.isActive()).toEqual(false); expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback); }); + + + }); } ); diff --git a/platform/search/res/templates/search-menu.html b/platform/search/res/templates/search-menu.html index e051071f0d..daa350a77b 100644 --- a/platform/search/res/templates/search-menu.html +++ b/platform/search/res/templates/search-menu.html @@ -22,13 +22,13 @@