diff --git a/dist/ng-quick-date-plus-default-theme.css b/dist/ng-quick-date-plus-default-theme.css
index 6d7d18a..6e343fd 100644
--- a/dist/ng-quick-date-plus-default-theme.css
+++ b/dist/ng-quick-date-plus-default-theme.css
@@ -71,6 +71,12 @@ table.quickdate-calendar {
width: 100%;
margin-top: 5px;
}
+table.quickdate-calendar.hide-weekends th:first-child,
+table.quickdate-calendar.hide-weekends tbody td:first-child,
+table.quickdate-calendar.hide-weekends th:last-child,
+table.quickdate-calendar.hide-weekends tbody td:last-child {
+ display: none;
+}
table.quickdate-calendar th,
table.quickdate-calendar td {
padding: 5px;
diff --git a/dist/ng-quick-date.css b/dist/ng-quick-date.css
index 1b71c60..6bd49a8 100644
--- a/dist/ng-quick-date.css
+++ b/dist/ng-quick-date.css
@@ -71,6 +71,12 @@ table.quickdate-calendar {
width: 100%;
margin-top: 5px;
}
+table.quickdate-calendar.hide-weekends th:first-child,
+table.quickdate-calendar.hide-weekends tbody td:first-child,
+table.quickdate-calendar.hide-weekends th:last-child,
+table.quickdate-calendar.hide-weekends tbody td:last-child {
+ display: none;
+}
table.quickdate-calendar th,
table.quickdate-calendar td {
padding: 5px;
diff --git a/dist/ng-quick-date.js b/dist/ng-quick-date.js
index f92cab6..f1850bc 100644
--- a/dist/ng-quick-date.js
+++ b/dist/ng-quick-date.js
@@ -20,6 +20,7 @@
defaultTime: null,
dayAbbreviations: ["Su", "M", "Tu", "W", "Th", "F", "Sa"],
dateFilter: null,
+ hideWeekends: false,
parseDateFunction: function(str) {
var seconds;
seconds = Date.parse(str);
@@ -285,7 +286,7 @@
closeCalendar = true;
}
changed = (!ngModelCtrl.$viewValue && date) || (ngModelCtrl.$viewValue && !date) || ((date && ngModelCtrl.$viewValue) && (date.getTime() !== ngModelCtrl.$viewValue.getTime()));
- if (typeof scope.dateFilter === 'function' && !scope.dateFilter(date)) {
+ if (typeof scope.dateFilter === 'function' && !scope.dateFilter(date) || (scope.hideWeekends === true && (date.getDay() === 0 || date.getDay() === 6))) {
return false;
}
ngModelCtrl.$setViewValue(date);
@@ -354,7 +355,7 @@
};
return initialize();
},
- template: "
"
+ template: ""
};
}
]);
diff --git a/dist/ng-quick-date.min.js b/dist/ng-quick-date.min.js
index c68026c..6f882fd 100644
--- a/dist/ng-quick-date.min.js
+++ b/dist/ng-quick-date.min.js
@@ -1 +1 @@
-(function(){var a;a=angular.module("ngQuickDate",[]),a.provider("ngQuickDateDefaults",function(){return{options:{dateFormat:"M/d/yyyy",timeFormat:"h:mm a",labelFormat:null,placeholder:"Click to Set Date",hoverText:null,buttonIconHtml:null,closeButtonHtml:"×",nextLinkHtml:"Next →",prevLinkHtml:"← Prev",disableTimepicker:!1,disableClearButton:!1,defaultTime:null,dayAbbreviations:["Su","M","Tu","W","Th","F","Sa"],dateFilter:null,parseDateFunction:function(a){var b;return b=Date.parse(a),isNaN(b)?null:new Date(b)}},$get:function(){return this.options},set:function(a,b){var c,d,e;if("object"==typeof a){e=[];for(c in a)d=a[c],e.push(this.options[c]=d);return e}return this.options[a]=b}}}),a.directive("quickDatepicker",["ngQuickDateDefaults","$filter","$sce",function(a,b,c){return{restrict:"E",require:"?ngModel",scope:{dateFilter:"=?",onChange:"&",required:"@"},replace:!0,link:function(d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u;return n=function(){var a;return r(),d.toggleCalendar(!1),d.weeks=[],d.inputDate=null,d.inputTime=null,d.invalid=!0,"string"==typeof f.initValue&&g.$setViewValue(f.initValue),d.defaultTime||(a=new Date(2013,0,1,12,0),d.datePlaceholder=b("date")(a,d.dateFormat),d.timePlaceholder=b("date")(a,d.timeFormat)),q(),p()},r=function(){var b,e;for(b in a)e=a[b],b.match(/[Hh]tml/)?d[b]=c.trustAsHtml(a[b]||""):!d[b]&&f[b]?d[b]=f[b]:d[b]||(d[b]=a[b]);return d.labelFormat||(d.labelFormat=d.dateFormat,d.disableTimepicker||(d.labelFormat+=" "+d.timeFormat)),f.iconClass&&f.iconClass.length?d.buttonIconHtml=c.trustAsHtml(""):void 0},i=!1,window.document.addEventListener("click",function(){return d.calendarShown&&!i&&(d.toggleCalendar(!1),d.$apply()),i=!1}),angular.element(e[0])[0].addEventListener("click",function(){return i=!0}),p=function(){var a;return a=g.$modelValue?o(g.$modelValue):null,t(),s(a),d.mainButtonStr=a?b("date")(a,d.labelFormat):d.placeholder,d.invalid=g.$invalid},s=function(a){return null!=a?(d.inputDate=b("date")(a,d.dateFormat),d.inputTime=b("date")(a,d.timeFormat)):(d.inputDate=null,d.inputTime=null)},q=function(a){var b;return null==a&&(a=null),b=null!=a?new Date(a):new Date,"Invalid Date"===b.toString()&&(b=new Date),b.setDate(1),d.calendarDate=new Date(b)},t=function(){var a,b,c,e,f,h,i,k,l,n,o,p,q,r;for(h=d.calendarDate.getDay(),e=m(d.calendarDate.getFullYear(),d.calendarDate.getMonth()),f=Math.ceil((h+e)/7),o=[],a=new Date(d.calendarDate),a.setDate(a.getDate()+-1*h),i=p=0,r=f-1;r>=0?r>=p:p>=r;i=r>=0?++p:--p)for(o.push([]),c=q=0;6>=q;c=++q)b=new Date(a),d.defaultTime&&(l=d.defaultTime.split(":"),b.setHours(l[0]||0),b.setMinutes(l[1]||0),b.setSeconds(l[2]||0)),k=g.$modelValue&&b&&j(b,g.$modelValue),n=j(b,new Date),o[i].push({date:b,selected:k,disabled:"function"==typeof d.dateFilter?!d.dateFilter(b):!1,other:b.getMonth()!==d.calendarDate.getMonth(),today:n}),a.setDate(a.getDate()+1);return d.weeks=o},g.$parsers.push(function(a){return d.required&&null==a?(g.$setValidity("required",!1),null):angular.isDate(a)?(g.$setValidity("required",!0),a):angular.isString(a)?(g.$setValidity("required",!0),d.parseDateFunction(a)):null}),g.$formatters.push(function(a){return angular.isDate(a)?a:angular.isString(a)?d.parseDateFunction(a):void 0}),h=function(a,c){return b("date")(a,c)},u=function(a){return"string"==typeof a?o(a):a},o=a.parseDateFunction,j=function(a,b,c){return null==c&&(c=!1),c?a-b===0:(a=u(a),b=u(b),a&&b&&a.getYear()===b.getYear()&&a.getMonth()===b.getMonth()&&a.getDate()===b.getDate())},k=function(a,b){return a&&b?parseInt(a.getTime()/6e4)===parseInt(b.getTime()/6e4):!1},m=function(a,b){return[31,a%4===0&&a%100!==0||a%400===0?29:28,31,30,31,30,31,31,30,31,30,31][b]},l=function(a,b){var c,d,e,f,g,h;return g=c=d=h=f=null,e=function(){var a;return a=+new Date-h,g=b>a&&a>0?setTimeout(e,b-a):null},function(){return d=this,c=arguments,h=+new Date,g||(g=setTimeout(e,b),f=a.apply(d,c),d=c=null),f}},g.$render=function(){return q(g.$viewValue),p()},g.$viewChangeListeners.unshift(function(){return q(g.$viewValue),p(),d.onChange?d.onChange():void 0}),d.$watch("calendarShown",function(a){var b;return a?(b=angular.element(e[0].querySelector(".quickdate-date-input"))[0],b.select()):void 0}),d.toggleCalendar=l(function(a){return d.calendarShown=isFinite(a)?a:!d.calendarShown},150),d.selectDate=function(a,b){var c;return null==b&&(b=!0),c=!g.$viewValue&&a||g.$viewValue&&!a||a&&g.$viewValue&&a.getTime()!==g.$viewValue.getTime(),"function"!=typeof d.dateFilter||d.dateFilter(a)?(g.$setViewValue(a),b&&d.toggleCalendar(!1),!0):!1},d.selectDateFromInput=function(a){var b,c,e,f;null==a&&(a=!1);try{if(c=o(d.inputDate),!c)throw"Invalid Date";if(!d.disableTimepicker&&d.inputTime&&d.inputTime.length&&c){if(f=d.disableTimepicker?"00:00:00":d.inputTime,e=o(""+d.inputDate+" "+f),!e)throw"Invalid Time";c=e}if(!k(g.$viewValue,c)&&!d.selectDate(c,!1))throw"Invalid Date";return a&&d.toggleCalendar(!1),d.inputDateErr=!1,d.inputTimeErr=!1}catch(h){if(b=h,"Invalid Date"===b)return d.inputDateErr=!0;if("Invalid Time"===b)return d.inputTimeErr=!0}},d.onDateInputTab=function(){return d.disableTimepicker&&d.toggleCalendar(!1),!0},d.onTimeInputTab=function(){return d.toggleCalendar(!1),!0},d.nextMonth=function(){return q(new Date(new Date(d.calendarDate).setMonth(d.calendarDate.getMonth()+1))),p()},d.prevMonth=function(){return q(new Date(new Date(d.calendarDate).setMonth(d.calendarDate.getMonth()-1))),p()},d.clear=function(){return d.selectDate(null,!0)},n()},template:""}}]),a.directive("ngEnter",function(){return function(a,b,c){return b.bind("keydown keypress",function(b){return 13===b.which?(a.$apply(c.ngEnter),b.preventDefault()):void 0})}}),a.directive("onTab",function(){return{restrict:"A",link:function(a,b,c){return b.bind("keydown keypress",function(b){return 9!==b.which||b.shiftKey?void 0:a.$apply(c.onTab)})}}})}).call(this);
\ No newline at end of file
+(function(){var a;a=angular.module("ngQuickDate",[]),a.provider("ngQuickDateDefaults",function(){return{options:{dateFormat:"M/d/yyyy",timeFormat:"h:mm a",labelFormat:null,placeholder:"Click to Set Date",hoverText:null,buttonIconHtml:null,closeButtonHtml:"×",nextLinkHtml:"Next →",prevLinkHtml:"← Prev",disableTimepicker:!1,disableClearButton:!1,defaultTime:null,dayAbbreviations:["Su","M","Tu","W","Th","F","Sa"],dateFilter:null,hideWeekends:!1,parseDateFunction:function(a){var b;return b=Date.parse(a),isNaN(b)?null:new Date(b)}},$get:function(){return this.options},set:function(a,b){var c,d,e;if("object"==typeof a){e=[];for(c in a)d=a[c],e.push(this.options[c]=d);return e}return this.options[a]=b}}}),a.directive("quickDatepicker",["ngQuickDateDefaults","$filter","$sce",function(a,b,c){return{restrict:"E",require:"?ngModel",scope:{dateFilter:"=?",onChange:"&",required:"@"},replace:!0,link:function(d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u;return n=function(){var a;return r(),d.toggleCalendar(!1),d.weeks=[],d.inputDate=null,d.inputTime=null,d.invalid=!0,"string"==typeof f.initValue&&g.$setViewValue(f.initValue),d.defaultTime||(a=new Date(2013,0,1,12,0),d.datePlaceholder=b("date")(a,d.dateFormat),d.timePlaceholder=b("date")(a,d.timeFormat)),q(),p()},r=function(){var b,e;for(b in a)e=a[b],b.match(/[Hh]tml/)?d[b]=c.trustAsHtml(a[b]||""):!d[b]&&f[b]?d[b]=f[b]:d[b]||(d[b]=a[b]);return d.labelFormat||(d.labelFormat=d.dateFormat,d.disableTimepicker||(d.labelFormat+=" "+d.timeFormat)),f.iconClass&&f.iconClass.length?d.buttonIconHtml=c.trustAsHtml(""):void 0},i=!1,window.document.addEventListener("click",function(){return d.calendarShown&&!i&&(d.toggleCalendar(!1),d.$apply()),i=!1}),angular.element(e[0])[0].addEventListener("click",function(){return i=!0}),p=function(){var a;return a=g.$modelValue?o(g.$modelValue):null,t(),s(a),d.mainButtonStr=a?b("date")(a,d.labelFormat):d.placeholder,d.invalid=g.$invalid},s=function(a){return null!=a?(d.inputDate=b("date")(a,d.dateFormat),d.inputTime=b("date")(a,d.timeFormat)):(d.inputDate=null,d.inputTime=null)},q=function(a){var b;return null==a&&(a=null),b=null!=a?new Date(a):new Date,"Invalid Date"===b.toString()&&(b=new Date),b.setDate(1),d.calendarDate=new Date(b)},t=function(){var a,b,c,e,f,h,i,k,l,n,o,p,q,r;for(h=d.calendarDate.getDay(),e=m(d.calendarDate.getFullYear(),d.calendarDate.getMonth()),f=Math.ceil((h+e)/7),o=[],a=new Date(d.calendarDate),a.setDate(a.getDate()+-1*h),i=p=0,r=f-1;r>=0?r>=p:p>=r;i=r>=0?++p:--p)for(o.push([]),c=q=0;6>=q;c=++q)b=new Date(a),d.defaultTime&&(l=d.defaultTime.split(":"),b.setHours(l[0]||0),b.setMinutes(l[1]||0),b.setSeconds(l[2]||0)),k=g.$modelValue&&b&&j(b,g.$modelValue),n=j(b,new Date),o[i].push({date:b,selected:k,disabled:"function"==typeof d.dateFilter?!d.dateFilter(b):!1,other:b.getMonth()!==d.calendarDate.getMonth(),today:n}),a.setDate(a.getDate()+1);return d.weeks=o},g.$parsers.push(function(a){return d.required&&null==a?(g.$setValidity("required",!1),null):angular.isDate(a)?(g.$setValidity("required",!0),a):angular.isString(a)?(g.$setValidity("required",!0),d.parseDateFunction(a)):null}),g.$formatters.push(function(a){return angular.isDate(a)?a:angular.isString(a)?d.parseDateFunction(a):void 0}),h=function(a,c){return b("date")(a,c)},u=function(a){return"string"==typeof a?o(a):a},o=a.parseDateFunction,j=function(a,b,c){return null==c&&(c=!1),c?a-b===0:(a=u(a),b=u(b),a&&b&&a.getYear()===b.getYear()&&a.getMonth()===b.getMonth()&&a.getDate()===b.getDate())},k=function(a,b){return a&&b?parseInt(a.getTime()/6e4)===parseInt(b.getTime()/6e4):!1},m=function(a,b){return[31,a%4===0&&a%100!==0||a%400===0?29:28,31,30,31,30,31,31,30,31,30,31][b]},l=function(a,b){var c,d,e,f,g,h;return g=c=d=h=f=null,e=function(){var a;return a=+new Date-h,g=b>a&&a>0?setTimeout(e,b-a):null},function(){return d=this,c=arguments,h=+new Date,g||(g=setTimeout(e,b),f=a.apply(d,c),d=c=null),f}},g.$render=function(){return q(g.$viewValue),p()},g.$viewChangeListeners.unshift(function(){return q(g.$viewValue),p(),d.onChange?d.onChange():void 0}),d.$watch("calendarShown",function(a){var b;return a?(b=angular.element(e[0].querySelector(".quickdate-date-input"))[0],b.select()):void 0}),d.toggleCalendar=l(function(a){return d.calendarShown=isFinite(a)?a:!d.calendarShown},150),d.selectDate=function(a,b){var c;return null==b&&(b=!0),c=!g.$viewValue&&a||g.$viewValue&&!a||a&&g.$viewValue&&a.getTime()!==g.$viewValue.getTime(),"function"==typeof d.dateFilter&&!d.dateFilter(a)||d.hideWeekends===!0&&(0===a.getDay()||6===a.getDay())?!1:(g.$setViewValue(a),b&&d.toggleCalendar(!1),!0)},d.selectDateFromInput=function(a){var b,c,e,f;null==a&&(a=!1);try{if(c=o(d.inputDate),!c)throw"Invalid Date";if(!d.disableTimepicker&&d.inputTime&&d.inputTime.length&&c){if(f=d.disableTimepicker?"00:00:00":d.inputTime,e=o(""+d.inputDate+" "+f),!e)throw"Invalid Time";c=e}if(!k(g.$viewValue,c)&&!d.selectDate(c,!1))throw"Invalid Date";return a&&d.toggleCalendar(!1),d.inputDateErr=!1,d.inputTimeErr=!1}catch(h){if(b=h,"Invalid Date"===b)return d.inputDateErr=!0;if("Invalid Time"===b)return d.inputTimeErr=!0}},d.onDateInputTab=function(){return d.disableTimepicker&&d.toggleCalendar(!1),!0},d.onTimeInputTab=function(){return d.toggleCalendar(!1),!0},d.nextMonth=function(){return q(new Date(new Date(d.calendarDate).setMonth(d.calendarDate.getMonth()+1))),p()},d.prevMonth=function(){return q(new Date(new Date(d.calendarDate).setMonth(d.calendarDate.getMonth()-1))),p()},d.clear=function(){return d.selectDate(null,!0)},n()},template:""}}]),a.directive("ngEnter",function(){return function(a,b,c){return b.bind("keydown keypress",function(b){return 13===b.which?(a.$apply(c.ngEnter),b.preventDefault()):void 0})}}),a.directive("onTab",function(){return{restrict:"A",link:function(a,b,c){return b.bind("keydown keypress",function(b){return 9!==b.which||b.shiftKey?void 0:a.$apply(c.onTab)})}}})}).call(this);
\ No newline at end of file
diff --git a/spec/configuration-specs.coffee b/spec/configuration-specs.coffee
index 4f9c320..67c9301 100644
--- a/spec/configuration-specs.coffee
+++ b/spec/configuration-specs.coffee
@@ -122,6 +122,17 @@ describe "ngQuickDate", ->
it 'shows the timepicker input', ->
expect($(element).find('.quickdate-input-wrapper:last').hasClass('ng-hide')).toNotEqual(true)
+ describe 'Given that it is configured to hide weekends', ->
+ beforeEach(module('ngQuickDate', (ngQuickDateDefaultsProvider) ->
+ ngQuickDateDefaultsProvider.set('hideWeekends', true)
+ null
+ ))
+ describe 'and given a basic datepicker', ->
+ beforeEach(angular.mock.inject(($compile, $rootScope) ->
+ element = buildBasicDatepicker($compile, $rootScope, new Date(Date.parse('11/1/2013 3:59 pm')))
+ ))
+ it 'does not show the first table column nor the last table column', ->
+ expect($(element).find('table.quickdate-calendar').hasClass('hide-weekends')).toEqual(true)
describe 'Given that it is configured with a custom date/time parser function that always returns July 1, 2013', ->
beforeEach(module('ngQuickDate', (ngQuickDateDefaultsProvider) ->
diff --git a/src/ng-quick-date.coffee b/src/ng-quick-date.coffee
index 952da85..75c56a1 100644
--- a/src/ng-quick-date.coffee
+++ b/src/ng-quick-date.coffee
@@ -27,6 +27,7 @@ app.provider "ngQuickDateDefaults", ->
defaultTime: null
dayAbbreviations: ["Su", "M", "Tu", "W", "Th", "F", "Sa"],
dateFilter: null
+ hideWeekends: false
parseDateFunction: (str) ->
seconds = Date.parse(str)
if isNaN(seconds)
@@ -285,7 +286,7 @@ app.directive "quickDatepicker", ['ngQuickDateDefaults', '$filter', '$sce', (ngQ
# * The clear button is clicked
scope.selectDate = (date, closeCalendar=true) ->
changed = (!ngModelCtrl.$viewValue && date) || (ngModelCtrl.$viewValue && !date) || ((date && ngModelCtrl.$viewValue) && (date.getTime() != ngModelCtrl.$viewValue.getTime()))
- if typeof(scope.dateFilter) == 'function' && !scope.dateFilter(date)
+ if typeof(scope.dateFilter) == 'function' && !scope.dateFilter(date) || (scope.hideWeekends == true && (date.getDay() == 0 || date.getDay() == 6))
return false
ngModelCtrl.$setViewValue(date)
if closeCalendar
@@ -368,7 +369,7 @@ app.directive "quickDatepicker", ['ngQuickDateDefaults', '$filter', '$sce', (ngQ
{{calendarDate | date:'MMMM yyyy'}}
-
+
{{day}} |
diff --git a/src/ng-quick-date.less b/src/ng-quick-date.less
index d19e0f0..855ccf1 100644
--- a/src/ng-quick-date.less
+++ b/src/ng-quick-date.less
@@ -77,6 +77,14 @@ input.quickdate-date-input, input.quickdate-time-input {
}
table.quickdate-calendar {
+ &.hide-weekends {
+ th, tbody td {
+ &:first-child, &:last-child {
+ display: none;
+ }
+ }
+ }
+
border-collapse: collapse;
border-spacing: 0;
width: 100%;