if (!window.locjs_tt) { window.locjs_tt = {}; function locjs_t(str) { if (window.locjs_tt[str] == undefined) { return str; } return window.locjs_tt[str]; } function locjs_extend_tt(tt) { for (i in tt) { window.locjs_tt[i] = tt[i]; } } } locjs_extend_tt({"Select from the options below":"Select from the options below","Expand the options below and select the activity that best describes what your organization does.":"Expand the options below and select the activity that best describes what your organization does."}); /** * This file contains all of the necessary functions for tree control display * on the organization registration page. * * @author Dave Allen and Mark Burdett */ var activity_types_codes; //DA: a 3-deep array that holds all activity types and subtypes (codes) var base_path; //DA: a string that is the base path for the site /** * This function initializes the variables that will be used later after the page is loaded. * * @param {Object} activity_types_codes -- "3-deep" nested array of activity types and subtypes sent in JSON format * @param {Object} base_path -- base directory of the Drupal site */ function initialize_vars(activity_types_codes_param, base_path_param) { activity_types_codes = activity_types_codes_param; base_path = base_path_param; } /** * This function opens and closes a particular activity tree branch. * * @param {Object} activity_type_id -- ID of the activity type */ function hide_unhide(activity_type_id) { $('#activity_block_type_' + activity_type_id).toggle(); $('#image_plus_type_' + activity_type_id).toggle(); $('#image_minus_type_' + activity_type_id).toggle(); } /** * This function opens a particular activity tree branch. * * @param {Object} activity_type_id -- ID of the activity type */ function unhide(activity_type_id) { $('#activity_block_type_' + activity_type_id).show(); $('#image_plus_type_' + activity_type_id).hide(); $('#image_minus_type_' + activity_type_id).show(); } /** * This function sets all activity values for activity type and subtype. * * @param {Object} activity_type_id -- ID of the activity type * @param {Object} activity_code_id -- ID of the activity code (subtype) * @param {Object} type_name -- name of the activity type * @param {Object} code_name -- name of the activity code (subtype) */ function set_activity_values(activity_type_id, activity_code_id, type_name, code_name) { old_activity_code_id = $('#selected_activity_code').attr("value"); $('#activity_code_' + old_activity_code_id).css("color", "black"); //DA: make old code name not red $('#image_code_' + old_activity_code_id).hide(); //DA: remove check or any preceding image icon from old code name display $('#activity_code_' + activity_code_id).css("color", "red"); //DA: make new selected code name red $('#image_code_' + activity_code_id).show(); //DA: add preceding check mark or any other image icon //DA: sets the name (for display) and activity code (for form submission) $('#selected_activity_name').val(code_name); $('#selected_activity_type').val(activity_type_id); //DA: set activity type for form submission $('#selected_activity_code').val(activity_code_id); //DA: set activity code for form submission organization_register_library_survey(activity_type_id); if(typeof register_warrants == 'function') { register_warrants(activity_code_id); } } /** * Hide or display the library survey form. */ function organization_register_library_survey(activity_type_id) { if (activity_type_id == '3') { $('#id_' + Drupal.settings.library_survey_field_group).show(); } else { $('#id_' + Drupal.settings.library_survey_field_group + '_show').hide(); $('#id_' + Drupal.settings.library_survey_field_group).hide(); } } /** * Set up and invoke jquery validate plugin for the user-register form. */ function organization_register_validate() { jQuery.validator.messages.required = Drupal.settings.library_survey_required; var validate = new Object(); validate.rules = new Object(); $('#id_' + Drupal.settings.library_survey_field_group).find('select').each(function() { validate.rules[this.id] = { required: function() { return ($('#id_' + Drupal.settings.library_survey_field_group).is(":visible")) ? true : false; } } }); $('#id_' + Drupal.settings.library_survey_field_group).find('input').each(function() { if ($(this).is(":checkbox")) { validate.rules[this.name] = { required: function(element) { return ($('#id_' + Drupal.settings.library_survey_field_group).is(":visible") && $(element).siblings(":checked").length < 1) ? true : false; } } } else if ($(this).is(":radio")) { validate.rules[this.name] = { required: function() { return ($('#id_' + Drupal.settings.library_survey_field_group).is(":visible")) ? true : false; } } } else { validate.rules[this.id] = { required: function() { return ($('#id_' + Drupal.settings.library_survey_field_group).is(":visible")) ? true : false; } } } }); validate.showErrors = function(errorMap, errorList) { if (errorList.length && !$("#required-message").length) { $('#id_' + Drupal.settings.library_survey_field_group + ' table').before('' + Drupal.settings.library_survey_message + ''); } this.defaultShowErrors(); }; $("#user-register").validate(validate); } /** * This function hides the "non-tree" version of the activity selection section and * displays the "tree" version of the activity selection section. It executes after * the non-javascrip version is rendered. */ $(function() { $('#no_tree_control_version').after($('
').attr('id','tree_control_version')); $('#no_tree_control_version').hide(); selected_activity_text = locjs_t("Select from the options below"); tree_control_instructions = locjs_t("Expand the options below and select the activity that best describes what your organization does."); plus_path = base_path + 'sites/all/modules/techsoup/includes/small_plus.gif'; minus_path = base_path + 'sites/all/modules/techsoup/includes/small_minus.gif'; red_checkmark_path = base_path + 'sites/all/modules/techsoup/includes/red_checkmark.gif'; $('#tree_control_version').append($('').addClass("form-item").css("font-weight","bold").html('Activity Type: *')); $('#tree_control_version').append(''); $('#tree_control_version').append(''); $('#tree_control_version').append(''); $('#tree_control_version').append($('').addClass("description").html(tree_control_instructions)); //DA: Start of actual tree $('#tree_control_version').append('