~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/composer/extensions/help/help/content/helpDocBook/help.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ***** BEGIN LICENSE BLOCK *****
 
2
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
3
#
 
4
# The contents of this file are subject to the Mozilla Public License Version
 
5
# 1.1 (the "License"); you may not use this file except in compliance with
 
6
# the License. You may obtain a copy of the License at
 
7
# http://www.mozilla.org/MPL/
 
8
#
 
9
# Software distributed under the License is distributed on an "AS IS" basis,
 
10
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
11
# for the specific language governing rights and limitations under the
 
12
# License.
 
13
#
 
14
# The Original Code is Mozilla Firefox Help Viewer Source Code.
 
15
#
 
16
# The Initial Developer of the Original Code is
 
17
# R.J. Keller <rlk@trfenv.com>
 
18
# Portions created by the Initial Developer are Copyright (C) 2003-2004
 
19
# the Initial Developer. All Rights Reserved.
 
20
#
 
21
# Contributor(s):
 
22
#
 
23
# Alternatively, the contents of this file may be used under the terms of
 
24
# either the GNU General Public License Version 2 or later (the "GPL"), or
 
25
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
26
# in which case the provisions of the GPL or the LGPL are applicable instead
 
27
# of those above. If you wish to allow use of your version of this file only
 
28
# under the terms of either the GPL or the LGPL, and not to allow others to
 
29
# use your version of this file under the terms of the MPL, indicate your
 
30
# decision by deleting the provisions above and replace them with the notice
 
31
# and other provisions required by the GPL or the LGPL. If you do not delete
 
32
# the provisions above, a recipient may use your version of this file under
 
33
# the terms of any one of the MPL, the GPL or the LGPL.
 
34
#
 
35
# ***** END LICENSE BLOCK ***** */
 
36
<?xml version="1.0" encoding="ISO-8859-1"?>
 
37
<?xml-stylesheet type="text/css" href="helpFileLayout.css"?>
 
38
 
 
39
<!DOCTYPE stylesheet [
 
40
    <!ENTITY % helpDocDTD SYSTEM "helpDoc.dtd" >
 
41
    %helpDocDTD;
 
42
]>
 
43
 
 
44
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
45
 
 
46
<xsl:output xsl:method="html" xsl:indent="yes" xsl:version="1.1"/>
 
47
 
 
48
<xsl:template match="/">
 
49
  <html>
 
50
  <head>
 
51
    <title><xsl:value-of select="article/artheader/title"/></title>
 
52
    <link rel="stylesheet" type="text/css" href="helpFileLayout.css"/>
 
53
  <script type="text/javascript">
 
54
  <![CDATA[
 
55
  var paragraphs;
 
56
  
 
57
# toggles the visibility of section "item". Also changes the plus sign shown to minus sign
 
58
# and vice versa depending on the items visiblity.
 
59
  function changeVisibility(item, plus)
 
60
  {
 
61
    var divsToHide = document.getElementById(item).getElementsByTagName("*");
 
62
    var currentVisibility = divsToHide.item(2).getAttribute("style");
 
63
    var currentImgSrc = document.getElementById(plus).getAttribute("src");
 
64
 
 
65
    document.getElementById(plus).setAttribute("src", (currentImgSrc == "chrome://global/skin/tree/twisty-clsd.gif") ? "chrome://global/skin/tree/twisty-open.gif" : "chrome://global/skin/tree/twisty-clsd.gif");
 
66
 
 
67
    for (var i = 2; i < divsToHide.length; i++)
 
68
      if (currentVisibility == "display: none;")
 
69
        divsToHide.item(i).removeAttribute("style");
 
70
      else
 
71
        divsToHide.item(i).setAttribute("style", "display:none;");
 
72
 
 
73
  }
 
74
 
 
75
# Takes in a String and returns that string with the spaces replaced with underscoes and
 
76
# in all lowercase.
 
77
  function spacesToUnderscores(str)
 
78
  {
 
79
    if (!str) return null;
 
80
    
 
81
    var newStr = "";
 
82
    for (var i = 0; i < str.length; i++)
 
83
    {
 
84
      var curChar = str.substring(i, i+1);
 
85
      if (curChar == " ")
 
86
        newStr += "_"
 
87
      else
 
88
        newStr += curChar.toLowerCase();
 
89
    }
 
90
    return newStr;
 
91
  }
 
92
  
 
93
# Takes in an element("title") and runs spacesToUnderscores(str) on all the elements
 
94
# inside of "title".
 
95
#
 
96
# You can use the attr parameter to change the attribute to something other than ID
 
97
# (such as href for hyperlinks).
 
98
  function initalizeIDs(title, attr)
 
99
  {
 
100
    var attribute = !attr ? "id" : attr;
 
101
    for (var i = 0; i < document.getElementsByTagName(title).length; i++)
 
102
    {
 
103
      var curItem = document.getElementsByTagName(title).item(i);
 
104
      var curId = curItem.getAttribute(attribute);
 
105
      var newId = spacesToUnderscores(curId);
 
106
      if (newId)
 
107
        curItem.setAttribute(attribute, newId);
 
108
    }
 
109
  }
 
110
  ]]>
 
