diff --git a/src/main/webapp/WEB-INF/jsp/fims/ogdp/ogdp01010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/ogdp/ogdp01010-main.jsp index 2d713be1..ccdae165 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/ogdp/ogdp01010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/ogdp/ogdp01010-main.jsp @@ -408,9 +408,9 @@ $(document).ready(function(){ }; //이미지 뷰어 - fnMakeSingleImageViewer($P.find("offcsImage"), $P.find("offcs"), "orgn-path", "orgn-name"); - fnMakeSingleImageViewer($P.find("symbolImage"), $P.find("symbol"), "orgn-path", "orgn-name"); - fnMakeSingleImageViewer($P.find("logoImage"), $P.find("logo"), "orgn-path", "orgn-name"); + FimsComponentization.fnMakeSingleImageViewer($P.find("offcsImage"), $P.find("offcs"), "orgn-path", "orgn-name"); + FimsComponentization.fnMakeSingleImageViewer($P.find("symbolImage"), $P.find("symbol"), "orgn-path", "orgn-name"); + FimsComponentization.fnMakeSingleImageViewer($P.find("logoImage"), $P.find("logo"), "orgn-path", "orgn-name"); //시군구 기본 설정 저장 버튼 $P.$find("btnSaveSgg").on("click", function(){ diff --git a/src/main/webapp/WEB-INF/jsp/fims/stng01010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/stng01010-main.jsp index a845a55e..afd6ad8b 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/stng01010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/stng01010-main.jsp @@ -386,9 +386,9 @@ $(document).ready(function(){ var lastTr = $P.$find(tbodyName).find("tr").last()[0]; - fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontNm")); - fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontColr")); - fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontStyle")); + FimsComponentization.fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontNm")); + FimsComponentization.fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontColr")); + FimsComponentization.fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontStyle")); $($P.fnGetElement(lastTr,"otptArtclNm")).set(data.OTPT_ARTCL_NM); $($P.fnGetElement(lastTr,"componentType")).set(data.COMPONENT_TYPE); @@ -427,7 +427,7 @@ $(document).ready(function(){ var sel = $P.fnGetElement(this,"textSort"); var toPrev = $(sel).siblings()[0]; var toNext = $(sel).siblings()[1]; - fnMakeSpinnerSelect(sel, toPrev, toNext); + FimsComponentization.fnMakeSpinnerSelect(sel, toPrev, toNext); var scrollDivName = ""; if(tbodyName == "tbodyUnique"){ @@ -438,7 +438,7 @@ $(document).ready(function(){ var rowSpinButtons = $(this).find("td[data-col='otptArtclSeq']").find("button"); - fnMakeRowSpinner(this,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.validForBackground); + FimsComponentization.fnMakeRowSpinner(this,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.validForBackground); }); } @@ -527,9 +527,9 @@ $(document).ready(function(){ var lastTr = $P.$find(tbodyName).find("tr").last()[0]; - fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontNm")); - fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontColr")); - fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontStyle")); + FimsComponentization.fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontNm")); + FimsComponentization.fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontColr")); + FimsComponentization.fnMakeOptionStyleSelect($P.fnGetElement(lastTr,"fontStyle")); var scrollDivName = ""; if(tbodyName == "tbodyUnique"){ @@ -538,7 +538,7 @@ $(document).ready(function(){ scrollDivName = "scrollMultiple"; } var rowSpinButtons = $(lastTr).find("td[data-col='otptArtclSeq']").find("button"); - fnMakeRowSpinner(lastTr,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.validForBackground); + FimsComponentization.fnMakeRowSpinner(lastTr,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.validForBackground); if(otptArtclNm != null && otptArtclNm != ""){ @@ -580,7 +580,7 @@ $(document).ready(function(){ var sel = $P.fnGetElement(lastTr,"textSort"); var toPrev = $(sel).siblings()[0]; var toNext = $(sel).siblings()[1]; - fnMakeSpinnerSelect(sel, toPrev, toNext); + FimsComponentization.fnMakeSpinnerSelect(sel, toPrev, toNext); if(tbodyName == "tbodyUnique"){ $P.$find("scrollUnique").scrollTop($P.find("scrollUnique").scrollHeight); diff --git a/src/main/webapp/WEB-INF/jsp/fims/stng01020-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/stng01020-main.jsp index fba12625..cbf271a1 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/stng01020-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/stng01020-main.jsp @@ -271,7 +271,7 @@ $(document).ready(function(){ var rowSpinButtons = $(this).find("td[data-col='extrArtclOrdr']").find("button"); - fnMakeRowSpinner(this,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.valid); + FimsComponentization.fnMakeRowSpinner(this,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.valid); }); } @@ -337,7 +337,7 @@ $(document).ready(function(){ scrollDivName = "scrollCustom"; } var rowSpinButtons = $(lastTr).find("td[data-col='extrArtclOrdr']").find("button"); - fnMakeRowSpinner(lastTr,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.valid); + FimsComponentization.fnMakeRowSpinner(lastTr,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), $P.valid); if(extrArtclNm != null && extrArtclNm != ""){ @@ -364,7 +364,7 @@ $(document).ready(function(){ var sel = $P.fnGetElement(lastTr,"textSort"); var toPrev = $(sel).siblings()[0]; var toNext = $(sel).siblings()[1]; - fnMakeSpinnerSelect(sel, toPrev, toNext); + FimsComponentization.fnMakeSpinnerSelect(sel, toPrev, toNext); if(tbodyName == "tbodyPredefined"){ $P.$find("scrollPredefined").scrollTop($P.find("scrollPredefined").scrollHeight); diff --git a/src/main/webapp/WEB-INF/jsp/fims/stng01030-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/stng01030-main.jsp index 043c27ba..f328902d 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/stng01030-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/stng01030-main.jsp @@ -237,13 +237,13 @@ $(document).ready(function(){ var sel = $P.fnGetElement(this,"paddingDirection"); var toPrev = $(sel).siblings()[0]; var toNext = $(sel).siblings()[1]; - fnMakeSpinnerSelect(sel, toPrev, toNext); + FimsComponentization.fnMakeSpinnerSelect(sel, toPrev, toNext); var scrollDivName = "scroll"; var rowSpinButtons = $(this).find("td[data-col='artclOrdr']").find("button"); - fnMakeRowSpinner(this,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), null); + FimsComponentization.fnMakeRowSpinner(this,rowSpinButtons[0],rowSpinButtons[1],$P.find(scrollDivName), null); }); } @@ -270,14 +270,14 @@ $(document).ready(function(){ var lastTr = $P.$find("tbody").find("tr").last()[0]; var rowSpinButtons = $(lastTr).find("td[data-col='artclOrdr']").find("button"); - fnMakeRowSpinner(lastTr,rowSpinButtons[0],rowSpinButtons[1], $P.find("scroll"), null); + FimsComponentization.fnMakeRowSpinner(lastTr,rowSpinButtons[0],rowSpinButtons[1], $P.find("scroll"), null); //셀렉트 스피너 var sel = $P.fnGetElement(lastTr,"paddingDirection"); var toPrev = $(sel).siblings()[0]; var toNext = $(sel).siblings()[1]; - fnMakeSpinnerSelect(sel, toPrev, toNext); + FimsComponentization.fnMakeSpinnerSelect(sel, toPrev, toNext); $P.$find("scroll").scrollTop($P.find("scroll").scrollHeight); diff --git a/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js b/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js index c8e7af7b..0c4d5999 100644 --- a/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js +++ b/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js @@ -121,7 +121,7 @@ function ObjectInspector(doctx, data){ /************************************************************************** -* UI요소 값 세팅 +* jquery.fn 커스텀 - UI요소 값 세팅 **************************************************************************/ $.fn.set = function(value) { return this.each(function(){ diff --git a/src/main/webapp/resources/js/fims/cmmn/fims-componentization.js b/src/main/webapp/resources/js/fims/cmmn/fims-componentization.js index 1f62d6a8..ebfddfdf 100644 --- a/src/main/webapp/resources/js/fims/cmmn/fims-componentization.js +++ b/src/main/webapp/resources/js/fims/cmmn/fims-componentization.js @@ -1,215 +1,226 @@ -/************************************************************************** -* 버튼으로 조작가능한 셀렉트박스 -**************************************************************************/ -function fnMakeSpinnerSelect(selectEl, prevBtnEl, nextBtnEl){ - - $(selectEl).on("animationend", function(){ - $(selectEl).removeClass("highlight-once"); - }); - $(prevBtnEl).on("click", function(){ - var selected = $(selectEl).find("option:selected"); - var prev = selected.prev(); - if(prev.length >= 1){ - $(selectEl).val(prev.val()); - } else { - $(selectEl).addClass("highlight-once"); - } - }); - $(nextBtnEl).on("click", function(){ - var selected = $(selectEl).find("option:selected"); - var next = selected.next(); - if(next.length >= 1){ - $(selectEl).val(next.val()); - } else { - $(selectEl).addClass("highlight-once"); - } - }); -} +class FimsComponentization { + + static help(){ + console.log("fnMakeSpinnerSelect(셀렉트박스,이전버튼,다음버튼) : 특정 셀렉트박스를 버튼클릭으로 옵션 선택 가능한 셀렉트박스로 만든다."); + console.log("fnMakeOptionStyleSelect(셀렉트박스) : 특정 셀렉트박스를 선택된 옵션의 스타일이 적용된 셀렉트박스로 만든다."); + console.log("fnMakeRowSpinner(테이블row,up버튼,down버튼,스크롤컨테이너,validator) : 특정 테이블을 행 위치 이동이 가능한 테이블로 만든다."); + console.log("fnMakeSingleImageViewer(img태그,fileInput태그,파일경로속성명,파일이름속성명) : 특정 이미지 태그를 단일 업로드 이미지 뷰어로 만든다."); + } + + /************************************************************************** + * 특정 셀렉트박스를 버튼클릭으로 옵션 선택 가능한 셀렉트박스로 만든다. + **************************************************************************/ + static fnMakeSpinnerSelect(selectEl, prevBtnEl, nextBtnEl){ + + $(selectEl).on("animationend", function(){ + $(selectEl).removeClass("highlight-once"); + }); + $(prevBtnEl).on("click", function(){ + var selected = $(selectEl).find("option:selected"); + var prev = selected.prev(); + if(prev.length >= 1){ + $(selectEl).val(prev.val()); + } else { + $(selectEl).addClass("highlight-once"); + } + }); + $(nextBtnEl).on("click", function(){ + var selected = $(selectEl).find("option:selected"); + var next = selected.next(); + if(next.length >= 1){ + $(selectEl).val(next.val()); + } else { + $(selectEl).addClass("highlight-once"); + } + }); + } + + /************************************************************************** + * 특정 셀렉트박스를 선택된 옵션의 스타일이 적용된 셀렉트박스로 만든다. + **************************************************************************/ + static fnMakeOptionStyleSelect(selectEl){ + $(selectEl).addClass("option-style-select"); -/************************************************************************** -* 선택된 옵션의 스타일이 적용된 셀렉트박스 -**************************************************************************/ -function fnMakeOptionStyleSelect(selectEl){ - $(selectEl).addClass("option-style-select"); + selectEl.changeUI = function(){ + + var selected = $(this).find("option:selected"); + + if(selected.length <= 0){ + selectEl.dataset.optionStyle = ""; + selectEl.title = ""; + return; + } - selectEl.changeUI = function(){ - - var selected = $(this).find("option:selected"); + selectEl.dataset.optionStyle = selected.val(); + selectEl.title = selected[0].title; + }; - if(selected.length <= 0){ - selectEl.dataset.optionStyle = ""; - selectEl.title = ""; - return; - } + $(selectEl).on("change", function(){ + selectEl.changeUI(); + }); - selectEl.dataset.optionStyle = selected.val(); - selectEl.title = selected[0].title; - }; - - $(selectEl).on("change", function(){ selectEl.changeUI(); - }); - - selectEl.changeUI(); -} - -/************************************************************************** -* 행 위치 이동 가능한 테이블 -**************************************************************************/ -function getBrowserName() { - var agent = navigator.userAgent.toUpperCase(); - if (agent.indexOf('TRIDENT') >= 0) { - return 'IE'; - } else if (agent.indexOf('FIREFOX') >= 0) { - return 'FIREFOX'; - } else if (agent.indexOf('EDG') >= 0) { - return 'EDGE'; - } else if (agent.indexOf('CHROME') >= 0) { - return 'CHROME'; - } else if (agent.indexOf('SAFARI') >= 0) { - return 'SAFARI'; - } else { - return ''; - } -} -const BROWSER_NAME = getBrowserName(); -var VERTICAL_SCROLL_HEIGHT = 14; -switch(BROWSER_NAME){ - case "EDGE" : - VERTICAL_SCROLL_HEIGHT = 14; - break; - case "FIREFOX" : - VERTICAL_SCROLL_HEIGHT = 15; - break; - case "CHROME" : - VERTICAL_SCROLL_HEIGHT = 15; - break; -} - -function fnMakeRowSpinner(tableRowEl, upBtnEl, downBtnEl, scrollEl, validFunc){ - - if(validFunc != undefined && validFunc != null){ - tableRowEl.validForComponent = validFunc; - } else { - tableRowEl.validForComponent = function(eventInfo){ - return true; - }; } + + /************************************************************************** + * 특정 테이블을 행 위치 이동 가능한 테이블로 만든다. + **************************************************************************/ + static fnMakeRowSpinner(tableRowEl, upBtnEl, downBtnEl, scrollEl, validFunc){ - $(upBtnEl).on("click", function(){ - var tbody = $(tableRowEl).parent(); - - var theadHeight = $(scrollEl).find("thead").outerHeight(); - var scrollElStart = $(scrollEl).offset().top + theadHeight; - var scrollElHeight = $(scrollEl).height() - theadHeight - VERTICAL_SCROLL_HEIGHT; - var scrollMiddle = scrollElStart + (scrollElHeight/2); - - if($(tableRowEl).index() == 0){ - return; + if(validFunc != undefined && validFunc != null){ + tableRowEl.validForComponent = validFunc; + } else { + tableRowEl.validForComponent = function(eventInfo){ + return true; + }; } - - var beforeIndex = $(tableRowEl).index() - 1; - var beforeTr = $(tbody).find("tr").eq(beforeIndex); - - var eventInfo = { - clickedButtonType : "up", - currentRow : tableRowEl, - siblingRow : beforeTr - }; - if(!tableRowEl.validForComponent(eventInfo)){ - return; - } - - - var rowStart = beforeTr.offset().top; - var rowHeight = beforeTr.outerHeight(); - var rowMiddle = rowStart+(rowHeight/2); - - beforeTr.before(tableRowEl); + $(upBtnEl).on("click", function(){ + var tbody = $(tableRowEl).parent(); + + var theadHeight = $(scrollEl).find("thead").outerHeight(); + var scrollElStart = $(scrollEl).offset().top + theadHeight; + var scrollElHeight = $(scrollEl).height() - theadHeight - VERTICAL_SCROLL_HEIGHT; + var scrollMiddle = scrollElStart + (scrollElHeight/2); + + if($(tableRowEl).index() == 0){ + return; + } + + var beforeIndex = $(tableRowEl).index() - 1; + var beforeTr = $(tbody).find("tr").eq(beforeIndex); + - if(rowMiddle < scrollMiddle){ - var move = scrollMiddle - rowMiddle; - $(scrollEl).scrollTop($(scrollEl).scrollTop() - move); - } + var eventInfo = { + clickedButtonType : "up", + currentRow : tableRowEl, + siblingRow : beforeTr + }; + if(!tableRowEl.validForComponent(eventInfo)){ + return; + } + + + var rowStart = beforeTr.offset().top; + var rowHeight = beforeTr.outerHeight(); + var rowMiddle = rowStart+(rowHeight/2); + + beforeTr.before(tableRowEl); - $(tbody).find("tr").removeClass("current-row"); - $(tableRowEl).addClass("current-row"); - }); - - $(downBtnEl).on("click", function(){ - var tbody = $(tableRowEl).parent(); - - var theadHeight = $(scrollEl).find("thead").outerHeight(); - var scrollElStart = $(scrollEl).offset().top + theadHeight; - var scrollElHeight = $(scrollEl).height() - theadHeight - VERTICAL_SCROLL_HEIGHT; - var scrollMiddle = scrollElStart + (scrollElHeight/2); - - if($(tableRowEl).index() == ($(tbody).children().length) - 1){ - return; - } + if(rowMiddle < scrollMiddle){ + var move = scrollMiddle - rowMiddle; + $(scrollEl).scrollTop($(scrollEl).scrollTop() - move); + } - var afterIndex = $(tableRowEl).index() + 1; - var afterTr = $(tbody).find("tr").eq(afterIndex); - - - var eventInfo = { - clickedButtonType : "down", - currentRow : tableRowEl, - siblingRow : afterTr - }; - if(!tableRowEl.validForComponent(eventInfo)){ - return; - } + $(tbody).find("tr").removeClass("current-row"); + $(tableRowEl).addClass("current-row"); + }); + $(downBtnEl).on("click", function(){ + var tbody = $(tableRowEl).parent(); + + var theadHeight = $(scrollEl).find("thead").outerHeight(); + var scrollElStart = $(scrollEl).offset().top + theadHeight; + var scrollElHeight = $(scrollEl).height() - theadHeight - VERTICAL_SCROLL_HEIGHT; + var scrollMiddle = scrollElStart + (scrollElHeight/2); + + if($(tableRowEl).index() == ($(tbody).children().length) - 1){ + return; + } + + var afterIndex = $(tableRowEl).index() + 1; + var afterTr = $(tbody).find("tr").eq(afterIndex); + + + var eventInfo = { + clickedButtonType : "down", + currentRow : tableRowEl, + siblingRow : afterTr + }; + if(!tableRowEl.validForComponent(eventInfo)){ + return; + } + + + var rowStart = afterTr.offset().top; + var rowHeight = afterTr.outerHeight(); + var rowMiddle = rowStart+(rowHeight/2); + + afterTr.after(tableRowEl); + + if(rowMiddle > scrollMiddle){ + var move = rowMiddle - scrollMiddle; + $(scrollEl).scrollTop($(scrollEl).scrollTop() + move); + } + + $(tbody).find("tr").removeClass("current-row"); + $(tableRowEl).addClass("current-row"); + }); - var rowStart = afterTr.offset().top; - var rowHeight = afterTr.outerHeight(); - var rowMiddle = rowStart+(rowHeight/2); - - afterTr.after(tableRowEl); - - if(rowMiddle > scrollMiddle){ - var move = rowMiddle - scrollMiddle; - $(scrollEl).scrollTop($(scrollEl).scrollTop() + move); - } - $(tbody).find("tr").removeClass("current-row"); - $(tableRowEl).addClass("current-row"); - }); -} - - -/************************************************************************** -* 단일 업로드 이미지 뷰어 -**************************************************************************/ -function fnMakeSingleImageViewer(imgEl, fileInputEl, dataAttributeForFilePath, dataAttributeForFileName){ - - $(imgEl).on("click", function(){ - $(fileInputEl).click(); - }); + } - $(fileInputEl).on("change", function(){ + /************************************************************************** + * 특정 이미지 태그를 단일 업로드 이미지 뷰어로 만든다. + **************************************************************************/ + static fnMakeSingleImageViewer(imgEl, fileInputEl, dataAttributeForFilePath, dataAttributeForFileName){ - if(this.files != null && this.files.length > 0){ - $(imgEl).attr("alt", this.files[0].name); - $(imgEl).attr("src", (window.URL || window.webkitURL).createObjectURL(this.files[0])); - - } else { - - var orgnName = $(imgEl).attr("data-"+dataAttributeForFileName); - var orgnPath = $(imgEl).attr("data-"+dataAttributeForFilePath); + $(imgEl).on("click", function(){ + $(fileInputEl).click(); + }); + + $(fileInputEl).on("change", function(){ - if(orgnPath != undefined && orgnPath != null && orgnPath != ""){ - $(imgEl).attr("alt", orgnName); - $(imgEl).attr("src", orgnPath); + if(this.files != null && this.files.length > 0){ + $(imgEl).attr("alt", this.files[0].name); + $(imgEl).attr("src", (window.URL || window.webkitURL).createObjectURL(this.files[0])); + } else { - $(imgEl).attr("alt", "파일이 없습니다."); - $(imgEl).attr("src", "/resources/img/no-image.svg"); + + var orgnName = $(imgEl).attr("data-"+dataAttributeForFileName); + var orgnPath = $(imgEl).attr("data-"+dataAttributeForFilePath); + + if(orgnPath != undefined && orgnPath != null && orgnPath != ""){ + $(imgEl).attr("alt", orgnName); + $(imgEl).attr("src", orgnPath); + } else { + $(imgEl).attr("alt", "파일이 없습니다."); + $(imgEl).attr("src", "/resources/img/no-image.svg"); + } + } - } - - }); + }); + } + + static getBrowserName() { + var agent = navigator.userAgent.toUpperCase(); + if (agent.indexOf('TRIDENT') >= 0) { + return 'IE'; + } else if (agent.indexOf('FIREFOX') >= 0) { + return 'FIREFOX'; + } else if (agent.indexOf('EDG') >= 0) { + return 'EDGE'; + } else if (agent.indexOf('CHROME') >= 0) { + return 'CHROME'; + } else if (agent.indexOf('SAFARI') >= 0) { + return 'SAFARI'; + } else { + return ''; + } + } } +const BROWSER_NAME = FimsComponentization.getBrowserName(); +var VERTICAL_SCROLL_HEIGHT = 14; +switch(BROWSER_NAME){ + case "EDGE" : + VERTICAL_SCROLL_HEIGHT = 14; + break; + case "FIREFOX" : + VERTICAL_SCROLL_HEIGHT = 15; + break; + case "CHROME" : + VERTICAL_SCROLL_HEIGHT = 15; + break; +} \ No newline at end of file