2015-12-01 05:06:34 +00:00
|
|
|
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
|
|
|
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
|
|
|
/-------------------------------------------------------------------------------------------------------/
|
|
|
|
|
2016-06-27 10:46:34 +00:00
|
|
|
@version 3.4.2
|
2016-08-16 11:46:32 +00:00
|
|
|
@build 16th August, 2016
|
2015-12-01 05:06:34 +00:00
|
|
|
@created 15th June, 2012
|
|
|
|
@package Cost Benefit Projection
|
|
|
|
@subpackage scaling_factor.js
|
|
|
|
@author Llewellyn van der Merwe <http://www.vdm.io>
|
|
|
|
@owner Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
|
|
|
@copyright Copyright (C) 2015. All Rights Reserved
|
|
|
|
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
|
|
|
|
/-------------------------------------------------------------------------------------------------------/
|
|
|
|
Cost Benefit Projection Tool.
|
|
|
|
/------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
2016-01-14 07:44:50 +00:00
|
|
|
// Some Global Values
|
2016-02-26 13:57:23 +00:00
|
|
|
jform_vvvvvvxvwi_required = false;
|
2016-01-14 07:44:50 +00:00
|
|
|
|
|
|
|
// Initial Script
|
|
|
|
jQuery(document).ready(function()
|
|
|
|
{
|
2016-02-26 13:57:23 +00:00
|
|
|
var company_vvvvvvx = jQuery("#jform_company").val();
|
|
|
|
vvvvvvx(company_vvvvvvx);
|
2016-01-14 07:44:50 +00:00
|
|
|
});
|
|
|
|
|
2016-02-26 13:57:23 +00:00
|
|
|
// the vvvvvvx function
|
|
|
|
function vvvvvvx(company_vvvvvvx)
|
2016-01-14 07:44:50 +00:00
|
|
|
{
|
2016-02-26 13:57:23 +00:00
|
|
|
if (isSet(company_vvvvvvx) && company_vvvvvvx.constructor !== Array)
|
2016-01-14 07:44:50 +00:00
|
|
|
{
|
2016-02-26 13:57:23 +00:00
|
|
|
var temp_vvvvvvx = company_vvvvvvx;
|
|
|
|
var company_vvvvvvx = [];
|
|
|
|
company_vvvvvvx.push(temp_vvvvvvx);
|
2016-01-14 07:44:50 +00:00
|
|
|
}
|
2016-02-26 13:57:23 +00:00
|
|
|
else if (!isSet(company_vvvvvvx))
|
2016-01-14 07:44:50 +00:00
|
|
|
{
|
2016-02-26 13:57:23 +00:00
|
|
|
var company_vvvvvvx = [];
|
2016-01-14 07:44:50 +00:00
|
|
|
}
|
2016-02-26 13:57:23 +00:00
|
|
|
var company = company_vvvvvvx.some(company_vvvvvvx_SomeFunc);
|
2016-01-14 07:44:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
// set this function logic
|
|
|
|
if (company)
|
|
|
|
{
|
|
|
|
jQuery('#jform_country').closest('.control-group').show();
|
2016-02-26 13:57:23 +00:00
|
|
|
if (jform_vvvvvvxvwi_required)
|
2016-01-14 07:44:50 +00:00
|
|
|
{
|
|
|
|
updateFieldRequired('country',0);
|
|
|
|
jQuery('#jform_country').prop('required','required');
|
|
|
|
jQuery('#jform_country').attr('aria-required',true);
|
|
|
|
jQuery('#jform_country').addClass('required');
|
2016-02-26 13:57:23 +00:00
|
|
|
jform_vvvvvvxvwi_required = false;
|
2016-01-14 07:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
jQuery('#jform_country').closest('.control-group').hide();
|
2016-02-26 13:57:23 +00:00
|
|
|
if (!jform_vvvvvvxvwi_required)
|
2016-01-14 07:44:50 +00:00
|
|
|
{
|
|
|
|
updateFieldRequired('country',1);
|
|
|
|
jQuery('#jform_country').removeAttr('required');
|
|
|
|
jQuery('#jform_country').removeAttr('aria-required');
|
|
|
|
jQuery('#jform_country').removeClass('required');
|
2016-02-26 13:57:23 +00:00
|
|
|
jform_vvvvvvxvwi_required = true;
|
2016-01-14 07:44:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-26 13:57:23 +00:00
|
|
|
// the vvvvvvx Some function
|
|
|
|
function company_vvvvvvx_SomeFunc(company_vvvvvvx)
|
2016-01-14 07:44:50 +00:00
|
|
|
{
|
|
|
|
// set the function logic
|
2016-02-26 13:57:23 +00:00
|
|
|
if (company_vvvvvvx == 0)
|
2016-01-14 07:44:50 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update required fields
|
|
|
|
function updateFieldRequired(name,status)
|
|
|
|
{
|
|
|
|
var not_required = jQuery('#jform_not_required').val();
|
|
|
|
|
|
|
|
if(status == 1)
|
|
|
|
{
|
|
|
|
if (isSet(not_required) && not_required != 0)
|
|
|
|
{
|
|
|
|
not_required = not_required+','+name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
not_required = ','+name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isSet(not_required) && not_required != 0)
|
|
|
|
{
|
|
|
|
not_required = not_required.replace(','+name,'');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery('#jform_not_required').val(not_required);
|
|
|
|
}
|
|
|
|
|
|
|
|
// the isSet function
|
|
|
|
function isSet(val)
|
|
|
|
{
|
|
|
|
if ((val != undefined) && (val != null) && 0 !== val.length){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|