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