Show More
@@ -1,723 +1,722 b'' | |||
|
1 | 1 | /** |
|
2 | 2 | RhodeCode JS Files |
|
3 | 3 | **/ |
|
4 | 4 | |
|
5 | 5 | if (typeof console == "undefined" || typeof console.log == "undefined"){ |
|
6 | 6 | console = { log: function() {} } |
|
7 | 7 | } |
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | var str_repeat = function(i, m) { |
|
11 | 11 | for (var o = []; m > 0; o[--m] = i); |
|
12 | 12 | return o.join(''); |
|
13 | 13 | }; |
|
14 | 14 | |
|
15 | 15 | /** |
|
16 | 16 | * INJECT .format function into String |
|
17 | 17 | * Usage: "My name is {0} {1}".format("Johny","Bravo") |
|
18 | 18 | * Return "My name is Johny Bravo" |
|
19 | 19 | * Inspired by https://gist.github.com/1049426 |
|
20 | 20 | */ |
|
21 | 21 | String.prototype.format = function() { |
|
22 | 22 | |
|
23 | 23 | function format() { |
|
24 | 24 | var str = this; |
|
25 | 25 | var len = arguments.length+1; |
|
26 | 26 | var safe = undefined; |
|
27 | 27 | var arg = undefined; |
|
28 | 28 | |
|
29 | 29 | // For each {0} {1} {n...} replace with the argument in that position. If |
|
30 | 30 | // the argument is an object or an array it will be stringified to JSON. |
|
31 | 31 | for (var i=0; i < len; arg = arguments[i++]) { |
|
32 | 32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; |
|
33 | 33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); |
|
34 | 34 | } |
|
35 | 35 | return str; |
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | // Save a reference of what may already exist under the property native. |
|
39 | 39 | // Allows for doing something like: if("".format.native) { /* use native */ } |
|
40 | 40 | format.native = String.prototype.format; |
|
41 | 41 | |
|
42 | 42 | // Replace the prototype property |
|
43 | 43 | return format; |
|
44 | 44 | |
|
45 | 45 | }(); |
|
46 | 46 | |
|
47 | 47 | |
|
48 | 48 | /** |
|
49 | 49 | * SmartColorGenerator |
|
50 | 50 | * |
|
51 | 51 | *usage:: |
|
52 | 52 | * var CG = new ColorGenerator(); |
|
53 | 53 | * var col = CG.getColor(key); //returns array of RGB |
|
54 | 54 | * 'rgb({0})'.format(col.join(',') |
|
55 | 55 | * |
|
56 | 56 | * @returns {ColorGenerator} |
|
57 | 57 | */ |
|
58 | 58 | var ColorGenerator = function(){ |
|
59 | 59 | this.GOLDEN_RATIO = 0.618033988749895; |
|
60 | 60 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random |
|
61 | 61 | this.HSV_1 = 0.75;//saturation |
|
62 | 62 | this.HSV_2 = 0.95; |
|
63 | 63 | this.color; |
|
64 | 64 | this.cacheColorMap = {}; |
|
65 | 65 | }; |
|
66 | 66 | |
|
67 | 67 | ColorGenerator.prototype = { |
|
68 | 68 | getColor:function(key){ |
|
69 | 69 | if(this.cacheColorMap[key] !== undefined){ |
|
70 | 70 | return this.cacheColorMap[key]; |
|
71 | 71 | } |
|
72 | 72 | else{ |
|
73 | 73 | this.cacheColorMap[key] = this.generateColor(); |
|
74 | 74 | return this.cacheColorMap[key]; |
|
75 | 75 | } |
|
76 | 76 | }, |
|
77 | 77 | _hsvToRgb:function(h,s,v){ |
|
78 | 78 | if (s == 0.0) |
|
79 | 79 | return [v, v, v]; |
|
80 | 80 | i = parseInt(h * 6.0) |
|
81 | 81 | f = (h * 6.0) - i |
|
82 | 82 | p = v * (1.0 - s) |
|
83 | 83 | q = v * (1.0 - s * f) |
|
84 | 84 | t = v * (1.0 - s * (1.0 - f)) |
|
85 | 85 | i = i % 6 |
|
86 | 86 | if (i == 0) |
|
87 | 87 | return [v, t, p] |
|
88 | 88 | if (i == 1) |
|
89 | 89 | return [q, v, p] |
|
90 | 90 | if (i == 2) |
|
91 | 91 | return [p, v, t] |
|
92 | 92 | if (i == 3) |
|
93 | 93 | return [p, q, v] |
|
94 | 94 | if (i == 4) |
|
95 | 95 | return [t, p, v] |
|
96 | 96 | if (i == 5) |
|
97 | 97 | return [v, p, q] |
|
98 | 98 | }, |
|
99 | 99 | generateColor:function(){ |
|
100 | 100 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
|
101 | 101 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; |
|
102 | 102 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] |
|
103 | 103 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
|
104 | 104 | function toRgb(v){ |
|
105 | 105 | return ""+parseInt(v*256) |
|
106 | 106 | } |
|
107 | 107 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
|
108 | 108 | |
|
109 | 109 | } |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | 112 | |
|
113 | 113 | |
|
114 | 114 | |
|
115 | 115 | |
|
116 | 116 | /** |
|
117 | 117 | * GLOBAL YUI Shortcuts |
|
118 | 118 | */ |
|
119 | 119 | var YUC = YAHOO.util.Connect; |
|
120 | 120 | var YUD = YAHOO.util.Dom; |
|
121 | 121 | var YUE = YAHOO.util.Event; |
|
122 | 122 | var YUQ = YAHOO.util.Selector.query; |
|
123 | 123 | |
|
124 | 124 | // defines if push state is enabled for this browser ? |
|
125 | 125 | var push_state_enabled = Boolean( |
|
126 | 126 | window.history && window.history.pushState && window.history.replaceState |
|
127 | 127 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ |
|
128 | 128 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) |
|
129 | 129 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ |
|
130 | 130 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) |
|
131 | 131 | ) |
|
132 | 132 | ); |
|
133 | 133 | |
|
134 | 134 | var _run_callbacks = function(callbacks){ |
|
135 | 135 | if (callbacks !== undefined){ |
|
136 | 136 | var _l = callbacks.length; |
|
137 | 137 | for (var i=0;i<_l;i++){ |
|
138 | 138 | var func = callbacks[i]; |
|
139 | 139 | if(typeof(func)=='function'){ |
|
140 | 140 | try{ |
|
141 | 141 | func(); |
|
142 | 142 | }catch (err){}; |
|
143 | 143 | } |
|
144 | 144 | } |
|
145 | 145 | } |
|
146 | 146 | } |
|
147 | 147 | |
|
148 | 148 | /** |
|
149 | 149 | * Partial Ajax Implementation |
|
150 | 150 | * |
|
151 | 151 | * @param url: defines url to make partial request |
|
152 | 152 | * @param container: defines id of container to input partial result |
|
153 | 153 | * @param s_call: success callback function that takes o as arg |
|
154 | 154 | * o.tId |
|
155 | 155 | * o.status |
|
156 | 156 | * o.statusText |
|
157 | 157 | * o.getResponseHeader[ ] |
|
158 | 158 | * o.getAllResponseHeaders |
|
159 | 159 | * o.responseText |
|
160 | 160 | * o.responseXML |
|
161 | 161 | * o.argument |
|
162 | 162 | * @param f_call: failure callback |
|
163 | 163 | * @param args arguments |
|
164 | 164 | */ |
|
165 | 165 | function ypjax(url,container,s_call,f_call,args){ |
|
166 | 166 | var method='GET'; |
|
167 | 167 | if(args===undefined){ |
|
168 | 168 | args=null; |
|
169 | 169 | } |
|
170 | 170 | |
|
171 | 171 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR |
|
172 | 172 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
173 | 173 | |
|
174 | 174 | // wrapper of passed callback |
|
175 | 175 | var s_wrapper = (function(o){ |
|
176 | 176 | return function(o){ |
|
177 | 177 | YUD.get(container).innerHTML=o.responseText; |
|
178 | 178 | YUD.setStyle(container,'opacity','1.0'); |
|
179 | 179 | //execute the given original callback |
|
180 | 180 | if (s_call !== undefined){ |
|
181 | 181 | s_call(o); |
|
182 | 182 | } |
|
183 | 183 | } |
|
184 | 184 | })() |
|
185 | 185 | YUD.setStyle(container,'opacity','0.3'); |
|
186 | 186 | YUC.asyncRequest(method,url,{ |
|
187 | 187 | success:s_wrapper, |
|
188 | 188 | failure:function(o){ |
|
189 | 189 | console.log(o); |
|
190 | 190 | YUD.get(container).innerHTML='ERROR'; |
|
191 | 191 | YUD.setStyle(container,'opacity','1.0'); |
|
192 | 192 | YUD.setStyle(container,'color','red'); |
|
193 | 193 | } |
|
194 | 194 | },args); |
|
195 | 195 | |
|
196 | 196 | }; |
|
197 | 197 | |
|
198 | 198 | /** |
|
199 | 199 | * tooltip activate |
|
200 | 200 | */ |
|
201 | 201 | var tooltip_activate = function(){ |
|
202 | 202 | function toolTipsId(){ |
|
203 | 203 | var ids = []; |
|
204 | 204 | var tts = YUQ('.tooltip'); |
|
205 | 205 | for (var i = 0; i < tts.length; i++) { |
|
206 | 206 | // if element doesn't not have and id |
|
207 | 207 | // autogenerate one for tooltip |
|
208 | 208 | if (!tts[i].id){ |
|
209 | 209 | tts[i].id='tt'+((i*100)+tts.length); |
|
210 | 210 | } |
|
211 | 211 | ids.push(tts[i].id); |
|
212 | 212 | } |
|
213 | 213 | return ids |
|
214 | 214 | }; |
|
215 | 215 | var myToolTips = new YAHOO.widget.Tooltip("tooltip", { |
|
216 | 216 | context: [[toolTipsId()],"tl","bl",null,[0,5]], |
|
217 | 217 | monitorresize:false, |
|
218 | 218 | xyoffset :[0,0], |
|
219 | 219 | autodismissdelay:300000, |
|
220 | 220 | hidedelay:5, |
|
221 | 221 | showdelay:20, |
|
222 | 222 | }); |
|
223 | 223 | }; |
|
224 | 224 | |
|
225 | 225 | /** |
|
226 | 226 | * show more |
|
227 | 227 | */ |
|
228 | 228 | var show_more_event = function(){ |
|
229 | 229 | YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ |
|
230 | 230 | var el = e.target; |
|
231 | 231 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); |
|
232 | 232 | YUD.setStyle(el.parentNode,'display','none'); |
|
233 | 233 | }); |
|
234 | 234 | }; |
|
235 | 235 | |
|
236 | 236 | |
|
237 | 237 | /** |
|
238 | 238 | * Quick filter widget |
|
239 | 239 | * |
|
240 | 240 | * @param target: filter input target |
|
241 | 241 | * @param nodes: list of nodes in html we want to filter. |
|
242 | 242 | * @param display_element function that takes current node from nodes and |
|
243 | 243 | * does hide or show based on the node |
|
244 | 244 | * |
|
245 | 245 | */ |
|
246 | 246 | var q_filter = function(target,nodes,display_element){ |
|
247 | 247 | |
|
248 | 248 | var nodes = nodes; |
|
249 | 249 | var q_filter_field = YUD.get(target); |
|
250 | 250 | var F = YAHOO.namespace(target); |
|
251 | 251 | |
|
252 | 252 | YUE.on(q_filter_field,'click',function(){ |
|
253 | 253 | q_filter_field.value = ''; |
|
254 | 254 | }); |
|
255 | 255 | |
|
256 | 256 | YUE.on(q_filter_field,'keyup',function(e){ |
|
257 | 257 | clearTimeout(F.filterTimeout); |
|
258 | 258 | F.filterTimeout = setTimeout(F.updateFilter,600); |
|
259 | 259 | }); |
|
260 | 260 | |
|
261 | 261 | F.filterTimeout = null; |
|
262 | 262 | |
|
263 | 263 | var show_node = function(node){ |
|
264 | 264 | YUD.setStyle(node,'display','') |
|
265 | 265 | } |
|
266 | 266 | var hide_node = function(node){ |
|
267 | 267 | YUD.setStyle(node,'display','none'); |
|
268 | 268 | } |
|
269 | 269 | |
|
270 | 270 | F.updateFilter = function() { |
|
271 | 271 | // Reset timeout |
|
272 | 272 | F.filterTimeout = null; |
|
273 | 273 | |
|
274 | 274 | var obsolete = []; |
|
275 | 275 | |
|
276 | 276 | var req = q_filter_field.value.toLowerCase(); |
|
277 | 277 | |
|
278 | 278 | var l = nodes.length; |
|
279 | 279 | var i; |
|
280 | 280 | var showing = 0; |
|
281 | 281 | |
|
282 | 282 | for (i=0;i<l;i++ ){ |
|
283 | 283 | var n = nodes[i]; |
|
284 | 284 | var target_element = display_element(n) |
|
285 | 285 | if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ |
|
286 | 286 | hide_node(target_element); |
|
287 | 287 | } |
|
288 | 288 | else{ |
|
289 | 289 | show_node(target_element); |
|
290 | 290 | showing+=1; |
|
291 | 291 | } |
|
292 | 292 | } |
|
293 | 293 | |
|
294 | 294 | // if repo_count is set update the number |
|
295 | 295 | var cnt = YUD.get('repo_count'); |
|
296 | 296 | if(cnt){ |
|
297 | 297 | YUD.get('repo_count').innerHTML = showing; |
|
298 | 298 | } |
|
299 | 299 | |
|
300 | 300 | } |
|
301 | 301 | }; |
|
302 | 302 | |
|
303 | 303 | var ajaxPOST = function(url,postData,success) { |
|
304 | 304 | var sUrl = url; |
|
305 | 305 | var callback = { |
|
306 | 306 | success: success, |
|
307 | 307 | failure: function (o) { |
|
308 | 308 | alert("error"); |
|
309 | 309 | }, |
|
310 | 310 | }; |
|
311 | 311 | var postData = postData; |
|
312 | 312 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); |
|
313 | 313 | }; |
|
314 | 314 | |
|
315 | 315 | |
|
316 | 316 | /** comments **/ |
|
317 | 317 | var removeInlineForm = function(form) { |
|
318 | 318 | form.parentNode.removeChild(form); |
|
319 | 319 | }; |
|
320 | 320 | |
|
321 | 321 | var tableTr = function(cls,body){ |
|
322 | 322 | var form = document.createElement('tr'); |
|
323 | 323 | YUD.addClass(form, cls); |
|
324 | 324 | form.innerHTML = '<td class="lineno-inline new-inline"></td>'+ |
|
325 | 325 | '<td class="lineno-inline old-inline"></td>'+ |
|
326 | 326 | '<td>{0}</td>'.format(body); |
|
327 | 327 | return form; |
|
328 | 328 | }; |
|
329 | 329 | |
|
330 | 330 | var createInlineForm = function(parent_tr, f_path, line) { |
|
331 | 331 | var tmpl = YUD.get('comment-inline-form-template').innerHTML; |
|
332 | 332 | tmpl = tmpl.format(f_path, line); |
|
333 | 333 | var form = tableTr('comment-form-inline',tmpl) |
|
334 | 334 | |
|
335 | 335 | // create event for hide button |
|
336 | 336 | form = new YAHOO.util.Element(form); |
|
337 | 337 | var form_hide_button = new YAHOO.util.Element(form.getElementsByClassName('hide-inline-form')[0]); |
|
338 | 338 | form_hide_button.on('click', function(e) { |
|
339 | 339 | var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; |
|
340 | 340 | removeInlineForm(newtr); |
|
341 | 341 | YUD.removeClass(parent_tr, 'form-open'); |
|
342 | 342 | }); |
|
343 | 343 | return form |
|
344 | 344 | }; |
|
345 | 345 | var injectInlineForm = function(tr){ |
|
346 | 346 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(tr,'no-comment')){ |
|
347 | 347 | return |
|
348 | 348 | } |
|
349 | 349 | YUD.addClass(tr,'form-open'); |
|
350 | 350 | var node = tr.parentNode.parentNode.parentNode.getElementsByClassName('full_f_path')[0]; |
|
351 | 351 | var f_path = YUD.getAttribute(node,'path'); |
|
352 | 352 | var lineno = getLineNo(tr); |
|
353 | 353 | var form = createInlineForm(tr, f_path, lineno); |
|
354 | 354 | var target_tr = tr; |
|
355 | 355 | if(YUD.hasClass(YUD.getNextSibling(tr),'inline-comments')){ |
|
356 | 356 | target_tr = YUD.getNextSibling(tr); |
|
357 | 357 | } |
|
358 | 358 | YUD.insertAfter(form,target_tr); |
|
359 | 359 | YUD.get('text_'+lineno).focus(); |
|
360 | 360 | tooltip_activate(); |
|
361 | 361 | }; |
|
362 | 362 | |
|
363 | 363 | var createInlineAddButton = function(tr,label){ |
|
364 | 364 | var html = '<div class="add-comment"><span class="ui-btn">{0}</span></div>'.format(label); |
|
365 | 365 | |
|
366 | 366 | var add = new YAHOO.util.Element(tableTr('inline-comments-button',html)); |
|
367 | 367 | add.on('click', function(e) { |
|
368 | 368 | injectInlineForm(tr); |
|
369 | 369 | }); |
|
370 | 370 | return add; |
|
371 | 371 | }; |
|
372 | 372 | |
|
373 | 373 | var getLineNo = function(tr) { |
|
374 | 374 | var line; |
|
375 | 375 | var o = tr.children[0].id.split('_'); |
|
376 | 376 | var n = tr.children[1].id.split('_'); |
|
377 | 377 | |
|
378 | 378 | if (n.length >= 2) { |
|
379 | 379 | line = n[n.length-1]; |
|
380 | 380 | } else if (o.length >= 2) { |
|
381 | 381 | line = o[o.length-1]; |
|
382 | 382 | } |
|
383 | 383 | |
|
384 | 384 | return line |
|
385 | 385 | }; |
|
386 | 386 | |
|
387 | 387 | |
|
388 | 388 | var fileBrowserListeners = function(current_url, node_list_url, url_base, |
|
389 | 389 | truncated_lbl, nomatch_lbl){ |
|
390 | 390 | var current_url_branch = +"?branch=__BRANCH__"; |
|
391 | 391 | var url = url_base; |
|
392 | 392 | var node_url = node_list_url; |
|
393 | 393 | |
|
394 | 394 | YUE.on('stay_at_branch','click',function(e){ |
|
395 | 395 | if(e.target.checked){ |
|
396 | 396 | var uri = current_url_branch; |
|
397 | 397 | uri = uri.replace('__BRANCH__',e.target.value); |
|
398 | 398 | window.location = uri; |
|
399 | 399 | } |
|
400 | 400 | else{ |
|
401 | 401 | window.location = current_url; |
|
402 | 402 | } |
|
403 | 403 | }) |
|
404 | 404 | |
|
405 | 405 | var n_filter = YUD.get('node_filter'); |
|
406 | 406 | var F = YAHOO.namespace('node_filter'); |
|
407 | 407 | |
|
408 | 408 | F.filterTimeout = null; |
|
409 | 409 | var nodes = null; |
|
410 | 410 | |
|
411 | 411 | F.initFilter = function(){ |
|
412 | 412 | YUD.setStyle('node_filter_box_loading','display',''); |
|
413 | 413 | YUD.setStyle('search_activate_id','display','none'); |
|
414 | 414 | YUD.setStyle('add_node_id','display','none'); |
|
415 | 415 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
416 | 416 | YUC.asyncRequest('GET',url,{ |
|
417 | 417 | success:function(o){ |
|
418 | 418 | nodes = JSON.parse(o.responseText); |
|
419 | 419 | YUD.setStyle('node_filter_box_loading','display','none'); |
|
420 | 420 | YUD.setStyle('node_filter_box','display',''); |
|
421 | 421 | n_filter.focus(); |
|
422 | 422 | if(YUD.hasClass(n_filter,'init')){ |
|
423 | 423 | n_filter.value = ''; |
|
424 | 424 | YUD.removeClass(n_filter,'init'); |
|
425 | 425 | } |
|
426 | 426 | }, |
|
427 | 427 | failure:function(o){ |
|
428 | 428 | console.log('failed to load'); |
|
429 | 429 | } |
|
430 | 430 | },null); |
|
431 | 431 | } |
|
432 | 432 | |
|
433 | 433 | F.updateFilter = function(e) { |
|
434 | 434 | |
|
435 | 435 | return function(){ |
|
436 | 436 | // Reset timeout |
|
437 | 437 | F.filterTimeout = null; |
|
438 | 438 | var query = e.target.value.toLowerCase(); |
|
439 | 439 | var match = []; |
|
440 | 440 | var matches = 0; |
|
441 | 441 | var matches_max = 20; |
|
442 | 442 | if (query != ""){ |
|
443 | 443 | for(var i=0;i<nodes.length;i++){ |
|
444 | 444 | |
|
445 | 445 | var pos = nodes[i].name.toLowerCase().indexOf(query) |
|
446 | 446 | if(query && pos != -1){ |
|
447 | 447 | |
|
448 | 448 | matches++ |
|
449 | 449 | //show only certain amount to not kill browser |
|
450 | 450 | if (matches > matches_max){ |
|
451 | 451 | break; |
|
452 | 452 | } |
|
453 | 453 | |
|
454 | 454 | var n = nodes[i].name; |
|
455 | 455 | var t = nodes[i].type; |
|
456 | 456 | var n_hl = n.substring(0,pos) |
|
457 | 457 | +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) |
|
458 | 458 | +n.substring(pos+query.length) |
|
459 | 459 | match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,node_url.replace('__FPATH__',n),n_hl)); |
|
460 | 460 | } |
|
461 | 461 | if(match.length >= matches_max){ |
|
462 | 462 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(truncated_lbl)); |
|
463 | 463 | } |
|
464 | 464 | |
|
465 | 465 | } |
|
466 | 466 | } |
|
467 | 467 | if(query != ""){ |
|
468 | 468 | YUD.setStyle('tbody','display','none'); |
|
469 | 469 | YUD.setStyle('tbody_filtered','display',''); |
|
470 | 470 | |
|
471 | 471 | if (match.length==0){ |
|
472 | 472 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(nomatch_lbl)); |
|
473 | 473 | } |
|
474 | 474 | |
|
475 | 475 | YUD.get('tbody_filtered').innerHTML = match.join(""); |
|
476 | 476 | } |
|
477 | 477 | else{ |
|
478 | 478 | YUD.setStyle('tbody','display',''); |
|
479 | 479 | YUD.setStyle('tbody_filtered','display','none'); |
|
480 | 480 | } |
|
481 | 481 | |
|
482 | 482 | } |
|
483 | 483 | }; |
|
484 | 484 | |
|
485 | 485 | YUE.on(YUD.get('filter_activate'),'click',function(){ |
|
486 | 486 | F.initFilter(); |
|
487 | 487 | }) |
|
488 | 488 | YUE.on(n_filter,'click',function(){ |
|
489 | 489 | if(YUD.hasClass(n_filter,'init')){ |
|
490 | 490 | n_filter.value = ''; |
|
491 | 491 | YUD.removeClass(n_filter,'init'); |
|
492 | 492 | } |
|
493 | 493 | }); |
|
494 | 494 | YUE.on(n_filter,'keyup',function(e){ |
|
495 | 495 | clearTimeout(F.filterTimeout); |
|
496 | 496 | F.filterTimeout = setTimeout(F.updateFilter(e),600); |
|
497 | 497 | }); |
|
498 | 498 | }; |
|
499 | 499 | |
|
500 | 500 | |
|
501 | 501 | var initCodeMirror = function(textAreadId,resetUrl){ |
|
502 | 502 | var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ |
|
503 | 503 | mode: "null", |
|
504 | 504 | lineNumbers:true |
|
505 | 505 | }); |
|
506 | 506 | YUE.on('reset','click',function(e){ |
|
507 | 507 | window.location=resetUrl |
|
508 | 508 | }); |
|
509 | 509 | |
|
510 | 510 | YUE.on('file_enable','click',function(){ |
|
511 | 511 | YUD.setStyle('editor_container','display',''); |
|
512 | 512 | YUD.setStyle('upload_file_container','display','none'); |
|
513 | 513 | YUD.setStyle('filename_container','display',''); |
|
514 | 514 | }); |
|
515 | 515 | |
|
516 | 516 | YUE.on('upload_file_enable','click',function(){ |
|
517 | 517 | YUD.setStyle('editor_container','display','none'); |
|
518 | 518 | YUD.setStyle('upload_file_container','display',''); |
|
519 | 519 | YUD.setStyle('filename_container','display','none'); |
|
520 | 520 | }); |
|
521 | 521 | }; |
|
522 | 522 | |
|
523 | 523 | |
|
524 | 524 | |
|
525 | 525 | var getIdentNode = function(n){ |
|
526 | 526 | //iterate thru nodes untill matched interesting node ! |
|
527 | 527 | |
|
528 | 528 | if (typeof n == 'undefined'){ |
|
529 | 529 | return -1 |
|
530 | 530 | } |
|
531 | 531 | |
|
532 | 532 | if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ |
|
533 | 533 | return n |
|
534 | 534 | } |
|
535 | 535 | else{ |
|
536 | 536 | return getIdentNode(n.parentNode); |
|
537 | 537 | } |
|
538 | 538 | }; |
|
539 | 539 | |
|
540 | 540 | var getSelectionLink = function(selection_link_label) { |
|
541 | 541 | return function(){ |
|
542 | 542 | //get selection from start/to nodes |
|
543 | 543 | if (typeof window.getSelection != "undefined") { |
|
544 | 544 | s = window.getSelection(); |
|
545 | 545 | |
|
546 | 546 | from = getIdentNode(s.anchorNode); |
|
547 | 547 | till = getIdentNode(s.focusNode); |
|
548 | 548 | |
|
549 | 549 | f_int = parseInt(from.id.replace('L','')); |
|
550 | 550 | t_int = parseInt(till.id.replace('L','')); |
|
551 | 551 | |
|
552 | 552 | if (f_int > t_int){ |
|
553 | 553 | //highlight from bottom |
|
554 | 554 | offset = -35; |
|
555 | 555 | ranges = [t_int,f_int]; |
|
556 | 556 | |
|
557 | 557 | } |
|
558 | 558 | else{ |
|
559 | 559 | //highligth from top |
|
560 | 560 | offset = 35; |
|
561 | 561 | ranges = [f_int,t_int]; |
|
562 | 562 | } |
|
563 | 563 | |
|
564 | 564 | if (ranges[0] != ranges[1]){ |
|
565 | 565 | if(YUD.get('linktt') == null){ |
|
566 | 566 | hl_div = document.createElement('div'); |
|
567 | 567 | hl_div.id = 'linktt'; |
|
568 | 568 | } |
|
569 | 569 | anchor = '#L'+ranges[0]+'-'+ranges[1]; |
|
570 | 570 | hl_div.innerHTML = ''; |
|
571 | 571 | l = document.createElement('a'); |
|
572 | 572 | l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; |
|
573 | 573 | l.innerHTML = selection_link_label; |
|
574 | 574 | hl_div.appendChild(l); |
|
575 | 575 | |
|
576 | 576 | YUD.get('body').appendChild(hl_div); |
|
577 | 577 | |
|
578 | 578 | xy = YUD.getXY(till.id); |
|
579 | 579 | |
|
580 | 580 | YUD.addClass('linktt','yui-tt'); |
|
581 | 581 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); |
|
582 | 582 | YUD.setStyle('linktt','left',xy[0]+'px'); |
|
583 | 583 | YUD.setStyle('linktt','visibility','visible'); |
|
584 | 584 | } |
|
585 | 585 | else{ |
|
586 | 586 | YUD.setStyle('linktt','visibility','hidden'); |
|
587 | 587 | } |
|
588 | 588 | } |
|
589 | 589 | } |
|
590 | 590 | }; |
|
591 | 591 | |
|
592 | 592 | var deleteNotification = function(url, notification_id,callbacks){ |
|
593 | 593 | var callback = { |
|
594 | 594 | success:function(o){ |
|
595 | 595 | var obj = YUD.get(String("notification_"+notification_id)); |
|
596 | 596 | if(obj.parentNode !== undefined){ |
|
597 | 597 | obj.parentNode.removeChild(obj); |
|
598 | 598 | } |
|
599 | 599 | _run_callbacks(callbacks); |
|
600 | 600 | }, |
|
601 | 601 | failure:function(o){ |
|
602 | 602 | alert("error"); |
|
603 | 603 | }, |
|
604 | 604 | }; |
|
605 | 605 | var postData = '_method=delete'; |
|
606 | 606 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
607 | 607 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
608 | 608 | callback, postData); |
|
609 | 609 | }; |
|
610 | 610 | |
|
611 | 611 | |
|
612 | 612 | /** |
|
613 | 613 | * QUICK REPO MENU |
|
614 | 614 | */ |
|
615 | 615 | var quick_repo_menu = function(){ |
|
616 | 616 | YUE.on(YUQ('.quick_repo_menu'),'click',function(e){ |
|
617 | 617 | var menu = e.currentTarget.firstElementChild.firstElementChild; |
|
618 | 618 | if(YUD.hasClass(menu,'hidden')){ |
|
619 | 619 | YUD.addClass(e.currentTarget,'active'); |
|
620 | 620 | YUD.removeClass(menu,'hidden'); |
|
621 | 621 | }else{ |
|
622 | 622 | YUD.removeClass(e.currentTarget,'active'); |
|
623 | 623 | YUD.addClass(menu,'hidden'); |
|
624 | 624 | } |
|
625 | 625 | }) |
|
626 | 626 | }; |
|
627 | 627 | |
|
628 | 628 | |
|
629 | 629 | /** |
|
630 | 630 | * TABLE SORTING |
|
631 | 631 | */ |
|
632 | 632 | |
|
633 | 633 | // returns a node from given html; |
|
634 | 634 | var fromHTML = function(html){ |
|
635 | 635 | var _html = document.createElement('element'); |
|
636 | 636 | _html.innerHTML = html; |
|
637 | 637 | return _html; |
|
638 | 638 | } |
|
639 | 639 | var get_rev = function(node){ |
|
640 | 640 | var n = node.firstElementChild.firstElementChild; |
|
641 | 641 | |
|
642 | 642 | if (n===null){ |
|
643 | 643 | return -1 |
|
644 | 644 | } |
|
645 | 645 | else{ |
|
646 | 646 | out = n.firstElementChild.innerHTML.split(':')[0].replace('r',''); |
|
647 | 647 | return parseInt(out); |
|
648 | 648 | } |
|
649 | 649 | } |
|
650 | 650 | |
|
651 | 651 | var get_name = function(node){ |
|
652 | 652 | var name = node.firstElementChild.children[2].innerHTML; |
|
653 | 653 | return name |
|
654 | 654 | } |
|
655 | 655 | var get_group_name = function(node){ |
|
656 | 656 | var name = node.firstElementChild.children[1].innerHTML; |
|
657 | 657 | return name |
|
658 | 658 | } |
|
659 | 659 | var get_date = function(node){ |
|
660 | console.log(node.firstElementChild) | |
|
661 | 660 | var date_ = node.firstElementChild.innerHTML; |
|
662 | 661 | return date_ |
|
663 | 662 | } |
|
664 | 663 | |
|
665 | 664 | var revisionSort = function(a, b, desc, field) { |
|
666 | 665 | |
|
667 | 666 | var a_ = fromHTML(a.getData(field)); |
|
668 | 667 | var b_ = fromHTML(b.getData(field)); |
|
669 | 668 | |
|
670 | 669 | // extract revisions from string nodes |
|
671 | 670 | a_ = get_rev(a_) |
|
672 | 671 | b_ = get_rev(b_) |
|
673 | 672 | |
|
674 | 673 | var comp = YAHOO.util.Sort.compare; |
|
675 | 674 | var compState = comp(a_, b_, desc); |
|
676 | 675 | return compState; |
|
677 | 676 | }; |
|
678 | 677 | var ageSort = function(a, b, desc, field) { |
|
679 | 678 | var a_ = a.getData(field); |
|
680 | 679 | var b_ = b.getData(field); |
|
681 | 680 | |
|
682 | 681 | var comp = YAHOO.util.Sort.compare; |
|
683 | 682 | var compState = comp(a_, b_, desc); |
|
684 | 683 | return compState; |
|
685 | 684 | }; |
|
686 | 685 | |
|
687 | 686 | var nameSort = function(a, b, desc, field) { |
|
688 | 687 | var a_ = fromHTML(a.getData(field)); |
|
689 | 688 | var b_ = fromHTML(b.getData(field)); |
|
690 | 689 | |
|
691 | 690 | // extract name from table |
|
692 | 691 | a_ = get_name(a_) |
|
693 | 692 | b_ = get_name(b_) |
|
694 | 693 | |
|
695 | 694 | var comp = YAHOO.util.Sort.compare; |
|
696 | 695 | var compState = comp(a_, b_, desc); |
|
697 | 696 | return compState; |
|
698 | 697 | }; |
|
699 | 698 | |
|
700 | 699 | var groupNameSort = function(a, b, desc, field) { |
|
701 | 700 | var a_ = fromHTML(a.getData(field)); |
|
702 | 701 | var b_ = fromHTML(b.getData(field)); |
|
703 | 702 | |
|
704 | 703 | // extract name from table |
|
705 | 704 | a_ = get_group_name(a_) |
|
706 | 705 | b_ = get_group_name(b_) |
|
707 | 706 | |
|
708 | 707 | var comp = YAHOO.util.Sort.compare; |
|
709 | 708 | var compState = comp(a_, b_, desc); |
|
710 | 709 | return compState; |
|
711 | 710 | }; |
|
712 | 711 | var dateSort = function(a, b, desc, field) { |
|
713 | 712 | var a_ = fromHTML(a.getData(field)); |
|
714 | 713 | var b_ = fromHTML(b.getData(field)); |
|
715 | 714 | |
|
716 | 715 | // extract name from table |
|
717 | 716 | a_ = get_date(a_) |
|
718 | 717 | b_ = get_date(b_) |
|
719 | 718 | |
|
720 | 719 | var comp = YAHOO.util.Sort.compare; |
|
721 | 720 | var compState = comp(a_, b_, desc); |
|
722 | 721 | return compState; |
|
723 | 722 | }; No newline at end of file |
@@ -1,221 +1,220 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | <%inherit file="/base/base.html"/> |
|
4 | 4 | |
|
5 | 5 | <%def name="title()"> |
|
6 | 6 | ${c.repo_name} ${_('Changelog')} - ${c.rhodecode_name} |
|
7 | 7 | </%def> |
|
8 | 8 | |
|
9 | 9 | <%def name="breadcrumbs_links()"> |
|
10 | 10 | ${h.link_to(u'Home',h.url('/'))} |
|
11 | 11 | » |
|
12 | 12 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} |
|
13 | 13 | » |
|
14 | 14 | ${_('Changelog')} - ${_('showing ')} ${c.size if c.size <= c.total_cs else c.total_cs} ${_('out of')} ${c.total_cs} ${_('revisions')} |
|
15 | 15 | </%def> |
|
16 | 16 | |
|
17 | 17 | <%def name="page_nav()"> |
|
18 | 18 | ${self.menu('changelog')} |
|
19 | 19 | </%def> |
|
20 | 20 | |
|
21 | 21 | <%def name="main()"> |
|
22 | 22 | <div class="box"> |
|
23 | 23 | <!-- box / title --> |
|
24 | 24 | <div class="title"> |
|
25 | 25 | ${self.breadcrumbs()} |
|
26 | 26 | </div> |
|
27 | 27 | <div class="table"> |
|
28 | 28 | % if c.pagination: |
|
29 | 29 | <div id="graph"> |
|
30 | 30 | <div id="graph_nodes"> |
|
31 | 31 | <canvas id="graph_canvas"></canvas> |
|
32 | 32 | </div> |
|
33 | 33 | <div id="graph_content"> |
|
34 | 34 | <div class="container_header"> |
|
35 | 35 | ${h.form(h.url.current(),method='get')} |
|
36 | 36 | <div class="info_box" style="float:left"> |
|
37 | 37 | ${h.submit('set',_('Show'),class_="ui-btn")} |
|
38 | 38 | ${h.text('size',size=1,value=c.size)} |
|
39 | 39 | ${_('revisions')} |
|
40 | 40 | </div> |
|
41 | 41 | ${h.end_form()} |
|
42 | 42 | <div id="rev_range_container" style="display:none"></div> |
|
43 | 43 | <div style="float:right">${h.select('branch_filter',c.branch_name,c.branch_filters)}</div> |
|
44 | 44 | </div> |
|
45 | 45 | |
|
46 | 46 | %for cnt,cs in enumerate(c.pagination): |
|
47 | 47 | <div id="chg_${cnt+1}" class="container ${'tablerow%s' % (cnt%2)}"> |
|
48 | 48 | <div class="left"> |
|
49 | 49 | <div> |
|
50 | 50 | ${h.checkbox(cs.short_id,class_="changeset_range")} |
|
51 | 51 | <span class="tooltip" title="${h.age(cs.date)}"><a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id)}"><span class="changeset_id">${cs.revision}:<span class="changeset_hash">${h.short_id(cs.raw_id)}</span></span></a></span> |
|
52 | 52 | </div> |
|
53 | 53 | <div class="author"> |
|
54 | 54 | <div class="gravatar"> |
|
55 | 55 | <img alt="gravatar" src="${h.gravatar_url(h.email(cs.author),16)}"/> |
|
56 | 56 | </div> |
|
57 | 57 | <div title="${cs.author}" class="user">${h.person(cs.author)}</div> |
|
58 | 58 | </div> |
|
59 | 59 | <div class="date">${cs.date}</div> |
|
60 | 60 | </div> |
|
61 | 61 | <div class="mid"> |
|
62 | 62 | <div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message))}</div> |
|
63 | 63 | <div class="expand ${'tablerow%s' % (cnt%2)}">↓ ${_('show more')} ↓</div> |
|
64 | 64 | </div> |
|
65 | 65 | <div class="right"> |
|
66 | 66 | <div id="${cs.raw_id}_changes_info" class="changes"> |
|
67 | 67 | <span id="${cs.raw_id}" class="changed_total tooltip" title="${_('Affected number of files, click to show more details')}">${len(cs.affected_files)}</span> |
|
68 | 68 | </div> |
|
69 | 69 | %if cs.parents: |
|
70 | 70 | %for p_cs in reversed(cs.parents): |
|
71 | 71 | <div class="parent">${_('Parent')} |
|
72 | 72 | <span class="changeset_id">${p_cs.revision}:<span class="changeset_hash">${h.link_to(h.short_id(p_cs.raw_id), |
|
73 | 73 | h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}</span></span> |
|
74 | 74 | </div> |
|
75 | 75 | %endfor |
|
76 | 76 | %else: |
|
77 | 77 | <div class="parent">${_('No parents')}</div> |
|
78 | 78 | %endif |
|
79 | 79 | |
|
80 | 80 | <span class="logtags"> |
|
81 | 81 | %if len(cs.parents)>1: |
|
82 | 82 | <span class="merge">${_('merge')}</span> |
|
83 | 83 | %endif |
|
84 | 84 | %if cs.branch: |
|
85 | 85 | <span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}"> |
|
86 | 86 | ${h.link_to(cs.branch,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span> |
|
87 | 87 | %endif |
|
88 | 88 | %for tag in cs.tags: |
|
89 | 89 | <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}"> |
|
90 | 90 | ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span> |
|
91 | 91 | %endfor |
|
92 | 92 | </span> |
|
93 | 93 | </div> |
|
94 | 94 | </div> |
|
95 | 95 | |
|
96 | 96 | %endfor |
|
97 | 97 | <div class="pagination-wh pagination-left"> |
|
98 | 98 | ${c.pagination.pager('$link_previous ~2~ $link_next')} |
|
99 | 99 | </div> |
|
100 | 100 | </div> |
|
101 | 101 | </div> |
|
102 | 102 | |
|
103 | 103 | <script type="text/javascript" src="${h.url('/js/graph.js')}"></script> |
|
104 | 104 | <script type="text/javascript"> |
|
105 | 105 | YAHOO.util.Event.onDOMReady(function(){ |
|
106 | 106 | |
|
107 | 107 | //Monitor range checkboxes and build a link to changesets |
|
108 | 108 | //ranges |
|
109 | 109 | var checkboxes = YUD.getElementsByClassName('changeset_range'); |
|
110 | 110 | var url_tmpl = "${h.url('changeset_home',repo_name=c.repo_name,revision='__REVRANGE__')}"; |
|
111 | 111 | YUE.on(checkboxes,'click',function(e){ |
|
112 | 112 | var checked_checkboxes = []; |
|
113 | 113 | for (pos in checkboxes){ |
|
114 | 114 | if(checkboxes[pos].checked){ |
|
115 | 115 | checked_checkboxes.push(checkboxes[pos]); |
|
116 | 116 | } |
|
117 | 117 | } |
|
118 | 118 | if(checked_checkboxes.length>1){ |
|
119 | 119 | var rev_end = checked_checkboxes[0].name; |
|
120 | 120 | var rev_start = checked_checkboxes[checked_checkboxes.length-1].name; |
|
121 | 121 | |
|
122 | 122 | var url = url_tmpl.replace('__REVRANGE__', |
|
123 | 123 | rev_start+'...'+rev_end); |
|
124 | 124 | |
|
125 | 125 | var link = "<a href="+url+">${_('Show selected changes __S -> __E')}</a>" |
|
126 | 126 | link = link.replace('__S',rev_start); |
|
127 | 127 | link = link.replace('__E',rev_end); |
|
128 | 128 | YUD.get('rev_range_container').innerHTML = link; |
|
129 | 129 | YUD.setStyle('rev_range_container','display',''); |
|
130 | 130 | } |
|
131 | 131 | else{ |
|
132 | 132 | YUD.setStyle('rev_range_container','display','none'); |
|
133 | 133 | |
|
134 | 134 | } |
|
135 | 135 | }); |
|
136 | 136 | |
|
137 | 137 | var msgs = YUQ('.message'); |
|
138 | 138 | // get firts element height; |
|
139 | 139 | var el = YUQ('.container')[0]; |
|
140 | 140 | var row_h = el.clientHeight; |
|
141 | 141 | for(var i=0;i<msgs.length;i++){ |
|
142 | 142 | var m = msgs[i]; |
|
143 | 143 | |
|
144 | 144 | var h = m.clientHeight; |
|
145 | 145 | var pad = YUD.getStyle(m,'padding'); |
|
146 | 146 | if(h > row_h){ |
|
147 | 147 | YUD.setStyle(m.nextElementSibling,'display','block'); |
|
148 | 148 | YUD.setStyle(m.nextElementSibling,'margin-top',row_h-(h+14)+'px'); |
|
149 | 149 | YUD.setAttribute(m.nextElementSibling,'expand',h); |
|
150 | 150 | }; |
|
151 | 151 | } |
|
152 | 152 | YUE.on(YUQ('.expand'),'click',function(e){ |
|
153 | 153 | var elem = e.currentTarget.parentElement.parentElement; |
|
154 | 154 | YUD.setStyle(e.currentTarget,'display','none'); |
|
155 | 155 | YUD.setStyle(elem,'height',YUD.getAttribute(e.currentTarget,'expand')+'px'); |
|
156 | 156 | |
|
157 | 157 | //redraw the graph max_w and jsdata are global vars |
|
158 | 158 | set_canvas(max_w); |
|
159 | 159 | |
|
160 | 160 | var r = new BranchRenderer(); |
|
161 | 161 | r.render(jsdata,max_w); |
|
162 | 162 | |
|
163 | 163 | }) |
|
164 | 164 | |
|
165 | 165 | // Fetch changeset details |
|
166 | 166 | YUE.on(YUD.getElementsByClassName('changed_total'),'click',function(e){ |
|
167 | 167 | var id = e.currentTarget.id |
|
168 | 168 | var url = "${h.url('changelog_details',repo_name=c.repo_name,cs='__CS__')}" |
|
169 | 169 | var url = url.replace('__CS__',id); |
|
170 | 170 | ypjax(url,id+'_changes_info',function(){tooltip_activate()}); |
|
171 | 171 | }); |
|
172 | 172 | |
|
173 | 173 | // change branch filter |
|
174 | 174 | YUE.on(YUD.get('branch_filter'),'change',function(e){ |
|
175 | 175 | var selected_branch = e.currentTarget.options[e.currentTarget.selectedIndex].value; |
|
176 | console.log(selected_branch); | |
|
177 | 176 | var url_main = "${h.url('changelog_home',repo_name=c.repo_name)}"; |
|
178 | 177 | var url = "${h.url('changelog_home',repo_name=c.repo_name,branch='__BRANCH__')}"; |
|
179 | 178 | var url = url.replace('__BRANCH__',selected_branch); |
|
180 | 179 | if(selected_branch != ''){ |
|
181 | 180 | window.location = url; |
|
182 | 181 | }else{ |
|
183 | 182 | window.location = url_main; |
|
184 | 183 | } |
|
185 | 184 | |
|
186 | 185 | }); |
|
187 | 186 | |
|
188 | 187 | function set_canvas(heads) { |
|
189 | 188 | var c = document.getElementById('graph_nodes'); |
|
190 | 189 | var t = document.getElementById('graph_content'); |
|
191 | 190 | canvas = document.getElementById('graph_canvas'); |
|
192 | 191 | var div_h = t.clientHeight; |
|
193 | 192 | c.style.height=div_h+'px'; |
|
194 | 193 | canvas.setAttribute('height',div_h); |
|
195 | 194 | c.style.height=max_w+'px'; |
|
196 | 195 | canvas.setAttribute('width',max_w); |
|
197 | 196 | }; |
|
198 | 197 | var heads = 1; |
|
199 | 198 | var max_heads = 0; |
|
200 | 199 | var jsdata = ${c.jsdata|n}; |
|
201 | 200 | |
|
202 | 201 | for( var i=0;i<jsdata.length;i++){ |
|
203 | 202 | var m = Math.max.apply(Math, jsdata[i][1]); |
|
204 | 203 | if (m>max_heads){ |
|
205 | 204 | max_heads = m; |
|
206 | 205 | } |
|
207 | 206 | } |
|
208 | 207 | var max_w = Math.max(100,max_heads*25); |
|
209 | 208 | set_canvas(max_w); |
|
210 | 209 | |
|
211 | 210 | var r = new BranchRenderer(); |
|
212 | 211 | r.render(jsdata,max_w); |
|
213 | 212 | |
|
214 | 213 | }); |
|
215 | 214 | </script> |
|
216 | 215 | %else: |
|
217 | 216 | ${_('There are no changes yet')} |
|
218 | 217 | %endif |
|
219 | 218 | </div> |
|
220 | 219 | </div> |
|
221 | 220 | </%def> |
@@ -1,193 +1,189 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | <%inherit file="/base/base.html"/> |
|
4 | 4 | |
|
5 | 5 | <%def name="title()"> |
|
6 | 6 | ${c.repo_name} ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} - ${c.rhodecode_name} |
|
7 | 7 | </%def> |
|
8 | 8 | |
|
9 | 9 | <%def name="breadcrumbs_links()"> |
|
10 | 10 | ${h.link_to(u'Home',h.url('/'))} |
|
11 | 11 | » |
|
12 | 12 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} |
|
13 | 13 | » |
|
14 | 14 | ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} |
|
15 | 15 | </%def> |
|
16 | 16 | |
|
17 | 17 | <%def name="page_nav()"> |
|
18 | 18 | ${self.menu('changelog')} |
|
19 | 19 | </%def> |
|
20 | 20 | |
|
21 | 21 | <%def name="main()"> |
|
22 | 22 | <div class="box"> |
|
23 | 23 | <!-- box / title --> |
|
24 | 24 | <div class="title"> |
|
25 | 25 | ${self.breadcrumbs()} |
|
26 | 26 | </div> |
|
27 | 27 | <div class="table"> |
|
28 | 28 | <div class="diffblock"> |
|
29 | 29 | <div class="code-header"> |
|
30 | 30 | <div class="date"> |
|
31 | 31 | R${c.changeset.revision}:${h.link_to(h.short_id(c.changeset.raw_id),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))} |
|
32 | 32 | ${c.changeset.date}</div> |
|
33 | 33 | <div class="diff-actions"> |
|
34 | 34 | <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show')}" title="${_('raw diff')}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a> |
|
35 | 35 | <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download')}" title="${_('download diff')}"><img class="icon" src="${h.url('/images/icons/page_white_get.png')}"/></a> |
|
36 | 36 | ${c.ignorews_url()} |
|
37 | 37 | ${c.context_url()} |
|
38 | 38 | </div> |
|
39 | 39 | <div class="comments-number" style="float:right;padding-right:5px">${len(c.comments)} comment(s) (${c.inline_cnt} ${_('inline')})</div> |
|
40 | 40 | </div> |
|
41 | 41 | </div> |
|
42 | 42 | <div id="changeset_content"> |
|
43 | 43 | <div class="container"> |
|
44 | 44 | <div class="left"> |
|
45 | 45 | <div class="author"> |
|
46 | 46 | <div class="gravatar"> |
|
47 | 47 | <img alt="gravatar" src="${h.gravatar_url(h.email(c.changeset.author),20)}"/> |
|
48 | 48 | </div> |
|
49 | 49 | <span>${h.person(c.changeset.author)}</span><br/> |
|
50 | 50 | <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/> |
|
51 | 51 | </div> |
|
52 | 52 | <div class="message">${h.urlify_commit(h.wrap_paragraphs(c.changeset.message))}</div> |
|
53 | 53 | </div> |
|
54 | 54 | <div class="right"> |
|
55 | 55 | <div class="changes"> |
|
56 | 56 | % if len(c.changeset.affected_files) <= c.affected_files_cut_off: |
|
57 | 57 | <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span> |
|
58 | 58 | <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span> |
|
59 | 59 | <span class="added" title="${_('added')}">${len(c.changeset.added)}</span> |
|
60 | 60 | % else: |
|
61 | 61 | <span class="removed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
62 | 62 | <span class="changed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
63 | 63 | <span class="added" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
64 | 64 | % endif |
|
65 | 65 | </div> |
|
66 | 66 | |
|
67 | 67 | %if c.changeset.parents: |
|
68 | 68 | %for p_cs in reversed(c.changeset.parents): |
|
69 | 69 | <div class="parent">${_('Parent')} |
|
70 | 70 | <span class="changeset_id">${p_cs.revision}:<span class="changeset_hash">${h.link_to(h.short_id(p_cs.raw_id), |
|
71 | 71 | h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}</span></span> |
|
72 | 72 | </div> |
|
73 | 73 | %endfor |
|
74 | 74 | %else: |
|
75 | 75 | <div class="parent">${_('No parents')}</div> |
|
76 | 76 | %endif |
|
77 | 77 | <span class="logtags"> |
|
78 | 78 | %if len(c.changeset.parents)>1: |
|
79 | 79 | <span class="merge">${_('merge')}</span> |
|
80 | 80 | %endif |
|
81 | 81 | <span class="branchtag" title="${'%s %s' % (_('branch'),c.changeset.branch)}"> |
|
82 | 82 | ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> |
|
83 | 83 | %for tag in c.changeset.tags: |
|
84 | 84 | <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}"> |
|
85 | 85 | ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> |
|
86 | 86 | %endfor |
|
87 | 87 | </span> |
|
88 | 88 | </div> |
|
89 | 89 | </div> |
|
90 | 90 | <span> |
|
91 | 91 | ${_('%s files affected with %s additions and %s deletions:') % (len(c.changeset.affected_files),c.lines_added,c.lines_deleted)} |
|
92 | 92 | </span> |
|
93 | 93 | <div class="cs_files"> |
|
94 | 94 | %for change,filenode,diff,cs1,cs2,stat in c.changes: |
|
95 | 95 | <div class="cs_${change}"> |
|
96 | 96 | <div class="node"> |
|
97 | 97 | %if change != 'removed': |
|
98 | 98 | ${h.link_to(h.safe_unicode(filenode.path),c.anchor_url(filenode.changeset.raw_id,filenode.path)+"_target")} |
|
99 | 99 | %else: |
|
100 | 100 | ${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor=h.FID('',filenode.path)))} |
|
101 | 101 | %endif |
|
102 | 102 | </div> |
|
103 | 103 | <div class="changes">${h.fancy_file_stats(stat)}</div> |
|
104 | 104 | </div> |
|
105 | 105 | %endfor |
|
106 | 106 | % if c.cut_off: |
|
107 | 107 | ${_('Changeset was too big and was cut off...')} |
|
108 | 108 | % endif |
|
109 | 109 | </div> |
|
110 | 110 | </div> |
|
111 | 111 | |
|
112 | 112 | </div> |
|
113 | 113 | |
|
114 | 114 | ## diff block |
|
115 | 115 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> |
|
116 | 116 | ${diff_block.diff_block(c.changes)} |
|
117 | 117 | |
|
118 | 118 | ## template for inline comment form |
|
119 | 119 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
120 | 120 | ${comment.comment_inline_form(c.changeset)} |
|
121 | 121 | |
|
122 | 122 | ${comment.comments(c.changeset)} |
|
123 | 123 | |
|
124 | 124 | <script type="text/javascript"> |
|
125 | 125 | var deleteComment = function(comment_id){ |
|
126 | 126 | |
|
127 | 127 | var url = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}".replace('__COMMENT_ID__',comment_id); |
|
128 | 128 | var postData = '_method=delete'; |
|
129 | 129 | var success = function(o){ |
|
130 | 130 | var n = YUD.get('comment-'+comment_id); |
|
131 | 131 | n.parentNode.removeChild(n); |
|
132 | 132 | } |
|
133 | 133 | ajaxPOST(url,postData,success); |
|
134 | 134 | } |
|
135 | 135 | |
|
136 | 136 | YUE.onDOMReady(function(){ |
|
137 | 137 | |
|
138 | 138 | YUE.on(YUQ('.show-inline-comments'),'change',function(e){ |
|
139 | 139 | var show = 'none'; |
|
140 | 140 | var target = e.currentTarget; |
|
141 | console.log(target); | |
|
142 | 141 | if(target.checked){ |
|
143 | 142 | var show = '' |
|
144 | 143 | } |
|
145 | console.log('aa') | |
|
146 | 144 | var boxid = YUD.getAttribute(target,'id_for'); |
|
147 | console.log(boxid); | |
|
148 | 145 | var comments = YUQ('#{0} .inline-comments'.format(boxid)); |
|
149 | console.log(comments) | |
|
150 | 146 | for(c in comments){ |
|
151 | 147 | YUD.setStyle(comments[c],'display',show); |
|
152 | 148 | } |
|
153 | 149 | var btns = YUQ('#{0} .inline-comments-button'.format(boxid)); |
|
154 | 150 | for(c in btns){ |
|
155 | 151 | YUD.setStyle(btns[c],'display',show); |
|
156 | 152 | } |
|
157 | 153 | }) |
|
158 | 154 | |
|
159 | 155 | YUE.on(YUQ('.line'),'click',function(e){ |
|
160 | 156 | var tr = e.currentTarget; |
|
161 | 157 | injectInlineForm(tr); |
|
162 | 158 | }); |
|
163 | 159 | |
|
164 | 160 | // inject comments into they proper positions |
|
165 | 161 | var file_comments = YUQ('.inline-comment-placeholder'); |
|
166 | 162 | |
|
167 | 163 | for (f in file_comments){ |
|
168 | 164 | var box = file_comments[f]; |
|
169 | 165 | var inlines = box.children; |
|
170 | 166 | for(var i=0; i<inlines.length; i++){ |
|
171 | 167 | try{ |
|
172 | 168 | |
|
173 | 169 | var inline = inlines[i]; |
|
174 | 170 | var lineno = YUD.getAttribute(inlines[i],'line'); |
|
175 | 171 | var lineid = "{0}_{1}".format(YUD.getAttribute(inline,'target_id'),lineno); |
|
176 | 172 | var target_line = YUD.get(lineid); |
|
177 | 173 | |
|
178 | 174 | var add = createInlineAddButton(target_line.parentNode,'${_("add another comment")}'); |
|
179 | 175 | YUD.insertAfter(add,target_line.parentNode); |
|
180 | 176 | |
|
181 | 177 | var comment = new YAHOO.util.Element(tableTr('inline-comments',inline.innerHTML)) |
|
182 | 178 | YUD.insertAfter(comment,target_line.parentNode); |
|
183 | 179 | }catch(e){ |
|
184 | 180 | console.log(e); |
|
185 | 181 | } |
|
186 | 182 | } |
|
187 | 183 | } |
|
188 | 184 | }) |
|
189 | 185 | |
|
190 | 186 | </script> |
|
191 | 187 | |
|
192 | 188 | </div> |
|
193 | 189 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now