##// END OF EJS Templates
SCM browser: directories can now be collapsed and re-expanded with no additional request....
Jean-Philippe Lang -
r850:33003e5b2d88
parent child
Show More
@@ -1,15 +1,15
1 <table class="list">
1 <table class="list" id="browser">
2 <thead>
2 <thead>
3 <tr id="root">
3 <tr id="root">
4 <th><%= l(:field_name) %></th>
4 <th><%= l(:field_name) %></th>
5 <th><%= l(:field_filesize) %></th>
5 <th><%= l(:field_filesize) %></th>
6 <th><%= l(:label_revision) %></th>
6 <th><%= l(:label_revision) %></th>
7 <th><%= l(:label_date) %></th>
7 <th><%= l(:label_date) %></th>
8 <th><%= l(:field_author) %></th>
8 <th><%= l(:field_author) %></th>
9 <th><%= l(:field_comments) %></th>
9 <th><%= l(:field_comments) %></th>
10 </tr>
10 </tr>
11 </thead>
11 </thead>
12 <tbody>
12 <tbody>
13 <%= render :partial => 'dir_list_content' %>
13 <%= render :partial => 'dir_list_content' %>
14 </tbody>
14 </tbody>
15 </table>
15 </table>
@@ -1,32 +1,32
1 <% @entries.each do |entry| %>
1 <% @entries.each do |entry| %>
2 <% tr_id = Digest::MD5.hexdigest(entry.path)
2 <% tr_id = Digest::MD5.hexdigest(entry.path)
3 depth = params[:depth].to_i %>
3 depth = params[:depth].to_i %>
4 <tr id="<%= tr_id %>">
4 <tr id="<%= tr_id %>" class="<%= params[:parent_id] %>">
5 <td>
5 <td>
6 <%= if entry.is_dir?
6 <%= if entry.is_dir?
7 link_to_remote h(entry.name),
7 link_to_remote h(entry.name),
8 {:url => {:action => 'browse', :id => @project, :path => entry.path, :rev => @rev, :depth => (depth + 1)},
8 {:url => {:action => 'browse', :id => @project, :path => entry.path, :rev => @rev, :depth => (depth + 1), :parent_id => tr_id},
9 :update => tr_id,
9 :update => tr_id,
10 :position => :after,
10 :position => :after,
11 :success => "Element.addClassName('#{tr_id}', 'open');",
11 :success => "scmEntryLoaded('#{tr_id}')",
12 :condition => "!Element.hasClassName('#{tr_id}', 'open')"
12 :condition => "scmEntryClick('#{tr_id}')"
13 },
13 },
14 {:href => url_for({:action => 'browse', :id => @project, :path => entry.path, :rev => @rev}),
14 {:href => url_for({:action => 'browse', :id => @project, :path => entry.path, :rev => @rev}),
15 :class => ('icon icon-folder'),
15 :class => ('icon icon-folder'),
16 :style => "margin-left: #{18 * depth}px;"
16 :style => "margin-left: #{18 * depth}px;"
17 }
17 }
18 else
18 else
19 link_to h(entry.name),
19 link_to h(entry.name),
20 {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev},
20 {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev},
21 :class => 'icon icon-file',
21 :class => 'icon icon-file',
22 :style => "margin-left: #{18 * depth}px;"
22 :style => "margin-left: #{18 * depth}px;"
23 end %>
23 end %>
24 </td>
24 </td>
25 <td align="right"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
25 <td align="right"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
26 <td align="right"><%= link_to(entry.lastrev.name, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %></td>
26 <td align="right"><%= link_to(entry.lastrev.name, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %></td>
27 <td align="center"><%= format_time(entry.lastrev.time) if entry.lastrev %></td>
27 <td align="center"><%= format_time(entry.lastrev.time) if entry.lastrev %></td>
28 <td align="center"><em><%=h(entry.lastrev.author) if entry.lastrev %></em></td>
28 <td align="center"><em><%=h(entry.lastrev.author) if entry.lastrev %></em></td>
29 <% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev %>
29 <% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev %>
30 <td><%=h truncate(changeset.comments, 50) unless changeset.nil? %></td>
30 <td><%=h truncate(changeset.comments, 50) unless changeset.nil? %></td>
31 </tr>
31 </tr>
32 <% end %>
32 <% end %>
@@ -1,74 +1,108
1 function checkAll (id, checked) {
1 function checkAll (id, checked) {
2 var el = document.getElementById(id);
2 var el = document.getElementById(id);
3 for (var i = 0; i < el.elements.length; i++) {
3 for (var i = 0; i < el.elements.length; i++) {
4 if (el.elements[i].disabled==false) {
4 if (el.elements[i].disabled==false) {
5 el.elements[i].checked = checked;
5 el.elements[i].checked = checked;
6 }
6 }
7 }
7 }
8 }
8 }
9
9
10 function addFileField() {
10 function addFileField() {
11 var f = document.createElement("input");
11 var f = document.createElement("input");
12 f.type = "file";
12 f.type = "file";
13 f.name = "attachments[]";
13 f.name = "attachments[]";
14 f.size = 30;
14 f.size = 30;
15
15
16 p = document.getElementById("attachments_p");
16 p = document.getElementById("attachments_p");
17 p.appendChild(document.createElement("br"));
17 p.appendChild(document.createElement("br"));
18 p.appendChild(f);
18 p.appendChild(f);
19 }
19 }
20
20
21 function showTab(name) {
21 function showTab(name) {
22 var f = $$('div#content .tab-content');
22 var f = $$('div#content .tab-content');
23 for(var i=0; i<f.length; i++){
23 for(var i=0; i<f.length; i++){
24 Element.hide(f[i]);
24 Element.hide(f[i]);
25 }
25 }
26 var f = $$('div.tabs a');
26 var f = $$('div.tabs a');
27 for(var i=0; i<f.length; i++){
27 for(var i=0; i<f.length; i++){
28 Element.removeClassName(f[i], "selected");
28 Element.removeClassName(f[i], "selected");
29 }
29 }
30 Element.show('tab-content-' + name);
30 Element.show('tab-content-' + name);
31 Element.addClassName('tab-' + name, "selected");
31 Element.addClassName('tab-' + name, "selected");
32 return false;
32 return false;
33 }
33 }
34
34
35 function setPredecessorFieldsVisibility() {
35 function setPredecessorFieldsVisibility() {
36 relationType = $('relation_relation_type');
36 relationType = $('relation_relation_type');
37 if (relationType && relationType.value == "precedes") {
37 if (relationType && relationType.value == "precedes") {
38 Element.show('predecessor_fields');
38 Element.show('predecessor_fields');
39 } else {
39 } else {
40 Element.hide('predecessor_fields');
40 Element.hide('predecessor_fields');
41 }
41 }
42 }
42 }
43
43
44 function promptToRemote(text, param, url) {
44 function promptToRemote(text, param, url) {
45 value = prompt(text + ':');
45 value = prompt(text + ':');
46 if (value) {
46 if (value) {
47 new Ajax.Request(url + '?' + param + '=' + value, {asynchronous:true, evalScripts:true});
47 new Ajax.Request(url + '?' + param + '=' + value, {asynchronous:true, evalScripts:true});
48 return false;
48 return false;
49 }
49 }
50 }
50 }
51
51
52 /* checks that at least one checkbox is checked (used when submitting bulk edit form) */
52 /* checks that at least one checkbox is checked (used when submitting bulk edit form) */
53 function checkBulkEdit(form) {
53 function checkBulkEdit(form) {
54 for (var i = 0; i < form.elements.length; i++) {
54 for (var i = 0; i < form.elements.length; i++) {
55 if (form.elements[i].checked) {
55 if (form.elements[i].checked) {
56 return true;
56 return true;
57 }
57 }
58 }
58 }
59 return false;
59 return false;
60 }
60 }
61
61
62 function collapseScmEntry(id) {
63 var els = document.getElementsByClassName(id, 'browser');
64 for (var i = 0; i < els.length; i++) {
65 collapseScmEntry(els[i].id);
66 Element.hide(els[i]);
67 }
68 $(id).removeClassName('open');
69 }
70
71 function expandScmEntry(id) {
72 var els = document.getElementsByClassName(id, 'browser');
73 for (var i = 0; i < els.length; i++) {
74 Element.show(els[i]);
75 }
76 $(id).addClassName('open');
77 }
78
79 function scmEntryClick(id) {
80 el = $(id);
81 if (el.hasClassName('open')) {
82 collapseScmEntry(id);
83 return false;
84 } else if (el.hasClassName('loaded')) {
85 expandScmEntry(id);
86 return false;
87 }
88 return true;
89 }
90
91 function scmEntryLoaded(id) {
92 Element.addClassName(id, 'open');
93 Element.addClassName(id, 'loaded');
94 }
95
62 /* shows and hides ajax indicator */
96 /* shows and hides ajax indicator */
63 Ajax.Responders.register({
97 Ajax.Responders.register({
64 onCreate: function(){
98 onCreate: function(){
65 if ($('ajax-indicator') && Ajax.activeRequestCount > 0) {
99 if ($('ajax-indicator') && Ajax.activeRequestCount > 0) {
66 Element.show('ajax-indicator');
100 Element.show('ajax-indicator');
67 }
101 }
68 },
102 },
69 onComplete: function(){
103 onComplete: function(){
70 if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
104 if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
71 Element.hide('ajax-indicator');
105 Element.hide('ajax-indicator');
72 }
106 }
73 }
107 }
74 });
108 });
General Comments 0
You need to be logged in to leave comments. Login now