[5515] | 1 | function formatBytes(bytes) { |
---|
[6044] | 2 | if (bytes >= 1000000000) { |
---|
| 3 | return (bytes / 1000000000).toFixed(2) + ' GB'; |
---|
| 4 | } |
---|
| 5 | if (bytes >= 1000000) { |
---|
| 6 | return (bytes / 1000000).toFixed(2) + ' MB'; |
---|
| 7 | } |
---|
| 8 | if (bytes >= 1000) { |
---|
| 9 | return (bytes / 1000).toFixed(2) + ' KB'; |
---|
| 10 | } |
---|
| 11 | return bytes + ' B'; |
---|
[5515] | 12 | }; |
---|
| 13 | |
---|
[5341] | 14 | function validDateEvent(){ |
---|
[6444] | 15 | |
---|
| 16 | var errors = { |
---|
| 17 | 'emptyInitData': 'Por favor, informe uma data inicial', |
---|
| 18 | 'emptyEndData': 'Por favor, informe uma data final', |
---|
| 19 | 'emptyInitHour': 'Por favor, informe uma hora inicial', |
---|
| 20 | 'emptyEndHour': 'Por favor, informe uma hora final', |
---|
| 21 | |
---|
| 22 | 'invalidInitData' : 'Data inicial inválida', |
---|
| 23 | 'invalidEndData' : 'Data final inválida', |
---|
| 24 | |
---|
| 25 | 'equalData' : 'Hora inicial igual a final', |
---|
[6552] | 26 | 'theirData' : 'Data final menor que a inicial', |
---|
| 27 | 'theirHour' : 'Hora final menor que a inicial', |
---|
[6444] | 28 | |
---|
| 29 | 'emptyOcurrence' : 'Por favor, informe o número de ocorrências', |
---|
| 30 | 'invalidOcurrence' : 'Por favor, informe um valor válido para a quantidade de ocorrências', |
---|
| 31 | |
---|
| 32 | 'emptyInterval' : 'Por favor, informe o intervalo', |
---|
| 33 | 'invalidInterval' : 'Por favor informe um valor válido para o intervalo' |
---|
| 34 | }; |
---|
| 35 | |
---|
[6044] | 36 | var start_date = $(".new-event-win.active .start-date").val(); |
---|
| 37 | var end_date = $(".new-event-win.active .end-date").val(); |
---|
| 38 | var start_time = $(".new-event-win.active .start-time").val(); |
---|
| 39 | var end_time = $(".new-event-win.active .end-time").val(); |
---|
| 40 | var isAllDay = $('.new-event-win.active input[name="allDay"]').is(':checked'); |
---|
[6077] | 41 | var customDate = $(".endRepeat").val() == "customDate"; |
---|
| 42 | var occurrences = $(".endRepeat").val() == "occurrences"; |
---|
[6087] | 43 | var eventInterval = $('.eventInterval').val(); |
---|
| 44 | |
---|
[6044] | 45 | if(start_date == "") |
---|
[6444] | 46 | return errors['emptyInitData']; |
---|
[6044] | 47 | else if(end_date == "") |
---|
[6444] | 48 | return errors['emptyEndData']; |
---|
[6044] | 49 | else if(!isAllDay && start_time == "") |
---|
[6444] | 50 | return errors['emptyInitHour']; |
---|
[6044] | 51 | else if(!isAllDay && end_time == "") |
---|
[6444] | 52 | return errors['emptyEndHour']; |
---|
[5341] | 53 | |
---|
[6444] | 54 | var formatString = User.preferences.dateFormat + " " + User.preferences.hourFormat; |
---|
[5409] | 55 | |
---|
[6444] | 56 | var startDate = Date.parseExact( start_date + " " + $.trim(start_time) , formatString ); |
---|
| 57 | var endDate = Date.parseExact( end_date + " " + $.trim(end_time) , formatString ); |
---|
[5510] | 58 | |
---|
[6044] | 59 | if(startDate == null || startDate.getTime() < 0 ) |
---|
[6444] | 60 | return errors['invalidInitData']; |
---|
[6044] | 61 | if(endDate == null || endDate.getTime() < 0) |
---|
[6444] | 62 | return errors['invalidEndData']; |
---|
[5341] | 63 | |
---|
[6444] | 64 | if(isAllDay){ |
---|
| 65 | startDate.clearTime(); |
---|
| 66 | endDate.clearTime(); |
---|
| 67 | if(endDate.compareTo(startDate) == -1) |
---|
| 68 | return errors['theirData']; |
---|
| 69 | }else{ |
---|
[6552] | 70 | var condition = endDate.compareTo(startDate); |
---|
| 71 | if(condition != 1){ |
---|
| 72 | if(condition < 0){ |
---|
| 73 | startDate.clearTime(); |
---|
| 74 | endDate.clearTime(); |
---|
| 75 | condition = endDate.compareTo(startDate); |
---|
| 76 | return (errors[ condition == 0 ? 'theirHour' : 'theirData'] ); |
---|
| 77 | } |
---|
| 78 | else |
---|
| 79 | return errors['equalData']; |
---|
| 80 | } |
---|
[6444] | 81 | } |
---|
[6077] | 82 | |
---|
[6444] | 83 | if (customDate) |
---|
| 84 | if ( !($('.new-event-win.active .customDateEnd').val().length) ) |
---|
| 85 | return errors['emptyEndData']; |
---|
| 86 | |
---|
[6077] | 87 | if (occurrences){ |
---|
[6444] | 88 | if ( !($('.occurrencesEnd').val().length) ) |
---|
| 89 | return errors['emptyOcurrence']; |
---|
| 90 | else if (parseInt($('.occurrencesEnd').val(),10) <= 0 || parseInt($('.occurrencesEnd').val(),10).toString() == "NaN") |
---|
| 91 | return errors['invalidOcurrence']; |
---|
| 92 | } |
---|
[6087] | 93 | |
---|
| 94 | if (!($('.new-event-win.active p.input-group.finish_event.repeat-in').hasClass('hidden'))){ |
---|
| 95 | if (!eventInterval.length) |
---|
[6444] | 96 | return errors['emptyInterval']; |
---|
[6346] | 97 | else if (parseInt(eventInterval,10) < 1 || parseInt(eventInterval,10).toString() == "NaN") |
---|
[6444] | 98 | return errors['invalidInterval']; |
---|
[6087] | 99 | } |
---|
[6044] | 100 | return false; |
---|
[5341] | 101 | } |
---|
| 102 | |
---|
[6996] | 103 | function printNow(){ |
---|
[7022] | 104 | if($("#calendar").fullCalendar('getView').name == "agendaWeek" || $("#calendar").fullCalendar('getView').name == "basicWeek" || $("#calendar").fullCalendar('getView').name == "year") |
---|
| 105 | alert('A tela de impressão será melhor visualizada com a preferência "Paisagem" do seu browser selecionada.'); |
---|
| 106 | |
---|
[6996] | 107 | var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); |
---|
| 108 | window_print.document.open(); |
---|
| 109 | |
---|
| 110 | var start = $("#calendar").fullCalendar('getView').visStart.getTime()/1000; |
---|
| 111 | var end = $("#calendar").fullCalendar('getView').visEnd.getTime()/1000; |
---|
| 112 | var criteria = DataLayer.criteria("schedulable:calendar", {'start':start, 'end':end} ); |
---|
| 113 | |
---|
[8028] | 114 | var data = DataLayer.encode('schedulable:print', DataLayer.dispatch('modules/calendar/schedules', criteria ) ); |
---|
| 115 | |
---|
[6996] | 116 | if($("#calendar").fullCalendar('getView').name == "month"){ |
---|
| 117 | window_print.document.write(DataLayer.render('templates/calendar_month_print.ejs', { |
---|
| 118 | 'InfoPage' : $("#calendar").fullCalendar('getView').title, |
---|
| 119 | 'days' : data |
---|
| 120 | } )); |
---|
| 121 | } |
---|
[7022] | 122 | if($("#calendar").fullCalendar('getView').name == "agendaDay" || $("#calendar").fullCalendar('getView').name == "basicDay"){ |
---|
[6996] | 123 | window_print.document.write(DataLayer.render('templates/calendar_day_print.ejs', { |
---|
| 124 | 'InfoPage' : $("#calendar").fullCalendar('getView').title, |
---|
| 125 | 'days' : data |
---|
| 126 | } )); |
---|
| 127 | } |
---|
[7022] | 128 | if($("#calendar").fullCalendar('getView').name == "agendaWeek" || $("#calendar").fullCalendar('getView').name == "basicWeek"){ |
---|
[6996] | 129 | window_print.document.write(DataLayer.render('templates/calendar_week_print.ejs', { |
---|
| 130 | 'InfoPage' : $("#calendar").fullCalendar('getView').title, |
---|
| 131 | 'days' : data |
---|
| 132 | })); |
---|
| 133 | |
---|
| 134 | var aux = 0; |
---|
| 135 | setTimeout(function(){$(window_print.document).find(".all-day").each(function(){ |
---|
| 136 | if($(this).height() > aux) |
---|
| 137 | aux = $(this).height(); |
---|
| 138 | }); |
---|
| 139 | $(window_print.document).find(".all-day").each(function(){ |
---|
| 140 | $(this).height(aux); |
---|
| 141 | }); |
---|
| 142 | $(window_print.document).find(".all-day-line .write").height(aux); |
---|
| 143 | aux = 0; |
---|
| 144 | },20); |
---|
| 145 | } |
---|
| 146 | if($("#calendar").fullCalendar('getView').name == "year"){ |
---|
| 147 | window_print.document.write(DataLayer.render('templates/calendar_year_print.ejs', { |
---|
| 148 | 'html' : $('#calendar .fc-content').html(), |
---|
| 149 | 'header': $('#calendar').find('.fc-header-center h2').text() |
---|
| 150 | } )); |
---|
| 151 | } |
---|
| 152 | window_print.document.close(); |
---|
[7022] | 153 | window_print.print(); |
---|
[6996] | 154 | } |
---|
| 155 | |
---|
| 156 | function printEvents(){ |
---|
| 157 | //var html = DataLayer.render( path + 'templates/attendee_permissions.ejs', {} ); |
---|
[8020] | 158 | var print = $('.fc-header-right').find('.fc-button.fc-button-year').clone(); |
---|
[6996] | 159 | |
---|
[5341] | 160 | $('.fc-header-right').find('.fc-button-year').toggleClass('fc-corner-right'); |
---|
[6996] | 161 | print.addClass('fc-corner-right'); |
---|
| 162 | print.addClass('fc-button-print'); |
---|
[8020] | 163 | print.removeClass('fc-button-year'); |
---|
[6996] | 164 | print.removeClass('fc-corner-left'); |
---|
[8020] | 165 | print.removeClass('fc-state-active'); |
---|
[6996] | 166 | print.find('.fc-button-content').html('Imprimir'); |
---|
| 167 | $('.fc-header-right').append(print); |
---|
| 168 | $('.fc-button-print').click(function(){ |
---|
| 169 | printNow(); |
---|
| 170 | }); |
---|
[5341] | 171 | } |
---|
[5514] | 172 | |
---|
[5746] | 173 | /* |
---|
| 174 | * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do |
---|
| 175 | *DataLayer, repeat somente é usado quando se trata da criação de um evento |
---|
| 176 | *pela edição de uma ocorrência. |
---|
| 177 | */ |
---|
| 178 | |
---|
| 179 | function eventDetails( objEvent, decoded, path, isMail, repeat) |
---|
[5341] | 180 | { |
---|
[6996] | 181 | $('.qtip.qtip-blue').remove(); |
---|
| 182 | |
---|
[6044] | 183 | attendees = {}; |
---|
[7983] | 184 | |
---|
| 185 | if(!!objEvent.participants) |
---|
| 186 | { |
---|
| 187 | $.each(objEvent.participants ,function(index, value) { |
---|
[7991] | 188 | |
---|
[7983] | 189 | var part = DataLayer.get('participant' , value ); |
---|
| 190 | var user = DataLayer.get('user' , part.user ); |
---|
| 191 | |
---|
| 192 | attendees[part.user] = user.name; |
---|
| 193 | }); |
---|
| 194 | } |
---|
| 195 | |
---|
[6044] | 196 | if(path == undefined) |
---|
| 197 | path = ""; |
---|
[5389] | 198 | |
---|
[6044] | 199 | if( !decoded ) |
---|
| 200 | objEvent = DataLayer.decode( "schedulable:calendar", objEvent ); |
---|
[5341] | 201 | |
---|
[6044] | 202 | if(!isMail) |
---|
| 203 | objEvent = DataLayer.encode( "schedulable:preview", objEvent ); |
---|
[5341] | 204 | |
---|
[6044] | 205 | if(typeof(objEvent.id) == 'undefined'){ |
---|
| 206 | objEvent.alarms = Calendar.signatureOf[User.preferences.defaultCalendar || Calendar.calendarIds[0]].defaultAlarms || false; |
---|
| 207 | objEvent.useAlarmDefault = 1; |
---|
| 208 | } |
---|
[5341] | 209 | |
---|
[6044] | 210 | /** |
---|
[5341] | 211 | * canDiscardEventDialog deve ser true se não houver alterações no evento |
---|
| 212 | */ |
---|
[6044] | 213 | canDiscardEventDialog = true; |
---|
| 214 | /** |
---|
[5341] | 215 | * zebraDiscardEventDialog é uma flag indicando que uma janela de confirmação (Zebra_Dialog) |
---|
| 216 | * já está aberta na tela, uma vez que não é possivel acessar o evento ESC utilizado para fechá-la |
---|
| 217 | */ |
---|
[6044] | 218 | zebraDiscardEventDialog = false; |
---|
[5341] | 219 | |
---|
[6044] | 220 | /** |
---|
[5514] | 221 | ACLs do participant |
---|
| 222 | */ |
---|
[6044] | 223 | acl_names = { |
---|
| 224 | 'w': 'acl-white', |
---|
| 225 | 'i': 'acl-invite-guests', |
---|
| 226 | 'p': 'acl-participation-required' |
---|
| 227 | }; |
---|
[6103] | 228 | |
---|
| 229 | var dependsDelegate = function(reference, inverse){ |
---|
| 230 | if(inverse){ |
---|
| 231 | if(reference.find('input[name="attendee[]"]').val() == blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val()) |
---|
| 232 | blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val()); |
---|
| 233 | }else{ |
---|
| 234 | if(blkAddAtendee.find('.me input[name="attendee[]"]').val() == blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val()) |
---|
| 235 | blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val(reference.find('input[name="attendee[]"]').val()); |
---|
| 236 | } |
---|
[5636] | 237 | |
---|
[6103] | 238 | }; |
---|
| 239 | |
---|
| 240 | var removeOthers = function(){ |
---|
| 241 | var other = blkAddAtendee.find('.delegate.attendee-permissions-change-button'); |
---|
| 242 | if(other.lenght){ |
---|
| 243 | dependsDelegate(other.parents('li'), true); |
---|
| 244 | } |
---|
| 245 | blkAddAtendee.find('.delegate').removeClass('attendee-permissions-change-button'); |
---|
| 246 | blkAddAtendee.find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change'); |
---|
| 247 | |
---|
| 248 | }; |
---|
| 249 | |
---|
[6044] | 250 | var callbackAttendee = function(){ |
---|
| 251 | //Cria qtip de permissões pelo click do checkbox |
---|
| 252 | var checked = false; |
---|
| 253 | blkAddAtendee.find("li.not-attendee").addClass('hidden'); |
---|
[5514] | 254 | |
---|
[6044] | 255 | blkAddAtendee.find("li .button").filter(".close.new").button({ |
---|
| 256 | icons: { |
---|
| 257 | primary: "ui-icon-close" |
---|
| 258 | }, |
---|
| 259 | text: false |
---|
| 260 | }).click(function () { |
---|
[7997] | 261 | var participant = DataLayer.get('participant' , $(this).parents('li').find('[type=checkbox]').val()); |
---|
| 262 | DataLayer.remove('participant', participant.id); |
---|
| 263 | |
---|
[6044] | 264 | if($(this).parent().find('.button.delegate').hasClass('attendee-permissions-change-button')){ |
---|
[6103] | 265 | removeOthers(); |
---|
[6044] | 266 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 267 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
[5530] | 268 | |
---|
[6044] | 269 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 270 | } |
---|
[7996] | 271 | |
---|
[6044] | 272 | $(this).parents('li').remove(); |
---|
[5530] | 273 | |
---|
[6044] | 274 | if(blkAddAtendee.find(".attendee-list li").length == 1) |
---|
| 275 | blkAddAtendee.find("li.not-attendee").removeClass('hidden'); |
---|
[7997] | 276 | delete attendees[participant.user]; |
---|
[6044] | 277 | }) |
---|
| 278 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 279 | .removeClass('new').end() |
---|
[5514] | 280 | |
---|
[6044] | 281 | .filter(".delegate.new").button({ |
---|
| 282 | icons: { |
---|
| 283 | primary: "ui-icon-transferthick-e-w" |
---|
| 284 | }, |
---|
| 285 | text: false |
---|
| 286 | }).click(function () { |
---|
[6103] | 287 | var me = $(this).parents('li'); |
---|
[6044] | 288 | if($(this).hasClass('attendee-permissions-change-button')){ |
---|
| 289 | $(this).removeClass('attendee-permissions-change-button') |
---|
[6103] | 290 | .find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change').end(); |
---|
| 291 | |
---|
| 292 | me.find('input[name="delegatedFrom[]"]').val(''); |
---|
| 293 | dependsDelegate(me, true); |
---|
[5514] | 294 | |
---|
[6044] | 295 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 296 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
[6103] | 297 | |
---|
[6044] | 298 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
[5514] | 299 | |
---|
[6044] | 300 | }else{ |
---|
[6103] | 301 | removeOthers(); |
---|
[5514] | 302 | |
---|
[6044] | 303 | $(this).addClass('attendee-permissions-change-button') |
---|
| 304 | .find('.ui-icon-transferthick-e-w').addClass('attendee-permissions-change').end(); |
---|
[6103] | 305 | |
---|
| 306 | me.find('input[name="delegatedFrom[]"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val()); |
---|
| 307 | |
---|
| 308 | dependsDelegate(me, false); |
---|
[5514] | 309 | |
---|
[6044] | 310 | blkAddAtendee.find('.request-update').removeClass('hidden'); |
---|
| 311 | if(blkAddAtendee.find('.status option.hidden').length == 1) |
---|
| 312 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
[5514] | 313 | |
---|
[6044] | 314 | blkAddAtendee.find('option[value=5]').attr('selected','selected').trigger('change'); |
---|
| 315 | } |
---|
| 316 | }) |
---|
| 317 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 318 | .removeClass('new').end() |
---|
[5514] | 319 | |
---|
[6044] | 320 | .filter(".edit.new").button({ |
---|
| 321 | icons: { |
---|
| 322 | primary: "ui-icon-key" |
---|
| 323 | }, |
---|
| 324 | text: false |
---|
| 325 | }).click(function() { |
---|
[5514] | 326 | |
---|
[6044] | 327 | if(!!!checked) |
---|
| 328 | $(this).parents('li').find('[type=checkbox]').attr('checked', (!$(this).parent().find('[type=checkbox]').is(':checked'))).end(); |
---|
[5514] | 329 | |
---|
[6044] | 330 | var aclsParticipant = $(this).parents('li').find('input[name="attendeeAcl[]"]').val(); |
---|
| 331 | checked = false; |
---|
[5514] | 332 | |
---|
[6044] | 333 | if( $('.qtip.qtip-blue.qtip-active').val() !== ''){ |
---|
| 334 | blkAddAtendee.find('dd.attendee-list').qtip({ |
---|
| 335 | show: { |
---|
| 336 | ready: true, |
---|
| 337 | solo: true, |
---|
| 338 | when: { |
---|
| 339 | event: 'click' |
---|
| 340 | } |
---|
| 341 | }, |
---|
| 342 | hide: false, |
---|
| 343 | content: { |
---|
[6718] | 344 | text: $('<div></div>').html( DataLayer.render( path + 'templates/attendee_permissions.ejs', {} ) ), |
---|
[6044] | 345 | title: { |
---|
| 346 | text:'Permissões', |
---|
| 347 | button: '<a class="button close" href="#">close</a>' |
---|
| 348 | } |
---|
| 349 | }, |
---|
| 350 | style: { |
---|
| 351 | name: 'blue', |
---|
| 352 | tip: { |
---|
| 353 | corner: 'leftMiddle' |
---|
| 354 | }, |
---|
| 355 | border: { |
---|
| 356 | width: 4, |
---|
| 357 | radius: 8 |
---|
| 358 | }, |
---|
| 359 | width: { |
---|
| 360 | min: 230, |
---|
| 361 | max:230 |
---|
| 362 | } |
---|
| 363 | }, |
---|
| 364 | position: { |
---|
| 365 | corner: { |
---|
| 366 | target: 'rightMiddle', |
---|
| 367 | tooltip: 'leftMiddle' |
---|
| 368 | }, |
---|
| 369 | adjust: { |
---|
| 370 | x:0, |
---|
| 371 | y:0 |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | }) |
---|
| 375 | .qtip("api").onShow = function(arg0) { |
---|
| 376 | $('.qtip-active .button.close').button({ |
---|
| 377 | icons: { |
---|
| 378 | primary: "ui-icon-close" |
---|
| 379 | }, |
---|
| 380 | text: false |
---|
| 381 | }) |
---|
| 382 | .click(function(){ |
---|
| 383 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 384 | }); |
---|
[5514] | 385 | |
---|
[6044] | 386 | $('.qtip-active .button.save').button().click(function(){ |
---|
[5514] | 387 | |
---|
[6044] | 388 | var acl = ''; |
---|
| 389 | $('.qtip-active').find('[type=checkbox]:checked').each(function(i, obj) { |
---|
| 390 | acl+= obj.value; |
---|
| 391 | }); |
---|
[5514] | 392 | |
---|
[6044] | 393 | blkAddAtendee.find('dd.attendee-list [type=checkbox]:checked').siblings('input[name="attendeeAcl[]"]').each(function(i, obj) { |
---|
| 394 | obj.value = 'r'+acl; |
---|
| 395 | }).parents('li').find('.button.edit').addClass('attendee-permissions-change-button') |
---|
| 396 | .find('.ui-icon-key').addClass('attendee-permissions-change'); |
---|
[5514] | 397 | |
---|
[6044] | 398 | blkAddAtendee.find('dd.attendee-list [type=checkbox]').attr('checked', false); |
---|
[5514] | 399 | |
---|
[6044] | 400 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
[5514] | 401 | |
---|
[6044] | 402 | }); |
---|
| 403 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 404 | blkAddAtendee.find('dd.attendee-list [type=checkbox]').attr('checked', false); |
---|
| 405 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 406 | }); |
---|
[5514] | 407 | |
---|
[6044] | 408 | if(aclsParticipant) |
---|
| 409 | for(var i = 1; i < aclsParticipant.length; i++){ |
---|
| 410 | $('.qtip-active').find('input[name="'+acl_names[aclsParticipant.charAt(i)]+'"]').attr('checked', true); |
---|
| 411 | } |
---|
[6718] | 412 | |
---|
| 413 | $('.qtip .button').button(); |
---|
[5514] | 414 | |
---|
[6044] | 415 | }; |
---|
| 416 | }else{ |
---|
| 417 | if(!$('.new-event-win dd.attendee-list').find('[type=checkbox]:checked').length){ |
---|
| 418 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 419 | }else{ |
---|
| 420 | $('.qtip-active .button.save .ui-button-text').html('Aplicar a todos') |
---|
| 421 | } |
---|
[5514] | 422 | |
---|
[6044] | 423 | }; |
---|
| 424 | }) |
---|
| 425 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 426 | .removeClass('new').end() |
---|
[5514] | 427 | |
---|
[6044] | 428 | .filter(".open-delegate.new").click(function(){ |
---|
| 429 | if($(this).hasClass('ui-icon-triangle-1-e')){ |
---|
| 430 | $(this).removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); |
---|
| 431 | $(this).parents('li').find('.list-delegates').removeClass('hidden'); |
---|
| 432 | }else{ |
---|
| 433 | $(this).removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); |
---|
| 434 | $(this).parents('li').find('.list-delegates').addClass('hidden'); |
---|
| 435 | } |
---|
[5514] | 436 | |
---|
[6044] | 437 | }).removeClass('new'); |
---|
[5514] | 438 | |
---|
| 439 | |
---|
[6044] | 440 | blkAddAtendee.find("li input[type=checkbox].new").click(function(){ |
---|
| 441 | if(!$('.new-event-win dd.attendee-list').find('[type=checkbox]:checked').length){ |
---|
| 442 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 443 | }else{ |
---|
| 444 | checked = true; |
---|
| 445 | $(this).parents('li').find('.button.edit').click(); |
---|
| 446 | } |
---|
| 447 | }).removeClass('new'); |
---|
[5514] | 448 | |
---|
[6044] | 449 | UI.dialogs.addEvent.find('.attendees-list li').hover( |
---|
| 450 | function () { |
---|
| 451 | $(this).addClass("hover-attendee"); |
---|
| 452 | $(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 453 | .find('.attendee-options').addClass('hover-attendee'); |
---|
| 454 | }, |
---|
| 455 | function () { |
---|
| 456 | $(this).removeClass("hover-attendee"); |
---|
| 457 | $(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 458 | .find('.attendee-options').removeClass('hover-attendee');; |
---|
| 459 | } |
---|
| 460 | ); |
---|
[7996] | 461 | |
---|
| 462 | |
---|
[6044] | 463 | } |
---|
[5937] | 464 | |
---|
[6044] | 465 | var html = DataLayer.render( path+'templates/event_add.ejs', { |
---|
| 466 | event:objEvent |
---|
| 467 | }); |
---|
[5341] | 468 | |
---|
[6044] | 469 | if (!UI.dialogs.addEvent) { |
---|
| 470 | UI.dialogs.addEvent = jQuery('#sandbox').append('<div title="Criar Evento" class="new-event-win active"> <div>').find('.new-event-win.active').html(html).dialog({ |
---|
| 471 | resizable: false, |
---|
| 472 | modal:true, |
---|
| 473 | autoOpen: false, |
---|
[7857] | 474 | width:"auto", |
---|
[6044] | 475 | position: 'center', |
---|
| 476 | close: function(event, ui) { |
---|
[6683] | 477 | /** |
---|
[6412] | 478 | * Remove tooltip possivelmente existente |
---|
| 479 | */ |
---|
[6683] | 480 | if ($('.qtip.qtip-blue.qtip-active').length) |
---|
| 481 | $('.qtip.qtip-blue.qtip-active').qtip('destroy'); |
---|
| 482 | attendees = {}; |
---|
[6044] | 483 | }, |
---|
| 484 | beforeClose: function(event, ui) { |
---|
[5341] | 485 | |
---|
[6044] | 486 | if (!canDiscardEventDialog && !zebraDiscardEventDialog) { |
---|
| 487 | zebraDiscardEventDialog = true; |
---|
| 488 | window.setTimeout(function() { |
---|
| 489 | $.Zebra_Dialog('Suas alterações no evento não foram salvas. Deseja descartar as alterações?', { |
---|
| 490 | 'type': 'question', |
---|
| 491 | 'overlay_opacity': '0.5', |
---|
| 492 | 'buttons': ['Descartar alterações', 'Continuar editando'], |
---|
| 493 | 'onClose': function(clicked) { |
---|
| 494 | if(clicked == 'Descartar alterações') { |
---|
| 495 | canDiscardEventDialog = true; |
---|
| 496 | /** |
---|
[6412] | 497 | *Remoção dos anexos do eventos caso seja cancelado a edição |
---|
| 498 | */ |
---|
| 499 | DataLayer.rollback(); |
---|
| 500 | |
---|
| 501 | var ids = false; |
---|
[6044] | 502 | $.each($('.attachment-list input'), function (i, input) { |
---|
[6412] | 503 | DataLayer.put('attachment', {id: ''+input.value}); |
---|
| 504 | DataLayer.remove('attachment', ''+input.value); |
---|
| 505 | ids = true; |
---|
[6044] | 506 | }); |
---|
[6412] | 507 | if(ids) |
---|
| 508 | DataLayer.commit(); |
---|
| 509 | |
---|
| 510 | |
---|
[5746] | 511 | |
---|
[6044] | 512 | UI.dialogs.addEvent.dialog('close'); |
---|
| 513 | }else{ |
---|
| 514 | zebraDiscardEventDialog = false; |
---|
| 515 | } |
---|
[5341] | 516 | |
---|
[6044] | 517 | /** |
---|
[6476] | 518 | * Uma vez aberta uma janela de confirmação (Zebra_Dialog), ao fechá-la |
---|
| 519 | * com ESC, para que o evento ESC não seja propagado para fechamento da |
---|
| 520 | * janela de edição de eventos, deve ser setada uma flag indicando que |
---|
| 521 | * já existe uma janela de confirmação aberta. |
---|
| 522 | */ |
---|
[6044] | 523 | if (!clicked) { |
---|
| 524 | window.setTimeout(function() { |
---|
| 525 | zebraDiscardEventDialog = false; |
---|
| 526 | }, 200); |
---|
| 527 | } |
---|
| 528 | } |
---|
| 529 | }); |
---|
[5341] | 530 | |
---|
[6044] | 531 | }, 300); |
---|
[5341] | 532 | |
---|
[6044] | 533 | } |
---|
[6412] | 534 | //DataLayer.rollback(); |
---|
[6044] | 535 | return canDiscardEventDialog; |
---|
[6683] | 536 | }, |
---|
| 537 | dragStart: function(event, ui) { |
---|
| 538 | if ($('.qtip.qtip-blue.qtip-active').length) |
---|
| 539 | $('.qtip.qtip-blue.qtip-active').qtip('destroy'); |
---|
[6044] | 540 | } |
---|
| 541 | }); |
---|
[5341] | 542 | |
---|
[6044] | 543 | } else { |
---|
| 544 | UI.dialogs.addEvent.html(html); |
---|
| 545 | } |
---|
[5341] | 546 | |
---|
[6683] | 547 | var tabs = UI.dialogs.addEvent.children('.content').tabs({ |
---|
| 548 | select: function(event, ui) { |
---|
| 549 | if ($('.qtip.qtip-blue.qtip-active').length) |
---|
| 550 | $('.qtip.qtip-blue.qtip-active').qtip('destroy'); |
---|
| 551 | } |
---|
| 552 | }); |
---|
[6044] | 553 | var calendar = DataLayer.get('calendar', objEvent.calendar); |
---|
[5381] | 554 | |
---|
[7597] | 555 | if ( (calendar.timezone != objEvent.timezone) && objEvent.id){ |
---|
[6044] | 556 | UI.dialogs.addEvent.find('.calendar-addevent-details-txt-timezone').find('option[value="'+objEvent.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 557 | UI.dialogs.addEvent.find('.calendar_addevent_details_lnk_timezone').addClass('hidden'); |
---|
| 558 | $('.calendar-addevent-details-txt-timezone').removeClass('hidden'); |
---|
[5341] | 559 | |
---|
[6044] | 560 | } |
---|
[5715] | 561 | |
---|
[7996] | 562 | |
---|
| 563 | dateSameValue = function(){ |
---|
| 564 | UI.dialogs.addEvent.find('input.start-date').datepicker({ |
---|
[8018] | 565 | dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy'), |
---|
[7996] | 566 | onSelect : function (selectedDate){ |
---|
[8018] | 567 | endDate = $(".end-date").val(); |
---|
| 568 | storeSelectedDate = selectedDate; |
---|
| 569 | |
---|
| 570 | if ( User.preferences.dateFormat == "dd/MM/yyyy" || User.preferences.dateFormat == "dd-MM-yyyy" ) { |
---|
| 571 | if ( User.preferences.dateFormat == "dd/MM/yyyy" ) { |
---|
| 572 | selectedDate = selectedDate.split("/"); |
---|
| 573 | endDate = endDate.split("/"); |
---|
| 574 | } else if( User.preferences.dateFormat == "dd-MM-yyyy" ){ |
---|
| 575 | selectedDate = selectedDate.split("-"); |
---|
| 576 | endDate = endDate.split("-"); |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | newDt = new Date(selectedDate[2],selectedDate[1], selectedDate[0]); |
---|
| 580 | endDate = new Date(endDate[2],endDate[1], endDate[0]); |
---|
| 581 | |
---|
| 582 | } else if ( User.preferences.dateFormat == "MM/dd/yyyy" ) { |
---|
| 583 | selectedDate = selectedDate.split("/"); |
---|
| 584 | endDate = endDate.split("/"); |
---|
| 585 | |
---|
| 586 | newDt = new Date(selectedDate[2],selectedDate[0], selectedDate[1]); |
---|
| 587 | endDate = new Date(endDate[2],endDate[0], endDate[1]); |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | if( newDt > endDate ) |
---|
| 591 | $(".end-date").val(storeSelectedDate); |
---|
[7996] | 592 | } |
---|
| 593 | }); |
---|
| 594 | } |
---|
| 595 | |
---|
[6044] | 596 | DataLayer.render( path+'templates/event_repeat.ejs', { |
---|
| 597 | event:objEvent |
---|
| 598 | }, function( repeatHtml ){ |
---|
[5715] | 599 | |
---|
[6044] | 600 | UI.dialogs.addEvent.find('#calendar_addevent_details3').html(repeatHtml); |
---|
[7996] | 601 | |
---|
| 602 | dateSameValue(); |
---|
[6444] | 603 | $(".date").datepicker({ |
---|
| 604 | dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy') |
---|
[7996] | 605 | }); |
---|
| 606 | |
---|
| 607 | |
---|
[6044] | 608 | if(objEvent.repeat) |
---|
| 609 | { |
---|
| 610 | if( objEvent.repeat['id'] ) |
---|
| 611 | { |
---|
| 612 | $("[name='repeatId']:last").val( objEvent.repeat['id'] ); |
---|
| 613 | } |
---|
[5715] | 614 | |
---|
[6044] | 615 | if( objEvent.repeat['frequency'] !== 'none' ) |
---|
| 616 | { |
---|
| 617 | if( objEvent.repeat['startTime'] && objEvent.repeat['startTime'] !== "0" ) |
---|
| 618 | { |
---|
| 619 | $("[name='startOptions'] [value='customDate']:last").attr( 'selected', 'selected' ); |
---|
| 620 | $("[name='start']:last").val(new Date( parseInt(objEvent.repeat['startTime']) ).toString( User.preferences.dateFormat ) ); |
---|
| 621 | } |
---|
| 622 | else |
---|
| 623 | { |
---|
| 624 | $("[name='start']:last").val($("[name='startDate']:last").val()); |
---|
| 625 | $("[name='start']:last").readOnly=true; |
---|
| 626 | $("[name='start']:last").datepicker("disable"); |
---|
| 627 | } |
---|
[5715] | 628 | |
---|
[6044] | 629 | $(".finish_event").removeClass("hidden"); |
---|
[5715] | 630 | |
---|
[6044] | 631 | if(objEvent.repeat['endTime'] && objEvent.repeat['endTime'] !== "0" ) |
---|
| 632 | { |
---|
| 633 | //$("[name='occurrences']").addClass("hidden"); |
---|
| 634 | $(".customDateEnd").removeClass("hidden"); |
---|
| 635 | $(".endRepeat option[value='customDate']").attr('selected', 'selected') |
---|
| 636 | $(".customDateEnd").val( new Date( parseInt(objEvent.repeat['endTime']) )/*.setTimezoneOffset( Timezone.timezone( objEvent.timezone ) )*/.toString( User.preferences.dateFormat ) ); |
---|
| 637 | } |
---|
| 638 | else if (objEvent.repeat['count'] && objEvent.repeat['count'] !== "0" ) { |
---|
| 639 | $(".endRepeat option[value='occurrences']").attr('selected', 'selected'); |
---|
| 640 | $(".occurrencesEnd").removeClass("hidden"); |
---|
| 641 | $(".occurrencesEnd").val(objEvent.repeat['count']); |
---|
| 642 | } |
---|
[5715] | 643 | |
---|
[6044] | 644 | switch ( objEvent.repeat['frequency'] ) |
---|
| 645 | { |
---|
| 646 | case "daily": |
---|
[6209] | 647 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Dia(s)") |
---|
[6346] | 648 | .end().find(".eventInterval").val( objEvent.repeat['interval'] || "1" ); |
---|
[6044] | 649 | $(".frequency option[value='daily']").attr('selected', 'selected'); |
---|
| 650 | break; |
---|
| 651 | case "weekly": |
---|
[6209] | 652 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Semana(s)") |
---|
[6346] | 653 | .end().find(".eventInterval").val( objEvent.repeat['interval'] || "1" ); |
---|
[7602] | 654 | |
---|
[6044] | 655 | $(".frequency option[value='weekly']").attr('selected', 'selected'); |
---|
[5715] | 656 | |
---|
[6044] | 657 | $(".event-repeat-weekly").removeClass("hidden"); |
---|
[5715] | 658 | |
---|
[6044] | 659 | var day = []; |
---|
[5715] | 660 | |
---|
[6044] | 661 | if( objEvent.repeat.byday ) |
---|
| 662 | day = objEvent.repeat.byday.split(','); |
---|
[5715] | 663 | |
---|
[6044] | 664 | for(i=0; i<day.length; i++) |
---|
| 665 | $(".event-repeat-weekly [value='" + day[i] + "']").attr("checked","checked"); |
---|
[5715] | 666 | |
---|
[6044] | 667 | break; |
---|
| 668 | case "monthly": |
---|
[6209] | 669 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Mes(s)") |
---|
[6346] | 670 | .end().find(".eventInterval").val( objEvent.repeat['interval'] || "1" ); |
---|
[7602] | 671 | |
---|
[6044] | 672 | $(".frequency option[value='monthly']").attr('selected', 'selected') |
---|
[7602] | 673 | |
---|
[6044] | 674 | $(".event-repeat-monthly:last").removeClass("hidden").find("input[type=radio][name=repeatmonthyType]").click(function(){ |
---|
[7602] | 675 | if($("input[type=radio][name=repeatmonthyType]:checked").val() == "1") |
---|
| 676 | $(".event-repeat-weekly:last").removeClass("hidden"); |
---|
| 677 | else |
---|
| 678 | $(".event-repeat-weekly:last").addClass("hidden"); |
---|
[6044] | 679 | }); |
---|
[7602] | 680 | |
---|
| 681 | |
---|
| 682 | if( objEvent.repeat && objEvent.repeat.bymonthday != ''){ |
---|
| 683 | |
---|
| 684 | $("input[type=radio][name=repeatmonthyType][value=0]").attr('checked', 'checked'); |
---|
| 685 | |
---|
| 686 | }else if(objEvent.repeat){ |
---|
| 687 | |
---|
| 688 | $("input[type=radio][name=repeatmonthyType][value=1]").attr('checked', 'checked'); |
---|
| 689 | |
---|
| 690 | var days = objEvent.repeat.byday.split(','); |
---|
| 691 | |
---|
| 692 | $.each(days, function(i, e){ |
---|
| 693 | $(".event-repeat-weekly:last").find('input[name="repeatweekly[]"][value="'+e+'"]').attr('checked', 'checked'); |
---|
| 694 | }); |
---|
| 695 | |
---|
| 696 | } |
---|
| 697 | |
---|
| 698 | |
---|
[6044] | 699 | if($("input[type=radio][name=repeatmonthyType]:checked").val() == "1") |
---|
[7602] | 700 | $(".event-repeat-weekly:last").removeClass("hidden"); |
---|
[6044] | 701 | else |
---|
[7602] | 702 | $(".event-repeat-weekly:last").addClass("hidden"); |
---|
[6044] | 703 | break; |
---|
| 704 | case "yearly": |
---|
[6209] | 705 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Ano(s)") |
---|
[6346] | 706 | .end().find(".eventInterval").val( objEvent.repeat['interval'] || "1" ); |
---|
[6044] | 707 | $(".frequency option[value='yearly']").attr('selected', 'selected') |
---|
| 708 | break; |
---|
| 709 | } |
---|
| 710 | } |
---|
| 711 | } |
---|
| 712 | else { |
---|
| 713 | $(".endRepeat option[value='never']").attr('selected', 'selected'); |
---|
| 714 | } |
---|
[5715] | 715 | |
---|
| 716 | |
---|
[6044] | 717 | $(".event-repeat-container:last").find(".repeat-in").find("[name=startOptions]").change(function(){ |
---|
[5715] | 718 | |
---|
[6044] | 719 | if($(this).find("option:selected").val() == "Today"){ |
---|
| 720 | $("[name='start']:last").val($("[name='startDate']:last").val()); |
---|
| 721 | $("[name='start']:last").readOnly=true; |
---|
| 722 | $("[name='start']:last").datepicker("disable"); |
---|
| 723 | } |
---|
| 724 | else{ |
---|
| 725 | $("[name='start']:last").readOnly=false; |
---|
| 726 | $("[name='start']:last").datepicker("enable"); |
---|
| 727 | } |
---|
| 728 | }); |
---|
| 729 | $(".event-repeat-container:last").find(".repeat-in").find("[name=endOptions]").change(function(){ |
---|
| 730 | if($(this).find("option:selected").val() == "never"){ |
---|
| 731 | $("[name='occurrences']").addClass("hidden"); |
---|
| 732 | $("[name='end']:last").addClass("hidden"); |
---|
| 733 | } |
---|
| 734 | else if($(this).find("option:selected").val() == "customDate"){ |
---|
| 735 | $("[name='occurrences']").addClass("hidden"); |
---|
| 736 | $("[name='end']:last").removeClass("hidden"); |
---|
| 737 | } |
---|
| 738 | else{ |
---|
| 739 | $("[name='end']:last").addClass("hidden"); |
---|
| 740 | $("[name='occurrences']").removeClass("hidden"); |
---|
| 741 | } |
---|
| 742 | }); |
---|
[5715] | 743 | |
---|
[6044] | 744 | $("[name='frequency']:last").change(function () { |
---|
| 745 | $(".frequency-option").addClass("hidden"); |
---|
| 746 | if($(this).val() == "none"){ |
---|
| 747 | $(".repeat-in").addClass("hidden"); |
---|
| 748 | return; |
---|
| 749 | }else{ |
---|
| 750 | $(".repeat-in").removeClass("hidden"); |
---|
| 751 | $("[name='start']:last").val($("[name='startDate']:last").val()); |
---|
| 752 | } |
---|
[5715] | 753 | |
---|
| 754 | |
---|
[6044] | 755 | switch($(this).val()){ |
---|
| 756 | case "daily": |
---|
| 757 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Dia(s)"); |
---|
| 758 | break; |
---|
| 759 | case "weekly": |
---|
| 760 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Semana(s)"); |
---|
| 761 | $(".event-repeat-weekly:last").removeClass("hidden"); |
---|
| 762 | break; |
---|
| 763 | case "monthly": |
---|
| 764 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Mes(s)"); |
---|
| 765 | $(".event-repeat-monthly:last").removeClass("hidden").find("input[type=radio][name=repeatmonthyType]").click(function(){ |
---|
| 766 | if($("input[type=radio][name=repeatmonthyType]:checked").val() == "1") |
---|
| 767 | $(".event-repeat-weekly:last").removeClass("hidden"); |
---|
| 768 | else |
---|
| 769 | $(".event-repeat-weekly:last").addClass("hidden"); |
---|
| 770 | }); |
---|
| 771 | if($("input[type=radio][name=repeatmonthyType]:checked").val() == "1") |
---|
| 772 | $(".event-repeat-weekly:last").removeClass("hidden"); |
---|
| 773 | else |
---|
| 774 | $(".event-repeat-weekly:last").addClass("hidden"); |
---|
| 775 | break; |
---|
| 776 | default: |
---|
| 777 | $(".event-repeat-container:last").find(".repeat-in").find(".interval").html("Ano(s)"); |
---|
| 778 | break; |
---|
| 779 | } |
---|
[5715] | 780 | |
---|
[6044] | 781 | }); |
---|
| 782 | }); |
---|
[5715] | 783 | |
---|
[6044] | 784 | UI.dialogs.addEvent.find('.calendar_addevent_details_lnk_timezone').click(function(e){ |
---|
| 785 | $(this).addClass('hidden'); |
---|
| 786 | $('.calendar-addevent-details-txt-timezone').removeClass('hidden'); |
---|
| 787 | e.preventDefault(); |
---|
| 788 | }); |
---|
[5341] | 789 | |
---|
[6044] | 790 | UI.dialogs.addEvent.find('.button.remove').button({ |
---|
| 791 | text:false, |
---|
| 792 | icons:{ |
---|
| 793 | primary:'ui-icon-close' |
---|
| 794 | } |
---|
| 795 | }).click(function(el){ |
---|
| 796 | var id; |
---|
| 797 | if( id = $(this).parent().find('input[name="alarmId[]"]').val()) |
---|
| 798 | DataLayer.remove('alarm', id); |
---|
| 799 | $(this).parent().remove().find('li').is(':empty'); |
---|
| 800 | }); |
---|
[5937] | 801 | |
---|
[6331] | 802 | var myCalendar = function(){ |
---|
| 803 | for(var i in Calendar.signatures) |
---|
| 804 | if(Calendar.signatures[i].isOwner == "1") |
---|
| 805 | return Calendar.signatures[i].calendar.id; |
---|
| 806 | } |
---|
[6476] | 807 | |
---|
| 808 | /*Seleciona a agenda padrão para visualização/edição de um evento*/ |
---|
| 809 | if(objEvent.id) |
---|
| 810 | UI.dialogs.addEvent.find('option[value="'+objEvent.calendar+'"]').attr('selected','selected').trigger('change'); |
---|
| 811 | |
---|
[6044] | 812 | /*Adicionar alarms padrões, quando alterado a agenda do usuário*/ |
---|
| 813 | UI.dialogs.addEvent.find('select[name="calendar"]').change(function(){ |
---|
| 814 | if((typeof($('input[name = "idEvent"]').val()) == 'undefined') || (!!!$('input[name = "idEvent"]').val())) { |
---|
| 815 | $('input[name = "isDefaultAlarm[]"]').parent().remove(); |
---|
| 816 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').parent().removeClass('hidden'); |
---|
| 817 | var calendarSelected = Calendar.signatureOf[$(this).val()]; |
---|
| 818 | calendarSelected.useAlarmDefault = 1; |
---|
| 819 | if(calendarSelected.defaultAlarms != ""){ |
---|
| 820 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', { |
---|
| 821 | alarm:calendarSelected |
---|
| 822 | }); |
---|
| 823 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({ |
---|
| 824 | text:false, |
---|
| 825 | icons:{ |
---|
| 826 | primary:'ui-icon-close' |
---|
| 827 | } |
---|
| 828 | }).click(function(el) { |
---|
| 829 | $(this).parent().remove().find('li').is(':empty'); |
---|
| 830 | }); |
---|
[6476] | 831 | |
---|
[6044] | 832 | }else{ |
---|
| 833 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').parent().addClass('hidden'); |
---|
| 834 | } |
---|
| 835 | } |
---|
[5947] | 836 | |
---|
[6476] | 837 | var participant = UI.dialogs.addEvent.find('dd.me input[name="attendee[]"]').val(); |
---|
| 838 | var calendar = $(this).val(); |
---|
| 839 | |
---|
| 840 | if( !parseInt(Calendar.signatureOf[calendar].isOwner) ){ |
---|
| 841 | var signature = Calendar.signatureOf[calendar]; |
---|
[6044] | 842 | var organizer = DataLayer.get('calendarSignature', { |
---|
| 843 | filter: ['AND', ['=','calendar',signature.calendar.id], ['=','isOwner','1']], |
---|
| 844 | criteria: { |
---|
| 845 | deepness: 2 |
---|
| 846 | } |
---|
| 847 | }); |
---|
[5947] | 848 | |
---|
[6044] | 849 | if($.isArray(organizer)) |
---|
| 850 | organizer = organizer[0]; |
---|
| 851 | DataLayer.put('participant', { |
---|
| 852 | id: participant, |
---|
| 853 | user: organizer.user.id, |
---|
| 854 | mail: organizer.user.mail |
---|
| 855 | }); |
---|
[5947] | 856 | |
---|
[6044] | 857 | UI.dialogs.addEvent.find('dt.me').html(organizer.user.name); |
---|
| 858 | UI.dialogs.addEvent.find('li.organizer input[name="attendee_organizer"]').val(participant); |
---|
| 859 | UI.dialogs.addEvent.find('li.organizer label').filter('.name').html(organizer.user.name).end() |
---|
| 860 | .filter('.mail').html(organizer.user.mail).attr('title',organizer.user.mail); |
---|
[5947] | 861 | |
---|
[6044] | 862 | }else{ |
---|
| 863 | UI.dialogs.addEvent.find('dt.me').html(User.me.name); |
---|
| 864 | DataLayer.put('participant', { |
---|
| 865 | id: participant, |
---|
| 866 | user: User.me.id, |
---|
| 867 | mail: User.me.mail |
---|
| 868 | }); |
---|
| 869 | UI.dialogs.addEvent.find('li.organizer input[name="attendee_organizer"]').val(participant); |
---|
| 870 | UI.dialogs.addEvent.find('li.organizer label').filter('.name').html(User.me.name).end() |
---|
| 871 | .filter('.mail').html(User.me.mail).attr('title',User.me.mail); |
---|
| 872 | } |
---|
[6476] | 873 | |
---|
[6044] | 874 | }); |
---|
[6331] | 875 | |
---|
[6044] | 876 | /*Checkbox adicionar alarms padrões*/ |
---|
| 877 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').click(function(){ |
---|
| 878 | if($(this).attr("checked")){ |
---|
| 879 | $('input[name="isDefaultAlarm[]"]').parent().remove(); |
---|
| 880 | var calendarSelected = Calendar.signatureOf[$('select[name="calendar"]').val()]; |
---|
| 881 | calendarSelected.useAlarmDefault = 1; |
---|
| 882 | if(calendarSelected.defaultAlarms != ""){ |
---|
| 883 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', { |
---|
| 884 | alarm:calendarSelected |
---|
[5341] | 885 | }); |
---|
[6044] | 886 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({ |
---|
| 887 | text:false, |
---|
| 888 | icons:{ |
---|
| 889 | primary:'ui-icon-close' |
---|
| 890 | } |
---|
| 891 | }).click(function(el) { |
---|
| 892 | var id; |
---|
| 893 | if( id = $(this).parent().find('input[name="alarmId[]"]').val()) |
---|
| 894 | DataLayer.remove('alarm', id); |
---|
| 895 | $(this).parent().remove().find('li').is(':empty') |
---|
| 896 | }); |
---|
| 897 | } |
---|
| 898 | } else { |
---|
| 899 | $('input[name="isDefaultAlarm[]"]').parent().remove(); |
---|
| 900 | } |
---|
| 901 | }); |
---|
| 902 | /* Checkbox allday */ |
---|
| 903 | UI.dialogs.addEvent.find('input[name="allDay"]').click(function(){ |
---|
| 904 | $(this).attr("checked") ? |
---|
| 905 | UI.dialogs.addEvent.find('.start-time, .end-time').addClass('hidden') : |
---|
| 906 | UI.dialogs.addEvent.find('.start-time, .end-time').removeClass('hidden'); |
---|
| 907 | updateMap(true); |
---|
| 908 | }); |
---|
[5341] | 909 | |
---|
[6044] | 910 | UI.dialogs.addEvent.find('.button').button(); |
---|
| 911 | UI.dialogs.addEvent.find('.button.add').button({ |
---|
| 912 | icons: { |
---|
| 913 | secondary: "ui-icon-plus" |
---|
| 914 | } |
---|
| 915 | }); |
---|
[5341] | 916 | |
---|
[6044] | 917 | // ==== validation events ==== |
---|
| 918 | UI.dialogs.addEvent.find(".input-group .h1").Watermark("Evento sem título"); |
---|
| 919 | if(User.preferences.hourFormat.length == 5) { |
---|
| 920 | UI.dialogs.addEvent.find(".end-time, .start-time").mask("99:99", { |
---|
| 921 | completed: function(){ |
---|
| 922 | updateMap(); |
---|
| 923 | } |
---|
| 924 | }); |
---|
| 925 | } else { |
---|
| 926 | $.mask.definitions['{']='[ap]'; |
---|
| 927 | $.mask.definitions['}']='[m]'; |
---|
| 928 | UI.dialogs.addEvent.find(".end-time, .start-time").mask("99:99 {}", { |
---|
| 929 | completed:function(){ |
---|
| 930 | $(this).val(date.Calendar.defaultToAmPm($(this).val())); |
---|
| 931 | $(this).timepicker("refresh"); |
---|
| 932 | $(this).val($(this).val().replace(/[\.]/gi, "")); |
---|
| 933 | updateMap(); |
---|
| 934 | } |
---|
| 935 | }); |
---|
| 936 | } |
---|
| 937 | UI.dialogs.addEvent.find(".number").numeric(); |
---|
| 938 | User.preferences.dateFormat.indexOf('-') > 0 ? |
---|
| 939 | UI.dialogs.addEvent.find(".date").mask("99-99-9999", { |
---|
| 940 | completed:function(){ |
---|
| 941 | updateMap(); |
---|
| 942 | } |
---|
| 943 | }) : |
---|
| 944 | UI.dialogs.addEvent.find(".date").mask("99/99/9999", { |
---|
| 945 | completed:function(){ |
---|
| 946 | updateMap(); |
---|
| 947 | } |
---|
| 948 | }); |
---|
[5341] | 949 | |
---|
[6044] | 950 | UI.dialogs.addEvent.find(".menu-addevent") |
---|
| 951 | .children(".delete").click(function(){ |
---|
| 952 | $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', { |
---|
| 953 | 'type': 'question', |
---|
| 954 | 'overlay_opacity': '0.5', |
---|
| 955 | 'buttons': ['Sim', 'Não'], |
---|
| 956 | 'onClose': function(clicked) { |
---|
| 957 | if(clicked == 'Sim'){ |
---|
| 958 | canDiscardEventDialog = true; |
---|
[6286] | 959 | /* Remove por filtro */ |
---|
[6331] | 960 | DataLayer.removeFilter('schedulable', {filter: ['AND', ['=', 'id', objEvent.id], ['=', 'calendar', objEvent.calendar], ['=','user',(objEvent.me.user ? objEvent.me.user.id : objEvent.me.id)]]}); |
---|
[6286] | 961 | Calendar.rerenderView(true); |
---|
| 962 | /********************/ |
---|
[6044] | 963 | UI.dialogs.addEvent.dialog("close"); |
---|
| 964 | } |
---|
| 965 | } |
---|
| 966 | }); |
---|
| 967 | }).end() |
---|
[5341] | 968 | |
---|
[6044] | 969 | .children(".cancel").click(function(){ |
---|
| 970 | UI.dialogs.addEvent.dialog("close"); |
---|
| 971 | }).end() |
---|
[5341] | 972 | |
---|
[6044] | 973 | .children(".save").click(function(){ |
---|
| 974 | /* Validação */ |
---|
| 975 | var msg = false; |
---|
| 976 | if(msg = validDateEvent()){ |
---|
| 977 | $(".new-event-win.active").find('.messages-validation').removeClass('hidden').find('.message label').html(msg); |
---|
| 978 | return false; |
---|
| 979 | } |
---|
[5341] | 980 | |
---|
[6044] | 981 | canDiscardEventDialog = true; |
---|
[5341] | 982 | |
---|
[6044] | 983 | var exit = function(event){ |
---|
| 984 | if(event) |
---|
| 985 | DataLayer.remove('schedulable', event, false); |
---|
[5752] | 986 | |
---|
[6044] | 987 | UI.dialogs.addEvent.children().find('form.form-addevent').submit(); |
---|
| 988 | UI.dialogs.addEvent.dialog("close"); |
---|
| 989 | } |
---|
[5746] | 990 | |
---|
[6044] | 991 | if(repeat){ |
---|
| 992 | DataLayer.remove('repeat', false); |
---|
| 993 | DataLayer.put('repeat', repeat); |
---|
| 994 | DataLayer.commit('repeat', false, exit(repeat.schedulable)); |
---|
| 995 | }else |
---|
| 996 | exit(); |
---|
| 997 | }).end() |
---|
[5341] | 998 | |
---|
[6044] | 999 | .children(".export").click(function(){ |
---|
| 1000 | UI.dialogs.addEvent.children().find(".form-export").submit(); |
---|
| 1001 | }); |
---|
[5341] | 1002 | |
---|
[8018] | 1003 | dateSameValue(); |
---|
[7996] | 1004 | |
---|
| 1005 | |
---|
[8018] | 1006 | var setTime = function( selectedDateTime ) { |
---|
| 1007 | if ((selectedDateTime.value == '__:__') || (selectedDateTime.value == '__:__ __')) |
---|
| 1008 | selectedDateTime.value = ""; |
---|
| 1009 | if(!(User.preferences.hourFormat.length == 5)) |
---|
| 1010 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1011 | updateMap(); |
---|
[7996] | 1012 | |
---|
[8018] | 1013 | if( Date.parse(selectedDateTime) < Date.parse(oldTime) ) return true; |
---|
[7996] | 1014 | |
---|
[8018] | 1015 | var time = selectedDateTime.split(":"); |
---|
| 1016 | |
---|
| 1017 | var hh = time[0]; |
---|
| 1018 | var mm = time[1].substring(0, 2); |
---|
| 1019 | |
---|
| 1020 | |
---|
| 1021 | dt = new Date(); |
---|
| 1022 | dt.setHours(hh, mm); |
---|
| 1023 | var startHours = dt.getHours(); |
---|
| 1024 | add = parseInt(User.preferences.defaultDuration) + parseInt($("input.end-time").val().split(":")[1].substring(0,2)); |
---|
| 1025 | dt.addMinutes(add); |
---|
| 1026 | |
---|
| 1027 | |
---|
| 1028 | var minutes = dt.getMinutes().toString(); |
---|
| 1029 | var hours = dt.getHours(); |
---|
| 1030 | |
---|
| 1031 | if (time[1].indexOf("p.m.") != -1 ) { |
---|
| 1032 | var startHours = startHours == 12 ? 12 : startHours; |
---|
| 1033 | var startHours = startHours == 1 ? 13 : startHours; |
---|
| 1034 | var startHours = startHours == 2 ? 14 : startHours; |
---|
| 1035 | var startHours = startHours == 3 ? 15 : startHours; |
---|
| 1036 | var startHours = startHours == 4 ? 16 : startHours; |
---|
| 1037 | var startHours = startHours == 5 ? 17 : startHours; |
---|
| 1038 | var startHours = startHours == 6 ? 18 : startHours; |
---|
| 1039 | var startHours = startHours == 7 ? 19 : startHours; |
---|
| 1040 | var startHours = startHours == 8 ? 20 : startHours; |
---|
| 1041 | var startHours = startHours == 9 ? 21 : startHours; |
---|
| 1042 | var startHours = startHours == 10 ? 22 : startHours; |
---|
| 1043 | var startHours = startHours == 11 ? 23 : startHours; |
---|
| 1044 | } else if (time[1].indexOf("a.m.") ) { |
---|
| 1045 | var startHours = startHours == 12 ? 00 : startHours; |
---|
[6044] | 1046 | } |
---|
[8018] | 1047 | dtFormat = (time[1].indexOf("p.m.") != -1 || time[1].indexOf("a.m.") != -1) ? ((((User.preferences.defaultDuration / 60) + startHours) >= 12 && (startHours + 4) < 24) ? " pm" : " am") : ""; |
---|
| 1048 | |
---|
| 1049 | var newHours = ""; |
---|
| 1050 | if(dtFormat){ |
---|
| 1051 | hours = hours == 13 ? 01 : hours; |
---|
| 1052 | hours = hours == 14 ? 02 : hours; |
---|
| 1053 | hours = hours == 15 ? 03 : hours; |
---|
| 1054 | hours = hours == 16 ? 04 : hours; |
---|
| 1055 | hours = hours == 17 ? 05 : hours; |
---|
| 1056 | hours = hours == 18 ? 06 : hours; |
---|
| 1057 | hours = hours == 19 ? 07 : hours; |
---|
| 1058 | hours = hours == 20 ? 08 : hours; |
---|
| 1059 | hours = hours == 21 ? 09 : hours; |
---|
| 1060 | hours = hours == 22 ? 10 : hours; |
---|
| 1061 | hours = hours == 23 ? 11 : hours; |
---|
| 1062 | hours = hours == 24 ? 12 : hours; |
---|
| 1063 | } else { |
---|
| 1064 | newHours = hours <= 9 ? "0" : ""; |
---|
| 1065 | } |
---|
[7996] | 1066 | |
---|
[8018] | 1067 | minutes = minutes.length == 1 ? "0"+minutes+dtFormat : minutes+dtFormat; |
---|
| 1068 | newHours += hours.toString() + ":" +minutes; |
---|
| 1069 | UI.dialogs.addEvent.find("input.end-time").val(newHours); |
---|
[7996] | 1070 | |
---|
[8018] | 1071 | } |
---|
[7996] | 1072 | |
---|
[8018] | 1073 | $(".start-date").focusout(function(data){ |
---|
| 1074 | $(".end-date").val($(this).val()); |
---|
| 1075 | }); |
---|
| 1076 | |
---|
[7996] | 1077 | if($("#calendar").fullCalendar('getView').name == "month"){ |
---|
[8018] | 1078 | |
---|
[7999] | 1079 | var oldTime = UI.dialogs.addEvent.find('input.start-time').val(); |
---|
[8018] | 1080 | $(".start-time").focusout(function(data){ |
---|
| 1081 | setTime( $(this).val() ); |
---|
| 1082 | }); |
---|
| 1083 | |
---|
[7996] | 1084 | UI.dialogs.addEvent.find('input.start-time').timepicker({ |
---|
[8018] | 1085 | ampm : ((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 1086 | timeFormat: "hh:mm tt", |
---|
| 1087 | onSelect: function( selectedDateTime ){ |
---|
| 1088 | setTime( selectedDateTime ); |
---|
| 1089 | } |
---|
[7996] | 1090 | }); |
---|
| 1091 | |
---|
| 1092 | } |
---|
| 1093 | |
---|
[6044] | 1094 | UI.dialogs.addEvent.find('input.time').timepicker({ |
---|
| 1095 | closeText: 'Ok', |
---|
| 1096 | hourGrid: 4, |
---|
| 1097 | minuteGrid: 10, |
---|
| 1098 | ampm : ((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 1099 | timeFormat: "hh:mm tt", |
---|
| 1100 | onSelect: function (selectedDateTime){ |
---|
[7102] | 1101 | if ((selectedDateTime.value == '__:__') || (selectedDateTime.value == '__:__ __')) |
---|
| 1102 | selectedDateTime.value = ""; |
---|
| 1103 | if(!(User.preferences.hourFormat.length == 5)) |
---|
| 1104 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1105 | updateMap(); |
---|
[6044] | 1106 | }, |
---|
| 1107 | onClose : function (selectedDateTime){ |
---|
| 1108 | if(!(User.preferences.hourFormat.length == 5)) |
---|
| 1109 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
[7102] | 1110 | }, |
---|
| 1111 | beforeShow: function (selectedDateTime) { |
---|
| 1112 | if ((selectedDateTime.value == '__:__') || (selectedDateTime.value == '__:__ __')) |
---|
| 1113 | selectedDateTime.value = ""; |
---|
[6044] | 1114 | } |
---|
| 1115 | }); |
---|
| 1116 | //} |
---|
[5341] | 1117 | |
---|
[6044] | 1118 | UI.dialogs.addEvent.find('.button-add-alarms').click(function(){ |
---|
| 1119 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {}); |
---|
[5341] | 1120 | |
---|
[6044] | 1121 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({ |
---|
| 1122 | text:false, |
---|
| 1123 | icons:{ |
---|
| 1124 | primary:'ui-icon-close' |
---|
| 1125 | } |
---|
| 1126 | }).click(function(el) { |
---|
| 1127 | $(this).parent().remove().find('li').is(':empty') |
---|
| 1128 | }); |
---|
| 1129 | // valicacao de campos numericos |
---|
| 1130 | $('.number').numeric(); |
---|
| 1131 | }); |
---|
[5341] | 1132 | |
---|
[5514] | 1133 | |
---|
[6044] | 1134 | UI.dialogs.addEvent.find('.button.suggestion-hours').button({ |
---|
| 1135 | icons: { |
---|
| 1136 | primary: "ui-icon-clock" |
---|
| 1137 | }, |
---|
| 1138 | text: 'Sugerir horário' |
---|
| 1139 | }).click(function () { |
---|
| 1140 | $(this).siblings('input').removeAttr('disabled') |
---|
| 1141 | .end().parents().find('input[name="allDay"]').removeAttr('disabled'); |
---|
| 1142 | }); |
---|
[5514] | 1143 | |
---|
| 1144 | |
---|
[6044] | 1145 | if(!repeat) |
---|
| 1146 | if(objEvent.me.id == User.me.id){ |
---|
| 1147 | objEvent.me.id = DataLayer.put('participant', { |
---|
| 1148 | user: objEvent.me.id, |
---|
| 1149 | mail: objEvent.me.mail |
---|
| 1150 | }); |
---|
| 1151 | objEvent.organizer.id = objEvent.me.id; |
---|
| 1152 | } |
---|
[5746] | 1153 | |
---|
[6044] | 1154 | var attendeeHtml = DataLayer.render( path+'templates/attendee_add.ejs', { |
---|
| 1155 | event:objEvent |
---|
[7996] | 1156 | }); |
---|
[5341] | 1157 | |
---|
[6044] | 1158 | // load template of attendees |
---|
| 1159 | var blkAddAtendee = UI.dialogs.addEvent.find('#calendar_addevent_details6').append(attendeeHtml); |
---|
[7996] | 1160 | if(objEvent.attendee.length) |
---|
[6996] | 1161 | callbackAttendee(); |
---|
[6044] | 1162 | /** |
---|
[6996] | 1163 | Opções de delegação do participante/organizer |
---|
| 1164 | */ |
---|
[6044] | 1165 | blkAddAtendee.find(".button.participant-delegate").button({ |
---|
| 1166 | icons: { |
---|
| 1167 | primary: "ui-icon-transferthick-e-w" |
---|
| 1168 | }, |
---|
| 1169 | text: false |
---|
| 1170 | }).click(function () { |
---|
| 1171 | if($(this).hasClass('attendee-permissions-change-button')){ |
---|
| 1172 | if(!$(this).hasClass('disable')){ |
---|
| 1173 | $(this).removeClass('attendee-permissions-change-button') |
---|
| 1174 | .find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change').end(); |
---|
| 1175 | blkAddAtendee.find('.block-add-attendee.search').addClass('hidden'); |
---|
| 1176 | blkAddAtendee.find('.block-add-attendee.search dt').html('Adicionar outros contatos'); |
---|
| 1177 | } |
---|
| 1178 | }else{ |
---|
| 1179 | $(this).addClass('attendee-permissions-change-button') |
---|
| 1180 | .find('.ui-icon-transferthick-e-w').addClass('attendee-permissions-change').end(); |
---|
| 1181 | blkAddAtendee.find('.block-add-attendee.search dt').html('Delegar participação para'); |
---|
| 1182 | blkAddAtendee.find('.block-add-attendee.search').removeClass('hidden'); |
---|
| 1183 | blkAddAtendee.find('.block-add-attendee.search input.search').focus(); |
---|
| 1184 | } |
---|
| 1185 | }) |
---|
| 1186 | .addClass('tiny'); |
---|
[5341] | 1187 | |
---|
[6044] | 1188 | //show or hidden permissions attendees |
---|
| 1189 | //blkAddAtendee.find('.block-attendee-list #attendees-users li').click(show_permissions_attendees); |
---|
[5341] | 1190 | |
---|
[6044] | 1191 | UI.dialogs.addEvent.find(".attendee-list-add .add-attendee-input input").Watermark("digite um email para convidar"); |
---|
[6996] | 1192 | /* |
---|
| 1193 | * Trata a edição de um novo participante adicionado |
---|
| 1194 | */ |
---|
[6044] | 1195 | var hasNewAttendee = false; |
---|
[5641] | 1196 | |
---|
[6044] | 1197 | blkAddAtendee.find('.attendee-list-add .add-attendee-input span').click(function(data){ |
---|
| 1198 | blkAddAtendee.find('.attendee-list-add .add-attendee-input input').keydown(); |
---|
| 1199 | }); |
---|
[5641] | 1200 | |
---|
[6044] | 1201 | blkAddAtendee.find('.attendee-list-add .add-attendee-input input').keydown(function(event) { |
---|
| 1202 | if (event.keyCode == '13' && $(this).val() != '' || (event.keyCode == undefined && $(this).val() != '')) { |
---|
| 1203 | Encoder.EncodeType = "entity"; |
---|
| 1204 | $(this).val(Encoder.htmlEncode($(this).val())); |
---|
[5341] | 1205 | |
---|
[6044] | 1206 | newAttendeeEmail = false; |
---|
| 1207 | newAttendeeName = false; |
---|
| 1208 | skipAddNewLine = false; |
---|
[5341] | 1209 | |
---|
[6044] | 1210 | var info = $(this).val(); |
---|
[5341] | 1211 | |
---|
[6044] | 1212 | /** |
---|
[6996] | 1213 | * email válido? |
---|
| 1214 | */ |
---|
[6044] | 1215 | info.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/) ? |
---|
| 1216 | newAttendeeEmail = info : newAttendeeName = info; |
---|
[5341] | 1217 | |
---|
[6044] | 1218 | /** |
---|
[6996] | 1219 | * 1) busca no banco para saber se o usuário já existe |
---|
| 1220 | * 1.1) se existe, atualiza as info na lista de participantes e nao abre o tooltip |
---|
| 1221 | * 1.2) se não existe |
---|
| 1222 | * a) salva como novo usuario externo no banco (apenas com email) |
---|
| 1223 | * b) exibe tooltip pedindo o nome |
---|
| 1224 | * c) se o usuário preenche tooltip e salva, atualiza com o nome o usuário recém criado |
---|
| 1225 | * d) se o usuário cancela o tooltip, fica o usuário salvo apenas com email e sem nome |
---|
| 1226 | */ |
---|
[5341] | 1227 | |
---|
[6044] | 1228 | var user = DataLayer.get('user', ["=", "mail", $(this).val()]); |
---|
| 1229 | if(!!user && user[0].id) |
---|
| 1230 | attendees[user[0].id] = { |
---|
| 1231 | name: user[0].name |
---|
| 1232 | }; |
---|
[5353] | 1233 | |
---|
[6044] | 1234 | /** |
---|
[6996] | 1235 | * guarda o último tooltip aberto referente à lista de participantes |
---|
| 1236 | */ |
---|
[6044] | 1237 | lastEditAttendeeToolTip = []; |
---|
[5354] | 1238 | |
---|
[6044] | 1239 | /** |
---|
[6996] | 1240 | * Valida email e salva um participante externo |
---|
| 1241 | */ |
---|
[6044] | 1242 | var saveContact = function() { |
---|
| 1243 | Encoder.EncodeType = "entity"; |
---|
[5354] | 1244 | |
---|
[6044] | 1245 | var currentTip = $('.qtip-active'); |
---|
| 1246 | newAttendeeName = currentTip.find('input[name="name"]').val(); |
---|
| 1247 | newAttendeeEmail = currentTip.find('input[name="mail"]').val(); |
---|
[5354] | 1248 | |
---|
[6044] | 1249 | if (!(!!newAttendeeEmail.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/))) { |
---|
| 1250 | currentTip.find('.messages').removeClass('hidden').find('.message label').html('Email inválido.'); |
---|
| 1251 | return false; |
---|
| 1252 | } |
---|
[5354] | 1253 | |
---|
[6044] | 1254 | DataLayer.put('user', { |
---|
| 1255 | id:userId, |
---|
| 1256 | name:newAttendeeName, |
---|
| 1257 | mail:newAttendeeEmail, |
---|
| 1258 | isExternal:isExternal |
---|
| 1259 | }); |
---|
[5354] | 1260 | |
---|
[6044] | 1261 | lastEditAttendeeToolTip.find('label') |
---|
| 1262 | .filter('.name').html(Encoder.htmlEncode(newAttendeeName)).attr('title', Encoder.htmlEncode(newAttendeeName)).end() |
---|
| 1263 | .filter('.mail').html(Encoder.htmlEncode(newAttendeeEmail)).attr('title', Encoder.htmlEncode(newAttendeeEmail)); |
---|
[5354] | 1264 | |
---|
[6044] | 1265 | blkAddAtendee.find('.attendee-list-add .add-attendee-input input').val(''); |
---|
| 1266 | return true; |
---|
| 1267 | } |
---|
[5354] | 1268 | |
---|
[6044] | 1269 | /** |
---|
[5354] | 1270 | * Formata e adequa um tootip abert para edição de um participante na lista |
---|
| 1271 | */ |
---|
[6044] | 1272 | var onShowToolTip = function(arg0) { |
---|
| 1273 | $('.qtip-active .button.close').button({ |
---|
| 1274 | icons: { |
---|
| 1275 | primary: "ui-icon-close" |
---|
| 1276 | }, |
---|
| 1277 | text: false |
---|
| 1278 | }); |
---|
| 1279 | $('.qtip-active .button').button() |
---|
| 1280 | .filter('.save').click(function(event, ui) { |
---|
| 1281 | if(saveContact()) |
---|
| 1282 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
| 1283 | else |
---|
| 1284 | return false; |
---|
| 1285 | }).end() |
---|
| 1286 | .filter('.cancel').click(function(event, ui) { |
---|
| 1287 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
| 1288 | }) |
---|
[5353] | 1289 | |
---|
[6044] | 1290 | /** |
---|
[5353] | 1291 | * Trata o ENTER no campo da tooltip, equivalente a salvar |
---|
| 1292 | * o novo convidado. |
---|
| 1293 | */ |
---|
[6044] | 1294 | $('.qtip-active input').keydown(function(event) { |
---|
| 1295 | if (event.keyCode == '13') { |
---|
| 1296 | if (saveContact()) |
---|
| 1297 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5409] | 1298 | |
---|
[6044] | 1299 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
| 1300 | event.preventDefault(); |
---|
| 1301 | } |
---|
| 1302 | }) |
---|
| 1303 | .filter('[name="name"]').Watermark("informe o nome do contato").end() |
---|
| 1304 | .filter('[name="mail"]').Watermark("informe o email do contato"); |
---|
| 1305 | } |
---|
[5353] | 1306 | |
---|
[6044] | 1307 | /** |
---|
[5354] | 1308 | * Se o email digitado já foi adicionado na lista, |
---|
| 1309 | * o usuário deve ser avisado e um botão de edição deve ser exibido |
---|
| 1310 | */ |
---|
[6044] | 1311 | if(blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').length) { |
---|
| 1312 | hasNewAttendee = false; |
---|
| 1313 | newAttendeeName = blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').parents('li').find('label.name').attr('title'); |
---|
[5354] | 1314 | |
---|
[6044] | 1315 | blkAddAtendee.find('.email-validation').removeClass('hidden') |
---|
| 1316 | .find('.message label').html("O usuário acima já foi adicionado! <a class=\"small button\">Editar</a>") |
---|
| 1317 | .find(".button").button().click(function () { |
---|
| 1318 | /** |
---|
[5354] | 1319 | * Se o usuário optar por editar o participante anteriormente adicionado, |
---|
| 1320 | * uma tooltip deve ser aberta para este participante, viabilizando a edição |
---|
| 1321 | */ |
---|
[6044] | 1322 | blkAddAtendee.find("ul.attendee-list").scrollTo('label.mail[title="' + newAttendeeEmail + '"]'); |
---|
| 1323 | /** |
---|
[5354] | 1324 | * Remove tooltip possivelmente existente |
---|
| 1325 | */ |
---|
[6044] | 1326 | if (lastEditAttendeeToolTip.length && lastEditAttendeeToolTip.data('qtip')) |
---|
| 1327 | lastEditAttendeeToolTip.qtip('destroy'); |
---|
[5354] | 1328 | |
---|
[6044] | 1329 | lastEditAttendeeToolTip = blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').parents('li'); |
---|
| 1330 | lastEditAttendeeToolTip.qtip({ |
---|
| 1331 | show: { |
---|
| 1332 | ready: true, |
---|
| 1333 | solo: true, |
---|
| 1334 | when: { |
---|
| 1335 | event: 'click' |
---|
| 1336 | } |
---|
| 1337 | }, |
---|
| 1338 | hide: false, |
---|
| 1339 | content: { |
---|
| 1340 | text: $('<div></div>').html( DataLayer.render( path+'templates/attendee_quick_edit.ejs', { |
---|
| 1341 | attendee:{ |
---|
| 1342 | name:newAttendeeName, |
---|
| 1343 | mail:newAttendeeEmail |
---|
| 1344 | } |
---|
| 1345 | } ) ), |
---|
| 1346 | title: { |
---|
| 1347 | text:'Detalhes do participante', |
---|
| 1348 | button: '<a class="button close" href="#">close</a>' |
---|
| 1349 | } |
---|
| 1350 | }, |
---|
| 1351 | style: { |
---|
| 1352 | name: 'blue', |
---|
| 1353 | tip: { |
---|
| 1354 | corner: 'leftMiddle' |
---|
| 1355 | }, |
---|
| 1356 | border: { |
---|
| 1357 | width: 4, |
---|
| 1358 | radius: 8 |
---|
| 1359 | }, |
---|
| 1360 | width: { |
---|
| 1361 | min: 230, |
---|
| 1362 | max:230 |
---|
| 1363 | } |
---|
| 1364 | }, |
---|
| 1365 | position: { |
---|
| 1366 | corner: { |
---|
| 1367 | target: 'rightMiddle', |
---|
| 1368 | tooltip: 'leftMiddle' |
---|
| 1369 | }, |
---|
| 1370 | adjust: { |
---|
| 1371 | x:0, |
---|
| 1372 | y:0 |
---|
| 1373 | } |
---|
| 1374 | } |
---|
| 1375 | }); |
---|
| 1376 | lastEditAttendeeToolTip.qtip("api").onShow = onShowToolTip; |
---|
| 1377 | }); |
---|
| 1378 | skipAddNewLine = true; |
---|
| 1379 | } else { |
---|
| 1380 | hasNewAttendee = true; |
---|
| 1381 | blkAddAtendee.find('.email-validation').addClass('hidden'); |
---|
| 1382 | } |
---|
[5353] | 1383 | |
---|
| 1384 | |
---|
[6044] | 1385 | var isExternal = (!!user && !(!!user.isExternal)) ? 0 : 1; |
---|
[5341] | 1386 | |
---|
[6044] | 1387 | /** |
---|
[5341] | 1388 | * Remove tooltip possivelmente existente |
---|
| 1389 | */ |
---|
[6044] | 1390 | if (lastEditAttendeeToolTip.length && lastEditAttendeeToolTip.data('qtip')) |
---|
| 1391 | lastEditAttendeeToolTip.qtip('destroy'); |
---|
[5341] | 1392 | |
---|
[6044] | 1393 | userId = ''; |
---|
| 1394 | var newAttendeeId = ''; |
---|
[5341] | 1395 | |
---|
[6044] | 1396 | if (user){ |
---|
| 1397 | if (!skipAddNewLine) { |
---|
| 1398 | user[0].id = DataLayer.put('participant', { |
---|
| 1399 | user: user[0].id, |
---|
| 1400 | isExternal: isExternal, |
---|
| 1401 | acl: 'r' |
---|
| 1402 | }); |
---|
[6203] | 1403 | user[0].acl = objEvent.acl; |
---|
| 1404 | user[0].isDirty = !!!objEvent.id; |
---|
[7377] | 1405 | user[0].isDelegate = (objEvent.id && (objEvent.me.status == '5')); |
---|
[5592] | 1406 | |
---|
[6044] | 1407 | blkAddAtendee.find('dd.attendee-list ul.attendee-list').append( |
---|
| 1408 | DataLayer.render(path+'templates/participants_add_itemlist.ejs', user) |
---|
| 1409 | ) |
---|
| 1410 | .scrollTo('max'); |
---|
| 1411 | callbackAttendee(); |
---|
| 1412 | } |
---|
[5349] | 1413 | |
---|
[6044] | 1414 | $(this).val(''); |
---|
[5341] | 1415 | |
---|
[6996] | 1416 | } else if (!skipAddNewLine) { |
---|
[6044] | 1417 | /** |
---|
[6996] | 1418 | * a) salva como novo usuario externo no banco (apenas com email) e... |
---|
| 1419 | * adiciona novo contato externo à lista de convidados |
---|
| 1420 | */ |
---|
[5341] | 1421 | |
---|
[6044] | 1422 | userId = DataLayer.put('user', { |
---|
| 1423 | name: newAttendeeName, |
---|
| 1424 | mail: newAttendeeEmail, |
---|
| 1425 | isExternal: isExternal |
---|
| 1426 | }); |
---|
| 1427 | newAttendeeId = DataLayer.put('participant', { |
---|
| 1428 | user: userId, |
---|
| 1429 | isExternal: isExternal |
---|
| 1430 | }); |
---|
[5341] | 1431 | |
---|
[5354] | 1432 | |
---|
[6044] | 1433 | blkAddAtendee.find('dd.attendee-list ul.attendee-list').append( |
---|
| 1434 | DataLayer.render(path+'templates/participants_add_itemlist.ejs', [{ |
---|
| 1435 | id:newAttendeeId, |
---|
| 1436 | name: newAttendeeName, |
---|
| 1437 | mail: newAttendeeEmail, |
---|
| 1438 | isExternal: 1, |
---|
[6203] | 1439 | acl: objEvent.acl, |
---|
[7377] | 1440 | isDirty: !!!objEvent.id, |
---|
| 1441 | isDelegate: (objEvent.id && (objEvent.me.status == '5')) |
---|
[6044] | 1442 | }]) |
---|
| 1443 | ).scrollTo('max'); |
---|
| 1444 | callbackAttendee(); |
---|
[5341] | 1445 | |
---|
[6044] | 1446 | /** |
---|
[5341] | 1447 | * Adiciona tootip para atualização dos dados do contato externo |
---|
| 1448 | * recém adicionado. |
---|
| 1449 | */ |
---|
[6044] | 1450 | lastEditAttendeeToolTip = blkAddAtendee.find('dd.attendee-list li:last'); |
---|
| 1451 | lastEditAttendeeToolTip.qtip({ |
---|
| 1452 | show: { |
---|
| 1453 | ready: true, |
---|
| 1454 | solo: true, |
---|
| 1455 | when: { |
---|
| 1456 | event: 'click' |
---|
| 1457 | } |
---|
| 1458 | }, |
---|
| 1459 | hide: false, |
---|
| 1460 | content: { |
---|
| 1461 | text: $('<div></div>').html( DataLayer.render( path+'templates/attendee_quick_edit.ejs', { |
---|
| 1462 | attendee:{ |
---|
| 1463 | name:newAttendeeName, |
---|
| 1464 | mail:newAttendeeEmail |
---|
| 1465 | } |
---|
| 1466 | } ) ), |
---|
| 1467 | title: { |
---|
| 1468 | text:'Detalhes do participante', |
---|
| 1469 | button: '<a class="button close" href="#">close</a>' |
---|
| 1470 | } |
---|
| 1471 | }, |
---|
| 1472 | style: { |
---|
| 1473 | name: 'blue', |
---|
| 1474 | tip: { |
---|
| 1475 | corner: 'leftMiddle' |
---|
| 1476 | }, |
---|
| 1477 | border: { |
---|
| 1478 | width: 4, |
---|
| 1479 | radius: 8 |
---|
| 1480 | }, |
---|
| 1481 | width: { |
---|
| 1482 | min: 230, |
---|
| 1483 | max:230 |
---|
| 1484 | } |
---|
| 1485 | }, |
---|
| 1486 | position: { |
---|
| 1487 | corner: { |
---|
| 1488 | target: 'rightMiddle', |
---|
| 1489 | tooltip: 'leftMiddle' |
---|
| 1490 | }, |
---|
| 1491 | adjust: { |
---|
| 1492 | x:0, |
---|
| 1493 | y:0 |
---|
| 1494 | } |
---|
| 1495 | } |
---|
| 1496 | }); |
---|
[5341] | 1497 | |
---|
[6044] | 1498 | lastEditAttendeeToolTip.qtip("api").onShow = onShowToolTip; |
---|
[5341] | 1499 | |
---|
[6044] | 1500 | $(this).val(''); |
---|
[5341] | 1501 | |
---|
[5353] | 1502 | |
---|
[6044] | 1503 | } |
---|
| 1504 | event.preventDefault(); |
---|
| 1505 | } |
---|
[5354] | 1506 | |
---|
[6044] | 1507 | }); |
---|
[5341] | 1508 | |
---|
[6044] | 1509 | /** |
---|
[6996] | 1510 | * Trata a busca de usuários para adição de participantes |
---|
| 1511 | */ |
---|
[6044] | 1512 | blkAddAtendee.find('.add-attendee-search .ui-icon-search').click(function(event) { |
---|
| 1513 | blkAddAtendee.find('.add-attendee-search input').keydown(); |
---|
| 1514 | }); |
---|
[5592] | 1515 | |
---|
| 1516 | |
---|
[6044] | 1517 | blkAddAtendee.find('.add-attendee-search input').keydown(function(event) { |
---|
[5341] | 1518 | |
---|
[6044] | 1519 | if(event.keyCode == '13' || typeof(event.keyCode) == 'undefined') { |
---|
| 1520 | var result = DataLayer.get('user', ["*", "name", $(this).val()], true); |
---|
[5341] | 1521 | |
---|
[6044] | 1522 | /** |
---|
[6371] | 1523 | * TODO: trocar por template |
---|
| 1524 | */ |
---|
[6044] | 1525 | blkAddAtendee.find('ul.search-result-list').empty().css('overflow', 'hidden'); |
---|
| 1526 | if (!result) { |
---|
| 1527 | blkAddAtendee.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>'); |
---|
| 1528 | } |
---|
[5341] | 1529 | |
---|
[6044] | 1530 | for(i=0; i<result.length; i++) |
---|
| 1531 | result[i].enabled = (blkAddAtendee.find('dd.attendee-list ul.attendee-list label.mail[title="' + result[i].mail + '"]').length) ? false : true; |
---|
[5363] | 1532 | |
---|
[6044] | 1533 | blkAddAtendee.find('ul.search-result-list').append(DataLayer.render( path+'templates/participants_search_itemlist.ejs', result)); |
---|
[5341] | 1534 | |
---|
[6044] | 1535 | blkAddAtendee.find('ul.search-result-list li').click(function(event, ui){ |
---|
| 1536 | if ($(event.target).is('input')) { |
---|
| 1537 | old_item = $(event.target).parents('li'); |
---|
| 1538 | newAttendeeId = DataLayer.put('participant', { |
---|
| 1539 | user: old_item.find('.id').html(), |
---|
[6371] | 1540 | isExternal: old_item.find('.isExternal').html() |
---|
[6044] | 1541 | }); |
---|
[5636] | 1542 | |
---|
[6044] | 1543 | attendees[old_item.find('.id').html()] = old_item.find('.name').html(); |
---|
[5636] | 1544 | |
---|
[6044] | 1545 | blkAddAtendee.find('dd.attendee-list ul.attendee-list') |
---|
| 1546 | .append(DataLayer.render(path+'templates/participants_add_itemlist.ejs', [{ |
---|
| 1547 | id: newAttendeeId, |
---|
| 1548 | name: old_item.find('.name').html(), |
---|
| 1549 | mail: old_item.find('.mail').html(), |
---|
[6371] | 1550 | isExternal: old_item.find('.isExternal').html(), |
---|
[6203] | 1551 | acl: objEvent.acl, |
---|
[7377] | 1552 | isDirty: !!!objEvent.id, |
---|
| 1553 | isDelegate: (objEvent.id && (objEvent.me.status == '5')) |
---|
[6044] | 1554 | }])) |
---|
| 1555 | .scrollTo('max'); |
---|
| 1556 | /** |
---|
[5514] | 1557 | * Delegação de participação de um participante com permissão apenas de leitura |
---|
| 1558 | * |
---|
| 1559 | */ |
---|
[6044] | 1560 | if(!objEvent.acl.organization && !objEvent.acl.write && !objEvent.acl.inviteGuests && objEvent.acl.read ){ |
---|
[5514] | 1561 | |
---|
[6044] | 1562 | blkAddAtendee.find('.block-add-attendee.search').addClass('hidden'); |
---|
| 1563 | blkAddAtendee.find('.block-add-attendee.search dt').html('Adicionar outros contatos'); |
---|
[5514] | 1564 | |
---|
[6044] | 1565 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
| 1566 | blkAddAtendee.find('option[value=5]').attr('selected','selected').trigger('change'); |
---|
| 1567 | blkAddAtendee.find('.request-update').removeClass('hidden'); |
---|
[5341] | 1568 | |
---|
[6044] | 1569 | blkAddAtendee.find('dd.attendee-list ul.attendee-list li .button.close').parents('li').find('input[name="delegatedFrom[]"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val()); |
---|
[5514] | 1570 | |
---|
[6044] | 1571 | blkAddAtendee.find('.me .participant-delegate').addClass('disable ui-button-disabled ui-state-disabled'); |
---|
| 1572 | blkAddAtendee.find(".button.close").button({ |
---|
| 1573 | icons: { |
---|
| 1574 | primary: "ui-icon-close" |
---|
| 1575 | }, |
---|
| 1576 | text: false |
---|
| 1577 | }).click(function () { |
---|
[5514] | 1578 | |
---|
[6044] | 1579 | $(this).parents('li').find('input[name="delegatedFrom[]"]').val(''); |
---|
| 1580 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 1581 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
| 1582 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 1583 | blkAddAtendee.find('.me .participant-delegate').removeClass('disable ui-button-disabled ui-state-disabled attendee-permissions-change-button') |
---|
| 1584 | .find('.ui-icon-person').removeClass('attendee-permissions-change').end(); |
---|
[5514] | 1585 | |
---|
[6044] | 1586 | DataLayer.remove('participant', $(this).parents('li').find('[type=checkbox]').val()); |
---|
| 1587 | $(this).parents('li').remove(); |
---|
| 1588 | }) |
---|
| 1589 | .addClass('tiny'); |
---|
| 1590 | }else{ |
---|
| 1591 | callbackAttendee(); |
---|
| 1592 | old_item.remove(); |
---|
| 1593 | } |
---|
| 1594 | } |
---|
| 1595 | }); |
---|
[5341] | 1596 | |
---|
[6044] | 1597 | event.preventDefault(); |
---|
| 1598 | } |
---|
| 1599 | }); |
---|
[6996] | 1600 | |
---|
[6044] | 1601 | //$('.block-add-attendee .search-result-list').selectable(); |
---|
[5341] | 1602 | |
---|
[6044] | 1603 | UI.dialogs.addEvent.find('.row.fileupload-buttonbar .button').filter('.delete').button({ |
---|
| 1604 | icons: { |
---|
| 1605 | primary: "ui-icon-close" |
---|
| 1606 | }, |
---|
| 1607 | text: 'Excluir' |
---|
| 1608 | }).click(function () { |
---|
[6369] | 1609 | $.Zebra_Dialog('Tem certeza que deseja excluir todos anexos?', { |
---|
| 1610 | 'type': 'question', |
---|
| 1611 | 'overlay_opacity': '0.5', |
---|
| 1612 | 'buttons': ['Sim', 'Não'], |
---|
| 1613 | 'onClose': function(clicked) { |
---|
| 1614 | if(clicked == 'Sim'){ |
---|
| 1615 | |
---|
| 1616 | var ids = []; |
---|
| 1617 | $.each($('.attachment-list input'), function (i, input) { |
---|
| 1618 | DataLayer.remove('schedulableToAttachment', { |
---|
| 1619 | filter: ['=', 'id', ''+input.value] |
---|
| 1620 | }); |
---|
| 1621 | }); |
---|
[6996] | 1622 | $('div.new-event-win .attachment-list input').remove(); |
---|
| 1623 | $('div.new-event-win .row.fileupload-buttonbar .attachments-list p').remove(); |
---|
| 1624 | $('div.new-event-win .btn-danger.delete').addClass('hidden'); |
---|
[6369] | 1625 | } |
---|
| 1626 | }}); |
---|
[6044] | 1627 | }).end() |
---|
| 1628 | .filter('.close').button({ |
---|
| 1629 | icons: { |
---|
| 1630 | primary: "ui-icon-close" |
---|
| 1631 | }, |
---|
| 1632 | text: false |
---|
| 1633 | }).click(function () { |
---|
[6369] | 1634 | DataLayer.remove('schedulableToAttachment', $(this).parents('p').find('input[name="fileId[]"]').val()); |
---|
[6044] | 1635 | $(this).parents('p').remove(); |
---|
| 1636 | }).end() |
---|
| 1637 | .filter('.downlaod-archive').button({ |
---|
| 1638 | icons: { |
---|
| 1639 | primary: "ui-icon-arrowthickstop-1-s" |
---|
| 1640 | }, |
---|
| 1641 | text: false |
---|
| 1642 | }); |
---|
| 1643 | |
---|
[6996] | 1644 | extendsFileupload('event', path); |
---|
[5592] | 1645 | |
---|
[6044] | 1646 | if(objEvent.isShared){ |
---|
[5514] | 1647 | |
---|
[6044] | 1648 | var acls = Calendar.signatureOf[objEvent.calendar].permission.acl; |
---|
[5514] | 1649 | |
---|
[6044] | 1650 | if(!acls.write){ |
---|
| 1651 | UI.dialogs.addEvent.find(':input').attr('disabled', 'disabled'); |
---|
| 1652 | UI.dialogs.addEvent.find('.button').hide(); |
---|
| 1653 | } |
---|
[5592] | 1654 | |
---|
[6044] | 1655 | if(acls.remove) |
---|
| 1656 | UI.dialogs.addEvent.find('.button.remove').show(); |
---|
[6476] | 1657 | |
---|
| 1658 | UI.dialogs.addEvent.find('.button.cancel').show(); |
---|
[6044] | 1659 | } |
---|
[5636] | 1660 | |
---|
[6996] | 1661 | disponibily(objEvent, path, attendees, 'event'); |
---|
[6331] | 1662 | |
---|
| 1663 | /*Seleciona a agenda padrão para criação de um evento*/ |
---|
[6476] | 1664 | if(!objEvent.id){ |
---|
| 1665 | var selectedCalendar = (objEvent.calendar != undefined) ? objEvent.calendar : (User.preferences.defaultCalendar ? User.preferences.defaultCalendar : myCalendar()); |
---|
| 1666 | UI.dialogs.addEvent.find('option[value="'+selectedCalendar+'"]').attr('selected','selected').trigger('change'); |
---|
| 1667 | } |
---|
[6044] | 1668 | UI.dialogs.addEvent.find(':input').change(function(event){ |
---|
| 1669 | if (event.keyCode != '27' && event.keyCode != '13') |
---|
| 1670 | canDiscardEventDialog = false; |
---|
| 1671 | }).keydown(function(event){ |
---|
| 1672 | if (event.keyCode != '27' && event.keyCode != '13') |
---|
| 1673 | canDiscardEventDialog = false; |
---|
| 1674 | }); |
---|
[5636] | 1675 | |
---|
[6044] | 1676 | UI.dialogs.addEvent.dialog('open'); |
---|
[6996] | 1677 | |
---|
[5341] | 1678 | } |
---|
| 1679 | |
---|
[5353] | 1680 | |
---|
| 1681 | |
---|
[5341] | 1682 | function add_tab_preferences() |
---|
| 1683 | { |
---|
[6044] | 1684 | if(!(document.getElementById('preference_tab'))) |
---|
| 1685 | { |
---|
| 1686 | var tab_title = "Preferencias"; |
---|
| 1687 | $tabs.tabs( "add", "#preference_tab", tab_title ); |
---|
[5341] | 1688 | |
---|
[6044] | 1689 | /* |
---|
[5341] | 1690 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 1691 | tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1692 | }); |
---|
| 1693 | */ |
---|
[6044] | 1694 | DataLayer.render( 'templates/preferences_calendar.ejs', { |
---|
| 1695 | preferences:User.preferences, |
---|
[7997] | 1696 | calendars: Calendar.calendars, |
---|
| 1697 | signatureOf : Calendar.signatureOf |
---|
[6044] | 1698 | }, function( template ){ |
---|
| 1699 | var tabPrefCalendar = jQuery('#preference_tab').html( template ).find('.preferences-win'); |
---|
[5341] | 1700 | |
---|
[7997] | 1701 | tabPrefCalendar.find('select[name="defaultCalendar"] option[value="'+User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); |
---|
| 1702 | tabPrefCalendar.find('select[name="dafaultImportCalendar"] option[value="'+User.preferences.dafaultImportCalendar+'"]').attr('selected','selected').trigger('change'); |
---|
| 1703 | |
---|
[7996] | 1704 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
[6044] | 1705 | tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1706 | }); |
---|
[5341] | 1707 | |
---|
[6044] | 1708 | tabPrefCalendar.find('.button').button() |
---|
| 1709 | .filter('.save').click(function(evt){ |
---|
| 1710 | tabPrefCalendar.find('form').submit(); |
---|
| 1711 | $('#calendar').fullCalendar('render'); |
---|
| 1712 | $('.block-vertical-toolbox .mini-calendar').datepicker( "refresh" ); |
---|
| 1713 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 1714 | }).end().filter('.cancel').click(function(evt){ |
---|
| 1715 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 1716 | }); |
---|
[5341] | 1717 | |
---|
[6044] | 1718 | tabPrefCalendar.find('.number').numeric(); |
---|
[5510] | 1719 | |
---|
[6044] | 1720 | tabPrefCalendar.find('input.time').timepicker({ |
---|
| 1721 | closeText: 'Ok', |
---|
| 1722 | hourGrid: 4, |
---|
| 1723 | minuteGrid: 10, |
---|
| 1724 | ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false), //((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 1725 | timeFormat: "hh:mm tt", |
---|
| 1726 | onSelect: function (selectedDateTime){ |
---|
| 1727 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1728 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1729 | } |
---|
| 1730 | }, |
---|
| 1731 | onClose : function (selectedDateTime){ |
---|
| 1732 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1733 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1734 | } |
---|
| 1735 | } |
---|
| 1736 | }); |
---|
[5510] | 1737 | |
---|
[6044] | 1738 | $.mask.definitions['{']='[ap]'; |
---|
| 1739 | $.mask.definitions['}']='[m]'; |
---|
| 1740 | tabPrefCalendar.find("input.time").mask( ((User.preferences.hourFormat.length > 5) ? "99:99 {}" : "99:99"), { |
---|
| 1741 | completed:function(){ |
---|
| 1742 | $(this).val(dateCalendar.defaultToAmPm($(this).val())); |
---|
| 1743 | $(this).timepicker("refresh"); |
---|
| 1744 | $(this).val($(this).val().replace(/[\.]/gi, "")); |
---|
| 1745 | } |
---|
| 1746 | }); |
---|
[5510] | 1747 | |
---|
[6044] | 1748 | tabPrefCalendar.find("select[name=hourFormat]").change( function() { // evento ao selecionar formato de hora |
---|
[5510] | 1749 | |
---|
[6044] | 1750 | tabPrefCalendar.find("input.time").timepicker("destroy"); |
---|
[5510] | 1751 | |
---|
[6044] | 1752 | tabPrefCalendar.find('input.time').timepicker({ |
---|
| 1753 | closeText: 'Ok', |
---|
| 1754 | hourGrid: 4, |
---|
| 1755 | minuteGrid: 10, |
---|
| 1756 | ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false), |
---|
| 1757 | timeFormat: "hh:mm tt", |
---|
| 1758 | onSelect: function (selectedDateTime){ |
---|
| 1759 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1760 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1761 | } |
---|
| 1762 | }, |
---|
| 1763 | onClose : function (selectedDateTime){ |
---|
| 1764 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1765 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1766 | } |
---|
| 1767 | } |
---|
| 1768 | }); |
---|
[5510] | 1769 | |
---|
[6044] | 1770 | var defaultStartHour = tabPrefCalendar.find("input[name=defaultStartHour]").val().trim(); |
---|
| 1771 | var defaultEndHour = tabPrefCalendar.find("input[name=defaultEndHour]").val().trim(); |
---|
[5510] | 1772 | |
---|
[6044] | 1773 | tabPrefCalendar.find("input.time").mask( (($("select[name=hourFormat] option:selected").val().trim().length > 5) ? "99:99 {}" : "99:99") ); |
---|
[5510] | 1774 | |
---|
[6044] | 1775 | if (parseInt($("select[name=hourFormat] option:selected").val().length) > 5) { // am/pm |
---|
| 1776 | tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.defaultToAmPm(defaultStartHour)); |
---|
| 1777 | tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.defaultToAmPm(defaultEndHour)) |
---|
[5510] | 1778 | |
---|
[6044] | 1779 | } else { //24h |
---|
| 1780 | tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.AmPmTo24(defaultStartHour)); |
---|
| 1781 | tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.AmPmTo24(defaultEndHour)); |
---|
| 1782 | } |
---|
| 1783 | }); |
---|
[5510] | 1784 | |
---|
| 1785 | |
---|
| 1786 | |
---|
[6044] | 1787 | }); |
---|
| 1788 | } else { |
---|
| 1789 | $tabs.tabs("select", "#preference_tab"); |
---|
[5341] | 1790 | |
---|
[6044] | 1791 | return true; |
---|
| 1792 | } |
---|
[5341] | 1793 | } |
---|
| 1794 | |
---|
| 1795 | |
---|
[6996] | 1796 | function add_tab_configure_calendar(calendar, type) |
---|
[5341] | 1797 | { |
---|
[6996] | 1798 | $('.qtip.qtip-blue').remove(); |
---|
| 1799 | |
---|
[6044] | 1800 | var calendars = []; |
---|
| 1801 | var signatures = []; |
---|
| 1802 | var previewActiveCalendarConf = 0; |
---|
[6498] | 1803 | var calendarAlarms = []; |
---|
| 1804 | |
---|
[6996] | 1805 | for (var i=0; i<Calendar.signatures.length; i++) { |
---|
| 1806 | if(parseInt(Calendar.signatures[i].calendar.type) == type){ |
---|
| 1807 | calendars.push(Calendar.signatures[i].calendar); |
---|
| 1808 | signatures.push(Calendar.signatures[i]); |
---|
| 1809 | length = signatures.length - 1; |
---|
| 1810 | signatures[length].numberDefaultAlarm = signatures[length].defaultAlarms != '' ? signatures[length].defaultAlarms.length: 0; |
---|
| 1811 | if (calendar && calendars[length].id == calendar) |
---|
| 1812 | previewActiveCalendarConf = length; |
---|
| 1813 | } |
---|
| 1814 | } |
---|
| 1815 | var tab_selector = ['configure_tab', 'configure_tab_group']; |
---|
| 1816 | if(!(document.getElementById(tab_selector[type]))) |
---|
[6044] | 1817 | { |
---|
| 1818 | $('.positionHelper').css('display', 'none'); |
---|
[6696] | 1819 | $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); |
---|
[6996] | 1820 | if(type == 0){ |
---|
| 1821 | var tab_title = "Configurações de agendas"; |
---|
| 1822 | }else{ |
---|
| 1823 | var tab_title = "Configurações de Grupos"; |
---|
| 1824 | } |
---|
| 1825 | $tabs.tabs( "add", "#"+tab_selector[type], tab_title ); |
---|
[5341] | 1826 | |
---|
[6044] | 1827 | var dataColorPicker = { |
---|
| 1828 | colorsSuggestions: colors_suggestions() |
---|
| 1829 | }; |
---|
[5341] | 1830 | |
---|
| 1831 | |
---|
| 1832 | |
---|
[6044] | 1833 | var populateAccordionOnActive = function(event, ui) { |
---|
| 1834 | var nowActive = (typeof(event) == 'number') ? event : $(event.target).accordion( "option", "active" ); |
---|
[6696] | 1835 | if (nowActive === false) |
---|
| 1836 | return; |
---|
[6044] | 1837 | dataColorPicker.colorsDefined = { |
---|
| 1838 | border: '#'+signatures[nowActive].borderColor, |
---|
| 1839 | font:'#'+signatures[nowActive].fontColor, |
---|
| 1840 | background:'#'+signatures[nowActive].backgroundColor |
---|
| 1841 | }; |
---|
| 1842 | if (!jQuery('.accordion-user-calendars .ui-accordion-content').eq(nowActive).has('form')) { |
---|
| 1843 | return true; |
---|
| 1844 | } |
---|
[5341] | 1845 | |
---|
[6044] | 1846 | DataLayer.render( 'templates/configure_calendars_itemlist.ejs', { |
---|
| 1847 | user:User, |
---|
[6996] | 1848 | type:0, |
---|
[6044] | 1849 | calendar:calendars[nowActive], |
---|
| 1850 | signature:signatures[nowActive] |
---|
| 1851 | }, function( form_template ){ |
---|
[6996] | 1852 | var form_content = jQuery('#'+tab_selector[type]+' .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form'); |
---|
[6044] | 1853 | form_content.find('.preferences-alarms-list .button').button({ |
---|
| 1854 | text:false, |
---|
| 1855 | icons:{ |
---|
| 1856 | primary:'ui-icon-close' |
---|
| 1857 | } |
---|
| 1858 | }); |
---|
| 1859 | form_content.find('.button').button(); |
---|
[6498] | 1860 | jQuery('.preferences-alarms-list').find('.button.remove').click(function(el){ |
---|
| 1861 | calendarAlarms[calendarAlarms.length] = $(this).parent('li').find('input[name="alarmId[]"]').val(); |
---|
| 1862 | $(this).parent().remove(); |
---|
| 1863 | }); |
---|
| 1864 | |
---|
[6044] | 1865 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 1866 | var valueTimeZone = calendars[nowActive].timezone; |
---|
| 1867 | form_content.find('select[name="timezone"]').html(timezones_options).find('option[value="'+valueTimeZone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1868 | }); |
---|
[5341] | 1869 | |
---|
[6044] | 1870 | form_content.find('.button-add-alarms').click(function(){ |
---|
[7405] | 1871 | DataLayer.render( 'templates/alarms_add_itemlist.ejs', {type: (parseInt(type) == 1 ? '4' : type) }, function( template ){ |
---|
[6044] | 1872 | jQuery('.preferences-alarms-list').append(template) |
---|
| 1873 | .find('li:last label:eq(0)').remove().end() |
---|
| 1874 | .find('.number').numeric().end() |
---|
| 1875 | .find('.button.remove').button({ |
---|
| 1876 | text:false, |
---|
| 1877 | icons:{ |
---|
| 1878 | primary:'ui-icon-close' |
---|
| 1879 | } |
---|
| 1880 | }).click(function(el) { |
---|
| 1881 | $(this).parent().remove(); |
---|
| 1882 | }); |
---|
| 1883 | }); |
---|
| 1884 | }); |
---|
[5341] | 1885 | |
---|
| 1886 | |
---|
[6044] | 1887 | /** |
---|
[5341] | 1888 | * Set color picker |
---|
| 1889 | */ |
---|
[6044] | 1890 | DataLayer.render( 'templates/calendar_colorpicker.ejs', dataColorPicker, function( template ){ |
---|
| 1891 | form_content.find('.calendar-colorpicker').html( template ); |
---|
[5341] | 1892 | |
---|
[6044] | 1893 | var f = $.farbtastic(form_content.find('.colorpicker'), colorpickerPreviewChange); |
---|
| 1894 | var selected; |
---|
| 1895 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
[5341] | 1896 | |
---|
[6044] | 1897 | var colorpickerPreviewChange = function(color) { |
---|
| 1898 | var pickedup = form_content.find('.colorwell-selected').val(color).css('background-color', color); |
---|
[5341] | 1899 | |
---|
[6044] | 1900 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
[5341] | 1901 | |
---|
[6044] | 1902 | if (pickedup.is('input[name="backgroundColor"]')) { |
---|
| 1903 | colorpicker.find('.fc-event-skin').css('background-color',color); |
---|
| 1904 | } else if (pickedup.is('input[name="fontColor"]')) { |
---|
| 1905 | colorpicker.find('.fc-event-skin').css('color',color); |
---|
| 1906 | } else if (pickedup.is('input[name="borderColor"]')) { |
---|
| 1907 | colorpicker.find('.fc-event-skin').css('border-color',color); |
---|
| 1908 | } |
---|
| 1909 | } |
---|
[5341] | 1910 | |
---|
[6044] | 1911 | form_content.find('.colorwell').each(function () { |
---|
| 1912 | f.linkTo(this); |
---|
[5341] | 1913 | |
---|
[6044] | 1914 | if ($(this).is('input[name="backgroundColor"]')) { |
---|
| 1915 | colorpicker.find('.fc-event-skin').css('background-color', $(this).val()); |
---|
| 1916 | } else if ($(this).is('input[name="fontColor"]')) { |
---|
| 1917 | colorpicker.find('.fc-event-skin').css('color', $(this).val()); |
---|
| 1918 | } else if ($(this).is('input[name="borderColor"]')) { |
---|
| 1919 | colorpicker.find('.fc-event-skin').css('border-color', $(this).val()); |
---|
| 1920 | } |
---|
| 1921 | }) |
---|
| 1922 | .focus(function() { |
---|
| 1923 | if (selected) { |
---|
| 1924 | $(selected).removeClass('colorwell-selected'); |
---|
| 1925 | } |
---|
[5341] | 1926 | |
---|
[6044] | 1927 | $(selected = this).addClass('colorwell-selected'); |
---|
| 1928 | f.linkTo(this, colorpickerPreviewChange); |
---|
| 1929 | f.linkTo(colorpickerPreviewChange); |
---|
[5341] | 1930 | |
---|
[6044] | 1931 | }); |
---|
[5341] | 1932 | |
---|
[6044] | 1933 | form_content.find('select.color-suggestions').change(function() { |
---|
| 1934 | var colors; |
---|
[5341] | 1935 | |
---|
[6044] | 1936 | if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) { |
---|
| 1937 | colorpicker |
---|
| 1938 | .find('input[name="fontColor"]').val(colors.font).focus().end() |
---|
| 1939 | .find('input[name="backgroundColor"]').val(colors.background).focus().end() |
---|
| 1940 | .find('input[name="borderColor"]').val(colors.border).focus().end() |
---|
[5341] | 1941 | |
---|
[6044] | 1942 | .find('.fc-event-skin').css({ |
---|
| 1943 | 'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background, |
---|
| 1944 | 'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border, |
---|
| 1945 | 'color':dataColorPicker.colorsSuggestions[$(this).val()].font |
---|
| 1946 | }); |
---|
| 1947 | } |
---|
| 1948 | }); |
---|
[5341] | 1949 | |
---|
[6044] | 1950 | /** |
---|
[5341] | 1951 | * Trata a mudança dos valores dos campos de cores. |
---|
| 1952 | * Se mudar um conjunto de cores sugerido, |
---|
| 1953 | * este vira um conjunto de cores personalizado. |
---|
| 1954 | */ |
---|
[6044] | 1955 | form_content.find('.colorwell').change(function (element, ui) { |
---|
| 1956 | if (true) { |
---|
| 1957 | form_content.find('select.color-suggestions') |
---|
| 1958 | .find('option:selected').removeAttr('selected').end() |
---|
| 1959 | .find('option[value="custom"]').attr('selected', 'selected').trigger('change'); |
---|
| 1960 | } |
---|
| 1961 | }); |
---|
| 1962 | }); //END set colorpicker |
---|
[5341] | 1963 | |
---|
[6044] | 1964 | form_content.find('.phone').mask("+99 (99) 9999-9999"); |
---|
| 1965 | form_content.find('.number').numeric(); |
---|
[5341] | 1966 | |
---|
[6044] | 1967 | }); //END DataLayer.render( 'templates/configure_calendars_itemlist.ejs' ... |
---|
[5341] | 1968 | |
---|
[6044] | 1969 | // === validations preferences ==== |
---|
[5341] | 1970 | |
---|
| 1971 | |
---|
[6044] | 1972 | } //END populateAccordionOnActive(event, ui) |
---|
[5341] | 1973 | |
---|
| 1974 | |
---|
[6044] | 1975 | DataLayer.render( 'templates/configure_calendars.ejs', { |
---|
| 1976 | user:User, |
---|
[7259] | 1977 | type: type, |
---|
[6044] | 1978 | calendars:calendars, |
---|
| 1979 | signatures:signatures |
---|
| 1980 | }, function( template ){ |
---|
[6996] | 1981 | var template_content = jQuery('#'+tab_selector[type]).html( template ).find('.configure-calendars-win'); |
---|
[6044] | 1982 | template_content.find('.button').button().filter('.save').click(function(evt){ |
---|
[6498] | 1983 | if(calendarAlarms.length) |
---|
| 1984 | DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]}); |
---|
[6044] | 1985 | template_content.find('form').submit(); |
---|
[6996] | 1986 | $tabs.tabs( "remove", "#"+tab_selector[type]); |
---|
[6044] | 1987 | DataLayer.commit( false, false, function( received ){ |
---|
| 1988 | delete Calendar.currentViewKey; |
---|
| 1989 | Calendar.load(); |
---|
| 1990 | refresh_calendars(); |
---|
| 1991 | }); |
---|
[6498] | 1992 | if(calendarAlarms.length) |
---|
| 1993 | Calendar.load(); |
---|
[6044] | 1994 | }).end().filter('.cancel').click(function(evt){ |
---|
[6996] | 1995 | $tabs.tabs( "remove", "#"+tab_selector[type]); |
---|
[6044] | 1996 | }); |
---|
[5341] | 1997 | |
---|
[6044] | 1998 | /** |
---|
[5341] | 1999 | * Muda a estrutura do template para a aplicação do plugin accordion |
---|
| 2000 | */ |
---|
[6044] | 2001 | template_content.find('.header-menu-container').after('<div class="accordion-user-calendars"></div>').end().find('.accordion-user-calendars') |
---|
| 2002 | .append(template_content.children('fieldset')); |
---|
[5341] | 2003 | |
---|
[6044] | 2004 | template_content.find('.accordion-user-calendars').children('fieldset').each(function(index) { |
---|
| 2005 | $(this).before($('<h3></h3>').html($(this).children('legend'))); |
---|
| 2006 | }); |
---|
[5341] | 2007 | |
---|
[6044] | 2008 | template_content.find('.accordion-user-calendars').accordion({ |
---|
| 2009 | autoHeight: false, |
---|
| 2010 | collapsible: true, |
---|
| 2011 | clearStyle: true, |
---|
| 2012 | active: previewActiveCalendarConf, |
---|
| 2013 | changestart: populateAccordionOnActive |
---|
| 2014 | }); |
---|
| 2015 | populateAccordionOnActive(previewActiveCalendarConf); |
---|
| 2016 | }); |
---|
[5341] | 2017 | |
---|
[6044] | 2018 | } else { |
---|
[6696] | 2019 | $('.positionHelper').css('display','none'); |
---|
| 2020 | $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); |
---|
[6996] | 2021 | $tabs.tabs("select", "#"+tab_selector[type]); |
---|
[6044] | 2022 | $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); |
---|
[5341] | 2023 | |
---|
[6044] | 2024 | return true; |
---|
| 2025 | } |
---|
[5341] | 2026 | |
---|
| 2027 | } |
---|
| 2028 | |
---|
[6996] | 2029 | function getSelectedCalendars( reverse, type ){ |
---|
[7964] | 2030 | var selector = !!type ? "div.my-groups-task .calendar-view" : "div.my-calendars .calendar-view, div.signed-calendars .calendar-view"; |
---|
| 2031 | var returns = []; |
---|
| 2032 | |
---|
| 2033 | $.each( $(selector), function(i , c){ |
---|
| 2034 | |
---|
| 2035 | if( reverse ? !c.checked : c.checked ) |
---|
| 2036 | returns.push( c.value ); |
---|
| 2037 | |
---|
[6044] | 2038 | }); |
---|
[7964] | 2039 | |
---|
| 2040 | if (!returns.length) |
---|
| 2041 | return false; |
---|
| 2042 | |
---|
| 2043 | return returns; |
---|
[5341] | 2044 | } |
---|
| 2045 | |
---|
| 2046 | /** |
---|
| 2047 | * TODO - transformar em preferência do módulo e criar telas de adição e exclusão de conjunto de cores |
---|
| 2048 | */ |
---|
| 2049 | function colors_suggestions(){ |
---|
[6044] | 2050 | return [ |
---|
| 2051 | { |
---|
| 2052 | name:'Padrão', |
---|
| 2053 | border:'#3366cc', |
---|
| 2054 | font:'#ffffff', |
---|
| 2055 | background:'#3366cc' |
---|
| 2056 | }, |
---|
| 2057 | |
---|
| 2058 | { |
---|
| 2059 | name:'Coala', |
---|
| 2060 | border:'#123456', |
---|
| 2061 | font:'#ffffff', |
---|
| 2062 | background:'#385c80' |
---|
| 2063 | }, |
---|
| 2064 | |
---|
| 2065 | { |
---|
| 2066 | name:'Tomate', |
---|
| 2067 | border:'#d5130b', |
---|
| 2068 | font:'#111111', |
---|
| 2069 | background:'#e36d76' |
---|
| 2070 | }, |
---|
| 2071 | |
---|
| 2072 | { |
---|
| 2073 | name:'Limão', |
---|
| 2074 | border:'#32ed21', |
---|
| 2075 | font:'#1f3f1c', |
---|
| 2076 | background:'#b2f1ac' |
---|
| 2077 | }, |
---|
| 2078 | |
---|
| 2079 | { |
---|
| 2080 | name:'Alto contraste', |
---|
| 2081 | border:'#000000', |
---|
| 2082 | font:'#ffffff', |
---|
| 2083 | background:'#222222' |
---|
| 2084 | } |
---|
| 2085 | ] |
---|
[5341] | 2086 | } |
---|
| 2087 | |
---|
[7017] | 2088 | function remove_event(eventId, idCalendar, type){ |
---|
[6996] | 2089 | $.Zebra_Dialog('Tem certeza que deseja excluir?', { |
---|
[6044] | 2090 | 'type': 'question', |
---|
| 2091 | 'overlay_opacity': '0.5', |
---|
| 2092 | 'buttons': ['Sim', 'Não'], |
---|
| 2093 | 'onClose': function(clicked) { |
---|
| 2094 | if(clicked == 'Sim'){ |
---|
[6331] | 2095 | |
---|
[7702] | 2096 | var schedulable = getSchedulable( eventId, ''); |
---|
[6359] | 2097 | schedulable.calendar = ''+idCalendar; |
---|
[6331] | 2098 | var schudableDecode = DataLayer.encode( "schedulable:preview", schedulable); |
---|
| 2099 | var me = schudableDecode.me.user ? schudableDecode.me.user.id : schudableDecode.me.id; |
---|
| 2100 | |
---|
[7017] | 2101 | var filter = {filter: ['AND', ['=','id',eventId], ['=','calendar',idCalendar], ['=','user', me]]}; |
---|
| 2102 | |
---|
| 2103 | if(type) |
---|
| 2104 | filter.filter.push(['=','type',type]); |
---|
| 2105 | |
---|
| 2106 | DataLayer.removeFilter('schedulable', filter); |
---|
[6286] | 2107 | Calendar.rerenderView(true); |
---|
[6044] | 2108 | } |
---|
| 2109 | } |
---|
| 2110 | }); |
---|
[5592] | 2111 | } |
---|
| 2112 | |
---|
[7953] | 2113 | function mount_exception(eventID, exception){ |
---|
[5592] | 2114 | |
---|
[7702] | 2115 | getSchedulable( eventID.toString() , ''); |
---|
| 2116 | var schedulable = DataLayer.get('schedulable', eventID.toString() ) |
---|
| 2117 | var edit = { repeat: (DataLayer.get('repeat', schedulable.repeat)) }; |
---|
| 2118 | |
---|
[5746] | 2119 | edit.repeat.startTime = new Date(parseInt(edit.repeat.startTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5752] | 2120 | edit.repeat.endTime = parseInt(edit.repeat.count) > 0 ? '0' : new Date(parseInt(edit.repeat.endTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5746] | 2121 | |
---|
[7953] | 2122 | edit.repeat.exceptions = ( exception ); |
---|
[5746] | 2123 | |
---|
| 2124 | return edit.repeat; |
---|
| 2125 | } |
---|
| 2126 | |
---|
| 2127 | function remove_ocurrence(eventId, idRecurrence){ |
---|
[6044] | 2128 | $.Zebra_Dialog('Tem certeza que deseja excluir esta ocorrência?', { |
---|
| 2129 | 'type': 'question', |
---|
| 2130 | 'overlay_opacity': '0.5', |
---|
| 2131 | 'buttons': ['Sim', 'Não'], |
---|
| 2132 | 'onClose': function(clicked) { |
---|
| 2133 | if(clicked == 'Sim'){ |
---|
| 2134 | var repeat = mount_exception(eventId, idRecurrence); |
---|
| 2135 | DataLayer.remove('repeat', false); |
---|
| 2136 | DataLayer.put('repeat', repeat); |
---|
| 2137 | DataLayer.commit(false, false, function(data){ |
---|
| 2138 | Calendar.rerenderView(true); |
---|
| 2139 | }); |
---|
| 2140 | } |
---|
| 2141 | } |
---|
| 2142 | }); |
---|
[5746] | 2143 | } |
---|
| 2144 | |
---|
| 2145 | |
---|
[6996] | 2146 | function remove_calendar(type){ |
---|
[6044] | 2147 | /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ |
---|
[6996] | 2148 | if(!!parseInt(type)) |
---|
| 2149 | var title = 'Todas as tarefas deste grupo serão removidas. Deseja prosseguir com a operação?'; |
---|
| 2150 | else |
---|
| 2151 | var title = 'Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?'; |
---|
| 2152 | $.Zebra_Dialog(title, { |
---|
[6044] | 2153 | 'type': 'question', |
---|
| 2154 | 'overlay_opacity': '0.5', |
---|
| 2155 | 'buttons': ['Sim', 'Não'], |
---|
| 2156 | 'onClose': function(clicked) { |
---|
| 2157 | if(clicked == 'Sim'){ |
---|
| 2158 | var idCalendar = $('.cal-list-options-btn.ui-state-active').attr('class').match(/[0-9]+/g); |
---|
[5592] | 2159 | |
---|
[6044] | 2160 | DataLayer.remove('calendarSignature', Calendar.signatureOf[idCalendar[0]].id ); |
---|
[5592] | 2161 | |
---|
[6044] | 2162 | if(idCalendar == User.preferences.defaultCalendar) |
---|
| 2163 | DataLayer.remove( 'modulePreference', User.preferenceIds['defaultCalendar']); |
---|
[5636] | 2164 | |
---|
[6044] | 2165 | DataLayer.commit( false, false, function( received ){ |
---|
| 2166 | delete Calendar.currentViewKey; |
---|
| 2167 | Calendar.load(); |
---|
[6996] | 2168 | refresh_calendars(type); |
---|
[6044] | 2169 | }); |
---|
| 2170 | } |
---|
| 2171 | $('.positionHelper').css('display', 'none'); |
---|
[5409] | 2172 | |
---|
[6044] | 2173 | } |
---|
| 2174 | }); |
---|
[5341] | 2175 | } |
---|
| 2176 | |
---|
[6996] | 2177 | function refresh_calendars(type){ |
---|
[5341] | 2178 | |
---|
[6044] | 2179 | var colorsSuggestions = colors_suggestions(); |
---|
| 2180 | var buttons_colors = ""; |
---|
| 2181 | for(var i = 0; i < colorsSuggestions.length; i++){ |
---|
| 2182 | buttons_colors += "<a class=\"cal-colors-options-btn ui-icon ui-button-icon-primary signed-cal-colors-options-btn-"+i+"\" style=\"background-color:"+colorsSuggestions[i]['background']+"; border-color:"+colorsSuggestions[i]['border']+"; color:"+colorsSuggestions[i]['font']+"\">•</a>"; |
---|
| 2183 | } |
---|
[5341] | 2184 | |
---|
[6044] | 2185 | //DataLayer.render( 'templates/calendar_list.ejs', 'calendar:list', ["IN", "id", Calendar.calendarIds], function( html ){ |
---|
| 2186 | DataLayer.render( 'templates/calendar_list.ejs', Calendar, function( html ){ |
---|
[5341] | 2187 | |
---|
[6044] | 2188 | var meu_container = $(".calendars-list").html( html ); |
---|
[5341] | 2189 | |
---|
[6674] | 2190 | var doMenu = function(){ |
---|
| 2191 | $('ul.list-calendars .cal-list-options-btn').each(function(){ |
---|
| 2192 | $(this).menu({ |
---|
| 2193 | content: $(this).next().html(), |
---|
| 2194 | width: '120', |
---|
| 2195 | positionOpts: { |
---|
| 2196 | posX: 'left', |
---|
| 2197 | posY: 'bottom', |
---|
| 2198 | offsetX: 0, |
---|
| 2199 | offsetY: 0, |
---|
| 2200 | directionH: 'right', |
---|
| 2201 | directionV: 'down', |
---|
| 2202 | detectH: true, // do horizontal collision detection |
---|
| 2203 | detectV: true, // do vertical collision detection |
---|
| 2204 | linkToFront: false |
---|
| 2205 | }, |
---|
| 2206 | flyOut: true, |
---|
| 2207 | showSpeed: 100, |
---|
| 2208 | crumbDefaultText: '>' |
---|
| 2209 | }); |
---|
| 2210 | }); |
---|
| 2211 | } |
---|
[6996] | 2212 | |
---|
[6674] | 2213 | doMenu(); |
---|
[6996] | 2214 | var currentToolTip = null; |
---|
[6674] | 2215 | $('#divAppbox').on('scroll',function(){ |
---|
| 2216 | if ($('.cal-list-options-btn.fg-menu-open.ui-state-active')){ |
---|
| 2217 | var offset = $('.cal-list-options-btn.fg-menu-open.ui-state-active').offset(); |
---|
| 2218 | if (offset) |
---|
[6996] | 2219 | $('.positionHelper').css('top',offset.top); |
---|
[6674] | 2220 | } |
---|
[6996] | 2221 | |
---|
[6956] | 2222 | if ($('.button.config-menu.fg-menu-open')){ |
---|
| 2223 | var offset = $('.button.config-menu.fg-menu-open').offset(); |
---|
| 2224 | if (offset) |
---|
[6996] | 2225 | $('.positionHelper').css('top',offset.top); |
---|
[6956] | 2226 | } |
---|
[6996] | 2227 | |
---|
| 2228 | |
---|
| 2229 | if ($(".new-group.qtip-active").length || $(".new-calendar.qtip-active").length) |
---|
| 2230 | $('.qtip-active').css('top',currentToolTip.offset().top - 50); |
---|
| 2231 | |
---|
[6674] | 2232 | }); |
---|
[7928] | 2233 | |
---|
| 2234 | $('ul.list-calendars .cal-list-options-btn').on('click',function(){doMenu();}); |
---|
[6996] | 2235 | |
---|
| 2236 | |
---|
| 2237 | /***************************************New Calendar***************************************/ |
---|
[5592] | 2238 | meu_container.find(".button.new-calendar").button({ |
---|
[6044] | 2239 | icons: { |
---|
| 2240 | primary: "ui-icon-plus" |
---|
| 2241 | }, |
---|
| 2242 | text: false |
---|
| 2243 | }).click(function () { |
---|
[6996] | 2244 | currentToolTip = $(this); |
---|
| 2245 | var typeCalendar = !!parseInt($(this).attr('class').match(/[0-9]+/g)) ? |
---|
| 2246 | {type: 'new-group', title: 'Novo Grupo', typeValue: 1, prompt: 'Nome do grupo'} : |
---|
| 2247 | {type: 'new-calendar', title: 'Nova Agenda', typeValue: 0, prompt: 'Nome da agenda'} |
---|
[5341] | 2248 | |
---|
[6996] | 2249 | if(!$('.qtip.qtip-blue.qtip-active.'+typeCalendar.type).length){ |
---|
| 2250 | |
---|
| 2251 | $('.qtip.qtip-blue').remove(); |
---|
| 2252 | |
---|
| 2253 | $(this).qtip({ |
---|
| 2254 | show: { |
---|
| 2255 | ready: true, |
---|
| 2256 | solo: true, |
---|
| 2257 | when: { |
---|
| 2258 | event: 'click' |
---|
| 2259 | } |
---|
| 2260 | }, |
---|
| 2261 | hide: false, |
---|
| 2262 | content: { |
---|
| 2263 | text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), |
---|
| 2264 | title: { |
---|
| 2265 | text: typeCalendar.title, |
---|
| 2266 | button: '<a class="button close" href="#">close</a>' |
---|
| 2267 | } |
---|
| 2268 | }, |
---|
| 2269 | style: { |
---|
| 2270 | name: 'blue', |
---|
| 2271 | tip: { |
---|
| 2272 | corner: 'leftMiddle' |
---|
| 2273 | }, |
---|
| 2274 | border: { |
---|
| 2275 | width: 4, |
---|
| 2276 | radius: 8 |
---|
| 2277 | }, |
---|
| 2278 | width: { |
---|
| 2279 | min: 230, |
---|
| 2280 | max:230 |
---|
| 2281 | } |
---|
| 2282 | }, |
---|
| 2283 | position: { |
---|
| 2284 | corner: { |
---|
| 2285 | target: 'rightMiddle', |
---|
| 2286 | tooltip: 'leftMiddle' |
---|
| 2287 | }, |
---|
| 2288 | adjust: { |
---|
| 2289 | x:0, |
---|
| 2290 | y: -12 |
---|
| 2291 | |
---|
| 2292 | } |
---|
| 2293 | } |
---|
| 2294 | }) |
---|
| 2295 | .qtip("api").onShow = function(arg0) { |
---|
[5341] | 2296 | |
---|
[6996] | 2297 | $('.qtip-active .button.close').button({ |
---|
[7457] | 2298 | icons: { primary: "ui-icon-close" }, |
---|
[6996] | 2299 | text: false |
---|
| 2300 | }) |
---|
| 2301 | .click(function(){ |
---|
[7457] | 2302 | $('.qtip.qtip-blue').remove(); |
---|
[6996] | 2303 | }); |
---|
| 2304 | |
---|
[7457] | 2305 | $('.qtip-active').addClass(typeCalendar.type); |
---|
[6996] | 2306 | |
---|
[7457] | 2307 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 2308 | $('.qtip.qtip-blue').remove(); |
---|
| 2309 | }); |
---|
| 2310 | |
---|
| 2311 | |
---|
[6996] | 2312 | $('.qtip-active .button.save').button().click(function(){ |
---|
| 2313 | if(!typeCalendar.typeValue) |
---|
| 2314 | for(var i = 0; i < Calendar.calendars.length; i++){ |
---|
| 2315 | if(Calendar.calendars[i].location == ( User.me.uid + '/' + $('.qtip-active input').val())){ |
---|
| 2316 | $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ |
---|
| 2317 | 'overlay_opacity': '0.5', |
---|
| 2318 | 'type': 'warning' |
---|
| 2319 | }); |
---|
| 2320 | $('.qtip.qtip-blue').remove(); |
---|
| 2321 | return; |
---|
| 2322 | } |
---|
| 2323 | } |
---|
| 2324 | |
---|
| 2325 | var selected; |
---|
| 2326 | var color = $('.cal-colors-options-btn').each(function(index){ |
---|
| 2327 | if ($(this).is('.color-selected')) |
---|
| 2328 | selected = index; |
---|
| 2329 | }); |
---|
| 2330 | DataLayer.put( "calendarSignature", { |
---|
| 2331 | user: User.me.id, |
---|
| 2332 | calendar: { |
---|
| 2333 | name: Encoder.htmlEncode($('.qtip-active input').val()), |
---|
| 2334 | timezone: User.preferences.timezone, |
---|
| 2335 | type: typeCalendar.typeValue |
---|
| 2336 | }, |
---|
| 2337 | isOwner: 1, |
---|
| 2338 | fontColor: colorsSuggestions[selected]['font'].substring(1) , |
---|
| 2339 | backgroundColor: colorsSuggestions[selected]['background'].substring(1) , |
---|
| 2340 | borderColor: colorsSuggestions[selected]['border'].substring(1) |
---|
| 2341 | }); |
---|
| 2342 | DataLayer.commit( false, false, function( received ){ |
---|
| 2343 | delete Calendar.currentViewKey; |
---|
| 2344 | Calendar.load(); |
---|
| 2345 | refresh_calendars(); |
---|
| 2346 | }); |
---|
| 2347 | $('.qtip.qtip-blue').remove(); |
---|
| 2348 | }); |
---|
[7457] | 2349 | |
---|
[6996] | 2350 | $(".qtip-active input").Watermark(typeCalendar.prompt); |
---|
| 2351 | |
---|
| 2352 | $('.qtip-active').keydown(function(event) { |
---|
| 2353 | if (event.keyCode == '27') |
---|
| 2354 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 2355 | }); |
---|
| 2356 | |
---|
| 2357 | $('.colors-options').prepend(buttons_colors); |
---|
| 2358 | $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); |
---|
| 2359 | |
---|
| 2360 | var buttons = $('.cal-colors-options-btn').button(); |
---|
| 2361 | |
---|
| 2362 | buttons.click(function(){ |
---|
| 2363 | buttons.removeClass('color-selected'); |
---|
| 2364 | $(this).addClass('color-selected'); |
---|
| 2365 | }); |
---|
| 2366 | } |
---|
| 2367 | } |
---|
[6044] | 2368 | }); |
---|
[6996] | 2369 | |
---|
[6044] | 2370 | $("img.cal-list-img").click(function(evt) { |
---|
[6996] | 2371 | $(".cal-list-options_1").toggleClass( "hidden" ); |
---|
[6044] | 2372 | }); |
---|
[5341] | 2373 | |
---|
[6996] | 2374 | $(".my-groups-task a.title-my-calendars").click(function() { |
---|
| 2375 | $(".my-groups-task ul.my-list-calendars").toggleClass("hidden") |
---|
| 2376 | $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-s"); |
---|
| 2377 | $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-e"); |
---|
| 2378 | }); |
---|
| 2379 | |
---|
[6044] | 2380 | $(".my-calendars a.title-my-calendars").click(function() { |
---|
[6996] | 2381 | $(".my-calendars ul.my-list-calendars").toggleClass("hidden") |
---|
| 2382 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s"); |
---|
| 2383 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e"); |
---|
[6044] | 2384 | }); |
---|
[5381] | 2385 | |
---|
[6044] | 2386 | $(".signed-calendars a.title-signed-calendars").click(function() { |
---|
[6996] | 2387 | $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden"); |
---|
[6044] | 2388 | }); |
---|
[5341] | 2389 | |
---|
[6044] | 2390 | $("ul li.list-calendars-item").click(function(evt) { |
---|
[5341] | 2391 | |
---|
[6044] | 2392 | }); |
---|
[5341] | 2393 | |
---|
[6044] | 2394 | $("ul li.list-calendars-item .ui-corner-all").click(function(evt) { |
---|
| 2395 | //alert('teste'); |
---|
| 2396 | }); |
---|
[5341] | 2397 | |
---|
[6044] | 2398 | meu_container.find(".button.new-calendar-shared").button({ |
---|
| 2399 | icons: { |
---|
| 2400 | primary: "ui-icon-plus" |
---|
| 2401 | }, |
---|
| 2402 | text: false |
---|
| 2403 | }).click(function (event) { |
---|
| 2404 | show_modal_search_shared(); |
---|
| 2405 | }); |
---|
[5592] | 2406 | |
---|
[7928] | 2407 | |
---|
[6044] | 2408 | meu_container.find('.title-signed-calendars').click(function(evt){ |
---|
| 2409 | var status = $(this).parent().find('.status-list-shared'); |
---|
[5592] | 2410 | |
---|
[6044] | 2411 | if(status.hasClass('ui-icon-triangle-1-s')) |
---|
| 2412 | status.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); |
---|
| 2413 | else |
---|
| 2414 | status.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); |
---|
| 2415 | }); |
---|
[5592] | 2416 | |
---|
[6044] | 2417 | $('.calendar-view').click(function(evt){ |
---|
[7928] | 2418 | |
---|
[7964] | 2419 | var checkBox = $(this); |
---|
| 2420 | var calendarId = $(this).val(); |
---|
[7928] | 2421 | |
---|
[7964] | 2422 | Calendar.signatureOf[ calendarId ].hidden = (checkBox.is(':checked') ? 0 : 1 ); |
---|
[7928] | 2423 | |
---|
[7964] | 2424 | DataLayer.put('calendarSignature', {id: Calendar.signatureOf[ calendarId ].id , hidden: Calendar.signatureOf[ calendarId ].hidden } ); |
---|
| 2425 | DataLayer.commit(); |
---|
[7928] | 2426 | |
---|
| 2427 | |
---|
[7964] | 2428 | if($tabs.tabs('option' ,'selected') == 0){ |
---|
| 2429 | |
---|
| 2430 | if(Calendar.currentView && !!Calendar.currentView[ calendarId ]){ |
---|
| 2431 | |
---|
| 2432 | Calendar.currentView[ calendarId ].hidden = !checkBox.is(':checked'); |
---|
| 2433 | $('#calendar').fullCalendar( 'refetchEvents' ); |
---|
| 2434 | } |
---|
| 2435 | |
---|
| 2436 | }else{ |
---|
| 2437 | type = $tabs.tabs('option' ,'selected'); |
---|
| 2438 | type = type > 2 ? 2 : (type - 1) |
---|
| 2439 | |
---|
| 2440 | pageselectCallback('', 0, false, type); |
---|
| 2441 | } |
---|
[6044] | 2442 | }); |
---|
| 2443 | }); |
---|
[5341] | 2444 | } |
---|
| 2445 | |
---|
[6996] | 2446 | function add_events_list(keyword, type) |
---|
[5341] | 2447 | { |
---|
[7423] | 2448 | if ($.trim(keyword) == "") return; |
---|
[6044] | 2449 | var tab_title = ""; |
---|
| 2450 | if (keyword){ |
---|
[6996] | 2451 | type = 2; |
---|
| 2452 | if(keyword.length < 10) |
---|
| 2453 | tab_title = keyword; |
---|
| 2454 | else |
---|
| 2455 | tab_title = keyword.substr(0,10) + '..."'; |
---|
[6044] | 2456 | }else{ |
---|
[6996] | 2457 | if(type){ |
---|
| 2458 | if(!!parseInt(type)) |
---|
| 2459 | tab_title = "Lista de tarefas"; |
---|
| 2460 | else |
---|
| 2461 | tab_title = "Lista de eventos"; |
---|
| 2462 | } |
---|
[6044] | 2463 | } |
---|
[6996] | 2464 | var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; |
---|
[6044] | 2465 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
[5341] | 2466 | |
---|
[6996] | 2467 | if(!(document.getElementById(tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") ))) |
---|
[6044] | 2468 | { |
---|
| 2469 | Encoder.EncodeType = "entity"; |
---|
[6996] | 2470 | $tabs.tabs( "add", "#"+tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) ); |
---|
[6044] | 2471 | } |
---|
| 2472 | else /* Tab already opened */ |
---|
| 2473 | { |
---|
[6996] | 2474 | //$tabs.tabs("option", "selected", 2); |
---|
| 2475 | } |
---|
[5341] | 2476 | |
---|
[6996] | 2477 | pageselectCallback(keyword, 0, false, type); // load page 1 and insert data on event_list.ejs |
---|
[5341] | 2478 | |
---|
[6044] | 2479 | $('.preferences-win.active .button.save, .preferences-win.active .button.cancel, .preferences-win.active .button.import, .preferences-win.active .button.export').button(); |
---|
[5341] | 2480 | } |
---|
| 2481 | |
---|
| 2482 | function paginatorSearch(currentView){ |
---|
[6044] | 2483 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
| 2484 | function(){ |
---|
| 2485 | $(this).addClass('fc-state-hover'); |
---|
| 2486 | }, |
---|
| 2487 | function(){ |
---|
| 2488 | $(this).removeClass('fc-state-hover'); |
---|
| 2489 | }).mousedown(function(){ |
---|
| 2490 | $(this).addClass('fc-state-down'); |
---|
| 2491 | }).mouseup(function(){ |
---|
| 2492 | $(this).removeClass('fc-state-down'); |
---|
| 2493 | $('.events-list.events-list-win.active').removeClass('active'); |
---|
| 2494 | var paginator = $(this).attr('class'); |
---|
| 2495 | if(paginator.indexOf('next') > 0){ |
---|
| 2496 | if(parseInt($(currentView+' [name = results]').val()) > 25) |
---|
[6996] | 2497 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), false, 2); |
---|
[6044] | 2498 | }else{ |
---|
| 2499 | if(parseInt($(currentView+' [name = page_index]').val()) > 0) |
---|
[6996] | 2500 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), false, 2); |
---|
[6044] | 2501 | } |
---|
| 2502 | }); |
---|
[5341] | 2503 | } |
---|
| 2504 | |
---|
| 2505 | function mountTitleList(page_index ,view){ |
---|
[6044] | 2506 | switch (view){ |
---|
| 2507 | case 'agendaDay': |
---|
| 2508 | case 'basicDay': |
---|
| 2509 | var date = new Date().add({ |
---|
| 2510 | days: page_index |
---|
| 2511 | }); |
---|
| 2512 | return (dateCalendar.dayNames[date.getDay()])+", "+(date.toString('dd MMM yyyy')); |
---|
| 2513 | case 'agendaWeek': |
---|
| 2514 | var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
| 2515 | dateStart.add({ |
---|
| 2516 | days: (7 * page_index) |
---|
| 2517 | }); |
---|
| 2518 | var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
| 2519 | dateEnd.add({ |
---|
| 2520 | days: (page_index * 7)+7 |
---|
| 2521 | }); |
---|
| 2522 | if(dateStart.toString('MM') != dateEnd.toString('MM')) |
---|
| 2523 | return dateStart.toString('dd')+' de '+dateCalendar.monthNamesShort[dateStart.getMonth()]+' a '+dateEnd.toString('dd')+' de '+dateCalendar.monthNames[dateEnd.getMonth()]+' - '+dateEnd.toString('yyyy'); |
---|
| 2524 | return +dateStart.toString("dd")+" a "+dateEnd.toString("dd")+" de "+dateCalendar.monthNames[dateEnd.getMonth()]+" - "+dateEnd.toString('yyyy'); |
---|
| 2525 | case 'month': |
---|
| 2526 | var date = new Date().add({ |
---|
| 2527 | months: page_index |
---|
| 2528 | }) |
---|
| 2529 | return dateCalendar.monthNames[date.getMonth()]+" "+date.toString("yyyy"); |
---|
| 2530 | case 'year': |
---|
| 2531 | var date = new Date().add({ |
---|
| 2532 | years: page_index |
---|
| 2533 | }); |
---|
| 2534 | return date.toString("yyyy"); |
---|
| 2535 | } |
---|
[5341] | 2536 | } |
---|
| 2537 | |
---|
[6996] | 2538 | function paginatorList(currentView, view, type){ |
---|
| 2539 | $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>'+mountTitleList( parseInt($(currentView+' [name = page_index]').val()),view)+'</h2>'); |
---|
[6044] | 2540 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
| 2541 | if(view == 'basicDay') |
---|
| 2542 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-agendaDay').addClass('fc-state-active'); |
---|
| 2543 | else |
---|
| 2544 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-'+view).addClass('fc-state-active'); |
---|
| 2545 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right').addClass('list-right'); |
---|
[5381] | 2546 | |
---|
[6044] | 2547 | $(currentView+' .header-paginator .fc-header-right .fc-button').hover( |
---|
| 2548 | function(){ |
---|
| 2549 | $(this).addClass('fc-state-hover'); |
---|
| 2550 | }, |
---|
[8020] | 2551 | |
---|
[6044] | 2552 | function(){ |
---|
| 2553 | $(this).removeClass('fc-state-hover'); |
---|
| 2554 | }).mousedown(function(){ |
---|
| 2555 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
| 2556 | $(this).addClass('fc-state-active'); |
---|
| 2557 | }).mouseup(function(){ |
---|
| 2558 | var goView = $(this).attr('class'); |
---|
| 2559 | if(goView.indexOf('agendaDay') > 0) |
---|
[6996] | 2560 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaDay', type); |
---|
[6044] | 2561 | else if(goView.indexOf('month') > 0) |
---|
[6996] | 2562 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'month', type); |
---|
[6044] | 2563 | else if(goView.indexOf('year') > 0) |
---|
[6996] | 2564 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'year', type); |
---|
[6044] | 2565 | else if(goView.indexOf('agendaWeek') > 0) |
---|
[6996] | 2566 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaWeek', type); |
---|
[5381] | 2567 | |
---|
[6044] | 2568 | }); |
---|
[5381] | 2569 | |
---|
[6044] | 2570 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
| 2571 | function(){ |
---|
| 2572 | $(this).addClass('fc-state-hover'); |
---|
| 2573 | }, |
---|
| 2574 | function(){ |
---|
| 2575 | $(this).removeClass('fc-state-hover'); |
---|
| 2576 | }).mousedown(function(){ |
---|
| 2577 | $(this).addClass('fc-state-down'); |
---|
| 2578 | }).mouseup(function(){ |
---|
| 2579 | $(this).removeClass('fc-state-down'); |
---|
| 2580 | var paginator = $(this).attr('class'); |
---|
| 2581 | if(paginator.indexOf('next') > 0) |
---|
[6996] | 2582 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), view, type); |
---|
[6044] | 2583 | else |
---|
[6996] | 2584 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), view, type); |
---|
[6044] | 2585 | }); |
---|
[5341] | 2586 | } |
---|
| 2587 | |
---|
[6996] | 2588 | function printEventList(view){ |
---|
| 2589 | $('.fc-button-print.print-list-events').click(function(){ |
---|
| 2590 | var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); |
---|
| 2591 | var listEvents = $(view).clone(); |
---|
| 2592 | listEvents.find('.fc-button').remove(); |
---|
| 2593 | listEvents.find('.details-event-list').remove(); |
---|
[7022] | 2594 | listEvents.find('.list-events-paginator').remove(); |
---|
[6996] | 2595 | listEvents = listEvents.html(); |
---|
| 2596 | type = $(this).parents('.ui-tabs-panel').attr("id").split("_")[1]; |
---|
[7022] | 2597 | |
---|
[6996] | 2598 | var data = { |
---|
| 2599 | type : type == "tasks" ? "task-list" : ( type == "events" ? "event-list" : "search"), |
---|
[7022] | 2600 | html : listEvents, |
---|
| 2601 | InfoPage : $(this).parents('table.header-paginator').find( '.fc-header-title' ).text() |
---|
[6996] | 2602 | } |
---|
| 2603 | window_print.document.open(); |
---|
| 2604 | window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); |
---|
| 2605 | window_print.document.close(); |
---|
| 2606 | window_print.print(); |
---|
| 2607 | }); |
---|
| 2608 | } |
---|
| 2609 | |
---|
| 2610 | function paginatorListEvent(currentView, typeView, view, type){ |
---|
[6044] | 2611 | if(!!$(currentView).find('.fc-calendar').length) |
---|
| 2612 | return; |
---|
[6190] | 2613 | $(currentView+' .events-list.events-list-win.active').prepend($('.fc-header:first').clone()); |
---|
[6044] | 2614 | //Remove contudo nao utilizado |
---|
| 2615 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-today').remove(); |
---|
| 2616 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicWeek').remove(); |
---|
[8020] | 2617 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicDay').removeClass("fc-button-basicDay").addClass('fc-button-agendaDay'); |
---|
[5341] | 2618 | |
---|
[6044] | 2619 | //Adiciona e remove as classes para esta visualizacao |
---|
| 2620 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-header-center').addClass('list-events-paginator'); |
---|
| 2621 | $(currentView+' .events-list.events-list-win.active .fc-header .list-events-paginator').removeClass('fc-header-center'); |
---|
[6996] | 2622 | |
---|
[6044] | 2623 | //Adicionar class no header padronizar com a tela principal |
---|
[6996] | 2624 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-print').addClass('print-list-events'); |
---|
| 2625 | $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); |
---|
| 2626 | $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); |
---|
| 2627 | |
---|
| 2628 | printEventList(currentView); |
---|
| 2629 | |
---|
[6044] | 2630 | if(typeView == 'search'){ |
---|
[6996] | 2631 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right span.fc-button:not(.fc-button-print)').remove(); |
---|
[6044] | 2632 | $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>Resultados para: '+$(currentView+' [name = keyword]').val()+'</h2>'); |
---|
| 2633 | if((parseInt($(currentView+' [name = page_index]').val()) == 0) && (parseInt($(currentView+' [name = results]').val()) <= 25)) |
---|
| 2634 | return; |
---|
| 2635 | paginatorSearch(currentView); |
---|
| 2636 | }else |
---|
[6996] | 2637 | paginatorList(currentView, view, type); |
---|
[5341] | 2638 | } |
---|
| 2639 | |
---|
| 2640 | function mountCriteriaList(view, page_index, calerdars_selecteds){ |
---|
[6044] | 2641 | var rangeStart , rangeEnd; |
---|
| 2642 | switch (view){ |
---|
| 2643 | case 'basicDay': |
---|
| 2644 | case 'agendaDay': |
---|
[7829] | 2645 | rangeStart = new Date.today().add({ days: page_index }).getTime(); |
---|
[6996] | 2646 | rangeEnd = rangeStart + 86400000; |
---|
[6044] | 2647 | break; |
---|
| 2648 | case 'agendaWeek': |
---|
| 2649 | var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
[7828] | 2650 | var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
| 2651 | dateEnd.setHours(0,0,0); |
---|
| 2652 | dateStart.setHours(0,0,0); |
---|
[7702] | 2653 | rangeStart = dateStart.add({ days: (7 * page_index) }).getTime(); |
---|
| 2654 | rangeEnd = dateEnd.add({ days: (7 * page_index)+7 }).getTime(); |
---|
[6044] | 2655 | break; |
---|
| 2656 | case 'month': |
---|
[7702] | 2657 | var date = Date.today().add({ months: page_index }) |
---|
[6044] | 2658 | rangeStart = date.moveToFirstDayOfMonth().getTime(); |
---|
[7828] | 2659 | rangeEnd = date.moveToLastDayOfMonth().getTime() + 86400000; |
---|
[6044] | 2660 | break; |
---|
| 2661 | case 'year': |
---|
[7702] | 2662 | var dateStart = new Date().add({ years: page_index }); |
---|
| 2663 | var dateEnd = new Date().add({ years: page_index }); |
---|
[7828] | 2664 | dateEnd.setHours(0,0,0); |
---|
| 2665 | dateStart.setHours(0,0,0); |
---|
[6044] | 2666 | if(dateStart.getMonth() != 0) |
---|
[7702] | 2667 | dateStart.moveToMonth(0, -1) |
---|
[6044] | 2668 | if(dateEnd.getMonth() != 11) |
---|
[7702] | 2669 | dateEnd.moveToMonth(11) |
---|
| 2670 | |
---|
| 2671 | rangeStart = dateStart.moveToFirstDayOfMonth().getTime(); |
---|
[7828] | 2672 | rangeEnd = dateEnd.moveToLastDayOfMonth().getTime() + 86400000; |
---|
[6044] | 2673 | break; |
---|
| 2674 | } |
---|
[5641] | 2675 | |
---|
[6044] | 2676 | var timezone = {}; |
---|
| 2677 | for(var i in Calendar.signatureOf) |
---|
[7702] | 2678 | timezone[i] = Calendar.signatureOf[i].calendar.timezone; |
---|
[5641] | 2679 | |
---|
[7702] | 2680 | return { |
---|
| 2681 | rangeStart: rangeStart, |
---|
| 2682 | rangeEnd: rangeEnd, |
---|
[6044] | 2683 | order: 'startTime', |
---|
[7702] | 2684 | timezones: timezone, |
---|
| 2685 | calendar: calerdars_selecteds |
---|
| 2686 | }; |
---|
[5341] | 2687 | } |
---|
| 2688 | |
---|
[6996] | 2689 | function pageselectCallback(keyword, page_index, view, type){ |
---|
| 2690 | $('.qtip.qtip-blue').remove(); |
---|
| 2691 | var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; |
---|
| 2692 | var tab_title = ['Lista de eventos', 'Lista de tarefas']; |
---|
| 2693 | var label_noselect_calendar = ['Por favor selecione ao menos uma agenda.', 'Por favor selecione ao menos um grupo.', 'Por favor selecione ao menos uma agenda ou grupo.']; |
---|
| 2694 | var label_nofound_search = ['Não foi encontrado nenhum evento correspondente à sua pesquisa.', 'Não foi encontrado nenhuma tarefa ou atividade correspondente à sua pesquisa.', 'Não foi encontrado nenhum evento ou tarefa ou atividade correspondente à sua pesquisa.']; |
---|
| 2695 | var label_nofound = ['Não foram encontrados eventos neste intervalo.', 'Não foram encontradas tarefas ou atividades neste intervalo.', 'Não foram encontrados eventos ou tarefas ou atividades neste intervalo.']; |
---|
| 2696 | var selecteds = getSelectedCalendars(false, type); |
---|
| 2697 | |
---|
| 2698 | if(!selecteds && (keyword != '' && keyword != null)){ |
---|
[7702] | 2699 | jQuery('#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 2700 | '<div title="'+tab_title[type]+'" class="events-list events-list-win active empty">' + |
---|
| 2701 | '<label>'+label_noselect_calendar[type]+'</label>' + |
---|
| 2702 | '</div>' |
---|
| 2703 | ); |
---|
[6044] | 2704 | }else{ |
---|
[7702] | 2705 | var criteria = null; |
---|
| 2706 | if(keyword == '' || keyword == null){ |
---|
| 2707 | |
---|
| 2708 | criteria = mountCriteriaList(!!view ? view : User.preferences.defaultCalView, page_index, selecteds); |
---|
| 2709 | |
---|
| 2710 | }else{ |
---|
| 2711 | |
---|
| 2712 | var timezone = {}; |
---|
| 2713 | for(var i in Calendar.signatureOf) |
---|
| 2714 | timezone[i] = Calendar.signatureOf[i].calendar.timezone; |
---|
| 2715 | |
---|
| 2716 | criteria = { |
---|
| 2717 | |
---|
| 2718 | searchEvent: true, |
---|
| 2719 | order: 'startTime', |
---|
| 2720 | offset: (25 * page_index), |
---|
| 2721 | limit: (((25 * page_index) + 25) + 1), |
---|
| 2722 | summary: keyword, |
---|
| 2723 | description: keyword, |
---|
| 2724 | calendar: selecteds, |
---|
| 2725 | timezones: timezone |
---|
| 2726 | |
---|
| 2727 | }; |
---|
| 2728 | } |
---|
[7828] | 2729 | |
---|
[7702] | 2730 | var results = DataLayer.encode('schedulable:list', DataLayer.dispatch('modules/calendar/schedules', criteria)); |
---|
[7828] | 2731 | //var results = DataLayer.get('schedulable:detail', criteria); |
---|
[7702] | 2732 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
[6996] | 2733 | } |
---|
[6044] | 2734 | // não há resultados |
---|
[6444] | 2735 | |
---|
[6996] | 2736 | var currentView = '#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); |
---|
[6444] | 2737 | |
---|
[6044] | 2738 | if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) { |
---|
[6444] | 2739 | $(currentView).html( |
---|
[6996] | 2740 | '<div title="'+title+'" class="events-list events-list-win active empty">' + |
---|
| 2741 | '<label>'+label_nofound_search[type]+'</label>' + |
---|
[6444] | 2742 | '</div>' |
---|
[6044] | 2743 | ); |
---|
| 2744 | // há resultados e Agendas Selecionadas |
---|
| 2745 | } else{ |
---|
| 2746 | if(typeof(results) != 'undefined'){ |
---|
[6444] | 2747 | results['page_index'] = page_index; |
---|
| 2748 | results['keyword'] = keyword; |
---|
[6996] | 2749 | results['tab_title'] = tab_title[type]; |
---|
[6444] | 2750 | DataLayer.render( 'templates/event_list.ejs', results, function( html ){ |
---|
[5341] | 2751 | |
---|
[6444] | 2752 | $(currentView).html( html ); |
---|
| 2753 | $('.events-list-win .menu-container .button').button(); |
---|
| 2754 | |
---|
[6996] | 2755 | $(".event-details-item").parent().click(function(event){ |
---|
| 2756 | event.stopImmediatePropagation(); |
---|
[7702] | 2757 | var container = $(this).siblings("div.details-event-list"); |
---|
| 2758 | |
---|
| 2759 | |
---|
| 2760 | //lazy data |
---|
| 2761 | if( container.hasClass('hidden') ){ |
---|
| 2762 | |
---|
| 2763 | //only first click |
---|
| 2764 | if(!container.find('fieldset').length){ |
---|
| 2765 | |
---|
| 2766 | $(this).append( '<span style="width: 20px;" class="load-event-detail"><img style="width: 20px;" src="'+DataLayer.dispatchPath+'/modules/calendar/img/loading.gif"></img></span>'); |
---|
| 2767 | |
---|
| 2768 | var schedulable = container.find('input[name="eventid"]').val(); |
---|
| 2769 | schedulable = DataLayer.encode('schedulable:detail', [getSchedulable( schedulable, '' )]); |
---|
| 2770 | |
---|
| 2771 | schedulable = $.isArray( schedulable ) ? schedulable[0] : schedulable; |
---|
| 2772 | |
---|
| 2773 | container.prepend( DataLayer.render( 'templates/event_detail_list.ejs', {'_event': schedulable})); |
---|
| 2774 | |
---|
| 2775 | $(this).find('span.load-event-detail').remove(); |
---|
| 2776 | } |
---|
| 2777 | } |
---|
| 2778 | |
---|
| 2779 | container.toggleClass("hidden") |
---|
[6996] | 2780 | .find('.button.delete').click(function(event){ |
---|
[6444] | 2781 | var eventId = $(this).siblings('[name="eventid"]').val(); |
---|
| 2782 | var calendarId = $(this).siblings('[name="calendarid"]').val(); |
---|
[7017] | 2783 | remove_event(eventId, calendarId, 2); |
---|
[6996] | 2784 | event.stopImmediatePropagation() |
---|
[6444] | 2785 | }) |
---|
[7010] | 2786 | .end().find('.button.edit').click(function(event){ |
---|
[7702] | 2787 | |
---|
| 2788 | var schedulable = $(this).siblings('[name="eventid"]').val(); |
---|
[7010] | 2789 | switch($(this).siblings('[name="eventtype"]').val()){ |
---|
[7702] | 2790 | |
---|
[7010] | 2791 | case '1': |
---|
[7702] | 2792 | eventDetails( getSchedulable( schedulable, '' ), true ); |
---|
[7010] | 2793 | break; |
---|
| 2794 | case '2': |
---|
[7702] | 2795 | taskDetails( getSchedulable( schedulable, '' ), true ); |
---|
[7010] | 2796 | break; |
---|
| 2797 | case '3': |
---|
[7702] | 2798 | activityDetails( getSchedulable( schedulable, '' ), true ); |
---|
[7010] | 2799 | break; |
---|
| 2800 | } |
---|
[6996] | 2801 | event.stopImmediatePropagation() |
---|
| 2802 | }) |
---|
| 2803 | .end().find('.button.print').click(function(event){ |
---|
| 2804 | var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); |
---|
| 2805 | var html = $(this).parents("td:first").clone(); |
---|
| 2806 | html.find(".menu-container.footer-container").remove(); |
---|
[7022] | 2807 | html.find(".fc-header-title").remove(); |
---|
[6996] | 2808 | var html = html.html(); |
---|
| 2809 | var data = { |
---|
| 2810 | type : $(this).parents('.details-event-list').hasClass("details-event") ? "event-detail" : "task-detail", |
---|
[7022] | 2811 | html : html, |
---|
| 2812 | InfoPage : 'Detalhes: '+$(this).parents('tr.start-date').find('td span a').text() |
---|
[6996] | 2813 | } |
---|
| 2814 | window_print.document.open(); |
---|
| 2815 | window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); |
---|
| 2816 | window_print.document.close(); |
---|
| 2817 | window_print.print(); |
---|
| 2818 | |
---|
| 2819 | event.stopImmediatePropagation() |
---|
[6444] | 2820 | }); |
---|
| 2821 | |
---|
| 2822 | }); |
---|
[6996] | 2823 | paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView, type); |
---|
[6044] | 2824 | }); |
---|
| 2825 | }else{ |
---|
[6444] | 2826 | $(currentView).html( |
---|
[6996] | 2827 | '<div title="'+title+'" class="events-list events-list-win active empty">' + |
---|
[6444] | 2828 | '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ |
---|
| 2829 | '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ |
---|
[6996] | 2830 | '<label class="empty-result">'+label_nofound[type]+'</label>' + |
---|
[6444] | 2831 | '</div>' |
---|
| 2832 | ); |
---|
[6996] | 2833 | paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView, type); |
---|
[6044] | 2834 | } |
---|
| 2835 | } |
---|
[6996] | 2836 | if(currentView != '#'+tab_selector[type]) |
---|
[6476] | 2837 | $tabs.tabs("select", currentView); |
---|
[5341] | 2838 | } |
---|
| 2839 | |
---|
[6996] | 2840 | function show_modal_import_export(tab, calendarId, typeView){ |
---|
| 2841 | $('.qtip.qtip-blue').remove(); |
---|
[6044] | 2842 | DataLayer.render( 'templates/import_export.ejs', { |
---|
[6996] | 2843 | calendars: typeView == 0 ? Calendar.calendars : Calendar.groups, |
---|
| 2844 | owner: User.me.id, |
---|
| 2845 | typeView: typeView |
---|
[6044] | 2846 | }, function( html ){ |
---|
[5341] | 2847 | |
---|
[6044] | 2848 | if (!UI.dialogs.importCalendar) { |
---|
| 2849 | UI.dialogs.importCalendar = jQuery('#div-import-export-calendar') |
---|
[6996] | 2850 | .append('<div title="Importar e Exportar "' + (typeView == 0 ? 'Eventos' : 'Tarefas') + '" class="import-export import-export-win active"> <div>') |
---|
[6044] | 2851 | .find('.import-export-win.active').html(html).dialog({ |
---|
| 2852 | resizable: false, |
---|
| 2853 | modal:true, |
---|
| 2854 | width:500, |
---|
| 2855 | position: 'center' |
---|
| 2856 | }); |
---|
[5341] | 2857 | |
---|
[6044] | 2858 | } else { |
---|
| 2859 | UI.dialogs.importCalendar.html(html); |
---|
| 2860 | } |
---|
[5341] | 2861 | |
---|
[6044] | 2862 | var tabsImportExport = UI.dialogs.importCalendar.find(".tabs-import-export").tabs({ |
---|
| 2863 | selected: tab |
---|
| 2864 | }); |
---|
[5341] | 2865 | |
---|
[6044] | 2866 | UI.dialogs.importCalendar.find('.button').button(); |
---|
[5341] | 2867 | |
---|
[6044] | 2868 | tabsImportExport.find('option[value="'+calendarId+'"]').attr('selected','selected').trigger('change'); |
---|
[5381] | 2869 | |
---|
[6044] | 2870 | var form = false; |
---|
| 2871 | $('.import-event-form').fileupload({ |
---|
| 2872 | sequentialUploads: true, |
---|
| 2873 | add: function (e, data) { |
---|
[7661] | 2874 | form = data |
---|
| 2875 | var name = form.files[0].name; |
---|
| 2876 | $('.import-event-form').find('input[type="file"]').hide(); |
---|
| 2877 | $('.import-event-form').find('span.file-add').removeClass('hidden'); |
---|
| 2878 | $('.import-event-form').find('span.file-add').append('<span>'+ name +'</span><a class="button remove-attachment tiny"></a>'); |
---|
| 2879 | $('.import-event-form').find('.button.remove-attachment').button({ |
---|
| 2880 | icons: { |
---|
| 2881 | primary: "ui-icon-close" |
---|
| 2882 | }, |
---|
| 2883 | text: false |
---|
| 2884 | }).click(function (event){ |
---|
| 2885 | $('.import-event-form').find('input[type="file"]').show(); |
---|
| 2886 | $('.import-event-form').find('span.file-add').addClass('hidden').html(''); |
---|
| 2887 | form = false; |
---|
| 2888 | }); |
---|
| 2889 | |
---|
[6044] | 2890 | }, |
---|
[7661] | 2891 | submit:function(e, data){ |
---|
| 2892 | |
---|
| 2893 | $('div.import-export').find('a.button').button('option', 'disabled', true) |
---|
| 2894 | $('.import-event-form').find('span.file-add').append('<img src="../prototype/modules/calendar/img/ajax-loader.gif">'); |
---|
| 2895 | |
---|
| 2896 | }, |
---|
[6044] | 2897 | done: function(e, data){ |
---|
[7661] | 2898 | var msg = ''; |
---|
| 2899 | var type = ''; |
---|
[5901] | 2900 | |
---|
[7661] | 2901 | if(!!data.result && data.result == '[][""]' || data.result.indexOf('Error') >= 0 ){ |
---|
| 2902 | msg = 'Erro ao realizar a importação, por favor verifique o arquivo .ics'; |
---|
| 2903 | type = 'warning'; |
---|
[7394] | 2904 | |
---|
[7661] | 2905 | $('div.import-export').find('a.button').button('option', 'disabled', false) |
---|
| 2906 | $('.import-event-form').find('span.file-add img ').remove(); |
---|
[5901] | 2907 | |
---|
[7394] | 2908 | }else{ |
---|
| 2909 | |
---|
[7661] | 2910 | if(data.result.indexOf('schedulable') >= 0){ |
---|
[7394] | 2911 | msg = 'Importação realizada com sucesso!'; |
---|
| 2912 | type = 'confirmation'; |
---|
| 2913 | Calendar.rerenderView(true); |
---|
| 2914 | }else{ |
---|
[7661] | 2915 | var res = JSON.parse(data.result); |
---|
| 2916 | var asData = false; |
---|
| 2917 | |
---|
| 2918 | for(var i = 0; i < res.length; i++) |
---|
| 2919 | if(res[i].length > 0) |
---|
| 2920 | asData = true; |
---|
| 2921 | |
---|
| 2922 | if(asData){ |
---|
| 2923 | msg = 'Importação realizada com sucesso!'; |
---|
| 2924 | type = 'confirmation'; |
---|
| 2925 | Calendar.rerenderView(true); |
---|
| 2926 | }else{ |
---|
| 2927 | msg = 'Não foram encontrados novos eventos na importação!'; |
---|
| 2928 | type = 'information'; |
---|
| 2929 | } |
---|
[7394] | 2930 | } |
---|
[7661] | 2931 | |
---|
| 2932 | UI.dialogs.importCalendar.dialog("close"); |
---|
[7394] | 2933 | } |
---|
| 2934 | |
---|
[7661] | 2935 | $.Zebra_Dialog(msg, { |
---|
| 2936 | 'type': type, |
---|
| 2937 | 'overlay_opacity': '0.5', |
---|
| 2938 | 'buttons': ['Fechar'] |
---|
| 2939 | }); |
---|
[6044] | 2940 | } |
---|
| 2941 | }); |
---|
[5901] | 2942 | |
---|
[6044] | 2943 | UI.dialogs.importCalendar.find(".menu-import-event") |
---|
[7661] | 2944 | .children(".import").click(function(data){ |
---|
| 2945 | $('.import-event-form fieldset.import-calendar', UI.dialogs.importCalendar).append( |
---|
| 2946 | '<input type="hidden" name="params[calendar_timezone]" value="'+ |
---|
| 2947 | Calendar.signatureOf[$('.import-event-form option:selected').val()].calendar.timezone |
---|
| 2948 | +'"/>') |
---|
| 2949 | if(form) |
---|
| 2950 | form.submit(); |
---|
[6044] | 2951 | }); |
---|
[5341] | 2952 | |
---|
[6044] | 2953 | UI.dialogs.importCalendar.find(".menu-export-event") |
---|
| 2954 | .children(".export").click(function(){ |
---|
[5341] | 2955 | |
---|
[6044] | 2956 | $('.export-event-form', UI.dialogs.importCalendar).submit(); |
---|
| 2957 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 2958 | /** |
---|
[5341] | 2959 | * TODO - implementar ação de exportação |
---|
| 2960 | */ |
---|
[6044] | 2961 | }); |
---|
[5341] | 2962 | |
---|
[6044] | 2963 | UI.dialogs.importCalendar.find(".menu-container") |
---|
| 2964 | .children(".cancel").click(function(){ |
---|
| 2965 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 2966 | }); |
---|
[5341] | 2967 | |
---|
[6044] | 2968 | UI.dialogs.importCalendar.dialog("open"); |
---|
[5341] | 2969 | }); |
---|
[5592] | 2970 | } |
---|
| 2971 | |
---|
[7991] | 2972 | function copyAndMoveTo(calendar, event, idRecurrence, type, evt ){ |
---|
[5746] | 2973 | /* |
---|
| 2974 | * Types |
---|
| 2975 | * 0 = Move |
---|
| 2976 | * 1 = Copy Event end Repet |
---|
| 2977 | * 2 = Copy Ocurrence |
---|
| 2978 | * 3 = Copy to edit ocurrence |
---|
| 2979 | * |
---|
| 2980 | **/ |
---|
| 2981 | if(!type) |
---|
[6044] | 2982 | type = $('.calendar-copy-move input[name="typeEvent"]').val(); |
---|
[5592] | 2983 | |
---|
[7702] | 2984 | getSchedulable(event,''); |
---|
| 2985 | var schedulable = DataLayer.get('schedulable', event.toString()); |
---|
[7106] | 2986 | schedulable['class'] = '1'; |
---|
[6331] | 2987 | |
---|
[6044] | 2988 | calendar = !!calendar ? calendar : schedulable.calendar; |
---|
[7357] | 2989 | |
---|
| 2990 | owner = decodeOwnerCalendar(calendar); |
---|
[5746] | 2991 | |
---|
[6044] | 2992 | if(typeof(schedulable) == "array") |
---|
| 2993 | schedulable = schedulable[0]; |
---|
[5592] | 2994 | |
---|
[6044] | 2995 | //Move eventos entre agendas |
---|
| 2996 | if(parseInt(type) == 0){ |
---|
[5592] | 2997 | |
---|
[6331] | 2998 | schedulable.lastCalendar = schedulable.calendar; |
---|
[7702] | 2999 | schedulable.calendar = calendar; |
---|
[6044] | 3000 | DataLayer.put('schedulable', schedulable); |
---|
[5592] | 3001 | |
---|
[6044] | 3002 | DataLayer.commit(); |
---|
| 3003 | //copia eventos entre agendas |
---|
| 3004 | }else{ |
---|
[5592] | 3005 | |
---|
[6044] | 3006 | var newSchedulable = schedulable; |
---|
[5592] | 3007 | |
---|
[6044] | 3008 | delete newSchedulable.id; |
---|
| 3009 | delete newSchedulable.uid; |
---|
| 3010 | delete newSchedulable.sequence; |
---|
| 3011 | delete newSchedulable.dtstamp; |
---|
[5746] | 3012 | |
---|
[6044] | 3013 | delete schedulable.DayLigth; |
---|
| 3014 | delete schedulable.rangeStart |
---|
| 3015 | delete schedulable.rangeEnd; |
---|
| 3016 | delete schedulable.lastUpdate; |
---|
[5746] | 3017 | |
---|
[6044] | 3018 | delete schedulable.calendar; |
---|
[5746] | 3019 | |
---|
[6044] | 3020 | if(schedulable.repeat && type == "1" ){ |
---|
| 3021 | var repeat = DataLayer.get('repeat', schedulable.repeat); |
---|
| 3022 | delete repeat.schedulable; |
---|
| 3023 | delete repeat.id; |
---|
[7702] | 3024 | repeat.startTime = repeat.startTime == '' ? '' : new Date(parseInt(repeat.startTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
| 3025 | repeat.endTime = repeat.endTime == '' ? '' : new Date(parseInt(repeat.endTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5746] | 3026 | |
---|
[6044] | 3027 | var exceptions = DataLayer.get('repeatOccurrence', { |
---|
| 3028 | filter: ['AND', ['=','repeat', schedulable.repeat], ['=','exception','1']] |
---|
| 3029 | }, true); |
---|
| 3030 | if(exceptions){ |
---|
| 3031 | repeat.exceptions = ''; |
---|
| 3032 | for(var i in exceptions ) |
---|
| 3033 | repeat.exceptions += exceptions[i].occurrence + ((exceptions.length -1) == parseInt(i) ? '' : ','); |
---|
[5746] | 3034 | |
---|
[6044] | 3035 | } |
---|
[5746] | 3036 | |
---|
| 3037 | |
---|
[6044] | 3038 | schedulable.repeat = repeat; |
---|
| 3039 | }else{ |
---|
| 3040 | if(!!idRecurrence){ |
---|
| 3041 | newSchedulable.endTime = parseInt(schedulable.occurrences[idRecurrence]) + (parseInt(newSchedulable.endTime) - parseInt(newSchedulable.startTime)); |
---|
| 3042 | newSchedulable.startTime = schedulable.occurrences[idRecurrence]; |
---|
| 3043 | } |
---|
| 3044 | delete schedulable.repeat; |
---|
| 3045 | } |
---|
| 3046 | delete schedulable.occurrences; |
---|
[5746] | 3047 | |
---|
[7702] | 3048 | schedulable.calendar = DataLayer.copy(calendar); |
---|
[5592] | 3049 | |
---|
[6044] | 3050 | var participants = DataLayer.copy(schedulable.participants); |
---|
| 3051 | delete schedulable.participants; |
---|
[7357] | 3052 | |
---|
| 3053 | if(schedulable['type'] == '2') |
---|
| 3054 | delete schedulable['historic']; |
---|
| 3055 | |
---|
[7991] | 3056 | schedulable.participants = $.map( participants, function( attendee, i ){ |
---|
[7357] | 3057 | |
---|
[7991] | 3058 | var participant = DataLayer.get('participant', attendee, false); |
---|
| 3059 | |
---|
| 3060 | if(typeof(participant) == 'array') |
---|
| 3061 | participant = participant[0]; |
---|
| 3062 | |
---|
| 3063 | if(owner.id != participant.user) |
---|
| 3064 | delete participant.status; |
---|
| 3065 | |
---|
| 3066 | delete participant.delegatedFrom; |
---|
| 3067 | delete participant.id; |
---|
| 3068 | delete participant.schedulable; |
---|
| 3069 | |
---|
| 3070 | participant.id = DataLayer.put('participant', participant); |
---|
| 3071 | |
---|
[7993] | 3072 | return (parseInt(type) == 3) ? participant.id : participant ; |
---|
[7991] | 3073 | }); |
---|
| 3074 | |
---|
[6044] | 3075 | //Edit ocurrence |
---|
| 3076 | if(parseInt(type) == 3){ |
---|
| 3077 | newSchedulable.endTime = !!evt.end ? evt.end.getTime() : ((evt.start).getTime() + 86400000); |
---|
| 3078 | newSchedulable.startTime = evt.start.getTime(); |
---|
[5746] | 3079 | |
---|
[6044] | 3080 | return newSchedulable; |
---|
| 3081 | } |
---|
[7702] | 3082 | newSchedulable.endTime = new Date(parseInt(newSchedulable.endTime) - (parseInt(newSchedulable.allDay) ? 86400000 : 0)).toString('yyyy-MM-dd HH:mm:00'); |
---|
| 3083 | newSchedulable.startTime = new Date(parseInt(newSchedulable.startTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5592] | 3084 | |
---|
[6044] | 3085 | DataLayer.put('schedulable', newSchedulable); |
---|
[5636] | 3086 | |
---|
[6044] | 3087 | } |
---|
[6476] | 3088 | } |
---|
[5592] | 3089 | |
---|
[6476] | 3090 | function messageHelper(msg, isShow){ |
---|
| 3091 | if(isShow) |
---|
| 3092 | new $.Zebra_Dialog('<span style="width: 50px; height: 50px;">'+ |
---|
| 3093 | '<img src="'+DataLayer.dispatchPath+'/modules/calendar/img/loading.gif"></img>'+ |
---|
| 3094 | '</span><label class="messagesHelpers"> '+ msg +' </label>' , { |
---|
| 3095 | 'buttons': false, |
---|
| 3096 | 'modal': true, |
---|
| 3097 | 'overlay_opacity': '0.5', |
---|
| 3098 | 'keyboard': false, |
---|
| 3099 | 'overlay_close': false, |
---|
| 3100 | 'type': false, |
---|
| 3101 | 'custom_class': 'messagesHelpersExpressoCalendar' |
---|
| 3102 | } |
---|
| 3103 | ); |
---|
| 3104 | else{ |
---|
| 3105 | $('.messagesHelpersExpressoCalendar').remove(); |
---|
| 3106 | $('.ZebraDialogOverlay').remove(); |
---|
| 3107 | } |
---|
[6498] | 3108 | } |
---|
[6996] | 3109 | |
---|
| 3110 | function extendsFileupload(view, path){ |
---|
| 3111 | var viewName = 'div.new-'+view+'-win'; |
---|
| 3112 | |
---|
| 3113 | path = !!path ? path : ''; |
---|
| 3114 | |
---|
| 3115 | var maxSizeFile = 2000000; |
---|
| 3116 | $('#fileupload'+view).fileupload({ |
---|
| 3117 | sequentialUploads: true, |
---|
| 3118 | add: function (e, data) { |
---|
| 3119 | if(data.files[0].size < maxSizeFile) |
---|
| 3120 | data.submit(); |
---|
| 3121 | }, |
---|
| 3122 | change: function (e, data) { |
---|
| 3123 | $.each(data.files, function (index, file) { |
---|
| 3124 | var attach = {}; |
---|
| 3125 | attach.fileName = file.name; |
---|
| 3126 | var ext = file.name.split('.'); |
---|
| 3127 | if(file.name.length > 10) |
---|
| 3128 | attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; |
---|
| 3129 | attach.fileSize = formatBytes(file.size); |
---|
| 3130 | if(file.size > maxSizeFile) |
---|
| 3131 | attach.error = 'Tamanho de arquivo nao permitido!!' |
---|
| 3132 | |
---|
| 3133 | $(viewName+' .attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { |
---|
| 3134 | file : attach |
---|
| 3135 | })); |
---|
| 3136 | |
---|
| 3137 | if(file.size < maxSizeFile){ |
---|
| 3138 | $(viewName+' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); |
---|
| 3139 | $(viewName+' .attachments-list').find('[type=file]').addClass('hidden'); |
---|
| 3140 | |
---|
| 3141 | }else |
---|
| 3142 | $(viewName+' .fileinput-button.new').removeClass('new'); |
---|
| 3143 | |
---|
| 3144 | |
---|
| 3145 | $(viewName+' .attachments-list').find('.button.close').button({ |
---|
| 3146 | icons: { |
---|
| 3147 | primary: "ui-icon-close" |
---|
| 3148 | }, |
---|
| 3149 | text: false |
---|
| 3150 | }).click(function(){ |
---|
| 3151 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
| 3152 | $(viewName+' .attachment-list').find('input[value="'+idAttach+'"]').remove(); |
---|
| 3153 | $(this).parent().remove(); |
---|
| 3154 | |
---|
| 3155 | if(!$(viewName+' .attachment-list input').length) |
---|
| 3156 | $(viewName+' .btn-danger.delete').addClass('hidden'); |
---|
| 3157 | |
---|
| 3158 | }); |
---|
| 3159 | |
---|
| 3160 | }) |
---|
| 3161 | }, |
---|
| 3162 | done: function(e, data){ |
---|
| 3163 | var currentUpload = $(viewName+' .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); |
---|
| 3164 | |
---|
| 3165 | if(!!data.result && data.result != "[]"){ |
---|
| 3166 | $(viewName+' .btn-danger.delete').removeClass('hidden'); |
---|
| 3167 | var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); |
---|
| 3168 | $(viewName+' .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); |
---|
| 3169 | currentUpload.removeClass('on-complete').parents('p') |
---|
| 3170 | .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') |
---|
| 3171 | .find('.status-upload').addClass('ui-icon ui-icon-check'); |
---|
| 3172 | }else |
---|
| 3173 | currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); |
---|
| 3174 | } |
---|
| 3175 | }); |
---|
| 3176 | $('.attachments-list .button').button(); |
---|
| 3177 | |
---|
| 3178 | if(!!window.FormData) |
---|
| 3179 | $('#fileupload'+view).bind('fileuploadstart', function () { |
---|
| 3180 | var widget = $(this), |
---|
| 3181 | progressElement = $('#fileupload-progress-'+view).fadeIn(), |
---|
| 3182 | interval = 500, |
---|
| 3183 | total = 0, |
---|
| 3184 | loaded = 0, |
---|
| 3185 | loadedBefore = 0, |
---|
| 3186 | progressTimer, |
---|
| 3187 | progressHandler = function (e, data) { |
---|
| 3188 | loaded = data.loaded; |
---|
| 3189 | total = data.total; |
---|
| 3190 | }, |
---|
| 3191 | stopHandler = function () { |
---|
| 3192 | widget |
---|
| 3193 | .unbind('fileuploadprogressall', progressHandler) |
---|
| 3194 | .unbind('fileuploadstop', stopHandler); |
---|
| 3195 | window.clearInterval(progressTimer); |
---|
| 3196 | progressElement.fadeOut(function () { |
---|
| 3197 | progressElement.html(''); |
---|
| 3198 | }); |
---|
| 3199 | }, |
---|
| 3200 | formatTime = function (seconds) { |
---|
| 3201 | var date = new Date(seconds * 1000); |
---|
| 3202 | return ('0' + date.getUTCHours()).slice(-2) + ':' + |
---|
| 3203 | ('0' + date.getUTCMinutes()).slice(-2) + ':' + |
---|
| 3204 | ('0' + date.getUTCSeconds()).slice(-2); |
---|
| 3205 | }, |
---|
| 3206 | /* formatBytes = function (bytes) { |
---|
| 3207 | if (bytes >= 1000000000) { |
---|
| 3208 | return (bytes / 1000000000).toFixed(2) + ' GB'; |
---|
| 3209 | } |
---|
| 3210 | if (bytes >= 1000000) { |
---|
| 3211 | return (bytes / 1000000).toFixed(2) + ' MB'; |
---|
| 3212 | } |
---|
| 3213 | if (bytes >= 1000) { |
---|
| 3214 | return (bytes / 1000).toFixed(2) + ' KB'; |
---|
| 3215 | } |
---|
| 3216 | return bytes + ' B'; |
---|
| 3217 | },*/ |
---|
| 3218 | formatPercentage = function (floatValue) { |
---|
| 3219 | return (floatValue * 100).toFixed(2) + ' %'; |
---|
| 3220 | }, |
---|
| 3221 | updateProgressElement = function (loaded, total, bps) { |
---|
| 3222 | progressElement.html( |
---|
| 3223 | formatBytes(bps) + 'ps | ' + |
---|
| 3224 | formatTime((total - loaded) / bps) + ' | ' + |
---|
| 3225 | formatPercentage(loaded / total) + ' | ' + |
---|
| 3226 | formatBytes(loaded) + ' / ' + formatBytes(total) |
---|
| 3227 | ); |
---|
| 3228 | }, |
---|
| 3229 | intervalHandler = function () { |
---|
| 3230 | var diff = loaded - loadedBefore; |
---|
| 3231 | if (!diff) { |
---|
| 3232 | return; |
---|
| 3233 | } |
---|
| 3234 | loadedBefore = loaded; |
---|
| 3235 | updateProgressElement( |
---|
| 3236 | loaded, |
---|
| 3237 | total, |
---|
| 3238 | diff * (1000 / interval) |
---|
| 3239 | ); |
---|
| 3240 | }; |
---|
| 3241 | widget |
---|
| 3242 | .bind('fileuploadprogressall', progressHandler) |
---|
| 3243 | .bind('fileuploadstop', stopHandler); |
---|
| 3244 | progressTimer = window.setInterval(intervalHandler, interval); |
---|
| 3245 | }); |
---|
| 3246 | |
---|
[7828] | 3247 | } |
---|