All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.gwtbootstrap.client.ui.ResponsiveNavbar Maven / Gradle / Ivy

The newest version!
/*
 *  Copyright 2012 GWT-Bootstrap
 *
 *  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.
 */
package com.github.gwtbootstrap.client.ui;

import com.github.gwtbootstrap.client.ui.base.DivWidget;
import com.github.gwtbootstrap.client.ui.base.NavbarButton;
import com.github.gwtbootstrap.client.ui.config.Configurator;
import com.github.gwtbootstrap.client.ui.constants.Constants;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.user.client.ui.Widget;

//@formatter:off
/**
 * A {@link Navbar} that hides the contents of a {@link NavCollapse} whenever
 * the width of the window is too small.
 * 

* Only works when the Responsive Layout ist turned on. Create your own * {@link Configurator} and let {@link Configurator#hasResponsiveDesign() * hasResponsiveDesign()} return true. * *

*

UiBinder Usage:

* *
 * {@code
 * 
 *     
 *         Bootstrap
 *         
 *             
 *                 Link 1
 *                 Link 2
 *             
 *             
 *             
 *                 Link 3
 *             
 *         
 *     
 *     
 *         [...]
 *     
 * 
 * }
 * 
*

* * @since 2.0.4.0 * * @author Dominik Mayer * @author Carlos Alexandro Becker * * @see Bootstrap documentation */ //@formatter:on public class ResponsiveNavbar extends Navbar { private final NavbarButton collapseButton = new NavbarButton(); private final DivWidget navCollapse = new DivWidget(Constants.NAV_COLLAPSE); /** * Creates an empty widget. */ public ResponsiveNavbar() { super(); addCollapseButton(); } private void addCollapseButton() { collapseButton.getElement().setAttribute(Constants.DATA_TOGGLE, Constants.COLLAPSE); collapseButton.getElement().setAttribute(Constants.DATA_TARGET, Constants.NAV_COLLAPSE_TARGET); collapseButton.add(new Icon(IconType.BAR)); collapseButton.add(new Icon(IconType.BAR)); collapseButton.add(new Icon(IconType.BAR)); add(collapseButton); } /** * {@inheritDoc} */ @Override public void add(Widget child) { if (child instanceof Nav) { // without this, the order of elements in navbar will bug. if (!getChildren().contains(navCollapse)) super.add(navCollapse); navCollapse.add(child); } else super.add(child); } /** * {@inheritDoc} */ @Override protected Container getContainer() { return new FluidContainer(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy