[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 | |
---|
| 114 | var data = DataLayer.get("schedulable:print", criteria); |
---|
| 115 | |
---|
| 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', {} ); |
---|
[8021] | 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'); |
---|
[8021] | 163 | print.removeClass('fc-button-year'); |
---|
[6996] | 164 | print.removeClass('fc-corner-left'); |
---|
[8021] | 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 | |
---|
| 182 | $('.qtip.qtip-blue').remove(); |
---|
| 183 | |
---|
[6044] | 184 | attendees = {}; |
---|
[7985] | 185 | |
---|
| 186 | if(!!objEvent.participants) |
---|
| 187 | { |
---|
| 188 | $.each(objEvent.participants ,function(index, value) { |
---|
[7992] | 189 | |
---|
[7985] | 190 | var part = DataLayer.get('participant' , value ); |
---|
| 191 | var user = DataLayer.get('user' , part.user ); |
---|
| 192 | |
---|
| 193 | attendees[part.user] = user.name; |
---|
| 194 | }); |
---|
| 195 | } |
---|
| 196 | |
---|
[6044] | 197 | if(path == undefined) |
---|
| 198 | path = ""; |
---|
[8035] | 199 | |
---|
| 200 | |
---|
[6044] | 201 | if( !decoded ) |
---|
[8035] | 202 | objEvent = DataLayer.decode("schedulable:calendar", objEvent ); |
---|
| 203 | |
---|
| 204 | var dtstamp = objEvent.dtstamp; |
---|
[6044] | 205 | if(!isMail) |
---|
[8035] | 206 | objEvent = DataLayer.encode( "schedulable:preview", objEvent ); |
---|
| 207 | objEvent.creationDate = dateFormat(parseInt(dtstamp),"dd/mm/yyyy"); |
---|
| 208 | |
---|
[6044] | 209 | if(typeof(objEvent.id) == 'undefined'){ |
---|
| 210 | objEvent.alarms = Calendar.signatureOf[User.preferences.defaultCalendar || Calendar.calendarIds[0]].defaultAlarms || false; |
---|
| 211 | objEvent.useAlarmDefault = 1; |
---|
| 212 | } |
---|
[5341] | 213 | |
---|
[6044] | 214 | /** |
---|
[5341] | 215 | * canDiscardEventDialog deve ser true se não houver alterações no evento |
---|
| 216 | */ |
---|
[6044] | 217 | canDiscardEventDialog = true; |
---|
| 218 | /** |
---|
[5341] | 219 | * zebraDiscardEventDialog é uma flag indicando que uma janela de confirmação (Zebra_Dialog) |
---|
| 220 | * já está aberta na tela, uma vez que não é possivel acessar o evento ESC utilizado para fechá-la |
---|
| 221 | */ |
---|
[6044] | 222 | zebraDiscardEventDialog = false; |
---|
[5341] | 223 | |
---|
[6044] | 224 | /** |
---|
[5514] | 225 | ACLs do participant |
---|
| 226 | */ |
---|
[6044] | 227 | acl_names = { |
---|
| 228 | 'w': 'acl-white', |
---|
| 229 | 'i': 'acl-invite-guests', |
---|
| 230 | 'p': 'acl-participation-required' |
---|
| 231 | }; |
---|
[6103] | 232 | |
---|
| 233 | var dependsDelegate = function(reference, inverse){ |
---|
| 234 | if(inverse){ |
---|
| 235 | if(reference.find('input[name="attendee[]"]').val() == blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val()) |
---|
| 236 | blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val()); |
---|
| 237 | }else{ |
---|
| 238 | if(blkAddAtendee.find('.me input[name="attendee[]"]').val() == blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val()) |
---|
| 239 | blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val(reference.find('input[name="attendee[]"]').val()); |
---|
| 240 | } |
---|
[5636] | 241 | |
---|
[6103] | 242 | }; |
---|
| 243 | |
---|
| 244 | var removeOthers = function(){ |
---|
| 245 | var other = blkAddAtendee.find('.delegate.attendee-permissions-change-button'); |
---|
| 246 | if(other.lenght){ |
---|
| 247 | dependsDelegate(other.parents('li'), true); |
---|
| 248 | } |
---|
| 249 | blkAddAtendee.find('.delegate').removeClass('attendee-permissions-change-button'); |
---|
| 250 | blkAddAtendee.find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change'); |
---|
| 251 | |
---|
| 252 | }; |
---|
| 253 | |
---|
[6044] | 254 | var callbackAttendee = function(){ |
---|
| 255 | //Cria qtip de permissões pelo click do checkbox |
---|
| 256 | var checked = false; |
---|
| 257 | blkAddAtendee.find("li.not-attendee").addClass('hidden'); |
---|
[5514] | 258 | |
---|
[6044] | 259 | blkAddAtendee.find("li .button").filter(".close.new").button({ |
---|
| 260 | icons: { |
---|
| 261 | primary: "ui-icon-close" |
---|
| 262 | }, |
---|
| 263 | text: false |
---|
| 264 | }).click(function () { |
---|
[7985] | 265 | var participant = DataLayer.get('participant' , $(this).parents('li').find('[type=checkbox]').val()); |
---|
| 266 | DataLayer.remove('participant', participant.id); |
---|
[6044] | 267 | if($(this).parent().find('.button.delegate').hasClass('attendee-permissions-change-button')){ |
---|
[6103] | 268 | removeOthers(); |
---|
[6044] | 269 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 270 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
[5530] | 271 | |
---|
[6044] | 272 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 273 | } |
---|
| 274 | $(this).parents('li').remove(); |
---|
[5530] | 275 | |
---|
[6044] | 276 | if(blkAddAtendee.find(".attendee-list li").length == 1) |
---|
| 277 | blkAddAtendee.find("li.not-attendee").removeClass('hidden'); |
---|
[7985] | 278 | delete attendees[participant.user]; |
---|
[6044] | 279 | }) |
---|
| 280 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 281 | .removeClass('new').end() |
---|
[5514] | 282 | |
---|
[6044] | 283 | .filter(".delegate.new").button({ |
---|
| 284 | icons: { |
---|
| 285 | primary: "ui-icon-transferthick-e-w" |
---|
| 286 | }, |
---|
| 287 | text: false |
---|
| 288 | }).click(function () { |
---|
[6103] | 289 | var me = $(this).parents('li'); |
---|
[6044] | 290 | if($(this).hasClass('attendee-permissions-change-button')){ |
---|
| 291 | $(this).removeClass('attendee-permissions-change-button') |
---|
[6103] | 292 | .find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change').end(); |
---|
| 293 | |
---|
| 294 | me.find('input[name="delegatedFrom[]"]').val(''); |
---|
| 295 | dependsDelegate(me, true); |
---|
[5514] | 296 | |
---|
[6044] | 297 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 298 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
[6103] | 299 | |
---|
[6044] | 300 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
[5514] | 301 | |
---|
[6044] | 302 | }else{ |
---|
[6103] | 303 | removeOthers(); |
---|
[5514] | 304 | |
---|
[6044] | 305 | $(this).addClass('attendee-permissions-change-button') |
---|
| 306 | .find('.ui-icon-transferthick-e-w').addClass('attendee-permissions-change').end(); |
---|
[6103] | 307 | |
---|
| 308 | me.find('input[name="delegatedFrom[]"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val()); |
---|
| 309 | |
---|
| 310 | dependsDelegate(me, false); |
---|
[5514] | 311 | |
---|
[6044] | 312 | blkAddAtendee.find('.request-update').removeClass('hidden'); |
---|
| 313 | if(blkAddAtendee.find('.status option.hidden').length == 1) |
---|
| 314 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
[5514] | 315 | |
---|
[6044] | 316 | blkAddAtendee.find('option[value=5]').attr('selected','selected').trigger('change'); |
---|
| 317 | } |
---|
| 318 | }) |
---|
| 319 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 320 | .removeClass('new').end() |
---|
[5514] | 321 | |
---|
[6044] | 322 | .filter(".edit.new").button({ |
---|
| 323 | icons: { |
---|
| 324 | primary: "ui-icon-key" |
---|
| 325 | }, |
---|
| 326 | text: false |
---|
| 327 | }).click(function() { |
---|
[5514] | 328 | |
---|
[6044] | 329 | if(!!!checked) |
---|
| 330 | $(this).parents('li').find('[type=checkbox]').attr('checked', (!$(this).parent().find('[type=checkbox]').is(':checked'))).end(); |
---|
[5514] | 331 | |
---|
[6044] | 332 | var aclsParticipant = $(this).parents('li').find('input[name="attendeeAcl[]"]').val(); |
---|
| 333 | checked = false; |
---|
[5514] | 334 | |
---|
[6044] | 335 | if( $('.qtip.qtip-blue.qtip-active').val() !== ''){ |
---|
| 336 | blkAddAtendee.find('dd.attendee-list').qtip({ |
---|
| 337 | show: { |
---|
| 338 | ready: true, |
---|
| 339 | solo: true, |
---|
| 340 | when: { |
---|
| 341 | event: 'click' |
---|
| 342 | } |
---|
| 343 | }, |
---|
| 344 | hide: false, |
---|
| 345 | content: { |
---|
[6718] | 346 | text: $('<div></div>').html( DataLayer.render( path + 'templates/attendee_permissions.ejs', {} ) ), |
---|
[6044] | 347 | title: { |
---|
| 348 | text:'Permissões', |
---|
| 349 | button: '<a class="button close" href="#">close</a>' |
---|
| 350 | } |
---|
| 351 | }, |
---|
| 352 | style: { |
---|
| 353 | name: 'blue', |
---|
| 354 | tip: { |
---|
| 355 | corner: 'leftMiddle' |
---|
| 356 | }, |
---|
| 357 | border: { |
---|
| 358 | width: 4, |
---|
| 359 | radius: 8 |
---|
| 360 | }, |
---|
| 361 | width: { |
---|
| 362 | min: 230, |
---|
| 363 | max:230 |
---|
| 364 | } |
---|
| 365 | }, |
---|
| 366 | position: { |
---|
| 367 | corner: { |
---|
| 368 | target: 'rightMiddle', |
---|
| 369 | tooltip: 'leftMiddle' |
---|
| 370 | }, |
---|
| 371 | adjust: { |
---|
| 372 | x:0, |
---|
| 373 | y:0 |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | }) |
---|
| 377 | .qtip("api").onShow = function(arg0) { |
---|
| 378 | $('.qtip-active .button.close').button({ |
---|
| 379 | icons: { |
---|
| 380 | primary: "ui-icon-close" |
---|
| 381 | }, |
---|
| 382 | text: false |
---|
| 383 | }) |
---|
| 384 | .click(function(){ |
---|
| 385 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 386 | }); |
---|
[5514] | 387 | |
---|
[6044] | 388 | $('.qtip-active .button.save').button().click(function(){ |
---|
[5514] | 389 | |
---|
[6044] | 390 | var acl = ''; |
---|
| 391 | $('.qtip-active').find('[type=checkbox]:checked').each(function(i, obj) { |
---|
| 392 | acl+= obj.value; |
---|
| 393 | }); |
---|
[5514] | 394 | |
---|
[6044] | 395 | blkAddAtendee.find('dd.attendee-list [type=checkbox]:checked').siblings('input[name="attendeeAcl[]"]').each(function(i, obj) { |
---|
| 396 | obj.value = 'r'+acl; |
---|
| 397 | }).parents('li').find('.button.edit').addClass('attendee-permissions-change-button') |
---|
| 398 | .find('.ui-icon-key').addClass('attendee-permissions-change'); |
---|
[5514] | 399 | |
---|
[6044] | 400 | blkAddAtendee.find('dd.attendee-list [type=checkbox]').attr('checked', false); |
---|
[5514] | 401 | |
---|
[6044] | 402 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
[5514] | 403 | |
---|
[6044] | 404 | }); |
---|
| 405 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 406 | blkAddAtendee.find('dd.attendee-list [type=checkbox]').attr('checked', false); |
---|
| 407 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 408 | }); |
---|
[5514] | 409 | |
---|
[6044] | 410 | if(aclsParticipant) |
---|
| 411 | for(var i = 1; i < aclsParticipant.length; i++){ |
---|
| 412 | $('.qtip-active').find('input[name="'+acl_names[aclsParticipant.charAt(i)]+'"]').attr('checked', true); |
---|
| 413 | } |
---|
[6718] | 414 | |
---|
| 415 | $('.qtip .button').button(); |
---|
[5514] | 416 | |
---|
[6044] | 417 | }; |
---|
| 418 | }else{ |
---|
| 419 | if(!$('.new-event-win dd.attendee-list').find('[type=checkbox]:checked').length){ |
---|
| 420 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 421 | }else{ |
---|
| 422 | $('.qtip-active .button.save .ui-button-text').html('Aplicar a todos') |
---|
| 423 | } |
---|
[5514] | 424 | |
---|
[6044] | 425 | }; |
---|
| 426 | }) |
---|
| 427 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 428 | .removeClass('new').end() |
---|
[5514] | 429 | |
---|
[6044] | 430 | .filter(".open-delegate.new").click(function(){ |
---|
| 431 | if($(this).hasClass('ui-icon-triangle-1-e')){ |
---|
| 432 | $(this).removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); |
---|
| 433 | $(this).parents('li').find('.list-delegates').removeClass('hidden'); |
---|
| 434 | }else{ |
---|
| 435 | $(this).removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); |
---|
| 436 | $(this).parents('li').find('.list-delegates').addClass('hidden'); |
---|
| 437 | } |
---|
[5514] | 438 | |
---|
[6044] | 439 | }).removeClass('new'); |
---|
[5514] | 440 | |
---|
| 441 | |
---|
[6044] | 442 | blkAddAtendee.find("li input[type=checkbox].new").click(function(){ |
---|
| 443 | if(!$('.new-event-win dd.attendee-list').find('[type=checkbox]:checked').length){ |
---|
| 444 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 445 | }else{ |
---|
| 446 | checked = true; |
---|
| 447 | $(this).parents('li').find('.button.edit').click(); |
---|
| 448 | } |
---|
| 449 | }).removeClass('new'); |
---|
[5514] | 450 | |
---|
[6044] | 451 | UI.dialogs.addEvent.find('.attendees-list li').hover( |
---|
| 452 | function () { |
---|
| 453 | $(this).addClass("hover-attendee"); |
---|
| 454 | $(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 455 | .find('.attendee-options').addClass('hover-attendee'); |
---|
| 456 | }, |
---|
| 457 | function () { |
---|
| 458 | $(this).removeClass("hover-attendee"); |
---|
| 459 | $(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 460 | .find('.attendee-options').removeClass('hover-attendee');; |
---|
| 461 | } |
---|
| 462 | ); |
---|
| 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, |
---|
[7864] | 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 | |
---|
[8034] | 562 | |
---|
| 563 | dateSameValue = function(){ |
---|
| 564 | UI.dialogs.addEvent.find('input.start-date').datepicker({ |
---|
| 565 | dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy'), |
---|
| 566 | onSelect : function (selectedDate){ |
---|
| 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); |
---|
| 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); |
---|
[8034] | 601 | |
---|
| 602 | dateSameValue(); |
---|
[6444] | 603 | $(".date").datepicker({ |
---|
| 604 | dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy') |
---|
[8034] | 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 | |
---|
[8034] | 1003 | dateSameValue(); |
---|
| 1004 | |
---|
| 1005 | |
---|
| 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(); |
---|
| 1012 | |
---|
| 1013 | if( Date.parse(selectedDateTime) < Date.parse(oldTime) ) return true; |
---|
| 1014 | |
---|
| 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; |
---|
| 1046 | } |
---|
| 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 | } |
---|
| 1066 | |
---|
| 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); |
---|
| 1070 | |
---|
| 1071 | } |
---|
| 1072 | |
---|
| 1073 | $(".start-date").focusout(function(data){ |
---|
| 1074 | $(".end-date").val($(this).val()); |
---|
[6044] | 1075 | }); |
---|
[8034] | 1076 | |
---|
| 1077 | if($("#calendar").fullCalendar('getView').name == "month"){ |
---|
| 1078 | |
---|
| 1079 | var oldTime = UI.dialogs.addEvent.find('input.start-time').val(); |
---|
| 1080 | $(".start-time").focusout(function(data){ |
---|
| 1081 | setTime( $(this).val() ); |
---|
| 1082 | }); |
---|
| 1083 | |
---|
| 1084 | UI.dialogs.addEvent.find('input.start-time').timepicker({ |
---|
| 1085 | ampm : ((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 1086 | timeFormat: "hh:mm tt", |
---|
| 1087 | onSelect: function( selectedDateTime ){ |
---|
| 1088 | setTime( selectedDateTime ); |
---|
| 1089 | } |
---|
| 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 |
---|
[7985] | 1156 | }); |
---|
[5341] | 1157 | |
---|
[6044] | 1158 | // load template of attendees |
---|
| 1159 | var blkAddAtendee = UI.dialogs.addEvent.find('#calendar_addevent_details6').append(attendeeHtml); |
---|
[7985] | 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, |
---|
[7982] | 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 | |
---|
[7982] | 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 | |
---|
| 1704 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 1705 | |
---|
[6044] | 1706 | tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1707 | }); |
---|
[5341] | 1708 | |
---|
[6044] | 1709 | tabPrefCalendar.find('.button').button() |
---|
| 1710 | .filter('.save').click(function(evt){ |
---|
| 1711 | tabPrefCalendar.find('form').submit(); |
---|
| 1712 | $('#calendar').fullCalendar('render'); |
---|
| 1713 | $('.block-vertical-toolbox .mini-calendar').datepicker( "refresh" ); |
---|
| 1714 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 1715 | }).end().filter('.cancel').click(function(evt){ |
---|
| 1716 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 1717 | }); |
---|
[5341] | 1718 | |
---|
[6044] | 1719 | tabPrefCalendar.find('.number').numeric(); |
---|
[5510] | 1720 | |
---|
[6044] | 1721 | tabPrefCalendar.find('input.time').timepicker({ |
---|
| 1722 | closeText: 'Ok', |
---|
| 1723 | hourGrid: 4, |
---|
| 1724 | minuteGrid: 10, |
---|
| 1725 | ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false), //((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 1726 | timeFormat: "hh:mm tt", |
---|
| 1727 | onSelect: function (selectedDateTime){ |
---|
| 1728 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1729 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1730 | } |
---|
| 1731 | }, |
---|
| 1732 | onClose : function (selectedDateTime){ |
---|
| 1733 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1734 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1735 | } |
---|
| 1736 | } |
---|
| 1737 | }); |
---|
[5510] | 1738 | |
---|
[6044] | 1739 | $.mask.definitions['{']='[ap]'; |
---|
| 1740 | $.mask.definitions['}']='[m]'; |
---|
| 1741 | tabPrefCalendar.find("input.time").mask( ((User.preferences.hourFormat.length > 5) ? "99:99 {}" : "99:99"), { |
---|
| 1742 | completed:function(){ |
---|
| 1743 | $(this).val(dateCalendar.defaultToAmPm($(this).val())); |
---|
| 1744 | $(this).timepicker("refresh"); |
---|
| 1745 | $(this).val($(this).val().replace(/[\.]/gi, "")); |
---|
| 1746 | } |
---|
| 1747 | }); |
---|
[5510] | 1748 | |
---|
[6044] | 1749 | tabPrefCalendar.find("select[name=hourFormat]").change( function() { // evento ao selecionar formato de hora |
---|
[5510] | 1750 | |
---|
[6044] | 1751 | tabPrefCalendar.find("input.time").timepicker("destroy"); |
---|
[5510] | 1752 | |
---|
[6044] | 1753 | tabPrefCalendar.find('input.time').timepicker({ |
---|
| 1754 | closeText: 'Ok', |
---|
| 1755 | hourGrid: 4, |
---|
| 1756 | minuteGrid: 10, |
---|
| 1757 | ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false), |
---|
| 1758 | timeFormat: "hh:mm tt", |
---|
| 1759 | onSelect: function (selectedDateTime){ |
---|
| 1760 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1761 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1762 | } |
---|
| 1763 | }, |
---|
| 1764 | onClose : function (selectedDateTime){ |
---|
| 1765 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1766 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1767 | } |
---|
| 1768 | } |
---|
| 1769 | }); |
---|
[5510] | 1770 | |
---|
[6044] | 1771 | var defaultStartHour = tabPrefCalendar.find("input[name=defaultStartHour]").val().trim(); |
---|
| 1772 | var defaultEndHour = tabPrefCalendar.find("input[name=defaultEndHour]").val().trim(); |
---|
[5510] | 1773 | |
---|
[6044] | 1774 | tabPrefCalendar.find("input.time").mask( (($("select[name=hourFormat] option:selected").val().trim().length > 5) ? "99:99 {}" : "99:99") ); |
---|
[5510] | 1775 | |
---|
[6044] | 1776 | if (parseInt($("select[name=hourFormat] option:selected").val().length) > 5) { // am/pm |
---|
| 1777 | tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.defaultToAmPm(defaultStartHour)); |
---|
| 1778 | tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.defaultToAmPm(defaultEndHour)) |
---|
[5510] | 1779 | |
---|
[6044] | 1780 | } else { //24h |
---|
| 1781 | tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.AmPmTo24(defaultStartHour)); |
---|
| 1782 | tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.AmPmTo24(defaultEndHour)); |
---|
| 1783 | } |
---|
| 1784 | }); |
---|
[5510] | 1785 | |
---|
| 1786 | |
---|
| 1787 | |
---|
[6044] | 1788 | }); |
---|
| 1789 | } else { |
---|
| 1790 | $tabs.tabs("select", "#preference_tab"); |
---|
[5341] | 1791 | |
---|
[6044] | 1792 | return true; |
---|
| 1793 | } |
---|
[5341] | 1794 | } |
---|
| 1795 | |
---|
| 1796 | |
---|
[6996] | 1797 | function add_tab_configure_calendar(calendar, type) |
---|
[5341] | 1798 | { |
---|
[6996] | 1799 | $('.qtip.qtip-blue').remove(); |
---|
| 1800 | |
---|
[6044] | 1801 | var calendars = []; |
---|
| 1802 | var signatures = []; |
---|
| 1803 | var previewActiveCalendarConf = 0; |
---|
[6498] | 1804 | var calendarAlarms = []; |
---|
| 1805 | |
---|
[6996] | 1806 | for (var i=0; i<Calendar.signatures.length; i++) { |
---|
| 1807 | if(parseInt(Calendar.signatures[i].calendar.type) == type){ |
---|
| 1808 | calendars.push(Calendar.signatures[i].calendar); |
---|
| 1809 | signatures.push(Calendar.signatures[i]); |
---|
| 1810 | length = signatures.length - 1; |
---|
| 1811 | signatures[length].numberDefaultAlarm = signatures[length].defaultAlarms != '' ? signatures[length].defaultAlarms.length: 0; |
---|
| 1812 | if (calendar && calendars[length].id == calendar) |
---|
| 1813 | previewActiveCalendarConf = length; |
---|
| 1814 | } |
---|
| 1815 | } |
---|
| 1816 | var tab_selector = ['configure_tab', 'configure_tab_group']; |
---|
| 1817 | if(!(document.getElementById(tab_selector[type]))) |
---|
[6044] | 1818 | { |
---|
| 1819 | $('.positionHelper').css('display', 'none'); |
---|
[6696] | 1820 | $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); |
---|
[6996] | 1821 | if(type == 0){ |
---|
| 1822 | var tab_title = "Configurações de agendas"; |
---|
| 1823 | }else{ |
---|
| 1824 | var tab_title = "Configurações de Grupos"; |
---|
| 1825 | } |
---|
| 1826 | $tabs.tabs( "add", "#"+tab_selector[type], tab_title ); |
---|
[5341] | 1827 | |
---|
[6044] | 1828 | var dataColorPicker = { |
---|
| 1829 | colorsSuggestions: colors_suggestions() |
---|
| 1830 | }; |
---|
[5341] | 1831 | |
---|
| 1832 | |
---|
| 1833 | |
---|
[6044] | 1834 | var populateAccordionOnActive = function(event, ui) { |
---|
| 1835 | var nowActive = (typeof(event) == 'number') ? event : $(event.target).accordion( "option", "active" ); |
---|
[6696] | 1836 | if (nowActive === false) |
---|
| 1837 | return; |
---|
[6044] | 1838 | dataColorPicker.colorsDefined = { |
---|
| 1839 | border: '#'+signatures[nowActive].borderColor, |
---|
| 1840 | font:'#'+signatures[nowActive].fontColor, |
---|
| 1841 | background:'#'+signatures[nowActive].backgroundColor |
---|
| 1842 | }; |
---|
| 1843 | if (!jQuery('.accordion-user-calendars .ui-accordion-content').eq(nowActive).has('form')) { |
---|
| 1844 | return true; |
---|
| 1845 | } |
---|
[5341] | 1846 | |
---|
[6044] | 1847 | DataLayer.render( 'templates/configure_calendars_itemlist.ejs', { |
---|
| 1848 | user:User, |
---|
[6996] | 1849 | type:0, |
---|
[6044] | 1850 | calendar:calendars[nowActive], |
---|
| 1851 | signature:signatures[nowActive] |
---|
| 1852 | }, function( form_template ){ |
---|
[6996] | 1853 | var form_content = jQuery('#'+tab_selector[type]+' .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form'); |
---|
[6044] | 1854 | form_content.find('.preferences-alarms-list .button').button({ |
---|
| 1855 | text:false, |
---|
| 1856 | icons:{ |
---|
| 1857 | primary:'ui-icon-close' |
---|
| 1858 | } |
---|
| 1859 | }); |
---|
| 1860 | form_content.find('.button').button(); |
---|
[6498] | 1861 | jQuery('.preferences-alarms-list').find('.button.remove').click(function(el){ |
---|
| 1862 | calendarAlarms[calendarAlarms.length] = $(this).parent('li').find('input[name="alarmId[]"]').val(); |
---|
| 1863 | $(this).parent().remove(); |
---|
| 1864 | }); |
---|
| 1865 | |
---|
[6044] | 1866 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 1867 | var valueTimeZone = calendars[nowActive].timezone; |
---|
| 1868 | form_content.find('select[name="timezone"]').html(timezones_options).find('option[value="'+valueTimeZone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1869 | }); |
---|
[5341] | 1870 | |
---|
[6044] | 1871 | form_content.find('.button-add-alarms').click(function(){ |
---|
[7405] | 1872 | DataLayer.render( 'templates/alarms_add_itemlist.ejs', {type: (parseInt(type) == 1 ? '4' : type) }, function( template ){ |
---|
[6044] | 1873 | jQuery('.preferences-alarms-list').append(template) |
---|
| 1874 | .find('li:last label:eq(0)').remove().end() |
---|
| 1875 | .find('.number').numeric().end() |
---|
| 1876 | .find('.button.remove').button({ |
---|
| 1877 | text:false, |
---|
| 1878 | icons:{ |
---|
| 1879 | primary:'ui-icon-close' |
---|
| 1880 | } |
---|
| 1881 | }).click(function(el) { |
---|
| 1882 | $(this).parent().remove(); |
---|
| 1883 | }); |
---|
| 1884 | }); |
---|
| 1885 | }); |
---|
[5341] | 1886 | |
---|
| 1887 | |
---|
[6044] | 1888 | /** |
---|
[5341] | 1889 | * Set color picker |
---|
| 1890 | */ |
---|
[6044] | 1891 | DataLayer.render( 'templates/calendar_colorpicker.ejs', dataColorPicker, function( template ){ |
---|
| 1892 | form_content.find('.calendar-colorpicker').html( template ); |
---|
[5341] | 1893 | |
---|
[6044] | 1894 | var f = $.farbtastic(form_content.find('.colorpicker'), colorpickerPreviewChange); |
---|
| 1895 | var selected; |
---|
| 1896 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
[5341] | 1897 | |
---|
[6044] | 1898 | var colorpickerPreviewChange = function(color) { |
---|
| 1899 | var pickedup = form_content.find('.colorwell-selected').val(color).css('background-color', color); |
---|
[5341] | 1900 | |
---|
[6044] | 1901 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
[5341] | 1902 | |
---|
[6044] | 1903 | if (pickedup.is('input[name="backgroundColor"]')) { |
---|
| 1904 | colorpicker.find('.fc-event-skin').css('background-color',color); |
---|
| 1905 | } else if (pickedup.is('input[name="fontColor"]')) { |
---|
| 1906 | colorpicker.find('.fc-event-skin').css('color',color); |
---|
| 1907 | } else if (pickedup.is('input[name="borderColor"]')) { |
---|
| 1908 | colorpicker.find('.fc-event-skin').css('border-color',color); |
---|
| 1909 | } |
---|
| 1910 | } |
---|
[5341] | 1911 | |
---|
[6044] | 1912 | form_content.find('.colorwell').each(function () { |
---|
| 1913 | f.linkTo(this); |
---|
[5341] | 1914 | |
---|
[6044] | 1915 | if ($(this).is('input[name="backgroundColor"]')) { |
---|
| 1916 | colorpicker.find('.fc-event-skin').css('background-color', $(this).val()); |
---|
| 1917 | } else if ($(this).is('input[name="fontColor"]')) { |
---|
| 1918 | colorpicker.find('.fc-event-skin').css('color', $(this).val()); |
---|
| 1919 | } else if ($(this).is('input[name="borderColor"]')) { |
---|
| 1920 | colorpicker.find('.fc-event-skin').css('border-color', $(this).val()); |
---|
| 1921 | } |
---|
| 1922 | }) |
---|
| 1923 | .focus(function() { |
---|
| 1924 | if (selected) { |
---|
| 1925 | $(selected).removeClass('colorwell-selected'); |
---|
| 1926 | } |
---|
[5341] | 1927 | |
---|
[6044] | 1928 | $(selected = this).addClass('colorwell-selected'); |
---|
| 1929 | f.linkTo(this, colorpickerPreviewChange); |
---|
| 1930 | f.linkTo(colorpickerPreviewChange); |
---|
[5341] | 1931 | |
---|
[6044] | 1932 | }); |
---|
[5341] | 1933 | |
---|
[6044] | 1934 | form_content.find('select.color-suggestions').change(function() { |
---|
| 1935 | var colors; |
---|
[5341] | 1936 | |
---|
[6044] | 1937 | if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) { |
---|
| 1938 | colorpicker |
---|
| 1939 | .find('input[name="fontColor"]').val(colors.font).focus().end() |
---|
| 1940 | .find('input[name="backgroundColor"]').val(colors.background).focus().end() |
---|
| 1941 | .find('input[name="borderColor"]').val(colors.border).focus().end() |
---|
[5341] | 1942 | |
---|
[6044] | 1943 | .find('.fc-event-skin').css({ |
---|
| 1944 | 'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background, |
---|
| 1945 | 'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border, |
---|
| 1946 | 'color':dataColorPicker.colorsSuggestions[$(this).val()].font |
---|
| 1947 | }); |
---|
| 1948 | } |
---|
| 1949 | }); |
---|
[5341] | 1950 | |
---|
[6044] | 1951 | /** |
---|
[5341] | 1952 | * Trata a mudança dos valores dos campos de cores. |
---|
| 1953 | * Se mudar um conjunto de cores sugerido, |
---|
| 1954 | * este vira um conjunto de cores personalizado. |
---|
| 1955 | */ |
---|
[6044] | 1956 | form_content.find('.colorwell').change(function (element, ui) { |
---|
| 1957 | if (true) { |
---|
| 1958 | form_content.find('select.color-suggestions') |
---|
| 1959 | .find('option:selected').removeAttr('selected').end() |
---|
| 1960 | .find('option[value="custom"]').attr('selected', 'selected').trigger('change'); |
---|
| 1961 | } |
---|
| 1962 | }); |
---|
| 1963 | }); //END set colorpicker |
---|
[5341] | 1964 | |
---|
[6044] | 1965 | form_content.find('.phone').mask("+99 (99) 9999-9999"); |
---|
| 1966 | form_content.find('.number').numeric(); |
---|
[5341] | 1967 | |
---|
[6044] | 1968 | }); //END DataLayer.render( 'templates/configure_calendars_itemlist.ejs' ... |
---|
[5341] | 1969 | |
---|
[6044] | 1970 | // === validations preferences ==== |
---|
[5341] | 1971 | |
---|
| 1972 | |
---|
[6044] | 1973 | } //END populateAccordionOnActive(event, ui) |
---|
[5341] | 1974 | |
---|
| 1975 | |
---|
[6044] | 1976 | DataLayer.render( 'templates/configure_calendars.ejs', { |
---|
| 1977 | user:User, |
---|
[7259] | 1978 | type: type, |
---|
[6044] | 1979 | calendars:calendars, |
---|
| 1980 | signatures:signatures |
---|
| 1981 | }, function( template ){ |
---|
[6996] | 1982 | var template_content = jQuery('#'+tab_selector[type]).html( template ).find('.configure-calendars-win'); |
---|
[6044] | 1983 | template_content.find('.button').button().filter('.save').click(function(evt){ |
---|
[6498] | 1984 | if(calendarAlarms.length) |
---|
| 1985 | DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]}); |
---|
[6044] | 1986 | template_content.find('form').submit(); |
---|
[6996] | 1987 | $tabs.tabs( "remove", "#"+tab_selector[type]); |
---|
[6044] | 1988 | DataLayer.commit( false, false, function( received ){ |
---|
| 1989 | delete Calendar.currentViewKey; |
---|
| 1990 | Calendar.load(); |
---|
| 1991 | refresh_calendars(); |
---|
| 1992 | }); |
---|
[6498] | 1993 | if(calendarAlarms.length) |
---|
| 1994 | Calendar.load(); |
---|
[6044] | 1995 | }).end().filter('.cancel').click(function(evt){ |
---|
[6996] | 1996 | $tabs.tabs( "remove", "#"+tab_selector[type]); |
---|
[6044] | 1997 | }); |
---|
[5341] | 1998 | |
---|
[6044] | 1999 | /** |
---|
[5341] | 2000 | * Muda a estrutura do template para a aplicação do plugin accordion |
---|
| 2001 | */ |
---|
[6044] | 2002 | template_content.find('.header-menu-container').after('<div class="accordion-user-calendars"></div>').end().find('.accordion-user-calendars') |
---|
| 2003 | .append(template_content.children('fieldset')); |
---|
[5341] | 2004 | |
---|
[6044] | 2005 | template_content.find('.accordion-user-calendars').children('fieldset').each(function(index) { |
---|
| 2006 | $(this).before($('<h3></h3>').html($(this).children('legend'))); |
---|
| 2007 | }); |
---|
[5341] | 2008 | |
---|
[6044] | 2009 | template_content.find('.accordion-user-calendars').accordion({ |
---|
| 2010 | autoHeight: false, |
---|
| 2011 | collapsible: true, |
---|
| 2012 | clearStyle: true, |
---|
| 2013 | active: previewActiveCalendarConf, |
---|
| 2014 | changestart: populateAccordionOnActive |
---|
| 2015 | }); |
---|
| 2016 | populateAccordionOnActive(previewActiveCalendarConf); |
---|
| 2017 | }); |
---|
[5341] | 2018 | |
---|
[6044] | 2019 | } else { |
---|
[6696] | 2020 | $('.positionHelper').css('display','none'); |
---|
| 2021 | $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); |
---|
[6996] | 2022 | $tabs.tabs("select", "#"+tab_selector[type]); |
---|
[6044] | 2023 | $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); |
---|
[5341] | 2024 | |
---|
[6044] | 2025 | return true; |
---|
| 2026 | } |
---|
[5341] | 2027 | |
---|
| 2028 | } |
---|
| 2029 | |
---|
[6996] | 2030 | function getSelectedCalendars( reverse, type ){ |
---|
[7970] | 2031 | var selector = !!type ? "div.my-groups-task .calendar-view" : "div.my-calendars .calendar-view, div.signed-calendars .calendar-view"; |
---|
| 2032 | var returns = []; |
---|
| 2033 | |
---|
| 2034 | $.each( $(selector), function(i , c){ |
---|
| 2035 | |
---|
| 2036 | if( reverse ? !c.checked : c.checked ) |
---|
| 2037 | returns.push( c.value ); |
---|
| 2038 | |
---|
[6044] | 2039 | }); |
---|
[7970] | 2040 | |
---|
| 2041 | if (!returns.length) |
---|
| 2042 | return false; |
---|
| 2043 | |
---|
| 2044 | return returns; |
---|
[5341] | 2045 | } |
---|
| 2046 | |
---|
| 2047 | /** |
---|
| 2048 | * TODO - transformar em preferência do módulo e criar telas de adição e exclusão de conjunto de cores |
---|
| 2049 | */ |
---|
| 2050 | function colors_suggestions(){ |
---|
[6044] | 2051 | return [ |
---|
| 2052 | { |
---|
| 2053 | name:'Padrão', |
---|
| 2054 | border:'#3366cc', |
---|
| 2055 | font:'#ffffff', |
---|
| 2056 | background:'#3366cc' |
---|
| 2057 | }, |
---|
| 2058 | |
---|
| 2059 | { |
---|
| 2060 | name:'Coala', |
---|
| 2061 | border:'#123456', |
---|
| 2062 | font:'#ffffff', |
---|
| 2063 | background:'#385c80' |
---|
| 2064 | }, |
---|
| 2065 | |
---|
| 2066 | { |
---|
| 2067 | name:'Tomate', |
---|
| 2068 | border:'#d5130b', |
---|
| 2069 | font:'#111111', |
---|
| 2070 | background:'#e36d76' |
---|
| 2071 | }, |
---|
| 2072 | |
---|
| 2073 | { |
---|
| 2074 | name:'Limão', |
---|
| 2075 | border:'#32ed21', |
---|
| 2076 | font:'#1f3f1c', |
---|
| 2077 | background:'#b2f1ac' |
---|
| 2078 | }, |
---|
| 2079 | |
---|
| 2080 | { |
---|
| 2081 | name:'Alto contraste', |
---|
| 2082 | border:'#000000', |
---|
| 2083 | font:'#ffffff', |
---|
| 2084 | background:'#222222' |
---|
| 2085 | } |
---|
| 2086 | ] |
---|
[5341] | 2087 | } |
---|
| 2088 | |
---|
[7017] | 2089 | function remove_event(eventId, idCalendar, type){ |
---|
[6996] | 2090 | $.Zebra_Dialog('Tem certeza que deseja excluir?', { |
---|
[6044] | 2091 | 'type': 'question', |
---|
| 2092 | 'overlay_opacity': '0.5', |
---|
| 2093 | 'buttons': ['Sim', 'Não'], |
---|
| 2094 | 'onClose': function(clicked) { |
---|
| 2095 | if(clicked == 'Sim'){ |
---|
[6331] | 2096 | |
---|
[7702] | 2097 | var schedulable = getSchedulable( eventId, ''); |
---|
[6359] | 2098 | schedulable.calendar = ''+idCalendar; |
---|
[6331] | 2099 | var schudableDecode = DataLayer.encode( "schedulable:preview", schedulable); |
---|
| 2100 | var me = schudableDecode.me.user ? schudableDecode.me.user.id : schudableDecode.me.id; |
---|
| 2101 | |
---|
[7017] | 2102 | var filter = {filter: ['AND', ['=','id',eventId], ['=','calendar',idCalendar], ['=','user', me]]}; |
---|
| 2103 | |
---|
| 2104 | if(type) |
---|
| 2105 | filter.filter.push(['=','type',type]); |
---|
| 2106 | |
---|
| 2107 | DataLayer.removeFilter('schedulable', filter); |
---|
[6286] | 2108 | Calendar.rerenderView(true); |
---|
[6044] | 2109 | } |
---|
| 2110 | } |
---|
| 2111 | }); |
---|
[5592] | 2112 | } |
---|
| 2113 | |
---|
[7965] | 2114 | function mount_exception(eventID, exception){ |
---|
[5592] | 2115 | |
---|
[7702] | 2116 | getSchedulable( eventID.toString() , ''); |
---|
| 2117 | var schedulable = DataLayer.get('schedulable', eventID.toString() ) |
---|
| 2118 | var edit = { repeat: (DataLayer.get('repeat', schedulable.repeat)) }; |
---|
| 2119 | |
---|
[5746] | 2120 | edit.repeat.startTime = new Date(parseInt(edit.repeat.startTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5752] | 2121 | edit.repeat.endTime = parseInt(edit.repeat.count) > 0 ? '0' : new Date(parseInt(edit.repeat.endTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5746] | 2122 | |
---|
[7965] | 2123 | edit.repeat.exceptions = ( exception ); |
---|
[5746] | 2124 | |
---|
| 2125 | return edit.repeat; |
---|
| 2126 | } |
---|
| 2127 | |
---|
| 2128 | function remove_ocurrence(eventId, idRecurrence){ |
---|
[6044] | 2129 | $.Zebra_Dialog('Tem certeza que deseja excluir esta ocorrência?', { |
---|
| 2130 | 'type': 'question', |
---|
| 2131 | 'overlay_opacity': '0.5', |
---|
| 2132 | 'buttons': ['Sim', 'Não'], |
---|
| 2133 | 'onClose': function(clicked) { |
---|
| 2134 | if(clicked == 'Sim'){ |
---|
| 2135 | var repeat = mount_exception(eventId, idRecurrence); |
---|
| 2136 | DataLayer.remove('repeat', false); |
---|
| 2137 | DataLayer.put('repeat', repeat); |
---|
| 2138 | DataLayer.commit(false, false, function(data){ |
---|
| 2139 | Calendar.rerenderView(true); |
---|
| 2140 | }); |
---|
| 2141 | } |
---|
| 2142 | } |
---|
| 2143 | }); |
---|
[5746] | 2144 | } |
---|
| 2145 | |
---|
| 2146 | |
---|
[6996] | 2147 | function remove_calendar(type){ |
---|
[6044] | 2148 | /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ |
---|
[6996] | 2149 | if(!!parseInt(type)) |
---|
| 2150 | var title = 'Todas as tarefas deste grupo serão removidas. Deseja prosseguir com a operação?'; |
---|
| 2151 | else |
---|
| 2152 | var title = 'Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?'; |
---|
| 2153 | $.Zebra_Dialog(title, { |
---|
[6044] | 2154 | 'type': 'question', |
---|
| 2155 | 'overlay_opacity': '0.5', |
---|
| 2156 | 'buttons': ['Sim', 'Não'], |
---|
| 2157 | 'onClose': function(clicked) { |
---|
| 2158 | if(clicked == 'Sim'){ |
---|
| 2159 | var idCalendar = $('.cal-list-options-btn.ui-state-active').attr('class').match(/[0-9]+/g); |
---|
[5592] | 2160 | |
---|
[6044] | 2161 | DataLayer.remove('calendarSignature', Calendar.signatureOf[idCalendar[0]].id ); |
---|
[5592] | 2162 | |
---|
[6044] | 2163 | if(idCalendar == User.preferences.defaultCalendar) |
---|
| 2164 | DataLayer.remove( 'modulePreference', User.preferenceIds['defaultCalendar']); |
---|
[5636] | 2165 | |
---|
[6044] | 2166 | DataLayer.commit( false, false, function( received ){ |
---|
| 2167 | delete Calendar.currentViewKey; |
---|
| 2168 | Calendar.load(); |
---|
[6996] | 2169 | refresh_calendars(type); |
---|
[6044] | 2170 | }); |
---|
| 2171 | } |
---|
| 2172 | $('.positionHelper').css('display', 'none'); |
---|
[5409] | 2173 | |
---|
[6044] | 2174 | } |
---|
| 2175 | }); |
---|
[5341] | 2176 | } |
---|
| 2177 | |
---|
[6996] | 2178 | function refresh_calendars(type){ |
---|
[5341] | 2179 | |
---|
[6044] | 2180 | var colorsSuggestions = colors_suggestions(); |
---|
| 2181 | var buttons_colors = ""; |
---|
| 2182 | for(var i = 0; i < colorsSuggestions.length; i++){ |
---|
| 2183 | 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>"; |
---|
| 2184 | } |
---|
[5341] | 2185 | |
---|
[6044] | 2186 | //DataLayer.render( 'templates/calendar_list.ejs', 'calendar:list', ["IN", "id", Calendar.calendarIds], function( html ){ |
---|
| 2187 | DataLayer.render( 'templates/calendar_list.ejs', Calendar, function( html ){ |
---|
[5341] | 2188 | |
---|
[6044] | 2189 | var meu_container = $(".calendars-list").html( html ); |
---|
[5341] | 2190 | |
---|
[6674] | 2191 | var doMenu = function(){ |
---|
| 2192 | $('ul.list-calendars .cal-list-options-btn').each(function(){ |
---|
| 2193 | $(this).menu({ |
---|
| 2194 | content: $(this).next().html(), |
---|
| 2195 | width: '120', |
---|
| 2196 | positionOpts: { |
---|
| 2197 | posX: 'left', |
---|
| 2198 | posY: 'bottom', |
---|
| 2199 | offsetX: 0, |
---|
| 2200 | offsetY: 0, |
---|
| 2201 | directionH: 'right', |
---|
| 2202 | directionV: 'down', |
---|
| 2203 | detectH: true, // do horizontal collision detection |
---|
| 2204 | detectV: true, // do vertical collision detection |
---|
| 2205 | linkToFront: false |
---|
| 2206 | }, |
---|
| 2207 | flyOut: true, |
---|
| 2208 | showSpeed: 100, |
---|
| 2209 | crumbDefaultText: '>' |
---|
| 2210 | }); |
---|
| 2211 | }); |
---|
| 2212 | } |
---|
[6996] | 2213 | |
---|
[6674] | 2214 | doMenu(); |
---|
[6996] | 2215 | var currentToolTip = null; |
---|
[6674] | 2216 | $('#divAppbox').on('scroll',function(){ |
---|
| 2217 | if ($('.cal-list-options-btn.fg-menu-open.ui-state-active')){ |
---|
| 2218 | var offset = $('.cal-list-options-btn.fg-menu-open.ui-state-active').offset(); |
---|
| 2219 | if (offset) |
---|
[6996] | 2220 | $('.positionHelper').css('top',offset.top); |
---|
[6674] | 2221 | } |
---|
[6996] | 2222 | |
---|
[6956] | 2223 | if ($('.button.config-menu.fg-menu-open')){ |
---|
| 2224 | var offset = $('.button.config-menu.fg-menu-open').offset(); |
---|
| 2225 | if (offset) |
---|
[6996] | 2226 | $('.positionHelper').css('top',offset.top); |
---|
[6956] | 2227 | } |
---|
[6996] | 2228 | |
---|
| 2229 | |
---|
| 2230 | if ($(".new-group.qtip-active").length || $(".new-calendar.qtip-active").length) |
---|
| 2231 | $('.qtip-active').css('top',currentToolTip.offset().top - 50); |
---|
| 2232 | |
---|
[6674] | 2233 | }); |
---|
[7938] | 2234 | |
---|
| 2235 | $('ul.list-calendars .cal-list-options-btn').on('click',function(){doMenu();}); |
---|
[6996] | 2236 | |
---|
| 2237 | |
---|
| 2238 | /***************************************New Calendar***************************************/ |
---|
[5592] | 2239 | meu_container.find(".button.new-calendar").button({ |
---|
[6044] | 2240 | icons: { |
---|
| 2241 | primary: "ui-icon-plus" |
---|
| 2242 | }, |
---|
| 2243 | text: false |
---|
| 2244 | }).click(function () { |
---|
[6996] | 2245 | currentToolTip = $(this); |
---|
| 2246 | var typeCalendar = !!parseInt($(this).attr('class').match(/[0-9]+/g)) ? |
---|
| 2247 | {type: 'new-group', title: 'Novo Grupo', typeValue: 1, prompt: 'Nome do grupo'} : |
---|
| 2248 | {type: 'new-calendar', title: 'Nova Agenda', typeValue: 0, prompt: 'Nome da agenda'} |
---|
[5341] | 2249 | |
---|
[6996] | 2250 | if(!$('.qtip.qtip-blue.qtip-active.'+typeCalendar.type).length){ |
---|
| 2251 | |
---|
| 2252 | $('.qtip.qtip-blue').remove(); |
---|
| 2253 | |
---|
| 2254 | $(this).qtip({ |
---|
| 2255 | show: { |
---|
| 2256 | ready: true, |
---|
| 2257 | solo: true, |
---|
| 2258 | when: { |
---|
| 2259 | event: 'click' |
---|
| 2260 | } |
---|
| 2261 | }, |
---|
| 2262 | hide: false, |
---|
| 2263 | content: { |
---|
| 2264 | text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), |
---|
| 2265 | title: { |
---|
| 2266 | text: typeCalendar.title, |
---|
| 2267 | button: '<a class="button close" href="#">close</a>' |
---|
| 2268 | } |
---|
| 2269 | }, |
---|
| 2270 | style: { |
---|
| 2271 | name: 'blue', |
---|
| 2272 | tip: { |
---|
| 2273 | corner: 'leftMiddle' |
---|
| 2274 | }, |
---|
| 2275 | border: { |
---|
| 2276 | width: 4, |
---|
| 2277 | radius: 8 |
---|
| 2278 | }, |
---|
| 2279 | width: { |
---|
| 2280 | min: 230, |
---|
| 2281 | max:230 |
---|
| 2282 | } |
---|
| 2283 | }, |
---|
| 2284 | position: { |
---|
| 2285 | corner: { |
---|
| 2286 | target: 'rightMiddle', |
---|
| 2287 | tooltip: 'leftMiddle' |
---|
| 2288 | }, |
---|
| 2289 | adjust: { |
---|
| 2290 | x:0, |
---|
| 2291 | y: -12 |
---|
| 2292 | |
---|
| 2293 | } |
---|
| 2294 | } |
---|
| 2295 | }) |
---|
| 2296 | .qtip("api").onShow = function(arg0) { |
---|
[5341] | 2297 | |
---|
[6996] | 2298 | $('.qtip-active .button.close').button({ |
---|
[7457] | 2299 | icons: { primary: "ui-icon-close" }, |
---|
[6996] | 2300 | text: false |
---|
| 2301 | }) |
---|
| 2302 | .click(function(){ |
---|
[7457] | 2303 | $('.qtip.qtip-blue').remove(); |
---|
[6996] | 2304 | }); |
---|
| 2305 | |
---|
[7457] | 2306 | $('.qtip-active').addClass(typeCalendar.type); |
---|
[6996] | 2307 | |
---|
[7457] | 2308 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 2309 | $('.qtip.qtip-blue').remove(); |
---|
| 2310 | }); |
---|
| 2311 | |
---|
| 2312 | |
---|
[6996] | 2313 | $('.qtip-active .button.save').button().click(function(){ |
---|
| 2314 | if(!typeCalendar.typeValue) |
---|
| 2315 | for(var i = 0; i < Calendar.calendars.length; i++){ |
---|
| 2316 | if(Calendar.calendars[i].location == ( User.me.uid + '/' + $('.qtip-active input').val())){ |
---|
| 2317 | $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ |
---|
| 2318 | 'overlay_opacity': '0.5', |
---|
| 2319 | 'type': 'warning' |
---|
| 2320 | }); |
---|
| 2321 | $('.qtip.qtip-blue').remove(); |
---|
| 2322 | return; |
---|
| 2323 | } |
---|
| 2324 | } |
---|
| 2325 | |
---|
| 2326 | var selected; |
---|
| 2327 | var color = $('.cal-colors-options-btn').each(function(index){ |
---|
| 2328 | if ($(this).is('.color-selected')) |
---|
| 2329 | selected = index; |
---|
| 2330 | }); |
---|
| 2331 | DataLayer.put( "calendarSignature", { |
---|
| 2332 | user: User.me.id, |
---|
| 2333 | calendar: { |
---|
| 2334 | name: Encoder.htmlEncode($('.qtip-active input').val()), |
---|
| 2335 | timezone: User.preferences.timezone, |
---|
| 2336 | type: typeCalendar.typeValue |
---|
| 2337 | }, |
---|
| 2338 | isOwner: 1, |
---|
| 2339 | fontColor: colorsSuggestions[selected]['font'].substring(1) , |
---|
| 2340 | backgroundColor: colorsSuggestions[selected]['background'].substring(1) , |
---|
| 2341 | borderColor: colorsSuggestions[selected]['border'].substring(1) |
---|
| 2342 | }); |
---|
| 2343 | DataLayer.commit( false, false, function( received ){ |
---|
| 2344 | delete Calendar.currentViewKey; |
---|
| 2345 | Calendar.load(); |
---|
| 2346 | refresh_calendars(); |
---|
| 2347 | }); |
---|
| 2348 | $('.qtip.qtip-blue').remove(); |
---|
| 2349 | }); |
---|
[7457] | 2350 | |
---|
[6996] | 2351 | $(".qtip-active input").Watermark(typeCalendar.prompt); |
---|
| 2352 | |
---|
| 2353 | $('.qtip-active').keydown(function(event) { |
---|
| 2354 | if (event.keyCode == '27') |
---|
| 2355 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 2356 | }); |
---|
| 2357 | |
---|
| 2358 | $('.colors-options').prepend(buttons_colors); |
---|
| 2359 | $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); |
---|
| 2360 | |
---|
| 2361 | var buttons = $('.cal-colors-options-btn').button(); |
---|
| 2362 | |
---|
| 2363 | buttons.click(function(){ |
---|
| 2364 | buttons.removeClass('color-selected'); |
---|
| 2365 | $(this).addClass('color-selected'); |
---|
| 2366 | }); |
---|
| 2367 | } |
---|
| 2368 | } |
---|
[6044] | 2369 | }); |
---|
[6996] | 2370 | |
---|
[6044] | 2371 | $("img.cal-list-img").click(function(evt) { |
---|
[6996] | 2372 | $(".cal-list-options_1").toggleClass( "hidden" ); |
---|
[6044] | 2373 | }); |
---|
[5341] | 2374 | |
---|
[6996] | 2375 | $(".my-groups-task a.title-my-calendars").click(function() { |
---|
| 2376 | $(".my-groups-task ul.my-list-calendars").toggleClass("hidden") |
---|
| 2377 | $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-s"); |
---|
| 2378 | $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-e"); |
---|
| 2379 | }); |
---|
| 2380 | |
---|
[6044] | 2381 | $(".my-calendars a.title-my-calendars").click(function() { |
---|
[6996] | 2382 | $(".my-calendars ul.my-list-calendars").toggleClass("hidden") |
---|
| 2383 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s"); |
---|
| 2384 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e"); |
---|
[6044] | 2385 | }); |
---|
[5381] | 2386 | |
---|
[6044] | 2387 | $(".signed-calendars a.title-signed-calendars").click(function() { |
---|
[6996] | 2388 | $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden"); |
---|
[6044] | 2389 | }); |
---|
[5341] | 2390 | |
---|
[6044] | 2391 | $("ul li.list-calendars-item").click(function(evt) { |
---|
[5341] | 2392 | |
---|
[6044] | 2393 | }); |
---|
[5341] | 2394 | |
---|
[6044] | 2395 | $("ul li.list-calendars-item .ui-corner-all").click(function(evt) { |
---|
| 2396 | //alert('teste'); |
---|
| 2397 | }); |
---|
[5341] | 2398 | |
---|
[6044] | 2399 | meu_container.find(".button.new-calendar-shared").button({ |
---|
| 2400 | icons: { |
---|
| 2401 | primary: "ui-icon-plus" |
---|
| 2402 | }, |
---|
| 2403 | text: false |
---|
| 2404 | }).click(function (event) { |
---|
| 2405 | show_modal_search_shared(); |
---|
| 2406 | }); |
---|
[7938] | 2407 | |
---|
| 2408 | |
---|
[6044] | 2409 | meu_container.find('.title-signed-calendars').click(function(evt){ |
---|
| 2410 | var status = $(this).parent().find('.status-list-shared'); |
---|
[5592] | 2411 | |
---|
[6044] | 2412 | if(status.hasClass('ui-icon-triangle-1-s')) |
---|
| 2413 | status.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); |
---|
| 2414 | else |
---|
| 2415 | status.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); |
---|
| 2416 | }); |
---|
[5592] | 2417 | |
---|
[6044] | 2418 | $('.calendar-view').click(function(evt){ |
---|
[7938] | 2419 | |
---|
[7970] | 2420 | var checkBox = $(this); |
---|
| 2421 | var calendarId = $(this).val(); |
---|
[7938] | 2422 | |
---|
[7970] | 2423 | Calendar.signatureOf[ calendarId ].hidden = (checkBox.is(':checked') ? 0 : 1 ); |
---|
[7938] | 2424 | |
---|
[7970] | 2425 | DataLayer.put('calendarSignature', {id: Calendar.signatureOf[ calendarId ].id , hidden: Calendar.signatureOf[ calendarId ].hidden } ); |
---|
| 2426 | DataLayer.commit(); |
---|
[7938] | 2427 | |
---|
| 2428 | |
---|
[7970] | 2429 | if($tabs.tabs('option' ,'selected') == 0){ |
---|
| 2430 | |
---|
| 2431 | if(Calendar.currentView && !!Calendar.currentView[ calendarId ]){ |
---|
| 2432 | |
---|
| 2433 | Calendar.currentView[ calendarId ].hidden = !checkBox.is(':checked'); |
---|
| 2434 | $('#calendar').fullCalendar( 'refetchEvents' ); |
---|
| 2435 | } |
---|
| 2436 | |
---|
| 2437 | }else{ |
---|
| 2438 | type = $tabs.tabs('option' ,'selected'); |
---|
| 2439 | type = type > 2 ? 2 : (type - 1) |
---|
| 2440 | |
---|
| 2441 | pageselectCallback('', 0, false, type); |
---|
| 2442 | } |
---|
[6044] | 2443 | }); |
---|
| 2444 | }); |
---|
[5341] | 2445 | } |
---|
| 2446 | |
---|
[6996] | 2447 | function add_events_list(keyword, type) |
---|
[5341] | 2448 | { |
---|
[7423] | 2449 | if ($.trim(keyword) == "") return; |
---|
[6044] | 2450 | var tab_title = ""; |
---|
| 2451 | if (keyword){ |
---|
[6996] | 2452 | type = 2; |
---|
| 2453 | if(keyword.length < 10) |
---|
| 2454 | tab_title = keyword; |
---|
| 2455 | else |
---|
| 2456 | tab_title = keyword.substr(0,10) + '..."'; |
---|
[6044] | 2457 | }else{ |
---|
[6996] | 2458 | if(type){ |
---|
| 2459 | if(!!parseInt(type)) |
---|
| 2460 | tab_title = "Lista de tarefas"; |
---|
| 2461 | else |
---|
| 2462 | tab_title = "Lista de eventos"; |
---|
| 2463 | } |
---|
[6044] | 2464 | } |
---|
[6996] | 2465 | var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; |
---|
[6044] | 2466 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
[5341] | 2467 | |
---|
[6996] | 2468 | if(!(document.getElementById(tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") ))) |
---|
[6044] | 2469 | { |
---|
| 2470 | Encoder.EncodeType = "entity"; |
---|
[6996] | 2471 | $tabs.tabs( "add", "#"+tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) ); |
---|
[6044] | 2472 | } |
---|
| 2473 | else /* Tab already opened */ |
---|
| 2474 | { |
---|
[6996] | 2475 | //$tabs.tabs("option", "selected", 2); |
---|
| 2476 | } |
---|
[5341] | 2477 | |
---|
[6996] | 2478 | pageselectCallback(keyword, 0, false, type); // load page 1 and insert data on event_list.ejs |
---|
[5341] | 2479 | |
---|
[6044] | 2480 | $('.preferences-win.active .button.save, .preferences-win.active .button.cancel, .preferences-win.active .button.import, .preferences-win.active .button.export').button(); |
---|
[5341] | 2481 | } |
---|
| 2482 | |
---|
| 2483 | function paginatorSearch(currentView){ |
---|
[6044] | 2484 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
| 2485 | function(){ |
---|
| 2486 | $(this).addClass('fc-state-hover'); |
---|
| 2487 | }, |
---|
| 2488 | function(){ |
---|
| 2489 | $(this).removeClass('fc-state-hover'); |
---|
| 2490 | }).mousedown(function(){ |
---|
| 2491 | $(this).addClass('fc-state-down'); |
---|
| 2492 | }).mouseup(function(){ |
---|
| 2493 | $(this).removeClass('fc-state-down'); |
---|
| 2494 | $('.events-list.events-list-win.active').removeClass('active'); |
---|
| 2495 | var paginator = $(this).attr('class'); |
---|
| 2496 | if(paginator.indexOf('next') > 0){ |
---|
| 2497 | if(parseInt($(currentView+' [name = results]').val()) > 25) |
---|
[6996] | 2498 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), false, 2); |
---|
[6044] | 2499 | }else{ |
---|
| 2500 | if(parseInt($(currentView+' [name = page_index]').val()) > 0) |
---|
[6996] | 2501 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), false, 2); |
---|
[6044] | 2502 | } |
---|
| 2503 | }); |
---|
[5341] | 2504 | } |
---|
| 2505 | |
---|
| 2506 | function mountTitleList(page_index ,view){ |
---|
[6044] | 2507 | switch (view){ |
---|
| 2508 | case 'agendaDay': |
---|
| 2509 | case 'basicDay': |
---|
| 2510 | var date = new Date().add({ |
---|
| 2511 | days: page_index |
---|
| 2512 | }); |
---|
| 2513 | return (dateCalendar.dayNames[date.getDay()])+", "+(date.toString('dd MMM yyyy')); |
---|
| 2514 | case 'agendaWeek': |
---|
| 2515 | var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
| 2516 | dateStart.add({ |
---|
| 2517 | days: (7 * page_index) |
---|
| 2518 | }); |
---|
| 2519 | var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
| 2520 | dateEnd.add({ |
---|
| 2521 | days: (page_index * 7)+7 |
---|
| 2522 | }); |
---|
| 2523 | if(dateStart.toString('MM') != dateEnd.toString('MM')) |
---|
| 2524 | return dateStart.toString('dd')+' de '+dateCalendar.monthNamesShort[dateStart.getMonth()]+' a '+dateEnd.toString('dd')+' de '+dateCalendar.monthNames[dateEnd.getMonth()]+' - '+dateEnd.toString('yyyy'); |
---|
| 2525 | return +dateStart.toString("dd")+" a "+dateEnd.toString("dd")+" de "+dateCalendar.monthNames[dateEnd.getMonth()]+" - "+dateEnd.toString('yyyy'); |
---|
| 2526 | case 'month': |
---|
| 2527 | var date = new Date().add({ |
---|
| 2528 | months: page_index |
---|
| 2529 | }) |
---|
| 2530 | return dateCalendar.monthNames[date.getMonth()]+" "+date.toString("yyyy"); |
---|
| 2531 | case 'year': |
---|
| 2532 | var date = new Date().add({ |
---|
| 2533 | years: page_index |
---|
| 2534 | }); |
---|
| 2535 | return date.toString("yyyy"); |
---|
| 2536 | } |
---|
[5341] | 2537 | } |
---|
| 2538 | |
---|
[6996] | 2539 | function paginatorList(currentView, view, type){ |
---|
| 2540 | $(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] | 2541 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
| 2542 | if(view == 'basicDay') |
---|
| 2543 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-agendaDay').addClass('fc-state-active'); |
---|
| 2544 | else |
---|
| 2545 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-'+view).addClass('fc-state-active'); |
---|
| 2546 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right').addClass('list-right'); |
---|
[5381] | 2547 | |
---|
[6044] | 2548 | $(currentView+' .header-paginator .fc-header-right .fc-button').hover( |
---|
| 2549 | function(){ |
---|
| 2550 | $(this).addClass('fc-state-hover'); |
---|
| 2551 | }, |
---|
[8021] | 2552 | |
---|
[6044] | 2553 | function(){ |
---|
| 2554 | $(this).removeClass('fc-state-hover'); |
---|
| 2555 | }).mousedown(function(){ |
---|
| 2556 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
| 2557 | $(this).addClass('fc-state-active'); |
---|
| 2558 | }).mouseup(function(){ |
---|
| 2559 | var goView = $(this).attr('class'); |
---|
| 2560 | if(goView.indexOf('agendaDay') > 0) |
---|
[6996] | 2561 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaDay', type); |
---|
[6044] | 2562 | else if(goView.indexOf('month') > 0) |
---|
[6996] | 2563 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'month', type); |
---|
[6044] | 2564 | else if(goView.indexOf('year') > 0) |
---|
[6996] | 2565 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'year', type); |
---|
[6044] | 2566 | else if(goView.indexOf('agendaWeek') > 0) |
---|
[6996] | 2567 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaWeek', type); |
---|
[5381] | 2568 | |
---|
[6044] | 2569 | }); |
---|
[5381] | 2570 | |
---|
[6044] | 2571 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
| 2572 | function(){ |
---|
| 2573 | $(this).addClass('fc-state-hover'); |
---|
| 2574 | }, |
---|
| 2575 | function(){ |
---|
| 2576 | $(this).removeClass('fc-state-hover'); |
---|
| 2577 | }).mousedown(function(){ |
---|
| 2578 | $(this).addClass('fc-state-down'); |
---|
| 2579 | }).mouseup(function(){ |
---|
| 2580 | $(this).removeClass('fc-state-down'); |
---|
| 2581 | var paginator = $(this).attr('class'); |
---|
| 2582 | if(paginator.indexOf('next') > 0) |
---|
[6996] | 2583 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), view, type); |
---|
[6044] | 2584 | else |
---|
[6996] | 2585 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), view, type); |
---|
[6044] | 2586 | }); |
---|
[5341] | 2587 | } |
---|
| 2588 | |
---|
[6996] | 2589 | function printEventList(view){ |
---|
| 2590 | $('.fc-button-print.print-list-events').click(function(){ |
---|
| 2591 | var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); |
---|
| 2592 | var listEvents = $(view).clone(); |
---|
| 2593 | listEvents.find('.fc-button').remove(); |
---|
| 2594 | listEvents.find('.details-event-list').remove(); |
---|
[7022] | 2595 | listEvents.find('.list-events-paginator').remove(); |
---|
[6996] | 2596 | listEvents = listEvents.html(); |
---|
| 2597 | type = $(this).parents('.ui-tabs-panel').attr("id").split("_")[1]; |
---|
[7022] | 2598 | |
---|
[6996] | 2599 | var data = { |
---|
| 2600 | type : type == "tasks" ? "task-list" : ( type == "events" ? "event-list" : "search"), |
---|
[7022] | 2601 | html : listEvents, |
---|
| 2602 | InfoPage : $(this).parents('table.header-paginator').find( '.fc-header-title' ).text() |
---|
[6996] | 2603 | } |
---|
| 2604 | window_print.document.open(); |
---|
| 2605 | window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); |
---|
| 2606 | window_print.document.close(); |
---|
| 2607 | window_print.print(); |
---|
| 2608 | }); |
---|
| 2609 | } |
---|
| 2610 | |
---|
| 2611 | function paginatorListEvent(currentView, typeView, view, type){ |
---|
[6044] | 2612 | if(!!$(currentView).find('.fc-calendar').length) |
---|
| 2613 | return; |
---|
[6190] | 2614 | $(currentView+' .events-list.events-list-win.active').prepend($('.fc-header:first').clone()); |
---|
[6044] | 2615 | //Remove contudo nao utilizado |
---|
| 2616 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-today').remove(); |
---|
| 2617 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicWeek').remove(); |
---|
[8021] | 2618 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicDay').removeClass("fc-button-basicDay").addClass('fc-button-agendaDay'); |
---|
[5341] | 2619 | |
---|
[6044] | 2620 | //Adiciona e remove as classes para esta visualizacao |
---|
| 2621 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-header-center').addClass('list-events-paginator'); |
---|
| 2622 | $(currentView+' .events-list.events-list-win.active .fc-header .list-events-paginator').removeClass('fc-header-center'); |
---|
[6996] | 2623 | |
---|
[6044] | 2624 | //Adicionar class no header padronizar com a tela principal |
---|
[6996] | 2625 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-print').addClass('print-list-events'); |
---|
| 2626 | $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); |
---|
| 2627 | $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); |
---|
| 2628 | |
---|
| 2629 | printEventList(currentView); |
---|
| 2630 | |
---|
[6044] | 2631 | if(typeView == 'search'){ |
---|
[6996] | 2632 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right span.fc-button:not(.fc-button-print)').remove(); |
---|
[6044] | 2633 | $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>Resultados para: '+$(currentView+' [name = keyword]').val()+'</h2>'); |
---|
| 2634 | if((parseInt($(currentView+' [name = page_index]').val()) == 0) && (parseInt($(currentView+' [name = results]').val()) <= 25)) |
---|
| 2635 | return; |
---|
| 2636 | paginatorSearch(currentView); |
---|
| 2637 | }else |
---|
[6996] | 2638 | paginatorList(currentView, view, type); |
---|
[5341] | 2639 | } |
---|
| 2640 | |
---|
| 2641 | function mountCriteriaList(view, page_index, calerdars_selecteds){ |
---|
[6044] | 2642 | var rangeStart , rangeEnd; |
---|
| 2643 | switch (view){ |
---|
| 2644 | case 'basicDay': |
---|
| 2645 | case 'agendaDay': |
---|
[7702] | 2646 | rangeStart = new Date.today().add({ days: page_index }).getTime(); |
---|
[6996] | 2647 | rangeEnd = rangeStart + 86400000; |
---|
[6044] | 2648 | break; |
---|
| 2649 | case 'agendaWeek': |
---|
| 2650 | var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
[7835] | 2651 | var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
| 2652 | dateEnd.setHours(0,0,0); |
---|
| 2653 | dateStart.setHours(0,0,0); |
---|
[7702] | 2654 | rangeStart = dateStart.add({ days: (7 * page_index) }).getTime(); |
---|
| 2655 | rangeEnd = dateEnd.add({ days: (7 * page_index)+7 }).getTime(); |
---|
[6044] | 2656 | break; |
---|
| 2657 | case 'month': |
---|
[7702] | 2658 | var date = Date.today().add({ months: page_index }) |
---|
[6044] | 2659 | rangeStart = date.moveToFirstDayOfMonth().getTime(); |
---|
[7835] | 2660 | rangeEnd = date.moveToLastDayOfMonth().getTime() + 86400000; |
---|
[6044] | 2661 | break; |
---|
| 2662 | case 'year': |
---|
[7702] | 2663 | var dateStart = new Date().add({ years: page_index }); |
---|
| 2664 | var dateEnd = new Date().add({ years: page_index }); |
---|
[7835] | 2665 | dateEnd.setHours(0,0,0); |
---|
| 2666 | dateStart.setHours(0,0,0); |
---|
[6044] | 2667 | if(dateStart.getMonth() != 0) |
---|
[7702] | 2668 | dateStart.moveToMonth(0, -1) |
---|
[6044] | 2669 | if(dateEnd.getMonth() != 11) |
---|
[7702] | 2670 | dateEnd.moveToMonth(11) |
---|
| 2671 | |
---|
| 2672 | rangeStart = dateStart.moveToFirstDayOfMonth().getTime(); |
---|
[7835] | 2673 | rangeEnd = dateEnd.moveToLastDayOfMonth().getTime() + 86400000; |
---|
[6044] | 2674 | break; |
---|
| 2675 | } |
---|
[5641] | 2676 | |
---|
[6044] | 2677 | var timezone = {}; |
---|
| 2678 | for(var i in Calendar.signatureOf) |
---|
[7702] | 2679 | timezone[i] = Calendar.signatureOf[i].calendar.timezone; |
---|
[5641] | 2680 | |
---|
[7702] | 2681 | return { |
---|
| 2682 | rangeStart: rangeStart, |
---|
| 2683 | rangeEnd: rangeEnd, |
---|
[6044] | 2684 | order: 'startTime', |
---|
[7702] | 2685 | timezones: timezone, |
---|
| 2686 | calendar: calerdars_selecteds |
---|
| 2687 | }; |
---|
[5341] | 2688 | } |
---|
| 2689 | |
---|
[6996] | 2690 | function pageselectCallback(keyword, page_index, view, type){ |
---|
| 2691 | $('.qtip.qtip-blue').remove(); |
---|
| 2692 | var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; |
---|
| 2693 | var tab_title = ['Lista de eventos', 'Lista de tarefas']; |
---|
| 2694 | 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.']; |
---|
| 2695 | 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.']; |
---|
| 2696 | 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.']; |
---|
| 2697 | var selecteds = getSelectedCalendars(false, type); |
---|
| 2698 | |
---|
| 2699 | if(!selecteds && (keyword != '' && keyword != null)){ |
---|
[7702] | 2700 | jQuery('#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 2701 | '<div title="'+tab_title[type]+'" class="events-list events-list-win active empty">' + |
---|
| 2702 | '<label>'+label_noselect_calendar[type]+'</label>' + |
---|
| 2703 | '</div>' |
---|
| 2704 | ); |
---|
[6044] | 2705 | }else{ |
---|
[7702] | 2706 | var criteria = null; |
---|
| 2707 | if(keyword == '' || keyword == null){ |
---|
| 2708 | |
---|
| 2709 | criteria = mountCriteriaList(!!view ? view : User.preferences.defaultCalView, page_index, selecteds); |
---|
| 2710 | |
---|
| 2711 | }else{ |
---|
| 2712 | |
---|
| 2713 | var timezone = {}; |
---|
| 2714 | for(var i in Calendar.signatureOf) |
---|
| 2715 | timezone[i] = Calendar.signatureOf[i].calendar.timezone; |
---|
| 2716 | |
---|
| 2717 | criteria = { |
---|
| 2718 | |
---|
| 2719 | searchEvent: true, |
---|
| 2720 | order: 'startTime', |
---|
| 2721 | offset: (25 * page_index), |
---|
| 2722 | limit: (((25 * page_index) + 25) + 1), |
---|
| 2723 | summary: keyword, |
---|
| 2724 | description: keyword, |
---|
| 2725 | calendar: selecteds, |
---|
| 2726 | timezones: timezone |
---|
| 2727 | |
---|
| 2728 | }; |
---|
| 2729 | } |
---|
[7835] | 2730 | |
---|
[7702] | 2731 | var results = DataLayer.encode('schedulable:list', DataLayer.dispatch('modules/calendar/schedules', criteria)); |
---|
| 2732 | //var results = DataLayer.get('schedulable:detail', criteria); |
---|
| 2733 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
[6996] | 2734 | } |
---|
[6044] | 2735 | // não há resultados |
---|
[6444] | 2736 | |
---|
[6996] | 2737 | var currentView = '#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); |
---|
[6444] | 2738 | |
---|
[6044] | 2739 | if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) { |
---|
[6444] | 2740 | $(currentView).html( |
---|
[6996] | 2741 | '<div title="'+title+'" class="events-list events-list-win active empty">' + |
---|
| 2742 | '<label>'+label_nofound_search[type]+'</label>' + |
---|
[6444] | 2743 | '</div>' |
---|
[6044] | 2744 | ); |
---|
| 2745 | // há resultados e Agendas Selecionadas |
---|
| 2746 | } else{ |
---|
| 2747 | if(typeof(results) != 'undefined'){ |
---|
[6444] | 2748 | results['page_index'] = page_index; |
---|
| 2749 | results['keyword'] = keyword; |
---|
[6996] | 2750 | results['tab_title'] = tab_title[type]; |
---|
[6444] | 2751 | DataLayer.render( 'templates/event_list.ejs', results, function( html ){ |
---|
[5341] | 2752 | |
---|
[6444] | 2753 | $(currentView).html( html ); |
---|
| 2754 | $('.events-list-win .menu-container .button').button(); |
---|
| 2755 | |
---|
[6996] | 2756 | $(".event-details-item").parent().click(function(event){ |
---|
| 2757 | event.stopImmediatePropagation(); |
---|
[7702] | 2758 | var container = $(this).siblings("div.details-event-list"); |
---|
| 2759 | |
---|
| 2760 | |
---|
| 2761 | //lazy data |
---|
| 2762 | if( container.hasClass('hidden') ){ |
---|
| 2763 | |
---|
| 2764 | //only first click |
---|
| 2765 | if(!container.find('fieldset').length){ |
---|
| 2766 | |
---|
| 2767 | $(this).append( '<span style="width: 20px;" class="load-event-detail"><img style="width: 20px;" src="'+DataLayer.dispatchPath+'/modules/calendar/img/loading.gif"></img></span>'); |
---|
| 2768 | |
---|
| 2769 | var schedulable = container.find('input[name="eventid"]').val(); |
---|
| 2770 | schedulable = DataLayer.encode('schedulable:detail', [getSchedulable( schedulable, '' )]); |
---|
| 2771 | |
---|
| 2772 | schedulable = $.isArray( schedulable ) ? schedulable[0] : schedulable; |
---|
| 2773 | |
---|
| 2774 | container.prepend( DataLayer.render( 'templates/event_detail_list.ejs', {'_event': schedulable})); |
---|
| 2775 | |
---|
| 2776 | $(this).find('span.load-event-detail').remove(); |
---|
| 2777 | } |
---|
| 2778 | } |
---|
| 2779 | |
---|
| 2780 | container.toggleClass("hidden") |
---|
[6996] | 2781 | .find('.button.delete').click(function(event){ |
---|
[6444] | 2782 | var eventId = $(this).siblings('[name="eventid"]').val(); |
---|
| 2783 | var calendarId = $(this).siblings('[name="calendarid"]').val(); |
---|
[7017] | 2784 | remove_event(eventId, calendarId, 2); |
---|
[6996] | 2785 | event.stopImmediatePropagation() |
---|
[6444] | 2786 | }) |
---|
[7010] | 2787 | .end().find('.button.edit').click(function(event){ |
---|
[7702] | 2788 | |
---|
| 2789 | var schedulable = $(this).siblings('[name="eventid"]').val(); |
---|
[7010] | 2790 | switch($(this).siblings('[name="eventtype"]').val()){ |
---|
[7702] | 2791 | |
---|
[7010] | 2792 | case '1': |
---|
[7702] | 2793 | eventDetails( getSchedulable( schedulable, '' ), true ); |
---|
[7010] | 2794 | break; |
---|
| 2795 | case '2': |
---|
[7702] | 2796 | taskDetails( getSchedulable( schedulable, '' ), true ); |
---|
[7010] | 2797 | break; |
---|
| 2798 | case '3': |
---|
[7702] | 2799 | activityDetails( getSchedulable( schedulable, '' ), true ); |
---|
[7010] | 2800 | break; |
---|
| 2801 | } |
---|
[6996] | 2802 | event.stopImmediatePropagation() |
---|
| 2803 | }) |
---|
| 2804 | .end().find('.button.print').click(function(event){ |
---|
| 2805 | var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); |
---|
| 2806 | var html = $(this).parents("td:first").clone(); |
---|
| 2807 | html.find(".menu-container.footer-container").remove(); |
---|
[7022] | 2808 | html.find(".fc-header-title").remove(); |
---|
[6996] | 2809 | var html = html.html(); |
---|
| 2810 | var data = { |
---|
| 2811 | type : $(this).parents('.details-event-list').hasClass("details-event") ? "event-detail" : "task-detail", |
---|
[7022] | 2812 | html : html, |
---|
| 2813 | InfoPage : 'Detalhes: '+$(this).parents('tr.start-date').find('td span a').text() |
---|
[6996] | 2814 | } |
---|
| 2815 | window_print.document.open(); |
---|
| 2816 | window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); |
---|
| 2817 | window_print.document.close(); |
---|
| 2818 | window_print.print(); |
---|
| 2819 | |
---|
| 2820 | event.stopImmediatePropagation() |
---|
[6444] | 2821 | }); |
---|
| 2822 | |
---|
| 2823 | }); |
---|
[6996] | 2824 | paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView, type); |
---|
[6044] | 2825 | }); |
---|
| 2826 | }else{ |
---|
[6444] | 2827 | $(currentView).html( |
---|
[6996] | 2828 | '<div title="'+title+'" class="events-list events-list-win active empty">' + |
---|
[6444] | 2829 | '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ |
---|
| 2830 | '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ |
---|
[6996] | 2831 | '<label class="empty-result">'+label_nofound[type]+'</label>' + |
---|
[6444] | 2832 | '</div>' |
---|
| 2833 | ); |
---|
[6996] | 2834 | paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView, type); |
---|
[6044] | 2835 | } |
---|
| 2836 | } |
---|
[6996] | 2837 | if(currentView != '#'+tab_selector[type]) |
---|
[6476] | 2838 | $tabs.tabs("select", currentView); |
---|
[5341] | 2839 | } |
---|
| 2840 | |
---|
[6996] | 2841 | function show_modal_import_export(tab, calendarId, typeView){ |
---|
| 2842 | $('.qtip.qtip-blue').remove(); |
---|
[6044] | 2843 | DataLayer.render( 'templates/import_export.ejs', { |
---|
[6996] | 2844 | calendars: typeView == 0 ? Calendar.calendars : Calendar.groups, |
---|
| 2845 | owner: User.me.id, |
---|
| 2846 | typeView: typeView |
---|
[6044] | 2847 | }, function( html ){ |
---|
[5341] | 2848 | |
---|
[6044] | 2849 | if (!UI.dialogs.importCalendar) { |
---|
| 2850 | UI.dialogs.importCalendar = jQuery('#div-import-export-calendar') |
---|
[6996] | 2851 | .append('<div title="Importar e Exportar "' + (typeView == 0 ? 'Eventos' : 'Tarefas') + '" class="import-export import-export-win active"> <div>') |
---|
[6044] | 2852 | .find('.import-export-win.active').html(html).dialog({ |
---|
| 2853 | resizable: false, |
---|
| 2854 | modal:true, |
---|
| 2855 | width:500, |
---|
| 2856 | position: 'center' |
---|
| 2857 | }); |
---|
[5341] | 2858 | |
---|
[6044] | 2859 | } else { |
---|
| 2860 | UI.dialogs.importCalendar.html(html); |
---|
| 2861 | } |
---|
[5341] | 2862 | |
---|
[6044] | 2863 | var tabsImportExport = UI.dialogs.importCalendar.find(".tabs-import-export").tabs({ |
---|
| 2864 | selected: tab |
---|
| 2865 | }); |
---|
[5341] | 2866 | |
---|
[6044] | 2867 | UI.dialogs.importCalendar.find('.button').button(); |
---|
[5341] | 2868 | |
---|
[6044] | 2869 | tabsImportExport.find('option[value="'+calendarId+'"]').attr('selected','selected').trigger('change'); |
---|
[5381] | 2870 | |
---|
[6044] | 2871 | var form = false; |
---|
| 2872 | $('.import-event-form').fileupload({ |
---|
| 2873 | sequentialUploads: true, |
---|
| 2874 | add: function (e, data) { |
---|
[7661] | 2875 | form = data |
---|
| 2876 | var name = form.files[0].name; |
---|
| 2877 | $('.import-event-form').find('input[type="file"]').hide(); |
---|
| 2878 | $('.import-event-form').find('span.file-add').removeClass('hidden'); |
---|
| 2879 | $('.import-event-form').find('span.file-add').append('<span>'+ name +'</span><a class="button remove-attachment tiny"></a>'); |
---|
| 2880 | $('.import-event-form').find('.button.remove-attachment').button({ |
---|
| 2881 | icons: { |
---|
| 2882 | primary: "ui-icon-close" |
---|
| 2883 | }, |
---|
| 2884 | text: false |
---|
| 2885 | }).click(function (event){ |
---|
| 2886 | $('.import-event-form').find('input[type="file"]').show(); |
---|
| 2887 | $('.import-event-form').find('span.file-add').addClass('hidden').html(''); |
---|
| 2888 | form = false; |
---|
| 2889 | }); |
---|
| 2890 | |
---|
[6044] | 2891 | }, |
---|
[7661] | 2892 | submit:function(e, data){ |
---|
| 2893 | |
---|
| 2894 | $('div.import-export').find('a.button').button('option', 'disabled', true) |
---|
| 2895 | $('.import-event-form').find('span.file-add').append('<img src="../prototype/modules/calendar/img/ajax-loader.gif">'); |
---|
| 2896 | |
---|
| 2897 | }, |
---|
[6044] | 2898 | done: function(e, data){ |
---|
[7661] | 2899 | var msg = ''; |
---|
| 2900 | var type = ''; |
---|
[5901] | 2901 | |
---|
[7661] | 2902 | if(!!data.result && data.result == '[][""]' || data.result.indexOf('Error') >= 0 ){ |
---|
| 2903 | msg = 'Erro ao realizar a importação, por favor verifique o arquivo .ics'; |
---|
| 2904 | type = 'warning'; |
---|
[7394] | 2905 | |
---|
[7661] | 2906 | $('div.import-export').find('a.button').button('option', 'disabled', false) |
---|
| 2907 | $('.import-event-form').find('span.file-add img ').remove(); |
---|
[5901] | 2908 | |
---|
[7394] | 2909 | }else{ |
---|
| 2910 | |
---|
[7661] | 2911 | if(data.result.indexOf('schedulable') >= 0){ |
---|
[7394] | 2912 | msg = 'Importação realizada com sucesso!'; |
---|
| 2913 | type = 'confirmation'; |
---|
| 2914 | Calendar.rerenderView(true); |
---|
| 2915 | }else{ |
---|
[7661] | 2916 | var res = JSON.parse(data.result); |
---|
| 2917 | var asData = false; |
---|
| 2918 | |
---|
| 2919 | for(var i = 0; i < res.length; i++) |
---|
| 2920 | if(res[i].length > 0) |
---|
| 2921 | asData = true; |
---|
| 2922 | |
---|
| 2923 | if(asData){ |
---|
| 2924 | msg = 'Importação realizada com sucesso!'; |
---|
| 2925 | type = 'confirmation'; |
---|
| 2926 | Calendar.rerenderView(true); |
---|
| 2927 | }else{ |
---|
| 2928 | msg = 'Não foram encontrados novos eventos na importação!'; |
---|
| 2929 | type = 'information'; |
---|
| 2930 | } |
---|
[7394] | 2931 | } |
---|
[7661] | 2932 | |
---|
| 2933 | UI.dialogs.importCalendar.dialog("close"); |
---|
[7394] | 2934 | } |
---|
| 2935 | |
---|
[7661] | 2936 | $.Zebra_Dialog(msg, { |
---|
| 2937 | 'type': type, |
---|
| 2938 | 'overlay_opacity': '0.5', |
---|
| 2939 | 'buttons': ['Fechar'] |
---|
| 2940 | }); |
---|
[6044] | 2941 | } |
---|
| 2942 | }); |
---|
[5901] | 2943 | |
---|
[6044] | 2944 | UI.dialogs.importCalendar.find(".menu-import-event") |
---|
[7661] | 2945 | .children(".import").click(function(data){ |
---|
| 2946 | $('.import-event-form fieldset.import-calendar', UI.dialogs.importCalendar).append( |
---|
| 2947 | '<input type="hidden" name="params[calendar_timezone]" value="'+ |
---|
| 2948 | Calendar.signatureOf[$('.import-event-form option:selected').val()].calendar.timezone |
---|
| 2949 | +'"/>') |
---|
| 2950 | if(form) |
---|
| 2951 | form.submit(); |
---|
[6044] | 2952 | }); |
---|
[5341] | 2953 | |
---|
[6044] | 2954 | UI.dialogs.importCalendar.find(".menu-export-event") |
---|
| 2955 | .children(".export").click(function(){ |
---|
[5341] | 2956 | |
---|
[6044] | 2957 | $('.export-event-form', UI.dialogs.importCalendar).submit(); |
---|
| 2958 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 2959 | /** |
---|
[5341] | 2960 | * TODO - implementar ação de exportação |
---|
| 2961 | */ |
---|
[6044] | 2962 | }); |
---|
[5341] | 2963 | |
---|
[6044] | 2964 | UI.dialogs.importCalendar.find(".menu-container") |
---|
| 2965 | .children(".cancel").click(function(){ |
---|
| 2966 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 2967 | }); |
---|
[5341] | 2968 | |
---|
[6044] | 2969 | UI.dialogs.importCalendar.dialog("open"); |
---|
[5341] | 2970 | }); |
---|
[5592] | 2971 | } |
---|
| 2972 | |
---|
[7992] | 2973 | function copyAndMoveTo(calendar, event, idRecurrence, type, evt ){ |
---|
[5746] | 2974 | /* |
---|
| 2975 | * Types |
---|
| 2976 | * 0 = Move |
---|
| 2977 | * 1 = Copy Event end Repet |
---|
| 2978 | * 2 = Copy Ocurrence |
---|
| 2979 | * 3 = Copy to edit ocurrence |
---|
| 2980 | * |
---|
| 2981 | **/ |
---|
| 2982 | if(!type) |
---|
[6044] | 2983 | type = $('.calendar-copy-move input[name="typeEvent"]').val(); |
---|
[5592] | 2984 | |
---|
[7702] | 2985 | getSchedulable(event,''); |
---|
| 2986 | var schedulable = DataLayer.get('schedulable', event.toString()); |
---|
[7106] | 2987 | schedulable['class'] = '1'; |
---|
[6331] | 2988 | |
---|
[6044] | 2989 | calendar = !!calendar ? calendar : schedulable.calendar; |
---|
[7357] | 2990 | |
---|
| 2991 | owner = decodeOwnerCalendar(calendar); |
---|
[5746] | 2992 | |
---|
[6044] | 2993 | if(typeof(schedulable) == "array") |
---|
| 2994 | schedulable = schedulable[0]; |
---|
[5592] | 2995 | |
---|
[6044] | 2996 | //Move eventos entre agendas |
---|
| 2997 | if(parseInt(type) == 0){ |
---|
[5592] | 2998 | |
---|
[6331] | 2999 | schedulable.lastCalendar = schedulable.calendar; |
---|
[7702] | 3000 | schedulable.calendar = calendar; |
---|
[6044] | 3001 | DataLayer.put('schedulable', schedulable); |
---|
[5592] | 3002 | |
---|
[6044] | 3003 | DataLayer.commit(); |
---|
| 3004 | //copia eventos entre agendas |
---|
| 3005 | }else{ |
---|
[5592] | 3006 | |
---|
[6044] | 3007 | var newSchedulable = schedulable; |
---|
[5592] | 3008 | |
---|
[6044] | 3009 | delete newSchedulable.id; |
---|
| 3010 | delete newSchedulable.uid; |
---|
| 3011 | delete newSchedulable.sequence; |
---|
| 3012 | delete newSchedulable.dtstamp; |
---|
[5746] | 3013 | |
---|
[6044] | 3014 | delete schedulable.DayLigth; |
---|
| 3015 | delete schedulable.rangeStart |
---|
| 3016 | delete schedulable.rangeEnd; |
---|
| 3017 | delete schedulable.lastUpdate; |
---|
[5746] | 3018 | |
---|
[6044] | 3019 | delete schedulable.calendar; |
---|
[5746] | 3020 | |
---|
[6044] | 3021 | if(schedulable.repeat && type == "1" ){ |
---|
| 3022 | var repeat = DataLayer.get('repeat', schedulable.repeat); |
---|
| 3023 | delete repeat.schedulable; |
---|
| 3024 | delete repeat.id; |
---|
[7702] | 3025 | repeat.startTime = repeat.startTime == '' ? '' : new Date(parseInt(repeat.startTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
| 3026 | repeat.endTime = repeat.endTime == '' ? '' : new Date(parseInt(repeat.endTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5746] | 3027 | |
---|
[6044] | 3028 | var exceptions = DataLayer.get('repeatOccurrence', { |
---|
| 3029 | filter: ['AND', ['=','repeat', schedulable.repeat], ['=','exception','1']] |
---|
| 3030 | }, true); |
---|
| 3031 | if(exceptions){ |
---|
| 3032 | repeat.exceptions = ''; |
---|
| 3033 | for(var i in exceptions ) |
---|
| 3034 | repeat.exceptions += exceptions[i].occurrence + ((exceptions.length -1) == parseInt(i) ? '' : ','); |
---|
[5746] | 3035 | |
---|
[6044] | 3036 | } |
---|
[5746] | 3037 | |
---|
| 3038 | |
---|
[6044] | 3039 | schedulable.repeat = repeat; |
---|
| 3040 | }else{ |
---|
| 3041 | if(!!idRecurrence){ |
---|
| 3042 | newSchedulable.endTime = parseInt(schedulable.occurrences[idRecurrence]) + (parseInt(newSchedulable.endTime) - parseInt(newSchedulable.startTime)); |
---|
| 3043 | newSchedulable.startTime = schedulable.occurrences[idRecurrence]; |
---|
| 3044 | } |
---|
| 3045 | delete schedulable.repeat; |
---|
| 3046 | } |
---|
| 3047 | delete schedulable.occurrences; |
---|
[5746] | 3048 | |
---|
[7702] | 3049 | schedulable.calendar = DataLayer.copy(calendar); |
---|
[5592] | 3050 | |
---|
[6044] | 3051 | var participants = DataLayer.copy(schedulable.participants); |
---|
| 3052 | delete schedulable.participants; |
---|
[7357] | 3053 | |
---|
| 3054 | if(schedulable['type'] == '2') |
---|
| 3055 | delete schedulable['historic']; |
---|
| 3056 | |
---|
[7992] | 3057 | schedulable.participants = $.map( participants, function( attendee, i ){ |
---|
| 3058 | |
---|
| 3059 | var participant = DataLayer.get('participant', attendee, false); |
---|
| 3060 | |
---|
| 3061 | if(typeof(participant) == 'array') |
---|
| 3062 | participant = participant[0]; |
---|
| 3063 | |
---|
| 3064 | if(owner.id != participant.user) |
---|
| 3065 | delete participant.status; |
---|
| 3066 | |
---|
| 3067 | delete participant.delegatedFrom; |
---|
| 3068 | delete participant.id; |
---|
| 3069 | delete participant.schedulable; |
---|
| 3070 | |
---|
| 3071 | participant.id = DataLayer.put('participant', participant); |
---|
| 3072 | |
---|
[7994] | 3073 | return (parseInt(type) == 3) ? participant.id : participant ; |
---|
[7992] | 3074 | }); |
---|
| 3075 | |
---|
[6044] | 3076 | //Edit ocurrence |
---|
| 3077 | if(parseInt(type) == 3){ |
---|
| 3078 | newSchedulable.endTime = !!evt.end ? evt.end.getTime() : ((evt.start).getTime() + 86400000); |
---|
| 3079 | newSchedulable.startTime = evt.start.getTime(); |
---|
[5746] | 3080 | |
---|
[6044] | 3081 | return newSchedulable; |
---|
| 3082 | } |
---|
[7702] | 3083 | newSchedulable.endTime = new Date(parseInt(newSchedulable.endTime) - (parseInt(newSchedulable.allDay) ? 86400000 : 0)).toString('yyyy-MM-dd HH:mm:00'); |
---|
| 3084 | newSchedulable.startTime = new Date(parseInt(newSchedulable.startTime)).toString('yyyy-MM-dd HH:mm:00'); |
---|
[5592] | 3085 | |
---|
[6044] | 3086 | DataLayer.put('schedulable', newSchedulable); |
---|
[5636] | 3087 | |
---|
[6044] | 3088 | } |
---|
[6476] | 3089 | } |
---|
[5592] | 3090 | |
---|
[6476] | 3091 | function messageHelper(msg, isShow){ |
---|
| 3092 | if(isShow) |
---|
| 3093 | new $.Zebra_Dialog('<span style="width: 50px; height: 50px;">'+ |
---|
| 3094 | '<img src="'+DataLayer.dispatchPath+'/modules/calendar/img/loading.gif"></img>'+ |
---|
| 3095 | '</span><label class="messagesHelpers"> '+ msg +' </label>' , { |
---|
| 3096 | 'buttons': false, |
---|
| 3097 | 'modal': true, |
---|
| 3098 | 'overlay_opacity': '0.5', |
---|
| 3099 | 'keyboard': false, |
---|
| 3100 | 'overlay_close': false, |
---|
| 3101 | 'type': false, |
---|
| 3102 | 'custom_class': 'messagesHelpersExpressoCalendar' |
---|
| 3103 | } |
---|
| 3104 | ); |
---|
| 3105 | else{ |
---|
| 3106 | $('.messagesHelpersExpressoCalendar').remove(); |
---|
| 3107 | $('.ZebraDialogOverlay').remove(); |
---|
| 3108 | } |
---|
[6498] | 3109 | } |
---|
[6996] | 3110 | |
---|
| 3111 | function extendsFileupload(view, path){ |
---|
| 3112 | var viewName = 'div.new-'+view+'-win'; |
---|
| 3113 | |
---|
| 3114 | path = !!path ? path : ''; |
---|
| 3115 | |
---|
| 3116 | var maxSizeFile = 2000000; |
---|
| 3117 | $('#fileupload'+view).fileupload({ |
---|
| 3118 | sequentialUploads: true, |
---|
| 3119 | add: function (e, data) { |
---|
| 3120 | if(data.files[0].size < maxSizeFile) |
---|
| 3121 | data.submit(); |
---|
| 3122 | }, |
---|
| 3123 | change: function (e, data) { |
---|
| 3124 | $.each(data.files, function (index, file) { |
---|
| 3125 | var attach = {}; |
---|
| 3126 | attach.fileName = file.name; |
---|
| 3127 | var ext = file.name.split('.'); |
---|
| 3128 | if(file.name.length > 10) |
---|
| 3129 | attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; |
---|
| 3130 | attach.fileSize = formatBytes(file.size); |
---|
| 3131 | if(file.size > maxSizeFile) |
---|
| 3132 | attach.error = 'Tamanho de arquivo nao permitido!!' |
---|
| 3133 | |
---|
| 3134 | $(viewName+' .attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { |
---|
| 3135 | file : attach |
---|
| 3136 | })); |
---|
| 3137 | |
---|
| 3138 | if(file.size < maxSizeFile){ |
---|
| 3139 | $(viewName+' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); |
---|
| 3140 | $(viewName+' .attachments-list').find('[type=file]').addClass('hidden'); |
---|
| 3141 | |
---|
| 3142 | }else |
---|
| 3143 | $(viewName+' .fileinput-button.new').removeClass('new'); |
---|
| 3144 | |
---|
| 3145 | |
---|
| 3146 | $(viewName+' .attachments-list').find('.button.close').button({ |
---|
| 3147 | icons: { |
---|
| 3148 | primary: "ui-icon-close" |
---|
| 3149 | }, |
---|
| 3150 | text: false |
---|
| 3151 | }).click(function(){ |
---|
| 3152 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
| 3153 | $(viewName+' .attachment-list').find('input[value="'+idAttach+'"]').remove(); |
---|
| 3154 | $(this).parent().remove(); |
---|
| 3155 | |
---|
| 3156 | if(!$(viewName+' .attachment-list input').length) |
---|
| 3157 | $(viewName+' .btn-danger.delete').addClass('hidden'); |
---|
| 3158 | |
---|
| 3159 | }); |
---|
| 3160 | |
---|
| 3161 | }) |
---|
| 3162 | }, |
---|
| 3163 | done: function(e, data){ |
---|
| 3164 | var currentUpload = $(viewName+' .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); |
---|
| 3165 | |
---|
| 3166 | if(!!data.result && data.result != "[]"){ |
---|
| 3167 | $(viewName+' .btn-danger.delete').removeClass('hidden'); |
---|
| 3168 | var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); |
---|
| 3169 | $(viewName+' .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); |
---|
| 3170 | currentUpload.removeClass('on-complete').parents('p') |
---|
| 3171 | .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') |
---|
| 3172 | .find('.status-upload').addClass('ui-icon ui-icon-check'); |
---|
| 3173 | }else |
---|
| 3174 | currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); |
---|
| 3175 | } |
---|
| 3176 | }); |
---|
| 3177 | $('.attachments-list .button').button(); |
---|
| 3178 | |
---|
| 3179 | if(!!window.FormData) |
---|
| 3180 | $('#fileupload'+view).bind('fileuploadstart', function () { |
---|
| 3181 | var widget = $(this), |
---|
| 3182 | progressElement = $('#fileupload-progress-'+view).fadeIn(), |
---|
| 3183 | interval = 500, |
---|
| 3184 | total = 0, |
---|
| 3185 | loaded = 0, |
---|
| 3186 | loadedBefore = 0, |
---|
| 3187 | progressTimer, |
---|
| 3188 | progressHandler = function (e, data) { |
---|
| 3189 | loaded = data.loaded; |
---|
| 3190 | total = data.total; |
---|
| 3191 | }, |
---|
| 3192 | stopHandler = function () { |
---|
| 3193 | widget |
---|
| 3194 | .unbind('fileuploadprogressall', progressHandler) |
---|
| 3195 | .unbind('fileuploadstop', stopHandler); |
---|
| 3196 | window.clearInterval(progressTimer); |
---|
| 3197 | progressElement.fadeOut(function () { |
---|
| 3198 | progressElement.html(''); |
---|
| 3199 | }); |
---|
| 3200 | }, |
---|
| 3201 | formatTime = function (seconds) { |
---|
| 3202 | var date = new Date(seconds * 1000); |
---|
| 3203 | return ('0' + date.getUTCHours()).slice(-2) + ':' + |
---|
| 3204 | ('0' + date.getUTCMinutes()).slice(-2) + ':' + |
---|
| 3205 | ('0' + date.getUTCSeconds()).slice(-2); |
---|
| 3206 | }, |
---|
| 3207 | /* formatBytes = function (bytes) { |
---|
| 3208 | if (bytes >= 1000000000) { |
---|
| 3209 | return (bytes / 1000000000).toFixed(2) + ' GB'; |
---|
| 3210 | } |
---|
| 3211 | if (bytes >= 1000000) { |
---|
| 3212 | return (bytes / 1000000).toFixed(2) + ' MB'; |
---|
| 3213 | } |
---|
| 3214 | if (bytes >= 1000) { |
---|
| 3215 | return (bytes / 1000).toFixed(2) + ' KB'; |
---|
| 3216 | } |
---|
| 3217 | return bytes + ' B'; |
---|
| 3218 | },*/ |
---|
| 3219 | formatPercentage = function (floatValue) { |
---|
| 3220 | return (floatValue * 100).toFixed(2) + ' %'; |
---|
| 3221 | }, |
---|
| 3222 | updateProgressElement = function (loaded, total, bps) { |
---|
| 3223 | progressElement.html( |
---|
| 3224 | formatBytes(bps) + 'ps | ' + |
---|
| 3225 | formatTime((total - loaded) / bps) + ' | ' + |
---|
| 3226 | formatPercentage(loaded / total) + ' | ' + |
---|
| 3227 | formatBytes(loaded) + ' / ' + formatBytes(total) |
---|
| 3228 | ); |
---|
| 3229 | }, |
---|
| 3230 | intervalHandler = function () { |
---|
| 3231 | var diff = loaded - loadedBefore; |
---|
| 3232 | if (!diff) { |
---|
| 3233 | return; |
---|
| 3234 | } |
---|
| 3235 | loadedBefore = loaded; |
---|
| 3236 | updateProgressElement( |
---|
| 3237 | loaded, |
---|
| 3238 | total, |
---|
| 3239 | diff * (1000 / interval) |
---|
| 3240 | ); |
---|
| 3241 | }; |
---|
| 3242 | widget |
---|
| 3243 | .bind('fileuploadprogressall', progressHandler) |
---|
| 3244 | .bind('fileuploadstop', stopHandler); |
---|
| 3245 | progressTimer = window.setInterval(intervalHandler, interval); |
---|
| 3246 | }); |
---|
| 3247 | |
---|
[7835] | 3248 | } |
---|