[903] | 1 | var tabStack = new Array(); |
---|
| 2 | |
---|
| 3 | function initBorders(num) |
---|
| 4 | { |
---|
| 5 | for (ix=0; ix < num; ix++) |
---|
| 6 | { |
---|
| 7 | BordersArray[ix] = new setBorderAttributes(ix); |
---|
| 8 | } |
---|
| 9 | } |
---|
| 10 | |
---|
| 11 | function setBorderAttributes(ID) |
---|
| 12 | { |
---|
| 13 | this.border_id = "border_id_"+ID; |
---|
| 14 | this.sequence = ID; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | function alternate_border(ID) |
---|
| 18 | { |
---|
| 19 | if (!document.getElementById("border_id_"+ID)) |
---|
| 20 | return; |
---|
| 21 | tabStack.push(ID); |
---|
| 22 | var len = BordersArray.length; |
---|
| 23 | for (var i=0; i < len; i++) |
---|
| 24 | { |
---|
| 25 | m = document.getElementById(BordersArray[i].border_id); |
---|
| 26 | m.className = 'abas_menu'; |
---|
| 27 | c = document.getElementById("content_id_"+BordersArray[i].sequence); |
---|
| 28 | if (is_ie) { |
---|
| 29 | c.className = "conteudo_div_ie"; |
---|
| 30 | } |
---|
| 31 | c.style.display = 'none'; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | m = document.getElementById("border_id_"+ID); |
---|
| 35 | m.className = 'abas_menu_sel'; |
---|
| 36 | c = document.getElementById("content_id_"+ID); |
---|
| 37 | c.style.display = ''; |
---|
| 38 | |
---|
| 39 | return c.childNodes.length; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | function create_border(borderTitle) |
---|
| 43 | { |
---|
| 44 | var ID = (BordersArray[(BordersArray.length-1)].sequence + 1); |
---|
| 45 | |
---|
| 46 | td = document.createElement("TD"); |
---|
| 47 | td.id="border_id_" + ID; |
---|
| 48 | td.setAttribute("width", "auto"); |
---|
| 49 | td.className = "abas_menu"; |
---|
| 50 | td.setAttribute("align", "right"); |
---|
| 51 | td.onclick = function(){alternate_border(ID);}; |
---|
| 52 | td.setAttribute("noWrap","true"); |
---|
| 53 | |
---|
| 54 | borderTitle = borderTitle ? borderTitle : "Sem assunto"; |
---|
| 55 | td.title = borderTitle; |
---|
| 56 | |
---|
| 57 | if (borderTitle.length > 30){ |
---|
| 58 | borderTitle = borderTitle.substring(0,30) + "..."; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | td.innerHTML = " " + borderTitle + " <img style='cursor:pointer' onclick=delete_border('" + ID + "') src='" + _icon_dir + "/close_button.gif'>"; |
---|
| 62 | |
---|
| 63 | bb = document.getElementById("border_blank"); |
---|
| 64 | parent_bb = bb.parentNode; //Pego o tbody |
---|
| 65 | parent_bb.insertBefore(td, bb); |
---|
| 66 | |
---|
| 67 | BordersArray[BordersArray.length] = new setBorderAttributes(ID); |
---|
| 68 | |
---|
| 69 | var div = document.createElement("DIV"); |
---|
| 70 | div.id = "content_id_" + ID; |
---|
| 71 | if (is_ie) { |
---|
| 72 | div.className = "conteudo_div_ie"; |
---|
| 73 | } else { |
---|
| 74 | div.className = "conteudo_div"; |
---|
| 75 | } |
---|
| 76 | div.style.display=''; |
---|
| 77 | |
---|
| 78 | document.getElementById("main_body").appendChild(div); |
---|
| 79 | alternate_border(ID); |
---|
| 80 | |
---|
| 81 | return ID; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | function delete_border(ID) |
---|
| 85 | { |
---|
| 86 | for (i=0;i<BordersArray.length;i++) |
---|
| 87 | { |
---|
| 88 | m = document.getElementById(BordersArray[i].border_id); |
---|
| 89 | if (m.className == 'abas_menu_sel') |
---|
| 90 | border_selected = BordersArray[i].border_id; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | if ('border_id_' + ID == border_selected) |
---|
| 94 | { |
---|
| 95 | var previousTab; |
---|
| 96 | var nextTab = -1; |
---|
| 97 | while (tabStack.length > 0) |
---|
| 98 | { |
---|
| 99 | previousTab = tabStack.pop(); |
---|
| 100 | if (previousTab != ID) |
---|
| 101 | if (document.getElementById('content_id_' + previousTab)) |
---|
| 102 | { |
---|
| 103 | nextTab = previousTab; |
---|
| 104 | break; |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | if (nextTab == -1) |
---|
| 108 | nextTab = (BordersArray[i-2].sequence == ID) ? 0 : BordersArray[i-2].sequence; |
---|
| 109 | this.alternate_border(nextTab); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | // Remove TD, title |
---|
| 113 | border = document.getElementById('border_id_' + ID); |
---|
| 114 | border.parentNode.removeChild(border); |
---|
| 115 | // Remove Div Content |
---|
| 116 | content = document.getElementById('content_id_' + ID); |
---|
| 117 | content.parentNode.removeChild(content); |
---|
| 118 | |
---|
| 119 | var new_BordersArray = new Array(); |
---|
| 120 | j = 0; |
---|
| 121 | for (i=0;i<BordersArray.length;i++) |
---|
| 122 | { |
---|
| 123 | if (document.getElementById(BordersArray[i].border_id) != null){ |
---|
| 124 | new_BordersArray[j] = BordersArray[i]; |
---|
| 125 | j++; |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | BordersArray = new_BordersArray; |
---|
| 129 | } |
---|