| | 901 | |
|---|
| | 902 | //**** ACTIONS **** |
|---|
| | 903 | //now add some rollovers and onclick actions |
|---|
| | 904 | //to the elements of the freebusy grid |
|---|
| | 905 | $("#bwScheduleTable .icon").hover( |
|---|
| | 906 | function () { |
|---|
| | 907 | $(this).next(".tip").fadeIn(100); |
|---|
| | 908 | }, |
|---|
| | 909 | function () { |
|---|
| | 910 | $(this).next(".tip").fadeOut(100); |
|---|
| | 911 | } |
|---|
| | 912 | ); |
|---|
| | 913 | |
|---|
| | 914 | $("#bwScheduleTable .activeCell").hover( |
|---|
| | 915 | function () { |
|---|
| | 916 | $(this).children(".tip").fadeIn(20); |
|---|
| | 917 | }, |
|---|
| | 918 | function () { |
|---|
| | 919 | $(this).children(".tip").fadeOut(20); |
|---|
| | 920 | } |
|---|
| | 921 | ); |
|---|
| | 922 | |
|---|
| | 923 | $("#bwScheduleTable .fbcell").click ( |
|---|
| | 924 | function () { |
|---|
| | 925 | // clear all previous highlighting |
|---|
| | 926 | $("#bwScheduleTable .highlight").removeClass("highlight"); |
|---|
| | 927 | |
|---|
| | 928 | // get the id of the current cell - takes the form "1271947500000-attendeestring" |
|---|
| | 929 | // we want the first half, which is the same as the time class associated with the column |
|---|
| | 930 | var splitId = $(this).attr("id").split("-"); |
|---|
| | 931 | |
|---|
| | 932 | // set the start of the selection range in milliseconds (first half of the ID) |
|---|
| | 933 | // we will use this to set the start time and to find cells in the same column |
|---|
| | 934 | var startSelectionMils = splitId[0]; |
|---|
| | 935 | var endSelectionMils = Number(startSelectionMils) + Number(durationMils); |
|---|
| | 936 | |
|---|
| | 937 | // now do the highlighting |
|---|
| | 938 | $("#bwScheduleTable .fbcell").each(function(index) { |
|---|
| | 939 | var splId = $(this).attr("id").split("-"); |
|---|
| | 940 | if (splId[0] >= startSelectionMils && splId[0] < endSelectionMils) { |
|---|
| | 941 | $(this).addClass("highlight"); |
|---|
| | 942 | } |
|---|
| | 943 | }); |
|---|
| | 944 | |
|---|
| | 945 | // set the freeTimeIndex to the nearest index for the pickNext/previous buttons |
|---|
| | 946 | for (var i = 0; i < bwGrid.freeTime.length; i++) { |
|---|
| | 947 | if (Number(bwGrid.freeTime[i]) >= Number(startSelectionMils)) { |
|---|
| | 948 | 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 |
|---|
| | 949 | if (bwGrid.freeTimeIndex < 0) { |
|---|
| | 950 | bwGrid.freeTimeIndex = 0; |
|---|
| | 951 | } |
|---|
| | 952 | break; |
|---|
| | 953 | } |
|---|
| | 954 | } |
|---|
| | 955 | |
|---|
| | 956 | bwGrid.setDateTimeWidgets(startSelectionMils); |
|---|
| | 957 | |
|---|
| | 958 | } |
|---|
| | 959 | ); |
|---|
| | 960 | |
|---|
| | 961 | /* |
|---|
| | 962 | $("#bwScheduleTable .fbcell").mousedown ( |
|---|
| | 963 | function () { |
|---|
| | 964 | // clear all previous highlighting |
|---|
| | 965 | $("#bwScheduleTable .highlight").removeClass("highlight"); |
|---|
| | 966 | |
|---|
| | 967 | // get the id of the current cell - takes the form "1271947500000-attendeestring" |
|---|
| | 968 | // we want the first half, which is the same as the time class associated with the column |
|---|
| | 969 | var splitId = $(this).attr("id").split("-"); |
|---|
| | 970 | |
|---|
| | 971 | // set the start of the selection range in milliseconds (first half of the ID) |
|---|
| | 972 | // we will use this to set the start time and to find cells in the same column |
|---|
| | 973 | startSelectionMils = splitId[0]; |
|---|
| | 974 | |
|---|
| | 975 | // find the cells (the column) that share the same class |
|---|
| | 976 | $("#bwScheduleTable ." + startSelectionMils).addClass("highlight"); |
|---|
| | 977 | |
|---|
| | 978 | // we are now selecting, so highlight as we go |
|---|
| | 979 | selecting = true; |
|---|
| | 980 | } |
|---|
| | 981 | ); |
|---|
| | 982 | |
|---|
| | 983 | $("#bwScheduleTable .fbcell").mouseover ( |
|---|
| | 984 | function () { |
|---|
| | 985 | if (selecting) { |
|---|
| | 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 | // find the cells (the column) that contain the first half as a class |
|---|
| | 991 | $("#bwScheduleTable ." + splitId[0]).addClass("highlight"); |
|---|
| | 992 | } |
|---|
| | 993 | } |
|---|
| | 994 | ); |
|---|
| | 995 | |
|---|
| | 996 | $("#bwScheduleTable .fbcell").mouseup ( |
|---|
| | 997 | function () { |
|---|
| | 998 | // we are no longer selecting |
|---|
| | 999 | selecting = false; |
|---|
| | 1000 | |
|---|
| | 1001 | // get the id of the current cell - takes the form "1271947500000-attendeestring" |
|---|
| | 1002 | // we want the first half, which is the same as the time class associated with the column |
|---|
| | 1003 | var splitId = $(this).attr("id").split("-"); |
|---|
| | 1004 | |
|---|
| | 1005 | // set the end of the selection range in milliseconds (first half of the ID) |
|---|
| | 1006 | // we will use this to set the end time / duration |
|---|
| | 1007 | endSelectionMils = splitId[0]; |
|---|
| | 1008 | |
|---|
| | 1009 | } |
|---|
| | 1010 | ); |
|---|
| | 1011 | */ |
|---|
| | 1012 | |
|---|
| | 1013 | $("#bwScheduleTable #bwAddAttendee").click ( |
|---|
| | 1014 | function () { |
|---|
| | 1015 | if (this.value == bwAddAttendeeDisp) { |
|---|
| | 1016 | this.value = ""; |
|---|
| | 1017 | } |
|---|
| | 1018 | $(this).addClass("active"); |
|---|
| | 1019 | $(this).removeClass("pending"); |
|---|
| | 1020 | |
|---|
| | 1021 | // hide advanced switch, show add button |
|---|
| | 1022 | // $("#bwAddAttendeeAdvanced").hide(); |
|---|
| | 1023 | changeClass("bwAddAttendeeAdd","visible"); |
|---|
| | 1024 | changeClass("bwAddAttendeeFields", "visible"); |
|---|
| | 1025 | } |
|---|
| | 1026 | ); |
|---|
| | 1027 | |
|---|
| | 1028 | // add attendee box - use jquery UI autocomplete |
|---|
| | 1029 | // carddavUrl supplied in bedework.js |
|---|
| | 1030 | // var carddavUrlTemp = "/ucalrsrc/themes/bedeworkTheme/javascript/addrbookUsers.js" |
|---|
| | 1031 | // var carddavUrlTemp = "/ucalrsrc/themes/bedeworkTheme/javascript/addrbookLocations.js" |
|---|
| | 1032 | $("#bwScheduleTable #bwAddAttendee").autocomplete({ |
|---|
| | 1033 | minLength: 1, |
|---|
| | 1034 | // set the data source, call it, and format the results: |
|---|
| | 1035 | source: function(req, include) { |
|---|
| | 1036 | // build the address book url; the path to the address book is determined by the |
|---|
| | 1037 | // radio button choices in the "add attendee" widget - these are stored on the fly |
|---|
| | 1038 | // in the hidden field with id bwCardDavBookPath |
|---|
| | 1039 | addrBookUrl = carddavUrl + "?format=json&addrbook=" + $("#bwCardDavBookPath").val(); |
|---|
| | 1040 | |
|---|
| | 1041 | // call the server and push the results into an array "items" |
|---|
| | 1042 | $.getJSON(addrBookUrl, req, function(data) { |
|---|
| | 1043 | var acResults = ""; |
|---|
| | 1044 | if (data != undefined && data.microformats != undefined && data.microformats.vcard != undefined) { |
|---|
| | 1045 | acResults = data.microformats.vcard; |
|---|
| | 1046 | } |
|---|
| | 1047 | var items = []; |
|---|
| | 1048 | $.each(acResults, function(i,entry) { |
|---|
| | 1049 | |
|---|
| | 1050 | // build the label from the full name and email address |
|---|
| | 1051 | var curFn = ""; |
|---|
| | 1052 | var curEmail = ""; |
|---|
| | 1053 | var curLabel = ""; |
|---|
| | 1054 | var curKind = ""; |
|---|
| | 1055 | |
|---|
| | 1056 | if (entry.fn != undefined && entry.fn.value != undefined) { |
|---|
| | 1057 | curFn = entry.fn.value; |
|---|
| | 1058 | } |
|---|
| | 1059 | |
|---|
| | 1060 | if (entry.kind != undefined && entry.kind.value != undefined) { |
|---|
| | 1061 | curKind = entry.kind.value; |
|---|
| | 1062 | } |
|---|
| | 1063 | |
|---|
| | 1064 | if (curKind == "group") { |
|---|
| | 1065 | if (entry.member != undefined && entry.member.length > 0) { |
|---|
| | 1066 | var members = ""; |
|---|
| | 1067 | for (var i = 0; i < entry.member.length; i++ ) { |
|---|
| | 1068 | members += entry.member[i].value + ","; |
|---|
| | 1069 | } |
|---|
| | 1070 | members = members.substring(0,members.length-1); |
|---|
| | 1071 | var curItem = {label: curFn, value: members}; |
|---|
| | 1072 | items.push(curItem); |
|---|
| | 1073 | } |
|---|
| | 1074 | } else { |
|---|
| | 1075 | // this is probably not enough: we should account for all email addresses if there is no calendar uri |
|---|
| | 1076 | if (entry.email != undefined && entry.email[0] != undefined && entry.email[0].value != undefined) { |
|---|
| | 1077 | curEmail = entry.email[0].value; |
|---|
| | 1078 | } |
|---|
| | 1079 | if (curFn != "") { |
|---|
| | 1080 | curLabel = curFn + ", " + curEmail; |
|---|
| | 1081 | } else { |
|---|
| | 1082 | curLabel = curEmail; |
|---|
| | 1083 | } |
|---|
| | 1084 | |
|---|
| | 1085 | // use the calendar address uri if available, otherwise use email |
|---|
| | 1086 | var curUri = ""; |
|---|
| | 1087 | if (entry.caladruri != undefined && entry.caladruri.value != undefined) { |
|---|
| | 1088 | curUri = entry.caladruri.value; |
|---|
| | 1089 | } |
|---|
| | 1090 | if (curUri == "" && entry.email != undefined && entry.email[0] != undefined && entry.email[0].value != undefined) { |
|---|
| | 1091 | var curEmail = entry.email[0].value; |
|---|
| | 1092 | if (curEmail != "") { |
|---|
| | 1093 | curUri = "mailto:" + curEmail; |
|---|
| | 1094 | } |
|---|
| | 1095 | } |
|---|
| | 1096 | |
|---|
| | 1097 | // only add the entry if there is a uri and a label to use |
|---|
| | 1098 | if (curUri != "" && curLabel != "") { |
|---|
| | 1099 | var curItem = {label: curLabel, value: curUri}; |
|---|
| | 1100 | items.push(curItem); |
|---|
| | 1101 | } |
|---|
| | 1102 | } |
|---|
| | 1103 | }); |
|---|
| | 1104 | |
|---|
| | 1105 | // pass items to the callback function for display in the autocomplete pulldown |
|---|
| | 1106 | include(items); |
|---|
| | 1107 | }); |
|---|
| | 1108 | } |
|---|
| | 1109 | }); |
|---|
| | 1110 | |
|---|
| | 1111 | // capture the enter key when entering an attendee; |
|---|
| | 1112 | // do not submit the form; add the attendee. |
|---|
| | 1113 | $("#bwScheduleTable #bwAddAttendee").keypress ( |
|---|
| | 1114 | function (e) { |
|---|
| | 1115 | if(e.keyCode == 13) { // enter |
|---|
| | 1116 | e.preventDefault(); |
|---|
| | 1117 | bwGrid.addAttendeeFromGrid(); |
|---|
| | 1118 | } |
|---|
| | 1119 | } |
|---|
| | 1120 | ); |
|---|
| | 1121 | |
|---|
| | 1122 | $("#bwScheduleTable #bwAddAttendeeAdd").click ( |
|---|
| | 1123 | function () { |
|---|
| | 1124 | bwGrid.addAttendeeFromGrid(); |
|---|
| | 1125 | } |
|---|
| | 1126 | ); |
|---|
| | 1127 | |
|---|
| | 1128 | |
|---|
| | 1129 | $("#bwScheduleTable .removeAttendee").click ( |
|---|
| | 1130 | function () { |
|---|
| | 1131 | var i = $("#bwScheduleTable .removeAttendee").index(this); |
|---|
| | 1132 | bwGrid.removeAttendee(i); |
|---|
| | 1133 | } |
|---|
| | 1134 | ); |
|---|
| | 1135 | |
|---|
| | 1136 | // enable or disable an attendee |
|---|
| | 1137 | $("#bwScheduleTable input.selectedToggle").click ( |
|---|
| | 1138 | function () { |
|---|
| | 1139 | var i = $("#bwScheduleTable input.selectedToggle").index(this); |
|---|
| | 1140 | if (this.checked) { |
|---|
| | 1141 | bwGrid.attendees[i].selected = true; |
|---|
| | 1142 | } else { |
|---|
| | 1143 | bwGrid.attendees[i].selected = false; |
|---|
| | 1144 | } |
|---|
| | 1145 | |
|---|
| | 1146 | bwGrid.display(); |
|---|
| | 1147 | } |
|---|
| | 1148 | ); |
|---|
| | 1149 | |
|---|
| 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 | | |
|---|