111
  </script>
 
112
  </head>
 
113
# set all the IDs and hyperlinks in the document to not have spaces or capital letters.
 
114
  <body onload="initalizeIDs('h2');initalizeIDs('h3');initalizeIDs('img');initalizeIDs('div');initalizeIDs('a', 'href');">
 
115
 
 
116
  <h1 id="top"><xsl:value-of select="article/artheader/title"/></h1>
 
117
  
 
118
  <xsl:for-each select="article/artheader/para">
 
119
    <p><xsl:copy-of select="."/></p>
 
120
  </xsl:for-each>
 
121
  
 
122
  <div class="contentsBox">In this section:
 
123
    <ul>
 
124
    <xsl:for-each select="article/sect1">
 
125
      <li><a href="#{title}"><xsl:value-of select="title"/></a></li>
 
126
      <xsl:for-each select="sect2">
 
127
      
 
128
      </xsl:for-each>
 
129
    </xsl:for-each>
 
130
    </ul>
 
131
  </div>
 
132
 
 
133
  <xsl:for-each select="article">
 
134
    <xsl:apply-templates/>
 
135
  </xsl:for-each>
 
136
 
 
137
  <div class="contentsBox"><em>Copyright (C) <xsl:copy-of select="article/artheader/copyright/year"/> <xsl:copy-of select="article/artheader/copyright/holder"/></em></div>
 
138
  <p><xsl:copy-of select="helpFile/copyright"/></p>
 
139
  </body>
 
140
  </html>
 
141
</xsl:template>
 
142
 
 
143
# Create a hiderDiv element so that we can run this through the changeVisibility function when the
 
144
# user requests a collapse in the help content.
 
145
<xsl:template match="sect1">
 
146
  <div id="hiderDiv{title}">
 
147
    <xsl:apply-templates/>
 
148
  </div>
 
149
</xsl:template>
 
150
 
 
151
# Adds the title along with a plus sign to collapse/expand the help topic.
 
152
<xsl:template match="sect1/title">
 
153
  <h2 id="{.}"><img class="plus" id="plus{.}" onclick="changeVisibility(spacesToUnderscores('hiderDiv{.}'), spacesToUnderscores('plus{.}'));" src="chrome://global/skin/tree/twisty-open.gif"/><xsl:value-of select="."/></h2>
 
154
</xsl:template>
 
155
 
 
156
<xsl:template match="sect2">
 
157
  <div id="hiderDiv{title}">
 
158
    <xsl:apply-templates/>
 
159
  </div>
 
160
</xsl:template>
 
161
 
 
162
# see sect1/title
 
163
<xsl:template match="sect2/title">
 
164
  <h3 id="{.}"><img class="plus" id="plus{.}" onclick="changeVisibility(spacesToUnderscores('hiderDiv{.}'), spacesToUnderscores('plus{.}'));" src="chrome://global/skin/tree/twisty-open.gif"/><xsl:value-of select="."/></h3>
 
165
</xsl:template>
 
166
 
 
167
<xsl:template match="para">
 
168
  <p><xsl:copy-of select="."/></p>
 
169
</xsl:template>
 
170
 
 
171
<xsl:template match="graphic">
 
172
  <p><img src="{@fileref}" width="{@width}" height="{@height}" alt=""/></p>
 
173
</xsl:template>
 
174
 
 
175
# Creates a hyperlink for the text of this element. Note that although the code using the section
 
176
# attribute as the ID to where to go to in the document, the initializeIDs function called in the
 
177
# body's onload event will change it to the appropriate topic, so you can use the exact title name
 
178
# (with spaces) if you wish.
 
179
<xsl:template match="link">
 
180
  <a href="{@location}#{@sect}"><xsl:copy-of select="."/></a>
 
181
</xsl:template>
 
182
 
 
183
<xsl:template match="indexEntry">
 
184
  <a name="{@sect}"/>
 
185
</xsl:template>
 
186
</xsl:stylesheet>