1//Version 1.5.5 2(function (window, undefined) { 3 4 // Prepare our Variables 5 var 6 History = window.History, 7 $ = window.jQuery, 8 document = window.document 9 10 let stateChangeTimer 11 12 // Check to see if History.js is enabled for our Browser 13 if (!History.enabled) return false 14 15 // Wait for Document 16 $(function () { 17 // Prepare Variables 18 var 19 // Application Specific Variables 20 rootUrl = aws_data['rootUrl'], 21 contentSelector = '#' + aws_data['container_id'], 22 $content = $(contentSelector), 23 contentNode = $content.get(0), 24 // Application Generic Variables 25 $body = $(document.body), 26 scrollOptions = { 27 duration: 800, 28 easing: 'swing' 29 } 30 31 // Ensure Content 32 if ($content.length === 0) $content = $body 33 34 // Internal Helper 35 $.expr[':'].internal = function (obj, index, meta, stack) { 36 // Prepare 37 var 38 $this = $(obj), 39 url = $this.attr('href') || '', 40 isInternalLink 41 42 // Check link 43 isInternalLink = url.substring(0, rootUrl.length) === rootUrl || url.indexOf(':') === -1 44 45 // Ignore or Keep 46 return isInternalLink 47 } 48 49 // HTML Helper 50 var documentHtml = function (html) { 51 // Prepare 52 var result = String(html).replace(/<\!DOCTYPE[^>]*>/i, '') 53 .replace(/<(html|head|body|title|script)([\s\>])/gi, '<div id="document-$1"$2') 54 .replace(/<\/(html|head|body|title|script)\>/gi, '</div>') 55 // Return 56 return result 57 } 58 59 // Ajaxify Helper 60 $.fn.ajaxify = function () { 61 // Prepare 62 var $this = $(this) 63 64 // Ajaxify 65 $this.find('a:not(.no-ajaxy,[href^="#"],[href*="wp-login"],[href*="wp-admin"],[target="_blank"])').on('click', function (event) { 66 // Prepare 67 var 68 $this = $(this), 69 url = $this.attr('href'), 70 title = $this.attr('title') || null 71 72 // Continue as normal for cmd clicks etc 73 if (event.which == 2 || event.metaKey) return true 74 75 // Ajaxify this link 76 History.pushState(null, title, url) 77 event.preventDefault() 78 return false 79 }) 80 // Chain 81 return $this 82 } 83 84 // Ajaxify our Internal Links 85 $body.ajaxify() 86 87 // Hook into State Changes 88 $(window).bind('statechange', () => { 89 stateChangedAction() 90 document.title = 'Loading...' 91 92 }) // end onStateChange 93 94 function stateChangedAction() { 95 96 // Prepare Variables 97 var 98 State = History.getState(), 99 url = State.url, 100 relativeUrl = url.replace(rootUrl, '') 101 102 // Set Loading 103 $body.addClass('loading') 104 105 stateChanged() // in index.js 106 107 stateChangeTimer = setTimeout(() => { 108 109 document.title = 'Loading...' 110 111 // Ajax Request the Traditional Page 112 $.ajax({ 113 url: url, 114 success: function (data, textStatus, jqXHR) { 115 // Prepare 116 var 117 $data = $(documentHtml(data)), 118 $dataBody = $data.find('#document-body:first ' + contentSelector), 119 bodyClasses = $data.find('#document-body:first').attr('class'), 120 contentHtml, $scripts 121 122 var $menu_list = $data.find('.' + aws_data['mcdc']) 123 124 //Add classes to body 125 jQuery('body').attr('class', bodyClasses) 126 127 // Fetch the scripts 128 $scripts = $dataBody.find('#document-script') 129 if ($scripts.length) $scripts.detach() 130 131 // Fetch the content 132 contentHtml = $dataBody.html() || $data.html() 133 134 if (!contentHtml) { 135 document.location.href = url 136 return false 137 } 138 139 // Update the content 140 $content.stop(true, true) 141 $content.html(contentHtml) 142 .ajaxify() 143 .css('text-align', '') 144 // .animate({opacity: 1, visibility: "visible"}); 145 146 //Scroll to the top of ajax container 147 if ('' != aws_data['scrollTop']) { 148 jQuery('html, body').animate({ 149 scrollTop: jQuery(contentSelector).offset().top 150 }, 1000) 151 } 152 153 // Update UI - COMMONWP 154 linkChanged() // in index.js 155 156 //Append new menu HTML to provided classs 157 $('.' + aws_data['mcdc']).html($menu_list.html()) 158 $body.ajaxify() 159 //Adding no-ajaxy class to a tags present under ids provided 160 $(aws_data['ids']).each(function () { 161 jQuery(this).addClass('no-ajaxy') 162 }) 163 164 // Update the title 165 document.title = $data.find('#document-title:first').text() 166 try { 167 document.getElementsByTagName('title')[0].innerHTML = document.title.replace('<', '<') 168 .replace('>', '>') 169 .replace(' & ', ' & ') 170 } 171 catch (Exception) { } 172 173 // Add the scripts 174 $scripts.each(function () { 175 var scriptText = $(this).html() 176 177 if ('' != scriptText) { 178 scriptNode = document.createElement('script') 179 scriptNode.appendChild(document.createTextNode(scriptText)) 180 contentNode.appendChild(scriptNode) 181 } else { 182 $.getScript($(this).attr('src')) 183 } 184 }) 185 186 // BuddyPress Support 187 if (aws_data['bp_status']) { 188 $.getScript(rootUrl + '/wp-content/plugins/buddypress/bp-templates/bp-legacy/js/buddypress.js') 189 } 190 191 $body.removeClass('loading') 192 193 // Inform Google Analytics of the change 194 if (typeof window.pageTracker !== 'undefined') window.pageTracker._trackPageview(relativeUrl) 195 196 // Inform ReInvigorate of a state change 197 if (typeof window.reinvigorate !== 'undefined' && typeof window.reinvigorate.ajax_track !== 'undefined') 198 reinvigorate.ajax_track(url)// ^ we use the full url here as that is what reinvigorate supports 199 }, 200 error: function (jqXHR, textStatus, errorThrown) { 201 document.location.href = url 202 return false 203 } 204 205 }) // end ajax 206 207 }, 500) // end of timer 208 } 209 210 }) // end onDomLoad 211 212})(window) // end closure 213 214jQuery(document).ready(function () { 215 216 //Adding no-ajaxy class to a tags present under ids provided 217 jQuery(aws_data['ids']).each(function () { 218 jQuery(this).addClass('no-ajaxy') 219 }) 220 221 //append anchor tag to DOM to make the search in site ajaxify. 222 var searchButtonHtml = '<span id="ajax-search" style="display:none;"><a href=""></a></span>' 223 jQuery("body").prepend(searchButtonHtml) 224 225 //Make the link ajaxify. 226 // jQuery("#ajax-search").ajaxify(); 227 228 //After submitting the search form search the post without refreshing the browser. 229 jQuery(aws_data['searchID']).on('submit', 230 function (d) { 231 d.preventDefault() 232 var host = aws_data['rootUrl'] + "?s=" 233 jQuery("#ajax-search a").attr("href", host + jQuery(this).find('input[type="search"]').val()) 234 jQuery("#ajax-search a").trigger("click") 235 } 236 ) 237})
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.