⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajax.js

📁 SugarCRM5.1 开源PHP客户关系管理系统
💻 JS
📖 第 1 页 / 共 4 页
字号:
/********************************************************************************* * 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". ********************************************************************************//** */var AjaxObject = {	ret : '',	currentRequestObject : null,	//timeout : 30000, // 30 second timeout default	timeout : 9999999999, // 30 second timeout default	forceAbort : false,	trail : new Array(),	/**	 */	_reset : function() {		this.timeout = 30000;		this.forceAbort = false;	},	folderRenameCleanup : function() {		SUGAR.email2.folders.setSugarFolders();	},	fullSyncCleanup : function(o) {		this.folders.checkMailCleanup(o);		SUGAR.email2.settings.settingsDialog.hide();	},	/**	 */	composeCache : function(o) {		var idx = SUGAR.email2.composeLayout.currentInstanceId; // post instance increment		// get email templates and user signatures		var ret = JSON.parse(o.responseText);		SUGAR.email2.composeLayout.emailTemplates = ret.emailTemplates;		SUGAR.email2.composeLayout.signatures = ret.signatures;		SUGAR.email2.composeLayout.fromAccounts = ret.fromAccounts;		SUGAR.email2.composeLayout.setComposeOptions(idx);	},	/**	 */	handleDeleteReturn : function(o) {		// force refresh ListView		hideOverlay();		if(document.getElementById('focusEmailMbox')) {			YAHOO.namespace('frameFolders').selectednode = SUGAR.email2.folders.getNodeFromMboxPath(document.getElementById('focusEmailMbox').innerHTML);		}		// need to display success message before calling next async call?		document.getElementById(this.target).innerHTML = o.responseText;	},	/**	 */    handleFailure : function(o) {		// Failure handler		overlay('Exception occurred...', o.statusText, 'alert');	},	handleReplyForward : function(o) {		var a = JSON.parse(o.responseText);		globalA = a;		var idx = SUGAR.email2.composeLayout.currentInstanceId;		document.getElementById('email_id' + idx).value = a.uid;		document.getElementById('emailSubject' + idx).value = a.name;		document.getElementById('addressTo' + idx).value = a.from;		if(a.cc) {			document.getElementById('addressCC' + idx).value = a.cc;		}		if(a.type) {			document.getElementById('type' + idx).value = a.type;		}		// apply attachment values		SUGAR.email2.composeLayout.loadAttachments(a.attachments);		setTimeout("callbackReplyForward.finish(globalA);", 500);	},	handleReplyForwardForDraft : function(o) {		var a = JSON.parse(o.responseText);		globalA = a;		var idx = SUGAR.email2.composeLayout.currentInstanceId;		document.getElementById('email_id' + idx).value = a.uid;		document.getElementById('emailSubject' + idx).value = a.name;		document.getElementById('addressTo' + idx).value = a.to;		if(a.cc) {			document.getElementById('addressCC' + idx).value = a.cc;		}		if(a.bcc) {			document.getElementById('addressBCC' + idx).value = a.bcc;		}				if(a.type) {			document.getElementById('type' + idx).value = a.type;		}		// apply attachment values		SUGAR.email2.composeLayout.loadAttachments(a.attachments);		setTimeout("callbackReplyForward.finish(globalA);", 500);	},			/**	 */	handleSuccess : function(o) {		document.getElementById(this.target).innerHTML = o.responseText;		hideOverlay();	},	/**	 */	ieDeleteSuccess : function(o) {		hideOverlay();		SUGAR.email2.accounts.addNewAccount();		var ret = JSON.parse(o.responseText);		var ms = document.getElementById('ieAccountList');		var ms2 = document.getElementById('ieAccountListShow');		for(i=0; i<ms.options.length; i++) {			if(ret.id == ms.options[i].value) {				document.ieSelect.ieId.options[i] = null;			}		}		for(j=0; j<ms2.options.length; j++) {			if(ret.id == ms2.options[j].value) {				ms2.options[j] = null;			}		}		SUGAR.email2.accounts.rebuildAccountList();		alert(app_strings.LBL_EMAIL_IE_DELETE_SUCCESSFUL);		SUGAR.email2.accounts.rebuildFolderList();		SUGAR.email2.search.markSearchAccountListDirty();			},	/**	 */	ieSaveSuccess : function(o) {		document.getElementById('saveButton').disabled = false;		var a = JSON.parse(o.responseText);		if (a) {			if(a.error) {				overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_CHECK_IE_SETTINGS, 'alert');				SUGAR.email2.accounts.ieAccountError(SUGAR.email2.accounts.errorStyle);			} else {				resp = JSON.parse(o.responseText);				SUGAR.email2.search.markSearchAccountListDirty();				SUGAR.email2.accounts.fillIeAccount(o.responseText);				SUGAR.email2.accounts.focusOrCreateIeEl(o.responseText);				SUGAR.email2.folders.startEmailCheckOneAccount(resp.id, true);			}		} else {		     hideOverlay();		     overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_SAVE_ACCOUNT, 'alert'); 		}			},	/**	 */	loadAttachments : function(o) {		var result = JSON.parse(o.responseText);		SUGAR.email2.composeLayout.loadAttachments(result);	},	/**	 */	loadSignature : function(o) {		var ret = JSON.parse(o.responseText);		SUGAR.email2.signatures[ret.id] = ret.signature_html;		SUGAR.email2.composeLayout.setSignature(SUGAR.email2.signatures.targetInstance);	},	/**	 * Follow up to mark email read|unread|flagged	 */	markEmailCleanup : function(o) {		SUGAR.email2.contextMenus.markEmailCleanup();	},	/**	 */	rebuildShowFolders : function(o) {		var t = JSON.parse(o.responseText);		var show = document.getElementById('ieAccountListShow');		SUGAR.email2.util.emptySelectOptions(show);		for(i=0; i<t.length; i++) { // iterate through assoc array			var opt = new Option(t[i].text, t[i].value, t[i].selected);			opt.selected = t[i].selected;			show.options.add(opt);		}		SUGAR.email2.search.markSearchAccountListDirty();		SUGAR.email2.accounts.renderTree();	},	/**	 */	rebuildShowFoldersForSearch : function(o) {		var t = JSON.parse(o.responseText);		var show = document.getElementById('accountListSearch');		SUGAR.email2.util.emptySelectOptions(show);		for(i=0; i<t.length; i++) { // iterate through assoc array			var opt = new Option(t[i].text, t[i].value);			opt.protocol = t[i].protocol;			show.options.add(opt);		}		SUGAR.email2.search.accountListSearchChange(show);	},	/**	 */	saveListViewSortOrderPart2 : function() {		// create the JSON string the func expects		focusFolderPath = '[ "Home", "' + ieName + '"';		var f = new String(focusFolder);		var fEx = f.split('.');		for(i=0; i<fEx.length; i++) {			focusFolderPath += ', "' + fEx[i] +'"'		}		focusFolderPath += ']';		YAHOO.namespace('frameFolders').selectednode = SUGAR.email2.folders.getNodeFromMboxPath(focusFolderPath);		SUGAR.email2.listView.populateListFrame(YAHOO.namespace('frameFolders').selectednode, ieId, 'true');	},	/**	 *	 */	sendEmailCleanUp : function(o) {		hideOverlay();		var ret = JSON.parse(o.responseText);		if (ret) {		  SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);		  //SUGAR.email2.addressBook.showContactMatches(ret.possibleMatches);		} else if (o.responseText) {		  overlay(app_strings.LBL_EMAIL_ERROR_GENERAL_TITLE, o.responseText, 'alert');		}		SUGAR.email2.grid.getDataSource().reload();		//Disabled while address book is disabled			},	/**	 */	settingsFolderRefresh : function(o) {		//SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder		var ret = JSON.parse(o.responseText);		var user = document.getElementById('userFolders');		var grp = document.getElementById('groupFolders');		var grpAdd = document.getElementById('groupFoldersAdd');		var editGroupFolderList = document.getElementById('editGroupFolderList');		if (document.getElementById('groupFolderAddName') != null) {			document.getElementById('groupFolderAddName').value = '';		} // if		if (document.getElementById('addNewFolders') != null) {			document.getElementById('addNewFolders').style.display = '';		}		if (document.getElementById('saveGroupFolder') != null) {			document.getElementById('saveGroupFolder').style.display = 'none';		}		if (document.getElementById('cancelEditGroupFolder') != null) {			document.getElementById('cancelEditGroupFolder').style.display = 'none';		} // if		SUGAR.email2.util.emptySelectOptions(user);		SUGAR.email2.util.emptySelectOptions(grp);		SUGAR.email2.util.emptySelectOptions(grpAdd);		SUGAR.email2.util.emptySelectOptions(editGroupFolderList);		for(i=0; i<ret.userFolders.length; i++) {			var display = ret.userFolders[i].name;			var value = ret.userFolders[i].id;			var selected = (ret.userFolders[i].selected != "") ? true : false;			var opt = new Option(display, value, selected);			opt.selected = selected;			user.options.add(opt);		}		for(i=0; i<ret.groupFolders.length; i++) {			var display = ret.groupFolders[i].name;			var value = ret.groupFolders[i].id;			var selected = (ret.groupFolders[i].selected != "") ? true : false;			var opt = new Option(display, value, selected);			var optAdd = new Option(display, value, selected);			opt.selected = selected;			grp.options.add(opt);			if(grpAdd) {				grpAdd.options.add(new Option(display, value));			}			if (editGroupFolderList) {				editGroupFolderList.options.add(new Option(display, value));			}		}	},	/**	 */	startRequest : function(callback, args, forceAbort) {		if(this.currentRequestObject != null) {			if(this.forceAbort == true) {				YAHOO.util.Connect.abort(this.currentRequestObject, null, false);			}		}		this.currentRequestObject = YAHOO.util.Connect.asyncRequest('POST', "./index.php", callback, args);		this._reset();	},	/**	 */	updateFolderSubscriptions : function() {		SUGAR.email2.folders.lazyLoadSettings(); // refresh view in Settings overlay		setTimeout("SUGAR.email2.folders.setSugarFolders();", 1000);		//SUGAR.email2.folders.setSugarFolders(); // refresh view in TreeView	},	/**	 */	updateFrameFolder : function() {		SUGAR.email2.folders.checkEmailAccounts();	},	/**	 */	updateUserPrefs : function(o) {		SUGAR.email2.userPrefs = JSON.parse(o.responseText);		SUGAR.email2.folders.startCheckTimer(); // starts the auto-check interval	},	/**	 */	uploadAttachmentSuccessful : function(o) {		// clear out field		document.getElementById('email_attachment').value = '';		var ret = JSON.parse(o.responseText);		var idx = SUGAR.email2.composeLayout.currentInstanceId;		var overall = document.getElementById('addedFiles' + idx);		var index = overall.childNodes.length;		// bucket		var tmp = Ext.DomHelper.append(overall, {			tag : 'div',			id : 'email_attachment_bucket' + idx + index		}, true);		var d = tmp.dom;		// remove button		Ext.DomHelper.append(d, {			tag:'img',			src: 'themes/Sugar/images/minus.gif',			cls: 'image',			style: 'cursor:pointer',			align: 'absmiddle',			onclick: "SUGAR.email2.composeLayout.deleteUploadAttachment('"+idx +index+"', '"+ret.guid+ret.name+"');"		});		// file icon		Ext.DomHelper.append(d, {			tag:'img',			src: 'themes/default/images/attachment.gif',			id:'email_attachmentImage' + idx + index,			align: 'absmiddle',			cls: 'image'		});		// hidden id field		Ext.DomHelper.append(d, {			tag:'input',			type: 'hidden',			value: ret.guid+ret.name,			name:'email_attachment' + index,			id:'email_attachment' + idx + index		});		// file name		d.innerHTML += ret.name + "&nbsp;";		// br		Ext.DomHelper.append(d, {			tag:'br'		});		if(SUGAR.email2.util.isIe()) {			document.getElementById('addedFiles' + idx).innerHTML = document.getElementById('addedFiles' + idx).innerHTML;		}		// hide popup

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -