Show More
This diff has been collapsed as it changes many lines, (2115 lines changed) Show them Hide them | |||
@@ -3,13 +3,13 b' 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 |
|
|
|
12 |
|
|
|
11 | for (var o = []; m > 0; o[--m] = i); | |
|
12 | return o.join(''); | |
|
13 | 13 | }; |
|
14 | 14 | |
|
15 | 15 | /** |
@@ -19,48 +19,48 b' var str_repeat = function(i, m) {' | |||
|
19 | 19 | * Inspired by https://gist.github.com/1049426 |
|
20 | 20 | */ |
|
21 | 21 | String.prototype.format = function() { |
|
22 | ||
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 | ||
|
29 | // For each {0} {1} {n...} replace with the argument in that position. If | |
|
30 | // the argument is an object or an array it will be stringified to JSON. | |
|
31 | for (var i=0; i < len; arg = arguments[i++]) { | |
|
32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; | |
|
33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); | |
|
34 | } | |
|
35 | return str; | |
|
36 | } | |
|
22 | ||
|
23 | function format() { | |
|
24 | var str = this; | |
|
25 | var len = arguments.length+1; | |
|
26 | var safe = undefined; | |
|
27 | var arg = undefined; | |
|
37 | 28 | |
|
38 | // Save a reference of what may already exist under the property native. | |
|
39 | // Allows for doing something like: if("".format.native) { /* use native */ } | |
|
40 | format.native = String.prototype.format; | |
|
29 | // For each {0} {1} {n...} replace with the argument in that position. If | |
|
30 | // the argument is an object or an array it will be stringified to JSON. | |
|
31 | for (var i=0; i < len; arg = arguments[i++]) { | |
|
32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; | |
|
33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); | |
|
34 | } | |
|
35 | return str; | |
|
36 | } | |
|
41 | 37 | |
|
42 | // Replace the prototype property | |
|
43 | return format; | |
|
38 | // Save a reference of what may already exist under the property native. | |
|
39 | // Allows for doing something like: if("".format.native) { /* use native */ } | |
|
40 | format.native = String.prototype.format; | |
|
41 | ||
|
42 | // Replace the prototype property | |
|
43 | return format; | |
|
44 | 44 | |
|
45 | 45 | }(); |
|
46 | 46 | |
|
47 | 47 | String.prototype.strip = function(char) { |
|
48 |
|
|
|
49 |
|
|
|
50 | } | |
|
51 |
|
|
|
48 | if(char === undefined){ | |
|
49 | char = '\\s'; | |
|
50 | } | |
|
51 | return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); | |
|
52 | 52 | } |
|
53 | 53 | String.prototype.lstrip = function(char) { |
|
54 |
|
|
|
55 |
|
|
|
56 | } | |
|
57 |
|
|
|
54 | if(char === undefined){ | |
|
55 | char = '\\s'; | |
|
56 | } | |
|
57 | return this.replace(new RegExp('^'+char+'+'),''); | |
|
58 | 58 | } |
|
59 | 59 | String.prototype.rstrip = function(char) { |
|
60 |
|
|
|
61 |
|
|
|
62 | } | |
|
63 |
|
|
|
60 | if(char === undefined){ | |
|
61 | char = '\\s'; | |
|
62 | } | |
|
63 | return this.replace(new RegExp(''+char+'+$'),''); | |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | |
@@ -90,30 +90,30 b' var prevElementSibling = function( el ) ' | |||
|
90 | 90 | * SmartColorGenerator |
|
91 | 91 | * |
|
92 | 92 | *usage:: |
|
93 |
* |
|
|
93 | * var CG = new ColorGenerator(); | |
|
94 | 94 | * var col = CG.getColor(key); //returns array of RGB |
|
95 | 95 | * 'rgb({0})'.format(col.join(',') |
|
96 |
* |
|
|
96 | * | |
|
97 | 97 | * @returns {ColorGenerator} |
|
98 | 98 | */ |
|
99 | 99 | var ColorGenerator = function(){ |
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
100 | this.GOLDEN_RATIO = 0.618033988749895; | |
|
101 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random | |
|
102 | this.HSV_1 = 0.75;//saturation | |
|
103 | this.HSV_2 = 0.95; | |
|
104 | this.color; | |
|
105 | this.cacheColorMap = {}; | |
|
106 | 106 | }; |
|
107 | 107 | |
|
108 | 108 | ColorGenerator.prototype = { |
|
109 | 109 | getColor:function(key){ |
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
110 | if(this.cacheColorMap[key] !== undefined){ | |
|
111 | return this.cacheColorMap[key]; | |
|
112 | } | |
|
113 | else{ | |
|
114 | this.cacheColorMap[key] = this.generateColor(); | |
|
115 | return this.cacheColorMap[key]; | |
|
116 | } | |
|
117 | 117 | }, |
|
118 | 118 | _hsvToRgb:function(h,s,v){ |
|
119 | 119 | if (s == 0.0) |
@@ -124,18 +124,18 b' ColorGenerator.prototype = {' | |||
|
124 | 124 | q = v * (1.0 - s * f) |
|
125 | 125 | t = v * (1.0 - s * (1.0 - f)) |
|
126 | 126 | i = i % 6 |
|
127 |
if (i == 0) |
|
|
127 | if (i == 0) | |
|
128 | 128 | return [v, t, p] |
|
129 |
if (i == 1) |
|
|
129 | if (i == 1) | |
|
130 | 130 | return [q, v, p] |
|
131 |
if (i == 2) |
|
|
131 | if (i == 2) | |
|
132 | 132 | return [p, v, t] |
|
133 | 133 | if (i == 3) |
|
134 | 134 | return [p, q, v] |
|
135 |
if (i == 4) |
|
|
135 | if (i == 4) | |
|
136 | 136 | return [t, p, v] |
|
137 | 137 | if (i == 5) |
|
138 |
return [v, p, q] |
|
|
138 | return [v, p, q] | |
|
139 | 139 | }, |
|
140 | 140 | generateColor:function(){ |
|
141 | 141 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
@@ -143,20 +143,20 b' ColorGenerator.prototype = {' | |||
|
143 | 143 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] |
|
144 | 144 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
|
145 | 145 | function toRgb(v){ |
|
146 |
|
|
|
146 | return ""+parseInt(v*256) | |
|
147 | 147 | } |
|
148 | 148 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
|
149 | ||
|
149 | ||
|
150 | 150 | } |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | 153 | /** |
|
154 | 154 | * PyRoutesJS |
|
155 |
* |
|
|
155 | * | |
|
156 | 156 | * Usage pyroutes.url('mark_error_fixed',{"error_id":error_id}) // /mark_error_fixed/<error_id> |
|
157 | 157 | */ |
|
158 | 158 | var pyroutes = (function() { |
|
159 |
|
|
|
159 | // access global map defined in special file pyroutes | |
|
160 | 160 | var matchlist = PROUTES_MAP; |
|
161 | 161 | var sprintf = (function() { |
|
162 | 162 | function get_type(variable) { |
@@ -285,7 +285,7 b' var pyroutes = (function() {' | |||
|
285 | 285 | 'url': function(route_name, params) { |
|
286 | 286 | var result = route_name; |
|
287 | 287 | if (typeof(params) != 'object'){ |
|
288 |
|
|
|
288 | params = {}; | |
|
289 | 289 | } |
|
290 | 290 | if (matchlist.hasOwnProperty(route_name)) { |
|
291 | 291 | var route = matchlist[route_name]; |
@@ -296,40 +296,40 b' var pyroutes = (function() {' | |||
|
296 | 296 | throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation'); |
|
297 | 297 | } |
|
298 | 298 | result = sprintf(route[0], params); |
|
299 | ||
|
299 | ||
|
300 | 300 | var ret = []; |
|
301 | 301 | //extra params => GET |
|
302 | 302 | for(param in params){ |
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
|
303 | if (route[1].indexOf(param) == -1){ | |
|
304 | ret.push(encodeURIComponent(param) + "=" + encodeURIComponent(params[param])); | |
|
305 | } | |
|
306 | 306 | } |
|
307 | 307 | var _parts = ret.join("&"); |
|
308 | 308 | if(_parts){ |
|
309 |
|
|
|
309 | result = result +'?'+ _parts | |
|
310 | 310 | } |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | return result; |
|
314 | 314 | }, |
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 | } | |
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 | } | |
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 | ] | |
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
315 | 'register': function(route_name, route_tmpl, req_params) { | |
|
316 | if (typeof(req_params) != 'object') { | |
|
317 | req_params = []; | |
|
318 | } | |
|
319 | //fix escape | |
|
320 | route_tmpl = unescape(route_tmpl); | |
|
321 | keys = []; | |
|
322 | for (o in req_params){ | |
|
323 | keys.push(req_params[o]) | |
|
324 | } | |
|
325 | matchlist[route_name] = [ | |
|
326 | route_tmpl, | |
|
327 | keys | |
|
328 | ] | |
|
329 | }, | |
|
330 | '_routes': function(){ | |
|
331 | return matchlist; | |
|
332 | } | |
|
333 | 333 | } |
|
334 | 334 | })(); |
|
335 | 335 | |
@@ -345,31 +345,31 b' var YUQ = YAHOO.util.Selector.query;' | |||
|
345 | 345 | |
|
346 | 346 | // defines if push state is enabled for this browser ? |
|
347 | 347 | var push_state_enabled = Boolean( |
|
348 |
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
|
353 | ) | |
|
348 | window.history && window.history.pushState && window.history.replaceState | |
|
349 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ | |
|
350 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) | |
|
351 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ | |
|
352 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) | |
|
353 | ) | |
|
354 | 354 | ); |
|
355 | 355 | |
|
356 | 356 | var _run_callbacks = function(callbacks){ |
|
357 |
|
|
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
|
|
|
364 |
|
|
|
365 | } | |
|
366 |
|
|
|
367 | } | |
|
357 | if (callbacks !== undefined){ | |
|
358 | var _l = callbacks.length; | |
|
359 | for (var i=0;i<_l;i++){ | |
|
360 | var func = callbacks[i]; | |
|
361 | if(typeof(func)=='function'){ | |
|
362 | try{ | |
|
363 | func(); | |
|
364 | }catch (err){}; | |
|
365 | } | |
|
366 | } | |
|
367 | } | |
|
368 | 368 | } |
|
369 | 369 | |
|
370 | 370 | /** |
|
371 | 371 | * Partial Ajax Implementation |
|
372 |
* |
|
|
372 | * | |
|
373 | 373 | * @param url: defines url to make partial request |
|
374 | 374 | * @param container: defines id of container to input partial result |
|
375 | 375 | * @param s_call: success callback function that takes o as arg |
@@ -382,44 +382,44 b' var _run_callbacks = function(callbacks)' | |||
|
382 | 382 | * o.responseXML |
|
383 | 383 | * o.argument |
|
384 | 384 | * @param f_call: failure callback |
|
385 |
* @param args arguments |
|
|
385 | * @param args arguments | |
|
386 | 386 | */ |
|
387 | 387 | function ypjax(url,container,s_call,f_call,args){ |
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
|
391 | } | |
|
392 | ||
|
393 |
|
|
|
394 |
|
|
|
395 | ||
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
|
403 |
|
|
|
404 | } | |
|
405 | } | |
|
406 | })() | |
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
|
414 | }, | |
|
415 |
|
|
|
416 |
|
|
|
417 | ||
|
388 | var method='GET'; | |
|
389 | if(args===undefined){ | |
|
390 | args=null; | |
|
391 | } | |
|
392 | ||
|
393 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR | |
|
394 | YUC.initHeader('X-PARTIAL-XHR',true); | |
|
395 | ||
|
396 | // wrapper of passed callback | |
|
397 | var s_wrapper = (function(o){ | |
|
398 | return function(o){ | |
|
399 | YUD.get(container).innerHTML=o.responseText; | |
|
400 | YUD.setStyle(container,'opacity','1.0'); | |
|
401 | //execute the given original callback | |
|
402 | if (s_call !== undefined){ | |
|
403 | s_call(o); | |
|
404 | } | |
|
405 | } | |
|
406 | })() | |
|
407 | YUD.setStyle(container,'opacity','0.3'); | |
|
408 | YUC.asyncRequest(method,url,{ | |
|
409 | success:s_wrapper, | |
|
410 | failure:function(o){ | |
|
411 | console.log(o); | |
|
412 | YUD.get(container).innerHTML='<span class="error_red">ERROR: {0}</span>'.format(o.status); | |
|
413 | YUD.setStyle(container,'opacity','1.0'); | |
|
414 | }, | |
|
415 | cache:false | |
|
416 | },args); | |
|
417 | ||
|
418 | 418 | }; |
|
419 | 419 | |
|
420 | 420 | var ajaxGET = function(url,success) { |
|
421 |
|
|
|
422 |
|
|
|
421 | // Set special header for ajax == HTTP_X_PARTIAL_XHR | |
|
422 | YUC.initHeader('X-PARTIAL-XHR',true); | |
|
423 | 423 | |
|
424 | 424 | var sUrl = url; |
|
425 | 425 | var callback = { |
@@ -438,20 +438,20 b' var ajaxGET = function(url,success) {' | |||
|
438 | 438 | |
|
439 | 439 | |
|
440 | 440 | var ajaxPOST = function(url,postData,success) { |
|
441 |
|
|
|
442 |
|
|
|
443 | ||
|
444 |
|
|
|
445 |
|
|
|
446 |
|
|
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
453 | }; | |
|
454 | ||
|
441 | // Set special header for ajax == HTTP_X_PARTIAL_XHR | |
|
442 | YUC.initHeader('X-PARTIAL-XHR',true); | |
|
443 | ||
|
444 | var toQueryString = function(o) { | |
|
445 | if(typeof o !== 'object') { | |
|
446 | return false; | |
|
447 | } | |
|
448 | var _p, _qs = []; | |
|
449 | for(_p in o) { | |
|
450 | _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p])); | |
|
451 | } | |
|
452 | return _qs.join('&'); | |
|
453 | }; | |
|
454 | ||
|
455 | 455 | var sUrl = url; |
|
456 | 456 | var callback = { |
|
457 | 457 | success: success, |
@@ -469,8 +469,8 b' var ajaxPOST = function(url,postData,suc' | |||
|
469 | 469 | * tooltip activate |
|
470 | 470 | */ |
|
471 | 471 | var tooltip_activate = function(){ |
|
472 |
|
|
|
473 |
|
|
|
472 | yt = YAHOO.yuitip.main; | |
|
473 | YUE.onDOMReady(yt.init); | |
|
474 | 474 | }; |
|
475 | 475 | |
|
476 | 476 | /** |
@@ -488,26 +488,26 b' var show_more_event = function(){' | |||
|
488 | 488 | * show changeset tooltip |
|
489 | 489 | */ |
|
490 | 490 | var show_changeset_tooltip = function(){ |
|
491 |
|
|
|
492 |
|
|
|
493 |
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
|
|
|
499 |
|
|
|
500 |
|
|
|
501 | } | |
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
509 | } | |
|
510 | }); | |
|
491 | YUE.on(YUD.getElementsByClassName('lazy-cs'), 'mouseover', function(e){ | |
|
492 | var target = e.currentTarget; | |
|
493 | var rid = YUD.getAttribute(target,'raw_id'); | |
|
494 | var repo_name = YUD.getAttribute(target,'repo_name'); | |
|
495 | var ttid = 'tt-'+rid; | |
|
496 | var success = function(o){ | |
|
497 | var json = JSON.parse(o.responseText); | |
|
498 | YUD.addClass(target,'tooltip') | |
|
499 | YUD.setAttribute(target, 'title',json['message']); | |
|
500 | YAHOO.yuitip.main.show_yuitip(e, target); | |
|
501 | } | |
|
502 | if(rid && !YUD.hasClass(target, 'tooltip')){ | |
|
503 | YUD.setAttribute(target,'id',ttid); | |
|
504 | YUD.setAttribute(target, 'title',_TM['loading...']); | |
|
505 | YAHOO.yuitip.main.set_listeners(target); | |
|
506 | YAHOO.yuitip.main.show_yuitip(e, target); | |
|
507 | var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid}); | |
|
508 | ajaxGET(url, success) | |
|
509 | } | |
|
510 | }); | |
|
511 | 511 | }; |
|
512 | 512 | |
|
513 | 513 | var onSuccessFollow = function(target){ |
@@ -541,7 +541,7 b' var toggleFollowingUser = function(targe' | |||
|
541 | 541 | } |
|
542 | 542 | YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{ |
|
543 | 543 | success:function(o){ |
|
544 |
|
|
|
544 | onSuccessFollow(target); | |
|
545 | 545 | } |
|
546 | 546 | },args); |
|
547 | 547 | return false; |
@@ -556,7 +556,7 b' var toggleFollowingRepo = function(targe' | |||
|
556 | 556 | } |
|
557 | 557 | YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{ |
|
558 | 558 | success:function(o){ |
|
559 |
|
|
|
559 | onSuccessFollow(target); | |
|
560 | 560 | } |
|
561 | 561 | },args); |
|
562 | 562 | return false; |
@@ -564,18 +564,18 b' var toggleFollowingRepo = function(targe' | |||
|
564 | 564 | |
|
565 | 565 | var showRepoSize = function(target, repo_name, token){ |
|
566 | 566 | var args= 'auth_token='+token; |
|
567 | ||
|
567 | ||
|
568 | 568 | if(!YUD.hasClass(target, 'loaded')){ |
|
569 | 569 | YUD.get(target).innerHTML = _TM['Loading ...']; |
|
570 | 570 | var url = pyroutes.url('repo_size', {"repo_name":repo_name}); |
|
571 | 571 | YUC.asyncRequest('POST',url,{ |
|
572 | 572 | success:function(o){ |
|
573 |
|
|
|
574 |
|
|
|
573 | YUD.get(target).innerHTML = JSON.parse(o.responseText); | |
|
574 | YUD.addClass(target, 'loaded'); | |
|
575 | 575 | } |
|
576 |
},args); |
|
|
576 | },args); | |
|
577 | 577 | } |
|
578 |
return false; |
|
|
578 | return false; | |
|
579 | 579 | } |
|
580 | 580 | |
|
581 | 581 | /** |
@@ -584,207 +584,207 b' var showRepoSize = function(target, repo' | |||
|
584 | 584 | YAHOO.namespace('yuitip'); |
|
585 | 585 | YAHOO.yuitip.main = { |
|
586 | 586 | |
|
587 |
|
|
|
587 | $: YAHOO.util.Dom.get, | |
|
588 | 588 | |
|
589 |
|
|
|
590 |
|
|
|
591 |
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
|
|
|
595 |
|
|
|
596 |
|
|
|
589 | bgColor: '#000', | |
|
590 | speed: 0.3, | |
|
591 | opacity: 0.9, | |
|
592 | offset: [15,15], | |
|
593 | useAnim: false, | |
|
594 | maxWidth: 600, | |
|
595 | add_links: false, | |
|
596 | yuitips: [], | |
|
597 | 597 | |
|
598 |
|
|
|
599 |
|
|
|
600 |
|
|
|
601 |
|
|
|
602 | }, | |
|
598 | set_listeners: function(tt){ | |
|
599 | YUE.on(tt, 'mouseover', yt.show_yuitip, tt); | |
|
600 | YUE.on(tt, 'mousemove', yt.move_yuitip, tt); | |
|
601 | YUE.on(tt, 'mouseout', yt.close_yuitip, tt); | |
|
602 | }, | |
|
603 | 603 | |
|
604 |
|
|
|
605 |
|
|
|
606 |
|
|
|
607 |
|
|
|
608 |
|
|
|
609 |
|
|
|
610 | } | |
|
604 | init: function(){ | |
|
605 | yt.tipBox = yt.$('tip-box'); | |
|
606 | if(!yt.tipBox){ | |
|
607 | yt.tipBox = document.createElement('div'); | |
|
608 | document.body.appendChild(yt.tipBox); | |
|
609 | yt.tipBox.id = 'tip-box'; | |
|
610 | } | |
|
611 | 611 | |
|
612 |
|
|
|
613 |
|
|
|
614 |
|
|
|
615 |
|
|
|
616 | } | |
|
612 | YUD.setStyle(yt.tipBox, 'display', 'none'); | |
|
613 | YUD.setStyle(yt.tipBox, 'position', 'absolute'); | |
|
614 | if(yt.maxWidth !== null){ | |
|
615 | YUD.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px'); | |
|
616 | } | |
|
617 | 617 | |
|
618 |
|
|
|
618 | var yuitips = YUD.getElementsByClassName('tooltip'); | |
|
619 | 619 | |
|
620 |
|
|
|
621 |
|
|
|
622 |
|
|
|
623 |
|
|
|
624 |
|
|
|
625 | } | |
|
626 | } | |
|
620 | if(yt.add_links === true){ | |
|
621 | var links = document.getElementsByTagName('a'); | |
|
622 | var linkLen = links.length; | |
|
623 | for(i=0;i<linkLen;i++){ | |
|
624 | yuitips.push(links[i]); | |
|
625 | } | |
|
626 | } | |
|
627 | 627 | |
|
628 |
|
|
|
628 | var yuiLen = yuitips.length; | |
|
629 | 629 | |
|
630 |
|
|
|
631 |
|
|
|
632 | } | |
|
633 | }, | |
|
630 | for(i=0;i<yuiLen;i++){ | |
|
631 | yt.set_listeners(yuitips[i]); | |
|
632 | } | |
|
633 | }, | |
|
634 | 634 | |
|
635 |
|
|
|
636 |
|
|
|
637 |
|
|
|
638 |
|
|
|
639 |
|
|
|
640 |
|
|
|
641 | } | |
|
635 | show_yuitip: function(e, el){ | |
|
636 | YUE.stopEvent(e); | |
|
637 | if(el.tagName.toLowerCase() === 'img'){ | |
|
638 | yt.tipText = el.alt ? el.alt : ''; | |
|
639 | } else { | |
|
640 | yt.tipText = el.title ? el.title : ''; | |
|
641 | } | |
|
642 | 642 | |
|
643 |
|
|
|
644 |
|
|
|
645 |
|
|
|
646 |
|
|
|
647 |
|
|
|
643 | if(yt.tipText !== ''){ | |
|
644 | // save org title | |
|
645 | YUD.setAttribute(el, 'tt_title', yt.tipText); | |
|
646 | // reset title to not show org tooltips | |
|
647 | YUD.setAttribute(el, 'title', ''); | |
|
648 | 648 | |
|
649 |
|
|
|
650 |
|
|
|
651 |
|
|
|
652 |
|
|
|
653 |
|
|
|
654 | { | |
|
655 |
|
|
|
656 |
|
|
|
657 | ); | |
|
658 |
|
|
|
659 | } | |
|
660 | } | |
|
661 | }, | |
|
649 | yt.tipBox.innerHTML = yt.tipText; | |
|
650 | YUD.setStyle(yt.tipBox, 'display', 'block'); | |
|
651 | if(yt.useAnim === true){ | |
|
652 | YUD.setStyle(yt.tipBox, 'opacity', '0'); | |
|
653 | var newAnim = new YAHOO.util.Anim(yt.tipBox, | |
|
654 | { | |
|
655 | opacity: { to: yt.opacity } | |
|
656 | }, yt.speed, YAHOO.util.Easing.easeOut | |
|
657 | ); | |
|
658 | newAnim.animate(); | |
|
659 | } | |
|
660 | } | |
|
661 | }, | |
|
662 | 662 | |
|
663 |
|
|
|
664 |
|
|
|
665 |
|
|
|
666 |
|
|
|
667 |
|
|
|
668 | }, | |
|
663 | move_yuitip: function(e, el){ | |
|
664 | YUE.stopEvent(e); | |
|
665 | var movePos = YUE.getXY(e); | |
|
666 | YUD.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px'); | |
|
667 | YUD.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px'); | |
|
668 | }, | |
|
669 | ||
|
670 | close_yuitip: function(e, el){ | |
|
671 | YUE.stopEvent(e); | |
|
669 | 672 | |
|
670 | close_yuitip: function(e, el){ | |
|
671 | YUE.stopEvent(e); | |
|
672 | ||
|
673 | if(yt.useAnim === true){ | |
|
674 | var newAnim = new YAHOO.util.Anim(yt.tipBox, | |
|
675 | { | |
|
676 | opacity: { to: 0 } | |
|
677 | }, yt.speed, YAHOO.util.Easing.easeOut | |
|
678 | ); | |
|
679 | newAnim.animate(); | |
|
680 | } else { | |
|
681 | YUD.setStyle(yt.tipBox, 'display', 'none'); | |
|
682 | } | |
|
683 | YUD.setAttribute(el,'title', YUD.getAttribute(el, 'tt_title')); | |
|
684 | } | |
|
673 | if(yt.useAnim === true){ | |
|
674 | var newAnim = new YAHOO.util.Anim(yt.tipBox, | |
|
675 | { | |
|
676 | opacity: { to: 0 } | |
|
677 | }, yt.speed, YAHOO.util.Easing.easeOut | |
|
678 | ); | |
|
679 | newAnim.animate(); | |
|
680 | } else { | |
|
681 | YUD.setStyle(yt.tipBox, 'display', 'none'); | |
|
682 | } | |
|
683 | YUD.setAttribute(el,'title', YUD.getAttribute(el, 'tt_title')); | |
|
684 | } | |
|
685 | 685 | } |
|
686 | 686 | |
|
687 | 687 | /** |
|
688 | 688 | * Quick filter widget |
|
689 |
* |
|
|
689 | * | |
|
690 | 690 | * @param target: filter input target |
|
691 | 691 | * @param nodes: list of nodes in html we want to filter. |
|
692 | 692 | * @param display_element function that takes current node from nodes and |
|
693 | 693 | * does hide or show based on the node |
|
694 |
* |
|
|
694 | * | |
|
695 | 695 | */ |
|
696 | 696 | var q_filter = function(target,nodes,display_element){ |
|
697 | ||
|
698 |
|
|
|
699 |
|
|
|
700 |
|
|
|
697 | ||
|
698 | var nodes = nodes; | |
|
699 | var q_filter_field = YUD.get(target); | |
|
700 | var F = YAHOO.namespace(target); | |
|
701 | ||
|
702 | YUE.on(q_filter_field,'keyup',function(e){ | |
|
703 | clearTimeout(F.filterTimeout); | |
|
704 | F.filterTimeout = setTimeout(F.updateFilter,600); | |
|
705 | }); | |
|
706 | ||
|
707 | F.filterTimeout = null; | |
|
701 | 708 | |
|
702 | YUE.on(q_filter_field,'keyup',function(e){ | |
|
703 | clearTimeout(F.filterTimeout); | |
|
704 | F.filterTimeout = setTimeout(F.updateFilter,600); | |
|
705 | }); | |
|
709 | var show_node = function(node){ | |
|
710 | YUD.setStyle(node,'display','') | |
|
711 | } | |
|
712 | var hide_node = function(node){ | |
|
713 | YUD.setStyle(node,'display','none'); | |
|
714 | } | |
|
706 | 715 | |
|
707 | F.filterTimeout = null; | |
|
716 | F.updateFilter = function() { | |
|
717 | // Reset timeout | |
|
718 | F.filterTimeout = null; | |
|
719 | ||
|
720 | var obsolete = []; | |
|
708 | 721 | |
|
709 | var show_node = function(node){ | |
|
710 | YUD.setStyle(node,'display','') | |
|
711 | } | |
|
712 | var hide_node = function(node){ | |
|
713 | YUD.setStyle(node,'display','none'); | |
|
714 | } | |
|
715 | ||
|
716 | F.updateFilter = function() { | |
|
717 | // Reset timeout | |
|
718 | F.filterTimeout = null; | |
|
719 | ||
|
720 | var obsolete = []; | |
|
721 | ||
|
722 | var req = q_filter_field.value.toLowerCase(); | |
|
723 | ||
|
724 | var l = nodes.length; | |
|
725 | var i; | |
|
726 | var showing = 0; | |
|
727 | ||
|
722 | var req = q_filter_field.value.toLowerCase(); | |
|
723 | ||
|
724 | var l = nodes.length; | |
|
725 | var i; | |
|
726 | var showing = 0; | |
|
727 | ||
|
728 | 728 | for (i=0;i<l;i++ ){ |
|
729 |
|
|
|
730 |
|
|
|
731 |
|
|
|
732 |
|
|
|
733 |
|
|
|
734 |
|
|
|
735 |
|
|
|
736 |
|
|
|
737 |
|
|
|
738 |
} |
|
|
729 | var n = nodes[i]; | |
|
730 | var target_element = display_element(n) | |
|
731 | if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ | |
|
732 | hide_node(target_element); | |
|
733 | } | |
|
734 | else{ | |
|
735 | show_node(target_element); | |
|
736 | showing+=1; | |
|
737 | } | |
|
738 | } | |
|
739 | 739 | |
|
740 |
|
|
|
741 |
|
|
|
742 |
|
|
|
743 |
|
|
|
744 |
|
|
|
745 | ||
|
746 | } | |
|
740 | // if repo_count is set update the number | |
|
741 | var cnt = YUD.get('repo_count'); | |
|
742 | if(cnt){ | |
|
743 | YUD.get('repo_count').innerHTML = showing; | |
|
744 | } | |
|
745 | ||
|
746 | } | |
|
747 | 747 | }; |
|
748 | 748 | |
|
749 | 749 | var tableTr = function(cls, body){ |
|
750 |
|
|
|
751 |
|
|
|
752 |
|
|
|
753 |
|
|
|
754 |
|
|
|
755 |
|
|
|
756 |
|
|
|
750 | var _el = document.createElement('div'); | |
|
751 | var cont = new YAHOO.util.Element(body); | |
|
752 | var comment_id = fromHTML(body).children[0].id.split('comment-')[1]; | |
|
753 | var id = 'comment-tr-{0}'.format(comment_id); | |
|
754 | var _html = ('<table><tbody><tr id="{0}" class="{1}">'+ | |
|
755 | '<td class="lineno-inline new-inline"></td>'+ | |
|
756 | '<td class="lineno-inline old-inline"></td>'+ | |
|
757 | 757 | '<td>{2}</td>'+ |
|
758 | 758 | '</tr></tbody></table>').format(id, cls, body); |
|
759 |
|
|
|
760 |
|
|
|
759 | _el.innerHTML = _html; | |
|
760 | return _el.children[0].children[0].children[0]; | |
|
761 | 761 | }; |
|
762 | 762 | |
|
763 | 763 | /** comments **/ |
|
764 | 764 | var removeInlineForm = function(form) { |
|
765 |
|
|
|
765 | form.parentNode.removeChild(form); | |
|
766 | 766 | }; |
|
767 | 767 | |
|
768 | 768 | var createInlineForm = function(parent_tr, f_path, line) { |
|
769 |
|
|
|
770 |
|
|
|
771 |
|
|
|
769 | var tmpl = YUD.get('comment-inline-form-template').innerHTML; | |
|
770 | tmpl = tmpl.format(f_path, line); | |
|
771 | var form = tableTr('comment-form-inline',tmpl) | |
|
772 | 772 | |
|
773 |
|
|
|
774 |
|
|
|
775 |
|
|
|
776 |
|
|
|
777 |
|
|
|
778 |
|
|
|
779 |
|
|
|
780 | } | |
|
781 |
|
|
|
782 |
|
|
|
783 |
|
|
|
784 | ||
|
785 | }); | |
|
786 | ||
|
787 |
|
|
|
773 | // create event for hide button | |
|
774 | form = new YAHOO.util.Element(form); | |
|
775 | var form_hide_button = new YAHOO.util.Element(YUD.getElementsByClassName('hide-inline-form',null,form)[0]); | |
|
776 | form_hide_button.on('click', function(e) { | |
|
777 | var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; | |
|
778 | if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){ | |
|
779 | YUD.setStyle(newtr.nextElementSibling,'display',''); | |
|
780 | } | |
|
781 | removeInlineForm(newtr); | |
|
782 | YUD.removeClass(parent_tr, 'form-open'); | |
|
783 | YUD.removeClass(parent_tr, 'hl-comment'); | |
|
784 | ||
|
785 | }); | |
|
786 | ||
|
787 | return form | |
|
788 | 788 | }; |
|
789 | 789 | |
|
790 | 790 | /** |
@@ -793,116 +793,116 b' var createInlineForm = function(parent_t' | |||
|
793 | 793 | * block at the very bottom |
|
794 | 794 | */ |
|
795 | 795 | var injectInlineForm = function(tr){ |
|
796 |
|
|
|
797 |
|
|
|
798 | } | |
|
799 |
|
|
|
800 |
|
|
|
801 |
|
|
|
802 |
|
|
|
803 | } | |
|
804 |
|
|
|
805 |
|
|
|
806 |
|
|
|
807 |
|
|
|
808 |
|
|
|
809 |
|
|
|
810 | ||
|
811 |
|
|
|
812 |
|
|
|
813 |
|
|
|
814 |
|
|
|
815 |
|
|
|
816 |
|
|
|
817 | } | |
|
818 | else{ | |
|
819 | break; | |
|
820 | } | |
|
821 | } | |
|
822 |
|
|
|
823 |
|
|
|
824 |
|
|
|
825 |
|
|
|
826 | ||
|
827 |
|
|
|
828 |
|
|
|
829 | ||
|
830 |
|
|
|
831 |
|
|
|
832 |
|
|
|
833 |
|
|
|
834 |
|
|
|
835 |
|
|
|
836 | }; | |
|
837 | ||
|
838 |
|
|
|
839 |
|
|
|
840 | return | |
|
841 | } | |
|
842 |
|
|
|
843 |
|
|
|
844 | return | |
|
845 | } | |
|
846 | ||
|
847 | if(text == ""){ | |
|
848 | return | |
|
849 | } | |
|
850 | ||
|
851 | var success = function(o){ | |
|
852 | YUD.removeClass(tr, 'form-open'); | |
|
853 | removeInlineForm(f); | |
|
854 | var json_data = JSON.parse(o.responseText); | |
|
855 | renderInlineComment(json_data); | |
|
856 | }; | |
|
796 | if(!YUD.hasClass(tr, 'line')){ | |
|
797 | return | |
|
798 | } | |
|
799 | var submit_url = AJAX_COMMENT_URL; | |
|
800 | var _td = YUD.getElementsByClassName('code',null,tr)[0]; | |
|
801 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ | |
|
802 | return | |
|
803 | } | |
|
804 | YUD.addClass(tr,'form-open'); | |
|
805 | YUD.addClass(tr,'hl-comment'); | |
|
806 | var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0]; | |
|
807 | var f_path = YUD.getAttribute(node,'path'); | |
|
808 | var lineno = getLineNo(tr); | |
|
809 | var form = createInlineForm(tr, f_path, lineno, submit_url); | |
|
810 | ||
|
811 | var parent = tr; | |
|
812 | while (1){ | |
|
813 | var n = parent.nextElementSibling; | |
|
814 | // next element are comments ! | |
|
815 | if(YUD.hasClass(n,'inline-comments')){ | |
|
816 | parent = n; | |
|
817 | } | |
|
818 | else{ | |
|
819 | break; | |
|
820 | } | |
|
821 | } | |
|
822 | YUD.insertAfter(form,parent); | |
|
823 | var f = YUD.get(form); | |
|
824 | var overlay = YUD.getElementsByClassName('overlay',null,f)[0]; | |
|
825 | var _form = YUD.getElementsByClassName('inline-form',null,f)[0]; | |
|
826 | ||
|
827 | YUE.on(YUD.get(_form), 'submit',function(e){ | |
|
828 | YUE.preventDefault(e); | |
|
829 | ||
|
830 | //ajax submit | |
|
831 | var text = YUD.get('text_'+lineno).value; | |
|
832 | var postData = { | |
|
833 | 'text':text, | |
|
834 | 'f_path':f_path, | |
|
835 | 'line':lineno | |
|
836 | }; | |
|
837 | ||
|
838 | if(lineno === undefined){ | |
|
839 | alert('missing line !'); | |
|
840 | return | |
|
841 | } | |
|
842 | if(f_path === undefined){ | |
|
843 | alert('missing file path !'); | |
|
844 | return | |
|
845 | } | |
|
857 | 846 | |
|
858 | if (YUD.hasClass(overlay,'overlay')){ | |
|
859 | var w = _form.offsetWidth; | |
|
860 | var h = _form.offsetHeight; | |
|
861 | YUD.setStyle(overlay,'width',w+'px'); | |
|
862 | YUD.setStyle(overlay,'height',h+'px'); | |
|
863 | } | |
|
864 | YUD.addClass(overlay, 'submitting'); | |
|
865 | ||
|
866 | ajaxPOST(submit_url, postData, success); | |
|
867 | }); | |
|
847 | if(text == ""){ | |
|
848 | return | |
|
849 | } | |
|
850 | ||
|
851 | var success = function(o){ | |
|
852 | YUD.removeClass(tr, 'form-open'); | |
|
853 | removeInlineForm(f); | |
|
854 | var json_data = JSON.parse(o.responseText); | |
|
855 | renderInlineComment(json_data); | |
|
856 | }; | |
|
868 | 857 | |
|
869 | YUE.on('preview-btn_'+lineno, 'click', function(e){ | |
|
870 | var _text = YUD.get('text_'+lineno).value; | |
|
871 | if(!_text){ | |
|
872 | return | |
|
873 | } | |
|
874 | var post_data = {'text': _text}; | |
|
875 | YUD.addClass('preview-box_'+lineno, 'unloaded'); | |
|
876 | YUD.get('preview-box_'+lineno).innerHTML = _TM['Loading ...']; | |
|
877 | YUD.setStyle('edit-container_'+lineno, 'display', 'none'); | |
|
878 | YUD.setStyle('preview-container_'+lineno, 'display', ''); | |
|
858 | if (YUD.hasClass(overlay,'overlay')){ | |
|
859 | var w = _form.offsetWidth; | |
|
860 | var h = _form.offsetHeight; | |
|
861 | YUD.setStyle(overlay,'width',w+'px'); | |
|
862 | YUD.setStyle(overlay,'height',h+'px'); | |
|
863 | } | |
|
864 | YUD.addClass(overlay, 'submitting'); | |
|
865 | ||
|
866 | ajaxPOST(submit_url, postData, success); | |
|
867 | }); | |
|
879 | 868 | |
|
880 | var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); | |
|
881 | ajaxPOST(url,post_data,function(o){ | |
|
882 | YUD.get('preview-box_'+lineno).innerHTML = o.responseText; | |
|
883 | YUD.removeClass('preview-box_'+lineno, 'unloaded'); | |
|
884 |
|
|
|
885 | }) | |
|
886 | YUE.on('edit-btn_'+lineno, 'click', function(e){ | |
|
887 | YUD.setStyle('edit-container_'+lineno, 'display', ''); | |
|
888 |
|
|
|
889 | }) | |
|
890 | ||
|
891 | ||
|
892 | setTimeout(function(){ | |
|
893 | // callbacks | |
|
894 | tooltip_activate(); | |
|
895 | MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, | |
|
896 | _USERS_AC_DATA, _GROUPS_AC_DATA); | |
|
897 | var _e = YUD.get('text_'+lineno); | |
|
898 | if(_e){ | |
|
899 | _e.focus(); | |
|
900 | } | |
|
901 | },10) | |
|
869 | YUE.on('preview-btn_'+lineno, 'click', function(e){ | |
|
870 | var _text = YUD.get('text_'+lineno).value; | |
|
871 | if(!_text){ | |
|
872 | return | |
|
873 | } | |
|
874 | var post_data = {'text': _text}; | |
|
875 | YUD.addClass('preview-box_'+lineno, 'unloaded'); | |
|
876 | YUD.get('preview-box_'+lineno).innerHTML = _TM['Loading ...']; | |
|
877 | YUD.setStyle('edit-container_'+lineno, 'display', 'none'); | |
|
878 | YUD.setStyle('preview-container_'+lineno, 'display', ''); | |
|
879 | ||
|
880 | var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); | |
|
881 | ajaxPOST(url,post_data,function(o){ | |
|
882 | YUD.get('preview-box_'+lineno).innerHTML = o.responseText; | |
|
883 | YUD.removeClass('preview-box_'+lineno, 'unloaded'); | |
|
884 | }) | |
|
885 | }) | |
|
886 | YUE.on('edit-btn_'+lineno, 'click', function(e){ | |
|
887 | YUD.setStyle('edit-container_'+lineno, 'display', ''); | |
|
888 | YUD.setStyle('preview-container_'+lineno, 'display', 'none'); | |
|
889 | }) | |
|
890 | ||
|
891 | ||
|
892 | setTimeout(function(){ | |
|
893 | // callbacks | |
|
894 | tooltip_activate(); | |
|
895 | MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, | |
|
896 | _USERS_AC_DATA, _GROUPS_AC_DATA); | |
|
897 | var _e = YUD.get('text_'+lineno); | |
|
898 | if(_e){ | |
|
899 | _e.focus(); | |
|
900 | } | |
|
901 | },10) | |
|
902 | 902 | }; |
|
903 | 903 | |
|
904 | 904 | var deleteComment = function(comment_id){ |
|
905 |
|
|
|
905 | var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); | |
|
906 | 906 | var postData = {'_method':'delete'}; |
|
907 | 907 | var success = function(o){ |
|
908 | 908 | var n = YUD.get('comment-tr-'+comment_id); |
@@ -912,7 +912,7 b' var deleteComment = function(comment_id)' | |||
|
912 | 912 | // scann nodes, and attach add button to last one only for TR |
|
913 | 913 | // which are the inline comments |
|
914 | 914 | if(root && root.tagName == 'TR'){ |
|
915 |
|
|
|
915 | placeAddButton(root); | |
|
916 | 916 | } |
|
917 | 917 | } |
|
918 | 918 | ajaxPOST(url,postData,success); |
@@ -920,91 +920,91 b' var deleteComment = function(comment_id)' | |||
|
920 | 920 | |
|
921 | 921 | var createInlineAddButton = function(tr){ |
|
922 | 922 | |
|
923 |
|
|
|
924 | ||
|
925 |
|
|
|
926 |
|
|
|
927 |
|
|
|
928 | ||
|
929 |
|
|
|
930 |
|
|
|
931 |
|
|
|
932 | }); | |
|
933 |
|
|
|
923 | var label = TRANSLATION_MAP['Add another comment']; | |
|
924 | ||
|
925 | var html_el = document.createElement('div'); | |
|
926 | YUD.addClass(html_el, 'add-comment'); | |
|
927 | html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label); | |
|
928 | ||
|
929 | var add = new YAHOO.util.Element(html_el); | |
|
930 | add.on('click', function(e) { | |
|
931 | injectInlineForm(tr); | |
|
932 | }); | |
|
933 | return add; | |
|
934 | 934 | }; |
|
935 | 935 | |
|
936 | 936 | var getLineNo = function(tr) { |
|
937 |
|
|
|
938 |
|
|
|
939 |
|
|
|
937 | var line; | |
|
938 | var o = tr.children[0].id.split('_'); | |
|
939 | var n = tr.children[1].id.split('_'); | |
|
940 | 940 | |
|
941 |
|
|
|
942 |
|
|
|
943 |
|
|
|
944 |
|
|
|
945 | } | |
|
941 | if (n.length >= 2) { | |
|
942 | line = n[n.length-1]; | |
|
943 | } else if (o.length >= 2) { | |
|
944 | line = o[o.length-1]; | |
|
945 | } | |
|
946 | 946 | |
|
947 |
|
|
|
947 | return line | |
|
948 | 948 | }; |
|
949 | 949 | |
|
950 | 950 | var placeAddButton = function(target_tr){ |
|
951 |
|
|
|
952 | return | |
|
953 | } | |
|
954 |
|
|
|
955 |
//scann |
|
|
956 |
|
|
|
957 |
|
|
|
958 |
|
|
|
959 |
|
|
|
960 |
|
|
|
961 |
|
|
|
962 |
|
|
|
963 |
|
|
|
964 |
|
|
|
965 |
|
|
|
966 | } | |
|
967 | } | |
|
968 | else{ | |
|
969 | break; | |
|
970 | } | |
|
971 | } | |
|
972 | ||
|
951 | if(!target_tr){ | |
|
952 | return | |
|
953 | } | |
|
954 | var last_node = target_tr; | |
|
955 | //scann | |
|
956 | while (1){ | |
|
957 | var n = last_node.nextElementSibling; | |
|
958 | // next element are comments ! | |
|
959 | if(YUD.hasClass(n,'inline-comments')){ | |
|
960 | last_node = n; | |
|
961 | //also remove the comment button from previous | |
|
962 | var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node); | |
|
963 | for(var i=0;i<comment_add_buttons.length;i++){ | |
|
964 | var b = comment_add_buttons[i]; | |
|
965 | b.parentNode.removeChild(b); | |
|
966 | } | |
|
967 | } | |
|
968 | else{ | |
|
969 | break; | |
|
970 | } | |
|
971 | } | |
|
972 | ||
|
973 | 973 | var add = createInlineAddButton(target_tr); |
|
974 | 974 | // get the comment div |
|
975 | 975 | var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0]; |
|
976 | 976 | // attach add button |
|
977 |
YUD.insertAfter(add,comment_block); |
|
|
977 | YUD.insertAfter(add,comment_block); | |
|
978 | 978 | } |
|
979 | 979 | |
|
980 | 980 | /** |
|
981 | 981 | * Places the inline comment into the changeset block in proper line position |
|
982 | 982 | */ |
|
983 | 983 | var placeInline = function(target_container,lineno,html){ |
|
984 |
|
|
|
985 |
|
|
|
986 |
|
|
|
987 | ||
|
988 |
|
|
|
989 |
|
|
|
990 |
|
|
|
991 |
|
|
|
992 |
|
|
|
993 |
|
|
|
994 |
|
|
|
995 |
|
|
|
996 | } | |
|
997 | else{ | |
|
998 | break; | |
|
999 | } | |
|
1000 | } | |
|
1001 |
|
|
|
1002 |
|
|
|
1003 | ||
|
1004 |
|
|
|
984 | var lineid = "{0}_{1}".format(target_container,lineno); | |
|
985 | var target_line = YUD.get(lineid); | |
|
986 | var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) | |
|
987 | ||
|
988 | // check if there are comments already ! | |
|
989 | var parent = target_line.parentNode; | |
|
990 | var root_parent = parent; | |
|
991 | while (1){ | |
|
992 | var n = parent.nextElementSibling; | |
|
993 | // next element are comments ! | |
|
994 | if(YUD.hasClass(n,'inline-comments')){ | |
|
995 | parent = n; | |
|
996 | } | |
|
997 | else{ | |
|
998 | break; | |
|
999 | } | |
|
1000 | } | |
|
1001 | // put in the comment at the bottom | |
|
1002 | YUD.insertAfter(comment,parent); | |
|
1003 | ||
|
1004 | // scann nodes, and attach add button to last one | |
|
1005 | 1005 | placeAddButton(root_parent); |
|
1006 | 1006 | |
|
1007 |
|
|
|
1007 | return target_line; | |
|
1008 | 1008 | } |
|
1009 | 1009 | |
|
1010 | 1010 | /** |
@@ -1012,13 +1012,13 b' var placeInline = function(target_contai' | |||
|
1012 | 1012 | */ |
|
1013 | 1013 | var renderInlineComment = function(json_data){ |
|
1014 | 1014 | try{ |
|
1015 |
|
|
|
1016 |
|
|
|
1017 |
|
|
|
1018 |
|
|
|
1015 | var html = json_data['rendered_text']; | |
|
1016 | var lineno = json_data['line_no']; | |
|
1017 | var target_id = json_data['target_id']; | |
|
1018 | placeInline(target_id, lineno, html); | |
|
1019 | 1019 | |
|
1020 | 1020 | }catch(e){ |
|
1021 |
|
|
|
1021 | console.log(e); | |
|
1022 | 1022 | } |
|
1023 | 1023 | } |
|
1024 | 1024 | |
@@ -1026,135 +1026,135 b' var renderInlineComment = function(json_' | |||
|
1026 | 1026 | * Iterates over all the inlines, and places them inside proper blocks of data |
|
1027 | 1027 | */ |
|
1028 | 1028 | var renderInlineComments = function(file_comments){ |
|
1029 |
|
|
|
1029 | for (f in file_comments){ | |
|
1030 | 1030 | // holding all comments for a FILE |
|
1031 |
|
|
|
1031 | var box = file_comments[f]; | |
|
1032 | 1032 | |
|
1033 |
|
|
|
1034 |
|
|
|
1033 | var target_id = YUD.getAttribute(box,'target_id'); | |
|
1034 | // actually comments with line numbers | |
|
1035 | 1035 | var comments = box.children; |
|
1036 | 1036 | for(var i=0; i<comments.length; i++){ |
|
1037 |
|
|
|
1038 |
|
|
|
1039 |
|
|
|
1040 |
|
|
|
1041 |
|
|
|
1042 |
|
|
|
1037 | var data = { | |
|
1038 | 'rendered_text': comments[i].outerHTML, | |
|
1039 | 'line_no': YUD.getAttribute(comments[i],'line'), | |
|
1040 | 'target_id': target_id | |
|
1041 | } | |
|
1042 | renderInlineComment(data); | |
|
1043 | 1043 | } |
|
1044 |
} |
|
|
1044 | } | |
|
1045 | 1045 | } |
|
1046 | 1046 | |
|
1047 | 1047 | var fileBrowserListeners = function(current_url, node_list_url, url_base){ |
|
1048 |
|
|
|
1048 | var current_url_branch = +"?branch=__BRANCH__"; | |
|
1049 | 1049 | |
|
1050 |
|
|
|
1051 |
|
|
|
1052 |
|
|
|
1053 |
|
|
|
1054 |
|
|
|
1055 |
|
|
|
1056 |
|
|
|
1057 |
|
|
|
1058 |
|
|
|
1059 | }) | |
|
1050 | YUE.on('stay_at_branch','click',function(e){ | |
|
1051 | if(e.target.checked){ | |
|
1052 | var uri = current_url_branch; | |
|
1053 | uri = uri.replace('__BRANCH__',e.target.value); | |
|
1054 | window.location = uri; | |
|
1055 | } | |
|
1056 | else{ | |
|
1057 | window.location = current_url; | |
|
1058 | } | |
|
1059 | }) | |
|
1060 | 1060 | |
|
1061 |
|
|
|
1062 |
|
|
|
1063 | ||
|
1064 |
|
|
|
1065 |
|
|
|
1061 | var n_filter = YUD.get('node_filter'); | |
|
1062 | var F = YAHOO.namespace('node_filter'); | |
|
1063 | ||
|
1064 | F.filterTimeout = null; | |
|
1065 | var nodes = null; | |
|
1066 | 1066 | |
|
1067 |
|
|
|
1068 |
|
|
|
1069 |
|
|
|
1070 |
|
|
|
1071 |
|
|
|
1072 |
|
|
|
1073 |
|
|
|
1074 |
|
|
|
1075 |
|
|
|
1076 |
|
|
|
1077 |
|
|
|
1078 |
|
|
|
1079 |
|
|
|
1080 |
|
|
|
1081 | } | |
|
1082 |
|
|
|
1083 |
|
|
|
1084 |
|
|
|
1085 |
|
|
|
1086 | },null); | |
|
1087 | } | |
|
1067 | F.initFilter = function(){ | |
|
1068 | YUD.setStyle('node_filter_box_loading','display',''); | |
|
1069 | YUD.setStyle('search_activate_id','display','none'); | |
|
1070 | YUD.setStyle('add_node_id','display','none'); | |
|
1071 | YUC.initHeader('X-PARTIAL-XHR',true); | |
|
1072 | YUC.asyncRequest('GET', node_list_url, { | |
|
1073 | success:function(o){ | |
|
1074 | nodes = JSON.parse(o.responseText).nodes; | |
|
1075 | YUD.setStyle('node_filter_box_loading','display','none'); | |
|
1076 | YUD.setStyle('node_filter_box','display',''); | |
|
1077 | n_filter.focus(); | |
|
1078 | if(YUD.hasClass(n_filter,'init')){ | |
|
1079 | n_filter.value = ''; | |
|
1080 | YUD.removeClass(n_filter,'init'); | |
|
1081 | } | |
|
1082 | }, | |
|
1083 | failure:function(o){ | |
|
1084 | console.log('failed to load'); | |
|
1085 | } | |
|
1086 | },null); | |
|
1087 | } | |
|
1088 | ||
|
1089 | F.updateFilter = function(e) { | |
|
1090 | ||
|
1091 | return function(){ | |
|
1092 | // Reset timeout | |
|
1093 | F.filterTimeout = null; | |
|
1094 | var query = e.target.value.toLowerCase(); | |
|
1095 | var match = []; | |
|
1096 | var matches = 0; | |
|
1097 | var matches_max = 20; | |
|
1098 | if (query != ""){ | |
|
1099 | for(var i=0;i<nodes.length;i++){ | |
|
1088 | 1100 | |
|
1089 | F.updateFilter = function(e) { | |
|
1090 | ||
|
1091 | return function(){ | |
|
1092 | // Reset timeout | |
|
1093 | F.filterTimeout = null; | |
|
1094 | var query = e.target.value.toLowerCase(); | |
|
1095 | var match = []; | |
|
1096 | var matches = 0; | |
|
1097 | var matches_max = 20; | |
|
1098 | if (query != ""){ | |
|
1099 | for(var i=0;i<nodes.length;i++){ | |
|
1100 | ||
|
1101 | var pos = nodes[i].name.toLowerCase().indexOf(query) | |
|
1102 | if(query && pos != -1){ | |
|
1103 | ||
|
1104 | matches++ | |
|
1105 | //show only certain amount to not kill browser | |
|
1106 |
|
|
|
1107 | break; | |
|
1108 |
|
|
|
1109 |
|
|
|
1110 | var n = nodes[i].name; | |
|
1111 | var t = nodes[i].type; | |
|
1112 | var n_hl = n.substring(0,pos) | |
|
1113 | +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) | |
|
1114 | +n.substring(pos+query.length) | |
|
1115 | var new_url = url_base.replace('__FPATH__',n); | |
|
1116 | match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,new_url,n_hl)); | |
|
1117 | } | |
|
1118 | if(match.length >= matches_max){ | |
|
1119 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['Search truncated'])); | |
|
1120 | } | |
|
1121 | } | |
|
1122 | } | |
|
1123 | if(query != ""){ | |
|
1124 | YUD.setStyle('tbody','display','none'); | |
|
1125 | YUD.setStyle('tbody_filtered','display',''); | |
|
1126 | ||
|
1127 | if (match.length==0){ | |
|
1128 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['No matching files'])); | |
|
1129 | } | |
|
1130 | ||
|
1131 | YUD.get('tbody_filtered').innerHTML = match.join(""); | |
|
1132 | } | |
|
1133 | else{ | |
|
1134 | YUD.setStyle('tbody','display',''); | |
|
1135 | YUD.setStyle('tbody_filtered','display','none'); | |
|
1136 | } | |
|
1137 | ||
|
1138 | } | |
|
1139 | }; | |
|
1101 | var pos = nodes[i].name.toLowerCase().indexOf(query) | |
|
1102 | if(query && pos != -1){ | |
|
1103 | ||
|
1104 | matches++ | |
|
1105 | //show only certain amount to not kill browser | |
|
1106 | if (matches > matches_max){ | |
|
1107 | break; | |
|
1108 | } | |
|
1109 | ||
|
1110 | var n = nodes[i].name; | |
|
1111 | var t = nodes[i].type; | |
|
1112 | var n_hl = n.substring(0,pos) | |
|
1113 | +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) | |
|
1114 | +n.substring(pos+query.length) | |
|
1115 | var new_url = url_base.replace('__FPATH__',n); | |
|
1116 | match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,new_url,n_hl)); | |
|
1117 | } | |
|
1118 | if(match.length >= matches_max){ | |
|
1119 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['Search truncated'])); | |
|
1120 | } | |
|
1121 | } | |
|
1122 | } | |
|
1123 | if(query != ""){ | |
|
1124 | YUD.setStyle('tbody','display','none'); | |
|
1125 | YUD.setStyle('tbody_filtered','display',''); | |
|
1140 | 1126 | |
|
1141 | YUE.on(YUD.get('filter_activate'),'click',function(){ | |
|
1142 | F.initFilter(); | |
|
1143 | }) | |
|
1144 | YUE.on(n_filter,'click',function(){ | |
|
1145 | if(YUD.hasClass(n_filter,'init')){ | |
|
1146 | n_filter.value = ''; | |
|
1147 | YUD.removeClass(n_filter,'init'); | |
|
1148 | } | |
|
1149 | }); | |
|
1150 | YUE.on(n_filter,'keyup',function(e){ | |
|
1151 | clearTimeout(F.filterTimeout); | |
|
1152 | F.filterTimeout = setTimeout(F.updateFilter(e),600); | |
|
1153 | }); | |
|
1127 | if (match.length==0){ | |
|
1128 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['No matching files'])); | |
|
1129 | } | |
|
1130 | ||
|
1131 | YUD.get('tbody_filtered').innerHTML = match.join(""); | |
|
1132 | } | |
|
1133 | else{ | |
|
1134 | YUD.setStyle('tbody','display',''); | |
|
1135 | YUD.setStyle('tbody_filtered','display','none'); | |
|
1136 | } | |
|
1137 | ||
|
1138 | } | |
|
1139 | }; | |
|
1140 | ||
|
1141 | YUE.on(YUD.get('filter_activate'),'click',function(){ | |
|
1142 | F.initFilter(); | |
|
1143 | }) | |
|
1144 | YUE.on(n_filter,'click',function(){ | |
|
1145 | if(YUD.hasClass(n_filter,'init')){ | |
|
1146 | n_filter.value = ''; | |
|
1147 | YUD.removeClass(n_filter,'init'); | |
|
1148 | } | |
|
1149 | }); | |
|
1150 | YUE.on(n_filter,'keyup',function(e){ | |
|
1151 | clearTimeout(F.filterTimeout); | |
|
1152 | F.filterTimeout = setTimeout(F.updateFilter(e),600); | |
|
1153 | }); | |
|
1154 | 1154 | }; |
|
1155 | 1155 | |
|
1156 | 1156 | |
|
1157 |
var initCodeMirror = function(textAreadId,resetUrl){ |
|
|
1157 | var initCodeMirror = function(textAreadId,resetUrl){ | |
|
1158 | 1158 | var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ |
|
1159 | 1159 | mode: "null", |
|
1160 | 1160 | lineNumbers:true |
@@ -1162,129 +1162,129 b' var initCodeMirror = function(textAreadI' | |||
|
1162 | 1162 | YUE.on('reset','click',function(e){ |
|
1163 | 1163 | window.location=resetUrl |
|
1164 | 1164 | }); |
|
1165 | ||
|
1165 | ||
|
1166 | 1166 | YUE.on('file_enable','click',function(){ |
|
1167 | 1167 | YUD.setStyle('editor_container','display',''); |
|
1168 | 1168 | YUD.setStyle('upload_file_container','display','none'); |
|
1169 | 1169 | YUD.setStyle('filename_container','display',''); |
|
1170 | 1170 | }); |
|
1171 | ||
|
1171 | ||
|
1172 | 1172 | YUE.on('upload_file_enable','click',function(){ |
|
1173 | 1173 | YUD.setStyle('editor_container','display','none'); |
|
1174 | 1174 | YUD.setStyle('upload_file_container','display',''); |
|
1175 | 1175 | YUD.setStyle('filename_container','display','none'); |
|
1176 |
}); |
|
|
1176 | }); | |
|
1177 | 1177 | }; |
|
1178 | 1178 | |
|
1179 | 1179 | |
|
1180 | 1180 | |
|
1181 | 1181 | var getIdentNode = function(n){ |
|
1182 |
|
|
|
1183 | ||
|
1184 |
|
|
|
1185 |
|
|
|
1186 | } | |
|
1187 | ||
|
1188 |
|
|
|
1189 | return n | |
|
1190 | } | |
|
1191 |
|
|
|
1192 |
|
|
|
1193 | } | |
|
1182 | //iterate thru nodes untill matched interesting node ! | |
|
1183 | ||
|
1184 | if (typeof n == 'undefined'){ | |
|
1185 | return -1 | |
|
1186 | } | |
|
1187 | ||
|
1188 | if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ | |
|
1189 | return n | |
|
1190 | } | |
|
1191 | else{ | |
|
1192 | return getIdentNode(n.parentNode); | |
|
1193 | } | |
|
1194 | 1194 | }; |
|
1195 | 1195 | |
|
1196 | 1196 | var getSelectionLink = function(e) { |
|
1197 | 1197 | |
|
1198 |
|
|
|
1199 |
|
|
|
1200 |
|
|
|
1201 | ||
|
1202 |
|
|
|
1203 |
|
|
|
1204 | ||
|
1205 |
|
|
|
1206 |
|
|
|
1207 | ||
|
1208 |
|
|
|
1209 |
|
|
|
1210 |
|
|
|
1211 |
|
|
|
1212 | ||
|
1213 | } | |
|
1214 | else{ | |
|
1215 | //highligth from top | |
|
1216 | offset = 35; | |
|
1217 | ranges = [f_int,t_int]; | |
|
1218 | } | |
|
1219 | // if we select more than 2 lines | |
|
1220 | if (ranges[0] != ranges[1]){ | |
|
1221 | if(YUD.get('linktt') == null){ | |
|
1222 | hl_div = document.createElement('div'); | |
|
1223 | hl_div.id = 'linktt'; | |
|
1224 | } | |
|
1225 | hl_div.innerHTML = ''; | |
|
1198 | //get selection from start/to nodes | |
|
1199 | if (typeof window.getSelection != "undefined") { | |
|
1200 | s = window.getSelection(); | |
|
1201 | ||
|
1202 | from = getIdentNode(s.anchorNode); | |
|
1203 | till = getIdentNode(s.focusNode); | |
|
1204 | ||
|
1205 | f_int = parseInt(from.id.replace('L','')); | |
|
1206 | t_int = parseInt(till.id.replace('L','')); | |
|
1207 | ||
|
1208 | if (f_int > t_int){ | |
|
1209 | //highlight from bottom | |
|
1210 | offset = -35; | |
|
1211 | ranges = [t_int,f_int]; | |
|
1226 | 1212 | |
|
1227 | anchor = '#L'+ranges[0]+'-'+ranges[1]; | |
|
1228 | var link = document.createElement('a'); | |
|
1229 | link.href = location.href.substring(0,location.href.indexOf('#'))+anchor; | |
|
1230 | link.innerHTML = _TM['Selection link']; | |
|
1231 | hl_div.appendChild(link); | |
|
1232 | YUD.get('body').appendChild(hl_div); | |
|
1233 | ||
|
1234 | xy = YUD.getXY(till.id); | |
|
1213 | } | |
|
1214 | else{ | |
|
1215 | //highligth from top | |
|
1216 | offset = 35; | |
|
1217 | ranges = [f_int,t_int]; | |
|
1218 | } | |
|
1219 | // if we select more than 2 lines | |
|
1220 | if (ranges[0] != ranges[1]){ | |
|
1221 | if(YUD.get('linktt') == null){ | |
|
1222 | hl_div = document.createElement('div'); | |
|
1223 | hl_div.id = 'linktt'; | |
|
1224 | } | |
|
1225 | hl_div.innerHTML = ''; | |
|
1235 | 1226 | |
|
1236 | YUD.addClass('linktt', 'hl-tip-box'); | |
|
1237 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); | |
|
1238 | YUD.setStyle('linktt','left',xy[0]+'px'); | |
|
1239 | YUD.setStyle('linktt','visibility','visible'); | |
|
1227 | anchor = '#L'+ranges[0]+'-'+ranges[1]; | |
|
1228 | var link = document.createElement('a'); | |
|
1229 | link.href = location.href.substring(0,location.href.indexOf('#'))+anchor; | |
|
1230 | link.innerHTML = _TM['Selection link']; | |
|
1231 | hl_div.appendChild(link); | |
|
1232 | YUD.get('body').appendChild(hl_div); | |
|
1233 | ||
|
1234 | xy = YUD.getXY(till.id); | |
|
1240 | 1235 | |
|
1241 | } | |
|
1242 | else{ | |
|
1243 |
|
|
|
1244 | } | |
|
1245 | } | |
|
1236 | YUD.addClass('linktt', 'hl-tip-box'); | |
|
1237 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); | |
|
1238 | YUD.setStyle('linktt','left',xy[0]+'px'); | |
|
1239 | YUD.setStyle('linktt','visibility','visible'); | |
|
1240 | ||
|
1241 | } | |
|
1242 | else{ | |
|
1243 | YUD.setStyle('linktt','visibility','hidden'); | |
|
1244 | } | |
|
1245 | } | |
|
1246 | 1246 | }; |
|
1247 | 1247 | |
|
1248 | 1248 | var deleteNotification = function(url, notification_id,callbacks){ |
|
1249 |
var callback = { |
|
|
1250 |
|
|
|
1251 |
|
|
|
1252 |
|
|
|
1253 |
|
|
|
1254 | } | |
|
1255 |
|
|
|
1256 | }, | |
|
1257 |
|
|
|
1258 |
|
|
|
1259 |
|
|
|
1260 | }; | |
|
1249 | var callback = { | |
|
1250 | success:function(o){ | |
|
1251 | var obj = YUD.get(String("notification_"+notification_id)); | |
|
1252 | if(obj.parentNode !== undefined){ | |
|
1253 | obj.parentNode.removeChild(obj); | |
|
1254 | } | |
|
1255 | _run_callbacks(callbacks); | |
|
1256 | }, | |
|
1257 | failure:function(o){ | |
|
1258 | alert("error"); | |
|
1259 | }, | |
|
1260 | }; | |
|
1261 | 1261 | var postData = '_method=delete'; |
|
1262 | 1262 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
1263 |
var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
|
1264 | callback, postData); | |
|
1265 |
}; |
|
|
1263 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, | |
|
1264 | callback, postData); | |
|
1265 | }; | |
|
1266 | 1266 | |
|
1267 | 1267 | var readNotification = function(url, notification_id,callbacks){ |
|
1268 |
var callback = { |
|
|
1269 |
|
|
|
1270 |
|
|
|
1271 |
|
|
|
1272 |
|
|
|
1273 | ||
|
1274 |
|
|
|
1275 |
|
|
|
1276 | } | |
|
1277 |
|
|
|
1278 | }, | |
|
1279 |
|
|
|
1280 |
|
|
|
1281 |
|
|
|
1282 | }; | |
|
1268 | var callback = { | |
|
1269 | success:function(o){ | |
|
1270 | var obj = YUD.get(String("notification_"+notification_id)); | |
|
1271 | YUD.removeClass(obj, 'unread'); | |
|
1272 | var r_button = YUD.getElementsByClassName('read-notification',null,obj.children[0])[0]; | |
|
1273 | ||
|
1274 | if(r_button.parentNode !== undefined){ | |
|
1275 | r_button.parentNode.removeChild(r_button); | |
|
1276 | } | |
|
1277 | _run_callbacks(callbacks); | |
|
1278 | }, | |
|
1279 | failure:function(o){ | |
|
1280 | alert("error"); | |
|
1281 | }, | |
|
1282 | }; | |
|
1283 | 1283 | var postData = '_method=put'; |
|
1284 | 1284 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
1285 |
var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
|
1286 | callback, postData); | |
|
1287 |
}; |
|
|
1285 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, | |
|
1286 | callback, postData); | |
|
1287 | }; | |
|
1288 | 1288 | |
|
1289 | 1289 | /** MEMBERS AUTOCOMPLETE WIDGET **/ |
|
1290 | 1290 | |
@@ -1303,9 +1303,9 b' var MembersAutoComplete = function (divi' | |||
|
1303 | 1303 | // Match against each name of each contact |
|
1304 | 1304 | for (; i < l; i++) { |
|
1305 | 1305 | contact = myUsers[i]; |
|
1306 |
if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
|
1307 |
|
|
|
1308 |
|
|
|
1306 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
|
1307 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
|
1308 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
|
1309 | 1309 | matches[matches.length] = contact; |
|
1310 | 1310 | } |
|
1311 | 1311 | } |
@@ -1354,7 +1354,7 b' var MembersAutoComplete = function (divi' | |||
|
1354 | 1354 | membersAC.useShadow = false; |
|
1355 | 1355 | membersAC.resultTypeList = false; |
|
1356 | 1356 | membersAC.animVert = false; |
|
1357 |
membersAC.animHoriz = false; |
|
|
1357 | membersAC.animHoriz = false; | |
|
1358 | 1358 | membersAC.animSpeed = 0.1; |
|
1359 | 1359 | |
|
1360 | 1360 | // Instantiate AutoComplete for owner |
@@ -1367,9 +1367,9 b' var MembersAutoComplete = function (divi' | |||
|
1367 | 1367 | |
|
1368 | 1368 | // Helper highlight function for the formatter |
|
1369 | 1369 | var highlightMatch = function (full, snippet, matchindex) { |
|
1370 |
return full.substring(0, matchindex) |
|
|
1371 |
+ "<span class='match'>" |
|
|
1372 |
+ full.substr(matchindex, snippet.length) |
|
|
1370 | return full.substring(0, matchindex) | |
|
1371 | + "<span class='match'>" | |
|
1372 | + full.substr(matchindex, snippet.length) | |
|
1373 | 1373 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1374 | 1374 | }; |
|
1375 | 1375 | |
@@ -1377,11 +1377,11 b' var MembersAutoComplete = function (divi' | |||
|
1377 | 1377 | var custom_formatter = function (oResultData, sQuery, sResultMatch) { |
|
1378 | 1378 | var query = sQuery.toLowerCase(); |
|
1379 | 1379 | var _gravatar = function(res, em, group){ |
|
1380 |
|
|
|
1381 |
|
|
|
1382 |
|
|
|
1383 |
|
|
|
1384 |
|
|
|
1380 | if (group !== undefined){ | |
|
1381 | em = '/images/icons/group.png' | |
|
1382 | } | |
|
1383 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
|
1384 | return tmpl.format(em,res) | |
|
1385 | 1385 | } |
|
1386 | 1386 | // group |
|
1387 | 1387 | if (oResultData.grname != undefined) { |
@@ -1395,13 +1395,13 b' var MembersAutoComplete = function (divi' | |||
|
1395 | 1395 | if (grnameMatchIndex > -1) { |
|
1396 | 1396 | return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true); |
|
1397 | 1397 | } |
|
1398 |
|
|
|
1398 | return _gravatar(grprefix + oResultData.grname + grsuffix, null,true); | |
|
1399 | 1399 | // Users |
|
1400 | 1400 | } else if (oResultData.nname != undefined) { |
|
1401 | 1401 | var fname = oResultData.fname || ""; |
|
1402 | 1402 | var lname = oResultData.lname || ""; |
|
1403 | 1403 | var nname = oResultData.nname; |
|
1404 | ||
|
1404 | ||
|
1405 | 1405 | // Guard against null value |
|
1406 | 1406 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1407 | 1407 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
@@ -1435,7 +1435,7 b' var MembersAutoComplete = function (divi' | |||
|
1435 | 1435 | ownerAC.formatResult = custom_formatter; |
|
1436 | 1436 | |
|
1437 | 1437 | var myHandler = function (sType, aArgs) { |
|
1438 |
|
|
|
1438 | var nextId = divid.split('perm_new_member_name_')[1]; | |
|
1439 | 1439 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1440 | 1440 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1441 | 1441 | var oData = aArgs[2]; // object literal of selected item's result data |
@@ -1453,7 +1453,7 b' var MembersAutoComplete = function (divi' | |||
|
1453 | 1453 | |
|
1454 | 1454 | membersAC.itemSelectEvent.subscribe(myHandler); |
|
1455 | 1455 | if(ownerAC.itemSelectEvent){ |
|
1456 |
|
|
|
1456 | ownerAC.itemSelectEvent.subscribe(myHandler); | |
|
1457 | 1457 | } |
|
1458 | 1458 | |
|
1459 | 1459 | return { |
@@ -1471,11 +1471,11 b' var MentionsAutoComplete = function (div' | |||
|
1471 | 1471 | |
|
1472 | 1472 | // Define a custom search function for the DataSource of users |
|
1473 | 1473 | var matchUsers = function (sQuery) { |
|
1474 |
|
|
|
1475 |
|
|
|
1476 |
|
|
|
1477 |
|
|
|
1478 |
|
|
|
1474 | var org_sQuery = sQuery; | |
|
1475 | if(this.mentionQuery == null){ | |
|
1476 | return [] | |
|
1477 | } | |
|
1478 | sQuery = this.mentionQuery; | |
|
1479 | 1479 | // Case insensitive matching |
|
1480 | 1480 | var query = sQuery.toLowerCase(); |
|
1481 | 1481 | var i = 0; |
@@ -1485,9 +1485,9 b' var MentionsAutoComplete = function (div' | |||
|
1485 | 1485 | // Match against each name of each contact |
|
1486 | 1486 | for (; i < l; i++) { |
|
1487 | 1487 | contact = myUsers[i]; |
|
1488 |
if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
|
1489 |
|
|
|
1490 |
|
|
|
1488 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
|
1489 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
|
1490 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
|
1491 | 1491 | matches[matches.length] = contact; |
|
1492 | 1492 | } |
|
1493 | 1493 | } |
@@ -1513,37 +1513,37 b' var MentionsAutoComplete = function (div' | |||
|
1513 | 1513 | ownerAC.resultTypeList = false; |
|
1514 | 1514 | ownerAC.suppressInputUpdate = true; |
|
1515 | 1515 | ownerAC.animVert = false; |
|
1516 |
ownerAC.animHoriz = false; |
|
|
1516 | ownerAC.animHoriz = false; | |
|
1517 | 1517 | ownerAC.animSpeed = 0.1; |
|
1518 | ||
|
1518 | ||
|
1519 | 1519 | // Helper highlight function for the formatter |
|
1520 | 1520 | var highlightMatch = function (full, snippet, matchindex) { |
|
1521 |
return full.substring(0, matchindex) |
|
|
1522 |
+ "<span class='match'>" |
|
|
1523 |
+ full.substr(matchindex, snippet.length) |
|
|
1521 | return full.substring(0, matchindex) | |
|
1522 | + "<span class='match'>" | |
|
1523 | + full.substr(matchindex, snippet.length) | |
|
1524 | 1524 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1525 | 1525 | }; |
|
1526 | 1526 | |
|
1527 | 1527 | // Custom formatter to highlight the matching letters |
|
1528 | 1528 | ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
|
1529 |
|
|
|
1530 |
|
|
|
1531 |
|
|
|
1532 | } | |
|
1529 | var org_sQuery = sQuery; | |
|
1530 | if(this.dataSource.mentionQuery != null){ | |
|
1531 | sQuery = this.dataSource.mentionQuery; | |
|
1532 | } | |
|
1533 | 1533 | |
|
1534 | 1534 | var query = sQuery.toLowerCase(); |
|
1535 | 1535 | var _gravatar = function(res, em, group){ |
|
1536 |
|
|
|
1537 |
|
|
|
1538 |
|
|
|
1539 |
|
|
|
1540 |
|
|
|
1536 | if (group !== undefined){ | |
|
1537 | em = '/images/icons/group.png' | |
|
1538 | } | |
|
1539 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
|
1540 | return tmpl.format(em,res) | |
|
1541 | 1541 | } |
|
1542 | 1542 | if (oResultData.nname != undefined) { |
|
1543 | 1543 | var fname = oResultData.fname || ""; |
|
1544 | 1544 | var lname = oResultData.lname || ""; |
|
1545 | 1545 | var nname = oResultData.nname; |
|
1546 | ||
|
1546 | ||
|
1547 | 1547 | // Guard against null value |
|
1548 | 1548 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1549 | 1549 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
@@ -1575,7 +1575,7 b' var MentionsAutoComplete = function (div' | |||
|
1575 | 1575 | }; |
|
1576 | 1576 | |
|
1577 | 1577 | if(ownerAC.itemSelectEvent){ |
|
1578 |
|
|
|
1578 | ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) { | |
|
1579 | 1579 | |
|
1580 | 1580 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1581 | 1581 | var elLI = aArgs[1]; // reference to the selected LI element |
@@ -1583,13 +1583,13 b' var MentionsAutoComplete = function (div' | |||
|
1583 | 1583 | //fill the autocomplete with value |
|
1584 | 1584 | if (oData.nname != undefined) { |
|
1585 | 1585 | //users |
|
1586 |
|
|
|
1587 |
|
|
|
1588 |
|
|
|
1589 |
|
|
|
1590 |
|
|
|
1591 |
|
|
|
1592 |
|
|
|
1586 | //Replace the mention name with replaced | |
|
1587 | var re = new RegExp(); | |
|
1588 | var org = myAC.getInputEl().value; | |
|
1589 | var chunks = myAC.dataSource.chunks | |
|
1590 | // replace middle chunk(the search term) with actuall match | |
|
1591 | chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, | |
|
1592 | '@'+oData.nname+' '); | |
|
1593 | 1593 | myAC.getInputEl().value = chunks.join('') |
|
1594 | 1594 | YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !? |
|
1595 | 1595 | } else { |
@@ -1607,48 +1607,48 b' var MentionsAutoComplete = function (div' | |||
|
1607 | 1607 | ownerAC.dataSource.mentionQuery = null; |
|
1608 | 1608 | |
|
1609 | 1609 | ownerAC.get_mention = function(msg, max_pos) { |
|
1610 |
|
|
|
1611 |
|
|
|
1612 |
|
|
|
1610 | var org = msg; | |
|
1611 | var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$') | |
|
1612 | var chunks = []; | |
|
1613 | ||
|
1613 | 1614 | |
|
1614 | ||
|
1615 | // cut first chunk until curret pos | |
|
1616 | var to_max = msg.substr(0, max_pos); | |
|
1617 | var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); | |
|
1618 | var msg2 = to_max.substr(at_pos); | |
|
1615 | // cut first chunk until curret pos | |
|
1616 | var to_max = msg.substr(0, max_pos); | |
|
1617 | var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); | |
|
1618 | var msg2 = to_max.substr(at_pos); | |
|
1619 | 1619 | |
|
1620 |
|
|
|
1621 |
|
|
|
1622 |
|
|
|
1620 | chunks.push(org.substr(0,at_pos))// prefix chunk | |
|
1621 | chunks.push(msg2) // search chunk | |
|
1622 | chunks.push(org.substr(max_pos)) // postfix chunk | |
|
1623 | 1623 | |
|
1624 |
|
|
|
1625 |
|
|
|
1624 | // clean up msg2 for filtering and regex match | |
|
1625 | var msg2 = msg2.lstrip(' ').lstrip('\n'); | |
|
1626 | 1626 | |
|
1627 |
|
|
|
1628 |
|
|
|
1629 |
|
|
|
1630 | } | |
|
1631 |
|
|
|
1627 | if(re.test(msg2)){ | |
|
1628 | var unam = re.exec(msg2)[1]; | |
|
1629 | return [unam, chunks]; | |
|
1630 | } | |
|
1631 | return [null, null]; | |
|
1632 | 1632 | }; |
|
1633 | ||
|
1633 | ||
|
1634 | 1634 | if (ownerAC.textboxKeyUpEvent){ |
|
1635 |
|
|
|
1636 | ||
|
1637 |
|
|
|
1638 |
|
|
|
1639 |
|
|
|
1640 | ||
|
1641 |
|
|
|
1642 |
|
|
|
1643 |
|
|
|
1644 |
|
|
|
1645 | } | |
|
1646 | ||
|
1647 |
|
|
|
1648 |
|
|
|
1649 | ||
|
1650 | }) | |
|
1651 | } | |
|
1635 | ownerAC.textboxKeyUpEvent.subscribe(function(type, args){ | |
|
1636 | ||
|
1637 | var ac_obj = args[0]; | |
|
1638 | var currentMessage = args[1]; | |
|
1639 | var currentCaretPosition = args[0]._elTextbox.selectionStart; | |
|
1640 | ||
|
1641 | var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); | |
|
1642 | var curr_search = null; | |
|
1643 | if(unam[0]){ | |
|
1644 | curr_search = unam[0]; | |
|
1645 | } | |
|
1646 | ||
|
1647 | ownerAC.dataSource.chunks = unam[1]; | |
|
1648 | ownerAC.dataSource.mentionQuery = curr_search; | |
|
1649 | ||
|
1650 | }) | |
|
1651 | } | |
|
1652 | 1652 | return { |
|
1653 | 1653 | ownerDS: ownerDS, |
|
1654 | 1654 | ownerAC: ownerAC, |
@@ -1656,54 +1656,54 b' var MentionsAutoComplete = function (div' | |||
|
1656 | 1656 | } |
|
1657 | 1657 | |
|
1658 | 1658 | var addReviewMember = function(id,fname,lname,nname,gravatar_link){ |
|
1659 |
|
|
|
1660 |
|
|
|
1659 | var members = YUD.get('review_members'); | |
|
1660 | var tmpl = '<li id="reviewer_{2}">'+ | |
|
1661 | 1661 | '<div class="reviewers_member">'+ |
|
1662 | 1662 | '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+ |
|
1663 | 1663 | '<div style="float:left">{1}</div>'+ |
|
1664 | 1664 | '<input type="hidden" value="{2}" name="review_members" />'+ |
|
1665 | 1665 | '<span class="delete_icon action_button" onclick="removeReviewMember({2})"></span>'+ |
|
1666 | 1666 | '</div>'+ |
|
1667 |
'</li>' |
|
|
1667 | '</li>' ; | |
|
1668 | 1668 | var displayname = "{0} {1} ({2})".format(fname,lname,nname); |
|
1669 |
|
|
|
1670 |
|
|
|
1671 |
|
|
|
1672 |
|
|
|
1673 |
|
|
|
1674 |
|
|
|
1675 | } | |
|
1676 |
|
|
|
1677 |
|
|
|
1678 |
|
|
|
1679 | } | |
|
1680 | ||
|
1669 | var element = tmpl.format(gravatar_link,displayname,id); | |
|
1670 | // check if we don't have this ID already in | |
|
1671 | var ids = []; | |
|
1672 | var _els = YUQ('#review_members li'); | |
|
1673 | for (el in _els){ | |
|
1674 | ids.push(_els[el].id) | |
|
1675 | } | |
|
1676 | if(ids.indexOf('reviewer_'+id) == -1){ | |
|
1677 | //only add if it's not there | |
|
1678 | members.innerHTML += element; | |
|
1679 | } | |
|
1680 | ||
|
1681 | 1681 | } |
|
1682 | 1682 | |
|
1683 | 1683 | var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){ |
|
1684 |
|
|
|
1685 |
|
|
|
1686 |
|
|
|
1687 | } | |
|
1684 | var el = YUD.get('reviewer_{0}'.format(reviewer_id)); | |
|
1685 | if (el.parentNode !== undefined){ | |
|
1686 | el.parentNode.removeChild(el); | |
|
1687 | } | |
|
1688 | 1688 | } |
|
1689 | 1689 | |
|
1690 | 1690 | var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ |
|
1691 |
|
|
|
1692 |
|
|
|
1693 |
|
|
|
1694 |
|
|
|
1695 |
|
|
|
1696 |
|
|
|
1697 | } | |
|
1698 | } | |
|
1699 |
|
|
|
1700 | "pull_request_id": pull_request_id}); | |
|
1701 |
|
|
|
1702 |
|
|
|
1703 |
|
|
|
1704 |
|
|
|
1705 | } | |
|
1706 |
|
|
|
1691 | if (reviewers_ids === undefined){ | |
|
1692 | var reviewers_ids = []; | |
|
1693 | var ids = YUQ('#review_members input'); | |
|
1694 | for(var i=0; i<ids.length;i++){ | |
|
1695 | var id = ids[i].value | |
|
1696 | reviewers_ids.push(id); | |
|
1697 | } | |
|
1698 | } | |
|
1699 | var url = pyroutes.url('pullrequest_update', {"repo_name":repo_name, | |
|
1700 | "pull_request_id": pull_request_id}); | |
|
1701 | var postData = {'_method':'put', | |
|
1702 | 'reviewers_ids': reviewers_ids}; | |
|
1703 | var success = function(o){ | |
|
1704 | window.location.reload(); | |
|
1705 | } | |
|
1706 | ajaxPOST(url,postData,success); | |
|
1707 | 1707 | } |
|
1708 | 1708 | |
|
1709 | 1709 | var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) { |
@@ -1721,9 +1721,9 b' var PullRequestAutoComplete = function (' | |||
|
1721 | 1721 | // Match against each name of each contact |
|
1722 | 1722 | for (; i < l; i++) { |
|
1723 | 1723 | contact = myUsers[i]; |
|
1724 |
if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
|
1725 |
|
|
|
1726 |
|
|
|
1724 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
|
1725 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
|
1726 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
|
1727 | 1727 | matches[matches.length] = contact; |
|
1728 | 1728 | } |
|
1729 | 1729 | } |
@@ -1767,37 +1767,37 b' var PullRequestAutoComplete = function (' | |||
|
1767 | 1767 | reviewerAC.resultTypeList = false; |
|
1768 | 1768 | reviewerAC.suppressInputUpdate = true; |
|
1769 | 1769 | reviewerAC.animVert = false; |
|
1770 |
reviewerAC.animHoriz = false; |
|
|
1770 | reviewerAC.animHoriz = false; | |
|
1771 | 1771 | reviewerAC.animSpeed = 0.1; |
|
1772 | ||
|
1772 | ||
|
1773 | 1773 | // Helper highlight function for the formatter |
|
1774 | 1774 | var highlightMatch = function (full, snippet, matchindex) { |
|
1775 |
return full.substring(0, matchindex) |
|
|
1776 |
+ "<span class='match'>" |
|
|
1777 |
+ full.substr(matchindex, snippet.length) |
|
|
1775 | return full.substring(0, matchindex) | |
|
1776 | + "<span class='match'>" | |
|
1777 | + full.substr(matchindex, snippet.length) | |
|
1778 | 1778 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1779 | 1779 | }; |
|
1780 | 1780 | |
|
1781 | 1781 | // Custom formatter to highlight the matching letters |
|
1782 | 1782 | reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
|
1783 |
|
|
|
1784 |
|
|
|
1785 |
|
|
|
1786 | } | |
|
1783 | var org_sQuery = sQuery; | |
|
1784 | if(this.dataSource.mentionQuery != null){ | |
|
1785 | sQuery = this.dataSource.mentionQuery; | |
|
1786 | } | |
|
1787 | 1787 | |
|
1788 | 1788 | var query = sQuery.toLowerCase(); |
|
1789 | 1789 | var _gravatar = function(res, em, group){ |
|
1790 |
|
|
|
1791 |
|
|
|
1792 |
|
|
|
1793 |
|
|
|
1794 |
|
|
|
1790 | if (group !== undefined){ | |
|
1791 | em = '/images/icons/group.png' | |
|
1792 | } | |
|
1793 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
|
1794 | return tmpl.format(em,res) | |
|
1795 | 1795 | } |
|
1796 | 1796 | if (oResultData.nname != undefined) { |
|
1797 | 1797 | var fname = oResultData.fname || ""; |
|
1798 | 1798 | var lname = oResultData.lname || ""; |
|
1799 | 1799 | var nname = oResultData.nname; |
|
1800 | ||
|
1800 | ||
|
1801 | 1801 | // Guard against null value |
|
1802 | 1802 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1803 | 1803 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
@@ -1827,26 +1827,26 b' var PullRequestAutoComplete = function (' | |||
|
1827 | 1827 | return ''; |
|
1828 | 1828 | } |
|
1829 | 1829 | }; |
|
1830 | ||
|
1830 | ||
|
1831 | 1831 | //members cache to catch duplicates |
|
1832 | 1832 | reviewerAC.dataSource.cache = []; |
|
1833 | 1833 | // hack into select event |
|
1834 | 1834 | if(reviewerAC.itemSelectEvent){ |
|
1835 |
|
|
|
1835 | reviewerAC.itemSelectEvent.subscribe(function (sType, aArgs) { | |
|
1836 | 1836 | |
|
1837 | 1837 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1838 | 1838 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1839 | 1839 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1840 | ||
|
1840 | ||
|
1841 | 1841 | //fill the autocomplete with value |
|
1842 | 1842 | |
|
1843 | 1843 | if (oData.nname != undefined) { |
|
1844 |
|
|
|
1845 |
|
|
|
1846 |
|
|
|
1847 |
|
|
|
1844 | addReviewMember(oData.id, oData.fname, oData.lname, oData.nname, | |
|
1845 | oData.gravatar_lnk); | |
|
1846 | myAC.dataSource.cache.push(oData.id); | |
|
1847 | YUD.get('user').value = '' | |
|
1848 | 1848 | } |
|
1849 | }); | |
|
1849 | }); | |
|
1850 | 1850 | } |
|
1851 | 1851 | return { |
|
1852 | 1852 | ownerDS: ownerDS, |
@@ -1881,13 +1881,13 b' var quick_repo_menu = function(){' | |||
|
1881 | 1881 | |
|
1882 | 1882 | // returns a node from given html; |
|
1883 | 1883 | var fromHTML = function(html){ |
|
1884 |
|
|
|
1885 |
|
|
|
1886 |
|
|
|
1884 | var _html = document.createElement('element'); | |
|
1885 | _html.innerHTML = html; | |
|
1886 | return _html; | |
|
1887 | 1887 | } |
|
1888 | 1888 | var get_rev = function(node){ |
|
1889 | 1889 | var n = node.firstElementChild.firstElementChild; |
|
1890 | ||
|
1890 | ||
|
1891 | 1891 | if (n===null){ |
|
1892 | 1892 | return -1 |
|
1893 | 1893 | } |
@@ -1898,56 +1898,56 b' var get_rev = function(node){' | |||
|
1898 | 1898 | } |
|
1899 | 1899 | |
|
1900 | 1900 | var get_name = function(node){ |
|
1901 |
|
|
|
1902 |
|
|
|
1901 | var name = node.firstElementChild.children[2].innerHTML; | |
|
1902 | return name | |
|
1903 | 1903 | } |
|
1904 | 1904 | var get_group_name = function(node){ |
|
1905 |
|
|
|
1906 |
|
|
|
1905 | var name = node.firstElementChild.children[1].innerHTML; | |
|
1906 | return name | |
|
1907 | 1907 | } |
|
1908 | 1908 | var get_date = function(node){ |
|
1909 |
|
|
|
1910 |
|
|
|
1909 | var date_ = YUD.getAttribute(node.firstElementChild,'date'); | |
|
1910 | return date_ | |
|
1911 | 1911 | } |
|
1912 | 1912 | |
|
1913 | 1913 | var get_age = function(node){ |
|
1914 |
|
|
|
1914 | return node | |
|
1915 | 1915 | } |
|
1916 | 1916 | |
|
1917 | 1917 | var get_link = function(node){ |
|
1918 |
|
|
|
1918 | return node.firstElementChild.text; | |
|
1919 | 1919 | } |
|
1920 | 1920 | |
|
1921 | 1921 | var revisionSort = function(a, b, desc, field) { |
|
1922 | ||
|
1923 |
|
|
|
1924 |
|
|
|
1925 | ||
|
1926 |
|
|
|
1927 |
|
|
|
1928 |
|
|
|
1929 | ||
|
1930 |
|
|
|
1931 |
|
|
|
1932 |
|
|
|
1922 | ||
|
1923 | var a_ = fromHTML(a.getData(field)); | |
|
1924 | var b_ = fromHTML(b.getData(field)); | |
|
1925 | ||
|
1926 | // extract revisions from string nodes | |
|
1927 | a_ = get_rev(a_) | |
|
1928 | b_ = get_rev(b_) | |
|
1929 | ||
|
1930 | var comp = YAHOO.util.Sort.compare; | |
|
1931 | var compState = comp(a_, b_, desc); | |
|
1932 | return compState; | |
|
1933 | 1933 | }; |
|
1934 | 1934 | var ageSort = function(a, b, desc, field) { |
|
1935 | 1935 | var a_ = fromHTML(a.getData(field)); |
|
1936 | 1936 | var b_ = fromHTML(b.getData(field)); |
|
1937 | ||
|
1937 | ||
|
1938 | 1938 | // extract name from table |
|
1939 | 1939 | a_ = get_date(a_) |
|
1940 |
b_ = get_date(b_) |
|
|
1941 | ||
|
1940 | b_ = get_date(b_) | |
|
1941 | ||
|
1942 | 1942 | var comp = YAHOO.util.Sort.compare; |
|
1943 | 1943 | var compState = comp(a_, b_, desc); |
|
1944 | 1944 | return compState; |
|
1945 | 1945 | }; |
|
1946 | 1946 | |
|
1947 | 1947 | var lastLoginSort = function(a, b, desc, field) { |
|
1948 |
|
|
|
1948 | var a_ = a.getData('last_login_raw') || 0; | |
|
1949 | 1949 | var b_ = b.getData('last_login_raw') || 0; |
|
1950 | ||
|
1950 | ||
|
1951 | 1951 | var comp = YAHOO.util.Sort.compare; |
|
1952 | 1952 | var compState = comp(a_, b_, desc); |
|
1953 | 1953 | return compState; |
@@ -1959,8 +1959,8 b' var nameSort = function(a, b, desc, fiel' | |||
|
1959 | 1959 | |
|
1960 | 1960 | // extract name from table |
|
1961 | 1961 | a_ = get_name(a_) |
|
1962 |
b_ = get_name(b_) |
|
|
1963 | ||
|
1962 | b_ = get_name(b_) | |
|
1963 | ||
|
1964 | 1964 | var comp = YAHOO.util.Sort.compare; |
|
1965 | 1965 | var compState = comp(a_, b_, desc); |
|
1966 | 1966 | return compState; |
@@ -1972,8 +1972,8 b' var permNameSort = function(a, b, desc, ' | |||
|
1972 | 1972 | // extract name from table |
|
1973 | 1973 | |
|
1974 | 1974 | a_ = a_.children[0].innerHTML; |
|
1975 |
b_ = b_.children[0].innerHTML; |
|
|
1976 | ||
|
1975 | b_ = b_.children[0].innerHTML; | |
|
1976 | ||
|
1977 | 1977 | var comp = YAHOO.util.Sort.compare; |
|
1978 | 1978 | var compState = comp(a_, b_, desc); |
|
1979 | 1979 | return compState; |
@@ -1982,11 +1982,11 b' var permNameSort = function(a, b, desc, ' | |||
|
1982 | 1982 | var groupNameSort = function(a, b, desc, field) { |
|
1983 | 1983 | var a_ = fromHTML(a.getData(field)); |
|
1984 | 1984 | var b_ = fromHTML(b.getData(field)); |
|
1985 | ||
|
1985 | ||
|
1986 | 1986 | // extract name from table |
|
1987 | 1987 | a_ = get_group_name(a_) |
|
1988 |
b_ = get_group_name(b_) |
|
|
1989 | ||
|
1988 | b_ = get_group_name(b_) | |
|
1989 | ||
|
1990 | 1990 | var comp = YAHOO.util.Sort.compare; |
|
1991 | 1991 | var compState = comp(a_, b_, desc); |
|
1992 | 1992 | return compState; |
@@ -1994,26 +1994,26 b' var groupNameSort = function(a, b, desc,' | |||
|
1994 | 1994 | var dateSort = function(a, b, desc, field) { |
|
1995 | 1995 | var a_ = fromHTML(a.getData(field)); |
|
1996 | 1996 | var b_ = fromHTML(b.getData(field)); |
|
1997 | ||
|
1997 | ||
|
1998 | 1998 | // extract name from table |
|
1999 | 1999 | a_ = get_date(a_) |
|
2000 |
b_ = get_date(b_) |
|
|
2001 | ||
|
2000 | b_ = get_date(b_) | |
|
2001 | ||
|
2002 | 2002 | var comp = YAHOO.util.Sort.compare; |
|
2003 | 2003 | var compState = comp(a_, b_, desc); |
|
2004 | 2004 | return compState; |
|
2005 | 2005 | }; |
|
2006 | 2006 | |
|
2007 | 2007 | var usernamelinkSort = function(a, b, desc, field) { |
|
2008 |
|
|
|
2009 |
|
|
|
2010 | ||
|
2011 |
|
|
|
2012 |
|
|
|
2013 |
|
|
|
2014 |
|
|
|
2015 |
|
|
|
2016 |
|
|
|
2008 | var a_ = fromHTML(a.getData(field)); | |
|
2009 | var b_ = fromHTML(b.getData(field)); | |
|
2010 | ||
|
2011 | // extract url text from string nodes | |
|
2012 | a_ = get_link(a_) | |
|
2013 | b_ = get_link(b_) | |
|
2014 | var comp = YAHOO.util.Sort.compare; | |
|
2015 | var compState = comp(a_, b_, desc); | |
|
2016 | return compState; | |
|
2017 | 2017 | } |
|
2018 | 2018 | |
|
2019 | 2019 | var addPermAction = function(_html, users_list, groups_list){ |
@@ -2025,15 +2025,15 b' var addPermAction = function(_html, user' | |||
|
2025 | 2025 | last_node.innerHTML = _html; |
|
2026 | 2026 | YUD.setStyle(last_node, 'display', ''); |
|
2027 | 2027 | YUD.removeClass(last_node, 'last_new_member'); |
|
2028 |
MembersAutoComplete("perm_new_member_name_"+next_id, |
|
|
2029 |
"perm_container_"+next_id, users_list, groups_list); |
|
|
2028 | MembersAutoComplete("perm_new_member_name_"+next_id, | |
|
2029 | "perm_container_"+next_id, users_list, groups_list); | |
|
2030 | 2030 | //create new last NODE |
|
2031 | 2031 | var el = document.createElement('tr'); |
|
2032 | 2032 | el.id = 'add_perm_input'; |
|
2033 | 2033 | YUD.addClass(el,'last_new_member'); |
|
2034 | 2034 | YUD.addClass(el,'new_members'); |
|
2035 | 2035 | YUD.insertAfter(el, last_node); |
|
2036 |
} |
|
|
2036 | } | |
|
2037 | 2037 | } |
|
2038 | 2038 | |
|
2039 | 2039 | /* Multi selectors */ |
@@ -2041,156 +2041,155 b' var addPermAction = function(_html, user' | |||
|
2041 | 2041 | var MultiSelectWidget = function(selected_id, available_id, form_id){ |
|
2042 | 2042 | |
|
2043 | 2043 | |
|
2044 |
|
|
|
2045 |
|
|
|
2046 |
|
|
|
2047 | ||
|
2048 |
|
|
|
2049 |
|
|
|
2050 |
|
|
|
2051 |
|
|
|
2052 |
|
|
|
2053 | ||
|
2054 |
|
|
|
2055 |
|
|
|
2056 |
|
|
|
2057 |
|
|
|
2058 |
|
|
|
2059 |
|
|
|
2060 | } | |
|
2061 | ||
|
2062 |
|
|
|
2063 |
|
|
|
2064 |
|
|
|
2065 |
|
|
|
2066 | } | |
|
2067 | ||
|
2068 |
|
|
|
2069 |
|
|
|
2070 |
|
|
|
2071 | ||
|
2072 |
|
|
|
2073 |
|
|
|
2074 |
|
|
|
2075 |
|
|
|
2076 |
|
|
|
2077 |
|
|
|
2078 |
|
|
|
2079 |
|
|
|
2080 |
|
|
|
2081 |
|
|
|
2082 |
|
|
|
2083 | } | |
|
2084 | ||
|
2085 |
|
|
|
2086 |
|
|
|
2087 | } | |
|
2088 | ||
|
2089 |
|
|
|
2090 | ||
|
2091 |
|
|
|
2092 |
|
|
|
2093 | ||
|
2094 |
|
|
|
2095 |
|
|
|
2096 |
|
|
|
2097 |
|
|
|
2098 |
|
|
|
2099 | ||
|
2100 |
|
|
|
2101 |
|
|
|
2102 |
|
|
|
2103 |
|
|
|
2104 |
|
|
|
2105 |
|
|
|
2106 |
|
|
|
2107 |
|
|
|
2108 |
|
|
|
2109 | ||
|
2110 |
|
|
|
2111 |
|
|
|
2112 | ||
|
2113 |
|
|
|
2114 |
|
|
|
2115 |
|
|
|
2116 |
|
|
|
2117 |
|
|
|
2118 |
|
|
|
2119 |
|
|
|
2120 |
|
|
|
2121 | ||
|
2122 |
|
|
|
2123 |
|
|
|
2124 |
|
|
|
2125 |
|
|
|
2126 |
|
|
|
2127 |
|
|
|
2128 |
|
|
|
2129 |
|
|
|
2130 | ||
|
2131 |
|
|
|
2132 |
|
|
|
2133 |
|
|
|
2134 |
|
|
|
2135 |
|
|
|
2136 |
|
|
|
2137 |
|
|
|
2138 |
|
|
|
2139 |
|
|
|
2140 |
|
|
|
2141 |
|
|
|
2142 |
|
|
|
2143 |
|
|
|
2144 |
|
|
|
2145 |
|
|
|
2146 |
|
|
|
2147 |
|
|
|
2148 |
|
|
|
2149 |
|
|
|
2150 |
|
|
|
2151 |
|
|
|
2152 |
|
|
|
2153 |
|
|
|
2154 |
|
|
|
2155 |
|
|
|
2156 |
|
|
|
2157 |
|
|
|
2158 |
|
|
|
2159 | ||
|
2160 | } | |
|
2161 | ||
|
2162 |
|
|
|
2163 |
|
|
|
2164 |
|
|
|
2165 |
|
|
|
2166 |
|
|
|
2167 |
|
|
|
2168 |
|
|
|
2169 |
|
|
|
2170 | } | |
|
2171 | }); | |
|
2172 | } | |
|
2044 | //definition of containers ID's | |
|
2045 | var selected_container = selected_id; | |
|
2046 | var available_container = available_id; | |
|
2047 | ||
|
2048 | //temp container for selected storage. | |
|
2049 | var cache = new Array(); | |
|
2050 | var av_cache = new Array(); | |
|
2051 | var c = YUD.get(selected_container); | |
|
2052 | var ac = YUD.get(available_container); | |
|
2053 | ||
|
2054 | //get only selected options for further fullfilment | |
|
2055 | for(var i = 0;node =c.options[i];i++){ | |
|
2056 | if(node.selected){ | |
|
2057 | //push selected to my temp storage left overs :) | |
|
2058 | cache.push(node); | |
|
2059 | } | |
|
2060 | } | |
|
2061 | ||
|
2062 | //get all available options to cache | |
|
2063 | for(var i = 0;node =ac.options[i];i++){ | |
|
2064 | //push selected to my temp storage left overs :) | |
|
2065 | av_cache.push(node); | |
|
2066 | } | |
|
2067 | ||
|
2068 | //fill available only with those not in chosen | |
|
2069 | ac.options.length=0; | |
|
2070 | tmp_cache = new Array(); | |
|
2071 | ||
|
2072 | for(var i = 0;node = av_cache[i];i++){ | |
|
2073 | var add = true; | |
|
2074 | for(var i2 = 0;node_2 = cache[i2];i2++){ | |
|
2075 | if(node.value == node_2.value){ | |
|
2076 | add=false; | |
|
2077 | break; | |
|
2078 | } | |
|
2079 | } | |
|
2080 | if(add){ | |
|
2081 | tmp_cache.push(new Option(node.text, node.value, false, false)); | |
|
2082 | } | |
|
2083 | } | |
|
2084 | ||
|
2085 | for(var i = 0;node = tmp_cache[i];i++){ | |
|
2086 | ac.options[i] = node; | |
|
2087 | } | |
|
2088 | ||
|
2089 | function prompts_action_callback(e){ | |
|
2090 | ||
|
2091 | var chosen = YUD.get(selected_container); | |
|
2092 | var available = YUD.get(available_container); | |
|
2093 | ||
|
2094 | //get checked and unchecked options from field | |
|
2095 | function get_checked(from_field){ | |
|
2096 | //temp container for storage. | |
|
2097 | var sel_cache = new Array(); | |
|
2098 | var oth_cache = new Array(); | |
|
2099 | ||
|
2100 | for(var i = 0;node = from_field.options[i];i++){ | |
|
2101 | if(node.selected){ | |
|
2102 | //push selected fields :) | |
|
2103 | sel_cache.push(node); | |
|
2104 | } | |
|
2105 | else{ | |
|
2106 | oth_cache.push(node) | |
|
2107 | } | |
|
2108 | } | |
|
2109 | ||
|
2110 | return [sel_cache,oth_cache] | |
|
2111 | } | |
|
2112 | ||
|
2113 | //fill the field with given options | |
|
2114 | function fill_with(field,options){ | |
|
2115 | //clear firtst | |
|
2116 | field.options.length=0; | |
|
2117 | for(var i = 0;node = options[i];i++){ | |
|
2118 | field.options[i]=new Option(node.text, node.value, | |
|
2119 | false, false); | |
|
2120 | } | |
|
2121 | ||
|
2122 | } | |
|
2123 | //adds to current field | |
|
2124 | function add_to(field,options){ | |
|
2125 | for(var i = 0;node = options[i];i++){ | |
|
2126 | field.appendChild(new Option(node.text, node.value, | |
|
2127 | false, false)); | |
|
2128 | } | |
|
2129 | } | |
|
2130 | ||
|
2131 | // add action | |
|
2132 | if (this.id=='add_element'){ | |
|
2133 | var c = get_checked(available); | |
|
2134 | add_to(chosen,c[0]); | |
|
2135 | fill_with(available,c[1]); | |
|
2136 | } | |
|
2137 | // remove action | |
|
2138 | if (this.id=='remove_element'){ | |
|
2139 | var c = get_checked(chosen); | |
|
2140 | add_to(available,c[0]); | |
|
2141 | fill_with(chosen,c[1]); | |
|
2142 | } | |
|
2143 | // add all elements | |
|
2144 | if(this.id=='add_all_elements'){ | |
|
2145 | for(var i=0; node = available.options[i];i++){ | |
|
2146 | chosen.appendChild(new Option(node.text, | |
|
2147 | node.value, false, false)); | |
|
2148 | } | |
|
2149 | available.options.length = 0; | |
|
2150 | } | |
|
2151 | //remove all elements | |
|
2152 | if(this.id=='remove_all_elements'){ | |
|
2153 | for(var i=0; node = chosen.options[i];i++){ | |
|
2154 | available.appendChild(new Option(node.text, | |
|
2155 | node.value, false, false)); | |
|
2156 | } | |
|
2157 | chosen.options.length = 0; | |
|
2158 | } | |
|
2159 | ||
|
2160 | } | |
|
2161 | ||
|
2162 | YUE.addListener(['add_element','remove_element', | |
|
2163 | 'add_all_elements','remove_all_elements'],'click', | |
|
2164 | prompts_action_callback) | |
|
2165 | if (form_id !== undefined) { | |
|
2166 | YUE.addListener(form_id,'submit',function(){ | |
|
2167 | var chosen = YUD.get(selected_container); | |
|
2168 | for (var i = 0; i < chosen.options.length; i++) { | |
|
2169 | chosen.options[i].selected = 'selected'; | |
|
2170 | } | |
|
2171 | }); | |
|
2172 | } | |
|
2173 | 2173 | } |
|
2174 | 2174 | |
|
2175 | 2175 | |
|
2176 | 2176 | // global hooks after DOM is loaded |
|
2177 | 2177 | |
|
2178 | 2178 | YUE.onDOMReady(function(){ |
|
2179 |
|
|
|
2180 |
|
|
|
2181 |
|
|
|
2182 |
|
|
|
2183 |
|
|
|
2184 |
|
|
|
2185 |
|
|
|
2186 | } | |
|
2187 |
|
|
|
2188 |
|
|
|
2189 |
|
|
|
2190 | } | |
|
2191 | }); | |
|
2192 | ||
|
2193 | ||
|
2194 | ||
|
2179 | YUE.on(YUQ('.diff-collapse-button'), 'click', function(e){ | |
|
2180 | var button = e.currentTarget; | |
|
2181 | var t = YUD.get(button).getAttribute('target'); | |
|
2182 | console.log(t); | |
|
2183 | if(YUD.hasClass(t, 'hidden')){ | |
|
2184 | YUD.removeClass(t, 'hidden'); | |
|
2185 | YUD.get(button).innerHTML = "↑ {0} ↑".format(_TM['Collapse diff']); | |
|
2186 | } | |
|
2187 | else if(!YUD.hasClass(t, 'hidden')){ | |
|
2188 | YUD.addClass(t, 'hidden'); | |
|
2189 | YUD.get(button).innerHTML = "↓ {0} ↓".format(_TM['Expand diff']); | |
|
2190 | } | |
|
2191 | }); | |
|
2192 | ||
|
2193 | ||
|
2194 | ||
|
2195 | 2195 | }); |
|
2196 |
General Comments 0
You need to be logged in to leave comments.
Login now