diff --git a/build/angular-date-range-picker.js b/build/angular-date-range-picker.js
index b870931..c06e1ed 100644
--- a/build/angular-date-range-picker.js
+++ b/build/angular-date-range-picker.js
@@ -76,7 +76,7 @@
} else {
$scope.selection = false;
$scope.selection = $scope.model || false;
- $scope.date = moment($scope.model) || moment();
+ $scope.date = moment($scope.model || void 0);
return $scope.range = moment().range(moment($scope.date).startOf("month"), moment($scope.date).endOf("month"));
}
};
@@ -161,6 +161,7 @@
$event.stopPropagation();
}
}
+ $scope.selecting = false;
$scope.visible = false;
return $scope.start = null;
};
@@ -173,6 +174,11 @@
$event.stopPropagation();
}
}
+ if ($scope.selecting) {
+ $scope.select({
+ date: $scope.start.clone()
+ });
+ }
$scope.model = $scope.selection;
$timeout(function() {
if ($scope.callback) {
diff --git a/build/angular-date-range-picker.min.js b/build/angular-date-range-picker.min.js
index e84e720..7658996 100644
--- a/build/angular-date-range-picker.min.js
+++ b/build/angular-date-range-picker.min.js
@@ -1,2 +1,2 @@
-/*! angular-date-range-picker 2014-07-03 */
-(function(){angular.module("dateRangePicker",["pasvaz.bindonce"]),angular.module("dateRangePicker").directive("dateRangePicker",["$compile","$timeout",function(a,b){var c,d;return d='
\n
\n
◀\n
\n
\n
\n \n | \n | \n
\n \n | \n \n | \n
\n
\n
\n
▶\n
\n
\n
\n Select range: \n
\n
\n
\n
',c="CUSTOM",{restrict:"AE",replace:!0,template:'\n \n {{ model.start.format("ll") }} - {{ model.end.format("ll") }}\n Select date range\n \n \n {{ model.format("ll") }}\n Select date\n \n',scope:{model:"=ngModel",customSelectOptions:"=",ranged:"=",pastDates:"@",callback:"&"},link:function(e,f){var g,h,i,j,k,l;return e.quickListDefinitions=e.customSelectOptions,null==e.quickListDefinitions&&(e.quickListDefinitions=[{label:"This week",range:moment().range(moment().startOf("week").startOf("day"),moment().endOf("week").startOf("day"))},{label:"Next week",range:moment().range(moment().startOf("week").add(1,"week").startOf("day"),moment().add(1,"week").endOf("week").startOf("day"))},{label:"This fortnight",range:moment().range(moment().startOf("week").startOf("day"),moment().add(1,"week").endOf("week").startOf("day"))},{label:"This month",range:moment().range(moment().startOf("month").startOf("day"),moment().endOf("month").startOf("day"))},{label:"Next month",range:moment().range(moment().startOf("month").add(1,"month").startOf("day"),moment().add(1,"month").endOf("month").startOf("day"))}]),e.quick=null,e.range=null,e.selecting=!1,e.visible=!1,e.start=null,e.showRanged=void 0===e.ranged?!0:e.ranged,k=function(a){var b,d,f,g,h;if(null==a&&(a=!1),e.showRanged){for(e.quickList=[],a&&e.quickList.push({label:"Custom",range:c}),g=e.quickListDefinitions,h=[],d=0,f=g.length;f>d;d++)b=g[d],h.push(e.quickList.push(b));return h}},i=function(){var a,b;return e.showRanged?e.range=e.selection?(b=e.selection.start.clone().startOf("month").startOf("day"),a=b.clone().add(2,"months").endOf("month").startOf("day"),moment().range(b,a)):moment().range(moment().startOf("month").subtract(1,"month").startOf("day"),moment().endOf("month").add(1,"month").startOf("day")):(e.selection=!1,e.selection=e.model||!1,e.date=moment(e.model)||moment(),e.range=moment().range(moment(e.date).startOf("month"),moment(e.date).endOf("month")))},j=function(){var a,b,d,f;if(e.showRanged&&e.selection){for(f=e.quickList,b=0,d=f.length;d>b;b++)if(a=f[b],a.range!==c&&e.selection.start.startOf("day").unix()===a.range.start.startOf("day").unix()&&e.selection.end.startOf("day").unix()===a.range.end.startOf("day").unix())return e.quick=a.range,k(),void 0;return e.quick=c,k(!0)}},l=function(){var a,b,c,d,f,g;for(e.months=[],c=12*e.range.start.year()+e.range.start.month(),b=moment().startOf("week").day(),e.range.by("days",function(a){var d,f,g,h,i,j,k;return d=a.day()-b,0>d&&(d=7+d),g=12*a.year()+a.month()-c,i=parseInt((7+a.date()-d)/7),h=!1,f=!1,e.showRanged?e.start?(h=a===e.start,f=a0)),(j=e.months)[g]||(j[g]={name:a.format("MMMM YYYY"),weeks:[]}),(k=e.months[g].weeks)[i]||(k[i]=[]),e.months[g].weeks[i][d]={date:a,selected:h,disabled:f,start:e.start&&e.start.unix()===a.unix()}}),g=e.months,d=0,f=g.length;f>d;d++)a=g[d],a.weeks[0]||a.weeks.splice(0,1);return j()},e.show=function(){return e.selection=e.model,i(),l(),e.visible=!0},e.hide=function(a){return null!=a&&"function"==typeof a.stopPropagation&&a.stopPropagation(),e.visible=!1,e.start=null},e.prevent_select=function(a){return null!=a?"function"==typeof a.stopPropagation?a.stopPropagation():void 0:void 0},e.ok=function(a){return null!=a&&"function"==typeof a.stopPropagation&&a.stopPropagation(),e.model=e.selection,b(function(){return e.callback?e.callback():void 0}),e.hide()},e.select=function(a,b){return null!=b&&"function"==typeof b.stopPropagation&&b.stopPropagation(),a.disabled?void 0:(e.showRanged?(e.selecting=!e.selecting,e.selecting?e.start=a.date:(e.selection=moment().range(e.start,a.date),e.start=null)):e.selection=moment(a.date),l())},e.move=function(a,b){return null!=b&&"function"==typeof b.stopPropagation&&b.stopPropagation(),e.showRanged?e.range=moment().range(e.range.start.add(a,"months").startOf("month").startOf("day"),e.range.start.clone().add(2,"months").endOf("month").startOf("day")):(e.date.add(a,"months"),e.range=moment().range(moment(e.date).startOf("month"),moment(e.date).endOf("month"))),l()},e.handlePickerClick=function(a){return null!=a?"function"==typeof a.stopPropagation?a.stopPropagation():void 0:void 0},e.$watch("quick",function(a){return a&&a!==c?(e.selection=e.quick,e.selecting=!1,e.start=null,i(),l()):void 0}),e.$watch("customSelectOptions",function(a){return"undefined"!=typeof customSelectOptions&&null!==customSelectOptions?e.quickListDefinitions=a:void 0}),h=a(angular.element(d))(e),f.append(h),f.bind("click",function(a){return null!=a&&"function"==typeof a.stopPropagation&&a.stopPropagation(),e.$apply(function(){return e.visible?e.hide():e.show()})}),g=function(){return e.$apply(function(){return e.hide()}),!0},angular.element(document).bind("click",g),e.$on("$destroy",function(){return angular.element(document).unbind("click",g)}),k(),i(),l()}}}])}).call(this);
\ No newline at end of file
+/*! angular-date-range-picker 2015-07-23 */
+(function(){angular.module("dateRangePicker",["pasvaz.bindonce"]),angular.module("dateRangePicker").directive("dateRangePicker",["$compile","$timeout",function(a,b){var c,d;return d='\n
\n
◀\n
\n
\n
\n \n | \n | \n
\n \n | \n \n | \n
\n
\n
\n
▶\n
\n
\n
\n Select range: \n
\n
\n
\n
',c="CUSTOM",{restrict:"AE",replace:!0,template:'\n \n {{ model.start.format("ll") }} - {{ model.end.format("ll") }}\n Select date range\n \n \n {{ model.format("ll") }}\n Select date\n \n',scope:{model:"=ngModel",customSelectOptions:"=",ranged:"=",pastDates:"@",callback:"&"},link:function(e,f){var g,h,i,j,k,l;return e.quickListDefinitions=e.customSelectOptions,null==e.quickListDefinitions&&(e.quickListDefinitions=[{label:"This week",range:moment().range(moment().startOf("week").startOf("day"),moment().endOf("week").startOf("day"))},{label:"Next week",range:moment().range(moment().startOf("week").add(1,"week").startOf("day"),moment().add(1,"week").endOf("week").startOf("day"))},{label:"This fortnight",range:moment().range(moment().startOf("week").startOf("day"),moment().add(1,"week").endOf("week").startOf("day"))},{label:"This month",range:moment().range(moment().startOf("month").startOf("day"),moment().endOf("month").startOf("day"))},{label:"Next month",range:moment().range(moment().startOf("month").add(1,"month").startOf("day"),moment().add(1,"month").endOf("month").startOf("day"))}]),e.quick=null,e.range=null,e.selecting=!1,e.visible=!1,e.start=null,e.showRanged=void 0===e.ranged?!0:e.ranged,k=function(a){var b,d,f,g,h;if(null==a&&(a=!1),e.showRanged){for(e.quickList=[],a&&e.quickList.push({label:"Custom",range:c}),g=e.quickListDefinitions,h=[],d=0,f=g.length;f>d;d++)b=g[d],h.push(e.quickList.push(b));return h}},i=function(){var a,b;return e.showRanged?e.range=e.selection?(b=e.selection.start.clone().startOf("month").startOf("day"),a=b.clone().add(2,"months").endOf("month").startOf("day"),moment().range(b,a)):moment().range(moment().startOf("month").subtract(1,"month").startOf("day"),moment().endOf("month").add(1,"month").startOf("day")):(e.selection=!1,e.selection=e.model||!1,e.date=moment(e.model||void 0),e.range=moment().range(moment(e.date).startOf("month"),moment(e.date).endOf("month")))},j=function(){var a,b,d,f;if(e.showRanged&&e.selection){for(f=e.quickList,b=0,d=f.length;d>b;b++)if(a=f[b],a.range!==c&&e.selection.start.startOf("day").unix()===a.range.start.startOf("day").unix()&&e.selection.end.startOf("day").unix()===a.range.end.startOf("day").unix())return e.quick=a.range,void k();return e.quick=c,k(!0)}},l=function(){var a,b,c,d,f,g;for(e.months=[],c=12*e.range.start.year()+e.range.start.month(),b=moment().startOf("week").day(),e.range.by("days",function(a){var d,f,g,h,i,j,k;return d=a.day()-b,0>d&&(d=7+d),g=12*a.year()+a.month()-c,i=parseInt((7+a.date()-d)/7),h=!1,f=!1,e.showRanged?e.start?(h=a===e.start,f=a0)),(j=e.months)[g]||(j[g]={name:a.format("MMMM YYYY"),weeks:[]}),(k=e.months[g].weeks)[i]||(k[i]=[]),e.months[g].weeks[i][d]={date:a,selected:h,disabled:f,start:e.start&&e.start.unix()===a.unix()}}),g=e.months,d=0,f=g.length;f>d;d++)a=g[d],a.weeks[0]||a.weeks.splice(0,1);return j()},e.show=function(){return e.selection=e.model,i(),l(),e.visible=!0},e.hide=function(a){return null!=a&&"function"==typeof a.stopPropagation&&a.stopPropagation(),e.selecting=!1,e.visible=!1,e.start=null},e.prevent_select=function(a){return null!=a&&"function"==typeof a.stopPropagation?a.stopPropagation():void 0},e.ok=function(a){return null!=a&&"function"==typeof a.stopPropagation&&a.stopPropagation(),e.selecting&&e.select({date:e.start.clone()}),e.model=e.selection,b(function(){return e.callback?e.callback():void 0}),e.hide()},e.select=function(a,b){return null!=b&&"function"==typeof b.stopPropagation&&b.stopPropagation(),a.disabled?void 0:(e.showRanged?(e.selecting=!e.selecting,e.selecting?e.start=a.date:(e.selection=moment().range(e.start,a.date),e.start=null)):e.selection=moment(a.date),l())},e.move=function(a,b){return null!=b&&"function"==typeof b.stopPropagation&&b.stopPropagation(),e.showRanged?e.range=moment().range(e.range.start.add(a,"months").startOf("month").startOf("day"),e.range.start.clone().add(2,"months").endOf("month").startOf("day")):(e.date.add(a,"months"),e.range=moment().range(moment(e.date).startOf("month"),moment(e.date).endOf("month"))),l()},e.handlePickerClick=function(a){return null!=a&&"function"==typeof a.stopPropagation?a.stopPropagation():void 0},e.$watch("quick",function(a){return a&&a!==c?(e.selection=e.quick,e.selecting=!1,e.start=null,i(),l()):void 0}),e.$watch("customSelectOptions",function(a){return"undefined"!=typeof customSelectOptions&&null!==customSelectOptions?e.quickListDefinitions=a:void 0}),h=a(angular.element(d))(e),f.append(h),f.bind("click",function(a){return null!=a&&"function"==typeof a.stopPropagation&&a.stopPropagation(),e.$apply(function(){return e.visible?e.hide():e.show()})}),g=function(){return e.$apply(function(){return e.hide()}),!0},angular.element(document).bind("click",g),e.$on("$destroy",function(){return angular.element(document).unbind("click",g)}),k(),i(),l()}}}])}).call(this);
\ No newline at end of file
diff --git a/src/angular-date-range-picker.coffee b/src/angular-date-range-picker.coffee
index 88ed1d1..8745d30 100644
--- a/src/angular-date-range-picker.coffee
+++ b/src/angular-date-range-picker.coffee
@@ -131,7 +131,7 @@ angular.module("dateRangePicker").directive "dateRangePicker", ["$compile", "$ti
else
$scope.selection = false
$scope.selection = $scope.model || false
- $scope.date = moment($scope.model) || moment()
+ $scope.date = moment($scope.model || undefined)
$scope.range = moment().range(
moment($scope.date).startOf("month"),
moment($scope.date).endOf("month")
@@ -198,6 +198,7 @@ angular.module("dateRangePicker").directive "dateRangePicker", ["$compile", "$ti
$scope.hide = ($event) ->
$event?.stopPropagation?()
+ $scope.selecting = false
$scope.visible = false
$scope.start = null
@@ -207,6 +208,7 @@ angular.module("dateRangePicker").directive "dateRangePicker", ["$compile", "$ti
$scope.ok = ($event) ->
$event?.stopPropagation?()
+ $scope.select date: $scope.start.clone() if $scope.selecting
$scope.model = $scope.selection
$timeout -> $scope.callback() if $scope.callback
$scope.hide()