// (C) Copyright 2015 Moodle Pty Ltd. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. import { Component, Input, OnInit, OnDestroy, ContentChildren, ElementRef, QueryList } from '@angular/core'; import { Button } from 'ionic-angular'; import { CoreLoggerProvider } from '@providers/logger'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreContextMenuComponent } from '../context-menu/context-menu'; /** * Component to add buttons to the app's header without having to place them inside the header itself. This is meant for * pages that are loaded inside a sub ion-nav, so they don't have a header. * * If this component indicates a position (start/end), the buttons will only be added if the header has some buttons in that * position. If no start/end is specified, then the buttons will be added to the first found in the header. * * If this component has a "prepend" attribute, the buttons will be added before other existing buttons in the header. * * You can use the [hidden] input to hide all the inner buttons if a certain condition is met. * * IMPORTANT: Do not use *ngIf in the buttons inside this component, it can cause problems. Please use [hidden] instead. * * Example usage: * * * * */ @Component({ selector: 'core-navbar-buttons', template: '' }) export class CoreNavBarButtonsComponent implements OnInit, OnDestroy { protected BUTTON_HIDDEN_CLASS = 'core-navbar-button-hidden'; // If the hidden input is true, hide all buttons. @Input('hidden') set hidden(value: boolean) { this._hidden = value; this.showHideAllElements(); } // Get all the ion-buttons inside this directive and apply the role bar-button. @ContentChildren(Button) set buttons(buttons: QueryList