text: "use strict";!function(angular){angular.module("chocoboRangePicker",[]).directive("chocoboRangePicker",[function(){return String.prototype.capitalizeFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)},Date.prototype.reverseFormat=function(tDate,locale){if("pt-BR"===locale||"en-GB"===locale){var formatDate=tDate.split("/");return new Date(formatDate[2],formatDate[1]-1,formatDate[0])}if("de-DE"===locale){var parts=tDate.match(/(\d+)/g);return new Date(parts[2],parts[1]-1,parts[0])}return new Date(tDate)},{require:"ngModel",restrict:"AE",scope:{options:"="},link:function(scope,elem,attrs,ngModel){function dateOperation(date,value,operation,createNewObject){var newDate=date;return"undefined"!=typeof createNewObject&&createNewObject&&(newDate=new Date(date.getTime())),operation===DATEOPERATION.DAY?newDate.setDate(newDate.getDate()+value):operation===DATEOPERATION.MONTH?newDate.setMonth(newDate.getMonth()+value):operation===DATEOPERATION.YEAR&&newDate.setFullYear(newDate.getFullYear()+value),newDate}function dateWithoutTime(date){return date.setHours(0,0,0,0),date}function updateCalendar(calendar){var calendarMonth=calendar.baseDate.getMonth(),start=new Date(calendar.baseDate.getTime());start.setDate(1),start.setDate(start.getDate()-start.getDay());var end=new Date(calendar.baseDate.getTime());end.setDate(1),end.setMonth(end.getMonth()+1),end.setDate(0),end.setDate(end.getDate()+(6-end.getDay())),calendar.weeks=[];for(var week={};scope.isBeforeOrEqual(start,end,!0);){week[start.getDay()]={date:new Date(start.getTime()),calendarMonth:start.getMonth()===calendarMonth};var SATURDAY=6;start.getDay()===SATURDAY&&(calendar.weeks.push(week),week={});var ADD_ONE_DAY=1;dateOperation(start,ADD_ONE_DAY,DATEOPERATION.DAY)}}function updateModel(){var start=new Date(scope.leftCalendar.selectedDate.getTime()),days=[],BIND_RANGE_DATE="true";if(attrs.bindrange===BIND_RANGE_DATE)for(var end=dateOperation(scope.rightCalendar.selectedDate,1,DATEOPERATION.DAY,!0);scope.isEqualsDate(start,end)===!1;)days.push(new Date(start.getTime())),dateOperation(start,1,DATEOPERATION.DAY);else days.push(start),days.push(dateOperation(scope.rightCalendar.selectedDate,0,DATEOPERATION.DAY,!0));ngModel.$setViewValue(days),ngModel.$render()}var DATEOPERATION={DAY:0,MONTH:1,YEAR:2};scope.isEqualsDate=function(a,b){return dateWithoutTime(a).getTime()===dateWithoutTime(b).getTime()},scope.isBetweenDate=function(date,a,b){return dateWithoutTime(date).getTime()>=dateWithoutTime(a).getTime()&&dateWithoutTime(date).getTime()<=dateWithoutTime(b).getTime()},scope.betweenMinMax=function(date){return scope.options.minDate&&scope.options.maxDate?scope.isBetweenDate(date,scope.options.minDate,scope.options.maxDate):scope.options.minDate?scope.isAfterOrEqual(date,scope.options.minDate):!scope.options.maxDate||scope.isBeforeOrEqual(date,scope.options.maxDate,!0)},scope.isBeforeOrEqual=function(a,b,disableVerification){if(!disableVerification){var restrict=attrs.blockweekday?attrs.blockweekday.split(","):[];return restrict.indexOf(String(dateWithoutTime(a).getDay()))===-1}return dateWithoutTime(a).getTime()<=dateWithoutTime(b).getTime()},scope.isAfterOrEqual=function(a,b){var restrict=attrs.blockweekday?attrs.blockweekday.split(","):[];return restrict.indexOf(String(dateWithoutTime(a).getDay()))===-1&&dateWithoutTime(a).getTime()>=dateWithoutTime(b).getTime()},scope.nextMonth=function(calendar){var ADD_ONE_MONTH=1;dateOperation(calendar.baseDate,ADD_ONE_MONTH,DATEOPERATION.MONTH),updateCalendar(calendar)},scope.previousMonth=function(calendar){var REMOVE_ONE_MONTH=-1;dateOperation(calendar.baseDate,REMOVE_ONE_MONTH,DATEOPERATION.MONTH),updateCalendar(calendar)},scope.weekdays=function(){var date=new Date;date.setDate(date.getDate()-date.getDay());for(var weekList=[scope.localeWeekday(date)],i=0;i<6;i++)date.setDate(date.getDate()+1),weekList.push(scope.localeWeekday(date));return weekList},scope.selectDate=function(calendar,date){calendar.baseDate=new Date(date.getTime()),calendar.selectedDate=new Date(date.getTime()),updateCalendar(calendar),updateModel()},scope.localeMonth=function(date){return date.toLocaleDateString(attrs.locale||navigator.language,{month:"long"}).capitalizeFirstLetter()},scope.localeYear=function(date){return date.toLocaleDateString(attrs.locale||navigator.language,{year:"numeric"}).capitalizeFirstLetter()},scope.localeWeekday=function(date){return date.toLocaleDateString(attrs.locale||navigator.language,{weekday:"long"}).capitalizeFirstLetter()},scope.localeDate=function(date){return date.toLocaleDateString(attrs.locale||navigator.language,{day:"2-digit",month:"2-digit",year:"numeric"})};var currentDate=dateWithoutTime(new Date);scope.leftCalendar={baseDate:new Date(currentDate.getTime()),selectedDate:new Date(currentDate.getTime()),weeks:[]},updateCalendar(scope.leftCalendar),scope.rightCalendar={baseDate:new Date(currentDate.getTime()),selectedDate:new Date(currentDate.getTime()),weeks:[]},updateCalendar(scope.rightCalendar),scope.openModal=function(){scope.isOpen=!scope.isOpen},scope.isOpen=!1,scope.iconUrl="bower_components/chocoborangepicker/public/calendar.ico";(function(){var dt=new Date;dt.setHours(0,0,0,0),ngModel.$setViewValue([dt,dt]),ngModel.$render()})();scope.setPeriod=function(start,end){scope.leftCalendar.baseDate=new Date(start.getTime()),scope.leftCalendar.selectedDate=new Date(start.getTime()),updateCalendar(scope.leftCalendar),scope.rightCalendar.baseDate=new Date(end.getTime()),scope.rightCalendar.selectedDate=new Date(end.getTime()),updateCalendar(scope.rightCalendar),updateModel()},scope.selectYear=function(){scope.setPeriod(dateOperation(currentDate,-1,DATEOPERATION.YEAR,!0),new Date(currentDate.getTime()))},scope.selectSemester=function(){scope.setPeriod(dateOperation(currentDate,-6,DATEOPERATION.MONTH,!0),new Date(currentDate.getTime()))},scope.selectTrimester=function(){scope.setPeriod(dateOperation(currentDate,-3,DATEOPERATION.MONTH,!0),new Date(currentDate.getTime()))},scope.selectMonth=function(){scope.setPeriod(dateOperation(currentDate,-1,DATEOPERATION.MONTH,!0),new Date(currentDate.getTime()))},scope.selectWeek=function(){scope.setPeriod(dateOperation(currentDate,-7,DATEOPERATION.DAY,!0),new Date(currentDate.getTime()))},scope.selectLastDay=function(){scope.setPeriod(dateOperation(currentDate,-1,DATEOPERATION.DAY,!0),new Date(currentDate.getTime()))},scope.selectToday=function(){scope.setPeriod(new Date(currentDate.getTime()),new Date(currentDate.getTime()))}},replace:!0,templateUrl:"bower_components/chocoborangepicker/chocobo-range-picker.html"}}])}(angular);