Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Feb 1, 8:53 PM

in-portal

Index: trunk/admin/include/checkarray.js
===================================================================
--- trunk/admin/include/checkarray.js (revision 276)
+++ trunk/admin/include/checkarray.js (revision 277)
@@ -1,185 +1,184 @@
/* CheckArray - used to enable or disable toolbar images if items are checked or unchecked*/
function CheckArray()
{ /* class properties */
//alert('test');
this.paste_ = false;
this.ImageList = new Array(); // 2D array to hold image information
//[x][0] = image ID
//[x][1] = 'on' URL
//[x][2] = 'off' URL
//[x][3] = min. # of items required for 'on' state
this.CheckList = new Array(); // 1D array that contains document IDs for checkboxes
this.CheckValues = new Array();//1D array that contains values for each checkbox
this.itemschecked=0; // number of checked items
this.formname = null; // name of form containing checkboxes
this.envar = null; // envar of the document (from the query_string)
this.uncheckClassName = new Array(); //class to set element class to when unchecking item
/* class methods */
this.addImage = addImage; //adds an image to the image array
this.selectAll = selectAll; //set all check boxes to a value (true/false)
this.invertItems = invertItems; //invert all checkboxes
this.addCheck = addCheck; //called when an item is checked
this.removeCheck = removeCheck; //called when an item is unchecked
this.setImages = setImages; //used to set images to their on or off state
this.check_submit = check_submit; //called to submit the form
this.itemChecked=itemChecked; //returns true if at least 1 item is checked
this.countChecks=countChecks; //returns the # of checked items
this.getItemList=getItemList; //returns an array of the IDs currently checked
}
function addImage(Id,onURL,offURL,count)
{
img = new Array(Id,onURL,offURL,count);
this.ImageList[this.ImageList.length] = img;
}
function itemChecked()
{
if(this.itemschecked>0)
{
return true;
}
else
{
return false;
}
}
function selectAll(value)
{
checkcount = this.CheckList.length;
for(var i=0; i<checkcount; i++)
{
var ob = document.getElementById(this.CheckList[i]);
var inputs = ob.getElementsByTagName("INPUT");
for (var j = 0; j < inputs.length; j++)
{
if (inputs[j].type == "checkbox")
{
if(inputs[j].checked != value)
{
inputs[j].checked = value;
if(value==true)
{
this.addCheck(ob.id);
}
else
{
this.removeCheck(ob.id);
}
}
}
}
}
}
function invertItems()
{
checkcount = this.CheckList.length;
for(var i=0; i<checkcount; i++)
{
ob = document.getElementById(this.CheckList[i]);
var inputs = ob.getElementsByTagName("INPUT");
for (var j = 0; j < inputs.length; j++)
{
if (inputs[j].type == "checkbox")
{
value = inputs[j].checked;
if(value == false)
{
inputs[j].checked = true;
this.addCheck(ob.id);
}
else
{
inputs[j].checked = false;
this.removeCheck(ob.id);
}
}
}
}
}
function addCheck(el_id)
{
el = document.getElementById(el_id);
this.itemschecked++;
this.setImages();
this.uncheckClassName[el.id] = el.className;
el.className = 'selection';
idval = parseInt(el.id);
//alert(el_id+'='+idval);
this.CheckValues[el_id]=1;
}
function removeCheck(el_id)
{
el = document.getElementById(el_id);
this.itemschecked--;
this.setImages();
el.className = this.uncheckClassName[el.id];
idval = parseInt(el.id);
//alert(el_id+'='+idval);
this.CheckValues[el_id]=0;
}
function countChecks()
{
return this.itemschecked;
}
function setImages()
{
for(var i=0; i<this.ImageList.length; i++)
{
id = this.ImageList[i][0];
img = document.getElementById(id);
if(img)
{
if(this.itemschecked < this.ImageList[i][3])
{
img.src=this.ImageList[i][2];
}
else
{
img.src=this.ImageList[i][1];
}
}
else
alert('An Image [' +id+ '] not found');
}
}
function getItemList()
{
var res = new Array();
for(var i=0; i<this.CheckList.length; i++)
{
if(this.CheckValues[this.CheckList[i]]>0)
{
res[res.length] = this.CheckList[i];
}
}
return res;
}
function check_submit(location, ActionValue, EnvVar)
{
if( ActionValue.match(/_del/) || ActionValue.match(/del_/) )
if (!theMainScript.Confirm(lang_DeleteConfirm)) return;
f = document.getElementById(this.formname);
if(f)
{
- f.Action.value = ActionValue;
- f.action = location + '.php?' + this.envar;
- if(EnvVar != null) f.action += EnvVar;
- //alert(f.name+ ' is submitting to '+ f.action + ' action=' + f.Action.value);
+ f.Action.value = ActionValue;
+ f.action = location + '.php?' + this.envar;
+ if( HasParam(EnvVar) ) f.action += EnvVar;
f.submit();
}
else
alert('Form ' + this.formname + ' was not found.');
}
Property changes on: trunk/admin/include/checkarray.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/admin/include/tabs.js
===================================================================
--- trunk/admin/include/tabs.js (revision 276)
+++ trunk/admin/include/tabs.js (revision 277)
@@ -1,272 +1,272 @@
//parses input tags looking for validation attributes
function DataIsValid(f)
{
var ValType = '';
var span_id = '';
var form_result = true;
var field_result = true;
var j = 0;
for (var i = 0; i < f.elements.length; i++)
{
ValType = '';
Field = f.elements[i];
ValType = Field.getAttribute('ValidationType');
if(ValType)
{
ValType = TransformValidationType(ValType); // for capability with old forms
span_id = 'prompt_' + Field.name;
span = document.getElementById(span_id);
if(span)
{
field_result = true;
ValType = ValType.split(',');
j = 0;
while(j < ValType.length)
{
//alert('Validating ['+Field.name+'] as ['+ValType[j]+']');
if(ValType[j] == 'password')
{
var repasswd = document.getElementById(Field.name + '_verify');
if(repasswd)
{
field_result &= ValidateField(Field.value, ValType[j], repasswd.value);
document.getElementById('prompt_' + Field.name + '_verify').className = field_result ? 'text' : 'validation_error';
}
}
else
field_result &= ValidateField(Field.value, ValType[j]);
j++;
}
span.className = field_result ? 'text' : 'validation_error';
form_result &= field_result;
}
}
}
return form_result;
}
function TransformValidationType(OldType)
{
// replace old validation types with new
// on the fly in case if we have some forms
// that still use old validation types
var NewType = '';
switch(OldType)
{
case 'optional_date':
NewType = 'date';
break;
default:
NewType = OldType;
break;
}
return NewType;
}
function ValidateField(FieldValue, ValidateAs, RePasswdValue)
{
// validate FieldValue based on ValidateAs rule specified;
// in case if password field compare it with RePasswdValue
var result = true;
switch(ValidateAs)
{
case 'exists': // field is required
if(FieldValue.length == 0) result = false;
break;
case 'integer': // field must be integer number
result = ValidateNumber(FieldValue, ValidateAs);
break;
case 'password': // validate as password field
result = (FieldValue == RePasswdValue) || (FieldValue.length == 0);
break;
case 'date': // text must be a formatted date
result = ValidDate(FieldValue);
break;
case 'time': // text must be a formatted time
result = ValidTime(FieldValue);
break;
}
return result;
}
function MarkAsRequired(f)
{
var ValType = '';
var span_id = '';
var result = true;
for (var i = 0; i < f.elements.length; i++)
{
ValType = '';
Field = f.elements[i];
ValType = Field.getAttribute('ValidationType');
if(ValType)
{
ValType = ValType.split(',');
if( InArray(ValType,'exists') !== false )
{
span_id = 'prompt_' + Field.name;
span = document.getElementById(span_id);
span.innerHTML = span.innerHTML + '<span class="error">*</span>';
}
}
}
}
function InArray(aArray, aValue)
{
// checks if element in array
var k = 0;
while(k < aArray.length)
{
if(aArray[k] == aValue) return k;
k++;
}
return false;
}
//Used to submit the form when a tab is clicked on
function edit_submit(formname, status_field, targetURL, save_value, env_str, new_target)
{
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
-
+
if(full_env.substr(0,3) != "env") full_env = 'env=' + full_env;
f = document.getElementById(formname);
if(f)
{
var valid = false;
if(save_value != 2 && save_value !=-1)
{
valid = DataIsValid(f);
}
else
{
var a = f.Action;
if(a)
{
a.value='';
}
}
if(valid || save_value==2 || save_value==-1)
{
var URLPrefix = '';
if( targetURL.substring(0, rootURL.length) != rootURL ) URLPrefix = rootURL;
f.action = URLPrefix + targetURL + '?' + full_env;
if(status_field.length > 0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
if(new_target != null && typeof(new_target) != 'undefined') f.target = new_target;
f.submit();
}
else
if(!valid) alert(ErrorMsg);
}
else
alert('Form '+formname+' was not found.');
}
//Used when the save or cancel buttin is hit
function do_edit_save(formname, status_field, targetURL, save_value, env_str)
{
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
f = document.getElementById(formname);
if(f)
{
f.action = rootURL + targetURL + '?' + full_env;
//alert(f.action);
if(status_field.length>0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
f.submit();
}
else
alert('Form '+formname+' was not found.');
}
function jump_to_url(targetURL, env_str)
{
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
document.location = rootURL + targetURL + '?' + full_env;
}
// -------------------------------------------------------------------------------------------------------------
function submit_form(formname, status_field, targetURL, save_value, env_str)
{
// by Alex, submits form.
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
f = document.getElementById(formname);
if(f)
{
var valid = false;
if(save_value != 2 && save_value !=-1)
{
valid = DataIsValid(f);
}
else
{
var a = f.Action;
if(a)
{
a.value='';
}
}
if(valid || save_value==2 || save_value==-1)
{
f.action = rootURL + targetURL + '?' + full_env;
if(status_field.length>0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
f.submit();
}
else
if(!valid)
alert(ErrorMsg);
}
else
alert('Form '+formname+' was not found.');
}
function HasParam(param)
{
// checks of parameter is passed to function (cross-browser)
return typeof(param) == 'undefined' ? false : true;
}
function SetBackground(element_id, img_url)
{
// set background image of element specified by id
var el = document.getElementById(element_id);
el.style.backgroundImage = 'url('+img_url+')';
}
\ No newline at end of file
Property changes on: trunk/admin/include/tabs.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.8
\ No newline at end of property

Event Timeline