r110984 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110983‎ | r110984 | r110985 >
Date:23:37, 8 February 2012
Author:christian
Status:deferred
Tags:
Comment:
paste handler no longer causes fast viewport shift when pasting
Modified paths:
  • /trunk/extensions/VisualEditor/demos/ce/index.php (modified) (history)
  • /trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/demos/ce/index.php
@@ -157,6 +157,6 @@
158158 <!-- sandbox -->
159159 <script src="main.js"></script>
160160
161 - <div id="paste" contenteditable="true" style="height: 1px; width: 1px; position: absolute; left: -20000px;"></div>
 161+ <div id="paste" contenteditable="true" style="height: 1px; width: 1px; display: none; opacity: 0; position: absolute;"></div>
162162 </body>
163163 </html>
Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
@@ -55,19 +55,15 @@
5656 var insertionPoint = _this.getSelection().start;
5757 console.log(_this.clipboard);
5858
59 - var scrollTop = $(window).scrollTop();
 59+ $('#paste').html('').show().css('top', $(window).scrollTop()).css('left', $(window).scrollLeft()).focus();
6060
61 - $('#paste').html('');
62 - $('#paste').focus();
63 -
6461 setTimeout(function() {
65 - var key = $('#paste').text().replace(/( |\r\n|\n|\r|\t)/gm,"");
 62+ var key = $('#paste').hide().text().replace(/( |\r\n|\n|\r|\t)/gm,"");
6663
6764 if (_this.clipboard[key]) {
6865 var tx = _this.documentView.model.prepareInsertion( insertionPoint, _this.clipboard[key]);
6966 _this.documentView.model.commit(tx);
7067 _this.showCursorAt(insertionPoint + _this.clipboard[key].length);
71 - $(window).scrollTop(scrollTop);
7268 } else {
7369 alert('i can only handle copy/paste from hybrid surface. sorry. :(');
7470 }

Status & tagging log