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