myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3614] trunk: added the ability to expand pivot f


From: noreply
Subject: [myexperiment-hackers] [3614] trunk: added the ability to expand pivot filters to show more filters
Date: Tue, 23 Jul 2013 12:38:00 +0000 (UTC)

Revision
3614
Author
dgc
Date
2013-07-23 12:37:59 +0000 (Tue, 23 Jul 2013)

Log Message

added the ability to expand pivot filters to show more filters

Modified Paths

Added Paths

Diff

Added: trunk/app/helpers/content_helper.rb (0 => 3614)


--- trunk/app/helpers/content_helper.rb	                        (rev 0)
+++ trunk/app/helpers/content_helper.rb	2013-07-23 12:37:59 UTC (rev 3614)
@@ -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: trunk/app/views/content/_index.rhtml (3613 => 3614)


--- trunk/app/views/content/_index.rhtml	2013-07-19 10:05:53 UTC (rev 3613)
+++ trunk/app/views/content/_index.rhtml	2013-07-23 12:37:59 UTC (rev 3614)
@@ -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: trunk/config/default_settings.yml (3613 => 3614)


--- trunk/config/default_settings.yml	2013-07-19 10:05:53 UTC (rev 3613)
+++ trunk/config/default_settings.yml	2013-07-23 12:37:59 UTC (rev 3614)
@@ -672,6 +672,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.
@@ -680,4 +690,4 @@
 #
 # shortcut_keywords:
 #   biovel: /groups/643
-#
\ No newline at end of file
+#

Modified: trunk/lib/conf.rb (3613 => 3614)


--- trunk/lib/conf.rb	2013-07-19 10:05:53 UTC (rev 3613)
+++ trunk/lib/conf.rb	2013-07-23 12:37:59 UTC (rev 3614)
@@ -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: trunk/lib/pivoting.rb (3613 => 3614)


--- trunk/lib/pivoting.rb	2013-07-19 10:05:53 UTC (rev 3613)
+++ trunk/lib/pivoting.rb	2013-07-23 12:37:59 UTC (rev 3614)
@@ -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: trunk/public/stylesheets/styles.css (3613 => 3614)


--- trunk/public/stylesheets/styles.css	2013-07-19 10:05:53 UTC (rev 3613)
+++ trunk/public/stylesheets/styles.css	2013-07-23 12:37:59 UTC (rev 3614)
@@ -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;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]