/** * @fileOverview Epto Better Autocomplete is a flexible jQuery plugin * @author Claudio Vitellozzi, http://epto.it/ * from Better Autocomplete @version v1.0-dev @author Didrik Nordström, http://betamos.se/ * * @author Claudio Vitellozzi, http://epto.it/ * @version v1.5 * */ !function(e){e.fn.betterAutocomplete=function(i){var o={init:function(i,o,n){var s=e(this),r=new t(s,i,o,n);s.data("better-autocomplete",r),r.enable()},enable:function(e){e.enable()},disable:function(e){e.disable()},destroy:function(e){e.destroy()}},n=Array.prototype.slice.call(arguments,1);return this.each(function(){switch(i){case"init":o[i].apply(this,n);break;case"enable":case"disable":case"destroy":var s=e(this).data("better-autocomplete");s instanceof t&&o[i].call(this,s);break;default:e.error(["Method",i,"does not exist in jQuery.betterAutocomplete."].join(" "))}}),this};var t=function(t,o,n,s){var r,a="",l={},c=[],u=0,h={},p=1,d=[],f=!1,g={},m="string"!=e.type(o),y=e("
",t.description,"
"),"string"==e.type(t.url)&&""!=t.url&&i.push(""),i.join("")},queryLocalResults:function(t,i,o){if(!e.isArray(i))return[];var n=[];return e.each(i,function(i,s){switch(e.type(s)){case"string":(o?s:s.toLowerCase()).indexOf(t)>=0&&n.push({title:s});break;case"object":"string"==e.type(s.title)&&(o?s.title:s.title.toLowerCase()).indexOf(t)>=0?n.push(s):"string"==e.type(s.description)&&(o?s.description:s.description.toLowerCase()).indexOf(t)>=0&&n.push(s)}}),n},fetchRemoteData:function(t,i,o,n){e.ajax({url:t,dataType:n&&!e.support.cors?"jsonp":"json",timeout:o,success:function(e,t){i(e)},error:function(e,t,o){i()}})},processRemoteData:function(t){return e.isArray(t)?t:[]},getGroup:function(t){if("string"==e.type(t.group))return t.group},beginFetching:function(t){e(".head_search_go").css("display","none"),e(".search-rot").css("display","block"),e("#mousescrollicon").html('
')},afterShow:function(e){},afterHide:function(e){},constructURL:function(e,t,i){var o;return o="&p="+i,e+(e.indexOf("?")>-1?"&":"?")+"q="+encodeURIComponent(t)+o},canonicalQuery:function(t,i){var o=e.trim(t);return i||(o=o.toLowerCase()),o},insertSuggestionList:function(t,i,o){t.hide().append(e("").addClass("mousescrollicon").attr("id","mousescrollicon").html('
')).insertAfter(e("#quick_find")).append(i)}},o=e.expr[":"];o.focus||(o.focus=function(e){return e===document.activeElement&&(e.type||e.href)})}(jQuery);
(function ($, window) {
$.fn.RespProdSlide = function (options) {
// Default settings
var settings = $.extend({
nblock_visibili:10,
block_width :168 // 150 larghezza finestra prodotto
}, options);
var $this = $(this);
var thisclass= "."+$this.attr('class');
var $scrollbox = $(thisclass + " > div > div > div.scrollcontainer > .scrollbox");
var nblock_totali = $scrollbox.children().size();
$scrollbox.css("cssText","width: "+(nblock_totali*settings.block_width)+"px !important");
var pn=1;
var maxpn=2;
var $scrollcontainer=$(thisclass + " > div > div > div.scrollcontainer");
var scrollcontainer_width=$scrollcontainer.width();
var $scroll_gor=$(thisclass+" > div > div > img.gor");
var $scroll_gol=$(thisclass+" > div > div > img.gol");
var $scrollblock = $(thisclass+" > div > div > div.scrollcontainer > .scrollbox > .scrollblock");
$scroll_gor.click(function(){
if(maxpn<=1 || pn>=maxpn) return false;
$scrollblock.slice(0,1).animate({ "left": "-="+scrollcontainer_width }, {
duration: 400,
step: function(now, fx){
$scrollblock.slice(1).css("left", now);
$(window).trigger('scroll');
}
});
pn++;
if(pn>=maxpn) { pn=maxpn; $(this).css("opacity","0.3"); }
$scroll_gol.css("opacity","1.0");
});
$scroll_gol.click(function(){
if(pn<=1) return false;
$scrollblock.slice(0,1).animate({ "left": "+="+scrollcontainer_width }, {
duration: 400,
step: function(now, fx){
$scrollblock.slice(1).css("left", now);
}
});
pn--;
if(pn<=1) {
pn=1; $(this).css("opacity","0.3");
}
$scroll_gor.css("opacity","1.0");
});
$scrollcontainer.on("swiperight",function(){
if(pn<=1) return false;
$scrollblock.slice(0,1).animate({ "left": "+="+scrollcontainer_width }, {
duration: 400,
step: function(now, fx){
$scrollblock.slice(1).css("left", now);
}
});
pn--;
if(pn<=1) {
pn=1; $scroll_gol.css("opacity","0.3");
}
$scroll_gor.css("opacity","1.0");
}).on("swipeleft",function(){
if(maxpn<=1 || pn>=maxpn) return false;
$scrollblock.slice(0,1).animate({ "left": "-="+scrollcontainer_width }, {
duration: 400,
step: function(now, fx){
$scrollblock.slice(1).css("left", now);
}
});
pn++;
if(pn>=maxpn) { pn=maxpn; $scroll_gor.css("opacity","0.3"); }
$scroll_gol.css("opacity","1.0");
}).on('movestart', function(e) {
// If the movestart heads off in a upwards or downwards
// direction, prevent it so that the browser scrolls normally.
if ((e.distX > e.distY && e.distX < -e.distY) ||
(e.distX < e.distY && e.distX > -e.distY)) {
e.preventDefault();
return;
}
}).on('move', function(e) {
var left = 100 * (e.distX / scrollcontainer_width);
// Move slides with the finger
if (e.distX < 0) {
if(pn==maxpn) {
left=(left/10);
if (left<-10) {
left=-10;
}
}
if ($scrollblock.slice(pn+1)) {
$scrollblock.parent().css("margin-left", left + '%');
}else {
$scrollblock.parent().css("margin-left", (left/4) + '%');
}
}
if (e.distX > 0 ) {
if(pn==1) {
left=(left/10);
if (left>10) {
left=10;
}
}
if ($scrollblock.slice(pn-1)) {
$scrollblock.parent().css("margin-left", left + '%');
}else {
$scrollblock.parent().css("margin-left", (left/4) + '%');
}
}
}).on('moveend', function(e) {
$scrollblock.parent().animate({ "margin-left": "0" }, {
duration: 600
});
});
$this.reset_size = function() {
var nblock;
var max_scroll_width = $this.parent().width();
if (max_scroll_width>1500) {
scrollcontainer_width=1500;
}else{
scrollcontainer_width=max_scroll_width;
}
nblock = Math.floor(scrollcontainer_width/settings.block_width);
scrollcontainer_width = nblock*settings.block_width;
if (settings.nblock_visibili!=nblock) {
settings.nblock_visibili=nblock;
//$(".dejavue_box").css("cssText","max-width: "+((nblock_visibili*150)-100+3)+"px !important" );
$scrollcontainer.css("cssText","max-width: "+((settings.nblock_visibili*settings.block_width)-20)+"px !important");
//alert(((settings.nblock_visibili*settings.block_width)-20));
scrollrestart();
}
maxpn = Math.ceil( $scrollblock.length / settings.nblock_visibili); // numero blocchi
if(pn>=maxpn) { $scroll_gor.css("opacity","0.3"); }
}
function scrollrestart(){
pn=1 ;
$scrollblock.slice(0,1).animate({ "left": 0 }, {
duration: 400,
step: function(now, fx){
$scrollblock.slice(1).css("left", now);
}
});
$scroll_gol.css("opacity","0.3");
$scroll_gor.css("opacity","1.0");
};
$(window).on('resize',function(){
$this.reset_size();
});
$this.reset_size();
return $this;
};
})(jQuery, this, 0);
function addParameterToURL(_url,param){
_url += (_url.split('?')[1] ? '&':'?') + param;
return _url;
}
function upd_carrello(url_par){
url_par = '?'+url_par || '';
$( "#div_carrello" ).html('
')
.load(addParameterToURL(window.location.protocol + "//" + window.location.hostname+'/carrello_ajax.php'+url_par,'nocache='+new Date().getTime()));
$('#carrello_nqta').load(window.location.protocol + "//" + window.location.hostname+'/carrello_ajax.php?get_qta=1&nocache='+new Date().getTime());
}
function upd_carrello_qty(){
form = $('#form_cart');
$.ajax({
type: "POST",
url: window.location.protocol + "//" + window.location.hostname+"/carrello_ajax.php?action=update_product",
data: form.serialize(),
success: function (data) {
$( "#div_carrello" ).html(data);
$('#carrello_nqta').load(window.location.protocol + "//" + window.location.hostname+'/carrello_ajax.php?get_qta=1&nocache='+new Date().getTime());
},
beforeSend: function() {
$( "#div_carrello" ).html('
');
}
});
}
function controlloConfronta(ck_ncheck){
var i=0;
var cComp = document.getElementById('compara_' + ck_ncheck);
if(cComp){
var codice_prod=cComp.value;
}else{
var codice_prod='';
}
if(cComp.checked){
if ($.cookie('pConfrontati')){
var a_pConfrontati = $.cookie('pConfrontati').split(',');
if (a_pConfrontati.length < 4){
a_pConfrontati.push(codice_prod);
}else if (a_pConfrontati.length >= 4){
alert('Puoi comparare massimo 4 prodotti\r\nFai click su Compara per rimuovere i prodotti dalla comparazione');
cComp.checked=false;
}
}else{
var a_pConfrontati = new Array();
a_pConfrontati.push(codice_prod);
}
}else{
if ($.cookie('pConfrontati')) {
var a_pConfrontati = $.cookie('pConfrontati').split(',');
while (i < a_pConfrontati.length) {
if (a_pConfrontati[i] == codice_prod) {
a_pConfrontati.splice(i, 1);
} else {
i++;
}
}
}
}
$.cookie('pConfrontati', a_pConfrontati, {path: '/'});
}
function quickTabs(navQuick,show_hide,init_mode){
init_mode = init_mode || 0;
if(navQuick){
if(show_hide){
if (init_mode) {
$('#qck_all'+navQuick).show();
}else{
$('#qck_all'+navQuick).slideDown('fast');
}
$('#qckt'+navQuick).parent().parent().hide();
}else{
if (init_mode) {
$('#qck_all'+navQuick).hide();
}else{
$('#qck_all'+navQuick).slideUp('fast',function(){
$('#qckt'+navQuick).parent().parent().show();
});
}
}
}
return;
}
function shfiltri(show_hide) {
if (show_hide && $('#filtri_show > span > span > a').hasClass('disabled')==false) {
$('#filtri_show > span > span > a').addClass('disabled');
$('.column_left_main').css('display','block');
$('.column_left_main').animate({"left": '+=220'});
}else{
$('.column_left_main').animate({"left": '-=220'},function(){
$('.column_left_main').css('display','');
$('#filtri_show > span > span > a').removeClass('disabled');;
});
}
}
function chksearchtext(search_form){
search_form.keywords.value=trim(search_form.keywords.value);
if (search_form.keywords.value.length < 2 ) {
alert('Termine di ricerca troppo corto (minimo 2 caratteri)') ;
search_form.keywords.focus();
return (false);
}
if (search_form.keywords.value == 'Cosa stai cercando?'){
alert('Inserisci un termine per la ricerca');
search_form.keywords.focus();
return (false);
}
if (search_form.keywords.value.length > 50 ){
alert('Il termine di ricerca è troppo lungo. (Massimo 50 caratteri)');
search_form.keywords.focus();
return (false);
}
$(".head_search_go").css("display","none");
$(".search-rot").css("display","block");
return true;
}
function trim (str) {
var str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}