$(function() { $(".date_picker").datepicker({ dateFormat : "yy-mm-dd", showOn : "both", buttonImage : "/images/calendar.gif", buttonImageOnly : true, monthNames : ["01월","02월","03월","04월","05월","06월","07월","08월","09월","10월","11월","12월"], dayNamesMin : ["일", "월", "화", "수", "목", "금", "토"], changeYear : true }); $(".imgList a").click(function() { var src = $(this).closest("li").find("#product_image").prop("src"); $("#product_pop_image").prop("src", src); $(".popBg").fadeIn(); }); $(".popClose").click(function() { $(".popBg").fadeOut(); }); var fileTarget = $(".filebox .upload-hidden"); fileTarget.on('change', function(){ if (window.FileReader) { var filename = $(this)[0].files[0].name; } else { var filename = $(this).val().split("/").pop().split("\\").pop(); }; $(this).siblings(".upload-name").val(filename); }); }); var common = new function() { this.attach_upload = function(obj) { if ($(obj).val()) { var form = $(obj).closest("form"); var owner = $(obj).attr("owner"); var target = $(obj).attr("target"); var option = { type : "POST", url : "/common/file_upload.php?type=attach&owner=" + owner, dataType : "json", success : function(rst) { if (rst.error) { alert(rst.error); } else { var btn_attach_delete = ""; btn_attach_delete += "" + rst.file_name; btn_attach_delete += " "; btn_attach_delete += ""; $("#" + target).append(btn_attach_delete); } var agent = navigator.userAgent.toLowerCase(); if (agent.indexOf("msie") != -1) { $(obj).replaceWith($(obj).clone(true)); } else { $(obj).val(""); } }, error : function(e) { alert(e.status + " Error"); } }; form.ajaxSubmit(option); } }; this.attach_delete = function(obj) { var file_no = $(obj).attr("file_no"); var file_path = $(obj).attr("file_path"); var target = $(obj).parent(); if (confirm("삭제하시겠습니까?")) { $.ajax({ type : "POST", url : "/common/file_delete.php", data : {"file_no" : file_no, "file_path" : file_path}, dataType : "json", success: function(rst) { if (rst.success) { target.remove(); } }, error : function(e) { alert(e.status + " Error"); } }); } }; this.attach_download = function(obj) { var file_path = $(obj).attr("file_path"); var file_name = $(obj).attr("file_name"); location.href = "/common/file_download.php?file_path=" + file_path + "&file_name=" + file_name; }; this.check_pattern = function(val, type) { var pattern_id = /^[a-zA-Z0-9]{4,20}$/; var pattern_passwd = /^.{8,20}$/; var pattern_alphabat = /[a-zA-Z]/g; var pattern_number = /[0-9]/g; var pattern_special = /[~!@#$%^&*()_+|<>?:{}]/g; var pattern_email = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i; var result; if (type == "id") { result = (pattern_id.test(val) && pattern_alphabat.test(val)); } else if (type == "passwd") { result = (pattern_passwd.test(val) && pattern_alphabat.test(val) && pattern_number.test(val) && pattern_special.test(val)); } else if (type == "email") { result = pattern_email.test(val); } return result; }; this.search_address = function(id) { var filter = "win16|win32|win64|mac|macintel"; if (navigator.platform) { if (filter.indexOf(navigator.platform.toLowerCase()) < 0) { var width = "90%"; var height = parseInt($(window).height() * 0.9); } else { var width = "540"; var height = "540"; } } $("body").append("
"); $("#modal_post").dialog({ title : "우편번호 검색", resizable : false, modal : true, width : width, height : height, close : function() { $("#modal_post").remove(); } }); new daum.Postcode({ width : "100%", height : "100%", oncomplete: function(data) { $("#" + (id ? id + "_" : "") + "zipcode").val(data.zonecode); $("#" + (id ? id + "_" : "") + "address").val(data.address); $("#modal_post").dialog("close"); } }).embed($("#modal_post")[0]); }; }