Copied to clipboard
' + '' ); copyTooltipSpan.prepend(tooltipContainer); copyTooltipSpan.mouseleave(function() { tooltipContainer.remove(); }); setTimeout(function(){ tooltipContainer.remove();}, 3000); } } catch (err) { // Unable to copy if (copyTooltipSpan.find('.wh-tooltip').length == 0) { var tooltipContainer = $( '' + 'Oops, unable to copy
' + '' ); copyTooltipSpan.mouseleave(function() { tooltipContainer.remove(); }); copyTooltipSpan.prepend(tooltipContainer); setTimeout(function(){ tooltipContainer.remove(); }, 3000); } // WH-1806 //$('.copyTooltip').tooltip({title: 'Oops, unable to copy', trigger: "click"}); util.debug('Oops, unable to copy codeblock content!', err) } document.body.removeChild(textArea); } /** * Check to see if the window is top if not then display button */ $(window).scroll(function(){ if ($(this).scrollTop() > 5) { $('#go2top').fadeIn('fast'); } else { $('#go2top').fadeOut('fast'); } }); /** * Click event to scroll to top */ $('#go2top').click(function(){ $('html, body').animate({scrollTop : 0},800); return false; }); }); /** * @description Handle the vertical position of the side toc */ function handleSideTocPosition(scrollPosition) { var scrollPosition = scrollPosition !== undefined ? scrollPosition : 0; var $sideToc = $(".wh_publication_toc"); var $sideTocID = $("#wh_publication_toc"); var $navSection = $(".wh_tools"); var bottomNavOffset = 0; var $slideSection = $('#wh_topic_body'); var topOffset = 20; var visibleAreaHeight = parseInt($(window).height()) - parseInt($(".wh_footer").outerHeight()); if ($sideToc.length > 0 && $slideSection.length > 0) { var minVisibleOffset = $(window).scrollTop(); var tocHeight = parseInt($sideToc.height()) + parseInt($sideToc.css("padding-top")) + parseInt($sideToc.css("padding-bottom")) + parseInt($sideToc.css("margin-top")) + parseInt($sideToc.css("margin-bottom")); var tocWidth = parseInt($sideTocID.outerWidth()) - parseInt($sideTocID.css("padding-left")) - parseInt($sideTocID.css("padding-right")); var tocXNav = parseInt($slideSection.offset().left) - tocWidth; if (scrollPosition > $(window).scrollTop()) { if ($sideToc.offset().top < $sideToc.parent().offset().top) { $sideToc.css('position', 'inherit'); } } else { if (tocHeight > $(window).height()) { $sideToc.css('position', 'inherit'); } } if ($navSection.length > 0) { bottomNavOffset = parseInt($navSection.offset().top) + parseInt($navSection.height()) + parseInt($navSection.css("padding-top")) + parseInt($navSection.css("padding-bottom")) + parseInt($navSection.css("margin-top")) + parseInt($navSection.css("margin-bottom")); } if (bottomNavOffset > minVisibleOffset) { minVisibleOffset = bottomNavOffset; } if (tocHeight <= visibleAreaHeight) { var cHeight = parseInt($('.wh_content_area').height()); if (parseInt(minVisibleOffset - topOffset) <= $(window).scrollTop() && parseInt($(window).width()) > 767) { $('.wh_content_area').css('min-height', cHeight+'px'); $sideToc.css("top", topOffset + "px").css("width", tocWidth + "px").css("position", "fixed").css("z-index", "999"); } else { $sideToc.removeAttr('style'); } } else { $sideToc.removeAttr('style'); } scrollPosition = $(window).scrollTop(); } return $(window).scrollTop(); } /** * @description Highlight the current node in the page toc section on page scroll or clicking on Topic TOC items */ function pageTocHighlightNode(scrollPosition) { var scrollPosition = scrollPosition !== undefined ? Math.round(scrollPosition) : 0; var topOffset = 150; var hash = location.hash != undefined ? location.hash : ""; var hashOffTop = $(hash).offset() != undefined ? $(hash).offset().top : 0; var elemHashTop = hash != "" ? Math.round(hashOffTop) : 0; if( hash.substr(1) != '' && elemHashTop >= scrollPosition && (elemHashTop <= (scrollPosition + topOffset)) ){ $('#wh_topic_toc a').removeClass('current_node'); $('#wh_topic_toc a[data-tocid = "'+ hash.substr(1) + '"]').addClass('current_node'); } else { $.each( $('.wh_topic_content .title'), function (e) { var currentId = $(this).parent().attr('id'); var elemTop = Math.round($(this).offset().top); if( elemTop >= scrollPosition && (elemTop <= (scrollPosition + topOffset)) ){ $('#wh_topic_toc a').removeClass('current_node'); $('#wh_topic_toc a[data-tocid = "'+ currentId + '"]').addClass('current_node'); } }); } return $(window).scrollTop(); } /** * @description Handle the vertical position of the page toc */ function handlePageTocPosition(scrollPosition) { scrollPosition = scrollPosition !== undefined ? scrollPosition : 0; var $pageTOCID = $("#wh_topic_toc"); var $pageTOC = $(".wh_topic_toc"); var $navSection = $(".wh_tools"); var bottomNavOffset = 0; var topOffset = 33; var $contentBody = $(".wh_topic_content"); if ($pageTOC.length > 0) { pageTocHighlightNode(scrollPosition); var visibleAreaHeight = parseInt($(window).height()) - parseInt($(".wh_footer").outerHeight()); var tocHeight = parseInt($pageTOC.height()) + parseInt($pageTOC.css("padding-top")) + parseInt($pageTOC.css("padding-bottom")) + parseInt($pageTOC.css("margin-top")) + parseInt($pageTOC.css("margin-bottom")); var tocWidth = parseInt($pageTOCID.outerWidth()) - parseInt($pageTOCID.css("padding-left")) - parseInt($pageTOCID.css("padding-right")); var minVisibleOffset = $(window).scrollTop(); if ($navSection.length > 0) { bottomNavOffset = parseInt($navSection.offset().top) + parseInt($navSection.height()) + parseInt($navSection.css("padding-top")) + parseInt($navSection.css("padding-bottom")) + parseInt($navSection.css("margin-top")) + parseInt($navSection.css("margin-bottom")); } if (bottomNavOffset > minVisibleOffset) { minVisibleOffset = bottomNavOffset; } if ((tocHeight+topOffset) < visibleAreaHeight && (bottomNavOffset-topOffset) < $(window).scrollTop() && (tocHeight+topOffset) < $contentBody.height()) { if (parseInt(minVisibleOffset - topOffset) <= $(window).scrollTop() && parseInt($(window).width()) > 767) { $pageTOC.css("top", "20px").css("position", "fixed").css("width", tocWidth + "px").css("height", tocHeight + "px"); } else { $pageTOC.removeAttr('style'); } } else { $pageTOC.removeAttr('style'); } } } /** * @description Highlight searched words */ function highlightSearchTerm() { util.debug("highlightSearchTerm()"); if (highlighted) { return; } try { var $body = $('.wh_topic_content'); var $relatedLinks = $('.wh_related_links'); var $childLinks = $('.wh_child_links'); // Test if highlighter library is available if (typeof $body.removeHighlight != 'undefined') { $body.removeHighlight(); $relatedLinks.removeHighlight(); var hlParameter = util.getParameter('hl'); if (hlParameter != undefined) { var jsonString = decodeURIComponent(String(hlParameter)); util.debug("jsonString: ", jsonString); if (jsonString !== undefined && jsonString != "") { var words = jsonString.split(','); util.debug("words: ", words); for (var i = 0; i < words.length; i++) { util.debug('highlight(' + words[i] + ');'); $body.highlight(words[i]); $relatedLinks.highlight(words[i]); $childLinks.highlight(words[i]); } } } } else { // JQuery highlights library is not loaded } } catch (e) { util.debug (e); } highlighted = true; } /* * Hide the highlight of the search results */ $('.wh_hide_highlight').click(function(){ $('.highlight').addClass('wh-h'); $('.wh-h').toggleClass('highlight'); $(this).toggleClass('hl-close'); }); /* * Show the highlight button only if 'hl' parameter is found */ if( util.getParameter('hl')!= undefined ){ $('.wh_hide_highlight').show(); } var isTouchEnabled = false; try { if (document.createEvent("TouchEvent")) { isTouchEnabled = true; } } catch (e) { util.debug(e); } /** * Open the link from top_menu when the current group is expanded. * * Apply the events also on the dynamically generated elements. */ $(document).on('click', ".wh_top_menu li", function (event) { $(".wh_top_menu li").removeClass('active'); $(this).addClass('active'); $(this).parents('li').addClass('active'); event.stopImmediatePropagation(); }); $(document).on('click', '.wh_top_menu a', function (event) { var pointerType; if (typeof event.pointerType !== "undefined") { pointerType = event.pointerType; } if ($(window).width() < 767 || isTouchEnabled || pointerType == "touch") { var areaExpanded = $(this).closest('li'); var isActive = areaExpanded.hasClass('active'); var hasChildren = areaExpanded.hasClass('has-children'); if (isActive || !hasChildren) { window.location = $(this).attr("href"); event.preventDefault(); event.stopImmediatePropagation(); return false; } else { event.preventDefault(); } } else { return true; } }); });