001package gwt.material.design.client.ui;
002
003/*
004 * #%L
005 * GwtMaterial
006 * %%
007 * Copyright (C) 2015 - 2017 GwtMaterialDesign
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023
024import com.google.gwt.dom.client.Document;
025import com.google.gwt.user.client.ui.Widget;
026import gwt.material.design.client.base.HasType;
027import gwt.material.design.client.base.MaterialWidget;
028import gwt.material.design.client.base.mixin.CssTypeMixin;
029import gwt.material.design.client.constants.CssName;
030import gwt.material.design.client.constants.FooterType;
031import gwt.material.design.client.ui.html.Div;
032
033
034//@formatter:off
035
036/**
037 * Footers are a great way to organize a lot of site navigation and information at the end of a page. This is where the user will look once hes finished scrolling through the current page or is looking for additional information about your website.
038 * <h3>UiBinder Usage:</h3>
039 * <p>
040 * <pre>
041 * {@code
042 * <m:MaterialFooter backgroundColor="BLUE">
043 * <m:MaterialRow>
044 * <m:MaterialColumn grid="s12 m6 l6">
045 * <m:MaterialTitle fontSize="0.7em" color="WHITE" title="Join The Discussion" description="We provide Gitter Chat rooms in order for GWT Developers discussed and collaborate about GWT Material Design and Phonegap Integration."/>
046 * <m:MaterialButton ui:field="btnChat" text="CHAT" backgroundColor="BLUE_LIGHTEN_2" waves="LIGHT"/>
047 * </m:MaterialColumn>
048 * <m:MaterialColumn grid="s12 m6 l6">
049 * <m:MaterialTitle fontSize="0.7em" color="WHITE" title="GWT Phonegap" description="We provide Gitter Chat rooms in order for GWT Developers discussed and collaborate about GWT Material Design and Phonegap Integration."/>
050 * <m:MaterialButton ui:field="btnDownloadPhonegap" text="GWT Material APK" backgroundColor="BLUE_LIGHTEN_2" waves="LIGHT"/>
051 * </m:MaterialColumn>
052 * </m:MaterialRow>
053 *
054 * <m:MaterialFooterCopyright backgroundColor="BLUE_DARKEN_2">
055 * <m:MaterialLabel text=" © 2014 Copyright Text"/>
056 * </m:MaterialFooterCopyright>
057 * </m:MaterialFooter> }
058 * </pre>
059 * </p>
060 *
061 * @author kevzlou7979
062 * @author Ben Dol
063 * @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#footer">Material Footer</a>
064 */
065//@formatter:on
066public class MaterialFooter extends MaterialWidget implements HasType<FooterType> {
067
068    private Div container = new Div();
069    private CssTypeMixin<FooterType, MaterialFooter> typeMixin;
070
071    public MaterialFooter() {
072        super(Document.get().createElement("footer"), CssName.PAGE_FOOTER);
073    }
074
075    @Override
076    protected void onLoad() {
077        super.onLoad();
078
079        container.setStyleName(CssName.CONTAINER);
080        super.insert(container, 0);
081    }
082
083    @Override
084    public void add(Widget child) {
085        if (child instanceof MaterialFooterCopyright) {
086            super.add(child);
087        } else {
088            container.add(child);
089        }
090    }
091
092    @Override
093    public void setType(FooterType type) {
094        getTypeMixin().setType(type);
095    }
096
097    @Override
098    public FooterType getType() {
099        return getTypeMixin().getType();
100    }
101
102    public Div getContainer() {
103        return container;
104    }
105
106    protected CssTypeMixin<FooterType, MaterialFooter> getTypeMixin() {
107        if (typeMixin == null) {
108            typeMixin = new CssTypeMixin<>(this);
109        }
110        return typeMixin;
111    }
112}