Author: rgardler
Date: Tue Mar 27 22:54:31 2012
New Revision: 1306039

URL: http://svn.apache.org/viewvc?rev=1306039&view=rev
Log:
Add a filter to the list of widgets - makes for easier testing

Modified:
    incubator/wookie/trunk/WebContent/demo/index.htm
    incubator/wookie/trunk/WebContent/demo/wookie.js

Modified: incubator/wookie/trunk/WebContent/demo/index.htm
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/WebContent/demo/index.htm?rev=1306039&r1=1306038&r2=1306039&view=diff
==============================================================================
--- incubator/wookie/trunk/WebContent/demo/index.htm (original)
+++ incubator/wookie/trunk/WebContent/demo/index.htm Tue Mar 27 22:54:31 2012
@@ -52,6 +52,10 @@
         
         <!-- Scrolling list of widgets -->
         <div id="navigation">
+         <h1 id="widget_header">List of widgets</h1>
+
+         <ul id="widget_list">
+         </ul>
         </div>
           
         <div id="content">
@@ -98,4 +102,4 @@
         </div>
         
        </body>
-</html>
+</html> 

Modified: incubator/wookie/trunk/WebContent/demo/wookie.js
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/WebContent/demo/wookie.js?rev=1306039&r1=1306038&r2=1306039&view=diff
==============================================================================
--- incubator/wookie/trunk/WebContent/demo/wookie.js (original)
+++ incubator/wookie/trunk/WebContent/demo/wookie.js Tue Mar 27 22:54:31 2012
@@ -19,22 +19,44 @@
  
  $(document).ready(getWidgets);
 
+jQuery.expr[':'].Contains = function(a,i,m){
+    return (a.textContent || a.innerText || 
"").toUpperCase().indexOf(m[3].toUpperCase())>=0;
+};
+
 //
 // Get the current widgets installed and
 // show in the browse list
 //
 function getWidgets(){
-    Wookie.getWidgets(updateWidgets);
+  var form = $("<form>").attr({"class":"filterform","action":"#"}),
+      input = $("<input>").attr({"class":"filterinput","type":"text"});
+
+  $(form).append(input);
+  $('#widget_header').append(form);
+
+  $(input).change( function () {
+    var filter = $(this).val();
+    if (filter) {
+      $('#widget_list').find("li:not(:Contains(" + filter + "))").slideUp();
+      $('#widget_list').find("li:Contains(" + filter + ")").slideDown();
+    } else {
+      $('#widget_list').find("li").slideDown();
+    }
+  }).keyup( function () {
+    $(this).change();
+  });
+
+  Wookie.getWidgets(updateWidgets);
 }
 
 function updateWidgets(widgets){
     for (var i=0;i<widgets.length;i++){
-        var widgetEntry = $("<div 
id=\""+widgets[i].id+"\"class=\"widget\"><p><img 
src=\""+widgets[i].icon+"\">"+widgets[i].name+"</p></div>");
+        var widgetEntry = $("<li id=\""+widgets[i].id+"\"class=\"widget\"><img 
src=\""+widgets[i].icon+"\">"+widgets[i].name+"</li>");
         var id = widgets[i].id;
         $(widgetEntry).click(function(){
             showWidget($(this).attr("id"));
         });
-        $("#navigation").append(widgetEntry);
+        $("#widget_list").append(widgetEntry);
     }
 }
 


Reply via email to