$(document).ready(function() { //read-more section var $el, $ps, $up, totalHeight; $(".text-content .button").click(function() { totalHeight = 0 $el = $(this); $p = $el.parent(); $up = $p.parent(); $ps = $up.find("p:not('.read-more')"); // measure how tall inside should be by adding together heights of all inside paragraphs (except read-more paragraph) $ps.each(function() { totalHeight += $(this).outerHeight(); }); $up .css({ // Set height to prevent instant jumpdown when max height is removed "height": $up.height(), "max-height": 9999 }) .animate({ "height": totalHeight }); // fade out read-more $p.fadeOut(); // prevent jump-down return false; }); //end read-more section $.jGrowl.defaults.position = 'center'; $('.overflow_scroll').hover( function () { $(this).stop().animate({ textIndent: "-" + ( $(this).width() - $(this).parent().width() ) + "px" }, 1000); }, function () { $(this).stop().animate({ textIndent: "0" }, 1000); } ); //flip start var margin =$(".flipcard_item .front").width()/2; var width=$(".flipcard_item .front").width(); var height=$(".flipcard_item .front").height(); var flipspeed = 300; $(".flipcard_item .back").stop().css({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'}); function flip_front(el) { $(el).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:flipspeed}); window.setTimeout(function() { $(".flipcard_item .back").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:flipspeed}); },flipspeed); } function flip_back(el) { $(el).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:flipspeed}); window.setTimeout(function() { $(".flipcard_item .front").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:flipspeed}); },flipspeed); } $(".flipcard_item .front").hoverIntent( function () { flip_front(this); }, function () { } ); $(".flipcard_item .back").hoverIntent( function () { }, function () { flip_back(this); } ); $('.expand_midnav').click(function() { // $('.collapsible').slideUp(); var tmp = $(this).attr('id').split('_'); tmp = 'menu_cat_' + tmp[2]; $('#' + tmp).slideToggle(); return false; }); $('.swatch_popup').each(function() { init_swatch(this); }); $('.swatch_popup').live('click', function(e) { e.preventDefault(); init_swatch(this); }); $('.popup').click(function(e) { e.preventDefault(); var new_href = $(this).attr('href').replace('?','?in_popup=1&'); $(this).attr('href', new_href); $.colorbox({ href:$(this).attr('href'), scrolling: true, opacity: 0.7, width: 640, height: 480, preloading: true }); }); $('#product_shade').change(function() { if ($(this).val() == '') { return false; } $('ul.product_tabs li a:first').trigger('click'); var the_product_id = $(this).val(); $('#add_product_id').val(the_product_id); $('#swatch_desc span').html( $('#swatch_text_' + $(this).val()).html()); var img_href = $('#swatch_' + $(this).val()).attr('href'); $('#product_image_main img').attr('src', img_href); center_product_image(); $.post('/ajax',{ act: 'get_product_details', product_id: the_product_id},function(data) { update_cart_button(data); }); return false; }); $('.swatch_2').click(function(e) { var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; $('#add_product_id').val(the_product_id); $('#product_shade').val(the_product_id); $.post('/ajax',{ act: 'get_product_details', product_id: the_product_id},function(data) { update_cart_button(data); }); $(this).children('.swatch_name').show(); return false; }); $('.swatch_3').click(function(e) { var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; $.post('/ajax',{ act: 'get_product_details', product_id: the_product_id},function(data) { update_cart_button(data); }); return false; }); //real action is in the 'live' event handler, but this must be here to the tooltip to work $('.swatch_popup').click(function(e) { return false; }); $('.swatch_popup').hover(function() { return false; }); $('.btn_addtocart').live('click', function(event) { event.preventDefault(); if ($('#product_shade').length && $('#product_shade').val() == '') { alert('Wybierz kolor'); return false; } $('.floatingcart').html('
Please wait...
'); var form_addtocart = $(this).closest('form'); $.post($(form_addtocart).attr('action'), $(form_addtocart).serialize(), function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.btn_addtocart_list').live('click', function(event) { event.preventDefault(); $('.floatingcart').html('Please wait...
'); var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; var the_colitem_id = 0; if (tmp[3] != undefined) { the_colitem_id= tmp[3]; } $.post('/shop', { add_product_id: the_product_id, act: 'add_to_cart', floatingcart: 1, colitem_id: the_colitem_id}, function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.btn_addtocart_custom').live('click', function(event) { event.preventDefault(); $('.floatingcart').html('Please wait...
'); var tmp = $(this).attr('id').split('_'); var the_product_id = tmp[1]; var tmp_2 = 'list_' + the_product_id; $.post('/shop', { add_product_id: the_product_id, act: 'add_to_cart_custom', products_list: $('#'+tmp_2).val(), floatingcart: 1}, function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.btn_addtocart_mult').live('click', function(event) { event.preventDefault(); var tmp = $(this).attr('name').split('_'); $('.floatingcart').html('Please wait...
'); /* * */ $.post($('#form_addtocart').attr('action'), {add_product_id: tmp[2], act: 'add_to_cart', floatingcart: 1}, function(data) { $('.floatingcart').html(data); $('.floatingcart').slideDown().delay(6000).slideUp(); //show_basket_count(); show_basket_total(); }); return true; }); $('.show_basket_link').click(function() { if ($('.floatingcart').is(":visible") == true) { $('.floatingcart').slideUp(); } else { $('.floatingcart').slideDown(); } return false; }); $('.hide_basket_link').click(function() { $('.floatingcart').slideUp(); return false; }); var tabcontent_max_height = $('.product_tab_content :first').css('height'); var tabcontent_max_width = $('.product_tab_content :first').css('width'); $('ul.product_tabs li a').click(function(e) { e.preventDefault(); $('ul.product_tabs li').removeClass('active'); $(this).parent('li').addClass('active'); $('.product_tab_content').hide(); var target = $(this).attr('href').replace('#',''); $('#' + target).css('height',tabcontent_max_height); $('#' + target).css('width',tabcontent_max_width); $('#' + target).show(); }); $('.view_full').live('click', function(e) { e.preventDefault(); $('.view_full_container').html('
',
ajax: {
url: $(el).attr('href') // Use the rel attribute of each element for the url to load
},
title: {
text: $(el).attr('title'), // Give the tooltip a title using each elements text
button: true
}
},
position: {
at: 'bottom center', // Position the tooltip above the link
my: 'top center',
viewport: $(window), // Keep the tooltip on-screen at all times
effect: false // Disable positioning animation
},
show: {
event: 'click',
solo: true // Only show one tooltip at a time
},
hide: 'unfocus',
style: {
classes: 'qtip-dark qtip-shadow'
}
});
}
function center_product_image()
{
//position image center
var div_height = $('#product_image_main').height();
var div_width = $('#product_image_main').width();
var pos_top = (div_height - $('#product_image_main img').height()) / 2;
var pos_left = (div_width - $('#product_image_main img').width()) / 2;
$('#product_image_main img').css({'top':pos_top+'px', 'left':pos_left+'px'});
}
function update_cart_button(data)
{
if (data.trim() == 'IN STOCK')
{
$('#add_buttons').show();
$('#nostock_container').hide();
}
else
{
data = data.split('|');
if (data[0] == 'NO STOCK')
{
$('#add_buttons').hide();
$('#nostock_container').html(data[1]);
$('#nostock_container').show();
}
}
}
function show_basket_count()
{
$.jGrowl('DODANO DO KOSZYKA', { sticky: true, position: 'center', life:1000});
$.post('/ajax',{ act: 'get_basket_count'},function(data) {
$('.basket_icon').html(data);
});
}
function show_basket_total()
{
$.jGrowl('