<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template name="uiDownloadLinkDescription">
        <xsl:param name="description" select="''" />

        <xsl:if test="$description != ''">
            <span class="DownloadLink-description">
                <xsl:value-of select="$description" />
            </span>
        </xsl:if>
    </xsl:template>

    <xsl:template name="uiDownloadLink">
        <xsl:param name="text" />
        <xsl:param name="url" />
        <xsl:param name="status" select="'default'" />
        <xsl:param name="title" select="''" />
        <xsl:param name="description" select="''" />
        <xsl:param name="className" select="''" />

        <xsl:choose>
            <xsl:when test="$status != 'default'">
                <span title="{$title}">
                    <xsl:attribute name="class">
                        <xsl:text>DownloadLink DownloadLink-disabled</xsl:text>
                        <xsl:if test="$title != ''">
                            <xsl:text> js-tooltip</xsl:text>
                        </xsl:if>
                        <xsl:if test="$className != ''">
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="$className" />
                        </xsl:if>
                    </xsl:attribute>
                    <span>
                        <span class="DownloadLink-status-icon">
                            <xsl:call-template name="uiStatusIcon">
                                <xsl:with-param name="type">
                                    <xsl:choose>
                                        <xsl:when test="$status = 'isGenerating'">
                                            <xsl:text>attention</xsl:text>
                                        </xsl:when>
                                        <xsl:when test="$status = 'notGenerated'">
                                            <xsl:text>danger</xsl:text>
                                        </xsl:when>
                                    </xsl:choose>
                                </xsl:with-param>
                            </xsl:call-template>
                        </span>
                    </span>
                    <span class="DownloadLink-text">
                        <span class="DownloadLink-text-wrapper">
                            <xsl:value-of select="$text" />
                        </span>
                        <xsl:call-template name="uiDownloadLinkDescription">
                            <xsl:with-param name="description" select="$description" />
                        </xsl:call-template>
                    </span>
                </span>
            </xsl:when>
            <xsl:otherwise>
                <a title="{$title}">
                    <xsl:attribute name="class">
                        <xsl:text>DownloadLink</xsl:text>
                        <xsl:if test="$title != ''">
                            <xsl:text> js-tooltip</xsl:text>
                        </xsl:if>
                        <xsl:if test="$className != ''">
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="$className" />
                        </xsl:if>
                    </xsl:attribute>
                    <xsl:attribute name="href">
                        <xsl:value-of select="$url" />
                    </xsl:attribute>
                    <span>
                        <span class="DownloadLink-icon">
                            <xsl:call-template name="icon">
                                <xsl:with-param name="type" select="'download'" />
                            </xsl:call-template>
                        </span>
                    </span>
                    <span class="DownloadLink-text">
                        <span class="DownloadLink-text-wrapper">
                            <xsl:value-of select="$text" />
                        </span>
                        <xsl:call-template name="uiDownloadLinkDescription">
                            <xsl:with-param name="description" select="$description" />
                        </xsl:call-template>
                    </span>
                </a>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>
