|
22 | 22 | //= require_tree ./locale |
23 | 23 | //= require gettext/all |
24 | 24 | //= require jquery-accessible-autocomplet-list-aria.js |
25 | | - |
26 | | - |
27 | | -$( document ).ready(function() { |
28 | | - |
29 | | - $(function(){ |
30 | | - $('.dropdown-toggle').dropdown() |
31 | | - }); |
32 | | - |
33 | | - $('.accordion-body').on('show', function() { |
34 | | - var plus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-plus").removeClass("icon-plus").addClass("icon-minus"); |
35 | | - }).on('hide', function(){ |
36 | | - var minus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-minus").removeClass("icon-minus").addClass("icon-plus"); |
37 | | - }); |
38 | | - |
39 | | - //accordion home page |
40 | | - $('.accordion-home').on('show', function() { |
41 | | - var plus = $(this).parent().find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja"); |
42 | | - }).on('hide', function(){ |
43 | | - var minus = $(this).parent().find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja"); |
44 | | - }); |
45 | | - |
46 | | - //accordion project details page when project has more than 1 plan |
47 | | - $('.accordion-project').on('show', function() { |
48 | | - var plus = $(this).parent().children(".accordion-heading").find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja"); |
49 | | - }).on('hide', function(){ |
50 | | - var minus = $(this).parent().children(".accordion-heading").find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja"); |
51 | | - }); |
52 | | - |
53 | | - $('.export-format-selection').click(function(e){ |
54 | | - e.preventDefault(); |
55 | | - if($(this).val() == 'pdf'){ |
56 | | - $('#pdf-format-options').show(); |
57 | | - }else{ |
58 | | - $('#pdf-format-options').hide(); |
59 | | - } |
60 | | - }); |
61 | | - |
62 | | - //$('#3-or-4-splash').modal(); |
63 | | - |
64 | | - $('.typeahead').select2({ |
65 | | - width: "element", |
66 | | - allowClear: true |
67 | | - }); |
68 | | - |
69 | | - $(".help").popover(); |
70 | | - |
71 | | - $('.has-tooltip').tooltip({ |
72 | | - placement: "right", |
73 | | - trigger: "focus" |
74 | | - }); |
75 | | - |
76 | | - $(".show-edit-toggle").click(function (e) { |
77 | | - e.preventDefault(); |
78 | | - |
79 | | - $(".edit-plan-details").toggle(); |
80 | | - $(".show-plan-details").toggle(); |
81 | | - }); |
82 | | - |
83 | | - $(".toggle-existing-user-access").change(function(){ |
84 | | - $(this).closest("form").submit(); |
85 | | - }); |
86 | | - |
87 | | - $('#user_organisation_id').on("change", function(e) { |
88 | | - e.preventDefault(); |
89 | | - var selected_org = $(this).select2("val"); |
90 | | - var other_orgs = $("#other-organisation-name").attr("data-orgs").split(","); |
91 | | - var index = $.inArray(selected_org, other_orgs); |
92 | | - if (index > -1) { |
93 | | - $("#other-organisation-name").show(); |
94 | | - $("#user_other_organisation").focus(); |
95 | | - } |
96 | | - else { |
97 | | - $("#other-organisation-name").hide(); |
98 | | - } |
99 | | - }); |
100 | | - |
101 | | - $("#other-org-link > a").click(function(e){ |
102 | | - e.preventDefault(); |
103 | | - var other_org = $("#other-organisation-name").attr("data-orgs").split(","); |
104 | | - $("#user_organisation_id").select2("val", other_org); |
105 | | - $("#other-org-link").hide(); |
106 | | - $("#user_organisation_id").change(); |
107 | | - }); |
108 | | - |
109 | | - //alert dialog for unlink Shibbileth account |
110 | | - $("#unlink-institutional-credentials-dialog").on("show", function(){ |
111 | | - $('.select2-choice').hide(); |
112 | | - }); |
113 | | - |
114 | | - $("#unlink-shibboleth-cancelled").click(function (){ |
115 | | - $("#unlink-institutional-credentials-dialog").modal("hide"); |
116 | | - $('.select2-choice').show(); |
117 | | - }); |
118 | | - |
119 | | - $("#unlink-shibboleth-confirmed").click(function (){ |
120 | | - $("#unlink_flag").val('true'); |
121 | | - $("#edit_user").submit(); |
122 | | - |
123 | | - }); |
124 | | - |
125 | | - //Question Options |
126 | | - // --------------------------------------------------------------------------- |
127 | | - $(".options_table").on("click", ".remove-option", function(e){ |
128 | | - e.preventDefault(); |
129 | | - |
130 | | - // Mark the option for removal |
131 | | - $($(this).siblings()[0]).val(true); |
132 | | - |
133 | | - // Hide the entire table row and the associated hidden field for the item |
134 | | - $(this).parent().parent().addClass('hidden'); |
135 | | - }); |
136 | | - |
137 | | - $(".add-option").click(function(e){ |
138 | | - e.preventDefault(); |
139 | | - |
140 | | - var tbl = $(this).parent().find("table.options_table > tbody.options_tbody"), |
141 | | - last = tbl.find("tr:last"), |
142 | | - clone = last.clone(); |
143 | | - nbr = parseInt(last.find(".number_field").val()); |
144 | | - |
145 | | - // Update the input field names and ids |
146 | | - clone.find("input").each(function(index){ |
147 | | - $(this).prop("id", $(this).prop("id").replace(/_\d+_/g, "_" + nbr + "_")); |
148 | | - $(this).prop("name", $(this).prop("name").replace(/\[\d+\]/g, "[" + nbr + "]")); |
149 | | - }); |
150 | | - |
151 | | - // Remove the hidden class and make sure the new row is not marked for removal |
152 | | - clone.removeClass('hidden'); |
153 | | - clone.find("[id$=" + nbr + "__destroy]").val(false); |
154 | | - |
155 | | - // Default the other values |
156 | | - clone.find("[id$=" + nbr + "_number]").val("" + (nbr + 1)); |
157 | | - clone.find("[id$=" + nbr + "_text]").val(""); |
158 | | - clone.find("[id$=" + nbr + "_is_default]").prop("checked", false); |
159 | | - |
160 | | - last.after(clone); |
161 | | - }); |
162 | | - |
163 | | - /*$('#continue-to-new').click(function(e){ |
164 | | - var destination = $(this).attr("href"); |
165 | | - var n = destination.lastIndexOf('='); |
166 | | - destination = decodeURIComponent(destination.substring(n + 1)); |
167 | | - $.post('splash_logs', {destination: destination} ); |
168 | | - $("#3-or-4-splash").modal('hide'); |
169 | | - return false; |
170 | | - });*/ |
171 | | - |
172 | | -}); |
173 | | - |
174 | | -// --------------------------------------------------------------------------- |
175 | | -function selectItemsFromJsonArray(array, selector, array_of_values, callback){ |
176 | | - var out = []; |
177 | | - |
178 | | - if(!Array.isArray(array_of_values)){ |
179 | | - array_of_values = [array_of_values]; |
180 | | - } |
181 | | - |
182 | | - for(var i = 0; i < array.length; i++){ |
183 | | - if(array_of_values.indexOf('' + array[i][selector]) >= 0){ |
184 | | - out.push(array[i]); |
185 | | - } |
186 | | - } |
187 | | - |
188 | | - var selectItemsFromJsonArrayInterval = setInterval(function(){ |
189 | | - if(i >= array.length){ |
190 | | - clearInterval(selectItemsFromJsonArrayInterval); |
191 | | - callback(out); |
192 | | - } |
193 | | - }, 50); |
194 | | -} |
| 25 | +//= require bootstrap_listeners.js |
0 commit comments