From 618c50fabaf774f91db3ed3fb086ac9f45c22136 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Sat, 5 Apr 2014 19:25:49 -0400 Subject: [PATCH] Moved spinner updating back to 'stop' event to prevent object from reporting different DTSTART value than what appears on the screen. --- bower.json | 2 +- lib/angular-scheduler.js | 15 ++++++--------- lib/angular-scheduler.min.js | 2 +- package.json | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/bower.json b/bower.json index 025ace5..d706b50 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-scheduler", - "version": "0.0.13", + "version": "0.0.14", "authors": [ "Chris Houseknecht " ], diff --git a/lib/angular-scheduler.js b/lib/angular-scheduler.js index 9942484..e343e83 100644 --- a/lib/angular-scheduler.js +++ b/lib/angular-scheduler.js @@ -1042,24 +1042,21 @@ angular.module('AngularScheduler', ['underscore']) $(element).spinner({ min: min, max: max, - change: function() { + stop: function() { + //update the model immediately setTimeout(function() { scope.$apply(function() { if (zeroPad) { scope[attr.ngModel] = $filter('schZeroPad')($(element).spinner('value'),zeroPad); - $(element).val(scope[attr.ngModel]); - if (attr.ngChange) { - scope.$eval(attr.ngChange); - } } else { scope[attr.ngModel] = $(element).spinner('value'); - if (attr.ngChange) { - scope.$eval(attr.ngChange); - } + } + if (attr.ngChange) { + scope.$eval(attr.ngChange); } }); - },100); + }, 100); }, spin: function() { scope[form].$setDirty(); diff --git a/lib/angular-scheduler.min.js b/lib/angular-scheduler.min.js index 24690dc..4910a26 100644 --- a/lib/angular-scheduler.min.js +++ b/lib/angular-scheduler.min.js @@ -1 +1 @@ -/*! angular-scheduler - v0.0.13 - 2014-04-05 */"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","InRange",function(a,b,c,d,e,f,g,h,i,j){return function(k){var l=k.scope,m=k.requireFutureStartTime||!1;return l.schedulerShowTimeZone=h,l.schedulerShowUTCStartTime=i,l.setDefaults=function(){h&&(l.current_timezone=c.getLocal(),($.isEmptyObject(l.current_timezone)||!l.current_timezone.name)&&(a.error("Failed to find local timezone. Defaulting to America/New_York."),l.current_timezone={name:"America/New_York"}),l.schedulerTimeZone=g.find(l.timeZones,function(a){return a.name===l.current_timezone.name})),d(l),e(l),l.scheduleTimeChange(),l.scheduleRepeatChange()},l.scheduleTimeChange=function(){if(""===l.schedulerStartDt||null===l.schedulerStartDt||void 0===l.schedulerStartDt)l.startDateError("Provide a valid start date and time"),l.schedulerUTCTime="";else if(j(l.schedulerStartHour,0,23,2)&&j(l.schedulerStartMinute,0,59,2)&&j(l.schedulerStartSecond,0,59,2))if(h){l.resetStartDate();try{var a=l.schedulerStartDt.replace(/(\d{2})\/(\d{2})\/(\d{4})/,function(a,b,c,d){return d+"-"+b+"-"+c});a+="T"+b("schZeroPad")(l.schedulerStartHour,2)+":"+b("schZeroPad")(l.schedulerStartMinute,2)+":"+b("schZeroPad")(l.schedulerStartSecond,2)+".000Z",l.schedulerUTCTime=b("schDateStrFix")(c.toUTC(a,l.schedulerTimeZone.name).toISOString()),l.scheduler_form_schedulerStartDt_error=!1,l.scheduler_startTime_error=!1}catch(d){l.startDateError("Provide a valid start date and time")}}else l.scheduler_startTime_error=!1,l.scheduler_form_schedulerStartDt_error=!1,l.schedulerUTCTime=b("schDateStrFix")(l.schedulerStartDt+"T"+l.schedulerStartHour+":"+l.schedulerStartMinute+":"+l.schedulerStartSecond+".000Z");else l.scheduler_startTime_error=!0},l.resetError=function(a){l[a]=!1},l.scheduleRepeatChange=function(){l.schedulerFrequency&&""!==l.schedulerFrequency.value&&"none"!==l.schedulerFrequency.value?(l.schedulerInterval=1,l.schedulerShowInterval=!0,l.schedulerIntervalLabel=l.schedulerFrequency.intervalLabel):(l.schedulerShowInterval=!1,l.schedulerEnd=l.endOptions[0]),l.sheduler_frequency_error=!1},l.showCalendar=function(a){$("#"+a).focus()},l.monthlyRepeatChange=function(){$("#monthDay").spinner("day"!==l.monthlyRepeatOption?"disable":"enable")},l.yearlyRepeatChange=function(){$("#yearlyRepeatDay").spinner("month"!==l.yearlyRepeatOption?"disable":"enable")},l.setWeekday=function(a,b){var c=l.weekDays.indexOf(b);c>=0?l.weekDays.splice(c,1):l.weekDays.push(b),$(a.target).blur(),l.scheduler_weekDays_error=!1},l.startDateError=function(a){l.scheduler_form&&(l.scheduler_form.schedulerStartDt&&(l.scheduler_form_schedulerStartDt_error=a,l.scheduler_form.schedulerStartDt.$pristine=!1,l.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"))},l.resetStartDate=function(){l.scheduler_form&&(l.scheduler_form_schedulerStartDt_error="",l.scheduler_form.schedulerStartDt&&(l.scheduler_form.schedulerStartDt.$setValidity("custom-error",!0),l.scheduler_form.schedulerStartDt.$setPristine()))},l.schedulerEndChange=function(){var a=new Date,c=b("schZeroPad")(a.getMonth()+1,2),d=b("schZeroPad")(a.getDate(),2);l.schedulerEndDt=c+"/"+d+"/"+a.getFullYear(),l.schedulerOccurrenceCount=1},l.removeZonesReady&&l.removeZonesReady(),l.removeZonesReady=l.$on("zonesReady",function(){l.timeZones=JSON.parse(localStorage.zones),l.setDefaults()}),h?c.getZoneList(l):l.setDefaults(),f(l,m)}}]).factory("CreateObject",["AngularScheduler.useTimezone","$filter","GetRule","Inject","InjectDetail","SetDefaults","$timezones","SetRule","InRange",function(a,b,c,d,e,f,g,h,i){return function(f,j){var k=function(){this.scope=f,this.useTimezone=a,this.requireFutureStartTime=j,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.replace(/(\d{2})\/(\d{2})\/(\d{4})/,function(a,b,c,d){return d+"-"+b+"-"+c})+"T"+this.scope.schedulerUTCTime.replace(/\d{2}\/\d{2}\/\d{4} /,"").replace(/ UTC/,"")+"Z"),"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_monthDay_error=!1,this.scope.scheduler_yearlyMonthDay_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 c=this.getRRule(),d=this.scope;c&&(d.rrule_nlp_description=c.toText(),d.dateChoice="local",d.occurrence_list=[],c.all(function(c,e){var f,h;return 10>e?(a?(h=g.align(c,d.schedulerTimeZone.name),f=b("schZeroPad")(h.getMonth()+1,2)+"/"+b("schZeroPad")(h.getDate(),2)+"/"+h.getFullYear()+" "+b("schZeroPad")(h.getHours(),2)+":"+b("schZeroPad")(h.getMinutes(),2)+":"+b("schZeroPad")(h.getSeconds(),2)+" "+h.getTimezoneAbbreviation()):f=b("date")(c,"MM/dd/yyyy HH:mm:ss Z"),d.occurrence_list.push({utc:b("schDateStrFix")(c.toISOString()),local:f}),!0):!1}),d.rrule_nlp_description=c.toText().replace(/^RRule error.*$/,"Natural language description not available"),d.rrule=c.toString())},this.isValid=function(){var a,c,d,e,h,j,k=!0;if(this.clearErrors(),"none"===this.scope.schedulerFrequency.value||i(this.scope.schedulerInterval,1,999,3)||(this.scope.scheduler_interval_error=!0,k=!1),"after"!==this.scope.schedulerEnd.value||i(this.scope.schedulerOccurrenceCount,1,999,3)||(this.scope.scheduler_occurrenceCount_error=!0,k=!1),"weekly"===this.scope.schedulerFrequency.value&&0===this.scope.weekDays.length&&(this.scope.scheduler_weekDays_error=!0,k=!1),"monthly"!==this.scope.schedulerFrequency.value||"day"!==this.scope.monthlyRepeatOption||i(this.scope.monthDay,1,31,99)||(this.scope.scheduler_monthDay_error=!0,k=!1),"yearly"!==this.scope.schedulerFrequency.value||"month"!==this.scope.yearlyRepeatOption||i(this.scope.yearlyMonthDay,1,31,99)||(this.scope.scheduler_yearlyMonthDay_error=!0,k=!1),i(f.schedulerStartHour,0,23,2)&&i(f.schedulerStartMinute,0,59,2)&&i(f.schedulerStartSecond,0,59,2)||(this.scope.scheduler_startTime_error=!0,k=!1),this.scope.scheduler_form.schedulerName.$valid||(this.scope.scheduler_form.schedulerName.$dirty=!0,$("#schedulerName").addClass("ng-dirty"),k=!1),"on"===this.scope.schedulerEnd.value&&(/^\d{2}\/\d{2}\/\d{4}$/.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,k=!1)),this.scope.schedulerUTCTime)try{a=new Date(this.scope.schedulerUTCTime),isNaN(a)?(this.scope.startDateError("Invalid start time"),k=!1):(j=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>=j&&(this.scope.startDateError("Start time must be in the future"),k=!1))}catch(l){this.scope.startDateError("Invalid start time"),k=!1}else this.scope.startDateError("Provide a start time"),k=!1;return f.schedulerIsValid=k,k&&this.setDetails(),k},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 k}}]).factory("InRange",[function(){return function(a,b,c,d){var e=new RegExp("\\d{1,"+d+"}");return e.test(a)?b>a||a>c?!1:!0:!1}}]).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=o+"/"+p+"/"+l.getFullYear(),f.schedulerStartHour=e("schZeroPad")(l.getHours(),2),f.schedulerStartMinute=e("schZeroPad")(l.getMinutes(),2),f.schedulerStartSecond=e("schZeroPad")(l.getSeconds(),2),f.scheduleTimeChange()):(f.schedulerStartDt=s.replace(/T.*$/,"").replace(/(\d{4})-(\d{2})-(\d{2})/,function(a,b,c,d){return c+"/"+d+"/"+b}),q=s.replace(/^.*T/,""),f.schedulerStartHour=e("schZeroPad")(q.substr(0,2),2),f.schedulerStartMinute=e("schZeroPad")(q.substr(3,2),2),f.schedulerStartSecond=e("schZeroPad")(q.substr(6,2),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=o+"/"+p+"/"+l.getFullYear()):f.schedulerEndDt=s.replace(/T.*$/,"").replace(/(\d{4})-(\d{2})-(\d{2})/,function(a,b,c,d){return c+"/"+d+"/"+b})),"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?l.weekDays.splice(c,1):l.weekDays.push(b),$(a.target).blur(),l.scheduler_weekDays_error=!1},l.startDateError=function(a){l.scheduler_form&&(l.scheduler_form.schedulerStartDt&&(l.scheduler_form_schedulerStartDt_error=a,l.scheduler_form.schedulerStartDt.$pristine=!1,l.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"))},l.resetStartDate=function(){l.scheduler_form&&(l.scheduler_form_schedulerStartDt_error="",l.scheduler_form.schedulerStartDt&&(l.scheduler_form.schedulerStartDt.$setValidity("custom-error",!0),l.scheduler_form.schedulerStartDt.$setPristine()))},l.schedulerEndChange=function(){var a=new Date,c=b("schZeroPad")(a.getMonth()+1,2),d=b("schZeroPad")(a.getDate(),2);l.schedulerEndDt=c+"/"+d+"/"+a.getFullYear(),l.schedulerOccurrenceCount=1},l.removeZonesReady&&l.removeZonesReady(),l.removeZonesReady=l.$on("zonesReady",function(){l.timeZones=JSON.parse(localStorage.zones),l.setDefaults()}),h?c.getZoneList(l):l.setDefaults(),f(l,m)}}]).factory("CreateObject",["AngularScheduler.useTimezone","$filter","GetRule","Inject","InjectDetail","SetDefaults","$timezones","SetRule","InRange",function(a,b,c,d,e,f,g,h,i){return function(f,j){var k=function(){this.scope=f,this.useTimezone=a,this.requireFutureStartTime=j,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.replace(/(\d{2})\/(\d{2})\/(\d{4})/,function(a,b,c,d){return d+"-"+b+"-"+c})+"T"+this.scope.schedulerUTCTime.replace(/\d{2}\/\d{2}\/\d{4} /,"").replace(/ UTC/,"")+"Z"),"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_monthDay_error=!1,this.scope.scheduler_yearlyMonthDay_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 c=this.getRRule(),d=this.scope;c&&(d.rrule_nlp_description=c.toText(),d.dateChoice="local",d.occurrence_list=[],c.all(function(c,e){var f,h;return 10>e?(a?(h=g.align(c,d.schedulerTimeZone.name),f=b("schZeroPad")(h.getMonth()+1,2)+"/"+b("schZeroPad")(h.getDate(),2)+"/"+h.getFullYear()+" "+b("schZeroPad")(h.getHours(),2)+":"+b("schZeroPad")(h.getMinutes(),2)+":"+b("schZeroPad")(h.getSeconds(),2)+" "+h.getTimezoneAbbreviation()):f=b("date")(c,"MM/dd/yyyy HH:mm:ss Z"),d.occurrence_list.push({utc:b("schDateStrFix")(c.toISOString()),local:f}),!0):!1}),d.rrule_nlp_description=c.toText().replace(/^RRule error.*$/,"Natural language description not available"),d.rrule=c.toString())},this.isValid=function(){var a,c,d,e,h,j,k=!0;if(this.clearErrors(),"none"===this.scope.schedulerFrequency.value||i(this.scope.schedulerInterval,1,999,3)||(this.scope.scheduler_interval_error=!0,k=!1),"after"!==this.scope.schedulerEnd.value||i(this.scope.schedulerOccurrenceCount,1,999,3)||(this.scope.scheduler_occurrenceCount_error=!0,k=!1),"weekly"===this.scope.schedulerFrequency.value&&0===this.scope.weekDays.length&&(this.scope.scheduler_weekDays_error=!0,k=!1),"monthly"!==this.scope.schedulerFrequency.value||"day"!==this.scope.monthlyRepeatOption||i(this.scope.monthDay,1,31,99)||(this.scope.scheduler_monthDay_error=!0,k=!1),"yearly"!==this.scope.schedulerFrequency.value||"month"!==this.scope.yearlyRepeatOption||i(this.scope.yearlyMonthDay,1,31,99)||(this.scope.scheduler_yearlyMonthDay_error=!0,k=!1),i(f.schedulerStartHour,0,23,2)&&i(f.schedulerStartMinute,0,59,2)&&i(f.schedulerStartSecond,0,59,2)||(this.scope.scheduler_startTime_error=!0,k=!1),this.scope.scheduler_form.schedulerName.$valid||(this.scope.scheduler_form.schedulerName.$dirty=!0,$("#schedulerName").addClass("ng-dirty"),k=!1),"on"===this.scope.schedulerEnd.value&&(/^\d{2}\/\d{2}\/\d{4}$/.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,k=!1)),this.scope.schedulerUTCTime)try{a=new Date(this.scope.schedulerUTCTime),isNaN(a)?(this.scope.startDateError("Invalid start time"),k=!1):(j=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>=j&&(this.scope.startDateError("Start time must be in the future"),k=!1))}catch(l){this.scope.startDateError("Invalid start time"),k=!1}else this.scope.startDateError("Provide a start time"),k=!1;return f.schedulerIsValid=k,k&&this.setDetails(),k},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 k}}]).factory("InRange",[function(){return function(a,b,c,d){var e=new RegExp("\\d{1,"+d+"}");return e.test(a)?b>a||a>c?!1:!0:!1}}]).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=o+"/"+p+"/"+l.getFullYear(),f.schedulerStartHour=e("schZeroPad")(l.getHours(),2),f.schedulerStartMinute=e("schZeroPad")(l.getMinutes(),2),f.schedulerStartSecond=e("schZeroPad")(l.getSeconds(),2),f.scheduleTimeChange()):(f.schedulerStartDt=s.replace(/T.*$/,"").replace(/(\d{4})-(\d{2})-(\d{2})/,function(a,b,c,d){return c+"/"+d+"/"+b}),q=s.replace(/^.*T/,""),f.schedulerStartHour=e("schZeroPad")(q.substr(0,2),2),f.schedulerStartMinute=e("schZeroPad")(q.substr(3,2),2),f.schedulerStartSecond=e("schZeroPad")(q.substr(6,2),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=o+"/"+p+"/"+l.getFullYear()):f.schedulerEndDt=s.replace(/T.*$/,"").replace(/(\d{4})-(\d{2})-(\d{2})/,function(a,b,c,d){return c+"/"+d+"/"+b})),"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