001    /*
002     * Apache License
003     * Version 2.0, January 2004
004     * http://www.apache.org/licenses/
005     *
006     * Copyright 2008-2010 by chenillekit.org
007     *
008     * Licensed under the Apache License, Version 2.0 (the "License");
009     * you may not use this file except in compliance with the License.
010     * You may obtain a copy of the License at
011     *
012     * http://www.apache.org/licenses/LICENSE-2.0
013     */
014    
015    package org.chenillekit.tapestry.core.services.impl;
016    
017    import org.apache.tapestry5.Asset;
018    import org.apache.tapestry5.func.F;
019    import org.apache.tapestry5.func.Mapper;
020    import org.apache.tapestry5.services.AssetSource;
021    import org.apache.tapestry5.services.javascript.JavaScriptStack;
022    import org.apache.tapestry5.services.javascript.StylesheetLink;
023    
024    import java.util.Collections;
025    import java.util.List;
026    
027    /**
028     * @author <a href="mailto:shomburg@depot120.dpd.de">S.Homburg</a>
029     * @version $Id: YahooStack.java 675 2010-07-30 14:49:17Z homburgs $
030     */
031    public class YahooStack implements JavaScriptStack
032    {
033            private final List<Asset> javascriptStack;
034    
035            public YahooStack(final AssetSource assetSource)
036            {
037                    Mapper<String, Asset> pathToAsset = new Mapper<String, Asset>()
038                    {
039                            public Asset map(String path)
040                            {
041                                    return assetSource.getExpandedAsset(path);
042                            }
043                    };
044    
045                    javascriptStack = F.flow("${yahoo.yui}/yahoo-dom-event/yahoo-dom-event.js",
046                                    "${yahoo.yui}/element/element${yahoo.yui.mode}.js").map(pathToAsset).toList();
047            }
048    
049            public List<String> getStacks()
050            {
051                    return Collections.emptyList();
052            }
053    
054            /**
055             * Returns a list of <em>localized</em> assets for JavaScript libraries that form the stack.
056             */
057            public List<Asset> getJavaScriptLibraries()
058            {
059                    return javascriptStack;
060            }
061    
062            /**
063             * Returns a list of <em>localized<m/e> links for stylesheets that form the stack.
064             */
065            public List<StylesheetLink> getStylesheets()
066            {
067                    return Collections.emptyList();
068            }
069    
070            /**
071             * Returns static JavaScript initialization for the stack. This block of JavaScript code will be added to the
072             * page that imports the stack. The code executes outside of any other function (i.e., the code is not deferred
073             * until the DOM is loaded). As with the other methods, if localization is a factor, the result of this method
074             * should be localized.
075             */
076            public String getInitialization()
077            {
078                    return "";
079            }
080    }