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

Revision 42, 9.1 KB checked in by niltonneto, 17 years ago (diff)

Vide arquivo change_log.txt

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