source: trunk/expressoMail1_2/js/abas.js @ 163

Revision 163, 7.9 KB checked in by niltonneto, 16 years ago (diff)

Correção das funcionalidades: Mover e Apagar, do resultado da pesquisa.
Otimizado código do CSS utilizado nas linhas da lista de mensagens.
Correção de algumas traduções.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1var BordersArray = new Array();
2BordersArray[0] = new setBorderAttributes(0);
3
4function setBorderAttributes(ID)
5{
6        this.border_id = "border_id_"+ID;
7        this.sequence = ID;
8}
9
10
11function alternate_border(ID)
12{
13        Element("footer_menu").style.display = (ID != "0" ? 'none' : '');
14        var len = BordersArray.length;
15        for (var i=0; i < len; i++)
16        {
17                m = document.getElementById(BordersArray[i].border_id);
18                if (m.className == 'menu-sel')
19                {
20                        m.className = 'menu';
21                        c = document.getElementById("content_id_"+BordersArray[i].sequence);
22                        c.style.display = 'none';
23                        if(Element("font_border_id_"+BordersArray[i].sequence))
24                                Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu';   
25                        var body = Element('body_'+BordersArray[i].sequence);
26                        if (body)
27                        {
28                                try
29                                {
30                                        if (Element('viewsource_rt_checkbox').checked)
31                                        { 
32                                                connector.loadScript("rich_text_editor");
33                                                RichTextEditor.viewsource(false);
34                                        }
35                                }
36                                catch(e)
37                                {
38                                        //alert(e.message)
39                                }
40                        }
41                }
42        }
43
44        m = Element("border_id_"+ID);
45        m.className = 'menu-sel';
46        if(Element("font_border_id_" + ID))
47                Element("font_border_id_" + ID).className = 'font-menu-sel';
48        var c = Element("content_id_"+ID)
49        c.style.display = '';
50
51        body = document.getElementById('body_'+ ID);
52        if (body){
53                try{
54                        if(ID){
55                                connector.loadScript("rich_text_editor");
56                                RichTextEditor.loadEditor(ID);
57                        }
58                        body.contentWindow.document.designMode="on";
59                }
60                catch(e){
61                        //alert(e.message);
62                }
63        }
64
65        // hide the DropDrowContact, if necessary
66        window_DropDownContacts = Element('tipDiv');
67        if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){
68                window_DropDownContacts.style.visibility = 'hidden';
69        }
70       
71        /*var span_options = document.getElementById("span_options");   
72        if (span_options){
73                span_options.parentNode.removeChild(span_options);
74                var span_options = document.createElement("SPAN");     
75                span_options.setAttribute("id","span_options");
76        }
77               
78        if ((span_options) && (ID == 0)){
79                var span_D = Element("span_D");
80                span_options.innerHTML =
81                '<span title="'+get_lang("Delete")+'" style="margin-left:8px;" class="message_options" onclick=delete_msgs(\'null\',\'selected\',\'null\')>'+get_lang("Delete")+'</span> | '+
82                '<span title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span> | '+
83                '<span title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span> | '+
84                '<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span>';     
85                span_options.setAttribute('style',"font-size:5px;");
86                span_D.parentNode.insertBefore(span_options,span_D);   
87        } else
88                if ((span_options) && (ID != 0)){               
89                        span_options.innerHTML = '<span title="'+get_lang("Delete")+'" style="margin-left:8px" class="message_options" onclick=delete_search_msgs('+content.id+')>'+get_lang("Delete")+'</span> | '+
90                                '<span title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"border_id_'+content.id.substr(11)+'\",\"move_to\")>'+get_lang("Move")+'</span>';
91                var span_D = Element("span_D");                         
92                span_D.parentNode.insertBefore(span_options,span_D);   
93                }
94        */
95        return ID;
96}
97
98function create_border(borderTitle, id_value)
99{
100        var resize = false;     
101        var offWidth = Element('border_blank').offsetWidth ? Element('border_blank').offsetWidth : Element('border_blank').clientWidth;
102        if (offWidth < 200) {
103                resize = resize_borders();
104                if (!resize){
105                        alert('Limite máximo de abas atingido!');
106                        return false;
107                }
108        }
109        Element("footer_menu").style.display = 'none';
110        var ID = id_value ? id_value : parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1;
111       
112        td = document.createElement("TD");
113        td.id="border_id_" + ID;
114        if(resize) {
115                td.setAttribute("width", parseInt(resize)+"px");
116                td.style.width = parseInt(resize)+"px";
117        }
118        else
119                td.setAttribute("width", "200px");
120               
121        td.className = "menu";
122        td.setAttribute("align", "right");
123        td.onclick = function(){alternate_border(ID);};
124        td.setAttribute("noWrap","true");
125        var subject = borderTitle;
126       
127        borderTitle = borderTitle ?  borderTitle : id_value ? get_lang("No Subject") : "&nbsp;" ;
128        td.value = borderTitle;
129        if (borderTitle.length > 21){
130                borderTitle = borderTitle.substring(0,21) + "...";
131        }
132       
133        if (resize)
134                borderTitle = borderTitle.substring(0, resize*0.08);
135               
136        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/default/images/close_button.gif'></td></tr></table>";
137
138        bb = document.getElementById("border_blank");
139        parent_bb = bb.parentNode; //Pego o tbody
140        parent_bb.insertBefore(td, bb);
141       
142        if(id_value && id_value.match(/_r$/))   
143                _dragArea.makeDragged(td, id_value,td.value);
144
145        BordersArray[BordersArray.length] = new setBorderAttributes(ID);
146       
147        var div = document.createElement("DIV");
148        div.id = "content_id_" + ID;
149        div.className = "conteudo";
150        div.style.display='';
151
152        var bar = document.getElementById("toolbar");
153        var offset = 0;
154        if(bar.style.visibility != 'hidden')
155                offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;
156               
157        div.style.height = document.body.clientHeight - offset - (is_ie ? 76 : 86);
158        div.style.overflow = "auto";
159
160        if(!is_ie) {
161                var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
162                var defaultWidth = document.body.clientWidth - 27;
163                if(!menuHidden)
164                        defaultWidth -= Element("folderscol").offsetWidth;
165
166                div.style.width = defaultWidth;
167//              div.style.width ="99.3%";
168        }
169        document.getElementById("exmail_main_body").appendChild(div);
170        alternate_border(ID);
171       
172        return ID;
173}
174
175function resize_borders()
176{
177        var children;
178        var     numBorders = 0;
179        var widthTD = 0;
180        var newWidthTD = 0;             
181        children = Element('border_tr').childNodes;     
182        for (var i=0; i<children.length; i++) {
183                if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) {
184                        numBorders++;
185                        if(!widthTD)
186                                widthTD = children[i].clientWidth;                             
187                }
188        }
189        if (numBorders > 8)
190                return false;
191       
192        newWidthTD = ((numBorders*widthTD)+(Element("border_blank").clientWidth-20))/(numBorders+1);
193        for (var i=0; i<children.length; i++) {
194                if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){
195                        children[i].style.width = newWidthTD;
196                        Element("font_"+children[i].id).innerHTML = Element("font_"+children[i].id).innerHTML.substring(0, newWidthTD*0.08);
197                }
198        }
199        return newWidthTD;
200}
201
202function delete_border(ID, msg_sent)
203{
204        if(!ID)
205                return false;
206        if (msg_sent == 'false')
207        {
208                var body = document.getElementById('body_'+ ID);
209                if (body)
210                {
211                        try
212                        {
213                                if (body.contentWindow.document.designMode.toLowerCase() == 'on')
214                                {
215                                        var discard_msg = confirm(get_lang("Your message has not been sent. Discard your message?"), "");
216                                        if (!discard_msg)
217                                                return;
218                                }
219                        }
220                        catch(e){
221                                //alert(e.message);
222                        }
223                }
224        }
225
226        hold_session = false;
227        for (i=0;i<BordersArray.length;i++)
228        {
229                m = document.getElementById(BordersArray[i].border_id);
230                if (m.className == 'menu-sel')
231                        border_selected = BordersArray[i].border_id;
232        }
233       
234        if ('border_id_' + ID == border_selected)
235        {
236                if (BordersArray[i-2].sequence == ID)
237                        this.alternate_border(0);
238                else
239                        this.alternate_border(BordersArray[i-2].sequence);
240        }
241
242        // Remove TD, title
243        border = document.getElementById('border_id_' + ID);
244        border.parentNode.removeChild(border);
245        // Remove Div Content
246        content = document.getElementById('content_id_' + ID);
247        content.parentNode.removeChild(content);
248       
249        var new_BordersArray = new Array();
250        j = 0;
251        for (i=0;i<BordersArray.length;i++)
252        {
253                if (document.getElementById(BordersArray[i].border_id) != null){
254                        new_BordersArray[j] = BordersArray[i];
255                        j++;   
256                }
257        }
258        if(j == 1)
259                Element("footer_menu").style.display = '';
260        BordersArray = new_BordersArray;
261}
Note: See TracBrowser for help on using the repository browser.