1 /** 2 * @fileOverview 3 * @author <a href="https://www.labkey.org">LabKey</a> (<a href="mailto:info@labkey.com">info@labkey.com</a>) 4 * @license Copyright (c) 2008-2016 LabKey Corporation 5 * <p/> 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * <p/> 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * <p/> 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * <p/> 18 */ 19 20 /** 21 * @namespace NavTrail static class to adjust the text in LabKey's 22 * navigation trail. The navigation trail is the list of links across the top of 23 * the main body area, as well as the title for the current page. 24 */ 25 LABKEY.NavTrail = new function() 26 { 27 /** @scope LABKEY.NavTrail */ 28 return { 29 /** 30 * Set the nav trail's elements. 31 * @param {string} currentPageTitle The title for the current page 32 * @param {Object[]} [ancestors] An array of objects that describe the ancestor pages. Each 33 * object in this array can have two properties: url (which contains the URL for the page); 34 * and title (which contains the title for the page). These will be assembled into the full list of ancestor pages at the top of the nav trail. 35 * @param {string} [documentTitle] Document title 36 * @example 37 <pre name="code" class="xml"> 38 var ancestorURL = LABKEY.ActionURL.buildURL('project', 'begin'); 39 LABKEY.NavTrail.setTrail("People View", [{url: ancestorURL, title: "API Example"}]); 40 </pre> 41 */ 42 setTrail: function (currentPageTitle, ancestors, documentTitle) 43 { 44 var elem = document.getElementById("labkey-nav-trail-current-page"); 45 if (elem) 46 { 47 elem.innerHTML = currentPageTitle; 48 elem.style.visibility = "visible"; 49 } 50 51 elem = document.getElementById("navTrailAncestors"); 52 if (elem && ancestors) 53 { 54 var html = "", 55 sep = ""; 56 for (var idx = 0; idx < ancestors.length; ++idx) 57 { 58 html += sep; 59 if (ancestors[idx].url && ancestors[idx].title) 60 { 61 html += "<a href='" + ancestors[idx].url + "'>" + ancestors[idx].title + "</a>"; 62 } 63 else if (ancestors[idx].title) 64 { 65 html += ancestors[idx].title; 66 } 67 sep = ' > '; 68 } 69 elem.innerHTML = html; 70 elem.visibility = "visible"; 71 } 72 73 //set document title: 74 //<currentPageTitle>: <container path> 75 document.title = (documentTitle || currentPageTitle) + ": " + decodeURI(LABKEY.ActionURL.getContainer()); 76 } 77 }; 78 }; 79 80