Diff
Copied: branches/component-api/app/helpers/content_helper.rb (from rev 3679, trunk/app/helpers/content_helper.rb) (0 => 3680)
--- branches/component-api/app/helpers/content_helper.rb (rev 0)
+++ branches/component-api/app/helpers/content_helper.rb 2013-09-06 08:08:45 UTC (rev 3680)
@@ -0,0 +1,26 @@
+# myExperiment: app/helpers/content_helper.rb
+#
+# Copyright (c) 2007-2013 The University of Manchester, the University of
+# Oxford, and the University of Southampton. See license.txt for details.
+
+module ContentHelper
+ def filter_sets(objects)
+ size = Conf.initial_filter_size
+ sets = []
+
+ objects.each_index do |i|
+
+ object = objects[i]
+ visible = (i < size) || object[:selected]
+
+ if sets.empty? || sets.last[1] != visible
+ sets << [[object], visible]
+ else
+ sets.last[0] << object
+ end
+ end
+
+ sets
+ end
+end
+
Modified: branches/component-api/app/views/content/_index.rhtml (3679 => 3680)
--- branches/component-api/app/views/content/_index.rhtml 2013-09-05 15:28:38 UTC (rev 3679)
+++ branches/component-api/app/views/content/_index.rhtml 2013-09-06 08:08:45 UTC (rev 3680)
@@ -21,6 +21,9 @@
<div class="filters">
<% @pivot[:filters].each do |filter| %>
<% query_name = "#{filter[:query_option]}_query" %>
+ <% fold_name_1 = "FOLD_#{filter["query_option"]}_1" %>
+ <% fold_name_2 = "FOLD_#{filter["query_option"]}_2" %>
+
<% if @pivot[:cancel_filter_query_url] %>
<div class="category"><%= filter["title"].capitalize -%> results</div>
<% else %>
@@ -29,17 +32,25 @@
<div id="<%= query_name -%>" style="display: <%= @pivot[:cancel_filter_query_url] ? "block" : "none" -%>">
</div>
<div class="filter">
- <div class="options">
- <% filter[:objects].each do |object| %>
- <div title='<%= h(object[:plain_label]) -%>'<%= object[:selected] ? ' class="selected"' : '' -%>>
- <input class='checkbox' type='checkbox' <% if object[:selected] %> checked='checked' <% end %> />
- <a href="" url_with_params(request.path, object[:label_uri]) -%>">
- <div class='count'><%= object[:count] -%></div>
- <div class='label'><span class='truncate'><%= h(object[:label]) -%></span></div>
- </a>
- </div>
- <% end %>
- </div>
+ <% filter_sets(filter[:objects]).each do |set, visible| %>
+ <div class="options <%= visible ? "" : "extra_options #{fold_name_2}" -%>">
+ <% set.each do |object| %>
+ <div title='<%= h(object[:plain_label]) -%>'<%= object[:selected] ? ' class="selected"' : '' -%>>
+ <input class='checkbox' type='checkbox' <% if object[:selected] %> checked='checked' <% end %> />
+ <a href="" url_with_params(request.path, object[:label_uri]) -%>">
+ <div class='count'><%= object[:count] -%></div>
+ <div class='label'><span class='truncate'><%= h(object[:label]) -%></span></div>
+ </a>
+ </div>
+ <% end %>
+ </div>
+ <% end %>
+
+ <% if (filter[:objects].length > Conf.initial_filter_size) %>
+ <a class="more" href="" id="<%= fold_name_1 -%>" style="display: none" fold_name_1 %>').style.display = 'none'; var els = document.getElementsByClassName('<%= fold_name_2 %>'); for (var i = 0; i < els.length; i++) { els[i].style.display = 'block'; els[i].style.maxHeight = '1000px'; }; return false;">More...</a>
+ <% end %>
+ <script>document.getElementById("<%= fold_name_1 -%>").style.display = "block";</script>
+ <script>var els = document.getElementsByClassName("<%= fold_name_2 %>"); for (var i = 0; i < els.length; i++) { els[i].style.maxHeight = "0px"; }</script>
</div>
<% end %>
</div>
Modified: branches/component-api/config/default_settings.yml (3679 => 3680)
--- branches/component-api/config/default_settings.yml 2013-09-05 15:28:38 UTC (rev 3679)
+++ branches/component-api/config/default_settings.yml 2013-09-06 08:08:45 UTC (rev 3680)
@@ -665,6 +665,16 @@
num_options: ["10", "20", "25", "50", "100"]
+# initial_filter_size - The number of entries shown for each pivot filter by
+# default.
+
+initial_filter_size: 10
+
+# expanded_filter_size - The number of entries shown for each pivot filter when
+# it is expanded.
+
+expanded_filter_size: 25
+
# Shortcut keywords
# These are special keywords that, when typed into the search box (when 'All' is selected) will instantly jump to a
# specified page instead of returning a list of search results.
@@ -673,4 +683,4 @@
#
# shortcut_keywords:
# biovel: /groups/643
-#
\ No newline at end of file
+#
Modified: branches/component-api/lib/conf.rb (3679 => 3680)
--- branches/component-api/lib/conf.rb 2013-09-05 15:28:38 UTC (rev 3679)
+++ branches/component-api/lib/conf.rb 2013-09-06 08:08:45 UTC (rev 3680)
@@ -210,6 +210,14 @@
self.fetch_entry('sesame_repository')
end
+ def self.initial_filter_size
+ self.fetch_entry('initial_filter_size')
+ end
+
+ def self.expanded_filter_size
+ self.fetch_entry('expanded_filter_size')
+ end
+
# This method is required to create an administrator in the test fixtures
def self.admins=(value)
Modified: branches/component-api/lib/pivoting.rb (3679 => 3680)
--- branches/component-api/lib/pivoting.rb 2013-09-05 15:28:38 UTC (rev 3679)
+++ branches/component-api/lib/pivoting.rb 2013-09-06 08:08:45 UTC (rev 3680)
@@ -261,7 +261,7 @@
current = find_filter(opts[:filters], filter["query_option"]) ? find_filter(opts[:filters], filter["query_option"])[:expr][:terms] : []
if opts[:ids].nil?
- limit = 10
+ limit = Conf.expanded_filter_size
else
conditions << "(#{filter_id_column} IN ('#{opts[:ids].map do |id| escape_sql(id) end.join("','")}'))"
limit = nil
Modified: branches/component-api/public/stylesheets/styles.css (3679 => 3680)
--- branches/component-api/public/stylesheets/styles.css 2013-09-05 15:28:38 UTC (rev 3679)
+++ branches/component-api/public/stylesheets/styles.css 2013-09-06 08:08:45 UTC (rev 3680)
@@ -2123,6 +2123,20 @@
background: #ffe0c0;
}
+.pivot .extra_options {
+ transition-property: max-height;
+ transition-duration: 2s;
+ -webkit-transition-property: max-height;
+ -webkit-transition-duration: 2s;
+ overflow: hidden;
+}
+
+.pivot .more {
+ padding-top: 4px;
+ padding-left: 4px;
+ font-size: 90%;
+}
+
.pivot .checkbox {
display: inline;
padding-top: 0;