import { Component, ElementRef, OnInit, Input, Output, EventEmitter, HostBinding } from '@angular/core'; import { FabModel } from '../../models/fab/fab.model'; import { FabButtonModel } from '../../models/fab/fab-button.model'; import { CfCoreComponent } from '../core/core.component'; @Component({ selector: 'cf-fab', template: " ", styles: [":host { position: relative; z-index: 0; } "] }) export class CfFabComponent extends CfCoreComponent implements OnInit { /** * It is property to attach notification class when component has notifications actions. */ @HostBinding('class') notifacationClickable = ''; /** *

It is Object which will recive data from FabModel Class. It is used in cf-fab template.

*

Example:

*
{
   *  direction: "down",
   *  showButtons: true,
   *  stayOpened: true,
   *  triggerButton: { icon: {name: 'fa-gear'} },
   *  actionButtons: [
   *    { icon: {name:"fa-apple"}, display: this.shown },
   *    { icon: {name:"fa-star"}, label: "Item", labelPosition: "left" },
   *    { icon: {name:"fa-home"}, disabled: this.disabled }
   *  ]
   * }
*

direction: string

* It is direction of opening Fab action buttons. Optional. Default must be set in file: /src/assets/settings/fab/settings.ts. Can be: 'up', 'right', 'down', 'left'. *

showButtons: boolean

* It set if Fab action buttons must be shown on init. Optional. Default is false. *

stayOpened: boolean

* It is icon constructor, which take string values from Fab Component and create Fab object. *

triggerButton: FabButtonModel

* It is data for Fab trigger button based on FabButtonModel. Optional, but then must be set in file describet above. *

actionButtons: FabButtonModel[]

* It is an array of buttons with type FabButtonModel. Optional. */ cfFab: FabModel; /** * It is [properties] attribute of cf-fab component with json object generated by FabModel and FabButtonModel. */ @Input() public properties: FabModel; /** * It is [display] attribute of cf-fab component. Means if component is visible. */ @Input() public display: boolean = true; /** * It is (cfTriggerEvent) attribute of cf-fab component. Means what event to call when Fab trigger button was clicked. */ @Output() cfTriggerEvent: EventEmitter = new EventEmitter(); /** * It is (cfActionButtonEvent) attribute of cf-fab component. Means what event to call when Fab action button was clicked. */ @Output() cfActionButtonEvent: EventEmitter = new EventEmitter(); /** *

It is function to send event with Fab trigger button object when it was clciked.

*

Example of event object:

* @param item it is trigger button object */ coreTriggerEvent(fab: Object) { this.cfTriggerEvent.emit(fab); } /** *

It is function to send event with Fab action button object when it was clciked.

*

Example of event object:

* @param index it is index of action button * @param item it is action button object */ coreActionEvent(fab: Object) { this.cfActionButtonEvent.emit(fab); } public constructor(public elementRef: ElementRef) { super(elementRef); } /** * It will be generated cfFab object and rendered inside component template. */ ngOnInit(){ this.cfFab = this.properties; // if(this.notificationAction.observers.length>0) this.notifacationClickable = 'notification-clickable'; } }