-<p>
-<ul class="horizontal widget_categs" id="widget-filters">
- <li><%= message('filter_verb') -%>:</li>
- <li class="<%= 'selected' if category.blank? -%>">
- <a href="#" onClick="return filterWidgets('')" id="widget-filter-none"><%= message('none') -%></a>
- </li>
- <% @widget_categories.each do |c| %>
- <li class="<%= 'selected' if category==c -%>">
- <a href="#" onClick="return filterWidgets('<%= escape_javascript(c) -%>')" id="widget-filter-<%= u(c) -%>"><%= h(c) -%></a>
+<div style="line-height: 20px; vertical-align: middle; padding: 0px 3px; margin-right: 10px">
+ <ul class="horizontal widget_categs" id="widget-filters">
+ <li>Filter by category:</li>
+ <li class="<%= 'selected' if category.blank? -%>">
+ <a href="#" onClick="return filterWidgets('')" id="widget-filter-none"><%= message('none') -%></a>
</li>
- <% end %>
-</ul>
-<%= image_tag 'loading.gif', :style => 'vertical-align: top;display: none', :id => 'filter-widgets-loading' -%>
-</p>
+ <% @widget_categories.each do |c| %>
+ <li class="<%= 'selected' if category==c -%>">
+ <a href="#" onClick="return filterWidgets('<%= escape_javascript(c) -%>')" id="widget-filter-<%= u(c) -%>"><%= h(c) -%></a>
+ </li>
+ <% end %>
+ </ul>
+</div>
+<div style="float: left; padding: 0px 3px">
+ Filter by content:
+ <input id="filter-widget-box" name="filter-widget-box" size="20" onKeyUp="findWidgetsByContent(this.value);"/>
+</div>
+<div style="float: left; padding: 0px 3px;">
+ <%= image_tag 'loading.gif', :style => 'vertical-align: top; display: none', :id => 'filter-widgets-loading' -%>
+</div>
+<div style="clear: both"></div>
+
+<% @widget_definitions.each do |definition| %>
+ <%= render :partial => 'widget_definition', :locals => {:definition => definition, :dashboard => @dashboard, :resource => @resource, :category => category} %>
+<% end %>
-<table width="100%">
- <% @widget_definitions.each_slice(4) do |row_definitions| %>
- <tr>
- <% row_definitions.each do |definition| %>
- <%= render :partial => 'widget_definition', :locals => {:definition => definition, :dashboard => @dashboard, :resource => @resource, :category => category} %>
- <% end %>
- </tr>
- <% end %>
-</table>
$('filter-widgets-loading').show();
return false;
}
+
+ var widgetContents = [
+ <%
+ number_of_widgets = @widget_definitions.size()
+ @widget_definitions.each_with_index do |definition, index|
+ widget_id = "def_#{definition.id.tr('_', '')}"
+ widget_title = message("widget.#{definition.id}.name", :default => definition.title).downcase
+ widget_description = message("widget.#{definition.id}.description", :default => definition.description).downcase
+ %>
+ { id:"<%= widget_id -%>", c:"<%= widget_title.gsub(/\r\n?/, " ") -%> <%= widget_description.gsub(/\r\n?/, " ") -%>" } <%= "," unless index==number_of_widgets-1 -%>
+ <% end %>
+ ]
+
+ function findWidgetsByContent(text) {
+ var userInput = text.toLowerCase();
+ widgetContents.each(function (widget) {
+ var element = $(widget.id);
+ if (element != null) {
+ if (widget.c.indexOf(userInput) != -1) {
+ element.show();
+ } else {
+ element.hide();
+ }
+ }
+ });
+ return false;
+ }
//-->
+
+ $('filter-widget-box').focus();
</script>