diff --git a/lib/angular-scheduler.html b/lib/angular-scheduler.html index e12c483..3104adc 100644 --- a/lib/angular-scheduler.html +++ b/lib/angular-scheduler.html @@ -44,8 +44,9 @@ ng-model="schedulerStartHour" placeholder="HH24" min="0" max="23" data-zero-pad="2" required ng-change="scheduleTimeChange" > : - : + : +
Time must be in HH24:MM:SS format
diff --git a/lib/angular-scheduler.js b/lib/angular-scheduler.js index b38036e..f6c4fde 100644 --- a/lib/angular-scheduler.js +++ b/lib/angular-scheduler.js @@ -290,6 +290,11 @@ angular.module('AngularScheduler', ['underscore']) this.scope.scheduler_weekDays_error = true; validity = false; } + if (this.scope.schedulerStartHour < 0 || this.scope.schedulerStartMinute < 0 || scope.schedulerStartSecond < 0 || + this.scope.schedulerStartHour > 23 || this.scope.schedulerStartMinute > 59 || scope.schedulerStartSecond > 59) { + this.scope.scheduler_startTime_error = true; + validity = false; + } if (!this.scope.scheduler_form.schedulerName.$valid) { // Make sure schedulerName requird error shows up this.scope.scheduler_form.schedulerName.$dirty = true; @@ -817,9 +822,9 @@ angular.module('AngularScheduler', ['underscore']) defaultDateStr = defaultDate.getFullYear() + '-' + defaultMonth + '-' + defaultDay; scope.schedulerName = ''; scope.weekDays = []; - scope.schedulerStartHour = 0; - scope.schedulerStartMinute = 0; - scope.schedulerStartSecond = 0; + scope.schedulerStartHour = '00'; + scope.schedulerStartMinute = '00'; + scope.schedulerStartSecond = '00'; scope.schedulerStartDt = defaultDateStr; scope.schedulerFrequency = scope.frequencyOptions[0]; scope.schedulerShowEvery = false; diff --git a/lib/angular-scheduler.min.js b/lib/angular-scheduler.min.js index 2490529..7889be7 100644 --- a/lib/angular-scheduler.min.js +++ b/lib/angular-scheduler.min.js @@ -1 +1 @@ -/*! angular-scheduler - v0.0.7 - 2014-04-02 */"use strict";angular.module("underscore",[]).factory("_",[function(){return window._}]),angular.module("AngularScheduler",["underscore"]).constant("AngularScheduler.partials","/lib/").constant("AngularScheduler.useTimezone",!1).constant("AngularScheduler.showUTCField",!1).factory("SchedulerInit",["$log","$filter","$timezones","LoadLookupValues","SetDefaults","CreateObject","_","AngularScheduler.useTimezone","AngularScheduler.showUTCField",function(a,b,c,d,e,f,g,h,i){return function(j){var k=j.scope,l=j.requireFutureStartTime||!1;return k.schedulerShowTimeZone=h,k.schedulerShowUTCStartTime=i,k.setDefaults=function(){h&&(k.current_timezone=c.getLocal(),($.isEmptyObject(k.current_timezone)||!k.current_timezone.name)&&(a.error("Failed to find local timezone. Defaulting to America/New_York."),k.current_timezone={name:"America/New_York"}),k.schedulerTimeZone=g.find(k.timeZones,function(a){return a.name===k.current_timezone.name})),d(k),e(k),k.scheduleTimeChange(),k.scheduleRepeatChange()},k.scheduleTimeChange=function(){if(k.schedulerStartDt)if(h){k.resetStartDate();try{var a=k.schedulerStartDt+"T"+b("schZeroPad")(k.schedulerStartHour,2)+":"+b("schZeroPad")(k.schedulerStartMinute,2)+":"+b("schZeroPad")(k.schedulerStartSecond,2)+".000Z";k.schedulerUTCTime=c.toUTC(a,k.schedulerTimeZone.name).toISOString()}catch(d){k.startDateError("Provide a valid start date and time")}}else k.schedulerUTCTime=k.schedulerStartDt+"T"+k.schedulerStartHour+":"+k.schedulerStartMinute+":"+k.schedulerStartSecond+".000Z";else k.schedulerUTCTime=""},k.scheduleRepeatChange=function(){k.schedulerFrequency&&""!==k.schedulerFrequency.value&&"none"!==k.schedulerFrequency.value?(k.schedulerInterval=1,k.schedulerShowInterval=!0,k.schedulerIntervalLabel=k.schedulerFrequency.intervalLabel):(k.schedulerShowInterval=!1,k.schedulerEnd=k.endOptions[0])},k.showCalendar=function(a){$("#"+a).focus()},k.monthlyRepeatChange=function(){$("#monthDay").spinner("day"!==k.monthlyRepeatOption?"disable":"enable")},k.yearlyRepeatChange=function(){$("#yearlyRepeatDay").spinner("month"!==k.yearlyRepeatOption?"disable":"enable")},k.setWeekday=function(a){var b=k.weekDays.indexOf(a);b>=0?k.weekDays.splice(a,1):k.weekDays.push(a)},k.startDateError=function(a){k.scheduler_form&&(k.scheduler_form.schedulerStartDt&&(k.scheduler_form_schedulerStartDt_error=a,k.scheduler_form.schedulerStartDt.$pristine=!1,k.scheduler_form.schedulerStartDt.$dirty=!0),$("#schedulerStartDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"))},k.resetStartDate=function(){k.scheduler_form&&(k.scheduler_form_schedulerStartDt_error="",k.scheduler_form.schedulerStartDt&&(k.scheduler_form.schedulerStartDt.$setValidity("custom-error",!0),k.scheduler_form.schedulerStartDt.$setPristine()))},k.schedulerEndChange=function(){var a=new Date,c=b("schZeroPad")(a.getMonth()+1,2),d=b("schZeroPad")(a.getDate(),2);k.schedulerEndDt=a.getFullYear()+"-"+c+"-"+d,k.schedulerOccurrenceCount=1},k.removeZonesReady&&k.removeZonesReady(),k.removeZonesReady=k.$on("zonesReady",function(){k.timeZones=JSON.parse(localStorage.zones),k.setDefaults()}),h?c.getZoneList(k):k.setDefaults(),f(k,l)}}]).factory("CreateObject",["AngularScheduler.useTimezone","$filter","GetRule","Inject","InjectDetail","SetDefaults","$timezones","SetRule",function(a,b,c,d,e,f,g,h){return function(f,i){var j=function(){this.scope=f,this.useTimezone=a,this.requireFutureStartTime=i,this.getOptions=function(){var a={};return a.startDate=this.scope.schedulerUTCTime,a.frequency=this.scope.schedulerFrequency.value,a.interval=this.scope.schedulerInterval,"after"===this.scope.schedulerEnd.value&&(a.occurrenceCount=this.scope.schedulerOccurrenceCount),"on"===this.scope.schedulerEnd.value&&(a.endDate=f.schedulerEndDt+this.scope.schedulerUTCTime.replace(/^\d{4}-\d{2}-\d{2}/,"")),"weekly"===this.scope.schedulerFrequency.value?a.weekDays=this.scope.weekDays:"yearly"===this.scope.schedulerFrequency.value?"month"===this.scope.yearlyRepeatOption?(a.month=this.scope.yearlyMonth.value,a.monthDay=this.scope.yearlyMonthDay):(a.setOccurrence=this.scope.yearlyOccurrence.value,a.weekDays=this.scope.yearlyWeekDay.value,a.month=this.scope.yearlyOtherMonth.value):"monthly"===this.scope.schedulerFrequency.value&&("day"===this.scope.monthlyRepeatOption?a.monthDay=this.scope.monthDay:(a.setOccurrence=this.scope.monthlyOccurrence.value,a.weekDays=this.scope.monthlyWeekDay.value)),a},this.clearErrors=function(){this.scope.scheduler_weekDays_error=!1,this.scope.scheduler_endDt_error=!1,this.scope.resetStartDate(),this.scope.scheduler_endDt_error=!1,this.scope.scheduler_interval_error=!1,this.scope.scheduler_occurrenceCount_error=!1,this.scope.scheduler_form&&this.scope.scheduler_form.schedulerEndDt&&(this.scope.scheduler_form.schedulerEndDt.$setValidity("custom-error",!0),this.scope.scheduler_form.schedulerEndDt.$setPristine(),this.scope.scheduler_form.$setPristine())},this.setDetails=function(){var a=this.getRRule();a&&(f.rrule_nlp_description=a.toText(),f.dateChoice="utc",f.occurrence_list=[],a.all(function(a,b){return 10>b?(f.occurrence_list.push({utc:a.toUTCString(),local:a.toString()}),!0):!1}),f.rrule_nlp_description=a.toText().replace(/^RRule error.*$/,"Natural language description not available"),f.rrule=a.toString())},this.isValid=function(){var a,c,d,e,h,i,j=!0;if(this.clearErrors(),"none"!==this.scope.schedulerFrequency.value&&(this.scope.schedulerInterval<1||this.scope.schedulerInterval>999)&&(this.scope.scheduler_interval_error=!0,j=!1),"after"===this.scope.schedulerEnd.value&&(this.scope.schedulerOccurrenceCount<0||this.scope.schedulerOccurrenceCount>999)&&(this.scope.scheduler_occurrenceCount_error=!0,j=!1),"weekly"===this.scope.schedulerFrequency.value&&0===f.weekDays.length&&(this.scope.scheduler_weekDays_error=!0,j=!1),this.scope.scheduler_form.schedulerName.$valid||(this.scope.scheduler_form.schedulerName.$dirty=!0,$("#schedulerName").addClass("ng-dirty"),j=!1),"on"===this.scope.schedulerEnd.value&&(/^\d{4}-\d{2}-\d{2}$/.test(this.scope.schedulerEndDt)||(this.scope.scheduler_form.schedulerEndDt.$pristine=!1,this.scope.scheduler_form.schedulerEndDt.$dirty=!0,$("#schedulerEndDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"),this.scope.scheduler_endDt_error=!0,j=!1)),this.scope.schedulerUTCTime)try{a=new Date(this.scope.schedulerUTCTime),isNaN(a)?(this.scope.startDateError("Invalid start time"),j=!1):(i=a.getTime(),c=new Date,this.useTimezone?(d=c.getFullYear()+"-"+b("schZeroPad")(c.getMonth()+1,2)+"-"+b("schZeroPad")(c.getDate(),2)+"T"+b("schZeroPad")(c.getHours(),2)+":"+b("schZeroPad")(c.getMinutes(),2)+":"+b("schZeroPad")(c.getSeconds(),2)+".000Z",e=g.toUTC(d,this.scope.schedulerTimeZone.name),h=e.getTime()):h=c.getTime(),this.requireFutureStartTime&&h>=i&&(this.scope.startDateError("Start time must be in the future"),j=!1))}catch(k){this.scope.startDateError("Invalid start time"),j=!1}else this.scope.startDateError("Provide a start time"),j=!1;return f.schedulerIsValid=j,j&&this.setDetails(),j},this.getRRule=function(){var a=this.getOptions();return c(a)},this.getValue=function(){var a=this.getRRule(),b=this.getOptions();return{name:f.schedulerName,rrule:a.toString(),options:b}},this.setRRule=function(a){return this.clear(),h(a,this.scope)},this.setName=function(a){this.scope.schedulerName=a},this.inject=function(a,b){return d({scope:this.scope,target:a,buttons:b})},this.injectDetail=function(a,b){return e({scope:this.scope,target:a,showRRule:b})},this.clear=function(){this.clearErrors(),this.scope.scheduler_form&&this.scope.scheduler_form.schedulerName&&this.scope.scheduler_form.schedulerName.$setPristine(),this.scope.setDefaults()},this.getUserTimezone=function(){return g.getLocal()},this.setRequireFutureStartTime=function(a){this.requireFutureStartTime=a},this.getRequireFutureStartTime=function(){return this.requireFutureStartTime},this.setShowRRule=function(a){f.showRRule=a}};return new j}}]).factory("Inject",["AngularScheduler.partials","$compile","$http","$log",function(a,b,c){return function(d){var e=d.scope,f=d.target,g=d.buttons;e.removeHtmlReady&&e.removeHtmlReady(),e.removeHtmlReady=e.$on("htmlReady",function(a,c){var d=angular.isObject(f)?f:angular.element(document.getElementById(f));d.html(c),b(d)(e),g&&$("#scheduler-buttons").show()}),c({method:"GET",url:a+"angular-scheduler.html"}).success(function(a){e.$emit("htmlReady",a)}).error(function(b,c){throw"Error reading "+a+"angular-scheduler.html. "+c})}}]).factory("InjectDetail",["AngularScheduler.partials","$compile","$http","$log",function(a,b,c){return function(d){var e=d.scope,f=d.target,g=d.showRRule;e.showRRule=g||!1,e.removeHtmlDetailReady&&e.removeHtmlDetailReady(),e.removeHtmlDetailReady=e.$on("htmlDetailReady",function(a,c){var d=angular.isObject(f)?f:angular.element(document.getElementById(f));d.html(c),b(d)(e)}),c({method:"GET",url:a+"angular-scheduler-detail.html"}).success(function(a){e.$emit("htmlDetailReady",a)}).error(function(b,c){throw"Error reading "+a+"angular-scheduler-detail.html. "+c})}}]).factory("GetRule",["$log",function(a){return function(b){var c,d=b.startDate,e=b.frequency,f=b.interval,g=b.occurrenceCount,h=b.endDate,i=b.month,j=b.monthDay,k=b.weekDays,l=b.setOccurrence,m={};if(angular.isDate(d))m.dtstart=d;else try{m.dtstart=new Date(d)}catch(n){a.error("Date conversion failed. Attempted to convert "+d+" to Date. "+n.message)}if(e&&"none"!==e){if(m.freq=RRule[e.toUpperCase()],m.interval=f,k&&"string"==typeof k&&(m.byweekday=RRule[k.toUpperCase()]),k&&angular.isArray(k))for(m.byweekday=[],c=0;c 0"),"BYDAY"===r)if("WEEKLY"===g(d,"FREQ"))for(i=s.split(/,/),f.weekDays=[],k=0;k0&&parseInt(s,10)<32?(f.monthDay=parseInt(s,10),f.monhthlyRepeatOption="day"):m="BYMONTHDAY must contain an integer between 1 and 31"),"DTSTART"===r&&(n=!0,/\d{8}T\d{6}.*Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}.*$)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g.substr(0,2)+"Z"})),a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerStartDt=l.getFullYear()+"-"+o+"-"+p,f.schedulerStartHour=l.getHours(),f.schedulerStartMinute=l.getMinutes(),f.schedulerStartSecond=l.getSeconds(),f.scheduleTimeChange()):(q=s.replace(/^.*T/,""),f.schedulerStartDt=s.replace(/T.*$/,""),f.schedulerStartHour=q.substr(0,2),f.schedulerStartMinute=q.substr(3,2),f.schedulerStartSecond=q.substr(6,2)),f.scheduleTimeChange()),"BYSETPOS"===r&&("YEARLY"===g(d,"FREQ")?(f.yearlRepeatOption="other",f.yearlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.yearlyOccurrence&&f.yearlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1")):(f.monthlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.monthlyOccurrence&&f.monthlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1"))),"COUNT"===r&&(parseInt(s,10)?(f.schedulerEnd=f.endOptions[1],f.schedulerOccurrenceCount=parseInt(s,10)):m="COUNT must be a valid integer > 0"),"UNTIL"===r&&(/\d{8}T\d{6}.*Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}.*$)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g.substr(0,2)+"Z"})),f.schedulerEnd=f.endOptions[2],a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerEndDt=l.getFullYear()+"-"+o+"-"+p):f.schedulerEndDt=s.replace(/T.*$/,"")),"BYMONTH"===r&&("YEARLY"===g(d,"FREQ")&&g(d,"BYDAY")?(f.yearlRepeatOption="other",f.yearlyOtherMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyOtherMonth&&f.yearlyOtherMonth.name||(m="BYMONTH must be an integer between 1 and 12")):(f.yearlyOption="month",f.yearlyMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyMonth&&f.yearlyMonth.name||(m="BYMONTH must be an integer between 1 and 12"))),"BYMONTHDAY"===r&&(parseInt(s,10)?f.yearlyMonthDay=parseInt(s,10):m="BYMONTHDAY must be an integer between 1 and 31")}function j(){"weekly"===f.schedulerFrequency.name&&0===f.weekDays.length&&(m="Frequency is weekly, but BYDAYS value is missing."),n||(m="Warning: start date was not provided")}var k,l,m="",n=!1;if(d)if(k=d.split(/;/),angular.isArray(k)){for(l=0;l=0?k.weekDays.splice(a,1):k.weekDays.push(a)},k.startDateError=function(a){k.scheduler_form&&(k.scheduler_form.schedulerStartDt&&(k.scheduler_form_schedulerStartDt_error=a,k.scheduler_form.schedulerStartDt.$pristine=!1,k.scheduler_form.schedulerStartDt.$dirty=!0),$("#schedulerStartDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"))},k.resetStartDate=function(){k.scheduler_form&&(k.scheduler_form_schedulerStartDt_error="",k.scheduler_form.schedulerStartDt&&(k.scheduler_form.schedulerStartDt.$setValidity("custom-error",!0),k.scheduler_form.schedulerStartDt.$setPristine()))},k.schedulerEndChange=function(){var a=new Date,c=b("schZeroPad")(a.getMonth()+1,2),d=b("schZeroPad")(a.getDate(),2);k.schedulerEndDt=a.getFullYear()+"-"+c+"-"+d,k.schedulerOccurrenceCount=1},k.removeZonesReady&&k.removeZonesReady(),k.removeZonesReady=k.$on("zonesReady",function(){k.timeZones=JSON.parse(localStorage.zones),k.setDefaults()}),h?c.getZoneList(k):k.setDefaults(),f(k,l)}}]).factory("CreateObject",["AngularScheduler.useTimezone","$filter","GetRule","Inject","InjectDetail","SetDefaults","$timezones","SetRule",function(a,b,c,d,e,f,g,h){return function(f,i){var j=function(){this.scope=f,this.useTimezone=a,this.requireFutureStartTime=i,this.getOptions=function(){var a={};return a.startDate=this.scope.schedulerUTCTime,a.frequency=this.scope.schedulerFrequency.value,a.interval=this.scope.schedulerInterval,"after"===this.scope.schedulerEnd.value&&(a.occurrenceCount=this.scope.schedulerOccurrenceCount),"on"===this.scope.schedulerEnd.value&&(a.endDate=f.schedulerEndDt+this.scope.schedulerUTCTime.replace(/^\d{4}-\d{2}-\d{2}/,"")),"weekly"===this.scope.schedulerFrequency.value?a.weekDays=this.scope.weekDays:"yearly"===this.scope.schedulerFrequency.value?"month"===this.scope.yearlyRepeatOption?(a.month=this.scope.yearlyMonth.value,a.monthDay=this.scope.yearlyMonthDay):(a.setOccurrence=this.scope.yearlyOccurrence.value,a.weekDays=this.scope.yearlyWeekDay.value,a.month=this.scope.yearlyOtherMonth.value):"monthly"===this.scope.schedulerFrequency.value&&("day"===this.scope.monthlyRepeatOption?a.monthDay=this.scope.monthDay:(a.setOccurrence=this.scope.monthlyOccurrence.value,a.weekDays=this.scope.monthlyWeekDay.value)),a},this.clearErrors=function(){this.scope.scheduler_weekDays_error=!1,this.scope.scheduler_endDt_error=!1,this.scope.resetStartDate(),this.scope.scheduler_endDt_error=!1,this.scope.scheduler_interval_error=!1,this.scope.scheduler_occurrenceCount_error=!1,this.scope.scheduler_form&&this.scope.scheduler_form.schedulerEndDt&&(this.scope.scheduler_form.schedulerEndDt.$setValidity("custom-error",!0),this.scope.scheduler_form.schedulerEndDt.$setPristine(),this.scope.scheduler_form.$setPristine())},this.setDetails=function(){var a=this.getRRule();a&&(f.rrule_nlp_description=a.toText(),f.dateChoice="utc",f.occurrence_list=[],a.all(function(a,b){return 10>b?(f.occurrence_list.push({utc:a.toUTCString(),local:a.toString()}),!0):!1}),f.rrule_nlp_description=a.toText().replace(/^RRule error.*$/,"Natural language description not available"),f.rrule=a.toString())},this.isValid=function(){var a,c,d,e,h,i,j=!0;if(this.clearErrors(),"none"!==this.scope.schedulerFrequency.value&&(this.scope.schedulerInterval<1||this.scope.schedulerInterval>999)&&(this.scope.scheduler_interval_error=!0,j=!1),"after"===this.scope.schedulerEnd.value&&(this.scope.schedulerOccurrenceCount<0||this.scope.schedulerOccurrenceCount>999)&&(this.scope.scheduler_occurrenceCount_error=!0,j=!1),"weekly"===this.scope.schedulerFrequency.value&&0===f.weekDays.length&&(this.scope.scheduler_weekDays_error=!0,j=!1),(this.scope.schedulerStartHour<0||this.scope.schedulerStartMinute<0||f.schedulerStartSecond<0||this.scope.schedulerStartHour>23||this.scope.schedulerStartMinute>59||f.schedulerStartSecond>59)&&(this.scope.scheduler_startTime_error=!0,j=!1),this.scope.scheduler_form.schedulerName.$valid||(this.scope.scheduler_form.schedulerName.$dirty=!0,$("#schedulerName").addClass("ng-dirty"),j=!1),"on"===this.scope.schedulerEnd.value&&(/^\d{4}-\d{2}-\d{2}$/.test(this.scope.schedulerEndDt)||(this.scope.scheduler_form.schedulerEndDt.$pristine=!1,this.scope.scheduler_form.schedulerEndDt.$dirty=!0,$("#schedulerEndDt").removeClass("ng-pristine").removeClass("ng-valid").removeClass("ng-valid-custom-error").addClass("ng-dirty").addClass("ng-invalid").addClass("ng-invalid-custom-error"),this.scope.scheduler_endDt_error=!0,j=!1)),this.scope.schedulerUTCTime)try{a=new Date(this.scope.schedulerUTCTime),isNaN(a)?(this.scope.startDateError("Invalid start time"),j=!1):(i=a.getTime(),c=new Date,this.useTimezone?(d=c.getFullYear()+"-"+b("schZeroPad")(c.getMonth()+1,2)+"-"+b("schZeroPad")(c.getDate(),2)+"T"+b("schZeroPad")(c.getHours(),2)+":"+b("schZeroPad")(c.getMinutes(),2)+":"+b("schZeroPad")(c.getSeconds(),2)+".000Z",e=g.toUTC(d,this.scope.schedulerTimeZone.name),h=e.getTime()):h=c.getTime(),this.requireFutureStartTime&&h>=i&&(this.scope.startDateError("Start time must be in the future"),j=!1))}catch(k){this.scope.startDateError("Invalid start time"),j=!1}else this.scope.startDateError("Provide a start time"),j=!1;return f.schedulerIsValid=j,j&&this.setDetails(),j},this.getRRule=function(){var a=this.getOptions();return c(a)},this.getValue=function(){var a=this.getRRule(),b=this.getOptions();return{name:f.schedulerName,rrule:a.toString(),options:b}},this.setRRule=function(a){return this.clear(),h(a,this.scope)},this.setName=function(a){this.scope.schedulerName=a},this.inject=function(a,b){return d({scope:this.scope,target:a,buttons:b})},this.injectDetail=function(a,b){return e({scope:this.scope,target:a,showRRule:b})},this.clear=function(){this.clearErrors(),this.scope.scheduler_form&&this.scope.scheduler_form.schedulerName&&this.scope.scheduler_form.schedulerName.$setPristine(),this.scope.setDefaults()},this.getUserTimezone=function(){return g.getLocal()},this.setRequireFutureStartTime=function(a){this.requireFutureStartTime=a},this.getRequireFutureStartTime=function(){return this.requireFutureStartTime},this.setShowRRule=function(a){f.showRRule=a}};return new j}}]).factory("Inject",["AngularScheduler.partials","$compile","$http","$log",function(a,b,c){return function(d){var e=d.scope,f=d.target,g=d.buttons;e.removeHtmlReady&&e.removeHtmlReady(),e.removeHtmlReady=e.$on("htmlReady",function(a,c){var d=angular.isObject(f)?f:angular.element(document.getElementById(f));d.html(c),b(d)(e),g&&$("#scheduler-buttons").show()}),c({method:"GET",url:a+"angular-scheduler.html"}).success(function(a){e.$emit("htmlReady",a)}).error(function(b,c){throw"Error reading "+a+"angular-scheduler.html. "+c})}}]).factory("InjectDetail",["AngularScheduler.partials","$compile","$http","$log",function(a,b,c){return function(d){var e=d.scope,f=d.target,g=d.showRRule;e.showRRule=g||!1,e.removeHtmlDetailReady&&e.removeHtmlDetailReady(),e.removeHtmlDetailReady=e.$on("htmlDetailReady",function(a,c){var d=angular.isObject(f)?f:angular.element(document.getElementById(f));d.html(c),b(d)(e)}),c({method:"GET",url:a+"angular-scheduler-detail.html"}).success(function(a){e.$emit("htmlDetailReady",a)}).error(function(b,c){throw"Error reading "+a+"angular-scheduler-detail.html. "+c})}}]).factory("GetRule",["$log",function(a){return function(b){var c,d=b.startDate,e=b.frequency,f=b.interval,g=b.occurrenceCount,h=b.endDate,i=b.month,j=b.monthDay,k=b.weekDays,l=b.setOccurrence,m={};if(angular.isDate(d))m.dtstart=d;else try{m.dtstart=new Date(d)}catch(n){a.error("Date conversion failed. Attempted to convert "+d+" to Date. "+n.message)}if(e&&"none"!==e){if(m.freq=RRule[e.toUpperCase()],m.interval=f,k&&"string"==typeof k&&(m.byweekday=RRule[k.toUpperCase()]),k&&angular.isArray(k))for(m.byweekday=[],c=0;c 0"),"BYDAY"===r)if("WEEKLY"===g(d,"FREQ"))for(i=s.split(/,/),f.weekDays=[],k=0;k0&&parseInt(s,10)<32?(f.monthDay=parseInt(s,10),f.monhthlyRepeatOption="day"):m="BYMONTHDAY must contain an integer between 1 and 31"),"DTSTART"===r&&(n=!0,/\d{8}T\d{6}.*Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}.*$)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g.substr(0,2)+"Z"})),a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerStartDt=l.getFullYear()+"-"+o+"-"+p,f.schedulerStartHour=l.getHours(),f.schedulerStartMinute=l.getMinutes(),f.schedulerStartSecond=l.getSeconds(),f.scheduleTimeChange()):(q=s.replace(/^.*T/,""),f.schedulerStartDt=s.replace(/T.*$/,""),f.schedulerStartHour=q.substr(0,2),f.schedulerStartMinute=q.substr(3,2),f.schedulerStartSecond=q.substr(6,2)),f.scheduleTimeChange()),"BYSETPOS"===r&&("YEARLY"===g(d,"FREQ")?(f.yearlRepeatOption="other",f.yearlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.yearlyOccurrence&&f.yearlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1")):(f.monthlyOccurrence=b.find(f.occurrences,function(a){return a.value===parseInt(s,10)}),f.monthlyOccurrence&&f.monthlyOccurrence.name||(m="BYSETPOS was not in the set of 1,2,3,4,-1"))),"COUNT"===r&&(parseInt(s,10)?(f.schedulerEnd=f.endOptions[1],f.schedulerOccurrenceCount=parseInt(s,10)):m="COUNT must be a valid integer > 0"),"UNTIL"===r&&(/\d{8}T\d{6}.*Z/.test(s)&&(s=s.replace(/(\d{4})(\d{2})(\d{2}T)(\d{2})(\d{2})(\d{2}.*$)/,function(a,b,c,d,e,f,g){return b+"-"+c+"-"+d+e+":"+f+":"+g.substr(0,2)+"Z"})),f.schedulerEnd=f.endOptions[2],a?(l=new Date(s),o=e("schZeroPad")(l.getMonth()+1,2),p=e("schZeroPad")(l.getDate(),2),f.schedulerEndDt=l.getFullYear()+"-"+o+"-"+p):f.schedulerEndDt=s.replace(/T.*$/,"")),"BYMONTH"===r&&("YEARLY"===g(d,"FREQ")&&g(d,"BYDAY")?(f.yearlRepeatOption="other",f.yearlyOtherMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyOtherMonth&&f.yearlyOtherMonth.name||(m="BYMONTH must be an integer between 1 and 12")):(f.yearlyOption="month",f.yearlyMonth=b.find(f.months,function(a){return a.value===parseInt(s,10)}),f.yearlyMonth&&f.yearlyMonth.name||(m="BYMONTH must be an integer between 1 and 12"))),"BYMONTHDAY"===r&&(parseInt(s,10)?f.yearlyMonthDay=parseInt(s,10):m="BYMONTHDAY must be an integer between 1 and 31")}function j(){"weekly"===f.schedulerFrequency.name&&0===f.weekDays.length&&(m="Frequency is weekly, but BYDAYS value is missing."),n||(m="Warning: start date was not provided")}var k,l,m="",n=!1;if(d)if(k=d.split(/;/),angular.isArray(k)){for(l=0;l