~ubuntu-branches/ubuntu/hardy/qgis/hardy

« back to all changes in this revision

Viewing changes to doc/skin/breadcrumbs.js

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
 ============================================================================
4
 
                   The Apache Software License, Version 1.1
5
 
 ============================================================================
6
 
 
7
 
 Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
8
 
 
9
 
 Redistribution and use in source and binary forms, with or without modifica-
10
 
 tion, are permitted provided that the following conditions are met:
11
 
 
12
 
 1. Redistributions of  source code must  retain the above copyright  notice,
13
 
    this list of conditions and the following disclaimer.
14
 
 
15
 
 2. Redistributions in binary form must reproduce the above copyright notice,
16
 
    this list of conditions and the following disclaimer in the documentation
17
 
    and/or other materials provided with the distribution.
18
 
 
19
 
 3. The end-user documentation included with the redistribution, if any, must
20
 
    include  the following  acknowledgment:  "This product includes  software
21
 
    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
22
 
    Alternately, this  acknowledgment may  appear in the software itself,  if
23
 
    and wherever such third-party acknowledgments normally appear.
24
 
 
25
 
 4. The names "Apache Forrest" and "Apache Software Foundation"
26
 
    must not be used to endorse or promote products derived from this  software
27
 
    without  prior written permission. For written permission, please contact
28
 
    apache@apache.org.
29
 
 
30
 
 5. Products  derived from this software may not  be called "Apache", nor may
31
 
    "Apache" appear  in their name,  without prior written permission  of the
32
 
    Apache Software Foundation.
33
 
 
34
 
 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
35
 
 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
36
 
 FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
37
 
 APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
38
 
 INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
39
 
 DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
40
 
 OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
41
 
 ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
