Changeset 5858 for trunk/expressoMail1_2/js/main.js
- Timestamp:
- 04/02/12 14:50:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/js/main.js
r5844 r5858 3168 3168 } 3169 3169 3170 function import_window(){ 3171 var win = arrayJSWin["import_window"]; 3172 var form_upload = Element("form_upload"); 3173 if(!win) { 3174 var form = document.createElement("DIV"); 3175 form.id = "import_window"; 3176 form.style.visibility = "hidden"; 3177 form.style.position = "absolute"; 3178 form.style.background = "#eeeeee"; 3179 form.style.left = "0px"; 3180 form.style.top = "0px"; 3181 form.style.width = "0px"; 3182 form.style.height = "0px"; 3183 document.body.appendChild(form); 3184 form_upload = document.createElement("DIV"); 3185 form_upload.id = "form_upload"; 3186 form_upload.style.position = "absolute"; 3187 form_upload.style.top = "5px"; 3188 form_upload.style.left = "5px"; 3189 form_upload.name = get_lang('zip mails to import'); 3190 form_upload.style.width = "450px"; 3191 form_upload.style.height = "100px"; 3192 form.appendChild(form_upload); 3193 form.style.width = form.firstChild.style.width; 3194 form.style.height = form.firstChild.style.height; 3195 form.style.zIndex = "10000"; 3196 var title = form.firstChild.name; 3197 var wHeight = form.offsetHeight + "px"; 3198 var wWidth = form.offsetWidth + "px"; 3199 form.style.width = form.offsetWidth - 5; 3200 win = new dJSWin({ 3201 id: 'win_'+form.id, 3202 content_id: form.id, 3203 width: wWidth, 3204 height: wHeight, 3205 title_color: '#3978d6', 3206 bg_color: '#eee', 3207 title: title, 3208 title_text_color: 'white', 3209 button_x_img: '../phpgwapi/images/winclose.gif', 3210 border: true}); 3211 win.draw(); 3212 } 3170 function import_window() 3171 { 3172 var importEmails = $("#importEmails"); 3173 importEmails.html( DataLayer.render( BASE_PATH + "modules/mail/templates/importEmails.ejs", {})); 3174 importEmails.dialog( 3175 { 3176 height : 280, 3177 width : 500, 3178 resizable : false, 3179 title : get_lang('zip mails to import'), 3180 modal : true, 3181 buttons : [ 3182 { 3183 text : get_lang("Close"), 3184 click : function() 3185 { 3186 importEmails.dialog("destroy"); 3187 } 3188 }, 3189 { 3190 text : get_lang("Import"), 3191 click : function() 3192 { 3193 var input_file = importEmails.find("input[type=file]"); 3194 var input_hidden = importEmails.find("input[name=folder]"); 3195 3196 if( input_file.attr("value") == "" ) 3197 { 3198 $.Zebra_Dialog(get_lang("You must choose a file") + " !",{ 3199 'type' : 'warning', 3200 'overlay_opacity' : '0.5', 3201 'onClose' : function(){ 3202 $("#importMessageAccordion").accordion('activate',0); 3203 } 3204 }); 3205 } 3206 else 3207 { 3208 if( input_hidden.attr("value") == "" ) 3209 $.Zebra_Dialog( get_lang("You must choose a folder") + " !" , { 3210 'type' : 'warning', 3211 'overlay_opacity' : '0.5', 3212 'onClose' : function(){ 3213 $("#importMessageAccordion").accordion('activate',1); 3214 } 3215 }); 3216 else 3217 { 3218 var handler_return = function(data) 3219 { 3220 importEmails.dialog("destroy"); 3221 3222 return_import_msgs( data, input_hidden.attr("value") ); 3223 } 3224 3225 var formSend = document.getElementById("importFileMessages"); 3226 3227 write_msg(get_lang('You must wait while the messages will be imported...')); 3228 3229 cExecuteForm('$this.imap_functions.import_msgs', formSend , handler_return ); 3230 } 3231 } 3232 } 3233 } 3234 ] 3235 }); 3236 3237 importEmails.css("overflow","hidden"); 3238 3239 importEmails.find("input[type=file]").change(function() 3240 { 3241 var deniedExtension = true; 3242 var fileExtension = ["eml","zip"]; 3243 var fileName = importEmails.find("input[type=file]").attr('value'); 3244 fileName = fileName.split("."); 3245 3246 if( fileName[1] ) 3247 { 3248 for( var i in fileExtension ) 3249 { 3250 if( fileExtension[i].toUpperCase() === fileName[1].toUpperCase() ) 3251 { 3252 deniedExtension = false; 3253 break; 3254 } 3255 } 3256 } 3257 3258 if( deniedExtension ) 3259 { 3260 $.Zebra_Dialog( get_lang('File extension forbidden or invalid file') , { 3261 'type' : 'warning', 3262 'overlay_opacity' : '0.5' 3263 }); 3264 } 3265 3266 $("#lblFileName").html( ( !deniedExtension ) ? importEmails.find("input[type=file]").attr('value') : "" ); 3267 3268 }); 3269 3270 $("#importMessageAccordion").accordion(); 3271 3272 var foldersTree = jQuery("#foldertree-container-importMessage") 3273 .removeClass('empty-container') 3274 .html(DataLayer.render(BASE_PATH + 'api/templates/foldertree.ejs', {folders: [cp_tree1, cp_tree2, [] ]})) 3275 .find("#foldertree").treeview() 3276 .click(function(event) 3277 { 3278 //request new selected folder messages 3279 var target = $(event.target); 3280 3281 if( target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable, .lastExpandable, .treeview') ) 3282 return; 3283 3284 if( !target.attr('id') ) 3285 target = target.parent(); 3286 3287 if (target.attr('id') == "foldertree") return; 3288 3289 var targetId = target.attr('id'); 3290 var child = target.find('.folder'); 3291 3292 $('.filetree span.folder.selected').removeClass('selected'); 3293 if(!target.is('#foldertree > .expandable, #foldertree > .collapsable')) 3294 $(target).children('.folder').addClass('selected'); 3295 3296 selectedFolder = { 3297 id: targetId, 3298 name: child.attr('title'), 3299 'class': child.attr('class') 3300 }; 3301 3302 importEmails.find("input[name=folder]").attr("value", targetId); 3303 }); 3213 3304 3214 form_upload.innerHTML = '<div style="margin:3px;">' + 3215 '<fieldset>' + 3216 '<legend>' + get_lang('zip mails to import') + '</legend>' + 3217 '<form method="POST" name="form_import" enctype="multipart/form-data">' + 3218 '<input name="file_1" maxlength="255" size="35" id="file_1" type="file"><br>' + 3219 '<input style="margin:5px;" title="'+get_lang('Select a folder')+'" value="'+get_lang('Select a folder')+'" type="button" onclick="javascript:select_import_folder()">'+ 3220 '<input title="'+get_lang("Close")+'" value="'+get_lang("Close")+'" type="button" onclick="arrayJSWin[\'import_window\'].close();">' + 3221 '</form>' + 3222 '</fieldset>' + 3223 '</div>'; 3224 win.open(); 3225 } 3226 3227 function import_msgs(wfolders_tree){ 3228 function handler(data){ 3229 // Its necessary to encapsulate the data returned (IE bugfix) 3230 return_import_msgs(data,wfolders_tree); 3231 } 3232 var countFiles = document.form_import.countFiles; 3233 if(!countFiles){ 3234 countFiles = document.createElement("INPUT"); 3235 countFiles.type = "hidden"; 3236 countFiles.name = "countFiles"; 3237 countFiles.value = "1"; 3238 document.form_import.appendChild(countFiles); 3239 } 3240 var folder = document.createElement("INPUT"); 3241 folder.type = "hidden"; 3242 folder.name = "folder"; 3243 folder.value = wfolders_tree._selected.id; 3244 document.form_import.appendChild(folder); 3245 write_msg(get_lang('You must wait while the messages will be imported...')); 3246 3247 cExecuteForm('$this.imap_functions.import_msgs', document.form_import, handler); 3248 } 3249 function return_import_msgs(data, wfolders_tree){ 3305 $("#lblFileName").prev().css("margin-left", "10px"); 3306 $("#lblFileName").prev().css("font-weight", "bold"); 3307 } 3308 3309 function return_import_msgs(data, folderID){ 3250 3310 if(data && data.error){ 3251 3311 write_msg(data.error); … … 3274 3334 Element("dJSWin_wfolders_bok").blur(); 3275 3335 } 3276 if(openTab.imapBox[0] == wfolders_tree._selected.id)3336 if(openTab.imapBox[0] == folderID) 3277 3337 { 3278 3338 openTab.imapBox[0] = '';
Note: See TracChangeset
for help on using the changeset viewer.