Created
February 23, 2012 15:33
-
-
Save mkorostoff/1893316 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* On the video page, the description shows a trimmed version and expands when you click "more" | |
and shrinks again when you click "less". We do that by loading two copies of the field, | |
one trimmed and plain text, the other untrimmed and full HTML. We show/hide these elements | |
with a static link. | |
*/ | |
//When the more button is clicked: | |
jQuery('.node-type-video .more-button').click(function() { | |
jQuery('.node-type-video .view-id-video.view-display-id-block_1 .views-field.views-field-body').show(); | |
jQuery('.node-type-video .view-id-video.view-display-id-block_1 .views-field.views-field-body-1').hide(); | |
jQuery('.node-type-video .less-button').show(); | |
jQuery(this).hide(); | |
}); | |
//When the more button is clicked | |
jQuery('.node-type-video .less-button').click(function() { | |
jQuery('.node-type-video .view-id-video.view-display-id-block_1 .views-field.views-field-body').hide(); | |
jQuery('.node-type-video .view-id-video.view-display-id-block_1 .views-field.views-field-body-1').show(); | |
jQuery('.node-type-video .more-button').show(); | |
jQuery(this).hide(); | |
}); | |
//If the overall string is shorter than the trim length, we just execute the "show more" function, and hide the more/less controls | |
var click_hider = jQuery('.node-type-video .views-field-body-1 .field-content').html().length; | |
if (click_hider<=65) { | |
jQuery('.node-type-video .view-id-video.view-display-id-block_1 .views-field.views-field-body').show(); | |
jQuery('.node-type-video .view-id-video.view-display-id-block_1 .views-field.views-field-body-1').hide(); | |
jQuery('.node-type-video .more-button').hide(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment