PageSourceSearch

https://www.sharp.co.jp/assets/index/script.js

js sharp.co.jp collected 2026-09-24 08:49:08 UTC 8,198 bytes, 291 lines download raw bytes

1;
2! function ($) {
3
4	/* ========================================
5	 * 内部変数定義
6	 * ========================================*/
7
8	// ブレイクポイント定義
9	const mediaQueryList = window.matchMedia('(max-width: 767px)');
10
11	// おすすめの商品スライダー設定
12	let swiperRecommendCount = 0;
13	let swiperRecommend = null;
14	let swiperRecommendDestroy = true;
15	let swiperRecommendOptions = null;
16
17	// スペシャル情報スライダー設定
18	let swiperSpecialCount = 0;
19	let swiperSpecial = null;
20	let swiperSpecialDestroy = true;
21	let swiperSpecialOptions = null;
22
23	// キャンペーンスライダー設定
24	let swiperCampaignCount = 0;
25	let swiperCampaign = null;
26	let swiperCampaignDestroy = true;
27	let swiperCampaignOptions = null;
28
29	/* ========================================
30	 * セットアップ: ページロード後1回だけ実行
31	 * ========================================*/
32	function setup() {
33
34		// カルーセルギャラリー:おすすめの商品
35		swiperRecommendCount = $('#recommend .swiper-slide').length;
36		swiperRecommendOptions = {
37			slidesPerView: 2.3,
38			spaceBetween: 20,
39			navigation: {
40				nextEl: '#recommend .carousel-gallery .cg-button-next',
41				prevEl: '#recommend .carousel-gallery .cg-button-prev',
42			},
43			scrollbar: {
44				el: '#recommend .carousel-gallery .swiper-scrollbar',
45				draggable: true,
46			},
47			breakpoints: {
48				768: {
49					slidesPerView: 5,
50					spaceBetween: 20,
51				}
52			}
53		};
54
55		// カルーセルギャラリー:スペシャル情報
56		swiperSpecialCount = $('#special .swiper-slide').length;
57		swiperSpecialOptions = {
58			slidesPerView: 1.2,
59			spaceBetween: 20,
60			navigation: {
61				nextEl: '#special .carousel-gallery .cg-button-next',
62				prevEl: '#special .carousel-gallery .cg-button-prev',
63			},
64			scrollbar: {
65				el: '#special .carousel-gallery .swiper-scrollbar',
66				draggable: true,
67			},
68			breakpoints: {
69				768: {
70					slidesPerView: 3,
71					spaceBetween: 30,
72				}
73			}
74		};
75
76		// カルーセルギャラリー:キャンペーン
77		swiperCampaignCount = $('#campaign .swiper-slide').length;
78		swiperCampaignOptions = {
79			slidesPerView: 1.2,
80			spaceBetween: 20,
81			navigation: {
82				nextEl: '#campaign .carousel-gallery .cg-button-next',
83				prevEl: '#campaign .carousel-gallery .cg-button-prev',
84			},
85			scrollbar: {
86				el: '#campaign .carousel-gallery .swiper-scrollbar',
87				draggable: true,
88			},
89			breakpoints: {
90				768: {
91					slidesPerView: 3,
92					spaceBetween: 30,
93				}
94			}
95		};
96	}
97
98	/* ========================================
99	 * 内部関数定義
100	 * ========================================*/
101
102
103	/* ========================================
104	 * 初期化: setup後、または画面リサイズ時に実行
105	 * ========================================*/
106	function init() {
107
108		if (mediaQueryList.matches) {
109			// SP時の処理
110
111			// おすすめの商品スライダー設定
112			if (swiperRecommendCount > 2) {
113				swiperRecommendDestroy = false;
114			} else {
115				swiperRecommendDestroy = true;
116			}
117
118			// スペシャル情報スライダー設定
119			if (swiperSpecialCount > 1) {
120				swiperSpecialDestroy = false;
121			} else {
122				swiperSpecialDestroy = true;
123			}
124
125			// キャンペーン情報スライダー設定
126			if (swiperCampaignCount > 1) {
127				swiperCampaignDestroy = false;
128			} else {
129				swiperCampaignDestroy = true;
130			}
131		} else {
132			// PC時の処理
133
134			// おすすめの商品スライダー設定
135			if (swiperRecommendCount > 5) {
136				swiperRecommendDestroy = false;
137			} else {
138				swiperRecommendDestroy = true;
139			}
140
141			// スペシャル情報スライダー設定
142			if (swiperSpecialCount > 3) {
143				swiperSpecialDestroy = false;
144			} else {
145				swiperSpecialDestroy = true;
146			}
147
148			// キャンペーン情報スライダー設定
149			if (swiperCampaignCount > 3) {
150				swiperCampaignDestroy = false;
151			} else {
152				swiperCampaignDestroy = true;
153			}
154		}
155
156		// 新着おすすめ商品初期化
157		$('#recommend .carousel-gallery').removeClass('destroy');
158		if (swiperRecommendDestroy) {
159			// スライダー破棄時の処理
160			if (swiperRecommend !== null) {
161				swiperRecommend.destroy();
162				swiperRecommend = null;
163			}
164			$('#recommend .carousel-gallery').addClass('destroy');
165		} else {
166			// スライダー生成時の処理
167			if (swiperRecommend == null) {
168				swiperRecommend = new Swiper('#recommend .carousel-gallery .swiper', swiperRecommendOptions);
169			}
170		}
171
172		// スペシャル情報スライダー初期化
173		$('#special .carousel-gallery').removeClass('destroy');
174		if (swiperSpecialDestroy) {
175			// スライダー破棄時の処理
176			if (swiperSpecial !== null) {
177				swiperSpecial.destroy();
178				swiperSpecial = null;
179			}
180			$('#special .carousel-gallery').addClass('destroy');
181		} else {
182			// スライダー生成時の処理
183			if (swiperSpecial == null) {
184				swiperSpecial = new Swiper('#special .carousel-gallery .swiper', swiperSpecialOptions);
185			}
186		}
187
188		// キャンペーン情報スライダー初期化
189		$('#campaign .carousel-gallery').removeClass('destroy');
190		if (swiperCampaignDestroy) {
191			// スライダー破棄時の処理
192			if (swiperCampaign !== null) {
193				swiperCampaign.destroy();
194				swiperCampaign = null;
195			}
196			$('#campaign .carousel-gallery').addClass('destroy');
197		} else {
198			// スライダー生成時の処理
199			if (swiperCampaign == null) {
200				swiperCampaign = new Swiper('#campaign .carousel-gallery .swiper', swiperCampaignOptions);
201			}
202		}
203	}
204
205	/* ========================================
206	 * DOMロード時処理
207	 * ========================================*/
208	$(function () {
209
210		// セットアップ実行
211		setup();
212
213		// 初期化実行
214		mediaQueryList.addEventListener('change', init);
215		init();
216
217		// モーダルウィンドウ初期化
218		const scrollBarWidth = window.innerWidth - document.body.clientWidth;
219
220		MicroModal.init({
221			onShow: function () {
222				// スクロールバー表示によるガタツキ対策
223				$('html').css('padding-right', scrollBarWidth);
224			},
225			onClose: function () {
226				$('html').css('padding-right', '');
227			},
228			disableScroll: true,
229			disableFocus: true,
230			awaitOpenAnimation: true,
231			awaitCloseAnimation: true,
232		});
233
234		// メインスライダー
235		let mainSlider = new Swiper('#mainVisual .swiper', {
236			loop: true,
237			speed: 800,
238			autoplay: {
239				delay: 5000,
240				disableOnInteraction: false,
241			},
242			pagination: {
243				bulletActiveClass: 'mv-bullet-active',
244				bulletClass: 'mv-bullet',
245				bulletElement: 'button',
246				el: '#mainVisual .mv-pagination',
247				clickable: true,
248			},
249		});
250
251		// メインビジュアル・一時停止機能
252		$('.btn-swiper-control').on('click', function () {
253			if ($('#mainVisual .swiper').hasClass('is-play')) {
254				// 自動再生中の場合は停止
255				mainSlider.autoplay.stop();
256				$('#mainVisual .swiper').removeClass('is-play');
257				$(this).attr('aria-label', 'スライドショーを再生する');
258				$('.icon-swiper-pause').removeClass('is-active');
259				$('.icon-swiper-play').addClass('is-active');
260			} else {
261				// 停止中の場合は自動再生開始
262				mainSlider.autoplay.start();
263				$('#mainVisual .swiper').addClass('is-play');
264				$(this).attr('aria-label', 'スライドショーを一時停止する');
265				$('.icon-swiper-play').removeClass('is-active');
266				$('.icon-swiper-pause').addClass('is-active');
267			}
268		});
269
270		// カルーセルギャラリー:製品を選ぶヒント
271		let swiperHint = new Swiper('#pickup .carousel-gallery .swiper', {
272			slidesPerView: 2.3,
273			spaceBetween: 20,
274			navigation: {
275				nextEl: '#pickup .carousel-gallery .cg-button-next',
276				prevEl: '#pickup .carousel-gallery .cg-button-prev',
277			},
278			scrollbar: {
279				el: '#pickup .carousel-gallery .swiper-scrollbar',
280				draggable: true,
281			},
282			breakpoints: {
283				768: {
284					slidesPerView: 3,
285					spaceBetween: 30,
286				}
287			}
288		});
289
290	});
291}(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.