PageSourceSearch

https://www.le-raisin.jp/wp-content/themes/ego_welcart_tcd079/js/functions.js?ver=1.16

js le-raisin.jp collected 2026-10-06 15:28:16 UTC 28,023 bytes, 980 lines download raw bytes

1var winWidth;
2
3jQuery(function($){
4
5	var $window = $(window);
6	var $document = $(document);
7	var $html = $('html');
8	var $body = $('body');
9
10	winWidth = document.body.clientWidth || window.innerWidth;
11	$window.on('resize orientationchange', function(){
12		winWidth = document.body.clientWidth || window.innerWidth;
13	});
14
15	if ($('.p-drawer').length) {
16		/**
17		 * ドロワーボタン
18		 */
19		var drawerScrollTop;
20		$('#js-menu-button').click(function() {
21			drawerScrollTop = $window.scrollTop();
22
23			// 背景スクロール対策
24			$body.css({
25				position: 'fixed',
26				top: drawerScrollTop * -1
27			});
28
29			$('#js-header-view-cart').removeClass('is-active');
30			$html.addClass('show-drawer');
31			$document.trigger('drawerUpdate');
32
33			return false;
34		});
35		$('.p-drawer-overlay, .p-drawer a[href*="#"]').click(function() {
36			$html.removeClass('show-drawer');
37
38			// 背景スクロール対策
39			$body.css({
40				position: 'static',
41				top: 'auto'
42			});
43
44			$window.scrollTop(drawerScrollTop);
45		});
46
47		/**
48		 * ドロワー perfect scrollbar
49		 */
50		if (!$body.hasClass('wp-mobile-device')) {
51			var psDrawer;
52			var drawerPerfectScrollbar = function(){
53				if (winWidth < 992) {
54					if (psDrawer) {
55						psDrawer.update();
56					} else {
57						psDrawer = new PerfectScrollbar('.p-drawer__contents', {
58							wheelSpeed: 1,
59							wheelPropagation: false
60						});
61					}
62				} else {
63					if (psDrawer) {
64						psDrawer.destroy();
65						psDrawer = null;
66					}
67				}
68			};
69
70			$window.on('resize', drawerPerfectScrollbar);
71			$document.on('drawerUpdate', drawerPerfectScrollbar);
72		}
73	}
74
75	/**
76	 * グローバルナビゲーション モバイル
77	 */
78	$('.p-global-nav .menu-item-has-children > a > .p-global-nav__toggle').click(function() {
79		if (winWidth < 992) {
80			$(this).toggleClass('is-active');
81			$(this).closest('.menu-item-has-children').toggleClass('is-active').find('> .sub-menu').slideToggle(300, function(){
82				$document.trigger('drawerUpdate');
83			});
84		}
85		return false;
86	});
87
88	/**
89	 * メガメニュ-
90	 */
91	if ($('#js-global-nav > li > a[data-megamenu]').length && !$body.hasClass('wp-mobile-device')) {
92		$('#js-global-nav > li > a[data-megamenu]').each(function(){
93			if ($('#'+$(this).attr('data-megamenu')).length) {
94				$(this).closest('li').addClass('p-has-megamenu');
95			}
96		});
97		$('#js-global-nav .p-has-megamenu > a[data-megamenu]').on('mouseenter', function(){
98			$('#'+$(this).attr('data-megamenu')).addClass('is-active');
99
100		}).on('mouseleave', function(){
101			$('#'+$(this).attr('data-megamenu')).removeClass('is-active');
102		});
103	}
104
105	/**
106	 * ヘッダーログイン
107	 */
108	if ($('.js-header__membermenu-memberbox').length && $('#js-header-memberbox').length) {
109		var $headerMemberbox = $('#js-header-memberbox');
110		$('.js-header__membermenu-memberbox').hover(
111			function() {
112				$headerMemberbox.addClass('is-active');
113			},
114			function() {
115				$headerMemberbox.removeClass('is-active');
116			}
117		);
118		$('#js-header-memberbox :input').click(function(){
119			// focusだとオートコンプリートの関係で誤動作する
120			$headerMemberbox.addClass('is-active');
121		});
122		$('.js-header__membermenu-memberbox').click(function() {
123			$headerMemberbox.toggleClass('is-active');
124			return false;
125		});
126	}
127
128	//search widget
129	$('.widget_search #searchsubmit').wrap('<div class="submit_button"></div>');
130	$('.google_search #searchsubmit').wrap('<div class="submit_button"></div>');
131
132	// ウィジェットごとに個別に処理を実行
133	$('.widget_calendar .calendar_wrap').each(function () {
134		// それぞれのカレンダーに対してtd要素を処理
135		$(this).find('td').each(function () {
136			if ($(this).children().length === 0) {
137				$(this).addClass('no_link');
138				$(this).wrapInner('<span></span>');
139			} else {
140				$(this).addClass('has_link');
141			}
142		});
143	});
144	
145	// テキストウィジェットとHTMLウィジェットにエディターのクラスを追加する
146	$('.widget_text .textwidget').addClass('p-body');
147	
148	// アーカイブとカテゴリーのセレクトボックスにselect_wrapのクラスを追加する
149	$('.widget_archive select').wrap('<div class="select_wrap"></div>');
150	$('.widget_categories form').wrap('<div class="select_wrap"></div>');
151		
152	
153	/**
154	 * ヘッダーカート
155	 */
156	if ($('.js-header-cart').length && $('#js-header-view-cart').length) {
157		$('.js-header-cart').hover(
158			function() {
159				$('#js-header-memberbox.is-active').removeClass('is-active');
160				$('#js-header-view-cart').addClass('is-active');
161			},
162			function() {
163				$('#js-header-view-cart').removeClass('is-active');
164			}
165		);
166	}
167
168	/**
169	 * ヘッダー検索ボタン
170	 */
171	$('#js-header__search').click(function(){
172		var $cl = $('.p-header__upper-search');
173		if (winWidth >= 992 && $cl.hasClass('is-active') && $cl.find('.p-header__upper-search__input').val()) {
174			$cl.find('form').submit();
175		} else {
176			$cl.toggleClass('is-active');
177		}
178	});
179
180	/**
181	 * スムーススクロール
182	 */
183	window.tcdSmoothScroll = function(hash){
184		if (hash) {
185			if ($(hash).length) {
186				var t = $(hash).offset().top - 30;
187				if (winWidth < 992) {
188					if ($('body.l-header__fix--mobile #js-header').hasClass('is-header-fixed')) {
189						t -= $('#js-header').height();
190					}
191				} else {
192					if ($('body.l-header__fix #js-header').hasClass('is-header-fixed')) {
193						t -= $('#js-header').height();
194					}
195				}
196				$('body, html').animate({
197					scrollTop: t
198				}, 800);
199			}
200		}
201	};
202	$('a[href^="#"]:not([href="#"])').on('click.smoothscroll', function(e) {
203		if (this.hash) {
204			e.preventDefault();
205			window.tcdSmoothScroll(this.hash);
206		}
207	});
208
209	/**
210	 * ページトップ
211	 */
212	var pagetop = $('#js-pagetop');
213	pagetop.click(function() {
214		$('body, html').animate({
215			scrollTop: 0
216		}, 1000);
217		return false;
218	});
219	$window.scroll(function() {
220		if ($(this).scrollTop() > 100) {
221			pagetop.fadeIn(1000);
222		} else {
223			pagetop.fadeOut(300);
224		}
225	});
226	$('#js-pagetop a').off('click.smoothscroll');
227
228	/**
229	 * 記事一覧でのカテゴリークリック
230	 */
231	$document.on('mouseenter', 'a [data-href]', function(){
232		var $a = $(this).closest('a');
233		$a.attr('data-href', $a.attr('href'));
234		if ($(this).attr('data-href')) {
235			$a.attr('href', $(this).attr('data-href'));
236		}
237	}).on('mouseleave', 'a [data-href]', function(){
238		var $a = $(this).closest('a');
239		$a.attr('href', $a.attr('data-href')).removeAttr('data-href');
240	}).on('click', 'a [data-href]', function(){
241		var $a = $(this).closest('a');
242		if ($a.attr('data-href')) {
243			$a.attr('href', $a.attr('data-href'));
244		}
245		if ($(this).attr('data-href')) {
246			location.href = $(this).attr('data-href');
247			return false;
248		}
249	});
250
251	/**
252	 * コメント
253	 */
254	if ($('#js-comment__tab').length) {
255		var commentTab = $('#js-comment__tab');
256		commentTab.find('a').off('click.smoothscroll').click(function() {
257			if (!$(this).parent().hasClass('is-active')) {
258				$($('.is-active a', commentTab).attr('href')).hide();
259				$('.is-active', commentTab).removeClass('is-active');
260				$(this).parent().addClass('is-active');
261				$($(this).attr('href')).fadeIn(800);
262			}
263			return false;
264		});
265	}
266
267	/**
268	 * カテゴリー ウィジェット
269	 */
270	$('.p-widget-categories li ul.children').each(function() {
271		$(this).closest('li').addClass('has-children');
272		$(this).hide().before('<span class="toggle-children"></span>');
273	});
274	$('.p-widget-categories .toggle-children').click(function() {
275		$(this).closest('li').toggleClass('is-active').find('> ul.children').slideToggle();
276	});
277	$('.p-widget-categories li.current-cat').each(function() {
278		$(this).parents('.has-children').each(function() {
279			$(this).addClass('is-active').find('> ul.children').show();
280		});
281	});
282
283	/**
284	 * WooCommerce 商品カテゴリー ウィジェット
285	 */
286	$('.p-widget.widget_product_categories .product-categories li ul.children').each(function() {
287		$(this).closest('li').addClass('has-children');
288		$(this).hide().before('<span class="toggle-children"></span>');
289	});
290	$('.p-widget.widget_product_categories .product-categories .toggle-children').click(function() {
291		$(this).closest('li').toggleClass('is-active').find('> ul.children').slideToggle();
292	});
293	$('.p-widget.widget_product_categories .product-categories li.current-cat').each(function() {
294		$(this).parents('.has-children').each(function() {
295			$(this).addClass('is-active').find('> ul.children').show();
296		});
297	});
298
299	/**
300	 * アーカイブウィジェット
301	 */
302	if ($('.p-dropdown').length) {
303		$('.p-dropdown__title').click(function() {
304			$(this).toggleClass('is-active');
305			$('+ .p-dropdown__list:not(:animated)', this).slideToggle();
306		});
307	}
308
309	/**
310	 * WP検索ウィジェット, Welcart 検索ウィジェット
311	 */
312	$('.p-widget .searchform #searchsubmit, .widget_welcart_search #searchsubmit').val($('<div>').html('&#xe915;').text());
313
314	/**
315	 * モーダルCTA表示
316	 */
317	var show_modal_cta = function() {
318		setTimeout(function(){
319			$('#js-modal-cta').addClass('is-active');
320
321			// Video自動再生
322			if ($('#js-modal-cta--video[data-autoplay="1"]').length) {
323				$('#js-modal-cta--video').get(0).play();
324
325			// Youtube自動再生
326			} else if ($('#js-modal-cta--youtube[data-src]').length) {
327				$('#js-modal-cta--youtube').attr('src', $('#js-modal-cta--youtube').attr('data-src'));
328			}
329		}, $('#js-modal-cta').attr('data-delay') * 1000 || 0);
330	}
331
332	/**
333	 * モーダルCTA表示 ロードアイコン前
334	 */
335	if ($('#js-modal-cta[data-delay-type="0"]').length) {
336		show_modal_cta();
337	}
338
339	/**
340	 * モーダルCTA 閉じる
341	 */
342	$('.p-modal-cta__close').click(function(){
343		$('#js-modal-cta').removeClass('is-active');
344		setTimeout(function(){
345			$('#js-modal-cta').remove();
346		}, 500);
347	});
348
349	$(document).on('click', function(event){
350		if($('#js-modal-cta').hasClass("is-active")){
351			if(!$(event.target).closest('.p-modal-cta__inner').length){
352				$('#js-modal-cta').removeClass("is-active");
353				setTimeout(function(){
354					$('#js-modal-cta').remove();
355				}, 500);
356			}
357		}
358	});
359
360	/**
361	 * 商品アーカイブのajax処理
362	 */
363	if ($('#js-product-archive').length) {
364		var $itemArchive = $('#js-product-archive');
365		var $itemArchiveFilter = $('.p-archive03__sort-filter');
366		var itemArchiveAjaxing = false;
367		var pushStated = false;
368
369		// ajax
370		var getAjaxItemArchive = function( url ) {
371			if ($itemArchive.hasClass('is-ajaxing')) return;
372			$('.p-archive03__sort-filter__item.is-active').removeClass('is-active');
373			itemArchiveAjaxing = true;
374			$itemArchive.addClass('is-ajaxing');
375			$itemArchiveFilter.addClass('is-ajaxing');
376
377			var loadUrl;
378
379			if ( url ) {
380				loadUrl = url;
381			} else {
382				loadUrl = $itemArchive.attr('data-base-url');
383				if (!loadUrl) return false;
384
385				var sort = $('.js-product-archive__sort .is-active').attr('data-value') || null;
386				var stock = $('.js-product-archive__stock .is-active').attr('data-value') || null;
387
388				if (sort) {
389					loadUrl += (loadUrl.indexOf('?') > -1) ? '&' : '?';
390					loadUrl += 'orderby=' + sort;
391				}
392				if (stock) {
393					loadUrl += (loadUrl.indexOf('?') > -1) ? '&' : '?';
394					loadUrl += 'stock=' + stock;
395				}
396			}
397
398			$.ajax({
399				url: loadUrl,
400				type: 'GET',
401				data: {},
402				success: function(data, textStatus, XMLHttpRequest) {
403					// 履歴追加
404					if (pushStated) {
405						history.replaceState(null, null, loadUrl);
406					} else {
407						history.pushState(null, null, loadUrl);
408						pushStated = true;
409					}
410
411					var $data = $($.parseHTML(data));
412					$data.find('#js-product-archive > *').animate({opacity: 0}, 1000, 'swing', function(){
413						itemArchiveAjaxing = false;
414						$itemArchive.removeClass('is-ajaxing')
415						$itemArchiveFilter.removeClass('is-ajaxing')
416						$itemArchive.html($data.find('#js-product-archive').html());
417
418						if (window.lazyLoadInstance) {
419							lazyLoadInstance.update();
420						}
421
422						$itemArchive.find('> *').animate({opacity: 1}, 1000, 'swing');
423					});
424				},
425				error: function(XMLHttpRequest, textStatus, errorThrown) {
426					alert(TCD_FUNCTIONS.ajax_error_message);
427					itemArchiveAjaxing = false;
428					$itemArchive.removeClass('is-ajaxing')
429					$itemArchiveFilter.removeClass('is-ajaxing')
430				}
431			});
432		};
433
434		// ソート・フィルターのドロップダウン表示
435		$('.p-archive03__sort-filter__item .p-archive03__sort-filter__item-title').on('click', function() {
436			if (itemArchiveAjaxing) return false;
437
438			var $cl = $(this).closest('.p-archive03__sort-filter__item');
439			if ($cl.hasClass('is-active')) {
440				$cl.removeClass('is-active');
441				$body.off('click.hide-sort-filter-dropdown');
442			} else {
443				$cl.siblings('.is-active').removeClass('is-active');
444				$cl.addClass('is-active');
445				$body.on('click.hide-sort-filter-dropdown', function(){
446					$cl.removeClass('is-active');
447				});
448			}
449
450			return false;
451		});
452
453		// ソート・フィルターのドロップダウン変更
454		$('.p-archive03__sort-filter__item-dropdown li').on('click', function() {
455			if (itemArchiveAjaxing) return false;
456			var $this = $(this);
457			var $dropdown = $this.closest('.p-archive03__sort-filter__item-dropdown');
458
459			// 商品カテゴリーは遷移させる
460			if ($dropdown.is('.js-product-archive__category')) {
461				$('.p-archive03__sort-filter__item.is-active').removeClass('is-active');
462				return;
463			}
464
465			if ($this.hasClass('is-active')) return false;
466			$this.siblings('.is-active').removeClass('is-active');
467			$this.addClass('is-active');
468			$title = $this.closest('.p-archive03__sort-filter__item').find('.p-archive03__sort-filter__item-title').text($this.text());
469			getAjaxItemArchive();
470			return false;
471		});
472
473		 // ページャークリック
474		$itemArchive.on('click', '.p-pager a', function(){
475			getAjaxItemArchive(this.href);
476			$('body, html').animate({
477				scrollTop: $('.l-primary').offset().top - $('.l-header__bar').height() - 40
478			}, 500);
479			return false;
480		});
481	}
482
483	/**
484	 * 商品固定フッターバーのカートボタン
485	 */
486	if ($('#js-product-footer-bar__cart').length) {
487		$('#js-product-footer-bar__cart').on('click', function(){
488			var $cart = $('.p-entry-product__cart');
489
490			// Welcartでカートが1つ
491			if ($cart.length === 1 && $cart.find('.p-wc-button-sku').length) {
492				$cart.find('.p-wc-button-sku').click();
493
494			// WooCommerceでカートクリック可能
495			} else if ($cart.find('.single_add_to_cart_button:not(.disabled, :disabled)').length) {
496				$cart.find('.single_add_to_cart_button').click();
497
498			// その他
499			} else {
500				$('body, html').animate({
501					scrollTop: $cart.first().offset().top - $('.l-header__bar').height() - 40
502				}, 500);
503			}
504			return false;
505		});
506	}
507
508	/**
509	 * WooCommerce store notice
510	 */
511	if ($('.woocommerce-store-notice').length) {
512		var lastWidthStoreNotice = null;
513		var fitStoreNotice = function(force){
514			if (!force && lastWidthStoreNotice === winWidth) return;
515			lastWidthStoreNotice = winWidth;
516
517			$body.css('paddingTop', $('.woocommerce-store-notice:visible').innerHeight() + $('#wpadminbar').height() - 0)
518		};
519		fitStoreNotice();
520		$window.on('resize.fitStoreNotice', fitStoreNotice);
521
522		$('.woocommerce-store-notice__dismiss-link').click(function(){
523			setTimeout(function(){
524				fitStoreNotice(true);
525				$window.off('resize.fitStoreNotice');
526			}, 20);
527		});
528	}
529
530	/**
531	 * WooCommerce 退会フォームの確認メッセージ、重複送信対策
532	 */
533	if ($('form.delete-account').length) {
534		$('form.delete-account').on('submit.processing', function(){
535			var $form = $(this);
536			if ($form.hasClass('is-processing')) return false;
537
538			if ($form.data('confirm')) {
539				if (!window.confirm($form.data('confirm'))) {
540					return false;
541				}
542			}
543
544			$form.addClass('is-processing');
545		});
546	}
547
548	/**
549	 * 初期化処理
550	 */
551	$document.on('js-initialized', function(){
552		/**
553		 * モーダルCTA表示 ロードアイコン後
554		 */
555		if ($('#js-modal-cta[data-delay-type="1"]').length) {
556			show_modal_cta();
557		}
558
559		/**
560		 * スライダーウィジェット
561		 */
562		if ($('.p-widget-slider').length) {
563			$('.p-widget-slider').each(function(){
564				$(this).slick({
565					adaptiveHeight: false,
566					arrows: false,
567					autoplay: true,
568					autoplaySpeed: $(this).attr('data-interval') * 1000 || 7000,
569					dots: true,
570					infinite: true,
571					slidesToShow: 1,
572					slidesToScroll: 1,
573					speed: 1000
574				}).on('setPosition', function(event, slick){
575					if (slick.$dots) {
576						var imageHeight = slick.$slides.find('.p-widget-slider__item-thumbnail__image').innerHeight();
577						if (imageHeight) {
578							slick.$dots.css({bottom: 'auto', top: imageHeight - slick.$dots.outerHeight(true)});
579						}
580					}
581				});
582			});
583		}
584
585		/**
586		 * products carousel
587		 */
588		if ($('.p-archive03-carousel').length) {
589			var hasSidebar = $('.l-secondary').length;
590
591			$('.p-archive03-carousel').each(function(){
592				var $this = $(this);
593				var $tab = $this.siblings('.p-archive03-carousel__tab');
594
595				var slickArgs = {
596					adaptiveHeight: false,
597					arrows: true,
598					prevArrow: '<button type="button" class="slick-prev">&#xe90f;</button>',
599					nextArrow: '<button type="button" class="slick-next">&#xe910;</button>',
600					autoplay: true,
601					autoplaySpeed: $this.attr('data-interval') * 1000 || 7000,
602					dots: false,
603					infinite: true,
604					slidesToShow: hasSidebar ? 3 : 4,
605					slidesToScroll: hasSidebar ? 3 : 4,
606					speed: 1000,
607					responsive: [
608						{
609							breakpoint: 768,
610							settings: {
611								arrows: false,
612								slidesToShow: 2,
613								slidesToScroll: 2
614							}
615						}
616					]
617				}
618
619				if ($this.hasClass('p-recommend-products__carousel')) {
620					slickArgs.arrows = false;
621					slickArgs.dots= true;
622				}
623
624				$this.slick(slickArgs).on('setPosition', function(event, slick){
625					if (slick.$prevArrow || slick.$nextArrow) {
626						var imageHeight = slick.$slides.find('.p-article__thumbnail').innerHeight();
627						if (imageHeight) {
628							if (slick.$prevArrow) {
629								slick.$prevArrow.css('top', imageHeight / 2);
630							}
631							if (slick.$nextArrow) {
632								slick.$nextArrow.css('top', imageHeight / 2);
633							}
634						}
635					}
636				});
637
638				if ($tab.length) {
639					var $tabItems = $tab.find('.p-archive03-carousel__tab-item');
640					if ($tabItems.length) {
641						var $firstActiveItem = $tabItems.filter('.is-active');
642						if ($firstActiveItem.length) {
643							$this.slick('slickFilter', '.tab-' + $firstActiveItem.attr('data-tab-id'));
644						}
645						$tabItems.find('a').off('click.smoothscroll');
646						$tabItems.on('click', 'a', function(){
647							var $tabItem = $(this).closest('.p-archive03-carousel__tab-item');
648							if ($tabItem.hasClass('is-active')) return false;
649							$tabItems.filter('.is-active').removeClass('is-active');
650							$tabItem.addClass('is-active');
651							$this.css('opacity', 0);
652							$this.slick('slickUnfilter').slick('slickFilter', '.tab-' + $tabItem.attr('data-tab-id')).slick('slickGoTo', 1, true);
653							$this.animate({opacity: 1}, 1000, 'swing');
654							setMultilineEllipsis($this.find('.js-multiline-ellipsis'), true);
655							return false;
656						});
657					}
658				}
659			});
660		}
661
662		/**
663		 * 複数行対応3点リーダ
664		 */
665		if ($('.js-multiline-ellipsis').length) {
666			initMultilineEllipsis('.js-multiline-ellipsis');
667		}
668
669		/**
670		 * いいねクリック
671		 */
672		$('.js-product-toggle-like').on('click', function(){
673			var $this = $(this);
674			var post_id = $this.attr('data-post-id');
675			if (!post_id || $this.hasClass('is-ajaxing')) return false;
676
677			$this.addClass('is-ajaxing');
678			$.ajax({
679				url: TCD_FUNCTIONS.ajax_url,
680				type: 'POST',
681				data: {
682					action: 'toggle_like',
683					post_id: post_id
684				},
685				success: function(data, textStatus, XMLHttpRequest) {
686					var updated = false;
687
688					$this.removeClass('is-ajaxing');
689					if (data.result == 'added') {
690						$this.addClass('is-liked');
691						updated = true;
692					} else if (data.result == 'removed') {
693						$this.removeClass('is-liked');
694						updated = true;
695					}
696
697					if (updated) {
698						if (data.like_count) {
699							$('.p-header__membermenu-wishlist__count').text(data.like_count);
700						} else if (data.like_count === 0) {
701							$('.p-header__membermenu-wishlist__count').text('');
702						}
703
704						if (data.message) {
705							if ($this.closest('.p-archive03__item').length) {
706								var $msg = $this.siblings('.p-archive03__item-message').remove();
707								$msg = $('<div class="p-archive03__item-message"></div>').hide();
708								$this.after($msg);
709								$msg.html(data.message).fadeIn(500).delay(5000).fadeOut(800, function(){
710									$msg.remove();
711								});
712							}
713						}
714					} else if (data.message) {
715						alert(data.message);
716					}
717				},
718				error: function(XMLHttpRequest, textStatus, errorThrown) {
719					$this.removeClass('is-ajaxing');
720					alert(TCD_FUNCTIONS.ajax_error_message);
721				}
722			});
723
724			return false;
725		});
726
727		/**
728		 * いいね削除
729		 */
730		$('.js-product-remove-like').on('click', function(){
731			var $this = $(this);
732			var post_id = $this.attr('data-post-id');
733			var $cl = $this.closest('.p-wishlist__item');
734			if (!post_id || !$cl.length || $this.hasClass('is-ajaxing')) return false;
735
736			$this.addClass('is-ajaxing');
737			$.ajax({
738				url: TCD_FUNCTIONS.ajax_url,
739				type: 'POST',
740				data: {
741					action: 'remove_like',
742					post_id: post_id
743				},
744				success: function(data, textStatus, XMLHttpRequest) {
745					$this.removeClass('is-ajaxing');
746					if (data.result == 'removed') {
747						$cl.fadeOut(500, function(){
748							$cl.remove();
749						});
750					} else if (data.message) {
751						alert(data.message);
752					}
753				},
754				error: function(XMLHttpRequest, textStatus, errorThrown) {
755					$this.removeClass('is-ajaxing');
756					alert(TCD_FUNCTIONS.ajax_error_message);
757				}
758			});
759
760			return false;
761		});
762
763		// WCEX Widget Cart対応
764	    if (typeof widgetcart != 'undefined' && !$('#wgct_alert').length) {
765			$('body').append('<div id="wgct_alert"></div>');
766		}
767	});
768
769	$document.on('js-initialized-after', function(){
770		/**
771		 * ページヘッダーフェードイン
772		 */
773		if ($('.p-page-header__image .p-page-header__inner > *').length) {
774			// モーダルCTA表示中は閉じてから
775			if ($('#js-modal-cta').length) {
776				$('.p-modal-cta__close').click(function(){
777					setTimeout(function(){
778						$('.p-page-header__image').addClass('is-active');
779					}, 5000);
780				});
781			} else {
782				$('.p-page-header__image').addClass('is-active');
783			}
784		}
785
786		/**
787		 * LPヘッダーフェードイン
788		 */
789		if ($('.p-lp-header').length) {
790			// モーダルCTA表示中は閉じてからアクティブ化
791			if ($('#js-modal-cta.is-active').length) {
792				$('.p-modal-cta__close').click(function(){
793					setTimeout(function(){
794						$('.p-lp-header').addClass('is-active');
795					}, 500);
796				});
797			} else {
798				$('.p-lp-header').addClass('is-active');
799			}
800		}
801	});
802
803	/**
804	 * WCEX Widget Cart対応(カート追加後のリロード処理)
805	 */
806	$('.p-wc-button-sku').click(function() {
807		if ($('#wgct_alert').length) {
808			$(this).delay(100).queue(function(){
809				location.reload(false);
810			});
811		}
812	});
813
814});
815
816/**
817 * 複数行対応3点リーダ
818 */
819var multilineEllipsisVars = {
820	winHeight: 0,
821	winWidth: 0,
822	timer: null
823};
824var initMultilineEllipsis = function(el){
825	if (!el) {
826		el = '.js-multiline-ellipsis';
827	}
828	jQuery(el).each(function(){
829		jQuery(this).attr('data-default-text', jQuery(this).text());
830	});
831	multilineEllipsisVars.winHeight = 0;
832	multilineEllipsisVars.winWidth = 0;
833	setMultilineEllipsis(el);
834	jQuery(window).off('resize.multilineEllipsis').on('resize.multilineEllipsis', resizeMultilineEllipsis);
835};
836var setMultilineEllipsis = function(el, force){
837	var winHeight = document.body.clientHeight || window.innerHeight;
838	var winWidth = document.body.clientWidth || window.innerWidth;
839
840	if (!force && winHeight == multilineEllipsisVars.winHeight && winWidth == multilineEllipsisVars.winWidth) {
841		return false;
842	}
843	multilineEllipsisVars.winHeight = winHeight;
844	multilineEllipsisVars.winWidth = winWidth;
845
846	if (!el) {
847		el = '.js-multiline-ellipsis';
848	}
849
850	jQuery(el).each(function(){
851		var $target = jQuery(this);
852		if ($target.is(':hidden')) return;
853
854		var text = $target.attr('data-default-text');
855		if (!text) return;
856		$target.text(text);
857		var targetHeight = $target.innerHeight();
858		var targetWidth;
859		if (document.defaultView) {
860			// サブピクセル対応の横幅取得
861			var style = document.defaultView.getComputedStyle(this, '');
862			targetWidth = parseFloat(style.getPropertyValue('width'));
863		}
864		if (!targetWidth) {
865			targetWidth = $target.innerWidth();
866		}
867		var $clone = $target.clone();
868		$clone.css({
869			display : 'none',
870			height: 'auto',
871			maxHeight: 'none',
872			overflow : 'visible',
873			position : 'absolute',
874			width: targetWidth
875		}).text(text);
876
877		$target.after($clone);
878		while(text.length > 0 && $clone.innerHeight() > targetHeight) {
879			text = text.substr(0, text.length - 1);
880			$clone.text(text + '...');
881		}
882		$target.text($clone.text());
883		$clone.remove();
884	});
885};
886var resizeMultilineEllipsis = function(){
887	clearTimeout(multilineEllipsisVars.timer);
888	multilineEllipsisVars.timer = setTimeout(setMultilineEllipsis, 500);
889};
890
891
892/**
893 * カートの商品テーブルの削除ボタンを先頭にする仕様変更
894 */
895document.addEventListener('DOMContentLoaded', function() {
896	var rows = document.querySelectorAll('.p-wc-cart_table tr');
897	rows.forEach(function(row) {
898		var numCell = row.querySelector('.action');
899		if (numCell) {
900		row.insertBefore(numCell, row.firstChild);
901		}
902	});
903});
904/**
905 * メール認証機能のページレイアウト調整
906 */
907
908document.addEventListener('DOMContentLoaded', function() {
909	// マイページで実行
910	const memberPageId = document.getElementById('memberpages');
911	if (memberPageId) {
912		// リンクテキストから "》" を削除
913		const editLink = document.querySelector('.p-wc-member_submenu .member-edit a.p-button');
914		if (editLink) {
915			editLink.textContent = editLink.textContent.replace('》', '');
916		}
917	}
918		
919	// テンプレートが指定されていないWelcatrページで実行
920	// primaryとwc_memberのidがあったら、実行する
921	const primaryId = document.getElementById('primary');
922	const wcMemberId = document.getElementById('wc_member');
923	
924	if (wcMemberId && primaryId ) {
925	// 共通クラスの付与
926	wcMemberId.classList.add('p-wc__body', 'p-body','p-wc');
927	// クラスを追加
928	primaryId.classList.add('l-primary', 'l-main__inner', 'l-inner');
929	
930	// bodyタグにクラスを追記して、JSで追記したレイアウトページであることを示す。
931	const bodyTag = document.querySelector('body');
932	if (bodyTag) {
933	bodyTag.classList.add('tcd-llayout-adjusted');
934	}
935	
936	// h1.member_page_titleにp-wc-headlineクラスを追加
937	const memberPageTitle = document.querySelector('h1.member_page_title');
938	if (memberPageTitle) {
939	memberPageTitle.classList.add('p-wc-headline');
940	}
941	
942	// input[type="submit"]とinput[type="button"]にp-buttonクラスを追加
943	const inputElements = document.querySelectorAll('input[type="submit"], input[type="button"]');
944	inputElements.forEach(function(input) {
945		// 郵便番号のボタン以外にクラスを付与
946		if (input.id !== 'search_zipcode') {
947			input.classList.add('p-button');
948		}
949	});
950	
951	// 大枠にクラスを付与
952	const primaryElement = document.getElementById('primary');
953	if (primaryElement) {
954		// クラスを追加
955		primaryElement.classList.add('l-primary', 'l-mian__inner', 'l-inner');
956	}
957	
958	// 戻るボタンのテキスト調整
959	const backButton = document.querySelector('input[name="back"]');
960	if (backButton) {
961		backButton.value = "< " +backButton.value;
962	}
963	
964	const membereditElement = document.getElementById('memberedit');
965	if (membereditElement ) {
966		// #membereditにクラスの追加
967		primaryElement.classList.add('p-entry__body');
968		
969		// formタグにクラスの付与
970		const forms = document.querySelectorAll('form');
971		forms.forEach(function(form) {
972			// action属性のURLに'usces-member/#edit'が含まれているか確認
973			if (form.action.includes('usces-member/#edit')) {
974			// クラスを追加
975			form.classList.add('p-wc-customer_form');
976			}
977		});
978	}
979	}
980  });

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.