-
-
Save heyitsbryanm/b3afd430dcd4ca24b09bc75ec2b6b01a to your computer and use it in GitHub Desktop.
Line break in product title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> | |
<script> | |
String.prototype.replaceAll = function (target, replacement) { | |
return this.split(target).join(replacement); | |
}; | |
Ecwid.OnPageLoaded.add(function (page) { | |
var delimiter = ' | '; | |
switch (page.type) { | |
case 'PRODUCT': | |
var productName = $('div.ecwid-productBrowser-head')[0]; | |
if (productName) { | |
productName.innerHTML = productName.innerText.replaceAll(delimiter, '<br/>'); | |
$('.ecwid-productBrowser-relatedProducts .ecwid-productBrowser-price').css('bottom', '-5px !important'); | |
$('.ecwid-productBrowser-relatedProducts .ecwid-productBrowser-productNameLink').each(function () { | |
var currstr = $(this).text(); | |
var regex = currstr.replace(/\<br\>/g, ""); | |
$(this).html(regex); | |
$(this).css({ | |
"text-align": "center" | |
}); | |
}); | |
} | |
break; | |
case 'CATEGORY': | |
var productNames = $('div.ecwid-productBrowser-productNameLink'); | |
for (var i = 0; i < productNames.length; i++) { | |
productNames[i].getElementsByTagName('a')[0].innerHTML = productNames[i].innerText.replaceAll(delimiter, '<br/>'); | |
} | |
window.setTimeout(function () { | |
var subcategoryNames = $('.ecwid-productBrowser-subcategories-categoryName'); | |
for (var i = 0; i < subcategoryNames.length; i++) { | |
subcategoryNames[i].getElementsByTagName('span')[0].innerHTML = subcategoryNames[i].innerText.replaceAll(delimiter, '<br/>'); | |
} | |
}, 1); | |
break; | |
case 'SEARCH': | |
var productNames = $('div.ecwid-productBrowser-productNameLink'); | |
for (var i = 0; i < productNames.length; i++) { | |
productNames[i].getElementsByTagName('a')[0].innerHTML = productNames[i].innerText.replaceAll(delimiter, '<br/>'); | |
} | |
window.setTimeout(function () { | |
var subcategoryNames = $('.ecwid-productBrowser-subcategories-categoryName'); | |
for (var i = 0; i < subcategoryNames.length; i++) { | |
subcategoryNames[i].getElementsByTagName('span')[0].innerHTML = subcategoryNames[i].innerText.replaceAll(delimiter, '<br/>'); | |
} | |
}, 1); | |
break; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment