##// END OF EJS Templates
Autocomplete fixes...
marcink -
r2369:c2f13150 beta
parent child Browse files
Show More
@@ -2821,10 +2821,10 b' table.code-browser .submodule-dir {'
2821 }
2821 }
2822
2822
2823 .mentions-container{
2823 .mentions-container{
2824 width: 100% !important;
2824 width: 90% !important;
2825 }
2825 }
2826 .mentions-container .yui-ac-content{
2826 .mentions-container .yui-ac-content{
2827 width: 90% !important;
2827 width: 100% !important;
2828 }
2828 }
2829
2829
2830 .ac {
2830 .ac {
@@ -44,6 +44,24 b' String.prototype.format = function() {'
44
44
45 }();
45 }();
46
46
47 String.prototype.strip = function(char) {
48 if(char === undefined){
49 char = '\\s';
50 }
51 return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), '');
52 }
53 String.prototype.lstrip = function(char) {
54 if(char === undefined){
55 char = '\\s';
56 }
57 return this.replace(new RegExp('^'+char+'+'),'');
58 }
59 String.prototype.rstrip = function(char) {
60 if(char === undefined){
61 char = '\\s';
62 }
63 return this.replace(new RegExp(''+char+'+$'),'');
64 }
47
65
48 /**
66 /**
49 * SmartColorGenerator
67 * SmartColorGenerator
@@ -447,7 +465,7 b' var injectInlineForm = function(tr){'
447
465
448 ajaxPOST(submit_url, postData, success);
466 ajaxPOST(submit_url, postData, success);
449 });
467 });
450
468 // callbacks
451 tooltip_activate();
469 tooltip_activate();
452 };
470 };
453
471
@@ -819,7 +837,7 b' var deleteNotification = function(url, n'
819
837
820 /** MEMBERS AUTOCOMPLETE WIDGET **/
838 /** MEMBERS AUTOCOMPLETE WIDGET **/
821
839
822 var MembersAutoComplete = function (users_list, groups_list, group_lbl, members_lbl) {
840 var MembersAutoComplete = function (users_list, groups_list) {
823 var myUsers = users_list;
841 var myUsers = users_list;
824 var myGroups = groups_list;
842 var myGroups = groups_list;
825
843
@@ -834,9 +852,11 b' var MembersAutoComplete = function (user'
834 // Match against each name of each contact
852 // Match against each name of each contact
835 for (; i < l; i++) {
853 for (; i < l; i++) {
836 contact = myUsers[i];
854 contact = myUsers[i];
837 if ((contact.fname.toLowerCase().indexOf(query) > -1) || (contact.lname.toLowerCase().indexOf(query) > -1) || (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) {
855 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
838 matches[matches.length] = contact;
856 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
839 }
857 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
858 matches[matches.length] = contact;
859 }
840 }
860 }
841 return matches;
861 return matches;
842 };
862 };
@@ -912,21 +932,22 b' var MembersAutoComplete = function (user'
912 var grname = oResultData.grname;
932 var grname = oResultData.grname;
913 var grmembers = oResultData.grmembers;
933 var grmembers = oResultData.grmembers;
914 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
934 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
915 var grprefix = "{0}: ".format(group_lbl);
935 var grprefix = "{0}: ".format(_TM['Group']);
916 var grsuffix = " (" + grmembers + " )";
936 var grsuffix = " (" + grmembers + " )";
917 var grsuffix = " ({0} {1})".format(grmembers, members_lbl);
937 var grsuffix = " ({0} {1})".format(grmembers, _TM['members']);
918
938
919 if (grnameMatchIndex > -1) {
939 if (grnameMatchIndex > -1) {
920 return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true);
940 return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true);
921 }
941 }
922 return _gravatar(grprefix + oResultData.grname + grsuffix, null,true);
942 return _gravatar(grprefix + oResultData.grname + grsuffix, null,true);
923 // Users
943 // Users
924 } else if (oResultData.fname != undefined) {
944 } else if (oResultData.nname != undefined) {
925 var fname = oResultData.fname,
945 var fname = oResultData.fname || "";
926 lname = oResultData.lname,
946 var lname = oResultData.lname || "";
927 nname = oResultData.nname || "",
947 var nname = oResultData.nname;
928 // Guard against null value
948
929 fnameMatchIndex = fname.toLowerCase().indexOf(query),
949 // Guard against null value
950 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
930 lnameMatchIndex = lname.toLowerCase().indexOf(query),
951 lnameMatchIndex = lname.toLowerCase().indexOf(query),
931 nnameMatchIndex = nname.toLowerCase().indexOf(query),
952 nnameMatchIndex = nname.toLowerCase().indexOf(query),
932 displayfname, displaylname, displaynname;
953 displayfname, displaylname, displaynname;
@@ -988,7 +1009,7 b' var MembersAutoComplete = function (user'
988 }
1009 }
989
1010
990
1011
991 var MentionsAutoComplete = function (divid, cont, users_list, groups_list, group_lbl, members_lbl) {
1012 var MentionsAutoComplete = function (divid, cont, users_list, groups_list) {
992 var myUsers = users_list;
1013 var myUsers = users_list;
993 var myGroups = groups_list;
1014 var myGroups = groups_list;
994
1015
@@ -1008,7 +1029,9 b' var MentionsAutoComplete = function (div'
1008 // Match against each name of each contact
1029 // Match against each name of each contact
1009 for (; i < l; i++) {
1030 for (; i < l; i++) {
1010 contact = myUsers[i];
1031 contact = myUsers[i];
1011 if ((contact.fname.toLowerCase().indexOf(query) > -1) || (contact.lname.toLowerCase().indexOf(query) > -1) || (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) {
1032 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1033 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1034 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1012 matches[matches.length] = contact;
1035 matches[matches.length] = contact;
1013 }
1036 }
1014 }
1037 }
@@ -1023,6 +1046,7 b' var MentionsAutoComplete = function (div'
1023
1046
1024 // DataScheme for owner
1047 // DataScheme for owner
1025 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1048 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1049
1026 ownerDS.responseSchema = {
1050 ownerDS.responseSchema = {
1027 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1051 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1028 };
1052 };
@@ -1056,12 +1080,13 b' var MentionsAutoComplete = function (div'
1056 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1080 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1057 return tmpl.format(em,res)
1081 return tmpl.format(em,res)
1058 }
1082 }
1059 if (oResultData.fname != undefined) {
1083 if (oResultData.nname != undefined) {
1060 var fname = oResultData.fname,
1084 var fname = oResultData.fname || "";
1061 lname = oResultData.lname,
1085 var lname = oResultData.lname || "";
1062 nname = oResultData.nname || "",
1086 var nname = oResultData.nname;
1063 // Guard against null value
1087
1064 fnameMatchIndex = fname.toLowerCase().indexOf(query),
1088 // Guard against null value
1089 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1065 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1090 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1066 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1091 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1067 displayfname, displaylname, displaynname;
1092 displayfname, displaylname, displaynname;
@@ -1138,7 +1163,7 b' var MentionsAutoComplete = function (div'
1138 chunks.push(org.substr(max_pos)) // postfix chunk
1163 chunks.push(org.substr(max_pos)) // postfix chunk
1139
1164
1140 // clean up msg2 for filtering and regex match
1165 // clean up msg2 for filtering and regex match
1141 var msg2 = msg2.replace(' ','').replace('\n','');
1166 var msg2 = msg2.lstrip(' ').lstrip('\n');
1142
1167
1143 if(re.test(msg2)){
1168 if(re.test(msg2)){
1144 var unam = re.exec(msg2)[1];
1169 var unam = re.exec(msg2)[1];
@@ -1170,8 +1195,6 b' var MentionsAutoComplete = function (div'
1170 }
1195 }
1171
1196
1172
1197
1173
1174
1175 /**
1198 /**
1176 * QUICK REPO MENU
1199 * QUICK REPO MENU
1177 */
1200 */
@@ -117,12 +117,7 b' YUE.onDOMReady(function () {'
117 YUD.setStyle('add_perm', 'opacity', '0.6');
117 YUD.setStyle('add_perm', 'opacity', '0.6');
118 YUD.setStyle('add_perm', 'cursor', 'default');
118 YUD.setStyle('add_perm', 'cursor', 'default');
119 });
119 });
120 MembersAutoComplete(
120 MembersAutoComplete(${c.users_array|n}, ${c.users_groups_array|n});
121 ${c.users_array|n},
122 ${c.users_groups_array|n},
123 "${_('Group')}",
124 "${_('members')}"
125 );
126 });
121 });
127
122
128 </script>
123 </script>
@@ -106,12 +106,7 b' YUE.onDOMReady(function () {'
106 YUD.setStyle('add_perm', 'opacity', '0.6');
106 YUD.setStyle('add_perm', 'opacity', '0.6');
107 YUD.setStyle('add_perm', 'cursor', 'default');
107 YUD.setStyle('add_perm', 'cursor', 'default');
108 });
108 });
109 MembersAutoComplete(
109 MembersAutoComplete(${c.users_array|n}, ${c.users_groups_array|n});
110 ${c.users_array|n},
111 ${c.users_groups_array|n},
112 "${_('Group')}",
113 "${_('members')}"
114 );
115 });
110 });
116
111
117 </script>
112 </script>
@@ -36,6 +36,18 b''
36
36
37 ## JAVASCRIPT ##
37 ## JAVASCRIPT ##
38 <%def name="js()">
38 <%def name="js()">
39 <script type="text/javascript">
40 //JS translations map
41 var TRANSLATION_MAP = {
42 'add another comment':'${_("add another comment")}',
43 'Stop following this repository':"${_('Stop following this repository')}",
44 'Start following this repository':"${_('Start following this repository')}",
45 'Group':"${_('Group')}",
46 'members':"${_('members')}"
47
48 };
49 var _TM = TRANSLATION_MAP;
50 </script>
39 <script type="text/javascript" src="${h.url('/js/yui.2.9.js')}"></script>
51 <script type="text/javascript" src="${h.url('/js/yui.2.9.js')}"></script>
40 <!--[if lt IE 9]>
52 <!--[if lt IE 9]>
41 <script language="javascript" type="text/javascript" src="${h.url('/js/excanvas.min.js')}"></script>
53 <script language="javascript" type="text/javascript" src="${h.url('/js/excanvas.min.js')}"></script>
@@ -48,20 +60,13 b''
48 <script type="text/javascript">
60 <script type="text/javascript">
49 var follow_base_url = "${h.url('toggle_following')}";
61 var follow_base_url = "${h.url('toggle_following')}";
50
62
51 //JS translations map
52 var TRANSLATION_MAP = {
53 'add another comment':'${_("add another comment")}',
54 'Stop following this repository':"${_('Stop following this repository')}",
55 'Start following this repository':"${_('Start following this repository')}",
56 };
57
58 var onSuccessFollow = function(target){
63 var onSuccessFollow = function(target){
59 var f = YUD.get(target.id);
64 var f = YUD.get(target.id);
60 var f_cnt = YUD.get('current_followers_count');
65 var f_cnt = YUD.get('current_followers_count');
61
66
62 if(f.getAttribute('class')=='follow'){
67 if(f.getAttribute('class')=='follow'){
63 f.setAttribute('class','following');
68 f.setAttribute('class','following');
64 f.setAttribute('title',TRANSLATION_MAP['Stop following this repository']);
69 f.setAttribute('title',_TM['Stop following this repository']);
65
70
66 if(f_cnt){
71 if(f_cnt){
67 var cnt = Number(f_cnt.innerHTML)+1;
72 var cnt = Number(f_cnt.innerHTML)+1;
@@ -70,7 +75,7 b''
70 }
75 }
71 else{
76 else{
72 f.setAttribute('class','follow');
77 f.setAttribute('class','follow');
73 f.setAttribute('title',TRANSLATION_MAP['Start following this repository']);
78 f.setAttribute('title',_TM['Start following this repository']);
74 if(f_cnt){
79 if(f_cnt){
75 var cnt = Number(f_cnt.innerHTML)+1;
80 var cnt = Number(f_cnt.innerHTML)+1;
76 f_cnt.innerHTML = cnt;
81 f_cnt.innerHTML = cnt;
@@ -116,7 +116,10 b''
116 </div>
116 </div>
117
117
118 </div>
118 </div>
119
119 <script>
120 var _USERS_AC_DATA = ${c.users_array|n};
121 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
122 </script>
120 ## diff block
123 ## diff block
121 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
124 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
122 ${diff_block.diff_block(c.changes)}
125 ${diff_block.diff_block(c.changes)}
@@ -1,2 +1,4 b''
1 ## this is a dummy html file for partial rendering on server and sending
2 ## generated output via ajax after comment submit
1 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
3 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
2 ${comment.comment_block(c.co)}
4 ${comment.comment_block(c.co)}
@@ -30,7 +30,7 b''
30
30
31 <%def name="comment_inline_form(changeset)">
31 <%def name="comment_inline_form(changeset)">
32 <div id='comment-inline-form-template' style="display:none">
32 <div id='comment-inline-form-template' style="display:none">
33 <div class="comment-inline-form">
33 <div class="comment-inline-form ac">
34 %if c.rhodecode_user.username != 'default':
34 %if c.rhodecode_user.username != 'default':
35 <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div>
35 <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div>
36 ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=changeset.raw_id),class_='inline-form')}
36 ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=changeset.raw_id),class_='inline-form')}
@@ -41,7 +41,7 b''
41 _('Use @username inside this text to send notification to this RhodeCode user')))|n}
41 _('Use @username inside this text to send notification to this RhodeCode user')))|n}
42 </div>
42 </div>
43 <div class="mentions-container" id="mentions_container_{1}"></div>
43 <div class="mentions-container" id="mentions_container_{1}"></div>
44 <textarea id="text_{1}" name="text" class="yui-ac-input"></textarea>
44 <textarea id="text_{1}" name="text" class="yui-ac-input"></textarea>
45 </div>
45 </div>
46 <div class="comment-button">
46 <div class="comment-button">
47 <input type="hidden" name="f_path" value="{0}">
47 <input type="hidden" name="f_path" value="{0}">
@@ -115,15 +115,7 b''
115 </div>
115 </div>
116 <script>
116 <script>
117 YUE.onDOMReady(function () {
117 YUE.onDOMReady(function () {
118
118 MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
119 MentionsAutoComplete(
120 'text',
121 'mentions_container',
122 ${c.users_array|n},
123 ${c.users_groups_array|n},
124 "${_('Group')}",
125 "${_('members')}"
126 );
127 });
119 });
128 </script>
120 </script>
129 </%def>
121 </%def>
General Comments 0
You need to be logged in to leave comments. Login now