##// END OF EJS Templates
files: don't format 0 revision in select pickers
marcink -
r3707:da37aa49 new-ui
parent child Browse files
Show More
@@ -1,463 +1,467 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 <div>
30 <div>
31 <div id="files_data">
31 <div id="files_data">
32 <%include file='files_pjax.mako'/>
32 <%include file='files_pjax.mako'/>
33 </div>
33 </div>
34 </div>
34 </div>
35 <script>
35 <script>
36
36
37 var metadataRequest = null;
37 var metadataRequest = null;
38 var fileSourcePage = ${c.file_source_page};
38 var fileSourcePage = ${c.file_source_page};
39 var atRef = '${request.GET.get('at', '')}';
39 var atRef = '${request.GET.get('at', '')}';
40
40
41 var getState = function(context) {
41 var getState = function(context) {
42 var url = $(location).attr('href');
42 var url = $(location).attr('href');
43 var _base_url = '${h.route_path("repo_files",repo_name=c.repo_name,commit_id='',f_path='')}';
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='')}';
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('//', '/');
45 _base_url = _base_url.replace('//', '/');
46 _annotate_url = _annotate_url.replace('//', '/');
46 _annotate_url = _annotate_url.replace('//', '/');
47
47
48 //extract f_path from url.
48 //extract f_path from url.
49 var parts = url.split(_base_url);
49 var parts = url.split(_base_url);
50 if (parts.length != 2) {
50 if (parts.length != 2) {
51 parts = url.split(_annotate_url);
51 parts = url.split(_annotate_url);
52 if (parts.length != 2) {
52 if (parts.length != 2) {
53 var rev = "tip";
53 var rev = "tip";
54 var f_path = "";
54 var f_path = "";
55 } else {
55 } else {
56 var parts2 = parts[1].split('/');
56 var parts2 = parts[1].split('/');
57 var rev = parts2.shift(); // pop the first element which is the revision
57 var rev = parts2.shift(); // pop the first element which is the revision
58 var f_path = parts2.join('/');
58 var f_path = parts2.join('/');
59 }
59 }
60
60
61 } else {
61 } else {
62 var parts2 = parts[1].split('/');
62 var parts2 = parts[1].split('/');
63 var rev = parts2.shift(); // pop the first element which is the revision
63 var rev = parts2.shift(); // pop the first element which is the revision
64 var f_path = parts2.join('/');
64 var f_path = parts2.join('/');
65 }
65 }
66
66
67 var url_params = {
67 var url_params = {
68 repo_name: templateContext.repo_name,
68 repo_name: templateContext.repo_name,
69 commit_id: rev,
69 commit_id: rev,
70 f_path:'__FPATH__'
70 f_path:'__FPATH__'
71 };
71 };
72 if (atRef !== '') {
72 if (atRef !== '') {
73 url_params['at'] = atRef
73 url_params['at'] = atRef
74 }
74 }
75
75
76 var _url_base = pyroutes.url('repo_files', url_params);
76 var _url_base = pyroutes.url('repo_files', url_params);
77 var _node_list_url = pyroutes.url('repo_files_nodelist',
77 var _node_list_url = pyroutes.url('repo_files_nodelist',
78 {repo_name: templateContext.repo_name,
78 {repo_name: templateContext.repo_name,
79 commit_id: rev, f_path: f_path});
79 commit_id: rev, f_path: f_path});
80
80
81 return {
81 return {
82 url: url,
82 url: url,
83 f_path: f_path,
83 f_path: f_path,
84 rev: rev,
84 rev: rev,
85 commit_id: "${c.commit.raw_id}",
85 commit_id: "${c.commit.raw_id}",
86 node_list_url: _node_list_url,
86 node_list_url: _node_list_url,
87 url_base: _url_base
87 url_base: _url_base
88 };
88 };
89 };
89 };
90
90
91 var getFilesMetadata = function() {
91 var getFilesMetadata = function() {
92 if (metadataRequest && metadataRequest.readyState != 4) {
92 if (metadataRequest && metadataRequest.readyState != 4) {
93 metadataRequest.abort();
93 metadataRequest.abort();
94 }
94 }
95 if (fileSourcePage) {
95 if (fileSourcePage) {
96 return false;
96 return false;
97 }
97 }
98
98
99 if ($('#file-tree-wrapper').hasClass('full-load')) {
99 if ($('#file-tree-wrapper').hasClass('full-load')) {
100 // in case our HTML wrapper has full-load class we don't
100 // in case our HTML wrapper has full-load class we don't
101 // trigger the async load of metadata
101 // trigger the async load of metadata
102 return false;
102 return false;
103 }
103 }
104
104
105 var state = getState('metadata');
105 var state = getState('metadata');
106 var url_data = {
106 var url_data = {
107 'repo_name': templateContext.repo_name,
107 'repo_name': templateContext.repo_name,
108 'commit_id': state.commit_id,
108 'commit_id': state.commit_id,
109 'f_path': state.f_path
109 'f_path': state.f_path
110 };
110 };
111
111
112 var url = pyroutes.url('repo_nodetree_full', url_data);
112 var url = pyroutes.url('repo_nodetree_full', url_data);
113
113
114 metadataRequest = $.ajax({url: url});
114 metadataRequest = $.ajax({url: url});
115
115
116 metadataRequest.done(function(data) {
116 metadataRequest.done(function(data) {
117 $('#file-tree').html(data);
117 $('#file-tree').html(data);
118 timeagoActivate();
118 timeagoActivate();
119 });
119 });
120 metadataRequest.fail(function (data, textStatus, errorThrown) {
120 metadataRequest.fail(function (data, textStatus, errorThrown) {
121 if (data.status != 0) {
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));
122 alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText));
123 }
123 }
124 });
124 });
125 };
125 };
126
126
127 var initFileJS = function () {
127 var initFileJS = function () {
128 var state = getState('callbacks');
128 var state = getState('callbacks');
129
129
130 // select code link event
130 // select code link event
131 $("#hlcode").mouseup(getSelectionLink);
131 $("#hlcode").mouseup(getSelectionLink);
132
132
133 // file history select2 used for history of file, and switch to
133 // file history select2 used for history of file, and switch to
134 var initialCommitData = {
134 var initialCommitData = {
135 at_ref: atRef,
135 at_ref: atRef,
136 id: null,
136 id: null,
137 text: '${c.commit.raw_id}',
137 text: '${c.commit.raw_id}',
138 type: 'sha',
138 type: 'sha',
139 raw_id: '${c.commit.raw_id}',
139 raw_id: '${c.commit.raw_id}',
140 idx: ${c.commit.idx},
140 idx: ${c.commit.idx},
141 files_url: null,
141 files_url: null,
142 };
142 };
143
143
144 // check if we have ref info.
144 // check if we have ref info.
145 var selectedRef = fileTreeRefs[atRef];
145 var selectedRef = fileTreeRefs[atRef];
146 if (selectedRef !== undefined) {
146 if (selectedRef !== undefined) {
147 $.extend(initialCommitData, selectedRef)
147 $.extend(initialCommitData, selectedRef)
148 }
148 }
149
149
150 var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.rev,'f_path': state.f_path});
150 var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.rev,'f_path': state.f_path});
151 var cacheKey = '__SINGLE_FILE_REFS__';
151 var cacheKey = '__SINGLE_FILE_REFS__';
152 var cachedDataSource = {};
152 var cachedDataSource = {};
153
153
154 var loadRefsData = function (query) {
154 var loadRefsData = function (query) {
155 $.ajax({
155 $.ajax({
156 url: loadUrl,
156 url: loadUrl,
157 data: {},
157 data: {},
158 dataType: 'json',
158 dataType: 'json',
159 type: 'GET',
159 type: 'GET',
160 success: function (data) {
160 success: function (data) {
161 cachedDataSource[cacheKey] = data;
161 cachedDataSource[cacheKey] = data;
162 query.callback({results: data.results});
162 query.callback({results: data.results});
163 }
163 }
164 });
164 });
165 };
165 };
166
166
167 var feedRefsData = function (query, cachedData) {
167 var feedRefsData = function (query, cachedData) {
168 var data = {results: []};
168 var data = {results: []};
169 //filter results
169 //filter results
170 $.each(cachedData.results, function () {
170 $.each(cachedData.results, function () {
171 var section = this.text;
171 var section = this.text;
172 var children = [];
172 var children = [];
173 $.each(this.children, function () {
173 $.each(this.children, function () {
174 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
174 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
175 children.push(this)
175 children.push(this)
176 }
176 }
177 });
177 });
178 data.results.push({
178 data.results.push({
179 'text': section,
179 'text': section,
180 'children': children
180 'children': children
181 })
181 })
182 });
182 });
183
183
184 query.callback(data);
184 query.callback(data);
185 };
185 };
186
186
187 var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) {
187 var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) {
188 var formatResult = function (result, container, query) {
188 var formatResult = function (result, container, query) {
189 return formatSelect2SelectionRefs(result);
189 return formatSelect2SelectionRefs(result);
190 };
190 };
191
191
192 var formatSelection = function (data, container) {
192 var formatSelection = function (data, container) {
193 var commit_ref = data;
193 var commit_ref = data;
194
194
195 var tmpl = '';
195 var tmpl = '';
196 if (commit_ref.type === 'sha') {
196 if (commit_ref.type === 'sha') {
197 tmpl = (commit_ref.raw_id || "").substr(0,8);
197 tmpl = (commit_ref.raw_id || "").substr(0,8);
198 } else if (commit_ref.type === 'branch') {
198 } else if (commit_ref.type === 'branch') {
199 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
199 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
200 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
200 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
201 } else if (commit_ref.type === 'tag') {
201 } else if (commit_ref.type === 'tag') {
202 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
202 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
203 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
203 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
204 } else if (commit_ref.type === 'book') {
204 } else if (commit_ref.type === 'book') {
205 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
205 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
206 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
206 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
207 }
207 }
208 var idx = commit_ref.idx || 0;
208 var idx = commit_ref.idx || 0;
209 if (idx !== 0) {
209 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
210 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
211 }
210 return tmpl
212 return tmpl
211 };
213 };
212
214
213 $(targetElement).select2({
215 $(targetElement).select2({
214 dropdownAutoWidth: true,
216 dropdownAutoWidth: true,
215 width: "resolve",
217 width: "resolve",
216 containerCssClass: "drop-menu",
218 containerCssClass: "drop-menu",
217 dropdownCssClass: "drop-menu-dropdown",
219 dropdownCssClass: "drop-menu-dropdown",
218 query: function(query) {
220 query: function(query) {
219 var cachedData = cachedDataSource[cacheKey];
221 var cachedData = cachedDataSource[cacheKey];
220 if (cachedData) {
222 if (cachedData) {
221 feedRefsData(query, cachedData)
223 feedRefsData(query, cachedData)
222 } else {
224 } else {
223 loadRefsData(query)
225 loadRefsData(query)
224 }
226 }
225 },
227 },
226 initSelection: function(element, callback) {
228 initSelection: function(element, callback) {
227 callback(initialData);
229 callback(initialData);
228 },
230 },
229 formatResult: formatResult,
231 formatResult: formatResult,
230 formatSelection: formatSelection
232 formatSelection: formatSelection
231 });
233 });
232
234
233 };
235 };
234
236
235 select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData);
237 select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData);
236
238
237 $('#file_refs_filter').on('change', function(e) {
239 $('#file_refs_filter').on('change', function(e) {
238 var data = $('#file_refs_filter').select2('data');
240 var data = $('#file_refs_filter').select2('data');
239 var commit_id = data.id;
241 var commit_id = data.id;
240
242
241 if ("${c.annotate}" === "True") {
243 if ("${c.annotate}" === "True") {
242 var url = pyroutes.url('repo_files:annotated',
244 var url = pyroutes.url('repo_files:annotated',
243 {'repo_name': templateContext.repo_name,
245 {'repo_name': templateContext.repo_name,
244 'commit_id': commit_id, 'f_path': state.f_path});
246 'commit_id': commit_id, 'f_path': state.f_path});
245 } else {
247 } else {
246 var url = pyroutes.url('repo_files',
248 var url = pyroutes.url('repo_files',
247 {'repo_name': templateContext.repo_name,
249 {'repo_name': templateContext.repo_name,
248 'commit_id': commit_id, 'f_path': state.f_path});
250 'commit_id': commit_id, 'f_path': state.f_path});
249 }
251 }
250 window.location = url;
252 window.location = url;
251
253
252 });
254 });
253
255
254 // show more authors
256 // show more authors
255 $('#show_authors').on('click', function(e) {
257 $('#show_authors').on('click', function(e) {
256 e.preventDefault();
258 e.preventDefault();
257 var url = pyroutes.url('repo_file_authors',
259 var url = pyroutes.url('repo_file_authors',
258 {'repo_name': templateContext.repo_name,
260 {'repo_name': templateContext.repo_name,
259 'commit_id': state.rev, 'f_path': state.f_path});
261 'commit_id': state.rev, 'f_path': state.f_path});
260
262
261 $.pjax({
263 $.pjax({
262 url: url,
264 url: url,
263 data: 'annotate=${("1" if c.annotate else "0")}',
265 data: 'annotate=${("1" if c.annotate else "0")}',
264 container: '#file_authors',
266 container: '#file_authors',
265 push: false,
267 push: false,
266 timeout: 5000
268 timeout: 5000
267 }).complete(function(){
269 }).complete(function(){
268 $('#show_authors').hide();
270 $('#show_authors').hide();
269 $('#file_authors_title').html(_gettext('All Authors'))
271 $('#file_authors_title').html(_gettext('All Authors'))
270 })
272 })
271 });
273 });
272
274
273 // load file short history
275 // load file short history
274 $('#file_history_overview').on('click', function(e) {
276 $('#file_history_overview').on('click', function(e) {
275 e.preventDefault();
277 e.preventDefault();
276 path = state.f_path;
278 path = state.f_path;
277 if (path.indexOf("#") >= 0) {
279 if (path.indexOf("#") >= 0) {
278 path = path.slice(0, path.indexOf("#"));
280 path = path.slice(0, path.indexOf("#"));
279 }
281 }
280 var url = pyroutes.url('repo_changelog_file',
282 var url = pyroutes.url('repo_changelog_file',
281 {'repo_name': templateContext.repo_name,
283 {'repo_name': templateContext.repo_name,
282 'commit_id': state.rev, 'f_path': path, 'limit': 6});
284 'commit_id': state.rev, 'f_path': path, 'limit': 6});
283 $('#file_history_container').show();
285 $('#file_history_container').show();
284 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
286 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
285
287
286 $.pjax({
288 $.pjax({
287 url: url,
289 url: url,
288 container: '#file_history_container',
290 container: '#file_history_container',
289 push: false,
291 push: false,
290 timeout: 5000
292 timeout: 5000
291 });
293 });
292 });
294 });
293
295
294
296
295 };
297 };
296
298
297 var initTreeJS = function () {
299 var initTreeJS = function () {
298 var state = getState('callbacks');
300 var state = getState('callbacks');
299 getFilesMetadata();
301 getFilesMetadata();
300
302
301 // fuzzy file filter
303 // fuzzy file filter
302 fileBrowserListeners(state.node_list_url, state.url_base);
304 fileBrowserListeners(state.node_list_url, state.url_base);
303
305
304 // switch to widget
306 // switch to widget
305 var initialCommitData = {
307 var initialCommitData = {
306 at_ref: atRef,
308 at_ref: atRef,
307 id: null,
309 id: null,
308 text: '${c.commit.raw_id}',
310 text: '${c.commit.raw_id}',
309 type: 'sha',
311 type: 'sha',
310 raw_id: '${c.commit.raw_id}',
312 raw_id: '${c.commit.raw_id}',
311 idx: ${c.commit.idx},
313 idx: ${c.commit.idx},
312 files_url: null,
314 files_url: null,
313 };
315 };
314
316
315 // check if we have ref info.
317 // check if we have ref info.
316 var selectedRef = fileTreeRefs[atRef];
318 var selectedRef = fileTreeRefs[atRef];
317 if (selectedRef !== undefined) {
319 if (selectedRef !== undefined) {
318 $.extend(initialCommitData, selectedRef)
320 $.extend(initialCommitData, selectedRef)
319 }
321 }
320
322
321 var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
323 var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
322 var cacheKey = '__ALL_FILE_REFS__';
324 var cacheKey = '__ALL_FILE_REFS__';
323 var cachedDataSource = {};
325 var cachedDataSource = {};
324
326
325 var loadRefsData = function (query) {
327 var loadRefsData = function (query) {
326 $.ajax({
328 $.ajax({
327 url: loadUrl,
329 url: loadUrl,
328 data: {},
330 data: {},
329 dataType: 'json',
331 dataType: 'json',
330 type: 'GET',
332 type: 'GET',
331 success: function (data) {
333 success: function (data) {
332 cachedDataSource[cacheKey] = data;
334 cachedDataSource[cacheKey] = data;
333 query.callback({results: data.results});
335 query.callback({results: data.results});
334 }
336 }
335 });
337 });
336 };
338 };
337
339
338 var feedRefsData = function (query, cachedData) {
340 var feedRefsData = function (query, cachedData) {
339 var data = {results: []};
341 var data = {results: []};
340 //filter results
342 //filter results
341 $.each(cachedData.results, function () {
343 $.each(cachedData.results, function () {
342 var section = this.text;
344 var section = this.text;
343 var children = [];
345 var children = [];
344 $.each(this.children, function () {
346 $.each(this.children, function () {
345 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
347 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
346 children.push(this)
348 children.push(this)
347 }
349 }
348 });
350 });
349 data.results.push({
351 data.results.push({
350 'text': section,
352 'text': section,
351 'children': children
353 'children': children
352 })
354 })
353 });
355 });
354
356
355 //push the typed in commit idx
357 //push the typed in commit idx
356 if (!isNaN(query.term)) {
358 if (!isNaN(query.term)) {
357 var files_url = pyroutes.url('repo_files',
359 var files_url = pyroutes.url('repo_files',
358 {'repo_name': templateContext.repo_name,
360 {'repo_name': templateContext.repo_name,
359 'commit_id': query.term, 'f_path': state.f_path});
361 'commit_id': query.term, 'f_path': state.f_path});
360
362
361 data.results.push({
363 data.results.push({
362 'text': _gettext('go to numeric commit'),
364 'text': _gettext('go to numeric commit'),
363 'children': [{
365 'children': [{
364 at_ref: null,
366 at_ref: null,
365 id: null,
367 id: null,
366 text: 'r{0}'.format(query.term),
368 text: 'r{0}'.format(query.term),
367 type: 'sha',
369 type: 'sha',
368 raw_id: query.term,
370 raw_id: query.term,
369 idx: query.term,
371 idx: query.term,
370 files_url: files_url,
372 files_url: files_url,
371 }]
373 }]
372 });
374 });
373 }
375 }
374 query.callback(data);
376 query.callback(data);
375 };
377 };
376
378
377 var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
379 var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
378 var formatResult = function (result, container, query) {
380 var formatResult = function (result, container, query) {
379 return formatSelect2SelectionRefs(result);
381 return formatSelect2SelectionRefs(result);
380 };
382 };
381
383
382 var formatSelection = function (data, container) {
384 var formatSelection = function (data, container) {
383 var commit_ref = data;
385 var commit_ref = data;
384
386
385 var tmpl = '';
387 var tmpl = '';
386 if (commit_ref.type === 'sha') {
388 if (commit_ref.type === 'sha') {
387 tmpl = (commit_ref.raw_id || "").substr(0,8);
389 tmpl = (commit_ref.raw_id || "").substr(0,8);
388 } else if (commit_ref.type === 'branch') {
390 } else if (commit_ref.type === 'branch') {
389 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
391 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
390 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
392 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
391 } else if (commit_ref.type === 'tag') {
393 } else if (commit_ref.type === 'tag') {
392 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
394 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
393 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
395 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
394 } else if (commit_ref.type === 'book') {
396 } else if (commit_ref.type === 'book') {
395 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
397 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
396 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
398 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
397 }
399 }
398
400
399 var idx = commit_ref.idx || 0;
401 var idx = commit_ref.idx || 0;
402 if (idx !== 0) {
400 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
403 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
404 }
401 return tmpl
405 return tmpl
402 };
406 };
403
407
404 $(targetElement).select2({
408 $(targetElement).select2({
405 dropdownAutoWidth: true,
409 dropdownAutoWidth: true,
406 width: "resolve",
410 width: "resolve",
407 containerCssClass: "drop-menu",
411 containerCssClass: "drop-menu",
408 dropdownCssClass: "drop-menu-dropdown",
412 dropdownCssClass: "drop-menu-dropdown",
409 query: function(query) {
413 query: function(query) {
410
414
411 var cachedData = cachedDataSource[cacheKey];
415 var cachedData = cachedDataSource[cacheKey];
412 if (cachedData) {
416 if (cachedData) {
413 feedRefsData(query, cachedData)
417 feedRefsData(query, cachedData)
414 } else {
418 } else {
415 loadRefsData(query)
419 loadRefsData(query)
416 }
420 }
417 },
421 },
418 initSelection: function(element, callback) {
422 initSelection: function(element, callback) {
419 callback(initialData);
423 callback(initialData);
420 },
424 },
421 formatResult: formatResult,
425 formatResult: formatResult,
422 formatSelection: formatSelection
426 formatSelection: formatSelection
423 });
427 });
424
428
425 };
429 };
426
430
427 select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
431 select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
428
432
429 $('#refs_filter').on('change', function(e) {
433 $('#refs_filter').on('change', function(e) {
430 var data = $('#refs_filter').select2('data');
434 var data = $('#refs_filter').select2('data');
431 window.location = data.files_url
435 window.location = data.files_url
432 });
436 });
433
437
434 };
438 };
435
439
436 $(document).ready(function() {
440 $(document).ready(function() {
437 timeagoActivate();
441 timeagoActivate();
438
442
439 if ($('#trimmed_message_box').height() < 50) {
443 if ($('#trimmed_message_box').height() < 50) {
440 $('#message_expand').hide();
444 $('#message_expand').hide();
441 }
445 }
442
446
443 $('#message_expand').on('click', function(e) {
447 $('#message_expand').on('click', function(e) {
444 $('#trimmed_message_box').css('max-height', 'none');
448 $('#trimmed_message_box').css('max-height', 'none');
445 $(this).hide();
449 $(this).hide();
446 });
450 });
447
451
448 if (fileSourcePage) {
452 if (fileSourcePage) {
449 initFileJS()
453 initFileJS()
450 } else {
454 } else {
451 initTreeJS()
455 initTreeJS()
452 }
456 }
453
457
454 var search_GET = "${request.GET.get('search','')}";
458 var search_GET = "${request.GET.get('search','')}";
455 if (search_GET === "1") {
459 if (search_GET === "1") {
456 NodeFilter.initFilter();
460 NodeFilter.initFilter();
457 NodeFilter.focus();
461 NodeFilter.focus();
458 }
462 }
459 });
463 });
460
464
461 </script>
465 </script>
462
466
463 </%def> No newline at end of file
467 </%def>
General Comments 0
You need to be logged in to leave comments. Login now