From 3d909ceda997bdcde2aec09bd72e646098389e7d Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Fri, 3 Jul 2009 22:11:16 -0700 Subject: [PATCH] [Compass Core] Cross browser ellipsis mixin. 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. --- examples/compass/src/utilities.sass | 7 +++++++ examples/compass/utilities.html.haml | 4 ++++ .../compass/utilities/text/_ellipsis.sass | 13 +++++++++++++ .../compass/templates/ellipsis/ellipsis.sass | 6 ++++++ frameworks/compass/templates/ellipsis/manifest.rb | 2 ++ .../compass/templates/ellipsis/xml/ellipsis.xml | 14 ++++++++++++++ 6 files changed, 46 insertions(+) create mode 100644 frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.sass create mode 100644 frameworks/compass/templates/ellipsis/ellipsis.sass create mode 100644 frameworks/compass/templates/ellipsis/manifest.rb create mode 100644 frameworks/compass/templates/ellipsis/xml/ellipsis.xml diff --git a/examples/compass/src/utilities.sass b/examples/compass/src/utilities.sass index 92b15031..404a8d6d 100644 --- a/examples/compass/src/utilities.sass +++ b/examples/compass/src/utilities.sass @@ -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 @@ -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 diff --git a/examples/compass/utilities.html.haml b/examples/compass/utilities.html.haml index 0cd663e4..2fa72ab1 100644 --- a/examples/compass/utilities.html.haml +++ b/examples/compass/utilities.html.haml @@ -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 diff --git a/frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.sass b/frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.sass new file mode 100644 index 00000000..01fc3fbc --- /dev/null +++ b/frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.sass @@ -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") diff --git a/frameworks/compass/templates/ellipsis/ellipsis.sass b/frameworks/compass/templates/ellipsis/ellipsis.sass new file mode 100644 index 00000000..47d6fe68 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/frameworks/compass/templates/ellipsis/manifest.rb b/frameworks/compass/templates/ellipsis/manifest.rb new file mode 100644 index 00000000..de28fcec --- /dev/null +++ b/frameworks/compass/templates/ellipsis/manifest.rb @@ -0,0 +1,2 @@ +file 'xml/ellipsis.xml', :like => :css +stylesheet 'ellipsis.sass' \ No newline at end of file diff --git a/frameworks/compass/templates/ellipsis/xml/ellipsis.xml b/frameworks/compass/templates/ellipsis/xml/ellipsis.xml new file mode 100644 index 00000000..3f94b6e2 --- /dev/null +++ b/frameworks/compass/templates/ellipsis/xml/ellipsis.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file