Created
September 4, 2012 04:43
-
-
Save dbieber/3616675 to your computer and use it in GitHub Desktop.
Collapsible Blog Posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* CSS for Collapsible Blog Posts */ | |
[id^=_] { | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* JS for Collapsible Blog Posts */ | |
<script type="text/javascript"> | |
function swap(e1, e2) { | |
e1.fadeOut(500).promise().done(function() { | |
e2.fadeIn(500); | |
}); | |
} | |
function register_swap(e1, e2) { | |
$(e1).click(function(e) { | |
var srcEl = e.srcElement? e.srcElement : e.target; | |
if (srcEl.tagName.toUpperCase() == "A") return; | |
swap($(e1), $(e2)); | |
}); | |
} | |
function register_pair(e1, e2) { | |
register_swap(e1, e2); | |
register_swap(e2, e1); | |
} | |
function addBorder(e1) { | |
$(e1).css("border-left", "solid 1px lightgray"); | |
$(e1).css("padding-left", "5px"); | |
} | |
var paragraphs = $('.post *'); | |
for (var cv = 0; cv < paragraphs.length; cv++) { | |
var keyId = paragraphs[cv].id; | |
if (keyId.charAt(0) == "_") { | |
register_pair('#' + keyId, '#' + keyId.substr(1)); | |
addBorder('#' + keyId); | |
addBorder('#' + keyId.substr(1)); | |
} | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p id="example">Try it. You'll like it.</p> | |
<p id="_example">Inspired to try blogging by a few of my friends: <a href="http://www.dskang.com">Dan Kang</a> and <a href="http://www.harvestzhang.com">Harvest Zhang</a>.</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment