jQuery(function($){ $('.wt-popup-module').each(function(e){ var pwrap = $(this); $('body').append(pwrap); if($(this).hasClass('cover')){ $('body').append('
'); } var pcookie = pwrap.find('input'); var pcookieName = pwrap.find('input').attr('class')+e; var msg = pwrap.find('.msg'); var dateRange = parseInt(pcookie.attr('data-role')); var isMobile = pwrap.hasClass('mobile'); var msgTxt = ''; switch(dateRange) { case 1 : msgTxt = '오늘하루 열지 않기' break; case 7 : msgTxt = '일주일동안 열지 않기' break; case 30 : msgTxt = '한달동안 열지 않기' break; case 90 : msgTxt = '세달동안 열지 않기' break; default : msgTxt = dateRange+'일 동안 열지 않기' break; } msg.text(msgTxt); var pcookieVal = getPCookie(pcookieName); if(pcookieVal==''){ pwrap.addClass('on'); } var btnClose = pwrap.find('.wtp-close'); btnClose.bind('click',function(){ if(isMobile){ if(pcookie.prop('checked')){ setPCookie(pcookieName,true,dateRange); } }else { if(pcookie.attr('checked')){ setPCookie(pcookieName,true,dateRange); } } pwrap.removeClass('on'); return false; }); /*if(pwrap.hasClass('hanatour')){ pwrap.find('label').bind('click',function(){ setPCookie(pcookieName,true,dateRange); pwrap.removeClass('on'); }); }*/ pwrap.find('label,.label').bind('click',function(){ setPCookie(pcookieName,true,dateRange); pwrap.removeClass('on'); }); }); }); function setPCookie(cname, value, expire) { var todayValue = new Date(); todayValue.setDate(todayValue.getDate() + expire); document.cookie = cname + "=" + encodeURI(value) + "; expires=" + todayValue.toGMTString() + "; path=/;"; }//save cookie function getPCookie(name) { var cookieName = name + "="; var x = 0; while ( x <= document.cookie.length ) { var y = (x+cookieName.length); if ( document.cookie.substring( x, y ) == cookieName) { if ((lastChrCookie=document.cookie.indexOf(";", y)) == -1) lastChrCookie = document.cookie.length; return decodeURI(document.cookie.substring(y, lastChrCookie)); } x = document.cookie.indexOf(" ", x ) + 1; if ( x == 0 ) break; } return ""; }//get cookie