diff --git a/app/index.html b/app/index.html
index c334249..a5a907a 100644
--- a/app/index.html
+++ b/app/index.html
@@ -20,59 +20,73 @@
Calendar
default views
year
+
month
+
date
+
hours
+
minutes
+
-
min views
year
+
month
+
date
+
hours
+
minutes
+
-
-
+
+
max views
year
+
month
+
date
+
hours
+
maxutes
+
@@ -80,9 +94,11 @@ maxutes
max & min views
time
+
date
+
@@ -94,8 +110,7 @@ date
-
Date range
- <div date-range start="start" end="end" ></div>
+
Date range button
@@ -146,9 +160,8 @@ Date range button
-
-
-
+
+
diff --git a/app/scripts/datePicker.js b/app/scripts/datePicker.js
index b1e26ec..ed7393e 100644
--- a/app/scripts/datePicker.js
+++ b/app/scripts/datePicker.js
@@ -123,7 +123,7 @@ Module.directive('datePicker', function datePickerDirective(datePickerConfig) {
scope.views.indexOf(attrs.minView || 'minutes')+1
);
- if (scope.views.length === 1 || scope.views.indexOf(scope.view)==-1) {
+ if (scope.views.length === 1 || scope.views.indexOf(scope.view)===-1) {
scope.view = scope.views[0];
}
diff --git a/dist/index.js b/dist/index.js
index 71b75db..279fc8c 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -118,20 +118,14 @@ Module.directive('datePicker', function datePickerDirective(datePickerConfig) {
scope.template = attrs.template || datePickerConfig.template;
var step = parseInt(attrs.step || datePickerConfig.step, 10);
- var index;
- /** @namespace attrs.minView */
- if (attrs.minView) {
- index = scope.views.indexOf(attrs.minView);
- scope.views.splice(0, index);
- }
- /** @namespace attrs.maxView */
- if (attrs.maxView) {
- index = scope.views.indexOf(attrs.maxView);
- scope.views.splice(index + 1);
- }
+ /** @namespace attrs.minView, attrs.maxView */
+ scope.views =scope.views.slice(
+ scope.views.indexOf(attrs.maxView || 'year'),
+ scope.views.indexOf(attrs.minView || 'minutes')+1
+ );
- if (scope.views.length === 1) {
+ if (scope.views.length === 1 || scope.views.indexOf(scope.view)===-1) {
scope.view = scope.views[0];
}
@@ -340,7 +334,7 @@ Module.directive('dateTimeAppend', function () {
return {
link: function (scope, element) {
element.bind('click', function () {
- element.find('input').focus();
+ element.find('input')[0].focus();
});
}
};
diff --git a/dist/index.min.js b/dist/index.min.js
index 73aad58..793ff54 100644
--- a/dist/index.min.js
+++ b/dist/index.min.js
@@ -1 +1 @@
-"use strict";!function(a){function b(a,b){a=new Date(a||new Date),a=new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours());for(var c=[],d=a.getTime()+36e5;a.getTime()d;d++)c.push(new Date(a)),a.setDate(a.getDate()+1);b.push(c)}return b}function d(a){var b=[];a=new Date(a||new Date),a.setFullYear(a.getFullYear()-a.getFullYear()%10);for(var c=0;12>c;c++)b.push(new Date(a.getFullYear()+(c-1),0,1));return b}function e(a){a=new Date(a||new Date),a=new Date(a.getFullYear(),a.getMonth(),a.getDate()),a.setDate(a.getDate()-(a.getDay()-1));for(var b=[],c=0;7>c;c++)b.push(new Date(a)),a.setDate(a.getDate()+1);return b}function f(a){a=new Date(a||new Date);for(var b=a.getFullYear(),c=[],d=0;12>d;d++)c.push(new Date(b,d,1));return c}function g(a){a=new Date(a||new Date),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0);for(var b=[],c=0;24>c;c++)b.push(a),a=new Date(a.getTime()+36e5);return b}var h=a.module("datePicker",[]);h.constant("datePickerConfig",{template:"templates/datepicker.html",view:"month",views:["year","month","date","hours","minutes"],step:5}),h.directive("datePicker",["datePickerConfig",function(a){return{template:'',scope:{model:"=datePicker",after:"=?",before:"=?"},link:function(h,i,j){function k(){var a=h.view,i=h.date;switch(a){case"year":h.years=d(i);break;case"month":h.months=f(i);break;case"date":h.weekdays=h.weekdays||e(),h.weeks=c(i);break;case"hours":h.hours=g(i);break;case"minutes":h.minutes=b(i,n)}}function l(){return"date"!==h.view?h.view:h.model?h.model.getMonth():null}h.date=new Date(h.model||new Date),h.views=a.views.concat(),h.view=j.view||a.view,h.now=new Date,h.template=j.template||a.template;var m,n=parseInt(j.step||a.step,10);j.minView&&(m=h.views.indexOf(j.minView),h.views.splice(0,m)),j.maxView&&(m=h.views.indexOf(j.maxView),h.views.splice(m+1)),1===h.views.length&&(h.view=h.views[0]),h.setView=function(a){-1!==h.views.indexOf(a)&&(h.view=a)},h.setDate=function(a){h.date=a;var b=h.views[h.views.indexOf(h.view)+1];if(!b||h.model){switch(h.model=new Date(h.model||a),h.view){case"minutes":h.model.setMinutes(a.getMinutes());case"hours":h.model.setHours(a.getHours());case"date":h.model.setDate(a.getDate());case"month":h.model.setMonth(a.getMonth());case"year":h.model.setFullYear(a.getFullYear())}h.$emit("setDate",h.model,h.view)}b&&h.setView(b)},h.$watch(l,k),h.next=function(a){var b=h.date;switch(a=a||1,h.view){case"year":case"month":b.setFullYear(b.getFullYear()+a);break;case"date":b.setMonth(b.getMonth()+a);break;case"hours":case"minutes":b.setHours(b.getHours()+a)}k()},h.prev=function(a){return h.next(-a||-1)},h.isAfter=function(a){return h.after?h.after.getTime()<=a.getTime():!1},h.isBefore=function(a){return h.before?h.before.getTime()>=a.getTime():!1},h.isSameMonth=function(a){return h.isSameYear(a)&&h.model.getMonth()===a.getMonth()},h.isSameYear=function(a){return h.model?h.model.getFullYear()===a.getFullYear():!1},h.isSameDay=function(a){return h.isSameMonth(a)&&h.model.getDate()===a.getDate()},h.isSameHour=function(a){return h.isSameDay(a)&&h.model.getHours()===a.getHours()},h.isSameMinutes=function(a){return h.isSameHour(a)&&h.model.getMinutes()===a.getMinutes()},h.isNow=function(a){var b=!0,c=h.now;switch(h.view){case"minutes":b&=~~(a.getMinutes()/n)===~~(c.getMinutes()/n);case"hours":b&=a.getHours()===c.getHours();case"date":b&=a.getDate()===c.getDate();case"month":b&=a.getMonth()===c.getMonth();case"year":b&=a.getFullYear()===c.getFullYear()}return b}}}}]);var h=a.module("datePicker");h.directive("dateRange",function(){return{templateUrl:"templates/daterange.html",scope:{start:"=",end:"="},link:function(a){a.$watch("start.getTime()",function(b){b&&a.end&&b>a.end.getTime()&&(a.end=new Date(b))}),a.$watch("end.getTime()",function(b){b&&a.start&&b'},format:"yyyy-MM-dd HH:mm",views:["date","year","month","hours","minutes","month"],dismiss:!1,position:"relative"}),h.directive("dateTimeAppend",function(){return{link:function(a,b){b.bind("click",function(){b.find("input").focus()})}}}),h.directive("dateTime",["$compile","$document","$filter","dateTimeConfig","$parse",function(b,c,d,e,f){var g=c.find("body"),h=d("date");return{require:"ngModel",scope:!0,link:function(c,d,k,l){function m(a){return h(a,r)}function n(){return l.$modelValue}function o(a){a.stopPropagation(),l.$pristine&&(l.$dirty=!0,l.$pristine=!1,d.removeClass(i).addClass(j),s&&s.$setDirty(),l.$render())}function p(){x&&(x.remove(),x=null),z&&(z.remove(),z=null)}function q(){if(!x){if(x=b(A)(c),c.$digest(),c.$on("setDate",function(a){o(a),w&&p()}),c.$on("$destroy",p),"absolute"===y){var e=a.extend(d.offset(),{height:d[0].offsetHeight});x.css({top:e.top+e.height,left:e.left,display:"block",position:y}),g.append(x)}else z=a.element(""),d[0].parentElement.insertBefore(z[0],d[0]),z.append(x),x.css({top:d[0].offsetHeight+"px",display:"block"});x.bind("mousedown",function(a){a.preventDefault()})}}var r=k.format||e.format,s=d.inheritedData("$formController"),t=f(k.views)(c)||e.views.concat(),u=k.view||t[0],v=t.indexOf(u),w=k.dismiss?f(k.dismiss)(c):e.dismiss,x=null,y=k.position||e.position,z=null;-1===v&&t.splice(v,1),t.unshift(u),l.$formatters.push(m),l.$parsers.unshift(n);var A=e.template(k);d.bind("focus",q),d.bind("blur",p)}}}]),a.module("datePicker").run(["$templateCache",function(a){a.put("templates/datepicker.html",'\n
\n
\n \n \n ‹ | \n {{date|date:"yyyy MMMM"}} | \n › | \n
\n \n {{ day|date:"EEE" }} | \n
\n \n \n \n \n \n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{years[0].getFullYear()}}-{{years[years.length-1].getFullYear()}} | \n › | \n
\n \n \n \n \n \n\n\n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{ date|date:"yyyy" }} | \n › | \n
\n \n \n \n \n {{month|date:\'MMM\'}}\n\n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{ date|date:"dd MMMM yyyy" }} | \n › | \n
\n \n \n \n \n \n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{ date|date:"dd MMMM yyyy" }}\n | \n › | \n
\n \n \n \n \n {{minute|date:"HH:mm"}}\n | \n
\n \n
\n
\n
\n'),a.put("templates/daterange.html",'\n
\n \n \n \n | \n \n \n | \n
\n
\n
\n')}])}(angular);
\ No newline at end of file
+"use strict";!function(a){function b(a,b){a=new Date(a||new Date),a=new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours());for(var c=[],d=a.getTime()+36e5;a.getTime()d;d++)c.push(new Date(a)),a.setDate(a.getDate()+1);b.push(c)}return b}function d(a){var b=[];a=new Date(a||new Date),a.setFullYear(a.getFullYear()-a.getFullYear()%10);for(var c=0;12>c;c++)b.push(new Date(a.getFullYear()+(c-1),0,1));return b}function e(a){a=new Date(a||new Date),a=new Date(a.getFullYear(),a.getMonth(),a.getDate()),a.setDate(a.getDate()-(a.getDay()-1));for(var b=[],c=0;7>c;c++)b.push(new Date(a)),a.setDate(a.getDate()+1);return b}function f(a){a=new Date(a||new Date);for(var b=a.getFullYear(),c=[],d=0;12>d;d++)c.push(new Date(b,d,1));return c}function g(a){a=new Date(a||new Date),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0);for(var b=[],c=0;24>c;c++)b.push(a),a=new Date(a.getTime()+36e5);return b}var h=a.module("datePicker",[]);h.constant("datePickerConfig",{template:"templates/datepicker.html",view:"month",views:["year","month","date","hours","minutes"],step:5}),h.directive("datePicker",["datePickerConfig",function(a){return{template:'',scope:{model:"=datePicker",after:"=?",before:"=?"},link:function(h,i,j){function k(){var a=h.view,i=h.date;switch(a){case"year":h.years=d(i);break;case"month":h.months=f(i);break;case"date":h.weekdays=h.weekdays||e(),h.weeks=c(i);break;case"hours":h.hours=g(i);break;case"minutes":h.minutes=b(i,m)}}function l(){return"date"!==h.view?h.view:h.model?h.model.getMonth():null}h.date=new Date(h.model||new Date),h.views=a.views.concat(),h.view=j.view||a.view,h.now=new Date,h.template=j.template||a.template;var m=parseInt(j.step||a.step,10);h.views=h.views.slice(h.views.indexOf(j.maxView||"year"),h.views.indexOf(j.minView||"minutes")+1),(1===h.views.length||-1===h.views.indexOf(h.view))&&(h.view=h.views[0]),h.setView=function(a){-1!==h.views.indexOf(a)&&(h.view=a)},h.setDate=function(a){h.date=a;var b=h.views[h.views.indexOf(h.view)+1];if(!b||h.model){switch(h.model=new Date(h.model||a),h.view){case"minutes":h.model.setMinutes(a.getMinutes());case"hours":h.model.setHours(a.getHours());case"date":h.model.setDate(a.getDate());case"month":h.model.setMonth(a.getMonth());case"year":h.model.setFullYear(a.getFullYear())}h.$emit("setDate",h.model,h.view)}b&&h.setView(b)},h.$watch(l,k),h.next=function(a){var b=h.date;switch(a=a||1,h.view){case"year":case"month":b.setFullYear(b.getFullYear()+a);break;case"date":b.setMonth(b.getMonth()+a);break;case"hours":case"minutes":b.setHours(b.getHours()+a)}k()},h.prev=function(a){return h.next(-a||-1)},h.isAfter=function(a){return h.after?h.after.getTime()<=a.getTime():!1},h.isBefore=function(a){return h.before?h.before.getTime()>=a.getTime():!1},h.isSameMonth=function(a){return h.isSameYear(a)&&h.model.getMonth()===a.getMonth()},h.isSameYear=function(a){return h.model?h.model.getFullYear()===a.getFullYear():!1},h.isSameDay=function(a){return h.isSameMonth(a)&&h.model.getDate()===a.getDate()},h.isSameHour=function(a){return h.isSameDay(a)&&h.model.getHours()===a.getHours()},h.isSameMinutes=function(a){return h.isSameHour(a)&&h.model.getMinutes()===a.getMinutes()},h.isNow=function(a){var b=!0,c=h.now;switch(h.view){case"minutes":b&=~~(a.getMinutes()/m)===~~(c.getMinutes()/m);case"hours":b&=a.getHours()===c.getHours();case"date":b&=a.getDate()===c.getDate();case"month":b&=a.getMonth()===c.getMonth();case"year":b&=a.getFullYear()===c.getFullYear()}return b}}}}]);var h=a.module("datePicker");h.directive("dateRange",function(){return{templateUrl:"templates/daterange.html",scope:{start:"=",end:"="},link:function(a){a.$watch("start.getTime()",function(b){b&&a.end&&b>a.end.getTime()&&(a.end=new Date(b))}),a.$watch("end.getTime()",function(b){b&&a.start&&b'},format:"yyyy-MM-dd HH:mm",views:["date","year","month","hours","minutes","month"],dismiss:!1,position:"relative"}),h.directive("dateTimeAppend",function(){return{link:function(a,b){b.bind("click",function(){b.find("input")[0].focus()})}}}),h.directive("dateTime",["$compile","$document","$filter","dateTimeConfig","$parse",function(b,c,d,e,f){var g=c.find("body"),h=d("date");return{require:"ngModel",scope:!0,link:function(c,d,k,l){function m(a){return h(a,r)}function n(){return l.$modelValue}function o(a){a.stopPropagation(),l.$pristine&&(l.$dirty=!0,l.$pristine=!1,d.removeClass(i).addClass(j),s&&s.$setDirty(),l.$render())}function p(){x&&(x.remove(),x=null),z&&(z.remove(),z=null)}function q(){if(!x){if(x=b(A)(c),c.$digest(),c.$on("setDate",function(a){o(a),w&&p()}),c.$on("$destroy",p),"absolute"===y){var e=a.extend(d.offset(),{height:d[0].offsetHeight});x.css({top:e.top+e.height,left:e.left,display:"block",position:y}),g.append(x)}else z=a.element(""),d[0].parentElement.insertBefore(z[0],d[0]),z.append(x),x.css({top:d[0].offsetHeight+"px",display:"block"});x.bind("mousedown",function(a){a.preventDefault()})}}var r=k.format||e.format,s=d.inheritedData("$formController"),t=f(k.views)(c)||e.views.concat(),u=k.view||t[0],v=t.indexOf(u),w=k.dismiss?f(k.dismiss)(c):e.dismiss,x=null,y=k.position||e.position,z=null;-1===v&&t.splice(v,1),t.unshift(u),l.$formatters.push(m),l.$parsers.unshift(n);var A=e.template(k);d.bind("focus",q),d.bind("blur",p)}}}]),a.module("datePicker").run(["$templateCache",function(a){a.put("templates/datepicker.html",'\n
\n
\n \n \n ‹ | \n {{date|date:"yyyy MMMM"}} | \n › | \n
\n \n {{ day|date:"EEE" }} | \n
\n \n \n \n \n \n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{years[0].getFullYear()}}-{{years[years.length-1].getFullYear()}} | \n › | \n
\n \n \n \n \n \n\n\n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{ date|date:"yyyy" }} | \n › | \n
\n \n \n \n \n {{month|date:\'MMM\'}}\n\n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{ date|date:"dd MMMM yyyy" }} | \n › | \n
\n \n \n \n \n \n | \n
\n \n
\n
\n
\n
\n \n \n ‹ | \n {{ date|date:"dd MMMM yyyy" }}\n | \n › | \n
\n \n \n \n \n {{minute|date:"HH:mm"}}\n | \n
\n \n
\n
\n
\n'),a.put("templates/daterange.html",'\n
\n \n \n \n | \n \n \n | \n
\n
\n
\n')}])}(angular);
\ No newline at end of file