var sample_clishe; var smpl_clishe; function parse_string(t) { switch (temp_str = t[0], t[2]) { case "italic": temp_str = "" + temp_str + ""; break; case "bold": temp_str = "" + temp_str + ""; break; case "bold italic": temp_str = "" + temp_str + "" } switch (t[4]) { case -1: align = "left"; break; case 0: align = "center"; break; case 1: align = "right"; break; default: align = "" } switch (t[1]) { case "Arial": temp_str = '' + temp_str + ""; break; case "Times": temp_str = '' + temp_str + ""; break; case "Courier": temp_str = '' + temp_str + ""; break; case "Verdana": temp_str = '' + temp_str + "" } return "" != align && (temp_str = "<" + align + ">" + temp_str + ""), temp_str + "
" } function ChangeQuickSample(t) { it_is_dater ? el = $(".sample_img_dater.active") : el = $(".sample_img_stamp.active"), el.removeClass("active"), el.parent().parent().find("#" + t).addClass("active") } function Button_Checker() { it_is_dater ? max_x = dater_x_size.length : max_x = x_size.length; for (var t = 0; t < max_x && (it_is_dater ? cur_x = dater_x_size[t] : cur_x = x_size[t], cur_x != current_press[0]); t++); 0 == t ? ($(".inc_x").removeClass("disabled"), $(".dec_x").addClass("disabled")) : t + 1 >= max_x ? ($(".inc_x").addClass("disabled"), $(".dec_x").removeClass("disabled")) : ($(".inc_x").removeClass("disabled"), $(".dec_x").removeClass("disabled")), it_is_dater ? max_y = dater_y_size.length : max_y = y_size.length; for (var t = 0; t < max_y && (it_is_dater ? cur_y = dater_y_size[t] : cur_y = y_size[t], cur_y != current_press[1]); t++); 0 == t ? ($(".inc_y").removeClass("disabled"), $(".dec_y").addClass("disabled")) : t + 1 >= max_y ? ($(".inc_y").addClass("disabled"), $(".dec_y").removeClass("disabled")) : ($(".inc_y").removeClass("disabled"), $(".dec_y").removeClass("disabled")) } function Stamp_Order_Find() { if (it_is_dater) for (var t = 0; t < dater_list.length; t++) dater_list[t] == start_dater && (document.getElementById("dater_selector").selectedIndex = t); else for (var t = 0; t < order_list.length; t++) order_list[t] == start_stamp && (document.getElementById("stamp_selector").selectedIndex = t) } function Stamp_Change(t) { if (it_is_dater ? max_count = dater_count : max_count = stamp_count, t < max_count && t >= 0) { if (picture_path = Size_to_Path("" + current_press[0]) + "_" + Size_to_Path("" + current_press[1]), it_is_dater) start_dater = t, current_press = dater_size[start_dater]; else { for (start_stamp = t, current_press = stamp_size[start_stamp], h = 0; t < order_list.length && order_list[h] != t;) h++; try { $("#press_sample").slick("slickGoTo", h) } catch (e) {} } start_x = current_press[0], start_y = current_press[1], stamp_line_count = parseInt(start_y / min_char_height), stamp_line_count > max_line_count && (stamp_line_count = 10); for (var a = 0; a < max_line_count; a++) 10 > a ? temp_str = "0" + a.toString() : temp_str = a.toString(), this_view = a < stamp_line_count || stamp_text[a] ? "block" : "none", el = document.getElementById("text_" + temp_str), el.setAttribute("display", this_view), el.style.display = this_view; picture_path = Size_to_Path("" + current_press[0]) + "_" + Size_to_Path("" + current_press[1]), temp_str = current_press[2].split(",")[0].toString(), table_image = "../images/stamp/" + picture_path + "/" + temp_str + "/" + temp_str + "_01.png", el = document.getElementById("sample_table"), el.style.backgroundImage = "url('" + table_image + "')", el.style.backgroundRepeat = "no-repeat", el.style.backgroundPosition = "center", temp_size = parseInt(parseInt(current_press[6].split(",")[0]) / 2.75), is_mobile ? el.style.backgroundSize = "contain" : (temp_size = parseInt(parseInt(current_press[6].split(",")[0]) / 2.75), el.style.backgroundSize = temp_size + "%"), Stamp_Order_Find(), Button_Checker() } } function Restote_Text() { for (var t = 0; t < stamp_text.length; t++) 10 > t ? temp_str = "0" + t.toString() : temp_str = t.toString(), current_text = stamp_text[t] ? stamp_text[t][0] : "", document.getElementById("line_" + temp_str).value = current_text } function PushAllCookie() { setCookie("with_resize", with_resize), setCookie("start_stamp", start_stamp), setCookie("start_dater", start_dater), setCookie("it_is_dater", it_is_dater), setCookie("border", border), setCookie("date_border", date_border), setCookie("line_count", stamp_text.length); for (var t = 0; t < stamp_text.length; t++) setCookie("st_text_" + t.toString(), stamp_text[t][0]), setCookie("st_font_" + t.toString(), stamp_text[t][1]), setCookie("st_type_" + t.toString(), stamp_text[t][2]), setCookie("st_size_" + t.toString(), stamp_text[t][3]), setCookie("st_of_x_" + t.toString(), stamp_text[t][4]), setCookie("st_of_y_" + t.toString(), stamp_text[t][5]), setCookie("st_alig_" + t.toString(), stamp_text[t][6]); "drei" == getCookie("last_stamp") ? setCookie("last_stamp", "first") : setCookie("last_stamp", "ein"), setCookie("place_holder", outer_text.length > 0 ? nicEditors.findEditor("stamp_text_area").getContent() : "") } function PopAllCookie() { if (loader && (with_resize = "true" == getCookie("with_resize", with_resize) ? !0 : !1, start_stamp = parseInt(getCookie("start_stamp", start_stamp)), start_dater = parseInt(getCookie("start_dater", start_dater)), it_is_dater = "true" == getCookie("it_is_dater", it_is_dater) ? !0 : !1, border = parseInt(getCookie("border", border)), border ? document.getElementById("stamp_border").checked = !0 : document.getElementById("stamp_border").checked = !1, date_border = parseInt(0 + getCookie("date_border", date_border)), Restore_Date(), it_is_dater ? (ChangeQuickSample(start_dater), Stamp_Change(start_dater)) : (ChangeQuickSample(start_stamp), Stamp_Change(start_stamp)), check_price = parseInt(getCookie("line_count")), check_price > 0)) { for (var t = stamp_text.length - 1; t >= 0; t--) { for (var e = 6; e >= 0; e--) stamp_text[t][e] = 0; stamp_text[t] = 0 } stamp_text = []; for (var t = 0; check_price > t; t++) stamp_text[t] = [], stamp_text[t][0] = getCookie("st_text_" + t.toString(), ""), stamp_text[t][1] = getCookie("st_font_" + t.toString(), "Arial"), stamp_text[t][2] = getCookie("st_type_" + t.toString(), "normal"), stamp_text[t][3] = parseInt(getCookie("st_size_" + t.toString(), 10)), stamp_text[t][4] = parseInt(getCookie("st_of_x_" + t.toString(), 0)), stamp_text[t][5] = parseInt(getCookie("st_of_y_" + t.toString(), 0)), stamp_text[t][6] = parseInt(getCookie("st_alig_" + t.toString(), 0)); Restote_Text() } } function Switch_Allign(t) { switch (el = document.getElementById("to_left"), el.style["background-color"] = "#fff", el = document.getElementById("to_center"), el.style["background-color"] = "#fff", el = document.getElementById("to_right"), el.style["background-color"] = "#fff", t) { case -1: position_name = "to_left"; break; case 0: position_name = "to_center"; break; case 1: position_name = "to_right" } el = document.getElementById(position_name), el.style["background-color"] = "#ccc" } function RestoreDriver(t, e, a, _, r, s, i) { if (e = e || getCookie("font_value", 10), a = a || getCookie("font_strange", "bold"), _ = _ || getCookie("font_type", "arial"), r = r || getCookie("x_Name", 0), s = s || getCookie("y_Name", 0), i = i || 0, t) { switch (document.getElementById("font_value").value = e, a) { case "normal": document.getElementById("font_strange").selectedIndex = 0; break; case "italic": document.getElementById("font_strange").selectedIndex = 1; break; case "bold": document.getElementById("font_strange").selectedIndex = 2; break; case "bold italic": document.getElementById("font_strange").selectedIndex = 3 } switch (_) { case "Arial": document.getElementById("font_type").selectedIndex = 0; break; case "Times": document.getElementById("font_type").selectedIndex = 1; break; case "Courier": document.getElementById("font_type").selectedIndex = 2; break; case "Verdana": document.getElementById("font_type").selectedIndex = 3 } } else document.getElementById("font_value").value = 10, document.getElementById("font_strange").selectedIndex = 1, document.getElementById("font_type").selectedIndex = 0; Switch_Allign(i) } function Restore_Date() { el1 = document.getElementById("stamp_block"), el2 = document.getElementById("dater_block"), el3 = document.getElementById("stamp_selector"), el4 = document.getElementById("dater_selector"), it_is_dater ? (el1.style.display = "none", el2.style.display = "", el3.style.display = "none", el4.style.display = "", current_press = dater_size[start_dater], Stamp_Change(start_dater), document.getElementById("with_date").checked = !0) : (el1.style.display = "", el2.style.display = "none", el3.style.display = "", el4.style.display = "none", current_press = stamp_size[start_stamp], Stamp_Change(start_stamp)), start_x = current_press[0], start_y = current_press[1], date_border ? document.getElementById("date_border").checked = !0 : document.getElementById("date_border").checked = !1 } function next_step() { // ff = document.getElementById("example"), ef = ff.getContext("2d"); ff = sample_clishe ; ef = smpl_clishe; a = ef.getImageData(0, 0, ff.width, ff.height); for (_ = 0; _ < a.data.length; _ += 4) (a.data[_ + 0] > 230 && a.data[_ + 1] >= 230 || a.data[_ + 2] < 200 || a.data[_ + 1] > 200 || a.data[_] > 200) && (a.data[_] = 0, a.data[_ + 1] = 0, a.data[_ + 2] = 0, a.data[_ + 3] = 0); ef.putImageData(a, 0, 0), data_x = 28, data_y = 11, dater_left_x = parseInt((max_el[0] - data_x) / 2 * pixel_to_mm), dater_left_y = parseInt((max_el[1] - data_y) / 2 * pixel_to_mm), dater_size_x = parseInt(data_x * pixel_to_mm), dater_size_y = parseInt(data_y * pixel_to_mm), it_is_dater && ( smpl_clishe.scale(2, 2), ef.globalAlpha = .05, ef.fillStyle = "#101010", ef.fillRect(dater_left_x, dater_left_y, dater_size_x, dater_size_y), 3 == parseInt(current_press[7].split(",")[0]) ? (smpl_clishe.font = "bold 10px Arial", offset_y = 12, offset_x = 16) : (smpl_clishe.font = "bold 14px Arial", offset_y = 8, offset_x = 1), ef.fillStyle = "#000000", ef.strokeStyle = "#000000", ef.globalAlpha = .35, ef.fillText('', dater_left_x + global_offset_x - 1 + offset_x, dater_left_y + global_offset_y + offset_y + border + parseInt(24 - offset_y)) ); a = ef.getImageData(0, 0, ff.width, ff.height); // smpl_clishe.clearRect(0, 0, smpl_clishe.canvas.width, smpl_clishe.canvas.height); // smpl_clishe.scale(2, 2); // smpl_clishe.drawImage(ef.canvas, 0, 0); /* var t = document.getElementById("example"), e = t.getContext("2d"), a = e.getImageData(0, 0, t.width, t.height);*/ // a = smpl_clishe.getImageData(0, 0, smpl_clishe.width, smpl_clishe.height); /* var r = document.createElement("canvas"), s = r.getContext("2d"); r.width = sample_clishe.width, r.height = sample_clishe.height, s.drawImage(sample_clishe, 0, 0, sample_clishe.width, sample_clishe.height, 0, 0, r.width, r.height); */ data = sample_clishe.toDataURL(); data.replace("/+/g", " "); document.getElementById("id_sales_data").value = data; document.getElementById("id_sales_price").value = check_price; PushAllCookie() } with_resize = !1, stamp_price_min = 0, stamp_price_max = 0, stamp_full_price = 0, current_press = stamp_size[start_stamp], start_x = current_press[0], start_y = current_press[1]; var start_stamp_price = 0; min_char_height = 3, min_char_width = 1.5, max_line_count = 10, max_line_length = 75, fit_in_stamp = !0, text_change = !1; var sample_text = new Array; sample_text[0] = ['', "Arial", "normal", 10, 0, 0, 0], sample_text[1] = ['', "Arial", "bold", 10, 0, 0, 0], sample_text[2] = ['', "Arial", "normal", 8, 0, 0, 0], sample_text[3] = ['', "Arial", "bold", 16, 0, 0, 0], sample_text[4] = ['', "Arial", "normal", 10, 0, 0, 0],sample_text[5] = ['', "Arial", "italic", 11, 0, 0, 0]; var sample_date = new Array; sample_date[0] = ['', "Arial", "normal", 10, 0, 0, 0], sample_date[1] = ['', "Arial", "bold", 10, 0, 0, 0], sample_date[2] = ['', "Arial", "normal", 8, 0, 0, 0], sample_date[3] = ['', "Arial", "bold", 24, 0, 0, 0], sample_date[4] = ['', "Arial", "bold", 24, 0, 0, 0], sample_date[5] = ['', "Arial", "bold", 5, 0, 0, 0], sample_date[6] = ['', "Arial", "bold", 16, 0, 0, 0], sample_date[7] = ['', "Arial", "normal", 10, 0, 0, 0], sample_date[8] = ['', "Arial", "italic", 11, 0, 0, 0]; var stamp_text = new Array; stamp_text[0] = sample_text[0].slice(), stamp_text[1] = sample_text[1].slice(), stamp_text[2] = sample_text[2].slice(), stamp_text[3] = sample_text[3].slice(), stamp_text[4] = sample_text[4].slice(), stamp_text[5] = sample_text[5].slice(); var fontproperty = "", check_price = 0, loader = !0; pixel_to_mm = 3.9, min_draw_x = max_draw_x = 0, min_draw_y = max_draw_y = 0, global_offset_x = 0, global_offset_y = 0; var border = 2, date_border = 0; current_line_edit = 0, mashtab = 1, navigator.cookieEnabled || alert(''), text_is_change = '', text_place_change = '', $(function() { function t(t, e, a, _, r, s, i, n) { switch (i = i || 0, date_border = date_border || 0, textwidth = t.measureText(e).width, it_is_dater && _ >= dater_left_y - date_border + n && _ <= dater_left_y + dater_size_y + date_border ? delta_x = dater_size_x + 2 * date_border : delta_x = 0, i) { case 0: offset_x = parseInt((r - textwidth - border - delta_x) / 2); break; case -1: offset_x = 0; break; case 1: offset_x = r - textwidth - border - delta_x-2 } new_left_x = a + offset_x; _=_+1; n=n*mashtab; for (var l = 0; l < e.length; l++) textwidth = t.measureText(e[l]).width, delta_x > 0 && new_left_x >= dater_left_x - date_border && new_left_x <= dater_left_x + dater_size_x + date_border && (new_left_x += delta_x), new_left_x < left_x || new_left_x + textwidth > left_x + size_x || _ < left_y + border + n || _ > left_y + s - border ? (t.fillStyle = "#D00000", fit_in_stamp = !1) : (t.fillStyle = "#0000D0", fit_in_stamp = !0), t.fillText(e[l], new_left_x, _), new_left_x < min_draw_x && (min_draw_x = new_left_x), new_left_x += textwidth, new_left_x > max_draw_x && (max_draw_x = new_left_x), _ < min_draw_y && (min_draw_y = _), _ > max_draw_y && (max_draw_y = _) } function e() { $("#price span").html(current_press[3].toString()), price_list = Min_Max_Price(current_press[5].split(",")), price_min = price_list[0], price_max = price_list[price_list.length - 1], $("#price_min span").html(price_min.toString()), el1 = document.getElementById("price_max"), el2 = document.getElementById("price_do"), price_min == price_max ? (el1.setAttribute("display", "none"), el1.style.display = "none", el2.setAttribute("display", "none"), el2.style.display = "none") : (el1.setAttribute("display", ""), el1.style.display = "", el2.setAttribute("display", ""), el2.style.display = "", $("#price_max span").html(price_max.toString())), stamp_full_price = parseInt(current_press[3]) + price_min, $("#price_full span").html(stamp_full_price.toString()), $("#stamp_size_x").html(current_press[0]), $("#stamp_size_y").html(current_press[1]) } function a() { text_change = !1; for (var t = 0; t < max_line_count; t++) stamp_text[t] && (stamp_text[t][0] = "", stamp_text[t][1] = "Arial", stamp_text[t][2] = "normal", stamp_text[t][3] = "10", stamp_text[t][4] = "0", stamp_text[t][5] = "0", stamp_text[t][6] = "0") } function _() { if (a(), it_is_dater) for (var t = 0; t < sample_date.length; t++) stamp_text[t] = sample_date[t].slice(); else for (var t = 0; t < sample_text.length; t++) stamp_text[t] = sample_text[t].slice(); Restote_Text(), y(), v(), n(!0), text_change = !1 } function r() { loader = !0, RestoreDriver(loader), PopAllCookie(), e(), v(), y(), c(it_is_dater) } function s() { stamp_text[current_line_edit][4] = 0, stamp_text[current_line_edit][5] = 0, stamp_text[current_line_edit][6] = 0; try { $("#x-position").slider("option", "value", 0), $("#y-position").slider("option", "value", 0) } catch (t) {} } function n(t) { void 0 === t && (t = !0), t ? ($("#self_edit").addClass("tab-current"), $("#outer_edit").removeClass("tab-current"), $("#text_on_strings").css("display", ""), $("#text_off_strings").css("display", "none"), $("#text_parameters").css("display", ""), $("#submit_button").css("top", ""), $("#submit_button").css("width", ""), $("#submit_button").css("height", ""), $("#submit_button").css("left", ""), $("#submit_button")[0].value = '') : ($("#self_edit").removeClass("tab-current"), $("#outer_edit").addClass("tab-current"), $("#text_on_strings").css("display", "none"), $("#text_off_strings").css("display", ""), $("#text_parameters").css("display", "none"), /* $("#submit_button").css("top", "365px"), $("#submit_button").css("width", "99px"), $("#submit_button").css("left", "-140px"), $("#submit_button").css("position", "relative"), */ $("#submit_button")[0].value = '') } function l() { if (it_is_dater) for (var t = 0; 9 > t; t++) stamp_text[t] = sample_date[t].slice(); else for (var t = 0; 6 > t; t++) stamp_text[t] = sample_text[t].slice(); for (var t = t; t < max_line_count; t++) stamp_text[t] && (stamp_text[t][0] = ""); _(), v(), text_change = !1 } function o() { outer_text = nicEditors.findEditor("stamp_text_area").getContent().replace(/<[^>]+>/g, ""); var t = document.getElementById("example"), e = t.getContext("2d"); textwidth = parseInt(e.measureText(outer_text).width / 7) + 2; for (var a = 0, _ = 0, r = 0; 8 > r; r++) { stamp_text[r] || (stamp_text[r] = []); for (var s = 0; s < textwidth && a < outer_text.length - 1;) a++, a < outer_text.length && (s += e.measureText(outer_text[a]).width); stamp_text[r][0] = outer_text.substring(_, a), _ = a, stamp_text[r][1] = "Arial", stamp_text[r][2] = "normal", stamp_text[r][3] = 10, stamp_text[r][4] = 0, stamp_text[r][5] = 0, stamp_text[r][6] = 0 } for (var r = r; r < max_line_count; r++) stamp_text[r] && (stamp_text[r][0] = ""); text_change = !1 } function d() { n(!1), o(), it_is_dater ? (start_dater = 2, Stamp_Change(start_dater), ChangeQuickSample(start_dater)) : (start_stamp = 9, Stamp_Change(start_stamp), ChangeQuickSample(start_stamp)), e(), v(), text_change = !1 } function c(t) { t ? (el = document.getElementById("with_date"), el.checked = it_is_dater, $("#date_off").removeClass("tab-current"), $("#date_on").addClass("tab-current"), $("#date_option").css("display", "")) : (el = document.getElementById("with_date"), el.checked = it_is_dater, $("#date_on").removeClass("tab-current"), $("#date_off").addClass("tab-current"), $("#date_option").css("display", "none")) } function m() { for (var t = 0; t < max_line_count; t++) stamp_text[t] && (stamp_text[t][6] = 0); v(), RestoreDriver() } function p() { all_center = !0; for (var t = 0; t < max_line_count; t++) stamp_text[t] && 0 != stamp_text[t][6] && confirm('', m) } function u() { with_resize = !with_resize, x(), v() } function x() { with_resize ? ( $(".auto_text").css("border-style", "inset"), $(".auto_text").css("background-color", "lightblue"), mashtab = 1, p(), b = document.getElementById("example"), k = b.getContext("2d"), draw(!0,k), delta_x = parseInt((max_draw_x - min_draw_x - border) / pixel_to_mm) + 2 * border, delta_y = parseInt((max_draw_y - min_draw_y) / pixel_to_mm) + 2 * border, crop_x = current_press[0] / delta_x, crop_y = current_press[1] / delta_y, crop_x > crop_y ? mashtab = crop_y : mashtab = crop_x) : ($(".auto_text").css("border-style", "outset"), $(".auto_text").css("background-color", "initial"), mashtab = 1) } function f() { for (var t = 0; t < dater_count && !(dater_size[t][0] >= delta_x); t++); for (var t = t; t < dater_count && !(dater_size[t][1] >= delta_y); t++); if (auto_price = 99999, t < dater_count) { for (var e = t; e < dater_count; e++) price_list = Min_Max_Price(dater_size[e][5].split(",")), price_min = price_list[0], price_max = price_list[price_list.length - 1], stamp_full_price = parseInt(dater_size[e][3]) + price_min, stamp_full_price < auto_price && dater_size[e][1] >= delta_y && (t = e, auto_price = stamp_full_price); return t } return -1 } function g() { for (var t = 0; t < stamp_count && !(stamp_size[t][0] >= delta_x); t++); for (var t = t; t < stamp_count && !(stamp_size[t][1] >= delta_y); t++); if (auto_price = 99999, t < stamp_count) { for (var e = t; e < stamp_count; e++) { price_list = stamp_size[e][5].split(","), price_list.length > 0 && (price_min = parseInt(price_list[0].toString()), price_max = parseInt(price_list[0].toString())); for (var a = 1; a < price_list.length; a++) temp_price = parseInt(price_list[a].toString()), temp_price < price_min && (price_min = temp_price), temp_price > price_max && (price_max = temp_price); stamp_full_price = parseInt(stamp_size[e][3]) + price_min, stamp_full_price < auto_price && stamp_size[e][1] >= delta_y && (t = e, auto_price = stamp_full_price) } return t } return -1 } function y(t) { var e; for (t = t || "00", e = 0; e < max_line_count; e++) 10 > e ? temp_str = "0" + e.toString() : temp_str = e.toString(), el = document.getElementById("edit_" + temp_str), el.setAttribute("display", "none"), el.style.display = "none", el = document.getElementById("erase_" + temp_str), el.setAttribute("display", "none"), el.style.display = "none", el = document.getElementById("line_" + temp_str), el.style.color = "initial", stamp_line_count = parseInt(start_y / min_char_height), e < stamp_line_count ? (el.disabled = !1, el.style.backgroundColor = "white") : stamp_text[e] && (stamp_text[e][0].length > 0 ? (el.disabled = !0, el.style.backgroundColor = "lightgrey", el = document.getElementById("erase_" + temp_str), el.style.display = "") : (el.style.backgroundColor = "white", el.style.border = "inherit", el1 = document.getElementById("text_" + temp_str), el1.style.display = "none")), el.style.border = "inherit"; el = document.getElementById("edit_" + t), el.setAttribute("display", ""), el.style.display = "", el = document.getElementById("erase_" + t), el.setAttribute("display", ""), el.style.display = "", el = document.getElementById("line_" + t), el.style.color = "darkgreen", el.style.backgroundColor = "azure", el.style.border = "2px dotted darkgrey", current_line_edit = parseInt(t), stamp_text[current_line_edit] ? RestoreDriver(!0, stamp_text[current_line_edit][3], stamp_text[current_line_edit][2], stamp_text[current_line_edit][1], stamp_text[current_line_edit][4], stamp_text[current_line_edit][5], stamp_text[current_line_edit][6]) : RestoreDriver(!1) } function h() { outer_text.length > 0 && outer_text != nicEditors.findEditor("stamp_text_area").getContent().replace(/<[^>]+>/g, "") && (text_change = !0, o(), v()) } last_state = getCookie("last_stamp"), "drei" == last_state ? (loader = confirm('', r), loader = !1) : loader = !0, RestoreDriver(loader), PopAllCookie(); /* old_mashtab=1;*/ var v = function(a) { sample_clishe = document.getElementById("sample"); smpl_clishe = sample_clishe.getContext("2d"); // mashtab=old_mashtab; b = document.getElementById("example"); k = b.getContext("2d"); draw(a,k); /* old_mashtab=mashtab;*/ // mashtab=1+(1-mashtab)*2; smpl_clishe.scale(2, 2); draw(a,smpl_clishe); smpl_clishe.scale(0.5, 0.5); // mashtab=1+(1-mashtab)*2; draw(a,k); /* mashtab=old_mashtab;*/ }; function draw(a,cs) { // cs = cs || k; a = a || !1, a || x(), cs.clearRect(0, 0, cs.canvas.width, cs.canvas.height), cs.beginPath(), cs.lineWidth = "1"; cs.fillStyle = "#f0f0f0"; cs.globalAlpha = .1, cs.fillRect(0, 0, cs.canvas.width, cs.canvas.height), it_is_dater ? (max_el = dater_size[dater_count], current_press[7] || Restore_Date()) : max_el = stamp_size[stamp_count], min_draw_x = max_el[0] * pixel_to_mm, min_draw_y = max_el[1] * pixel_to_mm, max_draw_x = max_draw_y = 0, start_x = current_press[0], start_y = current_press[1], left_x = parseInt((max_el[0] - start_x) / 2 * pixel_to_mm), left_y = parseInt((max_el[1] - start_y) / 2 * pixel_to_mm), size_x = parseInt(start_x * pixel_to_mm), size_y = parseInt(start_y * pixel_to_mm), cs.globalAlpha = 1, cs.fillStyle = "azure", cs.fillRect(left_x, left_y, size_x, size_y), fontproperty = $("#font_strange").val() + " " + document.getElementById("font_value").value + "px " + $("#font_type").val(), offset_y = 0, temp_y = 0, data_x = 28, data_y = 11, dater_left_x = parseInt((max_el[0] - data_x) / 2 * pixel_to_mm), dater_left_y = parseInt((max_el[1] - data_y) / 2 * pixel_to_mm), dater_size_x = parseInt(data_x * pixel_to_mm), dater_size_y = parseInt(data_y * pixel_to_mm); for (var _ = 0; _ < max_line_count; _++) stamp_text[_] && stamp_text[_][0].length > 0 && (0 == offset_y && (temp_y =parseInt(.1 * stamp_text[_][3] * mashtab)), offset_y += parseInt(.75 * stamp_text[_][3] * mashtab), cs.font = stamp_text[_][2] + " " + stamp_text[_][3] * mashtab + "px " + stamp_text[_][1], t(cs, stamp_text[_][0], left_x + stamp_text[_][4] + global_offset_x + border, left_y + stamp_text[_][5] + global_offset_y + offset_y + border, size_x - border, size_y - border, stamp_text[_][6], parseInt(stamp_text[_][3] / 2)), offset_y += parseInt(.6 * stamp_text[_][3] * mashtab)); min_draw_y -= temp_y, it_is_dater && (cs.fillStyle = "#e8e8e8", cs.globalAlpha = 1, cs.fillRect(dater_left_x, dater_left_y, dater_size_x, dater_size_y), 3 == parseInt(current_press[7].split(",")[0]) ? (cs.font = "normal 15px Arial", offset_y = 12) : (cs.font = "normal 18px Arial", offset_y = 8), t(cs, "22 TPA 2016", dater_left_x + global_offset_x + border, dater_left_y + global_offset_y + offset_y + border + parseInt(24 - offset_y), dater_size_x - border, dater_size_y - border, 0, parseInt(size_y)), date_border && (cs.strokeStyle = "#0000D0", cs.strokeRect(dater_left_x - 1, dater_left_y - 1, dater_size_x + 1, dater_size_y + 1))), cs.clearRect(left_x - border, left_y - border, size_x + 2 * border, 2 * border), cs.clearRect(left_x - border, left_y + size_y - border, size_x + 2 * border, 2 * border), cs.clearRect(left_x - border, left_y - border, 2 * border, size_y + 2 * border), cs.clearRect(left_x + size_x - border, left_y - border, 2 * border, size_y + 2 * border), border && (cs.strokeStyle = "#0000D0", cs.strokeRect(left_x, left_y, size_x, size_y)), $("#picture span").html(current_press[2]), e(), picture_path = Size_to_Path("" + current_press[0]) + "_" + Size_to_Path("" + current_press[1]); }; $("#to_left").click(function() { stamp_text[current_line_edit][6] = -1, Switch_Allign(-1), v() }), $("#to_center").click(function() { stamp_text[current_line_edit][6] = 0, Switch_Allign(0), v() }), $("#to_right").click(function() { stamp_text[current_line_edit][6] = 1, Switch_Allign(1), v() }), $("#complete_order").click(function() { next_step() }), $("#center_str_text").click(function() { stamp_text[current_line_edit] && (s(), Switch_Allign(0)), v() }), $("#dec_font_size").click(function() { cur_font_size = document.getElementById("font_value").value, cur_font_size > 5 && stamp_text[current_line_edit] && (cur_font_size--, stamp_text[current_line_edit][3] = cur_font_size, document.getElementById("font_value").value = cur_font_size, v()) }), $("#inc_font_size").click(function() { cur_font_size = document.getElementById("font_value").value, cur_font_size < 80 && stamp_text[current_line_edit] && (cur_font_size++, stamp_text[current_line_edit][3] = cur_font_size, document.getElementById("font_value").value = cur_font_size, v()) }), $("#font_value").change(function() { stamp_text[current_line_edit] && (stamp_text[current_line_edit][3] = document.getElementById("font_value").value), v() }), $("#font_type").change(function() { stamp_text[current_line_edit] && (stamp_text[current_line_edit][1] = $("#font_type").val()), v() }), $("#font_strange").change(function() { stamp_text[current_line_edit] && (stamp_text[current_line_edit][2] = $("#font_strange").val()), v() }), $("#stamp_selector").change(function() { Stamp_Change($("#stamp_selector").val()), ChangeQuickSample($("#stamp_selector").val()), v(), y() }), $("#dater_selector").change(function() { Stamp_Change($("#dater_selector").val()), ChangeQuickSample($("#dater_selector").val()), v(), y() }), $("#stamp_border").click(function() { $(this).is(":checked") ? (border = 2, $("#stamp_border_span").html('')) : (border = 0, $("#stamp_border_span").html('')), v() }), $("#date_border").click(function() { date_border = $(this).is(":checked") ? 2 : 0, v() }), $("#with_date").click(function() { $(this).is(":checked") ? it_is_dater = !0 : it_is_dater = !1, text_change ? confirm('', _) : _(), Restore_Date(), y(), ChangeQuickSample(it_is_dater ? start_dater : start_stamp), v() }), $("#self_edit").click(function() { outer_text = "", mashtab = 1, it_is_dater ? (start_dater = 2, Stamp_Change(start_dater), ChangeQuickSample(start_dater)) : (start_stamp = 5, Stamp_Change(start_stamp), ChangeQuickSample(start_stamp)), text_change ? confirm(text_is_change, l) : _(), n(!0), v() }), $(".nicEdit-main").click(function() { o(), v() }), $("#outer_edit").click(function() { text_change ? confirm(text_place_change, d) : d() }), $("#date_off").click(function() { c(!1), it_is_dater && (it_is_dater = !1, text_change ? confirm(text_is_change, _) : (_(), start_stamp = 5, Stamp_Change(start_stamp), ChangeQuickSample(start_stamp)), Restore_Date(), y(), ChangeQuickSample(start_stamp), v()) }), $("#date_on").click(function() { c(!0), it_is_dater || (it_is_dater = !0, text_change ? confirm(text_is_change, _) : _(), Restore_Date(), y(), ChangeQuickSample(start_dater), v()) }), $(".auto_text").click(function() { with_resize ? (with_resize = !0, u()) : confirm('', u) }), $(".auto_size").click(function() { return with_resize = !1, $(".auto_text").css("border-style", "outset"), $(".auto_text").css("background-color", "initial"), mashtab = 1, v(), p(), delta_x = parseInt((max_draw_x - min_draw_x) / pixel_to_mm), delta_y = parseInt((max_draw_y - min_draw_y) / pixel_to_mm), it_is_dater ? result = f() : result = g(), result >= 0 ? (Stamp_Change(result), ChangeQuickSample(result), v(), void y()) : void alert("") }), $(".dec_x").click(function() { if (it_is_dater) { for (i = dater_x_size.length; i > 1 && !(dater_x_size[i - 1] < start_x); i--); for (j = start_dater; j > 1 && dater_size[j - 1][0] != dater_x_size[i - 1]; j--); if (start_dater == j - 1) return } else { for (i = x_size.length; i > 1 && !(x_size[i - 1] < start_x); i--); for (j = start_stamp; j > 1 && stamp_size[j - 1][0] != x_size[i - 1]; j--); if (start_stamp == j - 1) return } Stamp_Change(j - 1), ChangeQuickSample(j - 1), v(), y() }), $(".inc_x").click(function() { if (it_is_dater) { for (i = 0; i < dater_x_size.length - 1 && !(dater_x_size[i] > start_x); i++); for (j = start_dater; j < dater_count - 1 && dater_size[j][0] != dater_x_size[i]; j++); if (start_dater == j) return } else { for (i = 0; i < x_size.length - 1 && !(x_size[i] > start_x); i++); for (j = start_stamp; j < stamp_count - 1 && stamp_size[j][0] != x_size[i]; j++); if (start_stamp == j) return } Stamp_Change(j), ChangeQuickSample(j), v(), y() }), $(".dec_y").click(function() { if (it_is_dater) { for (i = dater_y_size.length; i > 1 && !(dater_y_size[i - 1] < start_y); i--); for (j = dater_count; j > 1 && dater_size[j - 1][1] != dater_y_size[i - 1]; j--); if (start_dater == j - 1) return } else { for (i = y_size.length; i > 1 && !(y_size[i - 1] < start_y); i--); for (j = stamp_count; j > 1 && stamp_size[j - 1][1] != y_size[i - 1]; j--); if (start_stamp == j - 1) return } Stamp_Change(j - 1), ChangeQuickSample(j - 1), v(), y() }), $(".inc_y").click(function() { if (it_is_dater) { for (i = 0; i < dater_y_size.length - 1 && !(dater_y_size[i] > start_y); i++); for (j = 0; j < dater_count - 1 && dater_size[j][1] != dater_y_size[i]; j++); if (start_dater == j) return } else { for (i = 0; i < y_size.length - 1 && !(y_size[i] > start_y); i++); for (j = 0; j < stamp_count - 1 && stamp_size[j][1] != y_size[i]; j++); if (start_stamp == j) return } Stamp_Change(j), ChangeQuickSample(j), v(), y() }), $(".text_in_line").keyup(function(t) { 9 != t.which && 16 != t.which ? (stamp_text[parseInt(this.id.substring(5))] = [this.value, document.getElementById("font_type").value, document.getElementById("font_strange").value, document.getElementById("font_value").value, 0, 0, 0], v()) : y(this.id.substring(5)) }), $(".text_in_line").click(function() { y(this.id.substring(5)) }), $(".text_in_line").change(function() { stamp_text[parseInt(this.id.substring(5))] = [this.value, document.getElementById("font_type").value, document.getElementById("font_strange").value, document.getElementById("font_value").value, 0, 0, 0], text_change = !0, v() }), $(".sample_img_stamp").click(function() { $(this).parent().parent().find(".active").removeClass("active"), $(this).addClass("active"), Stamp_Change($(this).attr("id")), y(), e(), v() }), $(".sample_img_dater").click(function() { $(this).parent().parent().find(".active").removeClass("active"), $(this).addClass("active"), Stamp_Change($(this).attr("id")), y(), e(), v() }), $(".variable").slick({ dots: !0, infinite: !1, variableWidth: !0, centerMode: !1, speed: 700, slidesToShow: 4, slidesToScroll: 3 }); try { $("#press_sample").slick("slickGoTo", $(".sample_img_stamp.active").parent().data("slick-index")) } catch (z) {} $(".erase").click(function() { el = $(this), x_line_edit = parseInt(el.attr("id").substring(6, 8)), stamp_text[x_line_edit][0] = "", text_change = !0, s(), temp_str = x_line_edit.toString(), x_line_edit < 10 && (temp_str = "0" + temp_str), el = document.getElementById("line_" + temp_str), el.value = "", v() }), e(), v(), y(), setInterval(h, 500), c(it_is_dater) });