42
 
 (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
43
 
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
 
 
45
 
 This software  consists of voluntary contributions made  by many individuals
46
 
 on  behalf of the Apache Software  Foundation. For more  information on the
47
 
 Apache Software Foundation, please see <http://www.apache.org/>.
48
 
 
49
 
*/
50
 
 
51
 
/**
52
 
 * This script, when included in a html file, builds a neat breadcrumb trail
53
 
 * based on its url. That is, if it doesn't contains bugs (I'm relatively
54
 
 * sure it does).
55
 
 *
56
 
 * Typical usage:
57
 
 * <script type="text/javascript" language="JavaScript" src="breadcrumbs.js"></script>
58
 
 *
59
 
 *@author     <a href="mailto:leosimons@apache.org">Leo Simons</a> (main author)
60
 
 *@author     <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a> (integration in skin)
61
 
 *@created    July 12, 2002
62
 
 *@version    1.0
63
 
 */
64
 
 
65
 
/**
66
 
 * IE 5 on Mac doesn't know Array.push.
67
 
 *
68
 
 * Implement it - courtesy to fritz.
69
 
 */
70
 
var abc = new Array();
71
 
if (!abc.push) {
72
 
  Array.prototype.push  = function(what){this[this.length]=what}
73
 
}
74
 
 
75
 
/* ========================================================================
76
 
        CONSTANTS
77
 
   ======================================================================== */
78
 
 
79
 
/**
80
 
 * Two-dimensional array containing extra crumbs to place at the front of
81
 
 * the trail. Specify first the name of the crumb, then the URI that belongs
82
 
 * to it. You'll need to modify this for every domain or subdomain where
83
 
 * you use this script (you can leave it as an empty array if you wish)
84
 
 */
85
 
var PREPREND_CRUMBS = new Array();
86
 
   if(!(""=="")){
87
 
     PREPREND_CRUMBS.push( new Array( "", "" ) );
88
 
   }
89
 
   if(!(""=="")){
90
 
     PREPREND_CRUMBS.push( new Array( "", "" ) );
91
 
   }
92
 
   if(!(""=="")){
93
 
     PREPREND_CRUMBS.push( new Array( "", "" ) );
94
 
   }
95
 
 
96
 
/**
97
 
 * String to include between crumbs:
98
 
 */
99
 
var DISPLAY_SEPARATOR = " &gt; ";
100
 
/**
101
 
 * String to include at the beginning of the trail
102
 
 */
103
 
var DISPLAY_PREPREND = "";
104
 
/**
105
 
 * String to include at the end of the trail
106
 
 */
107
 
var DISPLAY_POSTPREND = "";
108
 
 
109
 
/**
110
 
 * CSS Class to use for a single crumb:
111
 
 */
112
 
var CSS_CLASS_CRUMB = "breadcrumb";
113
 
 
114
 
/**
115
 
 * CSS Class to use for the complete trail:
116
 
 */
117
 
var CSS_CLASS_TRAIL = "breadcrumbTrail";
118
 
 
119
 
/**
120
 
 * CSS Class to use for crumb separator:
121
 
 */
122
 
var CSS_CLASS_SEPARATOR = "crumbSeparator";
123
 
 
124
 
/**
125
 
 * Array of strings containing common file extensions. We use this to
126
 
 * determine what part of the url to ignore (if it contains one of the
127
 
 * string specified here, we ignore it).
128
 
 */
129
 
var FILE_EXTENSIONS = new Array( ".html", ".htm", ".jsp", ".php", ".php3", ".php4" );
130
 
 
131
 
/**
132
 
 * String that separates parts of the breadcrumb trail from each other.
133
 
 * When this is no longer a slash, I'm sure I'll be old and grey.
134
 
 */
135
 
var PATH_SEPARATOR = "/";
136
 
 
137
 
/* ========================================================================
138
 
        UTILITY FUNCTIONS
139
 
   ======================================================================== */
140
 
/**
141
 
 * Capitalize first letter of the provided string and return the modified
142
 
 * string.
143
 
 */
144
 
function sentenceCase( string )
145
 
{        return string;
146
 
        //var lower = string.toLowerCase();
147
 
        //return lower.substr(0,1).toUpperCase() + lower.substr(1);
148
 
}
149
 
 
150
 
/**
151
 
 * Returns an array containing the names of all the directories in the
152
 
 * current document URL
153
 
 */
154
 
function getDirectoriesInURL()
155
 
{
156
 
        var trail = document.location.pathname.split( PATH_SEPARATOR );
157
 
 
158
 
        // check whether last section is a file or a directory
159
 
        var lastcrumb = trail[trail.length-1];
160
 
        for( var i = 0; i < FILE_EXTENSIONS.length; i++ )
161
 
        {
162
 
                if( lastcrumb.indexOf( FILE_EXTENSIONS[i] ) )
163
 
                {
164
 
                        // it is, remove it and send results
165
 
                        return trail.slice( 1, trail.length-1 );
166
 
                }
167
 
        }
168
 
 
169
 
        // it's not; send the trail unmodified
170
 
        return trail.slice( 1, trail.length );
171
 
}
172
 
 
173
 
/* ========================================================================
174
 
        BREADCRUMB FUNCTIONALITY
175
 
   ======================================================================== */
176
 
/**
177
 
 * Return a two-dimensional array describing the breadcrumbs based on the
178
 
 * array of directories passed in.
179
 
 */
180
 
function getBreadcrumbs( dirs )
181
 
{
182
 
        var prefix = "/";
183
 
        var postfix = "/";
184
 
 
185
 
        // the array we will return
186
 
        var crumbs = new Array();
187
 
 
188
 
        if( dirs != null )
189
 
        {
190
 
                for( var i = 0; i < dirs.length; i++ )
191
 
                {
192
 
                        prefix += dirs[i] + postfix;
193
 
                        crumbs.push( new Array( dirs[i], prefix ) );
194
 
                }
195
 
        }
196
 
 
197
 
        // preprend the PREPREND_CRUMBS
198
 
        if(PREPREND_CRUMBS.length > 0 )
199
 
        {
200
 
                return PREPREND_CRUMBS.concat( crumbs );
201
 
        }
202
 
 
203
 
        return crumbs;
204
 
}
205
 
 
206
 
/**
207
 
 * Return a string containing a simple text breadcrumb trail based on the
208
 
 * two-dimensional array passed in.
209
 
 */
210
 
function getCrumbTrail( crumbs )
211
 
{
212
 
        var xhtml = DISPLAY_PREPREND;
213
 
 
214
 
        for( var i = 0; i < crumbs.length; i++ )
215
 
        {
216
 
                xhtml += '<a href="' + crumbs[i][1] + '" >';
217
 
                xhtml += unescape( crumbs[i][0] ) + '</a>';
218
 
                if( i != (crumbs.length-1) )
219
 
                {
220
 
                        xhtml += DISPLAY_SEPARATOR;
221
 
                }
222
 
        }
223
 
 
224
 
        xhtml += DISPLAY_POSTPREND;
225
 
 
226
 
        return xhtml;
227
 
}
228
 
 
229
 
/**
230
 
 * Return a string containing an XHTML breadcrumb trail based on the
231
 
 * two-dimensional array passed in.
232
 
 */
233
 
function getCrumbTrailXHTML( crumbs )
234
 
{
235
 
        var xhtml = '<span class="' + CSS_CLASS_TRAIL  + '">';
236
 
        xhtml += DISPLAY_PREPREND;
237
 
 
238
 
        for( var i = 0; i < crumbs.length; i++ )
239
 
        {
240
 
                xhtml += '<a href="' + crumbs[i][1] + '" class="' + CSS_CLASS_CRUMB + '">';
241
 
                xhtml += unescape( crumbs[i][0] ) + '</a>';
242
 
                if( i != (crumbs.length-1) )
243
 
                {
244
 
                        xhtml += '<span class="' + CSS_CLASS_SEPARATOR + '">' + DISPLAY_SEPARATOR + '</span>';
245
 
                }
246
 
        }
247
 
 
248
 
        xhtml += DISPLAY_POSTPREND;
249
 
        xhtml += '</span>';
250
 
 
251
 
        return xhtml;
252
 
}
253
 
 
254
 
/* ========================================================================
255
 
        PRINT BREADCRUMB TRAIL
256
 
   ======================================================================== */
257
 
 
258
 
// check if we're local; if so, only print the PREPREND_CRUMBS
259
 
if( document.location.href.toLowerCase().indexOf( "http://" ) == -1 )
260
 
{
261
 
        document.write( getCrumbTrail( getBreadcrumbs() ) );
262
 
}
263
 
else
264
 
{
265
 
        document.write( getCrumbTrail( getBreadcrumbs( getDirectoriesInURL() ) ) );
266
 
}
267