Skip to content

Commit

Permalink
Added chnages to version 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Manohar-Gunturu committed Jan 3, 2018
1 parent bf14137 commit 26052e4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
28 changes: 22 additions & 6 deletions calendar-lite_polymer1.x/calendar-lite-dark.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
properties: {
date: {
type: Date,
value: new Date()
},
currentMonth: {
type: Number
Expand Down Expand Up @@ -395,8 +396,11 @@
this.generateTable();
this._animationEvent = this._whichAnimationEnd();

multiple.push(this.date.getDate()+","+this.date.getMonth()+","+this.date.getFullYear());

// in multiple date selection - insert today date if it in not in the disabled days list
if(!this.isDisabled(this.date.getDate())){
multiple.push(this.date.getDate()+","+this.date.getMonth()+","+this.date.getFullYear());
}

this.currentYear = this.date.getFullYear();
this.currentMonth = this.date.getMonth();
if(this.mainColor != null){
Expand Down Expand Up @@ -426,6 +430,12 @@
//some thing weird
}
},
isDisabled: function(i){
return ( (this.minDate != null && this.tmpDate<=this.minDate) ||
(this.maxDate != null && this.tmpDate>=this.maxDate) ||
this.disabledWeekDay.indexOf(this.days_names[(this.tmpDate).getDay()]) != -1 ||
(this.disabledDays).indexOf(i) != -1 )
},
generateTable : function(){

// if date attribute is not set take today date
Expand All @@ -442,7 +452,7 @@
}
for(var i=1;i<=tmpDate.monthDays();i++){
tmpDate.setDate(i);
if((this.minDate != null && tmpDate<=this.minDate) || (this.maxDate != null && tmpDate>=this.maxDate) || this.disabledWeekDay.indexOf(days_names[(tmpDate).getDay()]) != -1 || (this.disabledDays).indexOf(i) != -1){
if(this.isDisabled(i)){
tmpArray.push({text:i,isDisabled:true,i:cf++});
}else{
tmpArray.push({text:i,isDisabled:false,i:cf++});
Expand All @@ -457,14 +467,20 @@
tmpArray = null;
},
_getDayClass:function(s,d){

if(this.isDisabled(this.date.getDate())){
return "dateSticker";
}

if(this.multiSelect != null){
if(multiple.indexOf(s+","+this.currentMonth+","+this.currentYear) > -1){
return "dateSticker selected";
}
}
if(this.date.getDate() == s && this.date.getMonth() == this.currentMonth && this.date.getFullYear()== this.currentYear){
return "dateSticker selected";
}

if(this.date.getDate() == s && this.date.getMonth() == this.currentMonth && this.date.getFullYear()== this.currentYear){
return "dateSticker selected";
}
return "dateSticker";
},
_setDate: function(e){
Expand Down
27 changes: 21 additions & 6 deletions calendar-lite_polymer1.x/calendar-lite.html
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@
properties: {
date: {
type: Date,
value: new Date()
},
currentMonth: {
type: Number
Expand Down Expand Up @@ -399,8 +400,11 @@
this.generateTable();
this._animationEvent = this._whichAnimationEnd();

multiple.push(this.date.getDate()+","+this.date.getMonth()+","+this.date.getFullYear());

// in multiple date selection - insert today date if it in not in the disabled days list
if(!this.isDisabled(this.date.getDate())){
multiple.push(this.date.getDate()+","+this.date.getMonth()+","+this.date.getFullYear());
}

this.currentYear = this.date.getFullYear();
this.currentMonth = this.date.getMonth();

Expand All @@ -420,6 +424,12 @@
//discard tmpArray
tmpArray = null;
},
isDisabled: function(i){
return ( (this.minDate != null && tmpDate<=this.minDate) ||
(this.maxDate != null && tmpDate>=this.maxDate) ||
this.disabledWeekDay.indexOf(this.days_names[(tmpDate).getDay()]) != -1 ||
(this.disabledDays).indexOf(i) != -1 )
},
_getUpdated:function(d,type){
if(type == 'year'){
return this.date.getFullYear();
Expand Down Expand Up @@ -455,7 +465,7 @@
//fill days and check disable dates
for(var i=1;i<=tmpDate.monthDays();i++){
tmpDate.setDate(i);
if((this.minDate != null && tmpDate<=this.minDate) || (this.maxDate != null && tmpDate>=this.maxDate) || this.disabledWeekDay.indexOf(days_names[(tmpDate).getDay()]) != -1 || (this.disabledDays).indexOf(i) != -1){
if(this.isDisabled(i)){
tmpArray.push({text:i,isDisabled:true,i:cf++});
}else{
tmpArray.push({text:i,isDisabled:false,i:cf++});
Expand All @@ -471,15 +481,20 @@
tmpArray = null;
},
_getDayClass:function(s,d){
if(this.multiSelect != null){

if(this.isDisabled(this.date.getDate())){
return "dateSticker";
}

if(this.multiSelect != null){
if(multiple.indexOf(s+","+this.currentMonth+","+this.currentYear) > -1){
return "dateSticker selected";
}
}
}
if(this.date.getDate() == s && this.date.getMonth() == this.currentMonth && this.date.getFullYear()== this.currentYear){
return "dateSticker selected";
}
return "dateSticker";
return "dateSticker";
},
_setDate: function(e){
var target = e.target;
Expand Down
4 changes: 2 additions & 2 deletions calendar-lite_polymer1.x/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<h2></h2>

<calendar-lite-dark id="excalendar" min-date="2016,12,9" multi-select='{"max":3,"consequent":false}' disabled-week-day='["Fri"]' disabled-days="[2,3,4]">
</calendar-lite-dark>
<calendar-lite id="excalendar" min-date="2016,12,9" multi-select='{"max":3,"consequent":false}' disabled-week-day='["Fri"]' disabled-days="[2,3,4]">
</calendar-lite>

<script>

Expand Down

0 comments on commit 26052e4

Please sign in to comment.