|
|
@ -1,16 +1,16 @@
|
|
|
|
/**************************************************************************
|
|
|
|
/**************************************************************************
|
|
|
|
* 그리드 내부 이미지 첨부
|
|
|
|
* 그리드 내부 이미지 첨부
|
|
|
|
**************************************************************************/
|
|
|
|
**************************************************************************/
|
|
|
|
function fnMakeGridImageViewer(tdEl, fileInputElName, fileInfo){
|
|
|
|
function fnMakeGridImageViewer(tdEl, fileInputElName, fileInfo) {
|
|
|
|
|
|
|
|
|
|
|
|
let fileInputEl = document.createElement("input");
|
|
|
|
let fileInputEl = document.createElement("input");
|
|
|
|
fileInputEl.name = fileInputElName;
|
|
|
|
fileInputEl.name = fileInputElName;
|
|
|
|
fileInputEl.type = "file";
|
|
|
|
fileInputEl.type = "file";
|
|
|
|
fileInputEl.setAttribute("hidden","hidden");
|
|
|
|
fileInputEl.setAttribute("hidden", "hidden");
|
|
|
|
fileInputEl.setAttribute("accept","image/*")
|
|
|
|
fileInputEl.setAttribute("accept", "image/*")
|
|
|
|
tdEl.appendChild(fileInputEl);
|
|
|
|
tdEl.appendChild(fileInputEl);
|
|
|
|
|
|
|
|
|
|
|
|
if(fileInfo != null){
|
|
|
|
if (fileInfo != null) {
|
|
|
|
fileInputEl.dataset.url = fileInfo.URL;
|
|
|
|
fileInputEl.dataset.url = fileInfo.URL;
|
|
|
|
fileInputEl.dataset.fileNm = fileInfo.FILE_NM;
|
|
|
|
fileInputEl.dataset.fileNm = fileInfo.FILE_NM;
|
|
|
|
fileInputEl.dataset.mimeType = fileInfo.MIME_TYPE;
|
|
|
|
fileInputEl.dataset.mimeType = fileInfo.MIME_TYPE;
|
|
|
@ -19,38 +19,38 @@ function fnMakeGridImageViewer(tdEl, fileInputElName, fileInfo){
|
|
|
|
|
|
|
|
|
|
|
|
let uploadButtonEl = document.createElement("button");
|
|
|
|
let uploadButtonEl = document.createElement("button");
|
|
|
|
uploadButtonEl.type = "button";
|
|
|
|
uploadButtonEl.type = "button";
|
|
|
|
uploadButtonEl.classList.add("btn","btn-primary","w-px-50", "mx-1");
|
|
|
|
uploadButtonEl.classList.add("btn", "btn-primary", "w-px-50", "mx-1");
|
|
|
|
uploadButtonEl.textContent = "등록";
|
|
|
|
uploadButtonEl.textContent = "등록";
|
|
|
|
tdEl.appendChild(uploadButtonEl);
|
|
|
|
tdEl.appendChild(uploadButtonEl);
|
|
|
|
|
|
|
|
|
|
|
|
let viewButtonEl = document.createElement("button");
|
|
|
|
let viewButtonEl = document.createElement("button");
|
|
|
|
viewButtonEl.type = "button";
|
|
|
|
viewButtonEl.type = "button";
|
|
|
|
viewButtonEl.classList.add("btn","btn-primary","w-px-50", "mx-1");
|
|
|
|
viewButtonEl.classList.add("btn", "btn-primary", "w-px-50", "mx-1");
|
|
|
|
viewButtonEl.setAttribute("hidden","hidden");
|
|
|
|
viewButtonEl.setAttribute("hidden", "hidden");
|
|
|
|
viewButtonEl.textContent = "보기";
|
|
|
|
viewButtonEl.textContent = "보기";
|
|
|
|
tdEl.appendChild(viewButtonEl);
|
|
|
|
tdEl.appendChild(viewButtonEl);
|
|
|
|
|
|
|
|
|
|
|
|
$(fileInputEl).on("change", function(){
|
|
|
|
$(fileInputEl).on("change", function () {
|
|
|
|
if(this.files != null && this.files.length > 0){
|
|
|
|
if (this.files != null && this.files.length > 0) {
|
|
|
|
$(uploadButtonEl).text("수정");
|
|
|
|
$(uploadButtonEl).text("변경");
|
|
|
|
$(viewButtonEl).removeAttr("hidden");
|
|
|
|
$(viewButtonEl).removeAttr("hidden");
|
|
|
|
} else if(this.dataset.url != null){
|
|
|
|
} else if (this.dataset.url != null) {
|
|
|
|
$(uploadButtonEl).text("수정");
|
|
|
|
$(uploadButtonEl).text("변경");
|
|
|
|
$(viewButtonEl).removeAttr("hidden");
|
|
|
|
$(viewButtonEl).removeAttr("hidden");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$(uploadButtonEl).text("등록");
|
|
|
|
$(uploadButtonEl).text("등록");
|
|
|
|
$(viewButtonEl).attr("hidden","hidden");
|
|
|
|
$(viewButtonEl).attr("hidden", "hidden");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(uploadButtonEl).on("click", function(){
|
|
|
|
$(uploadButtonEl).on("click", function () {
|
|
|
|
$(fileInputEl).click();
|
|
|
|
$(fileInputEl).click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(viewButtonEl).on("click", function(){
|
|
|
|
$(viewButtonEl).on("click", function () {
|
|
|
|
|
|
|
|
|
|
|
|
let viewUrl = "";
|
|
|
|
let viewUrl = "";
|
|
|
|
if(fileInputEl.files.length != 0){
|
|
|
|
if (fileInputEl.files.length != 0) {
|
|
|
|
viewUrl = (window.URL || window.webkitURL).createObjectURL(fileInputEl.files[0]);
|
|
|
|
viewUrl = (window.URL || window.webkitURL).createObjectURL(fileInputEl.files[0]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
viewUrl = fileInputEl.dataset.url;
|
|
|
|
viewUrl = fileInputEl.dataset.url;
|
|
|
|