Registe-se e receba um desconto de 15%
| Newsletter
Início da primavera
Até 70% de desconto!
Acolhimento para a sua casa
Descubra Agora
$(document).ready(function() {
var f = $('#rugFinderForm'), fi = $('#facetsInput'), pMin = $('#priceMinInput'), pMax = $('#priceMaxInput'), pD = $('#priceDropdown'), b = f.find('button[type="submit"]'), v = { t: $('#typeInput'), clr: $('#colorInput'), sz: $('#sizeInput') }, d = { t: $('#typeDropdown'), clr: $('#colorDropdown'), sz: $('#sizeDropdown') }; let p = false;
function debounce(fn, w) { let t; return function(...a) { clearTimeout(t); t = setTimeout(() => fn.apply(this, a), w); }; }
const debouncedApiCall = debounce(apiCall, 300);
function fetchData(fcts) {
if (p) return; p = true;
$.ajax({
url: '/rest/finder/items', type: 'GET', dataType: 'json', data: { facets: fcts.join(','), categoryId: v.t.val() || null, priceMin: pMin.val() || null, priceMax: pMax.val() || null },
beforeSend: () => b.prop('disabled', true),
success: r => {
updDropdown(d.clr, sortFacets((r.facets[28] || {}).values || []), 'Selecionar cor');
updDropdown(d.sz, sortFacets((r.facets[29] || {}).values || []), 'Selecionar tamanho', true);
updItemCount(r.count || 0);
},
error: () => updItemCount(0),
complete: () => { b.prop('disabled', false); p = false; },
});
}
function sortFacets(f) { return f.sort((a, b) => a.id - b.id || a.name.localeCompare(b.name)); }
function updItemCount(c) { b.find('span').text(c > 0 ? c + ' Artigo encontrado' : 'Selecionar'); }
function updDropdown(dd, v, dt, sz) {
var m = dd.next('.dropdown-menu');
m.empty().append($(' ', { type: 'button', class: 'dropdown-item text-danger' }).text('Remover seleção').on('click', () => resetDropdown(dd, dt)));
$.each(v, (_, i) => {
m.append($(' ', { type: 'button', class: 'dropdown-item', 'data-value': i.id }).html(sz ? fmtSize(i.name) : i.name).on('click', () => sel(dd, i.id, i.name)));
if ([201, 205, 212, 220, 224].indexOf(i.id) >= 0) m.append('
');
});
}
function fmtSize(n) { return n.replace(/(\d+(\s?x\s?\d+)?\s?cm)/g, "$1 "); }
function resetDropdown(dd, dt) {
dd.attr('data-value', ''); dd.closest('.dropdown').find('input[type="hidden"]').val('');
pMin.val(''); pMax.val('');
debouncedApiCall();
}
function sel(dd, v, t) {
if (t === 'Remover seleção') {
t = {
priceDropdown: 'Selecionar preço',
colorDropdown: 'Selecionar cor',
sizeDropdown: 'Selecionar tamanho'
}[dd.attr('id')] || t;
}
if (dd.attr('data-value') !== String(v)) {
dd.text(t).attr('data-value', v);
dd.closest('.dropdown').find('input[type="hidden"]').val(v);
debouncedApiCall();
}
}
function apiCall() {
var fcts = [v.clr.val(), v.sz.val()].filter(x => x && x.trim());
fi.val(fcts.join(','));
fetchData(fcts);
}
f.on('submit', function(e) {
var p = new URLSearchParams();
if (pMin.val()?.trim()) p.append('priceMin', pMin.val());
if (pMax.val()?.trim()) p.append('priceMax', pMax.val());
if (fi.val()?.trim()) p.append('facets', fi.val());
p.append('categoryId', v.t.val() || '73');
f.attr('action', '/tapetes' + '?' + p.toString());
f.off('submit').submit();
});
$(document).on('click', '.price-dropdown .dropdown-item', function() {
var min = $(this).data('min'), max = $(this).data('max');
if (min === 0 && max === 0) { resetDropdown(pD, 'Selecionar preço'); return; }
if (pMin.length && pMax.length) { pMin.val(min); pMax.val(max); } else { console.error('Price range inputs missing.'); return; }
var lbl = max ? min + ' € - ' + max + ' €' : min + '€ +'; pD.text(lbl);
debouncedApiCall();
});
$(document).on('click', '.dropdown-item', function() { const dd = $(this).closest('.dropdown').find('.btn'); sel(dd, $(this).data('value'), $(this).text()); });
d.t.on('click', '.dropdown-item', function() {
const val = $(this).data('value');
f.attr('action', val === '76' ? '/tapetes-modernos' : val === '87' ? 'tapetes-orientais' : '/tapetes');
v.t.val(val);
debouncedApiCall();
});
if (!v.clr.val() && !v.sz.val()) fetchData([]);
});
Principais categorias Mostrar Tudo Avaliações & Comentários
7.649+ Reviews
5
/ 5 nos últimos 12 meses
Nossos Parceiros na Produção Sustentável de Tapetes
O ser humano está no centro de tudo para nós
You are on our Portuguese website!
The website is in Portuguese language. Would you like to be redirected to our Englisch website for a better experience?
Stay on Site
$(document).ready(function() {
function setLocalStorage(key, value) { localStorage.setItem(key, value); }
function getLocalStorage(key) { return localStorage.getItem(key); }
function fetchData() {
var lastShownDate = getLocalStorage('geoLocationModalShownDate');
var currentDate = new Date().getTime();
var daysSinceLastShown = lastShownDate ? (currentDate - lastShownDate) / (1000 * 3600 * 24) : null;
if (getLocalStorage('geoLocationModalShown') && daysSinceLastShown < 3) return;
fetch("https://morgenland-cpanel.eu/api/morgenland-info").then(function(r) {
if (!r.ok) throw new Error('HTTP error! status: ' + r.status);
return r.json();
}).then(function(d) {
var c = normalizeCountryCode(d.data.countryCode), l = [{"lang":"de","locale":"de","url":"https:\/\/www.morgenland-teppiche.de","name":"German","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/German.png"},{"lang":"en","locale":"en","url":"https:\/\/www.morgenland-rugs.com","name":"English","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/USA.png"},{"lang":"uk","locale":"en-gb","url":"https:\/\/www.morgenland-rugs.co.uk","name":"English","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/UK.png"},{"lang":"fr","locale":"fr","url":"https:\/\/www.morgenland-tapis.fr","name":"French","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/France.png"},{"lang":"nl","locale":"nl","url":"https:\/\/www.morgenland-tapijt.nl","name":"Dutch","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Netherland.png"},{"lang":"se","locale":"sv-SE","url":"https:\/\/www.morgenland-mattor.se","name":"Swedish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Sweden.png"},{"lang":"at","locale":"de-AT","url":"https:\/\/www.morgenland-teppiche.at","name":"Austria","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Austria.png"},{"lang":"ch","locale":"de-CH","url":"https:\/\/www.morgenland-teppiche.ch","name":"Swiss German","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Switzerland.png"},{"lang":"nn","locale":"no-NO","url":"https:\/\/www.morgenland-tepper.com","name":"Norwegian","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Norway.png"},{"lang":"da","locale":"da","url":"https:\/\/www.morgenland-taepper.com","name":"Danish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Denmark.png"},{"lang":"es","locale":"es","url":"https:\/\/www.morgenland-alfombra.es","name":"Spanish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Spain.png"},{"lang":"it","locale":"it","url":"https:\/\/www.morgenland-tappeto.it","name":"Italian","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Italy.png"},{"lang":"pl","locale":"pl","url":"https:\/\/www.morgenland-dywany.pl","name":"Polish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Poland.png"},{"lang":"cz","locale":"cs-CZ","url":"https:\/\/www.morgenland-koberce.cz","name":"Czech","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Czech-Republic.png"}], a = {"lang":"pt","name":"Portuguese","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Portguese.png"}, f = findActiveUrl(l, c);
if (shouldShowModal(f, a, c)) {
updateModal(f);
$('#geoLocationModal').modal('show');
$('#geoLocationModal').attr('aria-hidden', 'false');
setLocalStorage('geoLocationModalShown', 'true');
setLocalStorage('geoLocationModalShownDate', currentDate);
}
}).catch(function(e) { console.error('Fetch error:', e.message); });
}
function normalizeCountryCode(c) {
return c.toLowerCase() === "gb" ? "uk" : c.toLowerCase();
}
function findActiveUrl(l, c) {
var d = l.filter(function(u) { return u.lang === 'en'; })[0];
return l.find(function(u) { return u.lang === c; }) || d;
}
function shouldShowModal(foundUrl, activeUrl, countryCode) {
if (!foundUrl || countryCode === activeUrl.lang) return false;
var exceptions = { 'de': ['at', 'ch'], 'uk': ['en'], 'en': ['uk'], 'at': ['de', 'ch'], 'ch': ['de', 'at'] };
var activeExceptions = exceptions[activeUrl.lang] || [];
return !activeExceptions.includes(foundUrl.lang);
}
function updateModal(f) {
var b = document.querySelector('#redirectButton'), t = document.querySelector('#geoLocationText'), bt = document.querySelector('#redirectButtonText'), bi = document.querySelector('#redirectButtonImage');
b.href = f.url;
t.textContent = "The website is in Portuguese language. Would you like to be redirected to our {name} website for a better experience?".replace("{name}", f.name);
bi.src = bi['data-src'] = f.image;
bi.alt = f.name;
bt.textContent = "Redirect to {name} Site".replace("{name}", f.name);
}
fetchData();
});