λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°

study/calendar

[calendar] 달λ ₯을 μ΄μš©ν•˜μ—¬ μ‹κΆŒ μ‚¬μš©/등둝/λ°œκΈ‰ν•˜κΈ°(2) : μ‚¬μš©μžν™”λ©΄ κ΅¬ν˜„

λ°˜μ‘ν˜•


πŸ“’

μ €λ²ˆ ν¬μŠ€νŒ…μ—μ„œ 섀계, λ””μžμΈν–ˆλ˜ 것을 ν† λŒ€λ‘œ ν”ŒλŸ¬κ·ΈμΈμ„ 가져와 μ‚¬μš©μžκ°€ μ‚¬μš©ν•  화면을 κ΅¬ν˜„ν•΄λ³΄μ•˜μŠ΅λ‹ˆλ‹€.
μ €λŠ” 아직 λ°±μ—”λ“œκ°œλ°œκΉŒμ§€λŠ” 뢀쑱함이 많기 λ•Œλ¬Έμ— μ„œλ²„μ™€ 연동은 ν•˜μ§€ μ•Šκ³ 
μŠ€ν¬λ¦½νŠΈμ™€ 제이쿼리둜 ν•  수 μžˆλŠ” 만큼 진행해볼 μ˜ˆμ •μž…λ‹ˆλ‹€.

 

이전 ν¬μŠ€νŒ… πŸ‘€

https://yeonzzy.tistory.com/15

 

[calendar] 달λ ₯을 μ΄μš©ν•˜μ—¬ μ‹κΆŒ μ‚¬μš©/등둝/λ°œκΈ‰ν•˜κΈ°(1) : 섀계 및 λ””μžμΈ

βœ…κΈ°νšμ˜λ„ - μ’…μ΄μ‹κΆŒμœΌλ‘œ λ°œκΈ‰λ˜μ–΄μ Έ μ•„λ‚ λ‘œκ·Έν•œ λ°©μ‹μœΌλ‘œ 카운트 - μ™ΈλΆ€μΈμ—κ²Œ 제곡될 수 있음 - κ΄€λ¦¬μžμž…μž₯μ—μ„œ μ–΄λŠ νŒ€μ΄, μ–΄λŠ 사원이 μ–Όλ§ˆλ‚˜ μ‚¬μš©ν–ˆλŠ”μ§€ ν™•μΈν•˜κΈ° 어렀움 βœ…λͺ©μ  - monthly

yeonzzy.tistory.com

 


 

step.1 ν”ŒλŸ¬κ·ΈμΈ λ‹€μš΄λ‘œλ“œ

https://www.jqueryscript.net/time-clock/Responsive-Event-Calendar-Date-Picker-jQuery-Plugin-Monthly.html

 

Responsive Event Calendar & Date Picker jQuery Plugin - Monthly

Monthly is a jQuery plugin that provides responsive and easy-to-customize event calendar and date picker for your web application.

www.jqueryscript.net

λ‹€μš΄λ‘œλ“œ ν•œ 폴더λ₯Ό 가져와 vsCode λ˜λŠ” 자주 μ‚¬μš©ν•˜λŠ” μ—λ””ν„°νˆ΄λ‘œ λΆˆλŸ¬μ˜¨λ‹€.

index.html을 열어보면 μ‚¬μš©ν•˜μ§€ μ•Šμ„ 이미지와 λ²„νŠΌ 등을 μ§€μ›Œμ£Όκ³  달λ ₯만 남겨놓은 μƒνƒœλ‘œ μ‹œμž‘.

 

step.2 μΊ˜λ¦°λ”(달λ ₯) λ‘œλ“œ

달λ ₯을 λ‘œλ“œμ‹œν‚€κΈ° μœ„ν•΄   β˜μƒλ‹¨μ— ν•΄λ‹Ή cssμ—°κ²° 

** μ΄λ•Œ reset.cssλŠ” 기본으둜 λ“€μ–΄κ°€λŠ” 뢀뢄을 μΆ”κ°€μ μœΌλ‘œ λ§Œλ“€μ–΄ μ—°κ²°. 

