Based on the current UX feedback, remove the "Insert Link" UI from under the caption fields, see #18311

git-svn-id: https://develop.svn.wordpress.org/trunk@20114 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2012-03-05 07:31:31 +00:00
parent 21dd77dbe2
commit e169217ad0
10 changed files with 29 additions and 260 deletions

View File

@ -3888,41 +3888,10 @@ 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;
.media-item .post_excerpt textarea,
.media-item .post_content textarea,
.media-item textarea#caption {
min-height: 5em;
}
/*------------------------------------------------------------------------------

View File

@ -149,7 +149,8 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $
$width = $matches[1];
$caption = preg_replace_callback( '/<[a-zA-Z][^<>]+>/', '_cleanup_image_add_caption', $caption );
// look only for html tags with attributes
$caption = preg_replace_callback( '/<[a-zA-Z0-9]+ [^<>]+>/', '_cleanup_image_add_caption', $caption );
$caption = str_replace( '"', '&quot;', $caption );
$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
@ -165,12 +166,20 @@ 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] );
if ( isset($str[0]) ) {
// look for single quotes inside html attributes (for example in title)
$s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $str[0] );
return str_replace( '"', "'", $s );
}
return '';
}
// Private, preg_replace callback used in image_add_caption()
function _cleanup_image_add_caption2($str) {
return str_replace( "'", '&#39;', $str );
}
/**
* {@internal Missing Short Description}}
*
@ -795,21 +804,7 @@ 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>
';
return '<textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>';
}
/**
@ -1547,7 +1542,10 @@ var addExtImage = {
<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
if ( f.caption.value ) {
caption = f.caption.value.replace(/<[a-z][^<>]+>/g, function(a){
caption = f.caption.value.replace(/<[a-zA-Z0-9]+ [^<>]+>/g, function(a){
a = a.replace(/="[^"]+"/, function(b){
return b.replace(/'/g, '&#39;');
});
return a.replace(/"/g, "'");
});
@ -1954,7 +1952,7 @@ function wp_media_insert_url_form( $default_view = 'image' ) {
<th valign="top" scope="row" class="label">
<span class="alignleft"><label for="caption">' . __('Image Caption') . '</label></span>
</th>
<td class="field"><input id="caption" name="caption" value="" type="text" /></td>
<td class="field"><textarea id="caption" class="code" name="caption"></textarea></td>
</tr>
';
} else {

View File

@ -338,48 +338,15 @@ function uploadSizeError( up, file, over100mb ) {
}
jQuery(document).ready(function($){
var insert_link, bookmark;
$('.media-upload-form').bind('click.uploader', function(e) {
var target = $(e.target), tr, c, el, textarea, sel, text, startPos, endPos;
var target = $(e.target), tr, c;
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
if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment
tr = target.closest('tr');
if ( $(tr).hasClass('align') )
if ( tr.hasClass('align') )
setUserSetting('align', target.val());
else if ( $(tr).hasClass('image-size') )
else if ( tr.hasClass('image-size') )
setUserSetting('imgsize', target.val());
} else if ( target.is('button.button') ) { // remember the last used image link url
@ -427,45 +394,6 @@ jQuery(document).ready(function($){
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() {

View File

@ -499,7 +499,5 @@ s120:"120%",
s130:"130%",
img_title:"Title",
caption:"Caption",
insert_link:"Insert link",
linked_text:"Linked text",
alt:"Alternate Text"
});

View File

@ -542,8 +542,6 @@ function wp_mce_translation() {
's130' => __('130%'),
'img_title' => __('Title'),
'caption' => __('Caption'),
'insert_link' => __('Insert link'),
'linked_text' => __('Linked text'),
'alt' => __('Alternate Text')
);

View File

@ -357,38 +357,6 @@ div#media-upload-error {
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;
}

View File

@ -102,22 +102,6 @@ if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
</th>
<td class="field">
<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>

View File

@ -186,7 +186,7 @@
cls = ( cls && cls[1] ) ? cls[1] : '';
cls = cls.match(/align[a-z]+/) || 'alignnone';
cap = cap.replace(/<[a-z][^<>]+>/g, function(a){
cap = cap.replace(/<[a-zA-Z0-9]+ [^<>]+>/g, function(a){ // look only for html tags with attributes
a = a.replace(/="[^"]+"/, function(b){
return b.replace(/'/g, '&#39;');
});

View File

@ -21,7 +21,6 @@ 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);
@ -245,7 +244,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, DD, caption = '', dlc, pa, bookmark, insert_link;
d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, DD, caption = '', dlc, pa;
document.dir = tinyMCEPopup.editor.getParam('directionality','');
@ -330,79 +329,6 @@ wpImage = {
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() {

File diff suppressed because one or more lines are too long