JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / core / dom / event.js
index cf7d66c..273a5cf 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -117,26 +117,49 @@ CKEDITOR.dom.event.prototype =
        {\r
                var rawNode = this.$.target || this.$.srcElement;\r
                return rawNode ? new CKEDITOR.dom.node( rawNode ) : null;\r
+       },\r
+\r
+       /**\r
+        * Retrieves the coordinates of the mouse pointer relative to the top-left\r
+        * corner of the document, in mouse related event.\r
+        * @returns {Object} The object contains the position.\r
+        * @example\r
+        * element.on( 'mousemouse', function( ev )\r
+        *     {\r
+        *         var pageOffset = ev.data.getPageOffset();\r
+        *         alert( pageOffset.x ); // page offset X\r
+        *         alert( pageOffset.y ); // page offset Y\r
+        *     });\r
+        */\r
+       getPageOffset : function()\r
+       {\r
+               var doc = this.getTarget().getDocument().$;\r
+               var pageX = this.$.pageX || this.$.clientX + ( doc.documentElement.scrollLeft || doc.body.scrollLeft );\r
+               var pageY = this.$.pageY || this.$.clientY + ( doc.documentElement.scrollTop || doc.body.scrollTop );\r
+               return { x : pageX, y : pageY };\r
        }\r
 };\r
 \r
+// For the followind constants, we need to go over the Unicode boundaries\r
+// (0x10FFFF) to avoid collision.\r
+\r
 /**\r
- * CTRL key (1000).\r
+ * CTRL key (0x110000).\r
  * @constant\r
  * @example\r
  */\r
-CKEDITOR.CTRL = 1000;\r
+CKEDITOR.CTRL = 0x110000;\r
 \r
 /**\r
- * SHIFT key (2000).\r
+ * SHIFT key (0x220000).\r
  * @constant\r
  * @example\r
  */\r
-CKEDITOR.SHIFT = 2000;\r
+CKEDITOR.SHIFT = 0x220000;\r
 \r
 /**\r
- * ALT key (4000).\r
+ * ALT key (0x440000).\r
  * @constant\r
  * @example\r
  */\r
-CKEDITOR.ALT = 4000;\r
+CKEDITOR.ALT = 0x440000;\r