218 | | var scroll; |
219 | | // IE fires the "selectionchange" event when clicking |
220 | | // inside a selection. We don't want to capture that. |
221 | | body.on( 'mousedown', function( evt ) |
222 | | { |
223 | | // IE scrolls document to top on right mousedown |
224 | | // when editor has no focus, remember this scroll |
225 | | // position and revert it before context menu opens. (#5778) |
226 | | if ( evt.data.$.button == 2 ) |
227 | | { |
228 | | var sel = editor.document.$.selection; |
229 | | if ( sel.type == 'None' ) |
230 | | scroll = editor.window.getScrollPosition(); |
231 | | } |
232 | | disableSave(); |
233 | | }); |
234 | | |
235 | | body.on( 'mouseup', |
236 | | function( evt ) |
237 | | { |
238 | | // Restore recorded scroll position when needed on right mouseup. |
239 | | if ( evt.data.$.button == 2 && scroll ) |
240 | | { |
241 | | editor.document.$.documentElement.scrollLeft = scroll.x; |
242 | | editor.document.$.documentElement.scrollTop = scroll.y; |
243 | | } |
244 | | scroll = null; |
245 | | |
246 | | saveEnabled = 1; |
247 | | setTimeout( function() |
248 | | { |
249 | | saveSelection( true ); |
250 | | }, |
251 | | 0 ); |
252 | | }); |
253 | | |
254 | | body.on( 'keydown', disableSave ); |
255 | | body.on( 'keyup', |
256 | | function() |
257 | | { |
258 | | saveEnabled = 1; |
259 | | saveSelection(); |
260 | | }); |
261 | | |
262 | | |
263 | | // IE is the only to provide the "selectionchange" |
264 | | // event. |
265 | | doc.on( 'selectionchange', saveSelection ); |
266 | | |