mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Enhance the editor on the Add/Edit Post screens, first run. Props avril, see #28328.
Built from https://develop.svn.wordpress.org/trunk@29049 git-svn-id: http://core.svn.wordpress.org/trunk@28837 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3b291f7057
commit
5e4a020ff8
@ -37,7 +37,6 @@
|
||||
|
||||
#titlediv {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#titlediv label {
|
||||
@ -337,7 +336,7 @@ td.plugin-title p {
|
||||
background-color: #f7f7f7;
|
||||
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
||||
cursor: row-resize;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
#post-status-info td {
|
||||
@ -345,7 +344,7 @@ td.plugin-title p {
|
||||
}
|
||||
|
||||
.autosave-info {
|
||||
padding: 2px;
|
||||
padding: 2px 10px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@ -367,6 +366,18 @@ td.plugin-title p {
|
||||
padding: 2px 10px;
|
||||
}
|
||||
|
||||
#wp-content-editor-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#content-textarea-clone {
|
||||
z-index: -1;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
visibility: hidden;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#timestampdiv select {
|
||||
height: 21px;
|
||||
line-height: 14px;
|
||||
@ -1348,12 +1359,6 @@ table.links-table {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
#wp-content-editor-tools {
|
||||
overflow: hidden;
|
||||
padding: 20px 0 1px 15px;
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
a.wp-switch-editor {
|
||||
font-size: 16px;
|
||||
line-height: 1em;
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
#titlediv {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#titlediv label {
|
||||
@ -337,7 +336,7 @@ td.plugin-title p {
|
||||
background-color: #f7f7f7;
|
||||
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
||||
cursor: row-resize;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
#post-status-info td {
|
||||
@ -345,7 +344,7 @@ td.plugin-title p {
|
||||
}
|
||||
|
||||
.autosave-info {
|
||||
padding: 2px;
|
||||
padding: 2px 10px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@ -367,6 +366,18 @@ td.plugin-title p {
|
||||
padding: 2px 10px;
|
||||
}
|
||||
|
||||
#wp-content-editor-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#content-textarea-clone {
|
||||
z-index: -1;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
visibility: hidden;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#timestampdiv select {
|
||||
height: 21px;
|
||||
line-height: 14px;
|
||||
@ -1348,12 +1359,6 @@ table.links-table {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
#wp-content-editor-tools {
|
||||
overflow: hidden;
|
||||
padding: 20px 15px 1px 0;
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
a.wp-switch-editor {
|
||||
font-size: 16px;
|
||||
line-height: 1em;
|
||||
|
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
@ -11,6 +11,7 @@ if ( !defined('ABSPATH') )
|
||||
die('-1');
|
||||
|
||||
wp_enqueue_script('post');
|
||||
wp_enqueue_script('editor-expand');
|
||||
|
||||
if ( wp_is_mobile() )
|
||||
wp_enqueue_script( 'jquery-touch-punch' );
|
||||
@ -492,6 +493,7 @@ if ( post_type_supports($post_type, 'editor') ) {
|
||||
'editor_height' => 360,
|
||||
'tinymce' => array(
|
||||
'resize' => false,
|
||||
'wp_autoresize_on' => true,
|
||||
'add_unload_trigger' => false,
|
||||
),
|
||||
) ); ?>
|
||||
|
@ -179,7 +179,7 @@ $(document).ready( function() {
|
||||
});
|
||||
|
||||
$('#collapse-menu').on('click.collapse-menu', function() {
|
||||
var body = $( document.body ), respWidth;
|
||||
var body = $( document.body ), respWidth, state;
|
||||
|
||||
// reset any compensation for submenus near the bottom of the screen
|
||||
$('#adminmenu div.wp-submenu').css('margin-top', '');
|
||||
@ -197,19 +197,25 @@ $(document).ready( function() {
|
||||
body.removeClass('auto-fold').removeClass('folded');
|
||||
setUserSetting('unfold', 1);
|
||||
setUserSetting('mfold', 'o');
|
||||
state = 'open';
|
||||
} else {
|
||||
body.addClass('auto-fold');
|
||||
setUserSetting('unfold', 0);
|
||||
state = 'folded';
|
||||
}
|
||||
} else {
|
||||
if ( body.hasClass('folded') ) {
|
||||
body.removeClass('folded');
|
||||
setUserSetting('mfold', 'o');
|
||||
state = 'open';
|
||||
} else {
|
||||
body.addClass('folded');
|
||||
setUserSetting('mfold', 'f');
|
||||
state = 'folded';
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).trigger( 'wp-collapse-menu', { state: state } );
|
||||
});
|
||||
|
||||
if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
|
||||
@ -721,7 +727,7 @@ $(document).ready( function() {
|
||||
window.wpResponsive.init();
|
||||
});
|
||||
|
||||
// make Windows 8 devices playing along nicely
|
||||
// Make Windows 8 devices play along nicely.
|
||||
(function(){
|
||||
if ( '-ms-user-select' in document.documentElement.style && navigator.userAgent.match(/IEMobile\/10\.0/) ) {
|
||||
var msViewportStyle = document.createElement( 'style' );
|
||||
|
2
wp-admin/js/common.min.js
vendored
2
wp-admin/js/common.min.js
vendored
File diff suppressed because one or more lines are too long
378
wp-admin/js/editor-expand.js
Normal file
378
wp-admin/js/editor-expand.js
Normal file
@ -0,0 +1,378 @@
|
||||
|
||||
window.wp = window.wp || {};
|
||||
|
||||
jQuery( document ).ready( function($) {
|
||||
var $window = $( window ),
|
||||
$document = $( document ),
|
||||
$adminBar = $( '#wpadminbar' ),
|
||||
$contentWrap = $( '#wp-content-wrap' ),
|
||||
$tools = $( '#wp-content-editor-tools' ),
|
||||
$visualTop,
|
||||
$visualEditor,
|
||||
$textTop = $( '#ed_toolbar' ),
|
||||
$textEditor = $( '#content' ),
|
||||
$textEditorClone = $( '<div id="content-textarea-clone"></div>' ),
|
||||
$bottom = $( '#post-status-info' ),
|
||||
$statusBar,
|
||||
buffer = 200,
|
||||
adjust,
|
||||
fullscreen = window.wp.editor && window.wp.editor.fullscreen,
|
||||
editorInstance,
|
||||
fixedTop = false,
|
||||
fixedBottom = false;
|
||||
|
||||
$textEditorClone.insertAfter( $textEditor );
|
||||
|
||||
// use to enable/disable
|
||||
$contentWrap.addClass( 'wp-editor-expand' );
|
||||
$( '#content-resize-handle' ).hide();
|
||||
|
||||
$textEditorClone.css( {
|
||||
'font-family': $textEditor.css( 'font-family' ),
|
||||
'font-size': $textEditor.css( 'font-size' ),
|
||||
'line-height': $textEditor.css( 'line-height' ),
|
||||
'padding': $textEditor.css( 'padding' ),
|
||||
'padding-top': 37,
|
||||
'white-space': 'pre-wrap',
|
||||
'word-wrap': 'break-word'
|
||||
} );
|
||||
|
||||
$textEditor.on( 'focus input propertychange', function() {
|
||||
textEditorResize();
|
||||
} );
|
||||
|
||||
$textEditor.on( 'keyup', function() {
|
||||
var range = document.createRange(),
|
||||
start = $textEditor[0].selectionStart,
|
||||
end = $textEditor[0].selectionEnd,
|
||||
textNode = $textEditorClone[0].firstChild,
|
||||
windowHeight = $window.height(),
|
||||
offset, cursorTop, cursorBottom, editorTop, editorBottom;
|
||||
|
||||
if ( start && end && start !== end ) {
|
||||
return;
|
||||
}
|
||||
|
||||
range.setStart( textNode, start );
|
||||
range.setEnd( textNode, end + 1 );
|
||||
|
||||
offset = range.getBoundingClientRect();
|
||||
|
||||
if ( ! offset.height ) {
|
||||
return;
|
||||
}
|
||||
|
||||
cursorTop = offset.top;
|
||||
cursorBottom = cursorTop + offset.height;
|
||||
editorTop = $adminBar.outerHeight() + $textTop.outerHeight();
|
||||
editorBottom = windowHeight - $bottom.outerHeight();
|
||||
|
||||
if ( cursorTop < editorTop || cursorBottom > editorBottom ) {
|
||||
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - windowHeight / 2 );
|
||||
}
|
||||
} );
|
||||
|
||||
function textEditorResize() {
|
||||
if ( editorInstance && ! editorInstance.isHidden() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var hiddenHeight = $textEditorClone.width( $textEditor.width() ).text( $textEditor.val() + ' ' ).height(),
|
||||
textEditorHeight = $textEditor.height();
|
||||
|
||||
if ( hiddenHeight < 300 ) {
|
||||
hiddenHeight = 300;
|
||||
}
|
||||
|
||||
if ( hiddenHeight === textEditorHeight ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$textEditor.height( hiddenHeight );
|
||||
|
||||
adjust( 'resize' );
|
||||
}
|
||||
|
||||
// We need to wait for TinyMCE to initialize.
|
||||
$document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) {
|
||||
// Make sure it's the main editor.
|
||||
if ( editor.id !== 'content' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// Get the necessary UI elements.
|
||||
$visualTop = $contentWrap.find( '.mce-toolbar-grp' );
|
||||
$visualEditor = $contentWrap.find( '.mce-edit-area' );
|
||||
$statusBar = $contentWrap.find( '.mce-statusbar' ).filter( ':visible' );
|
||||
|
||||
// Adjust when switching editor modes.
|
||||
editor.on( 'show', function() {
|
||||
setTimeout( function() {
|
||||
editor.execCommand( 'mceAutoResize' );
|
||||
adjust( 'resize' );
|
||||
}, 200 );
|
||||
} );
|
||||
|
||||
editor.on( 'keyup', function() {
|
||||
var offset = getCursorOffset(),
|
||||
windowHeight = $window.height(),
|
||||
cursorTop, cursorBottom, editorTop, editorBottom;
|
||||
|
||||
if ( ! offset ) {
|
||||
return;
|
||||
}
|
||||
|
||||
cursorTop = offset.top + editor.getContentAreaContainer().getElementsByTagName( 'iframe' )[0].getBoundingClientRect().top;
|
||||
cursorBottom = cursorTop + offset.height;
|
||||
editorTop = $adminBar.outerHeight() + $tools.outerHeight() + $visualTop.outerHeight();
|
||||
editorBottom = $window.height() - $bottom.outerHeight();
|
||||
|
||||
if ( cursorTop < editorTop || cursorBottom > editorBottom ) {
|
||||
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - windowHeight / 2 );
|
||||
}
|
||||
} );
|
||||
|
||||
function getCursorOffset() {
|
||||
var selection = editor.selection,
|
||||
node = selection.getNode(),
|
||||
range = selection.getRng(),
|
||||
view, clone, right, offset;
|
||||
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( editor.plugins.wpview && ( view = editor.plugins.wpview.getView( node ) ) ) {
|
||||
offset = view.getBoundingClientRect();
|
||||
} else if ( selection.isCollapsed() ) {
|
||||
clone = range.cloneRange();
|
||||
|
||||
if ( clone.startContainer.length > 1 ) {
|
||||
if ( clone.startContainer.length > clone.endOffset ) {
|
||||
clone.setEnd( clone.startContainer, clone.endOffset + 1 );
|
||||
right = true;
|
||||
} else {
|
||||
clone.setStart( clone.startContainer, clone.endOffset - 1 );
|
||||
}
|
||||
|
||||
selection.setRng( clone );
|
||||
offset = selection.getRng().getBoundingClientRect();
|
||||
selection.setRng( range );
|
||||
} else {
|
||||
offset = node.getBoundingClientRect();
|
||||
}
|
||||
} else {
|
||||
offset = range.getBoundingClientRect();
|
||||
}
|
||||
|
||||
if ( ! offset.height ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
editor.on( 'hide', function() {
|
||||
textEditorResize();
|
||||
adjust( 'resize' );
|
||||
} );
|
||||
|
||||
// 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()
|
||||
} );
|
||||
} );
|
||||
|
||||
// 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' );
|
||||
} );
|
||||
|
||||
// Adjust the toolbars based on the active editor mode.
|
||||
function adjust( eventType ) {
|
||||
// Make sure we're not in fullscreen mode.
|
||||
if ( fullscreen && fullscreen.settings.visible ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bottomHeight = $bottom.outerHeight(),
|
||||
windowPos = $window.scrollTop(),
|
||||
windowHeight = $window.height(),
|
||||
windowWidth = $window.width(),
|
||||
adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0,
|
||||
$top, $editor, visual,
|
||||
toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight;
|
||||
|
||||
// Visual editor.
|
||||
if ( editorInstance && ! editorInstance.isHidden() ) {
|
||||
$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;
|
||||
}
|
||||
|
||||
toolsHeight = $tools.outerHeight();
|
||||
topPos = $top.parent().offset().top;
|
||||
topHeight = $top.outerHeight();
|
||||
editorPos = $editor.offset().top;
|
||||
editorHeight = $editor.outerHeight();
|
||||
editorWidth = $editor.outerWidth();
|
||||
statusBarHeight = visual ? $statusBar.outerHeight() : 0;
|
||||
|
||||
// Maybe pin the top.
|
||||
if ( ( ! fixedTop || eventType === 'resize' ) &&
|
||||
// Handle scrolling down.
|
||||
( windowPos >= ( topPos - toolsHeight - adminBarHeight ) &&
|
||||
// Handle scrolling up.
|
||||
windowPos <= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) ) {
|
||||
fixedTop = true;
|
||||
|
||||
$top.css( {
|
||||
position: 'fixed',
|
||||
top: adminBarHeight + toolsHeight,
|
||||
width: editorWidth - ( visual ? 0 : 38 ),
|
||||
borderTop: '1px solid #e5e5e5'
|
||||
} );
|
||||
|
||||
$tools.css( {
|
||||
position: 'fixed',
|
||||
top: adminBarHeight,
|
||||
width: editorWidth + 2
|
||||
} );
|
||||
// Maybe unpin the top.
|
||||
} else if ( fixedTop || eventType === 'resize' ) {
|
||||
// Handle scrolling up.
|
||||
if ( windowPos <= ( topPos - toolsHeight - adminBarHeight ) ) {
|
||||
fixedTop = false;
|
||||
|
||||
$top.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
borderTop: 'none',
|
||||
width: $editor.parent().width() - ( $top.outerWidth() - $top.width() )
|
||||
} );
|
||||
|
||||
$tools.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
borderTop: 'none',
|
||||
width: $contentWrap.width()
|
||||
} );
|
||||
// Handle scrolling down.
|
||||
} else if ( windowPos >= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) {
|
||||
fixedTop = false;
|
||||
|
||||
$top.css( {
|
||||
position: 'absolute',
|
||||
top: window.pageYOffset - $editor.offset().top + adminBarHeight + $tools.outerHeight(),
|
||||
borderTop: 'none'
|
||||
} );
|
||||
|
||||
$tools.css( {
|
||||
position: 'absolute',
|
||||
top: window.pageYOffset - $contentWrap.offset().top + adminBarHeight,
|
||||
borderTop: 'none',
|
||||
width: $contentWrap.width()
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe adjust the bottom bar.
|
||||
if ( ( ! fixedBottom || eventType === 'resize' ) &&
|
||||
// + 1 for the border around the .wp-editor-container.
|
||||
( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1 ) ) {
|
||||
fixedBottom = true;
|
||||
|
||||
$bottom.css( {
|
||||
position: 'fixed',
|
||||
bottom: 0,
|
||||
width: editorWidth + 2,
|
||||
borderTop: '1px solid #dedede'
|
||||
} );
|
||||
} else if ( fixedBottom &&
|
||||
( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1 ) ) {
|
||||
fixedBottom = false;
|
||||
|
||||
$bottom.css( {
|
||||
position: 'relative',
|
||||
bottom: 'auto',
|
||||
width: '100%',
|
||||
borderTop: 'none'
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
textEditorResize();
|
||||
|
||||
$tools.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
width: $contentWrap.width()
|
||||
} );
|
||||
|
||||
$contentWrap.css( {
|
||||
paddingTop: $tools.outerHeight()
|
||||
} );
|
||||
|
||||
// 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 )
|
||||
} );
|
||||
}, 500 );
|
||||
});
|
1
wp-admin/js/editor-expand.min.js
vendored
Normal file
1
wp-admin/js/editor-expand.min.js
vendored
Normal file
@ -0,0 +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:y-(i?0:38),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,borderTop:"none",width:k.width()})):B>=u-o-E+x-q&&(s=!1,b.css({position:"absolute",top:window.pageYOffset-c.offset().top+E+l.outerHeight(),borderTop:"none"}),l.css({position:"absolute",top:window.pageYOffset-k.offset().top+E,borderTop:"none",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,c,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,e=i.selection,f=e.getNode(),g=e.getRng();if(!(tinymce.Env.ie&&tinymce.Env.ie<9))return i.plugins.wpview&&(a=i.plugins.wpview.getView(f))?d=a.getBoundingClientRect():e.isCollapsed()?(b=g.cloneRange(),b.startContainer.length>1?(b.startContainer.length>b.endOffset?(b.setEnd(b.startContainer,b.endOffset+1),c=!0):b.setStart(b.startContainer,b.endOffset-1),e.setRng(b),d=e.getRng().getBoundingClientRect(),e.setRng(g)):d=f.getBoundingClientRect()):d=g.getBoundingClientRect(),d.height?d:!1}"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("mceAutoResize"),c("resize")},200)}),i.on("keyup",function(){var a,b,c,e,f=m(),g=h.height();f&&(a=f.top+i.getContentAreaContainer().getElementsByTagName("iframe")[0].getBoundingClientRect().top,b=a+f.height,c=j.outerHeight()+l.outerHeight()+d.outerHeight(),e=h.height()-p.outerHeight(),(c>a||b>e)&&window.scrollTo(window.pageXOffset,a+window.pageYOffset-g/2))}),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)});
|
@ -1004,7 +1004,8 @@ jQuery(document).ready( function($) {
|
||||
( function() {
|
||||
var editor, offset, mce,
|
||||
$textarea = $('textarea#content'),
|
||||
$handle = $('#post-status-info');
|
||||
$handle = $('#post-status-info'),
|
||||
$contentWrap = $('#wp-content-wrap');
|
||||
|
||||
// No point for touch devices
|
||||
if ( ! $textarea.length || 'ontouchstart' in window ) {
|
||||
@ -1012,6 +1013,10 @@ jQuery(document).ready( function($) {
|
||||
}
|
||||
|
||||
function dragging( event ) {
|
||||
if ( $contentWrap.hasClass( 'wp-editor-expand' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mce ) {
|
||||
editor.theme.resizeTo( null, offset + event.pageY );
|
||||
} else {
|
||||
@ -1024,6 +1029,10 @@ jQuery(document).ready( function($) {
|
||||
function endDrag() {
|
||||
var height, toolbarHeight;
|
||||
|
||||
if ( $contentWrap.hasClass( 'wp-editor-expand' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mce ) {
|
||||
editor.focus();
|
||||
toolbarHeight = parseInt( $( '#wp-content-editor-container .mce-toolbar-grp' ).height(), 10 );
|
||||
@ -1074,14 +1083,11 @@ jQuery(document).ready( function($) {
|
||||
$( '#post-formats-select input.post-format' ).on( 'change.set-editor-class', function() {
|
||||
var editor, body, format = this.id;
|
||||
|
||||
if ( format && $( this ).prop('checked') ) {
|
||||
editor = tinymce.get( 'content' );
|
||||
|
||||
if ( editor ) {
|
||||
body = editor.getBody();
|
||||
body.className = body.className.replace( /\bpost-format-[^ ]+/, '' );
|
||||
editor.dom.addClass( body, format == 'post-format-0' ? 'post-format-standard' : format );
|
||||
}
|
||||
if ( format && $( this ).prop( 'checked' ) && ( editor = tinymce.get( 'content' ) ) ) {
|
||||
body = editor.getBody();
|
||||
body.className = body.className.replace( /\bpost-format-[^ ]+/, '' );
|
||||
editor.dom.addClass( body, format == 'post-format-0' ? 'post-format-standard' : format );
|
||||
$( document ).trigger( 'editor-classchange' );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
2
wp-admin/js/post.min.js
vendored
2
wp-admin/js/post.min.js
vendored
File diff suppressed because one or more lines are too long
@ -159,6 +159,8 @@ var postboxes;
|
||||
if ( el ) {
|
||||
el.className = el.className.replace(/columns-\d+/, 'columns-' + n);
|
||||
}
|
||||
|
||||
$( document ).trigger( 'postboxes-columnchange' );
|
||||
},
|
||||
|
||||
_pb_change : function() {
|
||||
|
2
wp-admin/js/postbox.min.js
vendored
2
wp-admin/js/postbox.min.js
vendored
@ -1 +1 @@
|
||||
var postboxes;!function(a){postboxes={add_postbox_toggles:function(b,c){var d=this;d.init(b,c),a(".postbox .hndle, .postbox .handlediv").bind("click.postboxes",function(){var c=a(this).parent(".postbox"),e=c.attr("id");"dashboard_browser_nag"!=e&&(c.toggleClass("closed"),"press-this"!=b&&d.save_state(b),e&&(!c.hasClass("closed")&&a.isFunction(postboxes.pbshow)?d.pbshow(e):c.hasClass("closed")&&a.isFunction(postboxes.pbhide)&&d.pbhide(e)))}),a(".postbox .hndle a").click(function(a){a.stopPropagation()}),a(".postbox a.dismiss").bind("click.postboxes",function(){var b=a(this).parents(".postbox").attr("id")+"-hide";return a("#"+b).prop("checked",!1).triggerHandler("click"),!1}),a(".hide-postbox-tog").bind("click.postboxes",function(){var c=a(this).val();a(this).prop("checked")?(a("#"+c).show(),a.isFunction(postboxes.pbshow)&&d.pbshow(c)):(a("#"+c).hide(),a.isFunction(postboxes.pbhide)&&d.pbhide(c)),d.save_state(b),d._mark_area()}),a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var c=parseInt(a(this).val(),10);c&&(d._pb_edit(c),d.save_order(b))})},init:function(b,c){var d=a(document.body).hasClass("mobile");a.extend(this,c||{}),a("#wpbody-content").css("overflow","hidden"),a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:d?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){return a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id?void a(this).sortable("cancel"):void postboxes.save_order(b)},receive:function(b,c){"dashboard_browser_nag"==c.item[0].id&&a(c.sender).sortable("cancel"),postboxes._mark_area()}}),d&&(a(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()}),this._pb_change()),this._mark_area()},save_state:function(b){var c=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),d=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:c,hidden:d,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:b})},save_order:function(b){var c,d=a(".columns-prefs input:checked").val()||0;c={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:b},a(".meta-box-sortables").each(function(){c["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")}),a.post(ajaxurl,c)},_mark_area:function(){var b=a("div.postbox:visible").length,c=a("#post-body #side-sortables");a("#dashboard-widgets .meta-box-sortables:visible").each(function(){var c=a(this);1==b||c.children(".postbox:visible").length?c.removeClass("empty-container"):c.addClass("empty-container")}),c.length&&(c.children(".postbox:visible").length?c.removeClass("empty-container"):"280px"==a("#postbox-container-1").css("width")&&c.addClass("empty-container"))},_pb_edit:function(b){var c=a(".metabox-holder").get(0);c&&(c.className=c.className.replace(/columns-\d+/,"columns-"+b))},_pb_change:function(){var b=a('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case-90:b.length&&b.is(":checked")||this._pb_edit(2);break;case 0:case 180:a("#poststuff").length?this._pb_edit(1):b.length&&b.is(":checked")||this._pb_edit(2)}},pbshow:!1,pbhide:!1}}(jQuery);
|
||||
var postboxes;!function(a){postboxes={add_postbox_toggles:function(b,c){var d=this;d.init(b,c),a(".postbox .hndle, .postbox .handlediv").bind("click.postboxes",function(){var c=a(this).parent(".postbox"),e=c.attr("id");"dashboard_browser_nag"!=e&&(c.toggleClass("closed"),"press-this"!=b&&d.save_state(b),e&&(!c.hasClass("closed")&&a.isFunction(postboxes.pbshow)?d.pbshow(e):c.hasClass("closed")&&a.isFunction(postboxes.pbhide)&&d.pbhide(e)))}),a(".postbox .hndle a").click(function(a){a.stopPropagation()}),a(".postbox a.dismiss").bind("click.postboxes",function(){var b=a(this).parents(".postbox").attr("id")+"-hide";return a("#"+b).prop("checked",!1).triggerHandler("click"),!1}),a(".hide-postbox-tog").bind("click.postboxes",function(){var c=a(this).val();a(this).prop("checked")?(a("#"+c).show(),a.isFunction(postboxes.pbshow)&&d.pbshow(c)):(a("#"+c).hide(),a.isFunction(postboxes.pbhide)&&d.pbhide(c)),d.save_state(b),d._mark_area()}),a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var c=parseInt(a(this).val(),10);c&&(d._pb_edit(c),d.save_order(b))})},init:function(b,c){var d=a(document.body).hasClass("mobile");a.extend(this,c||{}),a("#wpbody-content").css("overflow","hidden"),a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:d?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){return a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id?void a(this).sortable("cancel"):void postboxes.save_order(b)},receive:function(b,c){"dashboard_browser_nag"==c.item[0].id&&a(c.sender).sortable("cancel"),postboxes._mark_area()}}),d&&(a(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()}),this._pb_change()),this._mark_area()},save_state:function(b){var c=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),d=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:c,hidden:d,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:b})},save_order:function(b){var c,d=a(".columns-prefs input:checked").val()||0;c={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:b},a(".meta-box-sortables").each(function(){c["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")}),a.post(ajaxurl,c)},_mark_area:function(){var b=a("div.postbox:visible").length,c=a("#post-body #side-sortables");a("#dashboard-widgets .meta-box-sortables:visible").each(function(){var c=a(this);1==b||c.children(".postbox:visible").length?c.removeClass("empty-container"):c.addClass("empty-container")}),c.length&&(c.children(".postbox:visible").length?c.removeClass("empty-container"):"280px"==a("#postbox-container-1").css("width")&&c.addClass("empty-container"))},_pb_edit:function(b){var c=a(".metabox-holder").get(0);c&&(c.className=c.className.replace(/columns-\d+/,"columns-"+b)),a(document).trigger("postboxes-columnchange")},_pb_change:function(){var b=a('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case-90:b.length&&b.is(":checked")||this._pb_edit(2);break;case 0:case 180:a("#poststuff").length?this._pb_edit(1):b.length&&b.is(":checked")||this._pb_edit(2)}},pbshow:!1,pbhide:!1}}(jQuery);
|
@ -347,6 +347,7 @@ final class _WP_Editors {
|
||||
'textcolor',
|
||||
'fullscreen',
|
||||
'wordpress',
|
||||
'wpautoresize',
|
||||
'wpeditimage',
|
||||
'wpgallery',
|
||||
'wplink',
|
||||
|
@ -148,8 +148,13 @@ div.mce-tab {
|
||||
div.mce-toolbar-grp {
|
||||
border-bottom: 1px solid #dedede;
|
||||
background: #f5f5f5;
|
||||
padding: 3px;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
div.mce-toolbar-grp > div {
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first {
|
||||
@ -161,14 +166,26 @@ div.mce-toolbar-grp {
|
||||
}
|
||||
|
||||
div.mce-statusbar {
|
||||
border-top: 1px solid #eee;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
div.mce-path {
|
||||
padding: 0 8px 2px;
|
||||
padding: 2px 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mce-path,
|
||||
.mce-path-item,
|
||||
.mce-path .mce-divider {
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.mce-path-item:focus {
|
||||
background: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.mce-toolbar .mce-btn,
|
||||
.qt-fullscreen {
|
||||
border-color: transparent;
|
||||
@ -731,7 +748,7 @@ i.mce-i-hr:before {
|
||||
}
|
||||
|
||||
.mce-i-wp_code:before {
|
||||
content: '\e017';
|
||||
content: '\f475';
|
||||
}
|
||||
|
||||
/* Editors */
|
||||
@ -740,8 +757,16 @@ i.mce-i-hr:before {
|
||||
}
|
||||
|
||||
.wp-editor-tools {
|
||||
background-color: #f1f1f1;
|
||||
padding-top: 20px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.wp-editor-tools:after {
|
||||
clear: both;
|
||||
content: '';
|
||||
display: table;
|
||||
}
|
||||
|
||||
.wp-editor-container {
|
||||
@ -763,10 +788,6 @@ i.mce-i-hr:before {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.wp-editor-tools {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.wp-editor-container textarea.wp-editor-area {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
|
2
wp-includes/css/editor-rtl.min.css
vendored
2
wp-includes/css/editor-rtl.min.css
vendored
File diff suppressed because one or more lines are too long
@ -148,8 +148,13 @@ div.mce-tab {
|
||||
div.mce-toolbar-grp {
|
||||
border-bottom: 1px solid #dedede;
|
||||
background: #f5f5f5;
|
||||
padding: 3px;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
div.mce-toolbar-grp > div {
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first {
|
||||
@ -161,14 +166,26 @@ div.mce-toolbar-grp {
|
||||
}
|
||||
|
||||
div.mce-statusbar {
|
||||
border-top: 1px solid #eee;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
div.mce-path {
|
||||
padding: 0 8px 2px;
|
||||
padding: 2px 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mce-path,
|
||||
.mce-path-item,
|
||||
.mce-path .mce-divider {
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.mce-path-item:focus {
|
||||
background: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.mce-toolbar .mce-btn,
|
||||
.qt-fullscreen {
|
||||
border-color: transparent;
|
||||
@ -731,7 +748,7 @@ i.mce-i-hr:before {
|
||||
}
|
||||
|
||||
.mce-i-wp_code:before {
|
||||
content: '\e017';
|
||||
content: '\f475';
|
||||
}
|
||||
|
||||
/* Editors */
|
||||
@ -740,8 +757,16 @@ i.mce-i-hr:before {
|
||||
}
|
||||
|
||||
.wp-editor-tools {
|
||||
background-color: #f1f1f1;
|
||||
padding-top: 20px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.wp-editor-tools:after {
|
||||
clear: both;
|
||||
content: '';
|
||||
display: table;
|
||||
}
|
||||
|
||||
.wp-editor-container {
|
||||
@ -763,10 +788,6 @@ i.mce-i-hr:before {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.wp-editor-tools {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.wp-editor-container textarea.wp-editor-area {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
|
2
wp-includes/css/editor.min.css
vendored
2
wp-includes/css/editor.min.css
vendored
File diff suppressed because one or more lines are too long
@ -52,6 +52,8 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
wpAdvButton && wpAdvButton.active( true );
|
||||
}
|
||||
}
|
||||
|
||||
editor.fire( 'wp-toolbar-toggle' );
|
||||
}
|
||||
|
||||
// Add the kitchen sink button :)
|
||||
|
File diff suppressed because one or more lines are too long
326
wp-includes/js/tinymce/plugins/wpautoresize/plugin.js
Normal file
326
wp-includes/js/tinymce/plugins/wpautoresize/plugin.js
Normal file
@ -0,0 +1,326 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
// Forked for WordPress so it can be turned on/off after loading.
|
||||
|
||||
/*global tinymce:true */
|
||||
/*eslint no-nested-ternary:0 */
|
||||
|
||||
/**
|
||||
* Auto Resize
|
||||
*
|
||||
* This plugin automatically resizes the content area to fit its content height.
|
||||
* It will retain a minimum height, which is the height of the content area when
|
||||
* it's initialized.
|
||||
*/
|
||||
tinymce.PluginManager.add('wpautoresize', function(editor) {
|
||||
var settings = editor.settings, oldSize = 0;
|
||||
|
||||
function isFullscreen() {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
}
|
||||
|
||||
if (editor.settings.inline) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets executed each time the editor needs to resize.
|
||||
*/
|
||||
function resize(e) {
|
||||
var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight, marginTop, marginBottom;
|
||||
|
||||
doc = editor.getDoc();
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
body = doc.body;
|
||||
docElm = doc.documentElement;
|
||||
resizeHeight = settings.autoresize_min_height;
|
||||
|
||||
if (!body || (e && e.type === "setcontent" && e.initial) || isFullscreen()) {
|
||||
if (body && docElm) {
|
||||
body.style.overflowY = "auto";
|
||||
docElm.style.overflowY = "auto"; // Old IE
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate outer height of the body element using CSS styles
|
||||
marginTop = editor.dom.getStyle(body, 'margin-top', true);
|
||||
marginBottom = editor.dom.getStyle(body, 'margin-bottom', true);
|
||||
myHeight = body.offsetHeight + parseInt(marginTop, 10) + parseInt(marginBottom, 10);
|
||||
|
||||
// Make sure we have a valid height
|
||||
if (isNaN(myHeight) || myHeight <= 0) {
|
||||
// Get height differently depending on the browser used
|
||||
myHeight = tinymce.Env.ie ? body.scrollHeight : (tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight);
|
||||
}
|
||||
|
||||
// Don't make it smaller than the minimum height
|
||||
if (myHeight > settings.autoresize_min_height) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
// If a maximum height has been defined don't exceed this height
|
||||
if (settings.autoresize_max_height && myHeight > settings.autoresize_max_height) {
|
||||
resizeHeight = settings.autoresize_max_height;
|
||||
body.style.overflowY = "auto";
|
||||
docElm.style.overflowY = "auto"; // Old IE
|
||||
} else {
|
||||
body.style.overflowY = "hidden";
|
||||
docElm.style.overflowY = "hidden"; // Old IE
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
|
||||
// Resize content element
|
||||
if (resizeHeight !== oldSize) {
|
||||
deltaSize = resizeHeight - oldSize;
|
||||
DOM.setStyle(DOM.get(editor.id + '_ifr'), 'height', resizeHeight + 'px');
|
||||
oldSize = resizeHeight;
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
||||
// So we need to continue to resize the iframe down until the size gets fixed
|
||||
if (tinymce.isWebKit && deltaSize < 0) {
|
||||
resize(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the resize x times in 100ms intervals. We can't wait for load events since
|
||||
* the CSS files might load async.
|
||||
*/
|
||||
function wait( times, interval, callback ) {
|
||||
setTimeout( function() {
|
||||
resize({});
|
||||
|
||||
if ( times-- ) {
|
||||
wait( times, interval, callback );
|
||||
} else if ( callback ) {
|
||||
callback();
|
||||
}
|
||||
}, interval );
|
||||
}
|
||||
|
||||
// Define minimum height
|
||||
settings.autoresize_min_height = parseInt(editor.getParam('autoresize_min_height', editor.getElement().offsetHeight), 10);
|
||||
|
||||
// Define maximum height
|
||||
settings.autoresize_max_height = parseInt(editor.getParam('autoresize_max_height', 0), 10);
|
||||
|
||||
function on() {
|
||||
if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
// Add appropriate listeners for resizing the content area
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
}
|
||||
}
|
||||
|
||||
function off() {
|
||||
// Don't turn off if the setting is 'on'
|
||||
if ( ! settings.wp_autoresize_on ) {
|
||||
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
|
||||
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
oldSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings.wp_autoresize_on ) {
|
||||
// Turn resizing on when the editor loads
|
||||
editor.on( 'init', function() {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
});
|
||||
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
|
||||
if ( editor.getParam( 'autoresize_on_init', true ) ) {
|
||||
editor.on( 'init', function() {
|
||||
// Hit it 20 times in 100 ms intervals
|
||||
wait( 10, 200, function() {
|
||||
// Hit it 5 times in 1 sec intervals
|
||||
wait( 5, 1000 );
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Register the command
|
||||
editor.addCommand( 'wpAutoResize', resize );
|
||||
|
||||
// On/off
|
||||
editor.addCommand( 'wpAutoResizeOn', on );
|
||||
editor.addCommand( 'wpAutoResizeOff', off );
|
||||
});
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
// Forked for WordPress so it can be turned on/off after loading.
|
||||
|
||||
/*global tinymce:true */
|
||||
/*eslint no-nested-ternary:0 */
|
||||
|
||||
/**
|
||||
* Auto Resize
|
||||
*
|
||||
* This plugin automatically resizes the content area to fit its content height.
|
||||
* It will retain a minimum height, which is the height of the content area when
|
||||
* it's initialized.
|
||||
*/
|
||||
tinymce.PluginManager.add('wpautoresize', function(editor) {
|
||||
var settings = editor.settings, oldSize = 0;
|
||||
|
||||
function isFullscreen() {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
}
|
||||
|
||||
if (editor.settings.inline) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets executed each time the editor needs to resize.
|
||||
*/
|
||||
function resize(e) {
|
||||
var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight, marginTop, marginBottom;
|
||||
|
||||
doc = editor.getDoc();
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
body = doc.body;
|
||||
docElm = doc.documentElement;
|
||||
resizeHeight = settings.autoresize_min_height;
|
||||
|
||||
if (!body || (e && e.type === "setcontent" && e.initial) || isFullscreen()) {
|
||||
if (body && docElm) {
|
||||
body.style.overflowY = "auto";
|
||||
docElm.style.overflowY = "auto"; // Old IE
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate outer height of the body element using CSS styles
|
||||
marginTop = editor.dom.getStyle(body, 'margin-top', true);
|
||||
marginBottom = editor.dom.getStyle(body, 'margin-bottom', true);
|
||||
myHeight = body.offsetHeight + parseInt(marginTop, 10) + parseInt(marginBottom, 10);
|
||||
|
||||
// Make sure we have a valid height
|
||||
if (isNaN(myHeight) || myHeight <= 0) {
|
||||
// Get height differently depending on the browser used
|
||||
myHeight = tinymce.Env.ie ? body.scrollHeight : (tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight);
|
||||
}
|
||||
|
||||
// Don't make it smaller than the minimum height
|
||||
if (myHeight > settings.autoresize_min_height) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
// If a maximum height has been defined don't exceed this height
|
||||
if (settings.autoresize_max_height && myHeight > settings.autoresize_max_height) {
|
||||
resizeHeight = settings.autoresize_max_height;
|
||||
body.style.overflowY = "auto";
|
||||
docElm.style.overflowY = "auto"; // Old IE
|
||||
} else {
|
||||
body.style.overflowY = "hidden";
|
||||
docElm.style.overflowY = "hidden"; // Old IE
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
|
||||
// Resize content element
|
||||
if (resizeHeight !== oldSize) {
|
||||
deltaSize = resizeHeight - oldSize;
|
||||
DOM.setStyle(DOM.get(editor.id + '_ifr'), 'height', resizeHeight + 'px');
|
||||
oldSize = resizeHeight;
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
||||
// So we need to continue to resize the iframe down until the size gets fixed
|
||||
if (tinymce.isWebKit && deltaSize < 0) {
|
||||
resize(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the resize x times in 100ms intervals. We can't wait for load events since
|
||||
* the CSS files might load async.
|
||||
*/
|
||||
function wait( times, interval, callback ) {
|
||||
setTimeout( function() {
|
||||
resize({});
|
||||
|
||||
if ( times-- ) {
|
||||
wait( times, interval, callback );
|
||||
} else if ( callback ) {
|
||||
callback();
|
||||
}
|
||||
}, interval );
|
||||
}
|
||||
|
||||
// Define minimum height
|
||||
settings.autoresize_min_height = parseInt(editor.getParam('autoresize_min_height', editor.getElement().offsetHeight), 10);
|
||||
|
||||
// Define maximum height
|
||||
settings.autoresize_max_height = parseInt(editor.getParam('autoresize_max_height', 0), 10);
|
||||
|
||||
function on() {
|
||||
if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
// Add appropriate listeners for resizing the content area
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
}
|
||||
}
|
||||
|
||||
function off() {
|
||||
// Don't turn off if the setting is 'on'
|
||||
if ( ! settings.wp_autoresize_on ) {
|
||||
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
|
||||
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
oldSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings.wp_autoresize_on ) {
|
||||
// Turn resizing on when the editor loads
|
||||
editor.on( 'init', function() {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
});
|
||||
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
|
||||
if ( editor.getParam( 'autoresize_on_init', true ) ) {
|
||||
editor.on( 'init', function() {
|
||||
// Hit it 20 times in 100 ms intervals
|
||||
wait( 10, 200, function() {
|
||||
// Hit it 5 times in 1 sec intervals
|
||||
wait( 5, 1000 );
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Register the command
|
||||
editor.addCommand( 'wpAutoResize', resize );
|
||||
|
||||
// On/off
|
||||
editor.addCommand( 'wpAutoResizeOn', on );
|
||||
editor.addCommand( 'wpAutoResizeOff', off );
|
||||
});
|
1
wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js
vendored
Normal file
@ -0,0 +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 setcontent keyup FullscreenStateChanged",c),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(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 setcontent keyup FullscreenStateChanged",c),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))});
|
@ -3,60 +3,20 @@
|
||||
* WP Fullscreen (Distraction Free Writing) TinyMCE plugin
|
||||
*/
|
||||
tinymce.PluginManager.add( 'wpfullscreen', function( editor ) {
|
||||
var settings = editor.settings,
|
||||
oldSize = 0;
|
||||
|
||||
function resize( e ) {
|
||||
var deltaSize, myHeight,
|
||||
d = editor.getDoc(),
|
||||
body = d.body,
|
||||
DOM = tinymce.DOM,
|
||||
resizeHeight = 250;
|
||||
|
||||
if ( ( e && e.type === 'setcontent' && e.initial ) || editor.settings.inline ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get height differently depending on the browser used
|
||||
myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight );
|
||||
|
||||
// Don't make it smaller than 250px
|
||||
if ( myHeight > 250 ) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
body.scrollTop = 0;
|
||||
|
||||
// Resize content element
|
||||
if ( resizeHeight !== oldSize ) {
|
||||
deltaSize = resizeHeight - oldSize;
|
||||
DOM.setStyle( DOM.get( editor.id + '_ifr' ), 'height', resizeHeight + 'px' );
|
||||
oldSize = resizeHeight;
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
||||
// So we need to continue to resize the iframe down until the size gets fixed
|
||||
if ( tinymce.isWebKit && deltaSize < 0 ) {
|
||||
resize( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register the command
|
||||
editor.addCommand( 'wpAutoResize', resize );
|
||||
var settings = editor.settings;
|
||||
|
||||
function fullscreenOn() {
|
||||
settings.wp_fullscreen = true;
|
||||
editor.dom.addClass( editor.getDoc().documentElement, 'wp-fullscreen' );
|
||||
// Add listeners for auto-resizing
|
||||
editor.on( 'change setcontent paste keyup', resize );
|
||||
// Start auto-resizing
|
||||
editor.execCommand( 'wpAutoResizeOn' );
|
||||
}
|
||||
|
||||
function fullscreenOff() {
|
||||
settings.wp_fullscreen = false;
|
||||
editor.dom.removeClass( editor.getDoc().documentElement, 'wp-fullscreen' );
|
||||
// Remove listeners for auto-resizing
|
||||
editor.off( 'change setcontent paste keyup', resize );
|
||||
oldSize = 0;
|
||||
// Stop auto-resizing
|
||||
editor.execCommand( 'wpAutoResizeOff' );
|
||||
}
|
||||
|
||||
// For use from outside the editor.
|
||||
|
@ -1 +1 @@
|
||||
tinymce.PluginManager.add("wpfullscreen",function(a){function b(c){var d,e,f=a.getDoc(),g=f.body,i=tinymce.DOM,j=250;c&&"setcontent"===c.type&&c.initial||a.settings.inline||(e=tinymce.Env.ie?g.scrollHeight:tinymce.Env.webkit&&0===g.clientHeight?0:g.offsetHeight,e>250&&(j=e),g.scrollTop=0,j!==h&&(d=j-h,i.setStyle(i.get(a.id+"_ifr"),"height",j+"px"),h=j,tinymce.isWebKit&&0>d&&b(c)))}function c(){g.wp_fullscreen=!0,a.dom.addClass(a.getDoc().documentElement,"wp-fullscreen"),a.on("change setcontent paste keyup",b)}function d(){g.wp_fullscreen=!1,a.dom.removeClass(a.getDoc().documentElement,"wp-fullscreen"),a.off("change setcontent paste keyup",b),h=0}function e(){return"undefined"!=typeof wp&&wp.editor&&wp.editor.fullscreen}function f(){var b=e();b&&(a.getParam("wp_fullscreen")?b.off():b.on())}var g=a.settings,h=0;a.addCommand("wpAutoResize",b),a.addCommand("wpFullScreenOn",c),a.addCommand("wpFullScreenOff",d),a.addCommand("wpFullScreen",f),a.on("keydown",function(a){var b;27===a.keyCode&&(b=e())&&b.settings.visible&&b.off()}),a.on("init",function(){a.getParam("wp_fullscreen")&&c(),a.addShortcut("alt+shift+w","","wpFullScreen")}),a.addButton("wp_fullscreen",{tooltip:"Distraction Free Writing",shortcut:"Alt+Shift+W",onclick:f,classes:"wp-fullscreen btn widget"}),a.addMenuItem("wp_fullscreen",{text:"Distraction Free Writing",icon:"wp_fullscreen",shortcut:"Alt+Shift+W",context:"view",onclick:f})});
|
||||
tinymce.PluginManager.add("wpfullscreen",function(a){function b(){f.wp_fullscreen=!0,a.dom.addClass(a.getDoc().documentElement,"wp-fullscreen"),a.execCommand("wpAutoResizeOn")}function c(){f.wp_fullscreen=!1,a.dom.removeClass(a.getDoc().documentElement,"wp-fullscreen"),a.execCommand("wpAutoResizeOff")}function d(){return"undefined"!=typeof wp&&wp.editor&&wp.editor.fullscreen}function e(){var b=d();b&&(a.getParam("wp_fullscreen")?b.off():b.on())}var f=a.settings;a.addCommand("wpFullScreenOn",b),a.addCommand("wpFullScreenOff",c),a.addCommand("wpFullScreen",e),a.on("keydown",function(a){var b;27===a.keyCode&&(b=d())&&b.settings.visible&&b.off()}),a.on("init",function(){a.getParam("wp_fullscreen")&&b(),a.addShortcut("alt+shift+w","","wpFullScreen")}),a.addButton("wp_fullscreen",{tooltip:"Distraction Free Writing",shortcut:"Alt+Shift+W",onclick:e,classes:"wp-fullscreen btn widget"}),a.addMenuItem("wp_fullscreen",{text:"Distraction Free Writing",icon:"wp_fullscreen",shortcut:"Alt+Shift+W",context:"view",onclick:e})});
|
@ -646,6 +646,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
|
||||
return {
|
||||
getViewText: getViewText,
|
||||
setViewText: setViewText
|
||||
setViewText: setViewText,
|
||||
getView: getView
|
||||
};
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
@ -14,7 +14,17 @@ body {
|
||||
font-size: 13px;
|
||||
line-height: 19px;
|
||||
color: #333;
|
||||
margin: 10px;
|
||||
margin: 9px 10px;
|
||||
}
|
||||
|
||||
body.wp-autoresize {
|
||||
max-width: 100%;
|
||||
overflow: visible !important;
|
||||
/* The padding ensures margins of the children are contained in the body. */
|
||||
padding-top: 1px !important;
|
||||
padding-bottom: 1px !important;
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
|
||||
/* When font-weight is different than the default browser style,
|
||||
|
Binary file not shown.
@ -459,6 +459,8 @@ function wp_default_scripts( &$scripts ) {
|
||||
'savingText' => __('Saving Draft…'),
|
||||
) );
|
||||
|
||||
$scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery' ), false, 1 );
|
||||
|
||||
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
|
||||
|
||||
$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
|
||||
|
Loading…
Reference in New Issue
Block a user