Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Product(form, options) {
- this.form = $(form);
- this.add2cart = this.form.find(".add2cart");
- this.button = this.add2cart.find("input[type=submit]");
- for (var k in options) {
- this[k] = options[k];
- }
- var self = this;
- this.form.find('.inline-select a').click(function () {
- console.log("111111111");
- });
- this.form.find(".sku-feature").change(function () {
- var key = "";
- self.form.find(".sku-feature").each(function () {
- key += $(this).data('feature-id') + ':' + $(this).val() + ';';
- });
- var sku = self.features[key];
- console.log(sku);
- if (sku) {
- if (sku.image_id) {
- $("#product-image-" + sku.image_id).click();
- }
- self.updateSkuServices(sku.id);
- if (sku.available) {
- self.button.removeAttr('disabled');
- } else {
- self.form.find("div.stocks div").hide();
- self.form.find(".sku-no-stock").show();
- self.button.attr('disabled', 'disabled');
- }
- self.add2cart.find(".price").data('price', sku.price);
- self.updatePrice(sku.price, sku.compare_price);
- } else {
- self.form.find("div.stocks div").hide();
- self.form.find(".sku-no-stock").show();
- self.button.attr('disabled', 'disabled');
- self.add2cart.find(".compare-at-price").hide();
- self.add2cart.find(".price").empty();
- }
- self.cartButtonVisibility(true);
- });
- this.form.find(".sku-feature:first").change();
- }
- Product.prototype.currencyFormat = function (number, no_html) {
- };
- Product.prototype.serviceVariantHtml= function (id, name, price) {
- return $('<option data-price="' + price + '" value="' + id + '"></option>').text(name + ' (+' + this.currencyFormat(price, 1) + ')');
- };
- Product.prototype.updateSkuServices = function (sku_id) {
- };
- Product.prototype.updatePrice = function (price, compare_price) {
- }
- Product.prototype.cartButtonVisibility = function (visible) {
- //toggles "Add to cart" / "%s is now in your shopping cart" visibility status
- }
- $(function () {
- // product images
- $("#product-gallery a").click(function () {
- $('.product-gallery .image').removeClass('selected');
- $(this).parent().addClass('selected');
- $("#product-image").addClass('blurred');
- $("#switching-image").show();
- var img = $(this).find('img');
- var size = $("#product-image").attr('src').replace(/^.*\/[0-9]+\.(.*)\..*$/, '$1');
- var src = img.attr('src').replace(/^(.*\/[0-9]+\.)(.*)(\..*)$/, '$1' + size + '$3');
- $('<img>').attr('src', src).load(function () {
- $("#product-image").attr('src', src);
- $("#product-image").removeClass('blurred');
- $("#switching-image").hide();
- }).each(function() {
- //ensure image load is fired. Fixes opera loading bug
- if (this.complete) { $(this).trigger("load"); }
- });
- var size = $("#product-image").parent().attr('href').replace(/^.*\/[0-9]+\.(.*)\..*$/, '$1');
- var href = img.attr('src').replace(/^(.*\/[0-9]+\.)(.*)(\..*)$/, '$1' + size + '$3');
- $("#product-image").parent().attr('href', href);
- return false;
- });
- // compare block
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement