org.got5.tapestry5.jquery.services.javascript.AjaxUploadStack 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.AjaxUpload;
import org.got5.tapestry5.jquery.utils.JQueryUtils;
/**
* Resource stack for {@link AjaxUpload}.
*
* @author criedel
*/
public class AjaxUploadStack implements JavaScriptStack
{
public static final String STACK_ID = "AjaxUploadStack";
private final List javaScriptStack;
private final List cssStack;
public AjaxUploadStack(
@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/upload/jquery.fileuploader%s.js", productionMode ? ".min" : "");
javaScriptStack = F.flow(path, "${assets.path}/components/upload/upload.js").map(pathToAsset).toList();
final Mapper pathToStylesheetLink = F.combine(pathToAsset, JQueryUtils.assetToStylesheetLink);
cssStack = F.flow("${assets.path}/components/upload/fileuploader.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();
}
}