Skip to content

Commit

Permalink
feat(): make LayoutToggle class reuse disable mixin (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
emoralesb05 authored Dec 13, 2017
1 parent 7fda8c2 commit d42825f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/platform/core/layout/layout-toggle.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Input, HostBinding, HostListener, Renderer2, ElementRef, AfterViewInit,

import { MatSidenav } from '@angular/material/sidenav';

import { ICanDisable, mixinDisabled } from '../common/common.module';

import { Subscription } from 'rxjs/Subscription';

export interface ILayoutTogglable {
Expand All @@ -12,18 +14,18 @@ export interface ILayoutTogglable {
close(): Promise<void>;
}

export abstract class LayoutToggle implements AfterViewInit, OnDestroy {
export class LayoutToggleBase { }

/* tslint:disable-next-line */
export const _TdLayoutToggleMixinBase = mixinDisabled(LayoutToggleBase);

export abstract class LayoutToggle extends _TdLayoutToggleMixinBase implements AfterViewInit, OnDestroy, ICanDisable {

private _toggleSubs: Subscription;

private _initialized: boolean = false;
private _disabled: boolean = false;
private _hideWhenOpened: boolean = false;

set disabled(disabled: boolean) {
this._disabled = disabled;
}

/**
* hideWhenOpened?: boolean
* When this is set to true, the host will be hidden when
Expand All @@ -40,6 +42,7 @@ export abstract class LayoutToggle implements AfterViewInit, OnDestroy {
constructor(protected _layout: ILayoutTogglable,
private _renderer: Renderer2,
private _elementRef: ElementRef) {
super();
this._renderer.addClass(this._elementRef.nativeElement, 'td-layout-menu-button');
}

Expand All @@ -66,7 +69,7 @@ export abstract class LayoutToggle implements AfterViewInit, OnDestroy {
@HostListener('click', ['$event'])
clickListener(event: Event): void {
event.preventDefault();
if (!this._disabled) {
if (!this.disabled) {
this.onClick();
}
}
Expand Down

0 comments on commit d42825f

Please sign in to comment.