Show More
@@ -1,2196 +1,2195 | |||
|
1 | 1 | /** |
|
2 | 2 | RhodeCode JS Files |
|
3 | 3 | **/ |
|
4 | 4 | |
|
5 | 5 | if (typeof console == "undefined" || typeof console.log == "undefined"){ |
|
6 | 6 |
|
|
7 | 7 | } |
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | var str_repeat = function(i, m) { |
|
11 | 11 |
|
|
12 | 12 |
|
|
13 | 13 | }; |
|
14 | 14 | |
|
15 | 15 | /** |
|
16 | 16 | * INJECT .format function into String |
|
17 | 17 | * Usage: "My name is {0} {1}".format("Johny","Bravo") |
|
18 | 18 | * Return "My name is Johny Bravo" |
|
19 | 19 | * Inspired by https://gist.github.com/1049426 |
|
20 | 20 | */ |
|
21 | 21 | String.prototype.format = function() { |
|
22 | 22 | |
|
23 | 23 |
|
|
24 | 24 |
|
|
25 | 25 |
|
|
26 | 26 |
|
|
27 | 27 |
|
|
28 | 28 | |
|
29 | 29 |
|
|
30 | 30 |
|
|
31 | 31 |
|
|
32 | 32 |
|
|
33 | 33 |
|
|
34 | 34 |
|
|
35 | 35 |
|
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 |
|
|
39 | 39 |
|
|
40 | 40 |
|
|
41 | 41 | |
|
42 | 42 |
|
|
43 | 43 |
|
|
44 | 44 | |
|
45 | 45 | }(); |
|
46 | 46 | |
|
47 | 47 | String.prototype.strip = function(char) { |
|
48 | 48 |
|
|
49 | 49 |
|
|
50 | 50 | } |
|
51 | 51 |
|
|
52 | 52 | } |
|
53 | 53 | String.prototype.lstrip = function(char) { |
|
54 | 54 |
|
|
55 | 55 |
|
|
56 | 56 | } |
|
57 | 57 |
|
|
58 | 58 | } |
|
59 | 59 | String.prototype.rstrip = function(char) { |
|
60 | 60 |
|
|
61 | 61 |
|
|
62 | 62 | } |
|
63 | 63 |
|
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | |
|
67 | 67 | if(!Array.prototype.indexOf) { |
|
68 | 68 | Array.prototype.indexOf = function(needle) { |
|
69 | 69 | for(var i = 0; i < this.length; i++) { |
|
70 | 70 | if(this[i] === needle) { |
|
71 | 71 | return i; |
|
72 | 72 | } |
|
73 | 73 | } |
|
74 | 74 | return -1; |
|
75 | 75 | }; |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | // IE(CRAP) doesn't support previousElementSibling |
|
79 | 79 | var prevElementSibling = function( el ) { |
|
80 | 80 | if( el.previousElementSibling ) { |
|
81 | 81 | return el.previousElementSibling; |
|
82 | 82 | } else { |
|
83 | 83 | while( el = el.previousSibling ) { |
|
84 | 84 | if( el.nodeType === 1 ) return el; |
|
85 | 85 | } |
|
86 | 86 | } |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | 89 | /** |
|
90 | 90 | * SmartColorGenerator |
|
91 | 91 | * |
|
92 | 92 | *usage:: |
|
93 | 93 |
* |
|
94 | 94 | * var col = CG.getColor(key); //returns array of RGB |
|
95 | 95 | * 'rgb({0})'.format(col.join(',') |
|
96 | 96 |
* |
|
97 | 97 | * @returns {ColorGenerator} |
|
98 | 98 | */ |
|
99 | 99 | var ColorGenerator = function(){ |
|
100 | 100 |
|
|
101 | 101 |
|
|
102 | 102 |
|
|
103 | 103 |
|
|
104 | 104 |
|
|
105 | 105 |
|
|
106 | 106 | }; |
|
107 | 107 | |
|
108 | 108 | ColorGenerator.prototype = { |
|
109 | 109 | getColor:function(key){ |
|
110 | 110 |
|
|
111 | 111 |
|
|
112 | 112 |
|
|
113 | 113 |
|
|
114 | 114 |
|
|
115 | 115 |
|
|
116 | 116 |
|
|
117 | 117 | }, |
|
118 | 118 | _hsvToRgb:function(h,s,v){ |
|
119 | 119 | if (s == 0.0) |
|
120 | 120 | return [v, v, v]; |
|
121 | 121 | i = parseInt(h * 6.0) |
|
122 | 122 | f = (h * 6.0) - i |
|
123 | 123 | p = v * (1.0 - s) |
|
124 | 124 | q = v * (1.0 - s * f) |
|
125 | 125 | t = v * (1.0 - s * (1.0 - f)) |
|
126 | 126 | i = i % 6 |
|
127 | 127 |
if (i == 0) |
|
128 | 128 | return [v, t, p] |
|
129 | 129 |
if (i == 1) |
|
130 | 130 | return [q, v, p] |
|
131 | 131 |
if (i == 2) |
|
132 | 132 | return [p, v, t] |
|
133 | 133 | if (i == 3) |
|
134 | 134 | return [p, q, v] |
|
135 | 135 |
if (i == 4) |
|
136 | 136 | return [t, p, v] |
|
137 | 137 | if (i == 5) |
|
138 | 138 |
return [v, p, q] |
|
139 | 139 | }, |
|
140 | 140 | generateColor:function(){ |
|
141 | 141 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
|
142 | 142 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; |
|
143 | 143 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] |
|
144 | 144 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
|
145 | 145 | function toRgb(v){ |
|
146 | 146 |
|
|
147 | 147 | } |
|
148 | 148 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
|
149 | 149 | |
|
150 | 150 | } |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | 153 | /** |
|
154 | 154 | * PyRoutesJS |
|
155 | 155 |
* |
|
156 | 156 | * Usage pyroutes.url('mark_error_fixed',{"error_id":error_id}) // /mark_error_fixed/<error_id> |
|
157 | 157 | */ |
|
158 | 158 | var pyroutes = (function() { |
|
159 | 159 |
|
|
160 | 160 | var matchlist = PROUTES_MAP; |
|
161 | 161 | var sprintf = (function() { |
|
162 | 162 | function get_type(variable) { |
|
163 | 163 | return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); |
|
164 | 164 | } |
|
165 | 165 | function str_repeat(input, multiplier) { |
|
166 | 166 | for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} |
|
167 | 167 | return output.join(''); |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | var str_format = function() { |
|
171 | 171 | if (!str_format.cache.hasOwnProperty(arguments[0])) { |
|
172 | 172 | str_format.cache[arguments[0]] = str_format.parse(arguments[0]); |
|
173 | 173 | } |
|
174 | 174 | return str_format.format.call(null, str_format.cache[arguments[0]], arguments); |
|
175 | 175 | }; |
|
176 | 176 | |
|
177 | 177 | str_format.format = function(parse_tree, argv) { |
|
178 | 178 | var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; |
|
179 | 179 | for (i = 0; i < tree_length; i++) { |
|
180 | 180 | node_type = get_type(parse_tree[i]); |
|
181 | 181 | if (node_type === 'string') { |
|
182 | 182 | output.push(parse_tree[i]); |
|
183 | 183 | } |
|
184 | 184 | else if (node_type === 'array') { |
|
185 | 185 | match = parse_tree[i]; // convenience purposes only |
|
186 | 186 | if (match[2]) { // keyword argument |
|
187 | 187 | arg = argv[cursor]; |
|
188 | 188 | for (k = 0; k < match[2].length; k++) { |
|
189 | 189 | if (!arg.hasOwnProperty(match[2][k])) { |
|
190 | 190 | throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); |
|
191 | 191 | } |
|
192 | 192 | arg = arg[match[2][k]]; |
|
193 | 193 | } |
|
194 | 194 | } |
|
195 | 195 | else if (match[1]) { // positional argument (explicit) |
|
196 | 196 | arg = argv[match[1]]; |
|
197 | 197 | } |
|
198 | 198 | else { // positional argument (implicit) |
|
199 | 199 | arg = argv[cursor++]; |
|
200 | 200 | } |
|
201 | 201 | |
|
202 | 202 | if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { |
|
203 | 203 | throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); |
|
204 | 204 | } |
|
205 | 205 | switch (match[8]) { |
|
206 | 206 | case 'b': arg = arg.toString(2); break; |
|
207 | 207 | case 'c': arg = String.fromCharCode(arg); break; |
|
208 | 208 | case 'd': arg = parseInt(arg, 10); break; |
|
209 | 209 | case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; |
|
210 | 210 | case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; |
|
211 | 211 | case 'o': arg = arg.toString(8); break; |
|
212 | 212 | case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; |
|
213 | 213 | case 'u': arg = Math.abs(arg); break; |
|
214 | 214 | case 'x': arg = arg.toString(16); break; |
|
215 | 215 | case 'X': arg = arg.toString(16).toUpperCase(); break; |
|
216 | 216 | } |
|
217 | 217 | arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); |
|
218 | 218 | pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; |
|
219 | 219 | pad_length = match[6] - String(arg).length; |
|
220 | 220 | pad = match[6] ? str_repeat(pad_character, pad_length) : ''; |
|
221 | 221 | output.push(match[5] ? arg + pad : pad + arg); |
|
222 | 222 | } |
|
223 | 223 | } |
|
224 | 224 | return output.join(''); |
|
225 | 225 | }; |
|
226 | 226 | |
|
227 | 227 | str_format.cache = {}; |
|
228 | 228 | |
|
229 | 229 | str_format.parse = function(fmt) { |
|
230 | 230 | var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; |
|
231 | 231 | while (_fmt) { |
|
232 | 232 | if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { |
|
233 | 233 | parse_tree.push(match[0]); |
|
234 | 234 | } |
|
235 | 235 | else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { |
|
236 | 236 | parse_tree.push('%'); |
|
237 | 237 | } |
|
238 | 238 | else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { |
|
239 | 239 | if (match[2]) { |
|
240 | 240 | arg_names |= 1; |
|
241 | 241 | var field_list = [], replacement_field = match[2], field_match = []; |
|
242 | 242 | if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { |
|
243 | 243 | field_list.push(field_match[1]); |
|
244 | 244 | while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { |
|
245 | 245 | if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { |
|
246 | 246 | field_list.push(field_match[1]); |
|
247 | 247 | } |
|
248 | 248 | else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { |
|
249 | 249 | field_list.push(field_match[1]); |
|
250 | 250 | } |
|
251 | 251 | else { |
|
252 | 252 | throw('[sprintf] huh?'); |
|
253 | 253 | } |
|
254 | 254 | } |
|
255 | 255 | } |
|
256 | 256 | else { |
|
257 | 257 | throw('[sprintf] huh?'); |
|
258 | 258 | } |
|
259 | 259 | match[2] = field_list; |
|
260 | 260 | } |
|
261 | 261 | else { |
|
262 | 262 | arg_names |= 2; |
|
263 | 263 | } |
|
264 | 264 | if (arg_names === 3) { |
|
265 | 265 | throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); |
|
266 | 266 | } |
|
267 | 267 | parse_tree.push(match); |
|
268 | 268 | } |
|
269 | 269 | else { |
|
270 | 270 | throw('[sprintf] huh?'); |
|
271 | 271 | } |
|
272 | 272 | _fmt = _fmt.substring(match[0].length); |
|
273 | 273 | } |
|
274 | 274 | return parse_tree; |
|
275 | 275 | }; |
|
276 | 276 | |
|
277 | 277 | return str_format; |
|
278 | 278 | })(); |
|
279 | 279 | |
|
280 | 280 | var vsprintf = function(fmt, argv) { |
|
281 | 281 | argv.unshift(fmt); |
|
282 | 282 | return sprintf.apply(null, argv); |
|
283 | 283 | }; |
|
284 | 284 | return { |
|
285 | 285 | 'url': function(route_name, params) { |
|
286 | 286 | var result = route_name; |
|
287 | 287 | if (typeof(params) != 'object'){ |
|
288 | 288 |
|
|
289 | 289 | } |
|
290 | 290 | if (matchlist.hasOwnProperty(route_name)) { |
|
291 | 291 | var route = matchlist[route_name]; |
|
292 | 292 | // param substitution |
|
293 | 293 | for(var i=0; i < route[1].length; i++) { |
|
294 | 294 | |
|
295 | 295 | if (!params.hasOwnProperty(route[1][i])) |
|
296 | 296 | throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation'); |
|
297 | 297 | } |
|
298 | 298 | result = sprintf(route[0], params); |
|
299 | 299 | |
|
300 | 300 | var ret = []; |
|
301 | 301 | //extra params => GET |
|
302 | 302 | for(param in params){ |
|
303 | 303 |
|
|
304 | 304 |
|
|
305 | 305 |
|
|
306 | 306 | } |
|
307 | 307 | var _parts = ret.join("&"); |
|
308 | 308 | if(_parts){ |
|
309 | 309 |
|
|
310 | 310 | } |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | return result; |
|
314 | 314 | }, |
|
315 | 315 |
|
|
316 | 316 |
|
|
317 | 317 |
|
|
318 | 318 | } |
|
319 | 319 |
|
|
320 | 320 |
|
|
321 | 321 |
|
|
322 | 322 |
|
|
323 | 323 |
|
|
324 | 324 | } |
|
325 | 325 |
|
|
326 | 326 |
|
|
327 | 327 |
|
|
328 | 328 | ] |
|
329 | 329 |
|
|
330 | 330 |
|
|
331 | 331 |
|
|
332 | 332 |
|
|
333 | 333 | } |
|
334 | 334 | })(); |
|
335 | 335 | |
|
336 | 336 | |
|
337 | 337 | |
|
338 | 338 | /** |
|
339 | 339 | * GLOBAL YUI Shortcuts |
|
340 | 340 | */ |
|
341 | 341 | var YUC = YAHOO.util.Connect; |
|
342 | 342 | var YUD = YAHOO.util.Dom; |
|
343 | 343 | var YUE = YAHOO.util.Event; |
|
344 | 344 | var YUQ = YAHOO.util.Selector.query; |
|
345 | 345 | |
|
346 | 346 | // defines if push state is enabled for this browser ? |
|
347 | 347 | var push_state_enabled = Boolean( |
|
348 | 348 |
|
|
349 | 349 |
|
|
350 | 350 |
|
|
351 | 351 |
|
|
352 | 352 |
|
|
353 | 353 | ) |
|
354 | 354 | ); |
|
355 | 355 | |
|
356 | 356 | var _run_callbacks = function(callbacks){ |
|
357 | 357 |
|
|
358 | 358 |
|
|
359 | 359 |
|
|
360 | 360 |
|
|
361 | 361 |
|
|
362 | 362 |
|
|
363 | 363 |
|
|
364 | 364 |
|
|
365 | 365 | } |
|
366 | 366 |
|
|
367 | 367 | } |
|
368 | 368 | } |
|
369 | 369 | |
|
370 | 370 | /** |
|
371 | 371 | * Partial Ajax Implementation |
|
372 | 372 |
* |
|
373 | 373 | * @param url: defines url to make partial request |
|
374 | 374 | * @param container: defines id of container to input partial result |
|
375 | 375 | * @param s_call: success callback function that takes o as arg |
|
376 | 376 | * o.tId |
|
377 | 377 | * o.status |
|
378 | 378 | * o.statusText |
|
379 | 379 | * o.getResponseHeader[ ] |
|
380 | 380 | * o.getAllResponseHeaders |
|
381 | 381 | * o.responseText |
|
382 | 382 | * o.responseXML |
|
383 | 383 | * o.argument |
|
384 | 384 | * @param f_call: failure callback |
|
385 | 385 |
* @param args arguments |
|
386 | 386 | */ |
|
387 | 387 | function ypjax(url,container,s_call,f_call,args){ |
|
388 | 388 |
|
|
389 | 389 |
|
|
390 | 390 |
|
|
391 | 391 | } |
|
392 | 392 | |
|
393 | 393 |
|
|
394 | 394 |
|
|
395 | 395 | |
|
396 | 396 |
|
|
397 | 397 |
|
|
398 | 398 |
|
|
399 | 399 |
|
|
400 | 400 |
|
|
401 | 401 |
|
|
402 | 402 |
|
|
403 | 403 |
|
|
404 | 404 | } |
|
405 | 405 | } |
|
406 | 406 | })() |
|
407 | 407 |
|
|
408 | 408 |
|
|
409 | 409 |
|
|
410 | 410 |
|
|
411 | 411 |
|
|
412 | 412 |
|
|
413 | 413 |
|
|
414 | 414 | }, |
|
415 | 415 |
|
|
416 | 416 |
|
|
417 | 417 | |
|
418 | 418 | }; |
|
419 | 419 | |
|
420 | 420 | var ajaxGET = function(url,success) { |
|
421 | 421 |
|
|
422 | 422 |
|
|
423 | 423 | |
|
424 | 424 | var sUrl = url; |
|
425 | 425 | var callback = { |
|
426 | 426 | success: success, |
|
427 | 427 | failure: function (o) { |
|
428 | 428 | if (o.status != 0) { |
|
429 | 429 | alert("error: " + o.statusText); |
|
430 | 430 | }; |
|
431 | 431 | }, |
|
432 | 432 | }; |
|
433 | 433 | |
|
434 | 434 | var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); |
|
435 | 435 | return request; |
|
436 | 436 | }; |
|
437 | 437 | |
|
438 | 438 | |
|
439 | 439 | |
|
440 | 440 | var ajaxPOST = function(url,postData,success) { |
|
441 | 441 |
|
|
442 | 442 |
|
|
443 | 443 | |
|
444 | 444 |
|
|
445 | 445 |
|
|
446 | 446 |
|
|
447 | 447 |
|
|
448 | 448 |
|
|
449 | 449 |
|
|
450 | 450 |
|
|
451 | 451 |
|
|
452 | 452 |
|
|
453 | 453 | }; |
|
454 | 454 | |
|
455 | 455 | var sUrl = url; |
|
456 | 456 | var callback = { |
|
457 | 457 | success: success, |
|
458 | 458 | failure: function (o) { |
|
459 | 459 | alert("error"); |
|
460 | 460 | }, |
|
461 | 461 | }; |
|
462 | 462 | var postData = toQueryString(postData); |
|
463 | 463 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); |
|
464 | 464 | return request; |
|
465 | 465 | }; |
|
466 | 466 | |
|
467 | 467 | |
|
468 | 468 | /** |
|
469 | 469 | * tooltip activate |
|
470 | 470 | */ |
|
471 | 471 | var tooltip_activate = function(){ |
|
472 | 472 |
|
|
473 | 473 |
|
|
474 | 474 | }; |
|
475 | 475 | |
|
476 | 476 | /** |
|
477 | 477 | * show more |
|
478 | 478 | */ |
|
479 | 479 | var show_more_event = function(){ |
|
480 | 480 | YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ |
|
481 | 481 | var el = e.target; |
|
482 | 482 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); |
|
483 | 483 | YUD.setStyle(el.parentNode,'display','none'); |
|
484 | 484 | }); |
|
485 | 485 | }; |
|
486 | 486 | |
|
487 | 487 | /** |
|
488 | 488 | * show changeset tooltip |
|
489 | 489 | */ |
|
490 | 490 | var show_changeset_tooltip = function(){ |
|
491 | 491 |
|
|
492 | 492 |
|
|
493 | 493 |
|
|
494 | 494 |
|
|
495 | 495 |
|
|
496 | 496 |
|
|
497 | 497 |
|
|
498 | 498 |
|
|
499 | 499 |
|
|
500 | 500 |
|
|
501 | 501 | } |
|
502 | 502 |
|
|
503 | 503 |
|
|
504 | 504 |
|
|
505 | 505 |
|
|
506 | 506 |
|
|
507 | 507 |
|
|
508 | 508 |
|
|
509 | 509 | } |
|
510 | 510 | }); |
|
511 | 511 | }; |
|
512 | 512 | |
|
513 | 513 | var onSuccessFollow = function(target){ |
|
514 | 514 | var f = YUD.get(target); |
|
515 | 515 | var f_cnt = YUD.get('current_followers_count'); |
|
516 | 516 | |
|
517 | 517 | if(YUD.hasClass(f, 'follow')){ |
|
518 | 518 | f.setAttribute('class','following'); |
|
519 | 519 | f.setAttribute('title',_TM['Stop following this repository']); |
|
520 | 520 | |
|
521 | 521 | if(f_cnt){ |
|
522 | 522 | var cnt = Number(f_cnt.innerHTML)+1; |
|
523 | 523 | f_cnt.innerHTML = cnt; |
|
524 | 524 | } |
|
525 | 525 | } |
|
526 | 526 | else{ |
|
527 | 527 | f.setAttribute('class','follow'); |
|
528 | 528 | f.setAttribute('title',_TM['Start following this repository']); |
|
529 | 529 | if(f_cnt){ |
|
530 | 530 | var cnt = Number(f_cnt.innerHTML)-1; |
|
531 | 531 | f_cnt.innerHTML = cnt; |
|
532 | 532 | } |
|
533 | 533 | } |
|
534 | 534 | } |
|
535 | 535 | |
|
536 | 536 | var toggleFollowingUser = function(target,fallows_user_id,token,user_id){ |
|
537 | 537 | args = 'follows_user_id='+fallows_user_id; |
|
538 | 538 | args+= '&auth_token='+token; |
|
539 | 539 | if(user_id != undefined){ |
|
540 | 540 | args+="&user_id="+user_id; |
|
541 | 541 | } |
|
542 | 542 | YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{ |
|
543 | 543 | success:function(o){ |
|
544 | 544 |
|
|
545 | 545 | } |
|
546 | 546 | },args); |
|
547 | 547 | return false; |
|
548 | 548 | } |
|
549 | 549 | |
|
550 | 550 | var toggleFollowingRepo = function(target,fallows_repo_id,token,user_id){ |
|
551 | 551 | |
|
552 | 552 | args = 'follows_repo_id='+fallows_repo_id; |
|
553 | 553 | args+= '&auth_token='+token; |
|
554 | 554 | if(user_id != undefined){ |
|
555 | 555 | args+="&user_id="+user_id; |
|
556 | 556 | } |
|
557 | 557 | YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{ |
|
558 | 558 | success:function(o){ |
|
559 | 559 |
|
|
560 | 560 | } |
|
561 | 561 | },args); |
|
562 | 562 | return false; |
|
563 | 563 | } |
|
564 | 564 | |
|
565 | 565 | var showRepoSize = function(target, repo_name, token){ |
|
566 | 566 | var args= 'auth_token='+token; |
|
567 | 567 | |
|
568 | 568 | if(!YUD.hasClass(target, 'loaded')){ |
|
569 | 569 | YUD.get(target).innerHTML = _TM['Loading ...']; |
|
570 | 570 | var url = pyroutes.url('repo_size', {"repo_name":repo_name}); |
|
571 | 571 | YUC.asyncRequest('POST',url,{ |
|
572 | 572 | success:function(o){ |
|
573 | 573 |
|
|
574 | 574 |
|
|
575 | 575 | } |
|
576 | 576 |
},args); |
|
577 | 577 | } |
|
578 | 578 |
return false; |
|
579 | 579 | } |
|
580 | 580 | |
|
581 | 581 | /** |
|
582 | 582 | * TOOLTIP IMPL. |
|
583 | 583 | */ |
|
584 | 584 | YAHOO.namespace('yuitip'); |
|
585 | 585 | YAHOO.yuitip.main = { |
|
586 | 586 | |
|
587 | 587 |
|
|
588 | 588 | |
|
589 | 589 |
|
|
590 | 590 |
|
|
591 | 591 |
|
|
592 | 592 |
|
|
593 | 593 |
|
|
594 | 594 |
|
|
595 | 595 |
|
|
596 | 596 |
|
|
597 | 597 | |
|
598 | 598 |
|
|
599 | 599 |
|
|
600 | 600 |
|
|
601 | 601 |
|
|
602 | 602 | }, |
|
603 | 603 | |
|
604 | 604 |
|
|
605 | 605 |
|
|
606 | 606 |
|
|
607 | 607 |
|
|
608 | 608 |
|
|
609 | 609 |
|
|
610 | 610 | } |
|
611 | 611 | |
|
612 | 612 |
|
|
613 | 613 |
|
|
614 | 614 |
|
|
615 | 615 |
|
|
616 | 616 | } |
|
617 | 617 | |
|
618 | 618 |
|
|
619 | 619 | |
|
620 | 620 |
|
|
621 | 621 |
|
|
622 | 622 |
|
|
623 | 623 |
|
|
624 | 624 |
|
|
625 | 625 | } |
|
626 | 626 | } |
|
627 | 627 | |
|
628 | 628 |
|
|
629 | 629 | |
|
630 | 630 |
|
|
631 | 631 |
|
|
632 | 632 | } |
|
633 | 633 | }, |
|
634 | 634 | |
|
635 | 635 |
|
|
636 | 636 |
|
|
637 | 637 |
|
|
638 | 638 |
|
|
639 | 639 |
|
|
640 | 640 |
|
|
641 | 641 | } |
|
642 | 642 | |
|
643 | 643 |
|
|
644 | 644 |
|
|
645 | 645 |
|
|
646 | 646 |
|
|
647 | 647 |
|
|
648 | 648 | |
|
649 | 649 |
|
|
650 | 650 |
|
|
651 | 651 |
|
|
652 | 652 |
|
|
653 | 653 |
|
|
654 | 654 | { |
|
655 | 655 |
|
|
656 | 656 |
|
|
657 | 657 | ); |
|
658 | 658 |
|
|
659 | 659 | } |
|
660 | 660 | } |
|
661 | 661 | }, |
|
662 | 662 | |
|
663 | 663 |
|
|
664 | 664 |
|
|
665 | 665 |
|
|
666 | 666 |
|
|
667 | 667 |
|
|
668 | 668 | }, |
|
669 | 669 | |
|
670 | 670 |
|
|
671 | 671 |
|
|
672 | 672 | |
|
673 | 673 |
|
|
674 | 674 |
|
|
675 | 675 | { |
|
676 | 676 | opacity: { to: 0 } |
|
677 | 677 |
|
|
678 | 678 | ); |
|
679 | 679 |
|
|
680 | 680 |
|
|
681 | 681 |
|
|
682 | 682 | } |
|
683 | 683 |
|
|
684 | 684 | } |
|
685 | 685 | } |
|
686 | 686 | |
|
687 | 687 | /** |
|
688 | 688 | * Quick filter widget |
|
689 | 689 |
* |
|
690 | 690 | * @param target: filter input target |
|
691 | 691 | * @param nodes: list of nodes in html we want to filter. |
|
692 | 692 | * @param display_element function that takes current node from nodes and |
|
693 | 693 | * does hide or show based on the node |
|
694 | 694 |
* |
|
695 | 695 | */ |
|
696 | 696 | var q_filter = function(target,nodes,display_element){ |
|
697 | 697 | |
|
698 | 698 |
|
|
699 | 699 |
|
|
700 | 700 |
|
|
701 | 701 | |
|
702 | 702 |
|
|
703 | 703 |
|
|
704 | 704 |
|
|
705 | 705 | }); |
|
706 | 706 | |
|
707 | 707 |
|
|
708 | 708 | |
|
709 | 709 |
|
|
710 | 710 |
|
|
711 | 711 | } |
|
712 | 712 |
|
|
713 | 713 |
|
|
714 | 714 | } |
|
715 | 715 | |
|
716 | 716 |
|
|
717 | 717 |
|
|
718 | 718 |
|
|
719 | 719 | |
|
720 | 720 |
|
|
721 | 721 | |
|
722 | 722 |
|
|
723 | 723 | |
|
724 | 724 |
|
|
725 | 725 |
|
|
726 | 726 |
|
|
727 | 727 | |
|
728 | 728 | for (i=0;i<l;i++ ){ |
|
729 | 729 |
|
|
730 | 730 |
|
|
731 | 731 |
|
|
732 | 732 |
|
|
733 | 733 |
|
|
734 | 734 |
|
|
735 | 735 |
|
|
736 | 736 |
|
|
737 | 737 |
|
|
738 | 738 |
} |
|
739 | 739 | |
|
740 | 740 |
|
|
741 | 741 |
|
|
742 | 742 |
|
|
743 | 743 |
|
|
744 | 744 |
|
|
745 | 745 | |
|
746 | 746 | } |
|
747 | 747 | }; |
|
748 | 748 | |
|
749 | 749 | var tableTr = function(cls, body){ |
|
750 | 750 |
|
|
751 | 751 |
|
|
752 | 752 |
|
|
753 | 753 |
|
|
754 | 754 |
|
|
755 | 755 |
|
|
756 | 756 |
|
|
757 | 757 | '<td>{2}</td>'+ |
|
758 | 758 | '</tr></tbody></table>').format(id, cls, body); |
|
759 | 759 |
|
|
760 | 760 |
|
|
761 | 761 | }; |
|
762 | 762 | |
|
763 | 763 | /** comments **/ |
|
764 | 764 | var removeInlineForm = function(form) { |
|
765 | 765 |
|
|
766 | 766 | }; |
|
767 | 767 | |
|
768 | 768 | var createInlineForm = function(parent_tr, f_path, line) { |
|
769 | 769 |
|
|
770 | 770 |
|
|
771 | 771 |
|
|
772 | 772 | |
|
773 | 773 |
|
|
774 | 774 |
|
|
775 | 775 |
|
|
776 | 776 |
|
|
777 | 777 |
|
|
778 | 778 |
|
|
779 | 779 |
|
|
780 | 780 | } |
|
781 | 781 |
|
|
782 | 782 |
|
|
783 | 783 |
|
|
784 | 784 | |
|
785 | 785 | }); |
|
786 | 786 | |
|
787 | 787 |
|
|
788 | 788 | }; |
|
789 | 789 | |
|
790 | 790 | /** |
|
791 | 791 | * Inject inline comment for on given TR this tr should be always an .line |
|
792 | 792 | * tr containing the line. Code will detect comment, and always put the comment |
|
793 | 793 | * block at the very bottom |
|
794 | 794 | */ |
|
795 | 795 | var injectInlineForm = function(tr){ |
|
796 | 796 |
|
|
797 | 797 |
|
|
798 | 798 | } |
|
799 | 799 |
|
|
800 | 800 |
|
|
801 | 801 |
|
|
802 | 802 |
|
|
803 | 803 | } |
|
804 | 804 |
|
|
805 | 805 |
|
|
806 | 806 |
|
|
807 | 807 |
|
|
808 | 808 |
|
|
809 | 809 |
|
|
810 | 810 | |
|
811 | 811 |
|
|
812 | 812 |
|
|
813 | 813 |
|
|
814 | 814 |
|
|
815 | 815 |
|
|
816 | 816 |
|
|
817 | 817 | } |
|
818 | 818 | else{ |
|
819 | 819 | break; |
|
820 | 820 | } |
|
821 | 821 | } |
|
822 | 822 |
|
|
823 | 823 |
|
|
824 | 824 |
|
|
825 | 825 |
|
|
826 | 826 | |
|
827 | 827 |
|
|
828 | 828 |
|
|
829 | 829 | |
|
830 | 830 |
|
|
831 | 831 |
|
|
832 | 832 |
|
|
833 | 833 |
|
|
834 | 834 |
|
|
835 | 835 |
|
|
836 | 836 | }; |
|
837 | 837 | |
|
838 | 838 |
|
|
839 | 839 |
|
|
840 | 840 | return |
|
841 | 841 | } |
|
842 | 842 |
|
|
843 | 843 |
|
|
844 | 844 | return |
|
845 | 845 | } |
|
846 | 846 | |
|
847 | 847 |
|
|
848 | 848 | return |
|
849 | 849 | } |
|
850 | 850 | |
|
851 | 851 |
|
|
852 | 852 |
|
|
853 | 853 |
|
|
854 | 854 |
|
|
855 | 855 |
|
|
856 | 856 | }; |
|
857 | 857 | |
|
858 | 858 |
|
|
859 | 859 |
|
|
860 | 860 |
|
|
861 | 861 |
|
|
862 | 862 |
|
|
863 | 863 | } |
|
864 | 864 |
|
|
865 | 865 | |
|
866 | 866 |
|
|
867 | 867 |
|
|
868 | 868 | |
|
869 | 869 |
|
|
870 | 870 |
|
|
871 | 871 |
|
|
872 | 872 |
|
|
873 | 873 |
|
|
874 | 874 |
|
|
875 | 875 |
|
|
876 | 876 |
|
|
877 | 877 |
|
|
878 | 878 |
|
|
879 | 879 | |
|
880 | 880 |
|
|
881 | 881 |
|
|
882 | 882 |
|
|
883 | 883 |
|
|
884 | 884 |
|
|
885 | 885 |
|
|
886 | 886 |
|
|
887 | 887 |
|
|
888 | 888 |
|
|
889 | 889 | }) |
|
890 | 890 | |
|
891 | 891 | |
|
892 | 892 |
|
|
893 | 893 |
|
|
894 | 894 |
|
|
895 | 895 |
|
|
896 | 896 |
|
|
897 | 897 |
|
|
898 | 898 |
|
|
899 | 899 |
|
|
900 | 900 | } |
|
901 | 901 |
|
|
902 | 902 | }; |
|
903 | 903 | |
|
904 | 904 | var deleteComment = function(comment_id){ |
|
905 | 905 |
|
|
906 | 906 | var postData = {'_method':'delete'}; |
|
907 | 907 | var success = function(o){ |
|
908 | 908 | var n = YUD.get('comment-tr-'+comment_id); |
|
909 | 909 | var root = prevElementSibling(prevElementSibling(n)); |
|
910 | 910 | n.parentNode.removeChild(n); |
|
911 | 911 | |
|
912 | 912 | // scann nodes, and attach add button to last one only for TR |
|
913 | 913 | // which are the inline comments |
|
914 | 914 | if(root && root.tagName == 'TR'){ |
|
915 | 915 |
|
|
916 | 916 | } |
|
917 | 917 | } |
|
918 | 918 | ajaxPOST(url,postData,success); |
|
919 | 919 | } |
|
920 | 920 | |
|
921 | 921 | var createInlineAddButton = function(tr){ |
|
922 | 922 | |
|
923 | 923 |
|
|
924 | 924 | |
|
925 | 925 |
|
|
926 | 926 |
|
|
927 | 927 |
|
|
928 | 928 | |
|
929 | 929 |
|
|
930 | 930 |
|
|
931 | 931 |
|
|
932 | 932 | }); |
|
933 | 933 |
|
|
934 | 934 | }; |
|
935 | 935 | |
|
936 | 936 | var getLineNo = function(tr) { |
|
937 | 937 |
|
|
938 | 938 |
|
|
939 | 939 |
|
|
940 | 940 | |
|
941 | 941 |
|
|
942 | 942 |
|
|
943 | 943 |
|
|
944 | 944 |
|
|
945 | 945 | } |
|
946 | 946 | |
|
947 | 947 |
|
|
948 | 948 | }; |
|
949 | 949 | |
|
950 | 950 | var placeAddButton = function(target_tr){ |
|
951 | 951 |
|
|
952 | 952 | return |
|
953 | 953 | } |
|
954 | 954 |
|
|
955 | 955 |
//scann |
|
956 | 956 |
|
|
957 | 957 |
|
|
958 | 958 |
|
|
959 | 959 |
|
|
960 | 960 |
|
|
961 | 961 |
|
|
962 | 962 |
|
|
963 | 963 |
|
|
964 | 964 |
|
|
965 | 965 |
|
|
966 | 966 | } |
|
967 | 967 | } |
|
968 | 968 | else{ |
|
969 | 969 | break; |
|
970 | 970 | } |
|
971 | 971 | } |
|
972 | 972 | |
|
973 | 973 | var add = createInlineAddButton(target_tr); |
|
974 | 974 | // get the comment div |
|
975 | 975 | var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0]; |
|
976 | 976 | // attach add button |
|
977 | 977 |
YUD.insertAfter(add,comment_block); |
|
978 | 978 | } |
|
979 | 979 | |
|
980 | 980 | /** |
|
981 | 981 | * Places the inline comment into the changeset block in proper line position |
|
982 | 982 | */ |
|
983 | 983 | var placeInline = function(target_container,lineno,html){ |
|
984 | 984 |
|
|
985 | 985 |
|
|
986 | 986 |
|
|
987 | 987 | |
|
988 | 988 |
|
|
989 | 989 |
|
|
990 | 990 |
|
|
991 | 991 |
|
|
992 | 992 |
|
|
993 | 993 |
|
|
994 | 994 |
|
|
995 | 995 |
|
|
996 | 996 | } |
|
997 | 997 | else{ |
|
998 | 998 | break; |
|
999 | 999 | } |
|
1000 | 1000 | } |
|
1001 | 1001 |
|
|
1002 | 1002 |
|
|
1003 | 1003 | |
|
1004 | 1004 |
|
|
1005 | 1005 | placeAddButton(root_parent); |
|
1006 | 1006 | |
|
1007 | 1007 |
|
|
1008 | 1008 | } |
|
1009 | 1009 | |
|
1010 | 1010 | /** |
|
1011 | 1011 | * make a single inline comment and place it inside |
|
1012 | 1012 | */ |
|
1013 | 1013 | var renderInlineComment = function(json_data){ |
|
1014 | 1014 | try{ |
|
1015 | 1015 |
|
|
1016 | 1016 |
|
|
1017 | 1017 |
|
|
1018 | 1018 |
|
|
1019 | 1019 | |
|
1020 | 1020 | }catch(e){ |
|
1021 | 1021 |
|
|
1022 | 1022 | } |
|
1023 | 1023 | } |
|
1024 | 1024 | |
|
1025 | 1025 | /** |
|
1026 | 1026 | * Iterates over all the inlines, and places them inside proper blocks of data |
|
1027 | 1027 | */ |
|
1028 | 1028 | var renderInlineComments = function(file_comments){ |
|
1029 | 1029 |
|
|
1030 | 1030 | // holding all comments for a FILE |
|
1031 | 1031 |
|
|
1032 | 1032 | |
|
1033 | 1033 |
|
|
1034 | 1034 |
|
|
1035 | 1035 | var comments = box.children; |
|
1036 | 1036 | for(var i=0; i<comments.length; i++){ |
|
1037 | 1037 |
|
|
1038 | 1038 |
|
|
1039 | 1039 |
|
|
1040 | 1040 |
|
|
1041 | 1041 |
|
|
1042 | 1042 |
|
|
1043 | 1043 | } |
|
1044 | 1044 |
} |
|
1045 | 1045 | } |
|
1046 | 1046 | |
|
1047 | 1047 | var fileBrowserListeners = function(current_url, node_list_url, url_base){ |
|
1048 | 1048 |
|
|
1049 | 1049 | |
|
1050 | 1050 |
|
|
1051 | 1051 |
|
|
1052 | 1052 |
|
|
1053 | 1053 |
|
|
1054 | 1054 |
|
|
1055 | 1055 |
|
|
1056 | 1056 |
|
|
1057 | 1057 |
|
|
1058 | 1058 |
|
|
1059 | 1059 | }) |
|
1060 | 1060 | |
|
1061 | 1061 |
|
|
1062 | 1062 |
|
|
1063 | 1063 | |
|
1064 | 1064 |
|
|
1065 | 1065 |
|
|
1066 | 1066 | |
|
1067 | 1067 |
|
|
1068 | 1068 |
|
|
1069 | 1069 |
|
|
1070 | 1070 |
|
|
1071 | 1071 |
|
|
1072 | 1072 |
|
|
1073 | 1073 |
|
|
1074 | 1074 |
|
|
1075 | 1075 |
|
|
1076 | 1076 |
|
|
1077 | 1077 |
|
|
1078 | 1078 |
|
|
1079 | 1079 |
|
|
1080 | 1080 |
|
|
1081 | 1081 | } |
|
1082 | 1082 |
|
|
1083 | 1083 |
|
|
1084 | 1084 |
|
|
1085 | 1085 |
|
|
1086 | 1086 | },null); |
|
1087 | 1087 | } |
|
1088 | 1088 | |
|
1089 | 1089 |
|
|
1090 | 1090 | |
|
1091 | 1091 |
|
|
1092 | 1092 |
|
|
1093 | 1093 |
|
|
1094 | 1094 |
|
|
1095 | 1095 |
|
|
1096 | 1096 |
|
|
1097 | 1097 |
|
|
1098 | 1098 |
|
|
1099 | 1099 |
|
|
1100 | 1100 | |
|
1101 | 1101 |
|
|
1102 | 1102 |
|
|
1103 | 1103 | |
|
1104 | 1104 |
|
|
1105 | 1105 |
|
|
1106 | 1106 |
|
|
1107 | 1107 |
|
|
1108 | 1108 |
|
|
1109 | 1109 | |
|
1110 | 1110 |
|
|
1111 | 1111 |
|
|
1112 | 1112 |
|
|
1113 | 1113 |
|
|
1114 | 1114 |
|
|
1115 | 1115 |
|
|
1116 | 1116 |
|
|
1117 | 1117 |
|
|
1118 | 1118 |
|
|
1119 | 1119 |
|
|
1120 | 1120 |
|
|
1121 | 1121 | } |
|
1122 | 1122 |
|
|
1123 | 1123 |
|
|
1124 | 1124 |
|
|
1125 | 1125 |
|
|
1126 | 1126 | |
|
1127 | 1127 |
|
|
1128 | 1128 |
|
|
1129 | 1129 | } |
|
1130 | 1130 | |
|
1131 | 1131 |
|
|
1132 | 1132 |
|
|
1133 | 1133 |
|
|
1134 | 1134 |
|
|
1135 | 1135 |
|
|
1136 | 1136 |
|
|
1137 | 1137 | |
|
1138 | 1138 |
|
|
1139 | 1139 | }; |
|
1140 | 1140 | |
|
1141 | 1141 |
|
|
1142 | 1142 |
|
|
1143 | 1143 | }) |
|
1144 | 1144 |
|
|
1145 | 1145 |
|
|
1146 | 1146 |
|
|
1147 | 1147 |
|
|
1148 | 1148 | } |
|
1149 | 1149 |
|
|
1150 | 1150 |
|
|
1151 | 1151 |
|
|
1152 | 1152 |
|
|
1153 | 1153 | }); |
|
1154 | 1154 | }; |
|
1155 | 1155 | |
|
1156 | 1156 | |
|
1157 | 1157 |
var initCodeMirror = function(textAreadId,resetUrl){ |
|
1158 | 1158 | var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ |
|
1159 | 1159 | mode: "null", |
|
1160 | 1160 | lineNumbers:true |
|
1161 | 1161 | }); |
|
1162 | 1162 | YUE.on('reset','click',function(e){ |
|
1163 | 1163 | window.location=resetUrl |
|
1164 | 1164 | }); |
|
1165 | 1165 | |
|
1166 | 1166 | YUE.on('file_enable','click',function(){ |
|
1167 | 1167 | YUD.setStyle('editor_container','display',''); |
|
1168 | 1168 | YUD.setStyle('upload_file_container','display','none'); |
|
1169 | 1169 | YUD.setStyle('filename_container','display',''); |
|
1170 | 1170 | }); |
|
1171 | 1171 | |
|
1172 | 1172 | YUE.on('upload_file_enable','click',function(){ |
|
1173 | 1173 | YUD.setStyle('editor_container','display','none'); |
|
1174 | 1174 | YUD.setStyle('upload_file_container','display',''); |
|
1175 | 1175 | YUD.setStyle('filename_container','display','none'); |
|
1176 | 1176 |
}); |
|
1177 | 1177 | }; |
|
1178 | 1178 | |
|
1179 | 1179 | |
|
1180 | 1180 | |
|
1181 | 1181 | var getIdentNode = function(n){ |
|
1182 | 1182 |
|
|
1183 | 1183 | |
|
1184 | 1184 |
|
|
1185 | 1185 |
|
|
1186 | 1186 | } |
|
1187 | 1187 | |
|
1188 | 1188 |
|
|
1189 | 1189 | return n |
|
1190 | 1190 | } |
|
1191 | 1191 |
|
|
1192 | 1192 |
|
|
1193 | 1193 | } |
|
1194 | 1194 | }; |
|
1195 | 1195 | |
|
1196 | 1196 | var getSelectionLink = function(e) { |
|
1197 | 1197 | |
|
1198 | 1198 |
|
|
1199 | 1199 |
|
|
1200 | 1200 |
|
|
1201 | 1201 | |
|
1202 | 1202 |
|
|
1203 | 1203 |
|
|
1204 | 1204 | |
|
1205 | 1205 |
|
|
1206 | 1206 |
|
|
1207 | 1207 | |
|
1208 | 1208 |
|
|
1209 | 1209 |
|
|
1210 | 1210 |
|
|
1211 | 1211 |
|
|
1212 | 1212 | |
|
1213 | 1213 |
|
|
1214 | 1214 |
|
|
1215 | 1215 |
|
|
1216 | 1216 |
|
|
1217 | 1217 |
|
|
1218 | 1218 |
|
|
1219 | 1219 |
|
|
1220 | 1220 |
|
|
1221 | 1221 |
|
|
1222 | 1222 |
|
|
1223 | 1223 |
|
|
1224 | 1224 |
|
|
1225 | 1225 |
|
|
1226 | 1226 | |
|
1227 | 1227 |
|
|
1228 | 1228 |
|
|
1229 | 1229 |
|
|
1230 | 1230 |
|
|
1231 | 1231 |
|
|
1232 | 1232 |
|
|
1233 | 1233 | |
|
1234 | 1234 |
|
|
1235 | 1235 | |
|
1236 | 1236 |
|
|
1237 | 1237 |
|
|
1238 | 1238 |
|
|
1239 | 1239 |
|
|
1240 | 1240 | |
|
1241 | 1241 |
|
|
1242 | 1242 |
|
|
1243 | 1243 |
|
|
1244 | 1244 |
|
|
1245 | 1245 | } |
|
1246 | 1246 | }; |
|
1247 | 1247 | |
|
1248 | 1248 | var deleteNotification = function(url, notification_id,callbacks){ |
|
1249 | 1249 |
var callback = { |
|
1250 | 1250 |
|
|
1251 | 1251 |
|
|
1252 | 1252 |
|
|
1253 | 1253 |
|
|
1254 | 1254 | } |
|
1255 | 1255 |
|
|
1256 | 1256 | }, |
|
1257 | 1257 |
|
|
1258 | 1258 |
|
|
1259 | 1259 |
|
|
1260 | 1260 | }; |
|
1261 | 1261 | var postData = '_method=delete'; |
|
1262 | 1262 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
1263 | 1263 |
var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
1264 | 1264 | callback, postData); |
|
1265 | 1265 |
}; |
|
1266 | 1266 | |
|
1267 | 1267 | var readNotification = function(url, notification_id,callbacks){ |
|
1268 | 1268 |
var callback = { |
|
1269 | 1269 |
|
|
1270 | 1270 |
|
|
1271 | 1271 |
|
|
1272 | 1272 |
|
|
1273 | 1273 | |
|
1274 | 1274 |
|
|
1275 | 1275 |
|
|
1276 | 1276 | } |
|
1277 | 1277 |
|
|
1278 | 1278 | }, |
|
1279 | 1279 |
|
|
1280 | 1280 |
|
|
1281 | 1281 |
|
|
1282 | 1282 | }; |
|
1283 | 1283 | var postData = '_method=put'; |
|
1284 | 1284 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
1285 | 1285 |
var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
1286 | 1286 | callback, postData); |
|
1287 | 1287 |
}; |
|
1288 | 1288 | |
|
1289 | 1289 | /** MEMBERS AUTOCOMPLETE WIDGET **/ |
|
1290 | 1290 | |
|
1291 | 1291 | var MembersAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1292 | 1292 | var myUsers = users_list; |
|
1293 | 1293 | var myGroups = groups_list; |
|
1294 | 1294 | |
|
1295 | 1295 | // Define a custom search function for the DataSource of users |
|
1296 | 1296 | var matchUsers = function (sQuery) { |
|
1297 | 1297 | // Case insensitive matching |
|
1298 | 1298 | var query = sQuery.toLowerCase(); |
|
1299 | 1299 | var i = 0; |
|
1300 | 1300 | var l = myUsers.length; |
|
1301 | 1301 | var matches = []; |
|
1302 | 1302 | |
|
1303 | 1303 | // Match against each name of each contact |
|
1304 | 1304 | for (; i < l; i++) { |
|
1305 | 1305 | contact = myUsers[i]; |
|
1306 | 1306 |
if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
1307 | 1307 |
|
|
1308 | 1308 |
|
|
1309 | 1309 | matches[matches.length] = contact; |
|
1310 | 1310 | } |
|
1311 | 1311 | } |
|
1312 | 1312 | return matches; |
|
1313 | 1313 | }; |
|
1314 | 1314 | |
|
1315 | 1315 | // Define a custom search function for the DataSource of userGroups |
|
1316 | 1316 | var matchGroups = function (sQuery) { |
|
1317 | 1317 | // Case insensitive matching |
|
1318 | 1318 | var query = sQuery.toLowerCase(); |
|
1319 | 1319 | var i = 0; |
|
1320 | 1320 | var l = myGroups.length; |
|
1321 | 1321 | var matches = []; |
|
1322 | 1322 | |
|
1323 | 1323 | // Match against each name of each contact |
|
1324 | 1324 | for (; i < l; i++) { |
|
1325 | 1325 | matched_group = myGroups[i]; |
|
1326 | 1326 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { |
|
1327 | 1327 | matches[matches.length] = matched_group; |
|
1328 | 1328 | } |
|
1329 | 1329 | } |
|
1330 | 1330 | return matches; |
|
1331 | 1331 | }; |
|
1332 | 1332 | |
|
1333 | 1333 | //match all |
|
1334 | 1334 | var matchAll = function (sQuery) { |
|
1335 | 1335 | u = matchUsers(sQuery); |
|
1336 | 1336 | g = matchGroups(sQuery); |
|
1337 | 1337 | return u.concat(g); |
|
1338 | 1338 | }; |
|
1339 | 1339 | |
|
1340 | 1340 | // DataScheme for members |
|
1341 | 1341 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); |
|
1342 | 1342 | memberDS.responseSchema = { |
|
1343 | 1343 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"] |
|
1344 | 1344 | }; |
|
1345 | 1345 | |
|
1346 | 1346 | // DataScheme for owner |
|
1347 | 1347 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
1348 | 1348 | ownerDS.responseSchema = { |
|
1349 | 1349 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
1350 | 1350 | }; |
|
1351 | 1351 | |
|
1352 | 1352 | // Instantiate AutoComplete for perms |
|
1353 | 1353 | var membersAC = new YAHOO.widget.AutoComplete(divid, cont, memberDS); |
|
1354 | 1354 | membersAC.useShadow = false; |
|
1355 | 1355 | membersAC.resultTypeList = false; |
|
1356 | 1356 | membersAC.animVert = false; |
|
1357 | 1357 |
membersAC.animHoriz = false; |
|
1358 | 1358 | membersAC.animSpeed = 0.1; |
|
1359 | 1359 | |
|
1360 | 1360 | // Instantiate AutoComplete for owner |
|
1361 | 1361 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); |
|
1362 | 1362 | ownerAC.useShadow = false; |
|
1363 | 1363 | ownerAC.resultTypeList = false; |
|
1364 | 1364 | ownerAC.animVert = false; |
|
1365 | 1365 | ownerAC.animHoriz = false; |
|
1366 | 1366 | ownerAC.animSpeed = 0.1; |
|
1367 | 1367 | |
|
1368 | 1368 | // Helper highlight function for the formatter |
|
1369 | 1369 | var highlightMatch = function (full, snippet, matchindex) { |
|
1370 | 1370 |
return full.substring(0, matchindex) |
|
1371 | 1371 |
+ "<span class='match'>" |
|
1372 | 1372 |
+ full.substr(matchindex, snippet.length) |
|
1373 | 1373 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1374 | 1374 | }; |
|
1375 | 1375 | |
|
1376 | 1376 | // Custom formatter to highlight the matching letters |
|
1377 | 1377 | var custom_formatter = function (oResultData, sQuery, sResultMatch) { |
|
1378 | 1378 | var query = sQuery.toLowerCase(); |
|
1379 | 1379 | var _gravatar = function(res, em, group){ |
|
1380 | 1380 |
|
|
1381 | 1381 |
|
|
1382 | 1382 |
|
|
1383 | 1383 |
|
|
1384 | 1384 |
|
|
1385 | 1385 | } |
|
1386 | 1386 | // group |
|
1387 | 1387 | if (oResultData.grname != undefined) { |
|
1388 | 1388 | var grname = oResultData.grname; |
|
1389 | 1389 | var grmembers = oResultData.grmembers; |
|
1390 | 1390 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); |
|
1391 | 1391 | var grprefix = "{0}: ".format(_TM['Group']); |
|
1392 | 1392 | var grsuffix = " (" + grmembers + " )"; |
|
1393 | 1393 | var grsuffix = " ({0} {1})".format(grmembers, _TM['members']); |
|
1394 | 1394 | |
|
1395 | 1395 | if (grnameMatchIndex > -1) { |
|
1396 | 1396 | return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true); |
|
1397 | 1397 | } |
|
1398 | 1398 |
|
|
1399 | 1399 | // Users |
|
1400 | 1400 | } else if (oResultData.nname != undefined) { |
|
1401 | 1401 | var fname = oResultData.fname || ""; |
|
1402 | 1402 | var lname = oResultData.lname || ""; |
|
1403 | 1403 | var nname = oResultData.nname; |
|
1404 | 1404 | |
|
1405 | 1405 | // Guard against null value |
|
1406 | 1406 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1407 | 1407 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
1408 | 1408 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
1409 | 1409 | displayfname, displaylname, displaynname; |
|
1410 | 1410 | |
|
1411 | 1411 | if (fnameMatchIndex > -1) { |
|
1412 | 1412 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
1413 | 1413 | } else { |
|
1414 | 1414 | displayfname = fname; |
|
1415 | 1415 | } |
|
1416 | 1416 | |
|
1417 | 1417 | if (lnameMatchIndex > -1) { |
|
1418 | 1418 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
1419 | 1419 | } else { |
|
1420 | 1420 | displaylname = lname; |
|
1421 | 1421 | } |
|
1422 | 1422 | |
|
1423 | 1423 | if (nnameMatchIndex > -1) { |
|
1424 | 1424 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
1425 | 1425 | } else { |
|
1426 | 1426 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1427 | 1427 | } |
|
1428 | 1428 | |
|
1429 | 1429 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1430 | 1430 | } else { |
|
1431 | 1431 | return ''; |
|
1432 | 1432 | } |
|
1433 | 1433 | }; |
|
1434 | 1434 | membersAC.formatResult = custom_formatter; |
|
1435 | 1435 | ownerAC.formatResult = custom_formatter; |
|
1436 | 1436 | |
|
1437 | 1437 | var myHandler = function (sType, aArgs) { |
|
1438 | 1438 |
|
|
1439 | 1439 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1440 | 1440 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1441 | 1441 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1442 | 1442 | //fill the autocomplete with value |
|
1443 | 1443 | if (oData.nname != undefined) { |
|
1444 | 1444 | //users |
|
1445 | 1445 | myAC.getInputEl().value = oData.nname; |
|
1446 | 1446 | YUD.get('perm_new_member_type_'+nextId).value = 'user'; |
|
1447 | 1447 | } else { |
|
1448 | 1448 | //groups |
|
1449 | 1449 | myAC.getInputEl().value = oData.grname; |
|
1450 | 1450 | YUD.get('perm_new_member_type_'+nextId).value = 'users_group'; |
|
1451 | 1451 | } |
|
1452 | 1452 | }; |
|
1453 | 1453 | |
|
1454 | 1454 | membersAC.itemSelectEvent.subscribe(myHandler); |
|
1455 | 1455 | if(ownerAC.itemSelectEvent){ |
|
1456 | 1456 |
|
|
1457 | 1457 | } |
|
1458 | 1458 | |
|
1459 | 1459 | return { |
|
1460 | 1460 | memberDS: memberDS, |
|
1461 | 1461 | ownerDS: ownerDS, |
|
1462 | 1462 | membersAC: membersAC, |
|
1463 | 1463 | ownerAC: ownerAC, |
|
1464 | 1464 | }; |
|
1465 | 1465 | } |
|
1466 | 1466 | |
|
1467 | 1467 | |
|
1468 | 1468 | var MentionsAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1469 | 1469 | var myUsers = users_list; |
|
1470 | 1470 | var myGroups = groups_list; |
|
1471 | 1471 | |
|
1472 | 1472 | // Define a custom search function for the DataSource of users |
|
1473 | 1473 | var matchUsers = function (sQuery) { |
|
1474 | 1474 |
|
|
1475 | 1475 |
|
|
1476 | 1476 |
|
|
1477 | 1477 |
|
|
1478 | 1478 |
|
|
1479 | 1479 | // Case insensitive matching |
|
1480 | 1480 | var query = sQuery.toLowerCase(); |
|
1481 | 1481 | var i = 0; |
|
1482 | 1482 | var l = myUsers.length; |
|
1483 | 1483 | var matches = []; |
|
1484 | 1484 | |
|
1485 | 1485 | // Match against each name of each contact |
|
1486 | 1486 | for (; i < l; i++) { |
|
1487 | 1487 | contact = myUsers[i]; |
|
1488 | 1488 |
if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
1489 | 1489 |
|
|
1490 | 1490 |
|
|
1491 | 1491 | matches[matches.length] = contact; |
|
1492 | 1492 | } |
|
1493 | 1493 | } |
|
1494 | 1494 | return matches |
|
1495 | 1495 | }; |
|
1496 | 1496 | |
|
1497 | 1497 | //match all |
|
1498 | 1498 | var matchAll = function (sQuery) { |
|
1499 | 1499 | u = matchUsers(sQuery); |
|
1500 | 1500 | return u |
|
1501 | 1501 | }; |
|
1502 | 1502 | |
|
1503 | 1503 | // DataScheme for owner |
|
1504 | 1504 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
1505 | 1505 | |
|
1506 | 1506 | ownerDS.responseSchema = { |
|
1507 | 1507 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
1508 | 1508 | }; |
|
1509 | 1509 | |
|
1510 | 1510 | // Instantiate AutoComplete for mentions |
|
1511 | 1511 | var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); |
|
1512 | 1512 | ownerAC.useShadow = false; |
|
1513 | 1513 | ownerAC.resultTypeList = false; |
|
1514 | 1514 | ownerAC.suppressInputUpdate = true; |
|
1515 | 1515 | ownerAC.animVert = false; |
|
1516 | 1516 |
ownerAC.animHoriz = false; |
|
1517 | 1517 | ownerAC.animSpeed = 0.1; |
|
1518 | 1518 | |
|
1519 | 1519 | // Helper highlight function for the formatter |
|
1520 | 1520 | var highlightMatch = function (full, snippet, matchindex) { |
|
1521 | 1521 |
return full.substring(0, matchindex) |
|
1522 | 1522 |
+ "<span class='match'>" |
|
1523 | 1523 |
+ full.substr(matchindex, snippet.length) |
|
1524 | 1524 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1525 | 1525 | }; |
|
1526 | 1526 | |
|
1527 | 1527 | // Custom formatter to highlight the matching letters |
|
1528 | 1528 | ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
|
1529 | 1529 |
|
|
1530 | 1530 |
|
|
1531 | 1531 |
|
|
1532 | 1532 | } |
|
1533 | 1533 | |
|
1534 | 1534 | var query = sQuery.toLowerCase(); |
|
1535 | 1535 | var _gravatar = function(res, em, group){ |
|
1536 | 1536 |
|
|
1537 | 1537 |
|
|
1538 | 1538 |
|
|
1539 | 1539 |
|
|
1540 | 1540 |
|
|
1541 | 1541 | } |
|
1542 | 1542 | if (oResultData.nname != undefined) { |
|
1543 | 1543 | var fname = oResultData.fname || ""; |
|
1544 | 1544 | var lname = oResultData.lname || ""; |
|
1545 | 1545 | var nname = oResultData.nname; |
|
1546 | 1546 | |
|
1547 | 1547 | // Guard against null value |
|
1548 | 1548 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1549 | 1549 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
1550 | 1550 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
1551 | 1551 | displayfname, displaylname, displaynname; |
|
1552 | 1552 | |
|
1553 | 1553 | if (fnameMatchIndex > -1) { |
|
1554 | 1554 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
1555 | 1555 | } else { |
|
1556 | 1556 | displayfname = fname; |
|
1557 | 1557 | } |
|
1558 | 1558 | |
|
1559 | 1559 | if (lnameMatchIndex > -1) { |
|
1560 | 1560 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
1561 | 1561 | } else { |
|
1562 | 1562 | displaylname = lname; |
|
1563 | 1563 | } |
|
1564 | 1564 | |
|
1565 | 1565 | if (nnameMatchIndex > -1) { |
|
1566 | 1566 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
1567 | 1567 | } else { |
|
1568 | 1568 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1569 | 1569 | } |
|
1570 | 1570 | |
|
1571 | 1571 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1572 | 1572 | } else { |
|
1573 | 1573 | return ''; |
|
1574 | 1574 | } |
|
1575 | 1575 | }; |
|
1576 | 1576 | |
|
1577 | 1577 | if(ownerAC.itemSelectEvent){ |
|
1578 | 1578 |
|
|
1579 | 1579 | |
|
1580 | 1580 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1581 | 1581 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1582 | 1582 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1583 | 1583 | //fill the autocomplete with value |
|
1584 | 1584 | if (oData.nname != undefined) { |
|
1585 | 1585 | //users |
|
1586 | 1586 |
|
|
1587 | 1587 |
|
|
1588 | 1588 |
|
|
1589 | 1589 |
|
|
1590 | 1590 |
|
|
1591 | 1591 |
|
|
1592 | 1592 |
|
|
1593 | 1593 | myAC.getInputEl().value = chunks.join('') |
|
1594 | 1594 | YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !? |
|
1595 | 1595 | } else { |
|
1596 | 1596 | //groups |
|
1597 | 1597 | myAC.getInputEl().value = oData.grname; |
|
1598 | 1598 | YUD.get('perm_new_member_type').value = 'users_group'; |
|
1599 | 1599 | } |
|
1600 | 1600 | }); |
|
1601 | 1601 | } |
|
1602 | 1602 | |
|
1603 | 1603 | // in this keybuffer we will gather current value of search ! |
|
1604 | 1604 | // since we need to get this just when someone does `@` then we do the |
|
1605 | 1605 | // search |
|
1606 | 1606 | ownerAC.dataSource.chunks = []; |
|
1607 | 1607 | ownerAC.dataSource.mentionQuery = null; |
|
1608 | 1608 | |
|
1609 | 1609 | ownerAC.get_mention = function(msg, max_pos) { |
|
1610 | 1610 |
|
|
1611 | 1611 |
|
|
1612 | 1612 |
|
|
1613 | 1613 | |
|
1614 | 1614 | |
|
1615 | 1615 |
|
|
1616 | 1616 |
|
|
1617 | 1617 |
|
|
1618 | 1618 |
|
|
1619 | 1619 | |
|
1620 | 1620 |
|
|
1621 | 1621 |
|
|
1622 | 1622 |
|
|
1623 | 1623 | |
|
1624 | 1624 |
|
|
1625 | 1625 |
|
|
1626 | 1626 | |
|
1627 | 1627 |
|
|
1628 | 1628 |
|
|
1629 | 1629 |
|
|
1630 | 1630 | } |
|
1631 | 1631 |
|
|
1632 | 1632 | }; |
|
1633 | 1633 | |
|
1634 | 1634 | if (ownerAC.textboxKeyUpEvent){ |
|
1635 | 1635 |
|
|
1636 | 1636 | |
|
1637 | 1637 |
|
|
1638 | 1638 |
|
|
1639 | 1639 |
|
|
1640 | 1640 | |
|
1641 | 1641 |
|
|
1642 | 1642 |
|
|
1643 | 1643 |
|
|
1644 | 1644 |
|
|
1645 | 1645 | } |
|
1646 | 1646 | |
|
1647 | 1647 |
|
|
1648 | 1648 |
|
|
1649 | 1649 | |
|
1650 | 1650 | }) |
|
1651 | 1651 | } |
|
1652 | 1652 | return { |
|
1653 | 1653 | ownerDS: ownerDS, |
|
1654 | 1654 | ownerAC: ownerAC, |
|
1655 | 1655 | }; |
|
1656 | 1656 | } |
|
1657 | 1657 | |
|
1658 | 1658 | var addReviewMember = function(id,fname,lname,nname,gravatar_link){ |
|
1659 | 1659 |
|
|
1660 | 1660 |
|
|
1661 | 1661 | '<div class="reviewers_member">'+ |
|
1662 | 1662 | '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+ |
|
1663 | 1663 | '<div style="float:left">{1}</div>'+ |
|
1664 | 1664 | '<input type="hidden" value="{2}" name="review_members" />'+ |
|
1665 | 1665 | '<span class="delete_icon action_button" onclick="removeReviewMember({2})"></span>'+ |
|
1666 | 1666 | '</div>'+ |
|
1667 | 1667 |
'</li>' |
|
1668 | 1668 | var displayname = "{0} {1} ({2})".format(fname,lname,nname); |
|
1669 | 1669 |
|
|
1670 | 1670 |
|
|
1671 | 1671 |
|
|
1672 | 1672 |
|
|
1673 | 1673 |
|
|
1674 | 1674 |
|
|
1675 | 1675 | } |
|
1676 | 1676 |
|
|
1677 | 1677 |
|
|
1678 | 1678 |
|
|
1679 | 1679 | } |
|
1680 | 1680 | |
|
1681 | 1681 | } |
|
1682 | 1682 | |
|
1683 | 1683 | var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){ |
|
1684 | 1684 |
|
|
1685 | 1685 |
|
|
1686 | 1686 |
|
|
1687 | 1687 | } |
|
1688 | 1688 | } |
|
1689 | 1689 | |
|
1690 | 1690 | var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ |
|
1691 | 1691 |
|
|
1692 | 1692 |
|
|
1693 | 1693 |
|
|
1694 | 1694 |
|
|
1695 | 1695 |
|
|
1696 | 1696 |
|
|
1697 | 1697 | } |
|
1698 | 1698 | } |
|
1699 | 1699 |
|
|
1700 | 1700 | "pull_request_id": pull_request_id}); |
|
1701 | 1701 |
|
|
1702 | 1702 |
|
|
1703 | 1703 |
|
|
1704 | 1704 |
|
|
1705 | 1705 | } |
|
1706 | 1706 |
|
|
1707 | 1707 | } |
|
1708 | 1708 | |
|
1709 | 1709 | var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1710 | 1710 | var myUsers = users_list; |
|
1711 | 1711 | var myGroups = groups_list; |
|
1712 | 1712 | |
|
1713 | 1713 | // Define a custom search function for the DataSource of users |
|
1714 | 1714 | var matchUsers = function (sQuery) { |
|
1715 | 1715 | // Case insensitive matching |
|
1716 | 1716 | var query = sQuery.toLowerCase(); |
|
1717 | 1717 | var i = 0; |
|
1718 | 1718 | var l = myUsers.length; |
|
1719 | 1719 | var matches = []; |
|
1720 | 1720 | |
|
1721 | 1721 | // Match against each name of each contact |
|
1722 | 1722 | for (; i < l; i++) { |
|
1723 | 1723 | contact = myUsers[i]; |
|
1724 | 1724 |
if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
1725 | 1725 |
|
|
1726 | 1726 |
|
|
1727 | 1727 | matches[matches.length] = contact; |
|
1728 | 1728 | } |
|
1729 | 1729 | } |
|
1730 | 1730 | return matches; |
|
1731 | 1731 | }; |
|
1732 | 1732 | |
|
1733 | 1733 | // Define a custom search function for the DataSource of userGroups |
|
1734 | 1734 | var matchGroups = function (sQuery) { |
|
1735 | 1735 | // Case insensitive matching |
|
1736 | 1736 | var query = sQuery.toLowerCase(); |
|
1737 | 1737 | var i = 0; |
|
1738 | 1738 | var l = myGroups.length; |
|
1739 | 1739 | var matches = []; |
|
1740 | 1740 | |
|
1741 | 1741 | // Match against each name of each contact |
|
1742 | 1742 | for (; i < l; i++) { |
|
1743 | 1743 | matched_group = myGroups[i]; |
|
1744 | 1744 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { |
|
1745 | 1745 | matches[matches.length] = matched_group; |
|
1746 | 1746 | } |
|
1747 | 1747 | } |
|
1748 | 1748 | return matches; |
|
1749 | 1749 | }; |
|
1750 | 1750 | |
|
1751 | 1751 | //match all |
|
1752 | 1752 | var matchAll = function (sQuery) { |
|
1753 | 1753 | u = matchUsers(sQuery); |
|
1754 | 1754 | return u |
|
1755 | 1755 | }; |
|
1756 | 1756 | |
|
1757 | 1757 | // DataScheme for owner |
|
1758 | 1758 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
1759 | 1759 | |
|
1760 | 1760 | ownerDS.responseSchema = { |
|
1761 | 1761 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
1762 | 1762 | }; |
|
1763 | 1763 | |
|
1764 | 1764 | // Instantiate AutoComplete for mentions |
|
1765 | 1765 | var reviewerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); |
|
1766 | 1766 | reviewerAC.useShadow = false; |
|
1767 | 1767 | reviewerAC.resultTypeList = false; |
|
1768 | 1768 | reviewerAC.suppressInputUpdate = true; |
|
1769 | 1769 | reviewerAC.animVert = false; |
|
1770 | 1770 |
reviewerAC.animHoriz = false; |
|
1771 | 1771 | reviewerAC.animSpeed = 0.1; |
|
1772 | 1772 | |
|
1773 | 1773 | // Helper highlight function for the formatter |
|
1774 | 1774 | var highlightMatch = function (full, snippet, matchindex) { |
|
1775 | 1775 |
return full.substring(0, matchindex) |
|
1776 | 1776 |
+ "<span class='match'>" |
|
1777 | 1777 |
+ full.substr(matchindex, snippet.length) |
|
1778 | 1778 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1779 | 1779 | }; |
|
1780 | 1780 | |
|
1781 | 1781 | // Custom formatter to highlight the matching letters |
|
1782 | 1782 | reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
|
1783 | 1783 |
|
|
1784 | 1784 |
|
|
1785 | 1785 |
|
|
1786 | 1786 | } |
|
1787 | 1787 | |
|
1788 | 1788 | var query = sQuery.toLowerCase(); |
|
1789 | 1789 | var _gravatar = function(res, em, group){ |
|
1790 | 1790 |
|
|
1791 | 1791 |
|
|
1792 | 1792 |
|
|
1793 | 1793 |
|
|
1794 | 1794 |
|
|
1795 | 1795 | } |
|
1796 | 1796 | if (oResultData.nname != undefined) { |
|
1797 | 1797 | var fname = oResultData.fname || ""; |
|
1798 | 1798 | var lname = oResultData.lname || ""; |
|
1799 | 1799 | var nname = oResultData.nname; |
|
1800 | 1800 | |
|
1801 | 1801 | // Guard against null value |
|
1802 | 1802 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1803 | 1803 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
1804 | 1804 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
1805 | 1805 | displayfname, displaylname, displaynname; |
|
1806 | 1806 | |
|
1807 | 1807 | if (fnameMatchIndex > -1) { |
|
1808 | 1808 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
1809 | 1809 | } else { |
|
1810 | 1810 | displayfname = fname; |
|
1811 | 1811 | } |
|
1812 | 1812 | |
|
1813 | 1813 | if (lnameMatchIndex > -1) { |
|
1814 | 1814 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
1815 | 1815 | } else { |
|
1816 | 1816 | displaylname = lname; |
|
1817 | 1817 | } |
|
1818 | 1818 | |
|
1819 | 1819 | if (nnameMatchIndex > -1) { |
|
1820 | 1820 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
1821 | 1821 | } else { |
|
1822 | 1822 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1823 | 1823 | } |
|
1824 | 1824 | |
|
1825 | 1825 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1826 | 1826 | } else { |
|
1827 | 1827 | return ''; |
|
1828 | 1828 | } |
|
1829 | 1829 | }; |
|
1830 | 1830 | |
|
1831 | 1831 | //members cache to catch duplicates |
|
1832 | 1832 | reviewerAC.dataSource.cache = []; |
|
1833 | 1833 | // hack into select event |
|
1834 | 1834 | if(reviewerAC.itemSelectEvent){ |
|
1835 | 1835 |
|
|
1836 | 1836 | |
|
1837 | 1837 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1838 | 1838 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1839 | 1839 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1840 | 1840 | |
|
1841 | 1841 | //fill the autocomplete with value |
|
1842 | 1842 | |
|
1843 | 1843 | if (oData.nname != undefined) { |
|
1844 | 1844 |
|
|
1845 | 1845 |
|
|
1846 | 1846 |
|
|
1847 | 1847 |
|
|
1848 | 1848 | } |
|
1849 | 1849 | }); |
|
1850 | 1850 | } |
|
1851 | 1851 | return { |
|
1852 | 1852 | ownerDS: ownerDS, |
|
1853 | 1853 | reviewerAC: reviewerAC, |
|
1854 | 1854 | }; |
|
1855 | 1855 | } |
|
1856 | 1856 | |
|
1857 | 1857 | /** |
|
1858 | 1858 | * QUICK REPO MENU |
|
1859 | 1859 | */ |
|
1860 | 1860 | var quick_repo_menu = function(){ |
|
1861 | 1861 | YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){ |
|
1862 | 1862 | var menu = e.currentTarget.firstElementChild.firstElementChild; |
|
1863 | 1863 | if(YUD.hasClass(menu,'hidden')){ |
|
1864 | 1864 | YUD.replaceClass(e.currentTarget,'hidden', 'active'); |
|
1865 | 1865 | YUD.replaceClass(menu, 'hidden', 'active'); |
|
1866 | 1866 | } |
|
1867 | 1867 | }) |
|
1868 | 1868 | YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){ |
|
1869 | 1869 | var menu = e.currentTarget.firstElementChild.firstElementChild; |
|
1870 | 1870 | if(YUD.hasClass(menu,'active')){ |
|
1871 | 1871 | YUD.replaceClass(e.currentTarget, 'active', 'hidden'); |
|
1872 | 1872 | YUD.replaceClass(menu, 'active', 'hidden'); |
|
1873 | 1873 | } |
|
1874 | 1874 | }) |
|
1875 | 1875 | }; |
|
1876 | 1876 | |
|
1877 | 1877 | |
|
1878 | 1878 | /** |
|
1879 | 1879 | * TABLE SORTING |
|
1880 | 1880 | */ |
|
1881 | 1881 | |
|
1882 | 1882 | // returns a node from given html; |
|
1883 | 1883 | var fromHTML = function(html){ |
|
1884 | 1884 |
|
|
1885 | 1885 |
|
|
1886 | 1886 |
|
|
1887 | 1887 | } |
|
1888 | 1888 | var get_rev = function(node){ |
|
1889 | 1889 | var n = node.firstElementChild.firstElementChild; |
|
1890 | 1890 | |
|
1891 | 1891 | if (n===null){ |
|
1892 | 1892 | return -1 |
|
1893 | 1893 | } |
|
1894 | 1894 | else{ |
|
1895 | 1895 | out = n.firstElementChild.innerHTML.split(':')[0].replace('r',''); |
|
1896 | 1896 | return parseInt(out); |
|
1897 | 1897 | } |
|
1898 | 1898 | } |
|
1899 | 1899 | |
|
1900 | 1900 | var get_name = function(node){ |
|
1901 | 1901 |
|
|
1902 | 1902 |
|
|
1903 | 1903 | } |
|
1904 | 1904 | var get_group_name = function(node){ |
|
1905 | 1905 |
|
|
1906 | 1906 |
|
|
1907 | 1907 | } |
|
1908 | 1908 | var get_date = function(node){ |
|
1909 | 1909 |
|
|
1910 | 1910 |
|
|
1911 | 1911 | } |
|
1912 | 1912 | |
|
1913 | 1913 | var get_age = function(node){ |
|
1914 | 1914 |
|
|
1915 | 1915 | } |
|
1916 | 1916 | |
|
1917 | 1917 | var get_link = function(node){ |
|
1918 | 1918 |
|
|
1919 | 1919 | } |
|
1920 | 1920 | |
|
1921 | 1921 | var revisionSort = function(a, b, desc, field) { |
|
1922 | 1922 | |
|
1923 | 1923 |
|
|
1924 | 1924 |
|
|
1925 | 1925 | |
|
1926 | 1926 |
|
|
1927 | 1927 |
|
|
1928 | 1928 |
|
|
1929 | 1929 | |
|
1930 | 1930 |
|
|
1931 | 1931 |
|
|
1932 | 1932 |
|
|
1933 | 1933 | }; |
|
1934 | 1934 | var ageSort = function(a, b, desc, field) { |
|
1935 | 1935 | var a_ = fromHTML(a.getData(field)); |
|
1936 | 1936 | var b_ = fromHTML(b.getData(field)); |
|
1937 | 1937 | |
|
1938 | 1938 | // extract name from table |
|
1939 | 1939 | a_ = get_date(a_) |
|
1940 | 1940 |
b_ = get_date(b_) |
|
1941 | 1941 | |
|
1942 | 1942 | var comp = YAHOO.util.Sort.compare; |
|
1943 | 1943 | var compState = comp(a_, b_, desc); |
|
1944 | 1944 | return compState; |
|
1945 | 1945 | }; |
|
1946 | 1946 | |
|
1947 | 1947 | var lastLoginSort = function(a, b, desc, field) { |
|
1948 | 1948 |
|
|
1949 | 1949 | var b_ = b.getData('last_login_raw') || 0; |
|
1950 | 1950 | |
|
1951 | 1951 | var comp = YAHOO.util.Sort.compare; |
|
1952 | 1952 | var compState = comp(a_, b_, desc); |
|
1953 | 1953 | return compState; |
|
1954 | 1954 | }; |
|
1955 | 1955 | |
|
1956 | 1956 | var nameSort = function(a, b, desc, field) { |
|
1957 | 1957 | var a_ = fromHTML(a.getData(field)); |
|
1958 | 1958 | var b_ = fromHTML(b.getData(field)); |
|
1959 | 1959 | |
|
1960 | 1960 | // extract name from table |
|
1961 | 1961 | a_ = get_name(a_) |
|
1962 | 1962 |
b_ = get_name(b_) |
|
1963 | 1963 | |
|
1964 | 1964 | var comp = YAHOO.util.Sort.compare; |
|
1965 | 1965 | var compState = comp(a_, b_, desc); |
|
1966 | 1966 | return compState; |
|
1967 | 1967 | }; |
|
1968 | 1968 | |
|
1969 | 1969 | var permNameSort = function(a, b, desc, field) { |
|
1970 | 1970 | var a_ = fromHTML(a.getData(field)); |
|
1971 | 1971 | var b_ = fromHTML(b.getData(field)); |
|
1972 | 1972 | // extract name from table |
|
1973 | 1973 | |
|
1974 | 1974 | a_ = a_.children[0].innerHTML; |
|
1975 | 1975 |
b_ = b_.children[0].innerHTML; |
|
1976 | 1976 | |
|
1977 | 1977 | var comp = YAHOO.util.Sort.compare; |
|
1978 | 1978 | var compState = comp(a_, b_, desc); |
|
1979 | 1979 | return compState; |
|
1980 | 1980 | }; |
|
1981 | 1981 | |
|
1982 | 1982 | var groupNameSort = function(a, b, desc, field) { |
|
1983 | 1983 | var a_ = fromHTML(a.getData(field)); |
|
1984 | 1984 | var b_ = fromHTML(b.getData(field)); |
|
1985 | 1985 | |
|
1986 | 1986 | // extract name from table |
|
1987 | 1987 | a_ = get_group_name(a_) |
|
1988 | 1988 |
b_ = get_group_name(b_) |
|
1989 | 1989 | |
|
1990 | 1990 | var comp = YAHOO.util.Sort.compare; |
|
1991 | 1991 | var compState = comp(a_, b_, desc); |
|
1992 | 1992 | return compState; |
|
1993 | 1993 | }; |
|
1994 | 1994 | var dateSort = function(a, b, desc, field) { |
|
1995 | 1995 | var a_ = fromHTML(a.getData(field)); |
|
1996 | 1996 | var b_ = fromHTML(b.getData(field)); |
|
1997 | 1997 | |
|
1998 | 1998 | // extract name from table |
|
1999 | 1999 | a_ = get_date(a_) |
|
2000 | 2000 |
b_ = get_date(b_) |
|
2001 | 2001 | |
|
2002 | 2002 | var comp = YAHOO.util.Sort.compare; |
|
2003 | 2003 | var compState = comp(a_, b_, desc); |
|
2004 | 2004 | return compState; |
|
2005 | 2005 | }; |
|
2006 | 2006 | |
|
2007 | 2007 | var usernamelinkSort = function(a, b, desc, field) { |
|
2008 | 2008 |
|
|
2009 | 2009 |
|
|
2010 | 2010 | |
|
2011 | 2011 |
|
|
2012 | 2012 |
|
|
2013 | 2013 |
|
|
2014 | 2014 |
|
|
2015 | 2015 |
|
|
2016 | 2016 |
|
|
2017 | 2017 | } |
|
2018 | 2018 | |
|
2019 | 2019 | var addPermAction = function(_html, users_list, groups_list){ |
|
2020 | 2020 | var elmts = YUD.getElementsByClassName('last_new_member'); |
|
2021 | 2021 | var last_node = elmts[elmts.length-1]; |
|
2022 | 2022 | if (last_node){ |
|
2023 | 2023 | var next_id = (YUD.getElementsByClassName('new_members')).length; |
|
2024 | 2024 | _html = _html.format(next_id); |
|
2025 | 2025 | last_node.innerHTML = _html; |
|
2026 | 2026 | YUD.setStyle(last_node, 'display', ''); |
|
2027 | 2027 | YUD.removeClass(last_node, 'last_new_member'); |
|
2028 | 2028 |
MembersAutoComplete("perm_new_member_name_"+next_id, |
|
2029 | 2029 |
"perm_container_"+next_id, users_list, groups_list); |
|
2030 | 2030 | //create new last NODE |
|
2031 | 2031 | var el = document.createElement('tr'); |
|
2032 | 2032 | el.id = 'add_perm_input'; |
|
2033 | 2033 | YUD.addClass(el,'last_new_member'); |
|
2034 | 2034 | YUD.addClass(el,'new_members'); |
|
2035 | 2035 | YUD.insertAfter(el, last_node); |
|
2036 | 2036 |
} |
|
2037 | 2037 | } |
|
2038 | 2038 | |
|
2039 | 2039 | /* Multi selectors */ |
|
2040 | 2040 | |
|
2041 | 2041 | var MultiSelectWidget = function(selected_id, available_id, form_id){ |
|
2042 | 2042 | |
|
2043 | 2043 | |
|
2044 | 2044 |
|
|
2045 | 2045 |
|
|
2046 | 2046 |
|
|
2047 | 2047 | |
|
2048 | 2048 |
|
|
2049 | 2049 |
|
|
2050 | 2050 |
|
|
2051 | 2051 |
|
|
2052 | 2052 |
|
|
2053 | 2053 | |
|
2054 | 2054 |
|
|
2055 | 2055 |
|
|
2056 | 2056 |
|
|
2057 | 2057 |
|
|
2058 | 2058 |
|
|
2059 | 2059 |
|
|
2060 | 2060 | } |
|
2061 | 2061 | |
|
2062 | 2062 |
|
|
2063 | 2063 |
|
|
2064 | 2064 |
|
|
2065 | 2065 |
|
|
2066 | 2066 | } |
|
2067 | 2067 | |
|
2068 | 2068 |
|
|
2069 | 2069 |
|
|
2070 | 2070 |
|
|
2071 | 2071 | |
|
2072 | 2072 |
|
|
2073 | 2073 |
|
|
2074 | 2074 |
|
|
2075 | 2075 |
|
|
2076 | 2076 |
|
|
2077 | 2077 |
|
|
2078 | 2078 |
|
|
2079 | 2079 |
|
|
2080 | 2080 |
|
|
2081 | 2081 |
|
|
2082 | 2082 |
|
|
2083 | 2083 | } |
|
2084 | 2084 | |
|
2085 | 2085 |
|
|
2086 | 2086 |
|
|
2087 | 2087 | } |
|
2088 | 2088 | |
|
2089 | 2089 |
|
|
2090 | 2090 | |
|
2091 | 2091 |
|
|
2092 | 2092 |
|
|
2093 | 2093 | |
|
2094 | 2094 |
|
|
2095 | 2095 |
|
|
2096 | 2096 |
|
|
2097 | 2097 |
|
|
2098 | 2098 |
|
|
2099 | 2099 | |
|
2100 | 2100 |
|
|
2101 | 2101 |
|
|
2102 | 2102 |
|
|
2103 | 2103 |
|
|
2104 | 2104 |
|
|
2105 | 2105 |
|
|
2106 | 2106 |
|
|
2107 | 2107 |
|
|
2108 | 2108 |
|
|
2109 | 2109 | |
|
2110 | 2110 |
|
|
2111 | 2111 |
|
|
2112 | 2112 | |
|
2113 | 2113 |
|
|
2114 | 2114 |
|
|
2115 | 2115 |
|
|
2116 | 2116 |
|
|
2117 | 2117 |
|
|
2118 | 2118 |
|
|
2119 | 2119 |
|
|
2120 | 2120 |
|
|
2121 | 2121 | |
|
2122 | 2122 |
|
|
2123 | 2123 |
|
|
2124 | 2124 |
|
|
2125 | 2125 |
|
|
2126 | 2126 |
|
|
2127 | 2127 |
|
|
2128 | 2128 |
|
|
2129 | 2129 |
|
|
2130 | 2130 | |
|
2131 | 2131 |
|
|
2132 | 2132 |
|
|
2133 | 2133 |
|
|
2134 | 2134 |
|
|
2135 | 2135 |
|
|
2136 | 2136 |
|
|
2137 | 2137 |
|
|
2138 | 2138 |
|
|
2139 | 2139 |
|
|
2140 | 2140 |
|
|
2141 | 2141 |
|
|
2142 | 2142 |
|
|
2143 | 2143 |
|
|
2144 | 2144 |
|
|
2145 | 2145 |
|
|
2146 | 2146 |
|
|
2147 | 2147 |
|
|
2148 | 2148 |
|
|
2149 | 2149 |
|
|
2150 | 2150 |
|
|
2151 | 2151 |
|
|
2152 | 2152 |
|
|
2153 | 2153 |
|
|
2154 | 2154 |
|
|
2155 | 2155 |
|
|
2156 | 2156 |
|
|
2157 | 2157 |
|
|
2158 | 2158 |
|
|
2159 | 2159 | |
|
2160 | 2160 | } |
|
2161 | 2161 | |
|
2162 | 2162 |
|
|
2163 | 2163 |
|
|
2164 | 2164 |
|
|
2165 | 2165 |
|
|
2166 | 2166 |
|
|
2167 | 2167 |
|
|
2168 | 2168 |
|
|
2169 | 2169 |
|
|
2170 | 2170 | } |
|
2171 | 2171 | }); |
|
2172 | 2172 | } |
|
2173 | 2173 | } |
|
2174 | 2174 | |
|
2175 | 2175 | |
|
2176 | 2176 | // global hooks after DOM is loaded |
|
2177 | 2177 | |
|
2178 | 2178 | YUE.onDOMReady(function(){ |
|
2179 | 2179 |
|
|
2180 | 2180 |
|
|
2181 | 2181 |
|
|
2182 | 2182 |
|
|
2183 | 2183 |
|
|
2184 | 2184 |
|
|
2185 | 2185 |
|
|
2186 | 2186 | } |
|
2187 | 2187 |
|
|
2188 | 2188 |
|
|
2189 | 2189 |
|
|
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