]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/MySugar/javascript/MySugar.js
Release 6.4.1
[Github/sugarcrm.git] / jssource / src_files / include / MySugar / javascript / MySugar.js
1 /*********************************************************************************
2  * SugarCRM Community Edition is a customer relationship management program developed by
3  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
4  * 
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Affero General Public License version 3 as published by the
7  * Free Software Foundation with the addition of the following permission added
8  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
11  * 
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
15  * details.
16  * 
17  * You should have received a copy of the GNU Affero General Public License along with
18  * this program; if not, see http://www.gnu.org/licenses or write to the Free
19  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301 USA.
21  * 
22  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
24  * 
25  * The interactive user interfaces in modified source and object code versions
26  * of this program must display Appropriate Legal Notices, as required under
27  * Section 5 of the GNU Affero General Public License version 3.
28  * 
29  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30  * these Appropriate Legal Notices must retain the display of the "Powered by
31  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32  * technical reasons, the Appropriate Legal Notices must display the words
33  * "Powered by SugarCRM".
34  ********************************************************************************/
35
36
37
38 initMySugar = function(){
39 SUGAR.mySugar = function() {
40         var originalLayout = null;
41         var configureDashletId = null;
42         var currentDashlet = null;
43         var leftColumnInnerHTML = null;
44         var leftColObj = null;
45         var maxCount;
46         var warningLang;
47
48     var closeDashletsDialogTimer = null;
49         
50         var activeTab = activePage;
51         var current_user = current_user_id;
52         
53         var module = moduleName;
54         
55         var charts = new Object();
56         
57         if (module == 'Dashboard'){
58                 cookiePageIndex = current_user + "_activeDashboardPage";
59         }
60         else{
61                 cookiePageIndex = current_user + "_activePage";
62         }
63         
64         var homepage_dd;
65         
66
67         return {
68                 
69
70                 
71                 
72
73                 
74                 
75
76         
77         
78                 
79                 
80                                 
81                 
82                 // get the current dashlet layout
83                 getLayout: function(asString) {
84                         columns = new Array();
85                         for(je = 0; je < 3; je++) {
86                             dashlets = document.getElementById('col_'+activeTab+'_'+ je);
87                                             
88                                 if (dashlets != null){
89                                     dashletIds = new Array();
90                                     for(wp = 0; wp < dashlets.childNodes.length; wp++) {
91                                       if(typeof dashlets.childNodes[wp].id != 'undefined' && dashlets.childNodes[wp].id.match(/dashlet_[\w-]*/)) {
92                                                 dashletIds.push(dashlets.childNodes[wp].id.replace(/dashlet_/,''));
93                                       }
94                                     }
95                                         if(asString) 
96                                                 columns[je] = dashletIds.join(',');
97                                         else 
98                                                 columns[je] = dashletIds;
99                                 }
100                         }
101
102                         if(asString) return columns.join('|');
103                         else return columns;
104                 },
105
106                 // called when dashlet is picked up
107                 onDrag: function(e, id) {
108                         originalLayout = SUGAR.mySugar.getLayout(true);         
109                 },
110                 
111                 // called when dashlet is dropped
112                 onDrop: function(e, id) {       
113                         newLayout = SUGAR.mySugar.getLayout(true);
114                         if(originalLayout != newLayout) { // only save if the layout has changed
115                                 SUGAR.mySugar.saveLayout(newLayout);
116                                 SUGAR.mySugar.sugarCharts.loadSugarCharts(); // called safely because there is a check to be sure the array exists
117                         }
118                 },
119                 
120                 // save the layout of the dashlet  
121                 saveLayout: function(order) {
122                         ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING_LAYOUT'));
123                         var success = function(data) {
124                                 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVED_LAYOUT'));
125                                 window.setTimeout('ajaxStatus.hideStatus()', 2000);
126                         }
127                         
128                         url = 'index.php?to_pdf=1&module='+module+'&action=DynamicAction&DynamicAction=saveLayout&layout=' + order + '&selectedPage=' + activeTab;
129                         var cObj = YAHOO.util.Connect.asyncRequest('GET', url, {success: success, failure: success});                                     
130                 },
131
132
133                 uncoverPage: function(id) {
134                         if (!SUGAR.isIE){       
135                                 document.getElementById('dlg_c').style.display = 'none';        
136                         }               
137                         configureDlg.hide();
138             if ( document.getElementById('dashletType') == null ) {
139                 dashletType = '';
140             } else {
141                 dashletType = document.getElementById('dashletType').value;
142             }
143                         SUGAR.mySugar.retrieveDashlet(SUGAR.mySugar.configureDashletId, dashletType);
144                 },
145                 
146                 // call to configure a Dashlet
147                 configureDashlet: function(id) {
148                         ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_LOADING'));
149                         configureDlg = new YAHOO.widget.SimpleDialog("dlg", 
150                                 { visible:false, 
151                                   width:"510", 
152                                   effect:[{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5}],
153                                   fixedcenter:true, 
154                                   modal:true, 
155                                   draggable:false }
156                         );
157                         
158                         fillInConfigureDiv = function(data){
159                                 ajaxStatus.hideStatus();
160                                 // uncomment the line below to debug w/ FireBug
161                                 // console.log(data.responseText); 
162                                 try {
163                                         eval(data.responseText);
164                                 }
165                                 catch(e) {
166                                         result = new Array();
167                                         result['header'] = 'error';
168                                         result['body'] = 'There was an error handling this request.';
169                                 }
170                                 configureDlg.setHeader(result['header']);
171                                 configureDlg.setBody(result['body']);
172                                 var listeners = new YAHOO.util.KeyListener(document, { keys : 27 }, {fn: function() {this.hide();}, scope: configureDlg, correctScope:true} );
173                                 configureDlg.cfg.queueProperty("keylisteners", listeners);
174
175                                 configureDlg.render(document.body);
176                                 configureDlg.show();
177                                 configureDlg.configFixedCenter(null, false) ;
178                                 SUGAR.util.evalScript(result['body']);
179                         }
180
181                         SUGAR.mySugar.configureDashletId = id; // save the id of the dashlet being configured
182                         var cObj = YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module='+module+'&action=DynamicAction&DynamicAction=configureDashlet&id=' + id, 
183                                                                                                           {success: fillInConfigureDiv, failure: fillInConfigureDiv}, null);
184                 },
185                 
186                                 
187                 /** returns dashlets contents
188                  * if url is defined, dashlet will be retrieve with it, otherwise use default url
189                  *
190                  * @param string id id of the dashlet to refresh
191                  * @param string url url to be used
192                  * @param function callback callback function after refresh
193                  * @param bool dynamic does the script load dynamic javascript, set to true if you user needs to refresh the dashlet after load
194                  */
195                 retrieveDashlet: function(id, url, callback, dynamic) {
196                         ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_LOADING'));
197                                         
198                         if(!url) {
199                                 url = 'index.php?action=DynamicAction&DynamicAction=displayDashlet&session_commit=1&module='+module+'&to_pdf=1&id=' + id;
200                                 is_chart_dashlet = false;
201                         }
202                         else if (url == 'predefined_chart'){
203                                 url = 'index.php?action=DynamicAction&DynamicAction=displayDashlet&session_commit=1&module='+module+'&to_pdf=1&id=' + id;
204                                 scriptUrl = 'index.php?action=DynamicAction&DynamicAction=getPredefinedChartScript&session_commit=1&module='+module+'&to_pdf=1&id=' + id;
205                                 is_chart_dashlet = true;
206                         }
207                         
208                         
209                         if(dynamic) {
210                                 url += '&dynamic=true';
211                         }
212
213                         var fillInDashlet = function(data) {
214
215                                 ajaxStatus.hideStatus();
216                                 if(data) {              
217                                         SUGAR.mySugar.currentDashlet.innerHTML = data.responseText;                     
218                                 }
219
220                                 SUGAR.util.evalScript(data.responseText);
221                                 if(callback) callback();
222                                 
223                                 var processChartScript = function(scriptData){
224                                         SUGAR.util.evalScript(scriptData.responseText);
225                                         //custom chart code
226                                         SUGAR.mySugar.sugarCharts.loadSugarCharts(activePage);
227
228                                 }
229                                 if(typeof(is_chart_dashlet)=='undefined'){
230                                         is_chart_dashlet = false;
231                                 }
232                                 if (is_chart_dashlet){                          
233                                         var chartScriptObj = YAHOO.util.Connect.asyncRequest('GET', scriptUrl,
234                                                                                                           {success: processChartScript, failure: processChartScript}, null);
235                                 }
236                         }
237                         
238                         SUGAR.mySugar.currentDashlet = document.getElementById('dashlet_entire_' + id);
239                         var cObj = YAHOO.util.Connect.asyncRequest('GET', url,
240                                             {success: fillInDashlet, failure: fillInDashlet}, null); 
241                         return false;
242                 },
243                 
244                 // for the display columns widget
245                 setChooser: function() {                
246                         var displayColumnsDef = new Array();
247                         var hideTabsDef = new Array();
248
249                     var left_td = document.getElementById('display_tabs_td');   
250                     var right_td = document.getElementById('hide_tabs_td');                     
251         
252                     var displayTabs = left_td.getElementsByTagName('select')[0];
253                     var hideTabs = right_td.getElementsByTagName('select')[0];
254                         
255                         for(i = 0; i < displayTabs.options.length; i++) {
256                                 displayColumnsDef.push(displayTabs.options[i].value);
257                         }
258                         
259                         if(typeof hideTabs != 'undefined') {
260                                 for(i = 0; i < hideTabs.options.length; i++) {
261                                  hideTabsDef.push(hideTabs.options[i].value);
262                                 }
263                         }
264                         
265                         document.getElementById('displayColumnsDef').value = displayColumnsDef.join('|');
266                         document.getElementById('hideTabsDef').value = hideTabsDef.join('|');
267                 },
268                 
269                 deleteDashlet: function(id) {
270                         if(confirm(SUGAR.language.get('app_strings', 'LBL_REMOVE_DASHLET_CONFIRM'))) {
271                                 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_REMOVING_DASHLET'));
272                                 
273                                 del = function() {
274                                         var success = function(data) {
275                                                 dashlet = document.getElementById('dashlet_' + id);
276                                                 dashlet.parentNode.removeChild(dashlet);
277                                                 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_REMOVED_DASHLET'));
278                                                 window.setTimeout('ajaxStatus.hideStatus()', 2000);
279                                         }
280                                 
281                                         
282                                         var cObj = YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module='+module+'&action=DynamicAction&DynamicAction=deleteDashlet&activePage=' + activeTab + '&id=' + id, 
283                                                                                                                           {success: success, failure: success}, null);
284                                 }
285                                 
286                                 var anim = new YAHOO.util.Anim('dashlet_entire_' + id, { height: {to: 1} }, .5 );                                       
287                                 anim.onComplete.subscribe(del);                                 
288                                 document.getElementById('dashlet_entire_' + id).style.overflow = 'hidden';
289                                 anim.animate();
290                                 
291                                 return false;
292                         }
293                         return false;
294                 },
295                 
296                 
297                 addDashlet: function(id, type, type_module) {
298                         ajaxStatus.hideStatus();
299                         columns = SUGAR.mySugar.getLayout();
300                                                 
301                         var num_dashlets = columns[0].length;
302                         if (typeof columns[1] == undefined){
303                                 num_dashlets = num_dashlets + columns[1].length;
304                         }
305                         
306                         if((num_dashlets) >= SUGAR.mySugar.maxCount) {
307                                 alert(SUGAR.language.get('app_strings', 'LBL_MAX_DASHLETS_REACHED'));
308                                 return;
309                         }                       
310 /*                      if((columns[0].length + columns[1].length) >= SUGAR.mySugar.maxCount) {
311                                 alert(SUGAR.language.get('Home', 'LBL_MAX_DASHLETS_REACHED'));
312                                 return;
313                         }*/
314                         ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_ADDING_DASHLET'));
315                         var success = function(data) {
316
317                                 colZero = document.getElementById('col_'+activeTab+'_0');
318                                 newDashlet = document.createElement('li'); // build the list item
319                                 newDashlet.id = 'dashlet_' + data.responseText;
320                                 newDashlet.className = 'noBullet active';
321                                 // hide it first, but append to getRegion
322                                 newDashlet.innerHTML = '<div style="position: absolute; top: -1000px; overflow: hidden;" id="dashlet_entire_' + data.responseText + '"></div>';
323
324                                 colZero.insertBefore(newDashlet, colZero.firstChild); // insert it into the first column
325                                 
326                                 var finishRetrieve = function() {
327                                         dashletEntire = document.getElementById('dashlet_entire_' + data.responseText);
328                                         dd = new ygDDList('dashlet_' + data.responseText); // make it draggable
329                                         dd.setHandleElId('dashlet_header_' + data.responseText);
330                     // Bug #47097 : Dashlets not displayed after moving them
331                     // add new property to save real id of dashlet, it needs to have ability reload dashlet by id
332                     dd.dashletID = data.responseText;
333                                         dd.onMouseDown = SUGAR.mySugar.onDrag;  
334                                         dd.onDragDrop = SUGAR.mySugar.onDrop;
335
336                                         ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_ADDED_DASHLET'));
337                                         dashletRegion = YAHOO.util.Dom.getRegion(dashletEntire);
338                                         dashletEntire.style.position = 'relative';
339                                         dashletEntire.style.height = '1px';
340                                         dashletEntire.style.top = '0px';
341                                         dashletEntire.className = 'dashletPanel';
342                                         
343                                         
344                                         var anim = new YAHOO.util.Anim('dashlet_entire_' + data.responseText, { height: {to: dashletRegion.bottom - dashletRegion.top} }, .5 );
345                                         anim.onComplete.subscribe(function() { document.getElementById('dashlet_entire_' + data.responseText).style.height = '100%'; });        
346                                         anim.animate();
347                                         
348                                         newLayout =     SUGAR.mySugar.getLayout(true);
349                                         SUGAR.mySugar.saveLayout(newLayout);    
350 //                                      window.setTimeout('ajaxStatus.hideStatus()', 2000);
351                                 }
352                                 
353                                 if (type == 'module' || type == 'web'){
354                                         url = null;
355                                         type = 'module';
356                                 }
357                                 else if (type == 'predefined_chart'){
358                                         url = 'predefined_chart';
359                                         type = 'predefined_chart';
360                                 }
361                                 else if (type == 'chart'){
362                                         url = 'chart';
363                                         type = 'chart';
364                                 }
365                                 
366                                 SUGAR.mySugar.retrieveDashlet(data.responseText, url, finishRetrieve, true); // retrieve it from the server
367                         }
368
369                         var cObj = YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module='+module+'&action=DynamicAction&DynamicAction=addDashlet&activeTab=' + activeTab + '&id=' + id+'&type=' + type + '&type_module=' + escape(type_module), 
370                                                                                                           {success: success, failure: success}, null);                                            
371
372                         return false;
373                 },
374                 
375                 showDashletsDialog: function() {                                             
376                         columns = SUGAR.mySugar.getLayout();
377
378             if (this.closeDashletsDialogTimer != null) {
379                 window.clearTimeout(this.closeDashletsDialogTimer);
380             }
381
382                         var num_dashlets = 0;
383             var i = 0;
384             for ( i = 0 ; i < 3; i++ ) {
385                 if (typeof columns[i] != "undefined") {
386                     num_dashlets = num_dashlets + columns[i].length;
387                 }
388             }
389                         
390                         if((num_dashlets) >= SUGAR.mySugar.maxCount) {
391                                 alert(SUGAR.language.get('app_strings', 'LBL_MAX_DASHLETS_REACHED'));
392                                 return;
393                         }
394                         ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_LOADING'));
395                         
396                         var success = function(data) {          
397                                 eval(data.responseText);
398                                 dashletsListDiv = document.getElementById('dashletsList');
399                                 dashletsListDiv.innerHTML = response['html'];
400                                 
401                                 document.getElementById('dashletsDialog_c').style.display = '';
402                 SUGAR.mySugar.dashletsDialog.show();
403
404                                 eval(response['script']);
405                                 ajaxStatus.hideStatus();
406                         }
407                         
408                         var cObj = YAHOO.util.Connect.asyncRequest('GET', 'index.php?to_pdf=true&module='+module+'&action=DynamicAction&DynamicAction=dashletsDialog', {success: success, failure: success});                   
409                         return false;
410                 },
411                 
412                 closeDashletsDialog: function(){
413                         SUGAR.mySugar.dashletsDialog.hide();
414                         if (this.closeDashletsDialogTimer != null) {
415                 window.clearTimeout(this.closeDashletsDialogTimer);
416             }
417             this.closeDashletsDialogTimer = window.setTimeout("document.getElementById('dashletsDialog_c').style.display = 'none';", 2000);
418                 },
419
420                 toggleDashletCategories: function(category){
421                         document.getElementById('search_string').value = '';
422                         document.getElementById('searchResults').innerHTML = '';
423                         
424                         var moduleTab = document.getElementById('moduleCategory');
425                         var moduleTabAnchor = document.getElementById('moduleCategoryAnchor');
426                         var moduleListDiv = document.getElementById('moduleDashlets');
427
428                         var chartTab = document.getElementById('chartCategory');
429                         var chartTabAnchor = document.getElementById('chartCategoryAnchor');                    
430                         var chartListDiv = document.getElementById('chartDashlets');                    
431                         
432                         var toolsTab = document.getElementById('toolsCategory');
433                         var toolsTabAnchor = document.getElementById('toolsCategoryAnchor');                    
434                         var toolsListDiv = document.getElementById('toolsDashlets');    
435                         
436                         var webTab = document.getElementById('webCategory');
437                         var webTabAnchor = document.getElementById('webCategoryAnchor');                        
438                         var webListDiv = document.getElementById('webDashlets');        
439                         
440                         switch(category){
441                                 case 'module':
442                                         moduleTab.className = 'active';
443                                         moduleTabAnchor.className = 'current';
444                                         moduleListDiv.style.display = '';
445                                         
446                                         chartTab.className = '';
447                                         chartTabAnchor.className = '';
448                                         chartListDiv.style.display = 'none';
449
450                                         toolsTab.className = '';
451                                         toolsTabAnchor.className = '';
452                                         toolsListDiv.style.display = 'none';
453
454                                         webTab.className = '';
455                                         webTabAnchor.className = '';
456                                         webListDiv.style.display = 'none';
457                                                                         
458                                         break;
459                                 case 'chart':
460                                         moduleTab.className = '';
461                                         moduleTabAnchor.className = '';
462                                         moduleListDiv.style.display = 'none';
463                                         
464                                         chartTab.className = 'active';
465                                         chartTabAnchor.className = 'current';
466                                         chartListDiv.style.display = '';                                        
467
468                                         toolsTab.className = '';
469                                         toolsTabAnchor.className = '';
470                                         toolsListDiv.style.display = 'none';
471
472                                         webTab.className = '';
473                                         webTabAnchor.className = '';
474                                         webListDiv.style.display = 'none';
475                                         
476                                         break;
477                                 case 'tools':
478                                         moduleTab.className = '';
479                                         moduleTabAnchor.className = '';
480                                         moduleListDiv.style.display = 'none';
481                                         
482                                         chartTab.className = '';
483                                         chartTabAnchor.className = '';
484                                         chartListDiv.style.display = 'none';                                    
485
486                                         toolsTab.className = 'active';
487                                         toolsTabAnchor.className = 'current';
488                                         toolsListDiv.style.display = '';
489
490                                         webTab.className = '';
491                                         webTabAnchor.className = '';
492                                         webListDiv.style.display = 'none';
493                                         
494                                         break;
495                 case 'web':
496                                         moduleTab.className = '';
497                                         moduleTabAnchor.className = '';
498                                         moduleListDiv.style.display = 'none';
499                                         
500                                         chartTab.className = '';
501                                         chartTabAnchor.className = '';
502                                         chartListDiv.style.display = 'none';                                    
503
504                                         toolsTab.className = '';
505                                         toolsTabAnchor.className = '';
506                                         toolsListDiv.style.display = 'none';
507
508                                         webTab.className = 'active';
509                                         webTabAnchor.className = 'current';
510                                         webListDiv.style.display = '';                                  
511                                         
512                                         break;
513                                 default:
514                                         break;                                  
515                         }                       
516                         
517                         document.getElementById('search_category').value = category;
518                 },
519                 
520
521                 searchDashlets: function(searchStr, searchCategory){
522                         var moduleTab = document.getElementById('moduleCategory');
523                         var moduleTabAnchor = document.getElementById('moduleCategoryAnchor');
524                         var moduleListDiv = document.getElementById('moduleDashlets');
525
526                         var chartTab = document.getElementById('chartCategory');
527                         var chartTabAnchor = document.getElementById('chartCategoryAnchor');                    
528                         var chartListDiv = document.getElementById('chartDashlets');                    
529                         
530                         var toolsTab = document.getElementById('toolsCategory');
531                         var toolsTabAnchor = document.getElementById('toolsCategoryAnchor');                    
532                         var toolsListDiv = document.getElementById('toolsDashlets');                    
533
534                         if (moduleTab != null && chartTab != null && toolsTab != null){ 
535                                 moduleListDiv.style.display = 'none';
536                                 chartListDiv.style.display = 'none';    
537                                 toolsListDiv.style.display = 'none';
538                         
539                         }
540                         // dashboards case, where there are no tabs
541                         else{
542                                 chartListDiv.style.display = 'none';
543                         }
544                         
545                         var searchResultsDiv = document.getElementById('searchResults');
546                         searchResultsDiv.style.display = '';
547         
548                         var success = function(data) {
549                                 eval(data.responseText);
550
551                                 searchResultsDiv.innerHTML = response['html'];
552                         }
553                         
554                         var cObj = YAHOO.util.Connect.asyncRequest('GET', 'index.php?to_pdf=true&module='+module+'&action=DynamicAction&DynamicAction=searchDashlets&search='+searchStr+'&category='+searchCategory, {success: success, failure: success});
555                         return false;
556                 },
557                 
558                 collapseList: function(chartList){
559                         document.getElementById(chartList+'List').style.display='none';
560                         document.getElementById(chartList+'ExpCol').innerHTML = '<a href="javascript:void(0)" onClick="javascript:SUGAR.mySugar.expandList(\''+chartList+'\');"><img border="0" src="' + SUGAR.themes.image_server + 'index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=advanced_search.gif" align="absmiddle" />';
561                 },
562                 
563                 expandList: function(chartList){
564                         document.getElementById(chartList+'List').style.display='';             
565                         document.getElementById(chartList+'ExpCol').innerHTML = '<a href="javascript:void(0)" onClick="javascript:SUGAR.mySugar.collapseList(\''+chartList+'\');"><img border="0" src="' + SUGAR.themes.image_server + 'index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=basic_search.gif" align="absmiddle" />';
566                 },
567                 
568                 collapseReportList: function(reportChartList){
569                         document.getElementById(reportChartList+'ReportsChartDashletsList').style.display='none';
570                         document.getElementById(reportChartList+'ExpCol').innerHTML = '<a href="javascript:void(0)" onClick="javascript:SUGAR.mySugar.expandReportList(\''+reportChartList+'\');"><img border="0" src="' + SUGAR.themes.image_server + 'index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=ProjectPlus.gif" align="absmiddle" />';
571                 },
572                 
573                 expandReportList: function(reportChartList){
574                         document.getElementById(reportChartList+'ReportsChartDashletsList').style.display='';
575                         document.getElementById(reportChartList+'ExpCol').innerHTML = '<a href="javascript:void(0)" onClick="javascript:SUGAR.mySugar.collapseReportList(\''+reportChartList+'\');"><img border="0" src="' + SUGAR.themes.image_server + 'index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=ProjectMinus.gif" align="absmiddle" />';
576                 },
577                 
578                 clearSearch: function(){
579                         document.getElementById('search_string').value = '';
580
581                         var moduleTab = document.getElementById('moduleCategory');
582                         var moduleTabAnchor = document.getElementById('moduleCategoryAnchor');
583                         var moduleListDiv = document.getElementById('moduleDashlets');
584                         
585                         document.getElementById('searchResults').innerHTML = '';
586                         if (moduleTab != null){
587                                 SUGAR.mySugar.toggleDashletCategories('module');
588                         }
589                         else{
590                                 document.getElementById('searchResults').style.display = 'none';
591                                 document.getElementById('chartDashlets').style.display = '';
592                         }
593                 },
594                 
595                 doneAddDashlets: function() {
596                         SUGAR.mySugar.dashletsDialog.hide();
597                         return false;
598                 },
599
600                 
601                 
602                 
603                 renderDashletsDialog: function(){       
604             var minHeight = 120;
605             var maxHeight = 520;
606             var minMargin = 16;
607
608             // adjust dialog height according to current page height
609             var pageHeight = document.documentElement.clientHeight;
610             var height = Math.min(maxHeight, pageHeight - minMargin * 2);
611             height = Math.max(height, minHeight);
612
613                         SUGAR.mySugar.dashletsDialog = new YAHOO.widget.Dialog("dashletsDialog", 
614                         { width : "480px",
615                           height: height + "px",
616                           fixedcenter : true,
617                           draggable:false,
618                           visible : false, 
619                          // effect:[{effect:YAHOO.widget.ContainerEffect.SLIDETOP, duration:0.5},{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5}],
620                           modal : true,
621                           close:false
622                          } );
623
624                         var listeners = new YAHOO.util.KeyListener(document, { keys : 27 }, {fn: function() {SUGAR.mySugar.closeDashletsDialog();} } );
625                         SUGAR.mySugar.dashletsDialog.cfg.queueProperty("keylisteners", listeners);
626
627                         document.getElementById('dashletsDialog').style.display = '';                                                                                                                                                            
628                         SUGAR.mySugar.dashletsDialog.render();
629                         document.getElementById('dashletsDialog_c').style.display = 'none';                     
630                 }       
631          }; 
632 }();
633 };