mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
Editor scrolling:
- Improve TinyMCE resizing when a floated block is at the end of the content. - Improve setting the padding/margin under the toolbar on loading. - Add custom event on TinyMCE resizing and use it to adjust the pinning (if needed). Part props avryl, see #28328. Built from https://develop.svn.wordpress.org/trunk@29279 git-svn-id: http://core.svn.wordpress.org/trunk@29061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
795c97d08b
commit
da0b98a8f0
@ -378,6 +378,24 @@ td.plugin-title p {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wp-fullscreen-wrap #content-textarea-clone {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* editor-expand.js override */
|
||||
.wp-fullscreen-wrap {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
|
||||
.wp-fullscreen-wrap .wp-editor-area {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
.wp-fullscreen-wrap .mce-edit-area {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
/* end editor-expand.js override */
|
||||
|
||||
#timestampdiv select {
|
||||
height: 21px;
|
||||
line-height: 14px;
|
||||
|
@ -378,6 +378,24 @@ td.plugin-title p {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wp-fullscreen-wrap #content-textarea-clone {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* editor-expand.js override */
|
||||
.wp-fullscreen-wrap {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
|
||||
.wp-fullscreen-wrap .wp-editor-area {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
.wp-fullscreen-wrap .mce-edit-area {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
/* end editor-expand.js override */
|
||||
|
||||
#timestampdiv select {
|
||||
height: 21px;
|
||||
line-height: 14px;
|
||||
|
2
wp-admin/css/wp-admin-rtl.min.css
vendored
2
wp-admin/css/wp-admin-rtl.min.css
vendored
File diff suppressed because one or more lines are too long
2
wp-admin/css/wp-admin.min.css
vendored
2
wp-admin/css/wp-admin.min.css
vendored
File diff suppressed because one or more lines are too long
@ -41,20 +41,26 @@ jQuery( document ).ready( function($) {
|
||||
textEditorResize();
|
||||
} );
|
||||
|
||||
$textEditor.on( 'keyup', function() {
|
||||
var range = document.createRange(),
|
||||
start = $textEditor[0].selectionStart,
|
||||
end = $textEditor[0].selectionEnd,
|
||||
$textEditor.on( 'keyup', function( event ) {
|
||||
var VK = jQuery.ui.keyCode,
|
||||
key = event.keyCode,
|
||||
range = document.createRange(),
|
||||
selStart = $textEditor[0].selectionStart,
|
||||
selEnd = $textEditor[0].selectionEnd,
|
||||
textNode = $textEditorClone[0].firstChild,
|
||||
windowHeight = $window.height(),
|
||||
buffer = 10,
|
||||
offset, cursorTop, cursorBottom, editorTop, editorBottom;
|
||||
|
||||
if ( start && end && start !== end ) {
|
||||
if ( selStart && selEnd && selStart !== selEnd ) {
|
||||
return;
|
||||
}
|
||||
|
||||
range.setStart( textNode, start );
|
||||
range.setEnd( textNode, end + 1 );
|
||||
// These are not TinyMCE ranges.
|
||||
try {
|
||||
range.setStart( textNode, selStart );
|
||||
range.setEnd( textNode, selEnd + 1 );
|
||||
} catch ( ex ) {}
|
||||
|
||||
offset = range.getBoundingClientRect();
|
||||
|
||||
@ -62,13 +68,15 @@ jQuery( document ).ready( function($) {
|
||||
return;
|
||||
}
|
||||
|
||||
cursorTop = offset.top;
|
||||
cursorBottom = cursorTop + offset.height;
|
||||
editorTop = $adminBar.outerHeight() + $textTop.outerHeight();
|
||||
cursorTop = offset.top - buffer;
|
||||
cursorBottom = cursorTop + offset.height + buffer;
|
||||
editorTop = $adminBar.outerHeight() + $tools.outerHeight() + $textTop.outerHeight();
|
||||
editorBottom = windowHeight - $bottom.outerHeight();
|
||||
|
||||
if ( cursorTop < editorTop || cursorBottom > editorBottom ) {
|
||||
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - windowHeight / 2 );
|
||||
if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
|
||||
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
|
||||
} else if ( cursorBottom > editorBottom ) {
|
||||
window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
|
||||
}
|
||||
} );
|
||||
|
||||
@ -77,8 +85,13 @@ jQuery( document ).ready( function($) {
|
||||
return;
|
||||
}
|
||||
|
||||
var hiddenHeight = $textEditorClone.width( $textEditor.width() ).text( $textEditor.val() + ' ' ).height(),
|
||||
textEditorHeight = $textEditor.height();
|
||||
var textEditorHeight = $textEditor.height(),
|
||||
hiddenHeight;
|
||||
|
||||
$textEditorClone.width( $textEditor.width() );
|
||||
$textEditorClone.text( $textEditor.val() + ' ' );
|
||||
|
||||
hiddenHeight = $textEditorClone.height();
|
||||
|
||||
if ( hiddenHeight < 300 ) {
|
||||
hiddenHeight = 300;
|
||||
@ -90,7 +103,7 @@ jQuery( document ).ready( function($) {
|
||||
|
||||
$textEditor.height( hiddenHeight );
|
||||
|
||||
adjust( 'resize' );
|
||||
adjust();
|
||||
}
|
||||
|
||||
// We need to wait for TinyMCE to initialize.
|
||||
@ -103,9 +116,6 @@ jQuery( document ).ready( function($) {
|
||||
// Copy the editor instance.
|
||||
editorInstance = editor;
|
||||
|
||||
// Resizing will be handled by the autoresize plugin.
|
||||
editor.theme.resizeTo = function() {};
|
||||
|
||||
// Set the minimum height to the initial viewport height.
|
||||
editor.settings.autoresize_min_height = 300;
|
||||
|
||||
@ -118,8 +128,8 @@ jQuery( document ).ready( function($) {
|
||||
editor.on( 'show', function() {
|
||||
setTimeout( function() {
|
||||
editor.execCommand( 'wpAutoResize' );
|
||||
adjust( 'resize' );
|
||||
}, 200 );
|
||||
adjust();
|
||||
}, 300 );
|
||||
} );
|
||||
|
||||
// Make sure the cursor is always visible.
|
||||
@ -195,58 +205,21 @@ jQuery( document ).ready( function($) {
|
||||
|
||||
editor.on( 'hide', function() {
|
||||
textEditorResize();
|
||||
adjust( 'resize' );
|
||||
adjust();
|
||||
} );
|
||||
|
||||
// Adjust when the editor resizes.
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', function() {
|
||||
adjust( 'resize' );
|
||||
} );
|
||||
|
||||
editor.on( 'wp-toolbar-toggle', function() {
|
||||
$visualEditor.css( {
|
||||
paddingTop: $visualTop.outerHeight()
|
||||
} );
|
||||
editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', function() {
|
||||
adjust();
|
||||
} );
|
||||
|
||||
// And adjust "immediately".
|
||||
// Allow some time to load CSS etc.
|
||||
setTimeout( function() {
|
||||
$visualEditor.css( {
|
||||
paddingTop: $visualTop.outerHeight()
|
||||
} );
|
||||
|
||||
adjust( 'resize' );
|
||||
}, 500 );
|
||||
} );
|
||||
|
||||
// Adjust when the window is scrolled or resized.
|
||||
$window.on( 'scroll resize', function( event ) {
|
||||
adjust( event.type );
|
||||
} );
|
||||
|
||||
// Adjust when exiting fullscreen mode.
|
||||
fullscreen && fullscreen.pubsub.subscribe( 'hidden', function() {
|
||||
adjust( 'resize' );
|
||||
} );
|
||||
|
||||
// Adjust when collapsing the menu.
|
||||
$document.on( 'wp-collapse-menu.editor-expand', function() {
|
||||
adjust( 'resize' );
|
||||
} )
|
||||
|
||||
// Adjust when changing the columns.
|
||||
.on( 'postboxes-columnchange.editor-expand', function() {
|
||||
adjust( 'resize' );
|
||||
} )
|
||||
|
||||
// Adjust when changing the body class.
|
||||
.on( 'editor-classchange.editor-expand', function() {
|
||||
adjust( 'resize' );
|
||||
initialResize( adjust );
|
||||
} );
|
||||
|
||||
// Adjust the toolbars based on the active editor mode.
|
||||
function adjust( eventType ) {
|
||||
function adjust( type ) {
|
||||
// Make sure we're not in fullscreen mode.
|
||||
if ( fullscreen && fullscreen.settings.visible ) {
|
||||
return;
|
||||
@ -257,22 +230,14 @@ jQuery( document ).ready( function($) {
|
||||
windowHeight = $window.height(),
|
||||
windowWidth = $window.width(),
|
||||
adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0,
|
||||
$top, $editor, visual,
|
||||
resize = type !== 'scroll',
|
||||
visual = ( editorInstance && ! editorInstance.isHidden() ),
|
||||
$top, $editor,
|
||||
toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight;
|
||||
|
||||
// Visual editor.
|
||||
if ( editorInstance && ! editorInstance.isHidden() ) {
|
||||
if ( visual ) {
|
||||
$top = $visualTop;
|
||||
$editor = $visualEditor;
|
||||
visual = true;
|
||||
|
||||
// Doesn't hide the panel of 'styleselect'. :(
|
||||
tinymce.each( editorInstance.controlManager.buttons, function( button ) {
|
||||
if ( button._active && ( button.type === 'colorbutton' || button.type === 'panelbutton' || button.type === 'menubutton' ) ) {
|
||||
button.hidePanel();
|
||||
}
|
||||
} );
|
||||
// Text editor.
|
||||
} else {
|
||||
$top = $textTop;
|
||||
$editor = $textEditor;
|
||||
@ -287,7 +252,7 @@ jQuery( document ).ready( function($) {
|
||||
statusBarHeight = visual ? $statusBar.outerHeight() : 0;
|
||||
|
||||
// Maybe pin the top.
|
||||
if ( ( ! fixedTop || eventType === 'resize' ) &&
|
||||
if ( ( ! fixedTop || resize ) &&
|
||||
// Handle scrolling down.
|
||||
( windowPos >= ( topPos - toolsHeight - adminBarHeight ) &&
|
||||
// Handle scrolling up.
|
||||
@ -307,7 +272,7 @@ jQuery( document ).ready( function($) {
|
||||
width: editorWidth + 2
|
||||
} );
|
||||
// Maybe unpin the top.
|
||||
} else if ( fixedTop || eventType === 'resize' ) {
|
||||
} else if ( fixedTop || resize ) {
|
||||
// Handle scrolling up.
|
||||
if ( windowPos <= ( topPos - toolsHeight - adminBarHeight ) ) {
|
||||
fixedTop = false;
|
||||
@ -342,7 +307,7 @@ jQuery( document ).ready( function($) {
|
||||
}
|
||||
|
||||
// Maybe adjust the bottom bar.
|
||||
if ( ( ! fixedBottom || eventType === 'resize' ) &&
|
||||
if ( ( ! fixedBottom || resize ) &&
|
||||
// + 1 for the border around the .wp-editor-container.
|
||||
( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1 ) ) {
|
||||
fixedBottom = true;
|
||||
@ -353,7 +318,7 @@ jQuery( document ).ready( function($) {
|
||||
width: editorWidth + 2,
|
||||
borderTop: '1px solid #dedede'
|
||||
} );
|
||||
} else if ( fixedBottom &&
|
||||
} else if ( ( fixedBottom || resize ) &&
|
||||
( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1 ) ) {
|
||||
fixedBottom = false;
|
||||
|
||||
@ -364,24 +329,50 @@ jQuery( document ).ready( function($) {
|
||||
borderTop: 'none'
|
||||
} );
|
||||
}
|
||||
|
||||
if ( resize ) {
|
||||
$contentWrap.css( {
|
||||
paddingTop: $tools.outerHeight()
|
||||
} );
|
||||
|
||||
if ( visual ) {
|
||||
$visualEditor.css( {
|
||||
paddingTop: $visualTop.outerHeight()
|
||||
} );
|
||||
} else {
|
||||
$textEditor.css( {
|
||||
marginTop: $textTop.outerHeight()
|
||||
} );
|
||||
$textEditorClone.width( $textEditor.width() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
textEditorResize();
|
||||
function initialResize( callback ) {
|
||||
for ( var i = 1; i < 6; i++ ) {
|
||||
setTimeout( callback, 500 * i );
|
||||
}
|
||||
}
|
||||
|
||||
$tools.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
width: $contentWrap.width()
|
||||
// Adjust when the window is scrolled or resized.
|
||||
$window.on( 'scroll.editor-expand resize.editor-expand', function( event ) {
|
||||
adjust( event.type );
|
||||
} );
|
||||
|
||||
$contentWrap.css( {
|
||||
paddingTop: $tools.outerHeight()
|
||||
// Adjust when entering/exiting fullscreen mode.
|
||||
fullscreen && fullscreen.pubsub.subscribe( 'hidden', function() {
|
||||
textEditorResize();
|
||||
adjust();
|
||||
} );
|
||||
|
||||
// This needs to execute after quicktags is ready or a button is added...
|
||||
setTimeout( function() {
|
||||
$textEditor.css( {
|
||||
paddingTop: $textTop.outerHeight() + parseInt( $textEditor.css( 'padding-top' ), 10 )
|
||||
// Adjust when collapsing the menu, changing the columns, changing the body class.
|
||||
$document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust );
|
||||
|
||||
// Ideally we need to resize just after CSS has fully loaded and QuickTags is ready.
|
||||
if ( $contentWrap.hasClass( 'html-active' ) ) {
|
||||
initialResize( function() {
|
||||
adjust();
|
||||
textEditorResize();
|
||||
} );
|
||||
}, 500 );
|
||||
}
|
||||
});
|
||||
|
2
wp-admin/js/editor-expand.min.js
vendored
2
wp-admin/js/editor-expand.min.js
vendored
@ -1 +1 @@
|
||||
window.wp=window.wp||{},jQuery(document).ready(function(a){function b(){if(!g||g.isHidden()){var a=o.width(n.width()).text(n.val()+" ").height(),b=n.height();300>a&&(a=300),a!==b&&(n.height(a),c("resize"))}}function c(a){if(!r||!r.settings.visible){var b,c,i,o,u,v,w,x,y,z,A=p.outerHeight(),B=h.scrollTop(),C=h.height(),D=h.width(),E=D>600?j.height():0;g&&!g.isHidden()?(b=d,c=e,i=!0,tinymce.each(g.controlManager.buttons,function(a){!a._active||"colorbutton"!==a.type&&"panelbutton"!==a.type&&"menubutton"!==a.type||a.hidePanel()})):(b=m,c=n),o=l.outerHeight(),u=b.parent().offset().top,v=b.outerHeight(),w=c.offset().top,x=c.outerHeight(),y=c.outerWidth(),z=i?f.outerHeight():0,(!s||"resize"===a)&&B>=u-o-E&&u-o-E+x-q>=B?(s=!0,b.css({position:"fixed",top:E+o,width:c.parent().width()-(b.outerWidth()-b.width()),borderTop:"1px solid #e5e5e5"}),l.css({position:"fixed",top:E,width:y+2})):(s||"resize"===a)&&(u-o-E>=B?(s=!1,b.css({position:"absolute",top:0,borderTop:"none",width:c.parent().width()-(b.outerWidth()-b.width())}),l.css({position:"absolute",top:0,width:k.width()})):B>=u-o-E+x-q&&(s=!1,b.css({position:"absolute",top:x-q}),l.css({position:"absolute",top:x-q+1,width:k.width()}))),(!t||"resize"===a)&&w+x+A+z+1>=B+C?(t=!0,p.css({position:"fixed",bottom:0,width:y+2,borderTop:"1px solid #dedede"})):t&&B+C>w+x+A+z-1&&(t=!1,p.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"}))}}var d,e,f,g,h=a(window),i=a(document),j=a("#wpadminbar"),k=a("#wp-content-wrap"),l=a("#wp-content-editor-tools"),m=a("#ed_toolbar"),n=a("#content"),o=a('<div id="content-textarea-clone"></div>'),p=a("#post-status-info"),q=200,r=window.wp.editor&&window.wp.editor.fullscreen,s=!1,t=!1;o.insertAfter(n),k.addClass("wp-editor-expand"),a("#content-resize-handle").hide(),o.css({"font-family":n.css("font-family"),"font-size":n.css("font-size"),"line-height":n.css("line-height"),padding:n.css("padding"),"padding-top":37,"white-space":"pre-wrap","word-wrap":"break-word"}),n.on("focus input propertychange",function(){b()}),n.on("keyup",function(){var a,b,c,d,e,f=document.createRange(),g=n[0].selectionStart,i=n[0].selectionEnd,k=o[0].firstChild,l=h.height();g&&i&&g!==i||(f.setStart(k,g),f.setEnd(k,i+1),a=f.getBoundingClientRect(),a.height&&(b=a.top,c=b+a.height,d=j.outerHeight()+m.outerHeight(),e=l-p.outerHeight(),(d>b||c>e)&&window.scrollTo(window.pageXOffset,b+window.pageYOffset-l/2)))}),i.on("tinymce-editor-init.editor-expand",function(a,i){function m(){var a,b,c,d=i.selection,e=d.getNode(),f=d.getRng();if(!(tinymce.Env.ie&&tinymce.Env.ie<9)&&(i.plugins.wpview&&(a=i.plugins.wpview.getView(e))?c=a.getBoundingClientRect():d.isCollapsed()?(b=f.cloneRange(),b.startContainer.length>1?(b.startContainer.length>b.endOffset?b.setEnd(b.startContainer,b.endOffset+1):b.setStart(b.startContainer,b.endOffset-1),d.setRng(b),c=d.getRng().getBoundingClientRect(),d.setRng(f)):c=e.getBoundingClientRect()):c=f.getBoundingClientRect(),c.height))return c}"content"===i.id&&(g=i,i.theme.resizeTo=function(){},i.settings.autoresize_min_height=300,d=k.find(".mce-toolbar-grp"),e=k.find(".mce-edit-area"),f=k.find(".mce-statusbar").filter(":visible"),i.on("show",function(){setTimeout(function(){i.execCommand("wpAutoResize"),c("resize")},200)}),i.on("keyup",function(a){var b,c,e,f,g=tinymce.util.VK,k=a.keyCode,n=m(),o=h.height(),q=10;n&&(b=n.top+i.getContentAreaContainer().getElementsByTagName("iframe")[0].getBoundingClientRect().top,c=b+n.height,b-=q,c+=q,e=j.outerHeight()+l.outerHeight()+d.outerHeight(),f=o-p.outerHeight(),e>b&&(k===g.UP||k===g.LEFT||k===g.BACKSPACE)?window.scrollTo(window.pageXOffset,b+window.pageYOffset-e):c>f&&window.scrollTo(window.pageXOffset,c+window.pageYOffset-f))}),i.on("hide",function(){b(),c("resize")}),i.on("nodechange setcontent keyup FullscreenStateChanged",function(){c("resize")}),i.on("wp-toolbar-toggle",function(){e.css({paddingTop:d.outerHeight()})}),setTimeout(function(){e.css({paddingTop:d.outerHeight()}),c("resize")},500))}),h.on("scroll resize",function(a){c(a.type)}),r&&r.pubsub.subscribe("hidden",function(){c("resize")}),i.on("wp-collapse-menu.editor-expand",function(){c("resize")}).on("postboxes-columnchange.editor-expand",function(){c("resize")}).on("editor-classchange.editor-expand",function(){c("resize")}),b(),l.css({position:"absolute",top:0,width:k.width()}),k.css({paddingTop:l.outerHeight()}),setTimeout(function(){n.css({paddingTop:m.outerHeight()+parseInt(n.css("padding-top"),10)})},500)});
|
||||
window.wp=window.wp||{},jQuery(document).ready(function(a){function b(){if(!h||h.isHidden()){var a,b=o.height();p.width(o.width()),p.text(o.val()+" "),a=p.height(),300>a&&(a=300),a!==b&&(o.height(a),c())}}function c(a){if(!s||!s.settings.visible){var b,c,d,j,v,w,x,y,z,A=q.outerHeight(),B=i.scrollTop(),C=i.height(),D=i.width(),E=D>600?k.height():0,F="scroll"!==a,G=h&&!h.isHidden();G?(b=e,c=f):(b=n,c=o),d=m.outerHeight(),j=b.parent().offset().top,v=b.outerHeight(),w=c.offset().top,x=c.outerHeight(),y=c.outerWidth(),z=G?g.outerHeight():0,(!t||F)&&B>=j-d-E&&j-d-E+x-r>=B?(t=!0,b.css({position:"fixed",top:E+d,width:c.parent().width()-(b.outerWidth()-b.width()),borderTop:"1px solid #e5e5e5"}),m.css({position:"fixed",top:E,width:y+2})):(t||F)&&(j-d-E>=B?(t=!1,b.css({position:"absolute",top:0,borderTop:"none",width:c.parent().width()-(b.outerWidth()-b.width())}),m.css({position:"absolute",top:0,width:l.width()})):B>=j-d-E+x-r&&(t=!1,b.css({position:"absolute",top:x-r}),m.css({position:"absolute",top:x-r+1,width:l.width()}))),(!u||F)&&w+x+A+z+1>=B+C?(u=!0,q.css({position:"fixed",bottom:0,width:y+2,borderTop:"1px solid #dedede"})):(u||F)&&B+C>w+x+A+z-1&&(u=!1,q.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"})),F&&(l.css({paddingTop:m.outerHeight()}),G?f.css({paddingTop:e.outerHeight()}):(o.css({marginTop:n.outerHeight()}),p.width(o.width())))}}function d(a){for(var b=1;6>b;b++)setTimeout(a,500*b)}var e,f,g,h,i=a(window),j=a(document),k=a("#wpadminbar"),l=a("#wp-content-wrap"),m=a("#wp-content-editor-tools"),n=a("#ed_toolbar"),o=a("#content"),p=a('<div id="content-textarea-clone"></div>'),q=a("#post-status-info"),r=200,s=window.wp.editor&&window.wp.editor.fullscreen,t=!1,u=!1;p.insertAfter(o),l.addClass("wp-editor-expand"),a("#content-resize-handle").hide(),p.css({"font-family":o.css("font-family"),"font-size":o.css("font-size"),"line-height":o.css("line-height"),padding:o.css("padding"),"padding-top":37,"white-space":"pre-wrap","word-wrap":"break-word"}),o.on("focus input propertychange",function(){b()}),o.on("keyup",function(a){var b,c,d,e,f,g=jQuery.ui.keyCode,h=a.keyCode,j=document.createRange(),l=o[0].selectionStart,r=o[0].selectionEnd,s=p[0].firstChild,t=i.height(),u=10;if(!l||!r||l===r){try{j.setStart(s,l),j.setEnd(s,r+1)}catch(v){}b=j.getBoundingClientRect(),b.height&&(c=b.top-u,d=c+b.height+u,e=k.outerHeight()+m.outerHeight()+n.outerHeight(),f=t-q.outerHeight(),e>c&&(h===g.UP||h===g.LEFT||h===g.BACKSPACE)?window.scrollTo(window.pageXOffset,c+window.pageYOffset-e):d>f&&window.scrollTo(window.pageXOffset,d+window.pageYOffset-f))}}),j.on("tinymce-editor-init.editor-expand",function(a,j){function n(){var a,b,c,d=j.selection,e=d.getNode(),f=d.getRng();if(!(tinymce.Env.ie&&tinymce.Env.ie<9)&&(j.plugins.wpview&&(a=j.plugins.wpview.getView(e))?c=a.getBoundingClientRect():d.isCollapsed()?(b=f.cloneRange(),b.startContainer.length>1?(b.startContainer.length>b.endOffset?b.setEnd(b.startContainer,b.endOffset+1):b.setStart(b.startContainer,b.endOffset-1),d.setRng(b),c=d.getRng().getBoundingClientRect(),d.setRng(f)):c=e.getBoundingClientRect()):c=f.getBoundingClientRect(),c.height))return c}"content"===j.id&&(h=j,j.settings.autoresize_min_height=300,e=l.find(".mce-toolbar-grp"),f=l.find(".mce-edit-area"),g=l.find(".mce-statusbar").filter(":visible"),j.on("show",function(){setTimeout(function(){j.execCommand("wpAutoResize"),c()},300)}),j.on("keyup",function(a){var b,c,d,f,g=tinymce.util.VK,h=a.keyCode,l=n(),o=i.height(),p=10;l&&(b=l.top+j.getContentAreaContainer().getElementsByTagName("iframe")[0].getBoundingClientRect().top,c=b+l.height,b-=p,c+=p,d=k.outerHeight()+m.outerHeight()+e.outerHeight(),f=o-q.outerHeight(),d>b&&(h===g.UP||h===g.LEFT||h===g.BACKSPACE)?window.scrollTo(window.pageXOffset,b+window.pageYOffset-d):c>f&&window.scrollTo(window.pageXOffset,c+window.pageYOffset-f))}),j.on("hide",function(){b(),c()}),j.on("setcontent wp-autoresize wp-toolbar-toggle",function(){c()}),d(c))}),i.on("scroll.editor-expand resize.editor-expand",function(a){c(a.type)}),s&&s.pubsub.subscribe("hidden",function(){b(),c()}),j.on("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",c),l.hasClass("html-active")&&d(function(){c(),b()})});
|
@ -42,6 +42,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = e || {};
|
||||
body = doc.body;
|
||||
docElm = doc.documentElement;
|
||||
resizeHeight = settings.autoresize_min_height;
|
||||
@ -60,6 +61,11 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
marginBottom = editor.dom.getStyle( body, 'margin-bottom', true );
|
||||
myHeight = body.offsetHeight + parseInt( marginTop, 10 ) + parseInt( marginBottom, 10 );
|
||||
|
||||
// IE < 11, other?
|
||||
if ( myHeight && myHeight < docElm.offsetHeight ) {
|
||||
myHeight = docElm.offsetHeight;
|
||||
}
|
||||
|
||||
// Make sure we have a valid height
|
||||
if ( isNaN( myHeight ) || myHeight <= 0 ) {
|
||||
// Get height differently depending on the browser used
|
||||
@ -93,6 +99,8 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
if ( tinymce.isWebKit && deltaSize < 0 ) {
|
||||
resize( e );
|
||||
}
|
||||
|
||||
editor.fire( 'wp-autoresize', { height: resizeHeight } );
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +110,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
*/
|
||||
function wait( times, interval, callback ) {
|
||||
setTimeout( function() {
|
||||
resize({});
|
||||
resize();
|
||||
|
||||
if ( times-- ) {
|
||||
wait( times, interval, callback );
|
||||
@ -123,14 +131,20 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
// Add appropriate listeners for resizing the content area
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
resize();
|
||||
}
|
||||
}
|
||||
|
||||
function off() {
|
||||
var doc;
|
||||
|
||||
// Don't turn off if the setting is 'on'
|
||||
if ( ! settings.wp_autoresize_on ) {
|
||||
doc = editor.getDoc();
|
||||
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
|
||||
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
doc.body.style.overflowY = 'auto';
|
||||
doc.documentElement.style.overflowY = 'auto'; // Old IE
|
||||
oldSize = 0;
|
||||
}
|
||||
}
|
||||
@ -158,6 +172,11 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the stored size
|
||||
editor.on( 'show', function() {
|
||||
oldSize = 0;
|
||||
});
|
||||
|
||||
// Register the command
|
||||
editor.addCommand( 'wpAutoResize', resize );
|
||||
|
||||
|
@ -1 +1 @@
|
||||
tinymce.PluginManager.add("wpautoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(d){var e,f,i,j,k,l,m,n,o=tinymce.DOM;if(f=a.getDoc()){if(i=f.body,j=f.documentElement,k=g.autoresize_min_height,!i||d&&"setcontent"===d.type&&d.initial||b())return void(i&&j&&(i.style.overflowY="auto",j.style.overflowY="auto"));m=a.dom.getStyle(i,"margin-top",!0),n=a.dom.getStyle(i,"margin-bottom",!0),l=i.offsetHeight+parseInt(m,10)+parseInt(n,10),(isNaN(l)||0>=l)&&(l=tinymce.Env.ie?i.scrollHeight:tinymce.Env.webkit&&0===i.clientHeight?0:i.offsetHeight),l>g.autoresize_min_height&&(k=l),g.autoresize_max_height&&l>g.autoresize_max_height?(k=g.autoresize_max_height,i.style.overflowY="auto",j.style.overflowY="auto"):(i.style.overflowY="hidden",j.style.overflowY="hidden",i.scrollTop=0),k!==h&&(e=k-h,o.setStyle(o.get(a.id+"_ifr"),"height",k+"px"),h=k,tinymce.isWebKit&&0>e&&c(d))}}function d(a,b,e){setTimeout(function(){c({}),a--?d(a,b,e):e&&e()},b)}function e(){a.dom.hasClass(a.getBody(),"wp-autoresize")||(a.dom.addClass(a.getBody(),"wp-autoresize"),a.on("nodechange setcontent keyup FullscreenStateChanged",c))}function f(){g.wp_autoresize_on||(a.dom.removeClass(a.getBody(),"wp-autoresize"),a.off("nodechange setcontent keyup FullscreenStateChanged",c),h=0)}var g=a.settings,h=0;a.settings.inline||(g.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),g.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),g.wp_autoresize_on&&(a.on("init",function(){a.dom.addClass(a.getBody(),"wp-autoresize")}),a.on("nodechange keyup FullscreenStateChanged",c),a.on("setcontent",function(){d(3,100)}),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){d(10,200,function(){d(5,1e3)})})),a.addCommand("wpAutoResize",c),a.addCommand("wpAutoResizeOn",e),a.addCommand("wpAutoResizeOff",f))});
|
||||
tinymce.PluginManager.add("wpautoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(d){var e,f,i,j,k,l,m,n,o=tinymce.DOM;if(f=a.getDoc()){if(d=d||{},i=f.body,j=f.documentElement,k=g.autoresize_min_height,!i||d&&"setcontent"===d.type&&d.initial||b())return void(i&&j&&(i.style.overflowY="auto",j.style.overflowY="auto"));m=a.dom.getStyle(i,"margin-top",!0),n=a.dom.getStyle(i,"margin-bottom",!0),l=i.offsetHeight+parseInt(m,10)+parseInt(n,10),l&&l<j.offsetHeight&&(l=j.offsetHeight),(isNaN(l)||0>=l)&&(l=tinymce.Env.ie?i.scrollHeight:tinymce.Env.webkit&&0===i.clientHeight?0:i.offsetHeight),l>g.autoresize_min_height&&(k=l),g.autoresize_max_height&&l>g.autoresize_max_height?(k=g.autoresize_max_height,i.style.overflowY="auto",j.style.overflowY="auto"):(i.style.overflowY="hidden",j.style.overflowY="hidden",i.scrollTop=0),k!==h&&(e=k-h,o.setStyle(o.get(a.id+"_ifr"),"height",k+"px"),h=k,tinymce.isWebKit&&0>e&&c(d),a.fire("wp-autoresize",{height:k}))}}function d(a,b,e){setTimeout(function(){c(),a--?d(a,b,e):e&&e()},b)}function e(){a.dom.hasClass(a.getBody(),"wp-autoresize")||(a.dom.addClass(a.getBody(),"wp-autoresize"),a.on("nodechange setcontent keyup FullscreenStateChanged",c),c())}function f(){var b;g.wp_autoresize_on||(b=a.getDoc(),a.dom.removeClass(a.getBody(),"wp-autoresize"),a.off("nodechange setcontent keyup FullscreenStateChanged",c),b.body.style.overflowY="auto",b.documentElement.style.overflowY="auto",h=0)}var g=a.settings,h=0;a.settings.inline||(g.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),g.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),g.wp_autoresize_on&&(a.on("init",function(){a.dom.addClass(a.getBody(),"wp-autoresize")}),a.on("nodechange keyup FullscreenStateChanged",c),a.on("setcontent",function(){d(3,100)}),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){d(10,200,function(){d(5,1e3)})})),a.on("show",function(){h=0}),a.addCommand("wpAutoResize",c),a.addCommand("wpAutoResizeOn",e),a.addCommand("wpAutoResizeOff",f))});
|
Binary file not shown.
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.0-beta2-20140723';
|
||||
$wp_version = '4.0-beta2-20140724';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user