YAHOO.namespace("fitness.calendar"); YAHOO.fitness.calendar.init=function(){ YAHOO.fitness.calendar.oMenu=new YAHOO.widget.Menu("basicmenu",{hidedelay:2500,iframe:false,zindex:10000}); YAHOO.fitness.calendar.aMenuItems=new Array(); YAHOO.fitness.calendar.ajaxReq=''; YAHOO.fitness.calendar.response=new Array(); YAHOO.fitness.calendar.selMonth="07"; YAHOO.fitness.calendar.selYear="2021"; YAHOO.fitness.calendar.selDay="23"; YAHOO.fitness.calendar.menuGroup=0; YAHOO.fitness.calendar.cal1=new YAHOO.widget.CalendarGroup("cal1","calendar-container",{ LOCALE_WEEKDAYS:"1char", START_WEEKDAY: 1, MULTI_SELECT:false, PAGES:4 }); YAHOO.util.Connect.asyncRequest("GET","http://www.fitness.ee/ajax-calendar.php",{success:function(o){ YAHOO.fitness.calendar.response=eval('('+o.responseText+')'); /* menu begin */ for(var i in YAHOO.fitness.calendar.response.group){ YAHOO.fitness.calendar.aMenuItems[i]={text:YAHOO.fitness.calendar.response.group[i].est,url:"javascript:YAHOO.fitness.calendar.changeMenu('"+YAHOO.fitness.calendar.response.group[i].est+"','"+YAHOO.fitness.calendar.response.group[i].group_id+"');"}; } YAHOO.fitness.calendar.oMenu.addItems(YAHOO.fitness.calendar.aMenuItems); YAHOO.fitness.calendar.oMenu.render("rendertarget"); YAHOO.util.Event.addListener("menutoggle","mouseover",YAHOO.fitness.calendar.oMenu.show,null,YAHOO.fitness.calendar.oMenu); /*YAHOO.util.Event.addListener("menutoggle","mouseout",YAHOO.fitness.calendar.oMenu.hide,null,YAHOO.fitness.calendar.oMenu);*/ /* menu end */ //olemasolevad eventid //YAHOO.fitness.calendar.cal1.addRenderer("07/07/2011-07/10/2011", YAHOO.fitness.calendar.cal1.renderCellStyleHighlight1); //YAHOO.fitness.calendar.cal1.addRenderer("08/07/2011-08/10/2011", YAHOO.fitness.calendar.cal1.renderCellStyleHighlight1); //YAHOO.fitness.calendar.cal1.addRenderer("08/17/2011-08/20/2011", YAHOO.fitness.calendar.cal1.renderCellStyleHighlight3); // Correct formats for Estonia: dd.mm.yyyy, dd.mm, mm.yyyy YAHOO.fitness.calendar.cal1.cfg.setProperty("DATE_FIELD_DELIMITER","."); YAHOO.fitness.calendar.cal1.cfg.setProperty("MDY_DAY_POSITION",1); YAHOO.fitness.calendar.cal1.cfg.setProperty("MDY_MONTH_POSITION",2); YAHOO.fitness.calendar.cal1.cfg.setProperty("MDY_YEAR_POSITION",3); YAHOO.fitness.calendar.cal1.cfg.setProperty("MD_DAY_POSITION",1); YAHOO.fitness.calendar.cal1.cfg.setProperty("MD_MONTH_POSITION",2); // Date labels for Estonian locale YAHOO.fitness.calendar.cal1.cfg.setProperty("MONTHS_SHORT",["Jaan","Veeb","M\u00E4rts","Apr","Mai","Juun", "Juul", "Aug", "Sept", "Okt", "Nov", "Dets"]); YAHOO.fitness.calendar.cal1.cfg.setProperty("MONTHS_LONG", ["Jaanuar", "Veebruar", "M\u00E4rts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"]); YAHOO.fitness.calendar.cal1.cfg.setProperty("WEEKDAYS_1CHAR", ["P", "E", "T", "K", "N", "R", "L"]); YAHOO.fitness.calendar.cal1.cfg.setProperty("WEEKDAYS_SHORT", ["P\u00FC", "Es", "Te", "Ko", "Ne", "Re", "La"]); YAHOO.fitness.calendar.cal1.cfg.setProperty("WEEKDAYS_MEDIUM",["P\u00FCh", "Esm", "Tei", "Kol", "Nel", "Ree", "Lau"]); YAHOO.fitness.calendar.cal1.cfg.setProperty("WEEKDAYS_LONG", ["P\u00FChap\u00E4ev", "Esmasp\u00E4ev", "Teisip\u00E4ev", "Kolmap\u00E4ev", "Neljap\u00E4ev", "Reede", "Laup\u00E4ev"]); // Button texts for Estonian locale (accessibility feature, hidden with CSS) YAHOO.fitness.calendar.cal1.cfg.setProperty("STRINGS", { previousMonth : "Eelmine kuu", nextMonth : "J\u00E4rgmine kuu", close: "Sulge" }); /*//kuu muutus, pole midagi teha//YAHOO.fitness.calendar.cal1.changePageEvent.subscribe(YAHOO.fitness.calendar.monthSelect,YAHOO.fitness.calendar.cal1, true);*/ //päeva muutus, kuvame alates sellest eventid //YAHOO.fitness.calendar.cal1.beforeSelectEvent.subscribe(YAHOO.fitness.calendar.beforeDaySelect, YAHOO.fitness.calendar.cal1, true); YAHOO.fitness.calendar.cal1.selectEvent.subscribe(YAHOO.fitness.calendar.daySelect, YAHOO.fitness.calendar.cal1, true); //init enne renderdust YAHOO.fitness.calendar.cal1.beforeRenderEvent.subscribe(YAHOO.fitness.calendar.beforeSelect, YAHOO.fitness.calendar.cal1, true); YAHOO.fitness.calendar.cal1.render(); //inf kalendrisse YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); //YAHOO.fitness.calendar.changeMenu('Fitness','2'); if(YAHOO.fitness.cWord && YAHOO.fitness.cId){ //YAHOO.fitness.calendar.changeMenu(YAHOO.fitness.cWord,YAHOO.fitness.cId); /* YAHOO.fitness.calendar.menuGroup=YAHOO.fitness.cId; var menutoggleContainer=YAHOO.util.Dom.get("toggleTxt"); menutoggleContainer.innerHTML=YAHOO.fitness.cWord; YAHOO.fitness.calendar.oMenu.render("rendertarget"); YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); */ } },failure:function(o){alert(YAHOO.fitness.lc['ajaxError']);}}); }; //*** //*** //*** YAHOO.fitness.calendar.beforeDaySelect=function(actionName,selDay,container){}; //*** YAHOO.fitness.calendar.beforeSelect=function(actionName,selDay,container){ var sYear=parseInt(YAHOO.fitness.calendar.selYear); var sMonth=parseInt(YAHOO.fitness.calendar.selMonth); var sDay=parseInt(1); YAHOO.fitness.calendar.changeHeader(container,sYear,sMonth,sDay); }; //*** YAHOO.fitness.calendar.daySelect=function(actionName,selDay,container){ //var cald="7/7/2011"; //YAHOO.fitness.calendar.cal1.addRenderer(cald, YAHOO.fitness.calendar.cal1.renderCellStyleHighlight1); YAHOO.fitness.calendar.selMonth=parseInt(selDay[0][0][1]); YAHOO.fitness.calendar.selYear=parseInt(selDay[0][0][0]); YAHOO.fitness.calendar.selDay=parseInt(selDay[0][0][2]); YAHOO.fitness.calendar.changeHeader(container,YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); }; //*** YAHOO.fitness.calendar.prevYear=function(){ YAHOO.fitness.calendar.selYear=parseInt(YAHOO.fitness.calendar.selYear)-1; YAHOO.fitness.calendar.selMonth=parseInt(YAHOO.fitness.calendar.selMonth); YAHOO.fitness.calendar.selDay=parseInt(YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.cal1.setYear(YAHOO.fitness.calendar.selYear); YAHOO.fitness.calendar.cal1.setMonth(YAHOO.fitness.calendar.selMonth-1); //YAHOO.fitness.calendar.cal1.select(""+YAHOO.fitness.calendar.selDay+"."+YAHOO.fitness.calendar.selMonth+"."+YAHOO.fitness.calendar.selYear+""); YAHOO.fitness.calendar.cal1.render(); YAHOO.fitness.calendar.changeHeader(YAHOO.fitness.calendar.cal1,YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); }; //*** YAHOO.fitness.calendar.nextYear=function(){ YAHOO.fitness.calendar.selYear=parseInt(YAHOO.fitness.calendar.selYear)+1; YAHOO.fitness.calendar.selMonth=parseInt(YAHOO.fitness.calendar.selMonth); YAHOO.fitness.calendar.selDay=parseInt(YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.cal1.setYear(YAHOO.fitness.calendar.selYear); YAHOO.fitness.calendar.cal1.setMonth(YAHOO.fitness.calendar.selMonth-1); //YAHOO.fitness.calendar.cal1.select(""+YAHOO.fitness.calendar.selDay+"."+YAHOO.fitness.calendar.selMonth+"."+YAHOO.fitness.calendar.selYear+""); YAHOO.fitness.calendar.cal1.render(); YAHOO.fitness.calendar.changeHeader(YAHOO.fitness.calendar.cal1,YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); }; //*** YAHOO.fitness.calendar.prevMonth=function(){ YAHOO.fitness.calendar.selYear=parseInt(YAHOO.fitness.calendar.selYear); YAHOO.fitness.calendar.selMonth=parseInt(YAHOO.fitness.calendar.selMonth)-1; if(YAHOO.fitness.calendar.selMonth==0){ YAHOO.fitness.calendar.selYear=parseInt(YAHOO.fitness.calendar.selYear)-1; YAHOO.fitness.calendar.selMonth=12; } YAHOO.fitness.calendar.selDay=parseInt(YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.selDay=1; YAHOO.fitness.calendar.cal1.setYear(YAHOO.fitness.calendar.selYear); YAHOO.fitness.calendar.cal1.setMonth(YAHOO.fitness.calendar.selMonth-1); //YAHOO.fitness.calendar.cal1.select(""+YAHOO.fitness.calendar.selDay+"."+YAHOO.fitness.calendar.selMonth+"."+YAHOO.fitness.calendar.selYear+""); YAHOO.fitness.calendar.cal1.render(); YAHOO.fitness.calendar.changeHeader(YAHOO.fitness.calendar.cal1,YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); }; //*** YAHOO.fitness.calendar.nextMonth=function(){ YAHOO.fitness.calendar.selYear=parseInt(YAHOO.fitness.calendar.selYear); YAHOO.fitness.calendar.selMonth=parseInt(YAHOO.fitness.calendar.selMonth)+1; if(YAHOO.fitness.calendar.selMonth==13){ YAHOO.fitness.calendar.selYear=parseInt(YAHOO.fitness.calendar.selYear)+1; YAHOO.fitness.calendar.selMonth=1; } YAHOO.fitness.calendar.selDay=parseInt(YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.cal1.setYear(YAHOO.fitness.calendar.selYear); YAHOO.fitness.calendar.cal1.setMonth(YAHOO.fitness.calendar.selMonth-1); //YAHOO.fitness.calendar.cal1.select(""+YAHOO.fitness.calendar.selDay+"."+YAHOO.fitness.calendar.selMonth+"."+YAHOO.fitness.calendar.selYear+""); YAHOO.fitness.calendar.cal1.render(); YAHOO.fitness.calendar.changeHeader(YAHOO.fitness.calendar.cal1,YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); }; //*** //*** //*** YAHOO.fitness.calendar.changeHeader=function(container,y,m,d){ //muudan tekste päises var prevM=m-1; if(prevM==0){prevM=12;} var nextM=m+1;if(nextM==13){nextM=1;} var selMonthTxt=container.cfg.config.months_long.value[(m-1)]; var nextMonthTxt=container.cfg.config.months_long.value[(nextM-1)]; var prevMonthTxt=container.cfg.config.months_long.value[(prevM-1)]; var currMonthContainer=YAHOO.util.Dom.get("currMonth");currMonthContainer.innerHTML=selMonthTxt; var prevMonthContainer=YAHOO.util.Dom.get("prevMonth");prevMonthContainer.innerHTML=prevMonthTxt; var nextMonthContainer=YAHOO.util.Dom.get("nextMonth");nextMonthContainer.innerHTML=nextMonthTxt; var prevYearContainer=YAHOO.util.Dom.get("prevYear");prevYearContainer.innerHTML=y-1; var nextYearContainer=YAHOO.util.Dom.get("nextYear");nextYearContainer.innerHTML=y+1; }; //*** YAHOO.fitness.calendar.content=function(y,m,d){ var eventsContainer=YAHOO.util.Dom.get("events"); eventsContainer.innerHTML='loading'; var post='y='+y+'&m='+m+'&d='+d+'&g='+YAHOO.fitness.calendar.menuGroup; YAHOO.util.Connect.abort(YAHOO.fitness.calendar.ajaxReq); YAHOO.fitness.calendar.ajaxReq=YAHOO.util.Connect.asyncRequest("POST","http://www.fitness.ee/ajax-calendar.php",{ success:function(o){ YAHOO.fitness.calendar.response=eval('(' + o.responseText + ')'); YAHOO.fitness.calendar.manageTable(YAHOO.fitness.calendar.response.events); YAHOO.fitness.calendar.manageEvents(YAHOO.fitness.calendar.response.events); }, failure:function(o){alert(YAHOO.fitness.lc['ajaxError']);} },post); }; //*** YAHOO.fitness.calendar.manageTable=function(a){ var tblResponse=''; var eventsContainer=YAHOO.util.Dom.get("events"); eventsContainer.innerHTML=tblResponse; } //*** YAHOO.fitness.calendar.manageEvents=function(a){ YAHOO.fitness.calendar.cal1.deselectAll(); var k=0; for(var i in a){ for(var j=0; j<=a[i].event_duration;j++){ var d=new Date(a[i].event_datebegin); d.setDate(d.getDate()+j); var yr=d.getFullYear(); var mt=d.getMonth()+1; if(mt<10){mt='0'+mt;} var dy=d.getDate(); if(dy<10){dy='0'+dy;} if(!YAHOO.fitness.calendar.cal1.cfg.config.selected.value[k]){ YAHOO.fitness.calendar.cal1.cfg.config.selected.value[k]=new Array(); } YAHOO.fitness.calendar.cal1.cfg.config.selected.value[k][0]=yr; YAHOO.fitness.calendar.cal1.cfg.config.selected.value[k][1]=mt; YAHOO.fitness.calendar.cal1.cfg.config.selected.value[k][2]=dy; k++; } } YAHOO.fitness.calendar.cal1.render(); } //*** YAHOO.fitness.calendar.changeMenu=function(txt,id){ YAHOO.fitness.calendar.menuGroup=id; var menutoggleContainer=YAHOO.util.Dom.get("toggleTxt"); menutoggleContainer.innerHTML=txt; //YAHOO.fitness.calendar.oMenu.addItems(YAHOO.fitness.calendar.aMenuItems); YAHOO.fitness.calendar.oMenu.render("rendertarget"); YAHOO.fitness.calendar.content(YAHOO.fitness.calendar.selYear,YAHOO.fitness.calendar.selMonth,YAHOO.fitness.calendar.selDay); }; //YAHOO.util.Event.onDOMReady(YAHOO.fitness.calendar.init);