// (C) Copyright 2015 Martin Dougiamas // // 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, ContentChildren, ElementRef, QueryList } from '@angular/core'; import { Button } from 'ionic-angular'; import { CoreLoggerProvider } from '../../providers/logger'; import { CoreDomUtilsProvider } from '../../providers/utils/dom'; /** * 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. * * You can use the [hidden] input to hide all the inner buttons if a certain condition is met. * * Example usage: * * * * */ @Component({ selector: 'core-navbar-buttons', template: '' }) export class CoreNavBarButtonsComponent implements OnInit { 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; if (this._buttons) { this._buttons.forEach((button: Button) => { this.showHideButton(button); }); } } // Get all the buttons inside this directive. @ContentChildren(Button) set buttons(buttons: QueryList