<head>
<link rel="stylesheet" href="css/monthly.css">
<link rel="stylesheet" href="css/reset.css">
</head>
/* reset.css */
@charset "utf-8";
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;400;500;700;900&display=swap');

*{
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans KR', sans-serif !important;
}

html, body{
    width: 100%;
    height: 100%;
}

ol, ul, li{
    list-style: none;
}

a{
    text-decoration: none;
}

header, nav, article, aside, main, section, footer{
    display: block;
}

img{
    display: block;
}

 βœŒμΊ˜λ¦°λ”(달λ ₯)을 λ‘œλ“œν•˜κ³ μž ν•˜λŠ” 뢀뢄을 body에 기술 

** body μ•ˆμͺ½μ— pageλΆ€ν„° λ„£μ–΄μ€€λ‹€. id="myCalendar" 뢀뢄에 calendarκ°€ 그렀진닀.

<div class="page">
	<div style="display:inline-block;">
		<div class="monthly" id="mycalendar" style="width: 100%; height: 50px;"></div>
	</div>
</div>

 πŸ€ŸμŠ€ν¬λ¦½νŠΈ μ—°κ²° 및 μž‘μ„± 

** bodyκ°€ λλ‚˜κΈ° μ „ scriptλ₯Ό μ—°κ²°ν•΄μ€€λ‹€.

** μ—¬κΈ°μ„œ μ£Όμ„μ²˜λ¦¬μ˜ μ΄μœ λŠ” μžλ°”μŠ€ν¬λ¦½νŠΈλŠ” 둜컬 xml을 뢈러올 λ•Œ λ³΄μ•ˆμƒ CORS ERRORκ°€ λ°œμƒν•˜κΈ° λ•Œλ¬Έ.

** μ„œλ²„μ™€ μ—°κ²°ν•˜μ—¬ μ‚¬μš©ν•˜λŠ” 경우 mode / jsonUrl / dataType 이 ν•„μš”ν•˜λ‹€.

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/monthly.js"></script> 
<script type="text/javascript">
	$(window).load( function() {
		$('#mycalendar').monthly({
			//mode: 'event',
			//jsonUrl: 'https://cors-anywhere.herokuapp.com/events.json',
			//dataType: 'json',
			//xmlUrl: 'events.xml'
			// weekStart: 'Sun',
			// setWidth: '80%'
		});
	});
</script>
step3. 화면에 ν•„μš”ν•œ 뢀뢄을 μΆ”κ°€μ μœΌλ‘œ λ„£μ–΄μ€€λ‹€.

** 였λ₯Έμͺ½μ— ν•„ν„°(λ²”μ£Ό)와 [μ‹κΆŒμ‚¬μš©] λ²„νŠΌμ΄ λ“€μ–΄κ°€μ•Όν•˜λ―€λ‘œ 좔가적인 μž‘μ—…μ΄ 이뀄짐

<div id="right">
	<div class="right-container">
		<div class="r-new-schedule">
			<button id="new-schedule-btn">μ‹κΆŒμ‚¬μš©</button>
		</div>
		<div class="r-calendars">
			<div class="r-calendars-item">
				<label>
					<input type="checkbox" id="item-check-square" value="all" checked>
					<span class="viewAll">View all</span>
				</label>
			</div>
			<!-- νšŒμ‚¬ 근무지가 μ—¬λŸ¬κ°œ 일 경우 -->
			<div class="calendarList u-calendarList">
				<label>
					<input type="checkbox" value="1" name="listChk" class="filter-location" checked>
					<span class="list-round list-round-doksan"></span>
					<span class="list-title">독산 본사</span>
				</label>
				<label>
					<input type="checkbox" value="2" name="listChk" class="filter-location" checked>
					<span class="list-round list-round-uiwang"></span>
					<span class="list-title">μ˜μ™•</span>
				</label>
			</div>
		</div>
	</div>
