myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2461] branches/discovery: initial discovery piec


From: noreply
Subject: [myexperiment-hackers] [2461] branches/discovery: initial discovery piece
Date: Tue, 6 Jul 2010 10:40:51 -0400 (EDT)

Revision
2461
Author
dgc
Date
2010-07-06 10:40:50 -0400 (Tue, 06 Jul 2010)

Log Message

initial discovery piece

Modified Paths

Added Paths

Diff

Modified: branches/discovery/app/controllers/application.rb (2460 => 2461)


--- branches/discovery/app/controllers/application.rb	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/controllers/application.rb	2010-07-06 14:40:50 UTC (rev 2461)
@@ -369,4 +369,299 @@
 
     nil
   end 
+
+  # Pivot code
+  
+  def pivot_options
+    {
+      :order => 
+      [
+        {
+          :option => 'rank',
+          :label  => 'Rank',
+          :order  => 'rank DESC'
+        },
+        
+        {
+          :option => 'title',
+          :label  => 'Title',
+          :order  => 'label, rank DESC'
+        },
+
+        {
+          :option => 'latest',
+          :label  => 'Latest',
+          :order  => 'created_at DESC, rank DESC'
+        },
+
+        {
+          :option => 'last_updated',
+          :label  => 'Last updated',
+          :order  => 'updated_at DESC, rank DESC'
+        },
+
+        {
+          :option => 'rating',
+          :label  => 'Community rating',
+          :order  => 'rating DESC, rank DESC'
+        },
+
+        {
+          :option => 'viewings',
+          :label  => 'Most viewed',
+          :order  => 'site_viewings_count DESC, rank DESC'
+        },
+
+        {
+          :option => 'downloads',
+          :label  => 'Most downloaded',
+          :order  => 'site_downloads_count DESC, rank DESC'
+        },
+
+        {
+          :option => 'type',
+          :label  => 'Type',
+          :joins  => [ :content_types ],
+          :order  => 'content_types.title, rank DESC'
+        },
+
+        {
+          :option => 'licence',
+          :label  => 'Licence',
+          :joins  => [ :licences ],
+          :order  => 'licenses.title, rank DESC'
+        }
+      ],
+
+      :filters =>
+      [
+        {
+          :option    => "type",
+          :column    => "contributions.contributable_type",
+          :title     => 'Category',
+          :select    => 'contributions.contributable_type, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
+          :group     => 'contributions.contributable_type',
+          :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC',
+          :label     => 'visible_name(x.contributable_type)',
+          :key       => 'type',
+          :value     => 'x.contributable_type'
+        },
+
+        {
+          :option    => "content_type",
+          :column    => "content_types.title",
+          :joins     => [ :content_types ],
+          :title     => 'Type',
+          :select    => 'content_types.title, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
+          :condition => 'contributions.content_type_id IS NOT NULL',
+          :group     => 'content_types.title',
+          :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC LIMIT 10',
+          :label     => 'x.title',
+          :key       => 'content_type',
+          :value     => 'x.title'
+        },
+
+        {
+          :option    => "tag",
+          :column    => "tags.name",
+          :joins     => [ :taggings, :tags ],
+          :title     => 'Tag',
+          :select    => 'tags.name, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
+          :group     => 'tags.id',
+          :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC, tags.name LIMIT 10',
+          :label     => 'x.name',
+          :key       => 'tag',
+          :value     => 'x.name'
+        },
+
+        {
+          :option    => "member",
+          :column    => "users.name",
+          :joins     => [ :users ],
+          :title     => 'User',
+          :select    => 'users.name, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
+          :group     => 'users.name',
+          :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC LIMIT 10',
+          :label     => 'x.name',
+          :key       => 'member',
+          :value     => 'x.name'
+        },
+
+        {
+          :option    => "license",
+          :column    => "licenses.unique_name",
+          :joins     => [ :licences ],
+          :title     => 'Licence',
+          :select    => 'licenses.unique_name, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
+          :condition => 'contributions.license_id IS NOT NULL',
+          :group     => 'licenses.unique_name',
+          :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC LIMIT 10',
+          :label     => 'x.unique_name',
+          :key       => 'license',
+          :value     => 'x.unique_name'
+        },
+
+        {
+          :option    => "network",
+          :column    => "networks.title",
+          :joins     => [ :networks ],
+          :title     => "Group",
+          :select    => 'networks.title, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
+          :group     => 'networks.id',
+          :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC LIMIT 10',
+          :label     => 'x.title',
+          :key       => 'network',
+          :value     => 'x.title'
+        },
+
+        {
+          :option    => "attribution",
+          :column    => "attribution_targets.label",
+          :joins     => [ :attributions, :attribution_targets ],
+          :title     => "Attribution",
+          :select    => 'attribution_targets.label, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
+          :group     => 'attribution_targets.contributable_type, attribution_targets.contributable_id',
+          :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC LIMIT 10',
+          :label     => 'x.label',
+          :key       => 'attribution',
+          :value     => 'x.label'
+        },
+      ],
+
+      :joins =>
+      {
+        :content_types => "LEFT OUTER JOIN content_types ON contributions.content_type_id = content_types.id",
+        :licences      => "LEFT OUTER JOIN licenses ON contributions.license_id = licenses.id",
+        :users         => "INNER JOIN users ON contributions.contributor_type = 'User' AND contributions.contributor_id = users.id",
+        :taggings      => "LEFT OUTER JOIN taggings ON contributions.contributable_type = taggings.taggable_type AND contributions.contributable_id = taggings.taggable_id",
+        :tags          => "INNER JOIN tags ON taggings.tag_id = tags.id",
+        :networks      => "INNER JOIN networks ON permissions.contributor_type = 'Network' AND permissions.contributor_id = networks.id",
+        :attributions  => "INNER JOIN attributions ON attributor_type = contributions.contributable_type AND attributor_id = contributions.contributable_id",
+        :attribution_targets => "INNER JOIN contributions AS attribution_targets ON attributions.attributable_type = attribution_targets.contributable_type AND attributions.attributable_id = attribution_targets.contributable_id",
+        :credits       => "INNER JOIN creditations ON creditations.creditable_type = contributions.contributable_type AND creditations.creditable_id = contributions.contributable_id"
+      }
+    }
+  end
+
+  def contributions_list(klass = nil, params = nil, user = nil)
+
+    def escape_sql(str)
+      str.gsub(/\\/, '\&\&').gsub(/'/, "''")
+    end
+
+    def comparison(lhs, rhs)
+
+      bits = rhs.split(",")
+
+      if bits.length == 1
+        "#{lhs} = '#{escape_sql(rhs)}'"
+      else
+        "#{lhs} IN ('#{bits.map do |bit| escape_sql(bit) end.join("', '")}')"
+      end
+    end
+
+    # determine joins, conditions and order for the main results
+
+    joins      = []
+    conditions = []
+
+    pivot_options[:filters].each do |filter|
+      if columns = params[filter[:option]]
+        conditions << comparison(filter[:column], columns)
+        joins += filter[:joins] if filter[:joins]
+      end
+    end
+
+    order_options = pivot_options[:order].find do |x|
+      x[:option] == params[:order]
+    end
+
+    order_options ||= pivot_options[:order].first
+
+    joins += order_options[:joins] if order_options[:joins]
+
+    # perform the results query
+
+    results = Authorization.authorised_index(klass,
+        :all,
+        :authorised_user => user,
+        :include_permissions => true,
+        :contribution_records => true,
+        :page => { :size => 10, :current => params["page"] },
+        :joins => joins.length.zero? ? nil : joins.uniq.map do |j| pivot_options[:joins][j] end.join(" "),
+        :conditions => conditions.length.zero? ? nil : conditions.join(" AND "),
+        :order => order_options[:order])
+
+    # produce the filter list
+
+    filters = pivot_options[:filters].clone
+
+    filters.each do |filter|
+
+      # apply all the joins and conditions except for the current filter
+
+      joins      = []
+      conditions = []
+
+      pivot_options[:filters].each do |other_filter|
+        if columns = params[other_filter[:option]]
+          conditions << comparison(other_filter[:column], columns) unless other_filter == filter
+          joins += other_filter[:joins] if other_filter[:joins]
+        end
+      end
+
+      joins += filter[:joins] if filter[:joins]
+      conditions << filter[:condition] if filter[:condition]
+
+      filter[:current] = params[filter[:key]] ? params[filter[:key]].split(',') : []
+
+      filter[:objects] = Authorization.authorised_index(Contribution,
+          :all,
+          :include_permissions => true,
+          :select => filter[:select],
+          :joins => joins.length.zero? ? nil : joins.uniq.map do |j| pivot_options[:joins][j] end.join(" "),
+          :conditions => conditions.length.zero? ? nil : conditions.join(" AND "),
+          :group => filter[:group],
+          :order => filter[:order],
+          :authorised_user => user).map do |object|
+
+            x = object
+            value = eval(filter[:value])
+            selected = filter[:current].include?(value)
+
+            if selected
+              new_selection = (filter[:current] - [value]).uniq.join(',')
+            else
+              new_selection = (filter[:current] + [value]).uniq.join(',')
+            end
+
+            new_selection = nil if new_selection.empty?
+
+            target_query = request.query_parameters.merge(filter[:key] => new_selection, "page" => nil)
+
+            {
+              :object => object,
+              :value  => value,
+              :label  => "<div class='pivot-count'>" + eval("x.count") + "</div><div class='pivot-label'><span class='truncate'>" + eval(filter[:label]) + "</span></div>",
+              :query  => target_query,
+              :selected => selected
+            }
+          end
+    end
+
+    # remove filters that do not help in narrowing down the result set
+
+    filters = filters.select do |filter|
+      if filter[:objects].empty?
+        false
+#     elsif filter[:objects].length == 1 && filter[:objects][0][:selected] == false
+#       false
+      else
+        true
+      end
+    end
+
+    [results, filters, nil]
+  end
+
 end

Modified: branches/discovery/app/controllers/blobs_controller.rb (2460 => 2461)


--- branches/discovery/app/controllers/blobs_controller.rb	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/controllers/blobs_controller.rb	2010-07-06 14:40:50 UTC (rev 2461)
@@ -4,6 +4,9 @@
 # See license.txt for details.
 
 class BlobsController < ApplicationController
+
+  include ApplicationHelper
+
   before_filter :login_required, :except => [:index, :show, :download, :named_download, :statistics, :search]
   
   before_filter :find_blob_auth, :except => [:search, :index, :new, :create]
@@ -51,7 +54,8 @@
 
   # GET /files
   def index
-    @contributions = Contribution.contributions_list(Blob, params, current_user)
+    @pivot_options = pivot_options
+    @contributions, @filters, @summary = contributions_list(Blob, params, current_user)
     respond_to do |format|
       format.html # index.rhtml
     end

Modified: branches/discovery/app/controllers/packs_controller.rb (2460 => 2461)


--- branches/discovery/app/controllers/packs_controller.rb	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/controllers/packs_controller.rb	2010-07-06 14:40:50 UTC (rev 2461)
@@ -27,7 +27,8 @@
 
   # GET /packs
   def index
-    @contributions = Contribution.contributions_list(Pack, params, current_user)
+    @pivot_options = pivot_options
+    @contributions, @filters, @summary = contributions_list(Pack, params, current_user)
     respond_to do |format|
       format.html # index.rhtml
     end

Modified: branches/discovery/app/controllers/workflows_controller.rb (2460 => 2461)


--- branches/discovery/app/controllers/workflows_controller.rb	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/controllers/workflows_controller.rb	2010-07-06 14:40:50 UTC (rev 2461)
@@ -4,6 +4,9 @@
 # See license.txt for details.
 
 class WorkflowsController < ApplicationController
+
+  include ApplicationHelper
+
   before_filter :login_required, :except => [:index, :show, :download, :named_download, :statistics, :launch, :search]
   
   before_filter :find_workflows_rss, : [:index]
@@ -163,7 +166,8 @@
   def index
     respond_to do |format|
       format.html do
-        @contributions = Contribution.contributions_list(Workflow, params, current_user)
+        @pivot_options = pivot_options
+        @contributions, @filters, @summary = contributions_list(Contribution, params, current_user)
         # index.rhtml
       end
       format.rss do

Modified: branches/discovery/app/models/contribution.rb (2460 => 2461)


--- branches/discovery/app/models/contribution.rb	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/models/contribution.rb	2010-07-06 14:40:50 UTC (rev 2461)
@@ -3,7 +3,9 @@
 # Copyright (c) 2007 University of Manchester and the University of Southampton.
 # See license.txt for details.
 
+
 class Contribution < ActiveRecord::Base
+
   belongs_to :contributor, :polymorphic => true
   belongs_to :contributable, :polymorphic => true
   belongs_to :policy
@@ -16,81 +18,6 @@
            :order => "created_at DESC",
            :dependent => :destroy
 
-  def self.order_options
-    [
-      {
-        "order"  => "rank DESC",
-        "option" => "rank",
-        "label"  => "Rank"
-      },
-      
-      {
-        "order"  => "label, rank DESC",
-        "option" => "title",
-        "label"  => "Title"
-      },
-
-      {
-        "order"  => "created_at DESC, rank DESC",
-        "option" => "latest",
-        "label"  => "Latest"
-      },
-
-      {
-        "order"  => "updated_at DESC, rank DESC",
-        "option" => "last_updated",
-        "label"  => "Last updated"
-      },
-
-      {
-        "order"  => "rating DESC, rank DESC",
-        "option" => "rating",
-        "label"  => "Community rating"
-      },
-
-      {
-        "order"  => "site_viewings_count DESC, rank DESC",
-        "option" => "viewings",
-        "label"  => "Most viewed"
-      },
-
-      {
-        "order"  => "site_downloads_count DESC, rank DESC",
-        "option" => "downloads",
-        "label"  => "Most downloaded"
-      },
-
-      {
-        "joins"  => "LEFT OUTER JOIN content_types ON contributions.content_type_id = content_types.id",
-        "order"  => "content_types.title, rank DESC",
-        "option" => "type",
-        "label"  => "Type"
-      },
-
-      {
-        "joins"  => "LEFT OUTER JOIN licenses ON contributions.license_id = licenses.id",
-        "order"  => "licenses.title, rank DESC",
-        "option" => "licence",
-        "label"  => "Licence"
-      }
-    ]
-  end
-
-  def self.contributions_list(klass = nil, params = nil, user = nil)
-
-    sort_options = Contribution.order_options.find do |x| x["option"] == params["order"] end
-
-    sort_options ||= Contribution.order_options.first
-
-    results = Authorization.authorised_index(klass,
-        :all,
-        :authorised_user => user,
-        :contribution_records => true,
-        :page => { :size => 10, :current => params["page"] },
-        :joins => sort_options["joins"],
-        :order => sort_options["order"])
-  end
-
   # returns the 'most downloaded' Contributions
   # (only takes into account downloads, that is internal usage)
   # the maximum number of results is set by #limit#

Modified: branches/discovery/app/views/blobs/index.rhtml (2460 => 2461)


--- branches/discovery/app/views/blobs/index.rhtml	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/views/blobs/index.rhtml	2010-07-06 14:40:50 UTC (rev 2461)
@@ -13,7 +13,7 @@
 	<%= render :partial => "blobs/all_tags" %>
 <% end -%>
 
-<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => Contribution.order_options } %>
+<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => @pivot_options[:order] } %>
 
 <%= render :partial => "contributions/list", :locals => { :collection => @contributions, :table => true } %>
 

