##// END OF EJS Templates
Tab buttons appear on pages that have no tabs (#23751)....
Jean-Philippe Lang -
r15471:84ab16dcfe28
parent child
Show More
@@ -1,788 +1,788
1 /* Redmine - project management software
1 /* Redmine - project management software
2 Copyright (C) 2006-2016 Jean-Philippe Lang */
2 Copyright (C) 2006-2016 Jean-Philippe Lang */
3
3
4 function checkAll(id, checked) {
4 function checkAll(id, checked) {
5 $('#'+id).find('input[type=checkbox]:enabled').prop('checked', checked);
5 $('#'+id).find('input[type=checkbox]:enabled').prop('checked', checked);
6 }
6 }
7
7
8 function toggleCheckboxesBySelector(selector) {
8 function toggleCheckboxesBySelector(selector) {
9 var all_checked = true;
9 var all_checked = true;
10 $(selector).each(function(index) {
10 $(selector).each(function(index) {
11 if (!$(this).is(':checked')) { all_checked = false; }
11 if (!$(this).is(':checked')) { all_checked = false; }
12 });
12 });
13 $(selector).prop('checked', !all_checked);
13 $(selector).prop('checked', !all_checked);
14 }
14 }
15
15
16 function showAndScrollTo(id, focus) {
16 function showAndScrollTo(id, focus) {
17 $('#'+id).show();
17 $('#'+id).show();
18 if (focus !== null) {
18 if (focus !== null) {
19 $('#'+focus).focus();
19 $('#'+focus).focus();
20 }
20 }
21 $('html, body').animate({scrollTop: $('#'+id).offset().top}, 100);
21 $('html, body').animate({scrollTop: $('#'+id).offset().top}, 100);
22 }
22 }
23
23
24 function toggleRowGroup(el) {
24 function toggleRowGroup(el) {
25 var tr = $(el).parents('tr').first();
25 var tr = $(el).parents('tr').first();
26 var n = tr.next();
26 var n = tr.next();
27 tr.toggleClass('open');
27 tr.toggleClass('open');
28 while (n.length && !n.hasClass('group')) {
28 while (n.length && !n.hasClass('group')) {
29 n.toggle();
29 n.toggle();
30 n = n.next('tr');
30 n = n.next('tr');
31 }
31 }
32 }
32 }
33
33
34 function collapseAllRowGroups(el) {
34 function collapseAllRowGroups(el) {
35 var tbody = $(el).parents('tbody').first();
35 var tbody = $(el).parents('tbody').first();
36 tbody.children('tr').each(function(index) {
36 tbody.children('tr').each(function(index) {
37 if ($(this).hasClass('group')) {
37 if ($(this).hasClass('group')) {
38 $(this).removeClass('open');
38 $(this).removeClass('open');
39 } else {
39 } else {
40 $(this).hide();
40 $(this).hide();
41 }
41 }
42 });
42 });
43 }
43 }
44
44
45 function expandAllRowGroups(el) {
45 function expandAllRowGroups(el) {
46 var tbody = $(el).parents('tbody').first();
46 var tbody = $(el).parents('tbody').first();
47 tbody.children('tr').each(function(index) {
47 tbody.children('tr').each(function(index) {
48 if ($(this).hasClass('group')) {
48 if ($(this).hasClass('group')) {
49 $(this).addClass('open');
49 $(this).addClass('open');
50 } else {
50 } else {
51 $(this).show();
51 $(this).show();
52 }
52 }
53 });
53 });
54 }
54 }
55
55
56 function toggleAllRowGroups(el) {
56 function toggleAllRowGroups(el) {
57 var tr = $(el).parents('tr').first();
57 var tr = $(el).parents('tr').first();
58 if (tr.hasClass('open')) {
58 if (tr.hasClass('open')) {
59 collapseAllRowGroups(el);
59 collapseAllRowGroups(el);
60 } else {
60 } else {
61 expandAllRowGroups(el);
61 expandAllRowGroups(el);
62 }
62 }
63 }
63 }
64
64
65 function toggleFieldset(el) {
65 function toggleFieldset(el) {
66 var fieldset = $(el).parents('fieldset').first();
66 var fieldset = $(el).parents('fieldset').first();
67 fieldset.toggleClass('collapsed');
67 fieldset.toggleClass('collapsed');
68 fieldset.children('div').toggle();
68 fieldset.children('div').toggle();
69 }
69 }
70
70
71 function hideFieldset(el) {
71 function hideFieldset(el) {
72 var fieldset = $(el).parents('fieldset').first();
72 var fieldset = $(el).parents('fieldset').first();
73 fieldset.toggleClass('collapsed');
73 fieldset.toggleClass('collapsed');
74 fieldset.children('div').hide();
74 fieldset.children('div').hide();
75 }
75 }
76
76
77 // columns selection
77 // columns selection
78 function moveOptions(theSelFrom, theSelTo) {
78 function moveOptions(theSelFrom, theSelTo) {
79 $(theSelFrom).find('option:selected').detach().prop("selected", false).appendTo($(theSelTo));
79 $(theSelFrom).find('option:selected').detach().prop("selected", false).appendTo($(theSelTo));
80 }
80 }
81
81
82 function moveOptionUp(theSel) {
82 function moveOptionUp(theSel) {
83 $(theSel).find('option:selected').each(function(){
83 $(theSel).find('option:selected').each(function(){
84 $(this).prev(':not(:selected)').detach().insertAfter($(this));
84 $(this).prev(':not(:selected)').detach().insertAfter($(this));
85 });
85 });
86 }
86 }
87
87
88 function moveOptionTop(theSel) {
88 function moveOptionTop(theSel) {
89 $(theSel).find('option:selected').detach().prependTo($(theSel));
89 $(theSel).find('option:selected').detach().prependTo($(theSel));
90 }
90 }
91
91
92 function moveOptionDown(theSel) {
92 function moveOptionDown(theSel) {
93 $($(theSel).find('option:selected').get().reverse()).each(function(){
93 $($(theSel).find('option:selected').get().reverse()).each(function(){
94 $(this).next(':not(:selected)').detach().insertBefore($(this));
94 $(this).next(':not(:selected)').detach().insertBefore($(this));
95 });
95 });
96 }
96 }
97
97
98 function moveOptionBottom(theSel) {
98 function moveOptionBottom(theSel) {
99 $(theSel).find('option:selected').detach().appendTo($(theSel));
99 $(theSel).find('option:selected').detach().appendTo($(theSel));
100 }
100 }
101
101
102 function initFilters() {
102 function initFilters() {
103 $('#add_filter_select').change(function() {
103 $('#add_filter_select').change(function() {
104 addFilter($(this).val(), '', []);
104 addFilter($(this).val(), '', []);
105 });
105 });
106 $('#filters-table td.field input[type=checkbox]').each(function() {
106 $('#filters-table td.field input[type=checkbox]').each(function() {
107 toggleFilter($(this).val());
107 toggleFilter($(this).val());
108 });
108 });
109 $('#filters-table').on('click', 'td.field input[type=checkbox]', function() {
109 $('#filters-table').on('click', 'td.field input[type=checkbox]', function() {
110 toggleFilter($(this).val());
110 toggleFilter($(this).val());
111 });
111 });
112 $('#filters-table').on('click', '.toggle-multiselect', function() {
112 $('#filters-table').on('click', '.toggle-multiselect', function() {
113 toggleMultiSelect($(this).siblings('select'));
113 toggleMultiSelect($(this).siblings('select'));
114 });
114 });
115 $('#filters-table').on('keypress', 'input[type=text]', function(e) {
115 $('#filters-table').on('keypress', 'input[type=text]', function(e) {
116 if (e.keyCode == 13) $(this).closest('form').submit();
116 if (e.keyCode == 13) $(this).closest('form').submit();
117 });
117 });
118 }
118 }
119
119
120 function addFilter(field, operator, values) {
120 function addFilter(field, operator, values) {
121 var fieldId = field.replace('.', '_');
121 var fieldId = field.replace('.', '_');
122 var tr = $('#tr_'+fieldId);
122 var tr = $('#tr_'+fieldId);
123 if (tr.length > 0) {
123 if (tr.length > 0) {
124 tr.show();
124 tr.show();
125 } else {
125 } else {
126 buildFilterRow(field, operator, values);
126 buildFilterRow(field, operator, values);
127 }
127 }
128 $('#cb_'+fieldId).prop('checked', true);
128 $('#cb_'+fieldId).prop('checked', true);
129 toggleFilter(field);
129 toggleFilter(field);
130 $('#add_filter_select').val('').find('option').each(function() {
130 $('#add_filter_select').val('').find('option').each(function() {
131 if ($(this).attr('value') == field) {
131 if ($(this).attr('value') == field) {
132 $(this).attr('disabled', true);
132 $(this).attr('disabled', true);
133 }
133 }
134 });
134 });
135 }
135 }
136
136
137 function buildFilterRow(field, operator, values) {
137 function buildFilterRow(field, operator, values) {
138 var fieldId = field.replace('.', '_');
138 var fieldId = field.replace('.', '_');
139 var filterTable = $("#filters-table");
139 var filterTable = $("#filters-table");
140 var filterOptions = availableFilters[field];
140 var filterOptions = availableFilters[field];
141 if (!filterOptions) return;
141 if (!filterOptions) return;
142 var operators = operatorByType[filterOptions['type']];
142 var operators = operatorByType[filterOptions['type']];
143 var filterValues = filterOptions['values'];
143 var filterValues = filterOptions['values'];
144 var i, select;
144 var i, select;
145
145
146 var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html(
146 var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html(
147 '<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' +
147 '<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' +
148 '<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' +
148 '<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' +
149 '<td class="values"></td>'
149 '<td class="values"></td>'
150 );
150 );
151 filterTable.append(tr);
151 filterTable.append(tr);
152
152
153 select = tr.find('td.operator select');
153 select = tr.find('td.operator select');
154 for (i = 0; i < operators.length; i++) {
154 for (i = 0; i < operators.length; i++) {
155 var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]);
155 var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]);
156 if (operators[i] == operator) { option.attr('selected', true); }
156 if (operators[i] == operator) { option.attr('selected', true); }
157 select.append(option);
157 select.append(option);
158 }
158 }
159 select.change(function(){ toggleOperator(field); });
159 select.change(function(){ toggleOperator(field); });
160
160
161 switch (filterOptions['type']) {
161 switch (filterOptions['type']) {
162 case "list":
162 case "list":
163 case "list_optional":
163 case "list_optional":
164 case "list_status":
164 case "list_status":
165 case "list_subprojects":
165 case "list_subprojects":
166 tr.find('td.values').append(
166 tr.find('td.values').append(
167 '<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
167 '<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
168 ' <span class="toggle-multiselect">&nbsp;</span></span>'
168 ' <span class="toggle-multiselect">&nbsp;</span></span>'
169 );
169 );
170 select = tr.find('td.values select');
170 select = tr.find('td.values select');
171 if (values.length > 1) { select.attr('multiple', true); }
171 if (values.length > 1) { select.attr('multiple', true); }
172 for (i = 0; i < filterValues.length; i++) {
172 for (i = 0; i < filterValues.length; i++) {
173 var filterValue = filterValues[i];
173 var filterValue = filterValues[i];
174 var option = $('<option>');
174 var option = $('<option>');
175 if ($.isArray(filterValue)) {
175 if ($.isArray(filterValue)) {
176 option.val(filterValue[1]).text(filterValue[0]);
176 option.val(filterValue[1]).text(filterValue[0]);
177 if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);}
177 if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);}
178 if (filterValue.length == 3) {
178 if (filterValue.length == 3) {
179 var optgroup = select.find('optgroup').filter(function(){return $(this).attr('label') == filterValue[2]});
179 var optgroup = select.find('optgroup').filter(function(){return $(this).attr('label') == filterValue[2]});
180 if (!optgroup.length) {optgroup = $('<optgroup>').attr('label', filterValue[2]);}
180 if (!optgroup.length) {optgroup = $('<optgroup>').attr('label', filterValue[2]);}
181 option = optgroup.append(option);
181 option = optgroup.append(option);
182 }
182 }
183 } else {
183 } else {
184 option.val(filterValue).text(filterValue);
184 option.val(filterValue).text(filterValue);
185 if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
185 if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
186 }
186 }
187 select.append(option);
187 select.append(option);
188 }
188 }
189 break;
189 break;
190 case "date":
190 case "date":
191 case "date_past":
191 case "date_past":
192 tr.find('td.values').append(
192 tr.find('td.values').append(
193 '<span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
193 '<span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
194 ' <span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
194 ' <span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
195 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
195 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
196 );
196 );
197 $('#values_'+fieldId+'_1').val(values[0]).datepickerFallback(datepickerOptions);
197 $('#values_'+fieldId+'_1').val(values[0]).datepickerFallback(datepickerOptions);
198 $('#values_'+fieldId+'_2').val(values[1]).datepickerFallback(datepickerOptions);
198 $('#values_'+fieldId+'_2').val(values[1]).datepickerFallback(datepickerOptions);
199 $('#values_'+fieldId).val(values[0]);
199 $('#values_'+fieldId).val(values[0]);
200 break;
200 break;
201 case "string":
201 case "string":
202 case "text":
202 case "text":
203 tr.find('td.values').append(
203 tr.find('td.values').append(
204 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
204 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
205 );
205 );
206 $('#values_'+fieldId).val(values[0]);
206 $('#values_'+fieldId).val(values[0]);
207 break;
207 break;
208 case "relation":
208 case "relation":
209 tr.find('td.values').append(
209 tr.find('td.values').append(
210 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
210 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
211 '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
211 '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
212 );
212 );
213 $('#values_'+fieldId).val(values[0]);
213 $('#values_'+fieldId).val(values[0]);
214 select = tr.find('td.values select');
214 select = tr.find('td.values select');
215 for (i = 0; i < allProjects.length; i++) {
215 for (i = 0; i < allProjects.length; i++) {
216 var filterValue = allProjects[i];
216 var filterValue = allProjects[i];
217 var option = $('<option>');
217 var option = $('<option>');
218 option.val(filterValue[1]).text(filterValue[0]);
218 option.val(filterValue[1]).text(filterValue[0]);
219 if (values[0] == filterValue[1]) { option.attr('selected', true); }
219 if (values[0] == filterValue[1]) { option.attr('selected', true); }
220 select.append(option);
220 select.append(option);
221 }
221 }
222 break;
222 break;
223 case "integer":
223 case "integer":
224 case "float":
224 case "float":
225 case "tree":
225 case "tree":
226 tr.find('td.values').append(
226 tr.find('td.values').append(
227 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="14" class="value" /></span>' +
227 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="14" class="value" /></span>' +
228 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="14" class="value" /></span>'
228 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="14" class="value" /></span>'
229 );
229 );
230 $('#values_'+fieldId+'_1').val(values[0]);
230 $('#values_'+fieldId+'_1').val(values[0]);
231 $('#values_'+fieldId+'_2').val(values[1]);
231 $('#values_'+fieldId+'_2').val(values[1]);
232 break;
232 break;
233 }
233 }
234 }
234 }
235
235
236 function toggleFilter(field) {
236 function toggleFilter(field) {
237 var fieldId = field.replace('.', '_');
237 var fieldId = field.replace('.', '_');
238 if ($('#cb_' + fieldId).is(':checked')) {
238 if ($('#cb_' + fieldId).is(':checked')) {
239 $("#operators_" + fieldId).show().removeAttr('disabled');
239 $("#operators_" + fieldId).show().removeAttr('disabled');
240 toggleOperator(field);
240 toggleOperator(field);
241 } else {
241 } else {
242 $("#operators_" + fieldId).hide().attr('disabled', true);
242 $("#operators_" + fieldId).hide().attr('disabled', true);
243 enableValues(field, []);
243 enableValues(field, []);
244 }
244 }
245 }
245 }
246
246
247 function enableValues(field, indexes) {
247 function enableValues(field, indexes) {
248 var fieldId = field.replace('.', '_');
248 var fieldId = field.replace('.', '_');
249 $('#tr_'+fieldId+' td.values .value').each(function(index) {
249 $('#tr_'+fieldId+' td.values .value').each(function(index) {
250 if ($.inArray(index, indexes) >= 0) {
250 if ($.inArray(index, indexes) >= 0) {
251 $(this).removeAttr('disabled');
251 $(this).removeAttr('disabled');
252 $(this).parents('span').first().show();
252 $(this).parents('span').first().show();
253 } else {
253 } else {
254 $(this).val('');
254 $(this).val('');
255 $(this).attr('disabled', true);
255 $(this).attr('disabled', true);
256 $(this).parents('span').first().hide();
256 $(this).parents('span').first().hide();
257 }
257 }
258
258
259 if ($(this).hasClass('group')) {
259 if ($(this).hasClass('group')) {
260 $(this).addClass('open');
260 $(this).addClass('open');
261 } else {
261 } else {
262 $(this).show();
262 $(this).show();
263 }
263 }
264 });
264 });
265 }
265 }
266
266
267 function toggleOperator(field) {
267 function toggleOperator(field) {
268 var fieldId = field.replace('.', '_');
268 var fieldId = field.replace('.', '_');
269 var operator = $("#operators_" + fieldId);
269 var operator = $("#operators_" + fieldId);
270 switch (operator.val()) {
270 switch (operator.val()) {
271 case "!*":
271 case "!*":
272 case "*":
272 case "*":
273 case "t":
273 case "t":
274 case "ld":
274 case "ld":
275 case "w":
275 case "w":
276 case "lw":
276 case "lw":
277 case "l2w":
277 case "l2w":
278 case "m":
278 case "m":
279 case "lm":
279 case "lm":
280 case "y":
280 case "y":
281 case "o":
281 case "o":
282 case "c":
282 case "c":
283 case "*o":
283 case "*o":
284 case "!o":
284 case "!o":
285 enableValues(field, []);
285 enableValues(field, []);
286 break;
286 break;
287 case "><":
287 case "><":
288 enableValues(field, [0,1]);
288 enableValues(field, [0,1]);
289 break;
289 break;
290 case "<t+":
290 case "<t+":
291 case ">t+":
291 case ">t+":
292 case "><t+":
292 case "><t+":
293 case "t+":
293 case "t+":
294 case ">t-":
294 case ">t-":
295 case "<t-":
295 case "<t-":
296 case "><t-":
296 case "><t-":
297 case "t-":
297 case "t-":
298 enableValues(field, [2]);
298 enableValues(field, [2]);
299 break;
299 break;
300 case "=p":
300 case "=p":
301 case "=!p":
301 case "=!p":
302 case "!p":
302 case "!p":
303 enableValues(field, [1]);
303 enableValues(field, [1]);
304 break;
304 break;
305 default:
305 default:
306 enableValues(field, [0]);
306 enableValues(field, [0]);
307 break;
307 break;
308 }
308 }
309 }
309 }
310
310
311 function toggleMultiSelect(el) {
311 function toggleMultiSelect(el) {
312 if (el.attr('multiple')) {
312 if (el.attr('multiple')) {
313 el.removeAttr('multiple');
313 el.removeAttr('multiple');
314 el.attr('size', 1);
314 el.attr('size', 1);
315 } else {
315 } else {
316 el.attr('multiple', true);
316 el.attr('multiple', true);
317 if (el.children().length > 10)
317 if (el.children().length > 10)
318 el.attr('size', 10);
318 el.attr('size', 10);
319 else
319 else
320 el.attr('size', 4);
320 el.attr('size', 4);
321 }
321 }
322 }
322 }
323
323
324 function showTab(name, url) {
324 function showTab(name, url) {
325 $('#tab-content-' + name).parent().find('.tab-content').hide();
325 $('#tab-content-' + name).parent().find('.tab-content').hide();
326 $('#tab-content-' + name).parent().find('div.tabs a').removeClass('selected');
326 $('#tab-content-' + name).parent().find('div.tabs a').removeClass('selected');
327 $('#tab-content-' + name).show();
327 $('#tab-content-' + name).show();
328 $('#tab-' + name).addClass('selected');
328 $('#tab-' + name).addClass('selected');
329 //replaces current URL with the "href" attribute of the current link
329 //replaces current URL with the "href" attribute of the current link
330 //(only triggered if supported by browser)
330 //(only triggered if supported by browser)
331 if ("replaceState" in window.history) {
331 if ("replaceState" in window.history) {
332 window.history.replaceState(null, document.title, url);
332 window.history.replaceState(null, document.title, url);
333 }
333 }
334 return false;
334 return false;
335 }
335 }
336
336
337 function moveTabRight(el) {
337 function moveTabRight(el) {
338 var lis = $(el).parents('div.tabs').first().find('ul').children();
338 var lis = $(el).parents('div.tabs').first().find('ul').children();
339 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
339 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
340 var tabsWidth = 0;
340 var tabsWidth = 0;
341 var i = 0;
341 var i = 0;
342 lis.each(function() {
342 lis.each(function() {
343 if ($(this).is(':visible')) {
343 if ($(this).is(':visible')) {
344 tabsWidth += $(this).outerWidth(true);
344 tabsWidth += $(this).outerWidth(true);
345 }
345 }
346 });
346 });
347 if (tabsWidth < $(el).parents('div.tabs').first().width() - bw) { return; }
347 if (tabsWidth < $(el).parents('div.tabs').first().width() - bw) { return; }
348 $(el).siblings('.tab-left').removeClass('disabled');
348 $(el).siblings('.tab-left').removeClass('disabled');
349 while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
349 while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
350 var w = lis.eq(i).width();
350 var w = lis.eq(i).width();
351 lis.eq(i).hide();
351 lis.eq(i).hide();
352 if (tabsWidth - w < $(el).parents('div.tabs').first().width() - bw) {
352 if (tabsWidth - w < $(el).parents('div.tabs').first().width() - bw) {
353 $(el).addClass('disabled');
353 $(el).addClass('disabled');
354 }
354 }
355 }
355 }
356
356
357 function moveTabLeft(el) {
357 function moveTabLeft(el) {
358 var lis = $(el).parents('div.tabs').first().find('ul').children();
358 var lis = $(el).parents('div.tabs').first().find('ul').children();
359 var i = 0;
359 var i = 0;
360 while (i < lis.length && !lis.eq(i).is(':visible')) { i++; }
360 while (i < lis.length && !lis.eq(i).is(':visible')) { i++; }
361 if (i > 0) {
361 if (i > 0) {
362 lis.eq(i-1).show();
362 lis.eq(i-1).show();
363 $(el).siblings('.tab-right').removeClass('disabled');
363 $(el).siblings('.tab-right').removeClass('disabled');
364 }
364 }
365 if (i <= 1) {
365 if (i <= 1) {
366 $(el).addClass('disabled');
366 $(el).addClass('disabled');
367 }
367 }
368 }
368 }
369
369
370 function displayTabsButtons() {
370 function displayTabsButtons() {
371 var lis;
371 var lis;
372 var tabsWidth;
372 var tabsWidth;
373 var el;
373 var el;
374 var numHidden;
374 var numHidden;
375 $('div.tabs').each(function() {
375 $('div.tabs').each(function() {
376 el = $(this);
376 el = $(this);
377 lis = el.find('ul').children();
377 lis = el.find('ul').children();
378 tabsWidth = 0;
378 tabsWidth = 0;
379 numHidden = 0;
379 numHidden = 0;
380 lis.each(function(){
380 lis.each(function(){
381 if ($(this).is(':visible')) {
381 if ($(this).is(':visible')) {
382 tabsWidth += $(this).outerWidth(true);
382 tabsWidth += $(this).outerWidth(true);
383 } else {
383 } else {
384 numHidden++;
384 numHidden++;
385 }
385 }
386 });
386 });
387 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
387 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
388 if ((tabsWidth < el.width() - bw) && (lis.first().is(':visible'))) {
388 if ((tabsWidth < el.width() - bw) && (lis.length === 0 || lis.first().is(':visible'))) {
389 el.find('div.tabs-buttons').hide();
389 el.find('div.tabs-buttons').hide();
390 } else {
390 } else {
391 el.find('div.tabs-buttons').show().children('button.tab-left').toggleClass('disabled', numHidden == 0);
391 el.find('div.tabs-buttons').show().children('button.tab-left').toggleClass('disabled', numHidden == 0);
392 }
392 }
393 });
393 });
394 }
394 }
395
395
396 function setPredecessorFieldsVisibility() {
396 function setPredecessorFieldsVisibility() {
397 var relationType = $('#relation_relation_type');
397 var relationType = $('#relation_relation_type');
398 if (relationType.val() == "precedes" || relationType.val() == "follows") {
398 if (relationType.val() == "precedes" || relationType.val() == "follows") {
399 $('#predecessor_fields').show();
399 $('#predecessor_fields').show();
400 } else {
400 } else {
401 $('#predecessor_fields').hide();
401 $('#predecessor_fields').hide();
402 }
402 }
403 }
403 }
404
404
405 function showModal(id, width, title) {
405 function showModal(id, width, title) {
406 var el = $('#'+id).first();
406 var el = $('#'+id).first();
407 if (el.length === 0 || el.is(':visible')) {return;}
407 if (el.length === 0 || el.is(':visible')) {return;}
408 if (!title) title = el.find('h3.title').text();
408 if (!title) title = el.find('h3.title').text();
409 // moves existing modals behind the transparent background
409 // moves existing modals behind the transparent background
410 $(".modal").zIndex(99);
410 $(".modal").zIndex(99);
411 el.dialog({
411 el.dialog({
412 width: width,
412 width: width,
413 modal: true,
413 modal: true,
414 resizable: false,
414 resizable: false,
415 dialogClass: 'modal',
415 dialogClass: 'modal',
416 title: title
416 title: title
417 }).on('dialogclose', function(){
417 }).on('dialogclose', function(){
418 $(".modal").zIndex(101);
418 $(".modal").zIndex(101);
419 });
419 });
420 el.find("input[type=text], input[type=submit]").first().focus();
420 el.find("input[type=text], input[type=submit]").first().focus();
421 }
421 }
422
422
423 function hideModal(el) {
423 function hideModal(el) {
424 var modal;
424 var modal;
425 if (el) {
425 if (el) {
426 modal = $(el).parents('.ui-dialog-content');
426 modal = $(el).parents('.ui-dialog-content');
427 } else {
427 } else {
428 modal = $('#ajax-modal');
428 modal = $('#ajax-modal');
429 }
429 }
430 modal.dialog("close");
430 modal.dialog("close");
431 }
431 }
432
432
433 function submitPreview(url, form, target) {
433 function submitPreview(url, form, target) {
434 $.ajax({
434 $.ajax({
435 url: url,
435 url: url,
436 type: 'post',
436 type: 'post',
437 data: $('#'+form).serialize(),
437 data: $('#'+form).serialize(),
438 success: function(data){
438 success: function(data){
439 $('#'+target).html(data);
439 $('#'+target).html(data);
440 }
440 }
441 });
441 });
442 }
442 }
443
443
444 function collapseScmEntry(id) {
444 function collapseScmEntry(id) {
445 $('.'+id).each(function() {
445 $('.'+id).each(function() {
446 if ($(this).hasClass('open')) {
446 if ($(this).hasClass('open')) {
447 collapseScmEntry($(this).attr('id'));
447 collapseScmEntry($(this).attr('id'));
448 }
448 }
449 $(this).hide();
449 $(this).hide();
450 });
450 });
451 $('#'+id).removeClass('open');
451 $('#'+id).removeClass('open');
452 }
452 }
453
453
454 function expandScmEntry(id) {
454 function expandScmEntry(id) {
455 $('.'+id).each(function() {
455 $('.'+id).each(function() {
456 $(this).show();
456 $(this).show();
457 if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
457 if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
458 expandScmEntry($(this).attr('id'));
458 expandScmEntry($(this).attr('id'));
459 }
459 }
460 });
460 });
461 $('#'+id).addClass('open');
461 $('#'+id).addClass('open');
462 }
462 }
463
463
464 function scmEntryClick(id, url) {
464 function scmEntryClick(id, url) {
465 var el = $('#'+id);
465 var el = $('#'+id);
466 if (el.hasClass('open')) {
466 if (el.hasClass('open')) {
467 collapseScmEntry(id);
467 collapseScmEntry(id);
468 el.addClass('collapsed');
468 el.addClass('collapsed');
469 return false;
469 return false;
470 } else if (el.hasClass('loaded')) {
470 } else if (el.hasClass('loaded')) {
471 expandScmEntry(id);
471 expandScmEntry(id);
472 el.removeClass('collapsed');
472 el.removeClass('collapsed');
473 return false;
473 return false;
474 }
474 }
475 if (el.hasClass('loading')) {
475 if (el.hasClass('loading')) {
476 return false;
476 return false;
477 }
477 }
478 el.addClass('loading');
478 el.addClass('loading');
479 $.ajax({
479 $.ajax({
480 url: url,
480 url: url,
481 success: function(data) {
481 success: function(data) {
482 el.after(data);
482 el.after(data);
483 el.addClass('open').addClass('loaded').removeClass('loading');
483 el.addClass('open').addClass('loaded').removeClass('loading');
484 }
484 }
485 });
485 });
486 return true;
486 return true;
487 }
487 }
488
488
489 function randomKey(size) {
489 function randomKey(size) {
490 var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
490 var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
491 var key = '';
491 var key = '';
492 for (var i = 0; i < size; i++) {
492 for (var i = 0; i < size; i++) {
493 key += chars.charAt(Math.floor(Math.random() * chars.length));
493 key += chars.charAt(Math.floor(Math.random() * chars.length));
494 }
494 }
495 return key;
495 return key;
496 }
496 }
497
497
498 function updateIssueFrom(url, el) {
498 function updateIssueFrom(url, el) {
499 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
499 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
500 $(this).data('valuebeforeupdate', $(this).val());
500 $(this).data('valuebeforeupdate', $(this).val());
501 });
501 });
502 if (el) {
502 if (el) {
503 $("#form_update_triggered_by").val($(el).attr('id'));
503 $("#form_update_triggered_by").val($(el).attr('id'));
504 }
504 }
505 return $.ajax({
505 return $.ajax({
506 url: url,
506 url: url,
507 type: 'post',
507 type: 'post',
508 data: $('#issue-form').serialize()
508 data: $('#issue-form').serialize()
509 });
509 });
510 }
510 }
511
511
512 function replaceIssueFormWith(html){
512 function replaceIssueFormWith(html){
513 var replacement = $(html);
513 var replacement = $(html);
514 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
514 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
515 var object_id = $(this).attr('id');
515 var object_id = $(this).attr('id');
516 if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) {
516 if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) {
517 replacement.find('#'+object_id).val($(this).val());
517 replacement.find('#'+object_id).val($(this).val());
518 }
518 }
519 });
519 });
520 $('#all_attributes').empty();
520 $('#all_attributes').empty();
521 $('#all_attributes').prepend(replacement);
521 $('#all_attributes').prepend(replacement);
522 }
522 }
523
523
524 function updateBulkEditFrom(url) {
524 function updateBulkEditFrom(url) {
525 $.ajax({
525 $.ajax({
526 url: url,
526 url: url,
527 type: 'post',
527 type: 'post',
528 data: $('#bulk_edit_form').serialize()
528 data: $('#bulk_edit_form').serialize()
529 });
529 });
530 }
530 }
531
531
532 function observeAutocompleteField(fieldId, url, options) {
532 function observeAutocompleteField(fieldId, url, options) {
533 $(document).ready(function() {
533 $(document).ready(function() {
534 $('#'+fieldId).autocomplete($.extend({
534 $('#'+fieldId).autocomplete($.extend({
535 source: url,
535 source: url,
536 minLength: 2,
536 minLength: 2,
537 position: {collision: "flipfit"},
537 position: {collision: "flipfit"},
538 search: function(){$('#'+fieldId).addClass('ajax-loading');},
538 search: function(){$('#'+fieldId).addClass('ajax-loading');},
539 response: function(){$('#'+fieldId).removeClass('ajax-loading');}
539 response: function(){$('#'+fieldId).removeClass('ajax-loading');}
540 }, options));
540 }, options));
541 $('#'+fieldId).addClass('autocomplete');
541 $('#'+fieldId).addClass('autocomplete');
542 });
542 });
543 }
543 }
544
544
545 function observeSearchfield(fieldId, targetId, url) {
545 function observeSearchfield(fieldId, targetId, url) {
546 $('#'+fieldId).each(function() {
546 $('#'+fieldId).each(function() {
547 var $this = $(this);
547 var $this = $(this);
548 $this.addClass('autocomplete');
548 $this.addClass('autocomplete');
549 $this.attr('data-value-was', $this.val());
549 $this.attr('data-value-was', $this.val());
550 var check = function() {
550 var check = function() {
551 var val = $this.val();
551 var val = $this.val();
552 if ($this.attr('data-value-was') != val){
552 if ($this.attr('data-value-was') != val){
553 $this.attr('data-value-was', val);
553 $this.attr('data-value-was', val);
554 $.ajax({
554 $.ajax({
555 url: url,
555 url: url,
556 type: 'get',
556 type: 'get',
557 data: {q: $this.val()},
557 data: {q: $this.val()},
558 success: function(data){ if(targetId) $('#'+targetId).html(data); },
558 success: function(data){ if(targetId) $('#'+targetId).html(data); },
559 beforeSend: function(){ $this.addClass('ajax-loading'); },
559 beforeSend: function(){ $this.addClass('ajax-loading'); },
560 complete: function(){ $this.removeClass('ajax-loading'); }
560 complete: function(){ $this.removeClass('ajax-loading'); }
561 });
561 });
562 }
562 }
563 };
563 };
564 var reset = function() {
564 var reset = function() {
565 if (timer) {
565 if (timer) {
566 clearInterval(timer);
566 clearInterval(timer);
567 timer = setInterval(check, 300);
567 timer = setInterval(check, 300);
568 }
568 }
569 };
569 };
570 var timer = setInterval(check, 300);
570 var timer = setInterval(check, 300);
571 $this.bind('keyup click mousemove', reset);
571 $this.bind('keyup click mousemove', reset);
572 });
572 });
573 }
573 }
574
574
575 function beforeShowDatePicker(input, inst) {
575 function beforeShowDatePicker(input, inst) {
576 var default_date = null;
576 var default_date = null;
577 switch ($(input).attr("id")) {
577 switch ($(input).attr("id")) {
578 case "issue_start_date" :
578 case "issue_start_date" :
579 if ($("#issue_due_date").size() > 0) {
579 if ($("#issue_due_date").size() > 0) {
580 default_date = $("#issue_due_date").val();
580 default_date = $("#issue_due_date").val();
581 }
581 }
582 break;
582 break;
583 case "issue_due_date" :
583 case "issue_due_date" :
584 if ($("#issue_start_date").size() > 0) {
584 if ($("#issue_start_date").size() > 0) {
585 var start_date = $("#issue_start_date").val();
585 var start_date = $("#issue_start_date").val();
586 if (start_date != "") {
586 if (start_date != "") {
587 start_date = new Date(Date.parse(start_date));
587 start_date = new Date(Date.parse(start_date));
588 if (start_date > new Date()) {
588 if (start_date > new Date()) {
589 default_date = $("#issue_start_date").val();
589 default_date = $("#issue_start_date").val();
590 }
590 }
591 }
591 }
592 }
592 }
593 break;
593 break;
594 }
594 }
595 $(input).datepickerFallback("option", "defaultDate", default_date);
595 $(input).datepickerFallback("option", "defaultDate", default_date);
596 }
596 }
597
597
598 (function($){
598 (function($){
599 $.fn.positionedItems = function(sortableOptions, options){
599 $.fn.positionedItems = function(sortableOptions, options){
600 var settings = $.extend({
600 var settings = $.extend({
601 firstPosition: 1
601 firstPosition: 1
602 }, options );
602 }, options );
603
603
604 return this.sortable($.extend({
604 return this.sortable($.extend({
605 handle: ".sort-handle",
605 handle: ".sort-handle",
606 helper: function(event, ui){
606 helper: function(event, ui){
607 ui.children('td').each(function(){
607 ui.children('td').each(function(){
608 $(this).width($(this).width());
608 $(this).width($(this).width());
609 });
609 });
610 return ui;
610 return ui;
611 },
611 },
612 update: function(event, ui) {
612 update: function(event, ui) {
613 var sortable = $(this);
613 var sortable = $(this);
614 var handle = ui.item.find(".sort-handle").addClass("ajax-loading");
614 var handle = ui.item.find(".sort-handle").addClass("ajax-loading");
615 var url = handle.data("reorder-url");
615 var url = handle.data("reorder-url");
616 var param = handle.data("reorder-param");
616 var param = handle.data("reorder-param");
617 var data = {};
617 var data = {};
618 data[param] = {position: ui.item.index() + settings['firstPosition']};
618 data[param] = {position: ui.item.index() + settings['firstPosition']};
619 $.ajax({
619 $.ajax({
620 url: url,
620 url: url,
621 type: 'put',
621 type: 'put',
622 dataType: 'script',
622 dataType: 'script',
623 data: data,
623 data: data,
624 success: function(data){
624 success: function(data){
625 sortable.children(":even").removeClass("even").addClass("odd");
625 sortable.children(":even").removeClass("even").addClass("odd");
626 sortable.children(":odd").removeClass("odd").addClass("even");
626 sortable.children(":odd").removeClass("odd").addClass("even");
627 },
627 },
628 error: function(jqXHR, textStatus, errorThrown){
628 error: function(jqXHR, textStatus, errorThrown){
629 alert(jqXHR.status);
629 alert(jqXHR.status);
630 sortable.sortable("cancel");
630 sortable.sortable("cancel");
631 },
631 },
632 complete: function(jqXHR, textStatus, errorThrown){
632 complete: function(jqXHR, textStatus, errorThrown){
633 handle.removeClass("ajax-loading");
633 handle.removeClass("ajax-loading");
634 }
634 }
635 });
635 });
636 },
636 },
637 }, sortableOptions));
637 }, sortableOptions));
638 }
638 }
639 }( jQuery ));
639 }( jQuery ));
640
640
641 function initMyPageSortable(list, url) {
641 function initMyPageSortable(list, url) {
642 $('#list-'+list).sortable({
642 $('#list-'+list).sortable({
643 connectWith: '.block-receiver',
643 connectWith: '.block-receiver',
644 tolerance: 'pointer',
644 tolerance: 'pointer',
645 update: function(){
645 update: function(){
646 $.ajax({
646 $.ajax({
647 url: url,
647 url: url,
648 type: 'post',
648 type: 'post',
649 data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
649 data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
650 });
650 });
651 }
651 }
652 });
652 });
653 $("#list-top, #list-left, #list-right").disableSelection();
653 $("#list-top, #list-left, #list-right").disableSelection();
654 }
654 }
655
655
656 var warnLeavingUnsavedMessage;
656 var warnLeavingUnsavedMessage;
657 function warnLeavingUnsaved(message) {
657 function warnLeavingUnsaved(message) {
658 warnLeavingUnsavedMessage = message;
658 warnLeavingUnsavedMessage = message;
659 $(document).on('submit', 'form', function(){
659 $(document).on('submit', 'form', function(){
660 $('textarea').removeData('changed');
660 $('textarea').removeData('changed');
661 });
661 });
662 $(document).on('change', 'textarea', function(){
662 $(document).on('change', 'textarea', function(){
663 $(this).data('changed', 'changed');
663 $(this).data('changed', 'changed');
664 });
664 });
665 window.onbeforeunload = function(){
665 window.onbeforeunload = function(){
666 var warn = false;
666 var warn = false;
667 $('textarea').blur().each(function(){
667 $('textarea').blur().each(function(){
668 if ($(this).data('changed')) {
668 if ($(this).data('changed')) {
669 warn = true;
669 warn = true;
670 }
670 }
671 });
671 });
672 if (warn) {return warnLeavingUnsavedMessage;}
672 if (warn) {return warnLeavingUnsavedMessage;}
673 };
673 };
674 }
674 }
675
675
676 function setupAjaxIndicator() {
676 function setupAjaxIndicator() {
677 $(document).bind('ajaxSend', function(event, xhr, settings) {
677 $(document).bind('ajaxSend', function(event, xhr, settings) {
678 if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
678 if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
679 $('#ajax-indicator').show();
679 $('#ajax-indicator').show();
680 }
680 }
681 });
681 });
682 $(document).bind('ajaxStop', function() {
682 $(document).bind('ajaxStop', function() {
683 $('#ajax-indicator').hide();
683 $('#ajax-indicator').hide();
684 });
684 });
685 }
685 }
686
686
687 function setupTabs() {
687 function setupTabs() {
688 if($('.tabs').length > 0) {
688 if($('.tabs').length > 0) {
689 displayTabsButtons();
689 displayTabsButtons();
690 $(window).resize(displayTabsButtons);
690 $(window).resize(displayTabsButtons);
691 }
691 }
692 }
692 }
693
693
694 function hideOnLoad() {
694 function hideOnLoad() {
695 $('.hol').hide();
695 $('.hol').hide();
696 }
696 }
697
697
698 function addFormObserversForDoubleSubmit() {
698 function addFormObserversForDoubleSubmit() {
699 $('form[method=post]').each(function() {
699 $('form[method=post]').each(function() {
700 if (!$(this).hasClass('multiple-submit')) {
700 if (!$(this).hasClass('multiple-submit')) {
701 $(this).submit(function(form_submission) {
701 $(this).submit(function(form_submission) {
702 if ($(form_submission.target).attr('data-submitted')) {
702 if ($(form_submission.target).attr('data-submitted')) {
703 form_submission.preventDefault();
703 form_submission.preventDefault();
704 } else {
704 } else {
705 $(form_submission.target).attr('data-submitted', true);
705 $(form_submission.target).attr('data-submitted', true);
706 }
706 }
707 });
707 });
708 }
708 }
709 });
709 });
710 }
710 }
711
711
712 function defaultFocus(){
712 function defaultFocus(){
713 if (($('#content :focus').length == 0) && (window.location.hash == '')) {
713 if (($('#content :focus').length == 0) && (window.location.hash == '')) {
714 $('#content input[type=text], #content textarea').first().focus();
714 $('#content input[type=text], #content textarea').first().focus();
715 }
715 }
716 }
716 }
717
717
718 function blockEventPropagation(event) {
718 function blockEventPropagation(event) {
719 event.stopPropagation();
719 event.stopPropagation();
720 event.preventDefault();
720 event.preventDefault();
721 }
721 }
722
722
723 function toggleDisabledOnChange() {
723 function toggleDisabledOnChange() {
724 var checked = $(this).is(':checked');
724 var checked = $(this).is(':checked');
725 $($(this).data('disables')).attr('disabled', checked);
725 $($(this).data('disables')).attr('disabled', checked);
726 $($(this).data('enables')).attr('disabled', !checked);
726 $($(this).data('enables')).attr('disabled', !checked);
727 $($(this).data('shows')).toggle(checked);
727 $($(this).data('shows')).toggle(checked);
728 }
728 }
729 function toggleDisabledInit() {
729 function toggleDisabledInit() {
730 $('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
730 $('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
731 }
731 }
732
732
733 function toggleNewObjectDropdown() {
733 function toggleNewObjectDropdown() {
734 var dropdown = $('#new-object + ul.menu-children');
734 var dropdown = $('#new-object + ul.menu-children');
735 if(dropdown.hasClass('visible')){
735 if(dropdown.hasClass('visible')){
736 dropdown.removeClass('visible');
736 dropdown.removeClass('visible');
737 }else{
737 }else{
738 dropdown.addClass('visible');
738 dropdown.addClass('visible');
739 }
739 }
740 }
740 }
741
741
742 (function ( $ ) {
742 (function ( $ ) {
743
743
744 // detect if native date input is supported
744 // detect if native date input is supported
745 var nativeDateInputSupported = true;
745 var nativeDateInputSupported = true;
746
746
747 var input = document.createElement('input');
747 var input = document.createElement('input');
748 input.setAttribute('type','date');
748 input.setAttribute('type','date');
749 if (input.type === 'text') {
749 if (input.type === 'text') {
750 nativeDateInputSupported = false;
750 nativeDateInputSupported = false;
751 }
751 }
752
752
753 var notADateValue = 'not-a-date';
753 var notADateValue = 'not-a-date';
754 input.setAttribute('value', notADateValue);
754 input.setAttribute('value', notADateValue);
755 if (input.value === notADateValue) {
755 if (input.value === notADateValue) {
756 nativeDateInputSupported = false;
756 nativeDateInputSupported = false;
757 }
757 }
758
758
759 $.fn.datepickerFallback = function( options ) {
759 $.fn.datepickerFallback = function( options ) {
760 if (nativeDateInputSupported) {
760 if (nativeDateInputSupported) {
761 return this;
761 return this;
762 } else {
762 } else {
763 return this.datepicker( options );
763 return this.datepicker( options );
764 }
764 }
765 };
765 };
766 }( jQuery ));
766 }( jQuery ));
767
767
768 $(document).ready(function(){
768 $(document).ready(function(){
769 $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
769 $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
770 toggleDisabledInit();
770 toggleDisabledInit();
771 });
771 });
772
772
773 function keepAnchorOnSignIn(form){
773 function keepAnchorOnSignIn(form){
774 var hash = decodeURIComponent(self.document.location.hash);
774 var hash = decodeURIComponent(self.document.location.hash);
775 if (hash) {
775 if (hash) {
776 if (hash.indexOf("#") === -1) {
776 if (hash.indexOf("#") === -1) {
777 hash = "#" + hash;
777 hash = "#" + hash;
778 }
778 }
779 form.action = form.action + hash;
779 form.action = form.action + hash;
780 }
780 }
781 return true;
781 return true;
782 }
782 }
783
783
784 $(document).ready(setupAjaxIndicator);
784 $(document).ready(setupAjaxIndicator);
785 $(document).ready(hideOnLoad);
785 $(document).ready(hideOnLoad);
786 $(document).ready(addFormObserversForDoubleSubmit);
786 $(document).ready(addFormObserversForDoubleSubmit);
787 $(document).ready(defaultFocus);
787 $(document).ready(defaultFocus);
788 $(document).ready(setupTabs);
788 $(document).ready(setupTabs);
General Comments 0
You need to be logged in to leave comments. Login now