Skip to content

Instantly share code, notes, and snippets.

@JeongInyoung
Last active August 29, 2015 14:27
Show Gist options
  • Save JeongInyoung/9411b368ccb3fe6dfe7a to your computer and use it in GitHub Desktop.
Save JeongInyoung/9411b368ccb3fe6dfe7a to your computer and use it in GitHub Desktop.
(function($){
var popup = $('.notice-popup');
function closeWin(obj) {
if (obj === "1" ) {
notice_setCookie( "popup", "done" , 1);
}
popup.css( "display", "none" );
}
function notice_setCookie( name, value, expiredays ) {
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function checkCookie() {
if(getCookie("popup") === "done") {
popup.css( "display", "none" );
} else {
popup.css( "display", "block" );
}
}
function getCookie( name ) {
var nameOfCookie = name + "=",
ck = document.cookie,
x = 0;
while ( x <= ck.length ) {
var y = (x+nameOfCookie.length);
if ( ck.substring( x, y ) === nameOfCookie ) {
if ( (endOfCookie=ck.indexOf( ";", y )) == -1 )
endOfCookie = ck.length;
return unescape( ck.substring( y, endOfCookie ) );
}
x = ck.indexOf( " ", x ) + 1;
if ( x === 0 )
break;
}
return "";
}
// .notice-popup 닫기 설정
$( ".notice-popup-close" ).on( "click", function() {
popup.hide();
});
checkCookie();
// .notice-popup 하루 동안 닫기 설정
$( ".notice-popup-close-day" ).on( "click", function() {
closeWin(1);
});
})( window.jQuery );
.notice-popup {
position: relative;
min-height: 120px;
padding: 20px;
}
.notice-popup h3 {
font-size: 24px;
color: #0089d0;
letter-spacing: -0.03em;
}
.notice-popup p {
font-size: 14px;
line-height: 1.5;
color: #888;
margin-bottom: 0;
}
.notice-popup-close {
position: absolute;
top: 0;
right: 0;
width: 30px;
height: 30px;
background: #b5b5b5;
border: 0;
}
.notice-popup-close i.fa.fa-close {
font-size: 18px;
color: #f8f8f8;
}
.notice-popup-close-day {
position: absolute;
top: 0; right: 30px;
line-height: 1.5;
padding-left: 10px;
padding-right: 10px;
height: 30px;
font-size: 12px;
background: #c6c6c6;
border: 0; color: #fff;
}
<link rel="stylesheet" href="css/popup-close-style.css">
<div class="notice-popup">
<h3>팝업 제목</h3>
<p>팝업 내용</p>
<button class="notice-popup-close-day"> 오늘하루 보지 않기 </button>
<button class="notice-popup-close"><i class="fa fa-close"></i></button>
</div>
<script src="js/popup-close-javascript.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment