var scrollTimerID = 0; $(function() { // add click event for show/hide link $('#showhide').click(function() { $('body')[0].id = ('nohelp' == $('body')[0].id) ? 'help' : 'nohelp'; $.cookie('help', $('body')[0].id, {path: '/'}); this.blur(); return false; }); // add event handler to get ribbon content $('#menu a').click(function() { var title = $(this).html(); title = title.replace(/(<([^>]+)>)/ig, ''); selectMenuItem(title); this.blur(); return false; }); // setup any help links in links section $('a.help').click(function() { $('#sidebar').loadHelp(this.href); $('body')[0].id = 'help'; $.cookie('help', 'help', {path: '/'}); return false; }); $('#ribbon a.next').hover(function() { ribbonScroll(40); }, function() { if (scrollTimerID) { clearTimeout(scrollTimerID); } }); $('#ribbon a.prev').hover(function() { ribbonScroll(-40); }, function() { if (scrollTimerID) { clearTimeout(scrollTimerID); } }); selectMenuItem(); // load help index page //loadHtml(); }); function selectMenuItem(title) { var scroll = 0; // get title from cookies if not set if ('undefined' == typeof title) { title = $.cookie('menuSection'); scroll = $.cookie('scroll'); if (null == title) title = 'null'; } // display ribbon contents showRibbon(title, scroll); // update selected menu item $('#menu a').each(function() { if (title == $(this).html().replace(/(<([^>]+)>)/ig, '')) { $(this).addClass('current'); } else { $(this).removeClass('current'); } }); // add current menu selection to cookie $.cookie('menuSection', title, {path: '/'}); } function showRibbon(id, scroll) { id = id.replace(/[^a-zA-Z0-9]/g, '_'); $('#ribbonContent table').each(function() { if ($(this)[0].id) { $(this).addClass('hidden'); } }); $('#ribbon_' + id).removeClass('hidden'); if ($('#ribbonContent').length) { $('#ribbonContent')[0].scrollLeft = scroll; } checkScroll(); } function checkScroll() { if (!$('#ribbonContent').length) return; if (0 < $('#ribbonContent')[0].scrollLeft) { $('#ribbon .prev').removeClass('hidden'); } else { $('#ribbon .prev').addClass('hidden'); } if ($('#ribbonContent')[0].scrollLeft + $('#ribbonContent')[0].clientWidth < $('#ribbonContent')[0].scrollWidth) { $('#ribbon .next').removeClass('hidden'); } else { $('#ribbon .next').addClass('hidden'); } } function ribbonScroll(distance) { if (0 < distance && $('#ribbonContent')[0].scrollWidth < $('#ribbonContent')[0].scrollLeft + distance) { $('#ribbonContent')[0].scrollLeft = $('#ribbonContent')[0].scrollWidth; checkScroll(); clearTimeout(scrollTimerID); } else if (distance < 0 && $('#ribbonContent')[0].scrollLeft + distance < 0) { $('#ribbonContent')[0].scrollLeft = 0; checkScroll(); clearTimeout(scrollTimerID); } else { $('#ribbonContent')[0].scrollLeft = $('#ribbonContent')[0].scrollLeft + distance; checkScroll(); distance = distance * 1.2; scrollTimerID = setTimeout('ribbonScroll('+distance+')', 10); } $.cookie('scroll', $('#ribbonContent')[0].scrollLeft, {path: '/'}); } function loadHtml(file) { if ('undefined' == typeof file) { file = $.cookie('helpFile'); if (null == file) { file = urlHelpRoot; } } // check http vs https - otherwise the help bails with an error thinking we // are trying to use cross site scripting. if (file.substring(0, 5) != urlHelpRoot.substring(0, 5)) { file = (file.substring(0, 5) == 'https') ? file.substring(0, 4) + file.substring(5) : file.substring(0, 4) + 's' + file.substring(4); } $.cookie('helpFile', file, {path: '/'}); $('#sidebar').load(file, {}, function() { $('#sidebar').find('a.help').click(function() { loadHtml($(this)[0].href); return false; }); }); } //----------------------------------------------------------------------------- // table lists //-----------------------------------------------------------------------------