[General] remove dupe, debounce inputs

Remove duplicate ClickAwayController implementation that was obscuring actual
implementation.  Debounce clickaway action in case toggle is invoked in a
click handler.

Resolves https://github.com/nasa/openmct/issues/888
This commit is contained in:
Pete Richards
2016-05-05 18:25:37 -07:00
parent 01f290dc45
commit 7fad4e9ea1
6 changed files with 22 additions and 230 deletions

View File

@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
/*global define,describe,it,expect,beforeEach,jasmine*/
define(
["../../src/controllers/ClickAwayController"],
@ -27,20 +27,20 @@ define(
"use strict";
describe("The click-away controller", function () {
var mockScope,
mockDocument,
var mockDocument,
mockTimeout,
controller;
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$apply" ]
);
mockDocument = jasmine.createSpyObj(
"$document",
[ "on", "off" ]
);
controller = new ClickAwayController(mockScope, mockDocument);
mockTimeout = jasmine.createSpy('timeout');
controller = new ClickAwayController(
mockDocument,
mockTimeout
);
});
it("is initially inactive", function () {
@ -79,10 +79,12 @@ define(
});
it("deactivates and detaches listener on document click", function () {
var callback;
var callback, timeout;
controller.setState(true);
callback = mockDocument.on.mostRecentCall.args[1];
callback();
timeout = mockTimeout.mostRecentCall.args[0];
timeout();
expect(controller.isActive()).toEqual(false);
expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback);
});
@ -91,4 +93,4 @@ define(
});
}
);
);