[Bps-public-commit] RT-Extension-rt_cpan_org branch, rt4, updated. dec3fe01aee0be1b3797e39b096e7c7c9acc3fd2

Thomas Sibley trs at bestpractical.com
Fri Mar 1 20:01:28 EST 2013


The branch, rt4 has been updated
       via  dec3fe01aee0be1b3797e39b096e7c7c9acc3fd2 (commit)
      from  ecebe3b3dd4a0cb6a626327526459217a470f5e3 (commit)

Summary of changes:
 html/Elements/SelectQueue     | 15 +--------------
 html/NoAuth/js/rt.cpan.org.js | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit dec3fe01aee0be1b3797e39b096e7c7c9acc3fd2
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Mar 1 17:00:32 2013 -0800

    Attach queue autocompleter to any input with a data-autocomplete=Queues attribute
    
    This lets other parts of the UI indicate more inputs which should be
    autocompleted for CPAN distributions.

diff --git a/html/Elements/SelectQueue b/html/Elements/SelectQueue
index 8ae687f..b76aa99 100644
--- a/html/Elements/SelectQueue
+++ b/html/Elements/SelectQueue
@@ -59,17 +59,4 @@ $DefaultQueue->Load( $Default );
 
 undef $CheckQueueRight if $ShowAllQueues;
 </%init>
-<input name="<% $Name %>" size="25" value="<% $DefaultQueue->id ? $DefaultQueue->Name : "" %>" class="<% $Class %>" />
-<script type="text/javascript">
-    jQuery("input[name="+<% $Name |n,j %>+"]").autocomplete({
-        source: <% RT->Config->Get('WebPath') |n,j%>
-                + "/Helpers/Autocomplete/Queues?max=20&right="
-                + <% $CheckQueueRight ? $CheckQueueRight : "" |n,u,j %>,
-
-        // Auto-submit once a user is chosen
-        select: function( event, ui ) {
-            jQuery(event.target).val(ui.item.value);
-            jQuery(event.target).closest("form").submit();
-        }
-    });
-</script>
+<input name="<% $Name %>" size="25" value="<% $DefaultQueue->id ? $DefaultQueue->Name : "" %>" class="<% $Class %>" data-autocomplete="Queues" data-autocomplete-autosubmit=1 data-autocomplete-params="right=<% $CheckQueueRight || '' |u %>" />
diff --git a/html/NoAuth/js/rt.cpan.org.js b/html/NoAuth/js/rt.cpan.org.js
index 0012d92..c54c9fc 100644
--- a/html/NoAuth/js/rt.cpan.org.js
+++ b/html/NoAuth/js/rt.cpan.org.js
@@ -10,4 +10,27 @@ jQuery(function(){
         parent.removeChild(this);
         parent.innerHTML = parent.innerHTML.replace(/\[\]/,"");
     });
+
+    jQuery("input[data-autocomplete=Queues]").each(function() {
+        var input = jQuery(this);
+        var opts  = {
+            source: <% RT->Config->Get('WebPath') |n,j%>
+                    + "/Helpers/Autocomplete/Queues?max=20"
+        };
+
+        if (input.attr("data-autocomplete-params") != null)
+            opts.source = opts.source + "&" + input.attr("data-autocomplete-params");
+
+        // Auto-submit once a queue is chosen
+        if (input.attr("data-autocomplete-autosubmit")) {
+            opts.select = function( event, ui ) {
+                jQuery(event.target).val(ui.item.value);
+                jQuery(event.target).closest("form").submit();
+            };
+        }
+
+        input.autocomplete(opts);
+    });
+
+    // XXX TODO: Support users as well
 });

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



More information about the Bps-public-commit mailing list