// Script required for targeters to function
$(function () {
try {
/* Targeter invoking function */
function invokeTargeters() {
/* DO NOT REMOVE CODE TO PROVIDE DETAILS ABOUT TARGETER TO AB TESTING BY JAYDEEP START */
var targetWithDataArray = [];
/* DO NOT REMOVE CODE TO PROVIDE DETAILS ABOUT TARGETER TO AB TESTING BY JAYDEEP END */
$('form[name^="execute-ajax-targeter-form"]').each(function () {
var $form = $(this);
var formId = $form.attr('id');
var containerId = $form.find('input[name="containerId"]').val();
if (formId && $("#" + containerId) && $("#" + containerId).length) {
targetWithDataArray.push(formId + ":#:" + containerId);
}
});
/* DO NOT REMOVE CODE TO PROVIDE DETAILS ABOUT TARGETER TO AB TESTING BY JAYDEEP START */
var length = 0;
if (targetWithDataArray && targetWithDataArray.length > 0) {
length = targetWithDataArray.length;
var isLastIndex = false;
for (var index = 0; index < targetWithDataArray.length; index++) {
if (length - 1 === index) {
isLastIndex = true;
}
if (targetWithDataArray[index]) {
var formAndContIds = targetWithDataArray[index].split(":#:", 2);
if (formAndContIds && formAndContIds.length === 2) {
fetchTargetedContent(formAndContIds[0], formAndContIds[1], isLastIndex);
}
}
}
}
/* DO NOT REMOVE CODE TO PROVIDE DETAILS ABOUT TARGETER TO AB TESTING BY JAYDEEP END */
}
/** R4.2 Changes Start**/
function fetchTargetedContent(formid, divid) {
var $form = $('#' + formid);
var url = $form.attr('action');
if ($("#" + divid).length) {
var formpost = $.post(url, $form.serialize());
formpost.done(function (responseContent) {
$("#" + divid).html(responseContent);
$("#" + divid).find("script").each(function (i) {
eval($(this).text);
});
});
}
}
/** R4.2 Changes End**/
function fetchTargetedContent(formid, divid, isLastIndex) {
var targetStatus = "";
var $form = $('#' + formid);
var url = $form.attr('action');
$.each($form.serialize().split('&'), function (index, elem) {
var vals = elem.split('=');
if (vals[1] != null && vals[1].length > 0) {
url = url + "&" + vals[0] + "=" + vals[1];
}
});
if ($("#" + divid).length) {
$.get(url, function () {
})
.done(function (responseContent) {
$("#" + divid).html(responseContent);
$("#" + divid).find("script").each(function (i) {
eval($(this).text);
});
targetStatus = "success";
})
.fail(function () {
targetStatus = "failed";
})
.always(function () {
if (window.sessionStorage) {
if (targetStatus === 'success') {
if (sessionStorage.divid) {
sessionStorage.divid = sessionStorage.divid + ";" + divid;
} else {
sessionStorage.setItem("divid", divid);
}
} else if (targetStatus === 'failed') {
if (sessionStorage.fdivid) {
sessionStorage.divid = sessionStorage.fdivid + "-" + divid;
} else {
sessionStorage.setItem("fdivid", divid);
}
}
}
});
}
}
invokeTargeters();
} catch (exception) {
console.log(exception.message);
}
});
var pathname = document.location.pathname ? document.location.pathname : window.location.pathname;
$(window).on('load', function () {
if (window.location.search.indexOf('waitlist=true') != -1 && $("#channel").val() != 'MOBILE') {
$('#enterWaitList').click();
}
});
function detectIeVersion() {
var uaString = null;
uaString = uaString || navigator.userAgent;
var match = /\b(MSIE |Trident.*?rv:|Edge\/)(\d+)/.exec(uaString);
if (match) return parseInt(match[2]);
}
$(document).ready(function () {
if (detectIeVersion() === 11) {
document.body.classList.add('ie-' + detectIeVersion());
} else if (detectIeVersion() > 11) {
document.body.classList.add('ie-edge');
}
});
// dedect IE - end
// debounce start
function debounce(fn, wait) {
var timeout;
return function () {
clearTimeout(timeout);
timeout = setTimeout(function () {
fn.apply(this, arguments), (wait || 1)
});
};
}
//debounce end
// validation - start
var Validation = function () {
this.validateRequired = function (field) {
var fieldValue = $(field).val();
if (!fieldValue) {
return false;
}
return true;
};
this.setRequiredMessages = function (field) {
var fieldParent = $(field).parent();
var requiredMessageContainer = fieldParent.find('.is-required');
var validationMessage = $(field).closest('.form-with-validation').find('.form-validation-failed');
var label = $(field).siblings('.lh-label').html();
if (this.validateRequired) {
requiredMessageContainer.removeClass('hidden');
$(field).addClass('is-invalid');
validationMessage.removeClass('hidden');
validationMessage.find('.is-required-list-title').removeClass('hidden');
validationMessage.find('.is-required-list').removeClass('hidden');
if (validationMessage.find('.validation-list-item-' + label + '').length <= 0) {
validationMessage.find('.is-required-list').append('
' + label + '');
}
} else {
requiredMessageContainer.addClass('hidden');
$(field).removeClass('is-invalid');
validationMessage.addClass('hidden');
validationMessage.find('.validation-list-item-' + label + '').remove();
if (!$.trim($(validationMessage.find('.is-required-list')).html())) {
validationMessage.find('.is-required-list-title').addClass('hidden');
validationMessage.find('.is-required-list').addClass('hidden');
}
}
};
this.validateEmail = function (field) {
var emailRegex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var fieldValue = $(field).val();
if (fieldValue) {
if (emailRegex.test(fieldValue)) {
return true;
}
}
return false;
};
this.setEmailMessages = function (field) {
var fieldParent = $(field).parent();
var requiredMessageContainer = fieldParent.find('.wrong-format');
var validationMessage = $(field).closest('.form-with-validation').find('.form-validation-failed');
var label = $(field).siblings('.lh-label').html();
if (this.validateEmail) {
requiredMessageContainer.removeClass('hidden');
$(field).addClass('is-invalid');
validationMessage.removeClass('hidden');
validationMessage.find('.wrong-format-list-title').removeClass('hidden');
validationMessage.find('.wrong-format-list').removeClass('hidden');
if (validationMessage.find('.validation-list-item-' + label + '').length <= 0) {
validationMessage.find('.wrong-format-list').append('' + label + '');
}
} else {
requiredMessageContainer.addClass('hidden');
$(field).removeClass('is-invalid');
validationMessage.addClass('hidden');
validationMessage.find('.validation-list-item-' + label + '').remove();
if (!$.trim($(validationMessage.find('.wrong-format-list')).html())) {
validationMessage.find('.wrong-format-list-title').addClass('hidden');
validationMessage.find('.wrong-format-list').addClass('hidden');
}
}
};
this.clearValidation = function (form) {
var validationMessage = $(form).find('.form-validation-failed');
var classList = ['.wrong-format', '.wrong-format-list-title', '.wrong-format-list', '.is-required', '.is-required-list-title', '.is-required-list'];
$(form).find('.form-control').removeClass('is-invalid');
for (var i = 0; i < classList.length; i++) {
$(form).find(classList[i]).addClass('hidden');
}
validationMessage.addClass('hidden');
validationMessage.find('.is-required-list, .wrong-format-list').empty();
};
};
var validate = new Validation();
// validation - end
// header - start
var Header = function () {
this.init = function () {
var that = this;
$(document).ready(function () {
that.setSelectedLocation();
that.updateMainNavWaitListLink();
that.updateSelectedLocationDetails();
that.updateLoginAndShoppingBagStatus();
that.showLocationIfSelected();
that.hamburgerToggle();
that.mobileLocationTrigger();
that.cartEmptyToggle();
that.waitListClose();
that.updateLocationWaitListStatus();
// if ($('.hamburger-button').hasClass('hide-on-tablet')) {
// $('.hamburger-button').addClass('trackContent');
// $('.hamburger-button').attr('data-link-info', 'hamburger|close menu');
// }
});
};
this.setSelectedLocation = function () {
//Check if url contains restaurant parameter to change location - start
var restFromUrl = getUrlParameter("setRestaurant");
if (restFromUrl != undefined && restFromUrl != '') {
$.cookie("DRIRESTAURANTID", restFromUrl);
}
//Check if url contains restaurant parameter to change location - end
if ($("#isLocationDetails").val()) {
var newRestID = $("#restID").val();
var driRestCookie = decodeURIComponent($.cookie("DRIREST"));
var existingRestID;
if (driRestCookie) {
var driRestCookieValues = driRestCookie.split("@@");
existingRestID = driRestCookieValues[0];
}
if (!existingRestID || newRestID != existingRestID) {
var reqBody = {
"restaurantId": newRestID
};
$.ajax({
url: '/web-api/restaurant/update',
data: reqBody,
type: "POST"
}).done(function (response) {
if (response.successResponse) {
sessionStorage.setItem("restID", newRestID);
var header = new Header();
header.updateSelectedLocationDetails();
header.showLocationIfSelected();
}
});
}
}
};
this.updateSelectedLocationDetails = function () {
var locationCookie = decodeURIComponent($.cookie("DRIREST"));
if (locationCookie) {
var locValues = locationCookie.split("@@");
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();
locURL = locURL.replace(/-{2,}/g, '-');
var protocol = $('#protocol').val() ? $('#protocol').val() : 'https:';
var mapImg = protocol + "//media.longhornsteakhouse.com/images/site/lh_front.jpg";
var locDynImg = $('#locDynImg').val();
$("#mapImg").attr("src", locDynImg ? locDynImg : mapImg);
$("#mapImgStatic").attr("src", mapImg);
if ($("#mapImgDyn").attr('src') == '') {
$("#mapImgDyn").attr("src", locDynImg ? locDynImg : mapImg);
}
// add links to location details
$('#header-location-link').attr("href", locURL);
$('#mobile-location-link').attr("href", locURL);
$('#popRestNameLink').attr("href", locURL);
$('#popMapLink').attr("href", locURL);
// rest name
$('#header-location-name').text(locValues[1]);
$('#mobile-location-name').text(locValues[1]);
$('#mobileOverlayRestName').text(locValues[1]);
$('#overlayRestName').text(locValues[1]);
// rest phone number
$('#header-location-number').text(locValues[7]);
$('#mobile-location-number').text(locValues[7]);
$('#headRestPhone').text(locValues[7]);
$('#popRestPhone').text(locValues[7]);
// rest address
$('#mobile-location-address-streetname').text(locValues[3]);
$('#mobile-location-address-city').text(locValues[4]);
$('#mobile-location-address-state').text(locValues[5]);
$('#mobile-location-address-zip').text(locValues[6]);
$('#popRestAdd1').text(locValues[3]);
$('#popRestZip').text(locValues[6]);
// rest Op hours
$('#mobile-location-hours').html(locValues[8]);
// rest name
$("#pdRestId").val(locValues[0]);
}
}
};
this.updateLoginAndShoppingBagStatus = function () {
if (typeof locationPageDynamicValues !== 'function') {
var locale = $('#currentLocale').length ? $('#currentLocale').val() : "";
var data = {};
var request = $.ajax({
url: "/web-api/session/details?locale=" + locale + "&fromPage=" + location.pathname,
type: "GET",
cache: false,
data: data,
ContentType: "application/json"
});
request.done(function (response) {
// This function updates responsive-contentupdate template header profile and cart item based on session context.
if (typeof updateResponsiveHeaderProfileAndCart === 'function') {
updateResponsiveHeaderProfileAndCart(response);
}
if (typeof globalBannerMessage === 'function') {
globalBannerMessage(response);
}
});
}
};
this.updateLocationWaitListStatus = function () {
if ($("#isLocationDetails").val()) {
var restID = $("#restID").val();
var request = $.ajax({
url: "/ajax/togo-location-webahead-info.jsp?restIDs=" + restID,
type: "GET",
cache: false
});
request.done(function (response) {
if ($("#locationWaitlistDetails").length > 0) {
var location_wait_list_details = $("#locationWaitlistDetails");
location_wait_list_details.html($(response).find('#location-webahead-info-reload-' + restID + ':first').html());
}
});
}
};
this.showLocationIfSelected = function () {
if ($.cookie('DRIREST')) {
// desktop location
$('#no-location-selected').hide();
$('#selected-location').show();
// mobile location
$('#mobile-no-location-selected').hide();
$('#mobile-selected-location').show();
}
};
this.updateMainNavWaitListLink = function () {
if ($("#main-nav-join-wait-list-link").length > 0) {
$("#main-nav-join-wait-list-link").html(getMainNavJoinWaitLink());
$("#main-nav-join-wait-list-link").show();
}
if ($("#joinWaitlist").length > 0) {
$("#joinWaitlist").html(getMainNavMobileJoinWaitLink());
$("#joinWaitlist").show();
}
};
this.mobileLocationTrigger = function () {
$('#mobile-location-link-trigger').on('click', function () {
if ($('.mobile-nav-slider-wrapper').hasClass('is-open')) {
$('.hamburger-button').click();
$('.mobile-nav-slider-wrapper').removeClass('is-open');
}
if (!$('#cart-empty-popup').hasClass('hidden')) {
$('#cart-location-trigger').click();
$('#cart-empty-popup').addClass('hidden');
}
$('#mobile-location-information').toggleClass('is-open');
$('#mobile-location-link-trigger-icon').attr('src', '//media.longhornsteakhouse.com/images/site/responsive/global/close-icon.svg');
$('#mobile-location-link-trigger.slider-open #mobile-location-link-trigger-icon').attr('src', '//media.longhornsteakhouse.com/images/site/responsive/global/map-location-pin.svg')
$('#mobile-location-information').attr('aria-hidden') === 'true' ? $('.mobile-location-information').attr('aria-hidden', false) : $('.mobile-location-information').attr('aria-hidden', true);
$('.mobile-location-name').attr('tabindex', 0);
$(this).attr('aria-expanded') === 'true' ? $(this).attr('aria-expanded', false) : $(this).attr('aria-expanded', true);
$(this).toggleClass('slider-open');
});
};
this.hamburgerToggle = function () {
$('.hamburger-button, .mobile-nav-link').on('click', function () {
if ($(this).attr('href') == '/menu-listing') {
sessionStorage.setItem('orderOnlineflow', 'true');
}
if ($('#mobile-location-information').hasClass('is-open')) {
$('#mobile-location-link-trigger').click();
}
if (!$('#cart-empty-popup').hasClass('hidden')) {
$('#cart-location-trigger').click();
$('#cart-empty-popup').addClass('hidden');
}
//PBI73086 - Fixed for misaligned hamburger slider when global-alert is present
if ($('#global-alert').length) {
var $headerHeight = $('header').outerHeight();
$(' header .mobile-nav-slider-wrapper').css("top", $headerHeight + "px");
$('.hamburger-button').on('click', function () {
$('header .mobile-nav-slider-wrapper.is-open').css("top", $headerHeight + "px");
});
};
$('.mobile-nav-slider-wrapper').toggleClass('is-open');
$('body').toggleClass('no-scroll');
$('.mobile-nav-slider-wrapper').attr('aria-hidden') === 'true' ? $('.mobile-nav-slider-wrapper').attr('aria-hidden', false) : $('.mobile-nav-slider-wrapper').attr('aria-hidden', true);
$(this).attr('aria-expanded') === 'true' ? $(this).attr('aria-expanded', false) : $(this).attr('aria-expanded', true);
$('.hamburger-button .hamburger ').toggleClass('slider-open');
if ($('.hamburger-button .hamburger').hasClass('slider-open')) {
$('.hamburger-button').attr('data-link-info', 'hamburger|open menu')
} else {
$('.hamburger-button').attr('data-link-info', 'hamburger|close menu')
}
});
};
this.cartEmptyToggle = function () {
$('#cart-location-trigger').on('click', function () {
if ($('#mobile-location-information').hasClass('is-open')) {
$('#mobile-location-link-trigger').click();
}
if ($('.mobile-nav-slider-wrapper').hasClass('is-open')) {
$('.hamburger-button').click();
$('.mobile-nav-slider-wrapper').removeClass('is-open');
}
if ($('#cart-location-trigger').hasClass('cart-has-fooditem')) {
if ($("#channel").val() !== 'MOBILE') {
$('#drawer-panel.drawer-panel').removeClass("ipadFix")
ipadRotate();
}
return true;
} else if ($('#cart-location-trigger').hasClass('cart-has-giftcarditem')) {
return true;
} else {
$('#cart-empty-popup').toggleClass('hidden');
$('#cart-empty-popup').attr('aria-hidden') === 'true' ? $('#cart-empty-popup').attr('aria-hidden', false) : $('#cart-empty-popup').attr('aria-hidden', true);
$(this).attr('aria-expanded') === 'true' ? $(this).attr('aria-expanded', false) : $(this).attr('aria-expanded', true);
}
});
$('#close-cart-empty-popup').on('click', function () {
$('#cart-empty-popup').addClass('hidden');
$('#cart-empty-popup').attr('aria-hidden') === 'true' ? $('#cart-empty-popup').attr('aria-hidden', false) : $('#cart-empty-popup').attr('aria-hidden', true);
$('#cart-location-trigger').attr('aria-expanded') === 'true' ? $('#cart-location-trigger').attr('aria-expanded', false) : $('#cart-location-trigger').attr('aria-expanded', true);
});
};
this.waitListClose = function () {
$('#enterWaitList').on('click', function () {
setTimeout(function () {
$('#joinWaitListModal_overlayCloseButton_custom1, #waitlistCancel').on('click', function () {
$('#joinWaitListModal.modal').removeClass('in').css('display', 'none');
$('body').removeClass('modal-open');
$('modal-backdrop').removeClass('show in');
});
}, 500);
});
};
};
var header = new Header();
header.init();
// header - end
// footer - start
var Footer = function () {
this.init = function () {
this.footerSticky();
};
this.footerSticky = function () {
$(document).ready(function () {
$(window).scroll(function () {
if ($(window).scrollTop() + $(window).height() > $('#footer').offset().top) {
$('#order-bar-wrapper').removeClass('fixed-order-bar');
} else {
$('#order-bar-wrapper').addClass('fixed-order-bar');
}
});
});
};
};
var footer = new Footer();
footer.init();
// footer - end
// independant utility methods - start
/** Provides a link to join wait list if location selected **/
function getMainNavJoinWaitLink() {
if ($.cookie('DRIREST')) {
return ' Waitlist';
} else {
return ' Waitlist';
}
}
function getMainNavMobileJoinWaitLink() {
if ($.cookie('DRIREST')) {
return ' Waitlist';
} else {
return ' Waitlist';
}
}
function globalBannerMessage(response) {
if (response.successResponse.globalBannerMessage) {
if (response.successResponse.globalBannerMessage !== '') {
var message = response.successResponse.globalBannerMessage;
$("#global-alert").show();
$("#globalMessage").text(message);
}
}
}
function updateResponsiveHeaderProfileAndCart(response) {
// update login links with logout link
if (localStorage.getItem("msal.e28d1063-2be2-4834-956a-affdf495336e.active-account") || localStorage.getItem("msal.95629395-7d9f-4b5e-97e8-57b5dd310444.active-account") || response.successResponse.profile && !response.successResponse.profile.transient) {
var logOutLink = 'My AccountLog Out';
var logOutLinkMobile = 'MY ACCOUNTLOG OUT';
$("#header-login-link").html(logOutLink);
$("#responsiveLoginLink").html(logOutLink);
$("#header-mobile-login-link").html(logOutLinkMobile);
$("#responsiveMobileLoginLink").html(logOutLinkMobile);
}
if (response.successResponse.webaheadEnabled) {
if (response.successResponse.webaheadEnabled === true) {
$("#main-nav-join-wait-list-link").show();
$("#joinWaitlist").show();
}
if (response.successResponse.webaheadEnabled === false) {
$("#main-nav-join-wait-list-link").hide();
$("#joinWaitlist").hide();
}
}
if (response.successResponse.restaurantDetails) {
if (response.successResponse.restaurantDetails.isLocationWaitListOn === true) {
$("#main-nav-join-wait-list-link").show();
$("#joinWaitlist").show();
}
if (response.successResponse.restaurantDetails.isLocationWaitListOn === false) {
$("#main-nav-join-wait-list-link").hide();
$("#joinWaitlist").hide();
}
}
if (!response.successResponse.webaheadEnabled || !response.successResponse.restaurantDetails) {
$("#main-nav-join-wait-list-link").show();
$("#joinWaitlist").show();
}
if (response.successResponse.sessionContext) {
var viewwaitlist1 = response.successResponse.sessionContext.webAheadInfo;
if (viewwaitlist1) {
var restCookieValue = decodeURIComponent($.cookie("DRIREST"));
var restID = restCookieValue.split('@@')[0];
var request = $.ajax({
url: "/ajax/togo-location-webahead-info.jsp?restIDs=" + restID,
type: "GET",
cache: false
});
request.done(function (response) {
$('#main-nav-join-wait-list-link').html($(response).find('a#viewWaitList'));
$('#main-nav-join-wait-list-link a#viewWaitList').addClass('desktop-nav-link');
$('a#viewWaitList').attr('href', '/wait-list/confirmation');
let details = navigator.userAgent;
let regexp = /android|iphone|kindle|ipad/i;
let isMobileDevice = regexp.test(details);
if (isMobileDevice) {
setTimeout(function () {
//Mobile
//For mobile
$('#joinWaitlist').html($(response).find('a#viewWaitList'));
$('#joinWaitlist a#viewWaitList').addClass('mobile-nav-link');
$('#joinWaitlist a#viewWaitList').attr('href', '/wait-list/confirmation');
}, 200);
}
$('#footerJWL').text("VIEW WAITLIST");
$('#footerJWL').attr('href', '/wait-list/confirmation');
$('#footerJWL').removeAttr("onclick");
$('#footerJWL').removeAttr("onkeypress");
});
}
var orderTypeValue = response.successResponse.sessionContext.orderTypeValue;
//var itemCount = response.successResponse.sessionContext.itemCount;
var itemCount = sessionStorage.getItem("REACT_CART_ITEM_COUNT");
if (orderTypeValue !== undefined && itemCount !== undefined && itemCount > 0) {
$(".cart-item-count").html(itemCount + 'items in cart');
if (itemCount > 9) $(".cart-item-count").addClass('double-digit');
$(".cart-item-count").show();
$("#cart-location-trigger").addClass(orderTypeValue === 1 ? 'cart-has-giftcarditem' : 'cart-has-fooditem');
$("#cart-location-trigger").attr("href", orderTypeValue === 1 ? '/purchase/gift-cards/gift-card-review' : '/menu-listing?opnSldr=true');
}
// });
}
}
// independant utility methods - end
/** Omniture Method for HamburgerMenu Items - START **/
function omnitureCallForHamburgerMenuItems(linkName, linkurl) {
var cartItemCount = $('#commerceCartCount').html();
if (linkName != undefined && linkName != '' && linkName.localeCompare("LOCATIONS/WAITLIST") == 0) {
redirectLocationWaitList();
} else if (linkName != undefined && linkName != '' && linkName.localeCompare("LUGARES/LISTA DE ESPERA") == 0) {
redirectESLocationWaitList();
} else if (linkurl == '/order-online' && cartItemCount && cartItemCount >= 1) {
window.location.href = "/menus";
} else {
window.location.href = linkurl;
}
}
function redirectLocationWaitList() {
var pageURL = window.location.origin;
var waitListUrl = "/wait-list";
var wlRestId = document.getElementById('pdRestId').value;
var webAheadFlag = "";
var waitListValidationURL = '/mobile/customer-service/includes/validateWebAheadRestaurant.jsp';
var request = $.ajax({
url: waitListValidationURL,
type: 'post',
data: "selectedRestId=" + wlRestId
});
request.done(function (response, textStatus, jqXHR) {
webAheadFlag = $.trim(response);
});
request.fail(function (jqXHR, textStatus, errorThrown) {
console.error("Unable to Validate Web Ahead for Restaurant :: The following error occurred: " + textStatus,
errorThrown);
});
if (wlRestId != undefined && wlRestId != '' && webAheadFlag != '' && webAheadFlag == 'true') {
var redirectUrl = pageURL + waitListUrl;
window.location = redirectUrl;
} else {
var locSearchUrl = "/locations/location-search";
window.location = pageURL + locSearchUrl;
}
}
/*WO682304 - My account overlay header changes*/
$(document).on('click', '#myacc-arrow', function () {
$('div#myAccountModal').toggle();
$('#myacc-arrow').toggleClass('detialArrow_up');
});
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];
}
}
}
$(document).on("click", "#find_near_me_button", function () {
if (latlong == undefined && locationDetectedAlreadyCookie == "YES") {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(onSuccessGeoLocation, showError, {
maximumAge: 60000
});
} else {
//$.holdReady(false);
// THE BROWSER DOES NOT SUPPORTS LOCATION DETECTION
// MAKE THE AJAX CALL TO THE CURRENT R1 - AJAX CALL (Location detection
// servlet)
// Display the detected restaurant in the header
//alert("Geolocation is not supported by this browser. Use latitude and Longitude from Akamai");
}
}
});
var browserCookie = $.cookie("DRIREST");
var locationDetectedAlreadyCookie = sessionStorage.getItem("DRILOCATIONDETECTEDCOOKIE");
if (!locationDetectedAlreadyCookie && !browserCookie) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(onSuccessGeoLocation, showError, {
maximumAge: 60000
});
}
}
function onSuccessGeoLocation(position) {
sessionStorage.removeItem("DRILOCATIONDETECTEDCOOKIE");
sessionStorage.setItem("DRILOCATIONDETECTEDCOOKIE", "YES");
var latLong = position.coords.latitude + "," + position.coords.longitude;
//var latLong = 29.47621000 + "," + -81.21322000;
sessionStorage.setItem('processGeoLocation', latLong);
processGeoLocation(latLong);
}
function processGeoLocation(latLong) {
autoDetectLocation(latLong);
if (latLong === undefined) {
if ($("#autoDetectedLatLong").length > 0) {
var latlong = $("#autoDetectedLatLong").val();
}
autoDetectLocation(latlong);
}
$("#joinWaitListButtonOnLoad").hide();
$("#waitlistlabelspanonLoad").hide();
$.holdReady(false);
}
function autoDetectLocation(latLong) {
var url = url;
if (window.location.protocol == "https:") {
url = "/DardenAjaxURLRedirectServlet";
} else {
//url = "/customer-service/includes/detectedMobileLocAjax.jsp"
url = $("#locDetectionUrl").val();
}
if ($.cookie("DRIREST")) {
var locationCookie = decodeURIComponent($.cookie("DRIREST"));
var locValues = locationCookie.split("@@");
if (locValues.length > 0) {
var rest = locValues[0];
}
}
var data = {
AJAX_FUNCTION: "detectedMobileLocAjax",
LAT_LONG: latLong,
CURR_DEFAULT_REST: rest
};
// var data = { AJAX_FUNCTION : "detectedMobileLocAjax" , LAT_LONG :
// "29.552549,-81.222639" , CURR_DEFAULT_REST : rest };
request = $.ajax({
url: url,
type: "post",
cache: false,
data: data
});
request.done(function (response, textStatus, jqXHR) {
header.updateSelectedLocationDetails();
window.location.reload(true);
});
}
function showError(error) {
$.holdReady(false);
// THE USER DENIED LOCATION DETECTION
switch (error.code) {
case error.PERMISSION_DENIED:
sessionStorage.setItem("DRILOCATIONDETECTEDCOOKIE", "NO");
processGeoLocation($("#autoDetectedLatLong").val());
//Commenting out this code so that location detection happens in secure pages
//sessionStorage.setItem("DRILOCATIONDETECTEDCOOKIE", "NO");
//alert("User denied the request for Geolocation. location detected");
// using akamai");
break;
case error.POSITION_UNAVAILABLE:
// alert("Location information is unavailable.");
break;
case error.TIMEOUT:
// alert("The request to get user location timed out.");
break;
case error.UNKNOWN_ERROR:
// alert("An unknown error occurred.");
break;
}
}