Modified: branches/discovery/app/views/layouts/_paginate.rhtml (2460 => 2461)


--- branches/discovery/app/views/layouts/_paginate.rhtml	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/views/layouts/_paginate.rhtml	2010-07-06 14:40:50 UTC (rev 2461)
@@ -3,7 +3,7 @@
     Sort by:
     <select  = this.options[this.selectedIndex].value;">
       <% sort_by.each do |args| %>
-        <option value="?order=<%= args["option"] -%>" <% if params[:order] == args["option"] -%> selected="selected"<% end -%>><%= args["label"] -%></option>
+        <option value="?order=<%= args[:option] -%>" <% if params[:order] == args[:option] -%> selected="selected"<% end -%>><%= args[:label] -%></option>
       <% end %>
     </select>
   </div>

Modified: branches/discovery/app/views/packs/index.rhtml (2460 => 2461)


--- branches/discovery/app/views/packs/index.rhtml	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/views/packs/index.rhtml	2010-07-06 14:40:50 UTC (rev 2461)
@@ -33,7 +33,7 @@
 	<%= render :partial => "packs/all_tags" %>
 <% end -%>
 
-<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => Contribution.order_options } %>
+<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => @pivot_options[:order] } %>
 
 <%= render :partial => "contributions/list", :locals => { :collection => @contributions, :table => true } %>
 

