[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 // =================================================================== 2 // Author: Matt Kruse <matt@mattkruse.com> 3 // WWW: http://www.mattkruse.com/ 4 // 5 // NOTICE: You may use this code for any purpose, commercial or 6 // private, without any further permission from the author. You may 7 // remove this notice from your final code if you wish, however it is 8 // appreciated by the author if at least my web site address is kept. 9 // 10 // You may *NOT* re-distribute this code in any way except through its 11 // use. That means, you can include it in your product, or your web 12 // site, or any other form where the code is actually being used. You 13 // may not put the plain javascript up on your site for download or 14 // include it in your javascript libraries for download. 15 // If you wish to share this code with others, please just point them 16 // to the URL instead. 17 // Please DO NOT link directly to my .js files from your site. Copy 18 // the files to your server and use them there. Thank you. 19 // =================================================================== 20 21 // HISTORY 22 // ------------------------------------------------------------------ 23 // Sep 26, 2006: If MONTH_NAMES is already defined, use it. 24 // (blueyed) 25 // March 29, 2004: Added check in select() method for the form field 26 // being disabled. If it is, just return and don't do anything. 27 // March 24, 2004: Fixed bug - when month name and abbreviations were 28 // changed, date format still used original values. 29 // January 26, 2004: Added support for drop-down month and year 30 // navigation (Thanks to Chris Reid for the idea) 31 // September 22, 2003: Fixed a minor problem in YEAR calendar with 32 // CSS prefix. 33 // August 19, 2003: Renamed the function to get styles, and made it 34 // work correctly without an object reference 35 // August 18, 2003: Changed showYearNavigation and 36 // showYearNavigationInput to optionally take an argument of 37 // true or false 38 // July 31, 2003: Added text input option for year navigation. 39 // Added a per-calendar CSS prefix option to optionally use 40 // different styles for different calendars. 41 // July 29, 2003: Fixed bug causing the Today link to be clickable 42 // even though today falls in a disabled date range. 43 // Changed formatting to use pure CSS, allowing greater control 44 // over look-and-feel options. 45 // June 11, 2003: Fixed bug causing the Today link to be unselectable 46 // under certain cases when some days of week are disabled 47 // March 14, 2003: Added ability to disable individual dates or date 48 // ranges, display as light gray and strike-through 49 // March 14, 2003: Removed dependency on graypixel.gif and instead 50 /// use table border coloring 51 // March 12, 2003: Modified showCalendar() function to allow optional 52 // start-date parameter 53 // March 11, 2003: Modified select() function to allow optional 54 // start-date parameter 55 /* 56 DESCRIPTION: This object implements a popup calendar to allow the user to 57 select a date, month, quarter, or year. 58 59 COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small 60 positioning errors - usually with Window positioning - occur on the 61 Macintosh platform. 62 The calendar can be modified to work for any location in the world by 63 changing which weekday is displayed as the first column, changing the month 64 names, and changing the column headers for each day. 65 66 USAGE: 67 // Create a new CalendarPopup object of type WINDOW 68 var cal = new CalendarPopup(); 69 70 // Create a new CalendarPopup object of type DIV using the DIV named 'mydiv' 71 var cal = new CalendarPopup('mydiv'); 72 73 // Easy method to link the popup calendar with an input box. 74 cal.select(inputObject, anchorname, dateFormat); 75 // Same method, but passing a default date other than the field's current value 76 cal.select(inputObject, anchorname, dateFormat, '01/02/2000'); 77 // This is an example call to the popup calendar from a link to populate an 78 // input box. Note that to use this, date.js must also be included!! 79 <A HREF="#" onclick="cal.select(document.forms[0].date,'anchorname','MM/dd/yyyy'); return false;">Select</A> 80 81 // Set the type of date select to be used. By default it is 'date'. 82 cal.setDisplayType(type); 83 84 // When a date, month, quarter, or year is clicked, a function is called and 85 // passed the details. You must write this function, and tell the calendar 86 // popup what the function name is. 87 // Function to be called for 'date' select receives y, m, d 88 cal.setReturnFunction(functionname); 89 // Function to be called for 'month' select receives y, m 90 cal.setReturnMonthFunction(functionname); 91 // Function to be called for 'quarter' select receives y, q 92 cal.setReturnQuarterFunction(functionname); 93 // Function to be called for 'year' select receives y 94 cal.setReturnYearFunction(functionname); 95 96 // Show the calendar relative to a given anchor 97 cal.showCalendar(anchorname); 98 99 // Hide the calendar. The calendar is set to autoHide automatically 100 cal.hideCalendar(); 101 102 // Set the month names to be used. Default are English month names 103 cal.setMonthNames("January","February","March",...); 104 105 // Set the month abbreviations to be used. Default are English month abbreviations 106 cal.setMonthAbbreviations("Jan","Feb","Mar",...); 107 108 // Show navigation for changing by the year, not just one month at a time 109 cal.showYearNavigation(); 110 111 // Show month and year dropdowns, for quicker selection of month of dates 112 cal.showNavigationDropdowns(); 113 114 // Set the text to be used above each day column. The days start with 115 // sunday regardless of the value of WeekStartDay 116 cal.setDayHeaders("S","M","T",...); 117 118 // Set the day for the first column in the calendar grid. By default this 119 // is Sunday (0) but it may be changed to fit the conventions of other 120 // countries. 121 cal.setWeekStartDay(1); // week is Monday - Saturday 122 123 // Set the weekdays which should be disabled in the 'date' select popup. You can 124 // then allow someone to only select week end dates, or Tuedays, for example 125 cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week 126 127 // Selectively disable individual days or date ranges. Disabled days will not 128 // be clickable, and show as strike-through text on current browsers. 129 // Date format is any format recognized by parseDate() in date.js 130 // Pass a single date to disable: 131 cal.addDisabledDates("2003-01-01"); 132 // Pass null as the first parameter to mean "anything up to and including" the 133 // passed date: 134 cal.addDisabledDates(null, "01/02/03"); 135 // Pass null as the second parameter to mean "including the passed date and 136 // anything after it: 137 cal.addDisabledDates("Jan 01, 2003", null); 138 // Pass two dates to disable all dates inbetween and including the two 139 cal.addDisabledDates("January 01, 2003", "Dec 31, 2003"); 140 141 // When the 'year' select is displayed, set the number of years back from the 142 // current year to start listing years. Default is 2. 143 // This is also used for year drop-down, to decide how many years +/- to display 144 cal.setYearSelectStartOffset(2); 145 146 // Text for the word "Today" appearing on the calendar 147 cal.setTodayText("Today"); 148 149 // The calendar uses CSS classes for formatting. If you want your calendar to 150 // have unique styles, you can set the prefix that will be added to all the 151 // classes in the output. 152 // For example, normal output may have this: 153 // <SPAN CLASS="cpTodayTextDisabled">Today<SPAN> 154 // But if you set the prefix like this: 155 cal.setCssPrefix("Test"); 156 // The output will then look like: 157 // <SPAN CLASS="TestcpTodayTextDisabled">Today<SPAN> 158 // And you can define that style somewhere in your page. 159 160 // When using Year navigation, you can make the year be an input box, so 161 // the user can manually change it and jump to any year 162 cal.showYearNavigationInput(); 163 164 // Set the calendar offset to be different than the default. By default it 165 // will appear just below and to the right of the anchorname. So if you have 166 // a text box where the date will go and and anchor immediately after the 167 // text box, the calendar will display immediately under the text box. 168 cal.offsetX = 20; 169 cal.offsetY = 20; 170 171 NOTES: 172 1) Requires the functions in AnchorPosition.js and PopupWindow.js 173 174 2) Your anchor tag MUST contain both NAME and ID attributes which are the 175 same. For example: 176 <A NAME="test" ID="test"> </A> 177 178 3) There must be at least a space between <A> </A> for IE5.5 to see the 179 anchor tag correctly. Do not do <A></A> with no space. 180 181 4) When a CalendarPopup object is created, a handler for 'onmouseup' is 182 attached to any event handler you may have already defined. Do NOT define 183 an event handler for 'onmouseup' after you define a CalendarPopup object 184 or the autoHide() will not work correctly. 185 186 5) The calendar popup display uses style sheets to make it look nice. 187 188 */ 189 190 // CONSTRUCTOR for the CalendarPopup Object 191 function CalendarPopup() { 192 var c; 193 if (arguments.length>0) { 194 c = new PopupWindow(arguments[0]); 195 } 196 else { 197 c = new PopupWindow(); 198 c.setSize(150,175); 199 } 200 c.offsetX = -152; 201 c.offsetY = 25; 202 c.autoHide(); 203 // Calendar-specific properties 204 if( typeof MONTH_NAMES != "undefined" && MONTH_NAMES.slice ) 205 { 206 c.monthNames = MONTH_NAMES.slice(0, 12); 207 c.monthAbbreviations = MONTH_NAMES.slice(12, 24); 208 } 209 else 210 { 211 c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); 212 c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); 213 } 214 c.dayHeaders = new Array("S","M","T","W","T","F","S"); 215 c.returnFunction = "CP_tmpReturnFunction"; 216 c.returnMonthFunction = "CP_tmpReturnMonthFunction"; 217 c.returnQuarterFunction = "CP_tmpReturnQuarterFunction"; 218 c.returnYearFunction = "CP_tmpReturnYearFunction"; 219 c.weekStartDay = 0; 220 c.isShowYearNavigation = false; 221 c.displayType = "date"; 222 c.disabledWeekDays = new Object(); 223 c.disabledDatesExpression = ""; 224 c.yearSelectStartOffset = 2; 225 c.currentDate = null; 226 c.todayText="Today"; 227 c.cssPrefix=""; 228 c.isShowNavigationDropdowns=false; 229 c.isShowYearNavigationInput=false; 230 window.CP_calendarObject = null; 231 window.CP_targetInput = null; 232 window.CP_dateFormat = "MM/dd/yyyy"; 233 // Method mappings 234 c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow; 235 c.setReturnFunction = CP_setReturnFunction; 236 c.setReturnMonthFunction = CP_setReturnMonthFunction; 237 c.setReturnQuarterFunction = CP_setReturnQuarterFunction; 238 c.setReturnYearFunction = CP_setReturnYearFunction; 239 c.setMonthNames = CP_setMonthNames; 240 c.setMonthAbbreviations = CP_setMonthAbbreviations; 241 c.setDayHeaders = CP_setDayHeaders; 242 c.setWeekStartDay = CP_setWeekStartDay; 243 c.setDisplayType = CP_setDisplayType; 244 c.setDisabledWeekDays = CP_setDisabledWeekDays; 245 c.addDisabledDates = CP_addDisabledDates; 246 c.setYearSelectStartOffset = CP_setYearSelectStartOffset; 247 c.setTodayText = CP_setTodayText; 248 c.showYearNavigation = CP_showYearNavigation; 249 c.showCalendar = CP_showCalendar; 250 c.hideCalendar = CP_hideCalendar; 251 c.getStyles = getCalendarStyles; 252 c.refreshCalendar = CP_refreshCalendar; 253 c.getCalendar = CP_getCalendar; 254 c.select = CP_select; 255 c.setCssPrefix = CP_setCssPrefix; 256 c.showNavigationDropdowns = CP_showNavigationDropdowns; 257 c.showYearNavigationInput = CP_showYearNavigationInput; 258 c.copyMonthNamesToWindow(); 259 // Return the object 260 return c; 261 } 262 function CP_copyMonthNamesToWindow() { 263 // Copy these values over to the date.js 264 if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) { 265 window.MONTH_NAMES = new Array(); 266 for (var i=0; i<this.monthNames.length; i++) { 267 window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i]; 268 } 269 for (var i=0; i<this.monthAbbreviations.length; i++) { 270 window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i]; 271 } 272 } 273 } 274 // Temporary default functions to be called when items clicked, so no error is thrown 275 function CP_tmpReturnFunction(y,m,d) { 276 if (window.CP_targetInput!=null) { 277 var dt = new Date(y,m-1,d,0,0,0); 278 if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); } 279 window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat); 280 } 281 else { 282 alert('Use setReturnFunction() to define which function will get the clicked results!'); 283 } 284 } 285 function CP_tmpReturnMonthFunction(y,m) { 286 alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); 287 } 288 function CP_tmpReturnQuarterFunction(y,q) { 289 alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); 290 } 291 function CP_tmpReturnYearFunction(y) { 292 alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); 293 } 294 295 // Set the name of the functions to call to get the clicked item 296 function CP_setReturnFunction(name) { this.returnFunction = name; } 297 function CP_setReturnMonthFunction(name) { this.returnMonthFunction = name; } 298 function CP_setReturnQuarterFunction(name) { this.returnQuarterFunction = name; } 299 function CP_setReturnYearFunction(name) { this.returnYearFunction = name; } 300 301 // Over-ride the built-in month names 302 function CP_setMonthNames() { 303 for (var i=0; i<arguments.length; i++) { this.monthNames[i] = arguments[i]; } 304 this.copyMonthNamesToWindow(); 305 } 306 307 // Over-ride the built-in month abbreviations 308 function CP_setMonthAbbreviations() { 309 for (var i=0; i<arguments.length; i++) { this.monthAbbreviations[i] = arguments[i]; } 310 this.copyMonthNamesToWindow(); 311 } 312 313 // Over-ride the built-in column headers for each day 314 function CP_setDayHeaders() { 315 for (var i=0; i<arguments.length; i++) { this.dayHeaders[i] = arguments[i]; } 316 } 317 318 // Set the day of the week (0-7) that the calendar display starts on 319 // This is for countries other than the US whose calendar displays start on Monday(1), for example 320 function CP_setWeekStartDay(day) { this.weekStartDay = day; } 321 322 // Show next/last year navigation links 323 function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true; } 324 325 // Which type of calendar to display 326 function CP_setDisplayType(type) { 327 if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year") { alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false; } 328 this.displayType=type; 329 return false; 330 } 331 332 // How many years back to start by default for year display 333 function CP_setYearSelectStartOffset(num) { this.yearSelectStartOffset=num; } 334 335 // Set which weekdays should not be clickable 336 function CP_setDisabledWeekDays() { 337 this.disabledWeekDays = new Object(); 338 for (var i=0; i<arguments.length; i++) { this.disabledWeekDays[arguments[i]] = true; } 339 } 340 341 // Disable individual dates or ranges 342 // Builds an internal logical test which is run via eval() for efficiency 343 function CP_addDisabledDates(start, end) { 344 if (arguments.length==1) { end=start; } 345 if (start==null && end==null) { return; } 346 if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; } 347 if (start!=null) { start = parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());} 348 if (end!=null) { end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());} 349 if (start==null) { this.disabledDatesExpression+="(ds<="+end+")"; } 350 else if (end ==null) { this.disabledDatesExpression+="(ds>="+start+")"; } 351 else { this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")"; } 352 } 353 354 // Set the text to use for the "Today" link 355 function CP_setTodayText(text) { 356 this.todayText = text; 357 } 358 359 // Set the prefix to be added to all CSS classes when writing output 360 function CP_setCssPrefix(val) { 361 this.cssPrefix = val; 362 } 363 364 // Show the navigation as an dropdowns that can be manually changed 365 function CP_showNavigationDropdowns() { this.isShowNavigationDropdowns = (arguments.length>0)?arguments[0]:true; } 366 367 // Show the year navigation as an input box that can be manually changed 368 function CP_showYearNavigationInput() { this.isShowYearNavigationInput = (arguments.length>0)?arguments[0]:true; } 369 370 // Hide a calendar object 371 function CP_hideCalendar() { 372 if (arguments.length > 0) { window.popupWindowObjects[arguments[0]].hidePopup(); } 373 else { this.hidePopup(); } 374 } 375 376 // Refresh the contents of the calendar display 377 function CP_refreshCalendar(index) { 378 var calObject = window.popupWindowObjects[index]; 379 if (arguments.length>1) { 380 calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5])); 381 } 382 else { 383 calObject.populate(calObject.getCalendar()); 384 } 385 calObject.refresh(); 386 } 387 388 // Populate the calendar and display it 389 function CP_showCalendar(anchorname) { 390 if (arguments.length>1) { 391 if (arguments[1]==null||arguments[1]=="") { 392 this.currentDate=new Date(); 393 } 394 else { 395 this.currentDate=new Date(parseDate(arguments[1])); 396 } 397 } 398 this.populate(this.getCalendar()); 399 this.showPopup(anchorname); 400 } 401 402 // Simple method to interface popup calendar with a text-entry box 403 function CP_select(inputobj, linkname, format) { 404 var selectedDate=(arguments.length>3)?arguments[3]:null; 405 if (!window.getDateFromFormat) { 406 alert("calendar.select: To use this method you must also include 'date.js' for date formatting"); 407 return; 408 } 409 if (this.displayType!="date"&&this.displayType!="week-end") { 410 alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'"); 411 return; 412 } 413 if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 414 alert("calendar.select: Input object passed is not a valid form input object"); 415 window.CP_targetInput=null; 416 return; 417 } 418 if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input! 419 window.CP_targetInput = inputobj; 420 window.CP_calendarObject = this; 421 this.currentDate=null; 422 var time=0; 423 if (selectedDate!=null) { 424 time = getDateFromFormat(selectedDate,format) 425 } 426 else if (inputobj.value!="") { 427 time = getDateFromFormat(inputobj.value,format); 428 } 429 if (selectedDate!=null || inputobj.value!="") { 430 if (time==0) { this.currentDate=null; } 431 else { this.currentDate=new Date(time); } 432 } 433 window.CP_dateFormat = format; 434 this.showCalendar(linkname); 435 } 436 437 // Get style block needed to display the calendar correctly 438 function getCalendarStyles() { 439 var result = ""; 440 var p = ""; 441 if (this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!="") { p=this.cssPrefix; } 442 result += "<STYLE>\n"; 443 result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n"; 444 result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n"; 445 result += "TD."+p+"cpDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0 0 1 0; }\n"; 446 result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate { text-align:right; text-decoration:none; }\n"; 447 result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n"; 448 result += "."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n"; 449 result += "."+p+"cpOtherMonthDate { color:#808080; }\n"; 450 result += "TD."+p+"cpCurrentDate { color:white; background-color: #C0C0C0; border-width:1; border:solid thin #800000; }\n"; 451 result += "TD."+p+"cpCurrentDateDisabled { border-width:1; border:solid thin #FFAAAA; }\n"; 452 result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled { border:solid thin #C0C0C0; border-width:1 0 0 0;}\n"; 453 result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled { height:20px; }\n"; 454 result += "A."+p+"cpTodayText { color:black; }\n"; 455 result += "."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n"; 456 result += "."+p+"cpBorder { border:solid thin #808080; }\n"; 457 result += "</STYLE>\n"; 458 return result; 459 } 460 461 // Return a string containing all the calendar code to be displayed 462 function CP_getCalendar() { 463 var now = new Date(); 464 // Reference to window 465 if (this.type == "WINDOW") { var windowref = "window.opener."; } 466 else { var windowref = ""; } 467 var result = ""; 468 // If POPUP, write entire HTML document 469 if (this.type == "WINDOW") { 470 result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n"; 471 result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n'; 472 } 473 else { 474 result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n'; 475 result += '<TR><TD ALIGN=CENTER>\n'; 476 result += '<CENTER>\n'; 477 } 478 // Code for DATE display (default) 479 // ------------------------------- 480 if (this.displayType=="date" || this.displayType=="week-end") { 481 if (this.currentDate==null) { this.currentDate = now; } 482 if (arguments.length > 0) { var month = arguments[0]; } 483 else { var month = this.currentDate.getMonth()+1; } 484 if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; } 485 else { var year = this.currentDate.getFullYear(); } 486 var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31); 487 if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) { 488 daysinmonth[2] = 29; 489 } 490 var current_month = new Date(year,month-1,1); 491 var display_year = year; 492 var display_month = month; 493 var display_date = 1; 494 var weekday= current_month.getDay(); 495 var offset = 0; 496 497 offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ; 498 if (offset > 0) { 499 display_month--; 500 if (display_month < 1) { display_month = 12; display_year--; } 501 display_date = daysinmonth[display_month]-offset+1; 502 } 503 var next_month = month+1; 504 var next_month_year = year; 505 if (next_month > 12) { next_month=1; next_month_year++; } 506 var last_month = month-1; 507 var last_month_year = year; 508 if (last_month < 1) { last_month=12; last_month_year--; } 509 var date_class; 510 if (this.type!="WINDOW") { 511 result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>"; 512 } 513 result += '<TR>\n'; 514 var refresh = windowref+'CP_refreshCalendar'; 515 var refreshLink = 'javascript:' + refresh; 516 if (this.isShowNavigationDropdowns) { 517 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onchange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">'; 518 for( var monthCounter=1; monthCounter<=12; monthCounter++ ) { 519 var selected = (monthCounter==month) ? 'SELECTED' : ''; 520 result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>'; 521 } 522 result += '</select></TD>'; 523 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>'; 524 525 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onchange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">'; 526 for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) { 527 var selected = (yearCounter==year) ? 'SELECTED' : ''; 528 result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>'; 529 } 530 result += '</select></TD>'; 531 } 532 else { 533 if (this.isShowYearNavigation) { 534 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="../../admin/%27+refreshLink+%27(%27+this.index+%27,%27+last_month+%27,%27+last_month_year+%27);"><</A></TD>'; 535 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>'; 536 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="../../admin/%27+refreshLink+%27(%27+this.index+%27,%27+next_month+%27,%27+next_month_year+%27);">></A></TD>'; 537 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>'; 538 539 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="../../admin/%27+refreshLink+%27(%27+this.index+%27,%27+month+%27,%27+(year-1)+%27);"><</A></TD>'; 540 if (this.isShowYearNavigationInput) { 541 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onblur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>'; 542 } 543 else { 544 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>'; 545 } 546 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="../../admin/%27+refreshLink+%27(%27+this.index+%27,%27+month+%27,%27+(year+1)+%27);">></A></TD>'; 547 } 548 else { 549 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="../../admin/%27+refreshLink+%27(%27+this.index+%27,%27+last_month+%27,%27+last_month_year+%27);"><<</A></TD>\n'; 550 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n'; 551 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="../../admin/%27+refreshLink+%27(%27+this.index+%27,%27+next_month+%27,%27+next_month_year+%27);">>></A></TD>\n'; 552 } 553 } 554 result += '</TR></TABLE>\n'; 555 result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n'; 556 result += '<TR>\n'; 557 for (var j=0; j<7; j++) { 558 559 result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n'; 560 } 561 result += '</TR>\n'; 562 for (var row=1; row<=6; row++) { 563 result += '<TR>\n'; 564 for (var col=1; col<=7; col++) { 565 var disabled=false; 566 if (this.disabledDatesExpression!="") { 567 var ds=""+display_year+LZ(display_month)+LZ(display_date); 568 eval("disabled=("+this.disabledDatesExpression+")"); 569 } 570 var dateClass = ""; 571 if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) { 572 dateClass = "cpCurrentDate"; 573 } 574 else if (display_month == month) { 575 dateClass = "cpCurrentMonthDate"; 576 } 577 else { 578 dateClass = "cpOtherMonthDate"; 579 } 580 if (disabled || this.disabledWeekDays[col-1]) { 581 result += ' <TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n'; 582 } 583 else { 584 var selected_date = display_date; 585 var selected_month = display_month; 586 var selected_year = display_year; 587 if (this.displayType=="week-end") { 588 var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0); 589 d.setDate(d.getDate() + (7-col)); 590 selected_year = d.getYear(); 591 if (selected_year < 1000) { selected_year += 1900; } 592 selected_month = d.getMonth()+1; 593 selected_date = d.getDate(); 594 } 595 result += ' <TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n'; 596 } 597 display_date++; 598 if (display_date > daysinmonth[display_month]) { 599 display_date=1; 600 display_month++; 601 } 602 if (display_month > 12) { 603 display_month=1; 604 display_year++; 605 } 606 } 607 result += '</TR>'; 608 } 609 var current_weekday = now.getDay() - this.weekStartDay; 610 if (current_weekday < 0) { 611 current_weekday += 7; 612 } 613 result += '<TR>\n'; 614 result += ' <TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n'; 615 if (this.disabledDatesExpression!="") { 616 var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate()); 617 eval("disabled=("+this.disabledDatesExpression+")"); 618 } 619 if (disabled || this.disabledWeekDays[current_weekday+1]) { 620 result += ' <SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n'; 621 } 622 else { 623 result += ' <A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n'; 624 } 625 result += ' <BR>\n'; 626 result += ' </TD></TR></TABLE></CENTER></TD></TR></TABLE>\n'; 627 } 628 629 // Code common for MONTH, QUARTER, YEAR 630 // ------------------------------------ 631 if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") { 632 if (arguments.length > 0) { var year = arguments[0]; } 633 else { 634 if (this.displayType=="year") { var year = now.getFullYear()-this.yearSelectStartOffset; } 635 else { var year = now.getFullYear(); } 636 } 637 if (this.displayType!="year" && this.isShowYearNavigation) { 638 result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>"; 639 result += '<TR>\n'; 640 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');"><<</A></TD>\n'; 641 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n'; 642 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">>></A></TD>\n'; 643 result += '</TR></TABLE>\n'; 644 } 645 } 646 647 // Code for MONTH display 648 // ---------------------- 649 if (this.displayType=="month") { 650 // If POPUP, write entire HTML document 651 result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n'; 652 for (var i=0; i<4; i++) { 653 result += '<TR>'; 654 for (var j=0; j<3; j++) { 655 var monthindex = ((i*3)+j); 656 result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>'; 657 } 658 result += '</TR>'; 659 } 660 result += '</TABLE></CENTER></TD></TR></TABLE>\n'; 661 } 662 663 // Code for QUARTER display 664 // ------------------------ 665 if (this.displayType=="quarter") { 666 result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n'; 667 for (var i=0; i<2; i++) { 668 result += '<TR>'; 669 for (var j=0; j<2; j++) { 670 var quarter = ((i*2)+j+1); 671 result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>'; 672 } 673 result += '</TR>'; 674 } 675 result += '</TABLE></CENTER></TD></TR></TABLE>\n'; 676 } 677 678 // Code for YEAR display 679 // --------------------- 680 if (this.displayType=="year") { 681 var yearColumnSize = 4; 682 result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>"; 683 result += '<TR>\n'; 684 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');"><<</A></TD>\n'; 685 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">>></A></TD>\n'; 686 result += '</TR></TABLE>\n'; 687 result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n'; 688 for (var i=0; i<yearColumnSize; i++) { 689 for (var j=0; j<2; j++) { 690 var currentyear = year+(j*yearColumnSize)+i; 691 result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>'; 692 } 693 result += '</TR>'; 694 } 695 result += '</TABLE></CENTER></TD></TR></TABLE>\n'; 696 } 697 // Common 698 if (this.type == "WINDOW") { 699 result += "</BODY></HTML>\n"; 700 } 701 return result; 702 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |