Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mst = jQuery.noConflict();
- mst.fn.ForceNumericOnly = function() {
- return this.each(function() {
- mst(this).keydown(function(e) {
- var t = e.charCode || e.keyCode || 0;
- return t == 8 || t == 9 || t == 46 || t >= 37 && t <= 40 || t >= 48 && t <= 57 || t >= 96 && t <= 105
- })
- })
- };
- mst(document).ready(function(e) {
- function n(t, n, r, i) {
- var s = 0,
- o = 0;
- t.css("font-size", 0);
- t.css("line-height", 0);
- while (t.width() < n - i) {
- s++;
- t.css("font-size", s);
- e("#select_font_size").val(s)
- }
- while (t.height() < r - i) {
- o++;
- t.css("line-height", o + "px")
- }
- e(".overlay-btn").removeClass("send-back")
- }
- function r(e) {
- e = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
- 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)
- }
- function s(t) {
- e("#edit_item_wrap").show();
- var n;
- if (e("#change_text_type li a.bold").hasClass("active")) {
- t.css("font-weight", "bold")
- } else {
- t.css("font-weight", "normal")
- } if (e("#change_text_type li a.italic").hasClass("active")) {
- t.css("font-style", "italic")
- } else {
- t.css("font-style", "normal")
- } if (e("#change_text_type li a.underline").hasClass("active")) {
- t.css("text-decoration", "underline")
- } else {
- t.css("text-decoration", "none")
- }
- n = e("#change_text_type .align.active").text();
- switch (n) {
- case "C":
- t.css("text-align", "center");
- break;
- case "R":
- t.css("text-align", "right");
- break;
- case "J":
- t.css("text-align", "justify");
- break;
- default:
- t.css("text-align", "left");
- break
- }
- if (e("#use_shadow").is(":checked")) {
- t.css({
- "text-shadow": e("#h-shadow").val() + "px " + e("#v-shadow").val() + "px " + e("#t-blur").val() + "px " + e("#font_outline_color > div").css("backgroundColor")
- })
- } else {
- t.css("text-shadow", "none")
- }
- t.css({
- color: e("#font_color_div > div").css("background-color"),
- "line-height": "1.5",
- "font-size": e("#select_font_size").val() + "px",
- "font-family": e("#select_font_span").html()
- });
- t.css("transform", "rotate(0deg)");
- var r = t.width() + 20,
- i = t.height() + 20,
- s = t.parent().attr("scx"),
- o = t.parent().attr("scy"),
- u = t.parent().attr("angle2"),
- a = t.parent().position().left,
- f = t.parent().position().top;
- var l, c;
- if (u == 90) {
- u = 89.9999999999
- }
- var h = u * Math.PI / 180;
- var p = Math.cos(h);
- var d = Math.sin(h);
- if (p < 0) {
- p = -p
- }
- if (d < 0) {
- d = -d
- }
- l = i * d + r * p;
- c = i * p + r * d;
- var v = (r * p - i * d) / (p * p - d * d),
- m = (i - v * d) / p,
- g = l - v,
- y = c - m;
- var b = parseInt(a) + parseInt(l) / 2,
- w = parseInt(f) + parseInt(c) / 2;
- new_angle = -1 * u;
- t.parent().width(l).height(c).attr("w", r).attr("h", i).attr("pos", b + "," + w);
- t.css("transform", "rotate(" + new_angle + "deg) scaleX(" + s + ") scaleY(" + o + ")");
- t.css({
- left: (l - r) / 2,
- top: (c - i) / 2
- });
- e(".overlay-btn").removeClass("send-back")
- }
- function u(t) {
- e("#edit_item_wrap, .arc_text").show();
- e(".add_text_tab").click();
- e("#add_text_action").hide();
- e("#add_text_input").val(t.text());
- e("#select_font_span").html(t.css("font-family")).css("font-family", t.css("font-family"));
- e("#select_font_size").val(parseInt(t.css("font-size")));
- e("#font_color_div > div").css("backgroundColor", t.css("color"));
- if (t.css("font-weight") > 400 || t.css("font-weight") == "bold") {
- e("#change_text_type a.bold").addClass("active")
- } else {
- e("#change_text_type a.bold").removeClass("active")
- } if (t.css("font-style") == "italic") {
- e("#change_text_type a.italic").addClass("active")
- } else {
- e("#change_text_type a.italic").removeClass("active")
- } if (t.css("text-decoration") == "underline") {
- e("#change_text_type a.underline").addClass("active")
- } else {
- e("#change_text_type a.underline").removeClass("active")
- }
- switch (t.css("text-align")) {
- case "left":
- e("#change_text_type a.align_left").addClass("active");
- break;
- case "center":
- e("#change_text_type a.align_center").addClass("active");
- break;
- case "right":
- e("#change_text_type a.align_right").addClass("active");
- break;
- case "justify":
- e("#change_text_type a.align_justify").addClass("active");
- break;
- default:
- e("#change_text_type a.align_justify").removeClass("active");
- e("#change_text_type a.align_right").removeClass("active");
- e("#change_text_type a.align_center").removeClass("active");
- break
- }
- var n = t.css("text-shadow").match(/(-?\d+px)|(rgb\(.+\))/g);
- if (n) {
- if (!e("#use_shadow").is(":checked")) {
- e("#use_shadow").click()
- }
- e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape .blur,.font_shape .color").show();
- e("#h-shadow").val(parseInt(n[1]));
- e("#v-shadow").val(parseInt(n[2]));
- e("#t-blur").val(parseInt(n[3]));
- e("#font_outline_color > div").css("backgroundColor", n[0]);
- t.css("text-shadow", n[1] + " " + n[2] + " " + n[3] + " " + n[0])
- } else {
- e("#use_shadow").attr("checked", false);
- e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape .blur,.font_shape .color").hide()
- }
- }
- function a() {
- e("#use_shadow").attr("checked", false);
- e(".font_shape .h-shadow,.font_shape .v-shadow, .font_shape .blur, .font_shape .color").hide();
- e("#edit_text_action, .arc_text").hide();
- e("#add_text_input").val("");
- e("#select_font_span").html("Arial").css("font-family", "Arial");
- e("#select_font_size").val("20");
- e("#h-shadow, #v-shadow, #t-blur").val(0);
- e("#font_color_div > div").css("backgroundColor", "#444");
- e("#font_outline_color > div").css("backgroundColor", "#fff");
- e("#change_text_type a.active").removeClass("active")
- }
- function f(t) {
- var n = t.target.files;
- for (var r = 0, i; i = n[r]; r++) {
- if (!i.type.match("image.*")) {
- alert("Please upload a file in one of the following formats: .svg, .jpg, .png, .jpeg, .bmp, .gif");
- continue;
- }
- var s = new FileReader;
- s.onload = function(t) {
- return function(n) {
- var r = e("#lists_img_upload span").length;
- var i = document.createElement("span");
- i.innerHTML = ['<img id="img_up_' + r+++'" color="" class="thumb" src="', n.target.result, '" title="', escape(t.name), '"/>'].join("");
- document.getElementById("lists_img_upload").insertBefore(i, null)
- }
- }(i);
- s.readAsDataURL(i)
- }
- e("#files_upload").val("")
- }
- var t = e("#url_site").val().replace("index.php/", "");
- PDPsetting = {
- add_html: function() {
- e("body").prepend('<div class="pdploading no-display">Loading</div>');
- e("body").append('<div style="display:block;" class="no-display" id="save_original_img_text"></div>');
- e("#product-image-wrap").prepend('<img id="main_image" src="' + t + 'media/pdp/images/no_image.jpg" />');
- e("#product-image-wrap").attr("z_index", 1e3);
- e(".wrapper_pdp").append(e(".color_content"))
- },
- center_design_area: function() {
- var t = e(".wrapper_pdp").width(),
- n = e("#design_control").width(),
- r = e("#product-image-wrap").width(),
- i = e("#product-image-wrap").width(),
- s = parseInt((t - n - i) / 2)
- },
- position_color: function() {
- var t = e("body").width(),
- n = e(".wrapper_pdp").width(),
- r = e(".color_content_wrap").width(),
- i = (t - n) / 2 - r + n;
- e(".color_content_wrap").css("left", i + "px")
- },
- change_color: function() {
- e("#pdp_sides li").each(function() {
- var t = e(this).attr("tab"),
- n = e(".design-color-image li.active").attr(t),
- r = e("#pdp_media_url").val();
- e(this).attr("side_img", n).children("img").attr("src", r + n);
- e(".pdp_info_save[alt=" + t + "]").attr("side_img", n)
- });
- PDPsetting.change_image()
- },
- save_first_design: function() {
- e("#pdp_sides li").each(function() {
- var t = {
- inlay: e(this).attr("inlay"),
- side: e(this).attr("tab"),
- img: e(this).attr("side_img"),
- items: []
- };
- console.log(t.img);
- var n = e("#skin_url").val(),
- r = e("#base_dir").val(),
- i = e("#media_url").val(),
- s = e(this).attr("tab");
- e("#pdp_info_" + s).val(JSON.stringify(t))
- })
- },
- change_image: function() {
- var t = e("#pdp_sides li.active").attr("side_img"),
- n = e("#pdp_media_url").val();
- e(".wrap_pdp_design #main_image").attr("src", n + t)
- },
- change_side: function() {
- var t = e("#pdp_sides li.active"),
- n = t.attr("side_img"),
- r = t.attr("tab"),
- i = e("#pdp_info_" + r).val(),
- s = e("#pdp_media_url").val(),
- o = t.attr("inlay").split(",");
- e(".wrap_pdp_design #main_image").attr("src", s + n);
- e(".wrap_pdp_design #wrap_inlay").css({
- width: o[0] + "px",
- height: o[1] + "px",
- top: o[2] + "px",
- left: o[3] + "px"
- }).show();
- PDPsetting.display_design_as_html(i)
- },
- display_design_as_html: function(t) {
- e(".wrap_pdp_design #wrap_inlay").html("");
- if (t != "") {
- t = JSON.parse(t);
- if (t.items.length > 0) {
- var n = t.items;
- for (i = 0; i < n.length; i++) {
- var r = n[i];
- if (r.type == "image") {
- 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>')
- } else {
- 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>")
- }
- }
- PDPsetting.init_cr_item()
- }
- }
- },
- init: function() {
- e(".wrap_pdp_design .wrap_inlay").addClass("unloadinlay");
- e(".wrap_pdp_design .wrap_inlay").hover(function() {
- e(this).addClass("act2")
- }, function() {
- if (e(this).children(".item.active").length == 0) {
- e(this).removeClass("act2")
- }
- });
- e(".size_qty, #select_font_size, #h-shadow, #v-shadow, #t-blur").ForceNumericOnly();
- var n = e("#t-shirt-type").val(),
- r;
- if (e("#pdp_sides li.active").length > 0) {
- r = e("#pdp_sides li.active")
- } else {
- r = e("#pdp_sides li:eq(0)")
- } if (e(".design-color-image li").length > 0) {
- e(".design-color-image ul").prepend('<li class="pdp_color_original" name=""><img src="' + t + 'js/pdp/images/button-close.png" /></li>')
- }
- e("#pdp_sides li").each(function() {
- 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") + '" />');
- e(".pdp_color_original").attr(e(this).attr("tab"), e(this).attr("side_img"))
- });
- e(".design-color-image li").click(function() {
- var t = e(this).attr("price"),
- n = e(this).attr("name");
- e(".color-option .color_name").html(n);
- e(".design-color-image li.active").removeClass("active");
- e(this).addClass("active");
- PDPsetting.change_color()
- });
- e("#pdp_sides li").click(function() {
- PDPAction.save_cr_design();
- if (!e(this).hasClass("active")) {
- e("#pdp_sides li.active").removeClass("active");
- e(this).addClass("active");
- PDPsetting.change_side()
- }
- });
- PDPsetting.position_color();
- e("html").on("click", function(t) {
- var n = e(".wrap_pdp_design #wrap_inlay .item, #design_control, .color_att, .color_content").has(t.target).length;
- if (n === 0) {
- e(".product-image .active").removeClass("active");
- e(".color_att li").hide();
- e("#edit_item_wrap").hide();
- a()
- }
- });
- var s = e('input[name="extra_options"]').val();
- if (e("#cart_item_id").val() == "" && e("#wishlist_item_id").val() == "") {
- if (e("input[name='pdp_design_string']").length) {
- s = e("input[name='pdp_design_string']").val()
- }
- }
- r.addClass("active");
- if (s != "" && s !== undefined) {
- var o = JSON.parse(s);
- if (o.length > 0) {
- for (i = 0; i < o.length; i++) {
- e("#pdp_info_" + o[i].name).val(o[i].json);
- e(".design-color-image li#" + o[i].color).click()
- }
- }
- } else {
- PDPsetting.save_first_design()
- }
- PDPsetting.change_side()
- },
- init_cr_item: function() {
- if (e(".wrap_inlay .item").length > 0) {
- if (e(".design-color-image li.active").length > 0) {
- e(".design-color-image li.active").click()
- } else {
- e("#list_color li.active").click()
- }
- e(".wrap_inlay .item").each(function() {
- PDPsetting.init_design(e(this))
- })
- }
- },
- init_design: function(t) {
- var r = -1 * t.attr("angle2"),
- i = t.attr("scy"),
- s = t.attr("scx");
- t.prepend('<div class="ui-close">X</div>');
- t.find(".ui-close").click(function() {
- e(".overlay-btn").removeClass("send-back");
- t.remove()
- });
- if (t.hasClass("image_item")) {
- t.children("img").css({
- "-moz-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- "-o-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- "-webkit-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- "-ms-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- transform: "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")"
- });
- t.draggable({
- start: function() {
- var n = e(".product-image.act").attr("z_index"),
- r = t.find("img").attr("rel");
- n++;
- e(".color_att li[rel!=" + r + "]").hide();
- e(".color_att li[rel=" + r + "]").show();
- e(".product-image.act").attr("z_index", n);
- e(".product-image .active").removeClass("active");
- t.addClass("active").css({
- "z-index": n
- }).find("img").attr("rel", r);
- a()
- },
- drag: function() {
- var n = parseInt(t.css("left")) + parseInt(t.width()) / 2,
- r = parseInt(t.css("top")) + parseInt(t.height()) / 2;
- t.attr("pos", n + "," + r);
- e(".overlay-btn").removeClass("send-back");
- e("#edit_item_wrap").show()
- }
- });
- t.rotatable();
- t.resizable({
- aspectRatio: true,
- handles: "se",
- start: function() {},
- resize: function(n) {
- e("#edit_item_wrap").show();
- var r = t.find("img").attr("rel");
- e(".color_att li[rel!=" + r + "]").hide();
- e(".color_att li[rel=" + r + "]").show();
- var i = parseFloat(t.find("img").css("left")),
- s = parseFloat(t.find("img").css("top")),
- o = t.width(),
- u = t.height(),
- a = t.attr("angle2"),
- f = parseFloat(t.css("left")) + parseFloat(t.width()) / 2,
- l = parseFloat(t.css("top")) + parseFloat(t.height()) / 2;
- if (a % 45 == 0 || a % 90 == 0) {
- a = a + 1e-9
- }
- var c = a * Math.PI / 180;
- var h = Math.cos(c);
- var p = Math.sin(c);
- if (h < 0) {
- h = -h
- }
- if (p < 0) {
- p = -p
- }
- var d = (o * h - u * p) / (h * h - p * p),
- v = (u - d * p) / h,
- m = o - d,
- g = u - v;
- t.attr("pos", f + "," + l);
- t.find("img").width(d).height(v).css({
- left: (o - d) / 2,
- top: (u - v) / 2
- });
- e(".overlay-btn").removeClass("send-back");
- t.attr("w", d).attr("h", v)
- }
- });
- t.click(function() {
- e("#edit_item_wrap").show();
- var n = e(".product-image.act").attr("z_index");
- n++;
- var r = t.find("img").attr("rel");
- e(".color_att li[rel!=" + r + "]").hide();
- e(".color_att li[rel=" + r + "]").show();
- e(".product-image.act").attr("z_index", n);
- e(".product-image.act .active").removeClass("active");
- t.addClass("active").css({
- "z-index": n
- });
- a()
- })
- } else {
- t.children("p").css({
- "-moz-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- "-o-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- "-webkit-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- "-ms-transform": "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")",
- transform: "rotate(" + r + "deg) scaleX(" + s + ") scaleY(" + i + ")"
- });
- t.draggable({
- containment: "",
- start: function() {
- e("#edit_item_wrap").show();
- var n = e(".product-image.act").attr("z_index");
- n++;
- e(".product-image.act").attr("z_index", n);
- e(".product-image .active").removeClass("active");
- t.addClass("active").css({
- "z-index": n
- });
- u(t.children("p"))
- },
- drag: function() {
- var n = parseInt(t.css("left")) + parseInt(t.width()) / 2,
- r = parseInt(t.css("top")) + parseInt(t.height()) / 2;
- e(".overlay-btn").removeClass("send-back");
- t.attr("pos", n + "," + r)
- }
- });
- t.rotatabletext();
- t.resizable({
- aspectRatio: true,
- handles: "se",
- start: function() {},
- resize: function(r) {
- e("#edit_item_wrap").show();
- var i = parseFloat(t.find("p").css("left")),
- s = parseFloat(t.find("p").css("top")),
- o = t.width(),
- u = t.height(),
- a = t.attr("angle2"),
- f = parseFloat(t.css("left")) + parseFloat(t.width()) / 2,
- l = parseFloat(t.css("top")) + parseFloat(t.height()) / 2;
- if (a % 45 == 0 || a % 90 == 0) {
- a = a + 1e-9
- }
- var c = a * Math.PI / 180;
- var h = Math.cos(c);
- var p = Math.sin(c);
- if (h < 0) {
- h = -h
- }
- if (p < 0) {
- p = -p
- }
- var d = (o * h - u * p) / (h * h - p * p),
- v = (u - d * p) / h,
- m = o - d,
- g = u - v;
- t.attr("pos", f + "," + l);
- t.find("p").css({
- left: (o - d) / 2,
- top: (u - v) / 2
- });
- n(t.children("p"), d, v, 20);
- e(".overlay-btn").removeClass("send-back");
- t.attr("w", d).attr("h", v)
- }
- });
- t.click(function() {
- e("#edit_item_wrap").show();
- var n = e(".product-image.act").attr("z_index");
- n++;
- e(".product-image.act").attr("z_index", n);
- e(".product-image .active").removeClass("active");
- t.addClass("active").css({
- "z-index": n
- });
- u(t.children("p"))
- })
- }
- }
- };
- PDPsetting.add_html();
- PDPsetting.init();
- e("#add_text_input").click(function() {
- e(".image_item.active").removeClass("active")
- });
- e(".tshirt-size input").change(function() {
- if (e(this).val() == "" || e(this).val() < 0) {
- e(this).val(0)
- }
- e(this).val(parseInt(e(this).val()))
- });
- e("#design_control .control_tab .tab_main").click(function() {
- var t = e(this).attr("tab");
- e("#design_control .control_tab .tab_main.active").removeClass("active");
- e(this).addClass("active");
- e(".tab_content").hide();
- e("." + t).show()
- });
- e(".tab_design_image a").click(function() {
- e(".tab_design_image .active").removeClass("active");
- e(this).addClass("active");
- var t = e(this).attr("tab-content");
- e(".content_tab > div").hide();
- e(".content_tab ." + t).show()
- });
- a();
- e("#move_item .m_tl").click(function() {
- e(".item.active").animate({
- left: 0
- }, 600, function() {
- e(".item.active").animate({
- top: 0
- }, 600);
- var t = parseInt(e(".item.active").width()) / 2,
- n = parseInt(e(".item.active").height()) / 2;
- e(".item.active").attr("pos", t + "," + n)
- });
- e(".overlay-btn").removeClass("send-back")
- });
- e("#move_item .m_tr").click(function() {
- var t = e(".product-image.act .wrap_inlay").width(),
- n = e(".item.active").width(),
- r = e(".item.active").height(),
- i = t - n / 2,
- s = r / 2;
- e(".item.active").animate({
- left: parseFloat(t - n - 2) + "px"
- }, 600, function() {
- e(".item.active").animate({
- top: 0
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", i + "," + s)
- });
- e("#move_item .m_bl").click(function() {
- var t = e(".product-image.act .wrap_inlay").height(),
- n = e(".item.active").height(),
- r = e(".item.active").width(),
- i = r / 2,
- s = t - n / 2;
- e(".item.active").animate({
- left: 0
- }, 600, function() {
- e(".item.active").animate({
- top: parseFloat(t - n - 2) + "px"
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", i + "," + s)
- });
- e("#move_item .m_br").click(function() {
- var t = e(".product-image.act .wrap_inlay").height(),
- n = e(".item.active").height(),
- r = e(".product-image.act .wrap_inlay").width(),
- i = e(".item.active").width(),
- s = r - i / 2,
- o = t - n / 2;
- e(".item.active").animate({
- left: parseFloat(r - i - 2) + "px"
- }, 600, function() {
- e(".item.active").animate({
- top: parseFloat(t - n - 2) + "px"
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", s + "," + o)
- });
- e("#move_item .m_tc").click(function() {
- var t = e(".product-image.act .wrap_inlay").height(),
- n = e(".item.active").height(),
- r = e(".product-image.act .wrap_inlay").width(),
- i = e(".item.active").width(),
- s = r / 2,
- o = n / 2;
- e(".item.active").animate({
- left: parseFloat(r - i - 2) / 2 + "px"
- }, 600, function() {
- e(".item.active").animate({
- top: 0
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", s + "," + o)
- });
- e("#move_item .m_cr").click(function() {
- var t = e(".product-image.act .wrap_inlay").height(),
- n = e(".item.active").height(),
- r = e(".product-image.act .wrap_inlay").width(),
- i = e(".item.active").width(),
- s = r - i / 2,
- o = t / 2;
- e(".item.active").animate({
- left: parseFloat(r - i - 2) + "px"
- }, 600, function() {
- e(".item.active").animate({
- top: parseFloat(t - n - 2) / 2 + "px"
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", s + "," + o)
- });
- e("#move_item .m_cl").click(function() {
- var t = e(".product-image.act .wrap_inlay").height(),
- n = e(".item.active").height(),
- r = e(".product-image.act .wrap_inlay").width(),
- i = e(".item.active").width(),
- s = i / 2,
- o = t / 2;
- e(".item.active").animate({
- left: 0
- }, 600, function() {
- e(".item.active").animate({
- top: parseFloat(t - n - 2) / 2 + "px"
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", s + "," + o)
- });
- e("#move_item .m_bc").click(function() {
- var t = e(".product-image.act .wrap_inlay").height(),
- n = e(".item.active").height(),
- r = e(".product-image.act .wrap_inlay").width(),
- i = e(".item.active").width(),
- s = r / 2,
- o = t - n / 2;
- e(".item.active").animate({
- left: parseFloat(r - i - 2) / 2 + "px"
- }, 600, function() {
- e(".item.active").animate({
- top: parseFloat(t - n - 2) + "px"
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", s + "," + o)
- });
- e("#move_item .m_cc").click(function() {
- var t = e(".product-image.act .wrap_inlay").height(),
- n = e(".item.active").height(),
- r = e(".product-image.act .wrap_inlay").width(),
- i = e(".item.active").width(),
- s = r / 2,
- o = t / 2;
- e(".item.active").animate({
- left: parseFloat(r - i - 2) / 2 + "px"
- }, 600, function() {
- e(".item.active").animate({
- top: parseFloat(t - n - 2) / 2 + "px"
- }, 600)
- });
- e(".overlay-btn").removeClass("send-back");
- e(".item.active").attr("pos", s + "," + o)
- });
- e("#duplicate_item span").click(function() {
- e(".product-image.act .item.last").removeClass("last");
- var t = parseFloat(e(".product-image.act .item.active").css("left"));
- var n = parseFloat(e(".product-image.act .item.active").css("top"));
- t += 10;
- n += 10;
- e(".product-image.act .item.active").clone(false).appendTo(e(".product-image.act .wrap_inlay")).addClass("last").css({
- left: t + "px",
- top: n + "px"
- });
- e(".product-image.act .item.active").removeClass("active");
- e(".item.last").addClass("active").children(".ui-rotatable-handle, .ui-resizable-handle").remove();
- PDPsetting.init_design(e(".item.last"))
- });
- e("#delete_item span").click(function() {
- e(".product-image.act .item.active").remove();
- e(".wrap_inlay").removeClass("act2");
- e("#edit_item_wrap").hide()
- });
- e("#flip_items .flip_x").click(function() {
- var t = e(".item.active").attr("angle2"),
- n = e(".item.active").attr("scx"),
- r = e(".item.active").attr("scy"),
- i = -1 * t;
- if (e(".item.active").hasClass("image_item")) {
- e(".item.active").attr("scx", n * -1);
- e(".item.active").children("img").css({
- "-moz-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- "-o-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- "-ms-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- transform: "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")"
- })
- } else {
- e(".item.active").attr("scx", n * -1);
- e(".item.active").children("p").css({
- "-moz-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- "-o-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- "-ms-transform": "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")",
- transform: "rotate(" + i + "deg) scaleX(" + n * -1 + ") scaleY(" + r + ")"
- })
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#flip_items .flip_y").click(function() {
- var t = e(".item.active").attr("angle2"),
- n = e(".item.active").attr("scx"),
- r = e(".item.active").attr("scy"),
- i = -1 * t;
- if (e(".item.active").hasClass("image_item")) {
- e(".item.active").attr("scy", r * -1);
- e(".item.active").children("img").css({
- "-moz-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- "-o-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- "-ms-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- transform: "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")"
- })
- } else {
- e(".item.active").attr("scy", r * -1);
- e(".item.active").children("p").css({
- "-moz-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- "-o-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- "-webkit-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- "-ms-transform": "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")",
- transform: "rotate(" + i + "deg) scaleX(" + n + ") scaleY(" + r * -1 + ")"
- })
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#add_text_action").click(function() {
- var t = e(".product-image.act").attr("z_index");
- t++;
- e(".product-image.act").attr("z_index", t);
- var n = e("#add_text_input").val(),
- r = "normal",
- i = "normal",
- s = "none",
- o = "left",
- a = e("#arc_text_input").val(),
- f = e.trim(e("#select_font_span").html()),
- l = e.trim(e("#select_font_size").val()),
- c = e("#font_color_div > div").css("backgroundColor");
- if (e("#change_text_type a.bold").hasClass("active")) {
- r = "bold"
- }
- if (e("#change_text_type a.italic").hasClass("active")) {
- i = "italic"
- }
- if (e("#change_text_type a.underline").hasClass("active")) {
- s = "underline"
- }
- if (e("#change_text_type a.align_left").hasClass("active")) {
- o = "left"
- }
- if (e("#change_text_type a.align_center").hasClass("active")) {
- o = "center"
- }
- if (e("#change_text_type a.align_right").hasClass("active")) {
- o = "right"
- }
- if (e("#change_text_type a.align_justify").hasClass("active")) {
- o = "justify"
- }
- if (n != "") {
- e(".product-image .active").removeClass("active");
- e(".text-image.last").removeClass("last");
- 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>");
- var h = e(".text-image.last");
- h.attr("pos", h.width() / 2 + "," + h.height() / 2).attr("w", h.width()).attr("h", h.height());
- if (e("#use_shadow").is(":checked")) {
- h.css({
- "text-shadow": e("#h-shadow").val() + "px " + e("#v-shadow").val() + "px " + e("#t-blur").val() + "px " + e("#font_outline_color > div").css("backgroundColor")
- })
- }
- e(".text-image.last").rotatabletext();
- e("#edit_item_wrap, .arc_text").show();
- e("#add_text_action").hide();
- e("#edit_text_action").show();
- e("#edit_item_wrap").show();
- PDPsetting.init_design(e(".text-image.last"));
- e(".text-image.last").click(function() {
- e("#edit_item_wrap").show();
- var t = e(".product-image.act").attr("z_index");
- t++;
- e(".product-image.act").attr("z_index", t);
- e(".product-image .active").removeClass("active");
- e(this).addClass("active").css({
- "z-index": t
- });
- u(e(this).children("p"))
- })
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#use_shadow").click(function() {
- if (e(this).is(":checked")) {
- e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape .blur,.font_shape .color").show()
- } else {
- e(".font_shape .h-shadow,.font_shape .v-shadow,.font_shape .blur,.font_shape .color").hide()
- } if (e(".product-image.act .text-image.active").length > 0) {
- s(e(".text-image.active p"))
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e(".change_font .next_t").click(function() {
- var t = e(this).prev().val();
- e(this).prev().val(parseInt(t) + 1);
- if (e(".product-image.act .text-image.active").length > 0) {
- s(e(".text-image.active p"))
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e(".change_font .prev_t").click(function() {
- var t = e(this).next().val();
- if (e(this).next().attr("id") == "t-blur" && t == 0) {} else {
- if (e(this).next().attr("id") == "select_font_size" && t < 3) {} else {
- e(this).next().val(parseInt(t) - 1);
- if (e(".product-image.act .text-image.active").length > 0) {
- s(e(".text-image.active p"))
- }
- }
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#add_text_input").keyup(function() {
- if (e(".product-image.act .text-image.active").length > 0) {
- e(".text-image.active p").html(e(this).val());
- if (e(this).val() == "") {
- e(".text-image.active").remove()
- } else {
- s(e(".text-image.active p"))
- }
- } else {
- if (e(this).val() != "") {
- e("#add_text_action").click()
- }
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#change_text_type a.text").click(function() {
- e(this).toggleClass("active");
- if (e(".product-image.act .text-image.active").length > 0) {
- s(e(".text-image.active p"))
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#change_text_type a.align").click(function() {
- e("#change_text_type a.align.active").removeClass("active");
- e(this).toggleClass("active");
- if (e(".product-image.act .text-image.active").length > 0) {
- s(e(".text-image.active p"))
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#select_font_size, #h-shadow, #v-shadow, #t-blur").change(function() {
- if (e(".product-image.act .text-image.active").length > 0) {
- s(e(".text-image.active p"))
- }
- e(".overlay-btn").removeClass("send-back")
- });
- e("#font_color_div, #font_outline_color").click(function() {
- e(".color_content").show();
- e(".color_display, .color_content li a.act").removeClass("act");
- e(this).find(".color_display").addClass("act");
- var t = e(this).find(".color_display").css("background-color");
- e(".color_content li a").each(function() {
- if (e(this).css("background-color") == t) {
- e(this).addClass("act");
- e("#selected_color").val(r(t));
- e("a.selected_color").css("background-color", t)
- }
- })
- });
- e(".inlay_div.color, .color_content_wrap .bt_done").click(function() {
- e(".color_content").hide();
- e(".color_display").removeClass("act")
- });
- e(".color_content li a:not(.selected_color, .bt_done)").click(function() {
- e(".color_content li a.act").removeClass("act");
- e(this).addClass("act");
- var t = e(this).css("background-color");
- e(".color_display.act").css("background-color", t);
- e("#selected_color").val(r(t));
- if (e("#font_color_div .color_display").hasClass("act")) {
- e(".text-image.active p").css("color", t)
- }
- if (e("#font_outline_color .color_display").hasClass("act")) {
- var n = e("#h-shadow").val(),
- i = e("#v-shadow").val(),
- s = e("#t-blur").val();
- e(".text-image.active p").css("text-shadow", n + "px " + i + "px " + s + "px " + t)
- }
- e("a.selected_color").css("background-color", t)
- });
- e("#selected_color").change(function() {
- e("a.selected_color").css("background-color", "#" + e(this).val())
- });
- e("#select_font_span").click(function() {
- e("#select_font").show()
- });
- e(".box_text").hover(function() {}, function() {
- e("#select_font").hide()
- });
- e("#select_font").hover(function() {
- e(this).show()
- }, function() {
- e(this).hide()
- });
- e("#select_font li").each(function() {
- e(this).css("font-family", e(this).attr("rel"))
- });
- e("#select_font li").click(function() {
- e("#select_font").hide();
- e("#select_font_span").css("font-family", e(this).attr("rel")).html(e(this).attr("rel"));
- if (e(".product-image.act .text-image.active").length > 0) {
- s(e(".text-image.active p"))
- }
- });
- var o = 1;
- e("#select_image img").each(function() {});
- e(".color_att").on("click", "li", function() {
- var t = e(this).attr("isrc"),
- n = e("#" + t).attr("src");
- e(".image_item.active img").attr("src", n)
- });
- e("#icon_list, #lists_img_upload, #photos_album").on("click", "img", function() {
- var n = e(".product-image.act").attr("z_index");
- n++;
- e(".color_att li").hide();
- e(".product-image.act").attr("z_index", n);
- var r = e(this).attr("src"),
- i = e(this).attr("id"),
- s = e(this).attr("color");
- if (s != "") {
- var o = s.split(",");
- if (!e(this).hasClass("loaded")) {
- e(this).addClass("loaded");
- e(".product-img-box .color_att").append('<li class="ori_img" rel="' + i + '" isrc="' + i + '"><a iid="' + i + '"> </a></li>');
- for (ii = 0; ii < o.length; ii++) {
- var u = o[ii].split("-");
- 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>");
- e("#save_original_img_text").append('<img id="img_color_' + i + "_" + ii + '" src="' + t + "media/pdp/images/artworks/" + u[1] + '" />')
- }
- } else {
- e(".color_att li[rel=" + i + "]").show()
- }
- }
- e(".image_item.last").removeClass("last");
- e("#edit_item_wrap").show();
- e(".product-image .active").removeClass("active");
- 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>');
- if (e(this).hasClass("thumb")) {
- e(".image_item.last img").addClass("img_up")
- }
- e(".image_item.last").find("img").height(70).attr("rel", i).css({
- left: 0,
- top: 0,
- position: "absolute"
- });
- e(".image_item.last").height(70);
- width_img = e(".image_item.last").children("img").width();
- e(".image_item.last").width(width_img);
- e(".image_item.last").attr("w", width_img).attr("pos", width_img / 2 + "," + 35);
- PDPsetting.init_design(e(".image_item.last"));
- e(".overlay-btn").removeClass("send-back")
- });
- e("#save_design_btn_not_login").click(function() {
- window.location = e("#login_url").val()
- });
- e("body").keypress(function(t) {
- var n = t.keyCode || t.which;
- var r = e(".item.active").length;
- if (r > 0) {
- switch (n) {
- case 46:
- if (!e(".item.active").hasClass("text-image")) {
- e(".item.active").remove()
- }
- break;
- case 37:
- if (!e(".item.active").hasClass("text-image")) {
- var i = e(".item.active").position();
- e(".item.active").css("left", i.left - 1 + "px");
- return false
- }
- break;
- case 38:
- if (!e(".item.active").hasClass("text-image")) {
- var i = e(".item.active").position();
- e(".item.active").css("top", i.top - 1 + "px");
- return false
- }
- break;
- case 39:
- if (!e(".item.active").hasClass("text-image")) {
- var i = e(".item.active").position();
- e(".item.active").css("left", i.left + 1 + "px");
- return false
- }
- break;
- case 40:
- if (!e(".item.active").hasClass("text-image")) {
- var i = e(".item.active").position();
- e(".item.active").css("top", i.top + 1 + "px");
- return false
- }
- break
- }
- e(".overlay-btn").removeClass("send-back")
- }
- });
- e("#files_upload").hover(function() {
- if (!e(this).hasClass("active")) {
- document.getElementById("files_upload").addEventListener("change", f, false);
- e(this).addClass("active")
- }
- });
- e("#lists_img_upload2").hover(function() {
- var t = 0;
- e("#lists_img_upload span img").each(function() {
- t++;
- e(this).attr("id", "img_upload_" + t).attr("color", "")
- })
- });
- if (e("#fb_get_id").val() != "") {
- e(".add_artwork_tab").click();
- e(".tab_design_image .facebook_api").click()
- }
- e("#facebook_album").change(function() {
- var t = e(this).val();
- e("#fb_image_list li:not(." + t + ")").hide();
- e("#fb_image_list li.fb_album_" + t).show()
- });
- var l = t;
- var c = l + "media/pdp/images/artworks/";
- e(".content_designs").append('<span class="loading-img no-display"> </span>');
- Paging = {
- init: function() {
- this.loadMoreImage();
- this.filterByCategory()
- },
- loadMoreImage: function() {
- e("#load_more_image").click(function() {
- var t = e("#image_category_list li.active").attr("cr_act");
- var n = e("#image_category_list li.active span").attr("id");
- var r = e("#default_page_size").val();
- e.ajax({
- type: "POST",
- url: l + "index.php/pdp/index/loadMoreImage",
- data: {
- current_page: t,
- category: n,
- page_size: r
- },
- beforeSend: function() {
- e(".content_designs .loading-img").show()
- },
- error: function() {},
- success: function(n) {
- if (n != "nomore") {
- e("#image_category_list li.active").attr("cr_act", parseInt(t) + 1);
- var r = e.parseJSON(n);
- var i = "";
- for (var s = 0; s < r.length; s++) {
- 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>"
- }
- e("#icon_list").append(i)
- } else {
- alert("No more items to load!")
- }
- e(".content_designs .loading-img").hide()
- }
- })
- })
- },
- filterByCategory: function() {
- e("#image_category_list li").click(function() {
- e("#image_category_list li.active").removeClass("active");
- e(this).addClass("active");
- e("#icon_list li[cat!=" + e(this).children("span").attr("id") + "]").hide();
- e("#icon_list li[cat=" + e(this).children("span").attr("id") + "]").show();
- if (!e(this).hasClass("cat_loaded")) {
- e(this).addClass("cat_loaded");
- var t = 2,
- n = e("#image_category_list li.active span").attr("id"),
- r = e("#default_page_size").val(),
- i = parseInt(t - 1) * parseInt(r);
- e.ajax({
- type: "POST",
- url: l + "index.php/pdp/index/loadMoreImage",
- data: {
- current_page: 1,
- category: n,
- page_size: i
- },
- beforeSend: function() {
- e(".content_designs .loading-img").show()
- },
- error: function() {},
- success: function(t) {
- if (t != "nomore") {
- var n = e.parseJSON(t);
- var r = "";
- for (var i = 0; i < n.length; i++) {
- 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>"
- }
- e("#icon_list").append(r);
- e("#image_category_list li.active").attr("cr_act", 2)
- } else {
- alert("No more items to load!")
- }
- e(".content_designs .loading-img").hide()
- }
- })
- }
- })
- }
- };
- Paging.init();
- PdpShare = {
- doRequest: function(t, n, r) {
- e.ajax({
- type: "POST",
- url: t,
- data: n,
- beforeSend: function() {
- e(".pdploading").show()
- },
- error: function() {
- console.log("Something went wrong...")
- },
- success: function(t) {
- r(t);
- e(".pdploading").hide()
- }
- })
- },
- saveBeforeShare: function(t) {
- var n = e("#save_design_url").val(),
- r = e("#product_url").val(),
- i = {
- pdpdesign: t,
- url: r
- };
- this.doRequest(n, i, this.activeAddThis)
- },
- activeAddThis: function(t) {
- var n = e.parseJSON(t);
- for (var r = 0; r < addthis.links.length; r++) {
- addthis.links[r].share.url = n.url
- }
- e(".social-bottom .overlay-btn").addClass("send-back")
- },
- shareClick: function() {
- var t;
- e("#save_before_share").on("click", function() {
- shareBtn = e(this).attr("id").split("-")[0];
- url = e("#save_design_url").val();
- e("#is_share_btn").val("share")
- })
- }()
- };
- PDPAction = {
- doRequest: function(t, n, r) {
- e.ajax({
- type: "POST",
- url: t,
- data: n,
- beforeSend: function() {
- e(".pdploading").show()
- },
- error: function() {
- console.log("Something went wrong...")
- },
- success: function(t) {
- r(t);
- e(".pdploading").hide()
- }
- })
- },
- make_preview_design: function(n, r) {
- if (n != "") {
- n = JSON.parse(n);
- 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>');
- var s = n.inlay;
- if (s != "" && s != undefined) {
- s = s.split(",");
- r.find(".prev_wrap_inlay").css({
- width: s[0] + "px",
- height: s[1] + "px",
- top: s[2] + "px",
- left: s[3] + "px",
- position: "absolute"
- })
- }
- if (n.items.length > 0) {
- var o = n.items;
- for (i = 0; i < o.length; i++) {
- var u = o[i];
- if (u.type == "image") {
- 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>')
- } else {
- 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>")
- }
- }
- }
- }
- },
- save_cr_design: function(t) {
- var n = {
- inlay: e("#pdp_sides li.active").attr("inlay"),
- side: e("#pdp_sides li.active").attr("tab"),
- img: e("#pdp_sides li.active").attr("side_img"),
- items: []
- };
- var r = e("#skin_url").val(),
- i = e("#base_dir").val(),
- s = e("#media_url").val(),
- o = e("#pdp_sides li.active").attr("tab"),
- u, f, l = e("#product_id").val();
- a();
- var c = e(".product-image .item").length,
- h = "",
- p = e("#edit_id").val();
- var d = 0;
- if (c > 0) {
- e(".product-image .item").each(function() {
- if (e(this).children("img").hasClass("img_up")) {
- e(this).css("height", e(this).height() + "px");
- var s = e(this).children("img").attr("src"),
- u = e(this).attr("w"),
- a = e(this).attr("h"),
- f = e(this).attr("scx"),
- l = e(this).attr("scy"),
- h = e(this).attr("pos"),
- p = e(this).attr("angle2"),
- v = e(this).children("img").attr("rel"),
- m = e(this).attr("style");
- img_css = e(this).children("img").attr("style");
- e.ajax({
- url: r + "saveallimages.php",
- type: "post",
- data: {
- data: s,
- base_dir: i
- },
- beforeSend: function() {
- e(".pdploading").show()
- },
- success: function(r) {
- e(".pdploading").hide();
- d++;
- var i = {};
- i.angle = p;
- i.type = "image";
- i.width = u;
- i.height = a;
- i.pos = h;
- i.path = r;
- i.scx = f;
- i.scy = l;
- i.css = m;
- i.itemcss = img_css;
- n.items.push(i);
- e("img[rel=" + v + "]").attr("src", r).removeClass("img_up");
- e("#" + v).attr("src", r);
- if (d == c) {
- e("#pdp_info_" + o).val(JSON.stringify(n));
- if (t == "done") {
- PDPAction.pdp_add_to()
- }
- }
- }
- })
- } else {
- e(this).css("height", e(this).height() + "px");
- var s = e(this).attr("src"),
- u = e(this).attr("w"),
- a = e(this).attr("h"),
- f = e(this).attr("scx"),
- l = e(this).attr("scy"),
- h = e(this).attr("pos"),
- p = e(this).attr("angle2"),
- m = e(this).attr("style");
- d++;
- var y = {};
- y.angle = p;
- y.width = u;
- y.height = a;
- y.pos = h;
- y.scx = f;
- y.scy = l;
- y.css = m;
- if (e(this).hasClass("image_item")) {
- y.type = "image";
- y.path = e(this).children("img").attr("src");
- y.itemcss = e(this).children("img").attr("style")
- } else {
- if (e(this).hasClass("text-image")) {
- y.type = "text";
- y.text = e(this).children("p").text();
- y.itemcss = e(this).children("p").attr("style")
- }
- }
- n.items.push(y);
- if (d == c) {
- e("#pdp_info_" + o).val(JSON.stringify(n));
- if (t == "done") {
- PDPAction.pdp_add_to()
- }
- }
- }
- })
- } else {
- e("#pdp_info_" + o).val(JSON.stringify(n));
- if (t == "done") {
- PDPAction.pdp_add_to()
- }
- }
- e(".product-image .active").removeClass("active");
- return n
- },
- pdp_add_to: function() {
- var t = [];
- e(".pdp_info_save").each(function() {
- var n = e(this).attr("alt"),
- r = e("#pdp_sides li[tab=" + n + "]").attr("side_img");
- json_obj = {
- name: n,
- img: r,
- json: e(this).val()
- };
- if (e(".design-color-image li.active").length > 0) {
- json_obj.color = e(".design-color-image li.active").attr("id")
- }
- t.push(json_obj)
- });
- var n = JSON.stringify(t),
- r = e("#pdp_btn_action").val();
- switch (r) {
- case "pdp_add_to_cart":
- LoadDesign.updatePDPCustomOption(n);
- e("#pdp_design_popup").hide();
- e(".add-to-cart .btn-cart").click();
- break;
- case "pdp_add_to_wishlist":
- LoadDesign.updatePDPCustomOption(n);
- e("#pdp_design_popup").hide();
- if (e("#wishlist_item_id").val() != "") {
- e(".add-to-links .link-compare").each(function() {
- if (e(this).attr("onclick") != "") {
- e(this).click();
- return
- }
- })
- } else {
- e(".add-to-links .link-wishlist").click()
- }
- break;
- case "pdp_save_admin_sample":
- var i = e("#url_site").val() + "pdp/index/saveAdminTemplate";
- currentProductId = e("#current_product_id").val(), data = {
- product_id: currentProductId,
- pdp_design: n
- };
- this.doRequest(i, data, function() {});
- break;
- case "save_before_share":
- this.saveBeforeShare(n);
- break;
- case "save_design_btn":
- LoadDesign.updatePDPCustomOption(n);
- e("#pdp_design_popup .overlay").click();
- PDPAction.change_product_view();
- break
- }
- },
- change_product_view: function() {
- 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>');
- e("#pdp_sides li").each(function() {
- var t = '<li><div tab="' + e(this).attr("tab") + '"><img width="56" height="56" src="' + e(this).find("img").attr("src") + '"/></div></li>';
- e(".product-view .product-img-box .more-views ul").append(t);
- PDPAction.make_preview_design(e("#pdp_info_" + e(this).attr("tab")).val(), e(".more-views ul div[tab=" + e(this).attr("tab") + "]"))
- });
- e(".more-views li > div > img, .more-views .prev_wrap_inlay").css("opacity", 0);
- e(".more-views li > div > img").load(function() {
- var t = 1,
- n = 56,
- r = e(this).width();
- t = parseFloat(n / r);
- e(this).parent().css({
- "-webkit-transform": "scale(" + t + ")",
- "-moz-transform": "scale(" + t + ")",
- "-ms-transform": "scale(" + t + ")",
- transform: "scale(" + t + ")",
- height: e(this).parent().height() * t
- });
- e(this).css("opacity", 1).next().css("opacity", 1)
- });
- var t = e("#pdp_info_" + e(".more-views li:eq(0) > div").addClass("active").attr("tab")).val();
- PDPAction.make_preview_design(t, e("#pdp_design_preview"));
- e("#pdp_design_preview .prev_wrap_inlay, #pdp_design_preview > img").css("opacity", 0);
- e("#pdp_design_preview > img").load(function() {
- var t = 1,
- n = e(".product-view .product-img-box").width(),
- r = e("#pdp_design_preview > img").width();
- t = parseFloat(n / r);
- e("#pdp_design_preview").css({
- "-webkit-transform": "scale(" + t + ")",
- "-moz-transform": "scale(" + t + ")",
- "-ms-transform": "scale(" + t + ")",
- transform: "scale(" + t + ")",
- height: e("#pdp_design_preview").height() * t
- });
- e("#pdp_design_preview .prev_wrap_inlay, #pdp_design_preview > img").css("opacity", 1)
- });
- e(".more-views li > div").click(function() {
- if (!e(this).hasClass("active")) {
- e(".more-views li div.active").removeClass("active");
- e(this).addClass("active");
- PDPAction.make_preview_design(e("#pdp_info_" + e(this).attr("tab")).val(), e("#pdp_design_preview"))
- }
- })
- },
- saveBeforeShare: function(t) {
- var n = e("#save_design_url").val(),
- r = e("#product_url").val(),
- i = {
- pdpdesign: t,
- url: r
- };
- this.doRequest(n, i, this.activeAddThis)
- },
- activeAddThis: function(t) {
- var n = e.parseJSON(t);
- for (var r = 0; r < addthis.links.length; r++) {
- addthis.links[r].share.url = n.url
- }
- e(".social-bottom .overlay-btn").addClass("send-back")
- },
- pdpBtnClick: function() {
- e(".pdp-btn").on("click", function() {
- e("#pdp_btn_action").val(e(this).attr("id"));
- PDPAction.save_cr_design("done")
- })
- }
- };
- PDPAction.pdpBtnClick()
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement