https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112268

Revision: 112268
Author:   inez
Date:     2012-02-23 23:20:35 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
Recogonize if input came from spellcheck or from keyboard (Chrome)

Modified Paths:
--------------
    trunk/extensions/VisualEditor/demos/playground/playground.js

Modified: trunk/extensions/VisualEditor/demos/playground/playground.js
===================================================================
--- trunk/extensions/VisualEditor/demos/playground/playground.js        
2012-02-23 23:19:44 UTC (rev 112267)
+++ trunk/extensions/VisualEditor/demos/playground/playground.js        
2012-02-23 23:20:35 UTC (rev 112268)
@@ -32,9 +32,9 @@
        this.$editor.html("<b>Lorem Ipsum is simply dummy text</b> of the 
printing and typesetting industry. <b>Lorem Ipsum has been the 
<i>industry's</i> standard</b> dummy text ever since the 1500s, when an unknown 
printer took a galley of type and scrambled it <u>to <b>make <i>a type</i> 
specimen</b> book.</u>");
        this.$editor.addClass('leafNode');
 
+       this.keydown = false;
+       this.keyup = false;
        this.keypress = false;
-       this.keyup = false;
-       this.keydown = false;
        this.mousedown = false;
        this.inime = false;
        this.prevText = app.getDOMText(this.$editor[0]);
@@ -44,31 +44,31 @@
        }, 100);
 };
 
-app.prototype.onKeyPress = function() {
-       //console.log("onKeyPress");
-       this.keypress = true;
+app.prototype.onKeyDown = function( e ) {
+       console.log("onKeyDown");
+       this.keydown = true;
        if ( e.which === 229 ) {
                this.inime = true;
-       }       
+       }
 };
 
-app.prototype.onKeyUp = function() {
-       //console.log("onKeyUp");
+app.prototype.onKeyUp = function( e ) {
+       console.log("onKeyUp");
        this.keyup = true;
        if ( this.inime ) {
                this.inime = false;
        }
 };
 
-app.prototype.onKeyDown = function( e ) {
-       //console.log("onKeyDown");
-       this.keydown = true;
+app.prototype.onKeyPress = function( e ) {
+       //console.log("onKeyPress");
+       this.keypress = true;
        if ( e.which === 229 ) {
                this.inime = true;
-       }
+       }       
 };
 
-app.prototype.onMouseDown = function() {
+app.prototype.onMouseDown = function( e ) {
        this.mousedown = true;
 
        if ( this.inime ) {
@@ -81,6 +81,24 @@
 
        if(text != this.prevText) {
 
+               console.log("text is different");
+               
+               if(this.keydown) {
+                       console.log("keyboard");
+               } else {
+                       console.log("not keyboard");
+               }
+
+               this.prevText = text;
+       }
+       
+       this.keypress = false;
+       this.keyup = false;
+       this.keydown = false;
+       this.mousedown = false;
+
+       /*
+
                var selection = rangy.getSelection();
 
 
@@ -116,6 +134,7 @@
        this.keyup = false;
        this.keydown = false;
        this.mousedown = false;
+       */
 };
 
 app.getDOMText = function( elem ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to