UNPKG

jquery-yohours

Version:

Jquery and bootstrap based input widget to create opening_hours data

67 lines 108 kB
var YoHours=YoHours||{}; (function(y,r,w,c,A,C){function B(a){a=parseInt(a);return 0===a?6:a-1}var q;A.prototype.registerPlugin("modifier","t",function(a,b){var d=a;q instanceof C&&(void 0===b&&(b="yohours"),d=q.translate(a).withContext(b).fetch());return d});y.Array.prototype.equals=function(a){if(!a||this.length!==a.length)return!1;for(var b=0,d=this.length;b<d;b++)if(this[b]instanceof Array&&a[b]instanceof Array){if(!this[b].equals(a[b]))return!1}else if(this[b]!==a[b])return!1;return!0};y.Array.prototype.contains=function(a){for(var b= this.length;b--;)if(this[b]===a)return!0;return!1};c=r.extend(c,{counter:0,DAYS:{MONDAY:0,TUESDAY:1,WEDNESDAY:2,THURSDAY:3,FRIDAY:4,SATURDAY:5,SUNDAY:6},OSM_DAYS:"Mo Tu We Th Fr Sa Su".split(" "),IRL_DAYS:"Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),OSM_MONTHS:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),IRL_MONTHS:"January February March April May June July August September October November December".split(" "),MONTH_END_DAY:[31,28,31,30,31,30,31,31,30,31, 30,31],MINUTES_MAX:1440,DAYS_MAX:6,PH_WEEKDAY:-2,RGX_RULE_MODIFIER:/^(open|closed|off)$/i,RGX_WEEK_KEY:/^week$/,RGX_WEEK_VAL:/^([01234]?[0-9]|5[0123])(-([01234]?[0-9]|5[0123]))?(,([01234]?[0-9]|5[0123])(-([01234]?[0-9]|5[0123]))?)*:?$/,RGX_MONTH:/^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))?:?$/,RGX_MONTHDAY:/^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([012]?[0-9]|3[01])(-((Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) )?([012]?[0-9]|3[01]))?:?$/, RGX_TIME:/^((([01]?[0-9]|2[01234]):[012345][0-9](-([01]?[0-9]|2[01234]):[012345][0-9])?(,([01]?[0-9]|2[01234]):[012345][0-9](-([01]?[0-9]|2[01234]):[012345][0-9])?)*)|(24\/7))$/,RGX_WEEKDAY:/^(((Mo|Tu|We|Th|Fr|Sa|Su)(-(Mo|Tu|We|Th|Fr|Sa|Su))?)|(PH|SH|easter))(,(((Mo|Tu|We|Th|Fr|Sa|Su)(-(Mo|Tu|We|Th|Fr|Sa|Su))?)|(PH|SH|easter)))*$/,RGX_HOLIDAY:/^(PH|SH|easter)$/,RGX_WD:/^(Mo|Tu|We|Th|Fr|Sa|Su)(-(Mo|Tu|We|Th|Fr|Sa|Su))?$/});c.Interval=function(a,b,d,e){this._dayStart=a;this._dayEnd=b;this._start=d; this._end=e;this._dayEnd||this._end||(this._dayEnd=c.DAYS_MAX,this._end=c.MINUTES_MAX)};c.Interval.prototype.getStartDay=function(){return parseInt(this._dayStart)};c.Interval.prototype.getEndDay=function(){return parseInt(this._dayEnd)};c.Interval.prototype.getFrom=function(){return parseInt(this._start)};c.Interval.prototype.getTo=function(){return parseInt(this._end)};c.WideInterval=function(){this._type=this._end=this._start=null};c.WideInterval.prototype.day=function(a,b,d,e){if(void 0===a|| void 0===b)throw Error(q.translate("Start day and month can't be null").withContext("yohours/notifications").fetch());this._start={day:a,month:b};this._end=d&&e&&(d!==a||e!==b)?{day:d,month:e}:null;this._type="day";return this};c.WideInterval.prototype.week=function(a,b){if(void 0===a)throw Error(q.translate("Start week can't be null").withContext("yohours/notifications").fetch());this._start={week:a};this._end=b&&b!==a?{week:b}:null;this._type="week";return this};c.WideInterval.prototype.month=function(a, b){if(void 0===a)throw Error(q.translate("Start month can't be null").withContext("yohours/notifications").fetch());this._start={month:a};this._end=b&&b!==a?{month:b}:null;this._type="month";return this};c.WideInterval.prototype.holiday=function(a){if(void 0===a||"PH"!==a&&"SH"!==a&&"easter"!==a)throw Error(q.translate("Invalid holiday, must be PH, SH or easter").withContext("yohours/notifications").fetch());this._start={holiday:a};this._end=null;this._type="holiday";return this};c.WideInterval.prototype.always= function(){this._end=this._start=null;this._type="always";return this};c.WideInterval.prototype.getType=function(){return this._type};c.WideInterval.prototype.getStart=function(){return this._start};c.WideInterval.prototype.getEnd=function(){return this._end};c.WideInterval.prototype.equals=function(a){if(!(a instanceof c.WideInterval))return!1;if(this===a)return!0;if("always"===a._type)return"always"===this._type;var b=!1;switch(this._type){case "always":b=null===a._start;break;case "day":b="day"=== a._type&&a._start.month===this._start.month&&a._start.day===this._start.day&&(null===a._end&&null===this._end||null!==a._end&&null!==this._end&&this._end.month===a._end.month&&this._end.day===a._end.day)||"month"===a._type&&a._start.month===this._start.month&&this.isFullMonth()&&a.isFullMonth()||null!==a._end&&null!==this._end&&this._end.month===a._end.month&&this.endsMonth()&&a.endsMonth();break;case "week":b=a._start.week===this._start.week&&(a._end===this._end||null!==this._end&&null!==a._end&& a._end.week===this._end.week);break;case "month":b="day"===a._type&&this._start.month===a._start.month&&a.startsMonth()&&(null===this._end&&null!==a._end&&this._start.month===a._end.month&&a.endsMonth()||null!==this._end&&null!==a._end&&this._end.month===a._end.month&&a.endsMonth())||"month"===a._type&&a._start.month===this._start.month&&(null===this._end&&null===a._end||null!==this._end&&null!==a._end&&this._end.month===a._end.month);break;case "holiday":b=a._start.holiday===this._start.holiday}return b}; c.WideInterval.prototype.getTimeForHumans=function(){switch(this._type){case "day":var a=null!=this._end?q.translate("every week from %s %u to %s %u").withContext("yohours/timespan").fetch(q.translate(c.IRL_MONTHS[this._start.month-1]).withContext("yohours").fetch(),this._start.day,this._start.month!==this._end.month?q.translate(c.IRL_MONTHS[this._end.month-1]).withContext("yohours").fetch():"",this._end.day):q.translate("day %s %u").withContext("yohours/timespan").fetch(q.translate(c.IRL_MONTHS[this._start.month- 1]).withContext("yohours").fetch(),this._start.day);break;case "week":a=null!=this._end?q.translate("every week from week %u to %u").withContext("yohours/timespan").fetch(this._start.week,this._end.week):q.translate("week %u").withContext("yohours/timespan").fetch(this._start.week);break;case "month":a=null!=this._end?q.translate("every week from %s to %s").withContext("yohours/timespan").fetch(q.translate(c.IRL_MONTHS[this._start.month-1]).withContext("yohours").fetch(),q.translate(c.IRL_MONTHS[this._end.month- 1]).withContext("yohours").fetch()):q.translate("every week in %s").withContext("yohours/timespan").fetch(q.translate(c.IRL_MONTHS[this._start.month-1]).withContext("yohours").fetch());break;case "holiday":if("SH"===this._start.holiday)a=q.translate("every week during school holidays").withContext("yohours/timespan").fetch();else if("PH"===this._start.holiday)a=q.translate("every public holidays").withContext("yohours/timespan").fetch();else if("easter"===this._start.holiday)a=q.translate("each easter day").withContext("yohours/timespan").fetch(); else throw Error(q.translate("Invalid holiday type: %s").withContext("yohours/notifications").fetch(this._start.holiday));break;case "always":a=q.translate("every week of year").withContext("yohours/timespan").fetch();break;default:a=q.translate("invalid time").withContext("yohours/timespan").fetch()}return a};c.WideInterval.prototype.getTimeSelector=function(){switch(this._type){case "day":var a=c.OSM_MONTHS[this._start.month-1]+" "+(10>this._start.day?"0":"")+this._start.day;null!=this._end&&(a= this._start.month===this._end.month?a+("-"+(10>this._end.day?"0":"")+this._end.day):a+("-"+c.OSM_MONTHS[this._end.month-1]+" "+(10>this._end.day?"0":"")+this._end.day));break;case "week":a="week "+(10>this._start.week?"0":"")+this._start.week;null!=this._end&&(a+="-"+(10>this._end.week?"0":"")+this._end.week);break;case "month":a=c.OSM_MONTHS[this._start.month-1];null!=this._end&&(a+="-"+c.OSM_MONTHS[this._end.month-1]);break;case "holiday":a=this._start.holiday;break;default:a=""}return a};c.WideInterval.prototype.isFullMonth= function(){return"month"===this._type&&null===this._end?!0:"day"===this._type?1===this._start.day&&null!==this._end&&this._end.month===this._start.month&&void 0!==this._end.day&&this._end.day===c.MONTH_END_DAY[this._end.month-1]:!1};c.WideInterval.prototype.startsMonth=function(){return"month"===this._type||"always"===this._type||"day"===this._type&&1===this._start.day};c.WideInterval.prototype.endsMonth=function(){return"month"===this._type||"always"===this._type||"day"===this._type&&null!==this._end&& this._end.day===c.MONTH_END_DAY[this._end.month-1]};c.WideInterval.prototype.contains=function(a){var b=!1;if(this.equals(a))b=!1;else if("always"===this._type)b=!0;else if("day"===this._type)if("day"===a._type){if(a._start.month>this._start.month||a._start.month===this._start.month&&a._start.day>=this._start.day)null!=a._end?null!=this._end&&(a._end.month<this._end.month||a._end.month===this._end.month&&a._end.day<=this._end.day)&&(b=!0):null!=this._end&&(a._start.month<this._end.month||a._start.month=== this._end.month&&a._start.day<=this._end.day)&&(b=!0)}else"month"===a._type&&(a._start.month>this._start.month||a._start.month===this._start.month&&1===this._start.day)&&(null!=a._end&&null!=this._end&&(a._end.month<this._end.month||a._end.month===this._end.month&&this._end.day===c.MONTH_END_DAY[end.month-1])?b=!0:null===a._end&&null!=this._end&&a._start.month<this._end.month&&(b=!0));else"week"===this._type?"week"===a._type&&a._start.week>=this._start.week&&(null!=a._end&&null!=this._end&&a._end.week<= this._end.week?b=!0:null==a._end&&(null!=this._end&&a._start.week<=this._end.week||a._start.week===this._start.week)&&(b=!0)):"month"===this._type&&("month"===a._type?a._start.month>=this._start.month&&(null!=a._end&&null!=this._end&&a._end.month<=this._end.month?b=!0:null==a._end&&(null!=this._end&&a._start.month<=this._end.month||a._start.month===this._start.month)&&(b=!0)):"day"===a._type&&(null!=a._end?null==this._end?a._start.month===this._start.month&&a._end.month===this._start.month&&(1<=a._start.day&& a._end.day<c.MONTH_END_DAY[a._start.month-1]||1<a._start.day&&a._end.day<=c.MONTH_END_DAY[a._start.month-1])&&(b=!0):a._start.month>=this._start.month&&a._end.month<=this._end.month&&(a._start.month>this._start.month&&a._end.month<this._end.month||a._start.month===this._start.month&&a._end.month<this._end.month&&1<a._start.day||a._start.month>this._start.month&&a._end.month===this._end.month&&a._end.day<c.MONTH_END_DAY[a._end.month-1]||1<=a._start.day&&a._end.day<c.MONTH_END_DAY[a._end.month-1]|| 1<a._start.day&&a._end.day<=c.MONTH_END_DAY[a._end.month-1])&&(b=!0):null==this._end?this._start.month===a._start.month&&(b=!0):a._start.month>=this._start.month&&a._start.month<=this._end.month&&(b=!0)));return b};c.Day=function(){this._intervals=[];this._nextInterval=0};c.Day.prototype.getAsMinutesArray=function(){var a,b=[];for(a=0;a<=c.MINUTES_MAX;a++)b[a]=!1;for(var d=0,e=this._intervals.length;d<e;d++)if(void 0!==this._intervals[d]){var h=a=null;if(this._intervals[d].getStartDay()===this._intervals[d].getEndDay()|| this._intervals[d].getEndDay()===c.DAYS_MAX&&this._intervals[d].getTo()===c.MINUTES_MAX)a=this._intervals[d].getFrom(),h=this._intervals[d].getTo();if(null!==a&&null!==h)for(;a<=h;a++)b[a]=!0;else throw console.log(this._intervals[d].getFrom()+" "+this._intervals[d].getTo()+" "+this._intervals[d].getStartDay()+" "+this._intervals[d].getEndDay()),Error(q.translate("Invalid interval").withContext("yohours/notifications").fetch());}return b};c.Day.prototype.getIntervals=function(a){if(a){a=this.getAsMinutesArray(); for(var b=[],d=-1,e=0,h=a.length;e<h;e++)0===e?a[e]&&(d=e):e===h-1?a[e]&&b.push(new c.Interval(0,0,d,e)):a[e]&&0>d?d=e:!a[e]&&0<=d&&(b.push(new c.Interval(0,0,d,e-1)),d=-1);return b}return this._intervals};c.Day.prototype.addInterval=function(a){this._intervals[this._nextInterval]=a;this._nextInterval++;return this._nextInterval-1};c.Day.prototype.editInterval=function(a,b){this._intervals[a]=b};c.Day.prototype.removeInterval=function(a){this._intervals[a]=void 0;delete this._intervals[a]};c.Day.prototype.copyIntervals= function(a){this._intervals=[];for(var b=0;b<a.length;b++)void 0!==a[b]&&0===a[b].getStartDay()&&0===a[b].getEndDay()&&this._intervals.push(r.extend(!0,{},a[b]));this._intervals=this.getIntervals(!0)};c.Day.prototype.clearIntervals=function(){this._intervals=[]};c.Day.prototype.sameAs=function(a){return a.getAsMinutesArray().equals(this.getAsMinutesArray())};c.Week=function(){this._intervals=[]};c.Week.prototype.getAsMinutesArray=function(){var a,b,d=[];for(b=0;b<=c.DAYS_MAX;b++)for(d[b]=[],a=0;a<= c.MINUTES_MAX;a++)d[b][a]=!1;for(var e=0,h=this._intervals.length;e<h;e++)if(void 0!==this._intervals[e])for(b=this._intervals[e].getStartDay();b<=this._intervals[e].getEndDay();b++){a=b===this._intervals[e].getStartDay()?this._intervals[e].getFrom():0;var g=b===this._intervals[e].getEndDay()?this._intervals[e].getTo():c.MINUTES_MAX;if(null!=a&&null!=g)for(;a<=g;a++)d[b][a]=!0}return d};c.Week.prototype.getIntervals=function(a){if(a){a=this.getAsMinutesArray();for(var b=[],d=-1,e=-1,h=0,g=a.length;h< g;h++)for(var f=0,l=a[h].length;f<l;f++)0===h&&0===f?a[h][f]&&(d=h,e=f):h===c.DAYS_MAX&&f===l-1?0<=d&&a[h][f]&&b.push(new c.Interval(d,h,e,f)):a[h][f]&&0>d?(d=h,e=f):!a[h][f]&&0<=d&&(0===f?b.push(new c.Interval(d,h-1,e,c.MINUTES_MAX)):b.push(new c.Interval(d,h,e,f-1)),e=d=-1);return b}return this._intervals};c.Week.prototype.getIntervalsDiff=function(a){var b=this.getAsMinutesArray();a=a.getAsMinutesArray();for(var d={open:[],closed:[]},e=-1,h=-1,g,f,l,k=0;k<=c.DAYS_MAX;k++){g=!1;f=0;for(l=d.open.length;f<= c.MINUTES_MAX;)g?(0===k&&0===f?b[k][f]&&(e=k,h=f):k===c.DAYS_MAX&&f===c.MINUTES_MAX?0<=e&&b[k][f]&&d.open.push(new c.Interval(e,k,h,f)):b[k][f]&&0>e?(e=k,h=f):!b[k][f]&&0<=e&&(0===f?d.open.push(new c.Interval(e,k-1,h,c.MINUTES_MAX)):d.open.push(new c.Interval(e,k,h,f-1)),h=e=-1),f++):(g=b[k][f]?!a[k][f]:a[k][f])?f=0:f++;!g&&-1<e&&(d.open.push(new c.Interval(e,k-1,h,c.MINUTES_MAX)),h=e=-1);g&&-1===e&&l===d.open.length&&(0<d.closed.length&&d.closed[d.closed.length-1].getEndDay()===k-1?d.closed[d.closed.length- 1]=new c.Interval(d.closed[d.closed.length-1].getStartDay(),k,0,c.MINUTES_MAX):d.closed.push(new c.Interval(k,k,0,c.MINUTES_MAX)))}return d};c.Week.prototype.addInterval=function(a){this._intervals[this._intervals.length]=a;return this._intervals.length-1};c.Week.prototype.editInterval=function(a,b){this._intervals[a]=b};c.Week.prototype.removeInterval=function(a){this._intervals[a]=void 0;delete this._intervals[a]};c.Week.prototype.removeIntervalsDuringDay=function(a){for(var b,d=this._intervals.length, e,h=0;h<d;h++)if(b=this._intervals[h],void 0!==b&&b.getStartDay()<=a&&b.getEndDay()>=a&&(e=b.getEndDay()-b.getStartDay(),1<e||0===e||b.getStartDay()===a||b.getFrom()<=b.getTo()))1<=b.getEndDay()-b.getStartDay()&&b.getFrom()<=b.getTo()&&(b.getStartDay()<a&&this.addInterval(new c.Interval(b.getStartDay(),a-1,b.getFrom(),1440)),b.getEndDay()>a&&this.addInterval(new c.Interval(a+1,b.getEndDay(),0,b.getTo()))),this.removeInterval(h)};c.Week.prototype.copyIntervals=function(a){this._intervals=[];for(var b= 0;b<a.length;b++)void 0!==a[b]&&this._intervals.push(r.extend(!0,{},a[b]))};c.Week.prototype.sameAs=function(a){return a.getAsMinutesArray().equals(this.getAsMinutesArray())};c.DateRange=function(a){this._wideInterval=null;this._typical=void 0;this.updateRange(a)};c.DateRange.prototype.definesTypicalDay=function(){return this._typical instanceof c.Day};c.DateRange.prototype.definesTypicalWeek=function(){return this._typical instanceof c.Week};c.DateRange.prototype.getTypical=function(){return this._typical}; c.DateRange.prototype.getInterval=function(){return this._wideInterval};c.DateRange.prototype.updateRange=function(a){this._wideInterval=null!=a?a:(new c.WideInterval).always();if(void 0===this._typical)switch(this._wideInterval.getType()){case "day":null===this._wideInterval.getEnd()?this._typical=new c.Day:this._typical=new c.Week;break;case "week":this._typical=new c.Week;break;case "month":this._typical=new c.Week;break;case "holiday":"SH"===this._wideInterval.getStart().holiday?this._typical= new c.Week:this._typical=new c.Day;break;case "always":this._typical=new c.Week;break;default:throw Error("Invalid interval type: "+this._wideInterval.getType());}};c.DateRange.prototype.hasSameTypical=function(a){return this.definesTypicalDay()===a.definesTypicalDay()&&this._typical.sameAs(a.getTypical())};c.DateRange.prototype.isGeneralFor=function(a){return a.definesTypicalDay()===this.definesTypicalDay()&&this._wideInterval.contains(a.getInterval())};c.OhTime=function(a,b){this._start=0<=a?a: null;this._end=0<=b&&b!==a?b:null};c.OhTime.prototype.get=function(){return null===this._start&&null===this._end?"off":this._timeString(this._start)+(null==this._end?"":"-"+this._timeString(this._end))};c.OhTime.prototype.getStart=function(){return null===this._start?null:this._start.toString()};c.OhTime.prototype.getEnd=function(){return null===this._end?null:this._end.toString()};c.OhTime.prototype.equals=function(a){return this.getStart()===a.getStart()&&this.getEnd()===a.getEnd()};c.OhTime.prototype._timeString= function(a){var b=Math.floor(a/60);a%=60;return(10>b?"0":"")+b+":"+(10>a?"0":"")+a};c.OhDate=function(a,b,d){this._wideType=b;this._wide=a;this._weekdays=d.sort();this._wdOver=[];if(null===a||null===b||null===d)throw Error(q.translate("Missing parameter").withContext("yohours/notifications").fetch());};c.OhDate.prototype.getWideType=function(){return this._wideType.toString()};c.OhDate.prototype.getWideValue=function(){return this._wide.toString()};c.OhDate.prototype.getWd=function(){return this._weekdays}; c.OhDate.prototype.getWdOver=function(){return this._wdOver};c.OhDate.prototype.sameWd=function(a){return a.equals(this._weekdays)};c.OhDate.prototype.getWeekdays=function(){var a="",b=this._weekdays.concat(this._wdOver).sort();0<b.length&&parseInt(b[0])===c.PH_WEEKDAY&&(a="PH",b.shift());if(0<b.length&&b.contains(6)&&b.contains(0)&&(b.contains(5)||b.contains(1))){var d=6;var e=b.length-2;for(var h=!1;!h&&0<=e;)b[e]===b[e+1]-1?(d=b[e],e--):h=!0;e=1;h=!1;for(var g=0;!h&&e<b.length;)b[e-1]===b[e]-1? (g=b[e],e++):h=!0;if(3<=7-d+g+1&&d>g)for(0<a.length&&(a+=","),a+=c.OSM_DAYS[d]+"-"+c.OSM_DAYS[g],e=0;e<b.length;)b[e]<=g||b[e]>=d?b.splice(e,1):e++}if(1<b.length||1===b.length&&-1!==b[0])for(a+=0<a.length?","+c.OSM_DAYS[b[0]]:c.OSM_DAYS[b[0]],d=b[0],e=1;e<b.length;e++)b[e-1]!==b[e]-1?(d!==b[e-1]&&(a=1===b[e-1]-d?a+(","+c.OSM_DAYS[b[e-1]]):a+("-"+c.OSM_DAYS[b[e-1]])),a+=","+c.OSM_DAYS[b[e]],d=b[e]):e===b.length-1&&(a=1===b[e]-d?a+(","+c.OSM_DAYS[b[e]]):a+("-"+c.OSM_DAYS[b[e]]));"Mo-Su"===a&&(a=""); return a};c.OhDate.prototype.sameKindAs=function(a){return this._wideType===a.getWideType()&&a.sameWd(this._weekdays)};c.OhDate.prototype.equals=function(a){return a instanceof c.OhDate&&this._wideType===a.getWideType()&&this._wide===a.getWideValue()&&a.sameWd(this._weekdays)};c.OhDate.prototype.addWeekday=function(a){this._weekdays.contains(a)||this._wdOver.contains(a)||(this._weekdays.push(a),this._weekdays=this._weekdays.sort())};c.OhDate.prototype.addPhWeekday=function(){this.addWeekday(c.PH_WEEKDAY)}; c.OhDate.prototype.addOverwrittenWeekday=function(a){this._wdOver.contains(a)||this._weekdays.contains(a)||(this._wdOver.push(a),this._wdOver=this._wdOver.sort())};c.OhRule=function(){this._date=[];this._time=[]};c.OhRule.prototype.getDate=function(){return this._date};c.OhRule.prototype.getTime=function(){return this._time};c.OhRule.prototype.get=function(){var a,b="";if(1<this._date.length||""!==this._date[0].getWideValue()){var d=0;for(a=this._date.length;d<a;d++)0<d&&(b+=","),b+=this._date[d].getWideValue()}0< this._date.length&&(d=this._date[0].getWeekdays(),0<d.length&&(b+=" "+d));if(0<this._time.length)for(b+=" ",d=0,a=this._time.length;d<a;d++)0<d&&(b+=","),b+=this._time[d].get();else b+=" off";"00:00-24:00"===b.trim()&&(b="24/7");return b.trim()};c.OhRule.prototype.sameTime=function(a){if(void 0===a||null==a||a.getTime().length!==this._time.length)return!1;for(var b=0,d=this._time.length;b<d;b++)if(!this._time[b].equals(a.getTime()[b]))return!1;return!0};c.OhRule.prototype.isOff=function(){return 0=== this._time.length||1===this._time.length&&null===this._time[0].getStart()};c.OhRule.prototype.hasOverwrittenWeekday=function(){return 0<this._date.length&&0<this._date[0]._wdOver.length};c.OhRule.prototype.addWeekday=function(a){for(var b=0;b<this._date.length;b++)this._date[b].addWeekday(a)};c.OhRule.prototype.addPhWeekday=function(){for(var a=0;a<this._date.length;a++)this._date[a].addPhWeekday()};c.OhRule.prototype.addOverwrittenWeekday=function(a){for(var b=0;b<this._date.length;b++)this._date[b].addOverwrittenWeekday(a)}; c.OhRule.prototype.addDate=function(a){if(null===a||void 0===a||!(a instanceof c.OhDate))throw Error(q.translate("Invalid parameter").withContext("yohours/notifications").fetch());if(0===this._date.length||"always"!==this._date[0].getWideType()&&this._date[0].sameKindAs(a))this._date.push(a);else if(1!==this._date.length||"always"!==this._date[0].getWideType()||!this._date[0].sameWd(a.getWd()))throw Error(q.translate("This date can't be added to this rule").withContext("yohours/notifications").fetch()); };c.OhRule.prototype.addTime=function(a){if(0!==this._time.length&&"off"===this._time[0].get()||this._time.contains(a))throw Error(q.translate("This time can't be added to this rule").withContext("yohours/notifications").fetch());this._time.push(a)};c.OpeningHoursBuilder=function(){};c.OpeningHoursBuilder.prototype.build=function(a){var b=[],d;var e=0;for(var h=a.length;e<h;e++){var g=a[e];if(void 0!==g){var f=d=null;for(var l=e-1;0<=l&&null==d;){if(void 0!==a[l]){var k=a[l].isGeneralFor(g);a[l].hasSameTypical(g)&& (a[l].getInterval().equals(g.getInterval())||k)?d=l:k&&a[l].definesTypicalWeek()&&g.definesTypicalWeek()&&(f=l)}l--}if(0===e||null==d)for(g=g.definesTypicalWeek()?null!=f?this._buildWeekDiff(g,a[f]):this._buildWeek(g):this._buildDay(g),f=0,l=g.length;f<l;f++){d=g[f];var p=!1;for(k=0;!p&&k<b.length;)if(b[k].sameTime(d))try{for(var n=0,t=d.getDate().length;n<t;n++)b[k].addDate(d.getDate()[n]);p=!0}catch(m){"holiday"===d.getDate()[0].getWideType()&&"PH"===d.getDate()[0].getWideValue()&&"always"===b[k].getDate()[0].getWideType()? (b[k].addPhWeekday(),p=!0):"holiday"===b[k].getDate()[0].getWideType()&&"PH"===b[k].getDate()[0].getWideValue()&&"always"===d.getDate()[0].getWideType()?(d.addPhWeekday(),b[k]=d,p=!0):k++}else k++;p||b.push(d);if(f===l-1&&d.hasOverwrittenWeekday()){k=new c.OhRule;for(p=0;p<d.getDate().length;p++)k.addDate(new c.OhDate(d.getDate()[p].getWideValue(),d.getDate()[p].getWideType(),d.getDate()[p].getWdOver()));k.addTime(new c.OhTime);g.push(k);l++}}}}a="";k=0;for(h=b.length;k<h;k++)0<k&&(a+="; "),a+=b[k].get(); return a};c.OpeningHoursBuilder.prototype._buildDay=function(a){var b=a.getTypical().getIntervals(!0),d=new c.OhRule;a=new c.OhDate(a.getInterval().getTimeSelector(),a.getInterval().getType(),[-1]);d.addDate(a);for(var e=0,h=b.length;e<h;e++)a=b[e],void 0!==a&&d.addTime(new c.OhTime(a.getFrom(),a.getTo()));return[d]};c.OpeningHoursBuilder.prototype._buildWeek=function(a){var b=[];var d=a.getTypical().getIntervals(!0);d=this._createTimeIntervals(a.getInterval().getTimeSelector(),a.getInterval().getType(), d);a=d[2];a=this._nightMonSun(a,d[0],d[1]);var e=[];for(d=0;d<c.OSM_DAYS.length;d++)e[d]=0;for(d=0;d<a.length;d++)if(a[d].isOff()&&0===e[d])e[d]=8;else if(a[d].isOff()&&0>e[d]&&-8<e[d]){e[d]=-8;for(var h=!1,g=0;!h&&g<d;)a[g].isOff()?(a[g].addWeekday(d),h=!0):g++;h||b.push(a[d])}else if(0>=e[d]&&-8<e[d]){e[d]=d+1;g=d;var f=1;for(h=d+1;h<a.length;h++)a[d].sameTime(a[h])&&(e[h]=d+1,a[d].addWeekday(h),g=h,f++);if(1===f)b.push(a[d]);else if(2===f)a[d].addWeekday(g),b.push(a[d]);else if(2<f){for(h=d+1;h< g;h++)0===e[h]&&(e[h]=-d-1,a[d].addOverwrittenWeekday(h));a[d].addWeekday(g);b.push(a[d])}}return b=this._mergeDays(b)};c.OpeningHoursBuilder.prototype._buildWeekDiff=function(a,b){var d,e,h=a.getTypical().getIntervalsDiff(b.getTypical()),g=this._createTimeIntervals(a.getInterval().getTimeSelector(),a.getInterval().getType(),h.open),f=g[0],l=g[1];g=g[2];var k=0;for(e=h.closed.length;k<e;k++){var p=h.closed[k];for(d=p.getStartDay();d<=p.getEndDay();d++)g[d].addTime(new c.OhTime)}g=this._nightMonSun(g, f,l);h=[];for(k=0;k<c.OSM_DAYS.length;k++)h[k]=0;f=[];for(k=0;k<g.length;k++)if(g[k].isOff()&&1===g[k].getTime().length){h[k]=-8;d=!1;for(l=0;!d&&l<k;)g[l].isOff()&&1===g[l].getTime().length?(g[l].addWeekday(k),d=!0):l++;d||f.push(g[k])}else if(g[k].isOff()&&0===g[k].getTime().length)h[k]=8;else if(0>=h[k]&&-8<h[k]){h[k]=k+1;l=1;e=k;f.push(g[k]);for(d=k+1;d<g.length;d++)g[k].sameTime(g[d])&&(h[d]=k+1,g[k].addWeekday(d),e=d,l++);if(1===l)f.push(g[k]);else if(2===l)g[k].addWeekday(e),f.push(g[k]);else if(2< l){for(d=k+1;d<e;d++)0===h[d]&&(h[d]=-k-1,0<g[d].getTime().length&&g[k].addOverwrittenWeekday(d));g[k].addWeekday(e);f.push(g[k])}}return f=this._mergeDays(f)};c.OpeningHoursBuilder.prototype._mergeDays=function(a){if(0===a.length)return a;var b=[];b.push(a[0]);for(var d,e=1;e<a.length;e++){var h=!1;for(d=0;!h&&d<e;){if(a[d].sameTime(a[e])){h=a[e].getDate()[0].getWd();for(var g=0;g<h.length;g++)a[d].addWeekday(h[g]);h=!0}d++}h||b.push(a[e])}return b};c.OpeningHoursBuilder.prototype._createTimeIntervals= function(a,b,d){var e,h=-1,g=-1,f=[];for(e=0;7>e;e++)f.push(new c.OhRule),f[e].addDate(new c.OhDate(a,b,[e]));e=0;for(b=d.length;e<b;e++)if(a=d[e],void 0!==a){a.getStartDay()===c.DAYS_MAX&&a.getEndDay()===c.DAYS_MAX&&a.getTo()===c.MINUTES_MAX&&(g=a.getFrom());0===a.getStartDay()&&0===a.getEndDay()&&0===a.getFrom()&&(h=a.getTo());try{if(a.getStartDay()===a.getEndDay())f[a.getStartDay()].addTime(new c.OhTime(a.getFrom(),a.getTo()));else if(1===a.getEndDay()-a.getStartDay())a.getFrom()>a.getTo()?f[a.getStartDay()].addTime(new c.OhTime(a.getFrom(), a.getTo())):(f[a.getStartDay()].addTime(new c.OhTime(a.getFrom(),c.MINUTES_MAX)),f[a.getEndDay()].addTime(new c.OhTime(0,a.getTo())));else for(var l=a.getStartDay(),k=a.getEndDay();l<=k;l++)l===a.getStartDay()?f[l].addTime(new c.OhTime(a.getFrom(),c.MINUTES_MAX)):l===a.getEndDay()?f[l].addTime(new c.OhTime(0,a.getTo())):f[l].addTime(new c.OhTime(0,c.MINUTES_MAX))}catch(p){console.warn(p)}}return[h,g,f]};c.OpeningHoursBuilder.prototype._nightMonSun=function(a,b,d){0<=b&&0<=d&&b<d&&(a[0].getTime().sort(this._sortOhTime), a[6].getTime().sort(this._sortOhTime),a[6].getTime()[a[6].getTime().length-1]=new c.OhTime(d,b),a[0].getTime().shift());return a};c.OpeningHoursBuilder.prototype._sortOhTime=function(a,b){return a.getStart()-b.getStart()};c.OpeningHoursParser=function(){};c.OpeningHoursParser.prototype.parse=function(a){var b=[];a=a.split(";");for(var d,e,h,g,f,l,k,p,n,t,m,v,x=0,z=a.length;x<z;x++)if(d=a[x].trim(),0!==d.length){e=this._tokenize(d);h=e.length-1;g=d=null;0<=h&&this._isRuleModifier(e[h])&&(d=e[h].toLowerCase(), h--);k=[];if(0<=h&&this._isTime(e[h])){g=e[h];if("24/7"===g)k.push({from:0,to:1440});else for(g=g.split(","),n=0,m=g.length;n<m;n++)f=g[n].split("-"),l=this._asMinutes(f[0]),f=1<f.length?this._asMinutes(f[1]):l,k.push({from:l,to:f});h--}n=[];l=[];if("24/7"===g)l.push({from:0,to:6});else if(0<=h&&this._isWeekday(e[h])){g=e[h];g=g.split(",");m=0;for(f=g.length;m<f;m++)if(p=g[m],c.RGX_HOLIDAY.test(p))n.push(p);else if(c.RGX_WD.test(p)){p=p.split("-");var u=c.OSM_DAYS.indexOf(p[0]);p=1<p.length?c.OSM_DAYS.indexOf(p[1]): u;l.push({from:u,to:p})}else throw Error(q.translate("Invalid weekday interval: %s").withContext("yohours/notifications").fetch(p));h--}g=[];m=[];if(0<=h){f=e[0];for(u=1;u<=h;u++)f+=" "+e[u];if(0<f.length){f=f.replace(/:$/g,"").split("week");u=f[0].trim();0===u.length&&(u=null);1<f.length?(f=f[1].trim(),0===f.length&&(f=null)):f=null;if(null!=u&&null!=f)throw Error(q.translate("Unsupported simultaneous month and week selector").withContext("yohours/notifications").fetch());if(null!=u){u=u.split(","); t=0;for(var D=u.length;t<D;t++)if(f=u[t],"SH"===f)m.push({holiday:"SH"});else if(c.RGX_MONTH.test(f)){f=f.split("-");p=c.OSM_MONTHS.indexOf(f[0])+1;if(1>p)throw Error(q.translate("Invalid month: %s").withContext("yohours/notifications").fetch(f[0]));if(1<f.length){if(v=c.OSM_MONTHS.indexOf(f[1])+1,1>v)throw Error(q.translate("Invalid month: %s").withContext("yohours/notifications").fetch(f[1]));}else v=null;m.push({from:p,to:v})}else if(c.RGX_MONTHDAY.test(f)){f=f.replace(/:/g,"").split("-");p=f[0].split(" "); p={day:parseInt(p[1],10),month:c.OSM_MONTHS.indexOf(p[0])+1};if(1>p.month)throw Error(q.translate("Invalid month: %s").withContext("yohours/notifications").fetch(p[0]));if(1<f.length)if(v=f[1].split(" "),1===v.length)v={day:parseInt(v[0],10),month:p.month};else{if(v={day:parseInt(v[1],10),month:c.OSM_MONTHS.indexOf(v[0])+1},1>v.month)throw Error(q.translate("Invalid month: %s").withContext("yohours/notifications").fetch(v[0]));}else v=null;m.push({fromDay:p,toDay:v})}else throw Error(q.translate("Unsupported month selector: %s").withContext("yohours/notifications").fetch(f)); }else if(null!=f)for(f=f.split(","),p=0,v=f.length;p<v;p++)t=f[p].split("-"),u=parseInt(t[0],10),t=1<t.length?parseInt(t[1],10):null,g.push({from:u,to:t});else throw Error(q.translate("Invalid date selector").withContext("yohours/notifications").fetch());}}if(h===e.length-1)throw Error(q.translate("Unreadable string").withContext("yohours/notifications").fetch());e=[];if(0<m.length)for(g=0,u=m.length;g<u;g++)f=m[g],void 0!==f.holiday?e.push((new c.WideInterval).holiday(f.holiday)):(h=void 0!==f.fromDay? null!=f.toDay?(new c.WideInterval).day(f.fromDay.day,f.fromDay.month,f.toDay.day,f.toDay.month):(new c.WideInterval).day(f.fromDay.day,f.fromDay.month):null!=f.to?(new c.WideInterval).month(f.from,f.to):(new c.WideInterval).month(f.from),e.push(h));else if(0<g.length)for(m=0,f=g.length;m<f;m++)h=null!=g[m].to?(new c.WideInterval).week(g[m].from,g[m].to):(new c.WideInterval).week(g[m].from),e.push(h);else if(0<n.length)for(h=0,f=n.length;h<f;h++)e.push((new c.WideInterval).holiday(n[h])),"PH"===n[h]&& 0<l.length&&0===m.length&&0===g.length&&e.push((new c.WideInterval).always());else e.push((new c.WideInterval).always());0===l.length&&(0===n.length||1===n.length&&"SH"===n[0]?l.push({from:0,to:c.OSM_DAYS.length-1}):l.push({from:0,to:0}));0===k.length&&k.push({from:0,to:1440});n=0;for(h=e.length;n<h;n++){g=!1;for(m=0;m<b.length&&!g;)b[m].getInterval().equals(e[n])?g=!0:m++;if(g)g=b[m];else{g=new c.DateRange(e[n]);f=-1;for(m=0;m<b.length;m++)b[m].isGeneralFor(new c.DateRange(e[n]))&&(f=m);0<=f&&g.definesTypicalWeek()&& g.getTypical().copyIntervals(b[f].getTypical().getIntervals());b.push(g)}m=0;for(f=l.length;m<f;m++){if(l[m].from<=l[m].to)u=l[m].from;else{for(u=l[m].from;6>=u;u++)g.definesTypicalWeek()?g.getTypical().removeIntervalsDuringDay(u):g.getTypical().clearIntervals();u=0}for(;u<=l[m].to;u++)g.definesTypicalWeek()?g.getTypical().removeIntervalsDuringDay(u):g.getTypical().clearIntervals();u=0;for(p=k.length;u<p;u++)"closed"===d||"off"===d?this._removeInterval(g.getTypical(),l[m],k[u]):this._addInterval(g.getTypical(), l[m],k[u])}}}return b};c.OpeningHoursParser.prototype._removeInterval=function(a,b,d){if(b.from<=b.to)var e=b.from;else{for(e=b.from;6>=e;e++)this._removeIntervalWd(a,d,e);e=0}for(;e<=b.to;e++)this._removeIntervalWd(a,d,e)};c.OpeningHoursParser.prototype._removeIntervalWd=function(a,b,d){b.to>=b.from?a.removeInterval(new c.Interval(d,d,b.from,b.to)):6>d?a.removeInterval(new c.Interval(d,d+1,b.from,b.to)):(a.removeInterval(new c.Interval(d,d,b.from,1440)),a.removeInterval(new c.Interval(0,0,0,b.to)))}; c.OpeningHoursParser.prototype._addInterval=function(a,b,d){a instanceof c.Day&&(0!==b.from||0!==b.to&&d.from<=d.to)&&(b=r.extend({},b),b.from=0,b.to=d.from<=d.to?0:1);if(b.from<=b.to)var e=b.from;else{for(e=b.from;6>=e;e++)this._addIntervalWd(a,d,e);e=0}for(;e<=b.to;e++)this._addIntervalWd(a,d,e)};c.OpeningHoursParser.prototype._addIntervalWd=function(a,b,d){b.to>=b.from?a.addInterval(new c.Interval(d,d,b.from,b.to)):6>d?a.addInterval(new c.Interval(d,d+1,b.from,b.to)):(a.addInterval(new c.Interval(d, d,b.from,1440)),a.addInterval(new c.Interval(0,0,0,b.to)))};c.OpeningHoursParser.prototype._asMinutes=function(a){a=a.split(":");return 60*parseInt(a[0],10)+parseInt(a[1],10)};c.OpeningHoursParser.prototype._isWeekday=function(a){return c.RGX_WEEKDAY.test(a)};c.OpeningHoursParser.prototype._isTime=function(a){return c.RGX_TIME.test(a)};c.OpeningHoursParser.prototype._isRuleModifier=function(a){return c.RGX_RULE_MODIFIER.test(a)};c.OpeningHoursParser.prototype._tokenize=function(a){a=a.trim().split(" "); for(var b=r.inArray("",a);~b;)a.splice(b,1),b=r.inArray("",a);return a};c.OpeningHoursParser.prototype._printIntervals=function(a,b){console.log("From: "+a);if(0<b.length){console.log("-------------------------");for(var d=0;d<b.length;d++)void 0===b[d]?console.log(d+": undefined"):console.log(d+": "+b[d].getStartDay()+", "+b[d].getEndDay()+", "+b[d].getFrom()+", "+b[d].getTo());console.log("-------------------------")}else console.log("Empty intervals")};c.YoHoursChecker=function(){this._parser= new c.OpeningHoursParser};c.YoHoursChecker.prototype.canRead=function(a){var b=!1;try{null!=this._parser.parse(a)&&(b=!0)}catch(d){}return b};c.options={bootstrapVersion:"bootstrap3",delay:700,height:600,locale:"en",minimal:!1};c.templates={iconClock:"<strong>&#x1f556;</strong>",iconPencil:"&#x1F589;",iconTrash:"&#x1F5D1;",bootstrap3:{inputGroup:'<div class="input-group">\n\t<input type="text" class="form-control" id="toReplace">\n\t<span class="input-group-btn">\n\t\t<button class="btn btn-default" type="button" role="button" data-toggle="collapse" data-target="#{$prefix|default:\'\'}yo-hours-collapse"\n\t\t\t\taria-expanded="false" aria-controls="{$prefix|default:\'\'}yo-hours-collapse">\n\t\t\t{$iconClock|default:\'<strong>&#x1f556;</strong>\'}\n\t\t</button>\n\t</span>\n</div>\n<div id="{$prefix|default:\'\'}yo-hours-collapse" class="yo-hours-collapse collapse in">\n\t<div id="{$prefix|default:\'\'}yo-hours-range-nav"></div>\n\t\n\t<div class="tab-content">\n\t\t<div class="tab-pane active">\n\t\t\t<nav class="navbar navbar-default">\n\t\t\t\t<div class="navbar-header">\n\t\t\t\t\t<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"\n\t\t\t\t\t\t\tdata-target="#{$prefix|default:\'\'}yo-hours-nav" aria-expanded="false"\n\t\t\t\t\t\t\taria-controls="{$prefix|default:\'\'}yo-hours-nav">\n\t\t\t\t\t\t<span class="sr-only">{"Toggle navigation"|t}</span>\n\t\t\t\t\t\t<span class="icon-bar"></span>\n\t\t\t\t\t\t<span class="icon-bar"></span>\n\t\t\t\t\t\t<span class="icon-bar"></span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<div class="collapse navbar-collapse" id="{$prefix|default:\'\'}yo-hours-nav">\n\t\t\t\t\t<p class="navbar-text">{"Calendar defining"|t} <span id="{$prefix|default:\'\'}yo-hours-range-text-label"></span></p>\n\t\t\t\t\t<button id="{$prefix|default:\'\'}yo-hours-range-edit" class="btn btn-default navbar-btn navbar-right" type="button">\n\t\t\t\t\t\t{$iconPencil|default:\'&#x1F589;\'}\n\t\t\t\t\t</button>\n\t\t\t\t\t<button id="{$prefix|default:\'\'}yo-hours-range-delete" class="btn btn-danger navbar-btn navbar-right" type="button">\n\t\t\t\t\t\t{$iconTrash|default:\'&#x1F5D1;\'}\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</nav>\n\t\t\t<div id="{$prefix|default:\'\'}yo-hours-calendar" class="yo-hours-calendar"></div>\n\t\t</div>\n\t</div>\n</div>', dateRangeModal:'<div class="modal fade yo-hours-daterange-modal" tabindex="-1" role="dialog">\n\t<div class="modal-dialog" role="document">\n\t\t<div class="modal-content">\n\t\t\t<form class="form-horizontal">\n\t\t\t\t<div class="modal-header">\n\t\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-label="Close">\n\t\t\t\t\t\t<span aria-hidden="true">&times;</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<h4 class="modal-title">{"Select date range"|t}</h4>\n\t\t\t\t</div>\n\t\t\t\t<div class="modal-body">\n\t\t\t\t\t<ul class="nav nav-tabs" role="tablist">\n\t\t\t\t\t\t{if !$editMode || $typicalWeek}\n\t\t\t\t\t\t\t<li role="presentation"{if !$editMode || $type == "always"} class="active"{/if}>\n\t\t\t\t\t\t\t\t<a href="#{$prefix|default:\'\'}yo-hours-date-range-tab-always" role="tab" data-toggle="tab" data-type="always">{"Always"|t}</a>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li role="presentation"{if $editMode && $type == "month"} class="active"{/if}>\n\t\t\t\t\t\t\t\t<a href="#{$prefix|default:\'\'}yo-hours-date-range-tab-month" role="tab" data-toggle="tab" data-type="month">{"Month"|t}</a>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li role="presentation"{if $editMode && $type == "week"} class="active"{/if}>\n\t\t\t\t\t\t\t\t<a href="#{$prefix|default:\'\'}yo-hours-date-range-tab-week" role="tab" data-toggle="tab" data-type="week">{"Week"|t}</a>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t<li role="presentation"{if $editMode && $type == "day"} class="active"{/if}>\n\t\t\t\t\t\t\t<a href="#{$prefix|default:\'\'}yo-hours-date-range-tab-day" role="tab" data-toggle="tab" data-type="day">{"Day"|t}</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li role="presentation"{if $editMode && $type == "holiday"} class="active"{/if}>\n\t\t\t\t\t\t\t<a href="#{$prefix|default:\'\'}yo-hours-date-range-tab-holiday" role="tab" data-toggle="tab" data-type="holiday">{"Holiday"|t}</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\n\t\t\t\t\t<div class="tab-content">\n\t\t\t\t\t\t{if !$editMode || $typicalWeek}\n\t\t\t\t\t\t\t<div class="tab-pane{if !$editMode || $type == \'always\'} active{/if}" role="tabpanel" id="{$prefix|default:\'\'}yo-hours-date-range-tab-always">\n\t\t\t\t\t\t\t\t<p class="text-info">{"This calendar will define all weeks of the year"|t}</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class="tab-pane{if $editMode && $type == \'month\'} active{/if}" role="tabpanel" id="{$prefix|default:\'\'}yo-hours-date-range-tab-month">\n\t\t\t\t\t\t\t\t<p class="text-info">{"The end month is optional"|t}</p>\n\t\t\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t\t\t<label for="{$prefix|default:\'\'}yo-hours-date-range-input-month-start" class="col-sm-2 control-label">{"Start"|t}</label>\n\t\t\t\t\t\t\t\t\t<div class="col-sm-10">\n\t\t\t\t\t\t\t\t\t\t<select id="{$prefix|default:\'\'}yo-hours-date-range-input-month-start" class="form-control input-sm">\n\t\t\t\t\t\t\t\t\t\t\t<option value="1"{if $editMode && $type == "month" && $start.month == 1} selected{/if}>{"January"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="2"{if $editMode && $type == "month" && $start.month == 2} selected{/if}>{"February"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="3"{if $editMode && $type == "month" && $start.month == 3} selected{/if}>{"March"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="4"{if $editMode && $type == "month" && $start.month == 4} selected{/if}>{"April"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="5"{if $editMode && $type == "month" && $start.month == 5} selected{/if}>{"May"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="6"{if $editMode && $type == "month" && $start.month == 6} selected{/if}>{"June"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="7"{if $editMode && $type == "month" && $start.month == 7} selected{/if}>{"July"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="8"{if $editMode && $type == "month" && $start.month == 8} selected{/if}>{"August"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="9"{if $editMode && $type == "month" && $start.month == 9} selected{/if}>{"September"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="10"{if $editMode && $type == "month" && $start.month == 10} selected{/if}>{"October"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="11"{if $editMode && $type == "month" && $start.month == 11} selected{/if}>{"November"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="12"{if $editMode && $type == "month" && $start.month == 12} selected{/if}>{"December"|t}</option>\n\t\t\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\n\t\t\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t\t\t<label for="{$prefix|default:\'\'}yo-hours-date-range-input-month-end" class="col-sm-2 control-label">{"End"|t}</label>\n\t\t\t\t\t\t\t\t\t<div class="col-sm-10">\n\t\t\t\t\t\t\t\t\t\t<select id="{$prefix|default:\'\'}yo-hours-date-range-input-month-end" class="form-control input-sm">\n\t\t\t\t\t\t\t\t\t\t\t<option value="0"{if !$editMode || $type != "month" || !$end.month} selected{/if}></option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="1"{if $editMode && $type == "month" && $end.month == 1} selected{/if}>{"January"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="2"{if $editMode && $type == "month" && $end.month == 2} selected{/if}>{"February"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="3"{if $editMode && $type == "month" && $end.month == 3} selected{/if}>{"March"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="4"{if $editMode && $type == "month" && $end.month == 4} selected{/if}>{"April"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="5"{if $editMode && $type == "month" && $end.month == 5} selected{/if}>{"May"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="6"{if $editMode && $type == "month" && $end.month == 6} selected{/if}>{"June"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="7"{if $editMode && $type == "month" && $end.month == 7} selected{/if}>{"July"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="8"{if $editMode && $type == "month" && $end.month == 8} selected{/if}>{"August"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="9"{if $editMode && $type == "month" && $end.month == 9} selected{/if}>{"September"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="10"{if $editMode && $type == "month" && $end.month == 10} selected{/if}>{"October"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="11"{if $editMode && $type == "month" && $end.month == 11} selected{/if}>{"November"|t}</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value="12"{if $editMode && $type == "month" && $end.month == 12} selected{/if}>{"December"|t}</option>\n\t\t\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class="tab-pane{if $editMode && $type == \'week\'} active{/if}" role="tabpanel" id="{$prefix|default:\'\'}yo-hours-date-range-tab-week">\n\t\t\t\t\t\t\t\t<p class="text-info">{"The end week is optional"|t}</p>\n\t\t\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t\t\t<label for="{$prefix|default:\'\'}yo-hours-date-range-input-week-start" class="col-sm-2 control-label">{"Start"|t}</label>\n\t\t\t\t\t\t\t\t\t<div class="col-sm-10">\n\t\t\t\t\t\t\t\t\t\t<input type="number" class="form-control input-sm" min="1" max="53" step="1"\n\t\t\t\t\t\t\t\t\t\t\t value="{$start.week|default:1}" id="{$prefix|default:\'\'}yo-hours-date-range-input-week-start">\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t\t\t<label for="{$prefix|default:\'\'}yo-hours-date-range-input-week-end" class="col-sm-2 control-label">{"End"|t}</label>\n\t\t\t\t\t\t\t\t\t<div class="col-sm-10">\n\t\t\t\t\t\t\t\t\t\t<input type="number" class="form-control input-sm" min="1" max="53" step="1"\n\t\t\t\t\t\t\t\t\t\t\t value="{$end.week|default:\'\'}" id="{$prefix|default:\'\'}yo-hours-date-range-input-week-end">\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t<div class="tab-pane{if $editMode && $type == \'day\'} active{/if}" role="tabpanel" id="{$prefix|default:\'\'}yo-hours-date-range-tab-day">\n\t\t\t\t\t\t\t{if !$editMode || $typicalWeek}\n\t\t\t\t\t\t\t\t<p class="text-info">{"The end day is optional"|t}</p>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t\t<label for="{$prefix|default:\'\'}yo-hours-date-range-input-day-startday" class="col-sm-2 control-label">{"Start"|t}</label>\n\t\t\t\t\t\t\t\t<div class="col-sm-10 input-group">\n\t\t\t\t\t\t\t\t\t<input type="number" class="form-control input-sm" min="1" max="31" step="1"\n\t\t\t\t\t\t\t\t\t\t id="{$prefix|default:\'\'}yo-hours-date-range-input-day-startday" value="{$start.day|default:\'\'}">\n\t\t\t\t\t\t\t\t\t<div class="input-group-btn month-dropdown">\n\t\t\t\t\t\t\t\t\t\t<button type="button" class="btn btn-default btn-block dropdown-toggle"\n\t\t\t\t\t\t\t\t\t\t\t\tdata-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n\t\t\t\t\t\t\t\t\t\t\t{if $start.month}{$months[$start.month - 1]|default:{"January"|t}}{else}{"January"|t}{/if}\n\t\t\t\t\t\t\t\t\t\t\t<span class="caret"></span>\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t<input type="hidden" id="{$prefix|default:\'\'}yo-hours-date-range-input-day-startmonth" value="{$start.month|default:1}">\n\t\t\t\t\t\t\t\t\t\t<ul class="dropdown-menu dropdown-menu-right">\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 1 || !$start.month}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="1">{"January"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 2}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="2">{"February"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 3}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="3">{"March"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 4}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="4">{"April"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 5}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="5">{"May"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 6}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="6">{"June"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 7}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="7">{"July"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 8}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="8">{"August"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 9}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="9">{"September"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 10}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="10">{"October"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 11}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="11">{"November"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li {if $start.month == 12}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="12">{"December"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{if !$editMode || $typicalWeek}\n\t\t\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t\t\t<label for="{$prefix|default:\'\'}yo-hours-date-range-input-day-endday" class="col-sm-2 control-label">{"End"|t}</label>\n\t\t\t\t\t\t\t\t\t<div class="col-sm-10 input-group">\n\t\t\t\t\t\t\t\t\t\t<input type="number" class="form-control input-sm" min="1" max="31" step="1"\n\t\t\t\t\t\t\t\t\t\t\t id="{$prefix|default:\'\'}yo-hours-date-range-input-day-endday" value="{$end.day|default:\'\'}">\n\t\t\t\t\t\t\t\t\t\t<div class="input-group-btn month-dropdown">\n\t\t\t\t\t\t\t\t\t\t\t<button type="button" class="btn btn-default btn-block dropdown-toggle"\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n\t\t\t\t\t\t\t\t\t\t\t\t{if $end.month}{$months[$end.month - 1]|default:{"January"|t}}{else}{"(not set)"|t}{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t<span class="caret"></span>\n\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t\t<input type="hidden" id="{$prefix|default:\'\'}yo-hours-date-range-input-day-endmonth" value="{$end.month}">\n\t\t\t\t\t\t\t\t\t\t\t<ul class="dropdown-menu dropdown-menu-right">\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 1}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="1">{"January"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 2}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="2">{"February"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 3}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="3">{"March"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 4}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="4">{"April"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 5}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="5">{"May"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 6}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="6">{"June"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 7}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="7">{"July"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 8}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="8">{"August"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 9}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="9">{"September"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 10}class="active"{/if}>\n\t\t\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" data-value="10">{"October"|t}</a>\n\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li {if $end.month == 11}class="active"{/if}>\n\t\t\t\t\t\t\t\t\