rearrange things and get short tag buttons working
This commit is contained in:
parent
180646a3ca
commit
5ab3047bd2
|
@ -534,7 +534,7 @@ class WhatDidTheySayAdmin {
|
|||
* Handle admin_menu action.
|
||||
*/
|
||||
function admin_menu() {
|
||||
global $plugin_page;
|
||||
global $pagenow, $plugin_page;
|
||||
|
||||
if (current_user_can('submit_transcriptions')) {
|
||||
add_options_page(
|
||||
|
@ -548,6 +548,7 @@ class WhatDidTheySayAdmin {
|
|||
if ($plugin_page == "manage-wdts") {
|
||||
$this->read_language_file();
|
||||
wp_enqueue_style('wdts-admin', plugin_dir_url(dirname(__FILE__)) . 'css/wdts-admin.css');
|
||||
wp_enqueue_style('wdts-defaults', plugin_dir_url(dirname(__FILE__)) . 'css/wdts-defaults.css');
|
||||
|
||||
$this->plugin_data = get_plugin_data($this->_parent_file);
|
||||
}
|
||||
|
@ -556,16 +557,19 @@ class WhatDidTheySayAdmin {
|
|||
}
|
||||
|
||||
if (current_user_can('approve_transcriptions')) {
|
||||
add_meta_box(
|
||||
'manage-transcriptions',
|
||||
__('Manage Transcriptions', 'what-did-they-say'),
|
||||
array(&$this, 'manage_transcriptions_meta_box'),
|
||||
'post',
|
||||
'normal',
|
||||
'low'
|
||||
);
|
||||
if (strpos($pagenow, "post") === 0) {
|
||||
add_meta_box(
|
||||
'manage-transcriptions',
|
||||
__('Manage Transcriptions', 'what-did-they-say'),
|
||||
array(&$this, 'manage_transcriptions_meta_box'),
|
||||
'post',
|
||||
'normal',
|
||||
'low'
|
||||
);
|
||||
|
||||
wp_enqueue_script('scriptaculous-effects');
|
||||
wp_enqueue_style('wdts-admin', plugin_dir_url(dirname(__FILE__)) . 'css/wdts-admin.css');
|
||||
wp_enqueue_script('scriptaculous-effects');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -576,7 +580,7 @@ class WhatDidTheySayAdmin {
|
|||
$options = get_option('what-did-they-say-options');
|
||||
|
||||
$nonce = wp_create_nonce('what-did-they-say');
|
||||
include(dirname(__FILE__) . '/admin.inc');
|
||||
include('partials/admin.inc');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -597,7 +601,7 @@ class WhatDidTheySayAdmin {
|
|||
$transcript_options = new WDTSTranscriptOptions($post->ID);
|
||||
|
||||
$nonce = wp_create_nonce('what-did-they-say');
|
||||
include(dirname(__FILE__) . '/meta-box.inc');
|
||||
include('partials/meta-box.inc');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
[dialog name="John" direction="(towards the house)"]Hey, where are the keys?[/dialog]
|
||||
</pre>
|
||||
|
||||
<div style="width: 300px; border: solid #333 1px; margin: 10px; padding: 10px">
|
||||
<div style="text-transform: uppercase; text-align: center; margin-bottom: 10px; font-weight: bold; font-family: 'Courier New'"><?php _e('Ext. The Old Man\'s House', 'what-did-they-say') ?></div>
|
||||
<div style="font-family: 'Courier New'"><?php _e('John is walking down to the car parked in the driveway.', 'what-did-they-say') ?></div>
|
||||
<div style="text-align: center; margin-top: 10px">
|
||||
<div style="font-family: 'Courier New'; text-transform: uppercase"><?php _e('John', 'what-did-they-say') ?></div>
|
||||
<div style="font-family: 'Courier New'; margin-bottom: 10px"><?php _e('(towards the house)', 'what-did-they-say') ?></div>
|
||||
<div style="font-family: 'Courier New'"><?php _e('Hey, where are the keys?', 'what-did-they-say') ?></div>
|
||||
<div class="transcript">
|
||||
<div class="scene-heading">Ext. The Old Man's House</div>
|
||||
<div class="scene-action">John is walking down to the car parked in the driveway.</div>
|
||||
<div class="dialog">
|
||||
<span class="name">John</span>
|
||||
<span class="direction">(towards the house)</span>
|
||||
<span class="speech">Hey, where are the keys?</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -43,6 +43,12 @@
|
|||
</select>
|
||||
</label>
|
||||
|
||||
<div id="wdts-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>
|
||||
|
||||
<?php foreach (array_keys($options['languages']) as $code) {
|
||||
$approved_transcript_text = '';
|
||||
foreach ($approved_transcripts as $transcript) {
|
||||
|
@ -61,10 +67,12 @@
|
|||
'overwrite': '<?php _e('This will overwrite the current transcript. Are you sure?', 'what-did-they-say') ?>',
|
||||
'delete': '<?php _e('This will delete the queued transcript. Are you sure?', 'what-did-they-say') ?>',
|
||||
'approved': '<?php _e('Transcript approved and posted. You can further edit it below.', 'what-did-they-say') ?>',
|
||||
'deleted': '<?php _e('Transcript deleted.', 'what-did-they-say') ?>'
|
||||
'deleted': '<?php _e('Transcript deleted.', 'what-did-they-say') ?>',
|
||||
'scene_heading': '<?php _e('Enter the scene heading:', 'what-did-they-say') ?>',
|
||||
'scene_action': '<?php _e('Enter the scene action:', 'what-did-they-say') ?>',
|
||||
'dialog_name': '<?php _e('Enter the character name:', 'what-did-they-say') ?>',
|
||||
'dialog_direction': '<?php _e('Enter the direction in which the character is speaking:', 'what-did-they-say') ?>',
|
||||
'dialog_speech': '<?php _e('Enter what the character is speaking:', 'what-did-they-say') ?>',
|
||||
};
|
||||
|
||||
var s = document.createElement('script');
|
||||
s.src = '<?php echo plugin_dir_url(dirname(__FILE__)) . 'js/edit-transcripts.js' ?>';
|
||||
document.getElementsByTagName('head')[0].appendChild(s);
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo plugin_dir_url(dirname(__FILE__)) . '../js/edit-transcripts.js' ?>"></script>
|
|
@ -53,3 +53,8 @@
|
|||
float: right;
|
||||
display: inline
|
||||
}
|
||||
|
||||
#wdts-shorttags {
|
||||
background-color: #DFDFDF;
|
||||
padding: 3px
|
||||
}
|
||||
|
|
|
@ -3,11 +3,93 @@ function switch_transcript() {
|
|||
(t.id == "wdts-transcripts-" + $F('wdts-language')) ? t.show() : t.hide();
|
||||
});
|
||||
}
|
||||
switch_transcript();
|
||||
Event.observe(language_selector, 'change', switch_transcript);
|
||||
|
||||
var WDTSInjector = Class.create({
|
||||
initialize: function(textarea, end) {
|
||||
this.textarea = textarea;
|
||||
this.end = end;
|
||||
},
|
||||
inject: function(text, position) {
|
||||
this.textarea.value = this.textarea.value.substr(0, position) + text + this.textarea.value.substr(position);
|
||||
this.end += text.length;
|
||||
},
|
||||
set_caret: function() {
|
||||
if (this.textarea.setSelectionRange) {
|
||||
this.textarea.focus();
|
||||
this.textarea.setSelectionRange(this.end, this.end);
|
||||
} else if (this.textarea.createTextRange) {
|
||||
var range = this.textarea.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', this.end);
|
||||
range.moveStart('character', this.end);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$$('#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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
injector.set_caret();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$$('.approve-transcript').each(function(b) {
|
||||
Event.observe(b, 'click', function(e) {
|
||||
b.observe('click', function(e) {
|
||||
Event.stop(e);
|
||||
var lang = b.parentNode.parentNode.select("input[name*=[language]]").shift();
|
||||
var post_id = b.parentNode.parentNode.parentNode.select("input[name*=[post_id]]").shift();
|
||||
|
@ -89,3 +171,7 @@ $$('.delete-transcript').each(function(b) {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
switch_transcript();
|
||||
Event.observe(window, 'load', switch_transcript);
|
||||
Event.observe(language_selector, 'change', switch_transcript);
|
||||
|
|
Loading…
Reference in New Issue