Cost-Benefit-Projection/media/js/help_document.js

344 lines
8.8 KiB
JavaScript
Raw Normal View History

2022-03-03 02:58:38 +00:00
/*----------------------------------------------------------------------------------| www.giz.de |----/
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
/-------------------------------------------------------------------------------------------------------/
2022-05-27 05:41:44 +00:00
@version 3.5.x
@build 27th May, 2022
2022-03-03 02:58:38 +00:00
@created 15th June, 2012
@package Cost Benefit Projection
@subpackage help_document.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.
/------------------------------------------------------------------------------------------------------*/
2015-12-01 05:06:34 +00:00
// Some Global Values
jform_vvvvvwbvwl_required = false;
jform_vvvvvwcvwm_required = false;
jform_vvvvvwdvwn_required = false;
jform_vvvvvwevwo_required = false;
2019-08-14 02:20:32 +00:00
jform_vvvvvwgvwp_required = false;
2015-12-01 05:06:34 +00:00
// Initial Script
jQuery(document).ready(function()
{
var location_vvvvvwb = jQuery("#jform_location input[type='radio']:checked").val();
vvvvvwb(location_vvvvvwb);
2015-12-01 05:06:34 +00:00
var location_vvvvvwc = jQuery("#jform_location input[type='radio']:checked").val();
vvvvvwc(location_vvvvvwc);
2015-12-01 05:06:34 +00:00
var type_vvvvvwd = jQuery("#jform_type").val();
vvvvvwd(type_vvvvvwd);
2015-12-01 05:06:34 +00:00
var type_vvvvvwe = jQuery("#jform_type").val();
vvvvvwe(type_vvvvvwe);
2015-12-01 05:06:34 +00:00
var type_vvvvvwf = jQuery("#jform_type").val();
vvvvvwf(type_vvvvvwf);
2015-12-01 05:06:34 +00:00
var target_vvvvvwg = jQuery("#jform_target input[type='radio']:checked").val();
vvvvvwg(target_vvvvvwg);
2015-12-01 05:06:34 +00:00
});
// the vvvvvwb function
function vvvvvwb(location_vvvvvwb)
2015-12-01 05:06:34 +00:00
{
// set the function logic
if (location_vvvvvwb == 1)
2015-12-01 05:06:34 +00:00
{
jQuery('#jform_admin_view').closest('.control-group').show();
2019-04-04 11:51:37 +00:00
// add required attribute to admin_view field
if (jform_vvvvvwbvwl_required)
{
updateFieldRequired('admin_view',0);
jQuery('#jform_admin_view').prop('required','required');
jQuery('#jform_admin_view').attr('aria-required',true);
jQuery('#jform_admin_view').addClass('required');
jform_vvvvvwbvwl_required = false;
}
2015-12-01 05:06:34 +00:00
}
else
{
jQuery('#jform_admin_view').closest('.control-group').hide();
2019-04-04 11:51:37 +00:00
// remove required attribute from admin_view field
if (!jform_vvvvvwbvwl_required)
{
updateFieldRequired('admin_view',1);
jQuery('#jform_admin_view').removeAttr('required');
jQuery('#jform_admin_view').removeAttr('aria-required');
jQuery('#jform_admin_view').removeClass('required');
jform_vvvvvwbvwl_required = true;
}
2015-12-01 05:06:34 +00:00
}
}
// the vvvvvwc function
function vvvvvwc(location_vvvvvwc)
2015-12-01 05:06:34 +00:00
{
// set the function logic
if (location_vvvvvwc == 2)
2015-12-01 05:06:34 +00:00
{
jQuery('#jform_site_view').closest('.control-group').show();
2019-04-04 11:51:37 +00:00
// add required attribute to site_view field
if (jform_vvvvvwcvwm_required)
{
updateFieldRequired('site_view',0);
jQuery('#jform_site_view').prop('required','required');
jQuery('#jform_site_view').attr('aria-required',true);
jQuery('#jform_site_view').addClass('required');
jform_vvvvvwcvwm_required = false;
}
2015-12-01 05:06:34 +00:00
}
else
{
jQuery('#jform_site_view').closest('.control-group').hide();
2019-04-04 11:51:37 +00:00
// remove required attribute from site_view field
if (!jform_vvvvvwcvwm_required)
{
updateFieldRequired('site_view',1);
jQuery('#jform_site_view').removeAttr('required');
jQuery('#jform_site_view').removeAttr('aria-required');
jQuery('#jform_site_view').removeClass('required');
jform_vvvvvwcvwm_required = true;
}
2015-12-01 05:06:34 +00:00
}
}
// the vvvvvwd function
function vvvvvwd(type_vvvvvwd)
2015-12-01 05:06:34 +00:00
{
if (isSet(type_vvvvvwd) && type_vvvvvwd.constructor !== Array)
2015-12-01 05:06:34 +00:00
{
var temp_vvvvvwd = type_vvvvvwd;
var type_vvvvvwd = [];
type_vvvvvwd.push(temp_vvvvvwd);
2015-12-01 05:06:34 +00:00
}
else if (!isSet(type_vvvvvwd))
2015-12-01 05:06:34 +00:00
{
var type_vvvvvwd = [];
2015-12-01 05:06:34 +00:00
}
var type = type_vvvvvwd.some(type_vvvvvwd_SomeFunc);
2015-12-01 05:06:34 +00:00
// set this function logic
2015-12-01 05:06:34 +00:00
if (type)
{
jQuery('#jform_url').closest('.control-group').show();
2019-04-04 11:51:37 +00:00
// add required attribute to url field
if (jform_vvvvvwdvwn_required)
2015-12-01 05:06:34 +00:00
{
updateFieldRequired('url',0);
jQuery('#jform_url').prop('required','required');
jQuery('#jform_url').attr('aria-required',true);
jQuery('#jform_url').addClass('required');
jform_vvvvvwdvwn_required = false;
2015-12-01 05:06:34 +00:00
}
}
else
{
jQuery('#jform_url').closest('.control-group').hide();
2019-04-04 11:51:37 +00:00
// remove required attribute from url field
if (!jform_vvvvvwdvwn_required)
2015-12-01 05:06:34 +00:00
{
updateFieldRequired('url',1);
jQuery('#jform_url').removeAttr('required');
jQuery('#jform_url').removeAttr('aria-required');
jQuery('#jform_url').removeClass('required');
jform_vvvvvwdvwn_required = true;
2015-12-01 05:06:34 +00:00
}
}
}
// the vvvvvwd Some function
function type_vvvvvwd_SomeFunc(type_vvvvvwd)
2015-12-01 05:06:34 +00:00
{
// set the function logic
if (type_vvvvvwd == 3)
2015-12-01 05:06:34 +00:00
{
return true;
}
return false;
}
// the vvvvvwe function
function vvvvvwe(type_vvvvvwe)
2015-12-01 05:06:34 +00:00
{
if (isSet(type_vvvvvwe) && type_vvvvvwe.constructor !== Array)
2015-12-01 05:06:34 +00:00
{
var temp_vvvvvwe = type_vvvvvwe;
var type_vvvvvwe = [];
type_vvvvvwe.push(temp_vvvvvwe);
2015-12-01 05:06:34 +00:00
}
else if (!isSet(type_vvvvvwe))
2015-12-01 05:06:34 +00:00
{
var type_vvvvvwe = [];
2015-12-01 05:06:34 +00:00
}
var type = type_vvvvvwe.some(type_vvvvvwe_SomeFunc);
2015-12-01 05:06:34 +00:00
// set this function logic
2015-12-01 05:06:34 +00:00
if (type)
{
jQuery('#jform_article').closest('.control-group').show();
2019-04-04 11:51:37 +00:00
// add required attribute to article field
if (jform_vvvvvwevwo_required)
2015-12-01 05:06:34 +00:00
{
updateFieldRequired('article',0);
jQuery('#jform_article').prop('required','required');
jQuery('#jform_article').attr('aria-required',true);
jQuery('#jform_article').addClass('required');
jform_vvvvvwevwo_required = false;
2015-12-01 05:06:34 +00:00
}
}
else
{
jQuery('#jform_article').closest('.control-group').hide();
2019-04-04 11:51:37 +00:00
// remove required attribute from article field
if (!jform_vvvvvwevwo_required)
2015-12-01 05:06:34 +00:00
{
updateFieldRequired('article',1);
jQuery('#jform_article').removeAttr('required');
jQuery('#jform_article').removeAttr('aria-required');
jQuery('#jform_article').removeClass('required');
jform_vvvvvwevwo_required = true;
2015-12-01 05:06:34 +00:00
}
}
}
// the vvvvvwe Some function
function type_vvvvvwe_SomeFunc(type_vvvvvwe)
2015-12-01 05:06:34 +00:00
{
// set the function logic
if (type_vvvvvwe == 1)
2015-12-01 05:06:34 +00:00
{
return true;
}
return false;
}
// the vvvvvwf function
function vvvvvwf(type_vvvvvwf)
2015-12-01 05:06:34 +00:00
{
if (isSet(type_vvvvvwf) && type_vvvvvwf.constructor !== Array)
2015-12-01 05:06:34 +00:00
{
var temp_vvvvvwf = type_vvvvvwf;
var type_vvvvvwf = [];
type_vvvvvwf.push(temp_vvvvvwf);
2015-12-01 05:06:34 +00:00
}
else if (!isSet(type_vvvvvwf))
2015-12-01 05:06:34 +00:00
{
var type_vvvvvwf = [];
2015-12-01 05:06:34 +00:00
}
var type = type_vvvvvwf.some(type_vvvvvwf_SomeFunc);
2015-12-01 05:06:34 +00:00
// set this function logic
2015-12-01 05:06:34 +00:00
if (type)
{
jQuery('#jform_content-lbl').closest('.control-group').show();
}
else
{
jQuery('#jform_content-lbl').closest('.control-group').hide();
}
}
// the vvvvvwf Some function
function type_vvvvvwf_SomeFunc(type_vvvvvwf)
2015-12-01 05:06:34 +00:00
{
// set the function logic
if (type_vvvvvwf == 2)
2015-12-01 05:06:34 +00:00
{
return true;
}
return false;
}
// the vvvvvwg function
function vvvvvwg(target_vvvvvwg)
2015-12-01 05:06:34 +00:00
{
// set the function logic
if (target_vvvvvwg == 1)
2015-12-01 05:06:34 +00:00
{
jQuery('#jform_groups').closest('.control-group').show();
2019-04-04 11:51:37 +00:00
// add required attribute to groups field
2019-08-14 02:20:32 +00:00
if (jform_vvvvvwgvwp_required)
2015-12-01 05:06:34 +00:00
{
updateFieldRequired('groups',0);
jQuery('#jform_groups').prop('required','required');
jQuery('#jform_groups').attr('aria-required',true);
jQuery('#jform_groups').addClass('required');
2019-08-14 02:20:32 +00:00
jform_vvvvvwgvwp_required = false;
2015-12-01 05:06:34 +00:00
}
}
else
{
jQuery('#jform_groups').closest('.control-group').hide();
2019-04-04 11:51:37 +00:00
// remove required attribute from groups field
2019-08-14 02:20:32 +00:00
if (!jform_vvvvvwgvwp_required)
2015-12-01 05:06:34 +00:00
{
updateFieldRequired('groups',1);
jQuery('#jform_groups').removeAttr('required');
jQuery('#jform_groups').removeAttr('aria-required');
jQuery('#jform_groups').removeClass('required');
2019-08-14 02:20:32 +00:00
jform_vvvvvwgvwp_required = true;
2015-12-01 05:06:34 +00:00
}
}
}
2020-05-30 22:55:13 +00:00
// update fields required
function updateFieldRequired(name, status) {
// check if not_required exist
if (jQuery('#jform_not_required').length > 0) {
var not_required = jQuery('#jform_not_required').val().split(",");
2015-12-01 05:06:34 +00:00
2020-05-30 22:55:13 +00:00
if(status == 1)
2015-12-01 05:06:34 +00:00
{
2020-05-30 22:55:13 +00:00
not_required.push(name);
2015-12-01 05:06:34 +00:00
}
else
{
2020-05-30 22:55:13 +00:00
not_required = removeFieldFromNotRequired(not_required, name);
2015-12-01 05:06:34 +00:00
}
2020-05-30 22:55:13 +00:00
jQuery('#jform_not_required').val(fixNotRequiredArray(not_required).toString());
2015-12-01 05:06:34 +00:00
}
2020-05-30 22:55:13 +00:00
}
// remove field from not_required
function removeFieldFromNotRequired(array, what) {
return array.filter(function(element){
return element !== what;
});
}
// fix not required array
function fixNotRequiredArray(array) {
var seen = {};
return removeEmptyFromNotRequiredArray(array).filter(function(item) {
return seen.hasOwnProperty(item) ? false : (seen[item] = true);
});
}
2015-12-01 05:06:34 +00:00
2020-05-30 22:55:13 +00:00
// remove empty from not_required array
function removeEmptyFromNotRequiredArray(array) {
return array.filter(function (el) {
// remove ( 一_一) as well - lol
return (el.length > 0 && '一_一' !== el);
});
2015-12-01 05:06:34 +00:00
}
// the isSet function
function isSet(val)
{
if ((val != undefined) && (val != null) && 0 !== val.length){
return true;
}
return false;
2022-03-03 02:58:38 +00:00
}