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