##// END OF EJS Templates
Focus first text field automatically (#13134)....
Jean-Philippe Lang -
r12395:bacc2508161a
parent child
Show More
@@ -1,55 +1,53
1 <%= title l(:label_issue_new) %>
1 <%= title l(:label_issue_new) %>
2
2
3 <%= call_hook(:view_issues_new_top, {:issue => @issue}) %>
3 <%= call_hook(:view_issues_new_top, {:issue => @issue}) %>
4
4
5 <%= labelled_form_for @issue, :url => project_issues_path(@project),
5 <%= labelled_form_for @issue, :url => project_issues_path(@project),
6 :html => {:id => 'issue-form', :multipart => true} do |f| %>
6 :html => {:id => 'issue-form', :multipart => true} do |f| %>
7 <%= error_messages_for 'issue' %>
7 <%= error_messages_for 'issue' %>
8 <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %>
8 <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %>
9 <div class="box tabular">
9 <div class="box tabular">
10 <div id="all_attributes">
10 <div id="all_attributes">
11 <%= render :partial => 'issues/form', :locals => {:f => f} %>
11 <%= render :partial => 'issues/form', :locals => {:f => f} %>
12 </div>
12 </div>
13
13
14 <% if @copy_from && @copy_from.attachments.any? %>
14 <% if @copy_from && @copy_from.attachments.any? %>
15 <p>
15 <p>
16 <label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
16 <label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
17 <%= check_box_tag 'copy_attachments', '1', @copy_attachments %>
17 <%= check_box_tag 'copy_attachments', '1', @copy_attachments %>
18 </p>
18 </p>
19 <% end %>
19 <% end %>
20 <% if @copy_from && !@copy_from.leaf? %>
20 <% if @copy_from && !@copy_from.leaf? %>
21 <p>
21 <p>
22 <label for="copy_subtasks"><%= l(:label_copy_subtasks) %></label>
22 <label for="copy_subtasks"><%= l(:label_copy_subtasks) %></label>
23 <%= check_box_tag 'copy_subtasks', '1', @copy_subtasks %>
23 <%= check_box_tag 'copy_subtasks', '1', @copy_subtasks %>
24 </p>
24 </p>
25 <% end %>
25 <% end %>
26
26
27 <p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
27 <p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
28
28
29 <% if @issue.safe_attribute? 'watcher_user_ids' -%>
29 <% if @issue.safe_attribute? 'watcher_user_ids' -%>
30 <p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
30 <p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
31 <span id="watchers_inputs">
31 <span id="watchers_inputs">
32 <%= watchers_checkboxes(@issue, @available_watchers) %>
32 <%= watchers_checkboxes(@issue, @available_watchers) %>
33 </span>
33 </span>
34 <span class="search_for_watchers">
34 <span class="search_for_watchers">
35 <%= link_to l(:label_search_for_watchers),
35 <%= link_to l(:label_search_for_watchers),
36 {:controller => 'watchers', :action => 'new', :project_id => @issue.project},
36 {:controller => 'watchers', :action => 'new', :project_id => @issue.project},
37 :remote => true,
37 :remote => true,
38 :method => 'get' %>
38 :method => 'get' %>
39 </span>
39 </span>
40 </p>
40 </p>
41 <% end %>
41 <% end %>
42 </div>
42 </div>
43
43
44 <%= submit_tag l(:button_create) %>
44 <%= submit_tag l(:button_create) %>
45 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
45 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
46 <%= preview_link preview_new_issue_path(:project_id => @project), 'issue-form' %>
46 <%= preview_link preview_new_issue_path(:project_id => @project), 'issue-form' %>
47
48 <%= javascript_tag "$('#issue_subject').focus();" %>
49 <% end %>
47 <% end %>
50
48
51 <div id="preview" class="wiki"></div>
49 <div id="preview" class="wiki"></div>
52
50
53 <% content_for :header_tags do %>
51 <% content_for :header_tags do %>
54 <%= robot_exclusion_tag %>
52 <%= robot_exclusion_tag %>
55 <% end %>
53 <% end %>
@@ -1,26 +1,24
1 <h2><%=l(:button_change_password)%></h2>
1 <h2><%=l(:button_change_password)%></h2>
2
2
3 <%= error_messages_for 'user' %>
3 <%= error_messages_for 'user' %>
4
4
5 <%= form_tag({}, :class => "tabular") do %>
5 <%= form_tag({}, :class => "tabular") do %>
6 <div class="box">
6 <div class="box">
7 <p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
7 <p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
8 <%= password_field_tag 'password', nil, :size => 25 %></p>
8 <%= password_field_tag 'password', nil, :size => 25 %></p>
9
9
10 <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
10 <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
11 <%= password_field_tag 'new_password', nil, :size => 25 %>
11 <%= password_field_tag 'new_password', nil, :size => 25 %>
12 <em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
12 <em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
13
13
14 <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
14 <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
15 <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
15 <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
16 </div>
16 </div>
17 <%= submit_tag l(:button_apply) %>
17 <%= submit_tag l(:button_apply) %>
18 <% end %>
18 <% end %>
19
19
20 <% unless @user.must_change_passwd? %>
20 <% unless @user.must_change_passwd? %>
21 <% content_for :sidebar do %>
21 <% content_for :sidebar do %>
22 <%= render :partial => 'sidebar' %>
22 <%= render :partial => 'sidebar' %>
23 <% end %>
23 <% end %>
24 <% end %>
24 <% end %>
25
26 <%= javascript_tag "$('#password').focus();" %>
@@ -1,8 +1,7
1 <%= title l(:label_project_new) %>
1 <%= title l(:label_project_new) %>
2
2
3 <%= labelled_form_for @project do |f| %>
3 <%= labelled_form_for @project do |f| %>
4 <%= render :partial => 'form', :locals => { :f => f } %>
4 <%= render :partial => 'form', :locals => { :f => f } %>
5 <%= submit_tag l(:button_create) %>
5 <%= submit_tag l(:button_create) %>
6 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
6 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
7 <%= javascript_tag "$('#project_name').focus();" %>
8 <% end %>
7 <% end %>
@@ -1,64 +1,63
1 <h2><%= l(:label_search) %></h2>
1 <h2><%= l(:label_search) %></h2>
2
2
3 <div class="box">
3 <div class="box">
4 <%= form_tag({}, :method => :get, :id => 'search-form') do %>
4 <%= form_tag({}, :method => :get, :id => 'search-form') do %>
5 <%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %>
5 <%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %>
6 <p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %>
6 <p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %>
7 <%= javascript_tag "$('#search-input').focus()" %>
8 <%= project_select_tag %>
7 <%= project_select_tag %>
9 <%= hidden_field_tag 'all_words', '', :id => nil %>
8 <%= hidden_field_tag 'all_words', '', :id => nil %>
10 <label><%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></label>
9 <label><%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></label>
11 <%= hidden_field_tag 'titles_only', '', :id => nil %>
10 <%= hidden_field_tag 'titles_only', '', :id => nil %>
12 <label><%= check_box_tag 'titles_only', 1, @titles_only %> <%= l(:label_search_titles_only) %></label>
11 <label><%= check_box_tag 'titles_only', 1, @titles_only %> <%= l(:label_search_titles_only) %></label>
13 </p>
12 </p>
14
13
15 <p id="search-types">
14 <p id="search-types">
16 <% @object_types.each do |t| %>
15 <% @object_types.each do |t| %>
17 <label><%= check_box_tag t, 1, @scope.include?(t) %> <%= link_to type_label(t), "#" %></label>
16 <label><%= check_box_tag t, 1, @scope.include?(t) %> <%= link_to type_label(t), "#" %></label>
18 <% end %>
17 <% end %>
19 </p>
18 </p>
20
19
21 <p><%= submit_tag l(:button_submit) %></p>
20 <p><%= submit_tag l(:button_submit) %></p>
22 <% end %>
21 <% end %>
23 </div>
22 </div>
24
23
25 <% if @results %>
24 <% if @results %>
26 <div id="search-results-counts">
25 <div id="search-results-counts">
27 <%= render_results_by_type(@results_by_type) unless @scope.size == 1 %>
26 <%= render_results_by_type(@results_by_type) unless @scope.size == 1 %>
28 </div>
27 </div>
29
28
30 <h3><%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)</h3>
29 <h3><%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)</h3>
31 <dl id="search-results">
30 <dl id="search-results">
32 <% @results.each do |e| %>
31 <% @results.each do |e| %>
33 <dt class="<%= e.event_type %>"><%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, :length => 255), @tokens), e.event_url %></dt>
32 <dt class="<%= e.event_type %>"><%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, :length => 255), @tokens), e.event_url %></dt>
34 <dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span>
33 <dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span>
35 <span class="author"><%= format_time(e.event_datetime) %></span></dd>
34 <span class="author"><%= format_time(e.event_datetime) %></span></dd>
36 <% end %>
35 <% end %>
37 </dl>
36 </dl>
38 <% end %>
37 <% end %>
39
38
40 <p class="pagination">
39 <p class="pagination">
41 <% if @pagination_previous_date %>
40 <% if @pagination_previous_date %>
42 <%= link_to_content_update("\xc2\xab " + l(:label_previous),
41 <%= link_to_content_update("\xc2\xab " + l(:label_previous),
43 params.merge(:previous => 1,
42 params.merge(:previous => 1,
44 :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))) %>&nbsp;
43 :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))) %>&nbsp;
45 <% end %>
44 <% end %>
46 <% if @pagination_next_date %>
45 <% if @pagination_next_date %>
47 <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
46 <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
48 params.merge(:previous => nil,
47 params.merge(:previous => nil,
49 :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))) %>
48 :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))) %>
50 <% end %>
49 <% end %>
51 </p>
50 </p>
52
51
53 <% html_title(l(:label_search)) -%>
52 <% html_title(l(:label_search)) -%>
54
53
55 <%= javascript_tag do %>
54 <%= javascript_tag do %>
56 $("#search-types a").click(function(e){
55 $("#search-types a").click(function(e){
57 e.preventDefault();
56 e.preventDefault();
58 $("#search-types input[type=checkbox]").attr('checked', false);
57 $("#search-types input[type=checkbox]").attr('checked', false);
59 $(this).siblings("input[type=checkbox]").attr('checked', true);
58 $(this).siblings("input[type=checkbox]").attr('checked', true);
60 if ($("#search-input").val() != "") {
59 if ($("#search-input").val() != "") {
61 $("#search-form").submit();
60 $("#search-form").submit();
62 }
61 }
63 });
62 });
64 <% end %>
63 <% end %>
@@ -1,607 +1,614
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 $('#'+id).find('input[type=checkbox]:enabled').attr('checked', checked);
5 $('#'+id).find('input[type=checkbox]:enabled').attr('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).attr('checked', !all_checked);
13 $(selector).attr('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 function initFilters() {
77 function initFilters() {
78 $('#add_filter_select').change(function() {
78 $('#add_filter_select').change(function() {
79 addFilter($(this).val(), '', []);
79 addFilter($(this).val(), '', []);
80 });
80 });
81 $('#filters-table td.field input[type=checkbox]').each(function() {
81 $('#filters-table td.field input[type=checkbox]').each(function() {
82 toggleFilter($(this).val());
82 toggleFilter($(this).val());
83 });
83 });
84 $('#filters-table td.field input[type=checkbox]').live('click', function() {
84 $('#filters-table td.field input[type=checkbox]').live('click', function() {
85 toggleFilter($(this).val());
85 toggleFilter($(this).val());
86 });
86 });
87 $('#filters-table .toggle-multiselect').live('click', function() {
87 $('#filters-table .toggle-multiselect').live('click', function() {
88 toggleMultiSelect($(this).siblings('select'));
88 toggleMultiSelect($(this).siblings('select'));
89 });
89 });
90 $('#filters-table input[type=text]').live('keypress', function(e) {
90 $('#filters-table input[type=text]').live('keypress', function(e) {
91 if (e.keyCode == 13) submit_query_form("query_form");
91 if (e.keyCode == 13) submit_query_form("query_form");
92 });
92 });
93 }
93 }
94
94
95 function addFilter(field, operator, values) {
95 function addFilter(field, operator, values) {
96 var fieldId = field.replace('.', '_');
96 var fieldId = field.replace('.', '_');
97 var tr = $('#tr_'+fieldId);
97 var tr = $('#tr_'+fieldId);
98 if (tr.length > 0) {
98 if (tr.length > 0) {
99 tr.show();
99 tr.show();
100 } else {
100 } else {
101 buildFilterRow(field, operator, values);
101 buildFilterRow(field, operator, values);
102 }
102 }
103 $('#cb_'+fieldId).attr('checked', true);
103 $('#cb_'+fieldId).attr('checked', true);
104 toggleFilter(field);
104 toggleFilter(field);
105 $('#add_filter_select').val('').children('option').each(function() {
105 $('#add_filter_select').val('').children('option').each(function() {
106 if ($(this).attr('value') == field) {
106 if ($(this).attr('value') == field) {
107 $(this).attr('disabled', true);
107 $(this).attr('disabled', true);
108 }
108 }
109 });
109 });
110 }
110 }
111
111
112 function buildFilterRow(field, operator, values) {
112 function buildFilterRow(field, operator, values) {
113 var fieldId = field.replace('.', '_');
113 var fieldId = field.replace('.', '_');
114 var filterTable = $("#filters-table");
114 var filterTable = $("#filters-table");
115 var filterOptions = availableFilters[field];
115 var filterOptions = availableFilters[field];
116 if (!filterOptions) return;
116 if (!filterOptions) return;
117 var operators = operatorByType[filterOptions['type']];
117 var operators = operatorByType[filterOptions['type']];
118 var filterValues = filterOptions['values'];
118 var filterValues = filterOptions['values'];
119 var i, select;
119 var i, select;
120
120
121 var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html(
121 var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html(
122 '<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' +
122 '<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' +
123 '<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' +
123 '<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' +
124 '<td class="values"></td>'
124 '<td class="values"></td>'
125 );
125 );
126 filterTable.append(tr);
126 filterTable.append(tr);
127
127
128 select = tr.find('td.operator select');
128 select = tr.find('td.operator select');
129 for (i = 0; i < operators.length; i++) {
129 for (i = 0; i < operators.length; i++) {
130 var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]);
130 var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]);
131 if (operators[i] == operator) { option.attr('selected', true); }
131 if (operators[i] == operator) { option.attr('selected', true); }
132 select.append(option);
132 select.append(option);
133 }
133 }
134 select.change(function(){ toggleOperator(field); });
134 select.change(function(){ toggleOperator(field); });
135
135
136 switch (filterOptions['type']) {
136 switch (filterOptions['type']) {
137 case "list":
137 case "list":
138 case "list_optional":
138 case "list_optional":
139 case "list_status":
139 case "list_status":
140 case "list_subprojects":
140 case "list_subprojects":
141 tr.find('td.values').append(
141 tr.find('td.values').append(
142 '<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
142 '<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
143 ' <span class="toggle-multiselect">&nbsp;</span></span>'
143 ' <span class="toggle-multiselect">&nbsp;</span></span>'
144 );
144 );
145 select = tr.find('td.values select');
145 select = tr.find('td.values select');
146 if (values.length > 1) { select.attr('multiple', true); }
146 if (values.length > 1) { select.attr('multiple', true); }
147 for (i = 0; i < filterValues.length; i++) {
147 for (i = 0; i < filterValues.length; i++) {
148 var filterValue = filterValues[i];
148 var filterValue = filterValues[i];
149 var option = $('<option>');
149 var option = $('<option>');
150 if ($.isArray(filterValue)) {
150 if ($.isArray(filterValue)) {
151 option.val(filterValue[1]).text(filterValue[0]);
151 option.val(filterValue[1]).text(filterValue[0]);
152 if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);}
152 if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);}
153 } else {
153 } else {
154 option.val(filterValue).text(filterValue);
154 option.val(filterValue).text(filterValue);
155 if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
155 if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
156 }
156 }
157 select.append(option);
157 select.append(option);
158 }
158 }
159 break;
159 break;
160 case "date":
160 case "date":
161 case "date_past":
161 case "date_past":
162 tr.find('td.values').append(
162 tr.find('td.values').append(
163 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
163 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
164 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
164 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
165 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
165 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
166 );
166 );
167 $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions);
167 $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions);
168 $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions);
168 $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions);
169 $('#values_'+fieldId).val(values[0]);
169 $('#values_'+fieldId).val(values[0]);
170 break;
170 break;
171 case "string":
171 case "string":
172 case "text":
172 case "text":
173 tr.find('td.values').append(
173 tr.find('td.values').append(
174 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
174 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
175 );
175 );
176 $('#values_'+fieldId).val(values[0]);
176 $('#values_'+fieldId).val(values[0]);
177 break;
177 break;
178 case "relation":
178 case "relation":
179 tr.find('td.values').append(
179 tr.find('td.values').append(
180 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
180 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
181 '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
181 '<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
182 );
182 );
183 $('#values_'+fieldId).val(values[0]);
183 $('#values_'+fieldId).val(values[0]);
184 select = tr.find('td.values select');
184 select = tr.find('td.values select');
185 for (i = 0; i < allProjects.length; i++) {
185 for (i = 0; i < allProjects.length; i++) {
186 var filterValue = allProjects[i];
186 var filterValue = allProjects[i];
187 var option = $('<option>');
187 var option = $('<option>');
188 option.val(filterValue[1]).text(filterValue[0]);
188 option.val(filterValue[1]).text(filterValue[0]);
189 if (values[0] == filterValue[1]) { option.attr('selected', true); }
189 if (values[0] == filterValue[1]) { option.attr('selected', true); }
190 select.append(option);
190 select.append(option);
191 }
191 }
192 case "integer":
192 case "integer":
193 case "float":
193 case "float":
194 tr.find('td.values').append(
194 tr.find('td.values').append(
195 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="6" class="value" /></span>' +
195 '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="6" class="value" /></span>' +
196 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="6" class="value" /></span>'
196 ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="6" class="value" /></span>'
197 );
197 );
198 $('#values_'+fieldId+'_1').val(values[0]);
198 $('#values_'+fieldId+'_1').val(values[0]);
199 $('#values_'+fieldId+'_2').val(values[1]);
199 $('#values_'+fieldId+'_2').val(values[1]);
200 break;
200 break;
201 }
201 }
202 }
202 }
203
203
204 function toggleFilter(field) {
204 function toggleFilter(field) {
205 var fieldId = field.replace('.', '_');
205 var fieldId = field.replace('.', '_');
206 if ($('#cb_' + fieldId).is(':checked')) {
206 if ($('#cb_' + fieldId).is(':checked')) {
207 $("#operators_" + fieldId).show().removeAttr('disabled');
207 $("#operators_" + fieldId).show().removeAttr('disabled');
208 toggleOperator(field);
208 toggleOperator(field);
209 } else {
209 } else {
210 $("#operators_" + fieldId).hide().attr('disabled', true);
210 $("#operators_" + fieldId).hide().attr('disabled', true);
211 enableValues(field, []);
211 enableValues(field, []);
212 }
212 }
213 }
213 }
214
214
215 function enableValues(field, indexes) {
215 function enableValues(field, indexes) {
216 var fieldId = field.replace('.', '_');
216 var fieldId = field.replace('.', '_');
217 $('#tr_'+fieldId+' td.values .value').each(function(index) {
217 $('#tr_'+fieldId+' td.values .value').each(function(index) {
218 if ($.inArray(index, indexes) >= 0) {
218 if ($.inArray(index, indexes) >= 0) {
219 $(this).removeAttr('disabled');
219 $(this).removeAttr('disabled');
220 $(this).parents('span').first().show();
220 $(this).parents('span').first().show();
221 } else {
221 } else {
222 $(this).val('');
222 $(this).val('');
223 $(this).attr('disabled', true);
223 $(this).attr('disabled', true);
224 $(this).parents('span').first().hide();
224 $(this).parents('span').first().hide();
225 }
225 }
226
226
227 if ($(this).hasClass('group')) {
227 if ($(this).hasClass('group')) {
228 $(this).addClass('open');
228 $(this).addClass('open');
229 } else {
229 } else {
230 $(this).show();
230 $(this).show();
231 }
231 }
232 });
232 });
233 }
233 }
234
234
235 function toggleOperator(field) {
235 function toggleOperator(field) {
236 var fieldId = field.replace('.', '_');
236 var fieldId = field.replace('.', '_');
237 var operator = $("#operators_" + fieldId);
237 var operator = $("#operators_" + fieldId);
238 switch (operator.val()) {
238 switch (operator.val()) {
239 case "!*":
239 case "!*":
240 case "*":
240 case "*":
241 case "t":
241 case "t":
242 case "ld":
242 case "ld":
243 case "w":
243 case "w":
244 case "lw":
244 case "lw":
245 case "l2w":
245 case "l2w":
246 case "m":
246 case "m":
247 case "lm":
247 case "lm":
248 case "y":
248 case "y":
249 case "o":
249 case "o":
250 case "c":
250 case "c":
251 enableValues(field, []);
251 enableValues(field, []);
252 break;
252 break;
253 case "><":
253 case "><":
254 enableValues(field, [0,1]);
254 enableValues(field, [0,1]);
255 break;
255 break;
256 case "<t+":
256 case "<t+":
257 case ">t+":
257 case ">t+":
258 case "><t+":
258 case "><t+":
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 enableValues(field, [2]);
264 enableValues(field, [2]);
265 break;
265 break;
266 case "=p":
266 case "=p":
267 case "=!p":
267 case "=!p":
268 case "!p":
268 case "!p":
269 enableValues(field, [1]);
269 enableValues(field, [1]);
270 break;
270 break;
271 default:
271 default:
272 enableValues(field, [0]);
272 enableValues(field, [0]);
273 break;
273 break;
274 }
274 }
275 }
275 }
276
276
277 function toggleMultiSelect(el) {
277 function toggleMultiSelect(el) {
278 if (el.attr('multiple')) {
278 if (el.attr('multiple')) {
279 el.removeAttr('multiple');
279 el.removeAttr('multiple');
280 el.attr('size', 1);
280 el.attr('size', 1);
281 } else {
281 } else {
282 el.attr('multiple', true);
282 el.attr('multiple', true);
283 if (el.children().length > 10)
283 if (el.children().length > 10)
284 el.attr('size', 10);
284 el.attr('size', 10);
285 else
285 else
286 el.attr('size', 4);
286 el.attr('size', 4);
287 }
287 }
288 }
288 }
289
289
290 function submit_query_form(id) {
290 function submit_query_form(id) {
291 selectAllOptions("selected_columns");
291 selectAllOptions("selected_columns");
292 $('#'+id).submit();
292 $('#'+id).submit();
293 }
293 }
294
294
295 function showTab(name, url) {
295 function showTab(name, url) {
296 $('div#content .tab-content').hide();
296 $('div#content .tab-content').hide();
297 $('div.tabs a').removeClass('selected');
297 $('div.tabs a').removeClass('selected');
298 $('#tab-content-' + name).show();
298 $('#tab-content-' + name).show();
299 $('#tab-' + name).addClass('selected');
299 $('#tab-' + name).addClass('selected');
300 //replaces current URL with the "href" attribute of the current link
300 //replaces current URL with the "href" attribute of the current link
301 //(only triggered if supported by browser)
301 //(only triggered if supported by browser)
302 if ("replaceState" in window.history) {
302 if ("replaceState" in window.history) {
303 window.history.replaceState(null, document.title, url);
303 window.history.replaceState(null, document.title, url);
304 }
304 }
305 return false;
305 return false;
306 }
306 }
307
307
308 function moveTabRight(el) {
308 function moveTabRight(el) {
309 var lis = $(el).parents('div.tabs').first().find('ul').children();
309 var lis = $(el).parents('div.tabs').first().find('ul').children();
310 var tabsWidth = 0;
310 var tabsWidth = 0;
311 var i = 0;
311 var i = 0;
312 lis.each(function() {
312 lis.each(function() {
313 if ($(this).is(':visible')) {
313 if ($(this).is(':visible')) {
314 tabsWidth += $(this).width() + 6;
314 tabsWidth += $(this).width() + 6;
315 }
315 }
316 });
316 });
317 if (tabsWidth < $(el).parents('div.tabs').first().width() - 60) { return; }
317 if (tabsWidth < $(el).parents('div.tabs').first().width() - 60) { return; }
318 while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
318 while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
319 lis.eq(i).hide();
319 lis.eq(i).hide();
320 }
320 }
321
321
322 function moveTabLeft(el) {
322 function moveTabLeft(el) {
323 var lis = $(el).parents('div.tabs').first().find('ul').children();
323 var lis = $(el).parents('div.tabs').first().find('ul').children();
324 var i = 0;
324 var i = 0;
325 while (i < lis.length && !lis.eq(i).is(':visible')) { i++; }
325 while (i < lis.length && !lis.eq(i).is(':visible')) { i++; }
326 if (i > 0) {
326 if (i > 0) {
327 lis.eq(i-1).show();
327 lis.eq(i-1).show();
328 }
328 }
329 }
329 }
330
330
331 function displayTabsButtons() {
331 function displayTabsButtons() {
332 var lis;
332 var lis;
333 var tabsWidth = 0;
333 var tabsWidth = 0;
334 var el;
334 var el;
335 $('div.tabs').each(function() {
335 $('div.tabs').each(function() {
336 el = $(this);
336 el = $(this);
337 lis = el.find('ul').children();
337 lis = el.find('ul').children();
338 lis.each(function(){
338 lis.each(function(){
339 if ($(this).is(':visible')) {
339 if ($(this).is(':visible')) {
340 tabsWidth += $(this).width() + 6;
340 tabsWidth += $(this).width() + 6;
341 }
341 }
342 });
342 });
343 if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) {
343 if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) {
344 el.find('div.tabs-buttons').hide();
344 el.find('div.tabs-buttons').hide();
345 } else {
345 } else {
346 el.find('div.tabs-buttons').show();
346 el.find('div.tabs-buttons').show();
347 }
347 }
348 });
348 });
349 }
349 }
350
350
351 function setPredecessorFieldsVisibility() {
351 function setPredecessorFieldsVisibility() {
352 var relationType = $('#relation_relation_type');
352 var relationType = $('#relation_relation_type');
353 if (relationType.val() == "precedes" || relationType.val() == "follows") {
353 if (relationType.val() == "precedes" || relationType.val() == "follows") {
354 $('#predecessor_fields').show();
354 $('#predecessor_fields').show();
355 } else {
355 } else {
356 $('#predecessor_fields').hide();
356 $('#predecessor_fields').hide();
357 }
357 }
358 }
358 }
359
359
360 function showModal(id, width) {
360 function showModal(id, width) {
361 var el = $('#'+id).first();
361 var el = $('#'+id).first();
362 if (el.length === 0 || el.is(':visible')) {return;}
362 if (el.length === 0 || el.is(':visible')) {return;}
363 var title = el.find('h3.title').text();
363 var title = el.find('h3.title').text();
364 el.dialog({
364 el.dialog({
365 width: width,
365 width: width,
366 modal: true,
366 modal: true,
367 resizable: false,
367 resizable: false,
368 dialogClass: 'modal',
368 dialogClass: 'modal',
369 title: title
369 title: title
370 });
370 });
371 el.find("input[type=text], input[type=submit]").first().focus();
371 el.find("input[type=text], input[type=submit]").first().focus();
372 }
372 }
373
373
374 function hideModal(el) {
374 function hideModal(el) {
375 var modal;
375 var modal;
376 if (el) {
376 if (el) {
377 modal = $(el).parents('.ui-dialog-content');
377 modal = $(el).parents('.ui-dialog-content');
378 } else {
378 } else {
379 modal = $('#ajax-modal');
379 modal = $('#ajax-modal');
380 }
380 }
381 modal.dialog("close");
381 modal.dialog("close");
382 }
382 }
383
383
384 function submitPreview(url, form, target) {
384 function submitPreview(url, form, target) {
385 $.ajax({
385 $.ajax({
386 url: url,
386 url: url,
387 type: 'post',
387 type: 'post',
388 data: $('#'+form).serialize(),
388 data: $('#'+form).serialize(),
389 success: function(data){
389 success: function(data){
390 $('#'+target).html(data);
390 $('#'+target).html(data);
391 }
391 }
392 });
392 });
393 }
393 }
394
394
395 function collapseScmEntry(id) {
395 function collapseScmEntry(id) {
396 $('.'+id).each(function() {
396 $('.'+id).each(function() {
397 if ($(this).hasClass('open')) {
397 if ($(this).hasClass('open')) {
398 collapseScmEntry($(this).attr('id'));
398 collapseScmEntry($(this).attr('id'));
399 }
399 }
400 $(this).hide();
400 $(this).hide();
401 });
401 });
402 $('#'+id).removeClass('open');
402 $('#'+id).removeClass('open');
403 }
403 }
404
404
405 function expandScmEntry(id) {
405 function expandScmEntry(id) {
406 $('.'+id).each(function() {
406 $('.'+id).each(function() {
407 $(this).show();
407 $(this).show();
408 if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
408 if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
409 expandScmEntry($(this).attr('id'));
409 expandScmEntry($(this).attr('id'));
410 }
410 }
411 });
411 });
412 $('#'+id).addClass('open');
412 $('#'+id).addClass('open');
413 }
413 }
414
414
415 function scmEntryClick(id, url) {
415 function scmEntryClick(id, url) {
416 var el = $('#'+id);
416 var el = $('#'+id);
417 if (el.hasClass('open')) {
417 if (el.hasClass('open')) {
418 collapseScmEntry(id);
418 collapseScmEntry(id);
419 el.addClass('collapsed');
419 el.addClass('collapsed');
420 return false;
420 return false;
421 } else if (el.hasClass('loaded')) {
421 } else if (el.hasClass('loaded')) {
422 expandScmEntry(id);
422 expandScmEntry(id);
423 el.removeClass('collapsed');
423 el.removeClass('collapsed');
424 return false;
424 return false;
425 }
425 }
426 if (el.hasClass('loading')) {
426 if (el.hasClass('loading')) {
427 return false;
427 return false;
428 }
428 }
429 el.addClass('loading');
429 el.addClass('loading');
430 $.ajax({
430 $.ajax({
431 url: url,
431 url: url,
432 success: function(data) {
432 success: function(data) {
433 el.after(data);
433 el.after(data);
434 el.addClass('open').addClass('loaded').removeClass('loading');
434 el.addClass('open').addClass('loaded').removeClass('loading');
435 }
435 }
436 });
436 });
437 return true;
437 return true;
438 }
438 }
439
439
440 function randomKey(size) {
440 function randomKey(size) {
441 var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
441 var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
442 var key = '';
442 var key = '';
443 for (var i = 0; i < size; i++) {
443 for (var i = 0; i < size; i++) {
444 key += chars.charAt(Math.floor(Math.random() * chars.length));
444 key += chars.charAt(Math.floor(Math.random() * chars.length));
445 }
445 }
446 return key;
446 return key;
447 }
447 }
448
448
449 function updateIssueFrom(url) {
449 function updateIssueFrom(url) {
450 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
450 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
451 $(this).data('valuebeforeupdate', $(this).val());
451 $(this).data('valuebeforeupdate', $(this).val());
452 });
452 });
453 $.ajax({
453 $.ajax({
454 url: url,
454 url: url,
455 type: 'post',
455 type: 'post',
456 data: $('#issue-form').serialize()
456 data: $('#issue-form').serialize()
457 });
457 });
458 }
458 }
459
459
460 function replaceIssueFormWith(html){
460 function replaceIssueFormWith(html){
461 var replacement = $(html);
461 var replacement = $(html);
462 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
462 $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
463 var object_id = $(this).attr('id');
463 var object_id = $(this).attr('id');
464 if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) {
464 if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) {
465 replacement.find('#'+object_id).val($(this).val());
465 replacement.find('#'+object_id).val($(this).val());
466 }
466 }
467 });
467 });
468 $('#all_attributes').empty();
468 $('#all_attributes').empty();
469 $('#all_attributes').prepend(replacement);
469 $('#all_attributes').prepend(replacement);
470 }
470 }
471
471
472 function updateBulkEditFrom(url) {
472 function updateBulkEditFrom(url) {
473 $.ajax({
473 $.ajax({
474 url: url,
474 url: url,
475 type: 'post',
475 type: 'post',
476 data: $('#bulk_edit_form').serialize()
476 data: $('#bulk_edit_form').serialize()
477 });
477 });
478 }
478 }
479
479
480 function observeAutocompleteField(fieldId, url, options) {
480 function observeAutocompleteField(fieldId, url, options) {
481 $(document).ready(function() {
481 $(document).ready(function() {
482 $('#'+fieldId).autocomplete($.extend({
482 $('#'+fieldId).autocomplete($.extend({
483 source: url,
483 source: url,
484 minLength: 2,
484 minLength: 2,
485 search: function(){$('#'+fieldId).addClass('ajax-loading');},
485 search: function(){$('#'+fieldId).addClass('ajax-loading');},
486 response: function(){$('#'+fieldId).removeClass('ajax-loading');}
486 response: function(){$('#'+fieldId).removeClass('ajax-loading');}
487 }, options));
487 }, options));
488 $('#'+fieldId).addClass('autocomplete');
488 $('#'+fieldId).addClass('autocomplete');
489 });
489 });
490 }
490 }
491
491
492 function observeSearchfield(fieldId, targetId, url) {
492 function observeSearchfield(fieldId, targetId, url) {
493 $('#'+fieldId).each(function() {
493 $('#'+fieldId).each(function() {
494 var $this = $(this);
494 var $this = $(this);
495 $this.addClass('autocomplete');
495 $this.addClass('autocomplete');
496 $this.attr('data-value-was', $this.val());
496 $this.attr('data-value-was', $this.val());
497 var check = function() {
497 var check = function() {
498 var val = $this.val();
498 var val = $this.val();
499 if ($this.attr('data-value-was') != val){
499 if ($this.attr('data-value-was') != val){
500 $this.attr('data-value-was', val);
500 $this.attr('data-value-was', val);
501 $.ajax({
501 $.ajax({
502 url: url,
502 url: url,
503 type: 'get',
503 type: 'get',
504 data: {q: $this.val()},
504 data: {q: $this.val()},
505 success: function(data){ if(targetId) $('#'+targetId).html(data); },
505 success: function(data){ if(targetId) $('#'+targetId).html(data); },
506 beforeSend: function(){ $this.addClass('ajax-loading'); },
506 beforeSend: function(){ $this.addClass('ajax-loading'); },
507 complete: function(){ $this.removeClass('ajax-loading'); }
507 complete: function(){ $this.removeClass('ajax-loading'); }
508 });
508 });
509 }
509 }
510 };
510 };
511 var reset = function() {
511 var reset = function() {
512 if (timer) {
512 if (timer) {
513 clearInterval(timer);
513 clearInterval(timer);
514 timer = setInterval(check, 300);
514 timer = setInterval(check, 300);
515 }
515 }
516 };
516 };
517 var timer = setInterval(check, 300);
517 var timer = setInterval(check, 300);
518 $this.bind('keyup click mousemove', reset);
518 $this.bind('keyup click mousemove', reset);
519 });
519 });
520 }
520 }
521
521
522 function initMyPageSortable(list, url) {
522 function initMyPageSortable(list, url) {
523 $('#list-'+list).sortable({
523 $('#list-'+list).sortable({
524 connectWith: '.block-receiver',
524 connectWith: '.block-receiver',
525 tolerance: 'pointer',
525 tolerance: 'pointer',
526 update: function(){
526 update: function(){
527 $.ajax({
527 $.ajax({
528 url: url,
528 url: url,
529 type: 'post',
529 type: 'post',
530 data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
530 data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
531 });
531 });
532 }
532 }
533 });
533 });
534 $("#list-top, #list-left, #list-right").disableSelection();
534 $("#list-top, #list-left, #list-right").disableSelection();
535 }
535 }
536
536
537 var warnLeavingUnsavedMessage;
537 var warnLeavingUnsavedMessage;
538 function warnLeavingUnsaved(message) {
538 function warnLeavingUnsaved(message) {
539 warnLeavingUnsavedMessage = message;
539 warnLeavingUnsavedMessage = message;
540 $('form').live('submit', function(){
540 $('form').live('submit', function(){
541 $('textarea').removeData('changed');
541 $('textarea').removeData('changed');
542 });
542 });
543 $('textarea').live('change', function(){
543 $('textarea').live('change', function(){
544 $(this).data('changed', 'changed');
544 $(this).data('changed', 'changed');
545 });
545 });
546 window.onbeforeunload = function(){
546 window.onbeforeunload = function(){
547 var warn = false;
547 var warn = false;
548 $('textarea').blur().each(function(){
548 $('textarea').blur().each(function(){
549 if ($(this).data('changed')) {
549 if ($(this).data('changed')) {
550 warn = true;
550 warn = true;
551 }
551 }
552 });
552 });
553 if (warn) {return warnLeavingUnsavedMessage;}
553 if (warn) {return warnLeavingUnsavedMessage;}
554 };
554 };
555 }
555 }
556
556
557 function setupAjaxIndicator() {
557 function setupAjaxIndicator() {
558 $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) {
558 $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) {
559 if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
559 if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
560 $('#ajax-indicator').show();
560 $('#ajax-indicator').show();
561 }
561 }
562 });
562 });
563 $('#ajax-indicator').bind('ajaxStop', function() {
563 $('#ajax-indicator').bind('ajaxStop', function() {
564 $('#ajax-indicator').hide();
564 $('#ajax-indicator').hide();
565 });
565 });
566 }
566 }
567
567
568 function hideOnLoad() {
568 function hideOnLoad() {
569 $('.hol').hide();
569 $('.hol').hide();
570 }
570 }
571
571
572 function addFormObserversForDoubleSubmit() {
572 function addFormObserversForDoubleSubmit() {
573 $('form[method=post]').each(function() {
573 $('form[method=post]').each(function() {
574 if (!$(this).hasClass('multiple-submit')) {
574 if (!$(this).hasClass('multiple-submit')) {
575 $(this).submit(function(form_submission) {
575 $(this).submit(function(form_submission) {
576 if ($(form_submission.target).attr('data-submitted')) {
576 if ($(form_submission.target).attr('data-submitted')) {
577 form_submission.preventDefault();
577 form_submission.preventDefault();
578 } else {
578 } else {
579 $(form_submission.target).attr('data-submitted', true);
579 $(form_submission.target).attr('data-submitted', true);
580 }
580 }
581 });
581 });
582 }
582 }
583 });
583 });
584 }
584 }
585
585
586 function defaultFocus(){
587 if ($('#content :focus').length == 0) {
588 $('#content input[type=text], #content textarea').first().focus();
589 }
590 }
591
586 function blockEventPropagation(event) {
592 function blockEventPropagation(event) {
587 event.stopPropagation();
593 event.stopPropagation();
588 event.preventDefault();
594 event.preventDefault();
589 }
595 }
590
596
591 function toggleDisabledOnChange() {
597 function toggleDisabledOnChange() {
592 var checked = $(this).is(':checked');
598 var checked = $(this).is(':checked');
593 $($(this).data('disables')).attr('disabled', checked);
599 $($(this).data('disables')).attr('disabled', checked);
594 $($(this).data('enables')).attr('disabled', !checked);
600 $($(this).data('enables')).attr('disabled', !checked);
595 }
601 }
596 function toggleDisabledInit() {
602 function toggleDisabledInit() {
597 $('input[data-disables], input[data-enables]').each(toggleDisabledOnChange);
603 $('input[data-disables], input[data-enables]').each(toggleDisabledOnChange);
598 }
604 }
599 $(document).ready(function(){
605 $(document).ready(function(){
600 $('#content').on('change', 'input[data-disables], input[data-enables]', toggleDisabledOnChange);
606 $('#content').on('change', 'input[data-disables], input[data-enables]', toggleDisabledOnChange);
601 toggleDisabledInit();
607 toggleDisabledInit();
602 });
608 });
603
609
604 $(document).ready(setupAjaxIndicator);
610 $(document).ready(setupAjaxIndicator);
605 $(document).ready(hideOnLoad);
611 $(document).ready(hideOnLoad);
606 $(document).ready(addFormObserversForDoubleSubmit);
612 $(document).ready(addFormObserversForDoubleSubmit);
613 $(document).ready(defaultFocus);
607
614
General Comments 0
You need to be logged in to leave comments. Login now