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

org.got5.tapestry5.jquery.services.javascript.DataTableStack Maven / Gradle / Ivy

The newest version!
package org.got5.tapestry5.jquery.services.javascript;

import java.util.Collections;
import java.util.List;

import org.apache.tapestry5.Asset;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.func.F;
import org.apache.tapestry5.func.Mapper;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.services.AssetSource;
import org.apache.tapestry5.services.javascript.JavaScriptStack;
import org.apache.tapestry5.services.javascript.StylesheetLink;
import org.got5.tapestry5.jquery.components.DataTable;
import org.got5.tapestry5.jquery.utils.JQueryUtils;

/**
 * Resource stack for {@link DataTable}.
 *
 * @author criedel
 */
public class DataTableStack implements JavaScriptStack
{
    public static final String STACK_ID = "DataTableStack";

    private final List javaScriptStack;

    private final List cssStack;

    public DataTableStack(
            @Symbol(SymbolConstants.PRODUCTION_MODE)
            final boolean productionMode,
            final AssetSource assetSource)
    {

        final Mapper pathToAsset = new Mapper()
        {
            public Asset map(String path)
            {
                return assetSource.getExpandedAsset(path);
            }
        };

        final String path = String.format("${assets.path}/components/datatables/jquery.dataTables%s.js", productionMode ? ".min" : "");

        javaScriptStack = F.flow(path, "${assets.path}/components/datatables/dataTables.js").map(pathToAsset).toList();


        final Mapper pathToStylesheetLink = F.combine(pathToAsset, JQueryUtils.assetToStylesheetLink);
        cssStack = F.flow("${assets.path}/components/datatables/tango/skin.css").map(pathToStylesheetLink).toList();
    }

    public String getInitialization()
    {
        return null;
    }

    public List getJavaScriptLibraries()
    {
        return javaScriptStack;
    }

    public List getStylesheets()
    {
        return cssStack;
    }

    public List getStacks()
    {
        return Collections.emptyList();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy