##// END OF EJS Templates
js: refactor js and move logic to files.js
ergo -
r3713:d94ac941 new-ui
parent child Browse files
Show More
@@ -1,330 +1,411 b''
1 // # Copyright (C) 2010-2019 RhodeCode GmbH
1 // # Copyright (C) 2010-2019 RhodeCode GmbH
2 // #
2 // #
3 // # This program is free software: you can redistribute it and/or modify
3 // # This program is free software: you can redistribute it and/or modify
4 // # it under the terms of the GNU Affero General Public License, version 3
4 // # it under the terms of the GNU Affero General Public License, version 3
5 // # (only), as published by the Free Software Foundation.
5 // # (only), as published by the Free Software Foundation.
6 // #
6 // #
7 // # This program is distributed in the hope that it will be useful,
7 // # This program is distributed in the hope that it will be useful,
8 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // # GNU General Public License for more details.
10 // # GNU General Public License for more details.
11 // #
11 // #
12 // # You should have received a copy of the GNU Affero General Public License
12 // # You should have received a copy of the GNU Affero General Public License
13 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 // #
14 // #
15 // # This program is dual-licensed. If you wish to learn more about the
15 // # This program is dual-licensed. If you wish to learn more about the
16 // # RhodeCode Enterprise Edition, including its added features, Support services,
16 // # RhodeCode Enterprise Edition, including its added features, Support services,
17 // # and proprietary license terms, please see https://rhodecode.com/licenses/
17 // # and proprietary license terms, please see https://rhodecode.com/licenses/
18
18
19 /**
19 /**
20 * Search file list
20 * Search file list
21 */
21 */
22
22
23 var NodeFilter = {};
23 var NodeFilter = {};
24
24
25 var fileBrowserListeners = function (node_list_url, url_base) {
25 var fileBrowserListeners = function (node_list_url, url_base) {
26 var $filterInput = $('#node_filter');
26 var $filterInput = $('#node_filter');
27 var n_filter = $filterInput.get(0);
27 var n_filter = $filterInput.get(0);
28
28
29 NodeFilter.filterTimeout = null;
29 NodeFilter.filterTimeout = null;
30 var nodes = null;
30 var nodes = null;
31
31
32 NodeFilter.focus = function () {
32 NodeFilter.focus = function () {
33 $filterInput.focus()
33 $filterInput.focus()
34 };
34 };
35
35
36 NodeFilter.fetchNodes = function (callback) {
36 NodeFilter.fetchNodes = function (callback) {
37 $.ajax(
37 $.ajax(
38 {url: node_list_url, headers: {'X-PARTIAL-XHR': true}})
38 {url: node_list_url, headers: {'X-PARTIAL-XHR': true}})
39 .done(function (data) {
39 .done(function (data) {
40 nodes = data.nodes;
40 nodes = data.nodes;
41 if (callback) {
41 if (callback) {
42 callback();
42 callback();
43 }
43 }
44 })
44 })
45 .fail(function (data) {
45 .fail(function (data) {
46 console.log('failed to load');
46 console.log('failed to load');
47 });
47 });
48 };
48 };
49
49
50 NodeFilter.initFilter = function (e) {
50 NodeFilter.initFilter = function (e) {
51 if ($filterInput.hasClass('loading')) {
51 if ($filterInput.hasClass('loading')) {
52 return
52 return
53 }
53 }
54
54
55 // in case we are already loaded, do nothing
55 // in case we are already loaded, do nothing
56 if (!$filterInput.hasClass('init')) {
56 if (!$filterInput.hasClass('init')) {
57 return NodeFilter.handleKey(e);
57 return NodeFilter.handleKey(e);
58 }
58 }
59 var iconLoading = 'icon-spin animate-spin';
59 var iconLoading = 'icon-spin animate-spin';
60 var iconSearch = 'icon-search';
60 var iconSearch = 'icon-search';
61 $('.files-filter-box-path i').removeClass(iconSearch).addClass(iconLoading);
61 $('.files-filter-box-path i').removeClass(iconSearch).addClass(iconLoading);
62 $filterInput.addClass('loading');
62 $filterInput.addClass('loading');
63
63
64 var callback = function (org) {
64 var callback = function (org) {
65 return function () {
65 return function () {
66 if ($filterInput.hasClass('init')) {
66 if ($filterInput.hasClass('init')) {
67 $filterInput.removeClass('init');
67 $filterInput.removeClass('init');
68 $filterInput.removeClass('loading');
68 $filterInput.removeClass('loading');
69 }
69 }
70 $('.files-filter-box-path i').removeClass(iconLoading).addClass(iconSearch);
70 $('.files-filter-box-path i').removeClass(iconLoading).addClass(iconSearch);
71
71
72 // auto re-filter if we filled in the input
72 // auto re-filter if we filled in the input
73 if (n_filter.value !== "") {
73 if (n_filter.value !== "") {
74 NodeFilter.updateFilter(n_filter, e)()
74 NodeFilter.updateFilter(n_filter, e)()
75 }
75 }
76
76
77 }
77 }
78 };
78 };
79 // load node data
79 // load node data
80 NodeFilter.fetchNodes(callback());
80 NodeFilter.fetchNodes(callback());
81
81
82 };
82 };
83
83
84 NodeFilter.resetFilter = function () {
84 NodeFilter.resetFilter = function () {
85 $('#tbody').show();
85 $('#tbody').show();
86 $('#tbody_filtered').hide();
86 $('#tbody_filtered').hide();
87 $filterInput.val('');
87 $filterInput.val('');
88 };
88 };
89
89
90 NodeFilter.handleKey = function (e) {
90 NodeFilter.handleKey = function (e) {
91 var scrollDown = function (element) {
91 var scrollDown = function (element) {
92 var elementBottom = element.offset().top + $(element).outerHeight();
92 var elementBottom = element.offset().top + $(element).outerHeight();
93 var windowBottom = window.innerHeight + $(window).scrollTop();
93 var windowBottom = window.innerHeight + $(window).scrollTop();
94 if (elementBottom > windowBottom) {
94 if (elementBottom > windowBottom) {
95 var offset = elementBottom - window.innerHeight;
95 var offset = elementBottom - window.innerHeight;
96 $('html,body').scrollTop(offset);
96 $('html,body').scrollTop(offset);
97 return false;
97 return false;
98 }
98 }
99 return true;
99 return true;
100 };
100 };
101
101
102 var scrollUp = function (element) {
102 var scrollUp = function (element) {
103 if (element.offset().top < $(window).scrollTop()) {
103 if (element.offset().top < $(window).scrollTop()) {
104 $('html,body').scrollTop(element.offset().top);
104 $('html,body').scrollTop(element.offset().top);
105 return false;
105 return false;
106 }
106 }
107 return true;
107 return true;
108 };
108 };
109 var $hlElem = $('.browser-highlight');
109 var $hlElem = $('.browser-highlight');
110
110
111 if (e.keyCode === 40) { // Down
111 if (e.keyCode === 40) { // Down
112 if ($hlElem.length === 0) {
112 if ($hlElem.length === 0) {
113 $('.browser-result').first().addClass('browser-highlight');
113 $('.browser-result').first().addClass('browser-highlight');
114 } else {
114 } else {
115 var next = $hlElem.next();
115 var next = $hlElem.next();
116 if (next.length !== 0) {
116 if (next.length !== 0) {
117 $hlElem.removeClass('browser-highlight');
117 $hlElem.removeClass('browser-highlight');
118 next.addClass('browser-highlight');
118 next.addClass('browser-highlight');
119 }
119 }
120 }
120 }
121
121
122 if ($hlElem.get(0) !== undefined){
122 if ($hlElem.get(0) !== undefined){
123 scrollDown($hlElem);
123 scrollDown($hlElem);
124 }
124 }
125 }
125 }
126 if (e.keyCode === 38) { // Up
126 if (e.keyCode === 38) { // Up
127 e.preventDefault();
127 e.preventDefault();
128 if ($hlElem.length !== 0) {
128 if ($hlElem.length !== 0) {
129 var next = $hlElem.prev();
129 var next = $hlElem.prev();
130 if (next.length !== 0) {
130 if (next.length !== 0) {
131 $('.browser-highlight').removeClass('browser-highlight');
131 $('.browser-highlight').removeClass('browser-highlight');
132 next.addClass('browser-highlight');
132 next.addClass('browser-highlight');
133 }
133 }
134 }
134 }
135
135
136 if ($hlElem.get(0) !== undefined){
136 if ($hlElem.get(0) !== undefined){
137 scrollUp($hlElem);
137 scrollUp($hlElem);
138 }
138 }
139
139
140 }
140 }
141 if (e.keyCode === 13) { // Enter
141 if (e.keyCode === 13) { // Enter
142 if ($('.browser-highlight').length !== 0) {
142 if ($('.browser-highlight').length !== 0) {
143 var url = $('.browser-highlight').find('.match-link').attr('href');
143 var url = $('.browser-highlight').find('.match-link').attr('href');
144 window.location = url;
144 window.location = url;
145 }
145 }
146 }
146 }
147 if (e.keyCode === 27) { // Esc
147 if (e.keyCode === 27) { // Esc
148 NodeFilter.resetFilter();
148 NodeFilter.resetFilter();
149 $('html,body').scrollTop(0);
149 $('html,body').scrollTop(0);
150 }
150 }
151
151
152 var capture_keys = [
152 var capture_keys = [
153 40, // ArrowDown
153 40, // ArrowDown
154 38, // ArrowUp
154 38, // ArrowUp
155 39, // ArrowRight
155 39, // ArrowRight
156 37, // ArrowLeft
156 37, // ArrowLeft
157 13, // Enter
157 13, // Enter
158 27 // Esc
158 27 // Esc
159 ];
159 ];
160
160
161 if ($.inArray(e.keyCode, capture_keys) === -1) {
161 if ($.inArray(e.keyCode, capture_keys) === -1) {
162 clearTimeout(NodeFilter.filterTimeout);
162 clearTimeout(NodeFilter.filterTimeout);
163 NodeFilter.filterTimeout = setTimeout(NodeFilter.updateFilter(n_filter, e), 200);
163 NodeFilter.filterTimeout = setTimeout(NodeFilter.updateFilter(n_filter, e), 200);
164 }
164 }
165
165
166 };
166 };
167
167
168 NodeFilter.fuzzy_match = function (filepath, query) {
168 NodeFilter.fuzzy_match = function (filepath, query) {
169 var highlight = [];
169 var highlight = [];
170 var order = 0;
170 var order = 0;
171 for (var i = 0; i < query.length; i++) {
171 for (var i = 0; i < query.length; i++) {
172 var match_position = filepath.indexOf(query[i]);
172 var match_position = filepath.indexOf(query[i]);
173 if (match_position !== -1) {
173 if (match_position !== -1) {
174 var prev_match_position = highlight[highlight.length - 1];
174 var prev_match_position = highlight[highlight.length - 1];
175 if (prev_match_position === undefined) {
175 if (prev_match_position === undefined) {
176 highlight.push(match_position);
176 highlight.push(match_position);
177 } else {
177 } else {
178 var current_match_position = prev_match_position + match_position + 1;
178 var current_match_position = prev_match_position + match_position + 1;
179 highlight.push(current_match_position);
179 highlight.push(current_match_position);
180 order = order + current_match_position - prev_match_position;
180 order = order + current_match_position - prev_match_position;
181 }
181 }
182 filepath = filepath.substring(match_position + 1);
182 filepath = filepath.substring(match_position + 1);
183 } else {
183 } else {
184 return false;
184 return false;
185 }
185 }
186 }
186 }
187 return {
187 return {
188 'order': order,
188 'order': order,
189 'highlight': highlight
189 'highlight': highlight
190 };
190 };
191 };
191 };
192
192
193 NodeFilter.sortPredicate = function (a, b) {
193 NodeFilter.sortPredicate = function (a, b) {
194 if (a.order < b.order) return -1;
194 if (a.order < b.order) return -1;
195 if (a.order > b.order) return 1;
195 if (a.order > b.order) return 1;
196 if (a.filepath < b.filepath) return -1;
196 if (a.filepath < b.filepath) return -1;
197 if (a.filepath > b.filepath) return 1;
197 if (a.filepath > b.filepath) return 1;
198 return 0;
198 return 0;
199 };
199 };
200
200
201 NodeFilter.updateFilter = function (elem, e) {
201 NodeFilter.updateFilter = function (elem, e) {
202 return function () {
202 return function () {
203 // Reset timeout
203 // Reset timeout
204 NodeFilter.filterTimeout = null;
204 NodeFilter.filterTimeout = null;
205 var query = elem.value.toLowerCase();
205 var query = elem.value.toLowerCase();
206 var match = [];
206 var match = [];
207 var matches_max = 20;
207 var matches_max = 20;
208 if (query !== "") {
208 if (query !== "") {
209 var results = [];
209 var results = [];
210 for (var k = 0; k < nodes.length; k++) {
210 for (var k = 0; k < nodes.length; k++) {
211 var result = NodeFilter.fuzzy_match(
211 var result = NodeFilter.fuzzy_match(
212 nodes[k].name.toLowerCase(), query);
212 nodes[k].name.toLowerCase(), query);
213 if (result) {
213 if (result) {
214 result.type = nodes[k].type;
214 result.type = nodes[k].type;
215 result.filepath = nodes[k].name;
215 result.filepath = nodes[k].name;
216 results.push(result);
216 results.push(result);
217 }
217 }
218 }
218 }
219 results = results.sort(NodeFilter.sortPredicate);
219 results = results.sort(NodeFilter.sortPredicate);
220 var limit = matches_max;
220 var limit = matches_max;
221 if (results.length < matches_max) {
221 if (results.length < matches_max) {
222 limit = results.length;
222 limit = results.length;
223 }
223 }
224 for (var i = 0; i < limit; i++) {
224 for (var i = 0; i < limit; i++) {
225 if (query && results.length > 0) {
225 if (query && results.length > 0) {
226 var n = results[i].filepath;
226 var n = results[i].filepath;
227 var t = results[i].type;
227 var t = results[i].type;
228 var n_hl = n.split("");
228 var n_hl = n.split("");
229 var pos = results[i].highlight;
229 var pos = results[i].highlight;
230 for (var j = 0; j < pos.length; j++) {
230 for (var j = 0; j < pos.length; j++) {
231 n_hl[pos[j]] = "<em>" + n_hl[pos[j]] + "</em>";
231 n_hl[pos[j]] = "<em>" + n_hl[pos[j]] + "</em>";
232 }
232 }
233 n_hl = n_hl.join("");
233 n_hl = n_hl.join("");
234 var new_url = url_base.replace('__FPATH__', n);
234 var new_url = url_base.replace('__FPATH__', n);
235
235
236 var typeObj = {
236 var typeObj = {
237 dir: 'icon-directory browser-dir',
237 dir: 'icon-directory browser-dir',
238 file: 'icon-file-text browser-file'
238 file: 'icon-file-text browser-file'
239 };
239 };
240
240
241 var typeIcon = '<i class="{0}"></i>'.format(typeObj[t]);
241 var typeIcon = '<i class="{0}"></i>'.format(typeObj[t]);
242 match.push('<tr class="browser-result"><td><a class="match-link" href="{0}">{1}{2}</a></td><td colspan="5"></td></tr>'.format(new_url, typeIcon, n_hl));
242 match.push('<tr class="browser-result"><td><a class="match-link" href="{0}">{1}{2}</a></td><td colspan="5"></td></tr>'.format(new_url, typeIcon, n_hl));
243 }
243 }
244 }
244 }
245 if (results.length > limit) {
245 if (results.length > limit) {
246 var truncated_count = results.length - matches_max;
246 var truncated_count = results.length - matches_max;
247 if (truncated_count === 1) {
247 if (truncated_count === 1) {
248 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _gettext('truncated result')));
248 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _gettext('truncated result')));
249 } else {
249 } else {
250 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _gettext('truncated results')));
250 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _gettext('truncated results')));
251 }
251 }
252 }
252 }
253 }
253 }
254 if (query !== "") {
254 if (query !== "") {
255 $('#tbody').hide();
255 $('#tbody').hide();
256 $('#tbody_filtered').show();
256 $('#tbody_filtered').show();
257
257
258 if (match.length === 0) {
258 if (match.length === 0) {
259 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_gettext('No matching files')));
259 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_gettext('No matching files')));
260 }
260 }
261 $('#tbody_filtered').html(match.join(""));
261 $('#tbody_filtered').html(match.join(""));
262 } else {
262 } else {
263 $('#tbody').show();
263 $('#tbody').show();
264 $('#tbody_filtered').hide();
264 $('#tbody_filtered').hide();
265 }
265 }
266
266
267 };
267 };
268 };
268 };
269
269
270 };
270 };
271
271
272 var getIdentNode = function(n){
272 var getIdentNode = function(n){
273 // iterate through nodes until matched interesting node
273 // iterate through nodes until matched interesting node
274 if (typeof n === 'undefined'){
274 if (typeof n === 'undefined'){
275 return -1;
275 return -1;
276 }
276 }
277 if(typeof n.id !== "undefined" && n.id.match('L[0-9]+')){
277 if(typeof n.id !== "undefined" && n.id.match('L[0-9]+')){
278 return n;
278 return n;
279 }
279 }
280 else{
280 else{
281 return getIdentNode(n.parentNode);
281 return getIdentNode(n.parentNode);
282 }
282 }
283 };
283 };
284
284
285 var getSelectionLink = function(e) {
285 var getSelectionLink = function(e) {
286 // get selection from start/to nodes
286 // get selection from start/to nodes
287 if (typeof window.getSelection !== "undefined") {
287 if (typeof window.getSelection !== "undefined") {
288 s = window.getSelection();
288 s = window.getSelection();
289
289
290 from = getIdentNode(s.anchorNode);
290 from = getIdentNode(s.anchorNode);
291 till = getIdentNode(s.focusNode);
291 till = getIdentNode(s.focusNode);
292
292
293 f_int = parseInt(from.id.replace('L',''));
293 f_int = parseInt(from.id.replace('L',''));
294 t_int = parseInt(till.id.replace('L',''));
294 t_int = parseInt(till.id.replace('L',''));
295
295
296 if (f_int > t_int){
296 if (f_int > t_int){
297 // highlight from bottom
297 // highlight from bottom
298 offset = -35;
298 offset = -35;
299 ranges = [t_int,f_int];
299 ranges = [t_int,f_int];
300 }
300 }
301 else{
301 else{
302 // highligth from top
302 // highligth from top
303 offset = 35;
303 offset = 35;
304 ranges = [f_int,t_int];
304 ranges = [f_int,t_int];
305 }
305 }
306 // if we select more than 2 lines
306 // if we select more than 2 lines
307 if (ranges[0] !== ranges[1]){
307 if (ranges[0] !== ranges[1]){
308 if($('#linktt').length === 0){
308 if($('#linktt').length === 0){
309 hl_div = document.createElement('div');
309 hl_div = document.createElement('div');
310 hl_div.id = 'linktt';
310 hl_div.id = 'linktt';
311 }
311 }
312 hl_div.innerHTML = '';
312 hl_div.innerHTML = '';
313
313
314 anchor = '#L'+ranges[0]+'-'+ranges[1];
314 anchor = '#L'+ranges[0]+'-'+ranges[1];
315 var link = document.createElement('a');
315 var link = document.createElement('a');
316 link.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
316 link.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
317 link.innerHTML = _gettext('Selection link');
317 link.innerHTML = _gettext('Selection link');
318 hl_div.appendChild(link);
318 hl_div.appendChild(link);
319 $('#codeblock').append(hl_div);
319 $('#codeblock').append(hl_div);
320
320
321 var xy = $(till).offset();
321 var xy = $(till).offset();
322 $('#linktt').addClass('hl-tip-box tip-box');
322 $('#linktt').addClass('hl-tip-box tip-box');
323 $('#linktt').offset({top: xy.top + offset, left: xy.left});
323 $('#linktt').offset({top: xy.top + offset, left: xy.left});
324 $('#linktt').css('visibility','visible');
324 $('#linktt').css('visibility','visible');
325 }
325 }
326 else{
326 else{
327 $('#linktt').css('visibility','hidden');
327 $('#linktt').css('visibility','hidden');
328 }
328 }
329 }
329 }
330 };
330 };
331
332 var getFileState = function() {
333 // relies on a global set filesUrlData
334 var f_path = filesUrlData['f_path'];
335 var commit_id = filesUrlData['commit_id'];
336
337 var url_params = {
338 repo_name: templateContext.repo_name,
339 commit_id: commit_id,
340 f_path:'__FPATH__'
341 };
342 if (atRef !== '') {
343 url_params['at'] = atRef
344 }
345
346 var _url_base = pyroutes.url('repo_files', url_params);
347 var _node_list_url = pyroutes.url('repo_files_nodelist',
348 {repo_name: templateContext.repo_name,
349 commit_id: commit_id, f_path: f_path});
350
351 return {
352 f_path: f_path,
353 commit_id: commit_id,
354 node_list_url: _node_list_url,
355 url_base: _url_base
356 };
357 };
358
359 var getFilesMetadata = function() {
360 // relies on metadataRequest global state
361 if (metadataRequest && metadataRequest.readyState != 4) {
362 metadataRequest.abort();
363 }
364
365 if ($('#file-tree-wrapper').hasClass('full-load')) {
366 // in case our HTML wrapper has full-load class we don't
367 // trigger the async load of metadata
368 return false;
369 }
370
371 var state = getFileState();
372 var url_data = {
373 'repo_name': templateContext.repo_name,
374 'commit_id': state.commit_id,
375 'f_path': state.f_path
376 };
377
378 var url = pyroutes.url('repo_nodetree_full', url_data);
379
380 metadataRequest = $.ajax({url: url});
381
382 metadataRequest.done(function(data) {
383 $('#file-tree').html(data);
384 timeagoActivate();
385 });
386 metadataRequest.fail(function (data, textStatus, errorThrown) {
387 if (data.status != 0) {
388 alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText));
389 }
390 });
391 };
392
393 // show more authors
394 var showAuthors = function(elem, annotate) {
395 var state = getFileState('callbacks');
396
397 var url = pyroutes.url('repo_file_authors',
398 {'repo_name': templateContext.repo_name,
399 'commit_id': state.commit_id, 'f_path': state.f_path});
400
401 $.pjax({
402 url: url,
403 data: 'annotate={0}'.format(annotate),
404 container: '#file_authors',
405 push: false,
406 timeout: 5000
407 }).complete(function(){
408 $(elem).hide();
409 $('#file_authors_title').html(_gettext('All Authors'))
410 })
411 };
@@ -1,35 +1,35 b''
1 <%namespace name="base" file="/base/base.mako"/>
1 <%namespace name="base" file="/base/base.mako"/>
2
2
3 % if c.authors:
3 % if c.authors:
4
4
5 <table class="sidebar-right-content">
5 <table class="sidebar-right-content">
6 % for email, user, commits in sorted(c.authors, key=lambda e: c.file_last_commit.author_email!=e[0]):
6 % for email, user, commits in sorted(c.authors, key=lambda e: c.file_last_commit.author_email!=e[0]):
7 <tr class="file_author tooltip" title="${h.tooltip(h.author_string(email))}">
7 <tr class="file_author tooltip" title="${h.tooltip(h.author_string(email))}">
8
8
9 <td>
9 <td>
10 <span class="user commit-author">${h.link_to_user(user)}</span>
10 <span class="user commit-author">${h.link_to_user(user)}</span>
11 % if c.file_author:
11 % if c.file_author:
12 <span class="commit-date">- ${h.age_component(c.file_last_commit.date)}</span>
12 <span class="commit-date">- ${h.age_component(c.file_last_commit.date)}</span>
13 <a href="#ShowAuthors" id="show_authors" class="action_link"> - ${_('Load All Authors')}</a>
13 <a href="#ShowAuthors" onclick="showAuthors(this, ${("1" if c.annotate else "0")}); return false" class="action_link"> - ${_('Load All Authors')}</a>
14 % elif c.file_last_commit.author_email==email:
14 % elif c.file_last_commit.author_email==email:
15 <span> (${_('last author')})</span>
15 <span> (${_('last author')})</span>
16 % endif
16 % endif
17 </td>
17 </td>
18
18
19 <td>
19 <td>
20 % if not c.file_author:
20 % if not c.file_author:
21 <code>
21 <code>
22 % if commits == 1:
22 % if commits == 1:
23 ${commits} ${_('Commit')}
23 ${commits} ${_('Commit')}
24 % else:
24 % else:
25 ${commits} ${_('Commits')}
25 ${commits} ${_('Commits')}
26 % endif
26 % endif
27 </code>
27 </code>
28 % endif
28 % endif
29 </td>
29 </td>
30 </tr>
30 </tr>
31
31
32 % endfor
32 % endfor
33 </table>
33 </table>
34 % endif
34 % endif
35
35
@@ -1,467 +1,369 b''
1 <%inherit file="/base/base.mako"/>
1 <%inherit file="/base/base.mako"/>
2
2
3 <%def name="title(*args)">
3 <%def name="title(*args)">
4 ${_('{} Files').format(c.repo_name)}
4 ${_('{} Files').format(c.repo_name)}
5 %if hasattr(c,'file'):
5 %if hasattr(c,'file'):
6 &middot; ${(h.safe_unicode(c.file.path) or '\\')}
6 &middot; ${(h.safe_unicode(c.file.path) or '\\')}
7 %endif
7 %endif
8
8
9 %if c.rhodecode_name:
9 %if c.rhodecode_name:
10 &middot; ${h.branding(c.rhodecode_name)}
10 &middot; ${h.branding(c.rhodecode_name)}
11 %endif
11 %endif
12 </%def>
12 </%def>
13
13
14 <%def name="breadcrumbs_links()">
14 <%def name="breadcrumbs_links()">
15 ${_('Files')}
15 ${_('Files')}
16 %if c.file:
16 %if c.file:
17 @ ${h.show_id(c.commit)}
17 @ ${h.show_id(c.commit)}
18 %endif
18 %endif
19 </%def>
19 </%def>
20
20
21 <%def name="menu_bar_nav()">
21 <%def name="menu_bar_nav()">
22 ${self.menu_items(active='repositories')}
22 ${self.menu_items(active='repositories')}
23 </%def>
23 </%def>
24
24
25 <%def name="menu_bar_subnav()">
25 <%def name="menu_bar_subnav()">
26 ${self.repo_menu(active='files')}
26 ${self.repo_menu(active='files')}
27 </%def>
27 </%def>
28
28
29 <%def name="main()">
29 <%def name="main()">
30 <script type="text/javascript">
31 var fileSourcePage = ${c.file_source_page};
32 var atRef = '${request.GET.get('at', '')}';
33
34 // global state for fetching metadata
35 metadataRequest = null;
36
37 // global metadata about URL
38 filesUrlData = ${h.json.dumps(request.matchdict)|n};
39 </script>
40
30 <div>
41 <div>
31 <div id="files_data">
42 <div id="files_data">
32 <%include file='files_pjax.mako'/>
43 <%include file='files_pjax.mako'/>
33 </div>
44 </div>
34 </div>
45 </div>
35 <script>
36
46
37 var metadataRequest = null;
47 <script type="text/javascript">
38 var fileSourcePage = ${c.file_source_page};
39 var atRef = '${request.GET.get('at', '')}';
40
41 var getState = function(context) {
42 var url = $(location).attr('href');
43 var _base_url = '${h.route_path("repo_files",repo_name=c.repo_name,commit_id='',f_path='')}';
44 var _annotate_url = '${h.route_path("repo_files:annotated",repo_name=c.repo_name,commit_id='',f_path='')}';
45 _base_url = _base_url.replace('//', '/');
46 _annotate_url = _annotate_url.replace('//', '/');
47
48 //extract f_path from url.
49 var parts = url.split(_base_url);
50 if (parts.length != 2) {
51 parts = url.split(_annotate_url);
52 if (parts.length != 2) {
53 var rev = "tip";
54 var f_path = "";
55 } else {
56 var parts2 = parts[1].split('/');
57 var rev = parts2.shift(); // pop the first element which is the revision
58 var f_path = parts2.join('/');
59 }
60
61 } else {
62 var parts2 = parts[1].split('/');
63 var rev = parts2.shift(); // pop the first element which is the revision
64 var f_path = parts2.join('/');
65 }
66
67 var url_params = {
68 repo_name: templateContext.repo_name,
69 commit_id: rev,
70 f_path:'__FPATH__'
71 };
72 if (atRef !== '') {
73 url_params['at'] = atRef
74 }
75
76 var _url_base = pyroutes.url('repo_files', url_params);
77 var _node_list_url = pyroutes.url('repo_files_nodelist',
78 {repo_name: templateContext.repo_name,
79 commit_id: rev, f_path: f_path});
80
81 return {
82 url: url,
83 f_path: f_path,
84 rev: rev,
85 commit_id: "${c.commit.raw_id}",
86 node_list_url: _node_list_url,
87 url_base: _url_base
88 };
89 };
90
91 var getFilesMetadata = function() {
92 if (metadataRequest && metadataRequest.readyState != 4) {
93 metadataRequest.abort();
94 }
95 if (fileSourcePage) {
96 return false;
97 }
98
99 if ($('#file-tree-wrapper').hasClass('full-load')) {
100 // in case our HTML wrapper has full-load class we don't
101 // trigger the async load of metadata
102 return false;
103 }
104
105 var state = getState('metadata');
106 var url_data = {
107 'repo_name': templateContext.repo_name,
108 'commit_id': state.commit_id,
109 'f_path': state.f_path
110 };
111
112 var url = pyroutes.url('repo_nodetree_full', url_data);
113
114 metadataRequest = $.ajax({url: url});
115
116 metadataRequest.done(function(data) {
117 $('#file-tree').html(data);
118 timeagoActivate();
119 });
120 metadataRequest.fail(function (data, textStatus, errorThrown) {
121 if (data.status != 0) {
122 alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText));
123 }
124 });
125 };
126
48
127 var initFileJS = function () {
49 var initFileJS = function () {
128 var state = getState('callbacks');
50 var state = getFileState();
129
51
130 // select code link event
52 // select code link event
131 $("#hlcode").mouseup(getSelectionLink);
53 $("#hlcode").mouseup(getSelectionLink);
132
54
133 // file history select2 used for history of file, and switch to
55 // file history select2 used for history of file, and switch to
134 var initialCommitData = {
56 var initialCommitData = {
135 at_ref: atRef,
57 at_ref: atRef,
136 id: null,
58 id: null,
137 text: '${c.commit.raw_id}',
59 text: '${c.commit.raw_id}',
138 type: 'sha',
60 type: 'sha',
139 raw_id: '${c.commit.raw_id}',
61 raw_id: '${c.commit.raw_id}',
140 idx: ${c.commit.idx},
62 idx: ${c.commit.idx},
141 files_url: null,
63 files_url: null,
142 };
64 };
143
65
144 // check if we have ref info.
66 // check if we have ref info.
145 var selectedRef = fileTreeRefs[atRef];
67 var selectedRef = fileTreeRefs[atRef];
146 if (selectedRef !== undefined) {
68 if (selectedRef !== undefined) {
147 $.extend(initialCommitData, selectedRef)
69 $.extend(initialCommitData, selectedRef)
148 }
70 }
149
71
150 var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.rev,'f_path': state.f_path});
72 var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.commit_id,'f_path': state.f_path});
151 var cacheKey = '__SINGLE_FILE_REFS__';
73 var cacheKey = '__SINGLE_FILE_REFS__';
152 var cachedDataSource = {};
74 var cachedDataSource = {};
153
75
154 var loadRefsData = function (query) {
76 var loadRefsData = function (query) {
155 $.ajax({
77 $.ajax({
156 url: loadUrl,
78 url: loadUrl,
157 data: {},
79 data: {},
158 dataType: 'json',
80 dataType: 'json',
159 type: 'GET',
81 type: 'GET',
160 success: function (data) {
82 success: function (data) {
161 cachedDataSource[cacheKey] = data;
83 cachedDataSource[cacheKey] = data;
162 query.callback({results: data.results});
84 query.callback({results: data.results});
163 }
85 }
164 });
86 });
165 };
87 };
166
88
167 var feedRefsData = function (query, cachedData) {
89 var feedRefsData = function (query, cachedData) {
168 var data = {results: []};
90 var data = {results: []};
169 //filter results
91 //filter results
170 $.each(cachedData.results, function () {
92 $.each(cachedData.results, function () {
171 var section = this.text;
93 var section = this.text;
172 var children = [];
94 var children = [];
173 $.each(this.children, function () {
95 $.each(this.children, function () {
174 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
96 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
175 children.push(this)
97 children.push(this)
176 }
98 }
177 });
99 });
178 data.results.push({
100 data.results.push({
179 'text': section,
101 'text': section,
180 'children': children
102 'children': children
181 })
103 })
182 });
104 });
183
105
184 query.callback(data);
106 query.callback(data);
185 };
107 };
186
108
187 var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) {
109 var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) {
188 var formatResult = function (result, container, query) {
110 var formatResult = function (result, container, query) {
189 return formatSelect2SelectionRefs(result);
111 return formatSelect2SelectionRefs(result);
190 };
112 };
191
113
192 var formatSelection = function (data, container) {
114 var formatSelection = function (data, container) {
193 var commit_ref = data;
115 var commit_ref = data;
194
116
195 var tmpl = '';
117 var tmpl = '';
196 if (commit_ref.type === 'sha') {
118 if (commit_ref.type === 'sha') {
197 tmpl = (commit_ref.raw_id || "").substr(0,8);
119 tmpl = (commit_ref.raw_id || "").substr(0,8);
198 } else if (commit_ref.type === 'branch') {
120 } else if (commit_ref.type === 'branch') {
199 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
121 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
200 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
122 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
201 } else if (commit_ref.type === 'tag') {
123 } else if (commit_ref.type === 'tag') {
202 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
124 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
203 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
125 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
204 } else if (commit_ref.type === 'book') {
126 } else if (commit_ref.type === 'book') {
205 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
127 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
206 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
128 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
207 }
129 }
208 var idx = commit_ref.idx || 0;
130 var idx = commit_ref.idx || 0;
209 if (idx !== 0) {
131 if (idx !== 0) {
210 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
132 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
211 }
133 }
212 return tmpl
134 return tmpl
213 };
135 };
214
136
215 $(targetElement).select2({
137 $(targetElement).select2({
216 dropdownAutoWidth: true,
138 dropdownAutoWidth: true,
217 width: "resolve",
139 width: "resolve",
218 containerCssClass: "drop-menu",
140 containerCssClass: "drop-menu",
219 dropdownCssClass: "drop-menu-dropdown",
141 dropdownCssClass: "drop-menu-dropdown",
220 query: function(query) {
142 query: function(query) {
221 var cachedData = cachedDataSource[cacheKey];
143 var cachedData = cachedDataSource[cacheKey];
222 if (cachedData) {
144 if (cachedData) {
223 feedRefsData(query, cachedData)
145 feedRefsData(query, cachedData)
224 } else {
146 } else {
225 loadRefsData(query)
147 loadRefsData(query)
226 }
148 }
227 },
149 },
228 initSelection: function(element, callback) {
150 initSelection: function(element, callback) {
229 callback(initialData);
151 callback(initialData);
230 },
152 },
231 formatResult: formatResult,
153 formatResult: formatResult,
232 formatSelection: formatSelection
154 formatSelection: formatSelection
233 });
155 });
234
156
235 };
157 };
236
158
237 select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData);
159 select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData);
238
160
239 $('#file_refs_filter').on('change', function(e) {
161 $('#file_refs_filter').on('change', function(e) {
240 var data = $('#file_refs_filter').select2('data');
162 var data = $('#file_refs_filter').select2('data');
241 var commit_id = data.id;
163 var commit_id = data.id;
242
164
243 if ("${c.annotate}" === "True") {
165 if ("${c.annotate}" === "True") {
244 var url = pyroutes.url('repo_files:annotated',
166 var url = pyroutes.url('repo_files:annotated',
245 {'repo_name': templateContext.repo_name,
167 {'repo_name': templateContext.repo_name,
246 'commit_id': commit_id, 'f_path': state.f_path});
168 'commit_id': commit_id, 'f_path': state.f_path});
247 } else {
169 } else {
248 var url = pyroutes.url('repo_files',
170 var url = pyroutes.url('repo_files',
249 {'repo_name': templateContext.repo_name,
171 {'repo_name': templateContext.repo_name,
250 'commit_id': commit_id, 'f_path': state.f_path});
172 'commit_id': commit_id, 'f_path': state.f_path});
251 }
173 }
252 window.location = url;
174 window.location = url;
253
175
254 });
176 });
255
177
256 // show more authors
257 $('#show_authors').on('click', function(e) {
258 e.preventDefault();
259 var url = pyroutes.url('repo_file_authors',
260 {'repo_name': templateContext.repo_name,
261 'commit_id': state.rev, 'f_path': state.f_path});
262
263 $.pjax({
264 url: url,
265 data: 'annotate=${("1" if c.annotate else "0")}',
266 container: '#file_authors',
267 push: false,
268 timeout: 5000
269 }).complete(function(){
270 $('#show_authors').hide();
271 $('#file_authors_title').html(_gettext('All Authors'))
272 })
273 });
274
275 // load file short history
178 // load file short history
276 $('#file_history_overview').on('click', function(e) {
179 $('#file_history_overview').on('click', function(e) {
277 e.preventDefault();
180 e.preventDefault();
278 path = state.f_path;
181 path = state.f_path;
279 if (path.indexOf("#") >= 0) {
182 if (path.indexOf("#") >= 0) {
280 path = path.slice(0, path.indexOf("#"));
183 path = path.slice(0, path.indexOf("#"));
281 }
184 }
282 var url = pyroutes.url('repo_changelog_file',
185 var url = pyroutes.url('repo_changelog_file',
283 {'repo_name': templateContext.repo_name,
186 {'repo_name': templateContext.repo_name,
284 'commit_id': state.rev, 'f_path': path, 'limit': 6});
187 'commit_id': state.commit_id, 'f_path': path, 'limit': 6});
285 $('#file_history_container').show();
188 $('#file_history_container').show();
286 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
189 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
287
190
288 $.pjax({
191 $.pjax({
289 url: url,
192 url: url,
290 container: '#file_history_container',
193 container: '#file_history_container',
291 push: false,
194 push: false,
292 timeout: 5000
195 timeout: 5000
293 });
196 });
294 });
197 });
295
198
296
297 };
199 };
298
200
299 var initTreeJS = function () {
201 var initTreeJS = function () {
300 var state = getState('callbacks');
202 var state = getFileState();
301 getFilesMetadata();
203 getFilesMetadata();
302
204
303 // fuzzy file filter
205 // fuzzy file filter
304 fileBrowserListeners(state.node_list_url, state.url_base);
206 fileBrowserListeners(state.node_list_url, state.url_base);
305
207
306 // switch to widget
208 // switch to widget
307 var initialCommitData = {
209 var initialCommitData = {
308 at_ref: atRef,
210 at_ref: atRef,
309 id: null,
211 id: null,
310 text: '${c.commit.raw_id}',
212 text: '${c.commit.raw_id}',
311 type: 'sha',
213 type: 'sha',
312 raw_id: '${c.commit.raw_id}',
214 raw_id: '${c.commit.raw_id}',
313 idx: ${c.commit.idx},
215 idx: ${c.commit.idx},
314 files_url: null,
216 files_url: null,
315 };
217 };
316
218
317 // check if we have ref info.
219 // check if we have ref info.
318 var selectedRef = fileTreeRefs[atRef];
220 var selectedRef = fileTreeRefs[atRef];
319 if (selectedRef !== undefined) {
221 if (selectedRef !== undefined) {
320 $.extend(initialCommitData, selectedRef)
222 $.extend(initialCommitData, selectedRef)
321 }
223 }
322
224
323 var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
225 var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
324 var cacheKey = '__ALL_FILE_REFS__';
226 var cacheKey = '__ALL_FILE_REFS__';
325 var cachedDataSource = {};
227 var cachedDataSource = {};
326
228
327 var loadRefsData = function (query) {
229 var loadRefsData = function (query) {
328 $.ajax({
230 $.ajax({
329 url: loadUrl,
231 url: loadUrl,
330 data: {},
232 data: {},
331 dataType: 'json',
233 dataType: 'json',
332 type: 'GET',
234 type: 'GET',
333 success: function (data) {
235 success: function (data) {
334 cachedDataSource[cacheKey] = data;
236 cachedDataSource[cacheKey] = data;
335 query.callback({results: data.results});
237 query.callback({results: data.results});
336 }
238 }
337 });
239 });
338 };
240 };
339
241
340 var feedRefsData = function (query, cachedData) {
242 var feedRefsData = function (query, cachedData) {
341 var data = {results: []};
243 var data = {results: []};
342 //filter results
244 //filter results
343 $.each(cachedData.results, function () {
245 $.each(cachedData.results, function () {
344 var section = this.text;
246 var section = this.text;
345 var children = [];
247 var children = [];
346 $.each(this.children, function () {
248 $.each(this.children, function () {
347 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
249 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
348 children.push(this)
250 children.push(this)
349 }
251 }
350 });
252 });
351 data.results.push({
253 data.results.push({
352 'text': section,
254 'text': section,
353 'children': children
255 'children': children
354 })
256 })
355 });
257 });
356
258
357 //push the typed in commit idx
259 //push the typed in commit idx
358 if (!isNaN(query.term)) {
260 if (!isNaN(query.term)) {
359 var files_url = pyroutes.url('repo_files',
261 var files_url = pyroutes.url('repo_files',
360 {'repo_name': templateContext.repo_name,
262 {'repo_name': templateContext.repo_name,
361 'commit_id': query.term, 'f_path': state.f_path});
263 'commit_id': query.term, 'f_path': state.f_path});
362
264
363 data.results.push({
265 data.results.push({
364 'text': _gettext('go to numeric commit'),
266 'text': _gettext('go to numeric commit'),
365 'children': [{
267 'children': [{
366 at_ref: null,
268 at_ref: null,
367 id: null,
269 id: null,
368 text: 'r{0}'.format(query.term),
270 text: 'r{0}'.format(query.term),
369 type: 'sha',
271 type: 'sha',
370 raw_id: query.term,
272 raw_id: query.term,
371 idx: query.term,
273 idx: query.term,
372 files_url: files_url,
274 files_url: files_url,
373 }]
275 }]
374 });
276 });
375 }
277 }
376 query.callback(data);
278 query.callback(data);
377 };
279 };
378
280
379 var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
281 var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
380 var formatResult = function (result, container, query) {
282 var formatResult = function (result, container, query) {
381 return formatSelect2SelectionRefs(result);
283 return formatSelect2SelectionRefs(result);
382 };
284 };
383
285
384 var formatSelection = function (data, container) {
286 var formatSelection = function (data, container) {
385 var commit_ref = data;
287 var commit_ref = data;
386
288
387 var tmpl = '';
289 var tmpl = '';
388 if (commit_ref.type === 'sha') {
290 if (commit_ref.type === 'sha') {
389 tmpl = (commit_ref.raw_id || "").substr(0,8);
291 tmpl = (commit_ref.raw_id || "").substr(0,8);
390 } else if (commit_ref.type === 'branch') {
292 } else if (commit_ref.type === 'branch') {
391 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
293 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
392 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
294 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
393 } else if (commit_ref.type === 'tag') {
295 } else if (commit_ref.type === 'tag') {
394 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
296 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
395 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
297 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
396 } else if (commit_ref.type === 'book') {
298 } else if (commit_ref.type === 'book') {
397 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
299 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
398 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
300 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
399 }
301 }
400
302
401 var idx = commit_ref.idx || 0;
303 var idx = commit_ref.idx || 0;
402 if (idx !== 0) {
304 if (idx !== 0) {
403 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
305 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
404 }
306 }
405 return tmpl
307 return tmpl
406 };
308 };
407
309
408 $(targetElement).select2({
310 $(targetElement).select2({
409 dropdownAutoWidth: true,
311 dropdownAutoWidth: true,
410 width: "resolve",
312 width: "resolve",
411 containerCssClass: "drop-menu",
313 containerCssClass: "drop-menu",
412 dropdownCssClass: "drop-menu-dropdown",
314 dropdownCssClass: "drop-menu-dropdown",
413 query: function(query) {
315 query: function(query) {
414
316
415 var cachedData = cachedDataSource[cacheKey];
317 var cachedData = cachedDataSource[cacheKey];
416 if (cachedData) {
318 if (cachedData) {
417 feedRefsData(query, cachedData)
319 feedRefsData(query, cachedData)
418 } else {
320 } else {
419 loadRefsData(query)
321 loadRefsData(query)
420 }
322 }
421 },
323 },
422 initSelection: function(element, callback) {
324 initSelection: function(element, callback) {
423 callback(initialData);
325 callback(initialData);
424 },
326 },
425 formatResult: formatResult,
327 formatResult: formatResult,
426 formatSelection: formatSelection
328 formatSelection: formatSelection
427 });
329 });
428
330
429 };
331 };
430
332
431 select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
333 select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
432
334
433 $('#refs_filter').on('change', function(e) {
335 $('#refs_filter').on('change', function(e) {
434 var data = $('#refs_filter').select2('data');
336 var data = $('#refs_filter').select2('data');
435 window.location = data.files_url
337 window.location = data.files_url
436 });
338 });
437
339
438 };
340 };
439
341
440 $(document).ready(function() {
342 $(document).ready(function() {
441 timeagoActivate();
343 timeagoActivate();
442
344
443 if ($('#trimmed_message_box').height() < 50) {
345 if ($('#trimmed_message_box').height() < 50) {
444 $('#message_expand').hide();
346 $('#message_expand').hide();
445 }
347 }
446
348
447 $('#message_expand').on('click', function(e) {
349 $('#message_expand').on('click', function(e) {
448 $('#trimmed_message_box').css('max-height', 'none');
350 $('#trimmed_message_box').css('max-height', 'none');
449 $(this).hide();
351 $(this).hide();
450 });
352 });
451
353
452 if (fileSourcePage) {
354 if (fileSourcePage) {
453 initFileJS()
355 initFileJS()
454 } else {
356 } else {
455 initTreeJS()
357 initTreeJS()
456 }
358 }
457
359
458 var search_GET = "${request.GET.get('search','')}";
360 var search_GET = "${request.GET.get('search','')}";
459 if (search_GET === "1") {
361 if (search_GET === "1") {
460 NodeFilter.initFilter();
362 NodeFilter.initFilter();
461 NodeFilter.focus();
363 NodeFilter.focus();
462 }
364 }
463 });
365 });
464
366
465 </script>
367 </script>
466
368
467 </%def> No newline at end of file
369 </%def>
General Comments 0
You need to be logged in to leave comments. Login now