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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
/* Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.plugins.add( 'contextmenu', { requires : [ 'menu' ], // Make sure the base class (CKEDITOR.menu) is loaded before it (#3318). onLoad : function() { CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( { base : CKEDITOR.menu, $ : function( editor ) { this.base.call( this, editor, { panel: { className : editor.skinClass + ' cke_contextmenu', attributes : { 'aria-label' : editor.lang.contextmenu.options } } }); }, proto : { addTarget : function( element, nativeContextMenuOnCtrl ) { // Opera doesn't support 'contextmenu' event, we have duo approaches employed here: // 1. Inherit the 'button override' hack we introduced in v2 (#4530), while this require the Opera browser // option 'Allow script to detect context menu/right click events' to be always turned on. // 2. Considering the fact that ctrl/meta key is not been occupied // for multiple range selecting (like Gecko), we use this key // combination as a fallback for triggering context-menu. (#4530) if ( CKEDITOR.env.opera && !( 'oncontextmenu' in document.body )) { var contextMenuOverrideButton; element.on( 'mousedown', function( evt ) { evt = evt.data; if ( evt.$.button != 2 ) { if ( evt.getKeystroke() == CKEDITOR.CTRL + 1 ) element.fire( 'contextmenu', evt ); return; } if ( nativeContextMenuOnCtrl && ( CKEDITOR.env.mac ? evt.$.metaKey : evt.$.ctrlKey ) ) return; var target = evt.getTarget(); if ( !contextMenuOverrideButton ) { var ownerDoc = target.getDocument(); contextMenuOverrideButton = ownerDoc.createElement( 'input' ) ; contextMenuOverrideButton.$.type = 'button' ; ownerDoc.getBody().append( contextMenuOverrideButton ) ; } contextMenuOverrideButton.setAttribute( 'style', 'position:absolute;top:' + ( evt.$.clientY - 2 ) + 'px;left:' + ( evt.$.clientX - 2 ) + 'px;width:5px;height:5px;opacity:0.01' ); } ); element.on( 'mouseup', function ( evt ) { if ( contextMenuOverrideButton ) { contextMenuOverrideButton.remove(); contextMenuOverrideButton = undefined; // Simulate 'contextmenu' event. element.fire( 'contextmenu', evt.data ); } } ); } element.on( 'contextmenu', function( event ) { var domEvent = event.data; if ( nativeContextMenuOnCtrl && // Safari on Windows always show 'ctrlKey' as true in 'contextmenu' event, // which make this property unreliable. (#4826) ( CKEDITOR.env.webkit ? holdCtrlKey : ( CKEDITOR.env.mac ? domEvent.$.metaKey : domEvent.$.ctrlKey ) ) ) return; // Cancel the browser context menu. domEvent.preventDefault(); var offsetParent = domEvent.getTarget().getDocument().getDocumentElement(), offsetX = domEvent.$.clientX, offsetY = domEvent.$.clientY; CKEDITOR.tools.setTimeout( function() { this.open( offsetParent, null, offsetX, offsetY ); // IE needs a short while to allow selection change before opening menu. (#7908) }, CKEDITOR.env.ie? 200 : 0, this ); }, this ); if ( CKEDITOR.env.opera ) { // 'contextmenu' event triggered by Windows menu key is unpreventable, // cancel the key event itself. (#6534) element.on( 'keypress' , function ( evt ) { var domEvent = evt.data; if ( domEvent.$.keyCode === 0 ) domEvent.preventDefault(); }); } if ( CKEDITOR.env.webkit ) { var holdCtrlKey, onKeyDown = function( event ) { holdCtrlKey = CKEDITOR.env.mac ? event.data.$.metaKey : event.data.$.ctrlKey ; }, resetOnKeyUp = function() { holdCtrlKey = 0; }; element.on( 'keydown', onKeyDown ); element.on( 'keyup', resetOnKeyUp ); element.on( 'contextmenu', resetOnKeyUp ); } }, open : function( offsetParent, corner, offsetX, offsetY ) { this.editor.focus(); offsetParent = offsetParent || CKEDITOR.document.getDocumentElement(); this.show( offsetParent, corner, offsetX, offsetY ); } } }); }, beforeInit : function( editor ) { editor.contextMenu = new CKEDITOR.plugins.contextMenu( editor ); editor.addCommand( 'contextMenu', { exec : function() { editor.contextMenu.open( editor.document.getBody() ); } }); } }); /** * Whether to show the browser native context menu when the <em>Ctrl</em> or * <em>Meta</em> (Mac) key is pressed on opening the context menu with the * right mouse button click or the <em>Menu</em> key. * @name CKEDITOR.config.browserContextMenuOnCtrl * @since 3.0.2 * @type Boolean * @default <code>true</code> * @example * config.browserContextMenuOnCtrl = false; */ |
Commits for namibiapublic/scripts/ckeditor/_source/plugins/contextmenu/plugin.js
Revision | Author | Commited | Message |
---|---|---|---|
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |