2014-10-23 13:38:19 +00:00
|
|
|
!function(a,b,c,d){a.fn.wc_variation_form=function(){return a.fn.wc_variation_form.find_matching_variations=function(b,c){for(var d=[],e=0;e<b.length;e++){{var f=b[e];f.variation_id}a.fn.wc_variation_form.variations_match(f.attributes,c)&&d.push(f)}return d},a.fn.wc_variation_form.variations_match=function(a,b){var c=!0;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=b[e];f!==d&&g!==d&&0!==f.length&&0!==g.length&&f!==g&&(c=!1)}return c},this.unbind("check_variations update_variation_values found_variation"),this.find(".reset_variations").unbind("click"),this.find(".variations select").unbind("change focusin"),$form=this.on("click",".reset_variations",function(){a(this).closest(".variations_form").find(".variations select").val("").change();var b=a(this).closest(".product").find(".sku"),c=a(this).closest(".product").find(".product_weight"),d=a(this).closest(".product").find(".product_dimensions");return b.attr("data-o_sku")&&b.text(b.attr("data-o_sku")),c.attr("data-o_weight")&&c.text(c.attr("data-o_weight")),d.attr("data-o_dimensions")&&d.text(d.attr("data-o_dimensions")),!1}).on("change",".variations select",function(){$variation_form=a(this).closest(".variations_form"),$variation_form.find("input.variation_id").length>0?$variation_form.find("input.variation_id").val("").change():$variation_form.find("input[name=variation_id]").val("").change(),$variation_form.trigger("woocommerce_variation_select_change").trigger("check_variations",["",!1]),a(this).blur(),a().uniform&&a.isFunction(a.uniform.update)&&a.uniform.update()}).on("focusin touchstart",".variations select",function(){$variation_form=a(this).closest(".variations_form"),attribute_name="undefined"!=typeof a(this).data("attribute_name")?a(this).data("attribute_name"):a(this).attr("name"),$variation_form.trigger("woocommerce_variation_select_focusin").trigger("check_variations",[attribute_name,!0])}).on("check_variations",function(c,d,e){var f=!0,g=!1,h={},i=a(this),j=i.find(".reset_variations");i.find(".variations select").each(function(){attribute_name="undefined"!=typeof a(this).data("attribute_name")?a(this).data("attribute_name"):a(this).attr("name"),0===a(this).val().length?f=!1:g=!0,d&&attribute_name===d?(f=!1,h[attribute_name]=""):(value=a(this).val(),h[attribute_name]=value)});var k=parseInt(i.data("product_id")),l=i.data("product_variations");l||(l=b.product_variations.product_id),l||(l=b.product_variations),l||(l=b["product_variations_"+k]);var m=a.fn.wc_variation_form.find_matching_variations(l,h);if(f){var n=m.shift();n?($variation_input=i.find(i.find("input.variation_id").length>0?"input.variation_id":"input[name=variation_id]"),$variation_input.val(n.variation_id).change(),i.trigger("found_variation",[n])):(i.find(".variations select").val(""),e||i.trigger("reset_image"),alert(wc_add_to_cart_variation_params.i18n_no_matching_variations_text))}else i.trigger("update_variation_values",[m]),e||i.trigger("reset_image"),d||i.find(".single_variation_wrap").slideUp(200);g?"hidden"===j.css("visibility")&&j.css("visibility","visible").hide().fadeIn():j.css("visibility","hidden")}).on("reset_image",function(){var b=a(this).closest(".product"),c=b.find("div.images img:eq(0)"),e=b.find("div.images a.zoom:eq(0)"),f=c.attr("data-o_src"),g=c.attr("data-o_title"),h=c.attr("data-o_alt"),i=e.attr("data-o_href");f!==d&&c.attr("src",f),i!==d&&e.attr("href",i),g!==d&&(c.attr("title",g),e.attr("title",g)),h!==d&&c.attr("alt",h)}).on("update_variation_values",function(b,c){$variation_form=a(this).closest(".variations_form"),$variation_form.find(".variations select").each(function(b,d){current_attr_select=a(d),current_attr_select.data("attribute_options")||current_attr_select.data("attribute_options",current_attr_select.find("option:gt(0)").get()),current_attr_select.find("option:gt(0)").remove(),current_attr_select.append(current_attr_select.data("attribute_options")),current_attr_select.find("option:gt(0)").removeClass("attached"),current_attr_select.find("option:gt(0)").removeClass("enabled"),current_attr_select.find("option:gt(0)").removeAttr("disabled"),current_att
|