Mercurial > kallithea
comparison rhodecode/public/js/rhodecode.js @ 4158:e4848cd9c8ae rhodecode-2.2.5-gpl
rhodecode.js: fix indentation
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 02 Jul 2014 19:03:25 -0400 |
parents | bc296381fb6c |
children | a991e5c57a8d |
comparison
equal
deleted
inserted
replaced
4157:bc296381fb6c | 4158:e4848cd9c8ae |
---|---|
11 * Usage: "My name is {0} {1}".format("Johny","Bravo") | 11 * Usage: "My name is {0} {1}".format("Johny","Bravo") |
12 * Return "My name is Johny Bravo" | 12 * Return "My name is Johny Bravo" |
13 * Inspired by https://gist.github.com/1049426 | 13 * Inspired by https://gist.github.com/1049426 |
14 */ | 14 */ |
15 String.prototype.format = function() { | 15 String.prototype.format = function() { |
16 function format() { | 16 function format() { |
17 var str = this; | 17 var str = this; |
18 var len = arguments.length+1; | 18 var len = arguments.length+1; |
19 var safe = undefined; | 19 var safe = undefined; |
20 var arg = undefined; | 20 var arg = undefined; |
21 | 21 |
22 // For each {0} {1} {n...} replace with the argument in that position. If | 22 // For each {0} {1} {n...} replace with the argument in that position. If |
23 // the argument is an object or an array it will be stringified to JSON. | 23 // the argument is an object or an array it will be stringified to JSON. |
24 for (var i=0; i < len; arg = arguments[i++]) { | 24 for (var i=0; i < len; arg = arguments[i++]) { |
25 safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; | 25 safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; |
26 str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); | 26 str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); |
27 } | 27 } |
28 return str; | 28 return str; |
29 } | 29 } |
30 | 30 |
31 // Save a reference of what may already exist under the property native. | 31 // Save a reference of what may already exist under the property native. |
32 // Allows for doing something like: if("".format.native) { /* use native */ } | 32 // Allows for doing something like: if("".format.native) { /* use native */ } |
33 format.native = String.prototype.format; | 33 format.native = String.prototype.format; |
34 | 34 |
35 // Replace the prototype property | 35 // Replace the prototype property |
36 return format; | 36 return format; |
37 | 37 |
38 }(); | 38 }(); |
39 | 39 |
40 String.prototype.strip = function(char) { | 40 String.prototype.strip = function(char) { |
41 if(char === undefined){ | 41 if(char === undefined){ |
618 var hide_node = function(node){ | 618 var hide_node = function(node){ |
619 YUD.setStyle(node,'display','none'); | 619 YUD.setStyle(node,'display','none'); |
620 } | 620 } |
621 | 621 |
622 F.updateFilter = function() { | 622 F.updateFilter = function() { |
623 // Reset timeout | 623 // Reset timeout |
624 F.filterTimeout = null; | 624 F.filterTimeout = null; |
625 | 625 |
626 var obsolete = []; | 626 var obsolete = []; |
627 | 627 |
628 var req = q_filter_field.value.toLowerCase(); | 628 var req = q_filter_field.value.toLowerCase(); |
629 | 629 |
630 var l = nodes.length; | 630 var l = nodes.length; |
631 var i; | 631 var i; |
632 var showing = 0; | 632 var showing = 0; |
633 | 633 |
634 for (i=0;i<l;i++ ){ | 634 for (i=0;i<l;i++ ){ |
635 var n = nodes[i]; | 635 var n = nodes[i]; |
636 var target_element = display_element(n) | 636 var target_element = display_element(n) |
637 if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ | 637 if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ |
638 hide_node(target_element); | 638 hide_node(target_element); |
639 } | 639 } |
640 else{ | 640 else{ |
641 show_node(target_element); | 641 show_node(target_element); |
642 showing+=1; | 642 showing+=1; |
643 } | 643 } |
644 } | 644 } |
645 | 645 |
646 // if repo_count is set update the number | 646 // if repo_count is set update the number |
647 var cnt = YUD.get('repo_count'); | 647 var cnt = YUD.get('repo_count'); |
648 if(cnt){ | 648 if(cnt){ |
649 YUD.get('repo_count').innerHTML = showing; | 649 YUD.get('repo_count').innerHTML = showing; |
650 } | 650 } |
651 } | 651 } |
652 }; | 652 }; |
653 | 653 |
654 var tableTr = function(cls, body){ | 654 var tableTr = function(cls, body){ |
655 var _el = document.createElement('div'); | 655 var _el = document.createElement('div'); |
691 * Inject inline comment for on given TR this tr should be always an .line | 691 * Inject inline comment for on given TR this tr should be always an .line |
692 * tr containing the line. Code will detect comment, and always put the comment | 692 * tr containing the line. Code will detect comment, and always put the comment |
693 * block at the very bottom | 693 * block at the very bottom |
694 */ | 694 */ |
695 var injectInlineForm = function(tr){ | 695 var injectInlineForm = function(tr){ |
696 if(!YUD.hasClass(tr, 'line')){ | 696 if(!YUD.hasClass(tr, 'line')){ |
697 return | 697 return |
698 } | 698 } |
699 var submit_url = AJAX_COMMENT_URL; | 699 var submit_url = AJAX_COMMENT_URL; |
700 var _td = YUD.getElementsByClassName('code',null,tr)[0]; | 700 var _td = YUD.getElementsByClassName('code',null,tr)[0]; |
701 if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ | 701 if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ |
702 return | 702 return |
703 } | 703 } |
704 YUD.addClass(tr,'form-open'); | 704 YUD.addClass(tr,'form-open'); |
705 YUD.addClass(tr,'hl-comment'); | 705 YUD.addClass(tr,'hl-comment'); |
706 var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0]; | 706 var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0]; |
707 var f_path = YUD.getAttribute(node,'path'); | 707 var f_path = YUD.getAttribute(node,'path'); |
708 var lineno = getLineNo(tr); | 708 var lineno = getLineNo(tr); |
709 var form = createInlineForm(tr, f_path, lineno, submit_url); | 709 var form = createInlineForm(tr, f_path, lineno, submit_url); |
710 | 710 |
711 var parent = tr; | 711 var parent = tr; |
712 while (1){ | 712 while (1){ |
713 var n = parent.nextElementSibling; | 713 var n = parent.nextElementSibling; |
714 // next element are comments ! | 714 // next element are comments ! |
715 if(YUD.hasClass(n,'inline-comments')){ | 715 if(YUD.hasClass(n,'inline-comments')){ |
716 parent = n; | 716 parent = n; |
717 } | 717 } |
718 else{ | 718 else{ |
719 break; | 719 break; |
720 } | 720 } |
721 } | 721 } |
722 YUD.insertAfter(form,parent); | 722 YUD.insertAfter(form,parent); |
723 var f = YUD.get(form); | 723 var f = YUD.get(form); |
724 var overlay = YUD.getElementsByClassName('overlay',null,f)[0]; | 724 var overlay = YUD.getElementsByClassName('overlay',null,f)[0]; |
725 var _form = YUD.getElementsByClassName('inline-form',null,f)[0]; | 725 var _form = YUD.getElementsByClassName('inline-form',null,f)[0]; |
726 | 726 |
727 YUE.on(YUD.get(_form), 'submit',function(e){ | 727 YUE.on(YUD.get(_form), 'submit',function(e){ |
728 YUE.preventDefault(e); | 728 YUE.preventDefault(e); |
729 | 729 |
730 //ajax submit | 730 //ajax submit |
731 var text = YUD.get('text_'+lineno).value; | 731 var text = YUD.get('text_'+lineno).value; |
732 var postData = { | 732 var postData = { |
733 'text':text, | 733 'text':text, |
734 'f_path':f_path, | 734 'f_path':f_path, |
735 'line':lineno | 735 'line':lineno |
736 }; | 736 }; |
737 | 737 |
738 if(lineno === undefined){ | 738 if(lineno === undefined){ |
739 alert('missing line !'); | 739 alert('missing line !'); |
740 return | 740 return |
741 } | 741 } |
742 if(f_path === undefined){ | 742 if(f_path === undefined){ |
743 alert('missing file path !'); | 743 alert('missing file path !'); |
744 return | 744 return |
745 } | 745 } |
746 | 746 |
747 if(text == ""){ | 747 if(text == ""){ |
748 return | 748 return |
749 } | 749 } |
750 | 750 |
751 var success = function(o){ | 751 var success = function(o){ |
752 YUD.removeClass(tr, 'form-open'); | 752 YUD.removeClass(tr, 'form-open'); |
753 removeInlineForm(f); | 753 removeInlineForm(f); |
754 var json_data = JSON.parse(o.responseText); | 754 var json_data = JSON.parse(o.responseText); |
755 renderInlineComment(json_data); | 755 renderInlineComment(json_data); |
756 }; | 756 }; |
757 | 757 |
758 if (YUD.hasClass(overlay,'overlay')){ | 758 if (YUD.hasClass(overlay,'overlay')){ |
759 var w = _form.offsetWidth; | 759 var w = _form.offsetWidth; |
760 var h = _form.offsetHeight; | 760 var h = _form.offsetHeight; |
761 YUD.setStyle(overlay,'width',w+'px'); | 761 YUD.setStyle(overlay,'width',w+'px'); |
762 YUD.setStyle(overlay,'height',h+'px'); | 762 YUD.setStyle(overlay,'height',h+'px'); |
763 } | 763 } |
764 YUD.addClass(overlay, 'submitting'); | 764 YUD.addClass(overlay, 'submitting'); |
765 | 765 |
766 ajaxPOST(submit_url, postData, success); | 766 ajaxPOST(submit_url, postData, success); |
767 }); | 767 }); |
768 | 768 |
769 YUE.on('preview-btn_'+lineno, 'click', function(e){ | 769 YUE.on('preview-btn_'+lineno, 'click', function(e){ |
770 var _text = YUD.get('text_'+lineno).value; | 770 var _text = YUD.get('text_'+lineno).value; |
771 if(!_text){ | 771 if(!_text){ |
772 return | 772 return |
773 } | 773 } |
774 var post_data = {'text': _text}; | 774 var post_data = {'text': _text}; |
775 YUD.addClass('preview-box_'+lineno, 'unloaded'); | 775 YUD.addClass('preview-box_'+lineno, 'unloaded'); |
776 YUD.get('preview-box_'+lineno).innerHTML = _TM['Loading ...']; | 776 YUD.get('preview-box_'+lineno).innerHTML = _TM['Loading ...']; |
777 YUD.setStyle('edit-container_'+lineno, 'display', 'none'); | 777 YUD.setStyle('edit-container_'+lineno, 'display', 'none'); |
778 YUD.setStyle('preview-container_'+lineno, 'display', ''); | 778 YUD.setStyle('preview-container_'+lineno, 'display', ''); |
779 | 779 |
780 var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); | 780 var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); |
781 ajaxPOST(url,post_data,function(o){ | 781 ajaxPOST(url,post_data,function(o){ |
782 YUD.get('preview-box_'+lineno).innerHTML = o.responseText; | 782 YUD.get('preview-box_'+lineno).innerHTML = o.responseText; |
783 YUD.removeClass('preview-box_'+lineno, 'unloaded'); | 783 YUD.removeClass('preview-box_'+lineno, 'unloaded'); |
784 }) | 784 }) |
785 }) | 785 }) |
786 YUE.on('edit-btn_'+lineno, 'click', function(e){ | 786 YUE.on('edit-btn_'+lineno, 'click', function(e){ |
787 YUD.setStyle('edit-container_'+lineno, 'display', ''); | 787 YUD.setStyle('edit-container_'+lineno, 'display', ''); |
788 YUD.setStyle('preview-container_'+lineno, 'display', 'none'); | 788 YUD.setStyle('preview-container_'+lineno, 'display', 'none'); |
789 }) | 789 }) |
790 | 790 |
791 setTimeout(function(){ | 791 setTimeout(function(){ |
792 // callbacks | 792 // callbacks |
793 tooltip_activate(); | 793 tooltip_activate(); |
794 MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, | 794 MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, |
795 _USERS_AC_DATA, _GROUPS_AC_DATA); | 795 _USERS_AC_DATA, _GROUPS_AC_DATA); |
796 var _e = YUD.get('text_'+lineno); | 796 var _e = YUD.get('text_'+lineno); |
797 if(_e){ | 797 if(_e){ |
798 _e.focus(); | 798 _e.focus(); |
799 } | 799 } |
800 },10) | 800 },10) |
801 }; | 801 }; |
802 | 802 |
803 var deleteComment = function(comment_id){ | 803 var deleteComment = function(comment_id){ |
804 var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); | 804 var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); |
805 var postData = {'_method':'delete'}; | 805 var postData = {'_method':'delete'}; |
850 if(!target_tr){ | 850 if(!target_tr){ |
851 return | 851 return |
852 } | 852 } |
853 var last_node = target_tr; | 853 var last_node = target_tr; |
854 //scann | 854 //scann |
855 while (1){ | 855 while (1){ |
856 var n = last_node.nextElementSibling; | 856 var n = last_node.nextElementSibling; |
857 // next element are comments ! | 857 // next element are comments ! |
858 if(YUD.hasClass(n,'inline-comments')){ | 858 if(YUD.hasClass(n,'inline-comments')){ |
859 last_node = n; | 859 last_node = n; |
860 //also remove the comment button from previous | 860 //also remove the comment button from previous |
861 var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node); | 861 var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node); |
862 for(var i=0;i<comment_add_buttons.length;i++){ | 862 for(var i=0;i<comment_add_buttons.length;i++){ |
863 var b = comment_add_buttons[i]; | 863 var b = comment_add_buttons[i]; |
864 b.parentNode.removeChild(b); | 864 b.parentNode.removeChild(b); |
865 } | 865 } |
866 } | 866 } |
867 else{ | 867 else{ |
868 break; | 868 break; |
869 } | 869 } |
870 } | 870 } |
871 | 871 |
872 var add = createInlineAddButton(target_tr); | 872 var add = createInlineAddButton(target_tr); |
873 // get the comment div | 873 // get the comment div |
874 var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0]; | 874 var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0]; |
875 // attach add button | 875 // attach add button |
878 | 878 |
879 /** | 879 /** |
880 * Places the inline comment into the changeset block in proper line position | 880 * Places the inline comment into the changeset block in proper line position |
881 */ | 881 */ |
882 var placeInline = function(target_container,lineno,html){ | 882 var placeInline = function(target_container,lineno,html){ |
883 var lineid = "{0}_{1}".format(target_container,lineno); | 883 var lineid = "{0}_{1}".format(target_container,lineno); |
884 var target_line = YUD.get(lineid); | 884 var target_line = YUD.get(lineid); |
885 var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) | 885 var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) |
886 | 886 |
887 // check if there are comments already ! | 887 // check if there are comments already ! |
888 var parent = target_line.parentNode; | 888 var parent = target_line.parentNode; |
889 var root_parent = parent; | 889 var root_parent = parent; |
890 while (1){ | 890 while (1){ |
891 var n = parent.nextElementSibling; | 891 var n = parent.nextElementSibling; |
892 // next element are comments ! | 892 // next element are comments ! |
893 if(YUD.hasClass(n,'inline-comments')){ | 893 if(YUD.hasClass(n,'inline-comments')){ |
894 parent = n; | 894 parent = n; |
895 } | 895 } |
896 else{ | 896 else{ |
897 break; | 897 break; |
898 } | 898 } |
899 } | 899 } |
900 // put in the comment at the bottom | 900 // put in the comment at the bottom |
901 YUD.insertAfter(comment,parent); | 901 YUD.insertAfter(comment,parent); |
902 | 902 |
903 // scann nodes, and attach add button to last one | 903 // scann nodes, and attach add button to last one |
904 placeAddButton(root_parent); | 904 placeAddButton(root_parent); |
905 | 905 |
906 return target_line; | 906 return target_line; |
907 } | 907 } |
908 | 908 |
909 /** | 909 /** |
910 * make a single inline comment and place it inside | 910 * make a single inline comment and place it inside |
911 */ | 911 */ |
912 var renderInlineComment = function(json_data){ | 912 var renderInlineComment = function(json_data){ |
913 try{ | 913 try{ |
914 var html = json_data['rendered_text']; | 914 var html = json_data['rendered_text']; |
915 var lineno = json_data['line_no']; | 915 var lineno = json_data['line_no']; |
916 var target_id = json_data['target_id']; | 916 var target_id = json_data['target_id']; |
917 placeInline(target_id, lineno, html); | 917 placeInline(target_id, lineno, html); |
918 }catch(e){ | 918 }catch(e){ |
919 console.log(e); | 919 console.log(e); |
920 } | 920 } |
921 } | 921 } |
922 | 922 |
923 /** | 923 /** |
924 * Iterates over all the inlines, and places them inside proper blocks of data | 924 * Iterates over all the inlines, and places them inside proper blocks of data |
961 | 961 |
962 F.filterTimeout = null; | 962 F.filterTimeout = null; |
963 var nodes = null; | 963 var nodes = null; |
964 | 964 |
965 F.initFilter = function(){ | 965 F.initFilter = function(){ |
966 YUD.setStyle('node_filter_box_loading','display',''); | 966 YUD.setStyle('node_filter_box_loading','display',''); |
967 YUD.setStyle('search_activate_id','display','none'); | 967 YUD.setStyle('search_activate_id','display','none'); |
968 YUD.setStyle('add_node_id','display','none'); | 968 YUD.setStyle('add_node_id','display','none'); |
969 YUC.initHeader('X-PARTIAL-XHR',true); | 969 YUC.initHeader('X-PARTIAL-XHR',true); |
970 YUC.asyncRequest('GET', node_list_url, { | 970 YUC.asyncRequest('GET', node_list_url, { |
971 success:function(o){ | 971 success:function(o){ |
972 nodes = JSON.parse(o.responseText).nodes; | 972 nodes = JSON.parse(o.responseText).nodes; |
973 YUD.setStyle('node_filter_box_loading','display','none'); | 973 YUD.setStyle('node_filter_box_loading','display','none'); |
974 YUD.setStyle('node_filter_box','display',''); | 974 YUD.setStyle('node_filter_box','display',''); |
975 n_filter.focus(); | 975 n_filter.focus(); |
976 if(YUD.hasClass(n_filter,'init')){ | 976 if(YUD.hasClass(n_filter,'init')){ |
977 n_filter.value = ''; | 977 n_filter.value = ''; |
978 YUD.removeClass(n_filter,'init'); | 978 YUD.removeClass(n_filter,'init'); |
979 } | 979 } |
980 }, | 980 }, |
981 failure:function(o){ | 981 failure:function(o){ |
982 console.log('failed to load'); | 982 console.log('failed to load'); |
983 } | 983 } |
984 },null); | 984 },null); |
985 } | 985 } |
986 | 986 |
987 F.updateFilter = function(e) { | 987 F.updateFilter = function(e) { |
988 return function(){ | 988 return function(){ |
989 // Reset timeout | 989 // Reset timeout |
990 F.filterTimeout = null; | 990 F.filterTimeout = null; |
991 var query = e.target.value.toLowerCase(); | 991 var query = e.target.value.toLowerCase(); |
992 var match = []; | 992 var match = []; |
1031 } | 1031 } |
1032 } | 1032 } |
1033 }; | 1033 }; |
1034 | 1034 |
1035 YUE.on(YUD.get('filter_activate'),'click',function(){ | 1035 YUE.on(YUD.get('filter_activate'),'click',function(){ |
1036 F.initFilter(); | 1036 F.initFilter(); |
1037 }) | 1037 }) |
1038 YUE.on(n_filter,'click',function(){ | 1038 YUE.on(n_filter,'click',function(){ |
1039 if(YUD.hasClass(n_filter,'init')){ | 1039 if(YUD.hasClass(n_filter,'init')){ |
1040 n_filter.value = ''; | 1040 n_filter.value = ''; |
1041 YUD.removeClass(n_filter,'init'); | 1041 YUD.removeClass(n_filter,'init'); |
1042 } | 1042 } |
1043 }); | 1043 }); |
1044 YUE.on(n_filter,'keyup',function(e){ | 1044 YUE.on(n_filter,'keyup',function(e){ |
1045 clearTimeout(F.filterTimeout); | 1045 clearTimeout(F.filterTimeout); |
1046 F.filterTimeout = setTimeout(F.updateFilter(e),600); | 1046 F.filterTimeout = setTimeout(F.updateFilter(e),600); |
1047 }); | 1047 }); |
1048 }; | 1048 }; |
1049 | 1049 |
1050 | 1050 |
1051 var initCodeMirror = function(textAreadId,resetUrl){ | 1051 var initCodeMirror = function(textAreadId,resetUrl){ |
1052 var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ | 1052 var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ |
1053 mode: "null", | 1053 mode: "null", |
1054 lineNumbers:true, | 1054 lineNumbers:true, |
1055 indentUnit: 4 | 1055 indentUnit: 4 |
1056 }); | 1056 }); |
1057 YUE.on('reset','click',function(e){ | 1057 YUE.on('reset','click',function(e){ |
1058 window.location=resetUrl | 1058 window.location=resetUrl |
1059 }); | 1059 }); |
1060 | 1060 |
1061 YUE.on('file_enable','click',function(){ | 1061 YUE.on('file_enable','click',function(){ |
1062 YUD.setStyle('editor_container','display',''); | 1062 YUD.setStyle('editor_container','display',''); |
1063 YUD.setStyle('upload_file_container','display','none'); | 1063 YUD.setStyle('upload_file_container','display','none'); |
1064 YUD.setStyle('filename_container','display',''); | 1064 YUD.setStyle('filename_container','display',''); |
1065 }); | 1065 }); |
1066 | 1066 |
1067 YUE.on('upload_file_enable','click',function(){ | 1067 YUE.on('upload_file_enable','click',function(){ |
1068 YUD.setStyle('editor_container','display','none'); | 1068 YUD.setStyle('editor_container','display','none'); |
1069 YUD.setStyle('upload_file_container','display',''); | 1069 YUD.setStyle('upload_file_container','display',''); |
1070 YUD.setStyle('filename_container','display','none'); | 1070 YUD.setStyle('filename_container','display','none'); |
1071 }); | 1071 }); |
1072 | 1072 |
1073 return myCodeMirror | 1073 return myCodeMirror |
1074 }; | 1074 }; |
1075 | 1075 |
1076 var setCodeMirrorMode = function(codeMirrorInstance, mode) { | 1076 var setCodeMirrorMode = function(codeMirrorInstance, mode) { |
1077 codeMirrorInstance.setOption("mode", mode); | 1077 codeMirrorInstance.setOption("mode", mode); |
1078 CodeMirror.autoLoadMode(codeMirrorInstance, mode); | 1078 CodeMirror.autoLoadMode(codeMirrorInstance, mode); |
1079 } | 1079 } |
1080 | 1080 |
1081 | 1081 |
1082 var getIdentNode = function(n){ | 1082 var getIdentNode = function(n){ |
1083 //iterate thru nodes untill matched interesting node ! | 1083 //iterate thru nodes untill matched interesting node ! |
1085 if (typeof n == 'undefined'){ | 1085 if (typeof n == 'undefined'){ |
1086 return -1 | 1086 return -1 |
1087 } | 1087 } |
1088 | 1088 |
1089 if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ | 1089 if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ |
1090 return n | 1090 return n |
1091 } | 1091 } |
1092 else{ | 1092 else{ |
1093 return getIdentNode(n.parentNode); | 1093 return getIdentNode(n.parentNode); |
1094 } | 1094 } |
1095 }; | 1095 }; |
1096 | 1096 |
1097 var getSelectionLink = function(e) { | 1097 var getSelectionLink = function(e) { |
1098 //get selection from start/to nodes | 1098 //get selection from start/to nodes |
1099 if (typeof window.getSelection != "undefined") { | 1099 if (typeof window.getSelection != "undefined") { |
1100 s = window.getSelection(); | 1100 s = window.getSelection(); |
1101 | 1101 |
1102 from = getIdentNode(s.anchorNode); | 1102 from = getIdentNode(s.anchorNode); |
1204 for (; i < l; i++) { | 1204 for (; i < l; i++) { |
1205 contact = myUsers[i]; | 1205 contact = myUsers[i]; |
1206 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | 1206 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
1207 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | 1207 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
1208 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | 1208 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
1209 matches[matches.length] = contact; | 1209 matches[matches.length] = contact; |
1210 } | 1210 } |
1211 } | 1211 } |
1212 return matches; | 1212 return matches; |
1213 }; | 1213 }; |
1214 | 1214 |
1215 // Define a custom search function for the DataSource of userGroups | 1215 // Define a custom search function for the DataSource of userGroups |
1584 } | 1584 } |
1585 } | 1585 } |
1586 | 1586 |
1587 var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ | 1587 var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ |
1588 if (reviewers_ids === undefined){ | 1588 if (reviewers_ids === undefined){ |
1589 var reviewers_ids = []; | 1589 var reviewers_ids = []; |
1590 var ids = YUQ('#review_members input'); | 1590 var ids = YUQ('#review_members input'); |
1591 for(var i=0; i<ids.length;i++){ | 1591 for(var i=0; i<ids.length;i++){ |
1592 var id = ids[i].value | 1592 var id = ids[i].value |
1593 reviewers_ids.push(id); | 1593 reviewers_ids.push(id); |
1594 } | 1594 } |
1595 } | 1595 } |
1596 var url = pyroutes.url('pullrequest_update', {"repo_name":repo_name, | 1596 var url = pyroutes.url('pullrequest_update', {"repo_name":repo_name, |
1597 "pull_request_id": pull_request_id}); | 1597 "pull_request_id": pull_request_id}); |
1598 var postData = {'_method':'put', | 1598 var postData = {'_method':'put', |
1599 'reviewers_ids': reviewers_ids}; | 1599 'reviewers_ids': reviewers_ids}; |
1619 for (; i < l; i++) { | 1619 for (; i < l; i++) { |
1620 contact = myUsers[i]; | 1620 contact = myUsers[i]; |
1621 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | 1621 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
1622 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | 1622 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
1623 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | 1623 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
1624 matches[matches.length] = contact; | 1624 matches[matches.length] = contact; |
1625 } | 1625 } |
1626 } | 1626 } |
1627 return matches; | 1627 return matches; |
1628 }; | 1628 }; |
1629 | 1629 |
1630 // Define a custom search function for the DataSource of userGroups | 1630 // Define a custom search function for the DataSource of userGroups |
1776 * TABLE SORTING | 1776 * TABLE SORTING |
1777 */ | 1777 */ |
1778 | 1778 |
1779 // returns a node from given html; | 1779 // returns a node from given html; |
1780 var fromHTML = function(html){ | 1780 var fromHTML = function(html){ |
1781 var _html = document.createElement('element'); | 1781 var _html = document.createElement('element'); |
1782 _html.innerHTML = html; | 1782 _html.innerHTML = html; |
1783 return _html; | 1783 return _html; |
1784 } | 1784 } |
1785 | 1785 |
1786 var get_rev = function(node){ | 1786 var get_rev = function(node){ |
1787 var n = node.firstElementChild.firstElementChild; | 1787 var n = node.firstElementChild.firstElementChild; |
1788 | 1788 |
1799 var date_ = YUD.getAttribute(node.firstElementChild,'date'); | 1799 var date_ = YUD.getAttribute(node.firstElementChild,'date'); |
1800 return date_ | 1800 return date_ |
1801 } | 1801 } |
1802 | 1802 |
1803 var revisionSort = function(a, b, desc, field) { | 1803 var revisionSort = function(a, b, desc, field) { |
1804 var a_ = fromHTML(a.getData(field)); | 1804 var a_ = fromHTML(a.getData(field)); |
1805 var b_ = fromHTML(b.getData(field)); | 1805 var b_ = fromHTML(b.getData(field)); |
1806 | 1806 |
1807 // extract revisions from string nodes | 1807 // extract revisions from string nodes |
1808 a_ = get_rev(a_) | 1808 a_ = get_rev(a_) |
1809 b_ = get_rev(b_) | 1809 b_ = get_rev(b_) |
1810 | 1810 |
1811 var comp = YAHOO.util.Sort.compare; | 1811 var comp = YAHOO.util.Sort.compare; |
1812 var compState = comp(a_, b_, desc); | 1812 var compState = comp(a_, b_, desc); |
1813 return compState; | 1813 return compState; |
1814 }; | 1814 }; |
1815 | 1815 |
1816 var ageSort = function(a, b, desc, field) { | 1816 var ageSort = function(a, b, desc, field) { |
1817 var a_ = fromHTML(a.getData(field)); | 1817 var a_ = fromHTML(a.getData(field)); |
1818 var b_ = fromHTML(b.getData(field)); | 1818 var b_ = fromHTML(b.getData(field)); |
1859 | 1859 |
1860 var addPermAction = function(_html, users_list, groups_list){ | 1860 var addPermAction = function(_html, users_list, groups_list){ |
1861 var elmts = YUD.getElementsByClassName('last_new_member'); | 1861 var elmts = YUD.getElementsByClassName('last_new_member'); |
1862 var last_node = elmts[elmts.length-1]; | 1862 var last_node = elmts[elmts.length-1]; |
1863 if (last_node){ | 1863 if (last_node){ |
1864 var next_id = (YUD.getElementsByClassName('new_members')).length; | 1864 var next_id = (YUD.getElementsByClassName('new_members')).length; |
1865 _html = _html.format(next_id); | 1865 _html = _html.format(next_id); |
1866 last_node.innerHTML = _html; | 1866 last_node.innerHTML = _html; |
1867 YUD.setStyle(last_node, 'display', ''); | 1867 YUD.setStyle(last_node, 'display', ''); |
1868 YUD.removeClass(last_node, 'last_new_member'); | 1868 YUD.removeClass(last_node, 'last_new_member'); |
1869 MembersAutoComplete("perm_new_member_name_"+next_id, | 1869 MembersAutoComplete("perm_new_member_name_"+next_id, |
1870 "perm_container_"+next_id, users_list, groups_list); | 1870 "perm_container_"+next_id, users_list, groups_list); |
1871 //create new last NODE | 1871 //create new last NODE |
1872 var el = document.createElement('tr'); | 1872 var el = document.createElement('tr'); |
1873 el.id = 'add_perm_input'; | 1873 el.id = 'add_perm_input'; |
1874 YUD.addClass(el,'last_new_member'); | 1874 YUD.addClass(el,'last_new_member'); |
1875 YUD.addClass(el,'new_members'); | 1875 YUD.addClass(el,'new_members'); |
1876 YUD.insertAfter(el, last_node); | 1876 YUD.insertAfter(el, last_node); |
1877 } | 1877 } |
1878 } | 1878 } |
1879 | 1879 |
1880 function ajaxActionRevokePermission(url, obj_id, obj_type, field_id, extra_data) { | 1880 function ajaxActionRevokePermission(url, obj_id, obj_type, field_id, extra_data) { |
1881 var callback = { | 1881 var callback = { |