PageSourceSearch

https://www.mma.org/wp-content/plugins/wp-grid-viv-addon/js/wp-grid-viv-addon.js?ver=1790855167

js mma.org collected 2026-10-01 11:47:30 UTC 8,948 bytes, 267 lines download raw bytes

1var wpgb=false;
2(function($){
3	if(window.self != window.top) {
4		$(document.body).addClass("in-iframe");
5	}
6	var first_load = true;
7	window.addEventListener('wpgb.loaded',function(){(function(){
8		wpgb = WP_Grid_Builder.instance(1);
9		if(!wpgb.init){return}
10		if(typeof wpgb.facets !=='undefined'){
11			wpgb.facets.on( 'fetched', function(t){
12				grid_data = t;
13				all_count=parseInt(grid_data.count);
14				if(first_load){
15					$('.wpgb-viewport div').html(t.posts);
16					$('.wp-grid-builder').css('visibility','visible');
17					$('.wp-grid-builder').removeClass('wpgb-loading-viv');
18					wpgb.grid.init();
19					first_load=false;
20					$('.wpgb-masonry').imagesLoaded().then(function(){
21						wpgb.grid.layout();
22					});
23				}else{
24					if($('#vivgb-filtr-popup-overlay').length){
25						$('.vivgb-acc').removeAttr('style');
26						$('#vivgb-get-popup-filtr,#vivgb-filtr-popup-overlay').remove();
27					}
28				}
29				
30			});
31			wpgb.facets.on( 'loaded', function( facets ) {
32				$('.vivgb-search-choices-input').trigger('input');
33				wpgb.facets.autoRefresh=true;
34			});
35		}
36		var counter = 2;
37		wpgb.grid.on('added', function(t){
38			$('.wpgb-viewport').removeClass('bottom-shadow');
39			$('.wpgb-masonry').imagesLoaded().then(function(){
40				if($('.wpgb-load-more').length){
41					masonry_width = $('.wpgb-viewport').width();
42					card_width = $('.wpgb-card').width();
43					cards_colls = Math.floor(masonry_width/card_width);
44					if(cards_colls > 2){
45						if($('body').hasClass('noscroll')) return;
46						offset_ar=[];
47						cards_count = $('.wpgb-card').length;
48						cards_count--;
49						for(i=0;i<cards_colls;i++){
50							offset_ar[i] = Math.floor($('.wpgb-card').eq(cards_count).offset().top + $('.wpgb-card').eq(cards_count).height());
51							cards_count--;
52						}
53						min_offset = Math.min(...offset_ar);
54						max_offset = Math.max(...offset_ar);
55						if(max_offset - min_offset > 80){
56							old_height = $('.wpgb-viewport').height();
57							fix = max_offset - min_offset - 80;
58							$('.wpgb-viewport').height(old_height - fix); 
59							$('.wpgb-viewport').addClass('bottom-shadow'); 
60						}
61					}
62				}
63				if(counter % 2 === 0)
64					wpgb.grid.layout();
65				counter++;
66				mobile_width = 100000;
67				if (typeof viv_mbf_breakpoint !== 'undefined'){
68					mobile_width = viv_mbf_breakpoint;
69				}
70				filter_popup_tax=$('#vivgb-get-popup-filtr').val();
71				if(filter_popup_tax){
72					if($('.vivgb-acc[data-slug="'+filter_popup_tax+'"]')){
73						href=location.href;
74						href = href.replace('?filtr_popup='+filter_popup_tax,'');
75						history.pushState(null,null,href);
76						wpgb.facets.params.delete('filtr_popup');
77						if($(document).width()>mobile_width){
78							$('.vivgb-acc[data-slug="'+filter_popup_tax+'"]').removeClass('closed').addClass('open').css({'z-index':103,position:'relative',background:'#fff'});
79							$('#vivgb-filtr-popup-overlay').show();
80							
81								
82							$([document.documentElement, document.body]).animate({
83								scrollTop: $('.vivgb-acc[data-slug="'+filter_popup_tax+'"]').offset().top - 50
84							},500);
85						}
86					}
87				}
88			});
89			
90		});
91		
92		$(document).on('click','.vivgb-acc h4',function(){
93			$(this).closest('.vivgb-acc').toggleClass('open closed');
94		});
95		$(document).on('click','.vivgb-acc-subitems-but',function(){
96			$(this).closest('.vivgb-acc-has-childs').toggleClass('open closed');
97		});
98		$(document).on('input','.wpgb-input',function(){
99			if($(this).val())
100				$(this).closest('.wpgb-search-facet,.wpgb-autocomplete-facet').addClass('filled');
101			else
102				$(this).closest('.wpgb-search-facet,.wpgb-autocomplete-facet').removeClass('filled');
103		});
104		$(document).on('click','.wpgb-clear-button',function(){
105			$(this).closest('.wpgb-search-facet,.wpgb-autocomplete-facet').removeClass('filled');
106		});
107		$(document).on('click','.clear-ch-facet,.acplt-clear',function(e){
108			e.preventDefault();
109			slug = $(this).data('slug');
110			wpgb.facets.reset( [slug] );
111			$(this).closest('.wpgb-search-facet,.wpgb-autocomplete-facet').removeClass('filled');
112		});
113		
114		
115		$(document).on('click',function(){
116			if(!$('#vivgb-filtr-popup-overlay').length) return;
117			$('.vivgb-acc').removeAttr('style');
118			$('#vivgb-get-popup-filtr,#vivgb-filtr-popup-overlay').remove();
119		});
120		if(typeof wpgb.facets !=='undefined'){
121			wpgb.facets.on( 'change', function( slug, values ) {
122				if(slug.indexOf('vivgb-search-choices-input')>-1){
123					//wpgb.facets.deleteParams(slug);
124					wpgb.facets.autoRefresh=false;
125				}else{
126					wpgb.facets.autoRefresh=true;
127				}
128				
129			});
130		}
131		$(document).on('click','.vivgb-search-choices button',function(){
132			$(this).prev('.vivgb-search-choices-input').val('');
133			$(this).prop('hidden',true);
134			ul = $(this).closest('.vivgb-search-choices').next('.wpgb-hierarchical-list');
135			ul.find('li').prop('hidden',false);
136			labels = ul.find('.wpgb-checkbox-label');
137			labels.each(function(){
138				text = $(this).text();
139				$(this).text(text);
140			});
141		});
142		$(document).on('input','.vivgb-search-choices-input',function(){
143			wpgb.facets.autoRefresh=false;
144			val = $(this).val();
145			var s_val = val.toLowerCase();
146			ul = $(this).closest('.vivgb-search-choices').next('.wpgb-hierarchical-list');
147			ul.find('li').prop('hidden',false);
148			labels = ul.find('.wpgb-checkbox-label');
149			select_all = ul.closest('.wpgb-checkbox-facet').find('.ch-facet-select-all');
150			var founded = false;
151			if(ul.length){
152				if(val){
153					$(ul).find('.vivgb-acc-has-childs').removeClass('closed').addClass('open');
154					$(this).next('button').prop('hidden',false);
155					labels.each(function(){
156						text = $(this).text();
157						$(this).text(text);
158						if(text.toLowerCase().indexOf(s_val) > -1){					
159							var searchMask = s_val;
160							var regEx = new RegExp('('+searchMask+')', "i");
161							var replaceMask = '<span class="vivgb-hi">$1</span>';
162							var new_val = text.replace(regEx, replaceMask);
163							$(this).html(new_val);
164							$(this).closest('li.vivgb-acc-has-childs').removeAttr('hidden','hidden');
165							founded=true;
166						}else{
167							$(this).closest('li').attr('hidden','hidden');
168						}	
169					});
170					if(founded){
171						select_all.prop('hidden',false);
172					}else{
173						select_all.prop('hidden',true);
174					}
175					
176				}else{
177					$(this).next('button').prop('hidden',true);
178					labels.each(function(){
179						text = $(this).text();
180						$(this).text(text);
181					});
182					select_all.prop('hidden',true);
183				}
184				
185				
186			}
187		});
188		$(document).on('click','.ch-facet-select-all',function(e){
189			e.preventDefault();
190			slug = $(this).data('slug');
191			all_li = $(this).closest('.wpgb-checkbox-facet').find('.wpgb-hierarchical-list li');
192			var i=0;
193			var params=[];
194			all_li.each(function(){
195				if($(this).prop('hidden')==false){
196					params[i]=$(this).find('input').val();
197					i++;
198				}
199					
200			});
201			if(params.length){
202				wpgb.facets.setParams(slug,params);
203				wpgb.facets.autoRefresh=true;
204				wpgb.facets.refresh();
205			}
206			
207		})
208		if(typeof wpgb.facets !=='undefined'){
209			wpgb.facets.on( 'reset', function( facets ) {
210				fake_ar=[];
211				$('.vivgb-search-choices-input').each(function(){
212					fake_ar[fake_ar.length] = $(this).attr('name');
213				});
214				if(fake_ar.length){
215					wpgb.facets.reset(fake_ar);
216				}
217			});
218		}
219		$(document).on('click','.toggle-view-w',function(){
220			toogle_view = wpgb.facets.getParams('list_view');
221			console.log(wpgb.options.cardSizes);
222			if(toogle_view.length){
223				for (var key in wpgb.options.cardSizes) {
224					wpgb.options.cardSizes[key].columns=VIVGB.def_card_sizes[key].columns;
225				}
226				console.log(wpgb.options.cardSizes);
227				wpgb.facets.reset(['list_view']);
228				wpgb.grid.layout();
229			}else{
230				wpgb.facets.setParams('list_view',[1]);
231				for (var key in wpgb.options.cardSizes) {
232					wpgb.options.cardSizes[key].columns=1;
233				}
234				wpgb.facets.refresh();
235				wpgb.grid.layout();
236			}
237			
238		});
239		
240	})();});
241		
242})(jQuery);	
243
244jQuery.fn.imagesLoaded = function () {
245	$=jQuery;
246	// get all the images (excluding those with no src attribute)
247	var $imgs = this.find('img[src!=""]');
248	// if there's no images, just return an already resolved promise
249	if (!$imgs.length) {return $.Deferred().resolve().promise();}
250
251	// for each image, add a deferred object to the array which resolves when the image is loaded (or if loading fails)
252	var dfds = [];  
253	$imgs.each(function(){
254
255		var dfd = $.Deferred();
256		dfds.push(dfd);
257		var img = new Image();
258		img.onload = function(){dfd.resolve();}
259		img.onerror = function(){dfd.resolve();}
260		img.src = this.src;
261
262	});
263
264	// return a master promise object which will resolve when all the deferred objects have resolved
265	// IE - when all the images are loaded
266	return $.when.apply($,dfds);
267}

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.