(function(){
var tomitProductTagger = {
productsAdded: [],
blogProducts : "",
jQuery : "",
modalTemplate : '
',
getProductGridItem : function(product){
var Current = product.price.split(" ");
if(parseInt(product.oldPrice) > parseInt(Current[1]) && !isNaN(product.oldPrice)){
product.price = product.price.replace(".", ",")
if(product.oldPrice != null){
product.oldPrice = product.oldPrice.replace(".", ",")
}
return ' \
\
\
R$'+product.oldPrice+' '+product.price+'
\
';
}else{
product.price = product.price.replace(".", ",")
return ' \
\
\
'+ product.price +'
\
';
}
},
addCss : function(filename) {
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('link');
style.href = filename;
style.type = 'text/css';
style.rel = 'stylesheet';
head.append(style);
},
addCustomCss : function(styles){
var styleSheet = document.createElement("style")
styleSheet.type = "text/css"
styleSheet.innerText = styles
document.head.appendChild(styleSheet)
},
init : function($){
var res = window.location.href.split("/");
if(res.length < 6 && (window.location.href.indexOf('products') <= 0)){
console.log("skip");
return false;
}
tomitProductTagger.addCss('https://blogproducts.checkmyapp.net/limelight.css');
var css = ".TomITProductPopup, .TomITproductGridItem{font-family:Poppins, sans-serif;color:#333;font-weight:600}.TomITProductPopup img{padding:8px}.TomITProductPopup{box-shadow:0 0 4px 1px rgb(0 0 0 / 15%);border-radius:5px;padding:8px!important}.TomITproductGridItem{text-align:left}.TomITProductImage{height:100%}.TomITProductTitle{text-transform:lowercase;font-size:20px;line-height:1}#TomITProductTitle{text-transform:lowercase;font-size:20px;line-height:1;font-weight:700}#TomITProductTitle a:hover, #TomITProductDescription a:hover{color:#8a5eff}#TomITProductPrice, .TomITProductPrice{font-size:18px;margin:8px 0;font-weight:700;line-height:1.2;font-family:Poppins, sans-serif;font-style:normal;letter-spacing:0!important}#TomITProductDescription{color:#333!important;font-size:14px!important;font-family:Lato, sans-serif!important;line-height:150%!important;font-weight:400!important}.TomITproductGridItem .TomITProductTitle{min-height:50px!important}@media (max-width:599px){.TomITproductGridItem .TomITProductTitle{min-height:30px!important}}";
tomitProductTagger.addCustomCss(css);
$('body').append(this.modalTemplate);
this.jQuery = $;
var tomitProductIds = [];
var tomitCollectionIds = [];
$('a[data-tomit-product-id]').each(function(r){
tomitProductIds.push($(this).data('tomit-product-id'));
});
tomitProductIds = [... new Set(tomitProductIds)];
$('a[data-tomit-collection-id]').each(function(r){
tomitCollectionIds.push($(this).data('tomit-collection-id'));
});
tomitCollectionIds = [... new Set(tomitCollectionIds)];
var url = 'https://blogproducts.checkmyapp.net/products/sallvestore.myshopify.com/' + JSON.stringify(tomitProductIds) + '/' + JSON.stringify(tomitCollectionIds);
tomitProductTagger.loadJson(url).then(function(res){
tomitProductTagger.blogProducts = res;
tomitProductTagger.addToProductLinks();
});
},
loadJson : (url) => new Promise((resolve, reject) =>{
var e = url,
r = new XMLHttpRequest;
r.open("GET", e, !0), r.onload = function ()
{
if (200 === r.status)
{
var t = JSON.parse(r.responseText);
resolve(t)
}
else reject("error")
}, r.send()
}),
searchProduct : function(nameKey, myArray){
for (var i=0; i < myArray.products.length; i++) {
if(typeof(myArray.products[i].product) == 'undefined'){
continue;
}
if (nameKey == myArray.products[i].product.id) {
return myArray.products[i].product;
}
}
},
searchCollection : function(nameKey, myArray){
for (var i=0; i < myArray.collections.length; i++) {
if (nameKey == myArray.collections[i].collection.id) {
return myArray.collections[i].collection;
}
}
},
showProductPopup :function (link, e){
a = this;
var linkPos = a.jQuery(link).offset();
var currProdId = a.jQuery(link).data('tomit-product-id');
var neededPopup;
if(typeof currProdId != 'undefined') {
neededPopup = a.jQuery('body .TomITProductPopup[data-tomit-product-id="'+currProdId+'"]');
}else{
neededPopup = a.jQuery('body .TomITProductPopup[data-tomit-collection-id="'+a.jQuery(link).data('tomit-collection-id')+'"]');
}
neededPopup.css("visibility","visible");
neededPopup.css('z-index','10001');
if (a.jQuery(window).width() < 960) {
neededPopup.css("position","fixed");
neededPopup.offset({bottom:-210, left:90});
neededPopup.animate({bottom:0}, 500);
}else{
neededPopup.offset({left:linkPos.left-((neededPopup.width() /2 - a.jQuery(link).width() /2)),top:linkPos.top+20});
neededPopup.css("visibility","visible");
}
},
hideProductPopup : function (link) {
a = this;
var linkPos = a.jQuery(link).offset();
var currProdId = a.jQuery(link).data('tomit-product-id');
var neededPopup;
if(typeof currProdId != 'undefined') {
neededPopup = a.jQuery('body .TomITProductPopup[data-tomit-product-id="'+currProdId+'"]');
}else{
neededPopup = a.jQuery('body .TomITProductPopup[data-tomit-collection-id="'+a.jQuery(link).data('tomit-collection-id')+'"]');
}
if (a.jQuery(window).width() > 960) {
neededPopup.css('visibility','hidden');
neededPopup.offset({left:0,top:0});
neededPopup.css('z-index','0');
}else{
neededPopup.animate({bottom:-210}, 500, function(){
neededPopup.css('visibility','hidden');
neededPopup.css('z-index','0');
});
}
},
addClickHandler : function(link){
var main = this;
main.jQuery(link).click(function(e){
return true;
});
},
addStat(prodId, type) {
a = this;
a.jQuery.get('https://blogproducts.checkmyapp.net/stat/sallvestore.myshopify.com/'+prodId+'/' + type);
},
addToCart(prod) {
//stats/{customerId}/{productId}/{eventType}
//main.jQuery.get('url naar mijn server/stats/customerid/prodId/atc');
var main = this;
//Add to cart
main.jQuery.post('/cart/add.js', prod).always(function(e){
main.jQuery('.tomItAddedToCart').remove();
main.jQuery('#TomITProductLink').append('');
});
},
isMobile : function(e) {
var isMobile = false; //initiate as false
// device detection
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) {
isMobile = true;
}
return isMobile;
},
addHoverHandler : function(link){
var a = this;
a.jQuery(link).hover(function(e){
a.showProductPopup(this, e);
}, function(e){
a.hideProductPopup(this);
});
a.jQuery(link).on('touchstart', function(e){
a.showProductPopup(this, e);
});
a.jQuery(link).on('touchend', function(e){
a.hideProductPopup(this);
});
},
addToProductLinks : function() {
var a = this;
prods = [];
a.jQuery('a[data-tomit-collection-id]').each(function(e){
var collectionId = a.jQuery(this).data('tomit-collection-id');
var res = a.searchCollection(collectionId, a.blogProducts);
if(res) {
imageTag = "";
if(typeof(res.image) != undefined && res.image != null) {
imageTag = '';
}
a.jQuery('body').append('');
a.addHoverHandler(this);
}
});
a.productsAdded = [];
a.jQuery('a[data-tomit-product-id]').each(function(e){
var prodId = a.jQuery(this).data('tomit-product-id');
var res = a.searchProduct(prodId, a.blogProducts);
if(res) {
if(a.productsAdded.indexOf(prodId) == -1){
a.productsAdded.push(prodId);
price = String(parseFloat(res.variants[0].price).toFixed(2));
oldPrice = String(parseFloat(res.variants[0].oldPrice).toFixed(2));
imageTag = "";
if(typeof(res.images) != undefined && res.images != null) {
imageTag = '';
}
var prodTitle = res.title;
if(res.available == false) {
prodTitle = "(product not available)
" + res.title;
}
if(parseInt(oldPrice) > parseInt(price) && !isNaN(oldPrice)){
oldPrice = oldPrice.replace(".", ",");
price = price.replace(".", ",");
a.jQuery('body').append('');
}else{
price = price.replace(".", ",");
a.jQuery('body').append('');
}
var prod = {};
prod.title = res.title;
prod.handle = res.handle;
prod.image = res.images != null ? res.images[0] : '';
prod.price = "R$ " +res.variants[0].price;
prod.oldPrice = res.variants[0].oldPrice;
prods.push(a.jQuery(a.getProductGridItem(prod)));
par = a.jQuery(this).parent();
}
a.addClickHandler(this);
a.addHoverHandler(this);
}
});
var ul = a.jQuery('');
var div = a.jQuery('quer mais como estes?
');
ul.append(prods);
div.append(ul);
div.append('
');
ListHolder = document.getElementById('BlogProductsProductListHolder');
if(ListHolder != null ){
a.jQuery('#BlogProductsProductListHolder').append(div);
}
else{
a.jQuery('a[data-tomit-product-id]').first().closest('div').parent().append(div);
}
}
}
var loadScript = function(url, callback){
var script = document.createElement("script");
script.type = "text/javascript";
// If the browser is Internet Explorer.
if (script.readyState){
script.onreadystatechange = function(){
if (script.readyState == "loaded" || script.readyState == "complete"){
script.onreadystatechange = null;
callback();
}
};
// For any other browser.
} else {
script.onload = function(){
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
};
if ((typeof jQuery === 'undefined') || (parseFloat(jQuery.fn.jquery) < 1.9)) {
loadScript('//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js', function(){
jQuery331 = jQuery.noConflict(true);
tomitProductTagger.init(jQuery331);
});
} else {
tomitProductTagger.init(jQuery);
}
var css = `
@media only screen and (max-width: 600px) {
.tomit_quantity_atc{
width: 100%!important;
margin-bottom: 3px;
}
.tomit_add_to_cart{
width: 100%!important;
margin-bottom: 3px;
}
}
`,
head = document.head || document.getElementsByTagName('head')[0];
if(!document.getElementById('product-tagger-information-modal-style')) {
var style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
style.id = 'product-tagger-information-modal-style';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
})();