1/* 2Plugin Name: WP Tab Widget 3Author: MyThemeShop 4Author URI: mythemeshop.com 5*/ 6 7function wpt_loadTabContent(tab_name, page_num, container, args_obj) { 8 var container = jQuery(container); 9 var tab_content = container.find('#' + tab_name + '-tab-content'); 10 11 // only load content if it wasn't already loaded 12 var isLoaded = tab_content.data('loaded'); 13 14 if (tab_name == 'trending') { 15 isLoaded = true; 16 } 17 18 if (!isLoaded || page_num != 1) { 19 if (!container.hasClass('wpt-loading')) { 20 container.addClass('wpt-loading'); 21 22 tab_content.load( 23 wpt.ajax_url, 24 { 25 action: 'wpt_widget_content', 26 tab: tab_name, 27 page: page_num, 28 args: args_obj, 29 }, 30 function () { 31 container.removeClass('wpt-loading'); 32 tab_content.data('loaded', 1).hide().fadeIn().siblings().hide(); 33 } 34 ); 35 } 36 } else { 37 tab_content.fadeIn().siblings().hide(); 38 } 39} 40 41jQuery(document).ready(function () { 42 jQuery('.wpt_widget_content').each(function () { 43 var $this = jQuery(this); 44 var widget_id = this.id; 45 var args = $this.data('args'); 46 47 // load tab content on click 48 $this.find('.wpt-tabs a').click(function (e) { 49 e.preventDefault(); 50 jQuery(this) 51 .parent() 52 .addClass('selected') 53 .siblings() 54 .removeClass('selected'); 55 var tab_name = this.id.slice(0, -4); // -tab 56 wpt_loadTabContent(tab_name, 1, $this, args); 57 }); 58 59 // pagination 60 $this.on('click', '.wpt-pagination a', function (e) { 61 e.preventDefault(); 62 var $this_a = jQuery(this); 63 var tab_name = $this_a.closest('.tab-content').attr('id').slice(0, -12); // -tab-content 64 var page_num = parseInt( 65 $this_a.closest('.tab-content').children('.page_num').val() 66 ); 67 68 if ($this_a.hasClass('next')) { 69 wpt_loadTabContent(tab_name, page_num + 1, $this, args); 70 } else { 71 $this.find('#' + tab_name + '-tab-content').data('loaded', 0); 72 wpt_loadTabContent(tab_name, page_num - 1, $this, args); 73 } 74 }); 75 76 // load first tab now 77 $this.find('.wpt-tabs a').first().click(); 78 }); 79});
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.