[5341] | 1 | /* |
---|
| 2 | Todo Otimizar caulculo de timezone |
---|
| 3 | Objeto Date.toString() retorna a data com inserção do offset |
---|
| 4 | Objeto Date.getTime() retorna a data sem inserção do offset |
---|
| 5 | */ |
---|
| 6 | function checkTimezoneCalendar(idCalendar, timezone){ |
---|
| 7 | var obj = DataLayer.get('calendar', idCalendar); |
---|
| 8 | if(User.timezones[obj.timezone] == timezone) |
---|
| 9 | return true; |
---|
| 10 | else |
---|
| 11 | return false; |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | function setDateTimezone(date, timezone, existsTimezone, idCalendar){ |
---|
| 15 | |
---|
| 16 | if(!existsTimezone) |
---|
| 17 | return date; |
---|
| 18 | if(idCalendar) |
---|
| 19 | if(checkTimezoneCalendar(idCalendar, timezone)) |
---|
| 20 | return getDateTimezone(date, timezone, false); |
---|
| 21 | |
---|
| 22 | var timezoneOffset = ''; |
---|
| 23 | if(User.isDaylightSaving == '1') |
---|
| 24 | timezoneOffset = parseInt(timezone.substr(2)) - 100; |
---|
| 25 | else |
---|
| 26 | timezoneOffset = parseInt(timezone.substr(2)); |
---|
| 27 | |
---|
| 28 | var timeCurrent = parseInt((date.getTimezoneOffset()/60)+'00') |
---|
| 29 | var times = 0; |
---|
| 30 | if(timezone.charAt(0) != date.getUTCOffset().charAt(0)) |
---|
| 31 | times = timeCurrent + timezoneOffset ; |
---|
| 32 | else |
---|
| 33 | times = timezoneOffset - timeCurrent ; |
---|
| 34 | |
---|
| 35 | if(times == 0) |
---|
| 36 | return date; |
---|
| 37 | else if(times > 0) |
---|
| 38 | return date.setTimezoneOffset('-0'+(times)); |
---|
| 39 | else |
---|
| 40 | return date.setTimezoneOffset('+0'+((times * -1))); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | function getDateTimezone(date, timezone, recursive){ |
---|
| 45 | if(!timezone) |
---|
| 46 | return date; |
---|
| 47 | |
---|
| 48 | var times = 0; |
---|
| 49 | currentTimezone = parseInt((date.getTimezoneOffset()/60)+'00'); |
---|
| 50 | var timezoneOffset = 0; |
---|
| 51 | if(User.isDaylightSaving == '1') |
---|
| 52 | timezoneOffset = parseInt(timezone.substr(2)) - 100; |
---|
| 53 | else |
---|
| 54 | timezoneOffset = parseInt(timezone.substr(2)); |
---|
| 55 | |
---|
| 56 | var times = timezoneOffset - currentTimezone; |
---|
| 57 | if(times == 0){ |
---|
| 58 | if((timezone.charAt(0) == date.getUTCOffset().charAt(0)) && recursive) |
---|
| 59 | return date.setTimezoneOffset( timezone.charAt(0)+'0'+(currentTimezone)); |
---|
| 60 | else |
---|
| 61 | return date; |
---|
| 62 | }else if (times > 0) |
---|
| 63 | return date.setTimezoneOffset('+0'+(times)); |
---|
| 64 | else{ |
---|
| 65 | return date.setTimezoneOffset('-0'+((times * -1) + (currentTimezone * 2))); |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | function getDateUTC(date, timezone){ |
---|
| 70 | currentTimezone = parseInt(timezone.substr(2)); |
---|
| 71 | if(User.isDaylightSaving == '1') |
---|
| 72 | currentTimezone = currentTimezone - 100; |
---|
| 73 | return(date.setTimezoneOffset(timezone.charAt(0)+'0'+currentTimezone)); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | function createDateTimezone(date, timezone, idCalendar){ |
---|
| 77 | |
---|
| 78 | if(checkTimezoneCalendar(idCalendar, timezone)) |
---|
| 79 | return getDateTimezone(date, timezone, true); |
---|
| 80 | |
---|
| 81 | var times = 0; |
---|
| 82 | |
---|
| 83 | if(timezone.charAt(0) == '+') |
---|
| 84 | times = parseInt(timezone.substr(2)) - parseInt((date.getTimezoneOffset()/60)+'00'); |
---|
| 85 | else |
---|
| 86 | times = (parseInt(timezone.substr(2)) + parseInt((date.getTimezoneOffset()/60)+'00')) * (-1); |
---|
| 87 | if(times == 0) |
---|
| 88 | return date.setTimezoneOffset('0000'); |
---|
| 89 | else if (times > 0) |
---|
| 90 | return date.setTimezoneOffset('+0'+times); |
---|
| 91 | else |
---|
| 92 | return date.setTimezoneOffset('-0'+(times * -1)); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | function defaultToAmPm( Hour ) |
---|
| 96 | { |
---|
| 97 | var HourAmPm = Hour.split(":"); |
---|
| 98 | if(HourAmPm[0] == 0) |
---|
| 99 | HourAmPm[0] = 12; |
---|
| 100 | if(HourAmPm[0] < 12){ |
---|
| 101 | Hour += (Hour.length == 5) ? " am" : ""; |
---|
| 102 | }else if(HourAmPm[0] == 12){ |
---|
| 103 | Hour += (Hour.length == 5) ? " pm" : ""; |
---|
| 104 | }else |
---|
| 105 | Hour = "0"+(HourAmPm[0]-12)+":"+HourAmPm[1]+ ((Hour.length == 5) ? " pm" : ""); |
---|
| 106 | return Hour; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | function validDateEvent(){ |
---|
| 110 | var start_date = $(".new-event-win.active .start-date").val(); |
---|
| 111 | var end_date = $(".new-event-win.active .end-date").val(); |
---|
| 112 | var start_time = $(".new-event-win.active .start-time").val(); |
---|
| 113 | var end_time = $(".new-event-win.active .end-time").val(); |
---|
| 114 | var isAllDay = $('.new-event-win.active input[name="allDay"]').is(':checked'); |
---|
| 115 | |
---|
| 116 | if(start_date == "") |
---|
| 117 | return 'Por favor, informe uma data inicial'; |
---|
| 118 | else if(end_date == "") |
---|
| 119 | return 'Por favor, informe uma data final'; |
---|
| 120 | else if(!isAllDay && start_time == "") |
---|
| 121 | return 'Por favor, informe uma hora inicial'; |
---|
| 122 | else if(!isAllDay && end_time == "") |
---|
| 123 | return 'Por favor, informe uma hora final'; |
---|
| 124 | |
---|
| 125 | var formatString = (isAllDay)? User.preferences.dateFormat+" HH:mm" : User.preferences.dateFormat + " " + User.preferences.hourFormat; |
---|
| 126 | |
---|
| 127 | var spaces = function(hours){ |
---|
| 128 | return hours.replace(/\s$/, ""); |
---|
| 129 | }; |
---|
| 130 | |
---|
| 131 | var startDate = Date.parseExact( isAllDay ? start_date+ " 00:00": start_date + " " + spaces(start_time) , formatString ); |
---|
| 132 | var endDate = Date.parseExact( isAllDay ? end_date+ " 00:00": end_date + " " + spaces(end_time) , formatString ); |
---|
| 133 | |
---|
| 134 | if(startDate == null || startDate.getTime() < 0 ) |
---|
| 135 | return 'Data inicial inválida'; |
---|
| 136 | if(endDate == null || endDate.getTime() < 0) |
---|
| 137 | return 'Data final inválida'; |
---|
| 138 | |
---|
| 139 | if((endDate.compareTo(startDate) != 1) && !((endDate.compareTo(startDate) == 0) && (isAllDay))){ |
---|
| 140 | if(start_date == end_date){ |
---|
| 141 | if(end_time == start_time) |
---|
| 142 | return 'Hora inicial igual a final'; |
---|
| 143 | else |
---|
| 144 | return 'Hora final menor que a inicial'; |
---|
| 145 | |
---|
| 146 | }else |
---|
| 147 | return 'Data final menor que a inicial'; |
---|
| 148 | } |
---|
| 149 | return false; |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | /* |
---|
| 153 | function listEvents(){ |
---|
| 154 | var list = $('.fc-header-right').find('.fc-button.fc-button-agendaDay').clone(); |
---|
| 155 | $('.fc-header-right').find('.fc-button-year').toggleClass('fc-corner-right'); |
---|
| 156 | list.addClass('fc-corner-right'); |
---|
| 157 | list.addClass('fc-button-listagem'); |
---|
| 158 | list.removeClass('fc-button-agendaDay'); |
---|
| 159 | list.removeClass('fc-corner-left'); |
---|
| 160 | list.find('.fc-button-content').html('Listagem'); |
---|
| 161 | $('.fc-header-right').append(list); |
---|
| 162 | } |
---|
| 163 | */ |
---|
[5389] | 164 | function eventDetails( objEvent, decoded, path) |
---|
[5341] | 165 | { |
---|
[5389] | 166 | if(path == undefined) |
---|
| 167 | path = ""; |
---|
| 168 | |
---|
[5341] | 169 | if( !decoded ) |
---|
| 170 | objEvent = DataLayer.decode( "schedulable:calendar", objEvent ); |
---|
| 171 | |
---|
| 172 | objEvent = DataLayer.encode( "schedulable:preview", objEvent ); |
---|
| 173 | |
---|
| 174 | if(typeof(objEvent.id) == 'undefined'){ |
---|
| 175 | objEvent.alarms = Calendar.signatureOf[!!User.preferences.defaultCalendar ? User.preferences.defaultCalendar : Calendar.calendarIds[0]].defaultAlarms; |
---|
| 176 | objEvent.useAlarmDefault = 1; |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | /** |
---|
| 180 | * canDiscardEventDialog deve ser true se não houver alterações no evento |
---|
| 181 | */ |
---|
| 182 | canDiscardEventDialog = true; |
---|
| 183 | /** |
---|
| 184 | * zebraDiscardEventDialog é uma flag indicando que uma janela de confirmação (Zebra_Dialog) |
---|
| 185 | * já está aberta na tela, uma vez que não é possivel acessar o evento ESC utilizado para fechá-la |
---|
| 186 | */ |
---|
| 187 | zebraDiscardEventDialog = false; |
---|
| 188 | |
---|
[5389] | 189 | var html = DataLayer.render( path+'templates/event_add.ejs', {event:objEvent}); |
---|
[5341] | 190 | |
---|
| 191 | if (!UI.dialogs.addEvent) { |
---|
| 192 | UI.dialogs.addEvent = jQuery('#sandbox').append('<div title="Criar Evento" class="new-event-win active"> <div>').find('.new-event-win.active').html(html).dialog({ |
---|
| 193 | resizable: false, |
---|
| 194 | modal:true, |
---|
| 195 | autoOpen: false, |
---|
| 196 | width:700, |
---|
| 197 | position: 'center', |
---|
| 198 | close: function(event, ui) { |
---|
| 199 | /** |
---|
| 200 | * Remove tooltip possivelmente existente |
---|
| 201 | */ |
---|
| 202 | if ($('dd.attendee-list li:last').data('qtip')) |
---|
| 203 | $('dd.attendee-list li:last').qtip('destroy'); |
---|
| 204 | |
---|
| 205 | }, |
---|
| 206 | beforeClose: function(event, ui) { |
---|
| 207 | |
---|
| 208 | if (!canDiscardEventDialog && !zebraDiscardEventDialog) { |
---|
| 209 | zebraDiscardEventDialog = true; |
---|
| 210 | window.setTimeout(function() { |
---|
| 211 | $.Zebra_Dialog('Suas alterações no evento não foram salvas. Deseja descartar as alterações?', { |
---|
| 212 | 'type': 'question', |
---|
| 213 | 'overlay_opacity': '0.5', |
---|
| 214 | 'buttons': ['Descartar alterações', 'Continuar editando'], |
---|
| 215 | 'onClose': function(clicked) { |
---|
| 216 | if(clicked == 'Descartar alterações') { |
---|
| 217 | canDiscardEventDialog = true; |
---|
| 218 | UI.dialogs.addEvent.dialog('close'); |
---|
[5381] | 219 | }else{ |
---|
| 220 | zebraDiscardEventDialog = false; |
---|
[5341] | 221 | } |
---|
| 222 | |
---|
| 223 | /** |
---|
| 224 | * Uma vez aberta uma janela de confirmação (Zebra_Dialog), ao fechá-la |
---|
| 225 | * com ESC, para que o evento ESC não seja propagado para fechamento da |
---|
| 226 | * janela de edição de eventos, deve ser setada uma flag indicando que |
---|
| 227 | * já existe uma janela de confirmação aberta. |
---|
| 228 | */ |
---|
| 229 | if (!clicked) { |
---|
| 230 | window.setTimeout(function() { |
---|
| 231 | zebraDiscardEventDialog = false; |
---|
| 232 | }, 200); |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | }); |
---|
| 236 | |
---|
| 237 | }, 300); |
---|
| 238 | |
---|
| 239 | } |
---|
| 240 | return canDiscardEventDialog; |
---|
| 241 | } |
---|
| 242 | }); |
---|
| 243 | |
---|
| 244 | } else { |
---|
| 245 | UI.dialogs.addEvent.html(html); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | var tabs = UI.dialogs.addEvent.children('.content').tabs(); |
---|
| 249 | var calendar = DataLayer.get('calendar', objEvent.calendar); |
---|
[5381] | 250 | |
---|
[5341] | 251 | if (calendar.timezone != objEvent.timezone){ |
---|
| 252 | UI.dialogs.addEvent.find('.calendar-addevent-details-txt-timezone').find('option[value="'+objEvent.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 253 | UI.dialogs.addEvent.find('.calendar_addevent_details_lnk_timezone').addClass('hidden'); |
---|
| 254 | $('.calendar-addevent-details-txt-timezone').removeClass('hidden'); |
---|
| 255 | |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | UI.dialogs.addEvent.find('.calendar_addevent_details_lnk_timezone').click(function(e){ |
---|
| 259 | $(this).addClass('hidden'); |
---|
| 260 | $('.calendar-addevent-details-txt-timezone').removeClass('hidden'); |
---|
| 261 | |
---|
| 262 | e.preventDefault(); |
---|
| 263 | }); |
---|
| 264 | |
---|
[5376] | 265 | UI.dialogs.addEvent.find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el){ |
---|
| 266 | var id; |
---|
| 267 | if( id = $(this).parent().find('input[name="alarmId[]"]').val()) |
---|
| 268 | DataLayer.remove('alarm', id); |
---|
[5341] | 269 | if( $(this).parent().remove().find('li').is(':empty') ) { |
---|
| 270 | //alert('nao tem'); |
---|
| 271 | } |
---|
| 272 | }); |
---|
| 273 | |
---|
[5381] | 274 | /*Seleciona a agenda padrão para criação de um evento*/ |
---|
| 275 | UI.dialogs.addEvent.find('option[value="'+User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); |
---|
| 276 | |
---|
[5341] | 277 | /*Adicionar alarms padrões, quando alterado a agenda do usuário*/ |
---|
| 278 | UI.dialogs.addEvent.find('select[name="calendar"]').change(function(){ |
---|
| 279 | if((typeof($('input[name = "idEvent"]').val()) == 'undefined') || ($('input[name = "idEvent"]').val() == '')) { |
---|
| 280 | $('input[name = "isDefaultAlarm[]"]').parent().remove(); |
---|
| 281 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').parent().removeClass('hidden'); |
---|
| 282 | var calendarSelected = Calendar.signatureOf[$(this).val()]; |
---|
| 283 | calendarSelected.useAlarmDefault = 1; |
---|
| 284 | if(calendarSelected.defaultAlarms != ""){ |
---|
[5389] | 285 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {alarm:calendarSelected}); |
---|
[5341] | 286 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
| 287 | if( $(this).parent().remove().find('li').is(':empty') ) { |
---|
| 288 | //alert('nao tem'); |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | }); |
---|
| 292 | }else{ |
---|
| 293 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').parent().addClass('hidden'); |
---|
| 294 | } |
---|
| 295 | } |
---|
| 296 | }); |
---|
| 297 | |
---|
| 298 | /*Checkbox adicionar alarms padrões*/ |
---|
| 299 | UI.dialogs.addEvent.find('input[name="defaultAlarm"]').click(function(){ |
---|
| 300 | if($(this).attr("checked")){ |
---|
[5354] | 301 | $('input[name="isDefaultAlarm[]"]').parent().remove(); |
---|
[5341] | 302 | var calendarSelected = Calendar.signatureOf[$('select[name="calendar"]').val()]; |
---|
| 303 | calendarSelected.useAlarmDefault = 1; |
---|
| 304 | if(calendarSelected.defaultAlarms != ""){ |
---|
[5389] | 305 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {alarm:calendarSelected}); |
---|
[5341] | 306 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
[5376] | 307 | var id; |
---|
| 308 | if( id = $(this).parent().find('input[name="alarmId[]"]').val()) |
---|
| 309 | DataLayer.remove('alarm', id); |
---|
[5341] | 310 | if( $(this).parent().remove().find('li').is(':empty') ) { |
---|
| 311 | //alert('nao tem'); |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | }); |
---|
| 315 | } |
---|
[5354] | 316 | } else { |
---|
| 317 | $('input[name="isDefaultAlarm[]"]').parent().remove(); |
---|
| 318 | } |
---|
[5341] | 319 | }); |
---|
| 320 | /* Checkbox allday */ |
---|
| 321 | UI.dialogs.addEvent.find('input[name="allDay"]').click(function(){ |
---|
| 322 | if($(this).attr("checked")) |
---|
| 323 | UI.dialogs.addEvent.find('.start-time, .end-time').addClass('hidden'); |
---|
| 324 | else |
---|
| 325 | UI.dialogs.addEvent.find('.start-time, .end-time').removeClass('hidden'); |
---|
| 326 | }); |
---|
| 327 | |
---|
| 328 | UI.dialogs.addEvent.find('.button').button(); |
---|
| 329 | UI.dialogs.addEvent.find('.button.add').button({ |
---|
| 330 | icons: { |
---|
| 331 | secondary: "ui-icon-plus" |
---|
| 332 | } |
---|
| 333 | }); |
---|
| 334 | |
---|
| 335 | // ==== validation events ==== |
---|
[5354] | 336 | UI.dialogs.addEvent.find(".input-group .h1").Watermark("Evento sem título"); |
---|
| 337 | if(User.preferences.hourFormat.length == 5) { |
---|
| 338 | UI.dialogs.addEvent.find(".end-time, .start-time").mask("99:99"); |
---|
| 339 | } else { |
---|
[5341] | 340 | $.mask.definitions['{']='[ap]'; |
---|
| 341 | $.mask.definitions['}']='[m]'; |
---|
[5354] | 342 | UI.dialogs.addEvent.find(".end-time, .start-time").mask("99:99 {}", { |
---|
| 343 | completed:function(){ |
---|
[5341] | 344 | $(this).val(defaultToAmPm($(this).val())); |
---|
| 345 | $(this).timepicker("refresh"); |
---|
| 346 | $(this).val($(this).val().replace(/[\.]/gi, "")); |
---|
[5354] | 347 | } |
---|
| 348 | }); |
---|
[5341] | 349 | } |
---|
[5354] | 350 | UI.dialogs.addEvent.find(".number").numeric(); |
---|
[5341] | 351 | if(User.preferences.dateFormat.indexOf('-') > 0) |
---|
[5354] | 352 | UI.dialogs.addEvent.find(".date").mask("99-99-9999"); |
---|
[5341] | 353 | else |
---|
[5354] | 354 | UI.dialogs.addEvent.find(".date").mask("99/99/9999"); |
---|
[5341] | 355 | |
---|
| 356 | UI.dialogs.addEvent.find(".menu-addevent") |
---|
| 357 | .children(".delete").click(function(){ |
---|
| 358 | $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', { |
---|
| 359 | 'type': 'question', |
---|
| 360 | 'overlay_opacity': '0.5', |
---|
| 361 | 'buttons': ['Sim', 'Não'], |
---|
| 362 | 'onClose': function(clicked) { |
---|
| 363 | if(clicked == 'Sim'){ |
---|
| 364 | DataLayer.remove( "schedulable", UI.dialogs.addEvent.find(".id-event").val() ); |
---|
| 365 | UI.dialogs.addEvent.dialog("close"); |
---|
| 366 | } |
---|
| 367 | } |
---|
| 368 | }); |
---|
| 369 | }).end() |
---|
| 370 | |
---|
| 371 | .children(".cancel").click(function(){ |
---|
| 372 | DataLayer.rollback('participant'); |
---|
| 373 | UI.dialogs.addEvent.dialog("close"); |
---|
| 374 | }).end() |
---|
| 375 | |
---|
| 376 | .children(".save").click(function(){ |
---|
| 377 | /* Validação */ |
---|
[5354] | 378 | var msg = false; |
---|
| 379 | if(msg = validDateEvent()){ |
---|
| 380 | $(".new-event-win.active").find('.messages-validation').removeClass('hidden').find('.message label').html(msg); |
---|
| 381 | return false; |
---|
| 382 | } |
---|
[5341] | 383 | |
---|
| 384 | canDiscardEventDialog = true; |
---|
| 385 | |
---|
| 386 | UI.dialogs.addEvent.children(".form-addevent").submit(); |
---|
| 387 | UI.dialogs.addEvent.dialog("close"); |
---|
| 388 | }).end() |
---|
| 389 | |
---|
| 390 | .children(".export").click(function(){ |
---|
| 391 | UI.dialogs.addEvent.children(".form-export").submit(); |
---|
| 392 | }); |
---|
| 393 | |
---|
| 394 | UI.dialogs.addEvent.find('input.date').datepicker({dateFormat: 'dd/mm/yy'}); |
---|
[5392] | 395 | if(path == ""){ |
---|
| 396 | UI.dialogs.addEvent.find('input.time').timepicker({ |
---|
| 397 | closeText: 'Ok', |
---|
| 398 | hourGrid: 4, |
---|
| 399 | minuteGrid: 10, |
---|
| 400 | ampm : ((User.preferences.hourFormat.length > 5) ? true: false), |
---|
| 401 | timeFormat: "hh:mm tt", |
---|
| 402 | onSelect: function (selectedDateTime){ |
---|
| 403 | if(!(User.preferences.hourFormat.length == 5)) |
---|
| 404 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 405 | }, |
---|
| 406 | onClose : function (selectedDateTime){ |
---|
| 407 | if(!(User.preferences.hourFormat.length == 5)) |
---|
| 408 | $(this).val(selectedDateTime.replace(/[\.]/gi, "")); |
---|
| 409 | } |
---|
| 410 | }); |
---|
| 411 | } |
---|
[5341] | 412 | |
---|
| 413 | UI.dialogs.addEvent.find('.button-add-alarms').click(function(){ |
---|
[5389] | 414 | var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {}); |
---|
[5341] | 415 | |
---|
| 416 | jQuery('.event-alarms-list').append(li_attach).find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
| 417 | if( $(this).parent().remove().find('li').is(':empty') ) { |
---|
| 418 | //alert('nao tem'); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | }); |
---|
| 422 | |
---|
| 423 | // valicacao de campos numericos |
---|
| 424 | $('.number').numeric(); |
---|
| 425 | }); |
---|
| 426 | |
---|
[5354] | 427 | // UI.dialogs.addEvent.find('.button-add-attachment').click(function(){ |
---|
| 428 | // var li_attach = |
---|
| 429 | // '<li class="input_label">' + |
---|
| 430 | // '<input type="file" name="attachments[]"" />' + |
---|
| 431 | // '</li>'; |
---|
| 432 | // jQuery('.attachments-list').append(li_attach); |
---|
| 433 | // }); |
---|
[5341] | 434 | |
---|
[5389] | 435 | var attendeeHtml = DataLayer.render( path+'templates/attendee_add.ejs', {event:objEvent}); |
---|
[5341] | 436 | |
---|
| 437 | // load template of attendees |
---|
| 438 | var blkAddAtendee = UI.dialogs.addEvent.find('#calendar_addevent_details6').append(attendeeHtml); |
---|
| 439 | |
---|
[5361] | 440 | blkAddAtendee.find('li.attendee .button').addClass('small '+ (objEvent.isOrganizer == 1 ? '' : 'hidden')).button({text:false, icons: {primary:'ui-icon-close'}}).click(function () { |
---|
[5358] | 441 | DataLayer.remove('participant', $(this).parent().find('[type=checkbox]').val()); |
---|
[5341] | 442 | $(this).parent().remove(); |
---|
| 443 | }); |
---|
| 444 | //show or hidden permissions attendees |
---|
| 445 | //blkAddAtendee.find('.block-attendee-list #attendees-users li').click(show_permissions_attendees); |
---|
| 446 | |
---|
[5354] | 447 | UI.dialogs.addEvent.find(".attendee-list-add .add-attendee-input input").Watermark("digite um email para convidar"); |
---|
[5341] | 448 | /* Trata a edição de um novo participante adicionado |
---|
| 449 | * |
---|
| 450 | */ |
---|
| 451 | var hasNewAttendee = false; |
---|
[5360] | 452 | blkAddAtendee.find('.attendee-list-add .add-attendee-input input').keydown(function(event) { |
---|
[5341] | 453 | |
---|
| 454 | if (event.keyCode == '13' && $(this).val() != '') { |
---|
| 455 | Encoder.EncodeType = "entity"; |
---|
| 456 | $(this).val(Encoder.htmlEncode($(this).val())); |
---|
| 457 | |
---|
[5353] | 458 | newAttendeeEmail = false; |
---|
[5354] | 459 | newAttendeeName = false; |
---|
| 460 | skipAddNewLine = false; |
---|
[5341] | 461 | |
---|
| 462 | var info = $(this).val(); |
---|
| 463 | |
---|
| 464 | /** |
---|
| 465 | * email válido? |
---|
| 466 | */ |
---|
| 467 | info.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/) ? |
---|
| 468 | newAttendeeEmail = info : newAttendeeName = info; |
---|
| 469 | |
---|
| 470 | /** |
---|
| 471 | * 1) busca no banco para saber se o usuário já existe |
---|
| 472 | * 1.1) se existe, atualiza as info na lista de participantes e nao abre o tooltip |
---|
| 473 | * 1.2) se não existe |
---|
| 474 | * a) salva como novo usuario externo no banco (apenas com email) |
---|
| 475 | * b) exibe tooltip pedindo o nome |
---|
| 476 | * c) se o usuário preenche tooltip e salva, atualiza com o nome o usuário recém criado |
---|
| 477 | * d) se o usuário cancela o tooltip, fica o usuário salvo apenas com email e sem nome |
---|
| 478 | */ |
---|
| 479 | |
---|
| 480 | var user = DataLayer.get('user', ["=", "mail", $(this).val()], true); |
---|
[5353] | 481 | |
---|
[5354] | 482 | |
---|
| 483 | /** |
---|
| 484 | * guarda o último tooltip aberto referente à lista de participantes |
---|
| 485 | */ |
---|
| 486 | lastEditAttendeeToolTip = []; |
---|
| 487 | |
---|
| 488 | /** |
---|
| 489 | * Valida email e salva um participante externo |
---|
| 490 | */ |
---|
| 491 | var saveContact = function() { |
---|
| 492 | Encoder.EncodeType = "entity"; |
---|
| 493 | |
---|
| 494 | var currentTip = $('.qtip-active'); |
---|
| 495 | newAttendeeName = currentTip.find('input[name="name"]').val(); |
---|
| 496 | newAttendeeEmail = currentTip.find('input[name="mail"]').val(); |
---|
| 497 | |
---|
| 498 | var isValidMail = newAttendeeEmail.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/); |
---|
| 499 | if (!isValidMail) { |
---|
[5381] | 500 | currentTip.find('.messages').removeClass('hidden').find('.message label').html('Email inválido.'); |
---|
[5354] | 501 | return false; |
---|
| 502 | } |
---|
| 503 | |
---|
[5364] | 504 | DataLayer.put('user', {id:userId, name:newAttendeeName, mail:newAttendeeEmail, isExternal:isExternal}); |
---|
[5354] | 505 | |
---|
[5360] | 506 | lastEditAttendeeToolTip.find('label') |
---|
[5354] | 507 | .filter('.name').html(Encoder.htmlEncode(newAttendeeName)).attr('title', Encoder.htmlEncode(newAttendeeName)).end() |
---|
| 508 | .filter('.mail').html(Encoder.htmlEncode(newAttendeeEmail)).attr('title', Encoder.htmlEncode(newAttendeeEmail)); |
---|
| 509 | |
---|
[5360] | 510 | blkAddAtendee.find('.attendee-list-add .add-attendee-input input').val(''); |
---|
[5354] | 511 | return true; |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | /** |
---|
| 515 | * Formata e adequa um tootip abert para edição de um participante na lista |
---|
| 516 | */ |
---|
[5353] | 517 | var onShowToolTip = function(arg0) { |
---|
| 518 | $('.qtip-active .button.close').button({ |
---|
| 519 | icons: {primary: "ui-icon-close"}, |
---|
| 520 | text: false |
---|
| 521 | }); |
---|
| 522 | $('.qtip-active .button').button() |
---|
| 523 | .filter('.save').click(function(event, ui) { |
---|
| 524 | if (saveContact()) { |
---|
[5354] | 525 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5353] | 526 | } else { |
---|
| 527 | return false; |
---|
| 528 | } |
---|
| 529 | }).end() |
---|
| 530 | .filter('.cancel').click(function(event, ui) { |
---|
[5354] | 531 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5353] | 532 | }) |
---|
| 533 | |
---|
| 534 | /** |
---|
| 535 | * Trata o ENTER no campo da tooltip, equivalente a salvar |
---|
| 536 | * o novo convidado. |
---|
| 537 | */ |
---|
| 538 | $('.qtip-active input').keydown(function(event) { |
---|
| 539 | if (event.keyCode == '13') { |
---|
| 540 | if (saveContact()) { |
---|
[5354] | 541 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5353] | 542 | } |
---|
| 543 | |
---|
[5354] | 544 | lastEditAttendeeToolTip.qtip("destroy"); |
---|
[5353] | 545 | event.preventDefault(); |
---|
| 546 | } |
---|
| 547 | }) |
---|
| 548 | .filter('[name="name"]').Watermark("informe o nome do contato").end() |
---|
| 549 | .filter('[name="mail"]').Watermark("informe o email do contato"); |
---|
| 550 | } |
---|
| 551 | |
---|
| 552 | |
---|
[5354] | 553 | /** |
---|
| 554 | * Se o email digitado já foi adicionado na lista, |
---|
| 555 | * o usuário deve ser avisado e um botão de edição deve ser exibido |
---|
| 556 | */ |
---|
| 557 | if(blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').length) { |
---|
[5360] | 558 | hasNewAttendee = false; |
---|
[5354] | 559 | newAttendeeName = blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').parents('li').find('label.name').attr('title'); |
---|
| 560 | |
---|
| 561 | blkAddAtendee.find('.email-validation').removeClass('hidden') |
---|
[5353] | 562 | .find('.message label').html("O usuário acima já foi adicionado! <a class=\"small button\">Editar</a>") |
---|
| 563 | .find(".button").button().click(function () { |
---|
[5354] | 564 | /** |
---|
| 565 | * Se o usuário optar por editar o participante anteriormente adicionado, |
---|
| 566 | * uma tooltip deve ser aberta para este participante, viabilizando a edição |
---|
| 567 | */ |
---|
| 568 | blkAddAtendee.find("ul.attendee-list").scrollTo('label.mail[title="' + newAttendeeEmail + '"]'); |
---|
| 569 | /** |
---|
| 570 | * Remove tooltip possivelmente existente |
---|
| 571 | */ |
---|
[5360] | 572 | if (lastEditAttendeeToolTip.length && lastEditAttendeeToolTip.data('qtip')) |
---|
[5354] | 573 | lastEditAttendeeToolTip.qtip('destroy'); |
---|
| 574 | |
---|
| 575 | lastEditAttendeeToolTip = blkAddAtendee.find('label.mail[title="' + newAttendeeEmail + '"]').parents('li'); |
---|
| 576 | lastEditAttendeeToolTip.qtip({ |
---|
[5353] | 577 | show: {ready: true, solo: true, when: {event: 'click'}}, |
---|
| 578 | hide: false, |
---|
| 579 | content: { |
---|
[5389] | 580 | text: $('<div></div>').html( DataLayer.render( path+'templates/attendee_quick_edit.ejs', {attendee:{name:newAttendeeName, mail:newAttendeeEmail}} ) ), |
---|
[5353] | 581 | title: { |
---|
| 582 | text:'Detalhes do participante', |
---|
| 583 | button: '<a class="button close" href="#">close</a>' |
---|
| 584 | } |
---|
| 585 | }, |
---|
| 586 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 230, max:230}}, |
---|
| 587 | position: { |
---|
| 588 | corner: { |
---|
| 589 | target: 'rightMiddle', |
---|
| 590 | tooltip: 'leftMiddle' |
---|
| 591 | }, |
---|
| 592 | adjust: {x:0, y:0} |
---|
| 593 | } |
---|
| 594 | }); |
---|
[5354] | 595 | lastEditAttendeeToolTip.qtip("api").onShow = onShowToolTip; |
---|
| 596 | }); |
---|
| 597 | skipAddNewLine = true; |
---|
[5360] | 598 | } else { |
---|
| 599 | hasNewAttendee = true; |
---|
| 600 | blkAddAtendee.find('.email-validation').addClass('hidden'); |
---|
[5353] | 601 | } |
---|
| 602 | |
---|
| 603 | |
---|
[5387] | 604 | var isExternal = (!!user && !(!!user.isExternal)) ? 0 : 1; |
---|
[5341] | 605 | |
---|
| 606 | /** |
---|
| 607 | * Remove tooltip possivelmente existente |
---|
| 608 | */ |
---|
[5360] | 609 | if (lastEditAttendeeToolTip.length && lastEditAttendeeToolTip.data('qtip')) |
---|
[5354] | 610 | lastEditAttendeeToolTip.qtip('destroy'); |
---|
[5341] | 611 | |
---|
[5364] | 612 | userId = ''; |
---|
[5341] | 613 | var newAttendeeId = ''; |
---|
| 614 | |
---|
| 615 | if (user){ |
---|
[5354] | 616 | if (!skipAddNewLine) { |
---|
[5384] | 617 | user[0].id = DataLayer.put('participant', {user: user[0].id, isExternal: isExternal}); |
---|
[5354] | 618 | blkAddAtendee.find('dd.attendee-list ul.attendee-list').append( |
---|
[5389] | 619 | DataLayer.render(path+'templates/participants_add_itemlist.ejs', user) |
---|
[5354] | 620 | ) |
---|
| 621 | .find('.button.close').addClass('small').button({text:false, icons:{primary:'ui-icon-close'}}).click(function() { |
---|
[5358] | 622 | DataLayer.remove('participant', $(this).parent().find('[type=checkbox]').val()); |
---|
[5354] | 623 | $(this).parent().remove(); |
---|
| 624 | }).end() |
---|
| 625 | .scrollTo('max'); |
---|
| 626 | } |
---|
[5349] | 627 | |
---|
[5341] | 628 | $(this).val(''); |
---|
| 629 | |
---|
[5354] | 630 | } else if (!skipAddNewLine) { |
---|
[5341] | 631 | /** |
---|
| 632 | * a) salva como novo usuario externo no banco (apenas com email) e... |
---|
| 633 | * adiciona novo contato externo à lista de convidados |
---|
| 634 | */ |
---|
| 635 | |
---|
[5358] | 636 | userId = DataLayer.put('user', {name: newAttendeeName, mail: newAttendeeEmail, isExternal: isExternal}); |
---|
| 637 | newAttendeeId = DataLayer.put('participant', {user: userId, isExternal: isExternal}); |
---|
[5341] | 638 | |
---|
[5354] | 639 | |
---|
[5341] | 640 | blkAddAtendee.find('dd.attendee-list ul.attendee-list').append( |
---|
[5389] | 641 | DataLayer.render(path+'templates/participants_add_itemlist.ejs', [{id:newAttendeeId, name: newAttendeeName, mail: newAttendeeEmail, isExternal: 1}]) |
---|
[5341] | 642 | ).find('.button.close').addClass('small').button({text:false, icons:{primary:'ui-icon-close'}}).click(function() { |
---|
[5358] | 643 | DataLayer.remove('participant', $(this).parent().find('[type=checkbox]').val()); |
---|
[5341] | 644 | $(this).parent().remove(); |
---|
[5349] | 645 | }).end() |
---|
| 646 | .scrollTo('max'); |
---|
[5341] | 647 | |
---|
| 648 | |
---|
| 649 | /** |
---|
| 650 | * Adiciona tootip para atualização dos dados do contato externo |
---|
| 651 | * recém adicionado. |
---|
| 652 | */ |
---|
[5354] | 653 | lastEditAttendeeToolTip = blkAddAtendee.find('dd.attendee-list li:last'); |
---|
| 654 | lastEditAttendeeToolTip.qtip({ |
---|
[5341] | 655 | show: {ready: true, solo: true, when: {event: 'click'}}, |
---|
| 656 | hide: false, |
---|
| 657 | content: { |
---|
[5389] | 658 | text: $('<div></div>').html( DataLayer.render( path+'templates/attendee_quick_edit.ejs', {attendee:{name:newAttendeeName, mail:newAttendeeEmail}} ) ), |
---|
[5341] | 659 | title: { |
---|
| 660 | text:'Detalhes do participante', |
---|
| 661 | button: '<a class="button close" href="#">close</a>' |
---|
| 662 | } |
---|
| 663 | }, |
---|
| 664 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 230, max:230}}, |
---|
| 665 | position: { |
---|
| 666 | corner: { |
---|
| 667 | target: 'rightMiddle', |
---|
| 668 | tooltip: 'leftMiddle' |
---|
| 669 | }, |
---|
| 670 | adjust: {x:0, y:0} |
---|
| 671 | } |
---|
| 672 | }); |
---|
| 673 | |
---|
[5354] | 674 | lastEditAttendeeToolTip.qtip("api").onShow = onShowToolTip; |
---|
[5341] | 675 | |
---|
[5354] | 676 | $(this).val(''); |
---|
[5341] | 677 | |
---|
[5353] | 678 | |
---|
[5341] | 679 | } |
---|
[5354] | 680 | event.preventDefault(); |
---|
[5341] | 681 | } |
---|
[5354] | 682 | |
---|
[5341] | 683 | }); |
---|
| 684 | |
---|
| 685 | /** |
---|
| 686 | * Trata a busca de usuários para adição de participantes |
---|
| 687 | */ |
---|
| 688 | blkAddAtendee.find('.add-attendee-search input').keydown(function(event) { |
---|
| 689 | |
---|
| 690 | if(event.keyCode == '13') { |
---|
| 691 | Encoder.EncodeType = "entity"; |
---|
| 692 | $(this).val(Encoder.htmlEncode($(this).val())); |
---|
| 693 | |
---|
| 694 | var result = DataLayer.get('user', ["*", "name", $(this).val()], true); |
---|
| 695 | |
---|
| 696 | /** |
---|
| 697 | * TODO: trocar por template |
---|
| 698 | */ |
---|
[5360] | 699 | blkAddAtendee.find('ul.search-result-list').empty().css('overflow', 'hidden'); |
---|
[5341] | 700 | if (!result) { |
---|
[5360] | 701 | blkAddAtendee.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>'); |
---|
[5341] | 702 | } |
---|
| 703 | |
---|
[5363] | 704 | for(i=0; i<result.length; i++) |
---|
| 705 | result[i].enabled = (blkAddAtendee.find('dd.attendee-list ul.attendee-list label.mail[title="' + result[i].mail + '"]').length) ? false : true; |
---|
| 706 | |
---|
[5389] | 707 | blkAddAtendee.find('ul.search-result-list').append(DataLayer.render( path+'templates/participants_search_itemlist.ejs', result)); |
---|
[5341] | 708 | |
---|
[5360] | 709 | blkAddAtendee.find('ul.search-result-list li').click(function(event, ui){ |
---|
[5341] | 710 | if ($(event.target).is('input')) { |
---|
| 711 | old_item = $(event.target).parents('li'); |
---|
[5358] | 712 | newAttendeeId = DataLayer.put('participant', {user: old_item.find('.id').html(), isExternal: 0}); |
---|
[5341] | 713 | blkAddAtendee.find('dd.attendee-list ul.attendee-list') |
---|
[5389] | 714 | .append(DataLayer.render(path+'templates/participants_add_itemlist.ejs', [{id: newAttendeeId, name: old_item.find('.name').html(), mail: old_item.find('.mail').html(), isExternal: 0}])) |
---|
[5341] | 715 | .find('.button').addClass('small').button({text:false, icons: {primary:'ui-icon-close'}}).click(function () { |
---|
| 716 | $(this).parent().remove(); |
---|
[5349] | 717 | }).end() |
---|
| 718 | .scrollTo('max'); |
---|
[5341] | 719 | |
---|
| 720 | old_item.remove(); |
---|
| 721 | } |
---|
| 722 | }); |
---|
| 723 | |
---|
| 724 | event.preventDefault(); |
---|
| 725 | } |
---|
| 726 | }); |
---|
| 727 | |
---|
| 728 | |
---|
| 729 | UI.dialogs.addEvent.find('.attendees-list li').hover( |
---|
| 730 | function () { |
---|
| 731 | $(this).addClass("hover"); |
---|
| 732 | }, |
---|
| 733 | function () { |
---|
| 734 | $(this).removeClass("hover"); |
---|
| 735 | } |
---|
| 736 | ); |
---|
| 737 | |
---|
| 738 | //$('.block-add-attendee .search-result-list').selectable(); |
---|
| 739 | |
---|
| 740 | UI.dialogs.addEvent.find('.block-attendee-list select.status').change(function(){ |
---|
| 741 | if ($(this).val() == 'another') { |
---|
| 742 | // jQuery('.block-attendee-list .add-attendee-search').removeClass('hidden'); |
---|
| 743 | $(this).qtip({ |
---|
| 744 | show: {ready: true}, |
---|
| 745 | hide: false, |
---|
| 746 | content: { |
---|
| 747 | text: $('.block-attendee-list .add-attendee-search').clone().removeClass('hidden'), |
---|
| 748 | title: { |
---|
| 749 | text:'Indique o participante', |
---|
| 750 | button: '<a class="button close" href="#">close</a>' |
---|
| 751 | } |
---|
| 752 | }, |
---|
| 753 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 250, max:250}}, |
---|
| 754 | position: { |
---|
| 755 | corner: { |
---|
| 756 | target: 'rightMiddle', |
---|
| 757 | tooltip: 'leftMiddle' |
---|
| 758 | }, |
---|
| 759 | adjust: {x:0, y:0} |
---|
| 760 | } |
---|
| 761 | }) |
---|
| 762 | $(this).qtip.onShow = function() { |
---|
| 763 | $('.qtip .button.close').button({ |
---|
| 764 | icons: {primary: "ui-icon-close"}, |
---|
| 765 | text: false |
---|
| 766 | }); |
---|
| 767 | } |
---|
| 768 | } else { |
---|
| 769 | // jQuery('.block-attendee-list .add-attendee-search').addClass('hidden'); |
---|
| 770 | } |
---|
| 771 | }); |
---|
[5381] | 772 | UI.dialogs.addEvent.find(':input').change(function(event){ |
---|
| 773 | if (event.keyCode != '27' && event.keyCode != '13') |
---|
| 774 | canDiscardEventDialog = false; |
---|
| 775 | }).keydown(function(event){ |
---|
| 776 | if (event.keyCode != '27' && event.keyCode != '13') |
---|
| 777 | canDiscardEventDialog = false; |
---|
| 778 | }); |
---|
| 779 | |
---|
[5341] | 780 | UI.dialogs.addEvent.dialog('open'); |
---|
| 781 | } |
---|
| 782 | |
---|
[5353] | 783 | |
---|
| 784 | |
---|
[5341] | 785 | function add_tab_preferences() |
---|
| 786 | { |
---|
| 787 | if(!(document.getElementById('preference_tab'))) |
---|
| 788 | { |
---|
| 789 | var tab_title = "Preferencias"; |
---|
| 790 | $tabs.tabs( "add", "#preference_tab", tab_title ); |
---|
| 791 | |
---|
| 792 | /* |
---|
| 793 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 794 | tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 795 | }); |
---|
| 796 | */ |
---|
| 797 | DataLayer.render( 'templates/preferences_calendar.ejs', {preferences:User.preferences, calendars: Calendar.calendars}, function( template ){ |
---|
| 798 | var tabPrefCalendar = jQuery('#preference_tab').html( template ).find('.preferences-win'); |
---|
| 799 | |
---|
| 800 | tabPrefCalendar.find('option[value="'+User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); |
---|
| 801 | |
---|
| 802 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 803 | tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change'); |
---|
| 804 | }); |
---|
| 805 | |
---|
| 806 | tabPrefCalendar.find('.button').button() |
---|
| 807 | .filter('.save').click(function(evt){ |
---|
| 808 | tabPrefCalendar.find('form').submit(); |
---|
| 809 | $('#calendar').fullCalendar('render'); |
---|
| 810 | $('.block-vertical-toolbox .mini-calendar').datepicker( "refresh" ); |
---|
| 811 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 812 | }).end().filter('.cancel').click(function(evt){ |
---|
| 813 | $tabs.tabs( "remove", "#preference_tab"); |
---|
| 814 | }); |
---|
| 815 | |
---|
| 816 | tabPrefCalendar.find('.number').numeric(); |
---|
| 817 | }); |
---|
| 818 | } else { |
---|
| 819 | $tabs.tabs("select", "#preference_tab"); |
---|
| 820 | |
---|
| 821 | return true; |
---|
| 822 | } |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | |
---|
| 826 | function add_tab_configure_calendar(calendar) |
---|
| 827 | { |
---|
| 828 | var calendars = []; |
---|
| 829 | var signatures = []; |
---|
| 830 | var previewActiveCalendarConf = 0; |
---|
| 831 | |
---|
| 832 | for (var i=0; i<Calendar.signatures.length; i++) { |
---|
| 833 | calendars[i] = Calendar.signatures[i].calendar; |
---|
| 834 | signatures[i] = Calendar.signatures[i]; |
---|
| 835 | signatures[i].numberDefaultAlarm = signatures[i].defaultAlarms != '' ? signatures[i].defaultAlarms.length: 0; |
---|
| 836 | if (calendar && calendars[i].id == calendar) |
---|
| 837 | previewActiveCalendarConf = i; |
---|
| 838 | } |
---|
| 839 | |
---|
| 840 | if(!(document.getElementById('configure_tab'))) |
---|
| 841 | { |
---|
| 842 | $('.positionHelper').css('display', 'none'); |
---|
| 843 | var tab_title = "Configurações de agendas"; |
---|
| 844 | $tabs.tabs( "add", "#configure_tab", tab_title ); |
---|
| 845 | |
---|
| 846 | var dataColorPicker = { |
---|
| 847 | colorsSuggestions: colors_suggestions() |
---|
| 848 | }; |
---|
| 849 | |
---|
| 850 | |
---|
| 851 | |
---|
| 852 | var populateAccordionOnActive = function(event, ui) { |
---|
| 853 | var nowActive = (typeof(event) == 'number') ? event : $(event.target).accordion( "option", "active" ); |
---|
| 854 | dataColorPicker.colorsDefined = { |
---|
| 855 | border: '#'+signatures[nowActive].borderColor, |
---|
| 856 | font:'#'+signatures[nowActive].fontColor, |
---|
| 857 | background:'#'+signatures[nowActive].backgroundColor |
---|
| 858 | }; |
---|
| 859 | if (!jQuery('.accordion-user-calendars .ui-accordion-content').eq(nowActive).has('form')) { |
---|
| 860 | return true; |
---|
| 861 | } |
---|
| 862 | |
---|
| 863 | DataLayer.render( 'templates/configure_calendars_itemlist.ejs', {user:User, calendar:calendars[nowActive], signature:signatures[nowActive]}, function( form_template ){ |
---|
| 864 | var form_content = jQuery('.accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form'); |
---|
| 865 | form_content.find('.preferences-alarms-list .button').button({text:false, icons:{primary:'ui-icon-close'}}); |
---|
| 866 | form_content.find('.button').button(); |
---|
| 867 | |
---|
| 868 | DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ |
---|
| 869 | var valueTimeZone = calendars[nowActive].timezone; |
---|
| 870 | form_content.find('select[name="timezone"]').html(timezones_options).find('option[value="'+valueTimeZone+'"]').attr('selected','selected').trigger('change'); |
---|
| 871 | }); |
---|
| 872 | |
---|
| 873 | form_content.find('.button-add-alarms').click(function(){ |
---|
[5376] | 874 | DataLayer.render( 'templates/alarms_add_itemlist.ejs', {}, function( template ){ |
---|
[5341] | 875 | jQuery('.preferences-alarms-list').append(template) |
---|
| 876 | .find('li:last label:eq(0)').remove().end() |
---|
| 877 | .find('.number').numeric().end() |
---|
| 878 | .find('.button.remove').button({text:false, icons:{primary:'ui-icon-close'}}).click(function(el) { |
---|
| 879 | $(this).parent().remove(); |
---|
| 880 | }); |
---|
| 881 | }); |
---|
| 882 | }); |
---|
| 883 | |
---|
| 884 | |
---|
| 885 | /** |
---|
| 886 | * Set color picker |
---|
| 887 | */ |
---|
| 888 | DataLayer.render( 'templates/calendar_colorpicker.ejs', dataColorPicker, function( template ){ |
---|
| 889 | form_content.find('.calendar-colorpicker').html( template ); |
---|
| 890 | |
---|
| 891 | var f = $.farbtastic(form_content.find('.colorpicker'), colorpickerPreviewChange); |
---|
| 892 | var selected; |
---|
| 893 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
| 894 | |
---|
| 895 | var colorpickerPreviewChange = function(color) { |
---|
| 896 | var pickedup = form_content.find('.colorwell-selected').val(color).css('background-color', color); |
---|
| 897 | |
---|
| 898 | var colorpicker = form_content.find('.calendar-colorpicker'); |
---|
| 899 | |
---|
| 900 | if (pickedup.is('input[name="backgroundColor"]')) { |
---|
| 901 | colorpicker.find('.fc-event-skin').css('background-color',color); |
---|
| 902 | } else if (pickedup.is('input[name="fontColor"]')) { |
---|
| 903 | colorpicker.find('.fc-event-skin').css('color',color); |
---|
| 904 | } else if (pickedup.is('input[name="borderColor"]')) { |
---|
| 905 | colorpicker.find('.fc-event-skin').css('border-color',color); |
---|
| 906 | } |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | form_content.find('.colorwell').each(function () { |
---|
| 910 | f.linkTo(this); |
---|
| 911 | |
---|
| 912 | if ($(this).is('input[name="backgroundColor"]')) { |
---|
| 913 | colorpicker.find('.fc-event-skin').css('background-color', $(this).val()); |
---|
| 914 | } else if ($(this).is('input[name="fontColor"]')) { |
---|
| 915 | colorpicker.find('.fc-event-skin').css('color', $(this).val()); |
---|
| 916 | } else if ($(this).is('input[name="borderColor"]')) { |
---|
| 917 | colorpicker.find('.fc-event-skin').css('border-color', $(this).val()); |
---|
| 918 | } |
---|
| 919 | }) |
---|
| 920 | .focus(function() { |
---|
| 921 | if (selected) { |
---|
| 922 | $(selected).removeClass('colorwell-selected'); |
---|
| 923 | } |
---|
| 924 | |
---|
| 925 | $(selected = this).addClass('colorwell-selected'); |
---|
| 926 | f.linkTo(this, colorpickerPreviewChange); |
---|
| 927 | f.linkTo(colorpickerPreviewChange); |
---|
| 928 | |
---|
| 929 | }); |
---|
| 930 | |
---|
| 931 | form_content.find('select.color-suggestions').change(function() { |
---|
| 932 | var colors; |
---|
| 933 | |
---|
| 934 | if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) { |
---|
| 935 | colorpicker |
---|
| 936 | .find('input[name="fontColor"]').val(colors.font).focus().end() |
---|
| 937 | .find('input[name="backgroundColor"]').val(colors.background).focus().end() |
---|
| 938 | .find('input[name="borderColor"]').val(colors.border).focus().end() |
---|
| 939 | |
---|
| 940 | .find('.fc-event-skin').css({ |
---|
| 941 | 'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background, |
---|
| 942 | 'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border, |
---|
| 943 | 'color':dataColorPicker.colorsSuggestions[$(this).val()].font |
---|
| 944 | }); |
---|
| 945 | } |
---|
| 946 | }); |
---|
| 947 | |
---|
| 948 | /** |
---|
| 949 | * Trata a mudança dos valores dos campos de cores. |
---|
| 950 | * Se mudar um conjunto de cores sugerido, |
---|
| 951 | * este vira um conjunto de cores personalizado. |
---|
| 952 | */ |
---|
| 953 | form_content.find('.colorwell').change(function (element, ui) { |
---|
| 954 | if (true) { |
---|
| 955 | form_content.find('select.color-suggestions') |
---|
| 956 | .find('option:selected').removeAttr('selected').end() |
---|
| 957 | .find('option[value="custom"]').attr('selected', 'selected').trigger('change'); |
---|
| 958 | } |
---|
| 959 | }); |
---|
| 960 | }); //END set colorpicker |
---|
| 961 | |
---|
| 962 | form_content.find('.phone').mask("+99 (99) 9999-9999"); |
---|
| 963 | form_content.find('.number').numeric(); |
---|
| 964 | |
---|
| 965 | }); //END DataLayer.render( 'templates/configure_calendars_itemlist.ejs' ... |
---|
| 966 | |
---|
| 967 | // === validations preferences ==== |
---|
| 968 | |
---|
| 969 | |
---|
| 970 | } //END populateAccordionOnActive(event, ui) |
---|
| 971 | |
---|
| 972 | |
---|
| 973 | DataLayer.render( 'templates/configure_calendars.ejs', {user:User, calendars:calendars, signatures:signatures}, function( template ){ |
---|
| 974 | var template_content = jQuery('#configure_tab').html( template ).find('.configure-calendars-win'); |
---|
| 975 | template_content.find('.button').button().filter('.save').click(function(evt){ |
---|
| 976 | template_content.find('form').submit(); |
---|
| 977 | $tabs.tabs( "remove", "#configure_tab"); |
---|
| 978 | }).end().filter('.cancel').click(function(evt){ |
---|
| 979 | $tabs.tabs( "remove", "#configure_tab"); |
---|
| 980 | }); |
---|
| 981 | |
---|
| 982 | /** |
---|
| 983 | * Muda a estrutura do template para a aplicação do plugin accordion |
---|
| 984 | */ |
---|
| 985 | template_content.find('.header-menu-container').after('<div class="accordion-user-calendars"></div>').end().find('.accordion-user-calendars') |
---|
| 986 | .append(template_content.children('fieldset')); |
---|
| 987 | |
---|
| 988 | template_content.find('.accordion-user-calendars').children('fieldset').each(function(index) { |
---|
| 989 | $(this).before($('<h3></h3>').html($(this).children('legend'))); |
---|
| 990 | }); |
---|
| 991 | |
---|
| 992 | template_content.find('.accordion-user-calendars').accordion({ |
---|
| 993 | autoHeight: false, |
---|
| 994 | collapsible: true, |
---|
| 995 | clearStyle: true, |
---|
| 996 | active: previewActiveCalendarConf, |
---|
| 997 | changestart: populateAccordionOnActive |
---|
| 998 | }); |
---|
| 999 | populateAccordionOnActive(previewActiveCalendarConf); |
---|
| 1000 | }); |
---|
| 1001 | |
---|
| 1002 | } else { |
---|
| 1003 | |
---|
| 1004 | $tabs.tabs("select", "#configure_tab"); |
---|
| 1005 | $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); |
---|
| 1006 | |
---|
| 1007 | return true; |
---|
| 1008 | } |
---|
| 1009 | |
---|
| 1010 | } |
---|
| 1011 | |
---|
| 1012 | function getNotSelectedCalendars(){ |
---|
| 1013 | var selecteds = {}; |
---|
| 1014 | var cont = 0; |
---|
| 1015 | jQuery(function() { |
---|
| 1016 | jQuery(".my-calendars .calendar-view").each(function(i, obj) { |
---|
| 1017 | var check_box = obj; |
---|
| 1018 | if(!check_box.checked) { |
---|
| 1019 | selecteds[cont] = obj.value; |
---|
| 1020 | cont++; |
---|
| 1021 | }; |
---|
| 1022 | }); |
---|
| 1023 | }); |
---|
| 1024 | if (!cont) |
---|
| 1025 | return false; |
---|
| 1026 | |
---|
| 1027 | selecteds.length = cont; |
---|
| 1028 | return $.makeArray( selecteds ); |
---|
| 1029 | } |
---|
| 1030 | |
---|
| 1031 | function getSelectedCalendars(){ |
---|
| 1032 | var selecteds = {}; |
---|
| 1033 | var cont = 0; |
---|
| 1034 | jQuery(function() { |
---|
| 1035 | jQuery(".my-calendars .calendar-view").each(function(i, obj) { |
---|
| 1036 | var check_box = obj; |
---|
| 1037 | if(check_box.checked) { |
---|
| 1038 | selecteds[cont] = obj.value; |
---|
| 1039 | cont++; |
---|
| 1040 | }; |
---|
| 1041 | }); |
---|
| 1042 | }); |
---|
| 1043 | if (!cont) |
---|
| 1044 | return false; |
---|
| 1045 | |
---|
| 1046 | selecteds.length = cont; |
---|
| 1047 | return $.makeArray( selecteds ); |
---|
| 1048 | } |
---|
| 1049 | |
---|
| 1050 | /** |
---|
| 1051 | * TODO - transformar em preferência do módulo e criar telas de adição e exclusão de conjunto de cores |
---|
| 1052 | */ |
---|
| 1053 | function colors_suggestions(){ |
---|
| 1054 | return [ |
---|
| 1055 | {name:'Padrão', border:'#3366cc', font:'#ffffff', background:'#3366cc'}, |
---|
| 1056 | {name:'Coala', border:'#123456', font:'#ffffff', background:'#385c80'}, |
---|
| 1057 | {name:'Tomate', border:'#d5130b', font:'#111111', background:'#e36d76'}, |
---|
| 1058 | {name:'Limão', border:'#32ed21', font:'#1f3f1c', background:'#b2f1ac'}, |
---|
| 1059 | {name:'Alto contraste', border:'#000000', font:'#ffffff', background:'#222222'} |
---|
| 1060 | ] |
---|
| 1061 | } |
---|
| 1062 | |
---|
| 1063 | function remove_calendar(){ |
---|
| 1064 | /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ |
---|
[5381] | 1065 | $.Zebra_Dialog('Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?', { |
---|
[5341] | 1066 | 'type': 'question', |
---|
| 1067 | 'overlay_opacity': '0.5', |
---|
| 1068 | 'buttons': ['Sim', 'Não'], |
---|
| 1069 | 'onClose': function(clicked) { |
---|
| 1070 | if(clicked == 'Sim'){ |
---|
| 1071 | var idCalendar = $('.cal-list-options-btn.ui-state-active').attr('class').match(/[0-9]+/g); |
---|
| 1072 | var signature = ''; |
---|
| 1073 | for(var i =0; i < Calendar.signatures.length; i++){ |
---|
| 1074 | if(idCalendar[0] == Calendar.signatures[i].calendar.id){ |
---|
| 1075 | signature = Calendar.signatures[i].id; |
---|
| 1076 | break; |
---|
| 1077 | } |
---|
| 1078 | } |
---|
| 1079 | DataLayer.remove('calendarSignature', signature); |
---|
[5384] | 1080 | if(idCalendar == User.preferences.defaultCalendar) |
---|
| 1081 | DataLayer.remove( 'modulePreference', User.preferenceIds['defaultCalendar']); |
---|
[5341] | 1082 | $('.positionHelper').css('display', 'none'); |
---|
| 1083 | }else{ |
---|
| 1084 | $('.positionHelper').css('display', 'none'); |
---|
| 1085 | } |
---|
| 1086 | } |
---|
| 1087 | }); |
---|
| 1088 | } |
---|
| 1089 | |
---|
| 1090 | function refresh_calendars(){ |
---|
| 1091 | |
---|
| 1092 | var colorsSuggestions = colors_suggestions(); |
---|
| 1093 | var buttons_colors = ""; |
---|
| 1094 | for(var i = 0; i < colorsSuggestions.length; i++){ |
---|
| 1095 | 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>"; |
---|
| 1096 | } |
---|
| 1097 | |
---|
| 1098 | //DataLayer.render( 'templates/calendar_list.ejs', 'calendar:list', ["IN", "id", Calendar.calendarIds], function( html ){ |
---|
| 1099 | DataLayer.render( 'templates/calendar_list.ejs', Calendar, function( html ){ |
---|
| 1100 | |
---|
| 1101 | var meu_container = $(".calendars-list").html( html ); |
---|
| 1102 | |
---|
| 1103 | $('ul.list-calendars .cal-list-options-btn').each(function(){ |
---|
| 1104 | $(this).menu({ |
---|
| 1105 | content: $(this).next().html(), |
---|
| 1106 | width: '120', |
---|
| 1107 | positionOpts: { |
---|
| 1108 | posX: 'left', |
---|
| 1109 | posY: 'bottom', |
---|
| 1110 | offsetX: 0, |
---|
| 1111 | offsetY: 0, |
---|
| 1112 | directionH: 'right', |
---|
| 1113 | directionV: 'down', |
---|
| 1114 | detectH: true, // do horizontal collision detection |
---|
| 1115 | detectV: true, // do vertical collision detection |
---|
| 1116 | linkToFront: false |
---|
| 1117 | }, |
---|
| 1118 | flyOut: true, |
---|
| 1119 | showSpeed: 100, |
---|
| 1120 | crumbDefaultText: '>' |
---|
| 1121 | }); |
---|
| 1122 | }); |
---|
| 1123 | |
---|
| 1124 | |
---|
| 1125 | meu_container.find(".button.new").button({ |
---|
| 1126 | icons: { |
---|
| 1127 | primary: "ui-icon-plus" |
---|
| 1128 | }, |
---|
| 1129 | text: false |
---|
| 1130 | }).click(function () { |
---|
| 1131 | |
---|
| 1132 | if( $('.qtip.qtip-blue.qtip-active').val() !== ''){ |
---|
| 1133 | $(this).qtip({ |
---|
| 1134 | show: {ready: true, solo: true, when: {event: 'click'}}, |
---|
| 1135 | hide: false, |
---|
| 1136 | content: { |
---|
| 1137 | text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), |
---|
| 1138 | title: { |
---|
| 1139 | text:'Nova Agenda', |
---|
| 1140 | button: '<a class="button close" href="#">close</a>' |
---|
| 1141 | } |
---|
| 1142 | }, |
---|
| 1143 | style: {name: 'blue', tip: {corner: 'leftMiddle'}, border: {width: 4, radius: 8}, width: {min: 230, max:230}}, |
---|
| 1144 | position: { |
---|
| 1145 | corner: { |
---|
| 1146 | target: 'rightMiddle', |
---|
| 1147 | tooltip: 'leftMiddle' |
---|
| 1148 | }, |
---|
| 1149 | adjust: {x:0, y:-12} |
---|
| 1150 | } |
---|
| 1151 | }) |
---|
| 1152 | .qtip("api").onShow = function(arg0) { |
---|
| 1153 | $('.qtip-active .button.close').button({ |
---|
| 1154 | icons: {primary: "ui-icon-close"}, |
---|
| 1155 | text: false |
---|
| 1156 | }) |
---|
| 1157 | .click(function(){ |
---|
| 1158 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1159 | }); |
---|
| 1160 | //TODO emplementar tratamento de duplicação de valores no location |
---|
| 1161 | $('.qtip-active .button.save').button().click(function(){ |
---|
| 1162 | for(var i = 0; i < Calendar.calendars.length; i++){ |
---|
| 1163 | if(Calendar.calendars[i].location == $('.qtip-active input').val()){ |
---|
| 1164 | $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ |
---|
| 1165 | 'overlay_opacity': '0.5', |
---|
| 1166 | 'type': 'warning' |
---|
| 1167 | }); |
---|
| 1168 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1169 | return; |
---|
| 1170 | } |
---|
| 1171 | } |
---|
| 1172 | |
---|
| 1173 | var selected; |
---|
| 1174 | var color = $('.cal-colors-options-btn').each(function(index){ |
---|
| 1175 | if ($(this).is('.color-selected')) |
---|
| 1176 | selected = index; |
---|
| 1177 | }); |
---|
| 1178 | DataLayer.put( "calendarSignature", { |
---|
| 1179 | user: User.me.id, |
---|
| 1180 | calendar: { |
---|
[5384] | 1181 | name: Encoder.htmlEncode($('.qtip-active input').val()), |
---|
[5341] | 1182 | timezone: User.preferences.timezone |
---|
| 1183 | }, |
---|
| 1184 | isOwner: 1, |
---|
| 1185 | fontColor: colorsSuggestions[selected]['font'].substring(1) , |
---|
| 1186 | backgroundColor: colorsSuggestions[selected]['background'].substring(1) , |
---|
| 1187 | borderColor: colorsSuggestions[selected]['border'].substring(1) |
---|
| 1188 | }); |
---|
| 1189 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1190 | }); |
---|
| 1191 | |
---|
| 1192 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 1193 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1194 | }); |
---|
| 1195 | |
---|
| 1196 | $(".qtip-active input").Watermark("Nome da agenda"); |
---|
| 1197 | |
---|
| 1198 | $('.qtip-active').keydown(function(event) { |
---|
| 1199 | if (event.keyCode == '27') { |
---|
| 1200 | meu_container.find(".button.new").qtip('destroy'); |
---|
| 1201 | } |
---|
| 1202 | }); |
---|
| 1203 | |
---|
| 1204 | $('.colors-options').prepend(buttons_colors); |
---|
| 1205 | $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); |
---|
| 1206 | |
---|
| 1207 | var buttons = $('.cal-colors-options-btn').button(); |
---|
| 1208 | |
---|
| 1209 | buttons.click(function(){ |
---|
| 1210 | buttons.removeClass('color-selected'); |
---|
| 1211 | $(this).addClass('color-selected'); |
---|
| 1212 | }); |
---|
| 1213 | } |
---|
| 1214 | } |
---|
| 1215 | }); |
---|
| 1216 | |
---|
| 1217 | $("img.cal-list-img").click(function(evt) { |
---|
| 1218 | $(".cal-list-options_1").toggleClass( "hidden" ); |
---|
| 1219 | }); |
---|
| 1220 | |
---|
| 1221 | $(".my-calendars a.title-my-calendars").click(function() { |
---|
| 1222 | $(".my-calendars ul.my-list-calendars").toggleClass("hidden") |
---|
| 1223 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s"); |
---|
| 1224 | $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e"); |
---|
| 1225 | }); |
---|
[5381] | 1226 | |
---|
[5341] | 1227 | $(".signed-calendars a.title-signed-calendars").click(function() { |
---|
| 1228 | $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden"); |
---|
| 1229 | }); |
---|
| 1230 | |
---|
| 1231 | $("ul li.list-calendars-item").click(function(evt) { |
---|
| 1232 | |
---|
| 1233 | }); |
---|
| 1234 | |
---|
| 1235 | $("ul li.list-calendars-item .ui-corner-all").click(function(evt) { |
---|
| 1236 | //alert('teste'); |
---|
| 1237 | }); |
---|
| 1238 | |
---|
| 1239 | $('.calendar-view').click(function(evt){ |
---|
| 1240 | if($tabs.tabs('option' ,'selected') == 1){ |
---|
| 1241 | pageselectCallback('', 0); |
---|
| 1242 | } |
---|
| 1243 | |
---|
[5384] | 1244 | if(Calendar.currentView){ |
---|
[5341] | 1245 | var checkBox = $(this); |
---|
[5384] | 1246 | if(!!Calendar.currentView[ checkBox.val() ]){ |
---|
| 1247 | Calendar.currentView[ checkBox.val() ].hidden = !checkBox.is(':checked'); |
---|
| 1248 | $('#calendar').fullCalendar( 'refetchEvents' ); |
---|
| 1249 | } |
---|
| 1250 | } |
---|
[5341] | 1251 | }); |
---|
| 1252 | }); |
---|
| 1253 | } |
---|
| 1254 | |
---|
| 1255 | function add_events_list(keyword) |
---|
| 1256 | { |
---|
| 1257 | var tab_title = ""; |
---|
| 1258 | if (keyword){ |
---|
| 1259 | if(keyword.length < 10) |
---|
| 1260 | tab_title = keyword; |
---|
| 1261 | else |
---|
| 1262 | tab_title = keyword.substr(0,10) + '..."'; |
---|
| 1263 | }else{ |
---|
| 1264 | tab_title = "Lista de eventos"; |
---|
| 1265 | } |
---|
| 1266 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
| 1267 | |
---|
| 1268 | if(!(document.getElementById('tab_events_list_' + (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") ))) |
---|
| 1269 | { |
---|
| 1270 | Encoder.EncodeType = "entity"; |
---|
| 1271 | $tabs.tabs( "add", "#tab_events_list_" + (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) ); |
---|
| 1272 | } |
---|
| 1273 | else /* Tab already opened */ |
---|
| 1274 | { |
---|
| 1275 | $tabs.tabs("option", "selected", 2); |
---|
| 1276 | } |
---|
| 1277 | |
---|
| 1278 | pageselectCallback(keyword, 0); // load page 1 and insert data on event_list.ejs |
---|
| 1279 | |
---|
| 1280 | $('.preferences-win.active .button.save, .preferences-win.active .button.cancel, .preferences-win.active .button.import, .preferences-win.active .button.export').button(); |
---|
| 1281 | } |
---|
| 1282 | |
---|
| 1283 | function paginatorSearch(currentView){ |
---|
[5381] | 1284 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
| 1285 | function(){ |
---|
| 1286 | $(this).addClass('fc-state-hover'); |
---|
| 1287 | }, |
---|
| 1288 | function(){ |
---|
| 1289 | $(this).removeClass('fc-state-hover'); |
---|
| 1290 | }).mousedown(function(){ |
---|
| 1291 | $(this).addClass('fc-state-down'); |
---|
| 1292 | }).mouseup(function(){ |
---|
| 1293 | $(this).removeClass('fc-state-down'); |
---|
| 1294 | $('.events-list.events-list-win.active').removeClass('active'); |
---|
| 1295 | var paginator = $(this).attr('class'); |
---|
| 1296 | if(paginator.indexOf('next') > 0){ |
---|
| 1297 | if(parseInt($(currentView+' [name = results]').val()) > 25) |
---|
| 1298 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1)); |
---|
| 1299 | }else{ |
---|
| 1300 | if(parseInt($(currentView+' [name = page_index]').val()) > 0) |
---|
| 1301 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1)); |
---|
| 1302 | } |
---|
| 1303 | }); |
---|
[5341] | 1304 | } |
---|
| 1305 | |
---|
| 1306 | function mountTitleList(page_index ,view){ |
---|
| 1307 | switch (view){ |
---|
| 1308 | case 'day': |
---|
[5345] | 1309 | case 'basicDay': |
---|
[5341] | 1310 | var date = new Date().add({days: page_index}); |
---|
| 1311 | return (weekOfDay(date.getDay()))+", "+(date.toString('dd MMM yyyy')); |
---|
[5345] | 1312 | case 'agendaWeek': |
---|
[5341] | 1313 | case 'week': |
---|
| 1314 | var dateStart = new Date().moveToDayOfWeek(dayOfWeek(User.preferences.weekDefault)); |
---|
| 1315 | dateStart.add({days: (7 * page_index)}); |
---|
| 1316 | var dateEnd = new Date().moveToDayOfWeek(dayOfWeek(User.preferences.weekDefault)); |
---|
| 1317 | dateEnd.add({days: (page_index * 7)+7}); |
---|
| 1318 | if(dateStart.toString('MM') != dateEnd.toString('MM')) |
---|
| 1319 | return dateStart.toString('dd')+' de '+sortMonthOfNumber(dateStart.getMonth())+' a '+dateEnd.toString('dd')+' de '+monthOfNumber(dateEnd.getMonth())+' - '+dateEnd.toString('yyyy'); |
---|
| 1320 | return +dateStart.toString("dd")+" a "+dateEnd.toString("dd")+" de "+monthOfNumber(dateEnd.getMonth())+" - "+dateEnd.toString('yyyy'); |
---|
| 1321 | case 'month': |
---|
| 1322 | var date = new Date().add({months: page_index}) |
---|
| 1323 | return monthOfNumber(date.getMonth())+" "+date.toString("yyyy"); |
---|
| 1324 | case 'year': |
---|
| 1325 | var date = new Date().add({years: page_index}); |
---|
| 1326 | return date.toString("yyyy"); |
---|
| 1327 | } |
---|
| 1328 | } |
---|
| 1329 | |
---|
| 1330 | function paginatorList(currentView, view){ |
---|
| 1331 | $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>'+mountTitleList( parseInt($('[name = page_index]').val()),view)+'</h2>'); |
---|
| 1332 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
[5345] | 1333 | if(view == 'basicDay') |
---|
| 1334 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-agendaday').addClass('fc-state-active'); |
---|
| 1335 | else |
---|
| 1336 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-'+((view == 'day' || view == 'week') ? 'agenda'+view : view )).addClass('fc-state-active'); |
---|
[5341] | 1337 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right').addClass('list-right'); |
---|
[5381] | 1338 | |
---|
| 1339 | $(currentView+' .header-paginator .fc-header-right .fc-button').hover( |
---|
[5341] | 1340 | function(){ |
---|
| 1341 | $(this).addClass('fc-state-hover'); |
---|
| 1342 | }, |
---|
| 1343 | function(){ |
---|
| 1344 | $(this).removeClass('fc-state-hover'); |
---|
| 1345 | }).mousedown(function(){ |
---|
| 1346 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') |
---|
| 1347 | $(this).addClass('fc-state-active'); |
---|
| 1348 | }).mouseup(function(){ |
---|
[5381] | 1349 | var goView = $(this).attr('class'); |
---|
| 1350 | if(goView.indexOf('agendaDay') > 0) |
---|
| 1351 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'day'); |
---|
| 1352 | else if(goView.indexOf('month') > 0) |
---|
| 1353 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'month'); |
---|
| 1354 | else if(goView.indexOf('year') > 0) |
---|
| 1355 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'year'); |
---|
| 1356 | else if(goView.indexOf('agendaWeek') > 0) |
---|
| 1357 | pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'week'); |
---|
| 1358 | |
---|
[5341] | 1359 | }); |
---|
[5381] | 1360 | |
---|
| 1361 | $(currentView+' .header-paginator .fc-header-left .fc-button').hover( |
---|
[5341] | 1362 | function(){ |
---|
| 1363 | $(this).addClass('fc-state-hover'); |
---|
| 1364 | }, |
---|
| 1365 | function(){ |
---|
| 1366 | $(this).removeClass('fc-state-hover'); |
---|
| 1367 | }).mousedown(function(){ |
---|
| 1368 | $(this).addClass('fc-state-down'); |
---|
| 1369 | }).mouseup(function(){ |
---|
| 1370 | $(this).removeClass('fc-state-down'); |
---|
[5381] | 1371 | var paginator = $(this).attr('class'); |
---|
| 1372 | if(paginator.indexOf('next') > 0) |
---|
| 1373 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) +1), '', view); |
---|
| 1374 | else |
---|
| 1375 | pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) -1), '', view); |
---|
| 1376 | }); |
---|
[5341] | 1377 | } |
---|
| 1378 | |
---|
| 1379 | function paginatorListEvent(currentView, typeView, view){ |
---|
| 1380 | if(!!$(currentView).find('.fc-calendar').length) |
---|
| 1381 | return; |
---|
| 1382 | $(currentView+' .events-list.events-list-win.active').prepend($('.fc-header').clone()); |
---|
| 1383 | //Remove contudo nao utilizado |
---|
| 1384 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-today').remove(); |
---|
| 1385 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicWeek').remove(); |
---|
| 1386 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-basicDay').remove(); |
---|
| 1387 | |
---|
| 1388 | //Adiciona e remove as classes para esta visualizacao |
---|
| 1389 | $(currentView+' .events-list.events-list-win.active .fc-header .fc-header-center').addClass('list-events-paginator'); |
---|
| 1390 | $(currentView+' .events-list.events-list-win.active .fc-header .list-events-paginator').removeClass('fc-header-center'); |
---|
| 1391 | |
---|
| 1392 | //Adicionar class no header padronizar com a tela principal |
---|
| 1393 | $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); |
---|
| 1394 | $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); |
---|
| 1395 | |
---|
| 1396 | if(typeView == 'search'){ |
---|
| 1397 | $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right').remove() |
---|
| 1398 | $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>Resultados para: '+$(currentView+' [name = keyword]').val()+'</h2>'); |
---|
| 1399 | if((parseInt($(currentView+' [name = page_index]').val()) == 0) && (parseInt($(currentView+' [name = results]').val()) <= 25)) |
---|
| 1400 | return; |
---|
| 1401 | paginatorSearch(currentView); |
---|
| 1402 | }else |
---|
| 1403 | paginatorList(currentView, view); |
---|
| 1404 | } |
---|
| 1405 | |
---|
| 1406 | function mountCriteriaList(view, page_index, calerdars_selecteds){ |
---|
| 1407 | switch (view){ |
---|
[5345] | 1408 | case 'basicDay': |
---|
[5341] | 1409 | case 'day': |
---|
| 1410 | return {filter: ['AND', ['IN', 'calendar', calerdars_selecteds], ['=', 'rangeEnd', new Date().add({days: page_index}).toString("yyyy-MM-dd")]], criteria: {order: 'startTime'}}; |
---|
[5345] | 1411 | case 'agendaWeek': |
---|
[5341] | 1412 | case 'week': |
---|
| 1413 | var dateStart = new Date().moveToDayOfWeek(dayOfWeek(User.preferences.weekDefault)); |
---|
| 1414 | var dateEnd = new Date().moveToDayOfWeek(dayOfWeek(User.preferences.weekDefault)); |
---|
| 1415 | return {filter: ['AND', ['IN', 'calendar', calerdars_selecteds], ['AND',['>=', 'rangeEnd', dateStart.add({days: (7 * page_index)}).toString("yyyy-MM-dd")], ['<=', 'rangeEnd', dateEnd.add({days: (7 * page_index)+7}).toString("yyyy-MM-dd")]]], criteria: {order: 'startTime'}}; |
---|
| 1416 | case 'month': |
---|
| 1417 | var date = new Date().add({months: page_index}) |
---|
| 1418 | return {filter: ['AND',['IN', 'calendar', calerdars_selecteds], ['AND',['>=', 'rangeEnd', date.moveToFirstDayOfMonth().toString("yyyy-MM-dd")], ['<=', 'rangeEnd', date.moveToLastDayOfMonth().toString("yyyy-MM-dd")]]], criteria: {order: 'startTime'}}; |
---|
| 1419 | case 'year': |
---|
| 1420 | var dateStart = new Date().add({years: page_index}); |
---|
| 1421 | var dateEnd = new Date().add({years: page_index}); |
---|
| 1422 | if(dateStart.getMonth() != 0) |
---|
| 1423 | dateStart.moveToMonth(0, -1) |
---|
| 1424 | if(dateEnd.getMonth() != 11) |
---|
| 1425 | dateEnd.moveToMonth(11) |
---|
| 1426 | return {filter: ['AND', ['IN', 'calendar', calerdars_selecteds], ['AND',['>=', 'rangeEnd', dateStart.moveToFirstDayOfMonth().toString("yyyy-MM-dd")], ['<=', 'rangeEnd', dateEnd.moveToLastDayOfMonth().toString("yyyy-MM-dd")]]], criteria: {order: 'startTime'}}; |
---|
| 1427 | } |
---|
| 1428 | } |
---|
| 1429 | |
---|
| 1430 | function pageselectCallback(keyword, page_index, jq, view){ |
---|
| 1431 | |
---|
| 1432 | var selecteds = getSelectedCalendars(); |
---|
| 1433 | if(!selecteds && (keyword != '' && keyword != null)){ |
---|
| 1434 | jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 1435 | '<div title="Lista de eventos" class="events-list events-list-win active empty">' + |
---|
| 1436 | '<label>Por favor selecione ao menos uma agenda.</label>' + |
---|
| 1437 | '</div>' |
---|
| 1438 | ); |
---|
| 1439 | }else{ |
---|
| 1440 | var criteria = null; |
---|
| 1441 | if(keyword == '' || keyword == null) |
---|
| 1442 | criteria = mountCriteriaList(!!view ? view : User.preferences.defaultCalView, page_index, selecteds) |
---|
| 1443 | else |
---|
| 1444 | criteria = {filter: ['AND', ['OR', ["i*", "summary", keyword], ["i*", "description", keyword]], ['IN', 'calendar', selecteds]], criteria: {order: 'startTime', offset: (25 * page_index), limit: (((25 * page_index) + 25) + 1)}}; |
---|
| 1445 | var results = DataLayer.get('schedulable:detail', criteria); |
---|
| 1446 | keyword = ( keyword || '' ).replace( /\s+/g, "_" ); |
---|
| 1447 | } |
---|
| 1448 | // não há resultados |
---|
| 1449 | if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) { |
---|
| 1450 | jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 1451 | '<div title="Lista de eventos" class="events-list events-list-win active empty">' + |
---|
| 1452 | '<label>Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' + |
---|
| 1453 | '</div>' |
---|
| 1454 | ); |
---|
| 1455 | // há resultados e Agendas Selecionadas |
---|
| 1456 | } else{ |
---|
| 1457 | if(typeof(results) != 'undefined'){ |
---|
| 1458 | results['page_index'] = page_index; |
---|
| 1459 | results['keyword'] = keyword; |
---|
| 1460 | |
---|
| 1461 | DataLayer.render( 'templates/event_list.ejs', results, function( html ){ |
---|
| 1462 | var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); |
---|
| 1463 | jQuery(currentView).html( html ); |
---|
| 1464 | jQuery('.events-list-win .menu-container .button').button(); |
---|
| 1465 | |
---|
| 1466 | $(".event-details-item").parent().click(function(){ |
---|
| 1467 | |
---|
| 1468 | $(this).siblings("div.details-event-list").toggleClass("hidden") |
---|
| 1469 | .find('.button.delete').click(function(){ |
---|
[5381] | 1470 | var eventId = $(this).siblings('[name="eventid"]').val(); |
---|
| 1471 | $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', { |
---|
| 1472 | 'type': 'question', |
---|
| 1473 | 'overlay_opacity': '0.5', |
---|
| 1474 | 'buttons': ['Sim', 'Não'], |
---|
| 1475 | 'onClose': function(clicked) { |
---|
| 1476 | if(clicked == 'Sim'){ |
---|
| 1477 | DataLayer.remove('schedulable', eventId); |
---|
| 1478 | } |
---|
| 1479 | } |
---|
| 1480 | }); |
---|
[5341] | 1481 | }) |
---|
| 1482 | .end().find('.button.edit').click(function(){ |
---|
| 1483 | eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); |
---|
| 1484 | }); |
---|
| 1485 | |
---|
| 1486 | }); |
---|
| 1487 | paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView); |
---|
| 1488 | }); |
---|
| 1489 | }else{ |
---|
| 1490 | var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); |
---|
| 1491 | jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( |
---|
| 1492 | '<div title="Lista de eventos" class="events-list events-list-win active empty">' + |
---|
| 1493 | '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ |
---|
| 1494 | '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ |
---|
| 1495 | '<label>Não foram encontrados eventos neste intervalo.</label>' + |
---|
| 1496 | '</div>' |
---|
| 1497 | ); |
---|
| 1498 | paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView); |
---|
| 1499 | } |
---|
| 1500 | |
---|
| 1501 | } |
---|
| 1502 | |
---|
| 1503 | } |
---|
| 1504 | |
---|
[5381] | 1505 | function show_modal_import_export(tab, calendarId) { |
---|
[5341] | 1506 | DataLayer.render( 'templates/import_export.ejs', {calendars: Calendar.calendars, owner: User.me.id}, function( html ){ |
---|
| 1507 | |
---|
| 1508 | if (!UI.dialogs.importCalendar) { |
---|
| 1509 | UI.dialogs.importCalendar = jQuery('#div-import-export-calendar') |
---|
| 1510 | .append('<div title="Importar e Exportar Eventos" class="import-export import-export-win active"> <div>') |
---|
| 1511 | .find('.import-export-win.active').html(html).dialog({ |
---|
| 1512 | resizable: false, |
---|
| 1513 | modal:true, |
---|
| 1514 | width:500, |
---|
| 1515 | position: 'center' |
---|
| 1516 | }); |
---|
| 1517 | |
---|
| 1518 | } else { |
---|
| 1519 | UI.dialogs.importCalendar.html(html); |
---|
| 1520 | } |
---|
| 1521 | |
---|
| 1522 | var tabsImportExport = UI.dialogs.importCalendar.find(".tabs-import-export").tabs({selected: tab}); |
---|
| 1523 | |
---|
| 1524 | UI.dialogs.importCalendar.find('.button').button(); |
---|
| 1525 | |
---|
[5381] | 1526 | tabsImportExport.find('option[value="'+calendarId+'"]').attr('selected','selected').trigger('change'); |
---|
| 1527 | |
---|
| 1528 | |
---|
[5341] | 1529 | UI.dialogs.importCalendar.find(".menu-import-event") |
---|
[5381] | 1530 | .children(".import").click(function(data){ |
---|
| 1531 | $('.import-event-form', UI.dialogs.importCalendar).submit(); |
---|
[5341] | 1532 | UI.dialogs.importCalendar.dialog("close"); |
---|
[5384] | 1533 | isValidCalback = true; |
---|
[5341] | 1534 | /** |
---|
| 1535 | * TODO - implementar ação de importação |
---|
| 1536 | */ |
---|
| 1537 | }); |
---|
| 1538 | |
---|
| 1539 | UI.dialogs.importCalendar.find(".menu-export-event") |
---|
| 1540 | .children(".export").click(function(){ |
---|
| 1541 | |
---|
| 1542 | $('.export-event-form', UI.dialogs.importCalendar).submit(); |
---|
| 1543 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 1544 | /** |
---|
| 1545 | * TODO - implementar ação de exportação |
---|
| 1546 | */ |
---|
| 1547 | }); |
---|
| 1548 | |
---|
| 1549 | UI.dialogs.importCalendar.find(".menu-container") |
---|
| 1550 | .children(".cancel").click(function(){ |
---|
| 1551 | UI.dialogs.importCalendar.dialog("close"); |
---|
| 1552 | }); |
---|
| 1553 | |
---|
| 1554 | UI.dialogs.importCalendar.dialog("open"); |
---|
| 1555 | }); |
---|
| 1556 | } |
---|
| 1557 | |
---|
| 1558 | function dayOfWeek(day) { |
---|
| 1559 | switch (day) { |
---|
| 1560 | case 'SUN': |
---|
| 1561 | return 0; |
---|
| 1562 | break; |
---|
| 1563 | case 'MON': |
---|
| 1564 | return 1; |
---|
| 1565 | break; |
---|
| 1566 | case 'TUE': |
---|
| 1567 | return 2; |
---|
| 1568 | break; |
---|
| 1569 | case 'WED': |
---|
| 1570 | return 3; |
---|
| 1571 | break; |
---|
| 1572 | case 'THU': |
---|
| 1573 | return 4; |
---|
| 1574 | break; |
---|
| 1575 | case 'FRI': |
---|
| 1576 | return 5; |
---|
| 1577 | break; |
---|
| 1578 | case 'SAT': |
---|
| 1579 | return 6; |
---|
| 1580 | break; |
---|
| 1581 | default: |
---|
| 1582 | return false; |
---|
| 1583 | break; |
---|
| 1584 | } |
---|
| 1585 | } |
---|
| 1586 | |
---|
| 1587 | function weekOfDay(week) { |
---|
| 1588 | switch (week) { |
---|
| 1589 | case 0: |
---|
| 1590 | return 'Domingo'; |
---|
| 1591 | case 1: |
---|
| 1592 | return 'Segunda'; |
---|
| 1593 | case 2: |
---|
| 1594 | return 'Terça'; |
---|
| 1595 | case 3: |
---|
| 1596 | return 'Quarta'; |
---|
| 1597 | case 4: |
---|
| 1598 | return 'Quinta'; |
---|
| 1599 | case 5: |
---|
| 1600 | return 'Sexta'; |
---|
| 1601 | case 6: |
---|
| 1602 | return 'Sábado'; |
---|
| 1603 | default: |
---|
| 1604 | return false; |
---|
| 1605 | } |
---|
| 1606 | } |
---|
| 1607 | |
---|
| 1608 | function monthOfNumber(number) { |
---|
| 1609 | switch (number) { |
---|
| 1610 | case 0: |
---|
| 1611 | return 'Janeiro'; |
---|
| 1612 | case 1: |
---|
| 1613 | return 'Fevereiro'; |
---|
| 1614 | case 2: |
---|
| 1615 | return 'Março'; |
---|
| 1616 | case 3: |
---|
| 1617 | return 'Abril'; |
---|
| 1618 | case 4: |
---|
| 1619 | return 'Maio'; |
---|
| 1620 | case 5: |
---|
| 1621 | return 'Junho'; |
---|
| 1622 | case 6: |
---|
| 1623 | return 'Julho'; |
---|
| 1624 | case 7: |
---|
| 1625 | return 'Agosto'; |
---|
| 1626 | case 8: |
---|
| 1627 | return 'Setembro'; |
---|
| 1628 | case 9: |
---|
| 1629 | return 'Outubro'; |
---|
| 1630 | case 10: |
---|
| 1631 | return 'Novembro'; |
---|
| 1632 | case 11: |
---|
| 1633 | return 'Dezembro'; |
---|
| 1634 | default: |
---|
| 1635 | return false; |
---|
| 1636 | } |
---|
| 1637 | } |
---|
| 1638 | |
---|
| 1639 | function sortMonthOfNumber(number) { |
---|
| 1640 | switch (number) { |
---|
| 1641 | case 0: |
---|
| 1642 | return 'Jan'; |
---|
| 1643 | case 1: |
---|
| 1644 | return 'Fev'; |
---|
| 1645 | case 2: |
---|
| 1646 | return 'Mar'; |
---|
| 1647 | case 3: |
---|
| 1648 | return 'Abr'; |
---|
| 1649 | case 4: |
---|
| 1650 | return 'Mai'; |
---|
| 1651 | case 5: |
---|
| 1652 | return 'Jun'; |
---|
| 1653 | case 6: |
---|
| 1654 | return 'Jul'; |
---|
| 1655 | case 7: |
---|
| 1656 | return 'Ago'; |
---|
| 1657 | case 8: |
---|
| 1658 | return 'Set'; |
---|
| 1659 | case 9: |
---|
| 1660 | return 'Out'; |
---|
| 1661 | case 10: |
---|
| 1662 | return 'Nov'; |
---|
| 1663 | case 11: |
---|
| 1664 | return 'Dez'; |
---|
| 1665 | default: |
---|
| 1666 | return false; |
---|
| 1667 | } |
---|
| 1668 | } |
---|