Workaround for search box viewer instance not appearing on result click

Refs #173
This commit is contained in:
Will Abson 2016-06-10 16:08:57 +01:00
parent 0028f91fd4
commit ef8fde5c6f

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { Component, Input, Output, HostListener } from 'angular2/core'; import { Component, ElementRef, Input, Output, HostListener } from 'angular2/core';
import { EventEmitter } from 'angular2/src/facade/async'; import { EventEmitter } from 'angular2/src/facade/async';
import { PdfViewerComponent } from './pdfViewer.component'; import { PdfViewerComponent } from './pdfViewer.component';
import { NotSupportedFormat } from './notSupportedFormat.component'; import { NotSupportedFormat } from './notSupportedFormat.component';
@ -59,6 +59,9 @@ export class ViewerComponent {
extension: string; extension: string;
constructor(private element: ElementRef) {
}
ngOnChanges(changes) { ngOnChanges(changes) {
if (this.showViewer) { if (this.showViewer) {
this.hideOtherMenu(); this.hideOtherMenu();
@ -158,11 +161,24 @@ export class ViewerComponent {
} }
} }
private closestElement(el: HTMLElement, nodeName: string) {
let parent = el.parentElement;
if (parent) {
if (parent.nodeName.toLowerCase() === nodeName) {
return parent;
} else {
return this.closestElement(parent, nodeName);
}
} else {
return null;
}
}
/** /**
* Hide the othe possible menu in th eapplication * Hide the other possible menu in the application
*/ */
private hideOtherMenu() { private hideOtherMenu() {
if (this.overlayMode) { if (this.overlayMode && !this.closestElement(this.element.nativeElement, 'header')) {
this.otherMenu = document.querySelector('header'); this.otherMenu = document.querySelector('header');
if (this.otherMenu) { if (this.otherMenu) {
this.otherMenu.hidden = true; this.otherMenu.hidden = true;