[Rt-commit] rt branch, 4.0/user-autocomplete-extensibility, created. rt-4.0.4-151-gf270c61

Thomas Sibley trs at bestpractical.com
Fri Dec 23 16:37:16 EST 2011


The branch, 4.0/user-autocomplete-extensibility has been created
        at  f270c61523c9050d08fead9af03e320706ecd99d (commit)

- Log -----------------------------------------------------------------
commit 315f007faed524e600c2c13fc4c13d8ebfa1e456
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Dec 23 16:21:10 2011 -0500

    User autocomplete: Add the class autocompletes-user for easier selecting later
    
    This is nice because it means you can select/iterate all user
    autocompleters using basic jQuery / CSS.
    
    For the bespoke implementations, I add the class from JS so that if JS
    doesn't run, the elements aren't tagged incorrectly.  That really only
    matters if you're selecting elements with CSS (since your custom JS
    won't be running either).

diff --git a/share/html/Admin/Elements/SelectNewGroupMembers b/share/html/Admin/Elements/SelectNewGroupMembers
index 27b6f70..453ecde 100755
--- a/share/html/Admin/Elements/SelectNewGroupMembers
+++ b/share/html/Admin/Elements/SelectNewGroupMembers
@@ -57,7 +57,7 @@ jQuery(function(){
             jQuery(event.target).val(ui.item.value);
             jQuery(event.target).closest("form").submit();
         }
-    });
+    }).addClass("autocompletes-user");
 });
 </script>
 % }
diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index 178fd1c..9ded2c4 100755
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -70,7 +70,7 @@ jQuery(function(){
             form.find('input[name=UserOp]').val('=');
             form.submit();
         }
-    });
+    }).addClass("autocompletes-user");
 });
 </script>
 </form>
diff --git a/share/html/NoAuth/js/userautocomplete.js b/share/html/NoAuth/js/userautocomplete.js
index 1608deb..28581b2 100644
--- a/share/html/NoAuth/js/userautocomplete.js
+++ b/share/html/NoAuth/js/userautocomplete.js
@@ -105,6 +105,8 @@ jQuery(function() {
         if (queryargs.length)
             options.source += "?" + queryargs.join("&");
 
-        jQuery(input).autocomplete(options);
+        jQuery(input)
+            .addClass('autocompletes-user')
+            .autocomplete(options);
     }
 });

commit f270c61523c9050d08fead9af03e320706ecd99d
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Dec 23 16:27:45 2011 -0500

    User autocomplete: Override the item render to conditionally use HTML from the server
    
    Combined with the recent ModifySuggestion callback for
    /Helpers/Autocomplete/Users, this lets customizers fully affect
    rendering of the autocomplete suggestions.

diff --git a/share/html/NoAuth/js/userautocomplete.js b/share/html/NoAuth/js/userautocomplete.js
index 28581b2..77ba271 100644
--- a/share/html/NoAuth/js/userautocomplete.js
+++ b/share/html/NoAuth/js/userautocomplete.js
@@ -107,6 +107,20 @@ jQuery(function() {
 
         jQuery(input)
             .addClass('autocompletes-user')
-            .autocomplete(options);
+            .autocomplete(options)
+            .data("autocomplete")
+            ._renderItem = function(ul, item) {
+                var rendered = jQuery("<a/>");
+
+                if (item.html == null)
+                    rendered.text( item.label );
+                else
+                    rendered.html( item.html );
+
+                return jQuery("<li/>")
+                    .data( "item.autocomplete", item )
+                    .append( rendered )
+                    .appendTo( ul );
+            };
     }
 });

-----------------------------------------------------------------------


More information about the Rt-commit mailing list