📄 mysugar.js
字号:
/**
* SugarCRM is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation with the addition of the following permission added * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". */
SUGAR.mySugar = function() {
var originalLayout = null;
var configureDashletId = null;
var currentDashlet = null;
var leftColumnInnerHTML = null;
var leftColObj = null;
var maxCount;
var warningLang;
var activeTab = activePage;
var current_user = current_user_id;
var module = moduleName;
var charts = new Object();
if (module == 'Dashboard'){
cookiePageIndex = current_user + "_activeDashboardPage";
}
else{
cookiePageIndex = current_user + "_activePage";
}
var homepage_dd;
return {
clearChartsArray: function(){
charts[activeTab] = new Object();
},
addToChartsArray: function(name, xmlFile, width, height, styleSheet, colorScheme, langFile){
if (charts[activeTab] == null){
charts[activeTab] = new Object();
}
charts[activeTab][name] = new Object();
charts[activeTab][name]['name'] = name;
charts[activeTab][name]['xmlFile'] = xmlFile;
charts[activeTab][name]['width'] = width;
charts[activeTab][name]['height'] = height;
charts[activeTab][name]['styleSheet'] = styleSheet;
charts[activeTab][name]['colorScheme'] = colorScheme;
charts[activeTab][name]['langFile'] = langFile;
},
loadSugarChart: function(name, xmlFile, width, height, styleSheet, colorScheme, langFile){
loadChartSWF(name, xmlFile, width, height, styleSheet, colorScheme, langFile);
},
loadSugarCharts: function(){
for (id in charts[activeTab]){
if(id != 'undefined'){
SUGAR.mySugar.loadSugarChart(charts[activeTab][id]['name'],
charts[activeTab][id]['xmlFile'],
charts[activeTab][id]['width'],
charts[activeTab][id]['height'],
charts[activeTab][id]['styleSheet'],
charts[activeTab][id]['colorScheme'],
charts[activeTab][id]['langFile']);
}
}
},
// get the current dashlet layout
getLayout: function(asString) {
columns = new Array();
for(je = 0; je < 3; je++) {
dashlets = document.getElementById('col_'+activeTab+'_'+ je);
if (dashlets != null){
dashletIds = new Array();
for(wp = 0; wp < dashlets.childNodes.length; wp++) {
if(typeof dashlets.childNodes[wp].id != 'undefined' && dashlets.childNodes[wp].id.match(/dashlet_[\w-]*/)) {
dashletIds.push(dashlets.childNodes[wp].id.replace(/dashlet_/,''));
}
}
if(asString)
columns[je] = dashletIds.join(',');
else
columns[je] = dashletIds;
}
}
if(asString) return columns.join('|');
else return columns;
},
// called when dashlet is picked up
onDrag: function(e, id) {
originalLayout = SUGAR.mySugar.getLayout(true);
},
// called when dashlet is dropped
onDrop: function(e, id) {
newLayout = SUGAR.mySugar.getLayout(true);
if(originalLayout != newLayout) { // only save if the layout has changed
SUGAR.mySugar.saveLayout(newLayout);
SUGAR.mySugar.loadSugarCharts(); // called safely because there is a check to be sure the array exists
}
},
// save the layout of the dashlet
saveLayout: function(order) {
ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING_LAYOUT'));
var success = function(data) {
ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVED_LAYOUT'));
window.setTimeout('ajaxStatus.hideStatus()', 2000);
}
url = 'index.php?to_pdf=1&module='+module+'&action=DynamicAction&DynamicAction=saveLayout&layout=' + order + '&selectedPage=' + activeTab;
var cObj = YAHOO.util.Connect.asyncRequest('GET', url, {success: success, failure: success});
},
uncoverPage: function(id) {
if (!isIE){
document.getElementById('dlg_c').style.display = 'none';
}
configureDlg.hide();
dashletType = document.getElementById('dashletType').value;
SUGAR.mySugar.retrieveDashlet(SUGAR.mySugar.configureDashletId, dashletType);
},
// call to configure a Dashlet
configureDashlet: function(id) {
ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_LOADING'));
configureDlg = new YAHOO.widget.SimpleDialog("dlg",
{ visible:false,
width:"510",
effect:[{effect:YAHOO.widget.ContainerEffect.SLIDETOP, duration:0.5},
{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5}],
fixedcenter:true,
modal:true,
draggable:false }
);
fillInConfigureDiv = function(data){
ajaxStatus.hideStatus();
// uncomment the line below to debug w/ FireBug
// console.log(data.responseText);
try {
eval(data.responseText);
}
catch(e) {
result = new Array();
result['header'] = 'error';
result['body'] = 'There was an error handling this request.';
}
configureDlg.setHeader(result['header']);
configureDlg.setBody(result['body']);
var listeners = new YAHOO.util.KeyListener(document, { keys : 27 }, {fn: function() {this.hide();}, scope: configureDlg, correctScope:true} );
configureDlg.cfg.queueProperty("keylisteners", listeners);
configureDlg.render(document.body);
configureDlg.show();
configureDlg.configFixedCenter(null, false) ;
SUGAR.util.evalScript(result['body']);
}
SUGAR.mySugar.configureDashletId = id; // save the id of the dashlet being configured
var cObj = YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module='+module+'&action=DynamicAction&DynamicAction=configureDashlet&id=' + id,
{success: fillInConfigureDiv, failure: fillInConfigureDiv}, null);
},
/** returns dashlets contents
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -