Merge pull request #323 from victorsl/BUG-8489

BUG 8489 "Los aplicados a los elementos de las grillas no..." SOLVED
This commit is contained in:
julceslauhub
2012-07-18 14:34:23 -07:00
2 changed files with 197 additions and 167 deletions

View File

@@ -914,9 +914,9 @@ function G_Text( form, element, name)
if (me.mType == 'text' && me.validate == 'Real') { if (me.mType == 'text' && me.validate == 'Real') {
dir = 'reverse'; dir = 'reverse';
} else { } else {
dir = 'forward'; dir = 'forward';
} }
break; break;
} }
return G.ApplyMask(value, mask, cursor, dir, comma); return G.ApplyMask(value, mask, cursor, dir, comma);
@@ -1028,7 +1028,7 @@ function G_Text( form, element, name)
} }
if (newCursor < 0) newCursor = 0; if (newCursor < 0) newCursor = 0;
if (keyCode != 8 && keyCode != 46 && keyCode != 35 && keyCode != 36 && keyCode != 37 && keyCode != 39){ if (keyCode != 8 && keyCode != 46 && keyCode != 35 && keyCode != 36 && keyCode != 37 && keyCode != 39){
testData = dataWOMask.result; testData = dataWOMask.result;
tamData = testData.length; tamData = testData.length;
cleanMask = me.getCleanMask(); cleanMask = me.getCleanMask();
tamMask = cleanMask.length; tamMask = cleanMask.length;
@@ -1046,7 +1046,7 @@ function G_Text( form, element, name)
} }
} }
switch(action){ switch(action){
case 'mask': case 'move': case 'mask': case 'move':
dataNewMask = me.replaceMasks(newValue, newCursor); dataNewMask = me.replaceMasks(newValue, newCursor);
@@ -1131,11 +1131,11 @@ function G_Text( form, element, name)
if (me.validate == 'Any' && me.mask == '') return true; if (me.validate == 'Any' && me.mask == '') return true;
//pressKey = event.keyCode; //pressKey = event.keyCode;
pressKey = window.event ? window.event.keyCode : event.which; pressKey = window.event ? window.event.keyCode : event.which;
switch(pressKey){ switch(pressKey){
case 8: case 46: //BACKSPACE OR DELETE case 8: case 46: //BACKSPACE OR DELETE
case 35: case 36: //HOME OR END case 35: case 36: //HOME OR END
case 37: case 38: case 39: case 40: // ARROW KEYS case 37: case 38: case 39: case 40: // ARROW KEYS
if (me.validate == 'NodeName' && ((pressKey == 8) || (pressKey == 46))) { if (me.validate == 'NodeName' && ((pressKey == 8) || (pressKey == 46))) {
return true; return true;
} }
@@ -1279,7 +1279,7 @@ function G_Text( form, element, name)
lang :(typeof(me.language)!=='undefined')? me.language:"en" lang :(typeof(me.language)!=='undefined')? me.language:"en"
}); });
keyValid = k.result(); keyValid = k.result();
} }
break; break;
default: default:
var k = new leimnud.module.validator({ var k = new leimnud.module.validator({
@@ -1323,9 +1323,9 @@ function G_Text( form, element, name)
var evt = event || window.event; var evt = event || window.event;
var keyPressed = evt.which || evt.keyCode; var keyPressed = evt.which || evt.keyCode;
//me.putFormatNumber(keyPressed); //me.putFormatNumber(keyPressed);
if ( (me.mask != '') && ( (me.mType == 'currency') || (me.mType == 'percentage') || if ( (me.mask != '') && ( (me.mType == 'currency') || (me.mType == 'percentage') ||
((me.validate == "Real") && (me.mType == 'text')) ) && ((me.validate == "Real") && (me.mType == 'text')) ) &&
(me.mask.indexOf('-')==-1) && (me.element.value != '') ) { (me.mask.indexOf('-')==-1) && (me.element.value != '') ) {
var separatorField = ","; var separatorField = ",";
@@ -1359,7 +1359,7 @@ function G_Text( form, element, name)
var decimalString = ''; var decimalString = '';
var pluginDecimal = ''; var pluginDecimal = '';
var numberSet = me.element.value.split(separatorField); var numberSet = me.element.value.split(separatorField);
if (typeof(numberSet[1]) == 'undefined') { if (typeof(numberSet[1]) == 'undefined') {
var decimalSet = ''; var decimalSet = '';
var newInt = ''; var newInt = '';
@@ -1391,7 +1391,7 @@ function G_Text( form, element, name)
if(countDecimalNow < countDecimal) { if(countDecimalNow < countDecimal) {
for(; countDecimalNow < countDecimal; countDecimalNow++) { for(; countDecimalNow < countDecimal; countDecimalNow++) {
decimalString += '0'; decimalString += '0';
} }
me.element.value = numberSet[0] + separatorField + decimalString + pluginDecimal; me.element.value = numberSet[0] + separatorField + decimalString + pluginDecimal;
} }
} }
@@ -1427,7 +1427,7 @@ function G_Text( form, element, name)
this.element.value = this.element.value.toLowerCase(); this.element.value = this.element.value.toLowerCase();
break; break;
} }
} }
}.extend(this); }.extend(this);
} }
@@ -3437,37 +3437,37 @@ function hideRowsById(aFields){
function dateSetMask(mask) { function dateSetMask(mask) {
if (mask != '') { if (mask != '') {
mask = stringReplace("%y", "yy", mask); mask = strReplace("%y", "yy", mask);
mask = stringReplace("%Y", "yyyy", mask); mask = strReplace("%Y", "yyyy", mask);
mask = stringReplace("%m", "mm", mask); mask = strReplace("%m", "mm", mask);
mask = stringReplace("%o", "mm", mask); mask = strReplace("%o", "mm", mask);
mask = stringReplace("%d", "dd", mask); mask = strReplace("%d", "dd", mask);
mask = stringReplace("%e", "dd", mask); mask = strReplace("%e", "dd", mask);
//In the function getCleanMask valid characters for an mask that does not //In the function getCleanMask valid characters for an mask that does not
//is currency/percentage are: '0 ',' # ',' d ',' m ',' y ',' Y '. //is currency/percentage are: '0 ',' # ',' d ',' m ',' y ',' Y '.
//For hours, minutes and seconds replace this mask with '#' //For hours, minutes and seconds replace this mask with '#'
mask = stringReplace("%H", "##", mask); mask = strReplace("%H", "##", mask);
mask = stringReplace("%I", "##", mask); mask = strReplace("%I", "##", mask);
mask = stringReplace("%k", "##", mask); mask = strReplace("%k", "##", mask);
mask = stringReplace("%l", "##", mask); mask = strReplace("%l", "##", mask);
mask = stringReplace("%M", "##", mask); mask = strReplace("%M", "##", mask);
mask = stringReplace("%S", "##", mask); mask = strReplace("%S", "##", mask);
mask = stringReplace("%j", "###", mask); mask = strReplace("%j", "###", mask);
} }
return mask; return mask;
} }
function stringReplace(strSearch, strReplace, str) { function strReplace(strs, strr, str)
var expression = eval("/" + strSearch + "/g"); {
var expresion = eval("/" + strs + "/g");
return str.replace(expression, strReplace); return str.replace(expresion, strr);
} }
/* end file */ /* end file */

View File

@@ -24,20 +24,20 @@ var G_Grid = function(oForm, sGridName){
this.aElements = []; this.aElements = [];
this.aFunctions = []; this.aFunctions = [];
this.aFormulas = []; this.aFormulas = [];
this.allDependentFields = ''; //Stores all dependent fields this.allDependentFields = ''; //Stores all dependent fields
this.countRows = function(){ this.countRows = function(){
return this.aElements.length / this.aFields.length; return this.aElements.length / this.aFields.length;
}; };
this.getObjectName = function(Name){ this.getObjectName = function(Name){
var arr = Name.split(']['); var arr = Name.split('][');
var aux = arr.pop(); var aux = arr.pop();
aux = aux.replace(']',''); aux = aux.replace(']','');
return aux; return aux;
}; };
//Begin SetFields --------------------------------------------------------------------- //Begin SetFields ---------------------------------------------------------------------
this.setFields = function(aFields, iRow) { this.setFields = function(aFields, iRow) {
this.aFields = aFields; this.aFields = aFields;
@@ -60,43 +60,43 @@ var G_Grid = function(oForm, sGridName){
j++; j++;
} }
break; break;
case 'currency': case 'currency':
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) { while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + '][' this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
+ this.aFields[i].sFieldName)); + this.aFields[i].sFieldName));
if (this.aFields[i].oProperties) { if (this.aFields[i].oProperties) {
if (this.aFields[i].oProperties.comma_separator) { if (this.aFields[i].oProperties.comma_separator) {
this.aElements[this.aElements.length - 1].comma_separator = this.aFields[i].oProperties.comma_separator; this.aElements[this.aElements.length - 1].comma_separator = this.aFields[i].oProperties.comma_separator;
} }
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate; this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
this.aElements[this.aElements.length - 1].mask = this.aFields[i].oProperties.mask; this.aElements[this.aElements.length - 1].mask = this.aFields[i].oProperties.mask;
} }
j++; j++;
} }
break; break;
case 'percentage': case 'percentage':
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) { while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j
+ '][' + this.aFields[i].sFieldName)); + '][' + this.aFields[i].sFieldName));
if (this.aFields[i].oProperties) { if (this.aFields[i].oProperties) {
if (this.aFields[i].oProperties.comma_separator) { if (this.aFields[i].oProperties.comma_separator) {
this.aElements[this.aElements.length - 1].comma_separator = this.aFields[i].oProperties.comma_separator; this.aElements[this.aElements.length - 1].comma_separator = this.aFields[i].oProperties.comma_separator;
} }
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate; this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
this.aElements[this.aElements.length - 1].mask = this.aFields[i].oProperties.mask; this.aElements[this.aElements.length - 1].mask = this.aFields[i].oProperties.mask;
} }
j++; j++;
} }
break; break;
case 'dropdown': case 'dropdown':
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) { while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + '][' this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
@@ -107,7 +107,7 @@ var G_Grid = function(oForm, sGridName){
j++; j++;
} }
break; break;
default: default:
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) { while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
this.aElements.push(new G_Field(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + '][' this.aElements.push(new G_Field(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
@@ -134,9 +134,9 @@ var G_Grid = function(oForm, sGridName){
} }
}; };
//End Set Fields -------------------------------------------------------- //End Set Fields --------------------------------------------------------
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
this.setDependents = function(iRow, me, theDependentFields, sw) { this.setDependents = function(iRow, me, theDependentFields, sw) {
//alert('Row:' + iRow + ' me: ' + me.name + ' DP: ' + theDependentFields); //alert('Row:' + iRow + ' me: ' + me.name + ' DP: ' + theDependentFields);
var i; var i;
@@ -154,20 +154,20 @@ var G_Grid = function(oForm, sGridName){
} }
} }
}; };
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
this.unsetFields = function() { this.unsetFields = function() {
var i, j = 0, k, l = 0; var i, j = 0, k, l = 0;
k = this.aElements.length / this.aFields.length; k = this.aElements.length / this.aFields.length;
for (i = 0; i < this.aFields.length; i++) { for (i = 0; i < this.aFields.length; i++) {
j += k; j += k;
l++; l++;
this.aElements.splice(j - l, 1); this.aElements.splice(j - l, 1);
} }
}; };
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
this.getElementByName = function(iRow, sName) { this.getElementByName = function(iRow, sName) {
var i; var i;
@@ -178,9 +178,9 @@ var G_Grid = function(oForm, sGridName){
} }
return null; return null;
}; };
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
this.getElementValueByName = function(iRow, sName) { this.getElementValueByName = function(iRow, sName) {
var oAux = document.getElementById('form[' + this.sGridName + '][' + iRow + '][' + sName + ']'); var oAux = document.getElementById('form[' + this.sGridName + '][' + iRow + '][' + sName + ']');
if (oAux) { if (oAux) {
@@ -189,9 +189,9 @@ var G_Grid = function(oForm, sGridName){
return 'Object not found!'; return 'Object not found!';
} }
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
this.getFunctionResult = function(sName) { this.getFunctionResult = function(sName) {
var oAux = document.getElementById('form[SYS_GRID_AGGREGATE_' + this.sGridName + '_' + sName + ']'); var oAux = document.getElementById('form[SYS_GRID_AGGREGATE_' + this.sGridName + '_' + sName + ']');
if (oAux) { if (oAux) {
@@ -200,60 +200,91 @@ var G_Grid = function(oForm, sGridName){
return 'Object not found!'; return 'Object not found!';
} }
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
this.cloneInput = function(oNewObject){ this.cloneInput = function(oNewObject){
var newField;
var txt = oNewObject.parentNode.innerHTML; var txt = oNewObject.parentNode.innerHTML;
var xClass = 'module_app_input___gray'; var xClass = 'module_app_input___gray';
txt = txt.replace('input', ''); txt = txt.replace('input', '');
txt = txt.replace('INPUT', ''); txt = txt.replace('INPUT', '');
txt = txt.replace('<', ''); txt = txt.replace('<', '');
txt = txt.replace('/>', ''); txt = txt.replace('/>', '');
txt = txt.replace('>', ''); txt = txt.replace('>', '');
aux4 = txt.toLowerCase(); var strAux = strReplace(' ', '', txt);
aux4 = aux4.replace(' ',''); strAux = strAux.toLowerCase();
sw_display = false;
if ((aux4.indexOf ('display:none') > 0) || (aux4.indexOf('display: none')>0)){ var sw_display = (strAux.indexOf('display:none') > 0)? true : false;
sw_display = true;
} var arrayElemTxt = txt.split('="');
pTxt = txt.split('="'); var pos = 0;
for (v=1; v < pTxt.length; v++){ var strAux2 = '';
aux = pTxt[v]; var strAux3 = '';
if (pos = aux.indexOf('"')){
aux2 = aux.substr(0,pos); for (var i = 0; i <= arrayElemTxt.length - 1; i++) {
aux3 = aux2.replace(' ','[%space$]'); strAux = arrayElemTxt[i];
pTxt[v] = aux.replace(aux2, aux3); pos = strAux.indexOf('"');
if (pos > 0) {
strAux2 = strAux.substr(0, pos);
strAux3 = strReplace(' ', '__%SPACE__', strAux2)
arrayElemTxt[i] = strAux.replace(strAux2, strAux3);
} }
} }
txt = pTxt.join('="');
txt = arrayElemTxt.join('="');
aTxt = txt.split(' ');
arrayElemTxt = txt.split(' ');
var strStyle = (sw_display)? " style=\"display: none;\"" : "";
var strDisabled = (oNewObject.disabled)? " disabled=\"disabled\"" : ""; var arrayAttribute = [];
var strReadOnly = (oNewObject.readOnly)? " readonly=\"readonly\"" : ""; var arrayAttributeValue = [];
var strStyle = '';
var xElement = "<input id=\"" + oNewObject.id + "\" name=\"" + oNewObject.id + "\" class=\"" + xClass + "\"" + strStyle + strDisabled + strReadOnly + " />";
for (var i = 0; i <= arrayElemTxt.length - 1; i++) {
newField = document.createElement(xElement); if (arrayElemTxt[i].indexOf('=') > 0) {
aVals = arrayElemTxt[i].split('=');
for (var a=0; a < aTxt.length; a++){ aVals[0] = aVals[0].toLowerCase();
if (aTxt[a].indexOf('=')>0){ aVals[1] = strReplace('"', '', aVals[1])
aVals = aTxt[a].split('='); aVals[1] = strReplace('__%SPACE__', ' ', aVals[1])
if (aVals[0] != 'id' && aVals[0] != 'name' && aVals[0] != 'class' && aVals[0] != 'style'){ if (aVals[0] != 'id' && aVals[0] != 'name' && aVals[0] != 'class' && aVals[0] != 'style') {
newField.setAttribute(aVals[0], aVals[1].replace('"','').replace('"','').replace('[%space$]',' ')); arrayAttribute.push(aVals[0]);
arrayAttributeValue.push(aVals[1]);
} else {
if (aVals[0] == 'style') {
strStyle = aVals[1];
}
}
} }
}
} }
strStyle = ((sw_display)? "display: none;" : "") + strStyle;
var newField = document.createElement("input");
newField.setAttribute("id", oNewObject.id);
newField.setAttribute("name", oNewObject.id);
newField.className = xClass;
newField.style.cssText = strStyle;
if (oNewObject.disabled) {
newField.disabled = true;
}
if (oNewObject.readOnly) {
newField.readOnly = true;
}
for (var i = 0; i <= arrayAttribute.length - 1; i++) {
newField.setAttribute(arrayAttribute[i], arrayAttributeValue[i]);
}
return newField; return newField;
}; };
this.addGridRow = function() { this.addGridRow = function() {
var i, aObjects; var i, aObjects;
var defaultValue = ''; var defaultValue = '';
@@ -263,17 +294,17 @@ var G_Grid = function(oForm, sGridName){
var oNewRow = this.oGrid.insertRow(this.oGrid.rows.length - 1); var oNewRow = this.oGrid.insertRow(this.oGrid.rows.length - 1);
var currentRow = this.oGrid.rows.length - 2; var currentRow = this.oGrid.rows.length - 2;
var newID, attributes, img2, gridType; var newID, attributes, img2, gridType;
oNewRow.onmouseover=function(){ oNewRow.onmouseover=function(){
highlightRow(this, '#D9E8FF'); highlightRow(this, '#D9E8FF');
}; };
oNewRow.onmouseout=function(){ oNewRow.onmouseout=function(){
highlightRow(this, '#fff'); highlightRow(this, '#fff');
}; };
// Clone Cells Loop // Clone Cells Loop
for (i = 0; i < aCells.length; i++) { for (i = 0; i < aCells.length; i++) {
oNewRow.appendChild(aCells[i].cloneNode(true)); //Clone First Cell exactly. oNewRow.appendChild(aCells[i].cloneNode(true)); //Clone First Cell exactly.
switch (i){ switch (i){
case 0: case 0:
oNewRow.getElementsByTagName('td')[i].innerHTML = currentRow; oNewRow.getElementsByTagName('td')[i].innerHTML = currentRow;
@@ -307,7 +338,7 @@ var G_Grid = function(oForm, sGridName){
img2 = tags[1].innerHTML; img2 = tags[1].innerHTML;
//Create new trigger name //Create new trigger name
var datePickerTriggerId = tags[1].id.replace(/\[1\]/g, '\[' + currentRow + '\]'); var datePickerTriggerId = tags[1].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
//Remove 'a' tag for date picker trigger //Remove 'a' tag for date picker trigger
oNewRow.getElementsByTagName('td')[i].removeChild(tags[1]); oNewRow.getElementsByTagName('td')[i].removeChild(tags[1]);
//Capture Script and remove //Capture Script and remove
var scriptTags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script'); var scriptTags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');
@@ -319,7 +350,7 @@ var G_Grid = function(oForm, sGridName){
} }
//Create new 'a' to trigger DatePicker //Create new 'a' to trigger DatePicker
var a2 = document.createElement('a'); var a2 = document.createElement('a');
if( a2.style.setAttribute ) { if( a2.style.setAttribute ) {
var styleText = "position:relative;top:0px;left:-19px;"; var styleText = "position:relative;top:0px;left:-19px;";
a2.style.setAttribute("cssText", styleText ); a2.style.setAttribute("cssText", styleText );
@@ -328,16 +359,16 @@ var G_Grid = function(oForm, sGridName){
var styleText = "position:relative;top:0px;left:-22px;"; var styleText = "position:relative;top:0px;left:-22px;";
a2.setAttribute("style", styleText ); a2.setAttribute("style", styleText );
} }
a2.id = datePickerTriggerId; a2.id = datePickerTriggerId;
a2.innerHTML = img2; a2.innerHTML = img2;
oNewRow.getElementsByTagName('td')[i].appendChild(a2); oNewRow.getElementsByTagName('td')[i].appendChild(a2);
//Load DatePicker Trigger //Load DatePicker Trigger
datePicker4("", newID, attributes.mask, attributes.start, attributes.end, attributes.time); datePicker4("", newID, attributes.mask, attributes.start, attributes.end, attributes.time);
if(defaultValue=='today'){ if(defaultValue=='today'){
attributesValue = elementAttributesNS(aObjects[0], ''); attributesValue = elementAttributesNS(aObjects[0], '');
aObjects[n].value=attributesValue.value; aObjects[n].value=attributesValue.value;
}else }else
aObjects[n].value = defaultValue; aObjects[n].value = defaultValue;
}else{ }else{
if (_BROWSER.name == 'msie' && aObjects.length==1){ //Clone new input element if browser is IE if (_BROWSER.name == 'msie' && aObjects.length==1){ //Clone new input element if browser is IE
@@ -356,14 +387,14 @@ var G_Grid = function(oForm, sGridName){
} }
} }
break; break;
case 'checkbox': //CHECKBOX case 'checkbox': //CHECKBOX
if (_BROWSER.name != 'msie'){ if (_BROWSER.name != 'msie'){
attributesFalse = elementAttributesNS(aObjects[0], ''); attributesFalse = elementAttributesNS(aObjects[0], '');
if((defaultValue === attributesFalse.falsevalue) || (defaultValue==='')) if((defaultValue === attributesFalse.falsevalue) || (defaultValue===''))
aObjects[n].checked = false; aObjects[n].checked = false;
else else
aObjects[n].checked = true; aObjects[n].checked = true;
} }
break; break;
case 'hidden': //HIDDEN case 'hidden': //HIDDEN
if ((attributes.gridtype != 'yesno' && attributes.gridtype != 'dropdown') || typeof attributes.gridtype == 'undefined') if ((attributes.gridtype != 'yesno' && attributes.gridtype != 'dropdown') || typeof attributes.gridtype == 'undefined')
@@ -379,7 +410,7 @@ var G_Grid = function(oForm, sGridName){
} }
} }
aObjects = null; aObjects = null;
break; break;
case 'textarea': //TEXTAREA case 'textarea': //TEXTAREA
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea'); aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');
if (aObjects){ if (aObjects){
@@ -396,19 +427,19 @@ var G_Grid = function(oForm, sGridName){
} }
aObjects = null; aObjects = null;
break; break;
case 'select': //DROPDOWN case 'select': //DROPDOWN
var oNewSelect; var oNewSelect;
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('select'); aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('select');
if (aObjects){ if (aObjects){
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]'); newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
aObjects[0].id = newID; aObjects[0].id = newID;
aObjects[0].name = newID; aObjects[0].name = newID;
oNewSelect = document.createElement(aObjects[0].tagName); oNewSelect = document.createElement(aObjects[0].tagName);
oNewSelect.id = newID; oNewSelect.id = newID;
oNewSelect.name = newID; oNewSelect.name = newID;
oNewSelect.setAttribute('class','module_app_input___gray'); oNewSelect.setAttribute('class','module_app_input___gray');
aAttributes = aObjects[0].attributes; aAttributes = aObjects[0].attributes;
for (a=0; a < aAttributes.length; a++){ for (a=0; a < aAttributes.length; a++){
if (aAttributes[a].name.indexOf('pm:') != -1){ if (aAttributes[a].name.indexOf('pm:') != -1){
@@ -425,7 +456,7 @@ var G_Grid = function(oForm, sGridName){
} }
} }
} }
attributes = elementAttributesNS(aObjects[0], 'pm'); attributes = elementAttributesNS(aObjects[0], 'pm');
//var MyAtt = attributes; //var MyAtt = attributes;
if (attributes.defaultvalue != '' && typeof attributes.defaultvalue != 'undefined'){ if (attributes.defaultvalue != '' && typeof attributes.defaultvalue != 'undefined'){
@@ -490,7 +521,7 @@ var G_Grid = function(oForm, sGridName){
if (_BROWSER.name == 'msie'){ if (_BROWSER.name == 'msie'){
if (oAux.options[r].getAttribute('selected') != ''){ if (oAux.options[r].getAttribute('selected') != ''){
xOption.setAttribute('selected','selected'); xOption.setAttribute('selected','selected');
} }
}else{ }else{
if (oAux.options[r].getAttribute('selected') == 'selected'){ if (oAux.options[r].getAttribute('selected') == 'selected'){
xOption.setAttribute('selected','selected'); xOption.setAttribute('selected','selected');
@@ -533,10 +564,10 @@ var G_Grid = function(oForm, sGridName){
aObjects = null; aObjects = null;
break; break;
} }
break; break;
} }
} }
if (this.aFields.length > 0) { if (this.aFields.length > 0) {
this.setFields(this.aFields, currentRow); this.setFields(this.aFields, currentRow);
} }
@@ -591,7 +622,7 @@ var G_Grid = function(oForm, sGridName){
this.onaddrow(currentRow); this.onaddrow(currentRow);
} }
}; };
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
this.deleteGridRow = function(sRow, bWithoutConfirm){ this.deleteGridRow = function(sRow, bWithoutConfirm){
if (typeof bWithoutConfirm == 'undefined') bWithoutConfirm = false; if (typeof bWithoutConfirm == 'undefined') bWithoutConfirm = false;
@@ -613,16 +644,16 @@ var G_Grid = function(oForm, sGridName){
}); });
} }
}; };
this.deleteRowWC = function(oObj, aRow){ this.deleteRowWC = function(oObj, aRow){
sRow = new String(aRow); sRow = new String(aRow);
sRow = sRow.replace('[', ''); sRow = sRow.replace('[', '');
sRow = sRow.replace(']', ''); sRow = sRow.replace(']', '');
iRow = Number(sRow); iRow = Number(sRow);
deleteRowOnDynaform(oObj, iRow); deleteRowOnDynaform(oObj, iRow);
var lastItem = oObj.oGrid.rows.length - 2; var lastItem = oObj.oGrid.rows.length - 2;
iRowAux = iRow + 1; iRowAux = iRow + 1;
while (iRowAux <= (lastItem)) { while (iRowAux <= (lastItem)) {
for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) { for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) {
@@ -638,11 +669,11 @@ var G_Grid = function(oForm, sGridName){
} }
aObjects1[0].value = aObjects2[0].value; aObjects1[0].value = aObjects2[0].value;
} }
aObjects = oCell1.getElementsByTagName('div'); aObjects = oCell1.getElementsByTagName('div');
if (aObjects.length > 0) { if (aObjects.length > 0) {
if (aObjects[0]) { if (aObjects[0]) {
aObjects[0].id = aObjects[0].id.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]'); aObjects[0].id = aObjects[0].id.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]');
aObjects[0].name = aObjects[0].id.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]'); aObjects[0].name = aObjects[0].id.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]');
@@ -661,7 +692,7 @@ var G_Grid = function(oForm, sGridName){
} }
} }
} }
break; break;
case '<selec': case '<selec':
aObjects1 = oCell1.getElementsByTagName('select'); aObjects1 = oCell1.getElementsByTagName('select');
@@ -723,15 +754,15 @@ var G_Grid = function(oForm, sGridName){
} }
} }
} }
//Fires OnAddRow Event //Fires OnAddRow Event
if (oObj.ondeleterow) { if (oObj.ondeleterow) {
oObj.ondeleterow(iRow); oObj.ondeleterow(iRow);
} }
}; };
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
this.assignFunctions = function(aFields, sEvent, iRow) { this.assignFunctions = function(aFields, sEvent, iRow) {
iRow = iRow || 1; iRow = iRow || 1;
var i, j, oAux; var i, j, oAux;
@@ -765,14 +796,14 @@ var G_Grid = function(oForm, sGridName){
} }
} }
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
this.setFunctions = function(aFunctions) { this.setFunctions = function(aFunctions) {
this.aFunctions = aFunctions; this.aFunctions = aFunctions;
this.assignFunctions(this.aFunctions, 'change'); this.assignFunctions(this.aFunctions, 'change');
}; };
this.determineBrowser = function() this.determineBrowser = function()
{ {
var nAgt = navigator.userAgent; var nAgt = navigator.userAgent;
@@ -804,7 +835,7 @@ var G_Grid = function(oForm, sGridName){
return browserName; return browserName;
}; };
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
this.sum = function(oEvent, oDOM) { this.sum = function(oEvent, oDOM) {
oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement); oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement);
var i, aAux, oAux, fTotal, sMask, nnName; var i, aAux, oAux, fTotal, sMask, nnName;
@@ -812,7 +843,7 @@ var G_Grid = function(oForm, sGridName){
i = 1; i = 1;
fTotal = 0; fTotal = 0;
aAux[2] = aAux[2].replace(']', ''); aAux[2] = aAux[2].replace(']', '');
var j=1; var j=1;
for ( var k = 0; k < this.aElements.length; k++) { for ( var k = 0; k < this.aElements.length; k++) {
nnName= this.aElements[k].name.split(']['); nnName= this.aElements[k].name.split('][');
@@ -842,7 +873,7 @@ var G_Grid = function(oForm, sGridName){
oAux.innerHTML = fTotal; oAux.innerHTML = fTotal;
} }
}; };
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
this.avg = function(oEvent, oDOM) { this.avg = function(oEvent, oDOM) {
oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement); oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement);
@@ -882,9 +913,9 @@ var G_Grid = function(oForm, sGridName){
} }
} }
}; };
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
this.assignFormulas = function(aFields, sEvent, iRow) { this.assignFormulas = function(aFields, sEvent, iRow) {
iRow = iRow || 1; iRow = iRow || 1;
var i, j, oAux; var i, j, oAux;
@@ -901,13 +932,13 @@ var G_Grid = function(oForm, sGridName){
} }
} }
}; };
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
this.setFormulas = function(aFormulas) { this.setFormulas = function(aFormulas) {
this.aFormulas = aFormulas; this.aFormulas = aFormulas;
this.assignFormulas(this.aFormulas, 'change'); this.assignFormulas(this.aFormulas, 'change');
}; };
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
this.evaluateFormula = function(oEvent, oDOM, oField) { this.evaluateFormula = function(oEvent, oDOM, oField) {
oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement); oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement);
@@ -934,7 +965,7 @@ var G_Grid = function(oForm, sGridName){
} }
} }
eval("if (!document.getElementById('" + aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + "]')) { oContinue = false; }"); eval("if (!document.getElementById('" + aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + "]')) { oContinue = false; }");
if (oContinue) { if (oContinue) {
//we're selecting the mask to put in the field with the formula //we're selecting the mask to put in the field with the formula
for (i = 0; i < this.aFields.length; i++) { for (i = 0; i < this.aFields.length; i++) {
@@ -944,15 +975,15 @@ var G_Grid = function(oForm, sGridName){
} }
if(maskformula!=''){ if(maskformula!=''){
maskDecimal=maskformula.split(";"); maskDecimal=maskformula.split(";");
if(maskDecimal.length > 1) { if(maskDecimal.length > 1) {
maskDecimal=maskDecimal[1].split("."); maskDecimal=maskDecimal[1].split(".");
} else { } else {
maskDecimal=maskformula.split("."); maskDecimal=maskformula.split(".");
} }
if(typeof maskDecimal[1] != 'undefined') { if(typeof maskDecimal[1] != 'undefined') {
maskToPut=maskDecimal[1].length; maskToPut=maskDecimal[1].length;
} else { } else {
maskToPut=0; maskToPut=0;
} }
@@ -961,29 +992,29 @@ var G_Grid = function(oForm, sGridName){
maskToPut=0; maskToPut=0;
} }
// clean the field and load mask execute event keypress // clean the field and load mask execute event keypress
document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value = ''; document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value = '';
this.executeEvent(document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']'), 'keypress'); this.executeEvent(document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']'), 'keypress');
// execute formula and set decimal // execute formula and set decimal
eval("document.getElementById('" + aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + "]').value = (" + sAux + ').toFixed('+maskToPut+');'); eval("document.getElementById('" + aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + "]').value = (" + sAux + ').toFixed('+maskToPut+');');
// trim value // trim value
document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value = document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value.replace(/^\s*|\s*$/g,""); document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value = document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value.replace(/^\s*|\s*$/g,"");
// set '' to field if response is NaN // set '' to field if response is NaN
if (document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value =='NaN') if (document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value =='NaN')
document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value = ''; document.getElementById(aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']').value = '';
// save var symbol the response // save var symbol the response
var symbol = document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value.replace(/[0-9.\s]/g,''); var symbol = document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value.replace(/[0-9.\s]/g,'');
this.executeEvent(document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']'), 'keypress'); this.executeEvent(document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']'), 'keypress');
// replace symbol - for '' // replace symbol - for ''
document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value = document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value.replace('-',''); document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value = document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value.replace('-','');
// set var symbol // set var symbol
document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value = symbol+''+document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value; document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value = symbol+''+document.getElementById(aAux[0]+']['+ aAux[1] + '][' + oField.sFieldName + ']').value;
// return focus the field typed // return focus the field typed
if (typeof document.getElementById(domId) != 'undefined') { if (typeof document.getElementById(domId) != 'undefined') {
@@ -1020,25 +1051,25 @@ var G_Grid = function(oForm, sGridName){
}); });
} }
}; };
/*add*/ /*add*/
this.deleteGridRownomsg = function(sRow) { this.deleteGridRownomsg = function(sRow) {
var i, iRow, iRowAux, oAux, ooAux; var i, iRow, iRowAux, oAux, ooAux;
//action : function() { //action : function() {
//this.aElements = []; //this.aElements = [];
sRow = sRow.replace('[', ''); sRow = sRow.replace('[', '');
sRow = sRow.replace(']', ''); sRow = sRow.replace(']', '');
iRow = Number(sRow); iRow = Number(sRow);
/* /*
* delete the respective session row grid variables from * delete the respective session row grid variables from
* Dynaform - by Nyeke <erik@colosa.com * Dynaform - by Nyeke <erik@colosa.com
*/ */
deleteRowOnDybaform(this, iRow); deleteRowOnDybaform(this, iRow);
iRowAux = iRow + 1; iRowAux = iRow + 1;
while (iRowAux <= (this.oGrid.rows.length - 2)) { while (iRowAux <= (this.oGrid.rows.length - 2)) {
for (i = 1; i < this.oGrid.rows[iRowAux - 1].cells.length; i++) { for (i = 1; i < this.oGrid.rows[iRowAux - 1].cells.length; i++) {
@@ -1056,11 +1087,11 @@ var G_Grid = function(oForm, sGridName){
// if(oCell1.innerHTML.indexOf('<div id=')!=-1) // if(oCell1.innerHTML.indexOf('<div id=')!=-1)
// oCell1.innerHTML = oCell2.innerHTML; // oCell1.innerHTML = oCell2.innerHTML;
} }
aObjects = oCell1.getElementsByTagName('div'); aObjects = oCell1.getElementsByTagName('div');
if (aObjects.length > 0) { if (aObjects.length > 0) {
if (aObjects[0]) { if (aObjects[0]) {
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]'); aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
aObjects[0].name = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]'); aObjects[0].name = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
@@ -1155,9 +1186,9 @@ var G_Grid = function(oForm, sGridName){
j++; j++;
} }
} }
if (this.aFunctions.length > 0) { if (this.aFunctions.length > 0) {
for (i = 0; i < this.aFunctions.length; i++) { for (i = 0; i < this.aFunctions.length; i++) {
oAux = document.getElementById('form[' + this.sGridName + '][1][' + this.aFunctions[i].sFieldName + ']'); oAux = document.getElementById('form[' + this.sGridName + '][1][' + this.aFunctions[i].sFieldName + ']');
if (oAux) { if (oAux) {
@@ -1199,16 +1230,16 @@ var G_Grid = function(oForm, sGridName){
if (this.ondeleterow) { if (this.ondeleterow) {
this.ondeleterow(); this.ondeleterow();
} }
//}.extend(this) //}.extend(this)
}; };
/*add end*/ /*add end*/
}; };
/** /**
* Delete the respective session row grid variables from Dynaform * Delete the respective session row grid variables from Dynaform
* *
* @Param grid * @Param grid
* [object: grid] * [object: grid]
* @Param sRow * @Param sRow
@@ -1216,7 +1247,6 @@ var G_Grid = function(oForm, sGridName){
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@mail.com> * @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@mail.com>
*/ */
function deleteRowOnDynaform(grid, sRow) { function deleteRowOnDynaform(grid, sRow) {
var oRPC = new leimnud.module.rpc.xmlhttp( { var oRPC = new leimnud.module.rpc.xmlhttp( {
url : '../gulliver/genericAjax', url : '../gulliver/genericAjax',
@@ -1227,7 +1257,7 @@ function deleteRowOnDynaform(grid, sRow) {
oPanel.loader.hide(); oPanel.loader.hide();
scs = rpc.xmlhttp.responseText.extractScript(); scs = rpc.xmlhttp.responseText.extractScript();
scs.evalScript(); scs.evalScript();
/** /**
* We verify if the debug panel is open, if it is-> update its content * We verify if the debug panel is open, if it is-> update its content
*/ */