JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / core / dom / event.js
index 765c82c..273a5cf 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2009, 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
@@ -87,13 +87,18 @@ CKEDITOR.dom.event.prototype =
                        $.returnValue = false;\r
 \r
                if ( stopPropagation )\r
-               {\r
-                       if ( $.stopPropagation )\r
-                               $.stopPropagation();\r
-                       else\r
-                               $.cancelBubble = true;\r
-               }\r
+                       this.stopPropagation();\r
        },\r
+\r
+       stopPropagation : function()\r
+       {\r
+               var $ = this.$;\r
+               if ( $.stopPropagation )\r
+                       $.stopPropagation();\r
+               else\r
+                       $.cancelBubble = true;\r
+       },\r
+\r
        /**\r
         * Returns the DOM node where the event was targeted to.\r
         * @returns {CKEDITOR.dom.node} The target DOM node.\r
@@ -112,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