datepicker 수정(날짜 지우기 버튼 추가, 연월 변경시 일 선택 기능)

main
이범준 1 year ago
parent fd983ce750
commit 86b4df0f95

@ -11427,6 +11427,10 @@ $.extend( Datepicker.prototype, {
today: function() { today: function() {
$.datepicker._gotoToday( id ); $.datepicker._gotoToday( id );
}, },
/** 함수 추가(지우기 버튼) */
clear: function() {
$.datepicker._clearDate( id );
},
selectDay: function() { selectDay: function() {
$.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this ); $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
return false; return false;
@ -11590,6 +11594,18 @@ $.extend( Datepicker.prototype, {
} ) } )
.text( currentText ) : .text( currentText ) :
"" ) "" )
/** 지우기 버튼 추가 */
.append ( this._isInRange( inst, gotoDate ) ?
$( "<button>" )
.attr( {
type: "button",
"class": "ui-datepicker-clear ui-state-default ui-priority-secondary ui-corner-all",
"data-handler": "clear",
"data-event": "click"
} )
.text("지우기") :
""
)
.append( isRTL ? "" : controls )[ 0 ].outerHTML; .append( isRTL ? "" : controls )[ 0 ].outerHTML;
} }

@ -6,7 +6,22 @@ function initDatepicker(elementId){
executionArea.find(".form-date").datepicker({ executionArea.find(".form-date").datepicker({
changeMonth: true, changeMonth: true,
changeYear: true, changeYear: true,
showButtonPanel: true showButtonPanel: true,
onChangeMonthYear : function(year, month, inst){
/** 기능 추가 : 연월 변경시 일 선택 */
var result = "" + year + "-"+(""+month).padStart(2,'0') + "-";
var endDay = DateUtil.getEndOfMonthDay(year, month);
if(inst.selectedDay > endDay){
result += (""+endDay).padStart(2,'0');
} else {
result += (""+inst.selectedDay).padStart(2,'0');
}
$(this).datepicker("setDate", result);
}
}); });
executionArea.find(".form-date").next("button.bx-calendar").on("click", function() { executionArea.find(".form-date").next("button.bx-calendar").on("click", function() {

@ -36,6 +36,7 @@ display: none; /* 화살표 없애기 for IE10, 11*/
.ui-datepicker td, .ui-datepicker th { border: 0 } .ui-datepicker td, .ui-datepicker th { border: 0 }
.ui-datepicker .ui-datepicker-buttonpane button { float: right; cursor: pointer; width: auto; margin: 0.5em 0.2em 0.4em; padding: 0.2em 0.6em 0.3em; overflow: visible; } .ui-datepicker .ui-datepicker-buttonpane button { float: right; cursor: pointer; width: auto; margin: 0.5em 0.2em 0.4em; padding: 0.2em 0.6em 0.3em; overflow: visible; }
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float: left; } .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float: left; }
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-clear { float: left; }
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
.ui-corner-all { border-radius: 3px; } .ui-corner-all { border-radius: 3px; }
.ui-icon { display: block; width: 16px; height: 16px; } .ui-icon { display: block; width: 16px; height: 16px; }

Loading…
Cancel
Save