Skip to content

Instantly share code, notes, and snippets.

@danielhaim1
Created June 7, 2013 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielhaim1/5731513 to your computer and use it in GitHub Desktop.
Save danielhaim1/5731513 to your computer and use it in GitHub Desktop.
If paragraph has data-pullquote="span", quote will pull the <span></span> from the paragraph and data-pullquote that span. the data-pullquote="attribute" can change to anything really, e.g. "strong", "em", "blockquote" etc.
(function( $ ){
var PULLQUOTE = 'data-pullquote';
$('[' + PULLQUOTE + ']').each(function(){
var $parent = $(this),
$quote = $parent.find( $parent.data('pullquote') );
if ( $quote.length > 0 )
{
$parent
.attr( PULLQUOTE, $quote.eq(0).text() )
.addClass( 'has-pullquote ');
}
});
}( jQuery ));
/*** Example ***/
/**
<p data-pullquote="span">Ut <span>et lacus in augue tristique mollis vitae at mi.</span> <br />
Vestibulum eu tellus massa, sed rutrum eros. Nullam accumsan semper metus, vel tincidunt orci tincidunt quis.</p>
**/
/* CSS Part */
/***
.has-pullquote::before {
padding: 0;
border: none;
content: attr(data-pullquote);
float: right;
width: 320px;
margin: 12px -140px 24px 36px;
position: relative;
top: 5px;
font-size: 23px;
line-height: 30px;
}
.pullquote-left::before {
float: left;
margin: 12px 31px 24px -102px;
width: 251px;
}
.pullquote-adelle:before {
font-family: Arial, sans-serif;
font-weight: 100;
top: 10px !important;
}
.pullquote-helvetica:before {
font-family: Arial, sans-serif;
font-weight: bold;
top: 7px !important;
}
.pullquote-facit:before {
font-family: Arial, sans-serif;
font-weight: bold;
top: 7px !important;
}
***/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment