/jssource/src_files/include/javascript/sugar_3.js
JavaScript | 5060 lines | 4047 code | 498 blank | 515 comment | 1317 complexity | 69577f9e441f2729ec6387e2843ecb88 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, MPL-2.0-no-copyleft-exception
Large files files are truncated, but you can click here to view the full file
- /*********************************************************************************
- * SugarCRM Community Edition is a customer relationship management program developed by
- * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
- * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
- * Copyright (C) 2011 - 2014 Salesagility Ltd.
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Affero 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 Affero General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Affero 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 Affero General Public License version 3.
- *
- * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
- * these Appropriate Legal Notices must retain the display of the "Powered by
- * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
- * reasonably feasible for technical reasons, the Appropriate Legal Notices must
- * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
- ********************************************************************************/
- /**
- * Namespace for Sugar Objects
- */
- if (typeof(SUGAR) == "undefined") {
- SUGAR = {
- /**
- * Creates a namespace if it doesn't exist and then returns it.
- *
- * Note: this implementation only creates a top-level namespace. Extend this function if
- * multi-level namespaces are needed.
- * @param ns
- */
- namespace: function(ns) {
- SUGAR[ns] = SUGAR[ns] || {};
- return ((typeof SUGAR[ns] === "object") && (SUGAR[ns] !== null)) ? SUGAR[ns] : false;
- },
- /**
- * Add properties of an object to target object.
- * @param target
- * @param obj
- */
- append: function(target, obj) {
- for (var prop in obj) {
- if (obj[prop] !== void 0) target[prop] = obj[prop];
- }
- return target;
- }
- };
- }
- // Namespaces
- SUGAR.namespace("themes");
- SUGAR.namespace("tour");
- /**
- * Namespace for Homepage
- */
- SUGAR.namespace("sugarHome");
- /**
- * Namespace for Subpanel Utils
- */
- SUGAR.namespace("subpanelUtils");
- /**
- * AJAX status class
- */
- SUGAR.namespace("ajaxStatusClass");
- /**
- * Tab selector utils
- */
- SUGAR.namespace("tabChooser");
- /**
- * General namespace for Sugar utils
- */
- SUGAR.namespace("utils");
- SUGAR.namespace("savedViews");
- /**
- * Dashlet utils
- */
- SUGAR.namespace("dashlets");
- SUGAR.namespace("unifiedSearchAdvanced");
- SUGAR.namespace("searchForm");
- SUGAR.namespace("language");
- SUGAR.namespace("Studio");
- SUGAR.namespace("contextMenu");
- SUGAR.namespace("config");
- var nameIndex = 0;
- var typeIndex = 1;
- var requiredIndex = 2;
- var msgIndex = 3;
- var jstypeIndex = 5;
- var minIndex = 10;
- var maxIndex = 11;
- var altMsgIndex = 15;
- var compareToIndex = 7;
- var arrIndex = 12;
- var operatorIndex = 13;
- var callbackIndex = 16;
- var allowblank = 8;
- var validate = new Array();
- var maxHours = 24;
- var requiredTxt = 'Missing Required Field:';
- var invalidTxt = 'Invalid Value:';
- var secondsSinceLoad = 0;
- var alertsTimeoutId;
- var inputsWithErrors = new Array();
- var tabsWithErrors = new Array();
- var lastSubmitTime = 0;
- var alertList = new Array();
- var oldStartsWith = '';
- /**
- * @deprecated
- *
- * As of Sugar version 6.2.3 (MSIE Version 9) this function is deprecated. The preferred method is to use the
- * user agent check supplied by YUI to check for IE:
- *
- * for checking if a browser is IE in general : if(YAHOO.env.ua.ie) {...}
- *
- * or for checking specific versions: if (YAHOO.env.ua.ie >= 5.5 && YAHOO.env.ua.ie < 9) {...}
- *
- */
- function isSupportedIE() {
- var userAgent = navigator.userAgent.toLowerCase() ;
- // IE Check supports ActiveX controls
- if (userAgent.indexOf("msie") != -1 && userAgent.indexOf("mac") == -1 && userAgent.indexOf("opera") == -1) {
- var version = navigator.appVersion.match(/MSIE (\d+\.\d+)/)[1] ;
- if(version >= 5.5 && version < 10) {
- return true;
- } else {
- return false;
- }
- }
- }
- function checkMinSupported(c, s) {
- var current = c.split(".");
- var supported = s.split(".");
- for (var i in supported) {
- if (current[i] && parseInt(current[i]) > parseInt(supported[i])) return true;
- else if (current[i] && parseInt(current[i]) < parseInt(supported[i])) return false;
- }
- return true;
- }
- function checkMaxSupported(c, s) {
- var current = c.split(".");
- var supported = s.split(".");
- for (var i in supported) {
- if (current[i] && parseInt(current[i]) > parseInt(supported[i])) return false;
- else if (current[i] && parseInt(current[i]) < parseInt(supported[i])) return true;
- }
- return true;
- }
- SUGAR.isSupportedBrowser = function(){
- var supportedBrowsers = {
- msie : {min:9, max:11}, // IE 9, 11
- safari : {min:534}, // Safari 5.1
- mozilla : {min:23.0}, // Firefox 23.0
- chrome : {min:29} // Chrome 29
- };
- var current = String($.browser.version);
- var supported;
- if ($.browser.msie || (!(window.ActiveXObject) && "ActiveXObject" in window)){ // Internet Explorer
- supported = supportedBrowsers['msie'];
- }
- else if ($.browser.mozilla) { // Firefox
- supported = supportedBrowsers['mozilla'];
- }
- else {
- $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
- if($.browser.chrome){ // Chrome
- current = navigator.userAgent.match(/Chrome\/(.*?) /)[1];
- supported = supportedBrowsers['chrome'];
- }
- else if($.browser.safari){ // Safari
- supported = supportedBrowsers['safari'];
- }
- }
- if (current && supported)
- return checkMinSupported(current, String(supported.min)) && (!supported.max || checkMaxSupported(current, String(supported.max)));
- else
- return false;
- }
- SUGAR.isIECompatibilityMode = function(){
- var agentStr = navigator.userAgent;
- var mode = false;
- if (agentStr.indexOf("MSIE 7.0") > -1 &&
- (agentStr.indexOf("Trident/5.0") > -1 || // IE9 Compatibility View
- agentStr.indexOf("Trident/4.0") > -1 // IE8 Compatibility View
- )
- )
- {
- mode = true;
- }
- return mode;
- }
- SUGAR.isIE = isSupportedIE();
- var isSafari = (navigator.userAgent.toLowerCase().indexOf('safari')!=-1);
- // escapes regular expression characters
- RegExp.escape = function(text) { // http://simon.incutio.com/archive/2006/01/20/escape
- if (!arguments.callee.sRE) {
- var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\'];
- arguments.callee.sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
- }
- return text.replace(arguments.callee.sRE, '\\$1');
- }
- function addAlert(type, name,subtitle, description,time, redirect) {
- var addIndex = alertList.length;
- alertList[addIndex]= new Array();
- alertList[addIndex]['name'] = name;
- alertList[addIndex]['type'] = type;
- alertList[addIndex]['subtitle'] = subtitle;
- alertList[addIndex]['description'] = replaceHTMLChars(description.replace(/<br>/gi, "\n"));
- alertList[addIndex]['time'] = time;
- alertList[addIndex]['done'] = 0;
- alertList[addIndex]['redirect'] = redirect;
- }
- function checkAlerts() {
- secondsSinceLoad += 1;
- var mj = 0;
- var alertmsg = '';
- for(mj = 0 ; mj < alertList.length; mj++) {
- if(alertList[mj]['done'] == 0) {
- if(alertList[mj]['time'] < secondsSinceLoad && alertList[mj]['time'] > -1 ) {
- alertmsg = alertList[mj]['type'] + ":" + alertList[mj]['name'] + "\n" +alertList[mj]['subtitle']+ "\n"+ alertList[mj]['description'] + "\n\n";
- alertList[mj]['done'] = 1;
- if(alertList[mj]['redirect'] == '') {
- alert(alertmsg);
- }
- else if(confirm(alertmsg)) {
- window.location = alertList[mj]['redirect'];
- }
- }
- }
- }
- alertsTimeoutId = setTimeout("checkAlerts()", 1000);
- }
- function toggleDisplay(id) {
- if(this.document.getElementById(id).style.display == 'none') {
- this.document.getElementById(id).style.display = '';
- if(this.document.getElementById(id+"link") != undefined) {
- this.document.getElementById(id+"link").style.display = 'none';
- }
- if(this.document.getElementById(id+"_anchor") != undefined)
- this.document.getElementById(id+"_anchor").innerHTML='[ - ]';
- }
- else {
- this.document.getElementById(id).style.display = 'none';
- if(this.document.getElementById(id+"link") != undefined) {
- this.document.getElementById(id+"link").style.display = '';
- }
- if(this.document.getElementById(id+"_anchor") != undefined)
- this.document.getElementById(id+"_anchor").innerHTML='[+]';
- }
- }
- function checkAll(form, field, value) {
- for (i = 0; i < form.elements.length; i++) {
- if(form.elements[i].name == field)
- form.elements[i].checked = value;
- }
- }
- function replaceAll(text, src, rep) {
- offset = text.toLowerCase().indexOf(src.toLowerCase());
- while(offset != -1) {
- text = text.substring(0, offset) + rep + text.substring(offset + src.length ,text.length);
- offset = text.indexOf( src, offset + rep.length + 1);
- }
- return text;
- }
- function addForm(formname) {
- validate[formname] = new Array();
- }
- function addToValidate(formname, name, type, required, msg) {
- if(typeof validate[formname] == 'undefined') {
- addForm(formname);
- }
- validate[formname][validate[formname].length] = new Array(name, type,required, msg);
- }
- // Bug #47961 Callback validator definition
- function addToValidateCallback(formname, name, type, required, msg, callback)
- {
- addToValidate(formname, name, type, required, msg);
- var iIndex = validate[formname].length -1;
- validate[formname][iIndex][jstypeIndex] = 'callback';
- validate[formname][iIndex][callbackIndex] = callback;
- }
- function addToValidateRange(formname, name, type,required, msg,min,max) {
- addToValidate(formname, name, type,required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'range';
- validate[formname][validate[formname].length - 1][minIndex] = min;
- validate[formname][validate[formname].length - 1][maxIndex] = max;
- }
- function addToValidateIsValidDate(formname, name, type, required, msg) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'date';
- }
- function addToValidateIsValidTime(formname, name, type, required, msg) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'time';
- }
- function addToValidateDateBefore(formname, name, type, required, msg, compareTo) {
- addToValidate(formname, name, type,required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'isbefore';
- validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;
- }
- function addToValidateDateBeforeAllowBlank(formname, name, type, required, msg, compareTo, allowBlank) {
- addToValidate(formname, name, type,required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'isbefore';
- validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;
- validate[formname][validate[formname].length - 1][allowblank] = allowBlank;
- }
- function addToValidateBinaryDependency(formname, name, type, required, msg, compareTo) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'binarydep';
- validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;
- }
- function addToValidateComparison(formname, name, type, required, msg, compareTo) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'comparison';
- validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;
- }
- function addToValidateIsInArray(formname, name, type, required, msg, arr, operator) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'in_array';
- validate[formname][validate[formname].length - 1][arrIndex] = arr;
- validate[formname][validate[formname].length - 1][operatorIndex] = operator;
- }
- function addToValidateVerified(formname, name, type, required, msg, arr, operator) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'verified';
- }
- function addToValidateLessThan(formname, name, type, required, msg, max, max_field_msg) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'less';
- validate[formname][validate[formname].length - 1][maxIndex] = max;
- validate[formname][validate[formname].length - 1][altMsgIndex] = max_field_msg;
- }
- function addToValidateMoreThan(formname, name, type, required, msg, min) {
- addToValidate(formname, name, type, required, msg);
- validate[formname][validate[formname].length - 1][jstypeIndex] = 'more';
- validate[formname][validate[formname].length - 1][minIndex] = min;
- }
- function removeFromValidate(formname, name) {
- for(i = 0; i < validate[formname].length; i++)
- {
- if(validate[formname][i][nameIndex] == name)
- {
- validate[formname].splice(i--,1); // We subtract 1 from i since the slice removed an element, and we'll skip over the next item we scan
- }
- }
- }
- function checkValidate(formname, name) {
- if(validate[formname]){
- for(i = 0; i < validate[formname].length; i++){
- if(validate[formname][i][nameIndex] == name){
- return true;
- }
- }
- }
- return false;
- }
- var formsWithFieldLogic=null;
- var formWithPrecision =null;
- function addToValidateFieldLogic(formId,minFieldId, maxFieldId, defaultFieldId, lenFieldId,type,msg){
- this.formId = document.getElementById(formId);
- this.min=document.getElementById(minFieldId);
- this.max= document.getElementById(maxFieldId);
- this._default= document.getElementById(defaultFieldId);
- this.len = document.getElementById(lenFieldId);
- this.msg = msg;
- this.type= type;
- }
- //@params: formid- Dom id of the form containing the precision and float fields
- // valudId- Dom id of the field containing a float whose precision is to be checked.
- // precisionId- Dom id of the field containing precision value.
- function addToValidatePrecision(formId, valueId, precisionId){
- this.form = document.getElementById(formId);
- this.float = document.getElementById(valueId);
- this.precision = document.getElementById(precisionId);
- }
- //function checkLength(value, referenceValue){
- // return value
- //}
- function isValidPrecision(value, precision){
- value = trim(value.toString());
- if(precision == '')
- return true;
- if(value == '')
- return true;
- //#27021
- if( (precision == "0") ){
- if (value.indexOf(dec_sep)== -1){
- return true;
- }else{
- return false;
- }
- }
- //#27021 end
- if(value.charAt(value.length-precision-1) == num_grp_sep){
- if(value.substr(value.indexOf(dec_sep), 1)==dec_sep){
- return false;
- }
- return true;
- }
- var actualPrecision = value.substr(value.indexOf(dec_sep)+1, value.length).length;
- return actualPrecision == precision;
- }
- function toDecimal(original, precision) {
- precision = (precision == null) ? 2 : precision;
- num = Math.pow(10, precision);
- temp = Math.round(original*num)/num;
- if((temp * 100) % 100 == 0)
- return temp + '.00';
- if((temp * 10) % 10 == 0)
- return temp + '0';
- return temp
- }
- function isInteger(s) {
- if(typeof num_grp_sep != 'undefined' && typeof dec_sep != 'undefined')
- {
- s = unformatNumberNoParse(s, num_grp_sep, dec_sep).toString();
- }
- return /^[+-]?[0-9]*$/.test(s) ;
- }
- function isDecimal(s) {
- if (typeof s == "string" && s == "") // bug# 46530, this is required in order to
- return true; // not check empty decimal fields
- if(typeof num_grp_sep != 'undefined' && typeof dec_sep != 'undefined')
- {
- s = unformatNumberNoParse(s, num_grp_sep, dec_sep).toString();
- }
- return /^[+-]?[0-9]*\.?[0-9]*$/.test(s) ;
- }
- function isNumeric(s) {
- return isDecimal(s);
- }
- if (typeof date_reg_positions != "object") var date_reg_positions = {'Y': 1,'m': 2,'d': 3};
- if (typeof date_reg_format != "string") var date_reg_format = '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})';
- function isDate(dtStr) {
- if(dtStr.length== 0) {
- return true;
- }
- // Check that we have numbers
- myregexp = new RegExp(date_reg_format)
- if(!myregexp.test(dtStr))
- return false
- m = '';
- d = '';
- y = '';
- var dateParts = dtStr.match(date_reg_format);
- for(key in date_reg_positions) {
- index = date_reg_positions[key];
- if(key == 'm') {
- m = dateParts[index];
- } else if(key == 'd') {
- d = dateParts[index];
- } else {
- y = dateParts[index];
- }
- }
- // Check that date is real
- var dd = new Date(y,m,0);
- // reject negative years
- if (y < 1)
- return false;
- // reject month less than 1 and greater than 12
- if (m > 12 || m < 1)
- return false;
- // reject days less than 1 or days not in month (e.g. February 30th)
- if (d < 1 || d > dd.getDate())
- return false;
- return true;
- }
- function getDateObject(dtStr) {
- if(dtStr.length== 0) {
- return true;
- }
- myregexp = new RegExp(date_reg_format)
- if(myregexp.exec(dtStr)) var dt = myregexp.exec(dtStr)
- else return false;
- var yr = dt[date_reg_positions['Y']];
- var mh = dt[date_reg_positions['m']];
- var dy = dt[date_reg_positions['d']];
- var dtar = dtStr.split(' ');
- var date1;
- if(typeof(dtar[1])!='undefined' && isTime(dtar[1])) {//if it is a timedate, we should make date1 to have time value
- var t1 = dtar[1].replace(/am/i,' AM');
- var t1 = t1.replace(/pm/i,' PM');
- //bug #37977: where time format 23.00 causes java script error
- t1=t1.replace(/\./, ':');
- date1 = new Date(mh+'/'+dy+'/'+yr+' '+t1);
- }
- else
- {
- date1 = new Date(mh+'/'+dy+'/'+yr);
- }
- if (isNaN(date1.valueOf())) {
- return null;
- }
- return date1;
- }
- function isBefore(value1, value2) {
- var d1 = getDateObject(value1);
- var d2 = getDateObject(value2);
- if(typeof(d2)=='boolean') {// if d2 is not set, we should let it pass, the d2 may not need to be set. the empty check should not be done here.
- return true;
- }
- return d2 >= d1;
- }
- function isValidEmail(emailStr) {
- if(emailStr.length== 0) {
- return true;
- }
- // cn: bug 7128, a period at the end of the string mangles checks. (switched to accept spaces and delimiters)
- var lastChar = emailStr.charAt(emailStr.length - 1);
- if(!lastChar.match(/[^\.]/i)) {
- return false;
- }
- //bug 40068, According to rules in page 6 of http://www.apps.ietf.org/rfc/rfc3696.html#sec-3,
- //first character of local part of an email address
- //should not be a period i.e. '.'
- var firstLocalChar=emailStr.charAt(0);
- if(firstLocalChar.match(/\./)){
- return false;
- }
- //bug 40068, According to rules in page 6 of http://www.apps.ietf.org/rfc/rfc3696.html#sec-3,
- //last character of local part of an email address
- //should not be a period i.e. '.'
- var pos=emailStr.lastIndexOf("@");
- var localPart = emailStr.substr(0, pos);
- var lastLocalChar=localPart.charAt(localPart.length - 1);
- if(lastLocalChar.match(/\./)){
- return false;
- }
- var reg = /@.*?;/g;
- var results;
- while ((results = reg.exec(emailStr)) != null) {
- var original = results[0];
- parsedResult = results[0].replace(';', '::;::');
- emailStr = emailStr.replace (original, parsedResult);
- }
- reg = /.@.*?,/g;
- while ((results = reg.exec(emailStr)) != null) {
- var original = results[0];
- //Check if we were using ; as a delimiter. If so, skip the commas
- if(original.indexOf("::;::") == -1) {
- var parsedResult = results[0].replace(',', '::;::');
- emailStr = emailStr.replace (original, parsedResult);
- }
- }
- // mfh: bug 15010 - more practical implementation of RFC 2822 from http://www.regular-expressions.info/email.html, modifed to accept CAPITAL LETTERS
- //if(!/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/.test(emailStr))
- // return false
- //bug 40068, According to rules in page 6 of http://www.apps.ietf.org/rfc/rfc3696.html#sec-3,
- //allowed special characters ! # $ % & ' * + - / = ? ^ _ ` . { | } ~ in local part
- var emailArr = emailStr.split(/::;::/);
- for (var i = 0; i < emailArr.length; i++) {
- var emailAddress = emailArr[i];
- if (trim(emailAddress) != '') {
- if(!/^\s*[\w.%+\-&'#!\$\*=\?\^_`\{\}~\/]+@([A-Z0-9-]+\.)*[A-Z0-9-]+\.[\w-]{2,}\s*$/i.test(emailAddress) &&
- !/^.*<[A-Z0-9._%+\-&'#!\$\*=\?\^_`\{\}~]+?@([A-Z0-9-]+\.)*[A-Z0-9-]+\.[\w-]{2,}>\s*$/i.test(emailAddress)) {
- return false;
- } // if
- }
- } // for
- return true;
- }
- function isValidPhone(phoneStr) {
- if(phoneStr.length== 0) {
- return true;
- }
- if(!/^[0-9\-\(\)\s]+$/.test(phoneStr))
- return false
- return true
- }
- function isFloat(floatStr) {
- if(floatStr.length== 0) {
- return true;
- }
- if(!(typeof(num_grp_sep)=='undefined' || typeof(dec_sep)=='undefined')) {
- floatStr = unformatNumberNoParse(floatStr, num_grp_sep, dec_sep).toString();
- }
- return /^(-)?[0-9\.]+$/.test(floatStr);
- }
- function isDBName(str) {
- if(str.length== 0) {
- return true;
- }
- // must start with a letter
- if(!/^[a-zA-Z][a-zA-Z\_0-9]*$/.test(str))
- return false
- return true
- }
- var time_reg_format = "[0-9]{1,2}\:[0-9]{2}";
- function isTime(timeStr) {
- var timeRegex = time_reg_format;
- // eliminate the am/pm from the external time_reg_format
- timeRegex = timeRegex.replace(/[ ]*\([^)]*m\)/i, '');
- if(timeStr.length== 0){
- return true;
- }
- //we now support multiple time formats
- myregexp = new RegExp(timeRegex);
- if(!myregexp.test(timeStr)) {
- return false;
- }
- return true;
- }
- function inRange(value, min, max) {
- if (typeof num_grp_sep != 'undefined' && typeof dec_sep != 'undefined')
- value = unformatNumberNoParse(value, num_grp_sep, dec_sep).toString();
- var result = true;
- if (typeof min == 'number' && value < min)
- {
- result = false;
- }
- if (typeof max == 'number' && value > max)
- {
- result = false;
- }
- return result;
- }
- function bothExist(item1, item2) {
- if(typeof item1 == 'undefined') { return false; }
- if(typeof item2 == 'undefined') { return false; }
- if((item1 == '' && item2 != '') || (item1 != '' && item2 == '') ) { return false; }
- return true;
- }
- trim = YAHOO.lang.trim;
- function check_form(formname) {
- if (typeof(siw) != 'undefined' && siw
- && typeof(siw.selectingSomething) != 'undefined' && siw.selectingSomething)
- return false;
- return validate_form(formname, '');
- }
- function add_error_style(formname, input, txt, flash) {
- var raiseFlag = false;
- if (typeof flash == "undefined")
- flash = true;
- try {
- inputHandle = typeof input == "object" ? input : document.forms[formname][input];
- style = get_current_bgcolor(inputHandle);
- // strip off the colon at the end of the warning strings
- if ( txt.substring(txt.length-1) == ':' )
- txt = txt.substring(0,txt.length-1)
- // Bug 28249 - To help avoid duplicate messages for an element, strip off extra messages and
- // match on the field name itself
- requiredTxt = SUGAR.language.get('app_strings', 'ERR_MISSING_REQUIRED_FIELDS');
- invalidTxt = SUGAR.language.get('app_strings', 'ERR_INVALID_VALUE');
- nomatchTxt = SUGAR.language.get('app_strings', 'ERR_SQS_NO_MATCH_FIELD');
- matchTxt = txt.replace(requiredTxt,'').replace(invalidTxt,'').replace(nomatchTxt,'');
- YUI().use('node', function (Y) {
- Y.one(inputHandle).get('parentNode').get('children').each(function(node, index, nodeList){
- if(node.hasClass('validation-message') && node.get('text').search(matchTxt)){
- raiseFlag = true;
- }
- });
- });
- if(!raiseFlag) {
- errorTextNode = document.createElement('div');
- errorTextNode.className = 'required validation-message';
- errorTextNode.innerHTML = txt;
- if ( inputHandle.parentNode.className.indexOf('x-form-field-wrap') != -1 ) {
- inputHandle.parentNode.parentNode.appendChild(errorTextNode);
- }
- else {
- inputHandle.parentNode.appendChild(errorTextNode);
- }
- if (flash)
- inputHandle.style.backgroundColor = "#FF0000";
- inputsWithErrors.push(inputHandle);
- }
- if (flash)
- {
- // We only need to setup the flashy-flashy on the first entry, it loops through all fields automatically
- if ( inputsWithErrors.length == 1 ) {
- for(var wp = 1; wp <= 10; wp++) {
- window.setTimeout('fade_error_style(style, '+wp*10+')',1000+(wp*50));
- }
- }
- if(typeof (window[formname + "_tabs"]) != "undefined") {
- var tabView = window[formname + "_tabs"];
- var parentDiv = YAHOO.util.Dom.getAncestorByTagName(inputHandle, "div");
- if ( tabView.get ) {
- var tabs = tabView.get("tabs");
- for (var i in tabs) {
- if (tabs[i].get("contentEl") == parentDiv
- || YAHOO.util.Dom.isAncestor(tabs[i].get("contentEl"), inputHandle))
- {
- tabs[i].get("labelEl").style.color = "red";
- if ( inputsWithErrors.length == 1 )
- tabView.selectTab(i);
- }
- }
- }
- }
- window.setTimeout("inputsWithErrors[" + (inputsWithErrors.length - 1) + "].style.backgroundColor = '';", 2000);
- }
- } catch ( e ) {
- // Catch errors here so we don't allow an incomplete record through the javascript validation
- }
- }
- /**
- * removes all error messages for the current form
- */
- function clear_all_errors() {
- for(var wp = 0; wp < inputsWithErrors.length; wp++) {
- if(typeof(inputsWithErrors[wp]) !='undefined' && typeof inputsWithErrors[wp].parentNode != 'undefined' && inputsWithErrors[wp].parentNode != null) {
- if ( inputsWithErrors[wp].parentNode.className.indexOf('x-form-field-wrap') != -1 )
- {
- inputsWithErrors[wp].parentNode.parentNode.removeChild(inputsWithErrors[wp].parentNode.parentNode.lastChild);
- }
- else
- {
- inputsWithErrors[wp].parentNode.removeChild(inputsWithErrors[wp].parentNode.lastChild);
- }
- }
- }
- if (inputsWithErrors.length == 0) return;
- if ( YAHOO.util.Dom.getAncestorByTagName(inputsWithErrors[0], "form") ) {
- var formname = YAHOO.util.Dom.getAncestorByTagName(inputsWithErrors[0], "form").getAttribute("name");
- if(typeof (window[formname + "_tabs"]) != "undefined") {
- var tabView = window[formname + "_tabs"];
- if ( tabView.get ) {
- var tabs = tabView.get("tabs");
- for (var i in tabs) {
- if (typeof tabs[i] == "object")
- tabs[i].get("labelEl").style.color = "";
- }
- }
- }
- inputsWithErrors = new Array();
- }
- }
- function get_current_bgcolor(input) {
- if(input.currentStyle) {// ie
- style = input.currentStyle.backgroundColor;
- return style.substring(1,7);
- }
- else {// moz
- style = '';
- styleRGB = document.defaultView.getComputedStyle(input, '').getPropertyValue("background-color");
- comma = styleRGB.indexOf(',');
- style += dec2hex(styleRGB.substring(4, comma));
- commaPrevious = comma;
- comma = styleRGB.indexOf(',', commaPrevious+1);
- style += dec2hex(styleRGB.substring(commaPrevious+2, comma));
- style += dec2hex(styleRGB.substring(comma+2, styleRGB.lastIndexOf(')')));
- return style;
- }
- }
- function hex2dec(hex){return(parseInt(hex,16));}
- var hexDigit=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
- function dec2hex(dec){return(hexDigit[dec>>4]+hexDigit[dec&15]);}
- function fade_error_style(normalStyle, percent) {
- errorStyle = 'f10202';
- var r1 = hex2dec(errorStyle.slice(0,2));
- var g1 = hex2dec(errorStyle.slice(2,4));
- var b1 = hex2dec(errorStyle.slice(4,6));
- var r2 = hex2dec(normalStyle.slice(0,2));
- var g2 = hex2dec(normalStyle.slice(2,4));
- var b2 = hex2dec(normalStyle.slice(4,6));
- var pc = percent / 100;
- r= Math.floor(r1+(pc*(r2-r1)) + .5);
- g= Math.floor(g1+(pc*(g2-g1)) + .5);
- b= Math.floor(b1+(pc*(b2-b1)) + .5);
- for(var wp = 0; wp < inputsWithErrors.length; wp++) {
- inputsWithErrors[wp].style.backgroundColor = "#" + dec2hex(r) + dec2hex(g) + dec2hex(b);
- }
- }
- function isFieldTypeExceptFromEmptyCheck(fieldType)
- {
- var results = false;
- var exemptList = ['bool','file'];
- for(var i=0;i<exemptList.length;i++)
- {
- if(fieldType == exemptList[i])
- return true;
- }
- return results;
- }
- function validate_form(formname, startsWith){
- requiredTxt = SUGAR.language.get('app_strings', 'ERR_MISSING_REQUIRED_FIELDS');
- invalidTxt = SUGAR.language.get('app_strings', 'ERR_INVALID_VALUE');
- if ( typeof (formname) == 'undefined')
- {
- return false;
- }
- if ( typeof (validate[formname]) == 'undefined')
- {
- disableOnUnloadEditView(document.forms[formname]);
- return true;
- }
- var form = document.forms[formname];
- var isError = false;
- var errorMsg = "";
- var _date = new Date();
- if(_date.getTime() < (lastSubmitTime + 2000) && startsWith == oldStartsWith) { // ignore submits for the next 2 seconds
- return false;
- }
- lastSubmitTime = _date.getTime();
- oldStartsWith = startsWith;
- clear_all_errors(); // remove previous error messages
- inputsWithErrors = new Array();
- for(var i = 0; i < validate[formname].length; i++){
- if(validate[formname][i][nameIndex].indexOf(startsWith) == 0){
- if(typeof form[validate[formname][i][nameIndex]] != 'undefined' && typeof form[validate[formname][i][nameIndex]].value != 'undefined'){
- var bail = false;
- //If a field is not required and it is blank or is binarydependant, skip validation.
- //Example of binary dependant fields would be the hour/min/meridian dropdowns in a date time combo widget, which require further processing than a blank check
- if(!validate[formname][i][requiredIndex] && trim(form[validate[formname][i][nameIndex]].value) == '' && (typeof(validate[formname][i][jstypeIndex]) != 'undefined' && validate[formname][i][jstypeIndex] != 'binarydep'))
- {
- continue;
- }
- if(validate[formname][i][requiredIndex]
- && !isFieldTypeExceptFromEmptyCheck(validate[formname][i][typeIndex])
- ){
- if(typeof form[validate[formname][i][nameIndex]] == 'undefined' || trim(form[validate[formname][i][nameIndex]].value) == ""){
- add_error_style(formname, validate[formname][i][nameIndex], requiredTxt +' ' + validate[formname][i][msgIndex]);
- isError = true;
- }
- }
- if(!bail){
- switch(validate[formname][i][typeIndex]){
- case 'email':
- if(!isValidEmail(trim(form[validate[formname][i][nameIndex]].value))){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- }
- break;
- case 'time':
- if( !isTime(trim(form[validate[formname][i][nameIndex]].value))){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- } break;
- case 'date': if(!isDate(trim(form[validate[formname][i][nameIndex]].value))){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- } break;
- case 'alpha':
- break;
- case 'DBName':
- if(!isDBName(trim(form[validate[formname][i][nameIndex]].value))){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- }
- break;
- // Bug #49614 : Check value without trimming before
- case 'DBNameRaw':
- if(!isDBName(form[validate[formname][i][nameIndex]].value)){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- }
- break;
- case 'alphanumeric':
- break;
- case 'file':
- var file_input = form[validate[formname][i][nameIndex] + '_file'];
- if( file_input && validate[formname][i][requiredIndex] && trim(file_input.value) == "" && !file_input.disabled ) {
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], requiredTxt + " " + validate[formname][i][msgIndex]);
- }
- break;
- case 'int':
- if(!isInteger(trim(form[validate[formname][i][nameIndex]].value))){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- }
- break;
- case 'decimal':
- if(!isDecimal(trim(form[validate[formname][i][nameIndex]].value))){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- }
- break;
- case 'currency':
- case 'float':
- if(!isFloat(trim(form[validate[formname][i][nameIndex]].value))){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- }
- break;
- case 'teamset_mass':
- var div_element_id = formname + '_' + form[validate[formname][i][nameIndex]].name + '_operation_div';
- var input_elements = YAHOO.util.Selector.query('input', document.getElementById(div_element_id));
- var primary_field_id = '';
- var validation_passed = false;
- var replace_selected = false;
- //Loop through the option elements (replace or add currently)
- for(t in input_elements) {
- if(input_elements[t].type && input_elements[t].type == 'radio' && input_elements[t].checked == true && input_elements[t].value == 'replace') {
- //Now find where the primary radio button is and if a value has been set
- var radio_elements = YAHOO.util.Selector.query('input[type=radio]', document.getElementById(formname + '_team_name_table'));
- for(var x = 0; x < radio_elements.length; x++) {
- if(radio_elements[x].name != 'team_name_type') {
- primary_field_id = 'team_name_collection_' + radio_elements[x].value;
- if(radio_elements[x].checked) {
- replace_selected = true;
- if(trim(document.forms[formname].elements[primary_field_id].value) != '') {
- validation_passed = true;
- break;
- }
- } else if(trim(document.forms[formname].elements[primary_field_id].value) != '') {
- replace_selected = true;
- }
- }
- }
- }
- }
- if(replace_selected && !validation_passed) {
- add_error_style(formname, primary_field_id, SUGAR.language.get('app_strings', 'ERR_NO_PRIMARY_TEAM_SPECIFIED'));
- isError = true;
- }
- break;
- case 'teamset':
- var table_element_id = formname + '_' + form[validate[formname][i][nameIndex]].name + '_table';
- if(document.getElementById(table_element_id)) {
- var input_elements = YAHOO.util.Selector.query('input[type=radio]', document.getElementById(table_element_id));
- var has_primary = false;
- var primary_field_id = form[validate[formname][i][nameIndex]].name + '_collection_0';
- for(t in input_elements) {
- primary_field_id = form[validate[formname][i][nameIndex]].name + '_collection_' + input_elements[t].value;
- if(input_elements[t].type && input_elements[t].type == 'radio' && input_elements[t].checked == true) {
- if(document.forms[formname].elements[primary_field_id].value != '') {
- has_primary = true;
- }
- break;
- }
- }
- if(!has_primary) {
- isError = true;
- var field_id = form[validate[formname][i][nameIndex]].name + '_collection_' + input_elements[0].value;
- add_error_style(formname, field_id, SUGAR.language.get('app_strings', 'ERR_NO_PRIMARY_TEAM_SPECIFIED'));
- }
- }
- break;
- case 'error':
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex]);
- break;
- }
- if(typeof validate[formname][i][jstypeIndex] != 'undefined'/* && !isError*/){
- switch(validate[formname][i][jstypeIndex]){
- // Bug #47961 May be validation through callback is best way.
- case 'callback' :
- if (typeof validate[formname][i][callbackIndex] == 'function')
- {
- var result = validate[formname][i][callbackIndex](formname, validate[formname][i][nameIndex]);
- if (result == false)
- {
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], requiredTxt + " " + validate[formname][i][msgIndex]);
- }
- }
- break;
- case 'range':
- if(!inRange(trim(form[validate[formname][i][nameIndex]].value), validate[formname][i][minIndex], validate[formname][i][maxIndex])){
- isError = true;
- var lbl_validate_range = SUGAR.language.get('app_strings', 'LBL_VALIDATE_RANGE');
- if (typeof validate[formname][i][minIndex] == 'number' && typeof validate[formname][i][maxIndex] == 'number')
- {
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex] + " value " + form[validate[formname][i][nameIndex]].value + " " + lbl_validate_range + " (" +validate[formname][i][minIndex] + " - " + validate[formname][i][maxIndex] + ")");
- }
- else if (typeof validate[formname][i][minIndex] == 'number')
- {
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex] + " " + SUGAR.language.get('app_strings', 'MSG_SHOULD_BE') + ' ' + validate[formname][i][minIndex] + ' ' + SUGAR.language.get('app_strings', 'MSG_OR_GREATER'));
- }
- else if (typeof validate[formname][i][maxIndex] == 'number')
- {
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex] + " " + SUGAR.language.get('app_strings', 'MSG_IS_MORE_THAN') + ' ' + validate[formname][i][maxIndex]);
- }
- }
- break;
- case 'isbefore':
- compareTo = form[validate[formname][i][compareToIndex]];
- if( typeof compareTo != 'undefined'){
- if(trim(compareTo.value) != '' || (validate[formname][i][allowblank] != 'true') ) {
- date2 = trim(compareTo.value);
- date1 = trim(form[validate[formname][i][nameIndex]].value);
- if(trim(date1).length != 0 && !isBefore(date1,date2)){
- isError = true;
- //jc:#12287 - adding translation for the is not before message
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex] + "(" + date1 + ") " + SUGAR.language.get('app_strings', 'MSG_IS_NOT_BEFORE') + ' ' +date2);
- }
- }
- }
- break;
- case 'less':
- value=unformatNumber(trim(form[validate[formname][i][nameIndex]].value), num_grp_sep, dec_sep);
- maximum = parseFloat(validate[formname][i][maxIndex]);
- if( typeof maximum != 'undefined'){
- if(value>maximum) {
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex] +" " +SUGAR.language.get('app_strings', 'MSG_IS_MORE_THAN')+ ' ' + validate[formname][i][altMsgIndex]);
- }
- }
- break;
- case 'more':
- value=unformatNumber(trim(form[validate[formname][i][nameIndex]].value), num_grp_sep, dec_sep);
- minimum = parseFloat(validate[formname][i][minIndex]);
- if( typeof minimum != 'undefined'){
- if(value<minimum) {
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex] +" " +SUGAR.language.get('app_strings', 'MSG_SHOULD_BE')+ ' ' + minimum + ' ' + SUGAR.language.get('app_strings', 'MSG_OR_GREATER'));
- }
- }
- break;
- case 'binarydep':
- compareTo = form[validate[formname][i][compareToIndex]];
- if( typeof compareTo != 'undefined') {
- item1 = trim(form[validate[formname][i][nameIndex]].value);
- item2 = trim(compareTo.value);
- if(!bothExist(item1, item2)) {
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex]);
- }
- }
- break;
- case 'comparison':
- compareTo = form[validate[formname][i][compareToIndex]];
- if( typeof compareTo != 'undefined') {
- item1 = trim(form[validate[formname][i][nameIndex]].value);
- item2 = trim(compareTo.value);
- if(!bothExist(item1, item2) || item1 != item2) {
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], validate[formname][i][msgIndex]);
- }
- }
- break;
- case 'in_array':
- arr = eval(validate[formname][i][arrIndex]);
- operator = validate[formname][i][operatorIndex];
- item1 = trim(form[validate[formname][i][nameIndex]].value);
- if (operator.charAt(0) == 'u') {
- item1 = item1.toUpperCase();
- operator = operator.substring(1);
- } else if (operator.charAt(0) == 'l') {
- item1 = item1.toLowerCase();
- operator = operator.substring(1);
- }
- for(j = 0; j < arr.length; j++){
- val = arr[j];
- if((operator == "==" && val == item1) || (operator == "!=" && val != item1)){
- isError = true;
- add_error_style(formname, validate[formname][i][nameIndex], invalidTxt + " " + validate[formname][i][msgIndex]);
- }
- }
- break;
- case 'verified':
- if(trim(form[validate[formname][i][nameIndex]].value) == 'false'){
- //Fake an error so form does not submit
- isError = true;
- }
- break;
- }
- }
- }
- }
- }
- }
- /* nsingh: BUG#15102
- Check min max default field logic.
- Can work with float values as well, but as of 10/8/07 decimal values in MB and studio don't have min and max value constraints.*/
- if(formsWithFieldLogic){
- var invalidLogic=false;
- if(formsWithFieldLogic.min && formsWithFieldLogic.max && formsWithFieldLogic._default) {
- var showErrorsOn={min:{value:'min', show:false, obj:formsWithFieldLogic.min.value},
- max:{value:'max',show:false, obj:formsWithFieldLogic.max.value},
- _default:{value:'default',show:false, obj:formsWithFieldLogic._default.value},
- len:{value:'len', show:false, obj:parseInt(formsWithFieldLogic.len.value,10)}};
- var min = (formsWithFieldLogic.min.value !='') ? parseFloat(formsWithFieldLogic.min.value) : 'undef';
- var max = (formsWithFieldLogic.max.value !='') ? parseFloat(formsWithFieldLogic.max.value) : 'undef';
- var _default = (formsWithFieldLogic._default.value!='')? parseFloat(formsWithFieldLogic._default.value) : 'undef';
- /*Check all lengths are <= max size.*/
- for(var i in showErrorsOn){
- if(showErrorsOn[i].value!='len' && showErrorsOn[i].obj.length > showErrorsOn.len.obj){
- invalidLogic=true;
- showErrorsOn[i].show=true;
- showErrorsOn.len.show=true;
- }
- }
- if(min!='undef' && max!='undef' && _default!='undef'){
- if(!inRange(_default,min,max)){
- invalidLogic=true;
- showErrorsOn.min.show=true;
- showErrorsOn.max.show=true;
- showErrorsOn._default.show=true;
- }
- }
- if(min!='undef' && max!= 'undef' && min > max){
- invalidLogic = true;
- showErrorsOn.min.show=true;
- showErrorsOn.max.show=true;
- }
- if(min!='undef' && _default!='undef' && _default < min){
- invalidLogic = true;
- showErrorsOn.min.show=true;
- showErrorsOn._default.show=true;
- }
- if(max!='undef' && _default !='undef' && _default>max){
- invalidLogic = true;
- showErrorsOn.max.show=true;
- showErrorsOn._default.show=true;
- }
- if(invalidLogic){
- isError=true;
- for(var error in showErrorsOn)
- if(showErrorsOn[error].show)
- add_error_style(formname,showErrorsOn[error].value, formsWithFieldLogic.msg);
- }
- else if (!isError)
- formsWithFieldLogic = null;
- }
- }
- if(formWithPrecision){
- if (!isValidPrecision(formWithPrecision.float.value, formWithPrecision.precision.value)){
- isError = true;
- add_error_style(formname, 'default', SUGAR.language.get('app_strings', 'ERR_COMPATIBLE_PRECISION_VALUE'));
- }else if(!isError){
- isError = false;
- }
- }
- //END BUG# 15102
- if (isError == true) {
- var nw, ne, sw, se;
- if (self.pageYOffset) // all except Explorer
- {
- nwX = self.pageXOffset;
- seX = self.innerWidth;
- nwY = self.pageYOffset;
- seY = self.innerHeight;
- }
- else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
- {
- nwX = document.documentElement.scrollLeft;
- seX = document.documentElement.clientWidth;
- nwY = document.documentElement.scrollTop;
- seY = document.documentElement.clientHeight;
- }
- else if (document.body) // all other Explorers
- {
- nwX = document.body.scrollLeft;
- seX = document.body.clientWidth;
- nwY = document.body.scrollTop;
- seY = document.body.clientHeight;
- }
- var inView = true; // is there an error within viewport of browser
- for(var wp = 0; wp < inputsWithErrors.length; wp++) {
- var elementCoor = findElementPos(inputsWithErrors[wp]);
- if(!(elementCoor.x >= nwX && elementCoor.y >= nwY &&
- elementCoor.x <= seX+nwX && elementCoor.y <= seY+nwY)) { // if input is not within viewport, modify for SI bug 52497
- inView = false;
- scrollToTop = elementCoor.y - 75;
- scrollToLeft = elementCoor.x - 75;
- }
- else { // on first input within viewport, don't scroll
- break;
- }
- }
- if(!inView) window.scrollTo(scrollToLeft,scrollToTop);
- return false;
- }
- disableOnUnloadEditView(form);
- return true;
- }
- /**
- * This array is used to remember mark status of rows in browse mode
- */
- var marked_row = new Array;
- /**
- * Sets/unsets the pointer and marker in browse mode
- *
- * @param object the table row
- * @param interger the row number
- * @param string the action calling this script (over, out or click)
- * @param string the default background color
- * @param string the color to use for mouseover
- * @param string the color to use for marking a row
- *
- * @return boolean whether pointer is set or not
- */
- function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) {
- var theCells = null;
- // 1. Pointer and mark feature are disabled or the browser can't get the
- // row -> exits
- if ((thePointerColor == '' && theMarkColor == '')
- || typeof(theRow.style) == 'undefined') {
- return false;
- }
- // 2. Gets the current row and exits if the browser can't get it
- if (typeof(document.getElementsByTagName) != 'undefined') {
- theCells = theRow.getElementsByTagName('td');
- }
- else if (typeof(theRow.cells) != 'undefined') {
- theCells = theRow.cells;
- }
- else {
- return false;
- }
- // 3. Gets the current color...
- var rowCellsCnt = theCells.length;
- var domDetect = null;
- var currentColor = null;
- var newColor = nu…
Large files files are truncated, but you can click here to view the full file