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

📄 sugar_3.js

📁 SugarCRM5.1 开源PHP客户关系管理系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
					case 6: date = date.substring(0,2) + sep + date.substring(2, 4) + sep + '20' + date.substring(4,6); break;					case 8: date = date.substring(0,2) + sep + date.substring(2, 4) + sep + date.substring(4,8); break;				}				break;		}	}	date = date.replace(/[\/-]/g, sep);	input.value = date;}// find obj's positionfunction findElementPos(obj) {    var x = 0;    var y = 0;    if (obj.offsetParent) {      while (obj.offsetParent) {        x += obj.offsetLeft;        y += obj.offsetTop;        obj = obj.offsetParent;      }    }//if offsetParent exists    else if (obj.x && obj.y) {      y += obj.y      x += obj.x    }	return new coordinate(x, y);}//findElementPos// get dimensions of the browser windowfunction getClientDim() {	var nwX, nwY, seX, seY;	if (self.pageYOffset) // all except Explorer	{	  nwX = self.pageXOffset;	  seX = self.innerWidth + nwX;	  nwY = self.pageYOffset;	  seY = self.innerHeight + nwY;	}	else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict	{	  nwX = document.documentElement.scrollLeft;	  seX = document.documentElement.clientWidth + nwX;	  nwY = document.documentElement.scrollTop;	  seY = document.documentElement.clientHeight + nwY;	}	else if (document.body) // all other Explorers	{	  nwX = document.body.scrollLeft;	  seX = document.body.clientWidth + nwX;	  nwY = document.body.scrollTop;	  seY = document.body.clientHeight + nwY;	}	return {'nw' : new coordinate(nwX, nwY), 'se' : new coordinate(seX, seY)};}/*** stop propagation on events**/function freezeEvent(e) {	if(e) {	  if (e.preventDefault) e.preventDefault();	  e.returnValue = false;	  e.cancelBubble = true;	  if (e.stopPropagation) e.stopPropagation();	  return false;	}}/** * coordinate class **/function coordinate(_x, _y) {  var x = _x;  var y = _y;  this.add = add;  this.sub = sub;  this.x = x;  this.y = y;  function add(rh) {    return new position(this.x + rh.x, this.y + rh.y);  }  function sub(rh) {    return new position(this.x + rh.x, this.y + rh.y);  }}// sends theForm via AJAX and fills in the theDivfunction sendAndRetrieve(theForm, theDiv, loadingStr) {	function success(data) {		document.getElementById(theDiv).innerHTML = data.responseText;		ajaxStatus.hideStatus();	}	if(typeof loadingStr == 'undefined') SUGAR.language.get('app_strings', 'LBL_LOADING');	ajaxStatus.showStatus(loadingStr);	YAHOO.util.Connect.setForm(theForm);	var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', {success: success, failure: success});	return false;}//save the form and redirectfunction sendAndRedirect(theForm, loadingStr, redirect_location) {	function success(data) {		if(redirect_location){			location.href=redirect_location;		}		ajaxStatus.hideStatus();	}	if(typeof loadingStr == 'undefined') SUGAR.language.get('app_strings', 'LBL_LOADING');	ajaxStatus.showStatus(loadingStr);	YAHOO.util.Connect.setForm(theForm);	var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', {success: success, failure: success});	return false;}function saveForm(theForm, theDiv, loadingStr) {	if(check_form(theForm)){		for(i = 0; i < ajaxFormArray.length; i++){			if(ajaxFormArray[i] == theForm){				ajaxFormArray.splice(i, 1);			}		}		return sendAndRetrieve(theForm, theDiv, loadingStr);	}	else		return false;}/** save some forms using an ajax call* theForms - the ids of all of theh forms to save* savingStr - the string to display when saving the form* completeStr - the string to display when the form has been saved*/function saveForms( savingStr, completeStr) {	index = 0;	theForms = ajaxFormArray;	function success(data) {		var theForm = document.getElementById(ajaxFormArray[0]);		document.getElementById('multiedit_'+theForm.id).innerHTML = data.responseText;		var saveAllButton = document.getElementById('ajaxsaveall');		ajaxFormArray.splice(index, 1);		if(saveAllButton && ajaxFormArray.length <= 1){    		saveAllButton.style.visibility = 'hidden';    	}		index++;		if(index == theForms.length){			ajaxStatus.showStatus(completeStr);    		window.setTimeout('ajaxStatus.hideStatus();', 2000);    		if(saveAllButton)    			saveAllButton.style.visibility = 'hidden';    	}	}	if(typeof savingStr == 'undefined') SUGAR.language.get('app_strings', 'LBL_LOADING');	ajaxStatus.showStatus(savingStr);	//loop through the forms saving each one	for(i = 0; i < theForms.length; i++){		var theForm = document.getElementById(theForms[i]);		if(check_form(theForm.id)){			theForm.action.value='AjaxFormSave';			YAHOO.util.Connect.setForm(theForm);			var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', {success: success, failure: success});		}else{			ajaxStatus.hideStatus();		}		lastSubmitTime = lastSubmitTime-2000;	}	return false;}// -- start sugarListView class// js functions used for ListViewfunction sugarListView() {}sugarListView.prototype.confirm_action = function(del) {	if (del == 1) {		return confirm( SUGAR.language.get('app_strings', 'NTC_DELETE_CONFIRMATION_NUM') + sugarListView.get_num_selected()  + SUGAR.language.get('app_strings', 'NTC_DELETE_SELECTED_RECORDS'));	}	else {		return confirm( SUGAR.language.get('app_strings', 'NTC_UPDATE_CONFIRMATION_NUM') + sugarListView.get_num_selected()  + SUGAR.language.get('app_strings', 'NTC_DELETE_SELECTED_RECORDS'));	}}sugarListView.get_num_selected = function () {	if(typeof document.MassUpdate != 'undefined') {		the_form = document.MassUpdate;		for(wp = 0; wp < the_form.elements.length; wp++) {			if(typeof the_form.elements[wp].name != 'undefined' && the_form.elements[wp].name == 'selectCount[]') {				return the_form.elements[wp].value;			}		}	}	return 0;}sugarListView.update_count = function(count, add) {	if(typeof document.MassUpdate != 'undefined') {		the_form = document.MassUpdate;		for(wp = 0; wp < the_form.elements.length; wp++) {			if(typeof the_form.elements[wp].name != 'undefined' && the_form.elements[wp].name == 'selectCount[]') {				if(add)	{					the_form.elements[wp].value = parseInt(the_form.elements[wp].value) + count;				}				else the_form.elements[wp].value = count;			}		}	}}sugarListView.prototype.send_form = function(select, currentModule, action, no_record_txt,action_module,return_info) {	if (document.MassUpdate.select_entire_list.value == 1) {		var href = action + '&module=' + currentModule;		if (return_info)			href += return_info;		document.location.href = href;		return;	}	else if (document.MassUpdate.massall.checked == true)		select = false;	else		select = true;	sugarListView.get_checks();	// create new form to post (can't access action property of MassUpdate form due to action input)	var newForm = document.createElement('form');	newForm.method = 'post';	newForm.action = action;	newForm.name = 'newForm';	newForm.id = 'newForm';	var uidTa = document.createElement('textarea');	uidTa.name = 'uid';	uidTa.style.display = 'none';	if(select) { // use selected items		uidTa.value = document.MassUpdate.uid.value;	}	else { // use current page		inputs = document.MassUpdate.elements;		ar = new Array();		for(i = 0; i < inputs.length; i++) {			if(inputs[i].name == 'mass[]' && inputs[i].checked)				ar.push(inputs[i].value);		}		uidTa.value = ar.join(',');	}	if(uidTa.value == '') {		alert(no_record_txt);		return false;	}	newForm.appendChild(uidTa);	var moduleInput = document.createElement('input');	moduleInput.name = 'module';	moduleInput.type = 'hidden';	moduleInput.value = currentModule;	newForm.appendChild(moduleInput);	var actionInput = document.createElement('input');	actionInput.name = 'action';	actionInput.type = 'hidden';	actionInput.value = 'index';	newForm.appendChild(actionInput);	if (typeof action_module != 'undefined' && action_module!= '') {		var actionModule = document.createElement('input');		actionModule.name = 'action_module';		actionModule.type = 'hidden';		actionModule.value = action_module;		newForm.appendChild(actionModule);	}	//return_info must follow this pattern."&return_module=Accounts&return_action=index"	if (typeof return_info!= 'undefined' && return_info != '') {		var params= return_info.split('&');		if (params.length > 0) {			for (var i=0;i< params.length;i++) {				if (params[i].length > 0) {					var param_nv=params[i].split('=');					if (param_nv.length==2){						returnModule = document.createElement('input');						returnModule.name = param_nv[0];						returnModule.type = 'hidden';						returnModule.value = param_nv[1];						newForm.appendChild(returnModule);					}				}			}		}	}	document.MassUpdate.parentNode.appendChild(newForm);	newForm.submit();	// awu Bug 18624: Fixing issue where a canceled Export and unselect of row will persist the uid field, clear the field	document.MassUpdate.uid.value = '';	return false;}//return a count of checked row.sugarListView.get_checks_count = function() {	ar = new Array();	// build associated array of uids, associated array ensures uniqueness	inputs = document.MassUpdate.elements;	for(i = 0; i < inputs.length; i++) {		if(inputs[i].name == 'mass[]')			ar[inputs[i].value]	= (inputs[i].checked) ? 1 : 0; // 0 of it is unchecked	}	// build regular array of uids	uids = new Array();	for(i in ar) {		if(ar[i] == 1) uids.push(i);	}	return uids.length;}// saves the checks on the current page into the uid textareasugarListView.get_checks = function() {	ar = new Array();	if(document.MassUpdate.uid.value != '') {		oldUids = document.MassUpdate.uid.value.split(',');		for(uid in oldUids) ar[oldUids[uid]] = 1;	}	// build associated array of uids, associated array ensures uniqueness	inputs = document.MassUpdate.elements;	for(i = 0; i < inputs.length; i++) {		if(inputs[i].name == 'mass[]')			ar[inputs[i].value]	= (inputs[i].checked) ? 1 : 0; // 0 of it is unchecked	}	// build regular array of uids	uids = new Array();	for(i in ar) {		if(ar[i] == 1) uids.push(i);	}	document.MassUpdate.uid.value = uids.join(',');	if(uids.length == 0) return false; // return false if no checks to get	return true; // there are saved checks}sugarListView.prototype.save_checks = function(offset, moduleString) {	checks = sugarListView.get_checks();	eval('document.MassUpdate.' + moduleString + '.value = offset');	if(typeof document.MassUpdate.massupdate != 'undefined') document.MassUpdate.massupdate.value = 'false';	if(checks) document.MassUpdate.submit();	return !checks;}sugarListView.prototype.check_item = function(cb, form) {	if(cb.checked) sugarListView.update_count(1, true);	else sugarListView.update_count(-1, true);}sugarListView.prototype.check_entire_list = function(form, field, value, list_count) {	// count number of items	count = 0;	document.MassUpdate.massall.checked = true;	document.MassUpdate.massall.disabled = true;	for (i = 0; i < form.elements.length; i++) {		if(form.elements[i].name == field) {			if(form.elements[i].checked != value) count++;				form.elements[i].checked = value;				form.elements[i].disabled = true;		}	}	document.MassUpdate.select_entire_list.value = 1;	//if(value)	sugarListView.update_count(list_count, false);	//else sugarListView.update_count(-1 * count, true);}sugarListView.prototype.check_all = function(form, field, value, pageTotal) {	// count number of items	count = 0;	document.MassUpdate.massall.checked = value;	if (document.MassUpdate.select_entire_list &&		document.MassUpdate.select_entire_list.value == 1)		document.MassUpdate.massall.disabled = true;	else		document.MassUpdate.massall.disabled = false;	for (i = 0; i < form.elements.length; i++) {		if(form.elements[i].name == field) {			form.elements[i].disabled = false;			if(form.elements[i].checked != value)				count++;			form.elements[i].checked = value;		}

⌨️ 快捷键说明

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