1jQuery(document).ready(function ($) { 2 3 var shortcodeWrapper = $( '.ascustomfaq-shortcode-wrapper h3' ), 4 archiveWrapper = $( '.ascustomfaq-category-wrapper h3' ), 5 kbWrapper = $( '.ascustomfaq-kb-main span' ); 6 7 function accordionizeContent() { 8 var tis = $(this), 9 state = false, 10 answer = tis.next('div').slideUp(); 11 tis.on('click', function () { 12 state = !state; 13 14 // Update the UI 15 answer.slideToggle(state); 16 tis.toggleClass('active', state); 17 18 // Count the view 19 ascustomfaq_count_view_ajax(tis); 20 }); 21 } 22 23 shortcodeWrapper.each( accordionizeContent ); 24 archiveWrapper.each( accordionizeContent ); 25 kbWrapper.each( accordionizeContent ); 26 27 /** 28 * AJAX Count View 29 * Count the clicks when expanding a CUSTOMFAQ (only once) 30 */ 31 var alreadyClicked = []; 32 33 function ascustomfaq_count_view_ajax(tis) { 34 var id = tis.attr('data-id'); 35 var data = { 36 'action': 'ascustomfaq_count_view', 37 'customfaq_id': id 38 }; 39 40 if ($.inArray(id, alreadyClicked) == -1) { 41 alreadyClicked.push(id); 42 $.post(ascustomfaq.ajaxurl, data); 43 } 44 } 45 46 /** 47 * Live Search 48 * http://jsfiddle.net/umaar/t82gZ/ 49 */ 50 var searchInput = $('#ascustomfaq_sc_search_input'), 51 searchCount = $('#ascustomfaq_sc_search_count'), 52 searchClear = $('#ascustomfaq_sc_search_clear'), 53 searchItems = $('.ascustomfaq_item'); 54 55 searchInput.keyup(function () { 56 57 // Retrieve the input field text and reset the count to zero 58 var filter = $(this).val(), 59 count = 0; 60 61 // Loop through the CUSTOMFAQ list 62 searchItems.each(function () { 63 64 // If the list item does not contain the text phrase fade it out 65 if ($(this).text().search(new RegExp(filter, 'i')) < 0) { 66 $(this).addClass('ascustomfaq_item_has_result').fadeOut(); 67 } 68 // Show the list item if the phrase matches and increase the count by 1 69 else { 70 $(this).removeClass('ascustomfaq_item_has_result').show(); 71 count++; 72 } 73 74 }); 75 76 // Update the count 77 var countText; 78 count >= 2 ? countText = 'results found.' : countText = 'result found.'; 79 searchCount.text(count + ' ' + countText); 80 }); 81 82 // Clear the search input 83 searchClear.on('click', function (event) { 84 event.preventDefault(); 85 searchInput.val('').trigger('keyup'); 86 }); 87 88 var kbCategory = $( '.ascustomfaq-kb-category' ); 89 90 kbCategory.on( 'click', function( event ) { 91 event.preventDefault(); 92 93 $.ajax({ 94 type: 'POST', 95 url: ajaxurl, 96 data: { 97 slug: $( this ).data( 'slug' ), 98 action: 'get_category_customfaqs' 99 // nonce: $( 'ascustomfaq.nonce, 100 }, 101 dataType: "json", 102 success: function( response ) { 103 if ( response.success ) { 104 var kbMain = $( '#ascustomfaq-kb-main' ); 105 106 kbMain.each( accordionizeContent ); 107 kbMain.html( response.data.output ); 108 109 } 110 kbWrapper.each( accordionizeContent ); 111 112 } 113 }).fail(function (response) { 114 if ( window.console && window.console.log ) { 115 console.log( response ); 116 } 117 }); 118 119 }) 120});
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.