Skip to content

Commit ea4b0bb

Browse files
# Conflicts: # dist/vue-rangedate-picker.common.js # dist/vue-rangedate-picker.esm.js # dist/vue-rangedate-picker.js # dist/vue-rangedate-picker.min.js # src/RangedatePicker.vue # src/js/rangedate-picker.js
2 parents da833a3 + ad73e6e commit ea4b0bb

File tree

7 files changed

+140
-112
lines changed

7 files changed

+140
-112
lines changed

dist/vue-rangedate-picker.common.js

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-rangedate-picker v0.2.3
2+
* vue-rangedate-picker v0.2.4
33
* (c) 2017 hidayat.febiansyah
44
* Released under the MIT License.
55
*/
@@ -508,11 +508,11 @@ var __vue_module__ = {
508508
type: Object,
509509
default: function () { return null; }
510510
},
511-
startMonth: {
511+
startActiveMonth: {
512512
type: Number,
513513
default: new Date().getMonth()
514514
},
515-
startYear: {
515+
startActiveYear: {
516516
type: Number,
517517
default: new Date().getFullYear()
518518
},
@@ -537,15 +537,22 @@ var __vue_module__ = {
537537
isOpen: false,
538538
presetActive: '',
539539
showMonth: false,
540-
activeMonthStart: this.startMonth,
541-
startActiveYear: this.startYear
540+
activeMonthStart: this.startActiveMonth,
541+
activeYearStart: this.startActiveYear,
542+
activeYearEnd: this.startActiveYear
542543
}
543544
},
544545
created: function created () {
545546
this.range = this.initRange || null;
546547
if (this.isCompact) {
547548
this.isOpen = true;
548549
}
550+
if (this.activeMonthStart === 11) { this.activeYearEnd = this.activeYearStart + 1; }
551+
},
552+
watch: {
553+
startNextActiveMonth: function (value) {
554+
if (value === 0) { this.activeYearEnd = this.activeYearStart + 1; }
555+
}
549556
},
550557
computed: {
551558
monthsLocale: function () {
@@ -558,22 +565,19 @@ var __vue_module__ = {
558565
return Object.assign({}, defaultStyle, this.style)
559566
},
560567
startMonthDay: function () {
561-
return new Date(this.startActiveYear, this.activeMonthStart, 1).getDay()
568+
return new Date(this.activeYearStart, this.activeMonthStart, 1).getDay()
562569
},
563570
startNextMonthDay: function () {
564-
return new Date(this.startActiveYear, this.startNextActiveMonth, 1).getDay()
571+
return new Date(this.activeYearStart, this.startNextActiveMonth, 1).getDay()
565572
},
566573
endMonthDate: function () {
567-
return new Date(this.startActiveYear, this.startNextActiveMonth, 0).getDate()
574+
return new Date(this.activeYearEnd, this.startNextActiveMonth, 0).getDate()
568575
},
569576
endNextMonthDate: function () {
570-
return new Date(this.startActiveYear, this.activeMonthStart + 2, 0).getDate()
577+
return new Date(this.activeYearEnd, this.activeMonthStart + 2, 0).getDate()
571578
},
572579
startNextActiveMonth: function () {
573-
return this.activeMonthStart + 1
574-
},
575-
nextActiveYear: function () {
576-
return new Date(this.startActiveYear, this.activeMonthStart + 1, 1).getFullYear()
580+
return this.activeMonthStart >= 11 ? 0 : this.activeMonthStart + 1
577581
},
578582
finalPresetRanges: function () {
579583
var tmp = {};
@@ -631,7 +635,7 @@ var __vue_module__ = {
631635
} else {
632636
newData['end'] = null;
633637
}
634-
var resultDate = new Date(this.startActiveYear, activeMonth, result);
638+
var resultDate = new Date(this.activeYearStart, activeMonth, result);
635639
if (!this.isFirstChoice && resultDate < this.dateRange.start) {
636640
this.isFirstChoice = false;
637641
return { start: resultDate }
@@ -665,9 +669,9 @@ var __vue_module__ = {
665669

666670
var currDate = null;
667671
if (key === 'first') {
668-
currDate = new Date(this.startActiveYear, this.activeMonthStart, result);
672+
currDate = new Date(this.activeYearStart, this.activeMonthStart, result);
669673
} else {
670-
currDate = new Date(this.startActiveYear, this.startNextActiveMonth, result);
674+
currDate = new Date(this.activeYearEnd, this.startNextActiveMonth, result);
671675
}
672676
return (this.dateRange.start && this.dateRange.start.getTime() === currDate.getTime()) ||
673677
(this.dateRange.end && this.dateRange.end.getTime() === currDate.getTime())
@@ -678,29 +682,32 @@ var __vue_module__ = {
678682

679683
var currDate = null;
680684
if (key === 'first') {
681-
currDate = new Date(this.startActiveYear, this.activeMonthStart, result);
685+
currDate = new Date(this.activeYearStart, this.activeMonthStart, result);
682686
} else {
683-
currDate = new Date(this.startActiveYear, this.startNextActiveMonth, result);
687+
currDate = new Date(this.activeYearEnd, this.startNextActiveMonth, result);
684688
}
685689
return (this.dateRange.start && this.dateRange.start.getTime() < currDate.getTime()) &&
686690
(this.dateRange.end && this.dateRange.end.getTime() > currDate.getTime())
687691
},
688692
goPrevMonth: function goPrevMonth () {
689-
var prevMonth = new Date(this.startActiveYear, this.activeMonthStart, 0);
693+
var prevMonth = new Date(this.activeYearStart, this.activeMonthStart, 0);
690694
this.activeMonthStart = prevMonth.getMonth();
691-
this.startActiveYear = prevMonth.getFullYear();
695+
this.activeYearStart = prevMonth.getFullYear();
696+
this.activeYearEnd = prevMonth.getFullYear();
692697
},
693698
goNextMonth: function goNextMonth () {
694-
var nextMonth = new Date(this.startActiveYear, this.startNextActiveMonth, 1);
699+
var nextMonth = new Date(this.activeYearEnd, this.startNextActiveMonth, 1);
695700
this.activeMonthStart = nextMonth.getMonth();
696-
this.startActiveYear = nextMonth.getFullYear();
701+
this.activeYearStart = nextMonth.getFullYear();
702+
this.activeYearEnd = nextMonth.getFullYear();
697703
},
698704
updatePreset: function updatePreset (item) {
699705
this.presetActive = item.label;
700706
this.dateRange = item.dateRange;
701707
// update start active month
702708
this.activeMonthStart = this.dateRange.start.getMonth();
703-
this.startActiveYear = this.dateRange.start.getFullYear();
709+
this.activeYearStart = this.dateRange.start.getFullYear();
710+
this.activeYearEnd = this.dateRange.end.getFullYear();
704711
},
705712
setDateValue: function () {
706713
this.$emit('selected', this.dateRange);
@@ -711,8 +718,8 @@ var __vue_module__ = {
711718
}
712719
};
713720

714-
var __$__vue_module__ = Object.assign(__vue_module__, {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"calendar-root"},[_c('div',{staticClass:"input-date",on:{"click":function($event){_vm.toggleCalendar();}}},[_vm._v(" "+_vm._s(_vm.getDateString(_vm.dateRange.start))+" - "+_vm._s(_vm.getDateString(_vm.dateRange.end)))]),_vm._v(" "),(_vm.isOpen)?_c('div',{staticClass:"calendar",class:{'calendar-mobile ': _vm.isCompact, 'calendar-right-to-left': _vm.isRighttoLeft}},[(!_vm.isCompact)?_c('div',{staticClass:"calendar-head"},[_c('h2',[_vm._v(_vm._s(_vm.captions.title))]),_vm._v(" "),_c('i',{staticClass:"close",on:{"click":function($event){_vm.toggleCalendar();}}})]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"calendar-wrap"},[(_vm.showMonth)?_c('div',{staticClass:"calendar_month_left",class:{'calendar-left-mobile': _vm.isCompact}},[_c('div',{staticClass:"months-text"},[_c('i',{staticClass:"left",on:{"click":_vm.goPrevMonth}}),_vm._v(" "),(_vm.isCompact)?_c('i',{staticClass:"right",on:{"click":_vm.goNextMonth}}):_vm._e(),_vm._v(" "+_vm._s(_vm.monthsLocale[_vm.activeMonthStart] +' '+ _vm.startActiveYear))]),_vm._v(" "),_c('ul',{class:_vm.s.daysWeeks},_vm._l((_vm.shortDaysLocale),function(item){return _c('li',[_vm._v(_vm._s(item))])})),_vm._v(" "),_vm._l((6),function(r){return _c('ul',{class:[_vm.s.days]},_vm._l((_vm.numOfDays),function(i){return _c('li',{class:[( obj = {}, obj[_vm.s.daysSelected] = _vm.isDateSelected(r, i, 'first', _vm.startMonthDay, _vm.endMonthDate), obj[_vm.s.daysInRange] = _vm.isDateInRange(r, i, 'first', _vm.startMonthDay, _vm.endMonthDate), obj )],domProps:{"innerHTML":_vm._s(_vm.getDayCell(r, i, _vm.startMonthDay, _vm.endMonthDate))},on:{"click":function($event){_vm.selectFirstItem(r, i);}}})
715-
var obj;}))})],2):_vm._e(),_vm._v(" "),(!_vm.isCompact)?_c('div',{staticClass:"calendar_month_right"},[_c('div',{staticClass:"months-text"},[_vm._v(" "+_vm._s(_vm.monthsLocale[_vm.startNextActiveMonth % 12] +' '+ _vm.nextActiveYear)+" "),_c('i',{staticClass:"right",on:{"click":_vm.goNextMonth}})]),_vm._v(" "),_c('ul',{class:_vm.s.daysWeeks},_vm._l((_vm.shortDaysLocale),function(item){return _c('li',[_vm._v(_vm._s(item))])})),_vm._v(" "),_vm._l((6),function(r){return _c('ul',{class:[_vm.s.days]},_vm._l((_vm.numOfDays),function(i){return _c('li',{class:[( obj = {}, obj[_vm.s.daysSelected] = _vm.isDateSelected(r, i, 'second', _vm.startNextMonthDay, _vm.endNextMonthDate), obj[_vm.s.daysInRange] = _vm.isDateInRange(r, i, 'second', _vm.startNextMonthDay, _vm.endNextMonthDate), obj )],domProps:{"innerHTML":_vm._s(_vm.getDayCell(r, i, _vm.startNextMonthDay, _vm.endNextMonthDate))},on:{"click":function($event){_vm.selectSecondItem(r, i);}}})
721+
var __$__vue_module__ = Object.assign(__vue_module__, {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"calendar-root"},[_c('div',{staticClass:"input-date",on:{"click":function($event){_vm.toggleCalendar();}}},[_vm._v(" "+_vm._s(_vm.getDateString(_vm.dateRange.start))+" - "+_vm._s(_vm.getDateString(_vm.dateRange.end)))]),_vm._v(" "),(_vm.isOpen)?_c('div',{staticClass:"calendar",class:{'calendar-mobile ': _vm.isCompact, 'calendar-right-to-left': _vm.isRighttoLeft}},[(!_vm.isCompact)?_c('div',{staticClass:"calendar-head"},[_c('h2',[_vm._v(_vm._s(_vm.captions.title))]),_vm._v(" "),_c('i',{staticClass:"close",on:{"click":function($event){_vm.toggleCalendar();}}})]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"calendar-wrap"},[(_vm.showMonth)?_c('div',{staticClass:"calendar_month_left",class:{'calendar-left-mobile': _vm.isCompact}},[_c('div',{staticClass:"months-text"},[_c('i',{staticClass:"left",on:{"click":_vm.goPrevMonth}}),_vm._v(" "),(_vm.isCompact)?_c('i',{staticClass:"right",on:{"click":_vm.goNextMonth}}):_vm._e(),_vm._v(" "+_vm._s(_vm.monthsLocale[_vm.activeMonthStart] +' '+ _vm.activeYearStart))]),_vm._v(" "),_c('ul',{class:_vm.s.daysWeeks},_vm._l((_vm.shortDaysLocale),function(item){return _c('li',{key:item},[_vm._v(_vm._s(item))])})),_vm._v(" "),_vm._l((6),function(r){return _c('ul',{key:r,class:[_vm.s.days]},_vm._l((_vm.numOfDays),function(i){return _c('li',{key:i,class:[( obj = {}, obj[_vm.s.daysSelected] = _vm.isDateSelected(r, i, 'first', _vm.startMonthDay, _vm.endMonthDate), obj[_vm.s.daysInRange] = _vm.isDateInRange(r, i, 'first', _vm.startMonthDay, _vm.endMonthDate), obj )],domProps:{"innerHTML":_vm._s(_vm.getDayCell(r, i, _vm.startMonthDay, _vm.endMonthDate))},on:{"click":function($event){_vm.selectFirstItem(r, i);}}})
722+
var obj;}))})],2):_vm._e(),_vm._v(" "),(!_vm.isCompact)?_c('div',{staticClass:"calendar_month_right"},[_c('div',{staticClass:"months-text"},[_vm._v(" "+_vm._s(_vm.monthsLocale[_vm.startNextActiveMonth] +' '+ _vm.activeYearEnd)+" "),_c('i',{staticClass:"right",on:{"click":_vm.goNextMonth}})]),_vm._v(" "),_c('ul',{class:_vm.s.daysWeeks},_vm._l((_vm.shortDaysLocale),function(item){return _c('li',{key:item},[_vm._v(_vm._s(item))])})),_vm._v(" "),_vm._l((6),function(r){return _c('ul',{key:r,class:[_vm.s.days]},_vm._l((_vm.numOfDays),function(i){return _c('li',{key:i,class:[( obj = {}, obj[_vm.s.daysSelected] = _vm.isDateSelected(r, i, 'second', _vm.startNextMonthDay, _vm.endNextMonthDate), obj[_vm.s.daysInRange] = _vm.isDateInRange(r, i, 'second', _vm.startNextMonthDay, _vm.endNextMonthDate), obj )],domProps:{"innerHTML":_vm._s(_vm.getDayCell(r, i, _vm.startNextMonthDay, _vm.endNextMonthDate))},on:{"click":function($event){_vm.selectSecondItem(r, i);}}})
716723
var obj;}))})],2):_vm._e()]),_vm._v(" "),(!_vm.showMonth || !_vm.isCompact)?_c('div',{staticClass:"calendar-range",class:{'calendar-range-mobile ': _vm.isCompact}},[_c('ul',{staticClass:"calendar_preset"},[_vm._l((_vm.finalPresetRanges),function(item,idx){return _c('li',{key:idx,staticClass:"calendar_preset-ranges",class:{'active-preset': _vm.presetActive === item.label},on:{"click":function($event){_vm.updatePreset(item);}}},[_vm._v(" "+_vm._s(item.label)+" ")])}),_vm._v(" "),_c('li',[_c('button',{staticClass:"calendar-btn-apply",on:{"click":function($event){_vm.setDateValue();}}},[_vm._v(_vm._s(_vm.captions.ok_button))])])],2)]):_vm._e()]):_vm._e()])},staticRenderFns: [],_scopeId: 'data-v-5e837f70',});
717724
__$__vue_module__.prototype = __vue_module__.prototype;
718725

@@ -725,7 +732,7 @@ if (typeof window !== 'undefined' && window.Vue) {
725732
window.Vue.use(plugin);
726733
}
727734

728-
var version = '0.2.3';
735+
var version = '0.2.4';
729736

730737
exports['default'] = plugin;
731738
exports.RangedatePicker = __$__vue_module__;

0 commit comments

Comments
 (0)