Show More
@@ -3132,7 +3132,7 table.code-browser .submodule-dir { | |||
|
3132 | 3132 | } |
|
3133 | 3133 | |
|
3134 | 3134 | .hl-tip-box { |
|
3135 | visibility: hidden; | |
|
3135 | z-index: 1; | |
|
3136 | 3136 | position: absolute; |
|
3137 | 3137 | color: #666; |
|
3138 | 3138 | background-color: #FFF; |
This diff has been collapsed as it changes many lines, (1083 lines changed) Show them Hide them | |||
@@ -70,17 +70,6 if(!Array.prototype.indexOf) { | |||
|
70 | 70 | }; |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | // IE(CRAP) doesn't support previousElementSibling | |
|
74 | var prevElementSibling = function( el ) { | |
|
75 | if( el.previousElementSibling ) { | |
|
76 | return el.previousElementSibling; | |
|
77 | } else { | |
|
78 | while( el = el.previousSibling ) { | |
|
79 | if( el.nodeType === 1 ) return el; | |
|
80 | } | |
|
81 | } | |
|
82 | } | |
|
83 | ||
|
84 | 73 | /** |
|
85 | 74 | * A customized version of PyRoutes.JS from https://pypi.python.org/pypi/pyroutes.js/ |
|
86 | 75 | * which is copyright Stephane Klein and was made available under the BSD License. |
@@ -273,6 +262,7 var YUD = YAHOO.util.Dom; | |||
|
273 | 262 | var YUE = YAHOO.util.Event; |
|
274 | 263 | var YUQ = YAHOO.util.Selector.query; |
|
275 | 264 | |
|
265 | /* Invoke all functions in callbacks */ | |
|
276 | 266 | var _run_callbacks = function(callbacks){ |
|
277 | 267 | if (callbacks !== undefined){ |
|
278 | 268 | var _l = callbacks.length; |
@@ -290,7 +280,7 var _run_callbacks = function(callbacks) | |||
|
290 | 280 | /** |
|
291 | 281 | * turns objects into GET query string |
|
292 | 282 | */ |
|
293 | var toQueryString = function(o) { | |
|
283 | var _toQueryString = function(o) { | |
|
294 | 284 | if(typeof o !== 'object') { |
|
295 | 285 | return false; |
|
296 | 286 | } |
@@ -323,6 +313,7 function ypjax(url,container,s_call,f_ca | |||
|
323 | 313 | if(args===undefined){ |
|
324 | 314 | args=null; |
|
325 | 315 | } |
|
316 | $container = $('#' + container); | |
|
326 | 317 | |
|
327 | 318 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR |
|
328 | 319 | YUC.initHeader('X-PARTIAL-XHR',true); |
@@ -330,21 +321,21 function ypjax(url,container,s_call,f_ca | |||
|
330 | 321 | // wrapper of passed callback |
|
331 | 322 | var s_wrapper = (function(o){ |
|
332 | 323 | return function(o){ |
|
333 |
|
|
|
334 |
|
|
|
324 | $container.html(o.responseText); | |
|
325 | $container.css('opacity','1.0'); | |
|
335 | 326 | //execute the given original callback |
|
336 | 327 | if (s_call !== undefined){ |
|
337 | 328 | s_call(o); |
|
338 | 329 | } |
|
339 | 330 | } |
|
340 | 331 | })() |
|
341 |
|
|
|
332 | $container.css('opacity','0.3'); | |
|
342 | 333 | YUC.asyncRequest(method,url,{ |
|
343 | 334 | success:s_wrapper, |
|
344 | 335 | failure:function(o){ |
|
345 | console.log(o); | |
|
346 |
|
|
|
347 |
|
|
|
336 | console.log('ypjax failure: '+o); | |
|
337 | $container.html('<span class="error_red">ERROR: {0}</span>'.format(o.status)); | |
|
338 | $container.css('opacity','1.0'); | |
|
348 | 339 | }, |
|
349 | 340 | cache:false |
|
350 | 341 | },args); |
@@ -380,91 +371,78 var ajaxPOST = function(url,postData,suc | |||
|
380 | 371 | alert("error"); |
|
381 | 372 | }, |
|
382 | 373 | }; |
|
383 | var postData = toQueryString(postData); | |
|
374 | var postData = _toQueryString(postData); | |
|
384 | 375 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); |
|
385 | 376 | return request; |
|
386 | 377 | }; |
|
387 | 378 | |
|
388 | 379 | |
|
389 | 380 | /** |
|
390 | * tooltip activate | |
|
391 | */ | |
|
392 | var tooltip_activate = function(){ | |
|
393 | yt = YAHOO.yuitip.main; | |
|
394 | YUE.onDOMReady(yt.init); | |
|
395 | }; | |
|
396 | ||
|
397 | /** | |
|
398 | * show more | |
|
381 | * activate .show_more links | |
|
382 | * the .show_more must have an id that is the the id of an element to hide prefixed with _ | |
|
383 | * the parentnode will be displayed | |
|
399 | 384 | */ |
|
400 | 385 | var show_more_event = function(){ |
|
401 |
|
|
|
402 | var el = e.target; | |
|
403 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); | |
|
404 |
|
|
|
386 | $('.show_more').click(function(e){ | |
|
387 | var el = e.currentTarget; | |
|
388 | $('#' + el.id.substring(1)).hide(); | |
|
389 | $(el.parentNode).show(); | |
|
405 | 390 | }); |
|
406 | 391 | }; |
|
407 | 392 | |
|
408 | 393 | /** |
|
409 | * show changeset tooltip | |
|
394 | * activate .lazy-cs mouseover for showing changeset tooltip | |
|
410 | 395 | */ |
|
411 | 396 | var show_changeset_tooltip = function(){ |
|
412 |
|
|
|
413 | var target = e.currentTarget; | |
|
414 |
var rid = |
|
|
415 |
var repo_name = |
|
|
416 | var ttid = 'tt-'+rid; | |
|
417 | var success = function(o){ | |
|
418 | var json = JSON.parse(o.responseText); | |
|
419 | YUD.addClass(target,'tooltip') | |
|
420 | YUD.setAttribute(target, 'title',json['message']); | |
|
421 | YAHOO.yuitip.main.show_yuitip(e, target); | |
|
422 | } | |
|
423 | if(rid && !YUD.hasClass(target, 'tooltip')){ | |
|
424 | YUD.setAttribute(target,'id',ttid); | |
|
425 | YUD.setAttribute(target, 'title',_TM['loading ...']); | |
|
426 | YAHOO.yuitip.main.set_listeners(target); | |
|
427 | YAHOO.yuitip.main.show_yuitip(e, target); | |
|
428 | var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid}); | |
|
429 | ajaxGET(url, success) | |
|
397 | $('.lazy-cs').mouseover(function(e){ | |
|
398 | var $target = $(e.currentTarget); | |
|
399 | var rid = $target.attr('raw_id'); | |
|
400 | var repo_name = $target.attr('repo_name'); | |
|
401 | if(rid && !$target.hasClass('tooltip')){ | |
|
402 | _show_tooltip(e, _TM['loading ...']); | |
|
403 | var url = pyroutes.url('changeset_info', {"repo_name": repo_name, "revision": rid}); | |
|
404 | ajaxGET(url, function(o){ | |
|
405 | var json = JSON.parse(o.responseText); | |
|
406 | $target.addClass('tooltip') | |
|
407 | _show_tooltip(e, json['message']); | |
|
408 | _activate_tooltip($target); | |
|
409 | }); | |
|
430 | 410 | } |
|
431 | 411 | }); |
|
432 | 412 | }; |
|
433 | 413 | |
|
434 | var onSuccessFollow = function(target){ | |
|
435 |
var |
|
|
436 |
var f_cnt = |
|
|
437 | ||
|
438 | if(YUD.hasClass(f, 'follow')){ | |
|
439 | f.setAttribute('class','following'); | |
|
440 | f.setAttribute('title',_TM['Stop following this repository']); | |
|
441 | ||
|
442 | if(f_cnt){ | |
|
443 | var cnt = Number(f_cnt.innerHTML)+1; | |
|
444 | f_cnt.innerHTML = cnt; | |
|
414 | var _onSuccessFollow = function(target){ | |
|
415 | var $target = $(target); | |
|
416 | var $f_cnt = $('#current_followers_count'); | |
|
417 | if($target.hasClass('follow')){ | |
|
418 | $target.attr('class', 'following'); | |
|
419 | $target.attr('title', _TM['Stop following this repository']); | |
|
420 | if($f_cnt.html()){ | |
|
421 | var cnt = Number($f_cnt.html())+1; | |
|
422 | $f_cnt.html(cnt); | |
|
445 | 423 | } |
|
446 | 424 | } |
|
447 | 425 | else{ |
|
448 |
|
|
|
449 |
|
|
|
450 | if(f_cnt){ | |
|
451 |
var cnt = Number(f_cnt. |
|
|
452 |
f_cnt. |
|
|
426 | $target.attr('class', 'follow'); | |
|
427 | $target.attr('title', _TM['Start following this repository']); | |
|
428 | if($f_cnt.html()){ | |
|
429 | var cnt = Number($f_cnt.html())-1; | |
|
430 | $f_cnt.html(cnt); | |
|
453 | 431 | } |
|
454 | 432 | } |
|
455 | 433 | } |
|
456 | 434 | |
|
457 |
var toggleFollowingRepo = function(target, |
|
|
458 |
args = 'follows_repo_id='+f |
|
|
435 | var toggleFollowingRepo = function(target, follows_repo_id, token, user_id){ | |
|
436 | args = 'follows_repo_id='+follows_repo_id; | |
|
459 | 437 | args+= '&auth_token='+token; |
|
460 | 438 | if(user_id != undefined){ |
|
461 | 439 | args+="&user_id="+user_id; |
|
462 | 440 | } |
|
463 | 441 | $.post(TOGGLE_FOLLOW_URL, args, function(data){ |
|
464 | onSuccessFollow(target); | |
|
442 | _onSuccessFollow(target); | |
|
465 | 443 | }); |
|
466 | 444 | return false; |
|
467 | } | |
|
445 | }; | |
|
468 | 446 | |
|
469 | 447 | var showRepoSize = function(target, repo_name, token){ |
|
470 | 448 | var args= 'auth_token='+token; |
@@ -478,113 +456,73 var showRepoSize = function(target, repo | |||
|
478 | 456 | }); |
|
479 | 457 | } |
|
480 | 458 | return false; |
|
481 | } | |
|
459 | }; | |
|
482 | 460 | |
|
483 | 461 |
|
|
484 | * TOOLTIP IMPL. | |
|
462 | * tooltips | |
|
485 | 463 | */ |
|
486 | YAHOO.namespace('yuitip'); | |
|
487 | YAHOO.yuitip.main = { | |
|
488 | ||
|
489 | $: YAHOO.util.Dom.get, | |
|
490 | 464 | |
|
491 | bgColor: '#000', | |
|
492 | speed: 0.3, | |
|
493 | opacity: 0.9, | |
|
494 | offset: [15,15], | |
|
495 | useAnim: false, | |
|
496 | maxWidth: 600, | |
|
497 | add_links: false, | |
|
498 | yuitips: [], | |
|
465 | var tooltip_activate = function(){ | |
|
466 | $(document).ready(_init_tooltip); | |
|
467 | }; | |
|
499 | 468 | |
|
500 | set_listeners: function(tt){ | |
|
501 | YUE.on(tt, 'mouseover', yt.show_yuitip, tt); | |
|
502 | YUE.on(tt, 'mousemove', yt.move_yuitip, tt); | |
|
503 | YUE.on(tt, 'mouseout', yt.close_yuitip, tt); | |
|
504 | }, | |
|
469 | var _activate_tooltip = function($tt){ | |
|
470 | $tt.mouseover(_show_tooltip); | |
|
471 | $tt.mousemove(_move_tooltip); | |
|
472 | $tt.mouseout(_close_tooltip); | |
|
473 | }; | |
|
505 | 474 | |
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
509 | yt.tipBox = document.createElement('div'); | |
|
510 |
|
|
|
511 | yt.tipBox.id = 'tip-box'; | |
|
512 | } | |
|
475 | var _init_tooltip = function(){ | |
|
476 | var $tipBox = $('#tip-box'); | |
|
477 | if(!$tipBox.length){ | |
|
478 | $tipBox = $('<div id="tip-box"></div>') | |
|
479 | $(document.body).append($tipBox); | |
|
480 | } | |
|
513 | 481 | |
|
514 | YUD.setStyle(yt.tipBox, 'display', 'none'); | |
|
515 |
|
|
|
516 | if(yt.maxWidth !== null){ | |
|
517 | YUD.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px'); | |
|
518 | } | |
|
519 | ||
|
520 | var yuitips = YUD.getElementsByClassName('tooltip'); | |
|
482 | $tipBox.hide(); | |
|
483 | $tipBox.css('position', 'absolute'); | |
|
484 | $tipBox.css('max-width', '600px'); | |
|
521 | 485 | |
|
522 | if(yt.add_links === true){ | |
|
523 | var links = document.getElementsByTagName('a'); | |
|
524 | var linkLen = links.length; | |
|
525 | for(i=0;i<linkLen;i++){ | |
|
526 | yuitips.push(links[i]); | |
|
527 | } | |
|
528 | } | |
|
529 | ||
|
530 | var yuiLen = yuitips.length; | |
|
486 | _activate_tooltip($('.tooltip')); | |
|
487 | }; | |
|
531 | 488 | |
|
532 | for(i=0;i<yuiLen;i++){ | |
|
533 | yt.set_listeners(yuitips[i]); | |
|
534 | } | |
|
535 | }, | |
|
489 | var _show_tooltip = function(e, tipText){ | |
|
490 | e.stopImmediatePropagation(); | |
|
491 | var el = e.currentTarget; | |
|
492 | if(tipText){ | |
|
493 | // just use it | |
|
494 | } else if(el.tagName.toLowerCase() === 'img'){ | |
|
495 | tipText = el.alt ? el.alt : ''; | |
|
496 | } else { | |
|
497 | tipText = el.title ? el.title : ''; | |
|
498 | } | |
|
536 | 499 | |
|
537 | show_yuitip: function(e, el){ | |
|
538 | YUE.stopEvent(e); | |
|
539 | if(el.tagName.toLowerCase() === 'img'){ | |
|
540 | yt.tipText = el.alt ? el.alt : ''; | |
|
541 | } else { | |
|
542 | yt.tipText = el.title ? el.title : ''; | |
|
543 | } | |
|
544 | ||
|
545 | if(yt.tipText !== ''){ | |
|
546 | // save org title | |
|
547 | YUD.setAttribute(el, 'tt_title', yt.tipText); | |
|
548 | // reset title to not show org tooltips | |
|
549 | YUD.setAttribute(el, 'title', ''); | |
|
500 | if(tipText !== ''){ | |
|
501 | // save org title | |
|
502 | $(el).attr('tt_title', tipText); | |
|
503 | // reset title to not show org tooltips | |
|
504 | $(el).attr('title', ''); | |
|
550 | 505 | |
|
551 | yt.tipBox.innerHTML = yt.tipText; | |
|
552 | YUD.setStyle(yt.tipBox, 'display', 'block'); | |
|
553 | if(yt.useAnim === true){ | |
|
554 | YUD.setStyle(yt.tipBox, 'opacity', '0'); | |
|
555 | var newAnim = new YAHOO.util.Anim(yt.tipBox, | |
|
556 | { | |
|
557 | opacity: { to: yt.opacity } | |
|
558 | }, yt.speed, YAHOO.util.Easing.easeOut | |
|
559 | ); | |
|
560 | newAnim.animate(); | |
|
561 | } | |
|
562 | } | |
|
563 | }, | |
|
506 | var $tipBox = $('#tip-box'); | |
|
507 | $tipBox.html(tipText); | |
|
508 | $tipBox.css('display', 'block'); | |
|
509 | } | |
|
510 | }; | |
|
564 | 511 | |
|
565 |
|
|
|
566 | YUE.stopEvent(e); | |
|
567 | var movePos = YUE.getXY(e); | |
|
568 | YUD.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px'); | |
|
569 | YUD.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px'); | |
|
570 | }, | |
|
571 | ||
|
572 | close_yuitip: function(e, el){ | |
|
573 | YUE.stopEvent(e); | |
|
512 | var _move_tooltip = function(e){ | |
|
513 | e.stopImmediatePropagation(); | |
|
514 | var $tipBox = $('#tip-box'); | |
|
515 | $tipBox.css('top', (e.pageY + 15) + 'px'); | |
|
516 | $tipBox.css('left', (e.pageX + 15) + 'px'); | |
|
517 | }; | |
|
574 | 518 | |
|
575 | if(yt.useAnim === true){ | |
|
576 | var newAnim = new YAHOO.util.Anim(yt.tipBox, | |
|
577 | { | |
|
578 | opacity: { to: 0 } | |
|
579 | }, yt.speed, YAHOO.util.Easing.easeOut | |
|
580 | ); | |
|
581 | newAnim.animate(); | |
|
582 | } else { | |
|
583 | YUD.setStyle(yt.tipBox, 'display', 'none'); | |
|
584 | } | |
|
585 | YUD.setAttribute(el,'title', YUD.getAttribute(el, 'tt_title')); | |
|
586 | } | |
|
587 | } | |
|
519 | var _close_tooltip = function(e){ | |
|
520 | e.stopImmediatePropagation(); | |
|
521 | var $tipBox = $('#tip-box'); | |
|
522 | $tipBox.hide(); | |
|
523 | var el = e.currentTarget; | |
|
524 | $(el).attr('title', $(el).attr('tt_title')); | |
|
525 | }; | |
|
588 | 526 | |
|
589 | 527 |
|
|
590 | 528 | * Quick filter widget |
@@ -593,142 +531,109 YAHOO.yuitip.main = { | |||
|
593 | 531 | * @param nodes: list of nodes in html we want to filter. |
|
594 | 532 | * @param display_element function that takes current node from nodes and |
|
595 | 533 | * does hide or show based on the node |
|
596 | * | |
|
597 | 534 | */ |
|
598 | var q_filter = function(target,nodes,display_element){ | |
|
599 | ||
|
535 | var q_filter = function(target, nodes, display_element){ | |
|
600 | 536 | var nodes = nodes; |
|
601 |
var q_filter_field = |
|
|
537 | var $q_filter_field = $('#' + target); | |
|
602 | 538 | var F = YAHOO.namespace(target); |
|
603 | 539 | |
|
604 |
|
|
|
540 | $q_filter_field.keyup(function(e){ | |
|
605 | 541 | clearTimeout(F.filterTimeout); |
|
606 | F.filterTimeout = setTimeout(F.updateFilter,600); | |
|
542 | F.filterTimeout = setTimeout(F.updateFilter, 600); | |
|
607 | 543 | }); |
|
608 | 544 | |
|
609 | 545 | F.filterTimeout = null; |
|
610 | 546 | |
|
611 | var show_node = function(node){ | |
|
612 | YUD.setStyle(node,'display','') | |
|
613 | } | |
|
614 | var hide_node = function(node){ | |
|
615 | YUD.setStyle(node,'display','none'); | |
|
616 | } | |
|
617 | ||
|
618 | 547 | F.updateFilter = function() { |
|
619 | 548 | // Reset timeout |
|
620 | 549 | F.filterTimeout = null; |
|
621 | 550 | |
|
622 | 551 | var obsolete = []; |
|
623 | 552 | |
|
624 |
var req = q_filter_field.val |
|
|
553 | var req = $q_filter_field.val().toLowerCase(); | |
|
625 | 554 | |
|
626 | 555 | var l = nodes.length; |
|
627 | 556 | var i; |
|
628 | 557 | var showing = 0; |
|
629 | 558 | |
|
630 | for (i=0;i<l;i++ ){ | |
|
559 | for (i=0; i<l; i++ ){ | |
|
631 | 560 | var n = nodes[i]; |
|
632 | 561 | var target_element = display_element(n) |
|
633 | 562 | if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ |
|
634 |
|
|
|
563 | $(target_element).hide(); | |
|
635 | 564 | } |
|
636 | 565 | else{ |
|
637 |
|
|
|
638 | showing+=1; | |
|
566 | $(target_element).show(); | |
|
567 | showing += 1; | |
|
639 | 568 | } |
|
640 | 569 | } |
|
641 | 570 | |
|
642 | // if repo_count is set update the number | |
|
643 | var cnt = YUD.get('repo_count'); | |
|
644 | if(cnt){ | |
|
645 | YUD.get('repo_count').innerHTML = showing; | |
|
646 | } | |
|
571 | $('#repo_count').html(showing); /* FIXME: don't hardcode */ | |
|
647 | 572 | } |
|
648 | 573 | }; |
|
649 | 574 | |
|
650 | var tableTr = function(cls, body){ | |
|
651 | var _el = document.createElement('div'); | |
|
652 | var cont = new YAHOO.util.Element(body); | |
|
653 | var comment_id = fromHTML(body).children[0].id.split('comment-')[1]; | |
|
654 | var id = 'comment-tr-{0}'.format(comment_id); | |
|
655 | var _html = ('<table><tbody><tr id="{0}" class="{1}">'+ | |
|
575 | /* return jQuery expression with a tr with body in 3rd column and class cls and id named after the body */ | |
|
576 | var _table_tr = function(cls, body){ | |
|
577 | // like: <div class="comment" id="comment-8" line="o92"><div class="comment-wrapp">... | |
|
578 | // except new inlines which are different ... | |
|
579 | var comment_id = ($(body).attr('id') || 'comment-new').split('comment-')[1]; | |
|
580 | var tr_id = 'comment-tr-{0}'.format(comment_id); | |
|
581 | return $(('<tr id="{0}" class="{1}">'+ | |
|
656 | 582 | '<td class="lineno-inline new-inline"></td>'+ |
|
657 | 583 | '<td class="lineno-inline old-inline"></td>'+ |
|
658 | 584 | '<td>{2}</td>'+ |
|
659 |
'</tr> |
|
|
660 | _el.innerHTML = _html; | |
|
661 | return _el.children[0].children[0].children[0]; | |
|
585 | '</tr>').format(tr_id, cls, body)); | |
|
662 | 586 | }; |
|
663 | 587 | |
|
664 | var createInlineForm = function(parent_tr, f_path, line) { | |
|
665 | var tmpl = $('#comment-inline-form-template').html(); | |
|
666 | tmpl = tmpl.format(f_path, line); | |
|
667 |
var form = |
|
|
588 | /** return jQuery expression with new inline form based on template **/ | |
|
589 | var _createInlineForm = function(parent_tr, f_path, line) { | |
|
590 | var $tmpl = $('#comment-inline-form-template').html().format(f_path, line); | |
|
591 | var $form = _table_tr('comment-form-inline', $tmpl) | |
|
668 | 592 | |
|
669 | 593 | // create event for hide button |
|
670 | form = new YAHOO.util.Element(form); | |
|
671 | var form_hide_button = new YAHOO.util.Element(YUD.getElementsByClassName('hide-inline-form',null,form)[0]); | |
|
672 | form_hide_button.on('click', function(e) { | |
|
594 | $form.find('.hide-inline-form').click(function(e) { | |
|
673 | 595 | var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; |
|
674 |
if( |
|
|
675 | YUD.setStyle(newtr.nextElementSibling,'display',''); | |
|
596 | if($(newtr).next().hasClass('inline-comments-button')){ | |
|
597 | $(newtr).next().show(); | |
|
676 | 598 | } |
|
677 | removeInlineForm(newtr); | |
|
678 |
|
|
|
679 |
|
|
|
680 | ||
|
599 | $(newtr).remove(); | |
|
600 | $(parent_tr).removeClass('form-open'); | |
|
601 | $(parent_tr).removeClass('hl-comment'); | |
|
681 | 602 | }); |
|
682 | 603 | |
|
683 | return form | |
|
604 | return $form | |
|
684 | 605 | }; |
|
685 | 606 | |
|
686 | 607 | /** |
|
687 |
* Inject inline comment for |
|
|
688 | * tr containing the line. Code will detect comment, and always put the comment | |
|
689 | * block at the very bottom | |
|
608 | * Inject inline comment for an given TR. This tr should always be a .line . | |
|
609 | * The form will be inject after any comments. | |
|
690 | 610 | */ |
|
691 | 611 | var injectInlineForm = function(tr){ |
|
692 | if(!$(tr).hasClass('line')){ | |
|
612 | $tr = $(tr); | |
|
613 | if(!$tr.hasClass('line')){ | |
|
693 | 614 | return |
|
694 | 615 | } |
|
695 | 616 | var submit_url = AJAX_COMMENT_URL; |
|
696 | var _td = YUD.getElementsByClassName('code',null,tr)[0]; | |
|
697 |
if($ |
|
|
617 | var $td = $tr.find('.code'); | |
|
618 | if($tr.hasClass('form-open') || $tr.hasClass('context') || $td.hasClass('no-comment')){ | |
|
698 | 619 | return |
|
699 | 620 | } |
|
700 |
$ |
|
|
701 | var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0]; | |
|
702 |
var f_path = |
|
|
703 | var lineno = getLineNo(tr); | |
|
704 | var form = createInlineForm(tr, f_path, lineno, submit_url); | |
|
621 | $tr.addClass('form-open hl-comment'); | |
|
622 | var $node = $tr.parent().parent().parent().find('.full_f_path'); | |
|
623 | var f_path = $node.attr('path'); | |
|
624 | var lineno = _getLineNo(tr); | |
|
625 | var $form = _createInlineForm(tr, f_path, lineno, submit_url); | |
|
705 | 626 | |
|
706 | var parent = tr; | |
|
707 | while (1){ | |
|
708 |
var n = parent.next |
|
|
709 | // next element are comments ! | |
|
710 | if($(n).hasClass('inline-comments')){ | |
|
711 | parent = n; | |
|
712 | } | |
|
713 | else{ | |
|
714 | break; | |
|
715 | } | |
|
627 | var $parent = $tr; | |
|
628 | while ($parent.next().hasClass('inline-comments')){ | |
|
629 | var $parent = $parent.next(); | |
|
716 | 630 | } |
|
717 |
|
|
|
718 | var f = YUD.get(form); | |
|
719 | var overlay = YUD.getElementsByClassName('overlay',null,f)[0]; | |
|
720 | var _form = YUD.getElementsByClassName('inline-form',null,f)[0]; | |
|
721 | ||
|
722 | YUE.on(YUD.get(_form), 'submit',function(e){ | |
|
723 | YUE.preventDefault(e); | |
|
631 | $form.insertAfter($parent); | |
|
632 | var $overlay = $form.find('.overlay'); | |
|
633 | var $inlineform = $form.find('.inline-form'); | |
|
724 | 634 | |
|
725 | //ajax submit | |
|
726 | var text = YUD.get('text_'+lineno).value; | |
|
727 | var postData = { | |
|
728 | 'text':text, | |
|
729 | 'f_path':f_path, | |
|
730 | 'line':lineno | |
|
731 | }; | |
|
635 | $form.submit(function(e){ | |
|
636 | e.preventDefault(); | |
|
732 | 637 | |
|
733 | 638 | if(lineno === undefined){ |
|
734 | 639 | alert('missing line !'); |
@@ -739,48 +644,51 var injectInlineForm = function(tr){ | |||
|
739 | 644 | return |
|
740 | 645 | } |
|
741 | 646 | |
|
647 | var text = $('#text_'+lineno).val(); | |
|
742 | 648 | if(text == ""){ |
|
743 | 649 | return |
|
744 | 650 | } |
|
745 | 651 | |
|
746 | var success = function(o){ | |
|
747 | YUD.removeClass(tr, 'form-open'); | |
|
748 | removeInlineForm(f); | |
|
749 | var json_data = JSON.parse(o.responseText); | |
|
750 | renderInlineComment(json_data); | |
|
751 | }; | |
|
652 | if ($overlay.hasClass('overlay')){ | |
|
653 | $overlay.css('width', $inlineform.offsetWidth + 'px'); | |
|
654 | $overlay.css('height', $inlineform.offsetHeight + 'px'); | |
|
655 | } | |
|
656 | $overlay.addClass('submitting'); | |
|
752 | 657 | |
|
753 | if (YUD.hasClass(overlay,'overlay')){ | |
|
754 | var w = _form.offsetWidth; | |
|
755 |
|
|
|
756 | YUD.setStyle(overlay,'width',w+'px'); | |
|
757 | YUD.setStyle(overlay,'height',h+'px'); | |
|
758 | } | |
|
759 | YUD.addClass(overlay, 'submitting'); | |
|
760 | ||
|
658 | var success = function(o){ | |
|
659 | $tr.removeClass('form-open'); | |
|
660 | $form.remove(); | |
|
661 | var json_data = JSON.parse(o.responseText); | |
|
662 | _renderInlineComment(json_data); | |
|
663 | }; | |
|
664 | var postData = { | |
|
665 | 'text': text, | |
|
666 | 'f_path': f_path, | |
|
667 | 'line': lineno | |
|
668 | }; | |
|
761 | 669 | ajaxPOST(submit_url, postData, success); |
|
762 | 670 | }); |
|
763 | 671 | |
|
764 |
|
|
|
765 |
var |
|
|
766 |
if(! |
|
|
672 | $('#preview-btn_'+lineno).click(function(e){ | |
|
673 | var text = $('#text_'+lineno).val(); | |
|
674 | if(!text){ | |
|
767 | 675 | return |
|
768 | 676 | } |
|
769 | var post_data = {'text': _text}; | |
|
770 |
|
|
|
771 | YUD.get('preview-box_'+lineno).innerHTML = _TM['Loading ...']; | |
|
772 |
|
|
|
773 | YUD.setStyle('preview-container_'+lineno, 'display', ''); | |
|
677 | $('#preview-box_'+lineno).addClass('unloaded'); | |
|
678 | $('#preview-box_'+lineno).html(_TM['Loading ...']); | |
|
679 | $('#edit-container_'+lineno).hide(); | |
|
680 | $('#preview-container_'+lineno).show(); | |
|
774 | 681 | |
|
775 | 682 | var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); |
|
776 | ajaxPOST(url,post_data,function(o){ | |
|
777 | YUD.get('preview-box_'+lineno).innerHTML = o.responseText; | |
|
778 |
|
|
|
683 | var post_data = {'text': text}; | |
|
684 | ajaxPOST(url, post_data, function(o){ | |
|
685 | $('#preview-box_'+lineno).html(o.responseText); | |
|
686 | $('#preview-box_'+lineno).removeClass('unloaded'); | |
|
779 | 687 | }) |
|
780 | 688 | }) |
|
781 |
|
|
|
782 |
|
|
|
783 |
|
|
|
689 | $('#edit-btn_'+lineno).click(function(e){ | |
|
690 | $('#edit-container_'+lineno).show(); | |
|
691 | $('#preview-container_'+lineno).hide(); | |
|
784 | 692 | }) |
|
785 | 693 | |
|
786 | 694 | setTimeout(function(){ |
@@ -788,10 +696,7 var injectInlineForm = function(tr){ | |||
|
788 | 696 | tooltip_activate(); |
|
789 | 697 | MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, |
|
790 | 698 | _USERS_AC_DATA, _GROUPS_AC_DATA); |
|
791 |
|
|
|
792 | if(_e){ | |
|
793 | _e.focus(); | |
|
794 | } | |
|
699 | $('#text_'+lineno).focus(); | |
|
795 | 700 | },10) |
|
796 | 701 | }; |
|
797 | 702 | |
@@ -799,38 +704,18 var deleteComment = function(comment_id) | |||
|
799 | 704 | var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); |
|
800 | 705 | var postData = {'_method':'delete'}; |
|
801 | 706 | var success = function(o){ |
|
802 |
var |
|
|
803 | var root = prevElementSibling(prevElementSibling(n)); | |
|
804 |
|
|
|
805 | ||
|
806 | // scann nodes, and attach add button to last one only for TR | |
|
807 | // which are the inline comments | |
|
808 | if(root && root.tagName == 'TR'){ | |
|
809 | placeAddButton(root); | |
|
810 | } | |
|
707 | var $deleted = $('#comment-tr-'+comment_id); | |
|
708 | var $prev = $deleted.prev('tr'); | |
|
709 | $deleted.remove(); | |
|
710 | _placeAddButton($prev); | |
|
811 | 711 | } |
|
812 | 712 | ajaxPOST(url,postData,success); |
|
813 | 713 | } |
|
814 | 714 | |
|
815 |
var |
|
|
816 | ||
|
817 | var label = TRANSLATION_MAP['Add another comment']; | |
|
818 | ||
|
819 | var html_el = document.createElement('div'); | |
|
820 | YUD.addClass(html_el, 'add-comment'); | |
|
821 | html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label); | |
|
822 | ||
|
823 | var add = new YAHOO.util.Element(html_el); | |
|
824 | add.on('click', function(e) { | |
|
825 | injectInlineForm(tr); | |
|
826 | }); | |
|
827 | return add; | |
|
828 | }; | |
|
829 | ||
|
830 | var getLineNo = function(tr) { | |
|
715 | var _getLineNo = function(tr) { | |
|
831 | 716 | var line; |
|
832 | var o = tr.children[0].id.split('_'); | |
|
833 | var n = tr.children[1].id.split('_'); | |
|
717 | var o = $(tr).children()[0].id.split('_'); | |
|
718 | var n = $(tr).children()[1].id.split('_'); | |
|
834 | 719 | |
|
835 | 720 | if (n.length >= 2) { |
|
836 | 721 | line = n[n.length-1]; |
@@ -841,78 +726,48 var getLineNo = function(tr) { | |||
|
841 | 726 | return line |
|
842 | 727 | }; |
|
843 | 728 | |
|
844 |
var placeAddButton = function( |
|
|
845 | if(!target_tr){ | |
|
846 | return | |
|
729 | var _placeAddButton = function($line_tr){ | |
|
730 | var $tr = $line_tr; | |
|
731 | while ($tr.next().hasClass('inline-comments')){ | |
|
732 | $tr.find('.add-comment').remove(); | |
|
733 | $tr = $tr.next(); | |
|
847 | 734 | } |
|
848 | var last_node = target_tr; | |
|
849 | //scann | |
|
850 | while (1){ | |
|
851 | var n = last_node.nextElementSibling; | |
|
852 | // next element are comments ! | |
|
853 | if($(n).hasClass('inline-comments')){ | |
|
854 | last_node = n; | |
|
855 | //also remove the comment button from previous | |
|
856 | var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node); | |
|
857 | for(var i=0;i<comment_add_buttons.length;i++){ | |
|
858 | var b = comment_add_buttons[i]; | |
|
859 | b.parentNode.removeChild(b); | |
|
860 | } | |
|
861 | } | |
|
862 | else{ | |
|
863 | break; | |
|
864 | } | |
|
865 | } | |
|
866 | ||
|
867 | var add = createInlineAddButton(target_tr); | |
|
868 | // get the comment div | |
|
869 | var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0]; | |
|
870 | // attach add button | |
|
871 | YUD.insertAfter(add,comment_block); | |
|
872 | } | |
|
735 | $tr.find('.add-comment').remove(); | |
|
736 | var label = TRANSLATION_MAP['Add another comment']; | |
|
737 | var $html_el = $('<div class="add-comment"><span class="ui-btn">{0}</span></div>'.format(label)); | |
|
738 | $html_el.click(function(e) { | |
|
739 | injectInlineForm($line_tr); | |
|
740 | }); | |
|
741 | $tr.find('.comment').after($html_el); | |
|
742 | }; | |
|
873 | 743 | |
|
874 | 744 |
|
|
875 | 745 | * Places the inline comment into the changeset block in proper line position |
|
876 | 746 | */ |
|
877 |
var placeInline = function(target_ |
|
|
878 |
var |
|
|
879 | var target_line = YUD.get(lineid); | |
|
880 | var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) | |
|
747 | var _placeInline = function(target_id, lineno, html){ | |
|
748 | var $td = $("#{0}_{1}".format(target_id, lineno)); | |
|
881 | 749 | |
|
882 | 750 | // check if there are comments already ! |
|
883 | var parent = target_line.parentNode; | |
|
884 | var root_parent = parent; | |
|
885 | while (1){ | |
|
886 | var n = parent.nextElementSibling; | |
|
887 | // next element are comments ! | |
|
888 | if($(n).hasClass('inline-comments')){ | |
|
889 | parent = n; | |
|
890 | } | |
|
891 | else{ | |
|
892 | break; | |
|
893 | } | |
|
751 | var $line_tr = $td.parent(); // the tr | |
|
752 | var $after_tr = $line_tr; | |
|
753 | while ($after_tr.next().hasClass('inline-comments')){ | |
|
754 | $after_tr = $after_tr.next(); | |
|
894 | 755 | } |
|
895 | 756 | // put in the comment at the bottom |
|
896 | YUD.insertAfter(comment,parent); | |
|
757 | $after_tr.after(_table_tr('inline-comments', html)); | |
|
897 | 758 | |
|
898 |
// scan |
|
|
899 |
placeAddButton( |
|
|
900 | ||
|
901 | return target_line; | |
|
759 | // scan nodes, and attach add button to last one | |
|
760 | _placeAddButton($line_tr); | |
|
902 | 761 | } |
|
903 | 762 | |
|
904 | 763 | /** |
|
905 | 764 | * make a single inline comment and place it inside |
|
906 | 765 | */ |
|
907 | var renderInlineComment = function(json_data){ | |
|
908 | try{ | |
|
909 |
|
|
|
910 |
|
|
|
911 | var target_id = json_data['target_id']; | |
|
912 | placeInline(target_id, lineno, html); | |
|
913 | }catch(e){ | |
|
914 | console.log(e); | |
|
915 | } | |
|
766 | var _renderInlineComment = function(json_data){ | |
|
767 | var html = json_data['rendered_text']; | |
|
768 | var lineno = json_data['line_no']; | |
|
769 | var target_id = json_data['target_id']; | |
|
770 | _placeInline(target_id, lineno, html); | |
|
916 | 771 | } |
|
917 | 772 | |
|
918 | 773 | /** |
@@ -923,27 +778,28 var renderInlineComments = function(file | |||
|
923 | 778 | // holding all comments for a FILE |
|
924 | 779 | var box = file_comments[f]; |
|
925 | 780 | |
|
926 |
var target_id = |
|
|
927 |
// actual |
|
|
781 | var target_id = $(box).attr('target_id'); | |
|
782 | // actual comments with line numbers | |
|
928 | 783 | var comments = box.children; |
|
929 | 784 | for(var i=0; i<comments.length; i++){ |
|
930 | 785 | var data = { |
|
931 | 786 | 'rendered_text': comments[i].outerHTML, |
|
932 |
'line_no': |
|
|
787 | 'line_no': $(comments[i]).attr('line'), | |
|
933 | 788 | 'target_id': target_id |
|
934 | 789 | } |
|
935 | renderInlineComment(data); | |
|
790 | _renderInlineComment(data); | |
|
936 | 791 | } |
|
937 | 792 | } |
|
938 | 793 | } |
|
939 | 794 | |
|
795 | /* activate files.html stuff */ | |
|
940 | 796 | var fileBrowserListeners = function(current_url, node_list_url, url_base){ |
|
941 |
var current_url_branch = |
|
|
797 | var current_url_branch = "?branch=__BRANCH__"; | |
|
942 | 798 | |
|
943 | 799 | $('#stay_at_branch').on('click',function(e){ |
|
944 | if(e.target.checked){ | |
|
800 | if(e.currentTarget.checked){ | |
|
945 | 801 | var uri = current_url_branch; |
|
946 | uri = uri.replace('__BRANCH__',e.target.value); | |
|
802 | uri = uri.replace('__BRANCH__',e.currentTarget.value); | |
|
947 | 803 | window.location = uri; |
|
948 | 804 | } |
|
949 | 805 | else{ |
@@ -951,26 +807,25 var fileBrowserListeners = function(curr | |||
|
951 | 807 | } |
|
952 | 808 | }) |
|
953 | 809 | |
|
954 |
var n_filter = |
|
|
955 | var F = YAHOO.namespace('node_filter'); | |
|
810 | var $node_filter = $('#node_filter'); | |
|
956 | 811 | |
|
957 |
|
|
|
812 | var filterTimeout = null; | |
|
958 | 813 | var nodes = null; |
|
959 | 814 | |
|
960 |
|
|
|
961 |
$('#node_filter_box_loading'). |
|
|
962 |
$('#search_activate_id'). |
|
|
963 |
$('#add_node_id'). |
|
|
815 | var initFilter = function(){ | |
|
816 | $('#node_filter_box_loading').show(); | |
|
817 | $('#search_activate_id').hide(); | |
|
818 | $('#add_node_id').hide(); | |
|
964 | 819 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
965 | 820 | YUC.asyncRequest('GET', node_list_url, { |
|
966 | 821 | success:function(o){ |
|
967 | 822 | nodes = JSON.parse(o.responseText).nodes; |
|
968 |
$('#node_filter_box_loading'). |
|
|
969 |
$('#node_filter_box'). |
|
|
970 | n_filter.focus(); | |
|
971 |
if( |
|
|
972 |
n_filter.val |
|
|
973 |
|
|
|
823 | $('#node_filter_box_loading').hide(); | |
|
824 | $('#node_filter_box').show(); | |
|
825 | $node_filter.focus(); | |
|
826 | if($node_filter.hasClass('init')){ | |
|
827 | $node_filter.val(''); | |
|
828 | $node_filter.removeClass('init'); | |
|
974 | 829 | } |
|
975 | 830 | }, |
|
976 | 831 | failure:function(o){ |
@@ -979,11 +834,11 var fileBrowserListeners = function(curr | |||
|
979 | 834 | },null); |
|
980 | 835 | } |
|
981 | 836 | |
|
982 |
|
|
|
837 | var updateFilter = function(e) { | |
|
983 | 838 | return function(){ |
|
984 | 839 | // Reset timeout |
|
985 |
|
|
|
986 | var query = e.target.value.toLowerCase(); | |
|
840 | filterTimeout = null; | |
|
841 | var query = e.currentTarget.value.toLowerCase(); | |
|
987 | 842 | var match = []; |
|
988 | 843 | var matches = 0; |
|
989 | 844 | var matches_max = 20; |
@@ -1011,58 +866,58 var fileBrowserListeners = function(curr | |||
|
1011 | 866 | } |
|
1012 | 867 | } |
|
1013 | 868 | if(query != ""){ |
|
1014 |
$('#tbody'). |
|
|
1015 |
$('#tbody_filtered'). |
|
|
869 | $('#tbody').hide(); | |
|
870 | $('#tbody_filtered').show(); | |
|
1016 | 871 | |
|
1017 | 872 | if (match.length==0){ |
|
1018 | 873 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['No matching files'])); |
|
1019 | 874 | } |
|
1020 | 875 | |
|
1021 |
|
|
|
876 | $('#tbody_filtered').html(match.join("")); | |
|
1022 | 877 | } |
|
1023 | 878 | else{ |
|
1024 |
$('#tbody'). |
|
|
1025 |
$('#tbody_filtered'). |
|
|
879 | $('#tbody').show(); | |
|
880 | $('#tbody_filtered').hide(); | |
|
1026 | 881 | } |
|
1027 | 882 | } |
|
1028 | 883 | }; |
|
1029 | 884 | |
|
1030 |
|
|
|
1031 |
|
|
|
1032 | }) | |
|
1033 |
|
|
|
1034 |
if( |
|
|
1035 |
n_filter.val |
|
|
1036 |
|
|
|
885 | $('#filter_activate').click(function(){ | |
|
886 | initFilter(); | |
|
887 | }); | |
|
888 | $node_filter.click(function(){ | |
|
889 | if($node_filter.hasClass('init')){ | |
|
890 | $node_filter.val(''); | |
|
891 | $node_filter.removeClass('init'); | |
|
1037 | 892 | } |
|
1038 | 893 | }); |
|
1039 |
|
|
|
1040 |
clearTimeout( |
|
|
1041 |
|
|
|
894 | $node_filter.keyup(function(e){ | |
|
895 | clearTimeout(filterTimeout); | |
|
896 | filterTimeout = setTimeout(updateFilter(e),600); | |
|
1042 | 897 | }); |
|
1043 | 898 | }; |
|
1044 | 899 | |
|
1045 | 900 | |
|
1046 |
var initCodeMirror = function(text |
|
|
1047 |
var myCodeMirror = CodeMirror.fromTextArea( |
|
|
1048 |
mode: |
|
|
1049 | lineNumbers:true, | |
|
901 | var initCodeMirror = function(textarea_id, resetUrl){ | |
|
902 | var myCodeMirror = CodeMirror.fromTextArea($('#' + textarea_id)[0], { | |
|
903 | mode: "null", | |
|
904 | lineNumbers: true, | |
|
1050 | 905 | indentUnit: 4 |
|
1051 | 906 | }); |
|
1052 |
|
|
|
1053 | window.location=resetUrl | |
|
907 | $('#reset').click(function(e){ | |
|
908 | window.location=resetUrl; | |
|
1054 | 909 | }); |
|
1055 | 910 | |
|
1056 |
|
|
|
1057 |
$('#editor_container'). |
|
|
1058 |
$('#upload_file_container'). |
|
|
1059 |
$('#filename_container'). |
|
|
911 | $('#file_enable').click(function(){ | |
|
912 | $('#editor_container').show(); | |
|
913 | $('#upload_file_container').hide(); | |
|
914 | $('#filename_container').show(); | |
|
1060 | 915 | }); |
|
1061 | 916 | |
|
1062 |
|
|
|
1063 |
$('#editor_container'). |
|
|
1064 |
$('#upload_file_container'). |
|
|
1065 |
$('#filename_container'). |
|
|
917 | $('#upload_file_enable').click(function(){ | |
|
918 | $('#editor_container').hide(); | |
|
919 | $('#upload_file_container').show(); | |
|
920 | $('#filename_container').hide(); | |
|
1066 | 921 | }); |
|
1067 | 922 | |
|
1068 | 923 | return myCodeMirror |
@@ -1074,8 +929,8 var setCodeMirrorMode = function(codeMir | |||
|
1074 | 929 | } |
|
1075 | 930 | |
|
1076 | 931 | |
|
1077 | var getIdentNode = function(n){ | |
|
1078 |
//iterate thru nodes until |
|
|
932 | var _getIdentNode = function(n){ | |
|
933 | //iterate thrugh nodes until matching interesting node | |
|
1079 | 934 | |
|
1080 | 935 | if (typeof n == 'undefined'){ |
|
1081 | 936 | return -1 |
@@ -1085,68 +940,55 var getIdentNode = function(n){ | |||
|
1085 | 940 | return n |
|
1086 | 941 | } |
|
1087 | 942 | else{ |
|
1088 | return getIdentNode(n.parentNode); | |
|
943 | return _getIdentNode(n.parentNode); | |
|
1089 | 944 | } |
|
1090 | 945 | }; |
|
1091 | 946 | |
|
947 | /* generate links for multi line selects that can be shown by files.html page_highlights. | |
|
948 | * This is a mouseup handler for hlcode from CodeHtmlFormatter and pygmentize */ | |
|
1092 | 949 | var getSelectionLink = function(e) { |
|
1093 | 950 | //get selection from start/to nodes |
|
1094 | 951 | if (typeof window.getSelection != "undefined") { |
|
1095 | 952 | s = window.getSelection(); |
|
1096 | 953 | |
|
1097 | from = getIdentNode(s.anchorNode); | |
|
1098 | till = getIdentNode(s.focusNode); | |
|
954 | from = _getIdentNode(s.anchorNode); | |
|
955 | till = _getIdentNode(s.focusNode); | |
|
1099 | 956 | |
|
1100 | 957 | f_int = parseInt(from.id.replace('L','')); |
|
1101 | 958 | t_int = parseInt(till.id.replace('L','')); |
|
1102 | 959 | |
|
1103 | if (f_int > t_int){ | |
|
960 | var yoffset = 35; | |
|
961 | var ranges = [parseInt(from.id.replace('L','')), parseInt(till.id.replace('L',''))]; | |
|
962 | if (ranges[0] > ranges[1]){ | |
|
1104 | 963 | //highlight from bottom |
|
1105 |
offset = - |
|
|
1106 |
ranges = [ |
|
|
1107 | ||
|
964 | yoffset = -yoffset; | |
|
965 | ranges = [ranges[1], ranges[0]]; | |
|
1108 | 966 | } |
|
1109 | else{ | |
|
1110 | //highligth from top | |
|
1111 | offset = 35; | |
|
1112 | ranges = [f_int,t_int]; | |
|
1113 | } | |
|
967 | var $hl_div = $('div#linktt'); | |
|
1114 | 968 | // if we select more than 2 lines |
|
1115 | 969 | if (ranges[0] != ranges[1]){ |
|
1116 | if(YUD.get('linktt') == null){ | |
|
1117 |
hl_div |
|
|
1118 | hl_div.id = 'linktt'; | |
|
970 | if ($hl_div.length) { | |
|
971 | $hl_div.html(''); | |
|
972 | } else { | |
|
973 | $hl_div = $('<div id="linktt" class="hl-tip-box">'); | |
|
974 | $('body').prepend($hl_div); | |
|
1119 | 975 | } |
|
1120 | hl_div.innerHTML = ''; | |
|
1121 | 976 | |
|
1122 | anchor = '#L'+ranges[0]+'-'+ranges[1]; | |
|
1123 | var link = document.createElement('a'); | |
|
1124 | link.href = location.href.substring(0,location.href.indexOf('#'))+anchor; | |
|
1125 | link.innerHTML = _TM['Selection link']; | |
|
1126 | hl_div.appendChild(link); | |
|
1127 | YUD.get('body').appendChild(hl_div); | |
|
1128 | ||
|
1129 | xy = YUD.getXY(till.id); | |
|
1130 | ||
|
1131 | YUD.addClass('linktt', 'hl-tip-box'); | |
|
1132 | $('#linktt').css('top',xy[1]+offset+'px'); | |
|
1133 | $('#linktt').css('left',xy[0]+'px'); | |
|
1134 | $('#linktt').css('visibility','visible'); | |
|
1135 | ||
|
977 | $hl_div.append($('<a>').html(_TM['Selection link']).attr('href', location.href.substring(0, location.href.indexOf('#')) + '#L' + ranges[0] + '-'+ranges[1])); | |
|
978 | xy = $(till).offset(); | |
|
979 | $hl_div.css('top', (xy.top + yoffset) + 'px').css('left', xy.left + 'px'); | |
|
980 | $hl_div.show(); | |
|
1136 | 981 | } |
|
1137 | 982 | else{ |
|
1138 | $('#linktt').css('visibility','hidden'); | |
|
983 | $hl_div.hide(); | |
|
1139 | 984 | } |
|
1140 | 985 | } |
|
1141 | 986 | }; |
|
1142 | 987 | |
|
1143 | var deleteNotification = function(url, notification_id,callbacks){ | |
|
988 | var deleteNotification = function(url, notification_id, callbacks){ | |
|
1144 | 989 | var callback = { |
|
1145 | 990 | success:function(o){ |
|
1146 |
|
|
|
1147 | if(obj.parentNode !== undefined){ | |
|
1148 | obj.parentNode.removeChild(obj); | |
|
1149 | } | |
|
991 | $("#notification_"+notification_id).remove(); | |
|
1150 | 992 | _run_callbacks(callbacks); |
|
1151 | 993 | }, |
|
1152 | 994 | failure:function(o){ |
@@ -1159,16 +1001,12 var deleteNotification = function(url, n | |||
|
1159 | 1001 | callback, postData); |
|
1160 | 1002 | }; |
|
1161 | 1003 | |
|
1162 | var readNotification = function(url, notification_id,callbacks){ | |
|
1004 | var readNotification = function(url, notification_id, callbacks){ | |
|
1163 | 1005 | var callback = { |
|
1164 | 1006 | success:function(o){ |
|
1165 |
var obj = |
|
|
1166 |
|
|
|
1167 | var r_button = YUD.getElementsByClassName('read-notification',null,obj.children[0])[0]; | |
|
1168 | ||
|
1169 | if(r_button.parentNode !== undefined){ | |
|
1170 | r_button.parentNode.removeChild(r_button); | |
|
1171 | } | |
|
1007 | var $obj = $("#notification_"+notification_id); | |
|
1008 | $obj.removeClass('unread'); | |
|
1009 | $obj.find('.read-notification').remove(); | |
|
1172 | 1010 | _run_callbacks(callbacks); |
|
1173 | 1011 | }, |
|
1174 | 1012 | failure:function(o){ |
@@ -1183,7 +1021,7 var readNotification = function(url, not | |||
|
1183 | 1021 | |
|
1184 | 1022 | /** MEMBERS AUTOCOMPLETE WIDGET **/ |
|
1185 | 1023 | |
|
1186 | var MembersAutoComplete = function (divid, cont, users_list, groups_list) { | |
|
1024 | var _MembersAutoComplete = function (divid, cont, users_list, groups_list) { | |
|
1187 | 1025 | var myUsers = users_list; |
|
1188 | 1026 | var myGroups = groups_list; |
|
1189 | 1027 | |
@@ -1338,11 +1176,11 var MembersAutoComplete = function (divi | |||
|
1338 | 1176 | if (oData.nname != undefined) { |
|
1339 | 1177 | //users |
|
1340 | 1178 | myAC.getInputEl().value = oData.nname; |
|
1341 |
|
|
|
1179 | $('#perm_new_member_type_'+nextId).val('user'); | |
|
1342 | 1180 | } else { |
|
1343 | 1181 | //groups |
|
1344 | 1182 | myAC.getInputEl().value = oData.grname; |
|
1345 |
|
|
|
1183 | $('#perm_new_member_type_'+nextId).val('users_group'); | |
|
1346 | 1184 | } |
|
1347 | 1185 | }; |
|
1348 | 1186 | |
@@ -1485,11 +1323,11 var MentionsAutoComplete = function (div | |||
|
1485 | 1323 | chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, |
|
1486 | 1324 | '@'+oData.nname+' '); |
|
1487 | 1325 | myAC.getInputEl().value = chunks.join('') |
|
1488 |
|
|
|
1326 | myAC.getInputEl().focus(); // Y U NO WORK !? | |
|
1489 | 1327 | } else { |
|
1490 | 1328 | //groups |
|
1491 | 1329 | myAC.getInputEl().value = oData.grname; |
|
1492 |
|
|
|
1330 | $('#perm_new_member_type').val('users_group'); | |
|
1493 | 1331 | } |
|
1494 | 1332 | }); |
|
1495 | 1333 | } |
@@ -1549,7 +1387,6 var MentionsAutoComplete = function (div | |||
|
1549 | 1387 | } |
|
1550 | 1388 | |
|
1551 | 1389 | var addReviewMember = function(id,fname,lname,nname,gravatar_link){ |
|
1552 | var members = YUD.get('review_members'); | |
|
1553 | 1390 | var tmpl = '<li id="reviewer_{2}">'+ |
|
1554 | 1391 | '<div class="reviewers_member">'+ |
|
1555 | 1392 | '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+ |
@@ -1562,31 +1399,26 var addReviewMember = function(id,fname, | |||
|
1562 | 1399 | var element = tmpl.format(gravatar_link,displayname,id); |
|
1563 | 1400 | // check if we don't have this ID already in |
|
1564 | 1401 | var ids = []; |
|
1565 | var _els = YUQ('#review_members li'); | |
|
1566 | for (el in _els){ | |
|
1567 | ids.push(_els[el].id) | |
|
1568 | } | |
|
1402 | $('#review_members').find('li').each(function() { | |
|
1403 | ids.push(this.id); | |
|
1404 | }); | |
|
1569 | 1405 | if(ids.indexOf('reviewer_'+id) == -1){ |
|
1570 | 1406 | //only add if it's not there |
|
1571 |
members. |
|
|
1407 | $('#review_members').append(element); | |
|
1572 | 1408 | } |
|
1573 | 1409 | } |
|
1574 | 1410 | |
|
1575 | 1411 | var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){ |
|
1576 |
|
|
|
1577 | if (el.parentNode !== undefined){ | |
|
1578 | el.parentNode.removeChild(el); | |
|
1579 | } | |
|
1412 | $('#reviewer_{0}'.format(reviewer_id)).remove(); | |
|
1580 | 1413 | } |
|
1581 | 1414 | |
|
1415 | /* handle "Save Changes" of addReviewMember and removeReviewMember on PR */ | |
|
1582 | 1416 | var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ |
|
1583 | 1417 | if (reviewers_ids === undefined){ |
|
1584 | 1418 | var reviewers_ids = []; |
|
1585 |
|
|
|
1586 | for(var i=0; i<ids.length;i++){ | |
|
1587 | var id = ids[i].value | |
|
1588 | reviewers_ids.push(id); | |
|
1589 | } | |
|
1419 | $('#review_members').find('input').each(function(){ | |
|
1420 | reviewers_ids.push(this.value); | |
|
1421 | }); | |
|
1590 | 1422 | } |
|
1591 | 1423 | var url = pyroutes.url('pullrequest_update', {"repo_name":repo_name, |
|
1592 | 1424 | "pull_request_id": pull_request_id}); |
@@ -1598,6 +1430,7 var updateReviewers = function(reviewers | |||
|
1598 | 1430 | ajaxPOST(url,postData,success); |
|
1599 | 1431 | } |
|
1600 | 1432 | |
|
1433 | /* activate auto completion of users and groups ... but only used for users as PR reviewers */ | |
|
1601 | 1434 | var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1602 | 1435 | var myUsers = users_list; |
|
1603 | 1436 | var myGroups = groups_list; |
@@ -1731,37 +1564,32 var PullRequestAutoComplete = function ( | |||
|
1731 | 1564 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1732 | 1565 | |
|
1733 | 1566 | //fill the autocomplete with value |
|
1734 | ||
|
1735 | 1567 | if (oData.nname != undefined) { |
|
1736 | 1568 | addReviewMember(oData.id, oData.fname, oData.lname, oData.nname, |
|
1737 | 1569 | oData.gravatar_lnk); |
|
1738 | 1570 | myAC.dataSource.cache.push(oData.id); |
|
1739 |
|
|
|
1571 | $('#user').val(''); | |
|
1740 | 1572 | } |
|
1741 | 1573 | }); |
|
1742 | 1574 | } |
|
1743 | return { | |
|
1744 | ownerDS: ownerDS, | |
|
1745 | reviewerAC: reviewerAC, | |
|
1746 | }; | |
|
1747 | 1575 | } |
|
1748 | 1576 | |
|
1749 | 1577 | /** |
|
1750 | * QUICK REPO MENU | |
|
1578 | * Activate .quick_repo_menu | |
|
1751 | 1579 | */ |
|
1752 | 1580 | var quick_repo_menu = function(){ |
|
1753 |
|
|
|
1754 |
var menu = e.currentTarget. |
|
|
1755 |
if( |
|
|
1756 |
|
|
|
1757 |
|
|
|
1581 | $(".quick_repo_menu").mouseenter(function(e) { | |
|
1582 | var $menu = $(e.currentTarget).children().first().children().first(); | |
|
1583 | if($menu.hasClass('hidden')){ | |
|
1584 | $menu.removeClass('hidden').addClass('active'); | |
|
1585 | $(e.currentTarget).removeClass('hidden').addClass('active'); | |
|
1758 | 1586 | } |
|
1759 | 1587 | }) |
|
1760 |
|
|
|
1761 |
var menu = e.currentTarget. |
|
|
1762 |
if( |
|
|
1763 |
|
|
|
1764 |
|
|
|
1588 | $(".quick_repo_menu").mouseleave(function(e) { | |
|
1589 | var $menu = $(e.currentTarget).children().first().children().first(); | |
|
1590 | if($menu.hasClass('active')){ | |
|
1591 | $menu.removeClass('active').addClass('hidden'); | |
|
1592 | $(e.currentTarget).removeClass('active').addClass('hidden'); | |
|
1765 | 1593 | } |
|
1766 | 1594 | }) |
|
1767 | 1595 | }; |
@@ -1791,92 +1619,57 var get_rev = function(node){ | |||
|
1791 | 1619 | } |
|
1792 | 1620 | |
|
1793 | 1621 | var get_date = function(node){ |
|
1794 |
|
|
|
1795 | return date_ | |
|
1622 | return $(node.firstElementChild).attr('date'); | |
|
1796 | 1623 | } |
|
1797 | 1624 | |
|
1798 | 1625 | var revisionSort = function(a, b, desc, field) { |
|
1799 | var a_ = fromHTML(a.getData(field)); | |
|
1800 | var b_ = fromHTML(b.getData(field)); | |
|
1626 | var a_ = get_rev(fromHTML(a.getData(field))); | |
|
1627 | var b_ = get_rev(fromHTML(b.getData(field))); | |
|
1801 | 1628 | |
|
1802 | // extract revisions from string nodes | |
|
1803 | a_ = get_rev(a_) | |
|
1804 | b_ = get_rev(b_) | |
|
1805 | ||
|
1806 | var comp = YAHOO.util.Sort.compare; | |
|
1807 | var compState = comp(a_, b_, desc); | |
|
1808 | return compState; | |
|
1629 | return YAHOO.util.Sort.compare(a_, b_, desc); | |
|
1809 | 1630 | }; |
|
1810 | 1631 | |
|
1811 | 1632 | var ageSort = function(a, b, desc, field) { |
|
1812 | var a_ = fromHTML(a.getData(field)); | |
|
1813 |
var |
|
|
1633 | // data is like: <span class="tooltip" date="2014-06-04 18:18:55.325474" title="Wed, 04 Jun 2014 18:18:55">1 day and 23 hours ago</span> | |
|
1634 | var a_ = $(a.getData(field)).attr('date'); | |
|
1635 | var b_ = $(b.getData(field)).attr('date'); | |
|
1814 | 1636 | |
|
1815 | // extract name from table | |
|
1816 | a_ = get_date(a_) | |
|
1817 | b_ = get_date(b_) | |
|
1818 | ||
|
1819 | var comp = YAHOO.util.Sort.compare; | |
|
1820 | var compState = comp(a_, b_, desc); | |
|
1821 | return compState; | |
|
1637 | return YAHOO.util.Sort.compare(a_, b_, desc); | |
|
1822 | 1638 | }; |
|
1823 | 1639 | |
|
1824 | 1640 | var lastLoginSort = function(a, b, desc, field) { |
|
1825 | 1641 | var a_ = a.getData('last_login_raw') || 0; |
|
1826 | 1642 | var b_ = b.getData('last_login_raw') || 0; |
|
1827 | 1643 | |
|
1828 |
|
|
|
1829 | var compState = comp(a_, b_, desc); | |
|
1830 | return compState; | |
|
1644 | return YAHOO.util.Sort.compare(a_, b_, desc); | |
|
1831 | 1645 | }; |
|
1832 | 1646 | |
|
1833 | 1647 | var nameSort = function(a, b, desc, field) { |
|
1834 | 1648 | var a_ = a.getData('raw_name') || 0; |
|
1835 | 1649 | var b_ = b.getData('raw_name') || 0; |
|
1836 | 1650 | |
|
1837 |
|
|
|
1838 | var compState = comp(a_, b_, desc); | |
|
1839 | return compState; | |
|
1651 | return YAHOO.util.Sort.compare(a_, b_, desc); | |
|
1840 | 1652 | }; |
|
1841 | 1653 | |
|
1842 | 1654 | var dateSort = function(a, b, desc, field) { |
|
1843 | var a_ = fromHTML(a.getData(field)); | |
|
1844 | var b_ = fromHTML(b.getData(field)); | |
|
1655 | var a_ = get_date(fromHTML(a.getData(field))); | |
|
1656 | var b_ = get_date(fromHTML(b.getData(field))); | |
|
1845 | 1657 | |
|
1846 | // extract name from table | |
|
1847 | a_ = get_date(a_) | |
|
1848 | b_ = get_date(b_) | |
|
1849 | ||
|
1850 | var comp = YAHOO.util.Sort.compare; | |
|
1851 | var compState = comp(a_, b_, desc); | |
|
1852 | return compState; | |
|
1658 | return YAHOO.util.Sort.compare(a_, b_, desc); | |
|
1853 | 1659 | }; |
|
1854 | 1660 | |
|
1855 | 1661 | var addPermAction = function(_html, users_list, groups_list){ |
|
1856 | var elmts = YUD.getElementsByClassName('last_new_member'); | |
|
1857 | var last_node = elmts[elmts.length-1]; | |
|
1858 | if (last_node){ | |
|
1859 | var next_id = (YUD.getElementsByClassName('new_members')).length; | |
|
1860 | _html = _html.format(next_id); | |
|
1861 | last_node.innerHTML = _html; | |
|
1862 | YUD.setStyle(last_node, 'display', ''); | |
|
1863 | YUD.removeClass(last_node, 'last_new_member'); | |
|
1864 | MembersAutoComplete("perm_new_member_name_"+next_id, | |
|
1865 | "perm_container_"+next_id, users_list, groups_list); | |
|
1866 | //create new last NODE | |
|
1867 | var el = document.createElement('tr'); | |
|
1868 | el.id = 'add_perm_input'; | |
|
1869 | YUD.addClass(el,'last_new_member'); | |
|
1870 | YUD.addClass(el,'new_members'); | |
|
1871 | YUD.insertAfter(el, last_node); | |
|
1872 | } | |
|
1662 | var $last_node = $('.last_new_member').last(); // empty tr between last and add | |
|
1663 | var next_id = $('.new_members').length; | |
|
1664 | $last_node.before($('<tr class="new_members">').append(_html.format(next_id))); | |
|
1665 | _MembersAutoComplete("perm_new_member_name_"+next_id, | |
|
1666 | "perm_container_"+next_id, users_list, groups_list); | |
|
1873 | 1667 | } |
|
1874 | 1668 | |
|
1875 | 1669 | function ajaxActionRevokePermission(url, obj_id, obj_type, field_id, extra_data) { |
|
1876 | 1670 | var callback = { |
|
1877 | 1671 | success: function (o) { |
|
1878 | var tr = YUD.get(String(field_id)); | |
|
1879 | tr.parentNode.removeChild(tr); | |
|
1672 | $('#' + field_id).remove(); | |
|
1880 | 1673 | }, |
|
1881 | 1674 | failure: function (o) { |
|
1882 | 1675 | alert(_TM['Failed to remoke permission'] + ": " + o.status); |
@@ -1902,141 +1695,44 function ajaxActionRevokePermission(url, | |||
|
1902 | 1695 | } |
|
1903 | 1696 | |
|
1904 | 1697 | var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, |
|
1905 | toQueryString(query_params)); | |
|
1698 | _toQueryString(query_params)); | |
|
1906 | 1699 | }; |
|
1907 | 1700 | |
|
1908 | 1701 | /* Multi selectors */ |
|
1909 | 1702 | |
|
1910 | 1703 | var MultiSelectWidget = function(selected_id, available_id, form_id){ |
|
1911 | //definition of containers ID's | |
|
1912 |
var selected |
|
|
1913 | var available_container = available_id; | |
|
1914 | ||
|
1915 | //temp container for selected storage. | |
|
1916 | var cache = new Array(); | |
|
1917 | var av_cache = new Array(); | |
|
1918 | var c = YUD.get(selected_container); | |
|
1919 | var ac = YUD.get(available_container); | |
|
1920 | ||
|
1921 | //get only selected options for further fullfilment | |
|
1922 | for(var i = 0;node =c.options[i];i++){ | |
|
1923 | if(node.selected){ | |
|
1924 | //push selected to my temp storage left overs :) | |
|
1925 | cache.push(node); | |
|
1926 | } | |
|
1927 | } | |
|
1928 | ||
|
1929 | //get all available options to cache | |
|
1930 | for(var i = 0;node =ac.options[i];i++){ | |
|
1931 | //push selected to my temp storage left overs :) | |
|
1932 | av_cache.push(node); | |
|
1933 | } | |
|
1934 | ||
|
1935 | //fill available only with those not in chosen | |
|
1936 | ac.options.length=0; | |
|
1937 | tmp_cache = new Array(); | |
|
1704 | var $availableselect = $('#' + available_id); | |
|
1705 | var $selectedselect = $('#' + selected_id); | |
|
1938 | 1706 | |
|
1939 | for(var i = 0;node = av_cache[i];i++){ | |
|
1940 | var add = true; | |
|
1941 | for(var i2 = 0;node_2 = cache[i2];i2++){ | |
|
1942 | if(node.value == node_2.value){ | |
|
1943 | add=false; | |
|
1944 |
|
|
|
1945 | } | |
|
1946 | } | |
|
1947 | if(add){ | |
|
1948 | tmp_cache.push(new Option(node.text, node.value, false, false)); | |
|
1949 | } | |
|
1950 | } | |
|
1951 | ||
|
1952 | for(var i = 0;node = tmp_cache[i];i++){ | |
|
1953 | ac.options[i] = node; | |
|
1954 | } | |
|
1955 | ||
|
1956 | function prompts_action_callback(e){ | |
|
1957 | ||
|
1958 | var chosen = YUD.get(selected_container); | |
|
1959 | var available = YUD.get(available_container); | |
|
1960 | ||
|
1961 | //get checked and unchecked options from field | |
|
1962 | function get_checked(from_field){ | |
|
1963 | //temp container for storage. | |
|
1964 | var sel_cache = new Array(); | |
|
1965 | var oth_cache = new Array(); | |
|
1966 | ||
|
1967 | for(var i = 0;node = from_field.options[i];i++){ | |
|
1968 | if(node.selected){ | |
|
1969 | //push selected fields :) | |
|
1970 | sel_cache.push(node); | |
|
1971 | } | |
|
1972 | else{ | |
|
1973 | oth_cache.push(node) | |
|
1707 | //fill available only with those not in selected | |
|
1708 | var $selectedoptions = $selectedselect.children('option'); | |
|
1709 | $availableselect.children('option').filter(function(i, e){ | |
|
1710 | for(var j = 0, node; node = $selectedoptions[j]; j++){ | |
|
1711 | if(node.value == e.value){ | |
|
1712 | return true; | |
|
1974 | 1713 | } |
|
1975 | 1714 | } |
|
1976 | ||
|
1977 | return [sel_cache,oth_cache] | |
|
1978 | } | |
|
1979 | ||
|
1980 | //fill the field with given options | |
|
1981 | function fill_with(field,options){ | |
|
1982 | //clear firtst | |
|
1983 | field.options.length=0; | |
|
1984 | for(var i = 0;node = options[i];i++){ | |
|
1985 | field.options[i]=new Option(node.text, node.value, | |
|
1986 | false, false); | |
|
1987 | } | |
|
1988 | ||
|
1989 | } | |
|
1990 | //adds to current field | |
|
1991 | function add_to(field,options){ | |
|
1992 | for(var i = 0;node = options[i];i++){ | |
|
1993 | field.appendChild(new Option(node.text, node.value, | |
|
1994 | false, false)); | |
|
1995 | } | |
|
1996 | } | |
|
1715 | return false; | |
|
1716 | }).remove(); | |
|
1997 | 1717 | |
|
1998 | // add action | |
|
1999 | if (this.id=='add_element'){ | |
|
2000 | var c = get_checked(available); | |
|
2001 | add_to(chosen,c[0]); | |
|
2002 | fill_with(available,c[1]); | |
|
2003 | } | |
|
2004 | // remove action | |
|
2005 | if (this.id=='remove_element'){ | |
|
2006 | var c = get_checked(chosen); | |
|
2007 | add_to(available,c[0]); | |
|
2008 | fill_with(chosen,c[1]); | |
|
2009 | } | |
|
2010 | // add all elements | |
|
2011 | if(this.id=='add_all_elements'){ | |
|
2012 | for(var i=0; node = available.options[i];i++){ | |
|
2013 | chosen.appendChild(new Option(node.text, | |
|
2014 | node.value, false, false)); | |
|
2015 | } | |
|
2016 | available.options.length = 0; | |
|
2017 | } | |
|
2018 | //remove all elements | |
|
2019 | if(this.id=='remove_all_elements'){ | |
|
2020 | for(var i=0; node = chosen.options[i];i++){ | |
|
2021 | available.appendChild(new Option(node.text, | |
|
2022 | node.value, false, false)); | |
|
2023 | } | |
|
2024 | chosen.options.length = 0; | |
|
2025 | } | |
|
1718 | $('#add_element').click(function(e){ | |
|
1719 | $selectedselect.append($availableselect.children('option:selected')); | |
|
1720 | }); | |
|
1721 | $('#remove_element').click(function(e){ | |
|
1722 | $availableselect.append($selectedselect.children('option:selected')); | |
|
1723 | }); | |
|
1724 | $('#add_all_elements').click(function(e){ | |
|
1725 | $selectedselect.append($availableselect.children('option')); | |
|
1726 | }); | |
|
1727 | $('#remove_all_elements').click(function(e){ | |
|
1728 | $availableselect.append($selectedselect.children('option')); | |
|
1729 | }); | |
|
2026 | 1730 | |
|
2027 | } | |
|
2028 | ||
|
2029 | YUE.addListener(['add_element','remove_element', | |
|
2030 | 'add_all_elements','remove_all_elements'],'click', | |
|
2031 | prompts_action_callback) | |
|
2032 | if (form_id !== undefined) { | |
|
2033 | YUE.addListener(form_id,'submit',function(){ | |
|
2034 | var chosen = YUD.get(selected_container); | |
|
2035 | for (var i = 0; i < chosen.options.length; i++) { | |
|
2036 | chosen.options[i].selected = 'selected'; | |
|
2037 | } | |
|
1731 | $('#'+form_id).submit(function(){ | |
|
1732 | $selectedselect.children('option').each(function(i, e){ | |
|
1733 | e.selected = 'selected'; | |
|
1734 | }); | |
|
2038 | 1735 | }); |
|
2039 | } | |
|
2040 | 1736 | } |
|
2041 | 1737 | |
|
2042 | 1738 | // custom paginator |
@@ -2108,7 +1804,7 var YUI_paginator = function(links_per_p | |||
|
2108 | 1804 | |
|
2109 | 1805 | this.link = document.createElement('a'); |
|
2110 | 1806 | this.span = document.createElement('span'); |
|
2111 |
|
|
|
1807 | $(this.span).hide(); | |
|
2112 | 1808 | |
|
2113 | 1809 | var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); |
|
2114 | 1810 | this.leftmost_page = _pos[0]; |
@@ -2119,7 +1815,7 var YUI_paginator = function(links_per_p | |||
|
2119 | 1815 | this.link.className = c; |
|
2120 | 1816 | this.link.innerHTML = label; |
|
2121 | 1817 | this.link.title = title; |
|
2122 |
Y |
|
|
1818 | YUE.on(this.link,'click',this.onClick,this,true); | |
|
2123 | 1819 | |
|
2124 | 1820 | setId(this.span, id_base + '-first-span'); |
|
2125 | 1821 | this.span.className = c; |
@@ -2152,12 +1848,12 var YUI_paginator = function(links_per_p | |||
|
2152 | 1848 | } |
|
2153 | 1849 | }, |
|
2154 | 1850 | destroy : function () { |
|
2155 |
Y |
|
|
1851 | YUE.purgeElement(this.link); | |
|
2156 | 1852 | this.current.parentNode.removeChild(this.current); |
|
2157 | 1853 | this.link = this.span = null; |
|
2158 | 1854 | }, |
|
2159 | 1855 | onClick : function (e) { |
|
2160 |
Y |
|
|
1856 | YUE.stopEvent(e); | |
|
2161 | 1857 | this.paginator.setPage(1); |
|
2162 | 1858 | } |
|
2163 | 1859 | }; |
@@ -2237,7 +1933,7 var YUI_paginator = function(links_per_p | |||
|
2237 | 1933 | |
|
2238 | 1934 | this.link = document.createElement('a'); |
|
2239 | 1935 | this.span = document.createElement('span'); |
|
2240 |
|
|
|
1936 | $(this.span).hide(); | |
|
2241 | 1937 | |
|
2242 | 1938 | this.na = this.span.cloneNode(false); |
|
2243 | 1939 | |
@@ -2246,7 +1942,7 var YUI_paginator = function(links_per_p | |||
|
2246 | 1942 | this.link.className = c; |
|
2247 | 1943 | this.link.innerHTML = label; |
|
2248 | 1944 | this.link.title = title; |
|
2249 |
Y |
|
|
1945 | YUE.on(this.link,'click',this.onClick,this,true); | |
|
2250 | 1946 | |
|
2251 | 1947 | setId(this.span, id_base + '-last-span'); |
|
2252 | 1948 | this.span.className = c; |
@@ -2295,12 +1991,12 var YUI_paginator = function(links_per_p | |||
|
2295 | 1991 | |
|
2296 | 1992 | }, |
|
2297 | 1993 | destroy : function () { |
|
2298 |
Y |
|
|
1994 | YUE.purgeElement(this.link); | |
|
2299 | 1995 | this.current.parentNode.removeChild(this.current); |
|
2300 | 1996 | this.link = this.span = null; |
|
2301 | 1997 | }, |
|
2302 | 1998 | onClick : function (e) { |
|
2303 |
Y |
|
|
1999 | YUE.stopEvent(e); | |
|
2304 | 2000 | this.paginator.setPage(this.paginator.getTotalPages()); |
|
2305 | 2001 | } |
|
2306 | 2002 | }; |
@@ -2326,18 +2022,17 var YUI_paginator = function(links_per_p | |||
|
2326 | 2022 | |
|
2327 | 2023 | // global hooks after DOM is loaded |
|
2328 | 2024 | |
|
2329 |
|
|
|
2330 |
|
|
|
2331 | var button = e.currentTarget; | |
|
2332 |
var t = |
|
|
2333 | console.log(t); | |
|
2334 |
|
|
|
2335 | YUD.removeClass(t, 'hidden'); | |
|
2336 | YUD.get(button).innerHTML = "↑ {0} ↑".format(_TM['Collapse diff']); | |
|
2025 | $(document).ready(function(){ | |
|
2026 | $('.diff-collapse-button').click(function(e) { | |
|
2027 | var $button = $(e.currentTarget); | |
|
2028 | var $target = $('#' + $button.attr('target')); | |
|
2029 | if($target.hasClass('hidden')){ | |
|
2030 | $target.removeClass('hidden'); | |
|
2031 | $button.html("↑ {0} ↑".format(_TM['Collapse diff'])); | |
|
2337 | 2032 | } |
|
2338 |
else if(! |
|
|
2339 |
|
|
|
2340 |
|
|
|
2033 | else if(!$target.hasClass('hidden')){ | |
|
2034 | $target.addClass('hidden'); | |
|
2035 | $button.html("↓ {0} ↓".format(_TM['Expand diff'])); | |
|
2341 | 2036 | } |
|
2342 | 2037 | }); |
|
2343 | 2038 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now