[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 | { |
---|
[320] | 13 | if (! Element('border_id_'+ID)) |
---|
| 14 | return false; // Not possible to alternate |
---|
[412] | 15 | show_hide_span_paging(ID); |
---|
[790] | 16 | spanD = Element("span_D"); |
---|
| 17 | if (spanD) |
---|
| 18 | spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none'); |
---|
[2] | 19 | var len = BordersArray.length; |
---|
| 20 | for (var i=0; i < len; i++) |
---|
| 21 | { |
---|
| 22 | m = document.getElementById(BordersArray[i].border_id); |
---|
[320] | 23 | if ((m)&&(m.className == 'menu-sel')) |
---|
[2] | 24 | { |
---|
| 25 | m.className = 'menu'; |
---|
| 26 | c = document.getElementById("content_id_"+BordersArray[i].sequence); |
---|
| 27 | c.style.display = 'none'; |
---|
| 28 | if(Element("font_border_id_"+BordersArray[i].sequence)) |
---|
| 29 | Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu'; |
---|
| 30 | var body = Element('body_'+BordersArray[i].sequence); |
---|
| 31 | if (body) |
---|
| 32 | { |
---|
| 33 | try |
---|
| 34 | { |
---|
| 35 | if (Element('viewsource_rt_checkbox').checked) |
---|
| 36 | { |
---|
[1661] | 37 | expresso.connector.loadScript("rich_text_editor"); |
---|
[2] | 38 | RichTextEditor.viewsource(false); |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | catch(e) |
---|
| 42 | { |
---|
| 43 | //alert(e.message) |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | m = Element("border_id_"+ID); |
---|
[320] | 50 | if (m) |
---|
| 51 | m.className = 'menu-sel'; |
---|
[2] | 52 | if(Element("font_border_id_" + ID)) |
---|
| 53 | Element("font_border_id_" + ID).className = 'font-menu-sel'; |
---|
| 54 | var c = Element("content_id_"+ID) |
---|
[320] | 55 | if (c) |
---|
| 56 | c.style.display = ''; |
---|
[2] | 57 | |
---|
| 58 | body = document.getElementById('body_'+ ID); |
---|
| 59 | if (body){ |
---|
| 60 | try{ |
---|
| 61 | if(ID){ |
---|
[1661] | 62 | expresso.connector.loadScript("rich_text_editor"); |
---|
[2] | 63 | RichTextEditor.loadEditor(ID); |
---|
| 64 | } |
---|
| 65 | body.contentWindow.document.designMode="on"; |
---|
| 66 | } |
---|
| 67 | catch(e){ |
---|
| 68 | //alert(e.message); |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | // hide the DropDrowContact, if necessary |
---|
| 73 | window_DropDownContacts = Element('tipDiv'); |
---|
| 74 | if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){ |
---|
| 75 | window_DropDownContacts.style.visibility = 'hidden'; |
---|
| 76 | } |
---|
[320] | 77 | |
---|
| 78 | if (typeof(ID) == 'number') |
---|
| 79 | { |
---|
[606] | 80 | current_folder = openTab.imapBox[ID]; |
---|
| 81 | openTab.type[ID] = 0; |
---|
[320] | 82 | numBox=ID; |
---|
| 83 | } |
---|
[790] | 84 | else |
---|
| 85 | if (ID.match("search_")) |
---|
| 86 | numBox=ID.substr(7); |
---|
[606] | 87 | currentTab=ID; |
---|
[2] | 88 | return ID; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | function create_border(borderTitle, id_value) |
---|
| 92 | { |
---|
[790] | 93 | var resize = false; |
---|
[2] | 94 | var offWidth = Element('border_blank').offsetWidth ? Element('border_blank').offsetWidth : Element('border_blank').clientWidth; |
---|
| 95 | if (offWidth < 200) { |
---|
| 96 | resize = resize_borders(); |
---|
| 97 | if (!resize){ |
---|
[197] | 98 | alert(get_lang('Reached maximum tab limit')); |
---|
[2] | 99 | return false; |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | |
---|
[271] | 103 | if (! id_value) // Is new message? |
---|
| 104 | var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1; |
---|
[790] | 105 | else |
---|
| 106 | { |
---|
| 107 | if (Element("border_id_"+id_value)) // It's opened already! |
---|
| 108 | return alternate_border(id_value); |
---|
[271] | 109 | var ID = id_value; |
---|
| 110 | } |
---|
[2] | 111 | td = document.createElement("TD"); |
---|
| 112 | td.id="border_id_" + ID; |
---|
| 113 | if(resize) { |
---|
| 114 | td.setAttribute("width", parseInt(resize)+"px"); |
---|
| 115 | td.style.width = parseInt(resize)+"px"; |
---|
| 116 | } |
---|
| 117 | else |
---|
| 118 | td.setAttribute("width", "200px"); |
---|
[790] | 119 | |
---|
[2] | 120 | td.setAttribute("align", "right"); |
---|
| 121 | td.onclick = function(){alternate_border(ID);}; |
---|
| 122 | td.setAttribute("noWrap","true"); |
---|
[1247] | 123 | td.alt = borderTitle; |
---|
| 124 | td.title = borderTitle; |
---|
[2] | 125 | borderTitle = borderTitle ? borderTitle : id_value ? get_lang("No Subject") : " " ; |
---|
| 126 | td.value = borderTitle; |
---|
[790] | 127 | if (borderTitle.length > 21) |
---|
[2] | 128 | borderTitle = borderTitle.substring(0,21) + "..."; |
---|
[790] | 129 | |
---|
[2] | 130 | if (resize) |
---|
| 131 | borderTitle = borderTitle.substring(0, resize*0.08); |
---|
| 132 | |
---|
[790] | 133 | td.innerHTML = "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td id=font_border_id_" + ID+" class='font-menu' width=*>" + borderTitle + "</td><td width=1px><img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'></td></tr></table>"; |
---|
| 134 | |
---|
[2] | 135 | bb = document.getElementById("border_blank"); |
---|
| 136 | parent_bb = bb.parentNode; //Pego o tbody |
---|
| 137 | parent_bb.insertBefore(td, bb); |
---|
[790] | 138 | |
---|
| 139 | if(! Element("border_id_"+id_value+"_r") ||((typeof(id_value) == 'string') && id_value.match(/_r$/))) |
---|
[2] | 140 | _dragArea.makeDragged(td, id_value,td.value); |
---|
| 141 | |
---|
| 142 | BordersArray[BordersArray.length] = new setBorderAttributes(ID); |
---|
[790] | 143 | |
---|
[2] | 144 | var div = document.createElement("DIV"); |
---|
| 145 | div.id = "content_id_" + ID; |
---|
| 146 | div.className = "conteudo"; |
---|
| 147 | div.style.display=''; |
---|
| 148 | |
---|
| 149 | var bar = document.getElementById("toolbar"); |
---|
| 150 | var offset = 0; |
---|
[790] | 151 | if(bar.style.visibility != 'hidden') |
---|
[2] | 152 | offset = bar.offsetHeight ? bar.offsetHeight : bar.clientHeight; |
---|
[790] | 153 | |
---|
[2] | 154 | div.style.height = document.body.clientHeight - offset - (is_ie ? 76 : 86); |
---|
[320] | 155 | div.style.overflow = "hidden"; |
---|
[2] | 156 | |
---|
| 157 | if(!is_ie) { |
---|
| 158 | var menuHidden = Element("folderscol").style.display == 'none' ? true : false; |
---|
| 159 | var defaultWidth = document.body.clientWidth - 27; |
---|
| 160 | if(!menuHidden) |
---|
| 161 | defaultWidth -= Element("folderscol").offsetWidth; |
---|
| 162 | |
---|
| 163 | div.style.width = defaultWidth; |
---|
| 164 | } |
---|
[790] | 165 | Element("exmail_main_body").insertBefore(div,Element("footer_menu")); |
---|
[2] | 166 | alternate_border(ID); |
---|
| 167 | return ID; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | function resize_borders() |
---|
| 171 | { |
---|
| 172 | var children; |
---|
| 173 | var numBorders = 0; |
---|
| 174 | var widthTD = 0; |
---|
| 175 | var newWidthTD = 0; |
---|
| 176 | children = Element('border_tr').childNodes; |
---|
| 177 | for (var i=0; i<children.length; i++) { |
---|
| 178 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) { |
---|
| 179 | numBorders++; |
---|
| 180 | if(!widthTD) |
---|
| 181 | widthTD = children[i].clientWidth; |
---|
| 182 | } |
---|
| 183 | } |
---|
| 184 | if (numBorders > 8) |
---|
| 185 | return false; |
---|
| 186 | |
---|
| 187 | newWidthTD = ((numBorders*widthTD)+(Element("border_blank").clientWidth-20))/(numBorders+1); |
---|
| 188 | for (var i=0; i<children.length; i++) { |
---|
| 189 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){ |
---|
| 190 | children[i].style.width = newWidthTD; |
---|
| 191 | Element("font_"+children[i].id).innerHTML = Element("font_"+children[i].id).innerHTML.substring(0, newWidthTD*0.08); |
---|
| 192 | } |
---|
| 193 | } |
---|
| 194 | return newWidthTD; |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | function delete_border(ID, msg_sent) |
---|
| 198 | { |
---|
[648] | 199 | var borderElem = Element("border_id_" + ID) |
---|
| 200 | if (borderElem) |
---|
| 201 | borderElem.onclick = null; // It's avoid a FF3 bug |
---|
| 202 | else |
---|
[125] | 203 | return false; |
---|
[320] | 204 | |
---|
[2] | 205 | if (msg_sent == 'false') |
---|
| 206 | { |
---|
| 207 | var body = document.getElementById('body_'+ ID); |
---|
| 208 | if (body) |
---|
| 209 | { |
---|
[606] | 210 | var save_link = Element("save_message_options_"+ID); |
---|
| 211 | if (openTab.toPreserve[ID] == undefined) |
---|
| 212 | openTab.toPreserve[ID] = false; |
---|
[648] | 213 | if ((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on') && (save_link.onclick != '')) |
---|
[2] | 214 | { |
---|
| 215 | var discard_msg = confirm(get_lang("Your message has not been sent. Discard your message?"), ""); |
---|
| 216 | if (!discard_msg) |
---|
[245] | 217 | { |
---|
[606] | 218 | Element("border_id_"+ID).onclick = function () { alternate_border(ID);}; |
---|
[2] | 219 | return; |
---|
[245] | 220 | } |
---|
| 221 | else |
---|
| 222 | { |
---|
[606] | 223 | if (openTab.imapBox[ID] && !openTab.toPreserve[ID]){ |
---|
| 224 | delete_msgs(openTab.imapBox[ID], openTab.imapUid[ID].toString(), 0) |
---|
| 225 | delete(openTab.imapBox[ID]); |
---|
| 226 | openTab.toPreserve[ID] = false; |
---|
[320] | 227 | } |
---|
[667] | 228 | // Element('to_'+ID).focus(); It crash on IE |
---|
[245] | 229 | } |
---|
[2] | 230 | } |
---|
| 231 | } |
---|
| 232 | } |
---|
| 233 | |
---|
[606] | 234 | openTab.toPreserve[ID] = false; |
---|
| 235 | openTab.imapUid[ID] = 0; |
---|
[271] | 236 | |
---|
[801] | 237 | if (preferences.auto_save_draft == 1) |
---|
| 238 | { |
---|
| 239 | if (openTab.autosave_timer[ID]) |
---|
| 240 | clearTimeout(openTab.autosave_timer[ID]); |
---|
| 241 | openTab.autosave_timer[ID] = false; |
---|
| 242 | } |
---|
| 243 | |
---|
[2] | 244 | hold_session = false; |
---|
[790] | 245 | if (exist_className(Element('border_id_'+ID),'menu-sel')) |
---|
[2] | 246 | { |
---|
[790] | 247 | if (BordersArray[BordersArray.length-2].sequence == ID) |
---|
[2] | 248 | this.alternate_border(0); |
---|
| 249 | else |
---|
[790] | 250 | this.alternate_border(BordersArray[BordersArray.length-2].sequence); |
---|
[2] | 251 | } |
---|
| 252 | |
---|
| 253 | // Remove TD, title |
---|
[320] | 254 | border = Element('border_id_' + ID); |
---|
[2] | 255 | border.parentNode.removeChild(border); |
---|
[790] | 256 | var j=0; |
---|
[2] | 257 | var new_BordersArray = new Array(); |
---|
| 258 | for (i=0;i<BordersArray.length;i++) |
---|
[790] | 259 | if (document.getElementById(BordersArray[i].border_id) != null){ |
---|
[2] | 260 | new_BordersArray[j] = BordersArray[i]; |
---|
[790] | 261 | j++; |
---|
[2] | 262 | } |
---|
[58] | 263 | if(j == 1) |
---|
| 264 | Element("footer_menu").style.display = ''; |
---|
[2] | 265 | BordersArray = new_BordersArray; |
---|
[790] | 266 | |
---|
| 267 | // Remove Div Content |
---|
| 268 | content = Element('content_id_' + ID); |
---|
| 269 | content.parentNode.removeChild(content); |
---|
[320] | 270 | return true; |
---|
| 271 | } |
---|