add buttons to submit editor

This commit is contained in:
John Bintz 2009-09-23 21:45:33 -04:00
parent 5ab3047bd2
commit 2eac8f71dc
3 changed files with 78 additions and 66 deletions

View File

@ -23,7 +23,7 @@
$language_options->get_language_name($transcript['language']) $language_options->get_language_name($transcript['language'])
) )
?></p> ?></p>
<div class="queued-transcription"><?php echo $transcript['transcript'] ?></div> <div class="queued-transcription transcript"><?php echo do_shortcode($transcript['transcript']) ?></div>
<div class="queued-transcription-raw" style="display:none"><?php echo $transcript['transcript'] ?></div> <div class="queued-transcription-raw" style="display:none"><?php echo $transcript['transcript'] ?></div>
<div style="padding: 10px 0"> <div style="padding: 10px 0">
<a href="#" class="approve-transcript button">Approve</a> <a href="#" class="approve-transcript button">Approve</a>
@ -54,7 +54,7 @@
foreach ($approved_transcripts as $transcript) { foreach ($approved_transcripts as $transcript) {
if ($transcript['language'] == $code) { $approved_transcript_text = $transcript['transcript']; break; } if ($transcript['language'] == $code) { $approved_transcript_text = $transcript['transcript']; break; }
} ?> } ?>
<textarea class="edit-transcript" id="wdts-transcripts-<?php echo $code ?>" name="wdts[transcripts][<?php echo $code ?>]" style="display: none; width: 100%; height: 200px"><?php echo $approved_transcript_text ?></textarea> <textarea class="edit-transcript" id="wdts-transcripts-<?php echo $code ?>" name="wdts[transcripts][<?php echo $code ?>]" style="display: none; width: 95%; height: 200px"><?php echo $approved_transcript_text ?></textarea>
<?php } ?> <?php } ?>
</p> </p>

View File

@ -27,64 +27,72 @@ var WDTSInjector = Class.create({
} }
}); });
$$('#wdts-shorttags button').each(function(b) { Event.observe(window, 'load', function() {
b.observe('click', function(e) { [
Event.stop(e); [ '#wdts-shorttags button', $("wdts-transcripts-" + $F('wdts-language')) ],
var current_transcript = $("wdts-transcripts-" + $F('wdts-language')); [ '#wdts-submit-shorttags button', $('wdts-transcript') ]
if (current_transcript) { ].each(function(info) {
if (document.selection) { $$(info[0]).each(function(b) {
var range = document.selection.createRange(); top.console.log(b);
var stored_range = range.duplicate(); b.observe('click', function(e) {
stored_range.moveToElementText( element ); Event.stop(e);
stored_range.setEndPoint( 'EndToEnd', range ); var current_transcript = info[1];
element.selectionStart = stored_range.text.length - range.text.length; if (current_transcript) {
element.selectionEnd = element.selectionStart + range.text.length; if (document.selection) {
} var range = document.selection.createRange();
var stored_range = range.duplicate();
var start = current_transcript.selectionStart; stored_range.moveToElementText( element );
var end = current_transcript.selectionEnd; stored_range.setEndPoint( 'EndToEnd', range );
element.selectionStart = stored_range.text.length - range.text.length;
var injector = new WDTSInjector(current_transcript, end); element.selectionEnd = element.selectionStart + range.text.length;
var new_content = (start == end);
var tag = b.id.replace('wdts-', '');
switch (b.id) {
case 'wdts-scene-heading':
case 'wdts-scene-action':
var message = tag.replace('-', '_');
if (new_content) {
var content = prompt(messages[message]);
if (content) {
injector.inject('[' + tag + ']' + content + "[/" + tag + "]\n", start);
}
} else {
injector.inject("[/" + tag + "]\n", end);
injector.inject('[' + tag + ']', start);
} }
break;
case 'wdts-dialog':
var name = prompt(messages.dialog_name);
if (name) {
var direction = prompt(messages.dialog_direction);
var tag = '[dialog name="' + name + '"';
if (direction) { tag += ' direction="' + direction + '"'; }
tag += ']';
if (new_content) {
var speech = prompt(messages.dialog_speech);
tag += speech + "[/dialog]\n"; var start = current_transcript.selectionStart;
var end = current_transcript.selectionEnd;
injector.inject(tag, start); var injector = new WDTSInjector(current_transcript, end);
} else {
injector.inject("[/dialog]\n", end); var new_content = (start == end);
injector.inject(tag, start); var tag = b.id.replace('wdts-', '');
} switch (b.id) {
case 'wdts-scene-heading':
case 'wdts-scene-action':
var message = tag.replace('-', '_');
if (new_content) {
var content = prompt(messages[message]);
if (content) {
injector.inject('[' + tag + ']' + content + "[/" + tag + "]\n", start);
}
} else {
injector.inject("[/" + tag + "]\n", end);
injector.inject('[' + tag + ']', start);
}
break;
case 'wdts-dialog':
var name = prompt(messages.dialog_name);
if (name) {
var direction = prompt(messages.dialog_direction);
var tag = '[dialog name="' + name + '"';
if (direction) { tag += ' direction="' + direction + '"'; }
tag += ']';
if (new_content) {
var speech = prompt(messages.dialog_speech);
tag += speech + "[/dialog]\n";
injector.inject(tag, start);
} else {
injector.inject("[/dialog]\n", end);
injector.inject(tag, start);
}
}
break;
} }
break; injector.set_caret();
} }
injector.set_caret(); });
} });
}); });
}); });

