PageSourceSearch

https://mearry.com/js/shop_showcase.js?1781592562

js mearry.com collected 2026-10-04 01:44:25 UTC 14,816 bytes, 453 lines download raw bytes

1var shopShowCase = function(){
2	var code;
3	var $list_wrap;
4	var $org_html;
5	var old_item_cnt = 0;
6	var change_timer = setTimeout(function(){},1);
7	var current_window_width;
8	var option = {
9		'type' : 'slide',
10		'code' : '',
11		'margin' : 15,
12		'width' : 200
13	};
14	var mobile_section;
15	var extend_section;
16	var timesale_interval;
17	var init = function(data){
18
19		option = $.extend(option,data);
20		code = option.code;
21		$list_wrap = $('#container_'+code);
22		
23		if ($list_wrap.length === 0) {
24			return;
25		}
26		
27		var $section_obj = $list_wrap.closest('div[doz_type=section]');
28		mobile_section = $section_obj.attr('doz_mobile_section') == 'Y';
29		extend_section = $section_obj.attr('doz_extend') == 'Y';
30		current_window_width = $(window).width();
31		$org_html = $list_wrap.clone(false);
32		$list_wrap.css('visibility','hidden');
33		$list_wrap.imagesLoaded()
34			.always(function(){
35				clearTimeout(change_timer);
36				change_timer = setTimeout(function(){
37					shopListResize();
38				}, 100);
39			});
40		var windowWidth = $(window).width();
41		$(window).off('resize.'+code).on('resize.'+code,function(){
42
43      if ($(window).width() != windowWidth) windowWidth = $(window).width();
44      else return;
45
46      clearTimeout(change_timer);
47      change_timer = setTimeout(function(){
48        shopListResize();
49      },200);
50
51		});
52
53		$('body').off('gridChange.'+code).on('gridChange.'+code,function(){
54			$(window).trigger('showcase_width.'+code);
55		});
56		setTimesale();
57	};
58
59	var runSlide = function(item_cnt){
60		var window_width = $(window).width();
61		old_item_cnt = item_cnt;
62		if(mobile_section){
63			var mobile_cnt = option.line_cnt;
64		}else{
65			var mobile_cnt = option.mobile_line_cnt;
66			if(option.mobile_line_cnt == 0){
67				var	mobile_cnt = 1;
68			}
69		}
70		var pc_cnt = item_cnt;
71		if(option.show_paging == 'Y'){
72			switch(option.paging_style_type){
73				case 'st00':
74					switch(option.paging_default_style_type){
75						case 'st00':
76							$list_wrap.toggleClass('paging_type_dot paging_type_dot01', true);
77							break;
78						case 'st01':
79							$list_wrap.toggleClass('paging_type_dot paging_type_dot02', true);
80							break;
81					}
82					break;
83				case 'st01':
84					$list_wrap.toggleClass('paging_type_big_dot', true);
85					break;
86				case 'st02':
87					$list_wrap.toggleClass('paging_type_line', true);
88					break;
89				case 'st03':
90					switch(option.paging_active_style_type){
91						case 'st00':
92							$list_wrap.toggleClass('paging_type_count paging_type_count01', true);
93							break;
94						case 'st01':
95							$list_wrap.toggleClass('paging_type_count paging_type_count02', true);
96							break;
97						case 'st02':
98							$list_wrap.toggleClass('paging_type_count paging_type_count03', true);
99							break;
100					}
101					break;
102			}
103		}
104
105		if(option.show_next_prev == 'Y'){
106			$list_wrap.toggleClass('custom_nav nav_type_'+option.nav_style_type);
107			switch(option.nav_style_type){
108				case 'st00':
109					switch(option.nav_type_angle){
110						case 'normal':
111							break;
112						case 'round':
113							$list_wrap.toggleClass('nav_round');
114							break;
115						case 'square':
116							$list_wrap.toggleClass('nav_square');
117							break;
118					}
119					break;
120				case 'st01':
121					switch(option.nav_type_arrow){
122						case 'normal':
123							break;
124						case 'round':
125							$list_wrap.toggleClass('nav_round');
126							break;
127						case 'square':
128							$list_wrap.toggleClass('nav_square');
129							break;
130					}
131					break;
132				case 'st02':
133					switch(option.nav_type_long_arrow){
134						case 'normal':
135							break;
136						case 'round':
137							$list_wrap.toggleClass('nav_round');
138							break;
139						case 'square':
140							$list_wrap.toggleClass('nav_square');
141							break;
142					}
143					break;
144				case 'st03':
145					switch(option.nav_type_caret){
146						case 'normal':
147							break;
148						case 'round':
149							$list_wrap.toggleClass('nav_round');
150							break;
151						case 'square':
152							$list_wrap.toggleClass('nav_square');
153							break;
154					}
155					break;
156				case 'st04':
157					$list_wrap.toggleClass('nav_text');
158					break;
159			}
160		}
161
162
163		var stagePadding = 0;
164		var is_extend_grid = $list_wrap.closest('div[class="inside"]').length === 0;
165
166		if ( option.sub_type == 'b' ) {
167			$list_wrap.closest('._item_container').css('overflow', 'hidden');
168			if ( is_extend_grid ) { // 그리드 확장시
169				stagePadding = 100;
170			} else {
171				stagePadding = 60;
172			}
173		}
174
175		// 모바일 디바이스 뷰일 경우 & 섹션 확장일 때, 모바일 padding 처리
176		if (isMobileDeviceView() && is_extend_grid) {
177			stagePadding = option.sub_type == 'b' ? 40 : 0;
178		}
179
180		$list_wrap.owlCarousel({
181			'navText' : ["", ""],
182			'slideBy':(option.slide_by == 'Y' && (option.sub_type == 'a' || option.sub_type == 'b' )) ? 1 : pc_cnt,
183			'responsive':{
184				0:{
185					'items': mobile_cnt,
186					'stagePadding': option.sub_type == 'b' ? 40 : 0,
187					'slideBy':(option.slide_by == 'Y' && (option.sub_type == 'a' || option.sub_type == 'b' )) ? 1 : mobile_cnt,
188					'lazyLoadEager': mobile_cnt
189				},
190				991:{
191					'items':pc_cnt,
192					'stagePadding': option.sub_type == 'b' ? stagePadding : 0,
193					'slideBy':(option.slide_by == 'Y' && (option.sub_type == 'a' || option.sub_type == 'b' )) ? 1 : pc_cnt,
194					'lazyLoadEager': pc_cnt
195				}
196			},
197			'lazyLoad': true,
198			'nav' : option.show_next_prev =='Y',
199			'autoplay' : option.auto_change=='Y',
200			'dots' : option.show_paging=='Y',
201			'loop' : $list_wrap.find('._shop_item').length > 1 ? option.effect_loop=='Y' : false,
202			'smartSpeed' : option.effect_time*1000,
203			'autoplayTimeout' : option.effect_wait == 0 ? 50 : option.effect_wait*1000
204		});
205	};
206
207	var shopListResize = function(){
208		if(option.type == 'slide' && typeof $list_wrap.data('owlCarousel') != 'undefined'){
209			$list_wrap.data('owlCarousel',false);
210			$list_wrap.empty();
211			$list_wrap.off();
212			$list_wrap.unbind();
213			$.each($org_html.find('._shop_item'),function(e,$_item){
214				$list_wrap.append($_item);
215			});
216			$org_html = $list_wrap.clone(false);
217			setTimesale();
218		}
219		$list_wrap.imagesLoaded()
220			.always(function(){
221				var window_width =$(window).width();
222				if($('body').hasClass('device_type_m'))
223					window_width = 370;
224				if(window_width <= 768)
225					option.margin = 7.5;
226				$list_wrap.css({'margin':'0 -'+option.margin+'px'});
227				option.width = option.width < 1 ? 200 : option.width;
228
229        function getTrueFloatSize(element) {
230          const width = parseFloat(window.getComputedStyle(element).width)
231          const height = parseFloat(window.getComputedStyle(element).height)
232          return {width, height};
233        }
234				var inner_width = getTrueFloatSize($list_wrap[0]).width;
235				var item_cnt = option.line_cnt;
236				if(extend_section && option.extend_cnt != 'Y') // 섹션 확장이면서 갯수 유지가 아니면
237					item_cnt = Math.floor(inner_width/option.width);
238
239
240				var width = Math.floor(inner_width / item_cnt);
241				var item_thumbs_width = $('._shop_item .item-thumbs').width();
242				var item_detail_max_width = width - 35 - item_thumbs_width;
243
244				if(window_width <= 768 && !mobile_section){
245					item_cnt = option.mobile_line_cnt;
246					if (option.mobile_line_cnt == 0){
247						item_cnt = 2;
248					}
249				}
250				if(option.type == 'slide'){
251					runSlide(item_cnt);
252          $list_wrap.find('._shop_item').css({'width':'100%','padding':'0 0'+option.margin+'px'});
253				}else{
254					if(option.sub_type == 'b'){
255            if(window_width > 991){
256              $list_wrap.find('._shop_item').css({'max-width':width,});
257							$list_wrap.find('._shop_item .item-detail').css({'max-width' : item_detail_max_width,});
258						}else{
259							$list_wrap.find('._shop_item').css({'max-width': '100%',});
260							$list_wrap.find('._shop_item .item-detail').css({'max-width' : '100%',});
261						}
262					}
263				}
264
265				$list_wrap.css('visibility','visible');
266				shopListHeight();
267			});
268	};
269
270
271	var shopListHeight = async function(){
272		// 같은 행의 상품 카드를 동일 높이로 정렬하기 위해 min-height 를 사용
273		// height 를 사용하면 컨텐츠가 행 최대 높이보다 큰 경우 잘리는 문제가 있어 min-height 로 변경
274		$list_wrap.find('._shop_item').css('min-height', '');
275		var be = 0;
276		var ar = [];
277
278		await $list_wrap.find('img._org_img').lazyload({
279			/* 상품 상세페이지 lazy load 적용, 기본 /img/no-image.png 는 한번만 불러옴 */
280			threshold : 100,
281			effect : "fadeIn",
282			effect_speed : 50, // fadeIn 시간 단축(기본 400ms→50ms)
283			appear: function () {
284				// lazyload fadeIn effect로 추가된 inline style 제거
285				if ($(this).css('opacity')) {
286					$(this).css('opacity', '');
287				}
288			},
289			load: function () {
290				// IMOPS-13564: lazyload 내부에서 load 콜백은 fadeIn 호출 직후(애니메이션 중)에 실행되므로
291				// promise().done()으로 애니메이션 완료 시점에 인라인 opacity 를 제거한다.
292				// (IMOPS-11088 의 appear 콜백은 fadeIn 시작 전 실행되어 인라인 opacity 잔존을 막지 못했음)
293				$(this).promise().done(function () {
294					$(this).css('opacity', '');
295				});
296			}
297		});
298
299		// list 진열 타입은 CSS grid(align-items:stretch)로 같은 행 카드를 동일 높이로
300		// 자동 정렬하므로 JS min-height 주입이 불필요하다. 오히려 이미지 지연 로딩 이전
301		// 시점에 높이를 측정하면 행 높이를 잘못 계산해 실제 페이지와 디자인모드의 상하
302		// 간격이 달라지므로, list 타입은 정렬을 CSS 에 위임한다. (slide 타입만 JS 유지)
303		// (IMOPS-13992)
304		if (option.type === 'list') {
305			return;
306		}
307
308		await $list_wrap.find('._shop_item').each(function(){
309			if(be == $(this).position().top){
310				ar.push($(this));
311			}else{
312				var height = 0;
313				var interval = 0;
314				$.each(ar, function(e, $o){
315					var o_height = window.getComputedStyle($o.get(0), null).height;
316					o_height = parseFloat(o_height.replace("px", ""));
317					if(o_height > height)
318						height = Math.ceil(o_height);
319				});
320				$.each(ar, function(e, $o){
321					$o.css('min-height', (height + interval) + 'px');
322				});
323				ar = [];
324				ar.push($(this));
325				be = $(this).position().top;
326			}
327		});
328	};
329
330	var setPeriodSetting = function(code){
331		$.ajax({
332			type : 'GET',
333			data : {'code' : code},
334			url : ('/ajax/shop/get_period_setting.cm'),
335			dataType : 'json',
336			cache : true,
337			success : function(res){
338				if(res.msg == 'SUCCESS'){
339					if ( $list_wrap.find('._shop_item').length > 1 ) {
340						var prod_period_discount_info = res.prod_period_discount_info;
341						if(prod_period_discount_info.length > 0){
342							prod_period_discount_info.forEach(function(obj){
343								$list_wrap.find('.item_pay_detail_' + obj.prod_code).html(obj.html);
344								if(option.type == 'slide'){
345									$org_html.find('.item_pay_detail_' + obj.prod_code).html(obj.html);
346								}
347								if(obj.is_timesale == 'true' && obj.is_instant_sale == 'false'){
348									if($list_wrap.find('._shop_item').length > 1){//뱃지, 남은 기간 , 가격
349										//값 세팅
350										$list_wrap.find('._timesale_badge_' + obj.prod_code).show();
351										$list_wrap.find('._doz_timesale_' + obj.prod_code).show();
352										if(option.type == 'slide'){
353											$org_html.find('._timesale_badge_' + obj.prod_code).show();
354											$org_html.find('._doz_timesale_' + obj.prod_code).show();
355										}
356									}
357								}else{
358									$list_wrap.find('._timesale_badge_' + obj.prod_code).hide();
359									$list_wrap.find('._doz_timesale_' + obj.prod_code).hide();
360									if(option.type == 'slide'){
361										$org_html.find('._timesale_badge_' + obj.prod_code).hide();
362										$org_html.find('._doz_timesale_' + obj.prod_code).hide();
363									}
364								}
365								setTimesale();
366							});
367						}
368					}
369				}else{
370					alert(res.msg);
371				}
372			},
373			error : function(res){
374				return false;
375			}
376
377		});
378	};
379
380	var setTimesale = function(){
381		var $doz_timesale_wrap = $list_wrap.find('._doz_timesale_wrap');
382		if($doz_timesale_wrap.length > 0){
383        $doz_timesale_wrap.each(function(){
384				var $that = $(this);
385				var $doz_timesale = $that.find('._doz_timesale');
386				var date_now = Date.now();
387				var remain_ms = ($doz_timesale.attr('data-end-time') * 1000) - date_now;
388				if(remain_ms > 0){
389					var remain_d = Math.floor(remain_ms / 86400000);
390					var remain_h = Math.floor((remain_ms % 86400000) / 3600000);
391					var remain_m = Math.floor((remain_ms % 3600000) / 60000);
392					var remain_s = Math.floor((remain_ms % 60000) / 1000);
393
394					var remain_hh = remain_h < 10 ? '0' + remain_h : '' + remain_h;
395					var remain_mm = remain_m < 10 ? '0' + remain_m : '' + remain_m;
396					var remain_ss = remain_s < 10 ? '0' + remain_s : '' + remain_s;
397					if(remain_d >= 1){
398						$doz_timesale.text(getLocalizeString('설명_종료까지n1일n2시n3분n4초남음', [remain_d, remain_hh, remain_mm, remain_ss], '종료까지 %1일 %2:%3:%4'));
399					}else{
400						$doz_timesale.text(getLocalizeString('설명_종류까지n1시n2분n3초남음', [remain_hh, remain_mm, remain_ss], '종료까지 %1:%2:%3 남음'));
401					}
402					date_now = date_now + 1000;
403          
404          window.addEventListener('resize', function(){
405               clearInterval(timesale_interval);
406          });
407          // 리사이즈일때 인터벌 주기가 중첩되는 문제가 있음. 그래서 리사이즈일 때 기존 interval 설정되어 있던 걸 초기화
408          timesale_interval = setInterval(function(){
409						var remain_ms = ($doz_timesale.attr('data-end-time') * 1000) - date_now;
410						if(remain_ms > 0){
411							var remain_d = Math.floor(remain_ms / 86400000);
412							var remain_h = Math.floor((remain_ms % 86400000) / 3600000);
413							var remain_m = Math.floor((remain_ms % 3600000) / 60000);
414							var remain_s = Math.floor((remain_ms % 60000) / 1000);
415
416							var remain_hh = remain_h < 10 ? '0' + remain_h : '' + remain_h;
417							var remain_mm = remain_m < 10 ? '0' + remain_m : '' + remain_m;
418							var remain_ss = remain_s < 10 ? '0' + remain_s : '' + remain_s;
419							if(remain_d >= 1){
420								$doz_timesale.text(getLocalizeString('설명_종료까지n1일n2시n3분n4초남음', [remain_d, remain_hh, remain_mm, remain_ss], '종료까지 %1일 %2:%3:%4'));
421							}else{
422								$doz_timesale.text(getLocalizeString('설명_종류까지n1시n2분n3초남음', [remain_hh, remain_mm, remain_ss], '종료까지 %1:%2:%3 남음'));
423							}
424							date_now = date_now + 1000;
425						}else{
426							/* 타임세일 종료 */
427							clearInterval(timesale_interval);
428							$that.remove();
429						}
430					}, 1000);
431				}else{
432					$that.remove();
433				}
434			});
435		}
436	};
437
438	var isMobileDeviceView = function() {
439		return $('body').hasClass('device_type_m');
440	}
441
442	return {
443		'init' : function(d){
444			init(d);
445		},
446		'shopListHeight' : function(){
447			shopListHeight();
448		},
449		'setPeriodSetting' : function(code){
450			setPeriodSetting(code);
451		}
452	};
453};

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.