[2] | 1 | var BordersArray = new Array(); |
---|
| 2 | BordersArray[0] = new setBorderAttributes(0); |
---|
[5083] | 3 | var countBorders = 0; |
---|
[5134] | 4 | var partMsgs = new Array(); |
---|
[5604] | 5 | var msgAttachments = new Array(); |
---|
| 6 | var uidsSave = new Array(); |
---|
[5637] | 7 | var zebraDiscardEventDialog = false; |
---|
[6085] | 8 | var saveBorderError = new Array(); |
---|
| 9 | |
---|
[2] | 10 | function setBorderAttributes(ID) |
---|
| 11 | { |
---|
[7913] | 12 | this.border_id = "border_id_"+ID; |
---|
| 13 | this.sequence = ID; |
---|
[2] | 14 | } |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | function alternate_border(ID) |
---|
| 18 | { |
---|
[7913] | 19 | msg_selected = false;//Controle da seleção de mensagens |
---|
| 20 | if(isNaN(ID)) |
---|
| 21 | if(preferences.use_shortcuts == "1") |
---|
| 22 | select_msg((ID.split("_"))[0]); |
---|
| 23 | if( document.getElementById("div_menu_c3") != null ) |
---|
| 24 | { |
---|
| 25 | //div que contém divs de paginação de todas abas de listagem possíveis (listagem de pasta e listagem de pesquisa) |
---|
| 26 | var node = document.getElementById("div_menu_c3").firstChild; |
---|
| 27 | //Se for diferente da aba de listagem, remove a paginação |
---|
| 28 | if(currentTab != 0){ |
---|
| 29 | //Enquanto node for true (retorna false se não houver mais elementos) |
---|
| 30 | while ( node ) { |
---|
| 31 | node.style.display = "none"; |
---|
| 32 | node = node.nextSibling; |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | if( document.getElementById("span_paging"+ID) != null ) |
---|
| 37 | document.getElementById("span_paging"+ID).style.display = "block"; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | if ( typeof win == 'object' && win.close && win.close.constructor == Function ){ |
---|
[4787] | 41 | var search_win = document.getElementById( 'window_QuickCatalogSearch' ); |
---|
| 42 | if(search_win){ |
---|
| 43 | search_win.style.visibility = 'hidden'; |
---|
| 44 | } |
---|
| 45 | win.close( ); |
---|
| 46 | } |
---|
[7913] | 47 | |
---|
| 48 | if (! Element('border_id_'+ID)) |
---|
| 49 | return false; // Not possible to alternate |
---|
| 50 | show_hide_span_paging(ID); |
---|
| 51 | spanD = Element("span_D"); |
---|
| 52 | if (spanD) |
---|
| 53 | spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none'); |
---|
[1701] | 54 | |
---|
[7913] | 55 | var footer_menu = Element("footer_menu"); |
---|
| 56 | var aba = Element('border_id_'+ID); |
---|
| 57 | if (footer_menu != null) { |
---|
| 58 | footer_menu.style.display = (openTab.type[ID] != 4 ? '' : 'none'); |
---|
| 59 | var alternate_menu = document.getElementById('localOption'); |
---|
| 60 | |
---|
| 61 | if(alternate_menu != null && alternate_menu != 'undefined'){ //Quando Carregado o expresso mail |
---|
| 62 | if(openTab.imapBox[ID]!= null && openTab.imapBox[ID]!= 'undefined' ){ //Quando abrir uma Nova Mensagem |
---|
| 63 | if((openTab.imapBox[ID].indexOf("local_") >= 0)){ |
---|
| 64 | alternate_menu.title = get_lang("Unarchive"); |
---|
| 65 | alternate_menu.removeAttribute("onclick"); |
---|
| 66 | if(!is_ie) |
---|
| 67 | alternate_menu.setAttribute("onclick", 'expresso_local_messages.unarchive_msgs(\''+openTab.imapBox[ID]+'\', null)'); |
---|
| 68 | else{ |
---|
| 69 | alternate_menu.onclick = function(){ |
---|
| 70 | expresso_local_messages.unarchive_msgs(openTab.imapBox[ID], null); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | alternate_menu.innerHTML = get_lang("Unarchive"); |
---|
| 74 | |
---|
| 75 | }else{ |
---|
| 76 | alternate_menu.title = get_lang("Archive"); |
---|
| 77 | alternate_menu.removeAttribute("onclick"); |
---|
| 78 | if(!is_ie) |
---|
| 79 | alternate_menu.setAttribute("onclick", 'archive_msgs(\''+openTab.imapBox[ID]+'\', null)'); |
---|
| 80 | else{ |
---|
| 81 | alternate_menu.onclick = function(){ |
---|
| 82 | archive_msgs(openTab.imapBox[ID], null); |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | alternate_menu.innerHTML = get_lang("Archive"); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | if((aba.id.indexOf("_r") < 0) && (aba.id.indexOf("_0") < 0) && (aba.id.indexOf("id_search_") < 0) && (aba.id.indexOf("_s") < 0)){ |
---|
| 92 | spanD.style.display = 'none'; |
---|
| 93 | footer_menu.style.display = 'none'; |
---|
| 94 | } |
---|
| 95 | } |
---|
[1701] | 96 | |
---|
[5134] | 97 | |
---|
[7913] | 98 | var len = BordersArray.length; |
---|
| 99 | for (var i=0; i < len; i++) |
---|
| 100 | { |
---|
| 101 | m = document.getElementById(BordersArray[i].border_id); |
---|
| 102 | if ((m)&&(m.className == 'menu-sel')) |
---|
| 103 | { |
---|
| 104 | m.className = 'menu'; |
---|
| 105 | c = document.getElementById("content_id_"+BordersArray[i].sequence); |
---|
| 106 | c.style.display = 'none'; |
---|
| 107 | if(Element("font_border_id_"+BordersArray[i].sequence)) |
---|
| 108 | Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu'; |
---|
[5083] | 109 | |
---|
[7913] | 110 | } |
---|
| 111 | } |
---|
[2] | 112 | |
---|
[7913] | 113 | m = Element("border_id_"+ID); |
---|
| 114 | if (m) |
---|
| 115 | m.className = 'menu-sel'; |
---|
| 116 | if(Element("font_border_id_" + ID)) |
---|
| 117 | Element("font_border_id_" + ID).className = 'font-menu-sel'; |
---|
| 118 | var c = Element("content_id_"+ID) |
---|
| 119 | if (c) |
---|
| 120 | c.style.display = ''; |
---|
[2] | 121 | |
---|
| 122 | |
---|
[7913] | 123 | // hide the DropDrowContact, if necessary |
---|
| 124 | window_DropDownContacts = Element('tipDiv'); |
---|
| 125 | if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){ |
---|
| 126 | window_DropDownContacts.style.visibility = 'hidden'; |
---|
| 127 | } |
---|
[320] | 128 | |
---|
[7913] | 129 | numBox = getNumBoxFromTabId(ID); |
---|
| 130 | if (typeof(ID)=='number') { |
---|
[4889] | 131 | numBox = ID; |
---|
| 132 | } |
---|
| 133 | else { |
---|
| 134 | if (ID.match("search_")) |
---|
| 135 | { |
---|
| 136 | if (ID.match("search_local_msg")) |
---|
| 137 | { |
---|
| 138 | var p = ID.search(/[0-9]/); |
---|
| 139 | numBox = ID.substr(p); |
---|
| 140 | } |
---|
| 141 | else |
---|
| 142 | { |
---|
| 143 | numBox = ID.substr(7); |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | } |
---|
[7913] | 147 | currentTab=ID; |
---|
| 148 | if( document.getElementById('to_'+ID) && document.getElementById('to_'+ID).type == "textarea"){ |
---|
| 149 | document.getElementById('to_'+ID).focus(); |
---|
| 150 | } |
---|
| 151 | if (ID == 0){ |
---|
| 152 | updateSelectedMsgs(); |
---|
| 153 | } |
---|
| 154 | RichTextEditor.setEditable(ID); |
---|
| 155 | resizeWindow(); |
---|
| 156 | return ID; |
---|
[2] | 157 | } |
---|
| 158 | |
---|
[5219] | 159 | function create_border(borderTitle, id_value, search) |
---|
[2] | 160 | { |
---|
[7913] | 161 | borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); |
---|
[6104] | 162 | borderTitle = html_entities(borderTitle); |
---|
[7913] | 163 | var resize = false; |
---|
[3995] | 164 | resize = resize_borders(); |
---|
| 165 | if (!resize){ |
---|
| 166 | var str_continue = ''; |
---|
| 167 | var bolContinue = true; |
---|
[7913] | 168 | str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one'); |
---|
[3995] | 169 | if (preferences.auto_close_first_tab == 1){ |
---|
| 170 | var children = Element('border_tr').childNodes; |
---|
| 171 | var bolDelete = true; |
---|
| 172 | for (var i=0; i<children.length; i++) { |
---|
| 173 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) |
---|
| 174 | { |
---|
| 175 | bolDelete = true; |
---|
| 176 | var num_child = children[i].id.toString().substr(10); |
---|
| 177 | alternate_border(num_child); |
---|
| 178 | if (editTest(num_child)){ |
---|
| 179 | bolDelete = false; |
---|
| 180 | } |
---|
[5134] | 181 | if (bolDelete || bolContinue){ |
---|
[7913] | 182 | str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab'); |
---|
| 183 | var confirmacao = confirm(str_fechar); |
---|
[5134] | 184 | if(confirmacao){ |
---|
[3995] | 185 | bolContinue = false; |
---|
| 186 | delete_border(num_child, 'false'); |
---|
| 187 | break; |
---|
[7913] | 188 | }else{ |
---|
| 189 | return 'maximo'; |
---|
[3995] | 190 | } |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | } |
---|
[7913] | 194 | }else{ |
---|
[3995] | 195 | alert(get_lang('Reached maximum tab limit') + str_continue ); |
---|
[5134] | 196 | return 'maximo'; |
---|
[3995] | 197 | } |
---|
| 198 | } |
---|
[7913] | 199 | |
---|
| 200 | if (! id_value){ // Is new message? |
---|
| 201 | var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1; |
---|
| 202 | if(isNaN(ID)){ |
---|
| 203 | var aux = BordersArray[(BordersArray.length-1)].sequence.split("_"); |
---|
| 204 | ID = parseInt(aux[1]) + 1; |
---|
| 205 | } |
---|
[5172] | 206 | }else |
---|
[7913] | 207 | { |
---|
| 208 | if (Element("border_id_"+id_value)) // It's opened already! |
---|
| 209 | return alternate_border(id_value); |
---|
| 210 | |
---|
| 211 | var ID = id_value; |
---|
| 212 | if(isNaN(ID) && ID.indexOf("search_local") >= 0){ |
---|
| 213 | if(current_folder.indexOf("local") >= 0) |
---|
| 214 | openTab.imapBox[ID] = current_folder; |
---|
| 215 | else |
---|
| 216 | openTab.imapBox[ID] = 'local_search'; |
---|
| 217 | }else if(isNaN(ID) && ID.indexOf("search_") >= 0){ |
---|
| 218 | if(current_folder.indexOf("local") < 0) |
---|
| 219 | openTab.imapBox[ID] = current_folder; |
---|
| 220 | else |
---|
| 221 | openTab.imapBox[ID] = 'search'; |
---|
| 222 | }else if( (currentTab != 0) && isNaN(currentTab) && (currentTab.indexOf("search") >= 0) && (ID.indexOf("msg") < 0) ) { |
---|
| 223 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 224 | ID_TR = ID.toString().substr(0,ID.toString().indexOf("_r")); |
---|
| 225 | var tr = Element(ID_TR) ? Element(ID_TR) : Element(ID_TR+"_s"+id_border); |
---|
| 226 | openTab.imapBox[ID] = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 227 | }else |
---|
| 228 | openTab.imapBox[ID] = current_folder; |
---|
| 229 | } |
---|
| 230 | td = document.createElement("TD"); |
---|
| 231 | td.id="border_id_" + ID; |
---|
| 232 | if(resize) |
---|
| 233 | { |
---|
| 234 | td.setAttribute("width", parseInt(resize)+"px"); |
---|
| 235 | td.style.width = parseInt(resize)+"px"; |
---|
| 236 | } |
---|
| 237 | else |
---|
| 238 | td.setAttribute("width", "200px"); |
---|
[790] | 239 | |
---|
[7913] | 240 | td.setAttribute("align", "right"); |
---|
| 241 | td.onclick = function(){alternate_border(ID);resizeWindow()}; |
---|
| 242 | td.setAttribute("noWrap","true"); |
---|
[6122] | 243 | td.alt = ' '; |
---|
[3839] | 244 | td.title = borderTitle; |
---|
[7913] | 245 | borderTitle = borderTitle ? borderTitle : id_value ? get_lang("No Subject") : " " ; |
---|
| 246 | td.value = borderTitle; |
---|
| 247 | if (borderTitle.length > 21) |
---|
| 248 | borderTitle = borderTitle.substring(0,21) + "..."; |
---|
[790] | 249 | |
---|
[7913] | 250 | if ( resize ) |
---|
| 251 | borderTitle = borderTitle.substring(0, resize*0.08); |
---|
| 252 | |
---|
| 253 | var cc = search; |
---|
| 254 | if(!cc){ |
---|
| 255 | if(isNaN(ID)){ |
---|
| 256 | var is_local = ID.match('.*_local_.*'); |
---|
| 257 | if(!is_local) |
---|
| 258 | cc = document.getElementById("em_message_search").value; |
---|
| 259 | else{ |
---|
| 260 | if (currentTab == 0) |
---|
| 261 | cc = ""; |
---|
| 262 | else |
---|
| 263 | cc = document.getElementsByName(currentTab)[0].value; |
---|
| 264 | } |
---|
| 265 | }else{ |
---|
| 266 | cc =""; |
---|
| 267 | } |
---|
| 268 | } |
---|
| 269 | td.innerHTML = "<div><div id='font_border_id_" + ID+"' class='font-menu'>" + |
---|
[3525] | 270 | borderTitle + |
---|
| 271 | "</div>\n\ |
---|
[5754] | 272 | <div style='float:right;'>\n\ |
---|
[5213] | 273 | <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " + |
---|
| 274 | "</div>\n\ " + |
---|
[7913] | 275 | "<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>"; |
---|
| 276 | bb = document.getElementById("border_blank"); |
---|
| 277 | parent_bb = bb.parentNode; //Pego o tbody |
---|
| 278 | parent_bb.insertBefore(td, bb); |
---|
[790] | 279 | |
---|
[7913] | 280 | if((typeof(id_value) == 'string') && id_value.match(/_r/)){ |
---|
| 281 | $(td).draggable({ |
---|
| 282 | start : function(){ |
---|
| 283 | $('.upper, .lower').show(); |
---|
| 284 | $(".lower").css("top", ($("#content_folders").height()-18) + $("#content_folders").offset().top); |
---|
| 285 | /* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável, |
---|
| 286 | ou seja, nem de leitura (2), nem de lista de mensagens (0):*/ |
---|
| 287 | var current_tab_type = openTab.type[currentTab]; |
---|
| 288 | if (current_tab_type != 0 && current_tab_type != 2){ |
---|
| 289 | var dropzone = $("#fileupload_msg" + currentTab + "_droopzone"); |
---|
| 290 | dropzone.show(); |
---|
| 291 | dropzone.prev().hide(); |
---|
| 292 | dropzone.droppable({ |
---|
| 293 | over: function (event, ui){ |
---|
| 294 | dropzone.addClass('hover in'); |
---|
| 295 | $(ui.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); |
---|
| 296 | }, |
---|
| 297 | out: function (event, ui) { |
---|
| 298 | dropzone.removeClass('hover in'); |
---|
| 299 | $(ui.helper).find(".draggin-folder,.draggin-mail").css("color", ""); |
---|
| 300 | }, |
---|
| 301 | drop: function (event, ui) { |
---|
| 302 | var border_id = ui.draggable.find("input[type=hidden]").attr("name"); |
---|
| 303 | var id_msg = border_id.split("_")[0]; |
---|
| 304 | var folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); |
---|
[7972] | 305 | attach_message(folder, id_msg); /* Anexa a mensagem especificada (por folder e id_msg) |
---|
[7913] | 306 | na mensagem sendo criada.*/ |
---|
| 307 | } |
---|
| 308 | }); |
---|
| 309 | } |
---|
| 310 | if($(".shared-folders").length){ |
---|
| 311 | $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({ |
---|
| 312 | over : function(a, b){ |
---|
| 313 | //SETA BORDA EM VOLTA DA PASTA |
---|
| 314 | $(b.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); |
---|
| 315 | over = $(this); |
---|
| 316 | $(this).addClass("folder-over"); |
---|
| 317 | if(($(this)[0] != $(this).parent().find(".head_folder")[0])) |
---|
| 318 | if($(this).prev()[0]) |
---|
| 319 | if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ |
---|
| 320 | setTimeout(function(){ |
---|
| 321 | if(over.hasClass("folder-over")) |
---|
| 322 | over.prev().trigger("click"); |
---|
| 323 | }, 500); |
---|
| 324 | |
---|
| 325 | } |
---|
| 326 | //$("#content_folders").stop().scrollTo($(this), {axis:'y', margin:true, offset:-50, duration:400}); |
---|
| 327 | }, |
---|
| 328 | out : function(a,b){ |
---|
| 329 | //RETIRA BORDA EM VOLTA DA PASTA |
---|
| 330 | $(b.helper).find(".draggin-folder,.draggin-mail").css("color", ""); |
---|
| 331 | $(this).removeClass("folder-over"); |
---|
| 332 | }, |
---|
| 333 | //accept: ".draggin_mail", |
---|
| 334 | drop : function(event, ui){ |
---|
[8112] | 335 | $(this).css("border", "0"); |
---|
[7913] | 336 | if($(this).parent().attr('id') == undefined){ |
---|
| 337 | var folder_to = 'INBOX'; |
---|
| 338 | var to_folder_title = get_lang("Inbox"); |
---|
| 339 | }else{ |
---|
| 340 | var folder_to = $(this).parent().attr('id'); |
---|
| 341 | var to_folder_title = $(this).attr('title'); |
---|
| 342 | } |
---|
| 343 | var folder_to_move = ui.draggable.parent().attr('id'); |
---|
| 344 | var border_id = ui.draggable.find("input[type=hidden]").attr("name"); |
---|
| 345 | if(folder_to_move == "border_tr"){ |
---|
| 346 | var id_msg = border_id.split("_")[0]; |
---|
| 347 | folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); |
---|
| 348 | move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true); |
---|
| 349 | return refresh(); |
---|
| 350 | } |
---|
| 351 | } |
---|
| 352 | }); |
---|
| 353 | } |
---|
| 354 | }, |
---|
| 355 | stop :function(){ |
---|
| 356 | $('.upper, .lower').hide(); |
---|
| 357 | $(".shared-folders").parent().find(".folder").droppable("destroy"); |
---|
| 358 | /* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável, |
---|
| 359 | ou seja, nem de leitura (2), nem de lista de mensagens (0):*/ |
---|
| 360 | var current_tab_type = openTab.type[currentTab]; |
---|
| 361 | if (current_tab_type != 0 && current_tab_type != 2){ |
---|
| 362 | var dropzone = $("#fileupload_msg" + currentTab + "_droopzone"); |
---|
| 363 | dropzone.hide(); |
---|
| 364 | dropzone.prev().show(); |
---|
| 365 | } |
---|
| 366 | }, |
---|
| 367 | helper: function(event){ |
---|
| 368 | if( borderTitle.length > 18 ) |
---|
| 369 | return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>"); |
---|
| 370 | else |
---|
| 371 | return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>"); |
---|
| 372 | }, |
---|
| 373 | delay: 150, |
---|
| 374 | cursorAt: {top: 5, left: 56}, |
---|
| 375 | refreshPositions: true , |
---|
| 376 | containment: "#divAppbox" |
---|
| 377 | }); |
---|
| 378 | } |
---|
| 379 | //_dragArea.makeDragged(td, id_value,td.value); |
---|
[2] | 380 | |
---|
[7913] | 381 | BordersArray[BordersArray.length] = new setBorderAttributes(ID); |
---|
[790] | 382 | |
---|
[7913] | 383 | var div = document.createElement("DIV"); |
---|
| 384 | div.id = "content_id_" + ID; |
---|
| 385 | div.className = "conteudo"; |
---|
| 386 | div.style.display=''; |
---|
[2] | 387 | |
---|
[7913] | 388 | div.style.overflow = "hidden"; |
---|
[2] | 389 | |
---|
[7913] | 390 | Element("exmail_main_body").insertBefore(div,Element("footer_menu")); |
---|
| 391 | if (!is_ie) |
---|
| 392 | resizeWindow(); |
---|
| 393 | alternate_border(ID); |
---|
[6085] | 394 | uidsSave[ID] = []; |
---|
| 395 | saveBorderError[ID] = false; |
---|
[7913] | 396 | return ID; |
---|
[2] | 397 | } |
---|
| 398 | |
---|
| 399 | function resize_borders() |
---|
| 400 | { |
---|
[7913] | 401 | var numBorders = count_borders(); |
---|
[3336] | 402 | |
---|
[7913] | 403 | if (numBorders > 8) |
---|
| 404 | return false; |
---|
[3336] | 405 | |
---|
[7913] | 406 | return redim_borders(numBorders+1); |
---|
[3336] | 407 | } |
---|
| 408 | |
---|
| 409 | function count_borders() |
---|
| 410 | { |
---|
[7913] | 411 | var numBorders = 0; |
---|
| 412 | var children = Element('border_tr').childNodes; |
---|
| 413 | for (var i=0; i<children.length; i++) { |
---|
| 414 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) |
---|
| 415 | numBorders++; |
---|
| 416 | } |
---|
[3336] | 417 | |
---|
[7913] | 418 | return numBorders; |
---|
[3336] | 419 | } |
---|
| 420 | |
---|
| 421 | function redim_borders(numBorders) |
---|
| 422 | { |
---|
[7913] | 423 | var children = Element('border_tr').childNodes; |
---|
| 424 | var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30; |
---|
| 425 | var newWidthTD = (clientWidth/numBorders)-6; |
---|
| 426 | newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD); |
---|
| 427 | children = Element('border_tr').childNodes; |
---|
| 428 | for (var i=0; i<children.length; i++) { |
---|
| 429 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){ |
---|
| 430 | $(children[i]).css("width", newWidthTD); |
---|
| 431 | $(children[i]).find('div:first').css("width", newWidthTD); |
---|
| 432 | set_border_caption(children[i].id, children[i].title, newWidthTD); |
---|
| 433 | } |
---|
| 434 | } |
---|
| 435 | return newWidthTD; |
---|
[2] | 436 | } |
---|
| 437 | |
---|
[5268] | 438 | |
---|
| 439 | |
---|
| 440 | |
---|
[3525] | 441 | function set_border_caption(border_id, title, border_width) |
---|
[3372] | 442 | { |
---|
[3525] | 443 | var border = document.getElementById(border_id); |
---|
| 444 | if (border_width == null) |
---|
| 445 | { |
---|
| 446 | border_width = border.clientWidth; |
---|
| 447 | } |
---|
[7913] | 448 | var caption = ""; |
---|
[6458] | 449 | if (border != null){ |
---|
[7913] | 450 | Element("font_"+border.id).style.width = (border_width - 35)+'px'; |
---|
| 451 | Element("font_"+border.id).innerHTML = title; |
---|
| 452 | } |
---|
| 453 | return(title); |
---|
[3372] | 454 | } |
---|
| 455 | |
---|
[5268] | 456 | |
---|
[3977] | 457 | function draftTests(ID, msg_sent){ |
---|
[5637] | 458 | if( openTab.toPreserve[ID] = false) |
---|
| 459 | { |
---|
| 460 | close_delete(ID, msg_sent); |
---|
| 461 | delete(openTab.type[ID]); |
---|
| 462 | } |
---|
| 463 | else |
---|
| 464 | { |
---|
| 465 | var msg = 'Existem alterações não salvas na mensagem.'; |
---|
[6101] | 466 | var buttons = ['Descartar alterações', 'Salvar e fechar' ,'Cancelar']; |
---|
[6102] | 467 | var width = 371; |
---|
[5637] | 468 | if($('#fileupload_msg'+ID).find('.in-progress').length) |
---|
| 469 | { |
---|
[5702] | 470 | msg = 'Existem anexos sendo enviados para o servidor.'; |
---|
[5637] | 471 | buttons = ['Descartar alterações e anexos', 'Salvar estado atual fechar', 'Continuar editando']; |
---|
| 472 | width = 560; |
---|
| 473 | } |
---|
| 474 | zebraDiscardEventDialog = true; |
---|
| 475 | window.setTimeout(function() { |
---|
| 476 | $.Zebra_Dialog(msg, { |
---|
| 477 | 'type': 'question', |
---|
| 478 | 'overlay_opacity': '0.5', |
---|
[7913] | 479 | 'custom_class': 'custom-zebra-filter', |
---|
[5637] | 480 | 'buttons': buttons, |
---|
| 481 | 'width' : width, |
---|
| 482 | 'onClose': function(clicked) { |
---|
[7913] | 483 | if(clicked == 'Cancelar'){ |
---|
| 484 | if (RichTextEditor.plain[id] != true) |
---|
| 485 | setTimeout("RichTextEditor.focus("+ID+")",100); |
---|
| 486 | else |
---|
| 487 | $('#body_'+ID).focus(); |
---|
| 488 | } |
---|
[5637] | 489 | if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) { |
---|
| 490 | if (openTab.imapBox[ID] && !openTab.toPreserve[ID]) |
---|
| 491 | openTab.toPreserve[ID] = false; |
---|
| 492 | |
---|
| 493 | delete(openTab.type[ID]); |
---|
| 494 | close_delete(ID, msg_sent); |
---|
[7520] | 495 | |
---|
[5637] | 496 | } |
---|
| 497 | else if(clicked == 'Salvar e fechar' || clicked == 'Salvar estado atual fechar') |
---|
| 498 | { |
---|
| 499 | save_msg(ID); |
---|
| 500 | openTab.toPreserve[ID] = false; |
---|
[7520] | 501 | |
---|
[5637] | 502 | close_delete(ID, msg_sent); |
---|
| 503 | delete(openTab.type[ID]); |
---|
| 504 | } |
---|
| 505 | else{ |
---|
| 506 | |
---|
| 507 | Element("border_id_"+ID).onclick = function () {alternate_border(ID);}; |
---|
| 508 | var setFocus = function(ID){ |
---|
| 509 | if ($.trim($("#to_"+ID).val()) == "") |
---|
| 510 | $("#to_"+ID).focus(); |
---|
| 511 | else if ($("#tr_cc_"+ID).css('display') != 'none' && $.trim($("#cc_"+ID).val()) == "") |
---|
| 512 | $("#cc_"+ID).focus(); |
---|
| 513 | else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "") |
---|
[7913] | 514 | $("#cco_"+ID).focus(); |
---|
[5637] | 515 | else if ($.trim($("#subject_"+ID).val()) == "") |
---|
| 516 | $("#subject_"+ID).focus(); |
---|
| 517 | else{ |
---|
| 518 | if (RichTextEditor.plain[id] != true) |
---|
| 519 | setTimeout("RichTextEditor.focus("+ID+")",100); |
---|
| 520 | else |
---|
| 521 | $('#body_'+ID).focus(); |
---|
| 522 | } |
---|
| 523 | } |
---|
| 524 | setFocus(ID); |
---|
| 525 | } |
---|
| 526 | window.setTimeout(function() { |
---|
| 527 | zebraDiscardEventDialog = false; |
---|
| 528 | }, 500); |
---|
| 529 | }})}, 300); |
---|
| 530 | } |
---|
[7913] | 531 | |
---|
[3977] | 532 | } |
---|
| 533 | |
---|
[3995] | 534 | function editTest(ID){ |
---|
| 535 | var body = document.getElementById('body_'+ ID); |
---|
[7913] | 536 | var content = $('#content_id_'+ ID); |
---|
[3995] | 537 | if (body) |
---|
| 538 | { |
---|
[5911] | 539 | var save_link = content.find(".save"); |
---|
[3995] | 540 | if (openTab.toPreserve[ID] == undefined) |
---|
| 541 | openTab.toPreserve[ID] = false; |
---|
| 542 | if (((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on')) && (save_link.onclick != '')) |
---|
| 543 | { |
---|
| 544 | return true; |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | return false; |
---|
| 548 | } |
---|
| 549 | |
---|
[2] | 550 | function delete_border(ID, msg_sent) |
---|
| 551 | { |
---|
[7710] | 552 | var borderElem = Element("border_id_" + ID); |
---|
| 553 | if (borderElem){ |
---|
| 554 | borderElem.onclick = null; |
---|
| 555 | }else{ |
---|
| 556 | return false; |
---|
| 557 | } |
---|
[7520] | 558 | |
---|
[7879] | 559 | if($("#content_id_"+ID+" textarea[name=input_to]").length ){ |
---|
| 560 | if($("#content_id_"+ID+" .save").is(':disabled') ) { |
---|
[7520] | 561 | close_delete(ID, msg_sent); |
---|
[7879] | 562 | } else if( $("#content_id_"+ID+" .save").is(':enabled') ) { |
---|
[7520] | 563 | return(draftTests(ID, msg_sent)); |
---|
| 564 | } |
---|
| 565 | } else { |
---|
| 566 | close_delete(ID, msg_sent); |
---|
| 567 | } |
---|
[7710] | 568 | |
---|
| 569 | delete(openTab.type[ID]); |
---|
[7765] | 570 | //refresh(); |
---|
[7710] | 571 | return true; |
---|
[7520] | 572 | |
---|
| 573 | /*var bolExecuteClose = true; |
---|
[7913] | 574 | var borderElem = Element("border_id_" + ID); |
---|
| 575 | if (borderElem){ |
---|
[3995] | 576 | borderElem.onclick = null; // It's avoid a FF3 bug |
---|
| 577 | }else{ |
---|
| 578 | return false; |
---|
| 579 | } |
---|
[7913] | 580 | if (msg_sent == 'false') |
---|
| 581 | { |
---|
[3995] | 582 | if (editTest(ID)){ |
---|
| 583 | bolExecuteClose = false; |
---|
[5637] | 584 | if(zebraDiscardEventDialog === false) |
---|
| 585 | return(draftTests(ID, msg_sent)); |
---|
[3995] | 586 | } |
---|
[7913] | 587 | } |
---|
[7520] | 588 | |
---|
| 589 | |
---|
[3977] | 590 | if (bolExecuteClose) |
---|
| 591 | { |
---|
| 592 | close_delete(ID, msg_sent); |
---|
[7913] | 593 | } |
---|
| 594 | delete(openTab.type[ID]); |
---|
[7520] | 595 | return true;*/ |
---|
[7710] | 596 | |
---|
[3977] | 597 | } |
---|
[2] | 598 | |
---|
[3977] | 599 | function close_delete(ID, msg_sent) |
---|
| 600 | { |
---|
[7913] | 601 | openTab.toPreserve[ID] = false; |
---|
[5459] | 602 | // Limpa o autosave |
---|
| 603 | if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null ) |
---|
| 604 | { |
---|
| 605 | autoSaveControl.status[ID] = null; |
---|
| 606 | clearInterval(autoSaveControl.timer[ID]); |
---|
| 607 | } |
---|
| 608 | //////////////////////////////// |
---|
| 609 | |
---|
[7913] | 610 | hold_session = false; |
---|
| 611 | if (exist_className(Element('border_id_'+ID),'menu-sel')) |
---|
| 612 | { |
---|
| 613 | if (BordersArray[BordersArray.length-2].sequence == ID) |
---|
| 614 | this.alternate_border(0); |
---|
| 615 | else |
---|
| 616 | this.alternate_border(BordersArray[BordersArray.length-2].sequence); |
---|
| 617 | } |
---|
[2] | 618 | |
---|
[7913] | 619 | // Remove TD, title |
---|
| 620 | border = Element('border_id_' + ID); |
---|
| 621 | border.parentNode.removeChild(border); |
---|
| 622 | var j=0; |
---|
| 623 | var new_BordersArray = new Array(); |
---|
| 624 | for (i=0;i<BordersArray.length;i++) |
---|
| 625 | if (document.getElementById(BordersArray[i].border_id) != null){ |
---|
| 626 | new_BordersArray[j] = BordersArray[i]; |
---|
| 627 | j++; |
---|
| 628 | } |
---|
| 629 | if(j == 1) |
---|
| 630 | Element("footer_menu").style.display = ''; |
---|
| 631 | BordersArray = new_BordersArray; |
---|
[790] | 632 | |
---|
[7913] | 633 | // Remove Div Content |
---|
| 634 | content = Element('content_id_' + ID); |
---|
| 635 | content.parentNode.removeChild(content); |
---|
| 636 | if(is_webkit) |
---|
| 637 | resizeWindow(); |
---|
| 638 | RichTextEditor.destroy( 'body_'+ID ); |
---|
[5620] | 639 | delete msgAttachments[ID]; |
---|
[5134] | 640 | //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba |
---|
| 641 | var isPartMsg = false; |
---|
[7913] | 642 | if(!parseInt(id2)) |
---|
| 643 | return; |
---|
[5134] | 644 | var id2 = ID.replace('_r',''); |
---|
| 645 | for(var ii = 0; ii < partMsgs.length; ii++) |
---|
| 646 | if(partMsgs[ii] == id2){ |
---|
| 647 | isPartMsg = true; |
---|
| 648 | partMsgs[ii] = null; |
---|
| 649 | } |
---|
| 650 | |
---|
| 651 | if(isPartMsg === true){ |
---|
| 652 | var handler_delete_msg = function(){}; |
---|
| 653 | cExecute ("$this.imap_functions.delete_msgs&folder=INBOX"+cyrus_delimiter+trashfolder+"&msgs_number="+id2,handler_delete_msg); |
---|
| 654 | } |
---|
| 655 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 656 | |
---|
[7913] | 657 | return true; |
---|
[4802] | 658 | } |
---|
| 659 | |
---|
[5134] | 660 | function getTabPrefix() { // define o prefixo para os checkboxes das mensagens |
---|
[7913] | 661 | if (typeof(currentTab)!='number') |
---|
| 662 | return currentTab+"_"; |
---|
| 663 | else |
---|
| 664 | return ""; |
---|
[5134] | 665 | } |
---|
| 666 | |
---|
[4807] | 667 | function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha |
---|
[7913] | 668 | var p = row_id.search("_s"); |
---|
| 669 | if (p>0) |
---|
| 670 | return row_id.substr(0,p); |
---|
| 671 | else |
---|
| 672 | return row_id; |
---|
[4807] | 673 | } |
---|
| 674 | |
---|
| 675 | function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab |
---|
[7913] | 676 | if (typeof(tab_id)=='number') { |
---|
| 677 | return tab_id; |
---|
| 678 | } |
---|
| 679 | else { |
---|
| 680 | var p = tab_id.search(/[0-9]/); |
---|
| 681 | return tab_id.substr(p); |
---|
| 682 | } |
---|
[4843] | 683 | } |
---|
[5604] | 684 | |
---|
| 685 | function addAttachment(ID, att) |
---|
| 686 | { |
---|
| 687 | if(typeof(msgAttachments[ID]) == 'undefined') |
---|
| 688 | msgAttachments[ID] = []; |
---|
| 689 | |
---|
| 690 | msgAttachments[ID].push(att); |
---|
| 691 | } |
---|
| 692 | |
---|
| 693 | function delAttachment(ID, att) |
---|
| 694 | { |
---|
| 695 | |
---|
| 696 | if(msgAttachments[ID] == undefined) return; |
---|
| 697 | var len = msgAttachments[ID].length; |
---|
| 698 | for(var i = 0; i < len; i++) |
---|
| 699 | { |
---|
| 700 | if(msgAttachments[ID][i] == att) |
---|
| 701 | { |
---|
[5620] | 702 | delete msgAttachments[ID][i]; |
---|
[5604] | 703 | break; |
---|
| 704 | } |
---|
| 705 | } |
---|
| 706 | } |
---|
| 707 | |
---|
| 708 | function listAttachment(ID) |
---|
| 709 | { |
---|
[8063] | 710 | return (typeof(msgAttachments[ID]) == 'undefined') ? '' : JSON.stringify(msgAttachments[ID]); |
---|
[5604] | 711 | } |
---|