📄 reservationsummary.js
字号:
/** Constants used for time computations */Date.SECOND = 1000 /* milliseconds */;Date.MINUTE = 60 * Date.SECOND;Date.HOUR = 60 * Date.MINUTE;Date.DAY = 24 * Date.HOUR;Date.WEEK = 7 * Date.DAY;/** * Javascript object to deal with User Reservation infos * */var ReservationSummary = { /** * stores booking data coming from Json Object */ bookingEngineViewBean: null, /* * stores user profile data coming from Json object */ profileViewBean: null, /* * stores fidelity cards and fid attributes */ fidelityCardsViewBean: null, basketViewBean: null, /* * stores aclub special attribs */ aClubViewBean: null, /* * stores the arrival date throughout runtime */ arrival_date: null, departure_date: null, nights_nb: null, /** * used to indicate if the dates of stay are to be modified or just displayed */ dates_can_be_modified: true, /** * used to indicate if we actually display dates block on page */ show_dates: false, /* * used to indicate whether we received dates from the Json object */ has_initial_dates: false, /** * */ sections: new Array(['hotel'], ['dates-et-nb-chambres'], ['chambre-et-tarif'], ['upsale'], ['detail-clients','confirmation']), /** * Beans to be used. * * @return String a string of the nalmes of the Beans to be used in this class * */ getBeans: function() { return "BookingEngineViewBean;ProfileViewBean;BasketViewBean;AClubViewBean"; }, /** * assigning values from JSON object to global variables * * @return void * */ initJSON: function() { bookingEngineViewBean = viewBeans["BookingEngineViewBean"]; profileViewBean = viewBeans["ProfileViewBean"]; basketViewBean = viewBeans["BasketViewBean"]; this.aClubViewBean = viewBeans["AClubViewBean"]; }, /** * get the booking engine bean * * @return Object the json object for booking engine values * */ getBookingEngineViewBean: function() { return bookingEngineViewBean; }, /** * get the profile bean * * @return Object the json object for user profile * */ getProfileViewBean: function() { return profileViewBean; }, /** * get the basket bean * * @return Object the json object for basket informations * */ getBasketViewBean: function() { return (typeof(basketViewBean) != 'undefined')? basketViewBean : null; }, /** * wrapper method to execute init functions for the page * * also deals with adapting the left menu to the different pages the menu is displayed on * ReservationSummary is called on every page since it manages the left menu * * called on page load * * @return void * * */ rewrite: function() { this.rewriteRecap(); this.rewriteAvantage(); this.highLightMenu(); this.decorateMenu(); this.setupBasketLink(); this.setTitle(); this.rewriteAclub(); this.testChoixCouchage(); var basket_bean = this.getBasketViewBean(); var showCentralDates = this.getBookingEngineViewBean().displayDate; var modifDates = this.getBookingEngineViewBean().modifDate; //different actions depending on the page switch(document.body.id) { case "dates-et-nb-chambres": this.setupBeddingBlock(); //special case when we want to add a second room or more and display the dates in the center of the page //if((basket_bean && basket_bean.displayBasket)) { if(showCentralDates) { this.has_initial_dates = false; this.show_dates = false; this.dates_can_be_modified = true; this.setArrivalDate(); this.setNightsNb( (this.getBookingEngineViewBean().nightsNumber) ? this.getBookingEngineViewBean().nightsNumber : 1 ); if($("arrivee")) { this.setupRoomsDatesCalendar("arrivee"); } if($("arrivee_calendar_side")) { this.setupRoomsDatesCalendar("arrivee_calendar_side"); } if($("nb_nuit") && bookingEngineViewBean.hotelMaxStay) { this.setupMaxStayDropDown("nb_nuit"); } if($("nb_nuit_calendar_side") && bookingEngineViewBean.hotelMaxStay) { this.setupMaxStayDropDown("nb_nuit_calendar_side"); } } else{ this.show_dates = true; this.dates_can_be_modified = false; } break; case "chambre-et-tarif": this.show_dates = true; if(modifDates){ this.dates_can_be_modified = true; }else{ this.dates_can_be_modified = false; } break; case "upsale": this.show_dates = true; this.dates_can_be_modified = false; $('chambre-tarif').down('ul').removeClassName('hide'); break; case 'detail-clients': break; case 'confirmation': break; } if(this.show_dates) { this.setArrivalDate(); this.setNightsNb( (this.getBookingEngineViewBean().nightsNumber)? this.getBookingEngineViewBean().nightsNumber: 1 ); this.setupRoomsDatesStayDatesBlock(); } if(this.show_dates && $('dates-nb-chambres').down('ul')) //show dates block in reservation summary column $('dates-nb-chambres').down('ul').removeClassName('hide'); //if the dates can be modified or (to deal with 'in page' dates setup) if there are no dates in the bean // AND we want to show the dates if( ( this.dates_can_be_modified || !this.has_initial_dates ) && this.show_dates ) { if(document.getElementById("side-availability")) { var input = document.createElement("input"); input.type = "hidden"; input.name = "nb_personne"; input.value = bookingEngineViewBean.adultsNb?bookingEngineViewBean.adultsNb:""; document.getElementById("side-availability").appendChild(input); input = document.createElement("input"); input.type = "hidden"; input.name = "nb_enfant"; input.value = bookingEngineViewBean.childrenNb?bookingEngineViewBean.childrenNb:""; document.getElementById("side-availability").appendChild(input); input = document.createElement("input"); input.type = "hidden"; input.name = "bedding"; input.value = bookingEngineViewBean.bedding?bookingEngineViewBean.bedding:""; document.getElementById("side-availability").appendChild(input); input = document.createElement("input"); input.type = "hidden"; input.name = "rooms_nb"; input.value = bookingEngineViewBean.roomsNb?bookingEngineViewBean.roomsNb:""; document.getElementById("side-availability").appendChild(input); input = document.createElement("input"); input.type = "hidden"; input.name = "type_carte_fidelite"; input.value = bookingEngineViewBean.fidelityCardType?bookingEngineViewBean.fidelityCardType:""; document.getElementById("side-availability").appendChild(input); input = document.createElement("input"); input.type = "hidden"; input.name = "num_carte_fidelite"; input.value = bookingEngineViewBean.fidelityCardNumber?bookingEngineViewBean.fidelityCardNumber:""; document.getElementById("side-availability").appendChild(input); input = document.createElement("input"); input.type = "hidden"; input.name = "code_avantage"; input.value = bookingEngineViewBean.preferentialCode?bookingEngineViewBean.preferentialCode:""; document.getElementById("side-availability").appendChild(input); Event.observe( document.getElementById("depart_calendar_side").getElementsByTagName("a")[0], "click", function(e) { Event.stop(e); document.getElementById("side-availability").submit(); } ); } //remove fixed dates block if($('side-stay-dates')) $('side-stay-dates').remove(); if($("arrivee")) { this.setupRoomsDatesCalendar("arrivee"); } if($("arrivee_calendar_side")) { this.setupRoomsDatesCalendar("arrivee_calendar_side"); } if($("nb_nuit") && bookingEngineViewBean.hotelMaxStay) { this.setupMaxStayDropDown("nb_nuit"); } if($("nb_nuit_calendar_side") && bookingEngineViewBean.hotelMaxStay) { this.setupMaxStayDropDown("nb_nuit_calendar_side"); } } else { //remove stay dates form if($('side-availability')) $('side-availability').remove(); //if(basket_bean && !basket_bean.displayBasket) { if(!showCentralDates){ this.displayNightsNb(); } } this.displayArrivalDate(); if(this.arrival_date != undefined) this.updateDepartureDate(); }, /** * * alllow to show the beeding block if bookingEngineViewBean.hotelPaxPolicies.twinOrDouble is true in Bean * * @return void * */ setupBeddingBlock: function() { if(bookingEngineViewBean.hotelPaxPolicies.twinOrDouble != true) { if($("type-couchage")) { $("type-couchage").remove(); } } else { if($("type-couchage") && $("nb_personne").value != 2 && (!$("nb_enfant") || $("nb_enfant").value != 0)) { $("type-couchage").hide(); } if($("nb_personne")) { Event.observe( $("nb_personne"), "change", ReservationSummary.testChoixCouchage ); } if($("nb_enfant")) { Event.observe( $("nb_enfant"), "change", ReservationSummary.testChoixCouchage ); } } }, /** * Display or not the type couchage * * @return void * */ testChoixCouchage: function() { if($("type-couchage")){ if($("nb_personne").value != 2) { $("type-couchage").hide(); } else { if($("nb_enfant") && $("nb_enfant").value != 0) { $("type-couchage").hide(); } else { $("type-couchage").show(); } } if(navigator.userAgent.indexOf('Safari') != -1) { ReservationSummary.adaptSpanBottom('rooms-date-pax', 2); } } }, /** * adapt the position of the span bottom depending on the contener height * * @return void * */ adaptSpanBottom:function(referer, nbPix) { if($(referer)) { var last = $(referer).getElementsByTagName("span").length-1; var span = $(referer).getElementsByTagName("span")[last]; if(span.className.search(/extra-bottom/) !== -1) { var height= $(referer).getHeight(); span.style.bottom = "auto"; span.style.top = (height-nbPix)+"px"; } } }, /** * highlights right item in the left menu * * @return void * */ highLightMenu: function() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -