##// 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 2 <thead>
3 3 <tr id="root">
4 4 <th><%= l(:field_name) %></th>
5 5 <th><%= l(:field_filesize) %></th>
6 6 <th><%= l(:label_revision) %></th>
7 7 <th><%= l(:label_date) %></th>
8 8 <th><%= l(:field_author) %></th>
9 9 <th><%= l(:field_comments) %></th>
10 10 </tr>
11 11 </thead>
12 12 <tbody>
13 13 <%= render :partial => 'dir_list_content' %>
14 14 </tbody>
15 15 </table>
@@ -1,32 +1,32
1 1 <% @entries.each do |entry| %>
2 2 <% tr_id = Digest::MD5.hexdigest(entry.path)
3 3 depth = params[:depth].to_i %>
4 <tr id="<%= tr_id %>">
4 <tr id="<%= tr_id %>" class="<%= params[:parent_id] %>">
5 5 <td>
6 6 <%= if entry.is_dir?
7 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 9 :update => tr_id,
10 10 :position => :after,
11 :success => "Element.addClassName('#{tr_id}', 'open');",
12 :condition => "!Element.hasClassName('#{tr_id}', 'open')"
11 :success => "scmEntryLoaded('#{tr_id}')",
12 :condition => "scmEntryClick('#{tr_id}')"
13 13 },
14 14 {:href => url_for({:action => 'browse', :id => @project, :path => entry.path, :rev => @rev}),
15 15 :class => ('icon icon-folder'),
16 16 :style => "margin-left: #{18 * depth}px;"
17 17 }
18 18 else
19 19 link_to h(entry.name),
20 20 {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev},
21 21 :class => 'icon icon-file',
22 22 :style => "margin-left: #{18 * depth}px;"
23 23 end %>
24 24 </td>
25 25 <td align="right"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
26 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 27 <td align="center"><%= format_time(entry.lastrev.time) if entry.lastrev %></td>
28 28 <td align="center"><em><%=h(entry.lastrev.author) if entry.lastrev %></em></td>
29 29 <% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev %>
30 30 <td><%=h truncate(changeset.comments, 50) unless changeset.nil? %></td>
31 31 </tr>
32 32 <% end %>
@@ -1,74 +1,108
1 1 function checkAll (id, checked) {
2 2 var el = document.getElementById(id);
3 3 for (var i = 0; i < el.elements.length; i++) {
4 4 if (el.elements[i].disabled==false) {
5 5 el.elements[i].checked = checked;
6 6 }
7 7 }
8 8 }
9 9
10 10 function addFileField() {
11 11 var f = document.createElement("input");
12 12 f.type = "file";
13 13 f.name = "attachments[]";
14 14 f.size = 30;
15 15
16 16 p = document.getElementById("attachments_p");
17 17 p.appendChild(document.createElement("br"));
18 18 p.appendChild(f);
19 19 }
20 20
21 21 function showTab(name) {
22 22 var f = $$('div#content .tab-content');
23 23 for(var i=0; i<f.length; i++){
24 24 Element.hide(f[i]);
25 25 }
26 26 var f = $$('div.tabs a');
27 27 for(var i=0; i<f.length; i++){
28 28 Element.removeClassName(f[i], "selected");
29 29 }
30 30 Element.show('tab-content-' + name);
31 31 Element.addClassName('tab-' + name, "selected");
32 32 return false;
33 33 }
34 34
35 35 function setPredecessorFieldsVisibility() {
36 36 relationType = $('relation_relation_type');
37 37 if (relationType && relationType.value == "precedes") {
38 38 Element.show('predecessor_fields');
39 39 } else {
40 40 Element.hide('predecessor_fields');
41 41 }
42 42 }
43 43
44 44 function promptToRemote(text, param, url) {
45 45 value = prompt(text + ':');
46 46 if (value) {
47 47 new Ajax.Request(url + '?' + param + '=' + value, {asynchronous:true, evalScripts:true});
48 48 return false;
49 49 }
50 50 }
51 51
52 52 /* checks that at least one checkbox is checked (used when submitting bulk edit form) */
53 53 function checkBulkEdit(form) {
54 54 for (var i = 0; i < form.elements.length; i++) {
55 55 if (form.elements[i].checked) {
56 56 return true;
57 57 }
58 58 }
59 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 96 /* shows and hides ajax indicator */
63 97 Ajax.Responders.register({
64 98 onCreate: function(){
65 99 if ($('ajax-indicator') && Ajax.activeRequestCount > 0) {
66 100 Element.show('ajax-indicator');
67 101 }
68 102 },
69 103 onComplete: function(){
70 104 if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
71 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