Advertisement
tr13ze

GTM Tags

Jul 24th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.03 KB | None | 0 0
  1. /** > /scripts-v1705/profil/utils.js **/
  2. /*
  3. * $Id: utils.js,v 1.7 2016/10/20 09:27:47 mbenrebia Exp $
  4. *
  5. * Licensed to the Apache Software Foundation (ASF) under one
  6. * or more contributor license agreements. See the NOTICE file
  7. * distributed with this work for additional information
  8. * regarding copyright ownership. The ASF licenses this file
  9. * to you under the Apache License, Version 2.0 (the
  10. * "License"); you may not use this file except in compliance
  11. * with the License. You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing,
  16. * software distributed under the License is distributed on an
  17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18. * KIND, either express or implied. See the License for the
  19. * specific language governing permissions and limitations
  20. * under the License.
  21. */
  22.  
  23. var StrutsUtils = {};
  24.  
  25. // gets an object with validation errors from string returned by
  26. // the ajaxValidation interceptor
  27. StrutsUtils.getValidationErrors = function(data) {
  28. if (data.indexOf("{}&& {") == 0) {
  29. return eval("( " + data.substring(4, data.length) + " )");
  30. } else {
  31. return null;
  32. }
  33. };
  34.  
  35. StrutsUtils.clearValidationErrors = function(form) {
  36. clearErrors(form);
  37. };
  38.  
  39. StrutsUtils.clearActionErrors = function(errorMsgDiv) {
  40. clearActionErrors(errorMsgDiv);
  41. };
  42.  
  43. // shows validation errors using functions from xhtml/validation.js
  44. // or css_xhtml/validation.js
  45. StrutsUtils.showValidationErrors = function(form, errors) {
  46.  
  47. StrutsUtils.clearValidationErrors(form, errors);
  48. StrutsUtils.clearActionErrors();
  49.  
  50. if (errors.fieldErrors) {
  51. for (var fieldName in errors.fieldErrors) {
  52. for (var i = 0; i < errors.fieldErrors[fieldName].length; i++) {
  53. //var el = form.elements[fieldName];
  54.  
  55. //alert( form.elements[fieldName] );
  56.  
  57. //if (form.elements[fieldName][0] && form.elements[fieldName][0].type == 'radio')
  58. //if (el instanceof NodeList)
  59. // addError(el[0], errors.fieldErrors[fieldName][i]);
  60. //else
  61. addError(fieldName, errors.fieldErrors[fieldName][i]);
  62. }
  63. }
  64. }
  65.  
  66. if (errors.actionErrors) {
  67. for (var i = 0; i < errors.actionErrors.length; i++) {
  68. addActionError(errors.actionErrors[i]);
  69. }
  70. }
  71. };
  72.  
  73. StrutsUtils.firstElement = function(parentNode, tagName) {
  74. var node = parentNode.firstChild;
  75. while (node && node.nodeType != 1) {
  76. node = node.nextSibling;
  77. }
  78. if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
  79. node = StrutsUtils.nextElement(node, tagName);
  80. }
  81. return node;
  82. };
  83.  
  84. StrutsUtils.nextElement = function(node, tagName) {
  85. if (!node) {
  86. return null;
  87. }
  88. do {
  89. node = node.nextSibling;
  90. } while (node && node.nodeType != 1);
  91.  
  92. if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
  93. return StrutsUtils.nextElement(node, tagName);
  94. }
  95. return node;
  96. };
  97.  
  98. StrutsUtils.previousElement = function(node, tagName) {
  99. if (!node) {
  100. return null;
  101. }
  102. if (tagName) {
  103. tagName = tagName.toLowerCase();
  104. }
  105. do {
  106. node = node.previousSibling;
  107. } while (node && node.nodeType != 1);
  108.  
  109. if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
  110. return StrutsUtils.previousElement(node, tagName);
  111. }
  112. return node;
  113. };
  114.  
  115. StrutsUtils.addOnLoad = function(func) {
  116. var oldonload = window.onload;
  117. if (typeof window.onload != 'function') {
  118. window.onload = func;
  119. } else {
  120. window.onload = function() {
  121. oldonload();
  122. func();
  123. }
  124. }
  125. };
  126.  
  127. StrutsUtils.addEventListener = function(element, name, observer, capture) {
  128. if (element.addEventListener) {
  129. element.addEventListener(name, observer, false);
  130. } else if (element.attachEvent) {
  131. element.attachEvent('on' + name, observer);
  132. }
  133. };
  134.  
  135.  
  136. /* -------------------------------
  137. /* Ajout Spikly le 28/01/2012
  138. /* nouvel espace perso
  139. /* ------------------------------- */
  140.  
  141. utilsProfil = {
  142. init: function() {
  143. this.setBackgroundImage();
  144. this._rewriteUrlDmname();
  145.  
  146. },
  147.  
  148. _rewriteUrlDmname: function() {
  149. if (jQuery(".http").length) {
  150. var preDomName = document.domain.match(/www\.|secure\.|s\-/, "");
  151. if (preDomName == "secure.") {
  152. jQuery(".http").attr("href", jQuery(".http").attr("href").replace(/www\.|secure\.|s\-/, "www."));
  153. } else if (preDomName == "s-") {
  154. jQuery(".http").attr("href", jQuery(".http").attr("href").replace(/www\.|secure\.|s\-/, ""));
  155. }
  156. }
  157. },
  158.  
  159. setBackgroundImage :function(){
  160. var country = this.getCookie('displayZone'),
  161. userLang = this.getCookie('userLang'),
  162. selectedCountry = ['malaysia' , 'indonesia' ,'india' , 'bahrain' ,'jordan' , 'kuwait' ,'lebanon' ,'oman' ,'qatar' , 'saudi-arabia' ,'united-arab-emirates','other-regions-of-middle-east'] ;
  163.  
  164. if(selectedCountry.indexOf(country) > -1 || ['ar' ,'tr'].indexOf(userLang) > -1){
  165. if(!jQuery('.mainContainer').parent().hasClass('registration'))
  166. jQuery(".mainContainer").css('background-image' , 'url("/imagerie/profil/bg-visuel_ar.jpg")')
  167. }else{
  168. if(!jQuery('.mainContainer').parent().hasClass('registration'))
  169. jQuery(".mainContainer").css('background-image' , 'url("/imagerie/profil/bg-visuel.jpg")')
  170. }
  171. },
  172.  
  173. getCookie:function(cname) {
  174. var name = cname + "=";
  175. var ca = document.cookie.split(';');
  176. for(var i = 0; i <ca.length; i++) {
  177. var c = ca[i];
  178. while (c.charAt(0)==' ') {
  179. c = c.substring(1);
  180. }
  181. if (c.indexOf(name) == 0) {
  182. return c.substring(name.length,c.length);
  183. }
  184. }
  185. return "";
  186. }
  187. }
  188.  
  189. jQuery(document).ready(function() {
  190. utilsProfil.init();
  191. });
  192.  
  193. /** < /scripts-v1705/profil/utils.js **/
  194.  
  195. /** > /scripts-v1705/profil/booking-engine.js **/
  196. var bookingEngine = {
  197.  
  198. _init: function(){
  199. bookingEngineRegistration = new BookingEngine("bookingEngine", "bookingEngineRegistration", true);
  200. //Ajax request
  201. ajaxRequest._executeByUrl(
  202. "/bean/getViewBeans.action?beans=SearchCriteriaViewBean|OriginViewBean|CurrenciesViewBean|UserViewBean|WebSiteFunctionnalitiesViewBean|LoyaltyAccountViewBean",
  203. "validatorInvalidState",
  204. "bookingEngine._profilbookingsucess(errors, response)"
  205. );
  206. },
  207.  
  208. _profilbookingsucess : function(errors, response){
  209.  
  210. bookingEngineRegistration.success(errors, response);
  211. var viewBeans = {
  212. UserViewBean : response.viewBeans.UserViewBean,
  213. SearchCriteriaViewBean : response.viewBeans.SearchCriteriaViewBean
  214. }
  215. this._generateproinput(viewBeans);
  216. },
  217.  
  218. _generateproinput : function (viewBeans){
  219. this._setInputProValue(viewBeans);
  220.  
  221. if(jQuery("#identification-reserverContract-boo").val() == '' || jQuery("#identification-reserverContract-boo").val() == jQuery("#identification-reserverContract-boo").attr("title") &&(jQuery("#identification-reserverId-boo").val() == '' || jQuery("#identification-reserverId-boo").val() == jQuery("#identification-reserverId-boo").attr("title"))){
  222. jQuery('#pro-input').hide();
  223. }else{
  224. jQuery('#pro-input').show();
  225. jQuery("#identification-businessTravel-boo").attr('checked',false);
  226. this._setProInputObservers();
  227. }
  228. },
  229.  
  230. _setProInputObservers : function(){
  231. jQuery("#identification-reserverContract-boo , #identification-reserverId-boo").focusout(function () {
  232. if((jQuery("#identification-reserverContract-boo").val() == '' || jQuery("#identification-reserverContract-boo").val() == jQuery("#identification-reserverContract-boo").attr("title")) && (jQuery("#identification-reserverId-boo").val() == '' || jQuery("#identification-reserverId-boo").val() == jQuery("#identification-reserverId-boo").attr("title"))){
  233. jQuery("#identification-businessTravel-boo").attr('checked',false);
  234. }else{
  235. jQuery("#identification-businessTravel-boo").attr('checked',true);
  236. }
  237. });
  238. },
  239.  
  240. _setInputProValue :function(viewBeans){
  241. var AccountContract = "" ;
  242. var AccountId = "";
  243. // if search Criteria load Searched Criter
  244. if(viewBeans.SearchCriteriaViewBean && viewBeans.SearchCriteriaViewBean.accountContract && viewBeans.SearchCriteriaViewBean.accountContract.length>0 && viewBeans.SearchCriteriaViewBean.accountId && viewBeans.SearchCriteriaViewBean.accountId.length>0 ){
  245. AccountContract = viewBeans.SearchCriteriaViewBean.accountContract ;
  246. AccountId = viewBeans.SearchCriteriaViewBean.accountId
  247. } // if not search Criteria load professional Data
  248. else if(viewBeans.UserViewBean && viewBeans.UserViewBean.professionalData && viewBeans.UserViewBean.professionalData.contracts && viewBeans.UserViewBean.professionalData.companyId){
  249. if(viewBeans.UserViewBean.professionalData.contracts && viewBeans.UserViewBean.professionalData.contracts.length >0 && viewBeans.UserViewBean.professionalData.companyId.length >0){
  250. AccountContract = viewBeans.UserViewBean.professionalData.contracts ;
  251. AccountId = viewBeans.UserViewBean.professionalData.companyId;
  252. }
  253. }
  254.  
  255. jQuery("#identification-reserverContract-boo").val(AccountContract);
  256. jQuery("#identification-reserverId-boo").val(AccountId);
  257.  
  258.  
  259. if((jQuery("#identification-reserverContract-boo").val() == '' || jQuery("#identification-reserverContract-boo").val() == jQuery("#identification-reserverContract-boo").attr("title")) && (jQuery("#identification-reserverId-boo").val() == '' || jQuery("#identification-reserverId-boo").val() == jQuery("#identification-reserverId-boo").attr("title"))){
  260. jQuery("#identification-businessTravel-boo").attr('checked',false);
  261. }else{
  262. jQuery("#identification-businessTravel-boo").attr('checked',true);
  263. }
  264.  
  265. }
  266.  
  267. };
  268. jQuery(document).ready(function() {
  269. bookingEngine._init();
  270.  
  271. })
  272. /** < /scripts-v1705/profil/booking-engine.js **/
  273.  
  274. /** > /scripts-v1705/profil/template_utils.js **/
  275.  
  276.  
  277. var template_utils = {
  278.  
  279. /* CONVERT A VARIABLE NAME NESTED IN A STRING (Vous êtes à seulement $nightsToNextTiering) TO A VALUE
  280. * @param [Object] :
  281. * str [String] : a string that holds variable name
  282. * vars [Object] : an objet that holds the variables to implement
  283. */
  284. stringToVarValue : function(obj){
  285. var s = obj.str;
  286. for(var key in obj.vars){
  287. s = s.replace(key, obj.vars[key]);
  288. }
  289. return s;
  290. },
  291.  
  292. /* CONVERT A DATE STRING (2014-08-26T00:00:00) TO A READABLE DATE FORMAT (02/07/2014)
  293. * @param [Object] :
  294. * date [String] : a date
  295. * separator [String] : a separator to concatenate
  296. * lang [String] : test the different date format to return
  297. */
  298. dateFormat : function(obj){
  299. var d = (new Date(obj.date).toString() === 'NaN')? new Date(obj.date.replace(/-/g, "/")) : new Date(obj.date);
  300. var day = (d.getDate().toString().length === 1) ? '0' + d.getDate() : d.getDate();
  301. var month = d.getMonth() + 1;
  302. month = (month.toString().length === 1) ? '0' + month : month;
  303. var year = d.getFullYear();
  304.  
  305. var s = "";
  306. switch(obj.lang){
  307. case "fr" :
  308. case "tr" :
  309. s = day + obj.separator + month + obj.separator + year;
  310. break;
  311. case "en" :
  312. s = month + obj.separator + day + obj.separator + year;
  313. break;
  314.  
  315. default :
  316. s = month + obj.separator + day + obj.separator + year;
  317. break;
  318. }
  319. return s;
  320. }
  321.  
  322. }
  323.  
  324. /** < /scripts-v1705/profil/template_utils.js **/
  325.  
  326. /** > /scripts-v1705/profil/welcome.js **/
  327. var welcome = {
  328.  
  329. init : function(obj){
  330.  
  331. var facebookURL = {
  332. "aclubMember" : "https://www.facebook.com/leclubaccorhotels",
  333. "ALL" : "https://www.facebook.com/accorhotels",
  334. "SOF" : "https://www.facebook.com/Sofitel",
  335. "PUL" : "https://www.facebook.com/accorhotels",
  336. "MGA" : "https://www.facebook.com/accorhotels",
  337. "NOV" : "https://www.facebook.com/Novotelhotels",
  338. "SUI" : "https://www.facebook.com/suitenovotel",
  339. "MER" : "https://www.facebook.com/accorhotels",
  340. "ADG" : "https://www.facebook.com/accorhotels",
  341. "IBS" : "https://www.facebook.com/ibis",
  342. "IBH" : "https://www.facebook.com/ibis",
  343. "IBB" : "https://www.facebook.com/ibis",
  344. "IBP" : "https://www.facebook.com/ibis",
  345. "HOF" : "https://www.facebook.com/HotelF1",
  346. "FOR" : "https://www.facebook.com/accorhotels"
  347. }
  348.  
  349. //PRINT WELCOME MESSAGE
  350. jQuery('.welcome h1>strong').html(obj.firstName.toLowerCase() + ' ' + obj.lastName.toLowerCase());
  351.  
  352. //FACEBOOK BUTTON
  353. var url = (obj.aclubMember)? facebookURL.aclubMember : facebookURL[obj.siteCode];
  354. jQuery('.welcome p')
  355. .css('cursor', 'pointer')
  356. .click(function(e){
  357. //
  358. TagManager._pushVirtualPageView('account::transverse::facebookclick');
  359. //
  360. var o = jQuery(this).find('a').attr('href',url)[0];
  361. return xt_click(o, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::facebookclick');
  362. });
  363. }
  364.  
  365. }
  366. /** < /scripts-v1705/profil/welcome.js **/
  367.  
  368. /** > /scripts-v1705/profil/leftCol.js **/
  369.  
  370. var profilWebAnalytics = {
  371. _callTagClickFavoriteHotel: function() {
  372. TagManager._pushVirtualPageView('account::transverse::favoritehotel');
  373. xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::favoritehotel');
  374. },
  375. _callTagClickSearch: function() {
  376. TagManager._pushVirtualPageView('account::transverse::searchclick');
  377. xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::searchclick');
  378. },
  379. _callTagClickContactUs: function() {
  380. TagManager._pushVirtualPageView('account::transverse::contactus');
  381. xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::contactus');
  382. },
  383. _callTagClickTabFavoriteHotels: function() {
  384. TagManager._pushVirtualPageView('account::favoritehotel::favoritehotel');
  385. xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::favoritehotel::favoritehotel');
  386. },
  387. _callTagClickCarteAbo: function() {
  388. TagManager._pushVirtualPageView('account::favoritehotel::favoritehotel');
  389. xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::favoritehotel::favoritehotel');
  390. }
  391. }
  392.  
  393. var leftColUtils = {
  394. viewBeans: null,
  395. page: '',
  396. init: function(param) {
  397.  
  398. this.viewBeans = param.viewBeans;
  399. this.page = param.page;
  400.  
  401. this.slidePage();
  402.  
  403. this.buildFavoriteHotels();
  404.  
  405. this.bookingEvnt();
  406.  
  407. this.configureMenu();
  408.  
  409. this.buildCallTemplate();
  410.  
  411. this.buildClick2Call();
  412.  
  413. this.setFaqResaUrl();
  414.  
  415. this.setFaqFidelityUrl();
  416.  
  417. this.leftMenuEvnt();
  418.  
  419. var activeBookingCount = false;
  420. if (this.viewBeans.HistoricViewBean)
  421. activeBookingCount = this.viewBeans.HistoricViewBean.currentFolders.length;
  422. else if(this.viewBeans.AccountViewBean)
  423. activeBookingCount = this.viewBeans.AccountViewBean.activeBookingCount;
  424. if (activeBookingCount)
  425. jQuery('#current_booking_nb').html('&nbsp;('+activeBookingCount+')&nbsp;');
  426. },
  427. slidePage: function() {
  428. var $anchor;
  429. if (jQuery("html, body").hasClass("booking")) {
  430. if (leftColUtils.getParamLocation("anchor") == "booking") {
  431. $anchor = jQuery('#reservations');
  432. jQuery('html, body').animate({scrollTop: $anchor.offset().top - 90}, 500);
  433. } else if (leftColUtils.getParamLocation("anchor") == "history") {
  434. $anchor = jQuery('#history');
  435. jQuery('html, body').animate({scrollTop: $anchor.offset().top - 90}, 500);
  436. }
  437. }
  438. },
  439. buildFavoriteHotels: function(optionalArr) {
  440. var $select = jQuery('.user_favorite_destination');
  441. var $saveOption0 = jQuery(".user_favorite_destination option:eq(0)");
  442.  
  443. $select.empty();
  444. $select.append($saveOption0);
  445.  
  446. var arr = (optionalArr)? optionalArr : this.viewBeans.UserViewBean.favoriteHotels;
  447.  
  448. var $option;
  449. if (arr) {
  450. if (arr.length > 0) {
  451. for (var i = 0; i < arr.length; i++) {
  452. if (arr[i].bookableOnTheSameSite) {
  453. $option = this.buildOption(arr[i]);
  454. $select.append($option);
  455. }else if(arr[i].originalBean){
  456. $option = this.buildOption(arr[i].originalBean);
  457. $select.append($option);
  458. }
  459. }
  460. } else {
  461. jQuery(".destination_switch a").hide();
  462. }
  463. }
  464. if ($select.children().length === 1) {
  465. jQuery(".destination_switch a").hide();
  466. }
  467. },
  468.  
  469. buildOption : function(obj){
  470. var $option = jQuery('<option></option>');
  471. $option.html(obj.name);
  472. $option.attr('value', obj.code);
  473. return $option;
  474. },
  475.  
  476. bookingEvnt: function() {
  477. jQuery("#engine-submit .tSubmit").click(function() {
  478. profilWebAnalytics._callTagClickSearch();
  479. });
  480.  
  481. jQuery(".leftCol .toogle").click(function() {
  482.  
  483. var userLocalization = leftColUtils._readCookie('userLocalization'),
  484. userLanguage = (leftColUtils._readCookie('userPrefLocalization'))? leftColUtils._readCookie('userPrefLocalization') : leftColUtils.viewBeans.OriginViewBean.codeLang,
  485. userLanguage = (userLanguage === "en") ? "gb" : userLanguage;
  486. if(userLanguage === 'gb' || userLanguage === 'fr'){
  487. window.location = '/' + userLanguage + '/support/index.shtml';
  488. }else{
  489. if (!jQuery(this).hasClass("on")) {
  490. profilWebAnalytics._callTagClickContactUs();
  491. }
  492. jQuery(this).toggleClass("on");
  493. jQuery(this).next("ul").slideToggle("normal");
  494. }
  495. return false;
  496. });
  497.  
  498. jQuery(".destination_switch a").click(function() {
  499.  
  500. if (!jQuery("fieldset.destination").hasClass("fav")) {
  501. profilWebAnalytics._callTagClickFavoriteHotel();
  502. }
  503.  
  504. jQuery("fieldset.destination").toggleClass("fav");
  505. jQuery(".tSearchDestination").val(jQuery(".tSearchDestination").attr("title"));
  506. jQuery(".user_favorite_destination option").removeAttr("selected");
  507. jQuery(".user_favorite_destination option:eq(0)").attr("selected", "selected");
  508. return false;
  509. });
  510.  
  511. jQuery(".user_favorite_destination").change(function() {
  512. if (jQuery(this).val() != "") {
  513. jQuery(".tSearchDestination").val(jQuery(this).val());
  514. } else {
  515. jQuery(".tSearchDestination").val("");
  516. }
  517. })
  518.  
  519. jQuery(".tSearchDestination").addClass("disabled").focus(function() {
  520. if (jQuery(this).val() == jQuery(this).attr("title"))
  521. jQuery(this).val("").removeClass("disabled");
  522. });
  523.  
  524. jQuery(".tSearchDestination").blur(function() {
  525. if (jQuery(this).val() == "")
  526. jQuery(this).val(jQuery(this).attr("title")).addClass("disabled");
  527. });
  528.  
  529. },
  530. configureMenu: function(obj) {
  531.  
  532. var siteCode = this.viewBeans.OriginViewBean.siteCode;
  533. if (this.viewBeans.LoyaltyAccountViewBean && this.viewBeans.LoyaltyAccountViewBean.account) {
  534.  
  535. var defaultCard = this.viewBeans.LoyaltyAccountViewBean.account.loyaltyCards[0];
  536. var subscriptionCard = this.viewBeans.LoyaltyAccountViewBean.account.subscriptionCards[0];
  537. if (defaultCard) {
  538. if (defaultCard.links.CardFinalization) {
  539. this.cancelMenuList('myCarte',0);
  540. jQuery('#myCarte').show();
  541. jQuery('#myCarte ul').children().hide();
  542. jQuery('#myCarte ul :first-child').show();
  543. } else {
  544. jQuery('#myCarte').show();
  545. }
  546. }
  547. }
  548.  
  549. if(subscriptionCard){
  550. jQuery('#myCarteAbo').show();
  551. }else if(defaultCard){
  552. if(defaultCard.type === 'D4' || defaultCard.type === 'D5' || defaultCard.type === 'D6' || defaultCard.type === 'D7' || defaultCard.type === 'D9' || defaultCard.cardGroup === 'WW'){
  553. jQuery('#myCarteAbo').hide();
  554. }else{
  555. if (siteCode === "ALL" || siteCode === "IBB" || siteCode === "IBS" || siteCode === "IBH" || siteCode === "IBP" || siteCode === "BUS") {
  556. jQuery('#myCarteAbo').show();
  557. }
  558. }
  559. }else if(!subscriptionCard && !defaultCard){
  560. if (siteCode === "ALL" || siteCode === "IBB" || siteCode === "IBS" || siteCode === "IBH" || siteCode === "IBP" || siteCode === "BUS") {
  561. jQuery('#myCarteAbo').show();
  562. }else{
  563. jQuery('#myCarteAbo').hide();
  564. }
  565. }
  566.  
  567.  
  568. //My WALLET
  569. if(this.viewBeans.UserViewBean){
  570. if(this.viewBeans.UserViewBean.eligibleWallet == true){
  571. jQuery('#myProfil').find('ul li:eq(2)').show();
  572. }else{
  573. jQuery('#myProfil').find('ul li:eq(2)').hide();
  574. }
  575. }
  576.  
  577.  
  578. },
  579. buildCallTemplate: function() {
  580. var isWhiteLabel = leftColUtils.viewBeans.OriginViewBean.subSiteCode && leftColUtils.viewBeans.OriginViewBean.subSiteCode.toUpperCase() === 'WLB';
  581.  
  582. var $call_us = jQuery(".contact_us ul>li:eq(0)>ul>li:eq(1)")
  583. if (! isWhiteLabel) {
  584. //var $call_us = jQuery(".contact_us ul>li:eq(0)>ul>li:eq(1)")
  585.  
  586. var userLocalization = this._readCookie('userLocalization');
  587. var userLanguage = (this._readCookie('userPrefLocalization'))? this._readCookie('userPrefLocalization') : this.viewBeans.OriginViewBean.codeLang;
  588. userLanguage = (userLanguage === "en") ? "gb" : userLanguage;
  589. //var url = "/hotel-cms/" + userLanguage + "/profil/call-center_" + userLocalization + ".js";
  590. var url = "/geoloc/geoloc.cgi?file=/" + userLanguage + "/profil/call-center.js";
  591. jQuery.ajax({
  592. type: "GET",
  593. url: url,
  594. dataType: "json",
  595. success: function(data) {
  596. var arr = data['call-center-fh'];
  597. var phoneNumber, phoneCallRate;
  598.  
  599. if (arr.length > 0) {
  600. for (var i = 0; i < arr.length; i++) {
  601. if (arr[i].brand === leftColUtils.viewBeans.OriginViewBean.siteCode) {
  602. phoneNumber = arr[i].phoneNumber;
  603. phoneCallRate = arr[i].phoneCallRate;
  604. $call_us.setTemplateURL("/templates-v1705/profil/call_us.tpl", null, {filter_data: false});
  605. $call_us.setParam('call_us', template_utils.stringToVarValue({
  606. "str": registration_i18n.leftCol.call_us,
  607. "vars": {
  608. "$phoneNumber": phoneNumber,
  609. "$phoneCallRate": phoneCallRate
  610. }
  611. }));
  612. $call_us.processTemplate();
  613. if (phoneCallRate === null || phoneCallRate === "") {
  614. jQuery(".call_us_tel_number span").hide();
  615. }
  616. $call_us.show();
  617. break;
  618. } else {
  619. $call_us.hide();
  620. }
  621. }
  622. } else {
  623. $call_us.hide();
  624. }
  625. },
  626. error: function(data) {
  627. $call_us.hide();
  628. }
  629. });
  630. }else{
  631. var $lang = (jQuery("html").attr("lang") == "en") ? "gb" : jQuery("html").attr("lang");
  632. $call_us.css("padding", "11px 0 15px 46px").html('<a href="/'+ $lang +'/aide/callcenters.htm" class="popin p-m-a-s-w:800-h:400-type:infos-ref:callcenterhelp">'+registration_i18n.leftCol.call_us_WL+'</a>');
  633. if (popins) {
  634. // open call us in popin mode
  635. popins.init();
  636. }
  637. }
  638. },
  639. _readCookie: function(name) {
  640. var nameEQ = name + "=";
  641. var ca = document.cookie.split(';');
  642. for (var i = 0; i < ca.length; i++) {
  643. var c = ca[i];
  644. while (c.charAt(0) == ' ')
  645. c = c.substring(1, c.length);
  646. if (c.indexOf(nameEQ) == 0) {
  647. if (name == "authentification") {
  648. return decodeURIComponent(c.substring(nameEQ.length, c.length));
  649. } else {
  650. return c.substring(nameEQ.length, c.length);
  651. }
  652. }
  653. }
  654. return null;
  655. },
  656. buildClick2Call: function() {
  657. click2Call.init(this.viewBeans.OriginViewBean.accorhotels, this.page, jQuery('.orange_call_service'));
  658. },
  659. setFaqResaUrl: function() {
  660. var codeLang = (this.viewBeans.OriginViewBean.codeLang === 'en')? 'gb' : this.viewBeans.OriginViewBean.codeLang;
  661. var siteCode = this.viewBeans.OriginViewBean.siteCode;
  662. siteCode = (siteCode === 'IBP' && this.viewBeans.OriginViewBean.subSiteCode !== null)? this.viewBeans.OriginViewBean.subSiteCode : this.viewBeans.OriginViewBean.siteCode;
  663.  
  664. var faqURL = {
  665. "ACP" : "http://int1-accorplus.hotelandbook.com/LANG/aide/aide.shtml",
  666. "ALL": "https://int1-www.accorhotels.com/LANG/contact/contact.shtml",
  667. "SOF": "http://int1-www.sofitel.com/LANG/contact/ask-question-form.shtml",
  668. "PUL": "http://int1-www.pullmanhotels.com/LANG/contact/ask-question-form.shtml",
  669. "MGA": "http://int1-www.mgallery.com/LANG/help/booking.shtml",
  670. "NOV": "http://int1-www.novotel.com/LANG/help/index.shtml",
  671. "SUI": "http://www.suitenovotel.com/LANG/help/index.shtml#reservation",
  672. "MER": "http://int1-www.mercure.com/LANG/help/booking.shtml",
  673. "ADG": "http://int1-www.adagio-city.com/LANG/contact/ask-question-form.shtml",
  674. "IBP": "http://int1-www.ibis.com/LANG/frequently-asked-question/reservation.shtml",
  675. "IBS": "http://ibisstyleshotel.ibis.com/LANG/frequently-asked-question/reservation.shtml",
  676. "IBH": "http://ibishotel.ibis.com/LANG/frequently-asked-question/reservation.shtml",
  677. "IBB": "http://ibisbudgethotel.ibis.com/LANG/frequently-asked-question/reservation.shtml",
  678. "HOF": "http://int1-www.hotelf1.com/LANG/frequently-asked-questions/reservation.html",
  679. "FOR": "https://int1-www.accorhotels.com/LANG/aide/aide.shtml",
  680. "HOF": "",
  681. "FOR": "",
  682. "GME": "",
  683. "MSH": "",
  684. "WTH": "",
  685. "WTC": "",
  686. "WAF": ""
  687. }
  688. if (siteCode === "HOF" || siteCode === "FOR") {
  689. jQuery('.contact_us>ul>li:last').hide();
  690. } else {
  691. var url = (typeof faqURL[siteCode] !== 'undefined')?faqURL[siteCode].replace(/LANG/g, codeLang) :'';
  692. jQuery('.faq_resa').attr('href', url);
  693. }
  694. },
  695. setFaqFidelityUrl: function() {
  696. var codeLang = (this.viewBeans.OriginViewBean.codeLang === 'en')? 'gb' : this.viewBeans.OriginViewBean.codeLang;
  697. var siteCode = this.viewBeans.OriginViewBean.siteCode;
  698. siteCode = (siteCode === 'IBP' && this.viewBeans.OriginViewBean.subSiteCode !== null)? this.viewBeans.OriginViewBean.subSiteCode : this.viewBeans.OriginViewBean.siteCode;
  699.  
  700. var faqURL = {
  701. "ACP" : "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  702. "ALL": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  703. "SOF": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  704. "PUL": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  705. "MGA": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  706. "NOV": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  707. "SUI": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  708. "MER": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  709. "ADG": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  710. "IBP": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  711. "IBS": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  712. "IBH": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  713. "IBB": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
  714. "HOF": "",
  715. "FOR": "",
  716. "GME": "",
  717. "MSH": "",
  718. "WTH": "",
  719. "WTC": "",
  720. "WAF": ""
  721. }
  722.  
  723. if (siteCode === "HOF" || siteCode === "FOR") {
  724. jQuery('.contact_us>ul>li:last').hide();
  725. } else {
  726. var url = (typeof faqURL[siteCode] !== 'undefined')?faqURL[siteCode].replace(/LANG/g, codeLang) :'';
  727. jQuery('.faq_loyalty').attr('href', url);
  728. }
  729. },
  730. cancelMenuList: function(id,escape) {
  731. var i= 0;
  732. jQuery('#' + id + ' ul>li>a').each(function(){
  733. if(escape>i)
  734. jQuery(this).attr('href', '')
  735. .css({'color': '#DFDFDF', 'cursor': 'default'})
  736. .bind('click', function(event) {
  737. return false;
  738. });
  739. })
  740.  
  741. },
  742. getParamLocation: function(sname) {
  743. var params = location.search.substr(location.search.indexOf("?") + 1);
  744. var sval = "";
  745. params = params.split("&");
  746. for (var i = 0; i < params.length; i++)
  747. {
  748. temp = params[i].split("=");
  749. if ([temp[0]] == sname) {
  750. sval = temp[1];
  751. }
  752. }
  753. return sval;
  754. },
  755. setActiveMenu: function(numP, numF) {
  756. var menu = jQuery(".leftCol_elements .menu > ul > li:eq(" + numP + ")"),
  757. subMenu = menu.find("ul li:eq(" + numF + ")");
  758.  
  759. menu.addClass("current");
  760.  
  761. if (subMenu.length > 0) {
  762. menu.find(" > a").next("ul").show();
  763. subMenu.addClass("sCurrent");
  764. }
  765. },
  766. leftMenuEvnt: function() {
  767. if (jQuery(".leftCol_elements .menu").size() == 0)
  768. return false;
  769. jQuery(".menu > ul > li > ul").each(function() {
  770. jQuery(this).find("li:eq(0)")
  771. .addClass("first");
  772. });
  773. jQuery(".menu ul").find("ul").hide();
  774.  
  775. var menu_rub = jQuery('.menu > ul > li > a'),
  776. menu_sub = jQuery('.menu > ul > li > ul');
  777.  
  778. menu_rub.click(function(event) {
  779. event.preventDefault();
  780. if (! jQuery(this).hasClass("direct_link")) {
  781. // les liens avec direct_link n'ont pas besoin d'afficher de se déplier pour afficher le sous-menu
  782. if (jQuery(this).parents("li").attr('class') != 'current') {
  783. menu_sub.slideUp('normal');
  784. jQuery(this).stop().next().slideToggle('normal');
  785. menu_rub.parents("li").removeClass('current');
  786. jQuery(this).parents("li").addClass('current');
  787. } else {
  788. jQuery(this).parents("li").removeClass('current');
  789. jQuery(this).stop().next().slideUp('normal');
  790. }
  791. }
  792. });
  793.  
  794. var jBody = jQuery("body");
  795. if (jBody.hasClass("booking")) {
  796. if (leftColUtils.getParamLocation("anchor") == "booking") {
  797. leftColUtils.setActiveMenu(0, 0);
  798. } else if (leftColUtils.getParamLocation("anchor") == "history") {
  799. leftColUtils.setActiveMenu(0, 1);
  800. }
  801. } else if (jBody.hasClass("favoritehotels")) {
  802. leftColUtils.setActiveMenu(1, 0);
  803. } else if (jBody.hasClass("personaldetails")) {
  804. leftColUtils.setActiveMenu(2, 0);
  805. }else if (jBody.hasClass("contact-informations")) {
  806. leftColUtils.setActiveMenu(2, 1);
  807. } else if (jBody.hasClass("preferences")) {
  808. leftColUtils.setActiveMenu(2, 3);
  809. } else if (jBody.hasClass("newsletters")) {
  810. leftColUtils.setActiveMenu(2, 4);
  811. } else if (jBody.hasClass("pointHistory")) {
  812. leftColUtils.setActiveMenu(3, 0);
  813. } else if (jBody.hasClass("mycurrentoffers")) {
  814. leftColUtils.setActiveMenu(3, 1);
  815. } else if (jBody.hasClass("rewards")) {
  816. leftColUtils.setActiveMenu(3, 2);
  817. } else if (jBody.hasClass("subscription")) {
  818. leftColUtils.setActiveMenu(4, 0);
  819. } else if (jBody.hasClass("payment-cards")) {
  820. leftColUtils.setActiveMenu(2, 2);
  821. }
  822.  
  823.  
  824. jQuery("#myFavoriteHotels").click(function() {
  825. profilWebAnalytics._callTagClickTabFavoriteHotels();
  826. document.location.href = "/" + getDirLangFromHtmlAttrib() + "/profil/favoritehotels.shtml";
  827. });
  828.  
  829. jQuery("#myCarteAbo").click(function() {
  830. document.location.href = "/" + getDirLangFromHtmlAttrib() + "/profil/subscription.shtml";
  831. });
  832. }
  833. }
  834.  
  835. /** < /scripts-v1705/profil/leftCol.js **/
  836.  
  837. /** > /scripts-v1705/profil/profil_popin.js **/
  838.  
  839. var profil_popin = {
  840.  
  841. init : function(param){
  842. var datas = {
  843. modal: param.cls.indexOf('-m-') > -1,
  844. drag: param.cls.indexOf('-d-') > -1,
  845. redim: param.cls.indexOf('-r-') > -1,
  846. iframe: param.cls.indexOf('-i-') > -1,
  847. scrollable: param.cls.indexOf('-s-') > -1 ? "auto" : "no",
  848. ajax: param.cls.indexOf('-a-') > -1,
  849. width: /w:\d+/.test(param.cls) ? parseInt(param.cls.match(/w:(\d+)/)[1], 10) : null,
  850. height: /h:\d+/.test(param.cls) ? parseInt(param.cls.match(/h:(\d+)/)[1], 10) : null,
  851. type: param.cls.match(/type:([^\s-]+)/)[1],
  852. ref: param.cls.match(/ref:([^\s-]+)/)[1],
  853. url : "../../common/profil/message_popin.html",
  854. complete: /complete:([^\s-]+)/.test(param.cls) ? param.cls.match(/complete:([^\s-]+)/)[1] : null,
  855. objcomplete: /objcomplete:([^\s-]+)/.test(param.cls) ? param.cls.match(/objcomplete:([^\s-]+)/)[1] : null
  856. };
  857.  
  858. if(param.popinType === 'redirect'){
  859. datas.url = param.url;
  860. }
  861.  
  862. if (param.onClose) {
  863. datas.onClose = param.onClose;
  864. }
  865.  
  866. if(datas.ajax) {
  867.  
  868. //RESIZE THE BODY ELEMENT WHEN POPIN IS CLOSED
  869. var docHeight = jQuery('body').outerHeight(true) + 'px';
  870. jQuery(document).bind('closePopin', function(evt){
  871. jQuery('body').css('height', 'auto');
  872. });
  873.  
  874. jQuery.get(datas.url, function (response) {
  875. popins.openPopin(jQuery("<div class='popinBaseContent'>" + response + "</div>").appendTo('.mainContainer'), datas);
  876.  
  877. if(param.popinType === 'redirect'){
  878. datas.url = param.url;
  879. jQuery(".ui-dialog-titlebar").css("display", "none");
  880. jQuery(".popinBaseContent .msgBox").html(param.msg);
  881. jQuery(".popinBaseContent .btn .stop span").html(param.cancel);
  882.  
  883. jQuery(".popinBaseContent .btn .next span").html(param["continue"]).click(function(event){
  884. if(typeof param.loadProcess != 'undefined'){
  885. jQuery.globalEval(param.loadProcess+ "()");
  886. } else {
  887. jQuery(".ui-dialog-titlebar-close").click();
  888. window.location = param.redirectURL;
  889. return false;
  890. }
  891.  
  892. });
  893.  
  894. jQuery(".popinBaseContent").css({width : 'auto', height : 'auto'})
  895.  
  896. jQuery(".close a, a.close, .stop").click(function(){
  897. jQuery(".ui-dialog-titlebar-close").click();
  898. return false;
  899. });
  900.  
  901. }else{
  902. jQuery(".popinProfil h2").html(param.title);
  903. jQuery(".popinProfil p.msgBox").html(param.msg);
  904. if(param.userEmail != param.newUserEmail){
  905. jQuery(".popinProfil p.newEmailTerms").html(param.newEmailTerms);
  906. if(jQuery(".popinProfil p.newEmailTerms span.newUserEmail").size() > 0){
  907. jQuery(".popinProfil p.newEmailTerms span.newUserEmail").html(param.newUserEmail);
  908. }else if(jQuery(".popinProfil p.msgBox span.newUserEmail").size() > 0){
  909. jQuery(".popinProfil p.msgBox span.newUserEmail").html(param.newUserEmail);
  910. }
  911. }
  912. jQuery(".close a span").html(param.closePopin);
  913. jQuery(".close a, a.close").click(function(){
  914. jQuery(".ui-dialog-titlebar-close").click();
  915. if(param.redirectToClose){
  916. window.location = param.redirectToClose;
  917. }
  918. return false;
  919. });
  920.  
  921. /*RESIZE FOR THE PROFIL PAGES*/
  922. jQuery(".popinBaseContent").css('height', jQuery('.popin-personalValidation').css('height'));
  923. jQuery('.ui-widget-overlay').css('height', docHeight);
  924. jQuery('body').css('height', docHeight);
  925. }
  926.  
  927. });
  928. }else if(datas.iframe) {
  929. currentPopinIframe = jQuery('<div class="popin' + datas.ref + '"><iframe allowtransparency="true" class="popinBaseContent" src="about:blank" frameborder="0" scrolling="' + datas.scrollable + '"></iframe></div>').appendTo(document.body).data('popin', datas);
  930. popins.openPopin(currentPopinIframe, datas);
  931. }else{
  932. popins.openPopin(jQuery('div.' + datas.ref).data('popin', datas), datas);
  933. }
  934. }
  935. }
  936. /** < /scripts-v1705/profil/profil_popin.js **/
  937.  
  938. jQuery.noConflict();
  939.  
  940. /** > /scripts-v1705/profil/duplicate-card.js **/
  941. var duplicateCard = {
  942. viewBeans : null,
  943. returnCodeDuplicateisOne : false,
  944. initPopin : function(viewBeans){
  945. duplicateCard.print();
  946. duplicateCard.viewBeans = viewBeans;
  947. var $duplicateCard = jQuery('.js-link-letter');
  948. $duplicateCard.bind('click', function(event) {
  949. event.preventDefault;
  950. if(!duplicateCard.returnCodeDuplicateisOne){
  951. ajaxRequest._executeByUrl(
  952. "/ajax/loyalty/duplicateCard.action?cardNumber="+jQuery(event.currentTarget).data('card'),
  953. "none",
  954. "duplicateCard.duplicate(errors, response)"
  955. );
  956. } else {
  957. var data = {
  958. cls: 'p-m-a-w:560-h:170-s:1-type:infos-ref:duplicateCard',
  959. title : registration_i18n["dashboard"]["lc_infos"]["ask_card_by_post"],
  960. closePopin : registration_i18n["popinMessage"]["close"],
  961. msg : registration_i18n["dashboard"]["lc_infos"]["card_duplicate_success_address"]
  962. };
  963. profil_popin.init(data);
  964. }
  965.  
  966. });
  967. },
  968.  
  969. duplicate : function(errors, response){
  970. var data = {
  971. cls: 'p-m-a-w:560-h:170-s:1-type:infos-ref:duplicateCard',
  972. title : registration_i18n["dashboard"]["lc_infos"]["ask_card_by_post"],
  973. closePopin : registration_i18n["popinMessage"]["close"]
  974. };
  975. if(errors && errors.length > 0){
  976. data.msg = registration_i18n["dashboard"]["lc_infos"]["card_duplicate_error"];
  977. } else {
  978. if(response.viewBeans && response.viewBeans.DuplicateCardResultViewBean) {
  979. var codeRetour = response.viewBeans.DuplicateCardResultViewBean.codeRetour;
  980. var $duplicateCardElt = jQuery('.js-link-letter');
  981. if(codeRetour === 0){ // demande prise en compte
  982. $contenu = $duplicateCardElt.html();
  983. $duplicateCardElt
  984. .find('p')
  985. .unwrap()
  986. .empty()
  987. .html('<i class="sprite sprite-letter"></i>' + registration_i18n["dashboard"]["lc_infos"]["card_fabrication_progress"]);
  988. data.msg = registration_i18n["dashboard"]["lc_infos"]["card_duplicate_success"];
  989. } else if (codeRetour === 1){ // ok mais inviter a saisir adresse
  990. data.msg = registration_i18n["dashboard"]["lc_infos"]["card_duplicate_success_address"];
  991. duplicateCard.returnCodeDuplicateisOne = true;
  992. }
  993. }
  994. }
  995. profil_popin.init(data);
  996. },
  997.  
  998. print : function(){
  999. jQuery(".js-link-print").click(function(){
  1000. var cardNumber = jQuery(this).data('card');
  1001. var url = "/pdf/open.action?type=1&cardNumber="+cardNumber;
  1002. if(jQuery.browser.msie){
  1003. url = "/pdf/download.action?type=1&cardNumber="+cardNumber;
  1004. }
  1005. jQuery(this).attr('href', url);
  1006.  
  1007. });
  1008. },
  1009. printed : function(errors, response){
  1010. if(errors && errors.length > 0){
  1011.  
  1012. } else {
  1013.  
  1014. }
  1015. }
  1016.  
  1017.  
  1018. };
  1019. /** < /scripts-v1705/profil/duplicate-card.js **/
  1020.  
  1021. /** > /scripts-v1705/profil/subscription.js **/
  1022. (function(window, undefined) {
  1023.  
  1024. var viewBeans = {};
  1025.  
  1026. var $user_cards;
  1027.  
  1028. function init(errors, response) {
  1029. viewBeans.LoyaltyAccountViewBean = response.viewBeans.LoyaltyAccountViewBean;
  1030. viewBeans.AClubViewBean = response.viewBeans.AClubViewBean;
  1031. viewBeans.OriginViewBean = response.viewBeans.OriginViewBean;
  1032.  
  1033. //WELCOME MESSAGE AND FACEBOOK BUTTON
  1034. welcome.init({
  1035. firstName: viewBeans.UserViewBean.firstName,
  1036. lastName: viewBeans.UserViewBean.lastName,
  1037. aclubMember: viewBeans.AClubViewBean.aclubMember,
  1038. siteCode: viewBeans.OriginViewBean.siteCode
  1039. });
  1040.  
  1041. if (viewBeans.LoyaltyAccountViewBean.account && !viewBeans.LoyaltyAccountViewBean.account.subscriptionCards) {
  1042. viewBeans.LoyaltyAccountViewBean.account.subscriptionCards = [];
  1043. }
  1044.  
  1045. printCard();
  1046. manageLeftCol();
  1047.  
  1048. //
  1049. trackersXiti();
  1050. }
  1051.  
  1052. function printCard() {
  1053. var dates = [], subscriptionCards = [];
  1054. var cardType;
  1055. var hasAFGBCard = false;
  1056. var hasIbisCard = false;
  1057. var isAccountLocked;
  1058.  
  1059. if (viewBeans.LoyaltyAccountViewBean.account) {
  1060.  
  1061. isAccountLocked = viewBeans.LoyaltyAccountViewBean.account.locked;
  1062.  
  1063. for (var i = 0; i < viewBeans.LoyaltyAccountViewBean.account.subscriptionCards.length; i++) {
  1064.  
  1065. var myRegexDate = new RegExp("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})");
  1066.  
  1067. var resultDate = myRegexDate.exec(viewBeans.LoyaltyAccountViewBean.account.subscriptionCards[i].cardExpirationDate);
  1068. var cardExpirationDate = new Date(resultDate[1], resultDate[2] - 1, resultDate[3]);
  1069. cardExpirationDate = utils.printDate(cardExpirationDate, i18n.calendar.displayDateFormat);
  1070. dates.push(cardExpirationDate);
  1071.  
  1072. cardType = viewBeans.LoyaltyAccountViewBean.account.subscriptionCards[i].type;
  1073. if(cardType === "B3" || cardType === "B4" || cardType === "B5" || cardType === "B6" || cardType === "FavoriteGuestBusiness"){
  1074. hasAFGBCard = true;
  1075. }else if(cardType === "FI"){
  1076. hasIbisCard = true;
  1077. }
  1078. }
  1079.  
  1080. subscriptionCards = viewBeans.LoyaltyAccountViewBean.account.subscriptionCards;
  1081. }
  1082.  
  1083. var isBusinnesTravelSite = (viewBeans.OriginViewBean.siteCode === 'ALL' && viewBeans.OriginViewBean.subSiteCode === 'BIZ' && hasAFGBCard === false) ? true : false;
  1084. var isIbisSite = (viewBeans.OriginViewBean.siteCode === 'IBP')? true : false;
  1085. var randomCard = Math.round(Math.random());
  1086.  
  1087. $user_cards.setTemplateURL("../../templates-v1705/profil/subscription.tpl", null, {filter_data: false});
  1088. $user_cards.setParam("i18n", registration_i18n);
  1089. $user_cards.setParam("dates", dates);
  1090. $user_cards.setParam("isAccountLocked", isAccountLocked);
  1091. $user_cards.setParam("isBusinnesTravelSite", isBusinnesTravelSite);
  1092. $user_cards.setParam("isIbisSite", isIbisSite);
  1093. $user_cards.setParam("hasIbisCard", hasIbisCard);
  1094. $user_cards.setParam("hasAFGBCard", hasAFGBCard);
  1095. $user_cards.setParam("randomCard", randomCard);
  1096. $user_cards.processTemplate(subscriptionCards);
  1097. $user_cards.processTemplateStop(duplicateCard.initPopin(viewBeans));
  1098.  
  1099. //CHECK FOR LOCKEDACCOUNT CLASS AND DEACTIVATE THE TEMPLATES LINKS
  1100. jQuery('.user_cards .lockedAccount').each(function(element, index){
  1101. jQuery(this)
  1102. .css('cursor', 'default')
  1103. .find('span').css('cursor', 'default');
  1104. jQuery(this).click(function(event){
  1105. return false;
  1106. });
  1107. });
  1108.  
  1109. }
  1110.  
  1111. function manageLeftCol() {
  1112. leftColUtils.init({viewBeans: viewBeans, page: 'subscription'});
  1113. }
  1114.  
  1115. function trackersXiti() {
  1116. jQuery(".card.ibis.expired a.btnMore").click(function(e) {
  1117. TagManager._pushVirtualPageView('account::subscription::renewibissubscription');
  1118. xt_click(this, 'C', WebAnalyticsTools._getLv2Code(), 'account::subscription::renewibissubscription', 'N');
  1119. });
  1120. jQuery(".card.accor.expired a.btnMore").click(function(e) {
  1121. TagManager._pushVirtualPageView('account::subscription::renewaccorsubscription');
  1122. xt_click(this, 'C', WebAnalyticsTools._getLv2Code(), 'account::subscription::renewaccorsubscription', 'N');
  1123. });
  1124. jQuery(".card.ibis.subscription a.btnMore").click(function(e) {
  1125. TagManager._pushVirtualPageView('account::subscription::subscriptionoffer');
  1126. xt_click(this, 'C', WebAnalyticsTools._getLv2Code(), 'account::subscription::subscriptionoffer', 'N');
  1127. });
  1128. jQuery(".subscription .card a.btnMore").click(function(e) {
  1129. TagManager._pushVirtualPageView('account::subscription::validatetermsofsales');
  1130. });
  1131. }
  1132.  
  1133. var tagGTMbusinessPlus = {
  1134. init: function() {
  1135. jQuery(".card.accor.expired a.btnMore").click(function(e){
  1136. e.preventDefault();
  1137. tagGTMbusinessPlus._cardDiscover(this.href);
  1138. })
  1139. jQuery(".user_cards .card a.btnMore").click(function(e){
  1140. e.preventDefault();
  1141. tagGTMbusinessPlus._reNewSubscription(this.href);
  1142. });
  1143. },
  1144. _cardDiscover:function(link){
  1145. this._addTagGTM({
  1146. 'event': 'GAevent',
  1147. 'eventCategory': 'Profile page',
  1148. 'eventAction': 'My subscription cards - Click on CTA',
  1149. 'eventLabel': 'Business Plus - Discover'
  1150. });
  1151. this._callLink(link);
  1152. },
  1153. _reNewSubscription:function(link){
  1154. this._addTagGTM({
  1155. 'event': 'GAevent',
  1156. 'eventCategory': 'Profile page',
  1157. 'eventAction': 'My subscription cards - Click on CTA',
  1158. 'eventLabel': 'Business Plus - Renew subscription'
  1159. });
  1160. this._callLink(link);
  1161. },
  1162. _callLink:function(link){
  1163. setTimeout(function(){window.location.href=link} , 1500);
  1164. },
  1165. _addTagGTM : function(data){
  1166. if(typeof TagManager !== undefined || TagManager != null){
  1167. TagManager.pushDataCustom({
  1168. 'event': data.event,
  1169. 'eventCategory': data.eventCategory,
  1170. 'eventAction': data.eventAction,
  1171. 'eventLabel': data.eventLabel
  1172. });
  1173. }
  1174. }
  1175. };
  1176.  
  1177. window.Subscription = {};
  1178. Subscription.accessControl = accessControl;
  1179. Subscription.init = init;
  1180.  
  1181. jQuery(document).ready(function() {
  1182. jQuery.noConflict();
  1183.  
  1184. $user_cards = jQuery('.user_cards');
  1185.  
  1186. ajaxRequest._executeByUrl("/bean/getViewBeans.action?beans=UserViewBean",
  1187. "tAjaxError",
  1188. "Subscription.accessControl(errors, response)");
  1189. });
  1190.  
  1191. jQuery(window).load(function() {
  1192. tagGTMbusinessPlus.init();
  1193. });
  1194.  
  1195. function accessControl(errors, response) {
  1196. if (response.viewBeans.UserViewBean && response.viewBeans.UserViewBean.identified === true) {
  1197. viewBeans.UserViewBean = response.viewBeans.UserViewBean;
  1198. ajaxRequest._executeByUrl("/bean/getViewBeans.action?beans=OriginViewBean|LoyaltyAccountViewBean|AClubViewBean",
  1199. "tAjaxError",
  1200. "Subscription.init(errors, response)");
  1201. } else {
  1202. document.location.href = "/" + getDirLangFromHtmlAttrib() + "/profil/login.shtml";
  1203. }
  1204. }
  1205.  
  1206. })(window);
  1207.  
  1208. /** < /scripts-v1705/profil/subscription.js **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement