Skip to content

Commit 286faf8

Browse files
committed
little fixes
1 parent 7d2a063 commit 286faf8

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h3>Basic pf-calendar-events demo</h3>
3030
</style>
3131

3232

33-
<pf-calendar-events id="pf-calendar" calendarstyle="classic-calendaj"
33+
<pf-calendar-events id="pf-calendar" calendarstyle="material-calendar"
3434
data='[
3535
{ "eventName": "Lunch Meeting w/ Mark", "category": "Work", "color": "orange","date":"1491322091394" },
3636
{ "eventName": "Appoint ment With Dr David", "category": "Medical", "color": "yellow","date":"1499185140000" },

pf-calendar-events.html

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
box-sizing: border-box;
5959
}
6060

61+
6162
body {
6263
overflow: hidden;
6364
font-family: 'HelveticaNeue-UltraLight', 'Helvetica Neue UltraLight', 'Helvetica Neue', Arial, Helvetica, sans-serif;
@@ -800,8 +801,12 @@
800801
this.today = moment();
801802
}
802803
this.$.calendar.innerHTML = '';
803-
this.calendar = this._Calendar(this.$.calendar, this._convertMillsDate(
804-
this.data));
804+
if(!this.data){
805+
//dummy data
806+
this.data=JSON.parse('[{ "eventName": "Lunch Meeting w/ Mark", "category": "Work", "color": "orange","date":"14913220913940" }]');
807+
}
808+
this.calendar = this._Calendar(this.$.calendar,
809+
this.data);
805810
}
806811
_Calendar(selector, event) {
807812

@@ -992,6 +997,18 @@
992997
var self = this;
993998
if (day.month() === this.current.month()) {
994999
var todaysEvents = this.events.reduce(function (memo, ev) {
1000+
// ev.date = ev.date.replace(/['"]+/g, '');
1001+
var dateType=typeof ev.date
1002+
if (dateType=="string"){
1003+
1004+
1005+
ev.date=JSON.parse(ev.date);
1006+
var dateType=typeof ev.date
1007+
}
1008+
if(dateType=="number") {
1009+
ev.date = moment(parseInt(ev.date))
1010+
// ev.isDateFormat=true
1011+
}
9951012
if (ev.date.isSame(day, 'day')) {
9961013
memo.push(ev);
9971014
}
@@ -1202,14 +1219,16 @@
12021219
return ele;
12031220
}
12041221
_convertMillsDate(data) {
1222+
1223+
12051224
if(!data){
12061225

12071226
data=JSON.parse('[{ "eventName": "Lunch Meeting w/ Mark", "category": "Work", "color": "orange","date":"14913220913940" }]');
12081227
}
12091228
data.forEach(function (ev) {
1210-
if(!ev.isDateFormat) {
1229+
if(typeof ev.date=="number") {
12111230
ev.date = moment(parseInt(ev.date))
1212-
ev.isDateFormat=true
1231+
// ev.isDateFormat=true
12131232
}
12141233
// ev.date = self.current.clone().date(Math.random() * (29 - 1) + 1);
12151234
});

0 commit comments

Comments
 (0)