From da8dfedc24f2792944944d836b3ca3963e971220 Mon Sep 17 00:00:00 2001 From: "sangkil.an" Date: Fri, 17 Feb 2017 14:50:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=ED=9C=B4=EC=9D=BC=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- index.html | 4 ++-- src/calendar.js | 13 +++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 41a9aba..1bd9ca1 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,12 @@ $('#ca').calendar({ // Fixed date range: [new Date(2016, 0, 1), new Date(2016, 11, 31)] or ['2016/1/1', '2016/12/1'] // Starting today: [new Date(), null] or [new Date()] selectedRang: null, - + + // 휴일 관리 Array + // value : [ days ....] + // 예시 ['2017/02/17','2017/02/18'] + holidays: null, + // display data when mouse enter // value: `[{ date: String || Date, value: object }, ... ]` // example: [ { date: '2016/1/1', value: 'A new Year'} ] or [ { date: new Date(), value: 'What to do'} ] diff --git a/index.html b/index.html index fef8ad5..a93d17a 100644 --- a/index.html +++ b/index.html @@ -91,8 +91,9 @@

Trigger calendar

// startWeek: 0, // selectedRang: [new Date(), null], data: data, + holidays : ['2017/02/18','2017/02/19'], monthArray: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], - date: new Date(2016, 9, 31), + //date: new Date(2016, 9, 31), onSelected: function (view, date, data) { console.log('view:' + view) console.log('date:' + date) @@ -100,7 +101,6 @@

Trigger calendar

}, viewChange: function (view, y, m) { console.log(view, y, m) - } }); diff --git a/src/calendar.js b/src/calendar.js index d02046b..9ed802e 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -59,6 +59,8 @@ // 如设置2015年11月23日以前不可选:[new Date(), null] or ['2015/11/23'] selectedRang: null, + holidays:null, + // 日期关联数据 [{ date: string, value: object }, ... ] // 日期格式与 format 一致 // 如 [ {date: '2015/11/23', value: '面试'} ] @@ -279,6 +281,7 @@ this.height = this.options.height; this.date = this.options.date; this.selectedRang = this.options.selectedRang; + this.holidays = this.options.holidays; this.data = this.options.data; this.init(); } @@ -296,6 +299,16 @@ } } + if(this.holidays) { + + this.holidays.forEach(function (v,i) { + if(day.getTime() == Date.tryParse(v).getTime()) { + console.log(v); + action = DISABLED; + } + }); + } + return action; }, getDayData: function (day) { From 173617fcb5794f675fdef94aec5356ca42395bd0 Mon Sep 17 00:00:00 2001 From: "sangkil.an" Date: Fri, 17 Feb 2017 14:55:45 +0900 Subject: [PATCH 2/4] configration file addtion --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d01b4b4..482a31f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.idea/ + # Logs logs *.log From 25e22ed694ff9ed4a10268ae1f54573b31c82d06 Mon Sep 17 00:00:00 2001 From: "sangkil.an" Date: Fri, 17 Feb 2017 16:15:47 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Date=20format=20=EC=97=90=EB=94=B0=EB=A5=B8?= =?UTF-8?q?=20=EB=B7=B0=EC=9E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calendar.js b/src/calendar.js index 9ed802e..1a75c4c 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -648,7 +648,7 @@ toggleClass.call(this); } - return new Date(y, m - 1, d); + return new Date(y, m - 1, d).format(this.options.format); }, showLabel: function (event, view, date, data) { var $lbl = this.$label; From 21846b4f5a422652e9509fd27fc147663bb89b88 Mon Sep 17 00:00:00 2001 From: "sangkil.an" Date: Fri, 17 Feb 2017 16:39:36 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=EC=88=AB=EC=9E=90=EC=97=90=20lpad=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=20length=EA=B0=80=201=EB=B3=B4=EB=8B=A4?= =?UTF-8?q?=20=EC=9E=91=EC=9C=BC=EB=A9=B4=200=EC=9D=84=20=EC=B1=84?= =?UTF-8?q?=EC=9B=8C=20=EB=84=A3=EC=96=B4=EC=A3=BC=EC=96=B4=20MM.dd?= =?UTF-8?q?=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/calendar.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/calendar.js b/src/calendar.js index 1a75c4c..92ce285 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -175,13 +175,20 @@ } // extension methods - String.prototype.repeat = function (data) { return this.replace(/\{\w+\}/g, function (str) { var prop = str.replace(/\{|\}/g, ''); return data[prop] || ''; }); } + + String.prototype.lpad = function (padLength, padString) { + var str = this; + while(str.length < padLength) { + str = padString + str; + } + return str; + } String.prototype.toDate = function () { var dt = new Date(), @@ -193,10 +200,12 @@ Date.prototype.format = function (exp) { var y = this.getFullYear(), - m = this.getMonth() + 1, + m = ''+(this.getMonth() + 1), d = this.getDate(); - - return exp.replace('yyyy', y).replace('mm', m).replace('dd', d); + + m= m.lpad(2,0); + + return exp.replace('yyyy', y).replace('MM', m).replace('dd', d); } Date.prototype.isSame = function (y, m, d) { @@ -723,6 +732,7 @@ var day = _this.selectedDay(d, type); _this.options.onSelected.call(this, 'date', day, $(this).data(MARK_DATA)); + console.log('selected1'); _this.$trigger && _this.hide('date', day, $(this).data(MARK_DATA)); @@ -733,6 +743,7 @@ _this.updateDateView(y, m); vc('date', y, m); _this.options.onSelected.call(this, 'month', new Date(y, m - 1)); + console.log('selected2'); }); // hover @@ -808,4 +819,4 @@ $.fn.calendar.defaults = defaults; -})); +})); \ No newline at end of file