sajt u izradi..
English French German Italian Portuguese Russian Spanish
Calendar[JavaScript][Source File]
Created: Sunday, 18.August.2013. 13:34
/*
 * @copyright	Copyright (C) 2010 Branislav Kešelj . All rights reserved.
 * @license		GNU/GPLv2
*/


var XA_calendar = function (){
		var c_day = -1;
		var c_month = -1;
		var c_year = -1;
		var id = 'xa_calendar';
		var alpha = 0;
		var l_alpha = 0;
		var timer = 40;
		var fade = 0;
		var tooltip,xm,ym,i_box ;
		var o_format ='%d/%m/%y';
		var t_format ='%M/%y';
		var ie = document.all ? true : false; 
		var lang = 'en';	
		var month_num = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		var translation= new Array();
		translation['en']='January,February,March,April,May,June,July,August,September,October,November,December,Mo,Tu,We,Th,Fr,Sa,Su';
		translation['sr']='Januar,Februar,Mart,April,Maj,Jun,Juli,Avgust,Semptembar,Oktobar,Novembar,Decembar,Po,Ut,Sr,Ce,Pe,Su,Ne';
		translation['Next_language']='1_month,2_month,3_month,4_month,5_month,6_month,7_month,8_month,9_month,10_month,11_month,12_month,1_day,2_day,3_day,4_day,5_day,6_day,7_day';
		var error_msg= new Array();
		error_msg['en']='Language is not supported,Input box ID Error,Error while output in the input box';
		error_msg['sr']='Prevod nije podržan,Polje za unos ne postoji,Greška prilikom upisa u polje za unos';
		error_msg['next_language']='error_1,error_2,error_3';

		return {
				days:function()	
					{
					var p_month=0 ;				
					var e_day=0 ;	
					var p_e_day=0;
					var r_time=new Date() ;	
					var r_year=((r_time.getYear()-2000)>=0) ? r_time.getYear():r_time.getYear()+1900 ;
					if (c_month==-1 && c_year==-1)	
						{
						c_month=r_time.getMonth() ;	
						c_year=r_year ; 
						}
					var day=(c_month==r_time.getMonth() && c_year==r_year) ? r_time.getDate():0;
					var f_day=new Date(c_year,c_month,1) ; 
					var week_pos=(f_day.getDay()==0) ? 7:f_day.getDay() ;
					if (week_pos!=1) p_month=((c_month-1)>=0) ? c_month-1:11;
					if (c_month==1) e_day=((c_year%4)== 0) ? 1:0;					
					if (p_month==1) p_e_day=((c_year%4)==0) ? 1:0;	
					var count_day=((month_num[c_month]+e_day+week_pos)>35) ? 42:35;
					var create_day='<table>';
					var style='';
					for(var i=1;i<=count_day;i++)	
						{
						if (i%7==1) create_day +='<tr>';	
						if (i<week_pos) create_day +='<td class="previous_month_day" >'+(month_num[p_month]+p_e_day-week_pos+i+1)+'</td>';
						else if (week_pos<=i && i<(month_num[c_month]+e_day+week_pos))
							{
							style=((i-week_pos+1)==day) ? 'current_day':(((i%7)==6) ? 'saturday':(((i%7)==0) ? 'sunday':'day'));
							create_day +='<td id="'+style+'_'+i+'" class="current_month_'+style+'" onmouseover="XA_calendar.on_over(\''+style+'\','+i+');" onmouseout="XA_calendar.on_out(\''+style+'\','+i+');"  onclick="XA_calendar.output('+(i-week_pos+1)+');">'+(i-week_pos+1)+'</td>';			
							}	
							else create_day +='<td class="next_month_day" >'+(i-(month_num[c_month]+e_day+week_pos-1))+'</td>';
						if (i%7==0) create_day +='</tr>';
						}
					create_day +='</table>';
					return create_day ;
					},

				body:function() 
					{
					c_month=-1;
					c_year=-1;
					var day_row=this.days();
					var week_name=this.week_name();
					var week_row='';	
					for(var i=0;i<7;i++)
						{
						week_row +='<td class="week_row" >'+week_name[i]+'</td>';
						}
					var body ='';
					body +='<table>';
					body +=' <tr>';
					body +='  <td id="month_year_row" colspan="6" class="month_year">'+this.w_format(t_format)+'</td>';
					body +='  <td><span class="close" onclick="XA_calendar.close();">X</span></td>';
					body +=' </tr>';
					body +=' <tr>';
					body +='  <td><span class="next_year" onclick="XA_calendar.next_pre(0,-1)" />&lt;&lt</span></td>';
					body +='  <td><span class="next_month" onclick="XA_calendar.next_pre(-1,0)" />&lt;</span></td>';
					body +='  <td></td>';
					body +='  <td></td>';	
					body +='  <td></td>';	
					body +='  <td><span class="pre_month" onclick="XA_calendar.next_pre(1,0)" />&gt;</span></td>';
					body +='  <td><span class="pre_year" onclick="XA_calendar.next_pre(0,1)" />&gt;&gt;</span></td>';				
					body +=' </tr>';
					body +=' <tr>';
					body += week_row;
					body +=' </tr>';
					body +='</table>';
					body +='<div id="day_row">';
					body += day_row;
					body +='</div>';
					body +='';
					return body;
					},
				
				on_over : function(style,id)	{ document.getElementById(style+"_"+id).className = "day_hover";},
						
				on_out : function(style,id)		{ document.getElementById(style+"_"+id).className = "current_month_"+style;},

				output : function(x)
					{
					c_day=x;
					this.w_input_box(i_box);									
					this.close();
					},

				next_pre:function(x,y)
					{
					if (x!=0)
						{	
						c_month +=x ;					
						if (c_month>11)
							{
							c_month=0 ;
							c_year++;
							}
							else if (c_month<0)
									{
									c_month=11;
									c_year--;							
									}
						}
						else c_year +=y;	
					document.getElementById('month_year_row').innerHTML=this.w_format(t_format);	
					document.getElementById('day_row').innerHTML=this.days();	
					},

				week_name:function(x)
					{
					var a=translation[lang].split(',');
					a=a.slice(12,19);
					return (x==null) ? a:a[x];
					},
					
				month_name:function(x)
					{
					var a=translation[lang].split(',');	
					a=a.slice(0,12);						
					return (x==null) ? a:a[x];	
					},
					
				set_lang:function(x)
					{
					var a=translation[x];	
					if (a==null) alert('\''+x+'\' '+this.get_error_msg(0));
						else lang=x;
					},	
				get_error_msg:function(x)
					{
					var a=error_msg[lang].split(',');
					return a[x];					
					},
				c_input_box:function(x)
					{
					if (x==null || document.getElementById(x)==null)
						{
						alert(this.get_error_msg(1));
						return false;
						}			
					return true ;  
					},
					
				w_input_box:function(x)
					{
					if (this.c_input_box(x))
						{
						document.getElementById(x).value=this.w_format(o_format);		
						return;
						}						
					alert(this.get_error_msg(2));													
					},
					
				w_format:function(v)
					{
					var x=v;
					x=x.replace('%d',c_day);
					x=x.replace('%m',(c_month+1));
					x=x.replace('%M',this.month_name(c_month));
					x=x.replace('%y',c_year);		
					return x;		
					},
							
				show:function(i,ln,of,tf,xy,f)
					{
					if (i_box!=null && i_box!=i)
						{
						l_alpha=0;
                        alpha=0;
						tooltip.style.opacity=l_alpha*.01;
					    tooltip.style.filter='alpha(opacity='+l_alpha+')';
                        tooltip.style.display='none';
						}
					if (this.c_input_box(i)) i_box = i; 
					else return; 									
					if (ln!=null) this.set_lang(ln);
					o_format=(of==null) ? o_format:of;
					t_format=(tf==null) ? t_format:tf;	
					
					if (tooltip == null)
						{
						tooltip=document.createElement('div');
						tooltip.setAttribute('id',id);
						document.body.appendChild(tooltip);
						tooltip.style.opacity=0;
						tooltip.style.filter='alpha(opacity=0)';
						}					
					tooltip.style.display='block';
					tooltip.innerHTML=this.body();
					this.pos(xy);
					tooltip.style.width='auto';
					clearInterval(tooltip.timer);		
					tooltip.timer=setInterval(function(){XA_calendar.fade(f);},timer);
					},
					
				mpos:function(e)
					{
					ym=(ie ? event.clientY+document.documentElement.scrollTop:e.pageY);
					xm=(ie ? event.clientX+document.documentElement.scrollLeft:e.pageX);		
					},
					
				pos:function(v)
					{
					var xt=1;
					var yt=-1;					
					if	(v!=null)
						{
						v=v.split(',');	
						xt=v[0]*1;						
						yt=v[1]*1;															
						}						
					var x=(xt>=0 ? xm+xt:xm+xt-tooltip.offsetWidth);		
					var y=(yt>=0 ? ym-yt-tooltip.offsetHeight:ym-yt);			
					tooltip.style.top=y+'px';
					tooltip.style.left=x+'px';	
					},
					
				fade:function(d)
					{
					var speed=15;
					var e_alpha=100;	
					d=(d==null) ? 0:(d==0 || d==1) ? d:0  ; 	
					speed=(d==0) ? e_alpha:speed;	
					speed=(l_alpha==0) ? speed:speed*-1;			
					alpha=((alpha + speed)>e_alpha) ? e_alpha:((alpha+speed<0)) ? 0:alpha+speed;					
					tooltip.style.opacity=alpha*.01;
					tooltip.style.filter='alpha(opacity='+alpha+')';	
					if (alpha==0 || alpha==e_alpha)
						{
						clearInterval(tooltip.timer);								
						if (l_alpha==1) 
							{
							tooltip.style.display='none';
							l_alpha=0;
							}
							else l_alpha=1;							
						fade=d;	
						}					
					},
					
				close:function()
					{				
					clearInterval(tooltip.timer);
					tooltip.timer = setInterval(function(){XA_calendar.fade(fade);},timer);
					i_box=null;
					}											
		};
	}();
	document.onmousemove=XA_calendar.mpos ;

 

Post a comment
0
Comments | Add yours
  • No comments found
Free visitor tracking, live stats, counter, conversions for Joomla, Wordpress, Drupal, Magento and Prestashop