namibia
df0489e1eeeeab5a9bd44e1d84fce49924fe1bac
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
/* Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.event} class, which * represents the a native DOM event object. */ /** * Represents a native DOM event object. * @constructor * @param {Object} domEvent A native DOM event object. * @example */ CKEDITOR.dom.event = function( domEvent ) { /** * The native DOM event object represented by this class instance. * @type Object * @example */ this.$ = domEvent; }; CKEDITOR.dom.event.prototype = { /** * Gets the key code associated to the event. * @returns {Number} The key code. * @example * alert( event.getKey() ); "65" is "a" has been pressed */ getKey : function() { return this.$.keyCode || this.$.which; }, /** * Gets a number represeting the combination of the keys pressed during the * event. It is the sum with the current key code and the {@link CKEDITOR.CTRL}, * {@link CKEDITOR.SHIFT} and {@link CKEDITOR.ALT} constants. * @returns {Number} The number representing the keys combination. * @example * alert( event.getKeystroke() == 65 ); // "a" key * alert( event.getKeystroke() == CKEDITOR.CTRL + 65 ); // CTRL + "a" key * alert( event.getKeystroke() == CKEDITOR.CTRL + CKEDITOR.SHIFT + 65 ); // CTRL + SHIFT + "a" key */ getKeystroke : function() { var keystroke = this.getKey(); if ( this.$.ctrlKey || this.$.metaKey ) keystroke += CKEDITOR.CTRL; if ( this.$.shiftKey ) keystroke += CKEDITOR.SHIFT; if ( this.$.altKey ) keystroke += CKEDITOR.ALT; return keystroke; }, /** * Prevents the original behavior of the event to happen. It can optionally * stop propagating the event in the event chain. * @param {Boolean} [stopPropagation] Stop propagating this event in the * event chain. * @example * var element = CKEDITOR.document.getById( 'myElement' ); * element.on( 'click', function( ev ) * { * // The DOM event object is passed by the "data" property. * var domEvent = ev.data; * // Prevent the click to chave any effect in the element. * domEvent.preventDefault(); * }); */ preventDefault : function( stopPropagation ) { var $ = this.$; if ( $.preventDefault ) $.preventDefault(); else $.returnValue = false; if ( stopPropagation ) this.stopPropagation(); }, stopPropagation : function() { var $ = this.$; if ( $.stopPropagation ) $.stopPropagation(); else $.cancelBubble = true; }, /** * Returns the DOM node where the event was targeted to. * @returns {CKEDITOR.dom.node} The target DOM node. * @example * var element = CKEDITOR.document.getById( 'myElement' ); * element.on( 'click', function( ev ) * { * // The DOM event object is passed by the "data" property. * var domEvent = ev.data; * // Add a CSS class to the event target. * domEvent.getTarget().addClass( 'clicked' ); * }); */ getTarget : function() { var rawNode = this.$.target || this.$.srcElement; return rawNode ? new CKEDITOR.dom.node( rawNode ) : null; } }; // For the followind constants, we need to go over the Unicode boundaries // (0x10FFFF) to avoid collision. /** * CTRL key (0x110000). * @constant * @example */ CKEDITOR.CTRL = 0x110000; /** * SHIFT key (0x220000). * @constant * @example */ CKEDITOR.SHIFT = 0x220000; /** * ALT key (0x440000). * @constant * @example */ CKEDITOR.ALT = 0x440000; |
Commits for namibiapublic/scripts/ckeditor/_source/core/dom/event.js
Revision | Author | Commited | Message |
---|---|---|---|
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |