changeset 5231:96ed562709f9

autocomplete: remove dead code The three blocks of autocomplete code are clearly copy/pasted from one another, with dead code remaining due to group-autocomplete not being relevant for some cases.
author Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
date Wed, 24 Jun 2015 21:32:26 +0200
parents 514d89bbb3fa
children 0c82cb41d266
files kallithea/public/js/base.js kallithea/templates/pullrequests/pullrequest.html kallithea/templates/pullrequests/pullrequest_show.html
diffstat 3 files changed, 6 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Tue Jul 14 11:50:04 2015 +0200
+++ b/kallithea/public/js/base.js	Wed Jun 24 21:32:26 2015 +0200
@@ -731,7 +731,7 @@
         // callbacks
         tooltip_activate();
         MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno,
-                             _USERS_AC_DATA, _GROUPS_AC_DATA);
+                             _USERS_AC_DATA);
         $('#text_'+lineno).focus();
     },10)
 };
@@ -1289,9 +1289,8 @@
     };
 }
 
-var MentionsAutoComplete = function (divid, cont, users_list, groups_list) {
+var MentionsAutoComplete = function (divid, cont, users_list) {
     var myUsers = users_list;
-    var myGroups = groups_list;
 
     // Define a custom search function for the DataSource of users
     var matchUsers = function (sQuery) {
@@ -1318,11 +1317,6 @@
             return matches
         };
 
-    //match all
-    var matchAll = function (sQuery) {
-            return matchUsers(sQuery);
-        };
-
     // DataScheme for owner
     var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
 
@@ -1515,10 +1509,9 @@
     $li.find('.reviewer_member_remove').replaceWith('&nbsp;(remove not saved)');
 }
 
-/* activate auto completion of users and groups ... but only used for users as PR reviewers */
-var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) {
+/* activate auto completion of users as PR reviewers */
+var PullRequestAutoComplete = function (divid, cont, users_list) {
     var myUsers = users_list;
-    var myGroups = groups_list;
 
     // Define a custom search function for the DataSource of users
     var matchUsers = function (sQuery) {
@@ -1540,29 +1533,6 @@
             return matches;
         };
 
-    // Define a custom search function for the DataSource of userGroups
-    var matchGroups = function (sQuery) {
-            // Case insensitive matching
-            var query = sQuery.toLowerCase();
-            var i = 0;
-            var l = myGroups.length;
-            var matches = [];
-
-            // Match against each name of each contact
-            for (; i < l; i++) {
-                matched_group = myGroups[i];
-                if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
-                    matches[matches.length] = matched_group;
-                }
-            }
-            return matches;
-        };
-
-    //match all
-    var matchAll = function (sQuery) {
-            return matchUsers(sQuery);
-        };
-
     // DataScheme for owner
     var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
 
--- a/kallithea/templates/pullrequests/pullrequest.html	Tue Jul 14 11:50:04 2015 +0200
+++ b/kallithea/templates/pullrequests/pullrequest.html	Wed Jun 24 21:32:26 2015 +0200
@@ -130,7 +130,7 @@
 <script type="text/javascript">
   var _USERS_AC_DATA = ${c.users_array|n};
   var _GROUPS_AC_DATA = ${c.user_groups_array|n};
-  PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
+  PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA);
 
   pyroutes.register('pullrequest_repo_info', "${url('pullrequest_repo_info',repo_name='%(repo_name)s')}", ['repo_name']);
 
--- a/kallithea/templates/pullrequests/pullrequest_show.html	Tue Jul 14 11:50:04 2015 +0200
+++ b/kallithea/templates/pullrequests/pullrequest_show.html	Wed Jun 24 21:32:26 2015 +0200
@@ -369,7 +369,7 @@
 
     <script type="text/javascript">
       $(document).ready(function(){
-          PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
+          PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA);
 
           $('.add-bubble').click(function(e){
               var tr = e.currentTarget;