Angular.js directive for Dan Grossmans's [Bootstrap Datepicker](https://github.com/dangrossman/bootstrap-daterangepicker).
## Maintainer needed!
Hello, as you may noticed, we have troubles maintaining this repo. So if there is somebody willing to help merging PRs, testing and releasing, please contact me at lukas.marek(at)fragaria.cz.
**Beware: Use [Bootstrap Datepicker](https://github.com/dangrossman/bootstrap-daterangepicker) v 3.0.3 and newer!**

## Installation via Bower
The easiest way to install the picker is:
```
bower install angular-daterangepicker --save
```
## Manual installation
This directive depends on [Bootstrap Datepicker](https://github.com/dangrossman/bootstrap-daterangepicker), [Bootstrap](http://getbootstrap.com), [Moment.js](http://momentjs.com/) and [jQuery](http://jquery.com/).
Download dependencies above and then use [minified](js/angular-daterangepicker.min.js) or [normal](angular-daterangepicker.js) version.
## Basic usage
Assuming that bower installation directory is `bower_components`. In case of other installation directory, please update paths accordingly.
Do not forget to add a dot (.) in your model object to avoid [issues with scope inheritance](https://github.com/angular/angular.js/wiki/Understanding-Scopes). E.g. use `$scope.datePicker.date` instead of `$scope.date`.
## Advanced usage
####**Extra Options**
These are options beyond those provided in daterangepicker.
`pickerClasses` : **string**
-- additional classesadded to picker dropdown element
`cancelOnOutsideClick` : **boolean** (default: true) <sup><sub>(only applicable when autoApply==false)</sub></sup>
If true, then clicking outside of the picker, after value has been changed on calendar,
will trigger clicking cancel rather than applying value to model.
See [CONTRIBUTORS.md](https://github.com/fragaria/angular-daterangepicker/blob/master/CONTRIBUTORS.md) for all the great folks who contributed to this repo!
$('#config-text').val("$('#demo').daterangepicker("+JSON.stringify(options,null,' ')+", function(start, end, label) {\n console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});");
$('#config-demo').daterangepicker(options,function(start,end,label){console.log('New date range selected: '+start.format('YYYY-MM-DD')+' to '+end.format('YYYY-MM-DD')+' (predefined range: '+label+')');}).click();;
$('#config-text').val("$('#demo').daterangepicker("+JSON.stringify(options,null,' ')+", function(start, end, label) {\n console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});");
$('#config-demo').daterangepicker(options,function(start,end,label){console.log('New date range selected: '+start.format('YYYY-MM-DD')+' to '+end.format('YYYY-MM-DD')+' (predefined range: '+label+')');});
(f=!0,!l.prefix))returng=!1});if(c&&h.length)returna=F("timeout","Load timeout for modules: "+h,null,h),a.contextName=l.contextName,A(a);g&&y(k,function(a){J(a,{},{})});c&&!b||!f||!E&&!ja||ba||(ba=setTimeout(function(){ba=0;H()},50));aa=!1}}functionI(a){x(v,a[0])||u(q(a[0],null,!0)).init(a[1],a[2])}functionO(a){a=a.currentTarget||a.srcElement;varb=l.onScriptLoad;a.detachEvent&&!ca?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=l.onScriptError;a.detachEvent&&!ca||a.removeEventListener("error",
"Invalid require call"),f);if(a&&x(R,c))returnR[c](t[a.id]);if(g.get)returng.get(l,c,a,m);e=q(c,a,!1,!0);e=e.id;returnx(v,e)?v[e]:A(F("notloaded",'Module name "'+e+'" has not been loaded yet for context: '+b+(a?"":". Use require([])")))}P();l.nextTick(function(){P();r=u(q(null,a));r.skipMap=n.skipMap;r.init(c,d,f,{enabled:!0});H()});returnm}n=n||{};Y(m,{isBrowser:E,toUrl:function(b){vard,f=b.lastIndexOf("."),g=b.split("/")[0];-1!==f&&("."!==g&&".."!==g||1<f)&&(d=b.substring(f,b.length),b=b.substring(0,
for(B();G.length;){c=G.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}elsec[0]===a&&(b=!0);I(c)}l.defQueueMap={};c=e(t,a);if(!b&&!x(v,a)&&c&&!c.inited)if(!p.enforceDefine||g&&ia(g))I([a,d.deps||[],d.exportsFn]);elsereturnm(a)?void0:A(F("nodefine","No define call for "+a,null,[a]));H()},nameToUrl:function(a,b,c){vard,k,f,m;(d=e(p.pkgs,a))&&(a=d);if(d=e(fa,a))returnl.nameToUrl(d,b,c);if(g.jsExtRegExp.test(a))d=a+(b||"");else{d=p.paths;k=a.split("/");for(f=k.length;0<f;--f)if(m=k.slice(0,f).join("/"),
0),importScripts(d),b.completeLoad(c)}catch(q){b.onError(F("importscripts","importScripts failed for "+c+" at "+d,q,[c]))}};E&&!w.skipDataMain&&X(document.getElementsByTagName("script"),function(b){C||(C=b.parentNode);if(O=b.getAttribute("data-main"))returnu=O,w.baseUrl||-1!==u.indexOf("!")||(I=u.split("/"),u=I.pop(),T=I.length?I.join("/")+"/":"./",w.baseUrl=T),u=u.replace(U,""),g.jsExtRegExp.test(u)&&(u=O),w.deps=w.deps?w.deps.concat(u):[u],!0});define=function(b,c,d){vare,g;"string"!==typeofb&&
$('#config-text').val("$('#demo').daterangepicker("+JSON.stringify(options,null,' ')+", function(start, end, label) {\n console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});");
$('#config-demo').daterangepicker(options,function(start,end,label){console.log('New date range selected: '+start.format('YYYY-MM-DD')+' to '+end.format('YYYY-MM-DD')+' (predefined range: '+label+')');});
<liclass="nav-item"style="padding-left: 0"><aclass="nav-link"href="/"style="color: #eeeeee"><iclass="fa fa-calendar"></i> Date Range Picker</a></li>
<p>Originally created for reports at <ahref="https://www.improvely.com">Improvely</a>, the Date Range Picker can be attached to any webpage element to pop up two calendars for selecting dates, times, or predefined ranges like "Last 30 Days".</p>
<astyle="display: block; height: 300px; background: url('drp.png') top right no-repeat; background-size: cover; border: 1px solid #ccc; margin-bottom: 30px"href="https://awio.iljmp.com/5/drpdemo"title="Click for a Live Demo"></a>
<code>startDate</code> (Date or string) The beginning date of the initially selected date range. If you provide a string, it must match the date format string set in your <code>locale</code> setting.
</li>
<li>
<code>endDate</code>: (Date or string) The end date of the initially selected date range.
</li>
<li>
<code>minDate</code>: (Date or string) The earliest date a user may select.
</li>
<li>
<code>maxDate</code>: (Date or string) The latest date a user may select.
</li>
<li>
<code>maxSpan</code>: (object) The maximum span between the selected start and end dates. Check off <code>maxSpan</code> in the configuration generator for an example of how to use this. You can provide any object the <code>moment</code> library would let you add to a date.
</li>
<li>
<code>showDropdowns</code>: (true/false) Show year and month select boxes above calendars to jump to a specific month and year.
</li>
<li>
<code>minYear</code>: (number) The minimum year shown in the dropdowns when <code>showDropdowns</code> is set to true.
</li>
<li>
<code>maxYear</code>: (number) The maximum year shown in the dropdowns when <code>showDropdowns</code> is set to true.
</li>
<li>
<code>showWeekNumbers</code>: (true/false) Show localized week numbers at the start of each week on the calendars.
</li>
<li>
<code>showISOWeekNumbers</code>: (true/false) Show ISO week numbers at the start of each week on the calendars.
</li>
<li>
<code>timePicker</code>: (true/false) Adds select boxes to choose times in addition to dates.
</li>
<li>
<code>timePickerIncrement</code>: (number) Increment of the minutes selection list for times (i.e. 30 to allow only selection of times ending in 0 or 30).
</li>
<li>
<code>timePicker24Hour</code>: (true/false) Use 24-hour instead of 12-hour times, removing the AM/PM selection.
</li>
<li>
<code>timePickerSeconds</code>: (true/false) Show seconds in the timePicker.
</li>
<li>
<code>ranges</code>: (object) Set predefined date ranges the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range. Click <code>ranges</code> in the configuration generator for examples.
</li>
<li>
<code>showCustomRangeLabel</code>: (true/false) Displays "Custom Range" at
the end of the list of predefined ranges, when the <code>ranges</code> option is used.
This option will be highlighted whenever the current date range selection does not match one of the predefined ranges. Clicking it will display the calendars to select a new range.
</li>
<li>
<code>alwaysShowCalendars</code>: (true/false) Normally, if you use the <code>ranges</code> option to specify pre-defined date ranges, calendars for choosing a custom date range are not shown until the user clicks "Custom Range". When this option is set to true, the calendars for choosing a custom date range are always shown instead.
</li>
<li>
<code>opens</code>: ('left'/'right'/'center') Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to.
</li>
<li>
<code>drops</code>: ('down'/'up') Whether the picker appears below (default) or above the HTML element it's attached to.
</li>
<li>
<code>buttonClasses</code>: (string) CSS class names that will be added to both the apply and cancel buttons.
</li>
<li>
<code>applyButtonClasses</code>: (string) CSS class names that will be added only to the apply button.
</li>
<li>
<code>cancelButtonClasses</code>: (string) CSS class names that will be added only to the cancel button.
</li>
<li>
<code>locale</code>: (object) Allows you to provide localized strings for buttons and labels, customize the date format, and change the first day of week for the calendars.
Check off <code>locale</code> in the configuration generator to see how
to customize these options.
</li>
<li>
<code>singleDatePicker</code>: (true/false) Show only a single calendar to choose one date, instead of a range picker with two calendars. The start and end dates provided to your callback will be the same single date chosen.
</li>
<li>
<code>autoApply</code>: (true/false) Hide the apply and cancel buttons, and automatically apply a new date range as soon as two dates are clicked.
</li>
<li>
<code>linkedCalendars</code>: (true/false) When enabled, the two calendars displayed will always be for two sequential months (i.e. January and February), and both will be advanced when clicking the left or right arrows above the calendars. When disabled, the two calendars can be individually advanced and display any month/year.
</li>
<li>
<code>isInvalidDate</code>: (function) A function that is passed each date in the two
calendars before they are displayed, and may return true or false to indicate whether
that date should be available for selection or not.
</li>
<li>
<code>isCustomDate</code>: (function) A function that is passed each date in the two
calendars before they are displayed, and may return a string or array of CSS class names
to apply to that date's calendar cell.
</li>
<li>
<code>autoUpdateInput</code>: (true/false) Indicates whether the date range picker should
automatically update the value of the <code><input></code> element it's attached to at initialization and when the selected dates change.
</li>
<li>
<code>parentEl</code>: (string) jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body'
Several events are triggered on the element you attach the picker to, which you can listen for.
</p>
<ulclass="nobullets">
<li>
<code>show.daterangepicker</code>: Triggered when the picker is shown
</li>
<li>
<code>hide.daterangepicker</code>: Triggered when the picker is hidden
</li>
<li>
<code>showCalendar.daterangepicker</code>: Triggered when the calendar(s) are shown
</li>
<li>
<code>hideCalendar.daterangepicker</code>: Triggered when the calendar(s) are hidden
</li>
<li>
<code>apply.daterangepicker</code>: Triggered when the apply button is clicked,
or when a predefined range is clicked
</li>
<li>
<code>cancel.daterangepicker</code>: Triggered when the cancel button is clicked
</li>
</ul>
<p>
Some applications need a "clear" instead of a "cancel" functionality, which can be achieved by changing the button label and watching for the cancel event:
While passing in a callback to the constructor is the easiest way to listen for changes in the selected date range, you can also do something every time the apply button is clicked even if the selection hasn't changed:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
</p>
<p>
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
</p>
<p>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
$('#config-demo').daterangepicker(options,function(start,end,label){console.log('New date range selected: '+start.format('YYYY-MM-DD')+' to '+end.format('YYYY-MM-DD')+' (predefined range: '+label+')');});
!function(){"use strict";angular.module("avi-contact",[]),angular.module("avi-card",[]),angular.module("avi-card").controller("CardCallFormCtrl",["$scope","$http","$log",function(a,b,c){functiond(){a.options.agences=f.filter(function(b){returnb.city==a.contact.agency.city.code})}functione(){b({method:"POST",url:"/card-requests",data:angular.extend(a.contact,{status:"opened",comment:"",_perms:{r:["*"],w:["*"],d:["g:admin"]}})}).success(function(b){a.state="success"}).error(function(){a.state="error"})}varf=[{email:"casa44far@atlasvoyages.com",name:"CASA 44",code:"CASA44",address:"44, avenue de l’Armée Royale, Centre Ville, CASABLANCA",city:"CASABLANCA"},{email:"casatwincenter@atlasvoyages.com",name:"CASA TWIN CENTER",code:"CASATWINCENTER",address:"191 bd Mohamed Zerktouni Twin Center n°157 porte Maârif. Maarif 20330 CASABLANCA",city:"CASABLANCA"},{email:"casatechnopark@atlasvoyages.com",name:"CASA Technopark",code:"CASATechnopark",address:"Technopark rez de chaussée, Room 167/168 Sidi maarouf, CASABLANCA",city:"CASABLANCA"},{email:"casaanfaplace@atlasvoyages.com",name:"Anfa Place",code:"AnfaPlace",address:"S3 Centre Commercial Anfa Place, Bd La Corniche. CASABLANCA",city:"CASABLANCA"},{email:"casa150far@atlasvoyages.com",name:"CASA 150",code:"CASA150",address:"150, avenue des FAR Centre Ville, CASABLANCA",city:"CASABLANCA"},{email:"rabatagdal@atlasvoyages.com",name:"RABAT AGDAL",code:"RABATAGDAL",address:"59, avenue Ibnou Sina Appt n°1 Agdal, Rabat",city:"RABAT"},{email:"rabathayryad@atlasvoyages.com",name:"RABAT RYAD",code:"RABATRYAD",address:"Mahaj ryad n°22 - Hay Riad Rabat",city:"RABAT"},{email:"rabatlabelgallery@atlasvoyages.com",name:"Label Gallery",code:"LabelGallery",address:"Galerie commerciale « Label Gallery », Souissi, Route des Zaers, 3,5 km, rez de chaussée, local n° 16 Rabat",city:"RABAT"},{email:"fescentre@atlasvoyages.com",name:"Fès center",code:"Fescenter",address:"15 rue Bouchaib Doukkali. Fès",city:"FES"},{email:"fesborj@atlasvoyages.com",name:"Borj Fès",code:"BorjFes",address:"Centre Commercial Borj Fès. Fès",city:"FES"},{email:"tangerville@atlasvoyages.com",name:"Tanger Ville",code:"TangerVille",address:"N° 6 rés Camilia, Rue ibn Taymiya. Tanger",city:"TANGER"},{email:"tangersoccoalto@atlasvoyages.com",name:"Socco Alto",code:"SoccoAlto",address:"Centre commercial « Socco Alto », sis au quartier Californie, angle Rues Boubana et Banafsaj, rez de chaussée bas, local n° R34 Tanger",city:"TANGER"},{email:"oujda@atlasvoyages.com",name:"Oujda",code:"Oujda",address:"21 Bis Rue Melillia - oujda",city:"OUJDA"},{email:"agadir@atlasvoyages.com",name:"Agadir",code:"Agadir",address:"Immeuble Sud Bahia Avenue Hassan II. Agadir",city:"AGADIR"},{email:"marrakech@atlasvoyages.com",name:"Marrakech",code:"Marrakech",address:"131, bd. Mohammed V 40000, Marrakech",city:"MARRAKECH"},{email:"meknes@atlasvoyages.com",name:"Meknès",code:"Meknes",address:"Rue Abou Ali Ben Rahal, Meknès",city:"MEKNES"},{email:"kenitra@atlasvoyages.com",name:"Kénitra",code:"Kenitra",address:"352, Bd Mohamed V – Résidence Palace - rez de chaussée",city:"KENITRA"}];angular.extend(a,{contact:{agency:{infos:{},city:{}}},state:"form",save:e,onCityChanged:d,options:{cities:[{code:"CASABLANCA",name:"CASABLANCA"},{code:"MARRAKECH",name:"MARRAKECH"},{code:"RABAT",name:"RABAT"},{code:"FES",name:"FÉS"},{code:"AGADIR",name:"AGADIR"},{code:"TANGER",name:"TANGER"},{code:"OUJDA",name:"OUJDA"},{code:"KENITRA",name:"KÉNITRA"},{code:"MEKNES",name:"MEKNÈS"}],agences:f}})}]),angular.module("avi-contact").controller("RequestCallFormCtrl",["$scope","$http","$log",function(a,b,c){functiond(){c.debug("RequestCallFormCtrl: contact-requests onAdd"),b({method:"POST",url:"/contact-requests",data:angular.extend(a.contact,{status:"opened",_perms:{r:["*"],w:["*"],d:["g:admin"]}})}).success(function(b){a.state="success"}).error(function(){a.state="error"})}c.debug("RequestCallFormCtrl: init"),angular.extend(a,{contact:{agency:{infos:{},city:{}}},state:"form",save:d,options:{markets:["FRENCH","ENGLISH","DUTCH","OTHER"]}})}])}();
!function(){"use strict";angular.module("avi-contact",[]),angular.module("avi-card",[]),angular.module("avi-tombola",[]),angular.module("avi-card").controller("CardCallFormCtrl",["$scope","$http","$log",function(a,b,c){functiond(){a.options.agences=f.filter(function(b){returnb.city==a.contact.agency.city.code})}functione(){b({method:"POST",url:"/card-requests",data:angular.extend(a.contact,{status:"opened",comment:"",_perms:{r:["*"],w:["*"],d:["g:admin"]}})}).success(function(b){a.state="success"}).error(function(){a.state="error"})}varf=[{email:"casa44far@atlasvoyages.com",name:"CASA 44",code:"CASA44",address:"44, avenue de l’Armée Royale, Centre Ville, CASABLANCA",city:"CASABLANCA"},{email:"casatwincenter@atlasvoyages.com",name:"CASA TWIN CENTER",code:"CASATWINCENTER",address:"191 bd Mohamed Zerktouni Twin Center n°157 porte Maârif. Maarif 20330 CASABLANCA",city:"CASABLANCA"},{email:"casatechnopark@atlasvoyages.com",name:"CASA Technopark",code:"CASATechnopark",address:"Technopark rez de chaussée, Room 167/168 Sidi maarouf, CASABLANCA",city:"CASABLANCA"},{email:"casaanfaplace@atlasvoyages.com",name:"Anfa Place",code:"AnfaPlace",address:"S3 Centre Commercial Anfa Place, Bd La Corniche. CASABLANCA",city:"CASABLANCA"},{email:"casa150far@atlasvoyages.com",name:"CASA 150",code:"CASA150",address:"150, avenue des FAR Centre Ville, CASABLANCA",city:"CASABLANCA"},{email:"rabatagdal@atlasvoyages.com",name:"RABAT AGDAL",code:"RABATAGDAL",address:"59, avenue Ibnou Sina Appt n°1 Agdal, Rabat",city:"RABAT"},{email:"rabathayryad@atlasvoyages.com",name:"RABAT RYAD",code:"RABATRYAD",address:"Mahaj ryad n°22 - Hay Riad Rabat",city:"RABAT"},{email:"rabatlabelgallery@atlasvoyages.com",name:"Label Gallery",code:"LabelGallery",address:"Galerie commerciale « Label Gallery », Souissi, Route des Zaers, 3,5 km, rez de chaussée, local n° 16 Rabat",city:"RABAT"},{email:"fescentre@atlasvoyages.com",name:"Fès center",code:"Fescenter",address:"15 rue Bouchaib Doukkali. Fès",city:"FES"},{email:"fesborj@atlasvoyages.com",name:"Borj Fès",code:"BorjFes",address:"Centre Commercial Borj Fès. Fès",city:"FES"},{email:"tangerville@atlasvoyages.com",name:"Tanger Ville",code:"TangerVille",address:"N° 6 rés Camilia, Rue ibn Taymiya. Tanger",city:"TANGER"},{email:"tangersoccoalto@atlasvoyages.com",name:"Socco Alto",code:"SoccoAlto",address:"Centre commercial « Socco Alto », sis au quartier Californie, angle Rues Boubana et Banafsaj, rez de chaussée bas, local n° R34 Tanger",city:"TANGER"},{email:"oujda@atlasvoyages.com",name:"Oujda",code:"Oujda",address:"21 Bis Rue Melillia - oujda",city:"OUJDA"},{email:"agadir@atlasvoyages.com",name:"Agadir",code:"Agadir",address:"Immeuble Sud Bahia Avenue Hassan II. Agadir",city:"AGADIR"},{email:"marrakech@atlasvoyages.com",name:"Marrakech",code:"Marrakech",address:"131, bd. Mohammed V 40000, Marrakech",city:"MARRAKECH"},{email:"meknes@atlasvoyages.com",name:"Meknès",code:"Meknes",address:"Rue Abou Ali Ben Rahal, Meknès",city:"MEKNES"},{email:"kenitra@atlasvoyages.com",name:"Kénitra",code:"Kenitra",address:"352, Bd Mohamed V – Résidence Palace - rez de chaussée",city:"KENITRA"}];angular.extend(a,{contact:{agency:{infos:{},city:{}}},state:"form",save:e,onCityChanged:d,options:{cities:[{code:"CASABLANCA",name:"CASABLANCA"},{code:"MARRAKECH",name:"MARRAKECH"},{code:"RABAT",name:"RABAT"},{code:"FES",name:"FÉS"},{code:"AGADIR",name:"AGADIR"},{code:"TANGER",name:"TANGER"},{code:"OUJDA",name:"OUJDA"},{code:"KENITRA",name:"KÉNITRA"},{code:"MEKNES",name:"MEKNÈS"}],agences:f}})}]),angular.module("avi-contact").controller("RequestCallFormCtrl",["$scope","$http","$log",function(a,b,c){functiond(){c.debug("RequestCallFormCtrl: contact-requests onAdd"),b({method:"POST",url:"/contact-requests",data:angular.extend(a.contact,{status:"opened",_perms:{r:["*"],w:["*"],d:["g:admin"]}})}).success(function(b){a.state="success"}).error(function(){a.state="error"})}c.debug("RequestCallFormCtrl: init"),angular.extend(a,{contact:{agency:{infos:{},city:{}}},state:"form",save:d,options:{markets:["FRENCH","ENGLISH","DUTCH","OTHER"]}})}]),angular.module("avi-tombola").controller("TombolaCallFormCtrl",["$scope","$http","$log",function(a,b,c){functiond(){console.log(a.contact),b({method:"POST",url:"/tombola-requests",data:angular.extend(a.contact,{_perms:{r:["*"],w:["*"],d:["g:admin"]}})}).success(function(b){a.state="success"}).error(function(){a.state="error"})}angular.extend(a,{state:"form",save:d,options:{civilities:[{code:"M",name:"Monsieur"},{code:"Mme",name:"Madame"}]}})}])}();
!function(){"use strict";angular.module("air",["ui.bootstrap","ui.select","ui.bootstrap.datepicker","daterangepicker"]),angular.module("air").config(["datepickerConfig","datepickerPopupConfig",function(a,b){a.showWeeks=!1,a.dayFormat="d",a.startingDay=1,a.minDate=newDate,a.maxDate=moment().add(18,"months").toDate(),a.maxMode="month",b.toggleWeeksText=null,b.showButtonBar=!1}]),angular.module("air").factory("airQueryCodec",["$http","settings","$log",function(a,b,c){functiond(){return{tripType:f,segments:[],adults:1,children:0,ages:[],cabin:"-",corpid:"",flags:e.reduce(function(a,b){returna[b]=!1,a},{})}}vare=["nonstop","direct","nap","npe","nr","rf","flexible"],f=2,g=1;return{ROUND_TRIP:f,ONE_WAY:g,MULTI_SEGMENTS:3,knownFlags:e,newQuery:d,fromStateParams:function(f){if(!f.flight)returnnull;varg={},h=d();angular.isArray(f.flight)||(f.flight=[f.flight]),h.segments=f.flight.map(function(a){varb=a.split(",");returng[b[0]]||(g[b[0]]={code:b[0],name:b[0]}),g[b[1]]||(g[b[1]]={code:b[1],name:b[0]}),{from:g[b[0]],to:g[b[1]],date:b[2]}}),h.tripType=Math.min(3,h.segments.length),2===h.tripType&&h.segments[0].from!==h.segments[1].to&&(h.tripType=3),f.travellers=f.travellers||"1";vari=f.travellers.split(",");if(h.adults=parseInt(i.shift(),10)||1,console.log("travellers",i),h.ages=i.map(function(a){return{v:parseInt(a,10)}}).filter(function(a){returna.v>=0}),h.children=h.ages.length,f.flags&&f.flags.split(",").filter(function(a){returne.indexOf(a)>-1}).reduce(function(a,b){returna.flags[b]=!0,a},h),h.cabin=f.cabin||"-",h.corpid=f.corpid,f.airlines){varj=f.airlines.split("_");h.preferredAirline={code:j[0],name:j[1]}}returna.get(b.air.airportsResolve.replace(":codes",Object.keys(g).join(","))).then(function(a){returnangular.forEach(a.data,function(a){angular.extend(g[a.code],a)}),c.debug("decoded query",h),h},function(){returnh})},toApi:function(a){varb=a.cabin||"-",c="",d=a.preferredAirline?a.preferredAirline.code:"YY";angular.forEach(a.segments,function(a){c+="&itinerary="+d+".."+a.from.code+a.to.code+moment(a.date).format("YYYYMMDD")+b});varf=a.ages.map(function(a){returna.v});f.unshift(a.adults),c+="&travellers="+f.join(",");varg=Object.keys(a.flags).filter(function(b){returna.flags[b]&&e.indexOf(b)>-1}).join(",");return["M","C","F"].indexOf(a.cabin)>-1&&(c+="&cabin="+a.cabin),g&&(c+="&flags="+g),a.corpid&&(c+="&corpid="+a.corpid),c},toStateParams:function(a){varb=[];console.log("aaaa",a),a.tripType===f&&(a.segments[1].from=a.segments[0].to,a.segments[1].to=a.segments[0].from,a.segments.length=2),a.tripType===g&&(a.segments.length=1),angular.forEach(a.segments,function(a){b.push("flight="+a.from.code+","+a.to.code+","+moment(a.date).format("YYYY-MM-DD"))});vard=(a.ages||[]).map(function(a){returna.v});d.unshift(a.adults),b.push("travellers="+d.join(",")),a.cabin&&b.push("&cabin="+a.cabin),a.preferredAirline&&b.push("&airlines="+a.preferredAirline.code+"_"+a.preferredAirline.name),a.corpid&&b.push("&corpid="+a.corpid);varh=e.filter(function(b){returna.flags[b]}).join(",");returnh&&b.push("flags="+h),c.debug("toStateParams",a,b),b.join("&")}}}]),angular.module("air").controller("air_SearchFormCtrl",["$scope","settings","$window","$http","$log","airQueryCodec","$sce","$document",function(a,b,c,d,e,f,g,h){functioni(){a.roomInput="Adultes "+a.query.adults+" ,Enfant "+a.query.children,a.roomDiv=!a.roomDiv}functionj(a){varb=a;if(b!==s.tripType){varc,d=s.segments,e=0;for(console.log("---- length setSegmentCount ----",s),0===s.segments.length&&d.push({options:{minDate:r.minDeparture,minMonth:moment(r.minDeparture).startOf("month"),initDate:"query.segments[0].options.minMonth"}}),e=d.length;d.length<b;)c=s.segments[d.length-1],d.push({from:c.to,options:{minDate:c.date?c.date:c.minDate,minMonth:c.date?moment(c.date).startOf("month"):c.minMonth,initDate:"query.segments["+e+"].options.minMonth"}}),e++;2===b&&(d[1].from=d[0].to,d[1].to=d[0].from),s.tripType=b}}functionk(){vara=s.segments.length;if(!(a>=6)){varb=s.segments[a-1];s.segments.push({from:b.to,options:{minDate:b.date?b.date:b.minDate,minMonth:b.date?moment(b.date).startOf("month"):b.minMonth,initDate:"query.segments["+a+"].options.minMonth"}})}}functionl(a){varb=s.segments.indexOf(a);b>-1&&s.segments.splice(b,1)}functionm(c){returna.airports=[],c.length<1?[]:d.get(b.air.airportsSearch.replace(":term",c)).then(function(b){returna.airports=b.data||[],a.airports})}functionn(c){returna.airlines=[],c.length<1?[]:d.get(b.air.airlinesSearch.replace(":term",c)).then(function(b){returna.airlines=b.data||[],a.airlines})}functiono(a,b){varc="cal"+b,d=t[c];for(vareint)t[e]=!1;t[c]=!d}functionp(){s.tripType===f.ROUND_TRIP&&(s.segments[1].from=s.segments[0].to,s.segments[1].to=s.segments[0].from);vara=f.toStateParams(s);b.air&&b.air.standaloneSearchForm?c.location.href=b.air.salesApp+"?"+a:c.location.href=b.links.search+"?"+a}functionq(a){varb,c,d=s.segments,e=s.segments.length;if(d[a])for(c=s.segments[a].date,moment(c).startOf("month").toDate(),a++;a<e;)b=d[a],b.options=d.options||{initDate:"$parent.$parent.options.minMonth"},b.options.minDate=c,b.options.minMonth=moment(c).startOf("month").toDate(),b.date&&moment(b.date).isBefore(c)&&(b.date=c),a++}e.info("air_SearchFormCtrl:airQueryCodec",a.query),a.rangeDatePicker={picker:null,options:{pickerClasses:"custom-display",buttonClasses:"btn",applyButtonClasses:"btn-primary",cancelButtonClasses:"btn-danger",minDate:moment(),locale:{applyLabel:"valider",cancelLabel:"annuler",customRangeLabel:"Custom range",separator:" - ",format:"DD/MM/YYYY",weekLabel:"S",daysOfWeek:["Di","Lu","Ma","Me","Je","Ve","Sa"],monthNames:["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Decembre"],firstDay:1},eventHandlers:{"apply.daterangepicker":function(b,c){a.query.segments[0].date=a.rangeDatePicker.date.startDate,a.query.segments[1].date=a.rangeDatePicker.date.endDate}}}},void0!==a.query&&2==a.query.tripType&&a.query.segments[0].date&&a.query.segments[1].date?a.rangeDatePicker.date={startDate:a.query.segments[0].date,endDate:a.query.segments[1].date}:a.rangeDatePicker.date={startDate:moment().subtract(1,"days"),endDate:moment()},a.singleDatePicker={picker:null,options:{singleDatePicker:!0,pickerClasses:"custom-display",buttonClasses:"btn",applyButtonClasses:"btn-primary",cancelButtonClasses:"btn-danger",minDate:moment(),locale:{applyLabel:"valider",cancelLabel:"annuler",customRangeLabel:"Custom range",separator:" - ",format:"DD/MM/YYYY",weekLabel:"S",daysOfWeek:["Di","Lu","Ma","Me","Je","Ve","Sa"],monthNames:["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Decembre"],firstDay:1},eventHandlers:{"apply.daterangepicker":function(b,c){a.query.segments[0].date=a.singleDatePicker.date}}}},void0!==a.query&&1==a.query.tripType&&a.query.segments[0].date?a.singleDatePicker.date=a.query.segments[0].date:a.singleDatePicker.date=moment();varr={minDeparture:moment().startOf("day").toDate(),maxDeparture:moment().add(1,"years").toDate(),maxAdults:9,maxChildren:9,maxPax:9,adults:[1,2,3,4,5,6,7,8,9],children:[0,1,2,3,4,5,7,8,9],ages:[0,1,2,3,4,5,6,7,8,9,10,11],tripTypes:[{code:1,label:"Direct flight"},{code:2,label:"Round trip"},{code:3,label:"Multi-segments/open-jaw"}]};a.roomDiv=!1,a.roomInput="Adultes - Enfant ...",h.bind("click",function(b){"inputDivRooms"===b.target.id||"guests__inputs divRooms ng-scope"===b.target.className||!0!==a.roomDiv||b.target.classList.contains("divRoomsInputs")||b.target.nextSibling.classList.contains("divRoomsInputs")||(a.roomDiv=!a.roomDiv,a.$apply())});vars,t={};a.query&&!b.air.standaloneSearchForm?(s=angular.copy(a.query),console.log("------- query if existe with setting air -----",s)):(s=f.newQuery(),s.tripType=0,j(2),console.log("------- query if not existe -----",s)),a.$watch("query.children",function(a,b){if(a!==b){for(;s.ages.length<a;)s.ages.push({});for(;s.ages.length>a;)s.ages.pop()}}),s.tripType||j(2),angular.extend(a,{airports:[],airlines:[],query:s,calendars:t,setTripType:j,addSegment:k,removeSegment:l,toggleCalendar:o,searchAirports:m,searchAirlines:n,search:p,dateChanged:q,maxSegments:6,options:r,trustAsHtml:g.trustAsHtml,roomChange:i})}])}();