@@ -1,89 +1,100 | |||||
1 | <%= error_messages_for 'project' %> |
|
1 | <%= error_messages_for 'project' %> | |
2 |
|
2 | |||
3 | <div class="box tabular"> |
|
3 | <div class="box tabular"> | |
4 | <!--[form:project]--> |
|
4 | <!--[form:project]--> | |
5 | <p><%= f.text_field :name, :required => true, :size => 60 %></p> |
|
5 | <p><%= f.text_field :name, :required => true, :size => 60 %></p> | |
6 |
|
6 | |||
7 | <p><%= f.text_area :description, :rows => 8, :class => 'wiki-edit' %></p> |
|
7 | <p><%= f.text_area :description, :rows => 8, :class => 'wiki-edit' %></p> | |
8 | <p><%= f.text_field :identifier, :required => true, :size => 60, :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %> |
|
8 | <p><%= f.text_field :identifier, :required => true, :size => 60, :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %> | |
9 | <% unless @project.identifier_frozen? %> |
|
9 | <% unless @project.identifier_frozen? %> | |
10 | <em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em> |
|
10 | <em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em> | |
11 | <% end %></p> |
|
11 | <% end %></p> | |
12 | <p><%= f.text_field :homepage, :size => 60 %></p> |
|
12 | <p><%= f.text_field :homepage, :size => 60 %></p> | |
13 | <p><%= f.check_box :is_public %></p> |
|
13 | <p><%= f.check_box :is_public %></p> | |
14 |
|
14 | |||
15 | <% unless @project.allowed_parents.compact.empty? %> |
|
15 | <% unless @project.allowed_parents.compact.empty? %> | |
16 | <p><%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %></p> |
|
16 | <p><%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %></p> | |
17 | <% end %> |
|
17 | <% end %> | |
18 |
|
18 | |||
19 | <% if @project.safe_attribute? 'inherit_members' %> |
|
19 | <% if @project.safe_attribute? 'inherit_members' %> | |
20 | <p><%= f.check_box :inherit_members %></p> |
|
20 | <p><%= f.check_box :inherit_members %></p> | |
21 | <% end %> |
|
21 | <% end %> | |
22 |
|
22 | |||
23 | <%= wikitoolbar_for 'project_description' %> |
|
23 | <%= wikitoolbar_for 'project_description' %> | |
24 |
|
24 | |||
25 | <% @project.custom_field_values.each do |value| %> |
|
25 | <% @project.custom_field_values.each do |value| %> | |
26 | <p><%= custom_field_tag_with_label :project, value %></p> |
|
26 | <p><%= custom_field_tag_with_label :project, value %></p> | |
27 | <% end %> |
|
27 | <% end %> | |
28 | <%= call_hook(:view_projects_form, :project => @project, :form => f) %> |
|
28 | <%= call_hook(:view_projects_form, :project => @project, :form => f) %> | |
29 | </div> |
|
29 | </div> | |
30 |
|
30 | |||
31 | <% if @project.new_record? %> |
|
31 | <% if @project.new_record? %> | |
32 | <fieldset class="box tabular"><legend><%= l(:label_module_plural) %></legend> |
|
32 | <fieldset class="box tabular"><legend><%= l(:label_module_plural) %></legend> | |
33 | <% Redmine::AccessControl.available_project_modules.each do |m| %> |
|
33 | <% Redmine::AccessControl.available_project_modules.each do |m| %> | |
34 | <label class="floating"> |
|
34 | <label class="floating"> | |
35 | <%= check_box_tag 'project[enabled_module_names][]', m, @project.module_enabled?(m), :id => "project_enabled_module_names_#{m}" %> |
|
35 | <%= check_box_tag 'project[enabled_module_names][]', m, @project.module_enabled?(m), :id => "project_enabled_module_names_#{m}" %> | |
36 | <%= l_or_humanize(m, :prefix => "project_module_") %> |
|
36 | <%= l_or_humanize(m, :prefix => "project_module_") %> | |
37 | </label> |
|
37 | </label> | |
38 | <% end %> |
|
38 | <% end %> | |
39 | <%= hidden_field_tag 'project[enabled_module_names][]', '' %> |
|
39 | <%= hidden_field_tag 'project[enabled_module_names][]', '' %> | |
40 | <%= javascript_tag 'observeProjectModules()' %> |
|
|||
41 | </fieldset> |
|
40 | </fieldset> | |
42 | <% end %> |
|
41 | <% end %> | |
43 |
|
42 | |||
44 | <% if @project.new_record? || @project.module_enabled?('issue_tracking') %> |
|
43 | <% if @project.new_record? || @project.module_enabled?('issue_tracking') %> | |
45 | <% unless @trackers.empty? %> |
|
44 | <% unless @trackers.empty? %> | |
46 | <fieldset class="box tabular" id="project_trackers"><legend><%=l(:label_tracker_plural)%></legend> |
|
45 | <fieldset class="box tabular" id="project_trackers"><legend><%=l(:label_tracker_plural)%></legend> | |
47 | <% @trackers.each do |tracker| %> |
|
46 | <% @trackers.each do |tracker| %> | |
48 | <label class="floating"> |
|
47 | <label class="floating"> | |
49 | <%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.include?(tracker) %> |
|
48 | <%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.include?(tracker) %> | |
50 | <%=h tracker %> |
|
49 | <%=h tracker %> | |
51 | </label> |
|
50 | </label> | |
52 | <% end %> |
|
51 | <% end %> | |
53 | <%= hidden_field_tag 'project[tracker_ids][]', '' %> |
|
52 | <%= hidden_field_tag 'project[tracker_ids][]', '' %> | |
54 | </fieldset> |
|
53 | </fieldset> | |
55 | <% end %> |
|
54 | <% end %> | |
56 |
|
55 | |||
57 | <% unless @issue_custom_fields.empty? %> |
|
56 | <% unless @issue_custom_fields.empty? %> | |
58 | <fieldset class="box tabular" id="project_issue_custom_fields"><legend><%=l(:label_custom_field_plural)%></legend> |
|
57 | <fieldset class="box tabular" id="project_issue_custom_fields"><legend><%=l(:label_custom_field_plural)%></legend> | |
59 | <% @issue_custom_fields.each do |custom_field| %> |
|
58 | <% @issue_custom_fields.each do |custom_field| %> | |
60 | <label class="floating"> |
|
59 | <label class="floating"> | |
61 | <%= check_box_tag 'project[issue_custom_field_ids][]', custom_field.id, (@project.all_issue_custom_fields.include? custom_field), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %> |
|
60 | <%= check_box_tag 'project[issue_custom_field_ids][]', custom_field.id, (@project.all_issue_custom_fields.include? custom_field), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %> | |
62 | <%=h custom_field.name %> |
|
61 | <%=h custom_field.name %> | |
63 | </label> |
|
62 | </label> | |
64 | <% end %> |
|
63 | <% end %> | |
65 | <%= hidden_field_tag 'project[issue_custom_field_ids][]', '' %> |
|
64 | <%= hidden_field_tag 'project[issue_custom_field_ids][]', '' %> | |
66 | </fieldset> |
|
65 | </fieldset> | |
67 | <% end %> |
|
66 | <% end %> | |
68 | <% end %> |
|
67 | <% end %> | |
69 | <!--[eoform:project]--> |
|
68 | <!--[eoform:project]--> | |
70 |
|
69 | |||
71 | <% unless @project.identifier_frozen? %> |
|
70 | <% unless @project.identifier_frozen? %> | |
72 | <% content_for :header_tags do %> |
|
71 | <% content_for :header_tags do %> | |
73 | <%= javascript_include_tag 'project_identifier' %> |
|
72 | <%= javascript_include_tag 'project_identifier' %> | |
74 | <% end %> |
|
73 | <% end %> | |
75 | <% end %> |
|
74 | <% end %> | |
76 |
|
75 | |||
77 | <% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %> |
|
76 | <% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %> | |
78 | <%= javascript_tag do %> |
|
77 | <%= javascript_tag do %> | |
79 | $(document).ready(function() { |
|
78 | $(document).ready(function() { | |
80 | $("#project_inherit_members").change(function(){ |
|
79 | $("#project_inherit_members").change(function(){ | |
81 | if (!$(this).is(':checked')) { |
|
80 | if (!$(this).is(':checked')) { | |
82 | if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) { |
|
81 | if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) { | |
83 | $("#project_inherit_members").attr("checked", true); |
|
82 | $("#project_inherit_members").attr("checked", true); | |
84 | } |
|
83 | } | |
85 | } |
|
84 | } | |
86 | }); |
|
85 | }); | |
87 | }); |
|
86 | }); | |
88 | <% end %> |
|
87 | <% end %> | |
89 | <% end %> |
|
88 | <% end %> | |
|
89 | ||||
|
90 | <%= javascript_tag do %> | |||
|
91 | $(document).ready(function() { | |||
|
92 | $('#project_enabled_module_names_issue_tracking').on('change', function(){ | |||
|
93 | if ($(this).attr('checked')){ | |||
|
94 | $('#project_trackers, #project_issue_custom_fields').show(); | |||
|
95 | } else { | |||
|
96 | $('#project_trackers, #project_issue_custom_fields').hide(); | |||
|
97 | } | |||
|
98 | }).trigger('change'); | |||
|
99 | }); | |||
|
100 | <% end %> |
@@ -1,605 +1,591 | |||||
1 | /* Redmine - project management software |
|
1 | /* Redmine - project management software | |
2 | Copyright (C) 2006-2013 Jean-Philippe Lang */ |
|
2 | Copyright (C) 2006-2013 Jean-Philippe Lang */ | |
3 |
|
3 | |||
4 | function checkAll(id, checked) { |
|
4 | function checkAll(id, checked) { | |
5 | if (checked) { |
|
5 | if (checked) { | |
6 | $('#'+id).find('input[type=checkbox]').attr('checked', true); |
|
6 | $('#'+id).find('input[type=checkbox]').attr('checked', true); | |
7 | } else { |
|
7 | } else { | |
8 | $('#'+id).find('input[type=checkbox]').removeAttr('checked'); |
|
8 | $('#'+id).find('input[type=checkbox]').removeAttr('checked'); | |
9 | } |
|
9 | } | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
12 | function toggleCheckboxesBySelector(selector) { |
|
12 | function toggleCheckboxesBySelector(selector) { | |
13 | var all_checked = true; |
|
13 | var all_checked = true; | |
14 | $(selector).each(function(index) { |
|
14 | $(selector).each(function(index) { | |
15 | if (!$(this).is(':checked')) { all_checked = false; } |
|
15 | if (!$(this).is(':checked')) { all_checked = false; } | |
16 | }); |
|
16 | }); | |
17 | $(selector).attr('checked', !all_checked); |
|
17 | $(selector).attr('checked', !all_checked); | |
18 | } |
|
18 | } | |
19 |
|
19 | |||
20 | function showAndScrollTo(id, focus) { |
|
20 | function showAndScrollTo(id, focus) { | |
21 | $('#'+id).show(); |
|
21 | $('#'+id).show(); | |
22 | if (focus !== null) { |
|
22 | if (focus !== null) { | |
23 | $('#'+focus).focus(); |
|
23 | $('#'+focus).focus(); | |
24 | } |
|
24 | } | |
25 | $('html, body').animate({scrollTop: $('#'+id).offset().top}, 100); |
|
25 | $('html, body').animate({scrollTop: $('#'+id).offset().top}, 100); | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | function toggleRowGroup(el) { |
|
28 | function toggleRowGroup(el) { | |
29 | var tr = $(el).parents('tr').first(); |
|
29 | var tr = $(el).parents('tr').first(); | |
30 | var n = tr.next(); |
|
30 | var n = tr.next(); | |
31 | tr.toggleClass('open'); |
|
31 | tr.toggleClass('open'); | |
32 | while (n.length && !n.hasClass('group')) { |
|
32 | while (n.length && !n.hasClass('group')) { | |
33 | n.toggle(); |
|
33 | n.toggle(); | |
34 | n = n.next('tr'); |
|
34 | n = n.next('tr'); | |
35 | } |
|
35 | } | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | function collapseAllRowGroups(el) { |
|
38 | function collapseAllRowGroups(el) { | |
39 | var tbody = $(el).parents('tbody').first(); |
|
39 | var tbody = $(el).parents('tbody').first(); | |
40 | tbody.children('tr').each(function(index) { |
|
40 | tbody.children('tr').each(function(index) { | |
41 | if ($(this).hasClass('group')) { |
|
41 | if ($(this).hasClass('group')) { | |
42 | $(this).removeClass('open'); |
|
42 | $(this).removeClass('open'); | |
43 | } else { |
|
43 | } else { | |
44 | $(this).hide(); |
|
44 | $(this).hide(); | |
45 | } |
|
45 | } | |
46 | }); |
|
46 | }); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | function expandAllRowGroups(el) { |
|
49 | function expandAllRowGroups(el) { | |
50 | var tbody = $(el).parents('tbody').first(); |
|
50 | var tbody = $(el).parents('tbody').first(); | |
51 | tbody.children('tr').each(function(index) { |
|
51 | tbody.children('tr').each(function(index) { | |
52 | if ($(this).hasClass('group')) { |
|
52 | if ($(this).hasClass('group')) { | |
53 | $(this).addClass('open'); |
|
53 | $(this).addClass('open'); | |
54 | } else { |
|
54 | } else { | |
55 | $(this).show(); |
|
55 | $(this).show(); | |
56 | } |
|
56 | } | |
57 | }); |
|
57 | }); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | function toggleAllRowGroups(el) { |
|
60 | function toggleAllRowGroups(el) { | |
61 | var tr = $(el).parents('tr').first(); |
|
61 | var tr = $(el).parents('tr').first(); | |
62 | if (tr.hasClass('open')) { |
|
62 | if (tr.hasClass('open')) { | |
63 | collapseAllRowGroups(el); |
|
63 | collapseAllRowGroups(el); | |
64 | } else { |
|
64 | } else { | |
65 | expandAllRowGroups(el); |
|
65 | expandAllRowGroups(el); | |
66 | } |
|
66 | } | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | function toggleFieldset(el) { |
|
69 | function toggleFieldset(el) { | |
70 | var fieldset = $(el).parents('fieldset').first(); |
|
70 | var fieldset = $(el).parents('fieldset').first(); | |
71 | fieldset.toggleClass('collapsed'); |
|
71 | fieldset.toggleClass('collapsed'); | |
72 | fieldset.children('div').toggle(); |
|
72 | fieldset.children('div').toggle(); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | function hideFieldset(el) { |
|
75 | function hideFieldset(el) { | |
76 | var fieldset = $(el).parents('fieldset').first(); |
|
76 | var fieldset = $(el).parents('fieldset').first(); | |
77 | fieldset.toggleClass('collapsed'); |
|
77 | fieldset.toggleClass('collapsed'); | |
78 | fieldset.children('div').hide(); |
|
78 | fieldset.children('div').hide(); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | function initFilters() { |
|
81 | function initFilters() { | |
82 | $('#add_filter_select').change(function() { |
|
82 | $('#add_filter_select').change(function() { | |
83 | addFilter($(this).val(), '', []); |
|
83 | addFilter($(this).val(), '', []); | |
84 | }); |
|
84 | }); | |
85 | $('#filters-table td.field input[type=checkbox]').each(function() { |
|
85 | $('#filters-table td.field input[type=checkbox]').each(function() { | |
86 | toggleFilter($(this).val()); |
|
86 | toggleFilter($(this).val()); | |
87 | }); |
|
87 | }); | |
88 | $('#filters-table td.field input[type=checkbox]').live('click', function() { |
|
88 | $('#filters-table td.field input[type=checkbox]').live('click', function() { | |
89 | toggleFilter($(this).val()); |
|
89 | toggleFilter($(this).val()); | |
90 | }); |
|
90 | }); | |
91 | $('#filters-table .toggle-multiselect').live('click', function() { |
|
91 | $('#filters-table .toggle-multiselect').live('click', function() { | |
92 | toggleMultiSelect($(this).siblings('select')); |
|
92 | toggleMultiSelect($(this).siblings('select')); | |
93 | }); |
|
93 | }); | |
94 | $('#filters-table input[type=text]').live('keypress', function(e) { |
|
94 | $('#filters-table input[type=text]').live('keypress', function(e) { | |
95 | if (e.keyCode == 13) submit_query_form("query_form"); |
|
95 | if (e.keyCode == 13) submit_query_form("query_form"); | |
96 | }); |
|
96 | }); | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | function addFilter(field, operator, values) { |
|
99 | function addFilter(field, operator, values) { | |
100 | var fieldId = field.replace('.', '_'); |
|
100 | var fieldId = field.replace('.', '_'); | |
101 | var tr = $('#tr_'+fieldId); |
|
101 | var tr = $('#tr_'+fieldId); | |
102 | if (tr.length > 0) { |
|
102 | if (tr.length > 0) { | |
103 | tr.show(); |
|
103 | tr.show(); | |
104 | } else { |
|
104 | } else { | |
105 | buildFilterRow(field, operator, values); |
|
105 | buildFilterRow(field, operator, values); | |
106 | } |
|
106 | } | |
107 | $('#cb_'+fieldId).attr('checked', true); |
|
107 | $('#cb_'+fieldId).attr('checked', true); | |
108 | toggleFilter(field); |
|
108 | toggleFilter(field); | |
109 | $('#add_filter_select').val('').children('option').each(function() { |
|
109 | $('#add_filter_select').val('').children('option').each(function() { | |
110 | if ($(this).attr('value') == field) { |
|
110 | if ($(this).attr('value') == field) { | |
111 | $(this).attr('disabled', true); |
|
111 | $(this).attr('disabled', true); | |
112 | } |
|
112 | } | |
113 | }); |
|
113 | }); | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | function buildFilterRow(field, operator, values) { |
|
116 | function buildFilterRow(field, operator, values) { | |
117 | var fieldId = field.replace('.', '_'); |
|
117 | var fieldId = field.replace('.', '_'); | |
118 | var filterTable = $("#filters-table"); |
|
118 | var filterTable = $("#filters-table"); | |
119 | var filterOptions = availableFilters[field]; |
|
119 | var filterOptions = availableFilters[field]; | |
120 | var operators = operatorByType[filterOptions['type']]; |
|
120 | var operators = operatorByType[filterOptions['type']]; | |
121 | var filterValues = filterOptions['values']; |
|
121 | var filterValues = filterOptions['values']; | |
122 | var i, select; |
|
122 | var i, select; | |
123 |
|
123 | |||
124 | var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html( |
|
124 | var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html( | |
125 | '<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' + |
|
125 | '<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' + | |
126 | '<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' + |
|
126 | '<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' + | |
127 | '<td class="values"></td>' |
|
127 | '<td class="values"></td>' | |
128 | ); |
|
128 | ); | |
129 | filterTable.append(tr); |
|
129 | filterTable.append(tr); | |
130 |
|
130 | |||
131 | select = tr.find('td.operator select'); |
|
131 | select = tr.find('td.operator select'); | |
132 | for (i = 0; i < operators.length; i++) { |
|
132 | for (i = 0; i < operators.length; i++) { | |
133 | var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]); |
|
133 | var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]); | |
134 | if (operators[i] == operator) { option.attr('selected', true); } |
|
134 | if (operators[i] == operator) { option.attr('selected', true); } | |
135 | select.append(option); |
|
135 | select.append(option); | |
136 | } |
|
136 | } | |
137 | select.change(function(){ toggleOperator(field); }); |
|
137 | select.change(function(){ toggleOperator(field); }); | |
138 |
|
138 | |||
139 | switch (filterOptions['type']) { |
|
139 | switch (filterOptions['type']) { | |
140 | case "list": |
|
140 | case "list": | |
141 | case "list_optional": |
|
141 | case "list_optional": | |
142 | case "list_status": |
|
142 | case "list_status": | |
143 | case "list_subprojects": |
|
143 | case "list_subprojects": | |
144 | tr.find('td.values').append( |
|
144 | tr.find('td.values').append( | |
145 | '<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' + |
|
145 | '<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' + | |
146 | ' <span class="toggle-multiselect"> </span></span>' |
|
146 | ' <span class="toggle-multiselect"> </span></span>' | |
147 | ); |
|
147 | ); | |
148 | select = tr.find('td.values select'); |
|
148 | select = tr.find('td.values select'); | |
149 | if (values.length > 1) { select.attr('multiple', true); } |
|
149 | if (values.length > 1) { select.attr('multiple', true); } | |
150 | for (i = 0; i < filterValues.length; i++) { |
|
150 | for (i = 0; i < filterValues.length; i++) { | |
151 | var filterValue = filterValues[i]; |
|
151 | var filterValue = filterValues[i]; | |
152 | var option = $('<option>'); |
|
152 | var option = $('<option>'); | |
153 | if ($.isArray(filterValue)) { |
|
153 | if ($.isArray(filterValue)) { | |
154 | option.val(filterValue[1]).text(filterValue[0]); |
|
154 | option.val(filterValue[1]).text(filterValue[0]); | |
155 | if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);} |
|
155 | if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);} | |
156 | } else { |
|
156 | } else { | |
157 | option.val(filterValue).text(filterValue); |
|
157 | option.val(filterValue).text(filterValue); | |
158 | if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);} |
|
158 | if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);} | |
159 | } |
|
159 | } | |
160 | select.append(option); |
|
160 | select.append(option); | |
161 | } |
|
161 | } | |
162 | break; |
|
162 | break; | |
163 | case "date": |
|
163 | case "date": | |
164 | case "date_past": |
|
164 | case "date_past": | |
165 | tr.find('td.values').append( |
|
165 | tr.find('td.values').append( | |
166 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' + |
|
166 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' + | |
167 | ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' + |
|
167 | ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' + | |
168 | ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>' |
|
168 | ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>' | |
169 | ); |
|
169 | ); | |
170 | $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions); |
|
170 | $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions); | |
171 | $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions); |
|
171 | $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions); | |
172 | $('#values_'+fieldId).val(values[0]); |
|
172 | $('#values_'+fieldId).val(values[0]); | |
173 | break; |
|
173 | break; | |
174 | case "string": |
|
174 | case "string": | |
175 | case "text": |
|
175 | case "text": | |
176 | tr.find('td.values').append( |
|
176 | tr.find('td.values').append( | |
177 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>' |
|
177 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>' | |
178 | ); |
|
178 | ); | |
179 | $('#values_'+fieldId).val(values[0]); |
|
179 | $('#values_'+fieldId).val(values[0]); | |
180 | break; |
|
180 | break; | |
181 | case "relation": |
|
181 | case "relation": | |
182 | tr.find('td.values').append( |
|
182 | tr.find('td.values').append( | |
183 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' + |
|
183 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' + | |
184 | '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>' |
|
184 | '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>' | |
185 | ); |
|
185 | ); | |
186 | $('#values_'+fieldId).val(values[0]); |
|
186 | $('#values_'+fieldId).val(values[0]); | |
187 | select = tr.find('td.values select'); |
|
187 | select = tr.find('td.values select'); | |
188 | for (i = 0; i < allProjects.length; i++) { |
|
188 | for (i = 0; i < allProjects.length; i++) { | |
189 | var filterValue = allProjects[i]; |
|
189 | var filterValue = allProjects[i]; | |
190 | var option = $('<option>'); |
|
190 | var option = $('<option>'); | |
191 | option.val(filterValue[1]).text(filterValue[0]); |
|
191 | option.val(filterValue[1]).text(filterValue[0]); | |
192 | if (values[0] == filterValue[1]) { option.attr('selected', true); } |
|
192 | if (values[0] == filterValue[1]) { option.attr('selected', true); } | |
193 | select.append(option); |
|
193 | select.append(option); | |
194 | } |
|
194 | } | |
195 | case "integer": |
|
195 | case "integer": | |
196 | case "float": |
|
196 | case "float": | |
197 | tr.find('td.values').append( |
|
197 | tr.find('td.values').append( | |
198 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="6" class="value" /></span>' + |
|
198 | '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="6" class="value" /></span>' + | |
199 | ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="6" class="value" /></span>' |
|
199 | ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="6" class="value" /></span>' | |
200 | ); |
|
200 | ); | |
201 | $('#values_'+fieldId+'_1').val(values[0]); |
|
201 | $('#values_'+fieldId+'_1').val(values[0]); | |
202 | $('#values_'+fieldId+'_2').val(values[1]); |
|
202 | $('#values_'+fieldId+'_2').val(values[1]); | |
203 | break; |
|
203 | break; | |
204 | } |
|
204 | } | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | function toggleFilter(field) { |
|
207 | function toggleFilter(field) { | |
208 | var fieldId = field.replace('.', '_'); |
|
208 | var fieldId = field.replace('.', '_'); | |
209 | if ($('#cb_' + fieldId).is(':checked')) { |
|
209 | if ($('#cb_' + fieldId).is(':checked')) { | |
210 | $("#operators_" + fieldId).show().removeAttr('disabled'); |
|
210 | $("#operators_" + fieldId).show().removeAttr('disabled'); | |
211 | toggleOperator(field); |
|
211 | toggleOperator(field); | |
212 | } else { |
|
212 | } else { | |
213 | $("#operators_" + fieldId).hide().attr('disabled', true); |
|
213 | $("#operators_" + fieldId).hide().attr('disabled', true); | |
214 | enableValues(field, []); |
|
214 | enableValues(field, []); | |
215 | } |
|
215 | } | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | function enableValues(field, indexes) { |
|
218 | function enableValues(field, indexes) { | |
219 | var fieldId = field.replace('.', '_'); |
|
219 | var fieldId = field.replace('.', '_'); | |
220 | $('#tr_'+fieldId+' td.values .value').each(function(index) { |
|
220 | $('#tr_'+fieldId+' td.values .value').each(function(index) { | |
221 | if ($.inArray(index, indexes) >= 0) { |
|
221 | if ($.inArray(index, indexes) >= 0) { | |
222 | $(this).removeAttr('disabled'); |
|
222 | $(this).removeAttr('disabled'); | |
223 | $(this).parents('span').first().show(); |
|
223 | $(this).parents('span').first().show(); | |
224 | } else { |
|
224 | } else { | |
225 | $(this).val(''); |
|
225 | $(this).val(''); | |
226 | $(this).attr('disabled', true); |
|
226 | $(this).attr('disabled', true); | |
227 | $(this).parents('span').first().hide(); |
|
227 | $(this).parents('span').first().hide(); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | if ($(this).hasClass('group')) { |
|
230 | if ($(this).hasClass('group')) { | |
231 | $(this).addClass('open'); |
|
231 | $(this).addClass('open'); | |
232 | } else { |
|
232 | } else { | |
233 | $(this).show(); |
|
233 | $(this).show(); | |
234 | } |
|
234 | } | |
235 | }); |
|
235 | }); | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | function toggleOperator(field) { |
|
238 | function toggleOperator(field) { | |
239 | var fieldId = field.replace('.', '_'); |
|
239 | var fieldId = field.replace('.', '_'); | |
240 | var operator = $("#operators_" + fieldId); |
|
240 | var operator = $("#operators_" + fieldId); | |
241 | switch (operator.val()) { |
|
241 | switch (operator.val()) { | |
242 | case "!*": |
|
242 | case "!*": | |
243 | case "*": |
|
243 | case "*": | |
244 | case "t": |
|
244 | case "t": | |
245 | case "ld": |
|
245 | case "ld": | |
246 | case "w": |
|
246 | case "w": | |
247 | case "lw": |
|
247 | case "lw": | |
248 | case "l2w": |
|
248 | case "l2w": | |
249 | case "m": |
|
249 | case "m": | |
250 | case "lm": |
|
250 | case "lm": | |
251 | case "y": |
|
251 | case "y": | |
252 | case "o": |
|
252 | case "o": | |
253 | case "c": |
|
253 | case "c": | |
254 | enableValues(field, []); |
|
254 | enableValues(field, []); | |
255 | break; |
|
255 | break; | |
256 | case "><": |
|
256 | case "><": | |
257 | enableValues(field, [0,1]); |
|
257 | enableValues(field, [0,1]); | |
258 | break; |
|
258 | break; | |
259 | case "<t+": |
|
259 | case "<t+": | |
260 | case ">t+": |
|
260 | case ">t+": | |
261 | case "><t+": |
|
261 | case "><t+": | |
262 | case "t+": |
|
262 | case "t+": | |
263 | case ">t-": |
|
263 | case ">t-": | |
264 | case "<t-": |
|
264 | case "<t-": | |
265 | case "><t-": |
|
265 | case "><t-": | |
266 | case "t-": |
|
266 | case "t-": | |
267 | enableValues(field, [2]); |
|
267 | enableValues(field, [2]); | |
268 | break; |
|
268 | break; | |
269 | case "=p": |
|
269 | case "=p": | |
270 | case "=!p": |
|
270 | case "=!p": | |
271 | case "!p": |
|
271 | case "!p": | |
272 | enableValues(field, [1]); |
|
272 | enableValues(field, [1]); | |
273 | break; |
|
273 | break; | |
274 | default: |
|
274 | default: | |
275 | enableValues(field, [0]); |
|
275 | enableValues(field, [0]); | |
276 | break; |
|
276 | break; | |
277 | } |
|
277 | } | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 | function toggleMultiSelect(el) { |
|
280 | function toggleMultiSelect(el) { | |
281 | if (el.attr('multiple')) { |
|
281 | if (el.attr('multiple')) { | |
282 | el.removeAttr('multiple'); |
|
282 | el.removeAttr('multiple'); | |
283 | } else { |
|
283 | } else { | |
284 | el.attr('multiple', true); |
|
284 | el.attr('multiple', true); | |
285 | } |
|
285 | } | |
286 | } |
|
286 | } | |
287 |
|
287 | |||
288 | function submit_query_form(id) { |
|
288 | function submit_query_form(id) { | |
289 | selectAllOptions("selected_columns"); |
|
289 | selectAllOptions("selected_columns"); | |
290 | $('#'+id).submit(); |
|
290 | $('#'+id).submit(); | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | function showTab(name, url) { |
|
293 | function showTab(name, url) { | |
294 | $('div#content .tab-content').hide(); |
|
294 | $('div#content .tab-content').hide(); | |
295 | $('div.tabs a').removeClass('selected'); |
|
295 | $('div.tabs a').removeClass('selected'); | |
296 | $('#tab-content-' + name).show(); |
|
296 | $('#tab-content-' + name).show(); | |
297 | $('#tab-' + name).addClass('selected'); |
|
297 | $('#tab-' + name).addClass('selected'); | |
298 | //replaces current URL with the "href" attribute of the current link |
|
298 | //replaces current URL with the "href" attribute of the current link | |
299 | //(only triggered if supported by browser) |
|
299 | //(only triggered if supported by browser) | |
300 | if ("replaceState" in window.history) { |
|
300 | if ("replaceState" in window.history) { | |
301 | window.history.replaceState(null, document.title, url); |
|
301 | window.history.replaceState(null, document.title, url); | |
302 | } |
|
302 | } | |
303 | return false; |
|
303 | return false; | |
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 | function moveTabRight(el) { |
|
306 | function moveTabRight(el) { | |
307 | var lis = $(el).parents('div.tabs').first().find('ul').children(); |
|
307 | var lis = $(el).parents('div.tabs').first().find('ul').children(); | |
308 | var tabsWidth = 0; |
|
308 | var tabsWidth = 0; | |
309 | var i = 0; |
|
309 | var i = 0; | |
310 | lis.each(function() { |
|
310 | lis.each(function() { | |
311 | if ($(this).is(':visible')) { |
|
311 | if ($(this).is(':visible')) { | |
312 | tabsWidth += $(this).width() + 6; |
|
312 | tabsWidth += $(this).width() + 6; | |
313 | } |
|
313 | } | |
314 | }); |
|
314 | }); | |
315 | if (tabsWidth < $(el).parents('div.tabs').first().width() - 60) { return; } |
|
315 | if (tabsWidth < $(el).parents('div.tabs').first().width() - 60) { return; } | |
316 | while (i<lis.length && !lis.eq(i).is(':visible')) { i++; } |
|
316 | while (i<lis.length && !lis.eq(i).is(':visible')) { i++; } | |
317 | lis.eq(i).hide(); |
|
317 | lis.eq(i).hide(); | |
318 | } |
|
318 | } | |
319 |
|
319 | |||
320 | function moveTabLeft(el) { |
|
320 | function moveTabLeft(el) { | |
321 | var lis = $(el).parents('div.tabs').first().find('ul').children(); |
|
321 | var lis = $(el).parents('div.tabs').first().find('ul').children(); | |
322 | var i = 0; |
|
322 | var i = 0; | |
323 | while (i < lis.length && !lis.eq(i).is(':visible')) { i++; } |
|
323 | while (i < lis.length && !lis.eq(i).is(':visible')) { i++; } | |
324 | if (i > 0) { |
|
324 | if (i > 0) { | |
325 | lis.eq(i-1).show(); |
|
325 | lis.eq(i-1).show(); | |
326 | } |
|
326 | } | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | function displayTabsButtons() { |
|
329 | function displayTabsButtons() { | |
330 | var lis; |
|
330 | var lis; | |
331 | var tabsWidth = 0; |
|
331 | var tabsWidth = 0; | |
332 | var el; |
|
332 | var el; | |
333 | $('div.tabs').each(function() { |
|
333 | $('div.tabs').each(function() { | |
334 | el = $(this); |
|
334 | el = $(this); | |
335 | lis = el.find('ul').children(); |
|
335 | lis = el.find('ul').children(); | |
336 | lis.each(function(){ |
|
336 | lis.each(function(){ | |
337 | if ($(this).is(':visible')) { |
|
337 | if ($(this).is(':visible')) { | |
338 | tabsWidth += $(this).width() + 6; |
|
338 | tabsWidth += $(this).width() + 6; | |
339 | } |
|
339 | } | |
340 | }); |
|
340 | }); | |
341 | if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) { |
|
341 | if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) { | |
342 | el.find('div.tabs-buttons').hide(); |
|
342 | el.find('div.tabs-buttons').hide(); | |
343 | } else { |
|
343 | } else { | |
344 | el.find('div.tabs-buttons').show(); |
|
344 | el.find('div.tabs-buttons').show(); | |
345 | } |
|
345 | } | |
346 | }); |
|
346 | }); | |
347 | } |
|
347 | } | |
348 |
|
348 | |||
349 | function setPredecessorFieldsVisibility() { |
|
349 | function setPredecessorFieldsVisibility() { | |
350 | var relationType = $('#relation_relation_type'); |
|
350 | var relationType = $('#relation_relation_type'); | |
351 | if (relationType.val() == "precedes" || relationType.val() == "follows") { |
|
351 | if (relationType.val() == "precedes" || relationType.val() == "follows") { | |
352 | $('#predecessor_fields').show(); |
|
352 | $('#predecessor_fields').show(); | |
353 | } else { |
|
353 | } else { | |
354 | $('#predecessor_fields').hide(); |
|
354 | $('#predecessor_fields').hide(); | |
355 | } |
|
355 | } | |
356 | } |
|
356 | } | |
357 |
|
357 | |||
358 | function showModal(id, width) { |
|
358 | function showModal(id, width) { | |
359 | var el = $('#'+id).first(); |
|
359 | var el = $('#'+id).first(); | |
360 | if (el.length === 0 || el.is(':visible')) {return;} |
|
360 | if (el.length === 0 || el.is(':visible')) {return;} | |
361 | var title = el.find('h3.title').text(); |
|
361 | var title = el.find('h3.title').text(); | |
362 | el.dialog({ |
|
362 | el.dialog({ | |
363 | width: width, |
|
363 | width: width, | |
364 | modal: true, |
|
364 | modal: true, | |
365 | resizable: false, |
|
365 | resizable: false, | |
366 | dialogClass: 'modal', |
|
366 | dialogClass: 'modal', | |
367 | title: title |
|
367 | title: title | |
368 | }); |
|
368 | }); | |
369 | el.find("input[type=text], input[type=submit]").first().focus(); |
|
369 | el.find("input[type=text], input[type=submit]").first().focus(); | |
370 | } |
|
370 | } | |
371 |
|
371 | |||
372 | function hideModal(el) { |
|
372 | function hideModal(el) { | |
373 | var modal; |
|
373 | var modal; | |
374 | if (el) { |
|
374 | if (el) { | |
375 | modal = $(el).parents('.ui-dialog-content'); |
|
375 | modal = $(el).parents('.ui-dialog-content'); | |
376 | } else { |
|
376 | } else { | |
377 | modal = $('#ajax-modal'); |
|
377 | modal = $('#ajax-modal'); | |
378 | } |
|
378 | } | |
379 | modal.dialog("close"); |
|
379 | modal.dialog("close"); | |
380 | } |
|
380 | } | |
381 |
|
381 | |||
382 | function submitPreview(url, form, target) { |
|
382 | function submitPreview(url, form, target) { | |
383 | $.ajax({ |
|
383 | $.ajax({ | |
384 | url: url, |
|
384 | url: url, | |
385 | type: 'post', |
|
385 | type: 'post', | |
386 | data: $('#'+form).serialize(), |
|
386 | data: $('#'+form).serialize(), | |
387 | success: function(data){ |
|
387 | success: function(data){ | |
388 | $('#'+target).html(data); |
|
388 | $('#'+target).html(data); | |
389 | } |
|
389 | } | |
390 | }); |
|
390 | }); | |
391 | } |
|
391 | } | |
392 |
|
392 | |||
393 | function collapseScmEntry(id) { |
|
393 | function collapseScmEntry(id) { | |
394 | $('.'+id).each(function() { |
|
394 | $('.'+id).each(function() { | |
395 | if ($(this).hasClass('open')) { |
|
395 | if ($(this).hasClass('open')) { | |
396 | collapseScmEntry($(this).attr('id')); |
|
396 | collapseScmEntry($(this).attr('id')); | |
397 | } |
|
397 | } | |
398 | $(this).hide(); |
|
398 | $(this).hide(); | |
399 | }); |
|
399 | }); | |
400 | $('#'+id).removeClass('open'); |
|
400 | $('#'+id).removeClass('open'); | |
401 | } |
|
401 | } | |
402 |
|
402 | |||
403 | function expandScmEntry(id) { |
|
403 | function expandScmEntry(id) { | |
404 | $('.'+id).each(function() { |
|
404 | $('.'+id).each(function() { | |
405 | $(this).show(); |
|
405 | $(this).show(); | |
406 | if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) { |
|
406 | if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) { | |
407 | expandScmEntry($(this).attr('id')); |
|
407 | expandScmEntry($(this).attr('id')); | |
408 | } |
|
408 | } | |
409 | }); |
|
409 | }); | |
410 | $('#'+id).addClass('open'); |
|
410 | $('#'+id).addClass('open'); | |
411 | } |
|
411 | } | |
412 |
|
412 | |||
413 | function scmEntryClick(id, url) { |
|
413 | function scmEntryClick(id, url) { | |
414 | el = $('#'+id); |
|
414 | el = $('#'+id); | |
415 | if (el.hasClass('open')) { |
|
415 | if (el.hasClass('open')) { | |
416 | collapseScmEntry(id); |
|
416 | collapseScmEntry(id); | |
417 | el.addClass('collapsed'); |
|
417 | el.addClass('collapsed'); | |
418 | return false; |
|
418 | return false; | |
419 | } else if (el.hasClass('loaded')) { |
|
419 | } else if (el.hasClass('loaded')) { | |
420 | expandScmEntry(id); |
|
420 | expandScmEntry(id); | |
421 | el.removeClass('collapsed'); |
|
421 | el.removeClass('collapsed'); | |
422 | return false; |
|
422 | return false; | |
423 | } |
|
423 | } | |
424 | if (el.hasClass('loading')) { |
|
424 | if (el.hasClass('loading')) { | |
425 | return false; |
|
425 | return false; | |
426 | } |
|
426 | } | |
427 | el.addClass('loading'); |
|
427 | el.addClass('loading'); | |
428 | $.ajax({ |
|
428 | $.ajax({ | |
429 | url: url, |
|
429 | url: url, | |
430 | success: function(data) { |
|
430 | success: function(data) { | |
431 | el.after(data); |
|
431 | el.after(data); | |
432 | el.addClass('open').addClass('loaded').removeClass('loading'); |
|
432 | el.addClass('open').addClass('loaded').removeClass('loading'); | |
433 | } |
|
433 | } | |
434 | }); |
|
434 | }); | |
435 | return true; |
|
435 | return true; | |
436 | } |
|
436 | } | |
437 |
|
437 | |||
438 | function randomKey(size) { |
|
438 | function randomKey(size) { | |
439 | var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
|
439 | var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
440 | var key = ''; |
|
440 | var key = ''; | |
441 | for (var i = 0; i < size; i++) { |
|
441 | for (var i = 0; i < size; i++) { | |
442 | key += chars.charAt(Math.floor(Math.random() * chars.length)); |
|
442 | key += chars.charAt(Math.floor(Math.random() * chars.length)); | |
443 | } |
|
443 | } | |
444 | return key; |
|
444 | return key; | |
445 | } |
|
445 | } | |
446 |
|
446 | |||
447 | function updateIssueFrom(url) { |
|
447 | function updateIssueFrom(url) { | |
448 | $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){ |
|
448 | $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){ | |
449 | $(this).data('valuebeforeupdate', $(this).val()); |
|
449 | $(this).data('valuebeforeupdate', $(this).val()); | |
450 | }); |
|
450 | }); | |
451 | $.ajax({ |
|
451 | $.ajax({ | |
452 | url: url, |
|
452 | url: url, | |
453 | type: 'post', |
|
453 | type: 'post', | |
454 | data: $('#issue-form').serialize() |
|
454 | data: $('#issue-form').serialize() | |
455 | }); |
|
455 | }); | |
456 | } |
|
456 | } | |
457 |
|
457 | |||
458 | function replaceIssueFormWith(html){ |
|
458 | function replaceIssueFormWith(html){ | |
459 | var replacement = $(html); |
|
459 | var replacement = $(html); | |
460 | $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){ |
|
460 | $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){ | |
461 | var object_id = $(this).attr('id'); |
|
461 | var object_id = $(this).attr('id'); | |
462 | if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) { |
|
462 | if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) { | |
463 | replacement.find('#'+object_id).val($(this).val()); |
|
463 | replacement.find('#'+object_id).val($(this).val()); | |
464 | } |
|
464 | } | |
465 | }); |
|
465 | }); | |
466 | $('#all_attributes').empty(); |
|
466 | $('#all_attributes').empty(); | |
467 | $('#all_attributes').prepend(replacement); |
|
467 | $('#all_attributes').prepend(replacement); | |
468 | } |
|
468 | } | |
469 |
|
469 | |||
470 | function updateBulkEditFrom(url) { |
|
470 | function updateBulkEditFrom(url) { | |
471 | $.ajax({ |
|
471 | $.ajax({ | |
472 | url: url, |
|
472 | url: url, | |
473 | type: 'post', |
|
473 | type: 'post', | |
474 | data: $('#bulk_edit_form').serialize() |
|
474 | data: $('#bulk_edit_form').serialize() | |
475 | }); |
|
475 | }); | |
476 | } |
|
476 | } | |
477 |
|
477 | |||
478 | function observeAutocompleteField(fieldId, url, options) { |
|
478 | function observeAutocompleteField(fieldId, url, options) { | |
479 | $(document).ready(function() { |
|
479 | $(document).ready(function() { | |
480 | $('#'+fieldId).autocomplete($.extend({ |
|
480 | $('#'+fieldId).autocomplete($.extend({ | |
481 | source: url, |
|
481 | source: url, | |
482 | minLength: 2, |
|
482 | minLength: 2, | |
483 | search: function(){$('#'+fieldId).addClass('ajax-loading');}, |
|
483 | search: function(){$('#'+fieldId).addClass('ajax-loading');}, | |
484 | response: function(){$('#'+fieldId).removeClass('ajax-loading');} |
|
484 | response: function(){$('#'+fieldId).removeClass('ajax-loading');} | |
485 | }, options)); |
|
485 | }, options)); | |
486 | $('#'+fieldId).addClass('autocomplete'); |
|
486 | $('#'+fieldId).addClass('autocomplete'); | |
487 | }); |
|
487 | }); | |
488 | } |
|
488 | } | |
489 |
|
489 | |||
490 | function observeSearchfield(fieldId, targetId, url) { |
|
490 | function observeSearchfield(fieldId, targetId, url) { | |
491 | $('#'+fieldId).each(function() { |
|
491 | $('#'+fieldId).each(function() { | |
492 | var $this = $(this); |
|
492 | var $this = $(this); | |
493 | $this.addClass('autocomplete'); |
|
493 | $this.addClass('autocomplete'); | |
494 | $this.attr('data-value-was', $this.val()); |
|
494 | $this.attr('data-value-was', $this.val()); | |
495 | var check = function() { |
|
495 | var check = function() { | |
496 | var val = $this.val(); |
|
496 | var val = $this.val(); | |
497 | if ($this.attr('data-value-was') != val){ |
|
497 | if ($this.attr('data-value-was') != val){ | |
498 | $this.attr('data-value-was', val); |
|
498 | $this.attr('data-value-was', val); | |
499 | $.ajax({ |
|
499 | $.ajax({ | |
500 | url: url, |
|
500 | url: url, | |
501 | type: 'get', |
|
501 | type: 'get', | |
502 | data: {q: $this.val()}, |
|
502 | data: {q: $this.val()}, | |
503 | success: function(data){ if(targetId) $('#'+targetId).html(data); }, |
|
503 | success: function(data){ if(targetId) $('#'+targetId).html(data); }, | |
504 | beforeSend: function(){ $this.addClass('ajax-loading'); }, |
|
504 | beforeSend: function(){ $this.addClass('ajax-loading'); }, | |
505 | complete: function(){ $this.removeClass('ajax-loading'); } |
|
505 | complete: function(){ $this.removeClass('ajax-loading'); } | |
506 | }); |
|
506 | }); | |
507 | } |
|
507 | } | |
508 | }; |
|
508 | }; | |
509 | var reset = function() { |
|
509 | var reset = function() { | |
510 | if (timer) { |
|
510 | if (timer) { | |
511 | clearInterval(timer); |
|
511 | clearInterval(timer); | |
512 | timer = setInterval(check, 300); |
|
512 | timer = setInterval(check, 300); | |
513 | } |
|
513 | } | |
514 | }; |
|
514 | }; | |
515 | var timer = setInterval(check, 300); |
|
515 | var timer = setInterval(check, 300); | |
516 | $this.bind('keyup click mousemove', reset); |
|
516 | $this.bind('keyup click mousemove', reset); | |
517 | }); |
|
517 | }); | |
518 | } |
|
518 | } | |
519 |
|
519 | |||
520 | function observeProjectModules() { |
|
|||
521 | var f = function() { |
|
|||
522 | /* Hides trackers and issues custom fields on the new project form when issue_tracking module is disabled */ |
|
|||
523 | if ($('#project_enabled_module_names_issue_tracking').attr('checked')) { |
|
|||
524 | $('#project_trackers').show(); |
|
|||
525 | } else { |
|
|||
526 | $('#project_trackers').hide(); |
|
|||
527 | } |
|
|||
528 | }; |
|
|||
529 |
|
||||
530 | $(window).load(f); |
|
|||
531 | $('#project_enabled_module_names_issue_tracking').change(f); |
|
|||
532 | } |
|
|||
533 |
|
||||
534 | function initMyPageSortable(list, url) { |
|
520 | function initMyPageSortable(list, url) { | |
535 | $('#list-'+list).sortable({ |
|
521 | $('#list-'+list).sortable({ | |
536 | connectWith: '.block-receiver', |
|
522 | connectWith: '.block-receiver', | |
537 | tolerance: 'pointer', |
|
523 | tolerance: 'pointer', | |
538 | update: function(){ |
|
524 | update: function(){ | |
539 | $.ajax({ |
|
525 | $.ajax({ | |
540 | url: url, |
|
526 | url: url, | |
541 | type: 'post', |
|
527 | type: 'post', | |
542 | data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})} |
|
528 | data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})} | |
543 | }); |
|
529 | }); | |
544 | } |
|
530 | } | |
545 | }); |
|
531 | }); | |
546 | $("#list-top, #list-left, #list-right").disableSelection(); |
|
532 | $("#list-top, #list-left, #list-right").disableSelection(); | |
547 | } |
|
533 | } | |
548 |
|
534 | |||
549 | var warnLeavingUnsavedMessage; |
|
535 | var warnLeavingUnsavedMessage; | |
550 | function warnLeavingUnsaved(message) { |
|
536 | function warnLeavingUnsaved(message) { | |
551 | warnLeavingUnsavedMessage = message; |
|
537 | warnLeavingUnsavedMessage = message; | |
552 | $('form').live('submit', function(){ |
|
538 | $('form').live('submit', function(){ | |
553 | $('textarea').removeData('changed'); |
|
539 | $('textarea').removeData('changed'); | |
554 | }); |
|
540 | }); | |
555 | $('textarea').live('change', function(){ |
|
541 | $('textarea').live('change', function(){ | |
556 | $(this).data('changed', 'changed'); |
|
542 | $(this).data('changed', 'changed'); | |
557 | }); |
|
543 | }); | |
558 | window.onbeforeunload = function(){ |
|
544 | window.onbeforeunload = function(){ | |
559 | var warn = false; |
|
545 | var warn = false; | |
560 | $('textarea').blur().each(function(){ |
|
546 | $('textarea').blur().each(function(){ | |
561 | if ($(this).data('changed')) { |
|
547 | if ($(this).data('changed')) { | |
562 | warn = true; |
|
548 | warn = true; | |
563 | } |
|
549 | } | |
564 | }); |
|
550 | }); | |
565 | if (warn) {return warnLeavingUnsavedMessage;} |
|
551 | if (warn) {return warnLeavingUnsavedMessage;} | |
566 | }; |
|
552 | }; | |
567 | } |
|
553 | } | |
568 |
|
554 | |||
569 | function setupAjaxIndicator() { |
|
555 | function setupAjaxIndicator() { | |
570 | $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) { |
|
556 | $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) { | |
571 | if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') { |
|
557 | if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') { | |
572 | $('#ajax-indicator').show(); |
|
558 | $('#ajax-indicator').show(); | |
573 | } |
|
559 | } | |
574 | }); |
|
560 | }); | |
575 | $('#ajax-indicator').bind('ajaxStop', function() { |
|
561 | $('#ajax-indicator').bind('ajaxStop', function() { | |
576 | $('#ajax-indicator').hide(); |
|
562 | $('#ajax-indicator').hide(); | |
577 | }); |
|
563 | }); | |
578 | } |
|
564 | } | |
579 |
|
565 | |||
580 | function hideOnLoad() { |
|
566 | function hideOnLoad() { | |
581 | $('.hol').hide(); |
|
567 | $('.hol').hide(); | |
582 | } |
|
568 | } | |
583 |
|
569 | |||
584 | function addFormObserversForDoubleSubmit() { |
|
570 | function addFormObserversForDoubleSubmit() { | |
585 | $('form[method=post]').each(function() { |
|
571 | $('form[method=post]').each(function() { | |
586 | if (!$(this).hasClass('multiple-submit')) { |
|
572 | if (!$(this).hasClass('multiple-submit')) { | |
587 | $(this).submit(function(form_submission) { |
|
573 | $(this).submit(function(form_submission) { | |
588 | if ($(form_submission.target).attr('data-submitted')) { |
|
574 | if ($(form_submission.target).attr('data-submitted')) { | |
589 | form_submission.preventDefault(); |
|
575 | form_submission.preventDefault(); | |
590 | } else { |
|
576 | } else { | |
591 | $(form_submission.target).attr('data-submitted', true); |
|
577 | $(form_submission.target).attr('data-submitted', true); | |
592 | } |
|
578 | } | |
593 | }); |
|
579 | }); | |
594 | } |
|
580 | } | |
595 | }); |
|
581 | }); | |
596 | } |
|
582 | } | |
597 |
|
583 | |||
598 | function blockEventPropagation(event) { |
|
584 | function blockEventPropagation(event) { | |
599 | event.stopPropagation(); |
|
585 | event.stopPropagation(); | |
600 | event.preventDefault(); |
|
586 | event.preventDefault(); | |
601 | } |
|
587 | } | |
602 |
|
588 | |||
603 | $(document).ready(setupAjaxIndicator); |
|
589 | $(document).ready(setupAjaxIndicator); | |
604 | $(document).ready(hideOnLoad); |
|
590 | $(document).ready(hideOnLoad); | |
605 | $(document).ready(addFormObserversForDoubleSubmit); |
|
591 | $(document).ready(addFormObserversForDoubleSubmit); |
General Comments 0
You need to be logged in to leave comments.
Login now