(function($) { $(document).ready(function() { /* Category */ var filcol; $('.filter-tag a').click(function(e) { e.preventDefault(); filcol = $(this).data('value'); if($(this).hasClass('active')) { $(this).removeClass('active'); }else { $(this).addClass('active'); } updatePage("filter"); }); $('#sortBox li').click(function(e) { e.preventDefault(); if($(this).hasClass('active')) return false; $('#sortBox li').removeClass('active'); $(this).addClass('active'); updatePage("sortBox"); }); var page = $('.pagination li.active a').data('value'); $('.pagination li').click(function(e) { e.preventDefault(); if($(this).parent().hasClass('active') || $(this).hasClass('disabled')) return false; page = $(this).children('a').attr('data-page'); updatePage("pagination"); }); function updatePage(x) { var show = $('#showBox li.active a').attr('data-value'); var sort = $('.filtering').attr('data-filter'); var method = "get"; var action = window.location.pathname; var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", action); $('[data-filter]').each(function() { var values = []; $(this).find('.active').each(function(i) { values[i] = $(this).attr('data-value'); }); if(values.length > 0) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "filters"); hiddenField.setAttribute("value", JSON.stringify(values)); form.appendChild(hiddenField); } }); if(x=="sortBox"){ var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "filter"); hiddenField.setAttribute("value", $('#sortBox li.active').data('value')); form.appendChild(hiddenField); var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "mostrar"); hiddenField.setAttribute("value",24); form.appendChild(hiddenField); } if(x=="filter"){ var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "options[1]"); hiddenField.setAttribute("value", "["+filcol+"]"); form.appendChild(hiddenField); } if(x=="pagination"){ var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "mostrar"); hiddenField.setAttribute("value", 24); form.appendChild(hiddenField); var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "page"); hiddenField.setAttribute("value", page); form.appendChild(hiddenField); } /*if(x!="pagination" && x!="filter"){ var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "mostrar"); hiddenField.setAttribute("value", show); form.appendChild(hiddenField); }*/ document.body.appendChild(form); form.submit(); } /* Comments */ $('.spr-summary-actions-newreview').click(function(e) { e.preventDefault(); $('.spr-form').toggle(); }); $('.new-review-form .spr-starrating .spr-icon').click(function(e) { e.preventDefault(); $('.spr-form .spr-starrating .spr-icon').addClass('spr-icon-star-empty'); var value = $(this).attr('data-value'); $('.spr-form .spr-starrating .spr-icon').each(function() { if($(this).attr('data-value') <= value) $(this).removeClass('spr-icon-star-empty'); }) $('.spr-form [name="quality"]').val(value); }); /* Notificaciones */ if($('.alert-global').length > 0) { setTimeout(function() { if($('.alert-global').length > 0) { $('.alert-global').css('animation-name', 'bounceOutUp'); } }, 5000); $('.alert-global').click(function() { $(this).css('animation-name', 'bounceOutUp'); }) } function notification(type, message) { var alert = '
'+message+'