Changeset 7228 for branches/2.4/prototype/modules/calendar/js/helpers.js
- Timestamp:
- 09/17/12 14:30:47 (12 years ago)
- Location:
- branches/2.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.4
- Property svn:mergeinfo changed
-
branches/2.4/prototype/modules/calendar/js/helpers.js
r6972 r7228 101 101 } 102 102 103 /* 104 function listEvents(){ 105 var list = $('.fc-header-right').find('.fc-button.fc-button-agendaDay').clone(); 103 function printNow(){ 104 if($("#calendar").fullCalendar('getView').name == "agendaWeek" || $("#calendar").fullCalendar('getView').name == "basicWeek" || $("#calendar").fullCalendar('getView').name == "year") 105 alert('A tela de impressão será melhor visualizada com a preferência "Paisagem" do seu browser selecionada.'); 106 107 var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); 108 window_print.document.open(); 109 110 var start = $("#calendar").fullCalendar('getView').visStart.getTime()/1000; 111 var end = $("#calendar").fullCalendar('getView').visEnd.getTime()/1000; 112 var criteria = DataLayer.criteria("schedulable:calendar", {'start':start, 'end':end} ); 113 114 var data = DataLayer.get("schedulable:print", criteria); 115 116 if($("#calendar").fullCalendar('getView').name == "month"){ 117 window_print.document.write(DataLayer.render('templates/calendar_month_print.ejs', { 118 'InfoPage' : $("#calendar").fullCalendar('getView').title, 119 'days' : data 120 } )); 121 } 122 if($("#calendar").fullCalendar('getView').name == "agendaDay" || $("#calendar").fullCalendar('getView').name == "basicDay"){ 123 window_print.document.write(DataLayer.render('templates/calendar_day_print.ejs', { 124 'InfoPage' : $("#calendar").fullCalendar('getView').title, 125 'days' : data 126 } )); 127 } 128 if($("#calendar").fullCalendar('getView').name == "agendaWeek" || $("#calendar").fullCalendar('getView').name == "basicWeek"){ 129 window_print.document.write(DataLayer.render('templates/calendar_week_print.ejs', { 130 'InfoPage' : $("#calendar").fullCalendar('getView').title, 131 'days' : data 132 })); 133 134 var aux = 0; 135 setTimeout(function(){$(window_print.document).find(".all-day").each(function(){ 136 if($(this).height() > aux) 137 aux = $(this).height(); 138 }); 139 $(window_print.document).find(".all-day").each(function(){ 140 $(this).height(aux); 141 }); 142 $(window_print.document).find(".all-day-line .write").height(aux); 143 aux = 0; 144 },20); 145 } 146 if($("#calendar").fullCalendar('getView').name == "year"){ 147 window_print.document.write(DataLayer.render('templates/calendar_year_print.ejs', { 148 'html' : $('#calendar .fc-content').html(), 149 'header': $('#calendar').find('.fc-header-center h2').text() 150 } )); 151 } 152 window_print.document.close(); 153 window_print.print(); 154 } 155 156 function printEvents(){ 157 //var html = DataLayer.render( path + 'templates/attendee_permissions.ejs', {} ); 158 var print = $('.fc-header-right').find('.fc-button.fc-button-agendaDay').clone(); 159 106 160 $('.fc-header-right').find('.fc-button-year').toggleClass('fc-corner-right'); 107 list.addClass('fc-corner-right'); 108 list.addClass('fc-button-listagem'); 109 list.removeClass('fc-button-agendaDay'); 110 list.removeClass('fc-corner-left'); 111 list.find('.fc-button-content').html('Listagem'); 112 $('.fc-header-right').append(list); 113 } 114 */ 161 print.addClass('fc-corner-right'); 162 print.addClass('fc-button-print'); 163 print.removeClass('fc-button-agendaDay'); 164 print.removeClass('fc-corner-left'); 165 print.find('.fc-button-content').html('Imprimir'); 166 $('.fc-header-right').append(print); 167 $('.fc-button-print').click(function(){ 168 printNow(); 169 }); 170 } 115 171 116 172 /* … … 122 178 function eventDetails( objEvent, decoded, path, isMail, repeat) 123 179 { 180 181 $('.qtip.qtip-blue').remove(); 182 124 183 attendees = {}; 125 184 … … 399 458 modal:true, 400 459 autoOpen: false, 401 width:70 2,460 width:701, 402 461 position: 'center', 403 462 close: function(event, ui) { … … 883 942 timeFormat: "hh:mm tt", 884 943 onSelect: function (selectedDateTime){ 885 if(!(User.preferences.hourFormat.length == 5)) 886 $(this).val(selectedDateTime.replace(/[\.]/gi, "")); 887 updateMap(); 944 if ((selectedDateTime.value == '__:__') || (selectedDateTime.value == '__:__ __')) 945 selectedDateTime.value = ""; 946 if(!(User.preferences.hourFormat.length == 5)) 947 $(this).val(selectedDateTime.replace(/[\.]/gi, "")); 948 updateMap(); 888 949 }, 889 950 onClose : function (selectedDateTime){ 890 951 if(!(User.preferences.hourFormat.length == 5)) 891 952 $(this).val(selectedDateTime.replace(/[\.]/gi, "")); 953 }, 954 beforeShow: function (selectedDateTime) { 955 if ((selectedDateTime.value == '__:__') || (selectedDateTime.value == '__:__ __')) 956 selectedDateTime.value = ""; 892 957 } 893 958 }); … … 936 1001 // load template of attendees 937 1002 var blkAddAtendee = UI.dialogs.addEvent.find('#calendar_addevent_details6').append(attendeeHtml); 938 if(objEvent.attendee.length) 939 callbackAttendee(); 1003 if(objEvent.attendee.length) 1004 callbackAttendee(); 940 1005 /** 941 942 1006 Opções de delegação do participante/organizer 1007 */ 943 1008 blkAddAtendee.find(".button.participant-delegate").button({ 944 1009 icons: { … … 968 1033 969 1034 UI.dialogs.addEvent.find(".attendee-list-add .add-attendee-input input").Watermark("digite um email para convidar"); 970 /* Trata a edição de um novo participante adicionado971 * 972 1035 /* 1036 * Trata a edição de um novo participante adicionado 1037 */ 973 1038 var hasNewAttendee = false; 974 1039 … … 978 1043 979 1044 blkAddAtendee.find('.attendee-list-add .add-attendee-input input').keydown(function(event) { 980 981 1045 if (event.keyCode == '13' && $(this).val() != '' || (event.keyCode == undefined && $(this).val() != '')) { 982 1046 Encoder.EncodeType = "entity"; … … 990 1054 991 1055 /** 992 993 1056 * email válido? 1057 */ 994 1058 info.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/) ? 995 1059 newAttendeeEmail = info : newAttendeeName = info; 996 1060 997 1061 /** 998 999 1000 1001 1002 1003 1004 1005 1062 * 1) busca no banco para saber se o usuário já existe 1063 * 1.1) se existe, atualiza as info na lista de participantes e nao abre o tooltip 1064 * 1.2) se não existe 1065 * a) salva como novo usuario externo no banco (apenas com email) 1066 * b) exibe tooltip pedindo o nome 1067 * c) se o usuário preenche tooltip e salva, atualiza com o nome o usuário recém criado 1068 * d) se o usuário cancela o tooltip, fica o usuário salvo apenas com email e sem nome 1069 */ 1006 1070 1007 1071 var user = DataLayer.get('user', ["=", "mail", $(this).val()]); … … 1012 1076 1013 1077 /** 1014 1015 1078 * guarda o último tooltip aberto referente à lista de participantes 1079 */ 1016 1080 lastEditAttendeeToolTip = []; 1017 1081 1018 1082 /** 1019 1020 1083 * Valida email e salva um participante externo 1084 */ 1021 1085 var saveContact = function() { 1022 1086 Encoder.EncodeType = "entity"; … … 1192 1256 $(this).val(''); 1193 1257 1194 } else if (!skipAddNewLine) { 1258 } else if (!skipAddNewLine) { 1195 1259 /** 1196 1197 1198 1260 * a) salva como novo usuario externo no banco (apenas com email) e... 1261 * adiciona novo contato externo à lista de convidados 1262 */ 1199 1263 1200 1264 userId = DataLayer.put('user', { … … 1285 1349 1286 1350 /** 1287 1288 1351 * Trata a busca de usuários para adição de participantes 1352 */ 1289 1353 blkAddAtendee.find('.add-attendee-search .ui-icon-search').click(function(event) { 1290 1354 blkAddAtendee.find('.add-attendee-search input').keydown(); … … 1374 1438 } 1375 1439 }); 1440 1376 1441 //$('.block-add-attendee .search-result-list').selectable(); 1377 1442 … … 1395 1460 }); 1396 1461 }); 1397 $('.attachment-list input').remove(); 1398 $('.row.fileupload-buttonbar .attachments-list p').remove(); 1462 $('div.new-event-win .attachment-list input').remove(); 1463 $('div.new-event-win .row.fileupload-buttonbar .attachments-list p').remove(); 1464 $('div.new-event-win .btn-danger.delete').addClass('hidden'); 1399 1465 } 1400 1466 }}); … … 1415 1481 text: false 1416 1482 }); 1417 var maxSizeFile = 2000000; 1418 $('#fileupload').fileupload({ 1419 sequentialUploads: true, 1420 add: function (e, data) { 1421 if(data.files[0].size < maxSizeFile) 1422 data.submit(); 1423 }, 1424 change: function (e, data) { 1425 $.each(data.files, function (index, file) { 1426 var attach = {}; 1427 attach.fileName = file.name; 1428 var ext = file.name.split('.'); 1429 if(file.name.length > 10) 1430 attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; 1431 attach.fileSize = formatBytes(file.size); 1432 if(file.size > maxSizeFile) 1433 attach.error = 'Tamanho de arquivo nao permitido!!' 1434 1435 $('.attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { 1436 file : attach 1437 })); 1438 1439 if(file.size < maxSizeFile){ 1440 $('.fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 1441 $('.attachments-list').find('[type=file]').addClass('hidden'); 1442 1443 }else 1444 $('.fileinput-button.new').removeClass('new'); 1445 1446 1447 $('.attachments-list').find('.button.close').button({ 1448 icons: { 1449 primary: "ui-icon-close" 1450 }, 1451 text: false 1452 }).click(function(){ 1453 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 1454 $('.attachment-list').find('input[value="'+idAttach+'"]') 1455 $(this).parent().remove(); 1456 }); 1457 1458 }) 1459 }, 1460 done: function(e, data){ 1461 var currentUpload = $('.progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 1462 1463 if(!!data.result && data.result != "[]"){ 1464 var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 1465 $('.attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); 1466 currentUpload.removeClass('on-complete').parents('p') 1467 .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') 1468 .find('.status-upload').addClass('ui-icon ui-icon-check'); 1469 }else 1470 currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 1471 } 1472 }); 1473 $('.attachments-list .button').button(); 1474 1475 if(!!window.FormData) 1476 $('#fileupload').bind('fileuploadstart', function () { 1477 var widget = $(this), 1478 progressElement = $('#fileupload-progress').fadeIn(), 1479 interval = 500, 1480 total = 0, 1481 loaded = 0, 1482 loadedBefore = 0, 1483 progressTimer, 1484 progressHandler = function (e, data) { 1485 loaded = data.loaded; 1486 total = data.total; 1487 }, 1488 stopHandler = function () { 1489 widget 1490 .unbind('fileuploadprogressall', progressHandler) 1491 .unbind('fileuploadstop', stopHandler); 1492 window.clearInterval(progressTimer); 1493 progressElement.fadeOut(function () { 1494 progressElement.html(''); 1495 }); 1496 }, 1497 formatTime = function (seconds) { 1498 var date = new Date(seconds * 1000); 1499 return ('0' + date.getUTCHours()).slice(-2) + ':' + 1500 ('0' + date.getUTCMinutes()).slice(-2) + ':' + 1501 ('0' + date.getUTCSeconds()).slice(-2); 1502 }, 1503 /* formatBytes = function (bytes) { 1504 if (bytes >= 1000000000) { 1505 return (bytes / 1000000000).toFixed(2) + ' GB'; 1506 } 1507 if (bytes >= 1000000) { 1508 return (bytes / 1000000).toFixed(2) + ' MB'; 1509 } 1510 if (bytes >= 1000) { 1511 return (bytes / 1000).toFixed(2) + ' KB'; 1512 } 1513 return bytes + ' B'; 1514 },*/ 1515 formatPercentage = function (floatValue) { 1516 return (floatValue * 100).toFixed(2) + ' %'; 1517 }, 1518 updateProgressElement = function (loaded, total, bps) { 1519 progressElement.html( 1520 formatBytes(bps) + 'ps | ' + 1521 formatTime((total - loaded) / bps) + ' | ' + 1522 formatPercentage(loaded / total) + ' | ' + 1523 formatBytes(loaded) + ' / ' + formatBytes(total) 1524 ); 1525 }, 1526 intervalHandler = function () { 1527 var diff = loaded - loadedBefore; 1528 if (!diff) { 1529 return; 1530 } 1531 loadedBefore = loaded; 1532 updateProgressElement( 1533 loaded, 1534 total, 1535 diff * (1000 / interval) 1536 ); 1537 }; 1538 widget 1539 .bind('fileuploadprogressall', progressHandler) 1540 .bind('fileuploadstop', stopHandler); 1541 progressTimer = window.setInterval(intervalHandler, interval); 1542 }); 1483 1484 extendsFileupload('event', path); 1543 1485 1544 1486 if(objEvent.isShared){ … … 1557 1499 } 1558 1500 1559 disponibily(objEvent, path, attendees );1501 disponibily(objEvent, path, attendees, 'event'); 1560 1502 1561 1503 /*Seleciona a agenda padrão para criação de um evento*/ … … 1573 1515 1574 1516 UI.dialogs.addEvent.dialog('open'); 1575 //$('[href="#calendar_addevent_details7"]').trigger('click'); 1576 //$('[href="#calendar_addevent_details2"]').trigger('click'); 1517 1577 1518 } 1578 1519 … … 1691 1632 1692 1633 1693 function add_tab_configure_calendar(calendar )1634 function add_tab_configure_calendar(calendar, type) 1694 1635 { 1636 $('.qtip.qtip-blue').remove(); 1637 1695 1638 var calendars = []; 1696 1639 var signatures = []; … … 1698 1641 var calendarAlarms = []; 1699 1642 1700 for (var i=0; i<Calendar.signatures.length; i++) { 1701 calendars[i] = Calendar.signatures[i].calendar; 1702 signatures[i] = Calendar.signatures[i]; 1703 signatures[i].numberDefaultAlarm = signatures[i].defaultAlarms != '' ? signatures[i].defaultAlarms.length: 0; 1704 if (calendar && calendars[i].id == calendar) 1705 previewActiveCalendarConf = i; 1706 } 1707 1708 if(!(document.getElementById('configure_tab'))) 1643 for (var i=0; i<Calendar.signatures.length; i++) { 1644 if(parseInt(Calendar.signatures[i].calendar.type) == type){ 1645 calendars.push(Calendar.signatures[i].calendar); 1646 signatures.push(Calendar.signatures[i]); 1647 length = signatures.length - 1; 1648 signatures[length].numberDefaultAlarm = signatures[length].defaultAlarms != '' ? signatures[length].defaultAlarms.length: 0; 1649 if (calendar && calendars[length].id == calendar) 1650 previewActiveCalendarConf = length; 1651 } 1652 } 1653 var tab_selector = ['configure_tab', 'configure_tab_group']; 1654 if(!(document.getElementById(tab_selector[type]))) 1709 1655 { 1710 1656 $('.positionHelper').css('display', 'none'); 1711 1657 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); 1712 var tab_title = "Configurações de agendas"; 1713 $tabs.tabs( "add", "#configure_tab", tab_title ); 1658 if(type == 0){ 1659 var tab_title = "Configurações de agendas"; 1660 }else{ 1661 var tab_title = "Configurações de Grupos"; 1662 } 1663 $tabs.tabs( "add", "#"+tab_selector[type], tab_title ); 1714 1664 1715 1665 var dataColorPicker = { … … 1734 1684 DataLayer.render( 'templates/configure_calendars_itemlist.ejs', { 1735 1685 user:User, 1686 type:0, 1736 1687 calendar:calendars[nowActive], 1737 1688 signature:signatures[nowActive] 1738 1689 }, function( form_template ){ 1739 var form_content = jQuery(' .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form');1690 var form_content = jQuery('#'+tab_selector[type]+' .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form'); 1740 1691 form_content.find('.preferences-alarms-list .button').button({ 1741 1692 text:false, … … 1756 1707 1757 1708 form_content.find('.button-add-alarms').click(function(){ 1758 DataLayer.render( 'templates/alarms_add_itemlist.ejs', { }, function( template ){1709 DataLayer.render( 'templates/alarms_add_itemlist.ejs', {type: 0}, function( template ){ 1759 1710 jQuery('.preferences-alarms-list').append(template) 1760 1711 .find('li:last label:eq(0)').remove().end() … … 1862 1813 DataLayer.render( 'templates/configure_calendars.ejs', { 1863 1814 user:User, 1815 type: 0, 1864 1816 calendars:calendars, 1865 1817 signatures:signatures 1866 1818 }, function( template ){ 1867 var template_content = jQuery('# configure_tab').html( template ).find('.configure-calendars-win');1819 var template_content = jQuery('#'+tab_selector[type]).html( template ).find('.configure-calendars-win'); 1868 1820 template_content.find('.button').button().filter('.save').click(function(evt){ 1869 1821 if(calendarAlarms.length) 1870 1822 DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]}); 1871 1823 template_content.find('form').submit(); 1872 $tabs.tabs( "remove", "# configure_tab");1824 $tabs.tabs( "remove", "#"+tab_selector[type]); 1873 1825 DataLayer.commit( false, false, function( received ){ 1874 1826 delete Calendar.currentViewKey; … … 1879 1831 Calendar.load(); 1880 1832 }).end().filter('.cancel').click(function(evt){ 1881 $tabs.tabs( "remove", "# configure_tab");1833 $tabs.tabs( "remove", "#"+tab_selector[type]); 1882 1834 }); 1883 1835 … … 1905 1857 $('.positionHelper').css('display','none'); 1906 1858 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); 1907 $tabs.tabs("select", "# configure_tab");1859 $tabs.tabs("select", "#"+tab_selector[type]); 1908 1860 $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); 1909 1861 … … 1913 1865 } 1914 1866 1915 function getSelectedCalendars( reverse ){ 1867 function getSelectedCalendars( reverse, type ){ 1868 var selector = ""; 1869 if(type == 0) 1870 selector = ".my-calendars"; 1871 if(type == 1) 1872 selector = ".my-groups-task"; 1916 1873 var selecteds = {}; 1917 1874 var cont = 0; 1918 1875 jQuery(function() { 1919 jQuery( ".my-calendars.calendar-view").each(function(i, obj) {1876 jQuery(selector+" .calendar-view").each(function(i, obj) { 1920 1877 var check_box = obj; 1921 1878 if( reverse ? !check_box.checked : check_box.checked ) { … … 1974 1931 } 1975 1932 1976 function remove_event(eventId, idCalendar ){1977 $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', {1933 function remove_event(eventId, idCalendar, type){ 1934 $.Zebra_Dialog('Tem certeza que deseja excluir?', { 1978 1935 'type': 'question', 1979 1936 'overlay_opacity': '0.5', … … 1987 1944 var me = schudableDecode.me.user ? schudableDecode.me.user.id : schudableDecode.me.id; 1988 1945 1989 DataLayer.removeFilter('schedulable', {filter: ['AND', ['=','id',eventId], ['=','calendar',idCalendar], ['=','user', me]]}) 1946 var filter = {filter: ['AND', ['=','id',eventId], ['=','calendar',idCalendar], ['=','user', me]]}; 1947 1948 if(type) 1949 filter.filter.push(['=','type',type]); 1950 1951 DataLayer.removeFilter('schedulable', filter); 1990 1952 Calendar.rerenderView(true); 1991 1953 } … … 2029 1991 2030 1992 2031 function remove_calendar( ){1993 function remove_calendar(type){ 2032 1994 /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ 2033 $.Zebra_Dialog('Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?', { 1995 if(!!parseInt(type)) 1996 var title = 'Todas as tarefas deste grupo serão removidas. Deseja prosseguir com a operação?'; 1997 else 1998 var title = 'Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?'; 1999 $.Zebra_Dialog(title, { 2034 2000 'type': 'question', 2035 2001 'overlay_opacity': '0.5', … … 2047 2013 delete Calendar.currentViewKey; 2048 2014 Calendar.load(); 2049 refresh_calendars( );2015 refresh_calendars(type); 2050 2016 }); 2051 2017 } … … 2056 2022 } 2057 2023 2058 function refresh_calendars( ){2024 function refresh_calendars(type){ 2059 2025 2060 2026 var colorsSuggestions = colors_suggestions(); … … 2091 2057 }); 2092 2058 } 2059 2093 2060 doMenu(); 2061 var currentToolTip = null; 2094 2062 $('#divAppbox').on('scroll',function(){ 2095 2063 if ($('.cal-list-options-btn.fg-menu-open.ui-state-active')){ 2096 2064 var offset = $('.cal-list-options-btn.fg-menu-open.ui-state-active').offset(); 2097 2065 if (offset) 2098 2066 $('.positionHelper').css('top',offset.top); 2099 2067 } 2100 if ($('.button.config-menu.fg-menu-open')){ 2101 var offset = $('.button.config-menu.fg-menu-open').offset(); 2102 if (offset) 2103 $('.positionHelper').css('top',offset.top); 2104 } 2068 2069 if ($('.button.config-menu.fg-menu-open')){ 2070 var offset = $('.button.config-menu.fg-menu-open').offset(); 2071 if (offset) 2072 $('.positionHelper').css('top',offset.top); 2073 } 2074 2075 2076 if ($(".new-group.qtip-active").length || $(".new-calendar.qtip-active").length) 2077 $('.qtip-active').css('top',currentToolTip.offset().top - 50); 2078 2105 2079 }); 2080 2106 2081 $('ul.list-calendars .cal-list-options-btn').on('click',function(){doMenu();}); 2107 2082 2083 2084 /***************************************New Calendar***************************************/ 2108 2085 meu_container.find(".button.new-calendar").button({ 2109 2086 icons: { … … 2112 2089 text: false 2113 2090 }).click(function () { 2114 2115 if( $('.qtip.qtip-blue.qtip-active').val() !== ''){ 2116 $(this).qtip({ 2117 show: { 2118 ready: true, 2119 solo: true, 2120 when: { 2121 event: 'click' 2122 } 2123 }, 2124 hide: false, 2125 content: { 2126 text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), 2127 title: { 2128 text:'Nova Agenda', 2129 button: '<a class="button close" href="#">close</a>' 2130 } 2131 }, 2132 style: { 2133 name: 'blue', 2134 tip: { 2135 corner: 'leftMiddle' 2136 }, 2137 border: { 2138 width: 4, 2139 radius: 8 2140 }, 2141 width: { 2142 min: 230, 2143 max:230 2144 } 2145 }, 2146 position: { 2147 corner: { 2148 target: 'rightMiddle', 2149 tooltip: 'leftMiddle' 2150 }, 2151 adjust: { 2152 x:0, 2153 y:-12 2154 } 2155 } 2156 }) 2157 .qtip("api").onShow = function(arg0) { 2158 $('.qtip-active .button.close').button({ 2159 icons: { 2160 primary: "ui-icon-close" 2161 }, 2162 text: false 2163 }) 2164 .click(function(){ 2165 meu_container.find(".button.new-calendar").qtip('destroy'); 2166 }); 2167 //TODO emplementar tratamento de duplicação de valores no location 2168 $('.qtip-active .button.save').button().click(function(){ 2169 for(var i = 0; i < Calendar.calendars.length; i++){ 2170 if(Calendar.calendars[i].location == ( User.me.uid + '/' + $('.qtip-active input').val())){ 2171 $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ 2172 'overlay_opacity': '0.5', 2173 'type': 'warning' 2174 }); 2175 meu_container.find(".button.new").qtip('destroy'); 2176 return; 2177 } 2178 } 2091 currentToolTip = $(this); 2092 var typeCalendar = !!parseInt($(this).attr('class').match(/[0-9]+/g)) ? 2093 {type: 'new-group', title: 'Novo Grupo', typeValue: 1, prompt: 'Nome do grupo'} : 2094 {type: 'new-calendar', title: 'Nova Agenda', typeValue: 0, prompt: 'Nome da agenda'} 2095 2096 if(!$('.qtip.qtip-blue.qtip-active.'+typeCalendar.type).length){ 2097 2098 $('.qtip.qtip-blue').remove(); 2099 2100 $(this).qtip({ 2101 show: { 2102 ready: true, 2103 solo: true, 2104 when: { 2105 event: 'click' 2106 } 2107 }, 2108 hide: false, 2109 content: { 2110 text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), 2111 title: { 2112 text: typeCalendar.title, 2113 button: '<a class="button close" href="#">close</a>' 2114 } 2115 }, 2116 style: { 2117 name: 'blue', 2118 tip: { 2119 corner: 'leftMiddle' 2120 }, 2121 border: { 2122 width: 4, 2123 radius: 8 2124 }, 2125 width: { 2126 min: 230, 2127 max:230 2128 } 2129 }, 2130 position: { 2131 corner: { 2132 target: 'rightMiddle', 2133 tooltip: 'leftMiddle' 2134 }, 2135 adjust: { 2136 x:0, 2137 y: -12 2138 2139 } 2140 } 2141 }) 2142 .qtip("api").onShow = function(arg0) { 2179 2143 2180 var selected; 2181 var color = $('.cal-colors-options-btn').each(function(index){ 2182 if ($(this).is('.color-selected')) 2183 selected = index; 2184 }); 2185 DataLayer.put( "calendarSignature", { 2186 user: User.me.id, 2187 calendar: { 2188 name: Encoder.htmlEncode($('.qtip-active input').val()), 2189 timezone: User.preferences.timezone 2190 }, 2191 isOwner: 1, 2192 fontColor: colorsSuggestions[selected]['font'].substring(1) , 2193 backgroundColor: colorsSuggestions[selected]['background'].substring(1) , 2194 borderColor: colorsSuggestions[selected]['border'].substring(1) 2195 }); 2196 DataLayer.commit( false, false, function( received ){ 2197 delete Calendar.currentViewKey; 2198 Calendar.load(); 2199 refresh_calendars(); 2200 }); 2201 meu_container.find(".button.new").qtip('destroy'); 2202 }); 2203 2204 $('.qtip-active .button.cancel').button().click(function(){ 2205 meu_container.find(".button.new").qtip('destroy'); 2206 }); 2207 2208 $(".qtip-active input").Watermark("Nome da agenda"); 2209 2210 $('.qtip-active').keydown(function(event) { 2211 if (event.keyCode == '27') { 2212 meu_container.find(".button.new").qtip('destroy'); 2213 } 2214 }); 2215 2216 $('.colors-options').prepend(buttons_colors); 2217 $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); 2218 2219 var buttons = $('.cal-colors-options-btn').button(); 2220 2221 buttons.click(function(){ 2222 buttons.removeClass('color-selected'); 2223 $(this).addClass('color-selected'); 2224 }); 2225 } 2226 } 2144 $('.qtip-active .button.close').button({ 2145 icons: { 2146 primary: "ui-icon-close" 2147 }, 2148 text: false 2149 }) 2150 .click(function(){ 2151 $('.qtip.qtip-blue').remove(); 2152 }); 2153 2154 $('.qtip-active').addClass(typeCalendar.type); 2155 2156 $('.qtip-active .button.save').button().click(function(){ 2157 if(!typeCalendar.typeValue) 2158 for(var i = 0; i < Calendar.calendars.length; i++){ 2159 if(Calendar.calendars[i].location == ( User.me.uid + '/' + $('.qtip-active input').val())){ 2160 $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ 2161 'overlay_opacity': '0.5', 2162 'type': 'warning' 2163 }); 2164 $('.qtip.qtip-blue').remove(); 2165 return; 2166 } 2167 } 2168 2169 var selected; 2170 var color = $('.cal-colors-options-btn').each(function(index){ 2171 if ($(this).is('.color-selected')) 2172 selected = index; 2173 }); 2174 DataLayer.put( "calendarSignature", { 2175 user: User.me.id, 2176 calendar: { 2177 name: Encoder.htmlEncode($('.qtip-active input').val()), 2178 timezone: User.preferences.timezone, 2179 type: typeCalendar.typeValue 2180 }, 2181 isOwner: 1, 2182 fontColor: colorsSuggestions[selected]['font'].substring(1) , 2183 backgroundColor: colorsSuggestions[selected]['background'].substring(1) , 2184 borderColor: colorsSuggestions[selected]['border'].substring(1) 2185 }); 2186 DataLayer.commit( false, false, function( received ){ 2187 delete Calendar.currentViewKey; 2188 Calendar.load(); 2189 refresh_calendars(); 2190 }); 2191 $('.qtip.qtip-blue').remove(); 2192 }); 2193 2194 $('.qtip-active .button.cancel').button().click(function(){ 2195 meu_container.find(".button.new").qtip('destroy'); 2196 }); 2197 2198 $(".qtip-active input").Watermark(typeCalendar.prompt); 2199 2200 $('.qtip-active').keydown(function(event) { 2201 if (event.keyCode == '27') 2202 meu_container.find(".button.new").qtip('destroy'); 2203 }); 2204 2205 $('.colors-options').prepend(buttons_colors); 2206 $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); 2207 2208 var buttons = $('.cal-colors-options-btn').button(); 2209 2210 buttons.click(function(){ 2211 buttons.removeClass('color-selected'); 2212 $(this).addClass('color-selected'); 2213 }); 2214 } 2215 } 2227 2216 }); 2228 2217 2229 2218 $("img.cal-list-img").click(function(evt) { 2230 $(".cal-list-options_1").toggleClass( "hidden" );2219 $(".cal-list-options_1").toggleClass( "hidden" ); 2231 2220 }); 2232 2221 2222 $(".my-groups-task a.title-my-calendars").click(function() { 2223 $(".my-groups-task ul.my-list-calendars").toggleClass("hidden") 2224 $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-s"); 2225 $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-e"); 2226 }); 2227 2233 2228 $(".my-calendars a.title-my-calendars").click(function() { 2234 $(".my-calendars ul.my-list-calendars").toggleClass("hidden")2235 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s");2236 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e");2229 $(".my-calendars ul.my-list-calendars").toggleClass("hidden") 2230 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s"); 2231 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e"); 2237 2232 }); 2238 2233 2239 2234 $(".signed-calendars a.title-signed-calendars").click(function() { 2240 $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden");2235 $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden"); 2241 2236 }); 2242 2237 … … 2270 2265 2271 2266 $('.calendar-view').click(function(evt){ 2272 if($tabs.tabs('option' ,'selected') == 1){2273 pageselectCallback('', 0 );2267 if($tabs.tabs('option' ,'selected') != 0){ 2268 pageselectCallback('', 0, false, type); 2274 2269 } 2275 2270 … … 2285 2280 } 2286 2281 2287 function add_events_list(keyword )2282 function add_events_list(keyword, type) 2288 2283 { 2289 2284 var tab_title = ""; 2290 2285 if (keyword){ 2291 if(keyword.length < 10) 2292 tab_title = keyword; 2293 else 2294 tab_title = keyword.substr(0,10) + '..."'; 2286 type = 2; 2287 if(keyword.length < 10) 2288 tab_title = keyword; 2289 else 2290 tab_title = keyword.substr(0,10) + '..."'; 2295 2291 }else{ 2296 tab_title = "Lista de eventos"; 2297 } 2292 if(type){ 2293 if(!!parseInt(type)) 2294 tab_title = "Lista de tarefas"; 2295 else 2296 tab_title = "Lista de eventos"; 2297 } 2298 } 2299 var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; 2298 2300 keyword = ( keyword || '' ).replace( /\s+/g, "_" ); 2299 2301 2300 if(!(document.getElementById( 'tab_events_list_'+ (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") )))2302 if(!(document.getElementById(tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") ))) 2301 2303 { 2302 2304 Encoder.EncodeType = "entity"; 2303 $tabs.tabs( "add", "# tab_events_list_"+ (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) );2305 $tabs.tabs( "add", "#"+tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) ); 2304 2306 } 2305 2307 else /* Tab already opened */ 2306 2308 { 2307 $tabs.tabs("option", "selected", 2);2308 2309 2310 pageselectCallback(keyword, 0 ); // load page 1 and insert data on event_list.ejs2309 //$tabs.tabs("option", "selected", 2); 2310 } 2311 2312 pageselectCallback(keyword, 0, false, type); // load page 1 and insert data on event_list.ejs 2311 2313 2312 2314 $('.preferences-win.active .button.save, .preferences-win.active .button.cancel, .preferences-win.active .button.import, .preferences-win.active .button.export').button(); … … 2328 2330 if(paginator.indexOf('next') > 0){ 2329 2331 if(parseInt($(currentView+' [name = results]').val()) > 25) 2330 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1) );2332 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), false, 2); 2331 2333 }else{ 2332 2334 if(parseInt($(currentView+' [name = page_index]').val()) > 0) 2333 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1) );2335 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), false, 2); 2334 2336 } 2335 2337 }); … … 2369 2371 } 2370 2372 2371 function paginatorList(currentView, view ){2372 $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>'+mountTitleList( parseInt($( '[name = page_index]').val()),view)+'</h2>');2373 function paginatorList(currentView, view, type){ 2374 $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>'+mountTitleList( parseInt($(currentView+' [name = page_index]').val()),view)+'</h2>'); 2373 2375 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') 2374 2376 if(view == 'basicDay') … … 2390 2392 var goView = $(this).attr('class'); 2391 2393 if(goView.indexOf('agendaDay') > 0) 2392 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'agendaDay');2394 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaDay', type); 2393 2395 else if(goView.indexOf('month') > 0) 2394 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'month');2396 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'month', type); 2395 2397 else if(goView.indexOf('year') > 0) 2396 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'year');2398 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'year', type); 2397 2399 else if(goView.indexOf('agendaWeek') > 0) 2398 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'agendaWeek');2400 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaWeek', type); 2399 2401 2400 2402 }); … … 2412 2414 var paginator = $(this).attr('class'); 2413 2415 if(paginator.indexOf('next') > 0) 2414 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($( '[name = page_index]').val())) +1), '', view);2416 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), view, type); 2415 2417 else 2416 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($( '[name = page_index]').val())) -1), '', view);2418 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), view, type); 2417 2419 }); 2418 2420 } 2419 2421 2420 function paginatorListEvent(currentView, typeView, view){ 2422 function printEventList(view){ 2423 $('.fc-button-print.print-list-events').click(function(){ 2424 var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); 2425 var listEvents = $(view).clone(); 2426 listEvents.find('.fc-button').remove(); 2427 listEvents.find('.details-event-list').remove(); 2428 listEvents.find('.list-events-paginator').remove(); 2429 listEvents = listEvents.html(); 2430 type = $(this).parents('.ui-tabs-panel').attr("id").split("_")[1]; 2431 2432 var data = { 2433 type : type == "tasks" ? "task-list" : ( type == "events" ? "event-list" : "search"), 2434 html : listEvents, 2435 InfoPage : $(this).parents('table.header-paginator').find( '.fc-header-title' ).text() 2436 } 2437 window_print.document.open(); 2438 window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); 2439 window_print.document.close(); 2440 window_print.print(); 2441 }); 2442 } 2443 2444 function paginatorListEvent(currentView, typeView, view, type){ 2421 2445 if(!!$(currentView).find('.fc-calendar').length) 2422 2446 return; … … 2430 2454 $(currentView+' .events-list.events-list-win.active .fc-header .fc-header-center').addClass('list-events-paginator'); 2431 2455 $(currentView+' .events-list.events-list-win.active .fc-header .list-events-paginator').removeClass('fc-header-center'); 2432 2456 2433 2457 //Adicionar class no header padronizar com a tela principal 2434 $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); 2435 $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); 2436 2458 $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-print').addClass('print-list-events'); 2459 $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); 2460 $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); 2461 2462 printEventList(currentView); 2463 2437 2464 if(typeView == 'search'){ 2438 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right ').remove()2465 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right span.fc-button:not(.fc-button-print)').remove(); 2439 2466 $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>Resultados para: '+$(currentView+' [name = keyword]').val()+'</h2>'); 2440 2467 if((parseInt($(currentView+' [name = page_index]').val()) == 0) && (parseInt($(currentView+' [name = results]').val()) <= 25)) … … 2442 2469 paginatorSearch(currentView); 2443 2470 }else 2444 paginatorList(currentView, view );2471 paginatorList(currentView, view, type); 2445 2472 } 2446 2473 … … 2450 2477 case 'basicDay': 2451 2478 case 'agendaDay': 2452 rangeStart = new Date ().add({2479 rangeStart = new Date.today().add({ 2453 2480 days: page_index 2454 2481 }).getTime(); 2455 rangeEnd = rangeStart ;2482 rangeEnd = rangeStart + 86400000; 2456 2483 break; 2457 2484 case 'agendaWeek': … … 2519 2546 } 2520 2547 2521 function pageselectCallback(keyword, page_index, jq, view){ 2522 2523 var selecteds = getSelectedCalendars(); 2524 if(!selecteds && (keyword != '' && keyword != null)){ 2525 jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( 2526 '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 2527 '<label>Por favor selecione ao menos uma agenda.</label>' + 2548 function pageselectCallback(keyword, page_index, view, type){ 2549 $('.qtip.qtip-blue').remove(); 2550 var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; 2551 var tab_title = ['Lista de eventos', 'Lista de tarefas']; 2552 var label_noselect_calendar = ['Por favor selecione ao menos uma agenda.', 'Por favor selecione ao menos um grupo.', 'Por favor selecione ao menos uma agenda ou grupo.']; 2553 var label_nofound_search = ['Não foi encontrado nenhum evento correspondente à sua pesquisa.', 'Não foi encontrado nenhuma tarefa ou atividade correspondente à sua pesquisa.', 'Não foi encontrado nenhum evento ou tarefa ou atividade correspondente à sua pesquisa.']; 2554 var label_nofound = ['Não foram encontrados eventos neste intervalo.', 'Não foram encontradas tarefas ou atividades neste intervalo.', 'Não foram encontrados eventos ou tarefas ou atividades neste intervalo.']; 2555 var selecteds = getSelectedCalendars(false, type); 2556 2557 if(!selecteds && (keyword != '' && keyword != null)){ 2558 jQuery('#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( 2559 '<div title="'+tab_title[type]+'" class="events-list events-list-win active empty">' + 2560 '<label>'+label_noselect_calendar[type]+'</label>' + 2528 2561 '</div>' 2529 2562 ); … … 2545 2578 var results = DataLayer.get('schedulable:detail', criteria); 2546 2579 keyword = ( keyword || '' ).replace( /\s+/g, "_" ); 2547 }2580 } 2548 2581 // não há resultados 2549 2582 2550 var currentView = '# tab_events_list_'+ ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || '');2583 var currentView = '#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); 2551 2584 2552 2585 if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) { 2553 2586 $(currentView).html( 2554 '<div title=" Lista de eventos" class="events-list events-list-win active empty">' +2555 '<label> Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' +2587 '<div title="'+title+'" class="events-list events-list-win active empty">' + 2588 '<label>'+label_nofound_search[type]+'</label>' + 2556 2589 '</div>' 2557 2590 ); … … 2561 2594 results['page_index'] = page_index; 2562 2595 results['keyword'] = keyword; 2563 2596 results['tab_title'] = tab_title[type]; 2564 2597 DataLayer.render( 'templates/event_list.ejs', results, function( html ){ 2565 2598 … … 2567 2600 $('.events-list-win .menu-container .button').button(); 2568 2601 2569 $(".event-details-item").parent().click(function( ){2570 2602 $(".event-details-item").parent().click(function(event){ 2603 event.stopImmediatePropagation(); 2571 2604 $(this).siblings("div.details-event-list").toggleClass("hidden") 2572 .find('.button.delete').click(function( ){2605 .find('.button.delete').click(function(event){ 2573 2606 var eventId = $(this).siblings('[name="eventid"]').val(); 2574 2607 var calendarId = $(this).siblings('[name="calendarid"]').val(); 2575 2576 remove_event(eventId, calendarId);2608 remove_event(eventId, calendarId, 2); 2609 event.stopImmediatePropagation() 2577 2610 }) 2578 .end().find('.button.edit').click(function(){ 2579 eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2611 .end().find('.button.edit').click(function(event){ 2612 switch($(this).siblings('[name="eventtype"]').val()){ 2613 case '1': 2614 eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2615 break; 2616 case '2': 2617 taskDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2618 break; 2619 case '3': 2620 activityDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2621 break; 2622 } 2623 event.stopImmediatePropagation() 2624 }) 2625 .end().find('.button.print').click(function(event){ 2626 var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); 2627 var html = $(this).parents("td:first").clone(); 2628 html.find(".menu-container.footer-container").remove(); 2629 html.find(".fc-header-title").remove(); 2630 var html = html.html(); 2631 var data = { 2632 type : $(this).parents('.details-event-list').hasClass("details-event") ? "event-detail" : "task-detail", 2633 html : html, 2634 InfoPage : 'Detalhes: '+$(this).parents('tr.start-date').find('td span a').text() 2635 } 2636 window_print.document.open(); 2637 window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); 2638 window_print.document.close(); 2639 window_print.print(); 2640 2641 event.stopImmediatePropagation() 2580 2642 }); 2581 2643 2582 2644 }); 2583 paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView );2645 paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView, type); 2584 2646 }); 2585 2647 }else{ 2586 2648 $(currentView).html( 2587 '<div title=" Lista de eventos" class="events-list events-list-win active empty">' +2649 '<div title="'+title+'" class="events-list events-list-win active empty">' + 2588 2650 '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ 2589 2651 '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ 2590 '<label class="empty-result"> Não foram encontrados eventos neste intervalo.</label>' +2652 '<label class="empty-result">'+label_nofound[type]+'</label>' + 2591 2653 '</div>' 2592 2654 ); 2593 paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView );2594 } 2595 } 2596 if(currentView != '# tab_events_list_')2655 paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView, type); 2656 } 2657 } 2658 if(currentView != '#'+tab_selector[type]) 2597 2659 $tabs.tabs("select", currentView); 2598 2660 } 2599 2661 2600 function show_modal_import_export(tab, calendarId) { 2662 function show_modal_import_export(tab, calendarId, typeView){ 2663 $('.qtip.qtip-blue').remove(); 2601 2664 DataLayer.render( 'templates/import_export.ejs', { 2602 calendars: Calendar.calendars, 2603 owner: User.me.id 2665 calendars: typeView == 0 ? Calendar.calendars : Calendar.groups, 2666 owner: User.me.id, 2667 typeView: typeView 2604 2668 }, function( html ){ 2605 2669 2606 2670 if (!UI.dialogs.importCalendar) { 2607 2671 UI.dialogs.importCalendar = jQuery('#div-import-export-calendar') 2608 .append('<div title="Importar e Exportar Eventos" class="import-export import-export-win active"> <div>')2672 .append('<div title="Importar e Exportar "' + (typeView == 0 ? 'Eventos' : 'Tarefas') + '" class="import-export import-export-win active"> <div>') 2609 2673 .find('.import-export-win.active').html(html).dialog({ 2610 2674 resizable: false, … … 2718 2782 2719 2783 var schedulable = DataLayer.get('schedulable', event+''); 2784 schedulable['class'] = '1'; 2720 2785 2721 2786 calendar = !!calendar ? calendar : schedulable.calendar; … … 2831 2896 } 2832 2897 } 2898 2899 function extendsFileupload(view, path){ 2900 var viewName = 'div.new-'+view+'-win'; 2901 2902 path = !!path ? path : ''; 2903 2904 var maxSizeFile = 2000000; 2905 $('#fileupload'+view).fileupload({ 2906 sequentialUploads: true, 2907 add: function (e, data) { 2908 if(data.files[0].size < maxSizeFile) 2909 data.submit(); 2910 }, 2911 change: function (e, data) { 2912 $.each(data.files, function (index, file) { 2913 var attach = {}; 2914 attach.fileName = file.name; 2915 var ext = file.name.split('.'); 2916 if(file.name.length > 10) 2917 attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; 2918 attach.fileSize = formatBytes(file.size); 2919 if(file.size > maxSizeFile) 2920 attach.error = 'Tamanho de arquivo nao permitido!!' 2921 2922 $(viewName+' .attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { 2923 file : attach 2924 })); 2925 2926 if(file.size < maxSizeFile){ 2927 $(viewName+' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 2928 $(viewName+' .attachments-list').find('[type=file]').addClass('hidden'); 2929 2930 }else 2931 $(viewName+' .fileinput-button.new').removeClass('new'); 2932 2933 2934 $(viewName+' .attachments-list').find('.button.close').button({ 2935 icons: { 2936 primary: "ui-icon-close" 2937 }, 2938 text: false 2939 }).click(function(){ 2940 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 2941 $(viewName+' .attachment-list').find('input[value="'+idAttach+'"]').remove(); 2942 $(this).parent().remove(); 2943 2944 if(!$(viewName+' .attachment-list input').length) 2945 $(viewName+' .btn-danger.delete').addClass('hidden'); 2946 2947 }); 2948 2949 }) 2950 }, 2951 done: function(e, data){ 2952 var currentUpload = $(viewName+' .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 2953 2954 if(!!data.result && data.result != "[]"){ 2955 $(viewName+' .btn-danger.delete').removeClass('hidden'); 2956 var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 2957 $(viewName+' .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); 2958 currentUpload.removeClass('on-complete').parents('p') 2959 .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') 2960 .find('.status-upload').addClass('ui-icon ui-icon-check'); 2961 }else 2962 currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 2963 } 2964 }); 2965 $('.attachments-list .button').button(); 2966 2967 if(!!window.FormData) 2968 $('#fileupload'+view).bind('fileuploadstart', function () { 2969 var widget = $(this), 2970 progressElement = $('#fileupload-progress-'+view).fadeIn(), 2971 interval = 500, 2972 total = 0, 2973 loaded = 0, 2974 loadedBefore = 0, 2975 progressTimer, 2976 progressHandler = function (e, data) { 2977 loaded = data.loaded; 2978 total = data.total; 2979 }, 2980 stopHandler = function () { 2981 widget 2982 .unbind('fileuploadprogressall', progressHandler) 2983 .unbind('fileuploadstop', stopHandler); 2984 window.clearInterval(progressTimer); 2985 progressElement.fadeOut(function () { 2986 progressElement.html(''); 2987 }); 2988 }, 2989 formatTime = function (seconds) { 2990 var date = new Date(seconds * 1000); 2991 return ('0' + date.getUTCHours()).slice(-2) + ':' + 2992 ('0' + date.getUTCMinutes()).slice(-2) + ':' + 2993 ('0' + date.getUTCSeconds()).slice(-2); 2994 }, 2995 /* formatBytes = function (bytes) { 2996 if (bytes >= 1000000000) { 2997 return (bytes / 1000000000).toFixed(2) + ' GB'; 2998 } 2999 if (bytes >= 1000000) { 3000 return (bytes / 1000000).toFixed(2) + ' MB'; 3001 } 3002 if (bytes >= 1000) { 3003 return (bytes / 1000).toFixed(2) + ' KB'; 3004 } 3005 return bytes + ' B'; 3006 },*/ 3007 formatPercentage = function (floatValue) { 3008 return (floatValue * 100).toFixed(2) + ' %'; 3009 }, 3010 updateProgressElement = function (loaded, total, bps) { 3011 progressElement.html( 3012 formatBytes(bps) + 'ps | ' + 3013 formatTime((total - loaded) / bps) + ' | ' + 3014 formatPercentage(loaded / total) + ' | ' + 3015 formatBytes(loaded) + ' / ' + formatBytes(total) 3016 ); 3017 }, 3018 intervalHandler = function () { 3019 var diff = loaded - loadedBefore; 3020 if (!diff) { 3021 return; 3022 } 3023 loadedBefore = loaded; 3024 updateProgressElement( 3025 loaded, 3026 total, 3027 diff * (1000 / interval) 3028 ); 3029 }; 3030 widget 3031 .bind('fileuploadprogressall', progressHandler) 3032 .bind('fileuploadstop', stopHandler); 3033 progressTimer = window.setInterval(intervalHandler, interval); 3034 }); 3035 3036 }
Note: See TracChangeset
for help on using the changeset viewer.