PageSourceSearch

https://emarket88.ir/wp-content/plugins/sw_woocommerce/js/category-ajax.js

js emarket88.ir collected 2026-09-28 09:00:57 UTC 8,394 bytes, 265 lines download raw bytes

1/*
2	** Category Ajax Js
3	** Version: 1.0.0
4*/
5(function ($) {
6	$(document).ready(function(){
7		/* Category slider ajax */
8		$('[data-catload=ajax]').on('click', function() {
9			sw_tab_click_ajax( $(this) );
10		});
11		$('[data-catload=ajax_listing]').on('click', function() {
12			sw_tab_ajax_listing( $(this) );
13		});
14		
15		$('[data-catload=so_ajax]').on('click', function() {
16			sw_tab_click_ajax( $(this) );
17		});
18		
19		
20		function sw_tab_click_ajax( element ) {			
21			var target 		= $( element.attr( 'href' ) );
22			var id 				= element.attr( 'href' );
23			var length		= element.data( 'length' );
24			var ltype     = element.data( 'type' );
25			var layout 		= element.data( 'layout' );
26			var orderby 	= element.data( 'orderby' );
27			var order 		= element.data( 'order' );
28			var item_row  = element.data( 'row' );
29			var item_row2   = element.data('item_row2');
30			var sorder    = element.data( 'sorder' );
31			var catid 		= element.data( 'category' );
32			var number 		= element.data( 'number' );
33			var columns 	= element.data( 'lg' );
34			var columns1 	= element.data( 'md' );
35			var columns2 	= element.data( 'sm' );
36			var columns3 	= element.data( 'xs' );
37			var columns4 	= element.data( 'mobile' );
38			var interval 	= element.data( 'interval' );
39			var scroll 		= element.data( 'scroll' );
40			var speed 		= element.data( 'speed' );
41			var autoplay 	= element.data( 'autoplay' );	
42			var tg_append = element.parents( '.sw-ajax' ).find( ' .tab-content' );
43			var action = '';
44			if( ltype == 'cat_ajax' ) {
45				action = 'sw_category_callback';
46			} else if( ltype == 'so_ajax' ) {
47				action = 'sw_tab_category';
48			} else if( ltype == 'tab_ajax' ) {
49				action = 'sw_ajax_tab';
50			}else if( ltype == 'tab_ajax_listing' ) {
51				action = 'sw_ajax_tab_listing';
52			}else if( ltype == 'tab_ajax_countdown' ) {
53				action = 'sw_ajax_tab_countdown';
54			}
55			var ajaxurl   = element.data( 'ajaxurl' ).replace( '%%endpoint%%', action );
56			if( !element.parent().hasClass ('loaded') ){
57				tg_append.addClass( 'loading' );
58				var data 		= {
59					action: action,
60					catid: catid,
61					number: number,
62					target: id,
63					title_length: length,
64					layout: layout,
65					item_row: item_row,
66					item_row2: item_row2,
67					layout: layout,
68					sorder: sorder,
69					orderby: orderby,
70					order: order,
71					columns: columns,
72					columns1: columns1,
73					columns2: columns2,
74					columns3: columns3,
75					columns4: columns4,
76					interval: interval,
77					speed: speed,
78					scroll: scroll,
79					autoplay: autoplay,
80				};
81				jQuery.post(ajaxurl, data, function(response) {
82					element.parent().addClass( 'loaded' );
83					tg_append.find( '.tab-pane' ).removeClass( 'active' );
84					tg_append.append( response );
85					sw_slider_ajax( id );
86					
87					$( ".add_to_cart_button" ).attr( "title", "Add to cart" );
88					$( ".add_to_wishlist" ).attr( "title", "Add to wishlist" );
89					$( ".compare" ).attr( "title", "Add to compare" );
90					$( ".group" ).attr( "title", "Quickview" );
91
92					if( ltype == 'tab_ajax_countdown' ){
93						$('.sw-woo-tab-cat-ajax .product-countdown').each(function(event){
94							var $this = $(this);
95							var parent_target = $this.parents().eq(1);
96							var item_target 	= parent_target.find( '.item-price' );
97							var $current_time = new Date().getTime();
98							var $price				= $(this).data( 'price' ); 
99							var $cd_date			= $(this).data( 'date' ); 
100							var $start_time 	= $(this).data('starttime') * 1000;
101							var $countdown_time = $(this).data('cdtime') * 1000;
102							var $austDay 			= new Date( $cd_date * 1000 );	
103							if( $start_time > $current_time  ){
104								$this.remove();
105								return ;
106							}
107							if( $countdown_time > 0 && $current_time > $countdown_time ){
108								$this.remove();
109								return ;
110							}
111							if( $countdown_time <= 0 ){
112								$this.remove();
113								return ;
114							}
115							$this.countdown($austDay, function(event) {
116								$(this).html(
117									event.strftime('<span class="countdown-row countdown-show4"><span class="countdown-section days"><span class="countdown-amount">%D</span></span><span class="countdown-section hours"><span class="countdown-amount">%H</span></span><span class="countdown-section mins"><span class="countdown-amount">%M</span></span><span class="countdown-section secs"><span class="countdown-amount">%S</span></span></span>')
118								);
119							}).on('finish.countdown', function(event){
120								$(this).hide('slow', function(){ $(this).remove(); });	
121								item_target.find( '> span' ).hide('slow', function(){ item_target.find( '> span' ).remove();
122								item_target.append( '<span><span class="amount">' + $price + '</span></span>' ); });	
123							});
124						});
125					}
126
127					tg_append.removeClass( 'loading' );
128				});
129			}
130		}
131		
132		function sw_slider_ajax( target ) {	
133			var element 	= $(target).find( '.responsive-slider' );
134			var $col_lg 	= element.data('lg');
135			var $col_md 	= element.data('md');
136			var $col_sm 	= element.data('sm');
137			var $col_xs 	= element.data('xs');
138			var $col_mobile = element.data('mobile');
139			var $speed 		= element.data('speed');
140			var $interval 	= element.data('interval');
141			var $scroll 	= element.data('scroll');
142			var $autoplay 	= element.data('autoplay');
143			var $rtl 		= $('body').hasClass( 'rtl' );
144			$target = $(target).find( '.responsive' );
145			$target.slick({
146			  appendArrows: $(target),
147			  prevArrow: '<span data-role="none" class="res-button slick-prev" aria-label="previous"></span>',
148			  nextArrow: '<span data-role="none" class="res-button slick-next" aria-label="next"></span>',
149			  dots: false,
150			  infinite: true,
151			  speed: $speed,
152			  slidesToShow: $col_lg,
153			  slidesToScroll: $scroll,
154			  autoplay: $autoplay,
155			  autoplaySpeed: $interval,
156			  rtl: $rtl,			  
157			  responsive: [
158				{
159				  breakpoint: 1199,
160				  settings: {
161					slidesToShow: $col_md,
162					slidesToScroll: $col_md
163				  }
164				},
165				{
166				  breakpoint: 991,
167				  settings: {
168					slidesToShow: $col_sm,
169					slidesToScroll: $col_sm
170				  }
171				},
172				{
173				  breakpoint: 767,
174				  settings: {
175					slidesToShow: $col_xs,
176					slidesToScroll: $col_xs
177				  }
178				},
179				{
180				  breakpoint: 480,
181				  settings: {
182					slidesToShow: $col_mobile,
183					slidesToScroll: $col_mobile					
184				  }
185				}
186			  ]
187			});
188			setTimeout(function(){
189				element.removeClass("loading");
190			}, 500);
191		}
192		/*
193		** Categories Tab Ajax listing
194		*/
195		function sw_tab_ajax_listing( element ) {			
196			var target 		= $( element.attr( 'href' ) );
197			var id 				= element.attr( 'href' );
198			var ltype     = element.data( 'type' );
199			var layout 		= element.data( 'layout' );			
200			var catid 		= element.data( 'category' );
201			var number 		= element.data( 'number' );
202			var action 		= 'sw_ajax_tab_listing';
203			var ajaxurl   = element.data( 'ajaxurl' ).replace( '%%endpoint%%', action );
204			if( target.html() == '' ){
205				target.parent().addClass( 'loading' );
206				var data 		= {
207					action: action,
208					catid: catid,
209					number: number,
210					target: id,
211					layout: layout
212				};
213				jQuery.post(ajaxurl, data, function(response) {
214					target.html( response );
215					target.parent().removeClass( 'loading' );
216				});
217			}
218		}
219		/*
220		** Categories Ajax listing
221		*/
222		$('.sw-ajax-categories').each( function(){
223			var tparent  = $(this);
224			var target 	 = $(this).find( 'a.btn-loadmore' );
225			var number 	 = target.data( 'number' );
226			var maxpage  = target.data( 'maxpage' );
227			var length	 = target.data( 'length' );
228			var action 	 = 'sw_category_ajax_listing';
229			var ajaxurl  = target.data( 'ajaxurl' ).replace( '%%endpoint%%', action );
230			var page		 = 1;		
231			if( page >= maxpage ){
232				target.addClass( 'btn-loaded' );
233			}
234			target.on( 'click',function(){
235				if( page >= maxpage ){
236					return false;
237				}
238				target.addClass( 'btn-loading' );
239				jQuery.ajax({
240					type: "POST",
241					url: ajaxurl,
242					data: ({
243						action 	: action,
244						number  : number,
245						page 		: page,
246						title_length  : length
247					}),
248					 success: function(data) {	
249						target.removeClass('btn-loading');
250						var $newItems = $(data);
251						if( $newItems.length > 0 ){
252							page = page + 1;
253							tparent.find( '.resp-listing-container' ).append( $newItems );
254							if( page >= maxpage ){
255								target.addClass( 'btn-loaded' );
256							}
257						}else{
258							target.addClass( 'btn-loaded' );
259						}
260					}
261				});
262			});
263		});
264	});
265})(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.