ÿØÿà JFIF ` ` ÿþ
Server : Apache System : Linux ruga7-004.fmcity.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : tkt_travelbus ( 1137) PHP Version : 7.0.0p1 Disable Function : mysql_pconnect Directory : /tkt_travelbus/www/js/ajaxcalendar/ |
Upload File : |
/** * AjaxCalendar.js * * 작성자 : * 작성일 : 2010.03.23 * 수정일 : 2010.04.16 : 언어 선택 기능 추가 * 수정일 : 2010.04.29 : 달력 위치 자동 조정 추가 (달력이 화면을 넘어가는 경우를 대비) * 수정일 : 2013.05.02 : jquery적용 */ // 달력 호출 함수 function AjaxCal(obj, event, option) { ajaxcalendar = new AjaxCalendar(obj, event, option); } var AjaxCalendar = function(obj, event, option) { this.obj = obj; if (!this.obj) return; this.layer = (obj) ? ((typeof(obj) == 'string') ? document.getElementById(obj) : obj) : null; option = (option) ? option : {}; this.e = event; this.option = option; this.ie_ver = function() { var ieversion = 0; if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) ieversion = new Number(RegExp.$1) return ieversion; } this.sdate = (option.sdate) ? option.sdate : ''; // 달력 시작일 this.edate = (option.edate) ? option.edate : ''; // 달력 종료일 this.format = (option.format) ? option.format : ''; // 출력 포멧 this.add_event = (option.add_event) ? option.add_event : '';//이벤트추가 this.g_uid = (option.g_uid) ? option.g_uid : ''; //[son]good.g_uid this.dtid = (option.dtid) ? option.dtid : ''; //[son]TB_GOOD_DATE_TYPE.dtid this.offsetX = (option.offsetX != undefined) ? option.offsetX : -15; this.offsetY = (option.offsetY != undefined) ? option.offsetY : 15; this.selectbox = (option.selectbox == 'hide') ? 'hide' : ''; this.view_check = false; this.templete = (option.templete) ? "_"+option.templete : ''; // 달력 시작일 // IE6,7 버그 수정 (20100812 ) if (this.sdate == undefined) this.sdate = ''; if (this.edate == undefined) this.edate = ''; this.init(); this.show(); // 이벤트 this.event_click = this.click.bindAsEvent(this); Evt.add(document, 'click', this.event_click); } AjaxCalendar.prototype = { init: function() { var objBody = document.getElementsByTagName("body").item(0); this.Cal_Container = document.getElementById('Cal_Container'); if (!this.Cal_Container) { this.Cal_Container = document.createElement("div"); this.Cal_Container.setAttribute('id','Cal_Container'); this.Cal_Container.setAttribute('class','m_cal'); with (this.Cal_Container.style) { position = 'absolute'; display = 'none'; top = '0'; left = '0'; zIndex = '100000'; width = '180px'; margin = '0px'; textAlign = 'left'; } objBody.appendChild(this.Cal_Container); } }, show: function() { if (this.ie_ver > 0 && this.ie_ver < 8) this.toggleSelects('hide'); // 이벤트 좌표 설정 var evt2 = this.e || window.event; var x = evt2.pageX || evt2.clientX + document.documentElement.scrollLeft || document.body.scrollLeft; var y = evt2.pageY || evt2.clientY + document.documentElement.scrollTop || document.body.scrollTop; var pos = this.get_position(x, y); // 달력 위치 자동 조정해서 가져옴 (20100429) if(this.templete != ''){ this.Cal_Container.style.width = "100%"; this.Cal_Container.style.left = '0px'; this.Cal_Container.style.top = (pos.y + this.offsetY) + 'px'; } else { this.Cal_Container.style.left = (pos.x + this.offsetX) + 'px'; this.Cal_Container.style.top = (pos.y + this.offsetY) + 'px'; } this.Cal_Container.style.display = 'block'; this.Cal_Container.innerHTML = '<div style="padding:5px;"><img src="/js/ajaxcalendar/ajax-loader.gif"></div>'; this.updater('/js/ajaxcalendar/ajaxcalendar'+this.templete+'.php?sdate='+this.sdate+'&edate='+this.edate+'&format='+this.format+'&g_uid='+this.g_uid+'&dtid='+this.dtid); //[son] }, hide: function() { this.toggleSelects(this.selectbox); this.Cal_Container.style.display = 'none'; this.Cal_Container.innerHTML = ''; }, updater: function(url) { $(this.Cal_Container).load(url); }, insert: function(day) { this.obj.value = day; Evt.remove(document, 'click', this.event_click);//이벤트해제 if(this.add_event){ eval(this.add_event); //option.add_event 추가 } this.hide(); }, toggleSelects: function(state) { var selects = document.getElementsByTagName("select"); for (var i = 0; i < selects.length; i++ ) { selects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible'; } }, //객체 크기 get_size: function(el) { return { width:(el.offsetWidth || parseInt(el.style.width, 10)), height:(el.offsetHeight || parseInt(el.style.height, 10)) }; }, // 화면 크기 get_client: function() { return { width:(document.body.clientWidth || document.documentElement.clientWidth) + document.body.scrollLeft, height:(document.body.clientHeight || document.documentElement.clientHeight) + document.body.scrollTop }; }, // 달력 위치 자동 조정 (달력이 화면을 넘어가는 경우를 대비) (20100429 ) get_position: function(x, y) { var size = this.get_size(this.Cal_Container); var client = this.get_client(); var max_x = (client.width - size.width - this.offsetX) - 1; var max_y = (client.height - size.height - this.offsetY) - 1; return { x:(x > max_x) ? max_x : x, y:(y > max_y) ? max_y - (client.height - y + this.offsetY) : y }; }, click: function(e) { var evt = e || window.event; var el = evt.srcElement || evt.target; var is_view=false; //해당id는 클릭시에 obj를 닫지않고 유지 if(el.id=="cal_pre_month" || el.id=="cal_next_month" || el.id=="cal_ajaxcalendar_year" || el.id=="cal_ajaxcalendar_month" || el.id=="cal_yyyy" || el.id=="cal_mm" ) is_view=true; if (el.id != this.layer.id && is_view==false) { if (!this.view_check) { this.hide(); Evt.remove(document, 'click', this.event_click); // 이벤트해제 }else{ this.view_check = false; } } } } Function.prototype.bindAsEvent = function(object) { var method = this, args = []; for (var i=0, len=arguments.length; i<len; i++) args[i] = arguments[i]; object = args.shift(); return function(e) { return method.apply(object, [e || window.event].concat(args)); } } /* event js */ var Evt = new Object(); Evt.add = function(obj, evt, fnc) { if (obj.addEventListener) obj.addEventListener(evt, fnc, false); else obj.attachEvent('on' + evt, fnc); } Evt.remove = function(obj, evt, fnc) { if (obj.addEventListener) obj.removeEventListener(evt, fnc, false); else obj.detachEvent('on' + evt, fnc); }