source: branches/2.2/contactcenter/js/ccMain.js @ 3795

Revision 3795, 8.2 KB checked in by niltonneto, 13 years ago (diff)

Ticket #1515 - Modificado chamada inicial para retornar preferencias para o Javascript.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1var last_id = 0;       
2var preferences = null;
3function openwindow(url){       
4        var window_features =   "scrollbars=yes,resizable=yes,location=no,menubar=no," +
5                                                "personalbar=no,status=no,titlebar=no,toolbar=no," +
6                                                "screenX=0,screenY=0,top=0,left=0,width=" +
7                                                screen.width + ",height=" + screen.height/5*3;
8                       
9        window.open(url,'', window_features);
10}
11
12var Main_pre_load = document.body.onload;
13var ccSearch, ccTree;
14var Main_load = function ()
15        {
16                Connector.setProgressBox(Element('cc_loading'), true);
17                Connector.setProgressHolder(Element('cc_loading_inner'));               
18                /* Associate the Quick Add Button with the Plugin */
19                                       
20
21                /* Create the Search Object */
22                var search_params = new Array();
23                search_params['holder'] = Element('cc_panel_search_call');
24                search_params['total_width'] = (v_label != false &  v_atrib != false)? '485px' : '330px';
25                search_params['input_width'] = '200px';
26                search_params['progress_top'] = '150px';
27                search_params['progress_left'] = '-260px';
28                search_params['progress_color'] = '#3978d6';
29                search_params['progress_width'] = '250px';
30                search_params['conn_1_msg'] = Element('cc_loading_1').value;
31                search_params['conn_2_msg'] = Element('cc_loading_2').value;
32                search_params['conn_3_msg'] = Element('cc_loading_3').value;
33                search_params['button_text'] = Element('cc_panel_search_text').value;
34                search_params['Connector'] = Connector;
35
36                ccSearch = new ccSearchClass(search_params);
37                ccSearch.DOMresult.style.visibility = 'hidden';
38                ccSearch.onSearchFinish = ccSearchUpdate;
39                       
40                Connector.setProgressBox(Element('cc_loading'), true);
41                Connector.setProgressHolder(Element('cc_loading_inner'));
42
43                try
44                {
45                        function handlerInitValues(sdata)
46                        {
47                                var data = unserialize(sdata);
48                                preferences = data.preferences;
49                                if( boolData = eval(data.visible_all_ldap) )
50                                {
51                                        ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); updateCards()'});
52                                        showCards('all',getActualPage());
53                                        selectLetter('27');
54                                }       
55                                else
56                                {
57                                        ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); clearCards();'});
58                                        var ccQtdCompartilhado = function(responseText) {                                       
59                                                                                                                data = unserialize(responseText);
60                                                                                                                qtd_compartilhado = data[0];
61                                                                                                        }
62                                        Connector.newRequest('fulfilQtdCompartilhado', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_qtds_compartilhado', 'POST', ccQtdCompartilhado);
63                                }
64                        }
65
66                        Connector.newRequest('handlerInitValues', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_init_values', 'GET', handlerInitValues);               
67                       
68                        ccTree.Connector = Connector;                                           
69                }
70                catch(e){}
71
72                /* Create the Tree Object */                   
73                //ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); updateCards()'});
74                //ccTree.Connector = Connector;                                         
75        }
76        var menuStarted = false;
77        function findPosY(obj)
78        {
79                var curtop = 0;
80                if (obj.offsetParent)
81                {
82                        while (obj.offsetParent)
83                        {
84                                curtop += obj.offsetTop
85                                obj = obj.offsetParent;
86                        }
87                }
88                else if (obj.y)
89                        curtop += obj.y;
90                return curtop;
91        }
92        var _timeout = '';
93        var menu = function () {
94                 
95         if(! this.menuStarted)
96                this.menuStarted = true;
97               
98                submenu = [];
99                textmenu = [];
100                       
101                textmenu[0] = ["cc_msg_contact_qa","cc_msg_contact_full","cc_msg_contact_sh","cc_msg_group"];
102                textmenu[1] = ["cc_quick_add", "cc_full_add_button", "cc_full_add_button_sh", "cc_add_group_button"];
103                function show(){
104                        clearTimeout(_timeout);
105                        button = document.getElementById("cc_button_new");
106                               
107                        this.style.top = 19 + findPosY(button) + "px";
108                        this.style.visibility='visible';
109                }
110                function hide(){ _timeout = setTimeout("menu.style.visibility='hidden';",200); };
111                       
112                if(document.getElementById) {
113                        menu = document.getElementById("Layer1");
114                               
115                        for (i=0; i< textmenu[0].length; i++) {
116                                textmenu[0][i] = "<span onclick= 'menu.onmouseout();'>" + document.getElementById(textmenu[0][i]).value + "</span><br>";
117                                submenu[i] = document.createElement("DIV");                             
118                                submenu[i].innerHTML = textmenu[0][i];
119                                submenu[i].id = textmenu[1][i];
120                                submenu[i].onmouseover = function () {this.style.backgroundColor = 'LIGHTYELLOW';this.style.color = 'DARKBLUE';};
121                                submenu[i].onmouseout   = function () {  this.style.backgroundColor = '#DCDCDC'; this.style.color = '#006699';};                                       
122                                submenu[i].setAttribute("className", "special");
123                                submenu[i].setAttribute("class", "special");
124                                submenu[i].style.padding = "5px";                                         
125                                menu.appendChild(submenu[i]);
126                        }                       
127                               
128                        menu.onmouseover = show;
129                        menu.onmouseout = hide;
130                }
131                       
132                ccQuickAdd.associateAsButton(Element('cc_quick_add'));
133                ccAddGroup.associateAsButton(Element('cc_add_group_button'));
134                Element("cc_full_add_button").onclick = newContact;
135                Element("cc_full_add_button_sh").onclick = newSharedContact;
136                         
137                       
138                ccQuickAdd.afterSave = function ()
139                {
140                        updateCards();
141                }                       
142                       
143                ccAddGroup.load = function ()
144                {                               
145                        editGroup();                   
146                }
147                       
148                ccAddGroup.afterSave = function ()
149                {
150                        updateCards();
151                }
152                       
153                return true;
154        }
155
156        if (is_ie)
157        {
158                       
159                document.body.onload = function (e)
160                {                       
161                        Main_pre_load();                                                               
162                        Main_load();                                   
163                                                               
164                }
165        }
166        else
167        {
168               
169                Main_load();   
170                       
171        }       
172
173// BEGIN: FUNCTION RESIZE WINDOW
174var _showBar = showBar;
175var _hideBar = hideBar;
176
177function __showBar(){
178        _showBar();
179        resizeWindow();
180}
181
182function __hideBar(){
183        _hideBar();
184        resizeWindow();
185}
186showBar = __showBar;
187hideBar = __hideBar;
188       
189var _onResize   = window.onresize;
190window.onresize = resizeWindow;
191var defaultHeight = 0;
192function setDefaultHeight(){
193       
194        var bar = Element("toolbar");
195        var offset = 0;
196        if(bar.style.visibility != 'hidden')
197                offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);     
198
199        var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
200        defaultHeight = screenHeight - offset; 
201        Element("cc_tree").style.height                 = defaultHeight - 68;   
202        Element("cc_left_main").style.height    = defaultHeight - 68;   
203}
204
205function resizeWindow(){
206        setDefaultHeight();
207        if(Element("divScrollMain"))
208                Element("divScrollMain").style.height   = defaultHeight - 108; 
209        if (!is_ie)
210                Element('tableDivAppbox').width = '100%';
211}
212document.body.scroll="no";
213document.body.style.overflow ="hidden";
214setDefaultHeight();
215Element('cc_main').style.height = defaultHeight;
216var lang_warn_firefox = Element('cc_msg_warn_firefox');
217var lang_firefox_msg1 = Element('cc_msg_firefox_half1');
218var lang_firefox_msg2 = Element('cc_msg_firefox_half2');
219var lang_install_now = Element('cc_msg_install_now');
220var lang_install_new_firefox = Element('cc_msg_install_new_firefox');
221var lang_close = Element('cc_msg_close');
222function buildWarningMsg(_version) {
223        var screenWidth = document.body.clientWidth ? document.body.clientWidth: document.body.offsetWidth;
224        var _div = document.createElement("DIV");
225        _div.innerHTML += "<DIV id='warning_msg' style='background:LIGHTYELLOW;position:absolute;"+
226        "border:1px solid black;left:"+(screenWidth - 330)+";top:10px;width:300px;padding:10px;"+
227        (document.body.clientWidth ? "-moz-border-radius: 9px 9px 9px 9px;'>" : "")+
228            "<font color='RED' size='2'>"+lang_warn_firefox +  "("+_version+")</font><BR>"+
229            "<font color='black' size='2'><p style='text-align:justify'>&nbsp;"+lang_firefox_msg1+
230            lang_firefox_msg2 + ".</p></font><div style='width:100%' align='center'>"+
231            "<a title='"+lang_install_now+"' href='http://br.mozdev.org/firefox/download.html' target='_blank'>"+lang_install_new_firefox+ "</a>"+     
232        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
233            "<a title='"+lang_close+"' href='javascript:void(0)' onclick='javascript:myOpacity.toggle()'>"+lang_close+"</a></div>"+
234
235        "</DIV>";
236
237        document.body.appendChild(_div);
238
239        myOpacity = new fx.Opacity('warning_msg', {duration: 600});
240        document.getElementById("warning_msg").style.visibility = 'hidden';             
241        myOpacity.now = 0;
242        setTimeout("myOpacity.toggle()",3000);
243}
244// Verifica versão do Firefox
245var agt=navigator.userAgent.toLowerCase();
246if(agt.indexOf('firefox/1.0') != -1 && agt.indexOf('firefox/0.'))
247        buildWarningMsg(agt.substring(agt.indexOf('firefox/')+8,agt.indexOf('firefox/')+13));
Note: See TracBrowser for help on using the repository browser.