[yelp-xsl] Allow alt titles for ui:expander



commit 8bb57f8bf56cd8e08d149ce9b6eadb62bb9a620f
Author: Shaun McCance <shaunm gnome org>
Date:   Tue Jun 14 11:07:39 2011 -0400

    Allow alt titles for ui:expander

 xslt/common/html.xsl                 |   27 +++++++++++++++--
 xslt/mallard/html/mal2html-block.xsl |   52 ++++++++++++++++++++++++---------
 2 files changed, 62 insertions(+), 17 deletions(-)
---
diff --git a/xslt/common/html.xsl b/xslt/common/html.xsl
index 6f72998..5170e38 100644
--- a/xslt/common/html.xsl
+++ b/xslt/common/html.xsl
@@ -1044,6 +1044,7 @@ div.media-ttml-p {
   -moz-box-shadow: 2px 2px 4px </xsl:text>
     <xsl:value-of select="$color.gray_border"/><xsl:text>;
 }
+div.yelp-data { display: none; }
 div.ui-expander > div.inner > div.title:hover {
   color: </xsl:text><xsl:value-of select="$color.link"/><xsl:text>;
 }
@@ -1452,27 +1453,47 @@ $(document).ready(function () {
 $(document).ready(function () {
   $('.ui-expander').each(function () {
     var expander = $(this);
+    var yelpdata = expander.children('div.yelp-data-ui-expander');
     var arrow;
-    if (expander.attr('data-yelp-dir') == 'rtl')
+    if (yelpdata.attr('dir') == 'rtl')
       arrow = $('<span class="ui-expander-arrow-rtl">â</span>');
     else
       arrow = $('<span class="ui-expander-arrow-ltr">â</span>');
     var contents = expander.children('.inner').children('.contents');
     var title = expander.children('.inner').children('.title');
+    var titlespan = title.find('span.title:first');
+    var titlebase = titlespan.html();
     title.attr('role', 'button').attr('aria-controls', contents.attr('id'));
     title.children().append('&#x00A0;&#x00A0;').append(arrow);
-    if (expander.is('.ui-expander-c'))
+    var title_e = yelpdata.children('div.yelp-title-expanded');
+    var title_c = yelpdata.children('div.yelp-title-collapsed');
+    if (yelpdata.attr('data-yelp-expanded') == 'no') {
+      expander.addClass('ui-expander-c');
       contents.attr('aria-expanded', 'false').hide();
-    else
+      if (title_c.length != 0)
+        titlespan.html(title_c.html());
+    } else {
+      expander.addClass('ui-expander-e');
       contents.attr('aria-expanded', 'true');
+      if (title_e.length != 0)
+        titlespan.html(title_e.html());
+    }
     expander.children('.inner').children('.title').click(function () {
       if (expander.is('.ui-expander-e')) {
         expander.removeClass('ui-expander-e').addClass('ui-expander-c');
         contents.attr('aria-expanded', 'false').slideUp('fast');
+        if (title_c.length != 0)
+          titlespan.html(title_c.html());
+        else
+          titlespan.html(titlebase);
       }
       else {
         expander.removeClass('ui-expander-c').addClass('ui-expander-e');
         contents.attr('aria-expanded', 'true').slideDown('fast');
+        if (title_e.length != 0)
+          titlespan.html(title_e.html());
+        else
+          titlespan.html(titlebase);
       }
     });
   });
diff --git a/xslt/mallard/html/mal2html-block.xsl b/xslt/mallard/html/mal2html-block.xsl
index 5cd51d3..c804f1c 100644
--- a/xslt/mallard/html/mal2html-block.xsl
+++ b/xslt/mallard/html/mal2html-block.xsl
@@ -351,22 +351,10 @@ in accordance with the Mallard specification on fallback block content.
         <xsl:value-of select="concat(' note-', $notestyle)"/>
       </xsl:if>
       <xsl:if test="mal:title and @ui:expanded">
-        <xsl:text> ui-expander </xsl:text>
-        <xsl:choose>
-          <xsl:when test="@ui:expanded = 'yes'">
-            <xsl:text>ui-expander-e</xsl:text>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:text>ui-expander-c</xsl:text>
-          </xsl:otherwise>
-        </xsl:choose>
+        <xsl:text> ui-expander</xsl:text>
       </xsl:if>
     </xsl:attribute>
-    <xsl:if test="mal:title and @ui:expanded">
-      <xsl:attribute name="data-yelp-dir">
-        <xsl:call-template name="l10n.direction"/>
-      </xsl:attribute>
-    </xsl:if>
+    <xsl:call-template name="mal2html.ui.expander.data"/>
     <div class="inner">
       <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
       <div class="contents">
@@ -382,6 +370,42 @@ in accordance with the Mallard specification on fallback block content.
 </xsl:if>
 </xsl:template>
 
+<xsl:template name="mal2html.ui.expander.data">
+  <xsl:param name="node" select="."/>
+  <xsl:if test="$node/mal:title and ($node/@ui:expanded or $node/self::ui:expander)">
+    <xsl:variable name="title_e" select="$node/mal:info/mal:title[ type = 'ui:expanded'][1]"/>
+    <xsl:variable name="title_c" select="$node/mal:info/mal:title[ type = 'ui:collapsed'][1]"/>
+    <div class="yelp-data yelp-data-ui-expander">
+      <xsl:attribute name="dir">
+        <xsl:call-template name="l10n.direction"/>
+      </xsl:attribute>
+      <xsl:attribute name="data-yelp-expanded">
+        <xsl:choose>
+          <xsl:when test="$node/self::ui:expander/@expanded = 'no'">
+            <xsl:text>no</xsl:text>
+          </xsl:when>
+          <xsl:when test="$node/@ui:expanded = 'no'">
+            <xsl:text>no</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text>yes</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:attribute>
+      <xsl:if test="$title_e">
+        <div class="yelp-title-expanded">
+          <xsl:apply-templates mode="mal2html.inline.mode" select="$title_e/node()"/>
+        </div>
+      </xsl:if>
+      <xsl:if test="$title_c">
+        <div class="yelp-title-collapsed">
+          <xsl:apply-templates mode="mal2html.inline.mode" select="$title_c/node()"/>
+        </div>
+      </xsl:if>
+    </div>
+  </xsl:if>
+</xsl:template>
+
 <!-- = info = -->
 <xsl:template mode="mal2html.block.mode" match="mal:info"/>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]