Changeset 8040
- Timestamp:
- 03/19/13 16:16:18 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/js/helpers.js
r8031 r8040 1006 1006 dateSameValue(); 1007 1007 1008 var fixHour = function(){ 1009 currentTimeStart = UI.dialogs.addEvent.find("input.start-time").val(); 1010 UI.dialogs.addEvent.find("input.start-time").val(currentTimeStart.replace(".","").replace(".","")); 1011 } 1008 1012 1009 1013 var setTime = function( selectedDateTime ) { … … 1015 1019 1016 1020 if( Date.parse(selectedDateTime) < Date.parse(oldTime) ) return true; 1017 1021 1018 1022 var time = selectedDateTime.split(":"); 1019 1023 … … 1031 1035 var minutes = dt.getMinutes().toString(); 1032 1036 var hours = dt.getHours(); 1033 1037 UI.dialogs.addEvent.find("input.start-time").val(selectedDateTime.replace(".","").replace(".","")); 1038 1039 1034 1040 if (time[1].indexOf("p.m.") != -1 ) { 1035 1041 var startHours = startHours == 12 ? 12 : startHours; … … 1048 1054 var startHours = startHours == 12 ? 00 : startHours; 1049 1055 } 1050 dtFormat = (time[1].indexOf("p.m.") != -1 || time[1].indexOf("a.m.") != -1) ? ((((User.preferences.defaultDuration / 60) + startHours) >= 12 && (startHours + 4) < 24) ? " pm" : " am") : ""; 1056 1057 1058 dtFormat = (time[1].indexOf("p.m.") != -1 || time[1].indexOf("a.m.") != -1) ? ((((User.preferences.defaultDuration / 60) + startHours) >= 12 && (startHours + (User.preferences.defaultDuration / 60)) < 24) ? " pm" : " am") : ""; 1051 1059 1052 1060 var newHours = ""; … … 1089 1097 timeFormat: "hh:mm tt", 1090 1098 onSelect: function( selectedDateTime ){ 1099 1100 if ( selectedDateTime.indexOf("p.m.") == -1 || !selectedDateTime.indexOf("a.m.") == -1 ) { 1101 1102 var selectedTime = selectedDateTime.split(":"); 1103 var endTime = UI.dialogs.addEvent.find(".end-time").val(); 1104 endTime = endTime.split(":"); 1105 1106 var t1 = new Date(false,false,false,selectedTime[0],selectedTime[1],false); 1107 var t2 = new Date(false,false,false,endTime[0],endTime[1],false); 1108 1109 if (t1 < t2) return true; 1110 } 1111 1091 1112 setTime( selectedDateTime ); 1092 } 1113 }, 1114 onClose : function (selectedDateTime){ 1115 fixHour(); 1116 } 1117 1093 1118 }); 1094 1119 1095 1120 } 1096 1121 1097 UI.dialogs.addEvent.find('input. time').timepicker({1122 UI.dialogs.addEvent.find('input.end-time').timepicker({ 1098 1123 closeText: 'Ok', 1099 1124 hourGrid: 4, … … 1107 1132 $(this).val(selectedDateTime.replace(/[\.]/gi, "")); 1108 1133 updateMap(); 1134 1135 if ( selectedDateTime.indexOf("p.m.") == -1 || !selectedDateTime.indexOf("a.m.") == -1 ) { 1136 var startT = UI.dialogs.addEvent.find('input.start-time'); 1137 1138 var lessZeroTime = function( sTime ) { 1139 sTime = sTime.split(":"); 1140 sTime = new Date(false,false,false,sTime[0],sTime[1],false); 1141 sTimeReady = parseInt(sTime.getHours() - (User.preferences.defaultDuration / 60)); 1142 1143 if( sTimeReady < 0 ) 1144 return false; // If the value is less than 0, return false. 1145 1146 return sTimeReady.toString().length == 1 ? "0"+sTimeReady+":00" : sTimeReady+":00"; 1147 } 1148 1149 var hEnd = new Date(false,false,false,selectedDateTime.split(":")[0],selectedDateTime.split(":")[1],false); 1150 var hStart = new Date(false,false,false,startT.val().split(":")[0],startT.val().split(":")[1],false); 1151 1152 if ( hEnd <= hStart ){ 1153 var lessTime = lessZeroTime( selectedDateTime ); 1154 if ( !lessTime ){ 1155 startT.val( "00:00" ); 1156 return true; 1157 } 1158 startT.val( lessTime ); 1159 } 1160 } 1109 1161 }, 1110 1162 onClose : function (selectedDateTime){ 1111 1163 if(!(User.preferences.hourFormat.length == 5)) 1112 1164 $(this).val(selectedDateTime.replace(/[\.]/gi, "")); 1165 fixHour(); 1113 1166 }, 1167 1114 1168 beforeShow: function (selectedDateTime) { 1115 1169 if ((selectedDateTime.value == '__:__') || (selectedDateTime.value == '__:__ __'))
Note: See TracChangeset
for help on using the changeset viewer.