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([]); /** * 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_code_label -- label for the activity code field * @param {Object} activity_code_field -- name of the activity code field * @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_code_label_param, activity_code_field_param, activity_types_codes_param, base_path_param) { activity_code_label = activity_code_label_param; activity_code_field = activity_code_field_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 = "Wybierz odpowiednią opcję z listy poniżej"; tree_control_instructions = "Rozwiń listę opcji poniżej i wybierz rodzaj działalności który najlepiej opisuje specyfikę działań Twojej organizacji."; 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('Typ aktywności: *')); $('#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(''); $('#tree_control_outer_ul').css("list-style-image", "none").css("list-style-type","none"); $.each(activity_types_codes, function(type_id, type_parts) { $('#tree_control_outer_ul').append($('
  • ').css("list-style-image", "none").css("list-style-type","none")); $('#type_li_' + type_id).append($('
    ').attr("id","type_li_div_" + type_id).css("display","inline")); $('#type_li_div_' + type_id).click( function() {hide_unhide(type_id) } ); $('#type_li_div_' + type_id).append($('').attr("id","image_plus_type_" + type_id)); $('#image_plus_type_' + type_id).append($('').attr("src",plus_path)); $('#type_li_div_' + type_id).append($('').attr("id","image_minus_type_" + type_id)); $('#image_minus_type_' + type_id).append($('').attr("src",minus_path)); if (typeof activity_tree_expand === 'boolean' && activity_tree_expand == true) { $('#image_plus_type_' + type_id).hide(); } else { $('#image_minus_type_' + type_id).hide(); } //DA: Begin section that prints the type name and lists the subtypes (codes) $.each(type_parts, function(activity_type_part_key, activity_type_part_value) { if (activity_type_part_key == "name") { //DA: This part lists the names of the types type_name = activity_type_part_value; $('#type_li_div_' + type_id).append($('').css('text-decoration', 'underline').css('font-weight', 'bold').css('margin-left','.5em').css('cursor', 'pointer').text(type_name)); $('#type_li_' + type_id).append($('
    ').attr('id','activity_block_type_' + type_id)); $('#activity_block_type_' + type_id).append($('').attr('id','codes_inner_ul_' + type_id).css('list-style-image', 'none').css('list-style-type','none')); if (typeof activity_tree_expand === 'undefined' || activity_tree_expand == false) { $('#activity_block_type_' + type_id).hide(); } } else { //DA: This part lists the subtypes (codes) $.each(activity_type_part_value,function(code_id, code_name){ //SR: Don't loop through description array if (activity_type_part_key != "description") { $('#codes_inner_ul_' + type_id).append($('
  • ').attr('id','code_li_' + code_id).css('list-style-image', 'none').css('list-style-type','none')); $('#code_li_' + code_id).append($('').attr('id','image_code_' + code_id)); $('#image_code_' + code_id).append($('').attr('src',red_checkmark_path)); $('#image_code_' + code_id).hide(); //SR: Don't display description if description is null or blank if ( typeof(type_parts.description)== 'undefined' || (null == type_parts['description'][code_id]) || (type_parts['description'][code_id] == '')) { $('#code_li_' + code_id).append($('').attr('id','activity_code_' + code_id).mouseover( function() {$(this).attr('class', 'toolTip-on');} ).mouseout( function() {$(this).attr('class', 'toolTip');} )); $('#activity_code_' + code_id).text(code_name); }else{ $('#code_li_' + code_id).append($('').attr('id','activity_code_' + code_id).attr('title',type_parts['description'][code_id]).attr('class','toolTip').mouseover( function() {$(this).attr('class', 'toolTip-on'); } ).mouseout( function() {$(this).attr('class', 'toolTip'); } )); $('#activity_code_' + code_id).text(code_name); } $('#activity_code_' + code_id).click( function() { set_activity_values(type_id, code_id, type_name, code_name) } ); } }); } }); //DA: End section that prints the type name and lists the subtypes (codes) }); //DA: End of actual tree //DA: Begin section for populating values if errors on page var selected_activity_type_id = $('#edit-organization-activity-type').val(); var selected_activity_type_name = $("option[@value=" + selected_activity_type_id + "]").text(); var activity_code_field_selector = '#edit-' + activity_code_field.replace('_', '-'); var selected_activity_code_id = $(activity_code_field_selector).val(); var selected_activity_code_name = $("option[@value=" + selected_activity_code_id + "]").text(); if ($('#edit-organization-activity-type').val() != '') { unhide($('#edit-organization-activity-type').val()); set_activity_values($('#edit-organization-activity-type').val(), $(activity_code_field_selector).val(), selected_activity_type_id, selected_activity_code_name); } //DA: End section for populating values if errors on page if (activity_code_field == 'organization_activity') { organization_register_library_survey(selected_activity_type_id); organization_register_validate(); if (typeof register_warrants_validate == 'function') { register_warrants_validate(); } } $('#load').fadeOut(1500); }); /*-----------------------------------------------------------------------------------------------*/ /* SIMPLE jQUERY TOOLTIP */ /* VERSION: 1.1 */ /* AUTHOR: jon cazier */ /* EMAIL: jon@3nhanced.com */ /* WEBSITE: 3nhanced.com */ /*-----------------------------------------------------------------------------------------------*/ $(document).ready(function() { $('.toolTip').hover( function() { this.tip = this.title; $(this).append( '
    ' +'
    ' +this.tip +'
    ' +'
    ' ); this.title = ""; this.width = $(this).width(); $(this).find('.toolTipWrapper').css({left:150}); $('.toolTipWrapper').fadeIn(300); $(this).css('z-index', '100500'); }, function() { $('.toolTipWrapper').fadeOut(100); $(this).css('z-index', ''); $(this).children().remove(); this.title = this.tip; } ); });