better show/hide transcripts
This commit is contained in:
parent
d5fced6b95
commit
ec3619ec2a
@ -76,7 +76,9 @@ class WhatDidTheySayAdmin {
|
|||||||
add_filter('the_language_name', array(&$this, 'the_language_name'), 10, 2);
|
add_filter('the_language_name', array(&$this, 'the_language_name'), 10, 2);
|
||||||
add_filter('the_matching_transcript_excerpts', array(&$this, 'the_matching_transcript_excerpts'), 10, 3);
|
add_filter('the_matching_transcript_excerpts', array(&$this, 'the_matching_transcript_excerpts'), 10, 3);
|
||||||
add_filter('the_transcript_language_name', array(&$this, 'the_transcript_language_name'), 10, 3);
|
add_filter('the_transcript_language_name', array(&$this, 'the_transcript_language_name'), 10, 3);
|
||||||
add_filter('the_transcript_format_string', array(&$this, 'the_transcript_format_string'), 10);
|
add_filter('the_transcript_format_string', array(&$this, 'the_transcript_format_string'));
|
||||||
|
|
||||||
|
add_filter('the_transcript_opener', array(&$this, 'the_transcript_opener'));
|
||||||
|
|
||||||
add_filter('template_redirect', array(&$this, 'template_redirect'));
|
add_filter('template_redirect', array(&$this, 'template_redirect'));
|
||||||
|
|
||||||
@ -141,6 +143,15 @@ class WhatDidTheySayAdmin {
|
|||||||
return $content . ob_get_clean();
|
return $content . ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function the_transcript_opener($content = '') {
|
||||||
|
ob_start(); ?>
|
||||||
|
<div class="wdts-transcript-opener"> [
|
||||||
|
<a href="#" class="wdts-opener"><?php _e('Show transcripts') ?></a>
|
||||||
|
<a href="#" class="wdts-closer"><?php _e('Hide transcripts') ?></a>
|
||||||
|
] </div>
|
||||||
|
<?php return ob_get_clean();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter for WP_Query#get_posts to add searching for transcripts.
|
* Filter for WP_Query#get_posts to add searching for transcripts.
|
||||||
*/
|
*/
|
||||||
|
@ -60,25 +60,38 @@ WhatDidTheySay.build_bundle_header = function(bundle) {
|
|||||||
bundle.insert({ top: new_header })
|
bundle.insert({ top: new_header })
|
||||||
}
|
}
|
||||||
|
|
||||||
$$('.wdts-transcript-bundle').each(function(d) {
|
$$('.wdts-transcript-container').each(function(d) {
|
||||||
if (d.hasClassName('wdts-hide-transcript')) {
|
var bundle = d.select('.wdts-transcript-bundle').pop();
|
||||||
d.hide();
|
var opener_container = d.select('.wdts-transcript-opener').pop();
|
||||||
|
|
||||||
var opener = new Element("a", { 'href': '#', 'className': 'wdts-transcript-opener' }).update(WhatDidTheySay.messages.show_transcripts);
|
if (bundle && opener_container) {
|
||||||
|
WhatDidTheySay.build_bundle_header(bundle);
|
||||||
|
|
||||||
|
var opener = opener_container.select('.wdts-opener').pop();
|
||||||
|
var closer = opener_container.select('.wdts-closer').pop();
|
||||||
|
|
||||||
|
if (opener && closer) {
|
||||||
opener.observe('click', function(e) {
|
opener.observe('click', function(e) {
|
||||||
Event.stop(e);
|
opener.hide();
|
||||||
|
closer.show();
|
||||||
if (d.visible()) {
|
bundle.show();
|
||||||
d.hide();
|
|
||||||
opener.update(WhatDidTheySay.messages.show_transcripts);
|
|
||||||
} else {
|
|
||||||
d.show();
|
|
||||||
opener.update(WhatDidTheySay.messages.hide_transcripts);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
d.insert({before: opener});
|
closer.observe('click', function(e) {
|
||||||
|
closer.hide();
|
||||||
|
opener.show();
|
||||||
|
bundle.hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
WhatDidTheySay.build_bundle_header(d);
|
if (d.hasClassName('wdts-start-hidden')) {
|
||||||
|
bundle.hide();
|
||||||
|
closer.hide();
|
||||||
|
opener.show();
|
||||||
|
} else {
|
||||||
|
bundle.show();
|
||||||
|
closer.show();
|
||||||
|
opener.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -156,6 +156,9 @@ function transcripts_display($language_format = null, $show_transcripts_string =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$output[] = '<div class="wdts-transcript-container' . ($do_hide ? " wdts-start-hidden" : "") . '">';
|
||||||
|
$output[] = apply_filters('the_transcript_opener', '');
|
||||||
|
|
||||||
$output[] = '<div class="wdts-transcript-bundle' . ($do_hide ? ' wdts-hide-transcript' : '') . '">';
|
$output[] = '<div class="wdts-transcript-bundle' . ($do_hide ? ' wdts-hide-transcript' : '') . '">';
|
||||||
|
|
||||||
foreach ($transcripts as $code => $transcript) {
|
foreach ($transcripts as $code => $transcript) {
|
||||||
@ -166,7 +169,7 @@ function transcripts_display($language_format = null, $show_transcripts_string =
|
|||||||
$output[] = '<div class="transcript-holder ' . $code . '">' . $transcript . '</div>';
|
$output[] = '<div class="transcript-holder ' . $code . '">' . $transcript . '</div>';
|
||||||
}
|
}
|
||||||
$output[] = '</div>';
|
$output[] = '</div>';
|
||||||
|
$output[] = '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user