##// END OF EJS Templates
Merged r15996 (#24062)....
Jean-Philippe Lang -
r15666:202285ea8b57
parent child
Show More
@@ -1,783 +1,784
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 } else {
178 } else {
179 option.val(filterValue).text(filterValue);
179 option.val(filterValue).text(filterValue);
180 if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
180 if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
181 }
181 }
182 select.append(option);
182 select.append(option);
183 }
183 }
184 break;
184 break;
185 case "date":
185 case "date":
186 case "date_past":
186 case "date_past":
187 tr.find('td.values').append(
187 tr.find('td.values').append(
188 '<span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
188 '<span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
189 ' <span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
189 ' <span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
190 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
190 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
191 );
191 );
192 $('#values_'+fieldId+'_1').val(values[0]).datepickerFallback(datepickerOptions);
192 $('#values_'+fieldId+'_1').val(values[0]).datepickerFallback(datepickerOptions);
193 $('#values_'+fieldId+'_2').val(values[1]).datepickerFallback(datepickerOptions);
193 $('#values_'+fieldId+'_2').val(values[1]).datepickerFallback(datepickerOptions);
194 $('#values_'+fieldId).val(values[0]);
194 $('#values_'+fieldId).val(values[0]);
195 break;
195 break;
196 case "string":
196 case "string":
197 case "text":
197 case "text":
198 tr.find('td.values').append(
198 tr.find('td.values').append(
199 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
199 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
200 );
200 );
201 $('#values_'+fieldId).val(values[0]);
201 $('#values_'+fieldId).val(values[0]);
202 break;
202 break;
203 case "relation":
203 case "relation":
204 tr.find('td.values').append(
204 tr.find('td.values').append(
205 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
205 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
206 '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
206 '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
207 );
207 );
208 $('#values_'+fieldId).val(values[0]);
208 $('#values_'+fieldId).val(values[0]);
209 select = tr.find('td.values select');
209 select = tr.find('td.values select');
210 for (i = 0; i < allProjects.length; i++) {
210 for (i = 0; i < allProjects.length; i++) {
211 var filterValue = allProjects[i];
211 var filterValue = allProjects[i];
212 var option = $('<option>');
212 var option = $('<option>');
213 option.val(filterValue[1]).text(filterValue[0]);
213 option.val(filterValue[1]).text(filterValue[0]);
214 if (values[0] == filterValue[1]) { option.attr('selected', true); }
214 if (values[0] == filterValue[1]) { option.attr('selected', true); }
215 select.append(option);
215 select.append(option);
216 }
216 }
217 break;
217 break;
218 case "integer":
218 case "integer":
219 case "float":
219 case "float":
220 case "tree":
220 case "tree":
221 tr.find('td.values').append(
221 tr.find('td.values').append(
222 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="14" class="value" /></span>' +
222 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="14" class="value" /></span>' +
223 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="14" class="value" /></span>'
223 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="14" class="value" /></span>'
224 );
224 );
225 $('#values_'+fieldId+'_1').val(values[0]);
225 $('#values_'+fieldId+'_1').val(values[0]);
226 $('#values_'+fieldId+'_2').val(values[1]);
226 $('#values_'+fieldId+'_2').val(values[1]);
227 break;
227 break;
228 }
228 }
229 }
229 }
230
230
231 function toggleFilter(field) {
231 function toggleFilter(field) {
232 var fieldId = field.replace('.', '_');
232 var fieldId = field.replace('.', '_');
233 if ($('#cb_' + fieldId).is(':checked')) {
233 if ($('#cb_' + fieldId).is(':checked')) {
234 $("#operators_" + fieldId).show().removeAttr('disabled');
234 $("#operators_" + fieldId).show().removeAttr('disabled');
235 toggleOperator(field);
235 toggleOperator(field);
236 } else {
236 } else {
237 $("#operators_" + fieldId).hide().attr('disabled', true);
237 $("#operators_" + fieldId).hide().attr('disabled', true);
238 enableValues(field, []);
238 enableValues(field, []);
239 }
239 }
240 }
240 }
241
241
242 function enableValues(field, indexes) {
242 function enableValues(field, indexes) {
243 var fieldId = field.replace('.', '_');
243 var fieldId = field.replace('.', '_');
244 $('#tr_'+fieldId+' td.values .value').each(function(index) {
244 $('#tr_'+fieldId+' td.values .value').each(function(index) {
245 if ($.inArray(index, indexes) >= 0) {
245 if ($.inArray(index, indexes) >= 0) {
246 $(this).removeAttr('disabled');
246 $(this).removeAttr('disabled');
247 $(this).parents('span').first().show();
247 $(this).parents('span').first().show();
248 } else {
248 } else {
249 $(this).val('');
249 $(this).val('');
250 $(this).attr('disabled', true);
250 $(this).attr('disabled', true);
251 $(this).parents('span').first().hide();
251 $(this).parents('span').first().hide();
252 }
252 }
253
253
254 if ($(this).hasClass('group')) {
254 if ($(this).hasClass('group')) {
255 $(this).addClass('open');
255 $(this).addClass('open');
256 } else {
256 } else {
257 $(this).show();
257 $(this).show();
258 }
258 }
259 });
259 });
260 }
260 }
261
261
262 function toggleOperator(field) {
262 function toggleOperator(field) {
263 var fieldId = field.replace('.', '_');
263 var fieldId = field.replace('.', '_');
264 var operator = $("#operators_" + fieldId);
264 var operator = $("#operators_" + fieldId);
265 switch (operator.val()) {
265 switch (operator.val()) {
266 case "!*":
266 case "!*":
267 case "*":
267 case "*":
268 case "t":
268 case "t":
269 case "ld":
269 case "ld":
270 case "w":
270 case "w":
271 case "lw":
271 case "lw":
272 case "l2w":
272 case "l2w":
273 case "m":
273 case "m":
274 case "lm":
274 case "lm":
275 case "y":
275 case "y":
276 case "o":
276 case "o":
277 case "c":
277 case "c":
278 case "*o":
278 case "*o":
279 case "!o":
279 case "!o":
280 enableValues(field, []);
280 enableValues(field, []);
281 break;
281 break;
282 case "><":
282 case "><":
283 enableValues(field, [0,1]);
283 enableValues(field, [0,1]);
284 break;
284 break;
285 case "<t+":
285 case "<t+":
286 case ">t+":
286 case ">t+":
287 case "><t+":
287 case "><t+":
288 case "t+":
288 case "t+":
289 case ">t-":
289 case ">t-":
290 case "<t-":
290 case "<t-":
291 case "><t-":
291 case "><t-":
292 case "t-":
292 case "t-":
293 enableValues(field, [2]);
293 enableValues(field, [2]);
294 break;
294 break;
295 case "=p":
295 case "=p":
296 case "=!p":
296 case "=!p":
297 case "!p":
297 case "!p":
298 enableValues(field, [1]);
298 enableValues(field, [1]);
299 break;
299 break;
300 default:
300 default:
301 enableValues(field, [0]);
301 enableValues(field, [0]);
302 break;
302 break;
303 }
303 }
304 }
304 }
305
305
306 function toggleMultiSelect(el) {
306 function toggleMultiSelect(el) {
307 if (el.attr('multiple')) {
307 if (el.attr('multiple')) {
308 el.removeAttr('multiple');
308 el.removeAttr('multiple');
309 el.attr('size', 1);
309 el.attr('size', 1);
310 } else {
310 } else {
311 el.attr('multiple', true);
311 el.attr('multiple', true);
312 if (el.children().length > 10)
312 if (el.children().length > 10)
313 el.attr('size', 10);
313 el.attr('size', 10);
314 else
314 else
315 el.attr('size', 4);
315 el.attr('size', 4);
316 }
316 }
317 }
317 }
318
318
319 function showTab(name, url) {
319 function showTab(name, url) {
320 $('#tab-content-' + name).parent().find('.tab-content').hide();
320 $('#tab-content-' + name).parent().find('.tab-content').hide();
321 $('#tab-content-' + name).parent().find('div.tabs a').removeClass('selected');
321 $('#tab-content-' + name).parent().find('div.tabs a').removeClass('selected');
322 $('#tab-content-' + name).show();
322 $('#tab-content-' + name).show();
323 $('#tab-' + name).addClass('selected');
323 $('#tab-' + name).addClass('selected');
324 //replaces current URL with the "href" attribute of the current link
324 //replaces current URL with the "href" attribute of the current link
325 //(only triggered if supported by browser)
325 //(only triggered if supported by browser)
326 if ("replaceState" in window.history) {
326 if ("replaceState" in window.history) {
327 window.history.replaceState(null, document.title, url);
327 window.history.replaceState(null, document.title, url);
328 }
328 }
329 return false;
329 return false;
330 }
330 }
331
331
332 function moveTabRight(el) {
332 function moveTabRight(el) {
333 var lis = $(el).parents('div.tabs').first().find('ul').children();
333 var lis = $(el).parents('div.tabs').first().find('ul').children();
334 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
334 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
335 var tabsWidth = 0;
335 var tabsWidth = 0;
336 var i = 0;
336 var i = 0;
337 lis.each(function() {
337 lis.each(function() {
338 if ($(this).is(':visible')) {
338 if ($(this).is(':visible')) {
339 tabsWidth += $(this).outerWidth(true);
339 tabsWidth += $(this).outerWidth(true);
340 }
340 }
341 });
341 });
342 if (tabsWidth < $(el).parents('div.tabs').first().width() - bw) { return; }
342 if (tabsWidth < $(el).parents('div.tabs').first().width() - bw) { return; }
343 $(el).siblings('.tab-left').removeClass('disabled');
343 $(el).siblings('.tab-left').removeClass('disabled');
344 while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
344 while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
345 var w = lis.eq(i).width();
345 var w = lis.eq(i).width();
346 lis.eq(i).hide();
346 lis.eq(i).hide();
347 if (tabsWidth - w < $(el).parents('div.tabs').first().width() - bw) {
347 if (tabsWidth - w < $(el).parents('div.tabs').first().width() - bw) {
348 $(el).addClass('disabled');
348 $(el).addClass('disabled');
349 }
349 }
350 }
350 }
351
351
352 function moveTabLeft(el) {
352 function moveTabLeft(el) {
353 var lis = $(el).parents('div.tabs').first().find('ul').children();
353 var lis = $(el).parents('div.tabs').first().find('ul').children();
354 var i = 0;
354 var i = 0;
355 while (i < lis.length && !lis.eq(i).is(':visible')) { i++; }
355 while (i < lis.length && !lis.eq(i).is(':visible')) { i++; }
356 if (i > 0) {
356 if (i > 0) {
357 lis.eq(i-1).show();
357 lis.eq(i-1).show();
358 $(el).siblings('.tab-right').removeClass('disabled');
358 $(el).siblings('.tab-right').removeClass('disabled');
359 }
359 }
360 if (i <= 1) {
360 if (i <= 1) {
361 $(el).addClass('disabled');
361 $(el).addClass('disabled');
362 }
362 }
363 }
363 }
364
364
365 function displayTabsButtons() {
365 function displayTabsButtons() {
366 var lis;
366 var lis;
367 var tabsWidth;
367 var tabsWidth;
368 var el;
368 var el;
369 var numHidden;
369 var numHidden;
370 $('div.tabs').each(function() {
370 $('div.tabs').each(function() {
371 el = $(this);
371 el = $(this);
372 lis = el.find('ul').children();
372 lis = el.find('ul').children();
373 tabsWidth = 0;
373 tabsWidth = 0;
374 numHidden = 0;
374 numHidden = 0;
375 lis.each(function(){
375 lis.each(function(){
376 if ($(this).is(':visible')) {
376 if ($(this).is(':visible')) {
377 tabsWidth += $(this).outerWidth(true);
377 tabsWidth += $(this).outerWidth(true);
378 } else {
378 } else {
379 numHidden++;
379 numHidden++;
380 }
380 }
381 });
381 });
382 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
382 var bw = $(el).parents('div.tabs-buttons').outerWidth(true);
383 if ((tabsWidth < el.width() - bw) && (lis.length === 0 || lis.first().is(':visible'))) {
383 if ((tabsWidth < el.width() - bw) && (lis.length === 0 || lis.first().is(':visible'))) {
384 el.find('div.tabs-buttons').hide();
384 el.find('div.tabs-buttons').hide();
385 } else {
385 } else {
386 el.find('div.tabs-buttons').show().children('button.tab-left').toggleClass('disabled', numHidden == 0);
386 el.find('div.tabs-buttons').show().children('button.tab-left').toggleClass('disabled', numHidden == 0);
387 }
387 }
388 });
388 });
389 }
389 }
390
390
391 function setPredecessorFieldsVisibility() {
391 function setPredecessorFieldsVisibility() {
392 var relationType = $('#relation_relation_type');
392 var relationType = $('#relation_relation_type');
393 if (relationType.val() == "precedes" || relationType.val() == "follows") {
393 if (relationType.val() == "precedes" || relationType.val() == "follows") {
394 $('#predecessor_fields').show();
394 $('#predecessor_fields').show();
395 } else {
395 } else {
396 $('#predecessor_fields').hide();
396 $('#predecessor_fields').hide();
397 }
397 }
398 }
398 }
399
399
400 function showModal(id, width, title) {
400 function showModal(id, width, title) {
401 var el = $('#'+id).first();
401 var el = $('#'+id).first();
402 if (el.length === 0 || el.is(':visible')) {return;}
402 if (el.length === 0 || el.is(':visible')) {return;}
403 if (!title) title = el.find('h3.title').text();
403 if (!title) title = el.find('h3.title').text();
404 // moves existing modals behind the transparent background
404 // moves existing modals behind the transparent background
405 $(".modal").zIndex(99);
405 $(".modal").zIndex(99);
406 el.dialog({
406 el.dialog({
407 width: width,
407 width: width,
408 modal: true,
408 modal: true,
409 resizable: false,
409 resizable: false,
410 dialogClass: 'modal',
410 dialogClass: 'modal',
411 title: title
411 title: title
412 }).on('dialogclose', function(){
412 }).on('dialogclose', function(){
413 $(".modal").zIndex(101);
413 $(".modal").zIndex(101);
414 });
414 });
415 el.find("input[type=text], input[type=submit]").first().focus();
415 el.find("input[type=text], input[type=submit]").first().focus();
416 }
416 }
417
417
418 function hideModal(el) {
418 function hideModal(el) {
419 var modal;
419 var modal;
420 if (el) {
420 if (el) {
421 modal = $(el).parents('.ui-dialog-content');
421 modal = $(el).parents('.ui-dialog-content');
422 } else {
422 } else {
423 modal = $('#ajax-modal');
423 modal = $('#ajax-modal');
424 }
424 }
425 modal.dialog("close");
425 modal.dialog("close");
426 }
426 }
427
427
428 function submitPreview(url, form, target) {
428 function submitPreview(url, form, target) {
429 $.ajax({
429 $.ajax({
430 url: url,
430 url: url,
431 type: 'post',
431 type: 'post',
432 data: $('#'+form).serialize(),
432 data: $('#'+form).serialize(),
433 success: function(data){
433 success: function(data){
434 $('#'+target).html(data);
434 $('#'+target).html(data);
435 }
435 }
436 });
436 });
437 }
437 }
438
438
439 function collapseScmEntry(id) {
439 function collapseScmEntry(id) {
440 $('.'+id).each(function() {
440 $('.'+id).each(function() {
441 if ($(this).hasClass('open')) {
441 if ($(this).hasClass('open')) {
442 collapseScmEntry($(this).attr('id'));
442 collapseScmEntry($(this).attr('id'));
443 }
443 }
444 $(this).hide();
444 $(this).hide();
445 });
445 });
446 $('#'+id).removeClass('open');
446 $('#'+id).removeClass('open');
447 }
447 }
448
448
449 function expandScmEntry(id) {
449 function expandScmEntry(id) {
450 $('.'+id).each(function() {
450 $('.'+id).each(function() {
451 $(this).show();
451 $(this).show();
452 if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
452 if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
453 expandScmEntry($(this).attr('id'));
453 expandScmEntry($(this).attr('id'));
454 }
454 }
455 });
455 });
456 $('#'+id).addClass('open');
456 $('#'+id).addClass('open');
457 }
457 }
458
458
459 function scmEntryClick(id, url) {
459 function scmEntryClick(id, url) {
460 var el = $('#'+id);
460 var el = $('#'+id);
461 if (el.hasClass('open')) {
461 if (el.hasClass('open')) {
462 collapseScmEntry(id);
462 collapseScmEntry(id);
463 el.addClass('collapsed');
463 el.addClass('collapsed');
464 return false;
464 return false;
465 } else if (el.hasClass('loaded')) {
465 } else if (el.hasClass('loaded')) {
466 expandScmEntry(id);
466 expandScmEntry(id);
467 el.removeClass('collapsed');
467 el.removeClass('collapsed');
468 return false;
468 return false;
469 }
469 }
470 if (el.hasClass('loading')) {
470 if (el.hasClass('loading')) {
471 return false;
471 return false;
472 }
472 }
473 el.addClass('loading');
473 el.addClass('loading');
474 $.ajax({
474 $.ajax({
475 url: url,
475 url: url,
476 success: function(data) {
476 success: function(data) {
477 el.after(data);
477 el.after(data);
478 el.addClass('open').addClass('loaded').removeClass('loading');
478 el.addClass('open').addClass('loaded').removeClass('loading');
479 }
479 }
480 });
480 });
481 return true;
481 return true;
482 }
482 }
483
483
484 function randomKey(size) {
484 function randomKey(size) {
485 var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
485 var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
486 var key = '';
486 var key = '';
487 for (var i = 0; i < size; i++) {
487 for (var i = 0; i < size; i++) {
488 key += chars.charAt(Math.floor(Math.random() * chars.length));
488 key += chars.charAt(Math.floor(Math.random() * chars.length));
489 }
489 }
490 return key;
490 return key;
491 }
491 }
492
492
493 function updateIssueFrom(url, el) {
493 function updateIssueFrom(url, el) {
494 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
494 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
495 $(this).data('valuebeforeupdate', $(this).val());
495 $(this).data('valuebeforeupdate', $(this).val());
496 });
496 });
497 if (el) {
497 if (el) {
498 $("#form_update_triggered_by").val($(el).attr('id'));
498 $("#form_update_triggered_by").val($(el).attr('id'));
499 }
499 }
500 return $.ajax({
500 return $.ajax({
501 url: url,
501 url: url,
502 type: 'post',
502 type: 'post',
503 data: $('#issue-form').serialize()
503 data: $('#issue-form').serialize()
504 });
504 });
505 }
505 }
506
506
507 function replaceIssueFormWith(html){
507 function replaceIssueFormWith(html){
508 var replacement = $(html);
508 var replacement = $(html);
509 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
509 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
510 var object_id = $(this).attr('id');
510 var object_id = $(this).attr('id');
511 if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) {
511 if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) {
512 replacement.find('#'+object_id).val($(this).val());
512 replacement.find('#'+object_id).val($(this).val());
513 }
513 }
514 });
514 });
515 $('#all_attributes').empty();
515 $('#all_attributes').empty();
516 $('#all_attributes').prepend(replacement);
516 $('#all_attributes').prepend(replacement);
517 }
517 }
518
518
519 function updateBulkEditFrom(url) {
519 function updateBulkEditFrom(url) {
520 $.ajax({
520 $.ajax({
521 url: url,
521 url: url,
522 type: 'post',
522 type: 'post',
523 data: $('#bulk_edit_form').serialize()
523 data: $('#bulk_edit_form').serialize()
524 });
524 });
525 }
525 }
526
526
527 function observeAutocompleteField(fieldId, url, options) {
527 function observeAutocompleteField(fieldId, url, options) {
528 $(document).ready(function() {
528 $(document).ready(function() {
529 $('#'+fieldId).autocomplete($.extend({
529 $('#'+fieldId).autocomplete($.extend({
530 source: url,
530 source: url,
531 minLength: 2,
531 minLength: 2,
532 position: {collision: "flipfit"},
532 position: {collision: "flipfit"},
533 search: function(){$('#'+fieldId).addClass('ajax-loading');},
533 search: function(){$('#'+fieldId).addClass('ajax-loading');},
534 response: function(){$('#'+fieldId).removeClass('ajax-loading');}
534 response: function(){$('#'+fieldId).removeClass('ajax-loading');}
535 }, options));
535 }, options));
536 $('#'+fieldId).addClass('autocomplete');
536 $('#'+fieldId).addClass('autocomplete');
537 });
537 });
538 }
538 }
539
539
540 function observeSearchfield(fieldId, targetId, url) {
540 function observeSearchfield(fieldId, targetId, url) {
541 $('#'+fieldId).each(function() {
541 $('#'+fieldId).each(function() {
542 var $this = $(this);
542 var $this = $(this);
543 $this.addClass('autocomplete');
543 $this.addClass('autocomplete');
544 $this.attr('data-value-was', $this.val());
544 $this.attr('data-value-was', $this.val());
545 var check = function() {
545 var check = function() {
546 var val = $this.val();
546 var val = $this.val();
547 if ($this.attr('data-value-was') != val){
547 if ($this.attr('data-value-was') != val){
548 $this.attr('data-value-was', val);
548 $this.attr('data-value-was', val);
549 $.ajax({
549 $.ajax({
550 url: url,
550 url: url,
551 type: 'get',
551 type: 'get',
552 data: {q: $this.val()},
552 data: {q: $this.val()},
553 success: function(data){ if(targetId) $('#'+targetId).html(data); },
553 success: function(data){ if(targetId) $('#'+targetId).html(data); },
554 beforeSend: function(){ $this.addClass('ajax-loading'); },
554 beforeSend: function(){ $this.addClass('ajax-loading'); },
555 complete: function(){ $this.removeClass('ajax-loading'); }
555 complete: function(){ $this.removeClass('ajax-loading'); }
556 });
556 });
557 }
557 }
558 };
558 };
559 var reset = function() {
559 var reset = function() {
560 if (timer) {
560 if (timer) {
561 clearInterval(timer);
561 clearInterval(timer);
562 timer = setInterval(check, 300);
562 timer = setInterval(check, 300);
563 }
563 }
564 };
564 };
565 var timer = setInterval(check, 300);
565 var timer = setInterval(check, 300);
566 $this.bind('keyup click mousemove', reset);
566 $this.bind('keyup click mousemove', reset);
567 });
567 });
568 }
568 }
569
569
570 function beforeShowDatePicker(input, inst) {
570 function beforeShowDatePicker(input, inst) {
571 var default_date = null;
571 var default_date = null;
572 switch ($(input).attr("id")) {
572 switch ($(input).attr("id")) {
573 case "issue_start_date" :
573 case "issue_start_date" :
574 if ($("#issue_due_date").size() > 0) {
574 if ($("#issue_due_date").size() > 0) {
575 default_date = $("#issue_due_date").val();
575 default_date = $("#issue_due_date").val();
576 }
576 }
577 break;
577 break;
578 case "issue_due_date" :
578 case "issue_due_date" :
579 if ($("#issue_start_date").size() > 0) {
579 if ($("#issue_start_date").size() > 0) {
580 var start_date = $("#issue_start_date").val();
580 var start_date = $("#issue_start_date").val();
581 if (start_date != "") {
581 if (start_date != "") {
582 start_date = new Date(Date.parse(start_date));
582 start_date = new Date(Date.parse(start_date));
583 if (start_date > new Date()) {
583 if (start_date > new Date()) {
584 default_date = $("#issue_start_date").val();
584 default_date = $("#issue_start_date").val();
585 }
585 }
586 }
586 }
587 }
587 }
588 break;
588 break;
589 }
589 }
590 $(input).datepickerFallback("option", "defaultDate", default_date);
590 $(input).datepickerFallback("option", "defaultDate", default_date);
591 }
591 }
592
592
593 (function($){
593 (function($){
594 $.fn.positionedItems = function(sortableOptions, options){
594 $.fn.positionedItems = function(sortableOptions, options){
595 var settings = $.extend({
595 var settings = $.extend({
596 firstPosition: 1
596 firstPosition: 1
597 }, options );
597 }, options );
598
598
599 return this.sortable($.extend({
599 return this.sortable($.extend({
600 axis: 'y',
600 handle: ".sort-handle",
601 handle: ".sort-handle",
601 helper: function(event, ui){
602 helper: function(event, ui){
602 ui.children('td').each(function(){
603 ui.children('td').each(function(){
603 $(this).width($(this).width());
604 $(this).width($(this).width());
604 });
605 });
605 return ui;
606 return ui;
606 },
607 },
607 update: function(event, ui) {
608 update: function(event, ui) {
608 var sortable = $(this);
609 var sortable = $(this);
609 var handle = ui.item.find(".sort-handle").addClass("ajax-loading");
610 var handle = ui.item.find(".sort-handle").addClass("ajax-loading");
610 var url = handle.data("reorder-url");
611 var url = handle.data("reorder-url");
611 var param = handle.data("reorder-param");
612 var param = handle.data("reorder-param");
612 var data = {};
613 var data = {};
613 data[param] = {position: ui.item.index() + settings['firstPosition']};
614 data[param] = {position: ui.item.index() + settings['firstPosition']};
614 $.ajax({
615 $.ajax({
615 url: url,
616 url: url,
616 type: 'put',
617 type: 'put',
617 dataType: 'script',
618 dataType: 'script',
618 data: data,
619 data: data,
619 success: function(data){
620 success: function(data){
620 sortable.children(":even").removeClass("even").addClass("odd");
621 sortable.children(":even").removeClass("even").addClass("odd");
621 sortable.children(":odd").removeClass("odd").addClass("even");
622 sortable.children(":odd").removeClass("odd").addClass("even");
622 },
623 },
623 error: function(jqXHR, textStatus, errorThrown){
624 error: function(jqXHR, textStatus, errorThrown){
624 alert(jqXHR.status);
625 alert(jqXHR.status);
625 sortable.sortable("cancel");
626 sortable.sortable("cancel");
626 },
627 },
627 complete: function(jqXHR, textStatus, errorThrown){
628 complete: function(jqXHR, textStatus, errorThrown){
628 handle.removeClass("ajax-loading");
629 handle.removeClass("ajax-loading");
629 }
630 }
630 });
631 });
631 },
632 },
632 }, sortableOptions));
633 }, sortableOptions));
633 }
634 }
634 }( jQuery ));
635 }( jQuery ));
635
636
636 function initMyPageSortable(list, url) {
637 function initMyPageSortable(list, url) {
637 $('#list-'+list).sortable({
638 $('#list-'+list).sortable({
638 connectWith: '.block-receiver',
639 connectWith: '.block-receiver',
639 tolerance: 'pointer',
640 tolerance: 'pointer',
640 update: function(){
641 update: function(){
641 $.ajax({
642 $.ajax({
642 url: url,
643 url: url,
643 type: 'post',
644 type: 'post',
644 data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
645 data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
645 });
646 });
646 }
647 }
647 });
648 });
648 $("#list-top, #list-left, #list-right").disableSelection();
649 $("#list-top, #list-left, #list-right").disableSelection();
649 }
650 }
650
651
651 var warnLeavingUnsavedMessage;
652 var warnLeavingUnsavedMessage;
652 function warnLeavingUnsaved(message) {
653 function warnLeavingUnsaved(message) {
653 warnLeavingUnsavedMessage = message;
654 warnLeavingUnsavedMessage = message;
654 $(document).on('submit', 'form', function(){
655 $(document).on('submit', 'form', function(){
655 $('textarea').removeData('changed');
656 $('textarea').removeData('changed');
656 });
657 });
657 $(document).on('change', 'textarea', function(){
658 $(document).on('change', 'textarea', function(){
658 $(this).data('changed', 'changed');
659 $(this).data('changed', 'changed');
659 });
660 });
660 window.onbeforeunload = function(){
661 window.onbeforeunload = function(){
661 var warn = false;
662 var warn = false;
662 $('textarea').blur().each(function(){
663 $('textarea').blur().each(function(){
663 if ($(this).data('changed')) {
664 if ($(this).data('changed')) {
664 warn = true;
665 warn = true;
665 }
666 }
666 });
667 });
667 if (warn) {return warnLeavingUnsavedMessage;}
668 if (warn) {return warnLeavingUnsavedMessage;}
668 };
669 };
669 }
670 }
670
671
671 function setupAjaxIndicator() {
672 function setupAjaxIndicator() {
672 $(document).bind('ajaxSend', function(event, xhr, settings) {
673 $(document).bind('ajaxSend', function(event, xhr, settings) {
673 if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
674 if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
674 $('#ajax-indicator').show();
675 $('#ajax-indicator').show();
675 }
676 }
676 });
677 });
677 $(document).bind('ajaxStop', function() {
678 $(document).bind('ajaxStop', function() {
678 $('#ajax-indicator').hide();
679 $('#ajax-indicator').hide();
679 });
680 });
680 }
681 }
681
682
682 function setupTabs() {
683 function setupTabs() {
683 if($('.tabs').length > 0) {
684 if($('.tabs').length > 0) {
684 displayTabsButtons();
685 displayTabsButtons();
685 $(window).resize(displayTabsButtons);
686 $(window).resize(displayTabsButtons);
686 }
687 }
687 }
688 }
688
689
689 function hideOnLoad() {
690 function hideOnLoad() {
690 $('.hol').hide();
691 $('.hol').hide();
691 }
692 }
692
693
693 function addFormObserversForDoubleSubmit() {
694 function addFormObserversForDoubleSubmit() {
694 $('form[method=post]').each(function() {
695 $('form[method=post]').each(function() {
695 if (!$(this).hasClass('multiple-submit')) {
696 if (!$(this).hasClass('multiple-submit')) {
696 $(this).submit(function(form_submission) {
697 $(this).submit(function(form_submission) {
697 if ($(form_submission.target).attr('data-submitted')) {
698 if ($(form_submission.target).attr('data-submitted')) {
698 form_submission.preventDefault();
699 form_submission.preventDefault();
699 } else {
700 } else {
700 $(form_submission.target).attr('data-submitted', true);
701 $(form_submission.target).attr('data-submitted', true);
701 }
702 }
702 });
703 });
703 }
704 }
704 });
705 });
705 }
706 }
706
707
707 function defaultFocus(){
708 function defaultFocus(){
708 if (($('#content :focus').length == 0) && (window.location.hash == '')) {
709 if (($('#content :focus').length == 0) && (window.location.hash == '')) {
709 $('#content input[type=text], #content textarea').first().focus();
710 $('#content input[type=text], #content textarea').first().focus();
710 }
711 }
711 }
712 }
712
713
713 function blockEventPropagation(event) {
714 function blockEventPropagation(event) {
714 event.stopPropagation();
715 event.stopPropagation();
715 event.preventDefault();
716 event.preventDefault();
716 }
717 }
717
718
718 function toggleDisabledOnChange() {
719 function toggleDisabledOnChange() {
719 var checked = $(this).is(':checked');
720 var checked = $(this).is(':checked');
720 $($(this).data('disables')).attr('disabled', checked);
721 $($(this).data('disables')).attr('disabled', checked);
721 $($(this).data('enables')).attr('disabled', !checked);
722 $($(this).data('enables')).attr('disabled', !checked);
722 $($(this).data('shows')).toggle(checked);
723 $($(this).data('shows')).toggle(checked);
723 }
724 }
724 function toggleDisabledInit() {
725 function toggleDisabledInit() {
725 $('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
726 $('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
726 }
727 }
727
728
728 function toggleNewObjectDropdown() {
729 function toggleNewObjectDropdown() {
729 var dropdown = $('#new-object + ul.menu-children');
730 var dropdown = $('#new-object + ul.menu-children');
730 if(dropdown.hasClass('visible')){
731 if(dropdown.hasClass('visible')){
731 dropdown.removeClass('visible');
732 dropdown.removeClass('visible');
732 }else{
733 }else{
733 dropdown.addClass('visible');
734 dropdown.addClass('visible');
734 }
735 }
735 }
736 }
736
737
737 (function ( $ ) {
738 (function ( $ ) {
738
739
739 // detect if native date input is supported
740 // detect if native date input is supported
740 var nativeDateInputSupported = true;
741 var nativeDateInputSupported = true;
741
742
742 var input = document.createElement('input');
743 var input = document.createElement('input');
743 input.setAttribute('type','date');
744 input.setAttribute('type','date');
744 if (input.type === 'text') {
745 if (input.type === 'text') {
745 nativeDateInputSupported = false;
746 nativeDateInputSupported = false;
746 }
747 }
747
748
748 var notADateValue = 'not-a-date';
749 var notADateValue = 'not-a-date';
749 input.setAttribute('value', notADateValue);
750 input.setAttribute('value', notADateValue);
750 if (input.value === notADateValue) {
751 if (input.value === notADateValue) {
751 nativeDateInputSupported = false;
752 nativeDateInputSupported = false;
752 }
753 }
753
754
754 $.fn.datepickerFallback = function( options ) {
755 $.fn.datepickerFallback = function( options ) {
755 if (nativeDateInputSupported) {
756 if (nativeDateInputSupported) {
756 return this;
757 return this;
757 } else {
758 } else {
758 return this.datepicker( options );
759 return this.datepicker( options );
759 }
760 }
760 };
761 };
761 }( jQuery ));
762 }( jQuery ));
762
763
763 $(document).ready(function(){
764 $(document).ready(function(){
764 $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
765 $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
765 toggleDisabledInit();
766 toggleDisabledInit();
766 });
767 });
767
768
768 function keepAnchorOnSignIn(form){
769 function keepAnchorOnSignIn(form){
769 var hash = decodeURIComponent(self.document.location.hash);
770 var hash = decodeURIComponent(self.document.location.hash);
770 if (hash) {
771 if (hash) {
771 if (hash.indexOf("#") === -1) {
772 if (hash.indexOf("#") === -1) {
772 hash = "#" + hash;
773 hash = "#" + hash;
773 }
774 }
774 form.action = form.action + hash;
775 form.action = form.action + hash;
775 }
776 }
776 return true;
777 return true;
777 }
778 }
778
779
779 $(document).ready(setupAjaxIndicator);
780 $(document).ready(setupAjaxIndicator);
780 $(document).ready(hideOnLoad);
781 $(document).ready(hideOnLoad);
781 $(document).ready(addFormObserversForDoubleSubmit);
782 $(document).ready(addFormObserversForDoubleSubmit);
782 $(document).ready(defaultFocus);
783 $(document).ready(defaultFocus);
783 $(document).ready(setupTabs);
784 $(document).ready(setupTabs);
General Comments 0
You need to be logged in to leave comments. Login now