$(window).on('load', function () {
var locationCookie;
var locationResponse;
if ($.cookie("DRIRESTAURANTID")) {
var headerUrl = "/ajax/headerlocation.jsp?restNum=" + $.cookie("DRIRESTAURANTID");
$.get(headerUrl, function (data) {
locationResponse = JSON.parse(data);
locationCookie = locationResponse.join("@@");
sessionStorage.setItem('locationDetails', locationCookie);
setLocationCookie(locationCookie);
setLocationIDCookie(locationCookie);
setLocationHeader(locationCookie);
// if (!isToGoOneColumnTemplate()) {
// }
setHeaderViaAjax(locationCookie);
});
}
});
/**
* Generic method to be used for calling an ATG FormHandler asynchronously using
* AJAX
*
* @param obj -
* The input DOM object
* @param extraParams(optional) -
* Additional query string to be passed if necessary
* @param successMethod -
* reference of the success callback function to be called on AJAX
* success
* @param form(optional) -
* pass the form here if form is not enclosing the input DOM object
*
*/
function doAJAX(inputObj, extraParams, successMethod, form) {
var parentForm = form;
// if form object is not passed, then use closet form
if (parentForm == undefined) {
parentForm = inputObj.closest("form");
}
// serialize the data in the form
var data = parentForm.serialize();
var url = parentForm.attr("action");
if (extraParams != null) {
data = data + extraParams;
}
// disabling the inputs for the duration of the ajax request
$("input, button, a, span").prop("disabled", true);
// fire off the request to the url
request = $.ajax({
url: url,
type: "post",
data: data
});
// callback handler that will be called on success
request.done(function (response, textStatus, jqXHR) {
/**
* response - HTML String output of the AJAX call parentForm - the form
* inputObj - The input element bound to the event jqXHR -
* XMLHttpRequest object
*/
successMethod(response, parentForm, inputObj, jqXHR);
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console
.error("The following error occured: " + textStatus,
errorThrown);
});
// callback handler that will be called regardless
// if the request failed or succeeded
request.always(function () {
$("input, button, a, span").prop("disabled", false);
});
}
/**
* Generic method to be used for calling an ATG FormHandler
* asynchronously using AJAX without disabling the input fields.
*
* @param obj -
* The input DOM object
* @param extraParams(optional) -
* Additional query string to be passed if necessary
* @param successMethod -
* reference of the success callback function to be
* called on AJAX success
* @param form(optional) -
* pass the form here if form is not enclosing the
* input DOM object
*
*/
function doAJAXEnableInputs(inputObj, extraParams, successMethod, form) {
var parentForm = form;
//if form object is not passed, then use closest form
if (parentForm == undefined) {
parentForm = inputObj.closest("form");
}
//select input elements in the form
var formElements = parentForm.find("input, select, textarea");
// serialize the data in the form
var data = formElements.serialize();
var url = parentForm.attr("action");
if (extraParams != null) {
data = data + extraParams;
}
// fire off the request to the url
request = $.ajax({
url: url,
type: "post",
data: data
});
// callback handler that will be called on success
request.done(function (response, textStatus, jqXHR) {
/**
* response - HTML String output of the AJAX call
* parentForm - the form
* inputObj - The input element bound to the event
* jqXHR - XMLHttpRequest object
*/
successMethod(response, parentForm, inputObj, jqXHR);
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
}
function scrolloverlay(getID) {
getID.animate({
paddingTop: "0px"
}, function () {
var getscrolltop = parseInt($(window).scrollTop());
$(window).scrollTop(getscrolltop - 2000);
});
}
jQuery(document).ready(
function () {
var emailSignupCookieValidDays = Number($.trim($('#emailSignupCookieResetTime').val()));
var emailSignupCounterForSession = Number($.trim($('#emailSignupSessionCounter').val()));
/*
* start : opt-in select default pipe 145792 fix
*/
var hostname = window.location.hostname;
var pathname = window.location.pathname;
if (hostname.indexOf('longhornsteakhouse.com') > -1 && pathname.indexOf('customer-service/registration') > -1) {
$("#primaryOptin_reg").find('#offers').attr('checked', true);
$('#primaryOptin_reg').css('background-position', '0% -24px');
}
/*
* End : opt-in select default
*/
var hostname = window.location.hostname;
var pathname = window.location.pathname;
var restcookie = decodeURIComponent($.cookie("DRIREST"));
if (restcookie) {
var restid = restcookie.split('@@')[0];
var restlist = ['700928', '701019', '701020', '701012', '701013', '701014', '701016', '701015', '701017', '3900002', '3900003', '3900004', '3900005', '3900006'];
var restexists = (restlist.indexOf(restid));
if (pathname.indexOf('/commerce/checkout') > -1 && restexists != -1) {
$(".options-click").remove();
$(".or_mar_lef").remove();
}
}
/*
* start : avoid multiple clicks fix
var count= 0;
$(".capitalize").click(function(e) {
count++;
if(count>1){
//e.preventDefault();
}
});
* End : avoid multiple clicks fix
*/
/** function to show sign up overlay */
function showEmailSignupOverlay(isLoyaltyEnabled) {
var email_cookie = $.cookie("email_signup_cookie");
var loyalty_cookie = sessionStorage.getItem("LOYALTY_ACCOUNT_ID");
var cookieFlag = false;
var cookieEnabled = navigator.cookieEnabled;
var emailSignupCounterPerSession = $.cookie("emailSignupCounterPerSession");
if (!emailSignupCounterPerSession) {
$.cookie("emailSignupCounterPerSession", 1, {
path: "/"
});
emailSignupCounterPerSession = 1;
} else {
emailSignupCounterPerSession = Number(emailSignupCounterPerSession);
}
if (email_cookie != null && email_cookie != undefined) {
cookieFlag = true;
var cookieValues = email_cookie.split(":");
var cookie_counter = cookieValues[0];
var cookieCheckFlag = cookieValues[1];
}
var emailSignupCounter = new Number($("#emailSignupCounter").val());
if (cookieEnabled && (emailSignupCounterPerSession <= emailSignupCounterForSession) && (emailSignupCounter > 0 || (emailSignupCounter != null && emailSignupCounter != ""))) {
if (cookieFlag == false || (cookieFlag && cookie_counter <= emailSignupCounter && cookieCheckFlag != "true")) {
var emailsignup_url = $("#crm-popup").text().trim();
if (emailsignup_url == "" || emailsignup_url == null || emailsignup_url == undefined) {
var emailsignup_url = $("#emailSignup").val();
}
if ((isLoyaltyEnabled != null && isLoyaltyEnabled != undefined && isLoyaltyEnabled == "true") && (loyalty_cookie == null || loyalty_cookie == undefined)) {
var emailsignup_interstitial_url = $("#emailSignUpInterstitialOverlayUrl").val();
var emailsignup_url = emailsignup_interstitial_url;
if (location.protocol == "https:") {
emailsignup_url = "/customer-service" + emailsignup_url;
}
}
var request = $.ajax({
url: emailsignup_url,
cache: false
});
request.done(function (response, textStatus, jqXHR) {
$.cookie("emailSignupCounterPerSession", (emailSignupCounterPerSession + 1), {
path: "/"
});
if ((isLoyaltyEnabled != null && isLoyaltyEnabled != undefined && isLoyaltyEnabled == "true") && (loyalty_cookie == null || loyalty_cookie == undefined)) {
//var modalDiv = $($.parseHTML(response)).filter("#loyaltyEnrollmentSignupOverlayInModal");
} else {
var modalDiv = $($.parseHTML(response)).filter("#emailSignUpModal");
}
/*** optin fix on home interstitial overlay starts*/
modalDiv.find(".checkbox_d").dgStyle();
modalDiv.find('#join_checkbox,#globalOptin_reg').on('click', function (e) {
var a = modalDiv.find(this).css('background-position');
if (a == '0% 0px') {
$('.opt_in_darden_checkin .checkbox_d.cd_check').css('background-position', 'left 0px').data('checked', false).find(":checkbox").removeAttr('checked');
} else {
modalDiv.find('.opt_in_darden_checkin .checkbox_d.cd_check').css('background-position', 'left -24px').data('checked', true).find(":checkbox").attr('checked', true).prop('checked', true);
}
});
modalDiv.find('.opt_in_darden_checkin .checkbox_d.cd_check').on('click', function (e) {
/**WO251470 | DP Launch Project :: Start **/
if (typeof homeModalEclub === 'function') {
homeModalEclub(modalDiv.find(this));
}
/**WO251470 | DP Launch Project :: End **/
var innerCheckbox = modalDiv.find(this).css('background-position');
if (innerCheckbox == '0% -24px') {
modalDiv.find('#join_checkbox,#globalOptin_reg').css('background-position', 'left -24px').data('checked', true).find(":checkbox").attr('checked', true).prop('checked', true);
} else {
modalDiv.find('#join_checkbox,#globalOptin_reg').css('background-position', 'left 0px').data('checked', false).find(":checkbox").removeAttr('checked');
var inputs = modalDiv.find(".opt_in_darden_checkin .checkbox_d.cd_check");
for (var i = 0; i < inputs.length; i++) {
var inputbg = modalDiv.find(inputs[i]).css('background-position');
if (inputbg == '0% -24px') {
modalDiv.find('#join_checkbox,#globalOptin_reg').css('background-position', 'left -24px').data('checked', true).find(":checkbox").attr('checked', true).prop('checked', true);
}
}
}
});
/*** optin fix on home interstitial overlay ends*/
modalDiv.find(".styled-select select, .styled-select-red select").each(function () {
$(this).wrap("");
$(this).after("");
var firstOption = $(this).find("option:first").text();
$(this).next(".holder").text(firstOption);
});
scrolloverlay(modalDiv);
modalDiv.modal();
if ($("#dtmenabled").val() == "true") {
// on display of modal Added for welcome popup
let modalData = {
"modalName": "welcome eclub signup",
"modalIntent": "welcome user signup",
"modalContent": "welcome eclub signup form"
}
AU.dispatchEvent('AnalyticsEvent', 'DisplayModal', modalData);
// DTM eclub event END
}
if ($.cookie('email_signup_cookie') == null) {
var count = 1;
var cookie_value = ++count + ":" + false;
var expireOn = $.cookie('email_signup_cookie', cookie_value, {
expires: emailSignupCookieValidDays,
path: "/"
});
expireOn = expireOn.match(/expires=(.+); path/);
expireOn = expireOn[1];
$.cookie('email_signup_cookie_expire', expireOn, {
expires: emailSignupCookieValidDays,
path: "/"
});
} else {
if (cookie_counter <= emailSignupCounter) {
cookie_value = ++cookie_counter + ":" + cookieCheckFlag;
$.cookie('email_signup_cookie', cookie_value, {
expires: getCrmCookieExpireDate(),
path: "/"
});
}
}
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
}
}
}
/**
* AJAX call to invoke handleSavePartySize
*/
$(document).on("click", "#savePartySize", function () {
/** Omniture tracking start **/
//dtm flag check
if ($("#dtmenabled").val() == "false") {
var linktext = $("#catDeliveryPartySize").val();
s.linkTrackVars = "eVar83";
s.eVar83 = linktext;
s.tl($(this), 'o', 'save party size');
}
/** Omniture tracking end **/
var form = $(this).closest("form");
doAJAX($(this), null, successUpdatePartySize);
// preventing the page from being refreshed
return false;
});
/*get CRM Popup cookie expire date*/
function getCrmCookieExpireDate() {
var expireOn = $.cookie("email_signup_cookie_expire");
if (expireOn) {
expireOn = new Date(expireOn);
} else {
expireOn = $.cookie('email_signup_cookie_expire', "", {
expires: emailSignupCookieValidDays,
path: "/"
});
expireOn = expireOn.match(/expires=(.+); path/);
expireOn = expireOn[1];
$.cookie('email_signup_cookie_expire', expireOn, {
expires: emailSignupCookieValidDays,
path: "/"
});
expireOn = new Date(expireOn);
}
return expireOn;
}
function successUpdatePartySize(response, form, inputObj) {
var partySize = $(response).filter("#deliveryPartySize");
var estCost = $(response).filter("#estCostPerPerson");
$('#deliveryPartySize').empty();
$("#deliveryPartySize").html(partySize.html());
$('#estCostPerPerson').text(estCost.text());
$('#est_delivery_cost').text(estCost.text());
$('#editPartySize').show();
$('#savePartySize').hide();
}
/**
* AJAX call to invoke handleProcessEclub for Join E-club Step2
*/
$(document).on("click", "#save_email_button", function () {
var form = $(this).closest("form");
//Defect fix - 13003 : starts
if (!Modernizr.input.placeholder) {
$(this).parents('form').find('[placeholder]').each(function () {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
});
}
//Defect fix - 13003 : ends
doAJAX($(this), null, successEmailSignupCall);
// preventing the page from being refreshed
return false;
});
/**
* Success callback method for Join E-club Step 2
*/
function successEmailSignupCall(response, form, inputObj) {
/**WO251470 | DP Launch Project :: Start **/
if (typeof analyticsSignupPopUp === 'function') {
analyticsSignupPopUp();
}
/**WO251470 | DP Launch Project :: End **/
/*Update cookie flag as true*/
var email_cookie = $.cookie("email_signup_cookie");
if (email_cookie != null && email_cookie != undefined) {
var cookieValues = email_cookie.split(":");
var cookie_counter = cookieValues[0];
var cookieCheckFlag = cookieValues[1];
var cookie_value = cookie_counter + ":" + true;
$.cookie('email_signup_cookie', cookie_value, {
expires: getCrmCookieExpireDate(),
path: "/"
});
}
var errorDiv = $(response).find("#error_msg");
form.find('#zip_errorDiv').empty();
form.find("#error_msg").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
// DTM eclub event START
if ($("#dtmenabled").val() == "true") {
analyticsEvent("eclubSignup", "eclub");
}
// DTM eclub event END
$("#error_msg").empty();
var zipField = form.find("#zipcode_step2").val();
var zipCode_Country = form.find("#zipCode_Country").val();
$('#myModal').modal('hide');
form.find('#zip_errorDiv').empty();
var zipSearchEclubUrl = $("#emailZipSearchUrl").val();
if (zipField != null && zipField != undefined && zipField != '') {
form.find('#error_msg').empty();
if (zipCode_Country == 'US') {
if (zipField.length == 5) {
findZipCode(zipField, zipSearchEclubUrl, zipCode_Country, form, response);
}
}
if (zipCode_Country == 'CA') {
if (zipField.length == 6) {
findZipCode(zipField, zipSearchEclubUrl, zipCode_Country, form, response);
}
}
}
} else {
scrolloverlay($("#myModal"));
}
}
$(document).on("click", "#hasAccount", function () {
$("#myModal").modal('hide');
$("#myModal").remove();
var email_cookie_check = $.cookie("email_signup_cookie");
if (email_cookie_check != null && email_cookie_check != undefined) {
var cookieVals = email_cookie_check.split(":");
var cookie_new_val = cookieVals[0] + ":" + true;
$.cookie('email_signup_cookie', cookie_new_val, {
expires: getCrmCookieExpireDate(),
path: "/"
});
}
});
/**************start of code change for magic ticket 469098289****************/
/*
var EclubPageUrl = $("#joinclubPage").val();
if ( EclubPageUrl != undefined && EclubPageUrl != '' ) {
s.events='event3';
s.tl($(this), 'o', 'Eclub Step1 SignUp');
}
*/
/***************end of code change for magic ticket 469098289 ****************/
/** refresh header links on page load **/
if ($("#header-links").length > 0) {
var url = $("#header-links").attr('data-url');
refreshHeaderLinks(url);
}
function refreshHeaderLinks(url) {
var headerLinks = $("#header-links");
var join_wait_list_details;
var data = {};
if (window.location.protocol == "https:") {
url = $("#ajaxServletURL").val();
data.AJAX_FUNCTION = "headerLinks";
}
data.fromPage = location.pathname;
if (location.pathname.indexOf("/commerce/order-confirmation") != -1 || location.pathname.indexOf("/purchase/gift-card-order-confirmation") != -1) {
data.ANC = getParameterByName("ANC");
data._requestid = getParameterByName("_requestid");
}
// Change for Enhancement : Location update from sitemap - starts here [xsdamm1]
var isLocationDetailsPage = $('#isLocationDetails').val();
if (isLocationDetailsPage != undefined && isLocationDetailsPage != null && isLocationDetailsPage == 'true') {
var currentUrl = location.pathname;
var splitUrl = currentUrl.split("/");
var restnum = splitUrl[5];
if (restnum != undefined && restnum != null) {
var locationCookie = decodeURIComponent($.cookie("DRIREST"));
if (locationCookie) {
var locValues = locationCookie.split("@@");
if (locValues.length > 0) {
if (locValues[11] != restnum) {
data.changeCurrentLocation = 'true';
data.restNum = restnum;
}
}
} else {
data.changeCurrentLocation = 'true';
data.restNum = restnum;
}
}
}
// Change for Enhancement : Location update from sitemap - ends here [xsdamm1]
// Change for restCatering starts
var locnCookie = decodeURIComponent($.cookie("DRIREST"));
if (locnCookie) {
var locValues = locationCookie.split("@@");
var restId = locValues[0];
data.restId = restId;
var dataPageURL = location.pathname;
if ($("#joinWaitListDetails").length > 0) {
join_wait_list_details = $("#joinWaitListDetails");
data.dataPageURL = dataPageURL;
}
}
//Change for restCatering ends
var isLocDetails = $("#isLocationDetails").val();
var dataPageURL = location.pathname;
var restID = '';
var locDetailsReqURI = '';
var location_wait_list_details = '';
if (isLocDetails == "true") {
restID = $("#locationWaitlistDetails").attr('data-rest-id');
locDetailsReqURI = $("#locationWaitlistDetails").attr('base-url');
data.restID = restID;
data.locDetailsReqURI = locDetailsReqURI;
}
// gpodma1
var location_popup_holiday_message = '';
if ($("#idHolidayMessage-location-popup").length > 0) {
// Make sure the #idHolidayMessage-location-popup exists in
// xmgr.html#pages/desktop/us/en_US/olivegarden/global-header
location_popup_holiday_message = $("#idHolidayMessage-location-popup");
}
// gpodma1
$.ajaxSetup({
cache: false
});
//Check if url contains restaurant parameter to change location - start
var setRestaurantParamPresent = false;
var restFromUrl = getUrlParameter("setRestaurant");
if (restFromUrl != undefined && restFromUrl != '') {
setRestaurantParamPresent = true;
url = url + "?setRestaurant=" + restFromUrl;
}
//Check if url contains restaurant parameter to change location - end
$.get(url, data, function (response) {
if ($(".coupon-price-box") && $(".coupon-price-box").html() && location.pathname.indexOf("/togo/") != -1) {
$(".coupon-heading.txtbold").hide();
$(".coupon-label").hide();
$("#couponCode").hide();
$(".coupon-chk-out-bg.primary-btn.pull-right.item-null").hide();
}
var pageURL = location.pathname;
var securityStatus = $(response).find("#security_status").val();
var isLoyaltyEnabled = $(response).find("#loyaltyEnabled").val();
var loyaltyCookieValue = $(response).find("#isLoyaltyCookieAvailable").val();
sessionStorage.setItem("LOYALTY_ACCOUNT_ID", loyaltyCookieValue);
var loyalty_cookie = sessionStorage.getItem("LOYALTY_ACCOUNT_ID");
var loginStatusValue = $(response).filter("#profileTransient").val();
if (loginStatusValue == "false") {
sessionStorage.setItem("DRI_LOGGED_IN", "Y");
} else {
sessionStorage.removeItem("DRI_LOGGED_IN");
}
if (securityStatus < 4) {
/*if((location.pathname.indexOf("/home") == 0)||(location.pathname.indexOf("/es/pagina-de-inicio") == 0)){
showEmailSignupOverlay(isLoyaltyEnabled);
}*/
if (($('#crm-popup').length > 0) || (location.pathname.indexOf("/es/pagina-de-inicio") == 0)) {
showEmailSignupOverlay(isLoyaltyEnabled);
} else if ((isLoyaltyEnabled != null && isLoyaltyEnabled != undefined && isLoyaltyEnabled == "true") && (loyalty_cookie == null || loyalty_cookie == undefined)) {
showEmailSignupOverlay(isLoyaltyEnabled);
}
}
// added for DTM by Jaydeep START
if ($("#dtmenabled").val() == "true") {
var digitalDataAjx;
if ($(response).filter("#datalayer_jason").html()) {
digitalDataAjx = JSON.parse($(response).filter("#datalayer_jason").html());
}
// update ajax response in existing digitalData obj
if (digitalDataAjx && window.digitalData) {
// added for dtm event Jaydeep
if (digitalDataAjx.event && digitalDataAjx.event.length > 0 &&
location.pathname.indexOf("/customer-service/favorite-locations") == -1 &&
digitalDataAjx.event[0].eventInfo.eventName == "addLocationToFavorites") {
delete digitalDataAjx.event;
digitalDataAjx.event = digitalDataAjx.event || [];
} else {
window.digitalData = digitalDataAjx;
// eclubComplete event check
if (window.sessionStorage && location.pathname.indexOf("/reservations/reservation-confirmation") != -1 ||
location.pathname.indexOf("/private-dining/confirmation") != -1 ||
location.pathname.indexOf("/private-dining/national-accounts/thank-you") != -1 || location.pathname.indexOf("/customer-service/communication-preferences") != -1) {
if (sessionStorage.getItem("eclubChecked") &&
sessionStorage.getItem("eclubChecked") != null &&
sessionStorage.getItem("eclubChecked") === "true") {
sessionStorage.removeItem("eclubChecked");
analyticsEvent("eclubSignup", "eclub");
}
}
// eclubComplete event end
if ($(response).filter("#datalayer_event").html()) {
var eventNameDL = $(response).filter("#datalayer_event").html();
if (eventNameDL !== "pageDataResponse") {
sendCustomEvent($(response).filter("#datalayer_event").html());
}
}
}
sendCustomEvent("pageDataResponse");
}
}
// added for DTM by Jaydeep END
headerLinks.replaceWith(response);
var locnCookie = decodeURIComponent($.cookie("DRIREST"));
if (locnCookie) {
if ($("#joinWaitListDetails").length > 0) {
join_wait_list_details = $("#joinWaitListDetails");
join_wait_list_details.html($(response).filter('#waitListInfo').html());
$("#mainNavJoinWaitListLink").html($(response).filter('#waitListInfo').children('.inform-link').html());
}
if ($("#locationWaitlistDetails").length > 0) {
location_wait_list_details = $("#locationWaitlistDetails");
location_wait_list_details.html($(response).filter('#location-webahead-info-reload').html());
}
// gpodma1
if ($("#idHolidayMessage-location-popup-fromHeaderLinks").length > 0 && location_popup_holiday_message.length > 0) {
location_popup_holiday_message.html($(response).filter('#idHolidayMessage-location-popup-fromHeaderLinks').html());
}
// gpodma1
}
//show change restaurant overlay if locationMismatch is true
var locationMismatch = $('#locationMismatch').val();
var orderType = new Number($("#orderType").val());
var enableSettings = $('#expressSettingsEnabled').val();
var locationUrl = window.location.href;
if (enableSettings == 'true' && !(window.location.href.indexOf('enrollConfirmed') > -1 && window.location.href.indexOf('/customer-service/my-rewards') > -1)) {
var redirectUrlValue = $('#redirectUrlValue').val();
var data = {};
var overlayURL = $('#expressSettingsEnabled').attr('data-url');
if (window.location.protocol == "https:") {
overlayURL = $("#ajaxServletURL").val();
data.AJAX_FUNCTION = "enableExpressSetting";
}
$.get(overlayURL, data, function (overlayHTML) {
var modalDiv = $(overlayHTML).filter("#myModalEnableExpressSettings");
var successUrl = modalDiv.find('#expSuccessUrl').val();
successUrl = successUrl + "?returnPage=" + redirectUrlValue;
modalDiv.find('#expSuccessUrl').each(function () {
$(this).attr('value', successUrl);
});
modalDiv.find('#setReturnUrl').each(function () {
$(this).attr('value', successUrl);
});
modalDiv.modal();
});
} else if (locationMismatch == 'true' && !((location.pathname.indexOf("/purchase") == 0) || (location.pathname.indexOf("/commerce/checkout-payment-method") == 0))) {
var data = {};
var overlayURL = $('#locationMismatch').attr('data-url');
if (window.location.protocol == "https:") {
overlayURL = $("#ajaxServletURL").val();
data.AJAX_FUNCTION = "changeCurrentRestaurant";
}
$.get(overlayURL, data, function (overlayHTML) {
var modalDiv = $(overlayHTML).filter("#myModalRestaurantChange");
modalDiv.modal();
});
}
// Change for Enhancement : Location update from sitemap - starts here [xsdamm1]
if (locDetCookieVal != '' && locDetCookieVal != null) {
locDetCookieVal = locDetCookieVal.replace(/#/g, '"');
setLocationCookie(locDetCookieVal);
setLocationHeader(locDetCookieVal);
setLocationIDCookie(locDetCookieVal);
} else {
if (locationCookie) {
setLocationCookie(locationCookie);
setLocationIDCookie(locationCookie);
setLocationHeader(locationCookie);
}
}
// Change for Enhancement : Location update from sitemap - ends here [xsdamm1]
// Change for restCatering starts
var displayCateringLink = $(response).filter('#displayCateringLink').val();
var isDetectedLatLong = $(response).filter('#isDetectedLatLong').val();
if (isDetectedLatLong != null && isDetectedLatLong == 'true') {
$('span#find-locn-nearme-hidden-header').show();
}
if (displayCateringLink != null && displayCateringLink == 'true') {
$('span#selected-cateing').show();
}
if (displayCateringLink != null && displayCateringLink == 'false') {
$('span#selected-cateing').hide();
}
// Change for restCatering ends
$('a.capitalize.trackContent.come-on-in').contents().unwrap();
if (setRestaurantParamPresent) {
setLocationHeader(locationCookie);
}
var isOnlineTogoEnabledValue = $("#isOnlineTogoEnabled").val();
var inRestTogoEnabled = $("#inRestTogoEnabled").val();
var franchiseLocPhone = $("#togoFranchisePhoneNo").val();
// messages
var togoText = $("#togoText").val();
var onlineTogoText = $("#onlineTogoText").val();
var inrestTogoText = $("#inrestTogoText").val();
var togoOffText = $("#togoOffText").val();
if (typeof inRestTogoEnabled == 'undefined') {
inRestTogoEnabled = false;
} else {
if (inRestTogoEnabled === "true") {
inRestTogoEnabled = true;
} else {
inRestTogoEnabled = false;
}
}
if (typeof isOnlineTogoEnabledValue == 'undefined') {
isOnlineTogoEnabledValue = false;
} else {
if (isOnlineTogoEnabledValue === "true" || isOnlineTogoEnabledValue == "" || isOnlineTogoEnabledValue == null) {
isOnlineTogoEnabledValue = true;
} else {
isOnlineTogoEnabledValue = false;
}
}
if (!isOnlineTogoEnabledValue && inRestTogoEnabled) {
$("#\\/togo").html("TO GO");
$("#\\/togo").attr("onclick", "showFranchiseModal();");
$("#\\/togo").attr("id", "franchiseMenuHeading");
$("#franchiseMenuHeading").attr("style", "display:none;");
$("#franchise_restphno").html(franchiseLocPhone);
$(".franchiseOverlay").removeClass("primary-btn");
$(".franchiseOverlay").removeAttr("href");
$(".franchiseOverlay").attr("style", "text-decoration:none");
$("#franchiseLocOverlay").removeAttr("href");
$(".franchiseOverlay").html("To Go (Please Call)");
} else if (!isOnlineTogoEnabledValue && !inRestTogoEnabled) {
$("#\\/togo").html("TO GO");
$("#\\/togo").attr("onclick", "showFranchiseModal();");
$("#\\/togo").attr("id", "franchiseMenuHeading");
$("#franchiseMenuHeading").attr("style", "display:none;");
$("#franchise_restphno").html(franchiseLocPhone);
$(".franchiseOverlay").removeClass("primary-btn");
$(".franchiseOverlay").removeAttr("href");
$(".franchiseOverlay").attr("style", "text-decoration:none;display:none;");
$("#franchiseLocOverlay").removeAttr("href");
//$(".franchiseOverlay").html(togoOffText);
}
});
}
var loggedinCookie = sessionStorage.getItem("DRI_LOGGED_IN");
if ($("#favorite_link_location_detail").length > 0 && loggedinCookie) {
var favorite_link_location = $("#favorite_link_location_detail");
var favorite_link_location_detail_url = $("#favorite_link_location_detail_url");
var url = favorite_link_location_detail_url.attr('data-url');
var restId = favorite_link_location.attr('data-restId');
var directUrl = $("#favorite_location_redirectUrl").val();
var data = {
restaurantId: restId,
redirectUrl: directUrl
};
$.ajaxSetup({
cache: false
});
$.get(url, data, function (response) {
favorite_link_location.replaceWith(response);
});
}
/************************ REORDER FUNCTIONALITY -- START **********************************/
/**
* This Function is called when 'Add to Reorder'
* button is clicked from ToGo orders page *
*/
$(document).on("click", "#reorder_addtocart,#delivery_reorder_addtocart", function () {
// changed for new togo ref flow
window.location.replace('/reorder');
});
/**
* This Function is called when 'Continue'
* button is clicked from Reorder Error States Overlay *
*/
$(document).on("click", "#reorder-continue", function () {
var orderIdForReorder = $(this).attr('data-order-id');
var url = $(this).attr('data-url');
var itemIdsForContinue = $("#itemIdsForContinue");
var itemIdsForReorder = $.trim($("#itemIdsForReorder").val());
var data = {
orderIdForReorder: orderIdForReorder,
itemIdsForReorder: itemIdsForReorder
};
if (itemIdsForContinue.length > 0) {
var validItemIds = $.trim(itemIdsForContinue.val());
data.validItemIds = validItemIds;
}
if (location.pathname.indexOf("location-confirmation") != -1 ||
location.pathname.indexOf("pick-date-and-time") != -1) {
var requestedPickupDate = $.trim($("#requestedPickupDate").val());
var requestedPickupTime = $.trim($("#requestedPickupTime").val());
var selectedMenuType = $.trim($("#selectedMenuType").val());
data.selectedMenuType = selectedMenuType;
data.requestedPickupDate = requestedPickupDate;
data.requestedPickupTime = requestedPickupTime;
var ajaxurl = "reOrderStates";
data.AJAX_FUNCTION = ajaxurl;
url = $("#ajaxServletURL").val();
}
request = $.ajax({
url: url,
type: "get",
cache: false,
data: data
});
request.done(function (response, textStatus, jqXHR) {
if (location.pathname.indexOf("location-confirmation") == -1 ||
location.pathname.indexOf("pick-date-and-time") == -1) {
successReorder(response);
} else {
successReorderFromPickUpPage(response);
}
});
});
/**
* This Function is called when 'Change'
* button is clicked from Reorder Error States Overlay *
*/
$(document).on("click", "#reorder-pickup-change", function () {
var orderIdForReorder = $(this).attr('data-order-id');
var url = $(this).attr('data-url');
var itemIdsForReorder = $.trim($("#itemIdsForReorder").val());
var requestedPickupDate = $.trim($("#date_picker_reorder").val());
var requestedPickupTime = $.trim($("#reorder_pickup_time").val());
var selectedMenuType = $.trim($("#selectedMenuType").val());
var data = {
orderIdForReorder: orderIdForReorder,
itemIdsForReorder: itemIdsForReorder,
requestedPickupDate: requestedPickupDate,
requestedPickupTime: requestedPickupTime,
selectedMenuType: selectedMenuType
}
if (location.pathname.indexOf("location-confirmation") != -1 ||
location.pathname.indexOf("pick-date-and-time") != -1) {
url = $("#ajaxServletURL").val();
var ajaxurl = "reOrderStates";
data.AJAX_FUNCTION = ajaxurl;
}
request = $.ajax({
url: url,
type: "get",
cache: false,
data: data
});
request.done(function (response, textStatus, jqXHR) {
if (location.pathname.indexOf("pick-date-and-time") == -1) {
successReorder(response);
} else {
successReorderFromPickUpPage(response);
}
});
});
/**
* This Function is called when 'Continue' button is clicked from
* Location Confirmation page when the guest lands on this page
* after clicking on 'add to order'.
*/
$(document).on("click", "#reorder_pickup_continue", function () {
var orderIdForReorder = $(this).attr('data-order-id');
var url = $(this).attr('data-url');
var requestedPickupDate = $.trim($("#requestedPickupDate").val());
var requestedPickupTime = $.trim($("#requestedPickupTime").val());
var selectedMenuType = $.trim($("#selectedMenuType").val());
var ajaxurl = $.trim($("#ajaxurl").val());
if (!requestedPickupDate) {
alert("Please select pick up date");
return false;
}
if (!requestedPickupTime) {
alert("Please select a timeslot from available timeslots");
return false;
}
request = $.ajax({
url: url,
type: "get",
cache: false,
data: {
orderIdForReorder: orderIdForReorder,
requestedPickupDate: requestedPickupDate,
requestedPickupTime: requestedPickupTime,
selectedMenuType: selectedMenuType,
AJAX_FUNCTION: ajaxurl
}
});
request.done(function (response, textStatus, jqXHR) {
successReorderFromPickUpPage(response);
});
});
/**
* success Function for Reorder from TOGO orders page
*/
function successReorder(data) {
$("#reorderErrorStates").modal('hide');
$("#reorderErrorStates").remove();
var callHandleReorder = $(data).find("#callHandleReorder");
var noItems = $(data).find("#noItems");
if ($.trim(noItems.val()) == "true") {
$("#reorderErrorStates").modal('hide');
} else if ($.trim(callHandleReorder.val()) == "true") {
var formObj = $(data).find("form#reorder");
$("body").append(formObj);
formObj.submit();
} else {
var reorderErrorModal = $(data).filter("#reorderErrorStates");
scrolloverlay($("#reorderErrorStates"));
reorderErrorModal.modal();
reorderErrorModal.find(".styled-select selectmenu-layoutform").each(function () {
$(this).wrap("");
$(this).after("");
var firstOption = $(this).find("option:first").text();
$(this).next(".holder").text(firstOption);
});
var datePicker = reorderErrorModal.find("#reorder_pickup_time");
if (datePicker.length > 0) {
var pickupTimeSelectBox = reorderErrorModal.find("#reorder_pickup_time");
var intervalInMins = reorderErrorModal.find('#intervalInMinsReorder').val();
var pickupDate = reorderErrorModal.find("#date_picker_reorder").val();
populatePickUpTimeBox(pickupTimeSelectBox, intervalInMins, pickupDate);
loadDatePicker(reorderErrorModal.find("#date_picker_reorder"));
}
$(window).scrollTop(0);
}
}
/**
* success Function for Reorder when guest is redirected to pick up
* time page.
*/
function successReorderFromPickUpPage(data) {
$("#reorderErrorStates").modal('hide');
$("#reorderErrorStates").remove();
if (!!($.trim($("#requestedPickupDate").val()) && $.trim($("#requestedPickupTime").val()))) {
$("#requestedPickupDate").val($(data).find("#reorder_reqPickupDate").val());
$("#requestedPickupTime").val($(data).find("#reorder_reqPickupTime").val());
$("#selectedMenuType").val($(data).find("#selectedMenuType").val());
}
$("#pickup_validItemIds").val($(data).find("#itemIdsForReorder").val());
var callHandleReorder = $(data).find("#callHandleReorder");
var noItems = $(data).find("#noItems");
if ($.trim(noItems.val()) == "true") {
location.reload();
} else if ($.trim(callHandleReorder.val()) == "true") {
$("form#form-pick-up-time").submit();
} else {
var reorderErrorModal = $(data).filter("#reorderErrorStates");
reorderErrorModal.modal();
reorderErrorModal.find(".styled-select selectmenu-layoutform").each(function () {
$(this).wrap("");
$(this).after("");
var firstOption = $(this).find("option:first").text();
$(this).next(".holder").text(firstOption);
});
var datePicker = reorderErrorModal.find("#reorder_pickup_time");
if (datePicker.length > 0) {
var pickupTimeSelectBox = reorderErrorModal.find("#reorder_pickup_time");
var intervalInMins = reorderErrorModal.find('#intervalInMinsReorder').val();
var pickupDate = reorderErrorModal.find("#date_picker_reorder").val();
populatePickUpTimeBox(pickupTimeSelectBox, intervalInMins, pickupDate);
loadDatePicker(reorderErrorModal.find("#date_picker_reorder"));
}
$(window).scrollTop(0);
}
}
/************************ REORDER FUNCTIONALITY -- END **********************************/
/**
* Function to Load the datepicker on AJAX loaded overlay.
*/
function loadDatePicker(datePickerInput) {
var imagePrefix = $('#media').val();
datePickerInput.datepicker({
showOn: "both",
buttonImage: imagePrefix + "/calendar-icon.png",
buttonImageOnly: true,
buttonText: "Calendar",
showOtherMonths: true,
showButtonPanel: true,
minDate: 0,
maxDate: 11
});
}
/**
* Function to populate the pickuptime dropdown box on overlay.
*/
function populatePickUpTimeBox(pickupTimeSelectBox, intervalInMins, pickupDate) {
var url = pickupTimeSelectBox.attr('data-url');
var data = {};
if (window.location.protocol == "https:") {
url = $("#ajaxServletURL").val();
data = {
AJAX_FUNCTION: "restTimings"
};
}
data.pickupDate = pickupDate;
request = $.ajax({
url: url,
type: "get",
cache: false,
data: data
});
request.done(function (response, textStatus, jqXHR) {
var $response = $(response);
var lunchSlots = $response.filter('#lunchTimings').text();
var array = lunchSlots.split("#");
lunchStartTime = array[0];
lunchFirstSlot = array[1];
lunchEndTime = array[2];
if (lunchStartTime != null && lunchEndTime != null &&
lunchFirstSlot != null) {
populatePickUpTimeDropDown(pickupTimeSelectBox, lunchFirstSlot, lunchEndTime, intervalInMins);
}
var dinnerSlots = $response.filter('#dinnerTimings').text();
var array = dinnerSlots.split("#");
dinnerStartTime = array[0];
dinnerFirstSlot = array[1];
dinnerEndTime = array[2];
if (dinnerStartTime != null && dinnerEndTime != null &&
dinnerFirstSlot != null) {
populatePickUpTimeDropDown(pickupTimeSelectBox, dinnerFirstSlot, dinnerEndTime, intervalInMins);
}
});
}
/**
* Function to populate the pickuptime dropdown box on overlay.
*/
function populatePickUpTimeDropDown(pickUpTimeSelectBox, firstTimeSlot, endTime, intervalInMins) {
if (pickUpTimeSelectBox == null || pickUpTimeSelectBox.length < 1)
return;
var startTime = Date.parseExact(firstTimeSlot, "HH:mm");
var endTime = Date.parseExact(endTime, "HH:mm:ss");
var startHour = startTime.toString("HH");
var endHour = endTime.toString("HH");
var NumOfHours = endHour - startHour;
var slotsPerHour = 60 / intervalInMins;
var NumberOfSlots = NumOfHours * slotsPerHour;
for (var r = 0; r < NumberOfSlots; r++) {
if ((startTime.compareTo(endTime) == -1)) {
var startTimeString = startTime.toString("hh:mm tt");
startTime = startTime.addMinutes(intervalInMins);
}
pickUpTimeSelectBox.append($('').val($.trim(startTimeString)).html($.trim(startTimeString)));
}
}
/**
* Allow only numbers for phone number field
*/
$(document).on('keypress change', '#phone-ctn, #phoneExt, #loyaltyMemberPhone', function (e) {
if (e.which > 31 && (e.which < 48 || e.which > 57)) {
e.preventDefault();
}
});
/** Method for formatting phone number to (###) ###-#### format **/
$(document).on('keypress', '#phone-ctn, #loyaltyMemberPhone', function (e) {
var l = $(this).val().length;
var text = $(this).val();
var isNumber = (e.which > 47 && e.which < 58) || (e.which > 95 && e.which < 106);
if (isNumber) {
if (l <= 4) {
for (var i = 0; i <= l; i++) {
var codeA = text.charCodeAt(i);
if (codeA > 31 && (codeA < 48 || codeA > 57)) {
$(this).val(text.replace(/(\d{3})\)?/g, '$1)'));
return true;
}
}
/** alm 7526 change start **/
$(this).val(text.replace(/(\d{3})\)?/g, '($1) '));
return true;
/** alm 7526 change end **/
}
if (l == 9) {
$(this).val(text.replace(text, text + '-'));
return true;
}
}
});
// call format phone number on focus out
$(document).on('focusout', '#phone-ctn', formatPhoneNumber);
$(document).on('focusout', '#loyaltyMemberPhone', formatPhoneNumber4);
// call format phone number on page load.
if ($('#phone-ctn').length > 0) {
formatPhoneNumber();
}
if ($('#loyaltyMemberPhone').length > 0) {
formatPhoneNumber4();
}
/** function for formatting phone number to (###) ###-#### format **/
/*function formatPhoneNumber(input) {
var input = $('#phone-ctn');
var numsOnly = input.val().replace(/\D/g, '');
if (numsOnly.length >= 10) {
input.val(input.val().replace(/\D/g, ''));
}
input.val(input.val().replace(/(\d{3})(\d{3})(\d{4})/,'($1) $2-$3'));
if (input.val().length > 14) {
input.val(input.val().slice(0, 14));
}
}*/
function formatPhoneNumber() {
var input = $('#phone-ctn').val() ? $('#phone-ctn') : $("input[name=vmobilenumber]").val() ? $("input[name=vmobilenumber]") : "";
if (input) {
var numsOnly = input.val().replace(/\D/g, '');
if (numsOnly.length >= 10) {
$(this).removeClass("err-border-value");
$(".Phone-num-err").css("display", "none");
input.val(input.val().replace(/\D/g, ''));
}
input.val(input.val().replace(/(\d{3})(\d{3})(\d{4})/, '($1) $2-$3'));
if (input.val().length > 14) {
input.val(input.val().slice(0, 13));
}
}
}
function formatPhoneNumber4(input) {
var input = $('#loyaltyMemberPhone');
var numsOnly = input.val().replace(/\D/g, '');
if (numsOnly.length >= 10) {
input.val(input.val().replace(/\D/g, ''));
}
input.val(input.val().replace(/(\d{3})(\d{3})(\d{4})/, '($1) $2-$3'));
if (input.val().length > 14) {
input.val(input.val().slice(0, 13));
}
}
//call monthYearChanged if month/year dropdown is changed.
$(document).on("change", "#dobMonth, #dobYear", monthYearChanged);
/**
* Function to populate the days dropdown box based on the the month and
* year. This also takes leap years into account.
*/
function monthYearChanged() {
var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var enclosingDiv = $(this).closest('div.row');
var dayDiv = enclosingDiv.find('#dobDay');
var monthDiv = enclosingDiv.find('#dobMonth');
var yearDiv = enclosingDiv.find('#dobYear');
var month = monthDiv.val() - 1,
year = +yearDiv.val();
var diff;
// Check for leap year if Feb
if (month == 1 && new Date(year, month, 29).getMonth() == 1) {
days[1]++;
}
// Add/Remove options
diff = dayDiv.find('option').length - (days[month] + 1);
if (diff > 0) { // Remove
dayDiv.find('option').slice(days[month] + 1).remove();
if (($("label[for='dobMonth']").find(".holder").html().toLowerCase() == "february") && ($("label[for='dobDay']").find(".holder").html() == "29" ||
$("label[for='dobDay']").find(".holder").html() == "30" || $("label[for='dobDay']").find(".holder").html() == "31")) {
var dobDayVal = $("label[for='dobDay']").find(".holder").html("28");
$("#dobDay").val(dobDayVal);
}
} else if (diff < 0) { // Add
for (var i = dayDiv.find('option').length; i <= days[month]; i++) {
$('').val($.trim(stateCode)).html($.trim(stateName))
);
}
}
}
}
/**
* To highlight input fields that have incorrect data and clear those data while registration
*/
if ($("input[id*='propertyName_']").length != 0) {
$("input[id*='propertyName_']").each(function () {
var inputName = $(this).val();
var $input = null;
if (inputName == 'dobDay' || inputName == 'dobMonth' || inputName == 'dobYear') {
$input = $("#" + inputName);
$input.css('border', '1px solid #E9322D');
} else {
$input = $("input[name=" + inputName + "]");
$input.val('');
$input.css({
"border-color": "#E9322D",
"box-shadow": "0 0 6px #F8B9B7"
});
}
});
}
/**
* Send restauarant Information using SMS to user
*
*/
$(document).on("click", "#sendsms", function () {
var phonenumber = document.getElementById('phone-ctn').value;
var phonenumberformatted;
var len;
if (phonenumber.length > 0) {
var phonenumberformatted = phonenumber.replace(/\D/g, '');
}
if (phonenumberformatted == undefined) {
len = 0;
} else {
var len = phonenumberformatted.length;
}
if (len <= 0) {
$('#error_message_mobile,#locText label.error_msg').show();
$('#error_message_mobile').text($('#invalidphone').val());
} else if (len < 10) {
$('#error_message_mobile,#locText label.error_msg').show();
$('#error_message_mobile').text($('#invalidphone').val());
} else if (isNaN(phonenumberformatted)) {
$('#error_message_mobile,#locText label.error_msg').show();
$('#error_message_mobile').text($('#invalidphone').val());
} else {
$("#locText").modal('hide');
if ($('#locationUpArrow').length) {
$('#locationDownArrow').show();
$('#locationUpArrow').hide();
}
doAJAX($(this), null, hideSmsBlock);
$("div#location-pop-up").hide();
}
// preventing the page from being refreshed
return false;
});
/**
* Send SMS Success call back function
*
*/
function hideSmsBlock(response, form) {
$('#error_message_mobile').text('');
$("#locText").modal('hide');
}
/**
* Send restauarant Information via email to user
*
*/
$(document).on("click", "#sendrestinfoemail", function () {
var pattern = /^[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*@[a-z0-9]+(\-[a-z0-9]+)*(\.[a-z0-9]+(\-[a-z0-9]+)*)*\.[a-z]{2,4}$/;
var emailcontent = document.getElementById('emailId').value;
if (pattern.test(emailcontent)) {
$("#locEmail").modal('hide');
if ($('#locationUpArrow').length) {
$('#locationDownArrow').show();
$('#locationUpArrow').hide();
}
doAJAX($(this), null, hideEmailBlock);
$("input, button, a, span").prop("disabled", false);
$("div#location-pop-up").hide();
} else {
$("label.error_msg").show();
$('#error_message_email').show();
$('#error_message_email').text($('#invalidemailaddr').val());
}
return false;
});
/**
* Send restaurant info Success call back function
*
*/
function hideEmailBlock(response, form) {
$('#error_message_email').text('');
$("#locEmail").modal('hide');
}
/**
* Send restauarant Directions via email to user
*
*/
$(document).on("click", "#senddirectionsemail", function () {
$("#print_directions #directions .adp-substep").css("vertical-align", "top");
$("#print_directions #directions .adp-distance").css("width", "50px");
var dircontent = $("#print_directions").html();
document.getElementById("showdirections").value = dircontent;
var pattern = /^[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*@[a-z0-9]+(\-[a-z0-9]+)*(\.[a-z0-9]+(\-[a-z0-9]+)*)*\.[a-z]{2,4}$/;
var emailcontent = document.getElementById('emailId').value;
if (pattern.test(emailcontent)) {
doAJAX($(this), null, updateDirectionsMessage);
$("input, button, a, span").prop("disabled", false);
} else {
$('.error_msg').text($('#invalidemail').val());
}
// preventing the page from being refreshed
return false;
});
/**
* Send restaurant directions call back function
*
*/
function updateDirectionsMessage(response, form) {
$('.error_msg').text('');
$('.error_msg').text($('#sentsuccessful').val());
}
/**
* Method for displaying the preferred restaurant details based on selection.
*/
$(document).on("click", "#myRestaurantModal *[id*='choose']", function () {
var choose = $(this);
var id = choose.attr('data-id');
var url = choose.closest('div').attr('data-url');
var endecaInds = choose.closest('div').attr('data-id');
request = $.ajax({
url: url,
type: "post",
data: "id=" + id + "&endecaRestIndicators=" + endecaInds
});
request.done(function (response, textStatus, jqXHR) {
if ($("#eclubPreferredRestaurant").length != 0) {
$("#eclubPrefRest").html(response);
$("#eclubPreferredRestaurant").val(id);
} else {
$("#prefRest").html(response);
$("#preferredRestaurant").val(id);
}
$("#myRestaurantModal").modal('hide');
$("#myModal").show();
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " +
textStatus, errorThrown);
});
});
/**
* Method to restrict addition of comma at the end
* while editing/adding address.
*/
$(document).on('focusout', '#n1 , #n2, #zip, #a1, #a2 , #a3 , #a4 , #addAddress_city, #editAddress_city', function (e) {
var inputObj = $(this);
var str = inputObj.val();
var endChar = str.substring(str.length - 1, str.length);
if (endChar == ',') {
inputObj.val(str.substring(0, str.length - 1));
}
});
/**
* Function used for getting city and state based on zip code provided.
*/
function findCityState(inputField, zipSearchUrl) {
var $this = inputField;
var form = $this.closest("form");
if (($this.val()).trim() == "")
return;
var countrybox = $this.attr("data-countrybox");
var cityfield = $this.attr("data-cityfield");
var statebox = $this.attr("data-statebox");
var jsonData = {
"atg-rest-class-type": "com.darden.commerce.address.ZipSearchLookupRequest"
};
jsonData.zipCode = $this.val();
jsonData.country = form.find(countrybox).val();
$this.prop("disabled", true);
var request = $.ajax({
cache: false,
timeout: 5000,
type: "POST",
async: true,
data: {
requestData: JSON.stringify(jsonData)
}, //Creates JSON query string.
dataType: "json",
url: zipSearchUrl
})
request.done(function (res) {
if (res.errorMessage == null) {
form.find('#zip_errorDiv').empty();
$(cityfield).val(res.city);
$(statebox).val(res.state);
var holderText = $(statebox).find("option:selected").text();
$(statebox).next(".holder").text(holderText);
} else {
$(cityfield).val("");
$this.val("");
form.find('#zip_errorDiv').text(res.errorMessage);
}
})
request.fail(function (xhr) {
form.find('#zip_errorDiv').text(form.find('#zip_errorDiv').attr('data-error'));
});
request.always(function () {
$this.prop("disabled", false);
});
}
/**
* This method focus-out when user completes the typing of zipcode based on the country
*/
$(document).on("keyup", "#zip, #eclub_zip,#contactus_zip", function () {
var $this = $(this);
var countryObj = $this.attr("data-countrybox");
var zipSearchUrl = $("#zipSearchUrl").val();
var zipCode = $this.val().trim().replace(/ /g, '');
if ($(countryObj).val() == 'US') {
if (zipCode.length == 5) {
findCityState($this, zipSearchUrl);
}
}
if ($(countryObj).val() == 'CA') {
if (zipCode.length == 6) {
findCityState($this, zipSearchUrl);
}
}
});
/**
* validation for first name and last name for profile Add Address
*/
/*$(document).ready(function(){
$(document).on("blur", "#n2",function() {
var nameOnAddress = $('#n2').val();
nameOnAddress = nameOnAddress.replace(/^[ ]+|[ ]+$/g,'');
nameOnAddress = nameOnAddress.replace(/^\s+|\s+$/g,'');
var nameOnAddrArr = nameOnAddress.split(new RegExp("\\s+"));
if (nameOnAddrArr.length > 1) {
$('#firstLastNameError').remove();
return true;
}else{
if($('#firstLastNameError').length == 0){
$('#n2').before('');
}
}
return false;
});
}); */
/**
* AJAX call to invoke handleXX Method for Add Address
*/
$(document).on("click", "#adrAddButton", function () {
if ($('#firstLastNameError').length == 0) {
var nameVal = $('#n2').val()
var nameLength = nameVal.length;
var nameSplit = nameVal.split(" ");
var lastLength = nameLength - nameSplit[0].length;
var lastNameLength = nameSplit[0].length + 1;
var lastName = nameVal.slice(lastNameLength);
$('#addfirst_name').val(nameSplit[0]);
$('#addlast_name').val(lastName);
doAJAX($(this), null, successAddAddress);
// preventing the page from being refreshed
return false;
} else {
$("#n2").focus().select();
$(window).scrollTop($('#addAddress').offset().top);
}
});
/**
* Success callback method for Add Address
*/
function successAddAddress(response, form) {
var pageURL = window.location + "";
var errorDiv = $($.parseHTML(response)).find("#error_msg");
var returnUrl = $('#addAddrReturnUrl').val();
form.find("#error_msg").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
if (pageURL.indexOf('/customer-service/express-checkout-settings') > -1) {
window.location.href = "/customer-service/express-checkout-settings?returnPage=" + returnUrl;
} else {
$("#addAddress").replaceWith(response);
}
}
}
/**
* AJAX call to invoke handleXX Method for Edit Address
*/
$(document).on("click", "#adrEditButton", function () {
var nameVal = $('#n1').val()
var nameLength = nameVal.length;
var nameSplit = nameVal.split(" ");
var lastLength = nameLength - nameSplit[0].length;
var lastNameLength = nameSplit[0].length + 1;
var lastName = nameVal.slice(lastNameLength);
$('#first_name').val(nameSplit[0]);
$('#last_name').val(lastName);
doAJAX($(this), null, successEditAddress);
// preventing the page from being refreshed
return false;
});
/**
* Success callback method for Edit Address
*/
function successEditAddress(response, form) {
var pageURL = window.location + "";
var errorDiv = $($.parseHTML(response)).find("#error_msg");
var returnUrl = $('#updateAddrReturnUrl').val();
form.find("#error_msg").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
if (pageURL.indexOf('/customer-service/express-checkout-settings') > -1) {
window.location.href = $("#express_checkout_Url_Id").val() + "?returnPage=" + returnUrl;
} else {
$("#editAddress").replaceWith(response);
}
}
}
/**
* Method for setting nickname for removeAddress
*/
$(document).on("click", "a[id*='remove-ship-address']", function () {
var inputObj = $(this);
var removeModalURL = inputObj.attr('data-modal-url');
var defaultAddressId = inputObj.attr('data-default-address');
var noOfAddresses = inputObj.attr('data-address-count');
var removeAdrId = inputObj.attr('data-remove-address');
var defaultAddress = 'false';
if ($.trim(noOfAddresses) != 1 && ($.trim(removeAdrId) == $.trim(defaultAddressId))) {
defaultAddress = 'true';
}
$.ajaxSetup({
cache: false
});
$.get(removeModalURL, {
defaultAddress: defaultAddress
}, function (data) {
$("#removeAddressModal").remove();
var removeModal = $($.parseHTML(data)).filter("#removeAddressModal");
scrolloverlay(removeModal);
removeModal.modal();
var nickName = inputObj.attr('data-nickname');
removeModal.find("#removalNickName").val(nickName)
});
return false;
});
/**
* AJAX call for removeAddress function.
*/
$(document).on("click", "#remove-addr-confirm", function () {
doAJAX($(this), null, reloadAddresses);
$("#removeAddressModal").modal('hide');
$("#removeAddressModal").remove();
return false;
});
/**
* success callback function for removeAddress.
*/
function reloadAddresses(response, form) {
var errorDiv = $($.parseHTML(response)).filter("#error_msg");
form.find("#error_msg").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
$("#edit-address").replaceWith(response);
}
/**WO291993 | DP Launch Project :: Start **/
if (typeof loginDefaultUserInfo === 'function') {
loginDefaultUserInfo();
}
/**WO291993 | DP Launch Project :: End **/
}
/**
* AJAX call for selectDefaultAddress function.
*/
$(document).on("change", "input[id*='ship-addr-radio-']", function () {
doAJAX($(this), null, reloadAddresses);
return false;
});
/**
* Reset password using challenge question
*/
$(document).on("click", "#resetPassword", function () {
$("#errorMsg_email-address-1").css("display", "none");
var dataurl = $(this).attr("data-url");
var extraParams = "&redirectURL=" + dataurl;
doAJAX($(this), extraParams, successResetPasswordStep1);
return false;
});
// callback handler that will be called on success
function successResetPasswordStep1(response, form) {
var errorDiv = $($.parseHTML(response)).find("#error_chqn");
form.find(".error_msg").html(errorDiv.html());
var noErrors = form.find("#noErrors");
if (noErrors.length) {
$("#error_msg").empty();
$("#challengeQnDiv").html(response);
}
$(".styled-select select, .styled-select-red select").each(function () {
$(this).parent().wrap("");
$(this).after("");
var firstOption = $(this).find("option:first").text();
$(this).next(".holder").text(firstOption);
});
}
/**
* Reset password by sending email
*/
$(document).on("click", "#send_email", function () {
$("#errorMsg_email-address-2").css("display", "none");
doAJAX($(this), null, successSendEmail);
return false;
});
/**
* Success callback method for Send Email while resetting password
*/
function successSendEmail(response, form) {
$("#inValidTokenMessage").html('');
var errorDiv = $($.parseHTML(response)).find("#error_sendemail");
form.find("#error_sendemail").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
$("#successMsg").html(form.find("#send_email_msg").html());
} else {
$("#successMsg").html('');
}
}
/**
* When Reset Password page doesn't have a valid token.
*/
if ($("#reset").length != 0 && $("#reset").val() == 'true') {
if ($("#inValidTokenMessage").length != 0) {
$("#inValidTokenMessage").html('Reset Password link got expired. Please reset again');
}
}
//Manage Location
/**
* Remove a favorite location
*/
$(document).on("click", "a[id*='favorite-remove-']", function () {
var inputObj = $(this);
var removeModalURL = inputObj.attr('data-modal-url');
var locationId = inputObj.attr("data-id");
var defaultLocationId = inputObj.attr("data-default-location");
var noOfLocations = inputObj.attr("data-location-count");
var defaultLocation = 'false';
if ($.trim(noOfLocations) != 1 && ($.trim(locationId) == $.trim(defaultLocationId))) {
defaultLocation = 'true';
}
$.ajaxSetup({
cache: false
});
$.get(removeModalURL, {
defaultLocation: defaultLocation
}, function (data) {
$("#removeLocationModal").remove();
var removeModal = $($.parseHTML(data)).filter("#removeLocationModal");
scrolloverlay(removeModal);
removeModal.modal();
removeModal.find("#removeLocationId").val(locationId);
});
return false;
});
/**
* Remove location form submission
*/
$(document).on("click", "#removeLocation", function () {
var form = $(this).closest("form");
form.submit();
});
/**
* Make default a favorite location
*/
$(document).on("click", "input[id*='favorite-default-']", function () {
var inputObj = $(this);
var makeDefaultModalURL = inputObj.attr('data-modal-url');
var locationId = inputObj.val();
request = $.ajax({
url: makeDefaultModalURL,
type: "post",
data: "locationId=" + locationId
});
request.done(function (response, textStatus, jqXHR) {
var defaultLocation = $($.parseHTML(response)).filter("#makeDefaultLocationModal");
scrolloverlay(defaultLocation);
defaultLocation.modal();
defaultLocation.find("#defaultLocationId").val(locationId);
});
});
$(document).on("click", "#makeDefaultLocation", function () {
var form = $(this).closest("form");
form.submit();
});
$(document).on("click", "a[id*='favorite-location-cancel']", function () {
window.location = $(this).attr("data-modal-url");
});
if ($('#dtmenabled').val() == "false") { //dtm flag start
/**
* Omniture Tracking for Account Subscriptions on page load.
*/
if ($("form#manage-subscriptions div.subscription-check").length > 0) {
var doTracking = location.search.substring(1).indexOf('saveClicked');
if (doTracking > -1) {
s.linkTrackVars = 'eVar7,eVar10,events';
//If any of the checkboxes are ticked, track optin-event.
if ($("form#manage-subscriptions input[checked='checked']").length > 0) {
s.events = 'event7';
s.eVar10 = 'Account';
var global = $("#selectall-concepts").data('checked');
if ($.trim(global) == 'true') {
s.eVar7 = 'Global opt-in';
} else {
s.eVar7 = 'Concept opt-in';
}
s.pageName = 'Account Subscriptions Opt-In'
} else {
//If NONE of the checkboxes are ticked, track optout-event.
s.events = 'event37';
s.eVar10 = 'Account';
s.eVar7 = 'Global opt-out';
s.pageName = 'Account Subscriptions Opt-Out'
}
void (s.t());
}
}
} //dtm flag end
//Recent Activity and Order History changes
$(document).on("click", "a[id*='rtxt1']", function () {
var inputObj = $(this);
var orderId = inputObj.attr("data-id");
var url = inputObj.attr('data-url');
//added for INC17342
var checksum = inputObj.attr('data-checksum');
var orderType = inputObj.attr('data-orderType');
if ($("#order-details-" + orderId).length == 0) {
request = $.ajax({
url: url,
type: "post",
data: "orderId=" + orderId + "&checksum=" + checksum + "&orderType=" + orderType
});
request.done(function (response, textStatus, jqXHR) {
$("#rdemo-" + orderId).html(response);
$("#rdemo-" + orderId).css('height', 'auto');
});
} else {
$("#order-details-" + orderId).remove();
}
});
$(document).on("click", "a[id*='hide-']", function () {
var orderId = $(this).attr("data-id");
$("#order-details-" + orderId).remove();
});
//Manage Favorite menu items.
/**
* Remove a favorite location
*/
$(document).on("click", "a[id*='favoritemenu-remove-']", function () {
var inputObj = $(this);
var removeModalURL = inputObj.attr('data-modal-url');
var favoriteId = inputObj.attr("data-favorite-id");
var favoriteitemId = inputObj.attr("data-favoriteitem-id");
request = $.ajax({
url: removeModalURL,
type: "post",
data: "giftlistid=" + favoriteId
});
request.done(function (response, textStatus, jqXHR) {
var removeFavoriteItem = $($.parseHTML(response)).filter("#removeFavoriteMenuItemModal");
removeFavoriteItem.modal();
removeFavoriteItem.find("#removalids").val(favoriteitemId);
removeFavoriteItem.find("#giftlistid").val(favoriteId);
});
});
/**
* Remove location form submission
*/
$(document).on("click", "#removeFavoriteMenuItem", function () {
var form = $(this).closest("form");
form.submit();
});
/**
* Remove a favorite location
*/
$(document).on("click", "a[id*='favoriteitem_indicator']", function () {
var href = $(this).attr('href');
if (!$.trim((href))) {
var inputObj = $(this);
var prodID = inputObj.attr('data-prodID');
var catID = inputObj.attr('data-catId');
var size = inputObj.attr('data-mode');
$("#favCatId").val(catID);
var extraParams = "&favproductId=" + prodID + "&favcategoryId=" + catID + "&favIcon=" + size;
doAJAX($(this), extraParams, successAddFavoriteItem);
// preventing the page from being refreshed
return false;
}
});
/**
* Success callback method for add favorite item.
*/
function successAddFavoriteItem(response, form, inputObj) {
var prodID = inputObj.attr('data-prodID');
$("#favItem-indicator-" + prodID).replaceWith(response);
}
/**
* Ajax call for add favorite location.
*/
$(document).on("click", "#favorites_anch,#fav-txts-location", function () {
var inputObj = $(this);
var restId = inputObj.attr('data-restId');
var extraParams = "&restaurantId=" + restId;
doAJAX($(this), extraParams, successAddFavoriteLocation);
// preventing the page from being refreshed
return false;
});
/**
* Success callback method for Add favorite location.
*/
function successAddFavoriteLocation(response, form, inputObj) {
// added for DTM by Jaydeep START
analyticsEvent("addLocationToFavorites", "location");
// added for DTM by Jaydeep END
$("#favorite_link_location_detail").replaceWith(response);
}
/** order-lookup - setting name and placeholder attr for validation*/
$("input:radio[name='orderlookup_radio']").click(function () {
var inputName = $(this).data("lookupname");
var gtext = $(this).data("name");
$("#emailPhoneDiv").find(":text").val("");
if (inputName === "phonenumber") {
$("#emailPhoneDiv").find(":text").attr("id", "phone-ctn");
$('#phone-ctn').attr("placeholder", gtext);
}
if (inputName === "email") {
$("#emailPhoneDiv").find(":text").removeAttr("id", "phone-ctn");
$("#emailPhoneDiv").find(":text").attr("id", "email-ctn");
$('#email-ctn').attr("placeholder", gtext);
}
if (!Modernizr.input.placeholder) {
$('[placeholder]').focus(function () {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function () {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur();
$('[placeholder]').parents('form').submit(function () {
$(this).find('[placeholder]').each(function () {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
});
});
}
});
/**
* Changes the default behaviour in custom.js for orderlookup phone field
* Max length is increased to 14
*/
$("#detail_radio_phone").click(function () {
$("#emailPhoneDiv").find(":text").attr("maxlength", "14");
});
/**Maxlength increase*/
$("#detail_radio_email").click(function () {
var recProd = $('#maxlengthValue').val();
if (recProd != undefined) {
$("#emailPhoneDiv").find(":text").attr("maxlength", recProd);
}
});
/** Order History - for collapse image unhide*/
$("[id*='year_']").on('shown', function () {
var arrowId = $(this).attr("data-arrow-id");
$("#" + arrowId).addClass('arrow-up');
$("#" + arrowId).removeClass('arrow-down');
});
/** Order History - for collapse image hide */
$("[id*='year_']").on('hidden', function () {
var arrowId = $(this).attr("data-arrow-id");
$("#" + arrowId).addClass('arrow-down');
$("#" + arrowId).removeClass('arrow-up');
});
//Scroll to error div when create account give error on order-confirmation screen
if ($('#create_error').length && $('#rest-confirm-order').length) {
window.location.hash = '#rest-confirm-order';
}
//Scroll to error div when create account gives error on gift card order-confirmation screen
if ($('#create_error').length && $('#order-payment').length) {
window.location.hash = '#order-payment';
}
//Nutrition prefernces check for empty field
$("#saveInterests").click(function (e) {
var preventDefault = false;
$("input[id*='_editableOption']").each(function () {
var id = $(this).attr('id');
var idError = id.split('_')[0].concat('_error');
var errorLabel = $('#' + idError);
errorLabel.empty();
if ($(this).prop('checked')) {
var idInput = id.split('_')[0].concat('_editableInput');
var inputBox = $('#' + idInput);
if (!$.trim(inputBox.val())) {
var optionFieldError = $('#optionFieldError').val();
errorLabel.html(optionFieldError);
preventDefault = true;
}
}
});
if (preventDefault) e.preventDefault();
if ($('#dtmenabled').val() == "false") { //dtm flag start
/** Omniture tracking R4.2 -- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Save My Interests';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2 -- END **/
} //dtm flag end
});
if ($('#dtmenabled').val() == "false") { //dtm flag start
//Save subscrioption prefernces check for omniture tracking
$("#save-subscriptions").click(function (e) {
var emailOption = $("#subscriptionInfo_emailcheckbox").is(':checked');
var textOption = $("#subscriptionInfo_textcheckbox").is(':checked');
if ($.trim(emailOption) == 'true' && $.trim(textOption) == 'true') {
/** Omniture tracking R4.2 -- START **/
s.linkTrackVars = 'eVar70,prop49,eVar7,events';
s.linkTrackEvents = 'event95,event96';
s.events = 'event95,event96';
s.eVar7 = 'Email Opt In And Text Opt In';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Save My Subscriptions';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2 -- END **/
} else if ($.trim(emailOption) == 'true') {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,eVar7,events';
s.linkTrackEvents = 'event95';
s.events = 'event95';
s.eVar7 = 'Email Opt In';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Save My Subscriptions Link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
} else if ($.trim(textOption) == 'true') {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,eVar7,events';
s.linkTrackEvents = 'event96';
s.events = 'event96';
s.eVar7 = 'Text Opt In';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Save My Subscriptions Link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2 -- END **/
}
});
} //dtm flag end
if ($('#dtmenabled').val() == "false") { //dtm flag start
//ManageMyInterests link tracking for omniture.
$("#interestsUrl").click(function (e) {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Manage My Interests Link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
//EditEamilLink tracking for omniture.
$("#editEamilLink").click(function (e) {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Edit Email Link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
//EditPhoneLink tracking for omniture.
$("#editPhoneLink").click(function (e) {
/** Omniture tracking R4.2 -- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Edit Text Phone Link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
/*commenting out to remove two click events from tell-us-more page #469649356- Pooja*/
//Landing page phone type tracking for omniture
/** $("#floodLightSubmit").click(function() {
Omniture tracking R4.2 -- START
s.linkTrackVars='eVar70,prop49,events';
s.linkTrackEvents='event75';
s.events='event75';
var linkname=s.eVar70=s.prop49=s.pageName +' '+'SUBMIT link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2 -- END
}); **/
//Landing page clear button tracking for omniture
$("#clearFields").click(function () {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Clear Fields';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
//Edit Email address link in My Account page tracking for omniture
$("#edit-email-toggle").click(function () {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Edit Email Address link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
// Communication elsewhere link tracking for omniture.
$("a.addedBrand").click(function (e) {
var linktext = $(this).text();
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar7,eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar7 = s.eVar70 = s.prop49 = s.pageName + ' ' + linktext + ' ' + 'Communitation Elsewhere Link';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
//Create Account Overlay landing page tracking for omniture
$("#createAccountLink").click(function () {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Create Account Button';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
//Already subscribed Overlay landing page tracking for omniture
$("#alreadySubscribedLink").click(function () {
/** Omniture tracking R4.2-- START **/
s.linkTrackVars = 'eVar70,prop49,events';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkname = s.eVar70 = s.prop49 = s.pageName + ' ' + 'Manage My Subscriptions Button';
s.tl($(this), 'o', linkname);
/** Omniture tracking R4.2-- END **/
});
} //dtm flag end
$(yesmailOmniture);
function yesmailOmniture() {
if ($('#dtmenabled').val() == "false") { //dtm flag start
// Yes Mail Message ID
s.eVar68 = s.getQueryParam('YM_MID');
s.eVar68 = s.getValOnce(s.eVar68, 's_var_68', 0);
// Yes Mail Recipient ID
s.eVar67 = s.getQueryParam('YM_RID');
s.eVar67 = s.getValOnce(s.eVar67, 's_var_67', 0);
} //dtm flag end
}
// This function is to highlight the selection in selectboxes.
$(document).on("change", ".styled-select select, .styled-select-red select", function () {
var selectedOption = $(this).find(":selected").text();
$(this).next(".holder").text(selectedOption);
});
/* Refer a Friend starts*/
/**
* To show n number of referral section at load time.
*/
if (location.pathname
.indexOf("/customer-service/refer-a-friend") != -1) {
var numOfReferees = $("#numOfReferees").val();
var maxNumOfReferees = $("#maxNumOfReferees").val();
loadReferees(numOfReferees, maxNumOfReferees);
}
function loadReferees(numOfReferees, maxNumOfReferees, rafModal) {
for (var i = numOfReferees; i > 0; i--) {
if (rafModal == undefined) {
$("#frnd" + i).css({
display: "block"
});
$("#ref-mail" + i + "-frind-name").removeAttr("disabled");
$("#ref-mail" + i + "-frind-l-name").removeAttr("disabled");
$("#ref-mail" + i + "-f-mail").removeAttr("disabled");
$("#ref-mail" + i + "-subject").removeAttr("disabled");
$("#ref-mail-desc-" + i).removeAttr("disabled");
$("#border-" + i).css({
"display": "block",
"border-top": "0",
"padding-top": "0"
});
} else {
rafModal.find("#frnd" + i).css({
display: "block"
});
rafModal.find("#ref-mail" + i + "-frind-name").removeAttr("disabled");
rafModal.find("#ref-mail" + i + "-frind-l-name").removeAttr("disabled");
rafModal.find("#ref-mail" + i + "-f-mail").removeAttr("disabled");
rafModal.find("#ref-mail" + i + "-subject").removeAttr("disabled");
rafModal.find("#ref-mail-desc-" + i).removeAttr("disabled");
rafModal.find("#border-" + i).css({
"display": "block",
"border-top": "0",
"padding-top": "0"
});
}
}
if (numOfReferees == maxNumOfReferees) {
if (rafModal == undefined) {
$(".add-frnd-sec").hide();
} else {
rafModal.find(".add-frnd-sec").hide();
}
}
}
/**
* Ajax call for RAF to show the overlay.
*/
$(document).on("click", "a[id*='referafriend']", function () {
var inputObj = $(this);
var myModalURL = inputObj.attr('data-modal-url');
$.get(myModalURL, function (overlayHTML) {
successReferAFriend(overlayHTML)
});
});
/**
* Success call back for RAF.
*/
function successReferAFriend(overlayHTML) {
var rafModal = $(overlayHTML).filter("#refModal");
$('#myModal').modal('hide');
rafModal.modal();
var numOfReferees = rafModal.find("#numOfReferees").val();
var maxNumOfReferees = rafModal.find("#maxNumOfReferees").val();
loadReferees(numOfReferees, maxNumOfReferees, rafModal);
}
/**
* Ajax call for RAF form submission.
*/
$(document).on("click", "#raf_button", function () {
if (location.pathname
.indexOf("/customer-service/refer-a-friend") == -1) {
var numOfReferees = $("#totalFriends").val();
} else {
var numOfReferees = $("#numOfReferees").val();
}
var isPrepopulated = $("#isPrepopulated").val();
var n = numOfReferees;
for (var i = 1; i <= n; i++) {
var isEmpty = true;
var fName = $("#ref-mail" + i + "-frind-name").val();
var lName = $("#ref-mail" + i + "-frind-l-name").val();
var email = $("#ref-mail" + i + "-f-mail").val();
var subject = $("#ref-mail" + i + "-subject").val();
var body = $("#ref-mail-desc-" + i).val();
if (fName != "" || lName != "" || email != "" || (isPrepopulated == "false" && subject != "") ||
(isPrepopulated == "false" && body != "")) {
isEmpty = false;
}
$("#ref-mail" + i + "-frind-name").attr("name", "raf_f_" + i + "_firstName");
$("#ref-mail" + i + "-f-mail").attr("name", "raf_f_" + i + "_email");
$("#ref-mail" + i + "-subject").attr("name", "raf_f_" + i + "_subject");
if (isEmpty) {
$("#ref-mail" + i + "-frind-name").removeAttr("name");
$("#ref-mail" + i + "-f-mail").removeAttr("name");
$("#ref-mail" + i + "-subject").removeAttr("name");
$("#ref-mail-desc-" + i).removeAttr("name");
numOfReferees = numOfReferees - 1;
}
}
if (location.pathname
.indexOf("/customer-service/refer-a-friend") == -1) {
$("#successURL").val($("#overlaySuccessURL").val());
$("#errorURL").val($("#overlayErrorURL").val());
doAJAXEnableInputs($(this), null, successReferFriend);
} else {
var form = $(this).closest("form");
$("#successURL").val($("#pageSuccessURL").val());
$("#errorURL").val($("#pageErrorURL").val());
form.submit();
}
});
/**
* Success callback method for RAF Form Submission.
*/
function successReferFriend(response, form) {
var errorDiv = $(response).find("#error_raf");
form.find("#error_raf").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
//if no form errors show overlay
$("#error_raf").empty();
$('#refModal').modal('hide');
var modalDiv = $(response).filter("#refThankYouModal");
modalDiv.modal();
}
//Scroll to error div when form error occurs.
else {
scrolloverlay($("#error_raf"));
}
}
/**
* To add more friend's in RAF by clicking (+ADD FRIEND).
*/
$(document).on("click", "a[id*='addFrnd']", function (e) {
e.preventDefault();
var numOfReferees = $("#numOfReferees").val();
var refereesToAdd = $("#refereesToAdd").val();
var maxNumOfReferees = $("#maxNumOfReferees").val();
var toalReferees = parseInt(numOfReferees) + parseInt(refereesToAdd);
for (var i = toalReferees; i > 0; i--) {
document.getElementById("frnd" + i).style.display = "block";
$("#ref-mail" + i + "-frind-name").removeAttr("disabled");
$("#ref-mail" + i + "-frind-l-name").removeAttr("disabled");
$("#ref-mail" + i + "-f-mail").removeAttr("disabled");
$("#ref-mail" + i + "-subject").removeAttr("disabled");
$("#ref-mail-desc-" + i).removeAttr("disabled");
$("#border-" + i).css({
"display": "block",
"border-top": "0",
"padding-top": "0"
});
}
$("#numOfReferees").val(toalReferees);
$("#totalFriends").val(toalReferees);
if (toalReferees == maxNumOfReferees) {
$(".add-frnd-sec").hide();
}
});
/**
* Profanity check in RAF
*/
$(document).on('keyup', "textarea[id*='ref-mail-desc-']", function (e) {
if (e.keyCode == 32 || e.keyCode == 13 || e.keyCode == 39 || e.keyCode == 37) {
var str = $(this).val();
var newString = str.replace(/[^a-zA-Z0-9 ]/g, " ");
var strList = newString.split(" ");
var badWords = $("#badwords").val();
var badWordList = badWords.split(",");
for (var i = 0; i < badWordList.length; i++) {
for (var j = 0; j < strList.length; j++) {
if (strList[j].toLowerCase() == badWordList[i]) {
$(this).val(str.replace(strList[j], repeat("*", strList[j].length)));
}
}
}
}
});
/**
* To repeat a string n number of times.
*/
function repeat(str, n) {
var repeatedStr = "";
for (var a = 0; a < n; a++) repeatedStr += str;
return repeatedStr;
}
/**
* eClub success event call
*/
var eclubFlag = $('#eClubFlagID').val();
if (eclubFlag == 'true') {
analyticsEvent("eclubSignup", "eclub");
}
/**
* Clear datafields in RAF
*/
$(document).on("click", "button[id*='clear-raf-']", function () {
var isEditSubject = $("#isEditSubject").val();
var isEditComment = $("#isEditComment").val();
var inputObj = $(this);
var frndId = inputObj.attr("data-id");
if (isEditSubject == "true") {
$("#ref-mail" + frndId + "-subject").val("");
}
$("#ref-mail" + frndId + "-frind-name").val("");
$("#ref-mail" + frndId + "-frind-l-name").val("")
$("#ref-mail" + frndId + "-f-mail").val("");
if (isEditComment == "true") {
$("#ref-mail-desc-" + frndId).val("");
}
});
/* Refer a Friend ends*/
/**
* Viewing order details in orde confirmation page.
*/
$(document).on("click", "#lookUpOrder", function () {
$("#lookUpOrder").removeAttr('href');
var form = $(this).closest("form");
form.submit();
});
/* START of omniture tagging for MORE MENU */
$(document).on("click", '#moreMenuIcon,#moreMenu', function () {
var Language = $("#language").val();
var Brand = $("#brand").val();
var linkval = $("#linkval").val();
});
/* END of omniture tagging for MORE MENU */
/* for Location Search Results Page - 2 clickable tags(ORDER TO GO, WEBAHEAD) in LongHORN*/
$(document).on("click", "#WebAheadOmni", function () {
var Language = $("#language").val();
var Brand = $("#brand").val();
var linkval = $("#omniLinkVal").val();
});
$(document).on("click", "#orderOnline", function () {
var Language = $("#language").val();
var Brand = $("#brand").val();
var linkval = $("#omniLinkVal").val();
});
});
if ($('#dtmenabled').val() == "false") { //dtm flag start
if ($("#eventLogin").length > 0) {
var loggedin = $("#eventLogin").attr('data-logstatus');
if (loggedin == 'true') {
s.linkTrackVars = 'eVar9';
s.eVar9 = 'Logged In';
}
}
} //dtm flag end
$(document).ready(
function () {
var loggedin = $("#eventLogin").attr('data-logstatus');
if ((loggedin != "") && $("#doubleLine")) {
$("#doubleLine").remove();
}
});
/**
* omniture event for trackeing succesfully logged in user
*
* removed duplicate code
*/
/*if ($("#security_status").length > 0) {
var loggedin=$("#security_status").val();
s.linkTrackVars='eVar9,prop7';
if(loggedin == '2' || loggedin == '3' || loggedin == '4' || loggedin == '5') {
s.eVar9=s.prop7 = 'Logged In';
var checkEvent=s.events;
if(window.location.href.indexOf("requestid")>-1 && window.location.href.indexOf("giftcard")>-1){
if(checkEvent){
if(checkEvent.indexOf("event8") == -1){
s.linkTrackEvents='event8';
s.events = "event8";
}
}else{
s.linkTrackEvents='event8';
s.events = "event8";
}
}
s.tl($(this), 'o', s.pageName);
}else{
s.eVar9=s.prop7 = 'Not Logged In';
}
}*/
/**************start of code change for magic ticket 469098273 and 469098289****************/
/*$(function(){
$("#offers").parent(".checkbox_d").click(function () {
s.linkTrackVars='eVar7,eVar10,events';
s.eVar10= 'Eclub';
s.eVar7 = 'Global opt-in';
s.tl($(this), 'o', 'Eclub Step1 SignUp');
});
});*/
/***************end of code change for magic ticket 469098273 and 469098289 ****************/
/*START of omniture tagging **/
function omnitureTaggingFun(brand, language, linkName, linkType) { }
/* END of omniture tagging*/
/*START of webahead changes **/
$(document).ready(function () {
$('.webahead').children('img').attr('style', 'display:none');
$('#webahead').attr('style', 'top: 50%;bottom: 50%; width: 380px; position: fixed; padding-left:4px; transform: translate(-50%, -50%);');
$('#webahead').children('button.close').attr('style', 'margin-right:5px !important; right:0em !important; top:0em !important');
$('#webahead').children('button').click(function () {
document.getElementById('framwebahead').src = "about:blank";
});
if (location.pathname.indexOf('/locations/') != -1) {
var isJoinWaitlist = getUrlParameter('joinwaitlist');
var sid = getUrlParameter('SID');
if (isJoinWaitlist == 'true') {
var url = $('#webaheadURL').attr('value');
if ($('#newlocations').attr('value') != null &&
$('#newlocations').attr('value') != undefined) {
if ($('#newlocations').attr('value') == 'ALL') {
if ($('#newwebaheadURL').attr('value') != null &&
$('#newwebaheadURL').attr('value') != undefined) {
var restNum = getUrlParameter('restNum');
var newurl = $('#newwebaheadURL').attr('value') + "&sid=" + sid;
url = newurl;
}
} else if ($('#newlocations').attr('value') == 'NONE') {
url = url + "&SID=" + sid;
} else {
if ($('#newwebaheadURL').attr('value') != null &&
$('#newwebaheadURL').attr('value') != undefined) {
var restNum = getUrlParameter('restNum');
var splitNewLocations = $('#newlocations').attr('value').split("|");
var useNewUrl = false;
for (i = 0; i < splitNewLocations.length; i++) {
if (splitNewLocations[i] == restNum) {
useNewUrl = true;
}
}
if (useNewUrl) {
url = $('#newwebaheadURL').attr('value') + "&sid=" + sid;
} else {
url = url + "&SID=" + sid;
}
}
}
}
document.getElementById('framwebahead').src = url;
$('#webahead').toggleClass("hide");
}
$('#webahead').children('button.close').click(function () {
$('#webahead').toggleClass("hide");
});
if (location.pathname.indexOf("/menu-listing/dinner") != -1) {
if (location.hash.indexOf("#soups-salads") != -1) {
$('').insertAfter("input#media");
} else if (location.hash.indexOf("#cucina-mia") != -1) {
$('
').insertAfter("input#media");
}
} else if (location.pathname.indexOf("/menu-listing/pronto-lunch") != -1) {
if (location.hash.indexOf("#lighter-italian-fare") != -1) {
$('
').insertAfter("input#media");
}
}
}
});
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
}
function getUrlParameterFromUrl(sUrl, sParam) {
/* var sUrl = sParam.search.substring(1);
var sURLVariables = sPageURL.split('&'); */
var sURLVariables = sUrl.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
}
if ($('#dtmenabled').val() == "false") { //dtm flag start
if ($("#security_status").length > 0) {
var loggedin = $("#security_status").val();
if ($("#brand").val() == "OG") {
if (loggedin < 5) {
if ((location.pathname.indexOf("/home") == 0) || (location.pathname.indexOf("/es/pagina-de-inicio") == 0)) {
s.eVar9 = s.prop7 = 'Logged In';
}
} else {
s.linkTrackVars = 'eVar9,prop7';
if (loggedin == '2' || loggedin == '3' || loggedin == '4' || loggedin == '5') {
s.eVar9 = s.prop7 = 'Logged In';
if (window.location.href.indexOf("requestid") > -1) {
s.linkTrackEvents = 'event8';
s.events = "event8";
}
s.tl($(this), 'o', s.pageName);
} else {
s.eVar9 = s.prop7 = 'Not Logged In';
}
}
}
}
} //dtm flag end
function getUrlParameterFromUrl(url, query) {
query = query.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var expr = "[\\?&]" + query + "=([^]*)";
var regex = new RegExp(expr);
var results = regex.exec(url);
if (results !== null) {
return results[1];
} else {
return false;
}
}
function urlchange(url) {
if (location.pathname.indexOf('/fl/winter-park/winter-park-village/1275') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=38e07a9fc5064212a16b086d9f283b57";
}
if ($('#newlocations').attr('value') != null &&
$('#newlocations').attr('value') != undefined) {
if ($('#newlocations').attr('value') == 'ALL') {
if ($('#newwebaheadURL').attr('value') != null &&
$('#newwebaheadURL').attr('value') != undefined) {
var sid = getUrlParameterFromUrl(url, 'sid');
var restNum = getUrlParameterFromUrl(url, 'restNum');
var newurl = $('#newwebaheadURL').attr('value') + "&sid=" + sid;
url = newurl;
}
} else if ($('#newlocations').attr('value') == 'NONE') {
url = url.slice(0, url.length - 13);
} else {
if ($('#newwebaheadURL').attr('value') != null &&
$('#newwebaheadURL').attr('value') != undefined) {
var restNum = getUrlParameterFromUrl(url, 'restNum');
var splitNewLocations = $('#newlocations').attr('value').split("|");
var useNewUrl = false;
for (i = 0; i < splitNewLocations.length; i++) {
if (splitNewLocations[i] == restNum) {
useNewUrl = true;
}
}
if (useNewUrl) {
var sid = getUrlParameterFromUrl(url, 'sid');
url = $('#newwebaheadURL').attr('value') + "&sid=" + sid;
} else {
url = url.slice(0, url.length - 13);
}
}
}
}
document.getElementById('framwebahead').src = url;
if (location.pathname.indexOf('/locations/fl/') != -1) {
if (location.pathname.indexOf('/5326') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=a229d862380d433982cef893bf150904";
}
if (location.pathname.indexOf('/5359') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=e3ef8ce53aab4ac4a6e2a11da2299d7d";
}
if (location.pathname.indexOf('/5383') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=48d506d1764841aa9b31d34a4b485243";
}
if (location.pathname.indexOf('/5502') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=8b3125252d424480be2d009868744f0f";
}
if (location.pathname.indexOf('/5044') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=f1a5e079f23f462fb3213d8a4b0a3c3e";
}
if (location.pathname.indexOf('/5045') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=6e1304d9ce7947e6847f66d043207b13";
}
if (location.pathname.indexOf('/5133') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=5947bfd315f14ca1b7f7a4e2c93c9666";
}
if (location.pathname.indexOf('/5347') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=19373dd3e7044a30be354ca37e2e0f61";
}
if (location.pathname.indexOf('/5485') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=758b794608ad4766b687e0f15c88d348";
}
if (location.pathname.indexOf('/5055') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=6e095f84484f4f0fbb16b2dc52d8b7ab";
}
if (location.pathname.indexOf('/5129') != -1) {
document.getElementById('framwebahead').src = $('#newwebaheadURL').attr('value') + "&sid=4cf2a04140504d94ad13c5a09e86b11a";
}
}
}
//Recent Activity and Order History changes
var gcAccords = $("a[id*='order-history-collapse-plus']");
if (typeof gcAccords[0] !== 'undefined') {
$.each(gcAccords, function () {
$(this).attr("title", "expand");
});
}
//Recent Activity and Order History changes
$(document).on("click", "a[id*='order-history-collapse']", function () {
var inputObj = $(this);
var orderId = inputObj.attr("data-id");
var url = inputObj.attr('data-url');
//added for INC17342
var checksum = inputObj.attr('data-checksum');
if ($("#order-details-" + orderId).length == 0) {
request = $.ajax({
url: url,
type: "post",
data: "orderId=" + orderId + "&checksum=" + checksum
});
request.done(function (response, textStatus, jqXHR) {
$("#detailsContent" + orderId).html(response);
$("#detailsContent" + orderId).css('height', 'auto');
});
}
$(this).toggleClass("collapsed");
var elementID = $(this).attr("id")
if (elementID == "order-history-collapse-expand_link" + orderId || elementID == "order-history-collapse-click" + orderId) {
$("#order-history-collapse-plus" + orderId).toggleClass("collapsed");
}
if ($("#order-history-collapse-plus" + orderId).hasClass("collapsed")) {
$("#order-history-collapse-plus" + orderId).attr("title", "collapse");
} else {
$("#order-history-collapse-plus" + orderId).attr("title", "expand");
}
$(this).parents('.row').siblings(".gc_order_statuscontent").toggle();
});
/**END of webahead changes **/
/**
* Omniture tracking on refer-a-friend Page
*/
if (location.pathname
.indexOf("/customer-service/refer-a-friend-thank-you") != -1) {
s.events = "event38";
s.pageName = 'Refer a Friend Completed';
}
if (window.location.host.search(/beta/i) > 0) {
if ($('.togotxt').eq(1).html() == "GIFT CARD ORDERS") {
$('.togotxt').eq(1).attr("style", "display:none");
$('.togotxt').next().hide();
}
$('#orderdetails2').hide();
}
// Change for Enhancement : Location update from sitemap - starts here [xsdamm1]
function setLocationCookie(locationCookie) {
var $cookieValues = locationCookie;
var $locCookie = $.cookie("DRIREST");
var d = new Date();
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
if ($locCookie) {
$.cookie("DRIREST", null, { expires: -1 });
document.cookie = "DRIREST" + "=" + encodeURIComponent($cookieValues) + "; " + expires + "; path=/; Samesite=Lax";
}
else {
document.cookie = "DRIREST" + "=" + encodeURIComponent($cookieValues) + "; " + expires + "; path=/; Samesite=Lax";
}
}
function setLocationIDCookie(locationCookie) {
var $cookieValues = locationCookie;
var $locIDValue = $cookieValues.split("@@")[0];
var $locationIDCookie = $.cookie("DRILOCID");
var d = new Date();
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
if ($locationIDCookie) {
$.cookie("DRILOCID", null, { expires: -1 });
document.cookie = "DRILOCID" + "=" + $locIDValue + "; " + expires + "; path=/; Samesite=Lax";
}
else {
document.cookie = "DRILOCID" + "=" + $locIDValue + "; " + expires + "; path=/; Samesite=Lax";
}
}
function setRestaurantIdCookie(locationCookie) {
var restIdCookie = $.cookie("DRIRESTAURANTID");
var restId = locationCookie.split("@@")[11];
var d = new Date();
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
if (restIdCookie) {
$.cookie("DRIRESTAURANTID", null, { expires: -1 });
document.cookie = "DRIRESTAURANTID" + "=" + restId + "; " + expires + "; path=/; Samesite=Lax";
}
else {
document.cookie = "DRIRESTAURANTID" + "=" + restId + "; " + expires + "; path=/; Samesite=Lax";
}
}
function setLocationHeader(locationCookie) {
var locationCookie = decodeURIComponent($.cookie("DRIREST"));
var locValues = locationCookie.split("@@");
if (locationCookie) {
$('#no-location-selected').hide();
$('#selected-location').show();
$('#mobile-no-location-selected').hide();
$('#mobile-selected-location').show();
} else {
$('#no-location-selected').show();
$('#selected-location').hide();
$('#mobile-no-location-selected').show();
$('#mobile-selected-location').hide();
}
if (locValues.length > 0) {
// /state/city/restname/restnum
var locURL = $('#locationURL').val() + "/" + locValues[5] + "/" + locValues[4] + "/" + locValues[1] + "/" + locValues[11];
locURL = locURL.replace(/[^a-zA-Z0-9/]/g, '-');
locURL = locURL.toLowerCase();
/*Changes made for Multiple Hyphens Issue -Sai Priyanka */
locURL = locURL.replace(/-{2,}/g, '-');
// add links to location details
$('#popRestNameLink').attr("href", locURL);
$('#popRestHrsLink').attr("href", locURL);
$('#popDirIconLink').attr("href", locURL);
$('#popDirLink').attr("href", locURL);
$('#popMapLink').attr("href", locURL);
// set Rest_ID from cookie for SMS and Email
$('#sms-current').attr("data-id", locValues[0]);
$('#email-current').attr("data-id", locValues[0]);
//image
var protocol = $('#protocol').val() ? $('#protocol').val() : 'https:';
var locDynImg = $('#locDynImg').val();
var mapImg = protocol + "//media.longhornsteakhouse.com/images/site/lh_front.jpg";
$("#mapImg").attr("src", mapImg);
$("#mapImgStatic").attr("src", mapImg);
$("#mapImgDyn").attr("src", locDynImg ? locDynImg : mapImg);
$("#mapImg").attr("src", mapImg);
// lat_long
$('#latLong_header').val(locValues[2]);
// rest name
$('#headRestName').text(locValues[1]);
$('#popRestName').text(locValues[1]);
$('#overlayRestName').text(locValues[1]);
// rest phone number
$('#headRestPhone').text(locValues[7]);
$('#popRestPhone').text(locValues[7]);
// rest address
$('#popRestAdd1').text(locValues[3]);
$('#popRestCity').text(locValues[4]);
$('#popRestState').text(locValues[5]);
$('#popRestZip').text(locValues[6]);
// rest Op hours
$('#popRestHrs').html(locValues[8]);
var welcomeConfigValue = $('#welcomeConfigValue').val();
var pageURL = window.location + "";
if ((pageURL.indexOf('/home') > -1 || pageURL.indexOf('/pagina-de-inicio') > -1) && locValues[10] == 'auto') {
$("div#pop-up").show();
setTimeout('$("div#pop-up").hide()', parseInt(welcomeConfigValue));
var oldCookieVal = decodeURIComponent($.cookie("DRIREST"));
oldCookieVal = oldCookieVal.replace(/(auto)/g, '~');
$.cookie("DRIREST", oldCookieVal, {
expires: 365,
path: "/"
});
}
}
}
// Change for Enhancement : Location update from sitemap - ends here [xsdamm1]
//Following function added for Stability Fixes - Avinash [xsdaas1]
if ($('#dtmenabled').val() == "false") { //dtm flag start
/**
* Omniture tracking on refer-a-friend Page
*/
if (location.pathname
.indexOf("/customer-service/refer-a-friend-thank-you") != -1) {
s.events = "event38";
s.pageName = 'Refer a Friend Completed';
}
} //dtm flag end
//added by smitha for webahead changes
function showJoinWaitListDetails() {
//waitListInfo
var url = "/customer-service/includes/location-webahead-info.jsp";
var dataPageURL = location.pathname;
var data = {};
if (window.location.protocol == "https:") {
url = $("#ajaxServletURL").val();
data.AJAX_FUNCTION = "locationWebaheadinfo";
}
$.ajaxSetup({
cache: false
});
if ($("#joinWaitListDetails").length > 0) {
var join_wait_list_details = $("#joinWaitListDetails");
data.dataPageURL = dataPageURL;
$.get(url, data, function (response) {
join_wait_list_details.html($(response).filter('#waitListInfo').html());
});
}
}
if ($('#dtmenabled').val() == "false") { //dtm flag start
/**
* Omniture tracking on refer-a-friend Page
*/
if (location.pathname
.indexOf("/customer-service/refer-a-friend-thank-you") != -1) {
s.events = "event38";
s.pageName = 'Refer a Friend Completed';
}
/**
* Omniture tracking on tell-us-more Page
*/
if ((location.href.indexOf('/customer-service/landing-page') > -1) || (location.href.indexOf('/customer-service/tell-us-more') > -1)) {
s.linkTrackVars = 'eVar7,events,eVar10';
s.linkTrackEvents = "event3";
s.events = "event3";
s.eVar7 = "Concept Opt-in";
s.eVar10 = 'EClub' + '-' + s.pageName + ' option';
//void(s.t());
}
} //dtm flag end
function addWaitListPosition(modalDiv) {
var wlPosition = $(modalDiv).find('span#wlposition').html();
if (wlPosition) {
var addPosition = ["th", "st", "nd", "rd"], vnum = wlPosition % 100;
var lastn = (addPosition[(vnum - 20) % 10] || addPosition[vnum] || addPosition[0]);
$(modalDiv).find('span#wlposition').html(wlPosition + (lastn).sup());
}
}
/*
* Success callback method for waitlist step 2
*/
function waitListSuccessStep2Call(response, form, inputObj) {
var errorDiv = $(response).find("#error_msg");
form.find("#error_msg").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
$("#error_msg").empty();
$("#joinWaitListModal").remove();
loadWaitList2(response);
} else {
//WO38296 Decmonitor error code for Join wailist : Start
var decMonitorInput = $(response).filter("#DECMonitor");
form.append(decMonitorInput);
//WO38296 Decmonitor error code for Join wailist : End
form.find("#error_msg").html(errorDiv.html());
form.find("#error_msg").show();
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
}
}
function loadWaitList2(modalHTML) {
//DFA_floodLight('JoinWaitListFormButton');
if ($("#joinWaitListModal")) {
$("#joinWaitListModal").modal('hide');
$("#joinWaitListModal").remove();
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
}
var modalDiv = $(modalHTML).filter("#joinWaitListModal");
if (modalDiv.html() == undefined) {
modalDiv = $(modalHTML).filter("#switchLocationModal");
}
addWaitListPosition(modalDiv);
if ($('#dtmenabled').val() == "false") { //dtm flag start
//omniture starts-for confirmation page load
clearOmnitureVars();
s.linkTrackVars = 'events,eVar79,eVar75,eVar81,eVar1,prop1';
s.linkTrackEvents = 'event49,event99';
s.events = 'event49,event99';
if ($("#page_confirm").val() == 'editSuccess') {
s.pageName = 'lh|us|en|WebAhead|Edit Guests Confirmation';
} else {
s.pageName = 'lh|us|en|WebAhead|Wait List Confirmation';
}
s.eVar79 = $("#estimated_wait").val();
s.eVar75 = window.location.href;
s.eVar81 = $(modalHTML).find("#guest_size_val").val();
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t(true, 'o', linkname);
//omniture ends
} //dtm flag end
/* Adding this logic for Waitlist complete event for as part of DTM implementation /*
/* DTM changes start here */
// analyticas wait list complete event
if (window.AU !== "undefined") {
var partySize = 0;
var estimatedWait = "No Wait"
if ($(modalHTML).find("#guest_size_val").val()) {
partySize = $(modalHTML).find("#guest_size_val").val();
}
if ($(modalHTML).find("#estimated_wait").val()) {
estimatedWait = $(modalHTML).find("#estimated_wait").val();
}
AU.dispatchEvent("AnalyticsEvent", "waitlistComplete", { "partySize": partySize, "waitTime": estimatedWait });
}
/* DTM changes end here */
modalDiv.attr('style', 'top: 0% !important');
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
//$('input:disabled').prop('disabled', false);
//$('button:disabled').prop('disabled', false);
$(window).scrollTop(0);
}
/**
* Common method for loading overlay for waitlist
*/
function loadWaitListOverlay(modalHTML) {
var modalDiv = $(modalHTML).filter("#joinWaitListModal");
modalDiv.attr('style', 'top: 0% !important');
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
}
//email overlay changes
$(document).on("click", "#enterEmailWaitList", function () {
if ($(this).prop('disabled')) {
return false;
}
var wait_list_email_url = $("#enterEmailWaitList").attr('data-url');
request = $.ajax({
url: wait_list_email_url,
type: "post"
});
request.done(function (response, textStatus, jqXHR) {
if ($("#joinWaitListModal")) {
$("#joinWaitListModal").modal('hide');
//$("#joinWaitListModal").remove();
}
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
var modalDiv = $($.parseHTML(response)).filter(
"#joinWaitListStep2");
if ($('#dtmenabled').val() == "false") { //dtm flag start
//omniture starts- for confirm email page onload
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar1,prop1';
s.linkTrackEvents = 'event49';
s.events = 'event49';
s.pageName = 'lh|us|en|WebAhead|Send Via Email';
s.eVar75 = window.location.href;
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t($(this), 'o', linkname);
//omniture ends
} //dtm flag end
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
$(window).scrollTop(0);
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
/**
* Send waitlist Information via email to user
*
*/
$(document).on("click", "#emailWaitList", function () {
if ($(this).prop('disabled')) {
return false;
}
var pattern = /^[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*@[a-z0-9]+(\-[a-z0-9]+)*(\.[a-z0-9]+(\-[a-z0-9]+)*)*\.[a-z]{2,4}$/;
var emailcontent = document.getElementById('emailAddress').value;
if (pattern.test(emailcontent)) {
doAJAX($(this), null, hideEmailBlock);
//$("input, button, a, span").prop("disabled", false);
} else {
$('#error_message_email_waitlist').text($('#invalidemailaddr').val());
emailcontent = "";
}
return false;
});
function hideEmailBlock(response, form) {
$('#error_message_email_waitlist').text('');
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
loadWaitListOverlay_email(response);
/* $('#joinWaitListModal').modal({
show: 'true'
});*/
}
//waitlist email overlay display changes
function loadWaitListOverlay_email(modalHTML) {
var modalDiv;
modalDiv = $(modalHTML).filter("#joinWaitListModal");
if (modalDiv.html() == undefined) {
modalDiv = $(modalHTML).filter("#joinWaitListStep2");
}
modalDiv.attr('style', 'top: 0% !important');
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
}
//send via phone changes
$(document).on("click", "#enterSmsWaitList", function () {
if ($(this).prop('disabled')) {
return false;
}
var wait_list_sms_url = $("#enterSmsWaitList").attr('data-url');
request = $.ajax({
url: wait_list_sms_url,
type: "post",
});
request.done(function (response, textStatus, jqXHR) {
if ($("#joinWaitListModal")) {
$("#joinWaitListModal").modal('hide');
//$("#joinWaitListModal").remove();
}
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
var modalDiv = $($.parseHTML(response)).filter(
"#joinWaitListStep3");
scrolloverlay(modalDiv);
if ($('#dtmenabled').val() == "false") { //dtm flag start
//omniture starts- for confirm text page onload
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar1,prop1';
s.linkTrackEvents = 'event49';
s.events = 'event49';
s.pageName = 'lh|us|en|WebAhead|Send Via Text';
s.eVar75 = window.location.href;
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t($(this), 'o', linkname);
//omniture ends
} //dtm flag end
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
$(window).scrollTop(0);
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
/**
* Send waitlist Information using SMS to user
*
*/
$(document).on("click", "#smsWaitList", function () {
var phonenumber = document.getElementById('phone-ctn-waitlist').value;
var phonenumberformatted;
var len;
if (phonenumber.length > 0) {
var phonenumberformatted = phonenumber.replace(/\D/g, '');
}
if (phonenumberformatted == undefined) {
len = 0;
} else {
var len = phonenumberformatted.length;
}
if (len <= 0) {
$('#error_message_mobile_waitlist').text($('#invalidphone').val());
} else if (len < 10) {
$('#error_message_mobile_waitlist').text($('#invalidphone').val());
} else if (isNaN(phonenumberformatted)) {
$('#error_message_mobile_waitlist').text($('#invalidphone').val());
} else {
doAJAX($(this), null, hideSmsBlock);
}
// preventing the page from being refreshed
return false;
});
/**
* Send SMS Success call back function
*
*/
function hideSmsBlock(response, form) {
$('#error_message_mobile_waitlist').text('');
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
loadWaitListOverlay_sms(response);
}
//waitlist sms overlay display changes
function loadWaitListOverlay_sms(modalHTML) {
var modalDiv;
modalDiv = $(modalHTML).filter("#joinWaitListModal");
if (modalDiv.html() == undefined) {
modalDiv = $(modalHTML).filter("#joinWaitListStep3");
}
modalDiv.attr('style', 'top: 0% !important');
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
}
/**
* Allow only numbers for phone number field
*/
$(document).on('keypress', '#phone-ctn-waitlist', function (e) {
if (e.which > 31 && (e.which < 48 || e.which > 57)) {
e.preventDefault();
}
});
/** Method for formatting phone number to (###) ###-#### format **/
$(document).on('keypress', '#phone-ctn-waitlist', function (e) {
var l = $(this).val().length;
var text = $(this).val();
var isNumber = (e.which > 47 && e.which < 58) || (e.which > 95 && e.which < 106);
if (isNumber) {
if (l <= 4) {
for (var i = 0; i <= l; i++) {
var codeA = text.charCodeAt(i);
if (codeA > 31 && (codeA < 48 || codeA > 57)) {
$(this).val(text.replace(/(\d{3})\)?/g, '$1)'));
return true;
}
}
/** alm 7526 change start **/
$(this).val(text.replace(/(\d{3})\)?/g, '($1) '));
return true;
/** alm 7526 change end **/
}
if (l == 9) {
$(this).val(text.replace(text, text + '-'));
return true;
}
}
});
/**
* for redirection of close button in waitlist overlay
*/
$(document).on("click", "#joinWaitListModal_overlayCloseButton_custom1,#waitlistCancel", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').css('padding-right', '0px');
$('body').removeClass('modal-open');
$("#joinWaitListModal").removeClass("show");
$("#joinWaitListModal").hide();
$('.modal-backdrop').remove();
var div = document.getElementById('waitlist-step1');
var url = div.getAttribute("data-url");
if (url == "null") url = "";
$('[id="enterWaitList"]').prop('disabled', false);
});
$(document).on("click", "#joinWaitListModal_overlayCloseButton_custom2", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$("#joinWaitListModal").removeClass("show");
$('.modal-backdrop').remove();
var div = document.getElementById('waitlist-step2');
if (null != div) {
var url = div.getAttribute("data-url");
if (url == "null") url = "";
var name = div.getAttribute("data-name");
if (name == 'waitlist-step2') {
window.location.href = url;
}
}
var div2 = document.getElementById('session_msg');
if (null != div2) {
var currentUrl1 = location.pathname;
var splitUrl1 = currentUrl1.split("?");
var url = splitUrl1[0];
if (url == "null") url = "";
window.location.href = url;
}
});
$(document).on("click", "#joinWaitListModal_overlayCloseButton_custom3", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$("#joinWaitListModal").removeClass("show");
$('.modal-backdrop').remove();
var div = document.getElementById('waitlist-email');
if (null != div) {
var name = div.getAttribute("data-name");
if (name == 'waitlist-email') {
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
$('#joinWaitListModal').modal('show');
}
}
});
$(document).on("click", "#joinWaitListModal_overlayCloseButton_custom4", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$("#joinWaitListModal").removeClass("show");
$('.modal-backdrop').remove();
var div = document.getElementById('waitlist-text');
if (null != div) {
var name = div.getAttribute("data-name");
if (name == 'waitlist-text') {
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
$('#joinWaitListModal').modal('show');
}
}
});
$(document).on("click", "#joinWaitListModal_overlayCloseButton_custom5", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$('#joinWaitListModal').show();
$("#joinWaitListModal").removeClass("show");
$('.modal-backdrop').remove();
var div = document.getElementById('edit-waitlist-text');
var div2 = document.getElementById('error_msg');
if (null != div) {
var name = div.getAttribute("data-name");
if (name == 'edit-waitlist-text') {
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
$('#joinWaitListModal').modal('show');
}
}
});
/*added by chander */
$(document).on("click", "#joinWaitListModal_overlayCloseButton_custom6", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$("#joinWaitListModal").removeClass("show");
$('.modal-backdrop').remove();
var div = document.getElementById('editconfirm-close');
if (null != div) {
var url = div.getAttribute("data-url");
var name = div.getAttribute("data-name");
if (name == 'editconfirm-close') {
window.location.href = url;
}
}
});
/**By Chander-Waitlist Changes END here
*/
/**
* AJAX call to invoke remove waitlist step 1
* Added by sadanand
*
*/
$(document).on("click", "#CancelSwitch", function () {
$('#CancelSwitch').modal('hide');
var join_wait_list_url = $(this).attr('data-url');
request = $.ajax({
url: join_wait_list_url,
type: "post"
});
request.done(function (response, textStatus, jqXHR) {
var modalDiv = $($.parseHTML(response)).filter(
"#joinWaitListModal");
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
$(document).on("click", "#enterRMWaitList", function () {
$('#enterRMWaitList').modal('hide');
var join_wait_list_url = $(this).attr('data-url');
var base_wait_list_url = $(this).attr('base-url');
request = $.ajax({
url: join_wait_list_url,
type: "post",
data: {
base_wait_list_url: base_wait_list_url
}
});
request.done(function (response, textStatus, jqXHR) {
var modalDiv = $($.parseHTML(response)).filter(
"#removeWaitListModal");
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
$(window).scrollTop(0);
/* Adding this logic for Waitlist cancel event for as part of DTM implementation /*
/* DTM changes start here */
if ($("#dtmenabled").val() == "true") {
var ddAddWaitlistEvent = {
"eventInfo": {
"eventName": "waitlistCancel",
"type": "waitlist",
"timeStamp": new Date(),
"processed": {
"adobeAnalytics": false
}
}
};
if (window.digitalData != null) {
delete digitalData.event;
digitalData.event = digitalData.event || [];
window.digitalData.event.push(ddAddWaitlistEvent);
sendCustomEvent('waitlistCancel');
}
}
/* DTM changes end here */
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
//Changed for defect id 21469
$(document).on("click", "#RemoveWaitlistCancelConfirmation", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
$('#joinWaitListModal').show();
var div = document.getElementById('removeWaitlist-text');
if (null != div) {
var name = div.getAttribute("data-name");
if (name == 'removeWaitlist-text') {
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
$('#joinWaitListModal').modal('show');
}
}
});
$(document).on("click", "#RemoveWaitlistConfirmation", function () {
// $('#joinWaitListModal').modal('hide');
// $("#joinWaitListModal").remove();
var form = $(this).closest("form");
doAJAX($(this), null, RemovewaitListSuccessStep2Call);
// preventing the page from being refreshed
return false;
});
/* Success callback method for waitlist step 2
*/
function RemovewaitListSuccessStep2Call(response, form, inputObj) {
var errorDiv = $(response).find("#error_msg");
$("#error_msg").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
$("#error_msg").empty();
$('#removeWaitListModal').modal('hide');
$('#removeWaitListModal').remove();
var eventNameDL;
if (inputObj !== null) {
if (inputObj[0].value == "OK") {
eventNameDL = "waitlistCancel";
} else {
eventNameDL = "waitlistLocationUpdate";
}
}
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
if ($("#switchLocationModal")) {
$('#switchLocationModal').modal('hide');
$('#switchLocationModal').remove();
}
loadRemoveWaitListOverlay(response);
if (window.AU !== "undefined") {
var partySize = 0;
var estimatedWait = "No Wait";
if (eventNameDL == "waitlistLocationUpdate") {
if ($(response).find("#guest_size_val").val()) {
partySize = $(response).find("#guest_size_val").val();
}
if ($(response).find("#estimated_wait").val()) {
estimatedWait = $(response).find("#estimated_wait").val();
}
AU.dispatchEvent("AnalyticsEvent", eventNameDL, { "partySize": partySize, "waitTime": estimatedWait });
} else {
AU.dispatchEvent("AnalyticsEvent", eventNameDL);
}
}
} else {
$("div#error_msg").html(errorDiv.html());
$("div#error_msg").show();
}
}
function loadRemoveWaitListOverlay(modalHTML) {
if ($('#dtmenabled').val() == "false") { //dtm flag start
//omniture for -remove waitlist confiraiton page onload
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar1,prop1,eVar79,eVar81';
s.linkTrackEvents = 'event49,event100';
s.events = 'event49,event100';
s.pageName = 'lh|us|en|WebAhead|Wait List Removal';
s.eVar75 = window.location.href;
s.eVar79 = $("#estimated_wait").val();
s.eVar81 = $(modalHTML).find("#guest_size_val").val();
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t($(this), 'o', linkname);
//omiture ends
} //dtm flag end
$('#joinWaitListModal').modal('hide');
$("#joinWaitListModal").remove();
if ($("#joinWaitListModal")) {
$("#joinWaitListModal").remove();
}
var modalDiv = $(modalHTML).filter("#joinWaitListModal");
/*modalDiv.find(".styled-select select, .styled-select-red select").each(function() {
$(this).wrap("");
$(this).after("");
var firstOption = $(this).find("option:first").text();
$(this).next(".holder").text(firstOption);
});*/
modalDiv.attr('style', 'top: 0% !important');
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
//calling dgStyle() function manually for the checkbox to work normally
// as in a normal page load
if (modalDiv.find(".checkbox_d").length > 0) {
modalDiv.find(".checkbox_d").dgStyle();
}
}
$(document).on("click", "#enterSwitchLoc,#enterSwitchLocFromIE", function () {
$('#joinWaitListModal').modal('hide');
$("#joinWaitListModal").remove();
if ($("#switchLocationModal")) {
$('#switchLocationModal').modal('hide');
$('#switchLocationModal').remove();
}
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
var join_wait_list_url = $(this).attr('data-url');
var base_wait_list_url = $(this).attr('base-url');
request = $.ajax({
url: join_wait_list_url + "&base_wait_list_url=" + base_wait_list_url,
type: "post",
});
request.done(function (response, textStatus, jqXHR) {
var modalDiv = $($.parseHTML(response)).filter(
"#switchLocationModal");
scrolloverlay(modalDiv);
var isTOGO = $('#TOGO').val();
if (isTOGO) {
modalDiv.removeClass("hide"); //Togo Refactring pages need to remove hide class from bootstrap modal
}
if ($('#dtmenabled').val() == "false") { //dtm flag start
//omniture starts-for siwtch location page onload from location details page
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar1,prop1';
s.linkTrackEvents = 'event49';
s.events = 'event49';
s.pageName = 'lh|us|en|WebAhead|Switch Location';
s.eVar75 = window.location.href;
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t($(this), 'o', linkname);
//omniture ends
} //dtm flag end
if (!$("#switchLocationModal").length > 0) {
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
} else {
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
}
/* Adding this logic for Waitlist Change Location event for as part of DTM implementation /*
/* DTM changes start here */
if ($("#dtmenabled").val() == "true") {
var ddAddWaitlistEvent = {
"eventInfo": {
"eventName": "waitlistChangeLocation",
"type": "waitlist",
"timeStamp": new Date(),
"processed": {
"adobeAnalytics": false
}
}
};
if (window.digitalData != null) {
delete digitalData.event;
digitalData.event = digitalData.event || [];
window.digitalData.event.push(ddAddWaitlistEvent);
sendCustomEvent('waitlistChangeLocation');
}
}
/* DTM changes end here */
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
//stopping event propogation
/*Added by sadanand as Mutliple overlays where opening on multiple clicks*/
$(document).on("click", "#editWaitList", function () {
$('#joinWaitListModal').hide();
$(this).prop('disabled', true);
});
$(document).on("click", "#enterSmsWaitList", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#enterRMWaitList", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#enterEmailWaitList", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#omni_webahead_search_map", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#omni_webahead_search", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#enterSwitchLoc", function () {
$(this).prop('disabled', true);
});
//added for close overlay functionality
$(document).on("click", "#removeWaitlistModal_overlayCloseButton_custom1", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
var div = document.getElementById('removeWaitlist-text');
if (null != div) {
var name = div.getAttribute("data-name");
if (name == 'removeWaitlist-text') {
if ($("#removeWaitListModal")) {
$("#removeWaitListModal").remove();
}
if ($("#joinWaitListStep1")) {
$("#joinWaitListStep1").remove();
}
if ($("#joinWaitListStep2")) {
$("#joinWaitListStep2").remove();
}
if ($("#joinWaitListStep3")) {
$("#joinWaitListStep3").remove();
}
$('#joinWaitListModal').modal('show');
}
}
});
//commented as duplicate functions being called on click of button
$(document).on("click", "#removeWaitlistModal_overlayCloseButton_custom2", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
//magic 469665650
var currentUrl2 = location.pathname;
var splitUrl2 = currentUrl2.split("?");
var url = splitUrl2[0];
if (url == "null") url = "";
window.location.href = url;
});
$(document).on("click", "#removeWaitlistModal_overlayCloseButton_custom3", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
var currentUrl3 = location.pathname;
var splitUrl3 = currentUrl3.split("?");
var url = splitUrl3[0];
if (url == "null") url = "";
window.location.href = url;
});
/* End of modification by sadanand */
//Addition by Ajay
/**
* AJAX call to invoke view waitlist step 1
*
*/
$(document).on("click", "#viewWaitList,#viewWaitListFromIE", function () {
var view_wait_list_url = $(this).attr('data-url');
var base_wait_list_url = $(this).attr('base-url');
$(this).prop("disabled", true);
request = $.ajax({
url: view_wait_list_url + "&base_wait_list_url=" + base_wait_list_url,
type: "post",
});
request.done(function (response, textStatus, jqXHR) {
if ($('#dtmenabled').val() == "false") { //dtm flag start
if ($('#omniture_page_type').val() == 'location-info') {
clearOmnitureVars();
$(this).prop("disabled", true);
s.linkTrackVars = 'events,eVar75,eVar70,prop49,prop55,eVar81';
s.linkTrackEvents = 'event75,event97';
s.linkType = 'lnk_o';
s.events = 'event75,event97';
s.prop55 = $("#estimated_wait").val();
s.eVar81 = $(response).find("#guest_size_val").val();
var page_extra = s.pageName + ' '
s.eVar75 = window.location.href;
var linkText = $('#viewWaitList').text();
var linkname = s.eVar70 = s.prop49 = s.pageName + '|Location Details Page ' + linkText + ' link';
s.tl($(this), 'o', linkname);
}
} //dtm flag end
var modalDiv = $($.parseHTML(response)).filter(
/* accessbilty sunil */
"#joinWaitListModal").prepend("");
/* accessbilty sunil */
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
/*41459 - To update the wait list position*/
setTimeout(function () {
getWaitPosition();
}, 500);
});
/**
* AJAX call to invoke edit waitlist step 1
*
*
*/
$(document).on("click", "#editWaitList", function () {
var edit_wait_list_url = $("#editWaitList").attr('data-url');
request = $.ajax({
url: edit_wait_list_url,
type: "post"
});
request.done(function (response, textStatus, jqXHR) {
var modalDiv = $($.parseHTML(response)).filter(
"#joinWaitListStep1");
scrolloverlay(modalDiv);
if ($('#dtmenabled').val() == "false") { //dtm flag start
//omniture for -edit party size page onload
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar1,prop1';
s.linkTrackEvents = 'event49';
s.events = 'event49';
s.pageName = 'lh|us|en|WebAhead|Edit Guests';
s.eVar75 = window.location.href;
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t($(this), 'o', linkname);
//omiture ends
} //dtm flag end
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
$(window).scrollTop(0);
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
/**
* AJAX call to invoke edit wait list Step2
*/
$(document).on("click", "#EditWaitlistConfirmation", function () {
var form = $(this).closest("form");
doAJAX($(this), null, editConfirmationSuccess);
// preventing the page from being refreshed
return false;
});
/* Success callback method for edit wait list step 2
*/
function editConfirmationSuccess(response, form, inputObj) {
var errorDiv = $(response).find("#error_msg");
form.find("#error_msg").html(errorDiv.html());
if (!$.trim((errorDiv.html()))) {
$("#error_msg").empty();
$('#joinWaitListModal').remove();
$('#joinWaitListStep1').remove();
if ($("#joinWaitListStep1")) {
$("#joinWaitListModal1").modal('hide');
$("#joinWaitListStep1").remove();
}
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
if ($('#dtmenabled').val() == "false") { //dtm flag start
//omniture starts-for confirmation page load
clearOmnitureVars();
s.linkTrackVars = 'events,eVar79,eVar75,eVar81,eVar1,prop1';
s.linkTrackEvents = 'event49,event99';
s.events = 'event49,event99';
s.pageName = 'lh|us|en|WebAhead|Edit Guests Confirmation';
s.eVar79 = $("#estimated_wait").val();
s.eVar75 = window.location.href;
s.eVar81 = $(response).find("#guest_size_val").val();
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t(true, 'o', linkname);
//omniture ends
} //dtm flag end
loadWaitListOverlay_edit(response);
} else {
form.find("#error_msg").html(errorDiv.html());
form.find("#error_msg").show();
//scrolloverlay($("#joinWaitListModal"));
}
}
//Edit guest overlay display changes
function loadWaitListOverlay_edit(modalHTML) {
// analyticas wait list complete event
if (window.AU !== "undefined") {
var partySize = 0;
var estimatedWait = "No Wait"
if ($(modalHTML).find("#guest_size_val").val()) {
partySize = $(modalHTML).find("#guest_size_val").val();
}
if ($(modalHTML).find("#estimated_wait").val()) {
estimatedWait = $(modalHTML).find("#estimated_wait").val();
}
AU.dispatchEvent("AnalyticsEvent", "waitlistPartyUpdate", { "partySize": partySize, "waitTime": estimatedWait });
}
var modalDiv;
modalDiv = $(modalHTML).filter("#joinWaitListModal");
if (modalDiv.html() == undefined) {
modalDiv = $(modalHTML).filter("#joinWaitListStep1");
}
addWaitListPosition(modalDiv);
modalDiv.attr('style', 'top: 0% !important');
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
}
/**
* End of Modifications by Ajay
*/
function dfaFloodTag_header() {
// if ($('#time_error_msg').text()>-1)
DFA_floodLight('headerJoinWaitList');
}
function dfaFloodTag_locdropdown() {
// if ($('#time_error_msg').text()>-1)
DFA_floodLight('locDropDownJoinWaitList');
}
function dfaFloodTag_locDetail() {
// if ($('#time_error_msg').text()>-1)
DFA_floodLight('locDetailJoinWaitList');
}
function dfaFloodTag_Carousel() {
// if ($('#time_error_msg').text()>-1)
DFA_floodLight('CarouselJoinWaitList');
}
function dfaFloodTag_locationWebJoinWaitList(restID) {
// if ($('#time_error_msg').text()>-1)
DFA_floodLight('locationJoinWaitList' + restID);
}
//added by vara
//FOr onload waitlist confirmation page
$(document).on("click", "#EnterWaitlistConfirmationEmail", function () {
var wait_list_confirmation_url = $("#EnterWaitlistConfirmationEmail").attr('data-url');
request = $.ajax({
url: wait_list_confirmation_url,
type: "post"
});
request.done(function (response, textStatus, jqXHR) {
var modalDiv = $($.parseHTML(response)).filter(
"#joinWaitListModal");
addWaitListPosition(modalDiv);
scrolloverlay(modalDiv);
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
/*Added by sadanand as Mutliple overlays where opening on multiple clicks*/
$(document).on("click", "#editWaitList", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#enterSmsWaitList", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#enterRMWaitList", function () {
$('#joinWaitListModal').hide();
$(this).prop('disabled', true);
});
$(document).on("click", "#enterEmailWaitList", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#omni_webahead_search_map", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#omni_webahead_search", function () {
$(this).prop('disabled', true);
});
$(document).on("click", "#enterSwitchLoc", function () {
$(this).prop('disabled', true);
});
/*end of comments*/
$(document).on("click", "#enterWaitList1", function () {
window.location.href = "/wait-list";
});
$(document).on("click", "#enterSwitchLoc1", function () {
$('#joinWaitListModal').modal('hide');
$("#joinWaitListModal").remove();
if ($("#switchLocationModal")) {
$('#switchLocationModal').modal('hide');
$('#switchLocationModal').remove();
}
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
var join_wait_list_url = $(this).attr('data-url');
var base_wait_list_url = $(this).attr('base-url');
request = $.ajax({
url: join_wait_list_url + "&base_wait_list_url=" + base_wait_list_url,
type: "post",
});
request.done(function (response, textStatus, jqXHR) {
var modalDiv = $($.parseHTML(response)).filter(
"#switchLocationModal");
scrolloverlay(modalDiv);
if (!$("#switchLocationModal").length > 0) {
modalDiv.modal({
backdrop: 'static',
keyboard: false
});
$(window).scrollTop(0);
} else {
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
}
/* Adding this logic for Waitlist Change Location event for as part of DTM implementation /*
/* DTM changes start here */
if ($("#dtmenabled").val() == "true") {
var ddAddWaitlistEvent = {
"eventInfo": {
"eventName": "waitlistChangeLocation",
"type": "waitlist",
"timeStamp": new Date(),
"processed": {
"adobeAnalytics": false
}
}
};
if (window.digitalData != null) {
delete digitalData.event;
digitalData.event = digitalData.event || [];
window.digitalData.event.push(ddAddWaitlistEvent);
sendCustomEvent('waitlistChangeLocation');
}
}
/* DTM changes end here */
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// log the error to the console
console.error("The following error occured: " + textStatus,
errorThrown);
});
});
/*webahead omniture click events starts
* By chander
**/
if ($('#dtmenabled').val() == "false") { //dtm flag start
//1.Home page waitlist banner click
$(".slider2 .sliderli a[href$='location-search']").click(function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar70,prop49,eVar75,prop55';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
s.pageName = 'lh|us|en|WebAhead';
s.prop55 = $("#estimated_wait").val();
s.eVar75 = window.location.href;
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + 'Join Wait List Now Banner link';
s.tl($(this), 'o', linkname);
});
//1.join wait list
$(document).on("click", "#EnterWaitlistConfirmation,#waitlistCancel", function () {
$('input:disabled').prop('disabled', false);
$('button:disabled').prop('disabled', false);
$("#EnterWaitlistConfirmation").prop('disabled', true);
clearOmnitureVars();
s.linkTrackVars = 'events,eVar7,eVar79,eVar75,eVar10,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.events = 'event75';
var linkText;
var globalOptin;
//checkbox event
if ($(".checkbox_d_overlay.checkbox_checked").length) {
globalOptin = true;
} else {
globalOptin = false;
}
if ($(this).attr('id') == 'EnterWaitlistConfirmation') {
s.linkTrackEvents = 'event75,event7';
s.events = 'event75,event7';
s.eVar7 = 'Wait List';
if ($.trim(globalOptin) == 'true') {
s.eVar10 = 'Global opt-in';
} else {
s.eVar10 = 'Concept opt-in';
}
linkText = $(this).attr('value');
}
if ($(this).attr('id') == 'waitlistCancel') {
linkText = $('#waitlistCancel').text();
$(".inform-link #enterWaitList").prop('disabled', false);
}
s.linkType = 'lnk_o';
s.pageName = 'lh|us|en|WebAhead|Join Wait List';
s.eVar79 = $("#estimated_wait").val();
s.eVar75 = window.location.href;
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
var selectedPartySize = $('#partySize').val();
var defaultPartySize = $('#restDefaultPartySize').val();
if (selectedPartySize == null || selectedPartySize == "" || selectedPartySize == undefined) {
document.getElementById("partySize").value = defaultPartySize;
}
});
//2.wait list confirmation and edit guest confirmation
$(document).on("click", "#enterEmailWaitList,#enterSmsWaitList,#enterRMWaitList,#editWaitList,#directionsLink,#restNameLink,#mapLink", function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
var linkText;
s.events = 'event75';
if ($("#page_confirm").val() == 'editSuccess') {
s.pageName = 'lh|us|en|WebAhead|Edit Guests Confirmation';
linkText = $(this).attr('value');
} else {
s.pageName = 'lh|us|en|WebAhead|Wait List Confirmation';
linkText = $(this).attr('value');
}
if ($(this).attr('id') == 'directionsLink') {
linkText = $('#directionsLink').text();
}
if ($(this).attr('id') == 'restNameLink') {
linkText = $('#restNameLink').text();
}
if ($(this).attr('id') == 'mapLink') {
linkText = $('#mapLink').text();
}
s.eVar75 = window.location.href;
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
});
//3.emial and text conmfirmation
$(document).on("click", "#emailWaitList,#smsWaitList", function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
if ($(this).attr('id') == 'smsWaitList') {
s.pageName = 'lh|us|en|WebAhead|Send Via Text';
} else {
s.pageName = 'lh|us|en|WebAhead|Send Via Email';
}
s.eVar75 = window.location.href;
var linkText = $(this).attr('value');
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
});
//4.omniture starts for-location info- Wait List Details page button clicks
$(document).on("click", "#locText_webahead,#locEmail_webahead, #viewMenu_webahead,#orderbtn_webahead", function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
//s.pageName='lh|us|en|WebAhead|Wait List Details';
s.eVar75 = window.location.href;
var linkText;
linkText = $(this).attr('value');
if ($(this).attr('id') == 'locText_webahead') {
linkText = $('#locText_webahead').text();
}
if ($(this).attr('id') == 'locEmail_webahead') {
linkText = $('#locEmail_webahead').text();
}
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
});
//5.remove waitlist confirm page-buttons click
$(document).on("click", "#waitlistFindAnotherLoc,#waitlistToGoOrder", function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
s.pageName = 'lh|us|en|WebAhead|Wait List Removal';
s.eVar75 = window.location.href;
var linkText = $(this).attr('value');
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
});
//6.edit NO.of guets page
$(document).on("click", "#EditWaitlistConfirmation,#joinWaitListModal_overlayCloseButton_custom5", function () {
clearOmnitureVars();
var party = $('.holder').text();
var linkText;
if ($(this).attr('id') == 'EditWaitlistConfirmation') {
s.linkTrackVars = 'events,eVar75,eVar70,prop49,prop55';
s.prop55 = party;
linkText = $(this).attr('value');
}
if ($(this).attr('id') == 'joinWaitListModal_overlayCloseButton_custom5') {
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
linkText = $(this).text();
}
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
s.pageName = 'lh|us|en|WebAhead|Edit Guests';
s.eVar75 = window.location.href;
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
if (linkText == 'Cancel' || linkText == 'UPDATE')
s.tl($(this), 'o', linkname);
});
//7.switch location button click from location details page
$(document).on("click", "#enterSwitchLoc", function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49,prop55';
s.linkTrackEvents = 'event75,event97';
s.linkType = 'lnk_o';
s.events = 'event75,event97';
//s.pageName='lh|us|en|WebAhead';
s.eVar75 = window.location.href;
s.prop55 = $("#estimated_wait").val();
var linkText = $("#enterSwitchLoc").text();
var linkname = s.eVar70 = s.prop49 = s.pageName + ' Location Details Page ' + linkText + ' link';
s.tl($(this), 'o', linkname);
});
//8.switch location page
$(document).on("click", "#RemoveWaitlistConfirmation,#CancelSwitch", function () {
if ($("#RemoveWaitlistConfirmation").attr('value') != 'OK') {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
s.pageName = 'lh|us|en|WebAhead|Switch Location';
s.eVar75 = window.location.href;
var linkText = $(this).attr('value');
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
}
});
//9.Location Overlay page
$(document).on("click", "#sms-current,#email-current,#popNutritionIconLink,#popDirLink,#overlayRestName,#omni_viewmenu_location_overlay,#omni_ordertogo_location_overlay", function () {
if ($('#omniture_page_name').val() == 'header-info') {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
s.pageName = 'lh|us|en|Location Details Overlay';
s.eVar75 = window.location.href;
var linkText = $(this).text();
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
}
});
$(document).on("click", "a[id*='directionsLink-']", function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar75,eVar70,prop49';
s.linkTrackEvents = 'event75';
s.linkType = 'lnk_o';
s.events = 'event75';
s.pageName = 'lh|us|en|Join Waitlist Overlay';
s.eVar75 = window.location.href;
var linkText = $(this).text();
var linkname = s.eVar70 = s.prop49 = s.pageName + '|' + linkText + ' link';
s.tl($(this), 'o', linkname);
});
//webahead omniture click events ends
/*webahead page load events starts here*/
$('#location-show-arrow ,#headRestName').click(function () {
clearOmnitureVars();
s.linkTrackVars = 'events,eVar79,eVar75,eVar1,prop1';
s.linkTrackEvents = 'event49';
s.events = 'event49';
s.eVar79 = $("#estimated_wait").val();
s.pageName = 'lh|us|en|Location Details Overlay';
s.eVar75 = window.location.href;
s.eVar1 = s.prop1 = 'WebAhead';
var linkname = s.pageName;
s.t($(this), 'o', linkname);
});
/*webahead page load events ends here*/
//omniture chnages ends
} //dtm flag end
//added by vara
function scrolloverlay_joinwaitlist(getID) {
getID.animate({
paddingTop: "0px"
}, function () {
var getscrolltop = parseInt($(window).scrollTop());
$(window).scrollTop(getscrolltop - 2000);
});
}
/*Fix: send via email and send via text overlay persist error message after closing it */
$(".close").click(function () {
$("label.error_msg").hide();
});
/*====================================== R4.2 Subscriptions ==============================================*/
/**
* Function to display transfer mobile optin based on the selection of phone type
*/
$('html body').on('change', '#phoneType', function () {
var phoneType = $('#phoneType').val();
if (phoneType == 'Mobile') {
$("#mobileOptInOptions").show();
} else {
$("#mobileOptInOptions").hide();
}
});
/**
* Function to enable/greyout text opt-in when phone type is changed
* to mobile and unchanged from mobile to others
*/
$('html body').on('change', '#phone_type_wid', function () {
var phoneType = $('#phone_type_wid').val();
if (phoneType != 'Mobile') {
$(".textAlerts").remove();
disableClicks('textAlerts', 'textAlerts');
$("#textoptin_checkbox_d").css("background-position", "0% 0px");
var chk = $("#textoptin_checkbox").is(":checked");
if (chk) {
$("#textoptin_checkbox").removeAttr("checked");
}
} else {
$(".textAlerts").remove();
}
});
/**
* Function to enable/greyout text opt-in when phone type others during page load
*/
if ($('#phone_type_wid').length) {
var phoneType = $('#phone_type_wid').val();
if (phoneType != 'Mobile') {
disableClicks('textAlerts', 'textAlerts');
}
}
/**
* Function to disable all clickable events under the div
*/
function disableClicks(el_id, clas) {
var el_id = '#' + el_id;
var con2Width = $(el_id).width();
var con2Height = $(el_id).height();
$(el_id).css("position", "relative");
$(el_id).append("