Unify TinyMCE image popup and insert image popup. Props azaozz. see #6811

git-svn-id: https://develop.svn.wordpress.org/trunk@8066 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-06-10 04:40:21 +00:00
parent 250e5f0717
commit 4c1b6184ba
12 changed files with 1073 additions and 7 deletions

View File

@ -561,7 +561,7 @@ div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover
}
/* Containers */
.wp_themeSkin table {
.wp_themeSkin table, #wp_editbtns {
background: #83B4D5;
}

View File

@ -533,7 +533,7 @@ div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover
}
/* Containers */
.wp_themeSkin table {
.wp_themeSkin table, #wp_editbtns {
background: #cee1ef;
}

View File

@ -87,7 +87,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
?>
{
"betaManifestVersion" : 1,
"version" : "<?php echo $man_version; ?>_20080602",
"version" : "<?php echo $man_version; ?>_20080606",
"entries" : [
<?php echo $defaults; ?>
@ -149,6 +149,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/link.js?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm?ver=3091" },
@ -162,6 +163,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
{ "url" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/wp-mce-help.php?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?ver=3091" },
@ -174,6 +176,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
{ "url" : "../wp-includes/js/tinymce/plugins/media/css/media.css?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/wordpress.css?ver=3091" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/icons.gif" },
@ -208,5 +211,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/image.png" },
{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/delete.png" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/help.gif" }
]}

View File

@ -1587,3 +1587,26 @@ fieldset {
margin: 0;
padding: 0 7px;
}
#wp_editbtns {
padding: 2px;
position: absolute;
display: none;
z-index: 999998;
}
#wp_editimgbtn, #wp_delimgbtn {
margin: 2px;
padding: 2px;
border: 1px solid #999;
background-color: #eee;
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
#wp_editimgbtn:hover, #wp_delimgbtn:hover {
border-color: #555;
background-color: #ccc;
}

View File

@ -0,0 +1,167 @@
html, body {
background-color: #fff;
margin: 0;
padding: 0;
}
.submit input,
.button {
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
padding: 3px 5px;
font-size: 12px;
line-height: 1.5em;
border-width: 1px;
border-style: solid;
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
cursor: pointer;
text-decoration: none;
}
textarea,
input,
select {
font: 13px Verdana, Arial, Helvetica, sans-serif;
margin: 1px;
padding: 3px;
}
body, td {
font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
}
abbr.required {
color: #FF0000;
text-align: left;
}
.alignright {
float: right;
}
.alignleft {
float: left;
}
.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
label {
cursor: pointer;
}
th.label {
width: 128px;
}
.show-align {
padding: 8px;
height: 200px;
background-color: #f1f1f1;
cursor: default;
-moz-user-select: none;
user-select: none;
overflow: hidden;
}
#media-upload #img-edit {
border: 1px solid #c0c0c0;
width: 623px;
margin: 20px auto auto;
}
#media-upload .media-upload-form table.describe {
border-top-style: none;
border-top-width: 0;
}
#img_demo_txt {
font-size: 6px;
line-height: 10px;
font-family: "Courier New",Courier,monotype;
color: #ccc;
background-color: #ccc;
}
#img_demo {
padding: 0 5px 4px;
}
#saveeditimg {
padding: 10px 0 0 5px;
border-top: 1px solid #ccc;
}
#sidemenu,
#sidemenu li {
list-style: none;
}
#sidemenu li {
display: inline;
}
#sidemenu a {
border-bottom-style: solid;
border-bottom-width: 1px;
border-top-style: solid;
border-top-width: 1px;
display: block;
float: left;
line-height: 28px;
text-decoration: none;
text-align: center;
white-space: nowrap;
margin: 0;
padding: 0pt 7px;
}
#sidemenu a.current {
-moz-border-radius-topleft:4px;
-moz-border-radius-topright:4px;
border-style:solid;
border-width:1px;
font-weight:normal;
}
#adv_settings .field label {
padding: 0 5px 5px;
}
#media-upload h3 {
clear:both;
padding:0pt 0pt 3px;
border-bottom-style:solid;
border-bottom-width:1px;
font-family:Georgia,"Times New Roman",Times,serif;
font-size:20px;
font-weight:normal;
line-height:normal;
margin:20px 0 15px -4px;
padding:0 0 3px 0;
border-bottom-color:#DADADA;
color:#5A5A5A;
}
#img_dim #width,
#img_dim #height {
width:40px;
}
#img_dim abbr {
padding: 0 4px;
}
#basic .align .field label {
margin: 0 10px 0 0;
padding: 0 0 0 25px;
}

