1var cbrTools = (function () { 2 function scrollToElementIfNeed($elt) { 3 var y = $elt.offset().top; 4 var space = 120; 5 y = y - space; 6 if (y < 0) y = 0; 7 8 var scrollTop = $(window).scrollTop(); 9 var windowHeight = $(window).height(); 10 11 if (!(scrollTop <= y && y < scrollTop + windowHeight - 2 * space)) { 12 if (scrollTop + windowHeight - 2 * space <= y && y < scrollTop + windowHeight) { 13 y = y + 2 * space - windowHeight; 14 } 15 window.scrollTo(0, y); 16 } 17 } 18 function scrollToElement($elt, mode) { 19 scrollTo($elt.offset().top, $elt.height(), mode); 20 } 21 function scrollTo(eltTop, eltHeight, mode) { 22 if (eltTop) { 23 if (!eltHeight) eltHeight = 0; 24 25 var currentScrollTop = $(window).scrollTop(); 26 var windowHeight = $(window).height(); 27 var scrollToY; 28 switch (mode) { 29 case 'topIfNeed': 30 var y1 = eltTop - windowHeight / 3, y2 = eltTop; 31 if (y1 <= currentScrollTop && currentScrollTop <= y2) scrollToY = void 0; 32 else scrollToY = y1; 33 break; 34 case 'middle': 35 default: 36 scrollToY = eltHeight < windowHeight * 2 / 3 ? eltTop - (windowHeight - eltHeight) / 2 : (eltTop - windowHeight / 3); 37 break; 38 } 39 40 if (typeof (scrollToY) == 'number') { 41 if (scrollToY < 0) scrollToY = 0; 42 window.scrollTo(0, scrollToY); 43 } 44 } 45 } 46 47 var $liveRegion = null; 48 $(function () { 49 $liveRegion = $('<div/>', { 50 'role': 'status', 51 'aria-live': 'assertive', 52 'aria-relevant': 'additions' 53 }) 54 .addClass('ui-helper-hidden-accessible') 55 .appendTo($('body')); 56 }); 57 function accessibleMessage(message) { 58 if (message) { 59 $liveRegion.children().hide(); 60 $('<div>').text(message).appendTo($liveRegion); 61 } 62 } 63 64 return { 65 scrollToElementIfNeed: scrollToElementIfNeed, 66 scrollToElement: scrollToElement, 67 scrollTo: scrollTo, 68 accessibleMessage: accessibleMessage 69 } 70})(); 71 72$(function () { 73 var $anchorElement; 74 function highlightAnchor() { 75 try { 76 $(window).unbind('hashchange.highlightAnchor'); 77 78 var anchor = window.location.hash; 79 if (anchor && $anchorElement && $(anchor).get(0) === $anchorElement.get(0)) return; 80 if ($anchorElement) { 81 if ($anchorElement.is('.referenceable')) { 82 $anchorElement.removeClass('yellow'); 83 } 84 $anchorElement = null; 85 } 86 if (anchor && /^#[a-z0-9-_]+$/i.test(anchor)) { 87 var $elt = $(anchor); 88 if ($elt.length !== 0) { 89 $anchorElement = $elt; 90 if ($elt.is('.referenceable')) { 91 $anchorElement.addClass('yellow'); 92 } 93 $elt.trigger('open-anchor', [true]); 94 if (anchor !== window.location.hash) { 95 var from = window.location.hash; 96 window.location.hash = anchor; 97 } 98 } 99 } 100 } 101 finally { 102 $(window).bind('hashchange.highlightAnchor', highlightAnchor); 103 } 104 } 105 setTimeout(highlightAnchor, 0); 106 107 $.fn.replaceText = function (search, replace, text_only) { 108 return this.each(function () { 109 var node = this.firstChild, 110 val, 111 new_val, 112 remove = []; 113 if (node) { 114 do { 115 if (node.nodeType === 3) { 116 val = node.nodeValue; 117 new_val = val.replace(search, replace); 118 if (new_val !== val) { 119 if (!text_only && /</.test(new_val)) { 120 $(node).before(new_val); 121 remove.push(node); 122 } else { 123 node.nodeValue = new_val; 124 } 125 } 126 } 127 else if (node.nodeType === 1) { 128 $(node).replaceText(search, replace, text_only); 129 } 130 } while (node = node.nextSibling); 131 } 132 remove.length && $(remove).remove(); 133 }); 134 }; 135 136 function highlightSearch() { 137 try { 138 $(window).unbind('hashchange.highlightSearch'); 139 140 if (location.hash && location.hash.indexOf('#highlight=') === 0) { 141 $('mark').each(function () { $(this).replaceWith($(this).html()); }); 142 var wordsPattern = decodeURIComponent(location.hash.split('=')[1]); 143 if (/^[a-zа-ÑÑ0-9_\-]+(\|[a-zа-ÑÑ0-9_\-]+)*$/gi.exec(wordsPattern)) { 144 $('#content').replaceText(new RegExp('(^|[^a-zа-ÑÑ0-9_\\-])(' + wordsPattern + ')(?=$|[^a-zа-ÑÑ0-9_\\-])', 'gi'), '$1<mark>$2</mark>'); 145 } 146 var $marks = $('mark'); 147 if ($marks.length) { 148 $marks.trigger('open-anchor'); 149 //$marks.parents().addBack().each(function () { $(this).triggerHandler('open-anchor'); }); 150 setTimeout(function () { cbrTools.scrollToElementIfNeed($marks); }, 200); 151 } 152 } 153 } 154 finally { 155 $(window).bind('hashchange.highlightSearch', highlightSearch); 156 } 157 } 158 setTimeout(highlightSearch, 0); 159 160});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.