From 803a9f62c7639b7504e737d37eb12d7f7ac912f5 Mon Sep 17 00:00:00 2001 From: Ismail Akbudak Date: Sun, 2 Nov 2014 14:37:11 +0200 Subject: [PATCH] add new event date type --- README.md | 3 +++ example/index.html | 24 ++++++++++++++++++++++++ js/bic_calendar.js | 9 +++++++++ js/bic_calendar.min.js | 4 ++-- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0931718..63284d0 100755 --- a/README.md +++ b/README.md @@ -63,6 +63,9 @@ Event object - date(string): - "17/8/1989" + - "09/09/2014" + - "09/9/2014" + - "09/12/2014" - title (string) - "Event Barberà" - link (string) diff --git a/example/index.html b/example/index.html index 7442ec0..9dfb3a6 100644 --- a/example/index.html +++ b/example/index.html @@ -81,6 +81,30 @@ displayMonthController: true, displayYearController: true, nMonths: 6 + }, + { + date: "02/11/2014", + title: 'SPORT & WELLNESS', + link: 'http://bic.cat', + linkTarget: '_blank', + color: '', + content: '
06-11-2013 - 09:00
Tecnocampus Mataró Auditori', + class: '', + displayMonthController: true, + displayYearController: true, + nMonths: 6 + }, + { + date: "02/09/2014", + title: 'SPORT & WELLNESS', + link: 'http://bic.cat', + linkTarget: '_blank', + color: '', + content: '
06-11-2013 - 09:00
Tecnocampus Mataró Auditori', + class: '', + displayMonthController: true, + displayYearController: true, + nMonths: 6 } ]; diff --git a/js/bic_calendar.js b/js/bic_calendar.js index 8fd0543..ad43a25 100755 --- a/js/bic_calendar.js +++ b/js/bic_calendar.js @@ -28,6 +28,15 @@ $.fn.bic_calendar = function(options) { var calendarId = "bic_calendar"; var events = opts.events; + + // change dates 02/11/2014 to 2/11/2014 + $.each(events, function(k, v) { + var array = v.date.split('/'); + var d = parseInt(array[0]); + var m = parseInt(array[1]); + v = d + '/' + m +'/'+ array[2]; + events[k].date = v; + }); //Date obj to calc the day var objFecha; diff --git a/js/bic_calendar.min.js b/js/bic_calendar.min.js index 5946536..6aee54c 100644 --- a/js/bic_calendar.min.js +++ b/js/bic_calendar.min.js @@ -5,5 +5,5 @@ * * Made by bichotll * Under Apache License - */ -$.fn.bic_calendar=function(a){var b=$.extend({},$.fn.bic_calendar.defaults,a);return this.each(function(){function a(){n=$(''),d();var a=o.getMonth(),b=o.getFullYear();e(a,b);var f=$('');f.click(function(d){d.preventDefault(),a=(a+1)%12,0==a&&b++,c(a,b)});var g=$('');g.click(function(d){d.preventDefault(),a-=1,-1==a&&(b--,a=11),c(a,b)});var h=$('');h.click(function(d){d.preventDefault(),b++,c(a,b)});var j=$('');j.click(function(d){d.preventDefault(),b--,c(a,b)});var l=$('
');if(E===!0){var t=$(""),u=$('');t.append(j),t.append(u),t.append(h),u.append(r),l.append(t)}if(D===!0){var v=$(""),w=$('');v.append(g),v.append(w),v.append(f),w.append(q),l.append(v)}m=$('
'),m.prepend(l),m.append(n),p.append(m),i(a,b),k()}function c(a,b){n.empty(),d(),e(a,b),i(a,b),l()}function d(){if(0!=x){var a=$(''),b="";$(v).each(function(a,c){b+=""}),b+="",a.append(b),n.append(a)}}function e(a,b){q.text(w[a]),r.text(b);for(var c=1,d=f(1,a,b),e=h(a,b),g=a+1,i="",j=0;7>j;j++){if(d>j){var k="";0==j&&(k+=""),k+='"),k+='",6==j&&(k+=""),c++}i+=k}for(var l=1;e>=c;){var k="";l%7==1&&(k+=""),k+='",l%7==0&&(k+=""),c++,l++,i+=k}if(l--,l%7!=0){k="";for(var j=l%7+1;7>=j;j++){var k="";k+=""),i+=k}}n.append(i)}function f(a,b,c){var d=new Date(c,b,a),e=d.getDay();return e+=F,0==e?e=6:e--,e}function g(a,b,c){return a>0&&13>a&&c>0&&32768>c&&b>0&&b<=new Date(c,a,0).getDate()}function h(a,b){for(var c=28;g(a+1,c+1,b);)c++;return c}function i(a,b){0!=A?$.ajax({type:A.type,url:A.url,data:{mes:a+1,ano:b},dataType:"json"}).done(function(c){"undefined"==typeof t&&(t=[]),$.each(c,function(a){t.push(c[a])}),j(a,b)}):j(a,b)}function j(a,b){for(var c=a+1,d=0;dc){var d=b;b=c,c=d}for($("#bic_calendar_"+b.getDate()+"_"+(parseInt(b.getMonth())+1)+"_"+b.getFullYear()+" div").addClass("selection first-selection");c>b;)b.setDate(b.getDate()+1),$("#bic_calendar_"+b.getDate()+"_"+(parseInt(b.getMonth())+1)+"_"+b.getFullYear()+" div").addClass("selection middle-selection");$("#bic_calendar_"+b.getDate()+"_"+(parseInt(b.getMonth())+1)+"_"+b.getFullYear()+" div").removeClass("middle-selection").addClass("selection last-selection")}}var m,n,o,p=$(this),q=$('
'),r=$('
'),s="bic_calendar",t=b.events;if(b.date)if("string"==typeof b.date){var u=b.date.split("/");o=new Date(parseInt(u[2]),parseInt(u[1])-1,parseInt(u[0]))}else o=b.date;else o=new Date;var v;v="undefined"!=typeof b.dayNames?b.dayNames:["l","m","x","j","v","s","d"];var w;w="undefined"!=typeof b.monthNames?b.monthNames:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];var x;x="undefined"!=typeof b.showDays?b.showDays:!0;var y;y="undefined"!=typeof b.popoverOptions?b.popoverOptions:{placement:"bottom",html:!0,trigger:"hover"};var z;z="undefined"!=typeof b.tooltipOptions?b.tooltipOptions:{placement:"bottom",trigger:"hover"};var A;A="undefined"!=typeof b.reqAjax?b.reqAjax:!1;var B=!1;"undefined"!=typeof b.enableSelect&&(B=b.enableSelect);var C=!1;"undefined"!=typeof b.multiSelect&&(C=b.multiSelect);var D=!0;"undefined"!=typeof b.displayMonthController&&(D=b.displayMonthController);var E=!0;"undefined"!=typeof b.displayYearController&&(E=b.displayYearController);var F=0;"undefined"!=typeof b.startWeekDay&&(F=b.startWeekDay);var G="",H="",I="";a()}),this}; \ No newline at end of file + */ +$.fn.bic_calendar=function(w){var b=$.extend({},$.fn.bic_calendar.defaults,w);this.each(function(){function t(a,e){q.empty();z();A(a,e);B(a,e);x()}function z(){if(0!=C){var a=$(''),e="";$(D).each(function(a,d){e+=""});e+="";a.append(e);q.append(a)}}function A(a,e){E.text(F[a]);G.text(e);var b=1,d;d=(new Date(e,a,1)).getDay();d+=H;0==d?d=6:d--;var f;for(f=28;w(a+1,f+1,e);)f++;for(var h=a+ 1,l="",g=0;7>g;g++){if(g");c+='"),c+='",6==g&&(c+=""),b++;l+=c}for(d=1;b<=f;)c="",1==d%7&&(c+=""),c+='", 0==d%7&&(c+=""),b++,d++,l+=c;d--;if(0!=d%7)for(g=d%7+1;7>=g;g++)c="",c+=""),l+=c;q.append(l)}function w(a,e,b){return 0a&&0b&&0e)var b=a,a=e,e=b;for($("#bic_calendar_"+a.getDate()+"_"+(parseInt(a.getMonth())+1)+"_"+a.getFullYear()+" div").addClass("selection first-selection");a'),G=$('
'),f=b.events;$.each(f,function(a,e){var b=e.date.split("/"),d=parseInt(b[0]),k=parseInt(b[1]);e=d+"/"+k+"/"+b[2];f[a].date=e});var s;if(b.date)if("string"==typeof b.date){var y=b.date.split("/");s=new Date(parseInt(y[2]),parseInt(y[1])-1,parseInt(y[0]))}else s=b.date;else s=new Date;var D;D="undefined"!=typeof b.dayNames?b.dayNames:"lmxjvsd".split("");var F;F="undefined"!=typeof b.monthNames?b.monthNames: "Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre".split(" ");var C;C="undefined"!=typeof b.showDays?b.showDays:!0;var K;K="undefined"!=typeof b.popoverOptions?b.popoverOptions:{placement:"bottom",html:!0,trigger:"hover"};var J;J="undefined"!=typeof b.tooltipOptions?b.tooltipOptions:{placement:"bottom",trigger:"hover"};var u;u="undefined"!=typeof b.reqAjax?b.reqAjax:!1;var L=!1;"undefined"!=typeof b.enableSelect&&(L=b.enableSelect);var M=!1;"undefined"!=typeof b.multiSelect&& (M=b.multiSelect);var N=!0;"undefined"!=typeof b.displayMonthController&&(N=b.displayMonthController);var O=!0;"undefined"!=typeof b.displayYearController&&(O=b.displayYearController);var H=0;"undefined"!=typeof b.startWeekDay&&(H=b.startWeekDay);var m="",p="",n="";(function(){q=$('');z();var a=s.getMonth(),b=s.getFullYear();A(a,b);var f=$('');f.click(function(c){c.preventDefault(); a=(a+1)%12;0==a&&b++;t(a,b)});var d=$('');d.click(function(c){c.preventDefault();--a;-1==a&&(b--,a=11);t(a,b)});var k=$('');k.click(function(c){c.preventDefault();b++;t(a,b)});var h=$('');h.click(function(c){c.preventDefault(); b--;t(a,b)});var l=$('
');if(!0===O){var g=$(""),c=$('');g.append(h);g.append(c);g.append(k);c.append(G);l.append(g)}!0===N&&(k=$(""),h=$(''),k.append(d),k.append(h),k.append(f),h.append(E),l.append(k));v=$('
');v.prepend(l);v.append(q);r.append(v);B(a,b);P()})()});return this}; \ No newline at end of file