r110882 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110881‎ | r110882 | r110883 >
Date:22:15, 7 February 2012
Author:christian
Status:deferred
Tags:
Comment:
test page for copy and paste support
Modified paths:
  • /trunk/extensions/VisualEditor/cut-copy-paste.html (added) (history)
  • /trunk/extensions/VisualEditor/cut-copy-paste.js (added) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/cut-copy-paste.html
@@ -0,0 +1,16 @@
 2+<!doctype html>
 3+<html>
 4+<head>
 5+ <title>-----cut-----copy-----paste-----</title>
 6+ <script src="modules/jquery/jquery.js"></script>
 7+ <script src="contentEditable/rangy/rangy-core.js"></script>
 8+ <script src="cut-copy-paste.js"></script>
 9+</head>
 10+<body>
 11+ <div id="editor" contenteditable="true">
 12+ <p>Here is some text. I dare you to mess with me.</p>
 13+ <p>More text here. Don't you dare!</p>
 14+ </div>
 15+ <div id="paste" contenteditable="true" style="height: 1px; width: 1px; position: absolute; left: -20000px;"></div>
 16+</body>
 17+</html>
\ No newline at end of file
Index: trunk/extensions/VisualEditor/cut-copy-paste.js
@@ -0,0 +1,31 @@
 2+$(function() {
 3+ var paste = {};
 4+
 5+ $('#editor')
 6+ .on('copy', function(event) {
 7+ var range = rangy.getSelection().getRangeAt(0);
 8+ var key = range.toString().replace(/( |\r\n|\n|\r|\t)/gm,"");
 9+
 10+ paste = {};
 11+ paste[key] = 'some wikidom';
 12+ })
 13+ .on('paste', function(event) {
 14+ $('#paste').html('');
 15+ $('#paste').focus();
 16+
 17+ setTimeout(function() {
 18+ var key = $('#paste').text().replace(/( |\r\n|\n|\r|\t)/gm,"");
 19+
 20+ console.log(paste);
 21+
 22+ if (paste[key]) {
 23+ alert('you pasted from wikidom');
 24+ } else {
 25+ alert('i don\'t know where you pasted from');
 26+ }
 27+
 28+ }, 1);
 29+ });
 30+
 31+
 32+});
\ No newline at end of file
Property changes on: trunk/extensions/VisualEditor/cut-copy-paste.js
___________________________________________________________________
Added: svn:eol-style
133 + native

Status & tagging log