/** * (c) 2014 SBS */ function onWindowStatChange() { } /** * div ul > li ±¸Á¶·Î µÈ Ä«·çÁ© ±¸Á¶¸¦ È­¸é Å©±â¿¡ ¸Â°Ô ÃʱâÈ­ÇÑ´Ù. * div¸¦ this·Î °£ÁÖÇÏ¿© ó¸®ÇÑ´Ù. */ function buildCarousel(startIndex) { } function initCarouselEvent() { } function resizeImage(img, ratio) { } /* * ÁöÁ¤µÈ À̹ÌÁö ºñÀ²¿¡ µû¶ó À̹ÌÁöÀÇ ±æÀÌ ¶Ç´Â ÆøÀ» À߶ó ¸ÂÃá´Ù * @param selector ºñÀ²À» ¸ÂÃâ À̹ÌÁöÀÇ »óÀ§ ¿ä¼Ò * @param ratio ¼¼·Î/°¡·Î ºñÀ² */ function resizeImages(selector, ratio) { } function resizeEllipsisBlock() { } function onswipe(selector, callback) { } function setArticleFontSize(e, size) { } /* * ÃʱâÈ­ ·çƾ */ $(function() { // (Àӽà ÀÛ¾÷) ±¸ »çÀÌÆ®ÀÇ ÁÖ¼Ò¸¦ ½Å »çÀÌÆ® ÁÖ¼Ò·Î var OldPaths = [ 'http://news.sbs.co.kr/section_news/news_read.jsp?news_id=', 'http://w3.sbs.co.kr/news/newsEndPage.do?news_id=', 'http://program.sbs.co.kr/builder/', 'http://program.sbs.co.kr/radio/', 'http://m.sbs.co.kr/builder/programMainList.do?pgm_id=', 'http://m.sbs.co.kr/programMain/programMainList.do?pgm_id=', 'http://w3.sbs.co.kr/tvjobs/endPage.do?uniqNo=', 'http://w3.sbs.co.kr/tvjobs/endPage.do?uniq_no=', 'http://mnews.sbs.co.kr/news/endPage.do?', 'http://mnews.sbs.co.kr/app/endPage.do?', 'http://w3.sbs.co.kr/tvview/' ]; var NewPaths = [ 'http://mnews.sbs.co.kr/news/endPage.do?newsId=', 'http://mnews.sbs.co.kr/news/endPage.do?newsId=', '/builder/', '/builder/', '/builder/programMainList.do?pgm_id=', '/builder/programMainList.do?pgm_id=', '/tvjobs/tvjobsDetail.do?uniqNo=', '/tvjobs/tvjobsDetail.do?uniqNo=', 'http://mnews.sbs.co.kr/news/endPage.do?', 'http://mnews.sbs.co.kr/news/endPage.do?', '/tvview/' ]; // ajax¸¦ °í·ÁÇÏ¿© 300ms ÈÄ¿¡ URL º¯È¯ setTimeout(function() { $.each(OldPaths, function(idx) { $('a[href^="' + OldPaths[idx] + '"]').each(function() { this.href = NewPaths[idx] + this.href.substring(OldPaths[idx].length); }); }); }, 300); // À¥¿¡¼­ º¼ °æ¿ì¿¡ ´ëºñÇØ À̹ÌÁö µå·¡±ë ±ÝÁö $('img').on('dragstart', function(e) {e.preventDefault(); return false;}); // Ä«·çÁ© ÃʱâÈ­ - 1. Ç׸ñ »çÀÌÀÇ ºóÄ­À» ¸ðµÎ Á¦¾îÇÏ°í ÀζóÀÎ ºí·ÏÀ¸·Î ¸¸µç ÈÄ µå·¡±ë À̺¥Æ®¸¦ ºÙÀδ٠initCarouselEvent(); // Ä«·çÁ© ÃʱâÈ­ - 2. â Å©±â º¯°æ½Ã ÀçÃʱâÈ­Çϵµ·Ï ÇÑ´Ù. onWindowStatChange(); $(window).on(typeof(window['onorientationchange']) == 'undefined' ? 'resize' : 'orientationchange', function() {setTimeout(onWindowStatChange, 400);}); // GNB ¿­°í ´Ý±â function gnb_open(){ $('.gnb').animate({left:'0px'}, 300); $('#allwrap > .dim').height($(window).height() + 'px').fadeIn(); $('.gnb').scrollTop('0'); $('html, body, #wrap').css({ 'overflow-y':'hidden', 'height': '100%' }); return false; } function gnb_close(){ $('.gnb').animate({left:'-89%'}, 300, function() { $('html, body, #wrap').css({ // 'overflow-y':'inherit', // 'height': 'auto' 'overflow-y':'', 'height': '' }); }); toggleMainBtn(true); $('#allwrap > .dim').fadeOut(); return false; } $('.btn_s').click(function() { if (history.replaceState) { history.replaceState({gnb:'close'}, ''); history.pushState({gnb:'open'}, ''); } return gnb_open(); }); //GNB ¸Þ´º È°¼ºÈ­½Ã ¿©¹é Ŭ¸¯À¸·Î GNB´Ý±â $('.dim').on('click', function(){ gnb_close(); }); onswipe('#allwrap', function(swipeLeft) { if (swipeLeft) { // if (history.replaceState) { // history.replaceState({gnb:'open'}, ''); // history.pushState({gnb:'close'}, ''); // } gnb_close(); } }); $('.gnb .close').click(function() { // if (history.replaceState) { // history.replaceState({gnb:'open'}, ''); // history.pushState({gnb:'close'}, ''); // } return gnb_close(); }); //$(".dep").click(function () { // $("#mgnb ul li ul").hide(); // $(this).siblings("ul").show() // }); /*»õ·Î¿î GNB 150420*/ $('.gnb .ngnbs_closed_w').click(function() { return gnb_close(); }); /* 150914 - ¼öÁ¤ Àü ¿øº» $('.ngnbs_ml_cont.ngnbs_depth').click(function(){ $(this).toggleClass('ngnbs_open'); }); */ // 150914 - ¼öÁ¤ Àû¿ë $('.ngnbs_ml_cont.ngnbs_depth').click(function(){ if ( $( this ).hasClass( 'ngnbs_open' ) ) { $('.ngnbs_ml_cont.ngnbs_depth').removeClass('ngnbs_open'); } else { $('.ngnbs_ml_cont.ngnbs_depth').removeClass('ngnbs_open'); $(this).addClass('ngnbs_open'); } }); /*»õ·Î¿îGNB Ãß°¡*/ // ºê¶ó¿ìÀú ÀÌÀü, ´ÙÀ½ ´ÜÃß·Î GNB ¿­°í ´Ý±â $(window).on('popstate', function(e) { if (parseFloat($('.gnb').css('left')) == 0 && e.originalEvent.state && e.originalEvent.state['gnb'] == 'close') gnb_close(); // else if (parseFloat($('.gnb').css('left')) < 0 && e.originalEvent.state && e.originalEvent.state['gnb'] == 'open') // gnb_open(); }); $('.has_lnb').click(function(){ if($('.lnb_w').is(':hidden')){ $('.lnb_w').slideDown(); $('.has_lnb').css('background-image','url(http://image.sbs.co.kr/mobile/sbs/common/bg_has_on.png)'); }else{ $('.lnb_w').slideUp(); $('.has_lnb').css('background-image','url(http://image.sbs.co.kr/mobile/sbs/common/bg_has.png)'); } }); // ÆäÀÌÁö »ó´ÜÀ¸·Î ¿Ã¶ó°¡±â $('#_btnTop').click(function() { if ($(document.body).scrollTop() > 0) $(document.body).animate({scrollTop: '0'}, 'slow'); return false; }); $('.b_snmvf_top').click(function() { if ($(document.body).scrollTop() > 0) $(document.body).animate({scrollTop: '0'}, 'slow'); return false; }); // ÇöÀç ¸Þ´º Ç׸ñ °­Á¶ var loc = location.pathname + location.search; $('.gnb .menu a').each(function() { if (this.href.indexOf(loc, this.href.length - loc.length) != -1) { $(this).parent().addClass('on').parent().show(); if ($(this).parent().parent().parent().hasClass('depth')) $(this).parent().parent().parent().addClass('on'); } }); /*»õ·Î¿î GNB ¸Þ´º°­Á¶*/ $('.gnb .nbnbs_menulist_w a').each(function() { if (this.href.indexOf(loc, this.href.length - loc.length) != -1) { $(this).parent().addClass('current').parent().show(); if ($(this).parent().parent().parent().hasClass('ngnbs_depth')) $(this).parent().parent().parent().addClass('ngnbs_open'); } }); $('.lnb a').each(function() { if (this.href.indexOf(loc, this.href.length - loc.length) != -1) $(this).parent().addClass('on'); }); // µ¿ÀûÀÎ Ç÷ÎÆà ¸Þ´º ó¸® var $floating = $('.floating'); $floating.css('transition', 'all .4s ease-out'); function showFloating() { // clearTimeout(document.floatingTimeout); if (parseFloat($floating.css('bottom')) <= - $floating.outerHeight() + 5) { if ($floating.hasClass('end')) { var rect = $('.view_detail').offset(); var contentHeight = rect.top + $('.view_detail').height(); var viewHeight = $(document).scrollTop() + $(window).height(); // if (contentHeight < $(window).height()) // contentHeight = $(window).height(); // if (viewHeight <= contentHeight) $floating.css({bottom: '0', display: 'block'}); } else { $floating.css({bottom: '0', display: 'block'}); } } } function hideFloating(timeout) { // clearTimeout(document.floatingTimeout); // if (parseFloat($floating.css('bottom')) == 0) { document.floatingTimeout = setTimeout(function() { $floating.css({bottom: '-' + $floating.outerHeight() + 'px'}); $('.floating > .font_size > ul').hide('fast'); }, timeout * 1000); // } } if (0 >= $floating.length) { $('.float_btn > a').click(function() { if ($('.float_btn ul').css('height') == '0px') { $('.float_btn ul').animate({height : '240px', opacity : '1'}, 300, 'linear', function() { $(this).animate({bottom:'68px'}, 50, 'linear'); }); } else { $('.float_btn ul').animate({bottom : '32px'}, 50, 'linear', function() { $(this).animate({height: '0', opacity: '0'}, 300, 'linear'); }); } return false; }); } // µ¿ÀûÀÎ TOP, µÚ·Î°¡±â ¹öÆ° ó¸® var $topTopButton = $('.sn_mvf_w'); $topTopButton.hide(); function showTopButton() { $topTopButton.show(); } function hideTopButton() { $topTopButton.hide(); } // ¿©±â var prevScrollTop = $(document).scrollTop(); $(window).scroll(function() { if( $("#loadHtmlDiv").is(":visible") ) { return false; } // console.log( $(document).scrollTop() - prevScrollTop ); // var movingFlag = Math.abs( $(document).scrollTop() - prevScrollTop ); // if( 3 < movingFlag ){ // À§·Î ¿Ã¸®´Â Áß if ($(document).scrollTop() < prevScrollTop) { showFloating(); hideTopButton(); } else { hideFloating(0); showTopButton(); // document.floatingTimeout = setTimeout(function() { // showFloating(); // }, 1000); } prevScrollTop = $(document).scrollTop(); // } }); // ±Û²Ã Å©±â Á¦¾î (´ÜÃß°¡ ÀÖÀ» °æ¿ì¸¸) $('.floating > .font_size > a').each(function() { var size = setArticleFontSize(); $(this).click(function() { // hideFloating(4); $('.floating > .font_size > ul').toggle('fast'); return false; }); $('.floating > .font_size .plus > a').click(function(e) { if (size < 3) size += 1; setArticleFontSize(e, size); }); $('.floating > .font_size .minus > a').click(function(e) { if (size > 0) size -= 1; setArticleFontSize(e, size); }); }); // ¾Û¿¡¼­ º¼ °æ¿ì°¡ ¾Æ´Ñ °æ¿ì ó¸® if (navigator.userAgent.search(/sbs-news/) > 0) { $('.appOnly').show(); } else { $('.appOnly').click(function() { var msg = 'Á˼ÛÇÕ´Ï´Ù. ÇØ´ç ±â´ÉÀº ¾Èµå·ÎÀÌµå ±â±â ¹× iOS¿ëÀ¸·Î¸¸ Á¦°øµÇ´Â SBS ´º½º ¸ð¹ÙÀÏ ¾Û Àü¿ë ±â´ÉÀÔ´Ï´Ù.'; if (navigator.userAgent.search(/iPhone/) < 0 && navigator.userAgent.search(/Android/) < 0) alert(msg); else if (navigator.userAgent.search(/iPhone/) > 0) { if (confirm(msg + '\n\n¾ÛÀ» ¼³Ä¡Çϵµ·Ï ¾Û½ºÅä¾î·Î À̵¿ÇϽðڽÀ´Ï±î?')) window.open('https://itunes.apple.com/kr/app/sbs-nyuseu/id371932445?mt=8', '_blank', ''); } else { if (confirm(msg + '\n\n¾ÛÀ» ¼³Ä¡Çϵµ·Ï ¾Û½ºÅä¾î·Î À̵¿ÇϽðڽÀ´Ï±î?')) window.open('market://details?id=com.cubeflux.news&hl=ko', '_blank', ''); } return false; }); } }); function includeInlinePopup(id, initAfterInclude) { id = '#' + id; if (!$(id).length) { $.get('/popup/commonInclude.do', function(html) { $(document.body).find(id).remove(); // ÀÌ¹Ì ¸¸µé¾îÁø °æ¿ì ´ëºñ var $inlineInclude = $(html).find(id).css({ position: 'fixed', zIndex: 9999, left: 0, top: 0, right: 0, bottom: 0, backgroundColor: 'white', display: 'none', overflowY: 'auto' }).appendTo($(document.body)); // ½ºÅ©·Ñ¹Ù¸¦ ¾ø¾Ö±â À§ÇØ º»¹® ¿µ¿ªÀ» ¼û±âµµ·Ï Çϴµ¥ °©Àڱ⠾Ⱥ¸ÀÌ¸é ´çȲ½º·¯¿ì¹Ç·Î 300ms ÈÄ¿¡ °¨Ãá´Ù setTimeout(function() { document.oldOverflow = $('html').css('overflow-y'); $('html').css('overflow-y', 'hidden'); // $('.container').eq(0).css('visibility', 'hidden'); $('.floating').hide(); }, 300); $(id + ' .uarr, ' + id + ' .btn_x, ' + id + ' .end_sharepop_btn ').click(function() { $inlineInclude.fadeOut('fast'); $('html').css('overflow-y', document.oldOverflow); // $('.container').eq(0).css('visibility', 'visible'); $('.floating').show(); return false; }); $(id + ' .esp_closebtn').click(function() { $inlineInclude.fadeOut('fast'); $('html').css('overflow-y', "auto"); // $('.container').eq(0).css('visibility', 'visible'); $('.floating').show(); $('#wrap').fadeIn('fast'); return false; }); if (initAfterInclude) initAfterInclude(); }, 'html'); } } function commify(n) { } /* * CommonController#apiAddLike ¸Þ¼­µå ¼³¸í Âü°í */ //°øÀ¯Çϱâ - Ä«Ä«¿ÀÅå(À̹ÌÁö ¼¿·ºÅÍ) function shareImgFinder(parentClass){ var shareImg = null; $parent = $(parentClass); if($parent.length > 0){ $parent.each(function() { shareImg = $(this).children('img'); if(shareImg.length > 0){ return false; } }); } return (shareImg != null ? shareImg[0] : null); } function toggleMainBtn(toggle){ try{ window.android.setPullToRefresh(toggle); }catch (e) { //alert(e.toString()); } }