View File

@ -153,8 +153,8 @@ function transcripts_display($dropdown_message = null, $single_language_message
if (count($transcripts) == 1) { if (count($transcripts) == 1) {
list($code, $transcript) = each($transcripts); list($code, $transcript) = each($transcripts);
$output[] = apply_filters('the_language_name', get_the_language_name($code)); $output[] = end(apply_filters('the_language_name', get_the_language_name($code)));
$output[] = apply_filters('the_media_transcript', $transcript); $output[] = end(apply_filters('the_media_transcript', $transcript));
} else { } else {
$output[] = $dropdown_message; $output[] = $dropdown_message;
$output[] = '<select>'; $output[] = '<select>';
@ -165,8 +165,8 @@ function transcripts_display($dropdown_message = null, $single_language_message
} }
$output[] = '</select>'; $output[] = '</select>';
foreach ($transcripts as $code => $transcript) { foreach ($transcripts as $code => $transcript) {
$language_name = apply_filters('the_language_name', get_the_language_name($code)); $language_name = end(apply_filters('the_language_name', get_the_language_name($code)));
$transcript = apply_filters('the_media_transcript', $transcript); $transcript = end(apply_filters('the_media_transcript', $transcript));
$output[] = '<div ' $output[] = '<div '
. (($code == $default_language) ? 'style="display:none"' : '') . (($code == $default_language) ? 'style="display:none"' : '')
@ -215,13 +215,13 @@ function the_media_transcript_queue_editor() {
<?php if (current_user_can('approve_transcriptions')) { ?> <?php if (current_user_can('approve_transcriptions')) { ?>
<h3><?php _e('Manage Transcripts:', 'what-did-they-say') ?></h3> <h3><?php _e('Manage Transcripts:', 'what-did-they-say') ?></h3>
<form method="post" class="transcript-editor"> <form method="post" class="transcript-editor">
<?php include(dirname(__FILE__) . '/classes/meta-box.inc') ?> <?php include(dirname(__FILE__) . '/classes/partials/meta-box.inc') ?>
<input type="submit" value="Modify Transcript" /> <input type="submit" value="Modify Transcript" />
</form> </form>
<?php } ?> <?php } ?>
<?php if (current_user_can('submit_transcriptions')) { ?> <?php if (current_user_can('submit_transcriptions')) { ?>
<?php if ($transcript_options->are_new_transcripts_allowed()) { ?> <?php if ($transcript_options->are_new_transcripts_allowed()) { ?>
<h3><?php _e('Submit a new transcript:', 'what-did-they-say') ?></h3> <h3 style="margin-top: 0.5em"><?php _e('Submit a new transcript:', 'what-did-they-say') ?></h3>
<form method="post" class="transcript-editor"> <form method="post" class="transcript-editor">
<input type="hidden" name="wdts[_nonce]" value="<?php echo wp_create_nonce('what-did-they-say') ?>" /> <input type="hidden" name="wdts[_nonce]" value="<?php echo wp_create_nonce('what-did-they-say') ?>" />
<input type="hidden" name="wdts[module]" value="queue-transcript" /> <input type="hidden" name="wdts[module]" value="queue-transcript" />
@ -234,10 +234,14 @@ function the_media_transcript_queue_editor() {
<?php } ?> <?php } ?>
</select> </select>
</label><br /> </label><br />
<label> <?php _e('Transcript:', 'what-did-they-say') ?><br />
<?php _e('Transcription:', 'what-did-they-say') ?><br /> <div id="wdts-submit-shorttags">
<textarea style="height: 200px; width: 90%" name="wdts[transcript]"></textarea> <button class="wdts-create" id="wdts-scene-heading">Scene Heading</button>
</label> <button class="wdts-create" id="wdts-scene-action">Scene Action</button>
<button class="wdts-create" id="wdts-dialog">Dialog</button>
</div>
<textarea style="height: 200px; width: 90%" id="wdts-transcript" name="wdts[transcript]"></textarea>
<input type="submit" value="<?php _e('Submit For Approval', 'what-did-they-say') ?>" /> <input type="submit" value="<?php _e('Submit For Approval', 'what-did-they-say') ?>" />
<?php } ?> <?php } ?>
</form> </form>