PageSourceSearch

https://seminarbase.com/common/js/common.js

js seminarbase.com collected 2026-10-06 07:59:20 UTC 18,735 bytes, 770 lines download raw bytes

1
2
3
4
5
6$(function () {
7
8	CSS_pagerRewrite();
9	CSS_cateDivide();
10	categoryShuffle();
11	ellipsis();
12	listSlick();
13	gallerySlick();
14	galleryBricks();
15	createImagePopup();
16	accordionViewmoreStyle();
17	tab();
18	bookmarkButton();
19	changeInputByRdioButton();// maybe used
20	inputCalendar();// maybe used
21	inputImageFile();
22	contactFixed();// maybe used
23	sideFixed();
24	pageTop();
25	selectDirectLink();
26	detailTab();
27	searchMenuSP();
28	portalBaseSlider();
29});
30
31function detailTab() {
32	if (!$('[data-detail-tab-btn]')[0]) { return; }
33	$('[data-detail-tab-btn]').each(function () {
34		var $a = $(this).closest('a');
35		var href = $a.attr('href').split('?')[0];
36		var url = location.pathname;
37		var is_match = href.indexOf(url) != -1;
38		var is_top = url.match(/\/detail\/\d+?\/*?$/) != null;
39		var is_toppage = href.match(/\/detail\/\d+?\/*?$/) != null;
40
41		if (is_match && !is_top) {
42			$a.addClass('on');
43			//$(this).addClass('on');
44		}
45		if (is_top && is_toppage) {
46			$a.addClass('on');
47			//$(this).addClass('on');
48		}
49	});
50}
51
52function portalBaseSlider() {
53	if (!$('[data-pb-slider]')[0]) { return; }
54	try {
55
56		// ナビ
57		$('[data-pb-slider]').each(function () {
58			var $slider = $(this);
59			var $slick = $('[data-pb-slider-body]', $slider);
60			$('[data-pb-slider-body] img', $slider).each(function () {
61				var $button = $('<button type="button"></button>');
62				$button.append($(this).clone());
63				$('[data-pb-slider-nav]', $slider).append($button);
64			});
65			$('[data-pb-slider-nav] button', $slider).on('click', function () {
66				var i = $('[data-pb-slider-nav] button', $slider).index(this);
67				$slick.slick('slickGoTo', i);
68			});
69		});
70
71		// スライド
72		$('[data-pb-slider-body]').slick({
73			dots: false,
74			arrows: false,
75			fade: true,
76			cssEase: 'linear',
77			slidesToShow: 1,
78			speed: 200,
79			infinite: true,
80			autoplay: true,
81			autoplaySpeed: 400000
82		});
83
84		// 自動拡大
85		$(window).on('scroll', function () {
86			var $pb_slider = $('[data-pb-slider]');
87			if ($(window).scrollTop() > 480 && !$pb_slider.hasClass('active')) {
88				$pb_slider.addClass('active');
89			} else if ($(window).scrollTop() <= 480 && $pb_slider.hasClass('active')) {
90				$pb_slider.removeClass('active');
91			}
92		});
93	} catch (e) { console.log(e.message); }
94}
95
96function searchMenuSP() {
97
98	if (document.getElementById('search_f_menu') == null) { return; }
99
100	var $menu = $('#search_f_menu');
101	var $searchItems = $('[data-search-items]');
102
103	// open
104	$('[data-search-results-change]').on('click', function () {
105		$menu.addClass('active');
106		$searchItems.addClass('active');
107	});
108
109	// close
110	$('[data-search-results-cancel]').on('click', function () {
111		$menu.removeClass('active');
112		$searchItems.removeClass('active');
113	});
114
115	// submit
116	$('[data-search-results-submit]').on('click', function () {
117		$('form', $searchItems).submit();
118	});
119
120	if ($searchItems[0]) {
121		$(window).on('load resize', function () {
122			// No372の対応でコメント化
123			// let vh = window.innerHeight;
124			// let h = vh - $menu.outerHeight();
125			// if (window.matchMedia("(max-width: 959px)").matches) {
126			// 	$searchItems.outerHeight(h);
127			// }
128		});
129	}
130}
131
132/* slide */
133function listSlick() {
134	if (!$('.list_slide')[0]) { return; }
135	try {
136		$('.list_slide').slick({
137			dots: false,
138			arrows: true,
139			slidesToShow: 4,
140			speed: 200,
141			infinite: true,
142			autoplay: true,
143			autoplaySpeed: 2000,
144			responsive: [{
145				breakpoint: 767,
146				settings: {
147					slidesToShow: 1,
148				}
149			}]
150		});
151	} catch (e) { console.log(e.message); }
152}
153
154/* gallery slide */
155function gallerySlick() {
156	var selector = 'detail_main_gallery_slick';
157	if (document.getElementById(selector) == null) { return; }
158	try {
159		$('#' + selector).slick({
160
161			dots: false,
162			arrows: false,
163			slidesToShow: 1,
164			speed: 200,
165			infinite: true,
166			autoplay: true,
167			autoplaySpeed: 2000,
168		});
169
170		$('[data-gallery-thumb="' + selector + '"] li').on('click', function () {
171			var index = $('[data-gallery-thumb="' + selector + '"] li').index(this);
172			$('#' + selector).slick('slickGoTo', index);
173		});
174	} catch (e) { console.log(e.message); }
175}
176
177/* gallery bricks */
178function galleryBricks() {
179	const selector = '[data-pb-gallery-bricks]';
180	if (!$(selector)[0]) { return; }
181	try {
182		$(selector).each(function () {
183			galleryModal($(this));// モーダルの実装
184			var c = $(this).children().length;
185			$(this).children().each(function () {
186				let w = $(this).outerWidth();
187				$(this).outerHeight(getRandomHeight(w, c));
188			});
189		});
190		const sizes = [
191			{ columns: 3, gutter: 8 },
192			{ mq: '768px', columns: 4, gutter: 8 },
193			{ mq: '960px', columns: 4, gutter: 8 }
194		];
195		const instance = Bricks({
196			container: selector,
197			packed: 'data-pb-gallery-bricks-item',
198			sizes: sizes
199		});
200		instance.resize(true).pack();
201		$(window).on('resize', function () {
202			$(selector).removeAttr('style');
203			instance.pack()
204		});
205	} catch (e) { console.log(e.message); }
206
207	function getRandomHeight(w, c) {
208		if (c < 5) {
209			// 写真数が少ない場合は不格好になるのでアスペクト比を統一する
210			return 0.66 * w;
211		}
212
213		// ランダムな高さ(default 2:6-2:1)
214		let min = Math.ceil(2);
215		let max = Math.floor(6);
216
217		let rNum1 = Math.floor(Math.random() * (max - min) + min);
218		let rNum2 = Math.floor(Math.random() * (max - min) + min);
219		let rRatio = Math.floor((rNum1 / rNum2) * 100) / 100;
220		while (rRatio <= 0.5 || rRatio > 2) {
221			rNum1 = Math.floor(Math.random() * (max - min) + min);
222			rNum2 = Math.floor(Math.random() * (max - min) + min);
223			rRatio = Math.floor((rNum1 / rNum2) * 100) / 100;
224		}
225		return rRatio * w;
226	}
227}
228
229/* gallery modal */
230function galleryModal(container_selector) {
231	$(container_selector).each(function () {
232		// magnificPopup modalの実装(別のライブラリへ変更の場合は以下を編集)
233		$(this).magnificPopup({
234			type: 'image',
235			//closeOnContentClick: true,
236			//mainClass: 'mfp-img-mobile',// custum class name
237			//image: {verticalFit: true},// 1 image
238			delegate: 'a',
239			gallery: { enabled: true }
240		});
241	});
242}
243
244// data-pb-image-popup設定要素内imgタグにモーダル実装
245function createImagePopup() {
246	const selector = '[data-pb-image-popup]';
247	if (!$(selector)[0]) { return; }
248	$(selector).each(function () {
249		var $group = $(this);
250		$('img', $group).each(function () {
251			// aタグがimgの親に無い場合作る
252			if ($(this).parent().prop('tagName').toLowerCase() != 'a') {
253				$(this).wrap('<a href="' + $(this).attr('src') + '"></a>');
254			}
255		});
256		// modalの実装
257		galleryModal($group);
258	});
259}
260
261function selectDirectLink() {
262	if (!$('[data-select-direct-link]')[0]) { return; }
263	$('[data-select-direct-link]').on('change', function () {
264		$(this).closest('form').submit();
265	});
266}
267
268function ellipsis() {
269
270	if (!$('[data-ellipsis-pc]')[0]) { return; }
271
272	$(window).on('resize load', function () {
273
274		$('[data-ellipsis-pc]').each(function () {
275
276			var hellip = ($(this).attr('data-ellipsis-hellip') != '' ? $(this).attr('data-ellipsis-hellip') : '&hellip;');
277
278			var pc_num = Number($(this).attr('data-ellipsis-pc'));
279			pc_num = (pc_num ? pc_num : 0);
280
281			var sp_num = Number($(this).attr('data-ellipsis-sp'));
282			sp_num = (sp_num ? sp_num : 0);
283
284			//sp
285			if (window.matchMedia('screen and (max-width:767px)').matches) {
286
287				if (sp_num != 0) {
288					$(this).html($(this).text().substr(0, sp_num) + hellip);
289				}
290				//pc
291			} else {
292				if (pc_num != 0) {
293					$(this).html($(this).text().substr(0, pc_num) + hellip);
294				}
295			}
296		});
297	});
298}
299
300//文字数をカウントする
301function countString() {
302
303	if (!$('[data-count-str-length]')[0]) { return; }
304
305	$('[data-count-str-length]').each(function () {
306
307		//最大文字数
308		$(this).data('defaultLength', Number($('[data-count-str-length] > span').text()));
309
310		//文字数を図りたい箇所をセット
311		var id = '#' + $(this).data('count-str-length');
312
313		//ロード時の初期設定
314		countStringInit($(id), $(this));
315
316		$(id).on('keyup', countStringLength($(id)));
317	});
318}
319
320//ロード時の初期設定
321function countStringInit($elm, note) {
322
323	var defaultLength = note.data('defaultLength');
324	var text = $elm.val();
325
326	var countNumber = defaultLength - text.length;
327
328	var countTextElem = note.children('span');
329	countTextElem.text(countNumber);
330
331	var warring = 100;
332	if (countNumber < warring) {
333
334		countTextElem.css({ 'color': '#f73b1e', 'font-weight': 'bold' });
335
336		if ($elm.hasClass('input_color_warrning')) {
337			$elm.removeClass('input_color_warrning');
338		}
339
340	} else if (countNumber <= 0) {
341
342		$elm.addClass('input_color_warrning');
343		countTextElem.css({ 'color': 'inherit', 'font-weight': 'inherit' });
344
345	} else {
346
347		if ($elm.hasClass('input_color_warrning')) {
348			$elm.removeClass('input_color_warrning');
349		}
350		countTextElem.css({ 'color': 'inherit', 'font-weight': 'inherit' });
351	}
352}
353
354
355//文字数をカウントする
356function countStringLength($elm) {
357
358	var v, old = $elm.val();
359
360	return function () {
361
362		if (old != (v = $elm.val())) {
363
364			old = v;
365
366			var id = $(this).attr('id');
367			var note = $('[data-count-str-length="' + id + '"]');
368			var defaultLength = note.data('defaultLength');
369
370			var text = $(this).val();
371			var countNumber = defaultLength - text.length;
372
373			var countTextElem = note.children('span');
374			countTextElem.text(countNumber);
375
376			var warring = 100;
377			if (countNumber < warring) {
378
379				countTextElem.css({ 'color': '#f73b1e', 'font-weight': 'bold' });
380
381				if ($elm.hasClass('input_color_warrning')) {
382					$elm.removeClass('input_color_warrning');
383				}
384
385			} else if (countNumber <= 0) {
386
387				$elm.addClass('input_color_warrning');
388
389				countTextElem.css({ 'color': 'inherit', 'font-weight': 'inherit' });
390
391			} else {
392
393				if ($elm.hasClass('input_color_warrning')) {
394					$elm.removeClass('input_color_warrning');
395				}
396				countTextElem.css({ 'color': 'inherit', 'font-weight': 'inherit' });
397			}
398		}
399	};
400}
401
402function pageTop() {
403
404	$('#page_top').on('click', function () {
405		setTimeout(function () {
406			$('#page_top').blur();
407		}, 200);
408	});
409}
410
411$(function () {
412	$(".search_item_open").on("click", function () {
413		var show_text = $(this).parent(".search_item").find("[data-accordion-text]");
414		var small_height = 130; //This is initial height.
415		var original_height = show_text.css({ height: "auto" }).height();
416
417		if (show_text.hasClass("open")) {
418			/*CLOSE*/
419			show_text.height(original_height).animate({ height: small_height }, { duration: 100, easing: 'swing', });
420			show_text.removeClass("open");
421			$(this).removeClass("active");
422		} else {
423			/*OPEN*/
424			show_text
425				.height(small_height)
426				.animate({ height: original_height }, { duration: 100, easing: 'swing', }, function () {
427					show_text.height("auto");
428				});
429			show_text.addClass("open");
430			$(this).addClass("active");
431		}
432
433	})
434})
435
436function accordionViewmoreStyle() {
437	if (!$('[data-viewmore]')[0]) { return; }
438	$('[data-viewmore-btn]').on('click', function () {
439		if (window.matchMedia('screen and (max-width:767px)').matches) {
440			if ($(this).hasClass('active')) {
441				$(this).removeClass('active');
442				$(this).next('[data-viewmore-content]').stop().slideUp(400);
443			} else {
444				$(this).addClass('active');
445				$(this).next('[data-viewmore-content]').stop().slideDown(400);
446			}
447		}
448	});
449	$(window).on('load resize', function () {
450		if (!window.matchMedia('screen and (max-width:767px)').matches) {
451			$('[data-viewmore-btn]').removeClass('active');
452			$('[data-viewmore-content]').removeAttr('style');
453		}
454	});
455}
456
457function tab() {
458
459	if (!$('.page_tab')[0]) { return; }
460
461	//init
462	$('.page_tab_content > div').hide();
463	$('.page_tab a').each(function () {
464
465		if ($(this).hasClass('active')) {
466
467			var id = $(this).attr('href');
468			$(id).show();
469		}
470	});
471
472	//event
473	$('.page_tab a').on('click', function () {
474
475		if ($(this).hasClass('disabled')) {
476
477			$('.page_tab_content > div').hide();
478			var id = $(this).attr('href');
479			$(id).show();
480
481			$('.page_tab a').addClass('disabled');
482			$(this).removeClass('disabled');
483			$(this).addClass('active');
484		}
485
486		return false;
487	});
488}
489
490function bookmarkButton() {
491	if (!$('.btn_bookmark[onclick],.btn_bookmark[onClick]')[0]) { return; }
492	$('.btn_bookmark[onclick],.btn_bookmark[onClick]').on('click', function () {
493		var $btn = $(this);
494		$btn.addClass('active');
495		setTimeout(function () {
496			$btn.removeClass('active');
497		}, 250);
498	});
499}
500
501function changeInputByRdioButton() {
502
503	if (!$('[data-change-input]')[0]) { return; }
504
505	//init
506	var $noChecked = $('[data-change-input-target]:not(:checked)');
507	$noChecked.each(function () {
508
509		var target = $(this).attr('data-change-input-target');
510		$('#' + target).hide();
511	});
512
513	//event
514	$('[data-change-input] input[type="radio"]').on('click', function () {
515
516		var target = $(this).attr('data-change-input-target');
517		$('#' + target).show();
518
519		$('[data-change-input-target]').each(function () {
520
521			if ($(this).prop('checked') === false) {
522
523				var target = $(this).attr('data-change-input-target');
524				$('#' + target).hide();
525			}
526		});
527	});
528}
529
530//calendar入力
531function inputCalendar() {
532
533	if (!$('[data-calendar-id]')[0]) { return; }
534
535	$('input[readonly]').on('keydown', function (e) {
536
537		if ((e.which && e.which === 8) || (e.keyCode && e.keyCode === 8)) {
538			return false;
539		}
540	});
541
542	$('[data-calendar-id]').each(function () {
543
544		//init
545		var myID = $(this).attr('data-calendar-id');
546		var $input = $('[data-calendar-input="' + myID + '"]');//dummy text
547		var $input1 = $('[data-calendar-date="' + myID + '"]');//hidden date
548		var $input2 = $('[data-calendar-time="' + myID + '"]');//hidden time
549
550		//テキスト入力を編集不能に設定
551		$input.attr('readonly', true);
552
553		//ラベルを作成
554		inputCalendarCreateLabel($(this));
555
556		//event
557		$('input[type="radio"]', $(this)).on('click', function () {
558
559			var value = $(this).val();
560			var text = value.replace('~', '');
561			text = text.replace('(', '|');
562			text = text.replace(')', '|');
563
564			var date = text.split('|');
565			$input.val($(this).val());//dummy text
566			$input1.val(date[0]);//hidden date
567			$input2.val(date[2]);//hidden time
568
569			$input.trigger('blur');
570
571			var name = $(this).attr("name");
572
573			let modal = $.remodal.lookup[$('[data-remodal-id=' + name + ']').data('remodal')];
574			modal.close();
575
576		});
577	});
578}
579
580//ラベルを作成
581function inputCalendarCreateLabel($calendar) {
582
583	var $clone = $('.input_calendar', $calendar).clone();
584	$('td:not(:first-child),thead th:not(:first-child)', $clone).remove();
585	var $label = $('<div class="input_calendar_label"></div>');
586	$label.append($clone);
587	$('.input_calendar', $calendar).before($label);
588}
589
590function inputImageFile() {
591	if (!$('[data-input-file]')[0]) { return; }
592	$('[data-input-file] input[type="file"]').on('change', function (e) {
593		var reader = new FileReader();
594		var $input = $(this);
595		var $img = $('img', $input.parent());
596		reader.onload = function (reader_event) {
597			$img.attr('src', reader_event.target.result);
598		}
599		reader.readAsDataURL(e.target.files[0]);
600	});
601}
602
603//css
604function CSS_pagerRewrite() {
605
606	if (!$('.page_pager')[0]) { return; }
607
608	$('.page_pager').each(function () {
609
610		var str = $(this).html();
611		if (!str.match(/対象件数/)) { return true; }
612
613		str = str.explode(' ').join('');
614		str = str.replace(/対象件数\((.*?)\)/, '<span class="page_pager_head">対象件数<em>($1)</em></span>');
615		str = str.explode('&lt;').join('<span class="page_pager_shortcut">');
616		str = str.explode('&gt;').join('</span>');
617		str = str.explode('<b>').join('<b><span>');
618		str = str.explode('</b>').join('</span></b>');
619
620		$(this).html(str);
621	});
622}
623
624function CSS_cateDivide() {
625
626	if ($('.topic_cate')[0]) {
627		$('.topic_cate').each(function () {
628			var $cate = $(this);
629			var text = $cate.text();
630			var cates = text.split(/>|&gt;|>/);
631			$cate.empty();
632			$.each(cates, function (i, cate) {
633				$cate.append('<span>' + cate + '</span>');
634			});
635		});
636	}
637
638	if ($('.category_parts')[0]) {
639		$('.category_parts a').each(function () {
640			var $cate = $(this);
641			var text = $cate.text();
642			var cates = text.split(/>|&gt;|>/);
643			$cate.empty();
644			$.each(cates, function (i, cate) {
645				$cate.append('<span>' + cate + '</span>');
646			});
647		});
648	}
649}
650
651function categoryShuffle() {
652
653	if (!$('.list_category')[0]) { return; }
654
655	//get list
656	var arr = [];
657	$('.list_category').each(function (i) {
658
659		arr[i] = [];
660		$('li', $(this)).each(function () {
661
662			arr[i].push($(this).html());
663		});
664		arr[i].sort(function () {
665			return Math.random() - Math.random();
666		});
667	});
668
669	//append list
670	$('.list_category ul').empty();
671	$('.list_category').each(function (i) {
672
673		for (var n = 0; n < arr[i].length; n++) {
674
675			$('ul', $(this)).append('<li>' + arr[i][n] + '</li>');
676		}
677	});
678}
679
680function contactFixed() {
681
682	if (!$('.detail_header_func')[0]) { return; }
683
684	var $nav = $('.detail_header_func:eq(0)').clone();
685	$('a', $nav).wrap('<div />');
686	$nav.addClass('detail_header_func_fixed');
687	$('.goto_pagetop').addClass('goto_pagetop_offset');
688	$('body').append($nav);
689}
690
691function sideFixed() {
692
693	if (!$('.side_clinic')[0]) { return; }
694	var $side = $('.side_clinic:eq(0)');
695	var $sideArea = $('#detail_side');
696
697	var defaultSideTop = $sideArea.offset().top;
698	var endPointTop = 0;
699
700	$(window).on('load scroll resize', function () {
701
702		//get endPointTop
703		endPointTop = $sideArea.offset().top + $sideArea.height() - $side.height();
704
705		if ($(this).scrollTop() > defaultSideTop && $(this).scrollTop() < endPointTop) {
706			console.log('fixed');
707			$side.addClass('side_clinic_fixed');
708			$side.removeClass('side_clinic_end');
709
710		} else if ($(this).scrollTop() > defaultSideTop && $(this).scrollTop() >= endPointTop) {
711			console.log('end');
712			$side.addClass('side_clinic_end');
713		} else {
714			$side.removeClass('side_clinic_fixed');
715			$side.removeClass('side_clinic_end');
716		}
717	});
718}
719
720/** rem単位をpx単位に変換する **/
721function convertRemToPx(rem) {
722	var fontSize = getComputedStyle(document.documentElement).fontSize;
723	return rem * parseFloat(fontSize);
724}
725
726$(window).on("load", function () {
727	$('#header .sub_header > ul > li').hover(
728		function () {
729			var $ul = $(this).find("ul");
730			console.log("ul", $ul)
731			if (!$ul.length) {
732				return;
733			}
734			$ul.toggle();
735		},
736		function () {
737			var $ul = $(this).find("ul");
738			if (!$ul.length) {
739				return;
740			}
741			$ul.toggle(0, function () {
742				$ul.hide();
743			});
744		}
745	);
746	$("#g_menu > ul > li > a").click(function () {
747		var href = $(this).attr("href");
748		if (href) {
749			return;
750		}
751		var $ul = $(this).parent().find("ul");
752		if (!$ul.length) {
753			return;
754		}
755		var hasActiveClass = $(this).hasClass("active");
756		if ($ul.css("display") == "none") {
757			if (hasActiveClass) {
758				return false;
759			}
760			$(this).addClass("active");
761		} else {
762			if (!hasActiveClass) {
763				return false;
764			}
765			$(this).removeClass("active");
766		}
767		$ul.Toggle();
768		return false;
769	});
770})

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.