Modified: branches/discovery/app/views/workflows/_table.rhtml (2460 => 2461)


--- branches/discovery/app/views/workflows/_table.rhtml	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/views/workflows/_table.rhtml	2010-07-06 14:40:50 UTC (rev 2461)
@@ -21,7 +21,7 @@
 			    	<p style="margin-top:0; padding-top:0; text-align: center;"><b><%= owner_text workflow -%></b></p>
 						<center><%= contributor(workflow.contribution.contributor_id, workflow.contribution.contributor_type, true, 60) %></center>
 					</td>
-			    <td style="text-align: left;">
+			    <td style="text-align: left; width: 587px">
 			      <a name="<%= workflow.title.gsub(/ /, "_") %>"></a>
 			      <p class="title">
 					  	<%= icon "workflow", nil, nil, nil, '' %>
@@ -70,28 +70,30 @@
 						
 						<p style="font-size:85%;"><b>License: </b><% @license = License.find(workflow.license_id) %><%= link_to h(@license.title), license_path(@license) %></p>
 					  
-						<table style="width: 99%;">
-							<tbody>
-								<tr>
-									<% unless workflow.image.nil? -%>
-										<td style="margin: 0; padding: 0.2em 0; border: 0; padding-right: 0.8em; width: 101px;">
-							      	<%= link_to image_tag(url_for_file_column(workflow, "image", "thumb"), :class => 'framed_nospace'), workflow_path(workflow) %>
-										</td>
-									<% end -%>
-									<td style="margin: 0; padding: 0.2em 0; border: 0;">
-										<div class="desc" style="font-size: 85%;">
-											<% if workflow.body and workflow.body.length > 0 -%>
-											  <% desc = truncate(strip_html(workflow.body), 500) -%>
-									      <%= query ? highlight_all(desc, query) : desc %>
-											<% else -%>
-												<span class="none_text">No description</span>								      
-									  	<% end -%>
-										</div>
-									</td>
-								</tr>
-							</tbody>
-						</table>
+            <% desc_style = "font-size: 85%;" %>
+
+<% workflow.image = nil %>
+            <% unless workflow.image.nil? -%>
+              <p style="margin: 0; border: 0; width: 101px; float: left">
+                <%= link_to image_tag(url_for_file_column(workflow, "image", "thumb"), :class => 'framed_nospace'), workflow_path(workflow) %>
+              </p>
+
+              <% desc_style << " margin-left: 110px; width: 250px;" %>
+            <% end -%>
+
+            <p style="margin: 0; padding: 0; border: 0;">
+              <div class="desc" style="<%= desc_style -%>">
+                <% if workflow.body and workflow.body.length > 0 -%>
+                  <% desc = truncate(strip_html(workflow.body), 500) -%>
+                  <%= query ? highlight_all(desc, query) : desc %>
+                <% else -%>
+                  <span class="none_text">No description</span>                      
+                <% end -%>
+              </div>
+            </p>
 					  
