';
}
else {
html = '
';
}
}
if (li) {
html = '
' + html + ''
}
newContent += html;
});
root.html(newContent);
};
var setDataDefault = function() {
var $disclaimer__singles = $('.m_dotcom_footer article .disclaimer__single');
if($disclaimer__singles.length > 0) {
_.forEach($disclaimer__singles, function (single) {
if($(single).attr('data-default').length === 0) {
var html = $(single).html();
$(single).attr('data-default', html);
}
$(single).attr('disable-Shorten', false);
});
}
};
formatElement($footer_left, $footer_left_content);
formatElement($footer_disclaimer_p, $footer_disclaimer_p_content);
formatElement($footer_disclaimer_li, $footer_disclaimer_li_content, true);
setDataDefault();
};
var init = function() {
var $disclaimer = $('.disclaimer__row'),
$disclaimer_single = $('.m_dotcom_footer article .disclaimer__single'),
rowWidth = 0;
var formatDisclaimer = function ($item, resize, idx) {
var resize = resize || false,
idx = idx || 0;
if($item.attr('disable-Shorten') === "true")
return;
var strings = $item.text(),
htmlStrings = $item.attr('data-default').length > $item.html().length ? $item.attr('data-default') : $item.html(),
shortString = '',
charsWidth = -1,
stringLength = 0,
limitLength = $($disclaimer[idx]).length > 0 ? $($disclaimer[idx]).width() : $disclaimer.width();
if (strings.length > 0) {
var temp = $item.html();
$item.text('Abcd efgh ');
charsWidth = $item.width();
rowWidth = rowWidth || $disclaimer.width();
stringLength = Math.floor(((limitLength - charsWidth) / charsWidth)) * 10 + superscriptLength(htmlStrings) - 5;
var newLength = htmlStrings.indexOf('. ') + 1;
if(newLength === 0) {
$item.html(htmlStrings);
$item.attr('disable-Shorten', "true");
$item.siblings('.disclaimer__hide__single').hide();
$item.siblings('.disclaimer__show__single').hide();
return;
}
shortString = htmlStrings.slice(0, stringLength);
var lastSpace = shortString.lastIndexOf(' ');
shortString = shortString.slice(0, lastSpace) + '...';
var newString = htmlStrings.substr(0, newLength) + ' ';
if(resize) {
$item.attr('data-default', newString);
$item.html(temp);
}
else
$item.html(newString);
}
};
var superscriptLength = function (string) {
var len = 0,
sup = string.substring(0,50).split("
0) {
_.forEach($disclaimer_single, function (item, idx) {
if($(item).height() <= oneRowHeight) {
$(item).siblings('.disclaimer__hide__single').hide();
$(item).siblings('.disclaimer__show__single').hide();
}
else {
$(item).siblings('.disclaimer__hide__single').hide();
$(item).siblings('.disclaimer__show__single').show();
formatDisclaimer($(item), false, idx);
}
});
}
$('.disclaimer__show__single').on('click', function (e) {
e.preventDefault();
var $target = $(this).siblings('.disclaimer__single');
swapText($target);
$(this).hide();
$(this).siblings('.disclaimer__hide__single').show();
});
$('.disclaimer__hide__single').on('click', function (e) {
e.preventDefault();
var $target = $(this).siblings('.disclaimer__single');
swapText($target);
$(this).hide();
$(this).siblings('.disclaimer__show__single').show();
});
};
if(url.indexOf('/us/smartphones/es/') > -1) {
spanish = true;
}
if($footer_left_content.length > 0 || $footer_disclaimer_p_content.length > 0 || $footer_disclaimer_li_content.length > 0) {
prepare();
init();
}
} catch (e) {
console.log("shorten disclaimer feature error", e);
}
});
';
$(startFromDom).insertBefore('.s-snav-button');
} else {
$('.ma-floating-nav__utility-list').append('
From $'+totalPrice+' before trade-inӘ');
}
/*var kvText = 'From $'+ totalPrice +' with eligible trade-inᶿ or $' + monthlyPrice +'/mo for '+prdDeferredMonth+' months
⊕. Pre-order your Galaxy Z Fold3 5G and get $200 in Samsung Credit, up to $800 off with the highest online instant trade-in valuesβ and your first 12 months of Samsung Care+ on us.
Ω';
$('.highlights #kv-type2 .f_header-type1 .pricing').html(kvText);*/
}
var setnavTitle = function(title) {
$('.ma-floating-nav__headline-link').text(title);
};
if(getParameterByName('modelCode')) {
var sku = getParameterByName('modelCode');
window.COUNTRY_SHOP_URL = window.COUNTRY_SHOP_URL.split('?')[0]+ '?modelCode=' + getParameterByName('modelCode');
$('.s-snav-button').attr('href', $('.s-snav-button').attr('href').split('?')[0]+'?modelCode=' + getParameterByName('modelCode'));
if(window.Cookies('tppid')) {
// epp user
var requestData = {
referralUrl: document.referrer,
planId: window.Cookies('tppid'),
modelCodes: sku,
accessToken: window.Cookies('DR_SESSION_TOKEN')
};
var eppLink = '/us/shop/price.us';
$.ajax({
url: eppLink,
data: requestData,
type: 'POST',
dataType: 'json',
error: function() {
console.log('error loading /us/shop/price.us.');
}
}).success(function(succ){
var totalPriceEpp = succ[0].prdPromoPriceInf || succ[0].prdPriceInf
var totalPrice = (Number(totalPriceEpp.slice(1).replace(',', '')) - Number(succ[0].tradeDiscountPrice)).toFixed(2);
var monthlyPrice = (totalPrice / 36).toFixed(2);
var prdDeferredMonth = succ[0].prdDeferredMonth;
if(totalPrice && monthlyPrice && prdDeferredMonth && !isNaN(prdDeferredMonth)) {
setPrice(totalPrice, monthlyPrice, prdDeferredMonth);
}
});
// $.ajax({
// url: '/us/api/consumer/product-info/?tradeFlag=Y&modelCode=' + getParameterByName('modelCode'),
// type: 'POST',
// error: function() {
// console.log('error loading /us/api/consumer/product-info/');
// },
// success: function(productObj) {
// setnavTitle(productObj.info.productName);
// }
// });
} else {
$.ajax({
url: '/us/api/consumer/product-info/?tradeFlag=Y&modelCode=' + getParameterByName('modelCode'),
type: 'POST',
error: function() {
console.log('error loading /us/api/consumer/product-info/');
},
success: function(productObj) {
var totalPrice = productObj.info.samsungPrice;
var monthlyPrice = productObj.info.monthlyPrice;
var noOfMonths = parseInt(productObj.info.deferredMonth);
var buyUrl = productObj.info.haDeepLink;
if(totalPrice && monthlyPrice) {
setPrice(totalPrice, monthlyPrice, noOfMonths);
}
if(buyUrl) {
window.COUNTRY_SHOP_URL = buyUrl;
$('.s-snav-button, .order-button').attr('href', window.COUNTRY_SHOP_URL);
}
// setnavTitle(productObj.info.productName);
}
});
}
} else {
setPrice('949.99', '5.56', '36');
}
}
})