1jQuery(function ($) { 2 3 let currentFolder = ""; 4 let currentSort = "desc"; 5 6 // ACTIVE TAB / MENU SELECTION 7 $(document).on('click', '.item, .sub-item', function () { 8 $('.item, .sub-item').removeClass('active'); 9 $(this).addClass('active'); 10 11 // Update URL hash without browser scrolling 12 let navId = $(this).data('nav-id'); 13 if (navId) { 14 history.replaceState(null, null, '#' + navId); 15 } 16 }); 17 18 /* 19 ========================================= 20 STATIC CONTENT CLICK 21 ========================================= 22 */ 23 $(document).on('click', '.item[data-type="content"]', function () { 24 $('.item, .sub-item').removeClass('active'); 25 $(this).addClass('active'); 26 27 let key = $(this).data('key'); 28 let title = $(this).text().trim(); 29 let content = ''; 30 31 if (key === 'board') { 32 content = $('#pff-board-content').html(); 33 } else if (key === 'committees') { 34 content = $('#pff-committee-content').html(); 35 } else if (key === 'corporate-profile') { 36 content = $('#pff-corporate-profile-content').html(); 37 } else if (key === 'annual-reports') { 38 content = $('#pff-annual-reports-content').html(); 39 } 40 41 $('#pff-content-area').html(` 42 <div class="pff-main-heading"> 43 <h2><span>${title}</span></h2> 44 </div> 45 <div class="pff-static-content"> 46 ${content} 47 </div> 48 `); 49 }); 50 51 // LOAD PDF 52 function loadPDF(folder, year = '', heading = '') { 53 currentFolder = folder; 54 55 $('#pff-content-area').html('Loading...'); 56 57 $.post(pff_ajax.ajax_url, { 58 action: 'pff_fetch', 59 folder: folder, 60 year: year, 61 sort: currentSort, 62 heading: heading 63 }, function (res) { 64 $('#pff-content-area').html(res.data); 65 }); 66 } 67 68 // CLICK PDF 69 $(document).on('click', '.item[data-type="pdf"], .sub-item', function () { 70 let folder = $(this).data('folder'); 71 let title = $(this).text().trim(); 72 73 loadPDF(folder, '', title); 74 }); 75 76 /* 77 ========================================= 78 YEAR FILTER 79 ========================================= 80 */ 81 $(document).on('change', '#pff-year-filter', function () { 82 let selectedYear = $(this).val(); 83 loadPDF(currentFolder, selectedYear); 84 }); 85 86 /* 87 ========================================= 88 SORT FILTER 89 ========================================= 90 */ 91 $(document).on('change', '#pff-sort', function () { 92 currentSort = $(this).val(); 93 let selectedYear = $('#pff-year-filter').val(); 94 loadPDF(currentFolder, selectedYear); 95 }); 96 97 /* 98 ========================================= 99 CLEAR FILTER 100 ========================================= 101 */ 102 $(document).on('click', '#pff-clear-filter', function () { 103 currentSort = 'desc'; 104 $('#pff-sort').val('desc'); 105 $('#pff-year-filter').val(''); 106 loadPDF(currentFolder); 107 }); 108 109 /* 110 ========================================= 111 TABS 112 ========================================= 113 */ 114 $('.pff-tabs button').on('click', function (e, isDeepLink = false) { 115 $('.pff-tabs button').removeClass('active'); 116 $(this).addClass('active'); 117 118 let tab = $(this).data('tab'); 119 $('.menu').removeClass('active'); 120 121 let $menu = $('#' + tab).addClass('active'); 122 123 if (!isDeepLink) { 124 let $sub = $menu.find('.sub-item').first(); 125 let $item = $menu.find('.item').first(); 126 127 if ($sub.length) { 128 $menu.find('.sub-menu').show(); 129 $sub.trigger('click'); 130 } else if ($item.length) { 131 $item.trigger('click'); 132 } 133 } 134 }); 135 136 /* 137 ========================================= 138 INIT / HASH ROUTING 139 ========================================= 140 */ 141 function initTabFromHash() { 142 let hash = window.location.hash.replace('#', ''); 143 144 if (hash) { 145 // Check if hash matches a main tab directly (e.g., #ann, #fin, #gov, #off or #tab-ann) 146 let cleanTabHash = hash.replace('tab-', ''); 147 let $topTabBtn = $('.pff-tabs button[data-tab="' + cleanTabHash + '"]'); 148 149 if ($topTabBtn.length) { 150 $topTabBtn.trigger('click'); 151 return; 152 } 153 154 // Check if hash matches a specific item via data-nav-id 155 let $targetElement = $('[data-nav-id="' + hash + '"]'); 156 157 if ($targetElement.length) { 158 if ($targetElement.is('.pff-tabs button')) { 159 $targetElement.trigger('click'); 160 return; 161 } 162 163 let $parentMenu = $targetElement.closest('.menu'); 164 if ($parentMenu.length) { 165 let parentTabId = $parentMenu.attr('id'); 166 let $parentTabBtn = $('.pff-tabs button[data-tab="' + parentTabId + '"]'); 167 168 $parentTabBtn.trigger('click', [true]); 169 170 if ($targetElement.hasClass('sub-item')) { 171 $targetElement.closest('.sub-menu').show(); 172 $targetElement.closest('.sub-menu').prev('.has-sub').addClass('active'); 173 } 174 175 $targetElement.trigger('click'); 176 return; 177 } 178 } 179 } 180 181 // Default initial load if no URL hash exists 182 $('.pff-tabs button.active').trigger('click'); 183 } 184 185 initTabFromHash(); 186 187 /* 188 ========================================= 189 SUBMENU 190 ========================================= 191 */ 192 $(document).on('click', '.has-sub', function () { 193 $(this).toggleClass('active'); 194 $(this).next('.sub-menu').slideToggle(200); 195 });
196 197 /* 198 ========================================= 199 MODAL OPEN 200 ========================================= 201 */ 202 $(document).on('click', '.pff-view', function () { 203 var pdfUrl = $(this).data('url'); 204 205 $('#pff-modal').addClass('active'); 206 207 $('#pff-frame').attr( 208 'src', 209 pff_ajax.plugin_url + 210 'pdfjs/web/viewer.html?file=' + 211 encodeURIComponent(pdfUrl) + 212 '#zoom=page-width' 213 ); 214 }); 215 216 /* 217 ========================================= 218 MODAL CLOSE 219 ========================================= 220 */ 221 $('.pff-close').click(function () { 222 $('#pff-modal').removeClass('active'); 223 $('#pff-frame').attr('src', ''); 224 }); 225 226});
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.