+            <div style="clear: both"></div>
+
 					  <p style="font-size: 85%;">
 							<a href="" workflow_path(workflow) + '#ratings' -%>"><b>Rating: </b><%= number_with_precision(workflow.rating, 1) %> / 5 (<%= pluralize workflow.ratings_count, 'rating' %>)</a> |
 							<a href="" workflow_path(workflow) + '#versions' -%>"><b>Versions: </b><%= workflow.versions_count %></a> |

Modified: branches/discovery/app/views/workflows/index.rhtml (2460 => 2461)


--- branches/discovery/app/views/workflows/index.rhtml	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/app/views/workflows/index.rhtml	2010-07-06 14:40:50 UTC (rev 2461)
@@ -1,23 +1,32 @@
-<div class="box_standout" style="text-align: center; margin-bottom: 1em; font-weight: bold; line-height: 1.5em;">
-	<% Workflow.count(:all, :group => 'content_type_id').sort{|x,y| y[1] <=> x[1]}.each do |arr| %>
-		  <span class="nowrap"><%= link_to((h(ContentType.find_by_id(arr[0]).title)),
-        search_workflows_path + "?query=kind:(#{ContentType.find_by_id(arr[0]).title})") %> (<%= arr[1] %>)</span>
-	<% end %>
-</div>
+<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => @pivot_options[:order] } %>
 
