Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mst = jQuery.noConflict();
  2. mst.fn.ForceNumericOnly = function() {
  3.     return this.each(function() {
  4.         mst(this).keydown(function(e) {
  5.             var t = e.charCode || e.keyCode || 0;
  6.             return t == 8 || t == 9 || t == 46 || t >= 37 && t <= 40 || t >= 48 && t <= 57 || t >= 96 && t <= 105
  7.         })
  8.     })
  9. };
  10. mst(document).ready(function(e) {
  11.     function n(t, n, r, i) {
  12.         var s = 0,
  13.             o = 0;
  14.         t.css("font-size", 0);
  15.         t.css("line-height", 0);
  16.         while (t.width() < n - i) {
  17.             s++;
  18.             t.css("font-size", s);
  19.             e("#select_font_size").val(s)
  20.         }
  21.         while (t.height() < r - i) {
  22.             o++;
  23.             t.css("line-height", o + "px")
  24.         }
  25.         e(".overlay-btn").removeClass("send-back")
  26.     }
  27.  
  28.     function r(e) {
  29.         e = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  30.         return ("0" + parseInt(e[1], 10).toString(16)).slice(-2) + ("0" + parseInt(e[2], 10).toString(16)).slice(-2) + ("0" + parseInt(e[3], 10).toString(16)).slice(-2)
  31.     }
  32.  
  33.     function s(t) {
  34.         e("#edit_item_wrap").show();
  35.         var n;
  36.         if (e("#change_text_type li a.bold").hasClass("active")) {
  37.             t.css("font-weight", "bold")
  38.         } else {
  39.             t.css("font-weight", "normal")
  40.         } if (e("#change_text_type li a.italic").hasClass("active")) {
  41.             t.css("font-style", "italic")
  42.         } else {
  43.             t.css("font-style", "normal")
  44.         } if (e("#change_text_type li a.underline").hasClass("active")) {
  45.             t.css("text-decoration", "underline")
  46.         } else {
  47.             t.css("text-decoration", "none")
  48.         }
  49.         n = e("#change_text_type .align.active").text();
  50.         switch (n) {
  51.             case "C":
  52.                 t.css("text-align", "center");
  53.                 break;
  54.             case "R":
  55.                 t.css("text-align", "right");
  56.                 break;
  57.             case "J":
  58.                 t.css("text-align", "justify");
  59.                 break;
  60.             default:
  61.                 t.css("text-align", "left");
  62.                 break
  63.         }
  64.         if (e("#use_shadow").is(":checked")) {
  65.             t.css({
  66.                 "text-shadow": e("#h-shadow").val() + "px " + e("#v-shadow").val() + "px " + e("#t-blur").val() + "px " + e("#font_outline_color > div").css("backgroundColor")
  67.             })
  68.         } else {
  69.             t.css("text-shadow", "none")
  70.         }
  71.         t.css({
  72.             color: e("#font_color_div > div").css("background-color"),
  73.             "line-height": "1.5",
  74.             "font-size": e("#select_font_size").val() + "px",
  75.             "font-family": e("#select_font_span").html()
  76.         });
  77.         t.css("transform", "rotate(0deg)");
  78.         var r = t.width() + 20,
  79.             i = t.height() + 20,
  80.             s = t.parent().attr("scx"),
  81.             o = t.parent().attr("scy"),
  82.             u = t.parent().attr("angle2"),
  83.             a = t.parent().position().left,
  84.             f = t.parent().position().top;
  85.         var l, c;
  86.         if (u == 90) {
  87.             u = 89.9999999999
  88.         }
  89.         var h = u * Math.PI / 180;
  90.         var p = Math.cos(h);
  91.         var d = Math.sin(h);
  92.         if (p < 0) {
  93.             p = -p
  94.         }
  95.         if (d < 0) {
  96.             d = -d
  97.         }
  98.         l = i * d + r * p;
  99.         c = i * p + r * d;
  100.         var v = (r * p - i * d) / (p * p - d * d),
  101.             m = (i - v * d) / p,
  102.             g = l - v,
  103.             y = c - m;
  104.         var b = parseInt(a) + parseInt(l) / 2,
  105.             w = parseInt(f) + parseInt(c) / 2;
  106.         new_angle = -1 * u;
  107.         t.parent().width(l).height(c).attr("w", r).attr("h", i).attr("pos", b + "," + w);
  108.         t.css("transform", "rotate(" + new_angle + "deg) scaleX(" + s + ") scaleY(" + o + ")");
  109.         t.css({
  110.             left: (l - r) / 2,
  111.             top: (c - i) / 2
  112.         });
  113.         e(".overlay-btn").removeClass("send-back")
  114.     }
  115.  
  116.     function u(t) {
  117.         e("#edit_item_wrap, .arc_text").show();
  118.         e(".add_text_tab").click();
  119.         e("#add_text_action").hide();
  120.         e("#add_text_input").val(t.text());
  121.         e("#select_font_span").html(t.css("font-family")).css("font-family", t.css("font-family"));
  122.         e("#select_font_size").val(parseInt(t.css("font-size")));
  123.         e("#font_color_div > div").css("backgroundColor", t.css("color"));
  124.         if (t.css("font-weight") > 400 || t.css("font-weight") == "bold") {
  125.             e("#change_text_type a.bold").addClass("active")
  126.         } else {
  127.             e("#change_text_type a.bold").removeClass("active")
  128.         } if (t.css("font-style") == "italic") {
  129.             e("#change_text_type a.italic").addClass("active")
  130.         } else {
  131.             e("#change_text_type a.italic").removeClass("active")
  132.         } if (t.css("text-decoration") == "underline") {
  133.             e("#change_text_type a.underline").addClass("active")
  134.         } else {
  135.             e("#change_text_type a.underline").removeClass("active")
  136.         }
  137.         switch (t.css("text-align")) {
  138.             case "left":
  139.                 e("#change_text_type a.align_left").addClass("active");
  140.                 break;
  141.             case "center":
  142.                 e("#change_text_type a.align_center").addClass("active");
  143.                 break;
  144.             case "right":
  145.                 e("#change_text_type a.align_right").addClass("active");
  146.                 break;
  147.             case "justify":
  148.                 e("#change_text_type a.align_justify").addClass("active");
  149.                 break;
  150.             default:
  151.                 e("#change_text_type a.align_justify").removeClass("active");
  152.                 e("#change_text_type a.align_right").removeClass("active");
  153.                 e("#change_text_type a.align_center").removeClass("active");
  154.                 break
  155.         }
  156.         var n = t.css("text-shadow").match(/(-?\d+px)|(rgb\(.+\))/g);
  157.         if (n) {
  158.             if (!e("#use_shadow").is(":checked")) {
  159.                 e("#use_shadow").click()
  160.             }
  161.             e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape  .blur,.font_shape  .color").show();
  162.             e("#h-shadow").val(parseInt(n[1]));
  163.             e("#v-shadow").val(parseInt(n[2]));
  164.             e("#t-blur").val(parseInt(n[3]));
  165.             e("#font_outline_color > div").css("backgroundColor", n[0]);
  166.             t.css("text-shadow", n[1] + " " + n[2] + " " + n[3] + " " + n[0])
  167.         } else {
  168.             e("#use_shadow").attr("checked", false);
  169.             e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape  .blur,.font_shape  .color").hide()
  170.         }
  171.     }
  172.  
  173.     function a() {
  174.         e("#use_shadow").attr("checked", false);
  175.         e(".font_shape .h-shadow,.font_shape .v-shadow, .font_shape .blur, .font_shape .color").hide();
  176.         e("#edit_text_action, .arc_text").hide();
  177.         e("#add_text_input").val("");
  178.         e("#select_font_span").html("Arial").css("font-family", "Arial");
  179.         e("#select_font_size").val("20");
  180.         e("#h-shadow, #v-shadow, #t-blur").val(0);
  181.         e("#font_color_div > div").css("backgroundColor", "#444");
  182.         e("#font_outline_color > div").css("backgroundColor", "#fff");
  183.         e("#change_text_type a.active").removeClass("active")
  184.     }
  185.  
  186.     function f(t) {
  187.         var n = t.target.files;
  188.         for (var r = 0, i; i = n[r]; r++) {
  189.             if (!i.type.match("image.*")) {
  190.                 alert("Please upload a file in one of the following formats: .svg, .jpg, .png, .jpeg, .bmp, .gif");
  191.                 continue;
  192.             }
  193.             var s = new FileReader;
  194.             s.onload = function(t) {
  195.                 return function(n) {
  196.                     var r = e("#lists_img_upload span").length;
  197.                     var i = document.createElement("span");
  198.                     i.innerHTML = ['<img id="img_up_' + r+++'" color="" class="thumb" src="', n.target.result, '" title="', escape(t.name), '"/>'].join("");
  199.                     document.getElementById("lists_img_upload").insertBefore(i, null)
  200.                 }
  201.             }(i);
  202.             s.readAsDataURL(i)
  203.         }
  204.         e("#files_upload").val("")
  205.     }
  206.     var t = e("#url_site").val().replace("index.php/", "");
  207.     PDPsetting = {
  208.         add_html: function() {
  209.             e("body").prepend('<div class="pdploading no-display">Loading</div>');
  210.             e("body").append('<div style="display:block;" class="no-display" id="save_original_img_text"></div>');
  211.             e("#product-image-wrap").prepend('<img id="main_image" src="' + t + 'media/pdp/images/no_image.jpg" />');
  212.             e("#product-image-wrap").attr("z_index", 1e3);
  213.             e(".wrapper_pdp").append(e(".color_content"))
  214.         },
  215.         center_design_area: function() {
  216.             var t = e(".wrapper_pdp").width(),
  217.                 n = e("#design_control").width(),
  218.                 r = e("#product-image-wrap").width(),
  219.                 i = e("#product-image-wrap").width(),
  220.                 s = parseInt((t - n - i) / 2)
  221.         },
  222.         position_color: function() {
  223.             var t = e("body").width(),
  224.                 n = e(".wrapper_pdp").width(),
  225.                 r = e(".color_content_wrap").width(),
  226.                 i = (t - n) / 2 - r + n;
  227.             e(".color_content_wrap").css("left", i + "px")
  228.         },
  229.         change_color: function() {
  230.             e("#pdp_sides li").each(function() {
  231.                 var t = e(this).attr("tab"),
  232.                     n = e(".design-color-image li.active").attr(t),
  233.                     r = e("#pdp_media_url").val();
  234.                 e(this).attr("side_img", n).children("img").attr("src", r + n);
  235.                 e(".pdp_info_save[alt=" + t + "]").attr("side_img", n)
  236.             });
  237.             PDPsetting.change_image()
  238.         },
  239.         save_first_design: function() {
  240.             e("#pdp_sides li").each(function() {
  241.                 var t = {
  242.                     inlay: e(this).attr("inlay"),
  243.                     side: e(this).attr("tab"),
  244.                     img: e(this).attr("side_img"),
  245.                     items: []
  246.                 };
  247.                 console.log(t.img);
  248.                 var n = e("#skin_url").val(),
  249.                     r = e("#base_dir").val(),
  250.                     i = e("#media_url").val(),
  251.                     s = e(this).attr("tab");
  252.                 e("#pdp_info_" + s).val(JSON.stringify(t))
  253.             })
  254.         },
  255.         change_image: function() {
  256.             var t = e("#pdp_sides li.active").attr("side_img"),
  257.                 n = e("#pdp_media_url").val();
  258.             e(".wrap_pdp_design #main_image").attr("src", n + t)
  259.         },
  260.         change_side: function() {
  261.             var t = e("#pdp_sides li.active"),
  262.                 n = t.attr("side_img"),
  263.                 r = t.attr("tab"),
  264.                 i = e("#pdp_info_" + r).val(),
  265.                 s = e("#pdp_media_url").val(),
  266.                 o = t.attr("inlay").split(",");
  267.             e(".wrap_pdp_design #main_image").attr("src", s + n);
  268.             e(".wrap_pdp_design #wrap_inlay").css({
  269.                 width: o[0] + "px",
  270.                 height: o[1] + "px",
  271.                 top: o[2] + "px",
  272.                 left: o[3] + "px"
  273.             }).show();
  274.             PDPsetting.display_design_as_html(i)
  275.         },
  276.         display_design_as_html: function(t) {
  277.             e(".wrap_pdp_design #wrap_inlay").html("");
  278.             if (t != "") {
  279.                 t = JSON.parse(t);
  280.                 if (t.items.length > 0) {
  281.                     var n = t.items;
  282.                     for (i = 0; i < n.length; i++) {
  283.                         var r = n[i];
  284.                         if (r.type == "image") {
  285.                             e(".wrap_pdp_design #wrap_inlay").append('<div class="item image_item"  scy="' + r.scy + '" scx="' + r.scx + '" pos="' + r.pos + '" w="' + r.width + '" h="' + r.height + '" angle2="' + r.angle + '" style="' + r.css + '"><img style="' + r.itemcss + '" src="' + r.path + '" alt="img" /></div>')
  286.                         } else {
  287.                             e(".wrap_pdp_design #wrap_inlay").append('<div class="item text-image"  scy="' + r.scy + '" scx="' + r.scx + '" pos="' + r.pos + '" w="' + r.width + '" h="' + r.height + '" angle2="' + r.angle + '" style="' + r.css + '"><p style="' + r.itemcss + '">' + r.text + "</p></div>")
  288.                         }
  289.                     }
  290.                     PDPsetting.init_cr_item()
  291.                 }
  292.             }
  293.         },
  294.         init: function() {
  295.             e(".wrap_pdp_design .wrap_inlay").addClass("unloadinlay");
  296.             e(".wrap_pdp_design .wrap_inlay").hover(function() {
  297.                 e(this).addClass("act2")
  298.             }, function() {
  299.                 if (e(this).children(".item.active").length == 0) {
  300.                     e(this).removeClass("act2")
  301.                 }
  302.             });
  303.             e(".size_qty, #select_font_size, #h-shadow, #v-shadow, #t-blur").ForceNumericOnly();
  304.             var n = e("#t-shirt-type").val(),
  305.                 r;
  306.             if (e("#pdp_sides li.active").length > 0) {
  307.                 r = e("#pdp_sides li.active")
  308.             } else {
  309.                 r = e("#pdp_sides li:eq(0)")
  310.             } if (e(".design-color-image li").length > 0) {
  311.                 e(".design-color-image ul").prepend('<li class="pdp_color_original" name=""><img src="' + t + 'js/pdp/images/button-close.png" /></li>')
  312.             }
  313.             e("#pdp_sides li").each(function() {
  314.                 e("#pdp_info_to_action").append('<input type="hidden" class="pdp_info_save" alt="' + e(this).attr("tab") + '" id="pdp_info_' + e(this).attr("tab") + '" />');
  315.                 e(".pdp_color_original").attr(e(this).attr("tab"), e(this).attr("side_img"))
  316.             });
  317.             e(".design-color-image li").click(function() {
  318.                 var t = e(this).attr("price"),
  319.                     n = e(this).attr("name");
  320.                 e(".color-option .color_name").html(n);
  321.                 e(".design-color-image li.active").removeClass("active");
  322.                 e(this).addClass("active");
  323.                 PDPsetting.change_color()
  324.             });
  325.             e("#pdp_sides li").click(function() {
  326.                 PDPAction.save_cr_design();
  327.                 if (!e(this).hasClass("active")) {
  328.                     e("#pdp_sides li.active").removeClass("active");
  329.                     e(this).addClass("active");
  330.                     PDPsetting.change_side()
  331.                 }
  332.             });
  333.             PDPsetting.position_color();
  334.             e("html").on("click", function(t) {
  335.                 var n = e(".wrap_pdp_design #wrap_inlay .item, #design_control, .color_att, .color_content").has(t.target).length;
  336.                 if (n === 0) {
  337.                     e(".product-image .active").removeClass("active");
  338.                     e(".color_att li").hide();
  339.                     e("#edit_item_wrap").hide();
  340.                     a()
  341.                 }
  342.             });
  343.             var s = e('input[name="extra_options"]').val();
  344.             if (e("#cart_item_id").val() == "" && e("#wishlist_item_id").val() == "") {
  345.                 if (e("input[name='pdp_design_string']").length) {
  346.                     s = e("input[name='pdp_design_string']").val()
  347.                 }
  348.             }
  349.             r.addClass("active");
  350.             if (s != "" && s !== undefined) {
  351.                 var o = JSON.parse(s);
  352.                 if (o.length > 0) {
  353.                     for (i = 0; i < o.length; i++) {
  354.                         e("#pdp_info_" + o[i].name).val(o[i].json);
  355.                         e(".design-color-image li#" + o[i].color).click()
  356.                     }
  357.                 }
  358.             } else {
  359.                 PDPsetting.save_first_design()
  360.             }
  361.             PDPsetting.change_side()
  362.         },
  363.         init_cr_item: function() {
  364.             if (e(".wrap_inlay .item").length > 0) {
  365.                 if (e(".design-color-image li.active").length > 0) {
  366.                     e(".design-color-image li.active").click()
  367.                 } else {
  368.                     e("#list_color li.active").click()
  369.                 }
  370.                 e(".wrap_inlay .item").each(function() {
  371.                     PDPsetting.init_design(e(this))
  372.                 })
  373.             }
  374.         },
  375.         init_design: function(t) {
  376.             var r = -1 * t.attr("angle2"),
  377.                 i = t.attr("scy"),
  378.                 s = t.attr("scx");
  379.             t.prepend('<div class="ui-close">X</div>');
  380.             t.find(".ui-close").click(function() {
  381.                 e(".overlay-btn").removeClass("send-back");
  382.                 t.remove()
  383.             });
  384.             if (t.hasClass("image_item")) {
  385.                 t.children("img").css({
  386.                     "-moz-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  387.                     "-o-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  388.                     "-webkit-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  389.                     "-ms-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  390.                     transform: "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")"
  391.                 });
  392.                 t.draggable({
  393.                     start: function() {
  394.                         var n = e(".product-image.act").attr("z_index"),
  395.                             r = t.find("img").attr("rel");
  396.                         n++;
  397.                         e(".color_att li[rel!=" + r + "]").hide();
  398.                         e(".color_att li[rel=" + r + "]").show();
  399.                         e(".product-image.act").attr("z_index", n);
  400.                         e(".product-image .active").removeClass("active");
  401.                         t.addClass("active").css({
  402.                             "z-index": n
  403.                         }).find("img").attr("rel", r);
  404.                         a()
  405.                     },
  406.                     drag: function() {
  407.                         var n = parseInt(t.css("left")) + parseInt(t.width()) / 2,
  408.                             r = parseInt(t.css("top")) + parseInt(t.height()) / 2;
  409.                         t.attr("pos", n + "," + r);
  410.                         e(".overlay-btn").removeClass("send-back");
  411.                         e("#edit_item_wrap").show()
  412.                     }
  413.                 });
  414.                 t.rotatable();
  415.                 t.resizable({
  416.                     aspectRatio: true,
  417.                     handles: "se",
  418.                     start: function() {},
  419.                     resize: function(n) {
  420.                         e("#edit_item_wrap").show();
  421.                         var r = t.find("img").attr("rel");
  422.                         e(".color_att li[rel!=" + r + "]").hide();
  423.                         e(".color_att li[rel=" + r + "]").show();
  424.                         var i = parseFloat(t.find("img").css("left")),
  425.                             s = parseFloat(t.find("img").css("top")),
  426.                             o = t.width(),
  427.                             u = t.height(),
  428.                             a = t.attr("angle2"),
  429.                             f = parseFloat(t.css("left")) + parseFloat(t.width()) / 2,
  430.                             l = parseFloat(t.css("top")) + parseFloat(t.height()) / 2;
  431.                         if (a % 45 == 0 || a % 90 == 0) {
  432.                             a = a + 1e-9
  433.                         }
  434.                         var c = a * Math.PI / 180;
  435.                         var h = Math.cos(c);
  436.                         var p = Math.sin(c);
  437.                         if (h < 0) {
  438.                             h = -h
  439.                         }
  440.                         if (p < 0) {
  441.                             p = -p
  442.                         }
  443.                         var d = (o * h - u * p) / (h * h - p * p),
  444.                             v = (u - d * p) / h,
  445.                             m = o - d,
  446.                             g = u - v;
  447.                         t.attr("pos", f + "," + l);
  448.                         t.find("img").width(d).height(v).css({
  449.                             left: (o - d) / 2,
  450.                             top: (u - v) / 2
  451.                         });
  452.                         e(".overlay-btn").removeClass("send-back");
  453.                         t.attr("w", d).attr("h", v)
  454.                     }
  455.                 });
  456.                 t.click(function() {
  457.                     e("#edit_item_wrap").show();
  458.                     var n = e(".product-image.act").attr("z_index");
  459.                     n++;
  460.                     var r = t.find("img").attr("rel");
  461.                     e(".color_att li[rel!=" + r + "]").hide();
  462.                     e(".color_att li[rel=" + r + "]").show();
  463.                     e(".product-image.act").attr("z_index", n);
  464.                     e(".product-image.act .active").removeClass("active");
  465.                     t.addClass("active").css({
  466.                         "z-index": n
  467.                     });
  468.                     a()
  469.                 })
  470.             } else {
  471.                 t.children("p").css({
  472.                     "-moz-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  473.                     "-o-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  474.                     "-webkit-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  475.                     "-ms-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
  476.                     transform: "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")"
  477.                 });
  478.                 t.draggable({
  479.                     containment: "",
  480.                     start: function() {
  481.                         e("#edit_item_wrap").show();
  482.                         var n = e(".product-image.act").attr("z_index");
  483.                         n++;
  484.                         e(".product-image.act").attr("z_index", n);
  485.                         e(".product-image .active").removeClass("active");
  486.                         t.addClass("active").css({
  487.                             "z-index": n
  488.                         });
  489.                         u(t.children("p"))
  490.                     },
  491.                     drag: function() {
  492.                         var n = parseInt(t.css("left")) + parseInt(t.width()) / 2,
  493.                             r = parseInt(t.css("top")) + parseInt(t.height()) / 2;
  494.                         e(".overlay-btn").removeClass("send-back");
  495.                         t.attr("pos", n + "," + r)
  496.                     }
  497.                 });
  498.                 t.rotatabletext();
  499.                 t.resizable({
  500.                     aspectRatio: true,
  501.                     handles: "se",
  502.                     start: function() {},
  503.                     resize: function(r) {
  504.                         e("#edit_item_wrap").show();
  505.                         var i = parseFloat(t.find("p").css("left")),
  506.                             s = parseFloat(t.find("p").css("top")),
  507.                             o = t.width(),
  508.                             u = t.height(),
  509.                             a = t.attr("angle2"),
  510.                             f = parseFloat(t.css("left")) + parseFloat(t.width()) / 2,
  511.                             l = parseFloat(t.css("top")) + parseFloat(t.height()) / 2;
  512.                         if (a % 45 == 0 || a % 90 == 0) {
  513.                             a = a + 1e-9
  514.                         }
  515.                         var c = a * Math.PI / 180;
  516.                         var h = Math.cos(c);
  517.                         var p = Math.sin(c);
  518.                         if (h < 0) {
  519.                             h = -h
  520.                         }
  521.                         if (p < 0) {
  522.                             p = -p
  523.                         }
  524.                         var d = (o * h - u * p) / (h * h - p * p),
  525.                             v = (u - d * p) / h,
  526.                             m = o - d,
  527.                             g = u - v;
  528.                         t.attr("pos", f + "," + l);
  529.                         t.find("p").css({
  530.                             left: (o - d) / 2,
  531.                             top: (u - v) / 2
  532.                         });
  533.                         n(t.children("p"), d, v, 20);
  534.                         e(".overlay-btn").removeClass("send-back");
  535.                         t.attr("w", d).attr("h", v)
  536.                     }
  537.                 });
  538.                 t.click(function() {
  539.                     e("#edit_item_wrap").show();
  540.                     var n = e(".product-image.act").attr("z_index");
  541.                     n++;
  542.                     e(".product-image.act").attr("z_index", n);
  543.                     e(".product-image .active").removeClass("active");
  544.                     t.addClass("active").css({
  545.                         "z-index": n
  546.                     });
  547.                     u(t.children("p"))
  548.                 })
  549.             }
  550.         }
  551.     };
  552.     PDPsetting.add_html();
  553.     PDPsetting.init();
  554.     e("#add_text_input").click(function() {
  555.         e(".image_item.active").removeClass("active")
  556.     });
  557.     e(".tshirt-size input").change(function() {
  558.         if (e(this).val() == "" || e(this).val() < 0) {
  559.             e(this).val(0)
  560.         }
  561.         e(this).val(parseInt(e(this).val()))
  562.     });
  563.     e("#design_control .control_tab .tab_main").click(function() {
  564.         var t = e(this).attr("tab");
  565.         e("#design_control .control_tab .tab_main.active").removeClass("active");
  566.         e(this).addClass("active");
  567.         e(".tab_content").hide();
  568.         e("." + t).show()
  569.     });
  570.     e(".tab_design_image a").click(function() {
  571.         e(".tab_design_image .active").removeClass("active");
  572.         e(this).addClass("active");
  573.         var t = e(this).attr("tab-content");
  574.         e(".content_tab > div").hide();
  575.         e(".content_tab ." + t).show()
  576.     });
  577.     a();
  578.     e("#move_item .m_tl").click(function() {
  579.         e(".item.active").animate({
  580.             left: 0
  581.         }, 600, function() {
  582.             e(".item.active").animate({
  583.                 top: 0
  584.             }, 600);
  585.             var t = parseInt(e(".item.active").width()) / 2,
  586.                 n = parseInt(e(".item.active").height()) / 2;
  587.             e(".item.active").attr("pos", t + "," + n)
  588.         });
  589.         e(".overlay-btn").removeClass("send-back")
  590.     });
  591.     e("#move_item .m_tr").click(function() {
  592.         var t = e(".product-image.act .wrap_inlay").width(),
  593.             n = e(".item.active").width(),
  594.             r = e(".item.active").height(),
  595.             i = t - n / 2,
  596.             s = r / 2;
  597.         e(".item.active").animate({
  598.             left: parseFloat(t - n - 2) + "px"
  599.         }, 600, function() {
  600.             e(".item.active").animate({
  601.                 top: 0
  602.             }, 600)
  603.         });
  604.         e(".overlay-btn").removeClass("send-back");
  605.         e(".item.active").attr("pos", i + "," + s)
  606.     });
  607.     e("#move_item .m_bl").click(function() {
  608.         var t = e(".product-image.act .wrap_inlay").height(),
  609.             n = e(".item.active").height(),
  610.             r = e(".item.active").width(),
  611.             i = r / 2,
  612.             s = t - n / 2;
  613.         e(".item.active").animate({
  614.             left: 0
  615.         }, 600, function() {
  616.             e(".item.active").animate({
  617.                 top: parseFloat(t - n - 2) + "px"
  618.             }, 600)
  619.         });
  620.         e(".overlay-btn").removeClass("send-back");
  621.         e(".item.active").attr("pos", i + "," + s)
  622.     });
  623.     e("#move_item .m_br").click(function() {
  624.         var t = e(".product-image.act .wrap_inlay").height(),
  625.             n = e(".item.active").height(),
  626.             r = e(".product-image.act .wrap_inlay").width(),
  627.             i = e(".item.active").width(),
  628.             s = r - i / 2,
  629.             o = t - n / 2;
  630.         e(".item.active").animate({
  631.             left: parseFloat(r - i - 2) + "px"
  632.         }, 600, function() {
  633.             e(".item.active").animate({
  634.                 top: parseFloat(t - n - 2) + "px"
  635.             }, 600)
  636.         });
  637.         e(".overlay-btn").removeClass("send-back");
  638.         e(".item.active").attr("pos", s + "," + o)
  639.     });
  640.     e("#move_item .m_tc").click(function() {
  641.         var t = e(".product-image.act .wrap_inlay").height(),
  642.             n = e(".item.active").height(),
  643.             r = e(".product-image.act .wrap_inlay").width(),
  644.             i = e(".item.active").width(),
  645.             s = r / 2,
  646.             o = n / 2;
  647.         e(".item.active").animate({
  648.             left: parseFloat(r - i - 2) / 2 + "px"
  649.         }, 600, function() {
  650.             e(".item.active").animate({
  651.                 top: 0
  652.             }, 600)
  653.         });
  654.         e(".overlay-btn").removeClass("send-back");
  655.         e(".item.active").attr("pos", s + "," + o)
  656.     });
  657.     e("#move_item .m_cr").click(function() {
  658.         var t = e(".product-image.act .wrap_inlay").height(),
  659.             n = e(".item.active").height(),
  660.             r = e(".product-image.act .wrap_inlay").width(),
  661.             i = e(".item.active").width(),
  662.             s = r - i / 2,
  663.             o = t / 2;
  664.         e(".item.active").animate({
  665.             left: parseFloat(r - i - 2) + "px"
  666.         }, 600, function() {
  667.             e(".item.active").animate({
  668.                 top: parseFloat(t - n - 2) / 2 + "px"
  669.             }, 600)
  670.         });
  671.         e(".overlay-btn").removeClass("send-back");
  672.         e(".item.active").attr("pos", s + "," + o)
  673.     });
  674.     e("#move_item .m_cl").click(function() {
  675.         var t = e(".product-image.act .wrap_inlay").height(),
  676.             n = e(".item.active").height(),
  677.             r = e(".product-image.act .wrap_inlay").width(),
  678.             i = e(".item.active").width(),
  679.             s = i / 2,
  680.             o = t / 2;
  681.         e(".item.active").animate({
  682.             left: 0
  683.         }, 600, function() {
  684.             e(".item.active").animate({
  685.                 top: parseFloat(t - n - 2) / 2 + "px"
  686.             }, 600)
  687.         });
  688.         e(".overlay-btn").removeClass("send-back");
  689.         e(".item.active").attr("pos", s + "," + o)
  690.     });
  691.     e("#move_item .m_bc").click(function() {
  692.         var t = e(".product-image.act .wrap_inlay").height(),
  693.             n = e(".item.active").height(),
  694.             r = e(".product-image.act .wrap_inlay").width(),
  695.             i = e(".item.active").width(),
  696.             s = r / 2,
  697.             o = t - n / 2;
  698.         e(".item.active").animate({
  699.             left: parseFloat(r - i - 2) / 2 + "px"
  700.         }, 600, function() {
  701.             e(".item.active").animate({
  702.                 top: parseFloat(t - n - 2) + "px"
  703.             }, 600)
  704.         });
  705.         e(".overlay-btn").removeClass("send-back");
  706.         e(".item.active").attr("pos", s + "," + o)
  707.     });
  708.     e("#move_item .m_cc").click(function() {
  709.         var t = e(".product-image.act .wrap_inlay").height(),
  710.             n = e(".item.active").height(),
  711.             r = e(".product-image.act .wrap_inlay").width(),
  712.             i = e(".item.active").width(),
  713.             s = r / 2,
  714.             o = t / 2;
  715.         e(".item.active").animate({
  716.             left: parseFloat(r - i - 2) / 2 + "px"
  717.         }, 600, function() {
  718.             e(".item.active").animate({
  719.                 top: parseFloat(t - n - 2) / 2 + "px"
  720.             }, 600)
  721.         });
  722.         e(".overlay-btn").removeClass("send-back");
  723.         e(".item.active").attr("pos", s + "," + o)
  724.     });
  725.     e("#duplicate_item span").click(function() {
  726.         e(".product-image.act .item.last").removeClass("last");
  727.         var t = parseFloat(e(".product-image.act .item.active").css("left"));
  728.         var n = parseFloat(e(".product-image.act .item.active").css("top"));
  729.         t += 10;
  730.         n += 10;
  731.         e(".product-image.act .item.active").clone(false).appendTo(e(".product-image.act .wrap_inlay")).addClass("last").css({
  732.             left: t + "px",
  733.             top: n + "px"
  734.         });
  735.         e(".product-image.act .item.active").removeClass("active");
  736.         e(".item.last").addClass("active").children(".ui-rotatable-handle, .ui-resizable-handle").remove();
  737.         PDPsetting.init_design(e(".item.last"))
  738.     });
  739.     e("#delete_item span").click(function() {
  740.         e(".product-image.act .item.active").remove();
  741.         e(".wrap_inlay").removeClass("act2");
  742.         e("#edit_item_wrap").hide()
  743.     });
  744.     e("#flip_items .flip_x").click(function() {
  745.         var t = e(".item.active").attr("angle2"),
  746.             n = e(".item.active").attr("scx"),
  747.             r = e(".item.active").attr("scy"),
  748.             i = -1 * t;
  749.         if (e(".item.active").hasClass("image_item")) {
  750.             e(".item.active").attr("scx", n * -1);
  751.             e(".item.active").children("img").css({
  752.                 "-moz-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  753.                 "-o-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  754.                 "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  755.                 "-ms-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  756.                 transform: "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")"
  757.             })
  758.         } else {
  759.             e(".item.active").attr("scx", n * -1);
  760.             e(".item.active").children("p").css({
  761.                 "-moz-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  762.                 "-o-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  763.                 "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  764.                 "-ms-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
  765.                 transform: "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")"
  766.             })
  767.         }
  768.         e(".overlay-btn").removeClass("send-back")
  769.     });
  770.     e("#flip_items .flip_y").click(function() {
  771.         var t = e(".item.active").attr("angle2"),
  772.             n = e(".item.active").attr("scx"),
  773.             r = e(".item.active").attr("scy"),
  774.             i = -1 * t;
  775.         if (e(".item.active").hasClass("image_item")) {
  776.             e(".item.active").attr("scy", r * -1);
  777.             e(".item.active").children("img").css({
  778.                 "-moz-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  779.                 "-o-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  780.                 "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  781.                 "-ms-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  782.                 transform: "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")"
  783.             })
  784.         } else {
  785.             e(".item.active").attr("scy", r * -1);
  786.             e(".item.active").children("p").css({
  787.                 "-moz-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  788.                 "-o-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  789.                 "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  790.                 "-ms-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
  791.                 transform: "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")"
  792.             })
  793.         }
  794.         e(".overlay-btn").removeClass("send-back")
  795.     });
  796.     e("#add_text_action").click(function() {
  797.         var t = e(".product-image.act").attr("z_index");
  798.         t++;
  799.         e(".product-image.act").attr("z_index", t);
  800.         var n = e("#add_text_input").val(),
  801.             r = "normal",
  802.             i = "normal",
  803.             s = "none",
  804.             o = "left",
  805.             a = e("#arc_text_input").val(),
  806.             f = e.trim(e("#select_font_span").html()),
  807.             l = e.trim(e("#select_font_size").val()),
  808.             c = e("#font_color_div > div").css("backgroundColor");
  809.         if (e("#change_text_type a.bold").hasClass("active")) {
  810.             r = "bold"
  811.         }
  812.         if (e("#change_text_type a.italic").hasClass("active")) {
  813.             i = "italic"
  814.         }
  815.         if (e("#change_text_type a.underline").hasClass("active")) {
  816.             s = "underline"
  817.         }
  818.         if (e("#change_text_type a.align_left").hasClass("active")) {
  819.             o = "left"
  820.         }
  821.         if (e("#change_text_type a.align_center").hasClass("active")) {
  822.             o = "center"
  823.         }
  824.         if (e("#change_text_type a.align_right").hasClass("active")) {
  825.             o = "right"
  826.         }
  827.         if (e("#change_text_type a.align_justify").hasClass("active")) {
  828.             o = "justify"
  829.         }
  830.         if (n != "") {
  831.             e(".product-image .active").removeClass("active");
  832.             e(".text-image.last").removeClass("last");
  833.             e(".product-image.act .wrap_inlay").append('<div class="item text-image last active uncheck" angle2="0" scx="1" scy="1" style="left: 0; top: 0; position: absolute; text-align:' + o + "; z-index:" + t + ';"><p style="white-space: pre; font-weight: ' + r + "; font-size: " + l + "px; line-height: 1.5; padding: 10px; float: left; color: " + c + "; text-decoration:" + s + "; margin: 0; font-family: " + f + '; background: transparent;">' + n + "</p></div>");
  834.             var h = e(".text-image.last");
  835.             h.attr("pos", h.width() / 2 + "," + h.height() / 2).attr("w", h.width()).attr("h", h.height());
  836.             if (e("#use_shadow").is(":checked")) {
  837.                 h.css({
  838.                     "text-shadow": e("#h-shadow").val() + "px " + e("#v-shadow").val() + "px " + e("#t-blur").val() + "px " + e("#font_outline_color > div").css("backgroundColor")
  839.                 })
  840.             }
  841.             e(".text-image.last").rotatabletext();
  842.             e("#edit_item_wrap, .arc_text").show();
  843.             e("#add_text_action").hide();
  844.             e("#edit_text_action").show();
  845.             e("#edit_item_wrap").show();
  846.             PDPsetting.init_design(e(".text-image.last"));
  847.             e(".text-image.last").click(function() {
  848.                 e("#edit_item_wrap").show();
  849.                 var t = e(".product-image.act").attr("z_index");
  850.                 t++;
  851.                 e(".product-image.act").attr("z_index", t);
  852.                 e(".product-image .active").removeClass("active");
  853.                 e(this).addClass("active").css({
  854.                     "z-index": t
  855.                 });
  856.                 u(e(this).children("p"))
  857.             })
  858.         }
  859.         e(".overlay-btn").removeClass("send-back")
  860.     });
  861.     e("#use_shadow").click(function() {
  862.         if (e(this).is(":checked")) {
  863.             e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape  .blur,.font_shape  .color").show()
  864.         } else {
  865.             e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape  .blur,.font_shape  .color").hide()
  866.         } if (e(".product-image.act .text-image.active").length > 0) {
  867.             s(e(".text-image.active p"))
  868.         }
  869.         e(".overlay-btn").removeClass("send-back")
  870.     });
  871.     e(".change_font .next_t").click(function() {
  872.         var t = e(this).prev().val();
  873.         e(this).prev().val(parseInt(t) + 1);
  874.         if (e(".product-image.act .text-image.active").length > 0) {
  875.             s(e(".text-image.active p"))
  876.         }
  877.         e(".overlay-btn").removeClass("send-back")
  878.     });
  879.     e(".change_font .prev_t").click(function() {
  880.         var t = e(this).next().val();
  881.         if (e(this).next().attr("id") == "t-blur" && t == 0) {} else {
  882.             if (e(this).next().attr("id") == "select_font_size" && t < 3) {} else {
  883.                 e(this).next().val(parseInt(t) - 1);
  884.                 if (e(".product-image.act .text-image.active").length > 0) {
  885.                     s(e(".text-image.active p"))
  886.                 }
  887.             }
  888.         }
  889.         e(".overlay-btn").removeClass("send-back")
  890.     });
  891.     e("#add_text_input").keyup(function() {
  892.         if (e(".product-image.act .text-image.active").length > 0) {
  893.             e(".text-image.active p").html(e(this).val());
  894.             if (e(this).val() == "") {
  895.                 e(".text-image.active").remove()
  896.             } else {
  897.                 s(e(".text-image.active p"))
  898.             }
  899.         } else {
  900.             if (e(this).val() != "") {
  901.                 e("#add_text_action").click()
  902.             }
  903.         }
  904.         e(".overlay-btn").removeClass("send-back")
  905.     });
  906.     e("#change_text_type a.text").click(function() {
  907.         e(this).toggleClass("active");
  908.         if (e(".product-image.act .text-image.active").length > 0) {
  909.             s(e(".text-image.active p"))
  910.         }
  911.         e(".overlay-btn").removeClass("send-back")
  912.     });
  913.     e("#change_text_type a.align").click(function() {
  914.         e("#change_text_type a.align.active").removeClass("active");
  915.         e(this).toggleClass("active");
  916.         if (e(".product-image.act .text-image.active").length > 0) {
  917.             s(e(".text-image.active p"))
  918.         }
  919.         e(".overlay-btn").removeClass("send-back")
  920.     });
  921.     e("#select_font_size, #h-shadow, #v-shadow, #t-blur").change(function() {
  922.         if (e(".product-image.act .text-image.active").length > 0) {
  923.             s(e(".text-image.active p"))
  924.         }
  925.         e(".overlay-btn").removeClass("send-back")
  926.     });
  927.     e("#font_color_div, #font_outline_color").click(function() {
  928.         e(".color_content").show();
  929.         e(".color_display, .color_content li a.act").removeClass("act");
  930.         e(this).find(".color_display").addClass("act");
  931.         var t = e(this).find(".color_display").css("background-color");
  932.         e(".color_content li a").each(function() {
  933.             if (e(this).css("background-color") == t) {
  934.                 e(this).addClass("act");
  935.                 e("#selected_color").val(r(t));
  936.                 e("a.selected_color").css("background-color", t)
  937.             }
  938.         })
  939.     });
  940.     e(".inlay_div.color, .color_content_wrap .bt_done").click(function() {
  941.         e(".color_content").hide();
  942.         e(".color_display").removeClass("act")
  943.     });
  944.     e(".color_content li a:not(.selected_color, .bt_done)").click(function() {
  945.         e(".color_content li a.act").removeClass("act");
  946.         e(this).addClass("act");
  947.         var t = e(this).css("background-color");
  948.         e(".color_display.act").css("background-color", t);
  949.         e("#selected_color").val(r(t));
  950.         if (e("#font_color_div .color_display").hasClass("act")) {
  951.             e(".text-image.active p").css("color", t)
  952.         }
  953.         if (e("#font_outline_color .color_display").hasClass("act")) {
  954.             var n = e("#h-shadow").val(),
  955.                 i = e("#v-shadow").val(),
  956.                 s = e("#t-blur").val();
  957.             e(".text-image.active p").css("text-shadow", n + "px " + i + "px " + s + "px " + t)
  958.         }
  959.         e("a.selected_color").css("background-color", t)
  960.     });
  961.     e("#selected_color").change(function() {
  962.         e("a.selected_color").css("background-color", "#" + e(this).val())
  963.     });
  964.     e("#select_font_span").click(function() {
  965.         e("#select_font").show()
  966.     });
  967.     e(".box_text").hover(function() {}, function() {
  968.         e("#select_font").hide()
  969.     });
  970.     e("#select_font").hover(function() {
  971.         e(this).show()
  972.     }, function() {
  973.         e(this).hide()
  974.     });
  975.     e("#select_font li").each(function() {
  976.         e(this).css("font-family", e(this).attr("rel"))
  977.     });
  978.     e("#select_font li").click(function() {
  979.         e("#select_font").hide();
  980.         e("#select_font_span").css("font-family", e(this).attr("rel")).html(e(this).attr("rel"));
  981.         if (e(".product-image.act .text-image.active").length > 0) {
  982.             s(e(".text-image.active p"))
  983.         }
  984.     });
  985.     var o = 1;
  986.     e("#select_image img").each(function() {});
  987.     e(".color_att").on("click", "li", function() {
  988.         var t = e(this).attr("isrc"),
  989.             n = e("#" + t).attr("src");
  990.         e(".image_item.active img").attr("src", n)
  991.     });
  992.     e("#icon_list, #lists_img_upload, #photos_album").on("click", "img", function() {
  993.         var n = e(".product-image.act").attr("z_index");
  994.         n++;
  995.         e(".color_att li").hide();
  996.         e(".product-image.act").attr("z_index", n);
  997.         var r = e(this).attr("src"),
  998.             i = e(this).attr("id"),
  999.             s = e(this).attr("color");
  1000.         if (s != "") {
  1001.             var o = s.split(",");
  1002.             if (!e(this).hasClass("loaded")) {
  1003.                 e(this).addClass("loaded");
  1004.                 e(".product-img-box .color_att").append('<li class="ori_img" rel="' + i + '" isrc="' + i + '"><a iid="' + i + '">&nbsp;</a></li>');
  1005.                 for (ii = 0; ii < o.length; ii++) {
  1006.                     var u = o[ii].split("-");
  1007.                     e(".product-img-box .color_att").append('<li isrc="img_color_' + i + "_" + ii + '" rel="' + i + '" style="background: #' + u[0] + '"><a iid="' + i + '">' + u[0] + "</a></li>");
  1008.                     e("#save_original_img_text").append('<img id="img_color_' + i + "_" + ii + '" src="' + t + "media/pdp/images/artworks/" + u[1] + '" />')
  1009.                 }
  1010.             } else {
  1011.                 e(".color_att li[rel=" + i + "]").show()
  1012.             }
  1013.         }
  1014.         e(".image_item.last").removeClass("last");
  1015.         e("#edit_item_wrap").show();
  1016.         e(".product-image .active").removeClass("active");
  1017.         e(".wrapper_pdp .product-image.act .wrap_inlay").append('<div angle2="0" h="70" scx="1" scy="1" class="item image_item last active" style="left: 0; top: 0; position: absolute; z-index:' + n + ';"><img rel="' + i + '" src="' + r + '" /></div>');
  1018.         if (e(this).hasClass("thumb")) {
  1019.             e(".image_item.last img").addClass("img_up")
  1020.         }
  1021.         e(".image_item.last").find("img").height(70).attr("rel", i).css({
  1022.             left: 0,
  1023.             top: 0,
  1024.             position: "absolute"
  1025.         });
  1026.         e(".image_item.last").height(70);
  1027.         width_img = e(".image_item.last").children("img").width();
  1028.         e(".image_item.last").width(width_img);
  1029.         e(".image_item.last").attr("w", width_img).attr("pos", width_img / 2 + "," + 35);
  1030.         PDPsetting.init_design(e(".image_item.last"));
  1031.         e(".overlay-btn").removeClass("send-back")
  1032.     });
  1033.     e("#save_design_btn_not_login").click(function() {
  1034.         window.location = e("#login_url").val()
  1035.     });
  1036.     e("body").keypress(function(t) {
  1037.         var n = t.keyCode || t.which;
  1038.         var r = e(".item.active").length;
  1039.         if (r > 0) {
  1040.             switch (n) {
  1041.                 case 46:
  1042.                     if (!e(".item.active").hasClass("text-image")) {
  1043.                         e(".item.active").remove()
  1044.                     }
  1045.                     break;
  1046.                 case 37:
  1047.                     if (!e(".item.active").hasClass("text-image")) {
  1048.                         var i = e(".item.active").position();
  1049.                         e(".item.active").css("left", i.left - 1 + "px");
  1050.                         return false
  1051.                     }
  1052.                     break;
  1053.                 case 38:
  1054.                     if (!e(".item.active").hasClass("text-image")) {
  1055.                         var i = e(".item.active").position();
  1056.                         e(".item.active").css("top", i.top - 1 + "px");
  1057.                         return false
  1058.                     }
  1059.                     break;
  1060.                 case 39:
  1061.                     if (!e(".item.active").hasClass("text-image")) {
  1062.                         var i = e(".item.active").position();
  1063.                         e(".item.active").css("left", i.left + 1 + "px");
  1064.                         return false
  1065.                     }
  1066.                     break;
  1067.                 case 40:
  1068.                     if (!e(".item.active").hasClass("text-image")) {
  1069.                         var i = e(".item.active").position();
  1070.                         e(".item.active").css("top", i.top + 1 + "px");
  1071.                         return false
  1072.                     }
  1073.                     break
  1074.             }
  1075.             e(".overlay-btn").removeClass("send-back")
  1076.         }
  1077.     });
  1078.     e("#files_upload").hover(function() {
  1079.         if (!e(this).hasClass("active")) {
  1080.             document.getElementById("files_upload").addEventListener("change", f, false);
  1081.             e(this).addClass("active")
  1082.         }
  1083.     });
  1084.     e("#lists_img_upload2").hover(function() {
  1085.         var t = 0;
  1086.         e("#lists_img_upload span img").each(function() {
  1087.             t++;
  1088.             e(this).attr("id", "img_upload_" + t).attr("color", "")
  1089.         })
  1090.     });
  1091.     if (e("#fb_get_id").val() != "") {
  1092.         e(".add_artwork_tab").click();
  1093.         e(".tab_design_image .facebook_api").click()
  1094.     }
  1095.     e("#facebook_album").change(function() {
  1096.         var t = e(this).val();
  1097.         e("#fb_image_list li:not(." + t + ")").hide();
  1098.         e("#fb_image_list li.fb_album_" + t).show()
  1099.     });
  1100.     var l = t;
  1101.     var c = l + "media/pdp/images/artworks/";
  1102.     e(".content_designs").append('<span class="loading-img no-display">&nbsp;</span>');
  1103.     Paging = {
  1104.         init: function() {
  1105.             this.loadMoreImage();
  1106.             this.filterByCategory()
  1107.         },
  1108.         loadMoreImage: function() {
  1109.             e("#load_more_image").click(function() {
  1110.                 var t = e("#image_category_list li.active").attr("cr_act");
  1111.                 var n = e("#image_category_list li.active span").attr("id");
  1112.                 var r = e("#default_page_size").val();
  1113.                 e.ajax({
  1114.                     type: "POST",
  1115.                     url: l + "index.php/pdp/index/loadMoreImage",
  1116.                     data: {
  1117.                         current_page: t,
  1118.                         category: n,
  1119.                         page_size: r
  1120.                     },
  1121.                     beforeSend: function() {
  1122.                         e(".content_designs .loading-img").show()
  1123.                     },
  1124.                     error: function() {},
  1125.                     success: function(n) {
  1126.                         if (n != "nomore") {
  1127.                             e("#image_category_list li.active").attr("cr_act", parseInt(t) + 1);
  1128.                             var r = e.parseJSON(n);
  1129.                             var i = "";
  1130.                             for (var s = 0; s < r.length; s++) {
  1131.                                 i += "<li cat='" + r[s].category + "'> <a class='selection_img' rel='clover'><img color='" + r[s].color_img + "' src='" + c + r[s].filename + "' id='img" + r[s].image_id + "'/></a> </li>"
  1132.                             }
  1133.                             e("#icon_list").append(i)
  1134.                         } else {
  1135.                             alert("No more items to load!")
  1136.                         }
  1137.                         e(".content_designs .loading-img").hide()
  1138.                     }
  1139.                 })
  1140.             })
  1141.         },
  1142.         filterByCategory: function() {
  1143.             e("#image_category_list li").click(function() {
  1144.                 e("#image_category_list li.active").removeClass("active");
  1145.                 e(this).addClass("active");
  1146.                 e("#icon_list li[cat!=" + e(this).children("span").attr("id") + "]").hide();
  1147.                 e("#icon_list li[cat=" + e(this).children("span").attr("id") + "]").show();
  1148.                 if (!e(this).hasClass("cat_loaded")) {
  1149.                     e(this).addClass("cat_loaded");
  1150.                     var t = 2,
  1151.                         n = e("#image_category_list li.active span").attr("id"),
  1152.                         r = e("#default_page_size").val(),
  1153.                         i = parseInt(t - 1) * parseInt(r);
  1154.                     e.ajax({
  1155.                         type: "POST",
  1156.                         url: l + "index.php/pdp/index/loadMoreImage",
  1157.                         data: {
  1158.                             current_page: 1,
  1159.                             category: n,
  1160.                             page_size: i
  1161.                         },
  1162.                         beforeSend: function() {
  1163.                             e(".content_designs .loading-img").show()
  1164.                         },
  1165.                         error: function() {},
  1166.                         success: function(t) {
  1167.                             if (t != "nomore") {
  1168.                                 var n = e.parseJSON(t);
  1169.                                 var r = "";
  1170.                                 for (var i = 0; i < n.length; i++) {
  1171.                                     r += "<li cat='" + n[i].category + "'> <a class='selection_img' rel='clover'><img color='" + n[i].color_img + "' src='" + c + n[i].filename + "' id='img" + n[i].image_id + "'/></a> </li>"
  1172.                                 }
  1173.                                 e("#icon_list").append(r);
  1174.                                 e("#image_category_list li.active").attr("cr_act", 2)
  1175.                             } else {
  1176.                                 alert("No more items to load!")
  1177.                             }
  1178.                             e(".content_designs .loading-img").hide()
  1179.                         }
  1180.                     })
  1181.                 }
  1182.             })
  1183.         }
  1184.     };
  1185.     Paging.init();
  1186.     PdpShare = {
  1187.         doRequest: function(t, n, r) {
  1188.             e.ajax({
  1189.                 type: "POST",
  1190.                 url: t,
  1191.                 data: n,
  1192.                 beforeSend: function() {
  1193.                     e(".pdploading").show()
  1194.                 },
  1195.                 error: function() {
  1196.                     console.log("Something went wrong...")
  1197.                 },
  1198.                 success: function(t) {
  1199.                     r(t);
  1200.                     e(".pdploading").hide()
  1201.                 }
  1202.             })
  1203.         },
  1204.         saveBeforeShare: function(t) {
  1205.             var n = e("#save_design_url").val(),
  1206.                 r = e("#product_url").val(),
  1207.                 i = {
  1208.                     pdpdesign: t,
  1209.                     url: r
  1210.                 };
  1211.             this.doRequest(n, i, this.activeAddThis)
  1212.         },
  1213.         activeAddThis: function(t) {
  1214.             var n = e.parseJSON(t);
  1215.             for (var r = 0; r < addthis.links.length; r++) {
  1216.                 addthis.links[r].share.url = n.url
  1217.             }
  1218.             e(".social-bottom .overlay-btn").addClass("send-back")
  1219.         },
  1220.         shareClick: function() {
  1221.             var t;
  1222.             e("#save_before_share").on("click", function() {
  1223.                 shareBtn = e(this).attr("id").split("-")[0];
  1224.                 url = e("#save_design_url").val();
  1225.                 e("#is_share_btn").val("share")
  1226.             })
  1227.         }()
  1228.     };
  1229.     PDPAction = {
  1230.         doRequest: function(t, n, r) {
  1231.             e.ajax({
  1232.                 type: "POST",
  1233.                 url: t,
  1234.                 data: n,
  1235.                 beforeSend: function() {
  1236.                     e(".pdploading").show()
  1237.                 },
  1238.                 error: function() {
  1239.                     console.log("Something went wrong...")
  1240.                 },
  1241.                 success: function(t) {
  1242.                     r(t);
  1243.                     e(".pdploading").hide()
  1244.                 }
  1245.             })
  1246.         },
  1247.         make_preview_design: function(n, r) {
  1248.             if (n != "") {
  1249.                 n = JSON.parse(n);
  1250.                 r.css("position", "relative").html('<img src="' + t + "/media/pdp/images/" + e("#pdp_sides li[tab=" + n.side + "]").attr("side_img") + '" /><div class="prev_wrap_inlay"></div>');
  1251.                 var s = n.inlay;
  1252.                 if (s != "" && s != undefined) {
  1253.                     s = s.split(",");
  1254.                     r.find(".prev_wrap_inlay").css({
  1255.                         width: s[0] + "px",
  1256.                         height: s[1] + "px",
  1257.                         top: s[2] + "px",
  1258.                         left: s[3] + "px",
  1259.                         position: "absolute"
  1260.                     })
  1261.                 }
  1262.                 if (n.items.length > 0) {
  1263.                     var o = n.items;
  1264.                     for (i = 0; i < o.length; i++) {
  1265.                         var u = o[i];
  1266.                         if (u.type == "image") {
  1267.                             r.find(".prev_wrap_inlay").append('<div class="item image_item"  scy="' + u.scy + '" scx="' + u.scx + '" pos="' + u.pos + '" w="' + u.width + '" h="' + u.height + '" angle2="' + u.angle + '" style="' + u.css + '"><img style="' + u.itemcss + '" src="' + u.path + '" alt="img" /></div>')
  1268.                         } else {
  1269.                             r.find(".prev_wrap_inlay").append('<div class="item text-image"  scy="' + u.scy + '" scx="' + u.scx + '" pos="' + u.pos + '" w="' + u.width + '" h="' + u.height + '" angle2="' + u.angle + '" style="' + u.css + '"><p style="' + u.itemcss + '">' + u.text + "</p></div>")
  1270.                         }
  1271.                     }
  1272.                 }
  1273.             }
  1274.         },
  1275.         save_cr_design: function(t) {
  1276.             var n = {
  1277.                 inlay: e("#pdp_sides li.active").attr("inlay"),
  1278.                 side: e("#pdp_sides li.active").attr("tab"),
  1279.                 img: e("#pdp_sides li.active").attr("side_img"),
  1280.                 items: []
  1281.             };
  1282.             var r = e("#skin_url").val(),
  1283.                 i = e("#base_dir").val(),
  1284.                 s = e("#media_url").val(),
  1285.                 o = e("#pdp_sides li.active").attr("tab"),
  1286.                 u, f, l = e("#product_id").val();
  1287.             a();
  1288.             var c = e(".product-image .item").length,
  1289.                 h = "",
  1290.                 p = e("#edit_id").val();
  1291.             var d = 0;
  1292.             if (c > 0) {
  1293.                 e(".product-image .item").each(function() {
  1294.                     if (e(this).children("img").hasClass("img_up")) {
  1295.                         e(this).css("height", e(this).height() + "px");
  1296.                         var s = e(this).children("img").attr("src"),
  1297.                             u = e(this).attr("w"),
  1298.                             a = e(this).attr("h"),
  1299.                             f = e(this).attr("scx"),
  1300.                             l = e(this).attr("scy"),
  1301.                             h = e(this).attr("pos"),
  1302.                             p = e(this).attr("angle2"),
  1303.                             v = e(this).children("img").attr("rel"),
  1304.                             m = e(this).attr("style");
  1305.                         img_css = e(this).children("img").attr("style");
  1306.                         e.ajax({
  1307.                             url: r + "saveallimages.php",
  1308.                             type: "post",
  1309.                             data: {
  1310.                                 data: s,
  1311.                                 base_dir: i
  1312.                             },
  1313.                             beforeSend: function() {
  1314.                                 e(".pdploading").show()
  1315.                             },
  1316.                             success: function(r) {
  1317.                                 e(".pdploading").hide();
  1318.                                 d++;
  1319.                                 var i = {};
  1320.                                 i.angle = p;
  1321.                                 i.type = "image";
  1322.                                 i.width = u;
  1323.                                 i.height = a;
  1324.                                 i.pos = h;
  1325.                                 i.path = r;
  1326.                                 i.scx = f;
  1327.                                 i.scy = l;
  1328.                                 i.css = m;
  1329.                                 i.itemcss = img_css;
  1330.                                 n.items.push(i);
  1331.                                 e("img[rel=" + v + "]").attr("src", r).removeClass("img_up");
  1332.                                 e("#" + v).attr("src", r);
  1333.                                 if (d == c) {
  1334.                                     e("#pdp_info_" + o).val(JSON.stringify(n));
  1335.                                     if (t == "done") {
  1336.                                         PDPAction.pdp_add_to()
  1337.                                     }
  1338.                                 }
  1339.                             }
  1340.                         })
  1341.                     } else {
  1342.                         e(this).css("height", e(this).height() + "px");
  1343.                         var s = e(this).attr("src"),
  1344.                             u = e(this).attr("w"),
  1345.                             a = e(this).attr("h"),
  1346.                             f = e(this).attr("scx"),
  1347.                             l = e(this).attr("scy"),
  1348.                             h = e(this).attr("pos"),
  1349.                             p = e(this).attr("angle2"),
  1350.                             m = e(this).attr("style");
  1351.                         d++;
  1352.                         var y = {};
  1353.                         y.angle = p;
  1354.                         y.width = u;
  1355.                         y.height = a;
  1356.                         y.pos = h;
  1357.                         y.scx = f;
  1358.                         y.scy = l;
  1359.                         y.css = m;
  1360.                         if (e(this).hasClass("image_item")) {
  1361.                             y.type = "image";
  1362.                             y.path = e(this).children("img").attr("src");
  1363.                             y.itemcss = e(this).children("img").attr("style")
  1364.                         } else {
  1365.                             if (e(this).hasClass("text-image")) {
  1366.                                 y.type = "text";
  1367.                                 y.text = e(this).children("p").text();
  1368.                                 y.itemcss = e(this).children("p").attr("style")
  1369.                             }
  1370.                         }
  1371.                         n.items.push(y);
  1372.                         if (d == c) {
  1373.                             e("#pdp_info_" + o).val(JSON.stringify(n));
  1374.                             if (t == "done") {
  1375.                                 PDPAction.pdp_add_to()
  1376.                             }
  1377.                         }
  1378.                     }
  1379.                 })
  1380.             } else {
  1381.                 e("#pdp_info_" + o).val(JSON.stringify(n));
  1382.                 if (t == "done") {
  1383.                     PDPAction.pdp_add_to()
  1384.                 }
  1385.             }
  1386.             e(".product-image .active").removeClass("active");
  1387.             return n
  1388.         },
  1389.         pdp_add_to: function() {
  1390.             var t = [];
  1391.             e(".pdp_info_save").each(function() {
  1392.                 var n = e(this).attr("alt"),
  1393.                     r = e("#pdp_sides li[tab=" + n + "]").attr("side_img");
  1394.                 json_obj = {
  1395.                     name: n,
  1396.                     img: r,
  1397.                     json: e(this).val()
  1398.                 };
  1399.                 if (e(".design-color-image li.active").length > 0) {
  1400.                     json_obj.color = e(".design-color-image li.active").attr("id")
  1401.                 }
  1402.                 t.push(json_obj)
  1403.             });
  1404.             var n = JSON.stringify(t),
  1405.                 r = e("#pdp_btn_action").val();
  1406.             switch (r) {
  1407.                 case "pdp_add_to_cart":
  1408.                     LoadDesign.updatePDPCustomOption(n);
  1409.                     e("#pdp_design_popup").hide();
  1410.                     e(".add-to-cart .btn-cart").click();
  1411.                     break;
  1412.                 case "pdp_add_to_wishlist":
  1413.                     LoadDesign.updatePDPCustomOption(n);
  1414.                     e("#pdp_design_popup").hide();
  1415.                     if (e("#wishlist_item_id").val() != "") {
  1416.                         e(".add-to-links .link-compare").each(function() {
  1417.                             if (e(this).attr("onclick") != "") {
  1418.                                 e(this).click();
  1419.                                 return
  1420.                             }
  1421.                         })
  1422.                     } else {
  1423.                         e(".add-to-links .link-wishlist").click()
  1424.                     }
  1425.                     break;
  1426.                 case "pdp_save_admin_sample":
  1427.                     var i = e("#url_site").val() + "pdp/index/saveAdminTemplate";
  1428.                     currentProductId = e("#current_product_id").val(), data = {
  1429.                         product_id: currentProductId,
  1430.                         pdp_design: n
  1431.                     };
  1432.                     this.doRequest(i, data, function() {});
  1433.                     break;
  1434.                 case "save_before_share":
  1435.                     this.saveBeforeShare(n);
  1436.                     break;
  1437.                 case "save_design_btn":
  1438.                     LoadDesign.updatePDPCustomOption(n);
  1439.                     e("#pdp_design_popup .overlay").click();
  1440.                     PDPAction.change_product_view();
  1441.                     break
  1442.             }
  1443.         },
  1444.         change_product_view: function() {
  1445.             e(".product-view .product-img-box").html('<div id="pdp_design_preview"></div><div class="more-views pdp_more_view"><h2>More Views</h2><ul></ul></div>');
  1446.             e("#pdp_sides li").each(function() {
  1447.                 var t = '<li><div tab="' + e(this).attr("tab") + '"><img width="56" height="56" src="' + e(this).find("img").attr("src") + '"/></div></li>';
  1448.                 e(".product-view .product-img-box .more-views ul").append(t);
  1449.                 PDPAction.make_preview_design(e("#pdp_info_" + e(this).attr("tab")).val(), e(".more-views ul div[tab=" + e(this).attr("tab") + "]"))
  1450.             });
  1451.             e(".more-views li > div > img, .more-views .prev_wrap_inlay").css("opacity", 0);
  1452.             e(".more-views li > div > img").load(function() {
  1453.                 var t = 1,
  1454.                     n = 56,
  1455.                     r = e(this).width();
  1456.                 t = parseFloat(n / r);
  1457.                 e(this).parent().css({
  1458.                     "-webkit-transform": "scale(" + t + ")",
  1459.                     "-moz-transform": "scale(" + t + ")",
  1460.                     "-ms-transform": "scale(" + t + ")",
  1461.                     transform: "scale(" + t + ")",
  1462.                     height: e(this).parent().height() * t
  1463.                 });
  1464.                 e(this).css("opacity", 1).next().css("opacity", 1)
  1465.             });
  1466.             var t = e("#pdp_info_" + e(".more-views li:eq(0) > div").addClass("active").attr("tab")).val();
  1467.             PDPAction.make_preview_design(t, e("#pdp_design_preview"));
  1468.             e("#pdp_design_preview .prev_wrap_inlay, #pdp_design_preview > img").css("opacity", 0);
  1469.             e("#pdp_design_preview > img").load(function() {
  1470.                 var t = 1,
  1471.                     n = e(".product-view .product-img-box").width(),
  1472.                     r = e("#pdp_design_preview > img").width();
  1473.                 t = parseFloat(n / r);
  1474.                 e("#pdp_design_preview").css({
  1475.                     "-webkit-transform": "scale(" + t + ")",
  1476.                     "-moz-transform": "scale(" + t + ")",
  1477.                     "-ms-transform": "scale(" + t + ")",
  1478.                     transform: "scale(" + t + ")",
  1479.                     height: e("#pdp_design_preview").height() * t
  1480.                 });
  1481.                 e("#pdp_design_preview .prev_wrap_inlay, #pdp_design_preview > img").css("opacity", 1)
  1482.             });
  1483.             e(".more-views li > div").click(function() {
  1484.                 if (!e(this).hasClass("active")) {
  1485.                     e(".more-views li div.active").removeClass("active");
  1486.                     e(this).addClass("active");
  1487.                     PDPAction.make_preview_design(e("#pdp_info_" + e(this).attr("tab")).val(), e("#pdp_design_preview"))
  1488.                 }
  1489.             })
  1490.         },
  1491.         saveBeforeShare: function(t) {
  1492.             var n = e("#save_design_url").val(),
  1493.                 r = e("#product_url").val(),
  1494.                 i = {
  1495.                     pdpdesign: t,
  1496.                     url: r
  1497.                 };
  1498.             this.doRequest(n, i, this.activeAddThis)
  1499.         },
  1500.         activeAddThis: function(t) {
  1501.             var n = e.parseJSON(t);
  1502.             for (var r = 0; r < addthis.links.length; r++) {
  1503.                 addthis.links[r].share.url = n.url
  1504.             }
  1505.             e(".social-bottom .overlay-btn").addClass("send-back")
  1506.         },
  1507.         pdpBtnClick: function() {
  1508.             e(".pdp-btn").on("click", function() {
  1509.                 e("#pdp_btn_action").val(e(this).attr("id"));
  1510.                 PDPAction.save_cr_design("done")
  1511.             })
  1512.         }
  1513.     };
  1514.     PDPAction.pdpBtnClick()
  1515. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement