1 /* getAuthValueDropbox from js/acq.js is needed */
2 $(document).ready(function() {
3 // keep copy of the inactive budgets
4 disabledBudgetsCopy = $("select[name='all_budget_id']").html();
5 $("select[name='all_budget_id'] .b_inactive").remove();
6 $("select[name='budget_id'] .b_inactive").remove();
8 $("#showallbudgets").click(function() {
9 if ($(this).is(":checked")) {
10 $("select[name='budget_id']").html(disabledBudgetsCopy)
13 $("select[name='budget_id'] .b_inactive").remove();
17 $("#all_showallbudgets").click(function() {
18 if ($(this).is(":checked")) {
19 $("select[name='all_budget_id']").html(disabledBudgetsCopy);
22 $("select[name='all_budget_id'] .b_inactive").remove();
26 $("select[name='budget_id']").change(function(){
27 var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
28 var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
29 var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
30 var sort1 = $(destination_sort1).val() || "";
31 if ( destination_sort1.length < 1 ) {
32 destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
34 var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
35 var sort2 = $(destination_sort2).val() || "";
36 if ( destination_sort2.length < 1 ) {
37 destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
39 getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
41 getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
44 $("select[name='budget_id']").change();
46 $("select[name='all_budget_id']").change(function(){
47 var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
48 var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
49 var destination_sort1 = $(this).parent().siblings('li').find('input[name="all_sort1"]');
50 if ( destination_sort1.length < 1 ) {
51 destination_sort1 = $(this).parent().siblings('li').find('select[name="all_sort1"]');
53 var destination_sort2 = $(this).parent().siblings('li').find('input[name="all_sort2"]');
54 if ( destination_sort2.length < 1 ) {
55 destination_sort2 = $(this).parent().siblings('li').find('select[name="all_sort2"]');
57 getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1 );
58 getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2 );
59 $(this).parent().siblings('li').find('select[name="sort1"]').attr('name', 'all_sort1');
60 $(this).parent().siblings('li').find('input[name="sort1"]').attr('name', 'all_sort1');
61 $(this).parent().siblings('li').find('select[name="sort2"]').attr('name', 'all_sort2');
62 $(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
65 $("select[name='all_budget_id']").change();