diff --git a/app/scripts/dateRange.js b/app/scripts/dateRange.js index 6e58874..d2cf927 100644 --- a/app/scripts/dateRange.js +++ b/app/scripts/dateRange.js @@ -73,7 +73,7 @@ Module.directive('dateRange', ['$compile', 'datePickerUtils', 'dateTimeConfig', attrs.onSetDate = 'dateChange'; - var template = '
' + + var template = '
' + getTemplate(attrs, pickerIDs[0], 'start', false, scope.end) + '' + getTemplate(attrs, pickerIDs[1], 'end', scope.start, false) + diff --git a/app/styles/style.less b/app/styles/style.less index cde64da..0127b96 100644 --- a/app/styles/style.less +++ b/app/styles/style.less @@ -1,6 +1,14 @@ @import "variables.less"; @import "mixins.less"; +.date-picker-date-time { + position: absolute; +} + +.date-range .date-picker-date-time { + position: inherit; +} + [date-picker-wrapper] { position: absolute; min-width: 220px; diff --git a/bower.json b/bower.json index 9b6577e..24c5733 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "angular-datepicker", "license": "MIT", - "version": "2.0.2", + "version": "2.0.3", "main": [ "./dist/angular-datepicker.js", "./dist/angular-datepicker.css" diff --git a/dist/angular-datepicker.css b/dist/angular-datepicker.css index b31d905..02f2a52 100644 --- a/dist/angular-datepicker.css +++ b/dist/angular-datepicker.css @@ -25,6 +25,12 @@ -moz-box-sizing: border-box; box-sizing: border-box; } +.date-picker-date-time { + position: absolute; +} +.date-range .date-picker-date-time { + position: inherit; +} [date-picker-wrapper] { position: absolute; min-width: 220px; diff --git a/dist/angular-datepicker.js b/dist/angular-datepicker.js index cfd5238..879ca2e 100644 --- a/dist/angular-datepicker.js +++ b/dist/angular-datepicker.js @@ -645,7 +645,7 @@ Module.directive('dateRange', ['$compile', 'datePickerUtils', 'dateTimeConfig', attrs.onSetDate = 'dateChange'; - var template = '
' + + var template = '
' + getTemplate(attrs, pickerIDs[0], 'start', false, scope.end) + '' + getTemplate(attrs, pickerIDs[1], 'end', scope.start, false) + diff --git a/dist/angular-datepicker.min.css b/dist/angular-datepicker.min.css index b515d6b..3abd9bd 100644 --- a/dist/angular-datepicker.min.css +++ b/dist/angular-datepicker.min.css @@ -1 +1 @@ -.clearfix:after,.clearfix:before{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}[date-picker],[date-picker] td,[date-picker] th{-webkit-border-radius:4px;-moz-border-radius:4px}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[date-picker-wrapper]{position:absolute;min-width:220px;z-index:10;display:block;font-size:14px}[date-time-append] [date-picker-wrapper] [date-picker]{margin-top:-30px}[date-time-append] [date-picker]{position:relative;margin-right:-1000px;margin-bottom:-1000px}[date-range] [date-picker] .after.before{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#499dcd;background-image:-moz-linear-gradient(top,#5bc0de,#2f6ab4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f6ab4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f6ab4);background-image:-o-linear-gradient(top,#5bc0de,#2f6ab4);background-image:linear-gradient(to bottom,#5bc0de,#2f6ab4);background-repeat:repeat-x;border-color:#2f6ab4 #2f6ab4 #1f4677;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}[date-range] [date-picker] .after.before.active,[date-range] [date-picker] .after.before.disabled,[date-range] [date-picker] .after.before:active,[date-range] [date-picker] .after.before:hover,[date-range] [date-picker] .after.before[disabled]{color:#fff;background-color:#2f6ab4}[date-range] [date-picker] .after.before.active,[date-range] [date-picker] .after.before:active{background-color:#24528c\9}[date-picker].hidden{display:none}[date-picker]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;border-radius:4px;background-color:#fff;padding:4px}[date-picker] table{margin:0}[date-picker] td,[date-picker] th{padding:4px 5px;text-align:center;width:20px;height:20px;border-radius:4px;border:none}[date-picker] .switch{width:145px}[date-picker] span{display:block;width:23%;height:26px;line-height:25px;float:left;margin:1%;cursor:pointer;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}[date-picker] span:hover{background:#eee}[date-picker] span.disabled,[date-picker] span.disabled:hover{background:0 0;color:#999;cursor:default}[date-picker] .active,[date-picker] .now{text-shadow:0 -1px 0 rgba(0,0,0,.25);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);color:#fff}[date-picker] .active.active,[date-picker] .active.disabled,[date-picker] .active:active,[date-picker] .active:hover,[date-picker] .active[disabled],[date-picker] .now.active,[date-picker] .now.disabled,[date-picker] .now:active,[date-picker] .now:hover,[date-picker] .now[disabled]{color:#fff;background-color:#04c}[date-picker] .active.active,[date-picker] .active:active,[date-picker] .now.active,[date-picker] .now:active{background-color:#039\9}[date-picker] .now{color:#fff;background-color:#ee735b;background-image:-moz-linear-gradient(top,#ee5f5b,#ee905b);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#ee905b));background-image:-webkit-linear-gradient(top,#ee5f5b,#ee905b);background-image:-o-linear-gradient(top,#ee5f5b,#ee905b);background-image:linear-gradient(to bottom,#ee5f5b,#ee905b);border-color:#ee905b #ee905b #e56218;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25)}[date-picker] .now.active,[date-picker] .now.disabled,[date-picker] .now:active,[date-picker] .now:hover,[date-picker] .now[disabled]{color:#fff;background-color:#ee905b}[date-picker] .now.active,[date-picker] .now:active{background-color:#e9712d\9}[date-picker] .disabled{background:0 0;color:#999!important;cursor:default}[date-picker] [ng-switch-when=year] span,[date-picker] [ng-switch-when=month] span,[date-picker] [ng-switch-when=minutes] span{height:54px;line-height:54px}[date-picker] [ng-switch-when=date] td{padding:0}[date-picker] [ng-switch-when=date] span{width:100%;height:26px;line-height:26px}[date-picker] [ng-switch-when=date] td span:hover,[date-picker] th:hover{background:#eee;cursor:pointer} \ No newline at end of file +.clearfix:after,.clearfix:before{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}[date-picker],[date-picker] td,[date-picker] th{-webkit-border-radius:4px;-moz-border-radius:4px}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.date-picker-date-time{position:absolute}.date-range .date-picker-date-time{position:inherit}[date-picker-wrapper]{position:absolute;min-width:220px;z-index:10;display:block;font-size:14px}[date-time-append] [date-picker-wrapper] [date-picker]{margin-top:-30px}[date-time-append] [date-picker]{position:relative;margin-right:-1000px;margin-bottom:-1000px}[date-range] [date-picker] .after.before{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#499dcd;background-image:-moz-linear-gradient(top,#5bc0de,#2f6ab4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f6ab4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f6ab4);background-image:-o-linear-gradient(top,#5bc0de,#2f6ab4);background-image:linear-gradient(to bottom,#5bc0de,#2f6ab4);background-repeat:repeat-x;border-color:#2f6ab4 #2f6ab4 #1f4677;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}[date-range] [date-picker] .after.before.active,[date-range] [date-picker] .after.before.disabled,[date-range] [date-picker] .after.before:active,[date-range] [date-picker] .after.before:hover,[date-range] [date-picker] .after.before[disabled]{color:#fff;background-color:#2f6ab4}[date-range] [date-picker] .after.before.active,[date-range] [date-picker] .after.before:active{background-color:#24528c\9}[date-picker].hidden{display:none}[date-picker]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;border-radius:4px;background-color:#fff;padding:4px}[date-picker] table{margin:0}[date-picker] td,[date-picker] th{padding:4px 5px;text-align:center;width:20px;height:20px;border-radius:4px;border:none}[date-picker] .switch{width:145px}[date-picker] span{display:block;width:23%;height:26px;line-height:25px;float:left;margin:1%;cursor:pointer;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}[date-picker] span:hover{background:#eee}[date-picker] span.disabled,[date-picker] span.disabled:hover{background:0 0;color:#999;cursor:default}[date-picker] .active,[date-picker] .now{text-shadow:0 -1px 0 rgba(0,0,0,.25);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);color:#fff}[date-picker] .active.active,[date-picker] .active.disabled,[date-picker] .active:active,[date-picker] .active:hover,[date-picker] .active[disabled],[date-picker] .now.active,[date-picker] .now.disabled,[date-picker] .now:active,[date-picker] .now:hover,[date-picker] .now[disabled]{color:#fff;background-color:#04c}[date-picker] .active.active,[date-picker] .active:active,[date-picker] .now.active,[date-picker] .now:active{background-color:#039\9}[date-picker] .now{color:#fff;background-color:#ee735b;background-image:-moz-linear-gradient(top,#ee5f5b,#ee905b);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#ee905b));background-image:-webkit-linear-gradient(top,#ee5f5b,#ee905b);background-image:-o-linear-gradient(top,#ee5f5b,#ee905b);background-image:linear-gradient(to bottom,#ee5f5b,#ee905b);border-color:#ee905b #ee905b #e56218;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25)}[date-picker] .now.active,[date-picker] .now.disabled,[date-picker] .now:active,[date-picker] .now:hover,[date-picker] .now[disabled]{color:#fff;background-color:#ee905b}[date-picker] .now.active,[date-picker] .now:active{background-color:#e9712d\9}[date-picker] .disabled{background:0 0;color:#999!important;cursor:default}[date-picker] [ng-switch-when=year] span,[date-picker] [ng-switch-when=month] span,[date-picker] [ng-switch-when=minutes] span{height:54px;line-height:54px}[date-picker] [ng-switch-when=date] td{padding:0}[date-picker] [ng-switch-when=date] span{width:100%;height:26px;line-height:26px}[date-picker] [ng-switch-when=date] td span:hover,[date-picker] th:hover{background:#eee;cursor:pointer} \ No newline at end of file diff --git a/dist/angular-datepicker.min.js b/dist/angular-datepicker.min.js index d88478f..bb7f43d 100644 --- a/dist/angular-datepicker.min.js +++ b/dist/angular-datepicker.min.js @@ -1 +1 @@ -"use strict";!function(a){var b=a.module("datePicker",[]);b.constant("datePickerConfig",{template:"templates/datepicker.html",view:"month",views:["year","month","date","hours","minutes"],momentNames:{year:"year",month:"month",date:"day",hours:"hours",minutes:"minutes"},viewConfig:{year:["years","isSameYear"],month:["months","isSameMonth"],hours:["hours","isSameHour"],minutes:["minutes","isSameMinutes"]},step:5}),b.filter("mFormat",function(){return function(a,b,c){return moment.isMoment(a)?c?moment.tz(a,c).format(b):a.format(b):moment(a).format(b)}}),b.directive("datePicker",["datePickerConfig","datePickerUtils",function(b,c){return{require:"?ngModel",template:'
',scope:{model:"=datePicker",after:"=?",before:"=?"},link:function(d,e,f,g){function h(){d.views=b.views.concat(),d.view=f.view||b.view,d.views=d.views.slice(d.views.indexOf(f.maxView||"year"),d.views.indexOf(f.minView||"minutes")+1),(1===d.views.length||-1===d.views.indexOf(d.view))&&(d.view=d.views[0])}function i(a){return c.getDate(d,f,a)}function j(a){a&&(d.model=a,g&&g.$setViewValue(a)),d.$emit("setDate",d.model,d.view),d.callbackOnSetDate&&d.callbackOnSetDate(f.datePicker,d.date)}function k(){var a=d.view;c.setParams(s),d.model&&!r&&(d.date=t(d.model),r=!1);var b=d.date;switch(a){case"year":d.years=c.getVisibleYears(b);break;case"month":d.months=c.getVisibleMonths(b);break;case"date":d.weekdays=d.weekdays||c.getDaysOfWeek(),d.weeks=c.getVisibleWeeks(b);break;case"hours":d.hours=c.getVisibleHours(b);break;case"minutes":d.minutes=c.getVisibleMinutes(b,v)}m()}function l(){return"date"!==d.view?d.view:d.date?d.date.month():null}function m(){var a,e,f=d.view,g=d.date,h=[],i="";if(c.setParams(s),"date"===f){var j,k=d.weeks;for(a=0;ae;e+=b)d=c(f,g,h,i-j,e),k.push(d);return k},getVisibleWeeks:function(a){a=moment(a);var b=a.year(),c=a.month();a.date(1);var d=a.day();0===d?a.date(-6):a.date(1-d);for(var e=[];e.length<6&&!(a.year()===b&&a.month()>c);)e.push(this.getDaysOfWeek(a)),a.add(7,"d");return e},getVisibleYears:function(a){var b=moment(a),d=b.year();b.year(d-d%10),d=b.year();for(var e,f,g=b.utcOffset()/60,h=[],i=0;12>i;i++)e=c(d,0,1,0-g),f=e.utcOffset()/60,f!==g&&(e=c(d,0,1,0-f),g=f),h.push(e),d++;return h},getDaysOfWeek:function(a){a=a?a:b?moment.tz(b).day(0):moment().day(0);for(var d,e,f=a.year(),g=a.month(),h=a.date(),i=[],j=a.utcOffset()/60,k=0;7>k;k++)d=c(f,g,h,0-j,0,!1),e=d.utcOffset()/60,e!==j&&(d=c(f,g,h,0-e,0,!1)),i.push(d),h++;return i},getVisibleMonths:function(a){for(var b,d,e=a.year(),f=a.utcOffset()/60,g=[],h=0;12>h;h++)b=c(e,h,1,0-f,0,!1),d=b.utcOffset()/60,d!==f&&(b=c(e,h,1,0-d,0,!1)),g.push(b);return g},getVisibleHours:function(a){var b,d,e,f=a.year(),g=a.month(),h=a.date(),i=[],j=a.utcOffset()/60;for(b=0;24>b;b++)d=c(f,g,h,b-j,0,!1),e=d.utcOffset()/60,e!==j&&(d=c(f,g,h,b-e,0,!1)),i.push(d);return i},isAfter:function(a,b){return a&&a.unix()>=b.unix()},isBefore:function(a,b){return a.unix()<=b.unix()},isSameYear:function(a,b){return a&&a.year()===b.year()},isSameMonth:function(a,b){return this.isSameYear(a,b)&&a.month()===b.month()},isSameDay:function(a,b){return this.isSameMonth(a,b)&&a.date()===b.date()},isSameHour:function(a,b){return this.isSameDay(a,b)&&a.hours()===b.hours()},isSameMinutes:function(a,b){return this.isSameHour(a,b)&&a.minutes()===b.minutes()},setParams:function(a){b=a},findFunction:function(b,c){var d=b;do if(d=d.$parent,a.isFunction(d[c]))return d[c];while(d.$parent);return!1},findParam:function(a,b){var c=a;do if(c=c.$parent,c[b])return c[b];while(c.$parent);return!1},createMoment:function(a){return b?moment.tz(a,b):moment.isMoment(a)?moment.unix(a.unix()):moment(a)},getDate:function(a,b,c){var d=!1;return b[c]&&(d=this.createMoment(b[c]),d.isValid()||(d=this.findParam(a,b[c]),d&&(d=this.createMoment(d)))),d},eventIsForPicker:function(b,c){return a.isArray(b)&&b.indexOf(c)>-1||b===c}}});var b=a.module("datePicker");b.directive("dateRange",["$compile","datePickerUtils","dateTimeConfig",function(b,c,d){function e(b,c,e,f,g){return d.template(a.extend(b,{ngModel:e,minDate:f&&moment.isMoment(f)?f.format():!1,maxDate:g&&moment.isMoment(g)?g.format():!1}),c)}function f(){return"picker"+Math.random().toString().substr(2)}return{scope:{start:"=",end:"="},link:function(d,g,h){function i(a){d.$broadcast("pickerUpdate",m[0],{maxDate:a})}function j(a){d.$broadcast("pickerUpdate",m[1],{minDate:a})}var k=null,l=g[0].id,m=[f(),f()],n=c.createMoment,o=c.eventIsForPicker;d.dateChange=function(a,b){k&&k(a,b)},l&&d.$on("pickerUpdate",function(a,b,c){o(b,l)&&d.$broadcast("pickerUpdate",m,c)}),c.setParams(h.timezone),d.start=n(d.start),d.end=n(d.end),d.$watchGroup(["start","end"],function(a){j(a[0]),i(a[1])}),a.isDefined(h.dateChange)&&(k=c.findFunction(d,h.dateChange)),h.onSetDate="dateChange";var p='
'+e(h,m[0],"start",!1,d.end)+''+e(h,m[1],"end",d.start,!1)+"
",q=b(p)(d);g.append(q)}}}]);var c="ng-pristine",d="ng-dirty",b=a.module("datePicker");b.constant("dateTimeConfig",{template:function(a,b){return"
'},format:"YYYY-MM-DD HH:mm",views:["date","year","month","hours","minutes"],autoClose:!1,position:"relative"}),b.directive("dateTimeAppend",function(){return{link:function(a,b){b.bind("click",function(){b.find("input")[0].focus()})}}}),b.directive("dateTime",["$compile","$document","$filter","dateTimeConfig","$parse","datePickerUtils",function(b,e,f,g,h,i){var j=e.find("body"),k=f("mFormat");return{require:"ngModel",scope:!0,link:function(e,f,l,m){function n(a){return k(a,w,K)}function o(a){return a.length===w.length?a:void 0}function p(a){G=a,l.minDate=a?a.format():a,H=moment.isMoment(a)}function q(a){I=a,l.maxDate=a?a.format():a,J=moment.isMoment(a)}function r(){v=g.template(l)}function s(a){a.stopPropagation(),m.$pristine&&(m.$dirty=!0,m.$pristine=!1,f.removeClass(c).addClass(d),x&&x.$setDirty(),m.$render())}function t(){C&&(C.remove(),C=null),F&&(F.remove(),F=null)}function u(){if(!C){if(C=b(v)(e),e.$digest(),N||(e.$on("setDate",function(a,b,c){s(a),M&&M(l.ngModel,b),B&&y[y.length-1]===c&&t()}),e.$on("hidePicker",function(){f.triggerHandler("blur")}),e.$on("$destroy",t),N=!0),"absolute"===E){var c=a.extend(f.offset(),{height:f[0].offsetHeight});C.css({top:c.top+c.height,left:c.left,display:"block",position:E}),j.append(C)}else F=a.element("
"),f[0].parentElement.insertBefore(F[0],f[0]),F.append(C),C.css({top:f[0].offsetHeight+"px",display:"block"});C.bind("mousedown",function(a){a.preventDefault()})}}var v,w=l.format||g.format,x=f.inheritedData("$formController"),y=h(l.views)(e)||g.views.concat(),z=l.view||y[0],A=y.indexOf(z),B=l.autoClose?h(l.autoClose)(e):g.autoClose,C=null,D=f[0].id,E=l.position||g.position,F=null,G=null,H=null,I=null,J=null,K=l.timezone||!1,L=i.eventIsForPicker,M=null,N=!1;-1===A&&y.splice(A,1),y.unshift(z),m.$formatters.push(n),m.$parsers.unshift(o),a.isDefined(l.minDate)&&(p(i.findParam(e,l.minDate)),m.$validators.min=function(a){return H?moment.isMoment(a)&&(G.isSame(a)||G.isBefore(a)):!0}),a.isDefined(l.maxDate)&&(q(i.findParam(e,l.maxDate)),m.$validators.max=function(a){return J?moment.isMoment(a)&&(I.isSame(a)||I.isAfter(a)):!0}),a.isDefined(l.dateChange)&&(M=i.findFunction(e,l.dateChange)),D&&e.$on("pickerUpdate",function(b,c,d){if(L(c,D))if(C);else{var e=!1;a.isDefined(d.minDate)&&(p(d.minDate),e=!0),a.isDefined(d.maxDate)&&(q(d.maxDate),e=!0),a.isDefined(d.minView)&&(l.minView=d.minView),a.isDefined(d.maxView)&&(l.maxView=d.maxView),l.view=d.view||l.view,e&&m.$validate(),a.isDefined(d.format)&&(w=l.format=d.format||g.format,m.$modelValue=-1),r()}}),f.bind("focus",u),f.bind("blur",t),r()}}}]),a.module("datePicker").run(["$templateCache",function(a){a.put("templates/datepicker.html",'
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
')}])}(angular); \ No newline at end of file +"use strict";!function(a){var b=a.module("datePicker",[]);b.constant("datePickerConfig",{template:"templates/datepicker.html",view:"month",views:["year","month","date","hours","minutes"],momentNames:{year:"year",month:"month",date:"day",hours:"hours",minutes:"minutes"},viewConfig:{year:["years","isSameYear"],month:["months","isSameMonth"],hours:["hours","isSameHour"],minutes:["minutes","isSameMinutes"]},step:5}),b.filter("mFormat",function(){return function(a,b,c){return moment.isMoment(a)?c?moment.tz(a,c).format(b):a.format(b):moment(a).format(b)}}),b.directive("datePicker",["datePickerConfig","datePickerUtils",function(b,c){return{require:"?ngModel",template:'
',scope:{model:"=datePicker",after:"=?",before:"=?"},link:function(d,e,f,g){function h(){d.views=b.views.concat(),d.view=f.view||b.view,d.views=d.views.slice(d.views.indexOf(f.maxView||"year"),d.views.indexOf(f.minView||"minutes")+1),(1===d.views.length||-1===d.views.indexOf(d.view))&&(d.view=d.views[0])}function i(a){return c.getDate(d,f,a)}function j(a){a&&(d.model=a,g&&g.$setViewValue(a)),d.$emit("setDate",d.model,d.view),d.callbackOnSetDate&&d.callbackOnSetDate(f.datePicker,d.date)}function k(){var a=d.view;c.setParams(s),d.model&&!r&&(d.date=t(d.model),r=!1);var b=d.date;switch(a){case"year":d.years=c.getVisibleYears(b);break;case"month":d.months=c.getVisibleMonths(b);break;case"date":d.weekdays=d.weekdays||c.getDaysOfWeek(),d.weeks=c.getVisibleWeeks(b);break;case"hours":d.hours=c.getVisibleHours(b);break;case"minutes":d.minutes=c.getVisibleMinutes(b,v)}m()}function l(){return"date"!==d.view?d.view:d.date?d.date.month():null}function m(){var a,e,f=d.view,g=d.date,h=[],i="";if(c.setParams(s),"date"===f){var j,k=d.weeks;for(a=0;ae;e+=b)d=c(f,g,h,i-j,e),k.push(d);return k},getVisibleWeeks:function(a){a=moment(a);var b=a.year(),c=a.month();a.date(1);var d=a.day();0===d?a.date(-6):a.date(1-d);for(var e=[];e.length<6&&!(a.year()===b&&a.month()>c);)e.push(this.getDaysOfWeek(a)),a.add(7,"d");return e},getVisibleYears:function(a){var b=moment(a),d=b.year();b.year(d-d%10),d=b.year();for(var e,f,g=b.utcOffset()/60,h=[],i=0;12>i;i++)e=c(d,0,1,0-g),f=e.utcOffset()/60,f!==g&&(e=c(d,0,1,0-f),g=f),h.push(e),d++;return h},getDaysOfWeek:function(a){a=a?a:b?moment.tz(b).day(0):moment().day(0);for(var d,e,f=a.year(),g=a.month(),h=a.date(),i=[],j=a.utcOffset()/60,k=0;7>k;k++)d=c(f,g,h,0-j,0,!1),e=d.utcOffset()/60,e!==j&&(d=c(f,g,h,0-e,0,!1)),i.push(d),h++;return i},getVisibleMonths:function(a){for(var b,d,e=a.year(),f=a.utcOffset()/60,g=[],h=0;12>h;h++)b=c(e,h,1,0-f,0,!1),d=b.utcOffset()/60,d!==f&&(b=c(e,h,1,0-d,0,!1)),g.push(b);return g},getVisibleHours:function(a){var b,d,e,f=a.year(),g=a.month(),h=a.date(),i=[],j=a.utcOffset()/60;for(b=0;24>b;b++)d=c(f,g,h,b-j,0,!1),e=d.utcOffset()/60,e!==j&&(d=c(f,g,h,b-e,0,!1)),i.push(d);return i},isAfter:function(a,b){return a&&a.unix()>=b.unix()},isBefore:function(a,b){return a.unix()<=b.unix()},isSameYear:function(a,b){return a&&a.year()===b.year()},isSameMonth:function(a,b){return this.isSameYear(a,b)&&a.month()===b.month()},isSameDay:function(a,b){return this.isSameMonth(a,b)&&a.date()===b.date()},isSameHour:function(a,b){return this.isSameDay(a,b)&&a.hours()===b.hours()},isSameMinutes:function(a,b){return this.isSameHour(a,b)&&a.minutes()===b.minutes()},setParams:function(a){b=a},findFunction:function(b,c){var d=b;do if(d=d.$parent,a.isFunction(d[c]))return d[c];while(d.$parent);return!1},findParam:function(a,b){var c=a;do if(c=c.$parent,c[b])return c[b];while(c.$parent);return!1},createMoment:function(a){return b?moment.tz(a,b):moment.isMoment(a)?moment.unix(a.unix()):moment(a)},getDate:function(a,b,c){var d=!1;return b[c]&&(d=this.createMoment(b[c]),d.isValid()||(d=this.findParam(a,b[c]),d&&(d=this.createMoment(d)))),d},eventIsForPicker:function(b,c){return a.isArray(b)&&b.indexOf(c)>-1||b===c}}});var b=a.module("datePicker");b.directive("dateRange",["$compile","datePickerUtils","dateTimeConfig",function(b,c,d){function e(b,c,e,f,g){return d.template(a.extend(b,{ngModel:e,minDate:f&&moment.isMoment(f)?f.format():!1,maxDate:g&&moment.isMoment(g)?g.format():!1}),c)}function f(){return"picker"+Math.random().toString().substr(2)}return{scope:{start:"=",end:"="},link:function(d,g,h){function i(a){d.$broadcast("pickerUpdate",m[0],{maxDate:a})}function j(a){d.$broadcast("pickerUpdate",m[1],{minDate:a})}var k=null,l=g[0].id,m=[f(),f()],n=c.createMoment,o=c.eventIsForPicker;d.dateChange=function(a,b){k&&k(a,b)},l&&d.$on("pickerUpdate",function(a,b,c){o(b,l)&&d.$broadcast("pickerUpdate",m,c)}),c.setParams(h.timezone),d.start=n(d.start),d.end=n(d.end),d.$watchGroup(["start","end"],function(a){j(a[0]),i(a[1])}),a.isDefined(h.dateChange)&&(k=c.findFunction(d,h.dateChange)),h.onSetDate="dateChange";var p='
'+e(h,m[0],"start",!1,d.end)+''+e(h,m[1],"end",d.start,!1)+"
",q=b(p)(d);g.append(q)}}}]);var c="ng-pristine",d="ng-dirty",b=a.module("datePicker");b.constant("dateTimeConfig",{template:function(a,b){return"
'},format:"YYYY-MM-DD HH:mm",views:["date","year","month","hours","minutes"],autoClose:!1,position:"relative"}),b.directive("dateTimeAppend",function(){return{link:function(a,b){b.bind("click",function(){b.find("input")[0].focus()})}}}),b.directive("dateTime",["$compile","$document","$filter","dateTimeConfig","$parse","datePickerUtils",function(b,e,f,g,h,i){var j=e.find("body"),k=f("mFormat");return{require:"ngModel",scope:!0,link:function(e,f,l,m){function n(a){return k(a,w,K)}function o(a){return a.length===w.length?a:void 0}function p(a){G=a,l.minDate=a?a.format():a,H=moment.isMoment(a)}function q(a){I=a,l.maxDate=a?a.format():a,J=moment.isMoment(a)}function r(){v=g.template(l)}function s(a){a.stopPropagation(),m.$pristine&&(m.$dirty=!0,m.$pristine=!1,f.removeClass(c).addClass(d),x&&x.$setDirty(),m.$render())}function t(){C&&(C.remove(),C=null),F&&(F.remove(),F=null)}function u(){if(!C){if(C=b(v)(e),e.$digest(),N||(e.$on("setDate",function(a,b,c){s(a),M&&M(l.ngModel,b),B&&y[y.length-1]===c&&t()}),e.$on("hidePicker",function(){f.triggerHandler("blur")}),e.$on("$destroy",t),N=!0),"absolute"===E){var c=a.extend(f.offset(),{height:f[0].offsetHeight});C.css({top:c.top+c.height,left:c.left,display:"block",position:E}),j.append(C)}else F=a.element("
"),f[0].parentElement.insertBefore(F[0],f[0]),F.append(C),C.css({top:f[0].offsetHeight+"px",display:"block"});C.bind("mousedown",function(a){a.preventDefault()})}}var v,w=l.format||g.format,x=f.inheritedData("$formController"),y=h(l.views)(e)||g.views.concat(),z=l.view||y[0],A=y.indexOf(z),B=l.autoClose?h(l.autoClose)(e):g.autoClose,C=null,D=f[0].id,E=l.position||g.position,F=null,G=null,H=null,I=null,J=null,K=l.timezone||!1,L=i.eventIsForPicker,M=null,N=!1;-1===A&&y.splice(A,1),y.unshift(z),m.$formatters.push(n),m.$parsers.unshift(o),a.isDefined(l.minDate)&&(p(i.findParam(e,l.minDate)),m.$validators.min=function(a){return H?moment.isMoment(a)&&(G.isSame(a)||G.isBefore(a)):!0}),a.isDefined(l.maxDate)&&(q(i.findParam(e,l.maxDate)),m.$validators.max=function(a){return J?moment.isMoment(a)&&(I.isSame(a)||I.isAfter(a)):!0}),a.isDefined(l.dateChange)&&(M=i.findFunction(e,l.dateChange)),D&&e.$on("pickerUpdate",function(b,c,d){if(L(c,D))if(C);else{var e=!1;a.isDefined(d.minDate)&&(p(d.minDate),e=!0),a.isDefined(d.maxDate)&&(q(d.maxDate),e=!0),a.isDefined(d.minView)&&(l.minView=d.minView),a.isDefined(d.maxView)&&(l.maxView=d.maxView),l.view=d.view||l.view,e&&m.$validate(),a.isDefined(d.format)&&(w=l.format=d.format||g.format,m.$modelValue=-1),r()}}),f.bind("focus",u),f.bind("blur",t),r()}}}]),a.module("datePicker").run(["$templateCache",function(a){a.put("templates/datepicker.html",'
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
')}])}(angular); \ No newline at end of file diff --git a/package.json b/package.json index 8c62340..7a9bb56 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datepicker", - "version": "2.0.2", + "version": "2.0.3", "main": "dist/angular-datepicker.js", "repository": { "url": "https://github.com/g00fy-/angular-datepicker.git"