diff --git a/js/calendario.js b/js/calendario.js index 3b2cc99..d1fbc69 100644 --- a/js/calendario.js +++ b/js/calendario.js @@ -95,7 +95,7 @@ if(c.repeat == 'INTERVAL' || c.repeat == 'EVERYDAY') c.repeat = 'MON, TUE, WED, THU, FRI, SAT, SUN' else if(c.repeat == 'WEEKDAYS') c.repeat = self.options.weekdays else if(c.repeat == 'WEEKENDS') c.repeat = self.options.weekends - if($.inArray(c.repeat, [undefined, 'YEARLY', 'MONTHLY']) != -1) data = self.insertToCaldata(key.split('-')[1], c, key.split('-'), data) + if($.inArray(c.repeat, [undefined, 'YEARLY', 'MONTHLY']) != -1) data = self.insertToCaldata(parseInt(key.split('-')[1]), c, key.split('-'), data) else if(c.repeat) { $.each(c.repeat.split(','), function(v, k){ data = self.insertToCaldata(k.trim(), $.extend(c, {repeat: 'WEEKLY'}), key.split('-'), data) diff --git a/js/calendario.min.js b/js/calendario.min.js index d9e32f8..d58cae6 100644 --- a/js/calendario.min.js +++ b/js/calendario.min.js @@ -1 +1 @@ -+function(t){"use strict";function e(e,n,o,i){var s="";return this.each(function(){var r=t(this),h=r.data("bz.calendario"),p="object"==typeof e&&e;return h||r.data("bz.calendario",h=new a(this,p)),"string"==typeof e&&t.isFunction(h[e])?s=h[e](n,o,i):"string"==typeof e?s=h.option(n,o):void 0}),s?s:void t(document).trigger(t.Event("finish.calendar.calendario"))}var a=function(t,e){this.init("calendario",t,e)};a.INFO={EMAIL:"%email%",FEED:"%feed%",NAME:"FrozenTime!",VERSION:"4.1.0",UNIQUE:"%unique%",USER:"%user%",UPDATEURL:"%url%"},a.DEFAULTS={weeks:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekabbrs:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthabbrs:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],displayWeekAbbr:!1,displayMonthAbbr:!1,startIn:1,fillEmpty:!0,zone:"00:00",events:["click","focus"],checkUpdate:!0,weekdays:"MON, TUE, WED, THU, FRI",weekends:"SAT, SUN",feed:"http://calendario.t15.org/sync/"},a.prototype.init=function(e,n,o){this.INFO=a.INFO,this.type=e,this.$element=t(n),this.options=t.extend({},a.DEFAULTS,this.$element.data(),o),this.today=new Date,this.month=isNaN(this.options.month)||null===this.options.month?this.today.getMonth():this.options.month-1,this.year=isNaN(this.options.year)||null===this.options.year?this.today.getFullYear():this.options.year,this.caldata=this.processCaldata(this.options.caldata),this.curData=[],this.syncData={},this.generateTemplate(),this.initEvents()},a.prototype.sync=function(e){var a=this;return t.post(a.options.feed,{info:a.INFO,caldata:e,domain:document.domain},function(t){a.syncData=t},"json"),e},a.prototype.initEvents=function(){this.$element.on(this.options.events.join(".calendario ").trim()+".calendario","div.fc-row > div:not(:empty)",function(e){t(this).trigger(t.Event("onDay"+e.type.charAt(0).toUpperCase()+e.type.slice(1)),[t(this).data("bz.calendario.dateprop")])})},a.prototype.propDate=function(){var e=this;this.$element.find("div.fc-row > div").filter(":not(:empty)").each(function(){var a={day:t(this).children("span.fc-date").text(),month:e.month+1,monthname:e.options.displayMonthAbbr?e.options.monthabbrs[e.month]:e.options.months[e.month],year:e.year,weekday:t(this).index()+e.options.startIn,weekdayname:e.options.weeks[6==t(this).index()?0:t(this).index()+e.options.startIn],data:e.curData[t(this).children("span.fc-date").text()]?e.curData[t(this).children("span.fc-date").text()]:!1};t(this).data("bz.calendario.dateprop",a)})},a.prototype.insertToCaldata=function(t,e,a,n){return n[t]||(n[t]=[]),e.day=e.repeat?[a[1],e.endDate.split("-")[1]]:[a[1],a[1]],e.month=e.repeat?[a[0],e.endDate.split("-")[0]]:[a[0],a[0]],e.year=e.repeat?[a[2],e.endDate.split("-")[2]]:[a[2],a[2]],e.category=e.category?"calendar-"+e.category.split("-").pop():"calendar-default",n[t].push(e)?n:n},a.prototype.processCaldata=function(e){var a={},n=this;return t.each(e,function(e,o){t.each(o,function(o,i){"INTERVAL"==i.repeat||"EVERYDAY"==i.repeat?i.repeat="MON, TUE, WED, THU, FRI, SAT, SUN":"WEEKDAYS"==i.repeat?i.repeat=n.options.weekdays:"WEEKENDS"==i.repeat&&(i.repeat=n.options.weekends),-1!=t.inArray(i.repeat,[void 0,"YEARLY","MONTHLY"])?a=n.insertToCaldata(e.split("-")[1],i,e.split("-"),a):i.repeat&&t.each(i.repeat.split(","),function(o,s){a=n.insertToCaldata(s.trim(),t.extend(i,{repeat:"WEEKLY"}),e.split("-"),a)})})}),n.sync(a)},a.prototype.toDObj=function(t,e){var a=parseInt(this.options.zone.split(":")[0]),n=parseInt(this.options.zone.charAt(0)+this.options.zone.split(":")[1]),o=parseInt(t.split(":")[0])-a,i=parseInt(t.split(":")[1])-n;return new Date(Date.UTC(this.year,this.month,e,o,i,0,0))},a.prototype.parseDay=function(t,e){this.curData[e]||(this.curData[e]={html:[],allDay:[],startTime:[],endTime:[],note:[],content:[],url:[]}),this.curData[e].allDay.push(t.allDay?!0:!1),this.curData[e].startTime.push(t.allDay?this.toDObj("00:00",e):this.toDObj(t.startTime,e)),this.curData[e].endTime.push(t.allDay?this.toDObj("23:59",e):this.toDObj(t.endTime,e)),this.curData[e].note.push(t.note?t.note:""),this.curData[e].content.push(t.content?t.content:""),this.curData[e].url.push(t.url?t.url:"");var a=t.url?this.curData[e].html.push(''+t.content+"")-1:this.curData[e].html.push(''+t.content+"")-1;this.curData[e].html[a]+='',this.curData[e].html[a]+='',this.curData[e].html[a]+='',this.curData[e].html[a]+=""+this.curData[e].note[a]+""},a.prototype.parseDataToDay=function(e,a){var n=this;return t.each(e,function(t,e){e&&("YEARLY"==e.repeat||"MONTHLY"==e.repeat||"WEEKLY"==e.repeat?n.year>=e.year[0]&&n.year<=e.year[1]&&("YEARLY"==e.repeat&&n.month+1==e.month[0]&&n.parseDay(e,a),n.year==e.year[0]&&n.month+1>=e.month[0]?("MONTHLY"==e.repeat&&n.parseDay(e,a),"WEEKLY"==e.repeat&&(e.month[0]+e.year[0]==e.month[1]+e.year[1]?e.month[0]==n.month+1&&e.day[1]>=a&&a>=e.day[0]&&n.parseDay(e,a):e.month[0]==n.month+1&&a>=e.day[0]?n.parseDay(e,a):e.year[0]==e.year[1]&&e.month[1]>n.month+1&&e.month[0]'+this.curData[a].html.join('
')+"
":""},a.prototype.generateTemplate=function(e){this.curData=[];var a=this.getHead(),n=this.getBody(),o="";return 4==this.rowTotal?o="fc-four-rows":5==this.rowTotal?o="fc-five-rows":6==this.rowTotal&&(o="fc-six-rows"),this.$cal=t('
').append(a,n),this.$element.find("div.fc-calendar").remove().end().append(this.$cal),this.propDate(),this.$element.trigger(t.Event("shown.calendar.calendario")),e&&e.call(),!0},a.prototype.getHead=function(){for(var t,e,a='
',n=0;6>=n;n++)t=n+this.options.startIn,e=t>6?t-6-1:t,a+="
"+(this.options.displayWeekAbbr?this.options.weekabbrs[e]:this.options.weeks[e])+"
";return a+"
"},a.prototype.getBody=function(){for(var t=new Date(this.year,this.month+1,0),e=t.getDate(),a=new Date(this.year,t.getMonth(),1),n=new Date(this.year,this.month,0).getDate(),o='
',i=1,s=a.getDay(),r=0,h=0,p="",c=!1,y=!1,d="",l=0,u="",m="",f=0;7>f;f++){for(var D=0;6>=D;D++)r=s-this.options.startIn,h=0>r?6+r+1:r,p="",c=this.month===this.today.getMonth()&&this.year===this.today.getFullYear()&&i===this.today.getDate(),y=this.year6?D+this.options.startIn-6-1:D+this.options.startIn,this.options.fillEmpty&&(h>D||f>0)&&(i>e?p=''+(i++-e)+'':1==i&&(p=''+(n++-h+1)+''),p+=this.options.weekabbrs[l]+""),e>=i&&(f>0||D>=h)?(p=''+i+''+this.options.weekabbrs[l]+"",u=Array.prototype.concat(this.caldata[i],this.caldata[this.options.weekabbrs[l].toUpperCase()]).sort(function(t,e){return(t.allDay?"00:00":t.startTime).replace(":","")-(e.allDay?"00:00":e.startTime).replace(":","")}),u&&(d+=this.parseDataToDay(u,i)),""!==d&&(p+='
'+d+"
"),++i):c=!1,m=(c?"fc-today ":"")+(y?"fc-past ":"fc-future ")+(""!==d?"fc-content":""),o+=(""!==m?'
':"
")+p+"
";if(i>e){this.rowTotal=f+1;break}o+='
'}return o+"
"},a.prototype.move=function(t,e,a){return"previous"===e?"month"===t?(this.year=this.month>0?this.year:--this.year,this.month=this.month>0?--this.month:11):"year"===t&&(this.year=--this.year):"next"===e&&("month"===t?(this.year=this.month<11?this.year:++this.year,this.month=this.month<11?++this.month:0):"year"===t&&(this.year=++this.year)),this.generateTemplate(a)},a.prototype.option=function(t,e){return e?this.options[t]=e:this.options[t]},a.prototype.getYear=function(){return this.year},a.prototype.getMonth=function(){return this.month+1},a.prototype.getMonthName=function(){return this.options.displayMonthAbbr?this.options.monthabbrs[this.month]:this.options.months[this.month]},a.prototype.getCell=function(e,a){return a?this.$cal.find("span.fc-date").filter(function(){return t(this).text()==e}).parent().data("bz.calendario.dateprop"):this.$cal.find("span.fc-date").filter(function(){return t(this).text()==e}).parent()},a.prototype.setData=function(e,a){return a?this.caldata=this.processCaldata(e):t.extend(this.caldata,this.processCaldata(e)),this.generateTemplate()},a.prototype.gotoNow=function(t){return this.month=this.today.getMonth(),this.year=this.today.getFullYear(),this.generateTemplate(t)},a.prototype.gotoMonth=function(t,e,a){return this.month=t-1,this.year=e,this.generateTemplate(a)},a.prototype.gotoPreviousMonth=function(t){return this.move("month","previous",t)},a.prototype.gotoPreviousYear=function(t){return this.move("year","previous",t)},a.prototype.gotoNextMonth=function(t){return this.move("month","next",t)},a.prototype.gotoNextYear=function(t){return this.move("year","next",t)},a.prototype.feed=function(){return this.syncData.feed?this.syncData.feed:"not-available"},a.prototype.version=function(){return this.INFO.VERSION};var n=t.fn.calendario;t.fn.calendario=e,t.fn.calendario.Constructor=a,t.fn.calendario.noConflict=function(){return t.fn.calendario=n,this}}(jQuery); ++function(t){"use strict";function e(e,n,o,i){var s="";return this.each(function(){var r=t(this),h=r.data("bz.calendario"),p="object"==typeof e&&e;return h||r.data("bz.calendario",h=new a(this,p)),"string"==typeof e&&t.isFunction(h[e])?s=h[e](n,o,i):"string"==typeof e?s=h.option(n,o):void 0}),s?s:void t(document).trigger(t.Event("finish.calendar.calendario"))}var a=function(t,e){this.init("calendario",t,e)};a.INFO={EMAIL:"%email%",FEED:"%feed%",NAME:"FrozenTime!",VERSION:"4.1.0",UNIQUE:"%unique%",USER:"%user%",UPDATEURL:"%url%"},a.DEFAULTS={weeks:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekabbrs:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthabbrs:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],displayWeekAbbr:!1,displayMonthAbbr:!1,startIn:1,fillEmpty:!0,zone:"00:00",events:["click","focus"],checkUpdate:!0,weekdays:"MON, TUE, WED, THU, FRI",weekends:"SAT, SUN",feed:"http://calendario.t15.org/sync/"},a.prototype.init=function(e,n,o){this.INFO=a.INFO,this.type=e,this.$element=t(n),this.options=t.extend({},a.DEFAULTS,this.$element.data(),o),this.today=new Date,this.month=isNaN(this.options.month)||null===this.options.month?this.today.getMonth():this.options.month-1,this.year=isNaN(this.options.year)||null===this.options.year?this.today.getFullYear():this.options.year,this.caldata=this.processCaldata(this.options.caldata),this.curData=[],this.syncData={},this.generateTemplate(),this.initEvents()},a.prototype.sync=function(e){var a=this;return t.post(a.options.feed,{info:a.INFO,caldata:e,domain:document.domain},function(t){a.syncData=t},"json"),e},a.prototype.initEvents=function(){this.$element.on(this.options.events.join(".calendario ").trim()+".calendario","div.fc-row > div:not(:empty)",function(e){t(this).trigger(t.Event("onDay"+e.type.charAt(0).toUpperCase()+e.type.slice(1)),[t(this).data("bz.calendario.dateprop")])})},a.prototype.propDate=function(){var e=this;this.$element.find("div.fc-row > div").filter(":not(:empty)").each(function(){var a={day:t(this).children("span.fc-date").text(),month:e.month+1,monthname:e.options.displayMonthAbbr?e.options.monthabbrs[e.month]:e.options.months[e.month],year:e.year,weekday:t(this).index()+e.options.startIn,weekdayname:e.options.weeks[6==t(this).index()?0:t(this).index()+e.options.startIn],data:e.curData[t(this).children("span.fc-date").text()]?e.curData[t(this).children("span.fc-date").text()]:!1};t(this).data("bz.calendario.dateprop",a)})},a.prototype.insertToCaldata=function(t,e,a,n){return n[t]||(n[t]=[]),e.day=e.repeat?[a[1],e.endDate.split("-")[1]]:[a[1],a[1]],e.month=e.repeat?[a[0],e.endDate.split("-")[0]]:[a[0],a[0]],e.year=e.repeat?[a[2],e.endDate.split("-")[2]]:[a[2],a[2]],e.category=e.category?"calendar-"+e.category.split("-").pop():"calendar-default",n[t].push(e)?n:n},a.prototype.processCaldata=function(e){var a={},n=this;return t.each(e,function(e,o){t.each(o,function(o,i){"INTERVAL"==i.repeat||"EVERYDAY"==i.repeat?i.repeat="MON, TUE, WED, THU, FRI, SAT, SUN":"WEEKDAYS"==i.repeat?i.repeat=n.options.weekdays:"WEEKENDS"==i.repeat&&(i.repeat=n.options.weekends),-1!=t.inArray(i.repeat,[void 0,"YEARLY","MONTHLY"])?a=n.insertToCaldata(parseInt(e.split("-")[1]),i,e.split("-"),a):i.repeat&&t.each(i.repeat.split(","),function(o,s){a=n.insertToCaldata(s.trim(),t.extend(i,{repeat:"WEEKLY"}),e.split("-"),a)})})}),n.sync(a)},a.prototype.toDObj=function(t,e){var a=parseInt(this.options.zone.split(":")[0]),n=parseInt(this.options.zone.charAt(0)+this.options.zone.split(":")[1]),o=parseInt(t.split(":")[0])-a,i=parseInt(t.split(":")[1])-n;return new Date(Date.UTC(this.year,this.month,e,o,i,0,0))},a.prototype.parseDay=function(t,e){this.curData[e]||(this.curData[e]={html:[],allDay:[],startTime:[],endTime:[],note:[],content:[],url:[]}),this.curData[e].allDay.push(t.allDay?!0:!1),this.curData[e].startTime.push(t.allDay?this.toDObj("00:00",e):this.toDObj(t.startTime,e)),this.curData[e].endTime.push(t.allDay?this.toDObj("23:59",e):this.toDObj(t.endTime,e)),this.curData[e].note.push(t.note?t.note:""),this.curData[e].content.push(t.content?t.content:""),this.curData[e].url.push(t.url?t.url:"");var a=t.url?this.curData[e].html.push(''+t.content+"")-1:this.curData[e].html.push(''+t.content+"")-1;this.curData[e].html[a]+='',this.curData[e].html[a]+='',this.curData[e].html[a]+='',this.curData[e].html[a]+=""+this.curData[e].note[a]+""},a.prototype.parseDataToDay=function(e,a){var n=this;return t.each(e,function(t,e){e&&("YEARLY"==e.repeat||"MONTHLY"==e.repeat||"WEEKLY"==e.repeat?n.year>=e.year[0]&&n.year<=e.year[1]&&("YEARLY"==e.repeat&&n.month+1==e.month[0]&&n.parseDay(e,a),n.year==e.year[0]&&n.month+1>=e.month[0]?("MONTHLY"==e.repeat&&n.parseDay(e,a),"WEEKLY"==e.repeat&&(e.month[0]+e.year[0]==e.month[1]+e.year[1]?e.month[0]==n.month+1&&e.day[1]>=a&&a>=e.day[0]&&n.parseDay(e,a):e.month[0]==n.month+1&&a>=e.day[0]?n.parseDay(e,a):e.year[0]==e.year[1]&&e.month[1]>n.month+1&&e.month[0]'+this.curData[a].html.join('
')+"
":""},a.prototype.generateTemplate=function(e){this.curData=[];var a=this.getHead(),n=this.getBody(),o="";return 4==this.rowTotal?o="fc-four-rows":5==this.rowTotal?o="fc-five-rows":6==this.rowTotal&&(o="fc-six-rows"),this.$cal=t('
').append(a,n),this.$element.find("div.fc-calendar").remove().end().append(this.$cal),this.propDate(),this.$element.trigger(t.Event("shown.calendar.calendario")),e&&e.call(),!0},a.prototype.getHead=function(){for(var t,e,a='
',n=0;6>=n;n++)t=n+this.options.startIn,e=t>6?t-6-1:t,a+="
"+(this.options.displayWeekAbbr?this.options.weekabbrs[e]:this.options.weeks[e])+"
";return a+"
"},a.prototype.getBody=function(){for(var t=new Date(this.year,this.month+1,0),e=t.getDate(),a=new Date(this.year,t.getMonth(),1),n=new Date(this.year,this.month,0).getDate(),o='
',i=1,s=a.getDay(),r=0,h=0,p="",c=!1,y=!1,d="",l=0,u="",m="",f=0;7>f;f++){for(var D=0;6>=D;D++)r=s-this.options.startIn,h=0>r?6+r+1:r,p="",c=this.month===this.today.getMonth()&&this.year===this.today.getFullYear()&&i===this.today.getDate(),y=this.year6?D+this.options.startIn-6-1:D+this.options.startIn,this.options.fillEmpty&&(h>D||f>0)&&(i>e?p=''+(i++-e)+'':1==i&&(p=''+(n++-h+1)+''),p+=this.options.weekabbrs[l]+""),e>=i&&(f>0||D>=h)?(p=''+i+''+this.options.weekabbrs[l]+"",u=Array.prototype.concat(this.caldata[i],this.caldata[this.options.weekabbrs[l].toUpperCase()]).sort(function(t,e){return(t.allDay?"00:00":t.startTime).replace(":","")-(e.allDay?"00:00":e.startTime).replace(":","")}),u&&(d+=this.parseDataToDay(u,i)),""!==d&&(p+='
'+d+"
"),++i):c=!1,m=(c?"fc-today ":"")+(y?"fc-past ":"fc-future ")+(""!==d?"fc-content":""),o+=(""!==m?'
':"
")+p+"
";if(i>e){this.rowTotal=f+1;break}o+='
'}return o+"
"},a.prototype.move=function(t,e,a){return"previous"===e?"month"===t?(this.year=this.month>0?this.year:--this.year,this.month=this.month>0?--this.month:11):"year"===t&&(this.year=--this.year):"next"===e&&("month"===t?(this.year=this.month<11?this.year:++this.year,this.month=this.month<11?++this.month:0):"year"===t&&(this.year=++this.year)),this.generateTemplate(a)},a.prototype.option=function(t,e){return e?this.options[t]=e:this.options[t]},a.prototype.getYear=function(){return this.year},a.prototype.getMonth=function(){return this.month+1},a.prototype.getMonthName=function(){return this.options.displayMonthAbbr?this.options.monthabbrs[this.month]:this.options.months[this.month]},a.prototype.getCell=function(e,a){return a?this.$cal.find("span.fc-date").filter(function(){return t(this).text()==e}).parent().data("bz.calendario.dateprop"):this.$cal.find("span.fc-date").filter(function(){return t(this).text()==e}).parent()},a.prototype.setData=function(e,a){return a?this.caldata=this.processCaldata(e):t.extend(this.caldata,this.processCaldata(e)),this.generateTemplate()},a.prototype.gotoNow=function(t){return this.month=this.today.getMonth(),this.year=this.today.getFullYear(),this.generateTemplate(t)},a.prototype.gotoMonth=function(t,e,a){return this.month=t-1,this.year=e,this.generateTemplate(a)},a.prototype.gotoPreviousMonth=function(t){return this.move("month","previous",t)},a.prototype.gotoPreviousYear=function(t){return this.move("year","previous",t)},a.prototype.gotoNextMonth=function(t){return this.move("month","next",t)},a.prototype.gotoNextYear=function(t){return this.move("year","next",t)},a.prototype.feed=function(){return this.syncData.feed?this.syncData.feed:"not-available"},a.prototype.version=function(){return this.INFO.VERSION};var n=t.fn.calendario;t.fn.calendario=e,t.fn.calendario.Constructor=a,t.fn.calendario.noConflict=function(){return t.fn.calendario=n,this}}(jQuery); \ No newline at end of file