View File

@ -0,0 +1,262 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" 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=3091"></script>
<script type="text/javascript" src="../../utils/form_utils.js?ver=3091"></script>
<link rel="stylesheet" href="css/editimage.css?ver=3091" type="text/css" media="all" />
<link rel="stylesheet" href="../../../../../wp-admin/css/media.css?ver=2.6-bleeding2" type="text/css" media="all" />
<base target="_self" />
</head>
<body id="media-upload" style="display:none;">
<div id="media-upload-header">
<ul id="sidemenu">
<li><a href="javascript:;" id="tab_basic" class="current" onclick="wpImage.setTabs(this);">Edit image</a></li>
<li><a href="javascript:;" id="tab_advanced" onclick="wpImage.setTabs(this);">Advanced settings</a></li>
<li><a href="javascript:;" id="tab_attachment" style="display:none" target="_blanc" onclick="tinyMCEPopup.close();">Edit Attachment</a></li>
</ul>
</div>
<div id="img-edit">
<form class="media-upload-form" action="" onsubmit="wpImage.update();">
<div id="div_basic">
<div class="show-align">
<img id="img_demo" src="img/image.png" alt="" />
<span id="img_demo_txt">
Lorem ipsum dolor sit amet consectetuer velit pretium euismod ipsum enim. Mi cursus at a mollis senectus id arcu gravida quis urna. Sed et felis id tempus Morbi mauris tincidunt enim In mauris. Pede eu risus velit libero natoque enim lorem adipiscing ipsum consequat. In malesuada et sociis tincidunt tempus pellentesque cursus convallis ipsum Suspendisse. Risus In ac quis ut Nunc convallis laoreet ante Suspendisse Nam. Amet amet urna condimentum Vestibulum sem at Curabitur lorem et cursus. Sodales tortor fermentum leo dui habitant Nunc Sed Vestibulum.
Ut lorem In penatibus libero id ipsum sagittis nec elit Sed. Condimentum eget Vivamus vel consectetuer lorem molestie turpis amet tellus id. Condimentum vel ridiculus Fusce sed pede Nam nunc sodales eros tempor. Sit lacus magna dictumst Curabitur fringilla auctor id vitae wisi facilisi. Fermentum eget turpis felis velit leo Nunc Proin orci molestie Praesent. Curabitur tellus scelerisque suscipit ut sem amet cursus mi Morbi eu. Donec libero Vestibulum augue et mollis accumsan ornare condimentum In enim. Leo eget ac consectetuer quis condimentum malesuada.
Condimentum commodo et Lorem fringilla malesuada libero volutpat sem tellus enim. Tincidunt sed at Aenean nec nonummy porttitor Nam Sed Nulla ut. Auctor leo In aliquet Curabitur eros et velit Quisque justo morbi. Et vel mauris sit nulla semper vitae et quis at dui. Id at elit laoreet justo eu mauris Quisque et interdum pharetra. Nullam accumsan interdum Maecenas condimentum quis quis Fusce a sollicitudin Sed. Non Quisque Vivamus congue porttitor non semper ipsum porttitor quis vel. Donec eros lacus volutpat et tincidunt sem convallis id venenatis sit. Consectetuer odio.
Semper faucibus Morbi nulla convallis orci Aliquam Sed porttitor et Pellentesque. Venenatis laoreet lorem id a a Morbi augue turpis id semper. Arcu volutpat ac mauris Vestibulum fringilla Aenean condimentum nibh sed id. Sagittis eu lacus orci urna tellus tellus pretium Curabitur dui nunc. Et nibh eu eu nibh adipiscing at lorem Vestibulum adipiscing augue. Magna convallis Phasellus dolor malesuada Curabitur ornare adipiscing tellus Aliquam tempus. Id Aliquam Integer augue Nulla consectetuer ac Donec Curabitur tincidunt et. Id vel Nunc amet lacus dui magna ridiculus penatibus laoreet Duis. Enim sagittis nibh quis Nulla nec laoreet vel Maecenas mattis vel. Nullam velit est Curabitur gravida Vestibulum justo.
</span>
</div>
<table id="basic" class="describe">
<tbody>
<tr class="">
<th valign="top" scope="row" class="label">
<label for="img_title">
<span class="alignleft">Title</span>
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
</label>
</th>
<td class="field">
<input type="text" id="img_title" name="img_title" value="" aria-required="true" size="60" />
</td>
</tr>
<tr class="post_excerpt">
<th valign="top" scope="row" class="label">
<label for="img_alt">
<span class="alignleft">Caption</span>
</label>
</th>
<td class="field">
<input type="text" id="img_alt" name="img_alt" value="" size="60" />
<p class="help">Alternate text, e.g. "The Mona Lisa"</p>
</td>
</tr>
<tr class="url">
<th valign="top" scope="row" class="label">
<label for="link_href">
<span class="alignleft" id="lb_link_href">Link URL</span>
</label>
</th>
<td class="field">
<input type="text" id="link_href" name="link_href" value="" /><br />
<input type="button" class="button" onclick="wpImage.I('link_href').value='';" value="None" />
<input type="button" class="button" id="img_url_current" onclick="wpImage.img_seturl('current')" value="Current Link" />
<input type="button" class="button" id="img_url_img" onclick="wpImage.img_seturl('link')" value="Link to Image" />
<p class="help">Enter a link URL or click above for presets.</p>
</td>
</tr>
<tr class="align">
<th valign="top" scope="row" class="label">
<label for="img_align_td">
<span class="alignleft">{#advanced_dlg.image_align}</span>
</label>
</th>
<td class="field" id="img_align_td">
<input type="radio" onclick="wpImage.imgAlignCls('alignnone')" name="img_align" id="alignnone" value="alignnone" />
<label for="alignnone" class="align image-align-none-label">None</label>
<input type="radio" onclick="wpImage.imgAlignCls('alignleft')" name="img_align" id="alignleft" value="alignleft" />
<label for="alignleft" class="align image-align-left-label">{#advanced_dlg.image_align_left}</label>
<input type="radio" onclick="wpImage.imgAlignCls('aligncenter')" name="img_align" id="aligncenter" value="aligncenter" />
<label for="aligncenter" class="align image-align-center-label">Center</label>
<input type="radio" onclick="wpImage.imgAlignCls('alignright')" name="img_align" id="alignright" value="alignright" />
<label for="alignright" class="align image-align-right-label">{#advanced_dlg.image_align_right}</label>
</td>
</tr>
<tr class="image-size">
<th valign="top" scope="row" class="label">
<label for="img_size">
<span class="alignleft">Size</span>
</label>
</th>
<td class="field" id="img_size">
<input onclick="wpImage.imgEditSize('thumbnail')" type="radio" name="img_size" id="thumbnail" value="thumbnail" />
<label for="thumbnail" id="lb_sizethumb">Thumbnail</label>
<input onclick="wpImage.imgEditSize('medium')" type="radio" name="img_size" id="medium" value="medium" />
<label for="medium" id="lb_sizemedium">Medium</label>
<input onclick="wpImage.imgEditSize('full')" type="radio" name="img_size" id="full" value="full" />
<label for="full" id="lb_sizefull">Full_size</label>
</td>
</tr>
</tbody>
</table></div>
<div id="div_advanced" style="display:none;">
<h3>Advanced Image Settings</h3>
<table id="adv_settings_img" class="describe">
<tbody>
<tr>
<th valign="top" scope="row" class="label">
<label for="img_src">
<span class="alignleft">Source</span>
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
</label>
</th>
<td class="field">
<input type="text" id="img_src" name="img_src" value="" onblur="wpImage.checkVal(this)" size="60" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="img_dim">
<span class="alignleft">Size</span>
<span class="alignright"></span>
</label>
</th>
<td class="field" id="img_dim">
<label for="width">Width</label>
<input type="text" id="width" name="width" value="" />
<label for="height">Height</label>
<input type="text" id="height" name="height" value="" />
<input type="button" class="button" id="orig_size" name="orig_size" value="Original Size" onclick="wpImage.origSize();" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="img_classes">
<span class="alignleft">CSS Class</span>
</label>
</th>
<td class="field">
<input type="text" id="img_classes" name="img_classes" value="" size="60" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="img_style">
<span class="alignleft">Style</span>
</label>
</th>
<td class="field">
<input type="text" id="img_style" name="img_style" value="" size="60" />
</td>
</tr>
</tbody>
</table>
<h3>Advanced Link Settings</h3>
<table id="adv_settings_img" class="describe">
<tbody>
<tr>
<th valign="top" scope="row" class="label">
<label for="link_title">
<span class="alignleft">Link Title</span>
</label>
</th>
<td class="field">
<input type="text" id="link_title" name="link_title" value="" size="60" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="link_rel">
<span class="alignleft">Link Rel</span>
</label>
</th>
<td class="field">
<input type="text" id="link_rel" name="link_rel" value="" size="60" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="link_rev">
<span class="alignleft">Link Rev</span>
</label>
</th>
<td class="field">
<input type="text" id="link_rev" name="link_rev" value="" size="60" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="link_classes">
<span class="alignleft">CSS Class</span>
</label>
</th>
<td class="field">
<input type="text" id="link_classes" name="link_classes" value="" size="60" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="link_style">
<span class="alignleft">Style</span>
</label>
</th>
<td class="field">
<input type="text" id="link_style" name="link_style" value="" size="60" />
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<label for="link_target">
<span class="alignleft">Target</span>
</label>
</th>
<td class="field">
<input type="text" id="link_target" name="link_target" value="" size="60" />
</td>
</tr>
</tbody>
</table></div>
<div id="saveeditimg">
<input type="hidden" id="border" name="border" value="" />
<input type="hidden" id="hspace" name="hspace" value="" />
<input type="hidden" id="vspace" name="vspace" value="" />
<input type="hidden" id="align" name="align" value="" />
<input type="submit" id="saveimg" class="button" value="{#update}" />
<input type="button" class="button" id="cancelimg" name="cancelimg" value="{#cancel}" onclick="tinyMCEPopup.close();" />
</div>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,138 @@
(function() {
tinymce.create('tinymce.plugins.wpEditImage', {
init : function(ed, url) {
var t = this;
t.url = url;
t._createButtons();
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
ed.addCommand('WP_EditImage', function() {
var el = ed.selection.getNode();
if ( ed.dom.getAttrib(el, 'class').indexOf('mceItem') != -1 || el.nodeName != 'IMG' )
return;
tb_show('', url + '/editimage.html?TB_iframe=true');
tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
});
ed.onInit.add(function(ed) {
tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {
ed.plugins.wpeditimage.hideButtons();
});
});
ed.onExecCommand.add(function(ed, cmd, ui, val) {
if ( 'mceFullScreen' == cmd )
ed.plugins.wpeditimage.hideButtons();
});
ed.onSaveContent.add(function(ed, o) {
ed.plugins.wpeditimage.hideButtons();
});
ed.onMouseUp.add(function(ed, e) {
if ( tinymce.isOpera )
ed.plugins.wpeditimage.showButtons(e);
});
ed.onMouseDown.add(function(ed, e) {
if ( tinymce.isOpera ) return;
ed.plugins.wpeditimage.showButtons(e);
});
},
showButtons : function(e) {
var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y, el = e.target;
t.hideButtons();
if (el.nodeName == 'IMG') {
if (ed.dom.getAttrib(el, 'class').indexOf('mceItem') != -1)
return;
vp = ed.dom.getViewPort(ed.getWin());
p1 = DOM.getPos(ed.getContentAreaContainer());
p2 = ed.dom.getPos(el);
X = Math.max(p2.x - vp.x, 0) + p1.x;
Y = Math.max(p2.y - vp.y, 0) + p1.y;
DOM.setStyles('wp_editbtns', {
'top' : Y+5+'px',
'left' : X+5+'px',
'display' : 'block'
});
t.btnsTout = window.setTimeout( function(){ed.plugins.wpeditimage.hideButtons();}, 5000 );
}
},
hideButtons : function() {
tinymce.DOM.hide('wp_editbtns');
window.clearTimeout(this.btnsTout);
},
_createButtons : function() {
var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM;
DOM.remove('wp_editbtns');
var wp_editbtns = DOM.add(document.body, 'div', {
id : 'wp_editbtns',
style : 'display:none;'
});
var wp_editimgbtn = DOM.add('wp_editbtns', 'img', {
src : t.url+'/img/image.png',
id : 'wp_editimgbtn',
width : '24',
height : '24',
title : 'Edit'
});
wp_editimgbtn.onmousedown = function(e) {
var ed = tinyMCE.activeEditor;
ed.windowManager.bookmark = ed.selection.getBookmark('simple');
ed.execCommand("WP_EditImage");
this.parentNode.style.display = 'none';
}
var wp_delimgbtn = DOM.add('wp_editbtns', 'img', {
src : t.url+'/img/delete.png',
id : 'wp_delimgbtn',
width : '24',
height : '24',
title : 'Delete'
});
wp_delimgbtn.onmousedown = function(e) {
var ed = tinyMCE.activeEditor, el = ed.selection.getNode(), p;
if ( el.nodeName != 'IMG' || ed.dom.getAttrib(el, 'class').indexOf('mceItem') != -1 ) return;
if ( (p = ed.dom.getParent(el, 'A')) && p.childNodes.length == 1)
ed.dom.remove(p);
else ed.dom.remove(el);
this.parentNode.style.display = 'none';
ed.execCommand('mceRepaint');
return false;
}
},
getInfo : function() {
return {
longname : 'Edit Image',
author : 'WordPress',
authorurl : 'http://wordpress.org',
infourl : '',
version : "1.0"
};
}
});
tinymce.PluginManager.add('wpeditimage', tinymce.plugins.wpEditImage);
})();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -0,0 +1,471 @@
var tinymce = null, tinyMCEPopup, tinyMCE;
tinyMCEPopup = {
init: function() {
var t = this, w, ti, li, q, i, it;
li = ('' + document.location.search).replace(/^\?/, '').split('&');
q = {};
for (i=0; i<li.length; i++) {
it = li[i].split('=');
q[unescape(it[0])] = unescape(it[1]);
}
if (q.mce_rdomain)
document.domain = q.mce_rdomain;
// Find window & API
w = t.getWin();
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.params = t.editor.windowManager.params;
// Setup local DOM
t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
},
getWin : function() {
return window.dialogArguments || opener || parent || top;
},
getParam : function(n, dv) {
return this.editor.getParam(n, dv);
},
close : function() {
var t = this, win = t.getWin();
// To avoid domain relaxing issue in Opera
function close() {
t.editor.execCommand('mceRepaint');
win.tb_remove();
tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
};
if (tinymce.isOpera)
win.setTimeout(close, 0);
else
close();
},
execCommand : function(cmd, ui, val, a) {
a = a || {};
a.skip_focus = 1;
this.restoreSelection();
return this.editor.execCommand(cmd, ui, val, a);
},
storeSelection : function() {
this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
},
restoreSelection : function() {
var t = tinyMCEPopup;
if (tinymce.isIE)
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
}
}
tinyMCEPopup.init();
var wpImage = {
preInit : function() {
// import colors stylesheet from parent
var win = tinyMCEPopup.getWin();
var styles = win.document.styleSheets;
for ( i = 0; i < styles.length; i++ ) {
var url = styles.item(i).href;
if ( url && url.indexOf('colors-') != -1 ) {
document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );
break;
}
}
},
I : function(e) {
return document.getElementById(e);
},
current : '',
link : '',
link_rel : '',
setTabs : function(tab) {
var t = this;
if ( 'current' == tab.className ) return false;
t.I('div_advanced').style.display = ( 'tab_advanced' == tab.id ) ? 'block' : 'none';
t.I('div_basic').style.display = ( 'tab_basic' == tab.id ) ? 'block' : 'none';
t.I('tab_basic').className = t.I('tab_advanced').className = '';
tab.className = 'current';
return false;
},
img_seturl : function(u) {
var t = this, rel = t.I('link_rel').value;
if ( 'current' == u ) {
t.I('link_href').value = t.current;
t.I('link_rel').value = t.link_rel;
} else {
t.I('link_href').value = t.link;
if ( rel ) {
rel = rel.replace( /attachment|wp-att-[0-9]+/gi, '' );
t.I('link_rel').value = tinymce.trim(rel);
}
}
},
imgAlignCls : function(v) {
var t = this, cls = t.I('img_classes').value;
t.I('img_demo').className = v;
cls = cls.replace( /align[^ "']+/gi, '' );
cls += (' ' + v);
cls = cls.replace( /\s+/g, ' ' ).replace( /^\s/, '' );
t.I('img_classes').value = cls;
},
imgSizeCls : function(v) {
var t = this, cls = t.I('img_classes').value;
if (v) {
if ( cls.indexOf('size-') != -1 )
cls = cls.replace( /size-[^ "']+/i, 'size-' + v );
else cls += (' size-' + v);
} else {
cls = cls.replace( /size-[^ "']+/gi, '' );
t.demoSetSize();
t.I('thumbnail').checked = '';
t.I('medium').checked = '';
t.I('full').checked = '';
}
cls = cls.replace( /\s+/g, ' ' ).replace( /^\s|\s$/, '' );
t.I('img_classes').value = cls;
},
imgEditSize : function(size) {
var t = this, f = document.forms[0], sz, m = null;
var W = parseInt(t.preloadImg.width), H = parseInt(t.preloadImg.height);
if ( ! t.preloadImg || W == "" || H == "" )
return;
switch(size) {
case 'thumbnail':
m = 150;
t.imgSizeCls('thumbnail');
break;
case 'medium':
m = 300;
t.imgSizeCls('medium');
break;
case 'full':
m = 500;
t.imgSizeCls('full');
break;
}
if (m) {
if ( W > H ) {
m = Math.min(W, m);
f.width.value = m;
f.height.value = Math.floor((m / W) * H);
} else {
m = Math.min(H, m);
f.height.value = m;
f.width.value = Math.floor((m / H) * W);
}
t.width = f.width.value;
t.height = f.height.value;
}
t.demoSetSize();
},
demoSetSize : function(img) {
var demo = this.I('img_demo'), f = document.forms[0];
demo.style.width = f.width.value ? Math.floor(f.width.value * 0.6) + 'px' : '';
demo.style.height = f.height.value ? Math.floor(f.height.value * 0.6) + 'px' : '60%';
},
origSize : function() {
var t = this, f = document.forms[0];
f.width.value = t.preloadImg.width;
f.height.value = t.preloadImg.height;
t.demoSetSize();
t.imgSizeCls();
},
init : function() {
var ed = tinyMCEPopup.editor, h;
h = document.body.innerHTML;
// Replace a=x with a="x" in IE
if (tinymce.isIE)
h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
document.dir = ed.getParam('directionality','');
document.body.innerHTML = ed.translate(h);
window.setTimeout( function(){wpImage.setup();}, 100 );
},
setup : function() {
var t = this, h, c, el, id, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor, d = t.I('img_demo'), tr = ed.translate;
tinyMCEPopup.restoreSelection();
el = ed.selection.getNode();
if (el.nodeName != 'IMG') return;
f.img_src.value = d.src = link = ed.dom.getAttrib(el, 'src');
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');
f.vspace.value = ed.dom.getAttrib(el, 'vspace');
f.hspace.value = ed.dom.getAttrib(el, 'hspace');
f.align.value = ed.dom.getAttrib(el, 'align');
f.width.value = t.width = ed.dom.getAttrib(el, 'width');
f.height.value = t.height = ed.dom.getAttrib(el, 'height');
f.img_classes.value = c = ed.dom.getAttrib(el, 'class');
f.img_style.value = ed.dom.getAttrib(el, 'style');
this.updateStyle();
if (pa = ed.dom.getParent(el, 'A')) {
f.link_href.value = t.current = ed.dom.getAttrib(pa, 'href');
f.link_title.value = ed.dom.getAttrib(pa, 'title');
f.link_rel.value = t.link_rel = ed.dom.getAttrib(pa, 'rel');
f.link_rev.value = ed.dom.getAttrib(pa, 'rev');
f.link_style.value = ed.dom.getAttrib(pa, 'style');
f.link_target.value = ed.dom.getAttrib(pa, 'target');
f.link_classes.value = ed.dom.getAttrib(pa, 'class');
}
fname = link.substring( link.lastIndexOf('/') );
fname = fname.replace(/-[0-9]{2,4}x[0-9]{2,4}/, '' );
t.link = link.substring( 0, link.lastIndexOf('/') ) + fname;
if ( c.indexOf('size-thumbnail') != -1 )
t.I('thumbnail').checked = "checked";
else if ( c.indexOf('size-medium') != -1 )
t.I('medium').checked = "checked";
else if ( c.indexOf('size-full') != -1 )
t.I('full').checked = "checked";
if ( c.indexOf('alignleft') != -1 ) {
t.I('alignleft').checked = "checked";
d.className = "alignleft";
} else if ( c.indexOf('aligncenter') != -1 ) {
t.I('aligncenter').checked = "checked";
d.className = "aligncenter";
} else if ( c.indexOf('alignright') != -1 ) {
t.I('alignright').checked = "checked";
d.className = "alignright";
} else if ( c.indexOf('alignnone') != -1 ) {
t.I('alignnone').checked = "checked";
d.className = "alignnone";
}
document.body.style.display = '';
t.getImageData();
if ( (id = c.match( /wp-image-([0-9]{1,6})/ )) && id[1] ) {
t.I('tab_attachment').href = tinymce.documentBaseURL + 'media.php?action=edit&attachment_id=' + id[1];
t.I('tab_attachment').style.display = 'inline';
}
},
remove : function() {
var ed = tinyMCEPopup.editor, p, el;
tinyMCEPopup.restoreSelection();
el = ed.selection.getNode();
if (el.nodeName != 'IMG') return;
if ( (p = ed.dom.getParent(el, 'A')) && p.childNodes.length == 1)
ed.dom.remove(p);
else
ed.dom.remove(el);
ed.execCommand('mceRepaint');
tinyMCEPopup.close();
return;
},
update : function() {
var t = this, f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, p, el, b;
tinyMCEPopup.restoreSelection();
el = ed.selection.getNode();
if (el.nodeName != 'IMG') return;
if (f.img_src.value === '') t.remove();
ed.dom.setAttribs(el, {
src : f.img_src.value,
title : f.img_title.value,
alt : f.img_alt.value,
width : f.width.value,
height : f.height.value,
style : f.img_style.value,
'class' : f.img_classes.value
});
pa = ed.dom.getParent(el, 'A');
if ( ! f.link_href.value ) {
if ( pa ) {
tinyMCEPopup.execCommand("mceBeginUndoLevel");
b = ed.selection.getBookmark();
ed.dom.remove(pa, 1);
ed.selection.moveToBookmark(b);
tinyMCEPopup.execCommand("mceEndUndoLevel");
tinyMCEPopup.close();
return;
}
}
tinyMCEPopup.execCommand("mceBeginUndoLevel");
// Create new anchor elements
if (pa == null) {
tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
tinymce.each(ed.dom.select("a"), function(n) {
if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
ed.dom.setAttribs(n, {
href : f.link_href.value,
title : f.link_title.value,
rel : f.link_rel.value,
rev : f.link_rev.value,
target : f.link_target.value,
'class' : f.link_classes.value,
style : f.link_style.value
});
}
});
} else {
ed.dom.setAttribs(pa, {
href : f.link_href.value,
title : f.link_title.value,
rel : f.link_rel.value,
rev : f.link_rev.value,
target : f.link_target.value,
'class' : f.link_classes.value,
style : f.link_style.value
});
}
tinyMCEPopup.execCommand("mceEndUndoLevel");
tinyMCEPopup.close();
},
updateStyle : function() {
var dom = tinyMCEPopup.dom, st, v, f = document.forms[0];
if (tinyMCEPopup.editor.settings.inline_styles) {
st = tinyMCEPopup.dom.parseStyle(f.img_style.value);
// Handle align
v = f.align.value;
if (v) {
if (v == 'left' || v == 'right') {
st['float'] = v;
delete st['vertical-align'];
} else {
st['vertical-align'] = v;
delete st['float'];
}
} else {
delete st['float'];
delete st['vertical-align'];
}
// Handle border
v = f.border.value;
if (v || v == '0') {
if (v == '0')
st['border'] = '0';
else
st['border'] = v + 'px solid black';
} else
delete st['border'];
// Handle hspace
v = f.hspace.value;
if (v) {
delete st['margin'];
st['margin-left'] = v + 'px';
st['margin-right'] = v + 'px';
} else {
delete st['margin-left'];
delete st['margin-right'];
}
// Handle vspace
v = f.vspace.value;
if (v) {
delete st['margin'];
st['margin-top'] = v + 'px';
st['margin-bottom'] = v + 'px';
} else {
delete st['margin-top'];
delete st['margin-bottom'];
}
// Merge
st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st));
f.img_style.value = dom.serializeStyle(st);
}
},
checkVal : function(f) {
if ( f.value == '' ) {
// if ( f.id == 'width' ) f.value = this.width || this.preloadImg.width;
// if ( f.id == 'height' ) f.value = this.height || this.preloadImg.height;
if ( f.id == 'img_src' ) f.value = this.I('img_demo').src || this.preloadImg.src;
}
},
resetImageData : function() {
var f = document.forms[0];
f.width.value = f.height.value = "";
},
updateImageData : function() {
var f = document.forms[0], t = wpImage;
if ( f.width.value == '' || f.height.value == '' ) {
f.width.value = t.preloadImg.width;
f.height.value = t.preloadImg.height;
}
t.demoSetSize();
},
getImageData : function() {
var t = wpImage, f = document.forms[0];
t.preloadImg = new Image();
t.preloadImg.onload = t.updateImageData;
t.preloadImg.onerror = t.resetImageData;
t.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.img_src.value);
}
};
window.onload = function(){wpImage.init();}
wpImage.preInit();

View File

@ -70,7 +70,7 @@ http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
*/
$mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen' );
$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage' );
/*
The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
@ -122,7 +122,7 @@ if ( ! empty($mce_external_plugins) ) {
}
$plugins = implode($plugins, ',');
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'image', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
$mce_buttons = implode($mce_buttons, ',');
$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ));
@ -226,7 +226,7 @@ if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
// Setup cache info
if ( $disk_cache ) {
$cacheKey = apply_filters('tiny_mce_version', '20080602');
$cacheKey = apply_filters('tiny_mce_version', '20080606');
foreach ( $initArray as $v )
$cacheKey .= $v;

View File

@ -35,7 +35,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080325' );
// Modify this version when tinyMCE plugins are changed.
$mce_version = apply_filters('tiny_mce_version', '20080602');
$mce_version = apply_filters('tiny_mce_version', '20080606');
$scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');