Show More
@@ -1196,7 +1196,7 b' class InitialsGravatar(object):' | |||
|
1196 | 1196 | </text> |
|
1197 | 1197 | </svg>""".format( |
|
1198 | 1198 | size=self.size, |
|
1199 |
f_size=self.size/ |
|
|
1199 | f_size=self.size/2.05, # scale the text inside the box nicely | |
|
1200 | 1200 | background=self.background, |
|
1201 | 1201 | text_color=self.text_color, |
|
1202 | 1202 | text=initials.upper(), |
@@ -2187,6 +2187,11 b' h3.files_location{' | |||
|
2187 | 2187 | margin-right: @padding; |
|
2188 | 2188 | } |
|
2189 | 2189 | } |
|
2190 | ||
|
2191 | .select-index-number { | |
|
2192 | margin: 0 0 0 20px; | |
|
2193 | color: @grey3; | |
|
2194 | } | |
|
2190 | 2195 | } |
|
2191 | 2196 | |
|
2192 | 2197 | .search_activate { |
@@ -1,4 +1,11 b'' | |||
|
1 | 1 | <%def name="refs(commit)"> |
|
2 | ## Build a cache of refs for selector | |
|
3 | <script> | |
|
4 | fileTreeRefs = { | |
|
5 | ||
|
6 | } | |
|
7 | </script> | |
|
8 | ||
|
2 | 9 | %if commit.merge: |
|
3 | 10 | <span class="mergetag tag"> |
|
4 | 11 | <i class="icon-merge">${_('merge')}</i> |
@@ -10,6 +17,9 b'' | |||
|
10 | 17 | <span class="booktag tag" title="${h.tooltip(_('Bookmark %s') % book)}"> |
|
11 | 18 | <a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id,_query=dict(at=book))}"><i class="icon-bookmark"></i>${h.shorter(book)}</a> |
|
12 | 19 | </span> |
|
20 | <script> | |
|
21 | fileTreeRefs["${book}"] = {raw_id: "${commit.raw_id}", type:"book"}; | |
|
22 | </script> | |
|
13 | 23 | %endfor |
|
14 | 24 | %endif |
|
15 | 25 | |
@@ -17,12 +27,18 b'' | |||
|
17 | 27 | <span class="tagtag tag" title="${h.tooltip(_('Tag %s') % tag)}"> |
|
18 | 28 | <a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id,_query=dict(at=tag))}"><i class="icon-tag"></i>${tag}</a> |
|
19 | 29 | </span> |
|
30 | <script> | |
|
31 | fileTreeRefs["${tag}"] = {raw_id: "${commit.raw_id}", type:"tag"}; | |
|
32 | </script> | |
|
20 | 33 | %endfor |
|
21 | 34 | |
|
22 | 35 | %if commit.branch: |
|
23 | 36 | <span class="branchtag tag" title="${h.tooltip(_('Branch %s') % commit.branch)}"> |
|
24 | 37 | <a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id,_query=dict(at=commit.branch))}"><i class="icon-code-fork"></i>${h.shorter(commit.branch)}</a> |
|
25 | 38 | </span> |
|
39 | <script> | |
|
40 | fileTreeRefs["${commit.branch}"] = {raw_id: "${commit.raw_id}", type:"branch"}; | |
|
41 | </script> | |
|
26 | 42 | %endif |
|
27 | 43 | |
|
28 | 44 | </%def> |
@@ -33,6 +33,8 b'' | |||
|
33 | 33 | </div> |
|
34 | 34 | </div> |
|
35 | 35 | <script> |
|
36 | var pjaxTimeout = 5000; | |
|
37 | ||
|
36 | 38 | var curState = { |
|
37 | 39 | commit_id: "${c.commit.raw_id}" |
|
38 | 40 | }; |
@@ -121,15 +123,6 b'' | |||
|
121 | 123 | var state = getState('callbacks'); |
|
122 | 124 | timeagoActivate(); |
|
123 | 125 | |
|
124 | // used for history, and switch to | |
|
125 | var initialCommitData = { | |
|
126 | id: null, | |
|
127 | text: '${_("Pick Commit")}', | |
|
128 | type: 'sha', | |
|
129 | raw_id: null, | |
|
130 | files_url: null | |
|
131 | }; | |
|
132 | ||
|
133 | 126 | if ($('#trimmed_message_box').height() < 50) { |
|
134 | 127 | $('#message_expand').hide(); |
|
135 | 128 | } |
@@ -139,13 +132,21 b'' | |||
|
139 | 132 | $(this).hide(); |
|
140 | 133 | }); |
|
141 | 134 | |
|
135 | // VIEW FOR FILE SOURCE | |
|
142 | 136 | if (fileSourcePage) { |
|
143 | 137 | // variants for with source code, not tree view |
|
144 | 138 | |
|
145 | 139 | // select code link event |
|
146 | 140 | $("#hlcode").mouseup(getSelectionLink); |
|
147 | 141 | |
|
148 | // file history select2 | |
|
142 | // file history select2 used for history, and switch to | |
|
143 | var initialCommitData = { | |
|
144 | id: null, | |
|
145 | text: '${_("Pick Commit")}', | |
|
146 | type: 'sha', | |
|
147 | raw_id: null, | |
|
148 | files_url: null | |
|
149 | }; | |
|
149 | 150 | select2FileHistorySwitcher('#diff1', initialCommitData, state); |
|
150 | 151 | |
|
151 | 152 | // show at, diff to actions handlers |
@@ -231,6 +232,7 b'' | |||
|
231 | 232 | }); |
|
232 | 233 | |
|
233 | 234 | } |
|
235 | // VIEW FOR FILE TREE BROWSER | |
|
234 | 236 | else { |
|
235 | 237 | getFilesMetadata(); |
|
236 | 238 | |
@@ -238,7 +240,83 b'' | |||
|
238 | 240 | fileBrowserListeners(state.node_list_url, state.url_base); |
|
239 | 241 | |
|
240 | 242 | // switch to widget |
|
241 | select2RefSwitcher('#refs_filter', initialCommitData); | |
|
243 | console.log(state) | |
|
244 | var initialCommitData = { | |
|
245 | at_ref: '${request.GET.get('at')}', | |
|
246 | id: null, | |
|
247 | text: '${c.commit.raw_id}', | |
|
248 | type: 'sha', | |
|
249 | raw_id: '${c.commit.raw_id}', | |
|
250 | idx: ${c.commit.idx}, | |
|
251 | files_url: null, | |
|
252 | }; | |
|
253 | ||
|
254 | var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name}); | |
|
255 | ||
|
256 | var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) { | |
|
257 | var formatResult = function (result, container, query) { | |
|
258 | return formatSelect2SelectionRefs(result); | |
|
259 | }; | |
|
260 | ||
|
261 | var formatSelection = function (data, container) { | |
|
262 | var commit_ref = data; | |
|
263 | console.log(data) | |
|
264 | ||
|
265 | var tmpl = ''; | |
|
266 | if (commit_ref.type === 'sha') { | |
|
267 | tmpl = commit_ref.raw_id.substr(0,8); | |
|
268 | } else if (commit_ref.type === 'branch') { | |
|
269 | tmpl = tmpl.concat('<i class="icon-branch"></i> '); | |
|
270 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
|
271 | } else if (commit_ref.type === 'tag') { | |
|
272 | tmpl = tmpl.concat('<i class="icon-tag"></i> '); | |
|
273 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
|
274 | } else if (commit_ref.type === 'book') { | |
|
275 | tmpl = tmpl.concat('<i class="icon-bookmark"></i> '); | |
|
276 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
|
277 | } | |
|
278 | ||
|
279 | tmpl = tmpl.concat('<span class="select-index-number">{0}</span>'.format(commit_ref.idx)); | |
|
280 | return tmpl | |
|
281 | }; | |
|
282 | ||
|
283 | $(targetElement).select2({ | |
|
284 | cachedDataSource: {}, | |
|
285 | dropdownAutoWidth: true, | |
|
286 | width: "resolve", | |
|
287 | containerCssClass: "drop-menu", | |
|
288 | dropdownCssClass: "drop-menu-dropdown", | |
|
289 | query: function(query) { | |
|
290 | var self = this; | |
|
291 | var cacheKey = '__ALL_FILE_REFS__'; | |
|
292 | var cachedData = self.cachedDataSource[cacheKey]; | |
|
293 | if (cachedData) { | |
|
294 | var data = select2RefFilterResults(query.term, cachedData); | |
|
295 | query.callback({results: data.results}); | |
|
296 | } else { | |
|
297 | $.ajax({ | |
|
298 | url: loadUrl, | |
|
299 | data: {}, | |
|
300 | dataType: 'json', | |
|
301 | type: 'GET', | |
|
302 | success: function(data) { | |
|
303 | self.cachedDataSource[cacheKey] = data; | |
|
304 | query.callback({results: data.results}); | |
|
305 | } | |
|
306 | }); | |
|
307 | } | |
|
308 | }, | |
|
309 | initSelection: function(element, callback) { | |
|
310 | callback(initialData); | |
|
311 | }, | |
|
312 | formatResult: formatResult, | |
|
313 | formatSelection: formatSelection | |
|
314 | }); | |
|
315 | ||
|
316 | }; | |
|
317 | ||
|
318 | select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData); | |
|
319 | ||
|
242 | 320 | $('#refs_filter').on('change', function(e) { |
|
243 | 321 | var data = $('#refs_filter').select2('data'); |
|
244 | 322 | curState.commit_id = data.raw_id; |
@@ -255,22 +333,9 b'' | |||
|
255 | 333 | curState.commit_id = data.commitId; |
|
256 | 334 | }); |
|
257 | 335 | |
|
258 | $('#at_rev').on("keypress", function(e) { | |
|
259 | /* ENTER PRESSED */ | |
|
260 | if (e.keyCode === 13) { | |
|
261 | var rev = $('#at_rev').val(); | |
|
262 | // explicit reload page here. with pjax entering bad input | |
|
263 | // produces not so nice results | |
|
264 | window.location = pyroutes.url('repo_files', | |
|
265 | {'repo_name': templateContext.repo_name, | |
|
266 | 'commit_id': rev, 'f_path': state.f_path}); | |
|
267 | } | |
|
268 | }); | |
|
269 | 336 | } |
|
270 | 337 | }; |
|
271 | 338 | |
|
272 | var pjaxTimeout = 5000; | |
|
273 | ||
|
274 | 339 | $(document).pjax(".pjax-link", "#pjax-container", { |
|
275 | 340 | "fragment": "#pjax-content", |
|
276 | 341 | "maxCacheLength": 1000, |
@@ -2,18 +2,19 b'' | |||
|
2 | 2 | <div id="codeblock" class="browserblock"> |
|
3 | 3 | <div class="browser-header"> |
|
4 | 4 | <div class="browser-nav"> |
|
5 | ${h.form(h.current_route_path(request), method='GET', id='at_rev_form')} | |
|
5 | ||
|
6 | 6 | <div class="info_box"> |
|
7 | ${h.hidden('refs_filter')} | |
|
7 | ||
|
8 | 8 | <div class="info_box_elem previous"> |
|
9 | 9 |
|
|
10 | 10 | </div> |
|
11 | <div class="info_box_elem">${h.text('at_rev',value=c.commit.idx)}</div> | |
|
11 | ||
|
12 | ${h.hidden('refs_filter')} | |
|
13 | ||
|
12 | 14 | <div class="info_box_elem next"> |
|
13 | 15 |
|
|
14 | 16 | </div> |
|
15 | 17 | </div> |
|
16 | ${h.end_form()} | |
|
17 | 18 | |
|
18 | 19 | <div id="search_activate_id" class="search_activate"> |
|
19 | 20 | <a class="btn btn-default" id="filter_activate" href="javascript:void(0)">${_('Search File List')}</a> |
General Comments 0
You need to be logged in to leave comments.
Login now