/** * Miscellaneous js functions for WebHelp * Kasun Gajasinghe, http://kasunbg.blogspot.com * David Cramer, http://www.thingbag.net * */ //Turn ON and OFF the animations for Show/Hide Sidebar. Extend this to other anime as well if any. var noAnimations=false; $(document).ready(function() { // When you click on a link to an anchor, scroll down // 105 px to cope with the fact that the banner // hides the top 95px or so of the page. // This code deals with the problem when // you click on a link within a page. $('a[href*=#]').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']'); if (!(this.hash == "#searchDiv" || this.hash == "#treeDiv" || this.hash == "") && $target.length) { var targetOffset = $target.offset().top - 120; $('html,body') .animate({scrollTop: targetOffset}, 200); return false; } } }); // $("#showHideHighlight").button(); //add jquery button styling to 'Go' button //Generate tabs in nav-pane with JQuery $(function() { $("#tabs").tabs({ cookie: { expires: 2 // store cookie for 2 days. } }); }); //Generate the tree $("#ulTreeDiv").attr("style", ""); $("#tree").treeview({ collapsed: true, animated: "medium", control: "#sidetreecontrol", persist: "cookie" }); //after toc fully styled, display it. Until loading, a 'loading' image will be displayed $("#tocLoading").attr("style", "display:none;"); // $("#ulTreeDiv").attr("style","display:block;"); //.searchButton is the css class applied to 'Go' button $(function() { $("button", ".searchButton").button(); $("button", ".searchButton").click(function() { return false; }); }); //'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) if ($.cookie('ui-tabs-1') === '1') { //search tab is active if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { document.getElementById('textToSearch').value = $.cookie('textToSearch'); Verifie('searchForm'); searchHighlight($.cookie('textToSearch')); $("#showHideHighlight").css("display", "block"); } } syncToc(); //Synchronize the toc tree with the content pane, when loading the page. //$("#doSearch").button(); //add jquery button styling to 'Go' button // When you click on a link to an anchor, scroll down // 105 px to cope with the fact that the banner // hides the top 95px or so of the page. // This code deals with the problem when // you click on a link from another page. var hash = window.location.hash; if(hash){ var targetOffset = $(hash).offset().top - 120; $('html,body').animate({scrollTop: targetOffset}, 200); return false; } }); /** * If an user moved to another page by clicking on a toc link, and then clicked on #searchDiv, * search should be performed if the cookie textToSearch is not empty. */ function doSearch() { //'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { document.getElementById('textToSearch').value = $.cookie('textToSearch'); Verifie('searchForm'); } } /** * Synchronize with the tableOfContents */ function syncToc() { var a = document.getElementById("webhelp-currentid"); if (a != undefined) { //Expanding the child sections of the selected node. var nodeClass = a.getAttribute("class"); if (nodeClass != null && !nodeClass.match(/collapsable/)) { a.setAttribute("class", "collapsable"); //remove display:none; css style from