-<h1><%= feed_icon_tag "Latest Workflows", formatted_workflows_path(:rss), "margin-right: 0.3em;" -%> Workflows</h1>
+<div style="clear: left"></div>
 
-<ul class="sectionIcons">
-	<li><%= icon "workflow", new_workflow_path, nil, nil, "Upload New Workflow" %></li>
-</ul>
+<div>
+  <div class="pivot">
+    <% @filters.each do |filter| %>
+      <div class="filter">
+        <div class="category"><%= filter[:title] -%></div>
 
-<% cache(:controller => 'workflows', :action ="" 'all_tags') do -%>
-	<%= render :partial => "workflows/all_tags" %>
-<% end -%>
+        <div class="options">
+          <% filter[:objects].each do |object| %>
+            <div<%= object[:selected] ? ' class="selected"' : '' -%>>
+              <%= link_to(object[:label], object[:query]) -%>
+            </div>
+          <% end %>
+        </div>
+      </div>
+    <% end %>
+  </div>
 
-<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => Contribution.order_options } %>
+  <%= render :partial => "contributions/list", :locals => { :collection => @contributions, :table => true } %>
 
-<%= render :partial => "contributions/list", :locals => { :collection => @contributions, :table => true } %>
+</div>
 
+<div style="clear: left"></div>
+
+<%= _javascript__include_tag "ellipsis.js" %>
+<script>truncate_spans()</script>
+
 <%= render :partial => "layouts/paginate", :locals => { :collection => @contributions } %>
 

