From 0b46eecd0337ba0b8a33660901376a44e84042aa Mon Sep 17 00:00:00 2001 From: Thomas Jang Date: Fri, 8 Jul 2016 19:24:08 +0900 Subject: [PATCH] ax5calendar@0.8.2 --- dist/ax5calendar.js | 21 +++++++++++---------- dist/ax5calendar.min.js | 2 +- src/ax5calendar.js | 27 +++++++++++++-------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/dist/ax5calendar.js b/dist/ax5calendar.js index 64f273c..eadedc5 100755 --- a/dist/ax5calendar.js +++ b/dist/ax5calendar.js @@ -605,14 +605,12 @@ }.bind(this)); }, clearPeriodMap = function clearPeriodMap() { - setTimeout(function () { - if (cfg.mode === "day" || cfg.mode === "d") { - for (var k in this.periodMap) { - this.$["body"].find('[data-calendar-item-date="' + k + '"]').find(".addon-footer").empty(); - this.$["body"].find('[data-calendar-item-date="' + k + '"]').removeClass(this.periodMap[k].theme); - } + if (cfg.mode === "day" || cfg.mode === "d") { + for (var k in this.periodMap) { + this.$["body"].find('[data-calendar-item-date="' + k + '"]').find(".addon-footer").empty(); + this.$["body"].find('[data-calendar-item-date="' + k + '"]').removeClass(this.periodMap[k].theme); } - }.bind(this)); + } }; /** @@ -912,8 +910,7 @@ v.range.forEach(function (n) { if (U.isDateFormat(n.from) && U.isDateFormat(n.to)) { - - for (var d = U.date(n.from); d <= U.date(n.to); d.setDate(d.getDate() + 1)) { + for (var d = new Date(U.date(n.from)); d <= U.date(n.to); d.setDate(d.getDate() + 1)) { if (d.getTime() == U.date(n.from).getTime()) { map[U.date(d, { "return": cfg.dateFormat })] = { theme: n.theme || cfg.defaultPeriodTheme, label: n.fromLabel }; } else if (d.getTime() == U.date(n.to).getTime()) { @@ -935,6 +932,11 @@ var key, result = {}; + // 변경내용 적용하여 출력 + if (isApply !== false) { + clearPeriodMap.call(this); + } + if (cfg.period = period) { result = processor.range(period); } @@ -945,7 +947,6 @@ // 변경내용 적용하여 출력 if (isApply !== false) { - clearPeriodMap.call(this); applyPeriodMap.call(this); } return this; diff --git a/dist/ax5calendar.min.js b/dist/ax5calendar.min.js index 3c7517d..db38530 100755 --- a/dist/ax5calendar.min.js +++ b/dist/ax5calendar.min.js @@ -1 +1 @@ -"use strict";!function(e,t){var a=ax5.util,n=function(){t&&t.call(this);var n,l=this,i=1;this.target=null,this.selection=[],this.selectionMap={},this.selectableMap={},this.markerMap={},this.printedDay={start:"",end:""},this.config={clickEventName:"click",theme:"default",mode:"day",dateFormat:"yyyy-MM-dd",displayDate:new Date,animateTime:250,dimensions:{controlHeight:"40",controlButtonWidth:"40",colHeadHeight:"30",itemPadding:2},lang:{yearHeading:"Choose the year",monthHeading:"Choose the month",yearTmpl:"%s",months:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],dayTmpl:"%s"},multipleSelect:!1,selectMode:"day",defaultMarkerTheme:"holiday",defaultPeriodTheme:"period"},n=this.config;var r=function(e,t){e&&e.onStateChanged?e.onStateChanged.call(t,t):this.onStateChanged&&this.onStateChanged.call(t,t),t=null},d=function(){return'\n
\n {{#control}}\n \n {{/control}}\n
\n
\n '},s=function(){var e=jQuery.extend(!0,{},n,{controlCSS:{},controlButtonCSS:{}}),t=d();e.controlButtonCSS.height=e.controlCSS.height=a.cssNumber(n.dimensions.controlHeight),e.controlButtonCSS["line-height"]=e.controlCSS["line-height"]=a.cssNumber(n.dimensions.controlHeight),e.controlButtonCSS.width=a.cssNumber(n.dimensions.controlHeight),e.controlCSS=a.css(e.controlCSS),e.controlButtonCSS=a.css(e.controlButtonCSS);try{return ax5.mustache.render(t,e)}finally{e=null,t=null}},o=function(){return'\n \n \n \n {{#weekNames}}\n \n {{/weekNames}}\n \n \n \n \n {{#list}} \n {{#isStartOfWeek}}\n {{^@first}}\n \n \n {{/@first}}\n {{/isStartOfWeek}}\n \n {{/list}}\n \n \n
\n {{label}}\n
\n \n \n {{thisDataLabel}}\n \n \n
\n '},c=function(){return'\n \n \n \n \n \n \n \n \n {{#list}} \n {{#isStartOfRow}}\n {{^@first}}\n \n \n {{/@first}}\n {{/isStartOfRow}}\n \n {{/list}}\n \n \n
\n {{colHeadLabel}}\n
\n \n \n {{thisMonthLabel}}\n \n \n
\n '},h=function(){return'\n \n \n \n \n \n \n \n \n {{#list}} \n {{#isStartOfRow}}\n {{^@first}}\n \n \n {{/@first}}\n {{/isStartOfRow}}\n \n {{/list}}\n \n \n
\n {{colHeadLabel}}\n
\n \n \n {{thisYearLabel}}\n \n \n
\n '},u=function(){var e,t,l=a.date(n.displayDate),i="",r="";return n.control&&("day"==n.mode||"d"==n.mode?(i=n.control.yearTmpl?n.control.yearTmpl.replace("%s",l.getFullYear()):l.getFullYear(),r=n.control.monthTmpl?n.control.monthTmpl.replace("%s",n.lang.months[l.getMonth()]):n.lang.months[l.getMonth()],this.$["control-display"].html(function(){return n.control.yearFirst?''+i+''+r+"":''+r+''+i+""}())):"month"==n.mode||"m"==n.mode?(i=n.control.yearTmpl?n.control.yearTmpl.replace("%s",l.getFullYear()):l.getFullYear(),this.$["control-display"].html(''+i+"")):("year"==n.mode||"y"==n.mode)&&(e=n.control.yearTmpl?n.control.yearTmpl.replace("%s",l.getFullYear()-10):l.getFullYear()-10,t=n.control.yearTmpl?n.control.yearTmpl.replace("%s",Number(l.getFullYear())+9):Number(l.getFullYear())+9,this.$["control-display"].html(e+" ~ "+t)),this.$["control-display"].find("[data-calendar-display]").on(n.clickEventName,function(e){var t,n=a.findParentNode(e.target,function(e){return e.getAttribute("data-calendar-display")?!0:void 0});n&&(t=n.getAttribute("data-calendar-display"),this.changeMode(t)),n=null,t=null}.bind(this))),l=null,i=null,r=null,e=null,t=null,this},m=function(e){var t,i,d,s,c=a.date(e),h=new Date(c.getFullYear(),c.getMonth(),1,12),m=n.displayDate,f=function(){var e=h.getDay();0==e&&(e=7);try{return a.date(h,{add:{d:-e}})}finally{e=null}}(),y=c.getMonth(),g={},b=this.$.body.width(),v=Math.floor(b*(6/7)),M=o();for(n.dimensions.height&&(v=a.number(n.dimensions.height)-a.number(n.dimensions.colHeadHeight)),g.height=Math.floor(v/6)-2*a.number(n.dimensions.itemPadding)+"px",g["line-height"]=g.height,g.padding=a.cssNumber(n.dimensions.itemPadding),s={weekNames:[].concat(ax5.info.weekNames),list:[]},s.weekNames.forEach(function(e){e.colHeadHeight=a.cssNumber(n.dimensions.colHeadHeight)}),t=f,i=0;6>i;){for(d=0;7>d;){var D=""+a.date(t,{"return":n.dateFormat}),S={row:i,col:d,isStartOfWeek:0==d,thisDate:""+D,thisDataLabel:n.lang.dayTmpl.replace("%s",t.getDate()),itemStyles:a.css(g),addClass:function(){return n.selectable?l.selectableMap[D]?t.getMonth()==y?"live":"":"disable":t.getMonth()==y?D==a.date(m,{"return":"yyyyMMdd"})?"focus":"live":""}()+" "+function(){return l.markerMap[D]?l.markerMap[D].theme||n.defaultMarkerTheme:""}()+" "+function(){return l.selectionMap[D]?"selected-day":""}()};s.list.push(S),d++,t=a.date(t,{add:{d:1}}),D=null,S=null}i++}this.$.body.html(ax5.mustache.render(M,s)),this.$.body.find("[data-calendar-item-date]").on(n.clickEventName,function(e){e=e||window.event,p.call(l,e,"date"),a.stopEvent(e)}),this.printedDay={start:f,end:t},r.call(this,null,{self:this,action:"printDay",printedDay:this.printedDay}),u.call(this),c=null,h=null,m=null,f=null,t=null,y=null,g=null,i=null,d=null,b=null,v=null,s=null,M=null},f=function(e){var t,i,d,s,o,h=a.date(e),m=h.getMonth(),f={},y=this.$.body.width(),g=Math.floor(y*(6/7)),b=c();for(n.dimensions.height&&(g=a.number(n.dimensions.height)-a.number(n.dimensions.colHeadHeight)),f.height=Math.floor(g/4)-2*a.number(n.dimensions.itemPadding)+"px",f["line-height"]=f.height,f.padding=a.cssNumber(n.dimensions.itemPadding),o={colHeadHeight:a.cssNumber(n.dimensions.colHeadHeight),colHeadLabel:n.lang.monthHeading,list:[]},s=0,d=0,t=0;4>t;){for(i=0;3>i;){var v={row:t,col:i,isStartOfRow:0==i,thisMonth:h.getFullYear()+"-"+a.setDigit(d+1,2)+"-"+a.setDigit(h.getDate(),2),thisMonthLabel:n.lang.months[d],itemStyles:a.css(f),addClass:function(){return n.selectable?l.selectableMap[d]?"live":"disable":"live"}()+" "+function(){return d==m?"focus":""}()+" "+function(){return l.markerMap[d]?l.markerMap[d].theme||n.defaultMarkerTheme:""}()};o.list.push(v),d++,i++,v=null}t++}this.$.body.html(ax5.mustache.render(b,o)),this.$.body.find("[data-calendar-item-month]").on(n.clickEventName,function(e){e=e||window.event,p.call(l,e,"month"),a.stopEvent(e)}),this.printedDay={start:h.getFullYear()+"-"+a.setDigit(s+1,2),end:h.getFullYear()+"-"+a.setDigit(d,2)},r.call(this,null,{self:this,action:"printMonth",printedDay:this.printedDay}),u.call(this),h=null,m=null,f=null,t=null,i=null,d=null,s=null,y=null,g=null,o=null,b=null},y=function(e){var t,i,d,s,o,c=a.date(e),m=c.getFullYear(),f={},y=this.$.body.width(),g=Math.floor(y*(6/7)),b=h();for(n.dimensions.height&&(g=a.number(n.dimensions.height)-a.number(n.dimensions.colHeadHeight)),f.height=Math.floor(g/5)-2*a.number(n.dimensions.itemPadding)+"px",f["line-height"]=f.height,f.padding=a.cssNumber(n.dimensions.itemPadding),o={colHeadHeight:a.cssNumber(n.dimensions.colHeadHeight),colHeadLabel:n.lang.yearHeading,list:[]},s=m-10,d=m-10,t=0;5>t;){for(i=0;4>i;){var v={row:t,col:i,isStartOfRow:0==i,thisYear:d+"-"+a.setDigit(c.getMonth()+1,2)+"-"+a.setDigit(c.getDate(),2),thisYearLabel:n.lang.yearTmpl.replace("%s",d),itemStyles:a.css(f),addClass:function(){return n.selectable?l.selectableMap[d]?"live":"disable":"live"}()+" "+function(){return d==m?"focus":""}()+" "+function(){return l.selectableMap[d]?l.selectableMap[d].theme||n.defaultMarkerTheme:""}()};o.list.push(v),d++,i++,v=null}t++}this.$.body.html(ax5.mustache.render(b,o)),this.$.body.find("[data-calendar-item-year]").on(n.clickEventName,function(e){e=e||window.event,p.call(this,e,"year"),a.stopEvent(e)}),this.printedDay={start:s,end:d-1},r.call(this,null,{self:this,action:"printYear",printedDay:this.printedDay}),u.call(this),c=null,m=null,f=null,t=null,i=null,d=null,s=null,y=null,g=null,o=null,b=null},p=function(e,t,r,d){var s,o,c;t=t||"date",r=a.findParentNode(e.target,function(e){return e.getAttribute("data-calendar-item-"+t)?!0:void 0}),r&&(d=r.getAttribute("data-calendar-item-"+t),o=a.date(d,{"return":n.dateFormat}),c=!0,i=n.multipleSelect?a.isNumber(n.multipleSelect)?n.multipleSelect:2:1,n.selectable&&(l.selectableMap[o]||(c=!1)),"date"==t?c&&(l.selection.length>=i&&(s=l.selection.splice(0,l.selection.length-(i-1)),s.forEach(function(e){l.$.body.find('[data-calendar-item-date="'+a.date(e,{"return":n.dateFormat})+'"]').removeClass("selected-day")})),jQuery(r).addClass("selected-day"),l.selection.push(d),l.onClick&&l.onClick.call({self:this,date:d,target:this.target,dateElement:r})):"month"==t?"month"==n.selectMode?c&&(l.selection.length>=i&&(s=l.selection.splice(0,l.selection.length-(i-1)),s.forEach(function(e){l.$.body.find('[data-calendar-item-month="'+a.date(e,{"return":"yyyy-MM-dd"})+'"]').removeClass("selected-month")})),jQuery(r).addClass("selected-month"),l.selection.push(d),l.onClick&&l.onClick.call({self:this,date:d,target:this.target,dateElement:r})):l.changeMode("day",d):"year"==t&&("year"==n.selectMode?c&&(l.selection.length>=i&&(s=l.selection.splice(0,l.selection.length-(i-1)),s.forEach(function(e){l.$.body.find('[data-calendar-item-year="'+a.date(e,{"return":"yyyy-MM-dd"})+'"]').removeClass("selected-year")})),jQuery(r).addClass("selected-year"),l.selection.push(d),l.onClick&&l.onClick.call({self:this,date:d,target:this.target,dateElement:r})):l.changeMode("month",d))),t=null,r=null,d=null,s=null,o=null,c=null},g=function(e,t,l){t=a.findParentNode(e.target,function(e){return e.getAttribute("data-calendar-move")?!0:void 0}),t&&(l=t.getAttribute("data-calendar-move"),"day"==n.mode?("left"==l?n.displayDate=a.date(n.displayDate,{add:{m:-1}}):n.displayDate=a.date(n.displayDate,{add:{m:1}}),m.call(this,n.displayDate)):"month"==n.mode?("left"==l?n.displayDate=a.date(n.displayDate,{add:{y:-1}}):n.displayDate=a.date(n.displayDate,{add:{y:1}}),f.call(this,n.displayDate)):"year"==n.mode&&("left"==l?n.displayDate=a.date(n.displayDate,{add:{y:-10}}):n.displayDate=a.date(n.displayDate,{add:{y:10}}),y.call(this,n.displayDate))),t=null,l=null},b=function(){setTimeout(function(){if("day"===n.mode||"d"===n.mode)for(var e in this.markerMap)this.$.body.find('[data-calendar-item-date="'+e+'"]').addClass(this.markerMap[e].theme||n.defaultMarkerTheme)}.bind(this))},v=function(){setTimeout(function(){for(var e in this.selectionMap)this.$.body.find('[data-calendar-item-date="'+e+'"]').addClass("selected-day")}.bind(this))},M=function(){setTimeout(function(){if("day"===n.mode||"d"===n.mode)for(var e in this.periodMap)this.periodMap[e].label&&this.$.body.find('[data-calendar-item-date="'+e+'"]').find(".addon-footer").html(this.periodMap[e].label),this.$.body.find('[data-calendar-item-date="'+e+'"]').addClass(this.periodMap[e].theme)}.bind(this))},D=function(){setTimeout(function(){if("day"===n.mode||"d"===n.mode)for(var e in this.periodMap)this.$.body.find('[data-calendar-item-date="'+e+'"]').find(".addon-footer").empty(),this.$.body.find('[data-calendar-item-date="'+e+'"]').removeClass(this.periodMap[e].theme)}.bind(this))};this.init=function(){this.onStateChanged=n.onStateChanged,this.onClick=n.onClick,n.target||console.log(ax5.info.getError("ax5calendar","401","setConfig")),this.target=jQuery(n.target),n.displayDate=a.date(n.displayDate),this.target.html(s.call(this)),this.$={root:this.target.find('[data-calendar-els="root"]'),control:this.target.find('[data-calendar-els="control"]'),"control-display":this.target.find('[data-calendar-els="control-display"]'),body:this.target.find('[data-calendar-els="body"]')},n.control&&this.$.control.find("[data-calendar-move]").on(n.clickEventName,function(e){g.call(this,e||window.event)}.bind(this)),n.selection&&this.setSelection(n.selection,!1),n.selectable&&this.setSelectable(n.selectable,!1),n.marker&&this.setMarker(n.marker,!1),setTimeout(function(){"day"===n.mode||"d"===n.mode?m.call(this,n.displayDate):"month"===n.mode||"m"===n.mode?f.call(this,n.displayDate):("year"===n.mode||"y"===n.mode)&&y.call(this,n.displayDate)}.bind(this))},this.changeMode=function(e,t){return"undefined"!=typeof t&&(n.displayDate=t),e&&(n.mode=e),this.$.body.removeClass("fadein").addClass("fadeout"),setTimeout(function(){"day"==n.mode||"d"==n.mode?m.call(this,n.displayDate):"month"==n.mode||"m"==n.mode?f.call(this,n.displayDate):("year"==n.mode||"y"==n.mode)&&y.call(this,n.displayDate),this.$.body.removeClass("fadeout").addClass("fadein")}.bind(this),n.animateTime),this},this.setSelection=function(){l.selectionMap={};var e={arr:function(e,t,i){return t={},a.isArray(e)?(l.selection=e=e.splice(0,i),e.forEach(function(e){a.isDate(e)&&(e=a.date(e,{"return":n.dateFormat})),t[e]=!0}),t):t}};return function(t,l){var r={};if(i=n.multipleSelect?a.isNumber(n.multipleSelect)?n.multipleSelect:2:1,n.selection=t){if(!a.isArray(t))return this;r=e.arr(t,{},i)}return this.selectionMap=jQuery.extend({},r),l!==!1&&v.call(this),r=null,this}}(),this.getSelection=function(){return this.selection},this.setSelectable=function(){l.selectableMap={};var e={arr:function(e,t){return t={},a.isArray(e)?(e.forEach(function(e){a.isDate(e)&&(e=a.date(e,{"return":n.dateFormat})),t[e]=!0}),t):t},obj:function(e,t){if(t={},a.isArray(e))return t;if(e.range)return t;for(var n in e)t[n]=e[n];return t},range:function(e,t){return t={},a.isArray(e)?t:e.range?(e.range.forEach(function(e){if(a.isDateFormat(e.from)&&a.isDateFormat(e.to))for(var l=a.date(e.from);l<=a.date(e.to);l.setDate(l.getDate()+1))t[a.date(l,{"return":n.dateFormat})]=!0;else for(var i=e.from;i<=e.to;i++)t[i]=!0}),t):t}};return function(t,l){var i,r={};if(n.selectable=t)if(a.isArray(t))r=e.arr(t);else{for(i in e)if(t[i]){r=e[i](t);break}0===Object.keys(r).length&&(r=e.obj(t))}return this.selectableMap=r,l!==!1&&this.changeMode(),this}}(),this.setMarker=function(){l.markerMap={};var e={obj:function(e,t){if(t={},a.isArray(e))return t;if(e.range)return t;for(var n in e)t[n]=e[n];return e=null,t},range:function(e,t){return t={},a.isArray(e)?t:e.range?(e.range.forEach(function(e){if(a.isDateFormat(e.from)&&a.isDateFormat(e.to))for(var l=a.date(e.from);l<=a.date(e.to);l.setDate(l.getDate()+1))t[a.date(l,{"return":n.dateFormat})]={theme:e.theme,label:e.label};else for(var i=e.from;i<=e.to;i++)t[i]={theme:e.theme,label:e.label}}),e=null,t):t}};return function(t,a){var l,i={};if(n.marker=t){for(l in e)if(t[l]){i=e[l](t);break}0===Object.keys(i).length&&(i=e.obj(t))}return this.markerMap=i,a!==!1&&b.call(this),this}}(),this.setPeriod=function(){l.periodMap={};var e={range:function(e,t){return t={},a.isArray(e)?t:e.range?(e.range.forEach(function(e){if(a.isDateFormat(e.from)&&a.isDateFormat(e.to))for(var l=a.date(e.from);l<=a.date(e.to);l.setDate(l.getDate()+1))l.getTime()==a.date(e.from).getTime()?t[a.date(l,{"return":n.dateFormat})]={theme:e.theme||n.defaultPeriodTheme,label:e.fromLabel}:l.getTime()==a.date(e.to).getTime()?t[a.date(l,{"return":n.dateFormat})]={theme:e.theme||n.defaultPeriodTheme,label:e.toLabel}:t[a.date(l,{"return":n.dateFormat})]={theme:e.theme||n.defaultPeriodTheme}}),e=null,t):t}};return function(t,a){var l={};return(n.period=t)&&(l=e.range(t)),this.periodMap=l,a!==!1&&(D.call(this),M.call(this)),this}}(),this.main=function(){e.calendar_instance=e.calendar_instance||[],e.calendar_instance.push(this),arguments&&a.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};e.calendar=function(){return a.isFunction(t)&&(n.prototype=new t),n}()}(ax5.ui,ax5.ui.root); \ No newline at end of file +"use strict";!function(e,t){var a=ax5.util,n=function(){t&&t.call(this);var n,l=this,i=1;this.target=null,this.selection=[],this.selectionMap={},this.selectableMap={},this.markerMap={},this.printedDay={start:"",end:""},this.config={clickEventName:"click",theme:"default",mode:"day",dateFormat:"yyyy-MM-dd",displayDate:new Date,animateTime:250,dimensions:{controlHeight:"40",controlButtonWidth:"40",colHeadHeight:"30",itemPadding:2},lang:{yearHeading:"Choose the year",monthHeading:"Choose the month",yearTmpl:"%s",months:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],dayTmpl:"%s"},multipleSelect:!1,selectMode:"day",defaultMarkerTheme:"holiday",defaultPeriodTheme:"period"},n=this.config;var r=function(e,t){e&&e.onStateChanged?e.onStateChanged.call(t,t):this.onStateChanged&&this.onStateChanged.call(t,t),t=null},d=function(){return'\n
\n {{#control}}\n \n {{/control}}\n
\n
\n '},s=function(){var e=jQuery.extend(!0,{},n,{controlCSS:{},controlButtonCSS:{}}),t=d();e.controlButtonCSS.height=e.controlCSS.height=a.cssNumber(n.dimensions.controlHeight),e.controlButtonCSS["line-height"]=e.controlCSS["line-height"]=a.cssNumber(n.dimensions.controlHeight),e.controlButtonCSS.width=a.cssNumber(n.dimensions.controlHeight),e.controlCSS=a.css(e.controlCSS),e.controlButtonCSS=a.css(e.controlButtonCSS);try{return ax5.mustache.render(t,e)}finally{e=null,t=null}},o=function(){return'\n \n \n \n {{#weekNames}}\n \n {{/weekNames}}\n \n \n \n \n {{#list}} \n {{#isStartOfWeek}}\n {{^@first}}\n \n \n {{/@first}}\n {{/isStartOfWeek}}\n \n {{/list}}\n \n \n
\n {{label}}\n
\n \n \n {{thisDataLabel}}\n \n \n
\n '},c=function(){return'\n \n \n \n \n \n \n \n \n {{#list}} \n {{#isStartOfRow}}\n {{^@first}}\n \n \n {{/@first}}\n {{/isStartOfRow}}\n \n {{/list}}\n \n \n
\n {{colHeadLabel}}\n
\n \n \n {{thisMonthLabel}}\n \n \n
\n '},h=function(){return'\n \n \n \n \n \n \n \n \n {{#list}} \n {{#isStartOfRow}}\n {{^@first}}\n \n \n {{/@first}}\n {{/isStartOfRow}}\n \n {{/list}}\n \n \n
\n {{colHeadLabel}}\n
\n \n \n {{thisYearLabel}}\n \n \n
\n '},u=function(){var e,t,l=a.date(n.displayDate),i="",r="";return n.control&&("day"==n.mode||"d"==n.mode?(i=n.control.yearTmpl?n.control.yearTmpl.replace("%s",l.getFullYear()):l.getFullYear(),r=n.control.monthTmpl?n.control.monthTmpl.replace("%s",n.lang.months[l.getMonth()]):n.lang.months[l.getMonth()],this.$["control-display"].html(function(){return n.control.yearFirst?''+i+''+r+"":''+r+''+i+""}())):"month"==n.mode||"m"==n.mode?(i=n.control.yearTmpl?n.control.yearTmpl.replace("%s",l.getFullYear()):l.getFullYear(),this.$["control-display"].html(''+i+"")):("year"==n.mode||"y"==n.mode)&&(e=n.control.yearTmpl?n.control.yearTmpl.replace("%s",l.getFullYear()-10):l.getFullYear()-10,t=n.control.yearTmpl?n.control.yearTmpl.replace("%s",Number(l.getFullYear())+9):Number(l.getFullYear())+9,this.$["control-display"].html(e+" ~ "+t)),this.$["control-display"].find("[data-calendar-display]").on(n.clickEventName,function(e){var t,n=a.findParentNode(e.target,function(e){return e.getAttribute("data-calendar-display")?!0:void 0});n&&(t=n.getAttribute("data-calendar-display"),this.changeMode(t)),n=null,t=null}.bind(this))),l=null,i=null,r=null,e=null,t=null,this},m=function(e){var t,i,d,s,c=a.date(e),h=new Date(c.getFullYear(),c.getMonth(),1,12),m=n.displayDate,f=function(){var e=h.getDay();0==e&&(e=7);try{return a.date(h,{add:{d:-e}})}finally{e=null}}(),y=c.getMonth(),g={},b=this.$.body.width(),v=Math.floor(b*(6/7)),M=o();for(n.dimensions.height&&(v=a.number(n.dimensions.height)-a.number(n.dimensions.colHeadHeight)),g.height=Math.floor(v/6)-2*a.number(n.dimensions.itemPadding)+"px",g["line-height"]=g.height,g.padding=a.cssNumber(n.dimensions.itemPadding),s={weekNames:[].concat(ax5.info.weekNames),list:[]},s.weekNames.forEach(function(e){e.colHeadHeight=a.cssNumber(n.dimensions.colHeadHeight)}),t=f,i=0;6>i;){for(d=0;7>d;){var D=""+a.date(t,{"return":n.dateFormat}),S={row:i,col:d,isStartOfWeek:0==d,thisDate:""+D,thisDataLabel:n.lang.dayTmpl.replace("%s",t.getDate()),itemStyles:a.css(g),addClass:function(){return n.selectable?l.selectableMap[D]?t.getMonth()==y?"live":"":"disable":t.getMonth()==y?D==a.date(m,{"return":"yyyyMMdd"})?"focus":"live":""}()+" "+function(){return l.markerMap[D]?l.markerMap[D].theme||n.defaultMarkerTheme:""}()+" "+function(){return l.selectionMap[D]?"selected-day":""}()};s.list.push(S),d++,t=a.date(t,{add:{d:1}}),D=null,S=null}i++}this.$.body.html(ax5.mustache.render(M,s)),this.$.body.find("[data-calendar-item-date]").on(n.clickEventName,function(e){e=e||window.event,p.call(l,e,"date"),a.stopEvent(e)}),this.printedDay={start:f,end:t},r.call(this,null,{self:this,action:"printDay",printedDay:this.printedDay}),u.call(this),c=null,h=null,m=null,f=null,t=null,y=null,g=null,i=null,d=null,b=null,v=null,s=null,M=null},f=function(e){var t,i,d,s,o,h=a.date(e),m=h.getMonth(),f={},y=this.$.body.width(),g=Math.floor(y*(6/7)),b=c();for(n.dimensions.height&&(g=a.number(n.dimensions.height)-a.number(n.dimensions.colHeadHeight)),f.height=Math.floor(g/4)-2*a.number(n.dimensions.itemPadding)+"px",f["line-height"]=f.height,f.padding=a.cssNumber(n.dimensions.itemPadding),o={colHeadHeight:a.cssNumber(n.dimensions.colHeadHeight),colHeadLabel:n.lang.monthHeading,list:[]},s=0,d=0,t=0;4>t;){for(i=0;3>i;){var v={row:t,col:i,isStartOfRow:0==i,thisMonth:h.getFullYear()+"-"+a.setDigit(d+1,2)+"-"+a.setDigit(h.getDate(),2),thisMonthLabel:n.lang.months[d],itemStyles:a.css(f),addClass:function(){return n.selectable?l.selectableMap[d]?"live":"disable":"live"}()+" "+function(){return d==m?"focus":""}()+" "+function(){return l.markerMap[d]?l.markerMap[d].theme||n.defaultMarkerTheme:""}()};o.list.push(v),d++,i++,v=null}t++}this.$.body.html(ax5.mustache.render(b,o)),this.$.body.find("[data-calendar-item-month]").on(n.clickEventName,function(e){e=e||window.event,p.call(l,e,"month"),a.stopEvent(e)}),this.printedDay={start:h.getFullYear()+"-"+a.setDigit(s+1,2),end:h.getFullYear()+"-"+a.setDigit(d,2)},r.call(this,null,{self:this,action:"printMonth",printedDay:this.printedDay}),u.call(this),h=null,m=null,f=null,t=null,i=null,d=null,s=null,y=null,g=null,o=null,b=null},y=function(e){var t,i,d,s,o,c=a.date(e),m=c.getFullYear(),f={},y=this.$.body.width(),g=Math.floor(y*(6/7)),b=h();for(n.dimensions.height&&(g=a.number(n.dimensions.height)-a.number(n.dimensions.colHeadHeight)),f.height=Math.floor(g/5)-2*a.number(n.dimensions.itemPadding)+"px",f["line-height"]=f.height,f.padding=a.cssNumber(n.dimensions.itemPadding),o={colHeadHeight:a.cssNumber(n.dimensions.colHeadHeight),colHeadLabel:n.lang.yearHeading,list:[]},s=m-10,d=m-10,t=0;5>t;){for(i=0;4>i;){var v={row:t,col:i,isStartOfRow:0==i,thisYear:d+"-"+a.setDigit(c.getMonth()+1,2)+"-"+a.setDigit(c.getDate(),2),thisYearLabel:n.lang.yearTmpl.replace("%s",d),itemStyles:a.css(f),addClass:function(){return n.selectable?l.selectableMap[d]?"live":"disable":"live"}()+" "+function(){return d==m?"focus":""}()+" "+function(){return l.selectableMap[d]?l.selectableMap[d].theme||n.defaultMarkerTheme:""}()};o.list.push(v),d++,i++,v=null}t++}this.$.body.html(ax5.mustache.render(b,o)),this.$.body.find("[data-calendar-item-year]").on(n.clickEventName,function(e){e=e||window.event,p.call(this,e,"year"),a.stopEvent(e)}),this.printedDay={start:s,end:d-1},r.call(this,null,{self:this,action:"printYear",printedDay:this.printedDay}),u.call(this),c=null,m=null,f=null,t=null,i=null,d=null,s=null,y=null,g=null,o=null,b=null},p=function(e,t,r,d){var s,o,c;t=t||"date",r=a.findParentNode(e.target,function(e){return e.getAttribute("data-calendar-item-"+t)?!0:void 0}),r&&(d=r.getAttribute("data-calendar-item-"+t),o=a.date(d,{"return":n.dateFormat}),c=!0,i=n.multipleSelect?a.isNumber(n.multipleSelect)?n.multipleSelect:2:1,n.selectable&&(l.selectableMap[o]||(c=!1)),"date"==t?c&&(l.selection.length>=i&&(s=l.selection.splice(0,l.selection.length-(i-1)),s.forEach(function(e){l.$.body.find('[data-calendar-item-date="'+a.date(e,{"return":n.dateFormat})+'"]').removeClass("selected-day")})),jQuery(r).addClass("selected-day"),l.selection.push(d),l.onClick&&l.onClick.call({self:this,date:d,target:this.target,dateElement:r})):"month"==t?"month"==n.selectMode?c&&(l.selection.length>=i&&(s=l.selection.splice(0,l.selection.length-(i-1)),s.forEach(function(e){l.$.body.find('[data-calendar-item-month="'+a.date(e,{"return":"yyyy-MM-dd"})+'"]').removeClass("selected-month")})),jQuery(r).addClass("selected-month"),l.selection.push(d),l.onClick&&l.onClick.call({self:this,date:d,target:this.target,dateElement:r})):l.changeMode("day",d):"year"==t&&("year"==n.selectMode?c&&(l.selection.length>=i&&(s=l.selection.splice(0,l.selection.length-(i-1)),s.forEach(function(e){l.$.body.find('[data-calendar-item-year="'+a.date(e,{"return":"yyyy-MM-dd"})+'"]').removeClass("selected-year")})),jQuery(r).addClass("selected-year"),l.selection.push(d),l.onClick&&l.onClick.call({self:this,date:d,target:this.target,dateElement:r})):l.changeMode("month",d))),t=null,r=null,d=null,s=null,o=null,c=null},g=function(e,t,l){t=a.findParentNode(e.target,function(e){return e.getAttribute("data-calendar-move")?!0:void 0}),t&&(l=t.getAttribute("data-calendar-move"),"day"==n.mode?("left"==l?n.displayDate=a.date(n.displayDate,{add:{m:-1}}):n.displayDate=a.date(n.displayDate,{add:{m:1}}),m.call(this,n.displayDate)):"month"==n.mode?("left"==l?n.displayDate=a.date(n.displayDate,{add:{y:-1}}):n.displayDate=a.date(n.displayDate,{add:{y:1}}),f.call(this,n.displayDate)):"year"==n.mode&&("left"==l?n.displayDate=a.date(n.displayDate,{add:{y:-10}}):n.displayDate=a.date(n.displayDate,{add:{y:10}}),y.call(this,n.displayDate))),t=null,l=null},b=function(){setTimeout(function(){if("day"===n.mode||"d"===n.mode)for(var e in this.markerMap)this.$.body.find('[data-calendar-item-date="'+e+'"]').addClass(this.markerMap[e].theme||n.defaultMarkerTheme)}.bind(this))},v=function(){setTimeout(function(){for(var e in this.selectionMap)this.$.body.find('[data-calendar-item-date="'+e+'"]').addClass("selected-day")}.bind(this))},M=function(){setTimeout(function(){if("day"===n.mode||"d"===n.mode)for(var e in this.periodMap)this.periodMap[e].label&&this.$.body.find('[data-calendar-item-date="'+e+'"]').find(".addon-footer").html(this.periodMap[e].label),this.$.body.find('[data-calendar-item-date="'+e+'"]').addClass(this.periodMap[e].theme)}.bind(this))},D=function(){if("day"===n.mode||"d"===n.mode)for(var e in this.periodMap)this.$.body.find('[data-calendar-item-date="'+e+'"]').find(".addon-footer").empty(),this.$.body.find('[data-calendar-item-date="'+e+'"]').removeClass(this.periodMap[e].theme)};this.init=function(){this.onStateChanged=n.onStateChanged,this.onClick=n.onClick,n.target||console.log(ax5.info.getError("ax5calendar","401","setConfig")),this.target=jQuery(n.target),n.displayDate=a.date(n.displayDate),this.target.html(s.call(this)),this.$={root:this.target.find('[data-calendar-els="root"]'),control:this.target.find('[data-calendar-els="control"]'),"control-display":this.target.find('[data-calendar-els="control-display"]'),body:this.target.find('[data-calendar-els="body"]')},n.control&&this.$.control.find("[data-calendar-move]").on(n.clickEventName,function(e){g.call(this,e||window.event)}.bind(this)),n.selection&&this.setSelection(n.selection,!1),n.selectable&&this.setSelectable(n.selectable,!1),n.marker&&this.setMarker(n.marker,!1),setTimeout(function(){"day"===n.mode||"d"===n.mode?m.call(this,n.displayDate):"month"===n.mode||"m"===n.mode?f.call(this,n.displayDate):("year"===n.mode||"y"===n.mode)&&y.call(this,n.displayDate)}.bind(this))},this.changeMode=function(e,t){return"undefined"!=typeof t&&(n.displayDate=t),e&&(n.mode=e),this.$.body.removeClass("fadein").addClass("fadeout"),setTimeout(function(){"day"==n.mode||"d"==n.mode?m.call(this,n.displayDate):"month"==n.mode||"m"==n.mode?f.call(this,n.displayDate):("year"==n.mode||"y"==n.mode)&&y.call(this,n.displayDate),this.$.body.removeClass("fadeout").addClass("fadein")}.bind(this),n.animateTime),this},this.setSelection=function(){l.selectionMap={};var e={arr:function(e,t,i){return t={},a.isArray(e)?(l.selection=e=e.splice(0,i),e.forEach(function(e){a.isDate(e)&&(e=a.date(e,{"return":n.dateFormat})),t[e]=!0}),t):t}};return function(t,l){var r={};if(i=n.multipleSelect?a.isNumber(n.multipleSelect)?n.multipleSelect:2:1,n.selection=t){if(!a.isArray(t))return this;r=e.arr(t,{},i)}return this.selectionMap=jQuery.extend({},r),l!==!1&&v.call(this),r=null,this}}(),this.getSelection=function(){return this.selection},this.setSelectable=function(){l.selectableMap={};var e={arr:function(e,t){return t={},a.isArray(e)?(e.forEach(function(e){a.isDate(e)&&(e=a.date(e,{"return":n.dateFormat})),t[e]=!0}),t):t},obj:function(e,t){if(t={},a.isArray(e))return t;if(e.range)return t;for(var n in e)t[n]=e[n];return t},range:function(e,t){return t={},a.isArray(e)?t:e.range?(e.range.forEach(function(e){if(a.isDateFormat(e.from)&&a.isDateFormat(e.to))for(var l=a.date(e.from);l<=a.date(e.to);l.setDate(l.getDate()+1))t[a.date(l,{"return":n.dateFormat})]=!0;else for(var i=e.from;i<=e.to;i++)t[i]=!0}),t):t}};return function(t,l){var i,r={};if(n.selectable=t)if(a.isArray(t))r=e.arr(t);else{for(i in e)if(t[i]){r=e[i](t);break}0===Object.keys(r).length&&(r=e.obj(t))}return this.selectableMap=r,l!==!1&&this.changeMode(),this}}(),this.setMarker=function(){l.markerMap={};var e={obj:function(e,t){if(t={},a.isArray(e))return t;if(e.range)return t;for(var n in e)t[n]=e[n];return e=null,t},range:function(e,t){return t={},a.isArray(e)?t:e.range?(e.range.forEach(function(e){if(a.isDateFormat(e.from)&&a.isDateFormat(e.to))for(var l=a.date(e.from);l<=a.date(e.to);l.setDate(l.getDate()+1))t[a.date(l,{"return":n.dateFormat})]={theme:e.theme,label:e.label};else for(var i=e.from;i<=e.to;i++)t[i]={theme:e.theme,label:e.label}}),e=null,t):t}};return function(t,a){var l,i={};if(n.marker=t){for(l in e)if(t[l]){i=e[l](t);break}0===Object.keys(i).length&&(i=e.obj(t))}return this.markerMap=i,a!==!1&&b.call(this),this}}(),this.setPeriod=function(){l.periodMap={};var e={range:function(e,t){return t={},a.isArray(e)?t:e.range?(e.range.forEach(function(e){if(a.isDateFormat(e.from)&&a.isDateFormat(e.to))for(var l=new Date(a.date(e.from));l<=a.date(e.to);l.setDate(l.getDate()+1))l.getTime()==a.date(e.from).getTime()?t[a.date(l,{"return":n.dateFormat})]={theme:e.theme||n.defaultPeriodTheme,label:e.fromLabel}:l.getTime()==a.date(e.to).getTime()?t[a.date(l,{"return":n.dateFormat})]={theme:e.theme||n.defaultPeriodTheme,label:e.toLabel}:t[a.date(l,{"return":n.dateFormat})]={theme:e.theme||n.defaultPeriodTheme}}),e=null,t):t}};return function(t,a){var l={};return a!==!1&&D.call(this),(n.period=t)&&(l=e.range(t)),this.periodMap=l,a!==!1&&M.call(this),this}}(),this.main=function(){e.calendar_instance=e.calendar_instance||[],e.calendar_instance.push(this),arguments&&a.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};e.calendar=function(){return a.isFunction(t)&&(n.prototype=new t),n}()}(ax5.ui,ax5.ui.root); \ No newline at end of file diff --git a/src/ax5calendar.js b/src/ax5calendar.js index 38c6d02..3313b4b 100755 --- a/src/ax5calendar.js +++ b/src/ax5calendar.js @@ -752,14 +752,12 @@ }).bind(this)); }, clearPeriodMap = function () { - setTimeout((function () { - if (cfg.mode === "day" || cfg.mode === "d") { - for (var k in this.periodMap) { - this.$["body"].find('[data-calendar-item-date="' + k + '"]').find(".addon-footer").empty(); - this.$["body"].find('[data-calendar-item-date="' + k + '"]').removeClass(this.periodMap[k].theme); - } + if (cfg.mode === "day" || cfg.mode === "d") { + for (var k in this.periodMap) { + this.$["body"].find('[data-calendar-item-date="' + k + '"]').find(".addon-footer").empty(); + this.$["body"].find('[data-calendar-item-date="' + k + '"]').removeClass(this.periodMap[k].theme); } - }).bind(this)); + } }; /** @@ -1074,15 +1072,12 @@ v.range.forEach(function (n) { if (U.isDateFormat(n.from) && U.isDateFormat(n.to)) { - - for (var d = U.date(n.from); d <= U.date(n.to); d.setDate(d.getDate() + 1)) { + for (var d = new Date(U.date(n.from)); d <= U.date(n.to); d.setDate(d.getDate() + 1)) { if (d.getTime() == U.date(n.from).getTime()) { map[U.date(d, {"return": cfg.dateFormat})] = {theme: n.theme || cfg.defaultPeriodTheme, label: n.fromLabel}; - } - else if (d.getTime() == U.date(n.to).getTime()) { + } else if (d.getTime() == U.date(n.to).getTime()) { map[U.date(d, {"return": cfg.dateFormat})] = {theme: n.theme || cfg.defaultPeriodTheme, label: n.toLabel}; - } - else { + } else { map[U.date(d, {"return": cfg.dateFormat})] = {theme: n.theme || cfg.defaultPeriodTheme}; } } @@ -1101,6 +1096,11 @@ result = {} ; + // 변경내용 적용하여 출력 + if (isApply !== false) { + clearPeriodMap.call(this); + } + if (cfg.period = period) { result = processor.range(period); } @@ -1111,7 +1111,6 @@ // 변경내용 적용하여 출력 if (isApply !== false) { - clearPeriodMap.call(this); applyPeriodMap.call(this); } return this;