mirror of
https://github.com/nasa/openmct.git
synced 2024-12-23 23:12:23 +00:00
[Search] Amended ClickAwayController to trigger digest via instead of . Fixes #1065
This commit is contained in:
parent
652a50c700
commit
59e18b9a79
@ -259,7 +259,7 @@ define([
|
||||
"implementation": ClickAwayController,
|
||||
"depends": [
|
||||
"$document",
|
||||
"$timeout"
|
||||
"$scope"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -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, $timeout) {
|
||||
function ClickAwayController($document, $scope) {
|
||||
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 () {
|
||||
$timeout(function () {
|
||||
$scope.$apply(function () {
|
||||
self.deactivate();
|
||||
});
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ define(
|
||||
|
||||
describe("The click-away controller", function () {
|
||||
var mockDocument,
|
||||
mockTimeout,
|
||||
mockScope,
|
||||
controller;
|
||||
|
||||
beforeEach(function () {
|
||||
@ -34,10 +34,11 @@ define(
|
||||
"$document",
|
||||
["on", "off"]
|
||||
);
|
||||
mockTimeout = jasmine.createSpy('timeout');
|
||||
mockScope = jasmine.createSpyObj('$scope', ['$apply']);
|
||||
|
||||
controller = new ClickAwayController(
|
||||
mockDocument,
|
||||
mockTimeout
|
||||
mockScope
|
||||
);
|
||||
});
|
||||
|
||||
@ -77,18 +78,15 @@ define(
|
||||
});
|
||||
|
||||
it("deactivates and detaches listener on document click", function () {
|
||||
var callback, timeout;
|
||||
var callback, apply;
|
||||
controller.setState(true);
|
||||
callback = mockDocument.on.mostRecentCall.args[1];
|
||||
callback();
|
||||
timeout = mockTimeout.mostRecentCall.args[0];
|
||||
timeout();
|
||||
apply = mockScope.$apply.mostRecentCall.args[0];
|
||||
apply();
|
||||
expect(controller.isActive()).toEqual(false);
|
||||
expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user