mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
HTML in image captions, first run, see #18311
git-svn-id: http://svn.automattic.com/wordpress/trunk@19982 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a1d2e646ab
commit
73c87020c7
@ -3873,6 +3873,43 @@ abbr.required {
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
.media-item .edit-caption-controls {
|
||||
margin: 5px 0;
|
||||
width: 460px;
|
||||
}
|
||||
|
||||
.media-item .edit-caption-controls label {
|
||||
margin: 5px 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.media-item .edit-caption-controls label span {
|
||||
width: 100px;
|
||||
float: left;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.media-item .edit-caption-controls input[type="text"] {
|
||||
width: 335px;
|
||||
}
|
||||
|
||||
.media-item .caption-insert-link-buttons {
|
||||
text-align: right;
|
||||
margin: 5px 12px;
|
||||
}
|
||||
|
||||
.media-item .caption-insert-link-wrap {
|
||||
padding: 5px 0 5px 12px;
|
||||
background-color: #f8f8f8;
|
||||
border: 1px solid #eee;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.media-item .post_excerpt textarea {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
14.1 - Media Library
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -149,22 +149,28 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $
|
||||
|
||||
$width = $matches[1];
|
||||
|
||||
$caption = str_replace( array( '>', '<', '"', "'" ),
|
||||
array( '>', '<', '"', ''' ),
|
||||
$caption
|
||||
);
|
||||
$caption = preg_replace_callback( '/<[a-zA-Z][^<>]+>/', '_cleanup_image_add_caption', $caption );
|
||||
$caption = str_replace( '"', '"', $caption );
|
||||
|
||||
$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
|
||||
if ( empty($align) )
|
||||
$align = 'none';
|
||||
|
||||
$shcode = '[caption id="' . $id . '" align="align' . $align
|
||||
. '" width="' . $width . '" caption="' . addslashes($caption) . '"]' . $html . '[/caption]';
|
||||
. '" width="' . $width . '" caption="' . $caption . '"]' . $html . '[/caption]';
|
||||
|
||||
return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
|
||||
}
|
||||
add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
|
||||
|
||||
// Private, preg_replace callback used in image_add_caption()
|
||||
function _cleanup_image_add_caption($str) {
|
||||
if ( isset($str[0]) )
|
||||
return str_replace( '"', "'", $str[0] );
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
@ -776,12 +782,33 @@ function image_link_input_fields($post, $url_type = '') {
|
||||
|
||||
return "
|
||||
<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br />
|
||||
<button type='button' class='button urlnone' title=''>" . __('None') . "</button>
|
||||
<button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button>
|
||||
<button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>
|
||||
<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>
|
||||
<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>
|
||||
<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>
|
||||
";
|
||||
}
|
||||
|
||||
function wp_caption_input_textarea($edit_post) {
|
||||
// post data is already escaped
|
||||
$name = "attachments[{$edit_post->ID}][post_excerpt]";
|
||||
|
||||
return '
|
||||
<textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>
|
||||
<div class="edit-caption-controls hide-if-no-js">
|
||||
<input type="button" class="button caption-insert-link" value="' . esc_attr__('Insert Link') . '" />
|
||||
<div class="caption-insert-link-wrap hidden">
|
||||
<label><span>' . __('Link URL') . '</span>
|
||||
<input type="text" value="" class="caption-insert-link-url" /></label>
|
||||
<label><span>' . __('Linked text') . '</span>
|
||||
<input type="text" value="" class="caption-insert-link-text" /></label>
|
||||
<div class="caption-insert-link-buttons">
|
||||
<input type="button" class="button caption-cancel" value="' . esc_attr__('Cancel') . '" />
|
||||
<input type="button" class="button-primary caption-save" value="' . esc_attr__('Insert') . '" />
|
||||
<br class="clear" />
|
||||
</div></div></div>
|
||||
';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
@ -924,8 +951,9 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
||||
),
|
||||
'image_alt' => array(),
|
||||
'post_excerpt' => array(
|
||||
'label' => __('Caption'),
|
||||
'value' => $edit_post->post_excerpt
|
||||
'label' => __('Default Caption'),
|
||||
'input' => 'html',
|
||||
'html' => wp_caption_input_textarea($edit_post)
|
||||
),
|
||||
'post_content' => array(
|
||||
'label' => __('Description'),
|
||||
@ -1202,9 +1230,11 @@ function get_media_item( $attachment_id, $args = null ) {
|
||||
if ( !empty( $field[ $field['input'] ] ) )
|
||||
$item .= $field[ $field['input'] ];
|
||||
elseif ( $field['input'] == 'textarea' ) {
|
||||
if ( user_can_richedit() ) { // textarea_escaped when user_can_richedit() = false
|
||||
$field['value'] = esc_textarea( $field['value'] );
|
||||
if ( 'post_content' == $id && user_can_richedit() ) {
|
||||
// sanitize_post() skips the post_content when user_can_richedit
|
||||
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
|
||||
}
|
||||
// post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit()
|
||||
$item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>';
|
||||
} else {
|
||||
$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />";
|
||||
@ -1513,8 +1543,13 @@ var addExtImage = {
|
||||
alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
||||
|
||||
<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
|
||||
if ( f.caption.value )
|
||||
caption = f.caption.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
||||
if ( f.caption.value ) {
|
||||
caption = f.caption.value.replace(/<[a-z][^<>]+>/g, function(a){
|
||||
return a.replace(/"/g, "'");
|
||||
});
|
||||
|
||||
caption = caption.replace(/"/g, '"');
|
||||
}
|
||||
<?php } ?>
|
||||
|
||||
cls = caption ? '' : ' class="'+t.align+'"';
|
||||
|
@ -25,8 +25,8 @@ function send_to_editor(h) {
|
||||
ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
|
||||
|
||||
if ( h.indexOf('[caption') === 0 ) {
|
||||
if ( ed.plugins.wpeditimage )
|
||||
h = ed.plugins.wpeditimage._do_shcode(h);
|
||||
if ( ed.wpSetImgCaption )
|
||||
h = ed.wpSetImgCaption(h);
|
||||
} else if ( h.indexOf('[gallery') === 0 ) {
|
||||
if ( ed.plugins.wpgallery )
|
||||
h = ed.plugins.wpgallery._do_gallery(h);
|
||||
|
@ -1188,14 +1188,14 @@ function force_balance_tags( $text ) {
|
||||
/**
|
||||
* Acts on text which is about to be edited.
|
||||
*
|
||||
* Unless $richedit is set, it is simply a holder for the 'format_to_edit'
|
||||
* filter. If $richedit is set true htmlspecialchars(), through esc_textarea(),
|
||||
* will be run on the content, converting special characters to HTML entities.
|
||||
* The $content is run through esc_textarea(), which uses htmlspecialchars()
|
||||
* to convert special characters to HTML entities. If $richedit is set to true,
|
||||
* it is simply a holder for the 'format_to_edit' filter.
|
||||
*
|
||||
* @since 0.71
|
||||
*
|
||||
* @param string $content The text about to be edited.
|
||||
* @param bool $richedit Whether the $content should pass through htmlspecialchars(). Default false.
|
||||
* @param bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed).
|
||||
* @return string The text after the filter (and possibly htmlspecialchars()) has been run.
|
||||
*/
|
||||
function format_to_edit( $content, $richedit = false ) {
|
||||
|
@ -338,10 +338,43 @@ function uploadSizeError( up, file, over100mb ) {
|
||||
}
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
$('.media-upload-form').bind('click.uploader', function(e) {
|
||||
var target = $(e.target), tr, c;
|
||||
var insert_link, bookmark;
|
||||
|
||||
if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment
|
||||
$('.media-upload-form').bind('click.uploader', function(e) {
|
||||
var target = $(e.target), tr, c, el, textarea, sel, text, startPos, endPos;
|
||||
|
||||
if ( target.hasClass('caption-insert-link') ) {
|
||||
el = target.siblings('div.caption-insert-link-wrap'), textarea = target.parent().siblings('textarea').get(0);
|
||||
|
||||
if ( document.selection ) {
|
||||
textarea.focus();
|
||||
sel = document.selection.createRange();
|
||||
bookmark = sel.getBookmark();
|
||||
|
||||
if ( sel.text )
|
||||
el.find('.caption-insert-link-text').val(sel.text);
|
||||
|
||||
} else if ( textarea.selectionStart || textarea.selectionStart == '0' ) {
|
||||
text = textarea.value;
|
||||
startPos = textarea.selectionStart;
|
||||
endPos = textarea.selectionEnd;
|
||||
|
||||
if ( startPos != endPos )
|
||||
el.find('.caption-insert-link-text').val( text.substring(startPos, endPos) );
|
||||
}
|
||||
|
||||
target.hide();
|
||||
el.show();
|
||||
el.find('.caption-insert-link-url').focus();
|
||||
} else if ( target.hasClass('caption-cancel') || target.hasClass('caption-save') ) {
|
||||
el = target.closest('div.caption-insert-link-wrap');
|
||||
|
||||
if ( target.hasClass('caption-save') )
|
||||
insert_link( el.closest('.edit-caption-controls').siblings('textarea'), el );
|
||||
|
||||
el.hide();
|
||||
el.siblings('.caption-insert-link').show();
|
||||
} else if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment
|
||||
tr = target.closest('tr');
|
||||
|
||||
if ( $(tr).hasClass('align') )
|
||||
@ -355,7 +388,7 @@ jQuery(document).ready(function($){
|
||||
|
||||
if ( c && c[1] ) {
|
||||
setUserSetting('urlbutton', c[1]);
|
||||
target.siblings('.urlfield').val( target.attr('title') );
|
||||
target.siblings('.urlfield').val( target.data('link-url') );
|
||||
}
|
||||
} else if ( target.is('a.dismiss') ) {
|
||||
target.parents('.media-item').fadeOut(200, function(){
|
||||
@ -364,11 +397,11 @@ jQuery(document).ready(function($){
|
||||
} else if ( target.is('.upload-flash-bypass a') || target.is('a.uploader-html') ) { // switch uploader to html4
|
||||
$('#media-items, p.submit, span.big-file-warning').css('display', 'none');
|
||||
switchUploader(0);
|
||||
return false;
|
||||
e.preventDefault();
|
||||
} else if ( target.is('.upload-html-bypass a') ) { // switch uploader to multi-file
|
||||
$('#media-items, p.submit, span.big-file-warning').css('display', '');
|
||||
switchUploader(1);
|
||||
return false;
|
||||
e.preventDefault();
|
||||
} else if ( target.is('a.describe-toggle-on') ) { // Show
|
||||
target.parent().addClass('open');
|
||||
target.siblings('.slidetoggle').fadeIn(250, function(){
|
||||
@ -386,15 +419,54 @@ jQuery(document).ready(function($){
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
e.preventDefault();
|
||||
} else if ( target.is('a.describe-toggle-off') ) { // Hide
|
||||
target.siblings('.slidetoggle').fadeOut(250, function(){
|
||||
target.parent().removeClass('open');
|
||||
});
|
||||
return false;
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
insert_link = function(textarea, parent) {
|
||||
var sel, content, startPos, endPos, scrollTop, text,
|
||||
url = parent.find('.caption-insert-link-url'), link_text = parent.find('.caption-insert-link-text');
|
||||
|
||||
if ( !url.length || !link_text.length )
|
||||
return;
|
||||
|
||||
textarea = textarea.get(0);
|
||||
content = "<a href='"+url.val()+"'>"+link_text.val()+"</a>";
|
||||
|
||||
if ( document.selection ) {
|
||||
textarea.focus();
|
||||
sel = document.selection.createRange();
|
||||
|
||||
if ( bookmark ) {
|
||||
sel.moveToBookmark( bookmark );
|
||||
bookmark = '';
|
||||
}
|
||||
|
||||
sel.text = content;
|
||||
textarea.focus();
|
||||
} else if ( textarea.selectionStart || textarea.selectionStart == '0' ) {
|
||||
text = textarea.value;
|
||||
startPos = textarea.selectionStart;
|
||||
endPos = textarea.selectionEnd;
|
||||
scrollTop = textarea.scrollTop;
|
||||
|
||||
textarea.value = text.substring(0, startPos) + content + text.substring(endPos, text.length);
|
||||
|
||||
textarea.focus();
|
||||
textarea.selectionStart = startPos + content.length;
|
||||
textarea.selectionEnd = startPos + content.length;
|
||||
textarea.scrollTop = scrollTop;
|
||||
}
|
||||
|
||||
url.val('');
|
||||
link_text.val('');
|
||||
};
|
||||
|
||||
// init and set the uploader
|
||||
uploader_init = function() {
|
||||
uploader = new plupload.Uploader(wpUploaderInit);
|
||||
|
@ -12,7 +12,7 @@ not_set:"-- Not set --",
|
||||
clipboard_msg:"Copy/Cut/Paste is not available in Mozilla and Firefox.",
|
||||
clipboard_no_support:"Currently not supported by your browser, use keyboard shortcuts instead.",
|
||||
popup_blocked:"Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.",
|
||||
invalid_data:"Error: Invalid values entered, these are marked in red.",
|
||||
invalid_data:"ERROR: Invalid values entered, these are marked in red.",
|
||||
invalid_data_number:"{#field} must be a number",
|
||||
invalid_data_min:"{#field} must be a number greater than {#min}",
|
||||
invalid_data_size:"{#field} must be a number or percentage",
|
||||
@ -240,8 +240,8 @@ code:"Code",
|
||||
samp:"Code sample",
|
||||
dt:"Definition term ",
|
||||
dd:"Definition description",
|
||||
bold_desc:"Bold (Ctrl / Alt + Shift + B)",
|
||||
italic_desc:"Italic (Ctrl / Alt + Shift + I)",
|
||||
bold_desc:"Bold (Ctrl + B)",
|
||||
italic_desc:"Italic (Ctrl + I)",
|
||||
underline_desc:"Underline",
|
||||
striketrough_desc:"Strikethrough (Alt + Shift + D)",
|
||||
justifyleft_desc:"Align Left (Alt + Shift + L)",
|
||||
@ -266,6 +266,7 @@ removeformat_desc:"Remove formatting",
|
||||
forecolor_desc:"Select text color",
|
||||
backcolor_desc:"Select background color",
|
||||
charmap_desc:"Insert custom character",
|
||||
charmap_usage:"Use left and right arrows to navigate.",
|
||||
visualaid_desc:"Toggle guidelines/invisible elements",
|
||||
anchor_desc:"Insert/edit anchor",
|
||||
cut_desc:"Cut",
|
||||
@ -498,5 +499,7 @@ s120:"120%",
|
||||
s130:"130%",
|
||||
img_title:"Title",
|
||||
caption:"Caption",
|
||||
insert_link:"Insert link",
|
||||
linked_text:"Linked text",
|
||||
alt:"Alternate Text"
|
||||
});
|
||||
|
@ -275,6 +275,7 @@ removeformat_desc:"' . mce_escape( __('Remove formatting') ) . '",
|
||||
forecolor_desc:"' . mce_escape( __('Select text color') ) . '",
|
||||
backcolor_desc:"' . mce_escape( __('Select background color') ) . '",
|
||||
charmap_desc:"' . mce_escape( __('Insert custom character') ) . '",
|
||||
charmap_usage:"' . mce_escape( __('Use left and right arrows to navigate.') ) . '",
|
||||
visualaid_desc:"' . mce_escape( __('Toggle guidelines/invisible elements') ) . '",
|
||||
anchor_desc:"' . mce_escape( __('Insert/edit anchor') ) . '",
|
||||
cut_desc:"' . mce_escape( __('Cut') ) . '",
|
||||
@ -507,6 +508,8 @@ s120:"' . mce_escape( __('120%') ) . '",
|
||||
s130:"' . mce_escape( __('130%') ) . '",
|
||||
img_title:"' . mce_escape( __('Title') ) . '",
|
||||
caption:"' . mce_escape( __('Caption') ) . '",
|
||||
insert_link:"' . mce_escape( __('Insert link') ) . '",
|
||||
linked_text:"' . mce_escape( __('Linked text') ) . '",
|
||||
alt:"' . mce_escape( __('Alternate Text') ) . '"
|
||||
});
|
||||
';
|
||||
|
@ -1,68 +0,0 @@
|
||||
|
||||
body#media-upload ul#sidemenu {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
#basic .align .field label {
|
||||
display: block;
|
||||
float: right;
|
||||
padding: 0 24px 0 0;
|
||||
margin: 5px 3px 5px 5px;
|
||||
}
|
||||
|
||||
.align .field input {
|
||||
display: block;
|
||||
float: right;
|
||||
margin: 5px 15px 5px 0;
|
||||
}
|
||||
|
||||
tr.image-size label {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
tr.image-size input {
|
||||
margin: 3px 15px 0 5px;
|
||||
}
|
||||
|
||||
.image-align-none-label,
|
||||
.image-align-left-label,
|
||||
.image-align-center-label,
|
||||
.image-align-right-label {
|
||||
background-position: center right;
|
||||
}
|
||||
|
||||
#media-upload .describe th.label {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.show-align,
|
||||
.alignright,
|
||||
#img_size {
|
||||
float: left;
|
||||
}
|
||||
|
||||
tr.image-size label,
|
||||
tr.image-size input,
|
||||
#img_dim label,
|
||||
#img_dim input,
|
||||
#img_prop label,
|
||||
#img_prop input,
|
||||
#img_size_div,
|
||||
.alignleft {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#img_dim label,
|
||||
#img_prop label {
|
||||
margin: 5px 0pt;
|
||||
}
|
||||
|
||||
#img_dim input,
|
||||
#img_prop input {
|
||||
margin: 0 5px 0 10px;
|
||||
}
|
||||
|
||||
#img_size_title {
|
||||
text-align: left;
|
||||
}
|
@ -356,3 +356,112 @@ div#media-upload-error {
|
||||
background-color: #222222;
|
||||
color: #CFCFCF;
|
||||
}
|
||||
|
||||
#img-edit .edit-caption-controls {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
#img-edit .edit-caption-controls label {
|
||||
margin: 5px 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#img-edit .edit-caption-controls label span {
|
||||
width: 100px;
|
||||
float: left;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
#img-edit .edit-caption-controls input[type="text"] {
|
||||
width: 335px;
|
||||
}
|
||||
|
||||
#img-edit .caption-insert-link-buttons {
|
||||
text-align: right;
|
||||
margin: 5px 12px;
|
||||
}
|
||||
|
||||
#img-edit .caption-insert-link-wrap {
|
||||
padding: 5px 0 5px 12px;
|
||||
background-color: #f8f8f8;
|
||||
border: 1px solid #eee;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#img-edit #img_cap_text {
|
||||
font: normal 12px/18px monospace;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* RTL */
|
||||
body#media-upload.rtl ul#sidemenu {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.rtl #basic .align .field label {
|
||||
display: block;
|
||||
float: right;
|
||||
padding: 0 24px 0 0;
|
||||
margin: 5px 3px 5px 5px;
|
||||
}
|
||||
|
||||
.rtl .align .field input {
|
||||
display: block;
|
||||
float: right;
|
||||
margin: 5px 15px 5px 0;
|
||||
}
|
||||
|
||||
.rtl tr.image-size label {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.rtl tr.image-size input {
|
||||
margin: 3px 15px 0 5px;
|
||||
}
|
||||
|
||||
.rtl .image-align-none-label,
|
||||
.rtl .image-align-left-label,
|
||||
.rtl .image-align-center-label,
|
||||
.rtl .image-align-right-label {
|
||||
background-position: center right;
|
||||
}
|
||||
|
||||
#media-upload.rtl .describe th.label {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.rtl .show-align,
|
||||
.rtl .alignright,
|
||||
.rtl #img_size {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.rtl tr.image-size label,
|
||||
.rtl tr.image-size input,
|
||||
.rtl #img_dim label,
|
||||
.rtl #img_dim input,
|
||||
.rtl #img_prop label,
|
||||
.rtl #img_prop input,
|
||||
.rtl #img_size_div,
|
||||
.rtl .alignleft {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.rtl #img_dim label,
|
||||
.rtl #img_prop label {
|
||||
margin: 5px 0pt;
|
||||
}
|
||||
|
||||
.rtl #img_dim input,
|
||||
.rtl #img_prop input {
|
||||
margin: 0 5px 0 10px;
|
||||
}
|
||||
|
||||
.rtl #img_size_title {
|
||||
text-align: left;
|
||||
}
|
||||
|
@ -1,22 +1,20 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
|
||||
<script type="text/javascript" src="js/editimage.js?ver=327"></script>
|
||||
<script type="text/javascript" src="../../utils/form_utils.js?ver=3223"></script>
|
||||
|
||||
<link rel="stylesheet" href="css/editimage.css?ver=327" type="text/css" media="all" />
|
||||
|
||||
<script type="text/javascript">
|
||||
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
||||
document.write('<link rel="stylesheet" href="css/editimage-rtl.css?ver=3223" type="text/css" media="all" />');
|
||||
</script>
|
||||
<link rel="stylesheet" href="css/editimage.css?ver=348" type="text/css" media="all" />
|
||||
<script type="text/javascript" src="js/editimage.js?ver=348"></script>
|
||||
<script type="text/javascript" src="../../utils/form_utils.js?ver=348"></script>
|
||||
<base target="_self" />
|
||||
</head>
|
||||
|
||||
<body id="media-upload" style="display:none;">
|
||||
<script type="text/javascript">
|
||||
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
||||
document.body.className += ' rtl';
|
||||
</script>
|
||||
<div id="media-upload-header">
|
||||
<ul id="sidemenu">
|
||||
<li><a href="javascript:;" id="tab_basic" class="current" onclick="wpImage.setTabs(this);">{#wpeditimage.edit_img}</a></li>
|
||||
@ -103,7 +101,23 @@ if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
||||
</label>
|
||||
</th>
|
||||
<td class="field">
|
||||
<input type="text" id="img_cap" name="img_cap" value="" size="60" />
|
||||
<textarea id="img_cap_text"></textarea>
|
||||
|
||||
<div class="edit-caption-controls">
|
||||
<input type="button" class="button caption-insert-link" value="{#wpeditimage.insert_link}" />
|
||||
|
||||
<div class="caption-insert-link-wrap hidden">
|
||||
<label><span>{#advanced_dlg.link_url}</span>
|
||||
<input type="text" value="" class="caption-insert-link-url" /></label>
|
||||
|
||||
<label><span>{#wpeditimage.linked_text}</span>
|
||||
<input type="text" value="" class="caption-insert-link-text" /></label>
|
||||
|
||||
<div class="caption-insert-link-buttons">
|
||||
<input type="button" class="button caption-cancel" value="{#cancel}" />
|
||||
<input type="button" class="button-primary caption-save" value="{#insert}" />
|
||||
<br class="clear" />
|
||||
</div></div></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.wpEditImage', {
|
||||
url: '',
|
||||
editor: {},
|
||||
|
||||
init : function(ed, url) {
|
||||
init: function(ed, url) {
|
||||
var t = this, mouse = {};
|
||||
|
||||
t.url = url;
|
||||
t.editor = ed;
|
||||
t._createButtons();
|
||||
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
|
||||
@ -28,9 +31,12 @@
|
||||
});
|
||||
|
||||
ed.onInit.add(function(ed) {
|
||||
tinymce.dom.Event.add(ed.getBody(), 'dragstart', function(e) {
|
||||
if ( !tinymce.isGecko && e.target.nodeName == 'IMG' && ed.dom.getParent(e.target, 'dl.wp-caption') )
|
||||
return tinymce.dom.Event.cancel(e);
|
||||
ed.dom.events.add(ed.getBody(), 'dragstart', function(e) {
|
||||
var parent;
|
||||
|
||||
if ( e.target.nodeName == 'IMG' && ( parent = ed.dom.getParent(e.target, 'div.mceTemp') ) ) {
|
||||
ed.selection.select(parent);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -44,21 +50,16 @@
|
||||
|
||||
if ( 'IMG' == n.nodeName ) {
|
||||
window.setTimeout(function(){
|
||||
var DL, width;
|
||||
var DL = ed.dom.getParent(n, 'dl.wp-caption'), width;
|
||||
|
||||
if ( n.width != mouse.img_w || n.height != mouse.img_h )
|
||||
n.className = n.className.replace(/size-[^ "']+/, '');
|
||||
|
||||
if ( ed.dom.getParent(n, 'div.mceTemp') ) {
|
||||
DL = ed.dom.getParent(n, 'dl.wp-caption');
|
||||
|
||||
if ( DL ) {
|
||||
width = ed.dom.getAttrib(n, 'width') || n.width;
|
||||
width = parseInt(width, 10);
|
||||
ed.dom.setStyle(DL, 'width', 10 + width);
|
||||
ed.execCommand('mceRepaint');
|
||||
}
|
||||
|
||||
if ( DL ) {
|
||||
width = ed.dom.getAttrib(n, 'width') || n.width;
|
||||
width = parseInt(width, 10);
|
||||
ed.dom.setStyle(DL, 'width', 10 + width);
|
||||
ed.execCommand('mceRepaint');
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
@ -82,79 +83,104 @@
|
||||
}
|
||||
});
|
||||
|
||||
// when pressing Return inside a caption move the cursor to a new parapraph under it
|
||||
// when pressing Return inside a caption move the caret to a new parapraph under it
|
||||
ed.onKeyPress.add(function(ed, e) {
|
||||
var n, DL, DIV, P;
|
||||
|
||||
if ( e.keyCode == 13 ) {
|
||||
n = ed.selection.getNode();
|
||||
DL = ed.dom.getParent(n, 'dl.wp-caption');
|
||||
DIV = ed.dom.getParent(DL, 'div.mceTemp');
|
||||
|
||||
if ( DL && DIV ) {
|
||||
P = ed.dom.create('p', {}, ' ');
|
||||
if ( DL )
|
||||
DIV = ed.dom.getParent(DL, 'div.mceTemp');
|
||||
|
||||
if ( DIV ) {
|
||||
P = ed.dom.create('p', {}, '<br>');
|
||||
ed.dom.insertAfter( P, DIV );
|
||||
ed.selection.select(P.firstChild);
|
||||
|
||||
if ( P.firstChild )
|
||||
ed.selection.select(P.firstChild);
|
||||
else
|
||||
ed.selection.select(P);
|
||||
if ( tinymce.isIE ) {
|
||||
ed.selection.setContent('');
|
||||
} else {
|
||||
ed.selection.setContent('<br _moz_dirty="">');
|
||||
ed.selection.setCursorLocation(P, 0);
|
||||
}
|
||||
|
||||
tinymce.dom.Event.cancel(e);
|
||||
ed.dom.events.cancel(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ed.onBeforeSetContent.add(function(ed, o) {
|
||||
o.content = t._do_shcode(o.content);
|
||||
o.content = ed.wpSetImgCaption(o.content);
|
||||
});
|
||||
|
||||
ed.onPostProcess.add(function(ed, o) {
|
||||
if (o.get)
|
||||
o.content = t._get_shcode(o.content);
|
||||
o.content = ed.wpGetImgCaption(o.content);
|
||||
});
|
||||
|
||||
ed.wpSetImgCaption = function(content) {
|
||||
return t._do_shcode(content);
|
||||
};
|
||||
|
||||
ed.wpGetImgCaption = function(content) {
|
||||
return t._get_shcode(content);
|
||||
};
|
||||
},
|
||||
|
||||
_do_shcode : function(co) {
|
||||
return co.replace(/(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?[\s\u00a0]*/g, function(a,b,c){
|
||||
_do_shcode : function(content) {
|
||||
return content.replace(/(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function(a,b,c){
|
||||
var id, cls, w, cap, div_cls;
|
||||
|
||||
b = b.replace(/\\'|\\'|\\'/g, ''').replace(/\\"|\\"/g, '"');
|
||||
c = c.replace(/\\'|\\'/g, ''').replace(/\\"/g, '"');
|
||||
id = b.match(/id=['"]([^'"]+)/i);
|
||||
cls = b.match(/align=['"]([^'"]+)/i);
|
||||
w = b.match(/width=['"]([0-9]+)/);
|
||||
cap = b.match(/caption=['"]([^'"]+)/i);
|
||||
id = b.match(/id=['"]([^'"]+)['"] ?/);
|
||||
b = b.replace(id[0], '');
|
||||
|
||||
cls = b.match(/align=['"]([^'"]+)['"] ?/);
|
||||
b = b.replace(cls[0], '');
|
||||
|
||||
w = b.match(/width=['"]([0-9]+)['"] ?/);
|
||||
b = b.replace(w[0], '');
|
||||
|
||||
cap = tinymce.trim(b).replace(/caption=['"]/, '').replace(/['"]$/, '');
|
||||
|
||||
id = ( id && id[1] ) ? id[1] : '';
|
||||
cls = ( cls && cls[1] ) ? cls[1] : 'alignnone';
|
||||
w = ( w && w[1] ) ? w[1] : '';
|
||||
cap = ( cap && cap[1] ) ? cap[1] : '';
|
||||
if ( ! w || ! cap ) return c;
|
||||
|
||||
if ( !w || !cap )
|
||||
return c;
|
||||
|
||||
div_cls = (cls == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
|
||||
|
||||
return '<div class="'+div_cls+'" draggable><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+(10+parseInt(w))+
|
||||
return '<div class="'+div_cls+'" draggable="true"><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+( 10 + parseInt(w) )+
|
||||
'px"><dt class="wp-caption-dt">'+c+'</dt><dd class="wp-caption-dd">'+cap+'</dd></dl></div>';
|
||||
});
|
||||
},
|
||||
|
||||
_get_shcode : function(co) {
|
||||
return co.replace(/<div class="mceTemp[^"]*">\s*<dl([^>]+)>\s*<dt[^>]+>([\s\S]+?)<\/dt>\s*<dd[^>]+>(.+?)<\/dd>\s*<\/dl>\s*<\/div>\s*/gi, function(a,b,c,cap){
|
||||
_get_shcode : function(content) {
|
||||
return content.replace(/<div class="mceTemp[^"]*">\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]+?)<\/dd>\s*<\/dl>\s*<\/div>/gi, function(a,b,c,cap){
|
||||
var id, cls, w;
|
||||
|
||||
id = b.match(/id=['"]([^'"]+)/i);
|
||||
cls = b.match(/class=['"]([^'"]+)/i);
|
||||
w = c.match(/width=['"]([0-9]+)/);
|
||||
|
||||
id = ( id && id[1] ) ? id[1] : '';
|
||||
cls = ( cls && cls[1] ) ? cls[1] : 'alignnone';
|
||||
w = c.match(/width="([0-9]+)"/);
|
||||
w = ( w && w[1] ) ? w[1] : '';
|
||||
|
||||
if ( ! w || ! cap ) return c;
|
||||
cls = cls.match(/align[^ '"]+/) || 'alignnone';
|
||||
cap = cap.replace(/<\S[^<>]*>/gi, '').replace(/'/g, ''').replace(/"/g, '"');
|
||||
if ( !w || !cap )
|
||||
return c;
|
||||
|
||||
id = b.match(/id="([^"]+)"/);
|
||||
id = ( id && id[1] ) ? id[1] : '';
|
||||
|
||||
cls = b.match(/class="([^"]+)"/);
|
||||
cls = ( cls && cls[1] ) ? cls[1] : '';
|
||||
cls = cls.match(/align[a-z]+/) || 'alignnone';
|
||||
|
||||
cap = cap.replace(/<[a-z][^<>]+>/g, function(a){
|
||||
return a.replace(/"/g, "'");
|
||||
});
|
||||
|
||||
cap = cap.replace(/"/g, '"');
|
||||
|
||||
return '[caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/caption]';
|
||||
});
|
||||
|
@ -21,6 +21,7 @@ tinyMCEPopup = {
|
||||
tinyMCE = w.tinyMCE;
|
||||
t.editor = tinymce.EditorManager.activeEditor;
|
||||
t.params = t.editor.windowManager.params;
|
||||
t.events = new tinymce.dom.EventUtils();
|
||||
|
||||
// Setup local DOM
|
||||
t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
|
||||
@ -36,16 +37,16 @@ tinyMCEPopup = {
|
||||
},
|
||||
|
||||
close : function() {
|
||||
var t = this, win = t.getWin();
|
||||
var t = this;
|
||||
|
||||
// To avoid domain relaxing issue in Opera
|
||||
function close() {
|
||||
win.tb_remove();
|
||||
tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup
|
||||
t.editor.windowManager.close(window);
|
||||
tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
|
||||
};
|
||||
|
||||
if (tinymce.isOpera)
|
||||
win.setTimeout(close, 0);
|
||||
t.getWin().setTimeout(close, 0);
|
||||
else
|
||||
close();
|
||||
},
|
||||
@ -74,12 +75,14 @@ tinyMCEPopup.init();
|
||||
wpImage = {
|
||||
preInit : function() {
|
||||
// import colors stylesheet from parent
|
||||
var win = tinyMCEPopup.getWin(), styles = win.document.styleSheets, url, i;
|
||||
var ed = tinyMCEPopup.editor, win = tinyMCEPopup.getWin(), styles = win.document.styleSheets, url, i;
|
||||
|
||||
for ( i = 0; i < styles.length; i++ ) {
|
||||
url = styles.item(i).href;
|
||||
if ( url && url.indexOf('colors') != -1 )
|
||||
document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );
|
||||
if ( url && url.indexOf('colors') != -1 ) {
|
||||
document.getElementsByTagName('head')[0].appendChild( ed.dom.create('link', {rel:'stylesheet', href: url}) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -242,7 +245,7 @@ wpImage = {
|
||||
|
||||
setup : function() {
|
||||
var t = this, c, el, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor,
|
||||
d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = '', dlc, pa;
|
||||
d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, DD, caption = '', dlc, pa, bookmark, insert_link;
|
||||
|
||||
document.dir = tinyMCEPopup.editor.getParam('directionality','');
|
||||
|
||||
@ -267,15 +270,12 @@ wpImage = {
|
||||
tinymce.trim(c);
|
||||
}
|
||||
|
||||
tinymce.each(DL.childNodes, function(e) {
|
||||
if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) {
|
||||
caption = e.innerHTML;
|
||||
return;
|
||||
}
|
||||
});
|
||||
DD = ed.dom.select('dd.wp-caption-dd', DL);
|
||||
if ( DD && DD[0] )
|
||||
caption = ed.serializer.serialize(DD[0]).replace(/^<p>/, '').replace(/<\/p>$/, '');
|
||||
}
|
||||
|
||||
f.img_cap.value = caption;
|
||||
f.img_cap_text.value = caption;
|
||||
f.img_title.value = ed.dom.getAttrib(el, 'title');
|
||||
f.img_alt.value = ed.dom.getAttrib(el, 'alt');
|
||||
f.border.value = ed.dom.getAttrib(el, 'border');
|
||||
@ -326,8 +326,83 @@ wpImage = {
|
||||
d.className = t.align = "alignnone";
|
||||
}
|
||||
|
||||
if ( t.width && t.preloadImg.width ) t.showSizeSet();
|
||||
if ( t.width && t.preloadImg.width )
|
||||
t.showSizeSet();
|
||||
|
||||
document.body.style.display = '';
|
||||
|
||||
tinyMCEPopup.events.add(document.body, 'click', function(e) {
|
||||
var target = e.target, parent = target.parentNode, tr, c, el, textarea, sel, text, startPos, endPos;
|
||||
|
||||
if ( dom.hasClass(target, 'caption-insert-link') ) {
|
||||
el = dom.select('div.caption-insert-link-wrap', parent)[0], textarea = dom.select('#img_cap_text')[0];
|
||||
|
||||
if ( document.selection ) {
|
||||
textarea.focus();
|
||||
sel = document.selection.createRange();
|
||||
bookmark = sel.getBookmark();
|
||||
|
||||
if ( sel.text )
|
||||
dom.select('.caption-insert-link-text', el)[0].value = sel.text;
|
||||
|
||||
} else if ( textarea.selectionStart || textarea.selectionStart == '0' ) {
|
||||
text = textarea.value;
|
||||
startPos = textarea.selectionStart;
|
||||
endPos = textarea.selectionEnd;
|
||||
|
||||
if ( startPos != endPos )
|
||||
dom.select('.caption-insert-link-text', el)[0].value = text.substring(startPos, endPos);
|
||||
}
|
||||
|
||||
dom.hide(target);
|
||||
dom.show(el);
|
||||
dom.select('.caption-insert-link-url', el)[0].focus();
|
||||
} else if ( dom.hasClass(target, 'caption-cancel') || dom.hasClass(target, 'caption-save') ) {
|
||||
if ( dom.hasClass(target, 'caption-save') )
|
||||
insert_link();
|
||||
|
||||
dom.hide( dom.select('.caption-insert-link-wrap') );
|
||||
dom.show( dom.select('.caption-insert-link') );
|
||||
}
|
||||
});
|
||||
|
||||
insert_link = function() {
|
||||
var sel, content, startPos, endPos, scrollTop, text, textarea = dom.select('#img_cap_text')[0],
|
||||
url = dom.select('.caption-insert-link-url')[0], link_text = dom.select('.caption-insert-link-text')[0];
|
||||
|
||||
if ( !url || !link_text )
|
||||
return;
|
||||
|
||||
content = "<a href='"+url.value+"'>"+link_text.value+"</a>";
|
||||
|
||||
if ( document.selection ) {
|
||||
textarea.focus();
|
||||
sel = document.selection.createRange();
|
||||
|
||||
if ( bookmark ) {
|
||||
sel.moveToBookmark( bookmark );
|
||||
bookmark = '';
|
||||
}
|
||||
|
||||
sel.text = content;
|
||||
textarea.focus();
|
||||
} else if ( textarea.selectionStart || textarea.selectionStart == '0' ) {
|
||||
text = textarea.value;
|
||||
startPos = textarea.selectionStart;
|
||||
endPos = textarea.selectionEnd;
|
||||
scrollTop = textarea.scrollTop;
|
||||
|
||||
textarea.value = text.substring(0, startPos) + content + text.substring(endPos, text.length);
|
||||
|
||||
textarea.focus();
|
||||
textarea.selectionStart = startPos + content.length;
|
||||
textarea.selectionEnd = startPos + content.length;
|
||||
textarea.scrollTop = scrollTop;
|
||||
}
|
||||
|
||||
url.value = '';
|
||||
link_text.value = '';
|
||||
};
|
||||
},
|
||||
|
||||
remove : function() {
|
||||
@ -362,7 +437,7 @@ wpImage = {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( f.img_cap.value != '' && f.width.value != '' ) {
|
||||
if ( f.img_cap_text.value != '' && f.width.value != '' ) {
|
||||
do_caption = 1;
|
||||
img_class = img_class.replace( /align[^ "']+\s?/gi, '' );
|
||||
}
|
||||
@ -440,7 +515,7 @@ wpImage = {
|
||||
ed.dom.setAttrib(DIV, 'class', div_cls);
|
||||
|
||||
if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp-caption-dd') )
|
||||
ed.dom.setHTML(DD, f.img_cap.value);
|
||||
ed.dom.setHTML(DD, f.img_cap_text.value);
|
||||
|
||||
} else {
|
||||
if ( (id = f.img_classes.value.match( /wp-image-([0-9]{1,6})/ )) && id[1] )
|
||||
@ -457,7 +532,7 @@ wpImage = {
|
||||
} else html = ed.dom.getOuterHTML(el);
|
||||
|
||||
html = '<dl id="'+cap_id+'" class="wp-caption '+t.align+'" style="width: '+cap_width+
|
||||
'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap.value+'</dd></dl>';
|
||||
'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap_text.value+'</dd></dl>';
|
||||
|
||||
cap = ed.dom.create('div', {'class': div_cls}, html);
|
||||
|
||||
@ -614,3 +689,4 @@ wpImage = {
|
||||
|
||||
window.onload = function(){wpImage.init();}
|
||||
wpImage.preInit();
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,8 +1,4 @@
|
||||
body {
|
||||
font: 13px/19px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
|
||||
margin: 10px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
body.mceForceColors {background:#FFF; color:#000;}
|
||||
body.mceBrowserDefaults {background:transparent; color:inherit; font-size:inherit; font-family:inherit;}
|
||||
td {color:#000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; margin:8px;}
|
||||
@ -41,6 +37,24 @@ font[face=mceinline] {font-family:inherit !important}
|
||||
.mcePageBreak {display:block;border:0;width:100%;height:12px;border-top:1px dotted #ccc;margin-top:15px;background:#fff url(../../img/pagebreak.gif) no-repeat center top;}
|
||||
|
||||
/* WordPress styles */
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 19px;
|
||||
color: #333;
|
||||
margin: 10px;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
br[data-mce-bogus] {
|
||||
line-height: 1em;
|
||||
margin-top: -1em;
|
||||
}
|
||||
|
||||
br[data-mce-bogus]:only-child {
|
||||
line-height: inherit;
|
||||
margin-top: inherit;
|
||||
}
|
||||
|
||||
.aligncenter,
|
||||
dl.aligncenter {
|
||||
@ -75,6 +89,7 @@ dl.aligncenter {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0 none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
|
||||
.wp-caption-dd {
|
||||
|
Loading…
Reference in New Issue
Block a user