Skip to content

Commit

Permalink
Fixed #5180
Browse files Browse the repository at this point in the history
  • Loading branch information
Merve7 committed Feb 20, 2018
1 parent b3e3c45 commit cec0efe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/app/components/common/menuitem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface MenuItem {
styleClass?:string;
title?: string;
id?: string;
automationId?: any;
}
14 changes: 7 additions & 7 deletions src/app/components/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {RouterModule} from '@angular/router';
@Component({
selector: '[pMenuItemContent]',
template: `
<a *ngIf="!item.routerLink" [href]="item.url||'#'" class="ui-menuitem-link ui-corner-all" [attr.target]="item.target" [attr.title]="item.title" [attr.id]="item.id"
<a *ngIf="!item.routerLink" [href]="item.url||'#'" class="ui-menuitem-link ui-corner-all" [attr.data-automationid]="item.automationId" [attr.target]="item.target" [attr.title]="item.title" [attr.id]="item.id"
[ngClass]="{'ui-state-disabled':item.disabled}" (click)="menu.itemClick($event, item)">
<span class="ui-menuitem-icon fa fa-fw" *ngIf="item.icon" [ngClass]="item.icon"></span>
<span class="ui-menuitem-text">{{item.label}}</span>
</a>
<a *ngIf="item.routerLink" [routerLink]="item.routerLink" [queryParams]="item.queryParams" [routerLinkActive]="'ui-state-active'"
<a *ngIf="item.routerLink" [routerLink]="item.routerLink" [attr.data-automationid]="item.automationId" [queryParams]="item.queryParams" [routerLinkActive]="'ui-state-active'"
[routerLinkActiveOptions]="item.routerLinkActiveOptions||{exact:false}" class="ui-menuitem-link ui-corner-all" [attr.target]="item.target" [attr.id]="item.id"
[attr.title]="item.title" [ngClass]="{'ui-state-disabled':item.disabled}" (click)="menu.itemClick($event, item)">
<span class="ui-menuitem-icon fa fa-fw" *ngIf="item.icon" [ngClass]="item.icon"></span>
Expand All @@ -23,19 +23,19 @@ import {RouterModule} from '@angular/router';
export class MenuItemContent {

@Input("pMenuItemContent") item: MenuItem;

constructor(@Inject(forwardRef(() => Menu)) public menu: Menu) {}
}

@Component({
selector: 'p-menu',
template: `
<div #container [ngClass]="{'ui-menu ui-widget ui-widget-content ui-corner-all':true, 'ui-menu-dynamic ui-shadow':popup}"
<div #container [ngClass]="{'ui-menu ui-widget ui-widget-content ui-corner-all':true, 'ui-menu-dynamic ui-shadow':popup}"
[class]="styleClass" [ngStyle]="style" (click)="preventDocumentDefault=true">
<ul>
<ng-template ngFor let-submenu [ngForOf]="model" *ngIf="hasSubMenu()">
<li class="ui-menu-separator ui-widget-content" *ngIf="submenu.separator" [ngClass]="{'ui-helper-hidden': submenu.visible === false}"></li>
<li class="ui-submenu-header ui-widget-header ui-corner-all" *ngIf="!submenu.separator" [ngClass]="{'ui-helper-hidden': submenu.visible === false}">{{submenu.label}}</li>
<li class="ui-submenu-header ui-widget-header ui-corner-all" [attr.data-automationid]="submenu.automationId" *ngIf="!submenu.separator" [ngClass]="{'ui-helper-hidden': submenu.visible === false}">{{submenu.label}}</li>
<ng-template ngFor let-item [ngForOf]="submenu.items">
<li class="ui-menu-separator ui-widget-content" *ngIf="item.separator" [ngClass]="{'ui-helper-hidden': (item.visible === false || submenu.visible === false)}"></li>
<li class="ui-menuitem ui-widget ui-corner-all" *ngIf="!item.separator" [pMenuItemContent]="item" [ngClass]="{'ui-helper-hidden': (item.visible === false || submenu.visible === false)}"></li>
Expand Down Expand Up @@ -89,7 +89,7 @@ export class Menu implements AfterViewInit,OnDestroy {
else
this.domHandler.appendChild(this.container, this.appendTo);
}

this.documentClickListener = this.renderer.listen('document', 'click', () => {
if(!this.preventDocumentDefault) {
this.hide();
Expand Down Expand Up @@ -185,4 +185,4 @@ export class Menu implements AfterViewInit,OnDestroy {
exports: [Menu,RouterModule],
declarations: [Menu,MenuItemContent]
})
export class MenuModule { }
export class MenuModule { }
4 changes: 2 additions & 2 deletions src/app/components/menubar/menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { RouterModule } from '@angular/router';
<li *ngIf="!child.separator" #listItem [ngClass]="{'ui-menuitem ui-corner-all':true,
'ui-menu-parent':child.items,'ui-menuitem-active':listItem==activeItem,'ui-helper-hidden': child.visible === false}"
(mouseenter)="onItemMouseEnter($event,listItem,child)" (mouseleave)="onItemMouseLeave($event)" (click)="onItemMenuClick($event, listItem, child)">
<a *ngIf="!child.routerLink" [href]="child.url||'#'" [attr.target]="child.target" [attr.title]="child.title" [attr.id]="child.id" (click)="itemClick($event, child)"
<a *ngIf="!child.routerLink" [href]="child.url||'#'" [attr.data-automationid]="child.automationId" [attr.target]="child.target" [attr.title]="child.title" [attr.id]="child.id" (click)="itemClick($event, child)"
[ngClass]="{'ui-menuitem-link ui-corner-all':true,'ui-state-disabled':child.disabled}" [ngStyle]="child.style" [class]="child.styleClass">
<span class="ui-menuitem-icon fa fa-fw" *ngIf="child.icon" [ngClass]="child.icon"></span>
<span class="ui-menuitem-text">{{child.label}}</span>
<span class="ui-submenu-icon fa fa-fw" *ngIf="child.items" [ngClass]="{'fa-caret-down':root,'fa-caret-right':!root}"></span>
</a>
<a *ngIf="child.routerLink" [routerLink]="child.routerLink" [queryParams]="child.queryParams" [routerLinkActive]="'ui-state-active'" [routerLinkActiveOptions]="child.routerLinkActiveOptions||{exact:false}"
<a *ngIf="child.routerLink" [routerLink]="child.routerLink" [attr.data-automationid]="child.automationId" [queryParams]="child.queryParams" [routerLinkActive]="'ui-state-active'" [routerLinkActiveOptions]="child.routerLinkActiveOptions||{exact:false}"
[attr.target]="child.target" [attr.title]="child.title" [attr.id]="child.id"
(click)="itemClick($event, child)" [ngClass]="{'ui-menuitem-link ui-corner-all':true,'ui-state-disabled':child.disabled}" [ngStyle]="child.style" [class]="child.styleClass">
<span class="ui-menuitem-icon fa fa-fw" *ngIf="child.icon" [ngClass]="child.icon"></span>
Expand Down
14 changes: 10 additions & 4 deletions src/app/showcase/components/menumodel/menumodeldemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3 class="first">MenuItem</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MenuDemo &#123;

private items: MenuItem[];

ngOnInit() &#123;
Expand Down Expand Up @@ -175,16 +175,22 @@ <h3 class="first">MenuItem</h3>
<td>null</td>
<td>Tooltip text of the item.</td>
</tr>
<tr>
<td>automationId</td>
<td>any</td>
<td>null</td>
<td>Value of HTML data-* attribute.</td>
</tr>
</tbody>
</table>
</div>

<h4>Command</h4>
<p>The function to invoke when an item is clicked is defined using the command property.</p>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MenuDemo &#123;

private items: MenuItem[];

ngOnInit() &#123;
Expand All @@ -208,7 +214,7 @@ <h4>Navigation</h4>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MenuDemo &#123;

private items: MenuItem[];

ngOnInit() &#123;
Expand Down

0 comments on commit cec0efe

Please sign in to comment.