1 $(document).ready(function() {
2 $( ".constraints" ).accordion();
3 $('#subfieldtabs').tabs();
4 $("input[id^='hidden_']").click(setHiddenValue);
5 $("input[id^='hidden-']").each(function() {
6 populateHiddenCheckboxes($(this).attr('id').split('-')[1]);
11 /* Function to enable/disable hidden values checkboxes when Flag is (de)selected */
12 function enable_cb(tab) {
13 if ($("#hidden_flagged_" + tab).is(':checked')) {
14 $('.inclusive_' + tab).attr('disabled',true).prop('checked', false);
17 $('.inclusive_' + tab).removeAttr('disabled');
21 /* Function to serialize and set the 'hidden' field */
22 function setHiddenValue() {
24 var tab = $(this).attr('id').split('_')[2];
25 var flagged_checked = $("#hidden_flagged_" + tab).is(':checked');
26 var opac_checked = $("#hidden_opac_" + tab).is(':checked');
27 var intranet_checked = $("#hidden_intranet_" + tab).is(':checked');
28 var editor_checked = $("#hidden_editor_" + tab).is(':checked');
29 var collapsed_checked = $("#hidden_collapsed_" + tab).is(':checked');
30 var hidden_value = "";
32 if ( flagged_checked ) {
34 } else if ( opac_checked && ! intranet_checked && ! editor_checked && collapsed_checked ) {
36 } else if ( opac_checked && intranet_checked && ! editor_checked && ! collapsed_checked) {
38 } else if ( opac_checked && intranet_checked && ! editor_checked && collapsed_checked) {
40 } else if ( opac_checked && ! intranet_checked && ! editor_checked && ! collapsed_checked) {
42 } else if ( opac_checked && ! intranet_checked && editor_checked && collapsed_checked) {
44 } else if ( opac_checked && ! intranet_checked && editor_checked && ! collapsed_checked) {
46 } else if ( opac_checked && intranet_checked && editor_checked && collapsed_checked) {
48 } else if ( opac_checked && intranet_checked && editor_checked && ! collapsed_checked) {
50 } else if ( ! opac_checked && intranet_checked && editor_checked && collapsed_checked) {
52 } else if ( ! opac_checked && ! intranet_checked && editor_checked && ! collapsed_checked) {
54 } else if ( ! opac_checked && ! intranet_checked && editor_checked && collapsed_checked) {
56 } else if ( ! opac_checked && intranet_checked && editor_checked && ! collapsed_checked) {
58 } else if ( ! opac_checked && ! intranet_checked && ! editor_checked && collapsed_checked) {
60 } else if ( ! opac_checked && intranet_checked && ! editor_checked && ! collapsed_checked) {
62 } else if ( ! opac_checked && intranet_checked && ! editor_checked && collapsed_checked) {
64 } else if ( ! opac_checked && ! intranet_checked && ! editor_checked && ! collapsed_checked) {
70 $('#hidden-' + tab).val(hidden_value);
74 function populateHiddenCheckboxes(tab) {
75 // read the serialized value
76 var hidden_value = $('#hidden-' + tab).val();
78 var opac_checked = false;
79 var intranet_checked = false;
80 var editor_checked = false;
81 var collapsed_checked = false;
82 var flagged_checked = false;
84 if ( hidden_value == '-8' ) {
85 flagged_checked = true;
86 } else if ( hidden_value == '-7') {
88 collapsed_checked = true;
89 } else if ( hidden_value == '-6' ) {
91 intranet_checked = true;
92 } else if ( hidden_value == '-5') {
94 intranet_checked = true;
95 collapsed_checked = true;
96 } else if ( hidden_value == '-4' ) {
98 } else if ( hidden_value == '-3') {
100 editor_checked = true;
101 collapsed_checked = true;
102 } else if ( hidden_value == '-2' ) {
104 editor_checked = true;
105 } else if ( hidden_value == '-1' ) {
107 intranet_checked = true;
108 editor_checked = true;
109 collapsed_checked = true;
110 } else if ( hidden_value == '0' ) {
112 intranet_checked = true;
113 editor_checked = true;
114 } else if ( hidden_value == '1' ) {
115 intranet_checked = true;
116 editor_checked = true;
117 collapsed_checked = true;
118 } else if ( hidden_value == '2' ) {
119 editor_checked = true;
120 } else if ( hidden_value == '3' ) {
121 editor_checked = true;
122 collapsed_checked = true;
123 } else if ( hidden_value == '4' ) {
124 intranet_checked = true;
125 editor_checked = true;
126 } else if ( hidden_value == '5' ) {
127 collapsed_checked = true;
128 } else if ( hidden_value == '6' ) {
129 intranet_checked = true;
130 } else if ( hidden_value == '7' ) {
131 intranet_checked = true;
132 collapsed_checked = true;
133 } // else if ( hidden_value == '8') { skip }
135 $("#hidden_opac_" + tab).prop('checked',opac_checked);
136 $("#hidden_intranet_" + tab).prop('checked',intranet_checked);
137 $("#hidden_editor_" + tab).prop('checked',editor_checked);
138 $("#hidden_collapsed_" + tab).prop('checked',collapsed_checked);
139 $("#hidden_flagged_" + tab).prop('checked',flagged_checked);