</div>

** 기쑴에 있던 monthly.css 에 좔가적인 μŠ€νƒ€μΌμ„ μž…ν˜€μ€Œ.

** κΈ°μ‘΄ ν”ŒλŸ¬κ·ΈμΈμ˜ μΊ˜λ¦°λ”(달λ ₯) μŠ€νƒ€μΌμ„ μˆ˜μ •ν•˜κ³  싢을 경우 monthly.cssλ₯Ό ν™œμš©ν•œλ‹€.

/* monthly.css */
@charset "utf-8";

/* right */
#right{
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 200px;
	height: 100%;
	background-color: #fafafa;
	z-index: 9;
	font-size: 14px;
}

#right .right-container{
	width: 100%;
	height: 100%;
	padding: 12px 10px;
	box-sizing: border-box;
	margin: 0 auto;
}

.r-new-schedule{
	padding-bottom: 12px;
	border-bottom: 1px solid #e5e5e5;
}

/* μ‹κΆŒμ‚¬μš© λ²„νŠΌ */
button#new-schedule-btn{
	width: 180px;
	height: 40px;
	border-radius: 25px;
	background-color: #00a9ff;
	border: 0;
	padding: 10px 20px;
	color: #fff;
	cursor: pointer;
}

button#new-schedule-btn:focus{
	outline: none;
}

button#new-schedule-btn:hover{
	background-color: #008ee7;
    transition: all 1.0s;
}

.r-calendars-item{
	padding: 20px;
	border-bottom: 1px solid #e5e5e5;
	font-size: 0.8rem;
}

.r-calendars-item > label{
	display: inline-block;
	font-weight: normal;
}

.r-calendars-item > label > span.viewAll{
	display: inline-block;
	padding-left: 25px;
}

input[type="checkBox"]#item-check-square{
	display: none;
}

input[type="checkBox"]#item-check-square + span.viewAll{
	display: inline-block;
	cursor: pointer;
	line-height: 14px;
	background: url(../images/checkBox-false.png) no-repeat;
}

input[type="checkBox"]#item-check-square:checked ~ span.viewAll{
	background: url(../images/checkBox-true.png) no-repeat;
}

.calendarList{
	width: 100%;
	height: auto;
	padding: 10px 20px;
	box-sizing: border-box;
	border-bottom: 1px solid #e5e5e5;
}

.calendarList>ul>li{
	/* border: 1px solid; */
	height: 30px;	
	line-height: 30px;
	font-size: 0.8rem;
	color: #333;
}

/* μ‚¬μš©μž 일 λ•Œ "μ‚¬μš©μ΄λ ₯" λ²”μ£Ό 색상 */
.u-calendarList>ul>li:nth-child(1) span.list-round{
	background-color: #BAD532;
}
.u-calendarList>ul>li:nth-child(2) span.list-round{
	background-color: #ff8f4e;
}

span.list-title{
	vertical-align: 2px;
}

/* filter : location */
.calendarList > label{
	display: inline-block;
	font-weight: normal;
	width: 100%;
}

.calendarList > label:nth-child(1){
	margin-bottom: 10px;
}

input[type="checkBox"].filter-location{
	display: none;
}

input[type="checkBox"].filter-location + span.list-round{
	display: inline-block;
	cursor: pointer;
	width: 10px;
	height: 10px;
	line-height: 12px;
	/* vertical-align: middle; */
	margin-right: 8px;
	border-radius: 8px;
	border:2px solid;
	background: transparent;
}

span.list-round-doksan{
	color: #BAD532;
}

span.list-round-uiwang{
	color: #ff8f4e;
}

input[type="checkBox"].filter-location:checked ~ span.list-round-doksan{
	background-color: #BAD532;
}

input[type="checkBox"].filter-location:checked ~ span.list-round-uiwang{
	background-color: #ff8f4e;
}

.calendarList > label > span.list-title{
	font-size: 0.8rem;
}

적용 λͺ¨μŠ΅

 

λ°˜μ‘ν˜•