Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix facet wrapping/hyphenation in Firefox #1263

Merged
merged 1 commit into from
Oct 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/javascripts/blacklight/blacklight.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//= require blacklight/ajax_modal
//= require blacklight/search_context
//= require blacklight/collapsable
//= require blacklight/facet_load
//
//Bootstrap JS for providing collapsable tablet/mobile menu/alert boxes
//= require bootstrap/transition
Expand Down
23 changes: 23 additions & 0 deletions app/assets/javascripts/blacklight/facet_load.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*global Blacklight */

(function($) {
'use strict';

Blacklight.doResizeFacetLabelsAndCounts = function() {
// adjust width of facet columns to fit their contents
function longer (a,b){ return b.textContent.length - a.textContent.length; }

$('ul.facet-values, ul.pivot-facet').each(function(){
var longest = $(this).find('span.facet-count').sort(longer).first();
var clone = longest.clone()
.css('visibility','hidden').css('width', 'auto');
$('body').append(clone);
$(this).find('.facet-count').first().width(clone.width());
clone.remove();
});
};

Blacklight.onLoad(function() {
Blacklight.doResizeFacetLabelsAndCounts();
});
})(jQuery);
13 changes: 6 additions & 7 deletions app/assets/stylesheets/blacklight/_facets.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@

.facet-values {
display: table;
table-layout: fixed;
width: 100%;

li {

display: table-row;

.selected {
@extend .text-success;
}
Expand All @@ -69,35 +69,34 @@

@mixin hyphens-auto {
// breaks long words apart so they don't cause the containing div to
// be too big
// from http://kenneth.io/blog/2012/03/04/word-wrapping-hypernation-using-css/
-ms-word-break: break-all;
word-break: break-all;
// be too big, also fix hypenation
-ms-word-break: keep-all;
word-break: keep-all;

// Non standard for webkit
word-break: break-word;

-webkit-hyphens: auto;
-moz-hyphens: auto;
-ms-hyphens: auto;
-o-hyphens: auto;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid vendor prefixes.

hyphens: auto;
}

.facet-label {
display: table-cell;
padding-right: 1em;

text-indent: -15px;
padding-left: 15px;
padding-bottom: $padding-base-vertical;

@include hyphens-auto;
}

.facet-count {
display: table-cell;
vertical-align: top;
text-align: right;
width: 5em;
}
}

Expand Down