X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fevent.js;h=273a5cfdbff39c2f6103ebcc19e218ddd5ae26c9;hb=3fe9cac293e090ea459a3ee10d78cbe9e1dd0e03;hp=e8a1e1249e4a4a3dd134016335bdf95ce8cbf5de;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d;p=ckeditor.git diff --git a/_source/core/dom/event.js b/_source/core/dom/event.js index e8a1e12..273a5cf 100644 --- a/_source/core/dom/event.js +++ b/_source/core/dom/event.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -117,26 +117,49 @@ CKEDITOR.dom.event.prototype = { var rawNode = this.$.target || this.$.srcElement; return rawNode ? new CKEDITOR.dom.node( rawNode ) : null; + }, + + /** + * Retrieves the coordinates of the mouse pointer relative to the top-left + * corner of the document, in mouse related event. + * @returns {Object} The object contains the position. + * @example + * element.on( 'mousemouse', function( ev ) + * { + * var pageOffset = ev.data.getPageOffset(); + * alert( pageOffset.x ); // page offset X + * alert( pageOffset.y ); // page offset Y + * }); + */ + getPageOffset : function() + { + var doc = this.getTarget().getDocument().$; + var pageX = this.$.pageX || this.$.clientX + ( doc.documentElement.scrollLeft || doc.body.scrollLeft ); + var pageY = this.$.pageY || this.$.clientY + ( doc.documentElement.scrollTop || doc.body.scrollTop ); + return { x : pageX, y : pageY }; } }; +// For the followind constants, we need to go over the Unicode boundaries +// (0x10FFFF) to avoid collision. + /** - * CTRL key (1000). + * CTRL key (0x110000). * @constant * @example */ -CKEDITOR.CTRL = 1000; +CKEDITOR.CTRL = 0x110000; /** - * SHIFT key (2000). + * SHIFT key (0x220000). * @constant * @example */ -CKEDITOR.SHIFT = 2000; +CKEDITOR.SHIFT = 0x220000; /** - * ALT key (4000). + * ALT key (0x440000). * @constant * @example */ -CKEDITOR.ALT = 4000; +CKEDITOR.ALT = 0x440000;