Changeset 3078

Show
Ignore:
Timestamp:
11/29/10 15:44:39
Author:
johnsa
Message:

personal client: correct public address book master switch click handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • releases/bedework-3.7/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/javascript/bedeworkScheduling.js

    r3075 r3078  
    708708      addAttendeeHtml += '    <span class="bwAddAttendeeSubFieldHead">' + bwAddAttendeeBookDisp + '</span>'; 
    709709      addAttendeeHtml += '    <input type="radio" name="bwAddAttendeeAddrBk" value="/user/' + bwGrid.curUser + '/addressbook" checked="checked" onclick="changeClass(\'bwAddAttendeeTypeBlock\',\'invisible\');bwGrid.updateBookPath(this.value);">personal'; 
    710       addAttendeeHtml += '    <input type="radio" name="bwAddAttendeeAddrBk" value="/public" onclick="changeClass(\'bwAddAttendeeTypeBlock\',\'bwAddAttendeeSubField\');bwGrid.updateBookPath(this.form.bwAddAttendeeType.value);">public'; 
     710      // note: the public switch uses a separate click handler set after the display is written to the output (below) 
     711      addAttendeeHtml += '    <input type="radio" name="bwAddAttendeeAddrBk" id="bwAddAttendeePublicSwitch" value="/public" onclick="changeClass(\'bwAddAttendeeTypeBlock\',\'bwAddAttendeeSubField\');">public'; 
    711712      addAttendeeHtml += '  </div>'; 
    712713      addAttendeeHtml += '  <div class="invisible" id="bwAddAttendeeTypeBlock">'; 
     
    899900      //endSelectionMils = Number(curSelectionTime) + Number(durationMils); 
    900901      //bwGrid.highlight(curSelectionTime, endSelectionMils); 
     902        
     903     //**** ACTIONS **** 
     904     //now add some rollovers and onclick actions  
     905     //to the elements of the freebusy grid  
     906     $("#bwScheduleTable .icon").hover( 
     907       function () { 
     908         $(this).next(".tip").fadeIn(100); 
     909       },  
     910       function () { 
     911         $(this).next(".tip").fadeOut(100); 
     912       } 
     913     );   
     914      
     915     $("#bwScheduleTable .activeCell").hover( 
     916       function () { 
     917         $(this).children(".tip").fadeIn(20); 
     918       },  
     919       function () { 
     920         $(this).children(".tip").fadeOut(20); 
     921       } 
     922     ); 
     923      
     924     $("#bwScheduleTable .fbcell").click ( 
     925       function () { 
     926         // clear all previous highlighting 
     927         $("#bwScheduleTable .highlight").removeClass("highlight"); 
     928          
     929         // get the id of the current cell - takes the form "1271947500000-attendeestring" 
     930         // we want the first half, which is the same as the time class associated with the column 
     931         var splitId = $(this).attr("id").split("-"); 
     932          
     933         // set the start of the selection range in milliseconds (first half of the ID) 
     934         // we will use this to set the start time and to find cells in the same column 
     935         var startSelectionMils = splitId[0]; 
     936         var endSelectionMils = Number(startSelectionMils) + Number(durationMils); 
     937          
     938         // now do the highlighting 
     939         $("#bwScheduleTable .fbcell").each(function(index) { 
     940           var splId = $(this).attr("id").split("-"); 
     941           if (splId[0] >= startSelectionMils && splId[0] < endSelectionMils) { 
     942             $(this).addClass("highlight"); 
     943           } 
     944         }); 
     945          
     946         // set the freeTimeIndex to the nearest index for the pickNext/previous buttons 
     947         for (var i = 0; i < bwGrid.freeTime.length; i++) { 
     948           if (Number(bwGrid.freeTime[i]) >= Number(startSelectionMils)) { 
     949             bwGrid.freeTimeIndex = i - 1; // this will make pick previous jump an extra gap after clicking in a busy space, but it makes pick next work correctly in the same circumstance 
     950             if (bwGrid.freeTimeIndex < 0) { 
     951               bwGrid.freeTimeIndex = 0; 
     952             } 
     953             break; 
     954           } 
     955         } 
     956          
     957         bwGrid.setDateTimeWidgets(startSelectionMils); 
     958      
     959       } 
     960     ); 
     961      
     962     /* 
     963     $("#bwScheduleTable .fbcell").mousedown ( 
     964       function () { 
     965         // clear all previous highlighting 
     966         $("#bwScheduleTable .highlight").removeClass("highlight"); 
     967          
     968         // get the id of the current cell - takes the form "1271947500000-attendeestring" 
     969         // we want the first half, which is the same as the time class associated with the column 
     970         var splitId = $(this).attr("id").split("-"); 
     971          
     972         // set the start of the selection range in milliseconds (first half of the ID) 
     973         // we will use this to set the start time and to find cells in the same column 
     974         startSelectionMils = splitId[0]; 
     975          
     976         // find the cells (the column) that share the same class 
     977         $("#bwScheduleTable ." + startSelectionMils).addClass("highlight"); 
     978          
     979         // we are now selecting, so highlight as we go 
     980         selecting = true;           
     981       } 
     982     ); 
     983      
     984     $("#bwScheduleTable .fbcell").mouseover ( 
     985       function () { 
     986         if (selecting) { 
     987           // get the id of the current cell - takes the form "1271947500000-attendeestring" 
     988           // we want the first half, which is the same as the time class associated with the column 
     989           var splitId = $(this).attr("id").split("-"); 
     990      
     991           // find the cells (the column) that contain the first half as a class 
     992           $("#bwScheduleTable ." + splitId[0]).addClass("highlight"); 
     993         }           
     994       } 
     995     ); 
     996      
     997     $("#bwScheduleTable .fbcell").mouseup ( 
     998       function () { 
     999         // we are no longer selecting 
     1000         selecting = false; 
     1001          
     1002         // get the id of the current cell - takes the form "1271947500000-attendeestring" 
     1003         // we want the first half, which is the same as the time class associated with the column 
     1004         var splitId = $(this).attr("id").split("-"); 
     1005          
     1006         // set the end of the selection range in milliseconds (first half of the ID) 
     1007         // we will use this to set the end time / duration 
     1008         endSelectionMils = splitId[0]; 
     1009          
     1010       } 
     1011     ); 
     1012     */ 
     1013      
     1014     $("#bwScheduleTable #bwAddAttendee").click ( 
     1015       function () { 
     1016         if (this.value == bwAddAttendeeDisp) { 
     1017           this.value = ""; 
     1018         } 
     1019         $(this).addClass("active"); 
     1020         $(this).removeClass("pending"); 
     1021          
     1022         // hide advanced switch, show add button 
     1023         // $("#bwAddAttendeeAdvanced").hide(); 
     1024         changeClass("bwAddAttendeeAdd","visible"); 
     1025         changeClass("bwAddAttendeeFields", "visible"); 
     1026       } 
     1027     ); 
     1028      
     1029     // add a handler for the public switch (not in-line like the others) 
     1030     $("#bwAddAttendeePublicSwitch").click(function(){ 
     1031       bwGrid.updateBookPath($('input:radio[name=bwAddAttendeeType]:checked').val());   
     1032     }); 
     1033      
     1034     // add attendee box - use jquery UI autocomplete 
     1035     // carddavUrl supplied in bedework.js 
     1036     // var carddavUrlTemp = "/ucalrsrc/themes/bedeworkTheme/javascript/addrbookUsers.js" 
     1037     // var carddavUrlTemp = "/ucalrsrc/themes/bedeworkTheme/javascript/addrbookLocations.js" 
     1038     $("#bwScheduleTable #bwAddAttendee").autocomplete({ 
     1039       minLength: 1, 
     1040       // set the data source, call it, and format the results: 
     1041       source: function(req, include) { 
     1042         // build the address book url; the path to the address book is determined by the 
     1043         // radio button choices in the "add attendee" widget - these are stored on the fly 
     1044         // in the hidden field with id bwCardDavBookPath 
     1045         addrBookUrl = carddavUrl + "?format=json&addrbook=" + $("#bwCardDavBookPath").val(); 
     1046          
     1047         // call the server and push the results into an array "items" 
     1048         $.getJSON(addrBookUrl, req, function(data) { 
     1049           var acResults = ""; 
     1050           if (data != undefined && data.microformats != undefined && data.microformats.vcard != undefined) { 
     1051             acResults = data.microformats.vcard; 
     1052           } 
     1053           var items = []; 
     1054           $.each(acResults, function(i,entry) { 
     1055              
     1056             // build the label from the full name and email address 
     1057             var curFn = ""; 
     1058             var curEmail = ""; 
     1059             var curLabel = ""; 
     1060             var curKind = ""; 
     1061              
     1062             if (entry.fn != undefined && entry.fn.value != undefined) { 
     1063               curFn = entry.fn.value; 
     1064             }  
     1065              
     1066             if (entry.kind != undefined && entry.kind.value != undefined) { 
     1067               curKind = entry.kind.value; 
     1068             } 
     1069              
     1070             if (curKind == "group") { 
     1071               if (entry.member != undefined && entry.member.length > 0) { 
     1072                 var members = ""; 
     1073                 for (var i = 0; i < entry.member.length; i++ ) { 
     1074                   members += entry.member[i].value + ","; 
     1075                 } 
     1076                 members = members.substring(0,members.length-1); 
     1077                 var curItem = {label: curFn, value: members}; 
     1078                 items.push(curItem); 
     1079               } 
     1080             } else { 
     1081               // this is probably not enough: we should account for all email addresses if there is no calendar uri 
     1082               if (entry.email != undefined && entry.email[0] != undefined && entry.email[0].value != undefined) { 
     1083                 curEmail = entry.email[0].value; 
     1084               } 
     1085               if (curFn != "") { 
     1086                 curLabel = curFn + ", " + curEmail; 
     1087               } else { 
     1088                 curLabel = curEmail; 
     1089               } 
     1090                
     1091               // use the calendar address uri if available, otherwise use email 
     1092               var curUri = ""; 
     1093               if (entry.caladruri != undefined && entry.caladruri.value != undefined) { 
     1094                 curUri = entry.caladruri.value; 
     1095               } 
     1096               if (curUri == "" && entry.email != undefined && entry.email[0] != undefined && entry.email[0].value != undefined) { 
     1097                 var curEmail = entry.email[0].value; 
     1098                 if (curEmail != "") { 
     1099                   curUri = "mailto:" + curEmail; 
     1100                 } 
     1101               } 
     1102                
     1103               // only add the entry if there is a uri and a label to use 
     1104               if (curUri != "" && curLabel != "") { 
     1105                 var curItem = {label: curLabel, value: curUri}; 
     1106                 items.push(curItem); 
     1107               } 
     1108             } 
     1109           }); 
     1110            
     1111           // pass items to the callback function for display in the autocomplete pulldown 
     1112           include(items); 
     1113         }); 
     1114       } 
     1115     }); 
     1116      
     1117     // capture the enter key when entering an attendee; 
     1118     // do not submit the form; add the attendee. 
     1119     $("#bwScheduleTable #bwAddAttendee").keypress ( 
     1120         function (e) { 
     1121           if(e.keyCode == 13) { // enter 
     1122             e.preventDefault(); 
     1123             bwGrid.addAttendeeFromGrid(); 
     1124           } 
     1125         } 
     1126       ); 
     1127      
     1128     $("#bwScheduleTable #bwAddAttendeeAdd").click ( 
     1129       function () { 
     1130         bwGrid.addAttendeeFromGrid(); 
     1131       } 
     1132     ); 
     1133      
     1134      
     1135     $("#bwScheduleTable .removeAttendee").click ( 
     1136       function () { 
     1137         var i = $("#bwScheduleTable .removeAttendee").index(this); 
     1138         bwGrid.removeAttendee(i); 
     1139       } 
     1140     ); 
     1141      
     1142     // enable or disable an attendee 
     1143     $("#bwScheduleTable input.selectedToggle").click ( 
     1144       function () { 
     1145         var i = $("#bwScheduleTable input.selectedToggle").index(this); 
     1146         if (this.checked) { 
     1147            bwGrid.attendees[i].selected = true; 
     1148         } else { 
     1149            bwGrid.attendees[i].selected = false; 
     1150         } 
     1151          
     1152         bwGrid.display(); 
     1153       } 
     1154     ); 
     1155        
    9011156    } catch (e) { 
    9021157      alert(e); 
     
    9541209    } 
    9551210  }  
    956 }; 
    957  
    958 // **** ACTIONS **** 
    959 // now add some rollovers and onclick actions  
    960 // to the elements of the freebusy grid once the 
     1211   
     1212}; 
     1213 
     1214 
     1215//now add some interactions between the freebusy control buttons, 
     1216// the scheduling widget, and the rest of the form. once the 
    9611217// document is loaded 
    9621218$(document).ready(function() { 
    963   $("#bwScheduleTable .icon").hover( 
    964     function () { 
    965       $(this).next(".tip").fadeIn(100); 
    966     },  
    967     function () { 
    968       $(this).next(".tip").fadeOut(100); 
    969     } 
    970   );   
    971    
    972   $("#bwScheduleTable .activeCell").hover( 
    973     function () { 
    974       $(this).children(".tip").fadeIn(20); 
    975     },  
    976     function () { 
    977       $(this).children(".tip").fadeOut(20); 
    978     } 
    979   ); 
    980    
    981   $("#bwScheduleTable .fbcell").click ( 
    982     function () { 
    983       // clear all previous highlighting 
    984       $("#bwScheduleTable .highlight").removeClass("highlight"); 
    985        
    986       // get the id of the current cell - takes the form "1271947500000-attendeestring" 
    987       // we want the first half, which is the same as the time class associated with the column 
    988       var splitId = $(this).attr("id").split("-"); 
    989        
    990       // set the start of the selection range in milliseconds (first half of the ID) 
    991       // we will use this to set the start time and to find cells in the same column 
    992       var startSelectionMils = splitId[0]; 
    993       var endSelectionMils = Number(startSelectionMils) + Number(durationMils); 
    994        
    995       // now do the highlighting 
    996       $("#bwScheduleTable .fbcell").each(function(index) { 
    997         var splId = $(this).attr("id").split("-"); 
    998         if (splId[0] >= startSelectionMils && splId[0] < endSelectionMils) { 
    999           $(this).addClass("highlight"); 
    1000         } 
    1001       }); 
    1002        
    1003       // set the freeTimeIndex to the nearest index for the pickNext/previous buttons 
    1004       for (var i = 0; i < bwGrid.freeTime.length; i++) { 
    1005         if (Number(bwGrid.freeTime[i]) >= Number(startSelectionMils)) { 
    1006           bwGrid.freeTimeIndex = i - 1; // this will make pick previous jump an extra gap after clicking in a busy space, but it makes pick next work correctly in the same circumstance 
    1007           if (bwGrid.freeTimeIndex < 0) { 
    1008             bwGrid.freeTimeIndex = 0; 
    1009           } 
    1010           break; 
    1011         } 
    1012       } 
    1013        
    1014       bwGrid.setDateTimeWidgets(startSelectionMils); 
    1015    
    1016     } 
    1017   ); 
    1018    
    1019   /* 
    1020   $("#bwScheduleTable .fbcell").mousedown ( 
    1021     function () { 
    1022       // clear all previous highlighting 
    1023       $("#bwScheduleTable .highlight").removeClass("highlight"); 
    1024        
    1025       // get the id of the current cell - takes the form "1271947500000-attendeestring" 
    1026       // we want the first half, which is the same as the time class associated with the column 
    1027       var splitId = $(this).attr("id").split("-"); 
    1028        
    1029       // set the start of the selection range in milliseconds (first half of the ID) 
    1030       // we will use this to set the start time and to find cells in the same column 
    1031       startSelectionMils = splitId[0]; 
    1032        
    1033       // find the cells (the column) that share the same class 
    1034       $("#bwScheduleTable ." + startSelectionMils).addClass("highlight"); 
    1035        
    1036       // we are now selecting, so highlight as we go 
    1037       selecting = true;           
    1038     } 
    1039   ); 
    1040    
    1041   $("#bwScheduleTable .fbcell").mouseover ( 
    1042     function () { 
    1043       if (selecting) { 
    1044         // get the id of the current cell - takes the form "1271947500000-attendeestring" 
    1045         // we want the first half, which is the same as the time class associated with the column 
    1046         var splitId = $(this).attr("id").split("-"); 
    1047    
    1048         // find the cells (the column) that contain the first half as a class 
    1049         $("#bwScheduleTable ." + splitId[0]).addClass("highlight"); 
    1050       }           
    1051     } 
    1052   ); 
    1053    
    1054   $("#bwScheduleTable .fbcell").mouseup ( 
    1055     function () { 
    1056       // we are no longer selecting 
    1057       selecting = false; 
    1058        
    1059       // get the id of the current cell - takes the form "1271947500000-attendeestring" 
    1060       // we want the first half, which is the same as the time class associated with the column 
    1061       var splitId = $(this).attr("id").split("-"); 
    1062        
    1063       // set the end of the selection range in milliseconds (first half of the ID) 
    1064       // we will use this to set the end time / duration 
    1065       endSelectionMils = splitId[0]; 
    1066        
    1067     } 
    1068   ); 
    1069   */ 
    1070    
    1071   $("#bwScheduleTable #bwAddAttendee").click ( 
    1072     function () { 
    1073       if (this.value == bwAddAttendeeDisp) { 
    1074         this.value = ""; 
    1075       } 
    1076       $(this).addClass("active"); 
    1077       $(this).removeClass("pending"); 
    1078        
    1079       // hide advanced switch, show add button 
    1080       // $("#bwAddAttendeeAdvanced").hide(); 
    1081       changeClass("bwAddAttendeeAdd","visible"); 
    1082       changeClass("bwAddAttendeeFields", "visible"); 
    1083     } 
    1084   ); 
    1085    
    1086   // add attendee box - use jquery UI autocomplete 
    1087   // carddavUrl supplied in bedework.js 
    1088   // var carddavUrlTemp = "/ucalrsrc/themes/bedeworkTheme/javascript/addrbookUsers.js" 
    1089   // var carddavUrlTemp = "/ucalrsrc/themes/bedeworkTheme/javascript/addrbookLocations.js" 
    1090   $("#bwScheduleTable #bwAddAttendee").autocomplete({ 
    1091     minLength: 1, 
    1092     // set the data source, call it, and format the results: 
    1093     source: function(req, include) { 
    1094       // build the address book url; the path to the address book is determined by the 
    1095       // radio button choices in the "add attendee" widget - these are stored on the fly 
    1096       // in the hidden field with id bwCardDavBookPath 
    1097       addrBookUrl = carddavUrl + "?format=json&addrbook=" + $("#bwCardDavBookPath").val(); 
    1098        
    1099       // call the server and push the results into an array "items" 
    1100       $.getJSON(addrBookUrl, req, function(data) { 
    1101         var acResults = ""; 
    1102         if (data != undefined && data.microformats != undefined && data.microformats.vcard != undefined) { 
    1103           acResults = data.microformats.vcard; 
    1104         } 
    1105         var items = []; 
    1106         $.each(acResults, function(i,entry) { 
    1107            
    1108           // build the label from the full name and email address 
    1109           var curFn = ""; 
    1110           var curEmail = ""; 
    1111           var curLabel = ""; 
    1112           var curKind = ""; 
    1113            
    1114           if (entry.fn != undefined && entry.fn.value != undefined) { 
    1115             curFn = entry.fn.value; 
    1116           }  
    1117            
    1118           if (entry.kind != undefined && entry.kind.value != undefined) { 
    1119             curKind = entry.kind.value; 
    1120           } 
    1121            
    1122           if (curKind == "group") { 
    1123             if (entry.member != undefined && entry.member.length > 0) { 
    1124               var members = ""; 
    1125               for (var i = 0; i < entry.member.length; i++ ) { 
    1126                 members += entry.member[i].value + ","; 
    1127               } 
    1128               members = members.substring(0,members.length-1); 
    1129               var curItem = {label: curFn, value: members}; 
    1130               items.push(curItem); 
    1131             } 
    1132           } else { 
    1133             // this is probably not enough: we should account for all email addresses if there is no calendar uri 
    1134             if (entry.email != undefined && entry.email[0] != undefined && entry.email[0].value != undefined) { 
    1135               curEmail = entry.email[0].value; 
    1136             } 
    1137             if (curFn != "") { 
    1138               curLabel = curFn + ", " + curEmail; 
    1139             } else { 
    1140               curLabel = curEmail; 
    1141             } 
    1142              
    1143             // use the calendar address uri if available, otherwise use email 
    1144             var curUri = ""; 
    1145             if (entry.caladruri != undefined && entry.caladruri.value != undefined) { 
    1146               curUri = entry.caladruri.value; 
    1147             } 
    1148             if (curUri == "" && entry.email != undefined && entry.email[0] != undefined && entry.email[0].value != undefined) { 
    1149               var curEmail = entry.email[0].value; 
    1150               if (curEmail != "") { 
    1151                 curUri = "mailto:" + curEmail; 
    1152               } 
    1153             } 
    1154              
    1155             // only add the entry if there is a uri and a label to use 
    1156             if (curUri != "" && curLabel != "") { 
    1157               var curItem = {label: curLabel, value: curUri}; 
    1158               items.push(curItem); 
    1159             } 
    1160           } 
    1161         }); 
    1162          
    1163         // pass items to the callback function for display in the autocomplete pulldown 
    1164         include(items); 
    1165       }); 
    1166     } 
    1167   }); 
    1168    
    1169   // capture the enter key when entering an attendee; 
    1170   // do not submit the form; add the attendee. 
    1171   $("#bwScheduleTable #bwAddAttendee").keypress ( 
    1172       function (e) { 
    1173         if(e.keyCode == 13) { // enter 
    1174           e.preventDefault(); 
    1175           bwGrid.addAttendeeFromGrid(); 
    1176         } 
    1177       } 
    1178     ); 
    1179    
    1180   $("#bwScheduleTable #bwAddAttendeeAdd").click ( 
    1181     function () { 
    1182       bwGrid.addAttendeeFromGrid(); 
    1183     } 
    1184   ); 
    1185    
    1186    
    1187   $("#bwScheduleTable .removeAttendee").click ( 
    1188     function () { 
    1189       var i = $("#bwScheduleTable .removeAttendee").index(this); 
    1190       bwGrid.removeAttendee(i); 
    1191     } 
    1192   ); 
    1193    
    1194   // enable or disable an attendee 
    1195   $("#bwScheduleTable input.selectedToggle").click ( 
    1196     function () { 
    1197       var i = $("#bwScheduleTable input.selectedToggle").index(this); 
    1198       if (this.checked) { 
    1199          bwGrid.attendees[i].selected = true; 
    1200       } else { 
    1201          bwGrid.attendees[i].selected = false; 
    1202       } 
    1203        
    1204       bwGrid.display(); 
    1205     } 
    1206   ); 
    1207    
    1208   // now add some interactions between the freebusy control buttons, 
    1209   // the scheduling widget, and the rest of the form. 
    1210    
    12111219  // toggle 24 hour mode - can be done with text or with checkbox 
    12121220  // checkbox handler: