source: companies/serpro/expressoMail1_2/js/filters.js @ 903

Revision 903, 7.4 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1var rules_limit = 200;
2
3        function cfilterSh(){
4                this.filter_Sh   = new Array;
5                this.qvfaf               = "";
6               
7                // Images
8                this.grp_open_img = new Image();
9                this.grp_open_img.src = 'templates/default/images/filtro/group_open.gif';
10                this.grp_close_img = new Image();
11                this.grp_close_img.src = 'templates/default/images/filtro/group_close.gif';
12                this.filter_img = new Image();
13                this.filter_img.src = 'templates/default/images/filtro/filters.gif';
14                this.for_email_img = new Image();
15                this.for_email_img.src = 'templates/default/images/filtro/answered.gif';
16        }               
17
18        cfilterSh.prototype.Forms = function(){
19       
20                var form = document.createElement("DIV");
21                form.id  = "window_ffilter_ccform";
22                form.style.visibility = "hidden";
23                form.style.position = "absolute";
24                form.style.left = "0px";
25                form.style.top  = "0px";
26                form.style.width = "0px";
27                form.style.height = "0px";
28                document.body.appendChild(form);
29
30                var form_cont = document.createElement("SPAN");
31                form_cont.id = "form_status";
32                form_cont.style.display = "";                   
33                form_cont.style.position = "absolute";
34                form_cont.style.top = "10px";
35                form_cont.style.left = "600px";
36                form_cont.innerHTML = "";
37                form.appendChild(form_cont);
38               
39                var form_buttons = document.createElement("DIV");
40                form_buttons.id = "form_buttons";
41                form_buttons.style.position = "absolute";
42                form_buttons.style.display = "";
43                form_buttons.style.top = "320px";
44                form_buttons.style.left = "5px";
45                form_buttons.style.width = "655px";
46                form_buttons.innerHTML = "<input type='button' value="+get_lang("Enable")+" onclick='filter.enabled_disabled(\"ENABLED\");'>"+
47                                                                 "&nbsp;<input type='button' value="+get_lang("Disable")+" onclick='filter.enabled_disabled(\"DISABLED\");'>"+ 
48                                                                 "&nbsp;<input type='button' value="+get_lang("Remove")+" onclick='filter.delete_r();'>"+
49                                                                 "&nbsp;<input type='button' value="+get_lang("Close")+" onclick='filter.close_frm();'>";
50
51                form.appendChild(form_buttons);
52               
53                var form_body = document.createElement("DIV");
54                form_body.id = "form_body";
55                form_body.style.position = "absolute";
56                form_body.style.left = "5px";
57                form_body.style.top = "5px";
58                form_body.style.width = "668px";
59                form_body.style.height = "310px";
60                form_body.style.borderStyle = "outset";
61                form_body.style.borderColor = "black";
62                form_body.style.borderWidth = "1px";
63                form_body.style.overflow = "auto";
64                form.appendChild(form_body);   
65
66                this.showWindow(form);
67                filter.load_rules();
68                this.list_rules();                     
69       
70        }
71
72        cfilterSh.prototype.list_rules = function(){
73                if(filter.rulest.length == 0)
74                        setTimeout("filters.mount_list()",2500);
75                else
76                        this.mount_list();
77        }
78
79        cfilterSh.prototype.mount_list = function(){
80
81                Element('form_status').innerHTML = "";
82                var list = "";
83                // rules
84                if(filter.rulest.length == 0){
85                        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>";         
86                }else{
87                        if (filter.rulest.length < rules_limit ) //Limit of rules
88                                list = "<img id='set_rules_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"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>";
89                        else
90                                list = "<img id='set_rules_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"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");
91                               
92                        list += "<div id='set_rules'>";
93                        for(var i=0; i < filter.rulest.length; i++){
94                                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>";
95                        }
96                }
97                list += "</div><br>";
98                // out office
99                if(!filter.out_officeR){
100                        list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0'>&nbsp;";
101                        list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>";                 
102                }else{
103                        list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"set_out\") border='0'>&nbsp;";
104                        list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>";
105                        list += "<div id='set_out'>";
106                        list += "<input id='out_0' type='checkBox'><img id='set_out_form_email_img' src='"+this.for_email_img.src+"' border='0'>";
107                        list += " " + this.vl_outOffice(filter.out_officeR) + " " ;
108                        list += "</div>";
109                }
110                Element("form_body").innerHTML = list;
111        }
112       
113        cfilterSh.prototype.vl_rule = function(rule,pos){
114                var aux = rule.split("&&");
115                return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(aux[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + aux[3] + " - <b>" + get_lang("Action") + ":</b> " + aux[6] + "</a>";
116        }
117       
118        cfilterSh.prototype.vl_outOffice = function(outOffice){         
119                var aux = outOffice.split("&&");
120                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>";
121        }
122       
123        cfilterSh.prototype.n_rule = function(){
124                Element('form_body').innerHTML = "";
125                Element('form_body').innerHTML = filter.forms_();       
126                Element('div_rule').style.display = "";
127                filter.ac_form = "new_rule";
128                Element('form_buttons').style.display = 'none';
129                filter.sel_boxes();
130
131        }
132
133        cfilterSh.prototype.n_out_office = function(){
134                Element('form_body').innerHTML = "";
135                Element('form_body').innerHTML = filter.forms_();       
136                Element('div_vacation').style.display = "";                     
137                Element('form_buttons').style.display = 'none';
138                filter.ac_form = "new_out";     
139                }
140
141        cfilterSh.prototype.hidden = function(el){
142                var _this = this;
143                Element(el).style.display = "none";
144                Element(el+"_img").src = _this.grp_close_img.src;
145                Element(el+"_img").onclick = function(){filters.un_hidden(el);}
146        }
147
148        cfilterSh.prototype.un_hidden = function(el){
149                var _this = this;
150                Element(el).style.display = "";
151                Element(el+"_img").src = _this.grp_open_img.src;
152                Element(el+"_img").onclick = function(){filters.hidden(el);}
153        }
154
155        cfilterSh.prototype.showWindow = function (div){
156                if(! this.filter_Sh[div.id]) {
157                        div.style.width = "680px";
158                        div.style.height = "345px";
159                        div.style.visibility = "hidden";
160                        div.style.position = "absolute";
161                        div.style.zIndex = "10000";                     
162                        var title = ':: ' + get_lang('Filters management') + ' - ' + get_lang('Filters maintenance') + ':: ';
163                        var wHeight = div.offsetHeight + "px";
164                        var wWidth =  div.offsetWidth   + "px";
165
166                        win = new dJSWin({                     
167                                id: 'filter'+div.id,
168                                content_id: div.id,
169                                width: wWidth,
170                                height: wHeight,
171                                title_color: '#3978d6',
172                                bg_color: '#eee',
173                                title: title,                                           
174                                title_text_color: 'white',
175                                button_x_img: '../phpgwapi/images/winclose.gif',
176                                border: true });
177                       
178                        this.filter_Sh[div.id] = win;
179                        win.draw();
180                }else{
181                        div.innerHTML = '';
182                        win = this.filter_Sh[div.id];
183                        filter.form_m();                       
184                }
185                win.open();
186        }
187
188///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
189// build object
190        var filters;
191        filters = new cfilterSh();
Note: See TracBrowser for help on using the repository browser.