function send_to_textarea(e, t) { if (myField = document.getElementById(e), document.selection) myField.focus(), sel = document.selection.createRange(), sel.text = t, myField.focus(); else if (myField.selectionStart || "0" == myField.selectionStart) { var a = myField.selectionStart, r = myField.selectionEnd, o = myField.scrollTop; myField.value = myField.value.substring(0, a) + t + myField.value.substring(r, myField.value.length), myField.focus(), myField.selectionStart = a + t.length, myField.selectionEnd = a + t.length, myField.scrollTop = o } else myField.value += t, myField.focus() } function checked_by_class(e) { $("." + e).each(function() { this.checked = !this.checked }) } function do_ajax(e, t, a, r, o, n, i, s, l, c) { $.ajax({ manconf_id_for_show: r, manconf_id_for_loading: o, manconf_is_loading_need: n, manconf_loading_type: i, manconf_onsuccess: s, manconf_scroll_top: l, type: e, url: t, data: a, encoding: "UTF-8", cache: !1, id_hide: c, beforeSend: function() { ajax_before_send({ manconf_id_for_show: r, manconf_id_for_loading: o, manconf_is_loading_need: n, manconf_loading_type: i, manconf_onsuccess: s, manconf_scroll_top: l }) } }) } function do_load(e, t) { "on" == t ? (pageSize = new Array, "body" == e ? (pageSize.w = $(window).width(), pageSize.h = $(document).height(), pageSize.t = 0, pageSize.l = 0, m_app = "body") : (m_app = "#" + e, me = $(m_app).position("top"), pageSize.w = $(m_app).width(), pageSize.h = $(m_app).height(), pageSize.t = me.top, pageSize.l = me.left), first_loading[e] ? overlay = $("#lightbox-overlay_" + e) : ($(m_app).append(''), overlay = $("#lightbox-overlay_" + e), overlay.click(function() { $("#lightbox-overlay_" + e).animate({ height: "hide", opacity: "hide" }, "slow") }), first_loading[e] = "ok"), overlay.css({ position: "absolute", display: "none", top: pageSize.t, left: pageSize.l, zIndex: 1005, opacity: 0, height: pageSize.h + "px", width: pageSize.w + "px" }).fadeTo(1, .6).animate({ height: "show" }, "slow")) : $("#lightbox-overlay_" + e).animate({ height: "hide", opacity: "hide" }, "slow") } function table_show_list() { if ("ok" == var_list_show) { $("#hidden_" + var_get_page).columnManager({ listTargetID: "targetall", onClass: "advon", offClass: "advoff", hideInList: [1], saveState: !0, colsHidden: [var_colsHidden] }), $("#ulSelectColumn").clickMenu({ onClick: function() {} }) } } function include_once_js(e) { js_load[e] || (head = document.getElementsByTagName("head")[0], script = document.createElement("script"), script.type = "text/javascript", script.src = e, head.appendChild(script), js_load[e] = "ok") } function get_value_for_ajax(e) { return "" == e ? "" : (id = "" != last_form ? last_form + " #" + e + " " : e, $("#" + id).hasClass("checkbox_value") ? $("#" + id).is(":checked") ? $("#" + id).val() : "" : "checkbox" == $("#" + id).attr("type") ? $("#" + id).is(":checked") : $("#" + id).hasClass("inputprice") ? removecomma_obj("#" + id) : encodeURIComponent($("#" + id).hasClass("editor") ? editor_value(e) : $("#" + id).val())) } function change_list_class() { $(".list").each(function(e) { this.className = "list_" + e % 2 }) } function my_go(e) { setTimeout('document.location.href="' + decodeURIComponent(e) + '"', 100) } function select_user_value(e, t) { $("#" + e + " option").each(function() { this.value == t && (this.selected = !0) }) } function hide_id_link(e) { $("#" + e).find("a").each(function() { this.style.display = "none" }) } function moneycommasep(e) { var t = ",", a = e.value.replace(new RegExp(t, "g"), ""), r = new RegExp("\\B(\\d{3})(" + t + "|$)"); do a = a.replace(r, t + "$1"); while (a.search(r) >= 0); e.value = a } function removecomma(e) { var t = ","; return removed = document.getElementById(e).value.replace(new RegExp(t, "g"), ""), removed } function removecomma_obj(e) { var t = ","; return removed = $(e).val().replace(new RegExp(t, "g"), ""), removed } function array_search(e, t) { var a; bb = "no"; for (a in t) e === t[a] && (bb = a); return bb } function check_form_befor_submit(e, t, a) { id = t[0].id, my_error = "موارد الزامي را تکميل نماييد", my_ajax_form_error = $("#" + id).attr("ajax_error_id"); for (var r = 0; r < e.length; r++) { if (my_id = e[r].name, my_value = e[r].value, "ok" == $("#" + my_id).attr("ajax_require") && !$("#" + my_id).is(":disabled")) { if ("" == my_value) return my_ajax_error = $("#" + my_id).attr("ajax_error"), this_error = null == my_ajax_error ? my_error : my_ajax_error, $("#" + my_id).tooltip({ items: "#" + my_id, content: this_error, open: function(e) { setTimeout(function() { $(e.target).tooltip("destroy") }, 1e4) } }).tooltip("open"), $("#" + my_ajax_form_error).show("slow").html(this_error), $("#" + my_id).removeClass("my_error_fill_ok").addClass("my_error_fill_error").css({ "background-color": "#FFF1F2", border: "1px solid red" }).focus(), $(".pe#" + my_ajax_form_error).fadeOut(5e3), "ok" == a.manconf_scroll_top && $("html,body").animate({ scrollTop: 0 }, 800), setTimeout("$('#" + my_id + "').css('background-color','" + $("#" + my_id).css("background-color") + "')", 1e3), "admin" == my_site_place, !1; if ($("#" + my_id).is("[ajax_validate]")) if (validate = $("#" + my_id).attr("ajax_validate"), pat_arr = new Array, pat_arr.email = /^[a-zA-Z0-9-._]+@[a-zA-Z0-9-._]+\.[a-zA-Z0-9-._]{2,4}$/i, pat_arr.url = /http\:\/\/[a-zA-Z0-9-._]+\.[a-zA-Z]{2,4}/i, pat_arr.user = /^[a-zA-Z0-9-._]{3,40}$/, pat_arr.pass = /^[a-zA-Z0-9-._]{5,40}$/, pat_arr.mobile = /^09[0-9]{9}$/, pat_arr.tell = /^(0[0-9]{3})?[0-9]{7,8}$/, pat_arr.number = /^([0-9]+)$/, "price" == validate) { if (!$.isNumeric(my_value)) return !1 } else "mobile" == validate ? (value = pat_arr.mobile, my_value.match(new RegExp(value)) || alert(value)) : "email" == validate && (value = pat_arr.email, my_value.match(new RegExp(value)) || alert(value)) } $("#" + my_id).removeClass("my_error_fill_error").addClass("my_error_fill_ok") } ajax_before_send(a) } function check_form_do_success(e, t, a, r, o, n) { $("#" + e).removeClass("my_error_error").addClass("my_error_success"), "ok" == r && ($("#" + t).slideUp(), "admin" == my_site_place && (a += '[ فرم خالي] [ فرم حاوی اطلاعات تکمیل شده]")), "" !== a && null !== a && $("#" + e).append(a), "" !== o && null !== n && $("#" + o).hide("slow"), "" !== n && null !== n && ($("#list_" + n).addClass("list_delete"), $("#list_" + n).find("td").addClass("list_delete"), hide_id_link("list_" + n)) } function check_form_do_delete(e, t) { do_ajax("POST", e, t, "ajax_error", "body", "ok", "normal", "write") } function confirm_submitdata(e) { var t = confirm("از ثبت درخواست اطمینان دارید؟"); 1 == t && check_form_and_send_with_ajax(e) } function form_need_onload() { $("form[ajax=ok]").each(function() { $(this).is("[mdajax]") || ($(this).attr("mdajax", "ok"), check_form_and_send_with_ajax($(this).attr("id"))) }), $(".inputprice").keyup(function() { moneycommasep(this) }).click(function() { moneycommasep(this) }), $(".isnumeric").keypress(function(e) { return "no" != $(this).attr("isnumeric") && 8 != e.which && 0 != e.which && (e.which < 48 || e.which > 57) ? ($(".isnumeric_error").remove(), $(this).after(" لطفا مقدار را به صورت عددي وارد كنيد"), $(".isnumeric_error").fadeOut(5e3), !1) : void 0 }) } function check_form_and_send_with_ajax(e) { $("#" + e + " input[type=file]").length > 0 && $("#" + e).attr("enctype", "multipart/form-data"), $("#" + e + " input,#" + e + " textarea,#" + e + " select").each(function() { $(this).is("[name]") || $(this).attr("name", $(this).attr("id")) }), $("#" + e).is("[ajax_error_id]") || $("#" + e).attr("ajax_error_id", "ajax_error"), $("#" + e).attr("action", $("#" + e).attr("ajaxurl")).attr("method", "POST"), scrolltop = $("#" + e).attr("scrolltop"), my_ajax_form_error = $("#" + e).attr("ajax_error_id"); var t = { beforeSubmit: check_form_befor_submit, manconf_form: !0, manconf_id_for_show: my_ajax_form_error, manconf_id_for_loading: "body", manconf_is_loading_need: "ok", manconf_loading_type: "normal", manconf_onsuccess: "write", manconf_scroll_top: scrolltop }; $("#" + e).ajaxForm(t) } function clearFields(e) { $("input,select,textarea", "#" + e).each(function() { var e = this.type, t = this.tagName.toLowerCase(); if ("text" == e || "password" == e || "" == t) this.value = ""; else if ("textarea" == e) if ("editor" == $(this).attr("class")) { var a = FCKeditorAPI.GetInstance($(this).attr("id")); a.SetData("") } else this.value = ""; else "checkbox" == e || "radio" == e ? this.checked = !1 : "select" == t && (this.selectedIndex = -1) }) } function mycallbackform_delete_all(e) { my_d_i = "selected=ok", $("input[ch=ok]:checked").each(function() { my_d_i += "&id[]=" + $(this).val() }), "selected=ok" !== my_d_i && check_form_do_delete(e, my_d_i) } function ajax_confirm_send_ok(e) { "no" !== e && (mySplitResult = e.split("@@@"), check_form_do_delete(mySplitResult[0], mySplitResult[1])) } function ajax_confirm_send(e, t) { $.prompt("آيا از همه ي موارد انتخاب شده اطمينان داريد؟", { callback: ajax_confirm_send_ok, buttons: { "بله": e + "@@@" + t, "خير": "no" }, show: "slideDown" }) } function delete_all_confirm(e) { $.prompt("آيا از همه ي موارد انتخاب شده اطمينان داريد؟", { callback: mycallbackform_delete_all, buttons: { "بله": e, "خير": "no" }, show: "slideDown" }) } function list_select_all() { $("input[ch=ok]").each(function() { this.checked = !this.checked }) } function select_all(e) { for (field = document.getElementById(e), i = 0; i < field.length; i++) "checkbox" == field[i].type && "record_arr[]" == field[i].name && (field[i].checked = !0) } function form_style() { $("form input[type=checkbox]").addClass("form_input_type_checkbox"), $("form input[type=text]").addClass("form_input_type_text"), $("form input[type=submit]").addClass("form_input_type_submit"), $("form button[type=submit]").addClass("form_input_type_submit") } function show_tooltip_result(e, t) { my_id = e.attr("id"), $("#" + my_id).tooltip({ items: "#" + my_id, content: t, open: function(e) { setTimeout(function() { $(e.target).tooltip("destroy") }, 1e4) } }).tooltip("open") } function require_select(e, t) { $("#" + e).each(function() { this.selectedIndex = -1, $(this).val("").attr("ajax_require", "ok").attr("ajax_error", t) }) } function max_length_textarea() { $("textarea[maxlength]").keyup(function() { var e = parseInt($(this).attr("maxlength")), t = $(this).val(), a = t.length; if (a > e) { var r = t.substr(0, e); $(this).val(r) } }) } function ajax_before_send(e) { "undefined" != typeof e.manconf_id_for_show && ("undefined" != typeof e.manconf_form && ($("#disabled_button").attr("disabled", "disabled"), $("#" + e.manconf_id_for_show).addClass("my_error_error").show("slow").html("منتظر بمانيد...")), "ok" == e.manconf_is_loading_need && ("user" == my_site_place && $("#" + e.manconf_id_for_show).html('
لطفا صبر کنید...
'), do_load(e.manconf_id_for_loading, "on", e.manconf_loading_type))) } function PreviewImage(e, t) { var a = new FileReader; a.readAsDataURL(document.getElementById(e).files[0]), a.onload = function(e) { document.getElementById(t).src = e.target.result }, document.getElementById(t).style.display = "block" } function foucse_error_field(e) { $("#" + e).removeClass("my_error_fill_ok").addClass("my_error_fill_error").css({ "background-color": "#FFF1F2", border: "1px solid red" }).focus() }! function(e) { "function" == typeof define && define.amd ? define(["jquery"], e) : e("undefined" != typeof jQuery ? jQuery : window.Zepto) }(function(e) { "use strict"; function t(t) { var a = t.data; t.isDefaultPrevented() || (t.preventDefault(), e(t.target).ajaxSubmit(a)) } function a(t) { var a = t.target, r = e(a); if (!r.is("[type=submit],[type=image]")) { var o = r.closest("[type=submit]"); if (0 === o.length) return; a = o[0] } var n = this; if (n.clk = a, "image" == a.type) if (void 0 !== t.offsetX) n.clk_x = t.offsetX, n.clk_y = t.offsetY; else if ("function" == typeof e.fn.offset) { var i = r.offset(); n.clk_x = t.pageX - i.left, n.clk_y = t.pageY - i.top } else n.clk_x = t.pageX - a.offsetLeft, n.clk_y = t.pageY - a.offsetTop; setTimeout(function() { n.clk = n.clk_x = n.clk_y = null }, 100) } function r() { if (e.fn.ajaxSubmit.debug) { var t = "[jquery.form] " + Array.prototype.join.call(arguments, ""); window.console && window.console.log ? window.console.log(t) : window.opera && window.opera.postError && window.opera.postError(t) } } var o = {}; o.fileapi = void 0 !== e("").get(0).files, o.formdata = void 0 !== window.FormData; var n = !!e.fn.prop; e.fn.attr2 = function() { if (!n) return this.attr.apply(this, arguments); var e = this.prop.apply(this, arguments); return e && e.jquery || "string" == typeof e ? e : this.attr.apply(this, arguments) }, e.fn.ajaxSubmit = function(t) { function a(a) { var r, o, n = e.param(a, t.traditional).split("&"), i = n.length, s = []; for (r = 0; i > r; r++) n[r] = n[r].replace(/\+/g, " "), o = n[r].split("="), s.push([decodeURIComponent(o[0]), decodeURIComponent(o[1])]); return s } function i(r) { for (var o = new FormData, n = 0; n < r.length; n++) o.append(r[n].name, r[n].value); if (t.extraData) { var i = a(t.extraData); for (n = 0; n < i.length; n++) i[n] && o.append(i[n][0], i[n][1]) } t.data = null; var s = e.extend(!0, {}, e.ajaxSettings, t, { contentType: !1, processData: !1, cache: !1, type: l || "POST" }); t.uploadProgress && (s.xhr = function() { var a = e.ajaxSettings.xhr(); return a.upload && a.upload.addEventListener("progress", function(e) { var a = 0, r = e.loaded || e.position, o = e.total; e.lengthComputable && (a = Math.ceil(r / o * 100)), t.uploadProgress(e, r, o, a) }, !1), a }), s.data = null; var c = s.beforeSend; return s.beforeSend = function(e, a) { a.data = t.formData ? t.formData : o, c && c.call(this, e, a) }, e.ajax(s) } function s(a) { function o(e) { var t = null; try { e.contentWindow && (t = e.contentWindow.document) } catch (a) { r("cannot get iframe.contentWindow document: " + a) } if (t) return t; try { t = e.contentDocument ? e.contentDocument : e.document } catch (a) { r("cannot get iframe.contentDocument: " + a), t = e.document } return t } function i() { function t() { try { var e = o(y).readyState; r("state = " + e), e && "uninitialized" == e.toLowerCase() && setTimeout(t, 50) } catch (a) { r("Server abort: ", a, " (", a.name, ")"), s(T), $ && clearTimeout($), $ = void 0 } } var a = u.attr2("target"), n = u.attr2("action"); k.setAttribute("target", p), (!l || /post/i.test(l)) && k.setAttribute("method", "POST"), n != m.url && k.setAttribute("action", m.url), m.skipEncodingOverride || l && !/post/i.test(l) || u.attr({ encoding: "multipart/form-data", enctype: "multipart/form-data" }), m.timeout && ($ = setTimeout(function() { b = !0, s(j) }, m.timeout)); var i = []; try { if (m.extraData) for (var c in m.extraData) m.extraData.hasOwnProperty(c) && i.push(e.isPlainObject(m.extraData[c]) && m.extraData[c].hasOwnProperty("name") && m.extraData[c].hasOwnProperty("value") ? e('').val(m.extraData[c].value).appendTo(k)[0] : e('').val(m.extraData[c]).appendTo(k)[0]); m.iframeTarget || h.appendTo("body"), y.attachEvent ? y.attachEvent("onload", s) : y.addEventListener("load", s, !1), setTimeout(t, 15); try { k.submit() } catch (d) { var f = document.createElement("form").submit; f.apply(k) } } finally { k.setAttribute("action", n), a ? k.setAttribute("target", a) : u.removeAttr("target"), e(i).remove() } } function s(t) { if (!v.aborted && !E) { if (C = o(y), C || (r("cannot access response document"), t = T), t === j && v) return v.abort("timeout"), void w.reject(v, "timeout"); if (t == T && v) return v.abort("server abort"), void w.reject(v, "error", "server abort"); if (C && C.location.href != m.iframeSrc || b) { y.detachEvent ? y.detachEvent("onload", s) : y.removeEventListener("load", s, !1); var a, n = "success"; try { if (b) throw "timeout"; var i = "xml" == m.dataType || C.XMLDocument || e.isXMLDoc(C); if (r("isXml=" + i), !i && window.opera && (null === C.body || !C.body.innerHTML) && --A) return r("requeing onLoad callback, DOM not available"), void setTimeout(s, 250); var l = C.body ? C.body : C.documentElement; v.responseText = l ? l.innerHTML : null, v.responseXML = C.XMLDocument ? C.XMLDocument : C, i && (m.dataType = "xml"), v.getResponseHeader = function(e) { var t = { "content-type": m.dataType }; return t[e.toLowerCase()] }, l && (v.status = Number(l.getAttribute("status")) || v.status, v.statusText = l.getAttribute("statusText") || v.statusText); var c = (m.dataType || "").toLowerCase(), d = /(json|script|text)/.test(c); if (d || m.textarea) { var u = C.getElementsByTagName("textarea")[0]; if (u) v.responseText = u.value, v.status = Number(u.getAttribute("status")) || v.status, v.statusText = u.getAttribute("statusText") || v.statusText; else if (d) { var p = C.getElementsByTagName("pre")[0], _ = C.getElementsByTagName("body")[0]; p ? v.responseText = p.textContent ? p.textContent : p.innerText : _ && (v.responseText = _.textContent ? _.textContent : _.innerText) } } else "xml" == c && !v.responseXML && v.responseText && (v.responseXML = z(v.responseText)); try { D = M(v, c, m) } catch (g) { n = "parsererror", v.error = a = g || n } } catch (g) { r("error caught: ", g), n = "error", v.error = a = g || n } v.aborted && (r("upload aborted"), n = null), v.status && (n = v.status >= 200 && v.status < 300 || 304 === v.status ? "success" : "error"), "success" === n ? (m.success && m.success.call(m.context, D, "success", v), w.resolve(v.responseText, "success", v), f && e.event.trigger("ajaxSuccess", [v, m])) : n && (void 0 === a && (a = v.statusText), m.error && m.error.call(m.context, v, n, a), w.reject(v, "error", a), f && e.event.trigger("ajaxError", [v, m, a])), f && e.event.trigger("ajaxComplete", [v, m]), f && !--e.active && e.event.trigger("ajaxStop"), m.complete && m.complete.call(m.context, v, n), E = !0, m.timeout && clearTimeout($), setTimeout(function() { m.iframeTarget ? h.attr("src", m.iframeSrc) : h.remove(), v.responseXML = null }, 100) } } } var c, d, m, f, p, h, y, v, g, x, b, $, k = u[0], w = e.Deferred(); if (w.abort = function(e) { v.abort(e) }, a) for (d = 0; d < _.length; d++) c = e(_[d]), n ? c.prop("disabled", !1) : c.removeAttr("disabled"); if (m = e.extend(!0, {}, e.ajaxSettings, t), m.context = m.context || m, p = "jqFormIO" + (new Date).getTime(), m.iframeTarget ? (h = e(m.iframeTarget), x = h.attr2("name"), x ? p = x : h.attr2("name", p)) : (h = e('