##// END OF EJS Templates
fixed comment addition and deletion functionality on IE9
Dies Koper -
r2723:04aa0ea1 beta
parent child Browse files
Show More
@@ -1,1740 +1,1740
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 String.prototype.strip = function(char) {
48 48 if(char === undefined){
49 49 char = '\\s';
50 50 }
51 51 return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), '');
52 52 }
53 53 String.prototype.lstrip = function(char) {
54 54 if(char === undefined){
55 55 char = '\\s';
56 56 }
57 57 return this.replace(new RegExp('^'+char+'+'),'');
58 58 }
59 59 String.prototype.rstrip = function(char) {
60 60 if(char === undefined){
61 61 char = '\\s';
62 62 }
63 63 return this.replace(new RegExp(''+char+'+$'),'');
64 64 }
65 65
66 66
67 67 if(!Array.prototype.indexOf) {
68 68 Array.prototype.indexOf = function(needle) {
69 69 for(var i = 0; i < this.length; i++) {
70 70 if(this[i] === needle) {
71 71 return i;
72 72 }
73 73 }
74 74 return -1;
75 75 };
76 76 }
77 77
78 78 // IE(CRAP) doesn't support previousElementSibling
79 79 var prevElementSibling = function( el ) {
80 80 if( el.previousElementSibling ) {
81 81 return el.previousElementSibling;
82 82 } else {
83 83 while( el = el.previousSibling ) {
84 84 if( el.nodeType === 1 ) return el;
85 85 }
86 86 }
87 87 }
88 88
89 89
90 90
91 91
92 92 /**
93 93 * SmartColorGenerator
94 94 *
95 95 *usage::
96 96 * var CG = new ColorGenerator();
97 97 * var col = CG.getColor(key); //returns array of RGB
98 98 * 'rgb({0})'.format(col.join(',')
99 99 *
100 100 * @returns {ColorGenerator}
101 101 */
102 102 var ColorGenerator = function(){
103 103 this.GOLDEN_RATIO = 0.618033988749895;
104 104 this.CURRENT_RATIO = 0.22717784590367374 // this can be random
105 105 this.HSV_1 = 0.75;//saturation
106 106 this.HSV_2 = 0.95;
107 107 this.color;
108 108 this.cacheColorMap = {};
109 109 };
110 110
111 111 ColorGenerator.prototype = {
112 112 getColor:function(key){
113 113 if(this.cacheColorMap[key] !== undefined){
114 114 return this.cacheColorMap[key];
115 115 }
116 116 else{
117 117 this.cacheColorMap[key] = this.generateColor();
118 118 return this.cacheColorMap[key];
119 119 }
120 120 },
121 121 _hsvToRgb:function(h,s,v){
122 122 if (s == 0.0)
123 123 return [v, v, v];
124 124 i = parseInt(h * 6.0)
125 125 f = (h * 6.0) - i
126 126 p = v * (1.0 - s)
127 127 q = v * (1.0 - s * f)
128 128 t = v * (1.0 - s * (1.0 - f))
129 129 i = i % 6
130 130 if (i == 0)
131 131 return [v, t, p]
132 132 if (i == 1)
133 133 return [q, v, p]
134 134 if (i == 2)
135 135 return [p, v, t]
136 136 if (i == 3)
137 137 return [p, q, v]
138 138 if (i == 4)
139 139 return [t, p, v]
140 140 if (i == 5)
141 141 return [v, p, q]
142 142 },
143 143 generateColor:function(){
144 144 this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO;
145 145 this.CURRENT_RATIO = this.CURRENT_RATIO %= 1;
146 146 HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2]
147 147 RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]);
148 148 function toRgb(v){
149 149 return ""+parseInt(v*256)
150 150 }
151 151 return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])];
152 152
153 153 }
154 154 }
155 155
156 156
157 157
158 158
159 159
160 160 /**
161 161 * GLOBAL YUI Shortcuts
162 162 */
163 163 var YUC = YAHOO.util.Connect;
164 164 var YUD = YAHOO.util.Dom;
165 165 var YUE = YAHOO.util.Event;
166 166 var YUQ = YAHOO.util.Selector.query;
167 167
168 168 // defines if push state is enabled for this browser ?
169 169 var push_state_enabled = Boolean(
170 170 window.history && window.history.pushState && window.history.replaceState
171 171 && !( /* disable for versions of iOS before version 4.3 (8F190) */
172 172 (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent)
173 173 /* disable for the mercury iOS browser, or at least older versions of the webkit engine */
174 174 || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent)
175 175 )
176 176 );
177 177
178 178 var _run_callbacks = function(callbacks){
179 179 if (callbacks !== undefined){
180 180 var _l = callbacks.length;
181 181 for (var i=0;i<_l;i++){
182 182 var func = callbacks[i];
183 183 if(typeof(func)=='function'){
184 184 try{
185 185 func();
186 186 }catch (err){};
187 187 }
188 188 }
189 189 }
190 190 }
191 191
192 192 /**
193 193 * Partial Ajax Implementation
194 194 *
195 195 * @param url: defines url to make partial request
196 196 * @param container: defines id of container to input partial result
197 197 * @param s_call: success callback function that takes o as arg
198 198 * o.tId
199 199 * o.status
200 200 * o.statusText
201 201 * o.getResponseHeader[ ]
202 202 * o.getAllResponseHeaders
203 203 * o.responseText
204 204 * o.responseXML
205 205 * o.argument
206 206 * @param f_call: failure callback
207 207 * @param args arguments
208 208 */
209 209 function ypjax(url,container,s_call,f_call,args){
210 210 var method='GET';
211 211 if(args===undefined){
212 212 args=null;
213 213 }
214 214
215 215 // Set special header for partial ajax == HTTP_X_PARTIAL_XHR
216 216 YUC.initHeader('X-PARTIAL-XHR',true);
217 217
218 218 // wrapper of passed callback
219 219 var s_wrapper = (function(o){
220 220 return function(o){
221 221 YUD.get(container).innerHTML=o.responseText;
222 222 YUD.setStyle(container,'opacity','1.0');
223 223 //execute the given original callback
224 224 if (s_call !== undefined){
225 225 s_call(o);
226 226 }
227 227 }
228 228 })()
229 229 YUD.setStyle(container,'opacity','0.3');
230 230 YUC.asyncRequest(method,url,{
231 231 success:s_wrapper,
232 232 failure:function(o){
233 233 console.log(o);
234 234 YUD.get(container).innerHTML='<span class="error_red">ERROR: {0}</span>'.format(o.status);
235 235 YUD.setStyle(container,'opacity','1.0');
236 236 },
237 237 cache:false
238 238 },args);
239 239
240 240 };
241 241
242 242 var ajaxPOST = function(url,postData,success) {
243 243 // Set special header for ajax == HTTP_X_PARTIAL_XHR
244 244 YUC.initHeader('X-PARTIAL-XHR',true);
245 245
246 246 var toQueryString = function(o) {
247 247 if(typeof o !== 'object') {
248 248 return false;
249 249 }
250 250 var _p, _qs = [];
251 251 for(_p in o) {
252 252 _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p]));
253 253 }
254 254 return _qs.join('&');
255 255 };
256 256
257 257 var sUrl = url;
258 258 var callback = {
259 259 success: success,
260 260 failure: function (o) {
261 261 alert("error");
262 262 },
263 263 };
264 264 var postData = toQueryString(postData);
265 265 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
266 266 return request;
267 267 };
268 268
269 269
270 270 /**
271 271 * tooltip activate
272 272 */
273 273 var tooltip_activate = function(){
274 274 function toolTipsId(){
275 275 var ids = [];
276 276 var tts = YUQ('.tooltip');
277 277 for (var i = 0; i < tts.length; i++) {
278 278 // if element doesn't not have and id
279 279 // autogenerate one for tooltip
280 280 if (!tts[i].id){
281 281 tts[i].id='tt'+((i*100)+tts.length);
282 282 }
283 283 ids.push(tts[i].id);
284 284 }
285 285 return ids
286 286 };
287 287 var myToolTips = new YAHOO.widget.Tooltip("tooltip", {
288 288 context: [[toolTipsId()],"tl","bl",null,[0,5]],
289 289 monitorresize:false,
290 290 xyoffset :[0,0],
291 291 autodismissdelay:300000,
292 292 hidedelay:5,
293 293 showdelay:20,
294 294 });
295 295 };
296 296
297 297 /**
298 298 * show more
299 299 */
300 300 var show_more_event = function(){
301 301 YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
302 302 var el = e.target;
303 303 YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
304 304 YUD.setStyle(el.parentNode,'display','none');
305 305 });
306 306 };
307 307
308 308
309 309 /**
310 310 * Quick filter widget
311 311 *
312 312 * @param target: filter input target
313 313 * @param nodes: list of nodes in html we want to filter.
314 314 * @param display_element function that takes current node from nodes and
315 315 * does hide or show based on the node
316 316 *
317 317 */
318 318 var q_filter = function(target,nodes,display_element){
319 319
320 320 var nodes = nodes;
321 321 var q_filter_field = YUD.get(target);
322 322 var F = YAHOO.namespace(target);
323 323
324 324 YUE.on(q_filter_field,'click',function(){
325 325 q_filter_field.value = '';
326 326 });
327 327
328 328 YUE.on(q_filter_field,'keyup',function(e){
329 329 clearTimeout(F.filterTimeout);
330 330 F.filterTimeout = setTimeout(F.updateFilter,600);
331 331 });
332 332
333 333 F.filterTimeout = null;
334 334
335 335 var show_node = function(node){
336 336 YUD.setStyle(node,'display','')
337 337 }
338 338 var hide_node = function(node){
339 339 YUD.setStyle(node,'display','none');
340 340 }
341 341
342 342 F.updateFilter = function() {
343 343 // Reset timeout
344 344 F.filterTimeout = null;
345 345
346 346 var obsolete = [];
347 347
348 348 var req = q_filter_field.value.toLowerCase();
349 349
350 350 var l = nodes.length;
351 351 var i;
352 352 var showing = 0;
353 353
354 354 for (i=0;i<l;i++ ){
355 355 var n = nodes[i];
356 356 var target_element = display_element(n)
357 357 if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){
358 358 hide_node(target_element);
359 359 }
360 360 else{
361 361 show_node(target_element);
362 362 showing+=1;
363 363 }
364 364 }
365 365
366 366 // if repo_count is set update the number
367 367 var cnt = YUD.get('repo_count');
368 368 if(cnt){
369 369 YUD.get('repo_count').innerHTML = showing;
370 370 }
371 371
372 372 }
373 373 };
374 374
375 375 var tableTr = function(cls,body){
376 376 var tr = document.createElement('tr');
377 377 YUD.addClass(tr, cls);
378 378
379 379
380 380 var cont = new YAHOO.util.Element(body);
381 381 var comment_id = fromHTML(body).children[0].id.split('comment-')[1];
382 382 tr.id = 'comment-tr-{0}'.format(comment_id);
383 383 tr.innerHTML = '<td class="lineno-inline new-inline"></td>'+
384 384 '<td class="lineno-inline old-inline"></td>'+
385 385 '<td>{0}</td>'.format(body);
386 386 return tr;
387 387 };
388 388
389 389 /** comments **/
390 390 var removeInlineForm = function(form) {
391 391 form.parentNode.removeChild(form);
392 392 };
393 393
394 394 var createInlineForm = function(parent_tr, f_path, line) {
395 395 var tmpl = YUD.get('comment-inline-form-template').innerHTML;
396 396 tmpl = tmpl.format(f_path, line);
397 397 var form = tableTr('comment-form-inline',tmpl)
398 398
399 399 // create event for hide button
400 400 form = new YAHOO.util.Element(form);
401 var form_hide_button = new YAHOO.util.Element(form.getElementsByClassName('hide-inline-form')[0]);
401 var form_hide_button = new YAHOO.util.Element(YUD.getElementsByClassName('hide-inline-form',null,form)[0]);
402 402 form_hide_button.on('click', function(e) {
403 403 var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode;
404 404 if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){
405 405 YUD.setStyle(newtr.nextElementSibling,'display','');
406 406 }
407 407 removeInlineForm(newtr);
408 408 YUD.removeClass(parent_tr, 'form-open');
409 409
410 410 });
411 411
412 412 return form
413 413 };
414 414
415 415 /**
416 416 * Inject inline comment for on given TR this tr should be always an .line
417 417 * tr containing the line. Code will detect comment, and always put the comment
418 418 * block at the very bottom
419 419 */
420 420 var injectInlineForm = function(tr){
421 421 if(!YUD.hasClass(tr, 'line')){
422 422 return
423 423 }
424 424 var submit_url = AJAX_COMMENT_URL;
425 var _td = tr.getElementsByClassName('code')[0];
425 var _td = YUD.getElementsByClassName('code',null,tr)[0];
426 426 if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){
427 427 return
428 428 }
429 429 YUD.addClass(tr,'form-open');
430 var node = tr.parentNode.parentNode.parentNode.getElementsByClassName('full_f_path')[0];
430 var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0];
431 431 var f_path = YUD.getAttribute(node,'path');
432 432 var lineno = getLineNo(tr);
433 433 var form = createInlineForm(tr, f_path, lineno, submit_url);
434 434
435 435 var parent = tr;
436 436 while (1){
437 437 var n = parent.nextElementSibling;
438 438 // next element are comments !
439 439 if(YUD.hasClass(n,'inline-comments')){
440 440 parent = n;
441 441 }
442 442 else{
443 443 break;
444 444 }
445 445 }
446 446 YUD.insertAfter(form,parent);
447 447
448 448 var f = YUD.get(form);
449 449
450 var overlay = f.getElementsByClassName('overlay')[0];
451 var _form = f.getElementsByClassName('inline-form')[0];
450 var overlay = YUD.getElementsByClassName('overlay',null,f)[0];
451 var _form = YUD.getElementsByClassName('inline-form',null,f)[0];
452 452
453 453 form.on('submit',function(e){
454 454 YUE.preventDefault(e);
455 455
456 456 //ajax submit
457 457 var text = YUD.get('text_'+lineno).value;
458 458 var postData = {
459 459 'text':text,
460 460 'f_path':f_path,
461 461 'line':lineno
462 462 };
463 463
464 464 if(lineno === undefined){
465 465 alert('missing line !');
466 466 return
467 467 }
468 468 if(f_path === undefined){
469 469 alert('missing file path !');
470 470 return
471 471 }
472 472
473 473 if(text == ""){
474 474 return
475 475 }
476 476
477 477 var success = function(o){
478 478 YUD.removeClass(tr, 'form-open');
479 479 removeInlineForm(f);
480 480 var json_data = JSON.parse(o.responseText);
481 481 renderInlineComment(json_data);
482 482 };
483 483
484 484 if (YUD.hasClass(overlay,'overlay')){
485 485 var w = _form.offsetWidth;
486 486 var h = _form.offsetHeight;
487 487 YUD.setStyle(overlay,'width',w+'px');
488 488 YUD.setStyle(overlay,'height',h+'px');
489 489 }
490 490 YUD.addClass(overlay, 'submitting');
491 491
492 492 ajaxPOST(submit_url, postData, success);
493 493 });
494 494
495 495 setTimeout(function(){
496 496 // callbacks
497 497 tooltip_activate();
498 498 MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno,
499 499 _USERS_AC_DATA, _GROUPS_AC_DATA);
500 500 var _e = YUD.get('text_'+lineno);
501 501 if(_e){
502 502 _e.focus();
503 503 }
504 504 },10)
505 505 };
506 506
507 507 var deleteComment = function(comment_id){
508 508 var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id);
509 509 var postData = {'_method':'delete'};
510 510 var success = function(o){
511 511 var n = YUD.get('comment-tr-'+comment_id);
512 512 var root = prevElementSibling(prevElementSibling(n));
513 513 n.parentNode.removeChild(n);
514 514
515 515 // scann nodes, and attach add button to last one
516 516 placeAddButton(root);
517 517 }
518 518 ajaxPOST(url,postData,success);
519 519 }
520 520
521 521 var updateReviewers = function(reviewers_ids){
522 522 var url = AJAX_UPDATE_PULLREQUEST;
523 523 var postData = {'_method':'put',
524 524 'reviewers_ids': reviewers_ids};
525 525 var success = function(o){
526 526 window.location.reload();
527 527 }
528 528 ajaxPOST(url,postData,success);
529 529 }
530 530
531 531 var createInlineAddButton = function(tr){
532 532
533 533 var label = TRANSLATION_MAP['add another comment'];
534 534
535 535 var html_el = document.createElement('div');
536 536 YUD.addClass(html_el, 'add-comment');
537 537 html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label);
538 538
539 539 var add = new YAHOO.util.Element(html_el);
540 540 add.on('click', function(e) {
541 541 injectInlineForm(tr);
542 542 });
543 543 return add;
544 544 };
545 545
546 546 var getLineNo = function(tr) {
547 547 var line;
548 548 var o = tr.children[0].id.split('_');
549 549 var n = tr.children[1].id.split('_');
550 550
551 551 if (n.length >= 2) {
552 552 line = n[n.length-1];
553 553 } else if (o.length >= 2) {
554 554 line = o[o.length-1];
555 555 }
556 556
557 557 return line
558 558 };
559 559
560 560 var placeAddButton = function(target_tr){
561 561 if(!target_tr){
562 562 return
563 563 }
564 564 var last_node = target_tr;
565 565 //scann
566 566 while (1){
567 567 var n = last_node.nextElementSibling;
568 568 // next element are comments !
569 569 if(YUD.hasClass(n,'inline-comments')){
570 570 last_node = n;
571 //also remove the comment button from previos
572 var comment_add_buttons = last_node.getElementsByClassName('add-comment');
571 //also remove the comment button from previous
572 var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node);
573 573 for(var i=0;i<comment_add_buttons.length;i++){
574 574 var b = comment_add_buttons[i];
575 575 b.parentNode.removeChild(b);
576 576 }
577 577 }
578 578 else{
579 579 break;
580 580 }
581 581 }
582 582
583 583 var add = createInlineAddButton(target_tr);
584 584 // get the comment div
585 var comment_block = last_node.getElementsByClassName('comment')[0];
585 var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0];
586 586 // attach add button
587 587 YUD.insertAfter(add,comment_block);
588 588 }
589 589
590 590 /**
591 591 * Places the inline comment into the changeset block in proper line position
592 592 */
593 593 var placeInline = function(target_container,lineno,html){
594 594 var lineid = "{0}_{1}".format(target_container,lineno);
595 595 var target_line = YUD.get(lineid);
596 596 var comment = new YAHOO.util.Element(tableTr('inline-comments',html))
597 597
598 598 // check if there are comments already !
599 599 var parent = target_line.parentNode;
600 600 var root_parent = parent;
601 601 while (1){
602 602 var n = parent.nextElementSibling;
603 603 // next element are comments !
604 604 if(YUD.hasClass(n,'inline-comments')){
605 605 parent = n;
606 606 }
607 607 else{
608 608 break;
609 609 }
610 610 }
611 611 // put in the comment at the bottom
612 612 YUD.insertAfter(comment,parent);
613 613
614 614 // scann nodes, and attach add button to last one
615 615 placeAddButton(root_parent);
616 616
617 617 return target_line;
618 618 }
619 619
620 620 /**
621 621 * make a single inline comment and place it inside
622 622 */
623 623 var renderInlineComment = function(json_data){
624 624 try{
625 625 var html = json_data['rendered_text'];
626 626 var lineno = json_data['line_no'];
627 627 var target_id = json_data['target_id'];
628 628 placeInline(target_id, lineno, html);
629 629
630 630 }catch(e){
631 631 console.log(e);
632 632 }
633 633 }
634 634
635 635 /**
636 636 * Iterates over all the inlines, and places them inside proper blocks of data
637 637 */
638 638 var renderInlineComments = function(file_comments){
639 639 for (f in file_comments){
640 640 // holding all comments for a FILE
641 641 var box = file_comments[f];
642 642
643 643 var target_id = YUD.getAttribute(box,'target_id');
644 644 // actually comments with line numbers
645 645 var comments = box.children;
646 646 for(var i=0; i<comments.length; i++){
647 647 var data = {
648 648 'rendered_text': comments[i].outerHTML,
649 649 'line_no': YUD.getAttribute(comments[i],'line'),
650 650 'target_id': target_id
651 651 }
652 652 renderInlineComment(data);
653 653 }
654 654 }
655 655 }
656 656
657 657 var removeReviewer = function(reviewer_id){
658 658 var el = YUD.get('reviewer_{0}'.format(reviewer_id));
659 659 if (el.parentNode !== undefined){
660 660 el.parentNode.removeChild(el);
661 661 }
662 662 }
663 663
664 664 var fileBrowserListeners = function(current_url, node_list_url, url_base){
665 665
666 666 var current_url_branch = +"?branch=__BRANCH__";
667 667 var url = url_base;
668 668 var node_url = node_list_url;
669 669
670 670 YUE.on('stay_at_branch','click',function(e){
671 671 if(e.target.checked){
672 672 var uri = current_url_branch;
673 673 uri = uri.replace('__BRANCH__',e.target.value);
674 674 window.location = uri;
675 675 }
676 676 else{
677 677 window.location = current_url;
678 678 }
679 679 })
680 680
681 681 var n_filter = YUD.get('node_filter');
682 682 var F = YAHOO.namespace('node_filter');
683 683
684 684 F.filterTimeout = null;
685 685 var nodes = null;
686 686
687 687 F.initFilter = function(){
688 688 YUD.setStyle('node_filter_box_loading','display','');
689 689 YUD.setStyle('search_activate_id','display','none');
690 690 YUD.setStyle('add_node_id','display','none');
691 691 YUC.initHeader('X-PARTIAL-XHR',true);
692 692 YUC.asyncRequest('GET',url,{
693 693 success:function(o){
694 694 nodes = JSON.parse(o.responseText).nodes;
695 695 YUD.setStyle('node_filter_box_loading','display','none');
696 696 YUD.setStyle('node_filter_box','display','');
697 697 n_filter.focus();
698 698 if(YUD.hasClass(n_filter,'init')){
699 699 n_filter.value = '';
700 700 YUD.removeClass(n_filter,'init');
701 701 }
702 702 },
703 703 failure:function(o){
704 704 console.log('failed to load');
705 705 }
706 706 },null);
707 707 }
708 708
709 709 F.updateFilter = function(e) {
710 710
711 711 return function(){
712 712 // Reset timeout
713 713 F.filterTimeout = null;
714 714 var query = e.target.value.toLowerCase();
715 715 var match = [];
716 716 var matches = 0;
717 717 var matches_max = 20;
718 718 if (query != ""){
719 719 for(var i=0;i<nodes.length;i++){
720 720
721 721 var pos = nodes[i].name.toLowerCase().indexOf(query)
722 722 if(query && pos != -1){
723 723
724 724 matches++
725 725 //show only certain amount to not kill browser
726 726 if (matches > matches_max){
727 727 break;
728 728 }
729 729
730 730 var n = nodes[i].name;
731 731 var t = nodes[i].type;
732 732 var n_hl = n.substring(0,pos)
733 733 +"<b>{0}</b>".format(n.substring(pos,pos+query.length))
734 734 +n.substring(pos+query.length)
735 735 node_url = node_url.replace('__FPATH__',n);
736 736 match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,node_url,n_hl));
737 737 }
738 738 if(match.length >= matches_max){
739 739 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['search truncated']));
740 740 }
741 741 }
742 742 }
743 743 if(query != ""){
744 744 YUD.setStyle('tbody','display','none');
745 745 YUD.setStyle('tbody_filtered','display','');
746 746
747 747 if (match.length==0){
748 748 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['no matching files']));
749 749 }
750 750
751 751 YUD.get('tbody_filtered').innerHTML = match.join("");
752 752 }
753 753 else{
754 754 YUD.setStyle('tbody','display','');
755 755 YUD.setStyle('tbody_filtered','display','none');
756 756 }
757 757
758 758 }
759 759 };
760 760
761 761 YUE.on(YUD.get('filter_activate'),'click',function(){
762 762 F.initFilter();
763 763 })
764 764 YUE.on(n_filter,'click',function(){
765 765 if(YUD.hasClass(n_filter,'init')){
766 766 n_filter.value = '';
767 767 YUD.removeClass(n_filter,'init');
768 768 }
769 769 });
770 770 YUE.on(n_filter,'keyup',function(e){
771 771 clearTimeout(F.filterTimeout);
772 772 F.filterTimeout = setTimeout(F.updateFilter(e),600);
773 773 });
774 774 };
775 775
776 776
777 777 var initCodeMirror = function(textAreadId,resetUrl){
778 778 var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{
779 779 mode: "null",
780 780 lineNumbers:true
781 781 });
782 782 YUE.on('reset','click',function(e){
783 783 window.location=resetUrl
784 784 });
785 785
786 786 YUE.on('file_enable','click',function(){
787 787 YUD.setStyle('editor_container','display','');
788 788 YUD.setStyle('upload_file_container','display','none');
789 789 YUD.setStyle('filename_container','display','');
790 790 });
791 791
792 792 YUE.on('upload_file_enable','click',function(){
793 793 YUD.setStyle('editor_container','display','none');
794 794 YUD.setStyle('upload_file_container','display','');
795 795 YUD.setStyle('filename_container','display','none');
796 796 });
797 797 };
798 798
799 799
800 800
801 801 var getIdentNode = function(n){
802 802 //iterate thru nodes untill matched interesting node !
803 803
804 804 if (typeof n == 'undefined'){
805 805 return -1
806 806 }
807 807
808 808 if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){
809 809 return n
810 810 }
811 811 else{
812 812 return getIdentNode(n.parentNode);
813 813 }
814 814 };
815 815
816 816 var getSelectionLink = function(selection_link_label) {
817 817 return function(){
818 818 //get selection from start/to nodes
819 819 if (typeof window.getSelection != "undefined") {
820 820 s = window.getSelection();
821 821
822 822 from = getIdentNode(s.anchorNode);
823 823 till = getIdentNode(s.focusNode);
824 824
825 825 f_int = parseInt(from.id.replace('L',''));
826 826 t_int = parseInt(till.id.replace('L',''));
827 827
828 828 if (f_int > t_int){
829 829 //highlight from bottom
830 830 offset = -35;
831 831 ranges = [t_int,f_int];
832 832
833 833 }
834 834 else{
835 835 //highligth from top
836 836 offset = 35;
837 837 ranges = [f_int,t_int];
838 838 }
839 839
840 840 if (ranges[0] != ranges[1]){
841 841 if(YUD.get('linktt') == null){
842 842 hl_div = document.createElement('div');
843 843 hl_div.id = 'linktt';
844 844 }
845 845 anchor = '#L'+ranges[0]+'-'+ranges[1];
846 846 hl_div.innerHTML = '';
847 847 l = document.createElement('a');
848 848 l.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
849 849 l.innerHTML = selection_link_label;
850 850 hl_div.appendChild(l);
851 851
852 852 YUD.get('body').appendChild(hl_div);
853 853
854 854 xy = YUD.getXY(till.id);
855 855
856 856 YUD.addClass('linktt','yui-tt');
857 857 YUD.setStyle('linktt','top',xy[1]+offset+'px');
858 858 YUD.setStyle('linktt','left',xy[0]+'px');
859 859 YUD.setStyle('linktt','visibility','visible');
860 860 }
861 861 else{
862 862 YUD.setStyle('linktt','visibility','hidden');
863 863 }
864 864 }
865 865 }
866 866 };
867 867
868 868 var deleteNotification = function(url, notification_id,callbacks){
869 869 var callback = {
870 870 success:function(o){
871 871 var obj = YUD.get(String("notification_"+notification_id));
872 872 if(obj.parentNode !== undefined){
873 873 obj.parentNode.removeChild(obj);
874 874 }
875 875 _run_callbacks(callbacks);
876 876 },
877 877 failure:function(o){
878 878 alert("error");
879 879 },
880 880 };
881 881 var postData = '_method=delete';
882 882 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
883 883 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
884 884 callback, postData);
885 885 };
886 886
887 887 var readNotification = function(url, notification_id,callbacks){
888 888 var callback = {
889 889 success:function(o){
890 890 var obj = YUD.get(String("notification_"+notification_id));
891 891 YUD.removeClass(obj, 'unread');
892 var r_button = obj.children[0].getElementsByClassName('read-notification')[0]
892 var r_button = YUD.getElementsByClassName('read-notification',null,obj.children[0])[0];
893 893
894 894 if(r_button.parentNode !== undefined){
895 895 r_button.parentNode.removeChild(r_button);
896 896 }
897 897 _run_callbacks(callbacks);
898 898 },
899 899 failure:function(o){
900 900 alert("error");
901 901 },
902 902 };
903 903 var postData = '_method=put';
904 904 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
905 905 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
906 906 callback, postData);
907 907 };
908 908
909 909 /** MEMBERS AUTOCOMPLETE WIDGET **/
910 910
911 911 var MembersAutoComplete = function (users_list, groups_list) {
912 912 var myUsers = users_list;
913 913 var myGroups = groups_list;
914 914
915 915 // Define a custom search function for the DataSource of users
916 916 var matchUsers = function (sQuery) {
917 917 // Case insensitive matching
918 918 var query = sQuery.toLowerCase();
919 919 var i = 0;
920 920 var l = myUsers.length;
921 921 var matches = [];
922 922
923 923 // Match against each name of each contact
924 924 for (; i < l; i++) {
925 925 contact = myUsers[i];
926 926 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
927 927 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
928 928 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
929 929 matches[matches.length] = contact;
930 930 }
931 931 }
932 932 return matches;
933 933 };
934 934
935 935 // Define a custom search function for the DataSource of usersGroups
936 936 var matchGroups = function (sQuery) {
937 937 // Case insensitive matching
938 938 var query = sQuery.toLowerCase();
939 939 var i = 0;
940 940 var l = myGroups.length;
941 941 var matches = [];
942 942
943 943 // Match against each name of each contact
944 944 for (; i < l; i++) {
945 945 matched_group = myGroups[i];
946 946 if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
947 947 matches[matches.length] = matched_group;
948 948 }
949 949 }
950 950 return matches;
951 951 };
952 952
953 953 //match all
954 954 var matchAll = function (sQuery) {
955 955 u = matchUsers(sQuery);
956 956 g = matchGroups(sQuery);
957 957 return u.concat(g);
958 958 };
959 959
960 960 // DataScheme for members
961 961 var memberDS = new YAHOO.util.FunctionDataSource(matchAll);
962 962 memberDS.responseSchema = {
963 963 fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"]
964 964 };
965 965
966 966 // DataScheme for owner
967 967 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
968 968 ownerDS.responseSchema = {
969 969 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
970 970 };
971 971
972 972 // Instantiate AutoComplete for perms
973 973 var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS);
974 974 membersAC.useShadow = false;
975 975 membersAC.resultTypeList = false;
976 976 membersAC.animVert = false;
977 977 membersAC.animHoriz = false;
978 978 membersAC.animSpeed = 0.1;
979 979
980 980 // Instantiate AutoComplete for owner
981 981 var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS);
982 982 ownerAC.useShadow = false;
983 983 ownerAC.resultTypeList = false;
984 984 ownerAC.animVert = false;
985 985 ownerAC.animHoriz = false;
986 986 ownerAC.animSpeed = 0.1;
987 987
988 988 // Helper highlight function for the formatter
989 989 var highlightMatch = function (full, snippet, matchindex) {
990 990 return full.substring(0, matchindex)
991 991 + "<span class='match'>"
992 992 + full.substr(matchindex, snippet.length)
993 993 + "</span>" + full.substring(matchindex + snippet.length);
994 994 };
995 995
996 996 // Custom formatter to highlight the matching letters
997 997 var custom_formatter = function (oResultData, sQuery, sResultMatch) {
998 998 var query = sQuery.toLowerCase();
999 999 var _gravatar = function(res, em, group){
1000 1000 if (group !== undefined){
1001 1001 em = '/images/icons/group.png'
1002 1002 }
1003 1003 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1004 1004 return tmpl.format(em,res)
1005 1005 }
1006 1006 // group
1007 1007 if (oResultData.grname != undefined) {
1008 1008 var grname = oResultData.grname;
1009 1009 var grmembers = oResultData.grmembers;
1010 1010 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
1011 1011 var grprefix = "{0}: ".format(_TM['Group']);
1012 1012 var grsuffix = " (" + grmembers + " )";
1013 1013 var grsuffix = " ({0} {1})".format(grmembers, _TM['members']);
1014 1014
1015 1015 if (grnameMatchIndex > -1) {
1016 1016 return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true);
1017 1017 }
1018 1018 return _gravatar(grprefix + oResultData.grname + grsuffix, null,true);
1019 1019 // Users
1020 1020 } else if (oResultData.nname != undefined) {
1021 1021 var fname = oResultData.fname || "";
1022 1022 var lname = oResultData.lname || "";
1023 1023 var nname = oResultData.nname;
1024 1024
1025 1025 // Guard against null value
1026 1026 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1027 1027 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1028 1028 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1029 1029 displayfname, displaylname, displaynname;
1030 1030
1031 1031 if (fnameMatchIndex > -1) {
1032 1032 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1033 1033 } else {
1034 1034 displayfname = fname;
1035 1035 }
1036 1036
1037 1037 if (lnameMatchIndex > -1) {
1038 1038 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1039 1039 } else {
1040 1040 displaylname = lname;
1041 1041 }
1042 1042
1043 1043 if (nnameMatchIndex > -1) {
1044 1044 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1045 1045 } else {
1046 1046 displaynname = nname ? "(" + nname + ")" : "";
1047 1047 }
1048 1048
1049 1049 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1050 1050 } else {
1051 1051 return '';
1052 1052 }
1053 1053 };
1054 1054 membersAC.formatResult = custom_formatter;
1055 1055 ownerAC.formatResult = custom_formatter;
1056 1056
1057 1057 var myHandler = function (sType, aArgs) {
1058 1058
1059 1059 var myAC = aArgs[0]; // reference back to the AC instance
1060 1060 var elLI = aArgs[1]; // reference to the selected LI element
1061 1061 var oData = aArgs[2]; // object literal of selected item's result data
1062 1062 //fill the autocomplete with value
1063 1063 if (oData.nname != undefined) {
1064 1064 //users
1065 1065 myAC.getInputEl().value = oData.nname;
1066 1066 YUD.get('perm_new_member_type').value = 'user';
1067 1067 } else {
1068 1068 //groups
1069 1069 myAC.getInputEl().value = oData.grname;
1070 1070 YUD.get('perm_new_member_type').value = 'users_group';
1071 1071 }
1072 1072 };
1073 1073
1074 1074 membersAC.itemSelectEvent.subscribe(myHandler);
1075 1075 if(ownerAC.itemSelectEvent){
1076 1076 ownerAC.itemSelectEvent.subscribe(myHandler);
1077 1077 }
1078 1078
1079 1079 return {
1080 1080 memberDS: memberDS,
1081 1081 ownerDS: ownerDS,
1082 1082 membersAC: membersAC,
1083 1083 ownerAC: ownerAC,
1084 1084 };
1085 1085 }
1086 1086
1087 1087
1088 1088 var MentionsAutoComplete = function (divid, cont, users_list, groups_list) {
1089 1089 var myUsers = users_list;
1090 1090 var myGroups = groups_list;
1091 1091
1092 1092 // Define a custom search function for the DataSource of users
1093 1093 var matchUsers = function (sQuery) {
1094 1094 var org_sQuery = sQuery;
1095 1095 if(this.mentionQuery == null){
1096 1096 return []
1097 1097 }
1098 1098 sQuery = this.mentionQuery;
1099 1099 // Case insensitive matching
1100 1100 var query = sQuery.toLowerCase();
1101 1101 var i = 0;
1102 1102 var l = myUsers.length;
1103 1103 var matches = [];
1104 1104
1105 1105 // Match against each name of each contact
1106 1106 for (; i < l; i++) {
1107 1107 contact = myUsers[i];
1108 1108 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1109 1109 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1110 1110 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1111 1111 matches[matches.length] = contact;
1112 1112 }
1113 1113 }
1114 1114 return matches
1115 1115 };
1116 1116
1117 1117 //match all
1118 1118 var matchAll = function (sQuery) {
1119 1119 u = matchUsers(sQuery);
1120 1120 return u
1121 1121 };
1122 1122
1123 1123 // DataScheme for owner
1124 1124 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1125 1125
1126 1126 ownerDS.responseSchema = {
1127 1127 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1128 1128 };
1129 1129
1130 1130 // Instantiate AutoComplete for mentions
1131 1131 var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS);
1132 1132 ownerAC.useShadow = false;
1133 1133 ownerAC.resultTypeList = false;
1134 1134 ownerAC.suppressInputUpdate = true;
1135 1135 ownerAC.animVert = false;
1136 1136 ownerAC.animHoriz = false;
1137 1137 ownerAC.animSpeed = 0.1;
1138 1138
1139 1139 // Helper highlight function for the formatter
1140 1140 var highlightMatch = function (full, snippet, matchindex) {
1141 1141 return full.substring(0, matchindex)
1142 1142 + "<span class='match'>"
1143 1143 + full.substr(matchindex, snippet.length)
1144 1144 + "</span>" + full.substring(matchindex + snippet.length);
1145 1145 };
1146 1146
1147 1147 // Custom formatter to highlight the matching letters
1148 1148 ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
1149 1149 var org_sQuery = sQuery;
1150 1150 if(this.dataSource.mentionQuery != null){
1151 1151 sQuery = this.dataSource.mentionQuery;
1152 1152 }
1153 1153
1154 1154 var query = sQuery.toLowerCase();
1155 1155 var _gravatar = function(res, em, group){
1156 1156 if (group !== undefined){
1157 1157 em = '/images/icons/group.png'
1158 1158 }
1159 1159 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1160 1160 return tmpl.format(em,res)
1161 1161 }
1162 1162 if (oResultData.nname != undefined) {
1163 1163 var fname = oResultData.fname || "";
1164 1164 var lname = oResultData.lname || "";
1165 1165 var nname = oResultData.nname;
1166 1166
1167 1167 // Guard against null value
1168 1168 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1169 1169 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1170 1170 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1171 1171 displayfname, displaylname, displaynname;
1172 1172
1173 1173 if (fnameMatchIndex > -1) {
1174 1174 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1175 1175 } else {
1176 1176 displayfname = fname;
1177 1177 }
1178 1178
1179 1179 if (lnameMatchIndex > -1) {
1180 1180 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1181 1181 } else {
1182 1182 displaylname = lname;
1183 1183 }
1184 1184
1185 1185 if (nnameMatchIndex > -1) {
1186 1186 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1187 1187 } else {
1188 1188 displaynname = nname ? "(" + nname + ")" : "";
1189 1189 }
1190 1190
1191 1191 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1192 1192 } else {
1193 1193 return '';
1194 1194 }
1195 1195 };
1196 1196
1197 1197 if(ownerAC.itemSelectEvent){
1198 1198 ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) {
1199 1199
1200 1200 var myAC = aArgs[0]; // reference back to the AC instance
1201 1201 var elLI = aArgs[1]; // reference to the selected LI element
1202 1202 var oData = aArgs[2]; // object literal of selected item's result data
1203 1203 //fill the autocomplete with value
1204 1204 if (oData.nname != undefined) {
1205 1205 //users
1206 1206 //Replace the mention name with replaced
1207 1207 var re = new RegExp();
1208 1208 var org = myAC.getInputEl().value;
1209 1209 var chunks = myAC.dataSource.chunks
1210 1210 // replace middle chunk(the search term) with actuall match
1211 1211 chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery,
1212 1212 '@'+oData.nname+' ');
1213 1213 myAC.getInputEl().value = chunks.join('')
1214 1214 YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !?
1215 1215 } else {
1216 1216 //groups
1217 1217 myAC.getInputEl().value = oData.grname;
1218 1218 YUD.get('perm_new_member_type').value = 'users_group';
1219 1219 }
1220 1220 });
1221 1221 }
1222 1222
1223 1223 // in this keybuffer we will gather current value of search !
1224 1224 // since we need to get this just when someone does `@` then we do the
1225 1225 // search
1226 1226 ownerAC.dataSource.chunks = [];
1227 1227 ownerAC.dataSource.mentionQuery = null;
1228 1228
1229 1229 ownerAC.get_mention = function(msg, max_pos) {
1230 1230 var org = msg;
1231 1231 var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$')
1232 1232 var chunks = [];
1233 1233
1234 1234
1235 1235 // cut first chunk until curret pos
1236 1236 var to_max = msg.substr(0, max_pos);
1237 1237 var at_pos = Math.max(0,to_max.lastIndexOf('@')-1);
1238 1238 var msg2 = to_max.substr(at_pos);
1239 1239
1240 1240 chunks.push(org.substr(0,at_pos))// prefix chunk
1241 1241 chunks.push(msg2) // search chunk
1242 1242 chunks.push(org.substr(max_pos)) // postfix chunk
1243 1243
1244 1244 // clean up msg2 for filtering and regex match
1245 1245 var msg2 = msg2.lstrip(' ').lstrip('\n');
1246 1246
1247 1247 if(re.test(msg2)){
1248 1248 var unam = re.exec(msg2)[1];
1249 1249 return [unam, chunks];
1250 1250 }
1251 1251 return [null, null];
1252 1252 };
1253 1253
1254 1254 if (ownerAC.textboxKeyUpEvent){
1255 1255 ownerAC.textboxKeyUpEvent.subscribe(function(type, args){
1256 1256
1257 1257 var ac_obj = args[0];
1258 1258 var currentMessage = args[1];
1259 1259 var currentCaretPosition = args[0]._elTextbox.selectionStart;
1260 1260
1261 1261 var unam = ownerAC.get_mention(currentMessage, currentCaretPosition);
1262 1262 var curr_search = null;
1263 1263 if(unam[0]){
1264 1264 curr_search = unam[0];
1265 1265 }
1266 1266
1267 1267 ownerAC.dataSource.chunks = unam[1];
1268 1268 ownerAC.dataSource.mentionQuery = curr_search;
1269 1269
1270 1270 })
1271 1271 }
1272 1272 return {
1273 1273 ownerDS: ownerDS,
1274 1274 ownerAC: ownerAC,
1275 1275 };
1276 1276 }
1277 1277
1278 1278
1279 1279 var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) {
1280 1280 var myUsers = users_list;
1281 1281 var myGroups = groups_list;
1282 1282
1283 1283 // Define a custom search function for the DataSource of users
1284 1284 var matchUsers = function (sQuery) {
1285 1285 // Case insensitive matching
1286 1286 var query = sQuery.toLowerCase();
1287 1287 var i = 0;
1288 1288 var l = myUsers.length;
1289 1289 var matches = [];
1290 1290
1291 1291 // Match against each name of each contact
1292 1292 for (; i < l; i++) {
1293 1293 contact = myUsers[i];
1294 1294 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1295 1295 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1296 1296 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1297 1297 matches[matches.length] = contact;
1298 1298 }
1299 1299 }
1300 1300 return matches;
1301 1301 };
1302 1302
1303 1303 // Define a custom search function for the DataSource of usersGroups
1304 1304 var matchGroups = function (sQuery) {
1305 1305 // Case insensitive matching
1306 1306 var query = sQuery.toLowerCase();
1307 1307 var i = 0;
1308 1308 var l = myGroups.length;
1309 1309 var matches = [];
1310 1310
1311 1311 // Match against each name of each contact
1312 1312 for (; i < l; i++) {
1313 1313 matched_group = myGroups[i];
1314 1314 if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
1315 1315 matches[matches.length] = matched_group;
1316 1316 }
1317 1317 }
1318 1318 return matches;
1319 1319 };
1320 1320
1321 1321 //match all
1322 1322 var matchAll = function (sQuery) {
1323 1323 u = matchUsers(sQuery);
1324 1324 return u
1325 1325 };
1326 1326
1327 1327 // DataScheme for owner
1328 1328 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1329 1329
1330 1330 ownerDS.responseSchema = {
1331 1331 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1332 1332 };
1333 1333
1334 1334 // Instantiate AutoComplete for mentions
1335 1335 var reviewerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS);
1336 1336 reviewerAC.useShadow = false;
1337 1337 reviewerAC.resultTypeList = false;
1338 1338 reviewerAC.suppressInputUpdate = true;
1339 1339 reviewerAC.animVert = false;
1340 1340 reviewerAC.animHoriz = false;
1341 1341 reviewerAC.animSpeed = 0.1;
1342 1342
1343 1343 // Helper highlight function for the formatter
1344 1344 var highlightMatch = function (full, snippet, matchindex) {
1345 1345 return full.substring(0, matchindex)
1346 1346 + "<span class='match'>"
1347 1347 + full.substr(matchindex, snippet.length)
1348 1348 + "</span>" + full.substring(matchindex + snippet.length);
1349 1349 };
1350 1350
1351 1351 // Custom formatter to highlight the matching letters
1352 1352 reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
1353 1353 var org_sQuery = sQuery;
1354 1354 if(this.dataSource.mentionQuery != null){
1355 1355 sQuery = this.dataSource.mentionQuery;
1356 1356 }
1357 1357
1358 1358 var query = sQuery.toLowerCase();
1359 1359 var _gravatar = function(res, em, group){
1360 1360 if (group !== undefined){
1361 1361 em = '/images/icons/group.png'
1362 1362 }
1363 1363 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1364 1364 return tmpl.format(em,res)
1365 1365 }
1366 1366 if (oResultData.nname != undefined) {
1367 1367 var fname = oResultData.fname || "";
1368 1368 var lname = oResultData.lname || "";
1369 1369 var nname = oResultData.nname;
1370 1370
1371 1371 // Guard against null value
1372 1372 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1373 1373 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1374 1374 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1375 1375 displayfname, displaylname, displaynname;
1376 1376
1377 1377 if (fnameMatchIndex > -1) {
1378 1378 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1379 1379 } else {
1380 1380 displayfname = fname;
1381 1381 }
1382 1382
1383 1383 if (lnameMatchIndex > -1) {
1384 1384 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1385 1385 } else {
1386 1386 displaylname = lname;
1387 1387 }
1388 1388
1389 1389 if (nnameMatchIndex > -1) {
1390 1390 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1391 1391 } else {
1392 1392 displaynname = nname ? "(" + nname + ")" : "";
1393 1393 }
1394 1394
1395 1395 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1396 1396 } else {
1397 1397 return '';
1398 1398 }
1399 1399 };
1400 1400
1401 1401 //members cache to catch duplicates
1402 1402 reviewerAC.dataSource.cache = [];
1403 1403 // hack into select event
1404 1404 if(reviewerAC.itemSelectEvent){
1405 1405 reviewerAC.itemSelectEvent.subscribe(function (sType, aArgs) {
1406 1406
1407 1407 var myAC = aArgs[0]; // reference back to the AC instance
1408 1408 var elLI = aArgs[1]; // reference to the selected LI element
1409 1409 var oData = aArgs[2]; // object literal of selected item's result data
1410 1410 var members = YUD.get('review_members');
1411 1411 //fill the autocomplete with value
1412 1412
1413 1413 if (oData.nname != undefined) {
1414 1414 if (myAC.dataSource.cache.indexOf(oData.id) != -1){
1415 1415 return
1416 1416 }
1417 1417
1418 1418 var tmpl = '<li id="reviewer_{2}">'+
1419 1419 '<div class="reviewers_member">'+
1420 1420 '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+
1421 1421 '<div style="float:left">{1}</div>'+
1422 1422 '<input type="hidden" value="{2}" name="review_members" />'+
1423 1423 '<span class="delete_icon action_button" onclick="removeReviewer({2})"></span>'+
1424 1424 '</div>'+
1425 1425 '</li>'
1426 1426
1427 1427 var displayname = "{0} {1} ({2})".format(oData.fname,oData.lname,oData.nname);
1428 1428 var element = tmpl.format(oData.gravatar_lnk,displayname,oData.id);
1429 1429 members.innerHTML += element;
1430 1430 myAC.dataSource.cache.push(oData.id);
1431 1431 YUD.get('user').value = ''
1432 1432 }
1433 1433 });
1434 1434 }
1435 1435 return {
1436 1436 ownerDS: ownerDS,
1437 1437 reviewerAC: reviewerAC,
1438 1438 };
1439 1439 }
1440 1440
1441 1441
1442 1442 /**
1443 1443 * QUICK REPO MENU
1444 1444 */
1445 1445 var quick_repo_menu = function(){
1446 1446 YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){
1447 1447 var menu = e.currentTarget.firstElementChild.firstElementChild;
1448 1448 if(YUD.hasClass(menu,'hidden')){
1449 1449 YUD.replaceClass(e.currentTarget,'hidden', 'active');
1450 1450 YUD.replaceClass(menu, 'hidden', 'active');
1451 1451 }
1452 1452 })
1453 1453 YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){
1454 1454 var menu = e.currentTarget.firstElementChild.firstElementChild;
1455 1455 if(YUD.hasClass(menu,'active')){
1456 1456 YUD.replaceClass(e.currentTarget, 'active', 'hidden');
1457 1457 YUD.replaceClass(menu, 'active', 'hidden');
1458 1458 }
1459 1459 })
1460 1460 };
1461 1461
1462 1462
1463 1463 /**
1464 1464 * TABLE SORTING
1465 1465 */
1466 1466
1467 1467 // returns a node from given html;
1468 1468 var fromHTML = function(html){
1469 1469 var _html = document.createElement('element');
1470 1470 _html.innerHTML = html;
1471 1471 return _html;
1472 1472 }
1473 1473 var get_rev = function(node){
1474 1474 var n = node.firstElementChild.firstElementChild;
1475 1475
1476 1476 if (n===null){
1477 1477 return -1
1478 1478 }
1479 1479 else{
1480 1480 out = n.firstElementChild.innerHTML.split(':')[0].replace('r','');
1481 1481 return parseInt(out);
1482 1482 }
1483 1483 }
1484 1484
1485 1485 var get_name = function(node){
1486 1486 var name = node.firstElementChild.children[2].innerHTML;
1487 1487 return name
1488 1488 }
1489 1489 var get_group_name = function(node){
1490 1490 var name = node.firstElementChild.children[1].innerHTML;
1491 1491 return name
1492 1492 }
1493 1493 var get_date = function(node){
1494 1494 var date_ = YUD.getAttribute(node.firstElementChild,'date');
1495 1495 return date_
1496 1496 }
1497 1497
1498 1498 var get_age = function(node){
1499 1499 return node
1500 1500 }
1501 1501
1502 1502 var get_link = function(node){
1503 1503 return node.firstElementChild.text;
1504 1504 }
1505 1505
1506 1506 var revisionSort = function(a, b, desc, field) {
1507 1507
1508 1508 var a_ = fromHTML(a.getData(field));
1509 1509 var b_ = fromHTML(b.getData(field));
1510 1510
1511 1511 // extract revisions from string nodes
1512 1512 a_ = get_rev(a_)
1513 1513 b_ = get_rev(b_)
1514 1514
1515 1515 var comp = YAHOO.util.Sort.compare;
1516 1516 var compState = comp(a_, b_, desc);
1517 1517 return compState;
1518 1518 };
1519 1519 var ageSort = function(a, b, desc, field) {
1520 1520 var a_ = fromHTML(a.getData(field));
1521 1521 var b_ = fromHTML(b.getData(field));
1522 1522
1523 1523 // extract name from table
1524 1524 a_ = get_date(a_)
1525 1525 b_ = get_date(b_)
1526 1526
1527 1527 var comp = YAHOO.util.Sort.compare;
1528 1528 var compState = comp(a_, b_, desc);
1529 1529 return compState;
1530 1530 };
1531 1531
1532 1532 var lastLoginSort = function(a, b, desc, field) {
1533 1533 var a_ = a.getData('last_login_raw') || 0;
1534 1534 var b_ = b.getData('last_login_raw') || 0;
1535 1535
1536 1536 var comp = YAHOO.util.Sort.compare;
1537 1537 var compState = comp(a_, b_, desc);
1538 1538 return compState;
1539 1539 };
1540 1540
1541 1541 var nameSort = function(a, b, desc, field) {
1542 1542 var a_ = fromHTML(a.getData(field));
1543 1543 var b_ = fromHTML(b.getData(field));
1544 1544
1545 1545 // extract name from table
1546 1546 a_ = get_name(a_)
1547 1547 b_ = get_name(b_)
1548 1548
1549 1549 var comp = YAHOO.util.Sort.compare;
1550 1550 var compState = comp(a_, b_, desc);
1551 1551 return compState;
1552 1552 };
1553 1553
1554 1554 var permNameSort = function(a, b, desc, field) {
1555 1555 var a_ = fromHTML(a.getData(field));
1556 1556 var b_ = fromHTML(b.getData(field));
1557 1557 // extract name from table
1558 1558
1559 1559 a_ = a_.children[0].innerHTML;
1560 1560 b_ = b_.children[0].innerHTML;
1561 1561
1562 1562 var comp = YAHOO.util.Sort.compare;
1563 1563 var compState = comp(a_, b_, desc);
1564 1564 return compState;
1565 1565 };
1566 1566
1567 1567 var groupNameSort = function(a, b, desc, field) {
1568 1568 var a_ = fromHTML(a.getData(field));
1569 1569 var b_ = fromHTML(b.getData(field));
1570 1570
1571 1571 // extract name from table
1572 1572 a_ = get_group_name(a_)
1573 1573 b_ = get_group_name(b_)
1574 1574
1575 1575 var comp = YAHOO.util.Sort.compare;
1576 1576 var compState = comp(a_, b_, desc);
1577 1577 return compState;
1578 1578 };
1579 1579 var dateSort = function(a, b, desc, field) {
1580 1580 var a_ = fromHTML(a.getData(field));
1581 1581 var b_ = fromHTML(b.getData(field));
1582 1582
1583 1583 // extract name from table
1584 1584 a_ = get_date(a_)
1585 1585 b_ = get_date(b_)
1586 1586
1587 1587 var comp = YAHOO.util.Sort.compare;
1588 1588 var compState = comp(a_, b_, desc);
1589 1589 return compState;
1590 1590 };
1591 1591
1592 1592 var linkSort = function(a, b, desc, field) {
1593 1593 var a_ = fromHTML(a.getData(field));
1594 1594 var b_ = fromHTML(a.getData(field));
1595 1595
1596 1596 // extract url text from string nodes
1597 1597 a_ = get_link(a_)
1598 1598 b_ = get_link(b_)
1599 1599
1600 1600 var comp = YAHOO.util.Sort.compare;
1601 1601 var compState = comp(a_, b_, desc);
1602 1602 return compState;
1603 1603 }
1604 1604
1605 1605
1606 1606 /* Multi selectors */
1607 1607
1608 1608 var MultiSelectWidget = function(selected_id, available_id, form_id){
1609 1609
1610 1610
1611 1611 //definition of containers ID's
1612 1612 var selected_container = selected_id;
1613 1613 var available_container = available_id;
1614 1614
1615 1615 //temp container for selected storage.
1616 1616 var cache = new Array();
1617 1617 var av_cache = new Array();
1618 1618 var c = YUD.get(selected_container);
1619 1619 var ac = YUD.get(available_container);
1620 1620
1621 1621 //get only selected options for further fullfilment
1622 1622 for(var i = 0;node =c.options[i];i++){
1623 1623 if(node.selected){
1624 1624 //push selected to my temp storage left overs :)
1625 1625 cache.push(node);
1626 1626 }
1627 1627 }
1628 1628
1629 1629 //get all available options to cache
1630 1630 for(var i = 0;node =ac.options[i];i++){
1631 1631 //push selected to my temp storage left overs :)
1632 1632 av_cache.push(node);
1633 1633 }
1634 1634
1635 1635 //fill available only with those not in choosen
1636 1636 ac.options.length=0;
1637 1637 tmp_cache = new Array();
1638 1638
1639 1639 for(var i = 0;node = av_cache[i];i++){
1640 1640 var add = true;
1641 1641 for(var i2 = 0;node_2 = cache[i2];i2++){
1642 1642 if(node.value == node_2.value){
1643 1643 add=false;
1644 1644 break;
1645 1645 }
1646 1646 }
1647 1647 if(add){
1648 1648 tmp_cache.push(new Option(node.text, node.value, false, false));
1649 1649 }
1650 1650 }
1651 1651
1652 1652 for(var i = 0;node = tmp_cache[i];i++){
1653 1653 ac.options[i] = node;
1654 1654 }
1655 1655
1656 1656 function prompts_action_callback(e){
1657 1657
1658 1658 var choosen = YUD.get(selected_container);
1659 1659 var available = YUD.get(available_container);
1660 1660
1661 1661 //get checked and unchecked options from field
1662 1662 function get_checked(from_field){
1663 1663 //temp container for storage.
1664 1664 var sel_cache = new Array();
1665 1665 var oth_cache = new Array();
1666 1666
1667 1667 for(var i = 0;node = from_field.options[i];i++){
1668 1668 if(node.selected){
1669 1669 //push selected fields :)
1670 1670 sel_cache.push(node);
1671 1671 }
1672 1672 else{
1673 1673 oth_cache.push(node)
1674 1674 }
1675 1675 }
1676 1676
1677 1677 return [sel_cache,oth_cache]
1678 1678 }
1679 1679
1680 1680 //fill the field with given options
1681 1681 function fill_with(field,options){
1682 1682 //clear firtst
1683 1683 field.options.length=0;
1684 1684 for(var i = 0;node = options[i];i++){
1685 1685 field.options[i]=new Option(node.text, node.value,
1686 1686 false, false);
1687 1687 }
1688 1688
1689 1689 }
1690 1690 //adds to current field
1691 1691 function add_to(field,options){
1692 1692 for(var i = 0;node = options[i];i++){
1693 1693 field.appendChild(new Option(node.text, node.value,
1694 1694 false, false));
1695 1695 }
1696 1696 }
1697 1697
1698 1698 // add action
1699 1699 if (this.id=='add_element'){
1700 1700 var c = get_checked(available);
1701 1701 add_to(choosen,c[0]);
1702 1702 fill_with(available,c[1]);
1703 1703 }
1704 1704 // remove action
1705 1705 if (this.id=='remove_element'){
1706 1706 var c = get_checked(choosen);
1707 1707 add_to(available,c[0]);
1708 1708 fill_with(choosen,c[1]);
1709 1709 }
1710 1710 // add all elements
1711 1711 if(this.id=='add_all_elements'){
1712 1712 for(var i=0; node = available.options[i];i++){
1713 1713 choosen.appendChild(new Option(node.text,
1714 1714 node.value, false, false));
1715 1715 }
1716 1716 available.options.length = 0;
1717 1717 }
1718 1718 //remove all elements
1719 1719 if(this.id=='remove_all_elements'){
1720 1720 for(var i=0; node = choosen.options[i];i++){
1721 1721 available.appendChild(new Option(node.text,
1722 1722 node.value, false, false));
1723 1723 }
1724 1724 choosen.options.length = 0;
1725 1725 }
1726 1726
1727 1727 }
1728 1728
1729 1729 YUE.addListener(['add_element','remove_element',
1730 1730 'add_all_elements','remove_all_elements'],'click',
1731 1731 prompts_action_callback)
1732 1732 if (form_id !== undefined) {
1733 1733 YUE.addListener(form_id,'submit',function(){
1734 1734 var choosen = YUD.get(selected_container);
1735 1735 for (var i = 0; i < choosen.options.length; i++) {
1736 1736 choosen.options[i].selected = 'selected';
1737 1737 }
1738 1738 });
1739 1739 }
1740 } No newline at end of file
1740 }
@@ -1,179 +1,185
1 1 ## -*- coding: utf-8 -*-
2 2
3 3 <%inherit file="/base/base.html"/>
4 4
5 5 <%def name="title()">
6 6 ${_('%s Changeset') % c.repo_name} - 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 &raquo;
12 12 ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
13 13 &raquo;
14 14 ${_('Changeset')} - <span class='hash'>r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)}</span>
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="hash">
31 31 r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)}
32 32 </div>
33 33 <div class="date">
34 34 ${h.fmt_date(c.changeset.date)}
35 35 </div>
36 36 <div class="changeset-status-container">
37 37 %if c.statuses:
38 38 <div title="${_('Changeset status')}" class="changeset-status-lbl">[${h.changeset_status_lbl(c.statuses[0])}]</div>
39 39 <div class="changeset-status-ico"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses[0])}" /></div>
40 40 %endif
41 41 </div>
42 42 <div class="diff-actions">
43 43 <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show')}" class="tooltip" title="${h.tooltip(_('raw diff'))}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a>
44 44 <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('download diff'))}"><img class="icon" src="${h.url('/images/icons/page_white_get.png')}"/></a>
45 45 ${c.ignorews_url(request.GET)}
46 46 ${c.context_url(request.GET)}
47 47 </div>
48 48 <div class="comments-number" style="float:right;padding-right:5px">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div>
49 49 </div>
50 50 </div>
51 51 <div id="changeset_content">
52 52 <div class="container">
53 53 <div class="left">
54 54 <div class="author">
55 55 <div class="gravatar">
56 56 <img alt="gravatar" src="${h.gravatar_url(h.email(c.changeset.author),20)}"/>
57 57 </div>
58 58 <span>${h.person(c.changeset.author)}</span><br/>
59 59 <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/>
60 60 </div>
61 61 <div class="message">${h.urlify_commit(c.changeset.message, c.repo_name)}</div>
62 62 </div>
63 63 <div class="right">
64 64 <div class="changes">
65 65 % if len(c.changeset.affected_files) <= c.affected_files_cut_off:
66 66 <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span>
67 67 <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span>
68 68 <span class="added" title="${_('added')}">${len(c.changeset.added)}</span>
69 69 % else:
70 70 <span class="removed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span>
71 71 <span class="changed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span>
72 72 <span class="added" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span>
73 73 % endif
74 74 </div>
75 75
76 76 %if c.changeset.parents:
77 77 %for p_cs in reversed(c.changeset.parents):
78 78 <div class="parent">${_('Parent')}
79 79 <span class="changeset_id">${p_cs.revision}:<span class="changeset_hash">${h.link_to(h.short_id(p_cs.raw_id),
80 80 h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}</span></span>
81 81 </div>
82 82 %endfor
83 83 %else:
84 84 <div class="parent">${_('No parents')}</div>
85 85 %endif
86 86 <span class="logtags">
87 87 %if len(c.changeset.parents)>1:
88 88 <span class="merge">${_('merge')}</span>
89 89 %endif
90 90 %if c.changeset.branch:
91 91 <span class="branchtag" title="${'%s %s' % (_('branch'),c.changeset.branch)}">
92 92 ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}
93 93 </span>
94 94 %endif
95 95 %for tag in c.changeset.tags:
96 96 <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}">
97 97 ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span>
98 98 %endfor
99 99 </span>
100 100 </div>
101 101 </div>
102 102 <span>
103 103 ${_('%s files affected with %s insertions and %s deletions:') % (len(c.changeset.affected_files),c.lines_added,c.lines_deleted)}
104 104 </span>
105 105 <div class="cs_files">
106 106 %for change,filenode,diff,cs1,cs2,stat in c.changes:
107 107 <div class="cs_${change}">
108 108 <div class="node">
109 109 %if change != 'removed':
110 110 ${h.link_to(h.safe_unicode(filenode.path),c.anchor_url(filenode.changeset.raw_id,filenode.path,request.GET)+"_target")}
111 111 %else:
112 112 ${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor=h.FID('',filenode.path)))}
113 113 %endif
114 114 </div>
115 115 <div class="changes">${h.fancy_file_stats(stat)}</div>
116 116 </div>
117 117 %endfor
118 118 % if c.cut_off:
119 119 ${_('Changeset was too big and was cut off...')}
120 120 % endif
121 121 </div>
122 122 </div>
123 123
124 124 </div>
125 125 <script>
126 126 var _USERS_AC_DATA = ${c.users_array|n};
127 127 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
128 128 AJAX_COMMENT_URL = "${url('changeset_comment',repo_name=c.repo_name,revision=c.changeset.raw_id)}";
129 129 AJAX_COMMENT_DELETE_URL = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}";
130 130 </script>
131 131 ## diff block
132 132 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
133 133 ${diff_block.diff_block(c.changes)}
134 134
135 135 ## template for inline comment form
136 136 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
137 137 ${comment.comment_inline_form()}
138 138
139 139 ## render comments and inlines
140 140 ${comment.generate_comments()}
141 141
142 142 ## main comment form and it status
143 143 ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id),
144 144 h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))}
145 145
146 146 ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS
147 147 <script type="text/javascript">
148 148 YUE.onDOMReady(function(){
149 149 YUE.on(YUQ('.show-inline-comments'),'change',function(e){
150 150 var show = 'none';
151 151 var target = e.currentTarget;
152 if(target == null){
153 target = this;
154 }
152 155 if(target.checked){
153 156 var show = ''
154 157 }
155 158 var boxid = YUD.getAttribute(target,'id_for');
156 159 var comments = YUQ('#{0} .inline-comments'.format(boxid));
157 160 for(c in comments){
158 161 YUD.setStyle(comments[c],'display',show);
159 162 }
160 163 var btns = YUQ('#{0} .inline-comments-button'.format(boxid));
161 164 for(c in btns){
162 165 YUD.setStyle(btns[c],'display',show);
163 166 }
164 167 })
165 168
166 169 YUE.on(YUQ('.line'),'click',function(e){
167 170 var tr = e.currentTarget;
171 if(tr == null){
172 tr = this;
173 }
168 174 injectInlineForm(tr);
169 175 });
170 176
171 177 // inject comments into they proper positions
172 178 var file_comments = YUQ('.inline-comment-placeholder');
173 179 renderInlineComments(file_comments);
174 180 })
175 181
176 182 </script>
177 183
178 184 </div>
179 185 </%def>
General Comments 0
You need to be logged in to leave comments. Login now