From ef8fde5c6fa70c2d91a6df5e927e4c280aed568f Mon Sep 17 00:00:00 2001 From: Will Abson Date: Fri, 10 Jun 2016 16:08:57 +0100 Subject: [PATCH] Workaround for search box viewer instance not appearing on result click Refs #173 --- .../src/viewer.component.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts b/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts index c2032ca057..cc4e6f3e5d 100644 --- a/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts +++ b/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts @@ -15,7 +15,7 @@ * 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 { PdfViewerComponent } from './pdfViewer.component'; import { NotSupportedFormat } from './notSupportedFormat.component'; @@ -59,6 +59,9 @@ export class ViewerComponent { extension: string; + constructor(private element: ElementRef) { + } + ngOnChanges(changes) { if (this.showViewer) { 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() { - if (this.overlayMode) { + if (this.overlayMode && !this.closestElement(this.element.nativeElement, 'header')) { this.otherMenu = document.querySelector('header'); if (this.otherMenu) { this.otherMenu.hidden = true;