author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
9 | 1 |
/** |
2 |
* @output wp-admin/js/editor-expand.js |
|
3 |
*/ |
|
4 |
||
5 | 5 |
( function( window, $, undefined ) { |
6 |
'use strict'; |
|
7 |
||
8 |
var $window = $( window ), |
|
9 |
$document = $( document ), |
|
10 |
$adminBar = $( '#wpadminbar' ), |
|
11 |
$footer = $( '#wpfooter' ); |
|
12 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
/** |
9 | 14 |
* Handles the resizing of the editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
* |
16 | 18 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
*/ |
5 | 20 |
$( function() { |
21 |
var $wrap = $( '#postdivrich' ), |
|
22 |
$contentWrap = $( '#wp-content-wrap' ), |
|
23 |
$tools = $( '#wp-content-editor-tools' ), |
|
24 |
$visualTop = $(), |
|
25 |
$visualEditor = $(), |
|
26 |
$textTop = $( '#ed_toolbar' ), |
|
27 |
$textEditor = $( '#content' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
textEditor = $textEditor[0], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
oldTextLength = 0, |
5 | 30 |
$bottom = $( '#post-status-info' ), |
31 |
$menuBar = $(), |
|
32 |
$statusBar = $(), |
|
33 |
$sideSortables = $( '#side-sortables' ), |
|
34 |
$postboxContainer = $( '#postbox-container-1' ), |
|
35 |
$postBody = $('#post-body'), |
|
36 |
fullscreen = window.wp.editor && window.wp.editor.fullscreen, |
|
37 |
mceEditor, |
|
38 |
mceBind = function(){}, |
|
39 |
mceUnbind = function(){}, |
|
40 |
fixedTop = false, |
|
41 |
fixedBottom = false, |
|
42 |
fixedSideTop = false, |
|
43 |
fixedSideBottom = false, |
|
44 |
scrollTimer, |
|
45 |
lastScrollPosition = 0, |
|
46 |
pageYOffsetAtTop = 130, |
|
47 |
pinnedToolsTop = 56, |
|
48 |
sidebarBottom = 20, |
|
49 |
autoresizeMinHeight = 300, |
|
50 |
initialMode = $contentWrap.hasClass( 'tmce-active' ) ? 'tinymce' : 'html', |
|
51 |
advanced = !! parseInt( window.getUserSetting( 'hidetb' ), 10 ), |
|
52 |
// These are corrected when adjust() runs, except on scrolling if already set. |
|
53 |
heights = { |
|
54 |
windowHeight: 0, |
|
55 |
windowWidth: 0, |
|
56 |
adminBarHeight: 0, |
|
57 |
toolsHeight: 0, |
|
58 |
menuBarHeight: 0, |
|
59 |
visualTopHeight: 0, |
|
60 |
textTopHeight: 0, |
|
61 |
bottomHeight: 0, |
|
62 |
statusBarHeight: 0, |
|
63 |
sideSortablesHeight: 0 |
|
64 |
}; |
|
65 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
/** |
9 | 67 |
* Resizes textarea based on scroll height and width. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
* |
9 | 69 |
* Doesn't shrink the editor size below the 300px auto resize minimum height. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
* @since 4.6.1 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
* |
16 | 73 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
var shrinkTextarea = window._.throttle( function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
var x = window.scrollX || document.documentElement.scrollLeft; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
var y = window.scrollY || document.documentElement.scrollTop; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
var height = parseInt( textEditor.style.height, 10 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
textEditor.style.height = autoresizeMinHeight + 'px'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
if ( textEditor.scrollHeight > autoresizeMinHeight ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
textEditor.style.height = textEditor.scrollHeight + 'px'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
if ( typeof x !== 'undefined' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
window.scrollTo( x, y ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
if ( textEditor.scrollHeight < height ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
adjust(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
}, 300 ); |
5 | 94 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
/** |
9 | 96 |
* Resizes the text editor depending on the old text length. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
* If there is an mceEditor and it is hidden, it resizes the editor depending |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
* on the old text length. If the current length of the text is smaller than |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
* the old text length, it shrinks the text area. Otherwise it resizes the editor to |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
* the scroll height. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
* @since 4.6.1 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
* |
16 | 105 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
function textEditorResize() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
var length = textEditor.value.length; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
if ( mceEditor && ! mceEditor.isHidden() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
if ( ! mceEditor && initialMode === 'tinymce' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
} |
5 | 117 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
if ( length < oldTextLength ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
shrinkTextarea(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
} else if ( parseInt( textEditor.style.height, 10 ) < textEditor.scrollHeight ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
textEditor.style.height = Math.ceil( textEditor.scrollHeight ) + 'px'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
adjust(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
oldTextLength = length; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
/** |
9 | 129 |
* Gets the height and widths of elements. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
* Gets the heights of the window, the adminbar, the tools, the menu, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
* the visualTop, the textTop, the bottom, the statusbar and sideSortables |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
* and stores these in the heights object. Defaults to 0. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* Gets the width of the window and stores this in the heights object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
* |
16 | 138 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
*/ |
5 | 140 |
function getHeights() { |
141 |
var windowWidth = $window.width(); |
|
142 |
||
143 |
heights = { |
|
144 |
windowHeight: $window.height(), |
|
145 |
windowWidth: windowWidth, |
|
146 |
adminBarHeight: ( windowWidth > 600 ? $adminBar.outerHeight() : 0 ), |
|
147 |
toolsHeight: $tools.outerHeight() || 0, |
|
148 |
menuBarHeight: $menuBar.outerHeight() || 0, |
|
149 |
visualTopHeight: $visualTop.outerHeight() || 0, |
|
150 |
textTopHeight: $textTop.outerHeight() || 0, |
|
151 |
bottomHeight: $bottom.outerHeight() || 0, |
|
152 |
statusBarHeight: $statusBar.outerHeight() || 0, |
|
153 |
sideSortablesHeight: $sideSortables.height() || 0 |
|
154 |
}; |
|
155 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
// Adjust for hidden menubar. |
5 | 157 |
if ( heights.menuBarHeight < 3 ) { |
158 |
heights.menuBarHeight = 0; |
|
159 |
} |
|
160 |
} |
|
161 |
||
162 |
// We need to wait for TinyMCE to initialize. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
/** |
9 | 164 |
* Binds all necessary functions for editor expand to the editor when the editor |
165 |
* is initialized. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
* @param {event} event The TinyMCE editor init event. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
* @param {object} editor The editor to bind the vents on. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
* |
16 | 172 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
*/ |
5 | 174 |
$document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
// VK contains the type of key pressed. VK = virtual keyboard. |
5 | 176 |
var VK = window.tinymce.util.VK, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
/** |
9 | 178 |
* Hides any float panel with a hover state. Additionally hides tooltips. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
* |
16 | 180 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
*/ |
5 | 182 |
hideFloatPanels = _.debounce( function() { |
183 |
! $( '.mce-floatpanel:hover' ).length && window.tinymce.ui.FloatPanel.hideAll(); |
|
184 |
$( '.mce-tooltip' ).hide(); |
|
185 |
}, 1000, true ); |
|
186 |
||
187 |
// Make sure it's the main editor. |
|
188 |
if ( editor.id !== 'content' ) { |
|
189 |
return; |
|
190 |
} |
|
191 |
||
192 |
// Copy the editor instance. |
|
193 |
mceEditor = editor; |
|
194 |
||
195 |
// Set the minimum height to the initial viewport height. |
|
196 |
editor.settings.autoresize_min_height = autoresizeMinHeight; |
|
197 |
||
198 |
// Get the necessary UI elements. |
|
199 |
$visualTop = $contentWrap.find( '.mce-toolbar-grp' ); |
|
200 |
$visualEditor = $contentWrap.find( '.mce-edit-area' ); |
|
201 |
$statusBar = $contentWrap.find( '.mce-statusbar' ); |
|
202 |
$menuBar = $contentWrap.find( '.mce-menubar' ); |
|
203 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
/** |
9 | 205 |
* Gets the offset of the editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
* |
16 | 207 |
* @return {number|boolean} Returns the offset of the editor |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
* or false if there is no offset height. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
*/ |
5 | 210 |
function mceGetCursorOffset() { |
211 |
var node = editor.selection.getNode(), |
|
212 |
range, view, offset; |
|
213 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
* If editor.wp.getView and the selection node from the editor selection |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
* are defined, use this as a view for the offset. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
*/ |
5 | 218 |
if ( editor.wp && editor.wp.getView && ( view = editor.wp.getView( node ) ) ) { |
219 |
offset = view.getBoundingClientRect(); |
|
220 |
} else { |
|
221 |
range = editor.selection.getRng(); |
|
222 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
// Try to get the offset from a range. |
5 | 224 |
try { |
225 |
offset = range.getClientRects()[0]; |
|
226 |
} catch( er ) {} |
|
227 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
228 |
// Get the offset from the bounding client rectangle of the node. |
5 | 229 |
if ( ! offset ) { |
230 |
offset = node.getBoundingClientRect(); |
|
231 |
} |
|
232 |
} |
|
233 |
||
234 |
return offset.height ? offset : false; |
|
235 |
} |
|
236 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
/** |
9 | 238 |
* Filters the special keys that should not be used for scrolling. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
242 |
* @param {event} event The event to get the key code from. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
243 |
* |
16 | 244 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
*/ |
5 | 246 |
function mceKeyup( event ) { |
247 |
var key = event.keyCode; |
|
248 |
||
16 | 249 |
// Bail on special keys. Key code 47 is a '/'. |
5 | 250 |
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 ) ) { |
251 |
return; |
|
16 | 252 |
// OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys. |
253 |
// Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock. |
|
5 | 254 |
} else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) { |
255 |
return; |
|
256 |
} |
|
257 |
||
258 |
mceScroll( key ); |
|
259 |
} |
|
260 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
/** |
9 | 262 |
* Makes sure the cursor is always visible in the editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
* Makes sure the cursor is kept between the toolbars of the editor and scrolls |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
* the window when the cursor moves out of the viewport to a wpview. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
* Setting a buffer > 0 will prevent the browser default. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
* Some browsers will scroll to the middle, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
* others to the top/bottom of the *window* when moving the cursor out of the viewport. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
* @param {string} key The key code of the pressed key. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
* |
16 | 274 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
*/ |
5 | 276 |
function mceScroll( key ) { |
277 |
var offset = mceGetCursorOffset(), |
|
278 |
buffer = 50, |
|
279 |
cursorTop, cursorBottom, editorTop, editorBottom; |
|
280 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
// Don't scroll if there is no offset. |
5 | 282 |
if ( ! offset ) { |
283 |
return; |
|
284 |
} |
|
285 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
// Determine the cursorTop based on the offset and the top of the editor iframe. |
5 | 287 |
cursorTop = offset.top + editor.iframeElement.getBoundingClientRect().top; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
// Determine the cursorBottom based on the cursorTop and offset height. |
5 | 290 |
cursorBottom = cursorTop + offset.height; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
// Subtract the buffer from the cursorTop. |
5 | 293 |
cursorTop = cursorTop - buffer; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
// Add the buffer to the cursorBottom. |
5 | 296 |
cursorBottom = cursorBottom + buffer; |
297 |
editorTop = heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight + heights.visualTopHeight; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
* Set the editorBottom based on the window Height, and add the bottomHeight and statusBarHeight if the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
* advanced editor is enabled. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
*/ |
5 | 303 |
editorBottom = heights.windowHeight - ( advanced ? heights.bottomHeight + heights.statusBarHeight : 0 ); |
304 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
// Don't scroll if the node is taller than the visible part of the editor. |
5 | 306 |
if ( editorBottom - editorTop < offset.height ) { |
307 |
return; |
|
308 |
} |
|
309 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
* If the cursorTop is smaller than the editorTop and the up, left |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
* or backspace key is pressed, scroll the editor to the position defined |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
* by the cursorTop, pageYOffset and editorTop. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
*/ |
5 | 315 |
if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) { |
316 |
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
* If any other key is pressed or the cursorTop is bigger than the editorTop, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
* scroll the editor to the position defined by the cursorBottom, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
* pageYOffset and editorBottom. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
*/ |
5 | 323 |
} else if ( cursorBottom > editorBottom ) { |
324 |
window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom ); |
|
325 |
} |
|
326 |
} |
|
327 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
/** |
9 | 329 |
* If the editor is fullscreen, calls adjust. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
* @param {event} event The FullscreenStateChanged event. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
* |
16 | 335 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
*/ |
5 | 337 |
function mceFullscreenToggled( event ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
// event.state is true if the editor is fullscreen. |
5 | 339 |
if ( ! event.state ) { |
340 |
adjust(); |
|
341 |
} |
|
342 |
} |
|
343 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
/** |
9 | 345 |
* Shows the editor when scrolled. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
* Binds the hideFloatPanels function on the window scroll.mce-float-panels event. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
* Executes the wpAutoResize on the active editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
* |
16 | 352 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
*/ |
5 | 354 |
function mceShow() { |
355 |
$window.on( 'scroll.mce-float-panels', hideFloatPanels ); |
|
356 |
||
357 |
setTimeout( function() { |
|
358 |
editor.execCommand( 'wpAutoResize' ); |
|
359 |
adjust(); |
|
360 |
}, 300 ); |
|
361 |
} |
|
362 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
/** |
9 | 364 |
* Resizes the editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
* Removes all functions from the window scroll.mce-float-panels event. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
* Resizes the text editor and scrolls to a position based on the pageXOffset and adminBarHeight. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
* |
16 | 371 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
*/ |
5 | 373 |
function mceHide() { |
374 |
$window.off( 'scroll.mce-float-panels' ); |
|
375 |
||
376 |
setTimeout( function() { |
|
377 |
var top = $contentWrap.offset().top; |
|
378 |
||
379 |
if ( window.pageYOffset > top ) { |
|
380 |
window.scrollTo( window.pageXOffset, top - heights.adminBarHeight ); |
|
381 |
} |
|
382 |
||
383 |
textEditorResize(); |
|
384 |
adjust(); |
|
385 |
}, 100 ); |
|
386 |
||
387 |
adjust(); |
|
388 |
} |
|
389 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
/** |
9 | 391 |
* Toggles advanced states. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
* |
16 | 395 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
*/ |
5 | 397 |
function toggleAdvanced() { |
398 |
advanced = ! advanced; |
|
399 |
} |
|
400 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
/** |
9 | 402 |
* Binds events of the editor and window. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
* |
16 | 406 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
*/ |
5 | 408 |
mceBind = function() { |
409 |
editor.on( 'keyup', mceKeyup ); |
|
410 |
editor.on( 'show', mceShow ); |
|
411 |
editor.on( 'hide', mceHide ); |
|
412 |
editor.on( 'wp-toolbar-toggle', toggleAdvanced ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
|
5 | 414 |
// Adjust when the editor resizes. |
415 |
editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
|
5 | 417 |
// Don't hide the caret after undo/redo. |
418 |
editor.on( 'undo redo', mceScroll ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
|
5 | 420 |
// Adjust when exiting TinyMCE's fullscreen mode. |
421 |
editor.on( 'FullscreenStateChanged', mceFullscreenToggled ); |
|
422 |
||
423 |
$window.off( 'scroll.mce-float-panels' ).on( 'scroll.mce-float-panels', hideFloatPanels ); |
|
424 |
}; |
|
425 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
/** |
9 | 427 |
* Unbinds the events of the editor and window. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
* |
16 | 431 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
*/ |
5 | 433 |
mceUnbind = function() { |
434 |
editor.off( 'keyup', mceKeyup ); |
|
435 |
editor.off( 'show', mceShow ); |
|
436 |
editor.off( 'hide', mceHide ); |
|
437 |
editor.off( 'wp-toolbar-toggle', toggleAdvanced ); |
|
438 |
editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); |
|
439 |
editor.off( 'undo redo', mceScroll ); |
|
440 |
editor.off( 'FullscreenStateChanged', mceFullscreenToggled ); |
|
441 |
||
442 |
$window.off( 'scroll.mce-float-panels' ); |
|
443 |
}; |
|
444 |
||
445 |
if ( $wrap.hasClass( 'wp-editor-expand' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
// Adjust "immediately". |
5 | 448 |
mceBind(); |
449 |
initialResize( adjust ); |
|
450 |
} |
|
451 |
} ); |
|
452 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
/** |
9 | 454 |
* Adjusts the toolbars heights and positions. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
* |
9 | 456 |
* Adjusts the toolbars heights and positions based on the scroll position on |
457 |
* the page, the active editor mode and the heights of the editor, admin bar and |
|
458 |
* side bar. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
* @param {event} event The event that calls this function. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
* |
16 | 464 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
*/ |
5 | 466 |
function adjust( event ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
// Makes sure we're not in fullscreen mode. |
5 | 469 |
if ( fullscreen && fullscreen.settings.visible ) { |
470 |
return; |
|
471 |
} |
|
472 |
||
473 |
var windowPos = $window.scrollTop(), |
|
474 |
type = event && event.type, |
|
475 |
resize = type !== 'scroll', |
|
476 |
visual = mceEditor && ! mceEditor.isHidden(), |
|
477 |
buffer = autoresizeMinHeight, |
|
478 |
postBodyTop = $postBody.offset().top, |
|
479 |
borderWidth = 1, |
|
480 |
contentWrapWidth = $contentWrap.width(), |
|
481 |
$top, $editor, sidebarTop, footerTop, canPin, |
|
482 |
topPos, topHeight, editorPos, editorHeight; |
|
483 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
485 |
* Refresh the heights if type isn't 'scroll' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
* or heights.windowHeight isn't set. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
*/ |
5 | 488 |
if ( resize || ! heights.windowHeight ) { |
489 |
getHeights(); |
|
490 |
} |
|
491 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
// Resize on resize event when the editor is in text mode. |
5 | 493 |
if ( ! visual && type === 'resize' ) { |
494 |
textEditorResize(); |
|
495 |
} |
|
496 |
||
497 |
if ( visual ) { |
|
498 |
$top = $visualTop; |
|
499 |
$editor = $visualEditor; |
|
500 |
topHeight = heights.visualTopHeight; |
|
501 |
} else { |
|
502 |
$top = $textTop; |
|
503 |
$editor = $textEditor; |
|
504 |
topHeight = heights.textTopHeight; |
|
505 |
} |
|
506 |
||
9 | 507 |
// Return if TinyMCE is still initializing. |
5 | 508 |
if ( ! visual && ! $top.length ) { |
509 |
return; |
|
510 |
} |
|
511 |
||
512 |
topPos = $top.parent().offset().top; |
|
513 |
editorPos = $editor.offset().top; |
|
514 |
editorHeight = $editor.outerHeight(); |
|
515 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
* If in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + topHeight. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
* If not in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + 20. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
519 |
*/ |
16 | 520 |
canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding. |
5 | 521 |
canPin = editorHeight > ( canPin + 5 ); |
522 |
||
523 |
if ( ! canPin ) { |
|
524 |
if ( resize ) { |
|
525 |
$tools.css( { |
|
526 |
position: 'absolute', |
|
527 |
top: 0, |
|
528 |
width: contentWrapWidth |
|
529 |
} ); |
|
530 |
||
531 |
if ( visual && $menuBar.length ) { |
|
532 |
$menuBar.css( { |
|
533 |
position: 'absolute', |
|
534 |
top: 0, |
|
535 |
width: contentWrapWidth - ( borderWidth * 2 ) |
|
536 |
} ); |
|
537 |
} |
|
538 |
||
539 |
$top.css( { |
|
540 |
position: 'absolute', |
|
541 |
top: heights.menuBarHeight, |
|
542 |
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) |
|
543 |
} ); |
|
544 |
||
545 |
$statusBar.attr( 'style', advanced ? '' : 'visibility: hidden;' ); |
|
546 |
$bottom.attr( 'style', '' ); |
|
547 |
} |
|
548 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
// Check if the top is not already in a fixed position. |
5 | 550 |
if ( ( ! fixedTop || resize ) && |
551 |
( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight ) && |
|
552 |
windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) ) { |
|
553 |
fixedTop = true; |
|
554 |
||
555 |
$tools.css( { |
|
556 |
position: 'fixed', |
|
557 |
top: heights.adminBarHeight, |
|
558 |
width: contentWrapWidth |
|
559 |
} ); |
|
560 |
||
561 |
if ( visual && $menuBar.length ) { |
|
562 |
$menuBar.css( { |
|
563 |
position: 'fixed', |
|
564 |
top: heights.adminBarHeight + heights.toolsHeight, |
|
565 |
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) |
|
566 |
} ); |
|
567 |
} |
|
568 |
||
569 |
$top.css( { |
|
570 |
position: 'fixed', |
|
571 |
top: heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight, |
|
572 |
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) |
|
573 |
} ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
// Check if the top is already in a fixed position. |
5 | 575 |
} else if ( fixedTop || resize ) { |
576 |
if ( windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight ) ) { |
|
577 |
fixedTop = false; |
|
578 |
||
579 |
$tools.css( { |
|
580 |
position: 'absolute', |
|
581 |
top: 0, |
|
582 |
width: contentWrapWidth |
|
583 |
} ); |
|
584 |
||
585 |
if ( visual && $menuBar.length ) { |
|
586 |
$menuBar.css( { |
|
587 |
position: 'absolute', |
|
588 |
top: 0, |
|
589 |
width: contentWrapWidth - ( borderWidth * 2 ) |
|
590 |
} ); |
|
591 |
} |
|
592 |
||
593 |
$top.css( { |
|
594 |
position: 'absolute', |
|
595 |
top: heights.menuBarHeight, |
|
596 |
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) |
|
597 |
} ); |
|
598 |
} else if ( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) { |
|
599 |
fixedTop = false; |
|
600 |
||
601 |
$tools.css( { |
|
602 |
position: 'absolute', |
|
603 |
top: editorHeight - buffer, |
|
604 |
width: contentWrapWidth |
|
605 |
} ); |
|
606 |
||
607 |
if ( visual && $menuBar.length ) { |
|
608 |
$menuBar.css( { |
|
609 |
position: 'absolute', |
|
610 |
top: editorHeight - buffer, |
|
611 |
width: contentWrapWidth - ( borderWidth * 2 ) |
|
612 |
} ); |
|
613 |
} |
|
614 |
||
615 |
$top.css( { |
|
616 |
position: 'absolute', |
|
617 |
top: editorHeight - buffer + heights.menuBarHeight, |
|
618 |
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) |
|
619 |
} ); |
|
620 |
} |
|
621 |
} |
|
622 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
// Check if the bottom is not already in a fixed position. |
5 | 624 |
if ( ( ! fixedBottom || ( resize && advanced ) ) && |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
// Add borderWidth for the border around the .wp-editor-container. |
5 | 626 |
( windowPos + heights.windowHeight ) <= ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight + borderWidth ) ) { |
627 |
||
628 |
if ( event && event.deltaHeight > 0 && event.deltaHeight < 100 ) { |
|
629 |
window.scrollBy( 0, event.deltaHeight ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
630 |
} else if ( visual && advanced ) { |
5 | 631 |
fixedBottom = true; |
632 |
||
633 |
$statusBar.css( { |
|
634 |
position: 'fixed', |
|
635 |
bottom: heights.bottomHeight, |
|
636 |
visibility: '', |
|
637 |
width: contentWrapWidth - ( borderWidth * 2 ) |
|
638 |
} ); |
|
639 |
||
640 |
$bottom.css( { |
|
641 |
position: 'fixed', |
|
642 |
bottom: 0, |
|
643 |
width: contentWrapWidth |
|
644 |
} ); |
|
645 |
} |
|
646 |
} else if ( ( ! advanced && fixedBottom ) || |
|
647 |
( ( fixedBottom || resize ) && |
|
648 |
( windowPos + heights.windowHeight ) > ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight - borderWidth ) ) ) { |
|
649 |
fixedBottom = false; |
|
650 |
||
651 |
$statusBar.attr( 'style', advanced ? '' : 'visibility: hidden;' ); |
|
652 |
$bottom.attr( 'style', '' ); |
|
653 |
} |
|
654 |
} |
|
655 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
// The postbox container is positioned with @media from CSS. Ensure it is pinned on the side. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
if ( $postboxContainer.width() < 300 && heights.windowWidth > 600 && |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
// Check if the sidebar is not taller than the document height. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
660 |
$document.height() > ( $sideSortables.height() + postBodyTop + 120 ) && |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
// Check if the editor is taller than the viewport. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
heights.windowHeight < editorHeight ) { |
5 | 664 |
|
665 |
if ( ( heights.sideSortablesHeight + pinnedToolsTop + sidebarBottom ) > heights.windowHeight || fixedSideTop || fixedSideBottom ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
// Reset the sideSortables style when scrolling to the top. |
5 | 668 |
if ( windowPos + pinnedToolsTop <= postBodyTop ) { |
669 |
$sideSortables.attr( 'style', '' ); |
|
670 |
fixedSideTop = fixedSideBottom = false; |
|
671 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
// When scrolling down. |
5 | 674 |
if ( windowPos > lastScrollPosition ) { |
675 |
if ( fixedSideTop ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
676 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
// Let it scroll. |
5 | 678 |
fixedSideTop = false; |
679 |
sidebarTop = $sideSortables.offset().top - heights.adminBarHeight; |
|
680 |
footerTop = $footer.offset().top; |
|
681 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
// Don't get over the footer. |
5 | 683 |
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) { |
684 |
sidebarTop = footerTop - heights.sideSortablesHeight - 12; |
|
685 |
} |
|
686 |
||
687 |
$sideSortables.css({ |
|
688 |
position: 'absolute', |
|
689 |
top: sidebarTop, |
|
690 |
bottom: '' |
|
691 |
}); |
|
692 |
} else if ( ! fixedSideBottom && heights.sideSortablesHeight + $sideSortables.offset().top + sidebarBottom < windowPos + heights.windowHeight ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
// Pin the bottom. |
5 | 694 |
fixedSideBottom = true; |
695 |
||
696 |
$sideSortables.css({ |
|
697 |
position: 'fixed', |
|
698 |
top: 'auto', |
|
699 |
bottom: sidebarBottom |
|
700 |
}); |
|
701 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
// When scrolling up. |
5 | 704 |
} else if ( windowPos < lastScrollPosition ) { |
705 |
if ( fixedSideBottom ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
// Let it scroll. |
5 | 707 |
fixedSideBottom = false; |
708 |
sidebarTop = $sideSortables.offset().top - sidebarBottom; |
|
709 |
footerTop = $footer.offset().top; |
|
710 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
// Don't get over the footer. |
5 | 712 |
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) { |
713 |
sidebarTop = footerTop - heights.sideSortablesHeight - 12; |
|
714 |
} |
|
715 |
||
716 |
$sideSortables.css({ |
|
717 |
position: 'absolute', |
|
718 |
top: sidebarTop, |
|
719 |
bottom: '' |
|
720 |
}); |
|
721 |
} else if ( ! fixedSideTop && $sideSortables.offset().top >= windowPos + pinnedToolsTop ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
// Pin the top. |
5 | 723 |
fixedSideTop = true; |
724 |
||
725 |
$sideSortables.css({ |
|
726 |
position: 'fixed', |
|
727 |
top: pinnedToolsTop, |
|
728 |
bottom: '' |
|
729 |
}); |
|
730 |
} |
|
731 |
} |
|
732 |
} |
|
733 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
// If the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling. |
5 | 735 |
if ( windowPos >= ( postBodyTop - pinnedToolsTop ) ) { |
736 |
||
737 |
$sideSortables.css( { |
|
738 |
position: 'fixed', |
|
739 |
top: pinnedToolsTop |
|
740 |
} ); |
|
741 |
} else { |
|
742 |
$sideSortables.attr( 'style', '' ); |
|
743 |
} |
|
744 |
||
745 |
fixedSideTop = fixedSideBottom = false; |
|
746 |
} |
|
747 |
||
748 |
lastScrollPosition = windowPos; |
|
749 |
} else { |
|
750 |
$sideSortables.attr( 'style', '' ); |
|
751 |
fixedSideTop = fixedSideBottom = false; |
|
752 |
} |
|
753 |
||
754 |
if ( resize ) { |
|
755 |
$contentWrap.css( { |
|
756 |
paddingTop: heights.toolsHeight |
|
757 |
} ); |
|
758 |
||
759 |
if ( visual ) { |
|
760 |
$visualEditor.css( { |
|
761 |
paddingTop: heights.visualTopHeight + heights.menuBarHeight |
|
762 |
} ); |
|
763 |
} else { |
|
764 |
$textEditor.css( { |
|
765 |
marginTop: heights.textTopHeight |
|
766 |
} ); |
|
767 |
} |
|
768 |
} |
|
769 |
} |
|
770 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
/** |
9 | 772 |
* Resizes the editor and adjusts the toolbars. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
775 |
* |
16 | 776 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
*/ |
5 | 778 |
function fullscreenHide() { |
779 |
textEditorResize(); |
|
780 |
adjust(); |
|
781 |
} |
|
782 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
/** |
9 | 784 |
* Runs the passed function with 500ms intervals. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
786 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
* @param {function} callback The function to run in the timeout. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
* |
16 | 790 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
*/ |
5 | 792 |
function initialResize( callback ) { |
793 |
for ( var i = 1; i < 6; i++ ) { |
|
794 |
setTimeout( callback, 500 * i ); |
|
795 |
} |
|
796 |
} |
|
797 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
/** |
9 | 799 |
* Runs adjust after 100ms. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
* |
16 | 803 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
804 |
*/ |
5 | 805 |
function afterScroll() { |
806 |
clearTimeout( scrollTimer ); |
|
807 |
scrollTimer = setTimeout( adjust, 100 ); |
|
808 |
} |
|
809 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
810 |
/** |
9 | 811 |
* Binds editor expand events on elements. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
812 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
814 |
* |
16 | 815 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
816 |
*/ |
5 | 817 |
function on() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
818 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
819 |
* Scroll to the top when triggering this from JS. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
820 |
* Ensure the toolbars are pinned properly. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
821 |
*/ |
5 | 822 |
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { |
823 |
window.scrollTo( window.pageXOffset, 0 ); |
|
824 |
} |
|
825 |
||
826 |
$wrap.addClass( 'wp-editor-expand' ); |
|
827 |
||
828 |
// Adjust when the window is scrolled or resized. |
|
829 |
$window.on( 'scroll.editor-expand resize.editor-expand', function( event ) { |
|
830 |
adjust( event.type ); |
|
831 |
afterScroll(); |
|
832 |
} ); |
|
833 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
834 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
* Adjust when collapsing the menu, changing the columns |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
* or changing the body class. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
837 |
*/ |
5 | 838 |
$document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
839 |
.on( 'postbox-toggled.editor-expand postbox-moved.editor-expand', function() { |
5 | 840 |
if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > pinnedToolsTop ) { |
841 |
fixedSideBottom = true; |
|
842 |
window.scrollBy( 0, -1 ); |
|
843 |
adjust(); |
|
844 |
window.scrollBy( 0, 1 ); |
|
845 |
} |
|
846 |
||
847 |
adjust(); |
|
848 |
}).on( 'wp-window-resized.editor-expand', function() { |
|
849 |
if ( mceEditor && ! mceEditor.isHidden() ) { |
|
850 |
mceEditor.execCommand( 'wpAutoResize' ); |
|
851 |
} else { |
|
852 |
textEditorResize(); |
|
853 |
} |
|
854 |
}); |
|
855 |
||
856 |
$textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); |
|
857 |
mceBind(); |
|
858 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
// Adjust when entering or exiting fullscreen mode. |
5 | 860 |
fullscreen && fullscreen.pubsub.subscribe( 'hidden', fullscreenHide ); |
861 |
||
862 |
if ( mceEditor ) { |
|
863 |
mceEditor.settings.wp_autoresize_on = true; |
|
864 |
mceEditor.execCommand( 'wpAutoResizeOn' ); |
|
865 |
||
866 |
if ( ! mceEditor.isHidden() ) { |
|
867 |
mceEditor.execCommand( 'wpAutoResize' ); |
|
868 |
} |
|
869 |
} |
|
870 |
||
871 |
if ( ! mceEditor || mceEditor.isHidden() ) { |
|
872 |
textEditorResize(); |
|
873 |
} |
|
874 |
||
875 |
adjust(); |
|
876 |
||
877 |
$document.trigger( 'editor-expand-on' ); |
|
878 |
} |
|
879 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
/** |
9 | 881 |
* Unbinds editor expand events. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
882 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
883 |
* @since 4.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
884 |
* |
16 | 885 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
886 |
*/ |
5 | 887 |
function off() { |
888 |
var height = parseInt( window.getUserSetting( 'ed_size', 300 ), 10 ); |
|
889 |
||
890 |
if ( height < 50 ) { |
|
891 |
height = 50; |
|
892 |
} else if ( height > 5000 ) { |
|
893 |
height = 5000; |
|
894 |
} |
|
895 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
896 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
897 |
* Scroll to the top when triggering this from JS. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
* Ensure the toolbars are reset properly. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
899 |
*/ |
5 | 900 |
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { |
901 |
window.scrollTo( window.pageXOffset, 0 ); |
|
902 |
} |
|
903 |
||
904 |
$wrap.removeClass( 'wp-editor-expand' ); |
|
905 |
||
906 |
$window.off( '.editor-expand' ); |
|
907 |
$document.off( '.editor-expand' ); |
|
908 |
$textEditor.off( '.editor-expand' ); |
|
909 |
mceUnbind(); |
|
910 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
// Adjust when entering or exiting fullscreen mode. |
5 | 912 |
fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide ); |
913 |
||
16 | 914 |
// Reset all CSS. |
5 | 915 |
$.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) { |
916 |
element && element.attr( 'style', '' ); |
|
917 |
}); |
|
918 |
||
919 |
fixedTop = fixedBottom = fixedSideTop = fixedSideBottom = false; |
|
920 |
||
921 |
if ( mceEditor ) { |
|
922 |
mceEditor.settings.wp_autoresize_on = false; |
|
923 |
mceEditor.execCommand( 'wpAutoResizeOff' ); |
|
924 |
||
925 |
if ( ! mceEditor.isHidden() ) { |
|
926 |
$textEditor.hide(); |
|
927 |
||
928 |
if ( height ) { |
|
929 |
mceEditor.theme.resizeTo( null, height ); |
|
930 |
} |
|
931 |
} |
|
932 |
} |
|
933 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
// If there is a height found in the user setting. |
5 | 935 |
if ( height ) { |
936 |
$textEditor.height( height ); |
|
937 |
} |
|
938 |
||
939 |
$document.trigger( 'editor-expand-off' ); |
|
940 |
} |
|
941 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
// Start on load. |
5 | 943 |
if ( $wrap.hasClass( 'wp-editor-expand' ) ) { |
944 |
on(); |
|
945 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
// Resize just after CSS has fully loaded and QuickTags is ready. |
5 | 947 |
if ( $contentWrap.hasClass( 'html-active' ) ) { |
948 |
initialResize( function() { |
|
949 |
adjust(); |
|
950 |
textEditorResize(); |
|
951 |
} ); |
|
952 |
} |
|
953 |
} |
|
954 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
// Show the on/off checkbox. |
5 | 956 |
$( '#adv-settings .editor-expand' ).show(); |
957 |
$( '#editor-expand-toggle' ).on( 'change.editor-expand', function() { |
|
958 |
if ( $(this).prop( 'checked' ) ) { |
|
959 |
on(); |
|
960 |
window.setUserSetting( 'editor_expand', 'on' ); |
|
961 |
} else { |
|
962 |
off(); |
|
963 |
window.setUserSetting( 'editor_expand', 'off' ); |
|
964 |
} |
|
965 |
}); |
|
966 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
// Expose on() and off(). |
5 | 968 |
window.editorExpand = { |
969 |
on: on, |
|
970 |
off: off |
|
971 |
}; |
|
972 |
} ); |
|
973 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
/** |
9 | 975 |
* Handles the distraction free writing of TinyMCE. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
* |
16 | 979 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
980 |
*/ |
5 | 981 |
$( function() { |
982 |
var $body = $( document.body ), |
|
983 |
$wrap = $( '#wpcontent' ), |
|
984 |
$editor = $( '#post-body-content' ), |
|
985 |
$title = $( '#title' ), |
|
986 |
$content = $( '#content' ), |
|
987 |
$overlay = $( document.createElement( 'DIV' ) ), |
|
988 |
$slug = $( '#edit-slug-box' ), |
|
989 |
$slugFocusEl = $slug.find( 'a' ) |
|
990 |
.add( $slug.find( 'button' ) ) |
|
991 |
.add( $slug.find( 'input' ) ), |
|
992 |
$menuWrap = $( '#adminmenuwrap' ), |
|
993 |
$editorWindow = $(), |
|
994 |
$editorIframe = $(), |
|
995 |
_isActive = window.getUserSetting( 'editor_expand', 'on' ) === 'on', |
|
996 |
_isOn = _isActive ? window.getUserSetting( 'post_dfw' ) === 'on' : false, |
|
997 |
traveledX = 0, |
|
998 |
traveledY = 0, |
|
999 |
buffer = 20, |
|
1000 |
faded, fadedAdminBar, fadedSlug, |
|
1001 |
editorRect, x, y, mouseY, scrollY, |
|
1002 |
focusLostTimer, overlayTimer, editorHasFocus; |
|
1003 |
||
1004 |
$body.append( $overlay ); |
|
1005 |
||
1006 |
$overlay.css( { |
|
1007 |
display: 'none', |
|
1008 |
position: 'fixed', |
|
1009 |
top: $adminBar.height(), |
|
1010 |
right: 0, |
|
1011 |
bottom: 0, |
|
1012 |
left: 0, |
|
1013 |
'z-index': 9997 |
|
1014 |
} ); |
|
1015 |
||
1016 |
$editor.css( { |
|
1017 |
position: 'relative' |
|
1018 |
} ); |
|
1019 |
||
1020 |
$window.on( 'mousemove.focus', function( event ) { |
|
1021 |
mouseY = event.pageY; |
|
1022 |
} ); |
|
1023 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
/** |
9 | 1025 |
* Recalculates the bottom and right position of the editor in the DOM. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1026 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1027 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1028 |
* |
16 | 1029 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1030 |
*/ |
5 | 1031 |
function recalcEditorRect() { |
1032 |
editorRect = $editor.offset(); |
|
1033 |
editorRect.right = editorRect.left + $editor.outerWidth(); |
|
1034 |
editorRect.bottom = editorRect.top + $editor.outerHeight(); |
|
1035 |
} |
|
1036 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
/** |
9 | 1038 |
* Activates the distraction free writing mode. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1039 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
* |
16 | 1042 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
*/ |
5 | 1044 |
function activate() { |
1045 |
if ( ! _isActive ) { |
|
1046 |
_isActive = true; |
|
1047 |
||
1048 |
$document.trigger( 'dfw-activate' ); |
|
1049 |
$content.on( 'keydown.focus-shortcut', toggleViaKeyboard ); |
|
1050 |
} |
|
1051 |
} |
|
1052 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1053 |
/** |
9 | 1054 |
* Deactivates the distraction free writing mode. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1055 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1056 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
* |
16 | 1058 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1059 |
*/ |
5 | 1060 |
function deactivate() { |
1061 |
if ( _isActive ) { |
|
1062 |
off(); |
|
1063 |
||
1064 |
_isActive = false; |
|
1065 |
||
1066 |
$document.trigger( 'dfw-deactivate' ); |
|
1067 |
$content.off( 'keydown.focus-shortcut' ); |
|
1068 |
} |
|
1069 |
} |
|
1070 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
/** |
9 | 1072 |
* Returns _isActive. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1074 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1075 |
* |
16 | 1076 |
* @return {boolean} Returns true is _isActive is true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
*/ |
5 | 1078 |
function isActive() { |
1079 |
return _isActive; |
|
1080 |
} |
|
1081 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
/** |
9 | 1083 |
* Binds events on the editor for distraction free writing. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
* |
16 | 1087 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
*/ |
5 | 1089 |
function on() { |
1090 |
if ( ! _isOn && _isActive ) { |
|
1091 |
_isOn = true; |
|
1092 |
||
1093 |
$content.on( 'keydown.focus', fadeOut ); |
|
1094 |
||
1095 |
$title.add( $content ).on( 'blur.focus', maybeFadeIn ); |
|
1096 |
||
1097 |
fadeOut(); |
|
1098 |
||
1099 |
window.setUserSetting( 'post_dfw', 'on' ); |
|
1100 |
||
1101 |
$document.trigger( 'dfw-on' ); |
|
1102 |
} |
|
1103 |
} |
|
1104 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
/** |
9 | 1106 |
* Unbinds events on the editor for distraction free writing. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
* |
16 | 1110 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
*/ |
5 | 1112 |
function off() { |
1113 |
if ( _isOn ) { |
|
1114 |
_isOn = false; |
|
1115 |
||
1116 |
$title.add( $content ).off( '.focus' ); |
|
1117 |
||
1118 |
fadeIn(); |
|
1119 |
||
1120 |
$editor.off( '.focus' ); |
|
1121 |
||
1122 |
window.setUserSetting( 'post_dfw', 'off' ); |
|
1123 |
||
1124 |
$document.trigger( 'dfw-off' ); |
|
1125 |
} |
|
1126 |
} |
|
1127 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
/** |
9 | 1129 |
* Binds or unbinds the editor expand events. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
* |
16 | 1133 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
*/ |
5 | 1135 |
function toggle() { |
1136 |
if ( _isOn ) { |
|
1137 |
off(); |
|
1138 |
} else { |
|
1139 |
on(); |
|
1140 |
} |
|
1141 |
} |
|
1142 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
/** |
9 | 1144 |
* Returns the value of _isOn. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1145 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1146 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1147 |
* |
16 | 1148 |
* @return {boolean} Returns true if _isOn is true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1149 |
*/ |
5 | 1150 |
function isOn() { |
1151 |
return _isOn; |
|
1152 |
} |
|
1153 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
/** |
9 | 1155 |
* Fades out all elements except for the editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1156 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
* The fading is done based on key presses and mouse movements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1158 |
* Also calls the fadeIn on certain key presses |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
* or if the mouse leaves the editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1162 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1163 |
* @param event The event that triggers this function. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
* |
16 | 1165 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1166 |
*/ |
5 | 1167 |
function fadeOut( event ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1168 |
var isMac, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1169 |
key = event && event.keyCode; |
5 | 1170 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1171 |
if ( window.navigator.platform ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1172 |
isMac = ( window.navigator.platform.indexOf( 'Mac' ) > -1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1173 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1174 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1175 |
// Fade in and returns on Escape and keyboard shortcut Alt+Shift+W and Ctrl+Opt+W. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1176 |
if ( key === 27 || ( key === 87 && event.altKey && ( ( ! isMac && event.shiftKey ) || ( isMac && event.ctrlKey ) ) ) ) { |
5 | 1177 |
fadeIn( event ); |
1178 |
return; |
|
1179 |
} |
|
1180 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1181 |
// Return if any of the following keys or combinations of keys is pressed. |
5 | 1182 |
if ( event && ( event.metaKey || ( event.ctrlKey && ! event.altKey ) || ( event.altKey && event.shiftKey ) || ( key && ( |
16 | 1183 |
// Special keys ( tab, ctrl, alt, esc, arrow keys... ). |
5 | 1184 |
( key <= 47 && key !== 8 && key !== 13 && key !== 32 && key !== 46 ) || |
16 | 1185 |
// Windows keys. |
5 | 1186 |
( key >= 91 && key <= 93 ) || |
16 | 1187 |
// F keys. |
5 | 1188 |
( key >= 112 && key <= 135 ) || |
16 | 1189 |
// Num Lock, Scroll Lock, OEM. |
5 | 1190 |
( key >= 144 && key <= 150 ) || |
16 | 1191 |
// OEM or non-printable. |
5 | 1192 |
key >= 224 |
1193 |
) ) ) ) { |
|
1194 |
return; |
|
1195 |
} |
|
1196 |
||
1197 |
if ( ! faded ) { |
|
1198 |
faded = true; |
|
1199 |
||
1200 |
clearTimeout( overlayTimer ); |
|
1201 |
||
1202 |
overlayTimer = setTimeout( function() { |
|
1203 |
$overlay.show(); |
|
1204 |
}, 600 ); |
|
1205 |
||
1206 |
$editor.css( 'z-index', 9998 ); |
|
1207 |
||
1208 |
$overlay |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1209 |
// Always recalculate the editor area when entering the overlay with the mouse. |
5 | 1210 |
.on( 'mouseenter.focus', function() { |
1211 |
recalcEditorRect(); |
|
1212 |
||
1213 |
$window.on( 'scroll.focus', function() { |
|
1214 |
var nScrollY = window.pageYOffset; |
|
1215 |
||
1216 |
if ( ( |
|
1217 |
scrollY && mouseY && |
|
1218 |
scrollY !== nScrollY |
|
1219 |
) && ( |
|
1220 |
mouseY < editorRect.top - buffer || |
|
1221 |
mouseY > editorRect.bottom + buffer |
|
1222 |
) ) { |
|
1223 |
fadeIn(); |
|
1224 |
} |
|
1225 |
||
1226 |
scrollY = nScrollY; |
|
1227 |
} ); |
|
1228 |
} ) |
|
1229 |
.on( 'mouseleave.focus', function() { |
|
1230 |
x = y = null; |
|
1231 |
traveledX = traveledY = 0; |
|
1232 |
||
1233 |
$window.off( 'scroll.focus' ); |
|
1234 |
} ) |
|
1235 |
// Fade in when the mouse moves away form the editor area. |
|
1236 |
.on( 'mousemove.focus', function( event ) { |
|
1237 |
var nx = event.clientX, |
|
1238 |
ny = event.clientY, |
|
1239 |
pageYOffset = window.pageYOffset, |
|
1240 |
pageXOffset = window.pageXOffset; |
|
1241 |
||
1242 |
if ( x && y && ( nx !== x || ny !== y ) ) { |
|
1243 |
if ( |
|
1244 |
( ny <= y && ny < editorRect.top - pageYOffset ) || |
|
1245 |
( ny >= y && ny > editorRect.bottom - pageYOffset ) || |
|
1246 |
( nx <= x && nx < editorRect.left - pageXOffset ) || |
|
1247 |
( nx >= x && nx > editorRect.right - pageXOffset ) |
|
1248 |
) { |
|
1249 |
traveledX += Math.abs( x - nx ); |
|
1250 |
traveledY += Math.abs( y - ny ); |
|
1251 |
||
1252 |
if ( ( |
|
1253 |
ny <= editorRect.top - buffer - pageYOffset || |
|
1254 |
ny >= editorRect.bottom + buffer - pageYOffset || |
|
1255 |
nx <= editorRect.left - buffer - pageXOffset || |
|
1256 |
nx >= editorRect.right + buffer - pageXOffset |
|
1257 |
) && ( |
|
1258 |
traveledX > 10 || |
|
1259 |
traveledY > 10 |
|
1260 |
) ) { |
|
1261 |
fadeIn(); |
|
1262 |
||
1263 |
x = y = null; |
|
1264 |
traveledX = traveledY = 0; |
|
1265 |
||
1266 |
return; |
|
1267 |
} |
|
1268 |
} else { |
|
1269 |
traveledX = traveledY = 0; |
|
1270 |
} |
|
1271 |
} |
|
1272 |
||
1273 |
x = nx; |
|
1274 |
y = ny; |
|
1275 |
} ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
// When the overlay is touched, fade in and cancel the event. |
5 | 1278 |
.on( 'touchstart.focus', function( event ) { |
1279 |
event.preventDefault(); |
|
1280 |
fadeIn(); |
|
1281 |
} ); |
|
1282 |
||
1283 |
$editor.off( 'mouseenter.focus' ); |
|
1284 |
||
1285 |
if ( focusLostTimer ) { |
|
1286 |
clearTimeout( focusLostTimer ); |
|
1287 |
focusLostTimer = null; |
|
1288 |
} |
|
1289 |
||
1290 |
$body.addClass( 'focus-on' ).removeClass( 'focus-off' ); |
|
1291 |
} |
|
1292 |
||
1293 |
fadeOutAdminBar(); |
|
1294 |
fadeOutSlug(); |
|
1295 |
} |
|
1296 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1297 |
/** |
9 | 1298 |
* Fades all elements back in. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
* @param event The event that triggers this function. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
* |
16 | 1304 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
*/ |
5 | 1306 |
function fadeIn( event ) { |
1307 |
if ( faded ) { |
|
1308 |
faded = false; |
|
1309 |
||
1310 |
clearTimeout( overlayTimer ); |
|
1311 |
||
1312 |
overlayTimer = setTimeout( function() { |
|
1313 |
$overlay.hide(); |
|
1314 |
}, 200 ); |
|
1315 |
||
1316 |
$editor.css( 'z-index', '' ); |
|
1317 |
||
1318 |
$overlay.off( 'mouseenter.focus mouseleave.focus mousemove.focus touchstart.focus' ); |
|
1319 |
||
1320 |
/* |
|
1321 |
* When fading in, temporarily watch for refocus and fade back out - helps |
|
1322 |
* with 'accidental' editor exits with the mouse. When fading in and the event |
|
1323 |
* is a key event (Escape or Alt+Shift+W) don't watch for refocus. |
|
1324 |
*/ |
|
1325 |
if ( 'undefined' === typeof event ) { |
|
1326 |
$editor.on( 'mouseenter.focus', function() { |
|
1327 |
if ( $.contains( $editor.get( 0 ), document.activeElement ) || editorHasFocus ) { |
|
1328 |
fadeOut(); |
|
1329 |
} |
|
1330 |
} ); |
|
1331 |
} |
|
1332 |
||
1333 |
focusLostTimer = setTimeout( function() { |
|
1334 |
focusLostTimer = null; |
|
1335 |
$editor.off( 'mouseenter.focus' ); |
|
1336 |
}, 1000 ); |
|
1337 |
||
1338 |
$body.addClass( 'focus-off' ).removeClass( 'focus-on' ); |
|
1339 |
} |
|
1340 |
||
1341 |
fadeInAdminBar(); |
|
1342 |
fadeInSlug(); |
|
1343 |
} |
|
1344 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
/** |
9 | 1346 |
* Fades in if the focused element based on it position. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
* |
16 | 1350 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
*/ |
5 | 1352 |
function maybeFadeIn() { |
1353 |
setTimeout( function() { |
|
1354 |
var position = document.activeElement.compareDocumentPosition( $editor.get( 0 ) ); |
|
1355 |
||
1356 |
function hasFocus( $el ) { |
|
1357 |
return $.contains( $el.get( 0 ), document.activeElement ); |
|
1358 |
} |
|
1359 |
||
1360 |
// The focused node is before or behind the editor area, and not outside the wrap. |
|
1361 |
if ( ( position === 2 || position === 4 ) && ( hasFocus( $menuWrap ) || hasFocus( $wrap ) || hasFocus( $footer ) ) ) { |
|
1362 |
fadeIn(); |
|
1363 |
} |
|
1364 |
}, 0 ); |
|
1365 |
} |
|
1366 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1367 |
/** |
9 | 1368 |
* Fades out the admin bar based on focus on the admin bar. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1369 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1370 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1371 |
* |
16 | 1372 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
*/ |
5 | 1374 |
function fadeOutAdminBar() { |
1375 |
if ( ! fadedAdminBar && faded ) { |
|
1376 |
fadedAdminBar = true; |
|
1377 |
||
1378 |
$adminBar |
|
1379 |
.on( 'mouseenter.focus', function() { |
|
1380 |
$adminBar.addClass( 'focus-off' ); |
|
1381 |
} ) |
|
1382 |
.on( 'mouseleave.focus', function() { |
|
1383 |
$adminBar.removeClass( 'focus-off' ); |
|
1384 |
} ); |
|
1385 |
} |
|
1386 |
} |
|
1387 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
/** |
9 | 1389 |
* Fades in the admin bar. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
* |
16 | 1393 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
*/ |
5 | 1395 |
function fadeInAdminBar() { |
1396 |
if ( fadedAdminBar ) { |
|
1397 |
fadedAdminBar = false; |
|
1398 |
||
1399 |
$adminBar.off( '.focus' ); |
|
1400 |
} |
|
1401 |
} |
|
1402 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
/** |
9 | 1404 |
* Fades out the edit slug box. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1407 |
* |
16 | 1408 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
*/ |
5 | 1410 |
function fadeOutSlug() { |
1411 |
if ( ! fadedSlug && faded && ! $slug.find( ':focus').length ) { |
|
1412 |
fadedSlug = true; |
|
1413 |
||
1414 |
$slug.stop().fadeTo( 'fast', 0.3 ).on( 'mouseenter.focus', fadeInSlug ).off( 'mouseleave.focus' ); |
|
1415 |
||
1416 |
$slugFocusEl.on( 'focus.focus', fadeInSlug ).off( 'blur.focus' ); |
|
1417 |
} |
|
1418 |
} |
|
1419 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1420 |
/** |
9 | 1421 |
* Fades in the edit slug box. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1422 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1423 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
* |
16 | 1425 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1426 |
*/ |
5 | 1427 |
function fadeInSlug() { |
1428 |
if ( fadedSlug ) { |
|
1429 |
fadedSlug = false; |
|
1430 |
||
1431 |
$slug.stop().fadeTo( 'fast', 1 ).on( 'mouseleave.focus', fadeOutSlug ).off( 'mouseenter.focus' ); |
|
1432 |
||
1433 |
$slugFocusEl.on( 'blur.focus', fadeOutSlug ).off( 'focus.focus' ); |
|
1434 |
} |
|
1435 |
} |
|
1436 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1437 |
/** |
9 | 1438 |
* Triggers the toggle on Alt + Shift + W. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
* Keycode 87 = w. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
* @param {event} event The event to trigger the toggle. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
* |
16 | 1446 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
*/ |
5 | 1448 |
function toggleViaKeyboard( event ) { |
1449 |
if ( event.altKey && event.shiftKey && 87 === event.keyCode ) { |
|
1450 |
toggle(); |
|
1451 |
} |
|
1452 |
} |
|
1453 |
||
1454 |
if ( $( '#postdivrich' ).hasClass( 'wp-editor-expand' ) ) { |
|
1455 |
$content.on( 'keydown.focus-shortcut', toggleViaKeyboard ); |
|
1456 |
} |
|
1457 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
/** |
9 | 1459 |
* Adds the distraction free writing button when setting up TinyMCE. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1460 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
* @param {event} event The TinyMCE editor setup event. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
* @param {object} editor The editor to add the button to. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
* |
16 | 1466 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1467 |
*/ |
5 | 1468 |
$document.on( 'tinymce-editor-setup.focus', function( event, editor ) { |
1469 |
editor.addButton( 'dfw', { |
|
1470 |
active: _isOn, |
|
1471 |
classes: 'wp-dfw btn widget', |
|
1472 |
disabled: ! _isActive, |
|
1473 |
onclick: toggle, |
|
1474 |
onPostRender: function() { |
|
1475 |
var button = this; |
|
1476 |
||
9 | 1477 |
editor.on( 'init', function() { |
1478 |
if ( button.disabled() ) { |
|
1479 |
button.hide(); |
|
1480 |
} |
|
1481 |
} ); |
|
1482 |
||
5 | 1483 |
$document |
1484 |
.on( 'dfw-activate.focus', function() { |
|
1485 |
button.disabled( false ); |
|
9 | 1486 |
button.show(); |
5 | 1487 |
} ) |
1488 |
.on( 'dfw-deactivate.focus', function() { |
|
1489 |
button.disabled( true ); |
|
9 | 1490 |
button.hide(); |
5 | 1491 |
} ) |
1492 |
.on( 'dfw-on.focus', function() { |
|
1493 |
button.active( true ); |
|
1494 |
} ) |
|
1495 |
.on( 'dfw-off.focus', function() { |
|
1496 |
button.active( false ); |
|
1497 |
} ); |
|
1498 |
}, |
|
1499 |
tooltip: 'Distraction-free writing mode', |
|
1500 |
shortcut: 'Alt+Shift+W' |
|
1501 |
} ); |
|
1502 |
||
1503 |
editor.addCommand( 'wpToggleDFW', toggle ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1504 |
editor.addShortcut( 'access+w', '', 'wpToggleDFW' ); |
5 | 1505 |
} ); |
1506 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1507 |
/** |
9 | 1508 |
* Binds and unbinds events on the editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1509 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1511 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1512 |
* @param {event} event The TinyMCE editor init event. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1513 |
* @param {object} editor The editor to bind events on. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1514 |
* |
16 | 1515 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1516 |
*/ |
5 | 1517 |
$document.on( 'tinymce-editor-init.focus', function( event, editor ) { |
1518 |
var mceBind, mceUnbind; |
|
1519 |
||
1520 |
function focus() { |
|
1521 |
editorHasFocus = true; |
|
1522 |
} |
|
1523 |
||
1524 |
function blur() { |
|
1525 |
editorHasFocus = false; |
|
1526 |
} |
|
1527 |
||
1528 |
if ( editor.id === 'content' ) { |
|
1529 |
$editorWindow = $( editor.getWin() ); |
|
1530 |
$editorIframe = $( editor.getContentAreaContainer() ).find( 'iframe' ); |
|
1531 |
||
1532 |
mceBind = function() { |
|
1533 |
editor.on( 'keydown', fadeOut ); |
|
1534 |
editor.on( 'blur', maybeFadeIn ); |
|
1535 |
editor.on( 'focus', focus ); |
|
1536 |
editor.on( 'blur', blur ); |
|
1537 |
editor.on( 'wp-autoresize', recalcEditorRect ); |
|
1538 |
}; |
|
1539 |
||
1540 |
mceUnbind = function() { |
|
1541 |
editor.off( 'keydown', fadeOut ); |
|
1542 |
editor.off( 'blur', maybeFadeIn ); |
|
1543 |
editor.off( 'focus', focus ); |
|
1544 |
editor.off( 'blur', blur ); |
|
1545 |
editor.off( 'wp-autoresize', recalcEditorRect ); |
|
1546 |
}; |
|
1547 |
||
1548 |
if ( _isOn ) { |
|
1549 |
mceBind(); |
|
1550 |
} |
|
1551 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1552 |
// Bind and unbind based on the distraction free writing focus. |
5 | 1553 |
$document.on( 'dfw-on.focus', mceBind ).on( 'dfw-off.focus', mceUnbind ); |
1554 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
1555 |
// Focus the editor when it is the target of the click event. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1556 |
editor.on( 'click', function( event ) { |
5 | 1557 |
if ( event.target === editor.getDoc().documentElement ) { |
1558 |
editor.focus(); |
|
1559 |
} |
|
1560 |
} ); |
|
1561 |
} |
|
1562 |
} ); |
|
1563 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1564 |
/** |
9 | 1565 |
* Binds events on quicktags init. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1566 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1567 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1568 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1569 |
* @param {event} event The quicktags init event. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1570 |
* @param {object} editor The editor to bind events on. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1571 |
* |
16 | 1572 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1573 |
*/ |
5 | 1574 |
$document.on( 'quicktags-init', function( event, editor ) { |
1575 |
var $button; |
|
1576 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1577 |
// Bind the distraction free writing events if the distraction free writing button is available. |
5 | 1578 |
if ( editor.settings.buttons && ( ',' + editor.settings.buttons + ',' ).indexOf( ',dfw,' ) !== -1 ) { |
1579 |
$button = $( '#' + editor.name + '_dfw' ); |
|
1580 |
||
1581 |
$( document ) |
|
1582 |
.on( 'dfw-activate', function() { |
|
1583 |
$button.prop( 'disabled', false ); |
|
1584 |
} ) |
|
1585 |
.on( 'dfw-deactivate', function() { |
|
1586 |
$button.prop( 'disabled', true ); |
|
1587 |
} ) |
|
1588 |
.on( 'dfw-on', function() { |
|
1589 |
$button.addClass( 'active' ); |
|
1590 |
} ) |
|
1591 |
.on( 'dfw-off', function() { |
|
1592 |
$button.removeClass( 'active' ); |
|
1593 |
} ); |
|
1594 |
} |
|
1595 |
} ); |
|
1596 |
||
1597 |
$document.on( 'editor-expand-on.focus', activate ).on( 'editor-expand-off.focus', deactivate ); |
|
1598 |
||
1599 |
if ( _isOn ) { |
|
1600 |
$content.on( 'keydown.focus', fadeOut ); |
|
1601 |
||
1602 |
$title.add( $content ).on( 'blur.focus', maybeFadeIn ); |
|
1603 |
} |
|
1604 |
||
1605 |
window.wp = window.wp || {}; |
|
1606 |
window.wp.editor = window.wp.editor || {}; |
|
1607 |
window.wp.editor.dfw = { |
|
1608 |
activate: activate, |
|
1609 |
deactivate: deactivate, |
|
1610 |
isActive: isActive, |
|
1611 |
on: on, |
|
1612 |
off: off, |
|
1613 |
toggle: toggle, |
|
1614 |
isOn: isOn |
|
1615 |
}; |
|
1616 |
} ); |
|
1617 |
} )( window, window.jQuery ); |