source: trunk/calendar/templates/celepar/js/edit_exmail.js @ 2

Revision 2, 8.9 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1/******************************************************************************\
2|**************************   CALENDAR MODULE   *******************************|
3|********** INCLUDE PARTICIPANTS - PLUGIN USING AJAX EXPRESSOMAIL COMPONENT  **|
4\******************************************************************************/
5var contacts = '';
6var array_lang = new Array();
7// onUnload edit message
8if(!document.all)
9        window.onbeforeunload = '';
10       
11// Verifica versão do Firefox
12var agt = navigator.userAgent.toLowerCase();
13var is_firefox_0 = agt.indexOf('firefox/1.0') != -1 && agt.indexOf('firefox/0.') ? true : false;
14
15function optionFinderTimeout(obj)
16{
17        clearTimeout(finderTimeout);   
18        var oWait = document.getElementById("cal_span_searching");
19        oWait.innerHTML = document.getElementById("txt_searching").value + '...';
20        var finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500);
21}
22function optionFinder(id) {
23        var oWait = document.getElementById("cal_span_searching");
24        var oText = document.getElementById(id);                       
25        var select_available_users_tmp = document.getElementById('user_list_in')
26        for(var i = 0;i < select_available_users_tmp.options.length; i++)
27                select_available_users_tmp.options[i--] = null;
28
29        var RegExp_name = new RegExp("\\b"+oText.value, "i");
30
31        for(i = 0; i < select_available_users_clone.length; i++){
32                if (RegExp_name.test(select_available_users_clone[i].text))
33                {
34                        sel = select_available_users_tmp.options;
35                        option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value);
36                        sel[sel.length] = option;
37                }
38        }       
39        oWait.innerHTML = '&nbsp;';
40}       
41               
42function get_available_users(path,context)
43{
44        var handler_get_available_users = function(data)
45        {       
46                select_available_users = document.getElementById('user_list_in');
47               
48                for(var i=0; i<select_available_users.options.length; i++){
49                        select_available_users.options[i] = null;
50                        i--;
51                }
52                var options = '###';
53                if (data) {                     
54                        if(data.groups && data.groups.length > 0) {
55                                data.groups = '<option  value="-1" disabled>------------------- '+document.getElementById("txt_groups").value+' ------------------ </option>' + data.groups;
56                        }
57                       
58                        if(data.users && data.users.length > 0) {
59                                data.users = '<option  value="-1" disabled>------------------- '+document.getElementById("txt_users").value+' ------------------ </option>' + data.users;
60                        }
61                        options +=  data.groups && data.groups.length > 0 ? data.groups : '';
62                        options +=  data.users  && data.users.length  > 0 ? data.users  : '';
63                       
64                        if(is_firefox_0)
65                                fixBugInnerSelect(select_available_users,options);
66                        else
67                                select_available_users.innerHTML = options;
68
69                        select_available_users.outerHTML = select_available_users.outerHTML;
70                        select_available_users.disabled = false;
71                        select_available_users_clone = document.getElementById('user_list_in').cloneNode(true);
72                        document.getElementById('cal_input_searchUser').value = '';
73                }
74        }       
75
76        cExecute (path+'.ldap_functions.get_available_users&context='+context, handler_get_available_users);
77}
78function add_user()
79{
80        var select_available_users = document.getElementById('user_list_in');
81        var select_users = document.getElementById('user_list');
82        var count_available_users = select_available_users.length;
83        var count_users = select_users.options.length;
84        var new_options = '';
85       
86        for (i = 0 ; i < count_available_users ; i++) {
87                if (select_available_users.options[i].selected) {
88                        if(document.all) {
89                                if ( (select_users.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) {
90                                        new_options +=  '<option value='
91                                                                + select_available_users.options[i].value
92                                                                + '>'
93                                                                + select_available_users.options[i].text
94                                                                + '</option>';
95                                }
96                        }
97                        else if ( (select_users.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) {
98                                        new_options +=  '<option value='
99                                                                + select_available_users.options[i].value
100                                                                + '>'
101                                                                + select_available_users.options[i].text
102                                                                + '</option>';
103                        }
104                }
105        }
106
107        if (new_options != '') {
108
109                if(is_firefox_0)
110                        fixBugInnerSelect(select_users,'###' + new_options + select_users.innerHTML);
111                else
112                        select_users.innerHTML = '###' + new_options + select_users.innerHTML;
113
114                select_users.outerHTML = select_users.outerHTML;
115        }
116}
117
118function remove_user(){
119        select_users = document.getElementById('user_list');
120       
121        for(var i = 0;i < select_users.options.length; i++)
122                if(select_users.options[i].selected)
123                        select_users.options[i--] = null;
124}
125
126function submitValues(){
127        var select_in = document.getElementById('user_list');
128        for(i = 0; i < select_in.length; i++)
129                select_in.options[i].selected = true;
130}       
131
132function Element(id){
133        return document.getElementById(id);
134}
135
136function loadScript(scriptPath){
137
138        if(!connector)
139                throw new Error("Error : Connector is not loaded.");
140               
141        if (document.getElementById('scr_'+scriptPath)) {
142                return;
143        }
144       
145        connector.oxmlhttp.open("GET", scriptPath, false);
146    connector.oxmlhttp.setRequestHeader('Content-Type','text/plain');
147        connector.oxmlhttp.send(null);
148        if(connector.oxmlhttp.status != 0 && connector.oxmlhttp.status != 200 ||        connector.oxmlhttp.status == 0 && connector.oxmlhttp.responseText.length == 0)
149                throw new Error("Error " + connector.oxmlhttp.status + "("+connector.oxmlhttp.statusText+") when loading script file '"+scriptPath+"'");
150       
151        var head = document.getElementsByTagName("head")[0];
152        var script = document.createElement("SCRIPT");
153        script.id = 'uploadscript_'+scriptPath;
154        script.type = 'text/javascript';               
155        script.text = connector.oxmlhttp.responseText;
156        head.appendChild(script);
157        return;
158}
159
160function showExParticipants(el,path){
161        Element('tbl_ext_participants').style.display='';
162        el.style.display='none';
163        loadScript(path+"/js/DropDownContacts.js");
164        loadScript(path+"/js/common_functions.js");
165        loadScript(path+"/js/QuickCatalogSearch.js");
166        loadScript("calendar/templates/celepar/js/over_fn_exmail.js");
167        if(!contacts)
168                cExecute (path+'.db_functions.get_dropdown_contacts', save_contacts);
169}
170
171function hideExParticipants(el,path){
172        Element('a_ext_participants').style.display = '';
173        Element('tbl_ext_participants').style.display ='none';
174}
175
176function save_contacts(data){
177        contacts = data;       
178        var input_to = Element("ex_participants");
179        input_to.style.width = "100%";
180        input_to.setAttribute("wrap","soft");   
181        input_to.onfocus = function(){clearTimeout(parseInt(setTimeOutLayer)); search_contacts('onfocus', this.id);};
182        input_to.onblur = function(){setTimeOutLayer=setTimeout('search_contacts("lostfocus","'+this.id+'")',100);};
183        if (!is_ie)
184        {
185                input_to.rows = 2;
186                input_to.onkeypress = function (e)
187                {
188                        if ((e.keyCode) == 120) //F9
189                        {
190                                emQuickSearch(input_to);
191                        }
192                        else
193                        {
194                                if (((e.keyCode == 13) || ((e.keyCode == 38)||(e.keyCode == 40))) && (document.getElementById('tipDiv').style.visibility!='hidden'))
195                                {
196                                        e.preventDefault();
197                                        search_contacts(e.keyCode,this.id);
198                                }
199                        }
200                }
201                input_to.onkeyup = function (e)
202                {
203                        if ((e.keyCode != 13) && (e.keyCode != 38) && (e.keyCode != 40))
204                        {
205                                search_contacts(e.keyCode,this.id);
206                        }
207                }
208        }
209        else
210        {
211                input_to.rows = 3;
212                input_to.onkeyup = function (e)
213                {
214                        if ((window.event.keyCode) == 120) //F9
215                        {
216                                emQuickSearch(input_to);
217                        }
218                        else
219                        {
220                                search_contacts(window.event.keyCode,this.id);
221                        }       
222                }
223        }
224}
225
226function fixBugInnerSelect(objeto,innerHTML){
227/******
228* select_innerHTML - altera o innerHTML de um select independente se é FF ou IE
229* Corrige o problema de não ser possível usar o innerHTML no IE corretamente
230* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
231* Use a vontade mas coloque meu nome nos créditos. Dúvidas, me mande um email.
232* Versão: 1.0 - 06/04/2006
233* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
234* Parametros:
235* objeto(tipo object): o select a ser alterado
236* innerHTML(tipo string): o novo valor do innerHTML
237*******/
238    objeto.innerHTML = ""
239    var selTemp = document.createElement("micoxselect")
240    var opt;
241    selTemp.id="micoxselect1"
242    document.body.appendChild(selTemp)
243    selTemp = document.getElementById("micoxselect1")
244    selTemp.style.display="none"
245    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
246        innerHTML = "<option>" + innerHTML + "</option>"
247    }
248    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
249    selTemp.innerHTML = innerHTML
250    for(var i=0;i<selTemp.childNodes.length;i++){
251        if(selTemp.childNodes[i].tagName){
252            opt = document.createElement("OPTION")
253            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
254                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
255            }
256            opt.value = selTemp.childNodes[i].getAttribute("value")
257            opt.text = selTemp.childNodes[i].innerHTML
258            if(document.all){ //IEca
259                objeto.add(opt)
260            }else{
261                objeto.appendChild(opt)
262            }                   
263        }   
264    }
265    document.body.removeChild(selTemp)
266    selTemp = null
267}
Note: See TracBrowser for help on using the repository browser.