Changeset 6891 for sandbox/2.4.2-expresso1/expressoMail1_2/js/main.js
- Timestamp:
- 07/27/12 14:47:35 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/expressoMail1_2/js/main.js
r6788 r6891 3907 3907 wfolders.makeWindow('null','import'); 3908 3908 } 3909 function import_calendar(data){ 3910 var import_url = '$this.db_functions.import_vcard&msg_folder='+data; 3911 var logUser; 3912 var up; 3913 var owner; 3909 3910 function import_calendar(data){ 3911 var import_url = '$this.db_functions.import_vcard&msg_folder='+data; 3912 var logUser; 3913 var up; 3914 var owner; 3915 3916 //Verifica o contexto de importação 3917 var decodeOwner = function(){ 3918 3919 owner = User.me.id; 3920 var imapBox = openTab.imapBox[currentTab].split(cyrus_delimiter); 3921 if(imapBox.length > 1){ 3922 var user = DataLayer.get('user', {filter: ['=','uid',imapBox[1]]}); 3923 owner = $.isArray(user) ? user[0].id : user.id; 3924 } 3925 3926 return owner; 3927 } 3928 3929 function handler_import_calendar(data){ 3930 if(data === true){ 3931 write_msg(get_lang("The event was imported successfully.")); 3932 } 3933 else if( data['url'] ) 3934 { 3935 var form = document.createElement( "form" ); 3914 3936 3915 //Verifica o contexto de importação 3916 var decodeOwner = function(){ 3917 3918 owner = User.me.id; 3919 var imapBox = openTab.imapBox[currentTab].split(cyrus_delimiter); 3920 if(imapBox.length > 1){ 3921 var user = DataLayer.get('user', {filter: ['=','uid',imapBox[1]]}); 3922 owner = $.isArray(user) ? user[0].id : user.id; 3923 } 3924 3925 return owner; 3937 form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' ); 3938 form.setAttribute( "method", "POST" ); 3939 3940 document.body.appendChild( form ); 3941 3942 form.submit(); 3943 } 3944 else 3945 write_msg(get_lang(data)); 3946 } 3947 if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){ 3948 import_implements_calendar(); 3949 $( "#import-dialog" ).dialog({ 3950 autoOpen: false, 3951 height: 220, 3952 modal: true, 3953 resizable : false, 3954 close: function(event) { 3955 event.stopPropagation(); 3956 }, 3957 closeOnEscape: true 3958 }); 3959 3960 $.ajax({ 3961 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(), 3962 async: false, 3963 success: function(data){ 3964 data = connector.unserialize(data); 3965 3966 3967 var createDialog = function(typeImport, propaget){ 3968 3969 if(typeof(typeImport) == "object"){ 3970 var calendarPermission = typeImport.calendar; 3971 typeImport = typeImport.action; 3972 } 3973 3974 switch(parseInt(typeImport)){ 3975 case 1: 3976 case 7: 3977 case 10: 3978 $("#select-agenda").html(''); 3979 3980 var options = ''; 3981 3982 if(typeImport == 10){ 3983 for(var i = 0; i < calendarPermission.length; i++) 3984 options += '<option value="'+calendarPermission[i]+'">'+Calendar.signatureOf[calendarPermission[i]].calendar.name+'</option>' 3985 }else{ 3986 for(var id in Calendar.signatures) 3987 options += parseInt(Calendar.signatures[id].isOwner) ? '<option value="'+Calendar.signatures[id].calendar.id+'">'+Calendar.signatures[id].calendar.name+'</option>' : ''; 3988 } 3989 3990 $("#select-agenda").append(options); 3991 $("#select-agenda").css("display", "block"); 3992 3993 $("#import-dialog" ).dialog({ 3994 buttons: { 3995 Cancel: function() { 3996 $( this ).dialog( "close" ); 3997 }, 3998 "Importar" : function(){ 3999 $.ajax({ 4000 url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), 4001 success: function(msg){ 4002 var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento para a agenda "; 4003 alert( alt + $("#select-agenda option:selected").text() ); 4004 } 4005 }); 4006 $( this ).dialog( "close" ); 4007 } 4008 } 4009 }); 4010 4011 if(typeImport == 7){ 4012 $("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change'); 4013 $("#import-dialog").find('#select-status').attr('disabled','disabled'); 4014 } 4015 break; 4016 case 3: 4017 $.ajax({ 4018 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4019 success: function(msg){ 4020 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi removido " : "Ocorreu um erro ao remover o evento" ); 4021 } 4022 }); 4023 return; 4024 break; 4025 case 5: 4026 $.ajax({ 4027 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4028 success: function(msg){ 4029 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento" ); 4030 } 4031 }); 4032 return; 4033 break; 4034 case 6: 4035 var acceptedSuggestion = confirm("Deseja atualizar o evento de acordo com a sugestão ?"); 4036 $.ajax({ 4037 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value+'&uidAccount='+decodeOwner(), 4038 success: function(msg){ 4039 if(acceptedSuggestion) 4040 alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" ); 4041 } 4042 }); 4043 return; 4044 break; 4045 case 9: 4046 alert('Seu evento não possui alterações!'); 4047 return; 4048 break; 4049 case 11: 4050 alert('Este evento já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!'); 4051 return; 4052 break; 4053 default: 4054 up = true; 4055 $("#select-agenda").css("display", "none"); 4056 $("#import-dialog" ).children("p:first-child").css("display", "none"); 4057 $("#import-dialog" ).dialog({ 4058 height: 160, 4059 title: 'Atualizar Evento', 4060 buttons: { 4061 Cancel: function() { 4062 $( this ).dialog( "close" ); 4063 }, 4064 "Atualizar": function() { 4065 4066 $.ajax({ 4067 url: "controller.php?action="+import_url+'&from_ajax=true&cirus_delimiter='+cyrus_delimiter+'&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), 4068 success: function(msg){ 4069 alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso" : "Ocorreu um erro ao atualizar o evento" ); 4070 } 4071 }); 4072 $( this ).dialog( "close" ); 4073 } 4074 } 4075 }); 4076 $(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar"); 4077 } 4078 $( "#import-dialog" ).dialog( "open" ); 4079 4080 }; 4081 createDialog(data, true); 4082 4083 }, 4084 beforeSend: function( jqXHR, settings ){ 4085 connector.showProgressBar(); 4086 }, 4087 complete: function( jqXHR, settings ){ 4088 connector.hideProgressBar(); 4089 } 4090 }); 4091 4092 } 4093 else 4094 { 4095 if(confirm(get_lang("Do you confirm this import to your Calendar?"))){ 4096 cExecute( import_url + "&from_ajax=true", handler_import_calendar); 4097 } 4098 } 3926 4099 } 3927 3928 function handler_import_calendar(data){ 3929 if(data === true){ 3930 write_msg(get_lang("The event was imported successfully.")); 3931 } 3932 else if( data['url'] ) 3933 { 3934 var form = document.createElement( "form" ); 3935 3936 form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' ); 3937 form.setAttribute( "method", "POST" ); 3938 3939 document.body.appendChild( form ); 3940 3941 form.submit(); 3942 } 3943 else 3944 write_msg(get_lang(data)); 3945 } 3946 if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){ 3947 import_implements_calendar(); 3948 $( "#import-dialog" ).dialog({ 3949 autoOpen: false, 3950 height: 220, 3951 modal: true, 3952 resizable : false, 3953 close: function(event) { 3954 event.stopPropagation(); 3955 }, 3956 closeOnEscape: true 3957 }); 3958 3959 $.ajax({ 3960 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(), 3961 async: false, 3962 success: function(data){ 3963 data = connector.unserialize(data); 3964 3965 3966 var createDialog = function(typeImport, propaget){ 3967 3968 if(typeof(typeImport) == "object"){ 3969 var calendarPermission = typeImport.calendar; 3970 typeImport = typeImport.action; 3971 } 3972 3973 switch(parseInt(typeImport)){ 3974 case 1: 3975 case 7: 3976 case 10: 3977 $("#select-agenda").html(''); 3978 3979 var options = ''; 3980 3981 if(typeImport == 10){ 3982 for(var i = 0; i < calendarPermission.length; i++) 3983 options += '<option value="'+calendarPermission[i]+'">'+Calendar.signatureOf[calendarPermission[i]].calendar.name+'</option>' 3984 }else{ 3985 for(var id in Calendar.signatures) 3986 options += parseInt(Calendar.signatures[id].isOwner) ? '<option value="'+Calendar.signatures[id].calendar.id+'">'+Calendar.signatures[id].calendar.name+'</option>' : ''; 3987 } 3988 3989 $("#select-agenda").append(options); 3990 $("#select-agenda").css("display", "block"); 3991 3992 $("#import-dialog" ).dialog({ 3993 buttons: { 3994 Cancel: function() { 3995 $( this ).dialog( "close" ); 3996 }, 3997 "Importar" : function(){ 3998 $.ajax({ 3999 url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), 4000 success: function(msg){ 4001 var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento para a agenda "; 4002 alert( alt + $("#select-agenda option:selected").text() ); 4003 } 4004 }); 4005 $( this ).dialog( "close" ); 4006 } 4007 } 4008 }); 4009 4010 if(typeImport == 7){ 4011 $("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change'); 4012 $("#import-dialog").find('#select-status').attr('disabled','disabled'); 4013 } 4014 break; 4015 case 3: 4016 $.ajax({ 4017 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4018 success: function(msg){ 4019 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi removido " : "Ocorreu um erro ao remover o evento" ); 4020 } 4021 }); 4022 return; 4023 break; 4024 case 5: 4025 $.ajax({ 4026 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4027 success: function(msg){ 4028 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento" ); 4029 } 4030 }); 4031 return; 4032 break; 4033 case 6: 4034 var acceptedSuggestion = confirm("Deseja atualizar o evento de acordo com a sugestão ?"); 4035 $.ajax({ 4036 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value, 4037 success: function(msg){ 4038 if(acceptedSuggestion) 4039 alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" ); 4040 } 4041 }); 4042 return; 4043 break; 4044 case 9: 4045 alert('Seu evento não possui alterações!'); 4046 return; 4047 break; 4048 case 11: 4049 alert('Este evento já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!'); 4050 return; 4051 break; 4052 default: 4053 up = true; 4054 $("#select-agenda").css("display", "none"); 4055 $("#import-dialog" ).children("p:first-child").css("display", "none"); 4056 $("#import-dialog" ).dialog({ 4057 height: 160, 4058 title: 'Atualizar Evento', 4059 buttons: { 4060 Cancel: function() { 4061 $( this ).dialog( "close" ); 4062 }, 4063 "Atualizar": function() { 4064 4065 $.ajax({ 4066 url: "controller.php?action="+import_url+'&from_ajax=true&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val(), 4067 success: function(msg){ 4068 alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso para " : "Ocorreu um erro ao atualizar o evento" ); 4069 } 4070 }); 4071 $( this ).dialog( "close" ); 4072 } 4073 } 4074 }); 4075 $(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar"); 4076 } 4077 $( "#import-dialog" ).dialog( "open" ); 4078 4079 }; 4080 createDialog(data, true); 4081 4082 }, 4083 beforeSend: function( jqXHR, settings ){ 4084 connector.showProgressBar(); 4085 }, 4086 complete: function( jqXHR, settings ){ 4087 connector.hideProgressBar(); 4088 } 4089 }); 4090 4091 } 4092 else 4093 { 4094 if(confirm(get_lang("Do you confirm this import to your Calendar?"))){ 4095 cExecute( import_url + "&from_ajax=true", handler_import_calendar); 4096 } 4097 } 4098 } 4100 4099 4101 function open_msg_part(data){ 4100 4102 var handler_open_msg_part = function (data)
Note: See TracChangeset
for help on using the changeset viewer.