PageSourceSearch

https://ugm.ac.id/wp-content/themes/ugm-theme-2022/assets/js-dev/apps.js

js ugm.ac.id collected 2026-09-24 08:33:49 UTC 9,825 bytes, 422 lines download raw bytes

1// =SOCIAL SHARE CONDITION
2function socialShare() {
3	jQuery(window).scroll(function() {
4		var postContent = jQuery("#content").position().top;
5		var contentHeight = (jQuery(".single-post").height()) / 1.8;
6		jQuery(".share-box-wrapper").height(contentHeight);
7		if ( jQuery(this).scrollTop() > postContent) {
8			jQuery(".share-box-wrapper .share-box").addClass("sticky");
9		} else {
10			jQuery(".share-box-wrapper .share-box").removeClass("sticky");
11		}
12
13		if (jQuery(this).scrollTop() > contentHeight ) {
14			jQuery(".share-box-wrapper .share-box").addClass("holdy");
15		} else {
16			jQuery(".share-box-wrapper .share-box").removeClass("holdy");
17		}
18	});
19}
20
21jQuery(document).ready(function($) {
22	// keyboard on mobile
23	$(document).ready(function(){
24	  var _originalSize = $(window).width() + $(window).height()
25	  $(window).resize(function(){
26	    if($(window).width() + $(window).height() != _originalSize){
27	      $("body").addClass('keyboard-visible');  
28	    }else{
29	      $("body").removeClass('keyboard-visible');  
30	    }
31	  });
32	});
33	
34        
35	var scrollasd = $(window).scrollTop();
36	var header = $('header');
37	if (scrollasd >= 15) {
38		header.addClass('sticky-header-v3');
39	} else {
40		header.removeClass('sticky-header-v3');
41	}
42	
43	// Sticky Header
44	$(window).scroll(function() {
45		var scroll = $(window).scrollTop();
46		var header = $('header');
47
48		if(header.hasClass('header-v3')){
49			if (scroll >= 15) {
50				header.addClass('sticky-header-v3');
51			} else {
52				header.removeClass('sticky-header-v3');
53			}
54		}else{
55			if (scroll >= 15) {
56				header.addClass('sticky-header');
57			} else {
58				header.removeClass('sticky-header');
59			}
60		}
61	});
62
63
64	// Click dropdown menu on mobile
65	$(".navbar .dropdown").on("click", function(){
66		$('.navbar .dropdown').removeClass('active');
67		$(this).addClass("active");
68	});
69
70	// About Page / Tab Menu
71	$('.btn-tabmenu').on('click', function() {
72		$(this).toggleClass('show-menu');
73		$(this).find('.icon span').toggle();
74		
75		if ($(this).hasClass('show-menu')) {
76			$('.widget_menu').slideDown();
77			$(this).find('.icon span').css('transform', 'rotate(-90deg)');
78		} else {
79			$('.widget_menu').slideUp();
80			$(this).find('.icon span').css('transform', 'rotate(0deg)');
81		}
82	});
83
84	// SLick Slider
85	$(".post-slider").slick({
86		dots: true,
87		lazyLoad: '',
88		autoplay: true,
89		autoplaySpeed: 7000,
90		pauseOnHover: true
91	});
92
93	// Gallery Slider Preview
94	$(".slider-preview").slick({
95		slidesToShow: 1,
96		slidesToScroll: 1,
97		arrows: false,
98		fade: true,
99		asNavFor: '.slider-nav',
100		responsive: [
101		{
102			breakpoint: 480,
103			settings: {
104				arrows: true,
105				asNavFor: '',
106				fade: false
107			}
108		}
109		]
110	});
111
112	// Gallery Slider Nav
113	$(".slider-nav").slick({
114		slidesToShow: 3,
115		slidesToScroll: 1,
116		asNavFor: '.slider-preview',
117		dots: false,
118		focusOnSelect: true,
119	});
120
121	// event slider
122	$(".event-slider").slick({
123		slidesToShow: 2,
124		slidesToScroll: 1,
125		autoplay: true,
126		autoplaySpeed: 7000,
127		responsive: [
128		{
129			breakpoint: 768,
130			settings: {
131				slidesToShow: 1
132			}
133		}
134		]
135	});
136
137	// study slider on homepage
138	$('.schome-study__slider').slick({
139		arrows: false,
140		dots: false,
141		centerMode: false,
142		slidesToShow: 4,
143		slidesToScroll: 1,
144		responsive: [
145			{
146				breakpoint: 1024,
147				settings: {
148					slidesToShow: 2
149				}
150			},
151			{
152				breakpoint: 768,
153				settings: {
154					slidesToShow: 2,
155					variableWidth: true,
156				}
157			}
158		]
159	});
160
161	$('.schome-study__slider').slick({
162		arrows: false,
163		dots: false,
164		centerMode: false,
165		slidesToShow: 4,
166		slidesToScroll: 1,
167		responsive: [
168			{
169				breakpoint: 1024,
170				settings: {
171					slidesToShow: 2
172				}
173			},
174			{
175				breakpoint: 768,
176				settings: {
177					slidesToShow: 2,
178					variableWidth: true,
179				}
180			}
181		]
182	});
183
184	// Navbar on mobile
185	function mobileMenu() {
186		var screenWidth = $(window).width();
187		if (screenWidth < 1199) {
188			$('.navbar ul>li.dropdown>a>.caret').on('click', function(e) {				
189				$('.navbar ul>li.dropdown').removeClass('active');
190				$(this).parent().parent().addClass('active');		
191
192				e.preventDefault();		
193			});
194		}
195	}
196	mobileMenu();
197	$(window).resize(mobileMenu);
198
199	// Register Service Worker
200	if ('serviceWorker' in navigator) {
201		window.addEventListener('load', function() {
202			navigator.serviceWorker.register('./sw.js').then(function(registration) {
203				console.log('ServiceWorker registration successful with scope: ', registration.scope);
204			}, function(err) {
205				console.log('ServiceWorker registration failed: ', err);
206			});
207		});
208	}
209	// Popup add homescreen
210	window.addEventListener('beforeinstallprompt', function(e) {
211		e.userChoice.then(function(choiceResult) {
212
213			console.log(choiceResult.outcome);
214
215			if(choiceResult.outcome == 'dismissed') {
216				console.log('User cancelled home screen install');
217			}
218			else {
219				console.log('User added to home screen');
220			}
221		});
222	});
223
224	if ( $('.swiper-newshero').length ) {
225		// ========= SWIPER =============
226		var swiper_args = {
227			slidesPerView: 1,
228			loop: true,
229			speed: 1000,
230			pagination: {
231			el: ".swiper-pagination",
232				clickable: true,
233			},
234			navigation: {
235				nextEl: ".swiper-button-next",
236				prevEl: ".swiper-button-prev",
237			},
238		};
239		if ( ugm_apps && ugm_apps.auto_slide ) {
240			swiper_args.autoplay = {
241				delay: ugm_apps.slide_duration * 3000
242			}
243
244			// console.log('slide :', ugm_apps.slide_duration );
245		}
246		var swiper = new Swiper( ".swiper-newshero", swiper_args );
247	}
248
249	// ============ Categories Section ==========
250	if ($('.categories-wrap').length) {
251
252		$(".categories-wrap").each(function(){
253			if ($(this).find('.categories-list').length) {
254				$(this).find('.title').append('<button class="btn-toggle"></button>');
255
256				if (window.matchMedia('(max-width: 767px)').matches){
257					$(this).find('.btn-toggle').on('click', function(){
258						$(this).closest('.categories-wrap').toggleClass('show');
259
260						// $(this).closest('.categories-wrap').find('.categories-list').slideToggle(function() {
261						// 	$(this).animate({ 
262						// 		// style change
263						// 	}, 300);
264						// 	},
265						// 	function() {
266						// 	$(this).animate({ 
267						// 		// style change back
268						// 	}, 300);
269						// });
270					});
271				}
272
273			}
274		})
275	}
276
277	if ($('.kategori-toggle-sm').length) {
278		$('.kategori-toggle-sm').on('click', function(){
279			console.log('kategori-toggle-sm', $(this).prop('outerHTML'));
280			$(this).find('.icon').toggle();
281			$(this).next('.row-kategori').slideToggle();
282		})
283	}
284
285	function category_list(){
286		if ($(this).find('.categories-list').length) {
287			$(this).find('.title').append('<button class="btn-toggle"></button>');
288			$(this).find('.btn-toggle').on('click', function(){
289				let catWrap = $(this).closest('.categories-wrap');
290
291				if (catWrap.hasClass('hide')) {
292					catWrap.removeClass('hide');
293					catWrap.addClass('show');
294				}else{
295					catWrap.addClass('hide');
296					catWrap.removeClass('show');
297				}
298			});
299		}
300	}
301	if ($('.categories-wrap-revamp').length) {
302		$(".categories-wrap-revamp .categories-wrap").each(category_list);
303		$(".widget_archive-year .categories-wrap").each(category_list);
304	}
305
306	//menu nav
307	const menuDropdown = $('.menunav-dropdown .has-child .expand');
308
309	if (menuDropdown) {
310		menuDropdown.on('click', function(e){
311			$(this).parent().toggleClass('expand');
312
313			if ($(this).parent().hasClass('expand')) {
314				$(this).next('.menu-child').show(function() {
315					$(this).animate({ 
316						// style change
317					}, 300);
318					},
319					function() {
320					$(this).animate({ 
321						// style change back
322					}, 300);
323				});
324			}else{
325				$(this).next('.menu-child').hide(function() {
326					$(this).animate({ 
327						// style change
328					}, 300);
329					},
330					function() {
331					$(this).animate({ 
332						// style change back
333					}, 300);
334				});
335			}
336		})
337	}
338
339	//mega menu
340	const megaMenu = $('#menu-collapse.menu-mega');
341
342	if (megaMenu) {
343		$('#menu-collapse.menu-mega .menu-item a').each(function(){
344			const buttonExpand = $(this).find('button.expand');
345			if (buttonExpand) {
346				buttonExpand.on('click', function(){
347					if (!$(this).parent().parent().hasClass('expand')) {
348						$(this).parent().parent().addClass('expand');
349					}else{
350						$(this).parent().parent().removeClass('expand');
351					}
352				})
353			}
354		});
355
356		$('#menu-collapse.menu-mega .current-menu-item').addClass('expand');
357
358		if (window.matchMedia('(min-width: 991px)').matches)
359		{
360			$('#menu-collapse.menu-mega ul > .has-child').each(function(){
361				$(this).hover(
362					function(){
363						$(this).addClass('expand');
364					},
365					function(){
366						$(this).removeClass('expand');
367					}
368				);
369			});
370		}
371
372
373	}
374
375	//Check end of page
376	$( window ).scroll(function() {
377		if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
378			$('body').addClass('end-of-page');
379		}else{
380			$('body').removeClass('end-of-page');
381		}
382	});
383});
384
385const menuToggle = document.querySelector('#menu-toggle');
386
387if (menuToggle) {
388	menuToggle.addEventListener('click', function(e) {
389		e.preventDefault();
390		document.querySelector('body').classList.toggle('menu-toggle-show');
391	})
392}
393
394const menuToggleClose = document.querySelector('#menu-collapse #close');
395
396if (menuToggleClose) {
397	menuToggleClose.addEventListener('click', function(e) {
398		e.preventDefault();
399		document.querySelector('body').classList.remove('menu-toggle-show');
400	})
401}
402
403
404const searchToggle = document.querySelector('#search-toggle');
405
406if (searchToggle) {
407	searchToggle.addEventListener('click', function(e) {
408		e.preventDefault();
409		document.querySelector('body').classList.toggle('search-toggle-show');
410		document.querySelector('.menu-search input[type=text]').focus();
411	})
412}
413
414
415const searchToggleClose = document.querySelector('#search-collapse #close');
416
417if (searchToggleClose) {
418	searchToggleClose.addEventListener('click', function(e) {
419		e.preventDefault();
420		document.querySelector('body').classList.remove('search-toggle-show');
421	})
422}

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.