[2] | 1 | var BordersArray = new Array(); |
---|
| 2 | BordersArray[0] = new setBorderAttributes(0); |
---|
| 3 | |
---|
| 4 | function setBorderAttributes(ID) |
---|
| 5 | { |
---|
| 6 | this.border_id = "border_id_"+ID; |
---|
| 7 | this.sequence = ID; |
---|
| 8 | } |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | function alternate_border(ID) |
---|
| 12 | { |
---|
[3839] | 13 | if( document.getElementById("div_menu_c3") != null ) |
---|
| 14 | { |
---|
| 15 | var node = document.getElementById("div_menu_c3").firstChild; |
---|
| 16 | |
---|
| 17 | while ( node ) |
---|
| 18 | { |
---|
| 19 | node.style.display = "none"; |
---|
| 20 | node = node.nextSibling; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | if( document.getElementById("span_paging"+ID) != null ) |
---|
| 24 | document.getElementById("span_paging"+ID).style.display = "block"; |
---|
| 25 | } |
---|
| 26 | |
---|
[4787] | 27 | if ( typeof win == 'object' && win.close && win.close.constructor == Function ){ |
---|
| 28 | var search_win = document.getElementById( 'window_QuickCatalogSearch' ); |
---|
| 29 | if(search_win){ |
---|
| 30 | search_win.style.visibility = 'hidden'; |
---|
| 31 | } |
---|
| 32 | win.close( ); |
---|
| 33 | } |
---|
| 34 | |
---|
[320] | 35 | if (! Element('border_id_'+ID)) |
---|
| 36 | return false; // Not possible to alternate |
---|
[412] | 37 | show_hide_span_paging(ID); |
---|
[790] | 38 | spanD = Element("span_D"); |
---|
| 39 | if (spanD) |
---|
| 40 | spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none'); |
---|
[1701] | 41 | |
---|
| 42 | var footer_menu = Element("footer_menu"); |
---|
| 43 | if (footer_menu) { |
---|
| 44 | footer_menu.style.display = (openTab.type[ID] != 4 ? '' : 'none'); |
---|
| 45 | } |
---|
| 46 | |
---|
[2] | 47 | var len = BordersArray.length; |
---|
| 48 | for (var i=0; i < len; i++) |
---|
| 49 | { |
---|
| 50 | m = document.getElementById(BordersArray[i].border_id); |
---|
[320] | 51 | if ((m)&&(m.className == 'menu-sel')) |
---|
[2] | 52 | { |
---|
| 53 | m.className = 'menu'; |
---|
| 54 | c = document.getElementById("content_id_"+BordersArray[i].sequence); |
---|
| 55 | c.style.display = 'none'; |
---|
| 56 | if(Element("font_border_id_"+BordersArray[i].sequence)) |
---|
| 57 | Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu'; |
---|
| 58 | var body = Element('body_'+BordersArray[i].sequence); |
---|
| 59 | if (body) |
---|
| 60 | { |
---|
| 61 | try |
---|
| 62 | { |
---|
[4291] | 63 | if (Element('viewsource_rt_checkbox_' + ID).checked) |
---|
[2] | 64 | { |
---|
| 65 | connector.loadScript("rich_text_editor"); |
---|
| 66 | RichTextEditor.viewsource(false); |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | catch(e) |
---|
| 70 | { |
---|
| 71 | //alert(e.message) |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | m = Element("border_id_"+ID); |
---|
[320] | 78 | if (m) |
---|
| 79 | m.className = 'menu-sel'; |
---|
[2] | 80 | if(Element("font_border_id_" + ID)) |
---|
| 81 | Element("font_border_id_" + ID).className = 'font-menu-sel'; |
---|
| 82 | var c = Element("content_id_"+ID) |
---|
[320] | 83 | if (c) |
---|
| 84 | c.style.display = ''; |
---|
[2] | 85 | |
---|
| 86 | body = document.getElementById('body_'+ ID); |
---|
| 87 | if (body){ |
---|
| 88 | try{ |
---|
| 89 | if(ID){ |
---|
| 90 | connector.loadScript("rich_text_editor"); |
---|
[3068] | 91 | if(typeof(RichTextEditor) == 'undefined'){ |
---|
[3174] | 92 | setTimeout('alternate_border(\''+ID+'\');',500); |
---|
[3068] | 93 | return false; |
---|
| 94 | } |
---|
[2] | 95 | RichTextEditor.loadEditor(ID); |
---|
| 96 | } |
---|
| 97 | body.contentWindow.document.designMode="on"; |
---|
| 98 | } |
---|
| 99 | catch(e){ |
---|
| 100 | //alert(e.message); |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | // hide the DropDrowContact, if necessary |
---|
| 105 | window_DropDownContacts = Element('tipDiv'); |
---|
| 106 | if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){ |
---|
| 107 | window_DropDownContacts.style.visibility = 'hidden'; |
---|
| 108 | } |
---|
[320] | 109 | |
---|
[4807] | 110 | numBox = getNumBoxFromTabId(ID); |
---|
[1701] | 111 | currentTab=ID; |
---|
[3839] | 112 | |
---|
[3876] | 113 | if( document.getElementById('to_'+ID) && document.getElementById('to_'+ID).type == "textarea"){ |
---|
[3839] | 114 | document.getElementById('to_'+ID).focus(); |
---|
[3876] | 115 | } |
---|
[3606] | 116 | |
---|
[2] | 117 | return ID; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | function create_border(borderTitle, id_value) |
---|
| 121 | { |
---|
[3776] | 122 | borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); |
---|
| 123 | |
---|
[790] | 124 | var resize = false; |
---|
[3995] | 125 | resize = resize_borders(); |
---|
| 126 | if (!resize){ |
---|
| 127 | var str_continue = ''; |
---|
| 128 | var bolContinue = true; |
---|
| 129 | if (preferences.auto_close_first_tab == 1){ |
---|
| 130 | str_continue = '\n' + get_lang('You must manualy close one of your tabs before opening a new one'); |
---|
| 131 | var children = Element('border_tr').childNodes; |
---|
| 132 | var bolDelete = true; |
---|
| 133 | for (var i=0; i<children.length; i++) { |
---|
| 134 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) |
---|
| 135 | { |
---|
| 136 | bolDelete = true; |
---|
| 137 | var num_child = children[i].id.toString().substr(10); |
---|
| 138 | alternate_border(num_child); |
---|
| 139 | if (editTest(num_child)){ |
---|
| 140 | bolDelete = false; |
---|
| 141 | } |
---|
| 142 | if (bolDelete){ |
---|
| 143 | bolContinue = false; |
---|
| 144 | delete_border(num_child, 'false'); |
---|
| 145 | break; |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | if (bolContinue){ |
---|
| 151 | alert(get_lang('Reached maximum tab limit') + str_continue ); |
---|
[4139] | 152 | return 0; |
---|
[3995] | 153 | } |
---|
| 154 | } |
---|
[2] | 155 | |
---|
[271] | 156 | if (! id_value) // Is new message? |
---|
| 157 | var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1; |
---|
[790] | 158 | else |
---|
| 159 | { |
---|
[3839] | 160 | if (Element("border_id_"+id_value)) // It's opened already! |
---|
[790] | 161 | return alternate_border(id_value); |
---|
[3839] | 162 | |
---|
[271] | 163 | var ID = id_value; |
---|
[3018] | 164 | openTab.imapBox[ID] = current_folder; |
---|
[271] | 165 | } |
---|
[2] | 166 | td = document.createElement("TD"); |
---|
| 167 | td.id="border_id_" + ID; |
---|
[3839] | 168 | if(resize) |
---|
| 169 | { |
---|
[2] | 170 | td.setAttribute("width", parseInt(resize)+"px"); |
---|
| 171 | td.style.width = parseInt(resize)+"px"; |
---|
| 172 | } |
---|
| 173 | else |
---|
| 174 | td.setAttribute("width", "200px"); |
---|
[790] | 175 | |
---|
[2] | 176 | td.setAttribute("align", "right"); |
---|
[3018] | 177 | td.onclick = function(){alternate_border(ID);resizeWindow()}; |
---|
[2] | 178 | td.setAttribute("noWrap","true"); |
---|
[3839] | 179 | td.alt = borderTitle.replace( ' ', ' ' ); |
---|
| 180 | td.title = borderTitle; |
---|
[2] | 181 | borderTitle = borderTitle ? borderTitle : id_value ? get_lang("No Subject") : " " ; |
---|
| 182 | td.value = borderTitle; |
---|
[790] | 183 | if (borderTitle.length > 21) |
---|
[2] | 184 | borderTitle = borderTitle.substring(0,21) + "..."; |
---|
[790] | 185 | |
---|
[3839] | 186 | if ( resize ) |
---|
[2] | 187 | borderTitle = borderTitle.substring(0, resize*0.08); |
---|
| 188 | |
---|
[3525] | 189 | td.innerHTML = "<div style='width:100%;border:0;padding:0;'>\n\ |
---|
| 190 | <div id='font_border_id_" + ID+"' class='font-menu' style='width:*;'>" + |
---|
| 191 | borderTitle + |
---|
| 192 | "</div>\n\ |
---|
| 193 | <div style='width:1px;float:left;clear:right;'>\n\ |
---|
| 194 | <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ |
---|
| 195 | </div>\n\ |
---|
| 196 | </div>"; |
---|
[790] | 197 | |
---|
[2] | 198 | bb = document.getElementById("border_blank"); |
---|
| 199 | parent_bb = bb.parentNode; //Pego o tbody |
---|
| 200 | parent_bb.insertBefore(td, bb); |
---|
[790] | 201 | |
---|
| 202 | if(! Element("border_id_"+id_value+"_r") ||((typeof(id_value) == 'string') && id_value.match(/_r$/))) |
---|
[2] | 203 | _dragArea.makeDragged(td, id_value,td.value); |
---|
| 204 | |
---|
| 205 | BordersArray[BordersArray.length] = new setBorderAttributes(ID); |
---|
[790] | 206 | |
---|
[2] | 207 | var div = document.createElement("DIV"); |
---|
| 208 | div.id = "content_id_" + ID; |
---|
| 209 | div.className = "conteudo"; |
---|
| 210 | div.style.display=''; |
---|
| 211 | |
---|
[320] | 212 | div.style.overflow = "hidden"; |
---|
[2] | 213 | |
---|
[790] | 214 | Element("exmail_main_body").insertBefore(div,Element("footer_menu")); |
---|
[2] | 215 | alternate_border(ID); |
---|
| 216 | return ID; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | function resize_borders() |
---|
| 220 | { |
---|
[3336] | 221 | var numBorders = count_borders(); |
---|
| 222 | |
---|
[2] | 223 | if (numBorders > 8) |
---|
| 224 | return false; |
---|
[3336] | 225 | |
---|
| 226 | return redim_borders(numBorders+1); |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | function count_borders() |
---|
| 230 | { |
---|
| 231 | var numBorders = 0; |
---|
| 232 | var children = Element('border_tr').childNodes; |
---|
[2] | 233 | for (var i=0; i<children.length; i++) { |
---|
[3336] | 234 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) |
---|
| 235 | numBorders++; |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | return numBorders; |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | function redim_borders(numBorders) |
---|
| 242 | { |
---|
| 243 | var children = Element('border_tr').childNodes; |
---|
| 244 | var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30; |
---|
| 245 | var newWidthTD = (clientWidth/numBorders)-6; |
---|
| 246 | newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD); |
---|
| 247 | children = Element('border_tr').childNodes; |
---|
| 248 | for (var i=0; i<children.length; i++) { |
---|
[2] | 249 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){ |
---|
| 250 | children[i].style.width = newWidthTD; |
---|
[3525] | 251 | set_border_caption(children[i].id, children[i].title, newWidthTD); |
---|
[2] | 252 | } |
---|
| 253 | } |
---|
| 254 | return newWidthTD; |
---|
| 255 | } |
---|
| 256 | |
---|
[3525] | 257 | function set_border_caption(border_id, title, border_width) |
---|
[3372] | 258 | { |
---|
[3525] | 259 | var border = document.getElementById(border_id); |
---|
| 260 | if (border_width == null) |
---|
| 261 | { |
---|
| 262 | border_width = border.clientWidth; |
---|
| 263 | } |
---|
[3372] | 264 | var caption = ""; |
---|
[3525] | 265 | Element("font_"+border.id).style.width = (border_width - 25)+'px'; |
---|
[3372] | 266 | Element("font_"+border.id).innerHTML = title; |
---|
| 267 | return(title); |
---|
| 268 | } |
---|
| 269 | |
---|
[3977] | 270 | function draftTests(ID, msg_sent){ |
---|
| 271 | var cancel = new LertButton(get_lang('cancel'), function() { |
---|
[3995] | 272 | Element("border_id_"+ID).onclick = function () {alternate_border(ID);}; |
---|
[3977] | 273 | }); |
---|
| 274 | var yes = new LertButton(get_lang('Save'), function() { |
---|
[3995] | 275 | save_msg(ID); |
---|
| 276 | openTab.toPreserve[ID] = false; |
---|
| 277 | close_delete(ID, msg_sent); |
---|
[4460] | 278 | delete(openTab.type[ID]); |
---|
| 279 | write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder('Drafts'))); |
---|
[3977] | 280 | }); |
---|
| 281 | var discard = new LertButton(get_lang('Discard'), function() { |
---|
| 282 | if (openTab.imapBox[ID] && !openTab.toPreserve[ID]) |
---|
| 283 | { |
---|
| 284 | //delete_msgs(openTab.imapBox[ID], openTab.imapUid[ID].toString(), 0) |
---|
| 285 | //delete(openTab.imapBox[ID]); |
---|
| 286 | openTab.toPreserve[ID] = false; |
---|
| 287 | } |
---|
[4460] | 288 | delete(openTab.type[ID]); |
---|
[3977] | 289 | close_delete(ID, msg_sent); |
---|
| 290 | }); |
---|
| 291 | var titulo = '<b>' + get_lang('Warning') + '!</b>'; |
---|
| 292 | var message = get_lang("Your changes are not saved. What to do?"); |
---|
| 293 | var multConfirm = new Lert( |
---|
| 294 | titulo, |
---|
| 295 | message, |
---|
| 296 | [cancel,discard,yes], |
---|
| 297 | { |
---|
| 298 | defaultButton:yes, |
---|
| 299 | icon:'js/lert/images/dialog-help.gif' |
---|
| 300 | }); |
---|
| 301 | multConfirm.display(); |
---|
| 302 | } |
---|
| 303 | |
---|
[3995] | 304 | function editTest(ID){ |
---|
| 305 | var body = document.getElementById('body_'+ ID); |
---|
| 306 | if (body) |
---|
| 307 | { |
---|
| 308 | var save_link = Element("save_message_options_"+ID); |
---|
| 309 | if (openTab.toPreserve[ID] == undefined) |
---|
| 310 | openTab.toPreserve[ID] = false; |
---|
| 311 | if (((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on')) && (save_link.onclick != '')) |
---|
| 312 | { |
---|
| 313 | return true; |
---|
| 314 | } |
---|
| 315 | } |
---|
| 316 | return false; |
---|
| 317 | } |
---|
| 318 | |
---|
[2] | 319 | function delete_border(ID, msg_sent) |
---|
| 320 | { |
---|
[3977] | 321 | var bolExecuteClose = true; |
---|
[648] | 322 | var borderElem = Element("border_id_" + ID) |
---|
[3995] | 323 | if (borderElem){ |
---|
| 324 | borderElem.onclick = null; // It's avoid a FF3 bug |
---|
| 325 | }else{ |
---|
| 326 | return false; |
---|
| 327 | } |
---|
[2] | 328 | if (msg_sent == 'false') |
---|
| 329 | { |
---|
[3995] | 330 | if (editTest(ID)){ |
---|
| 331 | bolExecuteClose = false; |
---|
| 332 | return(draftTests(ID, msg_sent)); |
---|
| 333 | } |
---|
[2] | 334 | } |
---|
[3977] | 335 | if (bolExecuteClose) |
---|
| 336 | { |
---|
| 337 | close_delete(ID, msg_sent); |
---|
[4460] | 338 | } |
---|
| 339 | delete(openTab.type[ID]); |
---|
[3977] | 340 | return true; |
---|
| 341 | } |
---|
[2] | 342 | |
---|
[3977] | 343 | function close_delete(ID, msg_sent) |
---|
| 344 | { |
---|
[606] | 345 | openTab.toPreserve[ID] = false; |
---|
| 346 | openTab.imapUid[ID] = 0; |
---|
[271] | 347 | |
---|
[801] | 348 | if (preferences.auto_save_draft == 1) |
---|
| 349 | { |
---|
| 350 | if (openTab.autosave_timer[ID]) |
---|
| 351 | clearTimeout(openTab.autosave_timer[ID]); |
---|
| 352 | openTab.autosave_timer[ID] = false; |
---|
| 353 | } |
---|
| 354 | |
---|
[2] | 355 | hold_session = false; |
---|
[790] | 356 | if (exist_className(Element('border_id_'+ID),'menu-sel')) |
---|
[2] | 357 | { |
---|
[790] | 358 | if (BordersArray[BordersArray.length-2].sequence == ID) |
---|
[2] | 359 | this.alternate_border(0); |
---|
| 360 | else |
---|
[790] | 361 | this.alternate_border(BordersArray[BordersArray.length-2].sequence); |
---|
[2] | 362 | } |
---|
| 363 | |
---|
| 364 | // Remove TD, title |
---|
[320] | 365 | border = Element('border_id_' + ID); |
---|
[2] | 366 | border.parentNode.removeChild(border); |
---|
[790] | 367 | var j=0; |
---|
[2] | 368 | var new_BordersArray = new Array(); |
---|
| 369 | for (i=0;i<BordersArray.length;i++) |
---|
[790] | 370 | if (document.getElementById(BordersArray[i].border_id) != null){ |
---|
[2] | 371 | new_BordersArray[j] = BordersArray[i]; |
---|
[790] | 372 | j++; |
---|
[2] | 373 | } |
---|
[58] | 374 | if(j == 1) |
---|
| 375 | Element("footer_menu").style.display = ''; |
---|
[2] | 376 | BordersArray = new_BordersArray; |
---|
[790] | 377 | |
---|
| 378 | // Remove Div Content |
---|
| 379 | content = Element('content_id_' + ID); |
---|
| 380 | content.parentNode.removeChild(content); |
---|
[3018] | 381 | resizeWindow(); |
---|
[320] | 382 | return true; |
---|
[4802] | 383 | } |
---|
| 384 | |
---|
[4807] | 385 | function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha |
---|
| 386 | var p = row_id.search("_s"); |
---|
| 387 | if (p>0) |
---|
| 388 | return row_id.substr(0,p); |
---|
[4802] | 389 | else |
---|
| 390 | return row_id; |
---|
[4807] | 391 | } |
---|
| 392 | |
---|
| 393 | function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab |
---|
| 394 | if (typeof(tab_id)=='number') { |
---|
| 395 | return tab_id; |
---|
| 396 | } |
---|
| 397 | else { |
---|
| 398 | var p = tab_id.search(/[0-9]/); |
---|
| 399 | return tab_id.substr(p); |
---|
| 400 | } |
---|
[4843] | 401 | } |
---|
| 402 | |
---|
| 403 | function getTabSufix() { |
---|
| 404 | if (typeof(currentTab)=='number') |
---|
| 405 | return ''; |
---|
| 406 | else |
---|
| 407 | return '_s' + numBox.toString(); |
---|
[3977] | 408 | } |
---|