3
window.wp = window.wp || {};
5
jQuery( document ).ready( function( $ ) {
1
( function( window, $, undefined ) {
6
4
var $window = $( window ),
7
5
$document = $( document ),
8
6
$adminBar = $( '#wpadminbar' ),
9
$footer = $( '#wpfooter' ),
10
$wrap = $( '#postdivrich' ),
11
$contentWrap = $( '#wp-content-wrap' ),
12
$tools = $( '#wp-content-editor-tools' ),
15
$textTop = $( '#ed_toolbar' ),
16
$textEditor = $( '#content' ),
17
$textEditorClone = $( '<div id="content-textarea-clone"></div>' ),
18
$bottom = $( '#post-status-info' ),
21
$sideSortables = $( '#side-sortables' ),
22
$postboxContainer = $( '#postbox-container-1' ),
23
$postBody = $('#post-body'),
24
fullscreen = window.wp.editor && window.wp.editor.fullscreen,
26
mceBind = function(){},
27
mceUnbind = function(){},
31
fixedSideBottom = false,
33
lastScrollPosition = 0,
34
pageYOffsetAtTop = 130,
37
autoresizeMinHeight = 300,
38
initialMode = window.getUserSetting( 'editor' ),
39
// These are corrected when adjust() runs, except on scrolling if already set.
50
sideSortablesHeight: 0
53
$textEditorClone.insertAfter( $textEditor );
55
$textEditorClone.css( {
56
'font-family': $textEditor.css( 'font-family' ),
57
'font-size': $textEditor.css( 'font-size' ),
58
'line-height': $textEditor.css( 'line-height' ),
59
'white-space': 'pre-wrap',
60
'word-wrap': 'break-word'
63
function getHeights() {
64
var windowWidth = $window.width();
67
windowHeight: $window.height(),
68
windowWidth: windowWidth,
69
adminBarHeight: ( windowWidth > 600 ? $adminBar.outerHeight() : 0 ),
70
toolsHeight: $tools.outerHeight() || 0,
71
menuBarHeight: $menuBar.outerHeight() || 0,
72
visualTopHeight: $visualTop.outerHeight() || 0,
73
textTopHeight: $textTop.outerHeight() || 0,
74
bottomHeight: $bottom.outerHeight() || 0,
75
statusBarHeight: $statusBar.outerHeight() || 0,
76
sideSortablesHeight: $sideSortables.height() || 0
80
if ( heights.menuBarHeight < 3 ) {
81
heights.menuBarHeight = 0;
85
function textEditorKeyup( event ) {
86
var VK = jQuery.ui.keyCode,
88
range = document.createRange(),
89
selStart = $textEditor[0].selectionStart,
90
selEnd = $textEditor[0].selectionEnd,
91
textNode = $textEditorClone[0].firstChild,
93
offset, cursorTop, cursorBottom, editorTop, editorBottom;
95
if ( selStart && selEnd && selStart !== selEnd ) {
99
// These are not TinyMCE ranges.
101
range.setStart( textNode, selStart );
102
range.setEnd( textNode, selEnd + 1 );
105
offset = range.getBoundingClientRect();
107
if ( ! offset.height ) {
111
cursorTop = offset.top - buffer;
112
cursorBottom = cursorTop + offset.height + buffer;
113
editorTop = heights.adminBarHeight + heights.toolsHeight + heights.textTopHeight;
114
editorBottom = heights.windowHeight - heights.bottomHeight;
116
if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
117
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
118
} else if ( cursorBottom > editorBottom ) {
119
window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
123
function textEditorResize() {
124
if ( ( mceEditor && ! mceEditor.isHidden() ) || ( ! mceEditor && initialMode === 'tinymce' ) ) {
128
var textEditorHeight = $textEditor.height(),
131
$textEditorClone.width( $textEditor.width() - 22 );
132
$textEditorClone.text( $textEditor.val() + ' ' );
134
hiddenHeight = $textEditorClone.height();
136
if ( hiddenHeight < autoresizeMinHeight ) {
137
hiddenHeight = autoresizeMinHeight;
140
if ( hiddenHeight === textEditorHeight ) {
144
$textEditor.height( hiddenHeight );
149
// We need to wait for TinyMCE to initialize.
150
$document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) {
151
var hideFloatPanels = _.debounce( function() {
152
! $( '.mce-floatpanel:hover' ).length && tinymce.ui.FloatPanel.hideAll();
153
$( '.mce-tooltip' ).hide();
156
// Make sure it's the main editor.
157
if ( editor.id !== 'content' ) {
161
// Copy the editor instance.
164
// Set the minimum height to the initial viewport height.
165
editor.settings.autoresize_min_height = autoresizeMinHeight;
167
// Get the necessary UI elements.
168
$visualTop = $contentWrap.find( '.mce-toolbar-grp' );
169
$visualEditor = $contentWrap.find( '.mce-edit-area' );
170
$statusBar = $contentWrap.find( '.mce-statusbar' );
171
$menuBar = $contentWrap.find( '.mce-menubar' );
173
function mceGetCursorOffset() {
174
var node = editor.selection.getNode(),
177
if ( editor.plugins.wpview && ( view = editor.plugins.wpview.getView( node ) ) ) {
178
offset = view.getBoundingClientRect();
180
offset = node.getBoundingClientRect();
7
$footer = $( '#wpfooter' );
9
/* Autoresize editor. */
11
var $wrap = $( '#postdivrich' ),
12
$contentWrap = $( '#wp-content-wrap' ),
13
$tools = $( '#wp-content-editor-tools' ),
16
$textTop = $( '#ed_toolbar' ),
17
$textEditor = $( '#content' ),
18
$textEditorClone = $( '<div id="content-textarea-clone"></div>' ),
19
$bottom = $( '#post-status-info' ),
22
$sideSortables = $( '#side-sortables' ),
23
$postboxContainer = $( '#postbox-container-1' ),
24
$postBody = $('#post-body'),
25
fullscreen = window.wp.editor && window.wp.editor.fullscreen,
27
mceBind = function(){},
28
mceUnbind = function(){},
32
fixedSideBottom = false,
34
lastScrollPosition = 0,
35
pageYOffsetAtTop = 130,
38
autoresizeMinHeight = 300,
39
initialMode = $contentWrap.hasClass( 'tmce-active' ) ? 'tinymce' : 'html',
40
advanced = !! parseInt( window.getUserSetting( 'hidetb' ), 10 ),
41
// These are corrected when adjust() runs, except on scrolling if already set.
52
sideSortablesHeight: 0
55
$textEditorClone.insertAfter( $textEditor );
57
$textEditorClone.css( {
58
'font-family': $textEditor.css( 'font-family' ),
59
'font-size': $textEditor.css( 'font-size' ),
60
'line-height': $textEditor.css( 'line-height' ),
61
'white-space': 'pre-wrap',
62
'word-wrap': 'break-word'
65
function getHeights() {
66
var windowWidth = $window.width();
69
windowHeight: $window.height(),
70
windowWidth: windowWidth,
71
adminBarHeight: ( windowWidth > 600 ? $adminBar.outerHeight() : 0 ),
72
toolsHeight: $tools.outerHeight() || 0,
73
menuBarHeight: $menuBar.outerHeight() || 0,
74
visualTopHeight: $visualTop.outerHeight() || 0,
75
textTopHeight: $textTop.outerHeight() || 0,
76
bottomHeight: $bottom.outerHeight() || 0,
77
statusBarHeight: $statusBar.outerHeight() || 0,
78
sideSortablesHeight: $sideSortables.height() || 0
82
if ( heights.menuBarHeight < 3 ) {
83
heights.menuBarHeight = 0;
183
return offset.height ? offset : false;
186
// Make sure the cursor is always visible.
187
// This is not only necessary to keep the cursor between the toolbars,
188
// but also to scroll the window when the cursor moves out of the viewport to a wpview.
189
// Setting a buffer > 0 will prevent the browser default.
190
// Some browsers will scroll to the middle,
191
// others to the top/bottom of the *window* when moving the cursor out of the viewport.
192
function mceKeyup( event ) {
193
var VK = tinymce.util.VK,
87
function textEditorKeyup( event ) {
88
var VK = jQuery.ui.keyCode,
194
89
key = event.keyCode,
195
offset = mceGetCursorOffset(),
90
range = document.createRange(),
91
selStart = $textEditor[0].selectionStart,
92
selEnd = $textEditor[0].selectionEnd,
93
textNode = $textEditorClone[0].firstChild,
197
cursorTop, cursorBottom, editorTop, editorBottom;
203
// Bail on special keys.
204
if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) {
206
// OS keys, function keys, num lock, scroll lock
207
} else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) {
211
cursorTop = offset.top + editor.iframeElement.getBoundingClientRect().top;
212
cursorBottom = cursorTop + offset.height;
213
cursorTop = cursorTop - buffer;
214
cursorBottom = cursorBottom + buffer;
215
editorTop = heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight + heights.visualTopHeight;
216
editorBottom = heights.windowHeight - heights.bottomHeight - heights.statusBarHeight;
218
// Don't scroll if the node is taller than the visible part of the editor
219
if ( editorBottom - editorTop < offset.height ) {
95
offset, cursorTop, cursorBottom, editorTop, editorBottom;
97
if ( selStart && selEnd && selStart !== selEnd ) {
101
// These are not TinyMCE ranges.
103
range.setStart( textNode, selStart );
104
range.setEnd( textNode, selEnd + 1 );
107
offset = range.getBoundingClientRect();
109
if ( ! offset.height ) {
113
cursorTop = offset.top - buffer;
114
cursorBottom = cursorTop + offset.height + buffer;
115
editorTop = heights.adminBarHeight + heights.toolsHeight + heights.textTopHeight;
116
editorBottom = heights.windowHeight - heights.bottomHeight;
223
118
if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
224
119
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
230
// Adjust when switching editor modes.
232
$window.on( 'scroll.mce-float-panels', hideFloatPanels );
234
setTimeout( function() {
235
editor.execCommand( 'wpAutoResize' );
125
function textEditorResize() {
126
if ( ( mceEditor && ! mceEditor.isHidden() ) || ( ! mceEditor && initialMode === 'tinymce' ) ) {
130
var textEditorHeight = $textEditor.height(),
133
$textEditorClone.width( $textEditor.width() - 22 );
134
$textEditorClone.text( $textEditor.val() + ' ' );
136
hiddenHeight = $textEditorClone.height();
138
if ( hiddenHeight < autoresizeMinHeight ) {
139
hiddenHeight = autoresizeMinHeight;
142
if ( hiddenHeight === textEditorHeight ) {
146
$textEditor.height( hiddenHeight );
151
// We need to wait for TinyMCE to initialize.
152
$document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) {
153
var VK = window.tinymce.util.VK,
154
hideFloatPanels = _.debounce( function() {
155
! $( '.mce-floatpanel:hover' ).length && window.tinymce.ui.FloatPanel.hideAll();
156
$( '.mce-tooltip' ).hide();
159
// Make sure it's the main editor.
160
if ( editor.id !== 'content' ) {
164
// Copy the editor instance.
167
// Set the minimum height to the initial viewport height.
168
editor.settings.autoresize_min_height = autoresizeMinHeight;
170
// Get the necessary UI elements.
171
$visualTop = $contentWrap.find( '.mce-toolbar-grp' );
172
$visualEditor = $contentWrap.find( '.mce-edit-area' );
173
$statusBar = $contentWrap.find( '.mce-statusbar' );
174
$menuBar = $contentWrap.find( '.mce-menubar' );
176
function mceGetCursorOffset() {
177
var node = editor.selection.getNode(),
180
if ( editor.plugins.wpview && ( view = editor.plugins.wpview.getView( node ) ) ) {
181
offset = view.getBoundingClientRect();
183
range = editor.selection.getRng();
186
offset = range.getClientRects()[0];
190
offset = node.getBoundingClientRect();
194
return offset.height ? offset : false;
197
// Make sure the cursor is always visible.
198
// This is not only necessary to keep the cursor between the toolbars,
199
// but also to scroll the window when the cursor moves out of the viewport to a wpview.
200
// Setting a buffer > 0 will prevent the browser default.
201
// Some browsers will scroll to the middle,
202
// others to the top/bottom of the *window* when moving the cursor out of the viewport.
203
function mceKeyup( event ) {
204
var key = event.keyCode;
206
// Bail on special keys.
207
if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) {
209
// OS keys, function keys, num lock, scroll lock
210
} else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) {
217
function mceScroll( key ) {
218
var offset = mceGetCursorOffset(),
220
cursorTop, cursorBottom, editorTop, editorBottom;
226
cursorTop = offset.top + editor.iframeElement.getBoundingClientRect().top;
227
cursorBottom = cursorTop + offset.height;
228
cursorTop = cursorTop - buffer;
229
cursorBottom = cursorBottom + buffer;
230
editorTop = heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight + heights.visualTopHeight;
231
editorBottom = heights.windowHeight - ( advanced ? heights.bottomHeight + heights.statusBarHeight : 0 );
233
// Don't scroll if the node is taller than the visible part of the editor
234
if ( editorBottom - editorTop < offset.height ) {
238
if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
239
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
240
} else if ( cursorBottom > editorBottom ) {
241
window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
245
function mceFullscreenToggled( event ) {
246
if ( ! event.state ) {
251
// Adjust when switching editor modes.
253
$window.on( 'scroll.mce-float-panels', hideFloatPanels );
255
setTimeout( function() {
256
editor.execCommand( 'wpAutoResize' );
262
$window.off( 'scroll.mce-float-panels' );
264
setTimeout( function() {
265
var top = $contentWrap.offset().top;
267
if ( window.pageYOffset > top ) {
268
window.scrollTo( window.pageXOffset, top - heights.adminBarHeight );
241
$window.off( 'scroll.mce-float-panels' );
243
setTimeout( function() {
244
var top = $contentWrap.offset().top;
246
if ( window.pageYOffset > top ) {
247
window.scrollTo( window.pageXOffset, top - heights.adminBarHeight );
278
function toggleAdvanced() {
279
advanced = ! advanced;
282
mceBind = function() {
283
editor.on( 'keyup', mceKeyup );
284
editor.on( 'show', mceShow );
285
editor.on( 'hide', mceHide );
286
editor.on( 'wp-toolbar-toggle', toggleAdvanced );
287
// Adjust when the editor resizes.
288
editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
289
// Don't hide the caret after undo/redo.
290
editor.on( 'undo redo', mceScroll );
291
// Adjust when exiting TinyMCE's fullscreen mode.
292
editor.on( 'FullscreenStateChanged', mceFullscreenToggled );
294
$window.off( 'scroll.mce-float-panels' ).on( 'scroll.mce-float-panels', hideFloatPanels );
297
mceUnbind = function() {
298
editor.off( 'keyup', mceKeyup );
299
editor.off( 'show', mceShow );
300
editor.off( 'hide', mceHide );
301
editor.off( 'wp-toolbar-toggle', toggleAdvanced );
302
editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
303
editor.off( 'undo redo', mceScroll );
304
editor.off( 'FullscreenStateChanged', mceFullscreenToggled );
306
$window.off( 'scroll.mce-float-panels' );
309
if ( $wrap.hasClass( 'wp-editor-expand' ) ) {
310
// Adjust "immediately"
312
initialResize( adjust );
316
// Adjust the toolbars based on the active editor mode.
317
function adjust( event ) {
318
// Make sure we're not in fullscreen mode.
319
if ( fullscreen && fullscreen.settings.visible ) {
323
var windowPos = $window.scrollTop(),
324
type = event && event.type,
325
resize = type !== 'scroll',
326
visual = ( mceEditor && ! mceEditor.isHidden() ),
327
buffer = autoresizeMinHeight,
328
postBodyTop = $postBody.offset().top,
330
contentWrapWidth = $contentWrap.width(),
331
$top, $editor, sidebarTop, footerTop, canPin,
332
topPos, topHeight, editorPos, editorHeight;
334
// Refresh the heights
335
if ( resize || ! heights.windowHeight ) {
339
if ( ! visual && type === 'resize' ) {
250
340
textEditorResize();
257
mceBind = function() {
258
editor.on( 'keyup', mceKeyup );
259
editor.on( 'show', mceShow );
260
editor.on( 'hide', mceHide );
261
// Adjust when the editor resizes.
262
editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
264
$window.off( 'scroll.mce-float-panels' ).on( 'scroll.mce-float-panels', hideFloatPanels );
267
mceUnbind = function() {
268
editor.off( 'keyup', mceKeyup );
269
editor.off( 'show', mceShow );
270
editor.off( 'hide', mceHide );
271
editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
273
$window.off( 'scroll.mce-float-panels' );
276
if ( $wrap.hasClass( 'wp-editor-expand' ) ) {
277
// Adjust "immediately"
279
initialResize( adjust );
283
// Adjust the toolbars based on the active editor mode.
284
function adjust( type ) {
285
// Make sure we're not in fullscreen mode.
286
if ( fullscreen && fullscreen.settings.visible ) {
290
var windowPos = $window.scrollTop(),
291
resize = type !== 'scroll',
292
visual = ( mceEditor && ! mceEditor.isHidden() ),
293
buffer = autoresizeMinHeight,
294
postBodyTop = $postBody.offset().top,
296
contentWrapWidth = $contentWrap.width(),
297
$top, $editor, sidebarTop, footerTop, canPin,
298
topPos, topHeight, editorPos, editorHeight;
300
// Refresh the heights
301
if ( resize || ! heights.windowHeight ) {
305
if ( ! visual && type === 'resize' ) {
311
$editor = $visualEditor;
312
topHeight = heights.visualTopHeight;
315
$editor = $textEditor;
316
topHeight = heights.textTopHeight;
319
topPos = $top.parent().offset().top;
320
editorPos = $editor.offset().top;
321
editorHeight = $editor.outerHeight();
324
canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding
325
canPin = editorHeight > ( canPin + 5 );
330
position: 'absolute',
332
width: contentWrapWidth
335
if ( visual && $menuBar.length ) {
337
position: 'absolute',
339
width: contentWrapWidth - ( borderWidth * 2 )
344
position: 'absolute',
345
top: heights.menuBarHeight,
346
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
349
$statusBar.add( $bottom ).attr( 'style', '' );
352
// Maybe pin the top.
353
if ( ( ! fixedTop || resize ) &&
354
// Handle scrolling down.
355
( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight ) &&
356
// Handle scrolling up.
357
windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) ) {
362
top: heights.adminBarHeight,
363
width: contentWrapWidth
366
if ( visual && $menuBar.length ) {
369
top: heights.adminBarHeight + heights.toolsHeight,
370
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
376
top: heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight,
377
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
379
// Maybe unpin the top.
380
} else if ( fixedTop || resize ) {
381
// Handle scrolling up.
382
if ( windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight ) ) {
345
$editor = $visualEditor;
346
topHeight = heights.visualTopHeight;
349
$editor = $textEditor;
350
topHeight = heights.textTopHeight;
353
topPos = $top.parent().offset().top;
354
editorPos = $editor.offset().top;
355
editorHeight = $editor.outerHeight();
358
canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding
359
canPin = editorHeight > ( canPin + 5 );
386
364
position: 'absolute',
401
379
top: heights.menuBarHeight,
402
380
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
404
// Handle scrolling down.
405
} else if ( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) {
383
$statusBar.add( $bottom ).attr( 'style', '' );
386
// Maybe pin the top.
387
if ( ( ! fixedTop || resize ) &&
388
// Handle scrolling down.
389
( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight ) &&
390
// Handle scrolling up.
391
windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) ) {
409
position: 'absolute',
410
top: editorHeight - buffer,
396
top: heights.adminBarHeight,
411
397
width: contentWrapWidth
414
400
if ( visual && $menuBar.length ) {
403
top: heights.adminBarHeight + heights.toolsHeight,
404
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
410
top: heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight,
411
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
413
// Maybe unpin the top.
414
} else if ( fixedTop || resize ) {
415
// Handle scrolling up.
416
if ( windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight ) ) {
420
position: 'absolute',
422
width: contentWrapWidth
425
if ( visual && $menuBar.length ) {
427
position: 'absolute',
429
width: contentWrapWidth - ( borderWidth * 2 )
434
position: 'absolute',
435
top: heights.menuBarHeight,
436
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
438
// Handle scrolling down.
439
} else if ( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) {
416
443
position: 'absolute',
417
444
top: editorHeight - buffer,
445
width: contentWrapWidth
448
if ( visual && $menuBar.length ) {
450
position: 'absolute',
451
top: editorHeight - buffer,
452
width: contentWrapWidth - ( borderWidth * 2 )
457
position: 'absolute',
458
top: editorHeight - buffer + heights.menuBarHeight,
459
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
464
// Maybe adjust the bottom bar.
465
if ( ( ! fixedBottom || ( resize && advanced ) ) &&
466
// +[n] for the border around the .wp-editor-container.
467
( windowPos + heights.windowHeight ) <= ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight + borderWidth ) ) {
469
if ( event && event.deltaHeight > 0 && event.deltaHeight < 100 ) {
470
window.scrollBy( 0, event.deltaHeight );
471
} else if ( advanced ) {
476
bottom: heights.bottomHeight,
418
478
width: contentWrapWidth - ( borderWidth * 2 )
423
position: 'absolute',
424
top: editorHeight - buffer + heights.menuBarHeight,
425
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
484
width: contentWrapWidth
487
} else if ( ( ! advanced && fixedBottom ) ||
488
( ( fixedBottom || resize ) &&
489
( windowPos + heights.windowHeight ) > ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight - borderWidth ) ) ) {
492
$statusBar.add( $bottom ).attr( 'style', '' );
495
$statusBar.css( 'visibility', 'hidden' );
430
// Maybe adjust the bottom bar.
431
if ( ( ! fixedBottom || resize ) &&
432
// +[n] for the border around the .wp-editor-container.
433
( windowPos + heights.windowHeight ) <= ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight + borderWidth ) ) {
438
bottom: heights.bottomHeight,
439
width: contentWrapWidth - ( borderWidth * 2 )
445
width: contentWrapWidth
447
} else if ( ( fixedBottom || resize ) &&
448
( windowPos + heights.windowHeight ) > ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight - borderWidth ) ) {
451
$statusBar.add( $bottom ).attr( 'style', '' );
456
if ( $postboxContainer.width() < 300 && heights.windowWidth > 600 && // sidebar position is changed with @media from CSS, make sure it is on the side
457
$document.height() > ( $sideSortables.height() + postBodyTop + 120 ) && // the sidebar is not the tallest element
458
heights.windowHeight < editorHeight ) { // the editor is taller than the viewport
460
if ( ( heights.sideSortablesHeight + pinnedToolsTop + sidebarBottom ) > heights.windowHeight || fixedSideTop || fixedSideBottom ) {
461
// Reset when scrolling to the top
462
if ( windowPos + pinnedToolsTop <= postBodyTop ) {
463
$sideSortables.attr( 'style', '' );
501
if ( $postboxContainer.width() < 300 && heights.windowWidth > 600 && // sidebar position is changed with @media from CSS, make sure it is on the side
502
$document.height() > ( $sideSortables.height() + postBodyTop + 120 ) && // the sidebar is not the tallest element
503
heights.windowHeight < editorHeight ) { // the editor is taller than the viewport
505
if ( ( heights.sideSortablesHeight + pinnedToolsTop + sidebarBottom ) > heights.windowHeight || fixedSideTop || fixedSideBottom ) {
506
// Reset when scrolling to the top
507
if ( windowPos + pinnedToolsTop <= postBodyTop ) {
508
$sideSortables.attr( 'style', '' );
509
fixedSideTop = fixedSideBottom = false;
511
if ( windowPos > lastScrollPosition ) {
513
if ( fixedSideTop ) {
515
fixedSideTop = false;
516
sidebarTop = $sideSortables.offset().top - heights.adminBarHeight;
517
footerTop = $footer.offset().top;
519
// don't get over the footer
520
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
521
sidebarTop = footerTop - heights.sideSortablesHeight - 12;
525
position: 'absolute',
529
} else if ( ! fixedSideBottom && heights.sideSortablesHeight + $sideSortables.offset().top + sidebarBottom < windowPos + heights.windowHeight ) {
531
fixedSideBottom = true;
536
bottom: sidebarBottom
539
} else if ( windowPos < lastScrollPosition ) {
541
if ( fixedSideBottom ) {
543
fixedSideBottom = false;
544
sidebarTop = $sideSortables.offset().top - sidebarBottom;
545
footerTop = $footer.offset().top;
547
// don't get over the footer
548
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
549
sidebarTop = footerTop - heights.sideSortablesHeight - 12;
553
position: 'absolute',
557
} else if ( ! fixedSideTop && $sideSortables.offset().top >= windowPos + pinnedToolsTop ) {
570
// if the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling
571
if ( windowPos >= ( postBodyTop - pinnedToolsTop ) ) {
573
$sideSortables.css( {
578
$sideSortables.attr( 'style', '' );
464
581
fixedSideTop = fixedSideBottom = false;
466
if ( windowPos > lastScrollPosition ) {
468
if ( fixedSideTop ) {
470
fixedSideTop = false;
471
sidebarTop = $sideSortables.offset().top - heights.adminBarHeight;
472
footerTop = $footer.offset().top;
474
// don't get over the footer
475
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
476
sidebarTop = footerTop - heights.sideSortablesHeight - 12;
480
position: 'absolute',
484
} else if ( ! fixedSideBottom && heights.sideSortablesHeight + $sideSortables.offset().top + sidebarBottom < windowPos + heights.windowHeight ) {
486
fixedSideBottom = true;
491
bottom: sidebarBottom
494
} else if ( windowPos < lastScrollPosition ) {
496
if ( fixedSideBottom ) {
498
fixedSideBottom = false;
499
sidebarTop = $sideSortables.offset().top - sidebarBottom;
500
footerTop = $footer.offset().top;
502
// don't get over the footer
503
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
504
sidebarTop = footerTop - heights.sideSortablesHeight - 12;
508
position: 'absolute',
512
} else if ( ! fixedSideTop && $sideSortables.offset().top >= windowPos + pinnedToolsTop ) {
584
lastScrollPosition = windowPos;
525
// if the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling
526
if ( windowPos >= ( postBodyTop - pinnedToolsTop ) ) {
528
$sideSortables.css( {
533
$sideSortables.attr( 'style', '' );
586
$sideSortables.attr( 'style', '' );
536
587
fixedSideTop = fixedSideBottom = false;
539
lastScrollPosition = windowPos;
541
$sideSortables.attr( 'style', '' );
542
fixedSideTop = fixedSideBottom = false;
547
paddingTop: heights.toolsHeight
592
paddingTop: heights.toolsHeight
597
paddingTop: heights.visualTopHeight + heights.menuBarHeight
601
marginTop: heights.textTopHeight
604
$textEditorClone.width( contentWrapWidth - 20 - ( borderWidth * 2 ) );
609
function fullscreenHide() {
614
function initialResize( callback ) {
615
for ( var i = 1; i < 6; i++ ) {
616
setTimeout( callback, 500 * i );
620
function afterScroll() {
621
clearTimeout( scrollTimer );
622
scrollTimer = setTimeout( adjust, 100 );
626
// Scroll to the top when triggering this from JS.
627
// Ensures toolbars are pinned properly.
628
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
629
window.scrollTo( window.pageXOffset, 0 );
632
$wrap.addClass( 'wp-editor-expand' );
634
// Adjust when the window is scrolled or resized.
635
$window.on( 'scroll.editor-expand resize.editor-expand', function( event ) {
636
adjust( event.type );
552
paddingTop: heights.visualTopHeight + heights.menuBarHeight
556
marginTop: heights.textTopHeight
559
$textEditorClone.width( contentWrapWidth - 20 - ( borderWidth * 2 ) );
564
function fullscreenHide() {
569
function initialResize( callback ) {
570
for ( var i = 1; i < 6; i++ ) {
571
setTimeout( callback, 500 * i );
575
function afterScroll() {
576
clearTimeout( scrollTimer );
577
scrollTimer = setTimeout( adjust, 100 );
581
// Scroll to the top when triggering this from JS.
582
// Ensures toolbars are pinned properly.
583
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
584
window.scrollTo( window.pageXOffset, 0 );
587
$wrap.addClass( 'wp-editor-expand' );
589
// Adjust when the window is scrolled or resized.
590
$window.on( 'scroll.editor-expand resize.editor-expand', function( event ) {
591
adjust( event.type );
595
// Adjust when collapsing the menu, changing the columns, changing the body class.
596
$document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust )
597
.on( 'postbox-toggled.editor-expand', function() {
598
if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > pinnedToolsTop ) {
599
fixedSideBottom = true;
600
window.scrollBy( 0, -1 );
640
// Adjust when collapsing the menu, changing the columns, changing the body class.
641
$document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust )
642
.on( 'postbox-toggled.editor-expand', function() {
643
if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > pinnedToolsTop ) {
644
fixedSideBottom = true;
645
window.scrollBy( 0, -1 );
647
window.scrollBy( 0, 1 );
602
window.scrollBy( 0, 1 );
606
}).on( 'wp-window-resized.editor-expand', function() {
607
if ( mceEditor && ! mceEditor.isHidden() ) {
651
}).on( 'wp-window-resized.editor-expand', function() {
652
if ( mceEditor && ! mceEditor.isHidden() ) {
653
mceEditor.execCommand( 'wpAutoResize' );
659
$textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize );
660
$textEditor.on( 'keyup.editor-expand', textEditorKeyup );
663
// Adjust when entering/exiting fullscreen mode.
664
fullscreen && fullscreen.pubsub.subscribe( 'hidden', fullscreenHide );
667
mceEditor.settings.wp_autoresize_on = true;
668
mceEditor.execCommand( 'wpAutoResizeOn' );
670
if ( ! mceEditor.isHidden() ) {
608
671
mceEditor.execCommand( 'wpAutoResize' );
675
if ( ! mceEditor || mceEditor.isHidden() ) {
681
$document.trigger( 'editor-expand-on' );
685
var height = window.getUserSetting('ed_size');
687
// Scroll to the top when triggering this from JS.
688
// Ensures toolbars are reset properly.
689
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
690
window.scrollTo( window.pageXOffset, 0 );
693
$wrap.removeClass( 'wp-editor-expand' );
695
$window.off( '.editor-expand' );
696
$document.off( '.editor-expand' );
697
$textEditor.off( '.editor-expand' );
700
// Adjust when entering/exiting fullscreen mode.
701
fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide );
704
$.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) {
705
element && element.attr( 'style', '' );
614
$textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize );
615
$textEditor.on( 'keyup.editor-expand', textEditorKeyup );
618
// Adjust when entering/exiting fullscreen mode.
619
fullscreen && fullscreen.pubsub.subscribe( 'hidden', fullscreenHide );
622
mceEditor.settings.wp_autoresize_on = true;
623
mceEditor.execCommand( 'wpAutoResizeOn' );
625
if ( ! mceEditor.isHidden() ) {
626
mceEditor.execCommand( 'wpAutoResize' );
630
if ( ! mceEditor || mceEditor.isHidden() ) {
638
var height = window.getUserSetting('ed_size');
640
// Scroll to the top when triggering this from JS.
641
// Ensures toolbars are reset properly.
642
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
643
window.scrollTo( window.pageXOffset, 0 );
646
$wrap.removeClass( 'wp-editor-expand' );
648
$window.off( '.editor-expand' );
649
$document.off( '.editor-expand' );
650
$textEditor.off( '.editor-expand' );
653
// Adjust when entering/exiting fullscreen mode.
654
fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide );
657
$.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) {
658
element && element.attr( 'style', '' );
708
fixedTop = fixedBottom = fixedSideTop = fixedSideBottom = false;
711
mceEditor.settings.wp_autoresize_on = false;
712
mceEditor.execCommand( 'wpAutoResizeOff' );
714
if ( ! mceEditor.isHidden() ) {
718
mceEditor.theme.resizeTo( null, height );
724
$textEditor.height( height );
727
$document.trigger( 'editor-expand-off' );
731
if ( $wrap.hasClass( 'wp-editor-expand' ) ) {
734
// Ideally we need to resize just after CSS has fully loaded and QuickTags is ready.
735
if ( $contentWrap.hasClass( 'html-active' ) ) {
736
initialResize( function() {
743
// Show the on/off checkbox
744
$( '#adv-settings .editor-expand' ).show();
745
$( '#editor-expand-toggle' ).on( 'change.editor-expand', function() {
746
if ( $(this).prop( 'checked' ) ) {
748
window.setUserSetting( 'editor_expand', 'on' );
751
window.setUserSetting( 'editor_expand', 'off' );
661
fixedTop = fixedBottom = fixedSideTop = fixedSideBottom = false;
664
mceEditor.settings.wp_autoresize_on = false;
665
mceEditor.execCommand( 'wpAutoResizeOff' );
667
if ( ! mceEditor.isHidden() ) {
671
mceEditor.theme.resizeTo( null, height );
677
$textEditor.height( height );
682
if ( $wrap.hasClass( 'wp-editor-expand' ) ) {
685
// Ideally we need to resize just after CSS has fully loaded and QuickTags is ready.
686
if ( $contentWrap.hasClass( 'html-active' ) ) {
687
initialResize( function() {
755
// Expose on() and off()
756
window.editorExpand = {
764
var $body = $( document.body ),
765
$wrap = $( '#wpcontent' ),
766
$editor = $( '#post-body-content' ),
767
$title = $( '#title' ),
768
$content = $( '#content' ),
769
$overlay = $( document.createElement( 'DIV' ) ),
770
$slug = $( '#edit-slug-box' ),
771
$slugFocusEl = $slug.find( 'a' )
772
.add( $slug.find( 'button' ) )
773
.add( $slug.find( 'input' ) ),
774
$menuWrap = $( '#adminmenuwrap' ),
777
_isActive = window.getUserSetting( 'editor_expand', 'on' ) === 'on',
778
_isOn = _isActive ? window.getUserSetting( 'post_dfw' ) === 'on' : false,
782
faded, fadedAdminBar, fadedSlug,
783
editorRect, x, y, mouseY, scrollY,
784
focusLostTimer, overlayTimer, editorHasFocus;
786
$body.append( $overlay );
791
top: $adminBar.height(),
802
$window.on( 'mousemove.focus', function( event ) {
803
mouseY = event.pageY;
806
function recalcEditorRect() {
807
editorRect = $editor.offset();
808
editorRect.right = editorRect.left + $editor.outerWidth();
809
editorRect.bottom = editorRect.top + $editor.outerHeight();
812
function activate() {
816
$document.trigger( 'dfw-activate' );
817
$content.on( 'keydown.focus-shortcut', toggleViaKeyboard );
821
function deactivate() {
827
$document.trigger( 'dfw-deactivate' );
828
$content.off( 'keydown.focus-shortcut' );
832
function isActive() {
837
if ( ! _isOn && _isActive ) {
840
$content.on( 'keydown.focus', fadeOut );
842
$title.add( $content ).on( 'blur.focus', maybeFadeIn );
846
window.setUserSetting( 'post_dfw', 'on' );
848
$document.trigger( 'dfw-on' );
856
$title.add( $content ).off( '.focus' );
860
$editor.off( '.focus' );
862
window.setUserSetting( 'post_dfw', 'off' );
864
$document.trigger( 'dfw-off' );
880
function fadeOut( event ) {
881
var key = event && event.keyCode;
883
// fadeIn and return on Escape and keyboard shortcut Alt+Shift+W.
884
if ( key === 27 || ( key === 87 && event.altKey && event.shiftKey ) ) {
889
if ( event && ( event.metaKey || ( event.ctrlKey && ! event.altKey ) || ( event.altKey && event.shiftKey ) || ( key && (
890
// Special keys ( tab, ctrl, alt, esc, arrow keys... )
891
( key <= 47 && key !== 8 && key !== 13 && key !== 32 && key !== 46 ) ||
893
( key >= 91 && key <= 93 ) ||
895
( key >= 112 && key <= 135 ) ||
896
// Num Lock, Scroll Lock, OEM
897
( key >= 144 && key <= 150 ) ||
898
// OEM or non-printable
907
clearTimeout( overlayTimer );
909
overlayTimer = setTimeout( function() {
913
$editor.css( 'z-index', 9998 );
916
// Always recalculate the editor area entering the overlay with the mouse.
917
.on( 'mouseenter.focus', function() {
920
$window.on( 'scroll.focus', function() {
921
var nScrollY = window.pageYOffset;
927
mouseY < editorRect.top - buffer ||
928
mouseY > editorRect.bottom + buffer
936
.on( 'mouseleave.focus', function() {
938
traveledX = traveledY = 0;
940
$window.off( 'scroll.focus' );
942
// Fade in when the mouse moves away form the editor area.
943
.on( 'mousemove.focus', function( event ) {
944
var nx = event.clientX,
946
pageYOffset = window.pageYOffset,
947
pageXOffset = window.pageXOffset;
949
if ( x && y && ( nx !== x || ny !== y ) ) {
951
( ny <= y && ny < editorRect.top - pageYOffset ) ||
952
( ny >= y && ny > editorRect.bottom - pageYOffset ) ||
953
( nx <= x && nx < editorRect.left - pageXOffset ) ||
954
( nx >= x && nx > editorRect.right - pageXOffset )
956
traveledX += Math.abs( x - nx );
957
traveledY += Math.abs( y - ny );
960
ny <= editorRect.top - buffer - pageYOffset ||
961
ny >= editorRect.bottom + buffer - pageYOffset ||
962
nx <= editorRect.left - buffer - pageXOffset ||
963
nx >= editorRect.right + buffer - pageXOffset
971
traveledX = traveledY = 0;
976
traveledX = traveledY = 0;
983
// When the overlay is touched, always fade in and cancel the event.
984
.on( 'touchstart.focus', function( event ) {
985
event.preventDefault();
989
$editor.off( 'mouseenter.focus' );
991
if ( focusLostTimer ) {
992
clearTimeout( focusLostTimer );
993
focusLostTimer = null;
996
$body.addClass( 'focus-on' ).removeClass( 'focus-off' );
1003
function fadeIn( event ) {
1007
clearTimeout( overlayTimer );
1009
overlayTimer = setTimeout( function() {
1013
$editor.css( 'z-index', '' );
1015
$overlay.off( 'mouseenter.focus mouseleave.focus mousemove.focus touchstart.focus' );
1018
* When fading in, temporarily watch for refocus and fade back out - helps
1019
* with 'accidental' editor exits with the mouse. When fading in and the event
1020
* is a key event (Escape or Alt+Shift+W) don't watch for refocus.
1022
if ( 'undefined' === typeof event ) {
1023
$editor.on( 'mouseenter.focus', function() {
1024
if ( $.contains( $editor.get( 0 ), document.activeElement ) || editorHasFocus ) {
1030
focusLostTimer = setTimeout( function() {
1031
focusLostTimer = null;
1032
$editor.off( 'mouseenter.focus' );
1035
$body.addClass( 'focus-off' ).removeClass( 'focus-on' );
1042
function maybeFadeIn() {
1043
setTimeout( function() {
1044
var position = document.activeElement.compareDocumentPosition( $editor.get( 0 ) );
1046
function hasFocus( $el ) {
1047
return $.contains( $el.get( 0 ), document.activeElement );
1050
// The focused node is before or behind the editor area, and not outside the wrap.
1051
if ( ( position === 2 || position === 4 ) && ( hasFocus( $menuWrap ) || hasFocus( $wrap ) || hasFocus( $footer ) ) ) {
1057
function fadeOutAdminBar() {
1058
if ( ! fadedAdminBar && faded ) {
1059
fadedAdminBar = true;
1062
.on( 'mouseenter.focus', function() {
1063
$adminBar.addClass( 'focus-off' );
1065
.on( 'mouseleave.focus', function() {
1066
$adminBar.removeClass( 'focus-off' );
1071
function fadeInAdminBar() {
1072
if ( fadedAdminBar ) {
1073
fadedAdminBar = false;
1075
$adminBar.off( '.focus' );
1079
function fadeOutSlug() {
1080
if ( ! fadedSlug && faded && ! $slug.find( ':focus').length ) {
1083
$slug.stop().fadeTo( 'fast', 0.3 ).on( 'mouseenter.focus', fadeInSlug ).off( 'mouseleave.focus' );
1085
$slugFocusEl.on( 'focus.focus', fadeInSlug ).off( 'blur.focus' );
1089
function fadeInSlug() {
1093
$slug.stop().fadeTo( 'fast', 1 ).on( 'mouseleave.focus', fadeOutSlug ).off( 'mouseenter.focus' );
1095
$slugFocusEl.on( 'blur.focus', fadeOutSlug ).off( 'focus.focus' );
1099
function toggleViaKeyboard( event ) {
1100
if ( event.altKey && event.shiftKey && 87 === event.keyCode ) {
1105
if ( $( '#postdivrich' ).hasClass( 'wp-editor-expand' ) ) {
1106
$content.on( 'keydown.focus-shortcut', toggleViaKeyboard );
1109
$document.on( 'tinymce-editor-setup.focus', function( event, editor ) {
1110
editor.addButton( 'dfw', {
1112
classes: 'wp-dfw btn widget',
1113
disabled: ! _isActive,
1115
onPostRender: function() {
1119
.on( 'dfw-activate.focus', function() {
1120
button.disabled( false );
1122
.on( 'dfw-deactivate.focus', function() {
1123
button.disabled( true );
1125
.on( 'dfw-on.focus', function() {
1126
button.active( true );
1128
.on( 'dfw-off.focus', function() {
1129
button.active( false );
1132
tooltip: 'Distraction-free writing mode',
1133
shortcut: 'Alt+Shift+W'
694
// Show the on/off checkbox
695
$( '#adv-settings .editor-expand' ).show();
696
$( '#editor-expand-toggle' ).on( 'change.editor-expand', function() {
697
if ( $(this).prop( 'checked' ) ) {
699
window.setUserSetting( 'editor_expand', 'on' );
702
window.setUserSetting( 'editor_expand', 'off' );
706
// Expose on() and off()
707
window.editorExpand = {
1136
editor.addCommand( 'wpToggleDFW', toggle );
1137
editor.addShortcut( 'alt+shift+w', '', 'wpToggleDFW' );
1140
$document.on( 'tinymce-editor-init.focus', function( event, editor ) {
1141
var mceBind, mceUnbind;
1144
editorHasFocus = true;
1148
editorHasFocus = false;
1151
if ( editor.id === 'content' ) {
1152
$editorWindow = $( editor.getWin() );
1153
$editorIframe = $( editor.getContentAreaContainer() ).find( 'iframe' );
1155
mceBind = function() {
1156
editor.on( 'keydown', fadeOut );
1157
editor.on( 'blur', maybeFadeIn );
1158
editor.on( 'focus', focus );
1159
editor.on( 'blur', blur );
1160
editor.on( 'wp-autoresize', recalcEditorRect );
1163
mceUnbind = function() {
1164
editor.off( 'keydown', fadeOut );
1165
editor.off( 'blur', maybeFadeIn );
1166
editor.off( 'focus', focus );
1167
editor.off( 'blur', blur );
1168
editor.off( 'wp-autoresize', recalcEditorRect );
1175
$document.on( 'dfw-on.focus', mceBind ).on( 'dfw-off.focus', mceUnbind );
1177
// Make sure the body focuses when clicking outside it.
1178
editor.on( 'click', function( event ) {
1179
if ( event.target === editor.getDoc().documentElement ) {
1186
$document.on( 'quicktags-init', function( event, editor ) {
1189
if ( editor.settings.buttons && ( ',' + editor.settings.buttons + ',' ).indexOf( ',dfw,' ) !== -1 ) {
1190
$button = $( '#' + editor.name + '_dfw' );
1193
.on( 'dfw-activate', function() {
1194
$button.prop( 'disabled', false );
1196
.on( 'dfw-deactivate', function() {
1197
$button.prop( 'disabled', true );
1199
.on( 'dfw-on', function() {
1200
$button.addClass( 'active' );
1202
.on( 'dfw-off', function() {
1203
$button.removeClass( 'active' );
1208
$document.on( 'editor-expand-on.focus', activate ).on( 'editor-expand-off.focus', deactivate );
1211
$content.on( 'keydown.focus', fadeOut );
1213
$title.add( $content ).on( 'blur.focus', maybeFadeIn );
1216
window.wp = window.wp || {};
1217
window.wp.editor = window.wp.editor || {};
1218
window.wp.editor.dfw = {
1220
deactivate: deactivate,
1228
} )( window, window.jQuery );