source: branches/2.0/expressoMail1_2/js/filters.js @ 2788

Revision 2788, 9.7 KB checked in by amuller, 14 years ago (diff)

Ticket #1056 - Coloca mensagem amigavel ao usuário de erro, quando sieve ta fora

  • Property svn:eol-style set to native
  • Property svn:executable set to *
RevLine 
[810]1var rules_limit = 300;
[246]2
[2]3        function cfilterSh(){
4                this.filter_Sh   = new Array;
5                this.qvfaf               = "";
6               
7                // Images
8                this.grp_open_img = new Image();
[803]9                this.grp_open_img.src = 'templates/'+template+'/images/filtro/group_open.gif';
[2]10                this.grp_close_img = new Image();
[803]11                this.grp_close_img.src = 'templates/'+template+'/images/filtro/group_close.gif';
[2]12                this.filter_img = new Image();
[803]13                this.filter_img.src = 'templates/'+template+'/images/filtro/filters.gif';
[2]14                this.for_email_img = new Image();
[803]15                this.for_email_img.src = 'templates/'+template+'/images/filtro/answered.gif';
[564]16                this.telephone_voip = new Image();
[803]17                this.telephone_voip.src = 'templates/'+template+'/images/filtro/telephone_voip.jpg';
[2]18        }               
19
20        cfilterSh.prototype.Forms = function(){
21       
22                var form = document.createElement("DIV");
23                form.id  = "window_ffilter_ccform";
24                form.style.visibility = "hidden";
25                form.style.position = "absolute";
26                form.style.left = "0px";
27                form.style.top  = "0px";
28                form.style.width = "0px";
29                form.style.height = "0px";
30                document.body.appendChild(form);
31
32                var form_cont = document.createElement("SPAN");
33                form_cont.id = "form_status";
[564]34                form_cont.style.display = "block";                     
[2]35                form_cont.style.position = "absolute";
[197]36                form_cont.style.top = "10px";
[2]37                form_cont.style.left = "600px";
38                form_cont.innerHTML = "";
39                form.appendChild(form_cont);
40               
41                var form_buttons = document.createElement("DIV");
42                form_buttons.id = "form_buttons";
43                form_buttons.style.position = "absolute";
44                form_buttons.style.display = "";
45                form_buttons.style.top = "320px";
46                form_buttons.style.left = "5px";
47                form_buttons.style.width = "655px";
48                form_buttons.innerHTML = "<input type='button' value="+get_lang("Enable")+" onclick='filter.enabled_disabled(\"ENABLED\");'>"+
49                                                                 "&nbsp;<input type='button' value="+get_lang("Disable")+" onclick='filter.enabled_disabled(\"DISABLED\");'>"+ 
[53]50                                                                 "&nbsp;<input type='button' value="+get_lang("Remove")+" onclick='filter.delete_r();'>"+
51                                                                 "&nbsp;<input type='button' value="+get_lang("Close")+" onclick='filter.close_frm();'>";
[2]52
53                form.appendChild(form_buttons);
54               
55                var form_body = document.createElement("DIV");
56                form_body.id = "form_body";
57                form_body.style.position = "absolute";
58                form_body.style.left = "5px";
59                form_body.style.top = "5px";
60                form_body.style.width = "668px";
61                form_body.style.height = "310px";
62                form_body.style.borderStyle = "outset";
63                form_body.style.borderColor = "black";
64                form_body.style.borderWidth = "1px";
65                form_body.style.overflow = "auto";
66                form.appendChild(form_body);   
67
68                this.showWindow(form);
[2666]69                if ( filter.rulest.length > 0 )
70                        this.list_rules();
71                else
72                        filter.load_rules(this.list_rules);
[2]73        }
74
75        cfilterSh.prototype.list_rules = function(){
76                if(filter.rulest.length == 0)
[2788]77                        if(filter.criticalError || filter.rulest.length == 0)
78                                return false;
79                        else
80                                filters.mount_list();
[2]81        }
82
83        cfilterSh.prototype.mount_list = function(){
84
85                Element('form_status').innerHTML = "";
86                var list = "";
[564]87       
[2]88                // rules
89                if(filter.rulest.length == 0){
[564]90                        list = "<img id='set_rules_img' src='" + this.grp_close_img.src + "' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";           
[2]91                }else{
[564]92                        if ( filter.rulest.length < rules_limit ) //Limit of rules
93                                list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule();'>" + get_lang("new rule") + "</a>";
[246]94                        else
[564]95                                list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");
96                       
[2]97                        list += "<div id='set_rules'>";
[564]98                       
99                        for(var i= 0; i < filter.rulest.length; i++)
100                        {
101                                list += "<input id=rule_"+i+" type='checkBox'>&nbsp;<img src='"+this.filter_img.src+"' width='16' height='16' border='0' />&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i,'') + "<br>";
[2]102                        }
[564]103                        list += "</div>";                       
[2]104                }
[564]105               
106                list += "<br/>";
107               
[2]108                // out office
[197]109                if(!filter.out_officeR){
[564]110                        list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;";
[2]111                        list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>";                 
112                }else{
[564]113                        list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"set_out\");' border='0' />&nbsp;";
[197]114                        list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>";
[2]115                        list += "<div id='set_out'>";
116                        list += "<input id='out_0' type='checkBox'><img id='set_out_form_email_img' src='"+this.for_email_img.src+"' border='0'>";
[197]117                        list += " " + this.vl_outOffice(filter.out_officeR) + " " ;
[2]118                        list += "</div>";
119                }
[564]120                list += "<br/>";
121       
122                // Voip
123                if(preferences.voip_email_redirect)
124                {
125                        if( filter.rulesVoip.length == 0)
126                        {
127                                list += "<img id='voip_rule_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter();'>" + get_lang("new rule") + "</a>";         
128                        }
129                        else
130                        {
131                                if ( filter.rulest.length < rules_limit ) //Limit of rules
132                                        list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter()'>" + get_lang("new rule") + "</a>";
133                                else
134                                        list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");
135                                       
136                                list += "<div id='voip_rule'>";
137                                for(var i= 0; i < filter.rulesVoip.length; i++)
138                                {
139                                        list += "<input id='voip_rule_"+i+"' type='checkBox'>&nbsp;<img src='"+this.telephone_voip.src+"' width='16' height='16' border='0'/>&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulesVoip[i],i,'voip') + "<br>";
140                                }
141                                list += "</div>";
142                        }
143                }
144
[2]145                Element("form_body").innerHTML = list;
146        }
147       
[564]148        cfilterSh.prototype.vl_rule = function(rule,pos,type)
149        {
150                var fields = rule.split("&&");
151                if(type == 'voip')
152                        return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','voip')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - " + fields[3] + " <b>" + get_lang("Subject") + ":</b> " + fields[5] + "</a>";
153                else
154                        return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + fields[3] + " - <b>" + get_lang("Action") + ":</b> " + fields[6] + "</a>";
[2]155        }
156       
[197]157        cfilterSh.prototype.vl_outOffice = function(outOffice){         
[2]158                var aux = outOffice.split("&&");
[197]159                return get_lang("Rule") + " - <a href='javascript:void(0)' onclick=filter.form_out()> " + "<b>" + get_lang("Status") + " : </b><font color='red'>" + (aux[4] == "off" ? get_lang("Disabled") : get_lang("Enabled")) + "</font></a>";
[2]160        }
161       
[564]162        cfilterSh.prototype.n_rule = function()
163        {
[2]164                Element('form_body').innerHTML = "";
165                Element('form_body').innerHTML = filter.forms_();       
[564]166                Element('div_rule').style.display = "block";
[2]167                filter.ac_form = "new_rule";
168                Element('form_buttons').style.display = 'none';
169                filter.sel_boxes();
170
171        }
172
[564]173        cfilterSh.prototype.n_out_office = function()
174        {
[2]175                Element('form_body').innerHTML = "";
176                Element('form_body').innerHTML = filter.forms_();       
[564]177                Element('div_vacation').style.display = "block";                       
[2]178                Element('form_buttons').style.display = 'none';
179                filter.ac_form = "new_out";     
[564]180        }
[2]181
[564]182        cfilterSh.prototype.n_voipFilter = function()
183        {
184                Element('form_body').innerHTML = "";
185                Element('form_body').innerHTML = filter.forms_();
186                Element('div_voipFilter').style.display = "block";     
187                Element('form_buttons').style.display = 'none';
188                filter.ac_form = "new_voip";
189        }
190
191        function visibleRulesFalse(el)
192        {
[2]193                Element(el).style.display = "none";
[564]194                Element(el+"_img").src = filters.grp_close_img.src;
195                Element(el+"_img").onclick = function(){visibleRulesTrue(el);};
[2]196        }
197
[564]198        function visibleRulesTrue(el)
199        {
[2]200                Element(el).style.display = "";
[564]201                Element(el+"_img").src = filters.grp_open_img.src;
202                Element(el+"_img").onclick = function(){visibleRulesFalse(el);};
[2]203        }
204
[564]205        cfilterSh.prototype.showWindow = function (div)
206        {
[2]207                if(! this.filter_Sh[div.id]) {
208                        div.style.width = "680px";
209                        div.style.height = "345px";
210                        div.style.visibility = "hidden";
211                        div.style.position = "absolute";
212                        div.style.zIndex = "10000";                     
[61]213                        var title = ':: ' + get_lang('Filters management') + ' - ' + get_lang('Filters maintenance') + ':: ';
[2]214                        var wHeight = div.offsetHeight + "px";
215                        var wWidth =  div.offsetWidth   + "px";
216
217                        win = new dJSWin({                     
218                                id: 'filter'+div.id,
219                                content_id: div.id,
220                                width: wWidth,
221                                height: wHeight,
222                                title_color: '#3978d6',
223                                bg_color: '#eee',
224                                title: title,                                           
225                                title_text_color: 'white',
226                                button_x_img: '../phpgwapi/images/winclose.gif',
227                                border: true });
228                       
229                        this.filter_Sh[div.id] = win;
230                        win.draw();
231                }else{
232                        div.innerHTML = '';
233                        win = this.filter_Sh[div.id];
234                        filter.form_m();                       
235                }
236                win.open();
237        }
238
239///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
240// build object
241        var filters;
[803]242        filters = new cfilterSh();
Note: See TracBrowser for help on using the repository browser.