📄 multirates.js
字号:
} }, /** * En fonction du Json fourni, affiche ou non le bloc "autres chambres disponibles" */ displayRoomsList: function() { if( MultiRates.beanRoomsListe[MultiRates.tab_type] == null || MultiRates.beanRoomsListe[MultiRates.tab_type].size() == 1 ) { $$('#content .disponibilites')[0].hide(); $(document.getElementById("chambre-entete")).addClassName("full-width"); } else { //console.log(MultiRates.tab_type+' : ',MultiRates.beanRoomsListe[MultiRates.tab_type]); if($$('#content .disponibilites')[0]) $$('#content .disponibilites')[0].show(); $(document.getElementById("chambre-entete")).removeClassName("full-width"); } }, /** * Accroche la popup correspondant à "+ d'infos" */ setMoreInfosLinks: function() { var link = $$("#content")[0].down("div.detail").down("a.more-infos"); Event.observe( link, 'click', function(e) {Event.stop(e); DivPopup.openPopup('more_infos', 500, 400, $$("#content")[0].down("div.detail"), null); } ); }, /** * Accorche l'afichage de la popup "détail de la chambre" sur le lien correspondant */ setDescRoomsLinks: function() { if($$("#content").length) { var link = $$("#content")[0].down("div.disponibilites").down("a.desc-rooms"); Event.observe( link, 'click', this.openDescRoomsPopup.bindAsEventListener(this) ); } }, /** * Accroche l'ouverture de la popup "popup-rooms-description.htm" * * @param e Evenement correspondnat au clic */ openDescRoomsPopup: function(e) { Event.stop(e); if(this.desc_rooms_popup) this.desc_rooms_popup.destroy(); this.desc_rooms_popup = new Window( { className: 'accor', width: 516, height: 400, minimizable: false, maximizable: false, url: "/"+originViewBean.codeLangDirectory+"/reservation/popup-rooms-description.htm", showEffect: Element.show, hideEffect: Element.hide }); // On met en avant la chambre sélectionnée var liListe = $("old-desc-rooms").immediateDescendants("LI"); var selectedLi = 0; var i, j; for(i=1, j=liListe.length; i<j; i++) { if(liListe[i].getAttribute("code") == MultiRates.beanRoomsListe[MultiRates.tab_type].selectedRoomCode) { selectedLi = i; } liListe[i].removeClassName("hide"); } if(selectedLi != 0 && selectedLi<j) { liListe[0].innerHTML = liListe[selectedLi].innerHTML.replace(/mtarif/g, "").replace(/mdevise/g, ""); liListe[selectedLi].addClassName("hide"); } Event.observe( this.desc_rooms_popup.getContent(), 'load', function(e) { if(this.desc_rooms_popup.getContent().contentWindow.document.body) { this.desc_rooms_popup.getContent().contentWindow.document.body.innerHTML = $("div-desc").innerHTML.replace(/mtarif/g, "").replace(/mdevise/g, "").replace(/POPUP_ID/g, this.desc_rooms_popup.getId()).replace(/old-desc-rooms/, ""); } }.bind(this) ); // On affiche la liste selon l'onglet sélectionné this.desc_rooms_popup.showCenter(); DivPopup.addWindowCloseLabel(this.desc_rooms_popup); }, /** * Depuis le popup liste chambres dispos, rafrichie la chambre en fonction du lien choisi */ refreshFromListDetails: function(code) { var listeLignes = $$("#liste-chambres li"); for (var i = listeLignes.length - 1; i >= 0; i--) { var liCode = listeLignes[i].getAttribute("code"); if(liCode == code) { MultiRates.beanRoomsListe[MultiRates.tab_type].selectedRoomCode = code; MultiRates.selectRoom(true); return; } } }, /** * Accroche l'afichage des descriptifs Flex sur les liens correspondnat dans la page principale */ setLegendRatesPopupLinks: function() { var legend_rates_links = new Array(); //get links from main document var main_legend_rates_element = $$("dl.legend-rates"); if(main_legend_rates_element.length) { main_legend_rates_element[0].descendants().each( function(element) { if(element.tagName == 'A') { legend_rates_links.push(element); } } ); } legend_rates_links.each( function(element) { if (element!=null) Event.observe( element, 'click', function(e) {Event.stop(e); DivPopup.openPopup('legend_rates', 500, 400, $("legend-rates-popup"), null); } ); }.bind(this) ); //rewrite pop-in title from website domain name (brands.com only) var legend_rates_popup_titles = $$('#legend-rates-popup h3'); if (legend_rates_popup_titles.length) { var current_website = document.domain; var ah_pattern = new RegExp(".accorhotels.com$", "g"); if (!ah_pattern.test(current_website)) { current_website = current_website.sub('www.', '').capitalize(); legend_rates_popup_titles[0].innerHTML = legend_rates_popup_titles[0].innerHTML.replace(new RegExp("(accorhotels.com)", "gi"), current_website); } } }, /** * Accroche l'afichage des descriptifs Flex sur les liens correspondnat dans l'iframe */ bindTheIframeFlexPopup: function() { var legend_rates_links = []; var iframe_document = $("tarifs").contentWindow.document; for(var i = iframe_document.getElementsByTagName("ul").length - 1; i >= 0; i--) { var ulNode = iframe_document.getElementsByTagName("ul")[i]; if(ulNode.className.search(/gamme/) != -1) { // Transformation de la liste en numérables: http://www.prototypejs.org/api/element/methods/select var ilNode = ($A(ulNode.getElementsByTagName("li")).map(Element.extend)); if(ilNode.length > 0 ) { ilNode.each( function(element) { //console.log(element); // Ajout de la pop in sur les image "commissionable" if(element.className.search(/commissionable/) != -1) { var link0 = element.getElementsByTagName("a")[0]; Event.observe( link0, 'click', function(e) {Event.stop(e); DivPopup.openPopup('rates_sales_policies', 500, 400, null, link0+"¤cyCode="+iframe_document.getElementById("s_devise").value); } ); } // Ajout de la pop in sur les image "flex, felx+, uflex et first" else if(element.className.search(/flex|first/) != -1){ Event.observe( element.getElementsByTagName("a")[0], 'click', function(e) {Event.stop(e); DivPopup.openPopup('legend_rates', 500, 400, $("legend-rates-popup"), null); } ); } } ); } } } }, /** * Recherche et traite le clic sur l'ensemble des boutons "Valider" de l'iframe */ bindTheIframeValidateButtons: function() { var iframe_document = $("tarifs").contentWindow.document; if(iframe_document) { iframe_id = $(iframe_document.getElementById('iframe-multirates')) if (iframe_id) { // On cherche tous les éléments de l'iframe avec class="validate-link" var iframe_validateLinks = iframe_id.select("a.validate-link"); //used to be able to stop observing (see prototype stopObserving API docs) this.boundIFrameValidateButtonAction = this.iFrameValidateButtonAction.bindAsEventListener(this); iframe_validateLinks.each( function(element) { this.bindIframeValidateButton(element); }.bind(this) ); } } }, /** * Surveille le clic sur le bouton "Valider" passé en ramaètre * * @param element Bouton de validation à traiter */ bindIframeValidateButton: function(element) { //prevents multiple bindings under ie Event.stopObserving(element,'click',MultiRates.boundIFrameValidateButtonAction); Event.observe( element, 'click', this.boundIFrameValidateButtonAction ); }, /** * used to unbind the action on the validate link. In case of a validation mechanism needing to disable the link for instance. * */ unbindIframeValidateButton: function(element) { Event.stopObserving(element,'click',MultiRates.boundIFrameValidateButtonAction); }, /** * Gère le clic sur un bouton "Valider" * * @param e Evenement de clic */ iFrameValidateButtonAction: function(e) { // On envoie le lien sur la page mère, pas dans l'iframe if(!e.target && e.srcElement) { e.target = e.srcElement; } if (this.getMultirateCurrency() != Currencies.CrtCurrency) { //if (e.target.href.indexOf("currencyCode") == -1) e.target.href += '¤cyCode='+Currencies.CrtCurrency; //else // e.target.href = e.target.href.substring(0, e.target.href.indexOf("currencyCode")) + 'currencyCode='+Currencies.CrtCurrency; } //top.location.href = e.target.getAttribute("link"); }, /** * Accroche les popups "ratesSalesPolicies.jsp" et "ratesDetails.jsp" */ setRatesSalesPoliciesRatesDetailsLinks: function() { if(MultiRates.isTarifsIframeLoaded() === false || !$("tarifs")) { return; } var iframe_document = $("tarifs").contentWindow.document; //no packages iframe var iframe_rates_sales_links_main_parent = $(iframe_document.getElementById('nopackages')); var iframe_rates_sales_links_containers = iframe_rates_sales_links_main_parent.select("div.detail"); iframe_rates_sales_links_containers.each( function(element) { var link0 = element.getElementsByTagName('a')[0]; if (link0!=null) Event.observe( link0, 'click', function(e) {Event.stop(e); DivPopup.openPopup('rates_sales_policies', 500, 400, null, link0); } ); var link1 = element.getElementsByTagName('a')[1]; if (link1!=null) Event.observe( link1, 'click', function(e) {Event.stop(e); DivPopup.openPopup('rates_sales_policies', 600, 400, null, link1+"¤cyCode="+iframe_document.getElementById("s_devise").value); } ); }.bind(this) ); //packages iframe iframe_rates_sales_links_main_parent = $(iframe_document.getElementById('packages')); iframe_rates_sales_links_containers = iframe_rates_sales_links_main_parent.select("div.detail"); iframe_rates_sales_links_containers.each( function(element) { var link0 = element.getElementsByTagName('a')[0]; Event.observe( link0, 'click', function(e) {Event.stop(e); DivPopup.openPopup('rates_sales_policies', 500, 400, null, link0); } ); var link1 = element.getElementsByTagName('a')[1]; Event.observe( link1, 'click', function(e) {Event.stop(e); DivPopup.openPopup('rates_sales_policies', 500, 400, null, link1+"¤cyCode="+iframe_document.getElementById("s_devise").value); } ); if(element.getElementsByTagName('a')[2]){ var link2 = element.getElementsByTagName('a')[2]; Event.observe( link2, 'click', function(e) {Event.stop(e); DivPopup.openPopup('pkg_desc_policies', 500, 400, null, link2+"¤cyCode="+iframe_document.getElementById("s_devise").value); } ); } }.bind(this) ); }, /** * Accroche la popup "internet-sales-conditions.html" */ setInfoRatesLinks: function() { var link = $("infos-rates-popup-link"); Event.observe( link, 'click', function(e) { Event.stop(e); DivPopup.openPopup('rates_sales_policies', 500, 400, null, "/"+originViewBean.codeLangDirectory+"/reservation/internet-sales-conditions.html", cgv_title(), 17); } ); }, adaptPriceMarginHeight: function() { var iframe_chambre_elements = new Array(); var iframe_document = $("tarifs").contentWindow.document; iframe_chambre_elements = iframe_document.getElementsByClassName("chambre"); for(var i=0; i< iframe_chambre_elements.length; i++){ var li_h3_element = iframe_chambre_elements[i].down().next(); var tarifs_element = iframe_chambre_elements[i].select("p.tarifs"); var gamme_elements = iframe_chambre_elements[i].select("ul.gamme"); var h3_height = li_h3_element.offsetHeight; if(navigator.userAgent.search(/MSIE/) == -1){ if(h3_height > 16){ //tarifs_element[0].style.marginTop= 20+"px"; if(gamme_elements.length > 0){ gamme_elements[0].style.marginTop= 20+"px"; } } } if(gamme_elements.length == 0){ gamme_elements[0].style.height= 0+"px"; } } }}core.push(MultiRates);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -