import { Component , Input , ChangeDetectionStrategy , ViewChild , ElementRef , OnInit , OnDestroy , Renderer } from "@angular/core" ; declare var jQuery ; jQuery . fn . fixSidebar = function ( ) { let allModules = jQuery ( this ) ; allModules . each ( function ( ) { let selector = { pusher : ".pusher" } , module = jQuery ( this ) , context = jQuery ( "body" ) ; if ( module . nextAll ( selector . pusher ) . length === 0 ) { module . detach ( ) . prependTo ( context ) ; } } ) ; return this ; } ; link @ Component ( { changeDetection : ChangeDetectionStrategy . OnPush , selector : "sm-sidebar" , template : `<div class="ui sidebar {{class}}" #sidebar>
<ng-content></ng-content>
</div>` } ) export class SemanticSidebarComponent implements OnInit , OnDestroy { @ Input ( ) class : string ; @ ViewChild ( "sidebar" ) sidebar : ElementRef ; constructor ( public renderer ) { } show ( options ? ) { jQuery ( this . sidebar . nativeElement ) . sidebar ( options || { } ) . sidebar ( "toggle" ) ; } hide ( ) { jQuery ( this . sidebar . nativeElement ) . sidebar ( "hide" ) ; } ngOnInit ( ) { jQuery ( this . sidebar . nativeElement ) . fixSidebar ( ) ; } ngOnDestroy ( ) { this . renderer . detachView ( [ this . sidebar . nativeElement ] ) ; } }