Skip to content

Commit 6745a1c

Browse files
Add new style and remove logging
1 parent 208fc16 commit 6745a1c

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

dist/vue-rangedate-picker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-rangedate-picker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RangedatePicker.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ul v-for="r in 6" :class="[s.days]" :key="r">
1919
<li :class="[{[s.daysSelected]: isDateSelected(r, i, 'first', startMonthDay, endMonthDate),
2020
[s.daysInRange]: isDateInRange(r, i, 'first', startMonthDay, endMonthDate),
21-
[s.dateDisabled]: isDateDisabled(r, i, startMonthDay, endMonthDate)}]" v-for="i in numOfDays" :key="i" v-html="getDayCell(r, i, startMonthDay, endMonthDate)"
21+
[s.dateDisabled]: isDateDisabled(r, i, startMonthDay, endMonthDate), [s.dateAfterMax]: isDateAfterMax(r, i, 'first', startNextMonthDay, endNextMonthDate)}]" v-for="i in numOfDays" :key="i" v-html="getDayCell(r, i, startMonthDay, endMonthDate)"
2222
@click="selectFirstItem(r, i)"></li>
2323
</ul>
2424
</div>
@@ -33,7 +33,7 @@
3333
<ul v-for="r in 6" :class="[s.days]" :key="r">
3434
<li :class="[{[s.daysSelected]: isDateSelected(r, i, 'second', startNextMonthDay, endNextMonthDate),
3535
[s.daysInRange]: isDateInRange(r, i, 'second', startNextMonthDay, endNextMonthDate),
36-
[s.dateDisabled]: isDateDisabled(r, i, startNextMonthDay, endNextMonthDate), [s.dateAfterMax]: isDateAfterMax(r, i, startNextMonthDay, endNextMonthDate)}]"
36+
[s.dateDisabled]: isDateDisabled(r, i, startNextMonthDay, endNextMonthDate), [s.dateAfterMax]: isDateAfterMax(r, i, 'second', startNextMonthDay, endNextMonthDate)}]"
3737
v-for="i in numOfDays" :key="i" v-html="getDayCell(r, i, startNextMonthDay, endNextMonthDate)"
3838
@click="selectSecondItem(r, i)"></li>
3939
</ul>
@@ -217,7 +217,7 @@ li.calendar_days--disabled {
217217
218218
li.calendar_days--after-max {
219219
pointer-events: none;
220-
background: #eee;
220+
color: #9ca7b2;
221221
}
222222
223223
li.calendar_days_selected {

src/js/rangedate-picker.js

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ export default {
202202
}
203203
},
204204
created () {
205-
console.log(this.maxDate)
206205
if (this.initPreset) {
207206
this.updatePreset(this.presets[this.initPreset]())
208207
}
@@ -332,26 +331,14 @@ export default {
332331
isDateSelected (r, i, key, startMonthDay, endMonthDate) {
333332
const result = this.getDayIndexInMonth(r, i, startMonthDay) + 1
334333
if (result < 2 || result > endMonthDate + 1) return false
335-
336-
let currDate = null
337-
if (key === 'first') {
338-
currDate = new Date(this.activeYearStart, this.activeMonthStart, result)
339-
} else {
340-
currDate = new Date(this.activeYearEnd, this.startNextActiveMonth, result)
341-
}
334+
const currDate = this.currentDate(key, result)
342335
return (this.dateRange.start && this.dateRange.start.getTime() === currDate.getTime()) ||
343336
(this.dateRange.end && this.dateRange.end.getTime() === currDate.getTime())
344337
},
345338
isDateInRange (r, i, key, startMonthDay, endMonthDate) {
346339
const result = this.getDayIndexInMonth(r, i, startMonthDay) + 1
347340
if (result < 2 || result > endMonthDate + 1) return false
348-
349-
let currDate = null
350-
if (key === 'first') {
351-
currDate = new Date(this.activeYearStart, this.activeMonthStart, result)
352-
} else {
353-
currDate = new Date(this.activeYearEnd, this.startNextActiveMonth, result)
354-
}
341+
const currDate = this.currentDate(key, result)
355342
return (this.dateRange.start && this.dateRange.start.getTime() < currDate.getTime()) &&
356343
(this.dateRange.end && this.dateRange.end.getTime() > currDate.getTime())
357344
},
@@ -360,15 +347,22 @@ export default {
360347
// bound by > 0 and < last day of month
361348
return !(result > 0 && result <= endMonthDate)
362349
},
363-
isDateAfterMax (r, i, startMonthDay, endMonthDate) {
350+
isDateAfterMax (r, i, key, startMonthDay, endMonthDate) {
364351
if (!this.maxDate) return false
365352
const result = this.getDayIndexInMonth(r, i, startMonthDay)
366-
let currDate = null
367-
currDate = new Date(this.activeYearEnd, this.startNextActiveMonth, result)
368-
console.log(currDate)
369-
console.log(this.maxDate)
353+
const currDate = this.currentDate(key, result)
370354
return (currDate > this.maxDate)
371355
},
356+
currentDate (calendar, day) {
357+
// calendar is either 'first' or 'second'
358+
let currDate = null
359+
if (calendar === 'first') {
360+
currDate = new Date(this.activeYearStart, this.activeMonthStart, day)
361+
} else {
362+
currDate = new Date(this.activeYearEnd, this.startNextActiveMonth, day)
363+
}
364+
return currDate
365+
},
372366
goPrevMonth () {
373367
const prevMonth = new Date(this.activeYearStart, this.activeMonthStart, 0)
374368
this.activeMonthStart = prevMonth.getMonth()

0 commit comments

Comments
 (0)