diff --git a/common/js/plugins/ui.calendar/img/buttonCloseLayerX.gif b/common/js/plugins/ui.calendar/img/buttonCloseLayerX.gif new file mode 100644 index 000000000..535cfafad Binary files /dev/null and b/common/js/plugins/ui.calendar/img/buttonCloseLayerX.gif differ diff --git a/common/js/plugins/ui.calendar/img/buttonPaginate.gif b/common/js/plugins/ui.calendar/img/buttonPaginate.gif new file mode 100644 index 000000000..ab1c524c1 Binary files /dev/null and b/common/js/plugins/ui.calendar/img/buttonPaginate.gif differ diff --git a/common/js/plugins/ui.calendar/plugin.load b/common/js/plugins/ui.calendar/plugin.load new file mode 100644 index 000000000..800d8a64a --- /dev/null +++ b/common/js/plugins/ui.calendar/plugin.load @@ -0,0 +1,2 @@ +ui.calendar.js +ui.calendar.css \ No newline at end of file diff --git a/common/js/plugins/ui.calendar/ui.calendar.css b/common/js/plugins/ui.calendar/ui.calendar.css new file mode 100644 index 000000000..ff3205e47 --- /dev/null +++ b/common/js/plugins/ui.calendar/ui.calendar.css @@ -0,0 +1,30 @@ +/* Calendar */ +.ui-calendar {display:none; padding:25px 15px 15px 15px; position:absolute; border:2px solid #737373; background:#fff; color:#333;} +.ui-calendar .close{ position:absolute; top:10px; right:15px; width:17px; height:17px; border:0; padding:0; background:url(./img/buttonCloseLayerX.gif) no-repeat center center; cursor:pointer;} +.ui-calendar .close span{ position:absolute; width:0; height:0; font-size:0; line-height:0; overflow:hidden; z-index:-1; visibility:hidden;} +.ui-calendar table{ border:0; border-spacing:0; _width:200px;} +.ui-calendar caption{ font-weight:bold; text-align:center; position:relative;} +.ui-calendar caption span{ display:block; position:relative; padding:10px 0 15px 0; *zoom:1;} +.ui-calendar caption .today{ font-size:11px; border:0; padding:0; border-bottom:1px solid; background:none; cursor:pointer;} +.ui-calendar caption .today span{text-decoration:underline;} +.ui-calendar caption .navi{ position:absolute; top:10px; border:0; padding:0; width:17px; height:18px; background-color:transparent; background-image:url(./img/buttonPaginate.gif); background-repeat:no-repeat; cursor:pointer;} +.ui-calendar caption .navi span{ position:absolute; width:0; height:0; overflow:hidden; font-size:0; line-height:0; z-index:-1; visibility:hidden;} +.ui-calendar caption .navi.prev{ left:0; background-position:left top;} +.ui-calendar caption .navi.next{ right:0; background-position:right top;} +.ui-calendar th, +.ui-calendar td{ border:0; text-align:center;} +.ui-calendar th{ color:#666; background:#f2f2f2; padding:3px 8px;} +.ui-calendar td{ font-size:11px; padding:3px 8px;} +.ui-calendar td button{ padding:0; border:0; background:none; cursor:pointer; width:20px; font-size:11px; font-family:Tahoma, Sans-serif;} +.ui-calendar td button.today{ font-weight:bold;} +.ui-calendar td button.book, +.ui-calendar td button.active, +.ui-calendar tr.active button{ background:#ff4747; color:#fff;} +.ui-calendar .sun, +.ui-calendar .sun button{ color:#ff1a1a;} + +.ui-calendar table.month{ border-top:1px solid #f2f2f2; border-left:1px solid #f2f2f2;} +.ui-calendar table.month td{ border-right:1px solid #f2f2f2; border-bottom:1px solid #f2f2f2;} +.ui-calendar table.month td button{ width:50px; color:#bababa;} +.ui-calendar table.month td button.past{ color:#333;} +.ui-calendar table.month td button.active{ color:#fff;} diff --git a/common/js/plugins/ui.calendar/ui.calendar.js b/common/js/plugins/ui.calendar/ui.calendar.js new file mode 100644 index 000000000..c25f95f70 --- /dev/null +++ b/common/js/plugins/ui.calendar/ui.calendar.js @@ -0,0 +1,358 @@ +/** + * @brief XE Calendar + * @author gony (http://mygony.com) + * + * 사용법 + * + **/ +(function($){ + +if (!$.ui) $.ui = {}; +$.extend($.ui, { calendar: { version:'0.3' } }); + +var PROP_NAME = 'calendar'; +var index = 0; +var calendars = {}; +var template = {calendar:'',month:''}; + +function Calendar() { +} + +$.extend(Calendar.prototype, { + _activeCalendar : null, + _getuid : function(obj) { + var uid = obj.attr('class').match(/ui-calendar-(\d+-\d+)/); + + if (!uid) return -1; + return uid[1]; + }, + _show : function(obj) { + if (this._activeCalendar) this._hide(this._activeCalendar); + + // disabled? + if (obj.hasClass('ui-calendar-disabled')) return; + + // Active Calendar + this._activeCalendar = obj.show(300); + }, + _hide : function(obj) { + if (this._activeCalendar && this._activeCalendar.get(0) == obj.get(0)) this._activeCalendar = null; + obj.hide(300); + }, + _toggle : function(obj) { + (obj.css('display' ) == 'none')?this._show(obj):this._hide(obj); + }, + _attachCalendar : function(obj, options) { + if ((obj=$(obj)).hasClass('ui-calendar')) return; + + var uid = $.calendar.uuid+'-'+(index++); + var c = calendars[uid] = {}; + + // uid 추가 + obj.addClass('ui-calendar-'+uid).mousedown(function(){return false}); + + // default options + c.options = $.extend({ + type : 'day', + activeDate : '' + }, options||{}); + c.lang = $.extend({ + weekdays : 'Sun,Mon,Tue,Wed,Thu,Fri,Sat', + today : 'Today', + prevmonth : 'Prev Month', + nextmonth : 'Next Month', + close : 'Close' + }, options.lang||{}); + + c.lang.weekdays = c.lang.weekdays.split(','); + + // 날짜 설정 + var d; + if (typeof c.options.activeDate == 'string' && c.options.activeDate) { + var s = c.options.activeDate.split('/'); + d = new Date(s[0], s[1]-1, s[2]-0); + } else { + d = new Date(); + } + this._setDate(obj, d); + + // 토글 버튼 + if (c.options.button) { + (c.button=$(c.options.button)).click(function(){ obj.calendar('toggle') }); + } + + // 클래스 추가 + obj.addClass('ui-calendar'); + + // position 설정한 후, 좌표를 (0,0)으로 변경 + var pos = obj.css({position:'absolute',top:0,left:0}).show().offset(); + + // 버튼의 위치 구해서 좌표 조정 + var bpos = c.button.offset(); + var dx = bpos.left - pos.left; + var dy = bpos.top - pos.top; + + // 좌표 조정 후 레이어 숨김 + obj.css({top:(dy+c.button.height())+'px',left:dx+'px'}).hide(); + }, + _checkExternalClick : function(e) { + if ($.calendar._activeCalendar) $.calendar._hide($.calendar._activeCalendar); + }, + _processTemplate : function(tpl, vars) { + tpl = (' '+tpl+' ').split(/[\{\}]/g); + + for(var i=0; i < tpl.length; i++) { + if (i%2) { + if (/^[\w\.\[\]]+$/.test(tpl[i])) tpl[i] = 'try{v=vv.'+tpl[i]+'}catch(e){v=""};ret.push(v);'; + else if (/^@(\w+)\s+in\s+(\w+)$/.test(tpl[i])) tpl[i] = 'for(i=0,l=vv.'+RegExp.$2+'.length;i 9?v['m']:'0'+v['m']; + + // 연간 달력이 아니라면 이 달의 날짜를 구한다. + if (cal.options.type != 'month') { + // 날짜에 사용할 달력 + v['weeks'] = []; + + var d = new Date(cal.date.getTime()), w = []; + var last = (v.m!=2)? (v.m%2?31:30) : ((new Date(v.yyyy,v.m-1,29)).getMonth()==v.m?29:28); // 마지막 날 + + d.setDate(1); // 1일로 설정 후 1일의 요일을 가져온다. + var start = d.getDay(), end = last+start; + + for(var i=0,len=end+(7-(end%7||7));i= end) w.push(' '); + else w.push(''); + } + } + + // 템플릿 처리 + tpl = this._processTemplate(tpl, v); + obj.html(tpl); + + // 선택한 날짜 + if (cal.options.type == 'month') { + + } else { + var t = new Date(); + obj.find('td>button.day'+t.getFullYear()+'-'+(t.getMonth()+1)+'-'+t.getDate()).addClass('today'); + + t = cal.activeDate; + obj.find('td>button.day'+t.getFullYear()+'-'+(t.getMonth()+1)+'-'+t.getDate()).addClass('active'); + } + + // 이벤트 핸들러 + obj.find('button.close').click(function(){ $.calendar._hide(obj); }); + obj.find('button.today').click(function(){ $.calendar._moveToday(obj); }); + if (cal.options.type == 'month') { + obj.find('button.prev').click(function(){ $.calendar._prevYear(obj) }); + obj.find('button.next').click(function(){ $.calendar._nextYear(obj) }); + } else { + obj.find('button.prev').click(function(){ $.calendar._prevMonth(obj) }); + obj.find('button.next').click(function(){ $.calendar._nextMonth(obj) }); + } + obj.find('td>button').click(function(){ $.calendar._selectDate(obj, $(this)) }); + }, + _selectDate : function(obj, btn) { + var cal = calendars[ this._getuid(obj) ]; + var date = btn.attr('class').match(/day([\d\-]+)/); + if (!date) return; + + date = date[1].split('-'); + + var ad = cal.activeDate; + ad.setFullYear(date[0]-0); + ad.setMonth(date[1]-1); + ad.setDate(date[2]-0); + + this._setDate(obj, ad); + }, + _setDate : function(obj, newDate) { + var uid = this._getuid(obj); + if (uid < 0) return null; + if (!newDate || !(newDate instanceof Date)) newDate = new Date(); + + var cal = calendars[uid]; + cal.activeDate = new Date(newDate.getTime()); + cal.date = new Date(newDate.getTime()); + this._draw(obj); + + if ($.isFunction(cal.options.select) && obj.hasClass('ui-calendar')) { + cal.options.select(newDate.getFullYear(), newDate.getMonth()+1, newDate.getDate()); + } + }, + _getDate : function(obj, format) { + var uid = this._getuid(obj); + if (uid < 0) return null; + if (typeof format != 'string') return calendars[uid].activeDate; + + // format string + }, + _moveToday : function(obj) { + calendars[this._getuid(obj)].date = new Date(); + this._draw(obj); + }, + _prevMonth : function(obj) { + var cal = calendars[this._getuid(obj)]; + var m = cal.date.getMonth(); + + cal.date.setDate(1); + if (m == 0) { + cal.date.setFullYear(cal.date.getFullYear()-1); + cal.date.setMonth(11); + } else { + cal.date.setMonth(m-1); + } + + this._draw(obj); + }, + _nextMonth : function(obj) { + var cal = calendars[this._getuid(obj)]; + var m = cal.date.getMonth(); + + cal.date.setDate(1); + if (m == 11) { + cal.date.setFullYear(cal.date.getFullYear()+1); + cal.date.setMonth(0); + } else { + cal.date.setMonth(m+1); + } + + this._draw(obj); + }, + _prevYear : function(obj) { + this._draw(obj); + cal.date.setFullYear(cal.date.getFullYear()-1); + }, + _nextYear : function(obj) { + cal.date.setFullYear(cal.date.getFullYear()+1); + this._draw(obj); + } +}); + +/** + * Invoke the calednar functionallity + * @return jQuery object + */ +$.fn.calendar = function(options) { + var args = $.makeArray(arguments); + + if (!$.calendar.initialized) { + $(document).mousedown($.calendar._checkExternalClick); + $.calendar.initialized = true; + } + + if (typeof options == 'string' && $.inArray(options, ['getDate'])) { + args.shift(); + return $.calendar['_'+options].apply($.calendar, [$(this[0])].concat(args) ); + } + + return this.each(function(){ + if (typeof options == 'string') { + args.shift(); + $.calendar['_'+ options].apply($.calendar, [$(this)].concat(args)); + } else { + $.calendar._attachCalendar($(this), options); + } + }); +} + +$.calendar = new Calendar(); // singleton instance +$.calendar.initialized = false; +$.calendar.uuid = new Date().getTime(); +$.calendar.version = $.ui.calendar.version; + +// template +template.calendar = '\ +\ +\ +\ + \ + \ + \ + \ + \ + \ + \ + \ + \ +\ +\ + {@week in weeks}\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + {/}\ +\ +
\ + \ + {yyyy}.{mm}.\ + \ + \ + \ + \ +
{lang.weekdays[0]}{lang.weekdays[1]}{lang.weekdays[2]}{lang.weekdays[3]}{lang.weekdays[4]}{lang.weekdays[5]}{lang.weekdays[6]}
{week[0]}{week[1]}{week[2]}{week[3]}{week[4]}{week[5]}{week[6]}
\ +'; + +template.month = '\ +\ +\ +\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +\ +
\ + \ + {yyyy}.{mm} \ + \ + \ + \ +
\ +'; + +})(jQuery); \ No newline at end of file