Changeset 6891 for sandbox/2.4.2-expresso1/prototype/modules/calendar/js
- Timestamp:
- 07/27/12 14:47:35 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.codecs.js
r6885 r6891 1074 1074 1075 1075 return notArray ? res[0] : res; 1076 } 1077 1078 }); 1079 1080 1081 DataLayer.codec( "schedulable", "print", { 1082 1083 decoder: function( evtObj ){ 1084 1085 }, 1086 1087 1088 encoder: function( evtObj ){ 1089 1090 if(!(!!evtObj)) 1091 return undefined; 1092 1093 var notArray = false; 1094 1095 if( notArray = $.type(evtObj) !== "array" ) 1096 evtObj = [ evtObj ]; 1097 1098 var pref = User.preferences; 1099 var res = []; 1100 1101 for(var i = 0; i < evtObj.length; i++){ 1102 res.push(DataLayer.encode('schedulable:' + (evtObj[i].type == '1' ? 'preview' : 'task'), evtObj[i])); 1103 } 1104 1105 if( !notArray ){ 1106 var dates = {}; 1107 1108 var typeRepeat = { 1109 'none': false, 1110 'daily': 'Repetição diária', 1111 'weekly': 'Repetição semanal', 1112 'monthly': 'Repetição mensal', 1113 'yearly': 'repetição anual' 1114 } 1115 1116 for (var i=0; i < res.length; i++) { 1117 var startDate = Date.parseExact( res[i]['startDate'], User.preferences.dateFormat ); 1118 var endDate = Date.parseExact( res[i]['endDate'], User.preferences.dateFormat ); 1119 1120 var duration = parseInt( endDate.getTime() ) - parseInt( startDate.getTime() ); 1121 1122 var occurrences = [ startDate.getTime() ]; 1123 1124 if( res[i].occurrences ) 1125 { 1126 occurrences = res[i].occurrences; 1127 } 1128 1129 for( var ii = 0; ii < occurrences.length; ii++ ) 1130 { 1131 var currentDate = new Date( occurrences[ii] ); 1132 var counter = currentDate.clone(); 1133 1134 var res2 = $.extend( {}, res[i], { 1135 'startDate': currentDate.toString( User.preferences.dateFormat ), 1136 'endDate': new Date( occurrences[ii] + duration ).toString( User.preferences.dateFormat ) 1137 }); 1138 1139 if(res[i].repeat) 1140 res2.repeat = typeRepeat[res[i].repeat.frequency]; 1141 1142 var index = dateCalendar.dayNames[counter.getDay()] +' '+counter.toString('dd/MM'); 1143 1144 if(!dates[index] || !$.isArray(dates[index].events)) 1145 dates[index] = {events: []}; 1146 1147 dates[index].events.push(res2); 1148 1149 } 1150 } 1151 1152 var calendarView = $('#calendar').fullCalendar('getView'); 1153 var start = calendarView.visStart.getTime(); 1154 var end = calendarView.visEnd.getTime(); 1155 var next = start; 1156 var response = []; 1157 1158 while (next){ 1159 var index = dateCalendar.dayNames[new Date(next).getDay()] +' '+ new Date(next).toString('dd/MM'); 1160 1161 var event = {}; 1162 event[index] = {events: dates[index] ? dates[index].events : false}; 1163 1164 response[response.length] = event; 1165 next = (next + 86400000) > end ? false : (next + 86400000); 1166 } 1167 1168 1169 res = {events: response}; 1170 } 1171 1172 return notArray ? res[0] : res; 1076 1173 } 1077 1174
Note: See TracChangeset
for help on using the changeset viewer.