From 4f8ae3534fb18549a1f1e98778a8c6c35c01aef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Salvador?= Date: Fri, 29 May 2015 10:49:01 +0200 Subject: [PATCH 1/2] Added class 'pickadate-another-month' --- dist/angular-pickadate.js | 1 + dist/angular-pickadate.min.js | 2 +- src/angular-pickadate.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/angular-pickadate.js b/dist/angular-pickadate.js index eecc832..46ebca2 100755 --- a/dist/angular-pickadate.js +++ b/dist/angular-pickadate.js @@ -297,6 +297,7 @@ classNames.push('pickadate-enabled'); } + if (dateObj.getMonth() !== initialDate.getMonth()) classNames.push('pickadate-another-month'); if (isDisabled) classNames.push('pickadate-unavailable'); if (date === today) classNames.push('pickadate-today'); diff --git a/dist/angular-pickadate.min.js b/dist/angular-pickadate.min.js index 198a707..0d23306 100755 --- a/dist/angular-pickadate.min.js +++ b/dist/angular-pickadate.min.js @@ -1 +1 @@ -!function(e){"use strict";function t(e,t){for(var a=t.parentNode;null!==a;){if(a===e)return!0;a=a.parentNode}return!1}var a=[].indexOf||function(e){for(var t=0,a=this.length;a>t;t++)if(t in this&&this[t]===e)return t;return-1};e.module("pickadate",[]).provider("pickadateI18n",function(){var e={prev:"prev",next:"next"};this.translations={},this.$get=function(){var t=this.translations;return{t:function(a){return t[a]||e[a]}}}}).factory("pickadateUtils",["$locale",function(t){function a(e){switch(e){case"dd":return"day";case"MM":return"month";case"yyyy":return"year"}}return{parseDate:function(t,n){if(t){if(e.isDate(t))return new Date(t);n=n||"yyyy-MM-dd";var i="(dd|MM|yyyy)",r=n.match(/[-|/]/)[0],s=t.split(r),c=new RegExp([i,i,i].join(r)),l=n.match(c),o={};if(l.shift(),e.forEach(l,function(e,t){o[a(e)]=parseInt(s[t],10)}),!(isNaN(o.year)||isNaN(o.month)||isNaN(o.day)))return new Date(o.year,o.month-1,o.day,3)}},buildDates:function(e,t){var a=[],n=new Date(e.getFullYear(),e.getMonth()+1,0,3);for(t=t||{},e=new Date(e);e.getDay()!==t.weekStartsOn;)e.setDate(e.getDate()-1);for(var i=0;42>i&&!(t.noExtraRows&&e.getDay()===t.weekStartsOn&&e>n);i++)a.push(new Date(e)),e.setDate(e.getDate()+1);return a},buildDayNames:function(e){var a=t.DATETIME_FORMATS.SHORTDAY;if(e){a=a.slice(0);for(var n=0;e>n;n++)a.push(a.shift())}return a}}}]).directive("pickadate",["$locale","$sce","$compile","$document","$window","pickadateUtils","pickadateI18n","dateFilter",function(n,i,r,s,c,l,o,d){var u='
  • {{dayName}}
  • {{d.dateObj | date:"d"}}
';return{require:"ngModel",scope:{defaultDate:"=",minDate:"=",maxDate:"=",disabledDates:"=",weekStartsOn:"="},link:function(n,i,o,p){function f(){var e=new Date(n.currentDate.getFullYear(),n.currentDate.getMonth(),1,3),t=e.getMonth()+1,a=l.buildDates(e,{weekStartsOn:$,noExtraRows:m}),i=[],r=d(new Date,O),s=new Date(e);s.setMonth(t),n.allowPrevMonth=!w||e>w,n.allowNextMonth=!k||k>=s,n.dayNames=l.buildDayNames($);for(var c=0;ce||e>k||d(e,"M")!==d(n.currentDate,"M")}function D(e){return a.call(n.disabledDates||[],e)>=0}function g(e,t){var n=a.call(t,e);return-1===n?t.push(e):t.splice(n,1),t}var w,k,m=o.hasOwnProperty("noExtraRows"),M=o.hasOwnProperty("multiple"),$=n.weekStartsOn,b=[],N=i[0]instanceof HTMLInputElement,x=r(u)(n),O=(o.format||"yyyy-MM-dd").replace(/m/g,"M");n.displayPicker=!N,(!e.isNumber($)||0>$||$>6)&&($=0),n.setDate=function(e){v(e.dateObj)||D(e.date)||(b=M?g(e.date,b):[e.date],h(b),n.displayPicker=!N)};var R=p.$render=function(t){t=t||{},e.isArray(p.$viewValue)?b=p.$viewValue:p.$viewValue&&(b=[p.$viewValue]),n.currentDate=l.parseDate(n.defaultDate,O)||l.parseDate(b[0],O)||new Date,b=y(b),h(b,t),f()};if(n.classesFor=function(e){var t=a.call(b,e.date)>=0?"pickadate-active":null;return e.classNames.concat(t)},n.changeMonth=function(e){n.currentDate.setDate(1),n.currentDate.setMonth(n.currentDate.getMonth()+e),f()},n.$watch(function(){return e.toJson([n.minDate,n.maxDate,n.disabledDates])},function(){w=l.parseDate(n.minDate,O)||new Date(0),k=l.parseDate(n.maxDate,O)||new Date(99999999999999),R()}),N){var E=function(e){n.displayPicker=e,n.$apply()};i.on("focus",function(){var e=void 0!==c.pageXOffset,t="CSS1Compat"===(s.compatMode||""),a=e?c.pageXOffset:t?s.documentElement.scrollLeft:s.body.scrollLeft,r=e?c.pageYOffset:t?s.documentElement.scrollTop:s.body.scrollTop,l=c.innerWidth||s.documentElement.clientWidth||s.body.clientWidth;n.styles={top:r+i[0].getBoundingClientRect().bottom+"px"},l-i[0].getBoundingClientRect().left>=300?n.styles.left=a+i[0].getBoundingClientRect().left+"px":n.styles.right=l-i[0].getBoundingClientRect().right-a+"px",E(!0)}),i.on("keydown",function(e){a.call([9,13,27],e.keyCode)>=0&&E(!1)}),n.$watch(function(){return p.$viewValue},function(e){var t=l.parseDate(e,O);t&&R({skipRenderInput:!0}),p.$setValidity("date",!!t)}),s.on("click",function(e){t(x[0],e.target)||e.target===i[0]||E(!1)}),n.$$postDigest(function(){o.value&&(p.$viewValue=o.value,R())}),i.after(x.addClass("pickadate-modal"))}else i.append(x)}}}])}(window.angular); \ No newline at end of file +!function(e){"use strict";function t(e,t){for(var a=t.parentNode;null!==a;){if(a===e)return!0;a=a.parentNode}return!1}var a=[].indexOf||function(e){for(var t=0,a=this.length;a>t;t++)if(t in this&&this[t]===e)return t;return-1};e.module("pickadate",[]).provider("pickadateI18n",function(){var e={prev:"prev",next:"next"};this.translations={},this.$get=function(){var t=this.translations;return{t:function(a){return t[a]||e[a]}}}}).factory("pickadateUtils",["$locale",function(t){function a(e){switch(e){case"dd":return"day";case"MM":return"month";case"yyyy":return"year"}}return{parseDate:function(t,n){if(t){if(e.isDate(t))return new Date(t);n=n||"yyyy-MM-dd";var i="(dd|MM|yyyy)",r=n.match(/[-|/]/)[0],s=t.split(r),c=new RegExp([i,i,i].join(r)),l=n.match(c),o={};if(l.shift(),e.forEach(l,function(e,t){o[a(e)]=parseInt(s[t],10)}),!(isNaN(o.year)||isNaN(o.month)||isNaN(o.day)))return new Date(o.year,o.month-1,o.day,3)}},buildDates:function(e,t){var a=[],n=new Date(e.getFullYear(),e.getMonth()+1,0,3);for(t=t||{},e=new Date(e);e.getDay()!==t.weekStartsOn;)e.setDate(e.getDate()-1);for(var i=0;42>i&&!(t.noExtraRows&&e.getDay()===t.weekStartsOn&&e>n);i++)a.push(new Date(e)),e.setDate(e.getDate()+1);return a},buildDayNames:function(e){var a=t.DATETIME_FORMATS.SHORTDAY;if(e){a=a.slice(0);for(var n=0;e>n;n++)a.push(a.shift())}return a}}}]).directive("pickadate",["$locale","$sce","$compile","$document","$window","pickadateUtils","pickadateI18n","dateFilter",function(n,i,r,s,c,l,o,d){var u='
  • {{dayName}}
  • {{d.dateObj | date:"d"}}
';return{require:"ngModel",scope:{defaultDate:"=",minDate:"=",maxDate:"=",disabledDates:"=",weekStartsOn:"="},link:function(n,i,o,p){function f(){var e=new Date(n.currentDate.getFullYear(),n.currentDate.getMonth(),1,3),t=e.getMonth()+1,a=l.buildDates(e,{weekStartsOn:$,noExtraRows:m}),i=[],r=d(new Date,O),s=new Date(e);s.setMonth(t),n.allowPrevMonth=!w||e>w,n.allowNextMonth=!k||k>=s,n.dayNames=l.buildDayNames($);for(var c=0;ce||e>k||d(e,"M")!==d(n.currentDate,"M")}function D(e){return a.call(n.disabledDates||[],e)>=0}function g(e,t){var n=a.call(t,e);return-1===n?t.push(e):t.splice(n,1),t}var w,k,m=o.hasOwnProperty("noExtraRows"),M=o.hasOwnProperty("multiple"),$=n.weekStartsOn,b=[],N=i[0]instanceof HTMLInputElement,x=r(u)(n),O=(o.format||"yyyy-MM-dd").replace(/m/g,"M");n.displayPicker=!N,(!e.isNumber($)||0>$||$>6)&&($=0),n.setDate=function(e){v(e.dateObj)||D(e.date)||(b=M?g(e.date,b):[e.date],h(b),n.displayPicker=!N)};var R=p.$render=function(t){t=t||{},e.isArray(p.$viewValue)?b=p.$viewValue:p.$viewValue&&(b=[p.$viewValue]),n.currentDate=l.parseDate(n.defaultDate,O)||l.parseDate(b[0],O)||new Date,b=y(b),h(b,t),f()};if(n.classesFor=function(e){var t=a.call(b,e.date)>=0?"pickadate-active":null;return e.classNames.concat(t)},n.changeMonth=function(e){n.currentDate.setDate(1),n.currentDate.setMonth(n.currentDate.getMonth()+e),f()},n.$watch(function(){return e.toJson([n.minDate,n.maxDate,n.disabledDates])},function(){w=l.parseDate(n.minDate,O)||new Date(0),k=l.parseDate(n.maxDate,O)||new Date(99999999999999),R()}),N){var E=function(e){n.displayPicker=e,n.$apply()};i.on("focus",function(){var e=void 0!==c.pageXOffset,t="CSS1Compat"===(s.compatMode||""),a=e?c.pageXOffset:t?s.documentElement.scrollLeft:s.body.scrollLeft,r=e?c.pageYOffset:t?s.documentElement.scrollTop:s.body.scrollTop,l=c.innerWidth||s.documentElement.clientWidth||s.body.clientWidth;n.styles={top:r+i[0].getBoundingClientRect().bottom+"px"},l-i[0].getBoundingClientRect().left>=300?n.styles.left=a+i[0].getBoundingClientRect().left+"px":n.styles.right=l-i[0].getBoundingClientRect().right-a+"px",E(!0)}),i.on("keydown",function(e){a.call([9,13,27],e.keyCode)>=0&&E(!1)}),n.$watch(function(){return p.$viewValue},function(e){var t=l.parseDate(e,O);t&&R({skipRenderInput:!0}),p.$setValidity("date",!!t)}),s.on("click",function(e){t(x[0],e.target)||e.target===i[0]||E(!1)}),n.$$postDigest(function(){o.value&&(p.$viewValue=o.value,R())}),i.after(x.addClass("pickadate-modal"))}else i.append(x)}}}])}(window.angular); \ No newline at end of file diff --git a/src/angular-pickadate.js b/src/angular-pickadate.js index eecc832..46ebca2 100755 --- a/src/angular-pickadate.js +++ b/src/angular-pickadate.js @@ -297,6 +297,7 @@ classNames.push('pickadate-enabled'); } + if (dateObj.getMonth() !== initialDate.getMonth()) classNames.push('pickadate-another-month'); if (isDisabled) classNames.push('pickadate-unavailable'); if (date === today) classNames.push('pickadate-today'); From ded0611abfc13e4088a7b56dc76c370215cae177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Salvador?= Date: Tue, 2 Jun 2015 12:25:13 +0200 Subject: [PATCH 2/2] added .pickadate-another-month to the scss like a demo --- dist/angular-pickadate.css | 2 ++ src/angular-pickadate.scss | 3 +++ 2 files changed, 5 insertions(+) diff --git a/dist/angular-pickadate.css b/dist/angular-pickadate.css index f54b8b9..48c25d0 100644 --- a/dist/angular-pickadate.css +++ b/dist/angular-pickadate.css @@ -38,6 +38,8 @@ color: #DCDCDC; } .pickadate-cell .pickadate-disabled a { color: #DCDCDC; } + .pickadate-cell .pickadate-another-month { + color: #EEEEEE; } .pickadate-cell .pickadate-enabled { cursor: pointer; font-size: 12px; diff --git a/src/angular-pickadate.scss b/src/angular-pickadate.scss index 1880d5a..96e5134 100644 --- a/src/angular-pickadate.scss +++ b/src/angular-pickadate.scss @@ -49,6 +49,9 @@ color: #DCDCDC; } } + .pickadate-another-month { + color: #EEEEEE; + } .pickadate-enabled { cursor: pointer; font-size: 12px;