PageSourceSearch

https://radiohay.am/wp-content/plugins/qt-ajax-pageload/js/qt-ajax-pageload.js?ver=1.0

js radiohay.am collected 2026-10-06 18:18:00 UTC 6,188 bytes, 216 lines download raw bytes

1/**====================================================================
2 *
3 *  QT Ajax Page Loader main script
4 *  @author QantumThemes
5 *  
6 ====================================================================**/
7(function($) {
8	"use strict";
9	$("body").append('<div id="qtajaxpreloadericon"><i class="dripicons-loading" ></i></div>');
10	var qtAplSelector ="#maincontent",
11		qtAplMaincontent = $(qtAplSelector),
12		atAplPreloader = $("#qtajaxpreloadericon");
13	
14	/**
15	 * [Before switching content let's scroll to top]
16	 * @return {[bol]}
17	 */
18	$.fn.qtAplScrollTop = function(){
19		$('html, body').animate({
20			scrollTop: 0
21		},100, 'easeOutExpo');
22		return true;
23	};
24	
25	/**
26	 * [Main ajax initialization function]
27	 */
28	$.fn.qtAplInitAjaxPageLoad = function(){
29		$("body").off("click",'a');
30
31		/**
32		 * [Bind click function to all the links]
33		 */
34		$("body").on("click",'a', function(e) {
35			var that = $(this),
36				href = $(this).attr('href');
37
38			if(href === undefined){
39				return e;
40			}
41			if(href === ""){
42				return e;
43			}
44			/**
45			 * [exceptions that will skip ajax loading]
46			 */
47			if ( (href.match(/^https?\:/i)) && (!href.match(document.domain))  || that.attr("target") === '_blank' || that.hasClass("noajax") || that.attr("type") === 'submit' || that.attr("type") === 'button' || href.match("respond|wp-admin|mailto:|checkout|.zip|.jpg|.gif|.mp3|.pdf|.png|.rar|product|shop|cart|#noajax") ) {
48				return true;
49			} 
50			if(href.match(document.domain) ){
51				e.preventDefault();
52				if (window.history.pushState) {
53					var pageurl = href;
54					if (pageurl !== window.location) {
55						window.history.pushState({
56						path: pageurl,
57						state:'new'
58						}, '', pageurl);
59					}
60				}
61				/**
62				 * Close the sidebar and player
63				 */
64				$('.button-collapse').sideNav('hide');
65				$('.button-playlistswitch').sideNav('hide');
66				$("li.current_page_item").removeClass("current_page_item");
67				that.closest("li").addClass("current_page_item");
68				atAplPreloader.addClass("qt-visible");
69
70				qtAplMaincontent.fadeTo( "fast" ,0, function() {
71					 $.fn.qtAplScrollTop();
72				}).promise().done(function(){
73					qtAplExecuteAjaxLink(href);
74				});
75			}
76		});
77
78		/**
79		 * [ajax call]
80		 * @param  {[text]} link [url to load]
81		 * @return {[bol]}
82		 */
83		function qtAplExecuteAjaxLink(link){
84			var docClass, parser;
85			$.ajax({
86				url: link,
87				success:function(data) {
88					/*
89					*   Retrive the contents
90					*/
91				
92					$.ajaxData = data;
93					parser = new DOMParser();
94					$.qtAplAjaxContents = $($.ajaxData).filter(qtAplSelector).html();
95					$.qtAplAjaxTitle = $($.ajaxData).filter("title").text();
96					docClass = $($.ajaxData).filter("body").attr("class");
97
98					$.qtAplBodyMatches = data.match(/<body.*class=["']([^"']*)["'].*>/);
99
100					
101					if(typeof($.qtAplBodyMatches) !== 'undefined'){
102					   	docClass = $.qtAplBodyMatches[1];
103					}else{
104						window.location.replace(link);
105					}
106
107
108					// New method better working: 
109					var modifiedAjaxResult = data.replace(/<body/i,'<div id="re_body"').replace(/<\/body/i,'</div'),
110						bodyClassesNew = $(modifiedAjaxResult).filter("#re_body").attr("class");
111
112					if(bodyClassesNew){
113						docClass = bodyClassesNew;
114					}
115
116
117					$.wpadminbar = $($.ajaxData).filter("#wpadminbar").html(); 
118					$.visual_composer_styles = $($.ajaxData).filter('style[data-type=vc_shortcodes-custom-css]').text();					
119					/**
120					 * [if we have WPML plugin language selector]
121					 */
122					if($("#qwLLT")){
123						$.langswitcher = $($.ajaxData).find("#qwLLT").html(); 
124					}
125
126					/*
127					*   Start putting the data in the page
128					*/
129					if(docClass !== undefined && $.qtAplAjaxContents !== undefined){
130						$.fn.closeModal();
131						$("body").attr("class",docClass);
132						$("title").text($.qtAplAjaxTitle);
133						$("#wpadminbar").html($.wpadminbar);
134						$("#qwLLT").html($.langswitcher);
135						if($("style[data-type=vc_shortcodes-custom-css]").length > 0){
136							$("style[data-type=vc_shortcodes-custom-css]").append($.visual_composer_styles);
137						} else {
138							$("head").append('<style type="text/css"  data-type="vc_shortcodes-custom-css">'+$.visual_composer_styles+'</style>');
139						}
140						qtAplMaincontent.html( $.qtAplAjaxContents ).delay(100).promise().done(function(){
141							var scripts = qtAplMaincontent.find("script");
142							if(scripts.length > 0){
143								scripts.each(function(){
144									var code = $(this).html();
145									// code = '('+code+')'; // not really needed
146									eval(code);
147								});	
148							}
149							if(true === $.fn.initializeAfterAjax()){
150								$.fn.initializeVisualComposerAfterAjax();
151								atAplPreloader.removeClass("qt-visible");
152								qtAplMaincontent.fadeTo( "fast" ,1);
153							}else{
154								window.location.replace(link);
155							}
156						});   
157
158					}else{
159						window.location.replace(link);
160					}
161				},
162				error: function () {
163					//Go to the link normally
164					window.location.replace(link);
165				}
166			});
167			return true;
168		}
169		/**
170		 * Manage browser back and forward arrows
171		 */
172		$(window).on("popstate", function(e) {
173			var href;
174			if (e.originalEvent.state !== null) {
175				href = location.href;
176				if(href !== undefined){
177					if (!href.match(document.domain))    {
178						window.location.replace(href);
179					} else {
180						// qtAplExecuteAjaxLink(href);
181						qtAplMaincontent.fadeTo( "fast" ,0, function() {
182							$.fn.qtAplScrollTop();
183						}).promise().done(function(){
184							qtAplExecuteAjaxLink(href);
185						});
186					}
187				}
188			} else {
189				href = location.href;
190				if(href !== undefined){
191					if (!href.match(document.domain))    {
192						window.location.replace(href);
193					} else {
194						qtAplMaincontent.fadeTo( "fast" ,0, function() {
195							$.fn.qtAplScrollTop();
196						}).promise().done(function(){
197							qtAplExecuteAjaxLink(href);
198						});
199					}
200								
201				}
202			}
203		});
204	}; // $.fn.qtAplInitAjaxPageLoad
205
206	/**====================================================================
207	 *
208	 *	Page Ready Trigger
209	 * 	This needs to call only $.fn.qtInitTheme
210	 * 
211	 ====================================================================*/
212	jQuery(document).ready(function() {
213		$.fn.qtAplInitAjaxPageLoad();		
214	});
215
216})(jQuery);

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.