mirror of
https://github.com/nasa/openmct.git
synced 2025-02-06 19:19:23 +00:00
[search] Reverted previous change to ClickAwayController and introduced a custom fix to search menu. Fixes #888 (#1109)
This commit is contained in:
parent
4d89de7068
commit
0274490b68
@ -259,7 +259,7 @@ define([
|
|||||||
"implementation": ClickAwayController,
|
"implementation": ClickAwayController,
|
||||||
"depends": [
|
"depends": [
|
||||||
"$document",
|
"$document",
|
||||||
"$scope"
|
"$timeout"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ define(
|
|||||||
* @param $scope the scope in which this controller is active
|
* @param $scope the scope in which this controller is active
|
||||||
* @param $document the document element, injected by Angular
|
* @param $document the document element, injected by Angular
|
||||||
*/
|
*/
|
||||||
function ClickAwayController($document, $scope) {
|
function ClickAwayController($document, $timeout) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.state = false;
|
this.state = false;
|
||||||
@ -44,7 +44,7 @@ define(
|
|||||||
// `clickaway` action occurs after `toggle` if `toggle` is
|
// `clickaway` action occurs after `toggle` if `toggle` is
|
||||||
// triggered by a click/mouseup.
|
// triggered by a click/mouseup.
|
||||||
this.clickaway = function () {
|
this.clickaway = function () {
|
||||||
$scope.$apply(function () {
|
$timeout(function () {
|
||||||
self.deactivate();
|
self.deactivate();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -33,6 +33,8 @@ define(
|
|||||||
*/
|
*/
|
||||||
function ToggleController() {
|
function ToggleController() {
|
||||||
this.state = false;
|
this.state = false;
|
||||||
|
|
||||||
|
this.setState = this.setState.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ define(
|
|||||||
|
|
||||||
describe("The click-away controller", function () {
|
describe("The click-away controller", function () {
|
||||||
var mockDocument,
|
var mockDocument,
|
||||||
mockScope,
|
mockTimeout,
|
||||||
controller;
|
controller;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@ -34,11 +34,10 @@ define(
|
|||||||
"$document",
|
"$document",
|
||||||
["on", "off"]
|
["on", "off"]
|
||||||
);
|
);
|
||||||
mockScope = jasmine.createSpyObj('$scope', ['$apply']);
|
mockTimeout = jasmine.createSpy('timeout');
|
||||||
|
|
||||||
controller = new ClickAwayController(
|
controller = new ClickAwayController(
|
||||||
mockDocument,
|
mockDocument,
|
||||||
mockScope
|
mockTimeout
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,15 +77,18 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("deactivates and detaches listener on document click", function () {
|
it("deactivates and detaches listener on document click", function () {
|
||||||
var callback, apply;
|
var callback, timeout;
|
||||||
controller.setState(true);
|
controller.setState(true);
|
||||||
callback = mockDocument.on.mostRecentCall.args[1];
|
callback = mockDocument.on.mostRecentCall.args[1];
|
||||||
callback();
|
callback();
|
||||||
apply = mockScope.$apply.mostRecentCall.args[0];
|
timeout = mockTimeout.mostRecentCall.args[0];
|
||||||
apply();
|
timeout();
|
||||||
expect(controller.isActive()).toEqual(false);
|
expect(controller.isActive()).toEqual(false);
|
||||||
expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback);
|
expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
<div ng-controller="SearchMenuController as controller">
|
<div ng-controller="SearchMenuController as controller">
|
||||||
|
|
||||||
<div class="menu checkbox-menu">
|
<div class="menu checkbox-menu"
|
||||||
|
mct-click-elsewhere="parameters.menuVisible(false)">
|
||||||
<ul>
|
<ul>
|
||||||
<!-- First element is special - it's a reset option -->
|
<!-- First element is special - it's a reset option -->
|
||||||
<li class="search-menu-item special icon-asterisk"
|
<li class="search-menu-item special icon-asterisk"
|
||||||
title="Select all filters"
|
title="Select all filters"
|
||||||
ng-click="ngModel.checkAll = !ngModel.checkAll; controller.checkAll()">
|
ng-click="ngModel.checkAll = !ngModel.checkAll; controller.checkAll()">
|
||||||
|
|
||||||
<label class="checkbox custom no-text">
|
<label class="checkbox custom no-text">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
class="checkbox"
|
class="checkbox"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
-->
|
-->
|
||||||
<div class="l-flex-col flex-elem grows holder holder-search" ng-controller="SearchController as controller">
|
<div class="l-flex-col flex-elem grows holder holder-search" ng-controller="SearchController as controller">
|
||||||
<div class="search-bar flex-elem"
|
<div class="search-bar flex-elem"
|
||||||
ng-controller="ClickAwayController as toggle"
|
ng-controller="ToggleController as toggle"
|
||||||
ng-class="{ holder: !(ngModel.input === '' || ngModel.input === undefined) }">
|
ng-class="{ holder: !(ngModel.input === '' || ngModel.input === undefined) }">
|
||||||
<input class="search-input"
|
<input class="search-input"
|
||||||
type="text"
|
type="text"
|
||||||
@ -30,13 +30,17 @@
|
|||||||
<a class="clear-icon clear-input icon-x-in-circle"
|
<a class="clear-icon clear-input icon-x-in-circle"
|
||||||
ng-class="{show: !(ngModel.input === '' || ngModel.input === undefined)}"
|
ng-class="{show: !(ngModel.input === '' || ngModel.input === undefined)}"
|
||||||
ng-click="ngModel.input = ''; controller.search()"></a>
|
ng-click="ngModel.input = ''; controller.search()"></a>
|
||||||
<a class="menu-icon context-available"
|
<!-- To prevent double triggering of clicks on click away, render
|
||||||
|
non-clickable version of the button when menu active-->
|
||||||
|
<a ng-if="!toggle.isActive()" class="menu-icon context-available"
|
||||||
ng-click="toggle.toggle()"></a>
|
ng-click="toggle.toggle()"></a>
|
||||||
|
<a ng-if="toggle.isActive()" class="menu-icon context-available"></a>
|
||||||
|
|
||||||
<mct-include key="'search-menu'"
|
<mct-include key="'search-menu'"
|
||||||
class="menu-element search-menu-holder"
|
class="menu-element search-menu-holder"
|
||||||
ng-class="{off: !toggle.isActive()}"
|
ng-class="{off: !toggle.isActive()}"
|
||||||
ng-model="ngModel"
|
ng-model="ngModel"
|
||||||
ng-click="toggle.setState(true)">
|
parameters="{menuVisible: toggle.setState}">
|
||||||
</mct-include>
|
</mct-include>
|
||||||
</div>
|
</div>
|
||||||
<div class="active-filter-display flex-elem holder"
|
<div class="active-filter-display flex-elem holder"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user