[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*/
/*global define*/
define(
[],
@ -36,20 +36,19 @@ define(
* @param $scope the scope in which this controller is active
* @param $document the document element, injected by Angular
*/
function ClickAwayController($scope, $document) {
function ClickAwayController($document, $timeout) {
var self = this;
this.state = false;
this.$scope = $scope;
this.$document = $document;
// Callback used by the document listener. Deactivates;
// note also $scope.$apply is invoked to indicate that
// the state of this controller has changed.
// Callback used by the document listener. Timeout ensures that
// `clickaway` action occurs after `toggle` if `toggle` is
// triggered by a click/mouseup.
this.clickaway = function () {
self.deactivate();
$scope.$apply();
return false;
$timeout(function () {
self.deactivate();
});
};
}