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