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