[5515] | 1 | function formatBytes(bytes) { |
---|
| 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'; |
---|
| 12 | }; |
---|
| 13 | |
---|
[5341] | 14 | function validDateEvent(){ |
---|
| 15 | var start_date = $(".new-event-win.active .start-date").val(); |
---|
| 16 | var end_date = $(".new-event-win.active .end-date").val(); |
---|
| 17 | var start_time = $(".new-event-win.active .start-time").val(); |
---|
| 18 | var end_time = $(".new-event-win.active .end-time").val(); |
---|
[5409] | 19 | var isAllDay = $('.new-event-win.active input[name="allDay"]').is(':checked'); |
---|
[5341] | 20 | |
---|
| 21 | if(start_date == "") |
---|
| 22 | return 'Por favor, informe uma data inicial'; |
---|
| 23 | else if(end_date == "") |
---|
| 24 | return 'Por favor, informe uma data final'; |
---|
| 25 | else if(!isAllDay && start_time == "") |
---|
| 26 | return 'Por favor, informe uma hora inicial'; |
---|
| 27 | else if(!isAllDay && end_time == "") |
---|
| 28 | return 'Por favor, informe uma hora final'; |
---|
| 29 | |
---|
| 30 | var formatString = (isAllDay)? User.preferences.dateFormat+" HH:mm" : User.preferences.dateFormat + " " + User.preferences.hourFormat; |
---|
[5409] | 31 | |
---|
| 32 | var startDate = Date.parseExact( isAllDay ? start_date+ " 00:00": start_date + " " + $.trim(start_time) , formatString ); |
---|
| 33 | var endDate = Date.parseExact( isAllDay ? end_date+ " 00:00": end_date + " " + $.trim(end_time) , formatString ); |
---|
[5510] | 34 | |
---|
[5341] | 35 | if(startDate == null || startDate.getTime() < 0 ) |
---|
| 36 | return 'Data inicial inválida'; |
---|
| 37 | if(endDate == null || endDate.getTime() < 0) |
---|
| 38 | return 'Data final inválida'; |
---|
| 39 | |
---|
| 40 | if((endDate.compareTo(startDate) != 1) && !((endDate.compareTo(startDate) == 0) && (isAllDay))){ |
---|
[5409] | 41 | return (start_date == end_date) ? |
---|
| 42 | ((end_time == start_time) ? 'Hora inicial igual a final' : 'Hora final menor que a inicial') : |
---|
| 43 | 'Data final menor que a inicial'; |
---|
[5341] | 44 | } |
---|
| 45 | return false; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | /* |
---|
| 49 | function listEvents(){ |
---|
| 50 | var list = $('.fc-header-right').find('.fc-button.fc-button-agendaDay').clone(); |
---|
| 51 | $('.fc-header-right').find('.fc-button-year').toggleClass('fc-corner-right'); |
---|
| 52 | list.addClass('fc-corner-right'); |
---|
| 53 | list.addClass('fc-button-listagem'); |
---|
| 54 | list.removeClass('fc-button-agendaDay'); |
---|
| 55 | list.removeClass('fc-corner-left'); |
---|
| 56 | list.find('.fc-button-content').html('Listagem'); |
---|
| 57 | $('.fc-header-right').append(list); |
---|
| 58 | } |
---|
| 59 | */ |
---|
[5514] | 60 | |
---|
[5592] | 61 | function eventDetails( objEvent, decoded, path, isMail) |
---|
[5341] | 62 | { |
---|
[5636] | 63 | attendees = {}; |
---|
| 64 | |
---|
[5389] | 65 | if(path == undefined) |
---|
| 66 | path = ""; |
---|
| 67 | |
---|
[5341] | 68 | if( !decoded ) |
---|
| 69 | objEvent = DataLayer.decode( "schedulable:calendar", objEvent ); |
---|
| 70 | |
---|
[5592] | 71 | if(!isMail) |
---|
[5341] | 72 | objEvent = DataLayer.encode( "schedulable:preview", objEvent ); |
---|
| 73 | |
---|
| 74 | if(typeof(objEvent.id) == 'undefined'){ |
---|
[5409] | 75 | objEvent.alarms = Calendar.signatureOf[User.preferences.defaultCalendar || Calendar.calendarIds[0]].defaultAlarms || false; |
---|
[5341] | 76 | objEvent.useAlarmDefault = 1; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /** |
---|
| 80 | * canDiscardEventDialog deve ser true se não houver alterações no evento |
---|
| 81 | */ |
---|
| 82 | canDiscardEventDialog = true; |
---|
| 83 | /** |
---|
| 84 | * zebraDiscardEventDialog é uma flag indicando que uma janela de confirmação (Zebra_Dialog) |
---|
| 85 | * já está aberta na tela, uma vez que não é possivel acessar o evento ESC utilizado para fechá-la |
---|
| 86 | */ |
---|
| 87 | zebraDiscardEventDialog = false; |
---|
| 88 | |
---|
[5514] | 89 | /** |
---|
| 90 | ACLs do participant |
---|
| 91 | */ |
---|
| 92 | acl_names = { |
---|
| 93 | 'w': 'acl-white', |
---|
| 94 | 'i': 'acl-invite-guests', |
---|
| 95 | 'p': 'acl-participation-required' |
---|
| 96 | }; |
---|
[5636] | 97 | |
---|
[5514] | 98 | var callbackAttendee = function(){ |
---|
| 99 | //Cria qtip de permissões pelo click do checkbox |
---|
| 100 | var checked = false; |
---|
| 101 | blkAddAtendee.find("li.not-attendee").addClass('hidden'); |
---|
| 102 | |
---|
| 103 | blkAddAtendee.find("li .button").filter(".close.new").button({ |
---|
| 104 | icons: { |
---|
| 105 | primary: "ui-icon-close" |
---|
| 106 | }, |
---|
| 107 | text: false |
---|
| 108 | }).click(function () { |
---|
| 109 | DataLayer.remove('participant', $(this).parents('li').find('[type=checkbox]').val()); |
---|
[5530] | 110 | if($(this).parent().find('.button.delegate').hasClass('attendee-permissions-change-button')){ |
---|
| 111 | |
---|
| 112 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 113 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
| 114 | |
---|
| 115 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 116 | } |
---|
| 117 | |
---|
[5514] | 118 | $(this).parents('li').remove(); |
---|
[5530] | 119 | |
---|
[5514] | 120 | if(blkAddAtendee.find(".attendee-list li").length == 1) |
---|
| 121 | blkAddAtendee.find("li.not-attendee").removeClass('hidden'); |
---|
| 122 | }) |
---|
| 123 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 124 | .removeClass('new').end() |
---|
| 125 | |
---|
| 126 | .filter(".delegate.new").button({ |
---|
| 127 | icons: { |
---|
| 128 | primary: "ui-icon-transferthick-e-w" |
---|
| 129 | }, |
---|
| 130 | text: false |
---|
| 131 | }).click(function () { |
---|
| 132 | |
---|
| 133 | if($(this).hasClass('attendee-permissions-change-button')){ |
---|
| 134 | $(this).removeClass('attendee-permissions-change-button') |
---|
| 135 | .find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change').end(); |
---|
| 136 | |
---|
| 137 | $(this).parents('li').find('input[name="delegatedFrom[]"]').val(''); |
---|
| 138 | |
---|
| 139 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 140 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 144 | |
---|
| 145 | }else{ |
---|
| 146 | blkAddAtendee.find('.delegate').removeClass('attendee-permissions-change-button'); |
---|
| 147 | blkAddAtendee.find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change'); |
---|
| 148 | |
---|
| 149 | $(this).addClass('attendee-permissions-change-button') |
---|
| 150 | .find('.ui-icon-transferthick-e-w').addClass('attendee-permissions-change').end(); |
---|
| 151 | $(this).parents('li').find('input[name="delegatedFrom[]"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val()); |
---|
| 152 | |
---|
| 153 | blkAddAtendee.find('.request-update').removeClass('hidden'); |
---|
| 154 | if(blkAddAtendee.find('.status option.hidden').length == 1) |
---|
| 155 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
| 156 | |
---|
| 157 | blkAddAtendee.find('option[value=5]').attr('selected','selected').trigger('change'); |
---|
| 158 | } |
---|
| 159 | }) |
---|
| 160 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 161 | .removeClass('new').end() |
---|
| 162 | |
---|
| 163 | .filter(".edit.new").button({ |
---|
| 164 | icons: { |
---|
| 165 | primary: "ui-icon-key" |
---|
| 166 | }, |
---|
| 167 | text: false |
---|
| 168 | }).click(function() { |
---|
| 169 | |
---|
| 170 | if(!!!checked) |
---|
| 171 | $(this).parents('li').find('[type=checkbox]').attr('checked', (!$(this).parent().find('[type=checkbox]').is(':checked'))).end(); |
---|
| 172 | |
---|
| 173 | var aclsParticipant = $(this).parents('li').find('input[name="attendeeAcl[]"]').val(); |
---|
| 174 | checked = false; |
---|
| 175 | |
---|
| 176 | if( $('.qtip.qtip-blue.qtip-active').val() !== ''){ |
---|
| 177 | blkAddAtendee.find('dd.attendee-list').qtip({ |
---|
| 178 | show: {ready: true, solo: true, when: {event: 'click'}}, |
---|
| 179 | hide: false, |
---|
| 180 | content: { |
---|
| 181 | text: $('<div></div>').html( DataLayer.render( 'templates/attendee_permissions.ejs', {} ) ), |
---|
| 182 | title: { |
---|
| 183 | text:'Permissões', |
---|
| 184 | button: '<a class="button close" href="#">close</a>' |
---|
| 185 | } |
---|
| 186 | }, |
---|
| 187 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 230, max:230}}, |
---|
| 188 | position: { |
---|
| 189 | corner: { |
---|
| 190 | target: 'rightMiddle', |
---|
| 191 | tooltip: 'leftMiddle' |
---|
| 192 | }, |
---|
| 193 | adjust: {x:0, y:0} |
---|
| 194 | } |
---|
| 195 | }) |
---|
| 196 | .qtip("api").onShow = function(arg0) { |
---|
| 197 | $('.qtip-active .button.close').button({ |
---|
| 198 | icons: {primary: "ui-icon-close"}, |
---|
| 199 | text: false |
---|
| 200 | }) |
---|
| 201 | .click(function(){ |
---|
| 202 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 203 | }); |
---|
| 204 | |
---|
| 205 | $('.qtip-active .button.save').button().click(function(){ |
---|
| 206 | |
---|
| 207 | var acl = ''; |
---|
| 208 | $('.qtip-active').find('[type=checkbox]:checked').each(function(i, obj) { |
---|
| 209 | acl+= obj.value; |
---|
| 210 | }); |
---|
| 211 | |
---|
| 212 | blkAddAtendee.find('dd.attendee-list [type=checkbox]:checked').siblings('input[name="attendeeAcl[]"]').each(function(i, obj) { |
---|
| 213 | obj.value = 'r'+acl; |
---|
| 214 | }).parents('li').find('.button.edit').addClass('attendee-permissions-change-button') |
---|
| 215 | .find('.ui-icon-key').addClass('attendee-permissions-change'); |
---|
| 216 | |
---|
| 217 | blkAddAtendee.find('dd.attendee-list [type=checkbox]').attr('checked', false); |
---|
| 218 | |
---|
| 219 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 220 | |
---|
| 221 | }); |
---|
| 222 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 223 | blkAddAtendee.find('dd.attendee-list [type=checkbox]').attr('checked', false); |
---|
| 224 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 225 | }); |
---|
| 226 | |
---|
| 227 | if(aclsParticipant) |
---|
| 228 | for(var i = 1; i < aclsParticipant.length; i++){ |
---|
| 229 | $('.qtip-active').find('input[name="'+acl_names[aclsParticipant.charAt(i)]+'"]').attr('checked', true); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | $('.button').button(); |
---|
| 234 | |
---|
| 235 | }; |
---|
| 236 | }else{ |
---|
| 237 | if(!$('.new-event-win dd.attendee-list').find('[type=checkbox]:checked').length){ |
---|
| 238 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 239 | }else{ |
---|
| 240 | $('.qtip-active .button.save .ui-button-text').html('Aplicar a todos') |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | }; |
---|
| 244 | }) |
---|
| 245 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 246 | .removeClass('new').end() |
---|
| 247 | |
---|
| 248 | .filter(".open-delegate.new").click(function(){ |
---|
| 249 | if($(this).hasClass('ui-icon-triangle-1-e')){ |
---|
| 250 | $(this).removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); |
---|
| 251 | $(this).parents('li').find('.list-delegates').removeClass('hidden'); |
---|
| 252 | }else{ |
---|
| 253 | $(this).removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); |
---|
| 254 | $(this).parents('li').find('.list-delegates').addClass('hidden'); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | }).removeClass('new'); |
---|
| 258 | |
---|
| 259 | |
---|
| 260 | blkAddAtendee.find("li input[type=checkbox].new").click(function(){ |
---|
| 261 | if(!$('.new-event-win dd.attendee-list').find('[type=checkbox]:checked').length){ |
---|
| 262 | blkAddAtendee.find('dd.attendee-list').qtip('destroy'); |
---|
| 263 | }else{ |
---|
| 264 | checked = true; |
---|
| 265 | $(this).parents('li').find('.button.edit').click(); |
---|
| 266 | } |
---|
| 267 | }).removeClass('new'); |
---|
| 268 | |
---|
| 269 | UI.dialogs.addEvent.find('.attendees-list li').hover( |
---|
| 270 | function () { |
---|
| 271 | $(this).addClass("hover-attendee"); |
---|
| 272 | $(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 273 | .find('.attendee-options').addClass('hover-attendee'); |
---|
| 274 | }, |
---|
| 275 | function () { |
---|
| 276 | $(this).removeClass("hover-attendee"); |
---|
| 277 | $(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 278 | .find('.attendee-options').removeClass('hover-attendee');; |
---|
| 279 | } |
---|
| 280 | ); |
---|
| 281 | |
---|
| 282 | |
---|
| 283 | } |
---|
| 284 | |
---|
[5389] | 285 | var html = DataLayer.render( path+'templates/event_add.ejs', {event:objEvent}); |
---|
[5341] | 286 | |
---|
| 287 | if (!UI.dialogs.addEvent) { |
---|
| 288 | UI.dialogs.addEvent = jQuery('#sandbox').append('<div title="Criar Evento" class="new-event-win active"> <div>').find('.new-event-win.active').html(html).dialog({ |
---|
| 289 | resizable: false, |
---|
| 290 | modal:true, |
---|
| 291 | autoOpen: false, |
---|
| 292 | width:700, |
---|
| 293 | position: 'center', |
---|
| 294 | close: function(event, ui) { |
---|
| 295 | /** |
---|
| 296 | * Remove tooltip possivelmente existente |
---|
| 297 | */ |
---|
| 298 | if ($('dd.attendee-list li:last').data('qtip')) |
---|
| 299 | $('dd.attendee-list li:last').qtip('destroy'); |
---|
[5636] | 300 | |
---|
| 301 | attendees = {}; |
---|
[5341] | 302 | |
---|
| 303 | }, |
---|
| 304 | beforeClose: function(event, ui) { |
---|
| 305 | |
---|
| 306 | if (!canDiscardEventDialog && !zebraDiscardEventDialog) { |
---|
| 307 | zebraDiscardEventDialog = true; |
---|
| 308 | window.setTimeout(function() { |
---|
| 309 | $.Zebra_Dialog('Suas alterações no evento não foram salvas. Deseja descartar as alterações?', { |
---|
| 310 | 'type': 'question', |
---|
| 311 | 'overlay_opacity': '0.5', |
---|
| 312 | 'buttons': ['Descartar alterações', 'Continuar editando'], |
---|
| 313 | 'onClose': function(clicked) { |
---|
| 314 | if(clicked == 'Descartar alterações') { |
---|
| 315 | canDiscardEventDialog = true; |
---|
[5514] | 316 | /** |
---|
| 317 | *Remoção dos anexos do eventos caso seja cancelado a edição |
---|
| 318 | */ |
---|
| 319 | var ids = []; |
---|
| 320 | $.each($('.attachment-list input'), function (i, input) { ids.push(input.value); }); |
---|
| 321 | if(ids.length > 0) |
---|
| 322 | DataLayer.remove('attachment', {filter: ['IN', 'id', ids]}); |
---|
| 323 | |
---|
[5341] | 324 | UI.dialogs.addEvent.dialog('close'); |
---|
[5381] | 325 | }else{ |
---|
| 326 | zebraDiscardEventDialog = false; |
---|
[5341] | 327 | } |
---|
| 328 | |
---|
| 329 | /** |
---|
| 330 | * Uma vez aberta uma janela de confirmação (Zebra_Dialog), ao fechá-la |
---|
| 331 | * com ESC, para que o evento ESC não seja propagado para fechamento da |
---|
| 332 | * janela de edição de eventos, deve ser setada uma flag indicando que |
---|
| 333 | * já existe uma janela de confirmação aberta. |
---|
| 334 | */ |
---|
| 335 | if (!clicked) { |
---|
| 336 | window.setTimeout(function() { |
---|
| 337 | zebraDiscardEventDialog = false; |
---|
| 338 | }, 200); |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | }); |
---|
| 342 | |
---|
| 343 | }, 300); |
---|
| 344 | |
---|
| 345 | } |
---|
| 346 | return canDiscardEventDialog; |
---|
| 347 | } |
---|
| 348 | }); |
---|
| 349 | |
---|
| 350 | } else { |
---|
| 351 | UI.dialogs.addEvent.html(html); |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | var tabs = UI.dialogs.addEvent.children('.content').tabs(); |
---|
| 355 | var calendar = DataLayer.get('calendar', objEvent.calendar); |
---|
[5381] | 356 | |
---|
[5341] | 357 | if (calendar.timezone != objEvent.timezone){ |
---|
| 358 | UI.dialogs.addEvent.find('.calendar-addevent-details-txt-timezone').find('option[value="'+objEvent.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 359 | UI.dialogs.addEvent.find('.calendar_addevent_details_lnk_timezone').addClass('hidden'); |
---|
| 360 | $('.calendar-addevent-details-txt-timezone').removeClass('hidden'); |
---|
| 361 | |
---|
| 362 | } |
---|
| 363 | |
---|
| 364 | UI.dialogs.addEvent.find('.calendar_addevent_details_lnk_timezone').click(function(e){ |
---|
| 365 | $(this).addClass('hidden'); |
---|
| 366 | $('.calendar-addevent-details-txt-timezone').removeClass('hidden'); |
---|
| 367 | e.preventDefault(); |
---|
| 368 | }); |
---|
| 369 | |
---|
[5376] | 370 | UI.dialogs.addEvent.find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el){ |
---|
| 371 | var id; |
---|
| 372 | if( id = $(this).parent().find('input[name="alarmId[]"]').val()) |
---|
| 373 | DataLayer.remove('alarm', id); |
---|
[5409] | 374 | $(this).parent().remove().find('li').is(':empty'); |
---|
[5341] | 375 | }); |
---|
| 376 | |
---|
[5381] | 377 | /*Seleciona a agenda padrão para criação de um evento*/ |
---|
[5437] | 378 | UI.dialogs.addEvent.find('option[value="'+objEvent.calendar || User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); |
---|
[5381] | 379 | |
---|
[5341] | 380 | /*Adicionar alarms padrões, quando alterado a agenda do usuário*/ |
---|
| 381 | UI.dialogs.addEvent.find('select[name="calendar"]').change(function(){ |
---|
[5409] | 382 | if((typeof($('input[name = "idEvent"]').val()) == 'undefined') || (!!!$('input[name = "idEvent"]').val())) { |
---|
[5341] | 383 | $('input[name = "isDefaultAlarm[]"]').parent().remove(); |
---|
| 384 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').parent().removeClass('hidden'); |
---|
| 385 | var calendarSelected = Calendar.signatureOf[$(this).val()]; |
---|
| 386 | calendarSelected.useAlarmDefault = 1; |
---|
| 387 | if(calendarSelected.defaultAlarms != ""){ |
---|
[5389] | 388 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {alarm:calendarSelected}); |
---|
[5341] | 389 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
[5409] | 390 | $(this).parent().remove().find('li').is(':empty'); |
---|
[5341] | 391 | }); |
---|
| 392 | }else{ |
---|
| 393 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').parent().addClass('hidden'); |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | }); |
---|
| 397 | |
---|
| 398 | /*Checkbox adicionar alarms padrões*/ |
---|
| 399 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').click(function(){ |
---|
| 400 | if($(this).attr("checked")){ |
---|
[5354] | 401 | $('input[name="isDefaultAlarm[]"]').parent().remove(); |
---|
[5341] | 402 | var calendarSelected = Calendar.signatureOf[$('select[name="calendar"]').val()]; |
---|
| 403 | calendarSelected.useAlarmDefault = 1; |
---|
| 404 | if(calendarSelected.defaultAlarms != ""){ |
---|
[5389] | 405 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {alarm:calendarSelected}); |
---|
[5341] | 406 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
[5376] | 407 | var id; |
---|
| 408 | if( id = $(this).parent().find('input[name="alarmId[]"]').val()) |
---|
| 409 | DataLayer.remove('alarm', id); |
---|
[5409] | 410 | $(this).parent().remove().find('li').is(':empty') |
---|
[5341] | 411 | }); |
---|
| 412 | } |
---|
[5354] | 413 | } else { |
---|
| 414 | $('input[name="isDefaultAlarm[]"]').parent().remove(); |
---|
| 415 | } |
---|
[5341] | 416 | }); |
---|
| 417 | /* Checkbox allday */ |
---|
| 418 | UI.dialogs.addEvent.find('input[name="allDay"]').click(function(){ |
---|
[5409] | 419 | $(this).attr("checked") ? |
---|
| 420 | UI.dialogs.addEvent.find('.start-time, .end-time').addClass('hidden') : |
---|
[5341] | 421 | UI.dialogs.addEvent.find('.start-time, .end-time').removeClass('hidden'); |
---|
[5636] | 422 | updateMap(true); |
---|
[5341] | 423 | }); |
---|
| 424 | |
---|
| 425 | UI.dialogs.addEvent.find('.button').button(); |
---|
| 426 | UI.dialogs.addEvent.find('.button.add').button({ |
---|
| 427 | icons: { |
---|
| 428 | secondary: "ui-icon-plus" |
---|
| 429 | } |
---|
| 430 | }); |
---|
| 431 | |
---|
| 432 | // ==== validation events ==== |
---|
[5354] | 433 | UI.dialogs.addEvent.find(".input-group .h1").Watermark("Evento sem título"); |
---|
| 434 | if(User.preferences.hourFormat.length == 5) { |
---|
[5636] | 435 | UI.dialogs.addEvent.find(".end-time, .start-time").mask("99:99", { |
---|
| 436 | completed: function(){ |
---|
| 437 | updateMap(); |
---|
| 438 | } |
---|
| 439 | }); |
---|
[5354] | 440 | } else { |
---|
[5341] | 441 | $.mask.definitions['{']='[ap]'; |
---|
| 442 | $.mask.definitions['}']='[m]'; |
---|
[5354] | 443 | UI.dialogs.addEvent.find(".end-time, .start-time").mask("99:99 {}", { |
---|
| 444 | completed:function(){ |
---|
[5409] | 445 | $(this).val(date.Calendar.defaultToAmPm($(this).val())); |
---|
[5341] | 446 | $(this).timepicker("refresh"); |
---|
| 447 | $(this).val($(this).val().replace(/[\.]/gi, "")); |
---|
[5636] | 448 | updateMap(); |
---|
[5354] | 449 | } |
---|
| 450 | }); |
---|
[5341] | 451 | } |
---|
[5354] | 452 | UI.dialogs.addEvent.find(".number").numeric(); |
---|
[5409] | 453 | User.preferences.dateFormat.indexOf('-') > 0 ? |
---|
[5636] | 454 | UI.dialogs.addEvent.find(".date").mask("99-99-9999", { |
---|
| 455 | completed:function(){ |
---|
| 456 | updateMap(); |
---|
| 457 | } |
---|
| 458 | }) : |
---|
| 459 | UI.dialogs.addEvent.find(".date").mask("99/99/9999", { |
---|
| 460 | completed:function(){ |
---|
| 461 | updateMap(); |
---|
| 462 | } |
---|
| 463 | }); |
---|
[5341] | 464 | |
---|
| 465 | UI.dialogs.addEvent.find(".menu-addevent") |
---|
| 466 | .children(".delete").click(function(){ |
---|
| 467 | $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', { |
---|
| 468 | 'type': 'question', |
---|
| 469 | 'overlay_opacity': '0.5', |
---|
| 470 | 'buttons': ['Sim', 'Não'], |
---|
| 471 | 'onClose': function(clicked) { |
---|
| 472 | if(clicked == 'Sim'){ |
---|
| 473 | DataLayer.remove( "schedulable", UI.dialogs.addEvent.find(".id-event").val() ); |
---|
| 474 | UI.dialogs.addEvent.dialog("close"); |
---|
| 475 | } |
---|
| 476 | } |
---|
| 477 | }); |
---|
| 478 | }).end() |
---|
| 479 | |
---|
| 480 | .children(".cancel").click(function(){ |
---|
| 481 | DataLayer.rollback('participant'); |
---|
| 482 | UI.dialogs.addEvent.dialog("close"); |
---|
| 483 | }).end() |
---|
| 484 | |
---|
| 485 | .children(".save").click(function(){ |
---|
| 486 | /* Validação */ |
---|
[5354] | 487 | var msg = false; |
---|
| 488 | if(msg = validDateEvent()){ |
---|
| 489 | $(".new-event-win.active").find('.messages-validation').removeClass('hidden').find('.message label').html(msg); |
---|
| 490 | return false; |
---|
| 491 | } |
---|
[5341] | 492 | |
---|
| 493 | canDiscardEventDialog = true; |
---|
| 494 | |
---|
[5514] | 495 | UI.dialogs.addEvent.children().find('form.form-addevent').submit(); |
---|
[5341] | 496 | UI.dialogs.addEvent.dialog("close"); |
---|
| 497 | }).end() |
---|
| 498 | |
---|
| 499 | .children(".export").click(function(){ |
---|
[5514] | 500 | UI.dialogs.addEvent.children().find(".form-export").submit(); |
---|
[5341] | 501 | }); |
---|
| 502 | |
---|
[5636] | 503 | var dates = UI.dialogs.addEvent.find('input.date').datepicker({ |
---|
| 504 | dateFormat: 'dd/mm/yy', |
---|
| 505 | onSelect : function( selectedDate ){ |
---|
| 506 | updateMap(); |
---|
| 507 | } |
---|
| 508 | }); |
---|
| 509 | //if(path == ""){ |
---|
| 510 | UI.dialogs.addEvent.find('input.time').timepicker({ |
---|
| 511 | closeText: 'Ok', |
---|
| 512 | hourGrid: 4, |
---|
| 513 | minuteGrid: 10, |
---|
| 514 | ampm : ((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 515 | timeFormat: "hh:mm tt", |
---|
| 516 | onSelect: function (selectedDateTime){ |
---|
| 517 | if(!(User.preferences.hourFormat.length == 5)) |
---|
| 518 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 519 | updateMap(); |
---|
| 520 | }, |
---|
| 521 | onClose : function (selectedDateTime){ |
---|
| 522 | if(!(User.preferences.hourFormat.length == 5)) |
---|
| 523 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 524 | } |
---|
| 525 | }); |
---|
| 526 | //} |
---|
[5341] | 527 | |
---|
| 528 | UI.dialogs.addEvent.find('.button-add-alarms').click(function(){ |
---|
[5389] | 529 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {}); |
---|
[5341] | 530 | |
---|
| 531 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
[5409] | 532 | $(this).parent().remove().find('li').is(':empty') |
---|
[5341] | 533 | }); |
---|
| 534 | // valicacao de campos numericos |
---|
| 535 | $('.number').numeric(); |
---|
| 536 | }); |
---|
| 537 | |
---|
[5514] | 538 | |
---|
| 539 | UI.dialogs.addEvent.find('.button.suggestion-hours').button({ |
---|
| 540 | icons: { |
---|
| 541 | primary: "ui-icon-clock" |
---|
| 542 | }, |
---|
| 543 | text: 'Sugerir horário' |
---|
| 544 | }).click(function () { |
---|
| 545 | $(this).siblings('input').removeAttr('disabled') |
---|
| 546 | .end().parents().find('input[name="allDay"]').removeAttr('disabled'); |
---|
| 547 | }); |
---|
| 548 | |
---|
| 549 | if(objEvent.me.id == User.me.id){ |
---|
| 550 | objEvent.me.id = DataLayer.put('participant', {user: objEvent.me.id, mail: objEvent.me.mail }); |
---|
| 551 | objEvent.organizer.id = objEvent.me.id; |
---|
| 552 | } |
---|
| 553 | |
---|
| 554 | var attendeeHtml = DataLayer.render( path+'templates/attendee_add.ejs', {event:objEvent}); |
---|
[5341] | 555 | |
---|
| 556 | // load template of attendees |
---|
| 557 | var blkAddAtendee = UI.dialogs.addEvent.find('#calendar_addevent_details6').append(attendeeHtml); |
---|
[5514] | 558 | if(objEvent.attendee.length) |
---|
| 559 | callbackAttendee(); |
---|
| 560 | /** |
---|
| 561 | Opções de delegação do participante/organizer |
---|
| 562 | */ |
---|
| 563 | blkAddAtendee.find(".button.participant-delegate").button({ |
---|
| 564 | icons: { |
---|
| 565 | primary: "ui-icon-transferthick-e-w" |
---|
| 566 | }, |
---|
| 567 | text: false |
---|
| 568 | }).click(function () { |
---|
| 569 | if($(this).hasClass('attendee-permissions-change-button')){ |
---|
| 570 | if(!$(this).hasClass('disable')){ |
---|
| 571 | $(this).removeClass('attendee-permissions-change-button') |
---|
| 572 | .find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change').end(); |
---|
| 573 | blkAddAtendee.find('.block-add-attendee.search').addClass('hidden'); |
---|
| 574 | blkAddAtendee.find('.block-add-attendee.search dt').html('Adicionar outros contatos'); |
---|
| 575 | } |
---|
| 576 | }else{ |
---|
| 577 | $(this).addClass('attendee-permissions-change-button') |
---|
| 578 | .find('.ui-icon-transferthick-e-w').addClass('attendee-permissions-change').end(); |
---|
| 579 | blkAddAtendee.find('.block-add-attendee.search dt').html('Delegar participação para'); |
---|
| 580 | blkAddAtendee.find('.block-add-attendee.search').removeClass('hidden'); |
---|
| 581 | blkAddAtendee.find('.block-add-attendee.search input.search').focus(); |
---|
| 582 | } |
---|
| 583 | }) |
---|
| 584 | .addClass('tiny'); |
---|
[5341] | 585 | |
---|
| 586 | //show or hidden permissions attendees |
---|
| 587 | //blkAddAtendee.find('.block-attendee-list #attendees-users li').click(show_permissions_attendees); |
---|
| 588 | |
---|
[5354] | 589 | UI.dialogs.addEvent.find(".attendee-list-add .add-attendee-input input").Watermark("digite um email para convidar"); |
---|
[5341] | 590 | /* Trata a edição de um novo participante adicionado |
---|
| 591 | * |
---|
| 592 | */ |
---|
| 593 | var hasNewAttendee = false; |
---|
[5360] | 594 | blkAddAtendee.find('.attendee-list-add .add-attendee-input input').keydown(function(event) { |
---|
[5341] | 595 | |
---|
| 596 | if (event.keyCode == '13' && $(this).val() != '') { |
---|
| 597 | Encoder.EncodeType = "entity"; |
---|
| 598 | $(this).val(Encoder.htmlEncode($(this).val())); |
---|
| 599 | |
---|
[5353] | 600 | newAttendeeEmail = false; |
---|
[5354] | 601 | newAttendeeName = false; |
---|
| 602 | skipAddNewLine = false; |
---|
[5341] | 603 | |
---|
| 604 | var info = $(this).val(); |
---|
| 605 | |
---|
| 606 | /** |
---|
| 607 | * email válido? |
---|
| 608 | */ |
---|
| 609 | info.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/) ? |
---|
| 610 | newAttendeeEmail = info : newAttendeeName = info; |
---|
| 611 | |
---|
| 612 | /** |
---|
| 613 | * 1) busca no banco para saber se o usuário já existe |
---|
| 614 | * 1.1) se existe, atualiza as info na lista de participantes e nao abre o tooltip |
---|
| 615 | * 1.2) se não existe |
---|
| 616 | * a) salva como novo usuario externo no banco (apenas com email) |
---|
| 617 | * b) exibe tooltip pedindo o nome |
---|
| 618 | * c) se o usuário preenche tooltip e salva, atualiza com o nome o usuário recém criado |
---|
| 619 | * d) se o usuário cancela o tooltip, fica o usuário salvo apenas com email e sem nome |
---|
| 620 | */ |
---|
| 621 | |
---|
[5636] | 622 | var user = DataLayer.get('user', ["=", "mail", $(this).val()]); |
---|
| 623 | if(user[0].id) |
---|
| 624 | attendees[user[0].id].name = user[0].name; |
---|
[5353] | 625 | |
---|
[5354] | 626 | /** |
---|
| 627 | * guarda o último tooltip aberto referente à lista de participantes |
---|
| 628 | */ |
---|
| 629 | lastEditAttendeeToolTip = []; |
---|
| 630 | |
---|
| 631 | /** |
---|
| 632 | * Valida email e salva um participante externo |
---|
| 633 | */ |
---|
| 634 | var saveContact = function() { |
---|
| 635 | Encoder.EncodeType = "entity"; |
---|
| 636 | |
---|
| 637 | var currentTip = $('.qtip-active'); |
---|
| 638 | newAttendeeName = currentTip.find('input[name="name"]').val(); |
---|
| 639 | newAttendeeEmail = currentTip.find('input[name="mail"]').val(); |
---|
| 640 | |
---|
[5409] | 641 | if (!(!!newAttendeeEmail.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/))) { |
---|
[5381] | 642 | currentTip.find('.messages').removeClass('hidden').find('.message label').html('Email inválido.'); |
---|
[5354] | 643 | return false; |
---|
| 644 | } |
---|
| 645 | |
---|
[5364] | 646 | DataLayer.put('user', {id:userId, name:newAttendeeName, mail:newAttendeeEmail, isExternal:isExternal}); |
---|
[5354] | 647 | |
---|
[5360] | 648 | lastEditAttendeeToolTip.find('label') |
---|
[5354] | 649 | .filter('.name').html(Encoder.htmlEncode(newAttendeeName)).attr('title', Encoder.htmlEncode(newAttendeeName)).end() |
---|
| 650 | .filter('.mail').html(Encoder.htmlEncode(newAttendeeEmail)).attr('title', Encoder.htmlEncode(newAttendeeEmail)); |
---|
| 651 | |
---|
[5360] | 652 | blkAddAtendee.find('.attendee-list-add .add-attendee-input input').val(''); |
---|
[5354] | 653 | return true; |
---|
| 654 | } |
---|
| 655 | |
---|
| 656 | /** |
---|
| 657 | * Formata e adequa um tootip abert para edição de um participante na lista |
---|
| 658 | */ |
---|
[5353] | 659 | var onShowToolTip = function(arg0) { |
---|
| 660 | $('.qtip-active .button.close').button({ |
---|
| 661 | icons: {primary: "ui-icon-close"}, |
---|
| 662 | text: false |
---|
| 663 | }); |
---|
| 664 | $('.qtip-active .button').button() |
---|
| 665 | .filter('.save').click(function(event, ui) { |
---|
[5409] | 666 | if(saveContact()) |
---|
[5354] | 667 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5409] | 668 | else |
---|
[5353] | 669 | return false; |
---|
| 670 | }).end() |
---|
| 671 | .filter('.cancel').click(function(event, ui) { |
---|
[5354] | 672 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5353] | 673 | }) |
---|
| 674 | |
---|
| 675 | /** |
---|
| 676 | * Trata o ENTER no campo da tooltip, equivalente a salvar |
---|
| 677 | * o novo convidado. |
---|
| 678 | */ |
---|
| 679 | $('.qtip-active input').keydown(function(event) { |
---|
| 680 | if (event.keyCode == '13') { |
---|
[5409] | 681 | if (saveContact()) |
---|
[5354] | 682 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5409] | 683 | |
---|
[5354] | 684 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5353] | 685 | event.preventDefault(); |
---|
| 686 | } |
---|
| 687 | }) |
---|
| 688 | .filter('[name="name"]').Watermark("informe o nome do contato").end() |
---|
| 689 | .filter('[name="mail"]').Watermark("informe o email do contato"); |
---|
| 690 | } |
---|
| 691 | |
---|
[5354] | 692 | /** |
---|
| 693 | * Se o email digitado já foi adicionado na lista, |
---|
| 694 | * o usuário deve ser avisado e um botão de edição deve ser exibido |
---|
| 695 | */ |
---|
| 696 | if(blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').length) { |
---|
[5360] | 697 | hasNewAttendee = false; |
---|
[5354] | 698 | newAttendeeName = blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').parents('li').find('label.name').attr('title'); |
---|
| 699 | |
---|
| 700 | blkAddAtendee.find('.email-validation').removeClass('hidden') |
---|
[5353] | 701 | .find('.message label').html("O usuário acima já foi adicionado! <a class=\"small button\">Editar</a>") |
---|
| 702 | .find(".button").button().click(function () { |
---|
[5354] | 703 | /** |
---|
| 704 | * Se o usuário optar por editar o participante anteriormente adicionado, |
---|
| 705 | * uma tooltip deve ser aberta para este participante, viabilizando a edição |
---|
| 706 | */ |
---|
| 707 | blkAddAtendee.find("ul.attendee-list").scrollTo('label.mail[title="' + newAttendeeEmail + '"]'); |
---|
| 708 | /** |
---|
| 709 | * Remove tooltip possivelmente existente |
---|
| 710 | */ |
---|
[5360] | 711 | if (lastEditAttendeeToolTip.length && lastEditAttendeeToolTip.data('qtip')) |
---|
[5354] | 712 | lastEditAttendeeToolTip.qtip('destroy'); |
---|
| 713 | |
---|
| 714 | lastEditAttendeeToolTip = blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').parents('li'); |
---|
| 715 | lastEditAttendeeToolTip.qtip({ |
---|
[5353] | 716 | show: {ready: true, solo: true, when: {event: 'click'}}, |
---|
| 717 | hide: false, |
---|
| 718 | content: { |
---|
[5389] | 719 | text: $('<div></div>').html( DataLayer.render( path+'templates/attendee_quick_edit.ejs', {attendee:{name:newAttendeeName, mail:newAttendeeEmail}} ) ), |
---|
[5353] | 720 | title: { |
---|
| 721 | text:'Detalhes do participante', |
---|
| 722 | button: '<a class="button close" href="#">close</a>' |
---|
| 723 | } |
---|
| 724 | }, |
---|
| 725 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 230, max:230}}, |
---|
| 726 | position: { |
---|
| 727 | corner: { |
---|
| 728 | target: 'rightMiddle', |
---|
| 729 | tooltip: 'leftMiddle' |
---|
| 730 | }, |
---|
| 731 | adjust: {x:0, y:0} |
---|
| 732 | } |
---|
| 733 | }); |
---|
[5354] | 734 | lastEditAttendeeToolTip.qtip("api").onShow = onShowToolTip; |
---|
| 735 | }); |
---|
| 736 | skipAddNewLine = true; |
---|
[5360] | 737 | } else { |
---|
| 738 | hasNewAttendee = true; |
---|
| 739 | blkAddAtendee.find('.email-validation').addClass('hidden'); |
---|
[5353] | 740 | } |
---|
| 741 | |
---|
| 742 | |
---|
[5387] | 743 | var isExternal = (!!user && !(!!user.isExternal)) ? 0 : 1; |
---|
[5341] | 744 | |
---|
| 745 | /** |
---|
| 746 | * Remove tooltip possivelmente existente |
---|
| 747 | */ |
---|
[5360] | 748 | if (lastEditAttendeeToolTip.length && lastEditAttendeeToolTip.data('qtip')) |
---|
[5354] | 749 | lastEditAttendeeToolTip.qtip('destroy'); |
---|
[5341] | 750 | |
---|
[5364] | 751 | userId = ''; |
---|
[5341] | 752 | var newAttendeeId = ''; |
---|
| 753 | |
---|
| 754 | if (user){ |
---|
[5354] | 755 | if (!skipAddNewLine) { |
---|
[5592] | 756 | user[0].id = DataLayer.put('participant', {user: user[0].id, isExternal: isExternal, acl: 'r'}); |
---|
| 757 | user[0].acl = objEvent.acl |
---|
| 758 | |
---|
[5354] | 759 | blkAddAtendee.find('dd.attendee-list ul.attendee-list').append( |
---|
[5592] | 760 | DataLayer.render(path+'templates/participants_add_itemlist.ejs', user) |
---|
[5354] | 761 | ) |
---|
| 762 | .scrollTo('max'); |
---|
[5514] | 763 | callbackAttendee(); |
---|
[5354] | 764 | } |
---|
[5349] | 765 | |
---|
[5341] | 766 | $(this).val(''); |
---|
| 767 | |
---|
[5354] | 768 | } else if (!skipAddNewLine) { |
---|
[5341] | 769 | /** |
---|
| 770 | * a) salva como novo usuario externo no banco (apenas com email) e... |
---|
| 771 | * adiciona novo contato externo à lista de convidados |
---|
| 772 | */ |
---|
| 773 | |
---|
[5358] | 774 | userId = DataLayer.put('user', {name: newAttendeeName, mail: newAttendeeEmail, isExternal: isExternal}); |
---|
| 775 | newAttendeeId = DataLayer.put('participant', {user: userId, isExternal: isExternal}); |
---|
[5341] | 776 | |
---|
[5354] | 777 | |
---|
[5341] | 778 | blkAddAtendee.find('dd.attendee-list ul.attendee-list').append( |
---|
[5514] | 779 | DataLayer.render(path+'templates/participants_add_itemlist.ejs', [{id:newAttendeeId, name: newAttendeeName, mail: newAttendeeEmail, isExternal: 1, acl: objEvent.acl}]) |
---|
| 780 | ).scrollTo('max'); |
---|
| 781 | callbackAttendee(); |
---|
[5341] | 782 | |
---|
| 783 | /** |
---|
| 784 | * Adiciona tootip para atualização dos dados do contato externo |
---|
| 785 | * recém adicionado. |
---|
| 786 | */ |
---|
[5354] | 787 | lastEditAttendeeToolTip = blkAddAtendee.find('dd.attendee-list li:last'); |
---|
| 788 | lastEditAttendeeToolTip.qtip({ |
---|
[5341] | 789 | show: {ready: true, solo: true, when: {event: 'click'}}, |
---|
| 790 | hide: false, |
---|
| 791 | content: { |
---|
[5389] | 792 | text: $('<div></div>').html( DataLayer.render( path+'templates/attendee_quick_edit.ejs', {attendee:{name:newAttendeeName, mail:newAttendeeEmail}} ) ), |
---|
[5341] | 793 | title: { |
---|
| 794 | text:'Detalhes do participante', |
---|
| 795 | button: '<a class="button close" href="#">close</a>' |
---|
| 796 | } |
---|
| 797 | }, |
---|
| 798 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 230, max:230}}, |
---|
| 799 | position: { |
---|
| 800 | corner: { |
---|
| 801 | target: 'rightMiddle', |
---|
| 802 | tooltip: 'leftMiddle' |
---|
| 803 | }, |
---|
| 804 | adjust: {x:0, y:0} |
---|
| 805 | } |
---|
| 806 | }); |
---|
| 807 | |
---|
[5354] | 808 | lastEditAttendeeToolTip.qtip("api").onShow = onShowToolTip; |
---|
[5341] | 809 | |
---|
[5354] | 810 | $(this).val(''); |
---|
[5341] | 811 | |
---|
[5353] | 812 | |
---|
[5341] | 813 | } |
---|
[5354] | 814 | event.preventDefault(); |
---|
[5341] | 815 | } |
---|
[5354] | 816 | |
---|
[5341] | 817 | }); |
---|
| 818 | |
---|
| 819 | /** |
---|
| 820 | * Trata a busca de usuários para adição de participantes |
---|
| 821 | */ |
---|
[5592] | 822 | blkAddAtendee.find('.add-attendee-search .ui-icon-search').click(function(event) { |
---|
| 823 | blkAddAtendee.find('.add-attendee-search input').keydown(); |
---|
| 824 | }); |
---|
| 825 | |
---|
| 826 | |
---|
[5341] | 827 | blkAddAtendee.find('.add-attendee-search input').keydown(function(event) { |
---|
| 828 | |
---|
[5592] | 829 | if(event.keyCode == '13' || typeof(event.keyCode) == 'undefined') { |
---|
[5341] | 830 | var result = DataLayer.get('user', ["*", "name", $(this).val()], true); |
---|
| 831 | |
---|
| 832 | /** |
---|
| 833 | * TODO: trocar por template |
---|
| 834 | */ |
---|
[5360] | 835 | blkAddAtendee.find('ul.search-result-list').empty().css('overflow', 'hidden'); |
---|
[5341] | 836 | if (!result) { |
---|
[5360] | 837 | blkAddAtendee.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>'); |
---|
[5341] | 838 | } |
---|
| 839 | |
---|
[5363] | 840 | for(i=0; i<result.length; i++) |
---|
| 841 | result[i].enabled = (blkAddAtendee.find('dd.attendee-list ul.attendee-list label.mail[title="' + result[i].mail + '"]').length) ? false : true; |
---|
| 842 | |
---|
[5389] | 843 | blkAddAtendee.find('ul.search-result-list').append(DataLayer.render( path+'templates/participants_search_itemlist.ejs', result)); |
---|
[5341] | 844 | |
---|
[5360] | 845 | blkAddAtendee.find('ul.search-result-list li').click(function(event, ui){ |
---|
[5341] | 846 | if ($(event.target).is('input')) { |
---|
| 847 | old_item = $(event.target).parents('li'); |
---|
[5358] | 848 | newAttendeeId = DataLayer.put('participant', {user: old_item.find('.id').html(), isExternal: 0}); |
---|
[5636] | 849 | |
---|
| 850 | attendees[old_item.find('.id').html()] = old_item.find('.name').html(); |
---|
| 851 | |
---|
[5341] | 852 | blkAddAtendee.find('dd.attendee-list ul.attendee-list') |
---|
[5514] | 853 | .append(DataLayer.render(path+'templates/participants_add_itemlist.ejs', [{id: newAttendeeId, name: old_item.find('.name').html(), mail: old_item.find('.mail').html(), isExternal: 0, acl: objEvent.acl}])) |
---|
[5349] | 854 | .scrollTo('max'); |
---|
[5514] | 855 | /** |
---|
| 856 | * Delegação de participação de um participante com permissão apenas de leitura |
---|
| 857 | * |
---|
| 858 | */ |
---|
| 859 | if(!objEvent.acl.organization && !objEvent.acl.write && !objEvent.acl.inviteGuests && objEvent.acl.read ){ |
---|
| 860 | |
---|
| 861 | blkAddAtendee.find('.block-add-attendee.search').addClass('hidden'); |
---|
| 862 | blkAddAtendee.find('.block-add-attendee.search dt').html('Adicionar outros contatos'); |
---|
| 863 | |
---|
| 864 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
| 865 | blkAddAtendee.find('option[value=5]').attr('selected','selected').trigger('change'); |
---|
| 866 | blkAddAtendee.find('.request-update').removeClass('hidden'); |
---|
[5341] | 867 | |
---|
[5514] | 868 | 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()); |
---|
| 869 | |
---|
| 870 | blkAddAtendee.find('.me .participant-delegate').addClass('disable ui-button-disabled ui-state-disabled'); |
---|
| 871 | blkAddAtendee.find(".button.close").button({ |
---|
| 872 | icons: { |
---|
| 873 | primary: "ui-icon-close" |
---|
| 874 | }, |
---|
| 875 | text: false |
---|
| 876 | }).click(function () { |
---|
| 877 | |
---|
| 878 | $(this).parents('li').find('input[name="delegatedFrom[]"]').val(''); |
---|
| 879 | blkAddAtendee.find('.request-update').addClass('hidden'); |
---|
| 880 | blkAddAtendee.find('.status option').toggleClass('hidden'); |
---|
| 881 | blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 882 | blkAddAtendee.find('.me .participant-delegate').removeClass('disable ui-button-disabled ui-state-disabled attendee-permissions-change-button') |
---|
| 883 | .find('.ui-icon-person').removeClass('attendee-permissions-change').end(); |
---|
| 884 | |
---|
| 885 | DataLayer.remove('participant', $(this).parents('li').find('[type=checkbox]').val()); |
---|
| 886 | $(this).parents('li').remove(); |
---|
| 887 | }) |
---|
| 888 | .addClass('tiny'); |
---|
| 889 | }else{ |
---|
| 890 | callbackAttendee(); |
---|
| 891 | old_item.remove(); |
---|
| 892 | } |
---|
[5341] | 893 | } |
---|
| 894 | }); |
---|
| 895 | |
---|
| 896 | event.preventDefault(); |
---|
| 897 | } |
---|
| 898 | }); |
---|
| 899 | //$('.block-add-attendee .search-result-list').selectable(); |
---|
| 900 | |
---|
[5514] | 901 | UI.dialogs.addEvent.find('.row.fileupload-buttonbar .button').filter('.delete').button({ |
---|
| 902 | icons: { |
---|
| 903 | primary: "ui-icon-close" |
---|
| 904 | }, |
---|
| 905 | text: 'Excluir' |
---|
| 906 | }).click(function () { |
---|
| 907 | $('.row.fileupload-buttonbar .attachments-list p').remove(); |
---|
| 908 | |
---|
| 909 | var ids = []; |
---|
| 910 | $.each($('.attachment-list input'), function (i, input) { ids.push(input.value); }); |
---|
| 911 | if(ids.length > 0){ |
---|
| 912 | DataLayer.remove('attachment', {filter: ['IN', 'id', ids]}); |
---|
| 913 | $('.attachment-list input').remove(); |
---|
[5341] | 914 | } |
---|
[5514] | 915 | }).end() |
---|
| 916 | .filter('.close').button({ |
---|
| 917 | icons: { |
---|
| 918 | primary: "ui-icon-close" |
---|
| 919 | }, |
---|
| 920 | text: false |
---|
| 921 | }).click(function () { |
---|
| 922 | DataLayer.remove('attachment', $(this).parents('p').find('input[name="fileId[]"]').val()); |
---|
| 923 | $(this).parents('p').remove(); |
---|
| 924 | }).end() |
---|
| 925 | .filter('.downlaod-archive').button({ |
---|
| 926 | icons: { |
---|
| 927 | primary: "ui-icon-arrowthickstop-1-s" |
---|
| 928 | }, |
---|
| 929 | text: false |
---|
[5381] | 930 | }); |
---|
| 931 | |
---|
[5514] | 932 | $('#fileupload').fileupload({ |
---|
| 933 | sequentialUploads: true, |
---|
| 934 | add: function (e, data) { |
---|
[5592] | 935 | if(data.files[0].size < 2000000) |
---|
[5514] | 936 | data.submit(); |
---|
| 937 | }, |
---|
| 938 | change: function (e, data) { |
---|
| 939 | $.each(data.files, function (index, file) { |
---|
| 940 | var attach = {}; |
---|
| 941 | attach.fileName = file.name; |
---|
| 942 | if(file.name.length > 10) |
---|
| 943 | attach.fileName = file.name.substr(0, 6) + file.name.substr(file.name.length-4, file.name.length); |
---|
[5515] | 944 | attach.fileSize = formatBytes(file.size); |
---|
[5592] | 945 | if(file.size > 2000000) |
---|
[5514] | 946 | attach.error = 'Tamanho de arquivo nao permitido!!' |
---|
| 947 | |
---|
| 948 | $('.attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', {file : attach})); |
---|
| 949 | |
---|
[5592] | 950 | if(file.size < 2000000){ |
---|
[5514] | 951 | $('.fileinput-button.new').append(data.fileInput[0]).removeClass('new'); |
---|
| 952 | $('.attachments-list').find('[type=file]').addClass('hidden'); |
---|
| 953 | |
---|
| 954 | }else |
---|
| 955 | $('.fileinput-button.new').removeClass('new'); |
---|
| 956 | |
---|
| 957 | |
---|
| 958 | $('.attachments-list').find('.button.close').button({ |
---|
| 959 | icons: { |
---|
| 960 | primary: "ui-icon-close" |
---|
| 961 | }, |
---|
| 962 | text: false |
---|
| 963 | }).click(function(){ |
---|
| 964 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
| 965 | $('.attachment-list').find('input[value="'+idAttach+'"]') |
---|
| 966 | $(this).parent().remove(); |
---|
| 967 | }); |
---|
| 968 | |
---|
| 969 | })}, |
---|
| 970 | progress: function(e, data){ |
---|
| 971 | var value = parseInt(data.loaded / data.total * 100, 10); |
---|
| 972 | $('.progress.in-progress:first').removeClass('hidden') |
---|
| 973 | $('.progress.in-progress:first').progressbar({ |
---|
| 974 | value: value |
---|
| 975 | }); |
---|
| 976 | |
---|
| 977 | if(value == 100){ |
---|
| 978 | $('.progress.in-progress:first').removeClass('in-progress').addClass('on-complete').fadeOut('slow'); |
---|
| 979 | } |
---|
| 980 | |
---|
| 981 | }, |
---|
| 982 | done: function(e, data){ |
---|
| 983 | if(!!data.result && data.result != "[]"){ |
---|
| 984 | var newAttach = jQuery.parseJSON(data.result); |
---|
| 985 | $('.attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); |
---|
| 986 | $('.progress.on-complete:first').removeClass('on-complete').parents('p') |
---|
| 987 | .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') |
---|
| 988 | .find('.status-upload').addClass('ui-icon ui-icon-check'); |
---|
| 989 | }else |
---|
| 990 | $('.progress.on-complete:first').removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); |
---|
| 991 | } |
---|
| 992 | }); |
---|
[5515] | 993 | $('.attachments-list .button').button(); |
---|
| 994 | |
---|
[5514] | 995 | $('#fileupload').bind('fileuploadstart', function () { |
---|
| 996 | var widget = $(this), |
---|
| 997 | progressElement = $('#fileupload-progress').fadeIn(), |
---|
| 998 | interval = 500, |
---|
| 999 | total = 0, |
---|
| 1000 | loaded = 0, |
---|
| 1001 | loadedBefore = 0, |
---|
| 1002 | progressTimer, |
---|
| 1003 | progressHandler = function (e, data) { |
---|
| 1004 | loaded = data.loaded; |
---|
| 1005 | total = data.total; |
---|
| 1006 | }, |
---|
| 1007 | stopHandler = function () { |
---|
| 1008 | widget |
---|
| 1009 | .unbind('fileuploadprogressall', progressHandler) |
---|
| 1010 | .unbind('fileuploadstop', stopHandler); |
---|
| 1011 | window.clearInterval(progressTimer); |
---|
| 1012 | progressElement.fadeOut(function () { |
---|
| 1013 | progressElement.html(''); |
---|
| 1014 | }); |
---|
| 1015 | }, |
---|
| 1016 | formatTime = function (seconds) { |
---|
| 1017 | var date = new Date(seconds * 1000); |
---|
| 1018 | return ('0' + date.getUTCHours()).slice(-2) + ':' + |
---|
| 1019 | ('0' + date.getUTCMinutes()).slice(-2) + ':' + |
---|
| 1020 | ('0' + date.getUTCSeconds()).slice(-2); |
---|
| 1021 | }, |
---|
[5515] | 1022 | /* formatBytes = function (bytes) { |
---|
[5514] | 1023 | if (bytes >= 1000000000) { |
---|
| 1024 | return (bytes / 1000000000).toFixed(2) + ' GB'; |
---|
| 1025 | } |
---|
| 1026 | if (bytes >= 1000000) { |
---|
| 1027 | return (bytes / 1000000).toFixed(2) + ' MB'; |
---|
| 1028 | } |
---|
| 1029 | if (bytes >= 1000) { |
---|
| 1030 | return (bytes / 1000).toFixed(2) + ' KB'; |
---|
| 1031 | } |
---|
| 1032 | return bytes + ' B'; |
---|
[5515] | 1033 | },*/ |
---|
[5514] | 1034 | formatPercentage = function (floatValue) { |
---|
| 1035 | return (floatValue * 100).toFixed(2) + ' %'; |
---|
| 1036 | }, |
---|
| 1037 | updateProgressElement = function (loaded, total, bps) { |
---|
| 1038 | progressElement.html( |
---|
| 1039 | formatBytes(bps) + 'ps | ' + |
---|
| 1040 | formatTime((total - loaded) / bps) + ' | ' + |
---|
| 1041 | formatPercentage(loaded / total) + ' | ' + |
---|
| 1042 | formatBytes(loaded) + ' / ' + formatBytes(total) |
---|
| 1043 | ); |
---|
| 1044 | }, |
---|
| 1045 | intervalHandler = function () { |
---|
| 1046 | var diff = loaded - loadedBefore; |
---|
| 1047 | if (!diff) { |
---|
| 1048 | return; |
---|
| 1049 | } |
---|
| 1050 | loadedBefore = loaded; |
---|
| 1051 | updateProgressElement( |
---|
| 1052 | loaded, |
---|
| 1053 | total, |
---|
| 1054 | diff * (1000 / interval) |
---|
| 1055 | ); |
---|
| 1056 | }; |
---|
| 1057 | widget |
---|
| 1058 | .bind('fileuploadprogressall', progressHandler) |
---|
| 1059 | .bind('fileuploadstop', stopHandler); |
---|
| 1060 | progressTimer = window.setInterval(intervalHandler, interval); |
---|
| 1061 | }); |
---|
[5592] | 1062 | |
---|
| 1063 | if(objEvent.isShared){ |
---|
[5514] | 1064 | |
---|
[5592] | 1065 | var acls = Calendar.signatureOf[objEvent.calendar].permission.acl; |
---|
[5514] | 1066 | |
---|
[5592] | 1067 | if(!acls.write){ |
---|
| 1068 | UI.dialogs.addEvent.find(':input').attr('disabled', 'disabled'); |
---|
| 1069 | UI.dialogs.addEvent.find('.button').hide(); |
---|
| 1070 | } |
---|
| 1071 | |
---|
| 1072 | if(acls.remove) |
---|
| 1073 | UI.dialogs.addEvent.find('.button.remove').show(); |
---|
| 1074 | |
---|
| 1075 | UI.dialogs.addEvent.find('.button.cancel').show(); |
---|
| 1076 | |
---|
| 1077 | |
---|
| 1078 | } |
---|
[5636] | 1079 | |
---|
| 1080 | disponibily(objEvent, path, attendees); |
---|
| 1081 | |
---|
| 1082 | UI.dialogs.addEvent.find(':input').change(function(event){ |
---|
| 1083 | if (event.keyCode != '27' && event.keyCode != '13') |
---|
| 1084 | canDiscardEventDialog = false; |
---|
| 1085 | }).keydown(function(event){ |
---|
| 1086 | if (event.keyCode != '27' && event.keyCode != '13') |
---|
| 1087 | canDiscardEventDialog = false; |
---|
| 1088 | }); |
---|
| 1089 | |
---|
[5592] | 1090 | UI.dialogs.addEvent.dialog('open'); |
---|
[5636] | 1091 | //$('[href="#calendar_addevent_details7"]').trigger('click'); |
---|
| 1092 | //$('[href="#calendar_addevent_details2"]').trigger('click'); |
---|
[5341] | 1093 | } |
---|
| 1094 | |
---|
[5353] | 1095 | |
---|
| 1096 | |
---|
[5341] | 1097 | function add_tab_preferences() |
---|
| 1098 | { |
---|
| 1099 | if(!(document.getElementById('preference_tab'))) |
---|
| 1100 | { |
---|
| 1101 | var tab_title = "Preferencias"; |
---|
| 1102 | $tabs.tabs( "add", "#preference_tab", tab_title ); |
---|
| 1103 | |
---|
| 1104 | /* |
---|
| 1105 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 1106 | tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1107 | }); |
---|
| 1108 | */ |
---|
| 1109 | DataLayer.render( 'templates/preferences_calendar.ejs', {preferences:User.preferences, calendars: Calendar.calendars}, function( template ){ |
---|
| 1110 | var tabPrefCalendar = jQuery('#preference_tab').html( template ).find('.preferences-win'); |
---|
| 1111 | |
---|
| 1112 | tabPrefCalendar.find('option[value="'+User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); |
---|
| 1113 | |
---|
| 1114 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 1115 | tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1116 | }); |
---|
| 1117 | |
---|
| 1118 | tabPrefCalendar.find('.button').button() |
---|
| 1119 | .filter('.save').click(function(evt){ |
---|
| 1120 | tabPrefCalendar.find('form').submit(); |
---|
| 1121 | $('#calendar').fullCalendar('render'); |
---|
| 1122 | $('.block-vertical-toolbox .mini-calendar').datepicker( "refresh" ); |
---|
| 1123 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 1124 | }).end().filter('.cancel').click(function(evt){ |
---|
| 1125 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 1126 | }); |
---|
| 1127 | |
---|
| 1128 | tabPrefCalendar.find('.number').numeric(); |
---|
[5510] | 1129 | |
---|
| 1130 | tabPrefCalendar.find('input.time').timepicker({ |
---|
| 1131 | closeText: 'Ok', |
---|
| 1132 | hourGrid: 4, |
---|
| 1133 | minuteGrid: 10, |
---|
| 1134 | ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false), //((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 1135 | timeFormat: "hh:mm tt", |
---|
| 1136 | onSelect: function (selectedDateTime){ |
---|
| 1137 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1138 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1139 | } |
---|
| 1140 | }, |
---|
| 1141 | onClose : function (selectedDateTime){ |
---|
| 1142 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1143 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1144 | } |
---|
| 1145 | } |
---|
| 1146 | }); |
---|
| 1147 | |
---|
| 1148 | $.mask.definitions['{']='[ap]'; |
---|
| 1149 | $.mask.definitions['}']='[m]'; |
---|
| 1150 | tabPrefCalendar.find("input.time").mask( ((User.preferences.hourFormat.length > 5) ? "99:99 {}" : "99:99"), { |
---|
| 1151 | completed:function(){ |
---|
| 1152 | $(this).val(dateCalendar.defaultToAmPm($(this).val())); |
---|
| 1153 | $(this).timepicker("refresh"); |
---|
| 1154 | $(this).val($(this).val().replace(/[\.]/gi, "")); |
---|
| 1155 | } |
---|
| 1156 | }); |
---|
| 1157 | |
---|
| 1158 | tabPrefCalendar.find("select[name=hourFormat]").change( function() { // evento ao selecionar formato de hora |
---|
| 1159 | |
---|
| 1160 | tabPrefCalendar.find("input.time").timepicker("destroy"); |
---|
| 1161 | |
---|
| 1162 | tabPrefCalendar.find('input.time').timepicker({ |
---|
| 1163 | closeText: 'Ok', |
---|
| 1164 | hourGrid: 4, |
---|
| 1165 | minuteGrid: 10, |
---|
| 1166 | ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false), |
---|
| 1167 | timeFormat: "hh:mm tt", |
---|
| 1168 | onSelect: function (selectedDateTime){ |
---|
| 1169 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1170 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1171 | } |
---|
| 1172 | }, |
---|
| 1173 | onClose : function (selectedDateTime){ |
---|
| 1174 | if(!(User.preferences.hourFormat.length == 5)) { |
---|
| 1175 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 1176 | } |
---|
| 1177 | } |
---|
| 1178 | }); |
---|
| 1179 | |
---|
| 1180 | var defaultStartHour = tabPrefCalendar.find("input[name=defaultStartHour]").val().trim(); |
---|
| 1181 | var defaultEndHour = tabPrefCalendar.find("input[name=defaultEndHour]").val().trim(); |
---|
| 1182 | |
---|
| 1183 | tabPrefCalendar.find("input.time").mask( (($("select[name=hourFormat] option:selected").val().trim().length > 5) ? "99:99 {}" : "99:99") ); |
---|
| 1184 | |
---|
| 1185 | if (parseInt($("select[name=hourFormat] option:selected").val().length) > 5) { // am/pm |
---|
| 1186 | tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.defaultToAmPm(defaultStartHour)); |
---|
| 1187 | tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.defaultToAmPm(defaultEndHour)) |
---|
| 1188 | |
---|
| 1189 | } else { //24h |
---|
| 1190 | tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.AmPmTo24(defaultStartHour)); |
---|
| 1191 | tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.AmPmTo24(defaultEndHour)); |
---|
| 1192 | } |
---|
| 1193 | }); |
---|
| 1194 | |
---|
| 1195 | |
---|
| 1196 | |
---|
[5341] | 1197 | }); |
---|
| 1198 | } else { |
---|
| 1199 | $tabs.tabs("select", "#preference_tab"); |
---|
| 1200 | |
---|
| 1201 | return true; |
---|
| 1202 | } |
---|
| 1203 | } |
---|
| 1204 | |
---|
| 1205 | |
---|
| 1206 | function add_tab_configure_calendar(calendar) |
---|
| 1207 | { |
---|
| 1208 | var calendars = []; |
---|
| 1209 | var signatures = []; |
---|
| 1210 | var previewActiveCalendarConf = 0; |
---|
| 1211 | |
---|
| 1212 | for (var i=0; i<Calendar.signatures.length; i++) { |
---|
| 1213 | calendars[i] = Calendar.signatures[i].calendar; |
---|
| 1214 | signatures[i] = Calendar.signatures[i]; |
---|
| 1215 | signatures[i].numberDefaultAlarm = signatures[i].defaultAlarms != '' ? signatures[i].defaultAlarms.length: 0; |
---|
| 1216 | if (calendar && calendars[i].id == calendar) |
---|
| 1217 | previewActiveCalendarConf = i; |
---|
| 1218 | } |
---|
| 1219 | |
---|
| 1220 | if(!(document.getElementById('configure_tab'))) |
---|
| 1221 | { |
---|
| 1222 | $('.positionHelper').css('display', 'none'); |
---|
| 1223 | var tab_title = "Configurações de agendas"; |
---|
| 1224 | $tabs.tabs( "add", "#configure_tab", tab_title ); |
---|
| 1225 | |
---|
| 1226 | var dataColorPicker = { |
---|
| 1227 | colorsSuggestions: colors_suggestions() |
---|
| 1228 | }; |
---|
| 1229 | |
---|
| 1230 | |
---|
| 1231 | |
---|
| 1232 | var populateAccordionOnActive = function(event, ui) { |
---|
| 1233 | var nowActive = (typeof(event) == 'number') ? event : $(event.target).accordion( "option", "active" ); |
---|
| 1234 | dataColorPicker.colorsDefined = { |
---|
| 1235 | border: '#'+signatures[nowActive].borderColor, |
---|
| 1236 | font:'#'+signatures[nowActive].fontColor, |
---|
| 1237 | background:'#'+signatures[nowActive].backgroundColor |
---|
| 1238 | }; |
---|
| 1239 | if (!jQuery('.accordion-user-calendars .ui-accordion-content').eq(nowActive).has('form')) { |
---|
| 1240 | return true; |
---|
| 1241 | } |
---|
| 1242 | |
---|
| 1243 | DataLayer.render( 'templates/configure_calendars_itemlist.ejs', {user:User, calendar:calendars[nowActive], signature:signatures[nowActive]}, function( form_template ){ |
---|
| 1244 | var form_content = jQuery('.accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form'); |
---|
| 1245 | form_content.find('.preferences-alarms-list .button').button({text:false, icons:{primary:'ui-icon-close'}}); |
---|
| 1246 | form_content.find('.button').button(); |
---|
| 1247 | |
---|
| 1248 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 1249 | var valueTimeZone = calendars[nowActive].timezone; |
---|
| 1250 | form_content.find('select[name="timezone"]').html(timezones_options).find('option[value="'+valueTimeZone+'"]').attr('selected','selected').trigger('change'); |
---|
| 1251 | }); |
---|
| 1252 | |
---|
| 1253 | form_content.find('.button-add-alarms').click(function(){ |
---|
[5376] | 1254 | DataLayer.render( 'templates/alarms_add_itemlist.ejs', {}, function( template ){ |
---|
[5341] | 1255 | jQuery('.preferences-alarms-list').append(template) |
---|
| 1256 | .find('li:last label:eq(0)').remove().end() |
---|
| 1257 | .find('.number').numeric().end() |
---|
| 1258 | .find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
| 1259 | $(this).parent().remove(); |
---|
| 1260 | }); |
---|
| 1261 | }); |
---|
| 1262 | }); |
---|
| 1263 | |
---|
| 1264 | |
---|
| 1265 | /** |
---|
| 1266 | * Set color picker |
---|
| 1267 | */ |
---|
| 1268 | DataLayer.render( 'templates/calendar_colorpicker.ejs', dataColorPicker, function( template ){ |
---|
| 1269 | form_content.find('.calendar-colorpicker').html( template ); |
---|
| 1270 | |
---|
| 1271 | var f = $.farbtastic(form_content.find('.colorpicker'), colorpickerPreviewChange); |
---|
| 1272 | var selected; |
---|
| 1273 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
| 1274 | |
---|
| 1275 | var colorpickerPreviewChange = function(color) { |
---|
| 1276 | var pickedup = form_content.find('.colorwell-selected').val(color).css('background-color', color); |
---|
| 1277 | |
---|
| 1278 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
| 1279 | |
---|
| 1280 | if (pickedup.is('input[name="backgroundColor"]')) { |
---|
| 1281 | colorpicker.find('.fc-event-skin').css('background-color',color); |
---|
| 1282 | } else if (pickedup.is('input[name="fontColor"]')) { |
---|
| 1283 | colorpicker.find('.fc-event-skin').css('color',color); |
---|
| 1284 | } else if (pickedup.is('input[name="borderColor"]')) { |
---|
| 1285 | colorpicker.find('.fc-event-skin').css('border-color',color); |
---|
| 1286 | } |
---|
| 1287 | } |
---|
| 1288 | |
---|
| 1289 | form_content.find('.colorwell').each(function () { |
---|
| 1290 | f.linkTo(this); |
---|
| 1291 | |
---|
| 1292 | if ($(this).is('input[name="backgroundColor"]')) { |
---|
| 1293 | colorpicker.find('.fc-event-skin').css('background-color', $(this).val()); |
---|
| 1294 | } else if ($(this).is('input[name="fontColor"]')) { |
---|
| 1295 | colorpicker.find('.fc-event-skin').css('color', $(this).val()); |
---|
| 1296 | } else if ($(this).is('input[name="borderColor"]')) { |
---|
| 1297 | colorpicker.find('.fc-event-skin').css('border-color', $(this).val()); |
---|
| 1298 | } |
---|
| 1299 | }) |
---|
| 1300 | .focus(function() { |
---|
| 1301 | if (selected) { |
---|
| 1302 | $(selected).removeClass('colorwell-selected'); |
---|
| 1303 | } |
---|
| 1304 | |
---|
| 1305 | $(selected = this).addClass('colorwell-selected'); |
---|
| 1306 | f.linkTo(this, colorpickerPreviewChange); |
---|
| 1307 | f.linkTo(colorpickerPreviewChange); |
---|
| 1308 | |
---|
| 1309 | }); |
---|
| 1310 | |
---|
| 1311 | form_content.find('select.color-suggestions').change(function() { |
---|
| 1312 | var colors; |
---|
| 1313 | |
---|
| 1314 | if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) { |
---|
| 1315 | colorpicker |
---|
| 1316 | .find('input[name="fontColor"]').val(colors.font).focus().end() |
---|
| 1317 | .find('input[name="backgroundColor"]').val(colors.background).focus().end() |
---|
| 1318 | .find('input[name="borderColor"]').val(colors.border).focus().end() |
---|
| 1319 | |
---|
| 1320 | .find('.fc-event-skin').css({ |
---|
| 1321 | 'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background, |
---|
| 1322 | 'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border, |
---|
| 1323 | 'color':dataColorPicker.colorsSuggestions[$(this).val()].font |
---|
| 1324 | }); |
---|
| 1325 | } |
---|
| 1326 | }); |
---|
| 1327 | |
---|
| 1328 | /** |
---|
| 1329 | * Trata a mudança dos valores dos campos de cores. |
---|
| 1330 | * Se mudar um conjunto de cores sugerido, |
---|
| 1331 | * este vira um conjunto de cores personalizado. |
---|
| 1332 | */ |
---|
| 1333 | form_content.find('.colorwell').change(function (element, ui) { |
---|
| 1334 | if (true) { |
---|
| 1335 | form_content.find('select.color-suggestions') |
---|
| 1336 | .find('option:selected').removeAttr('selected').end() |
---|
| 1337 | .find('option[value="custom"]').attr('selected', 'selected').trigger('change'); |
---|
| 1338 | } |
---|
| 1339 | }); |
---|
| 1340 | }); //END set colorpicker |
---|
| 1341 | |
---|
| 1342 | form_content.find('.phone').mask("+99 (99) 9999-9999"); |
---|
| 1343 | form_content.find('.number').numeric(); |
---|
| 1344 | |
---|
| 1345 | }); //END DataLayer.render( 'templates/configure_calendars_itemlist.ejs' ... |
---|
| 1346 | |
---|
| 1347 | // === validations preferences ==== |
---|
| 1348 | |
---|
| 1349 | |
---|
| 1350 | } //END populateAccordionOnActive(event, ui) |
---|
| 1351 | |
---|
| 1352 | |
---|
| 1353 | DataLayer.render( 'templates/configure_calendars.ejs', {user:User, calendars:calendars, signatures:signatures}, function( template ){ |
---|
| 1354 | var template_content = jQuery('#configure_tab').html( template ).find('.configure-calendars-win'); |
---|
| 1355 | template_content.find('.button').button().filter('.save').click(function(evt){ |
---|
| 1356 | template_content.find('form').submit(); |
---|
| 1357 | $tabs.tabs( "remove", "#configure_tab"); |
---|
[5615] | 1358 | DataLayer.commit( false, false, function( received ){ |
---|
| 1359 | delete Calendar.currentViewKey; |
---|
| 1360 | Calendar.load(); |
---|
| 1361 | refresh_calendars(); |
---|
| 1362 | }); |
---|
[5341] | 1363 | }).end().filter('.cancel').click(function(evt){ |
---|
| 1364 | $tabs.tabs( "remove", "#configure_tab"); |
---|
| 1365 | }); |
---|
| 1366 | |
---|
| 1367 | /** |
---|
| 1368 | * Muda a estrutura do template para a aplicação do plugin accordion |
---|
| 1369 | */ |
---|
| 1370 | template_content.find('.header-menu-container').after('<div class="accordion-user-calendars"></div>').end().find('.accordion-user-calendars') |
---|
| 1371 | .append(template_content.children('fieldset')); |
---|
| 1372 | |
---|
| 1373 | template_content.find('.accordion-user-calendars').children('fieldset').each(function(index) { |
---|
| 1374 | $(this).before($('<h3></h3>').html($(this).children('legend'))); |
---|
| 1375 | }); |
---|
| 1376 | |
---|
| 1377 | template_content.find('.accordion-user-calendars').accordion({ |
---|
| 1378 | autoHeight: false, |
---|
| 1379 | collapsible: true, |
---|
| 1380 | clearStyle: true, |
---|
| 1381 | active: previewActiveCalendarConf, |
---|
| 1382 | changestart: populateAccordionOnActive |
---|
| 1383 | }); |
---|
| 1384 | populateAccordionOnActive(previewActiveCalendarConf); |
---|
| 1385 | }); |
---|
| 1386 | |
---|
| 1387 | } else { |
---|
| 1388 | |
---|
| 1389 | $tabs.tabs("select", "#configure_tab"); |
---|
| 1390 | $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); |
---|
| 1391 | |
---|
| 1392 | return true; |
---|
| 1393 | } |
---|
| 1394 | |
---|
| 1395 | } |
---|
| 1396 | |
---|
[5409] | 1397 | function getSelectedCalendars( reverse ){ |
---|
[5341] | 1398 | var selecteds = {}; |
---|
| 1399 | var cont = 0; |
---|
| 1400 | jQuery(function() { |
---|
| 1401 | jQuery(".my-calendars .calendar-view").each(function(i, obj) { |
---|
| 1402 | var check_box = obj; |
---|
[5409] | 1403 | if( reverse ? !check_box.checked : check_box.checked ) { |
---|
[5341] | 1404 | selecteds[cont] = obj.value; |
---|
| 1405 | cont++; |
---|
| 1406 | }; |
---|
| 1407 | }); |
---|
| 1408 | }); |
---|
| 1409 | if (!cont) |
---|
| 1410 | return false; |
---|
| 1411 | |
---|
| 1412 | selecteds.length = cont; |
---|
| 1413 | return $.makeArray( selecteds ); |
---|
| 1414 | } |
---|
| 1415 | |
---|
| 1416 | /** |
---|
| 1417 | * TODO - transformar em preferência do módulo e criar telas de adição e exclusão de conjunto de cores |
---|
| 1418 | */ |
---|
| 1419 | function colors_suggestions(){ |
---|
| 1420 | return [ |
---|
| 1421 | {name:'Padrão', border:'#3366cc', font:'#ffffff', background:'#3366cc'}, |
---|
| 1422 | {name:'Coala', border:'#123456', font:'#ffffff', background:'#385c80'}, |
---|
| 1423 | {name:'Tomate', border:'#d5130b', font:'#111111', background:'#e36d76'}, |
---|
| 1424 | {name:'Limão', border:'#32ed21', font:'#1f3f1c', background:'#b2f1ac'}, |
---|
| 1425 | {name:'Alto contraste', border:'#000000', font:'#ffffff', background:'#222222'} |
---|
| 1426 | ] |
---|
| 1427 | } |
---|
| 1428 | |
---|
[5592] | 1429 | function remove_event(eventId){ |
---|
| 1430 | $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', { |
---|
| 1431 | 'type': 'question', |
---|
| 1432 | 'overlay_opacity': '0.5', |
---|
| 1433 | 'buttons': ['Sim', 'Não'], |
---|
| 1434 | 'onClose': function(clicked) { |
---|
| 1435 | if(clicked == 'Sim'){ |
---|
| 1436 | DataLayer.remove('schedulable', ''+eventId); |
---|
| 1437 | window.setTimeout(function() {DataLayer.commit();}, 500); |
---|
| 1438 | } |
---|
| 1439 | } |
---|
| 1440 | }); |
---|
| 1441 | } |
---|
| 1442 | |
---|
| 1443 | |
---|
[5341] | 1444 | function remove_calendar(){ |
---|
| 1445 | /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ |
---|
[5381] | 1446 | $.Zebra_Dialog('Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?', { |
---|
[5341] | 1447 | 'type': 'question', |
---|
| 1448 | 'overlay_opacity': '0.5', |
---|
| 1449 | 'buttons': ['Sim', 'Não'], |
---|
| 1450 | 'onClose': function(clicked) { |
---|
| 1451 | if(clicked == 'Sim'){ |
---|
| 1452 | var idCalendar = $('.cal-list-options-btn.ui-state-active').attr('class').match(/[0-9]+/g); |
---|
[5592] | 1453 | |
---|
| 1454 | DataLayer.remove('calendarSignature', Calendar.signatureOf[idCalendar[0]].id ); |
---|
| 1455 | |
---|
[5384] | 1456 | if(idCalendar == User.preferences.defaultCalendar) |
---|
| 1457 | DataLayer.remove( 'modulePreference', User.preferenceIds['defaultCalendar']); |
---|
[5636] | 1458 | |
---|
[5615] | 1459 | DataLayer.commit( false, false, function( received ){ |
---|
| 1460 | delete Calendar.currentViewKey; |
---|
| 1461 | Calendar.load(); |
---|
| 1462 | refresh_calendars(); |
---|
| 1463 | }); |
---|
[5409] | 1464 | } |
---|
[5341] | 1465 | $('.positionHelper').css('display', 'none'); |
---|
[5409] | 1466 | |
---|
[5341] | 1467 | } |
---|
| 1468 | }); |
---|
| 1469 | } |
---|
| 1470 | |
---|
| 1471 | function refresh_calendars(){ |
---|
| 1472 | |
---|
| 1473 | var colorsSuggestions = colors_suggestions(); |
---|
| 1474 | var buttons_colors = ""; |
---|
| 1475 | for(var i = 0; i < colorsSuggestions.length; i++){ |
---|
| 1476 | 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>"; |
---|
| 1477 | } |
---|
| 1478 | |
---|
| 1479 | //DataLayer.render( 'templates/calendar_list.ejs', 'calendar:list', ["IN", "id", Calendar.calendarIds], function( html ){ |
---|
| 1480 | DataLayer.render( 'templates/calendar_list.ejs', Calendar, function( html ){ |
---|
| 1481 | |
---|
| 1482 | var meu_container = $(".calendars-list").html( html ); |
---|
| 1483 | |
---|
| 1484 | $('ul.list-calendars .cal-list-options-btn').each(function(){ |
---|
| 1485 | $(this).menu({ |
---|
| 1486 | content: $(this).next().html(), |
---|
| 1487 | width: '120', |
---|
| 1488 | positionOpts: { |
---|
| 1489 | posX: 'left', |
---|
| 1490 | posY: 'bottom', |
---|
| 1491 | offsetX: 0, |
---|
| 1492 | offsetY: 0, |
---|
| 1493 | directionH: 'right', |
---|
| 1494 | directionV: 'down', |
---|
| 1495 | detectH: true, // do horizontal collision detection |
---|
| 1496 | detectV: true, // do vertical collision detection |
---|
| 1497 | linkToFront: false |
---|
| 1498 | }, |
---|
| 1499 | flyOut: true, |
---|
| 1500 | showSpeed: 100, |
---|
| 1501 | crumbDefaultText: '>' |
---|
| 1502 | }); |
---|
| 1503 | }); |
---|
| 1504 | |
---|
[5592] | 1505 | meu_container.find(".button.new-calendar").button({ |
---|
[5341] | 1506 | icons: { |
---|
| 1507 | primary: "ui-icon-plus" |
---|
| 1508 | }, |
---|
| 1509 | text: false |
---|
| 1510 | }).click(function () { |
---|
| 1511 | |
---|
| 1512 | if( $('.qtip.qtip-blue.qtip-active').val() !== ''){ |
---|
| 1513 | $(this).qtip({ |
---|
| 1514 | show: {ready: true, solo: true, when: {event: 'click'}}, |
---|
| 1515 | hide: false, |
---|
| 1516 | content: { |
---|
| 1517 | text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), |
---|
| 1518 | title: { |
---|
| 1519 | text:'Nova Agenda', |
---|
| 1520 | button: '<a class="button close" href="#">close</a>' |
---|
| 1521 | } |
---|
| 1522 | }, |
---|
| 1523 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 230, max:230}}, |
---|
| 1524 | position: { |
---|
| 1525 | corner: { |
---|
| 1526 | target: 'rightMiddle', |
---|
| 1527 | tooltip: 'leftMiddle' |
---|
| 1528 | }, |
---|
| 1529 | adjust: {x:0, y:-12} |
---|
| 1530 | } |
---|
| 1531 | }) |
---|
| 1532 | .qtip("api").onShow = function(arg0) { |
---|
| 1533 | $('.qtip-active .button.close').button({ |
---|
| 1534 | icons: {primary: "ui-icon-close"}, |
---|
| 1535 | text: false |
---|
| 1536 | }) |
---|
| 1537 | .click(function(){ |
---|
[5592] | 1538 | meu_container.find(".button.new-calendar").qtip('destroy'); |
---|
[5341] | 1539 | }); |
---|
| 1540 | //TODO emplementar tratamento de duplicação de valores no location |
---|
| 1541 | $('.qtip-active .button.save').button().click(function(){ |
---|
| 1542 | for(var i = 0; i < Calendar.calendars.length; i++){ |
---|
| 1543 | if(Calendar.calendars[i].location == $('.qtip-active input').val()){ |
---|
| 1544 | $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ |
---|
| 1545 | 'overlay_opacity': '0.5', |
---|
| 1546 | 'type': 'warning' |
---|
| 1547 | }); |
---|
| 1548 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1549 | return; |
---|
| 1550 | } |
---|
| 1551 | } |
---|
| 1552 | |
---|
| 1553 | var selected; |
---|
| 1554 | var color = $('.cal-colors-options-btn').each(function(index){ |
---|
| 1555 | if ($(this).is('.color-selected')) |
---|
| 1556 | selected = index; |
---|
| 1557 | }); |
---|
| 1558 | DataLayer.put( "calendarSignature", { |
---|
| 1559 | user: User.me.id, |
---|
| 1560 | calendar: { |
---|
[5384] | 1561 | name: Encoder.htmlEncode($('.qtip-active input').val()), |
---|
[5341] | 1562 | timezone: User.preferences.timezone |
---|
| 1563 | }, |
---|
| 1564 | isOwner: 1, |
---|
| 1565 | fontColor: colorsSuggestions[selected]['font'].substring(1) , |
---|
| 1566 | backgroundColor: colorsSuggestions[selected]['background'].substring(1) , |
---|
| 1567 | borderColor: colorsSuggestions[selected]['border'].substring(1) |
---|
| 1568 | }); |
---|
[5615] | 1569 | DataLayer.commit( false, false, function( received ){ |
---|
| 1570 | delete Calendar.currentViewKey; |
---|
| 1571 | Calendar.load(); |
---|
| 1572 | refresh_calendars(); |
---|
| 1573 | }); |
---|
[5341] | 1574 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1575 | }); |
---|
| 1576 | |
---|
| 1577 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 1578 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1579 | }); |
---|
| 1580 | |
---|
| 1581 | $(".qtip-active input").Watermark("Nome da agenda"); |
---|
| 1582 | |
---|
| 1583 | $('.qtip-active').keydown(function(event) { |
---|
| 1584 | if (event.keyCode == '27') { |
---|
| 1585 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1586 | } |
---|
| 1587 | }); |
---|
| 1588 | |
---|
| 1589 | $('.colors-options').prepend(buttons_colors); |
---|
| 1590 | $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); |
---|
| 1591 | |
---|
| 1592 | var buttons = $('.cal-colors-options-btn').button(); |
---|
| 1593 | |
---|
| 1594 | buttons.click(function(){ |
---|
| 1595 | buttons.removeClass('color-selected'); |
---|
| 1596 | $(this).addClass('color-selected'); |
---|
| 1597 | }); |
---|
| 1598 | } |
---|
| 1599 | } |
---|
| 1600 | }); |
---|
| 1601 | |
---|
| 1602 | $("img.cal-list-img").click(function(evt) { |
---|
| 1603 | $(".cal-list-options_1").toggleClass( "hidden" ); |
---|
| 1604 | }); |
---|
| 1605 | |
---|
| 1606 | $(".my-calendars a.title-my-calendars").click(function() { |
---|
| 1607 | $(".my-calendars ul.my-list-calendars").toggleClass("hidden") |
---|
| 1608 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s"); |
---|
| 1609 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e"); |
---|
| 1610 | }); |
---|
[5381] | 1611 | |
---|
[5341] | 1612 | $(".signed-calendars a.title-signed-calendars").click(function() { |
---|
| 1613 | $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden"); |
---|
| 1614 | }); |
---|
| 1615 | |
---|
| 1616 | $("ul li.list-calendars-item").click(function(evt) { |
---|
| 1617 | |
---|
| 1618 | }); |
---|
| 1619 | |
---|
| 1620 | $("ul li.list-calendars-item .ui-corner-all").click(function(evt) { |
---|
| 1621 | //alert('teste'); |
---|
| 1622 | }); |
---|
| 1623 | |
---|
[5592] | 1624 | meu_container.find(".button.new-calendar-shared").button({ |
---|
| 1625 | icons: { |
---|
| 1626 | primary: "ui-icon-plus" |
---|
| 1627 | }, |
---|
| 1628 | text: false |
---|
| 1629 | }).click(function (event) { |
---|
| 1630 | show_modal_search_shared(); |
---|
| 1631 | }); |
---|
| 1632 | |
---|
| 1633 | |
---|
| 1634 | //TODO Implementar ocultar agendas. |
---|
| 1635 | meu_container.find('.title-signed-calendars').click(function(evt){ |
---|
| 1636 | var status = $(this).parent().find('.status-list-shared'); |
---|
| 1637 | |
---|
| 1638 | if(status.hasClass('ui-icon-triangle-1-s')) |
---|
| 1639 | status.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); |
---|
| 1640 | else |
---|
| 1641 | status.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); |
---|
| 1642 | }); |
---|
| 1643 | |
---|
[5341] | 1644 | $('.calendar-view').click(function(evt){ |
---|
| 1645 | if($tabs.tabs('option' ,'selected') == 1){ |
---|
| 1646 | pageselectCallback('', 0); |
---|
| 1647 | } |
---|
| 1648 | |
---|
[5384] | 1649 | if(Calendar.currentView){ |
---|
[5341] | 1650 | var checkBox = $(this); |
---|
[5384] | 1651 | if(!!Calendar.currentView[ checkBox.val() ]){ |
---|
| 1652 | Calendar.currentView[ checkBox.val() ].hidden = !checkBox.is(':checked'); |
---|
| 1653 | $('#calendar').fullCalendar( 'refetchEvents' ); |
---|
| 1654 | } |
---|
| 1655 | } |
---|
[5341] | 1656 | }); |
---|
| 1657 | }); |
---|
| 1658 | } |
---|
| 1659 | |
---|
| 1660 | function add_events_list(keyword) |
---|
| 1661 | { |
---|
| 1662 | var tab_title = ""; |
---|
| 1663 | if (keyword){ |
---|
| 1664 | if(keyword.length < 10) |
---|
| 1665 | tab_title = keyword; |
---|
| 1666 | else |
---|
| 1667 | tab_title = keyword.substr(0,10) + '..."'; |
---|
| 1668 | }else{ |
---|
| 1669 | tab_title = "Lista de eventos"; |
---|
| 1670 | } |
---|
| 1671 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
| 1672 | |
---|
| 1673 | if(!(document.getElementById('tab_events_list_' + (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") ))) |
---|
| 1674 | { |
---|
| 1675 | Encoder.EncodeType = "entity"; |
---|
| 1676 | $tabs.tabs( "add", "#tab_events_list_" + (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) ); |
---|
| 1677 | } |
---|
| 1678 | else /* Tab already opened */ |
---|
| 1679 | { |
---|
| 1680 | $tabs.tabs("option", "selected", 2); |
---|
| 1681 | } |
---|
| 1682 | |
---|
| 1683 | pageselectCallback(keyword, 0); // load page 1 and insert data on event_list.ejs |
---|
| 1684 | |
---|
| 1685 | $('.preferences-win.active .button.save, .preferences-win.active .button.cancel, .preferences-win.active .button.import, .preferences-win.active .button.export').button(); |
---|
| 1686 | } |
---|
| 1687 | |
---|
| 1688 | function paginatorSearch(currentView){ |
---|
[5381] | 1689 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
| 1690 | function(){ |
---|
| 1691 | $(this).addClass('fc-state-hover'); |
---|
| 1692 | }, |
---|
| 1693 | function(){ |
---|
| 1694 | $(this).removeClass('fc-state-hover'); |
---|
| 1695 | }).mousedown(function(){ |
---|
| 1696 | $(this).addClass('fc-state-down'); |
---|
| 1697 | }).mouseup(function(){ |
---|
| 1698 | $(this).removeClass('fc-state-down'); |
---|
| 1699 | $('.events-list.events-list-win.active').removeClass('active'); |
---|
| 1700 | var paginator = $(this).attr('class'); |
---|
| 1701 | if(paginator.indexOf('next') > 0){ |
---|
| 1702 | if(parseInt($(currentView+' [name = results]').val()) > 25) |
---|
| 1703 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1)); |
---|
| 1704 | }else{ |
---|
| 1705 | if(parseInt($(currentView+' [name = page_index]').val()) > 0) |
---|
| 1706 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1)); |
---|
| 1707 | } |
---|
| 1708 | }); |
---|
[5341] | 1709 | } |
---|
| 1710 | |
---|
| 1711 | function mountTitleList(page_index ,view){ |
---|
| 1712 | switch (view){ |
---|
| 1713 | case 'day': |
---|
[5345] | 1714 | case 'basicDay': |
---|
[5341] | 1715 | var date = new Date().add({days: page_index}); |
---|
[5409] | 1716 | return (dateCalendar.dayNames[date.getDay()])+", "+(date.toString('dd MMM yyyy')); |
---|
[5345] | 1717 | case 'agendaWeek': |
---|
[5341] | 1718 | case 'week': |
---|
[5409] | 1719 | var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
[5341] | 1720 | dateStart.add({days: (7 * page_index)}); |
---|
[5409] | 1721 | var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
[5341] | 1722 | dateEnd.add({days: (page_index * 7)+7}); |
---|
| 1723 | if(dateStart.toString('MM') != dateEnd.toString('MM')) |
---|
[5409] | 1724 | return dateStart.toString('dd')+' de '+dateCalendar.monthNamesShort[dateStart.getMonth()]+' a '+dateEnd.toString('dd')+' de '+dateCalendar.monthNames[dateEnd.getMonth()]+' - '+dateEnd.toString('yyyy'); |
---|
| 1725 | return +dateStart.toString("dd")+" a "+dateEnd.toString("dd")+" de "+dateCalendar.monthNames[dateEnd.getMonth()]+" - "+dateEnd.toString('yyyy'); |
---|
[5341] | 1726 | case 'month': |
---|
| 1727 | var date = new Date().add({months: page_index}) |
---|
[5409] | 1728 | return dateCalendar.monthNames[date.getMonth()]+" "+date.toString("yyyy"); |
---|
[5341] | 1729 | case 'year': |
---|
| 1730 | var date = new Date().add({years: page_index}); |
---|
| 1731 | return date.toString("yyyy"); |
---|
| 1732 | } |
---|
| 1733 | } |
---|
| 1734 | |
---|
| 1735 | function paginatorList(currentView, view){ |
---|
| 1736 | $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>'+mountTitleList( parseInt($('[name = page_index]').val()),view)+'</h2>'); |
---|
| 1737 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
[5345] | 1738 | if(view == 'basicDay') |
---|
| 1739 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-agendaday').addClass('fc-state-active'); |
---|
| 1740 | else |
---|
| 1741 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-'+((view == 'day' || view == 'week') ? 'agenda'+view : view )).addClass('fc-state-active'); |
---|
[5341] | 1742 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right').addClass('list-right'); |
---|
[5381] | 1743 | |
---|
| 1744 | $(currentView+' .header-paginator .fc-header-right .fc-button').hover( |
---|
[5341] | 1745 | function(){ |
---|
| 1746 | $(this).addClass('fc-state-hover'); |
---|
| 1747 | }, |
---|
| 1748 | function(){ |
---|
| 1749 | $(this).removeClass('fc-state-hover'); |
---|
| 1750 | }).mousedown(function(){ |
---|
| 1751 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
| 1752 | $(this).addClass('fc-state-active'); |
---|
| 1753 | }).mouseup(function(){ |
---|
[5381] | 1754 | var goView = $(this).attr('class'); |
---|
| 1755 | if(goView.indexOf('agendaDay') > 0) |
---|
| 1756 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'day'); |
---|
| 1757 | else if(goView.indexOf('month') > 0) |
---|
| 1758 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'month'); |
---|
| 1759 | else if(goView.indexOf('year') > 0) |
---|
| 1760 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'year'); |
---|
| 1761 | else if(goView.indexOf('agendaWeek') > 0) |
---|
| 1762 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'week'); |
---|
| 1763 | |
---|
[5341] | 1764 | }); |
---|
[5381] | 1765 | |
---|
| 1766 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
[5341] | 1767 | function(){ |
---|
| 1768 | $(this).addClass('fc-state-hover'); |
---|
| 1769 | }, |
---|
| 1770 | function(){ |
---|
| 1771 | $(this).removeClass('fc-state-hover'); |
---|
| 1772 | }).mousedown(function(){ |
---|
| 1773 | $(this).addClass('fc-state-down'); |
---|
| 1774 | }).mouseup(function(){ |
---|
| 1775 | $(this).removeClass('fc-state-down'); |
---|
[5381] | 1776 | var paginator = $(this).attr('class'); |
---|
| 1777 | if(paginator.indexOf('next') > 0) |
---|
| 1778 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) +1), '', view); |
---|
| 1779 | else |
---|
| 1780 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) -1), '', view); |
---|
| 1781 | }); |
---|
[5341] | 1782 | } |
---|
| 1783 | |
---|
| 1784 | function paginatorListEvent(currentView, typeView, view){ |
---|
| 1785 | if(!!$(currentView).find('.fc-calendar').length) |
---|
| 1786 | return; |
---|
| 1787 | $(currentView+' .events-list.events-list-win.active').prepend($('.fc-header').clone()); |
---|
| 1788 | //Remove contudo nao utilizado |
---|
| 1789 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-today').remove(); |
---|
| 1790 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicWeek').remove(); |
---|
| 1791 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicDay').remove(); |
---|
| 1792 | |
---|
| 1793 | //Adiciona e remove as classes para esta visualizacao |
---|
| 1794 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-header-center').addClass('list-events-paginator'); |
---|
| 1795 | $(currentView+' .events-list.events-list-win.active .fc-header .list-events-paginator').removeClass('fc-header-center'); |
---|
| 1796 | |
---|
| 1797 | //Adicionar class no header padronizar com a tela principal |
---|
| 1798 | $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); |
---|
| 1799 | $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); |
---|
| 1800 | |
---|
| 1801 | if(typeView == 'search'){ |
---|
| 1802 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right').remove() |
---|
| 1803 | $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>Resultados para: '+$(currentView+' [name = keyword]').val()+'</h2>'); |
---|
| 1804 | if((parseInt($(currentView+' [name = page_index]').val()) == 0) && (parseInt($(currentView+' [name = results]').val()) <= 25)) |
---|
| 1805 | return; |
---|
| 1806 | paginatorSearch(currentView); |
---|
| 1807 | }else |
---|
| 1808 | paginatorList(currentView, view); |
---|
| 1809 | } |
---|
| 1810 | |
---|
| 1811 | function mountCriteriaList(view, page_index, calerdars_selecteds){ |
---|
[5437] | 1812 | var rangeStart , rangeEnd; |
---|
[5341] | 1813 | switch (view){ |
---|
[5345] | 1814 | case 'basicDay': |
---|
[5341] | 1815 | case 'day': |
---|
[5592] | 1816 | rangeStart = new Date().add({days: page_index}).getTime(); |
---|
[5437] | 1817 | rangeEnd = rangeStart; |
---|
| 1818 | break; |
---|
[5345] | 1819 | case 'agendaWeek': |
---|
[5341] | 1820 | case 'week': |
---|
[5437] | 1821 | var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
| 1822 | var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); |
---|
[5592] | 1823 | rangeStart = dateStart.add({days: (7 * page_index)}).getTime(); |
---|
| 1824 | rangeEnd = dateEnd.add({days: (7 * page_index)+7}).getTime(); |
---|
[5437] | 1825 | break; |
---|
[5341] | 1826 | case 'month': |
---|
[5592] | 1827 | var date = Date.today().add({months: page_index}) |
---|
| 1828 | rangeStart = date.moveToFirstDayOfMonth().getTime(); |
---|
| 1829 | rangeEnd = date.moveToLastDayOfMonth().getTime(); |
---|
[5437] | 1830 | break; |
---|
[5341] | 1831 | case 'year': |
---|
| 1832 | var dateStart = new Date().add({years: page_index}); |
---|
| 1833 | var dateEnd = new Date().add({years: page_index}); |
---|
| 1834 | if(dateStart.getMonth() != 0) |
---|
| 1835 | dateStart.moveToMonth(0, -1) |
---|
| 1836 | if(dateEnd.getMonth() != 11) |
---|
| 1837 | dateEnd.moveToMonth(11) |
---|
[5592] | 1838 | rangeStart = dateStart.moveToFirstDayOfMonth().getTime(); |
---|
| 1839 | rangeEnd = dateEnd.moveToLastDayOfMonth().getTime(); |
---|
[5437] | 1840 | break; |
---|
| 1841 | } |
---|
| 1842 | return {filter: ['AND', ['>=', 'rangeStart', rangeStart], ['<=', 'rangeEnd', rangeEnd] , ['IN', 'calendar', calerdars_selecteds]], criteria: {deepness: 2, order: 'startTime'}}; |
---|
| 1843 | |
---|
[5341] | 1844 | } |
---|
| 1845 | |
---|
| 1846 | function pageselectCallback(keyword, page_index, jq, view){ |
---|
| 1847 | |
---|
| 1848 | var selecteds = getSelectedCalendars(); |
---|
| 1849 | if(!selecteds && (keyword != '' && keyword != null)){ |
---|
| 1850 | jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 1851 | '<div title="Lista de eventos" class="events-list events-list-win active empty">' + |
---|
| 1852 | '<label>Por favor selecione ao menos uma agenda.</label>' + |
---|
| 1853 | '</div>' |
---|
| 1854 | ); |
---|
| 1855 | }else{ |
---|
| 1856 | var criteria = null; |
---|
| 1857 | if(keyword == '' || keyword == null) |
---|
| 1858 | criteria = mountCriteriaList(!!view ? view : User.preferences.defaultCalView, page_index, selecteds) |
---|
| 1859 | else |
---|
[5409] | 1860 | criteria = {filter: ['AND', ['OR', ["i*", "summary", keyword], ["i*", "description", keyword]], ['IN', 'calendar', selecteds]], criteria: {order: 'startTime', offset: (25 * page_index), limit: (((25 * page_index) + 25) + 1), deepness: 2}}; |
---|
[5341] | 1861 | var results = DataLayer.get('schedulable:detail', criteria); |
---|
| 1862 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
| 1863 | } |
---|
| 1864 | // não há resultados |
---|
| 1865 | if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) { |
---|
| 1866 | jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 1867 | '<div title="Lista de eventos" class="events-list events-list-win active empty">' + |
---|
| 1868 | '<label>Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' + |
---|
| 1869 | '</div>' |
---|
| 1870 | ); |
---|
| 1871 | // há resultados e Agendas Selecionadas |
---|
| 1872 | } else{ |
---|
| 1873 | if(typeof(results) != 'undefined'){ |
---|
| 1874 | results['page_index'] = page_index; |
---|
| 1875 | results['keyword'] = keyword; |
---|
| 1876 | |
---|
| 1877 | DataLayer.render( 'templates/event_list.ejs', results, function( html ){ |
---|
| 1878 | var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); |
---|
| 1879 | jQuery(currentView).html( html ); |
---|
| 1880 | jQuery('.events-list-win .menu-container .button').button(); |
---|
| 1881 | |
---|
| 1882 | $(".event-details-item").parent().click(function(){ |
---|
| 1883 | |
---|
| 1884 | $(this).siblings("div.details-event-list").toggleClass("hidden") |
---|
| 1885 | .find('.button.delete').click(function(){ |
---|
[5381] | 1886 | var eventId = $(this).siblings('[name="eventid"]').val(); |
---|
| 1887 | $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', { |
---|
| 1888 | 'type': 'question', |
---|
| 1889 | 'overlay_opacity': '0.5', |
---|
| 1890 | 'buttons': ['Sim', 'Não'], |
---|
| 1891 | 'onClose': function(clicked) { |
---|
| 1892 | if(clicked == 'Sim'){ |
---|
| 1893 | DataLayer.remove('schedulable', eventId); |
---|
| 1894 | } |
---|
| 1895 | } |
---|
| 1896 | }); |
---|
[5341] | 1897 | }) |
---|
| 1898 | .end().find('.button.edit').click(function(){ |
---|
| 1899 | eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); |
---|
| 1900 | }); |
---|
| 1901 | |
---|
| 1902 | }); |
---|
| 1903 | paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView); |
---|
| 1904 | }); |
---|
| 1905 | }else{ |
---|
| 1906 | var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); |
---|
| 1907 | jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 1908 | '<div title="Lista de eventos" class="events-list events-list-win active empty">' + |
---|
| 1909 | '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ |
---|
| 1910 | '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ |
---|
| 1911 | '<label>Não foram encontrados eventos neste intervalo.</label>' + |
---|
| 1912 | '</div>' |
---|
| 1913 | ); |
---|
| 1914 | paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView); |
---|
| 1915 | } |
---|
| 1916 | |
---|
| 1917 | } |
---|
| 1918 | |
---|
| 1919 | } |
---|
| 1920 | |
---|
[5381] | 1921 | function show_modal_import_export(tab, calendarId) { |
---|
[5341] | 1922 | DataLayer.render( 'templates/import_export.ejs', {calendars: Calendar.calendars, owner: User.me.id}, function( html ){ |
---|
| 1923 | |
---|
| 1924 | if (!UI.dialogs.importCalendar) { |
---|
| 1925 | UI.dialogs.importCalendar = jQuery('#div-import-export-calendar') |
---|
| 1926 | .append('<div title="Importar e Exportar Eventos" class="import-export import-export-win active"> <div>') |
---|
| 1927 | .find('.import-export-win.active').html(html).dialog({ |
---|
| 1928 | resizable: false, |
---|
| 1929 | modal:true, |
---|
| 1930 | width:500, |
---|
| 1931 | position: 'center' |
---|
| 1932 | }); |
---|
| 1933 | |
---|
| 1934 | } else { |
---|
| 1935 | UI.dialogs.importCalendar.html(html); |
---|
| 1936 | } |
---|
| 1937 | |
---|
| 1938 | var tabsImportExport = UI.dialogs.importCalendar.find(".tabs-import-export").tabs({selected: tab}); |
---|
| 1939 | |
---|
| 1940 | UI.dialogs.importCalendar.find('.button').button(); |
---|
| 1941 | |
---|
[5381] | 1942 | tabsImportExport.find('option[value="'+calendarId+'"]').attr('selected','selected').trigger('change'); |
---|
| 1943 | |
---|
| 1944 | |
---|
[5341] | 1945 | UI.dialogs.importCalendar.find(".menu-import-event") |
---|
[5381] | 1946 | .children(".import").click(function(data){ |
---|
| 1947 | $('.import-event-form', UI.dialogs.importCalendar).submit(); |
---|
[5341] | 1948 | UI.dialogs.importCalendar.dialog("close"); |
---|
[5384] | 1949 | isValidCalback = true; |
---|
[5341] | 1950 | /** |
---|
| 1951 | * TODO - implementar ação de importação |
---|
| 1952 | */ |
---|
| 1953 | }); |
---|
| 1954 | |
---|
| 1955 | UI.dialogs.importCalendar.find(".menu-export-event") |
---|
| 1956 | .children(".export").click(function(){ |
---|
| 1957 | |
---|
| 1958 | $('.export-event-form', UI.dialogs.importCalendar).submit(); |
---|
| 1959 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 1960 | /** |
---|
| 1961 | * TODO - implementar ação de exportação |
---|
| 1962 | */ |
---|
| 1963 | }); |
---|
| 1964 | |
---|
| 1965 | UI.dialogs.importCalendar.find(".menu-container") |
---|
| 1966 | .children(".cancel").click(function(){ |
---|
| 1967 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 1968 | }); |
---|
| 1969 | |
---|
| 1970 | UI.dialogs.importCalendar.dialog("open"); |
---|
| 1971 | }); |
---|
[5592] | 1972 | } |
---|
| 1973 | |
---|
| 1974 | function copyAndMoveTo(calendar, eventId){ |
---|
| 1975 | |
---|
| 1976 | var type = $('.calendar-copy-move input[name="typeEvent"]').val(); |
---|
| 1977 | |
---|
| 1978 | var schedulable = DataLayer.get('schedulable' , ''+eventId); |
---|
| 1979 | |
---|
| 1980 | if(typeof(schedulable) == "array") |
---|
| 1981 | schedulable = schedulable[0]; |
---|
| 1982 | |
---|
| 1983 | //Move eventos entre agendas |
---|
| 1984 | if(!!parseInt(type)){ |
---|
| 1985 | |
---|
| 1986 | schedulable.calendar = calendar; |
---|
| 1987 | DataLayer.put('schedulable', schedulable); |
---|
| 1988 | |
---|
| 1989 | DataLayer.commit(); |
---|
| 1990 | //copia eventos entre agendas |
---|
| 1991 | }else{ |
---|
| 1992 | |
---|
| 1993 | var newSchedulable = schedulable; |
---|
| 1994 | |
---|
| 1995 | delete newSchedulable.id; |
---|
| 1996 | delete newSchedulable.uid; |
---|
| 1997 | delete newSchedulable.sequence; |
---|
| 1998 | delete newSchedulable.dtstamp; |
---|
| 1999 | delete schedulable.calendar; |
---|
[5615] | 2000 | delete schedulable.DayLigth; |
---|
| 2001 | delete schedulable.rangeStart |
---|
| 2002 | delete schedulable.rangeEnd; |
---|
| 2003 | delete schedulable.lastUpdate; |
---|
| 2004 | delete schedulable.repeat; |
---|
[5592] | 2005 | |
---|
[5636] | 2006 | |
---|
[5615] | 2007 | schedulable.calendar = DataLayer.copy(calendar); |
---|
| 2008 | |
---|
[5592] | 2009 | newSchedulable.endTime = new Date(parseInt(newSchedulable.endTime) - (newSchedulable.allDay ? 86400000 : 0)).toString('yyyy-MM-dd hh:mm:00'); |
---|
| 2010 | newSchedulable.startTime = new Date(parseInt(newSchedulable.startTime)).toString('yyyy-MM-dd hh:mm:00'); |
---|
| 2011 | |
---|
| 2012 | var participants = DataLayer.copy(schedulable.participants); |
---|
| 2013 | delete schedulable.participants; |
---|
| 2014 | |
---|
| 2015 | schedulable.participants = $.map( participants, function( attendee, i ){ |
---|
| 2016 | |
---|
| 2017 | var participant = DataLayer.get('participant', attendee); |
---|
| 2018 | |
---|
| 2019 | if(typeof(participant) == 'array') |
---|
| 2020 | participant = participant[0]; |
---|
| 2021 | |
---|
| 2022 | delete participant.id; |
---|
| 2023 | |
---|
| 2024 | return participant ; |
---|
| 2025 | }); |
---|
| 2026 | |
---|
[5636] | 2027 | |
---|
| 2028 | |
---|
| 2029 | DataLayer.put('schedulable', newSchedulable); |
---|
| 2030 | |
---|
[5592] | 2031 | } |
---|
| 2032 | |
---|
| 2033 | |
---|
[5341] | 2034 | } |
---|