From 0ea140b20e7093a5ddb7e48722c2fa35d46ffe74 Mon Sep 17 00:00:00 2001 From: emps Date: Mon, 21 Dec 2015 12:26:40 +0200 Subject: [PATCH] added $event to on-day-click second param after date --- angular-material-calendar.html | 2 +- angular-material-calendar.js | 14 +++++++------- angular-material-calendar.min.js | 2 +- dist/angular-material-calendar.html | 2 +- dist/angular-material-calendar.js | 14 +++++++------- dist/angular-material-calendar.min.js | 2 +- src/angular-material-calendar.html | 4 ++-- src/angular-material-calendar.js | 12 ++++++------ 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/angular-material-calendar.html b/angular-material-calendar.html index 52a2a89..2e471c1 100644 --- a/angular-material-calendar.html +++ b/angular-material-calendar.html @@ -1 +1 @@ -
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
\ No newline at end of file +
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
\ No newline at end of file diff --git a/angular-material-calendar.js b/angular-material-calendar.js index f7134c9..0d3a7a8 100644 --- a/angular-material-calendar.js +++ b/angular-material-calendar.js @@ -125,7 +125,7 @@ angular.module("materialCalendar").service("MaterialCalendarData", [function () angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse", "$http", "$q", "materialCalendar.Calendar", "MaterialCalendarData", function ($compile, $parse, $http, $q, Calendar, CalendarData) { - var defaultTemplate = "
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
"; + var defaultTemplate = "
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
"; var injectCss = function () { var styleId = "calendarMdCss"; @@ -220,8 +220,8 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" bootstrap(); }); - var handleCb = function (cb, data) { - (cb || angular.noop)(data); + var handleCb = function (cb, $event, data) { + (cb || angular.noop)(data, $event); }; var dateFind = function (arr, date) { @@ -254,7 +254,7 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" month: $scope.calendar.month + 1 }; setData(); - handleCb($scope.onPrevMonth, data); + handleCb($scope.onPrevMonth, null, data); }; $scope.next = function () { @@ -264,10 +264,10 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" month: $scope.calendar.month + 1 }; setData(); - handleCb($scope.onNextMonth, data); + handleCb($scope.onNextMonth, null, data); }; - $scope.handleDayClick = function (date) { + $scope.handleDayClick = function ($event, date) { if($scope.disableFutureSelection && date > new Date()) { return; @@ -294,7 +294,7 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" $parse($attrs.ngModel).assign($scope.$parent, angular.copy($scope.active)); } - handleCb($scope.onDayClick, angular.copy(date)); + handleCb($scope.onDayClick, $event, angular.copy(date)); }; diff --git a/angular-material-calendar.min.js b/angular-material-calendar.min.js index 2278401..ad3abd4 100644 --- a/angular-material-calendar.min.js +++ b/angular-material-calendar.min.js @@ -1 +1 @@ -angular.module("materialCalendar",["ngMaterial","ngSanitize"]),angular.module("materialCalendar").constant("materialCalendar.config",{version:"0.2.13",debug:document.domain.indexOf("localhost")>-1}),angular.module("materialCalendar").config(["materialCalendar.config","$logProvider","$compileProvider",function(t,a,e){t.debug&&(a.debugEnabled(!1),e.debugInfoEnabled(!1))}]),angular.module("materialCalendar").service("materialCalendar.Calendar",[function(){function t(t,a,e){var n=new Date;this.setWeekStartsOn=function(t){var a=parseInt(t||0,10);return this.weekStartsOn=!isNaN(a)&&a>=0&&6>=a?a:0,this.weekStartsOn},this.options=angular.isObject(e)?e:{},this.year=n.getFullYear(),this.month=n.getMonth(),this.weeks=[],this.weekStartsOn=this.setWeekStartsOn(this.options.weekStartsOn),this.next=function(){return this.start.getMonth()<11?void this.init(this.start.getFullYear(),this.start.getMonth()+1):void this.init(this.start.getFullYear()+1,0)},this.prev=function(){return this.month?void this.init(this.start.getFullYear(),this.start.getMonth()-1):void this.init(this.start.getFullYear()-1,11)},this.init=function(t,a){var e=new Date;this.year=angular.isDefined(t)?t:e.getFullYear(),this.month=angular.isDefined(a)?a:e.getMonth();var n=[31,28,31,30,31,30,31,31,30,31,30,31],o=n[this.month];1===this.month&&(this.year%4===0&&this.year%100!==0||this.year%400===0)&&(o=29),this.start=new Date(this.year,this.month,1);for(var r=angular.copy(this.start);r.getDay()!==this.weekStartsOn;)r.setDate(r.getDate()-1),o++;for(;o%7!==0;)o++;this.weeks=[];for(var i=0;o>i;++i)i%7===0&&this.weeks.push([]),this.weeks[this.weeks.length-1].push(angular.copy(r)),r.setDate(r.getDate()+1)},this.init(t,a)}return t}]),angular.module("materialCalendar").service("MaterialCalendarData",[function(){function t(){this.data={},this.getDayKey=function(t){return[t.getFullYear(),t.getMonth()+1,t.getDate()].join("-")},this.setDayContent=function(t,a){this.data[this.getDayKey(t)]=a||this.data[this.getDayKey(t)]||""}}return new t}]),angular.module("materialCalendar").directive("calendarMd",["$compile","$parse","$http","$q","materialCalendar.Calendar","MaterialCalendarData",function(t,a,e,n,o,r){var i="
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
",d=function(){var t="calendarMdCss";if(!document.getElementById(t)){var a=document.getElementsByTagName("head")[0],e=document.createElement("style");e.type="text/css",e.id=t,e.innerHTML="calendar-md md-content>md-content.agenda>*>* :not(:first-child),calendar-md md-content>md-content.calendar>:not(:first-child)>* :last-child{overflow:hidden;text-overflow:ellipsis}calendar-md{display:block;max-height:100%}calendar-md .md-toolbar-tools h2{overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content{border:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>*{border-bottom:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.agenda>*>* :first-child{padding:12px;width:200px;text-align:right;color:rgba(0,0,0,.75);font-weight:100;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content>*>*{min-width:48px}calendar-md md-content>md-content.calendar>:first-child{background:rgba(0,0,0,.02);border-bottom:1px solid rgba(0,0,0,.12);margin-right:0;min-height:36px}calendar-md md-content>md-content.calendar>:not(:first-child)>*{border-bottom:1px solid rgba(0,0,0,.12);border-right:1px solid rgba(0,0,0,.12);cursor:pointer}calendar-md md-content>md-content.calendar>:not(:first-child)>:hover{background:rgba(0,0,0,.04)}calendar-md md-content>md-content.calendar>:not(:first-child)>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.calendar>:not(:first-child)>.active{box-shadow:0 1px 3px 0 rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 2px 1px -1px rgba(0,0,0,.12);background:rgba(0,0,0,.02)}calendar-md md-content>md-content.calendar>:not(:first-child)>* :first-child{padding:0}",a.insertBefore(e,a.firstChild)}};return{restrict:"E",scope:{ngModel:"=?",template:"&",templateUrl:"=?",onDayClick:"=?",onPrevMonth:"=?",onNextMonth:"=?",calendarDirection:"=?",dayContent:"&?",timezone:"=?",titleFormat:"=?",dayFormat:"=?",dayLabelFormat:"=?",dayLabelTooltipFormat:"=?",dayTooltipFormat:"=?",weekStartsOn:"=?",tooltips:"&?",clearDataCacheOnLoad:"=?",disableFutureSelection:"=?"},link:function(l,c,s){d();var u=new Date,m=parseInt(s.startMonth||u.getMonth()),h=parseInt(s.startYear||u.getFullYear());l.columnWeekLayout="column",l.weekLayout="row",l.timezone=l.timezone||null,l.noCache=s.clearDataCacheOnLoad||!1,s.ngModel?(l.active=l.$parent.$eval(s.ngModel),s.ngModel&&l.$watch("$parent."+s.ngModel,function(t){l.active=t})):l.active=null,l.titleFormat=l.titleFormat||"MMMM yyyy",l.dayLabelFormat=l.dayLabelFormat||"EEE",l.dayLabelTooltipFormat=l.dayLabelTooltipFormat||"EEEE",l.dayFormat=l.dayFormat||"d",l.dayTooltipFormat=l.dayTooltipFormat||"fullDate",l.disableFutureSelection=l.disableFutureSelection||!1,l.sameMonth=function(t){var a=angular.copy(t);return a.getFullYear()===l.calendar.year&&a.getMonth()===l.calendar.month},l.isDisabled=function(t){return l.disableFutureSelection&&t>new Date?!0:!l.sameMonth(t)},l.calendarDirection=l.calendarDirection||"horizontal",l.$watch("calendarDirection",function(t){l.weekLayout="horizontal"===t?"row":"column"}),l.$watch("weekLayout",function(){h=l.calendar.year,m=l.calendar.month,k()});var g=function(t,a){(t||angular.noop)(a)},y=function(t,a){var e=-1;return angular.forEach(t,function(t,n){0>e&&angular.equals(a,t)&&(e=n)}),e};l.isActive=function(t){var a,e=angular.copy(l.active);return a=angular.isArray(e)?y(e,t)>-1:angular.equals(t,e)},l.prev=function(){l.calendar.prev();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onPrevMonth,t)},l.next=function(){l.calendar.next();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onNextMonth,t)},l.handleDayClick=function(t){if(!(l.disableFutureSelection&&t>new Date)){var e=angular.copy(l.active);if(angular.isArray(e)){var n=y(e,t);n>-1?e.splice(n,1):e.push(t)}else e=angular.equals(e,t)?null:t;l.active=e,s.ngModel&&a(s.ngModel).assign(l.$parent,angular.copy(l.active)),g(l.onDayClick,angular.copy(t))}};var v=function(a){c.html(a),t(c.contents())(l)},p=function(){l.calendar=new o(h,m,{weekStartsOn:l.weekStartsOn||0});var t=n.defer();return l.templateUrl?e.get(l.templateUrl).success(t.resolve).error(t.reject):t.resolve(l.template()||i),t.promise};l.dataService=r;var f=function(t){return l.dataService.getDayKey(t)};l.dayKey=f;var b=function(t){l.noCache?l.dataService.setDayContent(t,""):l.dataService.setDayContent(t,l.dataService.data[f(t)]||"");var a=(l.dayContent||angular.noop)(),e=(a||angular.noop)(t);angular.isObject(e)&&"function"==typeof e.success?e.success(function(a){l.dataService.setDayContent(t,a)}):angular.isObject(e)&&"function"==typeof e.then?e.then(function(a){l.dataService.setDayContent(t,a)}):l.dataService.setDayContent(t,e)},w=function(){angular.forEach(l.calendar.weeks,function(t){angular.forEach(t,b)})};window.data=l.data;var k=function(){p().then(function(t){v(t),w()})};l.$watch("weekStartsOn",p),k(),l._$$init=p,l._$$setTemplate=v,l._$$bootstrap=k}}}]); \ No newline at end of file +angular.module("materialCalendar",["ngMaterial","ngSanitize"]),angular.module("materialCalendar").constant("materialCalendar.config",{version:"0.2.13",debug:document.domain.indexOf("localhost")>-1}),angular.module("materialCalendar").config(["materialCalendar.config","$logProvider","$compileProvider",function(t,e,a){t.debug&&(e.debugEnabled(!1),a.debugInfoEnabled(!1))}]),angular.module("materialCalendar").service("materialCalendar.Calendar",[function(){function t(t,e,a){var n=new Date;this.setWeekStartsOn=function(t){var e=parseInt(t||0,10);return this.weekStartsOn=!isNaN(e)&&e>=0&&6>=e?e:0,this.weekStartsOn},this.options=angular.isObject(a)?a:{},this.year=n.getFullYear(),this.month=n.getMonth(),this.weeks=[],this.weekStartsOn=this.setWeekStartsOn(this.options.weekStartsOn),this.next=function(){return this.start.getMonth()<11?void this.init(this.start.getFullYear(),this.start.getMonth()+1):void this.init(this.start.getFullYear()+1,0)},this.prev=function(){return this.month?void this.init(this.start.getFullYear(),this.start.getMonth()-1):void this.init(this.start.getFullYear()-1,11)},this.init=function(t,e){var a=new Date;this.year=angular.isDefined(t)?t:a.getFullYear(),this.month=angular.isDefined(e)?e:a.getMonth();var n=[31,28,31,30,31,30,31,31,30,31,30,31],o=n[this.month];1===this.month&&(this.year%4===0&&this.year%100!==0||this.year%400===0)&&(o=29),this.start=new Date(this.year,this.month,1);for(var r=angular.copy(this.start);r.getDay()!==this.weekStartsOn;)r.setDate(r.getDate()-1),o++;for(;o%7!==0;)o++;this.weeks=[];for(var i=0;o>i;++i)i%7===0&&this.weeks.push([]),this.weeks[this.weeks.length-1].push(angular.copy(r)),r.setDate(r.getDate()+1)},this.init(t,e)}return t}]),angular.module("materialCalendar").service("MaterialCalendarData",[function(){function t(){this.data={},this.getDayKey=function(t){return[t.getFullYear(),t.getMonth()+1,t.getDate()].join("-")},this.setDayContent=function(t,e){this.data[this.getDayKey(t)]=e||this.data[this.getDayKey(t)]||""}}return new t}]),angular.module("materialCalendar").directive("calendarMd",["$compile","$parse","$http","$q","materialCalendar.Calendar","MaterialCalendarData",function(t,e,a,n,o,r){var i="
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
",d=function(){var t="calendarMdCss";if(!document.getElementById(t)){var e=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",a.id=t,a.innerHTML="calendar-md md-content>md-content.agenda>*>* :not(:first-child),calendar-md md-content>md-content.calendar>:not(:first-child)>* :last-child{overflow:hidden;text-overflow:ellipsis}calendar-md{display:block;max-height:100%}calendar-md .md-toolbar-tools h2{overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content{border:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>*{border-bottom:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.agenda>*>* :first-child{padding:12px;width:200px;text-align:right;color:rgba(0,0,0,.75);font-weight:100;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content>*>*{min-width:48px}calendar-md md-content>md-content.calendar>:first-child{background:rgba(0,0,0,.02);border-bottom:1px solid rgba(0,0,0,.12);margin-right:0;min-height:36px}calendar-md md-content>md-content.calendar>:not(:first-child)>*{border-bottom:1px solid rgba(0,0,0,.12);border-right:1px solid rgba(0,0,0,.12);cursor:pointer}calendar-md md-content>md-content.calendar>:not(:first-child)>:hover{background:rgba(0,0,0,.04)}calendar-md md-content>md-content.calendar>:not(:first-child)>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.calendar>:not(:first-child)>.active{box-shadow:0 1px 3px 0 rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 2px 1px -1px rgba(0,0,0,.12);background:rgba(0,0,0,.02)}calendar-md md-content>md-content.calendar>:not(:first-child)>* :first-child{padding:0}",e.insertBefore(a,e.firstChild)}};return{restrict:"E",scope:{ngModel:"=?",template:"&",templateUrl:"=?",onDayClick:"=?",onPrevMonth:"=?",onNextMonth:"=?",calendarDirection:"=?",dayContent:"&?",timezone:"=?",titleFormat:"=?",dayFormat:"=?",dayLabelFormat:"=?",dayLabelTooltipFormat:"=?",dayTooltipFormat:"=?",weekStartsOn:"=?",tooltips:"&?",clearDataCacheOnLoad:"=?",disableFutureSelection:"=?"},link:function(l,c,s){d();var u=new Date,m=parseInt(s.startMonth||u.getMonth()),h=parseInt(s.startYear||u.getFullYear());l.columnWeekLayout="column",l.weekLayout="row",l.timezone=l.timezone||null,l.noCache=s.clearDataCacheOnLoad||!1,s.ngModel?(l.active=l.$parent.$eval(s.ngModel),s.ngModel&&l.$watch("$parent."+s.ngModel,function(t){l.active=t})):l.active=null,l.titleFormat=l.titleFormat||"MMMM yyyy",l.dayLabelFormat=l.dayLabelFormat||"EEE",l.dayLabelTooltipFormat=l.dayLabelTooltipFormat||"EEEE",l.dayFormat=l.dayFormat||"d",l.dayTooltipFormat=l.dayTooltipFormat||"fullDate",l.disableFutureSelection=l.disableFutureSelection||!1,l.sameMonth=function(t){var e=angular.copy(t);return e.getFullYear()===l.calendar.year&&e.getMonth()===l.calendar.month},l.isDisabled=function(t){return l.disableFutureSelection&&t>new Date?!0:!l.sameMonth(t)},l.calendarDirection=l.calendarDirection||"horizontal",l.$watch("calendarDirection",function(t){l.weekLayout="horizontal"===t?"row":"column"}),l.$watch("weekLayout",function(){h=l.calendar.year,m=l.calendar.month,k()});var g=function(t,e,a){(t||angular.noop)(a,e)},y=function(t,e){var a=-1;return angular.forEach(t,function(t,n){0>a&&angular.equals(e,t)&&(a=n)}),a};l.isActive=function(t){var e,a=angular.copy(l.active);return e=angular.isArray(a)?y(a,t)>-1:angular.equals(t,a)},l.prev=function(){l.calendar.prev();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onPrevMonth,null,t)},l.next=function(){l.calendar.next();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onNextMonth,null,t)},l.handleDayClick=function(t,a){if(!(l.disableFutureSelection&&a>new Date)){var n=angular.copy(l.active);if(angular.isArray(n)){var o=y(n,a);o>-1?n.splice(o,1):n.push(a)}else n=angular.equals(n,a)?null:a;l.active=n,s.ngModel&&e(s.ngModel).assign(l.$parent,angular.copy(l.active)),g(l.onDayClick,t,angular.copy(a))}};var v=function(e){c.html(e),t(c.contents())(l)},p=function(){l.calendar=new o(h,m,{weekStartsOn:l.weekStartsOn||0});var t=n.defer();return l.templateUrl?a.get(l.templateUrl).success(t.resolve).error(t.reject):t.resolve(l.template()||i),t.promise};l.dataService=r;var f=function(t){return l.dataService.getDayKey(t)};l.dayKey=f;var b=function(t){l.noCache?l.dataService.setDayContent(t,""):l.dataService.setDayContent(t,l.dataService.data[f(t)]||"");var e=(l.dayContent||angular.noop)(),a=(e||angular.noop)(t);angular.isObject(a)&&"function"==typeof a.success?a.success(function(e){l.dataService.setDayContent(t,e)}):angular.isObject(a)&&"function"==typeof a.then?a.then(function(e){l.dataService.setDayContent(t,e)}):l.dataService.setDayContent(t,a)},w=function(){angular.forEach(l.calendar.weeks,function(t){angular.forEach(t,b)})};window.data=l.data;var k=function(){p().then(function(t){v(t),w()})};l.$watch("weekStartsOn",p),k(),l._$$init=p,l._$$setTemplate=v,l._$$bootstrap=k}}}]); \ No newline at end of file diff --git a/dist/angular-material-calendar.html b/dist/angular-material-calendar.html index 52a2a89..2e471c1 100644 --- a/dist/angular-material-calendar.html +++ b/dist/angular-material-calendar.html @@ -1 +1 @@ -
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
\ No newline at end of file +
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
\ No newline at end of file diff --git a/dist/angular-material-calendar.js b/dist/angular-material-calendar.js index f7134c9..0d3a7a8 100644 --- a/dist/angular-material-calendar.js +++ b/dist/angular-material-calendar.js @@ -125,7 +125,7 @@ angular.module("materialCalendar").service("MaterialCalendarData", [function () angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse", "$http", "$q", "materialCalendar.Calendar", "MaterialCalendarData", function ($compile, $parse, $http, $q, Calendar, CalendarData) { - var defaultTemplate = "
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
"; + var defaultTemplate = "
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
"; var injectCss = function () { var styleId = "calendarMdCss"; @@ -220,8 +220,8 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" bootstrap(); }); - var handleCb = function (cb, data) { - (cb || angular.noop)(data); + var handleCb = function (cb, $event, data) { + (cb || angular.noop)(data, $event); }; var dateFind = function (arr, date) { @@ -254,7 +254,7 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" month: $scope.calendar.month + 1 }; setData(); - handleCb($scope.onPrevMonth, data); + handleCb($scope.onPrevMonth, null, data); }; $scope.next = function () { @@ -264,10 +264,10 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" month: $scope.calendar.month + 1 }; setData(); - handleCb($scope.onNextMonth, data); + handleCb($scope.onNextMonth, null, data); }; - $scope.handleDayClick = function (date) { + $scope.handleDayClick = function ($event, date) { if($scope.disableFutureSelection && date > new Date()) { return; @@ -294,7 +294,7 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" $parse($attrs.ngModel).assign($scope.$parent, angular.copy($scope.active)); } - handleCb($scope.onDayClick, angular.copy(date)); + handleCb($scope.onDayClick, $event, angular.copy(date)); }; diff --git a/dist/angular-material-calendar.min.js b/dist/angular-material-calendar.min.js index 2278401..ad3abd4 100644 --- a/dist/angular-material-calendar.min.js +++ b/dist/angular-material-calendar.min.js @@ -1 +1 @@ -angular.module("materialCalendar",["ngMaterial","ngSanitize"]),angular.module("materialCalendar").constant("materialCalendar.config",{version:"0.2.13",debug:document.domain.indexOf("localhost")>-1}),angular.module("materialCalendar").config(["materialCalendar.config","$logProvider","$compileProvider",function(t,a,e){t.debug&&(a.debugEnabled(!1),e.debugInfoEnabled(!1))}]),angular.module("materialCalendar").service("materialCalendar.Calendar",[function(){function t(t,a,e){var n=new Date;this.setWeekStartsOn=function(t){var a=parseInt(t||0,10);return this.weekStartsOn=!isNaN(a)&&a>=0&&6>=a?a:0,this.weekStartsOn},this.options=angular.isObject(e)?e:{},this.year=n.getFullYear(),this.month=n.getMonth(),this.weeks=[],this.weekStartsOn=this.setWeekStartsOn(this.options.weekStartsOn),this.next=function(){return this.start.getMonth()<11?void this.init(this.start.getFullYear(),this.start.getMonth()+1):void this.init(this.start.getFullYear()+1,0)},this.prev=function(){return this.month?void this.init(this.start.getFullYear(),this.start.getMonth()-1):void this.init(this.start.getFullYear()-1,11)},this.init=function(t,a){var e=new Date;this.year=angular.isDefined(t)?t:e.getFullYear(),this.month=angular.isDefined(a)?a:e.getMonth();var n=[31,28,31,30,31,30,31,31,30,31,30,31],o=n[this.month];1===this.month&&(this.year%4===0&&this.year%100!==0||this.year%400===0)&&(o=29),this.start=new Date(this.year,this.month,1);for(var r=angular.copy(this.start);r.getDay()!==this.weekStartsOn;)r.setDate(r.getDate()-1),o++;for(;o%7!==0;)o++;this.weeks=[];for(var i=0;o>i;++i)i%7===0&&this.weeks.push([]),this.weeks[this.weeks.length-1].push(angular.copy(r)),r.setDate(r.getDate()+1)},this.init(t,a)}return t}]),angular.module("materialCalendar").service("MaterialCalendarData",[function(){function t(){this.data={},this.getDayKey=function(t){return[t.getFullYear(),t.getMonth()+1,t.getDate()].join("-")},this.setDayContent=function(t,a){this.data[this.getDayKey(t)]=a||this.data[this.getDayKey(t)]||""}}return new t}]),angular.module("materialCalendar").directive("calendarMd",["$compile","$parse","$http","$q","materialCalendar.Calendar","MaterialCalendarData",function(t,a,e,n,o,r){var i="
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
",d=function(){var t="calendarMdCss";if(!document.getElementById(t)){var a=document.getElementsByTagName("head")[0],e=document.createElement("style");e.type="text/css",e.id=t,e.innerHTML="calendar-md md-content>md-content.agenda>*>* :not(:first-child),calendar-md md-content>md-content.calendar>:not(:first-child)>* :last-child{overflow:hidden;text-overflow:ellipsis}calendar-md{display:block;max-height:100%}calendar-md .md-toolbar-tools h2{overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content{border:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>*{border-bottom:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.agenda>*>* :first-child{padding:12px;width:200px;text-align:right;color:rgba(0,0,0,.75);font-weight:100;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content>*>*{min-width:48px}calendar-md md-content>md-content.calendar>:first-child{background:rgba(0,0,0,.02);border-bottom:1px solid rgba(0,0,0,.12);margin-right:0;min-height:36px}calendar-md md-content>md-content.calendar>:not(:first-child)>*{border-bottom:1px solid rgba(0,0,0,.12);border-right:1px solid rgba(0,0,0,.12);cursor:pointer}calendar-md md-content>md-content.calendar>:not(:first-child)>:hover{background:rgba(0,0,0,.04)}calendar-md md-content>md-content.calendar>:not(:first-child)>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.calendar>:not(:first-child)>.active{box-shadow:0 1px 3px 0 rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 2px 1px -1px rgba(0,0,0,.12);background:rgba(0,0,0,.02)}calendar-md md-content>md-content.calendar>:not(:first-child)>* :first-child{padding:0}",a.insertBefore(e,a.firstChild)}};return{restrict:"E",scope:{ngModel:"=?",template:"&",templateUrl:"=?",onDayClick:"=?",onPrevMonth:"=?",onNextMonth:"=?",calendarDirection:"=?",dayContent:"&?",timezone:"=?",titleFormat:"=?",dayFormat:"=?",dayLabelFormat:"=?",dayLabelTooltipFormat:"=?",dayTooltipFormat:"=?",weekStartsOn:"=?",tooltips:"&?",clearDataCacheOnLoad:"=?",disableFutureSelection:"=?"},link:function(l,c,s){d();var u=new Date,m=parseInt(s.startMonth||u.getMonth()),h=parseInt(s.startYear||u.getFullYear());l.columnWeekLayout="column",l.weekLayout="row",l.timezone=l.timezone||null,l.noCache=s.clearDataCacheOnLoad||!1,s.ngModel?(l.active=l.$parent.$eval(s.ngModel),s.ngModel&&l.$watch("$parent."+s.ngModel,function(t){l.active=t})):l.active=null,l.titleFormat=l.titleFormat||"MMMM yyyy",l.dayLabelFormat=l.dayLabelFormat||"EEE",l.dayLabelTooltipFormat=l.dayLabelTooltipFormat||"EEEE",l.dayFormat=l.dayFormat||"d",l.dayTooltipFormat=l.dayTooltipFormat||"fullDate",l.disableFutureSelection=l.disableFutureSelection||!1,l.sameMonth=function(t){var a=angular.copy(t);return a.getFullYear()===l.calendar.year&&a.getMonth()===l.calendar.month},l.isDisabled=function(t){return l.disableFutureSelection&&t>new Date?!0:!l.sameMonth(t)},l.calendarDirection=l.calendarDirection||"horizontal",l.$watch("calendarDirection",function(t){l.weekLayout="horizontal"===t?"row":"column"}),l.$watch("weekLayout",function(){h=l.calendar.year,m=l.calendar.month,k()});var g=function(t,a){(t||angular.noop)(a)},y=function(t,a){var e=-1;return angular.forEach(t,function(t,n){0>e&&angular.equals(a,t)&&(e=n)}),e};l.isActive=function(t){var a,e=angular.copy(l.active);return a=angular.isArray(e)?y(e,t)>-1:angular.equals(t,e)},l.prev=function(){l.calendar.prev();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onPrevMonth,t)},l.next=function(){l.calendar.next();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onNextMonth,t)},l.handleDayClick=function(t){if(!(l.disableFutureSelection&&t>new Date)){var e=angular.copy(l.active);if(angular.isArray(e)){var n=y(e,t);n>-1?e.splice(n,1):e.push(t)}else e=angular.equals(e,t)?null:t;l.active=e,s.ngModel&&a(s.ngModel).assign(l.$parent,angular.copy(l.active)),g(l.onDayClick,angular.copy(t))}};var v=function(a){c.html(a),t(c.contents())(l)},p=function(){l.calendar=new o(h,m,{weekStartsOn:l.weekStartsOn||0});var t=n.defer();return l.templateUrl?e.get(l.templateUrl).success(t.resolve).error(t.reject):t.resolve(l.template()||i),t.promise};l.dataService=r;var f=function(t){return l.dataService.getDayKey(t)};l.dayKey=f;var b=function(t){l.noCache?l.dataService.setDayContent(t,""):l.dataService.setDayContent(t,l.dataService.data[f(t)]||"");var a=(l.dayContent||angular.noop)(),e=(a||angular.noop)(t);angular.isObject(e)&&"function"==typeof e.success?e.success(function(a){l.dataService.setDayContent(t,a)}):angular.isObject(e)&&"function"==typeof e.then?e.then(function(a){l.dataService.setDayContent(t,a)}):l.dataService.setDayContent(t,e)},w=function(){angular.forEach(l.calendar.weeks,function(t){angular.forEach(t,b)})};window.data=l.data;var k=function(){p().then(function(t){v(t),w()})};l.$watch("weekStartsOn",p),k(),l._$$init=p,l._$$setTemplate=v,l._$$bootstrap=k}}}]); \ No newline at end of file +angular.module("materialCalendar",["ngMaterial","ngSanitize"]),angular.module("materialCalendar").constant("materialCalendar.config",{version:"0.2.13",debug:document.domain.indexOf("localhost")>-1}),angular.module("materialCalendar").config(["materialCalendar.config","$logProvider","$compileProvider",function(t,e,a){t.debug&&(e.debugEnabled(!1),a.debugInfoEnabled(!1))}]),angular.module("materialCalendar").service("materialCalendar.Calendar",[function(){function t(t,e,a){var n=new Date;this.setWeekStartsOn=function(t){var e=parseInt(t||0,10);return this.weekStartsOn=!isNaN(e)&&e>=0&&6>=e?e:0,this.weekStartsOn},this.options=angular.isObject(a)?a:{},this.year=n.getFullYear(),this.month=n.getMonth(),this.weeks=[],this.weekStartsOn=this.setWeekStartsOn(this.options.weekStartsOn),this.next=function(){return this.start.getMonth()<11?void this.init(this.start.getFullYear(),this.start.getMonth()+1):void this.init(this.start.getFullYear()+1,0)},this.prev=function(){return this.month?void this.init(this.start.getFullYear(),this.start.getMonth()-1):void this.init(this.start.getFullYear()-1,11)},this.init=function(t,e){var a=new Date;this.year=angular.isDefined(t)?t:a.getFullYear(),this.month=angular.isDefined(e)?e:a.getMonth();var n=[31,28,31,30,31,30,31,31,30,31,30,31],o=n[this.month];1===this.month&&(this.year%4===0&&this.year%100!==0||this.year%400===0)&&(o=29),this.start=new Date(this.year,this.month,1);for(var r=angular.copy(this.start);r.getDay()!==this.weekStartsOn;)r.setDate(r.getDate()-1),o++;for(;o%7!==0;)o++;this.weeks=[];for(var i=0;o>i;++i)i%7===0&&this.weeks.push([]),this.weeks[this.weeks.length-1].push(angular.copy(r)),r.setDate(r.getDate()+1)},this.init(t,e)}return t}]),angular.module("materialCalendar").service("MaterialCalendarData",[function(){function t(){this.data={},this.getDayKey=function(t){return[t.getFullYear(),t.getMonth()+1,t.getDate()].join("-")},this.setDayContent=function(t,e){this.data[this.getDayKey(t)]=e||this.data[this.getDayKey(t)]||""}}return new t}]),angular.module("materialCalendar").directive("calendarMd",["$compile","$parse","$http","$q","materialCalendar.Calendar","MaterialCalendarData",function(t,e,a,n,o,r){var i="
Previous month«

{{ calendar.start | date:titleFormat:timezone }}

Next month»
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
{{ day | date:dayLabelTooltipFormat }}{{ day | date:dayLabelFormat }}
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
",d=function(){var t="calendarMdCss";if(!document.getElementById(t)){var e=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",a.id=t,a.innerHTML="calendar-md md-content>md-content.agenda>*>* :not(:first-child),calendar-md md-content>md-content.calendar>:not(:first-child)>* :last-child{overflow:hidden;text-overflow:ellipsis}calendar-md{display:block;max-height:100%}calendar-md .md-toolbar-tools h2{overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content{border:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>*{border-bottom:1px solid rgba(0,0,0,.12)}calendar-md md-content>md-content.agenda>*>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.agenda>*>* :first-child{padding:12px;width:200px;text-align:right;color:rgba(0,0,0,.75);font-weight:100;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}calendar-md md-content>md-content>*>*{min-width:48px}calendar-md md-content>md-content.calendar>:first-child{background:rgba(0,0,0,.02);border-bottom:1px solid rgba(0,0,0,.12);margin-right:0;min-height:36px}calendar-md md-content>md-content.calendar>:not(:first-child)>*{border-bottom:1px solid rgba(0,0,0,.12);border-right:1px solid rgba(0,0,0,.12);cursor:pointer}calendar-md md-content>md-content.calendar>:not(:first-child)>:hover{background:rgba(0,0,0,.04)}calendar-md md-content>md-content.calendar>:not(:first-child)>.disabled{color:rgba(0,0,0,.3);pointer-events:none;cursor:auto}calendar-md md-content>md-content.calendar>:not(:first-child)>.active{box-shadow:0 1px 3px 0 rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 2px 1px -1px rgba(0,0,0,.12);background:rgba(0,0,0,.02)}calendar-md md-content>md-content.calendar>:not(:first-child)>* :first-child{padding:0}",e.insertBefore(a,e.firstChild)}};return{restrict:"E",scope:{ngModel:"=?",template:"&",templateUrl:"=?",onDayClick:"=?",onPrevMonth:"=?",onNextMonth:"=?",calendarDirection:"=?",dayContent:"&?",timezone:"=?",titleFormat:"=?",dayFormat:"=?",dayLabelFormat:"=?",dayLabelTooltipFormat:"=?",dayTooltipFormat:"=?",weekStartsOn:"=?",tooltips:"&?",clearDataCacheOnLoad:"=?",disableFutureSelection:"=?"},link:function(l,c,s){d();var u=new Date,m=parseInt(s.startMonth||u.getMonth()),h=parseInt(s.startYear||u.getFullYear());l.columnWeekLayout="column",l.weekLayout="row",l.timezone=l.timezone||null,l.noCache=s.clearDataCacheOnLoad||!1,s.ngModel?(l.active=l.$parent.$eval(s.ngModel),s.ngModel&&l.$watch("$parent."+s.ngModel,function(t){l.active=t})):l.active=null,l.titleFormat=l.titleFormat||"MMMM yyyy",l.dayLabelFormat=l.dayLabelFormat||"EEE",l.dayLabelTooltipFormat=l.dayLabelTooltipFormat||"EEEE",l.dayFormat=l.dayFormat||"d",l.dayTooltipFormat=l.dayTooltipFormat||"fullDate",l.disableFutureSelection=l.disableFutureSelection||!1,l.sameMonth=function(t){var e=angular.copy(t);return e.getFullYear()===l.calendar.year&&e.getMonth()===l.calendar.month},l.isDisabled=function(t){return l.disableFutureSelection&&t>new Date?!0:!l.sameMonth(t)},l.calendarDirection=l.calendarDirection||"horizontal",l.$watch("calendarDirection",function(t){l.weekLayout="horizontal"===t?"row":"column"}),l.$watch("weekLayout",function(){h=l.calendar.year,m=l.calendar.month,k()});var g=function(t,e,a){(t||angular.noop)(a,e)},y=function(t,e){var a=-1;return angular.forEach(t,function(t,n){0>a&&angular.equals(e,t)&&(a=n)}),a};l.isActive=function(t){var e,a=angular.copy(l.active);return e=angular.isArray(a)?y(a,t)>-1:angular.equals(t,a)},l.prev=function(){l.calendar.prev();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onPrevMonth,null,t)},l.next=function(){l.calendar.next();var t={year:l.calendar.year,month:l.calendar.month+1};w(),g(l.onNextMonth,null,t)},l.handleDayClick=function(t,a){if(!(l.disableFutureSelection&&a>new Date)){var n=angular.copy(l.active);if(angular.isArray(n)){var o=y(n,a);o>-1?n.splice(o,1):n.push(a)}else n=angular.equals(n,a)?null:a;l.active=n,s.ngModel&&e(s.ngModel).assign(l.$parent,angular.copy(l.active)),g(l.onDayClick,t,angular.copy(a))}};var v=function(e){c.html(e),t(c.contents())(l)},p=function(){l.calendar=new o(h,m,{weekStartsOn:l.weekStartsOn||0});var t=n.defer();return l.templateUrl?a.get(l.templateUrl).success(t.resolve).error(t.reject):t.resolve(l.template()||i),t.promise};l.dataService=r;var f=function(t){return l.dataService.getDayKey(t)};l.dayKey=f;var b=function(t){l.noCache?l.dataService.setDayContent(t,""):l.dataService.setDayContent(t,l.dataService.data[f(t)]||"");var e=(l.dayContent||angular.noop)(),a=(e||angular.noop)(t);angular.isObject(a)&&"function"==typeof a.success?a.success(function(e){l.dataService.setDayContent(t,e)}):angular.isObject(a)&&"function"==typeof a.then?a.then(function(e){l.dataService.setDayContent(t,e)}):l.dataService.setDayContent(t,a)},w=function(){angular.forEach(l.calendar.weeks,function(t){angular.forEach(t,b)})};window.data=l.data;var k=function(){p().then(function(t){v(t),w()})};l.$watch("weekStartsOn",p),k(),l._$$init=p,l._$$setTemplate=v,l._$$bootstrap=k}}}]); \ No newline at end of file diff --git a/src/angular-material-calendar.html b/src/angular-material-calendar.html index 888108d..ccc5a7e 100644 --- a/src/angular-material-calendar.html +++ b/src/angular-material-calendar.html @@ -17,7 +17,7 @@

{{ calendar.start | date:titleFormat:timezon
-
+
{{ day | date:dayTooltipFormat:timezone }}
{{ day | date:dayFormat:timezone }}
@@ -33,7 +33,7 @@

{{ calendar.start | date:titleFormat:timezon

-
+
{{ day | date:dayTooltipFormat }}
{{ day | date:dayFormat }}
diff --git a/src/angular-material-calendar.js b/src/angular-material-calendar.js index 96c1211..0d52d6c 100644 --- a/src/angular-material-calendar.js +++ b/src/angular-material-calendar.js @@ -220,8 +220,8 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" bootstrap(); }); - var handleCb = function (cb, data) { - (cb || angular.noop)(data); + var handleCb = function (cb, $event, data) { + (cb || angular.noop)(data, $event); }; var dateFind = function (arr, date) { @@ -254,7 +254,7 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" month: $scope.calendar.month + 1 }; setData(); - handleCb($scope.onPrevMonth, data); + handleCb($scope.onPrevMonth, null, data); }; $scope.next = function () { @@ -264,10 +264,10 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" month: $scope.calendar.month + 1 }; setData(); - handleCb($scope.onNextMonth, data); + handleCb($scope.onNextMonth, null, data); }; - $scope.handleDayClick = function (date) { + $scope.handleDayClick = function ($event, date) { if($scope.disableFutureSelection && date > new Date()) { return; @@ -294,7 +294,7 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse" $parse($attrs.ngModel).assign($scope.$parent, angular.copy($scope.active)); } - handleCb($scope.onDayClick, angular.copy(date)); + handleCb($scope.onDayClick, $event, angular.copy(date)); };