JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="box box--fixed overflow">
No ellip. Too short.
</div>
<div class="box box--fixed one-line">
Forcing one line regardless
</div>
<div class="box box--fixed two-lines">
Forcing two lines of text
regardless of overflow
</div>
<div class="box box--fixed overflow">
Trying to ellipsis any overflowed content.
The quick brown fox jumped over the lazy dogs.
The quick brown fox jumped over the lazy dogs.
</div>
<div class="box box--responsive">
This is a responsive box that will update it's
ellipsis when the screen resizes. The quick brown
fox jumped over the lazy dogs. The quick brown fox
jumped over the lazy dogs.
</div>
body {
padding: 5%;
}
.box {
height: 4.5em;
background: #eee;
border: 1px solid #ccc;
padding: 0.5em 1em;
margin-right: 30px;
margin-bottom: 30px;
overflow: hidden;
float: left;
}
.box--fixed {
width: 130px;
}
.box--responsive {
width: 30%;
}
/* necessary plugin styles */
.ellip {
display: block;
height: 100%;
}
.ellip-line {
display: inline-block;
text-overflow: ellipsis;
white-space: nowrap;
word-wrap: normal;
}
.ellip,
.ellip-line {
position: relative;
overflow: hidden;
max-width: 100%;
}
/*!
* jQuery.ellipsis
* https://github.com/jjenzz/jquery.ellipsis
* --------------------------------------------------------------------------
* Copyright (c) 2013 J. Smith (@jjenzz)
* Dual licensed under the MIT and GPL licenses:
* https://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* adds a class to the last 'allowed' line of text so you can apply
* text-overflow: ellipsis;
*/
(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{a(jQuery)}}(function(d){var c="ellipsis",b='<span style="white-space: nowrap;">',e={lines:"auto",ellipClass:"ellip",responsive:false};function a(h,q){var m=this,w=0,g=[],k,p,i,f,j,n,s;m.$cont=d(h);m.opts=d.extend({},e,q);function o(){m.text=m.$cont.text();m.opts.ellipLineClass=m.opts.ellipClass+"-line";m.$el=d('<span class="'+m.opts.ellipClass+'" />');m.$el.text(m.text);m.$cont.empty().append(m.$el);t()}function t(){if(typeof m.opts.lines==="number"&&m.opts.lines<2){m.$el.addClass(m.opts.ellipLineClass);return}n=m.$cont.height();if(m.opts.lines==="auto"&&m.$el.prop("scrollHeight")<=n){return}if(!k){return}s=d.trim(m.text).split(/\s+/);m.$el.html(b+s.join("</span> "+b)+"</span>");m.$el.find("span").each(k);if(p!=null){u(p)}}function u(x){s[x]='<span class="'+m.opts.ellipLineClass+'">'+s[x];s.push("</span>");m.$el.html(s.join(" "))}if(m.opts.lines==="auto"){var r=function(y,A){var x=d(A),z=x.position().top;j=j||x.height();if(z===f){g[w].push(x)}else{f=z;w+=1;g[w]=[x]}if(z+j>n){p=y-g[w-1].length;return false}};k=r}if(typeof m.opts.lines==="number"&&m.opts.lines>1){var l=function(y,A){var x=d(A),z=x.position().top;if(z!==f){f=z;w+=1}if(w===m.opts.lines){p=y;return false}};k=l}if(m.opts.responsive){var v=function(){g=[];w=0;f=null;p=null;m.$el.html(m.text);clearTimeout(i);i=setTimeout(t,100)};d(window).on("resize."+c,v)}o()}d.fn[c]=function(f){return this.each(function(){try{d(this).data(c,(new a(this,f)))}catch(g){if(window.console){console.error(c+": "+g)}}})}}));
$('.overflow').ellipsis();
$('.one-line').ellipsis({ lines: 1 });
$('.two-lines').ellipsis({ lines: 2 });
$('.box--responsive').ellipsis({ responsive: true });
Also see: Tab Triggers