Changeset 6754 for branches/2.4/prototype/modules/calendar/js/helpers.js
- Timestamp:
- 07/11/12 11:45:10 (12 years ago)
- Location:
- branches/2.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.4
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk merged eligible /sandbox/2.4.1-3 6237-6527
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/2.4/prototype/modules/calendar/js/helpers.js
r6734 r6754 13 13 14 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 }; 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 35 36 36 var start_date = $(".new-event-win.active .start-date").val(); … … 44 44 45 45 if(start_date == "") 46 return errors['emptyInitData'];46 return errors['emptyInitData']; 47 47 else if(end_date == "") 48 return errors['emptyEndData'];48 return errors['emptyEndData']; 49 49 else if(!isAllDay && start_time == "") 50 return errors['emptyInitHour'];50 return errors['emptyInitHour']; 51 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 );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 58 59 59 if(startDate == null || startDate.getTime() < 0 ) 60 return errors['invalidInitData'];60 return errors['invalidInitData']; 61 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 else79 return errors['equalData'];80 81 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 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 } 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 93 94 94 if (!($('.new-event-win.active p.input-group.finish_event.repeat-in').hasClass('hidden'))){ 95 95 if (!eventInterval.length) 96 return errors['emptyInterval'];96 return errors['emptyInterval']; 97 97 else if (parseInt(eventInterval,10) < 1 || parseInt(eventInterval,10).toString() == "NaN") 98 return errors['invalidInterval'];98 return errors['invalidInterval']; 99 99 } 100 100 return false; … … 337 337 $('.qtip-active').find('input[name="'+acl_names[aclsParticipant.charAt(i)]+'"]').attr('checked', true); 338 338 } 339 340 $('.qtip .button').button(); 339 341 340 341 $('.qtip .button').button();342 342 }; 343 343 }else{ … … 402 402 position: 'center', 403 403 close: function(event, ui) { 404 404 /** 405 405 * Remove tooltip possivelmente existente 406 406 */ 407 if ($('.qtip.qtip-blue.qtip-active').length) 408 $('.qtip.qtip-blue.qtip-active').qtip('destroy'); 409 attendees = {}; 410 407 if ($('.qtip.qtip-blue.qtip-active').length) 408 $('.qtip.qtip-blue.qtip-active').qtip('destroy'); 409 attendees = {}; 411 410 }, 412 411 beforeClose: function(event, ui) { … … 442 441 zebraDiscardEventDialog = false; 443 442 } 444 445 /**446 * Uma vez aberta uma janela de confirmação (Zebra_Dialog), ao fechá-la447 * com ESC, para que o evento ESC não seja propagado para fechamento da 448 * janela de edição de eventos, deve ser setada uma flag indicando que 449 * já existe uma janela de confirmação aberta. 450 */ 443 444 /** 445 * Uma vez aberta uma janela de confirmação (Zebra_Dialog), ao fechá-la 446 * com ESC, para que o evento ESC não seja propagado para fechamento da 447 * janela de edição de eventos, deve ser setada uma flag indicando que 448 * já existe uma janela de confirmação aberta. 449 */ 451 450 if (!clicked) { 452 451 window.setTimeout(function() { … … 462 461 //DataLayer.rollback(); 463 462 return canDiscardEventDialog; 464 }, 465 dragStart: function(event, ui) { 466 if ($('.qtip.qtip-blue.qtip-active').length) 467 463 }, 464 dragStart: function(event, ui) { 465 if ($('.qtip.qtip-blue.qtip-active').length) 466 $('.qtip.qtip-blue.qtip-active').qtip('destroy'); 468 467 } 469 468 }); … … 473 472 } 474 473 475 var tabs = UI.dialogs.addEvent.children('.content').tabs({ 476 select: function(event, ui) {477 if ($('.qtip.qtip-blue.qtip-active').length) 478 $('.qtip.qtip-blue.qtip-active').qtip('destroy'); 479 } 480 474 var tabs = UI.dialogs.addEvent.children('.content').tabs({ 475 select: function(event, ui) { 476 if ($('.qtip.qtip-blue.qtip-active').length) 477 $('.qtip.qtip-blue.qtip-active').qtip('destroy'); 478 } 479 }); 481 480 var calendar = DataLayer.get('calendar', objEvent.calendar); 482 481 … … 493 492 494 493 UI.dialogs.addEvent.find('#calendar_addevent_details3').html(repeatHtml); 495 $(".date").datepicker({ 496 dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy') 497 }); 494 $(".date").datepicker({ 495 dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy') 496 }); 498 497 499 498 if(objEvent.repeat) … … 675 674 } 676 675 677 /*Seleciona a agenda padrão para visualização/edição de um evento*/ 678 if(objEvent.id) 679 UI.dialogs.addEvent.find('option[value="'+objEvent.calendar+'"]').attr('selected','selected').trigger('change'); 680 676 /*Seleciona a agenda padrão para visualização/edição de um evento*/ 677 if(objEvent.id) 678 UI.dialogs.addEvent.find('option[value="'+objEvent.calendar+'"]').attr('selected','selected').trigger('change'); 679 681 680 /*Adicionar alarms padrões, quando alterado a agenda do usuário*/ 682 681 UI.dialogs.addEvent.find('select[name="calendar"]').change(function(){ … … 704 703 } 705 704 706 var participant = UI.dialogs.addEvent.find('dd.me input[name="attendee[]"]').val(); 707 var calendar = $(this).val();708 709 if( !parseInt(Calendar.signatureOf[calendar].isOwner) ){710 var signature = Calendar.signatureOf[calendar]; 705 var participant = UI.dialogs.addEvent.find('dd.me input[name="attendee[]"]').val(); 706 var calendar = $(this).val(); 707 708 if( !parseInt(Calendar.signatureOf[calendar].isOwner) ){ 709 var signature = Calendar.signatureOf[calendar]; 711 710 var organizer = DataLayer.get('calendarSignature', { 712 711 filter: ['AND', ['=','calendar',signature.calendar.id], ['=','isOwner','1']], … … 1554 1553 if(acls.remove) 1555 1554 UI.dialogs.addEvent.find('.button.remove').show(); 1556 1557 UI.dialogs.addEvent.find('.button.cancel').show(); 1555 1556 UI.dialogs.addEvent.find('.button.cancel').show(); 1558 1557 } 1559 1558 … … 1561 1560 1562 1561 /*Seleciona a agenda padrão para criação de um evento*/ 1563 if(!objEvent.id){ 1564 var selectedCalendar = (objEvent.calendar != undefined) ? objEvent.calendar : (User.preferences.defaultCalendar ? User.preferences.defaultCalendar : myCalendar()); 1565 UI.dialogs.addEvent.find('option[value="'+selectedCalendar+'"]').attr('selected','selected').trigger('change'); 1566 } 1562 if(!objEvent.id){ 1563 var selectedCalendar = (objEvent.calendar != undefined) ? objEvent.calendar : (User.preferences.defaultCalendar ? User.preferences.defaultCalendar : myCalendar()); 1564 UI.dialogs.addEvent.find('option[value="'+selectedCalendar+'"]').attr('selected','selected').trigger('change'); 1565 } 1567 1566 UI.dialogs.addEvent.find(':input').change(function(event){ 1568 1567 if (event.keyCode != '27' && event.keyCode != '13') … … 1697 1696 var signatures = []; 1698 1697 var previewActiveCalendarConf = 0; 1699 var calendarAlarms = []; 1700 1698 var calendarAlarms = []; 1699 1701 1700 for (var i=0; i<Calendar.signatures.length; i++) { 1702 1701 calendars[i] = Calendar.signatures[i].calendar; … … 1722 1721 var populateAccordionOnActive = function(event, ui) { 1723 1722 var nowActive = (typeof(event) == 'number') ? event : $(event.target).accordion( "option", "active" ); 1724 if (nowActive === false) 1725 1723 if (nowActive === false) 1724 return; 1726 1725 dataColorPicker.colorsDefined = { 1727 1726 border: '#'+signatures[nowActive].borderColor, … … 1746 1745 }); 1747 1746 form_content.find('.button').button(); 1748 jQuery('.preferences-alarms-list').find('.button.remove').click(function(el){ 1749 calendarAlarms[calendarAlarms.length] = $(this).parent('li').find('input[name="alarmId[]"]').val(); 1750 $(this).parent().remove(); 1751 }); 1747 jQuery('.preferences-alarms-list').find('.button.remove').click(function(el){ 1748 calendarAlarms[calendarAlarms.length] = $(this).parent('li').find('input[name="alarmId[]"]').val(); 1749 $(this).parent().remove(); 1750 }); 1752 1751 1753 1752 DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ … … 1868 1867 var template_content = jQuery('#configure_tab').html( template ).find('.configure-calendars-win'); 1869 1868 template_content.find('.button').button().filter('.save').click(function(evt){ 1870 if(calendarAlarms.length) 1871 DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]}); 1869 if(calendarAlarms.length) 1870 DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]}); 1872 1871 template_content.find('form').submit(); 1873 1872 $tabs.tabs( "remove", "#configure_tab"); … … 1877 1876 refresh_calendars(); 1878 1877 }); 1879 if(calendarAlarms.length) 1880 Calendar.load(); 1878 if(calendarAlarms.length) 1879 Calendar.load(); 1881 1880 }).end().filter('.cancel').click(function(evt){ 1882 1881 $tabs.tabs( "remove", "#configure_tab"); … … 1904 1903 1905 1904 } else { 1906 $('.positionHelper').css('display','none');1907 1905 $('.positionHelper').css('display','none'); 1906 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); 1908 1907 $tabs.tabs("select", "#configure_tab"); 1909 1908 $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); … … 2070 2069 var meu_container = $(".calendars-list").html( html ); 2071 2070 2072 var doMenu = function(){ 2073 $('ul.list-calendars .cal-list-options-btn').each(function(){2074 $(this).menu({2075 content: $(this).next().html(),2076 width: '120',2077 positionOpts: {2078 posX: 'left',2079 posY: 'bottom',2080 offsetX: 0,2081 offsetY: 0,2082 directionH: 'right',2083 directionV: 'down',2084 detectH: true, // do horizontal collision detection2085 detectV: true, // do vertical collision detection2086 linkToFront: false2087 },2088 flyOut: true,2089 showSpeed: 100,2090 crumbDefaultText: '>'2091 });2092 }); 2093 } 2094 doMenu(); 2095 $('#divAppbox').on('scroll',function(){ 2096 if ($('.cal-list-options-btn.fg-menu-open.ui-state-active')){ 2097 var offset = $('.cal-list-options-btn.fg-menu-open.ui-state-active').offset(); 2098 if (offset) 2099 $('.positionHelper').css('top',offset.top); 2100 } 2101 }); 2102 $('ul.list-calendars .cal-list-options-btn').on('click',function(){doMenu();}); 2103 2071 var doMenu = function(){ 2072 $('ul.list-calendars .cal-list-options-btn').each(function(){ 2073 $(this).menu({ 2074 content: $(this).next().html(), 2075 width: '120', 2076 positionOpts: { 2077 posX: 'left', 2078 posY: 'bottom', 2079 offsetX: 0, 2080 offsetY: 0, 2081 directionH: 'right', 2082 directionV: 'down', 2083 detectH: true, // do horizontal collision detection 2084 detectV: true, // do vertical collision detection 2085 linkToFront: false 2086 }, 2087 flyOut: true, 2088 showSpeed: 100, 2089 crumbDefaultText: '>' 2090 }); 2091 }); 2092 } 2093 doMenu(); 2094 $('#divAppbox').on('scroll',function(){ 2095 if ($('.cal-list-options-btn.fg-menu-open.ui-state-active')){ 2096 var offset = $('.cal-list-options-btn.fg-menu-open.ui-state-active').offset(); 2097 if (offset) 2098 $('.positionHelper').css('top',offset.top); 2099 } 2100 }); 2101 $('ul.list-calendars .cal-list-options-btn').on('click',function(){doMenu();}); 2102 2104 2103 meu_container.find(".button.new-calendar").button({ 2105 2104 icons: { … … 2544 2543 // não há resultados 2545 2544 2546 var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); 2545 var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); 2547 2546 2548 2547 if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) { 2549 $(currentView).html( 2550 '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 2551 '<label>Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' + 2552 '</div>' 2548 $(currentView).html( 2549 '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 2550 '<label>Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' + 2551 '</div>' 2553 2552 ); 2554 2553 // há resultados e Agendas Selecionadas 2555 2554 } else{ 2556 2555 if(typeof(results) != 'undefined'){ 2557 results['page_index'] = page_index; 2558 results['keyword'] = keyword;2559 2560 DataLayer.render( 'templates/event_list.ejs', results, function( html ){2561 2562 $(currentView).html( html );2563 $('.events-list-win .menu-container .button').button();2564 2565 $(".event-details-item").parent().click(function(){2566 2567 $(this).siblings("div.details-event-list").toggleClass("hidden")2568 .find('.button.delete').click(function(){2569 var eventId = $(this).siblings('[name="eventid"]').val();2570 var calendarId = $(this).siblings('[name="calendarid"]').val();2571 2572 remove_event(eventId, calendarId);2573 })2574 .end().find('.button.edit').click(function(){2575 eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true );2576 });2577 2578 });2579 paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView);2556 results['page_index'] = page_index; 2557 results['keyword'] = keyword; 2558 2559 DataLayer.render( 'templates/event_list.ejs', results, function( html ){ 2560 2561 $(currentView).html( html ); 2562 $('.events-list-win .menu-container .button').button(); 2563 2564 $(".event-details-item").parent().click(function(){ 2565 2566 $(this).siblings("div.details-event-list").toggleClass("hidden") 2567 .find('.button.delete').click(function(){ 2568 var eventId = $(this).siblings('[name="eventid"]').val(); 2569 var calendarId = $(this).siblings('[name="calendarid"]').val(); 2570 2571 remove_event(eventId, calendarId); 2572 }) 2573 .end().find('.button.edit').click(function(){ 2574 eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2575 }); 2576 2577 }); 2578 paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView); 2580 2579 }); 2581 2580 }else{ 2582 $(currentView).html(2583 '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 2584 '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ 2585 '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ 2586 '<label class="empty-result">Não foram encontrados eventos neste intervalo.</label>' + 2587 '</div>' 2588 ); 2589 paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView); 2590 } 2591 } 2592 if(currentView != '#tab_events_list_') 2593 $tabs.tabs("select", currentView); 2581 $(currentView).html( 2582 '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 2583 '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ 2584 '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ 2585 '<label class="empty-result">Não foram encontrados eventos neste intervalo.</label>' + 2586 '</div>' 2587 ); 2588 paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView); 2589 } 2590 } 2591 if(currentView != '#tab_events_list_') 2592 $tabs.tabs("select", currentView); 2594 2593 } 2595 2594 … … 2806 2805 2807 2806 } 2808 } 2809 2810 function messageHelper(msg, isShow){ 2811 if(isShow) 2812 new $.Zebra_Dialog('<span style="width: 50px; height: 50px;">'+ 2813 '<img src="'+DataLayer.dispatchPath+'/modules/calendar/img/loading.gif"></img>'+ 2814 '</span><label class="messagesHelpers"> '+ msg +' </label>' , { 2815 'buttons': false, 2816 'modal': true, 2817 'overlay_opacity': '0.5', 2818 'keyboard': false, 2819 'overlay_close': false, 2820 'type': false, 2821 'custom_class': 'messagesHelpersExpressoCalendar' 2822 } 2823 ); 2824 else{ 2825 $('.messagesHelpersExpressoCalendar').remove(); 2826 $('.ZebraDialogOverlay').remove(); 2827 } 2828 } 2807 } 2808 2809 function messageHelper(msg, isShow){ 2810 if(isShow) 2811 new $.Zebra_Dialog('<span style="width: 50px; height: 50px;">'+ 2812 '<img src="'+DataLayer.dispatchPath+'/modules/calendar/img/loading.gif"></img>'+ 2813 '</span><label class="messagesHelpers"> '+ msg +' </label>' , { 2814 'buttons': false, 2815 'modal': true, 2816 'overlay_opacity': '0.5', 2817 'keyboard': false, 2818 'overlay_close': false, 2819 'type': false, 2820 'custom_class': 'messagesHelpersExpressoCalendar' 2821 } 2822 ); 2823 else{ 2824 $('.messagesHelpersExpressoCalendar').remove(); 2825 $('.ZebraDialogOverlay').remove(); 2826 } 2827 }
Note: See TracChangeset
for help on using the changeset viewer.