• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated about 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Haircut trims text down to fits into its container.

jquery.haircut.js

We've got plenty of long filenames in the LayerVault file dashboard. We needed a way to condense them to fit into the interface while still displaying important parts (like the file extension). Thus, Haircut was born.

Haircut will ellipsize a string of text to fit inside of its parent container without overflowing or breaking to another line.

You can see a video of it in action here: Haircut in Action.

When hovering over a piece of text that's been given a haircut, the full text is display in a nice bubble. This bubble can be styled to the user's desire. Haircut is smart enough to pull out and include anchor tags contained within ellipsized text.

Setup

First, include haircut on the page. Bonus points for rolling it into your asset pipeline.

<script type="text/javascript" src="/jquery.haircut.js"></script>

Next, select the items on the page you want to haircut.

$(function () {
  $('.Filename').haircut();
});

Next, you will need to call the method stringResize whenever your layout changes. This has been abstracted out for now so that users can use things like the Underscore throttle and debounce methods. It's highly recommended that you use these if you've got a heavy page.

$(window).resize(function () {
  $('.Filename').stringResize();
});

Configuration

Haircut has a few configuration parameters that will help with tweaking performance and deciding which part of the string get ellipsized. Set the options like so:

  $('.Filename').haircut({
    // The more haircut items on the page, the more it jitters during animation.
    // Adding padding reduces jitter but gives you less usable space.
    jitterPadding     : 30,

    // The placement of the ellipsis. Can be "beginning", "middle" or "end"
    // Defaults to "middle"
    placement         : "middle"
  });

Styling

To change the styling of the hover bubble, you will need to provide stylings for the classes ._LVshowHaircutExpand and ._LVhaircutExpand. You can see example CSS rules on the test page of this project.

Authors

Written by Allan Grinshtein and Kelly Sutton for LayerVault. More open-source projects are available in the LayerVault Cosmos. Licensed under the MIT License.

More Repositories

1

psd.rb

Parse Photoshop files in Ruby with ease
Ruby
3,123
star
2

jquery.typer.js

A simple jQuery plugin for a slick typing effect.
JavaScript
745
star
3

divergence

A HTTP proxy that lets you map subdomains to git branches for site testing
Ruby
408
star
4

psd-enginedata

General purpose parser for the markup format used in PSD files
Ruby
116
star
5

jquery.data.filter

Better jQuery data-* filtering
JavaScript
86
star
6

jquery.text.fadeto.js

jQuery library for fading text elements using CSS3 transitions
JavaScript
71
star
7

psd_native

Native mixins for PSD.rb that improve its performance.
C
67
star
8

ase.rb

Reader/writer for Adobe Swatch Exchange files in Ruby
Ruby
48
star
9

jquery.image.fadeto.js

A jQuery library for cross-fading images on the fly.
JavaScript
38
star
10

jquery.input.textslider.js

Emulates the Photoshop-style slidertext inputs
JavaScript
32
star
11

dn_ruby_client

Ruby gem for communicating with the Designer News API
Ruby
23
star
12

disk_store

ActiveSupport::Cache::Store-like gem for caching big files on disk
Ruby
17
star
13

LVDebounce

An Objective-C library for debouncing NSTimers
Objective-C
14
star
14

jquery.image.enhance.js

Enlarge images in a QuickLook-esque style.
JavaScript
14
star
15

layervault_js_client

NodeJS client for the LayerVault API
CoffeeScript
12
star
16

LayerVaultAPI.objc

LayerVault API Objective-C Library
Objective-C
12
star
17

layervault_ruby_client

This is the Ruby LayerVault API client.
Ruby
11
star
18

api

The LayerVault API documentation.
10
star
19

pummeldoge

Wow, such great example API app
Ruby
9
star
20

LVScreensaver

An example API app written in Objective-C. It's a screensaver that displays the latest designs in your LayerVault.
Objective-C
8
star
21

sidekiq-gelf-rb

Sidekiq logging to a GELF-supported server, such as Graylog2
Ruby
8
star
22

designer_news_js_client

NodeJS library for the Designer News API
CoffeeScript
8
star
23

ember-cli-stripejs

An ember-cli addon for using StripeJS in your application
JavaScript
5
star
24

omniauth-layervault

Official OmniAuth provider for LayerVault
Ruby
3
star
25

lv-jekyll-plugins

Jekyll tags for LayerVault public pages
Ruby
2
star
26

psd.tp

Test definitions for PSD parsers
1
star