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'])
)
?></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 style="padding: 10px 0">
<a href="#" class="approve-transcript button">Approve</a>
@ -54,7 +54,7 @@
foreach ($approved_transcripts as $transcript) {
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 } ?>
</p>

View File

@ -27,64 +27,72 @@ var WDTSInjector = Class.create({
}
});
$$('#wdts-shorttags button').each(function(b) {
b.observe('click', function(e) {
Event.stop(e);
var current_transcript = $("wdts-transcripts-" + $F('wdts-language'));
if (current_transcript) {
if (document.selection) {
var range = document.selection.createRange();
var stored_range = range.duplicate();
stored_range.moveToElementText( element );
stored_range.setEndPoint( 'EndToEnd', range );
element.selectionStart = stored_range.text.length - range.text.length;
element.selectionEnd = element.selectionStart + range.text.length;
}
var start = current_transcript.selectionStart;
var end = current_transcript.selectionEnd;
var injector = new WDTSInjector(current_transcript, end);
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);
Event.observe(window, 'load', function() {
[
[ '#wdts-shorttags button', $("wdts-transcripts-" + $F('wdts-language')) ],
[ '#wdts-submit-shorttags button', $('wdts-transcript') ]
].each(function(info) {
$$(info[0]).each(function(b) {
top.console.log(b);
b.observe('click', function(e) {
Event.stop(e);
var current_transcript = info[1];
if (current_transcript) {
if (document.selection) {
var range = document.selection.createRange();
var stored_range = range.duplicate();
stored_range.moveToElementText( element );
stored_range.setEndPoint( 'EndToEnd', range );
element.selectionStart = stored_range.text.length - range.text.length;
element.selectionEnd = element.selectionStart + range.text.length;
}
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);
} else {
injector.inject("[/dialog]\n", end);
injector.inject(tag, start);
}
var injector = new WDTSInjector(current_transcript, end);
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";
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) {
list($code, $transcript) = each($transcripts);
$output[] = apply_filters('the_language_name', get_the_language_name($code));
$output[] = apply_filters('the_media_transcript', $transcript);
$output[] = end(apply_filters('the_language_name', get_the_language_name($code)));
$output[] = end(apply_filters('the_media_transcript', $transcript));
} else {
$output[] = $dropdown_message;
$output[] = '<select>';
@ -165,8 +165,8 @@ function transcripts_display($dropdown_message = null, $single_language_message
}
$output[] = '</select>';
foreach ($transcripts as $code => $transcript) {
$language_name = apply_filters('the_language_name', get_the_language_name($code));
$transcript = apply_filters('the_media_transcript', $transcript);
$language_name = end(apply_filters('the_language_name', get_the_language_name($code)));
$transcript = end(apply_filters('the_media_transcript', $transcript));
$output[] = '<div '
. (($code == $default_language) ? 'style="display:none"' : '')
@ -215,13 +215,13 @@ function the_media_transcript_queue_editor() {
<?php if (current_user_can('approve_transcriptions')) { ?>
<h3><?php _e('Manage Transcripts:', 'what-did-they-say') ?></h3>
<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" />
</form>
<?php } ?>
<?php if (current_user_can('submit_transcriptions')) { ?>
<?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">
<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" />
@ -234,10 +234,14 @@ function the_media_transcript_queue_editor() {
<?php } ?>
</select>
</label><br />
<label>
<?php _e('Transcription:', 'what-did-they-say') ?><br />
<textarea style="height: 200px; width: 90%" name="wdts[transcript]"></textarea>
</label>
<?php _e('Transcript:', 'what-did-they-say') ?><br />
<div id="wdts-submit-shorttags">
<button class="wdts-create" id="wdts-scene-heading">Scene Heading</button>
<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') ?>" />
<?php } ?>
</form>