/* jQuery Highlight plugin * Based on highlight v3 by Johann Burkard * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html * Copyright (c) 2009 Bartek Szopka * Licensed under MIT license. * Modified to require a minimum number of characters before searching *//* eslint-disable */ ;jQuery.extend({highlight:function(a,c,b,d,f) {if(3===a.nodeType) {if(c=a.data.match(c))return b=document.createElement(b||"span"),b.className=d||"highlight",a=a.splitText(c.index),a.splitText(c[0].length),d=a.cloneNode(!0),b.appendChild(d),a.parentNode.replaceChild(b,a),1}else if(1===a.nodeType&&a.childNodes&&!/(script|style)/i.test(a.tagName)&&1>$(a).closest(f).length&&(a.tagName!==b.toUpperCase()||a.className!==d))for(var e=0;e').html('
'));return this.$tip},validate:function() {this.$element[0].parentNode||(this.hide(),this.options=this.$element=null)},enable:function() {this.enabled=!0},disable:function() {this.enabled=!1},toggleEnabled:function() {this.enabled= !this.enabled}};b.fn.tipsy=function(a) {function c(e) {var c=b.data(e,"tipsy");c||(c=new l(e,b.fn.tipsy.elementOptions(e,a)),b.data(e,"tipsy",c));return c}function d() {var b=c(this);b.hoverState="in";0==a.delayIn?b.show():(b.fixTitle(),setTimeout(function() {"in"==b.hoverState&&b.show()},a.delayIn))}function f() {var b=c(this);b.hoverState="out";0==a.delayOut?b.hide():setTimeout(function() {"out"==b.hoverState&&b.hide()},a.delayOut)}if(!0===a)return this.data("tipsy");if("string"==typeof a) {var g=this.data("tipsy"); if(g)g[a]();return this}a=b.extend({},b.fn.tipsy.defaults,a);a.live||this.each(function() {c(this)});if("manual"!=a.trigger) {var g=a.live?"live":"bind",h="hover"==a.trigger?"mouseleave":"blur";this[g]("hover"==a.trigger?"mouseenter":"focus",d)[g](h,f)}return this};b.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:0.8,title:"title",theme:["black","white"],trigger:"hover"};b.fn.tipsy.elementOptions=function(a,c) {return b.metadata? b.extend({},c,b(a).metadata()):c};b.fn.tipsy.autoNS=function() {return b(this).offset().top>b(document).scrollTop()+b(window).height()/2?"s":"n"};b.fn.tipsy.autoWE=function() {return b(this).offset().left>b(document).scrollLeft()+b(window).width()/2?"e":"w"};b.fn.tipsy.autoBounds=function(a,c) {return function() {var d=c[0],f=1 0 ? '' : value.length > 2 ? 'No results' : 'Please enter three or more letters' ); } else { message(''); } }, message = function(text) { $status .attr('original-title', text) .tipsy( text === '' ? 'hide' : 'show' ); // make sure the result count doesn't cover the search text $search.css('padding-right', $status.width() + 5); }, jumpTo = function() { if (resultsLength) { var resultPosition, parentPosition, leftPosition, $current = $results.eq(index), $collapsible = $current.closest('.collapsible, tr[id]'); if ($collapsible.length && $collapsible.is(':hidden')) { $collapsible.slideToggle(); } if ($current.length) { resultPosition = $current.offset().top; parentPosition = $collapsible.length ? $current.closest('tr[id]').offset().top : resultPosition; if (parentPosition + $(window).height() < resultPosition) { parentPosition = resultPosition; } leftPosition = 0; if ( $current.position().left > $(window).width() - menuWidth ) { leftPosition = $(window).width(); } window.scrollTo( leftPosition, parentPosition - 28 ); } } updateStatus(); }, applySearch = function() { searching = queryString.parse(search); if (searching.q) { $('#main-nav-check').prop('checked', true); $search .val( searching.q ) // make searching.index a zero-based index .trigger('change', [ isNaN(searching.index) ? 0 : parseInt(searching.index, 10) - 1 ]); } }; // make sure defaults are set $('#word, #csfalse').click(); $search // needed for IE .on('keyup', function(e) { if (e.which === 13) { $(this).trigger('change'); } }) .add('#word, #letter, #cstrue, #csfalse').on('change', function(event, newIndex) { index = newIndex || 0; $status.addClass('busy'); setTimeout(function() { $main .unhighlight() .highlight( $search.val(), { ignore:'thead', wordsOnly: $word.is(':checked'), caseSensitive: $case.is(':checked') }); $results = $('.highlight'); resultsLength = $results.length; if (index > resultsLength) { index = resultsLength - 1; } jumpTo(); }, 1); }); $('.search-prev, .search-next').click(function() { if (resultsLength) { index = index + ($(this).hasClass('search-prev') ? -1 : 1); if (index < 0) { index = resultsLength - 1; } if (index > resultsLength - 1) { index = 0; } jumpTo(); } }); $('.search-clear').click(function() { $search.val('').change(); updateStatus(); }); $main.on('click', '.highlight', function() { index = $results.index(this); updateStatus(); }); $('#main-nav-check').on('change', function() { var isChecked = this.checked; setTimeout(function() { $status.tipsy( isChecked ? 'show' : 'hide' ); }, 250); }); $('.tooltip-bottom').tipsy({ gravity: 'n' }); $('.tooltip-top').tipsy({ gravity: 's' }); $('.tooltip-edge-left').tipsy({ gravity: 'nw' }); $('.tooltip-edge-right').tipsy({ gravity: 'ne' }); $('.tooltip-right').tipsy({ gravity: 'w' }); $status.tipsy({ gravity: 's', opacity: 1, theme: [ '#d9534f', 'white' ] }); $status.tipsy('hide'); // search on load // ?q=array&index=10 if (search) { applySearch(); } });