Fix WebKit browsers reporting document.body height shorter than it is, add classes to TinyMCE's body: 'wp-editor' or 'wp-fullscreen-editor', fix mousemove event in IE, fixes #17664

git-svn-id: http://svn.automattic.com/wordpress/trunk@18142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-06-05 00:06:28 +00:00
parent e5090f3113
commit b96c4d3fc6
8 changed files with 35 additions and 26 deletions

View File

@ -186,6 +186,9 @@
}
});
if ( ed.id != 'wp_mce_fullscreen' )
ed.dom.addClass(ed.getBody(), 'wp-editor');
// remove invalid parent paragraphs when pasting HTML and/or switching to the HTML editor and back
ed.onBeforeSetContent.add(function(ed, o) {
if ( o.content ) {

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,6 @@ html, body {
background: transparent;
width: auto !important;
max-width: none !important;
margin: 0 !important;
padding: 0 !important;
margin: 0;
padding: 0;
}

View File

@ -8,7 +8,7 @@
tinymce.create('tinymce.plugins.wpFullscreenPlugin', {
init : function(ed, url) {
var t = this, oldHeight = 0, s = {}, DOM = tinymce.DOM;
var t = this, oldHeight = 0, s = {}, DOM = tinymce.DOM, resized = false;
// Register commands
ed.addCommand('wpFullScreenClose', function() {
@ -80,13 +80,14 @@
});
}, 1000);
edd.dom.addClass(edd.getBody(), 'wp-fullscreen-editor');
edd.focus();
});
fsed.render();
fsed.dom.bind( fsed.getWin(), 'mousemove', function(e){
if ( !fullscreen.settings.toolbar_shown )
fsed.dom.bind( fsed.dom.doc, 'mousemove', function(e){
if ( 'undefined' != fullscreen )
fullscreen.bounder( 'showToolbar', 'hideToolbar', 2000 );
});
});
@ -109,22 +110,28 @@
* This method gets executed each time the editor needs to resize.
*/
function resize() {
var d = ed.getDoc(), b = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight, myHeight;
if ( resized )
return;
var d = ed.getDoc(), DOM = tinymce.DOM, resizeHeight, myHeight;
// Get height differently depending on the browser used
if ( tinymce.isIE )
myHeight = b.scrollHeight;
myHeight = d.body.scrollHeight;
else if ( tinymce.isWebKit )
myHeight = b.offsetHeight;
myHeight = d.height;
else
myHeight = de.offsetHeight;
myHeight = d.documentElement.offsetHeight;
// Don't make it smaller than the minimum height
// Don't make it smaller than 300px
resizeHeight = (myHeight > 300) ? myHeight : 300;
// Resize content element
if ( oldHeight != resizeHeight ) {
oldHeight = resizeHeight;
resized = true;
setTimeout(function(){ resized = false; }, 100);
DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px');
}
};
@ -142,8 +149,6 @@
if (ed.getParam('autoresize_on_init', true)) {
ed.onLoadContent.add(function(ed, l) {
// resize(); // runs before onInit, useless?
// Because the content area resizes when its content CSS loads,
// and we can't easily add a listener to its onload event,
// we'll just trigger a resize after a short loading period

View File

@ -1 +1 @@
(function(){tinymce.create("tinymce.plugins.wpFullscreenPlugin",{init:function(a,c){var d=this,g=0,e={},f=tinymce.DOM;a.addCommand("wpFullScreenClose",function(){if(a.getParam("wp_fullscreen_is_enabled")){f.win.setTimeout(function(){tinyMCE.remove(a);f.remove("wp_mce_fullscreen_parent");tinyMCE.settings=tinyMCE.oldSettings},10)}});a.addCommand("wpFullScreenSave",function(){var h=tinyMCE.get("wp_mce_fullscreen"),i;h.focus();i=tinyMCE.get(h.getParam("wp_fullscreen_editor_id"));i.setContent(h.getContent({format:"raw"}),{format:"raw"})});a.addCommand("wpFullScreenInit",function(){var j=a.getDoc(),h=j.body,i;if(a.id=="wp_mce_fullscreen"){return}tinyMCE.oldSettings=tinyMCE.settings;tinymce.each(a.settings,function(k,l){e[l]=k});e.id="wp_mce_fullscreen";e.wp_fullscreen_is_enabled=true;e.wp_fullscreen_editor_id=a.id;e.theme_advanced_resizing=false;e.theme_advanced_statusbar_location="none";e.content_css=e.content_css+","+e.wp_fullscreen_content_css;e.height=tinymce.isIE?h.scrollHeight:h.offsetHeight;tinymce.each(a.getParam("wp_fullscreen_settings"),function(m,l){e[l]=m});i=new tinymce.Editor("wp_mce_fullscreen",e);i.onInit.add(function(k){var m=tinymce.DOM,l=m.select("a.mceButton",m.get("wp-fullscreen-buttons"));if(!a.isHidden()){k.setContent(a.getContent())}else{k.setContent(switchEditors.wpautop(k.getElement().value))}setTimeout(function(){k.onNodeChange.add(function(o,n,p){tinymce.each(l,function(s){var r,q;if(r=m.get("wp_mce_fullscreen_"+s.id.substr(6))){q=r.className;if(q){s.className=q}}})})},1000);k.focus()});i.render();i.dom.bind(i.getWin(),"mousemove",function(k){if(!fullscreen.settings.toolbar_shown){fullscreen.bounder("showToolbar","hideToolbar",2000)}})});if("undefined"!=fullscreen){a.addButton("fullscreen",{title:"fullscreen.desc",onclick:function(){fullscreen.on()}})}if(a.getParam("fullscreen_is_enabled")||!a.getParam("wp_fullscreen_is_enabled")){return}function b(){var k=a.getDoc(),h=k.body,m=k.documentElement,j=tinymce.DOM,l,i;if(tinymce.isIE){i=h.scrollHeight}else{if(tinymce.isWebKit){i=h.offsetHeight}else{i=m.offsetHeight}}l=(i>300)?i:300;if(g!=l){g=l;j.setStyle(j.get(a.id+"_ifr"),"height",l+"px")}}a.onInit.add(function(i,h){i.onChange.add(b);i.onSetContent.add(b);i.onPaste.add(b);i.onKeyUp.add(b);i.onPostRender.add(b);i.getBody().style.overflowY="hidden"});if(a.getParam("autoresize_on_init",true)){a.onLoadContent.add(function(i,h){setTimeout(function(){b()},1200)})}a.addCommand("wpAutoResize",b)},getInfo:function(){return{longname:"WP Fullscreen",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpfullscreen",tinymce.plugins.wpFullscreenPlugin)})();
(function(){tinymce.create("tinymce.plugins.wpFullscreenPlugin",{init:function(b,d){var e=this,h=0,f={},g=tinymce.DOM,a=false;b.addCommand("wpFullScreenClose",function(){if(b.getParam("wp_fullscreen_is_enabled")){g.win.setTimeout(function(){tinyMCE.remove(b);g.remove("wp_mce_fullscreen_parent");tinyMCE.settings=tinyMCE.oldSettings},10)}});b.addCommand("wpFullScreenSave",function(){var i=tinyMCE.get("wp_mce_fullscreen"),j;i.focus();j=tinyMCE.get(i.getParam("wp_fullscreen_editor_id"));j.setContent(i.getContent({format:"raw"}),{format:"raw"})});b.addCommand("wpFullScreenInit",function(){var k=b.getDoc(),i=k.body,j;if(b.id=="wp_mce_fullscreen"){return}tinyMCE.oldSettings=tinyMCE.settings;tinymce.each(b.settings,function(l,m){f[m]=l});f.id="wp_mce_fullscreen";f.wp_fullscreen_is_enabled=true;f.wp_fullscreen_editor_id=b.id;f.theme_advanced_resizing=false;f.theme_advanced_statusbar_location="none";f.content_css=f.content_css+","+f.wp_fullscreen_content_css;f.height=tinymce.isIE?i.scrollHeight:i.offsetHeight;tinymce.each(b.getParam("wp_fullscreen_settings"),function(m,l){f[l]=m});j=new tinymce.Editor("wp_mce_fullscreen",f);j.onInit.add(function(l){var n=tinymce.DOM,m=n.select("a.mceButton",n.get("wp-fullscreen-buttons"));if(!b.isHidden()){l.setContent(b.getContent())}else{l.setContent(switchEditors.wpautop(l.getElement().value))}setTimeout(function(){l.onNodeChange.add(function(p,o,q){tinymce.each(m,function(t){var s,r;if(s=n.get("wp_mce_fullscreen_"+t.id.substr(6))){r=s.className;if(r){t.className=r}}})})},1000);l.dom.addClass(l.getBody(),"wp-fullscreen-editor");l.focus()});j.render();j.dom.bind(j.dom.doc,"mousemove",function(l){if("undefined"!=fullscreen){fullscreen.bounder("showToolbar","hideToolbar",2000)}})});if("undefined"!=fullscreen){b.addButton("fullscreen",{title:"fullscreen.desc",onclick:function(){fullscreen.on()}})}if(b.getParam("fullscreen_is_enabled")||!b.getParam("wp_fullscreen_is_enabled")){return}function c(){if(a){return}var k=b.getDoc(),j=tinymce.DOM,l,i;if(tinymce.isIE){i=k.body.scrollHeight}else{if(tinymce.isWebKit){i=k.height}else{i=k.documentElement.offsetHeight}}l=(i>300)?i:300;if(h!=l){h=l;a=true;setTimeout(function(){a=false},100);j.setStyle(j.get(b.id+"_ifr"),"height",l+"px")}}b.onInit.add(function(j,i){j.onChange.add(c);j.onSetContent.add(c);j.onPaste.add(c);j.onKeyUp.add(c);j.onPostRender.add(c);j.getBody().style.overflowY="hidden"});if(b.getParam("autoresize_on_init",true)){b.onLoadContent.add(function(j,i){setTimeout(function(){c()},1200)})}b.addCommand("wpAutoResize",c)},getInfo:function(){return{longname:"WP Fullscreen",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpfullscreen",tinymce.plugins.wpFullscreenPlugin)})();

View File

@ -1,7 +1,12 @@
body, td, pre {color:#000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; margin:8px;}
body {background:#FFF;}
body {
font: 13px/19px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
margin: 0.6em;
background: #fff;
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;}
h1 {font-size: 2em}
h2 {font-size: 1.5em}
h3 {font-size: 1.17em}
@ -63,6 +68,10 @@ dl.aligncenter {
border-radius: 3px;
}
.mceIEcenter {
text-align: center;
}
.wp-caption img {
margin: 0;
padding: 0;
@ -76,13 +85,8 @@ dl.aligncenter {
margin: 0;
}
body.mceContentBody {
font: 13px/19px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
margin: 0.6em;
}
pre {
font: 12px/18px Consolas, Monaco, "Courier New", Courier, monospace;
font: 12px/18px Consolas, Monaco, monospace;
}
td {
@ -91,6 +95,3 @@ td {
margin: 8px;
}
.mceIEcenter {
text-align: center;
}

View File

@ -36,7 +36,7 @@ $wp_db_version = 17517;
*
* @global string $tinymce_version
*/
$tinymce_version = '342-20110603';
$tinymce_version = '342-20110604';
/**
* Holds the cache manifest version