Sha256: 77d3890b07c18485fb96b4c6f96d56ef435c1f990f91e0bce6f6fb1b5b268151

Contents?: true

Size: 1.75 KB

Versions: 8

Compression:

Stored size: 1.75 KB

Contents

$(document).ready(function() { 
  togglePartyTasks();
  $('#task_party_attributes_party_type').change(function() {
    togglePartyTasks();
  });
  toggleIndividualTaskFields();
  $('#task_party_attributes_entity_1').click(function() {
    toggleIndividualTaskFields();
  });
  toggleCompanyTaskFields();
  $('#task_party_attributes_entity_2').click(function() {
    toggleCompanyTaskFields();
  });
});

function togglePartyTasks() {
  if ($('#task_party_attributes_party_type').val() == '(NONE)') {
    $("#party_status").find(":input").each(function(index, value){
      $(value).attr("disabled", "disabled");
    });
    $("#party_status").hide();
  } else {
    $("#party_status").find(":input").each(function(index, value){
      $(value).removeAttr("disabled");
    });
    $("#party_status").show();
  }
}

function toggleIndividualTaskFields() {
  if ($('#task_party_attributes_entity_1').val() == "1") {
    $('#individual_party').show().effect('highlight');
    $('#party_name').show().effect('highlight');
    $("#party_name").find("label").first().html('Surname');
    $('#task_party_attributes_title').removeAttr("disabled");
    $('#task_party_attributes_forename').removeAttr("disabled");
    $('task_party_attributes_title').val("");
    $('task_party_attributes_forename').val("");
    $('task_party_attributes_surname').val("");
  }
}

function toggleCompanyTaskFields() {
  if ($('#task_party_attributes_entity_2').val() == "2") {
    $("#individual_party").hide();
    $('#party_name').show().effect('highlight');
    $("#party_name").find("label").first().html('Company Name');
    $('#task_party_attributes_title').attr("disabled", "disabled");
    $('#task_party_attributes_forename').attr("disabled", "disabled");
    $('#task_party_attributes_surname').val("");
  }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
head_start-0.1.7 vendor/assets/javascripts/scorpion/tasks.js
head_start-0.1.6 vendor/assets/javascripts/scorpion/tasks.js
head_start-0.1.5 vendor/assets/javascripts/scorpion/tasks.js
head_start-0.1.4 vendor/assets/javascripts/scorpion/tasks.js
head_start-0.1.3 vendor/assets/javascripts/scorpion/tasks.js
head_start-0.1.2 vendor/assets/javascripts/scorpion/tasks.js
head_start-0.1.1 vendor/assets/javascripts/scorpion/tasks.js
head_start-0.1.0 vendor/assets/javascripts/scorpion/tasks.js