📄 reservationsummary.js
字号:
var idBody = document.body.id; switch(idBody) { case 'dates-et-nb-chambres': if($("dates-nb-chambres")) { $('dates-nb-chambres').addClassName('current'); } break; case 'chambre-et-tarif': if($("dates-nb-chambres")) { $('chambre-tarif').addClassName('current'); } break; case 'upsale': if($("options")) { $('options').addClassName('current'); } break; case 'detail-clients': if($("recap-reservation")) { $('recap-reservation').addClassName('current'); } break; case 'confirmation': break; default: break; } }, /** * * changes the class of the menu sections based on position in reservation process * items that are before the current step are assigned a .visited className (and the .main className is removed) * * @return void * */ decorateMenu: function() { var idBody = document.body.id; var base_element = $('side-content'); var titles = base_element.getElementsBySelector('.main'); var _class = 'visited'; for(var i = 0 ; i < titles.length; i++) { var section = this.sections[i]; if(section.indexOf(idBody) != -1 && idBody != 'confirmation') { // if not on the confirmation page where all the items must be shown as visited _class = null; } if(_class) { titles[i].removeClassName('main'); titles[i].addClassName(_class); } } }, /** * Writes infos in the Personal infos block of the left menu * * @return void */ rewriteAvantage: function() { var bAffiche = false; if($("avantage")) { if(bookingEngineViewBean.preferentialCode != null && bookingEngineViewBean.preferentialCode.length) { bAffiche = true; $("avantage_preferentialCode").innerHTML = bookingEngineViewBean.preferentialCode; $("avantage_preferentialCode").up().removeClassName('hide'); } if(bookingEngineViewBean.fidelityCardName != null && bookingEngineViewBean.fidelityCardName.length) { bAffiche = true; $("avantage_fidelityCardName").innerHTML = bookingEngineViewBean.fidelityCardName; $("avantage_fidelityCardName").up().removeClassName('hide'); } if(bookingEngineViewBean.companyReserverName != null && bookingEngineViewBean.companyReserverName.length) { bAffiche = true; $("avantage_companyReserveName").innerHTML = bookingEngineViewBean.companyReserverName; $("avantage_companyReserveName").up().removeClassName('hide'); } if(bookingEngineViewBean.agencyReserverName != null && bookingEngineViewBean.agencyReserverName.length) { bAffiche = true; $("avantage_agencyReserverName").innerHTML = bookingEngineViewBean.agencyReserverName; $("avantage_agencyReserverName").up().removeClassName('hide'); } if(bAffiche) { $("avantage").removeClassName('hide'); } } }, /** * Writes Aclub img for non eco brands + ase */ rewriteAclub: function() { var elm = $('aclub'); if (elm && this.aClubViewBean && this.aClubViewBean.aclubVisible && this.aClubViewBean.aclubPartner) elm.removeClassName('hide'); }, /** * Writes infos about the reservation in the left menu * @return void */ rewriteRecap: function() { //write the title of the reservation block, title which changes on the confirmation page var target =''; target = document.getElementById("side-content").getElementsByTagName("h2")[0]; if(document.body.id != 'confirmation'){ if(target != undefined){ target.innerHTML = I18N._('confirmation','Your selection'); } } else if(document.body.id == 'confirmation'){ if(target != undefined){ target.innerHTML = I18N._('confirmation','Your confirmed booking'); } } if( $('recap_hotelname') ) { $('recap_hotelname').removeClassName('hide'); $('recap_hotelname').innerHTML = "<a href='/frm_fiche_hotel.svlt?code_hotel="+bookingEngineViewBean.hotelCode+"'>"+bookingEngineViewBean.hotelName+"</a>"; } if(bookingEngineViewBean.destination != null && bookingEngineViewBean.destination.length) { if( $('recap_destination') ) { $('recap_destination').removeClassName('hide'); $('recap_destination').innerHTML = bookingEngineViewBean.destination; } var back_urldestination = bookingEngineViewBean.hotelsListUrl; if(back_urldestination != null) { if( $('recap_destinationurl') ) { $('recap_destinationurl').removeClassName('hide'); $('recap_destinationurl').href = back_urldestination; } } else{ $('recap_destinationurl').style.display="none"; } } else { document.getElementById("recap_destinationurl").style.display = "none"; } if( $('recap_newsearchurl') ) { $('recap_newsearchurl').href = bookingEngineViewBean.newSearchUrl; } if( $('recap_adultsnb') ) { $('recap_adultsnb').innerHTML = bookingEngineViewBean.adultsNb; } if( $('recap_childrennb') && $('recap_children') && bookingEngineViewBean.childrenNb!=null && bookingEngineViewBean.childrenNb!=0 ) { $('recap_children').removeClassName('hide'); $('recap_childrennb').innerHTML = bookingEngineViewBean.childrenNb; } var roomsNb = bookingEngineViewBean.roomsNb; if(roomsNb > 1 && $('recap_roomsnb')){ $('recap_roomsnb').removeClassName('hide'); if(roomsNb == 2){ $('recap_roomsnb').innerHTML = I18N._('multirates',"Rooms 1 and 2"); } else{ $('recap_roomsnb').innerHTML = I18N._('multirates',"Rooms 1, 2 and 3"); } } if (this.getBasketViewBean()) { if ($('chambre-tarif')&& null != basketViewBean.currentRoom) { if (document.body.id == "upsale" && basketViewBean.currentRoom.famillyOffer && $('recap_roomsnb')) { $('recap_roomsnb').innerHTML = I18N._('upsale','2 chambres en famille'); $('recap_roomsnb').removeClassName('hide'); } if (document.body.id == "chambre-et-tarif" && basketViewBean.currentRoom.famillyOffer && $('recap_roomsnb')) { $('recap_roomsnb').innerHTML = I18N._('multirates',"Rooms 1 and 2"); $('recap_roomsnb').removeClassName('hide'); } //displays reserved room infos if(basketViewBean.currentRoom.label && $('chambre-tarif').down('.label')) { $('chambre-tarif').down('.label').innerHTML = basketViewBean.currentRoom.label; } if(basketViewBean.currentRoom.tariffLabel && $('chambre-tarif').down('.tariffLabel')) { $('chambre-tarif').down('.tariffLabel').innerHTML = basketViewBean.currentRoom.tariffLabel; } this.writeRoomPrice(); } } }, writeRoomPrice: function () { if(typeof(basketViewBean) != 'undefined' && $('chambre-tarif')) { if(null != basketViewBean.currentRoom) { if(basketViewBean.currentRoom.price && $('prix_total').down('.techPrice')) { $('prix_total').down('.techPrice').innerHTML = basketViewBean.currentRoom.price; } if(basketViewBean.currentRoom.currency && $('prix_total').down('.mdevise')) { $('prix_total').down('.mdevise').innerHTML = basketViewBean.currentRoom.currency; } } } }, /** * manages whether the stay dates are to be selected in the page or in the left column * if data in Bean => remove stay dates block in page * else remove the stay dates block in left menu * the html page contains elements with same ids but since we remove a block, we're left with unique ids * * TODO the management of displayiong the stay dates block in left menu has been moved to rewrite method * so it is probably not necessary to actualy remove the left menu stay dates block if there is no data in the bean * * @return void * */ setupRoomsDatesStayDatesBlock: function() { if( (bookingEngineViewBean.dayIn != null && bookingEngineViewBean.dayIn.length) && (bookingEngineViewBean.monthIn != null && bookingEngineViewBean.monthIn.length) && (bookingEngineViewBean.yearIn != null && bookingEngineViewBean.yearIn.length) && (bookingEngineViewBean.nightsNumber != null && bookingEngineViewBean.nightsNumber.length) ) { //remove stay dates block in page if exists (its the case in rooms dates page) if($('rooms-dates-stay-dates')) { $('rooms-dates-stay-dates').remove(); } } else { //remove stay dates block in reservation summary column $('dates-nb-chambres').down('ul').remove(); } }, /** * * Sets the arrival date as a class ppty * to be used throughout the dates functions * * @return void * */ setArrivalDate: function() { if( (bookingEngineViewBean.dayIn != null && bookingEngineViewBean.dayIn.length) && (bookingEngineViewBean.monthIn != null && bookingEngineViewBean.monthIn.length) && (bookingEngineViewBean.yearIn != null && bookingEngineViewBean.yearIn.length) && (bookingEngineViewBean.nightsNumber != null && bookingEngineViewBean.nightsNumber.length) ) { this.arrival_date = new Date( parseInt(bookingEngineViewBean.yearIn), Number(bookingEngineViewBean.monthIn) - 1, Number(bookingEngineViewBean.dayIn) ); this.has_initial_dates = true; } else { this.arrival_date = new Date(); } }, /** * * displays the arrival date * there is a distinction made between when the date can or can not be modified * there are 2 blocks with elements with same ids , we remove one of the block * depending on whether we need a form to modify the date or not * this depends on the page we are on * * @return void * */ displayArrivalDate: function() { if(!this.arrival_date) return; var str_date = this.arrival_date.print(Calendar._TT["DEF_DATE_FORMAT"]); if($("arrivee_display")) { $("arrivee_display").down("span.date").innerHTML = str_date; if($("arrivee_display").down('span.jour')) $("arrivee_display").down('span.jour').innerHTML = Calendar._DN[this.arrival_date.getDay()]; } if($("arrivee_calendar_side")) { $("arrivee_calendar_side").value = str_date; if($("arrivee_calendar_side").previous('span.jour')) $("arrivee_calendar_side").previous('span.jour').innerHTML = Calendar._DN[this.arrival_date.getDay()]; } if($("arrivee")) { $("arrivee").value = str_date; if($("arrivee").previous('span.jour')) $("arrivee").previous('span.jour').innerHTML = Calendar._DN[this.arrival_date.getDay()]; } }, /** * sets the nights number * * @return void * */ setNightsNb: function(value) { this.nights_nb = value; }, /** * displays the nights number on page * * @return void * */ displayNightsNb: function() { $('nb_nuit_display').innerHTML = this.nights_nb; }, /** * sets up calendar for arrival dates * * @return void * */ setupRoomsDatesCalendar: function(input_calendar_text) { if($(input_calendar_text)) { //since we want to be able to create a calendar when focusin or clicking on the field //but we don't want manual input int the field //blur it when focus is gained Event.observe( $(input_calendar_text), 'focus', function(e) { Event.element(e).blur(); } ); var calendarDate = null; if(typeof(this.arrival_date) != "undefined" && this.arrival_date) { var calendarDate = this.arrival_date; this.setDateHiddenFieldsValue(this.arrival_date); } Calendar.setup( { inputField : input_calendar_text, button : 'date_'+input_calendar_text+'_img', button_eventNames : ['click'], inputField_eventNames : ['click','focus'], ifFormat : Calendar._TT["DEF_DATE_FORMAT"], singleClick : true, align : 'T R', onSelect : this.arrivalDateOnselect.bind(this, input_calendar_text), dateStatusFunc : this.disableDates.bind(this) } ); } }, /** * date select handler * * @param Calendar object cal the calendar object on which a date has been selected * @param Date date the selected date * * @return void *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -