Changeset 2886
- Timestamp:
- 04/27/10 17:24:48
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/bedeworkFb.js
r2885 r2886 59 59 var bwAttendeeDispTypeResource = "resource"; 60 60 61 var bwFreeBusyDispTypeBusy = "BUSY"; 62 var bwFreeBusyDispTypeTentative = "TENTATIVE"; 63 var bwAddAttendeeDisp = "add attendee..."; 64 61 65 /* An attendee 62 66 * name: String - name of attendee, e.g. "Venerable Bede" … … 85 89 } 86 90 } 87 /* Freebusy data91 /* A Freebusy object 88 92 * Provides methods to work on freebusy values 89 * fb vals: Array of rfc5545 freebusy values93 * fbString: an rfc5545 freebusy string, including FBTYPE parameter if present 90 94 */ 91 95 var bwFreeBusy = function(fbString) { 92 96 this.name = fbString; 97 this.params = ""; // if there are parameters, we will split them from the name and put them here 98 this.type = bwFreeBusyDispTypeBusy; // default rfc5545 FBTYPE, "BUSY" 99 this.start = ""; // will hold the UTC start value in milliseconds 100 this.end = ""; // will hold the UTC end value in milliseconds 101 102 if (this.name.match(":")) { 103 // parameters are included with the freebusy string 104 // e.g. FBTYPE=BUSY:19980415T133000Z/19980415T170000Z 105 this.name = fbString.substr(fbString.indexOf(":")+1); 106 this.params = fbString.substring(0,fbString.indexOf(":")); 107 } 108 109 if (this.params.match("FBTYPE=BUSY-TENTATIVE")) { 110 this.type = bwFreeBusyDispTypeTentative; 111 } 93 112 94 113 // set the freebusy start date … … 121 140 // set the end in milliseconds 122 141 this.end = endMs; 123 124 125 // example of how to generate a date from the millisecond UTC value 126 // var testDate = new Date(this.fbHash[fbVals[0]].start); //fbVals[0] = a freebusy string 127 // alert(testDate.toLocaleString()); 128 129 /* returns true if date is contained in this freebusy value 142 143 /* returns true if a date is contained in this freebusy value 130 144 * mils: date/time in milliseconds 131 145 */ 132 146 this.contains = function(mils) { 133 147 if (mils >= this.start && mils < this.end) { 134 // should return type of freebusy if available135 148 return true; 136 149 } … … 175 188 176 189 // internal variables 177 var startSelectionMils; // where a mouse selection begins, milliseconds parsed from the first half of a fbcell's ID 178 var endSelectionMils; // where a mouse selection ends, milliseconds parsed from the first half of a fbcell's ID 179 var selecting = false; // are we currently selecting? If true, we'll highlight as we hover 190 var startMils = Number(this.startRange.getTime()) + Number(this.startHoursRange * 3600000); // the start of the grid 191 var durationMils = 3600000; // value used to calculate default endSelectionMils, defaults to 1 hour in milliseconds 192 var incrementMils = 3600000 / this.hourDivision; // increment for the pick next/previous buttons 193 var startSelectionMils = startMils; // where a mouse selection begins, milliseconds parsed from the first half of a fbcell's ID, default to beginning of grid 194 var endSelectionMils; // where a mouse selection ends, milliseconds parsed from the first half of a fbcell's ID 195 var selecting = false; // are we currently selecting? If true, we'll highlight as we hover 180 196 181 197 this.addAttendee = function(name, uid, freebusy, role, status, type) { … … 189 205 this.attendees.splice(index, 1); 190 206 this.diplay(); 207 } 208 209 this.pickNext = function(gridObj) { 210 // clear highlighting 211 $("#bwScheduleTable .fbcell").removeClass("highlight"); 212 213 // increment the start time 214 startSelectionMils = Number(startSelectionMils) + Number(incrementMils); 215 // set the end time based on duration 216 endSelectionMils = Number(startSelectionMils) + Number(durationMils); 217 218 // highlight the cells if no collision, otherwise try the next spot 219 $("#bwScheduleTable .fbcell").each(function(index) { 220 var splId = $(this).attr("id").split("-"); 221 if (splId[0] >= startSelectionMils && splId[0] < endSelectionMils) { 222 if ($(this).hasClass("busy")) { 223 alert("hit a busytime!"); 224 //this.pickNext(); 225 } else { 226 $(this).addClass("highlight"); 227 } 228 } 229 }); 230 } 231 232 this.pickPrevious = function(gridObj) { 233 // clear highlighting 234 $("#bwScheduleTable .fbcell").removeClass("highlight"); 235 236 // decrement the start time 237 startSelectionMils = Number(startSelectionMils) - Number(incrementMils); 238 // set the end time based on duration 239 endSelectionMils = Number(startSelectionMils) + Number(durationMils); 240 241 // highlight the cells if no collision, otherwise try the next spot 242 $("#bwScheduleTable .fbcell").each(function(index) { 243 var splId = $(this).attr("id").split("-"); 244 if (splId[0] >= startSelectionMils && splId[0] < endSelectionMils) { 245 $(this).addClass("highlight"); 246 } 247 }); 191 248 } 192 249 … … 286 343 switch (curAttendee.status) { 287 344 case bwAttendeeStatusAccepted : // ✔ - make an image to avoid font issues 288 $(fbDisplayAttendeeRow).html('<td class="status accepted"><span class="icon"><img src="check.gif" alt="accepted" width="15" height="15"/></span><span class="t ext">' + bwAttendeeDispStatusAccepted + '</span></td>');345 $(fbDisplayAttendeeRow).html('<td class="status accepted"><span class="icon"><img src="check.gif" alt="accepted" width="15" height="15"/></span><span class="tip">' + bwAttendeeDispStatusAccepted + '</span></td>'); 289 346 break; 290 347 case bwAttendeeStatusDeclined : 291 $(fbDisplayAttendeeRow).html('<td class="status declined"><span class="icon">x</span><span class="t ext">' + bwAttendeeDispStatusDeclined + '</span></td>');348 $(fbDisplayAttendeeRow).html('<td class="status declined"><span class="icon">x</span><span class="tip">' + bwAttendeeDispStatusDeclined + '</span></td>'); 292 349 break; 293 350 case bwAttendeeStatusTentative : 294 $(fbDisplayAttendeeRow).html('<td class="status tentative"><span class="icon">-</span><span class="t ext">' + bwAttendeeDispStatusTentative + '</span></td>');351 $(fbDisplayAttendeeRow).html('<td class="status tentative"><span class="icon">-</span><span class="tip">' + bwAttendeeDispStatusTentative + '</span></td>'); 295 352 break; 296 353 case bwAttendeeStatusDelegated : 297 $(fbDisplayAttendeeRow).html('<td class="status delegated"><span class="icon"></span><span class="t ext">' + bwAttendeeDispStatusDelegated + '</span></td>');354 $(fbDisplayAttendeeRow).html('<td class="status delegated"><span class="icon"></span><span class="tip">' + bwAttendeeDispStatusDelegated + '</span></td>'); 298 355 break; 299 356 case bwAttendeeStatusCompleted : 300 $(fbDisplayAttendeeRow).html('<td class="status completed"><span class="icon"></span><span class="t ext">' + bwAttendeeDispStatusCompleted + '</span></td>');357 $(fbDisplayAttendeeRow).html('<td class="status completed"><span class="icon"></span><span class="tip">' + bwAttendeeDispStatusCompleted + '</span></td>'); 301 358 break; 302 359 case bwAttendeeStatusInProcess : 303 $(fbDisplayAttendeeRow).html('<td class="status inprocess"><span class="icon"></span><span class="t ext">' + bwAttendeeDispStatusInProcess + '</span></td>');360 $(fbDisplayAttendeeRow).html('<td class="status inprocess"><span class="icon"></span><span class="tip">' + bwAttendeeDispStatusInProcess + '</span></td>'); 304 361 break; 305 362 default : // default to bwAttendeeStatusNeedsAction - display question mark 306 $(fbDisplayAttendeeRow).html('<td class="status needsaction"><span class="icon">?</span><span class="t ext">' + bwAttendeeDispStatusNeedsAction + '</span></td>');363 $(fbDisplayAttendeeRow).html('<td class="status needsaction"><span class="icon">?</span><span class="tip">' + bwAttendeeDispStatusNeedsAction + '</span></td>'); 307 364 } 308 365 … … 311 368 switch (curAttendee.role) { 312 369 case bwAttendeeRoleChair : // displays writing hand icon - ✍ 313 $(fbDisplayAttendeeRow).append('<td class="role chair"><span class="icon"><img src="chair.gif" alt="chair" width="17" height="15"/></span><span class="t ext">' + bwAttendeeDispRoleChair + '</span></td>');370 $(fbDisplayAttendeeRow).append('<td class="role chair"><span class="icon"><img src="chair.gif" alt="chair" width="17" height="15"/></span><span class="tip">' + bwAttendeeDispRoleChair + '</span></td>'); 314 371 break; 315 372 case bwAttendeeRoleRequired : // displays right-pointing arrow icon - ➙ 316 $(fbDisplayAttendeeRow).append('<td class="role required"><span class="icon"><img src="reqArrow.gif" alt="required" width="17" height="12"/></span><span class="t ext">' + bwAttendeeDispRoleRequired + '</span></td>');373 $(fbDisplayAttendeeRow).append('<td class="role required"><span class="icon"><img src="reqArrow.gif" alt="required" width="17" height="12"/></span><span class="tip">' + bwAttendeeDispRoleRequired + '</span></td>'); 317 374 break; 318 375 case bwAttendeeRoleNonParticipant : // non-participant 319 $(fbDisplayAttendeeRow).append('<td class="role nonparticipant"><span class="icon">x</span><span class="t ext">' + bwAttendeeDispRoleNonParticipant + '</span></td>');376 $(fbDisplayAttendeeRow).append('<td class="role nonparticipant"><span class="icon">x</span><span class="tip">' + bwAttendeeDispRoleNonParticipant + '</span></td>'); 320 377 break; 321 378 default : // bwAttendeeRoleOptional - no icon (use a space to provide a rollover) 322 $(fbDisplayAttendeeRow).append('<td class="role optional"><span class="icon"> </span><span class="text">' + bwAttendeeDispRoleOptional + '</span></td>'); 323 } 379 $(fbDisplayAttendeeRow).append('<td class="role optional"><span class="icon"> </span><span class="tip">' + bwAttendeeDispRoleOptional + '</span></td>'); 380 } 381 324 382 325 383 // output the attendee name or address (depending on which we have available) 384 // and add attendee functions 385 var attendeeNameHtml = '<td class="name">'; 326 386 if (curAttendee.name && curAttendee.name != "") { 327 $(fbDisplayAttendeeRow).append('<td class="name">' + curAttendee.name + '</td>');387 attendeeNameHtml += curAttendee.name; 328 388 } else { 329 $(fbDisplayAttendeeRow).append('<td class="name">' + curAttendee.uid.substr(curAttendee.uid.lastIndexOf(":")+1) + '</td>'); 330 } 389 attendeeNameHtml += curAttendee.uid.substr(curAttendee.uid.lastIndexOf(":")+1); 390 } 391 attendeeNameHtml += '</td>'; 392 $(fbDisplayAttendeeRow).append(attendeeNameHtml); 331 393 332 394 // output checkbox for attendee … … 355 417 var curDateUTC = curDate.getTime() + tzoffset + (60 / this.hourDivision * 60000); 356 418 if (curAttendee.freebusy[m].contains(curDateUTC)) { 357 $(fbCell).addClass("busy"); 419 if (curAttendee.freebusy[m].type.match("TENTATIVE")) { 420 $(fbCell).addClass("tentative"); 421 } else { 422 $(fbCell).addClass("busy"); 423 } 424 $(fbCell).addClass("activeCell"); 425 $(fbCell).append('<span class="tip">' + curAttendee.freebusy[m].type + '</span>'); 358 426 break; 359 427 } … … 371 439 372 440 // create the add attendee form 373 var addAttendeeHtml = '<td class="status"></td><td class="role"></td><td class="name">'; 374 addAttendeeHtml += '<input type="text" value="add attendee..." name="attendee" id="addAttendee" class="pending" size="14"/>'; 375 addAttendeeHtml += '<div id="addAttendeeFields">'; 376 addAttendeeHtml += '<select><option>person</option><option>group</option><option>resource</option></select>'; 377 addAttendeeHtml += '<input type="checkbox"/>personal <input type="checkbox"/>public'; 378 addAttendeeHtml += '</div>'; 379 addAttendeeHtml += '</td><td></td><td class="fbBoundry"></td>'; 441 var addAttendeeHtml = '<td class="status"></td><td class="role"></td><td class="addAttendee" colspan="2">'; 442 addAttendeeHtml += '<input type="text" value="' + bwAddAttendeeDisp +'" name="attendee" id="addAttendee" class="pending" size="14"/>'; 443 addAttendeeHtml += '<span class="addAttendeeAdvanced">advanced</span>'; 444 //addAttendeeHtml += '<div id="addAttendeeFields">'; 445 //addAttendeeHtml += '<select><option>person</option><option>group</option><option>resource</option></select>'; 446 //addAttendeeHtml += '<input type="checkbox"/>personal <input type="checkbox"/>public'; 447 //addAttendeeHtml += '</div>'; 448 addAttendeeHtml += '</td><td class="fbBoundry"></td>'; 380 449 381 450 $(fbDisplayAddAttendeeRow).html(addAttendeeHtml); … … 435 504 $("#bwScheduleTable .icon").hover( 436 505 function () { 437 $(this).next(".t ext").fadeIn(100);506 $(this).next(".tip").fadeIn(100); 438 507 }, 439 508 function () { 440 $(this).next(".t ext").fadeOut(100);509 $(this).next(".tip").fadeOut(100); 441 510 } 442 511 ); 443 512 513 $("#bwScheduleTable .activeCell").hover( 514 function () { 515 $(this).children(".tip").fadeIn(20); 516 }, 517 function () { 518 $(this).children(".tip").fadeOut(20); 519 } 520 ); 521 522 $("#bwScheduleTable .fbcell").click ( 523 function () { 524 // clear all previous highlighting 525 $("#bwScheduleTable .highlight").removeClass("highlight"); 526 527 // get the id of the current cell - takes the form "1271947500000-attendeestring" 528 // we want the first half, which is the same as the time class associated with the column 529 var splitId = $(this).attr("id").split("-"); 530 531 // set the start of the selection range in milliseconds (first half of the ID) 532 // we will use this to set the start time and to find cells in the same column 533 startSelectionMils = splitId[0]; 534 endSelectionMils = Number(startSelectionMils) + Number(durationMils); 535 536 // now do the highlighting 537 $("#bwScheduleTable .fbcell").each(function(index) { 538 var splId = $(this).attr("id").split("-"); 539 if (splId[0] >= startSelectionMils && splId[0] < endSelectionMils) { 540 $(this).addClass("highlight"); 541 } 542 }); 543 544 } 545 ); 546 547 /* 444 548 $("#bwScheduleTable .fbcell").mousedown ( 445 549 function () { … … 491 595 } 492 596 ); 597 */ 493 598 494 599 $("#bwScheduleTable #addAttendee").click ( 495 600 function () { 496 this.value = ""; 497 this.size = 32; 601 if (this.value == bwAddAttendeeDisp) { 602 this.value = ""; 603 } 604 $(this).addClass("active"); 498 605 $(this).removeClass("pending"); 499 $("#addAttendeeFields").show("slow");500 606 } 501 607 ); 608 502 609 503 610 } catch (e) { trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/index.html
r2885 r2886 18 18 // initialize the free/busy grid - values taken directly from the xml 19 19 // send params: displayId, startRange, endRange, startDate, endDate, startHourRange, endHourRange, attendees, workday, zoom 20 var bwGrid = new bwSchedulingGrid("bwFreeBusyDisplay","April 21, 2010","April 27, 2010","April 21, 2010 11:00:00","April 21, 2010 11:30:00",8,17,[{name:"Arlen Johnson",uid:"mailto:johnsa@rpi.edu",freebusy:["20100421T093000Z/PT2H00M","20100423T174500Z/PT8H30M"],role:"CHAIR",status:"ACCEPTED",type:"person"}], false,100);20 var bwGrid = new bwSchedulingGrid("bwFreeBusyDisplay","April 21, 2010","April 27, 2010","April 21, 2010 11:00:00","April 21, 2010 11:30:00",8,17,[{name:"Arlen Johnson",uid:"mailto:johnsa@rpi.edu",freebusy:["20100421T093000Z/PT2H00M","20100423T174500Z/PT8H30M"],role:"CHAIR",status:"ACCEPTED",type:"person"}],true,100); 21 21 22 22 // send in some attendees - these will come from interaction with the form 23 23 bwGrid.addAttendee("Gary Schwartz", "mailto:schwag@rpi.edu", ["20100422T090000Z/PT1H00M"], "REQ-PARTICIPANT", "NEEDS-ACTION"); 24 bwGrid.addAttendee("", "mailto:douglm@rpi.edu", [" 20100421T120000Z/20100421T130000Z","20100422T050000Z/20100422T060000Z"], "OPT-PARTICIPANT", "DECLINED");24 bwGrid.addAttendee("", "mailto:douglm@rpi.edu", ["FBTYPE=BUSY-TENTATIVE:20100421T120000Z/20100421T130000Z","20100422T050000Z/20100422T060000Z"], "OPT-PARTICIPANT", "DECLINED"); 25 25 26 26 // set datepicker defaults … … 63 63 64 64 <td> 65 <button >« Pick Previous</button>65 <button id="bwPickPrevious" onclick="bwGrid.pickPrevious();">« Pick Previous</button> 66 66 </td> 67 67 <td> 68 <button >Pick Next »</button>68 <button id="bwPickNext" onclick="bwGrid.pickNext();">Pick Next »</button> 69 69 </td> 70 70 <td class="dateLabel"> … … 170 170 </tr> 171 171 </table> 172 <button onclick="bwGrid.display();">redraw</button> 172 173 </div> 173 174 </body> trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/schedule.css
r2885 r2886 32 32 padding-right: 16px; 33 33 } 34 #bwScheduleTable .icon { 35 cursor: default; 34 #bwScheduleTable .icon, 35 #bwScheduleTable .activeCell { 36 cursor: default !important; 36 37 } 37 #bwScheduleTable .t ext{38 #bwScheduleTable .tip { 38 39 /* this is the default rollover for most icons */ 39 40 position: absolute; … … 79 80 border: none; 80 81 } 82 #bwScheduleTable #addAttendee.active { 83 color: black; 84 background-color: transparent; 85 border: none; 86 } 87 #bwScheduleTable .addAttendeeAdvanced { 88 color: #bbb; 89 background-color: transparent; 90 font-size: 0.8em; 91 } 81 92 #bwScheduleTable #addAttendeeFields, 82 93 #bwScheduleTable #attType { … … 87 98 } 88 99 #bwScheduleTable td.fbcell { 89 cursor: crosshair;100 /*cursor: crosshair;*/ 90 101 } 91 102 #bwScheduleTable td.busy { … … 94 105 } 95 106 #bwScheduleTable td.tentative { 96 background: url("tentativeLines.gif");107 background: #eef url("tentativeLines.gif") !important; 97 108 color: black; 98 109 } 99 110 #bwScheduleTable td.highlight { 100 background-color: #ffa !important;111 background-color: #ffa; 101 112 color: black; 102 113 }
