Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var frontendPopup = jQuery.noConflict();
  2. frontendPopup(function($) {
  3.     var baseUrl = $("#base_url").val(),
  4.         currentProductId = $("#current_product_id").val(),
  5.         designPageUrl = baseUrl + "pdp/view/getDesignPage/",
  6.         tempUrl,
  7.         w_window = $(window).width();
  8.     LoadDesign = {
  9.         load : function() {
  10.             $(".design-btn .design-product").on("click", function() {
  11.                 if (!$(this).hasClass("loaded")) {
  12.                     var cartItemId = $("#cart_item_id").val(),
  13.                         wishlistItemId = $("#wishlist_item_id").val(),
  14.                         shareId = $("#pdp_design_share").val();
  15.                     tempUrl = designPageUrl + "product-id/" + currentProductId;
  16.                     designPageUrl = tempUrl;
  17.                     if (cartItemId != "") {
  18.                         tempUrl = designPageUrl + "/item-id/" + cartItemId;
  19.                         designPageUrl = tempUrl;
  20.                     }
  21.                     if (shareId != "") {
  22.                         tempUrl = designPageUrl + "/share-id/" + shareId;
  23.                         designPageUrl = tempUrl;
  24.                     }
  25.                     if (wishlistItemId) {
  26.                         tempUrl = designPageUrl + "/wishlist-id/" + wishlistItemId;
  27.                         designPageUrl = tempUrl;
  28.                     }
  29.                     LoadDesign.sendRequest(designPageUrl, LoadDesign.prepareDesignPage);
  30.                 } else {
  31.                     //show popup here
  32.                     $('#pdp_design_popup').show();
  33.                 }
  34.             });
  35.         }(),
  36.         init : function() {
  37.             var action = $("#pdp_design_action").val(),
  38.                 shareId = $("#pdp_design_share").val(),
  39.                 cartItemId = $("#cart_item_id").val(),
  40.                 wishlistItemId = $("#wishlist_item_id").val();
  41.             //if (action != "" || shareId != "" || cartItemId != "" || wishlistItemId != "") {
  42.                 //Validate product form
  43.                 //var addToCartForm = new VarienForm('product_addtocart_form', true);
  44.                 //if (addToCartForm.validator.validate()) {
  45.                     $(window).load(function(){
  46.                         //$(".design-btn .design-product").click();
  47.                     });
  48.                 //}
  49.             //}
  50.         }(),
  51.         sendRequest : function(url, callback) {
  52.             $.ajax({
  53.                 type : "GET",
  54.                 url : url,
  55.                 beforeSend : function () {
  56.                     //console.log("Sending request...");
  57.                     $(".pdp_loading").show();
  58.                 },
  59.                 success : function(data) {
  60.                     callback(data);
  61.                     $(".pdp_loading").hide();
  62.                 }
  63.             });
  64.         },
  65.         prepareDesignPage : function(data) {
  66.             $(".design-btn .design-product").addClass('loaded');
  67.             $("#pdp_design_popup").html(data);
  68.             $('#pdp_design_popup').appendTo('body');
  69.             $('#pdp_design_popup').append('<div class="overlay"></div>');
  70.             $(".pdp_share_buttons").show();
  71.             var w_pdp = $('#cboxLoadedContent').width();
  72.             //PDPsetting.init();
  73.             $('#pdp_design_popup .overlay').click(function(){
  74.                 $('#pdp_design_popup').hide();
  75.             });
  76.         },
  77.  
  78.         updatePDPCustomOption : function(design) {
  79.             $("#product-options-wrapper .pdp_info input").val(design);
  80.             $("input[name='extra_options']").val(design);
  81.         }
  82.     }
  83. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement