let files = []; function contentFade(action){ if(action === "in"){ $("#fadeDiv").show() }else{ $("#fadeDiv").hide() } } $(document).on('click', '.allChk', function (){ $(this).parents('table').find('[type="checkbox"]').prop("checked", this.checked); }) $(document).on('click', '.page-item', function (){ if(!this.className.includes("modalPage")){ searchFormSubmit($(this).attr("data-pageindex")) }else{ searchModalSubmit($(this).attr("data-pageindex")) } }) $(document).on('click', '#searchModalBtn', function (){ searchModalSubmit(1); }) $(document).on('change', '#rowCnt', function (){ searchFormSubmit(1) }) function searchFormSubmit(pageIndex){ $("#pageIndex").val(pageIndex); $("#searchBtn").click(); } function searchModalSubmit(pageIndex){ $("#pageIndex").val(pageIndex); $.ajax({ url: $("#modalUrl").val(), data : $("#modalSearchForm").serialize(), type: 'GET', contentType: false, dataType:"html", success: function(html){ $("#modalBody").empty().append(html) if(selectedList !== undefined){ setSelectedChkBox(); } }, error:function(){ } }); } $(document).on('mouseenter', '.firstMenuLink', function (event){ $(".secondMenu").hide(); const targetMenu = $(this).parent().find(".secondMenu"); targetMenu.show() targetMenu.find("ul").css("padding-top",(event.clientY-20)+"px") }) $(document).on('mouseenter', '.secondMenuLink', function (event){ $(".thirdMenu").hide(); const targetMenu = $(this).parent().find(".thirdMenu"); targetMenu.show() targetMenu.find("ul").css("padding-top",(event.clientY-20)+"px") }) $(document).on('mouseleave', '.menuDiv', function (){ $(".secondMenu").hide(); $(".thirdMenu").hide(); }) $(document).on('change', '#fileInputer', function (){ for(const file of this.files){ setFileDiv(file, files.push(file)); } this.value = null; }) function byteCalculation(size) { const bytes = parseInt(size); const s = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']; const e = Math.floor(Math.log(bytes)/Math.log(1024)); if(e === "-Infinity") return "0 "+s[0]; else return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e]; } $(document).on('click', '.fileDelete', function (){ const target = $(this); files[Number(target.attr("data-fileidx"))].isDelete = true; target.parent().remove(); const uploadDiv = $("#uploadDiv"); if(uploadDiv.children().length === 0){ uploadDiv.append("
파일을 업로드 해주세요."); } }) $(document).on('click', '.uploadedFileDelete', function (){ const target = $(this).parent().find("span")[0]; if(target.className===""){ target.className = "text-decoration-line-through"; }else{ target.className = ""; } }) $(document).on('click', '.fileDownLink', function (){ const target = $(this) let url = "/file/fileDownload?" url += "board="+target.attr("data-board"); url += "&parentKey="+target.attr("data-parentkey"); url += "&fileSeq="+target.attr("data-fileseq"); window.open(encodeURI(url)); }) //Bootstrap multiple modal let count = 0; // 모달이 열릴 때 마다 count 해서 z-index값을 높여줌 $(document).on('show.bs.modal', '.modal', function () { let zIndex = 1040 + (10 * count); $(this).css('z-index', zIndex); setTimeout(function() { $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack'); }, 0); count = count + 1 }); // multiple modal Scrollbar fix $(document).on('hidden.bs.modal', '.modal', function(){ $('.modal:visible').length && $(document.body).addClass('modal-open'); }); function setUploadDiv(){ files = []; $("#uploadDiv").on("dragenter", function(e) { // $(this).addClass('drag-over'); }).on("dragleave", function(e) { // $(this).removeClass('drag-over'); }).on("dragover", function(e) { e.stopPropagation(); e.preventDefault(); }).on('drop', function(e) { e.preventDefault(); // $(this).removeClass('drag-over'); for(const file of e.originalEvent.dataTransfer.files){ setFileDiv(file, files.push(file)); } }).on('click', function (e){ if(e.target.className.indexOf("ileDelete")<0){ if(e.target.className.indexOf("artInfo")<0){ if(e.target.className.indexOf("artWork")<0){ $("#fileInputer").click(); } } } }); } function setFileDiv(file, idx){ const uploadDiv = $("#uploadDiv"); if($(".uploadedFileDelete").length===0 && $(".fileDelete").length === 0){ uploadDiv.empty(); } let fileInfo = "
"; fileInfo += file.name+" "+byteCalculation(file.size)+" "; fileInfo += "삭제"; fileInfo += "
"; uploadDiv.append(fileInfo); } function fileCheck(flag, files){ let totalSize = 0; for(const file of files) { if(!file.isDelete){ totalSize+=file.size; if(file.size>209715200){ alert("파일당 사이즈는 200MB을 넘길 수 없습니다.") flag = false; } } } if(totalSize>524288000){ alert("첨부파일의 용량 합은 500MB를 넘길 수 없습니다.") flag = false; } return flag; }