Added: branches/discovery/public/_javascript_s/ellipsis.js (0 => 2461)


--- branches/discovery/public/_javascript_s/ellipsis.js	                        (rev 0)
+++ branches/discovery/public/_javascript_s/ellipsis.js	2010-07-06 14:40:50 UTC (rev 2461)
@@ -0,0 +1,35 @@
+// ellipsis.js
+
+function parentEl(el) {
+  return el.parentElement ? el.parentElement : el.parentNode;
+}
+
+function truncate_span(span) {
+
+  var targetWidth = parentEl(span).offsetWidth;
+
+  if (span.offsetWidth <= targetWidth)
+    return;
+
+  var text = span.innerHTML;
+  var pos  = text.length;
+
+  while ((span.offsetWidth > targetWidth) && (pos > 0)) {
+    pos--;
+    span.innerHTML = text.substring(0, pos) + "&hellip; "
+  }
+}
+
+function truncate_spans() {
+
+  var spans = document.getElementsByTagName('SPAN');
+
+  for (var i = 0; i < spans.length; i++) {
+    var span = spans[i];
+
+    if (span.className == 'truncate') {
+      truncate_span(span);
+    }
+  }
+}
+

Modified: branches/discovery/public/stylesheets/styles.css (2460 => 2461)


--- branches/discovery/public/stylesheets/styles.css	2010-07-06 14:40:23 UTC (rev 2460)
+++ branches/discovery/public/stylesheets/styles.css	2010-07-06 14:40:50 UTC (rev 2461)
@@ -829,7 +829,6 @@
 }
 
 table.alt_table {
-	width: 100%;
 	border-collapse: collapse;
 }
 
@@ -887,6 +886,8 @@
 	text-align: left;
 	line-height: 1.3;
 	overflow: hidden;
+  word-wrap: break-word;
+  width: 360px;
 }
 
 table.alt_table .standout {
@@ -2032,3 +2033,62 @@
   padding-top: 1em;
 }
 
+/* pivot panel */
+
+DIV.pivot {
+  float: left;
+  width: 150px;
+  margin-right: 10px;
+}
+
+DIV.pivot DIV.filter {
+  margin-bottom: 1em;
+  padding: 2px;
+  background: #f0f0f0;
+  border-radius: 8px;
+}
+
+DIV.pivot DIV.category {
+  padding: 0.2em;
+  font-size: 120%;
+  background: #e0e0e0;
+  margin-bottom: 0.2em;
+  border-radius: 6px 6px 0 0;
+}
+
+DIV.pivot DIV.options > DIV {
+  border: 1px solid transparent;
+  padding: 0.2em;
+  font-size: 90%;
+  padding-left: 0.2em;
+}
+
+DIV.pivot DIV.options > DIV:last-child {
+  border-radius: 0 0 6px 6px;
+}
+
+DIV.pivot DIV.options > DIV:hover {
+  background: #d0d0f0;
+}
+
+DIV.pivot DIV.options > DIV.selected {
+  background: #ffe0c0;
+}
+ 
+DIV.pivot DIV.options > DIV.selected:hover {
+  background: #dfc0a0;
+}
+ 
+.pivot-label {
+  width: 110px;
+  overflow: hidden;
+}
+
+.pivot-count {
+  float: right;
+}
+
+.truncate {
+  white-space: nowrap;
+}
+

reply via email to

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