Skip to content

Commit

Permalink
[Compass Core] Cross browser ellipsis mixin.
Browse files Browse the repository at this point in the history
Since this requires the installation of an additional xml file for
firefox support, it is provided as a pattern.

To install:
compass -p ellipsis

To use:
Mix +ellipsis into a selector targeting the textual element that will
truncate via ellipsis. By default, ellipsis text is set tono-wrap. Pass
false as the first argument if you don't want that.

Note:
Firefox is the lame browser in this respect, it requires a lot of bending
over backwards and has many quirky behaviors. Please read the blog post at
http://mattsnider.com/css/css-string-truncation-with-ellipsis/ for a full
explanation of the issues. Also note that ellipsis text is white-space
sensitive in Firefox, an issue that is sure to affect Haml users more than
most.
  • Loading branch information
chriseppstein committed Jul 6, 2009
1 parent ff5c850 commit 3d909ce
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/compass/src/utilities.sass
Expand Up @@ -3,6 +3,7 @@
@import yui/modules/base.sass
@import blueprint/modules/grid.sass
@import blueprint/modules/scaffolding.sass
@import compass/utilities/text/ellipsis.sass

html
+yui-base
Expand Down Expand Up @@ -67,6 +68,12 @@ h2
+outer-table-borders(2px, #151A99)
+inner-table-borders(1px, #151A99)

#ellipsis
+column(8, true)
td
width: 50%
+ellipsis

#floats
+column(16)
.clearfix-example
Expand Down
4 changes: 4 additions & 0 deletions examples/compass/utilities.html.haml
Expand Up @@ -139,6 +139,10 @@
%td.numeric.even 15.5
%td.numeric.odd 16.0
%td.numeric.even 17.5
#ellipsis
.example
%h2 Ellipsis
%p This long text is truncated at the end of the first line. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
#floats
.example
%h2 Floats
Expand Down
@@ -0,0 +1,13 @@
//
This technique, by [Justin Maxwell](http://code404.com/), was originally
published at http://mattsnider.com/css/css-string-truncation-with-ellipsis/
Firefox implementation by [Rikkert Koppes](http://www.rikkertkoppes.com/thoughts/2008/6/)
=ellipsis(!no_wrap = true)
@if !no_wrap
white-space: nowrap
overflow: hidden
text-overflow: ellipsis
-o-text-overflow: ellipsis
-ms-text-overflow: ellipsis
-moz-binding= stylesheet_url("xml/ellipsis.xml#ellipsis")
6 changes: 6 additions & 0 deletions frameworks/compass/templates/ellipsis/ellipsis.sass
@@ -0,0 +1,6 @@
@import compass/utilities/text/ellipsis.sass

// You can delete this sass file if you want, it's just an example of how to use the ellipsis mixin.
// By default, ellipsis text is no-wrap. Pass false as the first argument if you don't want that.
.ellipsis
+ellipsis
2 changes: 2 additions & 0 deletions frameworks/compass/templates/ellipsis/manifest.rb
@@ -0,0 +1,2 @@
file 'xml/ellipsis.xml', :like => :css
stylesheet 'ellipsis.sass'
14 changes: 14 additions & 0 deletions frameworks/compass/templates/ellipsis/xml/ellipsis.xml
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>
<binding id="ellipsis">
<content>
<xul:window>
<xul:description crop="end" xbl:inherits="value=xbl:text"><children/></xul:description>
</xul:window>
</content>
</binding>
</bindings>

0 comments on commit 3d909ce

Please sign in to comment.